@dynamic-labs-sdk/client 1.7.0 → 1.8.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.
Files changed (118) hide show
  1. package/android/build.gradle +231 -0
  2. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  3. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  4. package/android/gradle.properties +8 -0
  5. package/android/gradlew +251 -0
  6. package/android/gradlew.bat +94 -0
  7. package/android/settings.gradle +30 -0
  8. package/android/src/main/java/xyz/dynamic/client/DynamicClientPackage.kt +52 -0
  9. package/android/src/main/java/xyz/dynamic/client/keychain/KeyStoreKeyManager.kt +147 -0
  10. package/android/src/main/java/xyz/dynamic/client/keychain/KeychainModule.kt +85 -0
  11. package/android/src/main/java/xyz/dynamic/client/manifest/ReactNativeManifestModule.kt +25 -0
  12. package/android/src/main/java/xyz/dynamic/client/webview/DynamicWebViewClient.kt +83 -0
  13. package/android/src/main/java/xyz/dynamic/client/webview/DynamicWebViewHost.kt +518 -0
  14. package/android/src/main/java/xyz/dynamic/client/webview/DynamicWebViewModule.kt +147 -0
  15. package/android/src/test/java/xyz/dynamic/client/keychain/KeyStoreKeyManagerTest.kt +288 -0
  16. package/android/src/test/java/xyz/dynamic/client/webview/DynamicWebViewClientTest.kt +196 -0
  17. package/android/src/test/java/xyz/dynamic/client/webview/DynamicWebViewHostOpenTest.kt +347 -0
  18. package/android/src/test/java/xyz/dynamic/client/webview/DynamicWebViewHostTest.kt +171 -0
  19. package/android/src/test/java/xyz/dynamic/client/webview/DynamicWebViewModuleTest.kt +191 -0
  20. package/dist/{InvalidParamError-Crwntjl7.native.esm.js → InvalidParamError-Bc6OZBog.native.esm.js} +3 -3
  21. package/dist/{InvalidParamError-Crwntjl7.native.esm.js.map → InvalidParamError-Bc6OZBog.native.esm.js.map} +1 -1
  22. package/dist/{InvalidParamError-fQLJaGBW.esm.js → InvalidParamError-IHYLdzFd.esm.js} +437 -5
  23. package/dist/InvalidParamError-IHYLdzFd.esm.js.map +1 -0
  24. package/dist/{InvalidParamError-CTssOe86.cjs → InvalidParamError-S56rFFDP.cjs} +550 -4
  25. package/dist/InvalidParamError-S56rFFDP.cjs.map +1 -0
  26. package/dist/{NotWaasWalletAccountError-BJLGGYmU.native.esm.js → NotWaasWalletAccountError-BP-bODbJ.native.esm.js} +3 -3
  27. package/dist/{NotWaasWalletAccountError-BJLGGYmU.native.esm.js.map → NotWaasWalletAccountError-BP-bODbJ.native.esm.js.map} +1 -1
  28. package/dist/{NotWaasWalletAccountError-DF_S7gqo.esm.js → NotWaasWalletAccountError-BYEL2l-W.esm.js} +3 -3
  29. package/dist/{NotWaasWalletAccountError-DF_S7gqo.esm.js.map → NotWaasWalletAccountError-BYEL2l-W.esm.js.map} +1 -1
  30. package/dist/{NotWaasWalletAccountError-2RaDipZu.cjs → NotWaasWalletAccountError-CbhIKUDM.cjs} +3 -3
  31. package/dist/{NotWaasWalletAccountError-2RaDipZu.cjs.map → NotWaasWalletAccountError-CbhIKUDM.cjs.map} +1 -1
  32. package/dist/core.cjs +23 -23
  33. package/dist/core.cjs.map +1 -1
  34. package/dist/core.esm.js +5 -5
  35. package/dist/core.native.esm.js +7 -7
  36. package/dist/core.native.esm.js.map +1 -1
  37. package/dist/errors/WebViewLoadFailedError.d.ts +1 -1
  38. package/dist/errors/WebViewLoadFailedError.d.ts.map +1 -1
  39. package/dist/exports/index.d.ts +2 -0
  40. package/dist/exports/index.d.ts.map +1 -1
  41. package/dist/{getNetworkProviderFromNetworkId-C1p9Rrg3.cjs → getNetworkProviderFromNetworkId-BDdcpGHH.cjs} +11 -317
  42. package/dist/getNetworkProviderFromNetworkId-BDdcpGHH.cjs.map +1 -0
  43. package/dist/{getNetworkProviderFromNetworkId-BWhaD23J.esm.js → getNetworkProviderFromNetworkId-D8rWYXlT.esm.js} +4 -242
  44. package/dist/getNetworkProviderFromNetworkId-D8rWYXlT.esm.js.map +1 -0
  45. package/dist/{getNetworkProviderFromNetworkId-BCSmILlH.native.esm.js → getNetworkProviderFromNetworkId-DVmF7pH2.native.esm.js} +6 -6
  46. package/dist/getNetworkProviderFromNetworkId-DVmF7pH2.native.esm.js.map +1 -0
  47. package/dist/{getSignedSessionId-CxxYNC_8.cjs → getSignedSessionId-BBaBCi9S.cjs} +3 -3
  48. package/dist/{getSignedSessionId-CxxYNC_8.cjs.map → getSignedSessionId-BBaBCi9S.cjs.map} +1 -1
  49. package/dist/{getSignedSessionId-c7dS4PQ9.esm.js → getSignedSessionId-CND07Eca.esm.js} +3 -3
  50. package/dist/{getSignedSessionId-c7dS4PQ9.esm.js.map → getSignedSessionId-CND07Eca.esm.js.map} +1 -1
  51. package/dist/{getSignedSessionId-DPOXdh6y.native.esm.js → getSignedSessionId-RwV7JPn8.native.esm.js} +3 -3
  52. package/dist/{getSignedSessionId-DPOXdh6y.native.esm.js.map → getSignedSessionId-RwV7JPn8.native.esm.js.map} +1 -1
  53. package/dist/{getVerifiedCredentialForWalletAccount-Cahp763h.esm.js → getVerifiedCredentialForWalletAccount-BVrGV8qf.native.esm.js} +2 -2
  54. package/dist/{getVerifiedCredentialForWalletAccount-DuNbORNW.native.esm.js.map → getVerifiedCredentialForWalletAccount-BVrGV8qf.native.esm.js.map} +1 -1
  55. package/dist/getVerifiedCredentialForWalletAccount-BiOS65Tk.esm.js +269 -0
  56. package/dist/getVerifiedCredentialForWalletAccount-BiOS65Tk.esm.js.map +1 -0
  57. package/dist/getVerifiedCredentialForWalletAccount-FrxYWSuD.cjs +347 -0
  58. package/dist/getVerifiedCredentialForWalletAccount-FrxYWSuD.cjs.map +1 -0
  59. package/dist/index.cjs +67 -67
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.esm.js +5 -5
  62. package/dist/index.esm.js.map +1 -1
  63. package/dist/index.native.esm.js +5 -5
  64. package/dist/index.native.esm.js.map +1 -1
  65. package/dist/isMfaRequiredForAction-BPL_dgIM.esm.js +318 -0
  66. package/dist/isMfaRequiredForAction-BPL_dgIM.esm.js.map +1 -0
  67. package/dist/isMfaRequiredForAction-BolTrtCO.cjs +405 -0
  68. package/dist/isMfaRequiredForAction-BolTrtCO.cjs.map +1 -0
  69. package/dist/{isMfaRequiredForAction-D8G5PBAd.native.esm.js → isMfaRequiredForAction-DQDoPsi6.native.esm.js} +2 -2
  70. package/dist/{isMfaRequiredForAction-D8G5PBAd.native.esm.js.map → isMfaRequiredForAction-DQDoPsi6.native.esm.js.map} +1 -1
  71. package/dist/modules/waas/createWaasClient/createWaasClient.d.ts.map +1 -1
  72. package/dist/modules/waas/createWaasClient/translateNativeOpenError.d.ts.map +1 -1
  73. package/dist/modules/wallets/walletProvider/events/onWalletProviderEvent/onWalletProviderEvent.d.ts +1 -2
  74. package/dist/modules/wallets/walletProvider/events/onWalletProviderEvent/onWalletProviderEvent.d.ts.map +1 -1
  75. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  76. package/dist/waas.cjs +9 -9
  77. package/dist/waas.cjs.map +1 -1
  78. package/dist/waas.esm.js +3 -3
  79. package/dist/waas.native.esm.js +3 -3
  80. package/dist/waasCore.cjs +8 -5
  81. package/dist/waasCore.cjs.map +1 -1
  82. package/dist/waasCore.esm.js +8 -4
  83. package/dist/waasCore.esm.js.map +1 -1
  84. package/dist/waasCore.native.esm.js +8 -7
  85. package/dist/waasCore.native.esm.js.map +1 -1
  86. package/dynamic-labs-sdk-client.podspec +27 -0
  87. package/ios/DynamicClientKeychain.h +4 -0
  88. package/ios/DynamicClientKeychain.mm +101 -0
  89. package/ios/DynamicClientManifest.h +4 -0
  90. package/ios/DynamicClientManifest.mm +45 -0
  91. package/ios/DynamicClientWebView.h +5 -0
  92. package/ios/DynamicClientWebView.mm +143 -0
  93. package/ios/DynamicWebViewImpl.swift +603 -0
  94. package/ios/LiveSecKeyAPI.swift +86 -0
  95. package/ios/ReactNativeManifestImpl.swift +20 -0
  96. package/ios/SecKeyAPI.swift +57 -0
  97. package/ios/SecureEnclaveKeyManager.swift +191 -0
  98. package/package.json +14 -5
  99. package/react-native.config.cjs +14 -0
  100. package/src/turboModules/NativeDynamicWebView.native.spec.ts +61 -0
  101. package/src/turboModules/NativeDynamicWebView.ts +40 -0
  102. package/src/turboModules/NativeKeychain.native.spec.ts +47 -0
  103. package/src/turboModules/NativeKeychain.ts +19 -0
  104. package/src/turboModules/NativeReactNativeManifest.native.spec.ts +55 -0
  105. package/src/turboModules/NativeReactNativeManifest.ts +28 -0
  106. package/dist/InvalidParamError-CTssOe86.cjs.map +0 -1
  107. package/dist/InvalidParamError-fQLJaGBW.esm.js.map +0 -1
  108. package/dist/getNetworkProviderFromNetworkId-BCSmILlH.native.esm.js.map +0 -1
  109. package/dist/getNetworkProviderFromNetworkId-BWhaD23J.esm.js.map +0 -1
  110. package/dist/getNetworkProviderFromNetworkId-C1p9Rrg3.cjs.map +0 -1
  111. package/dist/getVerifiedCredentialForWalletAccount-Cahp763h.esm.js.map +0 -1
  112. package/dist/getVerifiedCredentialForWalletAccount-Di8dM5Wx.cjs +0 -887
  113. package/dist/getVerifiedCredentialForWalletAccount-Di8dM5Wx.cjs.map +0 -1
  114. package/dist/getVerifiedCredentialForWalletAccount-DuNbORNW.native.esm.js +0 -701
  115. package/dist/isMfaRequiredForAction-BjRvPrU6.esm.js +0 -79
  116. package/dist/isMfaRequiredForAction-BjRvPrU6.esm.js.map +0 -1
  117. package/dist/isMfaRequiredForAction-hlhj0qAC.cjs +0 -96
  118. package/dist/isMfaRequiredForAction-hlhj0qAC.cjs.map +0 -1
