@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.
Files changed (368) hide show
  1. package/README.md +68 -18
  2. package/dist/_cjs/actions/auth/authenticateWithEmail.js +1 -2
  3. package/dist/_cjs/actions/auth/authenticateWithEmail.js.map +1 -1
  4. package/dist/_cjs/actions/auth/authenticateWithOAuth.js +2 -3
  5. package/dist/_cjs/actions/auth/authenticateWithOAuth.js.map +1 -1
  6. package/dist/_cjs/actions/auth/getAuthProxyConfigId.js +10 -0
  7. package/dist/_cjs/actions/auth/getAuthProxyConfigId.js.map +1 -0
  8. package/dist/_cjs/actions/auth/getAuthenticators.js +16 -0
  9. package/dist/_cjs/actions/auth/getAuthenticators.js.map +1 -0
  10. package/dist/_cjs/actions/auth/getOAuthLoginUrl.js +18 -0
  11. package/dist/_cjs/actions/auth/getOAuthLoginUrl.js.map +1 -0
  12. package/dist/_cjs/actions/auth/getParentOrgId.js +10 -0
  13. package/dist/_cjs/actions/auth/getParentOrgId.js.map +1 -0
  14. package/dist/_cjs/actions/auth/getWhoami.js +18 -4
  15. package/dist/_cjs/actions/auth/getWhoami.js.map +1 -1
  16. package/dist/_cjs/actions/auth/index.js +9 -3
  17. package/dist/_cjs/actions/auth/index.js.map +1 -1
  18. package/dist/_cjs/actions/auth/loginWithStamp.js +5 -6
  19. package/dist/_cjs/actions/auth/loginWithStamp.js.map +1 -1
  20. package/dist/_cjs/actions/auth/registerWithOTP.js +1 -2
  21. package/dist/_cjs/actions/auth/registerWithOTP.js.map +1 -1
  22. package/dist/_cjs/actions/auth/registerWithPasskey.js +1 -2
  23. package/dist/_cjs/actions/auth/registerWithPasskey.js.map +1 -1
  24. package/dist/_cjs/actions/index.js +9 -3
  25. package/dist/_cjs/actions/index.js.map +1 -1
  26. package/dist/_cjs/actions/wallet/getUserWallet.js +3 -5
  27. package/dist/_cjs/actions/wallet/getUserWallet.js.map +1 -1
  28. package/dist/_cjs/actions/wallet/index.js +9 -3
  29. package/dist/_cjs/actions/wallet/index.js.map +1 -1
  30. package/dist/_cjs/actions/wallet/sign7702Authorization.js +16 -0
  31. package/dist/_cjs/actions/wallet/sign7702Authorization.js.map +1 -0
  32. package/dist/_cjs/actions/wallet/signMessage.js +17 -0
  33. package/dist/_cjs/actions/wallet/signMessage.js.map +1 -0
  34. package/dist/_cjs/actions/wallet/signTransaction.js +9 -18
  35. package/dist/_cjs/actions/wallet/signTransaction.js.map +1 -1
  36. package/dist/_cjs/actions/wallet/signTypedDataV4.js +17 -0
  37. package/dist/_cjs/actions/wallet/signTypedDataV4.js.map +1 -0
  38. package/dist/_cjs/actions/wallet/signUserOperation.js +17 -0
  39. package/dist/_cjs/actions/wallet/signUserOperation.js.map +1 -0
  40. package/dist/_cjs/actions/wallet/signingUtils.js +64 -0
  41. package/dist/_cjs/actions/wallet/signingUtils.js.map +1 -0
  42. package/dist/_cjs/adapters/viem.js +60 -27
  43. package/dist/_cjs/adapters/viem.js.map +1 -1
  44. package/dist/_cjs/client/authProxy.js +1 -1
  45. package/dist/_cjs/client/authProxy.js.map +1 -1
  46. package/dist/_cjs/client/createClient.js +5 -5
  47. package/dist/_cjs/client/createClient.js.map +1 -1
  48. package/dist/_cjs/client/decorators/client.js +9 -4
  49. package/dist/_cjs/client/decorators/client.js.map +1 -1
  50. package/dist/_cjs/client/index.js.map +1 -1
  51. package/dist/_cjs/client/transports/createTransport.js +6 -5
  52. package/dist/_cjs/client/transports/createTransport.js.map +1 -1
  53. package/dist/_cjs/client/transports/rest.js +40 -28
  54. package/dist/_cjs/client/transports/rest.js.map +1 -1
  55. package/dist/_cjs/constants.js +4 -4
  56. package/dist/_cjs/constants.js.map +1 -1
  57. package/dist/_cjs/core/{createZeroDevWallet.js → createZeroDevWalletCore.js} +94 -86
  58. package/dist/_cjs/core/createZeroDevWalletCore.js.map +1 -0
  59. package/dist/_cjs/index.js +14 -8
  60. package/dist/_cjs/index.js.map +1 -1
  61. package/dist/_cjs/index.native.js +39 -0
  62. package/dist/_cjs/index.native.js.map +1 -0
  63. package/dist/_cjs/native/createZeroDevWallet.js +13 -0
  64. package/dist/_cjs/native/createZeroDevWallet.js.map +1 -0
  65. package/dist/_cjs/native/stampers/passkey.js +30 -0
  66. package/dist/_cjs/native/stampers/passkey.js.map +1 -0
  67. package/dist/_cjs/native/stampers/secureStore.js +112 -0
  68. package/dist/_cjs/native/stampers/secureStore.js.map +1 -0
  69. package/dist/_cjs/native/storage/asyncStorage.js +11 -0
  70. package/dist/_cjs/native/storage/asyncStorage.js.map +1 -0
  71. package/dist/_cjs/stampers/iframeStamper.js +3 -0
  72. package/dist/_cjs/stampers/iframeStamper.js.map +1 -1
  73. package/dist/_cjs/stampers/indexedDbStamper.js +20 -2
  74. package/dist/_cjs/stampers/indexedDbStamper.js.map +1 -1
  75. package/dist/_cjs/stampers/noopPasskeyStamper.js +16 -0
  76. package/dist/_cjs/stampers/noopPasskeyStamper.js.map +1 -0
  77. package/dist/_cjs/stampers/webauthnStamper.js +23 -3
  78. package/dist/_cjs/stampers/webauthnStamper.js.map +1 -1
  79. package/dist/_cjs/stubs/native-on-web.js +12 -0
  80. package/dist/_cjs/stubs/native-on-web.js.map +1 -0
  81. package/dist/_cjs/utils/encryptOtpAttempt.js +57 -0
  82. package/dist/_cjs/utils/encryptOtpAttempt.js.map +1 -0
  83. package/dist/_cjs/utils/exportPrivateKey.js +1 -1
  84. package/dist/_cjs/utils/exportPrivateKey.js.map +1 -1
  85. package/dist/_cjs/utils/exportWallet.js +52 -61
  86. package/dist/_cjs/utils/exportWallet.js.map +1 -1
  87. package/dist/_cjs/utils/hpke.js +78 -0
  88. package/dist/_cjs/utils/hpke.js.map +1 -0
  89. package/dist/_cjs/utils/platform.js +19 -0
  90. package/dist/_cjs/utils/platform.js.map +1 -0
  91. package/dist/_cjs/utils/resolveOrganizationId.js +20 -0
  92. package/dist/_cjs/utils/resolveOrganizationId.js.map +1 -0
  93. package/dist/_cjs/utils/utils.js +5 -6
  94. package/dist/_cjs/utils/utils.js.map +1 -1
  95. package/dist/_cjs/web/createZeroDevWallet.js +21 -0
  96. package/dist/_cjs/web/createZeroDevWallet.js.map +1 -0
  97. package/dist/_esm/actions/auth/authenticateWithEmail.js +1 -2
  98. package/dist/_esm/actions/auth/authenticateWithEmail.js.map +1 -1
  99. package/dist/_esm/actions/auth/authenticateWithOAuth.js +8 -7
  100. package/dist/_esm/actions/auth/authenticateWithOAuth.js.map +1 -1
  101. package/dist/_esm/actions/auth/getAuthProxyConfigId.js +13 -0
  102. package/dist/_esm/actions/auth/getAuthProxyConfigId.js.map +1 -0
  103. package/dist/_esm/actions/auth/getAuthenticators.js +36 -0
  104. package/dist/_esm/actions/auth/getAuthenticators.js.map +1 -0
  105. package/dist/_esm/actions/auth/getOAuthLoginUrl.js +23 -0
  106. package/dist/_esm/actions/auth/getOAuthLoginUrl.js.map +1 -0
  107. package/dist/_esm/actions/auth/getParentOrgId.js +17 -0
  108. package/dist/_esm/actions/auth/getParentOrgId.js.map +1 -0
  109. package/dist/_esm/actions/auth/getWhoami.js +28 -6
  110. package/dist/_esm/actions/auth/getWhoami.js.map +1 -1
  111. package/dist/_esm/actions/auth/index.js +4 -1
  112. package/dist/_esm/actions/auth/index.js.map +1 -1
  113. package/dist/_esm/actions/auth/loginWithStamp.js +9 -6
  114. package/dist/_esm/actions/auth/loginWithStamp.js.map +1 -1
  115. package/dist/_esm/actions/auth/registerWithOTP.js +5 -2
  116. package/dist/_esm/actions/auth/registerWithOTP.js.map +1 -1
  117. package/dist/_esm/actions/auth/registerWithPasskey.js +1 -3
  118. package/dist/_esm/actions/auth/registerWithPasskey.js.map +1 -1
  119. package/dist/_esm/actions/index.js +2 -2
  120. package/dist/_esm/actions/index.js.map +1 -1
  121. package/dist/_esm/actions/wallet/getUserWallet.js +5 -5
  122. package/dist/_esm/actions/wallet/getUserWallet.js.map +1 -1
  123. package/dist/_esm/actions/wallet/index.js +4 -1
  124. package/dist/_esm/actions/wallet/index.js.map +1 -1
  125. package/dist/_esm/actions/wallet/sign7702Authorization.js +13 -0
  126. package/dist/_esm/actions/wallet/sign7702Authorization.js.map +1 -0
  127. package/dist/_esm/actions/wallet/signMessage.js +14 -0
  128. package/dist/_esm/actions/wallet/signMessage.js.map +1 -0
  129. package/dist/_esm/actions/wallet/signTransaction.js +9 -36
  130. package/dist/_esm/actions/wallet/signTransaction.js.map +1 -1
  131. package/dist/_esm/actions/wallet/signTypedDataV4.js +14 -0
  132. package/dist/_esm/actions/wallet/signTypedDataV4.js.map +1 -0
  133. package/dist/_esm/actions/wallet/signUserOperation.js +14 -0
  134. package/dist/_esm/actions/wallet/signUserOperation.js.map +1 -0
  135. package/dist/_esm/actions/wallet/signingUtils.js +69 -0
  136. package/dist/_esm/actions/wallet/signingUtils.js.map +1 -0
  137. package/dist/_esm/adapters/viem.js +63 -30
  138. package/dist/_esm/adapters/viem.js.map +1 -1
  139. package/dist/_esm/client/authProxy.js +9 -4
  140. package/dist/_esm/client/authProxy.js.map +1 -1
  141. package/dist/_esm/client/createClient.js +5 -5
  142. package/dist/_esm/client/createClient.js.map +1 -1
  143. package/dist/_esm/client/decorators/client.js +9 -4
  144. package/dist/_esm/client/decorators/client.js.map +1 -1
  145. package/dist/_esm/client/index.js +1 -1
  146. package/dist/_esm/client/index.js.map +1 -1
  147. package/dist/_esm/client/transports/createTransport.js +6 -5
  148. package/dist/_esm/client/transports/createTransport.js.map +1 -1
  149. package/dist/_esm/client/transports/rest.js +44 -29
  150. package/dist/_esm/client/transports/rest.js.map +1 -1
  151. package/dist/_esm/constants.js +10 -3
  152. package/dist/_esm/constants.js.map +1 -1
  153. package/dist/_esm/core/{createZeroDevWallet.js → createZeroDevWalletCore.js} +115 -90
  154. package/dist/_esm/core/createZeroDevWalletCore.js.map +1 -0
  155. package/dist/_esm/index.js +13 -5
  156. package/dist/_esm/index.js.map +1 -1
  157. package/dist/_esm/index.native.js +19 -0
  158. package/dist/_esm/index.native.js.map +1 -0
  159. package/dist/_esm/native/createZeroDevWallet.js +10 -0
  160. package/dist/_esm/native/createZeroDevWallet.js.map +1 -0
  161. package/dist/_esm/native/stampers/passkey.js +27 -0
  162. package/dist/_esm/native/stampers/passkey.js.map +1 -0
  163. package/dist/_esm/native/stampers/secureStore.js +120 -0
  164. package/dist/_esm/native/stampers/secureStore.js.map +1 -0
  165. package/dist/_esm/native/storage/asyncStorage.js +13 -0
  166. package/dist/_esm/native/storage/asyncStorage.js.map +1 -0
  167. package/dist/_esm/stampers/iframeStamper.js +3 -0
  168. package/dist/_esm/stampers/iframeStamper.js.map +1 -1
  169. package/dist/_esm/stampers/indexedDbStamper.js +20 -2
  170. package/dist/_esm/stampers/indexedDbStamper.js.map +1 -1
  171. package/dist/_esm/stampers/noopPasskeyStamper.js +18 -0
  172. package/dist/_esm/stampers/noopPasskeyStamper.js.map +1 -0
  173. package/dist/_esm/stampers/webauthnStamper.js +23 -4
  174. package/dist/_esm/stampers/webauthnStamper.js.map +1 -1
  175. package/dist/_esm/stubs/native-on-web.js +25 -0
  176. package/dist/_esm/stubs/native-on-web.js.map +1 -0
  177. package/dist/_esm/utils/encryptOtpAttempt.js +81 -0
  178. package/dist/_esm/utils/encryptOtpAttempt.js.map +1 -0
  179. package/dist/_esm/utils/exportPrivateKey.js +1 -1
  180. package/dist/_esm/utils/exportPrivateKey.js.map +1 -1
  181. package/dist/_esm/utils/exportWallet.js +52 -61
  182. package/dist/_esm/utils/exportWallet.js.map +1 -1
  183. package/dist/_esm/utils/hpke.js +119 -0
  184. package/dist/_esm/utils/hpke.js.map +1 -0
  185. package/dist/_esm/utils/platform.js +16 -0
  186. package/dist/_esm/utils/platform.js.map +1 -0
  187. package/dist/_esm/utils/resolveOrganizationId.js +27 -0
  188. package/dist/_esm/utils/resolveOrganizationId.js.map +1 -0
  189. package/dist/_esm/utils/utils.js +5 -6
  190. package/dist/_esm/utils/utils.js.map +1 -1
  191. package/dist/_esm/web/createZeroDevWallet.js +18 -0
  192. package/dist/_esm/web/createZeroDevWallet.js.map +1 -0
  193. package/dist/_types/actions/auth/authenticateWithEmail.d.ts +0 -6
  194. package/dist/_types/actions/auth/authenticateWithEmail.d.ts.map +1 -1
  195. package/dist/_types/actions/auth/authenticateWithOAuth.d.ts +10 -4
  196. package/dist/_types/actions/auth/authenticateWithOAuth.d.ts.map +1 -1
  197. package/dist/_types/actions/auth/getAuthProxyConfigId.d.ts +12 -0
  198. package/dist/_types/actions/auth/getAuthProxyConfigId.d.ts.map +1 -0
  199. package/dist/_types/actions/auth/getAuthenticators.d.ts +65 -0
  200. package/dist/_types/actions/auth/getAuthenticators.d.ts.map +1 -0
  201. package/dist/_types/actions/auth/getOAuthLoginUrl.d.ts +30 -0
  202. package/dist/_types/actions/auth/getOAuthLoginUrl.d.ts.map +1 -0
  203. package/dist/_types/actions/auth/getParentOrgId.d.ts +17 -0
  204. package/dist/_types/actions/auth/getParentOrgId.d.ts.map +1 -0
  205. package/dist/_types/actions/auth/getWhoami.d.ts +9 -2
  206. package/dist/_types/actions/auth/getWhoami.d.ts.map +1 -1
  207. package/dist/_types/actions/auth/index.d.ts +5 -2
  208. package/dist/_types/actions/auth/index.d.ts.map +1 -1
  209. package/dist/_types/actions/auth/loginWithStamp.d.ts +2 -5
  210. package/dist/_types/actions/auth/loginWithStamp.d.ts.map +1 -1
  211. package/dist/_types/actions/auth/registerWithOTP.d.ts +10 -3
  212. package/dist/_types/actions/auth/registerWithOTP.d.ts.map +1 -1
  213. package/dist/_types/actions/auth/registerWithPasskey.d.ts +0 -7
  214. package/dist/_types/actions/auth/registerWithPasskey.d.ts.map +1 -1
  215. package/dist/_types/actions/index.d.ts +2 -2
  216. package/dist/_types/actions/index.d.ts.map +1 -1
  217. package/dist/_types/actions/wallet/index.d.ts +4 -1
  218. package/dist/_types/actions/wallet/index.d.ts.map +1 -1
  219. package/dist/_types/actions/wallet/sign7702Authorization.d.ts +19 -0
  220. package/dist/_types/actions/wallet/sign7702Authorization.d.ts.map +1 -0
  221. package/dist/_types/actions/wallet/signMessage.d.ts +19 -0
  222. package/dist/_types/actions/wallet/signMessage.d.ts.map +1 -0
  223. package/dist/_types/actions/wallet/signTransaction.d.ts +1 -19
  224. package/dist/_types/actions/wallet/signTransaction.d.ts.map +1 -1
  225. package/dist/_types/actions/wallet/signTypedDataV4.d.ts +21 -0
  226. package/dist/_types/actions/wallet/signTypedDataV4.d.ts.map +1 -0
  227. package/dist/_types/actions/wallet/signUserOperation.d.ts +21 -0
  228. package/dist/_types/actions/wallet/signUserOperation.d.ts.map +1 -0
  229. package/dist/_types/actions/wallet/signingUtils.d.ts +32 -0
  230. package/dist/_types/actions/wallet/signingUtils.d.ts.map +1 -0
  231. package/dist/_types/adapters/viem.d.ts +1 -1
  232. package/dist/_types/adapters/viem.d.ts.map +1 -1
  233. package/dist/_types/client/authProxy.d.ts +13 -7
  234. package/dist/_types/client/authProxy.d.ts.map +1 -1
  235. package/dist/_types/client/decorators/client.d.ts +32 -6
  236. package/dist/_types/client/decorators/client.d.ts.map +1 -1
  237. package/dist/_types/client/index.d.ts +1 -1
  238. package/dist/_types/client/index.d.ts.map +1 -1
  239. package/dist/_types/client/transports/createTransport.d.ts +2 -0
  240. package/dist/_types/client/transports/createTransport.d.ts.map +1 -1
  241. package/dist/_types/client/transports/rest.d.ts +13 -5
  242. package/dist/_types/client/transports/rest.d.ts.map +1 -1
  243. package/dist/_types/client/types.d.ts +9 -9
  244. package/dist/_types/client/types.d.ts.map +1 -1
  245. package/dist/_types/constants.d.ts +3 -3
  246. package/dist/_types/constants.d.ts.map +1 -1
  247. package/dist/_types/core/{createZeroDevWallet.d.ts → createZeroDevWalletCore.d.ts} +30 -10
  248. package/dist/_types/core/createZeroDevWalletCore.d.ts.map +1 -0
  249. package/dist/_types/index.d.ts +7 -7
  250. package/dist/_types/index.d.ts.map +1 -1
  251. package/dist/_types/index.native.d.ts +19 -0
  252. package/dist/_types/index.native.d.ts.map +1 -0
  253. package/dist/_types/native/createZeroDevWallet.d.ts +12 -0
  254. package/dist/_types/native/createZeroDevWallet.d.ts.map +1 -0
  255. package/dist/_types/native/stampers/passkey.d.ts +5 -0
  256. package/dist/_types/native/stampers/passkey.d.ts.map +1 -0
  257. package/dist/_types/native/stampers/secureStore.d.ts +3 -0
  258. package/dist/_types/native/stampers/secureStore.d.ts.map +1 -0
  259. package/dist/_types/native/storage/asyncStorage.d.ts +3 -0
  260. package/dist/_types/native/storage/asyncStorage.d.ts.map +1 -0
  261. package/dist/_types/stampers/iframeStamper.d.ts.map +1 -1
  262. package/dist/_types/stampers/indexedDbStamper.d.ts +2 -2
  263. package/dist/_types/stampers/indexedDbStamper.d.ts.map +1 -1
  264. package/dist/_types/stampers/noopPasskeyStamper.d.ts +8 -0
  265. package/dist/_types/stampers/noopPasskeyStamper.d.ts.map +1 -0
  266. package/dist/_types/stampers/types.d.ts +39 -5
  267. package/dist/_types/stampers/types.d.ts.map +1 -1
  268. package/dist/_types/stampers/webauthnStamper.d.ts +2 -2
  269. package/dist/_types/stampers/webauthnStamper.d.ts.map +1 -1
  270. package/dist/_types/stubs/native-on-web.d.ts +6 -0
  271. package/dist/_types/stubs/native-on-web.d.ts.map +1 -0
  272. package/dist/_types/types/session.d.ts +2 -3
  273. package/dist/_types/types/session.d.ts.map +1 -1
  274. package/dist/_types/utils/buildClientSignature.d.ts +3 -3
  275. package/dist/_types/utils/buildClientSignature.d.ts.map +1 -1
  276. package/dist/_types/utils/encryptOtpAttempt.d.ts +40 -0
  277. package/dist/_types/utils/encryptOtpAttempt.d.ts.map +1 -0
  278. package/dist/_types/utils/exportPrivateKey.d.ts +1 -1
  279. package/dist/_types/utils/exportPrivateKey.d.ts.map +1 -1
  280. package/dist/_types/utils/exportWallet.d.ts +1 -1
  281. package/dist/_types/utils/exportWallet.d.ts.map +1 -1
  282. package/dist/_types/utils/hpke.d.ts +38 -0
  283. package/dist/_types/utils/hpke.d.ts.map +1 -0
  284. package/dist/_types/utils/platform.d.ts +2 -0
  285. package/dist/_types/utils/platform.d.ts.map +1 -0
  286. package/dist/_types/utils/resolveOrganizationId.d.ts +16 -0
  287. package/dist/_types/utils/resolveOrganizationId.d.ts.map +1 -0
  288. package/dist/_types/utils/utils.d.ts.map +1 -1
  289. package/dist/_types/web/createZeroDevWallet.d.ts +18 -0
  290. package/dist/_types/web/createZeroDevWallet.d.ts.map +1 -0
  291. package/dist/tsconfig.build.tsbuildinfo +1 -1
  292. package/package.json +100 -11
  293. package/src/actions/auth/authenticateWithEmail.ts +1 -9
  294. package/src/actions/auth/authenticateWithOAuth.ts +12 -7
  295. package/src/actions/auth/getAuthProxyConfigId.ts +20 -0
  296. package/src/actions/auth/getAuthenticators.ts +89 -0
  297. package/src/actions/auth/getOAuthLoginUrl.ts +48 -0
  298. package/src/actions/auth/getParentOrgId.ts +25 -0
  299. package/src/actions/auth/getWhoami.ts +33 -6
  300. package/src/actions/auth/index.ts +21 -5
  301. package/src/actions/auth/loginWithStamp.ts +11 -12
  302. package/src/actions/auth/registerWithOTP.ts +11 -5
  303. package/src/actions/auth/registerWithPasskey.ts +1 -10
  304. package/src/actions/index.ts +26 -7
  305. package/src/actions/wallet/getUserWallet.ts +5 -5
  306. package/src/actions/wallet/index.ts +22 -4
  307. package/src/actions/wallet/sign7702Authorization.ts +48 -0
  308. package/src/actions/wallet/signMessage.ts +47 -0
  309. package/src/actions/wallet/signTransaction.ts +19 -38
  310. package/src/actions/wallet/signTypedDataV4.ts +52 -0
  311. package/src/actions/wallet/signUserOperation.ts +56 -0
  312. package/src/actions/wallet/signingUtils.ts +110 -0
  313. package/src/adapters/viem.ts +75 -43
  314. package/src/client/authProxy.ts +14 -8
  315. package/src/client/createClient.ts +6 -6
  316. package/src/client/decorators/client.ts +78 -19
  317. package/src/client/index.ts +4 -1
  318. package/src/client/transports/createTransport.ts +8 -5
  319. package/src/client/transports/rest.ts +57 -34
  320. package/src/client/types.ts +9 -9
  321. package/src/constants.ts +12 -4
  322. package/src/core/{createZeroDevWallet.ts → createZeroDevWalletCore.ts} +147 -122
  323. package/src/index.native.ts +102 -0
  324. package/src/index.ts +49 -16
  325. package/src/native/createZeroDevWallet.ts +26 -0
  326. package/src/native/stampers/passkey.ts +39 -0
  327. package/src/native/stampers/secureStore.ts +139 -0
  328. package/src/native/storage/asyncStorage.ts +18 -0
  329. package/src/stampers/iframeStamper.ts +3 -0
  330. package/src/stampers/indexedDbStamper.ts +27 -4
  331. package/src/stampers/noopPasskeyStamper.ts +21 -0
  332. package/src/stampers/types.ts +39 -5
  333. package/src/stampers/webauthnStamper.ts +27 -6
  334. package/src/stubs/native-on-web.ts +29 -0
  335. package/src/types/session.ts +2 -3
  336. package/src/utils/buildClientSignature.ts +3 -3
  337. package/src/utils/encryptOtpAttempt.ts +142 -0
  338. package/src/utils/exportPrivateKey.ts +2 -2
  339. package/src/utils/exportWallet.ts +66 -75
  340. package/src/utils/hpke.ts +219 -0
  341. package/src/utils/platform.ts +21 -0
  342. package/src/utils/resolveOrganizationId.ts +28 -0
  343. package/src/utils/utils.ts +5 -6
  344. package/src/web/createZeroDevWallet.ts +45 -0
  345. package/dist/_cjs/actions/auth/getUserEmail.js +0 -19
  346. package/dist/_cjs/actions/auth/getUserEmail.js.map +0 -1
  347. package/dist/_cjs/actions/wallet/signRawPayload.js +0 -27
  348. package/dist/_cjs/actions/wallet/signRawPayload.js.map +0 -1
  349. package/dist/_cjs/core/createZeroDevWallet.js.map +0 -1
  350. package/dist/_cjs/stampers/index.js +0 -10
  351. package/dist/_cjs/stampers/index.js.map +0 -1
  352. package/dist/_esm/actions/auth/getUserEmail.js +0 -33
  353. package/dist/_esm/actions/auth/getUserEmail.js.map +0 -1
  354. package/dist/_esm/actions/wallet/signRawPayload.js +0 -42
  355. package/dist/_esm/actions/wallet/signRawPayload.js.map +0 -1
  356. package/dist/_esm/core/createZeroDevWallet.js.map +0 -1
  357. package/dist/_esm/stampers/index.js +0 -4
  358. package/dist/_esm/stampers/index.js.map +0 -1
  359. package/dist/_types/actions/auth/getUserEmail.d.ts +0 -32
  360. package/dist/_types/actions/auth/getUserEmail.d.ts.map +0 -1
  361. package/dist/_types/actions/wallet/signRawPayload.d.ts +0 -39
  362. package/dist/_types/actions/wallet/signRawPayload.d.ts.map +0 -1
  363. package/dist/_types/core/createZeroDevWallet.d.ts.map +0 -1
  364. package/dist/_types/stampers/index.d.ts +0 -5
  365. package/dist/_types/stampers/index.d.ts.map +0 -1
  366. package/src/actions/auth/getUserEmail.ts +0 -52
  367. package/src/actions/wallet/signRawPayload.ts +0 -75
  368. 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-alpha.9",
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
- "types": "./dist/_types/index.d.ts",
11
- "import": "./dist/_esm/index.js",
12
- "require": "./dist/_cjs/index.js"
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
- "typescript": "5.9.3"
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, emailCustomization } = params
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 cookie-based backend flow
26
+ * Authenticates a user with OAuth using a server-side session ID
23
27
  *
24
- * The backend reads the OAuth session from a cookie set during the OAuth flow.
25
- * This requires the OAuth popup flow to complete first via the backend's
26
- * /oauth/google/login endpoint.
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: null,
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
- organizationId,
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 GetUserEmailParameters,
15
- type GetUserEmailReturnType,
16
- getUserEmail,
17
- } from './getUserEmail.js'
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?: 'indexedDb' | 'webauthn'
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 === 'indexedDb') {
62
- stamp = await client.indexedDbStamper.stamp(stampPayload)
63
- } else if (stampWith === 'webauthn') {
64
- stamp = await client.webauthnStamper.stamp(stampPayload)
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.indexedDbStamper.stamp(stampPayload)
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, emailCustomization } = params
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 { email, projectId, challenge, attestation, encodedPublicKey } = params
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,