@mattrglobal/verifier-sdk-web 2.0.0-preview-digital-credential-api.4 → 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 +53 -27
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +53 -27
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/index.d.ts +0 -1
- package/dist/typings/verifier/types/credential-presentation.d.ts +48 -4
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +71 -15
- package/dist/typings/verifier/utils.d.ts +0 -6
- package/dist/verifier-js.development.js +52 -26
- 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
|
|
|
@@ -172,6 +172,22 @@ const CredentialQueryValidator = v__namespace.object({
|
|
|
172
172
|
})))
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
+
const DcqlCredentialQueryValidator = v__namespace.object({
|
|
176
|
+
credentials: v__namespace.array(v__namespace.object({
|
|
177
|
+
id: v__namespace.string(),
|
|
178
|
+
format: v__namespace.string(),
|
|
179
|
+
meta: v__namespace.optional(v__namespace.unknown()),
|
|
180
|
+
claims: v__namespace.array(v__namespace.object({
|
|
181
|
+
path: v__namespace.array(v__namespace.string())
|
|
182
|
+
}))
|
|
183
|
+
})),
|
|
184
|
+
credential_sets: v__namespace.optional(v__namespace.array(v__namespace.object({
|
|
185
|
+
options: v__namespace.array(v__namespace.array(v__namespace.string())),
|
|
186
|
+
required: v__namespace.optional(v__namespace.boolean()),
|
|
187
|
+
purpose: v__namespace.optional(v__namespace.unknown())
|
|
188
|
+
})))
|
|
189
|
+
});
|
|
190
|
+
|
|
175
191
|
var PresentationErrorType;
|
|
176
192
|
|
|
177
193
|
(function(PresentationErrorType) {
|
|
@@ -192,7 +208,7 @@ const PresentationResultRelaxValidator = v__namespace.object({
|
|
|
192
208
|
});
|
|
193
209
|
|
|
194
210
|
v__namespace.object({
|
|
195
|
-
credentialQuery: v__namespace.array(CredentialQueryValidator),
|
|
211
|
+
credentialQuery: v__namespace.union([ v__namespace.array(CredentialQueryValidator), DcqlCredentialQueryValidator ]),
|
|
196
212
|
challenge: v__namespace.string(),
|
|
197
213
|
redirectUri: v__namespace.optional(v__namespace.string()),
|
|
198
214
|
walletProviderId: v__namespace.optional(v__namespace.string())
|
|
@@ -231,7 +247,7 @@ var MessageEventDataType;
|
|
|
231
247
|
})(MessageEventDataType || (MessageEventDataType = {}));
|
|
232
248
|
|
|
233
249
|
const RequestCredentialsSameDeviceOptionsValidator = v__namespace.object({
|
|
234
|
-
credentialQuery: v__namespace.pipe(v__namespace.array(CredentialQueryValidator), v__namespace.nonEmpty()),
|
|
250
|
+
credentialQuery: v__namespace.union([ v__namespace.pipe(v__namespace.array(CredentialQueryValidator), v__namespace.nonEmpty()), DcqlCredentialQueryValidator ]),
|
|
235
251
|
redirectUri: v__namespace.string(),
|
|
236
252
|
challenge: v__namespace.optional(v__namespace.string()),
|
|
237
253
|
walletProviderId: v__namespace.optional(v__namespace.string()),
|
|
@@ -239,7 +255,7 @@ const RequestCredentialsSameDeviceOptionsValidator = v__namespace.object({
|
|
|
239
255
|
});
|
|
240
256
|
|
|
241
257
|
const RequestCredentialsCrossDeviceOptionsValidator = v__namespace.object({
|
|
242
|
-
credentialQuery: v__namespace.pipe(v__namespace.array(CredentialQueryValidator), v__namespace.nonEmpty()),
|
|
258
|
+
credentialQuery: v__namespace.union([ v__namespace.pipe(v__namespace.array(CredentialQueryValidator), v__namespace.nonEmpty()), DcqlCredentialQueryValidator ]),
|
|
243
259
|
crossDeviceCallback: v__namespace.object({
|
|
244
260
|
onComplete: v__namespace.function(),
|
|
245
261
|
onFailure: v__namespace.function()
|
|
@@ -250,7 +266,7 @@ const RequestCredentialsCrossDeviceOptionsValidator = v__namespace.object({
|
|
|
250
266
|
});
|
|
251
267
|
|
|
252
268
|
const RequestCredentialsAutoDetectDeviceOptionsValidator = v__namespace.object({
|
|
253
|
-
credentialQuery: v__namespace.pipe(v__namespace.array(CredentialQueryValidator), v__namespace.nonEmpty()),
|
|
269
|
+
credentialQuery: v__namespace.union([ v__namespace.pipe(v__namespace.array(CredentialQueryValidator), v__namespace.nonEmpty()), DcqlCredentialQueryValidator ]),
|
|
254
270
|
crossDeviceCallback: v__namespace.object({
|
|
255
271
|
onComplete: v__namespace.function(),
|
|
256
272
|
onFailure: v__namespace.function()
|
|
@@ -391,15 +407,6 @@ const isMobileDetect = userAgent => isMobile.isMobile({
|
|
|
391
407
|
tablet: false
|
|
392
408
|
});
|
|
393
409
|
|
|
394
|
-
const isDigitalCredentialsApiSupported = () => {
|
|
395
|
-
var _a;
|
|
396
|
-
try {
|
|
397
|
-
return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.identity) === null || _a === void 0 ? void 0 : _a.get) === "function";
|
|
398
|
-
} catch (error) {
|
|
399
|
-
return false;
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
|
|
403
410
|
const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQuery, challenge: challenge, apiBaseUrl: apiBaseUrl, protocol: protocol}) => {
|
|
404
411
|
const postData = Object.assign({
|
|
405
412
|
credentialQuery: credentialQuery,
|
|
@@ -669,21 +676,41 @@ const requestCredentialsDigitalCredentialsApi = async options => {
|
|
|
669
676
|
}
|
|
670
677
|
const {request: request, sessionId: sessionId} = createSessionResult.value;
|
|
671
678
|
window.localStorage.setItem(LocalStorageKey.sessionId, sessionId);
|
|
672
|
-
let
|
|
679
|
+
let response;
|
|
673
680
|
try {
|
|
674
|
-
|
|
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
|
+
}
|
|
675
708
|
} catch (_a) {
|
|
676
709
|
return neverthrow.err({
|
|
677
710
|
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
678
711
|
message: "Failed call to digital credentials api"
|
|
679
712
|
});
|
|
680
713
|
}
|
|
681
|
-
let response;
|
|
682
|
-
try {
|
|
683
|
-
response = JSON.parse(rawResponse.data);
|
|
684
|
-
} catch (_b) {
|
|
685
|
-
response = rawResponse.data;
|
|
686
|
-
}
|
|
687
714
|
const result = await getDigitalCredentialsApiSessionResult({
|
|
688
715
|
challenge: challenge,
|
|
689
716
|
sessionId: sessionId,
|
|
@@ -712,7 +739,7 @@ const requestCredentials = async options => {
|
|
|
712
739
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
713
740
|
const {challenge: challenge = generateChallenge()} = options;
|
|
714
741
|
const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : isMobileDetect(navigator.userAgent) ? exports.Mode.sameDevice : exports.Mode.crossDevice;
|
|
715
|
-
if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow &&
|
|
742
|
+
if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow && mode === exports.Mode.crossDevice) {
|
|
716
743
|
console.log("Digital Credentials API support found, proceeding with request using API in cross device flow");
|
|
717
744
|
return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
|
|
718
745
|
initialiseOptions: initialiseOptions,
|
|
@@ -721,7 +748,7 @@ const requestCredentials = async options => {
|
|
|
721
748
|
} else if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow) {
|
|
722
749
|
console.log("Digital Credentials API support not found, falling back to OpenID4VP");
|
|
723
750
|
}
|
|
724
|
-
if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow &&
|
|
751
|
+
if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow && mode === exports.Mode.sameDevice) {
|
|
725
752
|
console.log("Digital Credentials API support found, proceeding with request using API in same device flow");
|
|
726
753
|
return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
|
|
727
754
|
initialiseOptions: initialiseOptions,
|
|
@@ -812,8 +839,7 @@ const handleRedirectCallback = async () => {
|
|
|
812
839
|
|
|
813
840
|
const utils = {
|
|
814
841
|
generateChallenge: generateChallenge,
|
|
815
|
-
unwrap: unwrap
|
|
816
|
-
isDigitalCredentialsApiSupported: isDigitalCredentialsApiSupported
|
|
842
|
+
unwrap: unwrap
|
|
817
843
|
};
|
|
818
844
|
|
|
819
845
|
exports.handleRedirectCallback = handleRedirectCallback;
|