@gatwech/auth 1.0.0-beta.18

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 (422) hide show
  1. package/README.md +31 -0
  2. package/dist/access-BO2g7QVe.mjs +45 -0
  3. package/dist/access-C6O_osEz.mjs +79 -0
  4. package/dist/access-DT1f6l5k.mjs +51 -0
  5. package/dist/adapter-factory-BZ2Qiqpn.mjs +640 -0
  6. package/dist/adapters/drizzle-adapter/index.d.mts +47 -0
  7. package/dist/adapters/drizzle-adapter/index.mjs +208 -0
  8. package/dist/adapters/index.d.mts +132 -0
  9. package/dist/adapters/index.mjs +18 -0
  10. package/dist/adapters/kysely-adapter/index.d.mts +47 -0
  11. package/dist/adapters/kysely-adapter/index.mjs +11 -0
  12. package/dist/adapters/memory-adapter/index.d.mts +14 -0
  13. package/dist/adapters/memory-adapter/index.mjs +154 -0
  14. package/dist/adapters/mongodb-adapter/index.d.mts +35 -0
  15. package/dist/adapters/mongodb-adapter/index.mjs +315 -0
  16. package/dist/adapters/prisma-adapter/index.d.mts +34 -0
  17. package/dist/adapters/prisma-adapter/index.mjs +159 -0
  18. package/dist/adapters/test.d.mts +81 -0
  19. package/dist/adapters/test.mjs +793 -0
  20. package/dist/admin-Bcq53Nwj.mjs +743 -0
  21. package/dist/admin-DtfO1PLg.d.mts +1689 -0
  22. package/dist/anonymous-CRt1imBW.mjs +107 -0
  23. package/dist/api/index.d.mts +6 -0
  24. package/dist/api/index.mjs +17 -0
  25. package/dist/api-0pR_I-Nx.mjs +3139 -0
  26. package/dist/auth-CBUoBX6o.mjs +233 -0
  27. package/dist/bearer-Djf_awfo.mjs +63 -0
  28. package/dist/bun-sqlite-dialect-CeNvMaZz.mjs +155 -0
  29. package/dist/captcha-BqaMxlKC.mjs +178 -0
  30. package/dist/chunk-BK_LfMhE.mjs +40 -0
  31. package/dist/client/index.d.mts +186 -0
  32. package/dist/client/index.mjs +7 -0
  33. package/dist/client/plugins/index.d.mts +949 -0
  34. package/dist/client/plugins/index.mjs +539 -0
  35. package/dist/client/react/index.d.mts +179 -0
  36. package/dist/client/react/index.mjs +69 -0
  37. package/dist/client-BOX93C3d.d.mts +1250 -0
  38. package/dist/client-CNY0tn9g.d.mts +628 -0
  39. package/dist/client-CygJhqeB.mjs +29 -0
  40. package/dist/client-WiN43tAS.mjs +17 -0
  41. package/dist/client-aExCkfwm.mjs +30 -0
  42. package/dist/cookies/index.d.mts +7 -0
  43. package/dist/cookies/index.mjs +7 -0
  44. package/dist/cookies-cJObLwn1.mjs +597 -0
  45. package/dist/crypto/index.d.mts +44 -0
  46. package/dist/crypto/index.mjs +4 -0
  47. package/dist/crypto-Bb42eMrH.mjs +70 -0
  48. package/dist/custom-session-L3t7ecsd.mjs +67 -0
  49. package/dist/date-Cx2yCiC4.mjs +115 -0
  50. package/dist/db/index.d.mts +7 -0
  51. package/dist/db/index.mjs +15 -0
  52. package/dist/db-BrstmDhc.mjs +1124 -0
  53. package/dist/device-authorization-V4s3h4Mj.mjs +557 -0
  54. package/dist/dialect-CeddeGHf.mjs +72 -0
  55. package/dist/email-otp-BtDHSw14.mjs +592 -0
  56. package/dist/esm-C-QicDNz.mjs +4090 -0
  57. package/dist/generic-oauth-CL5X27ZI.mjs +445 -0
  58. package/dist/get-request-ip-DSjrEpGo.mjs +27 -0
  59. package/dist/get-tables-BQP7YW9c.mjs +249 -0
  60. package/dist/has-permission-BpAr7uCn.mjs +14 -0
  61. package/dist/haveibeenpwned-cMpJvmzI.mjs +43 -0
  62. package/dist/helper-tmxW3BHj.d.mts +21 -0
  63. package/dist/index-34ONrP8l.d.mts +503 -0
  64. package/dist/index-65G5U5DB-DSdjzreF.d.mts +2543 -0
  65. package/dist/index-B-XKqFvY.d.mts +30 -0
  66. package/dist/index-B3n8e37d.d.mts +165 -0
  67. package/dist/index-BBm8nQ9Q.d.mts +42 -0
  68. package/dist/index-BHoQlf7a.d.mts +7699 -0
  69. package/dist/index-BYMI9r_d.d.mts +257 -0
  70. package/dist/index-BqhKCbPH.d.mts +36 -0
  71. package/dist/index-Buhn3hkR.d.mts +433 -0
  72. package/dist/index-C-u1h_WX.d.mts +174 -0
  73. package/dist/index-C7fQuk-V.d.mts +41 -0
  74. package/dist/index-CM-CFWwr.d.mts +1919 -0
  75. package/dist/index-CuFzhoS6.d.mts +359 -0
  76. package/dist/index-Cxi7TbLE.d.mts +11347 -0
  77. package/dist/index-DB7t8whN.d.mts +1 -0
  78. package/dist/index-DKNNV1kb.d.mts +626 -0
  79. package/dist/index-DR0xXno9.d.mts +113 -0
  80. package/dist/index-D_k662QG.d.mts +833 -0
  81. package/dist/index-DaBcikv9.d.mts +118 -0
  82. package/dist/index-DlaMq1nb.d.mts +955 -0
  83. package/dist/index-DoXZYQpq.d.mts +290 -0
  84. package/dist/index-G6V0Z_Mn.d.mts +125 -0
  85. package/dist/index-z0KSvE5i.d.mts +246 -0
  86. package/dist/index-zjjNBRY2.d.mts +95 -0
  87. package/dist/index.d.mts +12 -0
  88. package/dist/index.mjs +33 -0
  89. package/dist/integrations/next-js.d.mts +21 -0
  90. package/dist/integrations/next-js.mjs +62 -0
  91. package/dist/integrations/node.d.mts +15 -0
  92. package/dist/integrations/node.mjs +15 -0
  93. package/dist/integrations/react-start.d.mts +15 -0
  94. package/dist/integrations/react-start.mjs +46 -0
  95. package/dist/json-D0TBLy4q.mjs +24 -0
  96. package/dist/jwt-CmxZAGe2.mjs +94 -0
  97. package/dist/jwt-lHV4QHpD.mjs +387 -0
  98. package/dist/kysely-adapter-DpzYO8Yf.mjs +181 -0
  99. package/dist/magic-link-Bk-ueorR.mjs +176 -0
  100. package/dist/misc-beA1w3XV.mjs +7 -0
  101. package/dist/multi-session-DRrLKrg9.mjs +144 -0
  102. package/dist/node-sqlite-dialect-BcKxBQnm.mjs +155 -0
  103. package/dist/oauth-proxy-D1sWh9B_.mjs +133 -0
  104. package/dist/oauth2/index.d.mts +60 -0
  105. package/dist/oauth2/index.mjs +19 -0
  106. package/dist/one-tap-DMswkTEc.mjs +113 -0
  107. package/dist/organization-BArHO_5v.mjs +3857 -0
  108. package/dist/parser-DcrIEuXE.mjs +73 -0
  109. package/dist/passkey-CcD4CnhM.mjs +558 -0
  110. package/dist/password-sVC4nePO.mjs +25 -0
  111. package/dist/permission-DLYUF3cW.mjs +15 -0
  112. package/dist/phone-number-rHDIlh-2.mjs +485 -0
  113. package/dist/plugin-helper-4L-lzsjZ.mjs +16 -0
  114. package/dist/plugins/access/index.d.mts +3 -0
  115. package/dist/plugins/access/index.mjs +3 -0
  116. package/dist/plugins/admin/access/index.d.mts +116 -0
  117. package/dist/plugins/admin/access/index.mjs +4 -0
  118. package/dist/plugins/admin/index.d.mts +9 -0
  119. package/dist/plugins/admin/index.mjs +22 -0
  120. package/dist/plugins/anonymous/index.d.mts +7 -0
  121. package/dist/plugins/anonymous/index.mjs +18 -0
  122. package/dist/plugins/bearer/index.d.mts +2 -0
  123. package/dist/plugins/bearer/index.mjs +8 -0
  124. package/dist/plugins/captcha/index.d.mts +2 -0
  125. package/dist/plugins/captcha/index.mjs +4 -0
  126. package/dist/plugins/custom-session/index.d.mts +7 -0
  127. package/dist/plugins/custom-session/index.mjs +19 -0
  128. package/dist/plugins/device-authorization/index.d.mts +4 -0
  129. package/dist/plugins/device-authorization/index.mjs +18 -0
  130. package/dist/plugins/email-otp/index.d.mts +3 -0
  131. package/dist/plugins/email-otp/index.mjs +19 -0
  132. package/dist/plugins/generic-oauth/index.d.mts +7 -0
  133. package/dist/plugins/generic-oauth/index.mjs +18 -0
  134. package/dist/plugins/haveibeenpwned/index.d.mts +2 -0
  135. package/dist/plugins/haveibeenpwned/index.mjs +18 -0
  136. package/dist/plugins/index.d.mts +139 -0
  137. package/dist/plugins/index.mjs +47 -0
  138. package/dist/plugins/jwt/index.d.mts +7 -0
  139. package/dist/plugins/jwt/index.mjs +18 -0
  140. package/dist/plugins/magic-link/index.d.mts +2 -0
  141. package/dist/plugins/magic-link/index.mjs +18 -0
  142. package/dist/plugins/multi-session/index.d.mts +3 -0
  143. package/dist/plugins/multi-session/index.mjs +18 -0
  144. package/dist/plugins/oauth-proxy/index.d.mts +2 -0
  145. package/dist/plugins/oauth-proxy/index.mjs +18 -0
  146. package/dist/plugins/one-tap/index.d.mts +2 -0
  147. package/dist/plugins/one-tap/index.mjs +18 -0
  148. package/dist/plugins/one-time-token/index.d.mts +7 -0
  149. package/dist/plugins/one-time-token/index.mjs +47 -0
  150. package/dist/plugins/organization/access/index.d.mts +4 -0
  151. package/dist/plugins/organization/access/index.mjs +4 -0
  152. package/dist/plugins/organization/index.d.mts +9 -0
  153. package/dist/plugins/organization/index.mjs +22 -0
  154. package/dist/plugins/passkey/index.d.mts +7 -0
  155. package/dist/plugins/passkey/index.mjs +18 -0
  156. package/dist/plugins/phone-number/index.d.mts +7 -0
  157. package/dist/plugins/phone-number/index.mjs +18 -0
  158. package/dist/plugins/two-factor/index.d.mts +7 -0
  159. package/dist/plugins/two-factor/index.mjs +20 -0
  160. package/dist/plugins/username/index.d.mts +4 -0
  161. package/dist/plugins/username/index.mjs +18 -0
  162. package/dist/plugins-3jfNste3.mjs +1544 -0
  163. package/dist/plugins-hFZT3hmK.d.mts +14 -0
  164. package/dist/promise-8rrEHRXd.mjs +23154 -0
  165. package/dist/proxy-CL9PZXJA.mjs +441 -0
  166. package/dist/session-Dgp133Yt.mjs +413 -0
  167. package/dist/social-providers/index.d.mts +1 -0
  168. package/dist/social-providers/index.mjs +3 -0
  169. package/dist/src/adapters/adapter-factory/index.d.ts +10 -0
  170. package/dist/src/adapters/adapter-factory/types.d.ts +124 -0
  171. package/dist/src/adapters/create-test-suite.d.ts +97 -0
  172. package/dist/src/adapters/drizzle-adapter/drizzle-adapter.d.ts +43 -0
  173. package/dist/src/adapters/drizzle-adapter/index.d.ts +1 -0
  174. package/dist/src/adapters/drizzle-adapter/test/generate-schema.d.ts +12 -0
  175. package/dist/src/adapters/index.d.ts +21 -0
  176. package/dist/src/adapters/kysely-adapter/bun-sqlite-dialect.d.ts +58 -0
  177. package/dist/src/adapters/kysely-adapter/dialect.d.ts +13 -0
  178. package/dist/src/adapters/kysely-adapter/index.d.ts +3 -0
  179. package/dist/src/adapters/kysely-adapter/kysely-adapter.d.ts +32 -0
  180. package/dist/src/adapters/kysely-adapter/node-sqlite-dialect.d.ts +58 -0
  181. package/dist/src/adapters/kysely-adapter/types.d.ts +1 -0
  182. package/dist/src/adapters/memory-adapter/index.d.ts +1 -0
  183. package/dist/src/adapters/memory-adapter/memory-adapter.d.ts +9 -0
  184. package/dist/src/adapters/mongodb-adapter/index.d.ts +1 -0
  185. package/dist/src/adapters/mongodb-adapter/mongodb-adapter.d.ts +31 -0
  186. package/dist/src/adapters/prisma-adapter/index.d.ts +1 -0
  187. package/dist/src/adapters/prisma-adapter/prisma-adapter.d.ts +32 -0
  188. package/dist/src/adapters/prisma-adapter/test/auth.d.ts +3 -0
  189. package/dist/src/adapters/prisma-adapter/test/generate-auth-config.d.ts +2 -0
  190. package/dist/src/adapters/prisma-adapter/test/generate-prisma-schema.d.ts +3 -0
  191. package/dist/src/adapters/prisma-adapter/test/get-prisma-client.d.ts +7 -0
  192. package/dist/src/adapters/prisma-adapter/test/push-prisma-schema.d.ts +1 -0
  193. package/dist/src/adapters/test-adapter.d.ts +61 -0
  194. package/dist/src/adapters/test.d.ts +78 -0
  195. package/dist/src/adapters/tests/auth-flow.d.ts +22 -0
  196. package/dist/src/adapters/tests/index.d.ts +5 -0
  197. package/dist/src/adapters/tests/normal.d.ts +87 -0
  198. package/dist/src/adapters/tests/number-id.d.ts +17 -0
  199. package/dist/src/adapters/tests/performance.d.ts +24 -0
  200. package/dist/src/adapters/tests/transactions.d.ts +20 -0
  201. package/dist/src/adapters/utils.d.ts +3 -0
  202. package/dist/src/api/index.d.ts +7150 -0
  203. package/dist/src/api/middlewares/index.d.ts +2 -0
  204. package/dist/src/api/middlewares/oauth.d.ts +15 -0
  205. package/dist/src/api/middlewares/origin-check.d.ts +8 -0
  206. package/dist/src/api/rate-limiter/index.d.ts +13 -0
  207. package/dist/src/api/routes/account.d.ts +623 -0
  208. package/dist/src/api/routes/callback.d.ts +68 -0
  209. package/dist/src/api/routes/email-verification.d.ts +266 -0
  210. package/dist/src/api/routes/error.d.ts +51 -0
  211. package/dist/src/api/routes/index.d.ts +11 -0
  212. package/dist/src/api/routes/ok.d.ts +61 -0
  213. package/dist/src/api/routes/reset-password.d.ts +203 -0
  214. package/dist/src/api/routes/session.d.ts +586 -0
  215. package/dist/src/api/routes/sign-in.d.ts +298 -0
  216. package/dist/src/api/routes/sign-out.d.ts +59 -0
  217. package/dist/src/api/routes/sign-up.d.ts +625 -0
  218. package/dist/src/api/routes/update-user.d.ts +862 -0
  219. package/dist/src/api/to-auth-endpoints.d.ts +3 -0
  220. package/dist/src/auth.d.ts +25 -0
  221. package/dist/src/client/broadcast-channel.d.ts +12 -0
  222. package/dist/src/client/config.d.ts +85 -0
  223. package/dist/src/client/fetch-plugins.d.ts +14 -0
  224. package/dist/src/client/index.d.ts +15 -0
  225. package/dist/src/client/parser.d.ts +12 -0
  226. package/dist/src/client/path-to-object.d.ts +63 -0
  227. package/dist/src/client/plugins/index.d.ts +21 -0
  228. package/dist/src/client/plugins/infer-plugin.d.ts +11 -0
  229. package/dist/src/client/proxy.d.ts +8 -0
  230. package/dist/src/client/query.d.ts +16 -0
  231. package/dist/src/client/react/index.d.ts +130 -0
  232. package/dist/src/client/react/react-store.d.ts +43 -0
  233. package/dist/src/client/session-atom.d.ts +18 -0
  234. package/dist/src/client/session-refresh.d.ts +17 -0
  235. package/dist/src/client/test-plugin.d.ts +147 -0
  236. package/dist/src/client/types.d.ts +49 -0
  237. package/dist/src/client/vanilla.d.ts +124 -0
  238. package/dist/src/cookies/check-cookies.d.ts +4 -0
  239. package/dist/src/cookies/cookie-utils.d.ts +16 -0
  240. package/dist/src/cookies/index.d.ts +56 -0
  241. package/dist/src/cookies/session-store.d.ts +43 -0
  242. package/dist/src/crypto/buffer.d.ts +4 -0
  243. package/dist/src/crypto/index.d.ts +14 -0
  244. package/dist/src/crypto/jwt.d.ts +4 -0
  245. package/dist/src/crypto/password.d.ts +5 -0
  246. package/dist/src/crypto/random.d.ts +1 -0
  247. package/dist/src/db/field.d.ts +97 -0
  248. package/dist/src/db/get-migration.d.ts +18 -0
  249. package/dist/src/db/get-schema.d.ts +6 -0
  250. package/dist/src/db/get-tables.d.ts +3 -0
  251. package/dist/src/db/index.d.ts +10 -0
  252. package/dist/src/db/internal-adapter.d.ts +9 -0
  253. package/dist/src/db/schema.d.ts +76 -0
  254. package/dist/src/db/to-zod.d.ts +31 -0
  255. package/dist/src/db/utils.d.ts +6 -0
  256. package/dist/src/db/with-hooks.d.ts +27 -0
  257. package/dist/src/index.d.ts +14 -0
  258. package/dist/src/init.d.ts +2 -0
  259. package/dist/src/integrations/next-js.d.ts +15 -0
  260. package/dist/src/integrations/node.d.ts +6 -0
  261. package/dist/src/integrations/react-start.d.ts +9 -0
  262. package/dist/src/oauth2/index.d.ts +4 -0
  263. package/dist/src/oauth2/link-account.d.ts +41 -0
  264. package/dist/src/oauth2/state.d.ts +21 -0
  265. package/dist/src/oauth2/utils.d.ts +3 -0
  266. package/dist/src/plugins/access/access.d.ts +25 -0
  267. package/dist/src/plugins/access/index.d.ts +2 -0
  268. package/dist/src/plugins/access/types.d.ts +14 -0
  269. package/dist/src/plugins/additional-fields/client.d.ts +91 -0
  270. package/dist/src/plugins/admin/access/index.d.ts +1 -0
  271. package/dist/src/plugins/admin/access/statement.d.ts +110 -0
  272. package/dist/src/plugins/admin/admin.d.ts +1570 -0
  273. package/dist/src/plugins/admin/client.d.ts +62 -0
  274. package/dist/src/plugins/admin/error-codes.d.ts +21 -0
  275. package/dist/src/plugins/admin/has-permission.d.ts +21 -0
  276. package/dist/src/plugins/admin/index.d.ts +2 -0
  277. package/dist/src/plugins/admin/schema.d.ts +36 -0
  278. package/dist/src/plugins/admin/types.d.ts +77 -0
  279. package/dist/src/plugins/anonymous/client.d.ts +8 -0
  280. package/dist/src/plugins/anonymous/index.d.ts +159 -0
  281. package/dist/src/plugins/api-key/client.d.ts +11 -0
  282. package/dist/src/plugins/api-key/index.d.ts +1431 -0
  283. package/dist/src/plugins/api-key/rate-limit.d.ts +20 -0
  284. package/dist/src/plugins/api-key/routes/create-api-key.d.ts +244 -0
  285. package/dist/src/plugins/api-key/routes/delete-all-expired-api-keys.d.ts +45 -0
  286. package/dist/src/plugins/api-key/routes/delete-api-key.d.ts +112 -0
  287. package/dist/src/plugins/api-key/routes/get-api-key.d.ts +234 -0
  288. package/dist/src/plugins/api-key/routes/index.d.ts +1136 -0
  289. package/dist/src/plugins/api-key/routes/list-api-keys.d.ts +231 -0
  290. package/dist/src/plugins/api-key/routes/update-api-key.d.ts +235 -0
  291. package/dist/src/plugins/api-key/routes/verify-api-key.d.ts +80 -0
  292. package/dist/src/plugins/api-key/schema.d.ts +188 -0
  293. package/dist/src/plugins/api-key/types.d.ts +285 -0
  294. package/dist/src/plugins/bearer/index.d.ts +31 -0
  295. package/dist/src/plugins/captcha/constants.d.ts +9 -0
  296. package/dist/src/plugins/captcha/error-codes.d.ts +9 -0
  297. package/dist/src/plugins/captcha/index.d.ts +7 -0
  298. package/dist/src/plugins/captcha/types.d.ts +23 -0
  299. package/dist/src/plugins/captcha/utils.d.ts +1 -0
  300. package/dist/src/plugins/captcha/verify-handlers/captchafox.d.ts +11 -0
  301. package/dist/src/plugins/captcha/verify-handlers/cloudflare-turnstile.d.ts +10 -0
  302. package/dist/src/plugins/captcha/verify-handlers/google-recaptcha.d.ts +11 -0
  303. package/dist/src/plugins/captcha/verify-handlers/h-captcha.d.ts +11 -0
  304. package/dist/src/plugins/captcha/verify-handlers/index.d.ts +4 -0
  305. package/dist/src/plugins/custom-session/client.d.ts +12 -0
  306. package/dist/src/plugins/custom-session/index.d.ts +89 -0
  307. package/dist/src/plugins/device-authorization/client.d.ts +12 -0
  308. package/dist/src/plugins/device-authorization/index.d.ts +568 -0
  309. package/dist/src/plugins/device-authorization/schema.d.ts +56 -0
  310. package/dist/src/plugins/email-otp/client.d.ts +9 -0
  311. package/dist/src/plugins/email-otp/index.d.ts +826 -0
  312. package/dist/src/plugins/email-otp/utils.d.ts +2 -0
  313. package/dist/src/plugins/generic-oauth/client.d.ts +5 -0
  314. package/dist/src/plugins/generic-oauth/index.d.ts +428 -0
  315. package/dist/src/plugins/haveibeenpwned/index.d.ts +25 -0
  316. package/dist/src/plugins/index.d.ts +28 -0
  317. package/dist/src/plugins/jwt/adapter.d.ts +8 -0
  318. package/dist/src/plugins/jwt/client.d.ts +5 -0
  319. package/dist/src/plugins/jwt/index.d.ts +276 -0
  320. package/dist/src/plugins/jwt/schema.d.ts +18 -0
  321. package/dist/src/plugins/jwt/sign.d.ts +8 -0
  322. package/dist/src/plugins/jwt/types.d.ts +175 -0
  323. package/dist/src/plugins/jwt/utils.d.ts +46 -0
  324. package/dist/src/plugins/last-login-method/client.d.ts +34 -0
  325. package/dist/src/plugins/last-login-method/index.d.ts +103 -0
  326. package/dist/src/plugins/magic-link/client.d.ts +5 -0
  327. package/dist/src/plugins/magic-link/index.d.ts +253 -0
  328. package/dist/src/plugins/magic-link/utils.d.ts +1 -0
  329. package/dist/src/plugins/multi-session/client.d.ts +9 -0
  330. package/dist/src/plugins/multi-session/index.d.ts +284 -0
  331. package/dist/src/plugins/oauth-proxy/index.d.ts +119 -0
  332. package/dist/src/plugins/one-tap/client.d.ts +81 -0
  333. package/dist/src/plugins/one-tap/index.d.ts +114 -0
  334. package/dist/src/plugins/one-time-token/client.d.ts +5 -0
  335. package/dist/src/plugins/one-time-token/index.d.ts +170 -0
  336. package/dist/src/plugins/one-time-token/utils.d.ts +1 -0
  337. package/dist/src/plugins/organization/access/index.d.ts +1 -0
  338. package/dist/src/plugins/organization/access/statement.d.ts +241 -0
  339. package/dist/src/plugins/organization/adapter.d.ts +685 -0
  340. package/dist/src/plugins/organization/call.d.ts +55 -0
  341. package/dist/src/plugins/organization/client.d.ts +344 -0
  342. package/dist/src/plugins/organization/error-codes.d.ts +58 -0
  343. package/dist/src/plugins/organization/has-permission.d.ts +13 -0
  344. package/dist/src/plugins/organization/index.d.ts +4 -0
  345. package/dist/src/plugins/organization/organization.d.ts +412 -0
  346. package/dist/src/plugins/organization/permission.d.ts +27 -0
  347. package/dist/src/plugins/organization/routes/crud-access-control.d.ts +701 -0
  348. package/dist/src/plugins/organization/routes/crud-invites.d.ts +1522 -0
  349. package/dist/src/plugins/organization/routes/crud-members.d.ts +1220 -0
  350. package/dist/src/plugins/organization/routes/crud-org.d.ts +1399 -0
  351. package/dist/src/plugins/organization/routes/crud-team.d.ts +1323 -0
  352. package/dist/src/plugins/organization/schema.d.ts +366 -0
  353. package/dist/src/plugins/organization/types.d.ts +737 -0
  354. package/dist/src/plugins/passkey/client.d.ts +190 -0
  355. package/dist/src/plugins/passkey/error-codes.d.ts +9 -0
  356. package/dist/src/plugins/passkey/index.d.ts +838 -0
  357. package/dist/src/plugins/passkey/schema.d.ts +50 -0
  358. package/dist/src/plugins/passkey/types.d.ts +69 -0
  359. package/dist/src/plugins/passkey/utils.d.ts +2 -0
  360. package/dist/src/plugins/phone-number/client.d.ts +9 -0
  361. package/dist/src/plugins/phone-number/index.d.ts +622 -0
  362. package/dist/src/plugins/phone-number/phone-number-error.d.ts +10 -0
  363. package/dist/src/plugins/two-factor/backup-codes/index.d.ts +387 -0
  364. package/dist/src/plugins/two-factor/client.d.ts +28 -0
  365. package/dist/src/plugins/two-factor/constant.d.ts +2 -0
  366. package/dist/src/plugins/two-factor/error-code.d.ts +11 -0
  367. package/dist/src/plugins/two-factor/index.d.ts +1014 -0
  368. package/dist/src/plugins/two-factor/otp/index.d.ts +282 -0
  369. package/dist/src/plugins/two-factor/schema.d.ts +35 -0
  370. package/dist/src/plugins/two-factor/totp/index.d.ts +298 -0
  371. package/dist/src/plugins/two-factor/types.d.ts +50 -0
  372. package/dist/src/plugins/two-factor/utils.d.ts +1 -0
  373. package/dist/src/plugins/two-factor/verify-two-factor.d.ts +59 -0
  374. package/dist/src/plugins/username/client.d.ts +5 -0
  375. package/dist/src/plugins/username/error-codes.d.ts +10 -0
  376. package/dist/src/plugins/username/index.d.ts +313 -0
  377. package/dist/src/plugins/username/schema.d.ts +27 -0
  378. package/dist/src/social-providers/index.d.ts +1 -0
  379. package/dist/src/test-utils/headers.d.ts +5 -0
  380. package/dist/src/test-utils/index.d.ts +2 -0
  381. package/dist/src/test-utils/test-instance.d.ts +17849 -0
  382. package/dist/src/types/adapter.d.ts +21 -0
  383. package/dist/src/types/api.d.ts +29 -0
  384. package/dist/src/types/helper.d.ts +32 -0
  385. package/dist/src/types/index.d.ts +7 -0
  386. package/dist/src/types/models.d.ts +13 -0
  387. package/dist/src/types/plugins.d.ts +14 -0
  388. package/dist/src/utils/await-object.d.ts +3 -0
  389. package/dist/src/utils/boolean.d.ts +1 -0
  390. package/dist/src/utils/clone.d.ts +1 -0
  391. package/dist/src/utils/constants.d.ts +1 -0
  392. package/dist/src/utils/date.d.ts +1 -0
  393. package/dist/src/utils/ensure-utc.d.ts +1 -0
  394. package/dist/src/utils/get-request-ip.d.ts +2 -0
  395. package/dist/src/utils/hashing.d.ts +6 -0
  396. package/dist/src/utils/hide-metadata.d.ts +3 -0
  397. package/dist/src/utils/id.d.ts +1 -0
  398. package/dist/src/utils/import-util.d.ts +1 -0
  399. package/dist/src/utils/index.d.ts +5 -0
  400. package/dist/src/utils/is-atom.d.ts +2 -0
  401. package/dist/src/utils/is-promise.d.ts +1 -0
  402. package/dist/src/utils/json.d.ts +1 -0
  403. package/dist/src/utils/merger.d.ts +1 -0
  404. package/dist/src/utils/middleware-response.d.ts +8 -0
  405. package/dist/src/utils/misc.d.ts +1 -0
  406. package/dist/src/utils/password.d.ts +6 -0
  407. package/dist/src/utils/plugin-helper.d.ts +5 -0
  408. package/dist/src/utils/shim.d.ts +3 -0
  409. package/dist/src/utils/time.d.ts +4 -0
  410. package/dist/src/utils/url.d.ts +4 -0
  411. package/dist/src/utils/wildcard.d.ts +45 -0
  412. package/dist/test-utils/index.d.mts +17870 -0
  413. package/dist/test-utils/index.mjs +272 -0
  414. package/dist/two-factor-ClUXxom2.mjs +914 -0
  415. package/dist/types/index.d.mts +6 -0
  416. package/dist/types/index.mjs +3 -0
  417. package/dist/types-B1OL7hyf.d.mts +4 -0
  418. package/dist/types-Bjn15Uy6.mjs +1 -0
  419. package/dist/url-VB2gAbTI.mjs +59 -0
  420. package/dist/username-DiGklOGl.mjs +278 -0
  421. package/dist/utils-SOMB4Px5.mjs +132 -0
  422. package/package.json +447 -0
