@mattrglobal/verifier-sdk-web 2.0.3-unstable.9 → 2.1.0

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.
@@ -6,7 +6,7 @@ export declare enum LocalStorageKey {
6
6
  sessionId = "mattr_sid"
7
7
  }
8
8
  export declare const MATTR_SDK_VERSION_HEADER = "x-mattr-sdk-version";
9
- export declare const MATTR_SDK_VERSION_VALUE = "2.0.2";
9
+ export declare const MATTR_SDK_VERSION_VALUE = "2.1.0";
10
10
  export declare enum MessageEventDataType {
11
11
  PresentationCompleted = "PresentationCompleted",// { type: "PresentationCompleted", responseCode, sessionId }
12
12
  PresentationTimeout = "PresentationTimeout",// { type: "PresentationTimeout", sessionId }
@@ -7,8 +7,8 @@
7
7
  * Do Not Translate or Localize
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
- * Generated: 2025-07-09
11
- * Version: 2.0.2
10
+ * Generated: 2025-09-16
11
+ * Version: 2.1.0
12
12
  * Dependencies:
13
13
  *
14
14
  * neverthrow -- 4.3.0
@@ -1487,7 +1487,7 @@
1487
1487
  LocalStorageKey["sessionId"] = "mattr_sid";
1488
1488
  })(LocalStorageKey || (LocalStorageKey = {}));
1489
1489
  const MATTR_SDK_VERSION_HEADER = "x-mattr-sdk-version";
1490
- const MATTR_SDK_VERSION_VALUE = "2.0.2";
1490
+ const MATTR_SDK_VERSION_VALUE = "2.1.0";
1491
1491
  var MessageEventDataType;
1492
1492
  (function(MessageEventDataType) {
1493
1493
  MessageEventDataType["PresentationCompleted"] = "PresentationCompleted";
@@ -1713,15 +1713,18 @@
1713
1713
  return urlParams.get(param);
1714
1714
  };
1715
1715
  const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, applicationId: applicationId}) => {
1716
+ const openid4vpConfiguration = !!walletProviderId || !!redirectUri ? {
1717
+ redirectUri: redirectUri,
1718
+ walletProviderId: walletProviderId
1719
+ } : undefined;
1716
1720
  const postData = {
1717
1721
  credentialQuery: credentialQuery,
1718
1722
  challenge: challenge,
1719
1723
  applicationId: applicationId,
1720
- redirectUri: redirectUri,
1721
- walletProviderId: walletProviderId,
1722
- dcApiSupported: dcApiSupported
1724
+ dcApiSupported: dcApiSupported,
1725
+ openid4vpConfiguration: openid4vpConfiguration
1723
1726
  };
1724
- const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions`, {
1727
+ const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions`, {
1725
1728
  method: "POST",
1726
1729
  headers: {
1727
1730
  "Content-Type": "application/json"
@@ -1741,7 +1744,7 @@
1741
1744
  return ok(data);
1742
1745
  };
1743
1746
  const abortSession = async ({apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey}) => {
1744
- const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/abort`, {
1747
+ const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions/${sessionId}/abort`, {
1745
1748
  method: "POST",
1746
1749
  headers: {
1747
1750
  "Content-Type": "application/json",
@@ -1977,8 +1980,7 @@
1977
1980
  sessionId: sessionId,
1978
1981
  sessionKey: sessionKey,
1979
1982
  challenge: challenge,
1980
- protocol: parsedCredentialResponse.protocol,
1981
- data: parsedCredentialResponse.data
1983
+ response: parsedCredentialResponse
1982
1984
  });
1983
1985
  if (credentialVerificationResult.isErr()) {
1984
1986
  return err({
@@ -2017,8 +2019,19 @@
2017
2019
  }
2018
2020
  });
2019
2021
  }
2022
+ if (typeof credentialResponse === "object" && "toJSON" in credentialResponse && typeof credentialResponse.toJSON === "function") {
2023
+ return ok(credentialResponse.toJSON());
2024
+ }
2020
2025
  if (typeof credentialResponse === "object") {
2021
- return ok(credentialResponse);
2026
+ const entries = [];
2027
+ for (const key in credentialResponse) {
2028
+ const value = credentialResponse[key];
2029
+ if (typeof value === "function" || value === undefined || value === null) {
2030
+ continue;
2031
+ }
2032
+ entries.push([ key, value ]);
2033
+ }
2034
+ return ok(Object.fromEntries(entries));
2022
2035
  }
2023
2036
  if (typeof credentialResponse === "string") {
2024
2037
  try {
@@ -2043,13 +2056,11 @@
2043
2056
  });
2044
2057
  };
2045
2058
  const verifyCredentialResponse = async options => {
2046
- const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, protocol: protocol, data: data} = options;
2047
- const requestBody = {
2048
- protocol: protocol,
2049
- data: data,
2059
+ const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, response: response} = options;
2060
+ const requestBody = Object.assign(Object.assign({}, response), {
2050
2061
  challenge: challenge
2051
- };
2052
- const credentialVerificationResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/dc-api/response`, {
2062
+ });
2063
+ const credentialVerificationResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions/${sessionId}/dc-api/response`, {
2053
2064
  method: "POST",
2054
2065
  headers: {
2055
2066
  "Content-Type": "application/json",