@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
package/dist/typings/index.d.ts
CHANGED
|
@@ -7,6 +7,5 @@ export type { InitialiseOptions, RequestCredentialsOptions, RequestCredentialsSa
|
|
|
7
7
|
declare const utils: {
|
|
8
8
|
generateChallenge: () => string;
|
|
9
9
|
unwrap: <T = unknown>(result: import("neverthrow").Result<T, unknown>, errMessage?: string) => T;
|
|
10
|
-
isDigitalCredentialsApiSupported: () => boolean;
|
|
11
10
|
};
|
|
12
11
|
export { initialise, requestCredentials, handleRedirectCallback, utils };
|
|
@@ -49,12 +49,6 @@ export declare const exchangeSessionResult: ({ challenge, responseCode, sessionI
|
|
|
49
49
|
* @returns A boolean indicating whether the user agent is a mobile device.
|
|
50
50
|
*/
|
|
51
51
|
export declare const isMobileDetect: (userAgent: string) => boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Detects if digital credentials api is available.
|
|
54
|
-
*
|
|
55
|
-
* @returns A boolean indicating whether the user agent supports the digital credential api.
|
|
56
|
-
*/
|
|
57
|
-
export declare const isDigitalCredentialsApiSupported: () => boolean;
|
|
58
52
|
/**
|
|
59
53
|
* Creates a new digital credentials api session with the provided parameters.
|
|
60
54
|
*
|
|
@@ -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
|
* neverthrow -- 4.3.0
|
|
@@ -1522,14 +1522,6 @@
|
|
|
1522
1522
|
ua: userAgent,
|
|
1523
1523
|
tablet: false
|
|
1524
1524
|
});
|
|
1525
|
-
const isDigitalCredentialsApiSupported = () => {
|
|
1526
|
-
var _a;
|
|
1527
|
-
try {
|
|
1528
|
-
return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.identity) === null || _a === void 0 ? void 0 : _a.get) === "function";
|
|
1529
|
-
} catch (error) {
|
|
1530
|
-
return false;
|
|
1531
|
-
}
|
|
1532
|
-
};
|
|
1533
1525
|
const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQuery, challenge: challenge, apiBaseUrl: apiBaseUrl, protocol: protocol}) => {
|
|
1534
1526
|
const postData = Object.assign({
|
|
1535
1527
|
credentialQuery: credentialQuery,
|
|
@@ -1780,21 +1772,41 @@
|
|
|
1780
1772
|
}
|
|
1781
1773
|
const {request: request, sessionId: sessionId} = createSessionResult.value;
|
|
1782
1774
|
window.localStorage.setItem(LocalStorageKey.sessionId, sessionId);
|
|
1783
|
-
let
|
|
1775
|
+
let response;
|
|
1784
1776
|
try {
|
|
1785
|
-
|
|
1777
|
+
if ("providers" in request.digital) {
|
|
1778
|
+
let requestData;
|
|
1779
|
+
const providerRequest = request.digital.providers[0];
|
|
1780
|
+
if (providerRequest.protocol === "preview") {
|
|
1781
|
+
console.log(`DC API Preview Request: ${JSON.stringify(request)}`);
|
|
1782
|
+
const rawResponse = await navigator.identity.get(request);
|
|
1783
|
+
response = rawResponse.data;
|
|
1784
|
+
} else {
|
|
1785
|
+
requestData = {
|
|
1786
|
+
protocol: providerRequest.protocol,
|
|
1787
|
+
data: JSON.parse(providerRequest.request)
|
|
1788
|
+
};
|
|
1789
|
+
const modernRequest = Object.assign(Object.assign({}, requestData.protocol === "org-iso-mdoc" && {
|
|
1790
|
+
mediation: "required"
|
|
1791
|
+
}), {
|
|
1792
|
+
digital: {
|
|
1793
|
+
requests: [ requestData ]
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1796
|
+
console.log(`DC API Request: ${JSON.stringify(modernRequest)}`);
|
|
1797
|
+
const rawResponse = await navigator.credentials.get(modernRequest);
|
|
1798
|
+
response = rawResponse.data;
|
|
1799
|
+
}
|
|
1800
|
+
} else {
|
|
1801
|
+
const rawResponse = await navigator.credentials.get(request);
|
|
1802
|
+
response = rawResponse.data;
|
|
1803
|
+
}
|
|
1786
1804
|
} catch (_a) {
|
|
1787
1805
|
return err({
|
|
1788
1806
|
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1789
1807
|
message: "Failed call to digital credentials api"
|
|
1790
1808
|
});
|
|
1791
1809
|
}
|
|
1792
|
-
let response;
|
|
1793
|
-
try {
|
|
1794
|
-
response = JSON.parse(rawResponse.data);
|
|
1795
|
-
} catch (_b) {
|
|
1796
|
-
response = rawResponse.data;
|
|
1797
|
-
}
|
|
1798
1810
|
const result = await getDigitalCredentialsApiSessionResult({
|
|
1799
1811
|
challenge: challenge,
|
|
1800
1812
|
sessionId: sessionId,
|
|
@@ -1822,7 +1834,7 @@
|
|
|
1822
1834
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
1823
1835
|
const {challenge: challenge = generateChallenge()} = options;
|
|
1824
1836
|
const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : isMobileDetect(navigator.userAgent) ? exports.Mode.sameDevice : exports.Mode.crossDevice;
|
|
1825
|
-
if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow &&
|
|
1837
|
+
if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow && mode === exports.Mode.crossDevice) {
|
|
1826
1838
|
console.log("Digital Credentials API support found, proceeding with request using API in cross device flow");
|
|
1827
1839
|
return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
|
|
1828
1840
|
initialiseOptions: initialiseOptions,
|
|
@@ -1831,7 +1843,7 @@
|
|
|
1831
1843
|
} else if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow) {
|
|
1832
1844
|
console.log("Digital Credentials API support not found, falling back to OpenID4VP");
|
|
1833
1845
|
}
|
|
1834
|
-
if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow &&
|
|
1846
|
+
if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow && mode === exports.Mode.sameDevice) {
|
|
1835
1847
|
console.log("Digital Credentials API support found, proceeding with request using API in same device flow");
|
|
1836
1848
|
return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
|
|
1837
1849
|
initialiseOptions: initialiseOptions,
|
|
@@ -1916,8 +1928,7 @@
|
|
|
1916
1928
|
};
|
|
1917
1929
|
const utils = {
|
|
1918
1930
|
generateChallenge: generateChallenge,
|
|
1919
|
-
unwrap: unwrap
|
|
1920
|
-
isDigitalCredentialsApiSupported: isDigitalCredentialsApiSupported
|
|
1931
|
+
unwrap: unwrap
|
|
1921
1932
|
};
|
|
1922
1933
|
exports.handleRedirectCallback = handleRedirectCallback;
|
|
1923
1934
|
exports.initialise = initialise;
|