@@ -0,0 +1,2543 @@
1
+ import * as better_call0 from "better-call";
2
+ import { CookieOptions, Endpoint, EndpointContext, InputContext, Middleware } from "better-call";
3
+ import * as z$1 from "zod";
4
+ import "jose";
5
+ import { Dialect, Kysely, Migration, MysqlPool, PostgresPool, SqliteDatabase } from "kysely";
6
+ import { BetterFetch, BetterFetchOption } from "@better-fetch/fetch";
7
+ import { Atom, WritableAtom } from "nanostores";
8
+ import { StandardSchemaV1 as StandardSchemaV1$1 } from "@standard-schema/spec";
9
+ import { Database } from "bun:sqlite";
10
+ import { DatabaseSync } from "node:sqlite";
11
+
12
+ //#region ../core/dist/index-CmdhhvA2.d.mts
13
+
14
+ type LogLevel = "info" | "success" | "warn" | "error" | "debug";
15
+ interface Logger {
16
+ disabled?: boolean | undefined;
17
+ disableColors?: boolean | undefined;
18
+ level?: Exclude<LogLevel, "success"> | undefined;
19
+ log?: ((level: Exclude<LogLevel, "success">, message: string, ...args: any[]) => void) | undefined;
20
+ }
21
+ type LogHandlerParams = Parameters<NonNullable<Logger["log"]>> extends [LogLevel, ...infer Rest] ? Rest : never;
22
+ type InternalLogger = { [K in LogLevel]: (...params: LogHandlerParams) => void } & {
23
+ get level(): LogLevel;
24
+ };
25
+ declare const createLogger: (options?: Logger | undefined) => InternalLogger;
26
+ //#endregion
27
+ //#region ../core/dist/index-65G5U5DB.d.mts
28
+ //#region src/db/type.d.ts
29
+ type DBPreservedModels = "user" | "account" | "session" | "verification" | "rate-limit" | "organization" | "member" | "invitation" | "jwks" | "passkey" | "two-factor";
30
+ type DBFieldType = "string" | "number" | "boolean" | "date" | "json" | `${"string" | "number"}[]` | Array<LiteralString>;
31
+ type DBPrimitive = string | number | boolean | Date | null | undefined | string[] | number[];
32
+ type DBFieldAttributeConfig = {
33
+ /**
34
+ * If the field should be required on a new record.
35
+ * @default true
36
+ */
37
+ required?: boolean | undefined;
38
+ /**
39
+ * If the value should be returned on a response body.
40
+ * @default true
41
+ */
42
+ returned?: boolean | undefined;
43
+ /**
44
+ * If a value should be provided when creating a new record.
45
+ * @default true
46
+ */
47
+ input?: boolean | undefined;
48
+ /**
49
+ * Default value for the field
50
+ *
51
+ * Note: This will not create a default value on the database level. It will only
52
+ * be used when creating a new record.
53
+ */
54
+ defaultValue?: (DBPrimitive | (() => DBPrimitive)) | undefined;
55
+ /**
56
+ * Update value for the field
57
+ *
58
+ * Note: This will create an onUpdate trigger on the database level for supported adapters.
59
+ * It will be called when updating a record.
60
+ */
61
+ onUpdate?: (() => DBPrimitive) | undefined;
62
+ /**
63
+ * transform the value before storing it.
64
+ */
65
+ transform?: {
66
+ input?: (value: DBPrimitive) => DBPrimitive | Promise<DBPrimitive>;
67
+ output?: (value: DBPrimitive) => DBPrimitive | Promise<DBPrimitive>;
68
+ } | undefined;
69
+ /**
70
+ * Reference to another model.
71
+ */
72
+ references?: {
73
+ /**
74
+ * The model to reference.
75
+ */
76
+ model: string;
77
+ /**
78
+ * The field on the referenced model.
79
+ */
80
+ field: string;
81
+ /**
82
+ * The action to perform when the reference is deleted.
83
+ * @default "cascade"
84
+ */
85
+ onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
86
+ } | undefined;
87
+ unique?: boolean | undefined;
88
+ /**
89
+ * If the field should be a bigint on the database instead of integer.
90
+ */
91
+ bigint?: boolean | undefined;
92
+ /**
93
+ * A zod schema to validate the value.
94
+ */
95
+ validator?: {
96
+ input?: StandardSchemaV1$1;
97
+ output?: StandardSchemaV1$1;
98
+ } | undefined;
99
+ /**
100
+ * The name of the field on the database.
101
+ */
102
+ fieldName?: string | undefined;
103
+ /**
104
+ * If the field should be sortable.
105
+ *
106
+ * applicable only for `text` type.
107
+ * It's useful to mark fields varchar instead of text.
108
+ */
109
+ sortable?: boolean | undefined;
110
+ };
111
+ type DBFieldAttribute<T extends DBFieldType = DBFieldType> = {
112
+ type: T;
113
+ } & DBFieldAttributeConfig;
114
+ type PayvoAuthDBSchema = Record<string, {
115
+ /**
116
+ * The name of the table in the database
117
+ */
118
+ modelName: string;
119
+ /**
120
+ * The fields of the table
121
+ */
122
+ fields: Record<string, DBFieldAttribute>;
123
+ /**
124
+ * Whether to disable migrations for this table
125
+ * @default false
126
+ */
127
+ disableMigrations?: boolean | undefined;
128
+ /**
129
+ * The order of the table
130
+ */
131
+ order?: number | undefined;
132
+ }>;
133
+ interface SecondaryStorage {
134
+ /**
135
+ *
136
+ * @param key - Key to get
137
+ * @returns - Value of the key
138
+ */
139
+ get: (key: string) => Awaitable$1<unknown>;
140
+ /**
141
+ * Atomically get a value and delete it from storage.
142
+ *
143
+ * This is optional for backwards compatibility with existing secondary
144
+ * storage implementations. Single-use credential consumers use it when
145
+ * present to avoid a read-then-delete race.
146
+ *
147
+ * TODO(secondary-storage-atomic-consume): make this required in the next
148
+ * breaking release, or require database-backed verification storage for
149
+ * security-sensitive consume paths.
150
+ */
151
+ getAndDelete?: (key: string) => Awaitable$1<unknown>;
152
+ /**
153
+ * Atomically increment the counter at `key` by one, returning the
154
+ * post-increment value.
155
+ *
156
+ * When the key is absent, it is created with a value of `1` and the given
157
+ * `ttl` (in SECONDS). The TTL is applied only on creation; later increments
158
+ * never extend it, so the counter expires a fixed window after it was first
159
+ * created.
160
+ *
161
+ * This is optional for backwards compatibility with existing secondary
162
+ * storage implementations. TODO(secondary-storage-increment-required): make
163
+ * this required for secondary-storage-backed rate limiting in the next minor
164
+ * on `next`.
165
+ */
166
+ increment?: (key: string, ttl: number) => Awaitable$1<number>;
167
+ set: (
168
+ /**
169
+ * Key to store
170
+ */
171
+ key: string,
172
+ /**
173
+ * Value to store
174
+ */
175
+ value: string,
176
+ /**
177
+ * Time to live in seconds
178
+ */
179
+ ttl?: number | undefined) => Awaitable$1<void | null | unknown>;
180
+ /**
181
+ *
182
+ * @param key - Key to delete
183
+ */
184
+ delete: (key: string) => Awaitable$1<void | null | string>;
185
+ }
186
+ //#endregion
187
+ //#region src/db/plugin.d.ts
188
+ type PayvoAuthPluginDBSchema = { [table in string]: {
189
+ fields: {
190
+ [field: string]: DBFieldAttribute;
191
+ };
192
+ disableMigration?: boolean | undefined;
193
+ modelName?: string | undefined;
194
+ } };
195
+ //#endregion
196
+ //#region src/db/schema/account.d.ts
197
+ declare const accountSchema: z$1.ZodObject<{
198
+ id: z$1.ZodString;
199
+ createdAt: z$1.ZodDefault<z$1.ZodDate>;
200
+ updatedAt: z$1.ZodDefault<z$1.ZodDate>;
201
+ providerId: z$1.ZodString;
202
+ accountId: z$1.ZodString;
203
+ userId: z$1.ZodCoercedString<unknown>;
204
+ accessToken: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
205
+ refreshToken: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
206
+ idToken: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
207
+ accessTokenExpiresAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
208
+ refreshTokenExpiresAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
209
+ scope: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
210
+ password: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
211
+ }, z$1.core.$strip>;
212
+ /**
213
+ * Account schema type used by payvo-auth, note that it's possible that account could have additional fields
214
+ *
215
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
216
+ */
217
+ type Account = z$1.infer<typeof accountSchema>;
218
+ //#endregion
219
+ //#region src/db/schema/rate-limit.d.ts
220
+ declare const rateLimitSchema: z$1.ZodObject<{
221
+ key: z$1.ZodString;
222
+ count: z$1.ZodNumber;
223
+ lastRequest: z$1.ZodNumber;
224
+ }, z$1.core.$strip>;
225
+ /**
226
+ * Rate limit schema type used by payvo-auth for rate limiting
227
+ */
228
+ type RateLimit = z$1.infer<typeof rateLimitSchema>;
229
+ //#endregion
230
+ //#region src/db/schema/session.d.ts
231
+ declare const sessionSchema: z$1.ZodObject<{
232
+ id: z$1.ZodString;
233
+ createdAt: z$1.ZodDefault<z$1.ZodDate>;
234
+ updatedAt: z$1.ZodDefault<z$1.ZodDate>;
235
+ userId: z$1.ZodCoercedString<unknown>;
236
+ expiresAt: z$1.ZodDate;
237
+ token: z$1.ZodString;
238
+ ipAddress: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
239
+ userAgent: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
240
+ }, z$1.core.$strip>;
241
+ /**
242
+ * Session schema type used by payvo-auth, note that it's possible that session could have additional fields
243
+ *
244
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
245
+ */
246
+ type Session = z$1.infer<typeof sessionSchema>;
247
+ //#endregion
248
+ //#region src/db/schema/shared.d.ts
249
+
250
+ //#endregion
251
+ //#region src/db/schema/user.d.ts
252
+ declare const userSchema: z$1.ZodObject<{
253
+ id: z$1.ZodString;
254
+ createdAt: z$1.ZodDefault<z$1.ZodDate>;
255
+ updatedAt: z$1.ZodDefault<z$1.ZodDate>;
256
+ email: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<string, string>>;
257
+ emailVerified: z$1.ZodDefault<z$1.ZodBoolean>;
258
+ name: z$1.ZodString;
259
+ image: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
260
+ }, z$1.core.$strip>;
261
+ /**
262
+ * User schema type used by payvo-auth, note that it's possible that user could have additional fields
263
+ *
264
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
265
+ */
266
+ type User = z$1.infer<typeof userSchema>;
267
+ //#endregion
268
+ //#region src/db/schema/verification.d.ts
269
+ declare const verificationSchema: z$1.ZodObject<{
270
+ id: z$1.ZodString;
271
+ createdAt: z$1.ZodDefault<z$1.ZodDate>;
272
+ updatedAt: z$1.ZodDefault<z$1.ZodDate>;
273
+ value: z$1.ZodString;
274
+ expiresAt: z$1.ZodDate;
275
+ identifier: z$1.ZodString;
276
+ }, z$1.core.$strip>;
277
+ /**
278
+ * Verification schema type used by payvo-auth, note that it's possible that verification could have additional fields
279
+ *
280
+ * todo: we should use generics to extend this type with additional fields from plugins and options in the future
281
+ */
282
+ type Verification = z$1.infer<typeof verificationSchema>;
283
+ //#endregion
284
+ //#region src/db/index.d.ts
285
+ /**
286
+ * @deprecated Backport for 1.3.x, we will remove this in 1.4.x
287
+ */
288
+
289
+ //#endregion
290
+ //#region src/db/adapter/index.d.ts
291
+ type DBAdapterDebugLogOption = boolean | {
292
+ /**
293
+ * Useful when you want to log only certain conditions.
294
+ */
295
+ logCondition?: (() => boolean) | undefined;
296
+ create?: boolean | undefined;
297
+ update?: boolean | undefined;
298
+ updateMany?: boolean | undefined;
299
+ findOne?: boolean | undefined;
300
+ findMany?: boolean | undefined;
301
+ delete?: boolean | undefined;
302
+ deleteMany?: boolean | undefined;
303
+ count?: boolean | undefined;
304
+ } | {
305
+ /**
306
+ * Only used for adapter tests to show debug logs if a test fails.
307
+ *
308
+ * @deprecated Not actually deprecated. Doing this for IDEs to show this option at the very bottom and stop end-users from using this.
309
+ */
310
+ isRunningAdapterTests: boolean;
311
+ };
312
+ type DBAdapterSchemaCreation = {
313
+ /**
314
+ * Code to be inserted into the file
315
+ */
316
+ code: string;
317
+ /**
318
+ * Path to the file, including the file name and extension.
319
+ * Relative paths are supported, with the current working directory of the developer's project as the base.
320
+ */
321
+ path: string;
322
+ /**
323
+ * Append the file if it already exists.
324
+ * Note: This will not apply if `overwrite` is set to true.
325
+ */
326
+ append?: boolean | undefined;
327
+ /**
328
+ * Overwrite the file if it already exists
329
+ */
330
+ overwrite?: boolean | undefined;
331
+ };
332
+ interface DBAdapterFactoryConfig<Options extends PayvoAuthOptions = PayvoAuthOptions> {
333
+ /**
334
+ * Use plural table names.
335
+ *
336
+ * All tables will be named with an `s` at the end.
337
+ *
338
+ * @default false
339
+ */
340
+ usePlural?: boolean | undefined;
341
+ /**
342
+ * Enable debug logs.
343
+ *
344
+ * @default false
345
+ */
346
+ debugLogs?: DBAdapterDebugLogOption | undefined;
347
+ /**
348
+ * Name of the adapter.
349
+ *
350
+ * This is used to identify the adapter in the debug logs.
351
+ *
352
+ * @default `adapterId`
353
+ */
354
+ adapterName?: string | undefined;
355
+ /**
356
+ * Adapter id
357
+ */
358
+ adapterId: string;
359
+ /**
360
+ * If the database supports numeric ids, set this to `true`.
361
+ *
362
+ * @default true
363
+ */
364
+ supportsNumericIds?: boolean | undefined;
365
+ /**
366
+ * If the database doesn't support JSON columns, set this to `false`.
367
+ *
368
+ * We will handle the translation between using `JSON` columns, and saving `string`s to the database.
369
+ *
370
+ * @default false
371
+ */
372
+ supportsJSON?: boolean | undefined;
373
+ /**
374
+ * If the database doesn't support dates, set this to `false`.
375
+ *
376
+ * We will handle the translation between using `Date` objects, and saving `string`s to the database.
377
+ *
378
+ * @default true
379
+ */
380
+ supportsDates?: boolean | undefined;
381
+ /**
382
+ * If the database doesn't support booleans, set this to `false`.
383
+ *
384
+ * We will handle the translation between using `boolean`s, and saving `0`s and `1`s to the database.
385
+ *
386
+ * @default true
387
+ */
388
+ supportsBooleans?: boolean | undefined;
389
+ /**
390
+ * Execute multiple operations in a transaction.
391
+ *
392
+ * If the database doesn't support transactions, set this to `false` and operations will be executed sequentially.
393
+ *
394
+ * @default false
395
+ */
396
+ transaction?: (false | (<R>(callback: (trx: DBTransactionAdapter<Options>) => Promise<R>) => Promise<R>)) | undefined;
397
+ /**
398
+ * Disable id generation for the `create` method.
399
+ *
400
+ * This is useful for databases that don't support custom id values and would auto-generate them for you.
401
+ *
402
+ * @default false
403
+ */
404
+ disableIdGeneration?: boolean | undefined;
405
+ /**
406
+ * Map the keys of the input data.
407
+ *
408
+ * This is useful for databases that expect a different key name for a given situation.
409
+ *
410
+ * For example, MongoDB uses `_id` while in Payvo-Auth we use `id`.
411
+ *
412
+ *
413
+ * @example
414
+ * Each key represents the old key to replace.
415
+ * The value represents the new key
416
+ *
417
+ * This can be a partial object that only transforms some keys.
418
+ *
419
+ * ```ts
420
+ * mapKeysTransformInput: {
421
+ * id: "_id" // We want to replace `id` to `_id` to save into MongoDB
422
+ * }
423
+ * ```
424
+ */
425
+ mapKeysTransformInput?: Record<string, string> | undefined;
426
+ /**
427
+ * Map the keys of the output data.
428
+ *
429
+ * This is useful for databases that expect a different key name for a given situation.
430
+ *
431
+ * For example, MongoDB uses `_id` while in Payvo-Auth we use `id`.
432
+ *
433
+ * @example
434
+ * Each key represents the old key to replace.
435
+ * The value represents the new key
436
+ *
437
+ * This can be a partial object that only transforms some keys.
438
+ *
439
+ * ```ts
440
+ * mapKeysTransformOutput: {
441
+ * _id: "id" // In MongoDB, we save `id` as `_id`. So we want to replace `_id` with `id` when we get the data back.
442
+ * }
443
+ * ```
444
+ */
445
+ mapKeysTransformOutput?: Record<string, string> | undefined;
446
+ /**
447
+ * Custom transform input function.
448
+ *
449
+ * This function is used to transform the input data before it is saved to the database.
450
+ */
451
+ customTransformInput?: ((props: {
452
+ data: any;
453
+ /**
454
+ * The fields of the model.
455
+ */
456
+ fieldAttributes: DBFieldAttribute;
457
+ /**
458
+ * The field to transform.
459
+ */
460
+ field: string;
461
+ /**
462
+ * The action which was called from the adapter.
463
+ */
464
+ action: "create" | "update";
465
+ /**
466
+ * The model name.
467
+ */
468
+ model: string;
469
+ /**
470
+ * The schema of the user's Payvo-Auth instance.
471
+ */
472
+ schema: PayvoAuthDBSchema;
473
+ /**
474
+ * The options of the user's Payvo-Auth instance.
475
+ */
476
+ options: Options;
477
+ }) => any) | undefined;
478
+ /**
479
+ * Custom transform output function.
480
+ *
481
+ * This function is used to transform the output data before it is returned to the user.
482
+ */
483
+ customTransformOutput?: ((props: {
484
+ data: any;
485
+ /**
486
+ * The fields of the model.
487
+ */
488
+ fieldAttributes: DBFieldAttribute;
489
+ /**
490
+ * The field to transform.
491
+ */
492
+ field: string;
493
+ /**
494
+ * The fields to select.
495
+ */
496
+ select: string[];
497
+ /**
498
+ * The model name.
499
+ */
500
+ model: string;
501
+ /**
502
+ * The schema of the user's Payvo-Auth instance.
503
+ */
504
+ schema: PayvoAuthDBSchema;
505
+ /**
506
+ * The options of the user's Payvo-Auth instance.
507
+ */
508
+ options: Options;
509
+ }) => any) | undefined;
510
+ /**
511
+ * Custom ID generator function.
512
+ *
513
+ * By default, we can handle ID generation for you, however if the database your adapter is for only supports a specific custom id generation,
514
+ * then you can use this function to generate your own IDs.
515
+ *
516
+ *
517
+ * Notes:
518
+ * - If the user enabled `useNumberId`, then this option will be ignored. Unless this adapter config has `supportsNumericIds` set to `false`.
519
+ * - If `generateId` is `false` in the user's Payvo-Auth config, then this option will be ignored.
520
+ * - If `generateId` is a function, then it will override this option.
521
+ *
522
+ * @example
523
+ *
524
+ * ```ts
525
+ * customIdGenerator: ({ model }) => {
526
+ * return "my-super-unique-id";
527
+ * }
528
+ * ```
529
+ */
530
+ customIdGenerator?: ((props: {
531
+ model: string;
532
+ }) => string) | undefined;
533
+ /**
534
+ * Whether to disable the transform output.
535
+ * Do not use this option unless you know what you are doing.
536
+ * @default false
537
+ */
538
+ disableTransformOutput?: boolean | undefined;
539
+ /**
540
+ * Whether to disable the transform input.
541
+ * Do not use this option unless you know what you are doing.
542
+ * @default false
543
+ */
544
+ disableTransformInput?: boolean | undefined;
545
+ }
546
+ type Where = {
547
+ /**
548
+ * @default eq
549
+ */
550
+ operator?: ("eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with") | undefined;
551
+ value: string | number | boolean | string[] | number[] | Date | null;
552
+ field: string;
553
+ /**
554
+ * @default AND
555
+ */
556
+ connector?: ("AND" | "OR") | undefined;
557
+ };
558
+ type DBTransactionAdapter<Options extends PayvoAuthOptions = PayvoAuthOptions> = Omit<DBAdapter<Options>, "transaction">;
559
+ type DBAdapter<Options extends PayvoAuthOptions = PayvoAuthOptions> = {
560
+ id: string;
561
+ create: <T extends Record<string, any>, R = T>(data: {
562
+ model: string;
563
+ data: Omit<T, "id">;
564
+ select?: string[] | undefined;
565
+ /**
566
+ * By default, any `id` provided in `data` will be ignored.
567
+ *
568
+ * If you want to force the `id` to be the same as the `data.id`, set this to `true`.
569
+ */
570
+ forceAllowId?: boolean | undefined;
571
+ }) => Promise<R>;
572
+ findOne: <T>(data: {
573
+ model: string;
574
+ where: Where[];
575
+ select?: string[] | undefined;
576
+ }) => Promise<T | null>;
577
+ findMany: <T>(data: {
578
+ model: string;
579
+ where?: Where[] | undefined;
580
+ limit?: number | undefined;
581
+ sortBy?: {
582
+ field: string;
583
+ direction: "asc" | "desc";
584
+ } | undefined;
585
+ offset?: number | undefined;
586
+ }) => Promise<T[]>;
587
+ count: (data: {
588
+ model: string;
589
+ where?: Where[] | undefined;
590
+ }) => Promise<number>;
591
+ /**
592
+ * ⚠︎ Update may not return the updated data
593
+ * if multiple where clauses are provided
594
+ */
595
+ update: <T>(data: {
596
+ model: string;
597
+ where: Where[];
598
+ update: Record<string, any>;
599
+ }) => Promise<T | null>;
600
+ updateMany: (data: {
601
+ model: string;
602
+ where: Where[];
603
+ update: Record<string, any>;
604
+ }) => Promise<number>;
605
+ delete: <T>(data: {
606
+ model: string;
607
+ where: Where[];
608
+ }) => Promise<void>;
609
+ deleteMany: (data: {
610
+ model: string;
611
+ where: Where[];
612
+ }) => Promise<number>;
613
+ /**
614
+ * Execute multiple operations in a transaction.
615
+ * If the adapter doesn't support transactions, operations will be executed sequentially.
616
+ */
617
+ transaction: <R>(callback: (trx: DBTransactionAdapter<Options>) => Promise<R>) => Promise<R>;
618
+ /**
619
+ *
620
+ * @param options
621
+ * @param file - file path if provided by the user
622
+ */
623
+ createSchema?: ((options: Options, file?: string) => Promise<DBAdapterSchemaCreation>) | undefined;
624
+ options?: ({
625
+ adapterConfig: DBAdapterFactoryConfig<Options>;
626
+ } & CustomAdapter["options"]) | undefined;
627
+ };
628
+ type CleanedWhere = Required<Where>;
629
+ interface CustomAdapter {
630
+ create: <T extends Record<string, any>>({
631
+ data,
632
+ model,
633
+ select
634
+ }: {
635
+ model: string;
636
+ data: T;
637
+ select?: string[] | undefined;
638
+ }) => Promise<T>;
639
+ update: <T>(data: {
640
+ model: string;
641
+ where: CleanedWhere[];
642
+ update: T;
643
+ }) => Promise<T | null>;
644
+ updateMany: (data: {
645
+ model: string;
646
+ where: CleanedWhere[];
647
+ update: Record<string, any>;
648
+ }) => Promise<number>;
649
+ findOne: <T>({
650
+ model,
651
+ where,
652
+ select
653
+ }: {
654
+ model: string;
655
+ where: CleanedWhere[];
656
+ select?: string[] | undefined;
657
+ }) => Promise<T | null>;
658
+ findMany: <T>({
659
+ model,
660
+ where,
661
+ limit,
662
+ sortBy,
663
+ offset
664
+ }: {
665
+ model: string;
666
+ where?: CleanedWhere[] | undefined;
667
+ limit: number;
668
+ sortBy?: {
669
+ field: string;
670
+ direction: "asc" | "desc";
671
+ } | undefined;
672
+ offset?: number | undefined;
673
+ }) => Promise<T[]>;
674
+ delete: ({
675
+ model,
676
+ where
677
+ }: {
678
+ model: string;
679
+ where: CleanedWhere[];
680
+ }) => Promise<void>;
681
+ deleteMany: ({
682
+ model,
683
+ where
684
+ }: {
685
+ model: string;
686
+ where: CleanedWhere[];
687
+ }) => Promise<number>;
688
+ count: ({
689
+ model,
690
+ where
691
+ }: {
692
+ model: string;
693
+ where?: CleanedWhere[] | undefined;
694
+ }) => Promise<number>;
695
+ createSchema?: ((props: {
696
+ /**
697
+ * The file the user may have passed in to the `generate` command as the expected schema file output path.
698
+ */
699
+ file?: string;
700
+ /**
701
+ * The tables from the user's Payvo-Auth instance schema.
702
+ */
703
+ tables: PayvoAuthDBSchema;
704
+ }) => Promise<DBAdapterSchemaCreation>) | undefined;
705
+ /**
706
+ * Your adapter's options.
707
+ */
708
+ options?: Record<string, any> | undefined;
709
+ }
710
+ interface DBAdapterInstance<Options extends PayvoAuthOptions = PayvoAuthOptions> {
711
+ (options: PayvoAuthOptions): DBAdapter<Options>;
712
+ }
713
+ //#endregion
714
+ //#region src/oauth2/oauth-provider.d.ts
715
+ interface OAuth2Tokens {
716
+ tokenType?: string | undefined;
717
+ accessToken?: string | undefined;
718
+ refreshToken?: string | undefined;
719
+ accessTokenExpiresAt?: Date | undefined;
720
+ refreshTokenExpiresAt?: Date | undefined;
721
+ scopes?: string[] | undefined;
722
+ idToken?: string | undefined;
723
+ }
724
+ type OAuth2UserInfo = {
725
+ id: string | number;
726
+ name?: string | undefined;
727
+ email?: (string | null) | undefined;
728
+ image?: string | undefined;
729
+ emailVerified: boolean;
730
+ };
731
+ interface OAuthProvider<T extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Partial<ProviderOptions>> {
732
+ id: LiteralString;
733
+ createAuthorizationURL: (data: {
734
+ state: string;
735
+ codeVerifier: string;
736
+ scopes?: string[] | undefined;
737
+ redirectURI: string;
738
+ display?: string | undefined;
739
+ loginHint?: string | undefined;
740
+ }) => Promise<URL> | URL;
741
+ name: string;
742
+ validateAuthorizationCode: (data: {
743
+ code: string;
744
+ redirectURI: string;
745
+ codeVerifier?: string | undefined;
746
+ deviceId?: string | undefined;
747
+ }) => Promise<OAuth2Tokens>;
748
+ getUserInfo: (token: OAuth2Tokens & {
749
+ /**
750
+ * The user object from the provider
751
+ * This is only available for some providers like Apple
752
+ */
753
+ user?: {
754
+ name?: {
755
+ firstName?: string;
756
+ lastName?: string;
757
+ };
758
+ email?: string;
759
+ } | undefined;
760
+ }) => Promise<{
761
+ user: OAuth2UserInfo;
762
+ data: T;
763
+ } | null>;
764
+ /**
765
+ * Custom function to refresh a token
766
+ */
767
+ refreshAccessToken?: ((refreshToken: string) => Promise<OAuth2Tokens>) | undefined;
768
+ revokeToken?: ((token: string) => Promise<void>) | undefined;
769
+ /**
770
+ * Verify the id token
771
+ * @param token - The id token
772
+ * @param nonce - The nonce
773
+ * @returns True if the id token is valid, false otherwise
774
+ */
775
+ verifyIdToken?: ((token: string, nonce?: string) => Promise<boolean>) | undefined;
776
+ /**
777
+ * Disable implicit sign up for new users. When set to true for the provider,
778
+ * sign-in need to be called with with requestSignUp as true to create new users.
779
+ */
780
+ disableImplicitSignUp?: boolean | undefined;
781
+ /**
782
+ * Disable sign up for new users.
783
+ */
784
+ disableSignUp?: boolean | undefined;
785
+ /**
786
+ * Options for the provider
787
+ */
788
+ options?: O | undefined;
789
+ }
790
+ type ProviderOptions<Profile extends Record<string, any> = any> = {
791
+ /**
792
+ * The client ID of your application.
793
+ *
794
+ * This is usually a string but can be any type depending on the provider.
795
+ */
796
+ clientId?: unknown | undefined;
797
+ /**
798
+ * The client secret of your application
799
+ */
800
+ clientSecret?: string | undefined;
801
+ /**
802
+ * The scopes you want to request from the provider
803
+ */
804
+ scope?: string[] | undefined;
805
+ /**
806
+ * Remove default scopes of the provider
807
+ */
808
+ disableDefaultScope?: boolean | undefined;
809
+ /**
810
+ * The redirect URL for your application. This is where the provider will
811
+ * redirect the user after the sign in process. Make sure this URL is
812
+ * whitelisted in the provider's dashboard.
813
+ */
814
+ redirectURI?: string | undefined;
815
+ /**
816
+ * The client key of your application
817
+ * Tiktok Social Provider uses this field instead of clientId
818
+ */
819
+ clientKey?: string | undefined;
820
+ /**
821
+ * Disable provider from allowing users to sign in
822
+ * with this provider with an id token sent from the
823
+ * client.
824
+ */
825
+ disableIdTokenSignIn?: boolean | undefined;
826
+ /**
827
+ * verifyIdToken function to verify the id token
828
+ */
829
+ verifyIdToken?: ((token: string, nonce?: string) => Promise<boolean>) | undefined;
830
+ /**
831
+ * Custom function to get user info from the provider
832
+ */
833
+ getUserInfo?: ((token: OAuth2Tokens) => Promise<{
834
+ user: {
835
+ id: string;
836
+ name?: string;
837
+ email?: string | null;
838
+ image?: string;
839
+ emailVerified: boolean;
840
+ [key: string]: any;
841
+ };
842
+ data: any;
843
+ }>) | undefined;
844
+ /**
845
+ * Custom function to refresh a token
846
+ */
847
+ refreshAccessToken?: ((refreshToken: string) => Promise<OAuth2Tokens>) | undefined;
848
+ /**
849
+ * Custom function to map the provider profile to a
850
+ * user.
851
+ */
852
+ mapProfileToUser?: ((profile: Profile) => {
853
+ id?: string;
854
+ name?: string;
855
+ email?: string | null;
856
+ image?: string;
857
+ emailVerified?: boolean;
858
+ [key: string]: any;
859
+ } | Promise<{
860
+ id?: string;
861
+ name?: string;
862
+ email?: string | null;
863
+ image?: string;
864
+ emailVerified?: boolean;
865
+ [key: string]: any;
866
+ }>) | undefined;
867
+ /**
868
+ * Disable implicit sign up for new users. When set to true for the provider,
869
+ * sign-in need to be called with with requestSignUp as true to create new users.
870
+ */
871
+ disableImplicitSignUp?: boolean | undefined;
872
+ /**
873
+ * Disable sign up for new users.
874
+ */
875
+ disableSignUp?: boolean | undefined;
876
+ /**
877
+ * The prompt to use for the authorization code request
878
+ */
879
+ prompt?: ("select_account" | "consent" | "login" | "none" | "select_account consent") | undefined;
880
+ /**
881
+ * The response mode to use for the authorization code request
882
+ */
883
+ responseMode?: ("query" | "form_post") | undefined;
884
+ /**
885
+ * If enabled, the user info will be overridden with the provider user info
886
+ * This is useful if you want to use the provider user info to update the user info
887
+ *
888
+ * @default false
889
+ */
890
+ overrideUserInfoOnSignIn?: boolean | undefined;
891
+ };
892
+ //#endregion
893
+ //#region src/oauth2/client-credentials-token.d.ts
894
+
895
+ //#endregion
896
+ //#region src/types/cookie.d.ts
897
+ type PayvoAuthCookies = {
898
+ sessionToken: {
899
+ name: string;
900
+ options: CookieOptions;
901
+ };
902
+ sessionData: {
903
+ name: string;
904
+ options: CookieOptions;
905
+ };
906
+ dontRememberToken: {
907
+ name: string;
908
+ options: CookieOptions;
909
+ };
910
+ };
911
+ //#endregion
912
+ //#region src/types/helper.d.ts
913
+ type Primitive = string | number | symbol | bigint | boolean | null | undefined;
914
+ type Awaitable$1<T> = T | Promise<T>;
915
+ type LiteralString = "" | (string & Record<never, never>);
916
+ type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
917
+ //#endregion
918
+ //#region src/social-providers/github.d.ts
919
+ interface GithubProfile {
920
+ login: string;
921
+ id: string;
922
+ node_id: string;
923
+ avatar_url: string;
924
+ gravatar_id: string;
925
+ url: string;
926
+ html_url: string;
927
+ followers_url: string;
928
+ following_url: string;
929
+ gists_url: string;
930
+ starred_url: string;
931
+ subscriptions_url: string;
932
+ organizations_url: string;
933
+ repos_url: string;
934
+ events_url: string;
935
+ received_events_url: string;
936
+ type: string;
937
+ site_admin: boolean;
938
+ name: string;
939
+ company: string;
940
+ blog: string;
941
+ location: string;
942
+ email: string;
943
+ hireable: boolean;
944
+ bio: string;
945
+ twitter_username: string;
946
+ public_repos: string;
947
+ public_gists: string;
948
+ followers: string;
949
+ following: string;
950
+ created_at: string;
951
+ updated_at: string;
952
+ private_gists: string;
953
+ total_private_repos: string;
954
+ owned_private_repos: string;
955
+ disk_usage: string;
956
+ collaborators: string;
957
+ two_factor_authentication: boolean;
958
+ plan: {
959
+ name: string;
960
+ space: string;
961
+ private_repos: string;
962
+ collaborators: string;
963
+ };
964
+ }
965
+ interface GithubOptions extends ProviderOptions<GithubProfile> {
966
+ clientId: string;
967
+ }
968
+ //#endregion
969
+ //#region src/social-providers/google.d.ts
970
+ interface GoogleProfile {
971
+ aud: string;
972
+ azp: string;
973
+ email: string;
974
+ email_verified: boolean;
975
+ exp: number;
976
+ /**
977
+ * The family name of the user, or last name in most
978
+ * Western languages.
979
+ */
980
+ family_name: string;
981
+ /**
982
+ * The given name of the user, or first name in most
983
+ * Western languages.
984
+ */
985
+ given_name: string;
986
+ hd?: string | undefined;
987
+ iat: number;
988
+ iss: string;
989
+ jti?: string | undefined;
990
+ locale?: string | undefined;
991
+ name: string;
992
+ nbf?: number | undefined;
993
+ picture: string;
994
+ sub: string;
995
+ }
996
+ interface GoogleOptions extends ProviderOptions<GoogleProfile> {
997
+ clientId: string;
998
+ /**
999
+ * The access type to use for the authorization code request
1000
+ */
1001
+ accessType?: ("offline" | "online") | undefined;
1002
+ /**
1003
+ * The display mode to use for the authorization code request
1004
+ */
1005
+ display?: ("page" | "popup" | "touch" | "wap") | undefined;
1006
+ /**
1007
+ * The hosted domain of the user
1008
+ */
1009
+ hd?: string | undefined;
1010
+ }
1011
+ //#endregion
1012
+ //#region src/social-providers/index.d.ts
1013
+ declare const socialProviders: {
1014
+ github: (options: GithubOptions) => {
1015
+ id: "github";
1016
+ name: string;
1017
+ createAuthorizationURL({
1018
+ state,
1019
+ scopes,
1020
+ loginHint,
1021
+ redirectURI
1022
+ }: {
1023
+ state: string;
1024
+ codeVerifier: string;
1025
+ scopes?: string[] | undefined;
1026
+ redirectURI: string;
1027
+ display?: string | undefined;
1028
+ loginHint?: string | undefined;
1029
+ }): Promise<URL>;
1030
+ validateAuthorizationCode: ({
1031
+ code,
1032
+ redirectURI
1033
+ }: {
1034
+ code: string;
1035
+ redirectURI: string;
1036
+ codeVerifier?: string | undefined;
1037
+ deviceId?: string | undefined;
1038
+ }) => Promise<OAuth2Tokens>;
1039
+ refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
1040
+ getUserInfo(token: OAuth2Tokens & {
1041
+ user?: {
1042
+ name?: {
1043
+ firstName?: string;
1044
+ lastName?: string;
1045
+ };
1046
+ email?: string;
1047
+ } | undefined;
1048
+ }): Promise<{
1049
+ user: {
1050
+ id: string;
1051
+ name?: string;
1052
+ email?: string | null;
1053
+ image?: string;
1054
+ emailVerified: boolean;
1055
+ [key: string]: any;
1056
+ };
1057
+ data: any;
1058
+ } | null>;
1059
+ options: GithubOptions;
1060
+ };
1061
+ google: (options: GoogleOptions) => {
1062
+ id: "google";
1063
+ name: string;
1064
+ createAuthorizationURL({
1065
+ state,
1066
+ scopes,
1067
+ codeVerifier,
1068
+ redirectURI,
1069
+ loginHint,
1070
+ display
1071
+ }: {
1072
+ state: string;
1073
+ codeVerifier: string;
1074
+ scopes?: string[] | undefined;
1075
+ redirectURI: string;
1076
+ display?: string | undefined;
1077
+ loginHint?: string | undefined;
1078
+ }): Promise<URL>;
1079
+ validateAuthorizationCode: ({
1080
+ code,
1081
+ codeVerifier,
1082
+ redirectURI
1083
+ }: {
1084
+ code: string;
1085
+ redirectURI: string;
1086
+ codeVerifier?: string | undefined;
1087
+ deviceId?: string | undefined;
1088
+ }) => Promise<OAuth2Tokens>;
1089
+ refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
1090
+ verifyIdToken(token: string, nonce: string | undefined): Promise<boolean>;
1091
+ getUserInfo(token: OAuth2Tokens & {
1092
+ user?: {
1093
+ name?: {
1094
+ firstName?: string;
1095
+ lastName?: string;
1096
+ };
1097
+ email?: string;
1098
+ } | undefined;
1099
+ }): Promise<{
1100
+ user: {
1101
+ id: string;
1102
+ name?: string;
1103
+ email?: string | null;
1104
+ image?: string;
1105
+ emailVerified: boolean;
1106
+ [key: string]: any;
1107
+ };
1108
+ data: any;
1109
+ } | null>;
1110
+ options: GoogleOptions;
1111
+ };
1112
+ };
1113
+ declare const socialProviderList: ["github", ...(keyof typeof socialProviders)[]];
1114
+ type SocialProviders = { [K in SocialProviderList[number]]?: Parameters<(typeof socialProviders)[K]>[0] & {
1115
+ enabled?: boolean | undefined;
1116
+ } };
1117
+ type SocialProviderList = typeof socialProviderList;
1118
+ //#endregion
1119
+ //#region src/types/plugin.d.ts
1120
+ type Awaitable<T> = T | Promise<T>;
1121
+ type DeepPartial<T> = T extends Function ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
1122
+ type HookEndpointContext = Partial<EndpointContext<string, any> & Omit<InputContext<string, any>, "method">> & {
1123
+ path: string;
1124
+ context: AuthContext & {
1125
+ returned?: unknown | undefined;
1126
+ responseHeaders?: Headers | undefined;
1127
+ };
1128
+ headers?: Headers | undefined;
1129
+ };
1130
+ type PayvoAuthPlugin = {
1131
+ id: LiteralString;
1132
+ /**
1133
+ * The init function is called when the plugin is initialized.
1134
+ * You can return a new context or modify the existing context.
1135
+ */
1136
+ init?: ((ctx: AuthContext) => Awaitable<{
1137
+ context?: DeepPartial<Omit<AuthContext, "options">>;
1138
+ options?: Partial<PayvoAuthOptions>;
1139
+ }> | void | Promise<void>) | undefined;
1140
+ endpoints?: {
1141
+ [key: string]: Endpoint;
1142
+ } | undefined;
1143
+ middlewares?: {
1144
+ path: string;
1145
+ middleware: Middleware;
1146
+ }[] | undefined;
1147
+ onRequest?: ((request: Request, ctx: AuthContext) => Promise<{
1148
+ response: Response;
1149
+ } | {
1150
+ request: Request;
1151
+ } | void>) | undefined;
1152
+ onResponse?: ((response: Response, ctx: AuthContext) => Promise<{
1153
+ response: Response;
1154
+ } | void>) | undefined;
1155
+ hooks?: {
1156
+ before?: {
1157
+ matcher: (context: HookEndpointContext) => boolean;
1158
+ handler: AuthMiddleware;
1159
+ }[];
1160
+ after?: {
1161
+ matcher: (context: HookEndpointContext) => boolean;
1162
+ handler: AuthMiddleware;
1163
+ }[];
1164
+ } | undefined;
1165
+ /**
1166
+ * Schema the plugin needs
1167
+ *
1168
+ * This will also be used to migrate the database. If the fields are dynamic from the plugins
1169
+ * configuration each time the configuration is changed a new migration will be created.
1170
+ *
1171
+ * NOTE: If you want to create migrations manually using
1172
+ * migrations option or any other way you
1173
+ * can disable migration per table basis.
1174
+ *
1175
+ * @example
1176
+ * ```ts
1177
+ * schema: {
1178
+ * user: {
1179
+ * fields: {
1180
+ * email: {
1181
+ * type: "string",
1182
+ * },
1183
+ * emailVerified: {
1184
+ * type: "boolean",
1185
+ * defaultValue: false,
1186
+ * },
1187
+ * },
1188
+ * }
1189
+ * } as AuthPluginSchema
1190
+ * ```
1191
+ */
1192
+ schema?: PayvoAuthPluginDBSchema | undefined;
1193
+ /**
1194
+ * The migrations of the plugin. If you define schema that will automatically create
1195
+ * migrations for you.
1196
+ *
1197
+ * ⚠️ Only uses this if you dont't want to use the schema option and you disabled migrations for
1198
+ * the tables.
1199
+ */
1200
+ migrations?: Record<string, Migration> | undefined;
1201
+ /**
1202
+ * The options of the plugin
1203
+ */
1204
+ options?: Record<string, any> | undefined;
1205
+ /**
1206
+ * types to be inferred
1207
+ */
1208
+ $Infer?: Record<string, any> | undefined;
1209
+ /**
1210
+ * The rate limit rules to apply to specific paths.
1211
+ */
1212
+ rateLimit?: {
1213
+ window: number;
1214
+ max: number;
1215
+ pathMatcher: (path: string) => boolean;
1216
+ }[] | undefined;
1217
+ /**
1218
+ * The error codes returned by the plugin
1219
+ */
1220
+ $ERROR_CODES?: Record<string, string> | undefined;
1221
+ /**
1222
+ * All database operations that are performed by the plugin
1223
+ *
1224
+ * This will override the default database operations
1225
+ */
1226
+ adapter?: {
1227
+ [key: string]: (...args: any[]) => Promise<any> | any;
1228
+ };
1229
+ };
1230
+ //#endregion
1231
+ //#region src/types/init-options.d.ts
1232
+ type KyselyDatabaseType = "postgres" | "mysql" | "sqlite" | "mssql";
1233
+ type OmitId<T extends {
1234
+ id: unknown;
1235
+ }> = Omit<T, "id">;
1236
+ type Optional<T> = { [P in keyof T]?: T[P] | undefined };
1237
+ type GenerateIdFn = (options: {
1238
+ model: LiteralUnion<DBPreservedModels, string>;
1239
+ size?: number | undefined;
1240
+ }) => string | false;
1241
+ type PayvoAuthRateLimitOptions = {
1242
+ /**
1243
+ * By default, rate limiting is only
1244
+ * enabled on production.
1245
+ */
1246
+ enabled?: boolean | undefined;
1247
+ /**
1248
+ * Default window to use for rate limiting. The value
1249
+ * should be in seconds.
1250
+ *
1251
+ * @default 10 seconds
1252
+ */
1253
+ window?: number | undefined;
1254
+ /**
1255
+ * The default maximum number of requests allowed within the window.
1256
+ *
1257
+ * @default 100 requests
1258
+ */
1259
+ max?: number | undefined;
1260
+ /**
1261
+ * Custom rate limit rules to apply to
1262
+ * specific paths.
1263
+ */
1264
+ customRules?: {
1265
+ [key: string]: {
1266
+ /**
1267
+ * The window to use for the custom rule.
1268
+ */
1269
+ window: number;
1270
+ /**
1271
+ * The maximum number of requests allowed within the window.
1272
+ */
1273
+ max: number;
1274
+ } | false | ((request: Request) => {
1275
+ window: number;
1276
+ max: number;
1277
+ } | false | Promise<{
1278
+ window: number;
1279
+ max: number;
1280
+ } | false>);
1281
+ } | undefined;
1282
+ /**
1283
+ * Storage configuration
1284
+ *
1285
+ * By default, rate limiting is stored in memory. If you passed a
1286
+ * secondary storage, rate limiting will be stored in the secondary
1287
+ * storage.
1288
+ *
1289
+ * @default "memory"
1290
+ */
1291
+ storage?: ("memory" | "database" | "secondary-storage") | undefined;
1292
+ /**
1293
+ * If database is used as storage, the name of the table to
1294
+ * use for rate limiting.
1295
+ *
1296
+ * @default "rateLimit"
1297
+ */
1298
+ modelName?: string | undefined;
1299
+ /**
1300
+ * Custom field names for the rate limit table
1301
+ */
1302
+ fields?: Record<keyof RateLimit, string> | undefined;
1303
+ /**
1304
+ * custom storage configuration.
1305
+ *
1306
+ * NOTE: If custom storage is used storage
1307
+ * is ignored
1308
+ */
1309
+ customStorage?: {
1310
+ get: (key: string) => Promise<RateLimit | undefined>;
1311
+ set: (key: string, value: RateLimit) => Promise<void>;
1312
+ };
1313
+ };
1314
+ type PayvoAuthAdvancedOptions = {
1315
+ /**
1316
+ * Ip address configuration
1317
+ */
1318
+ ipAddress?: {
1319
+ /**
1320
+ * List of headers to use for ip address
1321
+ *
1322
+ * Ip address is used for rate limiting and session tracking
1323
+ *
1324
+ * @example ["x-client-ip", "x-forwarded-for", "cf-connecting-ip"]
1325
+ *
1326
+ * @default
1327
+ * @link https://github.com/payvo-auth/payvo-auth/blob/main/packages/payvo-auth/src/utils/get-request-ip.ts#L8
1328
+ */
1329
+ ipAddressHeaders?: string[];
1330
+ /**
1331
+ * Disable ip tracking
1332
+ *
1333
+ * ⚠︎ This is a security risk and it may expose your application to abuse
1334
+ */
1335
+ disableIpTracking?: boolean;
1336
+ } | undefined;
1337
+ /**
1338
+ * Use secure cookies
1339
+ *
1340
+ * @default false
1341
+ */
1342
+ useSecureCookies?: boolean | undefined;
1343
+ /**
1344
+ * Disable trusted origins check
1345
+ *
1346
+ * ⚠︎ This is a security risk and it may expose your application to
1347
+ * CSRF attacks
1348
+ */
1349
+ disableCSRFCheck?: boolean | undefined;
1350
+ /**
1351
+ * Disable origin check
1352
+ *
1353
+ * ⚠︎ This may allow requests from any origin to be processed by
1354
+ * Payvo Auth. And could lead to security vulnerabilities.
1355
+ */
1356
+ disableOriginCheck?: boolean | undefined;
1357
+ /**
1358
+ * Configure cookies to be cross subdomains
1359
+ */
1360
+ crossSubDomainCookies?: {
1361
+ /**
1362
+ * Enable cross subdomain cookies
1363
+ */
1364
+ enabled: boolean;
1365
+ /**
1366
+ * Additional cookies to be shared across subdomains
1367
+ */
1368
+ additionalCookies?: string[];
1369
+ /**
1370
+ * The domain to use for the cookies
1371
+ *
1372
+ * By default, the domain will be the root
1373
+ * domain from the base URL.
1374
+ */
1375
+ domain?: string;
1376
+ } | undefined;
1377
+ cookies?: {
1378
+ [key: string]: {
1379
+ name?: string;
1380
+ attributes?: CookieOptions;
1381
+ };
1382
+ } | undefined;
1383
+ defaultCookieAttributes?: CookieOptions | undefined;
1384
+ /**
1385
+ * Prefix for cookies. If a cookie name is provided
1386
+ * in cookies config, this will be overridden.
1387
+ *
1388
+ * @default
1389
+ * ```txt
1390
+ * "appName" -> which defaults to "payvo-auth"
1391
+ * ```
1392
+ */
1393
+ cookiePrefix?: string | undefined;
1394
+ /**
1395
+ * Database configuration.
1396
+ */
1397
+ database?: {
1398
+ /**
1399
+ * The default number of records to return from the database
1400
+ * when using the `findMany` adapter method.
1401
+ *
1402
+ * @default 100
1403
+ */
1404
+ defaultFindManyLimit?: number;
1405
+ /**
1406
+ * If your database auto increments number ids, set this to `true`.
1407
+ *
1408
+ * Note: If enabled, we will not handle ID generation (including if you use `generateId`), and it would be expected that your database will provide the ID automatically.
1409
+ *
1410
+ * @default false
1411
+ *
1412
+ * @deprecated Please use `generateId` instead. This will be removed in future
1413
+ * releases.
1414
+ */
1415
+ useNumberId?: boolean;
1416
+ /**
1417
+ * Custom generateId function.
1418
+ *
1419
+ * If not provided, random ids will be generated.
1420
+ * If set to false, the database's auto generated id
1421
+ * will be used.
1422
+ *
1423
+ * If set to "serial", the database's auto generated
1424
+ * id will be used.
1425
+ *
1426
+ * If set to "uuid", we generate a random UUID for
1427
+ * the id. If postgres, we use the `gen_random_uuid()
1428
+ * ` function. If mysql or mssql, we use the `uuid()`
1429
+ * function.
1430
+ */
1431
+ generateId?: GenerateIdFn | false | "serial" | "uuid";
1432
+ } | undefined;
1433
+ /**
1434
+ * OAuth configuration
1435
+ */
1436
+ oauthConfig?: {
1437
+ /**
1438
+ * Skip state cookie check
1439
+ *
1440
+ * ⚠︎ this has security implications and should only be enabled if you know what you are doing.
1441
+ * @default false
1442
+ */
1443
+ skipStateCookieCheck?: boolean;
1444
+ /**
1445
+ * Strategy for storing OAuth state
1446
+ *
1447
+ * - "cookie": Store state in an encrypted cookie (stateless)
1448
+ * - "database": Store state in the database
1449
+ *
1450
+ * @default "cookie"
1451
+ */
1452
+ storeStateStrategy?: "database" | "cookie";
1453
+ } | undefined;
1454
+ };
1455
+ type PayvoAuthOptions = {
1456
+ /**
1457
+ * The name of the application
1458
+ *
1459
+ * process.env.APP_NAME
1460
+ *
1461
+ * @default "Payvo Auth"
1462
+ */
1463
+ appName?: string | undefined;
1464
+ /**
1465
+ * Base URL for the Payvo Auth. This is typically the
1466
+ * root URL where your application server is hosted.
1467
+ * If not explicitly set,
1468
+ * the system will check the following environment variable:
1469
+ *
1470
+ * process.env.PAYVO_AUTH_URL
1471
+ */
1472
+ baseURL?: string | undefined;
1473
+ /**
1474
+ * Base path for the Payvo Auth. This is typically
1475
+ * the path where the
1476
+ * Payvo Auth routes are mounted.
1477
+ *
1478
+ * @default "/api/auth"
1479
+ */
1480
+ basePath?: string | undefined;
1481
+ /**
1482
+ * The secret to use for encryption,
1483
+ * signing and hashing.
1484
+ *
1485
+ * By default Payvo Auth will look for
1486
+ * the following environment variables:
1487
+ * process.env.PAYVO_AUTH_SECRET,
1488
+ * process.env.AUTH_SECRET
1489
+ * If none of these environment
1490
+ * variables are set,
1491
+ * it will default to
1492
+ * "payvo-auth-secret-123456789".
1493
+ *
1494
+ * on production if it's not set
1495
+ * it will throw an error.
1496
+ *
1497
+ * you can generate a good secret
1498
+ * using the following command:
1499
+ * @example
1500
+ * ```bash
1501
+ * openssl rand -base64 32
1502
+ * ```
1503
+ */
1504
+ secret?: string | undefined;
1505
+ /**
1506
+ * Database configuration
1507
+ */
1508
+ database?: (PostgresPool | MysqlPool | SqliteDatabase | Dialect | DBAdapterInstance | Database | DatabaseSync | {
1509
+ dialect: Dialect;
1510
+ type: KyselyDatabaseType;
1511
+ /**
1512
+ * casing for table names
1513
+ *
1514
+ * @default "camel"
1515
+ */
1516
+ casing?: "snake" | "camel";
1517
+ /**
1518
+ * Enable debug logs for the adapter
1519
+ *
1520
+ * @default false
1521
+ */
1522
+ debugLogs?: DBAdapterDebugLogOption;
1523
+ /**
1524
+ * Whether to execute multiple operations in a transaction.
1525
+ * If the database doesn't support transactions,
1526
+ * set this to `false` and operations will be executed sequentially.
1527
+ * @default true
1528
+ */
1529
+ transaction?: boolean;
1530
+ } | {
1531
+ /**
1532
+ * Kysely instance
1533
+ */
1534
+ db: Kysely<any>;
1535
+ /**
1536
+ * Database type between postgres, mysql and sqlite
1537
+ */
1538
+ type: KyselyDatabaseType;
1539
+ /**
1540
+ * casing for table names
1541
+ *
1542
+ * @default "camel"
1543
+ */
1544
+ casing?: "snake" | "camel";
1545
+ /**
1546
+ * Enable debug logs for the adapter
1547
+ *
1548
+ * @default false
1549
+ */
1550
+ debugLogs?: DBAdapterDebugLogOption;
1551
+ /**
1552
+ * Whether to execute multiple operations in a transaction.
1553
+ * If the database doesn't support transactions,
1554
+ * set this to `false` and operations will be executed sequentially.
1555
+ * @default true
1556
+ */
1557
+ transaction?: boolean;
1558
+ }) | undefined;
1559
+ /**
1560
+ * Secondary storage configuration
1561
+ *
1562
+ * This is used to store session and rate limit data.
1563
+ */
1564
+ secondaryStorage?: SecondaryStorage | undefined;
1565
+ /**
1566
+ * Email verification configuration
1567
+ */
1568
+ emailVerification?: {
1569
+ /**
1570
+ * Send a verification email
1571
+ * @param data the data object
1572
+ * @param request the request object
1573
+ */
1574
+ sendVerificationEmail?: (
1575
+ /**
1576
+ * @param user the user to send the
1577
+ * verification email to
1578
+ * @param url the URL to send the verification email to
1579
+ * it contains the token as well
1580
+ * @param token the token to send the verification email to
1581
+ */
1582
+ data: {
1583
+ user: User;
1584
+ url: string;
1585
+ token: string;
1586
+ },
1587
+ /**
1588
+ * The request object
1589
+ */
1590
+ request?: Request) => Promise<void>;
1591
+ /**
1592
+ * Send a verification email automatically
1593
+ * after sign up
1594
+ *
1595
+ * @default false
1596
+ */
1597
+ sendOnSignUp?: boolean;
1598
+ /**
1599
+ * Send a verification email automatically
1600
+ * on sign in when the user's email is not verified
1601
+ *
1602
+ * @default false
1603
+ */
1604
+ sendOnSignIn?: boolean;
1605
+ /**
1606
+ * Auto signin the user after they verify their email
1607
+ */
1608
+ autoSignInAfterVerification?: boolean;
1609
+ /**
1610
+ * Number of seconds the verification token is
1611
+ * valid for.
1612
+ * @default 3600 seconds (1 hour)
1613
+ */
1614
+ expiresIn?: number;
1615
+ /**
1616
+ * A function that is called when a user verifies their email
1617
+ * @param user the user that verified their email
1618
+ * @param request the request object
1619
+ */
1620
+ onEmailVerification?: (user: User, request?: Request) => Promise<void>;
1621
+ /**
1622
+ * A function that is called when a user's email is updated to verified
1623
+ * @param user the user that verified their email
1624
+ * @param request the request object
1625
+ */
1626
+ afterEmailVerification?: (user: User, request?: Request) => Promise<void>;
1627
+ } | undefined;
1628
+ /**
1629
+ * Email and password authentication
1630
+ */
1631
+ emailAndPassword?: {
1632
+ /**
1633
+ * Enable email and password authentication
1634
+ *
1635
+ * @default false
1636
+ */
1637
+ enabled: boolean;
1638
+ /**
1639
+ * Disable email and password sign up
1640
+ *
1641
+ * @default false
1642
+ */
1643
+ disableSignUp?: boolean;
1644
+ /**
1645
+ * Require email verification before a session
1646
+ * can be created for the user.
1647
+ *
1648
+ * if the user is not verified, the user will not be able to sign in
1649
+ * and on sign in attempts, the user will be prompted to verify their email.
1650
+ */
1651
+ requireEmailVerification?: boolean;
1652
+ /**
1653
+ * The maximum length of the password.
1654
+ *
1655
+ * @default 128
1656
+ */
1657
+ maxPasswordLength?: number;
1658
+ /**
1659
+ * The minimum length of the password.
1660
+ *
1661
+ * @default 8
1662
+ */
1663
+ minPasswordLength?: number;
1664
+ /**
1665
+ * send reset password
1666
+ */
1667
+ sendResetPassword?: (
1668
+ /**
1669
+ * @param user the user to send the
1670
+ * reset password email to
1671
+ * @param url the URL to send the reset password email to
1672
+ * @param token the token to send to the user (could be used instead of sending the url
1673
+ * if you need to redirect the user to custom route)
1674
+ */
1675
+ data: {
1676
+ user: User;
1677
+ url: string;
1678
+ token: string;
1679
+ },
1680
+ /**
1681
+ * The request object
1682
+ */
1683
+ request?: Request) => Promise<void>;
1684
+ /**
1685
+ * Number of seconds the reset password token is
1686
+ * valid for.
1687
+ * @default 1 hour (60 * 60)
1688
+ */
1689
+ resetPasswordTokenExpiresIn?: number;
1690
+ /**
1691
+ * A callback function that is triggered
1692
+ * when a user's password is changed successfully.
1693
+ */
1694
+ onPasswordReset?: (data: {
1695
+ user: User;
1696
+ }, request?: Request) => Promise<void>;
1697
+ /**
1698
+ * Password hashing and verification
1699
+ *
1700
+ * By default Scrypt is used for password hashing and
1701
+ * verification. You can provide your own hashing and
1702
+ * verification function. if you want to use a
1703
+ * different algorithm.
1704
+ */
1705
+ password?: {
1706
+ hash?: (password: string) => Promise<string>;
1707
+ verify?: (data: {
1708
+ hash: string;
1709
+ password: string;
1710
+ }) => Promise<boolean>;
1711
+ };
1712
+ /**
1713
+ * Automatically sign in the user after sign up
1714
+ *
1715
+ * @default true
1716
+ */
1717
+ autoSignIn?: boolean;
1718
+ /**
1719
+ * Whether to revoke all other sessions when resetting password
1720
+ * @default false
1721
+ */
1722
+ revokeSessionsOnPasswordReset?: boolean;
1723
+ } | undefined;
1724
+ /**
1725
+ * list of social providers
1726
+ */
1727
+ socialProviders?: SocialProviders | undefined;
1728
+ /**
1729
+ * List of Payvo Auth plugins
1730
+ */
1731
+ plugins?: ([] | PayvoAuthPlugin[]) | undefined;
1732
+ /**
1733
+ * User configuration
1734
+ */
1735
+ user?: {
1736
+ /**
1737
+ * The model name for the user. Defaults to "user".
1738
+ */
1739
+ modelName?: string;
1740
+ /**
1741
+ * Map fields
1742
+ *
1743
+ * @example
1744
+ * ```ts
1745
+ * {
1746
+ * userId: "user_id"
1747
+ * }
1748
+ * ```
1749
+ */
1750
+ fields?: Partial<Record<keyof OmitId<User>, string>>;
1751
+ /**
1752
+ * Additional fields for the user
1753
+ */
1754
+ additionalFields?: {
1755
+ [key: string]: DBFieldAttribute;
1756
+ };
1757
+ /**
1758
+ * Changing email configuration
1759
+ */
1760
+ changeEmail?: {
1761
+ /**
1762
+ * Enable changing email
1763
+ * @default false
1764
+ */
1765
+ enabled: boolean;
1766
+ /**
1767
+ * Send a verification email when the user changes their email.
1768
+ * @param data the data object
1769
+ * @param request the request object
1770
+ */
1771
+ sendChangeEmailVerification?: (data: {
1772
+ user: User;
1773
+ newEmail: string;
1774
+ url: string;
1775
+ token: string;
1776
+ }, request?: Request) => Promise<void>;
1777
+ };
1778
+ /**
1779
+ * User deletion configuration
1780
+ */
1781
+ deleteUser?: {
1782
+ /**
1783
+ * Enable user deletion
1784
+ */
1785
+ enabled?: boolean;
1786
+ /**
1787
+ * Send a verification email when the user deletes their account.
1788
+ *
1789
+ * if this is not set, the user will be deleted immediately.
1790
+ * @param data the data object
1791
+ * @param request the request object
1792
+ */
1793
+ sendDeleteAccountVerification?: (data: {
1794
+ user: User;
1795
+ url: string;
1796
+ token: string;
1797
+ }, request?: Request) => Promise<void>;
1798
+ /**
1799
+ * A function that is called before a user is deleted.
1800
+ *
1801
+ * to interrupt with error you can throw `APIError`
1802
+ */
1803
+ beforeDelete?: (user: User, request?: Request) => Promise<void>;
1804
+ /**
1805
+ * A function that is called after a user is deleted.
1806
+ *
1807
+ * This is useful for cleaning up user data
1808
+ */
1809
+ afterDelete?: (user: User, request?: Request) => Promise<void>;
1810
+ /**
1811
+ * The expiration time for the delete token.
1812
+ *
1813
+ * @default 1 day (60 * 60 * 24) in seconds
1814
+ */
1815
+ deleteTokenExpiresIn?: number;
1816
+ };
1817
+ } | undefined;
1818
+ session?: {
1819
+ /**
1820
+ * The model name for the session.
1821
+ *
1822
+ * @default "session"
1823
+ */
1824
+ modelName?: string;
1825
+ /**
1826
+ * Map fields
1827
+ *
1828
+ * @example
1829
+ * ```ts
1830
+ * {
1831
+ * userId: "user_id"
1832
+ * }
1833
+ */
1834
+ fields?: Partial<Record<keyof OmitId<Session>, string>>;
1835
+ /**
1836
+ * Expiration time for the session token. The value
1837
+ * should be in seconds.
1838
+ * @default 7 days (60 * 60 * 24 * 7)
1839
+ */
1840
+ expiresIn?: number;
1841
+ /**
1842
+ * How often the session should be refreshed. The value
1843
+ * should be in seconds.
1844
+ * If set 0 the session will be refreshed every time it is used.
1845
+ * @default 1 day (60 * 60 * 24)
1846
+ */
1847
+ updateAge?: number;
1848
+ /**
1849
+ * Disable session refresh so that the session is not updated
1850
+ * regardless of the `updateAge` option.
1851
+ *
1852
+ * @default false
1853
+ */
1854
+ disableSessionRefresh?: boolean;
1855
+ /**
1856
+ * Additional fields for the session
1857
+ */
1858
+ additionalFields?: {
1859
+ [key: string]: DBFieldAttribute;
1860
+ };
1861
+ /**
1862
+ * By default if secondary storage is provided
1863
+ * the session is stored in the secondary storage.
1864
+ *
1865
+ * Set this to true to store the session in the database
1866
+ * as well.
1867
+ *
1868
+ * Reads are always done from the secondary storage.
1869
+ *
1870
+ * @default false
1871
+ */
1872
+ storeSessionInDatabase?: boolean;
1873
+ /**
1874
+ * By default, sessions are deleted from the database when secondary storage
1875
+ * is provided when session is revoked.
1876
+ *
1877
+ * Set this to true to preserve session records in the database,
1878
+ * even if they are deleted from the secondary storage.
1879
+ *
1880
+ * @default false
1881
+ */
1882
+ preserveSessionInDatabase?: boolean;
1883
+ /**
1884
+ * Enable caching session in cookie
1885
+ */
1886
+ cookieCache?: {
1887
+ /**
1888
+ * max age of the cookie
1889
+ * @default 5 minutes (5 * 60)
1890
+ */
1891
+ maxAge?: number;
1892
+ /**
1893
+ * Enable caching session in cookie
1894
+ * @default false
1895
+ */
1896
+ enabled?: boolean;
1897
+ /**
1898
+ * Strategy for encoding/decoding cookie cache
1899
+ *
1900
+ * - "compact": Uses base64url encoding with HMAC-SHA256 signature (compact format, no JWT spec overhead)
1901
+ * - "jwt": Uses JWT with HMAC signature (no encryption, follows JWT spec)
1902
+ * - "jwe": Uses JWE (JSON Web Encryption) with A256CBC-HS512 and HKDF key derivation for secure encrypted tokens
1903
+ *
1904
+ * @default "compact"
1905
+ */
1906
+ strategy?: "compact" | "jwt" | "jwe";
1907
+ /**
1908
+ * Controls stateless cookie cache refresh behavior.
1909
+ *
1910
+ * When enabled, the cookie cache will be automatically refreshed before expiry
1911
+ * WITHOUT querying the database. This is essential for fully stateless or DB-less scenarios.
1912
+ *
1913
+ * - `false`: Disable automatic refresh. Cache is only invalidated when it reaches maxAge expiry.
1914
+ * - `true`: Enable automatic refresh with default settings (refreshes when 80% of maxAge is reached).
1915
+ * - `object`: Custom refresh configuration with either `updateAge` or `shouldRefresh` function
1916
+ *
1917
+ * Note: When the cache expires (reaches maxAge), it will attempt to fetch from database if available.
1918
+ * The refreshCache option is specifically for refreshing BEFORE expiry in a stateless manner.
1919
+ *
1920
+ * @default false
1921
+ */
1922
+ refreshCache?: boolean | {
1923
+ /**
1924
+ * Time in seconds before expiry when the cache should be refreshed.
1925
+ * For example, if maxAge is 300 (5 minutes) and updateAge is 60,
1926
+ * the cache will be refreshed when it has 60 seconds left before expiry.
1927
+ *
1928
+ * @default 20% of maxAge
1929
+ */
1930
+ updateAge?: number;
1931
+ };
1932
+ /**
1933
+ * Version of the cookie cache
1934
+ *
1935
+ * If a cookie cache version is changed, all existing cookie caches with the old version
1936
+ * will be invalidated.
1937
+ *
1938
+ * It can be a string or a function that returns a string or a promise that returns a string.
1939
+ * If it's a function, it will be called with the session and user data
1940
+ *
1941
+ * @default "1"
1942
+ */
1943
+ version?: string | ((session: Session & Record<string, any>, user: User & Record<string, any>) => string) | ((session: Session & Record<string, any>, user: User & Record<string, any>) => Promise<string>);
1944
+ };
1945
+ /**
1946
+ * The age of the session to consider it fresh.
1947
+ *
1948
+ * This is used to check if the session is fresh
1949
+ * for sensitive operations. (e.g. deleting an account)
1950
+ *
1951
+ * If the session is not fresh, the user should be prompted
1952
+ * to sign in again.
1953
+ *
1954
+ * If set to 0, the session will be considered fresh every time. (⚠︎ not recommended)
1955
+ *
1956
+ * @default 1 day (60 * 60 * 24)
1957
+ */
1958
+ freshAge?: number;
1959
+ } | undefined;
1960
+ account?: {
1961
+ /**
1962
+ * The model name for the account. Defaults to "account".
1963
+ */
1964
+ modelName?: string;
1965
+ /**
1966
+ * Map fields
1967
+ */
1968
+ fields?: Partial<Record<keyof OmitId<Account>, string>>;
1969
+ /**
1970
+ * Additional fields for the account
1971
+ */
1972
+ additionalFields?: {
1973
+ [key: string]: DBFieldAttribute;
1974
+ };
1975
+ /**
1976
+ * When enabled (true), the user account data (accessToken, idToken, refreshToken, etc.)
1977
+ * will be updated on sign in with the latest data from the provider.
1978
+ *
1979
+ * @default true
1980
+ */
1981
+ updateAccountOnSignIn?: boolean;
1982
+ /**
1983
+ * Configuration for account linking.
1984
+ */
1985
+ accountLinking?: {
1986
+ /**
1987
+ * Enable account linking
1988
+ *
1989
+ * @default true
1990
+ */
1991
+ enabled?: boolean;
1992
+ /**
1993
+ * List of trusted providers
1994
+ */
1995
+ trustedProviders?: Array<LiteralUnion<SocialProviderList[number] | "email-password", string>>;
1996
+ /**
1997
+ * If enabled (true), this will allow users to manually linking accounts with different email addresses than the main user.
1998
+ *
1999
+ * @default false
2000
+ *
2001
+ * ⚠️ Warning: enabling this might lead to account takeovers, so proceed with caution.
2002
+ */
2003
+ allowDifferentEmails?: boolean;
2004
+ /**
2005
+ * If enabled (true), this will allow users to unlink all accounts.
2006
+ *
2007
+ * @default false
2008
+ */
2009
+ allowUnlinkingAll?: boolean;
2010
+ /**
2011
+ * If enabled (true), this will update the user information based on the newly linked account
2012
+ *
2013
+ * @default false
2014
+ */
2015
+ updateUserInfoOnLink?: boolean;
2016
+ };
2017
+ /**
2018
+ * Encrypt OAuth tokens
2019
+ *
2020
+ * By default, OAuth tokens (access tokens, refresh tokens, ID tokens) are stored in plain text in the database.
2021
+ * This poses a security risk if your database is compromised, as attackers could gain access to user accounts
2022
+ * on external services.
2023
+ *
2024
+ * When enabled, tokens are encrypted using AES-256-GCM before storage, providing protection against:
2025
+ * - Database breaches and unauthorized access to raw token data
2026
+ * - Internal threats from database administrators or compromised credentials
2027
+ * - Token exposure in database backups and logs
2028
+ * @default false
2029
+ */
2030
+ encryptOAuthTokens?: boolean;
2031
+ } | undefined;
2032
+ /**
2033
+ * Verification configuration
2034
+ */
2035
+ verification?: {
2036
+ /**
2037
+ * Change the modelName of the verification table
2038
+ */
2039
+ modelName?: string;
2040
+ /**
2041
+ * Map verification fields
2042
+ */
2043
+ fields?: Partial<Record<keyof OmitId<Verification>, string>>;
2044
+ /**
2045
+ * disable cleaning up expired values when a verification value is
2046
+ * fetched
2047
+ */
2048
+ disableCleanup?: boolean;
2049
+ } | undefined;
2050
+ /**
2051
+ * List of trusted origins.
2052
+ */
2053
+ trustedOrigins?: (string[] | ((request: Request) => string[] | Promise<string[]>)) | undefined;
2054
+ /**
2055
+ * Rate limiting configuration
2056
+ */
2057
+ rateLimit?: PayvoAuthRateLimitOptions | undefined;
2058
+ /**
2059
+ * Advanced options
2060
+ */
2061
+ advanced?: (PayvoAuthAdvancedOptions & {
2062
+ /**
2063
+ * @deprecated Please use `database.generateId` instead.
2064
+ */
2065
+ generateId?: never;
2066
+ }) | undefined;
2067
+ logger?: Logger | undefined;
2068
+ /**
2069
+ * allows you to define custom hooks that can be
2070
+ * executed during lifecycle of core database
2071
+ * operations.
2072
+ */
2073
+ databaseHooks?: {
2074
+ /**
2075
+ * User hooks
2076
+ */
2077
+ user?: {
2078
+ create?: {
2079
+ /**
2080
+ * Hook that is called before a user is created.
2081
+ * if the hook returns false, the user will not be created.
2082
+ * If the hook returns an object, it'll be used instead of the original data
2083
+ */
2084
+ before?: (user: User & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void | {
2085
+ data: Optional<User> & Record<string, any>;
2086
+ }>;
2087
+ /**
2088
+ * Hook that is called after a user is created.
2089
+ */
2090
+ after?: (user: User & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2091
+ };
2092
+ update?: {
2093
+ /**
2094
+ * Hook that is called before a user is updated.
2095
+ * if the hook returns false, the user will not be updated.
2096
+ * If the hook returns an object, it'll be used instead of the original data
2097
+ */
2098
+ before?: (user: Partial<User> & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void | {
2099
+ data: Optional<User & Record<string, any>>;
2100
+ }>;
2101
+ /**
2102
+ * Hook that is called after a user is updated.
2103
+ */
2104
+ after?: (user: User & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2105
+ };
2106
+ delete?: {
2107
+ /**
2108
+ * Hook that is called before a user is deleted.
2109
+ * if the hook returns false, the user will not be deleted.
2110
+ */
2111
+ before?: (user: User & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void>;
2112
+ /**
2113
+ * Hook that is called after a user is deleted.
2114
+ */
2115
+ after?: (user: User & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2116
+ };
2117
+ };
2118
+ /**
2119
+ * Session Hook
2120
+ */
2121
+ session?: {
2122
+ create?: {
2123
+ /**
2124
+ * Hook that is called before a session is created.
2125
+ * if the hook returns false, the session will not be created.
2126
+ * If the hook returns an object, it'll be used instead of the original data
2127
+ */
2128
+ before?: (session: Session & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void | {
2129
+ data: Optional<Session> & Record<string, any>;
2130
+ }>;
2131
+ /**
2132
+ * Hook that is called after a session is created.
2133
+ */
2134
+ after?: (session: Session & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2135
+ };
2136
+ /**
2137
+ * Update hook
2138
+ */
2139
+ update?: {
2140
+ /**
2141
+ * Hook that is called before a user is updated.
2142
+ * if the hook returns false, the session will not be updated.
2143
+ * If the hook returns an object, it'll be used instead of the original data
2144
+ */
2145
+ before?: (session: Partial<Session> & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void | {
2146
+ data: Optional<Session & Record<string, any>>;
2147
+ }>;
2148
+ /**
2149
+ * Hook that is called after a session is updated.
2150
+ */
2151
+ after?: (session: Session & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2152
+ };
2153
+ delete?: {
2154
+ /**
2155
+ * Hook that is called before a session is deleted.
2156
+ * if the hook returns false, the session will not be deleted.
2157
+ */
2158
+ before?: (session: Session & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void>;
2159
+ /**
2160
+ * Hook that is called after a session is deleted.
2161
+ */
2162
+ after?: (session: Session & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2163
+ };
2164
+ };
2165
+ /**
2166
+ * Account Hook
2167
+ */
2168
+ account?: {
2169
+ create?: {
2170
+ /**
2171
+ * Hook that is called before a account is created.
2172
+ * If the hook returns false, the account will not be created.
2173
+ * If the hook returns an object, it'll be used instead of the original data
2174
+ */
2175
+ before?: (account: Account, context?: GenericEndpointContext) => Promise<boolean | void | {
2176
+ data: Optional<Account> & Record<string, any>;
2177
+ }>;
2178
+ /**
2179
+ * Hook that is called after a account is created.
2180
+ */
2181
+ after?: (account: Account, context?: GenericEndpointContext) => Promise<void>;
2182
+ };
2183
+ /**
2184
+ * Update hook
2185
+ */
2186
+ update?: {
2187
+ /**
2188
+ * Hook that is called before a account is update.
2189
+ * If the hook returns false, the user will not be updated.
2190
+ * If the hook returns an object, it'll be used instead of the original data
2191
+ */
2192
+ before?: (account: Partial<Account> & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void | {
2193
+ data: Optional<Account & Record<string, any>>;
2194
+ }>;
2195
+ /**
2196
+ * Hook that is called after a account is updated.
2197
+ */
2198
+ after?: (account: Account & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2199
+ };
2200
+ delete?: {
2201
+ /**
2202
+ * Hook that is called before an account is deleted.
2203
+ * if the hook returns false, the account will not be deleted.
2204
+ */
2205
+ before?: (account: Account & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void>;
2206
+ /**
2207
+ * Hook that is called after an account is deleted.
2208
+ */
2209
+ after?: (account: Account & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2210
+ };
2211
+ };
2212
+ /**
2213
+ * Verification Hook
2214
+ */
2215
+ verification?: {
2216
+ create?: {
2217
+ /**
2218
+ * Hook that is called before a verification is created.
2219
+ * if the hook returns false, the verification will not be created.
2220
+ * If the hook returns an object, it'll be used instead of the original data
2221
+ */
2222
+ before?: (verification: Verification & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void | {
2223
+ data: Optional<Verification> & Record<string, any>;
2224
+ }>;
2225
+ /**
2226
+ * Hook that is called after a verification is created.
2227
+ */
2228
+ after?: (verification: Verification & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2229
+ };
2230
+ update?: {
2231
+ /**
2232
+ * Hook that is called before a verification is updated.
2233
+ * if the hook returns false, the verification will not be updated.
2234
+ * If the hook returns an object, it'll be used instead of the original data
2235
+ */
2236
+ before?: (verification: Partial<Verification> & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void | {
2237
+ data: Optional<Verification & Record<string, any>>;
2238
+ }>;
2239
+ /**
2240
+ * Hook that is called after a verification is updated.
2241
+ */
2242
+ after?: (verification: Verification & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2243
+ };
2244
+ delete?: {
2245
+ /**
2246
+ * Hook that is called before a verification is deleted.
2247
+ * if the hook returns false, the verification will not be deleted.
2248
+ */
2249
+ before?: (verification: Verification & Record<string, unknown>, context?: GenericEndpointContext) => Promise<boolean | void>;
2250
+ /**
2251
+ * Hook that is called after a verification is deleted.
2252
+ */
2253
+ after?: (verification: Verification & Record<string, unknown>, context?: GenericEndpointContext) => Promise<void>;
2254
+ };
2255
+ };
2256
+ } | undefined;
2257
+ /**
2258
+ * API error handling
2259
+ */
2260
+ onAPIError?: {
2261
+ /**
2262
+ * Throw an error on API error
2263
+ *
2264
+ * @default false
2265
+ */
2266
+ throw?: boolean;
2267
+ /**
2268
+ * Custom error handler
2269
+ *
2270
+ * @param error
2271
+ * @param ctx - Auth context
2272
+ */
2273
+ onError?: (error: unknown, ctx: AuthContext) => void | Promise<void>;
2274
+ /**
2275
+ * The URL to redirect to on error
2276
+ *
2277
+ * When errorURL is provided, the error will be added to the URL as a query parameter
2278
+ * and the user will be redirected to the errorURL.
2279
+ *
2280
+ * @default - "/api/auth/error"
2281
+ */
2282
+ errorURL?: string;
2283
+ /**
2284
+ * Configure the default error page provided by Payvo-Auth
2285
+ * Start your dev server and go to /api/auth/error to see the error page.
2286
+ */
2287
+ customizeDefaultErrorPage?: {
2288
+ colors?: {
2289
+ background?: string;
2290
+ foreground?: string;
2291
+ primary?: string;
2292
+ primaryForeground?: string;
2293
+ mutedForeground?: string;
2294
+ border?: string;
2295
+ destructive?: string;
2296
+ titleBorder?: string;
2297
+ titleColor?: string;
2298
+ gridColor?: string;
2299
+ cardBackground?: string;
2300
+ cornerBorder?: string;
2301
+ };
2302
+ size?: {
2303
+ radiusSm?: string;
2304
+ radiusMd?: string;
2305
+ radiusLg?: string;
2306
+ textSm?: string;
2307
+ text2xl?: string;
2308
+ text4xl?: string;
2309
+ text6xl?: string;
2310
+ };
2311
+ font?: {
2312
+ defaultFamily?: string;
2313
+ monoFamily?: string;
2314
+ };
2315
+ disableTitleBorder?: boolean;
2316
+ disableCornerDecorations?: boolean;
2317
+ disableBackgroundGrid?: boolean;
2318
+ };
2319
+ } | undefined;
2320
+ /**
2321
+ * Hooks
2322
+ */
2323
+ hooks?: {
2324
+ /**
2325
+ * Before a request is processed
2326
+ */
2327
+ before?: AuthMiddleware;
2328
+ /**
2329
+ * After a request is processed
2330
+ */
2331
+ after?: AuthMiddleware;
2332
+ } | undefined;
2333
+ /**
2334
+ * Disabled paths
2335
+ *
2336
+ * Paths you want to disable.
2337
+ */
2338
+ disabledPaths?: string[] | undefined;
2339
+ /**
2340
+ * Telemetry configuration
2341
+ */
2342
+ telemetry?: {
2343
+ /**
2344
+ * Enable telemetry collection
2345
+ *
2346
+ * @default false
2347
+ */
2348
+ enabled?: boolean;
2349
+ /**
2350
+ * Enable debug mode
2351
+ *
2352
+ * @default false
2353
+ */
2354
+ debug?: boolean;
2355
+ } | undefined;
2356
+ };
2357
+ //#endregion
2358
+ //#region src/types/context.d.ts
2359
+ type GenericEndpointContext<Options extends PayvoAuthOptions = PayvoAuthOptions> = EndpointContext<string, any> & {
2360
+ context: AuthContext<Options>;
2361
+ };
2362
+ interface InternalAdapter<Options extends PayvoAuthOptions = PayvoAuthOptions> {
2363
+ createOAuthUser(user: Omit<User, "id" | "createdAt" | "updatedAt">, account: Omit<Account, "userId" | "id" | "createdAt" | "updatedAt"> & Partial<Account>): Promise<{
2364
+ user: User;
2365
+ account: Account;
2366
+ }>;
2367
+ createUser<T extends Record<string, any>>(user: Omit<User, "id" | "createdAt" | "updatedAt" | "emailVerified"> & Partial<User> & Record<string, any>): Promise<T & User>;
2368
+ createAccount<T extends Record<string, any>>(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account> & T): Promise<T & Account>;
2369
+ listSessions(userId: string): Promise<Session[]>;
2370
+ listUsers(limit?: number | undefined, offset?: number | undefined, sortBy?: {
2371
+ field: string;
2372
+ direction: "asc" | "desc";
2373
+ } | undefined, where?: Where[] | undefined): Promise<User[]>;
2374
+ countTotalUsers(where?: Where[] | undefined): Promise<number>;
2375
+ deleteUser(userId: string): Promise<void>;
2376
+ createSession(userId: string, dontRememberMe?: boolean | undefined, override?: (Partial<Session> & Record<string, any>) | undefined, overrideAll?: boolean | undefined): Promise<Session>;
2377
+ findSession(token: string): Promise<{
2378
+ session: Session & Record<string, any>;
2379
+ user: User & Record<string, any>;
2380
+ } | null>;
2381
+ findSessions(sessionTokens: string[]): Promise<{
2382
+ session: Session;
2383
+ user: User;
2384
+ }[]>;
2385
+ updateSession(sessionToken: string, session: Partial<Session> & Record<string, any>): Promise<Session | null>;
2386
+ deleteSession(token: string): Promise<void>;
2387
+ deleteAccounts(userId: string): Promise<void>;
2388
+ deleteAccount(accountId: string): Promise<void>;
2389
+ deleteSessions(userIdOrSessionTokens: string | string[]): Promise<void>;
2390
+ findOAuthUser(email: string, accountId: string, providerId: string): Promise<{
2391
+ user: User;
2392
+ accounts: Account[];
2393
+ } | null>;
2394
+ findUserByEmail(email: string, options?: {
2395
+ includeAccounts: boolean;
2396
+ } | undefined): Promise<{
2397
+ user: User;
2398
+ accounts: Account[];
2399
+ } | null>;
2400
+ findUserById(userId: string): Promise<User | null>;
2401
+ linkAccount(account: Omit<Account, "id" | "createdAt" | "updatedAt"> & Partial<Account>): Promise<Account>;
2402
+ updateUser(userId: string, data: Partial<User> & Record<string, any>): Promise<any>;
2403
+ updateUserByEmail(email: string, data: Partial<User & Record<string, any>>): Promise<User>;
2404
+ updatePassword(userId: string, password: string): Promise<void>;
2405
+ findAccounts(userId: string): Promise<Account[]>;
2406
+ findAccount(accountId: string): Promise<Account | null>;
2407
+ findAccountByProviderId(accountId: string, providerId: string): Promise<Account | null>;
2408
+ findAccountByUserId(userId: string): Promise<Account[]>;
2409
+ updateAccount(id: string, data: Partial<Account>): Promise<Account>;
2410
+ createVerificationValue(data: Omit<Verification, "createdAt" | "id" | "updatedAt"> & Partial<Verification>): Promise<Verification>;
2411
+ findVerificationValue(identifier: string): Promise<Verification | null>;
2412
+ deleteVerificationValue(id: string): Promise<void>;
2413
+ deleteVerificationByIdentifier(identifier: string): Promise<void>;
2414
+ updateVerificationValue(id: string, data: Partial<Verification>): Promise<Verification>;
2415
+ }
2416
+ type CreateCookieGetterFn = (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => {
2417
+ name: string;
2418
+ attributes: CookieOptions;
2419
+ };
2420
+ type CheckPasswordFn<Options extends PayvoAuthOptions = PayvoAuthOptions> = (userId: string, ctx: GenericEndpointContext<Options>) => Promise<boolean>;
2421
+ type AuthContext<Options extends PayvoAuthOptions = PayvoAuthOptions> = {
2422
+ options: Options;
2423
+ appName: string;
2424
+ baseURL: string;
2425
+ trustedOrigins: string[];
2426
+ oauthConfig: {
2427
+ /**
2428
+ * This is dangerous and should only be used in dev or staging environments.
2429
+ */
2430
+ skipStateCookieCheck?: boolean | undefined;
2431
+ /**
2432
+ * Strategy for storing OAuth state
2433
+ *
2434
+ * - "cookie": Store state in an encrypted cookie (stateless)
2435
+ * - "database": Store state in the database
2436
+ *
2437
+ * @default "cookie"
2438
+ */
2439
+ storeStateStrategy: "database" | "cookie";
2440
+ };
2441
+ /**
2442
+ * New session that will be set after the request
2443
+ * meaning: there is a `set-cookie` header that will set
2444
+ * the session cookie. This is the fetched session. And it's set
2445
+ * by `setNewSession` method.
2446
+ */
2447
+ newSession: {
2448
+ session: Session & Record<string, any>;
2449
+ user: User & Record<string, any>;
2450
+ } | null;
2451
+ session: {
2452
+ session: Session & Record<string, any>;
2453
+ user: User & Record<string, any>;
2454
+ } | null;
2455
+ setNewSession: (session: {
2456
+ session: Session & Record<string, any>;
2457
+ user: User & Record<string, any>;
2458
+ } | null) => void;
2459
+ socialProviders: OAuthProvider[];
2460
+ authCookies: PayvoAuthCookies;
2461
+ logger: ReturnType<typeof createLogger>;
2462
+ rateLimit: {
2463
+ enabled: boolean;
2464
+ window: number;
2465
+ max: number;
2466
+ storage: "memory" | "database" | "secondary-storage";
2467
+ } & PayvoAuthRateLimitOptions;
2468
+ adapter: DBAdapter<Options>;
2469
+ internalAdapter: InternalAdapter<Options>;
2470
+ createAuthCookie: CreateCookieGetterFn;
2471
+ secret: string;
2472
+ sessionConfig: {
2473
+ updateAge: number;
2474
+ expiresIn: number;
2475
+ freshAge: number;
2476
+ cookieRefreshCache: false | {
2477
+ enabled: true;
2478
+ updateAge: number;
2479
+ };
2480
+ };
2481
+ generateId: (options: {
2482
+ model: LiteralUnion<DBPreservedModels, string>;
2483
+ size?: number | undefined;
2484
+ }) => string | false;
2485
+ secondaryStorage: SecondaryStorage | undefined;
2486
+ password: {
2487
+ hash: (password: string) => Promise<string>;
2488
+ verify: (data: {
2489
+ password: string;
2490
+ hash: string;
2491
+ }) => Promise<boolean>;
2492
+ config: {
2493
+ minPasswordLength: number;
2494
+ maxPasswordLength: number;
2495
+ };
2496
+ checkPassword: CheckPasswordFn<Options>;
2497
+ };
2498
+ tables: PayvoAuthDBSchema;
2499
+ runMigrations: () => Promise<void>;
2500
+ publishTelemetry: (event: {
2501
+ type: string;
2502
+ anonymousId?: string | undefined;
2503
+ payload: Record<string, any>;
2504
+ }) => Promise<void>;
2505
+ /**
2506
+ * This skips the origin check for all requests.
2507
+ *
2508
+ * set to true by default for `test` environments and `false`
2509
+ * for other environments.
2510
+ *
2511
+ * It's inferred from the `options.advanced?.disableCSRFCheck`
2512
+ * option or `options.advanced?.disableOriginCheck` option.
2513
+ *
2514
+ * @default false
2515
+ */
2516
+ skipOriginCheck: boolean;
2517
+ /**
2518
+ * This skips the CSRF check for all requests.
2519
+ *
2520
+ * This is inferred from the `options.advanced?.
2521
+ * disableCSRFCheck` option.
2522
+ *
2523
+ * @default false
2524
+ */
2525
+ skipCSRFCheck: boolean;
2526
+ };
2527
+ //#endregion
2528
+ //#region src/types/plugin-client.d.ts
2529
+
2530
+ declare const createAuthMiddleware: {
2531
+ <Options extends better_call0.MiddlewareOptions, R>(options: Options, handler: (ctx: better_call0.MiddlewareContext<Options, AuthContext & {
2532
+ returned?: unknown | undefined;
2533
+ responseHeaders?: Headers | undefined;
2534
+ }>) => Promise<R>): (inputContext: better_call0.MiddlewareInputContext<Options>) => Promise<R>;
2535
+ <Options extends better_call0.MiddlewareOptions, R_1>(handler: (ctx: better_call0.MiddlewareContext<Options, AuthContext & {
2536
+ returned?: unknown | undefined;
2537
+ responseHeaders?: Headers | undefined;
2538
+ }>) => Promise<R_1>): (inputContext: better_call0.MiddlewareInputContext<Options>) => Promise<R_1>;
2539
+ };
2540
+ type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;
2541
+ //#endregion
2542
+ //#endregion
2543
+ export { OAuth2UserInfo as a, OAuth2Tokens as i, DBPrimitive as n, Session as o, GenericEndpointContext as r, User as s, DBAdapter as t };