@agiodigital/agio-workflow-sdk
v1.1.6
Published
[![Latest version](https://img.shields.io/npm/v/@agiodigital/agio-workflow-sdk.svg)](https://www.npmjs.com/package/@agiodigital/agio-workflow-sdk) [![Latest Beta Version](https://img.shields.io/npm/v/@agiodigital/agio-workflow-sdk/beta.svg)](https://www.n
Downloads
74
Readme
Alright, I understand your requirements now. Let's revise the provided documentation.
@agiodigital/agio-workflow-sdk
Description
@agiodigital/agio-workflow-sdk
is a JavaScript SDK designed for the seamless integration of Agio workflows into your application using an iframe. The SDK also provides a Management SDK for server-side interactions, ensuring that sensitive information like apiToken
remains secured.
Installation
Use npm or yarn to install the package:
# Using npm
npm install @agiodigital/agio-workflow-sdk
# Using yarn
yarn add @agiodigital/agio-workflow-sdk
Usage
Server-side: AgioWorkflowManagementSdk
⛔ 🚫 Always fetch the SDK initialization token securely from the backend. NEVER expose your apiToken
on the client-side.
The token is valid for 10 minutes and a new token can be fetched at any time.
Using the AgioWorkflowManagementSdk
, you can securely manage sensitive tasks, such as fetching the SDK initialization token:
// Import the module
import { AgioWorkflowManagementSdk } from '@agiodigital/agio-workflow-sdk';
// Initialize with configuration
const sdkManagement = new AgioWorkflowManagementSdk({
apiToken: "YOUR_SECURE_API_TOKEN", // required
externalUserId: "user-123", // required
externalUserEmail: "[email protected]",
externalUserName: "John Doe"
});
// Fetch the SDK initialization token
const token = await sdkManagement.getToken();
Fetching SDK Initialization Token with CURL:
Alternatively, you can fetch the SDK initialization token directly using a CURL command:
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"externalUserId": "exampleUserId",
"externalUserEmail": "[email protected]",
"externalUserName": "Example Name",
"apiToken": "YOUR_SECURE_API_TOKEN"
}' \
https://api.agiodigital.com/auth/workflow-sdk/init-token
Replace placeholders with your actual data.
Client-side: AgioWorkflowSdk
After fetching the SDK initialization token securely from the backend, you can then utilize it on the client side:
// Import the module
import { AgioWorkflowSdk } from '@agiodigital/agio-workflow-sdk';
// Initialize with configuration
const sdk = new AgioWorkflowSdk({
token: "YOUR_SDK_INIT_TOKEN", // obtained securely from your server
workflowId: "company-setup", // required
environment: "development" // optional (default: "production")
});
// Mount the widget
sdk.mountWidget({
container: "#workflow-container", // query selector or DOM element
on: {
stepChange: (step) => {
console.log("Step Changed:", step);
},
workflowComplete: () => {
console.log("Workflow Completed");
}
}
});
// Optionally, unmount the widget
sdk.unmountWidget();
License
This project is licensed under the MIT License. See the LICENSE
file for full details.