@mattrglobal/verifier-sdk-web 2.3.1-unstable.4 → 2.3.1-unstable.41
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 +5 -4
- package/dist/lib/verifier-js-no-deps.cjs.js +77 -10
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +159 -66
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/verifier/requestCredentialsDigitalCredentialsApi.d.ts +13 -2
- package/dist/typings/verifier/types/credential-presentation.d.ts +20 -0
- package/dist/typings/verifier/utils.d.ts +10 -2
- package/dist/verifier-js.development.js +153 -66
- 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 +5 -5
|
@@ -5,7 +5,7 @@ import { RequestCredentialsErrorType, RequestCredentialsResponse, RequestCredent
|
|
|
5
5
|
* Request credentials for the Digital Credentials API
|
|
6
6
|
*
|
|
7
7
|
* @param options - {@link RequestCredentialsWithDcApiOptions}
|
|
8
|
-
* @
|
|
8
|
+
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export declare const requestCredentialsWithDigitalCredentialsApi: (options: RequestCredentialsWithDcApiOptions) => Promise<Result<RequestCredentialsResponse, BaseError<RequestCredentialsErrorType.RequestCredentialsFailed>>>;
|
|
11
11
|
/**
|
|
@@ -14,6 +14,17 @@ export declare const requestCredentialsWithDigitalCredentialsApi: (options: Requ
|
|
|
14
14
|
*
|
|
15
15
|
* Checks if Digital Credentials API feature is supported for the current browser.
|
|
16
16
|
*
|
|
17
|
-
* @returns boolean
|
|
17
|
+
* @returns boolean
|
|
18
18
|
*/
|
|
19
19
|
export declare const isDigitalCredentialsApiSupported: () => boolean;
|
|
20
|
+
export type DigitalCredentialsApiSupport = {
|
|
21
|
+
supported: boolean;
|
|
22
|
+
/** MATTR VII & browser supported protocols */
|
|
23
|
+
protocols?: string[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Determines DC-API support for the current browser, narrowed to the protocols it accepts.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export declare const getDigitalCredentialsApiSupport: (apiBaseUrl: string) => Promise<DigitalCredentialsApiSupport>;
|
|
@@ -329,6 +329,18 @@ export type RequestCredentialsWithDcApiOptions = {
|
|
|
329
329
|
challenge: string;
|
|
330
330
|
request: Record<string, unknown>;
|
|
331
331
|
};
|
|
332
|
+
export type VerifierConfiguration = v.InferOutput<typeof VerifierConfigurationValidator>;
|
|
333
|
+
export declare const VerifierConfigurationValidator: v.ObjectSchema<{
|
|
334
|
+
readonly dcApi: v.ObjectSchema<{
|
|
335
|
+
/**
|
|
336
|
+
* DC-API protocols that MATTR VII supports.
|
|
337
|
+
*
|
|
338
|
+
* Typed as plain strings rather than a known strict set, since the list is fetched from MATTR VII
|
|
339
|
+
* at runtime and a fixed set here could introduce version mismatches between an SDK release
|
|
340
|
+
*/
|
|
341
|
+
readonly protocols: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
342
|
+
}, undefined>;
|
|
343
|
+
}, undefined>;
|
|
332
344
|
export type CreateSessionRequest = v.InferOutput<typeof CreateSessionRequestValidator>;
|
|
333
345
|
export declare const CreateSessionRequestValidator: v.ObjectSchema<{
|
|
334
346
|
readonly credentialQuery: v.ArraySchema<v.ObjectSchema<{
|
|
@@ -341,7 +353,15 @@ export declare const CreateSessionRequestValidator: v.ObjectSchema<{
|
|
|
341
353
|
readonly challenge: v.StringSchema<undefined>;
|
|
342
354
|
readonly redirectUri: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
343
355
|
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
356
|
+
/** Indicates if DC-API is supported in the browser */
|
|
344
357
|
readonly dcApiSupported: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
358
|
+
/**
|
|
359
|
+
* DC-API request protocols that MATTR VII supports & the browser accepts.
|
|
360
|
+
*
|
|
361
|
+
* Typed as plain strings rather than a known strict set, since the list is fetched from MATTR VII
|
|
362
|
+
* at runtime and a fixed set here could introduce version mismatches between an SDK release
|
|
363
|
+
*/
|
|
364
|
+
readonly dcApiProtocols: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
345
365
|
readonly state: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
346
366
|
}, undefined>;
|
|
347
367
|
export type CreateSessionResponse = v.InferOutput<typeof CreateSessionResponseValidator>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
2
|
import { SafeFetchValidateResponseError } from "../common/safeFetch";
|
|
3
|
-
import { CreateSessionRequest, ExchangeSessionResultResponse, GetSessionStatusRequest, GetSessionStatusResponse, AbortSessionRequest, InitializeOptions, CreateSessionResponse } from "./types";
|
|
3
|
+
import { CreateSessionRequest, ExchangeSessionResultResponse, GetSessionStatusRequest, GetSessionStatusResponse, AbortSessionRequest, InitializeOptions, CreateSessionResponse, VerifierConfiguration } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* Generates a challenge string using the window.crypto API.
|
|
6
6
|
*
|
|
@@ -15,6 +15,14 @@ export declare const generateChallenge: () => string;
|
|
|
15
15
|
* @returns The value of the specified parameter, or null if the parameter is not found.
|
|
16
16
|
*/
|
|
17
17
|
export declare const getHashParamValue: (hash: string, param: string) => string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Fetches the verifier configuration MATTR VII advertises, including the DC-API protocols it
|
|
20
|
+
* can serve.
|
|
21
|
+
*
|
|
22
|
+
* @param uri - The base URL of the API.
|
|
23
|
+
* @returns A promise that resolves to a result containing either the verifier configuration or an error.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getVerifierConfiguration: (uri: string) => Promise<Result<VerifierConfiguration, SafeFetchValidateResponseError>>;
|
|
18
26
|
/**
|
|
19
27
|
* Creates a new session with the provided parameters.
|
|
20
28
|
*
|
|
@@ -26,7 +34,7 @@ export declare const getHashParamValue: (hash: string, param: string) => string
|
|
|
26
34
|
* @param walletProviderId - optional, The ID of the wallet provider, if not provided the default wallet provider will be used.
|
|
27
35
|
* @returns A promise that resolves to a result containing either the created session response or an error.
|
|
28
36
|
*/
|
|
29
|
-
export declare const createSession: ({ credentialQuery, challenge, redirectUri, apiBaseUrl, walletProviderId, dcApiSupported, applicationId, state, }: CreateSessionRequest & InitializeOptions) => Promise<Result<CreateSessionResponse, SafeFetchValidateResponseError>>;
|
|
37
|
+
export declare const createSession: ({ credentialQuery, challenge, redirectUri, apiBaseUrl, walletProviderId, dcApiSupported, dcApiProtocols, applicationId, state, }: CreateSessionRequest & InitializeOptions) => Promise<Result<CreateSessionResponse, SafeFetchValidateResponseError>>;
|
|
30
38
|
/**
|
|
31
39
|
* Abort a session with the provided parameters.
|
|
32
40
|
*
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2026-
|
|
10
|
+
* Generated: 2026-11-05
|
|
11
11
|
* Version: 2.3.0
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*
|
|
14
14
|
* neverthrow -- 4.3.0
|
|
15
15
|
*
|
|
16
|
-
* valibot -- 1.2
|
|
16
|
+
* valibot -- 1.4.2
|
|
17
17
|
*
|
|
18
18
|
* is-mobile -- 4.0.0
|
|
19
19
|
*/
|
|
@@ -547,8 +547,15 @@
|
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
var store$4;
|
|
550
|
+
var DEFAULT_CONFIG = {
|
|
551
|
+
lang: void 0,
|
|
552
|
+
message: void 0,
|
|
553
|
+
abortEarly: void 0,
|
|
554
|
+
abortPipeEarly: void 0
|
|
555
|
+
};
|
|
550
556
|
function getGlobalConfig(config$1) {
|
|
551
557
|
var _config$1$lang, _store$, _config$1$abortEarly, _store$2, _config$1$abortPipeEa, _store$3;
|
|
558
|
+
if (!config$1 && !store$4) return DEFAULT_CONFIG;
|
|
552
559
|
return {
|
|
553
560
|
lang: (_config$1$lang = config$1 === null || config$1 === void 0 ? void 0 : config$1.lang) !== null && _config$1$lang !== void 0 ? _config$1$lang : (_store$ = store$4) === null || _store$ === void 0 ? void 0 : _store$.lang,
|
|
554
561
|
message: config$1 === null || config$1 === void 0 ? void 0 : config$1.message,
|
|
@@ -604,19 +611,25 @@
|
|
|
604
611
|
if (isSchema) dataset.typed = false;
|
|
605
612
|
if (dataset.issues) dataset.issues.push(issue); else dataset.issues = [ issue ];
|
|
606
613
|
}
|
|
614
|
+
var _standardCache = new WeakMap;
|
|
607
615
|
function _getStandardProps(context) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
616
|
+
var cached = _standardCache.get(context);
|
|
617
|
+
if (!cached) {
|
|
618
|
+
cached = {
|
|
619
|
+
version: 1,
|
|
620
|
+
vendor: "valibot",
|
|
621
|
+
validate: function validate(value$1) {
|
|
622
|
+
return context["~run"]({
|
|
623
|
+
value: value$1
|
|
624
|
+
}, getGlobalConfig());
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
_standardCache.set(context, cached);
|
|
628
|
+
}
|
|
629
|
+
return cached;
|
|
617
630
|
}
|
|
618
631
|
function _isValidObjectKey(object$1, key) {
|
|
619
|
-
return Object.
|
|
632
|
+
return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
620
633
|
}
|
|
621
634
|
function _joinExpects(values$1, separator) {
|
|
622
635
|
var _list$;
|
|
@@ -731,18 +744,18 @@
|
|
|
731
744
|
key: key,
|
|
732
745
|
value: value$1
|
|
733
746
|
};
|
|
734
|
-
var
|
|
747
|
+
var _iterator16 = _createForOfIteratorHelper(itemDataset.issues), _step16;
|
|
735
748
|
try {
|
|
736
|
-
for (
|
|
749
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done; ) {
|
|
737
750
|
var _dataset$issues;
|
|
738
|
-
var issue =
|
|
751
|
+
var issue = _step16.value;
|
|
739
752
|
if (issue.path) issue.path.unshift(pathItem); else issue.path = [ pathItem ];
|
|
740
753
|
(_dataset$issues = dataset.issues) === null || _dataset$issues === void 0 || _dataset$issues.push(issue);
|
|
741
754
|
}
|
|
742
755
|
} catch (err) {
|
|
743
|
-
|
|
756
|
+
_iterator16.e(err);
|
|
744
757
|
} finally {
|
|
745
|
-
|
|
758
|
+
_iterator16.f();
|
|
746
759
|
}
|
|
747
760
|
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
748
761
|
if (config$1.abortEarly) {
|
|
@@ -842,18 +855,18 @@
|
|
|
842
855
|
key: key,
|
|
843
856
|
value: value$1
|
|
844
857
|
};
|
|
845
|
-
var
|
|
858
|
+
var _iterator34 = _createForOfIteratorHelper(valueDataset.issues), _step34;
|
|
846
859
|
try {
|
|
847
|
-
for (
|
|
848
|
-
var _dataset$
|
|
849
|
-
var issue =
|
|
860
|
+
for (_iterator34.s(); !(_step34 = _iterator34.n()).done; ) {
|
|
861
|
+
var _dataset$issues11;
|
|
862
|
+
var issue = _step34.value;
|
|
850
863
|
if (issue.path) issue.path.unshift(pathItem); else issue.path = [ pathItem ];
|
|
851
|
-
(_dataset$
|
|
864
|
+
(_dataset$issues11 = dataset.issues) === null || _dataset$issues11 === void 0 || _dataset$issues11.push(issue);
|
|
852
865
|
}
|
|
853
866
|
} catch (err) {
|
|
854
|
-
|
|
867
|
+
_iterator34.e(err);
|
|
855
868
|
} finally {
|
|
856
|
-
|
|
869
|
+
_iterator34.f();
|
|
857
870
|
}
|
|
858
871
|
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
859
872
|
if (config$1.abortEarly) {
|
|
@@ -956,18 +969,18 @@
|
|
|
956
969
|
key: entryKey,
|
|
957
970
|
value: entryValue
|
|
958
971
|
};
|
|
959
|
-
var
|
|
972
|
+
var _iterator43 = _createForOfIteratorHelper(keyDataset.issues), _step43;
|
|
960
973
|
try {
|
|
961
|
-
for (
|
|
962
|
-
var _dataset$
|
|
963
|
-
var issue =
|
|
974
|
+
for (_iterator43.s(); !(_step43 = _iterator43.n()).done; ) {
|
|
975
|
+
var _dataset$issues17;
|
|
976
|
+
var issue = _step43.value;
|
|
964
977
|
issue.path = [ pathItem ];
|
|
965
|
-
(_dataset$
|
|
978
|
+
(_dataset$issues17 = dataset.issues) === null || _dataset$issues17 === void 0 || _dataset$issues17.push(issue);
|
|
966
979
|
}
|
|
967
980
|
} catch (err) {
|
|
968
|
-
|
|
981
|
+
_iterator43.e(err);
|
|
969
982
|
} finally {
|
|
970
|
-
|
|
983
|
+
_iterator43.f();
|
|
971
984
|
}
|
|
972
985
|
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
973
986
|
if (config$1.abortEarly) {
|
|
@@ -986,18 +999,18 @@
|
|
|
986
999
|
key: entryKey,
|
|
987
1000
|
value: entryValue
|
|
988
1001
|
};
|
|
989
|
-
var
|
|
1002
|
+
var _iterator44 = _createForOfIteratorHelper(valueDataset.issues), _step44;
|
|
990
1003
|
try {
|
|
991
|
-
for (
|
|
992
|
-
var _dataset$
|
|
993
|
-
var _issue5 =
|
|
1004
|
+
for (_iterator44.s(); !(_step44 = _iterator44.n()).done; ) {
|
|
1005
|
+
var _dataset$issues18;
|
|
1006
|
+
var _issue5 = _step44.value;
|
|
994
1007
|
if (_issue5.path) _issue5.path.unshift(_pathItem5); else _issue5.path = [ _pathItem5 ];
|
|
995
|
-
(_dataset$
|
|
1008
|
+
(_dataset$issues18 = dataset.issues) === null || _dataset$issues18 === void 0 || _dataset$issues18.push(_issue5);
|
|
996
1009
|
}
|
|
997
1010
|
} catch (err) {
|
|
998
|
-
|
|
1011
|
+
_iterator44.e(err);
|
|
999
1012
|
} finally {
|
|
1000
|
-
|
|
1013
|
+
_iterator44.f();
|
|
1001
1014
|
}
|
|
1002
1015
|
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1003
1016
|
if (config$1.abortEarly) {
|
|
@@ -1045,18 +1058,18 @@
|
|
|
1045
1058
|
key: key,
|
|
1046
1059
|
value: value$1
|
|
1047
1060
|
};
|
|
1048
|
-
var
|
|
1061
|
+
var _iterator52 = _createForOfIteratorHelper(valueDataset.issues), _step52;
|
|
1049
1062
|
try {
|
|
1050
|
-
for (
|
|
1051
|
-
var _dataset$
|
|
1052
|
-
var issue =
|
|
1063
|
+
for (_iterator52.s(); !(_step52 = _iterator52.n()).done; ) {
|
|
1064
|
+
var _dataset$issues23;
|
|
1065
|
+
var issue = _step52.value;
|
|
1053
1066
|
if (issue.path) issue.path.unshift(pathItem); else issue.path = [ pathItem ];
|
|
1054
|
-
(_dataset$
|
|
1067
|
+
(_dataset$issues23 = dataset.issues) === null || _dataset$issues23 === void 0 || _dataset$issues23.push(issue);
|
|
1055
1068
|
}
|
|
1056
1069
|
} catch (err) {
|
|
1057
|
-
|
|
1070
|
+
_iterator52.e(err);
|
|
1058
1071
|
} finally {
|
|
1059
|
-
|
|
1072
|
+
_iterator52.f();
|
|
1060
1073
|
}
|
|
1061
1074
|
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1062
1075
|
if (config$1.abortEarly) {
|
|
@@ -1122,17 +1135,28 @@
|
|
|
1122
1135
|
function _subIssues(datasets) {
|
|
1123
1136
|
var issues;
|
|
1124
1137
|
if (datasets) {
|
|
1125
|
-
var
|
|
1138
|
+
var _iterator67 = _createForOfIteratorHelper(datasets), _step67;
|
|
1126
1139
|
try {
|
|
1127
|
-
for (
|
|
1128
|
-
var
|
|
1129
|
-
|
|
1130
|
-
|
|
1140
|
+
for (_iterator67.s(); !(_step67 = _iterator67.n()).done; ) {
|
|
1141
|
+
var dataset = _step67.value;
|
|
1142
|
+
if (issues) {
|
|
1143
|
+
var _iterator68 = _createForOfIteratorHelper(dataset.issues), _step68;
|
|
1144
|
+
try {
|
|
1145
|
+
for (_iterator68.s(); !(_step68 = _iterator68.n()).done; ) {
|
|
1146
|
+
var issue = _step68.value;
|
|
1147
|
+
issues.push(issue);
|
|
1148
|
+
}
|
|
1149
|
+
} catch (err) {
|
|
1150
|
+
_iterator68.e(err);
|
|
1151
|
+
} finally {
|
|
1152
|
+
_iterator68.f();
|
|
1153
|
+
}
|
|
1154
|
+
} else issues = dataset.issues;
|
|
1131
1155
|
}
|
|
1132
1156
|
} catch (err) {
|
|
1133
|
-
|
|
1157
|
+
_iterator67.e(err);
|
|
1134
1158
|
} finally {
|
|
1135
|
-
|
|
1159
|
+
_iterator67.f();
|
|
1136
1160
|
}
|
|
1137
1161
|
}
|
|
1138
1162
|
return issues;
|
|
@@ -1156,10 +1180,10 @@
|
|
|
1156
1180
|
var validDataset;
|
|
1157
1181
|
var typedDatasets;
|
|
1158
1182
|
var untypedDatasets;
|
|
1159
|
-
var
|
|
1183
|
+
var _iterator69 = _createForOfIteratorHelper(this.options), _step69;
|
|
1160
1184
|
try {
|
|
1161
|
-
for (
|
|
1162
|
-
var schema =
|
|
1185
|
+
for (_iterator69.s(); !(_step69 = _iterator69.n()).done; ) {
|
|
1186
|
+
var schema = _step69.value;
|
|
1163
1187
|
var optionDataset = schema["~run"]({
|
|
1164
1188
|
value: dataset.value
|
|
1165
1189
|
}, config$1);
|
|
@@ -1173,9 +1197,9 @@
|
|
|
1173
1197
|
} else if (untypedDatasets) untypedDatasets.push(optionDataset); else untypedDatasets = [ optionDataset ];
|
|
1174
1198
|
}
|
|
1175
1199
|
} catch (err) {
|
|
1176
|
-
|
|
1200
|
+
_iterator69.e(err);
|
|
1177
1201
|
} finally {
|
|
1178
|
-
|
|
1202
|
+
_iterator69.f();
|
|
1179
1203
|
}
|
|
1180
1204
|
if (validDataset) return validDataset;
|
|
1181
1205
|
if (typedDatasets) {
|
|
@@ -1350,12 +1374,18 @@
|
|
|
1350
1374
|
SessionType["DigitalCredentialsApi"] = "digital-credentials-api";
|
|
1351
1375
|
SessionType["Openid4vp"] = "openid4vp";
|
|
1352
1376
|
})(SessionType || (SessionType = {}));
|
|
1377
|
+
const VerifierConfigurationValidator = object({
|
|
1378
|
+
dcApi: object({
|
|
1379
|
+
protocols: array(string())
|
|
1380
|
+
})
|
|
1381
|
+
});
|
|
1353
1382
|
object({
|
|
1354
1383
|
credentialQuery: array(CredentialQueryValidator),
|
|
1355
1384
|
challenge: string(),
|
|
1356
1385
|
redirectUri: optional(string()),
|
|
1357
1386
|
walletProviderId: optional(string()),
|
|
1358
1387
|
dcApiSupported: optional(_boolean()),
|
|
1388
|
+
dcApiProtocols: optional(array(string())),
|
|
1359
1389
|
state: optional(pipe(string(), minLength(1)))
|
|
1360
1390
|
});
|
|
1361
1391
|
const CreateSessionDigitalCredentialsValidator = object({
|
|
@@ -1617,18 +1647,40 @@
|
|
|
1617
1647
|
const urlParams = new URLSearchParams(hash.split("#")[1]);
|
|
1618
1648
|
return urlParams.get(param);
|
|
1619
1649
|
};
|
|
1620
|
-
const
|
|
1650
|
+
const getVerifierConfiguration = async uri => {
|
|
1651
|
+
const responseResult = await safeFetch(`${uri}/v2/presentations/web/configuration`, {
|
|
1652
|
+
method: "GET",
|
|
1653
|
+
headers: {
|
|
1654
|
+
"Content-Type": "application/json"
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
if (responseResult.isErr()) {
|
|
1658
|
+
return err(responseResult.error);
|
|
1659
|
+
}
|
|
1660
|
+
const body = await responseResult.value.json().catch((() => undefined));
|
|
1661
|
+
if (!isType(VerifierConfigurationValidator)(body)) {
|
|
1662
|
+
return err({
|
|
1663
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1664
|
+
message: "Verifier configuration returned unsupported response"
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
return ok(body);
|
|
1668
|
+
};
|
|
1669
|
+
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, dcApiProtocols: dcApiProtocols, applicationId: applicationId, state: state}) => {
|
|
1621
1670
|
const openid4vpConfiguration = !!walletProviderId || !!redirectUri ? {
|
|
1622
1671
|
redirectUri: redirectUri,
|
|
1623
1672
|
walletProviderId: walletProviderId
|
|
1624
1673
|
} : undefined;
|
|
1625
|
-
const postData = Object.assign({
|
|
1674
|
+
const postData = Object.assign(Object.assign(Object.assign({
|
|
1626
1675
|
credentialQuery: credentialQuery,
|
|
1627
1676
|
challenge: challenge,
|
|
1628
1677
|
applicationId: applicationId,
|
|
1629
|
-
dcApiSupported: dcApiSupported
|
|
1678
|
+
dcApiSupported: dcApiSupported
|
|
1679
|
+
}, dcApiProtocols !== undefined ? {
|
|
1680
|
+
dcApiProtocols: dcApiProtocols
|
|
1681
|
+
} : {}), {
|
|
1630
1682
|
openid4vpConfiguration: openid4vpConfiguration
|
|
1631
|
-
}, state !== undefined ? {
|
|
1683
|
+
}), state !== undefined ? {
|
|
1632
1684
|
state: state
|
|
1633
1685
|
} : {});
|
|
1634
1686
|
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions`, {
|
|
@@ -2054,9 +2106,43 @@
|
|
|
2054
2106
|
}
|
|
2055
2107
|
return ok(credentialVerificationResponse);
|
|
2056
2108
|
};
|
|
2057
|
-
const
|
|
2058
|
-
var _a;
|
|
2059
|
-
return "DigitalCredential" in
|
|
2109
|
+
const digitalCredentialsApiSupported = target => {
|
|
2110
|
+
var _a, _b;
|
|
2111
|
+
return "DigitalCredential" in target && typeof ((_b = (_a = target.navigator) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.get) === "function" && typeof target.DigitalCredential === "function" && (!("userAgentAllowsProtocol" in target.DigitalCredential) || typeof target.DigitalCredential.userAgentAllowsProtocol === "function");
|
|
2112
|
+
};
|
|
2113
|
+
const isDigitalCredentialsApiSupported = () => digitalCredentialsApiSupported(window);
|
|
2114
|
+
const getDigitalCredentialsApiSupport = async apiBaseUrl => {
|
|
2115
|
+
if (!digitalCredentialsApiSupported(window)) {
|
|
2116
|
+
return {
|
|
2117
|
+
supported: false
|
|
2118
|
+
};
|
|
2119
|
+
}
|
|
2120
|
+
const {DigitalCredential: digitalCredential} = window;
|
|
2121
|
+
if (!digitalCredential.userAgentAllowsProtocol) {
|
|
2122
|
+
return {
|
|
2123
|
+
supported: true
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
const configurationResult = await getVerifierConfiguration(apiBaseUrl);
|
|
2127
|
+
if (configurationResult.isErr()) {
|
|
2128
|
+
return {
|
|
2129
|
+
supported: true
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
const protocols = configurationResult.value.dcApi.protocols.filter((protocol => {
|
|
2133
|
+
var _a;
|
|
2134
|
+
try {
|
|
2135
|
+
return ((_a = digitalCredential.userAgentAllowsProtocol) === null || _a === void 0 ? void 0 : _a.call(digitalCredential, protocol)) === true;
|
|
2136
|
+
} catch (_b) {
|
|
2137
|
+
return false;
|
|
2138
|
+
}
|
|
2139
|
+
}));
|
|
2140
|
+
return protocols.length > 0 ? {
|
|
2141
|
+
supported: true,
|
|
2142
|
+
protocols: protocols
|
|
2143
|
+
} : {
|
|
2144
|
+
supported: false
|
|
2145
|
+
};
|
|
2060
2146
|
};
|
|
2061
2147
|
const sleep = ms => new Promise((resolve => setTimeout(resolve, ms)));
|
|
2062
2148
|
const SESSION_STATUS_POLLING_MAX_RETRY = 1e3;
|
|
@@ -2130,7 +2216,7 @@
|
|
|
2130
2216
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
2131
2217
|
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initializeOptions;
|
|
2132
2218
|
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration, state: state, onPresentationRequest: onPresentationRequest} = options;
|
|
2133
|
-
const
|
|
2219
|
+
const dcApiSupport = await getDigitalCredentialsApiSupport(apiBaseUrl);
|
|
2134
2220
|
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
2135
2221
|
const createSessionResult = await createSession({
|
|
2136
2222
|
credentialQuery: credentialQuery,
|
|
@@ -2139,7 +2225,8 @@
|
|
|
2139
2225
|
walletProviderId: (_a = openid4vpConfiguration === null || openid4vpConfiguration === void 0 ? void 0 : openid4vpConfiguration.walletProviderId) !== null && _a !== void 0 ? _a : undefined,
|
|
2140
2226
|
apiBaseUrl: apiBaseUrl,
|
|
2141
2227
|
applicationId: applicationId,
|
|
2142
|
-
dcApiSupported:
|
|
2228
|
+
dcApiSupported: dcApiSupport.supported,
|
|
2229
|
+
dcApiProtocols: dcApiSupport.protocols,
|
|
2143
2230
|
state: state
|
|
2144
2231
|
});
|
|
2145
2232
|
if (createSessionResult.isErr()) {
|