@mattrglobal/verifier-sdk-web 2.3.1-unstable.3 → 2.3.1-unstable.32
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 +1 -1
- 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 +77 -10
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/verifier/requestCredentialsDigitalCredentialsApi.d.ts +12 -1
- 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 +73 -10
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +2 -2
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +2 -2
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +3 -3
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2026-
|
|
10
|
+
* Generated: 2026-10-12
|
|
11
11
|
* Version: 2.3.0
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*
|
|
@@ -1441,12 +1441,19 @@ var SessionType;
|
|
|
1441
1441
|
SessionType["Openid4vp"] = "openid4vp";
|
|
1442
1442
|
})(SessionType || (SessionType = {}));
|
|
1443
1443
|
|
|
1444
|
+
const VerifierConfigurationValidator = object({
|
|
1445
|
+
dcApi: object({
|
|
1446
|
+
protocols: array(string())
|
|
1447
|
+
})
|
|
1448
|
+
});
|
|
1449
|
+
|
|
1444
1450
|
object({
|
|
1445
1451
|
credentialQuery: array(CredentialQueryValidator),
|
|
1446
1452
|
challenge: string(),
|
|
1447
1453
|
redirectUri: optional(string()),
|
|
1448
1454
|
walletProviderId: optional(string()),
|
|
1449
1455
|
dcApiSupported: optional(_boolean()),
|
|
1456
|
+
dcApiProtocols: optional(array(string())),
|
|
1450
1457
|
state: optional(pipe(string(), minLength(1)))
|
|
1451
1458
|
});
|
|
1452
1459
|
|
|
@@ -1764,18 +1771,41 @@ const getHashParamValue = (hash, param) => {
|
|
|
1764
1771
|
return urlParams.get(param);
|
|
1765
1772
|
};
|
|
1766
1773
|
|
|
1767
|
-
const
|
|
1774
|
+
const getVerifierConfiguration = async uri => {
|
|
1775
|
+
const responseResult = await safeFetch(`${uri}/v2/presentations/web/configuration`, {
|
|
1776
|
+
method: "GET",
|
|
1777
|
+
headers: {
|
|
1778
|
+
"Content-Type": "application/json"
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
if (responseResult.isErr()) {
|
|
1782
|
+
return err(responseResult.error);
|
|
1783
|
+
}
|
|
1784
|
+
const body = await responseResult.value.json().catch((() => undefined));
|
|
1785
|
+
if (!isType(VerifierConfigurationValidator)(body)) {
|
|
1786
|
+
return err({
|
|
1787
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1788
|
+
message: "Verifier configuration returned unsupported response"
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
return ok(body);
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, dcApiProtocols: dcApiProtocols, applicationId: applicationId, state: state}) => {
|
|
1768
1795
|
const openid4vpConfiguration = !!walletProviderId || !!redirectUri ? {
|
|
1769
1796
|
redirectUri: redirectUri,
|
|
1770
1797
|
walletProviderId: walletProviderId
|
|
1771
1798
|
} : undefined;
|
|
1772
|
-
const postData = Object.assign({
|
|
1799
|
+
const postData = Object.assign(Object.assign(Object.assign({
|
|
1773
1800
|
credentialQuery: credentialQuery,
|
|
1774
1801
|
challenge: challenge,
|
|
1775
1802
|
applicationId: applicationId,
|
|
1776
|
-
dcApiSupported: dcApiSupported
|
|
1803
|
+
dcApiSupported: dcApiSupported
|
|
1804
|
+
}, dcApiProtocols !== undefined ? {
|
|
1805
|
+
dcApiProtocols: dcApiProtocols
|
|
1806
|
+
} : {}), {
|
|
1777
1807
|
openid4vpConfiguration: openid4vpConfiguration
|
|
1778
|
-
}, state !== undefined ? {
|
|
1808
|
+
}), state !== undefined ? {
|
|
1779
1809
|
state: state
|
|
1780
1810
|
} : {});
|
|
1781
1811
|
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions`, {
|
|
@@ -2220,9 +2250,45 @@ const verifyCredentialResponse = async options => {
|
|
|
2220
2250
|
return ok(credentialVerificationResponse);
|
|
2221
2251
|
};
|
|
2222
2252
|
|
|
2223
|
-
const
|
|
2224
|
-
var _a;
|
|
2225
|
-
return "DigitalCredential" in
|
|
2253
|
+
const digitalCredentialsApiSupported = target => {
|
|
2254
|
+
var _a, _b;
|
|
2255
|
+
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");
|
|
2256
|
+
};
|
|
2257
|
+
|
|
2258
|
+
const isDigitalCredentialsApiSupported = () => digitalCredentialsApiSupported(window);
|
|
2259
|
+
|
|
2260
|
+
const getDigitalCredentialsApiSupport = async apiBaseUrl => {
|
|
2261
|
+
if (!digitalCredentialsApiSupported(window)) {
|
|
2262
|
+
return {
|
|
2263
|
+
supported: false
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
const {DigitalCredential: digitalCredential} = window;
|
|
2267
|
+
if (!digitalCredential.userAgentAllowsProtocol) {
|
|
2268
|
+
return {
|
|
2269
|
+
supported: true
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
const configurationResult = await getVerifierConfiguration(apiBaseUrl);
|
|
2273
|
+
if (configurationResult.isErr()) {
|
|
2274
|
+
return {
|
|
2275
|
+
supported: true
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
const protocols = configurationResult.value.dcApi.protocols.filter((protocol => {
|
|
2279
|
+
var _a;
|
|
2280
|
+
try {
|
|
2281
|
+
return ((_a = digitalCredential.userAgentAllowsProtocol) === null || _a === void 0 ? void 0 : _a.call(digitalCredential, protocol)) === true;
|
|
2282
|
+
} catch (_b) {
|
|
2283
|
+
return false;
|
|
2284
|
+
}
|
|
2285
|
+
}));
|
|
2286
|
+
return protocols.length > 0 ? {
|
|
2287
|
+
supported: true,
|
|
2288
|
+
protocols: protocols
|
|
2289
|
+
} : {
|
|
2290
|
+
supported: false
|
|
2291
|
+
};
|
|
2226
2292
|
};
|
|
2227
2293
|
|
|
2228
2294
|
const sleep = ms => new Promise((resolve => setTimeout(resolve, ms)));
|
|
@@ -2304,7 +2370,7 @@ const requestCredentials = async options => {
|
|
|
2304
2370
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
2305
2371
|
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initializeOptions;
|
|
2306
2372
|
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration, state: state, onPresentationRequest: onPresentationRequest} = options;
|
|
2307
|
-
const
|
|
2373
|
+
const dcApiSupport = await getDigitalCredentialsApiSupport(apiBaseUrl);
|
|
2308
2374
|
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
2309
2375
|
const createSessionResult = await createSession({
|
|
2310
2376
|
credentialQuery: credentialQuery,
|
|
@@ -2313,7 +2379,8 @@ const requestCredentials = async options => {
|
|
|
2313
2379
|
walletProviderId: (_a = openid4vpConfiguration === null || openid4vpConfiguration === void 0 ? void 0 : openid4vpConfiguration.walletProviderId) !== null && _a !== void 0 ? _a : undefined,
|
|
2314
2380
|
apiBaseUrl: apiBaseUrl,
|
|
2315
2381
|
applicationId: applicationId,
|
|
2316
|
-
dcApiSupported:
|
|
2382
|
+
dcApiSupported: dcApiSupport.supported,
|
|
2383
|
+
dcApiProtocols: dcApiSupport.protocols,
|
|
2317
2384
|
state: state
|
|
2318
2385
|
});
|
|
2319
2386
|
if (createSessionResult.isErr()) {
|