@mattrglobal/verifier-sdk-web 2.2.1-unstable.6 → 2.2.1-unstable.61
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 +70 -22
- package/dist/lib/verifier-js-no-deps.cjs.js +8 -3
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +8 -3
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +6 -1
- package/dist/verifier-js.development.js +8 -3
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +2 -2
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +2 -2
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
- [Define wallet identifiers](#define-wallet-identifiers)
|
|
22
22
|
- [Configure redirectUri](#configure-redirecturi)
|
|
23
23
|
- [Correlate sessions with your own records using state](#correlate-sessions-with-your-own-records-using-state)
|
|
24
|
+
- [Run logic on session creation using onSessionCreate](#run-logic-on-session-creation-using-onsessioncreate)
|
|
24
25
|
- [Request credentials using the DC API](#request-credentials-using-the-dc-api)
|
|
25
26
|
- [Request credentials examples](#request-credentials-examples)
|
|
26
27
|
- [Request credentials with automatic flow selection](#request-credentials-with-automatic-flow-selection)
|
|
@@ -39,12 +40,10 @@ Request or download the
|
|
|
39
40
|
## Overview
|
|
40
41
|
|
|
41
42
|
The Verifier Web SDK is a powerful tool for integrating online credential verification capabilities into your web
|
|
42
|
-
applications. It enables secure and efficient verification of [mDocs](https://learn.mattr.global/docs/mdocs),
|
|
43
|
-
both [same-device](https://learn.mattr.global/docs/verification/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
verification workflows. The SDK leverages the MATTR VII platform to handle credential presentation and verification
|
|
47
|
-
processes.
|
|
43
|
+
applications. It enables secure and efficient verification of [mDocs](https://learn.mattr.global/docs/concepts/mdocs),
|
|
44
|
+
supporting both [same-device](https://learn.mattr.global/docs/verification/remote-overview#verification-flows) and
|
|
45
|
+
[cross-device](https://learn.mattr.global/docs/verification/remote-overview#verification-flows) verification workflows.
|
|
46
|
+
The SDK leverages the MATTR VII platform to handle credential presentation and verification processes.
|
|
48
47
|
|
|
49
48
|
## Features
|
|
50
49
|
|
|
@@ -60,8 +59,8 @@ processes.
|
|
|
60
59
|
|
|
61
60
|
## How to get access to the MATTR Pi Verifier Web SDK
|
|
62
61
|
|
|
63
|
-
Refer to our [SDK Docs landing page](https://learn.mattr.global/
|
|
64
|
-
gain access to any of our SDKs.
|
|
62
|
+
Refer to our [SDK Docs landing page](https://learn.mattr.global/docs/resources/get-started) for step-by-step
|
|
63
|
+
instructions to gain access to any of our SDKs.
|
|
65
64
|
|
|
66
65
|
> Please [reach out](mailto:dev-support@mattr.global) if you need any assistance.
|
|
67
66
|
|
|
@@ -115,6 +114,8 @@ the following configurations and settings:
|
|
|
115
114
|
same-device flows).
|
|
116
115
|
- Optionally pass a `state` string to correlate the session with a record in your own system (see
|
|
117
116
|
[Correlate sessions with your own records using state](#correlate-sessions-with-your-own-records-using-state)).
|
|
117
|
+
- Optionally pass an `onSessionCreate` hook to run your own logic once the session has been created (see
|
|
118
|
+
[Run logic on session creation using onSessionCreate](#run-logic-on-session-creation-using-onsessioncreate)).
|
|
118
119
|
|
|
119
120
|
## Initialize the SDK
|
|
120
121
|
|
|
@@ -126,9 +127,9 @@ MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
|
126
127
|
|
|
127
128
|
- `apiBaseUrl` (required): URL of the MATTR VII verifier tenant.
|
|
128
129
|
- `applicationId` (required): Unique identifier of the verifier application. This must match the
|
|
129
|
-
[`id`](https://learn.mattr.global/api-reference/
|
|
130
|
-
|
|
131
|
-
[creating a Verifier application](https://learn.mattr.global/api-reference/
|
|
130
|
+
[`id`](https://learn.mattr.global/docs/api-reference/platform/verifier-applications/postVerifierApplication) parameter
|
|
131
|
+
in the response returned when
|
|
132
|
+
[creating a Verifier application](https://learn.mattr.global/docs/api-reference/platform/verifier-applications/postVerifierApplication)
|
|
132
133
|
on the MATTR VII verifier tenant.
|
|
133
134
|
|
|
134
135
|
## Prepare a credential query
|
|
@@ -227,13 +228,13 @@ This behavior can be explicitly overridden by specifying the desired mode in the
|
|
|
227
228
|
|
|
228
229
|
You can define an identifier of a specific wallet you want to invoke with this verification request. The identifier
|
|
229
230
|
defined by the SDK in the credential request must match one of the identifiers of a
|
|
230
|
-
[wallet provider](https://learn.mattr.global/api-reference/
|
|
231
|
-
|
|
231
|
+
[wallet provider](https://learn.mattr.global/docs/api-reference/platform/wallet-providers/postWalletProvider) created on
|
|
232
|
+
the MATTR VII verifier tenant.
|
|
232
233
|
|
|
233
234
|
- If an identifier is provided and matches the `id` of one of the objects in the `walletProviders` array, the verifier
|
|
234
235
|
tenant will invoke that specific wallet using its corresponding
|
|
235
|
-
[`authorizationEndpoint`](https://learn.mattr.global/api-reference/
|
|
236
|
-
- If an identifier is provided and does not match the `id` of any of the objects in the `walletProviders array
|
|
236
|
+
[`authorizationEndpoint`](https://learn.mattr.global/docs/api-reference/platform/wallet-providers/postWalletProvider).
|
|
237
|
+
- If an identifier is provided and does not match the `id` of any of the objects in the `walletProviders` array, the
|
|
237
238
|
request will fail.
|
|
238
239
|
- If an identifier is not provided, the verifier tenant will use `mdoc-openid4vp://` (default OID4VP scheme) to invoke
|
|
239
240
|
any wallet.
|
|
@@ -243,7 +244,7 @@ created on the MATTR VII verifier tenant.
|
|
|
243
244
|
When using the same-device presentation flow, the SDK must define what URI to redirect the user to once they complete
|
|
244
245
|
the verification workflow in their wallet app. This can be any URI (including custom URI schemes), and must match one of
|
|
245
246
|
the values defined in the
|
|
246
|
-
[`redirectUris` array](https://learn.mattr.global/api-reference/
|
|
247
|
+
[`redirectUris` array](https://learn.mattr.global/docs/api-reference/platform/verifier-applications/postVerifierApplication)
|
|
247
248
|
when creating a verifier application.
|
|
248
249
|
|
|
249
250
|
## Correlate sessions with your own records using `state`
|
|
@@ -340,6 +341,44 @@ MATTR VII platform and the SDK, see the
|
|
|
340
341
|
[Correlating verification sessions with your system](https://learn.mattr.global/docs/verification/remote-web-verifiers/guides/correlating-verification-sessions)
|
|
341
342
|
guide on MATTR Learn.
|
|
342
343
|
|
|
344
|
+
## Run logic on session creation using `onSessionCreate`
|
|
345
|
+
|
|
346
|
+
`requestCredentials()` accepts an optional `onSessionCreate` hook that the SDK invokes immediately after the
|
|
347
|
+
presentation session has been created on the MATTR VII verifier tenant, but before it continues with the rest of the
|
|
348
|
+
presentation flow (rendering the QR code for cross-device flows or redirecting to the wallet for same-device flows). Use
|
|
349
|
+
it to run your own logic against the freshly created session, for example persisting the `sessionId` in your backend,
|
|
350
|
+
starting a timer, or emitting analytics.
|
|
351
|
+
|
|
352
|
+
The hook receives the session creation result and may be synchronous or asynchronous; the SDK awaits it before
|
|
353
|
+
continuing:
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
const options: MATTRVerifierSDK.RequestCredentialsOptions = {
|
|
357
|
+
credentialQuery: [credentialQuery],
|
|
358
|
+
challenge: MATTRVerifierSDK.utils.generateChallenge(),
|
|
359
|
+
openid4vpConfiguration: {
|
|
360
|
+
redirectUri: window.location.origin,
|
|
361
|
+
walletProviderId,
|
|
362
|
+
},
|
|
363
|
+
onSessionCreate: async (session) => {
|
|
364
|
+
// e.g. record the session against your own system before the flow continues
|
|
365
|
+
await fetch("/api/sessions", {
|
|
366
|
+
method: "POST",
|
|
367
|
+
headers: { "Content-Type": "application/json" },
|
|
368
|
+
body: JSON.stringify({ sessionId: session.sessionId }),
|
|
369
|
+
});
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const results = await MATTRVerifierSDK.requestCredentials(options);
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
- The hook is supported in both same-device and cross-device sessions.
|
|
377
|
+
- The `session` argument exposes the identifiers for the created session, including its `sessionId`.
|
|
378
|
+
- Any error thrown or promise rejection from the hook is intentionally ignored so it cannot disrupt the presentation
|
|
379
|
+
flow. If a step is critical, handle its errors inside the hook rather than relying on `requestCredentials()` to
|
|
380
|
+
surface them.
|
|
381
|
+
|
|
343
382
|
## Request credentials using the DC API
|
|
344
383
|
|
|
345
384
|
> DC API support is currently offered as a **tech preview**. As such, functionality may be limited, may not work in all
|
|
@@ -396,6 +435,10 @@ const result = await MATTRVerifierSDK.requestCredentials({
|
|
|
396
435
|
walletProviderId, // Define the wallet identifier
|
|
397
436
|
redirectUri, // Define the redirect URI (not required for cross-device only requests)
|
|
398
437
|
},
|
|
438
|
+
onSessionCreate: (session) => {
|
|
439
|
+
// Optional: run your own logic once the session is created, before the flow continues
|
|
440
|
+
console.info("Session created", session.sessionId);
|
|
441
|
+
},
|
|
399
442
|
});
|
|
400
443
|
|
|
401
444
|
if (result.isErr()) {
|
|
@@ -405,24 +448,29 @@ if (result.isErr()) {
|
|
|
405
448
|
}
|
|
406
449
|
```
|
|
407
450
|
|
|
408
|
-
- `apiBaseUrl
|
|
409
|
-
your MATTR VII verifier
|
|
451
|
+
- `apiBaseUrl`: Replace with the
|
|
452
|
+
[`tenant_url`](https://learn.mattr.global/docs/platform-management/management-api/overview) of your MATTR VII verifier
|
|
453
|
+
tenant.
|
|
410
454
|
- `credentialQuery`: The credential query to be used in the request.
|
|
411
455
|
- `challenge`: The challenge that will be passed to the MATTR VII tenant with the request to create a presentation
|
|
412
456
|
session. This example uses the SDK built-in method to generate the challenge, but you can replace it with a challenge
|
|
413
457
|
generated by your backend system.
|
|
414
458
|
- `walletProviderId`: Replace with a wallet identifier that matches one of the identifiers of a
|
|
415
|
-
[wallet provider](https://learn.mattr.global/api-reference/
|
|
416
|
-
|
|
459
|
+
[wallet provider](https://learn.mattr.global/docs/api-reference/platform/wallet-providers/postWalletProvider) created
|
|
460
|
+
on the MATTR VII verifier tenant.
|
|
417
461
|
- `state` (optional): Your own opaque correlation reference for this presentation session. Do not include personally
|
|
418
462
|
identifiable information (PII), credentials, or anything sensitive, as the value is transmitted in plain text on the
|
|
419
463
|
wallet-facing request URI and stored in session records. Returned in the response from `requestCredentials()`
|
|
420
464
|
(cross-device) or `handleRedirectCallback()` (same-device). See
|
|
421
465
|
[Correlate sessions with your own records using state](#correlate-sessions-with-your-own-records-using-state).
|
|
466
|
+
- `onSessionCreate` (optional): A hook invoked with the session creation result once the presentation session has been
|
|
467
|
+
created, before the flow continues. Supported in both same-device and cross-device flows. Errors thrown by the hook
|
|
468
|
+
are ignored. See
|
|
469
|
+
[Run logic on session creation using onSessionCreate](#run-logic-on-session-creation-using-onsessioncreate).
|
|
422
470
|
- `mode`: When omitted, the SDK defaults to automatically selecting a flow based on the browser's user agent (set to
|
|
423
471
|
`undefined` in the example for clarity).
|
|
424
|
-
- `redirectUri
|
|
425
|
-
[`redirectUris` array](https://learn.mattr.global/api-reference/
|
|
472
|
+
- `redirectUri`: Replace with a URI that matches one of the values in the
|
|
473
|
+
[`redirectUris` array](https://learn.mattr.global/docs/api-reference/platform/verifier-applications/postVerifierApplication)
|
|
426
474
|
in the MATTR VII tenant's verifier application.
|
|
427
475
|
|
|
428
476
|
## Request credentials with explicit same-device flow
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2026-
|
|
10
|
+
* Generated: 2026-07-22
|
|
11
11
|
* Version: 2.2.0
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*/
|
|
@@ -579,7 +579,7 @@ const exchangeSessionResult = async ({challenge: challenge, responseCode: respon
|
|
|
579
579
|
body: JSON.stringify(postData)
|
|
580
580
|
});
|
|
581
581
|
const responseResult = await withRetrySafeFetch(fetchResultFn, {
|
|
582
|
-
retries:
|
|
582
|
+
retries: 4,
|
|
583
583
|
retryHttpStatus: 404
|
|
584
584
|
});
|
|
585
585
|
if (responseResult.isErr()) {
|
|
@@ -986,7 +986,7 @@ const requestCredentials = async options => {
|
|
|
986
986
|
}
|
|
987
987
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
988
988
|
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initializeOptions;
|
|
989
|
-
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration, state: state} = options;
|
|
989
|
+
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration, state: state, onSessionCreate: onSessionCreate} = options;
|
|
990
990
|
const dcApiSupported = isDigitalCredentialsApiSupported();
|
|
991
991
|
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
992
992
|
const createSessionResult = await createSession({
|
|
@@ -1008,6 +1008,11 @@ const requestCredentials = async options => {
|
|
|
1008
1008
|
}
|
|
1009
1009
|
const session = createSessionResult.value;
|
|
1010
1010
|
const {sessionKey: sessionKey, sessionId: sessionId} = session;
|
|
1011
|
+
if (onSessionCreate) {
|
|
1012
|
+
try {
|
|
1013
|
+
await onSessionCreate(session);
|
|
1014
|
+
} catch (_b) {}
|
|
1015
|
+
}
|
|
1011
1016
|
if (session.type === SessionType.DigitalCredentialsApi) {
|
|
1012
1017
|
const {request: request, sessionTtl: sessionTtl} = session;
|
|
1013
1018
|
return await requestCredentialsWithDigitalCredentialsApi({
|