@mattrglobal/verifier-sdk-web 1.0.2-unstable.99 → 1.1.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 +31 -22
- package/dist/lib/verifier-js-no-deps.cjs.js +18 -9
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +18 -9
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/verifier/types/credential-presentation.d.ts +46 -36
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +2 -0
- package/dist/typings/verifier/utils.d.ts +4 -5
- package/dist/verifier-js.development.js +18 -9
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +4 -4
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +4 -4
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Request or download the
|
|
|
34
34
|
|
|
35
35
|
## Overview
|
|
36
36
|
|
|
37
|
-
The Verifier Web SDK is a powerful tool for integrating online credential verification capabilities into your web applications. It enables secure and efficient verification of [mDocs](https://learn.mattr.global/docs/
|
|
37
|
+
The Verifier Web SDK is a powerful tool for integrating online credential verification capabilities into your web applications. It enables secure and efficient verification of [mDocs](https://learn.mattr.global/docs/mdocs), supporting both [same-device](https://learn.mattr.global/docs/verification/online/mdocs/overview#same-device-verification-workflow) and [cross-device](https://learn.mattr.global/docs/verification/online/mdocs/overview#cross-device-verification-workflow) verification workflows. The SDK leverages the MATTR VII platform to handle credential presentation and verification processes.
|
|
38
38
|
|
|
39
39
|
## Features
|
|
40
40
|
|
|
@@ -49,7 +49,7 @@ The Verifier Web SDK is a powerful tool for integrating online credential verifi
|
|
|
49
49
|
|
|
50
50
|
## How to get access to the MATTR Pi Verifier Web SDK
|
|
51
51
|
|
|
52
|
-
Refer to our [SDK Docs landing page](https://learn.mattr.global/sdk-docs) for step-by-step instructions to gain access
|
|
52
|
+
Refer to our [SDK Docs landing page](https://learn.mattr.global/references#mattr-pi-sdk-docs) for step-by-step instructions to gain access
|
|
53
53
|
to any of our SDKs.
|
|
54
54
|
|
|
55
55
|
> Please [reach out](mailto:dev-support@mattr.global) if you need any assistance.
|
|
@@ -102,33 +102,42 @@ The SDK can make a request to create a presentation session with a configured MA
|
|
|
102
102
|
|
|
103
103
|
## Initialise the SDK
|
|
104
104
|
|
|
105
|
-
You must initialise the SDK before you can use any of its functions and methods
|
|
105
|
+
You must initialise the SDK before you can use any of its functions and methods:
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
```javascript
|
|
108
|
+
MATTRVerifierSDK.initialise({ apiBaseUrl, applicationId });
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- `apiBaseUrl` (required): URL of the MATTR VII verifier tenant.
|
|
112
|
+
- `applicationId` (optional): Unique identifier of the verifier application. This must match the [`name`](https://learn.mattr.global/api-reference/latest/tag/mDocs-verification#operation/postVerifierApplication!path=name&t=request) parameter defined as part of a Verifier application created on the MATTR VII verifier tenant.
|
|
108
113
|
|
|
109
114
|
## Prepare a credential query
|
|
110
115
|
|
|
111
116
|
The following example credential query will request the `birthdate` and `portrait` claims from a `mobile` credential `profile` with `org.iso.18013.5.1.mDL` as a `docType`:
|
|
112
117
|
|
|
113
118
|
```javascript
|
|
114
|
-
const credentialQuery =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
119
|
+
const credentialQuery = [
|
|
120
|
+
{
|
|
121
|
+
"profile": "mobile",
|
|
122
|
+
"docType": "org.iso.18013.5.1.mDL",
|
|
123
|
+
"nameSpaces": {
|
|
124
|
+
"org.iso.18013.5.1": {
|
|
125
|
+
"birthdate": {
|
|
126
|
+
"intentToRetain": false
|
|
127
|
+
},
|
|
128
|
+
"portrait": {
|
|
129
|
+
"intentToRetain": false
|
|
130
|
+
},
|
|
131
|
+
"resident_postal_code": {
|
|
132
|
+
"intentToRetain": false
|
|
133
|
+
}
|
|
121
134
|
},
|
|
122
|
-
|
|
123
|
-
"resident_postal_code": {
|
|
124
|
-
"intentToRetain": false
|
|
125
|
-
}
|
|
126
|
-
},
|
|
135
|
+
}
|
|
127
136
|
}
|
|
128
|
-
|
|
137
|
+
];
|
|
129
138
|
```
|
|
130
139
|
|
|
131
|
-
> The API supports multiple
|
|
140
|
+
> The API supports including multiple query objects in the `credentialQuery` array in a single request. For simplicity, this example only includes a single query object.
|
|
132
141
|
|
|
133
142
|
## Generate challenge
|
|
134
143
|
|
|
@@ -168,7 +177,7 @@ When using the same-device presentation flow, the SDK must define what URI to re
|
|
|
168
177
|
## Request credentials with automatic flow selection
|
|
169
178
|
|
|
170
179
|
```javascript
|
|
171
|
-
MATTRVerifierSDK.initialise({ apiBaseUrl }); // Initialise the SDK
|
|
180
|
+
MATTRVerifierSDK.initialise({ apiBaseUrl, applicationId }); // Initialise the SDK
|
|
172
181
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
173
182
|
credentialQuery: [credentialQuery], // Define what credential query to use
|
|
174
183
|
challenge: MATTRVerifierSDK.utils.generateChallenge(), // Pass a unique challenge
|
|
@@ -195,7 +204,7 @@ const result = await MATTRVerifierSDK.requestCredentials({
|
|
|
195
204
|
## Request credentials with explicit same-device flow
|
|
196
205
|
|
|
197
206
|
```javascript
|
|
198
|
-
MATTRVerifierSDK.initialise({ apiBaseUrl });
|
|
207
|
+
MATTRVerifierSDK.initialise({ apiBaseUrl, applicationId });
|
|
199
208
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
200
209
|
credentialQuery: [credentialQuery],
|
|
201
210
|
challenge: MATTRVerifierSDK.utils.generateChallenge(),
|
|
@@ -206,7 +215,7 @@ const result = await MATTRVerifierSDK.requestCredentials({
|
|
|
206
215
|
|
|
207
216
|
// result can be retrieved on redirect uri page. for example
|
|
208
217
|
window.addEventListener("load", async () => {
|
|
209
|
-
MATTRVerifierSDK.initialise({ apiBaseUrl });
|
|
218
|
+
MATTRVerifierSDK.initialise({ apiBaseUrl, applicationId });
|
|
210
219
|
const result = await MATTRVerifierSDK.handleRedirectCallback();
|
|
211
220
|
});
|
|
212
221
|
```
|
|
@@ -218,7 +227,7 @@ window.addEventListener("load", async () => {
|
|
|
218
227
|
## Request credentials with explicit cross-device flow
|
|
219
228
|
|
|
220
229
|
```javascript
|
|
221
|
-
MATTRVerifierSDK.initialise({ apiBaseUrl });
|
|
230
|
+
MATTRVerifierSDK.initialise({ apiBaseUrl, applicationId });
|
|
222
231
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
223
232
|
credentialQuery: [credentialQuery],
|
|
224
233
|
challenge: MATTRVerifierSDK.utils.generateChallenge(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2025 - MATTR Limited
|
|
3
3
|
* All rights reserved
|
|
4
4
|
* Confidential and proprietary
|
|
5
5
|
*
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated:
|
|
11
|
-
* Version: 1.0
|
|
10
|
+
* Generated: 2025-01-07
|
|
11
|
+
* Version: 1.1.0
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -127,6 +127,9 @@ exports.MobileCredentialVerificationReasonType = void 0;
|
|
|
127
127
|
(function(MobileCredentialVerificationReasonType) {
|
|
128
128
|
MobileCredentialVerificationReasonType["Expired"] = "expired";
|
|
129
129
|
MobileCredentialVerificationReasonType["Inactive"] = "inactive";
|
|
130
|
+
MobileCredentialVerificationReasonType["StatusRevoked"] = "invalid";
|
|
131
|
+
MobileCredentialVerificationReasonType["StatusSuspended"] = "suspended";
|
|
132
|
+
MobileCredentialVerificationReasonType["StatusUnknown"] = "unknown";
|
|
130
133
|
})(exports.MobileCredentialVerificationReasonType || (exports.MobileCredentialVerificationReasonType = {}));
|
|
131
134
|
|
|
132
135
|
exports.ClaimType = void 0;
|
|
@@ -262,7 +265,8 @@ exports.RequestCredentialsErrorType = void 0;
|
|
|
262
265
|
})(exports.RequestCredentialsErrorType || (exports.RequestCredentialsErrorType = {}));
|
|
263
266
|
|
|
264
267
|
const InitialiseOptionsValidator = v__namespace.object({
|
|
265
|
-
apiBaseUrl: v__namespace.string()
|
|
268
|
+
apiBaseUrl: v__namespace.string(),
|
|
269
|
+
applicationId: v__namespace.optional(v__namespace.string())
|
|
266
270
|
});
|
|
267
271
|
|
|
268
272
|
let initialiseOptions = undefined;
|
|
@@ -312,12 +316,14 @@ const getHashParamValue = (hash, param) => {
|
|
|
312
316
|
return urlParams.get(param);
|
|
313
317
|
};
|
|
314
318
|
|
|
315
|
-
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId}) => {
|
|
316
|
-
const postData = Object.assign(Object.assign({
|
|
319
|
+
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, applicationId: applicationId, walletProviderId: walletProviderId}) => {
|
|
320
|
+
const postData = Object.assign(Object.assign(Object.assign({
|
|
317
321
|
credentialQuery: credentialQuery,
|
|
318
322
|
challenge: challenge
|
|
319
323
|
}, redirectUri ? {
|
|
320
324
|
redirectUri: redirectUri
|
|
325
|
+
} : {}), applicationId ? {
|
|
326
|
+
applicationId: applicationId
|
|
321
327
|
} : {}), walletProviderId ? {
|
|
322
328
|
walletProviderId: walletProviderId
|
|
323
329
|
} : {});
|
|
@@ -481,17 +487,19 @@ const openCrossDeviceModal = options => {
|
|
|
481
487
|
modalContainer.appendChild(style);
|
|
482
488
|
modalContainer.appendChild(iframe);
|
|
483
489
|
document.body.appendChild(modalContainer);
|
|
484
|
-
modalContainer.setAttribute("style", "background: rgba(0, 0, 0, 0.5) !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important;");
|
|
490
|
+
modalContainer.setAttribute("style", "background: rgba(0, 0, 0, 0.5) !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; z-index: 999;");
|
|
491
|
+
modalContainer.setAttribute("class", "mattr-verifier-modal-container");
|
|
485
492
|
return modalContainer;
|
|
486
493
|
};
|
|
487
494
|
|
|
488
495
|
const requestCredentialsCrossDevice = async options => {
|
|
489
496
|
const {challenge: challenge, walletProviderId: walletProviderId, credentialQuery: credentialQuery, crossDeviceCallback: crossDeviceCallback, initialiseOptions: initialiseOptions} = options;
|
|
490
|
-
const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
|
|
497
|
+
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
|
|
491
498
|
const createSessionResult = await createSession({
|
|
492
499
|
credentialQuery: credentialQuery,
|
|
493
500
|
challenge: challenge,
|
|
494
501
|
apiBaseUrl: apiBaseUrl,
|
|
502
|
+
applicationId: applicationId,
|
|
495
503
|
walletProviderId: walletProviderId
|
|
496
504
|
});
|
|
497
505
|
if (createSessionResult.isErr()) {
|
|
@@ -528,7 +536,7 @@ var SameDeviceRequestCredentialsErrorMessage;
|
|
|
528
536
|
|
|
529
537
|
const requestCredentialsSameDevice = async options => {
|
|
530
538
|
const {challenge: challenge, credentialQuery: credentialQuery, redirectUri: redirectUri, walletProviderId: walletProviderId, initialiseOptions: initialiseOptions} = options;
|
|
531
|
-
const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
|
|
539
|
+
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
|
|
532
540
|
window.localStorage.setItem(LocalStorageKey.challenge, challenge);
|
|
533
541
|
const storedChallenge = window.localStorage.getItem(LocalStorageKey.challenge);
|
|
534
542
|
if (!storedChallenge) {
|
|
@@ -542,6 +550,7 @@ const requestCredentialsSameDevice = async options => {
|
|
|
542
550
|
challenge: storedChallenge,
|
|
543
551
|
redirectUri: redirectUri,
|
|
544
552
|
apiBaseUrl: apiBaseUrl,
|
|
553
|
+
applicationId: applicationId,
|
|
545
554
|
walletProviderId: walletProviderId
|
|
546
555
|
});
|
|
547
556
|
if (createSessionResult.isErr()) {
|