@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.
- package/dist/{updateAuthFromVerifyResponse-DGrmo9MJ.native.esm.js → NativeModuleNotLinkedError-Ds_t3AZQ.native.esm.js} +33 -4
- package/dist/NativeModuleNotLinkedError-Ds_t3AZQ.native.esm.js.map +1 -0
- package/dist/client/createDynamicClient/assertClientProps/assertClientProps.d.ts +16 -0
- package/dist/client/createDynamicClient/assertClientProps/assertClientProps.d.ts.map +1 -0
- package/dist/client/createDynamicClient/assertClientProps/index.d.ts +2 -0
- package/dist/client/createDynamicClient/assertClientProps/index.d.ts.map +1 -0
- package/dist/client/createDynamicClient/createDynamicClient.d.ts.map +1 -1
- package/dist/client/types/DynamicClientConfig.d.ts +35 -0
- package/dist/client/types/DynamicClientConfig.d.ts.map +1 -1
- package/dist/consumeMfaTokenIfRequiredForAction-CWVbmQ2A.cjs +17 -0
- package/dist/consumeMfaTokenIfRequiredForAction-CWVbmQ2A.cjs.map +1 -0
- package/dist/consumeMfaTokenIfRequiredForAction-C_IvLTH6.esm.js +12 -0
- package/dist/consumeMfaTokenIfRequiredForAction-C_IvLTH6.esm.js.map +1 -0
- package/dist/core.cjs +9 -8
- package/dist/core.cjs.map +1 -1
- package/dist/core.esm.js +6 -5
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +5 -5
- package/dist/errors/WaasLoadFailedError.d.ts +45 -0
- package/dist/errors/WaasLoadFailedError.d.ts.map +1 -0
- package/dist/exports/index.d.ts +1 -0
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/exports/waas.d.ts +10 -0
- package/dist/exports/waas.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-DaVOUpiF.cjs → getNetworkProviderFromNetworkId-5V4Cf8A_.cjs} +48 -13
- package/dist/getNetworkProviderFromNetworkId-5V4Cf8A_.cjs.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-BlBx4Zh2.esm.js → getNetworkProviderFromNetworkId-DhS1snCk.esm.js} +48 -13
- package/dist/getNetworkProviderFromNetworkId-DhS1snCk.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-xmoBE1cZ.native.esm.js → getNetworkProviderFromNetworkId-DudGvTmd.native.esm.js} +2 -3
- package/dist/{getNetworkProviderFromNetworkId-xmoBE1cZ.native.esm.js.map → getNetworkProviderFromNetworkId-DudGvTmd.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-3L_aMxVD.cjs → getSignedSessionId-E6FIx5aj.cjs} +2 -17
- package/dist/getSignedSessionId-E6FIx5aj.cjs.map +1 -0
- package/dist/{getSignedSessionId-DlmNVy-g.native.esm.js → getSignedSessionId-ekp3lswQ.esm.js} +3 -12
- package/dist/getSignedSessionId-ekp3lswQ.esm.js.map +1 -0
- package/dist/{getSignedSessionId-BVc-sgeN.esm.js → getSignedSessionId-xZGFa4nS.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-DlmNVy-g.native.esm.js.map → getSignedSessionId-xZGFa4nS.native.esm.js.map} +1 -1
- package/dist/{getWalletProviderByKey-BilyW5Jr.cjs → getWalletProviderByKey-BwivhTYu.cjs} +2 -2
- package/dist/{getWalletProviderByKey-BilyW5Jr.cjs.map → getWalletProviderByKey-BwivhTYu.cjs.map} +1 -1
- package/dist/{getWalletProviderByKey-PIO1ygzj.esm.js → getWalletProviderByKey-CS299i1V.esm.js} +2 -2
- package/dist/{getWalletProviderByKey-PIO1ygzj.esm.js.map → getWalletProviderByKey-CS299i1V.esm.js.map} +1 -1
- package/dist/{getWalletProviderByKey-Ccx26JsF.native.esm.js → getWalletProviderByKey-CYGDw6-5.native.esm.js} +2 -2
- package/dist/{getWalletProviderByKey-Ccx26JsF.native.esm.js.map → getWalletProviderByKey-CYGDw6-5.native.esm.js.map} +1 -1
- package/dist/index.cjs +48 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +34 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +34 -7
- package/dist/index.native.esm.js.map +1 -1
- package/dist/{isDynamicWaasEnabled-DXVcXa66.cjs → isDynamicWaasEnabled-BEVAshnS.cjs} +2 -2
- package/dist/{isDynamicWaasEnabled-DXVcXa66.cjs.map → isDynamicWaasEnabled-BEVAshnS.cjs.map} +1 -1
- package/dist/{isDynamicWaasEnabled-C4oPJ0fw.native.esm.js → isDynamicWaasEnabled-C8Fb1xHn.native.esm.js} +2 -2
- package/dist/{isDynamicWaasEnabled-C4oPJ0fw.native.esm.js.map → isDynamicWaasEnabled-C8Fb1xHn.native.esm.js.map} +1 -1
- package/dist/{isDynamicWaasEnabled-JpnXC0f7.esm.js → isDynamicWaasEnabled-D5e2K02u.esm.js} +2 -2
- package/dist/{isDynamicWaasEnabled-JpnXC0f7.esm.js.map → isDynamicWaasEnabled-D5e2K02u.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-D6rt_Tzn.native.esm.js → isMfaRequiredForAction-A02NFVt8.esm.js} +3 -32
- package/dist/isMfaRequiredForAction-A02NFVt8.esm.js.map +1 -0
- package/dist/isMfaRequiredForAction-D4TSMQ4m.native.esm.js +77 -0
- package/dist/isMfaRequiredForAction-D4TSMQ4m.native.esm.js.map +1 -0
- package/dist/isMfaRequiredForAction-odpvykkm.cjs +94 -0
- package/dist/isMfaRequiredForAction-odpvykkm.cjs.map +1 -0
- package/dist/{isUserOnboardingComplete-CsoV3ae7.cjs → isUserOnboardingComplete-CEVSIxJC.cjs} +49 -3
- package/dist/isUserOnboardingComplete-CEVSIxJC.cjs.map +1 -0
- package/dist/{isUserOnboardingComplete-diGA1wlX.esm.js → isUserOnboardingComplete-Cgkw21XZ.esm.js} +44 -4
- package/dist/isUserOnboardingComplete-Cgkw21XZ.esm.js.map +1 -0
- package/dist/{isUserOnboardingComplete-DnExOJu7.native.esm.js → isUserOnboardingComplete-CvQShE05.native.esm.js} +44 -4
- package/dist/{isUserOnboardingComplete-CsoV3ae7.cjs.map → isUserOnboardingComplete-CvQShE05.native.esm.js.map} +1 -1
- package/dist/migrateFromFireblocks-BMtelH1a.native.esm.js +321 -0
- package/dist/migrateFromFireblocks-BMtelH1a.native.esm.js.map +1 -0
- package/dist/{migrateFromFireblocks-BrWXstt8.cjs → migrateFromFireblocks-CLUkVcFT.cjs} +54 -3
- package/dist/migrateFromFireblocks-CLUkVcFT.cjs.map +1 -0
- package/dist/{migrateFromFireblocks-CqL5l58Q.native.esm.js → migrateFromFireblocks-DcKrquTE.esm.js} +43 -4
- package/dist/migrateFromFireblocks-DcKrquTE.esm.js.map +1 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts +25 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountMember/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts +35 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts +19 -0
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts +184 -0
- package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.d.ts +16 -0
- package/dist/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/createBusinessAccount/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/createBusinessAccount/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.d.ts +36 -0
- package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.d.ts +15 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccount/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccount/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/getBusinessAccountsClient.d.ts +12 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/getBusinessAccountsClient.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccounts/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccounts/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.d.ts +10 -0
- package/dist/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts +33 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts +37 -0
- package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts.map +1 -0
- package/dist/modules/waas/createWaasClient/createWaasClient.d.ts.map +1 -1
- package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
- package/dist/modules/waas/createWaasProvider/isWaasLoadExhaustionError.d.ts +11 -0
- package/dist/modules/waas/createWaasProvider/isWaasLoadExhaustionError.d.ts.map +1 -0
- package/dist/modules/waas/waas.types.d.ts +11 -0
- package/dist/modules/waas/waas.types.d.ts.map +1 -1
- package/dist/services/keychain/createKeychainService/utils/openDatabase.d.ts +9 -1
- package/dist/services/keychain/createKeychainService/utils/openDatabase.d.ts.map +1 -1
- package/dist/services/keychain/createKeychainService/utils/withDatabase/withDatabase.d.ts +2 -1
- package/dist/services/keychain/createKeychainService/utils/withDatabase/withDatabase.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/{updateAuthFromVerifyResponse-B0K1VJ8b.cjs → updateAuthFromVerifyResponse-CSqnGlh3.cjs} +289 -19
- package/dist/updateAuthFromVerifyResponse-CSqnGlh3.cjs.map +1 -0
- package/dist/{updateAuthFromVerifyResponse-CVDQVEQM.esm.js → updateAuthFromVerifyResponse-C_YKKAIX.esm.js} +262 -4
- package/dist/updateAuthFromVerifyResponse-C_YKKAIX.esm.js.map +1 -0
- package/dist/utils/createTranslateRejection/createTranslateRejection.d.ts +29 -0
- package/dist/utils/createTranslateRejection/createTranslateRejection.d.ts.map +1 -0
- package/dist/utils/createTranslateRejection/index.d.ts +3 -0
- package/dist/utils/createTranslateRejection/index.d.ts.map +1 -0
- package/dist/waas.cjs +281 -17
- package/dist/waas.cjs.map +1 -1
- package/dist/waas.esm.js +273 -18
- package/dist/waas.esm.js.map +1 -1
- package/dist/waas.native.esm.js +272 -18
- package/dist/waas.native.esm.js.map +1 -1
- package/dist/waasCore.cjs +291 -170
- package/dist/waasCore.cjs.map +1 -1
- package/dist/waasCore.esm.js +285 -164
- package/dist/waasCore.esm.js.map +1 -1
- package/dist/waasCore.native.esm.js +273 -371
- package/dist/waasCore.native.esm.js.map +1 -1
- package/ios/DynamicClientScreenshotProtection.mm +70 -32
- package/package.json +4 -4
- package/dist/getNetworkProviderFromNetworkId-BlBx4Zh2.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-DaVOUpiF.cjs.map +0 -1
- package/dist/getSignedSessionId-3L_aMxVD.cjs.map +0 -1
- package/dist/getSignedSessionId-BVc-sgeN.esm.js.map +0 -1
- package/dist/isMfaRequiredForAction-20E6GsSc.esm.js +0 -336
- package/dist/isMfaRequiredForAction-20E6GsSc.esm.js.map +0 -1
- package/dist/isMfaRequiredForAction-9bYtZcve.cjs +0 -384
- package/dist/isMfaRequiredForAction-9bYtZcve.cjs.map +0 -1
- package/dist/isMfaRequiredForAction-D6rt_Tzn.native.esm.js.map +0 -1
- package/dist/isUserOnboardingComplete-DnExOJu7.native.esm.js.map +0 -1
- package/dist/isUserOnboardingComplete-diGA1wlX.esm.js.map +0 -1
- package/dist/migrateFromFireblocks--G-432sl.esm.js +0 -65
- package/dist/migrateFromFireblocks--G-432sl.esm.js.map +0 -1
- package/dist/migrateFromFireblocks-BrWXstt8.cjs.map +0 -1
- package/dist/migrateFromFireblocks-CqL5l58Q.native.esm.js.map +0 -1
- package/dist/updateAuthFromVerifyResponse-B0K1VJ8b.cjs.map +0 -1
- package/dist/updateAuthFromVerifyResponse-CVDQVEQM.esm.js.map +0 -1
- package/dist/updateAuthFromVerifyResponse-DGrmo9MJ.native.esm.js.map +0 -1
|
@@ -1,264 +1,58 @@
|
|
|
1
|
-
import { Ct as
|
|
2
|
-
import "./isDynamicWaasEnabled-
|
|
3
|
-
import { i as
|
|
4
|
-
import
|
|
5
|
-
import { n as consumeMfaTokenIfRequiredForAction, t as getSignedSessionId } from "./getSignedSessionId-
|
|
6
|
-
import { n as getWaasWalletProviderFromWalletAccount, t as migrateFromFireblocks } from "./migrateFromFireblocks-
|
|
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 {
|
|
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/
|
|
11
|
+
//#region src/utils/createTranslateRejection/createTranslateRejection.ts
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* which
|
|
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
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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/
|
|
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
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
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
|
|
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
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
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
|
|
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
|
-
|
|
76
|
+
const builtClient = createWaasClient({ chainName: getWaasChainNameFromChain(chain) }, sdkClient);
|
|
77
|
+
_waasClient = builtClient;
|
|
277
78
|
_waasClientSessionId = currentSessionId;
|
|
278
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
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
|
|