@dynamic-labs-sdk/client 1.31.1 → 1.32.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/{apiClient-BZfdx9fH.native.esm.js → apiClient-Bwd6cllS.native.esm.js} +2 -2
- package/dist/{apiClient-BZfdx9fH.native.esm.js.map → apiClient-Bwd6cllS.native.esm.js.map} +1 -1
- package/dist/core.cjs +7 -5
- package/dist/core.cjs.map +1 -1
- package/dist/core.esm.js +6 -6
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +8 -8
- package/dist/core.native.esm.js.map +1 -1
- package/dist/errors/AmbiguousWalletChainError.d.ts +30 -0
- package/dist/errors/AmbiguousWalletChainError.d.ts.map +1 -0
- package/dist/errors/ConnectionUriHandlerMissingError.d.ts +35 -0
- package/dist/errors/ConnectionUriHandlerMissingError.d.ts.map +1 -0
- package/dist/errors/NoConnectionOptionAvailableError.d.ts +39 -0
- package/dist/errors/NoConnectionOptionAvailableError.d.ts.map +1 -0
- package/dist/errors/WalletBrowserRedirectHandlerMissingError.d.ts +39 -0
- package/dist/errors/WalletBrowserRedirectHandlerMissingError.d.ts.map +1 -0
- package/dist/errors/WalletOptionNotFoundError.d.ts +30 -0
- package/dist/errors/WalletOptionNotFoundError.d.ts.map +1 -0
- package/dist/exports/core.d.ts +4 -0
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/exports/index.d.ts +12 -1
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-DNIuJp20.cjs → getNetworkProviderFromNetworkId-5UBZwUg2.cjs} +78 -2
- package/dist/getNetworkProviderFromNetworkId-5UBZwUg2.cjs.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-DRA4M5Ab.native.esm.js → getNetworkProviderFromNetworkId-DSsGkava.native.esm.js} +79 -9
- package/dist/getNetworkProviderFromNetworkId-DSsGkava.native.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-CbMpiSub.esm.js → getNetworkProviderFromNetworkId-TTqmAiJh.esm.js} +73 -3
- package/dist/getNetworkProviderFromNetworkId-TTqmAiJh.esm.js.map +1 -0
- package/dist/{getSignedSessionId-DKKSCpj9.native.esm.js → getSignedSessionId-BkYhH1zc.native.esm.js} +34 -4
- package/dist/getSignedSessionId-BkYhH1zc.native.esm.js.map +1 -0
- package/dist/{getSignedSessionId--wpV_VKs.cjs → getSignedSessionId-DBUnRGjt.cjs} +39 -3
- package/dist/getSignedSessionId-DBUnRGjt.cjs.map +1 -0
- package/dist/{getSignedSessionId-DHn6yhGX.esm.js → getSignedSessionId-DeeDyino.esm.js} +34 -4
- package/dist/getSignedSessionId-DeeDyino.esm.js.map +1 -0
- package/dist/{getVerifiedCredentialForWalletAccount-B5LUGiDP.cjs → getVerifiedCredentialForWalletAccount-BSxiaaVp.cjs} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-B5LUGiDP.cjs.map → getVerifiedCredentialForWalletAccount-BSxiaaVp.cjs.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-C_GcjgC8.esm.js → getVerifiedCredentialForWalletAccount-C--Dza_K.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-C_GcjgC8.esm.js.map → getVerifiedCredentialForWalletAccount-C--Dza_K.esm.js.map} +1 -1
- package/dist/highLevelFunctions/connectWalletOption/connectWalletOption.d.ts +55 -0
- package/dist/highLevelFunctions/connectWalletOption/connectWalletOption.d.ts.map +1 -0
- package/dist/highLevelFunctions/connectWalletOption/connectWalletOption.types.d.ts +46 -0
- package/dist/highLevelFunctions/connectWalletOption/connectWalletOption.types.d.ts.map +1 -0
- package/dist/highLevelFunctions/connectWalletOption/index.d.ts +2 -0
- package/dist/highLevelFunctions/connectWalletOption/index.d.ts.map +1 -0
- package/dist/index.cjs +802 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +795 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +755 -60
- package/dist/index.native.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-YjJLLFFs.cjs → isMfaRequiredForAction-62zh3W-2.cjs} +2 -2
- package/dist/{isMfaRequiredForAction-YjJLLFFs.cjs.map → isMfaRequiredForAction-62zh3W-2.cjs.map} +1 -1
- package/dist/{isMfaRequiredForAction-D1a1Nudo.esm.js → isMfaRequiredForAction-BPEXPqSt.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-D1a1Nudo.esm.js.map → isMfaRequiredForAction-BPEXPqSt.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-CC7bjhqy.native.esm.js → isMfaRequiredForAction-DfrEFvU2.native.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-CC7bjhqy.native.esm.js.map → isMfaRequiredForAction-DfrEFvU2.native.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-BIjk67vX.native.esm.js → isUserOnboardingComplete-BWrCHXXO.native.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-BIjk67vX.native.esm.js.map → isUserOnboardingComplete-BWrCHXXO.native.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-C4bE5xqM.esm.js → isUserOnboardingComplete-Dmck83_2.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-C4bE5xqM.esm.js.map → isUserOnboardingComplete-Dmck83_2.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-C2ZuLDT9.cjs → isUserOnboardingComplete-DtxIznZD.cjs} +3 -3
- package/dist/{isUserOnboardingComplete-C2ZuLDT9.cjs.map → isUserOnboardingComplete-DtxIznZD.cjs.map} +1 -1
- package/dist/{logoutWithReason-BcWQGREO.native.esm.js → logoutWithReason-DIc7cC6T.native.esm.js} +2 -2
- package/dist/{logoutWithReason-BcWQGREO.native.esm.js.map → logoutWithReason-DIc7cC6T.native.esm.js.map} +1 -1
- package/dist/{logoutWithReason-BqsgA8gI.esm.js → logoutWithReason-x8mE7EAy.esm.js} +2 -2
- package/dist/{logoutWithReason-BqsgA8gI.esm.js.map → logoutWithReason-x8mE7EAy.esm.js.map} +1 -1
- package/dist/{logoutWithReason-D6ruPOvJ.cjs → logoutWithReason-yDqQ0UIt.cjs} +2 -2
- package/dist/{logoutWithReason-D6ruPOvJ.cjs.map → logoutWithReason-yDqQ0UIt.cjs.map} +1 -1
- package/dist/{migrateFromFireblocks-BxPgqhbu.native.esm.js → migrateFromFireblocks-BUhWQCqm.native.esm.js} +2 -2
- package/dist/{migrateFromFireblocks-BxPgqhbu.native.esm.js.map → migrateFromFireblocks-BUhWQCqm.native.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-zazAx6WV.esm.js → migrateFromFireblocks-BapjEhra.esm.js} +2 -2
- package/dist/{migrateFromFireblocks-zazAx6WV.esm.js.map → migrateFromFireblocks-BapjEhra.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-CCNTDCmW.cjs → migrateFromFireblocks-qYPrnWF8.cjs} +2 -2
- package/dist/{migrateFromFireblocks-CCNTDCmW.cjs.map → migrateFromFireblocks-qYPrnWF8.cjs.map} +1 -1
- package/dist/modules/auth/social/oauth/clearSocialRedirectParams/clearSocialRedirectParams.d.ts +7 -1
- package/dist/modules/auth/social/oauth/clearSocialRedirectParams/clearSocialRedirectParams.d.ts.map +1 -1
- package/dist/modules/auth/social/oauth/clearSocialRedirectParams/clearSocialRedirectParams.types.d.ts +4 -0
- package/dist/modules/auth/social/oauth/clearSocialRedirectParams/clearSocialRedirectParams.types.d.ts.map +1 -0
- package/dist/modules/auth/social/oauth/completeSocialRedirect/completeSocialRedirect.d.ts +9 -0
- package/dist/modules/auth/social/oauth/completeSocialRedirect/completeSocialRedirect.d.ts.map +1 -1
- package/dist/modules/walletOptionsCatalogue/walletOptionsCatalogue.types.d.ts +2 -1
- package/dist/modules/walletOptionsCatalogue/walletOptionsCatalogue.types.d.ts.map +1 -1
- package/dist/modules/wallets/connectWithUriConnectionOption/connectWithUriConnectionOption.d.ts +53 -0
- package/dist/modules/wallets/connectWithUriConnectionOption/connectWithUriConnectionOption.d.ts.map +1 -0
- package/dist/modules/wallets/connectWithUriConnectionOption/getConnectionUriDeeplink/getConnectionUriDeeplink.d.ts +34 -0
- package/dist/modules/wallets/connectWithUriConnectionOption/getConnectionUriDeeplink/getConnectionUriDeeplink.d.ts.map +1 -0
- package/dist/modules/wallets/connectWithUriConnectionOption/getConnectionUriDeeplink/index.d.ts +2 -0
- package/dist/modules/wallets/connectWithUriConnectionOption/getConnectionUriDeeplink/index.d.ts.map +1 -0
- package/dist/modules/wallets/connectWithUriConnectionOption/index.d.ts +2 -0
- package/dist/modules/wallets/connectWithUriConnectionOption/index.d.ts.map +1 -0
- package/dist/modules/wallets/redirectToInAppBrowser/index.d.ts +2 -0
- package/dist/modules/wallets/redirectToInAppBrowser/index.d.ts.map +1 -0
- package/dist/modules/wallets/redirectToInAppBrowser/redirectToInAppBrowser.d.ts +60 -0
- package/dist/modules/wallets/redirectToInAppBrowser/redirectToInAppBrowser.d.ts.map +1 -0
- package/dist/modules/wallets/resolveWalletConnectionOption/index.d.ts +3 -0
- package/dist/modules/wallets/resolveWalletConnectionOption/index.d.ts.map +1 -0
- package/dist/modules/wallets/resolveWalletConnectionOption/resolveWalletConnectionOption.d.ts +36 -0
- package/dist/modules/wallets/resolveWalletConnectionOption/resolveWalletConnectionOption.d.ts.map +1 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/createUriConnectionStarterRegistry/createUriConnectionStarterRegistry.d.ts +22 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/createUriConnectionStarterRegistry/createUriConnectionStarterRegistry.d.ts.map +1 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/createUriConnectionStarterRegistry/index.d.ts +2 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/createUriConnectionStarterRegistry/index.d.ts.map +1 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/events.d.ts +18 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/events.d.ts.map +1 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/getUriConnectionStarterRegistry/getUriConnectionStarterRegistry.d.ts +22 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/getUriConnectionStarterRegistry/getUriConnectionStarterRegistry.d.ts.map +1 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/getUriConnectionStarterRegistry/index.d.ts +2 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/getUriConnectionStarterRegistry/index.d.ts.map +1 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/index.d.ts +3 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/index.d.ts.map +1 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/uriConnectionStarterRegistry.types.d.ts +32 -0
- package/dist/modules/wallets/uriConnectionStarterRegistry/uriConnectionStarterRegistry.types.d.ts.map +1 -0
- package/dist/modules/wallets/walletConnectionHandlers.types.d.ts +62 -0
- package/dist/modules/wallets/walletConnectionHandlers.types.d.ts.map +1 -0
- package/dist/modules/wallets/walletProviderUriConnection.types.d.ts +19 -0
- package/dist/modules/wallets/walletProviderUriConnection.types.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/buildInAppBrowserUrl/buildInAppBrowserUrl.d.ts +32 -0
- package/dist/utils/buildInAppBrowserUrl/buildInAppBrowserUrl.d.ts.map +1 -0
- package/dist/utils/buildInAppBrowserUrl/index.d.ts +2 -0
- package/dist/utils/buildInAppBrowserUrl/index.d.ts.map +1 -0
- package/dist/utils/getCurrentPageUrl/getCurrentPageUrl.d.ts +15 -0
- package/dist/utils/getCurrentPageUrl/getCurrentPageUrl.d.ts.map +1 -0
- package/dist/utils/getCurrentPageUrl/index.d.ts +2 -0
- package/dist/utils/getCurrentPageUrl/index.d.ts.map +1 -0
- package/dist/utils/getPreferredWalletDeepLink/getPreferredWalletDeepLink.d.ts +33 -0
- package/dist/utils/getPreferredWalletDeepLink/getPreferredWalletDeepLink.d.ts.map +1 -0
- package/dist/utils/getPreferredWalletDeepLink/index.d.ts +2 -0
- package/dist/utils/getPreferredWalletDeepLink/index.d.ts.map +1 -0
- package/dist/utils/isAndroid/index.d.ts +2 -0
- package/dist/utils/isAndroid/index.d.ts.map +1 -0
- package/dist/utils/isAndroid/isAndroid.d.ts +20 -0
- package/dist/utils/isAndroid/isAndroid.d.ts.map +1 -0
- package/dist/utils/isIOS/index.d.ts +2 -0
- package/dist/utils/isIOS/index.d.ts.map +1 -0
- package/dist/utils/isIOS/isIOS.d.ts +23 -0
- package/dist/utils/isIOS/isIOS.d.ts.map +1 -0
- package/dist/utils/isMobile/isMobile.d.ts +17 -36
- package/dist/utils/isMobile/isMobile.d.ts.map +1 -1
- package/dist/utils/userAgentChecks/userAgentChecks.d.ts +35 -0
- package/dist/utils/userAgentChecks/userAgentChecks.d.ts.map +1 -0
- package/dist/{waas-DidjjQjB.native.esm.js → waas-CyUrvkQr.native.esm.js} +4 -4
- package/dist/{waas-DidjjQjB.native.esm.js.map → waas-CyUrvkQr.native.esm.js.map} +1 -1
- package/dist/{waas-C2PbR02F.esm.js → waas-DzcYsWU8.esm.js} +4 -4
- package/dist/{waas-C2PbR02F.esm.js.map → waas-DzcYsWU8.esm.js.map} +1 -1
- package/dist/{waas-ZWlJHeXc.cjs → waas-WID2Fy_N.cjs} +4 -4
- package/dist/{waas-ZWlJHeXc.cjs.map → waas-WID2Fy_N.cjs.map} +1 -1
- package/dist/waas.cjs +4 -4
- package/dist/waas.esm.js +4 -4
- package/dist/waas.native.esm.js +4 -4
- package/dist/waasCore.cjs +10 -40
- package/dist/waasCore.cjs.map +1 -1
- package/dist/waasCore.esm.js +5 -35
- package/dist/waasCore.esm.js.map +1 -1
- package/dist/waasCore.native.esm.js +5 -35
- package/dist/waasCore.native.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/getNetworkProviderFromNetworkId-CbMpiSub.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-DNIuJp20.cjs.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-DRA4M5Ab.native.esm.js.map +0 -1
- package/dist/getSignedSessionId--wpV_VKs.cjs.map +0 -1
- package/dist/getSignedSessionId-DHn6yhGX.esm.js.map +0 -1
- package/dist/getSignedSessionId-DKKSCpj9.native.esm.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_logoutWithReason = require('./logoutWithReason-
|
|
2
|
-
const require_migrateFromFireblocks = require('./migrateFromFireblocks-
|
|
3
|
-
const require_waas = require('./waas-
|
|
4
|
-
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-
|
|
5
|
-
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-
|
|
6
|
-
const require_isUserOnboardingComplete = require('./isUserOnboardingComplete-
|
|
7
|
-
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-
|
|
1
|
+
const require_logoutWithReason = require('./logoutWithReason-yDqQ0UIt.cjs');
|
|
2
|
+
const require_migrateFromFireblocks = require('./migrateFromFireblocks-qYPrnWF8.cjs');
|
|
3
|
+
const require_waas = require('./waas-WID2Fy_N.cjs');
|
|
4
|
+
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-5UBZwUg2.cjs');
|
|
5
|
+
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-BSxiaaVp.cjs');
|
|
6
|
+
const require_isUserOnboardingComplete = require('./isUserOnboardingComplete-DtxIznZD.cjs');
|
|
7
|
+
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-62zh3W-2.cjs');
|
|
8
8
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
9
9
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
10
10
|
let zod_mini = require("zod/mini");
|
|
@@ -557,7 +557,7 @@ const initializeClient = async (client = require_logoutWithReason.getDefaultClie
|
|
|
557
557
|
*/
|
|
558
558
|
if (require_logoutWithReason.isCookieEnabled(client)) await require_logoutWithReason.__refreshAuth_wrapped(client).catch(async (error) => {
|
|
559
559
|
if (error.status === 401) {
|
|
560
|
-
core.logger.
|
|
560
|
+
core.logger.warn("Session expired during initialization", error);
|
|
561
561
|
if (client.user) await require_logoutWithReason.__logoutWithReason_wrapped({ reason: "session-refresh-unauthorized" }, client);
|
|
562
562
|
} else throw error;
|
|
563
563
|
});
|
|
@@ -1204,6 +1204,44 @@ const __createDynamicClient_wrapped = require_logoutWithReason.instrumentFunctio
|
|
|
1204
1204
|
}
|
|
1205
1205
|
});
|
|
1206
1206
|
|
|
1207
|
+
//#endregion
|
|
1208
|
+
//#region src/errors/AmbiguousWalletChainError.ts
|
|
1209
|
+
/**
|
|
1210
|
+
* Thrown when a wallet can be connected on more than one of the client's
|
|
1211
|
+
* enabled chains and no chain was passed to `connectWalletOption`.
|
|
1212
|
+
*
|
|
1213
|
+
* Multi-chain wallets such as MetaMask or Phantom connect to a different
|
|
1214
|
+
* account per chain, so the chain has to be an explicit choice rather than one
|
|
1215
|
+
* Dynamic makes on the customer's behalf.
|
|
1216
|
+
*
|
|
1217
|
+
* @example
|
|
1218
|
+
* ```ts
|
|
1219
|
+
* // Throws, since Phantom connects on both SOL and EVM
|
|
1220
|
+
* await connectWalletOption({ walletKey: 'phantom' });
|
|
1221
|
+
*
|
|
1222
|
+
* // Connects the wallet's Solana account
|
|
1223
|
+
* await connectWalletOption({ chain: 'SOL', walletKey: 'phantom' });
|
|
1224
|
+
* ```
|
|
1225
|
+
* @see connectWalletOption
|
|
1226
|
+
* @see getWalletOptionsCatalogue
|
|
1227
|
+
*/
|
|
1228
|
+
var AmbiguousWalletChainError = class extends require_logoutWithReason.BaseError {
|
|
1229
|
+
constructor({ chains, walletKey }) {
|
|
1230
|
+
super({
|
|
1231
|
+
cause: null,
|
|
1232
|
+
code: "ambiguous_wallet_chain",
|
|
1233
|
+
docsUrl: null,
|
|
1234
|
+
metaMessages: [
|
|
1235
|
+
`Wallet key: ${walletKey}`,
|
|
1236
|
+
`Available chains: ${chains.join(", ")}`,
|
|
1237
|
+
"Pass the chain param to pick which one to connect on."
|
|
1238
|
+
],
|
|
1239
|
+
name: "AmbiguousWalletChainError",
|
|
1240
|
+
shortMessage: `Wallet ${walletKey} can be connected on more than one chain, so the chain param is required.`
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1207
1245
|
//#endregion
|
|
1208
1246
|
//#region src/errors/CheckoutSessionTokenMissingError.ts
|
|
1209
1247
|
var CheckoutSessionTokenMissingError = class extends require_logoutWithReason.BaseError {
|
|
@@ -1362,6 +1400,48 @@ var CoinbaseTravelRuleRequiredError = class extends require_logoutWithReason.Bas
|
|
|
1362
1400
|
}
|
|
1363
1401
|
};
|
|
1364
1402
|
|
|
1403
|
+
//#endregion
|
|
1404
|
+
//#region src/errors/ConnectionUriHandlerMissingError.ts
|
|
1405
|
+
/**
|
|
1406
|
+
* Thrown when the only connection path for a wallet is a URI pairing and no
|
|
1407
|
+
* `onConnectionUri` handler was passed to `connectWalletOption`.
|
|
1408
|
+
*
|
|
1409
|
+
* The pairing URI has to reach the user — as a QR code on desktop, or by opening
|
|
1410
|
+
* the wallet's deeplink on mobile — for the wallet to be able to
|
|
1411
|
+
* approve the connection.
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```ts
|
|
1415
|
+
* // Throws, since the wallet can only be reached through a URI pairing
|
|
1416
|
+
* await connectWalletOption({ walletKey: 'trust' });
|
|
1417
|
+
*
|
|
1418
|
+
* // Connects, once the user approves the pairing
|
|
1419
|
+
* await connectWalletOption({
|
|
1420
|
+
* onConnectionUri: ({ uri }) => renderQrCode(uri),
|
|
1421
|
+
* walletKey: 'trust',
|
|
1422
|
+
* });
|
|
1423
|
+
* ```
|
|
1424
|
+
* @see connectWalletOption
|
|
1425
|
+
* @see ConnectionUriHandlerParams
|
|
1426
|
+
*/
|
|
1427
|
+
var ConnectionUriHandlerMissingError = class extends require_logoutWithReason.BaseError {
|
|
1428
|
+
constructor({ chain, type, walletKey }) {
|
|
1429
|
+
super({
|
|
1430
|
+
cause: null,
|
|
1431
|
+
code: "connection_uri_handler_missing",
|
|
1432
|
+
docsUrl: null,
|
|
1433
|
+
metaMessages: [
|
|
1434
|
+
`Wallet key: ${walletKey}`,
|
|
1435
|
+
`Chain: ${chain}`,
|
|
1436
|
+
`URI connection type: ${type}`,
|
|
1437
|
+
"Pass onConnectionUri to render the pairing URI it hands you as a QR code, or to open it as a link on mobile."
|
|
1438
|
+
],
|
|
1439
|
+
name: "ConnectionUriHandlerMissingError",
|
|
1440
|
+
shortMessage: `Connecting to ${walletKey} requires a URI pairing, so the onConnectionUri param is required.`
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1365
1445
|
//#endregion
|
|
1366
1446
|
//#region src/errors/DeeplinkConnectAndVerifyUnsupportedError.ts
|
|
1367
1447
|
var DeeplinkConnectAndVerifyUnsupportedError = class extends require_logoutWithReason.BaseError {
|
|
@@ -1603,6 +1683,54 @@ var NoAddressFoundError = class extends require_logoutWithReason.BaseError {
|
|
|
1603
1683
|
}
|
|
1604
1684
|
};
|
|
1605
1685
|
|
|
1686
|
+
//#endregion
|
|
1687
|
+
//#region src/errors/NoConnectionOptionAvailableError.ts
|
|
1688
|
+
/**
|
|
1689
|
+
* Thrown when a wallet exists in the catalogue but has no connection option
|
|
1690
|
+
* this client can drive.
|
|
1691
|
+
*
|
|
1692
|
+
* Happens when the wallet is not installed on the device and no URI pairing is
|
|
1693
|
+
* available for it — either the wallet does not support one, or the chain
|
|
1694
|
+
* extension providing that pairing was not added to the client.
|
|
1695
|
+
*
|
|
1696
|
+
* @example
|
|
1697
|
+
* ```ts
|
|
1698
|
+
* try {
|
|
1699
|
+
* await connectWalletOption({ walletKey: 'rainbow' });
|
|
1700
|
+
* } catch (error) {
|
|
1701
|
+
* if (error instanceof NoConnectionOptionAvailableError) {
|
|
1702
|
+
* promptWalletInstall(error.installationUrls);
|
|
1703
|
+
* }
|
|
1704
|
+
* }
|
|
1705
|
+
* ```
|
|
1706
|
+
* @see connectWalletOption
|
|
1707
|
+
* @see getWalletOptionsCatalogue
|
|
1708
|
+
*/
|
|
1709
|
+
var NoConnectionOptionAvailableError = class extends require_logoutWithReason.BaseError {
|
|
1710
|
+
/**
|
|
1711
|
+
* Install / download links for the wallet, when the wallet book carries any
|
|
1712
|
+
* for this device. Prompt the user to install the wallet with these.
|
|
1713
|
+
*/
|
|
1714
|
+
installationUrls;
|
|
1715
|
+
constructor({ chain, installationUrls, walletKey }) {
|
|
1716
|
+
super({
|
|
1717
|
+
cause: null,
|
|
1718
|
+
code: "no_connection_option_available",
|
|
1719
|
+
docsUrl: null,
|
|
1720
|
+
metaMessages: [
|
|
1721
|
+
`Wallet key: ${walletKey}`,
|
|
1722
|
+
...chain ? [`Chain: ${chain}`] : [],
|
|
1723
|
+
"The wallet is not installed and no URI pairing is available for it on this client.",
|
|
1724
|
+
"URI pairing requires the chain extension that provides it — addWalletConnect<Chain>Extension for WalletConnect, addMetaMask<Chain>Extension for MetaMask.",
|
|
1725
|
+
"Use this error's installationUrls to prompt the user to install the wallet."
|
|
1726
|
+
],
|
|
1727
|
+
name: "NoConnectionOptionAvailableError",
|
|
1728
|
+
shortMessage: `No connection option available for wallet: ${walletKey}`
|
|
1729
|
+
});
|
|
1730
|
+
this.installationUrls = installationUrls;
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1606
1734
|
//#endregion
|
|
1607
1735
|
//#region src/errors/NoPasskeyCredentialsFoundError.ts
|
|
1608
1736
|
var NoPasskeyCredentialsFoundError = class extends require_logoutWithReason.BaseError {
|
|
@@ -1797,6 +1925,93 @@ var WalletAccountNotSelectedError = class extends require_logoutWithReason.BaseE
|
|
|
1797
1925
|
}
|
|
1798
1926
|
};
|
|
1799
1927
|
|
|
1928
|
+
//#endregion
|
|
1929
|
+
//#region src/errors/WalletBrowserRedirectHandlerMissingError.ts
|
|
1930
|
+
/**
|
|
1931
|
+
* Thrown when the connection option resolved for a wallet is its in-app
|
|
1932
|
+
* browser, no `handleWalletBrowserRedirect` handler was passed to
|
|
1933
|
+
* `connectWalletOption`, and there is no current page URL to redirect into
|
|
1934
|
+
* that browser — as on React Native and during server-side rendering.
|
|
1935
|
+
*
|
|
1936
|
+
* That path connects by reloading your app inside the wallet's own browser,
|
|
1937
|
+
* so it needs the URL of the page to reload.
|
|
1938
|
+
*
|
|
1939
|
+
* @example
|
|
1940
|
+
* ```ts
|
|
1941
|
+
* // Throws on React Native, where there is no page URL to reuse
|
|
1942
|
+
* await connectWalletOption({ walletKey: 'coinbase' });
|
|
1943
|
+
*
|
|
1944
|
+
* // Connects, redirecting into the wallet's browser
|
|
1945
|
+
* await connectWalletOption({
|
|
1946
|
+
* handleWalletBrowserRedirect: ({ chain, walletKey }) =>
|
|
1947
|
+
* redirectToInAppBrowser({
|
|
1948
|
+
* appUrl: 'https://mydapp.xyz/login',
|
|
1949
|
+
* chain,
|
|
1950
|
+
* walletKey,
|
|
1951
|
+
* }),
|
|
1952
|
+
* walletKey: 'coinbase',
|
|
1953
|
+
* });
|
|
1954
|
+
* ```
|
|
1955
|
+
* @see connectWalletOption
|
|
1956
|
+
* @see redirectToInAppBrowser
|
|
1957
|
+
*/
|
|
1958
|
+
var WalletBrowserRedirectHandlerMissingError = class extends require_logoutWithReason.BaseError {
|
|
1959
|
+
constructor({ chain, walletKey }) {
|
|
1960
|
+
super({
|
|
1961
|
+
cause: null,
|
|
1962
|
+
code: "wallet_browser_redirect_handler_missing",
|
|
1963
|
+
docsUrl: null,
|
|
1964
|
+
metaMessages: [
|
|
1965
|
+
`Wallet key: ${walletKey}`,
|
|
1966
|
+
`Chain: ${chain}`,
|
|
1967
|
+
"Pass handleWalletBrowserRedirect and call redirectToInAppBrowser from it with the URL of the page to reload inside the wallet's browser."
|
|
1968
|
+
],
|
|
1969
|
+
name: "WalletBrowserRedirectHandlerMissingError",
|
|
1970
|
+
shortMessage: `Connecting to ${walletKey} requires opening its in-app browser, so the handleWalletBrowserRedirect param is required where there is no page URL to redirect.`
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
};
|
|
1974
|
+
|
|
1975
|
+
//#endregion
|
|
1976
|
+
//#region src/errors/WalletOptionNotFoundError.ts
|
|
1977
|
+
/**
|
|
1978
|
+
* Thrown when `connectWalletOption` is given a wallet key that no wallet option in
|
|
1979
|
+
* the catalogue matches.
|
|
1980
|
+
*
|
|
1981
|
+
* A wallet is only surfaced for the chains this client has an extension for, so
|
|
1982
|
+
* this also covers keys that are valid in the wallet book but not reachable
|
|
1983
|
+
* with the client's current chain extensions.
|
|
1984
|
+
*
|
|
1985
|
+
* @example
|
|
1986
|
+
* ```ts
|
|
1987
|
+
* try {
|
|
1988
|
+
* await connectWalletOption({ walletKey: 'metmask' });
|
|
1989
|
+
* } catch (error) {
|
|
1990
|
+
* if (error instanceof WalletOptionNotFoundError) {
|
|
1991
|
+
* showUnknownWalletMessage();
|
|
1992
|
+
* }
|
|
1993
|
+
* }
|
|
1994
|
+
* ```
|
|
1995
|
+
* @see connectWalletOption
|
|
1996
|
+
* @see getWalletOptionsCatalogue
|
|
1997
|
+
*/
|
|
1998
|
+
var WalletOptionNotFoundError = class extends require_logoutWithReason.BaseError {
|
|
1999
|
+
constructor({ walletKey }) {
|
|
2000
|
+
super({
|
|
2001
|
+
cause: null,
|
|
2002
|
+
code: "wallet_option_not_found",
|
|
2003
|
+
docsUrl: null,
|
|
2004
|
+
metaMessages: [
|
|
2005
|
+
`Wallet key: ${walletKey}`,
|
|
2006
|
+
"The key must match a wallet option surfaced by getWalletOptionsCatalogue (e.g. \"metamask\", \"phantom\").",
|
|
2007
|
+
"A wallet is only surfaced on chains this client has an extension for, so make sure the relevant chain extension is added."
|
|
2008
|
+
],
|
|
2009
|
+
name: "WalletOptionNotFoundError",
|
|
2010
|
+
shortMessage: `No wallet option found for key: ${walletKey}`
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
|
|
1800
2015
|
//#endregion
|
|
1801
2016
|
//#region src/errors/WalletProviderMethodUnavailableError.ts
|
|
1802
2017
|
var WalletProviderMethodUnavailableError = class extends require_logoutWithReason.BaseError {
|
|
@@ -2522,6 +2737,10 @@ const __authenticateWithSocial_wrapped = require_logoutWithReason.instrumentFunc
|
|
|
2522
2737
|
* browser. Calling it during server-side rendering (no `window`) throws
|
|
2523
2738
|
* `UnavailableInServerSideError`.
|
|
2524
2739
|
*
|
|
2740
|
+
* @param [params.expectedState] - When given, the parameters are only removed
|
|
2741
|
+
* while the current URL still carries this `dynamicOauthState`. Use it to
|
|
2742
|
+
* clean up after a specific callback without touching a newer one that has
|
|
2743
|
+
* meanwhile landed in the address bar.
|
|
2525
2744
|
* @returns Nothing. The current URL is rewritten in place via
|
|
2526
2745
|
* `window.history.replaceState`.
|
|
2527
2746
|
*
|
|
@@ -2541,9 +2760,12 @@ const __authenticateWithSocial_wrapped = require_logoutWithReason.instrumentFunc
|
|
|
2541
2760
|
*
|
|
2542
2761
|
* @notInstrumented
|
|
2543
2762
|
*/
|
|
2544
|
-
const clearSocialRedirectParams = () => {
|
|
2763
|
+
const clearSocialRedirectParams = ({ expectedState } = {}) => {
|
|
2545
2764
|
if (require_getNetworkProviderFromNetworkId.isServerSideRendering()) throw new require_getNetworkProviderFromNetworkId.UnavailableInServerSideError("clearSocialRedirectParams");
|
|
2546
|
-
|
|
2765
|
+
const currentHref = window.location.href;
|
|
2766
|
+
const currentState = new URL(currentHref).searchParams.get("dynamicOauthState");
|
|
2767
|
+
if (expectedState !== void 0 && currentState !== expectedState) return;
|
|
2768
|
+
window.history.replaceState({}, "", removeDynamicOauthParamsFromUrl(currentHref));
|
|
2547
2769
|
};
|
|
2548
2770
|
|
|
2549
2771
|
//#endregion
|
|
@@ -2627,6 +2849,14 @@ const __processSocialCallback_wrapped = require_logoutWithReason.instrumentFunct
|
|
|
2627
2849
|
* authenticating (or linking) the user with the social provider. This is the
|
|
2628
2850
|
* final step after `signInWithSocialRedirect` + `detectSocialRedirectUrl`.
|
|
2629
2851
|
*
|
|
2852
|
+
* A callback URL whose stored redirect state is missing or does not match can
|
|
2853
|
+
* never complete, so its OAuth parameters are stripped from the browser URL
|
|
2854
|
+
* before the error is rethrown. Callers that decide whether to complete a
|
|
2855
|
+
* redirect by inspecting the URL therefore see the failure once instead of
|
|
2856
|
+
* retrying the same doomed callback on every render. The clean-up is scoped to
|
|
2857
|
+
* the state of the callback it failed on, so a newer callback sitting in the
|
|
2858
|
+
* address bar is left alone.
|
|
2859
|
+
*
|
|
2630
2860
|
* @example
|
|
2631
2861
|
* ```ts
|
|
2632
2862
|
* const redirectUrl = detectSocialRedirectUrl();
|
|
@@ -2640,16 +2870,30 @@ const __processSocialCallback_wrapped = require_logoutWithReason.instrumentFunct
|
|
|
2640
2870
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2641
2871
|
* @returns A promise that resolves to the authenticated user or null.
|
|
2642
2872
|
* @throws MissingSocialUrlParamError If required OAuth parameters are missing.
|
|
2873
|
+
* @throws MissingRedirectStorageStateError If no stored redirect state exists.
|
|
2643
2874
|
* @throws InvalidRedirectStorageStateError If the stored state doesn't match.
|
|
2644
2875
|
* @see signInWithSocialRedirect
|
|
2645
2876
|
* @see detectSocialRedirectUrl
|
|
2646
2877
|
* @see clearSocialRedirectParams
|
|
2647
2878
|
* @instrumented
|
|
2648
2879
|
*/
|
|
2649
|
-
const completeSocialRedirect = ({ url, requestedScopes }, client = require_logoutWithReason.getDefaultClient()) =>
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2880
|
+
const completeSocialRedirect = async ({ url, requestedScopes }, client = require_logoutWithReason.getDefaultClient()) => {
|
|
2881
|
+
try {
|
|
2882
|
+
return await __processSocialCallback_wrapped({
|
|
2883
|
+
requestedScopes,
|
|
2884
|
+
url
|
|
2885
|
+
}, client);
|
|
2886
|
+
} catch (error) {
|
|
2887
|
+
const hasUnusableRedirectState = error instanceof MissingRedirectStorageStateError || error instanceof InvalidRedirectStorageStateError;
|
|
2888
|
+
const failedState = url.searchParams.get("dynamicOauthState");
|
|
2889
|
+
if (hasUnusableRedirectState && failedState !== null) try {
|
|
2890
|
+
clearSocialRedirectParams({ expectedState: failedState });
|
|
2891
|
+
} catch (clearError) {
|
|
2892
|
+
require_logoutWithReason.getCore(client).logger.debug("[completeSocialRedirect] failed to clear the social redirect params", clearError);
|
|
2893
|
+
}
|
|
2894
|
+
throw error;
|
|
2895
|
+
}
|
|
2896
|
+
};
|
|
2653
2897
|
const __completeSocialRedirect_impl = completeSocialRedirect;
|
|
2654
2898
|
const __completeSocialRedirect_wrapped = require_logoutWithReason.instrumentFunction({
|
|
2655
2899
|
fn: __completeSocialRedirect_impl,
|
|
@@ -7242,20 +7486,46 @@ const hasAllGoogleDriveBackupScopes = (grantedScopes) => findMissingGoogleDriveB
|
|
|
7242
7486
|
const isInsufficientGoogleDriveScopesError = (err) => err instanceof Error && err.message.includes(ACCESS_DENIED_PHRASE);
|
|
7243
7487
|
|
|
7244
7488
|
//#endregion
|
|
7245
|
-
//#region src/utils/
|
|
7489
|
+
//#region src/utils/isAndroid/isAndroid.ts
|
|
7490
|
+
/**
|
|
7491
|
+
* Tells whether the SDK is running on Android.
|
|
7492
|
+
*
|
|
7493
|
+
* The operating system comes from {@link getOperatingSystem}, which reads
|
|
7494
|
+
* `Platform.OS` in React Native and the user agent on web.
|
|
7495
|
+
*
|
|
7496
|
+
* @example
|
|
7497
|
+
* ```ts
|
|
7498
|
+
* if (isAndroid()) {
|
|
7499
|
+
* return installationUrls.android;
|
|
7500
|
+
* }
|
|
7501
|
+
* ```
|
|
7502
|
+
*
|
|
7503
|
+
* @returns `true` when the current device runs Android.
|
|
7504
|
+
* @see getOperatingSystem
|
|
7505
|
+
* @see isIOS
|
|
7506
|
+
* @notInstrumented
|
|
7507
|
+
*/
|
|
7508
|
+
const isAndroid = () => require_logoutWithReason.getOperatingSystem() === "android";
|
|
7509
|
+
|
|
7510
|
+
//#endregion
|
|
7511
|
+
//#region src/utils/userAgentChecks/userAgentChecks.ts
|
|
7246
7512
|
/**
|
|
7247
7513
|
* Sourced from http://detectmobilebrowsers.com/
|
|
7514
|
+
*
|
|
7515
|
+
* iOS devices are matched by {@link isIOSUserAgent} instead of a bare `ios`
|
|
7516
|
+
* alternative, which would also match unrelated words such as `kiosk`.
|
|
7248
7517
|
* @notInstrumented
|
|
7249
7518
|
*/
|
|
7250
|
-
const userAgentRegex1 = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|
|
|
7519
|
+
const userAgentRegex1 = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i;
|
|
7251
7520
|
const userAgentRegex2 = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i;
|
|
7252
|
-
/**
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7521
|
+
/**
|
|
7522
|
+
* Matches the device names Apple's handhelds report, plus the standalone `ios`
|
|
7523
|
+
* token that embedded web views and custom in-app browsers use in place of a
|
|
7524
|
+
* device name. The token must stand alone so that unrelated words containing
|
|
7525
|
+
* `ios` (`kiosk`, for instance) don't match.
|
|
7526
|
+
* @notInstrumented
|
|
7527
|
+
*/
|
|
7528
|
+
const isIOSUserAgent = () => typeof window === "undefined" || typeof navigator === "undefined" ? false : /iPhone|iPod|(?:^|[^a-z])ios(?:[^a-z]|$)/i.test(navigator.userAgent);
|
|
7259
7529
|
/**
|
|
7260
7530
|
* @param [optional] maxTouchPointsOverride - this is used for testing since
|
|
7261
7531
|
* it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
|
|
@@ -7268,13 +7538,11 @@ const isIPad = (maxTouchPointsOverride) => {
|
|
|
7268
7538
|
return /iPad/.test(navigator.userAgent) || /Mac/.test(navigator.userAgent) && maxTouchPoints === 5;
|
|
7269
7539
|
};
|
|
7270
7540
|
/** @notInstrumented */
|
|
7271
|
-
const
|
|
7541
|
+
const isMobileUserAgent = (maxTouchPointsOverride) => {
|
|
7272
7542
|
if (typeof window === "undefined" || typeof navigator === "undefined") return false;
|
|
7273
|
-
return
|
|
7543
|
+
return userAgentRegex1.test(navigator.userAgent) || userAgentRegex2.test(navigator.userAgent.substring(0, 4)) || isIPad(maxTouchPointsOverride) || isIOSUserAgent();
|
|
7274
7544
|
};
|
|
7275
7545
|
/** @notInstrumented */
|
|
7276
|
-
const isAndroid = () => isMobile() && !isIOS();
|
|
7277
|
-
/** @notInstrumented */
|
|
7278
7546
|
const isSafariBrowser = () => {
|
|
7279
7547
|
if (typeof window === "undefined" || typeof navigator === "undefined") return false;
|
|
7280
7548
|
const { userAgent } = navigator;
|
|
@@ -7301,6 +7569,31 @@ const isChromeBrowser = () => {
|
|
|
7301
7569
|
return /\bChrome\//.test(navigator.userAgent) && !isEdgeBrowser() && !isOperaBrowser();
|
|
7302
7570
|
};
|
|
7303
7571
|
|
|
7572
|
+
//#endregion
|
|
7573
|
+
//#region src/utils/isIOS/isIOS.ts
|
|
7574
|
+
/**
|
|
7575
|
+
* Tells whether the SDK is running on iOS or iPadOS.
|
|
7576
|
+
*
|
|
7577
|
+
* The operating system comes from {@link getOperatingSystem}, which reads
|
|
7578
|
+
* `Platform.OS` in React Native and the user agent on web. Two user agents
|
|
7579
|
+
* escape it: an iPad in desktop mode announces itself as macOS, and embedded
|
|
7580
|
+
* web views may carry a lowercase `ios` token instead of a device name.
|
|
7581
|
+
*
|
|
7582
|
+
* @example
|
|
7583
|
+
* ```ts
|
|
7584
|
+
* if (isIOS()) {
|
|
7585
|
+
* return installationUrls.ios;
|
|
7586
|
+
* }
|
|
7587
|
+
* ```
|
|
7588
|
+
*
|
|
7589
|
+
* @returns `true` when the current device runs iOS or iPadOS.
|
|
7590
|
+
* @see getOperatingSystem
|
|
7591
|
+
* @see isIPad
|
|
7592
|
+
* @see isIOSUserAgent
|
|
7593
|
+
* @notInstrumented
|
|
7594
|
+
*/
|
|
7595
|
+
const isIOS = () => require_logoutWithReason.getOperatingSystem() === "ios" || isIOSUserAgent() || isIPad();
|
|
7596
|
+
|
|
7304
7597
|
//#endregion
|
|
7305
7598
|
//#region src/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/getInstallationLinkForCurrentPlatform.ts
|
|
7306
7599
|
/**
|
|
@@ -8447,6 +8740,29 @@ const __confirmTransaction_wrapped = require_logoutWithReason.instrumentFunction
|
|
|
8447
8740
|
}
|
|
8448
8741
|
});
|
|
8449
8742
|
|
|
8743
|
+
//#endregion
|
|
8744
|
+
//#region src/utils/isMobile/isMobile.ts
|
|
8745
|
+
/**
|
|
8746
|
+
* Tells whether the SDK is running on a mobile device.
|
|
8747
|
+
*
|
|
8748
|
+
* This is the web implementation, which sniffs the browser's user agent. It
|
|
8749
|
+
* lives on its own so the React Native bundler can resolve
|
|
8750
|
+
* `isMobile.native.ts` instead, which always reports `true`.
|
|
8751
|
+
*
|
|
8752
|
+
* @example
|
|
8753
|
+
* ```ts
|
|
8754
|
+
* if (isMobile()) {
|
|
8755
|
+
* // hand the pairing to the wallet app instead of rendering a QR code
|
|
8756
|
+
* }
|
|
8757
|
+
* ```
|
|
8758
|
+
*
|
|
8759
|
+
* @returns `true` when the user agent belongs to a mobile device.
|
|
8760
|
+
* @see isMobileUserAgent
|
|
8761
|
+
* @see getPlatform
|
|
8762
|
+
* @notInstrumented
|
|
8763
|
+
*/
|
|
8764
|
+
const isMobile = () => isMobileUserAgent();
|
|
8765
|
+
|
|
8450
8766
|
//#endregion
|
|
8451
8767
|
//#region src/modules/wallets/utils/getAddressesWithTypesFromConnectionResult/getAddressesWithTypesFromConnectionResult.ts
|
|
8452
8768
|
/** @notInstrumented */
|
|
@@ -8846,6 +9162,457 @@ const __connectAndVerifyWithWalletProvider_wrapped = require_logoutWithReason.in
|
|
|
8846
9162
|
}
|
|
8847
9163
|
});
|
|
8848
9164
|
|
|
9165
|
+
//#endregion
|
|
9166
|
+
//#region src/utils/appendConnectionUriToDeeplink/appendConnectionUriToDeeplink.ts
|
|
9167
|
+
/**
|
|
9168
|
+
* Appends a wallet connection URI to a deeplink URL.
|
|
9169
|
+
*
|
|
9170
|
+
* Generic across URI-deeplink connection options — works for both
|
|
9171
|
+
* WalletConnect pairing URIs and MetaMask SDK URIs. Determines the
|
|
9172
|
+
* appropriate query parameter separator based on whether the deeplink
|
|
9173
|
+
* already contains query parameters.
|
|
9174
|
+
*
|
|
9175
|
+
* @param params.deeplinkUrl - The base deeplink URL (e.g., `walletapp://wc` or `walletapp://wc?param=value`).
|
|
9176
|
+
* @param params.connectionUri - The connection URI to append.
|
|
9177
|
+
* @returns The deeplink URL with the connection URI appended as a query parameter.
|
|
9178
|
+
*
|
|
9179
|
+
* @example
|
|
9180
|
+
* ```ts
|
|
9181
|
+
* appendConnectionUriToDeeplink({ deeplinkUrl: 'walletapp://wc', connectionUri: 'wc:123-456' })
|
|
9182
|
+
* // Returns: 'walletapp://wc?uri=wc%3A123-456'
|
|
9183
|
+
*
|
|
9184
|
+
* appendConnectionUriToDeeplink({ deeplinkUrl: 'walletapp://wc?param=value', connectionUri: 'wc:123-456' })
|
|
9185
|
+
* // Returns: 'walletapp://wc?param=value&uri=wc%3A123-456'
|
|
9186
|
+
* ```
|
|
9187
|
+
* @notInstrumented
|
|
9188
|
+
*/
|
|
9189
|
+
const appendConnectionUriToDeeplink = ({ connectionUri, deeplinkUrl }) => {
|
|
9190
|
+
const url = new URL(deeplinkUrl);
|
|
9191
|
+
url.searchParams.set("uri", connectionUri);
|
|
9192
|
+
return url.href;
|
|
9193
|
+
};
|
|
9194
|
+
|
|
9195
|
+
//#endregion
|
|
9196
|
+
//#region src/utils/getPreferredWalletDeepLink/getPreferredWalletDeepLink.ts
|
|
9197
|
+
/**
|
|
9198
|
+
* Picks the most appropriate deep link variant for the current platform.
|
|
9199
|
+
*
|
|
9200
|
+
* Mobile (Android, iOS, tablets) prefers `native` because the OS treats
|
|
9201
|
+
* custom URL schemes as first-class app links and gives the wallet a faster
|
|
9202
|
+
* round-trip back to the dApp. Desktop prefers `universal` because browsers
|
|
9203
|
+
* cannot resolve mobile-only custom schemes and need an `https://` link
|
|
9204
|
+
* that opens the wallet's web flow.
|
|
9205
|
+
*
|
|
9206
|
+
* In either case, the alternative is used as a fallback when the preferred
|
|
9207
|
+
* variant is missing. Returns `undefined` only when both variants are
|
|
9208
|
+
* absent.
|
|
9209
|
+
*
|
|
9210
|
+
* @example
|
|
9211
|
+
* ```ts
|
|
9212
|
+
* const deepLink = getPreferredWalletDeepLink({
|
|
9213
|
+
* deeplinks: wallet.deeplinks,
|
|
9214
|
+
* });
|
|
9215
|
+
* ```
|
|
9216
|
+
*
|
|
9217
|
+
* @param params.deeplinks - The deep link variants for a wallet (typically `WalletConnectCatalogWallet.deeplinks`).
|
|
9218
|
+
* @returns The preferred deep link URL, or `undefined` if neither variant is available.
|
|
9219
|
+
* @see appendConnectionUriToDeeplink
|
|
9220
|
+
* @see getConnectionUriDeeplink
|
|
9221
|
+
* @notInstrumented
|
|
9222
|
+
*/
|
|
9223
|
+
const getPreferredWalletDeepLink = ({ deeplinks }) => {
|
|
9224
|
+
const { native, universal } = deeplinks;
|
|
9225
|
+
if (isMobile()) return native ?? universal;
|
|
9226
|
+
return universal ?? native;
|
|
9227
|
+
};
|
|
9228
|
+
|
|
9229
|
+
//#endregion
|
|
9230
|
+
//#region src/modules/wallets/connectWithUriConnectionOption/getConnectionUriDeeplink/getConnectionUriDeeplink.ts
|
|
9231
|
+
/**
|
|
9232
|
+
* Builds the single deeplink that hands a pairing URI to the wallet, picking
|
|
9233
|
+
* the shape the URI's protocol expects.
|
|
9234
|
+
*
|
|
9235
|
+
* A WalletConnect URI travels as the `uri` query parameter of the wallet's own
|
|
9236
|
+
* deeplink, whereas the MetaMask SDK mints a launch link that already targets
|
|
9237
|
+
* MetaMask, so it is handed over untouched.
|
|
9238
|
+
*
|
|
9239
|
+
* @example
|
|
9240
|
+
* ```ts
|
|
9241
|
+
* const deeplink = getConnectionUriDeeplink({
|
|
9242
|
+
* deeplinks: connectionOption.deeplinks,
|
|
9243
|
+
* type: connectionOption.type,
|
|
9244
|
+
* uri,
|
|
9245
|
+
* });
|
|
9246
|
+
* ```
|
|
9247
|
+
*
|
|
9248
|
+
* @param params.deeplinks - The wallet's deeplink variants, as carried by the wallet book.
|
|
9249
|
+
* @param params.type - The URI connection type that minted the URI.
|
|
9250
|
+
* @param params.uri - The pairing URI.
|
|
9251
|
+
* @returns The deeplink to open, or `undefined` when the wallet publishes no deeplink to carry the URI.
|
|
9252
|
+
* @see getPreferredWalletDeepLink
|
|
9253
|
+
* @see appendConnectionUriToDeeplink
|
|
9254
|
+
* @notInstrumented
|
|
9255
|
+
*/
|
|
9256
|
+
const getConnectionUriDeeplink = ({ deeplinks, type, uri }) => {
|
|
9257
|
+
if (type === "metamaskSdkUri") return uri;
|
|
9258
|
+
const deeplinkUrl = getPreferredWalletDeepLink({ deeplinks });
|
|
9259
|
+
if (!deeplinkUrl) return;
|
|
9260
|
+
return appendConnectionUriToDeeplink({
|
|
9261
|
+
connectionUri: uri,
|
|
9262
|
+
deeplinkUrl
|
|
9263
|
+
});
|
|
9264
|
+
};
|
|
9265
|
+
|
|
9266
|
+
//#endregion
|
|
9267
|
+
//#region src/modules/wallets/connectWithUriConnectionOption/connectWithUriConnectionOption.ts
|
|
9268
|
+
/**
|
|
9269
|
+
* Connects to a wallet through a URI pairing and returns the connected wallet
|
|
9270
|
+
* account.
|
|
9271
|
+
*
|
|
9272
|
+
* Mints the pairing URI with the starter the chain extension registered for
|
|
9273
|
+
* the option's chain and URI type, hands it to `onConnectionUri` as the
|
|
9274
|
+
* wallet's deeplink carrying the pairing so the customer can render a QR code
|
|
9275
|
+
* or open the wallet app, then waits for the user to approve the pairing on
|
|
9276
|
+
* the wallet side.
|
|
9277
|
+
*
|
|
9278
|
+
* The handler is awaited, so an async handler that fails to open the wallet
|
|
9279
|
+
* rejects the connection rather than letting the pairing resolve into an
|
|
9280
|
+
* account nobody asked for.
|
|
9281
|
+
*
|
|
9282
|
+
* @example
|
|
9283
|
+
* ```ts
|
|
9284
|
+
* const walletAccount = await connectWithUriConnectionOption(
|
|
9285
|
+
* {
|
|
9286
|
+
* addToDynamicWalletAccounts: true,
|
|
9287
|
+
* connectionOption,
|
|
9288
|
+
* onConnectionUri: ({ uri }) => renderQrCode(uri),
|
|
9289
|
+
* walletKey: 'trust',
|
|
9290
|
+
* },
|
|
9291
|
+
* client
|
|
9292
|
+
* );
|
|
9293
|
+
* ```
|
|
9294
|
+
*
|
|
9295
|
+
* @param params.addToDynamicWalletAccounts - Whether the connected wallet account should be added to the client's wallet accounts.
|
|
9296
|
+
* @param params.connectionOption - The URI deeplink connection option to drive.
|
|
9297
|
+
* @param params.onConnectionUri - Called with the pairing URI once it is minted. Awaited before the approval is waited on.
|
|
9298
|
+
* @param params.walletKey - The wallet being connected, keyed as in the wallet options catalogue.
|
|
9299
|
+
* @param client - The Dynamic client instance.
|
|
9300
|
+
* @returns A promise that resolves to the connected wallet account.
|
|
9301
|
+
* @throws ConnectionUriHandlerMissingError If no onConnectionUri handler was passed.
|
|
9302
|
+
* @throws NoConnectionOptionAvailableError If no URI connection starter is registered for the option's chain and type.
|
|
9303
|
+
* @throws NoAddressFoundError If the pairing was approved but no address was shared with your app.
|
|
9304
|
+
* @see getUriConnectionStarterRegistry
|
|
9305
|
+
* @see getWalletOptionsCatalogue
|
|
9306
|
+
* @notInstrumented
|
|
9307
|
+
*/
|
|
9308
|
+
const connectWithUriConnectionOption = async ({ addToDynamicWalletAccounts, connectionOption, onConnectionUri, walletKey }, client) => {
|
|
9309
|
+
const { chain, deeplinks, type } = connectionOption;
|
|
9310
|
+
if (!onConnectionUri) throw new ConnectionUriHandlerMissingError({
|
|
9311
|
+
chain,
|
|
9312
|
+
type,
|
|
9313
|
+
walletKey
|
|
9314
|
+
});
|
|
9315
|
+
const starter = require_getNetworkProviderFromNetworkId.getUriConnectionStarterRegistry(client).get({
|
|
9316
|
+
chain,
|
|
9317
|
+
type
|
|
9318
|
+
});
|
|
9319
|
+
if (!starter) throw new NoConnectionOptionAvailableError({
|
|
9320
|
+
chain,
|
|
9321
|
+
walletKey
|
|
9322
|
+
});
|
|
9323
|
+
const { approval, uri } = await starter.start({ addToDynamicWalletAccounts });
|
|
9324
|
+
const walletAccountsPromise = approval();
|
|
9325
|
+
walletAccountsPromise.catch(() => void 0);
|
|
9326
|
+
await onConnectionUri({ uri: getConnectionUriDeeplink({
|
|
9327
|
+
deeplinks,
|
|
9328
|
+
type,
|
|
9329
|
+
uri
|
|
9330
|
+
}) ?? uri });
|
|
9331
|
+
const { walletAccounts } = await walletAccountsPromise;
|
|
9332
|
+
const [walletAccount] = walletAccounts;
|
|
9333
|
+
if (!walletAccount) throw new NoAddressFoundError();
|
|
9334
|
+
return walletAccount;
|
|
9335
|
+
};
|
|
9336
|
+
|
|
9337
|
+
//#endregion
|
|
9338
|
+
//#region src/utils/buildInAppBrowserUrl/buildInAppBrowserUrl.ts
|
|
9339
|
+
/**
|
|
9340
|
+
* Placeholder the wallet book leaves in in-app-browser URLs for the app URL
|
|
9341
|
+
* the wallet should open.
|
|
9342
|
+
*/
|
|
9343
|
+
const DAPP_URL_PLACEHOLDER = "{{encodedDappURI}}";
|
|
9344
|
+
/**
|
|
9345
|
+
* Fills a wallet's in-app-browser URL template with the app URL to open.
|
|
9346
|
+
*
|
|
9347
|
+
* Wallet book entries carry the entry point as a template (e.g.
|
|
9348
|
+
* `https://go.base.app/dapp?cb_url={{encodedDappURI}}`), so the URL is only
|
|
9349
|
+
* usable once every occurrence of the placeholder is substituted in,
|
|
9350
|
+
* percent-encoded. Templates without the placeholder are returned untouched —
|
|
9351
|
+
* some wallets open a fixed landing page.
|
|
9352
|
+
*
|
|
9353
|
+
* @example
|
|
9354
|
+
* ```ts
|
|
9355
|
+
* buildInAppBrowserUrl({
|
|
9356
|
+
* appUrl: 'https://myapp.xyz/login',
|
|
9357
|
+
* inAppBrowserUrl: 'https://go.base.app/dapp?cb_url={{encodedDappURI}}',
|
|
9358
|
+
* });
|
|
9359
|
+
* // Returns: 'https://go.base.app/dapp?cb_url=https%3A%2F%2Fmyapp.xyz%2Flogin'
|
|
9360
|
+
* ```
|
|
9361
|
+
*
|
|
9362
|
+
* @param params.appUrl - The URL of your app for the wallet's browser to open.
|
|
9363
|
+
* @param params.inAppBrowserUrl - The wallet's in-app-browser URL template.
|
|
9364
|
+
* @returns The in-app-browser URL to open.
|
|
9365
|
+
* @see redirectToInAppBrowser
|
|
9366
|
+
* @see getWalletOptionsCatalogue
|
|
9367
|
+
* @notInstrumented
|
|
9368
|
+
*/
|
|
9369
|
+
const buildInAppBrowserUrl = ({ appUrl, inAppBrowserUrl }) => inAppBrowserUrl.replaceAll(DAPP_URL_PLACEHOLDER, encodeURIComponent(appUrl));
|
|
9370
|
+
|
|
9371
|
+
//#endregion
|
|
9372
|
+
//#region src/modules/wallets/redirectToInAppBrowser/redirectToInAppBrowser.ts
|
|
9373
|
+
/**
|
|
9374
|
+
* Leaves your app for a wallet's in-app browser, which reloads `appUrl`
|
|
9375
|
+
* inside it.
|
|
9376
|
+
*
|
|
9377
|
+
* Call this from `handleWalletBrowserRedirect` with the URL of the page the
|
|
9378
|
+
* wallet should reload. The wallet's in-app-browser entry point is read from
|
|
9379
|
+
* the wallet options catalogue, so you only need the wallet's key. The wallet
|
|
9380
|
+
* is only injected on that reload, so the connection is made on the next page
|
|
9381
|
+
* load rather than in the current one.
|
|
9382
|
+
*
|
|
9383
|
+
* @example
|
|
9384
|
+
* ```ts
|
|
9385
|
+
* await connectWalletOption({
|
|
9386
|
+
* handleWalletBrowserRedirect: ({ chain, walletKey }) =>
|
|
9387
|
+
* redirectToInAppBrowser({ appUrl: window.location.href, chain, walletKey }),
|
|
9388
|
+
* walletKey: 'coinbase',
|
|
9389
|
+
* });
|
|
9390
|
+
* ```
|
|
9391
|
+
*
|
|
9392
|
+
* @param params.appUrl - The URL of your app for the wallet's browser to open.
|
|
9393
|
+
* @param params.walletKey - The wallet to open, keyed as in the wallet options catalogue.
|
|
9394
|
+
* @param [params.chain] - The chain to open the wallet's browser for. Required only when the wallet exposes an in-app browser on more than one enabled chain.
|
|
9395
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
9396
|
+
* @returns A promise that resolves once the redirect is triggered.
|
|
9397
|
+
* @throws WalletOptionNotFoundError If no wallet option matches the key.
|
|
9398
|
+
* @throws NoConnectionOptionAvailableError If the wallet exposes no in-app browser on the requested chain.
|
|
9399
|
+
* @throws AmbiguousWalletChainError If the wallet exposes an in-app browser on more than one chain and no chain was passed.
|
|
9400
|
+
* @throws UnsafeDeeplinkUrlError If the wallet's in-app-browser URL has a scheme that can execute script.
|
|
9401
|
+
* @see connectWalletOption
|
|
9402
|
+
* @see WalletBrowserRedirectHandlerParams
|
|
9403
|
+
* @instrumented
|
|
9404
|
+
*/
|
|
9405
|
+
const redirectToInAppBrowser = async ({ appUrl, chain, walletKey }, client = require_logoutWithReason.getDefaultClient()) => {
|
|
9406
|
+
const walletOption = (await getWalletOptionsCatalogue({ includeMobileOptions: true }, client)).find(({ key }) => key === walletKey);
|
|
9407
|
+
if (!walletOption) throw new WalletOptionNotFoundError({ walletKey });
|
|
9408
|
+
const inAppBrowserOptions = walletOption.connectionOptions.filter((option) => option.type === "inAppBrowser" && (!chain || option.chain === chain));
|
|
9409
|
+
if (inAppBrowserOptions.length === 0) throw new NoConnectionOptionAvailableError({
|
|
9410
|
+
chain,
|
|
9411
|
+
installationUrls: walletOption.installationUrls,
|
|
9412
|
+
walletKey
|
|
9413
|
+
});
|
|
9414
|
+
const availableChains = [...new Set(inAppBrowserOptions.map((option) => option.chain))];
|
|
9415
|
+
if (!chain && availableChains.length > 1) throw new AmbiguousWalletChainError({
|
|
9416
|
+
chains: availableChains,
|
|
9417
|
+
walletKey
|
|
9418
|
+
});
|
|
9419
|
+
const [inAppBrowserOption] = inAppBrowserOptions;
|
|
9420
|
+
const urlToOpen = buildInAppBrowserUrl({
|
|
9421
|
+
appUrl,
|
|
9422
|
+
inAppBrowserUrl: inAppBrowserOption.url
|
|
9423
|
+
});
|
|
9424
|
+
require_getNetworkProviderFromNetworkId.assertSafeDeeplinkUrl(urlToOpen);
|
|
9425
|
+
await require_logoutWithReason.getCore(client).openDeeplink(urlToOpen);
|
|
9426
|
+
};
|
|
9427
|
+
const __redirectToInAppBrowser_impl = redirectToInAppBrowser;
|
|
9428
|
+
const __redirectToInAppBrowser_wrapped = require_logoutWithReason.instrumentFunction({
|
|
9429
|
+
fn: __redirectToInAppBrowser_impl,
|
|
9430
|
+
functionName: "redirectToInAppBrowser",
|
|
9431
|
+
getCore: () => {
|
|
9432
|
+
try {
|
|
9433
|
+
return require_logoutWithReason.getCore(require_logoutWithReason.getDefaultClient());
|
|
9434
|
+
} catch {
|
|
9435
|
+
return;
|
|
9436
|
+
}
|
|
9437
|
+
}
|
|
9438
|
+
});
|
|
9439
|
+
|
|
9440
|
+
//#endregion
|
|
9441
|
+
//#region src/modules/wallets/resolveWalletConnectionOption/resolveWalletConnectionOption.ts
|
|
9442
|
+
/**
|
|
9443
|
+
* Picks the connection option `connectWalletOption` should drive for a wallet.
|
|
9444
|
+
*
|
|
9445
|
+
* Reads the wallet options catalogue, keeps the options this client can
|
|
9446
|
+
* actually drive — a registered wallet provider, an in-app-browser entry, or
|
|
9447
|
+
* a URI pairing whose starter a chain extension has registered — and returns
|
|
9448
|
+
* the best one by the catalogue's ordering.
|
|
9449
|
+
*
|
|
9450
|
+
* @example
|
|
9451
|
+
* ```ts
|
|
9452
|
+
* const connectionOption = await resolveWalletConnectionOption(
|
|
9453
|
+
* { walletKey: 'metamask' },
|
|
9454
|
+
* client
|
|
9455
|
+
* );
|
|
9456
|
+
* ```
|
|
9457
|
+
*
|
|
9458
|
+
* @param params.walletKey - The wallet to connect, keyed as in the wallet options catalogue.
|
|
9459
|
+
* @param [params.chain] - The chain to connect on. Required only when the wallet resolves on more than one enabled chain.
|
|
9460
|
+
* @param client - The Dynamic client instance.
|
|
9461
|
+
* @returns A promise that resolves to the connection option to drive.
|
|
9462
|
+
* @throws WalletOptionNotFoundError If no wallet option matches the key.
|
|
9463
|
+
* @throws AmbiguousWalletChainError If the wallet resolves on more than one chain and no chain was passed.
|
|
9464
|
+
* @throws NoConnectionOptionAvailableError If the wallet has no connection option this client can drive on the requested chain.
|
|
9465
|
+
* @see connectWalletOption
|
|
9466
|
+
* @see getWalletOptionsCatalogue
|
|
9467
|
+
* @notInstrumented
|
|
9468
|
+
*/
|
|
9469
|
+
const resolveWalletConnectionOption = async ({ walletKey, chain }, client) => {
|
|
9470
|
+
const walletOption = (await getWalletOptionsCatalogue({ includeMobileOptions: true }, client)).find(({ key }) => key === walletKey);
|
|
9471
|
+
if (!walletOption) throw new WalletOptionNotFoundError({ walletKey });
|
|
9472
|
+
const uriConnectionStarterRegistry = require_getNetworkProviderFromNetworkId.getUriConnectionStarterRegistry(client);
|
|
9473
|
+
const availableOptions = walletOption.connectionOptions.filter((option) => !chain || option.chain === chain).filter((option) => {
|
|
9474
|
+
if (option.type !== "walletConnect" && option.type !== "metamaskSdkUri") return true;
|
|
9475
|
+
const starter = uriConnectionStarterRegistry.get({
|
|
9476
|
+
chain: option.chain,
|
|
9477
|
+
type: option.type
|
|
9478
|
+
});
|
|
9479
|
+
return Boolean(starter);
|
|
9480
|
+
});
|
|
9481
|
+
if (availableOptions.length === 0) throw new NoConnectionOptionAvailableError({
|
|
9482
|
+
chain,
|
|
9483
|
+
installationUrls: walletOption.installationUrls,
|
|
9484
|
+
walletKey
|
|
9485
|
+
});
|
|
9486
|
+
const availableChains = [...new Set(availableOptions.map((option) => option.chain))];
|
|
9487
|
+
if (!chain && availableChains.length > 1) throw new AmbiguousWalletChainError({
|
|
9488
|
+
chains: availableChains,
|
|
9489
|
+
walletKey
|
|
9490
|
+
});
|
|
9491
|
+
const [connectionOption] = availableOptions;
|
|
9492
|
+
return connectionOption;
|
|
9493
|
+
};
|
|
9494
|
+
|
|
9495
|
+
//#endregion
|
|
9496
|
+
//#region src/utils/getCurrentPageUrl/getCurrentPageUrl.ts
|
|
9497
|
+
/**
|
|
9498
|
+
* Returns the URL of the page the app is running in.
|
|
9499
|
+
*
|
|
9500
|
+
* @example
|
|
9501
|
+
* ```ts
|
|
9502
|
+
* const appUrl = getCurrentPageUrl() ?? 'https://mydapp.xyz';
|
|
9503
|
+
* ```
|
|
9504
|
+
*
|
|
9505
|
+
* @returns The current page URL, or null where there is no page to read it from, such as on React Native and during server-side rendering.
|
|
9506
|
+
* @see isServerSideRendering
|
|
9507
|
+
* @see redirectToInAppBrowser
|
|
9508
|
+
* @notInstrumented
|
|
9509
|
+
*/
|
|
9510
|
+
const getCurrentPageUrl = () => {
|
|
9511
|
+
if (typeof window === "undefined") return null;
|
|
9512
|
+
const href = window.location?.href;
|
|
9513
|
+
if (typeof href !== "string") return null;
|
|
9514
|
+
return href;
|
|
9515
|
+
};
|
|
9516
|
+
|
|
9517
|
+
//#endregion
|
|
9518
|
+
//#region src/highLevelFunctions/connectWalletOption/connectWalletOption.ts
|
|
9519
|
+
/**
|
|
9520
|
+
* Connects to an external wallet by its wallet options catalogue key and
|
|
9521
|
+
* returns the connected wallet account.
|
|
9522
|
+
*
|
|
9523
|
+
* Picks the connection path for the wallet so the customer does not have to:
|
|
9524
|
+
* a registered wallet provider when the user has the wallet installed,
|
|
9525
|
+
* otherwise a URI pairing (WalletConnect or the MetaMask SDK), with the
|
|
9526
|
+
* pairing URI handed to `onConnectionUri` while the returned promise waits for
|
|
9527
|
+
* the user to approve on the wallet side.
|
|
9528
|
+
*
|
|
9529
|
+
* Wallets that can only be reached through their own in-app browser — no
|
|
9530
|
+
* extension, no URI pairing — resolve to a redirect instead: the wallet and
|
|
9531
|
+
* chain are handed to `handleWalletBrowserRedirect`, which leaves for that
|
|
9532
|
+
* browser with `redirectToInAppBrowser`. Without that handler, the current
|
|
9533
|
+
* page is redirected into the wallet's browser directly, so the handler is
|
|
9534
|
+
* only needed to pick a different page to come back to, or where there is no
|
|
9535
|
+
* page URL to reuse (React Native, server-side rendering). The returned
|
|
9536
|
+
* promise never settles either way, since the connection completes on the
|
|
9537
|
+
* next page load inside the wallet's browser.
|
|
9538
|
+
*
|
|
9539
|
+
* Note: This function does not verify the wallet account — use
|
|
9540
|
+
* `verifyWalletAccount` afterwards to link it to the user.
|
|
9541
|
+
*
|
|
9542
|
+
* @example
|
|
9543
|
+
* ```ts
|
|
9544
|
+
* const walletAccount = await connectWalletOption({
|
|
9545
|
+
* handleWalletBrowserRedirect: ({ chain, walletKey }) =>
|
|
9546
|
+
* redirectToInAppBrowser({ appUrl: 'https://mydapp.xyz', chain, walletKey }),
|
|
9547
|
+
* onConnectionUri: ({ uri }) => renderQrCode(uri),
|
|
9548
|
+
* walletKey: 'metamask',
|
|
9549
|
+
* });
|
|
9550
|
+
* console.log(walletAccount.address);
|
|
9551
|
+
* ```
|
|
9552
|
+
*
|
|
9553
|
+
* @param params.walletKey - The wallet to connect, keyed as in the wallet options catalogue (e.g. 'metamask', 'phantom').
|
|
9554
|
+
* @param [params.chain] - The chain to connect on. Required only when the wallet resolves on more than one enabled chain.
|
|
9555
|
+
* @param [params.onConnectionUri] - Called with the pairing URI when the connection runs through a URI pairing.
|
|
9556
|
+
* @param [params.handleWalletBrowserRedirect] - Called with the wallet and chain when the wallet can only be connected through its own in-app browser. Defaults to redirecting the current page into that browser.
|
|
9557
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
9558
|
+
* @returns A promise that resolves to the connected wallet account, or that never settles on the in-app-browser path.
|
|
9559
|
+
* @throws WalletOptionNotFoundError If no wallet option matches the key.
|
|
9560
|
+
* @throws AmbiguousWalletChainError If the wallet resolves on more than one chain and no chain was passed.
|
|
9561
|
+
* @throws NoConnectionOptionAvailableError If the wallet has no connection option this client can drive on the requested chain.
|
|
9562
|
+
* @throws ConnectionUriHandlerMissingError If the wallet resolves to a URI pairing and no onConnectionUri handler was passed.
|
|
9563
|
+
* @throws WalletBrowserRedirectHandlerMissingError If the wallet resolves to its in-app browser, no handleWalletBrowserRedirect handler was passed, and there is no current page URL to redirect.
|
|
9564
|
+
* @throws UnsafeDeeplinkUrlError If the wallet's in-app-browser URL has a scheme that can execute script.
|
|
9565
|
+
* @see verifyWalletAccount
|
|
9566
|
+
* @see redirectToInAppBrowser
|
|
9567
|
+
* @see getWalletOptionsCatalogue
|
|
9568
|
+
* @instrumented
|
|
9569
|
+
*/
|
|
9570
|
+
const connectWalletOption = async ({ walletKey, chain, handleWalletBrowserRedirect, onConnectionUri }, client = require_logoutWithReason.getDefaultClient()) => {
|
|
9571
|
+
const connectionOption = await resolveWalletConnectionOption({
|
|
9572
|
+
chain,
|
|
9573
|
+
walletKey
|
|
9574
|
+
}, client);
|
|
9575
|
+
if (connectionOption.type === "withWalletProvider") return __connectWithWalletProvider_wrapped({ walletProviderKey: connectionOption.walletProviderKey }, client);
|
|
9576
|
+
if (connectionOption.type === "inAppBrowser") {
|
|
9577
|
+
const { chain: inAppBrowserChain } = connectionOption;
|
|
9578
|
+
if (handleWalletBrowserRedirect) handleWalletBrowserRedirect({
|
|
9579
|
+
chain: inAppBrowserChain,
|
|
9580
|
+
walletKey
|
|
9581
|
+
});
|
|
9582
|
+
else {
|
|
9583
|
+
const currentPageUrl = getCurrentPageUrl();
|
|
9584
|
+
if (!currentPageUrl) throw new WalletBrowserRedirectHandlerMissingError({
|
|
9585
|
+
chain: inAppBrowserChain,
|
|
9586
|
+
walletKey
|
|
9587
|
+
});
|
|
9588
|
+
await __redirectToInAppBrowser_wrapped({
|
|
9589
|
+
appUrl: currentPageUrl,
|
|
9590
|
+
chain: inAppBrowserChain,
|
|
9591
|
+
walletKey
|
|
9592
|
+
}, client);
|
|
9593
|
+
}
|
|
9594
|
+
return new Promise(() => void 0);
|
|
9595
|
+
}
|
|
9596
|
+
return connectWithUriConnectionOption({
|
|
9597
|
+
addToDynamicWalletAccounts: true,
|
|
9598
|
+
connectionOption,
|
|
9599
|
+
onConnectionUri,
|
|
9600
|
+
walletKey
|
|
9601
|
+
}, client);
|
|
9602
|
+
};
|
|
9603
|
+
const __connectWalletOption_impl = connectWalletOption;
|
|
9604
|
+
const __connectWalletOption_wrapped = require_logoutWithReason.instrumentFunction({
|
|
9605
|
+
fn: __connectWalletOption_impl,
|
|
9606
|
+
functionName: "connectWalletOption",
|
|
9607
|
+
getCore: () => {
|
|
9608
|
+
try {
|
|
9609
|
+
return require_logoutWithReason.getCore(require_logoutWithReason.getDefaultClient());
|
|
9610
|
+
} catch {
|
|
9611
|
+
return;
|
|
9612
|
+
}
|
|
9613
|
+
}
|
|
9614
|
+
});
|
|
9615
|
+
|
|
8849
9616
|
//#endregion
|
|
8850
9617
|
//#region src/modules/wallets/getAvailableWalletProvidersData/getAvailableWalletProvidersData.ts
|
|
8851
9618
|
/**
|
|
@@ -10044,36 +10811,6 @@ const __withdrawFromYieldVault_wrapped = require_logoutWithReason.instrumentFunc
|
|
|
10044
10811
|
}
|
|
10045
10812
|
});
|
|
10046
10813
|
|
|
10047
|
-
//#endregion
|
|
10048
|
-
//#region src/utils/appendConnectionUriToDeeplink/appendConnectionUriToDeeplink.ts
|
|
10049
|
-
/**
|
|
10050
|
-
* Appends a wallet connection URI to a deeplink URL.
|
|
10051
|
-
*
|
|
10052
|
-
* Generic across URI-deeplink connection options — works for both
|
|
10053
|
-
* WalletConnect pairing URIs and MetaMask SDK URIs. Determines the
|
|
10054
|
-
* appropriate query parameter separator based on whether the deeplink
|
|
10055
|
-
* already contains query parameters.
|
|
10056
|
-
*
|
|
10057
|
-
* @param params.deeplinkUrl - The base deeplink URL (e.g., `walletapp://wc` or `walletapp://wc?param=value`).
|
|
10058
|
-
* @param params.connectionUri - The connection URI to append.
|
|
10059
|
-
* @returns The deeplink URL with the connection URI appended as a query parameter.
|
|
10060
|
-
*
|
|
10061
|
-
* @example
|
|
10062
|
-
* ```ts
|
|
10063
|
-
* appendConnectionUriToDeeplink({ deeplinkUrl: 'walletapp://wc', connectionUri: 'wc:123-456' })
|
|
10064
|
-
* // Returns: 'walletapp://wc?uri=wc%3A123-456'
|
|
10065
|
-
*
|
|
10066
|
-
* appendConnectionUriToDeeplink({ deeplinkUrl: 'walletapp://wc?param=value', connectionUri: 'wc:123-456' })
|
|
10067
|
-
* // Returns: 'walletapp://wc?param=value&uri=wc%3A123-456'
|
|
10068
|
-
* ```
|
|
10069
|
-
* @notInstrumented
|
|
10070
|
-
*/
|
|
10071
|
-
const appendConnectionUriToDeeplink = ({ connectionUri, deeplinkUrl }) => {
|
|
10072
|
-
const url = new URL(deeplinkUrl);
|
|
10073
|
-
url.searchParams.set("uri", connectionUri);
|
|
10074
|
-
return url.href;
|
|
10075
|
-
};
|
|
10076
|
-
|
|
10077
10814
|
//#endregion
|
|
10078
10815
|
//#region src/utils/parseUserAgent/parseUserAgent.ts
|
|
10079
10816
|
const browserMatchers = [
|
|
@@ -10155,6 +10892,7 @@ const parseUserAgent = ({ userAgent }) => {
|
|
|
10155
10892
|
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_logoutWithReason.name, require_logoutWithReason.version);
|
|
10156
10893
|
|
|
10157
10894
|
//#endregion
|
|
10895
|
+
exports.AmbiguousWalletChainError = AmbiguousWalletChainError;
|
|
10158
10896
|
exports.BaseError = require_logoutWithReason.BaseError;
|
|
10159
10897
|
exports.COINBASE_TRAVEL_RULE_FIELD_DESCRIPTIONS = COINBASE_TRAVEL_RULE_FIELD_DESCRIPTIONS;
|
|
10160
10898
|
exports.CaptchaProviderEnum = CaptchaProviderEnum;
|
|
@@ -10166,6 +10904,7 @@ exports.CoinbaseTransferMfaFailedError = CoinbaseTransferMfaFailedError;
|
|
|
10166
10904
|
exports.CoinbaseTransferMfaRequiredError = CoinbaseTransferMfaRequiredError;
|
|
10167
10905
|
exports.CoinbaseTravelRuleFieldName = CoinbaseTravelRuleFieldName;
|
|
10168
10906
|
exports.CoinbaseTravelRuleRequiredError = CoinbaseTravelRuleRequiredError;
|
|
10907
|
+
exports.ConnectionUriHandlerMissingError = ConnectionUriHandlerMissingError;
|
|
10169
10908
|
exports.DeeplinkConnectAndVerifyUnsupportedError = DeeplinkConnectAndVerifyUnsupportedError;
|
|
10170
10909
|
exports.DeviceRegistrationIdentityMismatchError = DeviceRegistrationIdentityMismatchError;
|
|
10171
10910
|
exports.FeeEstimationFailedError = FeeEstimationFailedError;
|
|
@@ -10189,6 +10928,7 @@ exports.NetworkAddingUnavailableError = NetworkAddingUnavailableError;
|
|
|
10189
10928
|
exports.NetworkNotAddedError = NetworkNotAddedError;
|
|
10190
10929
|
exports.NetworkSwitchingUnavailableError = NetworkSwitchingUnavailableError;
|
|
10191
10930
|
exports.NoAddressFoundError = NoAddressFoundError;
|
|
10931
|
+
exports.NoConnectionOptionAvailableError = NoConnectionOptionAvailableError;
|
|
10192
10932
|
exports.NoNetworkProvidersError = require_getNetworkProviderFromNetworkId.NoNetworkProvidersError;
|
|
10193
10933
|
exports.NoPasskeyCredentialsFoundError = NoPasskeyCredentialsFoundError;
|
|
10194
10934
|
exports.NoSmartWalletAccountSignerFoundError = NoSmartWalletAccountSignerFoundError;
|
|
@@ -10214,6 +10954,8 @@ exports.WaasRbacStaleRetryUnsafeError = require_isUserOnboardingComplete.WaasRba
|
|
|
10214
10954
|
exports.WalletAccountAlreadyVerifiedError = WalletAccountAlreadyVerifiedError;
|
|
10215
10955
|
exports.WalletAccountNotSelectedError = WalletAccountNotSelectedError;
|
|
10216
10956
|
exports.WalletAlreadyLinkedToAnotherUserError = require_getNetworkProviderFromNetworkId.WalletAlreadyLinkedToAnotherUserError;
|
|
10957
|
+
exports.WalletBrowserRedirectHandlerMissingError = WalletBrowserRedirectHandlerMissingError;
|
|
10958
|
+
exports.WalletOptionNotFoundError = WalletOptionNotFoundError;
|
|
10217
10959
|
exports.WalletProviderMethodUnavailableError = WalletProviderMethodUnavailableError;
|
|
10218
10960
|
exports.WalletScreeningBlockedError = require_getNetworkProviderFromNetworkId.WalletScreeningBlockedError;
|
|
10219
10961
|
exports.acknowledgeRecoveryCodes = __acknowledgeRecoveryCodes_wrapped;
|
|
@@ -10243,6 +10985,7 @@ exports.completeSocialAuthentication = __completeSocialAuthentication_wrapped;
|
|
|
10243
10985
|
exports.completeSocialRedirect = __completeSocialRedirect_wrapped;
|
|
10244
10986
|
exports.confirmTransaction = __confirmTransaction_wrapped;
|
|
10245
10987
|
exports.connectAndVerifyWithWalletProvider = __connectAndVerifyWithWalletProvider_wrapped;
|
|
10988
|
+
exports.connectWalletOption = __connectWalletOption_wrapped;
|
|
10246
10989
|
exports.connectWithWalletProvider = __connectWithWalletProvider_wrapped;
|
|
10247
10990
|
exports.consumeMfaToken = require_isMfaRequiredForAction.__consumeMfaToken_wrapped;
|
|
10248
10991
|
exports.createCheckoutTransaction = __createCheckoutTransaction_wrapped;
|
|
@@ -10296,6 +11039,7 @@ exports.getNativeBalance = getNativeBalance;
|
|
|
10296
11039
|
exports.getNetworksData = require_getNetworkProviderFromNetworkId.getNetworksData;
|
|
10297
11040
|
exports.getOwnerWalletAccountForSmartWalletAccount = getOwnerWalletAccountForSmartWalletAccount;
|
|
10298
11041
|
exports.getPasskeys = getPasskeys;
|
|
11042
|
+
exports.getPreferredWalletDeepLink = getPreferredWalletDeepLink;
|
|
10299
11043
|
exports.getPrimaryWalletAccount = getPrimaryWalletAccount;
|
|
10300
11044
|
exports.getRegisteredDevices = getRegisteredDevices;
|
|
10301
11045
|
exports.getSelectedWalletAccount = getSelectedWalletAccount;
|
|
@@ -10345,6 +11089,7 @@ exports.parseUserAgent = parseUserAgent;
|
|
|
10345
11089
|
exports.prepareCheckoutTransaction = __prepareCheckoutTransaction_wrapped;
|
|
10346
11090
|
exports.prepareFlowSigning = __prepareFlowSigning_wrapped;
|
|
10347
11091
|
exports.proveWalletAccountOwnership = __proveWalletAccountOwnership_wrapped;
|
|
11092
|
+
exports.redirectToInAppBrowser = __redirectToInAppBrowser_wrapped;
|
|
10348
11093
|
exports.refreshAuth = require_logoutWithReason.__refreshAuth_wrapped;
|
|
10349
11094
|
exports.refreshUser = __refreshUser_wrapped;
|
|
10350
11095
|
exports.registerPasskey = __registerPasskey_wrapped;
|