@dynamic-labs-sdk/client 1.20.0 → 1.21.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 (165) hide show
  1. package/dist/{updateAuthFromVerifyResponse-DGrmo9MJ.native.esm.js → NativeModuleNotLinkedError-Ds_t3AZQ.native.esm.js} +33 -4
  2. package/dist/NativeModuleNotLinkedError-Ds_t3AZQ.native.esm.js.map +1 -0
  3. package/dist/client/createDynamicClient/assertClientProps/assertClientProps.d.ts +16 -0
  4. package/dist/client/createDynamicClient/assertClientProps/assertClientProps.d.ts.map +1 -0
  5. package/dist/client/createDynamicClient/assertClientProps/index.d.ts +2 -0
  6. package/dist/client/createDynamicClient/assertClientProps/index.d.ts.map +1 -0
  7. package/dist/client/createDynamicClient/createDynamicClient.d.ts.map +1 -1
  8. package/dist/client/types/DynamicClientConfig.d.ts +35 -0
  9. package/dist/client/types/DynamicClientConfig.d.ts.map +1 -1
  10. package/dist/consumeMfaTokenIfRequiredForAction-CWVbmQ2A.cjs +17 -0
  11. package/dist/consumeMfaTokenIfRequiredForAction-CWVbmQ2A.cjs.map +1 -0
  12. package/dist/consumeMfaTokenIfRequiredForAction-C_IvLTH6.esm.js +12 -0
  13. package/dist/consumeMfaTokenIfRequiredForAction-C_IvLTH6.esm.js.map +1 -0
  14. package/dist/core.cjs +9 -8
  15. package/dist/core.cjs.map +1 -1
  16. package/dist/core.esm.js +6 -5
  17. package/dist/core.esm.js.map +1 -1
  18. package/dist/core.native.esm.js +5 -5
  19. package/dist/errors/WaasLoadFailedError.d.ts +45 -0
  20. package/dist/errors/WaasLoadFailedError.d.ts.map +1 -0
  21. package/dist/exports/index.d.ts +1 -0
  22. package/dist/exports/index.d.ts.map +1 -1
  23. package/dist/exports/waas.d.ts +10 -0
  24. package/dist/exports/waas.d.ts.map +1 -1
  25. package/dist/{getNetworkProviderFromNetworkId-DaVOUpiF.cjs → getNetworkProviderFromNetworkId-5V4Cf8A_.cjs} +48 -13
  26. package/dist/getNetworkProviderFromNetworkId-5V4Cf8A_.cjs.map +1 -0
  27. package/dist/{getNetworkProviderFromNetworkId-BlBx4Zh2.esm.js → getNetworkProviderFromNetworkId-DhS1snCk.esm.js} +48 -13
  28. package/dist/getNetworkProviderFromNetworkId-DhS1snCk.esm.js.map +1 -0
  29. package/dist/{getNetworkProviderFromNetworkId-xmoBE1cZ.native.esm.js → getNetworkProviderFromNetworkId-DudGvTmd.native.esm.js} +2 -3
  30. package/dist/{getNetworkProviderFromNetworkId-xmoBE1cZ.native.esm.js.map → getNetworkProviderFromNetworkId-DudGvTmd.native.esm.js.map} +1 -1
  31. package/dist/{getSignedSessionId-3L_aMxVD.cjs → getSignedSessionId-E6FIx5aj.cjs} +2 -17
  32. package/dist/getSignedSessionId-E6FIx5aj.cjs.map +1 -0
  33. package/dist/{getSignedSessionId-DlmNVy-g.native.esm.js → getSignedSessionId-ekp3lswQ.esm.js} +3 -12
  34. package/dist/getSignedSessionId-ekp3lswQ.esm.js.map +1 -0
  35. package/dist/{getSignedSessionId-BVc-sgeN.esm.js → getSignedSessionId-xZGFa4nS.native.esm.js} +3 -3
  36. package/dist/{getSignedSessionId-DlmNVy-g.native.esm.js.map → getSignedSessionId-xZGFa4nS.native.esm.js.map} +1 -1
  37. package/dist/{getWalletProviderByKey-BilyW5Jr.cjs → getWalletProviderByKey-BwivhTYu.cjs} +2 -2
  38. package/dist/{getWalletProviderByKey-BilyW5Jr.cjs.map → getWalletProviderByKey-BwivhTYu.cjs.map} +1 -1
  39. package/dist/{getWalletProviderByKey-PIO1ygzj.esm.js → getWalletProviderByKey-CS299i1V.esm.js} +2 -2
  40. package/dist/{getWalletProviderByKey-PIO1ygzj.esm.js.map → getWalletProviderByKey-CS299i1V.esm.js.map} +1 -1
  41. package/dist/{getWalletProviderByKey-Ccx26JsF.native.esm.js → getWalletProviderByKey-CYGDw6-5.native.esm.js} +2 -2
  42. package/dist/{getWalletProviderByKey-Ccx26JsF.native.esm.js.map → getWalletProviderByKey-CYGDw6-5.native.esm.js.map} +1 -1
  43. package/dist/index.cjs +48 -20
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.esm.js +34 -7
  46. package/dist/index.esm.js.map +1 -1
  47. package/dist/index.native.esm.js +34 -7
  48. package/dist/index.native.esm.js.map +1 -1
  49. package/dist/{isDynamicWaasEnabled-DXVcXa66.cjs → isDynamicWaasEnabled-BEVAshnS.cjs} +2 -2
  50. package/dist/{isDynamicWaasEnabled-DXVcXa66.cjs.map → isDynamicWaasEnabled-BEVAshnS.cjs.map} +1 -1
  51. package/dist/{isDynamicWaasEnabled-C4oPJ0fw.native.esm.js → isDynamicWaasEnabled-C8Fb1xHn.native.esm.js} +2 -2
  52. package/dist/{isDynamicWaasEnabled-C4oPJ0fw.native.esm.js.map → isDynamicWaasEnabled-C8Fb1xHn.native.esm.js.map} +1 -1
  53. package/dist/{isDynamicWaasEnabled-JpnXC0f7.esm.js → isDynamicWaasEnabled-D5e2K02u.esm.js} +2 -2
  54. package/dist/{isDynamicWaasEnabled-JpnXC0f7.esm.js.map → isDynamicWaasEnabled-D5e2K02u.esm.js.map} +1 -1
  55. package/dist/{isMfaRequiredForAction-D6rt_Tzn.native.esm.js → isMfaRequiredForAction-A02NFVt8.esm.js} +3 -32
  56. package/dist/isMfaRequiredForAction-A02NFVt8.esm.js.map +1 -0
  57. package/dist/isMfaRequiredForAction-D4TSMQ4m.native.esm.js +77 -0
  58. package/dist/isMfaRequiredForAction-D4TSMQ4m.native.esm.js.map +1 -0
  59. package/dist/isMfaRequiredForAction-odpvykkm.cjs +94 -0
  60. package/dist/isMfaRequiredForAction-odpvykkm.cjs.map +1 -0
  61. package/dist/{isUserOnboardingComplete-CsoV3ae7.cjs → isUserOnboardingComplete-CEVSIxJC.cjs} +49 -3
  62. package/dist/isUserOnboardingComplete-CEVSIxJC.cjs.map +1 -0
  63. package/dist/{isUserOnboardingComplete-diGA1wlX.esm.js → isUserOnboardingComplete-Cgkw21XZ.esm.js} +44 -4
  64. package/dist/isUserOnboardingComplete-Cgkw21XZ.esm.js.map +1 -0
  65. package/dist/{isUserOnboardingComplete-DnExOJu7.native.esm.js → isUserOnboardingComplete-CvQShE05.native.esm.js} +44 -4
  66. package/dist/{isUserOnboardingComplete-CsoV3ae7.cjs.map → isUserOnboardingComplete-CvQShE05.native.esm.js.map} +1 -1
  67. package/dist/migrateFromFireblocks-BMtelH1a.native.esm.js +321 -0
  68. package/dist/migrateFromFireblocks-BMtelH1a.native.esm.js.map +1 -0
  69. package/dist/{migrateFromFireblocks-BrWXstt8.cjs → migrateFromFireblocks-CLUkVcFT.cjs} +54 -3
  70. package/dist/migrateFromFireblocks-CLUkVcFT.cjs.map +1 -0
  71. package/dist/{migrateFromFireblocks-CqL5l58Q.native.esm.js → migrateFromFireblocks-DcKrquTE.esm.js} +43 -4
  72. package/dist/migrateFromFireblocks-DcKrquTE.esm.js.map +1 -0
  73. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts +25 -0
  74. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts.map +1 -0
  75. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/index.d.ts +2 -0
  76. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/index.d.ts.map +1 -0
  77. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts +35 -0
  78. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts.map +1 -0
  79. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/index.d.ts +2 -0
  80. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/index.d.ts.map +1 -0
  81. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts +19 -0
  82. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts.map +1 -0
  83. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/index.d.ts +2 -0
  84. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/index.d.ts.map +1 -0
  85. package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts +184 -0
  86. package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts.map +1 -0
  87. package/dist/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.d.ts +16 -0
  88. package/dist/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.d.ts.map +1 -0
  89. package/dist/modules/waas/businessAccounts/createBusinessAccount/index.d.ts +2 -0
  90. package/dist/modules/waas/businessAccounts/createBusinessAccount/index.d.ts.map +1 -0
  91. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.d.ts +36 -0
  92. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.d.ts.map +1 -0
  93. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/index.d.ts +2 -0
  94. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/index.d.ts.map +1 -0
  95. package/dist/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.d.ts +15 -0
  96. package/dist/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.d.ts.map +1 -0
  97. package/dist/modules/waas/businessAccounts/getBusinessAccount/index.d.ts +2 -0
  98. package/dist/modules/waas/businessAccounts/getBusinessAccount/index.d.ts.map +1 -0
  99. package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/getBusinessAccountsClient.d.ts +12 -0
  100. package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/getBusinessAccountsClient.d.ts.map +1 -0
  101. package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/index.d.ts +2 -0
  102. package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/index.d.ts.map +1 -0
  103. package/dist/modules/waas/businessAccounts/listBusinessAccounts/index.d.ts +2 -0
  104. package/dist/modules/waas/businessAccounts/listBusinessAccounts/index.d.ts.map +1 -0
  105. package/dist/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.d.ts +10 -0
  106. package/dist/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.d.ts.map +1 -0
  107. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/index.d.ts +2 -0
  108. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/index.d.ts.map +1 -0
  109. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts +33 -0
  110. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts.map +1 -0
  111. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/index.d.ts +2 -0
  112. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/index.d.ts.map +1 -0
  113. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts +37 -0
  114. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts.map +1 -0
  115. package/dist/modules/waas/createWaasClient/createWaasClient.d.ts.map +1 -1
  116. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  117. package/dist/modules/waas/createWaasProvider/isWaasLoadExhaustionError.d.ts +11 -0
  118. package/dist/modules/waas/createWaasProvider/isWaasLoadExhaustionError.d.ts.map +1 -0
  119. package/dist/modules/waas/waas.types.d.ts +11 -0
  120. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  121. package/dist/services/keychain/createKeychainService/utils/openDatabase.d.ts +9 -1
  122. package/dist/services/keychain/createKeychainService/utils/openDatabase.d.ts.map +1 -1
  123. package/dist/services/keychain/createKeychainService/utils/withDatabase/withDatabase.d.ts +2 -1
  124. package/dist/services/keychain/createKeychainService/utils/withDatabase/withDatabase.d.ts.map +1 -1
  125. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  126. package/dist/{updateAuthFromVerifyResponse-B0K1VJ8b.cjs → updateAuthFromVerifyResponse-CSqnGlh3.cjs} +289 -19
  127. package/dist/updateAuthFromVerifyResponse-CSqnGlh3.cjs.map +1 -0
  128. package/dist/{updateAuthFromVerifyResponse-CVDQVEQM.esm.js → updateAuthFromVerifyResponse-C_YKKAIX.esm.js} +262 -4
  129. package/dist/updateAuthFromVerifyResponse-C_YKKAIX.esm.js.map +1 -0
  130. package/dist/utils/createTranslateRejection/createTranslateRejection.d.ts +29 -0
  131. package/dist/utils/createTranslateRejection/createTranslateRejection.d.ts.map +1 -0
  132. package/dist/utils/createTranslateRejection/index.d.ts +3 -0
  133. package/dist/utils/createTranslateRejection/index.d.ts.map +1 -0
  134. package/dist/waas.cjs +281 -17
  135. package/dist/waas.cjs.map +1 -1
  136. package/dist/waas.esm.js +273 -18
  137. package/dist/waas.esm.js.map +1 -1
  138. package/dist/waas.native.esm.js +272 -18
  139. package/dist/waas.native.esm.js.map +1 -1
  140. package/dist/waasCore.cjs +291 -170
  141. package/dist/waasCore.cjs.map +1 -1
  142. package/dist/waasCore.esm.js +285 -164
  143. package/dist/waasCore.esm.js.map +1 -1
  144. package/dist/waasCore.native.esm.js +273 -371
  145. package/dist/waasCore.native.esm.js.map +1 -1
  146. package/ios/DynamicClientScreenshotProtection.mm +70 -32
  147. package/package.json +4 -4
  148. package/dist/getNetworkProviderFromNetworkId-BlBx4Zh2.esm.js.map +0 -1
  149. package/dist/getNetworkProviderFromNetworkId-DaVOUpiF.cjs.map +0 -1
  150. package/dist/getSignedSessionId-3L_aMxVD.cjs.map +0 -1
  151. package/dist/getSignedSessionId-BVc-sgeN.esm.js.map +0 -1
  152. package/dist/isMfaRequiredForAction-20E6GsSc.esm.js +0 -336
  153. package/dist/isMfaRequiredForAction-20E6GsSc.esm.js.map +0 -1
  154. package/dist/isMfaRequiredForAction-9bYtZcve.cjs +0 -384
  155. package/dist/isMfaRequiredForAction-9bYtZcve.cjs.map +0 -1
  156. package/dist/isMfaRequiredForAction-D6rt_Tzn.native.esm.js.map +0 -1
  157. package/dist/isUserOnboardingComplete-DnExOJu7.native.esm.js.map +0 -1
  158. package/dist/isUserOnboardingComplete-diGA1wlX.esm.js.map +0 -1
  159. package/dist/migrateFromFireblocks--G-432sl.esm.js +0 -65
  160. package/dist/migrateFromFireblocks--G-432sl.esm.js.map +0 -1
  161. package/dist/migrateFromFireblocks-BrWXstt8.cjs.map +0 -1
  162. package/dist/migrateFromFireblocks-CqL5l58Q.native.esm.js.map +0 -1
  163. package/dist/updateAuthFromVerifyResponse-B0K1VJ8b.cjs.map +0 -1
  164. package/dist/updateAuthFromVerifyResponse-CVDQVEQM.esm.js.map +0 -1
  165. package/dist/updateAuthFromVerifyResponse-DGrmo9MJ.native.esm.js.map +0 -1
