@mattrglobal/verifier-sdk-web 2.0.0-preview-digital-credential-api.1 → 2.0.0-preview-digital-credential-api.2

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 CHANGED
@@ -12,6 +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
+ - [Support for Digital Credential API (Tech Preview)](#support-for-digital-credential-api-tech-preview)
15
16
  - [Initialise the SDK](#initialise-the-sdk)
16
17
  - [Prepare a credential query](#prepare-a-credential-query)
17
18
  - [Generate challenge](#generate-challenge)
@@ -61,7 +62,7 @@ to any of our SDKs.
61
62
  1. Install dependencies via yarn:
62
63
 
63
64
  ```bash
64
- yarn add @mattrglobal/verifier-sdk-web
65
+ yarn add @mattrglobal/verifier-sdk-web@2.0.0-preview-digital-credential-api.2
65
66
  ```
66
67
 
67
68
  2. Import the sdk module in your code:
@@ -77,11 +78,9 @@ MATTRVerifierSDK.initialise(...);
77
78
  1. Load the following script tag from your web page:
78
79
 
79
80
  ```html
80
- <script src="https://cdn.mattr.global/js/verifier-sdk-web/1.0/verifier-js.production.js"></script>
81
+ <script src="https://cdn.mattr.global/js/verifier-sdk-web/2.0.0-preview-digital-credential-api.2/verifier-js.production.js"></script>
81
82
  ```
82
83
 
83
- > This script will automatically pick up any SDK patch updates. You can lock your implementation to a specific patch version by replacing 1.0 with the specific version (e.g. https://cdn.mattr.global/js/verifier-sdk-web/1.0.1/verifier-js.production.js).
84
-
85
84
  2. Access SDK functions via global `MATTRVerifierSDK` object.
86
85
 
87
86
  ```javascript
@@ -100,11 +99,24 @@ The SDK can make a request to create a presentation session with a configured MA
100
99
  * Define what wallets can be used to respond to the verification request.
101
100
  * Configure the URI the user will be redirected to when the verification workflow is completed (only required for same-device flows).
102
101
 
102
+ ## Support for Digital Credential API (Tech Preview)
103
+
104
+ This also SDK supports the experimental Web Platform Digital Credential API. If the SDK detects the Digital Credential API is available in the current web browser and the feature has been enabled via parameters passed to the initialise function, it will attempt to use it ahead of executing the request based on OpenID4VP (ISO 18013-7).
105
+
103
106
  ## Initialise the SDK
104
107
 
105
108
  You must initialise the SDK before you can use any of its functions and methods.
106
109
 
107
- When initialising the SDK, you must provide the URL of the MATTR VII verifier tenant.
110
+ ```javascript
111
+ MATTRVerifierSDK.initialise({
112
+ apiBaseUrl: "{tenant_url}", // provide the URL of the MATTR VII verifier tenant.
113
+ /**
114
+ * Configurations when Digital Credential Api is available
115
+ **/
116
+ enableDigitalCredentialsApiSameDeviceFlow: true, // indicate if SDK will request credential via Digital Credential Api in a same device flow
117
+ enableDigitalCredentialsApiCrossDeviceFlow: false, // indicate if SDK request credential via Digital Credential Api in a cross device flow
118
+ });
119
+ ```
108
120
 
109
121
  ## Prepare a credential query
110
122
 
@@ -159,9 +171,11 @@ You can define an identifier of a specific wallet you want to invoke with this v
159
171
  * If an identifier is provided and does not match the `id` of any of the objects in the `walletProviders array`, the request will fail.
160
172
  * If an identifier is not provided, the verifier tenant will use `mdoc-openid4vp://` (default OID4VP scheme) to invoke any wallet.
161
173
 
174
+ **Note** that if the SDK request credentials via the Digital Credential API, the mobile operating system will prompt the user to make a selection of which credential from which wallet it would like to respond to the request with.
175
+
162
176
  ## Configure redirectUri
163
177
 
164
- 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/putVerifierConfiguration!path=redirectUris&t=request) in the MATTR VII tenant's verifier configuration.
178
+ When using the same-device presentation flow with OpenID4VP (ISO 18013-7) e.g instead of using the Digital Credential API, 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/putVerifierConfiguration!path=redirectUris&t=request) in the MATTR VII tenant's verifier configuration.
165
179
 
166
180
  # Request credentials examples
167
181
 
@@ -169,7 +183,7 @@ When using the same-device presentation flow, the SDK must define what URI to re
169
183
 
170
184
  ```javascript
171
185
  MATTRVerifierSDK.initialise({ apiBaseUrl }); // Initialise the SDK
172
- const result = await MATTRVerifierSDK.requestCredentials({
186
+ const requestCredentialsResult = await MATTRVerifierSDK.requestCredentials({
173
187
  credentialQuery: [credentialQuery], // Define what credential query to use
174
188
  challenge: MATTRVerifierSDK.utils.generateChallenge(), // Pass a unique challenge
175
189
  walletProviderId, // Define the wallet identifier
@@ -183,6 +197,17 @@ const result = await MATTRVerifierSDK.requestCredentials({
183
197
  },
184
198
  },
185
199
  });
200
+
201
+ // Check result when it's available in the return value
202
+ if (requestCredentialsResult.isOk() && "result" in requestCredentialsResult.value) {
203
+ console.info("<<< MATTRVerifierSDK.requestCredentials result",result.value.result);
204
+ }
205
+
206
+ // Check result also in your page of redirect_uri
207
+ window.addEventListener("load", async () => {
208
+ MATTRVerifierSDK.initialise({ apiBaseUrl });
209
+ const result = await MATTRVerifierSDK.handleRedirectCallback();
210
+ });
186
211
  ```
187
212
  * `apiBaseUrl` : Replace with the [`tenant_url`](https://learn.mattr.global/docs/security/authentication) of your MATTR VII verifier tenant.
188
213
  * `credentialQuery`: The credential query to be used in the request.
@@ -196,7 +221,7 @@ const result = await MATTRVerifierSDK.requestCredentials({
196
221
 
197
222
  ```javascript
198
223
  MATTRVerifierSDK.initialise({ apiBaseUrl });
199
- const result = await MATTRVerifierSDK.requestCredentials({
224
+ const requestCredentialsResult = await MATTRVerifierSDK.requestCredentials({
200
225
  credentialQuery: [credentialQuery],
201
226
  challenge: MATTRVerifierSDK.utils.generateChallenge(),
202
227
  redirectUri,
@@ -204,7 +229,12 @@ const result = await MATTRVerifierSDK.requestCredentials({
204
229
  mode: "sameDevice",
205
230
  });
206
231
 
207
- // result can be retrieved on redirect uri page. for example
232
+ // Check result when it's available in the return value
233
+ if (requestCredentialsResult.isOk() && "result" in requestCredentialsResult.value) {
234
+ console.info("<<< MATTRVerifierSDK.requestCredentials result",result.value.result);
235
+ }
236
+
237
+ // Check result also in your page of redirect_uri
208
238
  window.addEventListener("load", async () => {
209
239
  MATTRVerifierSDK.initialise({ apiBaseUrl });
210
240
  const result = await MATTRVerifierSDK.handleRedirectCallback();
@@ -219,7 +249,7 @@ window.addEventListener("load", async () => {
219
249
 
220
250
  ```javascript
221
251
  MATTRVerifierSDK.initialise({ apiBaseUrl });
222
- const result = await MATTRVerifierSDK.requestCredentials({
252
+ const requestCredentialsResult = await MATTRVerifierSDK.requestCredentials({
223
253
  credentialQuery: [credentialQuery],
224
254
  challenge: MATTRVerifierSDK.utils.generateChallenge(),
225
255
  walletProviderId,
@@ -233,6 +263,11 @@ const result = await MATTRVerifierSDK.requestCredentials({
233
263
  },
234
264
  },
235
265
  });
266
+
267
+ // Check result when it's available in the return value
268
+ if (requestCredentialsResult.isOk() && "result" in requestCredentialsResult.value) {
269
+ console.info("<<< MATTRVerifierSDK.requestCredentials result",result.value.result);
270
+ }
236
271
  ```
237
272
 
238
273
  * `mode`: When set to `crossDevice`, the SDK will only support cross-device flow in this verification workflow.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
10
  * Generated: 2024-10-21
11
- * Version: 2.0.0-preview-digital-credential-api.1
11
+ * Version: 2.0.0-preview-digital-credential-api.2
12
12
  * Dependencies:
13
13
  */
14
14
 
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
10
  * Generated: 2024-10-21
11
- * Version: 2.0.0-preview-digital-credential-api.1
11
+ * Version: 2.0.0-preview-digital-credential-api.2
12
12
  * Dependencies:
13
13
  *
14
14
  * neverthrow -- 4.3.0
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
10
  * Generated: 2024-10-21
11
- * Version: 2.0.0-preview-digital-credential-api.1
11
+ * Version: 2.0.0-preview-digital-credential-api.2
12
12
  * Dependencies:
13
13
  *
14
14
  * neverthrow -- 4.3.0
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
10
  * Generated: 2024-10-21
11
- * Version: 2.0.0-preview-digital-credential-api.1
11
+ * Version: 2.0.0-preview-digital-credential-api.2
12
12
  * Dependencies:
13
13
  *
14
14
  * neverthrow -- 4.3.0
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
10
  * Generated: 2024-10-21
11
- * Version: 2.0.0-preview-digital-credential-api.1
11
+ * Version: 2.0.0-preview-digital-credential-api.2
12
12
  * Dependencies:
13
13
  *
14
14
  * neverthrow -- 4.3.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattrglobal/verifier-sdk-web",
3
- "version": "2.0.0-preview-digital-credential-api.1",
3
+ "version": "2.0.0-preview-digital-credential-api.2",
4
4
  "main": "dist/lib/verifier-js.cjs.js",
5
5
  "types": "dist/typings/index.d.ts",
6
6
  "module": "dist/verifier-js.production.esm.js",
@@ -30,5 +30,5 @@
30
30
  "docs": "rm -rf generatedDoc/ && typedoc && cp CHANGELOG_PUBLIC.md generatedDoc/CHANGELOG.md",
31
31
  "docs:html": "NAME=\"Mattr Verifier SDK Web\" ../../scripts/generateHtmlDocs.sh"
32
32
  },
33
- "gitHead": "b93397dffec9fa3a2ecee1aed0f01305ba1b6a81"
33
+ "gitHead": "f86d835469f47792f6e38c15a9878f22be6eec7b"
34
34
  }