1.0.3 • Published 9 months ago

@signitsa/signitsa-embedded v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Signit Embedded

Embed Signit signature requests and templates from within your web application.

Npm version Npm downloads Npm minified

Usage

The instructions below are for Signit Embedded.

Start by installing the Signit Embedded library from npm.

  • Via npm:
npm install @signitsa/signitsa-embedded
  • Via yarn:
yarn add @signitsa/signitsa-embedded
  • Via pnpm:
pnpm add @signitsa/signitsa-embedded
  • using jsDelivr:

If you prefer to load the library via CDN, you can use jsDelivr.

<script src="https://cdn.jsdelivr.net/npm/@signitsa/signitsa-embedded"></script>
  • using unpkg:

Alternatively, you can also load the library from unpkg:

<script src="https://unpkg.com/@signitsa/signitsa-embedded"></script>

In app usage

In your frontend app, import @signitsa/signitsa-embedded and instantiate a new client with your API app's client ID.

import SignitEmbedded from '@signitsa/signitsa-embedded';

// Create the Signit Embedded instance.
// Only do this once!
const client = new SignitEmbedded({
  clientId: 'Your client ID',
  debug: true,
  locale: SignitEmbedded.locales.EN_US,
  // Add other configuration options as needed
});

When you're ready to launch Signit Embedded, simply call open() on the client with your signature request's signing URL.

function launchSignitEmbedded(url) {
  client.open(url, options);
}

launchSignitEmbedded(url);

Usage with CDN

After including the library via CDN (jsDelivr or unpkg), you can use SignitEmbedded directly in your JavaScript. Here's a breakdown of how to set it up if you are using the package with a CDN.

Step 1: Add the CDN Script Tag

Add the SignitEmbedded script from jsDelivr or unpkg in your HTML file, ideally at the end of the <body> tag to ensure it loads after the rest of your HTML:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>SignitEmbedded Example</title>
  </head>
  <body>
    <!-- SignitEmbedded library (from jsDelivr or unpkg) -->
    <script src="https://cdn.jsdelivr.net/npm/@signitsa/signitsa-embedded"></script>
    <!-- OR use unpkg if preferred -->
    <!-- <script src="https://unpkg.com/@signitsa/signitsa-embedded"></script> -->

    <!-- Initialize SignitEmbedded -->
    <script>
      // Step 2: Initialize SignitEmbedded after the script loads
      document.addEventListener('DOMContentLoaded', function () {
        // Access SignitEmbedded from the global window object
        const client = new window.SignitEmbedded.default({
          clientId: YOUR_CLIENT_ID,
          allowCancel: true,
          debug: false,
          hideHeader: false,
          timeout: 999999,
          // Add other configuration options as needed
        });
        client.open(EMBEDDED_URL, {
          whiteLabeling: {
            theme: {
              lightPrimary: 'green',
              darkPrimary: 'blue',
            },
          },
          // Add other configuration options as needed
        });
      });
    </script>
  </body>
</html>

Explanation

  1. Script Tag Inclusion: The <script src="..."> tag loads the SignitEmbedded library from the specified CDN (either jsDelivr or unpkg). This makes the library accessible globally through the window object.

  2. DOMContentLoaded Event: The DOMContentLoaded event listener ensures that the script initializes only after the HTML content has fully loaded. This prevents issues where the library might attempt to access elements that haven't rendered yet.

  3. Accessing SignitEmbedded: When loading from a CDN, SignitEmbedded is available on the window object (e.g., window.SignitEmbedded). You can use this to create a new instance and configure it with options like clientId.

For more information on how to use Signit Embedded, visit the API Documentation.

Support

If you have any questions or issues with Signit Embedded or our API, please contact hala@signit.sa.

Resources

© 2024 Signit. All rights reserved.

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

10 months ago

1.0.0

10 months ago

1.0.6

10 months ago

1.0.5

1 year ago