@mattrglobal/verifier-sdk-web 1.0.2-unstable.99 → 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 +45 -10
- package/dist/lib/verifier-js-no-deps.cjs.js +157 -8
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +157 -8
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/index.d.ts +1 -0
- package/dist/typings/verifier/requestCredentialsViaDigitalCredentialsApi.d.ts +7 -0
- package/dist/typings/verifier/types/credential-presentation.d.ts +8 -0
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +17 -1
- package/dist/typings/verifier/utils.d.ts +33 -1
- package/dist/verifier-js.development.js +150 -8
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +3 -3
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +3 -3
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +2 -2
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/
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2024-10-
|
|
11
|
-
* Version:
|
|
10
|
+
* Generated: 2024-10-21
|
|
11
|
+
* Version: 2.0.0-preview-digital-credential-api.2
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -200,6 +200,11 @@ const CreateSessionResponseValidator = v__namespace.object({
|
|
|
200
200
|
sessionUrl: v__namespace.string()
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
+
const CreateDigitalCredentialsApiSessionResponseValidator = v__namespace.object({
|
|
204
|
+
sessionId: v__namespace.string(),
|
|
205
|
+
request: v__namespace.object({})
|
|
206
|
+
});
|
|
207
|
+
|
|
203
208
|
var LocalStorageKey;
|
|
204
209
|
|
|
205
210
|
(function(LocalStorageKey) {
|
|
@@ -262,7 +267,9 @@ exports.RequestCredentialsErrorType = void 0;
|
|
|
262
267
|
})(exports.RequestCredentialsErrorType || (exports.RequestCredentialsErrorType = {}));
|
|
263
268
|
|
|
264
269
|
const InitialiseOptionsValidator = v__namespace.object({
|
|
265
|
-
apiBaseUrl: v__namespace.string()
|
|
270
|
+
apiBaseUrl: v__namespace.string(),
|
|
271
|
+
enableDigitalCredentialsApiSameDeviceFlow: v__namespace.optional(v__namespace.boolean()),
|
|
272
|
+
enableDigitalCredentialsApiCrossDeviceFlow: v__namespace.optional(v__namespace.boolean())
|
|
266
273
|
});
|
|
267
274
|
|
|
268
275
|
let initialiseOptions = undefined;
|
|
@@ -378,6 +385,64 @@ const isMobileDetect = userAgent => isMobile.isMobile({
|
|
|
378
385
|
tablet: false
|
|
379
386
|
});
|
|
380
387
|
|
|
388
|
+
const isDigitalCredentialsApiSupported = () => {
|
|
389
|
+
var _a;
|
|
390
|
+
try {
|
|
391
|
+
return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.identity) === null || _a === void 0 ? void 0 : _a.get) === "function";
|
|
392
|
+
} catch (error) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQuery, challenge: challenge, apiBaseUrl: apiBaseUrl}) => {
|
|
398
|
+
const postData = {
|
|
399
|
+
credentialQuery: credentialQuery,
|
|
400
|
+
challenge: challenge
|
|
401
|
+
};
|
|
402
|
+
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/browserApi/request`, {
|
|
403
|
+
method: "POST",
|
|
404
|
+
headers: {
|
|
405
|
+
"Content-Type": "application/json"
|
|
406
|
+
},
|
|
407
|
+
body: JSON.stringify(postData)
|
|
408
|
+
});
|
|
409
|
+
if (responseResult.isErr()) {
|
|
410
|
+
return neverthrow.err(responseResult.error);
|
|
411
|
+
}
|
|
412
|
+
const data = await responseResult.value.json();
|
|
413
|
+
if (!isType(CreateDigitalCredentialsApiSessionResponseValidator)(data)) {
|
|
414
|
+
return neverthrow.err({
|
|
415
|
+
type: SafeFetchCommonRespondErrorType.UnexpectedRespond,
|
|
416
|
+
message: "Create digital credentials api session return unsupported response"
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
return neverthrow.ok(data);
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const getDigitalCredentialsApiSessionResult = async ({challenge: challenge, sessionId: sessionId, response: response, apiBaseUrl: apiBaseUrl}) => {
|
|
423
|
+
const postData = {
|
|
424
|
+
challenge: challenge,
|
|
425
|
+
sessionId: sessionId,
|
|
426
|
+
response: response
|
|
427
|
+
};
|
|
428
|
+
const fetchResultFn = async () => await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/browserApi/response`, {
|
|
429
|
+
method: "POST",
|
|
430
|
+
headers: {
|
|
431
|
+
"Content-Type": "application/json"
|
|
432
|
+
},
|
|
433
|
+
body: JSON.stringify(postData)
|
|
434
|
+
});
|
|
435
|
+
const responseResult = await withRetrySafeFetch(fetchResultFn, {
|
|
436
|
+
retries: 2,
|
|
437
|
+
retryHttpStatus: 404
|
|
438
|
+
});
|
|
439
|
+
if (responseResult.isErr()) {
|
|
440
|
+
return neverthrow.err(responseResult.error);
|
|
441
|
+
}
|
|
442
|
+
const data = await responseResult.value.json();
|
|
443
|
+
return neverthrow.ok(data);
|
|
444
|
+
};
|
|
445
|
+
|
|
381
446
|
exports.CrossDeviceCallbackErrorType = void 0;
|
|
382
447
|
|
|
383
448
|
(function(CrossDeviceCallbackErrorType) {
|
|
@@ -519,12 +584,12 @@ const requestCredentialsCrossDevice = async options => {
|
|
|
519
584
|
});
|
|
520
585
|
};
|
|
521
586
|
|
|
522
|
-
var SameDeviceRequestCredentialsErrorMessage;
|
|
587
|
+
var SameDeviceRequestCredentialsErrorMessage$1;
|
|
523
588
|
|
|
524
589
|
(function(SameDeviceRequestCredentialsErrorMessage) {
|
|
525
590
|
SameDeviceRequestCredentialsErrorMessage["FailedToStoreChallenge"] = "Failed to store challenge";
|
|
526
591
|
SameDeviceRequestCredentialsErrorMessage["FailedToCreateSession"] = "Failed to create session";
|
|
527
|
-
})(SameDeviceRequestCredentialsErrorMessage || (SameDeviceRequestCredentialsErrorMessage = {}));
|
|
592
|
+
})(SameDeviceRequestCredentialsErrorMessage$1 || (SameDeviceRequestCredentialsErrorMessage$1 = {}));
|
|
528
593
|
|
|
529
594
|
const requestCredentialsSameDevice = async options => {
|
|
530
595
|
const {challenge: challenge, credentialQuery: credentialQuery, redirectUri: redirectUri, walletProviderId: walletProviderId, initialiseOptions: initialiseOptions} = options;
|
|
@@ -534,7 +599,7 @@ const requestCredentialsSameDevice = async options => {
|
|
|
534
599
|
if (!storedChallenge) {
|
|
535
600
|
return neverthrow.err({
|
|
536
601
|
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
537
|
-
message: SameDeviceRequestCredentialsErrorMessage.FailedToStoreChallenge
|
|
602
|
+
message: SameDeviceRequestCredentialsErrorMessage$1.FailedToStoreChallenge
|
|
538
603
|
});
|
|
539
604
|
}
|
|
540
605
|
const createSessionResult = await createSession({
|
|
@@ -547,7 +612,7 @@ const requestCredentialsSameDevice = async options => {
|
|
|
547
612
|
if (createSessionResult.isErr()) {
|
|
548
613
|
return neverthrow.err({
|
|
549
614
|
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
550
|
-
message: SameDeviceRequestCredentialsErrorMessage.FailedToCreateSession,
|
|
615
|
+
message: SameDeviceRequestCredentialsErrorMessage$1.FailedToCreateSession,
|
|
551
616
|
cause: createSessionResult.error
|
|
552
617
|
});
|
|
553
618
|
}
|
|
@@ -559,6 +624,71 @@ const requestCredentialsSameDevice = async options => {
|
|
|
559
624
|
});
|
|
560
625
|
};
|
|
561
626
|
|
|
627
|
+
var SameDeviceRequestCredentialsErrorMessage;
|
|
628
|
+
|
|
629
|
+
(function(SameDeviceRequestCredentialsErrorMessage) {
|
|
630
|
+
SameDeviceRequestCredentialsErrorMessage["FailedToStoreChallenge"] = "Failed to store challenge";
|
|
631
|
+
SameDeviceRequestCredentialsErrorMessage["FailedToCreateSession"] = "Failed to create session";
|
|
632
|
+
})(SameDeviceRequestCredentialsErrorMessage || (SameDeviceRequestCredentialsErrorMessage = {}));
|
|
633
|
+
|
|
634
|
+
const requestCredentialsDigitalCredentialsApi = async options => {
|
|
635
|
+
const {challenge: challenge, credentialQuery: credentialQuery, initialiseOptions: initialiseOptions} = options;
|
|
636
|
+
const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
|
|
637
|
+
window.localStorage.setItem(LocalStorageKey.challenge, challenge);
|
|
638
|
+
const storedChallenge = window.localStorage.getItem(LocalStorageKey.challenge);
|
|
639
|
+
if (!storedChallenge) {
|
|
640
|
+
return neverthrow.err({
|
|
641
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
642
|
+
message: SameDeviceRequestCredentialsErrorMessage.FailedToStoreChallenge
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
const createSessionResult = await createDigitalCredentialsApiSession({
|
|
646
|
+
credentialQuery: credentialQuery,
|
|
647
|
+
challenge: storedChallenge,
|
|
648
|
+
apiBaseUrl: apiBaseUrl
|
|
649
|
+
});
|
|
650
|
+
if (createSessionResult.isErr()) {
|
|
651
|
+
return neverthrow.err({
|
|
652
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
653
|
+
message: SameDeviceRequestCredentialsErrorMessage.FailedToCreateSession,
|
|
654
|
+
cause: createSessionResult.error
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
const {request: request, sessionId: sessionId} = createSessionResult.value;
|
|
658
|
+
window.localStorage.setItem(LocalStorageKey.sessionId, sessionId);
|
|
659
|
+
let rawResponse;
|
|
660
|
+
try {
|
|
661
|
+
rawResponse = await navigator.identity.get(request);
|
|
662
|
+
} catch (_a) {
|
|
663
|
+
return neverthrow.err({
|
|
664
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
665
|
+
message: "Failed call to digital credentials api"
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
let response;
|
|
669
|
+
try {
|
|
670
|
+
response = JSON.parse(rawResponse.data);
|
|
671
|
+
} catch (_b) {
|
|
672
|
+
response = rawResponse.data;
|
|
673
|
+
}
|
|
674
|
+
const result = await getDigitalCredentialsApiSessionResult({
|
|
675
|
+
challenge: challenge,
|
|
676
|
+
sessionId: sessionId,
|
|
677
|
+
response: response,
|
|
678
|
+
apiBaseUrl: apiBaseUrl
|
|
679
|
+
});
|
|
680
|
+
if (result.isOk()) {
|
|
681
|
+
return neverthrow.ok({
|
|
682
|
+
sessionId: sessionId,
|
|
683
|
+
result: result.value
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
return neverthrow.err({
|
|
687
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
688
|
+
message: "Invalid response from digital credentials api"
|
|
689
|
+
});
|
|
690
|
+
};
|
|
691
|
+
|
|
562
692
|
const requestCredentials = async options => {
|
|
563
693
|
var _a;
|
|
564
694
|
const initialiseOptions = getInitialiseOptions();
|
|
@@ -568,6 +698,24 @@ const requestCredentials = async options => {
|
|
|
568
698
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
569
699
|
const {challenge: challenge = generateChallenge()} = options;
|
|
570
700
|
const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : isMobileDetect(navigator.userAgent) ? exports.Mode.sameDevice : exports.Mode.crossDevice;
|
|
701
|
+
if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow && isDigitalCredentialsApiSupported() && mode === exports.Mode.crossDevice) {
|
|
702
|
+
console.log("Digital Credentials API support found, proceeding with request using API in cross device flow");
|
|
703
|
+
return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
|
|
704
|
+
initialiseOptions: initialiseOptions,
|
|
705
|
+
challenge: challenge
|
|
706
|
+
}));
|
|
707
|
+
} else if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow) {
|
|
708
|
+
console.log("Digital Credentials API support not found, falling back to OpenID4VP");
|
|
709
|
+
}
|
|
710
|
+
if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow && isDigitalCredentialsApiSupported() && mode === exports.Mode.sameDevice) {
|
|
711
|
+
console.log("Digital Credentials API support found, proceeding with request using API in same device flow");
|
|
712
|
+
return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
|
|
713
|
+
initialiseOptions: initialiseOptions,
|
|
714
|
+
challenge: challenge
|
|
715
|
+
}));
|
|
716
|
+
} else if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow) {
|
|
717
|
+
console.log("Digital Credentials API support not found, falling back to OpenID4VP");
|
|
718
|
+
}
|
|
571
719
|
if (mode === exports.Mode.sameDevice && "redirectUri" in options) {
|
|
572
720
|
return await requestCredentialsSameDevice(Object.assign(Object.assign({}, options), {
|
|
573
721
|
initialiseOptions: initialiseOptions,
|
|
@@ -650,7 +798,8 @@ const handleRedirectCallback = async () => {
|
|
|
650
798
|
|
|
651
799
|
const utils = {
|
|
652
800
|
generateChallenge: generateChallenge,
|
|
653
|
-
unwrap: unwrap
|
|
801
|
+
unwrap: unwrap,
|
|
802
|
+
isDigitalCredentialsApiSupported: isDigitalCredentialsApiSupported
|
|
654
803
|
};
|
|
655
804
|
|
|
656
805
|
exports.handleRedirectCallback = handleRedirectCallback;
|