@dynamic-labs-sdk/client 0.1.0-alpha.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +322 -0
- package/InvalidParamError.cjs.js +2 -2
- package/InvalidParamError.esm.js +1 -1
- package/{refreshUser.cjs.js → NotWaasWalletAccountError.cjs.js} +18 -18
- package/{refreshUser.esm.js → NotWaasWalletAccountError.esm.js} +14 -14
- 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 +93 -39
- package/core.esm.js +47 -11
- package/filterDuplicates.cjs.js +8 -0
- package/filterDuplicates.esm.js +6 -0
- package/getNetworkProviderFromNetworkId.cjs.js +173 -21
- package/getNetworkProviderFromNetworkId.esm.js +146 -4
- package/getSignedSessionId.cjs.js +6 -6
- package/getSignedSessionId.esm.js +1 -1
- package/{getWalletProviderByKey.cjs.js → getVerifiedCredentialForWalletAccount.cjs.js} +176 -48
- package/{getWalletProviderByKey.esm.js → getVerifiedCredentialForWalletAccount.esm.js} +159 -36
- package/index.cjs.js +1088 -493
- package/index.esm.js +858 -279
- package/isMfaRequiredForAction.cjs.js +8 -8
- package/isMfaRequiredForAction.esm.js +1 -1
- package/package.json +7 -7
- 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 +28 -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/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/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/waitForClientInitialized/index.d.ts +2 -0
- package/src/modules/initializeClient/waitForClientInitialized/index.d.ts.map +1 -0
- package/src/modules/initializeClient/waitForClientInitialized/waitForClientInitialized.d.ts +8 -0
- package/src/modules/initializeClient/waitForClientInitialized/waitForClientInitialized.d.ts.map +1 -0
- 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/sessionKeys/generateSessionKeys/generateSessionKeys.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/primaryWalletAccount/selectPrimaryWalletAccount/selectPrimaryWalletAccount.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/index.d.ts +2 -0
- package/src/modules/wallets/unverifiedWalletAccounts/{setUnverifiedWalletAccount → setUnverifiedWalletAccounts}/index.d.ts.map +1 -1
- package/src/modules/wallets/unverifiedWalletAccounts/setUnverifiedWalletAccounts/setUnverifiedWalletAccounts.d.ts +13 -0
- package/src/modules/wallets/unverifiedWalletAccounts/setUnverifiedWalletAccounts/setUnverifiedWalletAccounts.d.ts.map +1 -0
- 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/events/createWalletProviderEventEmitter/createWalletProviderEventEmitter.d.ts +7 -5
- package/src/modules/wallets/walletProvider/events/createWalletProviderEventEmitter/createWalletProviderEventEmitter.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 +34 -12
- 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/modules/wallets/walletProviderRegistry/createWalletProviderRegistry/createWalletProviderRegistry.d.ts.map +1 -1
- package/src/modules/wallets/walletProviderRegistry/events.d.ts +6 -0
- package/src/modules/wallets/walletProviderRegistry/events.d.ts.map +1 -1
- package/src/modules/wallets/walletProviderRegistry/walletProviderRegistry.types.d.ts +18 -0
- package/src/modules/wallets/walletProviderRegistry/walletProviderRegistry.types.d.ts.map +1 -1
- 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/src/utils/isMobile/index.d.ts +2 -0
- package/src/utils/isMobile/index.d.ts.map +1 -0
- package/src/utils/isMobile/isMobile.d.ts +20 -0
- package/src/utils/isMobile/isMobile.d.ts.map +1 -0
- package/src/utils/retryOnFail/retryOnFail.d.ts.map +1 -1
- package/waas.cjs.js +88 -39
- package/waas.esm.js +63 -16
- package/waasCore.cjs.js +21 -9
- package/waasCore.esm.js +15 -3
- package/getChainFromVerifiedCredentialChain.cjs.js +0 -473
- package/getChainFromVerifiedCredentialChain.esm.js +0 -447
- 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/unverifiedWalletAccounts/addUnverifiedWalletAccounts/addUnverifiedWalletAccounts.d.ts +0 -11
- package/src/modules/wallets/unverifiedWalletAccounts/addUnverifiedWalletAccounts/addUnverifiedWalletAccounts.d.ts.map +0 -1
- package/src/modules/wallets/unverifiedWalletAccounts/addUnverifiedWalletAccounts/index.d.ts +0 -2
- package/src/modules/wallets/unverifiedWalletAccounts/addUnverifiedWalletAccounts/index.d.ts.map +0 -1
- package/src/modules/wallets/unverifiedWalletAccounts/setUnverifiedWalletAccount/index.d.ts +0 -2
- package/src/modules/wallets/unverifiedWalletAccounts/setUnverifiedWalletAccount/setUnverifiedWalletAccount.d.ts +0 -11
- package/src/modules/wallets/unverifiedWalletAccounts/setUnverifiedWalletAccount/setUnverifiedWalletAccount.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.cjs.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var assertPackageVersion = require('@dynamic-labs-sdk/assert-package-version');
|
|
4
|
-
var
|
|
4
|
+
var constants = require('./constants.cjs.js');
|
|
5
5
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
6
6
|
var getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId.cjs.js');
|
|
7
|
-
var
|
|
7
|
+
var getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount.cjs.js');
|
|
8
8
|
var z = require('zod/mini');
|
|
9
9
|
var isMfaRequiredForAction = require('./isMfaRequiredForAction.cjs.js');
|
|
10
|
+
var NotWaasWalletAccountError = require('./NotWaasWalletAccountError.cjs.js');
|
|
10
11
|
var EventEmitter = require('eventemitter3');
|
|
11
12
|
var browser = require('@simplewebauthn/browser');
|
|
12
13
|
var InvalidParamError = require('./InvalidParamError.cjs.js');
|
|
13
|
-
var refreshUser = require('./refreshUser.cjs.js');
|
|
14
14
|
require('buffer');
|
|
15
15
|
|
|
16
16
|
function _interopNamespaceDefault(e) {
|
|
@@ -49,7 +49,7 @@ var z__namespace = /*#__PURE__*/_interopNamespaceDefault(z);
|
|
|
49
49
|
/**
|
|
50
50
|
* This error is thrown when the `retryOnFail` function is called with an invalid
|
|
51
51
|
* number of retries (i.e. less than 0).
|
|
52
|
-
*/ class InvalidRetryOnFailCallError extends
|
|
52
|
+
*/ class InvalidRetryOnFailCallError extends constants.BaseError {
|
|
53
53
|
constructor(maxRetries){
|
|
54
54
|
super({
|
|
55
55
|
cause: null,
|
|
@@ -74,7 +74,10 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries })=>{
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Reaching this point should never happen and this
|
|
79
|
+
* error is thrown to help us debug the issue.
|
|
80
|
+
*/ throw new InvalidRetryOnFailCallError(maxRetries);
|
|
78
81
|
};
|
|
79
82
|
|
|
80
83
|
/**
|
|
@@ -85,11 +88,11 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries })=>{
|
|
|
85
88
|
*
|
|
86
89
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
87
90
|
* @returns True if the user is signed in, false otherwise.
|
|
88
|
-
*/ const isSignedIn = (client =
|
|
91
|
+
*/ const isSignedIn = (client = constants.getDefaultClient())=>Boolean(client.user || getVerifiedCredentialForWalletAccount.getWalletAccounts(client).length > 0);
|
|
89
92
|
|
|
90
93
|
/**
|
|
91
94
|
* The schema to track the expiration time of the project settings.
|
|
92
|
-
*/ const
|
|
95
|
+
*/ const projectSettingsExpirationStorageKeySchema = getNetworkProviderFromNetworkId.createStorageKeySchema({
|
|
93
96
|
key: 'projectSettingsExpiration',
|
|
94
97
|
schema: z__namespace.number()
|
|
95
98
|
});
|
|
@@ -106,9 +109,9 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries })=>{
|
|
|
106
109
|
*
|
|
107
110
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
108
111
|
* @returns A promise that resolves to the updated project settings.
|
|
109
|
-
*/ const fetchProjectSettings = async (client =
|
|
110
|
-
const core =
|
|
111
|
-
const currentExpiration = await core.storage.getItem(
|
|
112
|
+
*/ const fetchProjectSettings = async (client = constants.getDefaultClient())=>{
|
|
113
|
+
const core = constants.getCore(client);
|
|
114
|
+
const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
|
|
112
115
|
const hasProjectSettings = Boolean(client.projectSettings);
|
|
113
116
|
const isExpired = currentExpiration && currentExpiration < Date.now();
|
|
114
117
|
// We want to cache the project settings if its valid and user is connected.
|
|
@@ -116,10 +119,11 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries })=>{
|
|
|
116
119
|
if (hasProjectSettings && !isExpired && isSignedIn(client)) {
|
|
117
120
|
return client.projectSettings;
|
|
118
121
|
}
|
|
119
|
-
const apiClient =
|
|
122
|
+
const apiClient = constants.createApiClient({}, client);
|
|
123
|
+
core.logger.debug('[fetchProjectSettings] Fetching project settings...');
|
|
120
124
|
const doFetch = async ()=>apiClient.getEnvironmentSettings({
|
|
121
125
|
environmentId: core.environmentId,
|
|
122
|
-
sdkVersion: `${
|
|
126
|
+
sdkVersion: `${constants.CLIENT_SDK_NAME}/${core.version}`
|
|
123
127
|
}, {
|
|
124
128
|
credentials: 'omit'
|
|
125
129
|
});
|
|
@@ -130,7 +134,7 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries })=>{
|
|
|
130
134
|
core.state.set({
|
|
131
135
|
projectSettings: projectSettings != null ? projectSettings : null
|
|
132
136
|
});
|
|
133
|
-
await core.storage.setItem(
|
|
137
|
+
await core.storage.setItem(projectSettingsExpirationStorageKeySchema, Date.now() + PROJECT_SETTINGS_EXPIRATION_TIME);
|
|
134
138
|
return projectSettings;
|
|
135
139
|
};
|
|
136
140
|
|
|
@@ -180,7 +184,7 @@ const p256Keygen = async ()=>{
|
|
|
180
184
|
|
|
181
185
|
const generateSessionKeys = async (client)=>{
|
|
182
186
|
const { private: privateKey, public: publicKey, privateJwk: privateKeyJwk } = await p256Keygen();
|
|
183
|
-
const core =
|
|
187
|
+
const core = constants.getCore(client);
|
|
184
188
|
// stringify and encode the session keys to store in storage
|
|
185
189
|
const stringifiedSessionKeys = JSON.stringify({
|
|
186
190
|
privateKey,
|
|
@@ -188,7 +192,7 @@ const generateSessionKeys = async (client)=>{
|
|
|
188
192
|
publicKey,
|
|
189
193
|
registered: false
|
|
190
194
|
});
|
|
191
|
-
const encodedSessionKeys =
|
|
195
|
+
const encodedSessionKeys = constants.getBuffer().from(stringifiedSessionKeys).toString('base64');
|
|
192
196
|
core.state.set({
|
|
193
197
|
sessionKeys: encodedSessionKeys
|
|
194
198
|
});
|
|
@@ -213,15 +217,15 @@ const generateSessionKeys = async (client)=>{
|
|
|
213
217
|
};
|
|
214
218
|
|
|
215
219
|
const getAvailableWalletProvidersFromWalletAccounts = (client)=>{
|
|
216
|
-
const core =
|
|
220
|
+
const core = constants.getCore(client);
|
|
217
221
|
const walletProvidersMap = new Map();
|
|
218
|
-
const walletAccounts =
|
|
222
|
+
const walletAccounts = getVerifiedCredentialForWalletAccount.getWalletAccounts(client);
|
|
219
223
|
walletAccounts.forEach((walletAccount)=>{
|
|
220
224
|
if (walletProvidersMap.has(walletAccount.walletProviderKey)) {
|
|
221
225
|
return;
|
|
222
226
|
}
|
|
223
227
|
try {
|
|
224
|
-
const walletProvider =
|
|
228
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
225
229
|
walletAccount
|
|
226
230
|
}, client);
|
|
227
231
|
walletProvidersMap.set(walletAccount.walletProviderKey, walletProvider);
|
|
@@ -238,7 +242,7 @@ const getAvailableWalletProvidersFromWalletAccounts = (client)=>{
|
|
|
238
242
|
/**
|
|
239
243
|
* Disconnect and terminate each wallet provider, if available.
|
|
240
244
|
*/ const disconnectAndTerminateWalletProviders = async (client)=>{
|
|
241
|
-
const core =
|
|
245
|
+
const core = constants.getCore(client);
|
|
242
246
|
const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
|
|
243
247
|
await Promise.all(walletProviders.map(async (walletProvider)=>{
|
|
244
248
|
if (walletProvider.terminate) {
|
|
@@ -259,30 +263,37 @@ const getAvailableWalletProvidersFromWalletAccounts = (client)=>{
|
|
|
259
263
|
*
|
|
260
264
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
261
265
|
* @returns A promise that resolves when the logout process is complete.
|
|
262
|
-
*/ const logout = async (client =
|
|
263
|
-
const core =
|
|
266
|
+
*/ const logout = async (client = constants.getDefaultClient())=>{
|
|
267
|
+
const core = constants.getCore(client);
|
|
268
|
+
core.logger.debug('[logout] Logging out...');
|
|
264
269
|
await disconnectAndTerminateWalletProviders(client);
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
270
|
+
if (client.user !== null) {
|
|
271
|
+
const apiClient = constants.createApiClient({}, client);
|
|
272
|
+
try {
|
|
273
|
+
await apiClient.revokeSession({
|
|
274
|
+
environmentId: core.environmentId
|
|
275
|
+
});
|
|
276
|
+
} catch (error) {
|
|
277
|
+
core.logger.error('Failed to revoke session', error);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* This deletes the auth cookie if it exists.
|
|
281
|
+
* If the cookie doesn't exist, this sets a new cookie that expires immediately.
|
|
282
|
+
*/ if (constants.isCookieEnabled(client)) {
|
|
283
|
+
getVerifiedCredentialForWalletAccount.setCookie(`${getVerifiedCredentialForWalletAccount.DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`);
|
|
284
|
+
}
|
|
278
285
|
}
|
|
279
286
|
core.state.set({
|
|
287
|
+
captchaToken: null,
|
|
280
288
|
legacyToken: null,
|
|
289
|
+
mfaToken: null,
|
|
281
290
|
sessionExpiresAt: null,
|
|
291
|
+
sessionKeys: null,
|
|
282
292
|
token: null,
|
|
293
|
+
unverifiedWalletAccounts: [],
|
|
283
294
|
user: null
|
|
284
295
|
});
|
|
285
|
-
|
|
296
|
+
getVerifiedCredentialForWalletAccount.emitEvent({
|
|
286
297
|
event: 'logout'
|
|
287
298
|
}, client);
|
|
288
299
|
// Refetch project settings
|
|
@@ -319,7 +330,7 @@ const getAvailableWalletProvidersFromWalletAccounts = (client)=>{
|
|
|
319
330
|
/**
|
|
320
331
|
* Sets up a timeout to log out the user when their token expires.
|
|
321
332
|
*/ const initializeAuth = (client)=>{
|
|
322
|
-
const core =
|
|
333
|
+
const core = constants.getCore(client);
|
|
323
334
|
let clearExpirationTimeout = null;
|
|
324
335
|
const onChangeExpiration = getNetworkProviderFromNetworkId.subscribeWithSelector(core.state, (state)=>state.sessionExpiresAt);
|
|
325
336
|
const checkExpiration = ()=>{
|
|
@@ -342,13 +353,13 @@ const getAvailableWalletProvidersFromWalletAccounts = (client)=>{
|
|
|
342
353
|
};
|
|
343
354
|
|
|
344
355
|
const raiseStateEvents = (client)=>{
|
|
345
|
-
const core =
|
|
356
|
+
const core = constants.getCore(client);
|
|
346
357
|
core.state.subscribe((value, previous)=>{
|
|
347
358
|
const eventEntries = Object.entries(stateChangeEvents);
|
|
348
359
|
eventEntries.forEach(([key, event])=>{
|
|
349
360
|
// Check if this key had a change
|
|
350
361
|
if (getNetworkProviderFromNetworkId.isEqualShallow(value[key], previous[key])) return;
|
|
351
|
-
|
|
362
|
+
getVerifiedCredentialForWalletAccount.emitEvent({
|
|
352
363
|
args: {
|
|
353
364
|
[key]: value[key]
|
|
354
365
|
},
|
|
@@ -358,17 +369,32 @@ const raiseStateEvents = (client)=>{
|
|
|
358
369
|
});
|
|
359
370
|
};
|
|
360
371
|
|
|
361
|
-
const
|
|
372
|
+
const unverifiedWalletAccountSchema = z__namespace.object({
|
|
373
|
+
address: z__namespace.string(),
|
|
374
|
+
addressesWithTypes: z__namespace.optional(z__namespace.array(z__namespace.object({
|
|
375
|
+
address: z__namespace.string(),
|
|
376
|
+
publicKey: z__namespace.optional(z__namespace.string()),
|
|
377
|
+
type: z__namespace.custom((val)=>typeof val === 'string')
|
|
378
|
+
}))),
|
|
379
|
+
chain: z__namespace.custom((val)=>typeof val === 'string'),
|
|
380
|
+
id: z__namespace.string(),
|
|
381
|
+
lastSelectedAt: z__namespace.nullable(z__namespace.date()),
|
|
382
|
+
walletProviderKey: z__namespace.string()
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
const walletProviderKeyMapSchema = z__namespace.record(z__namespace.string(), z__namespace.string());
|
|
362
386
|
|
|
363
387
|
const stateStorageKeySchema = getNetworkProviderFromNetworkId.createStorageKeySchema({
|
|
364
388
|
key: 'state',
|
|
365
389
|
schema: z__namespace.object({
|
|
366
390
|
apiVersion: z__namespace.string(),
|
|
367
391
|
projectSettings: z__namespace.custom(),
|
|
368
|
-
|
|
392
|
+
unverifiedWalletAccounts: z__namespace.array(unverifiedWalletAccountSchema),
|
|
393
|
+
user: z__namespace.custom(),
|
|
394
|
+
walletProviderKeyMap: walletProviderKeyMapSchema
|
|
369
395
|
})
|
|
370
396
|
});
|
|
371
|
-
const
|
|
397
|
+
const sessionStorageKeySchema = getNetworkProviderFromNetworkId.createStorageKeySchema({
|
|
372
398
|
key: 'session',
|
|
373
399
|
schema: z__namespace.object({
|
|
374
400
|
/**
|
|
@@ -395,10 +421,11 @@ const sessionKeySchema = getNetworkProviderFromNetworkId.createStorageKeySchema(
|
|
|
395
421
|
});
|
|
396
422
|
|
|
397
423
|
const hydrateStateWithStorage = async (client)=>{
|
|
398
|
-
const core =
|
|
424
|
+
const core = constants.getCore(client);
|
|
425
|
+
const previousState = core.state.get();
|
|
399
426
|
const stateChanges = {};
|
|
400
427
|
// ================ TOKEN =================
|
|
401
|
-
const session = await core.storage.getItem(
|
|
428
|
+
const session = await core.storage.getItem(sessionStorageKeySchema);
|
|
402
429
|
const isSessionValid = (session == null ? void 0 : session.sessionExpiration) && session.sessionExpiration > Date.now();
|
|
403
430
|
if (isSessionValid) {
|
|
404
431
|
stateChanges.token = session.token;
|
|
@@ -411,25 +438,35 @@ const hydrateStateWithStorage = async (client)=>{
|
|
|
411
438
|
// ================ STATE =================
|
|
412
439
|
const storedState = await core.storage.getItem(stateStorageKeySchema);
|
|
413
440
|
// Only hydrate state if it came from an API with the same version as the current SDK
|
|
414
|
-
if ((storedState == null ? void 0 : storedState.apiVersion) === SDK_API_CORE_VERSION) {
|
|
441
|
+
if ((storedState == null ? void 0 : storedState.apiVersion) === constants.SDK_API_CORE_VERSION) {
|
|
442
|
+
stateChanges.unverifiedWalletAccounts = storedState.unverifiedWalletAccounts;
|
|
443
|
+
stateChanges.walletProviderKeyMap = storedState.walletProviderKeyMap;
|
|
415
444
|
// Variables that should only be hydrated if the session is valid
|
|
416
445
|
if (isSessionValid) {
|
|
417
446
|
stateChanges.user = storedState.user;
|
|
447
|
+
}
|
|
448
|
+
var _storedState_unverifiedWalletAccounts;
|
|
449
|
+
// if there's a session/user or connected unverified wallets, we should hydrate project settings
|
|
450
|
+
// so we don't refetch it on initial load
|
|
451
|
+
if (isSessionValid || ((_storedState_unverifiedWalletAccounts = storedState.unverifiedWalletAccounts) != null ? _storedState_unverifiedWalletAccounts : []).length > 0) {
|
|
418
452
|
stateChanges.projectSettings = storedState.projectSettings;
|
|
419
453
|
}
|
|
420
454
|
}
|
|
421
455
|
if (Object.keys(stateChanges).length > 0) {
|
|
422
456
|
core.state.set(stateChanges);
|
|
423
457
|
}
|
|
458
|
+
getVerifiedCredentialForWalletAccount.checkAndRaiseWalletAccountsChangedEvent({
|
|
459
|
+
previousState
|
|
460
|
+
}, client);
|
|
424
461
|
};
|
|
425
462
|
|
|
426
463
|
const syncStateWithStorage = (client)=>{
|
|
427
|
-
const core =
|
|
464
|
+
const core = constants.getCore(client);
|
|
428
465
|
core.state.subscribe((state)=>{
|
|
429
466
|
if (state.sessionExpiresAt === null) {
|
|
430
|
-
void core.storage.removeItem(
|
|
467
|
+
void core.storage.removeItem(sessionStorageKeySchema);
|
|
431
468
|
} else {
|
|
432
|
-
void core.storage.setItem(
|
|
469
|
+
void core.storage.setItem(sessionStorageKeySchema, {
|
|
433
470
|
captchaToken: state.captchaToken,
|
|
434
471
|
legacyToken: state.legacyToken,
|
|
435
472
|
mfaToken: state.mfaToken,
|
|
@@ -439,9 +476,11 @@ const syncStateWithStorage = (client)=>{
|
|
|
439
476
|
});
|
|
440
477
|
}
|
|
441
478
|
void core.storage.setItem(stateStorageKeySchema, {
|
|
442
|
-
apiVersion: SDK_API_CORE_VERSION,
|
|
479
|
+
apiVersion: constants.SDK_API_CORE_VERSION,
|
|
443
480
|
projectSettings: state.projectSettings,
|
|
444
|
-
|
|
481
|
+
unverifiedWalletAccounts: state.unverifiedWalletAccounts,
|
|
482
|
+
user: state.user,
|
|
483
|
+
walletProviderKeyMap: state.walletProviderKeyMap
|
|
445
484
|
});
|
|
446
485
|
});
|
|
447
486
|
};
|
|
@@ -453,7 +492,7 @@ const initializeStorageSync = async (client)=>{
|
|
|
453
492
|
syncStateWithStorage(client);
|
|
454
493
|
};
|
|
455
494
|
|
|
456
|
-
class ClientAlreadyInitializedError extends
|
|
495
|
+
class ClientAlreadyInitializedError extends constants.BaseError {
|
|
457
496
|
constructor(){
|
|
458
497
|
super({
|
|
459
498
|
cause: null,
|
|
@@ -477,8 +516,9 @@ class ClientAlreadyInitializedError extends getChainFromVerifiedCredentialChain.
|
|
|
477
516
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
478
517
|
* @returns A promise that resolves when initialization is complete.
|
|
479
518
|
* @throws ClientAlreadyInitializedError If the client is already initialized.
|
|
480
|
-
*/ const initializeClient = async (client =
|
|
481
|
-
const core =
|
|
519
|
+
*/ const initializeClient = async (client = constants.getDefaultClient())=>{
|
|
520
|
+
const core = constants.getCore(client);
|
|
521
|
+
core.logger.debug('[initializeClient] Initializing client. Current init status', core.state.get().initStatus);
|
|
482
522
|
if (core.state.get().initStatus !== 'uninitialized') {
|
|
483
523
|
throw new ClientAlreadyInitializedError();
|
|
484
524
|
}
|
|
@@ -493,23 +533,59 @@ class ClientAlreadyInitializedError extends getChainFromVerifiedCredentialChain.
|
|
|
493
533
|
await fetchProjectSettings(client);
|
|
494
534
|
}
|
|
495
535
|
});
|
|
496
|
-
|
|
536
|
+
/**
|
|
537
|
+
* Generate session keys if they don't exist
|
|
538
|
+
*/ const generateSessionKeysPromise = fetchProjectSettingsPromise.then(async ()=>{
|
|
497
539
|
if (!core.state.get().sessionKeys) {
|
|
498
540
|
await generateSessionKeys(client);
|
|
499
541
|
}
|
|
500
542
|
});
|
|
543
|
+
/**
|
|
544
|
+
* Refresh user state on initialization when cookie is enabled.
|
|
545
|
+
* This is necessary for supporting multiple subdomain domains.
|
|
546
|
+
*
|
|
547
|
+
* When a user logs in on sub1.example.com, they will have a cookie set. However, when they access
|
|
548
|
+
* sub2.example.com, the cookie will be present but the user state will not be present.
|
|
549
|
+
* We need to fetch the user to access the expiration date of the cookie on the new subdomain.
|
|
550
|
+
*
|
|
551
|
+
* This is also needed in case a user logs in with a new user on sub1.example.com and then accesses
|
|
552
|
+
* sub2.example.com that had the original logged-in user. We need to fetch the user to refresh
|
|
553
|
+
* the user state with the correct logged-in user.
|
|
554
|
+
*/ const refreshUserStateFromCookiePromise = fetchProjectSettingsPromise.then(async ()=>{
|
|
555
|
+
/**
|
|
556
|
+
* When cookies are enabled, we need to refresh the user as part of the initialization process
|
|
557
|
+
* to ensure the user is logged in and sync the auth state with the server.
|
|
558
|
+
*
|
|
559
|
+
* This call can fail with a 401 error if the user is not logged in and the SDK should finish its initialization process
|
|
560
|
+
* without throwing an error because that is an expected behavior.
|
|
561
|
+
*/ if (constants.isCookieEnabled(client)) {
|
|
562
|
+
await NotWaasWalletAccountError.refreshUser(client).catch(async (error)=>{
|
|
563
|
+
if (error.status === 401) {
|
|
564
|
+
if (client.user) {
|
|
565
|
+
await logout(client);
|
|
566
|
+
}
|
|
567
|
+
} else {
|
|
568
|
+
throw error;
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
});
|
|
501
573
|
core.initTrack.track({
|
|
502
|
-
name:
|
|
574
|
+
name: getNetworkProviderFromNetworkId.INITIALIZE_STORAGE_SYNC_TRACKER_KEY,
|
|
503
575
|
promise: initializeStorageSyncPromise
|
|
504
576
|
});
|
|
505
577
|
core.initTrack.track({
|
|
506
|
-
name:
|
|
578
|
+
name: getNetworkProviderFromNetworkId.FETCH_PROJECT_SETTINGS_TRACKER_KEY,
|
|
507
579
|
promise: fetchProjectSettingsPromise
|
|
508
580
|
});
|
|
509
581
|
core.initTrack.track({
|
|
510
|
-
name:
|
|
582
|
+
name: getNetworkProviderFromNetworkId.GENERATE_SESSION_KEYS_TRACKER_KEY,
|
|
511
583
|
promise: generateSessionKeysPromise
|
|
512
584
|
});
|
|
585
|
+
core.initTrack.track({
|
|
586
|
+
name: getNetworkProviderFromNetworkId.REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY,
|
|
587
|
+
promise: refreshUserStateFromCookiePromise
|
|
588
|
+
});
|
|
513
589
|
try {
|
|
514
590
|
await core.initTrack.waitForAll();
|
|
515
591
|
core.state.set({
|
|
@@ -557,7 +633,7 @@ const createDeferredPromise = ()=>{
|
|
|
557
633
|
/**
|
|
558
634
|
* Checks if all processes are initialized and resolves the main promise if they are.
|
|
559
635
|
*/ const checkIfAllSettled = ()=>{
|
|
560
|
-
const allSettled = Array.from(tracker.values()).every((status)=>status === 'resolved');
|
|
636
|
+
const allSettled = Array.from(tracker.values()).every(({ status })=>status === 'resolved');
|
|
561
637
|
if (!allSettled) return;
|
|
562
638
|
allSettledPromise.resolve();
|
|
563
639
|
};
|
|
@@ -567,19 +643,28 @@ const createDeferredPromise = ()=>{
|
|
|
567
643
|
}
|
|
568
644
|
// Disable tracking in the next node tick
|
|
569
645
|
void Promise.resolve().then(()=>isTrackEnabled = false);
|
|
570
|
-
tracker.set(name,
|
|
646
|
+
tracker.set(name, {
|
|
647
|
+
promise,
|
|
648
|
+
status: 'pending'
|
|
649
|
+
});
|
|
571
650
|
promise.then(()=>{
|
|
572
|
-
tracker.set(name,
|
|
651
|
+
tracker.set(name, {
|
|
652
|
+
promise,
|
|
653
|
+
status: 'resolved'
|
|
654
|
+
});
|
|
573
655
|
eventEmitter.emit('resolved', name);
|
|
574
656
|
checkIfAllSettled();
|
|
575
657
|
}).catch((error)=>{
|
|
576
|
-
tracker.set(name,
|
|
658
|
+
tracker.set(name, {
|
|
659
|
+
promise,
|
|
660
|
+
status: 'failed'
|
|
661
|
+
});
|
|
577
662
|
eventEmitter.emit('failed', name, error);
|
|
578
663
|
allSettledPromise.reject(error);
|
|
579
664
|
});
|
|
580
665
|
};
|
|
581
666
|
const waitForAll = ()=>allSettledPromise.promise;
|
|
582
|
-
const getTracker = ()=>tracker;
|
|
667
|
+
const getTracker = (trackerKey)=>tracker.get(trackerKey);
|
|
583
668
|
return {
|
|
584
669
|
getTracker,
|
|
585
670
|
off: eventEmitter.off.bind(eventEmitter),
|
|
@@ -591,7 +676,7 @@ const createDeferredPromise = ()=>{
|
|
|
591
676
|
|
|
592
677
|
const createEventEmitter = ()=>new EventEmitter();
|
|
593
678
|
|
|
594
|
-
class UnavailableInServerSideError extends
|
|
679
|
+
class UnavailableInServerSideError extends constants.BaseError {
|
|
595
680
|
constructor(unavailableFeature){
|
|
596
681
|
super({
|
|
597
682
|
cause: null,
|
|
@@ -645,7 +730,64 @@ class UnavailableInServerSideError extends getChainFromVerifiedCredentialChain.B
|
|
|
645
730
|
register: (options)=>browser.startRegistration(options)
|
|
646
731
|
});
|
|
647
732
|
|
|
648
|
-
|
|
733
|
+
const createDebouncedMutex = ()=>{
|
|
734
|
+
const mutexState = new Map();
|
|
735
|
+
return async ({ lockKey, callback, debounceTime = 0 })=>{
|
|
736
|
+
const resolutionPromise = createDeferredPromise();
|
|
737
|
+
// Prefill the state for this key if it doesn't exist to avoid needing to check for existence later.
|
|
738
|
+
if (!mutexState.has(lockKey)) {
|
|
739
|
+
mutexState.set(lockKey, {
|
|
740
|
+
nextCallback: null,
|
|
741
|
+
queuePromise: Promise.resolve(),
|
|
742
|
+
resolutionPromises: [],
|
|
743
|
+
timer: null
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
const currentState = mutexState.get(lockKey);
|
|
747
|
+
// This should never happen, but we'll assert it for TS safety.
|
|
748
|
+
constants.assertDefined(currentState, `Mutex state for key ${lockKey} not found`);
|
|
749
|
+
currentState.resolutionPromises.push(resolutionPromise);
|
|
750
|
+
if (currentState.timer) {
|
|
751
|
+
clearTimeout(currentState.timer);
|
|
752
|
+
}
|
|
753
|
+
// The last invocation wins. Always.
|
|
754
|
+
currentState.nextCallback = callback;
|
|
755
|
+
const addCallbackToQueue = async ()=>{
|
|
756
|
+
currentState.queuePromise = currentState.queuePromise.then(async ()=>{
|
|
757
|
+
if (!currentState.nextCallback) {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
// We can't just use the callback param directly because later invocations
|
|
761
|
+
// should override previous ones.
|
|
762
|
+
// Scenario to illustrate this (none of these will use the timer param for simplicity):
|
|
763
|
+
// 1. Very long running promise callback A runs
|
|
764
|
+
// 2. While it's running, we invoke callback B, which queues itself with "then" and overrides nextCallback with B.
|
|
765
|
+
// 3. While A is still running, we invoke callback C, same thing happens, now nextCallback is C.
|
|
766
|
+
// 4. A resolves, nextCallback is invoked with C.
|
|
767
|
+
// 5. After C resolves, nextCallback is invoked with null, so it doesn't run.
|
|
768
|
+
// Conclusion: B was never executed and only the last invocation runs.
|
|
769
|
+
const { nextCallback } = currentState;
|
|
770
|
+
currentState.nextCallback = null;
|
|
771
|
+
const promisesToResolve = currentState.resolutionPromises;
|
|
772
|
+
currentState.resolutionPromises = [];
|
|
773
|
+
try {
|
|
774
|
+
await nextCallback();
|
|
775
|
+
promisesToResolve.forEach((resolutionPromise)=>resolutionPromise.resolve());
|
|
776
|
+
} catch (error) {
|
|
777
|
+
promisesToResolve.forEach((resolutionPromise)=>resolutionPromise.reject(error));
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
};
|
|
781
|
+
if (debounceTime > 0) {
|
|
782
|
+
currentState.timer = setTimeout(addCallbackToQueue, debounceTime);
|
|
783
|
+
} else {
|
|
784
|
+
await addCallbackToQueue();
|
|
785
|
+
}
|
|
786
|
+
return resolutionPromise.promise;
|
|
787
|
+
};
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
class InvalidStorageValue extends constants.BaseError {
|
|
649
791
|
constructor(key, value){
|
|
650
792
|
super({
|
|
651
793
|
cause: null,
|
|
@@ -744,7 +886,8 @@ class InvalidStorageValue extends getChainFromVerifiedCredentialChain.BaseError
|
|
|
744
886
|
sessionKeys: null,
|
|
745
887
|
token: null,
|
|
746
888
|
unverifiedWalletAccounts: [],
|
|
747
|
-
user: null
|
|
889
|
+
user: null,
|
|
890
|
+
walletProviderKeyMap: {}
|
|
748
891
|
});
|
|
749
892
|
|
|
750
893
|
/**
|
|
@@ -754,7 +897,9 @@ class InvalidStorageValue extends getChainFromVerifiedCredentialChain.BaseError
|
|
|
754
897
|
var _config_coreConfig_apiBaseUrl;
|
|
755
898
|
const apiBaseUrl = (_config_coreConfig_apiBaseUrl = (_config_coreConfig = config.coreConfig) == null ? void 0 : _config_coreConfig.apiBaseUrl) != null ? _config_coreConfig_apiBaseUrl : DEFAULT_API_BASE_URL;
|
|
756
899
|
var _config_coreConfig_logger;
|
|
757
|
-
const logger = (_config_coreConfig_logger = (_config_coreConfig1 = config.coreConfig) == null ? void 0 : _config_coreConfig1.logger) != null ? _config_coreConfig_logger : getNetworkProviderFromNetworkId.createLogger(
|
|
900
|
+
const logger = (_config_coreConfig_logger = (_config_coreConfig1 = config.coreConfig) == null ? void 0 : _config_coreConfig1.logger) != null ? _config_coreConfig_logger : getNetworkProviderFromNetworkId.createLogger({
|
|
901
|
+
level: config.logLevel
|
|
902
|
+
});
|
|
758
903
|
var _config_coreConfig_storageAdapter;
|
|
759
904
|
const storage = getNetworkProviderFromNetworkId.createStorage({
|
|
760
905
|
prefix: `dynamic_${config.environmentId}`,
|
|
@@ -767,6 +912,7 @@ class InvalidStorageValue extends getChainFromVerifiedCredentialChain.BaseError
|
|
|
767
912
|
var _config_coreConfig_navigate;
|
|
768
913
|
const navigate = (_config_coreConfig_navigate = (_config_coreConfig5 = config.coreConfig) == null ? void 0 : _config_coreConfig5.navigate) != null ? _config_coreConfig_navigate : createNavigationHandler();
|
|
769
914
|
const state = createObservableState(getInitialState);
|
|
915
|
+
const debouncedMutex = createDebouncedMutex();
|
|
770
916
|
const eventEmitter = createEventEmitter();
|
|
771
917
|
const initTrack = createAsyncTrack();
|
|
772
918
|
const runtimeServices = createRuntimeServices();
|
|
@@ -775,6 +921,7 @@ class InvalidStorageValue extends getChainFromVerifiedCredentialChain.BaseError
|
|
|
775
921
|
var _config_coreConfig_getApiHeaders;
|
|
776
922
|
return {
|
|
777
923
|
apiBaseUrl,
|
|
924
|
+
debouncedMutex,
|
|
778
925
|
environmentId: config.environmentId,
|
|
779
926
|
eventEmitter,
|
|
780
927
|
extensions: new Set(),
|
|
@@ -789,7 +936,7 @@ class InvalidStorageValue extends getChainFromVerifiedCredentialChain.BaseError
|
|
|
789
936
|
runtimeServices,
|
|
790
937
|
state,
|
|
791
938
|
storage,
|
|
792
|
-
version:
|
|
939
|
+
version: constants.version
|
|
793
940
|
};
|
|
794
941
|
};
|
|
795
942
|
|
|
@@ -832,15 +979,20 @@ class InvalidStorageValue extends getChainFromVerifiedCredentialChain.BaseError
|
|
|
832
979
|
}
|
|
833
980
|
};
|
|
834
981
|
var _config_autoInitialize;
|
|
835
|
-
|
|
982
|
+
// Define if SDK should auto initialize, default to true
|
|
983
|
+
const autoInitialize = (_config_autoInitialize = config.autoInitialize) != null ? _config_autoInitialize : true;
|
|
984
|
+
// Prevent the auto initialization in SSR
|
|
985
|
+
const shouldAutoInitialize = isServerSideRendering() ? false : autoInitialize;
|
|
986
|
+
core.logger.debug('[createDynamicClient] Creating client...');
|
|
836
987
|
if (shouldAutoInitialize) {
|
|
988
|
+
core.logger.debug('[createDynamicClient] Initializing client...');
|
|
837
989
|
void initializeClient(client);
|
|
838
990
|
}
|
|
839
|
-
|
|
991
|
+
constants.setDefaultClient(client);
|
|
840
992
|
return client;
|
|
841
993
|
};
|
|
842
994
|
|
|
843
|
-
class InvalidRedirectStorageStateError extends
|
|
995
|
+
class InvalidRedirectStorageStateError extends constants.BaseError {
|
|
844
996
|
constructor(){
|
|
845
997
|
super({
|
|
846
998
|
cause: null,
|
|
@@ -852,7 +1004,7 @@ class InvalidRedirectStorageStateError extends getChainFromVerifiedCredentialCha
|
|
|
852
1004
|
}
|
|
853
1005
|
}
|
|
854
1006
|
|
|
855
|
-
class MissingRedirectStorageStateError extends
|
|
1007
|
+
class MissingRedirectStorageStateError extends constants.BaseError {
|
|
856
1008
|
constructor(){
|
|
857
1009
|
super({
|
|
858
1010
|
cause: null,
|
|
@@ -864,7 +1016,7 @@ class MissingRedirectStorageStateError extends getChainFromVerifiedCredentialCha
|
|
|
864
1016
|
}
|
|
865
1017
|
}
|
|
866
1018
|
|
|
867
|
-
class MissingSocialUrlParamError extends
|
|
1019
|
+
class MissingSocialUrlParamError extends constants.BaseError {
|
|
868
1020
|
constructor(param){
|
|
869
1021
|
super({
|
|
870
1022
|
cause: null,
|
|
@@ -876,7 +1028,20 @@ class MissingSocialUrlParamError extends getChainFromVerifiedCredentialChain.Bas
|
|
|
876
1028
|
}
|
|
877
1029
|
}
|
|
878
1030
|
|
|
879
|
-
class
|
|
1031
|
+
class MissingUserVerificationError extends constants.BaseError {
|
|
1032
|
+
constructor({ informationToVerify, message }){
|
|
1033
|
+
super({
|
|
1034
|
+
cause: null,
|
|
1035
|
+
code: 'missing_user_verification_error',
|
|
1036
|
+
docsUrl: null,
|
|
1037
|
+
name: 'MissingUserVerificationError',
|
|
1038
|
+
shortMessage: message != null ? message : `The user is missing verification for ${informationToVerify}. Please verify the user's ${informationToVerify}`
|
|
1039
|
+
});
|
|
1040
|
+
this.informationToVerify = informationToVerify;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
class NetworkSwitchingUnavailableError extends constants.BaseError {
|
|
880
1045
|
constructor({ walletProviderKey, originalError, extraMessages }){
|
|
881
1046
|
const cause = originalError instanceof Error ? originalError : null;
|
|
882
1047
|
super({
|
|
@@ -893,7 +1058,7 @@ class NetworkSwitchingUnavailableError extends getChainFromVerifiedCredentialCha
|
|
|
893
1058
|
}
|
|
894
1059
|
}
|
|
895
1060
|
|
|
896
|
-
class NoAddressFoundError extends
|
|
1061
|
+
class NoAddressFoundError extends constants.BaseError {
|
|
897
1062
|
constructor(){
|
|
898
1063
|
super({
|
|
899
1064
|
cause: null,
|
|
@@ -905,7 +1070,7 @@ class NoAddressFoundError extends getChainFromVerifiedCredentialChain.BaseError
|
|
|
905
1070
|
}
|
|
906
1071
|
}
|
|
907
1072
|
|
|
908
|
-
class NoPasskeyCredentialsFoundError extends
|
|
1073
|
+
class NoPasskeyCredentialsFoundError extends constants.BaseError {
|
|
909
1074
|
constructor(){
|
|
910
1075
|
super({
|
|
911
1076
|
cause: null,
|
|
@@ -917,7 +1082,19 @@ class NoPasskeyCredentialsFoundError extends getChainFromVerifiedCredentialChain
|
|
|
917
1082
|
}
|
|
918
1083
|
}
|
|
919
1084
|
|
|
920
|
-
class
|
|
1085
|
+
class NoSmartWalletAccountSignerFoundError extends constants.BaseError {
|
|
1086
|
+
constructor(smartWalletAddress){
|
|
1087
|
+
super({
|
|
1088
|
+
cause: null,
|
|
1089
|
+
code: 'no_smart_wallet_account_signer_found_error',
|
|
1090
|
+
docsUrl: null,
|
|
1091
|
+
name: 'NoSmartWalletAccountSignerFoundError',
|
|
1092
|
+
shortMessage: `No signer wallet account found for smart wallet account ${smartWalletAddress}`
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
class NoWebAuthNSupportError extends constants.BaseError {
|
|
921
1098
|
constructor(){
|
|
922
1099
|
super({
|
|
923
1100
|
cause: null,
|
|
@@ -929,7 +1106,7 @@ class NoWebAuthNSupportError extends getChainFromVerifiedCredentialChain.BaseErr
|
|
|
929
1106
|
}
|
|
930
1107
|
}
|
|
931
1108
|
|
|
932
|
-
class UnrecognizedNetworkError extends
|
|
1109
|
+
class UnrecognizedNetworkError extends constants.BaseError {
|
|
933
1110
|
constructor({ networkId, originalError, walletProviderKey }){
|
|
934
1111
|
const cause = originalError instanceof Error ? originalError : null;
|
|
935
1112
|
super({
|
|
@@ -945,7 +1122,7 @@ class UnrecognizedNetworkError extends getChainFromVerifiedCredentialChain.BaseE
|
|
|
945
1122
|
}
|
|
946
1123
|
}
|
|
947
1124
|
|
|
948
|
-
class UserNotAuthenticatedError extends
|
|
1125
|
+
class UserNotAuthenticatedError extends constants.BaseError {
|
|
949
1126
|
constructor({ shortMessage } = {}){
|
|
950
1127
|
super({
|
|
951
1128
|
cause: null,
|
|
@@ -957,7 +1134,7 @@ class UserNotAuthenticatedError extends getChainFromVerifiedCredentialChain.Base
|
|
|
957
1134
|
}
|
|
958
1135
|
}
|
|
959
1136
|
|
|
960
|
-
class UserRejectedError extends
|
|
1137
|
+
class UserRejectedError extends constants.BaseError {
|
|
961
1138
|
constructor({ action }){
|
|
962
1139
|
super({
|
|
963
1140
|
cause: null,
|
|
@@ -969,7 +1146,7 @@ class UserRejectedError extends getChainFromVerifiedCredentialChain.BaseError {
|
|
|
969
1146
|
}
|
|
970
1147
|
}
|
|
971
1148
|
|
|
972
|
-
class WalletAccountAlreadyVerifiedError extends
|
|
1149
|
+
class WalletAccountAlreadyVerifiedError extends constants.BaseError {
|
|
973
1150
|
constructor(address){
|
|
974
1151
|
super({
|
|
975
1152
|
cause: null,
|
|
@@ -981,33 +1158,22 @@ class WalletAccountAlreadyVerifiedError extends getChainFromVerifiedCredentialCh
|
|
|
981
1158
|
}
|
|
982
1159
|
}
|
|
983
1160
|
|
|
984
|
-
class WalletAccountNotSelectedError extends
|
|
1161
|
+
class WalletAccountNotSelectedError extends constants.BaseError {
|
|
985
1162
|
constructor(params){
|
|
1163
|
+
const currentAccountInfo = params.selectedAddress ? ` (currently ${params.selectedAddress})` : '';
|
|
986
1164
|
super({
|
|
987
1165
|
cause: null,
|
|
988
1166
|
code: 'wallet_account_not_selected_error',
|
|
989
1167
|
docsUrl: null,
|
|
990
1168
|
name: 'WalletAccountNotSelected',
|
|
991
|
-
shortMessage: `This wallet only supports signing with its selected account
|
|
1169
|
+
shortMessage: `This wallet only supports signing with its selected account${currentAccountInfo}. Please select account ${params.expectedAddress} in your wallet app and try again`
|
|
992
1170
|
});
|
|
993
1171
|
this.expectedAddress = params.expectedAddress;
|
|
994
1172
|
this.selectedAddress = params.selectedAddress;
|
|
995
1173
|
}
|
|
996
1174
|
}
|
|
997
1175
|
|
|
998
|
-
class
|
|
999
|
-
constructor({ cause }){
|
|
1000
|
-
super({
|
|
1001
|
-
cause,
|
|
1002
|
-
code: 'wallet_already_linked_to_another_user_error',
|
|
1003
|
-
docsUrl: null,
|
|
1004
|
-
name: 'WalletAlreadyLinkedToAnotherUserError',
|
|
1005
|
-
shortMessage: 'This wallet is already linked to another user'
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
class WalletProviderMethodUnavailableError extends getChainFromVerifiedCredentialChain.BaseError {
|
|
1176
|
+
class WalletProviderMethodUnavailableError extends constants.BaseError {
|
|
1011
1177
|
constructor({ methodName, walletProviderKey }){
|
|
1012
1178
|
super({
|
|
1013
1179
|
cause: null,
|
|
@@ -1028,9 +1194,9 @@ class WalletProviderMethodUnavailableError extends getChainFromVerifiedCredentia
|
|
|
1028
1194
|
* @param [params.externalJwt] - Optional external JWT token to authenticate with. Not required when using cookie based auth.
|
|
1029
1195
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1030
1196
|
* @returns A promise that resolves to the authentication response from the server.
|
|
1031
|
-
*/ const signInWithExternalJwt = async ({ externalJwt, sessionPublicKey } = {}, client =
|
|
1032
|
-
const core =
|
|
1033
|
-
const apiClient =
|
|
1197
|
+
*/ const signInWithExternalJwt = async ({ externalJwt, sessionPublicKey } = {}, client = constants.getDefaultClient())=>{
|
|
1198
|
+
const core = constants.getCore(client);
|
|
1199
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1034
1200
|
const response = await apiClient.externalAuthSignin({
|
|
1035
1201
|
environmentId: core.environmentId,
|
|
1036
1202
|
externalAuthSigninRequest: {
|
|
@@ -1038,7 +1204,7 @@ class WalletProviderMethodUnavailableError extends getChainFromVerifiedCredentia
|
|
|
1038
1204
|
sessionPublicKey
|
|
1039
1205
|
}
|
|
1040
1206
|
});
|
|
1041
|
-
|
|
1207
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1042
1208
|
response
|
|
1043
1209
|
}, client);
|
|
1044
1210
|
return response;
|
|
@@ -1050,9 +1216,11 @@ class WalletProviderMethodUnavailableError extends getChainFromVerifiedCredentia
|
|
|
1050
1216
|
* @param params.passkeyId - The unique identifier of the passkey to delete.
|
|
1051
1217
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1052
1218
|
* @returns A promise that resolves when the passkey is successfully deleted.
|
|
1053
|
-
*/ const deletePasskey = async ({ passkeyId }, client =
|
|
1054
|
-
const core =
|
|
1055
|
-
const apiClient =
|
|
1219
|
+
*/ const deletePasskey = async ({ passkeyId }, client = constants.getDefaultClient())=>{
|
|
1220
|
+
const core = constants.getCore(client);
|
|
1221
|
+
const apiClient = constants.createApiClient({
|
|
1222
|
+
includeMfaToken: true
|
|
1223
|
+
}, client);
|
|
1056
1224
|
await apiClient.deletePasskey({
|
|
1057
1225
|
deleteUserPasskeyRequest: {
|
|
1058
1226
|
passkeyId
|
|
@@ -1069,9 +1237,9 @@ class WalletProviderMethodUnavailableError extends getChainFromVerifiedCredentia
|
|
|
1069
1237
|
*
|
|
1070
1238
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1071
1239
|
* @returns A promise that resolves to an array of the user's registered passkeys.
|
|
1072
|
-
*/ const getPasskeys = async (client =
|
|
1073
|
-
const core =
|
|
1074
|
-
const apiClient =
|
|
1240
|
+
*/ const getPasskeys = async (client = constants.getDefaultClient())=>{
|
|
1241
|
+
const core = constants.getCore(client);
|
|
1242
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1075
1243
|
const response = await apiClient.getUserPasskeys({
|
|
1076
1244
|
environmentId: core.environmentId
|
|
1077
1245
|
});
|
|
@@ -1079,8 +1247,8 @@ class WalletProviderMethodUnavailableError extends getChainFromVerifiedCredentia
|
|
|
1079
1247
|
};
|
|
1080
1248
|
|
|
1081
1249
|
const getPasskeyRegistrationOptions = async (client)=>{
|
|
1082
|
-
const core =
|
|
1083
|
-
const apiClient =
|
|
1250
|
+
const core = constants.getCore(client);
|
|
1251
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1084
1252
|
const options = await apiClient.getPasskeyRegistrationOptions({
|
|
1085
1253
|
environmentId: core.environmentId
|
|
1086
1254
|
});
|
|
@@ -1088,12 +1256,12 @@ const getPasskeyRegistrationOptions = async (client)=>{
|
|
|
1088
1256
|
};
|
|
1089
1257
|
|
|
1090
1258
|
const serverRegisterPasskey = async ({ registration }, client)=>{
|
|
1091
|
-
const core =
|
|
1092
|
-
const apiClient =
|
|
1259
|
+
const core = constants.getCore(client);
|
|
1260
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1093
1261
|
const response = await apiClient.registerPasskey({
|
|
1094
1262
|
environmentId: core.environmentId,
|
|
1095
|
-
passkeyRegisterRequest:
|
|
1096
|
-
response:
|
|
1263
|
+
passkeyRegisterRequest: constants._extends({}, registration, {
|
|
1264
|
+
response: constants._extends({}, registration.response, {
|
|
1097
1265
|
clientDataJson: registration.response.clientDataJSON
|
|
1098
1266
|
})
|
|
1099
1267
|
})
|
|
@@ -1111,8 +1279,8 @@ const serverRegisterPasskey = async ({ registration }, client)=>{
|
|
|
1111
1279
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1112
1280
|
* @returns A promise that resolves to the registration response.
|
|
1113
1281
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
1114
|
-
*/ const registerPasskey = async (client =
|
|
1115
|
-
const core =
|
|
1282
|
+
*/ const registerPasskey = async (client = constants.getDefaultClient())=>{
|
|
1283
|
+
const core = constants.getCore(client);
|
|
1116
1284
|
if (!core.passkey.isSupported()) {
|
|
1117
1285
|
throw new NoWebAuthNSupportError();
|
|
1118
1286
|
}
|
|
@@ -1123,29 +1291,30 @@ const serverRegisterPasskey = async ({ registration }, client)=>{
|
|
|
1123
1291
|
const response = await serverRegisterPasskey({
|
|
1124
1292
|
registration
|
|
1125
1293
|
}, client);
|
|
1126
|
-
|
|
1294
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1127
1295
|
response
|
|
1128
1296
|
}, client);
|
|
1129
1297
|
return response;
|
|
1130
1298
|
};
|
|
1131
1299
|
|
|
1132
|
-
const getPasskeyAuthenticationSignInOptions = async (client)=>{
|
|
1133
|
-
const core =
|
|
1134
|
-
const apiClient =
|
|
1300
|
+
const getPasskeyAuthenticationSignInOptions = async ({ relatedOriginRpId } = {}, client)=>{
|
|
1301
|
+
const core = constants.getCore(client);
|
|
1302
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1135
1303
|
const options = await apiClient.getPasskeyAuthenticationSigninOptions({
|
|
1136
|
-
environmentId: core.environmentId
|
|
1304
|
+
environmentId: core.environmentId,
|
|
1305
|
+
relatedOriginRpId: relatedOriginRpId
|
|
1137
1306
|
});
|
|
1138
1307
|
return options;
|
|
1139
1308
|
};
|
|
1140
1309
|
|
|
1141
1310
|
const serverSigninPasskey = async ({ authentication, createMfaToken }, client)=>{
|
|
1142
|
-
const core =
|
|
1143
|
-
const apiClient =
|
|
1311
|
+
const core = constants.getCore(client);
|
|
1312
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1144
1313
|
const response = await apiClient.signinWithPasskey({
|
|
1145
1314
|
environmentId: core.environmentId,
|
|
1146
|
-
passkeyAuthRequest:
|
|
1315
|
+
passkeyAuthRequest: constants._extends({}, authentication, {
|
|
1147
1316
|
createMfaToken,
|
|
1148
|
-
response:
|
|
1317
|
+
response: constants._extends({}, authentication.response, {
|
|
1149
1318
|
clientDataJson: authentication.response.clientDataJSON
|
|
1150
1319
|
})
|
|
1151
1320
|
})
|
|
@@ -1163,107 +1332,67 @@ const serverSigninPasskey = async ({ authentication, createMfaToken }, client)=>
|
|
|
1163
1332
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1164
1333
|
* @returns A promise that resolves to the authentication response.
|
|
1165
1334
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
1166
|
-
*/ const signInWithPasskey = async (client =
|
|
1167
|
-
const core =
|
|
1335
|
+
*/ const signInWithPasskey = async ({ relatedOriginRpId } = {}, client = constants.getDefaultClient())=>{
|
|
1336
|
+
const core = constants.getCore(client);
|
|
1168
1337
|
if (!core.passkey.isSupported()) {
|
|
1169
1338
|
throw new NoWebAuthNSupportError();
|
|
1170
1339
|
}
|
|
1171
|
-
const options = await getPasskeyAuthenticationSignInOptions(
|
|
1172
|
-
|
|
1340
|
+
const options = await getPasskeyAuthenticationSignInOptions({
|
|
1341
|
+
relatedOriginRpId
|
|
1342
|
+
}, client);
|
|
1343
|
+
const formattedOptions = constants._extends({}, options);
|
|
1173
1344
|
const authentication = await core.passkey.authenticate({
|
|
1174
1345
|
optionsJSON: formattedOptions
|
|
1175
1346
|
});
|
|
1176
1347
|
const response = await serverSigninPasskey({
|
|
1177
1348
|
authentication
|
|
1178
1349
|
}, client);
|
|
1179
|
-
|
|
1350
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1180
1351
|
response
|
|
1181
1352
|
}, client);
|
|
1182
1353
|
return response;
|
|
1183
1354
|
};
|
|
1184
1355
|
|
|
1185
|
-
/** The schema to track the state of the OAuth flow. */ const redirectStateStorageSchema = getNetworkProviderFromNetworkId.createStorageKeySchema({
|
|
1186
|
-
key: 'redirectState',
|
|
1187
|
-
schema: z__namespace.object({
|
|
1188
|
-
codeVerifier: z__namespace.optional(z__namespace.string()),
|
|
1189
|
-
provider: z__namespace.enum(sdkApiCore.ProviderEnum),
|
|
1190
|
-
state: z__namespace.string()
|
|
1191
|
-
})
|
|
1192
|
-
});
|
|
1193
|
-
|
|
1194
1356
|
/**
|
|
1195
|
-
*
|
|
1357
|
+
* Retrieves all social accounts associated with the current user.
|
|
1196
1358
|
*
|
|
1197
|
-
* This function processes the OAuth callback URL with authorization codes
|
|
1198
|
-
* and completes the user authentication with the social provider.
|
|
1199
|
-
*
|
|
1200
|
-
* @param params.url - The callback URL containing OAuth response parameters.
|
|
1201
1359
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1202
|
-
* @returns
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
throw new MissingRedirectStorageStateError();
|
|
1220
|
-
}
|
|
1221
|
-
if (storedSocialRedirectState.state !== dynamicOauthState) {
|
|
1222
|
-
throw new InvalidRedirectStorageStateError();
|
|
1223
|
-
}
|
|
1224
|
-
const { provider, codeVerifier } = storedSocialRedirectState;
|
|
1225
|
-
await core.storage.removeItem(redirectStateStorageSchema);
|
|
1226
|
-
const response = await apiClient.oauthSignIn({
|
|
1227
|
-
environmentId: core.environmentId,
|
|
1228
|
-
oauthRequest: {
|
|
1229
|
-
captchaToken: getNetworkProviderFromNetworkId.consumeCaptchaToken(client),
|
|
1230
|
-
code: dynamicOauthCode,
|
|
1231
|
-
codeVerifier,
|
|
1232
|
-
state: dynamicOauthState
|
|
1233
|
-
},
|
|
1234
|
-
providerType: provider
|
|
1360
|
+
* @returns An array of `SocialAccount` objects associated with the user.
|
|
1361
|
+
*/ const getUserSocialAccounts = (client = constants.getDefaultClient())=>{
|
|
1362
|
+
const { user } = client;
|
|
1363
|
+
constants.assertDefined(user, 'User is not authenticated');
|
|
1364
|
+
var _user_verifiedCredentials_filter;
|
|
1365
|
+
const socialCredentials = (_user_verifiedCredentials_filter = user.verifiedCredentials.filter((credential)=>credential.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Oauth)) != null ? _user_verifiedCredentials_filter : [];
|
|
1366
|
+
return socialCredentials.map((credential)=>{
|
|
1367
|
+
var _credential_oauthAccountId, _credential_oauthDisplayName, _credential_oauthEmails, _credential_oauthAccountPhotos, _credential_oauthUsername;
|
|
1368
|
+
return {
|
|
1369
|
+
accountId: (_credential_oauthAccountId = credential.oauthAccountId) != null ? _credential_oauthAccountId : undefined,
|
|
1370
|
+
displayName: (_credential_oauthDisplayName = credential.oauthDisplayName) != null ? _credential_oauthDisplayName : undefined,
|
|
1371
|
+
emails: (_credential_oauthEmails = credential.oauthEmails) != null ? _credential_oauthEmails : [],
|
|
1372
|
+
photos: (_credential_oauthAccountPhotos = credential.oauthAccountPhotos) != null ? _credential_oauthAccountPhotos : [],
|
|
1373
|
+
provider: credential.oauthProvider,
|
|
1374
|
+
username: (_credential_oauthUsername = credential.oauthUsername) != null ? _credential_oauthUsername : undefined,
|
|
1375
|
+
verifiedCredentialId: credential.id
|
|
1376
|
+
};
|
|
1235
1377
|
});
|
|
1236
|
-
getWalletProviderByKey.updateAuthFromVerifyResponse({
|
|
1237
|
-
response
|
|
1238
|
-
}, client);
|
|
1239
|
-
return response.user;
|
|
1240
1378
|
};
|
|
1241
1379
|
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
*
|
|
1248
|
-
* @param params.url - The URL to check for OAuth redirect parameters.
|
|
1249
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1250
|
-
* @returns A promise that resolves to true if the URL is an OAuth redirect, false otherwise.
|
|
1251
|
-
*/ const detectOAuthRedirect = async ({ url }, client = getChainFromVerifiedCredentialChain.getDefaultClient())=>{
|
|
1252
|
-
const core = getChainFromVerifiedCredentialChain.getCore(client);
|
|
1253
|
-
const dynamicOauthState = url.searchParams.get('dynamicOauthState');
|
|
1254
|
-
const dynamicOauthCode = url.searchParams.get('dynamicOauthCode');
|
|
1255
|
-
if (!dynamicOauthState || !dynamicOauthCode) {
|
|
1256
|
-
return false;
|
|
1257
|
-
}
|
|
1258
|
-
// Wait for SDK to load
|
|
1259
|
-
await core.initTrack.waitForAll();
|
|
1260
|
-
const storedSocialRedirectState = await core.storage.getItem(redirectStateStorageSchema);
|
|
1261
|
-
if (!storedSocialRedirectState || storedSocialRedirectState.state !== dynamicOauthState) {
|
|
1262
|
-
return false;
|
|
1263
|
-
}
|
|
1264
|
-
return true;
|
|
1380
|
+
const removeDynamicOauthParamsFromUrl = (url)=>{
|
|
1381
|
+
const urlObject = new URL(url);
|
|
1382
|
+
urlObject.searchParams.delete('dynamicOauthState');
|
|
1383
|
+
urlObject.searchParams.delete('dynamicOauthCode');
|
|
1384
|
+
return urlObject.toString();
|
|
1265
1385
|
};
|
|
1266
1386
|
|
|
1387
|
+
/** The schema to track the state of the OAuth flow. */ const redirectStateStorageKeySchema = getNetworkProviderFromNetworkId.createStorageKeySchema({
|
|
1388
|
+
key: 'redirectState',
|
|
1389
|
+
schema: z__namespace.object({
|
|
1390
|
+
codeVerifier: z__namespace.optional(z__namespace.string()),
|
|
1391
|
+
provider: z__namespace.enum(sdkApiCore.ProviderEnum),
|
|
1392
|
+
state: z__namespace.string()
|
|
1393
|
+
})
|
|
1394
|
+
});
|
|
1395
|
+
|
|
1267
1396
|
const digestSHA256 = (str)=>{
|
|
1268
1397
|
const encoder = new TextEncoder();
|
|
1269
1398
|
const data = encoder.encode(str);
|
|
@@ -1285,9 +1414,9 @@ const digestSHA256 = (str)=>{
|
|
|
1285
1414
|
const APPLE_RESPONSE_MODE = 'form_post';
|
|
1286
1415
|
const APPLE_RESPONSE_TYPE = 'code id_token';
|
|
1287
1416
|
/** Helper function to add OAuth URL parameters to a given base URL. */ const addOAuthUrlParams = (provider, baseUrl)=>{
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1417
|
+
constants.assertDefined(provider.clientId, 'Client ID not found');
|
|
1418
|
+
constants.assertDefined(provider.provider, 'Provider type not found');
|
|
1419
|
+
constants.assertDefined(provider.redirectUrl, 'Redirect URL not found');
|
|
1291
1420
|
const providerType = provider.provider;
|
|
1292
1421
|
baseUrl.searchParams.set('client_id', provider.clientId);
|
|
1293
1422
|
baseUrl.searchParams.set('response_type', 'code');
|
|
@@ -1311,15 +1440,15 @@ const APPLE_RESPONSE_TYPE = 'code id_token';
|
|
|
1311
1440
|
};
|
|
1312
1441
|
|
|
1313
1442
|
/** Helper function to build the OAuth base URL for a given provider. */ const getOAuthBaseUrl = (provider)=>{
|
|
1314
|
-
|
|
1443
|
+
constants.assertDefined(provider.provider, 'Provider type not found');
|
|
1315
1444
|
const providerType = provider.provider;
|
|
1316
1445
|
if (providerType === sdkApiCore.ProviderEnum.Telegram) {
|
|
1317
|
-
|
|
1446
|
+
constants.assertDefined(provider.authorizationUrl, 'Telegram authorization URL not found');
|
|
1318
1447
|
return new URL(provider.authorizationUrl);
|
|
1319
1448
|
}
|
|
1320
|
-
|
|
1449
|
+
constants.assertDefined(provider.baseAuthUrl, 'Base auth URL not found');
|
|
1321
1450
|
if (providerType === sdkApiCore.ProviderEnum.Shopify) {
|
|
1322
|
-
|
|
1451
|
+
constants.assertDefined(provider.shopifyStore, 'Shopify store value not found in provider');
|
|
1323
1452
|
const loginBaseUrl = provider.baseAuthUrl.replace('{{shopifyStore}}', provider.shopifyStore);
|
|
1324
1453
|
return new URL(loginBaseUrl);
|
|
1325
1454
|
}
|
|
@@ -1333,17 +1462,17 @@ const providersRequiringPkce = [
|
|
|
1333
1462
|
/** Helper function to build the OAuth URL for a given provider. */ const buildOAuthUrl = async (/** The core instance. */ core, /** The provider to build the OAuth URL for. */ provider)=>{
|
|
1334
1463
|
const { projectSettings } = core.state.get();
|
|
1335
1464
|
// Check if the provider is supported
|
|
1336
|
-
|
|
1337
|
-
|
|
1465
|
+
constants.assertDefined(projectSettings, 'Project settings not found');
|
|
1466
|
+
constants.assertDefined(projectSettings.providers, 'Project providers not found');
|
|
1338
1467
|
const socialProvider = projectSettings.providers.find((p)=>p.provider === provider);
|
|
1339
|
-
|
|
1468
|
+
constants.assertDefined(socialProvider, `Social provider ${provider} not supported`);
|
|
1340
1469
|
// Build the OAuth URL
|
|
1341
1470
|
const loginBaseUrl = getOAuthBaseUrl(socialProvider);
|
|
1342
1471
|
const socialProviderUrl = addOAuthUrlParams(socialProvider, loginBaseUrl);
|
|
1343
1472
|
// Add PKCE and state parameters
|
|
1344
1473
|
const usingPkce = providersRequiringPkce.includes(provider);
|
|
1345
|
-
const state =
|
|
1346
|
-
const codeVerifier =
|
|
1474
|
+
const state = constants.randomString(32);
|
|
1475
|
+
const codeVerifier = constants.randomString(43);
|
|
1347
1476
|
socialProviderUrl.searchParams.set('state', state);
|
|
1348
1477
|
socialProviderUrl.searchParams.set('response_type', 'code');
|
|
1349
1478
|
if (usingPkce) {
|
|
@@ -1364,25 +1493,27 @@ const providersRequiringPkce = [
|
|
|
1364
1493
|
* This function redirects the user to the specified social provider's
|
|
1365
1494
|
* authorization page to complete OAuth authentication flow.
|
|
1366
1495
|
* After the oauth flow is complete, the user will be redirected back to your app.
|
|
1496
|
+
* You can then call `detectOAuthRedirect` to check if the user got redirected back to your app due to the oauth flow,
|
|
1497
|
+
* and finally call `completeSocialAuthentication` to complete the social authentication flow.
|
|
1367
1498
|
*
|
|
1368
1499
|
* @param params.provider - The social provider to authenticate with (e.g., 'google', 'github').
|
|
1369
1500
|
* @param params.redirectUrl - The URL to redirect back to after authentication.
|
|
1370
1501
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1371
|
-
*/ const
|
|
1372
|
-
const core =
|
|
1373
|
-
const apiClient =
|
|
1502
|
+
*/ const authenticateWithSocial = async ({ provider, redirectUrl }, client = constants.getDefaultClient())=>{
|
|
1503
|
+
const core = constants.getCore(client);
|
|
1504
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1374
1505
|
await core.initTrack.waitForAll();
|
|
1375
1506
|
const providerType = provider;
|
|
1376
1507
|
const { url, state, codeVerifier } = await buildOAuthUrl(core, providerType);
|
|
1377
1508
|
await apiClient.initAuth({
|
|
1378
1509
|
environmentId: core.environmentId,
|
|
1379
1510
|
oauthInitAuthRequest: {
|
|
1380
|
-
redirectUrl,
|
|
1511
|
+
redirectUrl: removeDynamicOauthParamsFromUrl(redirectUrl),
|
|
1381
1512
|
state
|
|
1382
1513
|
},
|
|
1383
1514
|
providerType
|
|
1384
1515
|
});
|
|
1385
|
-
await core.storage.setItem(
|
|
1516
|
+
await core.storage.setItem(redirectStateStorageKeySchema, {
|
|
1386
1517
|
codeVerifier,
|
|
1387
1518
|
provider: providerType,
|
|
1388
1519
|
state
|
|
@@ -1390,6 +1521,136 @@ const providersRequiringPkce = [
|
|
|
1390
1521
|
await core.navigate(url.toString());
|
|
1391
1522
|
};
|
|
1392
1523
|
|
|
1524
|
+
/**
|
|
1525
|
+
* Completes the social authentication flow after OAuth redirect.
|
|
1526
|
+
*
|
|
1527
|
+
* This function processes the OAuth callback URL with authorization codes
|
|
1528
|
+
* and completes the user authentication with the social provider.
|
|
1529
|
+
*
|
|
1530
|
+
* @param params.url - The callback URL containing OAuth response parameters.
|
|
1531
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1532
|
+
* @returns A promise that resolves to the authenticated user or null.
|
|
1533
|
+
* @throws MissingSocialUrlParamError If required OAuth parameters are missing.
|
|
1534
|
+
* @throws InvalidRedirectStorageStateError If the stored state doesn't match.
|
|
1535
|
+
*/ const completeSocialAuthentication = async ({ url }, client = constants.getDefaultClient())=>{
|
|
1536
|
+
const core = constants.getCore(client);
|
|
1537
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1538
|
+
await core.initTrack.waitForAll();
|
|
1539
|
+
const dynamicOauthState = url.searchParams.get('dynamicOauthState');
|
|
1540
|
+
const dynamicOauthCode = url.searchParams.get('dynamicOauthCode');
|
|
1541
|
+
if (!dynamicOauthState) {
|
|
1542
|
+
throw new MissingSocialUrlParamError('dynamicOauthState');
|
|
1543
|
+
}
|
|
1544
|
+
if (!dynamicOauthCode) {
|
|
1545
|
+
throw new MissingSocialUrlParamError('dynamicOauthCode');
|
|
1546
|
+
}
|
|
1547
|
+
const storedSocialRedirectState = await core.storage.getItem(redirectStateStorageKeySchema);
|
|
1548
|
+
if (!storedSocialRedirectState) {
|
|
1549
|
+
throw new MissingRedirectStorageStateError();
|
|
1550
|
+
}
|
|
1551
|
+
if (storedSocialRedirectState.state !== dynamicOauthState) {
|
|
1552
|
+
throw new InvalidRedirectStorageStateError();
|
|
1553
|
+
}
|
|
1554
|
+
const { provider, codeVerifier } = storedSocialRedirectState;
|
|
1555
|
+
await core.storage.removeItem(redirectStateStorageKeySchema);
|
|
1556
|
+
let response;
|
|
1557
|
+
// if user is alreadyauthenticated, we're verifying the social auth to link it to the user
|
|
1558
|
+
if (client.user) {
|
|
1559
|
+
response = await apiClient.oauthVerify({
|
|
1560
|
+
environmentId: core.environmentId,
|
|
1561
|
+
oauthRequest: {
|
|
1562
|
+
code: dynamicOauthCode,
|
|
1563
|
+
codeVerifier,
|
|
1564
|
+
state: dynamicOauthState
|
|
1565
|
+
},
|
|
1566
|
+
providerType: provider
|
|
1567
|
+
});
|
|
1568
|
+
} else {
|
|
1569
|
+
// if user is not authenticated, we're signing in with the social auth
|
|
1570
|
+
response = await apiClient.oauthSignIn({
|
|
1571
|
+
environmentId: core.environmentId,
|
|
1572
|
+
oauthRequest: {
|
|
1573
|
+
captchaToken: getNetworkProviderFromNetworkId.consumeCaptchaToken(client),
|
|
1574
|
+
code: dynamicOauthCode,
|
|
1575
|
+
codeVerifier,
|
|
1576
|
+
state: dynamicOauthState
|
|
1577
|
+
},
|
|
1578
|
+
providerType: provider
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1582
|
+
response
|
|
1583
|
+
}, client);
|
|
1584
|
+
return response.user;
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
/**
|
|
1588
|
+
* Detects if the current URL is an OAuth redirect from a social provider.
|
|
1589
|
+
*
|
|
1590
|
+
* This function examines the URL parameters to determine if it contains
|
|
1591
|
+
* OAuth callback data from a social authentication flow.
|
|
1592
|
+
*
|
|
1593
|
+
* @param params.url - The URL to check for OAuth redirect parameters.
|
|
1594
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1595
|
+
* @returns A promise that resolves to true if the URL is an OAuth redirect, false otherwise.
|
|
1596
|
+
*/ const detectOAuthRedirect = async ({ url }, client = constants.getDefaultClient())=>{
|
|
1597
|
+
const core = constants.getCore(client);
|
|
1598
|
+
const dynamicOauthState = url.searchParams.get('dynamicOauthState');
|
|
1599
|
+
const dynamicOauthCode = url.searchParams.get('dynamicOauthCode');
|
|
1600
|
+
if (!dynamicOauthState || !dynamicOauthCode) {
|
|
1601
|
+
return false;
|
|
1602
|
+
}
|
|
1603
|
+
// Wait for SDK to load
|
|
1604
|
+
await core.initTrack.waitForAll();
|
|
1605
|
+
const storedSocialRedirectState = await core.storage.getItem(redirectStateStorageKeySchema);
|
|
1606
|
+
if (!storedSocialRedirectState || storedSocialRedirectState.state !== dynamicOauthState) {
|
|
1607
|
+
return false;
|
|
1608
|
+
}
|
|
1609
|
+
return true;
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Get the primary wallet account.
|
|
1614
|
+
* The primary wallet account is the one that was last selected by the user.
|
|
1615
|
+
* This information is stored in both unverified and verified wallet accounts.
|
|
1616
|
+
* This function consolidates this information to determine which wallet was most recently selected.
|
|
1617
|
+
*/ const getPrimaryWalletAccount = (client = constants.getDefaultClient())=>{
|
|
1618
|
+
const walletAccounts = getVerifiedCredentialForWalletAccount.getWalletAccounts(client);
|
|
1619
|
+
const sortedLastSelectedWalletAccounts = walletAccounts.filter((walletAccount)=>Boolean(walletAccount.lastSelectedAt)).sort((a, b)=>b.lastSelectedAt.getTime() - a.lastSelectedAt.getTime());
|
|
1620
|
+
if (sortedLastSelectedWalletAccounts.length === 0) {
|
|
1621
|
+
return null;
|
|
1622
|
+
}
|
|
1623
|
+
const [primaryWalletAccount] = sortedLastSelectedWalletAccounts;
|
|
1624
|
+
return primaryWalletAccount;
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1627
|
+
/**
|
|
1628
|
+
* Unlinks a social account from the user's account.
|
|
1629
|
+
*
|
|
1630
|
+
* @param params.verifiedCredentialId - The verified credential ID of the social account to unlink.
|
|
1631
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1632
|
+
* @returns A promise that resolves to the verify response.
|
|
1633
|
+
*/ const unlinkSocialAccount = async ({ verifiedCredentialId }, client = constants.getDefaultClient())=>{
|
|
1634
|
+
var _primaryWalletAccount_verifiedCredentialId;
|
|
1635
|
+
const core = constants.getCore(client);
|
|
1636
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1637
|
+
// the api seems to require us to pass the primary wallet id when
|
|
1638
|
+
// unlinking a social account if the user has wallets
|
|
1639
|
+
const primaryWalletAccount = getPrimaryWalletAccount(client);
|
|
1640
|
+
const walletId = primaryWalletAccount == null ? void 0 : (_primaryWalletAccount_verifiedCredentialId = primaryWalletAccount.verifiedCredentialId) == null ? void 0 : _primaryWalletAccount_verifiedCredentialId.replace('-zerodev', '');
|
|
1641
|
+
const response = await apiClient.verifyUnlink({
|
|
1642
|
+
environmentId: core.environmentId,
|
|
1643
|
+
verifyUnlinkRequest: {
|
|
1644
|
+
verifiedCredentialId,
|
|
1645
|
+
walletId: walletId != null ? walletId : undefined
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1649
|
+
response
|
|
1650
|
+
}, client);
|
|
1651
|
+
return response;
|
|
1652
|
+
};
|
|
1653
|
+
|
|
1393
1654
|
/**
|
|
1394
1655
|
* Retrieves token balances across multiple blockchain networks.
|
|
1395
1656
|
*
|
|
@@ -1399,9 +1660,9 @@ const providersRequiringPkce = [
|
|
|
1399
1660
|
* @param params.balanceRequest - The balance request configuration specifying which chains, networks and addresses to query.
|
|
1400
1661
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1401
1662
|
* @returns A promise that resolves to the chain balances across multiple networks.
|
|
1402
|
-
*/ const getMultichainBalances = async ({ balanceRequest }, client =
|
|
1403
|
-
const core =
|
|
1404
|
-
const apiClient =
|
|
1663
|
+
*/ const getMultichainBalances = async ({ balanceRequest }, client = constants.getDefaultClient())=>{
|
|
1664
|
+
const core = constants.getCore(client);
|
|
1665
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1405
1666
|
const response = await apiClient.postMultichainAccountBalances({
|
|
1406
1667
|
environmentId: core.environmentId,
|
|
1407
1668
|
multichainAccountBalancesRequest: balanceRequest
|
|
@@ -1409,6 +1670,242 @@ const providersRequiringPkce = [
|
|
|
1409
1670
|
return response.chainBalances;
|
|
1410
1671
|
};
|
|
1411
1672
|
|
|
1673
|
+
/**
|
|
1674
|
+
* Adds a listener for Coinbase onramp order events.
|
|
1675
|
+
*
|
|
1676
|
+
* @param params.listener - The listener function to call when an event is received.
|
|
1677
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1678
|
+
* @returns A function to remove the listener.
|
|
1679
|
+
* @throws {ValueMustBeDefinedError} If the window is not available.
|
|
1680
|
+
* @docs https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api#events-names
|
|
1681
|
+
*/ const addCoinbaseOnrampOrderEventListener = ({ listener }, client = constants.getDefaultClient())=>{
|
|
1682
|
+
const core = constants.getCore(client);
|
|
1683
|
+
if (typeof window === 'undefined') {
|
|
1684
|
+
throw new constants.ValueMustBeDefinedError('Window is not available to listen for Coinbase onramp order events');
|
|
1685
|
+
}
|
|
1686
|
+
const handleMessageEvent = (event)=>{
|
|
1687
|
+
if (event.origin !== 'https://pay.coinbase.com') {
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
core.logger.debug('[addCoinbaseOnrampOrderEventListener] pay.coinbase.com event received', {
|
|
1691
|
+
event
|
|
1692
|
+
});
|
|
1693
|
+
try {
|
|
1694
|
+
var _coinbaseOnrampOrderEventData_eventName;
|
|
1695
|
+
const coinbaseOnrampOrderEventData = JSON.parse(event.data);
|
|
1696
|
+
if (!((_coinbaseOnrampOrderEventData_eventName = coinbaseOnrampOrderEventData.eventName) == null ? void 0 : _coinbaseOnrampOrderEventData_eventName.startsWith('onramp_api.'))) {
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
listener({
|
|
1700
|
+
data: coinbaseOnrampOrderEventData.data,
|
|
1701
|
+
eventName: coinbaseOnrampOrderEventData.eventName
|
|
1702
|
+
});
|
|
1703
|
+
} catch (error) {
|
|
1704
|
+
core.logger.debug('[addCoinbaseOnrampOrderEventListener] Failed to parse Coinbase onramp order event data', {
|
|
1705
|
+
error
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
window.addEventListener('message', handleMessageEvent);
|
|
1710
|
+
return ()=>{
|
|
1711
|
+
window.removeEventListener('message', handleMessageEvent);
|
|
1712
|
+
};
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
function _object_without_properties_loose(source, excluded) {
|
|
1716
|
+
if (source == null) return {};
|
|
1717
|
+
var target = {};
|
|
1718
|
+
var sourceKeys = Object.keys(source);
|
|
1719
|
+
var key, i;
|
|
1720
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
1721
|
+
key = sourceKeys[i];
|
|
1722
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
1723
|
+
target[key] = source[key];
|
|
1724
|
+
}
|
|
1725
|
+
return target;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
/**
|
|
1729
|
+
* This function is used to get a list of fields that are missing verification for a Coinbase onramp order
|
|
1730
|
+
*
|
|
1731
|
+
* - If the user is missing information for an email or phone number, the field will be returned with the error code MISSING_INFORMATION
|
|
1732
|
+
* - If the user is missing verification for an email or phone number, the field will be returned with the error code MISSING_VERIFICATION
|
|
1733
|
+
* and the existing unverified email or phone number will be included in the data field.
|
|
1734
|
+
* - 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
|
|
1735
|
+
* and the existing phone number will be included in the data field.
|
|
1736
|
+
*
|
|
1737
|
+
* @param params.paymentMethod - The payment method that will be used to create the onramp order
|
|
1738
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1739
|
+
* @returns FieldMissingVerificationForCoinbaseOnramp[] - An array of fields that are missing verification for a Coinbase onramp order
|
|
1740
|
+
* @throws {InvalidParamError} - If the payment method is not valid
|
|
1741
|
+
* @throws {ValueMustBeDefinedError} - If the user is not authenticated
|
|
1742
|
+
*/ const getMissingVerificationForCoinbaseOnrampOrder = ({ paymentMethod }, client = constants.getDefaultClient())=>{
|
|
1743
|
+
// adding the payment method as a param for now just so a user has to pass an object as the first param
|
|
1744
|
+
// that way, when we add more payment methods, we can easily add them to the param object
|
|
1745
|
+
// and not have to change the function signature
|
|
1746
|
+
if (paymentMethod !== 'GUEST_CHECKOUT_APPLE_PAY') {
|
|
1747
|
+
throw new InvalidParamError.InvalidParamError(`Invalid payment method: ${paymentMethod}`);
|
|
1748
|
+
}
|
|
1749
|
+
const { user } = client;
|
|
1750
|
+
constants.assertDefined(user, 'User is not authenticated');
|
|
1751
|
+
const fieldsMissingVerification = [];
|
|
1752
|
+
const emailVerifiedCredential = user.verifiedCredentials.find((credential)=>credential.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Email);
|
|
1753
|
+
if (!user.email) {
|
|
1754
|
+
// when user has no email at all (verified or not)
|
|
1755
|
+
fieldsMissingVerification.push({
|
|
1756
|
+
errorCode: 'MISSING_INFORMATION',
|
|
1757
|
+
field: 'email'
|
|
1758
|
+
});
|
|
1759
|
+
} else if (!emailVerifiedCredential) {
|
|
1760
|
+
// when user has an email but it is not verified
|
|
1761
|
+
fieldsMissingVerification.push({
|
|
1762
|
+
data: user.email,
|
|
1763
|
+
errorCode: 'MISSING_VERIFICATION',
|
|
1764
|
+
field: 'email'
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
const phoneVerifiedCredential = user.verifiedCredentials.find((credential)=>credential.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.PhoneNumber);
|
|
1768
|
+
const phoneNumberVerifiedInPast60Days = (phoneVerifiedCredential == null ? void 0 : phoneVerifiedCredential.verifiedAt) && phoneVerifiedCredential.verifiedAt >= new Date(Date.now() - 60 * 24 * 60 * 60 * 1000);
|
|
1769
|
+
if (!user.phoneNumber) {
|
|
1770
|
+
// when user has no phone number at all (verified or not)
|
|
1771
|
+
fieldsMissingVerification.push({
|
|
1772
|
+
errorCode: 'MISSING_INFORMATION',
|
|
1773
|
+
field: 'phoneNumber'
|
|
1774
|
+
});
|
|
1775
|
+
} else if (!phoneVerifiedCredential) {
|
|
1776
|
+
// when user has a phone number but it is not verified
|
|
1777
|
+
fieldsMissingVerification.push({
|
|
1778
|
+
data: user.phoneNumber,
|
|
1779
|
+
errorCode: 'MISSING_VERIFICATION',
|
|
1780
|
+
field: 'phoneNumber'
|
|
1781
|
+
});
|
|
1782
|
+
} else if (!phoneNumberVerifiedInPast60Days) {
|
|
1783
|
+
// when user has a verified phone number but it is not verified in the last 60 days
|
|
1784
|
+
fieldsMissingVerification.push({
|
|
1785
|
+
data: user.phoneNumber,
|
|
1786
|
+
errorCode: 'VERIFICATION_EXPIRED',
|
|
1787
|
+
field: 'phoneNumber'
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
return fieldsMissingVerification;
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
const validateUserCredentialsForCoinbaseOnrampOrder = (client)=>{
|
|
1794
|
+
const { user } = client;
|
|
1795
|
+
constants.assertDefined(user, 'User is not authenticated');
|
|
1796
|
+
const fieldsMissingVerification = getMissingVerificationForCoinbaseOnrampOrder({
|
|
1797
|
+
paymentMethod: 'GUEST_CHECKOUT_APPLE_PAY'
|
|
1798
|
+
}, client);
|
|
1799
|
+
const missingEmailVerification = fieldsMissingVerification.find((field)=>field.field === 'email');
|
|
1800
|
+
if (missingEmailVerification) {
|
|
1801
|
+
throw new MissingUserVerificationError({
|
|
1802
|
+
informationToVerify: 'email',
|
|
1803
|
+
message: 'User must have a verified email to create a Coinbase onramp order'
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
const missingPhoneNumberVerification = fieldsMissingVerification.find((field)=>field.field === 'phoneNumber');
|
|
1807
|
+
if (missingPhoneNumberVerification && missingPhoneNumberVerification.errorCode !== 'VERIFICATION_EXPIRED') {
|
|
1808
|
+
throw new MissingUserVerificationError({
|
|
1809
|
+
informationToVerify: 'phoneNumber',
|
|
1810
|
+
message: 'User must have a verified phone number to create a Coinbase onramp order'
|
|
1811
|
+
});
|
|
1812
|
+
}
|
|
1813
|
+
// this is a requirement for Coinbase Onramp
|
|
1814
|
+
// https://docs.cdp.coinbase.com/api-reference/v2/rest-api/onramp/create-an-onramp-order#body-phone-number-verified-at
|
|
1815
|
+
if (missingPhoneNumberVerification && missingPhoneNumberVerification.errorCode === 'VERIFICATION_EXPIRED') {
|
|
1816
|
+
throw new MissingUserVerificationError({
|
|
1817
|
+
informationToVerify: 'phoneNumber',
|
|
1818
|
+
message: "The user's phone number has not been verified in the last 60 days. Please re-verify the user's phone number"
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
return user;
|
|
1822
|
+
};
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* Creates a Coinbase onramp order
|
|
1826
|
+
*
|
|
1827
|
+
* @param orderParams CoinbaseCreateOnrampOrderRequest - The parameters for the onramp order.
|
|
1828
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1829
|
+
* @returns The created order
|
|
1830
|
+
* @throws {MissingUserVerificationError} If the user is missing verification for email or phone
|
|
1831
|
+
*/ const createCoinbaseOnrampOrder = async (orderParams, client = constants.getDefaultClient())=>{
|
|
1832
|
+
const user = validateUserCredentialsForCoinbaseOnrampOrder(client);
|
|
1833
|
+
const core = constants.getCore(client);
|
|
1834
|
+
const apiClient = constants.createApiClient({
|
|
1835
|
+
includeMfaToken: true
|
|
1836
|
+
}, client);
|
|
1837
|
+
const { isSandbox } = orderParams, restOrderParams = _object_without_properties_loose(orderParams, [
|
|
1838
|
+
"isSandbox"
|
|
1839
|
+
]);
|
|
1840
|
+
var _orderParams_partnerUserRef;
|
|
1841
|
+
const orderResponse = await apiClient.createCoinbaseOnrampOrder({
|
|
1842
|
+
coinbaseOnrampOrderCreateRequest: constants._extends({}, restOrderParams, {
|
|
1843
|
+
// to create a sandbox order, we need to prefix the partner user ref with 'sandbox-'
|
|
1844
|
+
// https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api#testing
|
|
1845
|
+
partnerUserRef: (_orderParams_partnerUserRef = orderParams.partnerUserRef) != null ? _orderParams_partnerUserRef : isSandbox ? `sandbox-${user.id}` : user.id,
|
|
1846
|
+
paymentMethod: orderParams.paymentMethod
|
|
1847
|
+
}),
|
|
1848
|
+
environmentId: core.environmentId
|
|
1849
|
+
});
|
|
1850
|
+
if (!isSandbox || !orderResponse.paymentLink) {
|
|
1851
|
+
return orderResponse;
|
|
1852
|
+
}
|
|
1853
|
+
return constants._extends({}, orderResponse, {
|
|
1854
|
+
paymentLink: constants._extends({}, orderResponse.paymentLink, {
|
|
1855
|
+
url: `${orderResponse.paymentLink.url}&useApplePaySandbox=true`
|
|
1856
|
+
})
|
|
1857
|
+
});
|
|
1858
|
+
};
|
|
1859
|
+
|
|
1860
|
+
/**
|
|
1861
|
+
* Gets a Coinbase buy URL
|
|
1862
|
+
*
|
|
1863
|
+
* @param buyUrlParams CoinbaseOnrampGetBuyUrlRequest - The parameters for the buy URL.
|
|
1864
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1865
|
+
* @returns an object containing the buy URL
|
|
1866
|
+
*/ const getCoinbaseBuyUrl = async (buyUrlParams, client = constants.getDefaultClient())=>{
|
|
1867
|
+
const core = constants.getCore(client);
|
|
1868
|
+
const apiClient = constants.createApiClient({
|
|
1869
|
+
includeMfaToken: true
|
|
1870
|
+
}, client);
|
|
1871
|
+
const response = await apiClient.generateCoinbaseOnrampBuyUrl({
|
|
1872
|
+
coinbaseOnrampGetBuyUrlRequest: buyUrlParams,
|
|
1873
|
+
environmentId: core.environmentId
|
|
1874
|
+
});
|
|
1875
|
+
return response;
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* Creates a crypto.com payment
|
|
1880
|
+
*
|
|
1881
|
+
* @param paymentParams CryptoDotComPaymentCreateRequest - The parameters for the payment.
|
|
1882
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1883
|
+
* @returns The created payment
|
|
1884
|
+
*/ const createCryptoDotComPayment = async (paymentParams, client = constants.getDefaultClient())=>{
|
|
1885
|
+
const core = constants.getCore(client);
|
|
1886
|
+
const apiClient = constants.createApiClient({
|
|
1887
|
+
includeMfaToken: true
|
|
1888
|
+
}, client);
|
|
1889
|
+
const response = await apiClient.createCryptoDotComPayment({
|
|
1890
|
+
cryptoDotComPaymentCreateRequest: constants._extends({}, paymentParams, {
|
|
1891
|
+
// eslint-disable-next-line custom-rules/ban-chain-enum
|
|
1892
|
+
chain: paymentParams.chain
|
|
1893
|
+
}),
|
|
1894
|
+
environmentId: core.environmentId
|
|
1895
|
+
});
|
|
1896
|
+
return response;
|
|
1897
|
+
};
|
|
1898
|
+
|
|
1899
|
+
/**
|
|
1900
|
+
* Allows waiting until all modules of the client have been properly initialized
|
|
1901
|
+
* and are ready for use.
|
|
1902
|
+
*
|
|
1903
|
+
* @returns a promise that resolves once the client is fully initialized.
|
|
1904
|
+
*/ const waitForClientInitialized = async (client = constants.getDefaultClient())=>{
|
|
1905
|
+
const core = constants.getCore(client);
|
|
1906
|
+
await core.initTrack.waitForAll();
|
|
1907
|
+
};
|
|
1908
|
+
|
|
1412
1909
|
/**
|
|
1413
1910
|
* Updates the current user's profile information.
|
|
1414
1911
|
*
|
|
@@ -1419,16 +1916,16 @@ const providersRequiringPkce = [
|
|
|
1419
1916
|
* @param params.userFields - The user fields to update.
|
|
1420
1917
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1421
1918
|
* @returns A promise that resolves to OTP verification details if verification is required, or undefined.
|
|
1422
|
-
*/ const updateUser = async ({ userFields }, client =
|
|
1423
|
-
const core =
|
|
1424
|
-
const apiClient =
|
|
1919
|
+
*/ const updateUser = async ({ userFields }, client = constants.getDefaultClient())=>{
|
|
1920
|
+
const core = constants.getCore(client);
|
|
1921
|
+
const apiClient = constants.createApiClient({
|
|
1425
1922
|
includeMfaToken: true
|
|
1426
1923
|
}, client);
|
|
1427
1924
|
const response = await apiClient.updateSelf({
|
|
1428
1925
|
environmentId: core.environmentId,
|
|
1429
1926
|
userFields
|
|
1430
1927
|
});
|
|
1431
|
-
|
|
1928
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1432
1929
|
response
|
|
1433
1930
|
}, client);
|
|
1434
1931
|
if (response.emailVerification) {
|
|
@@ -1456,7 +1953,7 @@ const providersRequiringPkce = [
|
|
|
1456
1953
|
*
|
|
1457
1954
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1458
1955
|
* @returns A promise that resolves when the acknowledgment is complete.
|
|
1459
|
-
*/ const acknowledgeRecoveryCodes = async (client =
|
|
1956
|
+
*/ const acknowledgeRecoveryCodes = async (client = constants.getDefaultClient())=>{
|
|
1460
1957
|
return updateUser({
|
|
1461
1958
|
userFields: {
|
|
1462
1959
|
mfaBackupCodeAcknowledgement: sdkApiCore.MfaBackupCodeAcknowledgement.Complete
|
|
@@ -1473,9 +1970,9 @@ const providersRequiringPkce = [
|
|
|
1473
1970
|
* @param params.code - The recovery code to authenticate with.
|
|
1474
1971
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1475
1972
|
* @returns A promise that resolves to the MFA authentication response with token.
|
|
1476
|
-
*/ const authenticateMfaRecoveryCode = async ({ code, createMfaTokenOptions }, client =
|
|
1477
|
-
const core =
|
|
1478
|
-
const apiClient =
|
|
1973
|
+
*/ const authenticateMfaRecoveryCode = async ({ code, createMfaTokenOptions }, client = constants.getDefaultClient())=>{
|
|
1974
|
+
const core = constants.getCore(client);
|
|
1975
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1479
1976
|
try {
|
|
1480
1977
|
const response = await apiClient.authMfaRecovery({
|
|
1481
1978
|
environmentId: core.environmentId,
|
|
@@ -1484,10 +1981,10 @@ const providersRequiringPkce = [
|
|
|
1484
1981
|
createMfaToken: createMfaTokenOptions
|
|
1485
1982
|
}
|
|
1486
1983
|
});
|
|
1487
|
-
|
|
1984
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1488
1985
|
response
|
|
1489
1986
|
}, client);
|
|
1490
|
-
|
|
1987
|
+
getVerifiedCredentialForWalletAccount.emitEvent({
|
|
1491
1988
|
args: {
|
|
1492
1989
|
mfaToken: response.mfaToken
|
|
1493
1990
|
},
|
|
@@ -1495,7 +1992,7 @@ const providersRequiringPkce = [
|
|
|
1495
1992
|
}, client);
|
|
1496
1993
|
return response;
|
|
1497
1994
|
} catch (error) {
|
|
1498
|
-
|
|
1995
|
+
getVerifiedCredentialForWalletAccount.emitEvent({
|
|
1499
1996
|
args: {
|
|
1500
1997
|
error
|
|
1501
1998
|
},
|
|
@@ -1505,23 +2002,24 @@ const providersRequiringPkce = [
|
|
|
1505
2002
|
}
|
|
1506
2003
|
};
|
|
1507
2004
|
|
|
1508
|
-
const getPasskeyAuthenticationOptions = async (client)=>{
|
|
1509
|
-
const core =
|
|
1510
|
-
const apiClient =
|
|
2005
|
+
const getPasskeyAuthenticationOptions = async ({ relatedOriginRpId } = {}, client)=>{
|
|
2006
|
+
const core = constants.getCore(client);
|
|
2007
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1511
2008
|
const options = await apiClient.getPasskeyAuthenticationOptions({
|
|
1512
|
-
environmentId: core.environmentId
|
|
2009
|
+
environmentId: core.environmentId,
|
|
2010
|
+
relatedOriginRpId
|
|
1513
2011
|
});
|
|
1514
2012
|
return options;
|
|
1515
2013
|
};
|
|
1516
2014
|
|
|
1517
2015
|
const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, client)=>{
|
|
1518
|
-
const core =
|
|
1519
|
-
const apiClient =
|
|
2016
|
+
const core = constants.getCore(client);
|
|
2017
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1520
2018
|
const response = await apiClient.authenticateMfaPasskeyDevice({
|
|
1521
2019
|
environmentId: core.environmentId,
|
|
1522
|
-
passkeyAuthRequest:
|
|
2020
|
+
passkeyAuthRequest: constants._extends({}, authentication, {
|
|
1523
2021
|
createMfaToken,
|
|
1524
|
-
response:
|
|
2022
|
+
response: constants._extends({}, authentication.response, {
|
|
1525
2023
|
clientDataJson: authentication.response.clientDataJSON
|
|
1526
2024
|
})
|
|
1527
2025
|
})
|
|
@@ -1540,22 +2038,24 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1540
2038
|
* @returns A promise that resolves to the MFA authentication response.
|
|
1541
2039
|
* @throws NoWebAuthNSupportError If WebAuthn is not supported by the browser.
|
|
1542
2040
|
* @throws NoPasskeyCredentialsFoundError If no passkey credentials are found.
|
|
1543
|
-
*/ const authenticatePasskeyMFA = async ({ createMfaToken } = {}, client =
|
|
1544
|
-
const core =
|
|
2041
|
+
*/ const authenticatePasskeyMFA = async ({ createMfaToken, relatedOriginRpId } = {}, client = constants.getDefaultClient())=>{
|
|
2042
|
+
const core = constants.getCore(client);
|
|
1545
2043
|
try {
|
|
1546
2044
|
var _options_allowCredentials;
|
|
1547
2045
|
if (!core.passkey.isSupported()) {
|
|
1548
2046
|
throw new NoWebAuthNSupportError();
|
|
1549
2047
|
}
|
|
1550
|
-
const options = await getPasskeyAuthenticationOptions(
|
|
1551
|
-
|
|
2048
|
+
const options = await getPasskeyAuthenticationOptions({
|
|
2049
|
+
relatedOriginRpId
|
|
2050
|
+
}, client);
|
|
2051
|
+
const allowCredentials = (_options_allowCredentials = options.allowCredentials) == null ? void 0 : _options_allowCredentials.map((credential)=>constants._extends({}, credential, {
|
|
1552
2052
|
type: 'public-key'
|
|
1553
2053
|
}));
|
|
1554
2054
|
if (!(allowCredentials == null ? void 0 : allowCredentials.length)) {
|
|
1555
2055
|
throw new NoPasskeyCredentialsFoundError();
|
|
1556
2056
|
}
|
|
1557
2057
|
// Ensure allowCredentials has the required type property
|
|
1558
|
-
const formattedOptions =
|
|
2058
|
+
const formattedOptions = constants._extends({}, options, {
|
|
1559
2059
|
allowCredentials
|
|
1560
2060
|
});
|
|
1561
2061
|
const authentication = await core.passkey.authenticate({
|
|
@@ -1565,10 +2065,10 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1565
2065
|
authentication,
|
|
1566
2066
|
createMfaToken
|
|
1567
2067
|
}, client);
|
|
1568
|
-
|
|
2068
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1569
2069
|
response
|
|
1570
2070
|
}, client);
|
|
1571
|
-
|
|
2071
|
+
getVerifiedCredentialForWalletAccount.emitEvent({
|
|
1572
2072
|
args: {
|
|
1573
2073
|
mfaToken: response.mfaToken
|
|
1574
2074
|
},
|
|
@@ -1576,7 +2076,7 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1576
2076
|
}, client);
|
|
1577
2077
|
return response;
|
|
1578
2078
|
} catch (error) {
|
|
1579
|
-
|
|
2079
|
+
getVerifiedCredentialForWalletAccount.emitEvent({
|
|
1580
2080
|
args: {
|
|
1581
2081
|
error
|
|
1582
2082
|
},
|
|
@@ -1597,9 +2097,9 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1597
2097
|
* @param [params.createMfaTokenOptions] - Optional configuration for MFA token creation.
|
|
1598
2098
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1599
2099
|
* @returns A promise that resolves to the MFA authentication response.
|
|
1600
|
-
*/ const authenticateTotpMfaDevice = async ({ deviceId, code, createMfaTokenOptions }, client =
|
|
1601
|
-
const core =
|
|
1602
|
-
const apiClient =
|
|
2100
|
+
*/ const authenticateTotpMfaDevice = async ({ deviceId, code, createMfaTokenOptions }, client = constants.getDefaultClient())=>{
|
|
2101
|
+
const core = constants.getCore(client);
|
|
2102
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1603
2103
|
try {
|
|
1604
2104
|
const response = await apiClient.authMfaTotpDevice({
|
|
1605
2105
|
environmentId: core.environmentId,
|
|
@@ -1609,10 +2109,10 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1609
2109
|
id: deviceId
|
|
1610
2110
|
}
|
|
1611
2111
|
});
|
|
1612
|
-
|
|
2112
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
1613
2113
|
response
|
|
1614
2114
|
}, client);
|
|
1615
|
-
|
|
2115
|
+
getVerifiedCredentialForWalletAccount.emitEvent({
|
|
1616
2116
|
args: {
|
|
1617
2117
|
deviceId,
|
|
1618
2118
|
mfaToken: response.mfaToken
|
|
@@ -1621,7 +2121,7 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1621
2121
|
}, client);
|
|
1622
2122
|
return response;
|
|
1623
2123
|
} catch (error) {
|
|
1624
|
-
|
|
2124
|
+
getVerifiedCredentialForWalletAccount.emitEvent({
|
|
1625
2125
|
args: {
|
|
1626
2126
|
deviceId,
|
|
1627
2127
|
error
|
|
@@ -1640,9 +2140,9 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1640
2140
|
*
|
|
1641
2141
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1642
2142
|
* @returns A promise that resolves to the newly generated recovery codes.
|
|
1643
|
-
*/ const createNewMfaRecoveryCodes = async (client =
|
|
1644
|
-
const core =
|
|
1645
|
-
const apiClient =
|
|
2143
|
+
*/ const createNewMfaRecoveryCodes = async (client = constants.getDefaultClient())=>{
|
|
2144
|
+
const core = constants.getCore(client);
|
|
2145
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1646
2146
|
return apiClient.createNewRecoveryCodes({
|
|
1647
2147
|
environmentId: core.environmentId
|
|
1648
2148
|
});
|
|
@@ -1658,11 +2158,11 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1658
2158
|
* @param params.mfaAuthToken - The MFA authentication token required for device deletion.
|
|
1659
2159
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1660
2160
|
* @returns A promise that resolves when the MFA device is successfully deleted.
|
|
1661
|
-
*/ const deleteMfaDevice = async ({ deviceId, mfaAuthToken }, client =
|
|
1662
|
-
const core =
|
|
1663
|
-
const apiClient =
|
|
1664
|
-
|
|
1665
|
-
|
|
2161
|
+
*/ const deleteMfaDevice = async ({ deviceId, mfaAuthToken }, client = constants.getDefaultClient())=>{
|
|
2162
|
+
const core = constants.getCore(client);
|
|
2163
|
+
const apiClient = constants.createApiClient({}, client);
|
|
2164
|
+
constants.assertDefined(deviceId, 'deviceId is required');
|
|
2165
|
+
constants.assertDefined(mfaAuthToken, 'mfaAuthToken is required');
|
|
1666
2166
|
return apiClient.deleteMfaDevice({
|
|
1667
2167
|
environmentId: core.environmentId,
|
|
1668
2168
|
mfaDeviceId: deviceId,
|
|
@@ -1678,9 +2178,9 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1678
2178
|
*
|
|
1679
2179
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1680
2180
|
* @returns A promise that resolves to an array of the user's registered MFA devices.
|
|
1681
|
-
*/ const getMfaDevices = async (client =
|
|
1682
|
-
const core =
|
|
1683
|
-
const apiClient =
|
|
2181
|
+
*/ const getMfaDevices = async (client = constants.getDefaultClient())=>{
|
|
2182
|
+
const core = constants.getCore(client);
|
|
2183
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1684
2184
|
const { devices } = await apiClient.getUserMfaDevices({
|
|
1685
2185
|
environmentId: core.environmentId
|
|
1686
2186
|
});
|
|
@@ -1697,9 +2197,9 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1697
2197
|
*
|
|
1698
2198
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1699
2199
|
* @returns A promise that resolves to the user's MFA recovery codes.
|
|
1700
|
-
*/ const getMfaRecoveryCodes = async (client =
|
|
1701
|
-
const core =
|
|
1702
|
-
const apiClient =
|
|
2200
|
+
*/ const getMfaRecoveryCodes = async (client = constants.getDefaultClient())=>{
|
|
2201
|
+
const core = constants.getCore(client);
|
|
2202
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1703
2203
|
return apiClient.getRecoveryCodes({
|
|
1704
2204
|
environmentId: core.environmentId
|
|
1705
2205
|
});
|
|
@@ -1713,9 +2213,9 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1713
2213
|
*
|
|
1714
2214
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1715
2215
|
* @returns True if recovery codes are pending acknowledgment, false otherwise.
|
|
1716
|
-
*/ const isPendingRecoveryCodesAcknowledgment = (client =
|
|
2216
|
+
*/ const isPendingRecoveryCodesAcknowledgment = (client = constants.getDefaultClient())=>{
|
|
1717
2217
|
const user = client.user;
|
|
1718
|
-
|
|
2218
|
+
constants.assertDefined(user, 'User not logged in');
|
|
1719
2219
|
return user.mfaBackupCodeAcknowledgement !== sdkApiCore.MfaBackupCodeAcknowledgement.Complete;
|
|
1720
2220
|
};
|
|
1721
2221
|
|
|
@@ -1727,10 +2227,10 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1727
2227
|
*
|
|
1728
2228
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1729
2229
|
* @returns True if the user needs additional MFA authentication, false otherwise.
|
|
1730
|
-
*/ const isUserMissingMfaAuth = (client =
|
|
2230
|
+
*/ const isUserMissingMfaAuth = (client = constants.getDefaultClient())=>{
|
|
1731
2231
|
var _user_scope;
|
|
1732
2232
|
const user = client.user;
|
|
1733
|
-
|
|
2233
|
+
constants.assertDefined(user, 'User not logged in');
|
|
1734
2234
|
return Boolean((_user_scope = user.scope) == null ? void 0 : _user_scope.includes('requiresAdditionalAuth'));
|
|
1735
2235
|
};
|
|
1736
2236
|
|
|
@@ -1743,9 +2243,9 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1743
2243
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1744
2244
|
* @returns A promise that resolves to the TOTP registration response containing setup information,
|
|
1745
2245
|
* like the secret key and the OTP Auth URI.
|
|
1746
|
-
*/ const registerTotpMfaDevice = async (client =
|
|
1747
|
-
const core =
|
|
1748
|
-
const apiClient =
|
|
2246
|
+
*/ const registerTotpMfaDevice = async (client = constants.getDefaultClient())=>{
|
|
2247
|
+
const core = constants.getCore(client);
|
|
2248
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1749
2249
|
return apiClient.registerTotpMfaDevice({
|
|
1750
2250
|
environmentId: core.environmentId
|
|
1751
2251
|
});
|
|
@@ -1760,10 +2260,10 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1760
2260
|
* @param params.deviceId - The unique identifier of the MFA device to set as default.
|
|
1761
2261
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1762
2262
|
* @returns A promise that resolves when the default MFA device is successfully set.
|
|
1763
|
-
*/ const setDefaultMfaDevice = async ({ deviceId }, client =
|
|
1764
|
-
const core =
|
|
1765
|
-
const apiClient =
|
|
1766
|
-
|
|
2263
|
+
*/ const setDefaultMfaDevice = async ({ deviceId }, client = constants.getDefaultClient())=>{
|
|
2264
|
+
const core = constants.getCore(client);
|
|
2265
|
+
const apiClient = constants.createApiClient({}, client);
|
|
2266
|
+
constants.assertDefined(deviceId, 'deviceId is required');
|
|
1767
2267
|
// All that this endpoint does is set the default device to the one provided.
|
|
1768
2268
|
return apiClient.updateUserMfaDevice({
|
|
1769
2269
|
environmentId: core.environmentId,
|
|
@@ -1779,9 +2279,9 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
|
|
|
1779
2279
|
* @param params.email - The email address to send the OTP to.
|
|
1780
2280
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
1781
2281
|
* @returns A promise that resolves to an OTPVerification object containing the email and verification UUID.
|
|
1782
|
-
*/ const sendEmailOTP = async ({ email }, client =
|
|
1783
|
-
const core =
|
|
1784
|
-
const apiClient =
|
|
2282
|
+
*/ const sendEmailOTP = async ({ email }, client = constants.getDefaultClient())=>{
|
|
2283
|
+
const core = constants.getCore(client);
|
|
2284
|
+
const apiClient = constants.createApiClient({}, client);
|
|
1785
2285
|
const { verificationUUID } = await apiClient.createEmailVerification({
|
|
1786
2286
|
emailVerificationCreateRequest: {
|
|
1787
2287
|
captchaToken: getNetworkProviderFromNetworkId.consumeCaptchaToken(client),
|
|
@@ -2726,9 +3226,9 @@ const supportedCountries = {
|
|
|
2726
3226
|
* @param params.phoneNumber - The phone number to send the OTP to.
|
|
2727
3227
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2728
3228
|
* @returns A promise that resolves to an OTPVerification object containing the phone details and verification UUID.
|
|
2729
|
-
*/ const sendSmsOTP = async ({ isoCountryCode, phoneNumber }, client =
|
|
2730
|
-
const core =
|
|
2731
|
-
const apiClient =
|
|
3229
|
+
*/ const sendSmsOTP = async ({ isoCountryCode, phoneNumber }, client = constants.getDefaultClient())=>{
|
|
3230
|
+
const core = constants.getCore(client);
|
|
3231
|
+
const apiClient = constants.createApiClient({}, client);
|
|
2732
3232
|
const phoneCountryCode = supportedCountries[isoCountryCode].code;
|
|
2733
3233
|
const { verificationUUID } = await apiClient.createSmsVerification({
|
|
2734
3234
|
environmentId: core.environmentId,
|
|
@@ -2748,8 +3248,8 @@ const supportedCountries = {
|
|
|
2748
3248
|
};
|
|
2749
3249
|
|
|
2750
3250
|
const verifyOTPForUserSignIn = async ({ otpVerification, verificationToken }, client)=>{
|
|
2751
|
-
const core =
|
|
2752
|
-
const apiClient =
|
|
3251
|
+
const core = constants.getCore(client);
|
|
3252
|
+
const apiClient = constants.createApiClient({}, client);
|
|
2753
3253
|
const verifyRequest = {
|
|
2754
3254
|
verificationToken,
|
|
2755
3255
|
verificationUUID: otpVerification.verificationUUID
|
|
@@ -2767,8 +3267,8 @@ const verifyOTPForUserSignIn = async ({ otpVerification, verificationToken }, cl
|
|
|
2767
3267
|
};
|
|
2768
3268
|
|
|
2769
3269
|
const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, client)=>{
|
|
2770
|
-
const core =
|
|
2771
|
-
const apiClient =
|
|
3270
|
+
const core = constants.getCore(client);
|
|
3271
|
+
const apiClient = constants.createApiClient({}, client);
|
|
2772
3272
|
const verifyRequest = {
|
|
2773
3273
|
verificationToken,
|
|
2774
3274
|
verificationUUID: otpVerification.verificationUUID
|
|
@@ -2794,17 +3294,36 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2794
3294
|
* @param params.otpVerification - The OTP verification object containing verification details.
|
|
2795
3295
|
* @param params.verificationToken - The token received from the OTP verification process.
|
|
2796
3296
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2797
|
-
* @returns A promise that resolves to the
|
|
2798
|
-
*/ const verifyOTP = async ({ otpVerification, verificationToken }, client =
|
|
3297
|
+
* @returns A promise that resolves to the verify response object upon successful verification.
|
|
3298
|
+
*/ const verifyOTP = async ({ otpVerification, verificationToken }, client = constants.getDefaultClient())=>{
|
|
2799
3299
|
const verifyOTPFunction = client.user ? verifyOTPForUserUpdate : verifyOTPForUserSignIn;
|
|
2800
3300
|
const response = await verifyOTPFunction({
|
|
2801
3301
|
otpVerification,
|
|
2802
3302
|
verificationToken
|
|
2803
3303
|
}, client);
|
|
2804
|
-
|
|
3304
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
2805
3305
|
response
|
|
2806
3306
|
}, client);
|
|
2807
|
-
return response
|
|
3307
|
+
return response;
|
|
3308
|
+
};
|
|
3309
|
+
|
|
3310
|
+
/**
|
|
3311
|
+
* Deletes the current user's account permanently.
|
|
3312
|
+
*
|
|
3313
|
+
* This function performs a hard delete of the user account. Upon successful deletion,
|
|
3314
|
+
* the user will be automatically logged out and all authentication data will be cleared.
|
|
3315
|
+
*
|
|
3316
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3317
|
+
* @returns A promise that resolves when the user account is successfully deleted.
|
|
3318
|
+
*/ const deleteUser = async (client = constants.getDefaultClient())=>{
|
|
3319
|
+
const core = constants.getCore(client);
|
|
3320
|
+
const apiClient = constants.createApiClient({
|
|
3321
|
+
includeMfaToken: true
|
|
3322
|
+
}, client);
|
|
3323
|
+
await apiClient.hardDeleteUser({
|
|
3324
|
+
environmentId: core.environmentId
|
|
3325
|
+
});
|
|
3326
|
+
await logout(client);
|
|
2808
3327
|
};
|
|
2809
3328
|
|
|
2810
3329
|
/**
|
|
@@ -2820,8 +3339,8 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2820
3339
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2821
3340
|
* @returns A promise that resolves if the wallet is available for signing.
|
|
2822
3341
|
* @throws WalletAccountNotSelectedError If the wallet account is not currently selected.
|
|
2823
|
-
*/ const assertWalletAccountSigningAvailability = async ({ walletAccount }, client =
|
|
2824
|
-
const walletProvider =
|
|
3342
|
+
*/ const assertWalletAccountSigningAvailability = async ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3343
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
2825
3344
|
walletAccount
|
|
2826
3345
|
}, client);
|
|
2827
3346
|
const { addresses } = await walletProvider.getConnectedAddresses();
|
|
@@ -2833,49 +3352,6 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2833
3352
|
}
|
|
2834
3353
|
};
|
|
2835
3354
|
|
|
2836
|
-
/*
|
|
2837
|
-
In older SDK versions we used to have the concept of "connect-only" vs "connect-and-sign".
|
|
2838
|
-
The only difference in backend is it stores some extra data for connect-only,
|
|
2839
|
-
so we can just default to using it.
|
|
2840
|
-
*/ const createVisit = async ({ walletAccount, authMode = sdkApiCore.AuthModeEnum.Only }, client)=>{
|
|
2841
|
-
const core = getChainFromVerifiedCredentialChain.getCore(client);
|
|
2842
|
-
const apiClient = getChainFromVerifiedCredentialChain.createApiClient({}, client);
|
|
2843
|
-
const walletProvider = getWalletProviderByKey.getWalletProviderFromWalletAccount({
|
|
2844
|
-
walletAccount
|
|
2845
|
-
}, client);
|
|
2846
|
-
try {
|
|
2847
|
-
const connectRequest = {
|
|
2848
|
-
address: walletAccount.address,
|
|
2849
|
-
authMode,
|
|
2850
|
-
// eslint-disable-next-line custom-rules/ban-chain-enum
|
|
2851
|
-
chain: walletProvider.chain,
|
|
2852
|
-
provider: walletProvider.getWalletProviderType(),
|
|
2853
|
-
walletName: walletAccount.walletProviderKey
|
|
2854
|
-
};
|
|
2855
|
-
await apiClient.createVisit({
|
|
2856
|
-
connectRequest,
|
|
2857
|
-
environmentId: core.environmentId
|
|
2858
|
-
});
|
|
2859
|
-
} catch (error) {
|
|
2860
|
-
core.logger.error('Error creating visit', {
|
|
2861
|
-
error
|
|
2862
|
-
});
|
|
2863
|
-
}
|
|
2864
|
-
};
|
|
2865
|
-
|
|
2866
|
-
/**
|
|
2867
|
-
* Updates the unverified wallet account in the client state.
|
|
2868
|
-
*/ const setUnverifiedWalletAccount = ({ unverifiedWalletAccountToUpdate }, client)=>{
|
|
2869
|
-
const core = getChainFromVerifiedCredentialChain.getCore(client);
|
|
2870
|
-
const filteredUnverifiedWalletAccounts = core.state.get().unverifiedWalletAccounts.filter((unverifiedWalletAccount)=>unverifiedWalletAccount.id !== unverifiedWalletAccountToUpdate.id);
|
|
2871
|
-
core.state.set({
|
|
2872
|
-
unverifiedWalletAccounts: [
|
|
2873
|
-
...filteredUnverifiedWalletAccounts,
|
|
2874
|
-
unverifiedWalletAccountToUpdate
|
|
2875
|
-
]
|
|
2876
|
-
});
|
|
2877
|
-
};
|
|
2878
|
-
|
|
2879
3355
|
/**
|
|
2880
3356
|
* Asserts that a specific wallet provider method is defined, throwing an error if it's not.
|
|
2881
3357
|
* This function acts as a type guard, narrowing the type to ensure the method exists.
|
|
@@ -2900,6 +3376,10 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2900
3376
|
}
|
|
2901
3377
|
}
|
|
2902
3378
|
|
|
3379
|
+
const getAddressesWithTypesFromConnectionResult = (connectionResult)=>{
|
|
3380
|
+
return connectionResult.addresses.filter((address)=>!!address.address && !!address.type);
|
|
3381
|
+
};
|
|
3382
|
+
|
|
2903
3383
|
/**
|
|
2904
3384
|
* Connects to a wallet provider and returns the connected wallet account.
|
|
2905
3385
|
*
|
|
@@ -2909,68 +3389,69 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
|
|
|
2909
3389
|
* @see connectAndVerifyWithWalletProvider
|
|
2910
3390
|
*
|
|
2911
3391
|
* @param params.walletProviderKey - The unique key identifying the wallet provider to connect to (e.g. 'metamaskevm', 'phantomsol').
|
|
2912
|
-
* @param [params.
|
|
3392
|
+
* @param [params.addToDynamicWalletAccounts] - Whether to add the connected wallet account to the user's wallet accounts. Defaults to true.
|
|
2913
3393
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2914
3394
|
* @returns A promise that resolves to the connected wallet account.
|
|
2915
3395
|
* @throws NoAddressFoundError If the request to connect was successful but no address is connected to your app.
|
|
2916
|
-
*/ const connectWithWalletProvider = async ({ walletProviderKey,
|
|
2917
|
-
const walletProvider =
|
|
3396
|
+
*/ const connectWithWalletProvider = async ({ walletProviderKey, addToDynamicWalletAccounts = true }, client = constants.getDefaultClient())=>{
|
|
3397
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderByKey({
|
|
2918
3398
|
walletProviderKey
|
|
2919
3399
|
}, client);
|
|
2920
3400
|
assertWalletProviderMethodDefined(walletProvider, 'connect');
|
|
2921
|
-
const { addresses
|
|
2922
|
-
const currentAddresses =
|
|
3401
|
+
const { addresses } = await walletProvider.connect();
|
|
3402
|
+
const currentAddresses = getVerifiedCredentialForWalletAccount.getWalletAccounts(client).map(({ address })=>address);
|
|
3403
|
+
const mainAddress = (addresses == null ? void 0 : addresses.length) ? addresses[0].address : null;
|
|
2923
3404
|
/**
|
|
2924
3405
|
* This error is thrown in case the wallet has no addresses connected
|
|
2925
3406
|
* to the dapp. Then the error is thrown so the consumer can instruct the
|
|
2926
3407
|
* user on the next steps.
|
|
2927
|
-
*/ if (!
|
|
3408
|
+
*/ if (!mainAddress) {
|
|
2928
3409
|
throw new NoAddressFoundError();
|
|
2929
3410
|
}
|
|
2930
3411
|
const walletAccount = {
|
|
2931
|
-
address:
|
|
3412
|
+
address: mainAddress,
|
|
3413
|
+
addressesWithTypes: getAddressesWithTypesFromConnectionResult({
|
|
3414
|
+
addresses
|
|
3415
|
+
}),
|
|
2932
3416
|
chain: walletProvider.chain,
|
|
2933
|
-
id:
|
|
3417
|
+
id: getVerifiedCredentialForWalletAccount.formatWalletAccountId({
|
|
3418
|
+
address: mainAddress,
|
|
3419
|
+
chain: walletProvider.chain,
|
|
3420
|
+
walletProviderKey
|
|
3421
|
+
}),
|
|
2934
3422
|
lastSelectedAt: null,
|
|
2935
3423
|
verifiedCredentialId: null,
|
|
2936
|
-
walletProviderKey
|
|
3424
|
+
walletProviderKey
|
|
2937
3425
|
};
|
|
2938
|
-
if (currentAddresses.includes(
|
|
3426
|
+
if (currentAddresses.includes(mainAddress)) {
|
|
2939
3427
|
return walletAccount;
|
|
2940
3428
|
}
|
|
2941
|
-
if (
|
|
2942
|
-
|
|
2943
|
-
|
|
3429
|
+
if (addToDynamicWalletAccounts) {
|
|
3430
|
+
getNetworkProviderFromNetworkId.setUnverifiedWalletAccounts({
|
|
3431
|
+
unverifiedWalletAccountsToUpdate: [
|
|
3432
|
+
walletAccount
|
|
3433
|
+
]
|
|
2944
3434
|
}, client);
|
|
2945
|
-
|
|
3435
|
+
getVerifiedCredentialForWalletAccount.emitWalletAccountsChangedEvent(client);
|
|
2946
3436
|
/*
|
|
2947
3437
|
* send information to backend to kick off background jobs
|
|
2948
3438
|
* this is an async work, but does not need to be awaited
|
|
2949
|
-
*/ void createVisit({
|
|
3439
|
+
*/ void getNetworkProviderFromNetworkId.createVisit({
|
|
2950
3440
|
walletAccount
|
|
2951
3441
|
}, client);
|
|
2952
3442
|
}
|
|
2953
3443
|
return walletAccount;
|
|
2954
3444
|
};
|
|
2955
3445
|
|
|
2956
|
-
/**
|
|
2957
|
-
* Check if the given value is an Error object
|
|
2958
|
-
*/ const isError = (error)=>error instanceof Error;
|
|
2959
|
-
|
|
2960
|
-
/**
|
|
2961
|
-
* Check if the given value is an Error object with a specific code
|
|
2962
|
-
*/ const isErrorWithCode = (error, code)=>{
|
|
2963
|
-
if (!isError(error)) return false;
|
|
2964
|
-
return 'code' in error && error.code === code;
|
|
2965
|
-
};
|
|
2966
|
-
|
|
2967
3446
|
const getChainIdForAccountVerification = async ({ walletProvider })=>{
|
|
2968
|
-
//
|
|
2969
|
-
//
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
3447
|
+
// for some chains, we don't need to specify a chain id for account verification because it's
|
|
3448
|
+
// not required and it might break the message signature in some wallets (e.g. Trust Wallet SOL)
|
|
3449
|
+
const chainsThatDontNeedChainId = [
|
|
3450
|
+
'BTC',
|
|
3451
|
+
'SOL',
|
|
3452
|
+
'SUI'
|
|
3453
|
+
];
|
|
3454
|
+
if (chainsThatDontNeedChainId.includes(walletProvider.chain)) {
|
|
2974
3455
|
return undefined;
|
|
2975
3456
|
}
|
|
2976
3457
|
const { networkId } = await walletProvider.getActiveNetworkId();
|
|
@@ -2986,21 +3467,22 @@ const getChainIdForAccountVerification = async ({ walletProvider })=>{
|
|
|
2986
3467
|
|
|
2987
3468
|
const getSignInMessage = async ({ walletAccount }, client)=>{
|
|
2988
3469
|
var _core_metadata;
|
|
2989
|
-
const core =
|
|
2990
|
-
const apiClient =
|
|
3470
|
+
const core = constants.getCore(client);
|
|
3471
|
+
const apiClient = constants.createApiClient({}, client);
|
|
2991
3472
|
const appUrl = (_core_metadata = core.metadata) == null ? void 0 : _core_metadata.url;
|
|
2992
|
-
|
|
3473
|
+
constants.assertDefined(appUrl, 'App URL is not set');
|
|
2993
3474
|
const url = new URL(appUrl);
|
|
2994
3475
|
const { nonce } = await apiClient.getNonce({
|
|
2995
3476
|
environmentId: core.environmentId
|
|
2996
3477
|
});
|
|
2997
|
-
|
|
2998
|
-
const walletProvider =
|
|
3478
|
+
constants.assertDefined(nonce, 'Failed to get nonce');
|
|
3479
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
2999
3480
|
walletAccount
|
|
3000
3481
|
}, client);
|
|
3482
|
+
const statement = getNetworkProviderFromNetworkId.createSignInMessageStatement(client);
|
|
3001
3483
|
const messageToSign = await getNetworkProviderFromNetworkId.formatSignInMessage({
|
|
3002
3484
|
address: walletAccount.address,
|
|
3003
|
-
blockchainName:
|
|
3485
|
+
blockchainName: constants.CHAINS_INFO_MAP[walletProvider.chain].blockchainName,
|
|
3004
3486
|
chainId: await getChainIdForAccountVerification({
|
|
3005
3487
|
walletProvider
|
|
3006
3488
|
}),
|
|
@@ -3008,6 +3490,7 @@ const getSignInMessage = async ({ walletAccount }, client)=>{
|
|
|
3008
3490
|
issuedAt: new Date().toISOString(),
|
|
3009
3491
|
nonce,
|
|
3010
3492
|
requestId: core.environmentId,
|
|
3493
|
+
statement,
|
|
3011
3494
|
uri: url.toString()
|
|
3012
3495
|
});
|
|
3013
3496
|
return messageToSign;
|
|
@@ -3022,8 +3505,8 @@ const getSignInMessage = async ({ walletAccount }, client)=>{
|
|
|
3022
3505
|
* @param params.walletAccount - The wallet account to prove ownership of.
|
|
3023
3506
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3024
3507
|
* @returns A promise that resolves to an object containing the message and signature.
|
|
3025
|
-
*/ const proveWalletAccountOwnership = async ({ walletAccount }, client =
|
|
3026
|
-
const walletProvider =
|
|
3508
|
+
*/ const proveWalletAccountOwnership = async ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3509
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
3027
3510
|
walletAccount
|
|
3028
3511
|
}, client);
|
|
3029
3512
|
assertWalletProviderMethodDefined(walletProvider, 'signMessage');
|
|
@@ -3036,22 +3519,29 @@ const getSignInMessage = async ({ walletAccount }, client)=>{
|
|
|
3036
3519
|
});
|
|
3037
3520
|
return {
|
|
3038
3521
|
messageToSign,
|
|
3039
|
-
|
|
3522
|
+
signature
|
|
3040
3523
|
};
|
|
3041
3524
|
};
|
|
3042
3525
|
|
|
3043
3526
|
/**
|
|
3044
3527
|
* Removes an unverified wallet account from the client's state.
|
|
3045
3528
|
*/ const removeUnverifiedWalletAccount = ({ unverifiedWalletAccount }, client)=>{
|
|
3046
|
-
const core =
|
|
3529
|
+
const core = constants.getCore(client);
|
|
3530
|
+
const previousState = core.state.get();
|
|
3047
3531
|
const { unverifiedWalletAccounts } = core.state.get();
|
|
3048
3532
|
const filteredUnverifiedWalletAccounts = unverifiedWalletAccounts.filter((account)=>account.id !== unverifiedWalletAccount.id);
|
|
3049
3533
|
core.state.set({
|
|
3050
3534
|
unverifiedWalletAccounts: filteredUnverifiedWalletAccounts
|
|
3051
3535
|
});
|
|
3536
|
+
/**
|
|
3537
|
+
* We check before raising because the wallet account we are removing might still
|
|
3538
|
+
* be present in wallet accounts due to having been moved to verified credentials.
|
|
3539
|
+
*/ getVerifiedCredentialForWalletAccount.checkAndRaiseWalletAccountsChangedEvent({
|
|
3540
|
+
previousState
|
|
3541
|
+
}, client);
|
|
3052
3542
|
};
|
|
3053
3543
|
|
|
3054
|
-
const isSameAddress = (left, right, chain)=>
|
|
3544
|
+
const isSameAddress = (left, right, chain)=>getVerifiedCredentialForWalletAccount.normalizeAddress(left, chain) === getVerifiedCredentialForWalletAccount.normalizeAddress(right, chain);
|
|
3055
3545
|
|
|
3056
3546
|
/**
|
|
3057
3547
|
* Verifies ownership of a wallet account and adds it to the user's profile.
|
|
@@ -3064,54 +3554,49 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3064
3554
|
* @returns A promise that resolves to the verified wallet account.
|
|
3065
3555
|
* @throws WalletAccountAlreadyVerifiedError If the wallet is already verified.
|
|
3066
3556
|
* @throws WalletAlreadyLinkedToAnotherUserError If the wallet is linked to another user.
|
|
3067
|
-
*/ const verifyWalletAccount = async ({ walletAccount }, client =
|
|
3557
|
+
*/ const verifyWalletAccount = async ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3558
|
+
var _response_user;
|
|
3068
3559
|
if (walletAccount.verifiedCredentialId) {
|
|
3069
3560
|
throw new WalletAccountAlreadyVerifiedError(walletAccount.address);
|
|
3070
3561
|
}
|
|
3071
|
-
const
|
|
3072
|
-
const apiClient = getChainFromVerifiedCredentialChain.createApiClient({}, client);
|
|
3073
|
-
const walletProvider = getWalletProviderByKey.getWalletProviderFromWalletAccount({
|
|
3562
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
3074
3563
|
walletAccount
|
|
3075
3564
|
}, client);
|
|
3076
|
-
const {
|
|
3565
|
+
const { messageToSign, signature } = await proveWalletAccountOwnership({
|
|
3077
3566
|
walletAccount
|
|
3078
3567
|
}, client);
|
|
3079
|
-
const
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
*/ removeUnverifiedWalletAccount({
|
|
3097
|
-
unverifiedWalletAccount: walletAccount
|
|
3098
|
-
}, client);
|
|
3099
|
-
/**
|
|
3100
|
-
* Adds the user with the new wallet verified credential
|
|
3101
|
-
* This will add the new verified wallet account to the client`s state
|
|
3102
|
-
*/ getWalletProviderByKey.updateAuthFromVerifyResponse({
|
|
3103
|
-
response
|
|
3104
|
-
}, client);
|
|
3105
|
-
} catch (error) {
|
|
3106
|
-
if (isErrorWithCode(error, 'reassign_wallet_confirm') || isErrorWithCode(error, 'merge_accounts_confirmation')) {
|
|
3107
|
-
throw new WalletAlreadyLinkedToAnotherUserError({
|
|
3108
|
-
cause: error
|
|
3109
|
-
});
|
|
3568
|
+
const response = await getNetworkProviderFromNetworkId.verifySignInMessage({
|
|
3569
|
+
addressesWithTypes: walletAccount.addressesWithTypes,
|
|
3570
|
+
chain: walletAccount.chain,
|
|
3571
|
+
messageToSign,
|
|
3572
|
+
signature,
|
|
3573
|
+
walletAddress: walletAccount.address,
|
|
3574
|
+
walletDisplayName: walletProvider.metadata.displayName,
|
|
3575
|
+
walletProviderType: walletProvider.walletProviderType
|
|
3576
|
+
}, client);
|
|
3577
|
+
const walletVerifiedCredential = (_response_user = response.user) == null ? void 0 : _response_user.verifiedCredentials.find((verifiedCredential)=>{
|
|
3578
|
+
var _verifiedCredential_address;
|
|
3579
|
+
return isSameAddress((_verifiedCredential_address = verifiedCredential.address) != null ? _verifiedCredential_address : '', walletAccount.address, walletAccount.chain);
|
|
3580
|
+
});
|
|
3581
|
+
constants.assertDefined(walletVerifiedCredential, `After verifying, still unable to find verified wallet credential for wallet account ${walletAccount.address} on chain ${walletAccount.chain}`);
|
|
3582
|
+
getNetworkProviderFromNetworkId.updateWalletProviderKeysForVerifiedCredentials({
|
|
3583
|
+
keysToUpdate: {
|
|
3584
|
+
[walletVerifiedCredential.id]: walletProvider.key
|
|
3110
3585
|
}
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3586
|
+
}, client);
|
|
3587
|
+
/**
|
|
3588
|
+
* Adds the user with the new wallet verified credential
|
|
3589
|
+
* This will add the new verified wallet account to the client`s state
|
|
3590
|
+
*/ getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
3591
|
+
response
|
|
3592
|
+
}, client);
|
|
3593
|
+
/**
|
|
3594
|
+
* Remove the now verified wallet account from the unverified wallet accounts
|
|
3595
|
+
*/ removeUnverifiedWalletAccount({
|
|
3596
|
+
unverifiedWalletAccount: walletAccount
|
|
3597
|
+
}, client);
|
|
3598
|
+
const verifiedWalletAccount = getVerifiedCredentialForWalletAccount.getWalletAccounts(client).find(({ address })=>isSameAddress(address, walletAccount.address, walletAccount.chain));
|
|
3599
|
+
constants.assertDefined(verifiedWalletAccount, `Unable to find wallet account ${walletAccount.address} on chain ${walletAccount.chain} for verified credential ${walletVerifiedCredential.id}`);
|
|
3115
3600
|
return verifiedWalletAccount;
|
|
3116
3601
|
};
|
|
3117
3602
|
|
|
@@ -3125,9 +3610,9 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3125
3610
|
* @param params.walletProviderKey - The unique key identifying the wallet provider to connect to.
|
|
3126
3611
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3127
3612
|
* @returns A promise that resolves to the connected and verified wallet account.
|
|
3128
|
-
*/ const connectAndVerifyWithWalletProvider = async ({ walletProviderKey }, client =
|
|
3613
|
+
*/ const connectAndVerifyWithWalletProvider = async ({ walletProviderKey }, client = constants.getDefaultClient())=>{
|
|
3129
3614
|
const walletAccount = await connectWithWalletProvider({
|
|
3130
|
-
|
|
3615
|
+
addToDynamicWalletAccounts: false,
|
|
3131
3616
|
walletProviderKey
|
|
3132
3617
|
}, client);
|
|
3133
3618
|
await verifyWalletAccount({
|
|
@@ -3136,7 +3621,7 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3136
3621
|
/*
|
|
3137
3622
|
* send information to backend to kick off background jobs
|
|
3138
3623
|
* this is an async work, but does not need to be awaited
|
|
3139
|
-
*/ void createVisit({
|
|
3624
|
+
*/ void getNetworkProviderFromNetworkId.createVisit({
|
|
3140
3625
|
authMode: sdkApiCore.AuthModeEnum.AndSign,
|
|
3141
3626
|
walletAccount
|
|
3142
3627
|
}, client);
|
|
@@ -3151,16 +3636,17 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3151
3636
|
*
|
|
3152
3637
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3153
3638
|
* @returns An array of wallet provider data including chain, keys, and metadata.
|
|
3154
|
-
*/ const getAvailableWalletProvidersData = (client =
|
|
3155
|
-
const allWalletProviders =
|
|
3156
|
-
//
|
|
3157
|
-
// like the Dynamic Waas providers or
|
|
3639
|
+
*/ const getAvailableWalletProvidersData = (client = constants.getDefaultClient())=>{
|
|
3640
|
+
const allWalletProviders = getVerifiedCredentialForWalletAccount.getWalletProviders(client);
|
|
3641
|
+
// This is to avoid returning the wallet providers that are connected via different means
|
|
3642
|
+
// than by the "connect" method — like the Dynamic Waas providers, AA providers, or WalletConnect providers.
|
|
3158
3643
|
const filteredWalletProviders = allWalletProviders.filter((walletProvider)=>Boolean(walletProvider.connect));
|
|
3159
3644
|
return filteredWalletProviders.map((walletProvider)=>({
|
|
3160
3645
|
chain: walletProvider.chain,
|
|
3161
3646
|
groupKey: walletProvider.groupKey,
|
|
3162
3647
|
key: walletProvider.key,
|
|
3163
|
-
metadata: walletProvider.metadata
|
|
3648
|
+
metadata: walletProvider.metadata,
|
|
3649
|
+
walletProviderType: walletProvider.walletProviderType
|
|
3164
3650
|
}));
|
|
3165
3651
|
};
|
|
3166
3652
|
|
|
@@ -3173,13 +3659,54 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3173
3659
|
* @param params.walletProviderKey - The unique key of the wallet provider to query.
|
|
3174
3660
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3175
3661
|
* @returns An array of connected wallet addresses.
|
|
3176
|
-
*/ const getConnectedAddresses = ({ walletProviderKey }, client =
|
|
3177
|
-
const walletProvider =
|
|
3662
|
+
*/ const getConnectedAddresses = ({ walletProviderKey }, client = constants.getDefaultClient())=>{
|
|
3663
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderByKey({
|
|
3178
3664
|
walletProviderKey
|
|
3179
3665
|
}, client);
|
|
3180
3666
|
return walletProvider.getConnectedAddresses();
|
|
3181
3667
|
};
|
|
3182
3668
|
|
|
3669
|
+
const getOwnerWalletAccountForSmartWalletAccount = ({ smartWalletAccount }, client = constants.getDefaultClient())=>{
|
|
3670
|
+
const smartWalletVerifiedCredential = getVerifiedCredentialForWalletAccount.getVerifiedCredentialForWalletAccount({
|
|
3671
|
+
walletAccount: smartWalletAccount
|
|
3672
|
+
}, client);
|
|
3673
|
+
constants.assertDefined(smartWalletVerifiedCredential == null ? void 0 : smartWalletVerifiedCredential.signerRefId, 'Invalid smart wallet account');
|
|
3674
|
+
return getVerifiedCredentialForWalletAccount.getWalletAccounts(client).find((walletAccount)=>walletAccount.verifiedCredentialId === smartWalletVerifiedCredential.signerRefId);
|
|
3675
|
+
};
|
|
3676
|
+
|
|
3677
|
+
const getWalletAccountAddressByType = ({ type, walletAccount })=>{
|
|
3678
|
+
var _walletAccount_addressesWithTypes_find, _walletAccount_addressesWithTypes;
|
|
3679
|
+
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;
|
|
3680
|
+
};
|
|
3681
|
+
|
|
3682
|
+
/**
|
|
3683
|
+
* Retrieves data for a specific wallet provider that can be used for display or connection.
|
|
3684
|
+
*
|
|
3685
|
+
* @param params.walletProviderKey - The key of the wallet provider to retrieve data for.
|
|
3686
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3687
|
+
* @returns The data for the wallet provider.
|
|
3688
|
+
*/ const getWalletProviderDataByKey = ({ walletProviderKey }, client = constants.getDefaultClient())=>{
|
|
3689
|
+
const { chain, groupKey, key, metadata, walletProviderType } = getVerifiedCredentialForWalletAccount.getWalletProviderByKey({
|
|
3690
|
+
walletProviderKey
|
|
3691
|
+
}, client);
|
|
3692
|
+
return {
|
|
3693
|
+
chain,
|
|
3694
|
+
groupKey,
|
|
3695
|
+
key,
|
|
3696
|
+
metadata,
|
|
3697
|
+
walletProviderType
|
|
3698
|
+
};
|
|
3699
|
+
};
|
|
3700
|
+
|
|
3701
|
+
/**
|
|
3702
|
+
* Checks if a wallet account has been verified by a user.
|
|
3703
|
+
*
|
|
3704
|
+
* @param walletAccount - The wallet account to check.
|
|
3705
|
+
* @returns True if the wallet account has been verified, false otherwise.
|
|
3706
|
+
*/ const isWalletAccountVerified = ({ walletAccount })=>{
|
|
3707
|
+
return walletAccount.verifiedCredentialId !== null;
|
|
3708
|
+
};
|
|
3709
|
+
|
|
3183
3710
|
/**
|
|
3184
3711
|
* Retrieves the network configuration data for the currently active network.
|
|
3185
3712
|
*
|
|
@@ -3190,8 +3717,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3190
3717
|
* @param params.walletAccount - The wallet account to get network data for.
|
|
3191
3718
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3192
3719
|
* @returns A promise that resolves to the network data, or undefined if not found.
|
|
3193
|
-
*/ const getActiveNetworkData = async ({ walletAccount }, client =
|
|
3194
|
-
const walletProvider =
|
|
3720
|
+
*/ const getActiveNetworkData = async ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3721
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
3195
3722
|
walletAccount
|
|
3196
3723
|
}, client);
|
|
3197
3724
|
const { networkId } = await walletProvider.getActiveNetworkId();
|
|
@@ -3208,8 +3735,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3208
3735
|
* @param params.walletAccount - The wallet account to get the network ID for.
|
|
3209
3736
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3210
3737
|
* @returns A promise that resolves to the active network ID for the wallet account.
|
|
3211
|
-
*/ const getActiveNetworkId = ({ walletAccount }, client =
|
|
3212
|
-
const walletProvider =
|
|
3738
|
+
*/ const getActiveNetworkId = ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3739
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
3213
3740
|
walletAccount
|
|
3214
3741
|
}, client);
|
|
3215
3742
|
return walletProvider.getActiveNetworkId();
|
|
@@ -3224,8 +3751,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3224
3751
|
* @param params.walletAccount - The wallet account to get the balance for.
|
|
3225
3752
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3226
3753
|
* @returns A promise that resolves to an object containing the balance as a string or null.
|
|
3227
|
-
*/ const getBalance = async ({ walletAccount }, client =
|
|
3228
|
-
const walletProvider =
|
|
3754
|
+
*/ const getBalance = async ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3755
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
3229
3756
|
walletAccount
|
|
3230
3757
|
}, client);
|
|
3231
3758
|
const { networkId } = await walletProvider.getActiveNetworkId();
|
|
@@ -3249,17 +3776,43 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3249
3776
|
* @param params.networkId - The specific network ID within the chain.
|
|
3250
3777
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3251
3778
|
* @returns A promise that resolves to an object containing the balance as a string or null.
|
|
3252
|
-
*/ const getBalanceForAddress = async ({ address, chain, networkId }, client =
|
|
3779
|
+
*/ const getBalanceForAddress = async ({ address, chain, networkId }, client = constants.getDefaultClient())=>{
|
|
3253
3780
|
const networkProvider = getNetworkProviderFromNetworkId.getNetworkProviderFromNetworkId({
|
|
3254
3781
|
chain,
|
|
3255
3782
|
networkId
|
|
3256
3783
|
}, client);
|
|
3257
|
-
|
|
3784
|
+
constants.assertDefined(networkProvider, `No network found for chain ${chain} and network id ${networkId}. Please ensure you've enabled this network in the Dashboard.`);
|
|
3258
3785
|
return networkProvider.getBalance({
|
|
3259
3786
|
address
|
|
3260
3787
|
});
|
|
3261
3788
|
};
|
|
3262
3789
|
|
|
3790
|
+
/**
|
|
3791
|
+
* Retrieves the transaction history for a given wallet address, chain and network.
|
|
3792
|
+
*
|
|
3793
|
+
* This function fetches the transaction history for a specified wallet address and chain,
|
|
3794
|
+
* returning a list of transactions associated with that address along with nextOffset for pagination.
|
|
3795
|
+
*
|
|
3796
|
+
* @param params.address - The wallet address to query transactions for.
|
|
3797
|
+
* @param params.chain - The chain to query transactions for.
|
|
3798
|
+
* @param [params.limit] - The maximum number of transactions to return.
|
|
3799
|
+
* @param params.networkId - The network ID to query transactions for.
|
|
3800
|
+
* @param [params.offset] - The offset to use for pagination.
|
|
3801
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3802
|
+
* @returns A promise that resolves to the transaction history along with nextOffset for the given wallet address and chain.
|
|
3803
|
+
*/ const getTransactionHistory = async (params, client = constants.getDefaultClient())=>{
|
|
3804
|
+
const core = constants.getCore(client);
|
|
3805
|
+
const apiClient = constants.createApiClient({}, client);
|
|
3806
|
+
const response = await apiClient.getWalletTransactions({
|
|
3807
|
+
address: params.address,
|
|
3808
|
+
// eslint-disable-next-line custom-rules/ban-chain-enum
|
|
3809
|
+
chainName: params.chain,
|
|
3810
|
+
environmentId: core.environmentId,
|
|
3811
|
+
networkId: params.networkId
|
|
3812
|
+
});
|
|
3813
|
+
return response;
|
|
3814
|
+
};
|
|
3815
|
+
|
|
3263
3816
|
/**
|
|
3264
3817
|
* Checks if programmatic network switching is available for a wallet account.
|
|
3265
3818
|
*
|
|
@@ -3269,8 +3822,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3269
3822
|
* @param params.walletAccount - The wallet account to check network switching support for.
|
|
3270
3823
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3271
3824
|
* @returns True if programmatic network switching is available, false otherwise.
|
|
3272
|
-
*/ const isProgrammaticNetworkSwitchAvailable = ({ walletAccount }, client =
|
|
3273
|
-
const walletProvider =
|
|
3825
|
+
*/ const isProgrammaticNetworkSwitchAvailable = ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3826
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderByKey({
|
|
3274
3827
|
walletProviderKey: walletAccount.walletProviderKey
|
|
3275
3828
|
}, client);
|
|
3276
3829
|
return walletProvider.switchActiveNetwork !== undefined;
|
|
@@ -3287,8 +3840,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3287
3840
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3288
3841
|
* @returns A promise that resolves when the network switch is complete.
|
|
3289
3842
|
* @throws NetworkSwitchingUnavailableError If the wallet provider doesn't support network switching.
|
|
3290
|
-
*/ const switchActiveNetwork = async ({ networkId, walletAccount }, client =
|
|
3291
|
-
const walletProvider =
|
|
3843
|
+
*/ const switchActiveNetwork = async ({ networkId, walletAccount }, client = constants.getDefaultClient())=>{
|
|
3844
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderByKey({
|
|
3292
3845
|
walletProviderKey: walletAccount.walletProviderKey
|
|
3293
3846
|
}, client);
|
|
3294
3847
|
if (walletProvider.switchActiveNetwork === undefined) {
|
|
@@ -3305,45 +3858,33 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3305
3858
|
});
|
|
3306
3859
|
};
|
|
3307
3860
|
|
|
3308
|
-
/**
|
|
3309
|
-
* Get the primary wallet account.
|
|
3310
|
-
* The primary wallet account is the one that was last selected by the user.
|
|
3311
|
-
* This information is stored in both unverified and verified wallet accounts.
|
|
3312
|
-
* This function consolidates this information to determine which wallet was most recently selected.
|
|
3313
|
-
*/ const getPrimaryWalletAccount = (client = getChainFromVerifiedCredentialChain.getDefaultClient())=>{
|
|
3314
|
-
const walletAccounts = getWalletProviderByKey.getWalletAccounts(client);
|
|
3315
|
-
const sortedLastSelectedWalletAccounts = walletAccounts.filter((walletAccount)=>Boolean(walletAccount.lastSelectedAt)).sort((a, b)=>b.lastSelectedAt.getTime() - a.lastSelectedAt.getTime());
|
|
3316
|
-
if (sortedLastSelectedWalletAccounts.length === 0) {
|
|
3317
|
-
return null;
|
|
3318
|
-
}
|
|
3319
|
-
const [primaryWalletAccount] = sortedLastSelectedWalletAccounts;
|
|
3320
|
-
return primaryWalletAccount;
|
|
3321
|
-
};
|
|
3322
|
-
|
|
3323
3861
|
/**
|
|
3324
3862
|
* Make the wallet account provided as the primary wallet account.
|
|
3325
|
-
*/ const selectPrimaryWalletAccount = async ({ walletAccount }, client =
|
|
3326
|
-
const core =
|
|
3863
|
+
*/ const selectPrimaryWalletAccount = async ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3864
|
+
const core = constants.getCore(client);
|
|
3327
3865
|
const currentPrimaryWalletAccount = getPrimaryWalletAccount(client);
|
|
3328
3866
|
if ((currentPrimaryWalletAccount == null ? void 0 : currentPrimaryWalletAccount.id) === walletAccount.id) {
|
|
3329
3867
|
return;
|
|
3330
3868
|
}
|
|
3331
3869
|
if (walletAccount.verifiedCredentialId) {
|
|
3332
|
-
const apiClient =
|
|
3870
|
+
const apiClient = constants.createApiClient({}, client);
|
|
3333
3871
|
const response = await apiClient.selectUserWallet({
|
|
3334
3872
|
environmentId: core.environmentId,
|
|
3335
3873
|
userWalletSelectionRequest: {
|
|
3336
3874
|
walletId: walletAccount.verifiedCredentialId
|
|
3337
3875
|
}
|
|
3338
3876
|
});
|
|
3339
|
-
|
|
3877
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
3340
3878
|
response
|
|
3341
3879
|
}, client);
|
|
3342
3880
|
} else {
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3881
|
+
const updatedWalletAccount = constants._extends({}, walletAccount, {
|
|
3882
|
+
lastSelectedAt: new Date()
|
|
3883
|
+
});
|
|
3884
|
+
getNetworkProviderFromNetworkId.setUnverifiedWalletAccounts({
|
|
3885
|
+
unverifiedWalletAccountsToUpdate: [
|
|
3886
|
+
updatedWalletAccount
|
|
3887
|
+
]
|
|
3347
3888
|
}, client);
|
|
3348
3889
|
}
|
|
3349
3890
|
};
|
|
@@ -3358,9 +3899,22 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3358
3899
|
* @param params.walletAccount - The wallet account to remove.
|
|
3359
3900
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3360
3901
|
* @returns A promise that resolves when the wallet account is successfully removed.
|
|
3361
|
-
*/ const removeWalletAccount = async ({ walletAccount }, client =
|
|
3362
|
-
const core =
|
|
3363
|
-
const apiClient =
|
|
3902
|
+
*/ const removeWalletAccount = async ({ walletAccount }, client = constants.getDefaultClient())=>{
|
|
3903
|
+
const core = constants.getCore(client);
|
|
3904
|
+
const apiClient = constants.createApiClient({}, client);
|
|
3905
|
+
try {
|
|
3906
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
3907
|
+
walletAccount
|
|
3908
|
+
}, client);
|
|
3909
|
+
await (walletProvider.disconnectWalletAccount == null ? void 0 : walletProvider.disconnectWalletAccount.call(walletProvider, {
|
|
3910
|
+
walletAccount
|
|
3911
|
+
}));
|
|
3912
|
+
} catch (error) {
|
|
3913
|
+
if (error instanceof getVerifiedCredentialForWalletAccount.NoWalletProviderFoundError) {
|
|
3914
|
+
return;
|
|
3915
|
+
}
|
|
3916
|
+
throw error;
|
|
3917
|
+
}
|
|
3364
3918
|
if (!walletAccount.verifiedCredentialId) {
|
|
3365
3919
|
removeUnverifiedWalletAccount({
|
|
3366
3920
|
unverifiedWalletAccount: walletAccount
|
|
@@ -3373,7 +3927,7 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3373
3927
|
walletId: walletAccount.verifiedCredentialId
|
|
3374
3928
|
}
|
|
3375
3929
|
});
|
|
3376
|
-
|
|
3930
|
+
getVerifiedCredentialForWalletAccount.updateAuthFromVerifyResponse({
|
|
3377
3931
|
response
|
|
3378
3932
|
}, client);
|
|
3379
3933
|
};
|
|
@@ -3388,8 +3942,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3388
3942
|
* @param params.message - The message to sign.
|
|
3389
3943
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3390
3944
|
* @returns A promise that resolves to an object containing the signature.
|
|
3391
|
-
*/ const signMessage = async ({ walletAccount, message }, client =
|
|
3392
|
-
const walletProvider =
|
|
3945
|
+
*/ const signMessage = async ({ walletAccount, message }, client = constants.getDefaultClient())=>{
|
|
3946
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({
|
|
3393
3947
|
walletAccount
|
|
3394
3948
|
}, client);
|
|
3395
3949
|
assertWalletProviderMethodDefined(walletProvider, 'signMessage');
|
|
@@ -3412,8 +3966,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3412
3966
|
* @param params.chain - The blockchain the wallet belongs to.
|
|
3413
3967
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3414
3968
|
* @returns The matching wallet account, or undefined if not found.
|
|
3415
|
-
*/ const getWalletAccountFromAddress = ({ address, chain }, client =
|
|
3416
|
-
const walletAccounts =
|
|
3969
|
+
*/ const getWalletAccountFromAddress = ({ address, chain }, client = constants.getDefaultClient())=>{
|
|
3970
|
+
const walletAccounts = getVerifiedCredentialForWalletAccount.getWalletAccounts(client);
|
|
3417
3971
|
return walletAccounts.find((walletAccount)=>walletAccount.address === address && walletAccount.chain === chain);
|
|
3418
3972
|
};
|
|
3419
3973
|
|
|
@@ -3426,8 +3980,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3426
3980
|
* @param params.event - The event name to remove the listener from.
|
|
3427
3981
|
* @param params.walletProviderKey - The unique key identifying the wallet provider to remove the listener from.
|
|
3428
3982
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3429
|
-
*/ const offWalletProviderEvent = ({ callback, event, walletProviderKey }, client =
|
|
3430
|
-
const walletProvider =
|
|
3983
|
+
*/ const offWalletProviderEvent = ({ callback, event, walletProviderKey }, client = constants.getDefaultClient())=>{
|
|
3984
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderByKey({
|
|
3431
3985
|
walletProviderKey
|
|
3432
3986
|
}, client);
|
|
3433
3987
|
assertWalletProviderMethodDefined(walletProvider, 'events');
|
|
@@ -3444,8 +3998,8 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3444
3998
|
* @param params.walletProviderKey - The unique key identifying the wallet provider to listen to.
|
|
3445
3999
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
3446
4000
|
* @returns A function that can be called to remove the listener.
|
|
3447
|
-
*/ const onWalletProviderEvent = ({ callback, event, walletProviderKey }, client =
|
|
3448
|
-
const walletProvider =
|
|
4001
|
+
*/ const onWalletProviderEvent = ({ callback, event, walletProviderKey }, client = constants.getDefaultClient())=>{
|
|
4002
|
+
const walletProvider = getVerifiedCredentialForWalletAccount.getWalletProviderByKey({
|
|
3449
4003
|
walletProviderKey
|
|
3450
4004
|
}, client);
|
|
3451
4005
|
assertWalletProviderMethodDefined(walletProvider, 'events');
|
|
@@ -3458,40 +4012,67 @@ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddr
|
|
|
3458
4012
|
};
|
|
3459
4013
|
};
|
|
3460
4014
|
|
|
3461
|
-
|
|
4015
|
+
/* eslint-disable no-useless-escape */ /* eslint-disable no-restricted-globals */ /**
|
|
4016
|
+
* Sourced from http://detectmobilebrowsers.com/
|
|
4017
|
+
*/ const userAgentRegex1 = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ios|ipad|playbook|silk/i;
|
|
4018
|
+
const userAgentRegex2 = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i;
|
|
4019
|
+
// This is a regex that covers both iphone, android and any other mobile device.
|
|
4020
|
+
const isMobile = (maxTouchPointsOverride)=>{
|
|
4021
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
4022
|
+
return false;
|
|
4023
|
+
}
|
|
4024
|
+
return userAgentRegex1.test(navigator.userAgent) || userAgentRegex2.test(navigator.userAgent.substring(0, 4)) || isIPad(maxTouchPointsOverride) || isIPhone();
|
|
4025
|
+
};
|
|
4026
|
+
const isIPhone = ()=>typeof window === 'undefined' || typeof navigator === 'undefined' ? false : /iPhone|ios/.test(navigator.userAgent);
|
|
4027
|
+
/**
|
|
4028
|
+
* @param [optional] maxTouchPointsOverride - this is used for testing since
|
|
4029
|
+
* it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
|
|
4030
|
+
* to mock it
|
|
4031
|
+
*/ const isIPad = (maxTouchPointsOverride)=>{
|
|
4032
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
4033
|
+
return false;
|
|
4034
|
+
}
|
|
4035
|
+
const maxTouchPoints = maxTouchPointsOverride || navigator.maxTouchPoints;
|
|
4036
|
+
return /iPad/.test(navigator.userAgent) || /Mac/.test(navigator.userAgent) && maxTouchPoints === 5;
|
|
4037
|
+
};
|
|
4038
|
+
|
|
4039
|
+
assertPackageVersion.assertPackageVersion(constants.name, constants.version);
|
|
3462
4040
|
|
|
3463
|
-
exports.BaseError =
|
|
3464
|
-
exports.InvalidExternalAuthError =
|
|
3465
|
-
exports.MfaInvalidOtpError =
|
|
3466
|
-
exports.MfaRateLimitedError =
|
|
3467
|
-
exports.SandboxMaximumThresholdReachedError =
|
|
3468
|
-
exports.getDefaultClient =
|
|
4041
|
+
exports.BaseError = constants.BaseError;
|
|
4042
|
+
exports.InvalidExternalAuthError = constants.InvalidExternalAuthError;
|
|
4043
|
+
exports.MfaInvalidOtpError = constants.MfaInvalidOtpError;
|
|
4044
|
+
exports.MfaRateLimitedError = constants.MfaRateLimitedError;
|
|
4045
|
+
exports.SandboxMaximumThresholdReachedError = constants.SandboxMaximumThresholdReachedError;
|
|
4046
|
+
exports.getDefaultClient = constants.getDefaultClient;
|
|
3469
4047
|
Object.defineProperty(exports, "MFAAction", {
|
|
3470
4048
|
enumerable: true,
|
|
3471
4049
|
get: function () { return sdkApiCore.MFAAction; }
|
|
3472
4050
|
});
|
|
3473
4051
|
exports.NoNetworkProvidersError = getNetworkProviderFromNetworkId.NoNetworkProvidersError;
|
|
4052
|
+
exports.WalletAlreadyLinkedToAnotherUserError = getNetworkProviderFromNetworkId.WalletAlreadyLinkedToAnotherUserError;
|
|
3474
4053
|
exports.getNetworksData = getNetworkProviderFromNetworkId.getNetworksData;
|
|
3475
4054
|
exports.hasExtension = getNetworkProviderFromNetworkId.hasExtension;
|
|
3476
4055
|
exports.isCaptchaRequired = getNetworkProviderFromNetworkId.isCaptchaRequired;
|
|
3477
4056
|
exports.setCaptchaToken = getNetworkProviderFromNetworkId.setCaptchaToken;
|
|
3478
|
-
exports.getWalletAccounts =
|
|
3479
|
-
exports.offEvent =
|
|
3480
|
-
exports.onEvent =
|
|
3481
|
-
exports.onceEvent =
|
|
4057
|
+
exports.getWalletAccounts = getVerifiedCredentialForWalletAccount.getWalletAccounts;
|
|
4058
|
+
exports.offEvent = getVerifiedCredentialForWalletAccount.offEvent;
|
|
4059
|
+
exports.onEvent = getVerifiedCredentialForWalletAccount.onEvent;
|
|
4060
|
+
exports.onceEvent = getVerifiedCredentialForWalletAccount.onceEvent;
|
|
3482
4061
|
exports.consumeMfaToken = isMfaRequiredForAction.consumeMfaToken;
|
|
3483
4062
|
exports.getMfaMethods = isMfaRequiredForAction.getMfaMethods;
|
|
3484
4063
|
exports.isMfaRequiredForAction = isMfaRequiredForAction.isMfaRequiredForAction;
|
|
4064
|
+
exports.NotWaasWalletAccountError = NotWaasWalletAccountError.NotWaasWalletAccountError;
|
|
4065
|
+
exports.refreshUser = NotWaasWalletAccountError.refreshUser;
|
|
3485
4066
|
exports.InvalidParamError = InvalidParamError.InvalidParamError;
|
|
3486
|
-
exports.NotWaasWalletAccountError = refreshUser.NotWaasWalletAccountError;
|
|
3487
|
-
exports.refreshUser = refreshUser.refreshUser;
|
|
3488
4067
|
exports.ClientAlreadyInitializedError = ClientAlreadyInitializedError;
|
|
3489
4068
|
exports.InvalidRedirectStorageStateError = InvalidRedirectStorageStateError;
|
|
3490
4069
|
exports.MissingRedirectStorageStateError = MissingRedirectStorageStateError;
|
|
3491
4070
|
exports.MissingSocialUrlParamError = MissingSocialUrlParamError;
|
|
4071
|
+
exports.MissingUserVerificationError = MissingUserVerificationError;
|
|
3492
4072
|
exports.NetworkSwitchingUnavailableError = NetworkSwitchingUnavailableError;
|
|
3493
4073
|
exports.NoAddressFoundError = NoAddressFoundError;
|
|
3494
4074
|
exports.NoPasskeyCredentialsFoundError = NoPasskeyCredentialsFoundError;
|
|
4075
|
+
exports.NoSmartWalletAccountSignerFoundError = NoSmartWalletAccountSignerFoundError;
|
|
3495
4076
|
exports.NoWebAuthNSupportError = NoWebAuthNSupportError;
|
|
3496
4077
|
exports.UnavailableInServerSideError = UnavailableInServerSideError;
|
|
3497
4078
|
exports.UnrecognizedNetworkError = UnrecognizedNetworkError;
|
|
@@ -3499,21 +4080,25 @@ exports.UserNotAuthenticatedError = UserNotAuthenticatedError;
|
|
|
3499
4080
|
exports.UserRejectedError = UserRejectedError;
|
|
3500
4081
|
exports.WalletAccountAlreadyVerifiedError = WalletAccountAlreadyVerifiedError;
|
|
3501
4082
|
exports.WalletAccountNotSelectedError = WalletAccountNotSelectedError;
|
|
3502
|
-
exports.WalletAlreadyLinkedToAnotherUserError = WalletAlreadyLinkedToAnotherUserError;
|
|
3503
4083
|
exports.WalletProviderMethodUnavailableError = WalletProviderMethodUnavailableError;
|
|
3504
4084
|
exports.acknowledgeRecoveryCodes = acknowledgeRecoveryCodes;
|
|
4085
|
+
exports.addCoinbaseOnrampOrderEventListener = addCoinbaseOnrampOrderEventListener;
|
|
3505
4086
|
exports.assertWalletAccountSigningAvailability = assertWalletAccountSigningAvailability;
|
|
3506
4087
|
exports.assertWalletProviderMethodDefined = assertWalletProviderMethodDefined;
|
|
3507
4088
|
exports.authenticateMfaRecoveryCode = authenticateMfaRecoveryCode;
|
|
3508
4089
|
exports.authenticatePasskeyMFA = authenticatePasskeyMFA;
|
|
3509
4090
|
exports.authenticateTotpMfaDevice = authenticateTotpMfaDevice;
|
|
3510
|
-
exports.
|
|
4091
|
+
exports.authenticateWithSocial = authenticateWithSocial;
|
|
4092
|
+
exports.completeSocialAuthentication = completeSocialAuthentication;
|
|
3511
4093
|
exports.connectAndVerifyWithWalletProvider = connectAndVerifyWithWalletProvider;
|
|
3512
4094
|
exports.connectWithWalletProvider = connectWithWalletProvider;
|
|
4095
|
+
exports.createCoinbaseOnrampOrder = createCoinbaseOnrampOrder;
|
|
4096
|
+
exports.createCryptoDotComPayment = createCryptoDotComPayment;
|
|
3513
4097
|
exports.createDynamicClient = createDynamicClient;
|
|
3514
4098
|
exports.createNewMfaRecoveryCodes = createNewMfaRecoveryCodes;
|
|
3515
4099
|
exports.deleteMfaDevice = deleteMfaDevice;
|
|
3516
4100
|
exports.deletePasskey = deletePasskey;
|
|
4101
|
+
exports.deleteUser = deleteUser;
|
|
3517
4102
|
exports.detectOAuthRedirect = detectOAuthRedirect;
|
|
3518
4103
|
exports.fetchProjectSettings = fetchProjectSettings;
|
|
3519
4104
|
exports.getActiveNetworkData = getActiveNetworkData;
|
|
@@ -3521,18 +4106,27 @@ exports.getActiveNetworkId = getActiveNetworkId;
|
|
|
3521
4106
|
exports.getAvailableWalletProvidersData = getAvailableWalletProvidersData;
|
|
3522
4107
|
exports.getBalance = getBalance;
|
|
3523
4108
|
exports.getBalanceForAddress = getBalanceForAddress;
|
|
4109
|
+
exports.getCoinbaseBuyUrl = getCoinbaseBuyUrl;
|
|
3524
4110
|
exports.getConnectedAddresses = getConnectedAddresses;
|
|
3525
4111
|
exports.getMfaDevices = getMfaDevices;
|
|
3526
4112
|
exports.getMfaRecoveryCodes = getMfaRecoveryCodes;
|
|
4113
|
+
exports.getMissingVerificationForCoinbaseOnrampOrder = getMissingVerificationForCoinbaseOnrampOrder;
|
|
3527
4114
|
exports.getMultichainBalances = getMultichainBalances;
|
|
4115
|
+
exports.getOwnerWalletAccountForSmartWalletAccount = getOwnerWalletAccountForSmartWalletAccount;
|
|
3528
4116
|
exports.getPasskeys = getPasskeys;
|
|
3529
4117
|
exports.getPrimaryWalletAccount = getPrimaryWalletAccount;
|
|
4118
|
+
exports.getTransactionHistory = getTransactionHistory;
|
|
4119
|
+
exports.getUserSocialAccounts = getUserSocialAccounts;
|
|
4120
|
+
exports.getWalletAccountAddressByType = getWalletAccountAddressByType;
|
|
3530
4121
|
exports.getWalletAccountFromAddress = getWalletAccountFromAddress;
|
|
4122
|
+
exports.getWalletProviderDataByKey = getWalletProviderDataByKey;
|
|
3531
4123
|
exports.initializeClient = initializeClient;
|
|
4124
|
+
exports.isMobile = isMobile;
|
|
3532
4125
|
exports.isPendingRecoveryCodesAcknowledgment = isPendingRecoveryCodesAcknowledgment;
|
|
3533
4126
|
exports.isProgrammaticNetworkSwitchAvailable = isProgrammaticNetworkSwitchAvailable;
|
|
3534
4127
|
exports.isSignedIn = isSignedIn;
|
|
3535
4128
|
exports.isUserMissingMfaAuth = isUserMissingMfaAuth;
|
|
4129
|
+
exports.isWalletAccountVerified = isWalletAccountVerified;
|
|
3536
4130
|
exports.logout = logout;
|
|
3537
4131
|
exports.offWalletProviderEvent = offWalletProviderEvent;
|
|
3538
4132
|
exports.onWalletProviderEvent = onWalletProviderEvent;
|
|
@@ -3546,9 +4140,10 @@ exports.sendSmsOTP = sendSmsOTP;
|
|
|
3546
4140
|
exports.setDefaultMfaDevice = setDefaultMfaDevice;
|
|
3547
4141
|
exports.signInWithExternalJwt = signInWithExternalJwt;
|
|
3548
4142
|
exports.signInWithPasskey = signInWithPasskey;
|
|
3549
|
-
exports.signInWithSocialRedirect = signInWithSocialRedirect;
|
|
3550
4143
|
exports.signMessage = signMessage;
|
|
3551
4144
|
exports.switchActiveNetwork = switchActiveNetwork;
|
|
4145
|
+
exports.unlinkSocialAccount = unlinkSocialAccount;
|
|
3552
4146
|
exports.updateUser = updateUser;
|
|
3553
4147
|
exports.verifyOTP = verifyOTP;
|
|
3554
4148
|
exports.verifyWalletAccount = verifyWalletAccount;
|
|
4149
|
+
exports.waitForClientInitialized = waitForClientInitialized;
|