@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/package.json
CHANGED
|
@@ -1,15 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodev/wallet-core",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "ZeroDev Wallet SDK built on Turnkey",
|
|
5
|
+
"sideEffects": false,
|
|
5
6
|
"main": "./dist/_cjs/index.js",
|
|
6
7
|
"module": "./dist/_esm/index.js",
|
|
7
8
|
"types": "./dist/_types/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
"react-native": {
|
|
12
|
+
"types": "./dist/_types/index.native.d.ts",
|
|
13
|
+
"default": "./dist/_esm/index.native.js"
|
|
14
|
+
},
|
|
15
|
+
"browser": {
|
|
16
|
+
"types": "./dist/_types/index.d.ts",
|
|
17
|
+
"default": "./dist/_esm/index.js"
|
|
18
|
+
},
|
|
19
|
+
"import": {
|
|
20
|
+
"types": "./dist/_types/index.d.ts",
|
|
21
|
+
"default": "./dist/_esm/index.js"
|
|
22
|
+
},
|
|
23
|
+
"require": {
|
|
24
|
+
"types": "./dist/_types/index.d.ts",
|
|
25
|
+
"default": "./dist/_cjs/index.js"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"types": "./dist/_types/index.d.ts",
|
|
29
|
+
"default": "./dist/_esm/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"./react-native": {
|
|
33
|
+
"browser": "./dist/_esm/stubs/native-on-web.js",
|
|
34
|
+
"node": "./dist/_esm/stubs/native-on-web.js",
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/_types/index.native.d.ts",
|
|
37
|
+
"default": "./dist/_esm/index.native.js"
|
|
38
|
+
},
|
|
39
|
+
"default": "./dist/_esm/index.native.js"
|
|
40
|
+
},
|
|
41
|
+
"./react-native/stampers/secure-store": {
|
|
42
|
+
"browser": "./dist/_esm/stubs/native-on-web.js",
|
|
43
|
+
"node": "./dist/_esm/stubs/native-on-web.js",
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/_types/native/stampers/secureStore.d.ts",
|
|
46
|
+
"default": "./dist/_esm/native/stampers/secureStore.js"
|
|
47
|
+
},
|
|
48
|
+
"default": "./dist/_esm/native/stampers/secureStore.js"
|
|
49
|
+
},
|
|
50
|
+
"./react-native/stampers/passkey": {
|
|
51
|
+
"browser": "./dist/_esm/stubs/native-on-web.js",
|
|
52
|
+
"node": "./dist/_esm/stubs/native-on-web.js",
|
|
53
|
+
"import": {
|
|
54
|
+
"types": "./dist/_types/native/stampers/passkey.d.ts",
|
|
55
|
+
"default": "./dist/_esm/native/stampers/passkey.js"
|
|
56
|
+
},
|
|
57
|
+
"default": "./dist/_esm/native/stampers/passkey.js"
|
|
58
|
+
},
|
|
59
|
+
"./react-native/storage/async-storage": {
|
|
60
|
+
"browser": "./dist/_esm/stubs/native-on-web.js",
|
|
61
|
+
"node": "./dist/_esm/stubs/native-on-web.js",
|
|
62
|
+
"import": {
|
|
63
|
+
"types": "./dist/_types/native/storage/asyncStorage.d.ts",
|
|
64
|
+
"default": "./dist/_esm/native/storage/asyncStorage.js"
|
|
65
|
+
},
|
|
66
|
+
"default": "./dist/_esm/native/storage/asyncStorage.js"
|
|
13
67
|
},
|
|
14
68
|
"./viem": {
|
|
15
69
|
"types": "./dist/_types/adapters/viem.d.ts",
|
|
@@ -20,11 +74,6 @@
|
|
|
20
74
|
"types": "./dist/_types/actions/index.d.ts",
|
|
21
75
|
"import": "./dist/_esm/actions/index.js",
|
|
22
76
|
"require": "./dist/_cjs/actions/index.js"
|
|
23
|
-
},
|
|
24
|
-
"./stampers": {
|
|
25
|
-
"types": "./dist/_types/stampers/index.d.ts",
|
|
26
|
-
"import": "./dist/_esm/stampers/index.js",
|
|
27
|
-
"require": "./dist/_cjs/stampers/index.js"
|
|
28
77
|
}
|
|
29
78
|
},
|
|
30
79
|
"files": [
|
|
@@ -49,6 +98,9 @@
|
|
|
49
98
|
],
|
|
50
99
|
"license": "MIT",
|
|
51
100
|
"dependencies": {
|
|
101
|
+
"@noble/ciphers": "^2.2.0",
|
|
102
|
+
"@noble/curves": "^2.2.0",
|
|
103
|
+
"@noble/hashes": "^2.2.0",
|
|
52
104
|
"@turnkey/http": "^3.12.1",
|
|
53
105
|
"@turnkey/iframe-stamper": "^2.5.0",
|
|
54
106
|
"@turnkey/indexed-db-stamper": "^1.1.1",
|
|
@@ -56,11 +108,48 @@
|
|
|
56
108
|
"json-canonicalize": "^2.0.0"
|
|
57
109
|
},
|
|
58
110
|
"peerDependencies": {
|
|
59
|
-
"viem": "^2.38.0"
|
|
111
|
+
"viem": "^2.38.0",
|
|
112
|
+
"@react-native-async-storage/async-storage": ">=2.0.0",
|
|
113
|
+
"@turnkey/api-key-stamper": ">=0.6.0",
|
|
114
|
+
"@turnkey/crypto": ">=2.8.0",
|
|
115
|
+
"@turnkey/react-native-passkey-stamper": ">=1.2.0",
|
|
116
|
+
"expo-secure-store": ">=14.0.0",
|
|
117
|
+
"react-native": ">=0.73.0",
|
|
118
|
+
"uuid": ">=11.0.0"
|
|
119
|
+
},
|
|
120
|
+
"peerDependenciesMeta": {
|
|
121
|
+
"@react-native-async-storage/async-storage": {
|
|
122
|
+
"optional": true
|
|
123
|
+
},
|
|
124
|
+
"@turnkey/api-key-stamper": {
|
|
125
|
+
"optional": true
|
|
126
|
+
},
|
|
127
|
+
"@turnkey/crypto": {
|
|
128
|
+
"optional": true
|
|
129
|
+
},
|
|
130
|
+
"@turnkey/react-native-passkey-stamper": {
|
|
131
|
+
"optional": true
|
|
132
|
+
},
|
|
133
|
+
"expo-secure-store": {
|
|
134
|
+
"optional": true
|
|
135
|
+
},
|
|
136
|
+
"react-native": {
|
|
137
|
+
"optional": true
|
|
138
|
+
},
|
|
139
|
+
"uuid": {
|
|
140
|
+
"optional": true
|
|
141
|
+
}
|
|
60
142
|
},
|
|
61
143
|
"devDependencies": {
|
|
144
|
+
"@hpke/core": "^1.9.0",
|
|
145
|
+
"@react-native-async-storage/async-storage": "2.2.0",
|
|
146
|
+
"@turnkey/api-key-stamper": "0.6.4",
|
|
147
|
+
"@turnkey/crypto": "2.8.13",
|
|
148
|
+
"@turnkey/react-native-passkey-stamper": "1.2.12",
|
|
62
149
|
"@types/node": "^20.0.0",
|
|
63
|
-
"
|
|
150
|
+
"expo-secure-store": "55.0.9",
|
|
151
|
+
"typescript": "5.9.3",
|
|
152
|
+
"uuid": "^13.0.0"
|
|
64
153
|
},
|
|
65
154
|
"scripts": {
|
|
66
155
|
"build": "pnpm run clean && pnpm run build:cjs && pnpm run build:esm && pnpm run build:types",
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Client } from '../../client/types.js'
|
|
2
2
|
|
|
3
|
-
export type EmailCustomization = {
|
|
4
|
-
/** A template for the URL to be used in a magic link button, e.g. `https://dapp.xyz/%s`. The auth bundle will be interpolated into the `%s`. */
|
|
5
|
-
magicLinkTemplate?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
3
|
export type AuthenticateWithEmailParameters = {
|
|
9
4
|
/** The email address to authenticate */
|
|
10
5
|
email: string
|
|
@@ -12,8 +7,6 @@ export type AuthenticateWithEmailParameters = {
|
|
|
12
7
|
projectId: string
|
|
13
8
|
/** Target public key for authentication */
|
|
14
9
|
targetPublicKey: string
|
|
15
|
-
/** Optional email customization settings */
|
|
16
|
-
emailCustomization?: EmailCustomization
|
|
17
10
|
}
|
|
18
11
|
|
|
19
12
|
export type AuthenticateWithEmailReturnType = {
|
|
@@ -37,14 +30,13 @@ export async function authenticateWithEmail(
|
|
|
37
30
|
client: Client,
|
|
38
31
|
params: AuthenticateWithEmailParameters,
|
|
39
32
|
): Promise<AuthenticateWithEmailReturnType> {
|
|
40
|
-
const { email, projectId, targetPublicKey
|
|
33
|
+
const { email, projectId, targetPublicKey } = params
|
|
41
34
|
|
|
42
35
|
return await client.request({
|
|
43
36
|
path: `${projectId}/auth/email-magic`,
|
|
44
37
|
method: 'POST',
|
|
45
38
|
body: {
|
|
46
39
|
email,
|
|
47
|
-
emailCustomization,
|
|
48
40
|
targetPublicKey,
|
|
49
41
|
projectId,
|
|
50
42
|
},
|
|
@@ -5,6 +5,10 @@ export type AuthenticateWithOAuthParameters = {
|
|
|
5
5
|
provider: string
|
|
6
6
|
/** The project ID for the request */
|
|
7
7
|
projectId: string
|
|
8
|
+
/** The session ID from the OAuth callback URL */
|
|
9
|
+
sessionId: string
|
|
10
|
+
/** Proof-of-possession signature for `sessionId`. */
|
|
11
|
+
popSignature: string
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
export type AuthenticateWithOAuthReturnType = {
|
|
@@ -19,11 +23,11 @@ export type AuthenticateWithOAuthReturnType = {
|
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
|
-
* Authenticates a user with OAuth using
|
|
26
|
+
* Authenticates a user with OAuth using a server-side session ID
|
|
23
27
|
*
|
|
24
|
-
* The backend
|
|
25
|
-
*
|
|
26
|
-
*
|
|
28
|
+
* The backend stores the OAuth session server-side and returns a session ID
|
|
29
|
+
* via the callback URL. The SDK extracts this session ID and sends it in
|
|
30
|
+
* the request body.
|
|
27
31
|
*
|
|
28
32
|
* @param client - The ZeroDev Wallet client
|
|
29
33
|
* @param params - The parameters for OAuth authentication
|
|
@@ -34,6 +38,8 @@ export type AuthenticateWithOAuthReturnType = {
|
|
|
34
38
|
* const result = await authenticateWithOAuth(client, {
|
|
35
39
|
* provider: 'google',
|
|
36
40
|
* projectId: 'proj_456',
|
|
41
|
+
* sessionId: 'abc123',
|
|
42
|
+
* popSignature: '3045022100...',
|
|
37
43
|
* });
|
|
38
44
|
* ```
|
|
39
45
|
*/
|
|
@@ -41,12 +47,11 @@ export async function authenticateWithOAuth(
|
|
|
41
47
|
client: Client,
|
|
42
48
|
params: AuthenticateWithOAuthParameters,
|
|
43
49
|
): Promise<AuthenticateWithOAuthReturnType> {
|
|
44
|
-
const { projectId } = params
|
|
50
|
+
const { projectId, sessionId, popSignature } = params
|
|
45
51
|
|
|
46
52
|
return await client.request({
|
|
47
53
|
path: `${projectId}/auth/oauth`,
|
|
48
54
|
method: 'POST',
|
|
49
|
-
body:
|
|
50
|
-
credentials: 'include',
|
|
55
|
+
body: { sessionId, popSignature },
|
|
51
56
|
})
|
|
52
57
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Client } from '../../client/types.js'
|
|
2
|
+
|
|
3
|
+
export type GetAuthProxyConfigIdReturnType = {
|
|
4
|
+
authProxyConfigId: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Fetches the auth proxy config ID from the backend
|
|
9
|
+
*
|
|
10
|
+
* @param client - The ZeroDev Wallet client
|
|
11
|
+
* @returns The auth proxy config ID
|
|
12
|
+
*/
|
|
13
|
+
export async function getAuthProxyConfigId(
|
|
14
|
+
client: Client,
|
|
15
|
+
): Promise<GetAuthProxyConfigIdReturnType> {
|
|
16
|
+
return await client.request({
|
|
17
|
+
path: 'server-info/auth-proxy-id',
|
|
18
|
+
method: 'GET',
|
|
19
|
+
})
|
|
20
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Client } from '../../client/types.js'
|
|
2
|
+
|
|
3
|
+
export type GetAuthenticatorsParameters = {
|
|
4
|
+
/** The sub-organization ID to query authenticators for */
|
|
5
|
+
subOrganizationId: string
|
|
6
|
+
/** The project ID for the request */
|
|
7
|
+
projectId: string
|
|
8
|
+
/** The session token for authorization */
|
|
9
|
+
token: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** An OAuth authenticator linked to the user */
|
|
13
|
+
export type OAuthAuthenticator = {
|
|
14
|
+
provider?: string
|
|
15
|
+
clientId?: string
|
|
16
|
+
subject?: string
|
|
17
|
+
[key: string]: unknown
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** A passkey (WebAuthn) authenticator */
|
|
21
|
+
export type PasskeyAuthenticator = {
|
|
22
|
+
rpId?: string
|
|
23
|
+
publicKey?: string
|
|
24
|
+
credentialId?: string
|
|
25
|
+
[key: string]: unknown
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** An email contact linked to the user */
|
|
29
|
+
export type EmailContact = {
|
|
30
|
+
email?: string
|
|
31
|
+
[key: string]: unknown
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** An API key authenticator */
|
|
35
|
+
export type ApiKeyAuthenticator = {
|
|
36
|
+
apiKey?: string
|
|
37
|
+
[key: string]: unknown
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type GetAuthenticatorsReturnType = {
|
|
41
|
+
/** OAuth providers linked to the user (null if none) */
|
|
42
|
+
oauths: OAuthAuthenticator[] | null
|
|
43
|
+
/** Passkey authenticators registered for the user (null if none) */
|
|
44
|
+
passkeys: PasskeyAuthenticator[] | null
|
|
45
|
+
/** Email contacts associated with the user (null if none) */
|
|
46
|
+
emailContacts: EmailContact[] | null
|
|
47
|
+
/** API keys associated with the user (null if none) */
|
|
48
|
+
apiKeys: ApiKeyAuthenticator[] | null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Fetches all authenticators (oauths, passkeys, emailContacts, apiKeys) for
|
|
53
|
+
* the authenticated user within the given project/sub-organization.
|
|
54
|
+
*
|
|
55
|
+
* Corresponds to `POST /api/v1/{projectId}/authenticators`.
|
|
56
|
+
*
|
|
57
|
+
* @param client - The ZeroDev Wallet client
|
|
58
|
+
* @param params - The parameters for the authenticators request
|
|
59
|
+
* @returns The user's authenticators grouped by type
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const authenticators = await getAuthenticators(client, {
|
|
64
|
+
* subOrganizationId: 'suborg_123',
|
|
65
|
+
* projectId: 'proj_456',
|
|
66
|
+
* token: 'session_token_abc',
|
|
67
|
+
* });
|
|
68
|
+
* console.log(authenticators.oauths, authenticators.passkeys);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export async function getAuthenticators(
|
|
72
|
+
client: Client,
|
|
73
|
+
params: GetAuthenticatorsParameters,
|
|
74
|
+
): Promise<GetAuthenticatorsReturnType> {
|
|
75
|
+
const { projectId, token } = params
|
|
76
|
+
|
|
77
|
+
// GET behind StampCheckUser: the backend resolves the user from the stamped
|
|
78
|
+
// credential (+ session JWT), so no body / sub-org is sent. The stamp signs
|
|
79
|
+
// the X-Timestamp value (see transport `stampPostion: 'timestamp'`).
|
|
80
|
+
return await client.request({
|
|
81
|
+
path: `${projectId}/authenticators`,
|
|
82
|
+
method: 'GET',
|
|
83
|
+
headers: {
|
|
84
|
+
Authorization: `Bearer ${token}`,
|
|
85
|
+
},
|
|
86
|
+
stamp: true,
|
|
87
|
+
stampPostion: 'timestamp',
|
|
88
|
+
})
|
|
89
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Client } from '../../client/types.js'
|
|
2
|
+
|
|
3
|
+
export type GetOAuthLoginUrlParameters = {
|
|
4
|
+
/** OAuth provider — currently only `'google'` is supported. */
|
|
5
|
+
provider: 'google'
|
|
6
|
+
/** The project ID for the request. */
|
|
7
|
+
projectId: string
|
|
8
|
+
/**
|
|
9
|
+
* The session public key (compressed P-256 hex, lowercase, with or
|
|
10
|
+
* without `0x` prefix). The backend embeds `sha256(utf8(hex))` as the
|
|
11
|
+
* OIDC `nonce` so the SDK can verify the URL was minted for this key.
|
|
12
|
+
*/
|
|
13
|
+
publicKey: string
|
|
14
|
+
/**
|
|
15
|
+
* Where the popup should land after the OAuth round-trip
|
|
16
|
+
* (e.g. `https://app.example.com/dashboard?oauth_success=true`).
|
|
17
|
+
* Must be on the project's whitelist.
|
|
18
|
+
*/
|
|
19
|
+
returnTo: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type GetOAuthLoginUrlReturnType = string
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Fetches the Google OAuth authorization URL from the backend.
|
|
26
|
+
*
|
|
27
|
+
* The SDK must verify the returned URL's `nonce` against
|
|
28
|
+
* `sha256(utf8(publicKey))` (and the host is `accounts.google.com`)
|
|
29
|
+
* before opening it in a popup — the backend is not a trusted party.
|
|
30
|
+
* See audit finding TOB-KMS-1.
|
|
31
|
+
*/
|
|
32
|
+
export async function getOAuthLoginUrl(
|
|
33
|
+
client: Client,
|
|
34
|
+
params: GetOAuthLoginUrlParameters,
|
|
35
|
+
): Promise<GetOAuthLoginUrlReturnType> {
|
|
36
|
+
if (params.provider !== 'google') {
|
|
37
|
+
throw new Error(`Unsupported OAuth provider: ${params.provider}`)
|
|
38
|
+
}
|
|
39
|
+
const query = new URLSearchParams({
|
|
40
|
+
project_id: params.projectId,
|
|
41
|
+
pub_key: params.publicKey.replace(/^0x/, '').toLowerCase(),
|
|
42
|
+
return_to: params.returnTo,
|
|
43
|
+
})
|
|
44
|
+
return await client.request<string>({
|
|
45
|
+
path: `oauth/google/login-url?${query.toString()}`,
|
|
46
|
+
method: 'GET',
|
|
47
|
+
})
|
|
48
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Client } from '../../client/types.js'
|
|
2
|
+
|
|
3
|
+
export type GetParentOrgIdReturnType = {
|
|
4
|
+
/** The Turnkey parent (base) organization ID configured on the backend. */
|
|
5
|
+
parentOrgId: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Fetches the Turnkey parent (base) organization ID from the backend.
|
|
10
|
+
*
|
|
11
|
+
* Stamp-login payloads must be signed against this org — the backend relays the
|
|
12
|
+
* stamp under the parent org and derives the sub-org from the credential. The
|
|
13
|
+
* SDK fetches it (rather than hardcoding) so it works across environments
|
|
14
|
+
* (prod/staging/local) without a per-env override.
|
|
15
|
+
*
|
|
16
|
+
* Corresponds to `GET /api/v1/server-info/parent-org-id`.
|
|
17
|
+
*/
|
|
18
|
+
export async function getParentOrgId(
|
|
19
|
+
client: Client,
|
|
20
|
+
): Promise<GetParentOrgIdReturnType> {
|
|
21
|
+
return await client.request({
|
|
22
|
+
path: 'server-info/parent-org-id',
|
|
23
|
+
method: 'GET',
|
|
24
|
+
})
|
|
25
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { canonicalizeEx } from 'json-canonicalize'
|
|
1
2
|
import type { Client } from '../../client/types.js'
|
|
2
3
|
|
|
3
4
|
export type GetWhoamiParameters = {
|
|
@@ -5,6 +6,8 @@ export type GetWhoamiParameters = {
|
|
|
5
6
|
organizationId: string
|
|
6
7
|
/** The project ID for the request */
|
|
7
8
|
projectId: string
|
|
9
|
+
/** The session token for authorization (required for session-based auth) */
|
|
10
|
+
token?: string
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export type GetWhoamiReturnType = {
|
|
@@ -19,7 +22,11 @@ export type GetWhoamiReturnType = {
|
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
|
-
* Gets the current user information
|
|
25
|
+
* Gets the current user information.
|
|
26
|
+
*
|
|
27
|
+
* The whoami endpoint requires two stamps:
|
|
28
|
+
* 1. An inner stamp over the payload (for Turnkey verification) embedded in the body
|
|
29
|
+
* 2. An outer stamp over the full body (for KMS middleware) in the X-Stamp header
|
|
23
30
|
*
|
|
24
31
|
* @param client - The ZeroDev Wallet client
|
|
25
32
|
* @param params - The parameters for the whoami request
|
|
@@ -29,7 +36,8 @@ export type GetWhoamiReturnType = {
|
|
|
29
36
|
* ```ts
|
|
30
37
|
* const userInfo = await getWhoami(client, {
|
|
31
38
|
* organizationId: 'org_123',
|
|
32
|
-
* projectId: 'proj_456'
|
|
39
|
+
* projectId: 'proj_456',
|
|
40
|
+
* token: 'session_token',
|
|
33
41
|
* });
|
|
34
42
|
* console.log(userInfo.userId); // 'user_789'
|
|
35
43
|
* ```
|
|
@@ -38,14 +46,33 @@ export async function getWhoami(
|
|
|
38
46
|
client: Client,
|
|
39
47
|
params: GetWhoamiParameters,
|
|
40
48
|
): Promise<GetWhoamiReturnType> {
|
|
41
|
-
const { organizationId, projectId } = params
|
|
49
|
+
const { organizationId, projectId, token } = params
|
|
50
|
+
|
|
51
|
+
// Step 1: Inner stamp over the payload (for Turnkey verification)
|
|
52
|
+
const innerBody = { organizationId }
|
|
53
|
+
const innerBodyString = canonicalizeEx(innerBody)
|
|
54
|
+
const innerStamp = await client.apiKeyStamper.stamp(innerBodyString)
|
|
55
|
+
|
|
56
|
+
// Step 2: Build full body with inner stamp embedded
|
|
57
|
+
const fullBody = {
|
|
58
|
+
...innerBody,
|
|
59
|
+
stamp: {
|
|
60
|
+
stampHeaderName: innerStamp.stampHeaderName,
|
|
61
|
+
stampHeaderValue: innerStamp.stampHeaderValue,
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Step 3: Outer stamp over full body (for KMS middleware)
|
|
66
|
+
const fullBodyString = canonicalizeEx(fullBody)
|
|
67
|
+
const outerStamp = await client.apiKeyStamper.stamp(fullBodyString)
|
|
42
68
|
|
|
43
69
|
return await client.request({
|
|
44
70
|
path: `${projectId}/whoami`,
|
|
45
71
|
method: 'POST',
|
|
46
|
-
body:
|
|
47
|
-
|
|
72
|
+
body: fullBody,
|
|
73
|
+
headers: {
|
|
74
|
+
[outerStamp.stampHeaderName]: outerStamp.stampHeaderValue,
|
|
75
|
+
...(token && { Authorization: `Bearer ${token}` }),
|
|
48
76
|
},
|
|
49
|
-
stamp: true,
|
|
50
77
|
})
|
|
51
78
|
}
|
|
@@ -2,7 +2,6 @@ export {
|
|
|
2
2
|
type AuthenticateWithEmailParameters,
|
|
3
3
|
type AuthenticateWithEmailReturnType,
|
|
4
4
|
authenticateWithEmail,
|
|
5
|
-
type EmailCustomization,
|
|
6
5
|
} from './authenticateWithEmail.js'
|
|
7
6
|
|
|
8
7
|
export {
|
|
@@ -11,10 +10,27 @@ export {
|
|
|
11
10
|
authenticateWithOAuth,
|
|
12
11
|
} from './authenticateWithOAuth.js'
|
|
13
12
|
export {
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
type ApiKeyAuthenticator,
|
|
14
|
+
type EmailContact,
|
|
15
|
+
type GetAuthenticatorsParameters,
|
|
16
|
+
type GetAuthenticatorsReturnType,
|
|
17
|
+
getAuthenticators,
|
|
18
|
+
type OAuthAuthenticator,
|
|
19
|
+
type PasskeyAuthenticator,
|
|
20
|
+
} from './getAuthenticators.js'
|
|
21
|
+
export {
|
|
22
|
+
type GetAuthProxyConfigIdReturnType,
|
|
23
|
+
getAuthProxyConfigId,
|
|
24
|
+
} from './getAuthProxyConfigId.js'
|
|
25
|
+
export {
|
|
26
|
+
type GetOAuthLoginUrlParameters,
|
|
27
|
+
type GetOAuthLoginUrlReturnType,
|
|
28
|
+
getOAuthLoginUrl,
|
|
29
|
+
} from './getOAuthLoginUrl.js'
|
|
30
|
+
export {
|
|
31
|
+
type GetParentOrgIdReturnType,
|
|
32
|
+
getParentOrgId,
|
|
33
|
+
} from './getParentOrgId.js'
|
|
18
34
|
export {
|
|
19
35
|
type GetWhoamiParameters,
|
|
20
36
|
type GetWhoamiReturnType,
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { canonicalizeEx } from 'json-canonicalize'
|
|
2
2
|
import type { Client } from '../../client/types.js'
|
|
3
3
|
import type { Stamp } from '../../stampers/types.js'
|
|
4
|
-
|
|
5
|
-
export type EmailCustomization = {
|
|
6
|
-
/** A template for the URL to be used in a magic link button, e.g. `https://dapp.xyz/%s`. The auth bundle will be interpolated into the `%s`. */
|
|
7
|
-
magicLinkTemplate?: string
|
|
8
|
-
}
|
|
4
|
+
import type { StamperType } from '../../types/session.js'
|
|
9
5
|
|
|
10
6
|
export type LoginWithStampParameters = {
|
|
11
7
|
/** The project ID for the request */
|
|
@@ -15,7 +11,7 @@ export type LoginWithStampParameters = {
|
|
|
15
11
|
/** The encoded public key for the request */
|
|
16
12
|
targetPublicKey: string
|
|
17
13
|
/** The stamper type for the request */
|
|
18
|
-
stampWith?:
|
|
14
|
+
stampWith?: StamperType
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
export type LoginWithStampReturnType = {
|
|
@@ -58,19 +54,22 @@ export async function loginWithStamp(
|
|
|
58
54
|
type: 'ACTIVITY_TYPE_STAMP_LOGIN',
|
|
59
55
|
})
|
|
60
56
|
let stamp: Stamp
|
|
61
|
-
if (stampWith === '
|
|
62
|
-
stamp = await client.
|
|
63
|
-
} else if (stampWith === '
|
|
64
|
-
stamp = await client.
|
|
57
|
+
if (stampWith === 'apiKey') {
|
|
58
|
+
stamp = await client.apiKeyStamper.stamp(stampPayload)
|
|
59
|
+
} else if (stampWith === 'passkey') {
|
|
60
|
+
stamp = await client.passkeyStamper.stamp(stampPayload)
|
|
65
61
|
} else {
|
|
66
|
-
stamp = await client.
|
|
62
|
+
stamp = await client.apiKeyStamper.stamp(stampPayload)
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
return client.request({
|
|
70
66
|
path: `${projectId}/auth/login/stamp`,
|
|
71
67
|
method: 'POST',
|
|
68
|
+
// The sub-org id is intentionally not sent: the backend derives it from
|
|
69
|
+
// the stamped credential. `organizationId` (the parent org) is only
|
|
70
|
+
// signed into `stampPayload` above so the stamp matches the body the
|
|
71
|
+
// backend relays to Turnkey — it is not part of the wire request.
|
|
72
72
|
body: {
|
|
73
|
-
subOrganizationId: organizationId,
|
|
74
73
|
targetPublicKey,
|
|
75
74
|
timestamp: timestampIso,
|
|
76
75
|
stamp,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Client } from '../../client/types.js'
|
|
2
|
-
import type { EmailCustomization } from './authenticateWithEmail.js'
|
|
3
2
|
|
|
4
3
|
export type OtpContact = {
|
|
5
4
|
/** The OTP delivery type (currently only 'email' is supported) */
|
|
@@ -15,19 +14,27 @@ export type RegisterWithOTPParameters = {
|
|
|
15
14
|
contact: OtpContact
|
|
16
15
|
/** The project ID for the request */
|
|
17
16
|
projectId: string
|
|
18
|
-
/** Optional email customization settings */
|
|
19
|
-
emailCustomization?: EmailCustomization
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
export type RegisterWithOTPReturnType = {
|
|
23
20
|
/** The OTP ID needed for verification */
|
|
24
21
|
otpId: string
|
|
22
|
+
/**
|
|
23
|
+
* Signed encryption target bundle issued by the TLS Fetcher enclave for
|
|
24
|
+
* this OTP session. Passed verbatim to the verify step so the SDK can
|
|
25
|
+
* HPKE-encrypt the OTP attempt to the enclave's ephemeral target key.
|
|
26
|
+
*/
|
|
27
|
+
otpEncryptionTargetBundle: string
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* Initiates OTP (One-Time Password) authentication
|
|
29
32
|
* This will send an OTP code to the specified contact method
|
|
30
33
|
*
|
|
34
|
+
* OTP code length/format and, when enabled, the magic-link URL template are
|
|
35
|
+
* configured per-project on the backend (`wallet.otp_configs`). The client no
|
|
36
|
+
* longer sends customization fields — they are ignored server-side.
|
|
37
|
+
*
|
|
31
38
|
* @param client - The ZeroDev Wallet client
|
|
32
39
|
* @param params - The parameters for OTP initiation
|
|
33
40
|
* @returns The result including otpId needed for verification
|
|
@@ -50,7 +57,7 @@ export async function registerWithOTP(
|
|
|
50
57
|
client: Client,
|
|
51
58
|
params: RegisterWithOTPParameters,
|
|
52
59
|
): Promise<RegisterWithOTPReturnType> {
|
|
53
|
-
const { email, contact, projectId
|
|
60
|
+
const { email, contact, projectId } = params
|
|
54
61
|
|
|
55
62
|
return await client.request({
|
|
56
63
|
path: `${projectId}/auth/init/otp`,
|
|
@@ -58,7 +65,6 @@ export async function registerWithOTP(
|
|
|
58
65
|
body: {
|
|
59
66
|
email,
|
|
60
67
|
contact,
|
|
61
|
-
emailCustomization,
|
|
62
68
|
},
|
|
63
69
|
})
|
|
64
70
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import type { Client } from '../../client/types.js'
|
|
2
2
|
|
|
3
|
-
export type EmailCustomization = {
|
|
4
|
-
/** A template for the URL to be used in a magic link button, e.g. `https://dapp.xyz/%s`. The auth bundle will be interpolated into the `%s`. */
|
|
5
|
-
magicLinkTemplate?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
3
|
export type RegisterWithPasskeyParameters = {
|
|
9
|
-
/** The email address to authenticate */
|
|
10
|
-
email: string
|
|
11
4
|
/** The project ID for the request */
|
|
12
5
|
projectId: string
|
|
13
6
|
/** The challenge for the request */
|
|
@@ -41,7 +34,6 @@ export type RegisterWithPasskeyReturnType = {
|
|
|
41
34
|
* @example
|
|
42
35
|
* ```ts
|
|
43
36
|
* const result = await registerWithPasskey(client, {
|
|
44
|
-
* email: 'user@example.com',
|
|
45
37
|
* projectId: 'proj_456',
|
|
46
38
|
* challenge: 'challenge',
|
|
47
39
|
* attestation: {
|
|
@@ -57,13 +49,12 @@ export async function registerWithPasskey(
|
|
|
57
49
|
client: Client,
|
|
58
50
|
params: RegisterWithPasskeyParameters,
|
|
59
51
|
): Promise<RegisterWithPasskeyReturnType> {
|
|
60
|
-
const {
|
|
52
|
+
const { projectId, challenge, attestation, encodedPublicKey } = params
|
|
61
53
|
|
|
62
54
|
return client.request({
|
|
63
55
|
path: `${projectId}/auth/register/passkey`,
|
|
64
56
|
method: 'POST',
|
|
65
57
|
body: {
|
|
66
|
-
email,
|
|
67
58
|
attestation,
|
|
68
59
|
challenge,
|
|
69
60
|
encodedPublicKey,
|