@@ -1,264 +1,58 @@
1
- import { Ct as version, N as getChainFromVerifiedCredentialChain, P as CHAINS_INFO_MAP, St as name, bt as BaseError, ct as isCookieEnabled, d as DYNAMIC_WAAS_METADATA, dt as getElevatedAccessToken, i as InvalidParamError, l as DEFAULT_WAAS_BASE_API_URL, mt as CLIENT_SDK_NAME, u as DEFAULT_WAAS_BASE_MPC_RELAY_API_URL, xt as getCore } from "./updateAuthFromVerifyResponse-DGrmo9MJ.native.esm.js";
2
- import "./isDynamicWaasEnabled-C4oPJ0fw.native.esm.js";
3
- import { i as NativeModuleNotLinkedError } from "./isMfaRequiredForAction-D6rt_Tzn.native.esm.js";
4
- import { a as WaasOnboardingIncompleteError, i as preconnectWaasIframe, t as isUserOnboardingComplete } from "./isUserOnboardingComplete-DnExOJu7.native.esm.js";
5
- import { n as consumeMfaTokenIfRequiredForAction, t as getSignedSessionId } from "./getSignedSessionId-DlmNVy-g.native.esm.js";
6
- import { n as getWaasWalletProviderFromWalletAccount, t as migrateFromFireblocks } from "./migrateFromFireblocks-CqL5l58Q.native.esm.js";
1
+ import { Ct as name, P as getChainFromVerifiedCredentialChain, St as getCore, a as InvalidParamError, f as DYNAMIC_WAAS_METADATA, ft as getElevatedAccessToken, wt as version } from "./NativeModuleNotLinkedError-Ds_t3AZQ.native.esm.js";
2
+ import "./isDynamicWaasEnabled-C8Fb1xHn.native.esm.js";
3
+ import { a as WaasOnboardingIncompleteError, i as preconnectWaasIframe, o as WaasLoadFailedError, t as isUserOnboardingComplete } from "./isUserOnboardingComplete-CvQShE05.native.esm.js";
4
+ import "./isMfaRequiredForAction-D4TSMQ4m.native.esm.js";
5
+ import { n as consumeMfaTokenIfRequiredForAction, t as getSignedSessionId } from "./getSignedSessionId-xZGFa4nS.native.esm.js";
6
+ import { i as createWaasClient, n as getWaasWalletProviderFromWalletAccount, r as getWaasChainNameFromChain, t as migrateFromFireblocks } from "./migrateFromFireblocks-BMtelH1a.native.esm.js";
7
7
  import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
