1.4.10 • Published 1 year ago

@verityguard/emblem-sdk-client v1.4.10

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Emblem SDK Client

Client SDK for interacting with the Emblem API

Installation

npm install @verityguard/emblem-sdk-client

or

yarn add @verityguard/emblem-sdk-client

Usage

import React, { useRef } from 'react';
import { EmblemButton } from '@verityguard/emblem-sdk-client';

function App() {
  const closeWindowRef = useRef<() => void>();

  useEffect(() => {
    if (completed) {
      closeWindowRef.current?.();
    }
  }, [completed]);

  return (
    <div>
      <EmblemButton
        url="https://emblem.generflow.com"
        projectKey="public_key_1234"
        state="state1234"
        style={{ marginRight: "1rem", border: "1px solid gray" }}
        postbackUrl="https://example.com/postback"
        postbackHeaders={JSON.stringify({ 'x-gateway': 'abcd-1234' })}
        onSuccessUrl="https://example.com/redirect"
        onClickCallback={() => console.log("onClick callback")}
        assignCloseWindow={(closeFn) => {
          closeWindowRef.current = closeFn;
        }}
      />
    </div>
  );
}

export default App;

EmblemButton Props

PropTypeRequiredDescription
urlstringtrueEmblem host url
projectKeystringtrueProject key is provided by Emblem
statestringtrueState is a unique identifier for the user provided by the integrator (you). This can be JSON encoded if you want to store more data with it. Emblem will pass this string along through every step
postbackUrlstringtrueURL that Emblem will send a POST request to after the user completes the age verification flow
postbackHeadersstringfalseJSON stringified object that will be url encoded within the button component. These headers will be included with the POST request
postbackOverridebooleanfalseIf true, only the postback will be sent. The POST to the project key's verification url will not be sent
onSuccessUrlstringfalseIf provided the user will be redirected to this url on successful verification
onClickCallbackfunctionfalseThis function will be called in addition to opening the Emblem window
labelstringfalseCustom button text
classNamestringfalseCustom CSS class
styleobjectfalseCustom style object
assignCloseWindow(closeFunc: () => void) => voidfalseAllows implementers to receive a function that can be used to programmatically close the opened Emblem window on-demand

interface Props {
  url: string;
  projectKey: string;
  state: string;
  postbackUrl: string;
  postbackHeaders?: string;
  postbackOverride?: boolean; 
  onSuccessUrl?: string;
  onClickCallback?: () => void;
  label?: string;
  className?: string;
  style?: CSSProperties;
  assignCloseWindow?: (closeFunc: () => void) => void;
}

Contributing

If you have suggestions for how emblem-sdk-client could be improved, or want to report a bug, open an issue! We'd love all and any contributions.

1.4.10

1 year ago

1.4.9-1

1 year ago

1.4.9

1 year ago

1.4.8

1 year ago

1.4.7

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago