@zerodev/wallet-core 0.0.1-alpha.8 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -18
- package/dist/_cjs/actions/auth/authenticateWithEmail.js +1 -2
- package/dist/_cjs/actions/auth/authenticateWithEmail.js.map +1 -1
- package/dist/_cjs/actions/auth/authenticateWithOAuth.js +2 -3
- package/dist/_cjs/actions/auth/authenticateWithOAuth.js.map +1 -1
- package/dist/_cjs/actions/auth/getAuthProxyConfigId.js +10 -0
- package/dist/_cjs/actions/auth/getAuthProxyConfigId.js.map +1 -0
- package/dist/_cjs/actions/auth/getAuthenticators.js +16 -0
- package/dist/_cjs/actions/auth/getAuthenticators.js.map +1 -0
- package/dist/_cjs/actions/auth/getOAuthLoginUrl.js +18 -0
- package/dist/_cjs/actions/auth/getOAuthLoginUrl.js.map +1 -0
- package/dist/_cjs/actions/auth/getParentOrgId.js +10 -0
- package/dist/_cjs/actions/auth/getParentOrgId.js.map +1 -0
- package/dist/_cjs/actions/auth/getWhoami.js +18 -4
- package/dist/_cjs/actions/auth/getWhoami.js.map +1 -1
- package/dist/_cjs/actions/auth/index.js +9 -3
- package/dist/_cjs/actions/auth/index.js.map +1 -1
- package/dist/_cjs/actions/auth/loginWithStamp.js +5 -6
- package/dist/_cjs/actions/auth/loginWithStamp.js.map +1 -1
- package/dist/_cjs/actions/auth/registerWithOTP.js +1 -2
- package/dist/_cjs/actions/auth/registerWithOTP.js.map +1 -1
- package/dist/_cjs/actions/auth/registerWithPasskey.js +1 -2
- package/dist/_cjs/actions/auth/registerWithPasskey.js.map +1 -1
- package/dist/_cjs/actions/index.js +9 -3
- package/dist/_cjs/actions/index.js.map +1 -1
- package/dist/_cjs/actions/wallet/getUserWallet.js +3 -5
- package/dist/_cjs/actions/wallet/getUserWallet.js.map +1 -1
- package/dist/_cjs/actions/wallet/index.js +9 -3
- package/dist/_cjs/actions/wallet/index.js.map +1 -1
- package/dist/_cjs/actions/wallet/sign7702Authorization.js +16 -0
- package/dist/_cjs/actions/wallet/sign7702Authorization.js.map +1 -0
- package/dist/_cjs/actions/wallet/signMessage.js +17 -0
- package/dist/_cjs/actions/wallet/signMessage.js.map +1 -0
- package/dist/_cjs/actions/wallet/signTransaction.js +9 -18
- package/dist/_cjs/actions/wallet/signTransaction.js.map +1 -1
- package/dist/_cjs/actions/wallet/signTypedDataV4.js +17 -0
- package/dist/_cjs/actions/wallet/signTypedDataV4.js.map +1 -0
- package/dist/_cjs/actions/wallet/signUserOperation.js +17 -0
- package/dist/_cjs/actions/wallet/signUserOperation.js.map +1 -0
- package/dist/_cjs/actions/wallet/signingUtils.js +64 -0
- package/dist/_cjs/actions/wallet/signingUtils.js.map +1 -0
- package/dist/_cjs/adapters/viem.js +60 -27
- package/dist/_cjs/adapters/viem.js.map +1 -1
- package/dist/_cjs/client/authProxy.js +1 -1
- package/dist/_cjs/client/authProxy.js.map +1 -1
- package/dist/_cjs/client/createClient.js +5 -5
- package/dist/_cjs/client/createClient.js.map +1 -1
- package/dist/_cjs/client/decorators/client.js +9 -4
- package/dist/_cjs/client/decorators/client.js.map +1 -1
- package/dist/_cjs/client/index.js.map +1 -1
- package/dist/_cjs/client/transports/createTransport.js +6 -5
- package/dist/_cjs/client/transports/createTransport.js.map +1 -1
- package/dist/_cjs/client/transports/rest.js +40 -28
- package/dist/_cjs/client/transports/rest.js.map +1 -1
- package/dist/_cjs/constants.js +4 -4
- package/dist/_cjs/constants.js.map +1 -1
- package/dist/_cjs/core/{createZeroDevWallet.js → createZeroDevWalletCore.js} +94 -86
- package/dist/_cjs/core/createZeroDevWalletCore.js.map +1 -0
- package/dist/_cjs/index.js +14 -8
- package/dist/_cjs/index.js.map +1 -1
- package/dist/_cjs/index.native.js +39 -0
- package/dist/_cjs/index.native.js.map +1 -0
- package/dist/_cjs/native/createZeroDevWallet.js +13 -0
- package/dist/_cjs/native/createZeroDevWallet.js.map +1 -0
- package/dist/_cjs/native/stampers/passkey.js +30 -0
- package/dist/_cjs/native/stampers/passkey.js.map +1 -0
- package/dist/_cjs/native/stampers/secureStore.js +112 -0
- package/dist/_cjs/native/stampers/secureStore.js.map +1 -0
- package/dist/_cjs/native/storage/asyncStorage.js +11 -0
- package/dist/_cjs/native/storage/asyncStorage.js.map +1 -0
- package/dist/_cjs/stampers/iframeStamper.js +3 -0
- package/dist/_cjs/stampers/iframeStamper.js.map +1 -1
- package/dist/_cjs/stampers/indexedDbStamper.js +20 -2
- package/dist/_cjs/stampers/indexedDbStamper.js.map +1 -1
- package/dist/_cjs/stampers/noopPasskeyStamper.js +16 -0
- package/dist/_cjs/stampers/noopPasskeyStamper.js.map +1 -0
- package/dist/_cjs/stampers/webauthnStamper.js +23 -3
- package/dist/_cjs/stampers/webauthnStamper.js.map +1 -1
- package/dist/_cjs/stubs/native-on-web.js +12 -0
- package/dist/_cjs/stubs/native-on-web.js.map +1 -0
- package/dist/_cjs/utils/encryptOtpAttempt.js +57 -0
- package/dist/_cjs/utils/encryptOtpAttempt.js.map +1 -0
- package/dist/_cjs/utils/exportPrivateKey.js +1 -1
- package/dist/_cjs/utils/exportPrivateKey.js.map +1 -1
- package/dist/_cjs/utils/exportWallet.js +52 -61
- package/dist/_cjs/utils/exportWallet.js.map +1 -1
- package/dist/_cjs/utils/hpke.js +78 -0
- package/dist/_cjs/utils/hpke.js.map +1 -0
- package/dist/_cjs/utils/platform.js +19 -0
- package/dist/_cjs/utils/platform.js.map +1 -0
- package/dist/_cjs/utils/resolveOrganizationId.js +20 -0
- package/dist/_cjs/utils/resolveOrganizationId.js.map +1 -0
- package/dist/_cjs/utils/utils.js +5 -6
- package/dist/_cjs/utils/utils.js.map +1 -1
- package/dist/_cjs/web/createZeroDevWallet.js +21 -0
- package/dist/_cjs/web/createZeroDevWallet.js.map +1 -0
- package/dist/_esm/actions/auth/authenticateWithEmail.js +1 -2
- package/dist/_esm/actions/auth/authenticateWithEmail.js.map +1 -1
- package/dist/_esm/actions/auth/authenticateWithOAuth.js +8 -7
- package/dist/_esm/actions/auth/authenticateWithOAuth.js.map +1 -1
- package/dist/_esm/actions/auth/getAuthProxyConfigId.js +13 -0
- package/dist/_esm/actions/auth/getAuthProxyConfigId.js.map +1 -0
- package/dist/_esm/actions/auth/getAuthenticators.js +36 -0
- package/dist/_esm/actions/auth/getAuthenticators.js.map +1 -0
- package/dist/_esm/actions/auth/getOAuthLoginUrl.js +23 -0
- package/dist/_esm/actions/auth/getOAuthLoginUrl.js.map +1 -0
- package/dist/_esm/actions/auth/getParentOrgId.js +17 -0
- package/dist/_esm/actions/auth/getParentOrgId.js.map +1 -0
- package/dist/_esm/actions/auth/getWhoami.js +28 -6
- package/dist/_esm/actions/auth/getWhoami.js.map +1 -1
- package/dist/_esm/actions/auth/index.js +4 -1
- package/dist/_esm/actions/auth/index.js.map +1 -1
- package/dist/_esm/actions/auth/loginWithStamp.js +9 -6
- package/dist/_esm/actions/auth/loginWithStamp.js.map +1 -1
- package/dist/_esm/actions/auth/registerWithOTP.js +5 -2
- package/dist/_esm/actions/auth/registerWithOTP.js.map +1 -1
- package/dist/_esm/actions/auth/registerWithPasskey.js +1 -3
- package/dist/_esm/actions/auth/registerWithPasskey.js.map +1 -1
- package/dist/_esm/actions/index.js +2 -2
- package/dist/_esm/actions/index.js.map +1 -1
- package/dist/_esm/actions/wallet/getUserWallet.js +5 -5
- package/dist/_esm/actions/wallet/getUserWallet.js.map +1 -1
- package/dist/_esm/actions/wallet/index.js +4 -1
- package/dist/_esm/actions/wallet/index.js.map +1 -1
- package/dist/_esm/actions/wallet/sign7702Authorization.js +13 -0
- package/dist/_esm/actions/wallet/sign7702Authorization.js.map +1 -0
- package/dist/_esm/actions/wallet/signMessage.js +14 -0
- package/dist/_esm/actions/wallet/signMessage.js.map +1 -0
- package/dist/_esm/actions/wallet/signTransaction.js +9 -36
- package/dist/_esm/actions/wallet/signTransaction.js.map +1 -1
- package/dist/_esm/actions/wallet/signTypedDataV4.js +14 -0
- package/dist/_esm/actions/wallet/signTypedDataV4.js.map +1 -0
- package/dist/_esm/actions/wallet/signUserOperation.js +14 -0
- package/dist/_esm/actions/wallet/signUserOperation.js.map +1 -0
- package/dist/_esm/actions/wallet/signingUtils.js +69 -0
- package/dist/_esm/actions/wallet/signingUtils.js.map +1 -0
- package/dist/_esm/adapters/viem.js +63 -30
- package/dist/_esm/adapters/viem.js.map +1 -1
- package/dist/_esm/client/authProxy.js +9 -4
- package/dist/_esm/client/authProxy.js.map +1 -1
- package/dist/_esm/client/createClient.js +5 -5
- package/dist/_esm/client/createClient.js.map +1 -1
- package/dist/_esm/client/decorators/client.js +9 -4
- package/dist/_esm/client/decorators/client.js.map +1 -1
- package/dist/_esm/client/index.js +1 -1
- package/dist/_esm/client/index.js.map +1 -1
- package/dist/_esm/client/transports/createTransport.js +6 -5
- package/dist/_esm/client/transports/createTransport.js.map +1 -1
- package/dist/_esm/client/transports/rest.js +44 -29
- package/dist/_esm/client/transports/rest.js.map +1 -1
- package/dist/_esm/constants.js +10 -3
- package/dist/_esm/constants.js.map +1 -1
- package/dist/_esm/core/{createZeroDevWallet.js → createZeroDevWalletCore.js} +115 -90
- package/dist/_esm/core/createZeroDevWalletCore.js.map +1 -0
- package/dist/_esm/index.js +13 -5
- package/dist/_esm/index.js.map +1 -1
- package/dist/_esm/index.native.js +19 -0
- package/dist/_esm/index.native.js.map +1 -0
- package/dist/_esm/native/createZeroDevWallet.js +10 -0
- package/dist/_esm/native/createZeroDevWallet.js.map +1 -0
- package/dist/_esm/native/stampers/passkey.js +27 -0
- package/dist/_esm/native/stampers/passkey.js.map +1 -0
- package/dist/_esm/native/stampers/secureStore.js +120 -0
- package/dist/_esm/native/stampers/secureStore.js.map +1 -0
- package/dist/_esm/native/storage/asyncStorage.js +13 -0
- package/dist/_esm/native/storage/asyncStorage.js.map +1 -0
- package/dist/_esm/stampers/iframeStamper.js +3 -0
- package/dist/_esm/stampers/iframeStamper.js.map +1 -1
- package/dist/_esm/stampers/indexedDbStamper.js +20 -2
- package/dist/_esm/stampers/indexedDbStamper.js.map +1 -1
- package/dist/_esm/stampers/noopPasskeyStamper.js +18 -0
- package/dist/_esm/stampers/noopPasskeyStamper.js.map +1 -0
- package/dist/_esm/stampers/webauthnStamper.js +23 -4
- package/dist/_esm/stampers/webauthnStamper.js.map +1 -1
- package/dist/_esm/stubs/native-on-web.js +25 -0
- package/dist/_esm/stubs/native-on-web.js.map +1 -0
- package/dist/_esm/utils/encryptOtpAttempt.js +81 -0
- package/dist/_esm/utils/encryptOtpAttempt.js.map +1 -0
- package/dist/_esm/utils/exportPrivateKey.js +1 -1
- package/dist/_esm/utils/exportPrivateKey.js.map +1 -1
- package/dist/_esm/utils/exportWallet.js +52 -61
- package/dist/_esm/utils/exportWallet.js.map +1 -1
- package/dist/_esm/utils/hpke.js +119 -0
- package/dist/_esm/utils/hpke.js.map +1 -0
- package/dist/_esm/utils/platform.js +16 -0
- package/dist/_esm/utils/platform.js.map +1 -0
- package/dist/_esm/utils/resolveOrganizationId.js +27 -0
- package/dist/_esm/utils/resolveOrganizationId.js.map +1 -0
- package/dist/_esm/utils/utils.js +5 -6
- package/dist/_esm/utils/utils.js.map +1 -1
- package/dist/_esm/web/createZeroDevWallet.js +18 -0
- package/dist/_esm/web/createZeroDevWallet.js.map +1 -0
- package/dist/_types/actions/auth/authenticateWithEmail.d.ts +0 -6
- package/dist/_types/actions/auth/authenticateWithEmail.d.ts.map +1 -1
- package/dist/_types/actions/auth/authenticateWithOAuth.d.ts +10 -4
- package/dist/_types/actions/auth/authenticateWithOAuth.d.ts.map +1 -1
- package/dist/_types/actions/auth/getAuthProxyConfigId.d.ts +12 -0
- package/dist/_types/actions/auth/getAuthProxyConfigId.d.ts.map +1 -0
- package/dist/_types/actions/auth/getAuthenticators.d.ts +65 -0
- package/dist/_types/actions/auth/getAuthenticators.d.ts.map +1 -0
- package/dist/_types/actions/auth/getOAuthLoginUrl.d.ts +30 -0
- package/dist/_types/actions/auth/getOAuthLoginUrl.d.ts.map +1 -0
- package/dist/_types/actions/auth/getParentOrgId.d.ts +17 -0
- package/dist/_types/actions/auth/getParentOrgId.d.ts.map +1 -0
- package/dist/_types/actions/auth/getWhoami.d.ts +9 -2
- package/dist/_types/actions/auth/getWhoami.d.ts.map +1 -1
- package/dist/_types/actions/auth/index.d.ts +5 -2
- package/dist/_types/actions/auth/index.d.ts.map +1 -1
- package/dist/_types/actions/auth/loginWithStamp.d.ts +2 -5
- package/dist/_types/actions/auth/loginWithStamp.d.ts.map +1 -1
- package/dist/_types/actions/auth/registerWithOTP.d.ts +10 -3
- package/dist/_types/actions/auth/registerWithOTP.d.ts.map +1 -1
- package/dist/_types/actions/auth/registerWithPasskey.d.ts +0 -7
- package/dist/_types/actions/auth/registerWithPasskey.d.ts.map +1 -1
- package/dist/_types/actions/index.d.ts +2 -2
- package/dist/_types/actions/index.d.ts.map +1 -1
- package/dist/_types/actions/wallet/index.d.ts +4 -1
- package/dist/_types/actions/wallet/index.d.ts.map +1 -1
- package/dist/_types/actions/wallet/sign7702Authorization.d.ts +19 -0
- package/dist/_types/actions/wallet/sign7702Authorization.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signMessage.d.ts +19 -0
- package/dist/_types/actions/wallet/signMessage.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signTransaction.d.ts +1 -19
- package/dist/_types/actions/wallet/signTransaction.d.ts.map +1 -1
- package/dist/_types/actions/wallet/signTypedDataV4.d.ts +21 -0
- package/dist/_types/actions/wallet/signTypedDataV4.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signUserOperation.d.ts +21 -0
- package/dist/_types/actions/wallet/signUserOperation.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signingUtils.d.ts +32 -0
- package/dist/_types/actions/wallet/signingUtils.d.ts.map +1 -0
- package/dist/_types/adapters/viem.d.ts +1 -1
- package/dist/_types/adapters/viem.d.ts.map +1 -1
- package/dist/_types/client/authProxy.d.ts +13 -7
- package/dist/_types/client/authProxy.d.ts.map +1 -1
- package/dist/_types/client/decorators/client.d.ts +32 -6
- package/dist/_types/client/decorators/client.d.ts.map +1 -1
- package/dist/_types/client/index.d.ts +1 -1
- package/dist/_types/client/index.d.ts.map +1 -1
- package/dist/_types/client/transports/createTransport.d.ts +2 -0
- package/dist/_types/client/transports/createTransport.d.ts.map +1 -1
- package/dist/_types/client/transports/rest.d.ts +13 -5
- package/dist/_types/client/transports/rest.d.ts.map +1 -1
- package/dist/_types/client/types.d.ts +9 -9
- package/dist/_types/client/types.d.ts.map +1 -1
- package/dist/_types/constants.d.ts +3 -3
- package/dist/_types/constants.d.ts.map +1 -1
- package/dist/_types/core/{createZeroDevWallet.d.ts → createZeroDevWalletCore.d.ts} +30 -10
- package/dist/_types/core/createZeroDevWalletCore.d.ts.map +1 -0
- package/dist/_types/index.d.ts +7 -7
- package/dist/_types/index.d.ts.map +1 -1
- package/dist/_types/index.native.d.ts +19 -0
- package/dist/_types/index.native.d.ts.map +1 -0
- package/dist/_types/native/createZeroDevWallet.d.ts +12 -0
- package/dist/_types/native/createZeroDevWallet.d.ts.map +1 -0
- package/dist/_types/native/stampers/passkey.d.ts +5 -0
- package/dist/_types/native/stampers/passkey.d.ts.map +1 -0
- package/dist/_types/native/stampers/secureStore.d.ts +3 -0
- package/dist/_types/native/stampers/secureStore.d.ts.map +1 -0
- package/dist/_types/native/storage/asyncStorage.d.ts +3 -0
- package/dist/_types/native/storage/asyncStorage.d.ts.map +1 -0
- package/dist/_types/stampers/iframeStamper.d.ts.map +1 -1
- package/dist/_types/stampers/indexedDbStamper.d.ts +2 -2
- package/dist/_types/stampers/indexedDbStamper.d.ts.map +1 -1
- package/dist/_types/stampers/noopPasskeyStamper.d.ts +8 -0
- package/dist/_types/stampers/noopPasskeyStamper.d.ts.map +1 -0
- package/dist/_types/stampers/types.d.ts +39 -5
- package/dist/_types/stampers/types.d.ts.map +1 -1
- package/dist/_types/stampers/webauthnStamper.d.ts +2 -2
- package/dist/_types/stampers/webauthnStamper.d.ts.map +1 -1
- package/dist/_types/stubs/native-on-web.d.ts +6 -0
- package/dist/_types/stubs/native-on-web.d.ts.map +1 -0
- package/dist/_types/types/session.d.ts +2 -3
- package/dist/_types/types/session.d.ts.map +1 -1
- package/dist/_types/utils/buildClientSignature.d.ts +3 -3
- package/dist/_types/utils/buildClientSignature.d.ts.map +1 -1
- package/dist/_types/utils/encryptOtpAttempt.d.ts +40 -0
- package/dist/_types/utils/encryptOtpAttempt.d.ts.map +1 -0
- package/dist/_types/utils/exportPrivateKey.d.ts +1 -1
- package/dist/_types/utils/exportPrivateKey.d.ts.map +1 -1
- package/dist/_types/utils/exportWallet.d.ts +1 -1
- package/dist/_types/utils/exportWallet.d.ts.map +1 -1
- package/dist/_types/utils/hpke.d.ts +38 -0
- package/dist/_types/utils/hpke.d.ts.map +1 -0
- package/dist/_types/utils/platform.d.ts +2 -0
- package/dist/_types/utils/platform.d.ts.map +1 -0
- package/dist/_types/utils/resolveOrganizationId.d.ts +16 -0
- package/dist/_types/utils/resolveOrganizationId.d.ts.map +1 -0
- package/dist/_types/utils/utils.d.ts.map +1 -1
- package/dist/_types/web/createZeroDevWallet.d.ts +18 -0
- package/dist/_types/web/createZeroDevWallet.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +100 -11
- package/src/actions/auth/authenticateWithEmail.ts +1 -9
- package/src/actions/auth/authenticateWithOAuth.ts +12 -7
- package/src/actions/auth/getAuthProxyConfigId.ts +20 -0
- package/src/actions/auth/getAuthenticators.ts +89 -0
- package/src/actions/auth/getOAuthLoginUrl.ts +48 -0
- package/src/actions/auth/getParentOrgId.ts +25 -0
- package/src/actions/auth/getWhoami.ts +33 -6
- package/src/actions/auth/index.ts +21 -5
- package/src/actions/auth/loginWithStamp.ts +11 -12
- package/src/actions/auth/registerWithOTP.ts +11 -5
- package/src/actions/auth/registerWithPasskey.ts +1 -10
- package/src/actions/index.ts +26 -7
- package/src/actions/wallet/getUserWallet.ts +5 -5
- package/src/actions/wallet/index.ts +22 -4
- package/src/actions/wallet/sign7702Authorization.ts +48 -0
- package/src/actions/wallet/signMessage.ts +47 -0
- package/src/actions/wallet/signTransaction.ts +19 -38
- package/src/actions/wallet/signTypedDataV4.ts +52 -0
- package/src/actions/wallet/signUserOperation.ts +56 -0
- package/src/actions/wallet/signingUtils.ts +110 -0
- package/src/adapters/viem.ts +75 -43
- package/src/client/authProxy.ts +14 -8
- package/src/client/createClient.ts +6 -6
- package/src/client/decorators/client.ts +78 -19
- package/src/client/index.ts +4 -1
- package/src/client/transports/createTransport.ts +8 -5
- package/src/client/transports/rest.ts +57 -34
- package/src/client/types.ts +9 -9
- package/src/constants.ts +12 -4
- package/src/core/{createZeroDevWallet.ts → createZeroDevWalletCore.ts} +147 -122
- package/src/index.native.ts +102 -0
- package/src/index.ts +49 -16
- package/src/native/createZeroDevWallet.ts +26 -0
- package/src/native/stampers/passkey.ts +39 -0
- package/src/native/stampers/secureStore.ts +139 -0
- package/src/native/storage/asyncStorage.ts +18 -0
- package/src/stampers/iframeStamper.ts +3 -0
- package/src/stampers/indexedDbStamper.ts +27 -4
- package/src/stampers/noopPasskeyStamper.ts +21 -0
- package/src/stampers/types.ts +39 -5
- package/src/stampers/webauthnStamper.ts +27 -6
- package/src/stubs/native-on-web.ts +29 -0
- package/src/types/session.ts +2 -3
- package/src/utils/buildClientSignature.ts +3 -3
- package/src/utils/encryptOtpAttempt.ts +142 -0
- package/src/utils/exportPrivateKey.ts +2 -2
- package/src/utils/exportWallet.ts +66 -75
- package/src/utils/hpke.ts +219 -0
- package/src/utils/platform.ts +21 -0
- package/src/utils/resolveOrganizationId.ts +28 -0
- package/src/utils/utils.ts +5 -6
- package/src/web/createZeroDevWallet.ts +45 -0
- package/dist/_cjs/actions/auth/getUserEmail.js +0 -16
- package/dist/_cjs/actions/auth/getUserEmail.js.map +0 -1
- package/dist/_cjs/actions/wallet/signRawPayload.js +0 -27
- package/dist/_cjs/actions/wallet/signRawPayload.js.map +0 -1
- package/dist/_cjs/core/createZeroDevWallet.js.map +0 -1
- package/dist/_cjs/stampers/index.js +0 -10
- package/dist/_cjs/stampers/index.js.map +0 -1
- package/dist/_esm/actions/auth/getUserEmail.js +0 -29
- package/dist/_esm/actions/auth/getUserEmail.js.map +0 -1
- package/dist/_esm/actions/wallet/signRawPayload.js +0 -42
- package/dist/_esm/actions/wallet/signRawPayload.js.map +0 -1
- package/dist/_esm/core/createZeroDevWallet.js.map +0 -1
- package/dist/_esm/stampers/index.js +0 -4
- package/dist/_esm/stampers/index.js.map +0 -1
- package/dist/_types/actions/auth/getUserEmail.d.ts +0 -29
- package/dist/_types/actions/auth/getUserEmail.d.ts.map +0 -1
- package/dist/_types/actions/wallet/signRawPayload.d.ts +0 -39
- package/dist/_types/actions/wallet/signRawPayload.d.ts.map +0 -1
- package/dist/_types/core/createZeroDevWallet.d.ts.map +0 -1
- package/dist/_types/stampers/index.d.ts +0 -5
- package/dist/_types/stampers/index.d.ts.map +0 -1
- package/src/actions/auth/getUserEmail.ts +0 -46
- package/src/actions/wallet/signRawPayload.ts +0 -75
- package/src/stampers/index.ts +0 -8
package/src/actions/index.ts
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
// Auth actions
|
|
2
2
|
export {
|
|
3
|
+
type ApiKeyAuthenticator,
|
|
3
4
|
type AuthenticateWithEmailParameters,
|
|
4
5
|
type AuthenticateWithEmailReturnType,
|
|
5
6
|
type AuthenticateWithOAuthParameters,
|
|
6
7
|
type AuthenticateWithOAuthReturnType,
|
|
7
8
|
authenticateWithEmail,
|
|
8
9
|
authenticateWithOAuth,
|
|
9
|
-
type
|
|
10
|
-
type
|
|
11
|
-
type
|
|
10
|
+
type EmailContact,
|
|
11
|
+
type GetAuthenticatorsParameters,
|
|
12
|
+
type GetAuthenticatorsReturnType,
|
|
13
|
+
type GetAuthProxyConfigIdReturnType,
|
|
14
|
+
type GetOAuthLoginUrlParameters,
|
|
15
|
+
type GetOAuthLoginUrlReturnType,
|
|
16
|
+
type GetParentOrgIdReturnType,
|
|
12
17
|
type GetWhoamiParameters,
|
|
13
18
|
type GetWhoamiReturnType,
|
|
14
|
-
|
|
19
|
+
getAuthenticators,
|
|
20
|
+
getAuthProxyConfigId,
|
|
21
|
+
getOAuthLoginUrl,
|
|
22
|
+
getParentOrgId,
|
|
15
23
|
getWhoami,
|
|
16
24
|
type LoginWithOTPParameters,
|
|
17
25
|
type LoginWithOTPReturnType,
|
|
18
26
|
loginWithOTP,
|
|
27
|
+
type OAuthAuthenticator,
|
|
19
28
|
type OtpContact,
|
|
29
|
+
type PasskeyAuthenticator,
|
|
20
30
|
type RegisterWithOTPParameters,
|
|
21
31
|
type RegisterWithOTPReturnType,
|
|
22
32
|
type RegisterWithPasskeyParameters,
|
|
@@ -30,10 +40,19 @@ export {
|
|
|
30
40
|
type GetUserWalletParameters,
|
|
31
41
|
type GetUserWalletReturnType,
|
|
32
42
|
getUserWallet,
|
|
33
|
-
type
|
|
34
|
-
type
|
|
43
|
+
type Sign7702AuthorizationParameters,
|
|
44
|
+
type Sign7702AuthorizationReturnType,
|
|
45
|
+
type SignMessageParameters,
|
|
46
|
+
type SignMessageReturnType,
|
|
35
47
|
type SignTransactionParameters,
|
|
36
48
|
type SignTransactionReturnType,
|
|
37
|
-
|
|
49
|
+
type SignTypedDataV4Parameters,
|
|
50
|
+
type SignTypedDataV4ReturnType,
|
|
51
|
+
type SignUserOperationParameters,
|
|
52
|
+
type SignUserOperationReturnType,
|
|
53
|
+
sign7702Authorization,
|
|
54
|
+
signMessage,
|
|
38
55
|
signTransaction,
|
|
56
|
+
signTypedDataV4,
|
|
57
|
+
signUserOperation,
|
|
39
58
|
} from './wallet/index.js'
|
|
@@ -37,17 +37,17 @@ export async function getUserWallet(
|
|
|
37
37
|
client: Client,
|
|
38
38
|
params: GetUserWalletParameters,
|
|
39
39
|
): Promise<GetUserWalletReturnType> {
|
|
40
|
-
const {
|
|
40
|
+
const { projectId, token } = params
|
|
41
41
|
|
|
42
|
+
// GET behind StampCheckUser: user is resolved from the stamped credential
|
|
43
|
+
// (+ session JWT); no body sent. The stamp signs the X-Timestamp value.
|
|
42
44
|
return await client.request({
|
|
43
45
|
path: `${projectId}/user-wallet`,
|
|
44
|
-
|
|
45
|
-
organizationId,
|
|
46
|
-
},
|
|
46
|
+
method: 'GET',
|
|
47
47
|
headers: {
|
|
48
48
|
Authorization: `Bearer ${token}`,
|
|
49
49
|
},
|
|
50
50
|
stamp: true,
|
|
51
|
-
stampPostion: '
|
|
51
|
+
stampPostion: 'timestamp',
|
|
52
52
|
})
|
|
53
53
|
}
|
|
@@ -5,13 +5,31 @@ export {
|
|
|
5
5
|
} from './getUserWallet.js'
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
|
-
type
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
} from './
|
|
8
|
+
type Sign7702AuthorizationParameters,
|
|
9
|
+
type Sign7702AuthorizationReturnType,
|
|
10
|
+
sign7702Authorization,
|
|
11
|
+
} from './sign7702Authorization.js'
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
type SignMessageParameters,
|
|
15
|
+
type SignMessageReturnType,
|
|
16
|
+
signMessage,
|
|
17
|
+
} from './signMessage.js'
|
|
12
18
|
|
|
13
19
|
export {
|
|
14
20
|
type SignTransactionParameters,
|
|
15
21
|
type SignTransactionReturnType,
|
|
16
22
|
signTransaction,
|
|
17
23
|
} from './signTransaction.js'
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
type SignTypedDataV4Parameters,
|
|
27
|
+
type SignTypedDataV4ReturnType,
|
|
28
|
+
signTypedDataV4,
|
|
29
|
+
} from './signTypedDataV4.js'
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
type SignUserOperationParameters,
|
|
33
|
+
type SignUserOperationReturnType,
|
|
34
|
+
signUserOperation,
|
|
35
|
+
} from './signUserOperation.js'
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Hex } from 'viem'
|
|
2
|
+
import type { Client } from '../../client/types.js'
|
|
3
|
+
import { buildTurnkeyPayload, sendSigningRequest } from './signingUtils.js'
|
|
4
|
+
|
|
5
|
+
export type Sign7702AuthorizationParameters = {
|
|
6
|
+
/** The organization ID */
|
|
7
|
+
organizationId: string
|
|
8
|
+
/** The project ID for the request */
|
|
9
|
+
projectId: string
|
|
10
|
+
/** The session token for authorization */
|
|
11
|
+
token: string
|
|
12
|
+
/** The address to sign with */
|
|
13
|
+
address: Hex
|
|
14
|
+
/** The hex-encoded EIP-7702 authorization to be signed (without 0x prefix) */
|
|
15
|
+
unsignedTransaction: string
|
|
16
|
+
/** The hashed authorization (hex without 0x prefix) */
|
|
17
|
+
hashedAuthorization: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type Sign7702AuthorizationReturnType = Hex
|
|
21
|
+
|
|
22
|
+
export async function sign7702Authorization(
|
|
23
|
+
client: Client,
|
|
24
|
+
params: Sign7702AuthorizationParameters,
|
|
25
|
+
): Promise<Sign7702AuthorizationReturnType> {
|
|
26
|
+
const {
|
|
27
|
+
organizationId,
|
|
28
|
+
projectId,
|
|
29
|
+
token,
|
|
30
|
+
address,
|
|
31
|
+
unsignedTransaction,
|
|
32
|
+
hashedAuthorization,
|
|
33
|
+
} = params
|
|
34
|
+
|
|
35
|
+
const turnkeyPayload = buildTurnkeyPayload(
|
|
36
|
+
organizationId,
|
|
37
|
+
address,
|
|
38
|
+
hashedAuthorization,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return sendSigningRequest(client, {
|
|
42
|
+
projectId,
|
|
43
|
+
token,
|
|
44
|
+
path: 'sign/7702-authorization',
|
|
45
|
+
turnkeyPayload,
|
|
46
|
+
bodyFields: { unsignedTransaction },
|
|
47
|
+
})
|
|
48
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Hex } from 'viem'
|
|
2
|
+
import type { Client } from '../../client/types.js'
|
|
3
|
+
import {
|
|
4
|
+
buildTurnkeyPayload,
|
|
5
|
+
computeMessagePayloadHash,
|
|
6
|
+
sendSigningRequest,
|
|
7
|
+
} from './signingUtils.js'
|
|
8
|
+
|
|
9
|
+
export type SignMessageParameters = {
|
|
10
|
+
/** The organization ID */
|
|
11
|
+
organizationId: string
|
|
12
|
+
/** The project ID for the request */
|
|
13
|
+
projectId: string
|
|
14
|
+
/** The session token for authorization */
|
|
15
|
+
token: string
|
|
16
|
+
/** The address to sign with */
|
|
17
|
+
address: Hex
|
|
18
|
+
/** The message to sign */
|
|
19
|
+
message: string
|
|
20
|
+
/** The encoding of the message ('utf8' or 'hex') */
|
|
21
|
+
encoding: 'utf8' | 'hex'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type SignMessageReturnType = Hex
|
|
25
|
+
|
|
26
|
+
export async function signMessage(
|
|
27
|
+
client: Client,
|
|
28
|
+
params: SignMessageParameters,
|
|
29
|
+
): Promise<SignMessageReturnType> {
|
|
30
|
+
const { organizationId, projectId, token, address, message, encoding } =
|
|
31
|
+
params
|
|
32
|
+
|
|
33
|
+
const payloadHash = computeMessagePayloadHash(message, encoding)
|
|
34
|
+
const turnkeyPayload = buildTurnkeyPayload(
|
|
35
|
+
organizationId,
|
|
36
|
+
address,
|
|
37
|
+
payloadHash,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
return sendSigningRequest(client, {
|
|
41
|
+
projectId,
|
|
42
|
+
token,
|
|
43
|
+
path: 'sign/message',
|
|
44
|
+
turnkeyPayload,
|
|
45
|
+
bodyFields: { message, encoding },
|
|
46
|
+
})
|
|
47
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Hex } from 'viem'
|
|
2
2
|
import type { Client } from '../../client/types.js'
|
|
3
|
+
import {
|
|
4
|
+
buildTurnkeyPayload,
|
|
5
|
+
computeDataPayloadHash,
|
|
6
|
+
sendSigningRequest,
|
|
7
|
+
} from './signingUtils.js'
|
|
3
8
|
|
|
4
9
|
export type SignTransactionParameters = {
|
|
5
10
|
/** The organization ID */
|
|
@@ -10,30 +15,12 @@ export type SignTransactionParameters = {
|
|
|
10
15
|
token: string
|
|
11
16
|
/** The address to sign with */
|
|
12
17
|
address: Hex
|
|
13
|
-
/** The unsigned transaction to sign */
|
|
18
|
+
/** The unsigned transaction to sign (hex without 0x prefix) */
|
|
14
19
|
unsignedTransaction: string
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export type SignTransactionReturnType = Hex
|
|
18
23
|
|
|
19
|
-
/**
|
|
20
|
-
* Signs a raw transaction with the user's wallet
|
|
21
|
-
*
|
|
22
|
-
* @param client - The ZeroDev Wallet client
|
|
23
|
-
* @param params - The parameters for signing
|
|
24
|
-
* @returns The signature
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* const result = await signTransaction(client, {
|
|
29
|
-
* organizationId: 'org_123',
|
|
30
|
-
* projectId: 'proj_456',
|
|
31
|
-
* address: '0x123...',
|
|
32
|
-
* unsignedTransaction: 'abc123...',
|
|
33
|
-
* });
|
|
34
|
-
* console.log(result.signature); // '0x...'
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
24
|
export async function signTransaction(
|
|
38
25
|
client: Client,
|
|
39
26
|
params: SignTransactionParameters,
|
|
@@ -41,24 +28,18 @@ export async function signTransaction(
|
|
|
41
28
|
const { organizationId, projectId, token, address, unsignedTransaction } =
|
|
42
29
|
params
|
|
43
30
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
parameters: {
|
|
51
|
-
signWith: address,
|
|
52
|
-
type: 'TRANSACTION_TYPE_ETHEREUM',
|
|
53
|
-
unsignedTransaction,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
headers: {
|
|
57
|
-
Authorization: `Bearer ${token}`,
|
|
58
|
-
},
|
|
59
|
-
stamp: true,
|
|
60
|
-
stampPostion: 'headers',
|
|
61
|
-
})
|
|
31
|
+
const payloadHash = computeDataPayloadHash(unsignedTransaction, 'hex')
|
|
32
|
+
const turnkeyPayload = buildTurnkeyPayload(
|
|
33
|
+
organizationId,
|
|
34
|
+
address,
|
|
35
|
+
payloadHash,
|
|
36
|
+
)
|
|
62
37
|
|
|
63
|
-
return
|
|
38
|
+
return sendSigningRequest(client, {
|
|
39
|
+
projectId,
|
|
40
|
+
token,
|
|
41
|
+
path: 'sign/transaction',
|
|
42
|
+
turnkeyPayload,
|
|
43
|
+
bodyFields: { unsignedTransaction },
|
|
44
|
+
})
|
|
64
45
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Hex } from 'viem'
|
|
2
|
+
import type { Client } from '../../client/types.js'
|
|
3
|
+
import { buildTurnkeyPayload, sendSigningRequest } from './signingUtils.js'
|
|
4
|
+
|
|
5
|
+
export type SignTypedDataV4Parameters = {
|
|
6
|
+
/** The organization ID */
|
|
7
|
+
organizationId: string
|
|
8
|
+
/** The project ID for the request */
|
|
9
|
+
projectId: string
|
|
10
|
+
/** The session token for authorization */
|
|
11
|
+
token: string
|
|
12
|
+
/** The address to sign with */
|
|
13
|
+
address: Hex
|
|
14
|
+
/** The serialized EIP-712 typed data to sign */
|
|
15
|
+
unsignedTypedDataV4: string
|
|
16
|
+
/** The encoding of the typed data ('utf8' or 'hex') */
|
|
17
|
+
encoding: 'utf8' | 'hex'
|
|
18
|
+
/** Pre-computed EIP-712 hash (hex without 0x prefix), used as the Turnkey payload. */
|
|
19
|
+
typedDataHash: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type SignTypedDataV4ReturnType = Hex
|
|
23
|
+
|
|
24
|
+
export async function signTypedDataV4(
|
|
25
|
+
client: Client,
|
|
26
|
+
params: SignTypedDataV4Parameters,
|
|
27
|
+
): Promise<SignTypedDataV4ReturnType> {
|
|
28
|
+
const {
|
|
29
|
+
organizationId,
|
|
30
|
+
projectId,
|
|
31
|
+
token,
|
|
32
|
+
address,
|
|
33
|
+
unsignedTypedDataV4,
|
|
34
|
+
encoding,
|
|
35
|
+
typedDataHash,
|
|
36
|
+
} = params
|
|
37
|
+
|
|
38
|
+
const payloadHash = typedDataHash
|
|
39
|
+
const turnkeyPayload = buildTurnkeyPayload(
|
|
40
|
+
organizationId,
|
|
41
|
+
address,
|
|
42
|
+
payloadHash,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return sendSigningRequest(client, {
|
|
46
|
+
projectId,
|
|
47
|
+
token,
|
|
48
|
+
path: 'sign/typed-data-v4',
|
|
49
|
+
turnkeyPayload,
|
|
50
|
+
bodyFields: { unsignedTypedDataV4, encoding },
|
|
51
|
+
})
|
|
52
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Hex } from 'viem'
|
|
2
|
+
import type { Client } from '../../client/types.js'
|
|
3
|
+
import {
|
|
4
|
+
buildTurnkeyPayload,
|
|
5
|
+
computeDataPayloadHash,
|
|
6
|
+
sendSigningRequest,
|
|
7
|
+
} from './signingUtils.js'
|
|
8
|
+
|
|
9
|
+
export type SignUserOperationParameters = {
|
|
10
|
+
/** The organization ID */
|
|
11
|
+
organizationId: string
|
|
12
|
+
/** The project ID for the request */
|
|
13
|
+
projectId: string
|
|
14
|
+
/** The session token for authorization */
|
|
15
|
+
token: string
|
|
16
|
+
/** The address to sign with */
|
|
17
|
+
address: Hex
|
|
18
|
+
/** The unsigned user operation to sign */
|
|
19
|
+
unsignedUserOperation: string
|
|
20
|
+
/** The chain ID for the user operation */
|
|
21
|
+
chainId: number
|
|
22
|
+
/** The encoding of the user operation ('utf8' or 'hex') */
|
|
23
|
+
encoding: 'utf8' | 'hex'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type SignUserOperationReturnType = Hex
|
|
27
|
+
|
|
28
|
+
export async function signUserOperation(
|
|
29
|
+
client: Client,
|
|
30
|
+
params: SignUserOperationParameters,
|
|
31
|
+
): Promise<SignUserOperationReturnType> {
|
|
32
|
+
const {
|
|
33
|
+
organizationId,
|
|
34
|
+
projectId,
|
|
35
|
+
token,
|
|
36
|
+
address,
|
|
37
|
+
unsignedUserOperation,
|
|
38
|
+
chainId,
|
|
39
|
+
encoding,
|
|
40
|
+
} = params
|
|
41
|
+
|
|
42
|
+
const payloadHash = computeDataPayloadHash(unsignedUserOperation, encoding)
|
|
43
|
+
const turnkeyPayload = buildTurnkeyPayload(
|
|
44
|
+
organizationId,
|
|
45
|
+
address,
|
|
46
|
+
payloadHash,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
return sendSigningRequest(client, {
|
|
50
|
+
projectId,
|
|
51
|
+
token,
|
|
52
|
+
path: 'sign/user-operation',
|
|
53
|
+
turnkeyPayload,
|
|
54
|
+
bodyFields: { unsignedUserOperation, chainId, encoding },
|
|
55
|
+
})
|
|
56
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { canonicalizeEx } from 'json-canonicalize'
|
|
2
|
+
import type { Hex } from 'viem'
|
|
3
|
+
import { hashMessage, keccak256, toHex } from 'viem'
|
|
4
|
+
import type { Client } from '../../client/types.js'
|
|
5
|
+
|
|
6
|
+
export type TurnkeyPayload = {
|
|
7
|
+
type: string
|
|
8
|
+
timestampMs: string
|
|
9
|
+
organizationId: string
|
|
10
|
+
parameters: {
|
|
11
|
+
signWith: string
|
|
12
|
+
payload: string
|
|
13
|
+
encoding: string
|
|
14
|
+
hashFunction: string
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function buildTurnkeyPayload(
|
|
19
|
+
organizationId: string,
|
|
20
|
+
address: Hex,
|
|
21
|
+
payloadHash: string,
|
|
22
|
+
): TurnkeyPayload {
|
|
23
|
+
return {
|
|
24
|
+
type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
|
|
25
|
+
timestampMs: Date.now().toString(),
|
|
26
|
+
organizationId,
|
|
27
|
+
parameters: {
|
|
28
|
+
signWith: address,
|
|
29
|
+
payload: payloadHash,
|
|
30
|
+
encoding: 'PAYLOAD_ENCODING_HEXADECIMAL',
|
|
31
|
+
hashFunction: 'HASH_FUNCTION_NO_OP',
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function sendSigningRequest(
|
|
37
|
+
client: Client,
|
|
38
|
+
params: {
|
|
39
|
+
projectId: string
|
|
40
|
+
token: string
|
|
41
|
+
path: string
|
|
42
|
+
turnkeyPayload: TurnkeyPayload
|
|
43
|
+
bodyFields: Record<string, unknown>
|
|
44
|
+
},
|
|
45
|
+
): Promise<Hex> {
|
|
46
|
+
const { projectId, token, path, turnkeyPayload, bodyFields } = params
|
|
47
|
+
|
|
48
|
+
// Inner stamp over the Turnkey payload (for Turnkey verification)
|
|
49
|
+
const innerBodyString = canonicalizeEx(turnkeyPayload)
|
|
50
|
+
const innerStamp = await client.apiKeyStamper.stamp(innerBodyString)
|
|
51
|
+
|
|
52
|
+
// Build full body with inner stamp embedded
|
|
53
|
+
const fullBody = {
|
|
54
|
+
...bodyFields,
|
|
55
|
+
turnkeyPayload,
|
|
56
|
+
stampHeader: {
|
|
57
|
+
stampHeaderName: innerStamp.stampHeaderName,
|
|
58
|
+
stampHeaderValue: innerStamp.stampHeaderValue,
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Outer stamp over full body (for KMS middleware)
|
|
63
|
+
const fullBodyString = canonicalizeEx(fullBody)
|
|
64
|
+
const outerStamp = await client.apiKeyStamper.stamp(fullBodyString)
|
|
65
|
+
|
|
66
|
+
const { signature } = await client.request({
|
|
67
|
+
path: `${projectId}/${path}`,
|
|
68
|
+
method: 'POST',
|
|
69
|
+
body: fullBody,
|
|
70
|
+
headers: {
|
|
71
|
+
[outerStamp.stampHeaderName]: outerStamp.stampHeaderValue,
|
|
72
|
+
Authorization: `Bearer ${token}`,
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
return (signature.startsWith('0x') ? signature : `0x${signature}`) as Hex
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Compute payload hash for message signing (EIP-191).
|
|
81
|
+
* Uses viem's hashMessage directly to guarantee correct EIP-191 hashing.
|
|
82
|
+
*/
|
|
83
|
+
export function computeMessagePayloadHash(
|
|
84
|
+
message: string,
|
|
85
|
+
encoding: 'utf8' | 'hex',
|
|
86
|
+
): string {
|
|
87
|
+
if (encoding === 'utf8') {
|
|
88
|
+
return hashMessage(message).slice(2)
|
|
89
|
+
}
|
|
90
|
+
const hex = message.replace(/^0x/, '')
|
|
91
|
+
return hashMessage({ raw: `0x${hex}` as Hex }).slice(2)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Compute payload hash for data signing (transaction, user operation).
|
|
96
|
+
* Hashes the raw decoded bytes: keccak256(hexDecode(hexData))
|
|
97
|
+
*/
|
|
98
|
+
export function computeDataPayloadHash(
|
|
99
|
+
data: string,
|
|
100
|
+
encoding: 'utf8' | 'hex',
|
|
101
|
+
): string {
|
|
102
|
+
let hexData: string
|
|
103
|
+
if (encoding === 'utf8') {
|
|
104
|
+
hexData = toHex(data).slice(2)
|
|
105
|
+
} else {
|
|
106
|
+
hexData = data.replace(/^0x/, '')
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return keccak256(`0x${hexData}` as Hex).slice(2)
|
|
110
|
+
}
|