@zerodev/wallet-core 0.0.1-alpha.8 → 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 -16
- 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 -29
- 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 -29
- 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 -46
- package/src/actions/wallet/signRawPayload.ts +0 -75
- package/src/stampers/index.ts +0 -8
package/src/index.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
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: the web entry was loaded in a React Native runtime. Check that your metro.config.js has `unstable_enablePackageExports: true` and `"react-native"` in `unstable_conditionNames`.',
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
export type {
|
|
2
11
|
// Auth types
|
|
12
|
+
ApiKeyAuthenticator,
|
|
3
13
|
AuthenticateWithEmailParameters,
|
|
4
14
|
AuthenticateWithEmailReturnType,
|
|
5
15
|
AuthenticateWithOAuthParameters,
|
|
6
16
|
AuthenticateWithOAuthReturnType,
|
|
7
|
-
|
|
17
|
+
EmailContact,
|
|
18
|
+
GetAuthenticatorsParameters,
|
|
19
|
+
GetAuthenticatorsReturnType,
|
|
8
20
|
// Wallet types
|
|
9
21
|
GetUserWalletParameters,
|
|
10
22
|
GetUserWalletReturnType,
|
|
@@ -12,13 +24,21 @@ export type {
|
|
|
12
24
|
GetWhoamiReturnType,
|
|
13
25
|
LoginWithOTPParameters,
|
|
14
26
|
LoginWithOTPReturnType,
|
|
27
|
+
OAuthAuthenticator,
|
|
15
28
|
OtpContact,
|
|
29
|
+
PasskeyAuthenticator,
|
|
16
30
|
RegisterWithOTPParameters,
|
|
17
31
|
RegisterWithOTPReturnType,
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
Sign7702AuthorizationParameters,
|
|
33
|
+
Sign7702AuthorizationReturnType,
|
|
34
|
+
SignMessageParameters,
|
|
35
|
+
SignMessageReturnType,
|
|
20
36
|
SignTransactionParameters,
|
|
21
37
|
SignTransactionReturnType,
|
|
38
|
+
SignTypedDataV4Parameters,
|
|
39
|
+
SignTypedDataV4ReturnType,
|
|
40
|
+
SignUserOperationParameters,
|
|
41
|
+
SignUserOperationReturnType,
|
|
22
42
|
} from './actions/index.js'
|
|
23
43
|
|
|
24
44
|
// Actions
|
|
@@ -26,13 +46,17 @@ export {
|
|
|
26
46
|
// Auth actions
|
|
27
47
|
authenticateWithEmail,
|
|
28
48
|
authenticateWithOAuth,
|
|
49
|
+
getAuthenticators,
|
|
29
50
|
// Wallet actions
|
|
30
51
|
getUserWallet,
|
|
31
52
|
getWhoami,
|
|
32
53
|
loginWithOTP,
|
|
33
54
|
registerWithOTP,
|
|
34
|
-
|
|
55
|
+
sign7702Authorization,
|
|
56
|
+
signMessage,
|
|
35
57
|
signTransaction,
|
|
58
|
+
signTypedDataV4,
|
|
59
|
+
signUserOperation,
|
|
36
60
|
} from './actions/index.js'
|
|
37
61
|
export type { ToViemAccountParams } from './adapters/viem.js'
|
|
38
62
|
// Adapters
|
|
@@ -40,7 +64,12 @@ export { toViemAccount } from './adapters/viem.js'
|
|
|
40
64
|
export type { ZeroDevWalletActions } from './client/decorators/client.js'
|
|
41
65
|
// Client decorators
|
|
42
66
|
export { zeroDevWalletActions } from './client/decorators/client.js'
|
|
43
|
-
export type {
|
|
67
|
+
export type {
|
|
68
|
+
Client,
|
|
69
|
+
ClientConfig,
|
|
70
|
+
CreateTransportOptions,
|
|
71
|
+
Transport,
|
|
72
|
+
} from './client/index.js'
|
|
44
73
|
// Client
|
|
45
74
|
export {
|
|
46
75
|
createBaseClient,
|
|
@@ -52,21 +81,17 @@ export {
|
|
|
52
81
|
export { KMS_SERVER_URL } from './constants.js'
|
|
53
82
|
export type {
|
|
54
83
|
AuthParams,
|
|
55
|
-
ZeroDevWalletConfig,
|
|
56
84
|
ZeroDevWalletSDK,
|
|
57
|
-
} from './core/
|
|
58
|
-
// Core
|
|
59
|
-
export { createZeroDevWallet } from './core/createZeroDevWallet.js'
|
|
85
|
+
} from './core/createZeroDevWalletCore.js'
|
|
60
86
|
// Stampers
|
|
61
|
-
export {
|
|
62
|
-
createIframeStamper,
|
|
63
|
-
createIndexedDbStamper,
|
|
64
|
-
createWebauthnStamper,
|
|
65
|
-
} from './stampers/index.js'
|
|
87
|
+
export { createIframeStamper } from './stampers/iframeStamper.js'
|
|
66
88
|
export type {
|
|
89
|
+
ApiKeyStamper,
|
|
90
|
+
Attestation,
|
|
67
91
|
IframeStamper,
|
|
68
|
-
|
|
69
|
-
|
|
92
|
+
PasskeyRegistrationOptions,
|
|
93
|
+
PasskeyRegistrationResult,
|
|
94
|
+
PasskeyStamper,
|
|
70
95
|
} from './stampers/types.js'
|
|
71
96
|
// Storage
|
|
72
97
|
export type { StorageAdapter, StorageManager } from './storage/manager.js'
|
|
@@ -77,3 +102,11 @@ export { exportPrivateKey } from './utils/exportPrivateKey.js'
|
|
|
77
102
|
export { exportWallet } from './utils/exportWallet.js'
|
|
78
103
|
// Utils
|
|
79
104
|
export { normalizeTimestamp } from './utils/utils.js'
|
|
105
|
+
// Core — bare specifier resolves web defaults (IndexedDB, WebAuthn, session
|
|
106
|
+
// storage, hostname-derived rpId) before forwarding to the shared factory.
|
|
107
|
+
// RN consumers go through `@zerodev/wallet-core/react-native`, which exposes
|
|
108
|
+
// the strict `ZeroDevWalletConfig` (= core's required-fields shape) directly.
|
|
109
|
+
export {
|
|
110
|
+
createZeroDevWallet,
|
|
111
|
+
type ZeroDevWalletConfig,
|
|
112
|
+
} from './web/createZeroDevWallet.js'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createZeroDevWalletCore,
|
|
3
|
+
type ZeroDevWalletConfigCore,
|
|
4
|
+
type ZeroDevWalletSDK,
|
|
5
|
+
} from '../core/createZeroDevWalletCore.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* React Native config — mirrors `web/createZeroDevWallet.ts`'s wrapper
|
|
9
|
+
* pattern. RN consumers must supply all four adapter fields up front
|
|
10
|
+
* (no platform-native defaults exist for IndexedDB/WebAuthn). The only
|
|
11
|
+
* RN-specific defaulting is `fetchOptions`: when omitted, we set
|
|
12
|
+
* `Origin: https://${rpId}` so Turnkey's ACL accepts the request. Power
|
|
13
|
+
* users wanting a different Origin can pass `fetchOptions` explicitly.
|
|
14
|
+
*/
|
|
15
|
+
export type ZeroDevWalletConfig = ZeroDevWalletConfigCore
|
|
16
|
+
|
|
17
|
+
export async function createZeroDevWallet(
|
|
18
|
+
config: ZeroDevWalletConfig,
|
|
19
|
+
): Promise<ZeroDevWalletSDK> {
|
|
20
|
+
return createZeroDevWalletCore({
|
|
21
|
+
...config,
|
|
22
|
+
fetchOptions: config.fetchOptions ?? {
|
|
23
|
+
headers: { Origin: `https://${config.rpId}` },
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPasskey,
|
|
3
|
+
PasskeyStamper as TurnkeyPasskeyStamper,
|
|
4
|
+
} from '@turnkey/react-native-passkey-stamper'
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
6
|
+
import type {
|
|
7
|
+
PasskeyRegistrationOptions,
|
|
8
|
+
PasskeyStamper,
|
|
9
|
+
} from '../../stampers/types.js'
|
|
10
|
+
|
|
11
|
+
export async function createReactNativePasskeyStamper({
|
|
12
|
+
rpId,
|
|
13
|
+
}: {
|
|
14
|
+
rpId: string
|
|
15
|
+
}): Promise<PasskeyStamper> {
|
|
16
|
+
const inner = new TurnkeyPasskeyStamper({ rpId })
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
async stamp(payload: string) {
|
|
20
|
+
return await inner.stamp(payload)
|
|
21
|
+
},
|
|
22
|
+
async clear() {},
|
|
23
|
+
async register({ rp, userName }: PasskeyRegistrationOptions) {
|
|
24
|
+
const { attestation, challenge: encodedChallenge } = await createPasskey({
|
|
25
|
+
rp: {
|
|
26
|
+
id: rp.id,
|
|
27
|
+
name: rp.name ?? 'Turnkey',
|
|
28
|
+
},
|
|
29
|
+
user: {
|
|
30
|
+
id: uuidv4(),
|
|
31
|
+
name: userName,
|
|
32
|
+
displayName: userName,
|
|
33
|
+
},
|
|
34
|
+
authenticatorName: userName ?? 'End-User Passkey',
|
|
35
|
+
})
|
|
36
|
+
return { attestation, encodedChallenge }
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { ApiKeyStamper, SignatureFormat } from '@turnkey/api-key-stamper'
|
|
2
|
+
import { generateP256KeyPair } from '@turnkey/crypto'
|
|
3
|
+
import * as SecureStore from 'expo-secure-store'
|
|
4
|
+
import type { ApiKeyStamper as ZDApiKeyStamper } from '../../stampers/types.js'
|
|
5
|
+
|
|
6
|
+
const PUBLIC_KEY = 'zerodev.publicKey'
|
|
7
|
+
const PRIVATE_KEY = 'zerodev.privateKey'
|
|
8
|
+
|
|
9
|
+
class SecureStoreStamperInner {
|
|
10
|
+
private publicKeyHex: string | null = null
|
|
11
|
+
|
|
12
|
+
async init(): Promise<void> {
|
|
13
|
+
const publicKey = await SecureStore.getItemAsync(PUBLIC_KEY)
|
|
14
|
+
const privateKey = await SecureStore.getItemAsync(PRIVATE_KEY)
|
|
15
|
+
|
|
16
|
+
if (publicKey && privateKey) {
|
|
17
|
+
this.publicKeyHex = publicKey
|
|
18
|
+
} else {
|
|
19
|
+
await this.resetKeyPair()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async getPublicKey(): Promise<string | null> {
|
|
24
|
+
return this.publicKeyHex
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async resetKeyPair(externalKeyPair?: {
|
|
28
|
+
publicKey: string
|
|
29
|
+
privateKey: string
|
|
30
|
+
}): Promise<void> {
|
|
31
|
+
await this.clear()
|
|
32
|
+
|
|
33
|
+
const pair = externalKeyPair ?? generateP256KeyPair()
|
|
34
|
+
|
|
35
|
+
await SecureStore.setItemAsync(PUBLIC_KEY, pair.publicKey)
|
|
36
|
+
await SecureStore.setItemAsync(PRIVATE_KEY, pair.privateKey)
|
|
37
|
+
|
|
38
|
+
this.publicKeyHex = pair.publicKey
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private async getTurnkeyApiKeyStamper(): Promise<ApiKeyStamper> {
|
|
42
|
+
if (!this.publicKeyHex) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
'Key not initialized. Call init() or resetKeyPair() first.',
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const privateKey = await SecureStore.getItemAsync(PRIVATE_KEY)
|
|
49
|
+
if (!privateKey) {
|
|
50
|
+
throw new Error('No private key found in secure store.')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return new ApiKeyStamper({
|
|
54
|
+
apiPublicKey: this.publicKeyHex,
|
|
55
|
+
apiPrivateKey: privateKey,
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async stamp(
|
|
60
|
+
payload: string,
|
|
61
|
+
): Promise<{ stampHeaderName: string; stampHeaderValue: string }> {
|
|
62
|
+
const stamper = await this.getTurnkeyApiKeyStamper()
|
|
63
|
+
const { stampHeaderName, stampHeaderValue } = await stamper.stamp(payload)
|
|
64
|
+
return { stampHeaderName, stampHeaderValue }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async sign(payload: string): Promise<string> {
|
|
68
|
+
const stamper = await this.getTurnkeyApiKeyStamper()
|
|
69
|
+
return stamper.sign(payload, SignatureFormat.Der)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async clear(): Promise<void> {
|
|
73
|
+
await SecureStore.deleteItemAsync(PUBLIC_KEY)
|
|
74
|
+
await SecureStore.deleteItemAsync(PRIVATE_KEY)
|
|
75
|
+
this.publicKeyHex = null
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function warmApiKeyStamperForMetroDev(
|
|
80
|
+
inner: SecureStoreStamperInner,
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
// `__DEV__` is a global set by React Native's Metro; read it via globalThis
|
|
83
|
+
// so this file needs no ambient `.d.ts` (which would conflict with RN's own
|
|
84
|
+
// typings when both happen to be in scope, e.g. in the editor).
|
|
85
|
+
if (!(globalThis as { __DEV__?: boolean }).__DEV__) return
|
|
86
|
+
|
|
87
|
+
// In Expo dev, Turnkey's API key stamper loads its React Native signer with a
|
|
88
|
+
// dynamic import the first time `stamp()` runs. OTP verification is usually
|
|
89
|
+
// the first code path that stamps a payload, and if the app was backgrounded
|
|
90
|
+
// while the user copied the code, Metro can serve that lazy module after
|
|
91
|
+
// foregrounding and trigger a full JS reload. Warming the stamper during dev
|
|
92
|
+
// startup makes Metro load the signer while the app is foregrounded; production
|
|
93
|
+
// builds do not use Metro and skip this block via `__DEV__`.
|
|
94
|
+
try {
|
|
95
|
+
await inner.stamp('{"purpose":"metro-dev-warmup"}')
|
|
96
|
+
} catch (error) {
|
|
97
|
+
// biome-ignore lint/suspicious/noConsole: This only runs in dev mode
|
|
98
|
+
console.warn('Failed to warm API key stamper in dev:', error)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function createSecureStoreStamper(): Promise<ZDApiKeyStamper> {
|
|
103
|
+
const inner = new SecureStoreStamperInner()
|
|
104
|
+
await inner.init()
|
|
105
|
+
await warmApiKeyStamperForMetroDev(inner)
|
|
106
|
+
|
|
107
|
+
let pendingKeyPair: { publicKey: string; privateKey: string } | null = null
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
async getPublicKey() {
|
|
111
|
+
return inner.getPublicKey()
|
|
112
|
+
},
|
|
113
|
+
async stamp(payload: string) {
|
|
114
|
+
return inner.stamp(payload)
|
|
115
|
+
},
|
|
116
|
+
async sign(payload: string) {
|
|
117
|
+
return inner.sign(payload)
|
|
118
|
+
},
|
|
119
|
+
async clear() {
|
|
120
|
+
await inner.clear()
|
|
121
|
+
},
|
|
122
|
+
async resetKeyPair() {
|
|
123
|
+
pendingKeyPair = null
|
|
124
|
+
await inner.resetKeyPair()
|
|
125
|
+
},
|
|
126
|
+
async prepareKeyRotation() {
|
|
127
|
+
const keyPair = generateP256KeyPair()
|
|
128
|
+
pendingKeyPair = keyPair
|
|
129
|
+
return keyPair.publicKey
|
|
130
|
+
},
|
|
131
|
+
async commitKeyRotation() {
|
|
132
|
+
if (!pendingKeyPair) {
|
|
133
|
+
throw new Error('No pending key rotation to commit')
|
|
134
|
+
}
|
|
135
|
+
await inner.resetKeyPair(pendingKeyPair)
|
|
136
|
+
pendingKeyPair = null
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AsyncStorageStatic } from '@react-native-async-storage/async-storage'
|
|
2
|
+
import * as AsyncStorageNS from '@react-native-async-storage/async-storage'
|
|
3
|
+
import type { StorageAdapter } from '../../storage/manager.js'
|
|
4
|
+
|
|
5
|
+
// CJS package whose `.d.ts` declares `export default AsyncStorage`. Our tsconfig
|
|
6
|
+
// keeps `esModuleInterop: false` (and `verbatimModuleSyntax: true`), so a plain
|
|
7
|
+
// `import AsyncStorage from '...'` types as the module namespace instead of
|
|
8
|
+
// the default. Unwrap explicitly. At runtime Metro returns the default object
|
|
9
|
+
// either way; this only affects the static type.
|
|
10
|
+
const AsyncStorage: AsyncStorageStatic = (
|
|
11
|
+
AsyncStorageNS as unknown as { default: AsyncStorageStatic }
|
|
12
|
+
).default
|
|
13
|
+
|
|
14
|
+
export const asyncStorageAdapter: StorageAdapter = {
|
|
15
|
+
getItem: (key) => AsyncStorage.getItem(key),
|
|
16
|
+
setItem: (key, value) => AsyncStorage.setItem(key, value),
|
|
17
|
+
removeItem: (key) => AsyncStorage.removeItem(key),
|
|
18
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { IndexedDbStamper as TurnkeyIndexedDbStamper } from '@turnkey/indexed-db-stamper'
|
|
2
|
-
import
|
|
2
|
+
import { generateCompressedPublicKeyFromKeyPair } from '../utils/utils.js'
|
|
3
|
+
import type { ApiKeyStamper } from './types.js'
|
|
3
4
|
|
|
4
|
-
export async function createIndexedDbStamper(): Promise<
|
|
5
|
+
export async function createIndexedDbStamper(): Promise<ApiKeyStamper> {
|
|
5
6
|
const inner = new TurnkeyIndexedDbStamper()
|
|
6
7
|
await inner.init()
|
|
7
8
|
|
|
9
|
+
let pendingKeyPair: CryptoKeyPair | null = null
|
|
10
|
+
|
|
8
11
|
return {
|
|
9
12
|
async getPublicKey() {
|
|
10
13
|
return await inner.getPublicKey()
|
|
@@ -12,11 +15,31 @@ export async function createIndexedDbStamper(): Promise<IndexedDbStamper> {
|
|
|
12
15
|
async stamp(payload: string) {
|
|
13
16
|
return await inner.stamp(payload)
|
|
14
17
|
},
|
|
18
|
+
async sign(payload: string) {
|
|
19
|
+
return await inner.sign(payload)
|
|
20
|
+
},
|
|
15
21
|
async clear() {
|
|
16
22
|
await inner.clear()
|
|
17
23
|
},
|
|
18
|
-
async resetKeyPair(
|
|
19
|
-
|
|
24
|
+
async resetKeyPair() {
|
|
25
|
+
pendingKeyPair = null
|
|
26
|
+
await inner.resetKeyPair()
|
|
27
|
+
},
|
|
28
|
+
async prepareKeyRotation() {
|
|
29
|
+
const keyPair = await crypto.subtle.generateKey(
|
|
30
|
+
{ name: 'ECDSA', namedCurve: 'P-256' },
|
|
31
|
+
false,
|
|
32
|
+
['sign', 'verify'],
|
|
33
|
+
)
|
|
34
|
+
pendingKeyPair = keyPair
|
|
35
|
+
return await generateCompressedPublicKeyFromKeyPair(keyPair)
|
|
36
|
+
},
|
|
37
|
+
async commitKeyRotation() {
|
|
38
|
+
if (!pendingKeyPair) {
|
|
39
|
+
throw new Error('No pending key rotation to commit')
|
|
40
|
+
}
|
|
41
|
+
await inner.resetKeyPair(pendingKeyPair)
|
|
42
|
+
pendingKeyPair = null
|
|
20
43
|
},
|
|
21
44
|
}
|
|
22
45
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PasskeyStamper } from './types.js'
|
|
2
|
+
|
|
3
|
+
const NOT_CONFIGURED_MESSAGE =
|
|
4
|
+
'passkeyStamper is not configured. Pass passkeyStamper to zeroDevWallet({ ... }) — use createReactNativePasskeyStamper({ rpId }) on React Native or createWebauthnStamper({ rpId }) on web.'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal fallback used when a consumer doesn't supply a `passkeyStamper`.
|
|
8
|
+
* Methods throw on use, so passkey register/login fails with an actionable
|
|
9
|
+
* message — all other flows (apiKey signing, OAuth, OTP) are unaffected.
|
|
10
|
+
*/
|
|
11
|
+
export function createNoopPasskeyStamper(): PasskeyStamper {
|
|
12
|
+
return {
|
|
13
|
+
async stamp() {
|
|
14
|
+
throw new Error(NOT_CONFIGURED_MESSAGE)
|
|
15
|
+
},
|
|
16
|
+
async register() {
|
|
17
|
+
throw new Error(NOT_CONFIGURED_MESSAGE)
|
|
18
|
+
},
|
|
19
|
+
async clear() {},
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/stampers/types.ts
CHANGED
|
@@ -5,8 +5,6 @@ export type Stamp = {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export type Stamper = {
|
|
8
|
-
/** retrieve public key compressed or otherwise as per the stamper */
|
|
9
|
-
getPublicKey: () => Promise<string | null>
|
|
10
8
|
/** produce Turnkey header value for a given request body */
|
|
11
9
|
stamp: (payload: string) => Promise<Stamp>
|
|
12
10
|
/** clear local state (embedded key, IDB keypair, etc.) */
|
|
@@ -16,6 +14,8 @@ export type Stamper = {
|
|
|
16
14
|
export type KeyFormat = 'Hexadecimal' | 'Solana'
|
|
17
15
|
|
|
18
16
|
export type IframeStamper = Stamper & {
|
|
17
|
+
/** retrieve public key compressed or otherwise as per the stamper */
|
|
18
|
+
getPublicKey: () => Promise<string | null>
|
|
19
19
|
init(): Promise<string>
|
|
20
20
|
injectCredentialBundle(bundle: string): Promise<boolean>
|
|
21
21
|
injectWalletExportBundle(
|
|
@@ -27,9 +27,43 @@ export type IframeStamper = Stamper & {
|
|
|
27
27
|
organizationId: string,
|
|
28
28
|
keyFormat?: KeyFormat,
|
|
29
29
|
): Promise<boolean>
|
|
30
|
+
applySettings(settings: { styles?: Record<string, string> }): Promise<boolean>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type ApiKeyStamper = Stamper & {
|
|
34
|
+
/** retrieve public key compressed or otherwise as per the stamper */
|
|
35
|
+
getPublicKey: () => Promise<string | null>
|
|
36
|
+
/** Generate + activate a new key pair immediately (simple cases: login init, logout). */
|
|
37
|
+
resetKeyPair: () => Promise<void>
|
|
38
|
+
/** Generate a new key pair internally, return its compressed public key, but keep the OLD key active for stamp(). */
|
|
39
|
+
prepareKeyRotation: () => Promise<string>
|
|
40
|
+
/** Promote the pending key to active. Call after the server accepts the new key. */
|
|
41
|
+
commitKeyRotation: () => Promise<void>
|
|
42
|
+
/**
|
|
43
|
+
* Sign `payload` with the currently active key. Returns a hex-encoded
|
|
44
|
+
* ECDSA-P256 / SHA-256 signature in ASN.1 DER form.
|
|
45
|
+
*/
|
|
46
|
+
sign: (payload: string) => Promise<string>
|
|
47
|
+
}
|
|
48
|
+
export type Attestation = {
|
|
49
|
+
attestationObject: string
|
|
50
|
+
clientDataJson: string
|
|
51
|
+
credentialId: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type PasskeyRegistrationOptions = {
|
|
55
|
+
rp: { id: string; name: string }
|
|
56
|
+
userName: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type PasskeyRegistrationResult = {
|
|
60
|
+
attestation: Attestation
|
|
61
|
+
encodedChallenge: string
|
|
30
62
|
}
|
|
31
63
|
|
|
32
|
-
export type
|
|
33
|
-
|
|
64
|
+
export type PasskeyStamper = Stamper & {
|
|
65
|
+
/** Create a new passkey credential. Owns challenge and user ID generation internally. */
|
|
66
|
+
register: (
|
|
67
|
+
options: PasskeyRegistrationOptions,
|
|
68
|
+
) => Promise<PasskeyRegistrationResult>
|
|
34
69
|
}
|
|
35
|
-
export type WebauthnStamper = Stamper
|
|
@@ -1,21 +1,42 @@
|
|
|
1
|
+
import { getWebAuthnAttestation } from '@turnkey/http'
|
|
1
2
|
import { WebauthnStamper as TurnkeyWebauthnStamper } from '@turnkey/webauthn-stamper'
|
|
2
|
-
import
|
|
3
|
+
import { base64UrlEncode, generateRandomBuffer } from '../utils/utils.js'
|
|
4
|
+
import type { PasskeyRegistrationOptions, PasskeyStamper } from './types.js'
|
|
3
5
|
|
|
4
6
|
export async function createWebauthnStamper({
|
|
5
7
|
rpId,
|
|
6
8
|
}: {
|
|
7
9
|
rpId: string
|
|
8
|
-
}): Promise<
|
|
10
|
+
}): Promise<PasskeyStamper> {
|
|
9
11
|
const inner = new TurnkeyWebauthnStamper({ rpId })
|
|
10
12
|
|
|
11
13
|
return {
|
|
12
|
-
async getPublicKey() {
|
|
13
|
-
// return await inner.();
|
|
14
|
-
return null
|
|
15
|
-
},
|
|
16
14
|
async stamp(payload: string) {
|
|
17
15
|
return await inner.stamp(payload)
|
|
18
16
|
},
|
|
19
17
|
async clear() {},
|
|
18
|
+
async register(options: PasskeyRegistrationOptions) {
|
|
19
|
+
const challenge = generateRandomBuffer()
|
|
20
|
+
const encodedChallenge = base64UrlEncode(challenge)
|
|
21
|
+
const authenticatorUserId = generateRandomBuffer()
|
|
22
|
+
|
|
23
|
+
const attestation = await getWebAuthnAttestation({
|
|
24
|
+
publicKey: {
|
|
25
|
+
rp: options.rp,
|
|
26
|
+
challenge,
|
|
27
|
+
pubKeyCredParams: [
|
|
28
|
+
{ type: 'public-key', alg: -7 },
|
|
29
|
+
{ type: 'public-key', alg: -257 },
|
|
30
|
+
],
|
|
31
|
+
user: {
|
|
32
|
+
id: authenticatorUserId,
|
|
33
|
+
name: options.userName,
|
|
34
|
+
displayName: options.userName,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
return { attestation, encodedChallenge }
|
|
40
|
+
},
|
|
20
41
|
}
|
|
21
42
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Catch-all stub used by every `./react-native/*` subpath in this package
|
|
2
|
+
// under the `browser` and `node` exports conditions. Both are needed for
|
|
3
|
+
// Expo web: the client bundle resolves with `browser` active, while Expo
|
|
4
|
+
// Router's SSR/RSC route render drops platform conditions (no `browser`)
|
|
5
|
+
// and turns on `node` instead — so the web stub has to be gated on both or
|
|
6
|
+
// the SSR pass falls through to the native impl. Imports must be safe on web
|
|
7
|
+
// (some route files are bundled even when they aren't rendered) so we expose
|
|
8
|
+
// the RN-only symbols as throw-on-use functions instead of throwing at
|
|
9
|
+
// module-init time.
|
|
10
|
+
//
|
|
11
|
+
// Anyone who *uses* these on web gets a clear actionable error; anyone who
|
|
12
|
+
// merely imports them (typically because their universal app bundles the
|
|
13
|
+
// native variant too) is unaffected.
|
|
14
|
+
|
|
15
|
+
const message =
|
|
16
|
+
'@zerodev/wallet-core react-native subpaths cannot be imported in a web environment. Use the bare specifier (`import { ... } from "@zerodev/wallet-core"`) instead.'
|
|
17
|
+
|
|
18
|
+
function throwOnUse(): never {
|
|
19
|
+
throw new Error(message)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const createSecureStoreStamper = throwOnUse
|
|
23
|
+
export const createReactNativePasskeyStamper = throwOnUse
|
|
24
|
+
export const asyncStorageAdapter = throwOnUse
|
|
25
|
+
|
|
26
|
+
// For the broad `./react-native` entry: any consumer reaching it on web is
|
|
27
|
+
// already off-pattern (they should use the bare specifier). Default export
|
|
28
|
+
// covers `import X from '...'`.
|
|
29
|
+
export default throwOnUse
|
package/src/types/session.ts
CHANGED
|
@@ -3,7 +3,7 @@ export enum SessionType {
|
|
|
3
3
|
READ_WRITE = 'SESSION_TYPE_READ_WRITE',
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export type StamperType = '
|
|
6
|
+
export type StamperType = 'apiKey' | 'passkey'
|
|
7
7
|
|
|
8
8
|
export type ZeroDevWalletSession = {
|
|
9
9
|
id: string
|
|
@@ -11,8 +11,7 @@ export type ZeroDevWalletSession = {
|
|
|
11
11
|
organizationId: string
|
|
12
12
|
stamperType: StamperType
|
|
13
13
|
sessionType?: SessionType
|
|
14
|
-
token
|
|
15
|
-
publicKey?: string
|
|
14
|
+
token: string
|
|
16
15
|
expiry: number
|
|
17
16
|
createdAt: number
|
|
18
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ApiKeyStamper } from '../stampers/types.js'
|
|
2
2
|
import { derToRawSignature } from './derToRawSignature.js'
|
|
3
3
|
|
|
4
4
|
export type BuildClientSignatureParams = {
|
|
@@ -6,8 +6,8 @@ export type BuildClientSignatureParams = {
|
|
|
6
6
|
verificationToken: string
|
|
7
7
|
/** The compressed public key hex */
|
|
8
8
|
publicKey: string
|
|
9
|
-
/** The
|
|
10
|
-
stamper:
|
|
9
|
+
/** The API key stamper for signing */
|
|
10
|
+
stamper: ApiKeyStamper
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|