@zerodev/wallet-core 0.0.1-alpha.9 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -18
- package/dist/_cjs/actions/auth/authenticateWithEmail.js +1 -2
- package/dist/_cjs/actions/auth/authenticateWithEmail.js.map +1 -1
- package/dist/_cjs/actions/auth/authenticateWithOAuth.js +2 -3
- package/dist/_cjs/actions/auth/authenticateWithOAuth.js.map +1 -1
- package/dist/_cjs/actions/auth/getAuthProxyConfigId.js +10 -0
- package/dist/_cjs/actions/auth/getAuthProxyConfigId.js.map +1 -0
- package/dist/_cjs/actions/auth/getAuthenticators.js +16 -0
- package/dist/_cjs/actions/auth/getAuthenticators.js.map +1 -0
- package/dist/_cjs/actions/auth/getOAuthLoginUrl.js +18 -0
- package/dist/_cjs/actions/auth/getOAuthLoginUrl.js.map +1 -0
- package/dist/_cjs/actions/auth/getParentOrgId.js +10 -0
- package/dist/_cjs/actions/auth/getParentOrgId.js.map +1 -0
- package/dist/_cjs/actions/auth/getWhoami.js +18 -4
- package/dist/_cjs/actions/auth/getWhoami.js.map +1 -1
- package/dist/_cjs/actions/auth/index.js +9 -3
- package/dist/_cjs/actions/auth/index.js.map +1 -1
- package/dist/_cjs/actions/auth/loginWithStamp.js +5 -6
- package/dist/_cjs/actions/auth/loginWithStamp.js.map +1 -1
- package/dist/_cjs/actions/auth/registerWithOTP.js +1 -2
- package/dist/_cjs/actions/auth/registerWithOTP.js.map +1 -1
- package/dist/_cjs/actions/auth/registerWithPasskey.js +1 -2
- package/dist/_cjs/actions/auth/registerWithPasskey.js.map +1 -1
- package/dist/_cjs/actions/index.js +9 -3
- package/dist/_cjs/actions/index.js.map +1 -1
- package/dist/_cjs/actions/wallet/getUserWallet.js +3 -5
- package/dist/_cjs/actions/wallet/getUserWallet.js.map +1 -1
- package/dist/_cjs/actions/wallet/index.js +9 -3
- package/dist/_cjs/actions/wallet/index.js.map +1 -1
- package/dist/_cjs/actions/wallet/sign7702Authorization.js +16 -0
- package/dist/_cjs/actions/wallet/sign7702Authorization.js.map +1 -0
- package/dist/_cjs/actions/wallet/signMessage.js +17 -0
- package/dist/_cjs/actions/wallet/signMessage.js.map +1 -0
- package/dist/_cjs/actions/wallet/signTransaction.js +9 -18
- package/dist/_cjs/actions/wallet/signTransaction.js.map +1 -1
- package/dist/_cjs/actions/wallet/signTypedDataV4.js +17 -0
- package/dist/_cjs/actions/wallet/signTypedDataV4.js.map +1 -0
- package/dist/_cjs/actions/wallet/signUserOperation.js +17 -0
- package/dist/_cjs/actions/wallet/signUserOperation.js.map +1 -0
- package/dist/_cjs/actions/wallet/signingUtils.js +64 -0
- package/dist/_cjs/actions/wallet/signingUtils.js.map +1 -0
- package/dist/_cjs/adapters/viem.js +60 -27
- package/dist/_cjs/adapters/viem.js.map +1 -1
- package/dist/_cjs/client/authProxy.js +1 -1
- package/dist/_cjs/client/authProxy.js.map +1 -1
- package/dist/_cjs/client/createClient.js +5 -5
- package/dist/_cjs/client/createClient.js.map +1 -1
- package/dist/_cjs/client/decorators/client.js +9 -4
- package/dist/_cjs/client/decorators/client.js.map +1 -1
- package/dist/_cjs/client/index.js.map +1 -1
- package/dist/_cjs/client/transports/createTransport.js +6 -5
- package/dist/_cjs/client/transports/createTransport.js.map +1 -1
- package/dist/_cjs/client/transports/rest.js +40 -28
- package/dist/_cjs/client/transports/rest.js.map +1 -1
- package/dist/_cjs/constants.js +4 -4
- package/dist/_cjs/constants.js.map +1 -1
- package/dist/_cjs/core/{createZeroDevWallet.js → createZeroDevWalletCore.js} +94 -86
- package/dist/_cjs/core/createZeroDevWalletCore.js.map +1 -0
- package/dist/_cjs/index.js +14 -8
- package/dist/_cjs/index.js.map +1 -1
- package/dist/_cjs/index.native.js +39 -0
- package/dist/_cjs/index.native.js.map +1 -0
- package/dist/_cjs/native/createZeroDevWallet.js +13 -0
- package/dist/_cjs/native/createZeroDevWallet.js.map +1 -0
- package/dist/_cjs/native/stampers/passkey.js +30 -0
- package/dist/_cjs/native/stampers/passkey.js.map +1 -0
- package/dist/_cjs/native/stampers/secureStore.js +112 -0
- package/dist/_cjs/native/stampers/secureStore.js.map +1 -0
- package/dist/_cjs/native/storage/asyncStorage.js +11 -0
- package/dist/_cjs/native/storage/asyncStorage.js.map +1 -0
- package/dist/_cjs/stampers/iframeStamper.js +3 -0
- package/dist/_cjs/stampers/iframeStamper.js.map +1 -1
- package/dist/_cjs/stampers/indexedDbStamper.js +20 -2
- package/dist/_cjs/stampers/indexedDbStamper.js.map +1 -1
- package/dist/_cjs/stampers/noopPasskeyStamper.js +16 -0
- package/dist/_cjs/stampers/noopPasskeyStamper.js.map +1 -0
- package/dist/_cjs/stampers/webauthnStamper.js +23 -3
- package/dist/_cjs/stampers/webauthnStamper.js.map +1 -1
- package/dist/_cjs/stubs/native-on-web.js +12 -0
- package/dist/_cjs/stubs/native-on-web.js.map +1 -0
- package/dist/_cjs/utils/encryptOtpAttempt.js +57 -0
- package/dist/_cjs/utils/encryptOtpAttempt.js.map +1 -0
- package/dist/_cjs/utils/exportPrivateKey.js +1 -1
- package/dist/_cjs/utils/exportPrivateKey.js.map +1 -1
- package/dist/_cjs/utils/exportWallet.js +52 -61
- package/dist/_cjs/utils/exportWallet.js.map +1 -1
- package/dist/_cjs/utils/hpke.js +78 -0
- package/dist/_cjs/utils/hpke.js.map +1 -0
- package/dist/_cjs/utils/platform.js +19 -0
- package/dist/_cjs/utils/platform.js.map +1 -0
- package/dist/_cjs/utils/resolveOrganizationId.js +20 -0
- package/dist/_cjs/utils/resolveOrganizationId.js.map +1 -0
- package/dist/_cjs/utils/utils.js +5 -6
- package/dist/_cjs/utils/utils.js.map +1 -1
- package/dist/_cjs/web/createZeroDevWallet.js +21 -0
- package/dist/_cjs/web/createZeroDevWallet.js.map +1 -0
- package/dist/_esm/actions/auth/authenticateWithEmail.js +1 -2
- package/dist/_esm/actions/auth/authenticateWithEmail.js.map +1 -1
- package/dist/_esm/actions/auth/authenticateWithOAuth.js +8 -7
- package/dist/_esm/actions/auth/authenticateWithOAuth.js.map +1 -1
- package/dist/_esm/actions/auth/getAuthProxyConfigId.js +13 -0
- package/dist/_esm/actions/auth/getAuthProxyConfigId.js.map +1 -0
- package/dist/_esm/actions/auth/getAuthenticators.js +36 -0
- package/dist/_esm/actions/auth/getAuthenticators.js.map +1 -0
- package/dist/_esm/actions/auth/getOAuthLoginUrl.js +23 -0
- package/dist/_esm/actions/auth/getOAuthLoginUrl.js.map +1 -0
- package/dist/_esm/actions/auth/getParentOrgId.js +17 -0
- package/dist/_esm/actions/auth/getParentOrgId.js.map +1 -0
- package/dist/_esm/actions/auth/getWhoami.js +28 -6
- package/dist/_esm/actions/auth/getWhoami.js.map +1 -1
- package/dist/_esm/actions/auth/index.js +4 -1
- package/dist/_esm/actions/auth/index.js.map +1 -1
- package/dist/_esm/actions/auth/loginWithStamp.js +9 -6
- package/dist/_esm/actions/auth/loginWithStamp.js.map +1 -1
- package/dist/_esm/actions/auth/registerWithOTP.js +5 -2
- package/dist/_esm/actions/auth/registerWithOTP.js.map +1 -1
- package/dist/_esm/actions/auth/registerWithPasskey.js +1 -3
- package/dist/_esm/actions/auth/registerWithPasskey.js.map +1 -1
- package/dist/_esm/actions/index.js +2 -2
- package/dist/_esm/actions/index.js.map +1 -1
- package/dist/_esm/actions/wallet/getUserWallet.js +5 -5
- package/dist/_esm/actions/wallet/getUserWallet.js.map +1 -1
- package/dist/_esm/actions/wallet/index.js +4 -1
- package/dist/_esm/actions/wallet/index.js.map +1 -1
- package/dist/_esm/actions/wallet/sign7702Authorization.js +13 -0
- package/dist/_esm/actions/wallet/sign7702Authorization.js.map +1 -0
- package/dist/_esm/actions/wallet/signMessage.js +14 -0
- package/dist/_esm/actions/wallet/signMessage.js.map +1 -0
- package/dist/_esm/actions/wallet/signTransaction.js +9 -36
- package/dist/_esm/actions/wallet/signTransaction.js.map +1 -1
- package/dist/_esm/actions/wallet/signTypedDataV4.js +14 -0
- package/dist/_esm/actions/wallet/signTypedDataV4.js.map +1 -0
- package/dist/_esm/actions/wallet/signUserOperation.js +14 -0
- package/dist/_esm/actions/wallet/signUserOperation.js.map +1 -0
- package/dist/_esm/actions/wallet/signingUtils.js +69 -0
- package/dist/_esm/actions/wallet/signingUtils.js.map +1 -0
- package/dist/_esm/adapters/viem.js +63 -30
- package/dist/_esm/adapters/viem.js.map +1 -1
- package/dist/_esm/client/authProxy.js +9 -4
- package/dist/_esm/client/authProxy.js.map +1 -1
- package/dist/_esm/client/createClient.js +5 -5
- package/dist/_esm/client/createClient.js.map +1 -1
- package/dist/_esm/client/decorators/client.js +9 -4
- package/dist/_esm/client/decorators/client.js.map +1 -1
- package/dist/_esm/client/index.js +1 -1
- package/dist/_esm/client/index.js.map +1 -1
- package/dist/_esm/client/transports/createTransport.js +6 -5
- package/dist/_esm/client/transports/createTransport.js.map +1 -1
- package/dist/_esm/client/transports/rest.js +44 -29
- package/dist/_esm/client/transports/rest.js.map +1 -1
- package/dist/_esm/constants.js +10 -3
- package/dist/_esm/constants.js.map +1 -1
- package/dist/_esm/core/{createZeroDevWallet.js → createZeroDevWalletCore.js} +115 -90
- package/dist/_esm/core/createZeroDevWalletCore.js.map +1 -0
- package/dist/_esm/index.js +13 -5
- package/dist/_esm/index.js.map +1 -1
- package/dist/_esm/index.native.js +19 -0
- package/dist/_esm/index.native.js.map +1 -0
- package/dist/_esm/native/createZeroDevWallet.js +10 -0
- package/dist/_esm/native/createZeroDevWallet.js.map +1 -0
- package/dist/_esm/native/stampers/passkey.js +27 -0
- package/dist/_esm/native/stampers/passkey.js.map +1 -0
- package/dist/_esm/native/stampers/secureStore.js +120 -0
- package/dist/_esm/native/stampers/secureStore.js.map +1 -0
- package/dist/_esm/native/storage/asyncStorage.js +13 -0
- package/dist/_esm/native/storage/asyncStorage.js.map +1 -0
- package/dist/_esm/stampers/iframeStamper.js +3 -0
- package/dist/_esm/stampers/iframeStamper.js.map +1 -1
- package/dist/_esm/stampers/indexedDbStamper.js +20 -2
- package/dist/_esm/stampers/indexedDbStamper.js.map +1 -1
- package/dist/_esm/stampers/noopPasskeyStamper.js +18 -0
- package/dist/_esm/stampers/noopPasskeyStamper.js.map +1 -0
- package/dist/_esm/stampers/webauthnStamper.js +23 -4
- package/dist/_esm/stampers/webauthnStamper.js.map +1 -1
- package/dist/_esm/stubs/native-on-web.js +25 -0
- package/dist/_esm/stubs/native-on-web.js.map +1 -0
- package/dist/_esm/utils/encryptOtpAttempt.js +81 -0
- package/dist/_esm/utils/encryptOtpAttempt.js.map +1 -0
- package/dist/_esm/utils/exportPrivateKey.js +1 -1
- package/dist/_esm/utils/exportPrivateKey.js.map +1 -1
- package/dist/_esm/utils/exportWallet.js +52 -61
- package/dist/_esm/utils/exportWallet.js.map +1 -1
- package/dist/_esm/utils/hpke.js +119 -0
- package/dist/_esm/utils/hpke.js.map +1 -0
- package/dist/_esm/utils/platform.js +16 -0
- package/dist/_esm/utils/platform.js.map +1 -0
- package/dist/_esm/utils/resolveOrganizationId.js +27 -0
- package/dist/_esm/utils/resolveOrganizationId.js.map +1 -0
- package/dist/_esm/utils/utils.js +5 -6
- package/dist/_esm/utils/utils.js.map +1 -1
- package/dist/_esm/web/createZeroDevWallet.js +18 -0
- package/dist/_esm/web/createZeroDevWallet.js.map +1 -0
- package/dist/_types/actions/auth/authenticateWithEmail.d.ts +0 -6
- package/dist/_types/actions/auth/authenticateWithEmail.d.ts.map +1 -1
- package/dist/_types/actions/auth/authenticateWithOAuth.d.ts +10 -4
- package/dist/_types/actions/auth/authenticateWithOAuth.d.ts.map +1 -1
- package/dist/_types/actions/auth/getAuthProxyConfigId.d.ts +12 -0
- package/dist/_types/actions/auth/getAuthProxyConfigId.d.ts.map +1 -0
- package/dist/_types/actions/auth/getAuthenticators.d.ts +65 -0
- package/dist/_types/actions/auth/getAuthenticators.d.ts.map +1 -0
- package/dist/_types/actions/auth/getOAuthLoginUrl.d.ts +30 -0
- package/dist/_types/actions/auth/getOAuthLoginUrl.d.ts.map +1 -0
- package/dist/_types/actions/auth/getParentOrgId.d.ts +17 -0
- package/dist/_types/actions/auth/getParentOrgId.d.ts.map +1 -0
- package/dist/_types/actions/auth/getWhoami.d.ts +9 -2
- package/dist/_types/actions/auth/getWhoami.d.ts.map +1 -1
- package/dist/_types/actions/auth/index.d.ts +5 -2
- package/dist/_types/actions/auth/index.d.ts.map +1 -1
- package/dist/_types/actions/auth/loginWithStamp.d.ts +2 -5
- package/dist/_types/actions/auth/loginWithStamp.d.ts.map +1 -1
- package/dist/_types/actions/auth/registerWithOTP.d.ts +10 -3
- package/dist/_types/actions/auth/registerWithOTP.d.ts.map +1 -1
- package/dist/_types/actions/auth/registerWithPasskey.d.ts +0 -7
- package/dist/_types/actions/auth/registerWithPasskey.d.ts.map +1 -1
- package/dist/_types/actions/index.d.ts +2 -2
- package/dist/_types/actions/index.d.ts.map +1 -1
- package/dist/_types/actions/wallet/index.d.ts +4 -1
- package/dist/_types/actions/wallet/index.d.ts.map +1 -1
- package/dist/_types/actions/wallet/sign7702Authorization.d.ts +19 -0
- package/dist/_types/actions/wallet/sign7702Authorization.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signMessage.d.ts +19 -0
- package/dist/_types/actions/wallet/signMessage.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signTransaction.d.ts +1 -19
- package/dist/_types/actions/wallet/signTransaction.d.ts.map +1 -1
- package/dist/_types/actions/wallet/signTypedDataV4.d.ts +21 -0
- package/dist/_types/actions/wallet/signTypedDataV4.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signUserOperation.d.ts +21 -0
- package/dist/_types/actions/wallet/signUserOperation.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signingUtils.d.ts +32 -0
- package/dist/_types/actions/wallet/signingUtils.d.ts.map +1 -0
- package/dist/_types/adapters/viem.d.ts +1 -1
- package/dist/_types/adapters/viem.d.ts.map +1 -1
- package/dist/_types/client/authProxy.d.ts +13 -7
- package/dist/_types/client/authProxy.d.ts.map +1 -1
- package/dist/_types/client/decorators/client.d.ts +32 -6
- package/dist/_types/client/decorators/client.d.ts.map +1 -1
- package/dist/_types/client/index.d.ts +1 -1
- package/dist/_types/client/index.d.ts.map +1 -1
- package/dist/_types/client/transports/createTransport.d.ts +2 -0
- package/dist/_types/client/transports/createTransport.d.ts.map +1 -1
- package/dist/_types/client/transports/rest.d.ts +13 -5
- package/dist/_types/client/transports/rest.d.ts.map +1 -1
- package/dist/_types/client/types.d.ts +9 -9
- package/dist/_types/client/types.d.ts.map +1 -1
- package/dist/_types/constants.d.ts +3 -3
- package/dist/_types/constants.d.ts.map +1 -1
- package/dist/_types/core/{createZeroDevWallet.d.ts → createZeroDevWalletCore.d.ts} +30 -10
- package/dist/_types/core/createZeroDevWalletCore.d.ts.map +1 -0
- package/dist/_types/index.d.ts +7 -7
- package/dist/_types/index.d.ts.map +1 -1
- package/dist/_types/index.native.d.ts +19 -0
- package/dist/_types/index.native.d.ts.map +1 -0
- package/dist/_types/native/createZeroDevWallet.d.ts +12 -0
- package/dist/_types/native/createZeroDevWallet.d.ts.map +1 -0
- package/dist/_types/native/stampers/passkey.d.ts +5 -0
- package/dist/_types/native/stampers/passkey.d.ts.map +1 -0
- package/dist/_types/native/stampers/secureStore.d.ts +3 -0
- package/dist/_types/native/stampers/secureStore.d.ts.map +1 -0
- package/dist/_types/native/storage/asyncStorage.d.ts +3 -0
- package/dist/_types/native/storage/asyncStorage.d.ts.map +1 -0
- package/dist/_types/stampers/iframeStamper.d.ts.map +1 -1
- package/dist/_types/stampers/indexedDbStamper.d.ts +2 -2
- package/dist/_types/stampers/indexedDbStamper.d.ts.map +1 -1
- package/dist/_types/stampers/noopPasskeyStamper.d.ts +8 -0
- package/dist/_types/stampers/noopPasskeyStamper.d.ts.map +1 -0
- package/dist/_types/stampers/types.d.ts +39 -5
- package/dist/_types/stampers/types.d.ts.map +1 -1
- package/dist/_types/stampers/webauthnStamper.d.ts +2 -2
- package/dist/_types/stampers/webauthnStamper.d.ts.map +1 -1
- package/dist/_types/stubs/native-on-web.d.ts +6 -0
- package/dist/_types/stubs/native-on-web.d.ts.map +1 -0
- package/dist/_types/types/session.d.ts +2 -3
- package/dist/_types/types/session.d.ts.map +1 -1
- package/dist/_types/utils/buildClientSignature.d.ts +3 -3
- package/dist/_types/utils/buildClientSignature.d.ts.map +1 -1
- package/dist/_types/utils/encryptOtpAttempt.d.ts +40 -0
- package/dist/_types/utils/encryptOtpAttempt.d.ts.map +1 -0
- package/dist/_types/utils/exportPrivateKey.d.ts +1 -1
- package/dist/_types/utils/exportPrivateKey.d.ts.map +1 -1
- package/dist/_types/utils/exportWallet.d.ts +1 -1
- package/dist/_types/utils/exportWallet.d.ts.map +1 -1
- package/dist/_types/utils/hpke.d.ts +38 -0
- package/dist/_types/utils/hpke.d.ts.map +1 -0
- package/dist/_types/utils/platform.d.ts +2 -0
- package/dist/_types/utils/platform.d.ts.map +1 -0
- package/dist/_types/utils/resolveOrganizationId.d.ts +16 -0
- package/dist/_types/utils/resolveOrganizationId.d.ts.map +1 -0
- package/dist/_types/utils/utils.d.ts.map +1 -1
- package/dist/_types/web/createZeroDevWallet.d.ts +18 -0
- package/dist/_types/web/createZeroDevWallet.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +100 -11
- package/src/actions/auth/authenticateWithEmail.ts +1 -9
- package/src/actions/auth/authenticateWithOAuth.ts +12 -7
- package/src/actions/auth/getAuthProxyConfigId.ts +20 -0
- package/src/actions/auth/getAuthenticators.ts +89 -0
- package/src/actions/auth/getOAuthLoginUrl.ts +48 -0
- package/src/actions/auth/getParentOrgId.ts +25 -0
- package/src/actions/auth/getWhoami.ts +33 -6
- package/src/actions/auth/index.ts +21 -5
- package/src/actions/auth/loginWithStamp.ts +11 -12
- package/src/actions/auth/registerWithOTP.ts +11 -5
- package/src/actions/auth/registerWithPasskey.ts +1 -10
- package/src/actions/index.ts +26 -7
- package/src/actions/wallet/getUserWallet.ts +5 -5
- package/src/actions/wallet/index.ts +22 -4
- package/src/actions/wallet/sign7702Authorization.ts +48 -0
- package/src/actions/wallet/signMessage.ts +47 -0
- package/src/actions/wallet/signTransaction.ts +19 -38
- package/src/actions/wallet/signTypedDataV4.ts +52 -0
- package/src/actions/wallet/signUserOperation.ts +56 -0
- package/src/actions/wallet/signingUtils.ts +110 -0
- package/src/adapters/viem.ts +75 -43
- package/src/client/authProxy.ts +14 -8
- package/src/client/createClient.ts +6 -6
- package/src/client/decorators/client.ts +78 -19
- package/src/client/index.ts +4 -1
- package/src/client/transports/createTransport.ts +8 -5
- package/src/client/transports/rest.ts +57 -34
- package/src/client/types.ts +9 -9
- package/src/constants.ts +12 -4
- package/src/core/{createZeroDevWallet.ts → createZeroDevWalletCore.ts} +147 -122
- package/src/index.native.ts +102 -0
- package/src/index.ts +49 -16
- package/src/native/createZeroDevWallet.ts +26 -0
- package/src/native/stampers/passkey.ts +39 -0
- package/src/native/stampers/secureStore.ts +139 -0
- package/src/native/storage/asyncStorage.ts +18 -0
- package/src/stampers/iframeStamper.ts +3 -0
- package/src/stampers/indexedDbStamper.ts +27 -4
- package/src/stampers/noopPasskeyStamper.ts +21 -0
- package/src/stampers/types.ts +39 -5
- package/src/stampers/webauthnStamper.ts +27 -6
- package/src/stubs/native-on-web.ts +29 -0
- package/src/types/session.ts +2 -3
- package/src/utils/buildClientSignature.ts +3 -3
- package/src/utils/encryptOtpAttempt.ts +142 -0
- package/src/utils/exportPrivateKey.ts +2 -2
- package/src/utils/exportWallet.ts +66 -75
- package/src/utils/hpke.ts +219 -0
- package/src/utils/platform.ts +21 -0
- package/src/utils/resolveOrganizationId.ts +28 -0
- package/src/utils/utils.ts +5 -6
- package/src/web/createZeroDevWallet.ts +45 -0
- package/dist/_cjs/actions/auth/getUserEmail.js +0 -19
- package/dist/_cjs/actions/auth/getUserEmail.js.map +0 -1
- package/dist/_cjs/actions/wallet/signRawPayload.js +0 -27
- package/dist/_cjs/actions/wallet/signRawPayload.js.map +0 -1
- package/dist/_cjs/core/createZeroDevWallet.js.map +0 -1
- package/dist/_cjs/stampers/index.js +0 -10
- package/dist/_cjs/stampers/index.js.map +0 -1
- package/dist/_esm/actions/auth/getUserEmail.js +0 -33
- package/dist/_esm/actions/auth/getUserEmail.js.map +0 -1
- package/dist/_esm/actions/wallet/signRawPayload.js +0 -42
- package/dist/_esm/actions/wallet/signRawPayload.js.map +0 -1
- package/dist/_esm/core/createZeroDevWallet.js.map +0 -1
- package/dist/_esm/stampers/index.js +0 -4
- package/dist/_esm/stampers/index.js.map +0 -1
- package/dist/_types/actions/auth/getUserEmail.d.ts +0 -32
- package/dist/_types/actions/auth/getUserEmail.d.ts.map +0 -1
- package/dist/_types/actions/wallet/signRawPayload.d.ts +0 -39
- package/dist/_types/actions/wallet/signRawPayload.d.ts.map +0 -1
- package/dist/_types/core/createZeroDevWallet.d.ts.map +0 -1
- package/dist/_types/stampers/index.d.ts +0 -5
- package/dist/_types/stampers/index.d.ts.map +0 -1
- package/src/actions/auth/getUserEmail.ts +0 -52
- package/src/actions/wallet/signRawPayload.ts +0 -75
- package/src/stampers/index.ts +0 -8
|
@@ -1,45 +1,39 @@
|
|
|
1
|
-
import { getWebAuthnAttestation } from '@turnkey/http'
|
|
2
1
|
import type { LocalAccount } from 'viem/accounts'
|
|
3
|
-
import type { EmailCustomization } from '../actions/auth/index.js'
|
|
4
2
|
import { toViemAccount } from '../adapters/viem.js'
|
|
5
3
|
import {
|
|
4
|
+
type CreateTransportOptions,
|
|
6
5
|
createAuthProxyClient,
|
|
7
6
|
createClient,
|
|
8
7
|
type ZeroDevWalletClient,
|
|
9
8
|
zeroDevWalletTransport,
|
|
10
9
|
} from '../client/index.js'
|
|
11
10
|
import {
|
|
12
|
-
DEFAULT_AUTH_PROXY_CONFIG_ID,
|
|
13
11
|
DEFAULT_ORGANIZATION_ID,
|
|
14
12
|
DEFAULT_SESSION_EXPIRATION_IN_SECONDS,
|
|
15
13
|
KMS_SERVER_URL,
|
|
16
14
|
} from '../constants.js'
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { createWebStorageAdapter } from '../storage/adapters.js'
|
|
15
|
+
import { createNoopPasskeyStamper } from '../stampers/noopPasskeyStamper.js'
|
|
16
|
+
import type { ApiKeyStamper, PasskeyStamper } from '../stampers/types.js'
|
|
20
17
|
import {
|
|
21
18
|
createStorageManager,
|
|
22
19
|
type StorageAdapter,
|
|
23
20
|
} from '../storage/manager.js'
|
|
24
21
|
import { SessionType, type ZeroDevWalletSession } from '../types/session.js'
|
|
25
22
|
import { buildClientSignature } from '../utils/buildClientSignature.js'
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
humanReadableDateTime,
|
|
31
|
-
parseSession,
|
|
32
|
-
} from '../utils/utils.js'
|
|
33
|
-
export interface ZeroDevWalletConfig {
|
|
23
|
+
import { encryptOtpAttempt } from '../utils/encryptOtpAttempt.js'
|
|
24
|
+
import { createOrganizationIdResolver } from '../utils/resolveOrganizationId.js'
|
|
25
|
+
import { humanReadableDateTime, parseSession } from '../utils/utils.js'
|
|
26
|
+
export interface ZeroDevWalletConfigCore {
|
|
34
27
|
organizationId?: string
|
|
35
28
|
proxyBaseUrl?: string
|
|
36
29
|
projectId: string
|
|
37
|
-
sessionStorage
|
|
38
|
-
rpId
|
|
30
|
+
sessionStorage: StorageAdapter
|
|
31
|
+
rpId: string
|
|
32
|
+
apiKeyStamper: ApiKeyStamper
|
|
33
|
+
passkeyStamper?: PasskeyStamper
|
|
34
|
+
fetchOptions?: CreateTransportOptions['fetchOptions']
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
// Re-export EmailCustomization for convenience
|
|
42
|
-
export type { EmailCustomization } from '../actions/auth/index.js'
|
|
43
37
|
export type { StorageAdapter, StorageManager } from '../storage/manager.js'
|
|
44
38
|
// Re-export new session types
|
|
45
39
|
export type { StamperType, ZeroDevWalletSession } from '../types/session.js'
|
|
@@ -48,10 +42,10 @@ export type AuthParams =
|
|
|
48
42
|
| {
|
|
49
43
|
type: 'oauth'
|
|
50
44
|
provider: string
|
|
45
|
+
sessionId: string
|
|
51
46
|
}
|
|
52
47
|
| {
|
|
53
48
|
type: 'passkey'
|
|
54
|
-
email: string
|
|
55
49
|
mode: 'register' | 'login'
|
|
56
50
|
}
|
|
57
51
|
| {
|
|
@@ -62,13 +56,33 @@ export type AuthParams =
|
|
|
62
56
|
type: 'email' | 'sms'
|
|
63
57
|
contact: string
|
|
64
58
|
}
|
|
65
|
-
emailCustomization?: EmailCustomization
|
|
66
59
|
}
|
|
67
60
|
| {
|
|
68
61
|
type: 'otp'
|
|
69
62
|
mode: 'verifyOtp'
|
|
70
63
|
otpId: string
|
|
71
64
|
otpCode: string
|
|
65
|
+
/**
|
|
66
|
+
* The encryption target bundle returned by the matching `sendOtp` call.
|
|
67
|
+
* Required — used to HPKE-encrypt the OTP attempt to the enclave.
|
|
68
|
+
*/
|
|
69
|
+
otpEncryptionTargetBundle: string
|
|
70
|
+
}
|
|
71
|
+
| {
|
|
72
|
+
type: 'magicLink'
|
|
73
|
+
mode: 'send'
|
|
74
|
+
email: string
|
|
75
|
+
}
|
|
76
|
+
| {
|
|
77
|
+
type: 'magicLink'
|
|
78
|
+
mode: 'verify'
|
|
79
|
+
otpId: string
|
|
80
|
+
code: string
|
|
81
|
+
/**
|
|
82
|
+
* The encryption target bundle returned by the matching `sendMagicLink`
|
|
83
|
+
* (a.k.a. magicLink `send`) call. Required for the encrypted-OTP flow.
|
|
84
|
+
*/
|
|
85
|
+
otpEncryptionTargetBundle: string
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
export interface ZeroDevWalletSDK {
|
|
@@ -93,37 +107,41 @@ export interface ZeroDevWalletSDK {
|
|
|
93
107
|
toAccount: () => Promise<LocalAccount>
|
|
94
108
|
}
|
|
95
109
|
|
|
96
|
-
export async function
|
|
97
|
-
config:
|
|
110
|
+
export async function createZeroDevWalletCore(
|
|
111
|
+
config: ZeroDevWalletConfigCore,
|
|
98
112
|
): Promise<ZeroDevWalletSDK> {
|
|
99
|
-
const {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
rpId = window.location.hostname,
|
|
103
|
-
organizationId = DEFAULT_ORGANIZATION_ID,
|
|
104
|
-
} = config
|
|
105
|
-
|
|
106
|
-
const sessionStorageManager = createStorageManager(
|
|
107
|
-
sessionStorage || createWebStorageAdapter(),
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
const indexedDbStamper = await createIndexedDbStamper()
|
|
113
|
+
const { projectId, sessionStorage, rpId, apiKeyStamper, organizationId } =
|
|
114
|
+
config
|
|
115
|
+
const passkeyStamper = config.passkeyStamper ?? createNoopPasskeyStamper()
|
|
111
116
|
|
|
112
|
-
const
|
|
117
|
+
const sessionStorageManager = createStorageManager(sessionStorage)
|
|
113
118
|
|
|
114
119
|
const client = createClient({
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
apiKeyStamper,
|
|
121
|
+
passkeyStamper,
|
|
117
122
|
transport: zeroDevWalletTransport({
|
|
118
123
|
baseUrl: config.proxyBaseUrl || `${KMS_SERVER_URL}/api/v1`,
|
|
124
|
+
...(config.fetchOptions && { fetchOptions: config.fetchOptions }),
|
|
119
125
|
}),
|
|
120
126
|
})
|
|
121
127
|
|
|
128
|
+
let cachedAuthProxyConfigId: string | undefined
|
|
129
|
+
|
|
130
|
+
// Resolve the Turnkey parent org that stamp-login is signed against: explicit
|
|
131
|
+
// override → backend fetch (/server-info/parent-org-id, cached) → hardcoded
|
|
132
|
+
// fallback if the endpoint is unavailable (older backends). This is why the
|
|
133
|
+
// org no longer needs to be hardcoded/overridden per environment.
|
|
134
|
+
const resolveOrganizationId = createOrganizationIdResolver({
|
|
135
|
+
organizationId,
|
|
136
|
+
fetchParentOrgId: async () => (await client.getParentOrgId()).parentOrgId,
|
|
137
|
+
fallback: DEFAULT_ORGANIZATION_ID,
|
|
138
|
+
})
|
|
139
|
+
|
|
122
140
|
return {
|
|
123
141
|
client,
|
|
124
142
|
async getPublicKey() {
|
|
125
|
-
await client.
|
|
126
|
-
const compressedPublicKey = await client.
|
|
143
|
+
await client.apiKeyStamper.resetKeyPair()
|
|
144
|
+
const compressedPublicKey = await client.apiKeyStamper.getPublicKey()
|
|
127
145
|
return compressedPublicKey
|
|
128
146
|
},
|
|
129
147
|
|
|
@@ -162,30 +180,26 @@ export async function createZeroDevWallet(
|
|
|
162
180
|
if (!activeSession) {
|
|
163
181
|
throw new Error('No active session')
|
|
164
182
|
}
|
|
165
|
-
if (activeSession.stamperType === '
|
|
166
|
-
const newKeyPair = await crypto.subtle.generateKey(
|
|
167
|
-
{
|
|
168
|
-
name: 'ECDSA',
|
|
169
|
-
namedCurve: 'P-256',
|
|
170
|
-
},
|
|
171
|
-
false,
|
|
172
|
-
['sign', 'verify'],
|
|
173
|
-
)
|
|
183
|
+
if (activeSession.stamperType === 'apiKey') {
|
|
174
184
|
const compressedPublicKeyHex =
|
|
175
|
-
await
|
|
185
|
+
await client.apiKeyStamper.prepareKeyRotation()
|
|
176
186
|
const data = await client.loginWithStamp({
|
|
177
187
|
targetPublicKey: compressedPublicKeyHex,
|
|
178
188
|
projectId,
|
|
179
|
-
|
|
180
|
-
|
|
189
|
+
// Stamp-login is signed against the Turnkey parent org; the backend
|
|
190
|
+
// resolves the sub-org from the stamped credential. Signing the
|
|
191
|
+
// sub-org here makes the relayed payload's org mismatch the
|
|
192
|
+
// signature → Turnkey SIGNATURE_INVALID.
|
|
193
|
+
organizationId: await resolveOrganizationId(),
|
|
194
|
+
stampWith: 'apiKey',
|
|
181
195
|
})
|
|
182
|
-
await client.
|
|
196
|
+
await client.apiKeyStamper.commitKeyRotation()
|
|
183
197
|
const parsedSession = parseSession(data.session)
|
|
184
198
|
const session: ZeroDevWalletSession = {
|
|
185
199
|
id: `session_indexedDb_${Date.now()}`,
|
|
186
200
|
userId: parsedSession.userId,
|
|
187
201
|
organizationId: parsedSession.organizationId,
|
|
188
|
-
stamperType: '
|
|
202
|
+
stamperType: 'apiKey',
|
|
189
203
|
sessionType: SessionType.READ_WRITE,
|
|
190
204
|
token: data.session,
|
|
191
205
|
expiry: parsedSession.expiry,
|
|
@@ -202,27 +216,26 @@ export async function createZeroDevWallet(
|
|
|
202
216
|
async auth(params: AuthParams) {
|
|
203
217
|
switch (params.type) {
|
|
204
218
|
case 'oauth': {
|
|
205
|
-
|
|
206
|
-
// set during the OAuth popup flow via /oauth/google/login
|
|
219
|
+
const popSignature = await client.apiKeyStamper.sign(params.sessionId)
|
|
207
220
|
const data = await client.authenticateWithOAuth({
|
|
208
221
|
provider: params.provider,
|
|
209
222
|
projectId,
|
|
223
|
+
sessionId: params.sessionId,
|
|
224
|
+
popSignature,
|
|
210
225
|
})
|
|
211
226
|
|
|
212
227
|
if (data.session) {
|
|
213
228
|
// Parse the JWT to get session data
|
|
214
229
|
const parsedSession = parseSession(data.session)
|
|
215
|
-
const publicKey = await client.indexedDbStamper.getPublicKey()
|
|
216
230
|
const session: ZeroDevWalletSession = {
|
|
217
231
|
id: `session_oauth_${Date.now()}`,
|
|
218
232
|
userId: parsedSession.userId,
|
|
219
233
|
organizationId: parsedSession.organizationId,
|
|
220
|
-
stamperType: '
|
|
234
|
+
stamperType: 'apiKey',
|
|
221
235
|
sessionType: parsedSession.sessionType || SessionType.READ_WRITE,
|
|
222
236
|
token: data.session,
|
|
223
237
|
expiry: parsedSession.expiry,
|
|
224
238
|
createdAt: Date.now(),
|
|
225
|
-
publicKey: publicKey || '',
|
|
226
239
|
}
|
|
227
240
|
await sessionStorageManager.storeSession(session, session.id)
|
|
228
241
|
}
|
|
@@ -235,64 +248,37 @@ export async function createZeroDevWallet(
|
|
|
235
248
|
'mode' in params &&
|
|
236
249
|
params.mode === 'register'
|
|
237
250
|
) {
|
|
238
|
-
|
|
239
|
-
await client.
|
|
240
|
-
const tempPublicKey = await client.indexedDbStamper.getPublicKey()
|
|
251
|
+
await client.apiKeyStamper.resetKeyPair()
|
|
252
|
+
const tempPublicKey = await client.apiKeyStamper.getPublicKey()
|
|
241
253
|
if (!tempPublicKey) {
|
|
242
254
|
throw new Error('Failed to get public key')
|
|
243
255
|
}
|
|
244
|
-
const
|
|
245
|
-
const encodedChallenge =
|
|
246
|
-
|
|
247
|
-
const name = `ZeroDevWallet-${humanReadableDateTime()}-${email}`
|
|
248
|
-
const attestation = await getWebAuthnAttestation({
|
|
249
|
-
publicKey: {
|
|
256
|
+
const name = `ZeroDevWallet-${humanReadableDateTime()}`
|
|
257
|
+
const { attestation, encodedChallenge } =
|
|
258
|
+
await passkeyStamper.register({
|
|
250
259
|
rp: { id: rpId, name: '' },
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
{
|
|
254
|
-
type: 'public-key',
|
|
255
|
-
alg: -7,
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
type: 'public-key',
|
|
259
|
-
alg: -257,
|
|
260
|
-
},
|
|
261
|
-
],
|
|
262
|
-
user: {
|
|
263
|
-
id: authenticatorUserId,
|
|
264
|
-
name,
|
|
265
|
-
displayName: name,
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
})
|
|
260
|
+
userName: name,
|
|
261
|
+
})
|
|
269
262
|
const data = await client.registerWithPasskey({
|
|
270
|
-
email,
|
|
271
263
|
attestation,
|
|
272
264
|
challenge: encodedChallenge,
|
|
273
265
|
projectId,
|
|
274
266
|
encodedPublicKey: tempPublicKey,
|
|
275
267
|
})
|
|
276
|
-
const newKeyPair = await crypto.subtle.generateKey(
|
|
277
|
-
{
|
|
278
|
-
name: 'ECDSA',
|
|
279
|
-
namedCurve: 'P-256',
|
|
280
|
-
},
|
|
281
|
-
false,
|
|
282
|
-
['sign', 'verify'],
|
|
283
|
-
)
|
|
284
268
|
const compressedPublicKeyHex =
|
|
285
|
-
await
|
|
269
|
+
await client.apiKeyStamper.prepareKeyRotation()
|
|
286
270
|
const loginData = await client.loginWithStamp({
|
|
287
271
|
projectId,
|
|
288
272
|
targetPublicKey: compressedPublicKeyHex,
|
|
289
|
-
|
|
273
|
+
// Sign against the parent org (see refreshSession note) — the
|
|
274
|
+
// backend derives the sub-org from the stamped credential.
|
|
275
|
+
organizationId: await resolveOrganizationId(),
|
|
290
276
|
})
|
|
291
|
-
await client.
|
|
277
|
+
await client.apiKeyStamper.commitKeyRotation()
|
|
292
278
|
const parsedSession = parseSession(loginData.session)
|
|
293
279
|
const session: ZeroDevWalletSession = {
|
|
294
280
|
id: `session_indexedDb_${Date.now()}`,
|
|
295
|
-
stamperType: '
|
|
281
|
+
stamperType: 'apiKey',
|
|
296
282
|
createdAt: Date.now(),
|
|
297
283
|
sessionType: SessionType.READ_WRITE,
|
|
298
284
|
userId: parsedSession.userId,
|
|
@@ -310,22 +296,24 @@ export async function createZeroDevWallet(
|
|
|
310
296
|
'mode' in params &&
|
|
311
297
|
params.mode === 'login'
|
|
312
298
|
) {
|
|
313
|
-
await client.
|
|
314
|
-
const generatedPublicKey =
|
|
315
|
-
await client.indexedDbStamper.getPublicKey()
|
|
299
|
+
await client.apiKeyStamper.resetKeyPair()
|
|
300
|
+
const generatedPublicKey = await client.apiKeyStamper.getPublicKey()
|
|
316
301
|
if (!generatedPublicKey) {
|
|
317
302
|
throw new Error('Failed to get public key')
|
|
318
303
|
}
|
|
319
304
|
const loginData = await client.loginWithStamp({
|
|
320
305
|
targetPublicKey: generatedPublicKey,
|
|
321
306
|
projectId,
|
|
322
|
-
|
|
323
|
-
|
|
307
|
+
// Sign against the parent org, not the user's sub-org (see the
|
|
308
|
+
// refreshSession note). The backend derives the sub-org from the
|
|
309
|
+
// stamped passkey credential.
|
|
310
|
+
organizationId: await resolveOrganizationId(),
|
|
311
|
+
stampWith: 'passkey',
|
|
324
312
|
})
|
|
325
313
|
const parsedSession = parseSession(loginData.session)
|
|
326
314
|
const session: ZeroDevWalletSession = {
|
|
327
315
|
id: `session_indexedDb_${Date.now()}`,
|
|
328
|
-
stamperType: '
|
|
316
|
+
stamperType: 'apiKey',
|
|
329
317
|
createdAt: Date.now(),
|
|
330
318
|
sessionType: SessionType.READ_WRITE,
|
|
331
319
|
userId: parsedSession.userId,
|
|
@@ -340,49 +328,84 @@ export async function createZeroDevWallet(
|
|
|
340
328
|
}
|
|
341
329
|
throw new Error('Passkey authentication requires passkey parameter')
|
|
342
330
|
}
|
|
343
|
-
case 'otp':
|
|
344
|
-
|
|
331
|
+
case 'otp':
|
|
332
|
+
case 'magicLink': {
|
|
333
|
+
// Normalize magicLink params into OTP params
|
|
334
|
+
let otpParams: Extract<AuthParams, { type: 'otp' }>
|
|
335
|
+
if (params.type === 'magicLink') {
|
|
336
|
+
if (params.mode === 'send') {
|
|
337
|
+
// Magic-link vs plain-OTP delivery and the link URL template are
|
|
338
|
+
// configured per-project on the backend (`wallet.otp_configs`);
|
|
339
|
+
// the client just initiates OTP and the backend decides.
|
|
340
|
+
otpParams = {
|
|
341
|
+
type: 'otp',
|
|
342
|
+
mode: 'sendOtp',
|
|
343
|
+
email: params.email,
|
|
344
|
+
contact: { type: 'email', contact: params.email },
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
otpParams = {
|
|
348
|
+
type: 'otp',
|
|
349
|
+
mode: 'verifyOtp',
|
|
350
|
+
otpId: params.otpId,
|
|
351
|
+
otpCode: params.code,
|
|
352
|
+
otpEncryptionTargetBundle: params.otpEncryptionTargetBundle,
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
otpParams = params
|
|
357
|
+
}
|
|
345
358
|
|
|
346
|
-
if (
|
|
347
|
-
const { email, contact
|
|
359
|
+
if (otpParams.mode === 'sendOtp') {
|
|
360
|
+
const { email, contact } = otpParams
|
|
348
361
|
|
|
349
362
|
const data = await client.registerWithOTP({
|
|
350
363
|
email,
|
|
351
364
|
contact,
|
|
352
365
|
projectId,
|
|
353
|
-
...(emailCustomization && { emailCustomization }),
|
|
354
366
|
})
|
|
355
367
|
|
|
356
368
|
return data
|
|
357
369
|
}
|
|
358
370
|
|
|
359
|
-
if (
|
|
360
|
-
const { otpId, otpCode } =
|
|
371
|
+
if (otpParams.mode === 'verifyOtp') {
|
|
372
|
+
const { otpId, otpCode, otpEncryptionTargetBundle } = otpParams
|
|
361
373
|
|
|
362
374
|
// Step 1: Generate new key pair
|
|
363
|
-
await client.
|
|
364
|
-
const targetPublicKey = await client.
|
|
375
|
+
await client.apiKeyStamper.resetKeyPair()
|
|
376
|
+
const targetPublicKey = await client.apiKeyStamper.getPublicKey()
|
|
365
377
|
|
|
366
378
|
if (!targetPublicKey) {
|
|
367
379
|
throw new Error('Failed to get public key')
|
|
368
380
|
}
|
|
369
381
|
|
|
370
|
-
// Step
|
|
382
|
+
// Step 2a: HPKE-seal the OTP attempt to the enclave's per-session
|
|
383
|
+
// target key. The auth proxy never sees the plaintext OTP code.
|
|
384
|
+
const encryptedOtpBundle = await encryptOtpAttempt({
|
|
385
|
+
otpCode,
|
|
386
|
+
publicKey: targetPublicKey,
|
|
387
|
+
encryptionTargetBundle: otpEncryptionTargetBundle,
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
// Step 2b: Verify OTP via Auth Proxy
|
|
391
|
+
if (!cachedAuthProxyConfigId) {
|
|
392
|
+
const { authProxyConfigId } = await client.getAuthProxyConfigId()
|
|
393
|
+
cachedAuthProxyConfigId = authProxyConfigId
|
|
394
|
+
}
|
|
371
395
|
const authProxyClient = createAuthProxyClient({
|
|
372
|
-
authProxyConfigId:
|
|
396
|
+
authProxyConfigId: cachedAuthProxyConfigId,
|
|
373
397
|
})
|
|
374
398
|
|
|
375
399
|
const { verificationToken } = await authProxyClient.verifyOtp({
|
|
376
400
|
otpId,
|
|
377
|
-
|
|
378
|
-
public_key: targetPublicKey,
|
|
401
|
+
encryptedOtpBundle,
|
|
379
402
|
})
|
|
380
403
|
|
|
381
404
|
// Step 3: Build client signature
|
|
382
405
|
const clientSignature = await buildClientSignature({
|
|
383
406
|
verificationToken,
|
|
384
407
|
publicKey: targetPublicKey,
|
|
385
|
-
stamper: client.
|
|
408
|
+
stamper: client.apiKeyStamper,
|
|
386
409
|
})
|
|
387
410
|
|
|
388
411
|
// Step 4: Login via backend (not Auth Proxy!)
|
|
@@ -399,13 +422,12 @@ export async function createZeroDevWallet(
|
|
|
399
422
|
id: `session_otp_${Date.now()}`,
|
|
400
423
|
userId: parsedSession.userId,
|
|
401
424
|
organizationId: parsedSession.organizationId,
|
|
402
|
-
stamperType: '
|
|
425
|
+
stamperType: 'apiKey',
|
|
403
426
|
sessionType:
|
|
404
427
|
parsedSession.sessionType || SessionType.READ_WRITE,
|
|
405
428
|
token: data.session,
|
|
406
429
|
expiry: parsedSession.expiry,
|
|
407
430
|
createdAt: Date.now(),
|
|
408
|
-
publicKey: targetPublicKey,
|
|
409
431
|
}
|
|
410
432
|
await sessionStorageManager.storeSession(session, session.id)
|
|
411
433
|
}
|
|
@@ -421,7 +443,7 @@ export async function createZeroDevWallet(
|
|
|
421
443
|
|
|
422
444
|
async logout() {
|
|
423
445
|
await sessionStorageManager.clearAllSessions()
|
|
424
|
-
await client.
|
|
446
|
+
await client.apiKeyStamper.resetKeyPair()
|
|
425
447
|
return true
|
|
426
448
|
},
|
|
427
449
|
|
|
@@ -435,7 +457,10 @@ export async function createZeroDevWallet(
|
|
|
435
457
|
client,
|
|
436
458
|
organizationId: session.organizationId,
|
|
437
459
|
projectId,
|
|
438
|
-
|
|
460
|
+
getToken: async () => {
|
|
461
|
+
const activeSession = await sessionStorageManager.getActiveSession()
|
|
462
|
+
return activeSession?.token ?? ''
|
|
463
|
+
},
|
|
439
464
|
})
|
|
440
465
|
},
|
|
441
466
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { isReactNative } from './utils/platform.js'
|
|
2
|
+
|
|
3
|
+
if (!isReactNative()) {
|
|
4
|
+
// biome-ignore lint/suspicious/noConsole: Warning users if they try to use the web entry on React Native.
|
|
5
|
+
console.warn(
|
|
6
|
+
'@zerodev/wallet-core/react-native: the React Native entry was loaded outside a React Native runtime. If this is a non-RN context, import `@zerodev/wallet-core` (the bare specifier) instead.',
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Re-export shared API surface. Note: we intentionally do NOT re-export the
|
|
11
|
+
// web stamper factories (createIndexedDbStamper, createWebauthnStamper,
|
|
12
|
+
// createIframeStamper) here — they're web-only. The native adapter factories
|
|
13
|
+
// live behind their own granular subpaths so consumers using alternative
|
|
14
|
+
// adapters (Keychain, MMKV, custom) skip the unused peer-dep installs.
|
|
15
|
+
export type {
|
|
16
|
+
ApiKeyAuthenticator,
|
|
17
|
+
AuthenticateWithEmailParameters,
|
|
18
|
+
AuthenticateWithEmailReturnType,
|
|
19
|
+
AuthenticateWithOAuthParameters,
|
|
20
|
+
AuthenticateWithOAuthReturnType,
|
|
21
|
+
EmailContact,
|
|
22
|
+
GetAuthenticatorsParameters,
|
|
23
|
+
GetAuthenticatorsReturnType,
|
|
24
|
+
GetUserWalletParameters,
|
|
25
|
+
GetUserWalletReturnType,
|
|
26
|
+
GetWhoamiParameters,
|
|
27
|
+
GetWhoamiReturnType,
|
|
28
|
+
LoginWithOTPParameters,
|
|
29
|
+
LoginWithOTPReturnType,
|
|
30
|
+
OAuthAuthenticator,
|
|
31
|
+
OtpContact,
|
|
32
|
+
PasskeyAuthenticator,
|
|
33
|
+
RegisterWithOTPParameters,
|
|
34
|
+
RegisterWithOTPReturnType,
|
|
35
|
+
Sign7702AuthorizationParameters,
|
|
36
|
+
Sign7702AuthorizationReturnType,
|
|
37
|
+
SignMessageParameters,
|
|
38
|
+
SignMessageReturnType,
|
|
39
|
+
SignTransactionParameters,
|
|
40
|
+
SignTransactionReturnType,
|
|
41
|
+
SignTypedDataV4Parameters,
|
|
42
|
+
SignTypedDataV4ReturnType,
|
|
43
|
+
SignUserOperationParameters,
|
|
44
|
+
SignUserOperationReturnType,
|
|
45
|
+
} from './actions/index.js'
|
|
46
|
+
export {
|
|
47
|
+
authenticateWithEmail,
|
|
48
|
+
authenticateWithOAuth,
|
|
49
|
+
getAuthenticators,
|
|
50
|
+
getUserWallet,
|
|
51
|
+
getWhoami,
|
|
52
|
+
loginWithOTP,
|
|
53
|
+
registerWithOTP,
|
|
54
|
+
sign7702Authorization,
|
|
55
|
+
signMessage,
|
|
56
|
+
signTransaction,
|
|
57
|
+
signTypedDataV4,
|
|
58
|
+
signUserOperation,
|
|
59
|
+
} from './actions/index.js'
|
|
60
|
+
export type { ToViemAccountParams } from './adapters/viem.js'
|
|
61
|
+
export { toViemAccount } from './adapters/viem.js'
|
|
62
|
+
export type { ZeroDevWalletActions } from './client/decorators/client.js'
|
|
63
|
+
export { zeroDevWalletActions } from './client/decorators/client.js'
|
|
64
|
+
export type {
|
|
65
|
+
Client,
|
|
66
|
+
ClientConfig,
|
|
67
|
+
CreateTransportOptions,
|
|
68
|
+
Transport,
|
|
69
|
+
} from './client/index.js'
|
|
70
|
+
export {
|
|
71
|
+
createBaseClient,
|
|
72
|
+
createClient,
|
|
73
|
+
type ZeroDevWalletClient,
|
|
74
|
+
zeroDevWalletTransport,
|
|
75
|
+
} from './client/index.js'
|
|
76
|
+
export { KMS_SERVER_URL } from './constants.js'
|
|
77
|
+
export type {
|
|
78
|
+
AuthParams,
|
|
79
|
+
ZeroDevWalletSDK,
|
|
80
|
+
} from './core/createZeroDevWalletCore.js'
|
|
81
|
+
// RN entry re-exports through a thin wrapper that auto-injects the
|
|
82
|
+
// `Origin: https://${rpId}` header on Turnkey requests. `ZeroDevWalletConfig`
|
|
83
|
+
// matches the strict `ZeroDevWalletConfigCore` shape, so RN consumers still
|
|
84
|
+
// get compile-time enforcement of the four required adapter fields.
|
|
85
|
+
export {
|
|
86
|
+
createZeroDevWallet,
|
|
87
|
+
type ZeroDevWalletConfig,
|
|
88
|
+
} from './native/createZeroDevWallet.js'
|
|
89
|
+
export type {
|
|
90
|
+
ApiKeyStamper,
|
|
91
|
+
Attestation,
|
|
92
|
+
IframeStamper,
|
|
93
|
+
PasskeyRegistrationOptions,
|
|
94
|
+
PasskeyRegistrationResult,
|
|
95
|
+
PasskeyStamper,
|
|
96
|
+
} from './stampers/types.js'
|
|
97
|
+
export type { StorageAdapter, StorageManager } from './storage/manager.js'
|
|
98
|
+
export type { StamperType, ZeroDevWalletSession } from './types/session.js'
|
|
99
|
+
export type { KeyFormat } from './utils/exportPrivateKey.js'
|
|
100
|
+
export { exportPrivateKey } from './utils/exportPrivateKey.js'
|
|
101
|
+
export { exportWallet } from './utils/exportWallet.js'
|
|
102
|
+
export { normalizeTimestamp } from './utils/utils.js'
|