@@ -1,11 +1,11 @@
1
- import { AuthStorageEnum, Configuration, SDKApi, isDeviceNonceSignatureRequiredForUrl } from "@dynamic-labs/sdk-api-core";
1
+ import { AuthStorageEnum, Configuration, JwtVerifiedCredentialFormatEnum, SDKApi, WalletProviderEnum, isDeviceNonceSignatureRequiredForUrl } from "@dynamic-labs/sdk-api-core";
2
2
 
3
3
  //#region package.json
4
4
  var name = "@dynamic-labs-sdk/client";
5
- var version = "1.7.0";
5
+ var version = "1.8.0";
6
6
  var dependencies = {
7
7
  "@dynamic-labs-sdk/assert-package-version": "workspace:*",
8
- "@dynamic-labs-wallet/browser-wallet-client": "1.0.7",
8
+ "@dynamic-labs-wallet/browser-wallet-client": "1.0.16",
9
9
  "@dynamic-labs-wallet/forward-mpc-client": "0.10.1",
10
10
  "@dynamic-labs/sdk-api-core": "catalog:",
11
11
  "@simplewebauthn/browser": "13.1.0",
@@ -1016,6 +1016,152 @@ const fetchAndStoreNonces = async (client) => {
1016
1016
  });
1017
1017
  };
