@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
package/src/adapters/viem.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
bytesToHex,
|
|
3
|
+
concat,
|
|
4
|
+
getTypesForEIP712Domain,
|
|
2
5
|
type Hex,
|
|
3
|
-
|
|
6
|
+
hashTypedData,
|
|
4
7
|
type LocalAccount,
|
|
8
|
+
numberToHex,
|
|
5
9
|
parseSignature,
|
|
6
|
-
parseTransaction,
|
|
7
10
|
type SerializeTransactionFn,
|
|
8
11
|
type SignableMessage,
|
|
9
12
|
serializeTransaction,
|
|
10
13
|
serializeTypedData,
|
|
11
14
|
type TransactionSerializable,
|
|
15
|
+
toRlp,
|
|
12
16
|
zeroAddress,
|
|
13
17
|
} from 'viem'
|
|
14
18
|
import type {
|
|
@@ -17,20 +21,19 @@ import type {
|
|
|
17
21
|
} from 'viem/accounts'
|
|
18
22
|
import { toAccount } from 'viem/accounts'
|
|
19
23
|
import { hashAuthorization } from 'viem/utils'
|
|
20
|
-
import type { signRawPayload } from '../actions/index.js'
|
|
21
24
|
import type { ZeroDevWalletClient } from '../client/index.js'
|
|
22
25
|
|
|
23
26
|
export interface ToViemAccountParams {
|
|
24
27
|
client: ZeroDevWalletClient
|
|
25
28
|
organizationId: string
|
|
26
29
|
projectId: string
|
|
27
|
-
|
|
30
|
+
getToken: () => string | Promise<string>
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
export async function toViemAccount(
|
|
31
34
|
params: ToViemAccountParams,
|
|
32
35
|
): Promise<LocalAccount> {
|
|
33
|
-
const { client, organizationId, projectId,
|
|
36
|
+
const { client, organizationId, projectId, getToken } = params
|
|
34
37
|
|
|
35
38
|
let address: Hex = zeroAddress
|
|
36
39
|
|
|
@@ -38,27 +41,12 @@ export async function toViemAccount(
|
|
|
38
41
|
const walletResponse = await client.getUserWallet({
|
|
39
42
|
organizationId,
|
|
40
43
|
projectId,
|
|
41
|
-
token,
|
|
44
|
+
token: await getToken(),
|
|
42
45
|
})
|
|
43
46
|
address = walletResponse.walletAddresses[0]
|
|
44
47
|
} catch {
|
|
45
48
|
address = zeroAddress
|
|
46
49
|
}
|
|
47
|
-
const signRawPayloadInternal = async (
|
|
48
|
-
payload: string,
|
|
49
|
-
encoding: Parameters<
|
|
50
|
-
typeof signRawPayload
|
|
51
|
-
>[1]['encoding'] = 'PAYLOAD_ENCODING_HEXADECIMAL',
|
|
52
|
-
) => {
|
|
53
|
-
return await client.signRawPayload({
|
|
54
|
-
organizationId,
|
|
55
|
-
projectId,
|
|
56
|
-
token,
|
|
57
|
-
address,
|
|
58
|
-
payload,
|
|
59
|
-
encoding,
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
50
|
|
|
63
51
|
// Modified from: https://github.com/tkhq/sdk/blob/4e439bf2973ea13b51d981d7c24a4841d4e5fd5f/packages/viem/src/index.ts#L419-L461
|
|
64
52
|
const signTransactionInternal = async <
|
|
@@ -79,32 +67,42 @@ export async function toViemAccount(
|
|
|
79
67
|
const signature = await client.signTransaction({
|
|
80
68
|
organizationId,
|
|
81
69
|
projectId,
|
|
82
|
-
token,
|
|
70
|
+
token: await getToken(),
|
|
83
71
|
address,
|
|
84
72
|
unsignedTransaction: nonHexPrefixedSerializedTx,
|
|
85
73
|
})
|
|
86
74
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const { r, s, v } = parseTransaction(signature)
|
|
90
|
-
|
|
91
|
-
// Recombine with the original transaction
|
|
92
|
-
return serializeTransaction(transaction, {
|
|
93
|
-
r: r!,
|
|
94
|
-
s: s!,
|
|
95
|
-
v: v!,
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return signature
|
|
75
|
+
const { r, s, v, yParity } = parseSignature(signature)
|
|
76
|
+
return serializeTransaction(transaction, { r, s, v, yParity })
|
|
100
77
|
}
|
|
101
78
|
|
|
102
79
|
return toAccount({
|
|
103
80
|
address,
|
|
104
81
|
|
|
105
82
|
async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {
|
|
106
|
-
|
|
107
|
-
|
|
83
|
+
if (typeof message === 'string') {
|
|
84
|
+
return client.signMessage({
|
|
85
|
+
organizationId,
|
|
86
|
+
projectId,
|
|
87
|
+
token: await getToken(),
|
|
88
|
+
address,
|
|
89
|
+
message,
|
|
90
|
+
encoding: 'utf8',
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
// Raw message (Hex or ByteArray)
|
|
94
|
+
const raw =
|
|
95
|
+
typeof message.raw === 'string'
|
|
96
|
+
? message.raw.replace(/^0x/, '')
|
|
97
|
+
: bytesToHex(message.raw).slice(2)
|
|
98
|
+
return client.signMessage({
|
|
99
|
+
organizationId,
|
|
100
|
+
projectId,
|
|
101
|
+
token: await getToken(),
|
|
102
|
+
address,
|
|
103
|
+
message: raw,
|
|
104
|
+
encoding: 'hex',
|
|
105
|
+
})
|
|
108
106
|
},
|
|
109
107
|
|
|
110
108
|
signTransaction: async <
|
|
@@ -123,11 +121,28 @@ export async function toViemAccount(
|
|
|
123
121
|
return signTransactionInternal(transaction, serializer)
|
|
124
122
|
},
|
|
125
123
|
signTypedData: async (typedData) => {
|
|
126
|
-
const serializedTypedData = serializeTypedData(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
const serializedTypedData = serializeTypedData({
|
|
125
|
+
...typedData,
|
|
126
|
+
types: {
|
|
127
|
+
...typedData.types,
|
|
128
|
+
EIP712Domain: getTypesForEIP712Domain({
|
|
129
|
+
domain: typedData.domain as Parameters<
|
|
130
|
+
typeof getTypesForEIP712Domain
|
|
131
|
+
>[0]['domain'],
|
|
132
|
+
}),
|
|
133
|
+
},
|
|
134
|
+
} as Parameters<typeof serializeTypedData>[0])
|
|
135
|
+
return client.signTypedDataV4({
|
|
136
|
+
organizationId,
|
|
137
|
+
projectId,
|
|
138
|
+
token: await getToken(),
|
|
139
|
+
address,
|
|
140
|
+
unsignedTypedDataV4: serializedTypedData,
|
|
141
|
+
encoding: 'utf8',
|
|
142
|
+
typedDataHash: hashTypedData(
|
|
143
|
+
typedData as Parameters<typeof hashTypedData>[0],
|
|
144
|
+
).slice(2),
|
|
145
|
+
})
|
|
131
146
|
},
|
|
132
147
|
|
|
133
148
|
async signAuthorization(
|
|
@@ -146,7 +161,24 @@ export async function toViemAccount(
|
|
|
146
161
|
nonce,
|
|
147
162
|
})
|
|
148
163
|
|
|
149
|
-
|
|
164
|
+
// Serialize EIP-7702 authorization: 0x05 || RLP([chainId, address, nonce])
|
|
165
|
+
const unsignedTransaction = concat([
|
|
166
|
+
'0x05',
|
|
167
|
+
toRlp([
|
|
168
|
+
chainId ? numberToHex(chainId) : '0x',
|
|
169
|
+
authAddress,
|
|
170
|
+
nonce ? numberToHex(nonce) : '0x',
|
|
171
|
+
]),
|
|
172
|
+
]).slice(2)
|
|
173
|
+
|
|
174
|
+
const signature = await client.sign7702Authorization({
|
|
175
|
+
organizationId,
|
|
176
|
+
projectId,
|
|
177
|
+
token: await getToken(),
|
|
178
|
+
address,
|
|
179
|
+
unsignedTransaction,
|
|
180
|
+
hashedAuthorization: hashedAuthorization.slice(2),
|
|
181
|
+
})
|
|
150
182
|
|
|
151
183
|
const parsedSignature = parseSignature(signature)
|
|
152
184
|
|
package/src/client/authProxy.ts
CHANGED
|
@@ -10,10 +10,11 @@ export type AuthProxyClientConfig = {
|
|
|
10
10
|
export type AuthProxyVerifyOtpRequest = {
|
|
11
11
|
/** The OTP ID from registration */
|
|
12
12
|
otpId: string
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
/**
|
|
14
|
+
* HPKE-sealed bundle containing `{otp_code, public_key}` encrypted to the
|
|
15
|
+
* enclave's per-session target key. Produced by `encryptOtpAttempt`.
|
|
16
|
+
*/
|
|
17
|
+
encryptedOtpBundle: string
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export type AuthProxyVerifyOtpResponse = {
|
|
@@ -62,15 +63,20 @@ export function createAuthProxyClient(config: AuthProxyClientConfig) {
|
|
|
62
63
|
|
|
63
64
|
return {
|
|
64
65
|
/**
|
|
65
|
-
* Verifies an OTP
|
|
66
|
+
* Verifies an OTP attempt with Turnkey's Auth Proxy.
|
|
66
67
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
68
|
+
* The `encryptedOtpBundle` is HPKE-sealed `{otp_code, public_key}` JSON
|
|
69
|
+
* (see `encryptOtpAttempt`). The auth proxy forwards the ciphertext to
|
|
70
|
+
* the TLS Fetcher enclave, which decrypts it, verifies the OTP code, and
|
|
71
|
+
* returns a `verificationToken` bound to the embedded public key.
|
|
72
|
+
*
|
|
73
|
+
* Pass the returned `verificationToken` to `/auth/login/otp` along with
|
|
74
|
+
* a client signature to complete the login.
|
|
69
75
|
*/
|
|
70
76
|
async verifyOtp(
|
|
71
77
|
params: AuthProxyVerifyOtpRequest,
|
|
72
78
|
): Promise<AuthProxyVerifyOtpResponse> {
|
|
73
|
-
return request<AuthProxyVerifyOtpResponse>('/v1/
|
|
79
|
+
return request<AuthProxyVerifyOtpResponse>('/v1/otp_verify_v2', params)
|
|
74
80
|
},
|
|
75
81
|
}
|
|
76
82
|
}
|
|
@@ -16,8 +16,8 @@ export function createBaseClient<
|
|
|
16
16
|
>(config: ClientConfig): Client<extended> {
|
|
17
17
|
const {
|
|
18
18
|
transport,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
apiKeyStamper,
|
|
20
|
+
passkeyStamper,
|
|
21
21
|
organizationId,
|
|
22
22
|
key = 'zeroDevWallet',
|
|
23
23
|
name = 'ZeroDev Wallet Client',
|
|
@@ -29,8 +29,8 @@ export function createBaseClient<
|
|
|
29
29
|
request,
|
|
30
30
|
value,
|
|
31
31
|
} = transport({
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
apiKeyStamper,
|
|
33
|
+
passkeyStamper,
|
|
34
34
|
})
|
|
35
35
|
const transportInstance = { ...transportConfig, ...value }
|
|
36
36
|
|
|
@@ -39,8 +39,8 @@ export function createBaseClient<
|
|
|
39
39
|
const client = {
|
|
40
40
|
transport: transportInstance,
|
|
41
41
|
request,
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
apiKeyStamper,
|
|
43
|
+
passkeyStamper,
|
|
44
44
|
organizationId,
|
|
45
45
|
key,
|
|
46
46
|
name,
|
|
@@ -10,13 +10,20 @@ import {
|
|
|
10
10
|
type AuthenticateWithOAuthReturnType,
|
|
11
11
|
authenticateWithEmail,
|
|
12
12
|
authenticateWithOAuth,
|
|
13
|
-
type
|
|
14
|
-
type
|
|
13
|
+
type GetAuthenticatorsParameters,
|
|
14
|
+
type GetAuthenticatorsReturnType,
|
|
15
|
+
type GetAuthProxyConfigIdReturnType,
|
|
16
|
+
type GetOAuthLoginUrlParameters,
|
|
17
|
+
type GetOAuthLoginUrlReturnType,
|
|
18
|
+
type GetParentOrgIdReturnType,
|
|
15
19
|
type GetUserWalletParameters,
|
|
16
20
|
type GetUserWalletReturnType,
|
|
17
21
|
type GetWhoamiParameters,
|
|
18
22
|
type GetWhoamiReturnType,
|
|
19
|
-
|
|
23
|
+
getAuthenticators,
|
|
24
|
+
getAuthProxyConfigId,
|
|
25
|
+
getOAuthLoginUrl,
|
|
26
|
+
getParentOrgId,
|
|
20
27
|
getUserWallet,
|
|
21
28
|
getWhoami,
|
|
22
29
|
type LoginWithOTPParameters,
|
|
@@ -28,15 +35,22 @@ import {
|
|
|
28
35
|
type RegisterWithPasskeyReturnType,
|
|
29
36
|
registerWithOTP,
|
|
30
37
|
registerWithPasskey,
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
import {
|
|
38
|
+
type Sign7702AuthorizationParameters,
|
|
39
|
+
type Sign7702AuthorizationReturnType,
|
|
40
|
+
type SignMessageParameters,
|
|
41
|
+
type SignMessageReturnType,
|
|
36
42
|
type SignTransactionParameters,
|
|
37
43
|
type SignTransactionReturnType,
|
|
44
|
+
type SignTypedDataV4Parameters,
|
|
45
|
+
type SignTypedDataV4ReturnType,
|
|
46
|
+
type SignUserOperationParameters,
|
|
47
|
+
type SignUserOperationReturnType,
|
|
48
|
+
sign7702Authorization,
|
|
49
|
+
signMessage,
|
|
38
50
|
signTransaction,
|
|
39
|
-
|
|
51
|
+
signTypedDataV4,
|
|
52
|
+
signUserOperation,
|
|
53
|
+
} from '../../actions/index.js'
|
|
40
54
|
import type { Client } from '../types.js'
|
|
41
55
|
|
|
42
56
|
/**
|
|
@@ -64,11 +78,12 @@ export type ZeroDevWalletActions = {
|
|
|
64
78
|
getWhoami: (params: GetWhoamiParameters) => Promise<GetWhoamiReturnType>
|
|
65
79
|
|
|
66
80
|
/**
|
|
67
|
-
*
|
|
81
|
+
* Fetches all authenticators (oauths, passkeys, emailContacts, apiKeys)
|
|
82
|
+
* for the authenticated user within the given project/sub-organization
|
|
68
83
|
*/
|
|
69
|
-
|
|
70
|
-
params:
|
|
71
|
-
) => Promise<
|
|
84
|
+
getAuthenticators: (
|
|
85
|
+
params: GetAuthenticatorsParameters,
|
|
86
|
+
) => Promise<GetAuthenticatorsReturnType>
|
|
72
87
|
|
|
73
88
|
// Wallet actions
|
|
74
89
|
/**
|
|
@@ -79,11 +94,9 @@ export type ZeroDevWalletActions = {
|
|
|
79
94
|
) => Promise<GetUserWalletReturnType>
|
|
80
95
|
|
|
81
96
|
/**
|
|
82
|
-
* Signs a
|
|
97
|
+
* Signs a message with the user's wallet
|
|
83
98
|
*/
|
|
84
|
-
|
|
85
|
-
params: SignRawPayloadParameters,
|
|
86
|
-
) => Promise<SignRawPayloadReturnType>
|
|
99
|
+
signMessage: (params: SignMessageParameters) => Promise<SignMessageReturnType>
|
|
87
100
|
|
|
88
101
|
/**
|
|
89
102
|
* Signs a transaction with the user's wallet
|
|
@@ -92,6 +105,27 @@ export type ZeroDevWalletActions = {
|
|
|
92
105
|
params: SignTransactionParameters,
|
|
93
106
|
) => Promise<SignTransactionReturnType>
|
|
94
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Signs EIP-712 typed data with the user's wallet
|
|
110
|
+
*/
|
|
111
|
+
signTypedDataV4: (
|
|
112
|
+
params: SignTypedDataV4Parameters,
|
|
113
|
+
) => Promise<SignTypedDataV4ReturnType>
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Signs a user operation with the user's wallet
|
|
117
|
+
*/
|
|
118
|
+
signUserOperation: (
|
|
119
|
+
params: SignUserOperationParameters,
|
|
120
|
+
) => Promise<SignUserOperationReturnType>
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Signs an EIP-7702 authorization with the user's wallet
|
|
124
|
+
*/
|
|
125
|
+
sign7702Authorization: (
|
|
126
|
+
params: Sign7702AuthorizationParameters,
|
|
127
|
+
) => Promise<Sign7702AuthorizationReturnType>
|
|
128
|
+
|
|
95
129
|
/**
|
|
96
130
|
* Registers a passkey with the user's wallet
|
|
97
131
|
*/
|
|
@@ -119,6 +153,25 @@ export type ZeroDevWalletActions = {
|
|
|
119
153
|
loginWithOTP: (
|
|
120
154
|
params: LoginWithOTPParameters,
|
|
121
155
|
) => Promise<LoginWithOTPReturnType>
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Gets the auth proxy config ID from the backend
|
|
159
|
+
*/
|
|
160
|
+
getAuthProxyConfigId: () => Promise<GetAuthProxyConfigIdReturnType>
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Gets the Turnkey parent (base) organization ID from the backend
|
|
164
|
+
*/
|
|
165
|
+
getParentOrgId: () => Promise<GetParentOrgIdReturnType>
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Fetches the Google OAuth authorization URL from the backend.
|
|
169
|
+
* The caller must verify the URL's `nonce` against `sha256(utf8(publicKey))`
|
|
170
|
+
* before opening it (audit finding TOB-KMS-1).
|
|
171
|
+
*/
|
|
172
|
+
getOAuthLoginUrl: (
|
|
173
|
+
params: GetOAuthLoginUrlParameters,
|
|
174
|
+
) => Promise<GetOAuthLoginUrlReturnType>
|
|
122
175
|
}
|
|
123
176
|
|
|
124
177
|
/**
|
|
@@ -149,15 +202,21 @@ export function zeroDevWalletActions(client: Client): ZeroDevWalletActions {
|
|
|
149
202
|
authenticateWithEmail: (params) => authenticateWithEmail(client, params),
|
|
150
203
|
authenticateWithOAuth: (params) => authenticateWithOAuth(client, params),
|
|
151
204
|
getWhoami: (params) => getWhoami(client, params),
|
|
152
|
-
|
|
205
|
+
getAuthenticators: (params) => getAuthenticators(client, params),
|
|
153
206
|
|
|
154
207
|
// Wallet actions
|
|
155
208
|
getUserWallet: (params) => getUserWallet(client, params),
|
|
156
|
-
|
|
209
|
+
signMessage: (params) => signMessage(client, params),
|
|
157
210
|
signTransaction: (params) => signTransaction(client, params),
|
|
211
|
+
signTypedDataV4: (params) => signTypedDataV4(client, params),
|
|
212
|
+
signUserOperation: (params) => signUserOperation(client, params),
|
|
213
|
+
sign7702Authorization: (params) => sign7702Authorization(client, params),
|
|
158
214
|
registerWithPasskey: (params) => registerWithPasskey(client, params),
|
|
159
215
|
loginWithStamp: (params) => loginWithStamp(client, params),
|
|
160
216
|
registerWithOTP: (params) => registerWithOTP(client, params),
|
|
161
217
|
loginWithOTP: (params) => loginWithOTP(client, params),
|
|
218
|
+
getAuthProxyConfigId: () => getAuthProxyConfigId(client),
|
|
219
|
+
getParentOrgId: () => getParentOrgId(client),
|
|
220
|
+
getOAuthLoginUrl: (params) => getOAuthLoginUrl(client, params),
|
|
162
221
|
}
|
|
163
222
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -10,7 +10,10 @@ export {
|
|
|
10
10
|
createClient,
|
|
11
11
|
type ZeroDevWalletClient,
|
|
12
12
|
} from './createClient.js'
|
|
13
|
-
export {
|
|
13
|
+
export {
|
|
14
|
+
type CreateTransportOptions,
|
|
15
|
+
zeroDevWalletTransport,
|
|
16
|
+
} from './transports/createTransport.js'
|
|
14
17
|
export type {
|
|
15
18
|
Client,
|
|
16
19
|
ClientConfig,
|
|
@@ -10,6 +10,8 @@ export type CreateTransportOptions = {
|
|
|
10
10
|
key?: string
|
|
11
11
|
/** Transport name */
|
|
12
12
|
name?: string
|
|
13
|
+
/** Extra options merged into every fetch() call */
|
|
14
|
+
fetchOptions?: Omit<RequestInit, 'body' | 'method' | 'signal'>
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -26,14 +28,15 @@ export function zeroDevWalletTransport(
|
|
|
26
28
|
name = 'ZeroDev Wallet Transport',
|
|
27
29
|
} = options
|
|
28
30
|
|
|
29
|
-
return ({
|
|
31
|
+
return ({ apiKeyStamper, passkeyStamper }) => {
|
|
30
32
|
// Create REST transport with stamper
|
|
31
33
|
const transport = rest(baseUrl, {
|
|
32
34
|
timeoutMs,
|
|
33
35
|
key,
|
|
34
36
|
name,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
apiKeyStamper,
|
|
38
|
+
passkeyStamper,
|
|
39
|
+
...(options.fetchOptions && { fetchOptions: options.fetchOptions }),
|
|
37
40
|
})
|
|
38
41
|
|
|
39
42
|
return {
|
|
@@ -46,8 +49,8 @@ export function zeroDevWalletTransport(
|
|
|
46
49
|
},
|
|
47
50
|
request: transport.request,
|
|
48
51
|
value: {
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
apiKeyStamper,
|
|
53
|
+
passkeyStamper,
|
|
51
54
|
},
|
|
52
55
|
}
|
|
53
56
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalizeEx } from 'json-canonicalize'
|
|
2
2
|
import { RestRequestError, RestTimeoutError } from '../../errors/request.js'
|
|
3
|
-
import type {
|
|
3
|
+
import type { ApiKeyStamper, PasskeyStamper } from '../../stampers/types.js'
|
|
4
|
+
import type { StamperType } from '../../types/session.js'
|
|
4
5
|
|
|
5
6
|
export type RestRequestArgs = {
|
|
6
7
|
path: string
|
|
@@ -8,8 +9,15 @@ export type RestRequestArgs = {
|
|
|
8
9
|
body?: any
|
|
9
10
|
headers?: Record<string, string>
|
|
10
11
|
stamp?: boolean
|
|
11
|
-
stampWith?:
|
|
12
|
-
|
|
12
|
+
stampWith?: StamperType
|
|
13
|
+
/**
|
|
14
|
+
* Where the stamp goes / what it signs:
|
|
15
|
+
* - `body`/`headers`: sign the canonicalized request body (POST endpoints).
|
|
16
|
+
* - `timestamp`: GET endpoints behind StampCheckUser — sign the current
|
|
17
|
+
* unix-millis string, send it as the `X-Timestamp` header plus the stamp
|
|
18
|
+
* header. No request body. Matches the backend's `FormatTimestamp`.
|
|
19
|
+
*/
|
|
20
|
+
stampPostion?: 'body' | 'headers' | 'timestamp'
|
|
13
21
|
/** Include credentials (cookies) in the request */
|
|
14
22
|
credentials?: RequestCredentials
|
|
15
23
|
}
|
|
@@ -32,8 +40,8 @@ export type RestTransportConfig = {
|
|
|
32
40
|
timeoutMs?: number
|
|
33
41
|
key?: string
|
|
34
42
|
name?: string
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
apiKeyStamper: ApiKeyStamper
|
|
44
|
+
passkeyStamper: PasskeyStamper
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
export function rest(url: string, cfg: RestTransportConfig): RestTransport {
|
|
@@ -48,48 +56,63 @@ export function rest(url: string, cfg: RestTransportConfig): RestTransport {
|
|
|
48
56
|
|
|
49
57
|
try {
|
|
50
58
|
let requestBody = args.body
|
|
51
|
-
let requestHeaders = {
|
|
52
|
-
|
|
59
|
+
let requestHeaders: Record<string, string> = {
|
|
60
|
+
...((cfg.fetchOptions?.headers as Record<string, string>) ?? {}),
|
|
53
61
|
...(args.headers ?? {}),
|
|
54
|
-
|
|
62
|
+
'content-type': 'application/json',
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
// Handle stamping if requested
|
|
58
66
|
if (args.stamp) {
|
|
59
|
-
let stamper:
|
|
60
|
-
if (args.stampWith === '
|
|
61
|
-
stamper = cfg.
|
|
62
|
-
} else if (args.stampWith === '
|
|
63
|
-
stamper = cfg.
|
|
67
|
+
let stamper: ApiKeyStamper | PasskeyStamper
|
|
68
|
+
if (args.stampWith === 'apiKey') {
|
|
69
|
+
stamper = cfg.apiKeyStamper
|
|
70
|
+
} else if (args.stampWith === 'passkey') {
|
|
71
|
+
stamper = cfg.passkeyStamper
|
|
64
72
|
} else {
|
|
65
|
-
stamper = cfg.
|
|
73
|
+
stamper = cfg.apiKeyStamper
|
|
66
74
|
}
|
|
67
|
-
const { body, apiUrl } = args.body
|
|
68
|
-
const bodyString = canonicalizeEx(body ?? args.body)
|
|
69
|
-
const stamp = await stamper.stamp(bodyString)
|
|
70
75
|
|
|
71
|
-
//
|
|
72
|
-
|
|
76
|
+
// Timestamped stamp for GET endpoints behind StampCheckUser: the
|
|
77
|
+
// signed body is the unix-millis string itself (the backend rebuilds
|
|
78
|
+
// it from the X-Timestamp header via FormatTimestamp). No request body.
|
|
79
|
+
if (args.stampPostion === 'timestamp') {
|
|
80
|
+
const ts = Date.now().toString()
|
|
81
|
+
const stamp = await stamper.stamp(ts)
|
|
73
82
|
requestHeaders = {
|
|
74
83
|
...requestHeaders,
|
|
84
|
+
'X-Timestamp': ts,
|
|
75
85
|
[stamp.stampHeaderName]: stamp.stampHeaderValue,
|
|
76
86
|
}
|
|
77
|
-
|
|
78
|
-
requestBody = {
|
|
79
|
-
body: bodyString,
|
|
80
|
-
stamp: {
|
|
81
|
-
stampHeaderName: stamp.stampHeaderName,
|
|
82
|
-
stampHeaderValue: stamp.stampHeaderValue,
|
|
83
|
-
},
|
|
84
|
-
apiUrl: apiUrl,
|
|
85
|
-
}
|
|
87
|
+
requestBody = undefined
|
|
86
88
|
} else {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
const { body, apiUrl } = args.body
|
|
90
|
+
const bodyString = canonicalizeEx(body ?? args.body)
|
|
91
|
+
const stamp = await stamper.stamp(bodyString)
|
|
92
|
+
|
|
93
|
+
// Restructure request body to match backend expectation
|
|
94
|
+
if (args.stampPostion === 'headers') {
|
|
95
|
+
requestHeaders = {
|
|
96
|
+
...requestHeaders,
|
|
97
|
+
[stamp.stampHeaderName]: stamp.stampHeaderValue,
|
|
98
|
+
}
|
|
99
|
+
} else if (body) {
|
|
100
|
+
requestBody = {
|
|
101
|
+
body: bodyString,
|
|
102
|
+
stamp: {
|
|
103
|
+
stampHeaderName: stamp.stampHeaderName,
|
|
104
|
+
stampHeaderValue: stamp.stampHeaderValue,
|
|
105
|
+
},
|
|
106
|
+
apiUrl: apiUrl,
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
requestBody = {
|
|
110
|
+
...args.body,
|
|
111
|
+
stamp: {
|
|
112
|
+
stampHeaderName: stamp.stampHeaderName,
|
|
113
|
+
stampHeaderValue: stamp.stampHeaderValue,
|
|
114
|
+
},
|
|
115
|
+
}
|
|
93
116
|
}
|
|
94
117
|
}
|
|
95
118
|
}
|
package/src/client/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ApiKeyStamper, PasskeyStamper } from '../stampers/types.js'
|
|
2
2
|
import type { RestRequestFn } from './transports/rest.js'
|
|
3
3
|
|
|
4
4
|
export type TransportConfig = {
|
|
@@ -17,8 +17,8 @@ export type TransportConfig = {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export type Transport = (options: {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
apiKeyStamper: ApiKeyStamper
|
|
21
|
+
passkeyStamper: PasskeyStamper
|
|
22
22
|
}) => {
|
|
23
23
|
config: TransportConfig
|
|
24
24
|
request: RestRequestFn
|
|
@@ -27,8 +27,8 @@ export type Transport = (options: {
|
|
|
27
27
|
|
|
28
28
|
export type ClientConfig = {
|
|
29
29
|
transport: Transport
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
apiKeyStamper: ApiKeyStamper
|
|
31
|
+
passkeyStamper: PasskeyStamper
|
|
32
32
|
organizationId?: string
|
|
33
33
|
key?: string
|
|
34
34
|
name?: string
|
|
@@ -39,10 +39,10 @@ export type Client<extended extends Extended | undefined = undefined> = {
|
|
|
39
39
|
transport: TransportConfig & Record<string, unknown>
|
|
40
40
|
/** Request function from transport */
|
|
41
41
|
request: RestRequestFn
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
|
|
42
|
+
/** API Key Stamper for authenticated requests */
|
|
43
|
+
apiKeyStamper: ApiKeyStamper
|
|
44
|
+
/** Passkey Stamper for authenticated requests */
|
|
45
|
+
passkeyStamper: PasskeyStamper
|
|
46
46
|
/** Organization ID */
|
|
47
47
|
organizationId?: string
|
|
48
48
|
/** A key for the client */
|
package/src/constants.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
export const DEFAULT_SESSION_EXPIRATION_IN_SECONDS = '900' // default to 15 minutes
|
|
2
2
|
export const DEFAULT_IFRAME_CONTAINER_ID = 'turnkey-auth-iframe-container-id'
|
|
3
3
|
export const DEFAULT_IFRAME_ELEMENT_ID = 'turnkey-default-iframe-element-id'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const KMS_SERVER_URL = 'https://kms.
|
|
4
|
+
// Prod parent organization id. Only a fallback — the SDK resolves the parent
|
|
5
|
+
// org at runtime from the KMS `server-info/parent-org-id` endpoint.
|
|
6
|
+
export const DEFAULT_ORGANIZATION_ID = '65028f18-01c6-4ed4-beff-2ed1be5d6bad'
|
|
7
|
+
export const KMS_SERVER_URL = 'https://kms.zerodev.app'
|
|
8
|
+
|
|
9
|
+
// Pinned ECDSA P-256 public key (uncompressed, 65 bytes hex) of Turnkey's
|
|
10
|
+
// TLS Fetcher Sign enclave. Used to verify the signature on the OTP encryption
|
|
11
|
+
// target bundle returned by /auth/init/otp before HPKE-encrypting the OTP
|
|
12
|
+
// attempt. The bundle's `dataSignature` is verified against this key, so a
|
|
13
|
+
// compromised proxy cannot substitute its own ephemeral key.
|
|
14
|
+
export const TURNKEY_TLS_FETCHER_SIGN_PUBLIC_KEY =
|
|
15
|
+
'046b4f88421f76b6ba418afc2ea1d8ced671337d7db6b80478a60d8531bf8f17fa9a512f0fef96fc0c9b4cd9dff70b34992e520ce04c79d931f6ff6296b547d201'
|