@mattrglobal/verifier-sdk-web 2.0.3-unstable.5 → 2.0.3-unstable.52

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
@@ -109,7 +109,7 @@ MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
109
109
  ```
110
110
 
111
111
  - `apiBaseUrl` (required): URL of the MATTR VII verifier tenant.
112
- - `applicationId` (required): Unique identifier of the verifier application. This must match the [`id`](https://learn.mattr.global/api-reference/latest/tag/mDocs-verification#operation/postVerifierApplication!c=200&path=id&t=response) parameter in the response returned when [creating a Verifier application configuration](https://learn.mattr.global/api-reference/latest/tag/mDocs-verification#operation/postVerifierApplication) on the MATTR VII verifier tenant.
112
+ - `applicationId` (required): Unique identifier of the verifier application. This must match the [`id`](https://learn.mattr.global/api-reference/latest/tag/Verifier-applications#operation/postVerifierApplication!c=201&path=0/id&t=response) parameter in the response returned when [creating a Verifier application](https://learn.mattr.global/api-reference/latest/tag/Verifier-applications#operation/postVerifierApplication) on the MATTR VII verifier tenant.
113
113
 
114
114
  ## Prepare a credential query
115
115
 
@@ -183,14 +183,14 @@ This behavior can be explicitly overridden by specifying the desired mode in the
183
183
 
184
184
  ## Define wallet identifiers
185
185
 
186
- You can define an identifier of a specific wallet you want to invoke with this verification request. The identifier defined by the SDK in the credential request must match one of the identifiers defined 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.
187
- * If an identifier is provided and matches the `id` of one of the objects in the `walletProviders` array, the verifier tenant will invoke that specific wallet using its corresponding [`authorizationEndpoint`](https://learn.mattr.global/api-reference/latest/tag/mDocs-verification#operation/putVerifierConfiguration!path=walletProviders/authorizationEndpoint&t=request).
186
+ You can define an identifier of a specific wallet you want to invoke with this verification request. The identifier defined by the SDK in the credential request must match one of the identifiers of a [wallet provider](https://learn.mattr.global/api-reference/latest/tag/Wallet-providers#operation/postWalletProvider!path=name&t=request) created on the MATTR VII verifier tenant.
187
+ * If an identifier is provided and matches the `id` of one of the objects in the `walletProviders` array, the verifier tenant will invoke that specific wallet using its corresponding [`authorizationEndpoint`](https://learn.mattr.global/api-reference/latest/tag/Wallet-providers#operation/postWalletProvider!path=openid4vpConfiguration/authorizationEndpoint&t=request).
188
188
  * If an identifier is provided and does not match the `id` of any of the objects in the `walletProviders array`, the request will fail.
189
189
  * If an identifier is not provided, the verifier tenant will use `mdoc-openid4vp://` (default OID4VP scheme) to invoke any wallet.
190
190
 
191
191
  ## Configure redirectUri
192
192
 
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.
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/Verifier-applications#operation/postVerifierApplication!path=0/openid4vpConfiguration/redirectUris&t=request) when creating a verifier application.
194
194
 
195
195
  # Request credentials examples
196
196
 
@@ -199,7 +199,7 @@ When using the same-device presentation flow, the SDK must define what URI to re
199
199
  ```javascript
200
200
  MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId }); // Initialize the SDK
201
201
  const result = await MATTRVerifierSDK.requestCredentials({
202
- credentialQuery: [credentialQuery], // Define what credential query to use
202
+ credentialQuery: credentialQuery, // Define what credential query to use
203
203
  challenge: MATTRVerifierSDK.utils.generateChallenge(), // Pass a unique challenge
204
204
  openid4vpConfiguration: {
205
205
  walletProviderId, // Define the wallet identifier
@@ -208,24 +208,24 @@ const result = await MATTRVerifierSDK.requestCredentials({
208
208
  });
209
209
 
210
210
  if (result.isErr()) {
211
- console.info("<<< MATTRVerifierSDK.requestCredentials succeed", result.error);
211
+ console.info("<<< MATTRVerifierSDK.requestCredentials failure", result.error);
212
212
  } else {
213
- console.info("<<< MATTRVerifierSDK.requestCredentials failure", result.value);
213
+ console.info("<<< MATTRVerifierSDK.requestCredentials succeed", result.value);
214
214
  }
215
215
  ```