1018
1018
 
1019
+ //#endregion
1020
+ //#region src/utils/setCookie/setCookie.ts
1021
+ /**
1022
+ * Sefelly sets the cookie in the browser.
1023
+ * @not-instrumented
1024
+ */
1025
+ const setCookie = (cookie) => {
1026
+ document.cookie = cookie;
1027
+ };
1028
+
1029
+ //#endregion
1030
+ //#region src/modules/clientEvents/clientEvents.ts
1031
+ /**
1032
+ * Adds an event listener for Dynamic client events.
1033
+ *
1034
+ * This function allows you to listen for various events emitted by the Dynamic client,
1035
+ * such as authentication state changes, wallet connections, and more.
1036
+ *
1037
+ * @param params.event - The event name to listen for.
1038
+ * @param params.listener - The callback function to execute when the event is fired.
1039
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1040
+ * @returns A function that can be called to remove the listener.
1041
+ * @not-instrumented
1042
+ */
1043
+ const onEvent = ({ event, listener }, client = getDefaultClient()) => {
1044
+ const { eventEmitter } = getCore(client);
1045
+ eventEmitter.on(event, listener);
1046
+ return () => {
1047
+ eventEmitter.off(event, listener);
1048
+ };
1049
+ };
1050
+ /**
1051
+ * Removes an event listener from Dynamic client events.
1052
+ *
1053
+ * This function unsubscribes a previously registered event listener
1054
+ * from the specified Dynamic client event.
1055
+ *
1056
+ * @param params.event - The event name to remove the listener from.
1057
+ * @param params.listener - The callback function to remove.
1058
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1059
+ * @not-instrumented
1060
+ */
1061
+ const offEvent = ({ event, listener }, client = getDefaultClient()) => {
1062
+ const { eventEmitter } = getCore(client);
1063
+ eventEmitter.off(event, listener);
1064
+ };
1065
+ /**
1066
+ * Adds a one-time event listener for Dynamic client events.
1067
+ *
1068
+ * This function listens for an event that will automatically remove itself
1069
+ * after being triggered once.
1070
+ *
1071
+ * @param params.event - The event name to listen for.
1072
+ * @param params.listener - The callback function to execute when the event is fired.
1073
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1074
+ * @returns A function that can be called to remove the listener before it fires.
1075
+ * @not-instrumented
1076
+ */
1077
+ const onceEvent = ({ event, listener }, client = getDefaultClient()) => {
1078
+ const { eventEmitter } = getCore(client);
1079
+ eventEmitter.once(event, listener);
1080
+ return () => {
1081
+ eventEmitter.off(event, listener);
1082
+ };
1083
+ };
1084
+ /**
1085
+ * Emits a Dynamic client event.
1086
+ *
1087
+ * This function triggers an event that will be received by all registered
1088
+ * listeners for the specified event type.
1089
+ *
1090
+ * @param params.event - The event name to emit.
1091
+ * @param params.args - The arguments to pass to event listeners.
1092
+ * @param client - The Dynamic client instance.
1093
+ * @not-instrumented
1094
+ */
1095
+ const emitEvent = ({ event, args }, client) => {
1096
+ const { eventEmitter } = getCore(client);
1097
+ eventEmitter.emit(event, args);
1098
+ };
1099
+
1100
+ //#endregion
1101
+ //#region src/errors/InvalidWalletProviderKeyError.ts
1102
+ var InvalidWalletProviderKeyError = class extends BaseError {
1103
+ constructor(value) {
1104
+ super({
1105
+ cause: null,
1106
+ code: "invalid_wallet_provider_key",
1107
+ docsUrl: null,
1108
+ name: "InvalidWalletProviderKeyError",
1109
+ shortMessage: `Invalid wallet provider key: ${value}. Key must be in the format of <normalizedWalletNameWithChain>:<walletProviderType>[:<suffix>]`
1110
+ });
1111
+ }
1112
+ };
1113
+
1114
+ //#endregion
1115
+ //#region src/modules/wallets/walletProvider/splitWalletProviderKey/splitWalletProviderKey.ts
1116
+ /** @not-instrumented */
1117
+ const splitWalletProviderKey = (walletProviderKey) => {
1118
+ const [normalizedWalletNameWithChain, walletProviderType, suffix, ...rest] = walletProviderKey.split(":");
1119
+ if (!normalizedWalletNameWithChain || !Object.values(WalletProviderEnum).includes(walletProviderType) || rest.length > 0) throw new InvalidWalletProviderKeyError(walletProviderKey);
1120
+ return {
1121
+ normalizedWalletNameWithChain,
1122
+ suffix,
1123
+ walletProviderType
1124
+ };
1125
+ };
1126
+
1127
+ //#endregion
1128
+ //#region src/modules/wallets/utils/normalizeAddress/normalizeAddress.ts
1129
+ /** @not-instrumented */
1130
+ const normalizeAddress = ({ address, chain }) => {
1131
+ let normalizedAddress = address;
1132
+ if (normalizedAddress?.startsWith("0x")) normalizedAddress = normalizedAddress.slice(2);
1133
+ normalizedAddress = ["EVM", "FLOW"].includes(chain) ? normalizedAddress?.toLowerCase() : normalizedAddress;
1134
+ return normalizedAddress;
1135
+ };
1136
+
1137
+ //#endregion
1138
+ //#region src/modules/wallets/utils/formatWalletAccountId/formatWalletAccountId.ts
1139
+ /** @not-instrumented */
1140
+ const formatWalletAccountId = ({ address, chain, walletProviderKey }) => {
1141
+ const { normalizedWalletNameWithChain } = splitWalletProviderKey(walletProviderKey);
1142
+ return `${normalizedWalletNameWithChain}:${normalizeAddress({
1143
+ address,
1144
+ chain
1145
+ })}`;
1146
+ };
1147
+
1148
+ //#endregion
1149
+ //#region src/modules/wallets/utils/convertUnverifiedWalletAccountToWalletAccount/convertUnverifiedWalletAccountToWalletAccount.ts
1150
+ /** @not-instrumented */
1151
+ const convertUnverifiedWalletAccountToWalletAccount = ({ unverifiedWalletAccount }) => ({
1152
+ address: unverifiedWalletAccount.address,
1153
+ addressesWithTypes: unverifiedWalletAccount.addressesWithTypes,
1154
+ chain: unverifiedWalletAccount.chain,
1155
+ id: formatWalletAccountId({
1156
+ address: unverifiedWalletAccount.address,
1157
+ chain: unverifiedWalletAccount.chain,
1158
+ walletProviderKey: unverifiedWalletAccount.walletProviderKey
1159
+ }),
1160
+ lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,
1161
+ verifiedCredentialId: null,
1162
+ walletProviderKey: unverifiedWalletAccount.walletProviderKey
1163
+ });
1164
+
1019
1165
  //#endregion
