@mattrglobal/verifier-sdk-web 2.0.0-preview-digital-credential-api.5 → 2.0.0-preview-digital-credential-api.6
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/dist/lib/verifier-js-no-deps.cjs.js +33 -23
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +33 -23
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/index.d.ts +0 -1
- package/dist/typings/verifier/utils.d.ts +0 -6
- package/dist/verifier-js.development.js +33 -22
- 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
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2025-
|
|
11
|
-
* Version: 2.0.0-preview-digital-credential-api.
|
|
10
|
+
* Generated: 2025-06-13
|
|
11
|
+
* Version: 2.0.0-preview-digital-credential-api.6
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -407,15 +407,6 @@ const isMobileDetect = userAgent => isMobile.isMobile({
|
|
|
407
407
|
tablet: false
|
|
408
408
|
});
|
|
409
409
|
|
|
410
|
-
const isDigitalCredentialsApiSupported = () => {
|
|
411
|
-
var _a;
|
|
412
|
-
try {
|
|
413
|
-
return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.identity) === null || _a === void 0 ? void 0 : _a.get) === "function";
|
|
414
|
-
} catch (error) {
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
|
|
419
410
|
const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQuery, challenge: challenge, apiBaseUrl: apiBaseUrl, protocol: protocol}) => {
|
|
420
411
|
const postData = Object.assign({
|
|
421
412
|
credentialQuery: credentialQuery,
|
|
@@ -685,21 +676,41 @@ const requestCredentialsDigitalCredentialsApi = async options => {
|
|
|
685
676
|
}
|
|
686
677
|
const {request: request, sessionId: sessionId} = createSessionResult.value;
|
|
687
678
|
window.localStorage.setItem(LocalStorageKey.sessionId, sessionId);
|
|
688
|
-
let
|
|
679
|
+
let response;
|
|
689
680
|
try {
|
|
690
|
-
|
|
681
|
+
if ("providers" in request.digital) {
|
|
682
|
+
let requestData;
|
|
683
|
+
const providerRequest = request.digital.providers[0];
|
|
684
|
+
if (providerRequest.protocol === "preview") {
|
|
685
|
+
console.log(`DC API Preview Request: ${JSON.stringify(request)}`);
|
|
686
|
+
const rawResponse = await navigator.identity.get(request);
|
|
687
|
+
response = rawResponse.data;
|
|
688
|
+
} else {
|
|
689
|
+
requestData = {
|
|
690
|
+
protocol: providerRequest.protocol,
|
|
691
|
+
data: JSON.parse(providerRequest.request)
|
|
692
|
+
};
|
|
693
|
+
const modernRequest = Object.assign(Object.assign({}, requestData.protocol === "org-iso-mdoc" && {
|
|
694
|
+
mediation: "required"
|
|
695
|
+
}), {
|
|
696
|
+
digital: {
|
|
697
|
+
requests: [ requestData ]
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
console.log(`DC API Request: ${JSON.stringify(modernRequest)}`);
|
|
701
|
+
const rawResponse = await navigator.credentials.get(modernRequest);
|
|
702
|
+
response = rawResponse.data;
|
|
703
|
+
}
|
|
704
|
+
} else {
|
|
705
|
+
const rawResponse = await navigator.credentials.get(request);
|
|
706
|
+
response = rawResponse.data;
|
|
707
|
+
}
|
|
691
708
|
} catch (_a) {
|
|
692
709
|
return neverthrow.err({
|
|
693
710
|
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
694
711
|
message: "Failed call to digital credentials api"
|
|
695
712
|
});
|
|
696
713
|
}
|
|
697
|
-
let response;
|
|
698
|
-
try {
|
|
699
|
-
response = JSON.parse(rawResponse.data);
|
|
700
|
-
} catch (_b) {
|
|
701
|
-
response = rawResponse.data;
|
|
702
|
-
}
|
|
703
714
|
const result = await getDigitalCredentialsApiSessionResult({
|
|
704
715
|
challenge: challenge,
|
|
705
716
|
sessionId: sessionId,
|
|
@@ -728,7 +739,7 @@ const requestCredentials = async options => {
|
|
|
728
739
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
729
740
|
const {challenge: challenge = generateChallenge()} = options;
|
|
730
741
|
const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : isMobileDetect(navigator.userAgent) ? exports.Mode.sameDevice : exports.Mode.crossDevice;
|
|
731
|
-
if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow &&
|
|
742
|
+
if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow && mode === exports.Mode.crossDevice) {
|
|
732
743
|
console.log("Digital Credentials API support found, proceeding with request using API in cross device flow");
|
|
733
744
|
return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
|
|
734
745
|
initialiseOptions: initialiseOptions,
|
|
@@ -737,7 +748,7 @@ const requestCredentials = async options => {
|
|
|
737
748
|
} else if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow) {
|
|
738
749
|
console.log("Digital Credentials API support not found, falling back to OpenID4VP");
|
|
739
750
|
}
|
|
740
|
-
if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow &&
|
|
751
|
+
if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow && mode === exports.Mode.sameDevice) {
|
|
741
752
|
console.log("Digital Credentials API support found, proceeding with request using API in same device flow");
|
|
742
753
|
return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
|
|
743
754
|
initialiseOptions: initialiseOptions,
|
|
@@ -828,8 +839,7 @@ const handleRedirectCallback = async () => {
|
|
|
828
839
|
|
|
829
840
|
const utils = {
|
|
830
841
|
generateChallenge: generateChallenge,
|
|
831
|
-
unwrap: unwrap
|
|
832
|
-
isDigitalCredentialsApiSupported: isDigitalCredentialsApiSupported
|
|
842
|
+
unwrap: unwrap
|
|
833
843
|
};
|
|
834
844
|
|
|
835
845
|
exports.handleRedirectCallback = handleRedirectCallback;
|