@sirketio/auth 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 (594) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +36 -0
  2. package/dist/adapter/index.d.mts +4 -0
  3. package/dist/adapter/index.mjs +7 -0
  4. package/dist/api/index.d.mts +3872 -0
  5. package/dist/api/index.mjs +206 -0
  6. package/dist/api/index.mjs.map +1 -0
  7. package/dist/api/middlewares/index.d.mts +1 -0
  8. package/dist/api/middlewares/index.mjs +3 -0
  9. package/dist/api/middlewares/origin-check.d.mts +18 -0
  10. package/dist/api/middlewares/origin-check.mjs +140 -0
  11. package/dist/api/middlewares/origin-check.mjs.map +1 -0
  12. package/dist/api/rate-limiter/index.mjs +204 -0
  13. package/dist/api/rate-limiter/index.mjs.map +1 -0
  14. package/dist/api/routes/account.d.mts +410 -0
  15. package/dist/api/routes/account.mjs +493 -0
  16. package/dist/api/routes/account.mjs.map +1 -0
  17. package/dist/api/routes/callback.d.mts +31 -0
  18. package/dist/api/routes/callback.mjs +179 -0
  19. package/dist/api/routes/callback.mjs.map +1 -0
  20. package/dist/api/routes/email-verification.d.mts +161 -0
  21. package/dist/api/routes/email-verification.mjs +299 -0
  22. package/dist/api/routes/email-verification.mjs.map +1 -0
  23. package/dist/api/routes/error.d.mts +28 -0
  24. package/dist/api/routes/error.mjs +386 -0
  25. package/dist/api/routes/error.mjs.map +1 -0
  26. package/dist/api/routes/index.d.mts +11 -0
  27. package/dist/api/routes/index.mjs +13 -0
  28. package/dist/api/routes/ok.d.mts +36 -0
  29. package/dist/api/routes/ok.mjs +30 -0
  30. package/dist/api/routes/ok.mjs.map +1 -0
  31. package/dist/api/routes/password.d.mts +182 -0
  32. package/dist/api/routes/password.mjs +198 -0
  33. package/dist/api/routes/password.mjs.map +1 -0
  34. package/dist/api/routes/session.d.mts +415 -0
  35. package/dist/api/routes/session.mjs +483 -0
  36. package/dist/api/routes/session.mjs.map +1 -0
  37. package/dist/api/routes/sign-in.d.mts +171 -0
  38. package/dist/api/routes/sign-in.mjs +263 -0
  39. package/dist/api/routes/sign-in.mjs.map +1 -0
  40. package/dist/api/routes/sign-out.d.mts +36 -0
  41. package/dist/api/routes/sign-out.mjs +33 -0
  42. package/dist/api/routes/sign-out.mjs.map +1 -0
  43. package/dist/api/routes/sign-up.d.mts +160 -0
  44. package/dist/api/routes/sign-up.mjs +227 -0
  45. package/dist/api/routes/sign-up.mjs.map +1 -0
  46. package/dist/api/routes/update-user.d.mts +445 -0
  47. package/dist/api/routes/update-user.mjs +493 -0
  48. package/dist/api/routes/update-user.mjs.map +1 -0
  49. package/dist/api/state/oauth.d.mts +18 -0
  50. package/dist/api/state/oauth.mjs +8 -0
  51. package/dist/api/state/oauth.mjs.map +1 -0
  52. package/dist/api/state/should-session-refresh.d.mts +13 -0
  53. package/dist/api/state/should-session-refresh.mjs +16 -0
  54. package/dist/api/state/should-session-refresh.mjs.map +1 -0
  55. package/dist/api/to-auth-endpoints.mjs +197 -0
  56. package/dist/api/to-auth-endpoints.mjs.map +1 -0
  57. package/dist/auth/base.mjs +45 -0
  58. package/dist/auth/base.mjs.map +1 -0
  59. package/dist/auth/minimal.d.mts +12 -0
  60. package/dist/auth/minimal.mjs +14 -0
  61. package/dist/auth/minimal.mjs.map +1 -0
  62. package/dist/auth/trusted-origins.mjs +31 -0
  63. package/dist/auth/trusted-origins.mjs.map +1 -0
  64. package/dist/client/broadcast-channel.d.mts +20 -0
  65. package/dist/client/broadcast-channel.mjs +46 -0
  66. package/dist/client/broadcast-channel.mjs.map +1 -0
  67. package/dist/client/config.mjs +90 -0
  68. package/dist/client/config.mjs.map +1 -0
  69. package/dist/client/fetch-plugins.mjs +18 -0
  70. package/dist/client/fetch-plugins.mjs.map +1 -0
  71. package/dist/client/focus-manager.d.mts +11 -0
  72. package/dist/client/focus-manager.mjs +32 -0
  73. package/dist/client/focus-manager.mjs.map +1 -0
  74. package/dist/client/index.d.mts +33 -0
  75. package/dist/client/index.mjs +21 -0
  76. package/dist/client/index.mjs.map +1 -0
  77. package/dist/client/online-manager.d.mts +12 -0
  78. package/dist/client/online-manager.mjs +35 -0
  79. package/dist/client/online-manager.mjs.map +1 -0
  80. package/dist/client/parser.mjs +73 -0
  81. package/dist/client/parser.mjs.map +1 -0
  82. package/dist/client/path-to-object.d.mts +65 -0
  83. package/dist/client/plugins/index.d.mts +53 -0
  84. package/dist/client/plugins/index.mjs +30 -0
  85. package/dist/client/plugins/infer-plugin.d.mts +16 -0
  86. package/dist/client/plugins/infer-plugin.mjs +11 -0
  87. package/dist/client/plugins/infer-plugin.mjs.map +1 -0
  88. package/dist/client/proxy.mjs +79 -0
  89. package/dist/client/proxy.mjs.map +1 -0
  90. package/dist/client/query.d.mts +23 -0
  91. package/dist/client/query.mjs +98 -0
  92. package/dist/client/query.mjs.map +1 -0
  93. package/dist/client/react/index.d.mts +128 -0
  94. package/dist/client/react/index.mjs +24 -0
  95. package/dist/client/react/index.mjs.map +1 -0
  96. package/dist/client/react/react-store.d.mts +47 -0
  97. package/dist/client/react/react-store.mjs +47 -0
  98. package/dist/client/react/react-store.mjs.map +1 -0
  99. package/dist/client/session-atom.mjs +29 -0
  100. package/dist/client/session-atom.mjs.map +1 -0
  101. package/dist/client/session-refresh.d.mts +28 -0
  102. package/dist/client/session-refresh.mjs +140 -0
  103. package/dist/client/session-refresh.mjs.map +1 -0
  104. package/dist/client/types.d.mts +41 -0
  105. package/dist/client/vanilla.d.mts +127 -0
  106. package/dist/client/vanilla.mjs +20 -0
  107. package/dist/client/vanilla.mjs.map +1 -0
  108. package/dist/context/create-context.mjs +211 -0
  109. package/dist/context/create-context.mjs.map +1 -0
  110. package/dist/context/helpers.mjs +83 -0
  111. package/dist/context/helpers.mjs.map +1 -0
  112. package/dist/context/init.mjs +20 -0
  113. package/dist/context/init.mjs.map +1 -0
  114. package/dist/cookies/cookie-utils.d.mts +29 -0
  115. package/dist/cookies/cookie-utils.mjs +105 -0
  116. package/dist/cookies/cookie-utils.mjs.map +1 -0
  117. package/dist/cookies/index.d.mts +121 -0
  118. package/dist/cookies/index.mjs +261 -0
  119. package/dist/cookies/index.mjs.map +1 -0
  120. package/dist/cookies/session-store.d.mts +36 -0
  121. package/dist/cookies/session-store.mjs +200 -0
  122. package/dist/cookies/session-store.mjs.map +1 -0
  123. package/dist/crypto/buffer.d.mts +8 -0
  124. package/dist/crypto/buffer.mjs +18 -0
  125. package/dist/crypto/buffer.mjs.map +1 -0
  126. package/dist/crypto/index.d.mts +27 -0
  127. package/dist/crypto/index.mjs +38 -0
  128. package/dist/crypto/index.mjs.map +1 -0
  129. package/dist/crypto/jwt.d.mts +8 -0
  130. package/dist/crypto/jwt.mjs +95 -0
  131. package/dist/crypto/jwt.mjs.map +1 -0
  132. package/dist/crypto/password.d.mts +12 -0
  133. package/dist/crypto/password.mjs +36 -0
  134. package/dist/crypto/password.mjs.map +1 -0
  135. package/dist/crypto/random.d.mts +5 -0
  136. package/dist/crypto/random.mjs +8 -0
  137. package/dist/crypto/random.mjs.map +1 -0
  138. package/dist/db/adapter-base.d.mts +8 -0
  139. package/dist/db/adapter-base.mjs +19 -0
  140. package/dist/db/adapter-base.mjs.map +1 -0
  141. package/dist/db/field-converter.d.mts +8 -0
  142. package/dist/db/field-converter.mjs +21 -0
  143. package/dist/db/field-converter.mjs.map +1 -0
  144. package/dist/db/field.d.mts +42 -0
  145. package/dist/db/get-schema.d.mts +11 -0
  146. package/dist/db/get-schema.mjs +39 -0
  147. package/dist/db/get-schema.mjs.map +1 -0
  148. package/dist/db/index.d.mts +18 -0
  149. package/dist/db/index.mjs +34 -0
  150. package/dist/db/index.mjs.map +1 -0
  151. package/dist/db/internal-adapter.d.mts +14 -0
  152. package/dist/db/internal-adapter.mjs +616 -0
  153. package/dist/db/internal-adapter.mjs.map +1 -0
  154. package/dist/db/schema.d.mts +49 -0
  155. package/dist/db/schema.mjs +118 -0
  156. package/dist/db/schema.mjs.map +1 -0
  157. package/dist/db/to-zod.d.mts +36 -0
  158. package/dist/db/to-zod.mjs +26 -0
  159. package/dist/db/to-zod.mjs.map +1 -0
  160. package/dist/db/verification-token-storage.mjs +28 -0
  161. package/dist/db/verification-token-storage.mjs.map +1 -0
  162. package/dist/db/with-hooks.d.mts +33 -0
  163. package/dist/db/with-hooks.mjs +159 -0
  164. package/dist/db/with-hooks.mjs.map +1 -0
  165. package/dist/index.d.mts +53 -0
  166. package/dist/index.mjs +27 -0
  167. package/dist/integrations/next-js.d.mts +29 -0
  168. package/dist/integrations/next-js.mjs +85 -0
  169. package/dist/integrations/next-js.mjs.map +1 -0
  170. package/dist/oauth2/index.d.mts +5 -0
  171. package/dist/oauth2/index.mjs +7 -0
  172. package/dist/oauth2/link-account.d.mts +48 -0
  173. package/dist/oauth2/link-account.mjs +143 -0
  174. package/dist/oauth2/link-account.mjs.map +1 -0
  175. package/dist/oauth2/state.d.mts +26 -0
  176. package/dist/oauth2/state.mjs +51 -0
  177. package/dist/oauth2/state.mjs.map +1 -0
  178. package/dist/oauth2/utils.d.mts +8 -0
  179. package/dist/oauth2/utils.mjs +31 -0
  180. package/dist/oauth2/utils.mjs.map +1 -0
  181. package/dist/plugins/access/access.d.mts +30 -0
  182. package/dist/plugins/access/access.mjs +46 -0
  183. package/dist/plugins/access/access.mjs.map +1 -0
  184. package/dist/plugins/access/index.d.mts +3 -0
  185. package/dist/plugins/access/index.mjs +3 -0
  186. package/dist/plugins/access/types.d.mts +17 -0
  187. package/dist/plugins/additional-fields/client.d.mts +96 -0
  188. package/dist/plugins/additional-fields/client.mjs +11 -0
  189. package/dist/plugins/additional-fields/client.mjs.map +1 -0
  190. package/dist/plugins/admin/access/index.d.mts +2 -0
  191. package/dist/plugins/admin/access/index.mjs +3 -0
  192. package/dist/plugins/admin/access/statement.d.mts +118 -0
  193. package/dist/plugins/admin/access/statement.mjs +53 -0
  194. package/dist/plugins/admin/access/statement.mjs.map +1 -0
  195. package/dist/plugins/admin/admin.d.mts +911 -0
  196. package/dist/plugins/admin/admin.mjs +95 -0
  197. package/dist/plugins/admin/admin.mjs.map +1 -0
  198. package/dist/plugins/admin/client.d.mts +76 -0
  199. package/dist/plugins/admin/client.mjs +36 -0
  200. package/dist/plugins/admin/client.mjs.map +1 -0
  201. package/dist/plugins/admin/error-codes.d.mts +29 -0
  202. package/dist/plugins/admin/error-codes.mjs +30 -0
  203. package/dist/plugins/admin/error-codes.mjs.map +1 -0
  204. package/dist/plugins/admin/has-permission.mjs +16 -0
  205. package/dist/plugins/admin/has-permission.mjs.map +1 -0
  206. package/dist/plugins/admin/index.d.mts +3 -0
  207. package/dist/plugins/admin/index.mjs +3 -0
  208. package/dist/plugins/admin/routes.mjs +841 -0
  209. package/dist/plugins/admin/routes.mjs.map +1 -0
  210. package/dist/plugins/admin/schema.d.mts +40 -0
  211. package/dist/plugins/admin/schema.mjs +34 -0
  212. package/dist/plugins/admin/schema.mjs.map +1 -0
  213. package/dist/plugins/admin/types.d.mts +89 -0
  214. package/dist/plugins/api-key/adapter.mjs +468 -0
  215. package/dist/plugins/api-key/adapter.mjs.map +1 -0
  216. package/dist/plugins/api-key/client.d.mts +46 -0
  217. package/dist/plugins/api-key/client.mjs +19 -0
  218. package/dist/plugins/api-key/client.mjs.map +1 -0
  219. package/dist/plugins/api-key/error-codes.d.mts +33 -0
  220. package/dist/plugins/api-key/error-codes.mjs +34 -0
  221. package/dist/plugins/api-key/error-codes.mjs.map +1 -0
  222. package/dist/plugins/api-key/index.d.mts +1251 -0
  223. package/dist/plugins/api-key/index.mjs +134 -0
  224. package/dist/plugins/api-key/index.mjs.map +1 -0
  225. package/dist/plugins/api-key/rate-limit.mjs +74 -0
  226. package/dist/plugins/api-key/rate-limit.mjs.map +1 -0
  227. package/dist/plugins/api-key/routes/create-api-key.mjs +252 -0
  228. package/dist/plugins/api-key/routes/create-api-key.mjs.map +1 -0
  229. package/dist/plugins/api-key/routes/delete-all-expired-api-keys.mjs +24 -0
  230. package/dist/plugins/api-key/routes/delete-all-expired-api-keys.mjs.map +1 -0
  231. package/dist/plugins/api-key/routes/delete-api-key.mjs +74 -0
  232. package/dist/plugins/api-key/routes/delete-api-key.mjs.map +1 -0
  233. package/dist/plugins/api-key/routes/get-api-key.mjs +158 -0
  234. package/dist/plugins/api-key/routes/get-api-key.mjs.map +1 -0
  235. package/dist/plugins/api-key/routes/index.mjs +71 -0
  236. package/dist/plugins/api-key/routes/index.mjs.map +1 -0
  237. package/dist/plugins/api-key/routes/list-api-keys.mjs +194 -0
  238. package/dist/plugins/api-key/routes/list-api-keys.mjs.map +1 -0
  239. package/dist/plugins/api-key/routes/update-api-key.mjs +248 -0
  240. package/dist/plugins/api-key/routes/update-api-key.mjs.map +1 -0
  241. package/dist/plugins/api-key/routes/verify-api-key.mjs +224 -0
  242. package/dist/plugins/api-key/routes/verify-api-key.mjs.map +1 -0
  243. package/dist/plugins/api-key/schema.d.mts +199 -0
  244. package/dist/plugins/api-key/schema.mjs +130 -0
  245. package/dist/plugins/api-key/schema.mjs.map +1 -0
  246. package/dist/plugins/api-key/types.d.mts +346 -0
  247. package/dist/plugins/bearer/index.d.mts +45 -0
  248. package/dist/plugins/bearer/index.mjs +66 -0
  249. package/dist/plugins/bearer/index.mjs.map +1 -0
  250. package/dist/plugins/captcha/constants.d.mts +10 -0
  251. package/dist/plugins/captcha/constants.mjs +22 -0
  252. package/dist/plugins/captcha/constants.mjs.map +1 -0
  253. package/dist/plugins/captcha/error-codes.mjs +16 -0
  254. package/dist/plugins/captcha/error-codes.mjs.map +1 -0
  255. package/dist/plugins/captcha/index.d.mts +21 -0
  256. package/dist/plugins/captcha/index.mjs +62 -0
  257. package/dist/plugins/captcha/index.mjs.map +1 -0
  258. package/dist/plugins/captcha/types.d.mts +28 -0
  259. package/dist/plugins/captcha/utils.mjs +11 -0
  260. package/dist/plugins/captcha/utils.mjs.map +1 -0
  261. package/dist/plugins/captcha/verify-handlers/captchafox.mjs +28 -0
  262. package/dist/plugins/captcha/verify-handlers/captchafox.mjs.map +1 -0
  263. package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +26 -0
  264. package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs.map +1 -0
  265. package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +30 -0
  266. package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs.map +1 -0
  267. package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +28 -0
  268. package/dist/plugins/captcha/verify-handlers/h-captcha.mjs.map +1 -0
  269. package/dist/plugins/captcha/verify-handlers/index.mjs +6 -0
  270. package/dist/plugins/custom-session/client.d.mts +17 -0
  271. package/dist/plugins/custom-session/client.mjs +11 -0
  272. package/dist/plugins/custom-session/client.mjs.map +1 -0
  273. package/dist/plugins/custom-session/index.d.mts +72 -0
  274. package/dist/plugins/custom-session/index.mjs +78 -0
  275. package/dist/plugins/custom-session/index.mjs.map +1 -0
  276. package/dist/plugins/device-authorization/client.d.mts +17 -0
  277. package/dist/plugins/device-authorization/client.mjs +18 -0
  278. package/dist/plugins/device-authorization/client.mjs.map +1 -0
  279. package/dist/plugins/device-authorization/error-codes.mjs +21 -0
  280. package/dist/plugins/device-authorization/error-codes.mjs.map +1 -0
  281. package/dist/plugins/device-authorization/index.d.mts +424 -0
  282. package/dist/plugins/device-authorization/index.mjs +50 -0
  283. package/dist/plugins/device-authorization/index.mjs.map +1 -0
  284. package/dist/plugins/device-authorization/routes.mjs +510 -0
  285. package/dist/plugins/device-authorization/routes.mjs.map +1 -0
  286. package/dist/plugins/device-authorization/schema.mjs +57 -0
  287. package/dist/plugins/device-authorization/schema.mjs.map +1 -0
  288. package/dist/plugins/email-otp/client.d.mts +21 -0
  289. package/dist/plugins/email-otp/client.mjs +18 -0
  290. package/dist/plugins/email-otp/client.mjs.map +1 -0
  291. package/dist/plugins/email-otp/error-codes.d.mts +11 -0
  292. package/dist/plugins/email-otp/error-codes.mjs +12 -0
  293. package/dist/plugins/email-otp/error-codes.mjs.map +1 -0
  294. package/dist/plugins/email-otp/index.d.mts +428 -0
  295. package/dist/plugins/email-otp/index.mjs +130 -0
  296. package/dist/plugins/email-otp/index.mjs.map +1 -0
  297. package/dist/plugins/email-otp/otp-token.mjs +29 -0
  298. package/dist/plugins/email-otp/otp-token.mjs.map +1 -0
  299. package/dist/plugins/email-otp/routes.mjs +631 -0
  300. package/dist/plugins/email-otp/routes.mjs.map +1 -0
  301. package/dist/plugins/email-otp/types.d.mts +86 -0
  302. package/dist/plugins/email-otp/utils.mjs +17 -0
  303. package/dist/plugins/email-otp/utils.mjs.map +1 -0
  304. package/dist/plugins/generic-oauth/client.d.mts +33 -0
  305. package/dist/plugins/generic-oauth/client.mjs +14 -0
  306. package/dist/plugins/generic-oauth/client.mjs.map +1 -0
  307. package/dist/plugins/generic-oauth/error-codes.d.mts +16 -0
  308. package/dist/plugins/generic-oauth/error-codes.mjs +17 -0
  309. package/dist/plugins/generic-oauth/error-codes.mjs.map +1 -0
  310. package/dist/plugins/generic-oauth/index.d.mts +201 -0
  311. package/dist/plugins/generic-oauth/index.mjs +145 -0
  312. package/dist/plugins/generic-oauth/index.mjs.map +1 -0
  313. package/dist/plugins/generic-oauth/providers/auth0.d.mts +37 -0
  314. package/dist/plugins/generic-oauth/providers/auth0.mjs +62 -0
  315. package/dist/plugins/generic-oauth/providers/auth0.mjs.map +1 -0
  316. package/dist/plugins/generic-oauth/providers/gumroad.d.mts +32 -0
  317. package/dist/plugins/generic-oauth/providers/gumroad.mjs +60 -0
  318. package/dist/plugins/generic-oauth/providers/gumroad.mjs.map +1 -0
  319. package/dist/plugins/generic-oauth/providers/hubspot.d.mts +37 -0
  320. package/dist/plugins/generic-oauth/providers/hubspot.mjs +60 -0
  321. package/dist/plugins/generic-oauth/providers/hubspot.mjs.map +1 -0
  322. package/dist/plugins/generic-oauth/providers/index.d.mts +9 -0
  323. package/dist/plugins/generic-oauth/providers/index.mjs +11 -0
  324. package/dist/plugins/generic-oauth/providers/keycloak.d.mts +37 -0
  325. package/dist/plugins/generic-oauth/providers/keycloak.mjs +62 -0
  326. package/dist/plugins/generic-oauth/providers/keycloak.mjs.map +1 -0
  327. package/dist/plugins/generic-oauth/providers/line.d.mts +55 -0
  328. package/dist/plugins/generic-oauth/providers/line.mjs +91 -0
  329. package/dist/plugins/generic-oauth/providers/line.mjs.map +1 -0
  330. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +37 -0
  331. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +66 -0
  332. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs.map +1 -0
  333. package/dist/plugins/generic-oauth/providers/okta.d.mts +37 -0
  334. package/dist/plugins/generic-oauth/providers/okta.mjs +62 -0
  335. package/dist/plugins/generic-oauth/providers/okta.mjs.map +1 -0
  336. package/dist/plugins/generic-oauth/providers/patreon.d.mts +30 -0
  337. package/dist/plugins/generic-oauth/providers/patreon.mjs +59 -0
  338. package/dist/plugins/generic-oauth/providers/patreon.mjs.map +1 -0
  339. package/dist/plugins/generic-oauth/providers/slack.d.mts +30 -0
  340. package/dist/plugins/generic-oauth/providers/slack.mjs +61 -0
  341. package/dist/plugins/generic-oauth/providers/slack.mjs.map +1 -0
  342. package/dist/plugins/generic-oauth/routes.mjs +411 -0
  343. package/dist/plugins/generic-oauth/routes.mjs.map +1 -0
  344. package/dist/plugins/generic-oauth/types.d.mts +159 -0
  345. package/dist/plugins/haveibeenpwned/index.d.mts +46 -0
  346. package/dist/plugins/haveibeenpwned/index.mjs +57 -0
  347. package/dist/plugins/haveibeenpwned/index.mjs.map +1 -0
  348. package/dist/plugins/index.d.mts +65 -0
  349. package/dist/plugins/index.mjs +48 -0
  350. package/dist/plugins/jwt/adapter.mjs +27 -0
  351. package/dist/plugins/jwt/adapter.mjs.map +1 -0
  352. package/dist/plugins/jwt/client.d.mts +40 -0
  353. package/dist/plugins/jwt/client.mjs +19 -0
  354. package/dist/plugins/jwt/client.mjs.map +1 -0
  355. package/dist/plugins/jwt/index.d.mts +224 -0
  356. package/dist/plugins/jwt/index.mjs +202 -0
  357. package/dist/plugins/jwt/index.mjs.map +1 -0
  358. package/dist/plugins/jwt/schema.d.mts +26 -0
  359. package/dist/plugins/jwt/schema.mjs +23 -0
  360. package/dist/plugins/jwt/schema.mjs.map +1 -0
  361. package/dist/plugins/jwt/sign.d.mts +57 -0
  362. package/dist/plugins/jwt/sign.mjs +66 -0
  363. package/dist/plugins/jwt/sign.mjs.map +1 -0
  364. package/dist/plugins/jwt/types.d.mts +194 -0
  365. package/dist/plugins/jwt/utils.d.mts +42 -0
  366. package/dist/plugins/jwt/utils.mjs +64 -0
  367. package/dist/plugins/jwt/utils.mjs.map +1 -0
  368. package/dist/plugins/jwt/verify.d.mts +12 -0
  369. package/dist/plugins/jwt/verify.mjs +46 -0
  370. package/dist/plugins/jwt/verify.mjs.map +1 -0
  371. package/dist/plugins/last-login-method/client.d.mts +38 -0
  372. package/dist/plugins/last-login-method/client.mjs +32 -0
  373. package/dist/plugins/last-login-method/client.mjs.map +1 -0
  374. package/dist/plugins/last-login-method/index.d.mts +118 -0
  375. package/dist/plugins/last-login-method/index.mjs +76 -0
  376. package/dist/plugins/last-login-method/index.mjs.map +1 -0
  377. package/dist/plugins/magic-link/client.d.mts +10 -0
  378. package/dist/plugins/magic-link/client.mjs +11 -0
  379. package/dist/plugins/magic-link/client.mjs.map +1 -0
  380. package/dist/plugins/magic-link/index.d.mts +193 -0
  381. package/dist/plugins/magic-link/index.mjs +177 -0
  382. package/dist/plugins/magic-link/index.mjs.map +1 -0
  383. package/dist/plugins/magic-link/utils.mjs +12 -0
  384. package/dist/plugins/magic-link/utils.mjs.map +1 -0
  385. package/dist/plugins/mcp/authorize.mjs +133 -0
  386. package/dist/plugins/mcp/authorize.mjs.map +1 -0
  387. package/dist/plugins/mcp/index.d.mts +458 -0
  388. package/dist/plugins/mcp/index.mjs +717 -0
  389. package/dist/plugins/mcp/index.mjs.map +1 -0
  390. package/dist/plugins/multi-session/client.d.mts +19 -0
  391. package/dist/plugins/multi-session/client.mjs +20 -0
  392. package/dist/plugins/multi-session/client.mjs.map +1 -0
  393. package/dist/plugins/multi-session/error-codes.d.mts +9 -0
  394. package/dist/plugins/multi-session/error-codes.mjs +8 -0
  395. package/dist/plugins/multi-session/error-codes.mjs.map +1 -0
  396. package/dist/plugins/multi-session/index.d.mts +235 -0
  397. package/dist/plugins/multi-session/index.mjs +172 -0
  398. package/dist/plugins/multi-session/index.mjs.map +1 -0
  399. package/dist/plugins/oauth-proxy/index.d.mts +97 -0
  400. package/dist/plugins/oauth-proxy/index.mjs +305 -0
  401. package/dist/plugins/oauth-proxy/index.mjs.map +1 -0
  402. package/dist/plugins/oauth-proxy/utils.mjs +51 -0
  403. package/dist/plugins/oauth-proxy/utils.mjs.map +1 -0
  404. package/dist/plugins/oidc-provider/authorize.mjs +194 -0
  405. package/dist/plugins/oidc-provider/authorize.mjs.map +1 -0
  406. package/dist/plugins/oidc-provider/client.d.mts +12 -0
  407. package/dist/plugins/oidc-provider/client.mjs +11 -0
  408. package/dist/plugins/oidc-provider/client.mjs.map +1 -0
  409. package/dist/plugins/oidc-provider/error.mjs +17 -0
  410. package/dist/plugins/oidc-provider/error.mjs.map +1 -0
  411. package/dist/plugins/oidc-provider/index.d.mts +702 -0
  412. package/dist/plugins/oidc-provider/index.mjs +1093 -0
  413. package/dist/plugins/oidc-provider/index.mjs.map +1 -0
  414. package/dist/plugins/oidc-provider/schema.d.mts +160 -0
  415. package/dist/plugins/oidc-provider/schema.mjs +132 -0
  416. package/dist/plugins/oidc-provider/schema.mjs.map +1 -0
  417. package/dist/plugins/oidc-provider/types.d.mts +517 -0
  418. package/dist/plugins/oidc-provider/utils/prompt.mjs +19 -0
  419. package/dist/plugins/oidc-provider/utils/prompt.mjs.map +1 -0
  420. package/dist/plugins/oidc-provider/utils.mjs +15 -0
  421. package/dist/plugins/oidc-provider/utils.mjs.map +1 -0
  422. package/dist/plugins/one-tap/client.d.mts +174 -0
  423. package/dist/plugins/one-tap/client.mjs +188 -0
  424. package/dist/plugins/one-tap/client.mjs.map +1 -0
  425. package/dist/plugins/one-tap/index.d.mts +83 -0
  426. package/dist/plugins/one-tap/index.mjs +95 -0
  427. package/dist/plugins/one-tap/index.mjs.map +1 -0
  428. package/dist/plugins/one-time-token/client.d.mts +10 -0
  429. package/dist/plugins/one-time-token/client.mjs +11 -0
  430. package/dist/plugins/one-time-token/client.mjs.map +1 -0
  431. package/dist/plugins/one-time-token/index.d.mts +133 -0
  432. package/dist/plugins/one-time-token/index.mjs +82 -0
  433. package/dist/plugins/one-time-token/index.mjs.map +1 -0
  434. package/dist/plugins/one-time-token/utils.mjs +12 -0
  435. package/dist/plugins/one-time-token/utils.mjs.map +1 -0
  436. package/dist/plugins/open-api/generator.d.mts +115 -0
  437. package/dist/plugins/open-api/generator.mjs +315 -0
  438. package/dist/plugins/open-api/generator.mjs.map +1 -0
  439. package/dist/plugins/open-api/index.d.mts +97 -0
  440. package/dist/plugins/open-api/index.mjs +67 -0
  441. package/dist/plugins/open-api/index.mjs.map +1 -0
  442. package/dist/plugins/open-api/logo.mjs +15 -0
  443. package/dist/plugins/open-api/logo.mjs.map +1 -0
  444. package/dist/plugins/organization/access/index.d.mts +2 -0
  445. package/dist/plugins/organization/access/index.mjs +3 -0
  446. package/dist/plugins/organization/access/statement.d.mts +249 -0
  447. package/dist/plugins/organization/access/statement.mjs +81 -0
  448. package/dist/plugins/organization/access/statement.mjs.map +1 -0
  449. package/dist/plugins/organization/adapter.d.mts +792 -0
  450. package/dist/plugins/organization/adapter.mjs +624 -0
  451. package/dist/plugins/organization/adapter.mjs.map +1 -0
  452. package/dist/plugins/organization/call.mjs +19 -0
  453. package/dist/plugins/organization/call.mjs.map +1 -0
  454. package/dist/plugins/organization/client.d.mts +372 -0
  455. package/dist/plugins/organization/client.mjs +95 -0
  456. package/dist/plugins/organization/client.mjs.map +1 -0
  457. package/dist/plugins/organization/error-codes.d.mts +65 -0
  458. package/dist/plugins/organization/error-codes.mjs +66 -0
  459. package/dist/plugins/organization/error-codes.mjs.map +1 -0
  460. package/dist/plugins/organization/has-permission.mjs +35 -0
  461. package/dist/plugins/organization/has-permission.mjs.map +1 -0
  462. package/dist/plugins/organization/index.d.mts +5 -0
  463. package/dist/plugins/organization/index.mjs +4 -0
  464. package/dist/plugins/organization/organization.d.mts +394 -0
  465. package/dist/plugins/organization/organization.mjs +428 -0
  466. package/dist/plugins/organization/organization.mjs.map +1 -0
  467. package/dist/plugins/organization/permission.d.mts +17 -0
  468. package/dist/plugins/organization/permission.mjs +16 -0
  469. package/dist/plugins/organization/permission.mjs.map +1 -0
  470. package/dist/plugins/organization/routes/crud-access-control.d.mts +394 -0
  471. package/dist/plugins/organization/routes/crud-access-control.mjs +678 -0
  472. package/dist/plugins/organization/routes/crud-access-control.mjs.map +1 -0
  473. package/dist/plugins/organization/routes/crud-invites.d.mts +1031 -0
  474. package/dist/plugins/organization/routes/crud-invites.mjs +551 -0
  475. package/dist/plugins/organization/routes/crud-invites.mjs.map +1 -0
  476. package/dist/plugins/organization/routes/crud-members.d.mts +940 -0
  477. package/dist/plugins/organization/routes/crud-members.mjs +466 -0
  478. package/dist/plugins/organization/routes/crud-members.mjs.map +1 -0
  479. package/dist/plugins/organization/routes/crud-org.d.mts +708 -0
  480. package/dist/plugins/organization/routes/crud-org.mjs +423 -0
  481. package/dist/plugins/organization/routes/crud-org.mjs.map +1 -0
  482. package/dist/plugins/organization/routes/crud-team.d.mts +1071 -0
  483. package/dist/plugins/organization/routes/crud-team.mjs +676 -0
  484. package/dist/plugins/organization/routes/crud-team.mjs.map +1 -0
  485. package/dist/plugins/organization/schema.d.mts +376 -0
  486. package/dist/plugins/organization/schema.mjs +68 -0
  487. package/dist/plugins/organization/schema.mjs.map +1 -0
  488. package/dist/plugins/organization/types.d.mts +677 -0
  489. package/dist/plugins/phone-number/client.d.mts +31 -0
  490. package/dist/plugins/phone-number/client.mjs +20 -0
  491. package/dist/plugins/phone-number/client.mjs.map +1 -0
  492. package/dist/plugins/phone-number/error-codes.d.mts +20 -0
  493. package/dist/plugins/phone-number/error-codes.mjs +21 -0
  494. package/dist/plugins/phone-number/error-codes.mjs.map +1 -0
  495. package/dist/plugins/phone-number/index.d.mts +318 -0
  496. package/dist/plugins/phone-number/index.mjs +49 -0
  497. package/dist/plugins/phone-number/index.mjs.map +1 -0
  498. package/dist/plugins/phone-number/routes.mjs +472 -0
  499. package/dist/plugins/phone-number/routes.mjs.map +1 -0
  500. package/dist/plugins/phone-number/schema.d.mts +23 -0
  501. package/dist/plugins/phone-number/schema.mjs +20 -0
  502. package/dist/plugins/phone-number/schema.mjs.map +1 -0
  503. package/dist/plugins/phone-number/types.d.mts +118 -0
  504. package/dist/plugins/two-factor/backup-codes/index.d.mts +279 -0
  505. package/dist/plugins/two-factor/backup-codes/index.mjs +277 -0
  506. package/dist/plugins/two-factor/backup-codes/index.mjs.map +1 -0
  507. package/dist/plugins/two-factor/client.d.mts +55 -0
  508. package/dist/plugins/two-factor/client.mjs +37 -0
  509. package/dist/plugins/two-factor/client.mjs.map +1 -0
  510. package/dist/plugins/two-factor/constant.mjs +8 -0
  511. package/dist/plugins/two-factor/constant.mjs.map +1 -0
  512. package/dist/plugins/two-factor/error-code.d.mts +17 -0
  513. package/dist/plugins/two-factor/error-code.mjs +18 -0
  514. package/dist/plugins/two-factor/error-code.mjs.map +1 -0
  515. package/dist/plugins/two-factor/index.d.mts +670 -0
  516. package/dist/plugins/two-factor/index.mjs +228 -0
  517. package/dist/plugins/two-factor/index.mjs.map +1 -0
  518. package/dist/plugins/two-factor/otp/index.d.mts +216 -0
  519. package/dist/plugins/two-factor/otp/index.mjs +199 -0
  520. package/dist/plugins/two-factor/otp/index.mjs.map +1 -0
  521. package/dist/plugins/two-factor/schema.d.mts +41 -0
  522. package/dist/plugins/two-factor/schema.mjs +36 -0
  523. package/dist/plugins/two-factor/schema.mjs.map +1 -0
  524. package/dist/plugins/two-factor/totp/index.d.mts +210 -0
  525. package/dist/plugins/two-factor/totp/index.mjs +157 -0
  526. package/dist/plugins/two-factor/totp/index.mjs.map +1 -0
  527. package/dist/plugins/two-factor/types.d.mts +73 -0
  528. package/dist/plugins/two-factor/utils.mjs +12 -0
  529. package/dist/plugins/two-factor/utils.mjs.map +1 -0
  530. package/dist/plugins/two-factor/verify-two-factor.mjs +85 -0
  531. package/dist/plugins/two-factor/verify-two-factor.mjs.map +1 -0
  532. package/dist/plugins/username/client.d.mts +26 -0
  533. package/dist/plugins/username/client.mjs +18 -0
  534. package/dist/plugins/username/client.mjs.map +1 -0
  535. package/dist/plugins/username/error-codes.d.mts +16 -0
  536. package/dist/plugins/username/error-codes.mjs +17 -0
  537. package/dist/plugins/username/error-codes.mjs.map +1 -0
  538. package/dist/plugins/username/index.d.mts +251 -0
  539. package/dist/plugins/username/index.mjs +234 -0
  540. package/dist/plugins/username/index.mjs.map +1 -0
  541. package/dist/plugins/username/schema.d.mts +33 -0
  542. package/dist/plugins/username/schema.mjs +26 -0
  543. package/dist/plugins/username/schema.mjs.map +1 -0
  544. package/dist/providers/index.d.mts +1 -0
  545. package/dist/providers/index.mjs +3 -0
  546. package/dist/state.d.mts +42 -0
  547. package/dist/state.mjs +107 -0
  548. package/dist/state.mjs.map +1 -0
  549. package/dist/types/adapter.d.mts +2 -0
  550. package/dist/types/api.d.mts +29 -0
  551. package/dist/types/auth.d.mts +29 -0
  552. package/dist/types/helper.d.mts +10 -0
  553. package/dist/types/index.d.mts +11 -0
  554. package/dist/types/index.mjs +1 -0
  555. package/dist/types/models.d.mts +11 -0
  556. package/dist/types/plugins.d.mts +20 -0
  557. package/dist/utils/boolean.mjs +8 -0
  558. package/dist/utils/boolean.mjs.map +1 -0
  559. package/dist/utils/constants.mjs +6 -0
  560. package/dist/utils/constants.mjs.map +1 -0
  561. package/dist/utils/date.mjs +8 -0
  562. package/dist/utils/date.mjs.map +1 -0
  563. package/dist/utils/get-request-ip.d.mts +7 -0
  564. package/dist/utils/get-request-ip.mjs +23 -0
  565. package/dist/utils/get-request-ip.mjs.map +1 -0
  566. package/dist/utils/hide-metadata.d.mts +7 -0
  567. package/dist/utils/hide-metadata.mjs +6 -0
  568. package/dist/utils/hide-metadata.mjs.map +1 -0
  569. package/dist/utils/index.d.mts +4 -0
  570. package/dist/utils/index.mjs +6 -0
  571. package/dist/utils/is-api-error.d.mts +7 -0
  572. package/dist/utils/is-api-error.mjs +11 -0
  573. package/dist/utils/is-api-error.mjs.map +1 -0
  574. package/dist/utils/is-atom.mjs +8 -0
  575. package/dist/utils/is-atom.mjs.map +1 -0
  576. package/dist/utils/is-promise.mjs +8 -0
  577. package/dist/utils/is-promise.mjs.map +1 -0
  578. package/dist/utils/middleware-response.mjs +9 -0
  579. package/dist/utils/middleware-response.mjs.map +1 -0
  580. package/dist/utils/password.mjs +26 -0
  581. package/dist/utils/password.mjs.map +1 -0
  582. package/dist/utils/plugin-helper.mjs +17 -0
  583. package/dist/utils/plugin-helper.mjs.map +1 -0
  584. package/dist/utils/shim.mjs +24 -0
  585. package/dist/utils/shim.mjs.map +1 -0
  586. package/dist/utils/time.d.mts +49 -0
  587. package/dist/utils/time.mjs +100 -0
  588. package/dist/utils/time.mjs.map +1 -0
  589. package/dist/utils/url.d.mts +8 -0
  590. package/dist/utils/url.mjs +92 -0
  591. package/dist/utils/url.mjs.map +1 -0
  592. package/dist/utils/wildcard.mjs +108 -0
  593. package/dist/utils/wildcard.mjs.map +1 -0
  594. package/package.json +428 -0
