1.0.0 • Published 1 year ago

@frollo/frollo-connect-sdk v1.0.0

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

Frollo Connect SDK

build npm bundle size npm

A JavaScript SDK for linking Frollo Link Web as a popup app.

Installation

npm i @frollo/frollo-connect-sdk

or

yarn add @frollo/frollo-connect-sdk

Import as a module

import { openFrolloLink } from '@frollo/frollo-connect-sdk';

openFrolloLink(options)

Direct Browser usage

Reference any one of the CDN scripts in your html
<!-- JSDelivr CDN -->
<script src="https://cdn.jsdelivr.net/npm/@frollo/frollo-connect-sdk"></script>

<!-- UnPkg CDN -->
<script src="https://unpkg.com/@frollo/frollo-connect-sdk"></script>
Then call the function on a user interaction event
FrolloConnectSdk.openFrolloLink(options);

Configuration options

{
  url: string;
  type: 'collection' | 'disclosure' | 'collection,disclosure' | 'dashboard';
  authorisation_code?: string;
  callback?: (arg0: { status: string; description: string } | string) => void | FunctionStringCallback;
  context?: string;
  external_party_id?: number | string;
}
url

Base url of client's Frollo Link Web environment.

type

Type of Consent to be provided.

authorisation_code

Authorisation code used for passwordless authentication. See Get User Passwordless Authentication Token.

callback

The callback is fired when a flow has completed, failed or ended. More info about the callback below.

context

Provide a context string identifier that all Collection Consents linked during a flow will be attributed with. Only applies to the Collection Consent flow and one will be generated automatically if not provided.

external_party_id

Unique ID of the External Party to disclose to. Only applies to the Disclosure Consent flow.

More info - Frollo Link Web developer portal

Callback

function linkCallback(data) {
  if (data === 'collection-consent-started') { // Consent created
    console.info('Consent partially linked');
  }
  if (data === 'linking-completed') { // Consent created and context updated
    console.info('Consent successfully linked');
  }
  if (data === 'disclose-consent-completed') { // Disclosure consent created
    console.info('Disclosure consent successfully linked');
  }
  if (data === 'failed') { // Consent failed (user can retry)
    console.info('Failed to link');
  }
  if (data.status === 'cancelled') { // Popup closed and description provided
    // description = 'Window closed' | 'Invalid origin' | 'manual-application'
    console.info(data.status, data.description);
  }
}

Note: For local development please refer to the general development readme.