@dynamic-labs-sdk/client 0.1.0-alpha.9 → 0.1.1
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/CHANGELOG.md +308 -0
- package/InvalidParamError.cjs.js +2 -2
- package/InvalidParamError.esm.js +1 -1
- package/NotWaasWalletAccountError.cjs.js +7 -7
- package/NotWaasWalletAccountError.esm.js +2 -2
- package/constants.cjs.js +493 -9
- package/constants.cjs2.js +15 -0
- package/constants.esm.js +468 -7
- package/constants.esm2.js +11 -0
- package/core.cjs.js +96 -41
- package/core.esm.js +47 -10
- package/filterDuplicates.cjs.js +8 -0
- package/filterDuplicates.esm.js +6 -0
- package/getNetworkProviderFromNetworkId.cjs.js +178 -20
- package/getNetworkProviderFromNetworkId.esm.js +150 -3
- package/getSignedSessionId.cjs.js +7 -7
- package/getSignedSessionId.esm.js +2 -2
- package/getVerifiedCredentialForWalletAccount.cjs.js +515 -0
- package/getVerifiedCredentialForWalletAccount.esm.js +491 -0
- package/index.cjs.js +1235 -471
- package/index.esm.js +1033 -282
- package/isMfaRequiredForAction.cjs.js +15 -8
- package/isMfaRequiredForAction.esm.js +8 -2
- package/package.json +4 -4
- package/src/client/core/createCore/createCore.d.ts.map +1 -1
- package/src/client/core/createCore/getInitialState.d.ts.map +1 -1
- package/src/client/core/types/DynamicCore.d.ts +8 -0
- package/src/client/core/types/DynamicCore.d.ts.map +1 -1
- package/src/client/createDynamicClient/createDynamicClient.d.ts.map +1 -1
- package/src/client/types/DynamicClientConfig.d.ts +6 -1
- package/src/client/types/DynamicClientConfig.d.ts.map +1 -1
- package/src/constants.d.ts +1 -0
- package/src/constants.d.ts.map +1 -1
- package/src/errors/APIError/APIError.d.ts.map +1 -1
- package/src/errors/InvalidWalletProviderKeyError.d.ts +5 -0
- package/src/errors/InvalidWalletProviderKeyError.d.ts.map +1 -0
- package/src/errors/MissingUserVerificationError.d.ts +12 -0
- package/src/errors/MissingUserVerificationError.d.ts.map +1 -0
- package/src/errors/NoSmartWalletAccountSignerFoundError.d.ts +5 -0
- package/src/errors/NoSmartWalletAccountSignerFoundError.d.ts.map +1 -0
- package/src/errors/WalletAccountNotSelectedError.d.ts.map +1 -1
- package/src/exports/core.d.ts +102 -2
- package/src/exports/core.d.ts.map +1 -1
- package/src/exports/index.d.ts +25 -7
- package/src/exports/index.d.ts.map +1 -1
- package/src/exports/waas.d.ts +2 -0
- package/src/exports/waas.d.ts.map +1 -1
- package/src/modules/apiClient/createApiClient.d.ts.map +1 -1
- package/src/modules/auth/createVisit/createVisit.d.ts.map +1 -1
- package/src/modules/auth/logout/logout.d.ts.map +1 -1
- package/src/modules/auth/passkeys/getPasskeyAuthenticationOptions/getPasskeyAuthenticationOptions.d.ts +4 -1
- package/src/modules/auth/passkeys/getPasskeyAuthenticationOptions/getPasskeyAuthenticationOptions.d.ts.map +1 -1
- package/src/modules/auth/passkeys/getPasskeyAuthenticationSignInOptions/getPasskeyAuthenticationSignInOptions.d.ts +4 -1
- package/src/modules/auth/passkeys/getPasskeyAuthenticationSignInOptions/getPasskeyAuthenticationSignInOptions.d.ts.map +1 -1
- package/src/modules/auth/passkeys/registerPasskey/registerPasskey.d.ts +7 -1
- package/src/modules/auth/passkeys/registerPasskey/registerPasskey.d.ts.map +1 -1
- package/src/modules/auth/passkeys/serverRegisterPasskey/serverRegisterPasskey.d.ts +3 -1
- package/src/modules/auth/passkeys/serverRegisterPasskey/serverRegisterPasskey.d.ts.map +1 -1
- package/src/modules/auth/passkeys/signInWithPasskey/signInWithPasskey.d.ts +4 -1
- package/src/modules/auth/passkeys/signInWithPasskey/signInWithPasskey.d.ts.map +1 -1
- package/src/modules/auth/social/getUserSocialAccounts/getUserSocialAccounts.d.ts +9 -0
- package/src/modules/auth/social/getUserSocialAccounts/getUserSocialAccounts.d.ts.map +1 -0
- package/src/modules/auth/social/getUserSocialAccounts/index.d.ts +2 -0
- package/src/modules/auth/social/getUserSocialAccounts/index.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/{signInWithSocialRedirect/signInWithSocialRedirect.d.ts → authenticateWithSocial/authenticateWithSocial.d.ts} +5 -3
- package/src/modules/auth/social/oauth/authenticateWithSocial/authenticateWithSocial.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/authenticateWithSocial/buildOAuthUrl/addOAuthUrlParams/addOAuthUrlParams.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/authenticateWithSocial/buildOAuthUrl/addOAuthUrlParams/index.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/authenticateWithSocial/buildOAuthUrl/buildOAuthUrl.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/authenticateWithSocial/buildOAuthUrl/getOAuthBaseUrl/getOAuthBaseUrl.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/authenticateWithSocial/buildOAuthUrl/getOAuthBaseUrl/index.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/{signInWithSocialRedirect → authenticateWithSocial}/buildOAuthUrl/index.d.ts.map +1 -1
- package/src/modules/auth/social/oauth/authenticateWithSocial/index.d.ts +2 -0
- package/src/modules/auth/social/oauth/{signInWithSocialRedirect → authenticateWithSocial}/index.d.ts.map +1 -1
- package/src/modules/auth/social/oauth/{completeSocialRedirectSignIn/completeSocialRedirectSignIn.d.ts → completeSocialAuthentication/completeSocialAuthentication.d.ts} +3 -3
- package/src/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/completeSocialAuthentication/index.d.ts +2 -0
- package/src/modules/auth/social/oauth/{completeSocialRedirectSignIn → completeSocialAuthentication}/index.d.ts.map +1 -1
- package/src/modules/auth/social/oauth/redirectStateStorageSchema/index.d.ts +1 -1
- package/src/modules/auth/social/oauth/redirectStateStorageSchema/index.d.ts.map +1 -1
- package/src/modules/auth/social/oauth/redirectStateStorageSchema/redirectStateStorageSchema.d.ts +1 -1
- package/src/modules/auth/social/oauth/redirectStateStorageSchema/redirectStateStorageSchema.d.ts.map +1 -1
- package/src/modules/auth/social/oauth/unlinkSocialAccount/index.d.ts +2 -0
- package/src/modules/auth/social/oauth/unlinkSocialAccount/index.d.ts.map +1 -0
- package/src/modules/auth/social/oauth/unlinkSocialAccount/unlinkSocialAccount.d.ts +14 -0
- package/src/modules/auth/social/oauth/unlinkSocialAccount/unlinkSocialAccount.d.ts.map +1 -0
- package/src/modules/auth/social/removeDynamicOauthParamsFromUrl/index.d.ts +2 -0
- package/src/modules/auth/social/removeDynamicOauthParamsFromUrl/index.d.ts.map +1 -0
- package/src/modules/auth/social/removeDynamicOauthParamsFromUrl/removeDynamicOauthParamsFromUrl.d.ts +2 -0
- package/src/modules/auth/social/removeDynamicOauthParamsFromUrl/removeDynamicOauthParamsFromUrl.d.ts.map +1 -0
- package/src/modules/auth/social/social.types.d.ts +9 -0
- package/src/modules/auth/social/social.types.d.ts.map +1 -1
- package/src/modules/auth/updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent/checkAndRaiseWalletAccountsChangedEvent.d.ts.map +1 -1
- package/src/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.d.ts.map +1 -1
- package/src/modules/balances/getMultichainBalances/getMultichainBalances.d.ts +1 -2
- package/src/modules/balances/getMultichainBalances/getMultichainBalances.d.ts.map +1 -1
- package/src/modules/balances/getMultichainBalances/index.d.ts +1 -1
- package/src/modules/balances/getMultichainBalances/index.d.ts.map +1 -1
- package/src/modules/funding/coinbase/addCoinbaseOnrampOrderEventListener/addCoinbaseOnrampOrderEventListener.d.ts +18 -0
- package/src/modules/funding/coinbase/addCoinbaseOnrampOrderEventListener/addCoinbaseOnrampOrderEventListener.d.ts.map +1 -0
- package/src/modules/funding/coinbase/addCoinbaseOnrampOrderEventListener/index.d.ts +2 -0
- package/src/modules/funding/coinbase/addCoinbaseOnrampOrderEventListener/index.d.ts.map +1 -0
- package/src/modules/funding/coinbase/coinbase.types.d.ts +269 -0
- package/src/modules/funding/coinbase/coinbase.types.d.ts.map +1 -0
- package/src/modules/funding/coinbase/createCoinbaseOnrampOrder/createCoinbaseOnrampOrder.d.ts +11 -0
- package/src/modules/funding/coinbase/createCoinbaseOnrampOrder/createCoinbaseOnrampOrder.d.ts.map +1 -0
- package/src/modules/funding/coinbase/createCoinbaseOnrampOrder/index.d.ts +2 -0
- package/src/modules/funding/coinbase/createCoinbaseOnrampOrder/index.d.ts.map +1 -0
- package/src/modules/funding/coinbase/getCoinbaseBuyUrl/getCoinbaseBuyUrl.d.ts +10 -0
- package/src/modules/funding/coinbase/getCoinbaseBuyUrl/getCoinbaseBuyUrl.d.ts.map +1 -0
- package/src/modules/funding/coinbase/getCoinbaseBuyUrl/index.d.ts +2 -0
- package/src/modules/funding/coinbase/getCoinbaseBuyUrl/index.d.ts.map +1 -0
- package/src/modules/funding/coinbase/getMissingVerificationForCoinbaseOnrampOrder/getMissingVerificationForCoinbaseOnrampOrder.d.ts +23 -0
- package/src/modules/funding/coinbase/getMissingVerificationForCoinbaseOnrampOrder/getMissingVerificationForCoinbaseOnrampOrder.d.ts.map +1 -0
- package/src/modules/funding/coinbase/getMissingVerificationForCoinbaseOnrampOrder/index.d.ts +2 -0
- package/src/modules/funding/coinbase/getMissingVerificationForCoinbaseOnrampOrder/index.d.ts.map +1 -0
- package/src/modules/funding/coinbase/utils/validateUserCredentialsForCoinbaseOnrampOrder/index.d.ts +2 -0
- package/src/modules/funding/coinbase/utils/validateUserCredentialsForCoinbaseOnrampOrder/index.d.ts.map +1 -0
- package/src/modules/funding/coinbase/utils/validateUserCredentialsForCoinbaseOnrampOrder/validateUserCredentialsForCoinbaseOnrampOrder.d.ts +4 -0
- package/src/modules/funding/coinbase/utils/validateUserCredentialsForCoinbaseOnrampOrder/validateUserCredentialsForCoinbaseOnrampOrder.d.ts.map +1 -0
- package/src/modules/funding/cryptoDotCom/createCryptoDotComPayment/createCryptoDotComPayment.d.ts +10 -0
- package/src/modules/funding/cryptoDotCom/createCryptoDotComPayment/createCryptoDotComPayment.d.ts.map +1 -0
- package/src/modules/funding/cryptoDotCom/createCryptoDotComPayment/index.d.ts +2 -0
- package/src/modules/funding/cryptoDotCom/createCryptoDotComPayment/index.d.ts.map +1 -0
- package/src/modules/funding/cryptoDotCom/cryptoDotCom.types.d.ts +8 -0
- package/src/modules/funding/cryptoDotCom/cryptoDotCom.types.d.ts.map +1 -0
- package/src/modules/initializeClient/consts.d.ts +5 -0
- package/src/modules/initializeClient/consts.d.ts.map +1 -0
- package/src/modules/initializeClient/initializeClient.d.ts.map +1 -1
- package/src/modules/initializeClient/waitForProjectSettings/index.d.ts +2 -0
- package/src/modules/initializeClient/waitForProjectSettings/index.d.ts.map +1 -0
- package/src/modules/initializeClient/waitForProjectSettings/waitForProjectSettings.d.ts +3 -0
- package/src/modules/initializeClient/waitForProjectSettings/waitForProjectSettings.d.ts.map +1 -0
- package/src/modules/mfa/authenticatePasskeyMFA/authenticatePasskeyMFA.d.ts +2 -1
- package/src/modules/mfa/authenticatePasskeyMFA/authenticatePasskeyMFA.d.ts.map +1 -1
- package/src/modules/otp/verifyOTP/verifyOTP.d.ts +3 -2
- package/src/modules/otp/verifyOTP/verifyOTP.d.ts.map +1 -1
- package/src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts.map +1 -1
- package/src/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.d.ts +1 -1
- package/src/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.d.ts.map +1 -1
- package/src/modules/storageSync/hydrateStateWithStorage/hydrateStateWithStorage.d.ts.map +1 -1
- package/src/modules/storageSync/schema.d.ts +15 -2
- package/src/modules/storageSync/schema.d.ts.map +1 -1
- package/src/modules/storageSync/syncStateWithStorage/syncStateWithStorage.d.ts.map +1 -1
- package/src/modules/user/deleteUser/deleteUser.d.ts +11 -0
- package/src/modules/user/deleteUser/deleteUser.d.ts.map +1 -0
- package/src/modules/user/deleteUser/index.d.ts +2 -0
- package/src/modules/user/deleteUser/index.d.ts.map +1 -0
- package/src/modules/waas/constants.d.ts +2 -2
- package/src/modules/waas/constants.d.ts.map +1 -1
- package/src/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
- package/src/modules/waas/createWaasWalletAccounts/createWaasWalletAccounts.d.ts.map +1 -1
- package/src/modules/waas/delegateWaasKeyShares/delegateWaasKeyShares.d.ts.map +1 -1
- package/src/modules/waas/getWaasWalletProviderByChain/getWaasWalletProviderByChain.d.ts.map +1 -1
- package/src/modules/waas/hasDelegatedAccess/hasDelegatedAccess.d.ts +14 -0
- package/src/modules/waas/hasDelegatedAccess/hasDelegatedAccess.d.ts.map +1 -0
- package/src/modules/waas/hasDelegatedAccess/index.d.ts +2 -0
- package/src/modules/waas/hasDelegatedAccess/index.d.ts.map +1 -0
- package/src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.d.ts.map +1 -1
- package/src/modules/waas/isWaasWalletProvider/isWaasWalletProvider.d.ts.map +1 -1
- package/src/modules/waas/revokeWaasDelegation/index.d.ts +2 -0
- package/src/modules/waas/revokeWaasDelegation/index.d.ts.map +1 -0
- package/src/modules/waas/revokeWaasDelegation/revokeWaasDelegation.d.ts +16 -0
- package/src/modules/waas/revokeWaasDelegation/revokeWaasDelegation.d.ts.map +1 -0
- package/src/modules/waas/waas.types.d.ts +4 -0
- package/src/modules/waas/waas.types.d.ts.map +1 -1
- package/src/modules/wallets/connectWithWalletProvider/connectWithWalletProvider.d.ts +4 -3
- package/src/modules/wallets/connectWithWalletProvider/connectWithWalletProvider.d.ts.map +1 -1
- package/src/modules/wallets/constants.d.ts.map +1 -1
- package/src/modules/wallets/getAvailableWalletProvidersData/getAvailableWalletProvidersData.d.ts +2 -6
- package/src/modules/wallets/getAvailableWalletProvidersData/getAvailableWalletProvidersData.d.ts.map +1 -1
- package/src/modules/wallets/getOwnerWalletAccountForSmartWalletAccount/getOwnerWalletAccountForSmartWalletAccount.d.ts +7 -0
- package/src/modules/wallets/getOwnerWalletAccountForSmartWalletAccount/getOwnerWalletAccountForSmartWalletAccount.d.ts.map +1 -0
- package/src/modules/wallets/getOwnerWalletAccountForSmartWalletAccount/index.d.ts +2 -0
- package/src/modules/wallets/getOwnerWalletAccountForSmartWalletAccount/index.d.ts.map +1 -0
- package/src/modules/wallets/getWalletAccountAddressByType/getWalletAccountAddressByType.d.ts +8 -0
- package/src/modules/wallets/getWalletAccountAddressByType/getWalletAccountAddressByType.d.ts.map +1 -0
- package/src/modules/wallets/getWalletAccountAddressByType/index.d.ts +2 -0
- package/src/modules/wallets/getWalletAccountAddressByType/index.d.ts.map +1 -0
- package/src/modules/wallets/getWalletAccounts/getWalletAccounts.d.ts.map +1 -1
- package/src/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.d.ts +9 -1
- package/src/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.d.ts.map +1 -1
- package/src/modules/wallets/getWalletProviderDataByKey/getWalletProviderDataByKey.d.ts +14 -0
- package/src/modules/wallets/getWalletProviderDataByKey/getWalletProviderDataByKey.d.ts.map +1 -0
- package/src/modules/wallets/getWalletProviderDataByKey/index.d.ts +2 -0
- package/src/modules/wallets/getWalletProviderDataByKey/index.d.ts.map +1 -0
- package/src/modules/wallets/isWalletAccountVerified/index.d.ts +2 -0
- package/src/modules/wallets/isWalletAccountVerified/index.d.ts.map +1 -0
- package/src/modules/wallets/isWalletAccountVerified/isWalletAccountVerified.d.ts +13 -0
- package/src/modules/wallets/isWalletAccountVerified/isWalletAccountVerified.d.ts.map +1 -0
- package/src/modules/wallets/networks/getNetworkDataForNetworkId/getNetworkDataForNetworkId.d.ts +10 -0
- package/src/modules/wallets/networks/getNetworkDataForNetworkId/getNetworkDataForNetworkId.d.ts.map +1 -0
- package/src/modules/wallets/networks/getNetworkDataForNetworkId/index.d.ts +2 -0
- package/src/modules/wallets/networks/getNetworkDataForNetworkId/index.d.ts.map +1 -0
- package/src/modules/wallets/networks/getTransactionHistory/getTransactionHistory.d.ts +26 -0
- package/src/modules/wallets/networks/getTransactionHistory/getTransactionHistory.d.ts.map +1 -0
- package/src/modules/wallets/networks/getTransactionHistory/index.d.ts +3 -0
- package/src/modules/wallets/networks/getTransactionHistory/index.d.ts.map +1 -0
- package/src/modules/wallets/networks/lastKnownNetworkRegistry/createLastKnownNetworkRegistry/createLastKnownNetworkRegistry.d.ts.map +1 -1
- package/src/modules/wallets/networks/lastKnownNetworkRegistry/createLastKnownNetworkRegistry/schema.d.ts +1 -1
- package/src/modules/wallets/networks/lastKnownNetworkRegistry/createLastKnownNetworkRegistry/schema.d.ts.map +1 -1
- package/src/modules/wallets/proveWalletAccountOwnership/proveWalletAccountOwnership.d.ts +1 -1
- package/src/modules/wallets/proveWalletAccountOwnership/proveWalletAccountOwnership.d.ts.map +1 -1
- package/src/modules/wallets/removeWalletAccount/removeWalletAccount.d.ts.map +1 -1
- package/src/modules/wallets/unverifiedWalletAccounts/removeUnverifiedWalletAccount/removeUnverifiedWalletAccount.d.ts.map +1 -1
- package/src/modules/wallets/unverifiedWalletAccounts/schema.d.ts +5 -0
- package/src/modules/wallets/unverifiedWalletAccounts/schema.d.ts.map +1 -1
- package/src/modules/wallets/unverifiedWalletAccounts/setUnverifiedWalletAccounts/setUnverifiedWalletAccounts.d.ts +2 -0
- package/src/modules/wallets/unverifiedWalletAccounts/setUnverifiedWalletAccounts/setUnverifiedWalletAccounts.d.ts.map +1 -1
- package/src/modules/wallets/utils/convertUnverifiedWalletAccountToWalletAccount/convertUnverifiedWalletAccountToWalletAccount.d.ts +5 -1
- package/src/modules/wallets/utils/convertUnverifiedWalletAccountToWalletAccount/convertUnverifiedWalletAccountToWalletAccount.d.ts.map +1 -1
- package/src/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.d.ts +6 -1
- package/src/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.d.ts.map +1 -1
- package/src/modules/wallets/utils/formatSignInMessage/formatSignInMessage.d.ts +9 -7
- package/src/modules/wallets/utils/formatSignInMessage/formatSignInMessage.d.ts.map +1 -1
- package/src/modules/wallets/utils/formatWalletAccountId/formatWalletAccountId.d.ts +9 -0
- package/src/modules/wallets/utils/formatWalletAccountId/formatWalletAccountId.d.ts.map +1 -0
- package/src/modules/wallets/utils/formatWalletAccountId/index.d.ts +2 -0
- package/src/modules/wallets/utils/formatWalletAccountId/index.d.ts.map +1 -0
- package/src/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.d.ts +17 -2
- package/src/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.d.ts.map +1 -1
- package/src/modules/wallets/utils/getAddressesWithTypesFromConnectionResult/getAddressesWithTypesFromConnectionResult.d.ts +4 -0
- package/src/modules/wallets/utils/getAddressesWithTypesFromConnectionResult/getAddressesWithTypesFromConnectionResult.d.ts.map +1 -0
- package/src/modules/wallets/utils/getAddressesWithTypesFromConnectionResult/index.d.ts +2 -0
- package/src/modules/wallets/utils/getAddressesWithTypesFromConnectionResult/index.d.ts.map +1 -0
- package/src/modules/wallets/utils/getChainIdForAccountVerification/getChainIdForAccountVerification.d.ts.map +1 -1
- package/src/modules/wallets/utils/getInjectedProviderFromWindow/getInjectedProviderFromWindow.d.ts +2 -0
- package/src/modules/wallets/utils/getInjectedProviderFromWindow/getInjectedProviderFromWindow.d.ts.map +1 -0
- package/src/modules/wallets/utils/getInjectedProviderFromWindow/index.d.ts +2 -0
- package/src/modules/wallets/utils/getInjectedProviderFromWindow/index.d.ts.map +1 -0
- package/src/modules/wallets/utils/getSignInMessage/createSignInMessageStatement/createSignInMessageStatement.d.ts +3 -0
- package/src/modules/wallets/utils/getSignInMessage/createSignInMessageStatement/createSignInMessageStatement.d.ts.map +1 -0
- package/src/modules/wallets/utils/getSignInMessage/createSignInMessageStatement/index.d.ts +2 -0
- package/src/modules/wallets/utils/getSignInMessage/createSignInMessageStatement/index.d.ts.map +1 -0
- package/src/modules/wallets/utils/getSignInMessage/getSignInMessage.d.ts.map +1 -1
- package/src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.d.ts +8 -0
- package/src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.d.ts.map +1 -0
- package/src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/index.d.ts +2 -0
- package/src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/index.d.ts.map +1 -0
- package/src/modules/wallets/utils/normalizeWalletNameWithChain/index.d.ts +2 -0
- package/src/modules/wallets/utils/normalizeWalletNameWithChain/index.d.ts.map +1 -0
- package/src/modules/wallets/utils/normalizeWalletNameWithChain/normalizeWalletNameWithChain.d.ts +12 -0
- package/src/modules/wallets/utils/normalizeWalletNameWithChain/normalizeWalletNameWithChain.d.ts.map +1 -0
- package/src/modules/wallets/verifySignInMessage/index.d.ts +2 -0
- package/src/modules/wallets/verifySignInMessage/index.d.ts.map +1 -0
- package/src/modules/wallets/verifySignInMessage/verifySignInMessage.d.ts +22 -0
- package/src/modules/wallets/verifySignInMessage/verifySignInMessage.d.ts.map +1 -0
- package/src/modules/wallets/verifyWalletAccount/verifyWalletAccount.d.ts.map +1 -1
- package/src/modules/wallets/walletAccount/index.d.ts +1 -1
- package/src/modules/wallets/walletAccount/index.d.ts.map +1 -1
- package/src/modules/wallets/walletAccount/walletAccount.types.d.ts +8 -0
- package/src/modules/wallets/walletAccount/walletAccount.types.d.ts.map +1 -1
- package/src/modules/wallets/walletProvider/index.d.ts +1 -1
- package/src/modules/wallets/walletProvider/index.d.ts.map +1 -1
- package/src/modules/wallets/walletProvider/splitWalletProviderKey/index.d.ts +2 -0
- package/src/modules/wallets/walletProvider/splitWalletProviderKey/index.d.ts.map +1 -0
- package/src/modules/wallets/walletProvider/splitWalletProviderKey/splitWalletProviderKey.d.ts +9 -0
- package/src/modules/wallets/walletProvider/splitWalletProviderKey/splitWalletProviderKey.d.ts.map +1 -0
- package/src/modules/wallets/walletProvider/walletProvider.types.d.ts +24 -8
- package/src/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/getWalletProviderKeyFromVerifiedCredential.d.ts +10 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/getWalletProviderKeyFromVerifiedCredential.d.ts.map +1 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/index.d.ts +2 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/index.d.ts.map +1 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/schema.d.ts +3 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/schema.d.ts.map +1 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/state.d.ts +16 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/state.d.ts.map +1 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/updateWalletProviderKeysForVerifiedCredentials/index.d.ts +2 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/updateWalletProviderKeysForVerifiedCredentials/index.d.ts.map +1 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/updateWalletProviderKeysForVerifiedCredentials/updateWalletProviderKeysForVerifiedCredentials.d.ts +7 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/updateWalletProviderKeysForVerifiedCredentials/updateWalletProviderKeysForVerifiedCredentials.d.ts.map +1 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/walletProviderKeyMap.types.d.ts +12 -0
- package/src/modules/wallets/walletProvider/walletProviderKeyMap/walletProviderKeyMap.types.d.ts.map +1 -0
- package/src/services/asyncTrack/asyncTrack.types.d.ts +5 -1
- package/src/services/asyncTrack/asyncTrack.types.d.ts.map +1 -1
- package/src/services/asyncTrack/createAsyncTrack.d.ts.map +1 -1
- package/src/services/storage/index.d.ts +1 -1
- package/src/services/storage/index.d.ts.map +1 -1
- package/src/utils/debouncedMutex/createDebouncedMutex/createDebouncedMutex.d.ts +3 -0
- package/src/utils/debouncedMutex/createDebouncedMutex/createDebouncedMutex.d.ts.map +1 -0
- package/src/utils/debouncedMutex/createDebouncedMutex/index.d.ts +2 -0
- package/src/utils/debouncedMutex/createDebouncedMutex/index.d.ts.map +1 -0
- package/src/utils/debouncedMutex/debouncedMutex.types.d.ts +39 -0
- package/src/utils/debouncedMutex/debouncedMutex.types.d.ts.map +1 -0
- package/src/utils/debouncedMutex/index.d.ts +2 -0
- package/src/utils/debouncedMutex/index.d.ts.map +1 -0
- package/waas.cjs.js +86 -38
- package/waas.esm.js +62 -16
- package/waasCore.cjs.js +21 -10
- package/waasCore.esm.js +15 -4
- package/getWalletProviderByKey.cjs.js +0 -74
- package/getWalletProviderByKey.esm.js +0 -69
- package/logout.cjs.js +0 -1086
- package/logout.esm.js +0 -1020
- package/src/modules/apiClient/utils/logoutOnUnauthorizedRequestMiddleware/index.d.ts +0 -2
- package/src/modules/apiClient/utils/logoutOnUnauthorizedRequestMiddleware/index.d.ts.map +0 -1
- package/src/modules/apiClient/utils/logoutOnUnauthorizedRequestMiddleware/logoutOnUnauthorizedRequestMiddleware.d.ts +0 -4
- package/src/modules/apiClient/utils/logoutOnUnauthorizedRequestMiddleware/logoutOnUnauthorizedRequestMiddleware.d.ts.map +0 -1
- package/src/modules/auth/social/oauth/completeSocialRedirectSignIn/completeSocialRedirectSignIn.d.ts.map +0 -1
- package/src/modules/auth/social/oauth/completeSocialRedirectSignIn/index.d.ts +0 -2
- package/src/modules/auth/social/oauth/signInWithSocialRedirect/buildOAuthUrl/addOAuthUrlParams/addOAuthUrlParams.d.ts.map +0 -1
- package/src/modules/auth/social/oauth/signInWithSocialRedirect/buildOAuthUrl/addOAuthUrlParams/index.d.ts.map +0 -1
- package/src/modules/auth/social/oauth/signInWithSocialRedirect/buildOAuthUrl/buildOAuthUrl.d.ts.map +0 -1
- package/src/modules/auth/social/oauth/signInWithSocialRedirect/buildOAuthUrl/getOAuthBaseUrl/getOAuthBaseUrl.d.ts.map +0 -1
- package/src/modules/auth/social/oauth/signInWithSocialRedirect/buildOAuthUrl/getOAuthBaseUrl/index.d.ts.map +0 -1
- package/src/modules/auth/social/oauth/signInWithSocialRedirect/index.d.ts +0 -2
- package/src/modules/auth/social/oauth/signInWithSocialRedirect/signInWithSocialRedirect.d.ts.map +0 -1
- package/src/modules/wallets/utils/createWalletAccountId/createWalletAccountId.d.ts +0 -3
- package/src/modules/wallets/utils/createWalletAccountId/createWalletAccountId.d.ts.map +0 -1
- package/src/modules/wallets/utils/createWalletAccountId/index.d.ts +0 -2
- package/src/modules/wallets/utils/createWalletAccountId/index.d.ts.map +0 -1
- /package/src/modules/auth/social/oauth/{signInWithSocialRedirect → authenticateWithSocial}/buildOAuthUrl/addOAuthUrlParams/addOAuthUrlParams.d.ts +0 -0
- /package/src/modules/auth/social/oauth/{signInWithSocialRedirect → authenticateWithSocial}/buildOAuthUrl/addOAuthUrlParams/index.d.ts +0 -0
- /package/src/modules/auth/social/oauth/{signInWithSocialRedirect → authenticateWithSocial}/buildOAuthUrl/buildOAuthUrl.d.ts +0 -0
- /package/src/modules/auth/social/oauth/{signInWithSocialRedirect → authenticateWithSocial}/buildOAuthUrl/getOAuthBaseUrl/getOAuthBaseUrl.d.ts +0 -0
- /package/src/modules/auth/social/oauth/{signInWithSocialRedirect → authenticateWithSocial}/buildOAuthUrl/getOAuthBaseUrl/index.d.ts +0 -0
- /package/src/modules/auth/social/oauth/{signInWithSocialRedirect → authenticateWithSocial}/buildOAuthUrl/index.d.ts +0 -0
package/index.esm.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';
|
|
2
|
-
import {
|
|
3
|
-
export { I as InvalidExternalAuthError, M as MfaInvalidOtpError,
|
|
4
|
-
import { ProviderEnum, MfaBackupCodeAcknowledgement, AuthModeEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { B as BaseError, g as getDefaultClient, a as getCore, c as createApiClient, C as CLIENT_SDK_NAME, b as getBuffer, i as isCookieEnabled, S as SDK_API_CORE_VERSION, d as assertDefined, v as version, s as setDefaultClient, _ as _extends, r as randomString, V as ValueMustBeDefinedError, e as CHAINS_INFO_MAP, n as name } from './constants.esm.js';
|
|
3
|
+
export { I as InvalidExternalAuthError, M as MfaInvalidOtpError, f as MfaRateLimitedError, h as SandboxMaximumThresholdReachedError } from './constants.esm.js';
|
|
4
|
+
import { JwtVerifiedCredentialFormatEnum, ProviderEnum, MfaBackupCodeAcknowledgement, AuthModeEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
export { MFAAction } from '@dynamic-labs/sdk-api-core';
|
|
6
|
-
import { s as subscribeWithSelector, i as isEqualShallow, C as CannotTrackError,
|
|
7
|
-
export { N as NoNetworkProvidersError,
|
|
6
|
+
import { c as createStorageKeySchema, s as subscribeWithSelector, i as isEqualShallow, I as INITIALIZE_STORAGE_SYNC_TRACKER_KEY, F as FETCH_PROJECT_SETTINGS_TRACKER_KEY, G as GENERATE_SESSION_KEYS_TRACKER_KEY, R as REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY, C as CannotTrackError, a as createLogger, b as createStorage, d as createLocalStorageAdapter, e as consumeCaptchaToken, f as setUnverifiedWalletAccounts, g as createVisit, h as createSignInMessageStatement, j as formatSignInMessage, v as verifySignInMessage, u as updateWalletProviderKeysForVerifiedCredentials, k as getNetworksData, l as getNetworkProviderFromNetworkId } from './getNetworkProviderFromNetworkId.esm.js';
|
|
7
|
+
export { N as NoNetworkProvidersError, W as WalletAlreadyLinkedToAnotherUserError, o as hasExtension, m as isCaptchaRequired, n as setCaptchaToken } from './getNetworkProviderFromNetworkId.esm.js';
|
|
8
|
+
import { g as getWalletAccounts, a as getWalletProviderFromWalletAccount, s as setCookie, e as emitEvent, D as DYNAMIC_AUTH_COOKIE_NAME, c as checkAndRaiseWalletAccountsChangedEvent, u as updateAuthFromVerifyResponse, b as getWalletProviderByKey, f as formatWalletAccountId, d as emitWalletAccountsChangedEvent, n as normalizeAddress, h as getWalletProviders, i as getVerifiedCredentialForWalletAccount, N as NoWalletProviderFoundError } from './getVerifiedCredentialForWalletAccount.esm.js';
|
|
9
|
+
export { o as offEvent, k as onEvent, j as onceEvent } from './getVerifiedCredentialForWalletAccount.esm.js';
|
|
8
10
|
import * as z from 'zod/mini';
|
|
11
|
+
import { b as bufferToHex } from './isMfaRequiredForAction.esm.js';
|
|
12
|
+
export { c as consumeMfaToken, g as getMfaMethods, i as isMfaRequiredForAction } from './isMfaRequiredForAction.esm.js';
|
|
9
13
|
import { r as refreshUser } from './NotWaasWalletAccountError.esm.js';
|
|
10
14
|
export { N as NotWaasWalletAccountError } from './NotWaasWalletAccountError.esm.js';
|
|
11
15
|
import EventEmitter$1, { EventEmitter } from 'eventemitter3';
|
|
12
16
|
import { startRegistration, browserSupportsWebAuthn, startAuthentication } from '@simplewebauthn/browser';
|
|
13
|
-
|
|
14
|
-
import { u as updateAuthFromVerifyResponse, g as getWalletProviderByKey, e as emitWalletAccountsChangedEvent, a as getWalletProviders } from './getWalletProviderByKey.esm.js';
|
|
15
|
-
export { c as consumeMfaToken, g as getMfaMethods, i as isMfaRequiredForAction } from './isMfaRequiredForAction.esm.js';
|
|
17
|
+
import { I as InvalidParamError } from './InvalidParamError.esm.js';
|
|
16
18
|
import 'buffer';
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -29,6 +31,163 @@ import 'buffer';
|
|
|
29
31
|
user: 'userChanged'
|
|
30
32
|
};
|
|
31
33
|
|
|
34
|
+
/**
|
|
35
|
+
* This error is thrown when the `retryOnFail` function is called with an invalid
|
|
36
|
+
* number of retries (i.e. less than 0).
|
|
37
|
+
*/ class InvalidRetryOnFailCallError extends BaseError {
|
|
38
|
+
constructor(maxRetries){
|
|
39
|
+
super({
|
|
40
|
+
cause: null,
|
|
41
|
+
code: 'invalid_retry_on_fail_call_error',
|
|
42
|
+
docsUrl: null,
|
|
43
|
+
name: 'InvalidRetryOnFailCallError',
|
|
44
|
+
shortMessage: `Invalid retries parameter for retryOnFail call: ${maxRetries}`
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const retryOnFail = async ({ delay = 0, fn, maxRetries })=>{
|
|
50
|
+
for(let retry = 0; retry <= maxRetries; retry++){
|
|
51
|
+
try {
|
|
52
|
+
return await fn();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (retry >= maxRetries) {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
if (delay > 0) {
|
|
58
|
+
await new Promise((resolve)=>setTimeout(resolve, delay));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Reaching this point should never happen and this
|
|
64
|
+
* error is thrown to help us debug the issue.
|
|
65
|
+
*/ throw new InvalidRetryOnFailCallError(maxRetries);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Checks if the user is currently signed in to the Dynamic client.
|
|
70
|
+
*
|
|
71
|
+
* The client is considered to be in a signed in state if a user has
|
|
72
|
+
* authenticated or if the client has at least one wallet connected.
|
|
73
|
+
*
|
|
74
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
75
|
+
* @returns True if the user is signed in, false otherwise.
|
|
76
|
+
*/ const isSignedIn = (client = getDefaultClient())=>Boolean(client.user || getWalletAccounts(client).length > 0);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The schema to track the expiration time of the project settings.
|
|
80
|
+
*/ const projectSettingsExpirationStorageKeySchema = createStorageKeySchema({
|
|
81
|
+
key: 'projectSettingsExpiration',
|
|
82
|
+
schema: z.number()
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Expiration time of the project settings in milliseconds.
|
|
87
|
+
*/ const PROJECT_SETTINGS_EXPIRATION_TIME = 1000 * 60 * 5; // 5 minutes
|
|
88
|
+
/**
|
|
89
|
+
* Fetches and updates the project settings from the API.
|
|
90
|
+
*
|
|
91
|
+
* This function retrieves the latest project configuration settings
|
|
92
|
+
* from Dynamic's servers, including authentication options, enabled chains,
|
|
93
|
+
* and security configurations. The settings are cached for performance.
|
|
94
|
+
*
|
|
95
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
96
|
+
* @returns A promise that resolves to the updated project settings.
|
|
97
|
+
*/ const fetchProjectSettings = async (client = getDefaultClient())=>{
|
|
98
|
+
const core = getCore(client);
|
|
99
|
+
const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
|
|
100
|
+
const hasProjectSettings = Boolean(client.projectSettings);
|
|
101
|
+
const isExpired = currentExpiration && currentExpiration < Date.now();
|
|
102
|
+
// We want to cache the project settings if its valid and user is connected.
|
|
103
|
+
// This avoids unnecessary API calls and speeds up the initial load.
|
|
104
|
+
if (hasProjectSettings && !isExpired && isSignedIn(client)) {
|
|
105
|
+
return client.projectSettings;
|
|
106
|
+
}
|
|
107
|
+
const apiClient = createApiClient({}, client);
|
|
108
|
+
core.logger.debug('[fetchProjectSettings] Fetching project settings...');
|
|
109
|
+
const doFetch = async ()=>apiClient.getEnvironmentSettings({
|
|
110
|
+
environmentId: core.environmentId,
|
|
111
|
+
sdkVersion: `${CLIENT_SDK_NAME}/${core.version}`
|
|
112
|
+
}, {
|
|
113
|
+
credentials: 'omit'
|
|
114
|
+
});
|
|
115
|
+
const projectSettings = await retryOnFail({
|
|
116
|
+
fn: doFetch,
|
|
117
|
+
maxRetries: 2
|
|
118
|
+
});
|
|
119
|
+
core.state.set({
|
|
120
|
+
projectSettings: projectSettings != null ? projectSettings : null
|
|
121
|
+
});
|
|
122
|
+
await core.storage.setItem(projectSettingsExpirationStorageKeySchema, Date.now() + PROJECT_SETTINGS_EXPIRATION_TIME);
|
|
123
|
+
return projectSettings;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Takes a base64url-encoded string (e.g. "nMueRPiAm51YXEjRtka8S_8Ura3HaqbmqDqMJCZmvkM")
|
|
128
|
+
* and return the corresponding bytes, as an array buffer.
|
|
129
|
+
*/ const base64UrlDecode = (s)=>{
|
|
130
|
+
// Go from base64url encoding to base64 encoding
|
|
131
|
+
s = (s == null ? void 0 : s.replace(/-/g, '+').replace(/_/g, '/')) || '';
|
|
132
|
+
// use `atob` to decode base64
|
|
133
|
+
return Uint8Array.from(atob(s), (c)=>c.charCodeAt(0));
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Accepts a public key array buffer, and returns a buffer with the compressed version of the public key
|
|
138
|
+
*/ const compressRawPublicKey = (rawPublicKey)=>{
|
|
139
|
+
const rawPublicKeyBytes = new Uint8Array(rawPublicKey);
|
|
140
|
+
const len = rawPublicKeyBytes.byteLength;
|
|
141
|
+
// Drop the y coordinate
|
|
142
|
+
const compressedBytes = rawPublicKeyBytes.slice(0, 1 + len >>> 1);
|
|
143
|
+
// Encode the parity of `y` in first bit
|
|
144
|
+
compressedBytes[0] = 0x2 | rawPublicKeyBytes[len - 1] & 0x01;
|
|
145
|
+
return compressedBytes.buffer;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const p256Keygen = async ()=>{
|
|
149
|
+
// Create a new P-256 keypair
|
|
150
|
+
const p256Keypair = await crypto.subtle.generateKey({
|
|
151
|
+
name: 'ECDSA',
|
|
152
|
+
namedCurve: 'P-256'
|
|
153
|
+
}, true, [
|
|
154
|
+
'sign',
|
|
155
|
+
'verify'
|
|
156
|
+
]);
|
|
157
|
+
// Export the raw public key. By default this will export in uncompressed format
|
|
158
|
+
const rawPublicKey = await crypto.subtle.exportKey('raw', p256Keypair.publicKey);
|
|
159
|
+
// We need to export with JWK format because exporting EC private keys with "raw" isn't supported
|
|
160
|
+
const privateKeyJwk = await crypto.subtle.exportKey('jwk', p256Keypair.privateKey);
|
|
161
|
+
const compressedPublicKeyBuffer = compressRawPublicKey(rawPublicKey);
|
|
162
|
+
const privateKeyBuffer = base64UrlDecode(privateKeyJwk.d);
|
|
163
|
+
return {
|
|
164
|
+
private: bufferToHex(privateKeyBuffer),
|
|
165
|
+
privateJwk: privateKeyJwk,
|
|
166
|
+
public: bufferToHex(compressedPublicKeyBuffer)
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const generateSessionKeys = async (client)=>{
|
|
171
|
+
const { private: privateKey, public: publicKey, privateJwk: privateKeyJwk } = await p256Keygen();
|
|
172
|
+
const core = getCore(client);
|
|
173
|
+
// stringify and encode the session keys to store in storage
|
|
174
|
+
const stringifiedSessionKeys = JSON.stringify({
|
|
175
|
+
privateKey,
|
|
176
|
+
privateKeyJwk,
|
|
177
|
+
publicKey,
|
|
178
|
+
registered: false
|
|
179
|
+
});
|
|
180
|
+
const encodedSessionKeys = getBuffer().from(stringifiedSessionKeys).toString('base64');
|
|
181
|
+
core.state.set({
|
|
182
|
+
sessionKeys: encodedSessionKeys
|
|
183
|
+
});
|
|
184
|
+
return {
|
|
185
|
+
privateKey,
|
|
186
|
+
privateKeyJwk,
|
|
187
|
+
publicKey
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
|
|
32
191
|
/**
|
|
33
192
|
* Creates a new runtime services instance that manages service registration and retrieval.
|
|
34
193
|
*
|
|
@@ -42,6 +201,92 @@ import 'buffer';
|
|
|
42
201
|
};
|
|
43
202
|
};
|
|
44
203
|
|
|
204
|
+
const getAvailableWalletProvidersFromWalletAccounts = (client)=>{
|
|
205
|
+
const core = getCore(client);
|
|
206
|
+
const walletProvidersMap = new Map();
|
|
207
|
+
const walletAccounts = getWalletAccounts(client);
|
|
208
|
+
walletAccounts.forEach((walletAccount)=>{
|
|
209
|
+
if (walletProvidersMap.has(walletAccount.walletProviderKey)) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
const walletProvider = getWalletProviderFromWalletAccount({
|
|
214
|
+
walletAccount
|
|
215
|
+
}, client);
|
|
216
|
+
walletProvidersMap.set(walletAccount.walletProviderKey, walletProvider);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
core.logger.debug('Wallet provider not found for wallet account', {
|
|
219
|
+
error,
|
|
220
|
+
walletAccount: walletAccount.address
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
return Array.from(walletProvidersMap.values());
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Disconnect and terminate each wallet provider, if available.
|
|
229
|
+
*/ const disconnectAndTerminateWalletProviders = async (client)=>{
|
|
230
|
+
const core = getCore(client);
|
|
231
|
+
const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
|
|
232
|
+
await Promise.all(walletProviders.map(async (walletProvider)=>{
|
|
233
|
+
if (walletProvider.terminate) {
|
|
234
|
+
await walletProvider.terminate();
|
|
235
|
+
}
|
|
236
|
+
if (walletProvider.disconnect) {
|
|
237
|
+
try {
|
|
238
|
+
await walletProvider.disconnect();
|
|
239
|
+
} catch (err) {
|
|
240
|
+
core.logger.error(`Error disconnecting from wallet ${walletProvider.key}`, err);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}));
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Logs out the current user and clears all authentication data.
|
|
248
|
+
*
|
|
249
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
250
|
+
* @returns A promise that resolves when the logout process is complete.
|
|
251
|
+
*/ const logout = async (client = getDefaultClient())=>{
|
|
252
|
+
const core = getCore(client);
|
|
253
|
+
core.logger.debug('[logout] Logging out...');
|
|
254
|
+
await disconnectAndTerminateWalletProviders(client);
|
|
255
|
+
if (client.user !== null) {
|
|
256
|
+
const apiClient = createApiClient({}, client);
|
|
257
|
+
try {
|
|
258
|
+
await apiClient.revokeSession({
|
|
259
|
+
environmentId: core.environmentId
|
|
260
|
+
});
|
|
261
|
+
} catch (error) {
|
|
262
|
+
core.logger.error('Failed to revoke session', error);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* This deletes the auth cookie if it exists.
|
|
266
|
+
* If the cookie doesn't exist, this sets a new cookie that expires immediately.
|
|
267
|
+
*/ if (isCookieEnabled(client)) {
|
|
268
|
+
setCookie(`${DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
core.state.set({
|
|
272
|
+
captchaToken: null,
|
|
273
|
+
legacyToken: null,
|
|
274
|
+
mfaToken: null,
|
|
275
|
+
sessionExpiresAt: null,
|
|
276
|
+
sessionKeys: null,
|
|
277
|
+
token: null,
|
|
278
|
+
unverifiedWalletAccounts: [],
|
|
279
|
+
user: null
|
|
280
|
+
});
|
|
281
|
+
emitEvent({
|
|
282
|
+
event: 'logout'
|
|
283
|
+
}, client);
|
|
284
|
+
// Refetch project settings
|
|
285
|
+
void fetchProjectSettings(client);
|
|
286
|
+
// Regenerate session keys
|
|
287
|
+
void generateSessionKeys(client);
|
|
288
|
+
};
|
|
289
|
+
|
|
45
290
|
/**
|
|
46
291
|
* A replacement for setTimeout that supports delays longer than 2147483647ms (~24.8 days).
|
|
47
292
|
*/ const setLongTimeout = (callback, delay)=>{
|
|
@@ -109,17 +354,32 @@ const raiseStateEvents = (client)=>{
|
|
|
109
354
|
});
|
|
110
355
|
};
|
|
111
356
|
|
|
112
|
-
const
|
|
357
|
+
const unverifiedWalletAccountSchema = z.object({
|
|
358
|
+
address: z.string(),
|
|
359
|
+
addressesWithTypes: z.optional(z.array(z.object({
|
|
360
|
+
address: z.string(),
|
|
361
|
+
publicKey: z.optional(z.string()),
|
|
362
|
+
type: z.custom((val)=>typeof val === 'string')
|
|
363
|
+
}))),
|
|
364
|
+
chain: z.custom((val)=>typeof val === 'string'),
|
|
365
|
+
id: z.string(),
|
|
366
|
+
lastSelectedAt: z.nullable(z.date()),
|
|
367
|
+
walletProviderKey: z.string()
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
const walletProviderKeyMapSchema = z.record(z.string(), z.string());
|
|
113
371
|
|
|
114
372
|
const stateStorageKeySchema = createStorageKeySchema({
|
|
115
373
|
key: 'state',
|
|
116
374
|
schema: z.object({
|
|
117
375
|
apiVersion: z.string(),
|
|
118
376
|
projectSettings: z.custom(),
|
|
119
|
-
|
|
377
|
+
unverifiedWalletAccounts: z.array(unverifiedWalletAccountSchema),
|
|
378
|
+
user: z.custom(),
|
|
379
|
+
walletProviderKeyMap: walletProviderKeyMapSchema
|
|
120
380
|
})
|
|
121
381
|
});
|
|
122
|
-
const
|
|
382
|
+
const sessionStorageKeySchema = createStorageKeySchema({
|
|
123
383
|
key: 'session',
|
|
124
384
|
schema: z.object({
|
|
125
385
|
/**
|
|
@@ -147,9 +407,10 @@ const sessionKeySchema = createStorageKeySchema({
|
|
|
147
407
|
|
|
148
408
|
const hydrateStateWithStorage = async (client)=>{
|
|
149
409
|
const core = getCore(client);
|
|
410
|
+
const previousState = core.state.get();
|
|
150
411
|
const stateChanges = {};
|
|
151
412
|
// ================ TOKEN =================
|
|
152
|
-
const session = await core.storage.getItem(
|
|
413
|
+
const session = await core.storage.getItem(sessionStorageKeySchema);
|
|
153
414
|
const isSessionValid = (session == null ? void 0 : session.sessionExpiration) && session.sessionExpiration > Date.now();
|
|
154
415
|
if (isSessionValid) {
|
|
155
416
|
stateChanges.token = session.token;
|
|
@@ -163,24 +424,34 @@ const hydrateStateWithStorage = async (client)=>{
|
|
|
163
424
|
const storedState = await core.storage.getItem(stateStorageKeySchema);
|
|
164
425
|
// Only hydrate state if it came from an API with the same version as the current SDK
|
|
165
426
|
if ((storedState == null ? void 0 : storedState.apiVersion) === SDK_API_CORE_VERSION) {
|
|
427
|
+
stateChanges.unverifiedWalletAccounts = storedState.unverifiedWalletAccounts;
|
|
428
|
+
stateChanges.walletProviderKeyMap = storedState.walletProviderKeyMap;
|
|
166
429
|
// Variables that should only be hydrated if the session is valid
|
|
167
430
|
if (isSessionValid) {
|
|
168
431
|
stateChanges.user = storedState.user;
|
|
432
|
+
}
|
|
433
|
+
var _storedState_unverifiedWalletAccounts;
|
|
434
|
+
// if there's a session/user or connected unverified wallets, we should hydrate project settings
|
|
435
|
+
// so we don't refetch it on initial load
|
|
436
|
+
if (isSessionValid || ((_storedState_unverifiedWalletAccounts = storedState.unverifiedWalletAccounts) != null ? _storedState_unverifiedWalletAccounts : []).length > 0) {
|
|
169
437
|
stateChanges.projectSettings = storedState.projectSettings;
|
|
170
438
|
}
|
|
171
439
|
}
|
|
172
440
|
if (Object.keys(stateChanges).length > 0) {
|
|
173
441
|
core.state.set(stateChanges);
|
|
174
442
|
}
|
|
443
|
+
checkAndRaiseWalletAccountsChangedEvent({
|
|
444
|
+
previousState
|
|
445
|
+
}, client);
|
|
175
446
|
};
|
|
176
447
|
|
|
177
448
|
const syncStateWithStorage = (client)=>{
|
|
178
449
|
const core = getCore(client);
|
|
179
450
|
core.state.subscribe((state)=>{
|
|
180
451
|
if (state.sessionExpiresAt === null) {
|
|
181
|
-
void core.storage.removeItem(
|
|
452
|
+
void core.storage.removeItem(sessionStorageKeySchema);
|
|
182
453
|
} else {
|
|
183
|
-
void core.storage.setItem(
|
|
454
|
+
void core.storage.setItem(sessionStorageKeySchema, {
|
|
184
455
|
captchaToken: state.captchaToken,
|
|
185
456
|
legacyToken: state.legacyToken,
|
|
186
457
|
mfaToken: state.mfaToken,
|
|
@@ -192,7 +463,9 @@ const syncStateWithStorage = (client)=>{
|
|
|
192
463
|
void core.storage.setItem(stateStorageKeySchema, {
|
|
193
464
|
apiVersion: SDK_API_CORE_VERSION,
|
|
194
465
|
projectSettings: state.projectSettings,
|
|
195
|
-
|
|
466
|
+
unverifiedWalletAccounts: state.unverifiedWalletAccounts,
|
|
467
|
+
user: state.user,
|
|
468
|
+
walletProviderKeyMap: state.walletProviderKeyMap
|
|
196
469
|
});
|
|
197
470
|
});
|
|
198
471
|
};
|
|
@@ -230,6 +503,7 @@ class ClientAlreadyInitializedError extends BaseError {
|
|
|
230
503
|
* @throws ClientAlreadyInitializedError If the client is already initialized.
|
|
231
504
|
*/ const initializeClient = async (client = getDefaultClient())=>{
|
|
232
505
|
const core = getCore(client);
|
|
506
|
+
core.logger.debug('[initializeClient] Initializing client. Current init status', core.state.get().initStatus);
|
|
233
507
|
if (core.state.get().initStatus !== 'uninitialized') {
|
|
234
508
|
throw new ClientAlreadyInitializedError();
|
|
235
509
|
}
|
|
@@ -263,24 +537,38 @@ class ClientAlreadyInitializedError extends BaseError {
|
|
|
263
537
|
* sub2.example.com that had the original logged-in user. We need to fetch the user to refresh
|
|
264
538
|
* the user state with the correct logged-in user.
|
|
265
539
|
*/ const refreshUserStateFromCookiePromise = fetchProjectSettingsPromise.then(async ()=>{
|
|
266
|
-
|
|
267
|
-
|
|
540
|
+
/**
|
|
541
|
+
* When cookies are enabled, we need to refresh the user as part of the initialization process
|
|
542
|
+
* to ensure the user is logged in and sync the auth state with the server.
|
|
543
|
+
*
|
|
544
|
+
* This call can fail with a 401 error if the user is not logged in and the SDK should finish its initialization process
|
|
545
|
+
* without throwing an error because that is an expected behavior.
|
|
546
|
+
*/ if (isCookieEnabled(client)) {
|
|
547
|
+
await refreshUser(client).catch(async (error)=>{
|
|
548
|
+
if (error.status === 401) {
|
|
549
|
+
if (client.user) {
|
|
550
|
+
await logout(client);
|
|
551
|
+
}
|
|
552
|
+
} else {
|
|
553
|
+
throw error;
|
|
554
|
+
}
|
|
555
|
+
});
|
|
268
556
|
}
|
|
269
557
|
});
|
|
270
558
|
core.initTrack.track({
|
|
271
|
-
name:
|
|
559
|
+
name: INITIALIZE_STORAGE_SYNC_TRACKER_KEY,
|
|
272
560
|
promise: initializeStorageSyncPromise
|
|
273
561
|
});
|
|
274
562
|
core.initTrack.track({
|
|
275
|
-
name:
|
|
563
|
+
name: FETCH_PROJECT_SETTINGS_TRACKER_KEY,
|
|
276
564
|
promise: fetchProjectSettingsPromise
|
|
277
565
|
});
|
|
278
566
|
core.initTrack.track({
|
|
279
|
-
name:
|
|
567
|
+
name: GENERATE_SESSION_KEYS_TRACKER_KEY,
|
|
280
568
|
promise: generateSessionKeysPromise
|
|
281
569
|
});
|
|
282
570
|
core.initTrack.track({
|
|
283
|
-
name:
|
|
571
|
+
name: REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY,
|
|
284
572
|
promise: refreshUserStateFromCookiePromise
|
|
285
573
|
});
|
|
286
574
|
try {
|
|
@@ -330,7 +618,7 @@ const createDeferredPromise = ()=>{
|
|
|
330
618
|
/**
|
|
331
619
|
* Checks if all processes are initialized and resolves the main promise if they are.
|
|
332
620
|
*/ const checkIfAllSettled = ()=>{
|
|
333
|
-
const allSettled = Array.from(tracker.values()).every((status)=>status === 'resolved');
|
|
621
|
+
const allSettled = Array.from(tracker.values()).every(({ status })=>status === 'resolved');
|
|
334
622
|
if (!allSettled) return;
|
|
335
623
|
allSettledPromise.resolve();
|
|
336
624
|
};
|
|
@@ -340,19 +628,28 @@ const createDeferredPromise = ()=>{
|
|
|
340
628
|
}
|
|
341
629
|
// Disable tracking in the next node tick
|
|
342
630
|
void Promise.resolve().then(()=>isTrackEnabled = false);
|
|
343
|
-
tracker.set(name,
|
|
631
|
+
tracker.set(name, {
|
|
632
|
+
promise,
|
|
633
|
+
status: 'pending'
|
|
634
|
+
});
|
|
344
635
|
promise.then(()=>{
|
|
345
|
-
tracker.set(name,
|
|
636
|
+
tracker.set(name, {
|
|
637
|
+
promise,
|
|
638
|
+
status: 'resolved'
|
|
639
|
+
});
|
|
346
640
|
eventEmitter.emit('resolved', name);
|
|
347
641
|
checkIfAllSettled();
|
|
348
642
|
}).catch((error)=>{
|
|
349
|
-
tracker.set(name,
|
|
643
|
+
tracker.set(name, {
|
|
644
|
+
promise,
|
|
645
|
+
status: 'failed'
|
|
646
|
+
});
|
|
350
647
|
eventEmitter.emit('failed', name, error);
|
|
351
648
|
allSettledPromise.reject(error);
|
|
352
649
|
});
|
|
353
650
|
};
|
|
354
651
|
const waitForAll = ()=>allSettledPromise.promise;
|
|
355
|
-
const getTracker = ()=>tracker;
|
|
652
|
+
const getTracker = (trackerKey)=>tracker.get(trackerKey);
|
|
356
653
|
return {
|
|
357
654
|
getTracker,
|
|
358
655
|
off: eventEmitter.off.bind(eventEmitter),
|
|
@@ -418,6 +715,63 @@ class UnavailableInServerSideError extends BaseError {
|
|
|
418
715
|
register: (options)=>startRegistration(options)
|
|
419
716
|
});
|
|
420
717
|
|
|
718
|
+
const createDebouncedMutex = ()=>{
|
|
719
|
+
const mutexState = new Map();
|
|
720
|
+
return async ({ lockKey, callback, debounceTime = 0 })=>{
|
|
721
|
+
const resolutionPromise = createDeferredPromise();
|
|
722
|
+
// Prefill the state for this key if it doesn't exist to avoid needing to check for existence later.
|
|
723
|
+
if (!mutexState.has(lockKey)) {
|
|
724
|
+
mutexState.set(lockKey, {
|
|
725
|
+
nextCallback: null,
|
|
726
|
+
queuePromise: Promise.resolve(),
|
|
727
|
+
resolutionPromises: [],
|
|
728
|
+
timer: null
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
const currentState = mutexState.get(lockKey);
|
|
732
|
+
// This should never happen, but we'll assert it for TS safety.
|
|
733
|
+
assertDefined(currentState, `Mutex state for key ${lockKey} not found`);
|
|
734
|
+
currentState.resolutionPromises.push(resolutionPromise);
|
|
735
|
+
if (currentState.timer) {
|
|
736
|
+
clearTimeout(currentState.timer);
|
|
737
|
+
}
|
|
738
|
+
// The last invocation wins. Always.
|
|
739
|
+
currentState.nextCallback = callback;
|
|
740
|
+
const addCallbackToQueue = async ()=>{
|
|
741
|
+
currentState.queuePromise = currentState.queuePromise.then(async ()=>{
|
|
742
|
+
if (!currentState.nextCallback) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
// We can't just use the callback param directly because later invocations
|
|
746
|
+
// should override previous ones.
|
|
747
|
+
// Scenario to illustrate this (none of these will use the timer param for simplicity):
|
|
748
|
+
// 1. Very long running promise callback A runs
|
|
749
|
+
// 2. While it's running, we invoke callback B, which queues itself with "then" and overrides nextCallback with B.
|
|
750
|
+
// 3. While A is still running, we invoke callback C, same thing happens, now nextCallback is C.
|
|
751
|
+
// 4. A resolves, nextCallback is invoked with C.
|
|
752
|
+
// 5. After C resolves, nextCallback is invoked with null, so it doesn't run.
|
|
753
|
+
// Conclusion: B was never executed and only the last invocation runs.
|
|
754
|
+
const { nextCallback } = currentState;
|
|
755
|
+
currentState.nextCallback = null;
|
|
756
|
+
const promisesToResolve = currentState.resolutionPromises;
|
|
757
|
+
currentState.resolutionPromises = [];
|
|
758
|
+
try {
|
|
759
|
+
await nextCallback();
|
|
760
|
+
promisesToResolve.forEach((resolutionPromise)=>resolutionPromise.resolve());
|
|
761
|
+
} catch (error) {
|
|
762
|
+
promisesToResolve.forEach((resolutionPromise)=>resolutionPromise.reject(error));
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
};
|
|
766
|
+
if (debounceTime > 0) {
|
|
767
|
+
currentState.timer = setTimeout(addCallbackToQueue, debounceTime);
|
|
768
|
+
} else {
|
|
769
|
+
await addCallbackToQueue();
|
|
770
|
+
}
|
|
771
|
+
return resolutionPromise.promise;
|
|
772
|
+
};
|
|
773
|
+
};
|
|
774
|
+
|
|
421
775
|
class InvalidStorageValue extends BaseError {
|
|
422
776
|
constructor(key, value){
|
|
423
777
|
super({
|
|
@@ -517,7 +871,8 @@ class InvalidStorageValue extends BaseError {
|
|
|
517
871
|
sessionKeys: null,
|
|
518
872
|
token: null,
|
|
519
873
|
unverifiedWalletAccounts: [],
|
|
520
|
-
user: null
|
|
874
|
+
user: null,
|
|
875
|
+
walletProviderKeyMap: {}
|
|
521
876
|
});
|
|
522
877
|
|
|
523
878
|
/**
|
|
@@ -527,7 +882,9 @@ class InvalidStorageValue extends BaseError {
|
|
|
527
882
|
var _config_coreConfig_apiBaseUrl;
|
|
528
883
|
const apiBaseUrl = (_config_coreConfig_apiBaseUrl = (_config_coreConfig = config.coreConfig) == null ? void 0 : _config_coreConfig.apiBaseUrl) != null ? _config_coreConfig_apiBaseUrl : DEFAULT_API_BASE_URL;
|
|
529
884
|
var _config_coreConfig_logger;
|
|
530
|
-
const logger = (_config_coreConfig_logger = (_config_coreConfig1 = config.coreConfig) == null ? void 0 : _config_coreConfig1.logger) != null ? _config_coreConfig_logger : createLogger(
|
|
885
|
+
const logger = (_config_coreConfig_logger = (_config_coreConfig1 = config.coreConfig) == null ? void 0 : _config_coreConfig1.logger) != null ? _config_coreConfig_logger : createLogger({
|
|
886
|
+
level: config.logLevel
|
|
887
|
+
});
|
|
531
888
|
var _config_coreConfig_storageAdapter;
|
|
532
889
|
const storage = createStorage({
|
|
533
890
|
prefix: `dynamic_${config.environmentId}`,
|
|
@@ -540,6 +897,7 @@ class InvalidStorageValue extends BaseError {
|
|
|
540
897
|
var _config_coreConfig_navigate;
|
|
541
898
|
const navigate = (_config_coreConfig_navigate = (_config_coreConfig5 = config.coreConfig) == null ? void 0 : _config_coreConfig5.navigate) != null ? _config_coreConfig_navigate : createNavigationHandler();
|
|
542
899
|
const state = createObservableState(getInitialState);
|
|
900
|
+
const debouncedMutex = createDebouncedMutex();
|
|
543
901
|
const eventEmitter = createEventEmitter();
|
|
544
902
|
const initTrack = createAsyncTrack();
|
|
545
903
|
const runtimeServices = createRuntimeServices();
|
|
@@ -548,6 +906,7 @@ class InvalidStorageValue extends BaseError {
|
|
|
548
906
|
var _config_coreConfig_getApiHeaders;
|
|
549
907
|
return {
|
|
550
908
|
apiBaseUrl,
|
|
909
|
+
debouncedMutex,
|
|
551
910
|
environmentId: config.environmentId,
|
|
552
911
|
eventEmitter,
|
|
553
912
|
extensions: new Set(),
|
|
@@ -605,8 +964,13 @@ class InvalidStorageValue extends BaseError {
|
|
|
605
964
|
}
|
|
606
965
|
};
|
|
607
966
|
var _config_autoInitialize;
|
|
608
|
-
|
|
967
|
+
// Define if SDK should auto initialize, default to true
|
|
968
|
+
const autoInitialize = (_config_autoInitialize = config.autoInitialize) != null ? _config_autoInitialize : true;
|
|
969
|
+
// Prevent the auto initialization in SSR
|
|
970
|
+
const shouldAutoInitialize = isServerSideRendering() ? false : autoInitialize;
|
|
971
|
+
core.logger.debug('[createDynamicClient] Creating client...');
|
|
609
972
|
if (shouldAutoInitialize) {
|
|
973
|
+
core.logger.debug('[createDynamicClient] Initializing client...');
|
|
610
974
|
void initializeClient(client);
|
|
611
975
|
}
|
|
612
976
|
setDefaultClient(client);
|
|
@@ -649,6 +1013,19 @@ class MissingSocialUrlParamError extends BaseError {
|
|
|
649
1013
|
}
|
|
650
1014
|
}
|
|
651
1015
|
|
|
1016
|
+
class MissingUserVerificationError extends BaseError {
|
|
1017
|
+
constructor({ informationToVerify, message }){
|
|
1018
|
+
super({
|
|
1019
|
+
cause: null,
|
|
1020
|
+
code: 'missing_user_verification_error',
|
|
1021
|
+
docsUrl: null,
|
|
1022
|
+
name: 'MissingUserVerificationError',
|
|
1023
|
+
shortMessage: message != null ? message : `The user is missing verification for ${informationToVerify}. Please verify the user's ${informationToVerify}`
|
|
1024
|
+
});
|
|
1025
|
+
this.informationToVerify = informationToVerify;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
652
1029
|
class NetworkSwitchingUnavailableError extends BaseError {
|
|
653
1030
|
constructor({ walletProviderKey, originalError, extraMessages }){
|
|
654
1031
|
const cause = originalError instanceof Error ? originalError : null;
|
|
@@ -690,6 +1067,18 @@ class NoPasskeyCredentialsFoundError extends BaseError {
|
|
|
690
1067
|
}
|
|
691
1068
|
}
|
|
692
1069
|
|
|
1070
|
+
class NoSmartWalletAccountSignerFoundError extends BaseError {
|
|
1071
|
+
constructor(smartWalletAddress){
|
|
1072
|
+
super({
|
|
1073
|
+
cause: null,
|
|
1074
|
+
code: 'no_smart_wallet_account_signer_found_error',
|
|
1075
|
+
docsUrl: null,
|
|
1076
|
+
name: 'NoSmartWalletAccountSignerFoundError',
|
|
1077
|
+
shortMessage: `No signer wallet account found for smart wallet account ${smartWalletAddress}`
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
693
1082
|
class NoWebAuthNSupportError extends BaseError {
|
|
694
1083
|
constructor(){
|
|
695
1084
|
super({
|
|
@@ -756,30 +1145,19 @@ class WalletAccountAlreadyVerifiedError extends BaseError {
|
|
|
756
1145
|
|
|
757
1146
|
class WalletAccountNotSelectedError extends BaseError {
|
|
758
1147
|
constructor(params){
|
|
1148
|
+
const currentAccountInfo = params.selectedAddress ? ` (currently ${params.selectedAddress})` : '';
|
|
759
1149
|
super({
|
|
760
1150
|
cause: null,
|
|
761
1151
|
code: 'wallet_account_not_selected_error',
|
|
762
1152
|
docsUrl: null,
|
|
763
1153
|
name: 'WalletAccountNotSelected',
|
|
764
|
-
shortMessage: `This wallet only supports signing with its selected account
|
|
1154
|
+
shortMessage: `This wallet only supports signing with its selected account${currentAccountInfo}. Please select account ${params.expectedAddress} in your wallet app and try again`
|
|
765
1155
|
});
|
|
766
1156
|
this.expectedAddress = params.expectedAddress;
|
|
767
1157
|
this.selectedAddress = params.selectedAddress;
|
|
768
1158
|
}
|
|
769
1159
|
}
|
|
770
1160
|
|
|
771
|
-
class WalletAlreadyLinkedToAnotherUserError extends BaseError {
|
|
772
|
-
constructor({ cause }){
|
|
773
|
-
super({
|
|
774
|
-
cause,
|
|
775
|
-
code: 'wallet_already_linked_to_another_user_error',
|
|
776
|
-
docsUrl: null,
|
|
777
|
-
name: 'WalletAlreadyLinkedToAnotherUserError',
|
|
778
|
-
shortMessage: 'This wallet is already linked to another user'
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
|
|
783
1161
|
class WalletProviderMethodUnavailableError extends BaseError {
|
|
784
1162
|
constructor({ methodName, walletProviderKey }){
|
|
785
1163
|
super({
|
|
@@ -862,12 +1240,13 @@ const getPasskeyRegistrationOptions = async (client)=>{
|
|
|
862
1240
|
return options;
|
|
863
1241
|
};
|
|
864
1242
|
|
|
865
|
-
const serverRegisterPasskey = async ({ registration }, client)=>{
|
|
1243
|
+
const serverRegisterPasskey = async ({ registration, createMfaToken }, client)=>{
|
|
866
1244
|
const core = getCore(client);
|
|
867
1245
|
const apiClient = createApiClient({}, client);
|
|
868
1246
|
const response = await apiClient.registerPasskey({
|
|
869
1247
|
environmentId: core.environmentId,
|
|
870
1248
|
passkeyRegisterRequest: _extends({}, registration, {
|
|
1249
|
+
createMfaToken,
|
|
871
1250
|
response: _extends({}, registration.response, {
|
|
872
1251
|
clientDataJson: registration.response.clientDataJSON
|
|
873
1252
|
})
|
|
@@ -883,10 +1262,11 @@ const serverRegisterPasskey = async ({ registration }, client)=>{
|
|
|
883
1262
|
* passwordless authentication. The user will be prompted to create a passkey
|
|
884
1263
|
* using their device's biometric authentication or security key.
|
|
885
1264
|
*
|
|
1265
|
+
* @param [params.createMfaToken] - Optional configuration for MFA token creation.
|
|
886
1266
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
887
1267
|
* @returns A promise that resolves to the registration response.
|
|
888
1268
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
889
|
-
*/ const registerPasskey = async (client = getDefaultClient())=>{
|
|
1269
|
+
*/ const registerPasskey = async ({ createMfaToken } = {}, client = getDefaultClient())=>{
|
|
890
1270
|
const core = getCore(client);
|
|
891
1271
|
if (!core.passkey.isSupported()) {
|
|
892
1272
|
throw new NoWebAuthNSupportError();
|
|
@@ -896,6 +1276,7 @@ const serverRegisterPasskey = async ({ registration }, client)=>{
|
|
|
896
1276
|
optionsJSON: options
|
|
897
1277
|
});
|
|
898
1278
|
const response = await serverRegisterPasskey({
|
|
1279
|
+
createMfaToken,
|
|
899
1280
|
registration
|
|
900
1281
|
}, client);
|
|
901
1282
|
updateAuthFromVerifyResponse({
|
|
@@ -904,11 +1285,12 @@ const serverRegisterPasskey = async ({ registration }, client)=>{
|
|
|
904
1285
|
return response;
|
|
905
1286
|
};
|
|
906
1287
|
|
|
907
|
-
const getPasskeyAuthenticationSignInOptions = async (client)=>{
|
|
1288
|
+
const getPasskeyAuthenticationSignInOptions = async ({ relatedOriginRpId } = {}, client)=>{
|
|
908
1289
|
const core = getCore(client);
|
|
909
1290
|
const apiClient = createApiClient({}, client);
|
|
910
1291
|
const options = await apiClient.getPasskeyAuthenticationSigninOptions({
|
|
911
|
-
environmentId: core.environmentId
|
|
1292
|
+
environmentId: core.environmentId,
|
|
1293
|
+
relatedOriginRpId: relatedOriginRpId
|
|
912
1294
|
});
|
|
913
1295
|
return options;
|
|
914
1296
|
};
|
|
@@ -938,12 +1320,14 @@ const serverSigninPasskey = async ({ authentication, createMfaToken }, client)=>
|
|
|
938
1320
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
939
1321
|
* @returns A promise that resolves to the authentication response.
|
|
940
1322
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
941
|
-
*/ const signInWithPasskey = async (client = getDefaultClient())=>{
|
|
1323
|
+
*/ const signInWithPasskey = async ({ relatedOriginRpId } = {}, client = getDefaultClient())=>{
|
|
942
1324
|
const core = getCore(client);
|
|
943
1325
|
if (!core.passkey.isSupported()) {
|
|
944
1326
|
throw new NoWebAuthNSupportError();
|
|
945
1327
|
}
|
|
946
|
-
const options = await getPasskeyAuthenticationSignInOptions(
|
|
1328
|
+
const options = await getPasskeyAuthenticationSignInOptions({
|
|
1329
|
+
relatedOriginRpId
|
|
1330
|
+
}, client);
|
|
947
1331
|
const formattedOptions = _extends({}, options);
|
|
948
1332
|
const authentication = await core.passkey.authenticate({
|
|
949
1333
|
optionsJSON: formattedOptions
|
|
@@ -957,88 +1341,46 @@ const serverSigninPasskey = async ({ authentication, createMfaToken }, client)=>
|
|
|
957
1341
|
return response;
|
|
958
1342
|
};
|
|
959
1343
|
|
|
960
|
-
/** The schema to track the state of the OAuth flow. */ const redirectStateStorageSchema = createStorageKeySchema({
|
|
961
|
-
key: 'redirectState',
|
|
962
|
-
schema: z.object({
|
|
963
|
-
codeVerifier: z.optional(z.string()),
|
|
964
|
-
provider: z.enum(ProviderEnum),
|
|
965
|
-
state: z.string()
|
|
966
|
-
})
|
|
967
|
-
});
|
|
968
|
-
|
|
969
1344
|
/**
|
|
970
|
-
*
|
|
1345
|
+
* Retrieves all social accounts associated with the current user.
|
|
971
1346
|
*
|
|
972
|
-
* This function processes the OAuth callback URL with authorization codes
|
|
973
|
-
* and completes the user authentication with the social provider.
|
|
974
|
-
*
|
|
975
|
-
* @param params.url - The callback URL containing OAuth response parameters.
|
|
976
1347
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
977
|
-
* @returns
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
const
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
throw new MissingRedirectStorageStateError();
|
|
995
|
-
}
|
|
996
|
-
if (storedSocialRedirectState.state !== dynamicOauthState) {
|
|
997
|
-
throw new InvalidRedirectStorageStateError();
|
|
998
|
-
}
|
|
999
|
-
const { provider, codeVerifier } = storedSocialRedirectState;
|
|
1000
|
-
await core.storage.removeItem(redirectStateStorageSchema);
|
|
1001
|
-
const response = await apiClient.oauthSignIn({
|
|
1002
|
-
environmentId: core.environmentId,
|
|
1003
|
-
oauthRequest: {
|
|
1004
|
-
captchaToken: consumeCaptchaToken(client),
|
|
1005
|
-
code: dynamicOauthCode,
|
|
1006
|
-
codeVerifier,
|
|
1007
|
-
state: dynamicOauthState
|
|
1008
|
-
},
|
|
1009
|
-
providerType: provider
|
|
1348
|
+
* @returns An array of `SocialAccount` objects associated with the user.
|
|
1349
|
+
*/ const getUserSocialAccounts = (client = getDefaultClient())=>{
|
|
1350
|
+
const { user } = client;
|
|
1351
|
+
assertDefined(user, 'User is not authenticated');
|
|
1352
|
+
var _user_verifiedCredentials_filter;
|
|
1353
|
+
const socialCredentials = (_user_verifiedCredentials_filter = user.verifiedCredentials.filter((credential)=>credential.format === JwtVerifiedCredentialFormatEnum.Oauth)) != null ? _user_verifiedCredentials_filter : [];
|
|
1354
|
+
return socialCredentials.map((credential)=>{
|
|
1355
|
+
var _credential_oauthAccountId, _credential_oauthDisplayName, _credential_oauthEmails, _credential_oauthAccountPhotos, _credential_oauthUsername;
|
|
1356
|
+
return {
|
|
1357
|
+
accountId: (_credential_oauthAccountId = credential.oauthAccountId) != null ? _credential_oauthAccountId : undefined,
|
|
1358
|
+
displayName: (_credential_oauthDisplayName = credential.oauthDisplayName) != null ? _credential_oauthDisplayName : undefined,
|
|
1359
|
+
emails: (_credential_oauthEmails = credential.oauthEmails) != null ? _credential_oauthEmails : [],
|
|
1360
|
+
photos: (_credential_oauthAccountPhotos = credential.oauthAccountPhotos) != null ? _credential_oauthAccountPhotos : [],
|
|
1361
|
+
provider: credential.oauthProvider,
|
|
1362
|
+
username: (_credential_oauthUsername = credential.oauthUsername) != null ? _credential_oauthUsername : undefined,
|
|
1363
|
+
verifiedCredentialId: credential.id
|
|
1364
|
+
};
|
|
1010
1365
|
});
|
|
1011
|
-
updateAuthFromVerifyResponse({
|
|
1012
|
-
response
|
|
1013
|
-
}, client);
|
|
1014
|
-
return response.user;
|
|
1015
1366
|
};
|
|
1016
1367
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
*
|
|
1023
|
-
* @param params.url - The URL to check for OAuth redirect parameters.
|
|
1024
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1025
|
-
* @returns A promise that resolves to true if the URL is an OAuth redirect, false otherwise.
|
|
1026
|
-
*/ const detectOAuthRedirect = async ({ url }, client = getDefaultClient())=>{
|
|
1027
|
-
const core = getCore(client);
|
|
1028
|
-
const dynamicOauthState = url.searchParams.get('dynamicOauthState');
|
|
1029
|
-
const dynamicOauthCode = url.searchParams.get('dynamicOauthCode');
|
|
1030
|
-
if (!dynamicOauthState || !dynamicOauthCode) {
|
|
1031
|
-
return false;
|
|
1032
|
-
}
|
|
1033
|
-
// Wait for SDK to load
|
|
1034
|
-
await core.initTrack.waitForAll();
|
|
1035
|
-
const storedSocialRedirectState = await core.storage.getItem(redirectStateStorageSchema);
|
|
1036
|
-
if (!storedSocialRedirectState || storedSocialRedirectState.state !== dynamicOauthState) {
|
|
1037
|
-
return false;
|
|
1038
|
-
}
|
|
1039
|
-
return true;
|
|
1368
|
+
const removeDynamicOauthParamsFromUrl = (url)=>{
|
|
1369
|
+
const urlObject = new URL(url);
|
|
1370
|
+
urlObject.searchParams.delete('dynamicOauthState');
|
|
1371
|
+
urlObject.searchParams.delete('dynamicOauthCode');
|
|
1372
|
+
return urlObject.toString();
|
|
1040
1373
|
};
|
|
1041
1374
|
|
|
1375
|
+
/** The schema to track the state of the OAuth flow. */ const redirectStateStorageKeySchema = createStorageKeySchema({
|
|
1376
|
+
key: 'redirectState',
|
|
1377
|
+
schema: z.object({
|
|
1378
|
+
codeVerifier: z.optional(z.string()),
|
|
1379
|
+
provider: z.enum(ProviderEnum),
|
|
1380
|
+
state: z.string()
|
|
1381
|
+
})
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1042
1384
|
const digestSHA256 = (str)=>{
|
|
1043
1385
|
const encoder = new TextEncoder();
|
|
1044
1386
|
const data = encoder.encode(str);
|
|
@@ -1126,43 +1468,175 @@ const providersRequiringPkce = [
|
|
|
1126
1468
|
socialProviderUrl.searchParams.set('code_challenge', encodeBase64Url(digest));
|
|
1127
1469
|
socialProviderUrl.searchParams.set('code_challenge_method', 'S256');
|
|
1128
1470
|
}
|
|
1129
|
-
return {
|
|
1130
|
-
codeVerifier: usingPkce ? codeVerifier : undefined,
|
|
1131
|
-
state,
|
|
1132
|
-
url: socialProviderUrl
|
|
1133
|
-
};
|
|
1471
|
+
return {
|
|
1472
|
+
codeVerifier: usingPkce ? codeVerifier : undefined,
|
|
1473
|
+
state,
|
|
1474
|
+
url: socialProviderUrl
|
|
1475
|
+
};
|
|
1476
|
+
};
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* Initiates social authentication by redirecting to the OAuth provider.
|
|
1480
|
+
*
|
|
1481
|
+
* This function redirects the user to the specified social provider's
|
|
1482
|
+
* authorization page to complete OAuth authentication flow.
|
|
1483
|
+
* After the oauth flow is complete, the user will be redirected back to your app.
|
|
1484
|
+
* You can then call `detectOAuthRedirect` to check if the user got redirected back to your app due to the oauth flow,
|
|
1485
|
+
* and finally call `completeSocialAuthentication` to complete the social authentication flow.
|
|
1486
|
+
*
|
|
1487
|
+
* @param params.provider - The social provider to authenticate with (e.g., 'google', 'github').
|
|
1488
|
+
* @param params.redirectUrl - The URL to redirect back to after authentication.
|
|
1489
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1490
|
+
*/ const authenticateWithSocial = async ({ provider, redirectUrl }, client = getDefaultClient())=>{
|
|
1491
|
+
const core = getCore(client);
|
|
1492
|
+
const apiClient = createApiClient({}, client);
|
|
1493
|
+
await core.initTrack.waitForAll();
|
|
1494
|
+
const providerType = provider;
|
|
1495
|
+
const { url, state, codeVerifier } = await buildOAuthUrl(core, providerType);
|
|
1496
|
+
await apiClient.initAuth({
|
|
1497
|
+
environmentId: core.environmentId,
|
|
1498
|
+
oauthInitAuthRequest: {
|
|
1499
|
+
redirectUrl: removeDynamicOauthParamsFromUrl(redirectUrl),
|
|
1500
|
+
state
|
|
1501
|
+
},
|
|
1502
|
+
providerType
|
|
1503
|
+
});
|
|
1504
|
+
await core.storage.setItem(redirectStateStorageKeySchema, {
|
|
1505
|
+
codeVerifier,
|
|
1506
|
+
provider: providerType,
|
|
1507
|
+
state
|
|
1508
|
+
});
|
|
1509
|
+
await core.navigate(url.toString());
|
|
1510
|
+
};
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* Completes the social authentication flow after OAuth redirect.
|
|
1514
|
+
*
|
|
1515
|
+
* This function processes the OAuth callback URL with authorization codes
|
|
1516
|
+
* and completes the user authentication with the social provider.
|
|
1517
|
+
*
|
|
1518
|
+
* @param params.url - The callback URL containing OAuth response parameters.
|
|
1519
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1520
|
+
* @returns A promise that resolves to the authenticated user or null.
|
|
1521
|
+
* @throws MissingSocialUrlParamError If required OAuth parameters are missing.
|
|
1522
|
+
* @throws InvalidRedirectStorageStateError If the stored state doesn't match.
|
|
1523
|
+
*/ const completeSocialAuthentication = async ({ url }, client = getDefaultClient())=>{
|
|
1524
|
+
const core = getCore(client);
|
|
1525
|
+
const apiClient = createApiClient({}, client);
|
|
1526
|
+
await core.initTrack.waitForAll();
|
|
1527
|
+
const dynamicOauthState = url.searchParams.get('dynamicOauthState');
|
|
1528
|
+
const dynamicOauthCode = url.searchParams.get('dynamicOauthCode');
|
|
1529
|
+
if (!dynamicOauthState) {
|
|
1530
|
+
throw new MissingSocialUrlParamError('dynamicOauthState');
|
|
1531
|
+
}
|
|
1532
|
+
if (!dynamicOauthCode) {
|
|
1533
|
+
throw new MissingSocialUrlParamError('dynamicOauthCode');
|
|
1534
|
+
}
|
|
1535
|
+
const storedSocialRedirectState = await core.storage.getItem(redirectStateStorageKeySchema);
|
|
1536
|
+
if (!storedSocialRedirectState) {
|
|
1537
|
+
throw new MissingRedirectStorageStateError();
|
|
1538
|
+
}
|
|
1539
|
+
if (storedSocialRedirectState.state !== dynamicOauthState) {
|
|
1540
|
+
throw new InvalidRedirectStorageStateError();
|
|
1541
|
+
}
|
|
1542
|
+
const { provider, codeVerifier } = storedSocialRedirectState;
|
|
1543
|
+
await core.storage.removeItem(redirectStateStorageKeySchema);
|
|
1544
|
+
let response;
|
|
1545
|
+
// if user is alreadyauthenticated, we're verifying the social auth to link it to the user
|
|
1546
|
+
if (client.user) {
|
|
1547
|
+
response = await apiClient.oauthVerify({
|
|
1548
|
+
environmentId: core.environmentId,
|
|
1549
|
+
oauthRequest: {
|
|
1550
|
+
code: dynamicOauthCode,
|
|
1551
|
+
codeVerifier,
|
|
1552
|
+
state: dynamicOauthState
|
|
1553
|
+
},
|
|
1554
|
+
providerType: provider
|
|
1555
|
+
});
|
|
1556
|
+
} else {
|
|
1557
|
+
// if user is not authenticated, we're signing in with the social auth
|
|
1558
|
+
response = await apiClient.oauthSignIn({
|
|
1559
|
+
environmentId: core.environmentId,
|
|
1560
|
+
oauthRequest: {
|
|
1561
|
+
captchaToken: consumeCaptchaToken(client),
|
|
1562
|
+
code: dynamicOauthCode,
|
|
1563
|
+
codeVerifier,
|
|
1564
|
+
state: dynamicOauthState
|
|
1565
|
+
},
|
|
1566
|
+
providerType: provider
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
updateAuthFromVerifyResponse({
|
|
1570
|
+
response
|
|
1571
|
+
}, client);
|
|
1572
|
+
return response.user;
|
|
1573
|
+
};
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* Detects if the current URL is an OAuth redirect from a social provider.
|
|
1577
|
+
*
|
|
1578
|
+
* This function examines the URL parameters to determine if it contains
|
|
1579
|
+
* OAuth callback data from a social authentication flow.
|
|
1580
|
+
*
|
|
1581
|
+
* @param params.url - The URL to check for OAuth redirect parameters.
|
|
1582
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1583
|
+
* @returns A promise that resolves to true if the URL is an OAuth redirect, false otherwise.
|
|
1584
|
+
*/ const detectOAuthRedirect = async ({ url }, client = getDefaultClient())=>{
|
|
1585
|
+
const core = getCore(client);
|
|
1586
|
+
const dynamicOauthState = url.searchParams.get('dynamicOauthState');
|
|
1587
|
+
const dynamicOauthCode = url.searchParams.get('dynamicOauthCode');
|
|
1588
|
+
if (!dynamicOauthState || !dynamicOauthCode) {
|
|
1589
|
+
return false;
|
|
1590
|
+
}
|
|
1591
|
+
// Wait for SDK to load
|
|
1592
|
+
await core.initTrack.waitForAll();
|
|
1593
|
+
const storedSocialRedirectState = await core.storage.getItem(redirectStateStorageKeySchema);
|
|
1594
|
+
if (!storedSocialRedirectState || storedSocialRedirectState.state !== dynamicOauthState) {
|
|
1595
|
+
return false;
|
|
1596
|
+
}
|
|
1597
|
+
return true;
|
|
1598
|
+
};
|
|
1599
|
+
|
|
1600
|
+
/**
|
|
1601
|
+
* Get the primary wallet account.
|
|
1602
|
+
* The primary wallet account is the one that was last selected by the user.
|
|
1603
|
+
* This information is stored in both unverified and verified wallet accounts.
|
|
1604
|
+
* This function consolidates this information to determine which wallet was most recently selected.
|
|
1605
|
+
*/ const getPrimaryWalletAccount = (client = getDefaultClient())=>{
|
|
1606
|
+
const walletAccounts = getWalletAccounts(client);
|
|
1607
|
+
const sortedLastSelectedWalletAccounts = walletAccounts.filter((walletAccount)=>Boolean(walletAccount.lastSelectedAt)).sort((a, b)=>b.lastSelectedAt.getTime() - a.lastSelectedAt.getTime());
|
|
1608
|
+
if (sortedLastSelectedWalletAccounts.length === 0) {
|
|
1609
|
+
return null;
|
|
1610
|
+
}
|
|
1611
|
+
const [primaryWalletAccount] = sortedLastSelectedWalletAccounts;
|
|
1612
|
+
return primaryWalletAccount;
|
|
1134
1613
|
};
|
|
1135
1614
|
|
|
1136
1615
|
/**
|
|
1137
|
-
*
|
|
1138
|
-
*
|
|
1139
|
-
* This function redirects the user to the specified social provider's
|
|
1140
|
-
* authorization page to complete OAuth authentication flow.
|
|
1141
|
-
* After the oauth flow is complete, the user will be redirected back to your app.
|
|
1616
|
+
* Unlinks a social account from the user's account.
|
|
1142
1617
|
*
|
|
1143
|
-
* @param params.
|
|
1144
|
-
* @param params.redirectUrl - The URL to redirect back to after authentication.
|
|
1618
|
+
* @param params.verifiedCredentialId - The verified credential ID of the social account to unlink.
|
|
1145
1619
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1146
|
-
|
|
1620
|
+
* @returns A promise that resolves to the verify response.
|
|
1621
|
+
*/ const unlinkSocialAccount = async ({ verifiedCredentialId }, client = getDefaultClient())=>{
|
|
1622
|
+
var _primaryWalletAccount_verifiedCredentialId;
|
|
1147
1623
|
const core = getCore(client);
|
|
1148
1624
|
const apiClient = createApiClient({}, client);
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1625
|
+
// the api seems to require us to pass the primary wallet id when
|
|
1626
|
+
// unlinking a social account if the user has wallets
|
|
1627
|
+
const primaryWalletAccount = getPrimaryWalletAccount(client);
|
|
1628
|
+
const walletId = primaryWalletAccount == null ? void 0 : (_primaryWalletAccount_verifiedCredentialId = primaryWalletAccount.verifiedCredentialId) == null ? void 0 : _primaryWalletAccount_verifiedCredentialId.replace('-zerodev', '');
|
|
1629
|
+
const response = await apiClient.verifyUnlink({
|
|
1153
1630
|
environmentId: core.environmentId,
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
}
|
|
1158
|
-
providerType
|
|
1159
|
-
});
|
|
1160
|
-
await core.storage.setItem(redirectStateStorageSchema, {
|
|
1161
|
-
codeVerifier,
|
|
1162
|
-
provider: providerType,
|
|
1163
|
-
state
|
|
1631
|
+
verifyUnlinkRequest: {
|
|
1632
|
+
verifiedCredentialId,
|
|
1633
|
+
walletId: walletId != null ? walletId : undefined
|
|
1634
|
+
}
|
|
1164
1635
|
});
|
|
1165
|
-
|
|
1636
|
+
updateAuthFromVerifyResponse({
|
|
1637
|
+
response
|
|
1638
|
+
}, client);
|
|
1639
|
+
return response;
|
|
1166
1640
|
};
|
|
1167
1641
|
|
|
1168
1642
|
/**
|
|
@@ -1184,6 +1658,232 @@ const providersRequiringPkce = [
|
|
|
1184
1658
|
return response.chainBalances;
|
|
1185
1659
|
};
|
|
1186
1660
|
|
|
1661
|
+
/**
|
|
1662
|
+
* Adds a listener for Coinbase onramp order events.
|
|
1663
|
+
*
|
|
1664
|
+
* @param params.listener - The listener function to call when an event is received.
|
|
1665
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1666
|
+
* @returns A function to remove the listener.
|
|
1667
|
+
* @throws {ValueMustBeDefinedError} If the window is not available.
|
|
1668
|
+
* @docs https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api#events-names
|
|
1669
|
+
*/ const addCoinbaseOnrampOrderEventListener = ({ listener }, client = getDefaultClient())=>{
|
|
1670
|
+
const core = getCore(client);
|
|
1671
|
+
if (typeof window === 'undefined') {
|
|
1672
|
+
throw new ValueMustBeDefinedError('Window is not available to listen for Coinbase onramp order events');
|
|
1673
|
+
}
|
|
1674
|
+
const handleMessageEvent = (event)=>{
|
|
1675
|
+
if (event.origin !== 'https://pay.coinbase.com') {
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
core.logger.debug('[addCoinbaseOnrampOrderEventListener] pay.coinbase.com event received', {
|
|
1679
|
+
event
|
|
1680
|
+
});
|
|
1681
|
+
try {
|
|
1682
|
+
var _coinbaseOnrampOrderEventData_eventName;
|
|
1683
|
+
const coinbaseOnrampOrderEventData = JSON.parse(event.data);
|
|
1684
|
+
if (!((_coinbaseOnrampOrderEventData_eventName = coinbaseOnrampOrderEventData.eventName) == null ? void 0 : _coinbaseOnrampOrderEventData_eventName.startsWith('onramp_api.'))) {
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
listener({
|
|
1688
|
+
data: coinbaseOnrampOrderEventData.data,
|
|
1689
|
+
eventName: coinbaseOnrampOrderEventData.eventName
|
|
1690
|
+
});
|
|
1691
|
+
} catch (error) {
|
|
1692
|
+
core.logger.debug('[addCoinbaseOnrampOrderEventListener] Failed to parse Coinbase onramp order event data', {
|
|
1693
|
+
error
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
};
|
|
1697
|
+
window.addEventListener('message', handleMessageEvent);
|
|
1698
|
+
return ()=>{
|
|
1699
|
+
window.removeEventListener('message', handleMessageEvent);
|
|
1700
|
+
};
|
|
1701
|
+
};
|
|
1702
|
+
|
|
1703
|
+
function _object_without_properties_loose(source, excluded) {
|
|
1704
|
+
if (source == null) return {};
|
|
1705
|
+
var target = {};
|
|
1706
|
+
var sourceKeys = Object.keys(source);
|
|
1707
|
+
var key, i;
|
|
1708
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
1709
|
+
key = sourceKeys[i];
|
|
1710
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
1711
|
+
target[key] = source[key];
|
|
1712
|
+
}
|
|
1713
|
+
return target;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* This function is used to get a list of fields that are missing verification for a Coinbase onramp order
|
|
1718
|
+
*
|
|
1719
|
+
* - If the user is missing information for an email or phone number, the field will be returned with the error code MISSING_INFORMATION
|
|
1720
|
+
* - If the user is missing verification for an email or phone number, the field will be returned with the error code MISSING_VERIFICATION
|
|
1721
|
+
* and the existing unverified email or phone number will be included in the data field.
|
|
1722
|
+
* - If the user's phone number has not been verified in the last 60 days, the field will be returned with the error code VERIFICATION_EXPIRED
|
|
1723
|
+
* and the existing phone number will be included in the data field.
|
|
1724
|
+
*
|
|
1725
|
+
* @param params.paymentMethod - The payment method that will be used to create the onramp order
|
|
1726
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1727
|
+
* @returns FieldMissingVerificationForCoinbaseOnramp[] - An array of fields that are missing verification for a Coinbase onramp order
|
|
1728
|
+
* @throws {InvalidParamError} - If the payment method is not valid
|
|
1729
|
+
* @throws {ValueMustBeDefinedError} - If the user is not authenticated
|
|
1730
|
+
*/ const getMissingVerificationForCoinbaseOnrampOrder = ({ paymentMethod }, client = getDefaultClient())=>{
|
|
1731
|
+
// adding the payment method as a param for now just so a user has to pass an object as the first param
|
|
1732
|
+
// that way, when we add more payment methods, we can easily add them to the param object
|
|
1733
|
+
// and not have to change the function signature
|
|
1734
|
+
if (paymentMethod !== 'GUEST_CHECKOUT_APPLE_PAY') {
|
|
1735
|
+
throw new InvalidParamError(`Invalid payment method: ${paymentMethod}`);
|
|
1736
|
+
}
|
|
1737
|
+
const { user } = client;
|
|
1738
|
+
assertDefined(user, 'User is not authenticated');
|
|
1739
|
+
const fieldsMissingVerification = [];
|
|
1740
|
+
const emailVerifiedCredential = user.verifiedCredentials.find((credential)=>credential.format === JwtVerifiedCredentialFormatEnum.Email);
|
|
1741
|
+
if (!user.email) {
|
|
1742
|
+
// when user has no email at all (verified or not)
|
|
1743
|
+
fieldsMissingVerification.push({
|
|
1744
|
+
errorCode: 'MISSING_INFORMATION',
|
|
1745
|
+
field: 'email'
|
|
1746
|
+
});
|
|
1747
|
+
} else if (!emailVerifiedCredential) {
|
|
1748
|
+
// when user has an email but it is not verified
|
|
1749
|
+
fieldsMissingVerification.push({
|
|
1750
|
+
data: user.email,
|
|
1751
|
+
errorCode: 'MISSING_VERIFICATION',
|
|
1752
|
+
field: 'email'
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
const phoneVerifiedCredential = user.verifiedCredentials.find((credential)=>credential.format === JwtVerifiedCredentialFormatEnum.PhoneNumber);
|
|
1756
|
+
const phoneNumberVerifiedInPast60Days = (phoneVerifiedCredential == null ? void 0 : phoneVerifiedCredential.verifiedAt) && phoneVerifiedCredential.verifiedAt >= new Date(Date.now() - 60 * 24 * 60 * 60 * 1000);
|
|
1757
|
+
if (!user.phoneNumber) {
|
|
1758
|
+
// when user has no phone number at all (verified or not)
|
|
1759
|
+
fieldsMissingVerification.push({
|
|
1760
|
+
errorCode: 'MISSING_INFORMATION',
|
|
1761
|
+
field: 'phoneNumber'
|
|
1762
|
+
});
|
|
1763
|
+
} else if (!phoneVerifiedCredential) {
|
|
1764
|
+
// when user has a phone number but it is not verified
|
|
1765
|
+
fieldsMissingVerification.push({
|
|
1766
|
+
data: user.phoneNumber,
|
|
1767
|
+
errorCode: 'MISSING_VERIFICATION',
|
|
1768
|
+
field: 'phoneNumber'
|
|
1769
|
+
});
|
|
1770
|
+
} else if (!phoneNumberVerifiedInPast60Days) {
|
|
1771
|
+
// when user has a verified phone number but it is not verified in the last 60 days
|
|
1772
|
+
fieldsMissingVerification.push({
|
|
1773
|
+
data: user.phoneNumber,
|
|
1774
|
+
errorCode: 'VERIFICATION_EXPIRED',
|
|
1775
|
+
field: 'phoneNumber'
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
return fieldsMissingVerification;
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
|
+
const validateUserCredentialsForCoinbaseOnrampOrder = (client)=>{
|
|
1782
|
+
const { user } = client;
|
|
1783
|
+
assertDefined(user, 'User is not authenticated');
|
|
1784
|
+
const fieldsMissingVerification = getMissingVerificationForCoinbaseOnrampOrder({
|
|
1785
|
+
paymentMethod: 'GUEST_CHECKOUT_APPLE_PAY'
|
|
1786
|
+
}, client);
|
|
1787
|
+
const missingEmailVerification = fieldsMissingVerification.find((field)=>field.field === 'email');
|
|
1788
|
+
if (missingEmailVerification) {
|
|
1789
|
+
throw new MissingUserVerificationError({
|
|
1790
|
+
informationToVerify: 'email',
|
|
1791
|
+
message: 'User must have a verified email to create a Coinbase onramp order'
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
const missingPhoneNumberVerification = fieldsMissingVerification.find((field)=>field.field === 'phoneNumber');
|
|
1795
|
+
if (missingPhoneNumberVerification && missingPhoneNumberVerification.errorCode !== 'VERIFICATION_EXPIRED') {
|
|
1796
|
+
throw new MissingUserVerificationError({
|
|
1797
|
+
informationToVerify: 'phoneNumber',
|
|
1798
|
+
message: 'User must have a verified phone number to create a Coinbase onramp order'
|
|
1799
|
+
});
|
|
1800
|
+
}
|
|
1801
|
+
// this is a requirement for Coinbase Onramp
|
|
1802
|
+
// https://docs.cdp.coinbase.com/api-reference/v2/rest-api/onramp/create-an-onramp-order#body-phone-number-verified-at
|
|
1803
|
+
if (missingPhoneNumberVerification && missingPhoneNumberVerification.errorCode === 'VERIFICATION_EXPIRED') {
|
|
1804
|
+
throw new MissingUserVerificationError({
|
|
1805
|
+
informationToVerify: 'phoneNumber',
|
|
1806
|
+
message: "The user's phone number has not been verified in the last 60 days. Please re-verify the user's phone number"
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
return user;
|
|
1810
|
+
};
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* Creates a Coinbase onramp order
|
|
1814
|
+
*
|
|
1815
|
+
* @param orderParams CoinbaseCreateOnrampOrderRequest - The parameters for the onramp order.
|
|
1816
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1817
|
+
* @returns The created order
|
|
1818
|
+
* @throws {MissingUserVerificationError} If the user is missing verification for email or phone
|
|
1819
|
+
*/ const createCoinbaseOnrampOrder = async (orderParams, client = getDefaultClient())=>{
|
|
1820
|
+
const user = validateUserCredentialsForCoinbaseOnrampOrder(client);
|
|
1821
|
+
const core = getCore(client);
|
|
1822
|
+
const apiClient = createApiClient({
|
|
1823
|
+
includeMfaToken: true
|
|
1824
|
+
}, client);
|
|
1825
|
+
const { isSandbox } = orderParams, restOrderParams = _object_without_properties_loose(orderParams, [
|
|
1826
|
+
"isSandbox"
|
|
1827
|
+
]);
|
|
1828
|
+
var _orderParams_partnerUserRef;
|
|
1829
|
+
const orderResponse = await apiClient.createCoinbaseOnrampOrder({
|
|
1830
|
+
coinbaseOnrampOrderCreateRequest: _extends({}, restOrderParams, {
|
|
1831
|
+
// to create a sandbox order, we need to prefix the partner user ref with 'sandbox-'
|
|
1832
|
+
// https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api#testing
|
|
1833
|
+
partnerUserRef: (_orderParams_partnerUserRef = orderParams.partnerUserRef) != null ? _orderParams_partnerUserRef : isSandbox ? `sandbox-${user.id}` : user.id,
|
|
1834
|
+
paymentMethod: orderParams.paymentMethod
|
|
1835
|
+
}),
|
|
1836
|
+
environmentId: core.environmentId
|
|
1837
|
+
});
|
|
1838
|
+
if (!isSandbox || !orderResponse.paymentLink) {
|
|
1839
|
+
return orderResponse;
|
|
1840
|
+
}
|
|
1841
|
+
return _extends({}, orderResponse, {
|
|
1842
|
+
paymentLink: _extends({}, orderResponse.paymentLink, {
|
|
1843
|
+
url: `${orderResponse.paymentLink.url}&useApplePaySandbox=true`
|
|
1844
|
+
})
|
|
1845
|
+
});
|
|
1846
|
+
};
|
|
1847
|
+
|
|
1848
|
+
/**
|
|
1849
|
+
* Gets a Coinbase buy URL
|
|
1850
|
+
*
|
|
1851
|
+
* @param buyUrlParams CoinbaseOnrampGetBuyUrlRequest - The parameters for the buy URL.
|
|
1852
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1853
|
+
* @returns an object containing the buy URL
|
|
1854
|
+
*/ const getCoinbaseBuyUrl = async (buyUrlParams, client = getDefaultClient())=>{
|
|
1855
|
+
const core = getCore(client);
|
|
1856
|
+
const apiClient = createApiClient({
|
|
1857
|
+
includeMfaToken: true
|
|
1858
|
+
}, client);
|
|
1859
|
+
const response = await apiClient.generateCoinbaseOnrampBuyUrl({
|
|
1860
|
+
coinbaseOnrampGetBuyUrlRequest: buyUrlParams,
|
|
1861
|
+
environmentId: core.environmentId
|
|
1862
|
+
});
|
|
1863
|
+
return response;
|
|
1864
|
+
};
|
|
1865
|
+
|
|
1866
|
+
/**
|
|
1867
|
+
* Creates a crypto.com payment
|
|
1868
|
+
*
|
|
1869
|
+
* @param paymentParams CryptoDotComPaymentCreateRequest - The parameters for the payment.
|
|
1870
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1871
|
+
* @returns The created payment
|
|
1872
|
+
*/ const createCryptoDotComPayment = async (paymentParams, client = getDefaultClient())=>{
|
|
1873
|
+
const core = getCore(client);
|
|
1874
|
+
const apiClient = createApiClient({
|
|
1875
|
+
includeMfaToken: true
|
|
1876
|
+
}, client);
|
|
1877
|
+
const response = await apiClient.createCryptoDotComPayment({
|
|
1878
|
+
cryptoDotComPaymentCreateRequest: _extends({}, paymentParams, {
|
|
1879
|
+
// eslint-disable-next-line custom-rules/ban-chain-enum
|
|
1880
|
+
chain: paymentParams.chain
|
|
1881
|
+
}),
|
|
1882
|
+
environmentId: core.environmentId
|
|
1883
|
+
});
|
|
1884
|
+
return response;
|
|
1885
|
+
};
|
|
1886
|
+
|
|
1187
1887
|
/**
|
|
1188
1888
|
* Allows waiting until all modules of the client have been properly initialized
|
|
1189
1889
|
* and are ready for use.
|
|
@@ -1290,11 +1990,12 @@ const providersRequiringPkce = [
|
|
|
1290
1990
|
}
|
|
1291
1991
|
};
|
|
1292
1992
|
|
|
1293
|
-
const getPasskeyAuthenticationOptions = async (client)=>{
|
|
1993
|
+
const getPasskeyAuthenticationOptions = async ({ relatedOriginRpId } = {}, client)=>{
|
|
1294
1994
|
const core = getCore(client);
|
|
1295
1995
|
const apiClient = createApiClient({}, client);
|
|
1296
1996
|
const options = await apiClient.getPasskeyAuthenticationOptions({
|
|
1297
|
-
environmentId: core.environmentId
|
|
1997
|
+
environmentId: core.environmentId,
|
|
1998
|
+
relatedOriginRpId
|
|
1298
1999
|
});
|
|
1299
2000
|
return options;
|
|
1300
2001
|
};
|
|
@@ -1325,14 +2026,16 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1325
2026
|
* @returns A promise that resolves to the MFA authentication response.
|
|
1326
2027
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
1327
2028
|
* @throws NoPasskeyCredentialsFoundError If no passkey credentials are found.
|
|
1328
|
-
*/ const authenticatePasskeyMFA = async ({ createMfaToken } = {}, client = getDefaultClient())=>{
|
|
2029
|
+
*/ const authenticatePasskeyMFA = async ({ createMfaToken, relatedOriginRpId } = {}, client = getDefaultClient())=>{
|
|
1329
2030
|
const core = getCore(client);
|
|
1330
2031
|
try {
|
|
1331
2032
|
var _options_allowCredentials;
|
|
1332
2033
|
if (!core.passkey.isSupported()) {
|
|
1333
2034
|
throw new NoWebAuthNSupportError();
|
|
1334
2035
|
}
|
|
1335
|
-
const options = await getPasskeyAuthenticationOptions(
|
|
2036
|
+
const options = await getPasskeyAuthenticationOptions({
|
|
2037
|
+
relatedOriginRpId
|
|
2038
|
+
}, client);
|
|
1336
2039
|
const allowCredentials = (_options_allowCredentials = options.allowCredentials) == null ? void 0 : _options_allowCredentials.map((credential)=>_extends({}, credential, {
|
|
1337
2040
|
type: 'public-key'
|
|
1338
2041
|
}));
|
|
@@ -2579,7 +3282,7 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2579
3282
|
* @param params.otpVerification - The OTP verification object containing verification details.
|
|
2580
3283
|
* @param params.verificationToken - The token received from the OTP verification process.
|
|
2581
3284
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2582
|
-
* @returns A promise that resolves to the
|
|
3285
|
+
* @returns A promise that resolves to the verify response object upon successful verification.
|
|
2583
3286
|
*/ const verifyOTP = async ({ otpVerification, verificationToken }, client = getDefaultClient())=>{
|
|
2584
3287
|
const verifyOTPFunction = client.user ? verifyOTPForUserUpdate : verifyOTPForUserSignIn;
|
|
2585
3288
|
const response = await verifyOTPFunction({
|
|
@@ -2589,7 +3292,26 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2589
3292
|
updateAuthFromVerifyResponse({
|
|
2590
3293
|
response
|
|
2591
3294
|
}, client);
|
|
2592
|
-
return response
|
|
3295
|
+
return response;
|
|
3296
|
+
};
|
|
3297
|
+
|
|
3298
|
+
/**
|
|
3299
|
+
* Deletes the current user's account permanently.
|
|
3300
|
+
*
|
|
3301
|
+
* This function performs a hard delete of the user account. Upon successful deletion,
|
|
3302
|
+
* the user will be automatically logged out and all authentication data will be cleared.
|
|
3303
|
+
*
|
|
3304
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3305
|
+
* @returns A promise that resolves when the user account is successfully deleted.
|
|
3306
|
+
*/ const deleteUser = async (client = getDefaultClient())=>{
|
|
3307
|
+
const core = getCore(client);
|
|
3308
|
+
const apiClient = createApiClient({
|
|
3309
|
+
includeMfaToken: true
|
|
3310
|
+
}, client);
|
|
3311
|
+
await apiClient.hardDeleteUser({
|
|
3312
|
+
environmentId: core.environmentId
|
|
3313
|
+
});
|
|
3314
|
+
await logout(client);
|
|
2593
3315
|
};
|
|
2594
3316
|
|
|
2595
3317
|
/**
|
|
@@ -2618,50 +3340,6 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2618
3340
|
}
|
|
2619
3341
|
};
|
|
2620
3342
|
|
|
2621
|
-
/*
|
|
2622
|
-
In older SDK versions we used to have the concept of "connect-only" vs "connect-and-sign".
|
|
2623
|
-
The only difference in backend is it stores some extra data for connect-only,
|
|
2624
|
-
so we can just default to using it.
|
|
2625
|
-
*/ const createVisit = async ({ walletAccount, authMode = AuthModeEnum.Only }, client)=>{
|
|
2626
|
-
const core = getCore(client);
|
|
2627
|
-
const apiClient = createApiClient({}, client);
|
|
2628
|
-
const walletProvider = getWalletProviderFromWalletAccount({
|
|
2629
|
-
walletAccount
|
|
2630
|
-
}, client);
|
|
2631
|
-
try {
|
|
2632
|
-
const connectRequest = {
|
|
2633
|
-
address: walletAccount.address,
|
|
2634
|
-
authMode,
|
|
2635
|
-
// eslint-disable-next-line custom-rules/ban-chain-enum
|
|
2636
|
-
chain: walletProvider.chain,
|
|
2637
|
-
provider: walletProvider.getWalletProviderType(),
|
|
2638
|
-
walletName: walletAccount.walletProviderKey
|
|
2639
|
-
};
|
|
2640
|
-
await apiClient.createVisit({
|
|
2641
|
-
connectRequest,
|
|
2642
|
-
environmentId: core.environmentId
|
|
2643
|
-
});
|
|
2644
|
-
} catch (error) {
|
|
2645
|
-
core.logger.error('Error creating visit', {
|
|
2646
|
-
error
|
|
2647
|
-
});
|
|
2648
|
-
}
|
|
2649
|
-
};
|
|
2650
|
-
|
|
2651
|
-
/**
|
|
2652
|
-
* Updates the unverified wallet account in the client state.
|
|
2653
|
-
*/ const setUnverifiedWalletAccounts = ({ unverifiedWalletAccountsToUpdate }, client)=>{
|
|
2654
|
-
const core = getCore(client);
|
|
2655
|
-
const unverifiedWalletAccountsToUpdateIds = unverifiedWalletAccountsToUpdate.map(({ id })=>id);
|
|
2656
|
-
const filteredUnverifiedWalletAccounts = core.state.get().unverifiedWalletAccounts.filter((unverifiedWalletAccount)=>!unverifiedWalletAccountsToUpdateIds.includes(unverifiedWalletAccount.id));
|
|
2657
|
-
core.state.set({
|
|
2658
|
-
unverifiedWalletAccounts: [
|
|
2659
|
-
...filteredUnverifiedWalletAccounts,
|
|
2660
|
-
...unverifiedWalletAccountsToUpdate
|
|
2661
|
-
]
|
|
2662
|
-
});
|
|
2663
|
-
};
|
|
2664
|
-
|
|
2665
3343
|
/**
|
|
2666
3344
|
* Asserts that a specific wallet provider method is defined, throwing an error if it's not.
|
|
2667
3345
|
* This function acts as a type guard, narrowing the type to ensure the method exists.
|
|
@@ -2686,6 +3364,10 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2686
3364
|
}
|
|
2687
3365
|
}
|
|
2688
3366
|
|
|
3367
|
+
const getAddressesWithTypesFromConnectionResult = (connectionResult)=>{
|
|
3368
|
+
return connectionResult.addresses.filter((address)=>!!address.address && !!address.type);
|
|
3369
|
+
};
|
|
3370
|
+
|
|
2689
3371
|
/**
|
|
2690
3372
|
* Connects to a wallet provider and returns the connected wallet account.
|
|
2691
3373
|
*
|
|
@@ -2695,36 +3377,44 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2695
3377
|
* @see connectAndVerifyWithWalletProvider
|
|
2696
3378
|
*
|
|
2697
3379
|
* @param params.walletProviderKey - The unique key identifying the wallet provider to connect to (e.g. 'metamaskevm', 'phantomsol').
|
|
2698
|
-
* @param [params.
|
|
3380
|
+
* @param [params.addToDynamicWalletAccounts] - Whether to add the connected wallet account to the user's wallet accounts. Defaults to true.
|
|
2699
3381
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2700
3382
|
* @returns A promise that resolves to the connected wallet account.
|
|
2701
3383
|
* @throws NoAddressFoundError If the request to connect was successful but no address is connected to your app.
|
|
2702
|
-
*/ const connectWithWalletProvider = async ({ walletProviderKey,
|
|
3384
|
+
*/ const connectWithWalletProvider = async ({ walletProviderKey, addToDynamicWalletAccounts = true }, client = getDefaultClient())=>{
|
|
2703
3385
|
const walletProvider = getWalletProviderByKey({
|
|
2704
3386
|
walletProviderKey
|
|
2705
3387
|
}, client);
|
|
2706
3388
|
assertWalletProviderMethodDefined(walletProvider, 'connect');
|
|
2707
|
-
const { addresses
|
|
3389
|
+
const { addresses } = await walletProvider.connect();
|
|
2708
3390
|
const currentAddresses = getWalletAccounts(client).map(({ address })=>address);
|
|
3391
|
+
const mainAddress = (addresses == null ? void 0 : addresses.length) ? addresses[0].address : null;
|
|
2709
3392
|
/**
|
|
2710
3393
|
* This error is thrown in case the wallet has no addresses connected
|
|
2711
3394
|
* to the dapp. Then the error is thrown so the consumer can instruct the
|
|
2712
3395
|
* user on the next steps.
|
|
2713
|
-
*/ if (!
|
|
3396
|
+
*/ if (!mainAddress) {
|
|
2714
3397
|
throw new NoAddressFoundError();
|
|
2715
3398
|
}
|
|
2716
3399
|
const walletAccount = {
|
|
2717
|
-
address:
|
|
3400
|
+
address: mainAddress,
|
|
3401
|
+
addressesWithTypes: getAddressesWithTypesFromConnectionResult({
|
|
3402
|
+
addresses
|
|
3403
|
+
}),
|
|
2718
3404
|
chain: walletProvider.chain,
|
|
2719
|
-
id:
|
|
3405
|
+
id: formatWalletAccountId({
|
|
3406
|
+
address: mainAddress,
|
|
3407
|
+
chain: walletProvider.chain,
|
|
3408
|
+
walletProviderKey
|
|
3409
|
+
}),
|
|
2720
3410
|
lastSelectedAt: null,
|
|
2721
3411
|
verifiedCredentialId: null,
|
|
2722
|
-
walletProviderKey
|
|
3412
|
+
walletProviderKey
|
|
2723
3413
|
};
|
|
2724
|
-
if (currentAddresses.includes(
|
|
3414
|
+
if (currentAddresses.includes(mainAddress)) {
|
|
2725
3415
|
return walletAccount;
|
|
2726
3416
|
}
|
|
2727
|
-
if (
|
|
3417
|
+
if (addToDynamicWalletAccounts) {
|
|
2728
3418
|
setUnverifiedWalletAccounts({
|
|
2729
3419
|
unverifiedWalletAccountsToUpdate: [
|
|
2730
3420
|
walletAccount
|
|
@@ -2741,24 +3431,15 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2741
3431
|
return walletAccount;
|
|
2742
3432
|
};
|
|
2743
3433
|
|
|
2744
|
-
/**
|
|
2745
|
-
* Check if the given value is an Error object
|
|
2746
|
-
*/ const isError = (error)=>error instanceof Error;
|
|
2747
|
-
|
|
2748
|
-
/**
|
|
2749
|
-
* Check if the given value is an Error object with a specific code
|
|
2750
|
-
*/ const isErrorWithCode = (error, code)=>{
|
|
2751
|
-
if (!isError(error)) return false;
|
|
2752
|
-
return 'code' in error && error.code === code;
|
|
2753
|
-
};
|
|
2754
|
-
|
|
2755
3434
|
const getChainIdForAccountVerification = async ({ walletProvider })=>{
|
|
2756
|
-
//
|
|
2757
|
-
//
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
3435
|
+
// for some chains, we don't need to specify a chain id for account verification because it's
|
|
3436
|
+
// not required and it might break the message signature in some wallets (e.g. Trust Wallet SOL)
|
|
3437
|
+
const chainsThatDontNeedChainId = [
|
|
3438
|
+
'BTC',
|
|
3439
|
+
'SOL',
|
|
3440
|
+
'SUI'
|
|
3441
|
+
];
|
|
3442
|
+
if (chainsThatDontNeedChainId.includes(walletProvider.chain)) {
|
|
2762
3443
|
return undefined;
|
|
2763
3444
|
}
|
|
2764
3445
|
const { networkId } = await walletProvider.getActiveNetworkId();
|
|
@@ -2786,6 +3467,7 @@ const getSignInMessage = async ({ walletAccount }, client)=>{
|
|
|
2786
3467
|
const walletProvider = getWalletProviderFromWalletAccount({
|
|
2787
3468
|
walletAccount
|
|
2788
3469
|
}, client);
|
|
3470
|
+
const statement = createSignInMessageStatement(client);
|
|
2789
3471
|
const messageToSign = await formatSignInMessage({
|
|
2790
3472
|
address: walletAccount.address,
|
|
2791
3473
|
blockchainName: CHAINS_INFO_MAP[walletProvider.chain].blockchainName,
|
|
@@ -2796,6 +3478,7 @@ const getSignInMessage = async ({ walletAccount }, client)=>{
|
|
|
2796
3478
|
issuedAt: new Date().toISOString(),
|
|
2797
3479
|
nonce,
|
|
2798
3480
|
requestId: core.environmentId,
|
|
3481
|
+
statement,
|
|
2799
3482
|
uri: url.toString()
|
|
2800
3483
|
});
|
|
2801
3484
|
return messageToSign;
|
|
@@ -2824,7 +3507,7 @@ const getSignInMessage = async ({ walletAccount }, client)=>{
|
|
|
2824
3507
|
});
|
|
2825
3508
|
return {
|
|
2826
3509
|
messageToSign,
|
|
2827
|
-
|
|
3510
|
+
signature
|
|
2828
3511
|
};
|
|
2829
3512
|
};
|
|
2830
3513
|
|
|
@@ -2832,11 +3515,18 @@ const getSignInMessage = async ({ walletAccount }, client)=>{
|
|
|
2832
3515
|
* Removes an unverified wallet account from the client's state.
|
|
2833
3516
|
*/ const removeUnverifiedWalletAccount = ({ unverifiedWalletAccount }, client)=>{
|
|
2834
3517
|
const core = getCore(client);
|
|
3518
|
+
const previousState = core.state.get();
|
|
2835
3519
|
const { unverifiedWalletAccounts } = core.state.get();
|
|
2836
3520
|
const filteredUnverifiedWalletAccounts = unverifiedWalletAccounts.filter((account)=>account.id !== unverifiedWalletAccount.id);
|
|
2837
3521
|
core.state.set({
|
|
2838
3522
|
unverifiedWalletAccounts: filteredUnverifiedWalletAccounts
|
|
2839
3523
|
});
|
|
3524
|
+
/**
|
|
3525
|
+
* We check before raising because the wallet account we are removing might still
|
|
3526
|
+
* be present in wallet accounts due to having been moved to verified credentials.
|
|
3527
|
+
*/ checkAndRaiseWalletAccountsChangedEvent({
|
|
3528
|
+
previousState
|
|
3529
|
+
}, client);
|
|
2840
3530
|
};
|
|
2841
3531
|
|
|
2842
3532
|
const isSameAddress = (left, right, chain)=>normalizeAddress(left, chain) === normalizeAddress(right, chain);
|
|
@@ -2853,53 +3543,48 @@ const isSameAddress = (left, right, chain)=>normalizeAddress(left, chain) === no
|
|
|
2853
3543
|
* @throws WalletAccountAlreadyVerifiedError If the wallet is already verified.
|
|
2854
3544
|
* @throws WalletAlreadyLinkedToAnotherUserError If the wallet is linked to another user.
|
|
2855
3545
|
*/ const verifyWalletAccount = async ({ walletAccount }, client = getDefaultClient())=>{
|
|
3546
|
+
var _response_user;
|
|
2856
3547
|
if (walletAccount.verifiedCredentialId) {
|
|
2857
3548
|
throw new WalletAccountAlreadyVerifiedError(walletAccount.address);
|
|
2858
3549
|
}
|
|
2859
|
-
const core = getCore(client);
|
|
2860
|
-
const apiClient = createApiClient({}, client);
|
|
2861
3550
|
const walletProvider = getWalletProviderFromWalletAccount({
|
|
2862
3551
|
walletAccount
|
|
2863
3552
|
}, client);
|
|
2864
|
-
const {
|
|
3553
|
+
const { messageToSign, signature } = await proveWalletAccountOwnership({
|
|
2865
3554
|
walletAccount
|
|
2866
3555
|
}, client);
|
|
2867
|
-
const
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
*/ removeUnverifiedWalletAccount({
|
|
2885
|
-
unverifiedWalletAccount: walletAccount
|
|
2886
|
-
}, client);
|
|
2887
|
-
/**
|
|
2888
|
-
* Adds the user with the new wallet verified credential
|
|
2889
|
-
* This will add the new verified wallet account to the client`s state
|
|
2890
|
-
*/ updateAuthFromVerifyResponse({
|
|
2891
|
-
response
|
|
2892
|
-
}, client);
|
|
2893
|
-
} catch (error) {
|
|
2894
|
-
if (isErrorWithCode(error, 'reassign_wallet_confirm') || isErrorWithCode(error, 'merge_accounts_confirmation')) {
|
|
2895
|
-
throw new WalletAlreadyLinkedToAnotherUserError({
|
|
2896
|
-
cause: error
|
|
2897
|
-
});
|
|
3556
|
+
const response = await verifySignInMessage({
|
|
3557
|
+
addressesWithTypes: walletAccount.addressesWithTypes,
|
|
3558
|
+
chain: walletAccount.chain,
|
|
3559
|
+
messageToSign,
|
|
3560
|
+
signature,
|
|
3561
|
+
walletAddress: walletAccount.address,
|
|
3562
|
+
walletDisplayName: walletProvider.metadata.displayName,
|
|
3563
|
+
walletProviderType: walletProvider.walletProviderType
|
|
3564
|
+
}, client);
|
|
3565
|
+
const walletVerifiedCredential = (_response_user = response.user) == null ? void 0 : _response_user.verifiedCredentials.find((verifiedCredential)=>{
|
|
3566
|
+
var _verifiedCredential_address;
|
|
3567
|
+
return isSameAddress((_verifiedCredential_address = verifiedCredential.address) != null ? _verifiedCredential_address : '', walletAccount.address, walletAccount.chain);
|
|
3568
|
+
});
|
|
3569
|
+
assertDefined(walletVerifiedCredential, `After verifying, still unable to find verified wallet credential for wallet account ${walletAccount.address} on chain ${walletAccount.chain}`);
|
|
3570
|
+
updateWalletProviderKeysForVerifiedCredentials({
|
|
3571
|
+
keysToUpdate: {
|
|
3572
|
+
[walletVerifiedCredential.id]: walletProvider.key
|
|
2898
3573
|
}
|
|
2899
|
-
|
|
2900
|
-
|
|
3574
|
+
}, client);
|
|
3575
|
+
/**
|
|
3576
|
+
* Adds the user with the new wallet verified credential
|
|
3577
|
+
* This will add the new verified wallet account to the client`s state
|
|
3578
|
+
*/ updateAuthFromVerifyResponse({
|
|
3579
|
+
response
|
|
3580
|
+
}, client);
|
|
3581
|
+
/**
|
|
3582
|
+
* Remove the now verified wallet account from the unverified wallet accounts
|
|
3583
|
+
*/ removeUnverifiedWalletAccount({
|
|
3584
|
+
unverifiedWalletAccount: walletAccount
|
|
3585
|
+
}, client);
|
|
2901
3586
|
const verifiedWalletAccount = getWalletAccounts(client).find(({ address })=>isSameAddress(address, walletAccount.address, walletAccount.chain));
|
|
2902
|
-
assertDefined(verifiedWalletAccount,
|
|
3587
|
+
assertDefined(verifiedWalletAccount, `Unable to find wallet account ${walletAccount.address} on chain ${walletAccount.chain} for verified credential ${walletVerifiedCredential.id}`);
|
|
2903
3588
|
return verifiedWalletAccount;
|
|
2904
3589
|
};
|
|
2905
3590
|
|
|
@@ -2915,7 +3600,7 @@ const isSameAddress = (left, right, chain)=>normalizeAddress(left, chain) === no
|
|
|
2915
3600
|
* @returns A promise that resolves to the connected and verified wallet account.
|
|
2916
3601
|
*/ const connectAndVerifyWithWalletProvider = async ({ walletProviderKey }, client = getDefaultClient())=>{
|
|
2917
3602
|
const walletAccount = await connectWithWalletProvider({
|
|
2918
|
-
|
|
3603
|
+
addToDynamicWalletAccounts: false,
|
|
2919
3604
|
walletProviderKey
|
|
2920
3605
|
}, client);
|
|
2921
3606
|
await verifyWalletAccount({
|
|
@@ -2948,7 +3633,8 @@ const isSameAddress = (left, right, chain)=>normalizeAddress(left, chain) === no
|
|
|
2948
3633
|
chain: walletProvider.chain,
|
|
2949
3634
|
groupKey: walletProvider.groupKey,
|
|
2950
3635
|
key: walletProvider.key,
|
|
2951
|
-
metadata: walletProvider.metadata
|
|
3636
|
+
metadata: walletProvider.metadata,
|
|
3637
|
+
walletProviderType: walletProvider.walletProviderType
|
|
2952
3638
|
}));
|
|
2953
3639
|
};
|
|
2954
3640
|
|
|
@@ -2968,6 +3654,47 @@ const isSameAddress = (left, right, chain)=>normalizeAddress(left, chain) === no
|
|
|
2968
3654
|
return walletProvider.getConnectedAddresses();
|
|
2969
3655
|
};
|
|
2970
3656
|
|
|
3657
|
+
const getOwnerWalletAccountForSmartWalletAccount = ({ smartWalletAccount }, client = getDefaultClient())=>{
|
|
3658
|
+
const smartWalletVerifiedCredential = getVerifiedCredentialForWalletAccount({
|
|
3659
|
+
walletAccount: smartWalletAccount
|
|
3660
|
+
}, client);
|
|
3661
|
+
assertDefined(smartWalletVerifiedCredential == null ? void 0 : smartWalletVerifiedCredential.signerRefId, 'Invalid smart wallet account');
|
|
3662
|
+
return getWalletAccounts(client).find((walletAccount)=>walletAccount.verifiedCredentialId === smartWalletVerifiedCredential.signerRefId);
|
|
3663
|
+
};
|
|
3664
|
+
|
|
3665
|
+
const getWalletAccountAddressByType = ({ type, walletAccount })=>{
|
|
3666
|
+
var _walletAccount_addressesWithTypes_find, _walletAccount_addressesWithTypes;
|
|
3667
|
+
return (_walletAccount_addressesWithTypes = walletAccount.addressesWithTypes) == null ? void 0 : (_walletAccount_addressesWithTypes_find = _walletAccount_addressesWithTypes.find((address)=>address.type === type)) == null ? void 0 : _walletAccount_addressesWithTypes_find.address;
|
|
3668
|
+
};
|
|
3669
|
+
|
|
3670
|
+
/**
|
|
3671
|
+
* Retrieves data for a specific wallet provider that can be used for display or connection.
|
|
3672
|
+
*
|
|
3673
|
+
* @param params.walletProviderKey - The key of the wallet provider to retrieve data for.
|
|
3674
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3675
|
+
* @returns The data for the wallet provider.
|
|
3676
|
+
*/ const getWalletProviderDataByKey = ({ walletProviderKey }, client = getDefaultClient())=>{
|
|
3677
|
+
const { chain, groupKey, key, metadata, walletProviderType } = getWalletProviderByKey({
|
|
3678
|
+
walletProviderKey
|
|
3679
|
+
}, client);
|
|
3680
|
+
return {
|
|
3681
|
+
chain,
|
|
3682
|
+
groupKey,
|
|
3683
|
+
key,
|
|
3684
|
+
metadata,
|
|
3685
|
+
walletProviderType
|
|
3686
|
+
};
|
|
3687
|
+
};
|
|
3688
|
+
|
|
3689
|
+
/**
|
|
3690
|
+
* Checks if a wallet account has been verified by a user.
|
|
3691
|
+
*
|
|
3692
|
+
* @param walletAccount - The wallet account to check.
|
|
3693
|
+
* @returns True if the wallet account has been verified, false otherwise.
|
|
3694
|
+
*/ const isWalletAccountVerified = ({ walletAccount })=>{
|
|
3695
|
+
return walletAccount.verifiedCredentialId !== null;
|
|
3696
|
+
};
|
|
3697
|
+
|
|
2971
3698
|
/**
|
|
2972
3699
|
* Retrieves the network configuration data for the currently active network.
|
|
2973
3700
|
*
|
|
@@ -3048,6 +3775,32 @@ const isSameAddress = (left, right, chain)=>normalizeAddress(left, chain) === no
|
|
|
3048
3775
|
});
|
|
3049
3776
|
};
|
|
3050
3777
|
|
|
3778
|
+
/**
|
|
3779
|
+
* Retrieves the transaction history for a given wallet address, chain and network.
|
|
3780
|
+
*
|
|
3781
|
+
* This function fetches the transaction history for a specified wallet address and chain,
|
|
3782
|
+
* returning a list of transactions associated with that address along with nextOffset for pagination.
|
|
3783
|
+
*
|
|
3784
|
+
* @param params.address - The wallet address to query transactions for.
|
|
3785
|
+
* @param params.chain - The chain to query transactions for.
|
|
3786
|
+
* @param [params.limit] - The maximum number of transactions to return.
|
|
3787
|
+
* @param params.networkId - The network ID to query transactions for.
|
|
3788
|
+
* @param [params.offset] - The offset to use for pagination.
|
|
3789
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3790
|
+
* @returns A promise that resolves to the transaction history along with nextOffset for the given wallet address and chain.
|
|
3791
|
+
*/ const getTransactionHistory = async (params, client = getDefaultClient())=>{
|
|
3792
|
+
const core = getCore(client);
|
|
3793
|
+
const apiClient = createApiClient({}, client);
|
|
3794
|
+
const response = await apiClient.getWalletTransactions({
|
|
3795
|
+
address: params.address,
|
|
3796
|
+
// eslint-disable-next-line custom-rules/ban-chain-enum
|
|
3797
|
+
chainName: params.chain,
|
|
3798
|
+
environmentId: core.environmentId,
|
|
3799
|
+
networkId: params.networkId
|
|
3800
|
+
});
|
|
3801
|
+
return response;
|
|
3802
|
+
};
|
|
3803
|
+
|
|
3051
3804
|
/**
|
|
3052
3805
|
* Checks if programmatic network switching is available for a wallet account.
|
|
3053
3806
|
*
|
|
@@ -3093,21 +3846,6 @@ const isSameAddress = (left, right, chain)=>normalizeAddress(left, chain) === no
|
|
|
3093
3846
|
});
|
|
3094
3847
|
};
|
|
3095
3848
|
|
|
3096
|
-
/**
|
|
3097
|
-
* Get the primary wallet account.
|
|
3098
|
-
* The primary wallet account is the one that was last selected by the user.
|
|
3099
|
-
* This information is stored in both unverified and verified wallet accounts.
|
|
3100
|
-
* This function consolidates this information to determine which wallet was most recently selected.
|
|
3101
|
-
*/ const getPrimaryWalletAccount = (client = getDefaultClient())=>{
|
|
3102
|
-
const walletAccounts = getWalletAccounts(client);
|
|
3103
|
-
const sortedLastSelectedWalletAccounts = walletAccounts.filter((walletAccount)=>Boolean(walletAccount.lastSelectedAt)).sort((a, b)=>b.lastSelectedAt.getTime() - a.lastSelectedAt.getTime());
|
|
3104
|
-
if (sortedLastSelectedWalletAccounts.length === 0) {
|
|
3105
|
-
return null;
|
|
3106
|
-
}
|
|
3107
|
-
const [primaryWalletAccount] = sortedLastSelectedWalletAccounts;
|
|
3108
|
-
return primaryWalletAccount;
|
|
3109
|
-
};
|
|
3110
|
-
|
|
3111
3849
|
/**
|
|
3112
3850
|
* Make the wallet account provided as the primary wallet account.
|
|
3113
3851
|
*/ const selectPrimaryWalletAccount = async ({ walletAccount }, client = getDefaultClient())=>{
|
|
@@ -3152,6 +3890,19 @@ const isSameAddress = (left, right, chain)=>normalizeAddress(left, chain) === no
|
|
|
3152
3890
|
*/ const removeWalletAccount = async ({ walletAccount }, client = getDefaultClient())=>{
|
|
3153
3891
|
const core = getCore(client);
|
|
3154
3892
|
const apiClient = createApiClient({}, client);
|
|
3893
|
+
try {
|
|
3894
|
+
const walletProvider = getWalletProviderFromWalletAccount({
|
|
3895
|
+
walletAccount
|
|
3896
|
+
}, client);
|
|
3897
|
+
await (walletProvider.disconnectWalletAccount == null ? void 0 : walletProvider.disconnectWalletAccount.call(walletProvider, {
|
|
3898
|
+
walletAccount
|
|
3899
|
+
}));
|
|
3900
|
+
} catch (error) {
|
|
3901
|
+
if (error instanceof NoWalletProviderFoundError) {
|
|
3902
|
+
return;
|
|
3903
|
+
}
|
|
3904
|
+
throw error;
|
|
3905
|
+
}
|
|
3155
3906
|
if (!walletAccount.verifiedCredentialId) {
|
|
3156
3907
|
removeUnverifiedWalletAccount({
|
|
3157
3908
|
unverifiedWalletAccount: walletAccount
|
|
@@ -3275,4 +4026,4 @@ const isIPhone = ()=>typeof window === 'undefined' || typeof navigator === 'unde
|
|
|
3275
4026
|
|
|
3276
4027
|
assertPackageVersion(name, version);
|
|
3277
4028
|
|
|
3278
|
-
export { BaseError, ClientAlreadyInitializedError, InvalidRedirectStorageStateError, MissingRedirectStorageStateError, MissingSocialUrlParamError, NetworkSwitchingUnavailableError, NoAddressFoundError, NoPasskeyCredentialsFoundError, NoWebAuthNSupportError, UnavailableInServerSideError, UnrecognizedNetworkError, UserNotAuthenticatedError, UserRejectedError, WalletAccountAlreadyVerifiedError, WalletAccountNotSelectedError,
|
|
4029
|
+
export { BaseError, ClientAlreadyInitializedError, InvalidParamError, InvalidRedirectStorageStateError, MissingRedirectStorageStateError, MissingSocialUrlParamError, MissingUserVerificationError, NetworkSwitchingUnavailableError, NoAddressFoundError, NoPasskeyCredentialsFoundError, NoSmartWalletAccountSignerFoundError, NoWebAuthNSupportError, UnavailableInServerSideError, UnrecognizedNetworkError, UserNotAuthenticatedError, UserRejectedError, WalletAccountAlreadyVerifiedError, WalletAccountNotSelectedError, WalletProviderMethodUnavailableError, acknowledgeRecoveryCodes, addCoinbaseOnrampOrderEventListener, assertWalletAccountSigningAvailability, assertWalletProviderMethodDefined, authenticateMfaRecoveryCode, authenticatePasskeyMFA, authenticateTotpMfaDevice, authenticateWithSocial, completeSocialAuthentication, connectAndVerifyWithWalletProvider, connectWithWalletProvider, createCoinbaseOnrampOrder, createCryptoDotComPayment, createDynamicClient, createNewMfaRecoveryCodes, deleteMfaDevice, deletePasskey, deleteUser, detectOAuthRedirect, fetchProjectSettings, getActiveNetworkData, getActiveNetworkId, getAvailableWalletProvidersData, getBalance, getBalanceForAddress, getCoinbaseBuyUrl, getConnectedAddresses, getDefaultClient, getMfaDevices, getMfaRecoveryCodes, getMissingVerificationForCoinbaseOnrampOrder, getMultichainBalances, getNetworksData, getOwnerWalletAccountForSmartWalletAccount, getPasskeys, getPrimaryWalletAccount, getTransactionHistory, getUserSocialAccounts, getWalletAccountAddressByType, getWalletAccountFromAddress, getWalletAccounts, getWalletProviderDataByKey, initializeClient, isMobile, isPendingRecoveryCodesAcknowledgment, isProgrammaticNetworkSwitchAvailable, isSignedIn, isUserMissingMfaAuth, isWalletAccountVerified, logout, offWalletProviderEvent, onWalletProviderEvent, proveWalletAccountOwnership, refreshUser, registerPasskey, registerTotpMfaDevice, removeWalletAccount, selectPrimaryWalletAccount, sendEmailOTP, sendSmsOTP, setDefaultMfaDevice, signInWithExternalJwt, signInWithPasskey, signMessage, switchActiveNetwork, unlinkSocialAccount, updateUser, verifyOTP, verifyWalletAccount, waitForClientInitialized };
|