1020
1166
  //#region src/modules/wallets/constants.ts
1021
1167
  const CHAINS_INFO_MAP = {
@@ -1119,6 +1265,292 @@ const getChainFromVerifiedCredentialChain = (verifiedCredentialChain) => {
1119
1265
  return chain;
1120
1266
  };
1121
1267
 
1268
+ //#endregion
1269
+ //#region src/modules/wallets/utils/normalizeWalletNameWithChain/normalizeWalletNameWithChain.ts
1270
+ /**
1271
+ * Format the raw wallet name and chain to get the value we can use for
1272
+ * verified credentials' `walletName` field.
1273
+ * @not-instrumented
1274
+ */
1275
+ const normalizeWalletNameWithChain = ({ displayName, chain }) => {
1276
+ const sanitizedWalletName = displayName.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
1277
+ const chainLowered = chain.toLocaleLowerCase();
1278
+ if (sanitizedWalletName.endsWith(chainLowered)) return sanitizedWalletName;
1279
+ return `${sanitizedWalletName}${chainLowered}`;
1280
+ };
1281
+
1282
+ //#endregion
1283
+ //#region src/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.ts
1284
+ /**
1285
+ * Assembles the wallet provider key from the wallet name, chain, and wallet provider type.
1286
+ *
1287
+ * The suffix is optional and can be used to add a uniquely identifying string to the key, which
1288
+ * might be necessary for some wallet providers (like Wallet Connect).
1289
+ *
1290
+ * IMPORTANT: Do NOT add a suffix unless absolutely necessary, as it will cause the wallet account
1291
+ * to not be able to find its wallet provider when connecting to a new device (it won't be possible
1292
+ * to determine the full key just from the Verified Credential data).
1293
+ * @not-instrumented
1294
+ */
1295
+ const formatWalletProviderKey = ({ suffix, chain, displayName, walletProviderType }) => {
1296
+ return `${normalizeWalletNameWithChain({
1297
+ chain,
1298
+ displayName
1299
+ })}:${walletProviderType}${suffix ? `:${suffix}` : ""}`;
1300
+ };
1301
+
1302
+ //#endregion
1303
+ //#region src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/getWalletProviderKeyFromVerifiedCredential.ts
1304
+ /** @not-instrumented */
1305
+ const getWalletProviderKeyFromVerifiedCredential = ({ verifiedCredential }, client) => {
1306
+ const { walletProviderKeyMap } = getCore(client).state.get();
1307
+ const storedWalletProviderKey = walletProviderKeyMap[verifiedCredential.id];
1308
+ if (storedWalletProviderKey) return { walletProviderKey: storedWalletProviderKey };
1309
+ /**
1310
+ * We fallback to comprising the wallet provider key from walletName and walletProvider.
1311
+ *
1312
+ * Some wallet provider types (like Wallet Connect) also use a special suffix for their wallet provider
1313
+ * keys, so this won't be enough for them.
1314
+ * Therefore, for those specific wallet providers, the wallet account will remain without a wallet provider
1315
+ * and will require reconnection.
1316
+ * Read walletProvider.types.ts for more info.
1317
+ */
1318
+ assertDefined(verifiedCredential.walletName, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletName`);
1319
+ assertDefined(verifiedCredential.walletProvider, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletProvider`);
1320
+ assertDefined(verifiedCredential.chain, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing chain`);
1321
+ return { walletProviderKey: formatWalletProviderKey({
1322
+ chain: getChainFromVerifiedCredentialChain(verifiedCredential.chain),
1323
+ displayName: verifiedCredential.walletName,
1324
+ walletProviderType: verifiedCredential.walletProvider
1325
+ }) };
1326
+ };
1327
+
1328
+ //#endregion
1329
+ //#region src/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.ts
1330
+ /** @not-instrumented */
1331
+ const convertVerifiedCredentialToWalletAccount = ({ verifiedCredential }, client) => {
1332
+ assertDefined(verifiedCredential.address, "Missing address in verified credential");
1333
+ assertDefined(verifiedCredential.chain, "Missing chain in verified credential");
1334
+ const chain = getChainFromVerifiedCredentialChain(verifiedCredential.chain);
1335
+ const { walletProviderKey } = getWalletProviderKeyFromVerifiedCredential({ verifiedCredential }, client);
1336
+ const walletAccountId = formatWalletAccountId({
1337
+ address: verifiedCredential.address,
1338
+ chain,
1339
+ walletProviderKey
1340
+ });
1341
+ return {
1342
+ address: verifiedCredential.address,
1343
+ addressesWithTypes: verifiedCredential.walletAdditionalAddresses,
1344
+ chain,
1345
+ hardwareWalletVendor: verifiedCredential.walletProperties?.hardwareWallet,
1346
+ id: walletAccountId,
1347
+ lastSelectedAt: verifiedCredential.lastSelectedAt ?? null,
1348
+ verifiedCredentialId: verifiedCredential.id,
1349
+ walletProviderKey
1350
+ };
1351
+ };
1352
+
1353
+ //#endregion
1354
+ //#region src/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.ts
1355
+ /** @not-instrumented */
1356
+ const getWalletAccountsFromState = ({ unverifiedWalletAccounts, user }, client) => {
1357
+ const walletAccountsMap = /* @__PURE__ */ new Map();
1358
+ /**
1359
+ * Handle the unverified wallet accounts before the user verified credentials
1360
+ * so the later verified wallet accounts can override the unverified wallet accounts
1361
+ */
1362
+ unverifiedWalletAccounts.forEach((unverifiedWalletAccount) => {
1363
+ const walletAccount = convertUnverifiedWalletAccountToWalletAccount({ unverifiedWalletAccount });
1364
+ walletAccountsMap.set(walletAccount.id, walletAccount);
1365
+ });
1366
+ (user?.verifiedCredentials ?? []).filter((verified) => verified.format === JwtVerifiedCredentialFormatEnum.Blockchain).forEach((verifiedWalletAccount) => {
1367
+ const walletAccount = convertVerifiedCredentialToWalletAccount({ verifiedCredential: verifiedWalletAccount }, client);
1368
+ walletAccountsMap.set(walletAccount.id, walletAccount);
1369
+ });
1370
+ return Array.from(walletAccountsMap.values());
1371
+ };
1372
+
1373
+ //#endregion
1374
+ //#region src/modules/wallets/getWalletAccounts/getWalletAccounts.ts
1375
+ /**
1376
+ * Retrieves all wallet accounts associated with the current session.
1377
+ *
1378
+ * This function returns both verified and unverified wallet accounts,
1379
+ * combining data from user credentials and local unverified accounts.
1380
+ * You can differentiate between verified and unverified wallet accounts by
1381
+ * checking the `verifiedCredentialId` property.
1382
+ *
1383
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1384
+ * @returns An array of wallet accounts associated with the session.
1385
+ * @not-instrumented
1386
+ */
1387
+ const getWalletAccounts = (client = getDefaultClient()) => {
1388
+ const { unverifiedWalletAccounts, user } = getCore(client).state.get();
1389
+ return getWalletAccountsFromState({
1390
+ unverifiedWalletAccounts,
1391
+ user
1392
+ }, client);
1393
+ };
1394
+
1395
+ //#endregion
1396
+ //#region src/errors/NoWalletProviderFoundError.ts
1397
+ var NoWalletProviderFoundError = class extends BaseError {
1398
+ constructor({ walletProviderKey }) {
1399
+ super({
1400
+ cause: null,
1401
+ code: "no_wallet_provider_found_error",
1402
+ docsUrl: null,
1403
+ name: "NoWalletProviderFoundError",
1404
+ shortMessage: `No wallet provider found with key: ${walletProviderKey}`
1405
+ });
1406
+ }
1407
+ };
1408
+
1409
+ //#endregion
1410
+ //#region src/services/runtimeServices/createRuntimeServiceAccessKey/createRuntimeServiceAccessKey.ts
1411
+ /**
1412
+ * Creates a service accessor function that manages service instantiation and caching.
1413
+ * The returned function will either retrieve an existing service from the registry or
1414
+ * create a new one using the provided builder function.
1415
+ *
1416
+ * @template - The type of service to be created/accessed
1417
+ * @param key - Unique identifier for the service in the registry
1418
+ * @param builder - Function that creates the service instance when called with a DynamicClient
1419
+ * @not-instrumented
1420
+ */
1421
+ const createRuntimeServiceAccessKey = (key, builder) => (client) => {
1422
+ const { runtimeServices } = getCore(client);
1423
+ const currentService = runtimeServices.getByKey(key);
1424
+ if (currentService) return currentService;
1425
+ const service = builder(client);
1426
+ runtimeServices.register(key, service);
1427
+ return service;
1428
+ };
1429
+
1430
+ //#endregion
1431
+ //#region src/modules/wallets/walletProviderRegistry/createWalletProviderRegistry/createWalletProviderRegistry.ts
1432
+ /**
1433
+ * Creates a new wallet provider registry that manages wallet providers with priority-based registration.
1434
+ *
1435
+ * @returns The wallet provider registry instance
1436
+ *
1437
+ * @example
1438
+ * ```typescript
1439
+ * const registry = createWalletProviderRegistry();
1440
+ *
1441
+ * registry.register({
1442
+ * priority: WalletProviderPriority.WALLET_SDK,
1443
+ * walletProvider: myWalletProvider
1444
+ * });
1445
+ *
1446
+ * const provider = registry.getByKey('my-wallet-key');
1447
+ * const providers = registry.listProviders();
1448
+ * ```
1449
+ * @not-instrumented
1450
+ */
1451
+ const createWalletProviderRegistry = (client) => {
1452
+ const registry = /* @__PURE__ */ new Map();
1453
+ return {
1454
+ getByKey: (key) => registry.get(key)?.walletProvider,
1455
+ listProviderEntries: () => Array.from(registry.values()),
1456
+ listProviders: () => Array.from(registry.values()).map((v) => v.walletProvider),
1457
+ register: (args) => {
1458
+ const existingEntry = registry.get(args.walletProvider.key);
1459
+ if (existingEntry) {
1460
+ if (existingEntry.priority < args.priority) {
1461
+ registry.set(args.walletProvider.key, args);
1462
+ emitEvent({
1463
+ args: { walletProviderKey: args.walletProvider.key },
1464
+ event: "walletProviderChanged"
1465
+ }, client);
1466
+ }
1467
+ } else {
1468
+ registry.set(args.walletProvider.key, args);
1469
+ emitEvent({
1470
+ args: { walletProvider: args.walletProvider },
1471
+ event: "walletProviderRegistered"
1472
+ }, client);
1473
+ emitEvent({
1474
+ args: { walletProviderKey: args.walletProvider.key },
1475
+ event: "walletProviderChanged"
1476
+ }, client);
1477
+ }
1478
+ },
1479
+ unregister: (key) => {
1480
+ registry.delete(key);
1481
+ emitEvent({
1482
+ args: { walletProviderKey: key },
1483
+ event: "walletProviderUnregistered"
1484
+ }, client);
1485
+ }
1486
+ };
1487
+ };
1488
+
1489
+ //#endregion
1490
+ //#region src/modules/wallets/walletProviderRegistry/getWalletProviderRegistry/getWalletProviderRegistry.ts
1491
+ /**
1492
+ * This function provides access to a shared instance of the wallet provider registry.
1493
+ *
1494
+ * It ensures that the same registry instance is used throughout the client to maintaining
1495
+ * consistency of registered wallet providers across different parts of the codebase.
1496
+ *
1497
+ * @returns The wallet provider registry instance
1498
+ *
1499
+ * @example
1500
+ * ```typescript
1501
+ * // Get the registry instance
1502
+ * const registry = getWalletProviderRegistry();
1503
+ *
1504
+ * // Register a wallet provider
1505
+ * registry.register({
1506
+ * priority: WalletProviderPriority.WALLET_SDK,
1507
+ * walletProvider: myWalletProvider
1508
+ * });
1509
+ *
1510
+ * // Retrieve a specific provider
1511
+ * const provider = registry.getByKey('metamaskevm');
1512
+ * ```
1513
+ */
1514
+ const getWalletProviderRegistry = createRuntimeServiceAccessKey("walletProviderRegistry", (client) => createWalletProviderRegistry(client));
1515
+
1516
+ //#endregion
1517
+ //#region src/modules/wallets/walletProviderRegistry/walletProviderRegistry.types.ts
1518
+ let WalletProviderPriority = /* @__PURE__ */ function(WalletProviderPriority$1) {
1519
+ /**
1520
+ * Highest priority should be used by wallet providers that implement
1521
+ * the most reliable wallet integration.
1522
+ * example: The SDK provided by the wallet provider.
1523
+ */
1524
+ WalletProviderPriority$1[WalletProviderPriority$1["WALLET_SDK"] = 100] = "WALLET_SDK";
1525
+ /**
1526
+ * Medium priority should be used by wallet providers that implement
1527
+ * a wallet integration via some reliable standard.
1528
+ * example: A wallet provider that uses EIP6963 announcement.
1529
+ */
1530
+ WalletProviderPriority$1[WalletProviderPriority$1["WALLET_SELF_ANNOUNCEMENT_STANDARD"] = 50] = "WALLET_SELF_ANNOUNCEMENT_STANDARD";
1531
+ /**
1532
+ * Low priority should be used by wallet providers that implement
1533
+ * a wallet integration on a less reliable standard.
1534
+ * example: A wallet provider that uses window.ethereum, where the
1535
+ * window key can be overridden by other extensions.
1536
+ */
1537
+ WalletProviderPriority$1[WalletProviderPriority$1["WINDOW_INJECT"] = 20] = "WINDOW_INJECT";
1538
+ return WalletProviderPriority$1;
1539
+ }({});
1540
+
1541
+ //#endregion
1542
+ //#region src/modules/wallets/utils/getWalletProviderFromWalletAccount/getWalletProviderFromWalletAccount.ts
1543
+ /** @not-instrumented */
1544
+ const getWalletProviderFromWalletAccount = ({ walletAccount }, client) => {
1545
+ const walletProvider = getWalletProviderRegistry(client).getByKey(walletAccount.walletProviderKey);
1546
+ if (!walletProvider) throw new NoWalletProviderFoundError({ walletProviderKey: walletAccount.walletProviderKey });
1547
+ return walletProvider;
1548
+ };
1549
+
1550
+ //#endregion
1551
+ //#region src/modules/auth/consts.ts
1552
+ const DYNAMIC_AUTH_COOKIE_NAME = "DYNAMIC_JWT_TOKEN";
1553
+
1122
1554
  //#endregion
1123
1555
  //#region src/constants.ts
1124
1556
  const SDK_API_CORE_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
@@ -1149,5 +1581,5 @@ var InvalidParamError = class extends BaseError {
1149
1581
  };
1150
1582
 
1151
1583
  //#endregion
1152
- export { getUserAgent as A, getCore as B, isCookieEnabled as C, instrumentFunction as D, __getElevatedAccessToken_wrapped as E, NONCE_POOL_SIZE as F, version as H, getDefaultClient as I, setDefaultClient as L, randomString as M, CLIENT_SDK_NAME as N, scrubParameters as O, DYNAMIC_SDK_API_VERSION as P, ClientNotFoundError as R, getSessionKeys as S, ValueMustBeDefinedError as T, name as V, MfaRateLimitedError as _, DYNAMIC_ICONIC_SPRITE_URL as a, InvalidExternalAuthError as b, CHAINS_INFO_MAP as c, UnauthorizedError as d, createDeviceSignatureHeadersMiddleware as f, SandboxMaximumThresholdReachedError as g, getNonce as h, DYNAMIC_WAAS_METADATA as i, extractSessionId as j, DEFAULT_PII_FIELDS as k, fetchAndStoreNonces as l, getDeviceSigner as m, DEFAULT_WAAS_BASE_API_URL as n, SDK_API_CORE_VERSION as o, getHeadersForNonceSignedByDeviceSigners as p, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as r, getChainFromVerifiedCredentialChain as s, InvalidParamError as t, createApiClient as u, MfaInvalidOtpError as v, assertDefined as w, APIError as x, LinkCredentialError as y, BaseError as z };
1153
- //# sourceMappingURL=InvalidParamError-fQLJaGBW.esm.js.map
1584
+ export { DYNAMIC_SDK_API_VERSION as $, UnauthorizedError as A, APIError as B, emitEvent as C, setCookie as D, onceEvent as E, SandboxMaximumThresholdReachedError as F, __getElevatedAccessToken_wrapped as G, isCookieEnabled as H, MfaRateLimitedError as I, DEFAULT_PII_FIELDS as J, instrumentFunction as K, MfaInvalidOtpError as L, getHeadersForNonceSignedByDeviceSigners as M, getDeviceSigner as N, fetchAndStoreNonces as O, getNonce as P, CLIENT_SDK_NAME as Q, LinkCredentialError as R, InvalidWalletProviderKeyError as S, onEvent as T, assertDefined as U, getSessionKeys as V, ValueMustBeDefinedError as W, extractSessionId as X, getUserAgent as Y, randomString as Z, getChainFromVerifiedCredentialChain as _, DYNAMIC_ICONIC_SPRITE_URL as a, getCore as at, normalizeAddress as b, getWalletProviderFromWalletAccount as c, createRuntimeServiceAccessKey as d, NONCE_POOL_SIZE as et, NoWalletProviderFoundError as f, normalizeWalletNameWithChain as g, formatWalletProviderKey as h, DYNAMIC_WAAS_METADATA as i, BaseError as it, createDeviceSignatureHeadersMiddleware as j, createApiClient as k, WalletProviderPriority as l, getWalletAccountsFromState as m, DEFAULT_WAAS_BASE_API_URL as n, setDefaultClient as nt, SDK_API_CORE_VERSION as o, name as ot, getWalletAccounts as p, scrubParameters as q, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as r, ClientNotFoundError as rt, DYNAMIC_AUTH_COOKIE_NAME as s, version as st, InvalidParamError as t, getDefaultClient as tt, getWalletProviderRegistry as u, CHAINS_INFO_MAP as v, offEvent as w, splitWalletProviderKey as x, formatWalletAccountId as y, InvalidExternalAuthError as z };
1585
+ //# sourceMappingURL=InvalidParamError-IHYLdzFd.esm.js.map