@@ -0,0 +1,174 @@
1
+ import * as _better_auth_core0 from "@better-auth/core";
2
+ import { ClientFetchOption } from "@better-auth/core";
3
+ import * as _better_fetch_fetch0 from "@better-fetch/fetch";
4
+
5
+ //#region src/plugins/one-tap/client.d.ts
6
+ declare global {
7
+ interface Window {
8
+ googleScriptInitialized?: boolean | undefined;
9
+ }
10
+ }
11
+ interface GsiButtonConfiguration {
12
+ /**
13
+ * The button type: icon, or standard button.
14
+ */
15
+ type: "standard" | "icon";
16
+ /**
17
+ * The button theme. For example, filled_blue or filled_black.
18
+ * outline A standard button theme:
19
+ * filled_blue A blue-filled button theme:
20
+ * filled_black A black-filled button theme:
21
+ */
22
+ theme?: "outline" | "filled_blue" | "filled_black";
23
+ /**
24
+ * The button size. For example, small or large.
25
+ */
26
+ size?: "small" | "medium" | "large";
27
+ /**
28
+ * The button text. The default value is signin_with.
29
+ * There are no visual differences for the text of icon buttons that
30
+ * have different text attributes. The only exception is when the
31
+ * text is read for screen accessibility.
32
+ *
33
+ * signin_with The button text is “Sign in with Google”:
34
+ * signup_with The button text is “Sign up with Google”:
35
+ * continue_with The button text is “Continue with Google”:
36
+ * signup_with The button text is “Sign in”:
37
+ */
38
+ text?: "signin_with" | "signup_with" | "continue_with" | "signin";
39
+ /**
40
+ * The button shape. The default value is rectangular.
41
+ */
42
+ shape?: "rectangular" | "pill" | "circle" | "square";
43
+ /**
44
+ * The alignment of the Google logo. The default value is left.
45
+ * This attribute only applies to the standard button type.
46
+ */
47
+ logo_alignment?: "left" | "center";
48
+ /**
49
+ * The minimum button width, in pixels. The maximum width is 400
50
+ * pixels.
51
+ */
52
+ width?: number;
53
+ /**
54
+ * The pre-set locale of the button text. If it's not set, the
55
+ * browser's default locale or the Google session user’s preference
56
+ * is used.
57
+ */
58
+ locale?: string;
59
+ /**
60
+ * You can define a JavaScript function to be called when the
61
+ * Sign in with Google button is clicked.
62
+ */
63
+ click_listener?: () => void;
64
+ /**
65
+ * Optional, as multiple Sign in with Google buttons can be
66
+ * rendered on the same page, you can assign each button with a
67
+ * unique string. The same string would return along with the ID
68
+ * token, so you can identify which button user clicked to sign in.
69
+ */
70
+ state?: string;
71
+ }
72
+ interface GoogleOneTapOptions {
73
+ /**
74
+ * Google client ID
75
+ */
76
+ clientId: string;
77
+ /**
78
+ * Auto select the account if the user is already signed in
79
+ */
80
+ autoSelect?: boolean | undefined;
81
+ /**
82
+ * Cancel the flow when the user taps outside the prompt
83
+ *
84
+ * Note: To use this option, disable `promptOptions.fedCM`
85
+ */
86
+ cancelOnTapOutside?: boolean | undefined;
87
+ /**
88
+ * The mode to use for the Google One Tap flow
89
+ *
90
+ * popup: Use a popup window
91
+ * redirect: Redirect the user to the Google One Tap flow
92
+ *
93
+ * @default "popup"
94
+ */
95
+ uxMode?: ("popup" | "redirect") | undefined;
96
+ /**
97
+ * The context to use for the Google One Tap flow.
98
+ *
99
+ * @see {@link https://developers.google.com/identity/gsi/web/reference/js-reference}
100
+ * @default "signin"
101
+ */
102
+ context?: ("signin" | "signup" | "use") | undefined;
103
+ /**
104
+ * Additional configuration options to pass to the Google One Tap API.
105
+ */
106
+ additionalOptions?: Record<string, any> | undefined;
107
+ /**
108
+ * Configuration options for the prompt and exponential backoff behavior.
109
+ */
110
+ promptOptions?: {
111
+ /**
112
+ * Base delay (in milliseconds) for exponential backoff.
113
+ * @default 1000
114
+ */
115
+ baseDelay?: number;
116
+ /**
117
+ * Maximum number of prompt attempts before calling onPromptNotification.
118
+ * @default 5
119
+ */
120
+ maxAttempts?: number;
121
+ /**
122
+ * Whether to support FedCM (Federated Credential Management) support.
123
+ *
124
+ * @see {@link https://developer.chrome.com/docs/identity/fedcm/overview}
125
+ * @default true
126
+ */
127
+ fedCM?: boolean | undefined;
128
+ } | undefined;
129
+ }
130
+ interface GoogleOneTapActionOptions extends Omit<GoogleOneTapOptions, "clientId" | "promptOptions"> {
131
+ fetchOptions?: ClientFetchOption | undefined;
132
+ /**
133
+ * Callback URL.
134
+ */
135
+ callbackURL?: string | undefined;
136
+ /**
137
+ * Optional callback that receives the prompt notification if (or when) the prompt is dismissed or skipped.
138
+ * This lets you render an alternative UI (e.g. a Google Sign-In button) to restart the process.
139
+ */
140
+ onPromptNotification?: ((notification?: any | undefined) => void) | undefined;
141
+ nonce?: string | undefined;
142
+ /**
143
+ * Button mode configuration. When provided, renders a "Sign In with Google" button
144
+ * instead of showing the One Tap prompt.
145
+ */
146
+ button?: {
147
+ /**
148
+ * The HTML element or CSS selector where the button should be rendered.
149
+ * If a string is provided, it will be used as a CSS selector.
150
+ */
151
+ container: HTMLElement | string;
152
+ /**
153
+ * Button configuration options
154
+ */
155
+ config?: GsiButtonConfiguration | undefined;
156
+ } | undefined;
157
+ }
158
+ declare const oneTapClient: (options: GoogleOneTapOptions) => {
159
+ id: "one-tap";
160
+ fetchPlugins: {
161
+ id: string;
162
+ name: string;
163
+ hooks: {
164
+ onResponse(ctx: _better_fetch_fetch0.ResponseContext): Promise<void>;
165
+ };
166
+ }[];
167
+ getActions: ($fetch: _better_fetch_fetch0.BetterFetch, _: _better_auth_core0.ClientStore) => {
168
+ oneTap: (opts?: GoogleOneTapActionOptions | undefined, fetchOptions?: ClientFetchOption | undefined) => Promise<void>;
169
+ };
170
+ getAtoms($fetch: _better_fetch_fetch0.BetterFetch): {};
171
+ };
172
+ //#endregion
173
+ export { GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, oneTapClient };
174
+ //# sourceMappingURL=client.d.mts.map
@@ -0,0 +1,188 @@
1
+ //#region src/plugins/one-tap/client.ts
2
+ let isRequestInProgress = false;
3
+ function isFedCMSupported() {
4
+ return typeof window !== "undefined" && "IdentityCredential" in window;
5
+ }
6
+ /**
7
+ * Reasons that should NOT trigger a retry.
8
+ * @see https://developers.google.com/identity/gsi/web/reference/js-reference
9
+ */
10
+ const noRetryReasons = {
11
+ dismissed: ["credential_returned", "cancel_called"],
12
+ skipped: ["user_cancel", "tap_outside"]
13
+ };
14
+ const oneTapClient = (options) => {
15
+ return {
16
+ id: "one-tap",
17
+ fetchPlugins: [{
18
+ id: "fedcm-signout-handle",
19
+ name: "FedCM Sign-Out Handler",
20
+ hooks: { async onResponse(ctx) {
21
+ if (!ctx.request.url.toString().includes("/sign-out")) return;
22
+ if (options.promptOptions?.fedCM === false || !isFedCMSupported()) return;
23
+ navigator.credentials.preventSilentAccess();
24
+ } }
25
+ }],
26
+ getActions: ($fetch, _) => {
27
+ return { oneTap: async (opts, fetchOptions) => {
28
+ if (isRequestInProgress) {
29
+ console.warn("A Google One Tap request is already in progress. Please wait.");
30
+ return;
31
+ }
32
+ if (typeof window === "undefined" || !window.document) {
33
+ console.warn("Google One Tap is only available in browser environments");
34
+ return;
35
+ }
36
+ if (opts?.button) {
37
+ await loadGoogleScript();
38
+ const container = typeof opts.button.container === "string" ? document.querySelector(opts.button.container) : opts.button.container;
39
+ if (!container) {
40
+ console.error("Google One Tap: Button container not found", opts.button.container);
41
+ return;
42
+ }
43
+ async function callback(idToken) {
44
+ await $fetch("/one-tap/callback", {
45
+ method: "POST",
46
+ body: { idToken },
47
+ ...opts?.fetchOptions,
48
+ ...fetchOptions
49
+ });
50
+ if (!opts?.fetchOptions && !fetchOptions || opts?.callbackURL) window.location.href = opts?.callbackURL ?? "/";
51
+ }
52
+ const { autoSelect, cancelOnTapOutside, context } = opts ?? {};
53
+ const contextValue = context ?? options.context ?? "signin";
54
+ window.google?.accounts.id.initialize({
55
+ client_id: options.clientId,
56
+ callback: async (response) => {
57
+ try {
58
+ await callback(response.credential);
59
+ } catch (error) {
60
+ console.error("Error during button callback:", error);
61
+ }
62
+ },
63
+ auto_select: autoSelect,
64
+ cancel_on_tap_outside: cancelOnTapOutside,
65
+ context: contextValue,
66
+ ux_mode: opts?.uxMode || "popup",
67
+ nonce: opts?.nonce,
68
+ itp_support: true,
69
+ ...options.additionalOptions
70
+ });
71
+ window.google?.accounts.id.renderButton(container, opts.button.config ?? { type: "icon" });
72
+ return;
73
+ }
74
+ async function callback(idToken) {
75
+ await $fetch("/one-tap/callback", {
76
+ method: "POST",
77
+ body: { idToken },
78
+ ...opts?.fetchOptions,
79
+ ...fetchOptions
80
+ });
81
+ if (!opts?.fetchOptions && !fetchOptions || opts?.callbackURL) window.location.href = opts?.callbackURL ?? "/";
82
+ }
83
+ const { autoSelect, cancelOnTapOutside, context } = opts ?? {};
84
+ const contextValue = context ?? options.context ?? "signin";
85
+ isRequestInProgress = true;
86
+ try {
87
+ await loadGoogleScript();
88
+ await new Promise((resolve, reject) => {
89
+ let isResolved = false;
90
+ const baseDelay = options.promptOptions?.baseDelay ?? 1e3;
91
+ const maxAttempts = options.promptOptions?.maxAttempts ?? 5;
92
+ window.google?.accounts.id.initialize({
93
+ client_id: options.clientId,
94
+ callback: async (response) => {
95
+ isResolved = true;
96
+ try {
97
+ await callback(response.credential);
98
+ resolve();
99
+ } catch (error) {
100
+ console.error("Error during One Tap callback:", error);
101
+ reject(error);
102
+ }
103
+ },
104
+ auto_select: autoSelect,
105
+ cancel_on_tap_outside: cancelOnTapOutside,
106
+ context: contextValue,
107
+ ux_mode: opts?.uxMode || "popup",
108
+ nonce: opts?.nonce,
109
+ itp_support: true,
110
+ ...options.additionalOptions
111
+ });
112
+ const handlePrompt = (attempt) => {
113
+ if (isResolved) return;
114
+ window.google?.accounts.id.prompt((notification) => {
115
+ if (isResolved) return;
116
+ if (notification.isDismissedMoment && notification.isDismissedMoment()) {
117
+ const reason = notification.getDismissedReason?.();
118
+ if (noRetryReasons.dismissed.includes(reason)) {
119
+ opts?.onPromptNotification?.(notification);
120
+ resolve();
121
+ return;
122
+ }
123
+ if (attempt < maxAttempts) {
124
+ const delay = Math.pow(2, attempt) * baseDelay;
125
+ setTimeout(() => handlePrompt(attempt + 1), delay);
126
+ } else {
127
+ opts?.onPromptNotification?.(notification);
128
+ resolve();
129
+ }
130
+ } else if (notification.isSkippedMoment && notification.isSkippedMoment()) {
131
+ const reason = notification.getSkippedReason?.();
132
+ if (!reason || noRetryReasons.skipped.includes(reason)) {
133
+ opts?.onPromptNotification?.(notification);
134
+ resolve();
135
+ return;
136
+ }
137
+ if (attempt < maxAttempts) {
138
+ const delay = Math.pow(2, attempt) * baseDelay;
139
+ setTimeout(() => handlePrompt(attempt + 1), delay);
140
+ } else {
141
+ opts?.onPromptNotification?.(notification);
142
+ resolve();
143
+ }
144
+ } else if (notification.isNotDisplayed && notification.isNotDisplayed()) {
145
+ opts?.onPromptNotification?.(notification);
146
+ resolve();
147
+ }
148
+ });
149
+ };
150
+ handlePrompt(0);
151
+ });
152
+ } catch (error) {
153
+ console.error("Error during Google One Tap flow:", error);
154
+ throw error;
155
+ } finally {
156
+ isRequestInProgress = false;
157
+ }
158
+ } };
159
+ },
160
+ getAtoms($fetch) {
161
+ return {};
162
+ }
163
+ };
164
+ };
165
+ const loadGoogleScript = () => {
166
+ return new Promise((resolve, reject) => {
167
+ if (window.googleScriptInitialized) {
168
+ resolve();
169
+ return;
170
+ }
171
+ const script = document.createElement("script");
172
+ script.src = "https://accounts.google.com/gsi/client";
173
+ script.async = true;
174
+ script.defer = true;
175
+ script.onload = () => {
176
+ window.googleScriptInitialized = true;
177
+ resolve();
178
+ };
179
+ script.onerror = () => {
180
+ reject(/* @__PURE__ */ new Error("Failed to load Google Identity Services script"));
181
+ };
182
+ document.head.appendChild(script);
183
+ });
184
+ };
185
+
186
+ //#endregion
187
+ export { oneTapClient };
188
+ //# sourceMappingURL=client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.mjs","names":[],"sources":["../../../src/plugins/one-tap/client.ts"],"sourcesContent":["/// <reference types=\"@types/google.accounts\" />\nimport type {\n\tBetterAuthClientPlugin,\n\tClientFetchOption,\n} from \"@better-auth/core\";\n\ndeclare global {\n\tinterface Window {\n\t\tgoogleScriptInitialized?: boolean | undefined;\n\t}\n}\n\nexport interface GsiButtonConfiguration {\n\t/**\n\t * The button type: icon, or standard button.\n\t */\n\ttype: \"standard\" | \"icon\";\n\n\t/**\n\t * The button theme. For example, filled_blue or filled_black.\n\t * outline A standard button theme:\n\t * filled_blue A blue-filled button theme:\n\t * filled_black A black-filled button theme:\n\t */\n\ttheme?: \"outline\" | \"filled_blue\" | \"filled_black\";\n\n\t/**\n\t * The button size. For example, small or large.\n\t */\n\tsize?: \"small\" | \"medium\" | \"large\";\n\n\t/**\n\t * The button text. The default value is signin_with.\n\t * There are no visual differences for the text of icon buttons that\n\t * have different text attributes. The only exception is when the\n\t * text is read for screen accessibility.\n\t *\n\t * signin_with The button text is “Sign in with Google”:\n\t * signup_with The button text is “Sign up with Google”:\n\t * continue_with The button text is “Continue with Google”:\n\t * signup_with The button text is “Sign in”:\n\t */\n\ttext?: \"signin_with\" | \"signup_with\" | \"continue_with\" | \"signin\";\n\n\t/**\n\t * The button shape. The default value is rectangular.\n\t */\n\tshape?: \"rectangular\" | \"pill\" | \"circle\" | \"square\";\n\n\t/**\n\t * The alignment of the Google logo. The default value is left.\n\t * This attribute only applies to the standard button type.\n\t */\n\tlogo_alignment?: \"left\" | \"center\";\n\n\t/**\n\t * The minimum button width, in pixels. The maximum width is 400\n\t * pixels.\n\t */\n\twidth?: number;\n\n\t/**\n\t * The pre-set locale of the button text. If it's not set, the\n\t * browser's default locale or the Google session user’s preference\n\t * is used.\n\t */\n\tlocale?: string;\n\n\t/**\n\t * You can define a JavaScript function to be called when the\n\t * Sign in with Google button is clicked.\n\t */\n\tclick_listener?: () => void;\n\n\t/**\n\t * Optional, as multiple Sign in with Google buttons can be\n\t * rendered on the same page, you can assign each button with a\n\t * unique string. The same string would return along with the ID\n\t * token, so you can identify which button user clicked to sign in.\n\t */\n\tstate?: string;\n}\n\nexport interface GoogleOneTapOptions {\n\t/**\n\t * Google client ID\n\t */\n\tclientId: string;\n\t/**\n\t * Auto select the account if the user is already signed in\n\t */\n\tautoSelect?: boolean | undefined;\n\t/**\n\t * Cancel the flow when the user taps outside the prompt\n\t *\n\t * Note: To use this option, disable `promptOptions.fedCM`\n\t */\n\tcancelOnTapOutside?: boolean | undefined;\n\t/**\n\t * The mode to use for the Google One Tap flow\n\t *\n\t * popup: Use a popup window\n\t * redirect: Redirect the user to the Google One Tap flow\n\t *\n\t * @default \"popup\"\n\t */\n\tuxMode?: (\"popup\" | \"redirect\") | undefined;\n\t/**\n\t * The context to use for the Google One Tap flow.\n\t *\n\t * @see {@link https://developers.google.com/identity/gsi/web/reference/js-reference}\n\t * @default \"signin\"\n\t */\n\tcontext?: (\"signin\" | \"signup\" | \"use\") | undefined;\n\t/**\n\t * Additional configuration options to pass to the Google One Tap API.\n\t */\n\tadditionalOptions?: Record<string, any> | undefined;\n\t/**\n\t * Configuration options for the prompt and exponential backoff behavior.\n\t */\n\tpromptOptions?:\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Base delay (in milliseconds) for exponential backoff.\n\t\t\t\t * @default 1000\n\t\t\t\t */\n\t\t\t\tbaseDelay?: number;\n\t\t\t\t/**\n\t\t\t\t * Maximum number of prompt attempts before calling onPromptNotification.\n\t\t\t\t * @default 5\n\t\t\t\t */\n\t\t\t\tmaxAttempts?: number;\n\t\t\t\t/**\n\t\t\t\t * Whether to support FedCM (Federated Credential Management) support.\n\t\t\t\t *\n\t\t\t\t * @see {@link https://developer.chrome.com/docs/identity/fedcm/overview}\n\t\t\t\t * @default true\n\t\t\t\t */\n\t\t\t\tfedCM?: boolean | undefined;\n\t\t }\n\t\t| undefined;\n}\n\nexport interface GoogleOneTapActionOptions\n\textends Omit<GoogleOneTapOptions, \"clientId\" | \"promptOptions\"> {\n\tfetchOptions?: ClientFetchOption | undefined;\n\t/**\n\t * Callback URL.\n\t */\n\tcallbackURL?: string | undefined;\n\t/**\n\t * Optional callback that receives the prompt notification if (or when) the prompt is dismissed or skipped.\n\t * This lets you render an alternative UI (e.g. a Google Sign-In button) to restart the process.\n\t */\n\tonPromptNotification?: ((notification?: any | undefined) => void) | undefined;\n\tnonce?: string | undefined;\n\t/**\n\t * Button mode configuration. When provided, renders a \"Sign In with Google\" button\n\t * instead of showing the One Tap prompt.\n\t */\n\tbutton?:\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * The HTML element or CSS selector where the button should be rendered.\n\t\t\t\t * If a string is provided, it will be used as a CSS selector.\n\t\t\t\t */\n\t\t\t\tcontainer: HTMLElement | string;\n\t\t\t\t/**\n\t\t\t\t * Button configuration options\n\t\t\t\t */\n\t\t\t\tconfig?: GsiButtonConfiguration | undefined;\n\t\t }\n\t\t| undefined;\n}\n\nlet isRequestInProgress = false;\n\nfunction isFedCMSupported() {\n\treturn typeof window !== \"undefined\" && \"IdentityCredential\" in window;\n}\n\n/**\n * Reasons that should NOT trigger a retry.\n * @see https://developers.google.com/identity/gsi/web/reference/js-reference\n */\nconst noRetryReasons = {\n\tdismissed: [\"credential_returned\", \"cancel_called\"],\n\tskipped: [\"user_cancel\", \"tap_outside\"],\n} as const;\n\nexport const oneTapClient = (options: GoogleOneTapOptions) => {\n\treturn {\n\t\tid: \"one-tap\",\n\t\tfetchPlugins: [\n\t\t\t{\n\t\t\t\tid: \"fedcm-signout-handle\",\n\t\t\t\tname: \"FedCM Sign-Out Handler\",\n\t\t\t\thooks: {\n\t\t\t\t\tasync onResponse(ctx) {\n\t\t\t\t\t\tif (!ctx.request.url.toString().includes(\"/sign-out\")) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (options.promptOptions?.fedCM === false || !isFedCMSupported()) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnavigator.credentials.preventSilentAccess();\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tgetActions: ($fetch, _) => {\n\t\t\treturn {\n\t\t\t\toneTap: async (\n\t\t\t\t\topts?: GoogleOneTapActionOptions | undefined,\n\t\t\t\t\tfetchOptions?: ClientFetchOption | undefined,\n\t\t\t\t) => {\n\t\t\t\t\tif (isRequestInProgress) {\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\"A Google One Tap request is already in progress. Please wait.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (typeof window === \"undefined\" || !window.document) {\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\"Google One Tap is only available in browser environments\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Button mode: render a button instead of showing the prompt\n\t\t\t\t\tif (opts?.button) {\n\t\t\t\t\t\tawait loadGoogleScript();\n\n\t\t\t\t\t\tconst container =\n\t\t\t\t\t\t\ttypeof opts.button.container === \"string\"\n\t\t\t\t\t\t\t\t? document.querySelector<HTMLElement>(opts.button.container)\n\t\t\t\t\t\t\t\t: opts.button.container;\n\n\t\t\t\t\t\tif (!container) {\n\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\"Google One Tap: Button container not found\",\n\t\t\t\t\t\t\t\topts.button.container,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tasync function callback(idToken: string) {\n\t\t\t\t\t\t\tawait $fetch(\"/one-tap/callback\", {\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\tbody: { idToken },\n\t\t\t\t\t\t\t\t...opts?.fetchOptions,\n\t\t\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif ((!opts?.fetchOptions && !fetchOptions) || opts?.callbackURL) {\n\t\t\t\t\t\t\t\twindow.location.href = opts?.callbackURL ?? \"/\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst { autoSelect, cancelOnTapOutside, context } = opts ?? {};\n\t\t\t\t\t\tconst contextValue = context ?? options.context ?? \"signin\";\n\n\t\t\t\t\t\twindow.google?.accounts.id.initialize({\n\t\t\t\t\t\t\tclient_id: options.clientId,\n\t\t\t\t\t\t\tcallback: async (response: { credential: string }) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait callback(response.credential);\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tconsole.error(\"Error during button callback:\", error);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tauto_select: autoSelect,\n\t\t\t\t\t\t\tcancel_on_tap_outside: cancelOnTapOutside,\n\t\t\t\t\t\t\tcontext: contextValue,\n\t\t\t\t\t\t\tux_mode: opts?.uxMode || \"popup\",\n\t\t\t\t\t\t\tnonce: opts?.nonce,\n\t\t\t\t\t\t\titp_support: true,\n\t\t\t\t\t\t\t...options.additionalOptions,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\twindow.google?.accounts.id.renderButton(\n\t\t\t\t\t\t\tcontainer,\n\t\t\t\t\t\t\topts.button.config ?? {\n\t\t\t\t\t\t\t\ttype: \"icon\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tasync function callback(idToken: string) {\n\t\t\t\t\t\tawait $fetch(\"/one-tap/callback\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: { idToken },\n\t\t\t\t\t\t\t...opts?.fetchOptions,\n\t\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif ((!opts?.fetchOptions && !fetchOptions) || opts?.callbackURL) {\n\t\t\t\t\t\t\twindow.location.href = opts?.callbackURL ?? \"/\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { autoSelect, cancelOnTapOutside, context } = opts ?? {};\n\t\t\t\t\tconst contextValue = context ?? options.context ?? \"signin\";\n\t\t\t\t\tisRequestInProgress = true;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait loadGoogleScript();\n\t\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\t\tlet isResolved = false;\n\t\t\t\t\t\t\tconst baseDelay = options.promptOptions?.baseDelay ?? 1000;\n\t\t\t\t\t\t\tconst maxAttempts = options.promptOptions?.maxAttempts ?? 5;\n\n\t\t\t\t\t\t\twindow.google?.accounts.id.initialize({\n\t\t\t\t\t\t\t\tclient_id: options.clientId,\n\t\t\t\t\t\t\t\tcallback: async (response: { credential: string }) => {\n\t\t\t\t\t\t\t\t\tisResolved = true;\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tawait callback(response.credential);\n\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.error(\"Error during One Tap callback:\", error);\n\t\t\t\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tauto_select: autoSelect,\n\t\t\t\t\t\t\t\tcancel_on_tap_outside: cancelOnTapOutside,\n\t\t\t\t\t\t\t\tcontext: contextValue,\n\t\t\t\t\t\t\t\tux_mode: opts?.uxMode || \"popup\",\n\t\t\t\t\t\t\t\tnonce: opts?.nonce,\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * @see {@link https://developers.google.com/identity/gsi/web/guides/overview}\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\titp_support: true,\n\n\t\t\t\t\t\t\t\t...options.additionalOptions,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst handlePrompt = (attempt: number) => {\n\t\t\t\t\t\t\t\tif (isResolved) return;\n\n\t\t\t\t\t\t\t\twindow.google?.accounts.id.prompt((notification: any) => {\n\t\t\t\t\t\t\t\t\tif (isResolved) return;\n\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tnotification.isDismissedMoment &&\n\t\t\t\t\t\t\t\t\t\tnotification.isDismissedMoment()\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tconst reason = notification.getDismissedReason?.();\n\t\t\t\t\t\t\t\t\t\tif (noRetryReasons.dismissed.includes(reason)) {\n\t\t\t\t\t\t\t\t\t\t\topts?.onPromptNotification?.(notification);\n\t\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (attempt < maxAttempts) {\n\t\t\t\t\t\t\t\t\t\t\tconst delay = Math.pow(2, attempt) * baseDelay;\n\t\t\t\t\t\t\t\t\t\t\tsetTimeout(() => handlePrompt(attempt + 1), delay);\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\topts?.onPromptNotification?.(notification);\n\t\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\tnotification.isSkippedMoment &&\n\t\t\t\t\t\t\t\t\t\tnotification.isSkippedMoment()\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tconst reason = notification.getSkippedReason?.();\n\t\t\t\t\t\t\t\t\t\tif (!reason || noRetryReasons.skipped.includes(reason)) {\n\t\t\t\t\t\t\t\t\t\t\topts?.onPromptNotification?.(notification);\n\t\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (attempt < maxAttempts) {\n\t\t\t\t\t\t\t\t\t\t\tconst delay = Math.pow(2, attempt) * baseDelay;\n\t\t\t\t\t\t\t\t\t\t\tsetTimeout(() => handlePrompt(attempt + 1), delay);\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\topts?.onPromptNotification?.(notification);\n\t\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\tnotification.isNotDisplayed &&\n\t\t\t\t\t\t\t\t\t\tnotification.isNotDisplayed()\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\topts?.onPromptNotification?.(notification);\n\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\thandlePrompt(0);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error(\"Error during Google One Tap flow:\", error);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tisRequestInProgress = false;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tgetAtoms($fetch) {\n\t\t\treturn {};\n\t\t},\n\t} satisfies BetterAuthClientPlugin;\n};\n\nconst loadGoogleScript = (): Promise<void> => {\n\treturn new Promise((resolve, reject) => {\n\t\tif (window.googleScriptInitialized) {\n\t\t\tresolve();\n\t\t\treturn;\n\t\t}\n\n\t\tconst script = document.createElement(\"script\");\n\t\tscript.src = \"https://accounts.google.com/gsi/client\";\n\t\tscript.async = true;\n\t\tscript.defer = true;\n\t\tscript.onload = () => {\n\t\t\twindow.googleScriptInitialized = true;\n\t\t\tresolve();\n\t\t};\n\t\tscript.onerror = () => {\n\t\t\treject(new Error(\"Failed to load Google Identity Services script\"));\n\t\t};\n\t\tdocument.head.appendChild(script);\n\t});\n};\n"],"mappings":"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"}
@@ -0,0 +1,83 @@
1
+ import * as better_call0 from "better-call";
2
+ import * as z from "zod";
3
+
4
+ //#region src/plugins/one-tap/index.d.ts
5
+ declare module "@better-auth/core" {
6
+ interface BetterAuthPluginRegistry<AuthOptions, Options> {
7
+ "one-tap": {
8
+ creator: typeof oneTap;
9
+ };
10
+ }
11
+ }
12
+ interface OneTapOptions {
13
+ /**
14
+ * Disable the signup flow
15
+ *
16
+ * @default false
17
+ */
18
+ disableSignup?: boolean | undefined;
19
+ /**
20
+ * Google Client ID
21
+ *
22
+ * If a client ID is provided in the social provider configuration,
23
+ * it will be used.
24
+ */
25
+ clientId?: string | undefined;
26
+ }
27
+ declare const oneTap: (options?: OneTapOptions | undefined) => {
28
+ id: "one-tap";
29
+ endpoints: {
30
+ oneTapCallback: better_call0.StrictEndpoint<"/one-tap/callback", {
31
+ method: "POST";
32
+ body: z.ZodObject<{
33
+ idToken: z.ZodString;
34
+ }, z.core.$strip>;
35
+ metadata: {
36
+ openapi: {
37
+ summary: string;
38
+ description: string;
39
+ responses: {
40
+ 200: {
41
+ description: string;
42
+ content: {
43
+ "application/json": {
44
+ schema: {
45
+ type: "object";
46
+ properties: {
47
+ session: {
48
+ $ref: string;
49
+ };
50
+ user: {
51
+ $ref: string;
52
+ };
53
+ };
54
+ };
55
+ };
56
+ };
57
+ };
58
+ 400: {
59
+ description: string;
60
+ };
61
+ };
62
+ };
63
+ };
64
+ }, {
65
+ error: string;
66
+ } | {
67
+ token: string;
68
+ user: {
69
+ id: string;
70
+ createdAt: Date;
71
+ updatedAt: Date;
72
+ email: string;
73
+ emailVerified: boolean;
74
+ name: string;
75
+ image?: string | null | undefined;
76
+ };
77
+ }>;
78
+ };
79
+ options: OneTapOptions | undefined;
80
+ };
81
+ //#endregion
82
+ export { OneTapOptions, oneTap };
83
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,95 @@
1
+ import { parseUserOutput } from "../../db/schema.mjs";
2
+ import { setSessionCookie } from "../../cookies/index.mjs";
3
+ import { APIError } from "../../api/index.mjs";
4
+ import { toBoolean } from "../../utils/boolean.mjs";
5
+ import { createAuthEndpoint } from "@better-auth/core/api";
6
+ import * as z from "zod";
7
+ import { createRemoteJWKSet, jwtVerify } from "jose";
8
+
9
+ //#region src/plugins/one-tap/index.ts
10
+ const oneTapCallbackBodySchema = z.object({ idToken: z.string().meta({ description: "Google ID token, which the client obtains from the One Tap API" }) });
11
+ const oneTap = (options) => ({
12
+ id: "one-tap",
13
+ endpoints: { oneTapCallback: createAuthEndpoint("/one-tap/callback", {
14
+ method: "POST",
15
+ body: oneTapCallbackBodySchema,
16
+ metadata: { openapi: {
17
+ summary: "One tap callback",
18
+ description: "Use this endpoint to authenticate with Google One Tap",
19
+ responses: {
20
+ 200: {
21
+ description: "Successful response",
22
+ content: { "application/json": { schema: {
23
+ type: "object",
24
+ properties: {
25
+ session: { $ref: "#/components/schemas/Session" },
26
+ user: { $ref: "#/components/schemas/User" }
27
+ }
28
+ } } }
29
+ },
30
+ 400: { description: "Invalid token" }
31
+ }
32
+ } }
33
+ }, async (ctx) => {
34
+ const { idToken } = ctx.body;
35
+ let payload;
36
+ try {
37
+ const JWKS = createRemoteJWKSet(new URL("https://www.googleapis.com/oauth2/v3/certs"));
38
+ const googleProvider = typeof ctx.context.options.socialProviders?.google === "function" ? await ctx.context.options.socialProviders?.google() : ctx.context.options.socialProviders?.google;
39
+ const { payload: verifiedPayload } = await jwtVerify(idToken, JWKS, {
40
+ issuer: ["https://accounts.google.com", "accounts.google.com"],
41
+ audience: options?.clientId || googleProvider?.clientId
42
+ });
43
+ payload = verifiedPayload;
44
+ } catch {
45
+ throw new APIError("BAD_REQUEST", { message: "invalid id token" });
46
+ }
47
+ const { email, email_verified, name, picture, sub } = payload;
48
+ if (!email) return ctx.json({ error: "Email not available in token" });
49
+ const user = await ctx.context.internalAdapter.findUserByEmail(email);
50
+ if (!user) {
51
+ if (options?.disableSignup) throw new APIError("BAD_GATEWAY", { message: "User not found" });
52
+ const newUser = await ctx.context.internalAdapter.createOAuthUser({
53
+ email,
54
+ emailVerified: typeof email_verified === "boolean" ? email_verified : toBoolean(email_verified),
55
+ name,
56
+ image: picture
57
+ }, {
58
+ providerId: "google",
59
+ accountId: sub
60
+ });
61
+ if (!newUser) throw new APIError("INTERNAL_SERVER_ERROR", { message: "Could not create user" });
62
+ const session = await ctx.context.internalAdapter.createSession(newUser.user.id);
63
+ await setSessionCookie(ctx, {
64
+ user: newUser.user,
65
+ session
66
+ });
67
+ return ctx.json({
68
+ token: session.token,
69
+ user: parseUserOutput(ctx.context.options, newUser.user)
70
+ });
71
+ }
72
+ if (!await ctx.context.internalAdapter.findAccount(sub)) if ((ctx.context.options.account?.accountLinking)?.enabled !== false && (ctx.context.trustedProviders.includes("google") || email_verified)) await ctx.context.internalAdapter.linkAccount({
73
+ userId: user.user.id,
74
+ providerId: "google",
75
+ accountId: sub,
76
+ scope: "openid,profile,email",
77
+ idToken
78
+ });
79
+ else throw new APIError("UNAUTHORIZED", { message: "Google sub doesn't match" });
80
+ const session = await ctx.context.internalAdapter.createSession(user.user.id);
81
+ await setSessionCookie(ctx, {
82
+ user: user.user,
83
+ session
84
+ });
85
+ return ctx.json({
86
+ token: session.token,
87
+ user: parseUserOutput(ctx.context.options, user.user)
88
+ });
89
+ }) },
90
+ options
91
+ });
92
+
93
+ //#endregion
94
+ export { oneTap };
95
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/one-tap/index.ts"],"sourcesContent":["import type { BetterAuthPlugin } from \"@better-auth/core\";\nimport { createAuthEndpoint } from \"@better-auth/core/api\";\nimport { createRemoteJWKSet, jwtVerify } from \"jose\";\nimport * as z from \"zod\";\nimport { APIError } from \"../../api\";\nimport { setSessionCookie } from \"../../cookies\";\nimport { parseUserOutput } from \"../../db/schema\";\nimport { toBoolean } from \"../../utils/boolean\";\n\ndeclare module \"@better-auth/core\" {\n\tinterface BetterAuthPluginRegistry<AuthOptions, Options> {\n\t\t\"one-tap\": {\n\t\t\tcreator: typeof oneTap;\n\t\t};\n\t}\n}\n\nexport interface OneTapOptions {\n\t/**\n\t * Disable the signup flow\n\t *\n\t * @default false\n\t */\n\tdisableSignup?: boolean | undefined;\n\t/**\n\t * Google Client ID\n\t *\n\t * If a client ID is provided in the social provider configuration,\n\t * it will be used.\n\t */\n\tclientId?: string | undefined;\n}\n\nconst oneTapCallbackBodySchema = z.object({\n\tidToken: z.string().meta({\n\t\tdescription:\n\t\t\t\"Google ID token, which the client obtains from the One Tap API\",\n\t}),\n});\n\nexport const oneTap = (options?: OneTapOptions | undefined) =>\n\t({\n\t\tid: \"one-tap\",\n\t\tendpoints: {\n\t\t\toneTapCallback: createAuthEndpoint(\n\t\t\t\t\"/one-tap/callback\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: oneTapCallbackBodySchema,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\topenapi: {\n\t\t\t\t\t\t\tsummary: \"One tap callback\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"Use this endpoint to authenticate with Google One Tap\",\n\t\t\t\t\t\t\tresponses: {\n\t\t\t\t\t\t\t\t200: {\n\t\t\t\t\t\t\t\t\tdescription: \"Successful response\",\n\t\t\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t\t\t\"application/json\": {\n\t\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsession: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t$ref: \"#/components/schemas/Session\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t$ref: \"#/components/schemas/User\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t400: {\n\t\t\t\t\t\t\t\t\tdescription: \"Invalid token\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tasync (ctx) => {\n\t\t\t\t\tconst { idToken } = ctx.body;\n\t\t\t\t\tlet payload: any;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst JWKS = createRemoteJWKSet(\n\t\t\t\t\t\t\tnew URL(\"https://www.googleapis.com/oauth2/v3/certs\"),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst googleProvider =\n\t\t\t\t\t\t\ttypeof ctx.context.options.socialProviders?.google === \"function\"\n\t\t\t\t\t\t\t\t? await ctx.context.options.socialProviders?.google()\n\t\t\t\t\t\t\t\t: ctx.context.options.socialProviders?.google;\n\t\t\t\t\t\tconst { payload: verifiedPayload } = await jwtVerify(\n\t\t\t\t\t\t\tidToken,\n\t\t\t\t\t\t\tJWKS,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tissuer: [\"https://accounts.google.com\", \"accounts.google.com\"],\n\t\t\t\t\t\t\t\taudience: options?.clientId || googleProvider?.clientId,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpayload = verifiedPayload;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthrow new APIError(\"BAD_REQUEST\", {\n\t\t\t\t\t\t\tmessage: \"invalid id token\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst { email, email_verified, name, picture, sub } = payload;\n\t\t\t\t\tif (!email) {\n\t\t\t\t\t\treturn ctx.json({ error: \"Email not available in token\" });\n\t\t\t\t\t}\n\n\t\t\t\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\t\t\t\tif (!user) {\n\t\t\t\t\t\tif (options?.disableSignup) {\n\t\t\t\t\t\t\tthrow new APIError(\"BAD_GATEWAY\", {\n\t\t\t\t\t\t\t\tmessage: \"User not found\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst newUser = await ctx.context.internalAdapter.createOAuthUser(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\temail,\n\t\t\t\t\t\t\t\temailVerified:\n\t\t\t\t\t\t\t\t\ttypeof email_verified === \"boolean\"\n\t\t\t\t\t\t\t\t\t\t? email_verified\n\t\t\t\t\t\t\t\t\t\t: toBoolean(email_verified),\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\timage: picture,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tproviderId: \"google\",\n\t\t\t\t\t\t\t\taccountId: sub,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (!newUser) {\n\t\t\t\t\t\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\", {\n\t\t\t\t\t\t\t\tmessage: \"Could not create user\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst session = await ctx.context.internalAdapter.createSession(\n\t\t\t\t\t\t\tnewUser.user.id,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait setSessionCookie(ctx, {\n\t\t\t\t\t\t\tuser: newUser.user,\n\t\t\t\t\t\t\tsession,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn ctx.json({\n\t\t\t\t\t\t\ttoken: session.token,\n\t\t\t\t\t\t\tuser: parseUserOutput(ctx.context.options, newUser.user),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst account = await ctx.context.internalAdapter.findAccount(sub);\n\t\t\t\t\tif (!account) {\n\t\t\t\t\t\tconst accountLinking = ctx.context.options.account?.accountLinking;\n\t\t\t\t\t\tconst shouldLinkAccount =\n\t\t\t\t\t\t\taccountLinking?.enabled !== false &&\n\t\t\t\t\t\t\t(ctx.context.trustedProviders.includes(\"google\") ||\n\t\t\t\t\t\t\t\temail_verified);\n\t\t\t\t\t\tif (shouldLinkAccount) {\n\t\t\t\t\t\t\tawait ctx.context.internalAdapter.linkAccount({\n\t\t\t\t\t\t\t\tuserId: user.user.id,\n\t\t\t\t\t\t\t\tproviderId: \"google\",\n\t\t\t\t\t\t\t\taccountId: sub,\n\t\t\t\t\t\t\t\tscope: \"openid,profile,email\",\n\t\t\t\t\t\t\t\tidToken,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\t\t\t\t\tmessage: \"Google sub doesn't match\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst session = await ctx.context.internalAdapter.createSession(\n\t\t\t\t\t\tuser.user.id,\n\t\t\t\t\t);\n\n\t\t\t\t\tawait setSessionCookie(ctx, {\n\t\t\t\t\t\tuser: user.user,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t});\n\t\t\t\t\treturn ctx.json({\n\t\t\t\t\t\ttoken: session.token,\n\t\t\t\t\t\tuser: parseUserOutput(ctx.context.options, user.user),\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t),\n\t\t},\n\t\toptions,\n\t}) satisfies BetterAuthPlugin;\n"],"mappings":";;;;;;;;;AAiCA,MAAM,2BAA2B,EAAE,OAAO,EACzC,SAAS,EAAE,QAAQ,CAAC,KAAK,EACxB,aACC,kEACD,CAAC,EACF,CAAC;AAEF,MAAa,UAAU,aACrB;CACA,IAAI;CACJ,WAAW,EACV,gBAAgB,mBACf,qBACA;EACC,QAAQ;EACR,MAAM;EACN,UAAU,EACT,SAAS;GACR,SAAS;GACT,aACC;GACD,WAAW;IACV,KAAK;KACJ,aAAa;KACb,SAAS,EACR,oBAAoB,EACnB,QAAQ;MACP,MAAM;MACN,YAAY;OACX,SAAS,EACR,MAAM,gCACN;OACD,MAAM,EACL,MAAM,6BACN;OACD;MACD,EACD,EACD;KACD;IACD,KAAK,EACJ,aAAa,iBACb;IACD;GACD,EACD;EACD,EACD,OAAO,QAAQ;EACd,MAAM,EAAE,YAAY,IAAI;EACxB,IAAI;AACJ,MAAI;GACH,MAAM,OAAO,mBACZ,IAAI,IAAI,6CAA6C,CACrD;GACD,MAAM,iBACL,OAAO,IAAI,QAAQ,QAAQ,iBAAiB,WAAW,aACpD,MAAM,IAAI,QAAQ,QAAQ,iBAAiB,QAAQ,GACnD,IAAI,QAAQ,QAAQ,iBAAiB;GACzC,MAAM,EAAE,SAAS,oBAAoB,MAAM,UAC1C,SACA,MACA;IACC,QAAQ,CAAC,+BAA+B,sBAAsB;IAC9D,UAAU,SAAS,YAAY,gBAAgB;IAC/C,CACD;AACD,aAAU;UACH;AACP,SAAM,IAAI,SAAS,eAAe,EACjC,SAAS,oBACT,CAAC;;EAEH,MAAM,EAAE,OAAO,gBAAgB,MAAM,SAAS,QAAQ;AACtD,MAAI,CAAC,MACJ,QAAO,IAAI,KAAK,EAAE,OAAO,gCAAgC,CAAC;EAG3D,MAAM,OAAO,MAAM,IAAI,QAAQ,gBAAgB,gBAAgB,MAAM;AACrE,MAAI,CAAC,MAAM;AACV,OAAI,SAAS,cACZ,OAAM,IAAI,SAAS,eAAe,EACjC,SAAS,kBACT,CAAC;GAEH,MAAM,UAAU,MAAM,IAAI,QAAQ,gBAAgB,gBACjD;IACC;IACA,eACC,OAAO,mBAAmB,YACvB,iBACA,UAAU,eAAe;IAC7B;IACA,OAAO;IACP,EACD;IACC,YAAY;IACZ,WAAW;IACX,CACD;AACD,OAAI,CAAC,QACJ,OAAM,IAAI,SAAS,yBAAyB,EAC3C,SAAS,yBACT,CAAC;GAEH,MAAM,UAAU,MAAM,IAAI,QAAQ,gBAAgB,cACjD,QAAQ,KAAK,GACb;AACD,SAAM,iBAAiB,KAAK;IAC3B,MAAM,QAAQ;IACd;IACA,CAAC;AACF,UAAO,IAAI,KAAK;IACf,OAAO,QAAQ;IACf,MAAM,gBAAgB,IAAI,QAAQ,SAAS,QAAQ,KAAK;IACxD,CAAC;;AAGH,MAAI,CADY,MAAM,IAAI,QAAQ,gBAAgB,YAAY,IAAI,CAOjE,MALuB,IAAI,QAAQ,QAAQ,SAAS,iBAEnC,YAAY,UAC3B,IAAI,QAAQ,iBAAiB,SAAS,SAAS,IAC/C,gBAED,OAAM,IAAI,QAAQ,gBAAgB,YAAY;GAC7C,QAAQ,KAAK,KAAK;GAClB,YAAY;GACZ,WAAW;GACX,OAAO;GACP;GACA,CAAC;MAEF,OAAM,IAAI,SAAS,gBAAgB,EAClC,SAAS,4BACT,CAAC;EAGJ,MAAM,UAAU,MAAM,IAAI,QAAQ,gBAAgB,cACjD,KAAK,KAAK,GACV;AAED,QAAM,iBAAiB,KAAK;GAC3B,MAAM,KAAK;GACX;GACA,CAAC;AACF,SAAO,IAAI,KAAK;GACf,OAAO,QAAQ;GACf,MAAM,gBAAgB,IAAI,QAAQ,SAAS,KAAK,KAAK;GACrD,CAAC;GAEH,EACD;CACD;CACA"}
@@ -0,0 +1,10 @@
1
+ import { OneTimeTokenOptions, oneTimeToken } from "./index.mjs";
2
+
3
+ //#region src/plugins/one-time-token/client.d.ts
4
+ declare const oneTimeTokenClient: () => {
5
+ id: "one-time-token";
6
+ $InferServerPlugin: ReturnType<typeof oneTimeToken>;
7
+ };
8
+ //#endregion
9
+ export { oneTimeTokenClient };
10
+ //# sourceMappingURL=client.d.mts.map
@@ -0,0 +1,11 @@
1
+ //#region src/plugins/one-time-token/client.ts
2
+ const oneTimeTokenClient = () => {
3
+ return {
4
+ id: "one-time-token",
5
+ $InferServerPlugin: {}
6
+ };
7
+ };
8
+
9
+ //#endregion
10
+ export { oneTimeTokenClient };
11
+ //# sourceMappingURL=client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.mjs","names":[],"sources":["../../../src/plugins/one-time-token/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"@better-auth/core\";\nimport type { oneTimeToken } from \"./index\";\n\nexport const oneTimeTokenClient = () => {\n\treturn {\n\t\tid: \"one-time-token\",\n\t\t$InferServerPlugin: {} as ReturnType<typeof oneTimeToken>,\n\t} satisfies BetterAuthClientPlugin;\n};\n\nexport type { OneTimeTokenOptions } from \"./index\";\n"],"mappings":";AAGA,MAAa,2BAA2B;AACvC,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EACtB"}