8
8
  import { MFAAction, TokenScope, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
9
- import { ACCESSIBLE, getGenericPassword, resetGenericPassword, setGenericPassword } from "react-native-keychain";
10
- import { NativeEventEmitter, TurboModuleRegistry } from "react-native";
11
- import { DynamicWalletClient, ThresholdSignatureScheme, WalletOperation } from "@dynamic-labs-wallet/browser-wallet-client";
9
+ import { ThresholdSignatureScheme, WalletOperation } from "@dynamic-labs-wallet/browser-wallet-client";
12
10
 
13
- //#region src/errors/CorruptedKeyShareError.ts
11
+ //#region src/utils/createTranslateRejection/createTranslateRejection.ts
14
12
  /**
15
- * Thrown when a persisted client key share cannot be parsed back into its
16
- * structured form (e.g. a partially-written or corrupted keychain entry).
13
+ * Builds a reusable decorator, bound once to a `match`/`mapTo` pair, that wraps
14
+ * any async function so a matching rejection is rethrown as `mapTo(error)`
15
+ * while every other rejection — and every resolved value — passes through
16
+ * untouched. Unmatched errors are rethrown by reference, so the decorator can
17
+ * never swallow or reshape an error it was not asked to translate.
17
18
  *
18
- * Surfaced as a typed error rather than swallowed so callers can distinguish
19
- * "no key share stored" (empty result) from "key share exists but is
20
- * unreadable" the latter must never be silently treated as the former,
21
- * which could trigger an unintended re-keygen that overwrites recoverable
22
- * material.
23
- */
24
- var CorruptedKeyShareError = class extends BaseError {
25
- constructor({ cause = null } = {}) {
26
- super({
27
- cause,
28
- code: "corrupted_key_share_error",
29
- details: "The stored client key share could not be parsed. The secure storage entry may be partially written or corrupted.",
30
- docsUrl: null,
31
- name: "CorruptedKeyShareError",
32
- shortMessage: "Stored client key share is corrupted and cannot be read."
33
- });
34
- }
35
- };
36
-
37
- //#endregion
38
- //#region src/turboModules/NativeDynamicWebView.ts
39
- var NativeDynamicWebView_default = TurboModuleRegistry.get("DynamicClientWebView");
40
-
41
- //#endregion
42
- //#region src/errors/WebViewLoadFailedError.ts
43
- /**
44
- * Thrown when `DynamicWebView.open()` (via the WaaS transport provider)
45
- * fails to establish a usable load. Inspect `reason` to distinguish the
46
- * failure mode; `statusCode` and `underlyingError` provide structured
47
- * metadata for the cases that have it.
48
- */
49
- var WebViewLoadFailedError = class extends BaseError {
50
- reason;
51
- statusCode;
52
- underlyingError;
53
- constructor({ reason, shortMessage, cause = null, statusCode, underlyingError }) {
54
- super({
55
- cause,
56
- code: "webview_load_failed_error",
57
- details: underlyingError,
58
- docsUrl: null,
59
- name: "WebViewLoadFailedError",
60
- shortMessage
61
- });
62
- this.reason = reason;
63
- this.statusCode = statusCode;
64
- this.underlyingError = underlyingError;
65
- }
66
- };
67
-
68
- //#endregion
69
- //#region src/modules/waas/createWaasClient/translateNativeOpenError.ts
70
- const REASON_BY_NATIVE_CODE = {
71
- webview_cancelled: "cancelled",
72
- webview_content_process_terminated: "content_process_terminated",
73
- webview_http_error: "http_error",
74
- webview_instance_busy: "instance_busy",
75
- webview_invalid_url: "invalid_url",
76
- webview_navigation_failed: "navigation_failed",
77
- webview_no_host_view: "no_host_view",
78
- webview_unsupported: "unsupported"
79
- };
80
- /**
81
- * Translates a native `DynamicWebView.open()` rejection into a typed
82
- * `WebViewLoadFailedError`. Maps the native RCT reject code to the JS-level
83
- * `WebViewLoadFailureReason` discriminator (falling back to
84
- * `navigation_failed` for unrecognized codes) and carries through the
85
- * structured `statusCode` / `underlyingError` metadata.
86
- *
87
- * The `reason` it produces is the contract `createWaasSDKContainer` branches
88
- * on — notably `emitError` swallows `cancelled` because that code is only ever
89
- * produced by our own `close()` teardown (verified on both the iOS and Android
90
- * native sides). Keep `REASON_BY_NATIVE_CODE` in sync with the native reject
91
- * codes so that branching stays correct.
19
+ * Binding `match`/`mapTo` up front keeps the generic wrapping machinery here
20
+ * instead of at the call site: consumers get a plain `(fn) => wrappedFn`
21
+ * decorator they can apply to many functions of differing signatures, each of
22
+ * which keeps its own argument and return types.
92
23
  *
93
24
  * @notInstrumented
94
25
  */
95
- const translateNativeOpenError = (err) => {
96
- const rejection = err ?? {};
97
- const isNativeRejectionCode = (code) => code != void 0 && code in REASON_BY_NATIVE_CODE;
98
- const reason = isNativeRejectionCode(rejection.code) ? REASON_BY_NATIVE_CODE[rejection.code] : "navigation_failed";
99
- return new WebViewLoadFailedError({
100
- cause: err instanceof Error ? err : null,
101
- reason,
102
- shortMessage: rejection.message ?? `DynamicWebView open failed (${reason}).`,
103
- statusCode: rejection.userInfo?.DynamicWebViewStatusCode,
104
- underlyingError: rejection.userInfo?.DynamicWebViewUnderlying
105
- });
26
+ const createTranslateRejection = ({ match, mapTo }) => (fn) => async (...args) => {
27
+ try {
28
+ return await fn(...args);
29
+ } catch (error) {
30
+ if (match(error)) throw mapTo(error);
31
+ throw error;
32
+ }
106
33
  };
107
34
 
108
35
  //#endregion
109
- //#region src/modules/waas/createWaasClient/createNativeWaasSDKContainer.native.ts
110
- const NATIVE_MODULE_NAME = "DynamicClientWebView";
111
- const MESSAGE_EVENT_NAME = "dynamicBridgeMessage";
112
- const generateInstanceId = () => `${Date.now().toString(36)}-${crypto.randomUUID()}`;
36
+ //#region src/modules/waas/createWaasProvider/isWaasLoadExhaustionError.ts
113
37
  /**
114
- * Creates a React Native `WaasSDKContainer` backed by a hidden, headless native
115
- * WebView (WKWebView on iOS, `android.webkit.WebView` on Android) hosted by the
116
- * `DynamicClientWebView` TurboModule. Each invocation returns an isolated
117
- * container with its own instance ID, native WebView, and message routing.
118
- *
119
- * Used for MPC operations (signing, key-share management) where there is
120
- * nothing for the user to see. The VISIBLE private-key export display is no
121
- * longer a native overlay — it is rendered by the `ExportPrivateKey` component
122
- * (`@dynamic-labs-sdk/react-native-embedded-wallet-export`) on top of
123
- * `react-native-webview`, so it scrolls and positions like any RN view.
124
- *
125
- * @notInstrumented
38
+ * Exact message prefix of the rejection thrown by
39
+ * `@dynamic-labs-wallet/browser-wallet-client` when the secure container load
40
+ * exhausts all retry attempts. The upstream library throws a plain `Error`
41
+ * with no code, so message matching is the only detection mechanism available;
42
+ * the dependency is pinned to an exact version and the spec pins this string
43
+ * so drift is caught at upgrade time.
126
44
  */
127
- const createNativeWaasSDKContainer = () => {
128
- if (!NativeDynamicWebView_default) throw new NativeModuleNotLinkedError({ moduleName: NATIVE_MODULE_NAME });
129
- const nativeModule = NativeDynamicWebView_default;
130
- const instanceId = generateInstanceId();
131
- const emitter = new NativeEventEmitter(nativeModule);
132
- const messageHandlers = [];
133
- const errorHandlers = [];
134
- let subscription = null;
135
- let destroyed = false;
136
- const emitError = (err) => {
137
- if (destroyed) return;
138
- const translated = translateNativeOpenError(err);
139
- if (translated.reason === "cancelled") return;
140
- for (const handler of errorHandlers) handler(translated);
141
- };
142
- return {
143
- destroy() {
144
- if (destroyed) return;
145
- destroyed = true;
146
- subscription?.remove();
147
- subscription = null;
148
- messageHandlers.length = 0;
149
- errorHandlers.length = 0;
150
- nativeModule.close(instanceId);
151
- },
152
- isAlive: () => !destroyed,
153
- onError(handler) {
154
- errorHandlers.push(handler);
155
- return () => {
156
- const index = errorHandlers.indexOf(handler);
157
- if (index !== -1) errorHandlers.splice(index, 1);
158
- };
159
- },
160
- onMessage(handler) {
161
- messageHandlers.push(handler);
162
- subscription ??= emitter.addListener(MESSAGE_EVENT_NAME, (payload) => {
163
- if (payload.instanceId !== instanceId) return;
164
- for (const fn of messageHandlers) fn(payload.data);
165
- });
166
- return () => {
167
- const index = messageHandlers.indexOf(handler);
168
- if (index !== -1) messageHandlers.splice(index, 1);
169
- if (messageHandlers.length === 0) {
170
- subscription?.remove();
171
- subscription = null;
172
- }
173
- };
174
- },
175
- sendMessage(data) {
176
- nativeModule.sendMessage(instanceId, data);
177
- },
178
- async setUrl(url) {
179
- nativeModule.open(instanceId, url).catch(emitError);
180
- }
181
- };
182
- };
183
-
184
- //#endregion
185
- //#region src/modules/waas/createWaasClient/createWaasSDKContainer.native.ts
45
+ const UPSTREAM_LOAD_EXHAUSTION_MESSAGE_PREFIX = "Failed to load iframe after all retry attempts";
186
46
  /**
187
- * Creates a React Native `WaasSDKContainer` backed by a hidden, headless native
188
- * WebView (WKWebView on iOS, `android.webkit.WebView` on Android) hosted by the
189
- * `DynamicClientWebView` TurboModule. Used for MPC operations (signing, key-share
190
- * management) where there is nothing for the user to see.
191
- *
192
- * For the private-key export display — where the hosted page must render the
193
- * key for the user — use the `ExportPrivateKey` component from
194
- * `@dynamic-labs-sdk/react-native-embedded-wallet-export`, which renders the
195
- * key inside a `react-native-webview` instead of a native overlay.
47
+ * True when `error` is the upstream "load retry attempts exhausted" rejection
48
+ * from the embedded (WaaS) wallet's secure container load. Narrows to `Error`
49
+ * so the matched value can be forwarded as a typed error cause without a cast,
50
+ * and guards `instanceof Error` before reading `.message` so a non-`Error`
51
+ * rejection never throws during detection.
196
52
  *
197
53
  * @notInstrumented
198
54
  */
199
- const createWaasSDKContainer = () => createNativeWaasSDKContainer();
200
-
201
- //#endregion
202
- //#region src/modules/waas/createWaasClient/createWaasClient.native.ts
203
- /**
204
- * Keychain security options for the client key share. The share is wallet
205
- * key material that cannot be re-derived locally, so the options are pinned
206
- * explicitly rather than inherited from `react-native-keychain` defaults
207
- * (which vary across versions and platforms).
208
- *
209
- * `WHEN_UNLOCKED_THIS_DEVICE_ONLY` keeps the share readable only while the
210
- * device is unlocked, excludes it from iCloud Keychain sync, and prevents it
211
- * migrating to a new device on encrypted-backup restore. It deliberately does
212
- * NOT set `accessControl` (e.g. biometry) — reads must not surface a Face ID /
213
- * passcode prompt, since the share is read on routine wallet operations.
214
- */
215
- const KEY_SHARE_KEYCHAIN_OPTIONS = { accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY };
216
- /** @notInstrumented */
217
- const createWaasClient = ({ chainName }, client) => {
218
- const core = getCore(client);
219
- const additionalTrustedOrigins = core.waas?.additionalTrustedOrigins;
220
- const getKeyShareService = (accountAddress) => `${core.environmentId}:${accountAddress}`;
221
- return new DynamicWalletClient({
222
- authMode: isCookieEnabled(client) ? "cookie" : "header",
223
- authToken: client.token || "",
224
- baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace("/api/v0", ""),
225
- baseMPCRelayApiUrl: client.projectSettings?.sdk.waas?.relayUrl || DEFAULT_WAAS_BASE_MPC_RELAY_API_URL,
226
- chainName,
227
- environmentId: core.environmentId,
228
- hostOrigin: core.metadata?.universalLink,
229
- sdkVersion: `${CLIENT_SDK_NAME}/${core.version}`,
230
- ...additionalTrustedOrigins == void 0 ? {} : { additionalTrustedOrigins }
231
- }, {
232
- createWaasSDKContainer,
233
- secureStorage: {
234
- getClientKeyShare: async (accountAddress) => {
235
- const result = await getGenericPassword({ service: getKeyShareService(accountAddress) });
236
- if (!result) return [];
237
- try {
238
- return JSON.parse(result.password);
239
- } catch (cause) {
240
- throw new CorruptedKeyShareError({ cause: cause instanceof Error ? cause : null });
241
- }
242
- },
243
- removeClientKeyShare: async (accountAddress) => {
244
- await resetGenericPassword({ service: getKeyShareService(accountAddress) });
245
- },
246
- setClientKeyShare: async (accountAddress, shares) => {
247
- await setGenericPassword(accountAddress, JSON.stringify(shares), {
248
- ...KEY_SHARE_KEYCHAIN_OPTIONS,
249
- service: getKeyShareService(accountAddress)
250
- });
251
- }
252
- }
253
- });
254
- };
255
-
256
- //#endregion
257
- //#region src/modules/waas/getWaasChainNameFromChain/getWaasChainNameFromChain.ts
258
- /** @notInstrumented */
259
- const getWaasChainNameFromChain = (chain) => {
260
- return CHAINS_INFO_MAP[chain].waasChainNameOverride || chain;
261
- };
55
+ const isWaasLoadExhaustionError = (error) => error instanceof Error && error.message.startsWith(UPSTREAM_LOAD_EXHAUSTION_MESSAGE_PREFIX);
262
56
 
263
57
  //#endregion
264
58
  //#region src/modules/waas/createWaasProvider/createWaasProvider.ts
@@ -268,25 +62,49 @@ const createWaasProvider = ({ sdkClient, chain }) => {
268
62
  const logger = getCore(sdkClient).logger;
269
63
  let _waasClient;
270
64
  let _waasClientSessionId;
65
+ const resetClientIfCurrent = (client) => {
66
+ if (_waasClient === client) {
67
+ _waasClient = void 0;
68
+ _waasClientSessionId = void 0;
69
+ }
70
+ };
271
71
  const getWaasClient = async () => {
272
72
  const currentSessionId = getCore(sdkClient).state.get().user?.sessionId;
273
73
  if (_waasClient && currentSessionId !== _waasClientSessionId) _waasClient = void 0;
274
74
  if (!_waasClient) {
275
75
  if (!isUserOnboardingComplete(sdkClient)) throw new WaasOnboardingIncompleteError();
276
- _waasClient = createWaasClient({ chainName: getWaasChainNameFromChain(chain) }, sdkClient);
76
+ const builtClient = createWaasClient({ chainName: getWaasChainNameFromChain(chain) }, sdkClient);
77
+ _waasClient = builtClient;
277
78
  _waasClientSessionId = currentSessionId;
278
- await _waasClient.initialize();
79
+ try {
80
+ await builtClient.initialize();
81
+ } catch (error) {
82
+ resetClientIfCurrent(builtClient);
83
+ throw error;
84
+ }
279
85
  }
280
86
  return _waasClient;
281
87
  };
88
+ const discardClientOnLoadFailure = async ({ waasClient, operation }) => {
89
+ try {
90
+ return await operation();
91
+ } catch (error) {
92
+ if (isWaasLoadExhaustionError(error)) resetClientIfCurrent(waasClient);
93
+ throw error;
94
+ }
95
+ };
282
96
  const backupKeySharesToGoogleDrive = async ({ googleDriveAccessToken, password, walletAccount }) => {
283
97
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
284
- return (await getWaasClient()).backupKeySharesToGoogleDrive({
285
- accountAddress: walletAccount.address,
286
- authToken: sdkClient.token ?? void 0,
287
- googleDriveAccessToken,
288
- password,
289
- signedSessionId
98
+ const waasClient = await getWaasClient();
99
+ return discardClientOnLoadFailure({
100
+ operation: () => waasClient.backupKeySharesToGoogleDrive({
101
+ accountAddress: walletAccount.address,
102
+ authToken: sdkClient.token ?? void 0,
103
+ googleDriveAccessToken,
104
+ password,
105
+ signedSessionId
106
+ }),
107
+ waasClient
290
108
  });
291
109
  };
292
110
  const createWalletAccount = async (args = {}) => {
@@ -295,30 +113,43 @@ const createWaasProvider = ({ sdkClient, chain }) => {
295
113
  thresholdSignatureScheme: args.thresholdSignatureScheme
296
114
  });
297
115
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
298
- return await (await getWaasClient()).createWalletAccount({
299
- authToken: sdkClient.token ?? void 0,
300
- bitcoinConfig: args.bitcoinConfig,
301
- password: args.password,
302
- signedSessionId,
303
- thresholdSignatureScheme: args.thresholdSignatureScheme ?? ThresholdSignatureScheme.TWO_OF_TWO
116
+ const waasClient = await getWaasClient();
117
+ return await discardClientOnLoadFailure({
118
+ operation: () => waasClient.createWalletAccount({
119
+ authToken: sdkClient.token ?? void 0,
120
+ bitcoinConfig: args.bitcoinConfig,
121
+ businessAccountId: args.businessAccountId,
122
+ password: args.password,
123
+ signedSessionId,
124
+ thresholdSignatureScheme: args.thresholdSignatureScheme ?? ThresholdSignatureScheme.TWO_OF_TWO
125
+ }),
126
+ waasClient
304
127
  });
305
128
  };
306
129
  const delegateKeyShares = async ({ password, walletAccount }) => {
307
130
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
308
- return (await getWaasClient()).delegateKeyShares({
309
- accountAddress: walletAccount.address,
310
- authToken: sdkClient.token ?? void 0,
311
- password,
312
- signedSessionId
131
+ const waasClient = await getWaasClient();
132
+ return discardClientOnLoadFailure({
133
+ operation: () => waasClient.delegateKeyShares({
134
+ accountAddress: walletAccount.address,
135
+ authToken: sdkClient.token ?? void 0,
136
+ password,
137
+ signedSessionId
138
+ }),
139
+ waasClient
313
140
  });
314
141
  };
315
142
  const exportClientKeyshares = async ({ password, walletAccount }) => {
316
143
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
317
- await (await getWaasClient()).exportClientKeyshares({
318
- accountAddress: walletAccount.address,
319
- authToken: sdkClient.token ?? void 0,
320
- password,
321
- signedSessionId
144
+ const waasClient = await getWaasClient();
145
+ await discardClientOnLoadFailure({
146
+ operation: () => waasClient.exportClientKeyshares({
147
+ accountAddress: walletAccount.address,
148
+ authToken: sdkClient.token ?? void 0,
149
+ password,
150
+ signedSessionId
151
+ }),
152
+ waasClient
322
153
  });
323
154
  };
324
155
  const exportPrivateKey = async ({ container, displayContainer, walletAccount, password }) => {
@@ -326,78 +157,120 @@ const createWaasProvider = ({ sdkClient, chain }) => {
326
157
  const waasClient = await getWaasClient();
327
158
  const mfaToken = await consumeMfaTokenIfRequiredForAction({ mfaAction: MFAAction.WalletWaasExport }, sdkClient);
328
159
  const elevatedAccessToken = getElevatedAccessToken({ scope: TokenScope.Walletexport }, sdkClient);
329
- await waasClient.exportPrivateKey({
330
- accountAddress: walletAccount.address,
331
- authToken: sdkClient.token ?? void 0,
332
- container,
333
- displayContainer,
334
- elevatedAccessToken,
335
- mfaToken,
336
- password,
337
- signedSessionId
160
+ await discardClientOnLoadFailure({
161
+ operation: () => waasClient.exportPrivateKey({
162
+ accountAddress: walletAccount.address,
163
+ authToken: sdkClient.token ?? void 0,
164
+ container,
165
+ displayContainer,
166
+ elevatedAccessToken,
167
+ mfaToken,
168
+ password,
169
+ signedSessionId
170
+ }),
171
+ waasClient
338
172
  });
339
173
  };
340
174
  const restoreUserShareForWalletAccount = async ({ walletAccount }) => {
341
175
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
342
- await (await getWaasClient()).getWallet({
343
- accountAddress: walletAccount.address,
344
- authToken: sdkClient.token ?? void 0,
345
- signedSessionId,
346
- walletOperation: WalletOperation.SIGN_MESSAGE
176
+ const waasClient = await getWaasClient();
177
+ await discardClientOnLoadFailure({
178
+ operation: () => waasClient.getWallet({
179
+ accountAddress: walletAccount.address,
180
+ authToken: sdkClient.token ?? void 0,
181
+ signedSessionId,
182
+ walletOperation: WalletOperation.SIGN_MESSAGE
183
+ }),
184
+ waasClient
347
185
  });
348
186
  };
349
187
  const importPrivateKey = async ({ privateKey, thresholdSignatureScheme = ThresholdSignatureScheme.TWO_OF_TWO }) => {
350
188
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
351
- await (await getWaasClient()).importPrivateKey({
352
- authToken: sdkClient.token ?? void 0,
353
- privateKey,
354
- signedSessionId,
355
- thresholdSignatureScheme
189
+ const walletClient = await getWaasClient();
190
+ await discardClientOnLoadFailure({
191
+ operation: () => walletClient.importPrivateKey({
192
+ authToken: sdkClient.token ?? void 0,
193
+ privateKey,
194
+ signedSessionId,
195
+ thresholdSignatureScheme
196
+ }),
197
+ waasClient: walletClient
356
198
  });
357
199
  };
358
200
  const migrateFromFireblocks$1 = async ({ coinTypes, deviceId, expectedAddresses, jwt, password, storage }) => {
359
201
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
360
- return (await getWaasClient()).migrateFromFireblocks({
361
- authToken: sdkClient.token ?? void 0,
362
- fireblocks: {
363
- deviceId,
364
- expectedAddresses,
365
- jwt,
366
- ncwStorage: storage,
367
- walletPassword: password,
368
- ...coinTypes ? { coinTypes } : {}
369
- },
370
- signedSessionId
202
+ const walletClient = await getWaasClient();
203
+ return discardClientOnLoadFailure({
204
+ operation: () => walletClient.migrateFromFireblocks({
205
+ authToken: sdkClient.token ?? void 0,
206
+ fireblocks: {
207
+ deviceId,
208
+ expectedAddresses,
209
+ jwt,
210
+ ncwStorage: storage,
211
+ walletPassword: password,
212
+ ...coinTypes ? { coinTypes } : {}
213
+ },
214
+ signedSessionId
215
+ }),
216
+ waasClient: walletClient
371
217
  });
372
218
  };
373
219
  const refreshWalletAccountShares = async ({ password, walletAccount }) => {
374
220
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
375
221
  const walletClient = await getWaasClient();
376
222
  const mfaToken = await consumeMfaTokenIfRequiredForAction({ mfaAction: MFAAction.WalletWaasRefresh }, sdkClient);
377
- return walletClient.refreshWalletAccountShares({
378
- accountAddress: walletAccount.address,
379
- authToken: sdkClient.token ?? void 0,
380
- mfaToken,
381
- password,
382
- signedSessionId
223
+ return discardClientOnLoadFailure({
224
+ operation: () => walletClient.refreshWalletAccountShares({
225
+ accountAddress: walletAccount.address,
226
+ authToken: sdkClient.token ?? void 0,
227
+ mfaToken,
228
+ password,
229
+ signedSessionId
230
+ }),
231
+ waasClient: walletClient
232
+ });
233
+ };
234
+ const reshareToNewSignerShareSet = async ({ businessAccountId, password, signerType, targetSignerIdentity, walletAccount }) => {
235
+ const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
236
+ const waasClient = await getWaasClient();
237
+ return discardClientOnLoadFailure({
238
+ operation: () => waasClient.reshareToNewSignerShareSet({
239
+ accountAddress: walletAccount.address,
240
+ authToken: sdkClient.token ?? void 0,
241
+ businessAccountId,
242
+ password,
243
+ signedSessionId,
244
+ signerType,
245
+ targetSignerIdentity
246
+ }),
247
+ waasClient
383
248
  });
384
249
  };
385
250
  const revokeDelegation = async ({ password, walletAccount }) => {
386
251
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
387
- return (await getWaasClient()).revokeDelegation({
388
- accountAddress: walletAccount.address,
389
- authToken: sdkClient.token ?? void 0,
390
- password,
391
- signedSessionId
252
+ const waasClient = await getWaasClient();
253
+ return discardClientOnLoadFailure({
254
+ operation: () => waasClient.revokeDelegation({
255
+ accountAddress: walletAccount.address,
256
+ authToken: sdkClient.token ?? void 0,
257
+ password,
258
+ signedSessionId
259
+ }),
260
+ waasClient
392
261
  });
393
262
  };
394
263
  const setWaasWalletAccountPassword = async ({ password, walletAccount }) => {
395
264
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
396
- return (await getWaasClient()).setPassword({
397
- accountAddress: walletAccount.address,
398
- authToken: sdkClient.token ?? void 0,
399
- newPassword: password,
400
- signedSessionId
265
+ const waasClient = await getWaasClient();
266
+ return discardClientOnLoadFailure({
267
+ operation: () => waasClient.setPassword({
268
+ accountAddress: walletAccount.address,
269
+ authToken: sdkClient.token ?? void 0,
270
+ newPassword: password,
271
+ signedSessionId
272
+ }),
273
+ waasClient
401
274
  });
402
275
  };
403
276
  const signRawMessage = async ({ message, password, walletAccount }) => {
@@ -405,14 +278,18 @@ const createWaasProvider = ({ sdkClient, chain }) => {
405
278
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
406
279
  const mfaToken = await consumeMfaTokenIfRequiredForAction({ mfaAction: MFAAction.WalletWaasSign }, sdkClient);
407
280
  const elevatedAccessToken = getElevatedAccessToken({ scope: TokenScope.Walletsign }, sdkClient);
408
- return { signature: await (await getWaasClient()).signRawMessage({
409
- accountAddress: walletAccount.address,
410
- authToken: sdkClient.token ?? void 0,
411
- elevatedAccessToken,
412
- message,
413
- mfaToken,
414
- password,
415
- signedSessionId
281
+ const walletClient = await getWaasClient();
282
+ return { signature: await discardClientOnLoadFailure({
283
+ operation: () => walletClient.signRawMessage({
284
+ accountAddress: walletAccount.address,
285
+ authToken: sdkClient.token ?? void 0,
286
+ elevatedAccessToken,
287
+ message,
288
+ mfaToken,
289
+ password,
290
+ signedSessionId
291
+ }),
292
+ waasClient: walletClient
416
293
  }) };
417
294
  };
418
295
  const destroy = async (args) => {
@@ -423,78 +300,103 @@ const createWaasProvider = ({ sdkClient, chain }) => {
423
300
  };
424
301
  const updatePassword = async ({ walletAccount, currentPassword, newPassword }) => {
425
302
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
426
- return (await getWaasClient()).updatePassword({
427
- accountAddress: walletAccount.address,
428
- authToken: sdkClient.token ?? void 0,
429
- existingPassword: currentPassword,
430
- newPassword,
431
- signedSessionId
303
+ const waasClient = await getWaasClient();
304
+ return discardClientOnLoadFailure({
305
+ operation: () => waasClient.updatePassword({
306
+ accountAddress: walletAccount.address,
307
+ authToken: sdkClient.token ?? void 0,
308
+ existingPassword: currentPassword,
309
+ newPassword,
310
+ signedSessionId
311
+ }),
312
+ waasClient
432
313
  });
433
314
  };
434
315
  const signMessage = async ({ message, walletAccount }) => {
435
316
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
436
317
  const mfaToken = await consumeMfaTokenIfRequiredForAction({ mfaAction: MFAAction.WalletWaasSign }, sdkClient);
437
318
  const elevatedAccessToken = getElevatedAccessToken({ scope: TokenScope.Walletsign }, sdkClient);
438
- return { signature: await (await getWaasClient()).signMessage({
439
- accountAddress: walletAccount.address,
440
- authToken: sdkClient.token ?? void 0,
441
- elevatedAccessToken,
442
- message,
443
- mfaToken,
444
- signedSessionId
319
+ const waasClient = await getWaasClient();
320
+ return { signature: await discardClientOnLoadFailure({
321
+ operation: () => waasClient.signMessage({
322
+ accountAddress: walletAccount.address,
323
+ authToken: sdkClient.token ?? void 0,
324
+ elevatedAccessToken,
325
+ message,
326
+ mfaToken,
327
+ signedSessionId
328
+ }),
329
+ waasClient
445
330
  }) };
446
331
  };
447
332
  const signSerializedTransaction = async ({ chainId, serializedTransaction, walletAccount }) => {
448
333
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
449
334
  const mfaToken = await consumeMfaTokenIfRequiredForAction({ mfaAction: MFAAction.WalletWaasSign }, sdkClient);
450
335
  const elevatedAccessToken = getElevatedAccessToken({ scope: TokenScope.Walletsign }, sdkClient);
451
- return { signature: await (await getWaasClient()).signTransaction({
452
- authToken: sdkClient.token ?? void 0,
453
- chainId,
454
- elevatedAccessToken,
455
- mfaToken,
456
- senderAddress: walletAccount.address,
457
- signedSessionId,
458
- transaction: serializedTransaction
336
+ const waasClient = await getWaasClient();
337
+ return { signature: await discardClientOnLoadFailure({
338
+ operation: () => waasClient.signTransaction({
339
+ authToken: sdkClient.token ?? void 0,
340
+ chainId,
341
+ elevatedAccessToken,
342
+ mfaToken,
343
+ senderAddress: walletAccount.address,
344
+ signedSessionId,
345
+ transaction: serializedTransaction
346
+ }),
347
+ waasClient
459
348
  }) };
460
349
  };
461
350
  const getWalletRecoveryState = async ({ walletAccount }) => {
462
351
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
463
- return (await getWaasClient()).getWalletRecoveryState({
464
- accountAddress: walletAccount.address,
465
- authToken: sdkClient.token ?? void 0,
466
- signedSessionId
352
+ const waasClient = await getWaasClient();
353
+ return discardClientOnLoadFailure({
354
+ operation: () => waasClient.getWalletRecoveryState({
355
+ accountAddress: walletAccount.address,
356
+ authToken: sdkClient.token ?? void 0,
357
+ signedSessionId
358
+ }),
359
+ waasClient
467
360
  });
468
361
  };
469
362
  const unlockWallet = async ({ password, walletAccount }) => {
470
363
  const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
471
- return (await getWaasClient()).unlockWallet({
472
- accountAddress: walletAccount.address,
473
- authToken: sdkClient.token ?? void 0,
474
- password,
475
- signedSessionId
364
+ const waasClient = await getWaasClient();
365
+ return discardClientOnLoadFailure({
366
+ operation: () => waasClient.unlockWallet({
367
+ accountAddress: walletAccount.address,
368
+ authToken: sdkClient.token ?? void 0,
369
+ password,
370
+ signedSessionId
371
+ }),
372
+ waasClient
476
373
  });
477
374
  };
375
+ const translateLoadFailure = createTranslateRejection({
376
+ mapTo: (error) => new WaasLoadFailedError({ cause: error }),
377
+ match: isWaasLoadExhaustionError
378
+ });
478
379
  return {
479
- backupKeySharesToGoogleDrive,
480
- createWalletAccount,
481
- delegateKeyShares,
482
- destroy,
483
- exportClientKeyshares,
484
- exportPrivateKey,
485
- getWaasClient,
486
- getWalletRecoveryState,
487
- importPrivateKey,
488
- migrateFromFireblocks: migrateFromFireblocks$1,
489
- refreshWalletAccountShares,
490
- restoreUserShareForWalletAccount,
491
- revokeDelegation,
492
- setWaasWalletAccountPassword,
493
- signMessage,
494
- signRawMessage,
495
- signSerializedTransaction,
496
- unlockWallet,
497
- updatePassword
380
+ backupKeySharesToGoogleDrive: translateLoadFailure(backupKeySharesToGoogleDrive),
381
+ createWalletAccount: translateLoadFailure(createWalletAccount),
382
+ delegateKeyShares: translateLoadFailure(delegateKeyShares),
383
+ destroy: translateLoadFailure(destroy),
384
+ exportClientKeyshares: translateLoadFailure(exportClientKeyshares),
385
+ exportPrivateKey: translateLoadFailure(exportPrivateKey),
386
+ getWaasClient: translateLoadFailure(getWaasClient),
387
+ getWalletRecoveryState: translateLoadFailure(getWalletRecoveryState),
388
+ importPrivateKey: translateLoadFailure(importPrivateKey),
389
+ migrateFromFireblocks: translateLoadFailure(migrateFromFireblocks$1),
390
+ refreshWalletAccountShares: translateLoadFailure(refreshWalletAccountShares),
391
+ reshareToNewSignerShareSet: translateLoadFailure(reshareToNewSignerShareSet),
392
+ restoreUserShareForWalletAccount: translateLoadFailure(restoreUserShareForWalletAccount),
393
+ revokeDelegation: translateLoadFailure(revokeDelegation),
394
+ setWaasWalletAccountPassword: translateLoadFailure(setWaasWalletAccountPassword),
395
+ signMessage: translateLoadFailure(signMessage),
396
+ signRawMessage: translateLoadFailure(signRawMessage),
397
+ signSerializedTransaction: translateLoadFailure(signSerializedTransaction),
398
+ unlockWallet: translateLoadFailure(unlockWallet),
399
+ updatePassword: translateLoadFailure(updatePassword)
498
400
  };
499
401
  };
500
402