216
216
  * `apiBaseUrl` : Replace with the [`tenant_url`](https://learn.mattr.global/docs/platform-management/authentication) of your MATTR VII verifier tenant.
217
217
  * `credentialQuery`: The credential query to be used in the request.
218
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.
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.
219
+ * `walletProviderId`: Replace with a wallet identifier that matches one of the identifiers of a [wallet provider](https://learn.mattr.global/api-reference/latest/tag/Wallet-providers#operation/postWalletProvider!path=name&t=request) created on the MATTR VII verifier tenant..
220
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).
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.
221
+ * `redirectUri` Replace with a URI that matches one of the values in the [`redirectUris` array](https://learn.mattr.global/api-reference/latest/tag/Verifier-applications#operation/postVerifierApplication!path=0/openid4vpConfiguration/redirectUris&t=request) in the MATTR VII tenant's verifier application.
222
222
 
223
223
  ## Request credentials with explicit same-device flow
224
224
 
225
225
  ```javascript
226
226
  MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
227
227
  const result = await MATTRVerifierSDK.requestCredentials({
228
- credentialQuery: [credentialQuery],
228
+ credentialQuery: credentialQuery,
229
229
  challenge: MATTRVerifierSDK.utils.generateChallenge(),
230
230
  openid4vpConfiguration: {
231
231
  redirectUri,
@@ -250,7 +250,7 @@ window.addEventListener("load", async () => {
250
250
  ```javascript
251
251
  MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
252
252
  const result = await MATTRVerifierSDK.requestCredentials({
253
- credentialQuery: [credentialQuery],
253
+ credentialQuery: credentialQuery,
254
254
  challenge: MATTRVerifierSDK.utils.generateChallenge(),
255
255
  openid4vpConfiguration: {
256
256
  walletProviderId,
@@ -259,9 +259,9 @@ const result = await MATTRVerifierSDK.requestCredentials({
259
259
  });
260
260
 
261
261
  if (result.isErr()) {
262
- console.info("<<< MATTRVerifierSDK.requestCredentials succeed", result.error);
262
+ console.info("<<< MATTRVerifierSDK.requestCredentials failure", result.error);
263
263
  } else {
264
- console.info("<<< MATTRVerifierSDK.requestCredentials failure", result.value);
264
+ console.info("<<< MATTRVerifierSDK.requestCredentials succeed", result.value);
265
265
  }
266
266
  ```
267
267
 
@@ -7,7 +7,7 @@
7
7
  * Do Not Translate or Localize
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
- * Generated: 2025-07-02
10
+ * Generated: 2025-08-21
11
11
  * Version: 2.0.2
12
12
  * Dependencies:
13
13
  */
@@ -493,15 +493,18 @@ const getHashParamValue = (hash, param) => {
493
493
  };
494
494
 
495
495
  const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, applicationId: applicationId}) => {
496
+ const openid4vpConfiguration = !!walletProviderId || !!redirectUri ? {
497
+ redirectUri: redirectUri,
498
+ walletProviderId: walletProviderId
499
+ } : undefined;
496
500
  const postData = {
497
501
  credentialQuery: credentialQuery,
498
502
  challenge: challenge,
499
503
  applicationId: applicationId,
500
- redirectUri: redirectUri,
501
- walletProviderId: walletProviderId,
502
- dcApiSupported: dcApiSupported
504
+ dcApiSupported: dcApiSupported,
505
+ openid4vpConfiguration: openid4vpConfiguration
503
506
  };
504
- const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions`, {
507
+ const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions`, {
505
508
  method: "POST",
506
509
  headers: {
507
510
  "Content-Type": "application/json"
@@ -522,7 +525,7 @@ const createSession = async ({credentialQuery: credentialQuery, challenge: chall
522
525
  };
523
526
 
524
527
  const abortSession = async ({apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey}) => {
525
- const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/abort`, {
528
+ const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions/${sessionId}/abort`, {
526
529
  method: "POST",
527
530
  headers: {
528
531
  "Content-Type": "application/json",
@@ -772,8 +775,7 @@ const requestCredentialsWithDigitalCredentialsApi = async options => {
772
775
  sessionId: sessionId,
773
776
  sessionKey: sessionKey,
774
777
  challenge: challenge,
775
- protocol: parsedCredentialResponse.protocol,
776
- data: parsedCredentialResponse.data
778
+ response: parsedCredentialResponse
777
779
  });
778
780
  if (credentialVerificationResult.isErr()) {
779
781
  return neverthrow.err({
@@ -814,8 +816,19 @@ const parseCredentialResponse = credentialResponse => {
814
816
  }
815
817
  });
816
818
  }
819
+ if (typeof credentialResponse === "object" && "toJSON" in credentialResponse && typeof credentialResponse.toJSON === "function") {
820
+ return neverthrow.ok(credentialResponse.toJSON());
821
+ }
817
822
  if (typeof credentialResponse === "object") {
818
- return neverthrow.ok(credentialResponse);
823
+ const entries = [];
824
+ for (const key in credentialResponse) {
825
+ const value = credentialResponse[key];
826
+ if (typeof value === "function" || value === undefined || value === null) {
827
+ continue;
828
+ }
829
+ entries.push([ key, value ]);
830
+ }
831
+ return neverthrow.ok(Object.fromEntries(entries));
819
832
  }
820
833
  if (typeof credentialResponse === "string") {
821
834
  try {
@@ -841,13 +854,11 @@ const parseCredentialResponse = credentialResponse => {
841
854
  };
842
855
 
843
856
  const verifyCredentialResponse = async options => {
844
- const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, protocol: protocol, data: data} = options;
845
- const requestBody = {
846
- protocol: protocol,
847
- data: data,
857
+ const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, response: response} = options;
858
+ const requestBody = Object.assign(Object.assign({}, response), {
848
859
  challenge: challenge
849
- };
850
- const credentialVerificationResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/dc-api/response`, {
860
+ });
861
+ const credentialVerificationResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions/${sessionId}/dc-api/response`, {
851
862
  method: "POST",
852
863
  headers: {
853
864
  "Content-Type": "application/json",