@mattrglobal/verifier-sdk-web 1.1.1-unstable.16 → 1.1.1-unstable.161
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 +63 -42
- package/dist/lib/verifier-js-no-deps.cjs.js +590 -198
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +716 -312
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/common/safeFetch.d.ts +6 -3
- package/dist/typings/common/sleep.d.ts +1 -0
- package/dist/typings/index.d.ts +6 -6
- package/dist/typings/verifier/abortCredentialRequest.d.ts +6 -0
- package/dist/typings/verifier/handleRedirectCallback.d.ts +1 -1
- package/dist/typings/verifier/index.d.ts +3 -1
- package/dist/typings/verifier/initialize.d.ts +12 -0
- package/dist/typings/verifier/instanceContext.d.ts +7 -0
- package/dist/typings/verifier/requestCredentialsCrossDevice.d.ts +3 -47
- package/dist/typings/verifier/requestCredentialsDigitalCredentialsApi.d.ts +16 -0
- package/dist/typings/verifier/requestCredentialsSameDevice.d.ts +1 -1
- package/dist/typings/verifier/types/credential-presentation.d.ts +129 -21
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +129 -186
- package/dist/typings/verifier/utils.d.ts +25 -5
- package/dist/verifier-js.development.js +661 -294
- 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/dist/typings/verifier/initialise.d.ts +0 -12
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- [Web project with an existing bundler set up](#web-project-with-an-existing-bundler-set-up)
|
|
13
13
|
- [Loading directly from script tag](#loading-directly-from-script-tag)
|
|
14
14
|
- [Usage](#usage)
|
|
15
|
-
- [
|
|
15
|
+
- [Initialize the SDK](#initialize-the-sdk)
|
|
16
16
|
- [Prepare a credential query](#prepare-a-credential-query)
|
|
17
17
|
- [Generate challenge](#generate-challenge)
|
|
18
18
|
- [Determine supported presentation flows](#determine-supported-presentation-flows)
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
## Licensing
|
|
30
30
|
|
|
31
31
|
Request or download the
|
|
32
|
-
[MATTR Pi SDK Trial
|
|
32
|
+
[MATTR Pi SDK Trial License Agreement](https://learn.mattr.global/docs/terms/mattr-pi-sdk-licence-agreement) and the
|
|
33
33
|
[MATTR Customer Agreement](https://learn.mattr.global/docs/terms/customer-agreement) and review these terms carefully.
|
|
34
34
|
|
|
35
35
|
## Overview
|
|
@@ -69,7 +69,7 @@ yarn add @mattrglobal/verifier-sdk-web
|
|
|
69
69
|
```javascript
|
|
70
70
|
import * as MATTRVerifierSDK from "@mattrglobal/verifier-sdk-web";
|
|
71
71
|
|
|
72
|
-
MATTRVerifierSDK.
|
|
72
|
+
MATTRVerifierSDK.initialize(...);
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
### Loading directly from script tag
|
|
@@ -86,26 +86,26 @@ MATTRVerifierSDK.initialise(...);
|
|
|
86
86
|
|
|
87
87
|
```javascript
|
|
88
88
|
<script>
|
|
89
|
-
MATTRVerifierSDK.
|
|
89
|
+
MATTRVerifierSDK.initialize(...);
|
|
90
90
|
</script>
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
# Usage
|
|
94
94
|
|
|
95
95
|
The SDK can make a request to create a presentation session with a configured MATTR VII verifier tenant. This requires the following configurations and settings:
|
|
96
|
-
*
|
|
96
|
+
* Initialize the SDK with the URL of the MATTR VII tenant that will handle the verification request.
|
|
97
97
|
* Prepare a credential query that defines what claims are required for verification.
|
|
98
98
|
* Generate a unique challenge for the presentation session.
|
|
99
99
|
* Determine what presentation flows are supported in the session.
|
|
100
100
|
* Define what wallets can be used to respond to the verification request.
|
|
101
101
|
* Configure the URI the user will be redirected to when the verification workflow is completed (only required for same-device flows).
|
|
102
102
|
|
|
103
|
-
##
|
|
103
|
+
## Initialize the SDK
|
|
104
104
|
|
|
105
|
-
You must
|
|
105
|
+
You must initialize the SDK before you can use any of its functions and methods:
|
|
106
106
|
|
|
107
107
|
```javascript
|
|
108
|
-
MATTRVerifierSDK.
|
|
108
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
- `apiBaseUrl` (required): URL of the MATTR VII verifier tenant.
|
|
@@ -113,7 +113,7 @@ MATTRVerifierSDK.initialise({ apiBaseUrl, applicationId });
|
|
|
113
113
|
|
|
114
114
|
## Prepare a credential query
|
|
115
115
|
|
|
116
|
-
The following example credential query will request the `
|
|
116
|
+
The following example credential query will request the `given_name`, `family_name`, `birth_date` and `portrait` claims from a `mobile` credential profile with `org.iso.18013.5.1.mDL` as a docType:
|
|
117
117
|
|
|
118
118
|
```javascript
|
|
119
119
|
const credentialQuery = [
|
|
@@ -122,7 +122,13 @@ const credentialQuery = [
|
|
|
122
122
|
"docType": "org.iso.18013.5.1.mDL",
|
|
123
123
|
"nameSpaces": {
|
|
124
124
|
"org.iso.18013.5.1": {
|
|
125
|
-
"
|
|
125
|
+
"given_name": {
|
|
126
|
+
"intentToRetain": false
|
|
127
|
+
},
|
|
128
|
+
"family_name": {
|
|
129
|
+
"intentToRetain": false
|
|
130
|
+
},
|
|
131
|
+
"birth_date": {
|
|
126
132
|
"intentToRetain": false
|
|
127
133
|
},
|
|
128
134
|
"portrait": {
|
|
@@ -136,9 +142,23 @@ const credentialQuery = [
|
|
|
136
142
|
}
|
|
137
143
|
];
|
|
138
144
|
```
|
|
139
|
-
|
|
145
|
+
* `profile`: Credential format of the credential that will be verified. Currently only mobile (mDocs) is supported.
|
|
146
|
+
* `docType`: the mDL’s type. Confirm with the certificate issuer for what docType they are issuing. Some common examples include:
|
|
147
|
+
* Mobile Driver License (`org.iso.18013.5.1.mDL`).
|
|
148
|
+
* PhotoID (`org.iso.23220.photoid.1`).
|
|
149
|
+
* Mobile Vehicle Registration Card (`org.iso.7367.1.mVRC`).
|
|
150
|
+
* Health certificate (`org.micov.vtr.1`).
|
|
151
|
+
* `nameSpaces`: Each namespace corresponds to a group of claims included in the credential. These can be claims that are part of a specific standard, jurisdiction or any other reference. The namespace would usually correspond to the requested `docType`.
|
|
152
|
+
* `intentToRetain` (Optional): When set to `true`, the holder will be indicated that the verifier intends to retain this claim beyond the verification workflow. Defaults to `false` when not specified.
|
|
153
|
+
|
|
140
154
|
> 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.
|
|
141
155
|
|
|
156
|
+
In this example the `credentialQuery` query will request for the `birthdate`, `portrait` and `resident_postal_code` claims from any credentials whose `profile` is `mobile` and `docType` is `org.iso.18013.5.1.mDL`.
|
|
157
|
+
|
|
158
|
+
It also sets `intentToRetain` as `false` for all claims, indicating to the holder that the verifier will not retain any of these claims.
|
|
159
|
+
|
|
160
|
+
> While `intentToRetain` defaults to false, it is explicitly set to `false` in the example above for clarity purposes. If there is no intention to retain a claim, it is sufficient to simply exclude `intentToRetain` from the query.
|
|
161
|
+
|
|
142
162
|
## Generate challenge
|
|
143
163
|
|
|
144
164
|
The Verifier Web SDK passes a unique challenge to the MATTR VII verifier tenant with every request to create a new presentation session. The purpose of the challenge is to ensure the security and integrity of the credential verification process by preventing replay attacks and verifying the authenticity of each request and response. You can either:
|
|
@@ -170,52 +190,53 @@ You can define an identifier of a specific wallet you want to invoke with this v
|
|
|
170
190
|
|
|
171
191
|
## Configure redirectUri
|
|
172
192
|
|
|
173
|
-
When using the same-device presentation flow, the SDK must define what URI to redirect the user to once they complete the verification workflow in their wallet app. This can be any URI (including custom URI schemes), and must match one of the values defined in the [`redirectUris` array](https://learn.mattr.global/latest/tag/mDocs-verification#operation/
|
|
193
|
+
When using the same-device presentation flow, the SDK must define what URI to redirect the user to once they complete the verification workflow in their wallet app. This can be any URI (including custom URI schemes), and must match one of the values defined in the [`redirectUris` array](https://learn.mattr.global/api-reference/latest/tag/mDocs-verification#operation/postVerifierApplication!path=openid4vpConfiguration/redirectUris&t=request) in the MATTR VII tenant's verifier configuration.
|
|
174
194
|
|
|
175
195
|
# Request credentials examples
|
|
176
196
|
|
|
177
197
|
## Request credentials with automatic flow selection
|
|
178
198
|
|
|
179
199
|
```javascript
|
|
180
|
-
MATTRVerifierSDK.
|
|
200
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId }); // Initialize the SDK
|
|
181
201
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
182
202
|
credentialQuery: [credentialQuery], // Define what credential query to use
|
|
183
203
|
challenge: MATTRVerifierSDK.utils.generateChallenge(), // Pass a unique challenge
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
console.info("<<< MATTRVerifierSDK.requestCredentials crossDeviceCallback.onComplete", result);
|
|
189
|
-
},
|
|
190
|
-
onFailure: (error) => {
|
|
191
|
-
console.info("<<< MATTRVerifierSDK.requestCredentials crossDeviceCallback.onFailure", error);
|
|
192
|
-
},
|
|
193
|
-
},
|
|
204
|
+
openid4vpConfiguration: {
|
|
205
|
+
walletProviderId, // Define the wallet identifier
|
|
206
|
+
redirectUri, // Define the redirect URI (not required for cross-device only requests)
|
|
207
|
+
}
|
|
194
208
|
});
|
|
209
|
+
|
|
210
|
+
if (result.isErr()) {
|
|
211
|
+
console.info("<<< MATTRVerifierSDK.requestCredentials succeed", result.error);
|
|
212
|
+
} else {
|
|
213
|
+
console.info("<<< MATTRVerifierSDK.requestCredentials failure", result.value);
|
|
214
|
+
}
|
|
195
215
|
```
|
|
196
|
-
* `apiBaseUrl` : Replace with the [`tenant_url`](https://learn.mattr.global/docs/
|
|
216
|
+
* `apiBaseUrl` : Replace with the [`tenant_url`](https://learn.mattr.global/docs/platform-management/authentication) of your MATTR VII verifier tenant.
|
|
197
217
|
* `credentialQuery`: The credential query to be used in the request.
|
|
198
218
|
* `challenge`: The challenge that will be passed to the MATTR VII tenant with the request to create a presentation session. This example uses the SDK built-in method to generate the challenge, but you can replace it with a challenge generated by your backend system.
|
|
199
219
|
* `walletProviderId`: Replace with a wallet identifier that matches one of the values in the [`walletProviders` array](https://learn.mattr.global/api-reference/latest/tag/mDocs-verification#operation/putVerifierConfiguration!path=walletProviders/id&t=request) of the MATTR VII tenant's verifier configuration.
|
|
200
220
|
* `mode`: When omitted, the SDK defaults to automatically selecting a flow based on the browser's user agent (set to `undefined` in the example for clarity).
|
|
201
|
-
* `redirectUri` Replace with a URI that matches one of the values in the [`redirectUris` array](https://learn.mattr.global/latest/tag/mDocs-verification#operation/
|
|
202
|
-
* `crossDeviceCallback`: Defines how to handle completion (`onComplete`) or failure (`onFailure`) of the verification workflow.
|
|
221
|
+
* `redirectUri` Replace with a URI that matches one of the values in the [`redirectUris` array](https://learn.mattr.global/api-reference/latest/tag/mDocs-verification#operation/postVerifierApplication!path=openid4vpConfiguration/redirectUris&t=request) in the MATTR VII tenant's verifier application configuration.
|
|
203
222
|
|
|
204
223
|
## Request credentials with explicit same-device flow
|
|
205
224
|
|
|
206
225
|
```javascript
|
|
207
|
-
MATTRVerifierSDK.
|
|
226
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
208
227
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
209
228
|
credentialQuery: [credentialQuery],
|
|
210
229
|
challenge: MATTRVerifierSDK.utils.generateChallenge(),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
230
|
+
openid4vpConfiguration: {
|
|
231
|
+
redirectUri,
|
|
232
|
+
walletProviderId,
|
|
233
|
+
mode: "sameDevice",
|
|
234
|
+
}
|
|
214
235
|
});
|
|
215
236
|
|
|
216
237
|
// result can be retrieved on redirect uri page. for example
|
|
217
238
|
window.addEventListener("load", async () => {
|
|
218
|
-
MATTRVerifierSDK.
|
|
239
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
219
240
|
const result = await MATTRVerifierSDK.handleRedirectCallback();
|
|
220
241
|
});
|
|
221
242
|
```
|
|
@@ -227,21 +248,21 @@ window.addEventListener("load", async () => {
|
|
|
227
248
|
## Request credentials with explicit cross-device flow
|
|
228
249
|
|
|
229
250
|
```javascript
|
|
230
|
-
MATTRVerifierSDK.
|
|
251
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
231
252
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
232
253
|
credentialQuery: [credentialQuery],
|
|
233
254
|
challenge: MATTRVerifierSDK.utils.generateChallenge(),
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
console.info("<<< MATTRVerifierSDK.requestCredentials crossDeviceCallback.onComplete", result);
|
|
239
|
-
},
|
|
240
|
-
onFailure: (error) => {
|
|
241
|
-
console.info("<<< MATTRVerifierSDK.requestCredentials crossDeviceCallback.onFailure", error);
|
|
242
|
-
},
|
|
243
|
-
},
|
|
255
|
+
openid4vpConfiguration: {
|
|
256
|
+
walletProviderId,
|
|
257
|
+
mode: "crossDevice",
|
|
258
|
+
}
|
|
244
259
|
});
|
|
260
|
+
|
|
261
|
+
if (result.isErr()) {
|
|
262
|
+
console.info("<<< MATTRVerifierSDK.requestCredentials succeed", result.error);
|
|
263
|
+
} else {
|
|
264
|
+
console.info("<<< MATTRVerifierSDK.requestCredentials failure", result.value);
|
|
265
|
+
}
|
|
245
266
|
```
|
|
246
267
|
|
|
247
268
|
* `mode`: When set to `crossDevice`, the SDK will only support cross-device flow in this verification workflow.
|