@didit-protocol/sdk-web 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/dist/didit-sdk.cjs.js +944 -3
- package/dist/didit-sdk.cjs.js.map +1 -1
- package/dist/didit-sdk.esm.js +943 -4
- package/dist/didit-sdk.esm.js.map +1 -1
- package/dist/didit-sdk.umd.js +944 -3
- package/dist/didit-sdk.umd.js.map +1 -1
- package/dist/didit-sdk.umd.min.js +2 -2
- package/dist/didit-sdk.umd.min.js.map +1 -1
- package/dist/index.d.ts +246 -2
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ A lightweight JavaScript/TypeScript SDK for embedding Didit identity verificatio
|
|
|
6
6
|
|
|
7
7
|
- 🎯 **Simple API** - Singleton pattern with easy-to-use methods
|
|
8
8
|
- 🔐 **Flexible Integration** - Use UniLink URL directly or create sessions via backend
|
|
9
|
+
- 💸 **Transaction Submission** - Submit monitored transactions (incl. Travel Rule) with a scoped token, automatic device intelligence, and an auto-launched wallet-ownership flow
|
|
9
10
|
- 📱 **Responsive** - Works on desktop and mobile browsers
|
|
10
11
|
- 🎨 **Customizable** - Configuration options for styling and behavior
|
|
11
12
|
- 📦 **Multiple Formats** - ESM, CommonJS, and UMD builds
|
|
@@ -269,6 +270,66 @@ console.log(DiditSdk.shared.state);
|
|
|
269
270
|
console.log(DiditSdk.shared.isPresented);
|
|
270
271
|
```
|
|
271
272
|
|
|
273
|
+
## Transaction Submission
|
|
274
|
+
|
|
275
|
+
Submit [monitored transactions](https://docs.didit.me/transaction-monitoring/sdk-transaction-submission) — including [Travel Rule](https://docs.didit.me/transaction-monitoring/travel-rule) transfers and crypto screening — straight from the browser. Your backend mints a short-lived scoped token with `POST /v3/transactions/sdk-token/`; the SDK does the rest: it binds the subject to the token server-side, attaches device intelligence automatically, and auto-launches the wallet-ownership flow when the transaction requires proof of wallet control.
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
import { DiditSdk, DiditTransactionError } from "@didit-protocol/sdk-web";
|
|
279
|
+
|
|
280
|
+
try {
|
|
281
|
+
const result = await DiditSdk.shared.submitTransaction({
|
|
282
|
+
transactionToken: sdkToken, // minted by YOUR backend - never ship an API key
|
|
283
|
+
transaction: {
|
|
284
|
+
txnId: "wd-2026-07-07-0042",
|
|
285
|
+
category: "travelRule",
|
|
286
|
+
details: {
|
|
287
|
+
direction: "out",
|
|
288
|
+
amount: "0.25",
|
|
289
|
+
currency: "ETH",
|
|
290
|
+
currencyType: "crypto",
|
|
291
|
+
cryptoParams: { crypto_chain: "ETH" },
|
|
292
|
+
},
|
|
293
|
+
subject: { type: "individual", fullName: "Jane Doe" },
|
|
294
|
+
counterparty: {
|
|
295
|
+
type: "individual",
|
|
296
|
+
fullName: "Ana Diaz",
|
|
297
|
+
paymentMethod: { type: "unhosted_wallet", accountId: "0xBeneficiaryWallet01" },
|
|
298
|
+
},
|
|
299
|
+
travelRule: {
|
|
300
|
+
beneficiaryData: { wallet_address: "0xBeneficiaryWallet01", name: "Ana Diaz" },
|
|
301
|
+
},
|
|
302
|
+
includeCryptoScreening: true,
|
|
303
|
+
},
|
|
304
|
+
autoLaunchAction: true, // default - auto-launches wallet_ownership in the SDK modal
|
|
305
|
+
onActionCompleted: (refreshed) => {
|
|
306
|
+
console.log(refreshed.status, refreshed.travelRuleStatus);
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
console.log(result.transactionId, result.status);
|
|
311
|
+
|
|
312
|
+
// verification_session actions are NEVER auto-launched - start them yourself:
|
|
313
|
+
if (result.actionRequired?.type === "verification_session") {
|
|
314
|
+
DiditSdk.shared.startVerification({ url: result.actionRequired.url });
|
|
315
|
+
}
|
|
316
|
+
} catch (error) {
|
|
317
|
+
if (error instanceof DiditTransactionError) {
|
|
318
|
+
// error.type: "expired_token" | "invalid_token" | "validation" | "network"
|
|
319
|
+
// error.fieldErrors carries per-field details for validation errors
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Key points:
|
|
325
|
+
|
|
326
|
+
- **`transactionToken`** — scoped to one user (`vendor_data`) at mint time; the subject identity is enforced server-side from it, so a tampered client cannot submit for another user.
|
|
327
|
+
- **`autoLaunchAction`** (default `true`) — auto-launches only `wallet_ownership` actions (in the SDK's overlay modal); a `verification_session` action always comes back in `result.actionRequired` for your app to launch with `startVerification`.
|
|
328
|
+
- **Device intelligence** — a privacy-safe fingerprint is attached to every submission automatically; IP and user agent are derived server-side.
|
|
329
|
+
- **`onActionCompleted`** — receives the refreshed transaction after an auto-launched flow completes or its window closes.
|
|
330
|
+
|
|
331
|
+
Full guide: [SDK Transaction Submission](https://docs.didit.me/transaction-monitoring/sdk-transaction-submission).
|
|
332
|
+
|
|
272
333
|
## API Reference
|
|
273
334
|
|
|
274
335
|
### DiditSdk.shared
|
|
@@ -280,6 +341,7 @@ The singleton SDK instance.
|
|
|
280
341
|
| Method | Description |
|
|
281
342
|
|--------|-------------|
|
|
282
343
|
| `startVerification(options)` | Start the verification flow |
|
|
344
|
+
| `submitTransaction(options)` | Submit a monitored transaction with a scoped token ([guide](https://docs.didit.me/transaction-monitoring/sdk-transaction-submission)) |
|
|
283
345
|
| `close()` | Programmatically close the verification modal |
|
|
284
346
|
| `destroy()` | Destroy the SDK instance and clean up |
|
|
285
347
|
|