@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.
@@ -7,8 +7,8 @@
7
7
  * Do Not Translate or Localize
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
- * Generated: 2025-04-28
11
- * Version: 2.0.0-preview-digital-credential-api.5
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
@@ -1645,15 +1645,6 @@ const isMobileDetect = userAgent => isMobile_2({
1645
1645
  tablet: false
1646
1646
  });
1647
1647
 
1648
- const isDigitalCredentialsApiSupported = () => {
1649
- var _a;
1650
- try {
1651
- return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.identity) === null || _a === void 0 ? void 0 : _a.get) === "function";
1652
- } catch (error) {
1653
- return false;
1654
- }
1655
- };
1656
-
1657
1648
  const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQuery, challenge: challenge, apiBaseUrl: apiBaseUrl, protocol: protocol}) => {
1658
1649
  const postData = Object.assign({
1659
1650
  credentialQuery: credentialQuery,
@@ -1923,21 +1914,41 @@ const requestCredentialsDigitalCredentialsApi = async options => {
1923
1914
  }
1924
1915
  const {request: request, sessionId: sessionId} = createSessionResult.value;
1925
1916
  window.localStorage.setItem(LocalStorageKey.sessionId, sessionId);
1926
- let rawResponse;
1917
+ let response;
1927
1918
  try {
1928
- rawResponse = await navigator.identity.get(request);
1919
+ if ("providers" in request.digital) {
1920
+ let requestData;
1921
+ const providerRequest = request.digital.providers[0];
1922
+ if (providerRequest.protocol === "preview") {
1923
+ console.log(`DC API Preview Request: ${JSON.stringify(request)}`);
1924
+ const rawResponse = await navigator.identity.get(request);
1925
+ response = rawResponse.data;
1926
+ } else {
1927
+ requestData = {
1928
+ protocol: providerRequest.protocol,
1929
+ data: JSON.parse(providerRequest.request)
1930
+ };
1931
+ const modernRequest = Object.assign(Object.assign({}, requestData.protocol === "org-iso-mdoc" && {
1932
+ mediation: "required"
1933
+ }), {
1934
+ digital: {
1935
+ requests: [ requestData ]
1936
+ }
1937
+ });
1938
+ console.log(`DC API Request: ${JSON.stringify(modernRequest)}`);
1939
+ const rawResponse = await navigator.credentials.get(modernRequest);
1940
+ response = rawResponse.data;
1941
+ }
1942
+ } else {
1943
+ const rawResponse = await navigator.credentials.get(request);
1944
+ response = rawResponse.data;
1945
+ }
1929
1946
  } catch (_a) {
1930
1947
  return err({
1931
1948
  type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
1932
1949
  message: "Failed call to digital credentials api"
1933
1950
  });
1934
1951
  }
1935
- let response;
1936
- try {
1937
- response = JSON.parse(rawResponse.data);
1938
- } catch (_b) {
1939
- response = rawResponse.data;
1940
- }
1941
1952
  const result = await getDigitalCredentialsApiSessionResult({
1942
1953
  challenge: challenge,
1943
1954
  sessionId: sessionId,
@@ -1966,7 +1977,7 @@ const requestCredentials = async options => {
1966
1977
  assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
1967
1978
  const {challenge: challenge = generateChallenge()} = options;
1968
1979
  const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : isMobileDetect(navigator.userAgent) ? exports.Mode.sameDevice : exports.Mode.crossDevice;
1969
- if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow && isDigitalCredentialsApiSupported() && mode === exports.Mode.crossDevice) {
1980
+ if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow && mode === exports.Mode.crossDevice) {
1970
1981
  console.log("Digital Credentials API support found, proceeding with request using API in cross device flow");
1971
1982
  return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
1972
1983
  initialiseOptions: initialiseOptions,
@@ -1975,7 +1986,7 @@ const requestCredentials = async options => {
1975
1986
  } else if (initialiseOptions.enableDigitalCredentialsApiCrossDeviceFlow) {
1976
1987
  console.log("Digital Credentials API support not found, falling back to OpenID4VP");
1977
1988
  }
1978
- if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow && isDigitalCredentialsApiSupported() && mode === exports.Mode.sameDevice) {
1989
+ if (initialiseOptions.enableDigitalCredentialsApiSameDeviceFlow && mode === exports.Mode.sameDevice) {
1979
1990
  console.log("Digital Credentials API support found, proceeding with request using API in same device flow");
1980
1991
  return await requestCredentialsDigitalCredentialsApi(Object.assign(Object.assign({}, options), {
1981
1992
  initialiseOptions: initialiseOptions,
@@ -2066,8 +2077,7 @@ const handleRedirectCallback = async () => {
2066
2077
 
2067
2078
  const utils = {
2068
2079
  generateChallenge: generateChallenge,
2069
- unwrap: unwrap,
2070
- isDigitalCredentialsApiSupported: isDigitalCredentialsApiSupported
2080
+ unwrap: unwrap
2071
2081
  };
2072
2082
 
2073
2083
  exports.handleRedirectCallback = handleRedirectCallback;