journeyid-sdk2
v0.2.0
Published
journey authentication and enrollment library.
Maintainers
Readme
journeyid-sdk
Frontend-safe TypeScript SDK for JourneyID iframe executions + websocket session events.
Features
- Lookup customer enrollments
- Create iframe executions (OTP, facial, device, push)
- Chainable builder API:
.authenticate(...).type(...).delivery(...).start() - Dedicated payment module:
.payment(...).type(...).delivery(...).start() - Automatic pipeline selection using configured pipeline keys
- Delivery fallback (configurable)
- WebSocket listener (automatic CONNECT )
- Works in browsers (uses
fetch,WebSocket) and Node.js with polyfills
Quick start
Install (after publishing) or link locally
Build
npm run build- Example usage
import { JourneyID, AuthType, DeliveryMethod } from "journeyid-sdk";
const journey = new JourneyID({
systemToken: "SYSTEM_JWT",
iframeToken: "IFRAME_JWT",
pipelines: {
otp: "12345678-1234-1234-1234-123456789012",
facial: "12345678-1234-1234-1234-123456789012",
push: "b12345678-1234-1234-1234-123456789012",
},
paymentPipelines: {
facial: "p12345678-1234-1234-1234-123456789012",
},
defaultAuthType: AuthType.OTP,
defaultDelivery: DeliveryMethod.SMS,
fallbackDelivery: [DeliveryMethod.EMAIL, DeliveryMethod.LINK],
});
const result = await journey
.payment("unique_id", { amount: 100, currency: "USD" })
.type(AuthType.FACIAL)
.delivery(DeliveryMethod.SMS)
.start();
journey.on("execution-progress", (e) => console.log(e));
journey.on("execution-completed", (e) => console.log("done", e));Notes
In Node.js you will need a fetch and WebSocket polyfill (e.g. node-fetch and ws) when using server-side. The library intentionally uses the browser APIs so it runs natively in browsers.
The package intentionally avoids Node-only globals so it is safe to ship to frontend consumers.
