@benji-money/connect-sdk
v1.0.9
Published
Benji Connect SDK for authentication and verification
Readme
Benji Connect Web SDK
A JavaScript Github Package SDK for integrating Benji Connect, Benji's authentication and verification services.
Installation
# If you're using npm
npm install @benji-money/connect-sdk
# If you're using yarn
yarn add @benji-money/connect-sdkUsage
ESM + CJS
import { ConnectSDK } from "@benji-money/connect-sdk";
const sdk = new ConnectSDK({
environment: "production", // or "sandbox" | "development",
token: "your-connect-token",
// token: string, metadata: BenjiConnectOnSuccessMetadata
onSuccess: (token, metadata) => {
console.log("✅ Benji Connect onSuccess");
},
// error: Error, error_id: string, metadata: BenjiConnectMetadata
onError: (error, error_id, metadata) => {
console.log("🛑 Benji Connect onError");
},
// metadata: BenjiConnectOnExitMetadata
onExit: (metadata) => {
console.log("🚪 Benji Connect onExit");
},
// type: BenjiConnectEventType, metadata: BenjiConnectMetadata
onEvent: (type, metadata) => {
console.log("📨 Benji Connect onEvent (type)");
},
});
// Open the authentication flow UI
sdk.open();Demo example here.
UMD (Script Tag)
<script src="/path/to/connect-sdk.umd.js"></script>
<script>
const sdk = new ConnectSDK({
environment: "production", // or "sandbox" | "development",
token: "your-connect-token",
onSuccess: (token, metadata) => {
console.log("✅ Benji Connect onSuccess");
},
onError: (error, error_id, metadata) => {
console.log("🛑 Benji Connect onError");
},
onExit: (metadata) => {
console.log("🚪 Benji Connect onExit");
},
onEvent: (type, metadata) => {
console.log("📨 Benji Connect onEvent", type);
},
});
sdk.open();
</script>Configuration
The SDK accepts the following configuration options:
token(required): Your API connect tokenonSuccess(optional): Callback function called when connect completed successfullyonError(optional): Callback function called when error occurs in the connect flowonExit(optional): Callback function called when the user exits the connect flowonEvent(optional): Callback function for handling various events
Development
# Install dependencies
npm install
# Build the package
npm run buildTesting locally
To test the SDK in another app without publishing to npm:
In this repo, run:
npm run local:publish
This builds and runsnpm pack, producing a.tgzfile (e.g.benji-money-connect-sdk-1.0.8.tgz).In your app, install the tarball:
npm install /path/to/benji-connect-sdk/benji-money-connect-sdk-1.0.8.tgzOr add to your app’s
package.json:"@benji-money/connect-sdk": "file:../path/to/benji-money-connect-sdk-1.0.8.tgz"then runnpm install.
After SDK changes, run npm run local:publish again and reinstall the new .tgz in your app (use --force if npm uses a cached copy).
License
License
This SDK is proprietary software provided by Benji Money.
You are welcome to use it to integrate with Benji services, but modification, redistribution, or use outside of Benji’s platform is not permitted.
See the LICENSE file for full terms and usage details.
