payload-auth 1.0.1 → 1.0.2

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 (328) hide show
  1. package/dist/authjs/index.d.ts +1 -0
  2. package/dist/authjs/index.d.ts.map +1 -0
  3. package/dist/authjs/index.js +1 -1
  4. package/dist/better-auth/adapter/dev/bin/run.d.ts +1 -0
  5. package/dist/better-auth/adapter/dev/bin/run.d.ts.map +1 -0
  6. package/dist/better-auth/adapter/dev/bin/run.js +1 -1
  7. package/dist/better-auth/adapter/dev/bin/schema.d.ts +1 -0
  8. package/dist/better-auth/adapter/dev/bin/schema.d.ts.map +1 -0
  9. package/dist/better-auth/adapter/dev/bin/schema.js +1 -1
  10. package/dist/better-auth/adapter/dev/collections.d.ts +1 -0
  11. package/dist/better-auth/adapter/dev/collections.d.ts.map +1 -0
  12. package/dist/better-auth/adapter/dev/collections.js +1 -1
  13. package/dist/better-auth/adapter/dev/index.d.ts +1 -0
  14. package/dist/better-auth/adapter/dev/index.d.ts.map +1 -0
  15. package/dist/better-auth/adapter/dev/index.js +1 -1
  16. package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +1 -0
  17. package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts.map +1 -0
  18. package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +1 -1
  19. package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +1 -0
  20. package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts.map +1 -0
  21. package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +1 -1
  22. package/dist/better-auth/adapter/generate-schema/index.d.ts +1 -0
  23. package/dist/better-auth/adapter/generate-schema/index.d.ts.map +1 -0
  24. package/dist/better-auth/adapter/generate-schema/index.js +3 -3
  25. package/dist/better-auth/adapter/generate-schema/utils.d.ts +1 -0
  26. package/dist/better-auth/adapter/generate-schema/utils.d.ts.map +1 -0
  27. package/dist/better-auth/adapter/generate-schema/utils.js +1 -1
  28. package/dist/better-auth/adapter/index.d.ts +1 -0
  29. package/dist/better-auth/adapter/index.d.ts.map +1 -0
  30. package/dist/better-auth/adapter/index.js +1 -1
  31. package/dist/better-auth/adapter/test/adapter.test.d.ts +1 -0
  32. package/dist/better-auth/adapter/test/adapter.test.d.ts.map +1 -0
  33. package/dist/better-auth/adapter/test/adapter.test.js +1 -1
  34. package/dist/better-auth/adapter/test/better-auth-adapter-test.d.ts +1 -0
  35. package/dist/better-auth/adapter/test/better-auth-adapter-test.d.ts.map +1 -0
  36. package/dist/better-auth/adapter/test/better-auth-adapter-test.js +1 -1
  37. package/dist/better-auth/adapter/test/schema.test.d.ts +1 -0
  38. package/dist/better-auth/adapter/test/schema.test.d.ts.map +1 -0
  39. package/dist/better-auth/adapter/test/schema.test.js +1 -1
  40. package/dist/better-auth/adapter/test/test_payload1/schema.d.ts +1 -0
  41. package/dist/better-auth/adapter/test/test_payload1/schema.d.ts.map +1 -0
  42. package/dist/better-auth/adapter/test/test_payload1/schema.js +1 -1
  43. package/dist/better-auth/adapter/test/test_payload2/schema.d.ts +1 -0
  44. package/dist/better-auth/adapter/test/test_payload2/schema.d.ts.map +1 -0
  45. package/dist/better-auth/adapter/test/test_payload2/schema.js +1 -1
  46. package/dist/better-auth/adapter/test/test_payload3/schema.d.ts +1 -0
  47. package/dist/better-auth/adapter/test/test_payload3/schema.d.ts.map +1 -0
  48. package/dist/better-auth/adapter/test/test_payload3/schema.js +1 -1
  49. package/dist/better-auth/adapter/transform/index.d.ts +5 -4
  50. package/dist/better-auth/adapter/transform/index.d.ts.map +1 -0
  51. package/dist/better-auth/adapter/transform/index.js +1 -1
  52. package/dist/better-auth/adapter/types.d.ts +1 -0
  53. package/dist/better-auth/adapter/types.d.ts.map +1 -0
  54. package/dist/better-auth/adapter/types.js +1 -1
  55. package/dist/better-auth/index.d.ts +1 -0
  56. package/dist/better-auth/index.d.ts.map +1 -0
  57. package/dist/better-auth/index.js +1 -1
  58. package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.d.ts +1 -0
  59. package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.d.ts.map +1 -0
  60. package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js +1 -1
  61. package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.d.ts +1 -0
  62. package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.d.ts.map +1 -0
  63. package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js +1 -1
  64. package/dist/better-auth/plugin/collections/users/hooks/after-login.d.ts +1 -0
  65. package/dist/better-auth/plugin/collections/users/hooks/after-login.d.ts.map +1 -0
  66. package/dist/better-auth/plugin/collections/users/hooks/after-login.js +1 -1
  67. package/dist/better-auth/plugin/collections/users/hooks/after-logout.d.ts +1 -0
  68. package/dist/better-auth/plugin/collections/users/hooks/after-logout.d.ts.map +1 -0
  69. package/dist/better-auth/plugin/collections/users/hooks/after-logout.js +1 -1
  70. package/dist/better-auth/plugin/collections/users/hooks/before-login.d.ts +1 -0
  71. package/dist/better-auth/plugin/collections/users/hooks/before-login.d.ts.map +1 -0
  72. package/dist/better-auth/plugin/collections/users/hooks/before-login.js +1 -1
  73. package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.d.ts +1 -0
  74. package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.d.ts.map +1 -0
  75. package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js +1 -1
  76. package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.d.ts +1 -0
  77. package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.d.ts.map +1 -0
  78. package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js +1 -1
  79. package/dist/better-auth/plugin/collections/users/hooks/sync-account.d.ts +1 -0
  80. package/dist/better-auth/plugin/collections/users/hooks/sync-account.d.ts.map +1 -0
  81. package/dist/better-auth/plugin/collections/users/hooks/sync-account.js +2 -2
  82. package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +1 -0
  83. package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts.map +1 -0
  84. package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +1 -1
  85. package/dist/better-auth/plugin/helpers/get-ip.d.ts +1 -0
  86. package/dist/better-auth/plugin/helpers/get-ip.d.ts.map +1 -0
  87. package/dist/better-auth/plugin/helpers/get-ip.js +1 -1
  88. package/dist/better-auth/plugin/helpers/index.d.ts +1 -0
  89. package/dist/better-auth/plugin/helpers/index.d.ts.map +1 -0
  90. package/dist/better-auth/plugin/helpers/index.js +1 -1
  91. package/dist/better-auth/plugin/helpers/serialize-cookie.d.ts +3 -2
  92. package/dist/better-auth/plugin/helpers/serialize-cookie.d.ts.map +1 -0
  93. package/dist/better-auth/plugin/helpers/serialize-cookie.js +1 -1
  94. package/dist/better-auth/plugin/index.d.ts +1 -0
  95. package/dist/better-auth/plugin/index.d.ts.map +1 -0
  96. package/dist/better-auth/plugin/index.js +1 -1
  97. package/dist/better-auth/plugin/lib/auth-strategy.d.ts +1 -0
  98. package/dist/better-auth/plugin/lib/auth-strategy.d.ts.map +1 -0
  99. package/dist/better-auth/plugin/lib/auth-strategy.js +1 -1
  100. package/dist/better-auth/plugin/lib/build-collection-configs.d.ts +1 -0
  101. package/dist/better-auth/plugin/lib/build-collection-configs.d.ts.map +1 -0
  102. package/dist/better-auth/plugin/lib/build-collection-configs.js +1 -1
  103. package/dist/better-auth/plugin/lib/config.d.ts +2 -0
  104. package/dist/better-auth/plugin/lib/config.d.ts.map +1 -0
  105. package/dist/better-auth/plugin/lib/config.js +3 -2
  106. package/dist/better-auth/plugin/lib/ensure-password-set-before-create.d.ts +1 -0
  107. package/dist/better-auth/plugin/lib/ensure-password-set-before-create.d.ts.map +1 -0
  108. package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js +1 -1
  109. package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +1 -0
  110. package/dist/better-auth/plugin/lib/get-payload-auth.d.ts.map +1 -0
  111. package/dist/better-auth/plugin/lib/get-payload-auth.js +1 -1
  112. package/dist/better-auth/plugin/lib/get-required-collection-slugs.d.ts +1 -0
  113. package/dist/better-auth/plugin/lib/get-required-collection-slugs.d.ts.map +1 -0
  114. package/dist/better-auth/plugin/lib/get-required-collection-slugs.js +1 -1
  115. package/dist/better-auth/plugin/lib/init-better-auth.d.ts +1 -0
  116. package/dist/better-auth/plugin/lib/init-better-auth.d.ts.map +1 -0
  117. package/dist/better-auth/plugin/lib/init-better-auth.js +2 -2
  118. package/dist/better-auth/plugin/lib/password.d.ts +1 -0
  119. package/dist/better-auth/plugin/lib/password.d.ts.map +1 -0
  120. package/dist/better-auth/plugin/lib/password.js +1 -1
  121. package/dist/better-auth/plugin/lib/payload-access.d.ts +1 -0
  122. package/dist/better-auth/plugin/lib/payload-access.d.ts.map +1 -0
  123. package/dist/better-auth/plugin/lib/payload-access.js +1 -1
  124. package/dist/better-auth/plugin/lib/prepare-session-data.d.ts +2 -1
  125. package/dist/better-auth/plugin/lib/prepare-session-data.d.ts.map +1 -0
  126. package/dist/better-auth/plugin/lib/prepare-session-data.js +1 -1
  127. package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.d.ts +1 -0
  128. package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.d.ts.map +1 -0
  129. package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js +1 -1
  130. package/dist/better-auth/plugin/lib/sanitize-auth-options.d.ts +1 -0
  131. package/dist/better-auth/plugin/lib/sanitize-auth-options.d.ts.map +1 -0
  132. package/dist/better-auth/plugin/lib/sanitize-auth-options.js +1 -1
  133. package/dist/better-auth/plugin/payload/components/admin-buttons.d.ts +3 -1
  134. package/dist/better-auth/plugin/payload/components/admin-buttons.d.ts.map +1 -0
  135. package/dist/better-auth/plugin/payload/components/admin-buttons.js +3 -6
  136. package/dist/better-auth/plugin/payload/components/login-redirect.d.ts +1 -0
  137. package/dist/better-auth/plugin/payload/components/login-redirect.d.ts.map +1 -0
  138. package/dist/better-auth/plugin/payload/components/login-redirect.js +1 -1
  139. package/dist/better-auth/plugin/payload/components/logo.d.ts +3 -1
  140. package/dist/better-auth/plugin/payload/components/logo.d.ts.map +1 -0
  141. package/dist/better-auth/plugin/payload/components/logo.js +1 -1
  142. package/dist/better-auth/plugin/payload/components/logout.d.ts +3 -1
  143. package/dist/better-auth/plugin/payload/components/logout.d.ts.map +1 -0
  144. package/dist/better-auth/plugin/payload/components/logout.js +1 -1
  145. package/dist/better-auth/plugin/payload/components/sign-in.d.ts +2 -1
  146. package/dist/better-auth/plugin/payload/components/sign-in.d.ts.map +1 -0
  147. package/dist/better-auth/plugin/payload/components/sign-in.js +1 -1
  148. package/dist/better-auth/plugin/payload/components/sign-up.d.ts +2 -1
  149. package/dist/better-auth/plugin/payload/components/sign-up.d.ts.map +1 -0
  150. package/dist/better-auth/plugin/payload/components/sign-up.js +2 -1
  151. package/dist/better-auth/plugin/payload/components/ui/button.d.ts +6 -5
  152. package/dist/better-auth/plugin/payload/components/ui/button.d.ts.map +1 -0
  153. package/dist/better-auth/plugin/payload/components/ui/button.js +1 -1
  154. package/dist/better-auth/plugin/payload/components/ui/card.d.ts +8 -7
  155. package/dist/better-auth/plugin/payload/components/ui/card.d.ts.map +1 -0
  156. package/dist/better-auth/plugin/payload/components/ui/card.js +1 -1
  157. package/dist/better-auth/plugin/payload/components/ui/checkbox.d.ts +2 -1
  158. package/dist/better-auth/plugin/payload/components/ui/checkbox.d.ts.map +1 -0
  159. package/dist/better-auth/plugin/payload/components/ui/checkbox.js +1 -1
  160. package/dist/better-auth/plugin/payload/components/ui/cn.d.ts +1 -0
  161. package/dist/better-auth/plugin/payload/components/ui/cn.d.ts.map +1 -0
  162. package/dist/better-auth/plugin/payload/components/ui/cn.js +1 -1
  163. package/dist/better-auth/plugin/payload/components/ui/input.d.ts +2 -1
  164. package/dist/better-auth/plugin/payload/components/ui/input.d.ts.map +1 -0
  165. package/dist/better-auth/plugin/payload/components/ui/input.js +1 -1
  166. package/dist/better-auth/plugin/payload/components/ui/label.d.ts +2 -1
  167. package/dist/better-auth/plugin/payload/components/ui/label.d.ts.map +1 -0
  168. package/dist/better-auth/plugin/payload/components/ui/label.js +1 -1
  169. package/dist/better-auth/plugin/payload/components/ui/password-input.d.ts +2 -1
  170. package/dist/better-auth/plugin/payload/components/ui/password-input.d.ts.map +1 -0
  171. package/dist/better-auth/plugin/payload/components/ui/password-input.js +1 -1
  172. package/dist/better-auth/plugin/payload/exports/client.d.ts +1 -0
  173. package/dist/better-auth/plugin/payload/exports/client.d.ts.map +1 -0
  174. package/dist/better-auth/plugin/payload/exports/client.js +1 -1
  175. package/dist/better-auth/plugin/payload/exports/rsc.d.ts +1 -0
  176. package/dist/better-auth/plugin/payload/exports/rsc.d.ts.map +1 -0
  177. package/dist/better-auth/plugin/payload/exports/rsc.js +1 -1
  178. package/dist/better-auth/plugin/payload/views/create-first-admin/index.d.ts +3 -1
  179. package/dist/better-auth/plugin/payload/views/create-first-admin/index.d.ts.map +1 -0
  180. package/dist/better-auth/plugin/payload/views/create-first-admin/index.js +1 -1
  181. package/dist/better-auth/plugin/payload/views/login/index.d.ts +3 -1
  182. package/dist/better-auth/plugin/payload/views/login/index.d.ts.map +1 -0
  183. package/dist/better-auth/plugin/payload/views/login/index.js +1 -1
  184. package/dist/better-auth/plugin/types.d.ts +1 -0
  185. package/dist/better-auth/plugin/types.d.ts.map +1 -0
  186. package/dist/better-auth/plugin/types.js +1 -1
  187. package/dist/better-auth/types.d.ts +1 -0
  188. package/dist/better-auth/types.d.ts.map +1 -0
  189. package/dist/better-auth/types.js +1 -1
  190. package/dist/clerk/admin-ui.d.ts +4 -0
  191. package/dist/clerk/admin-ui.d.ts.map +1 -0
  192. package/dist/clerk/admin-ui.js +5 -0
  193. package/dist/clerk/index.d.ts +7 -1
  194. package/dist/clerk/index.d.ts.map +1 -0
  195. package/dist/clerk/index.js +7 -2
  196. package/dist/clerk/plugin/auth-strategy.d.ts +11 -0
  197. package/dist/clerk/plugin/auth-strategy.d.ts.map +1 -0
  198. package/dist/clerk/plugin/auth-strategy.js +45 -0
  199. package/dist/clerk/plugin/collections/users/access.d.ts +14 -0
  200. package/dist/clerk/plugin/collections/users/access.d.ts.map +1 -0
  201. package/dist/clerk/plugin/collections/users/access.js +36 -0
  202. package/dist/clerk/plugin/collections/users/endpoints/sync-from-clerk.d.ts +14 -0
  203. package/dist/clerk/plugin/collections/users/endpoints/sync-from-clerk.d.ts.map +1 -0
  204. package/dist/clerk/plugin/collections/users/endpoints/sync-from-clerk.js +108 -0
  205. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/index.d.ts +4 -0
  206. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/index.d.ts.map +1 -0
  207. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/index.js +5 -0
  208. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userCreated.d.ts +13 -0
  209. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userCreated.d.ts.map +1 -0
  210. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userCreated.js +33 -0
  211. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userDeleted.d.ts +11 -0
  212. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userDeleted.d.ts.map +1 -0
  213. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userDeleted.js +27 -0
  214. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userUpdated.d.ts +13 -0
  215. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userUpdated.d.ts.map +1 -0
  216. package/dist/clerk/plugin/collections/users/endpoints/webhook/handlers/userUpdated.js +35 -0
  217. package/dist/clerk/plugin/collections/users/endpoints/webhook/index.d.ts +12 -0
  218. package/dist/clerk/plugin/collections/users/endpoints/webhook/index.d.ts.map +1 -0
  219. package/dist/clerk/plugin/collections/users/endpoints/webhook/index.js +86 -0
  220. package/dist/clerk/plugin/collections/users/fields.d.ts +6 -0
  221. package/dist/clerk/plugin/collections/users/fields.d.ts.map +1 -0
  222. package/dist/clerk/plugin/collections/users/fields.js +81 -0
  223. package/dist/clerk/plugin/collections/users/index.d.ts +10 -0
  224. package/dist/clerk/plugin/collections/users/index.d.ts.map +1 -0
  225. package/dist/clerk/plugin/collections/users/index.js +95 -0
  226. package/dist/clerk/plugin/components/after-login-form.d.ts +4 -0
  227. package/dist/clerk/plugin/components/after-login-form.d.ts.map +1 -0
  228. package/dist/clerk/plugin/components/after-login-form.js +65 -0
  229. package/dist/clerk/plugin/components/logout-button.d.ts +2 -0
  230. package/dist/clerk/plugin/components/logout-button.d.ts.map +1 -0
  231. package/dist/clerk/plugin/components/logout-button.js +49 -0
  232. package/dist/clerk/plugin/components/sync-clerk-users-button.d.ts +6 -0
  233. package/dist/clerk/plugin/components/sync-clerk-users-button.d.ts.map +1 -0
  234. package/dist/clerk/plugin/components/sync-clerk-users-button.js +75 -0
  235. package/dist/clerk/plugin.d.ts +6 -0
  236. package/dist/clerk/plugin.d.ts.map +1 -0
  237. package/dist/clerk/plugin.js +63 -0
  238. package/dist/clerk/types.d.ts +63 -0
  239. package/dist/clerk/types.d.ts.map +1 -0
  240. package/dist/clerk/types.js +3 -0
  241. package/dist/clerk/utils/clerk-user.d.ts +24 -0
  242. package/dist/clerk/utils/clerk-user.d.ts.map +1 -0
  243. package/dist/clerk/utils/clerk-user.js +47 -0
  244. package/dist/clerk/utils/index.d.ts +4 -0
  245. package/dist/clerk/utils/index.d.ts.map +1 -0
  246. package/dist/clerk/utils/index.js +5 -0
  247. package/dist/clerk/utils/load-clerk-instance.d.ts +8 -0
  248. package/dist/clerk/utils/load-clerk-instance.d.ts.map +1 -0
  249. package/dist/clerk/utils/load-clerk-instance.js +11 -0
  250. package/dist/clerk/utils/svix.d.ts +9 -0
  251. package/dist/clerk/utils/svix.d.ts.map +1 -0
  252. package/dist/clerk/utils/svix.js +40 -0
  253. package/dist/clerk/utils/user.d.ts +17 -0
  254. package/dist/clerk/utils/user.d.ts.map +1 -0
  255. package/dist/clerk/utils/user.js +46 -0
  256. package/dist/index.d.ts +5 -0
  257. package/dist/index.d.ts.map +1 -0
  258. package/dist/index.js +5 -5
  259. package/dist/kinde/index.d.ts +1 -0
  260. package/dist/kinde/index.d.ts.map +1 -0
  261. package/dist/kinde/index.js +1 -1
  262. package/package.json +38 -12
  263. package/dist/authjs/index.js.map +0 -1
  264. package/dist/better-auth/adapter/dev/bin/run.js.map +0 -1
  265. package/dist/better-auth/adapter/dev/bin/schema.js.map +0 -1
  266. package/dist/better-auth/adapter/dev/collections.js.map +0 -1
  267. package/dist/better-auth/adapter/dev/index.js.map +0 -1
  268. package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +0 -1
  269. package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +0 -1
  270. package/dist/better-auth/adapter/generate-schema/index.js.map +0 -1
  271. package/dist/better-auth/adapter/generate-schema/utils.js.map +0 -1
  272. package/dist/better-auth/adapter/index.js.map +0 -1
  273. package/dist/better-auth/adapter/test/adapter.test.js.map +0 -1
  274. package/dist/better-auth/adapter/test/better-auth-adapter-test.js.map +0 -1
  275. package/dist/better-auth/adapter/test/schema.test.js.map +0 -1
  276. package/dist/better-auth/adapter/test/test_payload1/schema.js.map +0 -1
  277. package/dist/better-auth/adapter/test/test_payload2/schema.js.map +0 -1
  278. package/dist/better-auth/adapter/test/test_payload3/schema.js.map +0 -1
  279. package/dist/better-auth/adapter/transform/index.js.map +0 -1
  280. package/dist/better-auth/adapter/types.js.map +0 -1
  281. package/dist/better-auth/index.js.map +0 -1
  282. package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js.map +0 -1
  283. package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js.map +0 -1
  284. package/dist/better-auth/plugin/collections/users/hooks/after-login.js.map +0 -1
  285. package/dist/better-auth/plugin/collections/users/hooks/after-logout.js.map +0 -1
  286. package/dist/better-auth/plugin/collections/users/hooks/before-login.js.map +0 -1
  287. package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js.map +0 -1
  288. package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js.map +0 -1
  289. package/dist/better-auth/plugin/collections/users/hooks/sync-account.js.map +0 -1
  290. package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +0 -1
  291. package/dist/better-auth/plugin/helpers/get-ip.js.map +0 -1
  292. package/dist/better-auth/plugin/helpers/index.js.map +0 -1
  293. package/dist/better-auth/plugin/helpers/serialize-cookie.js.map +0 -1
  294. package/dist/better-auth/plugin/index.js.map +0 -1
  295. package/dist/better-auth/plugin/lib/auth-strategy.js.map +0 -1
  296. package/dist/better-auth/plugin/lib/build-collection-configs.js.map +0 -1
  297. package/dist/better-auth/plugin/lib/config.js.map +0 -1
  298. package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js.map +0 -1
  299. package/dist/better-auth/plugin/lib/get-payload-auth.js.map +0 -1
  300. package/dist/better-auth/plugin/lib/get-required-collection-slugs.js.map +0 -1
  301. package/dist/better-auth/plugin/lib/init-better-auth.js.map +0 -1
  302. package/dist/better-auth/plugin/lib/password.js.map +0 -1
  303. package/dist/better-auth/plugin/lib/payload-access.js.map +0 -1
  304. package/dist/better-auth/plugin/lib/prepare-session-data.js.map +0 -1
  305. package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js.map +0 -1
  306. package/dist/better-auth/plugin/lib/sanitize-auth-options.js.map +0 -1
  307. package/dist/better-auth/plugin/payload/components/admin-buttons.js.map +0 -1
  308. package/dist/better-auth/plugin/payload/components/login-redirect.js.map +0 -1
  309. package/dist/better-auth/plugin/payload/components/logo.js.map +0 -1
  310. package/dist/better-auth/plugin/payload/components/logout.js.map +0 -1
  311. package/dist/better-auth/plugin/payload/components/sign-in.js.map +0 -1
  312. package/dist/better-auth/plugin/payload/components/sign-up.js.map +0 -1
  313. package/dist/better-auth/plugin/payload/components/ui/button.js.map +0 -1
  314. package/dist/better-auth/plugin/payload/components/ui/card.js.map +0 -1
  315. package/dist/better-auth/plugin/payload/components/ui/checkbox.js.map +0 -1
  316. package/dist/better-auth/plugin/payload/components/ui/cn.js.map +0 -1
  317. package/dist/better-auth/plugin/payload/components/ui/input.js.map +0 -1
  318. package/dist/better-auth/plugin/payload/components/ui/label.js.map +0 -1
  319. package/dist/better-auth/plugin/payload/components/ui/password-input.js.map +0 -1
  320. package/dist/better-auth/plugin/payload/exports/client.js.map +0 -1
  321. package/dist/better-auth/plugin/payload/exports/rsc.js.map +0 -1
  322. package/dist/better-auth/plugin/payload/views/create-first-admin/index.js.map +0 -1
  323. package/dist/better-auth/plugin/payload/views/login/index.js.map +0 -1
  324. package/dist/better-auth/plugin/types.js.map +0 -1
  325. package/dist/better-auth/types.js.map +0 -1
  326. package/dist/clerk/index.js.map +0 -1
  327. package/dist/index.js.map +0 -1
  328. package/dist/kinde/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/plugin/collections/users/endpoints/refresh-token.ts"],"sourcesContent":["import { setCookieCache } from 'better-auth/cookies'\nimport { CollectionSlug, type Endpoint, getFieldsToSign, refreshOperation, User } from 'payload'\nimport { GenericEndpointContext } from 'better-auth/types'\nimport { EndpointWithBetterAuth } from '../../../types'\nimport { getPayloadAuth } from '../../../lib/get-payload-auth'\n\ntype RefreshTokenEndpointOptions = {\n userSlug: CollectionSlug\n}\n\nexport const getRefreshTokenEndpoint = (options?: RefreshTokenEndpointOptions): Endpoint => {\n const userSlug = options?.userSlug\n\n const endpoint: EndpointWithBetterAuth = {\n path: '/refresh-token',\n method: 'post',\n handler: async (req) => {\n const payload = await getPayloadAuth(req.payload.config)\n const betterAuth = payload.betterAuth\n const authContext = await betterAuth?.$context\n const userCollection = payload.collections[userSlug as CollectionSlug]\n\n if (!betterAuth || !authContext) {\n return new Response(JSON.stringify({ message: 'BetterAuth not initialized' }), {\n status: 500,\n })\n }\n\n const sessionTokenName = authContext.authCookies.sessionToken.name\n const cookieHeader = req.headers.get('cookie') || ''\n const hasSessionToken = cookieHeader.includes(`${sessionTokenName}=`)\n\n if (!hasSessionToken) {\n try {\n const result = await refreshOperation({ collection: userCollection, req })\n return new Response(JSON.stringify(result), { status: 200 })\n } catch (error) {\n console.error('Token refresh failed:', error)\n return new Response(JSON.stringify({ message: 'Token refresh failed' }), { status: 401 })\n }\n }\n\n // @ts-ignore - @TODO, fix type of .api\n const session = await betterAuth.api.getSession({\n headers: req.headers,\n query: { disableCookieCache: true },\n })\n\n if (!session?.session?.userId) {\n return new Response(JSON.stringify({ message: 'No user in session' }), { status: 401 })\n }\n\n const user = await payload.findByID({\n collection: userSlug as string,\n id: session.session.userId,\n })\n\n if (!user) {\n return new Response(JSON.stringify({ message: 'No user found' }), { status: 401 })\n }\n\n const cookieCacheFields = getFieldsToSign({\n collectionConfig: userCollection.config,\n email: user.email,\n user: user as User,\n })\n\n const responseData = {\n refreshedToken: null,\n setCookie: !!authContext.options.session?.cookieCache?.enabled,\n strategy: 'better-auth',\n user: { ...user, collection: userSlug },\n }\n\n const response = new Response(JSON.stringify(responseData), {\n status: 200,\n })\n\n const ctx = {\n context: authContext,\n setCookie(name, value, options) {\n const path = options?.path || '/'\n const maxAge = options?.maxAge ? `; Max-Age=${options.maxAge}` : ''\n const httpOnly = options?.httpOnly ? '; HttpOnly' : ''\n const secure = options?.secure ? '; Secure' : ''\n const sameSite = options?.sameSite ? `; SameSite=${options.sameSite}` : '; SameSite=Lax'\n\n response.headers.set(\n 'Set-Cookie',\n `${name}=${value}; Path=${path}${maxAge}${httpOnly}${secure}${sameSite}`,\n )\n return name\n },\n } as GenericEndpointContext\n\n await setCookieCache(ctx, {\n session: session.session,\n user: cookieCacheFields as any,\n })\n\n return response\n },\n }\n\n return endpoint as unknown as Endpoint\n}\n"],"names":["setCookieCache","getFieldsToSign","refreshOperation","getPayloadAuth","getRefreshTokenEndpoint","options","userSlug","endpoint","path","method","handler","req","payload","config","betterAuth","authContext","$context","userCollection","collections","Response","JSON","stringify","message","status","sessionTokenName","authCookies","sessionToken","name","cookieHeader","headers","get","hasSessionToken","includes","result","collection","error","console","session","api","getSession","query","disableCookieCache","userId","user","findByID","id","cookieCacheFields","collectionConfig","email","responseData","refreshedToken","setCookie","cookieCache","enabled","strategy","response","ctx","context","value","maxAge","httpOnly","secure","sameSite","set"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAqB;AACpD,SAAwCC,eAAe,EAAEC,gBAAgB,QAAc,UAAS;AAGhG,SAASC,cAAc,QAAQ,gCAA+B;AAM9D,OAAO,MAAMC,0BAA0B,CAACC;IACtC,MAAMC,WAAWD,SAASC;IAE1B,MAAMC,WAAmC;QACvCC,MAAM;QACNC,QAAQ;QACRC,SAAS,OAAOC;YACd,MAAMC,UAAU,MAAMT,eAAeQ,IAAIC,OAAO,CAACC,MAAM;YACvD,MAAMC,aAAaF,QAAQE,UAAU;YACrC,MAAMC,cAAc,MAAMD,YAAYE;YACtC,MAAMC,iBAAiBL,QAAQM,WAAW,CAACZ,SAA2B;YAEtE,IAAI,CAACQ,cAAc,CAACC,aAAa;gBAC/B,OAAO,IAAII,SAASC,KAAKC,SAAS,CAAC;oBAAEC,SAAS;gBAA6B,IAAI;oBAC7EC,QAAQ;gBACV;YACF;YAEA,MAAMC,mBAAmBT,YAAYU,WAAW,CAACC,YAAY,CAACC,IAAI;YAClE,MAAMC,eAAejB,IAAIkB,OAAO,CAACC,GAAG,CAAC,aAAa;YAClD,MAAMC,kBAAkBH,aAAaI,QAAQ,CAAC,GAAGR,iBAAiB,CAAC,CAAC;YAEpE,IAAI,CAACO,iBAAiB;gBACpB,IAAI;oBACF,MAAME,SAAS,MAAM/B,iBAAiB;wBAAEgC,YAAYjB;wBAAgBN;oBAAI;oBACxE,OAAO,IAAIQ,SAASC,KAAKC,SAAS,CAACY,SAAS;wBAAEV,QAAQ;oBAAI;gBAC5D,EAAE,OAAOY,OAAO;oBACdC,QAAQD,KAAK,CAAC,y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AAM,EAAE,GAAG;oBACjE,MAAMC,WAAWvD,SAASuD,WAAW,eAAe;oBACpD,MAAMC,SAASxD,SAASwD,SAAS,aAAa;oBAC9C,MAAMC,WAAWzD,SAASyD,WAAW,CAAC,WAAW,EAAEzD,QAAQyD,QAAQ,EAAE,GAAG;oBAExEP,SAAS1B,OAAO,CAACkC,GAAG,CAClB,cACA,GAAGpC,KAAK,CAAC,EAAE+B,MAAM,OAAO,EAAElD,OAAOmD,SAASC,WAAWC,SAASC,UAAU;oBAE1E,OAAOnC;gBACT;YACF;YAEA,MAAM3B,eAAewD,KAAK;gBACxBnB,SAASA,QAAQA,OAAO;gBACxBM,MAAMG;YACR;YAEA,OAAOS;QACT;IACF;IAEA,OAAOhD;AACT,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/plugin/collections/users/hooks/after-login.ts"],"sourcesContent":["import { generateId, Session } from 'better-auth'\nimport { createAuthMiddleware } from 'better-auth/api'\nimport { setCookieCache } from 'better-auth/cookies'\nimport { parseSetCookie, type ResponseCookie } from 'next/dist/compiled/@edge-runtime/cookies'\nimport { cookies } from 'next/headers'\nimport { CollectionAfterLoginHook } from 'payload'\nimport { getPayloadAuth } from '../../../lib/get-payload-auth'\nimport { getIp } from '../../../helpers/get-ip'\nimport { prepareSessionData } from '../../../lib/prepare-session-data'\n\ntype AfterLoginOptions = {\n usersCollectionSlug: string\n sessionsCollectionSlug: string\n}\n\n/**\n * This hook is used to sync the admin login token with better-auth session token\n * It also creates a new session in better-auth\n */\nexport const getAfterLoginHook = (options: AfterLoginOptions): CollectionAfterLoginHook => {\n const hook: CollectionAfterLoginHook = async ({ collection, context, req, token, user }) => {\n const config = req.payload.config\n const payload = await getPayloadAuth(config)\n const cookieStore = await cookies()\n const authContext = await payload.betterAuth.$context\n\n const sessionExpiration = payload.betterAuth.options.session?.expiresIn || 60 * 60 * 24 * 7 // 7 days\n // we can't use internal adapter as we can cause a race condition unless we pass req to the payload.create\n const session = (await payload.create({\n collection: options.sessionsCollectionSlug,\n data: {\n ipAddress: getIp(req.headers, payload.betterAuth.options) || '',\n userAgent: req.headers?.get('user-agent') || '',\n user: user.id,\n token: generateId(32),\n expiresAt: new Date(Date.now() + sessionExpiration * 1000),\n },\n req,\n })) as Session\n\n const betterAuthHandleRequest = createAuthMiddleware(async (ctx): Promise<Headers | null> => {\n ctx.context = { ...authContext, user: user }\n await ctx.setSignedCookie(\n ctx.context.authCookies.sessionToken.name,\n session.token,\n ctx.context.secret,\n ctx.context.authCookies.sessionToken.options,\n )\n const filteredSessionData = await prepareSessionData({\n newSession: { session, user },\n payloadConfig: config,\n collectionSlugs: {\n userCollectionSlug: options.usersCollectionSlug,\n sessionCollectionSlug: options.sessionsCollectionSlug,\n },\n })\n await setCookieCache(ctx, filteredSessionData as any)\n if ('responseHeaders' in ctx) {\n return ctx.responseHeaders as Headers\n }\n return null\n })\n\n const responseHeaders = await betterAuthHandleRequest(req)\n const responseCookies = responseHeaders\n ?.getSetCookie()\n .map((cookie) => parseSetCookie(cookie))\n .filter(Boolean) as ResponseCookie[]\n\n if (responseCookies) {\n for (const cookieData of responseCookies) {\n const { name, value, ...options } = cookieData\n cookieStore.set({\n ...options,\n name,\n value: decodeURIComponent(value),\n })\n }\n }\n }\n\n return hook as CollectionAfterLoginHook\n}\n"],"names":["generateId","createAuthMiddleware","setCookieCache","parseSetCookie","cookies","getPayloadAuth","getIp","prepareSessionData","getAfterLoginHook","options","hook","collection","context","req","token","user","config","payload","cookieStore","authContext","betterAuth","$context","sessionExpiration","session","expiresIn","create","sessionsCollectionSlug","data","ipAddress","headers","userAgent","get","id","expiresAt","Date","now","betterAuthHandleRequest","ctx","setSignedCookie","authCookies","sessionToken","name","secret","filteredSessionData","newSession","payloadConfig","collectionSlugs","userCollectionSlug","usersCollectionSlug","sessionCollectionSlug","responseHeaders","responseCookies","getSetCookie","map","cookie","filter","Boolean","cookieData","value","set","decodeURIComponent"],"mappings":"AAAA,SAASA,UAAU,QAAiB,c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zClB,QAAQT,KAAK,EACbuB,IAAIzB,OAAO,CAAC8B,MAAM,EAClBL,IAAIzB,OAAO,CAAC2B,WAAW,CAACC,YAAY,CAAC/B,OAAO;YAE9C,MAAMkC,sBAAsB,MAAMpC,mBAAmB;gBACnDqC,YAAY;oBAAErB;oBAASR;gBAAK;gBAC5B8B,eAAe7B;gBACf8B,iBAAiB;oBACfC,oBAAoBtC,QAAQuC,mBAAmB;oBAC/CC,uBAAuBxC,QAAQiB,sBAAsB;gBACvD;YACF;YACA,MAAMxB,eAAemC,KAAKM;YAC1B,IAAI,qBAAqBN,KAAK;gBAC5B,OAAOA,IAAIa,eAAe;YAC5B;YACA,OAAO;QACT;QAEA,MAAMA,kBAAkB,MAAMd,wBAAwBvB;QACtD,MAAMsC,kBAAkBD,iBACpBE,eACDC,IAAI,CAACC,SAAWnD,eAAemD,SAC/BC,OAAOC;QAEV,IAAIL,iBAAiB;YACnB,KAAK,MAAMM,cAAcN,gBAAiB;gBACxC,MAAM,EAAEV,IAAI,EAAEiB,KAAK,EAAE,GAAGjD,SAAS,GAAGgD;gBACpCvC,YAAYyC,GAAG,CAAC;oBACd,GAAGlD,OAAO;oBACVgC;oBACAiB,OAAOE,mBAAmBF;gBAC5B;YACF;QACF;IACF;IAEA,OAAOhD;AACT,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/plugin/collections/users/hooks/after-logout.ts"],"sourcesContent":["import { cookies } from 'next/headers'\nimport type { CollectionAfterLogoutHook } from 'payload'\nimport type { CollectionHookWithBetterAuth } from '../../../types'\nimport { getPayloadAuth } from '../../../lib/get-payload-auth'\n\ntype CollectionAfterLogoutHookWithBetterAuth =\n CollectionHookWithBetterAuth<CollectionAfterLogoutHook>\n\ntype AfterLogoutOptions = {\n sessionsCollectionSlug: string\n}\n\nexport const getAfterLogoutHook = (options: AfterLogoutOptions): CollectionAfterLogoutHook => {\n const hook: CollectionAfterLogoutHookWithBetterAuth = async ({ req }) => {\n const cookieStore = await cookies()\n const payload = await getPayloadAuth(req.payload.config)\n const authContext = await payload.betterAuth.$context\n const sessionTokenName = authContext.authCookies.sessionToken.name\n\n const sessionDataName = authContext.authCookies.sessionData.name\n const dontRememberTokenName = authContext.authCookies.dontRememberToken.name\n\n const sessionCookieValue = cookieStore.get(sessionTokenName)?.value\n if (sessionCookieValue) {\n const payload = req.payload\n const [token] = sessionCookieValue.split('.')\n const { docs: sessions } = await payload.find({\n collection: options.sessionsCollectionSlug,\n where: {\n token: { equals: token },\n },\n limit: 1,\n })\n const session = sessions.at(0)\n if (session) {\n await payload.delete({\n collection: options.sessionsCollectionSlug,\n id: session.id,\n })\n }\n }\n\n const baseMultiSessionName = sessionTokenName + '_multi'\n const multiSessionCookies = cookieStore.getAll()\n multiSessionCookies.forEach((cookie) => {\n if (cookie.name.startsWith(baseMultiSessionName)) {\n cookieStore.delete(cookie.name)\n }\n })\n\n //TODO: this is a hack to delete the admin session cookie\n // we need to find a better way to do this (BETTER AUTH HARDCODED THIS)\n cookieStore.delete('admin_session')\n\n cookieStore.delete(sessionTokenName)\n cookieStore.delete(sessionDataName)\n cookieStore.delete(dontRememberTokenName)\n }\n\n return hook as CollectionAfterLogoutHook\n}\n"],"names":["cookies","getPayloadAuth","getAfterLogoutHook","options","hook","req","cookieStore","payload","config","authContext","betterAuth","$context","sessionTokenName","authCookies","sessionToken","name","sessionDataName","sessionData","dontRememberTokenName","dontRememberToken","sessionCookieValue","get","value","token","split","docs","sessions","find","collection","sessionsCollectionSlug","where","equals","limit","session","at","delete","id","baseMultiSessionName","multiSessionCookies","getAll","forEach","cookie","startsWith"],"mappings":"AAAA,SAASA,OAAO,QAAQ,eAAc;AAGtC,SAASC,cAAc,QAAQ,gCAA+B;AAS9D,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,OAAgD,OAAO,EAAEC,GAAG,EAAE;QAClE,MAAMC,cAAc,MAAMN;QAC1B,MAAMO,UAAU,MAAMN,eAAeI,IAAIE,OAAO,CAACC,M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ts"],"sourcesContent":["import { APIError, CollectionBeforeLoginHook } from 'payload'\nimport { getPayloadAuth } from '../../../lib/get-payload-auth'\n\n/**\n * This hook blocks login attempts if email verification is required and the user's email is not verified\n */\nexport const getBeforeLoginHook = (): CollectionBeforeLoginHook => {\n const hook: CollectionBeforeLoginHook = async ({ req, user }) => {\n const config = req.payload.config\n const payload = await getPayloadAuth(config)\n\n const requireEmailVerification =\n payload.betterAuth.options.emailAndPassword?.requireEmailVerification ?? false\n\n if (requireEmailVerification && !user.emailVerified) {\n throw new APIError(\n 'Email verification required. Please verify your email before logging in.',\n 403,\n )\n }\n\n return user\n }\n\n return hook\n}\n"],"names":["APIError","getPayloadAuth","getBeforeLoginHook","hook","req","user","config","payload","requireEmailVerification","betterAuth","options","emailAndPassword","emailVerified"],"mappings":"AAAA,SAASA,QAAQ,QAAmC,UAAS;AAC7D,SAASC,cAAc,QAAQ,gCAA+B;AAE9D;;CAEC,GACD,OAAO,MAAMC,qBAAqB;IAChC,MAAMC,OAAkC,OAAO,EAAEC,GAAG,EAAEC,IAAI,EAAE;QAC1D,MAAMC,SAASF,IAAIG,OAAO,CAACD,MAAM;QACjC,MAAMC,UAAU,MAAMN,eAAeK;QAErC,MAAME,2BACJD,QAAQE,UAAU,CAACC,OAAO,CAACC,gBAAgB,EAAEH,4BAA4B;QAE3E,IAAIA,4BAA4B,CAACH,KAAKO,aAAa,EAAE;YACnD,MAAM,IAAIZ,SACR,4EACA;QAEJ;QAEA,OAAOK;IACT;IAEA,OAAOF;AACT,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/plugin/collections/users/hooks/clean-up-user-after-delete.ts"],"sourcesContent":["import type { CollectionAfterDeleteHook } from 'payload'\nimport type { CollectionHookWithBetterAuth } from '../../../types'\n\ntype CollectionAfterDeleteHookWithBetterAuth =\n CollectionHookWithBetterAuth<CollectionAfterDeleteHook>\n\nexport const cleanUpUserAfterDelete: CollectionAfterDeleteHookWithBetterAuth = async ({\n doc,\n req,\n}) => {\n try {\n const { payload } = req\n const betterAuthContext = await payload.betterAuth.$context\n const userId = doc.id\n const beforeDelete = betterAuthContext.options.user?.deleteUser?.beforeDelete\n if (typeof beforeDelete === 'function') {\n await beforeDelete(doc, req as Request)\n }\n await betterAuthContext.internalAdapter.deleteSessions(userId)\n await betterAuthContext.internalAdapter.deleteAccounts(userId)\n if (payload.collections.verifications) {\n await payload.delete({\n collection: payload.collections.verifications.config.slug,\n where: {\n value: {\n like: `\"${userId}\"`,\n },\n },\n })\n }\n const afterDelete = betterAuthContext.options.user?.deleteUser?.afterDelete\n if (typeof afterDelete === 'function') {\n await afterDelete(doc, req as Request)\n }\n return doc\n } catch (error) {\n console.error('Error in user afterDelete hook:', error)\n return doc\n }\n}\n"],"names":["cleanUpUserAfterDelete","doc","req","payload","betterAuthContext","betterAuth","$context","userId","id","beforeDelete","options","user","deleteUser","internalAdapter","deleteSessions","deleteAccounts","collections","verifications","delete","collection","config","slug","where","value","like","afterDelete","error","console"],"mappings":"AAMA,OAAO,MAAMA,yBAAkE,OAAO,EACpFC,GAAG,EACHC,GAAG,EACJ;IACC,IAAI;QACF,MAAM,EAAEC,OAAO,EAAE,GAAGD;QACpB,MAAME,oBAAoB,MAAMD,QAAQE,UAAU,CAACC,QAAQ;QAC3D,MAAMC,SAASN,IAAIO,EAAE;QACrB,MAAMC,eAAeL,kBAAkBM,OAAO,CAACC,IAAI,EAAEC,YAAYH;QACjE,IAAI,OAAOA,iBAAiB,YAAY;YACtC,MAAMA,aAAaR,KAAKC;QAC1B;QACA,MAAME,kBAAkBS,eAAe,CAACC,cAAc,CAACP;QACvD,MAAMH,kBAAkBS,eAAe,CAACE,cAAc,CAACR;QACvD,IAAIJ,QAAQa,WAAW,CAACC,aAAa,EAAE;YACrC,MAAMd,QAAQe,MAAM,CAAC;gBACnBC,YAAYhB,QAAQa,WAAW,CAACC,aAAa,CAACG,MAAM,CAACC,IAAI;gBACzDC,OAAO;oBACLC,OAAO;wBACLC,MAAM,CAAC,CAAC,EAAEjB,OAAO,CAAC,CAAC;oBACrB;gBACF;YACF;QACF;QACA,MAAMkB,cAAcrB,kBAAkBM,OAAO,CAACC,IAAI,EAAEC,YAAYa;QAChE,IAAI,OAAOA,gBAAgB,YAAY;YACrC,MAAMA,YAAYxB,KAAKC;QACzB;QACA,OAAOD;IACT,EAAE,OAAOyB,OAAO;QACdC,QAAQD,KAAK,CAAC,mCAAmCA;QACjD,OAAOzB;IACT;AACF,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/plugin/collections/users/hooks/on-verified-change.ts"],"sourcesContent":["import { CollectionBeforeChangeHook } from 'payload'\n\nexport const onVerifiedChange: CollectionBeforeChangeHook = async ({ data, originalDoc }) => {\n const isVerifiedChangingToTrue = Boolean(data._verified) && !Boolean(originalDoc?._verified)\n const isEmailVerifiedChangingToTrue =\n Boolean(data.emailVerified) && !Boolean(originalDoc?.emailVerified)\n\n if (!isVerifiedChangingToTrue && !isEmailVerifiedChangingToTrue) {\n return data\n }\n\n return {\n ...data,\n _verified: true,\n emailVerified: true,\n }\n}\n"],"names":["onVerifiedChange","data","originalDoc","isVerifiedChangingToTrue","Boolean","_verified","isEmailVerifiedChangingToTrue","emailVerified"],"mappings":"AAEA,OAAO,MAAMA,mBAA+C,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAE;IACtF,MAAMC,2BAA2BC,QAAQH,KAAKI,SAAS,KAAK,CAACD,QAAQF,aAAaG;IAClF,MAAMC,gCACJF,QAAQH,KAAKM,aAAa,KAAK,CAACH,QAAQF,aAAaK;IAEvD,IAAI,CAACJ,4BAA4B,CAACG,+BAA+B;QAC/D,OAAOL;IACT;IAEA,OAAO;QACL,GAAGA,IAAI;QACPI,WAAW;QACXE,eAAe;IACjB;AACF,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/plugin/collections/users/hooks/sync-account.ts"],"sourcesContent":["import type { CollectionAfterChangeHook } from 'payload'\nimport type { CollectionHookWithBetterAuth } from '../../../types'\nimport { BETTER_AUTH_CONTEXT_KEY } from 'payload-auth/better-auth/adapter'\n\ntype CollectionAfterChangeHookWithBetterAuth =\n CollectionHookWithBetterAuth<CollectionAfterChangeHook>\n\ntype SyncAccountOptions = {\n userSlug: string\n accountSlug: string\n}\n\nexport const getSyncAccountHook = (options: SyncAccountOptions): CollectionAfterChangeHook => {\n const hook: CollectionAfterChangeHookWithBetterAuth = async ({\n doc,\n req,\n operation,\n context,\n }) => {\n if (context?.syncPasswordToUser) return doc\n\n if (operation !== 'create' && operation !== 'update') return doc\n\n const user = await req.payload.findByID({\n collection: options.userSlug,\n id: doc.id,\n depth: 0,\n req,\n showHiddenFields: true,\n })\n\n if (!user || !user.hash || !user.salt) return doc\n\n const passwordValue = `${user.salt}:${user.hash}`\n const userField = req.payload.betterAuth.options.account?.fields?.userId || 'userId'\n\n if (operation === 'create' && !(BETTER_AUTH_CONTEXT_KEY in context)) {\n try {\n await req.payload.create({\n collection: options.accountSlug,\n data: {\n [userField]: doc.id,\n accountId: doc.id.toString(),\n providerId: 'credential',\n password: passwordValue,\n context: { syncAccountHook: true },\n },\n req,\n })\n } catch (error) {\n console.error('Failed to create account for user:', error)\n }\n }\n\n if (operation === 'update') {\n try {\n const accounts = await req.payload.find({\n collection: options.accountSlug,\n where: {\n and: [{ [userField]: { equals: doc.id } }, { providerId: { equals: 'credential' } }],\n },\n req,\n depth: 0,\n context: { syncAccountHook: true },\n })\n\n const account = accounts.docs.at(0)\n if (account) {\n await req.payload.update({\n collection: options.accountSlug,\n id: account.id,\n data: {\n password: passwordValue,\n },\n req,\n context: { syncAccountHook: true },\n })\n }\n } catch (error) {\n console.error('Failed to sync hash/salt to account:', error)\n }\n }\n\n return doc\n }\n\n return hook as CollectionAfterChangeHook\n}\n"],"names":["BETTER_AUTH_CONTEXT_KEY","getSyncAccountHook","options","hook","doc","req","operation","context","syncPasswordToUser","user","payload","findByID","collection","userSlug","id","depth","showHiddenFields","hash","salt","passwordValue","userField","betterAuth","account","fields","userId","create","accountSlug","data","accountId","toString","providerId","password","syncAccountHook","error","console","accounts","find","where","and","equals","docs","at","update"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ,mCAAkC;AAU1E,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,OAAgD,OAAO,EAC3DC,GAAG,EACHC,GAAG,EACHC,SAAS,EACTC,OAAO,EACR;QACC,IAAIA,SAASC,oBAAoB,OAAOJ;QAExC,IAAIE,cAAc,YAAYA,cAAc,UAAU,OAAOF;QAE7D,MAAMK,OAAO,MAAMJ,IAAIK,OAAO,CAACC,QAAQ,CAAC;YACtCC,YAAYV,QAAQW,QAAQ;YAC5BC,IAAIV,IAAIU,EAAE;YACVC,OAAO;YACPV;YACAW,kBAAkB;QACpB;QAEA,IAAI,CAACP,QAAQ,CAACA,KAAKQ,IAAI,IAAI,CAACR,KAAKS,IAAI,EAAE,OAAOd;QAE9C,MAAMe,gBAAgB,GAAGV,KAAKS,IAAI,CAAC,CAAC,EAAET,KAAKQ,IAAI,EAAE;QACjD,MAAMG,YAAYf,IAAIK,OAAO,CAACW,UAAU,CAACnB,OAAO,CAACoB,OAAO,EAAEC,QAAQC,UAAU;QAE5E,IAAIlB,cAAc,YAAY,CAAEN,CAAAA,2BAA2BO,OAAM,GAAI;YACnE,IAAI;gBACF,MAAMF,IAAIK,OAAO,CAACe,MAAM,CAAC;oBACvBb,YAAYV,QAAQwB,WAAW;oBAC/BC,MAAM;wBACJ,CAACP,UAAU,EAAEhB,IAAIU,EAAE;wBACnBc,WAAWxB,IAAIU,EAAE,CAACe,QAAQ;wBAC1BC,YAAY;wBACZC,UAAUZ;wBACVZ,SAAS;4BAAEyB,iBAAiB;wBAAK;oBACnC;oBACA3B;gBACF;YACF,EAAE,OAAO4B,OAAO;gBACdC,QAAQD,KAAK,CAAC,sCAAsCA;YACtD;QACF;QAEA,IAAI3B,cAAc,UAAU;YAC1B,IAAI;gBACF,MAAM6B,WAAW,MAAM9B,IAAIK,OAAO,CAAC0B,IAAI,CAAC;oBACtCxB,YAAYV,QAAQwB,WAAW;oBAC/BW,OAAO;wBACLC,KAAK;4BAAC;gCAAE,CAAClB,UAAU,EAAE;oCAAEmB,QAAQnC,IAAIU,EAAE;gCAAC;4BAAE;4BAAG;gCAAEgB,YAAY;oCAAES,QAAQ;gCAAa;4BAAE;yBAAE;oBACtF;oBACAlC;oBACAU,OAAO;oBACPR,SAAS;wBAAEyB,iBAAiB;oBAAK;gBACnC;gBAEA,MAAMV,UAAUa,SAASK,IAAI,CAACC,EAAE,CAAC;gBACjC,IAAInB,SAAS;oBACX,MAAMjB,IAAIK,OAAO,CAACgC,MAAM,CAAC;wBACvB9B,YAAYV,QAAQwB,WAAW;wBAC/BZ,IAAIQ,QAAQR,EAAE;wBACda,MAAM;4BACJI,UAAUZ;wBACZ;wBACAd;wBACAE,SAAS;4BAAEyB,iBAAiB;wBAAK;oBACnC;gBACF;YACF,EAAE,OAAOC,OAAO;gBACdC,QAAQD,KAAK,CAAC,wCAAwCA;YACxD;QACF;QAEA,OAAO7B;IACT;IAEA,OAAOD;AACT,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/helpers/generate-verify-email-url.ts"],"sourcesContent":["import { SignJWT } from 'jose'\n\n/**\n * Generates a verification URL for email verification\n *\n * This utility function creates a JWT token containing the user's email and\n * expiration information, signs it with the provided secret, and constructs\n * a verification URL with the token as a query parameter.\n *\n * @param userEmail - The email address of the user to verify\n * @param secret - The secret used to sign the JWT\n * @param expiresIn - Duration in seconds for token expiration (default: 3600)\n * @param verifyRouteUrl - The base URL for the verification endpoint\n * @param callbackURL - Optional callback URL after verification (default: \"/\")\n * @returns The complete verification URL with token\n *\n * @example\n * const url = await generateVerifyEmailUrl({\n * userEmail: 'user@example.com',\n * secret: 'your-secret-key',\n * verifyRouteUrl: 'https://your-app.com/api/auth/verify-email',\n * callbackURL: '/profile'\n * });\n */\nexport const generateVerifyEmailUrl = async ({\n userEmail,\n secret,\n expiresIn = 3600,\n verifyRouteUrl,\n callbackURL = '/',\n}: {\n userEmail: string\n secret: string\n expiresIn?: number\n verifyRouteUrl: string\n callbackURL?: string\n}): Promise<string> => {\n if (!userEmail) {\n throw new Error('userEmail is required to generate a verification URL')\n }\n\n if (!secret) {\n throw new Error('secret is required to sign the JWT token')\n }\n\n if (!verifyRouteUrl) {\n throw new Error('verifyRouteUrl is required to generate a verification URL')\n }\n\n // Create and sign the JWT token\n const jwt = await new SignJWT({\n email: userEmail,\n iat: Math.floor(Date.now() / 1000),\n exp: Math.floor(Date.now() / 1000) + expiresIn,\n })\n .setProtectedHeader({ alg: 'HS256' })\n .sign(new TextEncoder().encode(secret))\n\n // Build the verification URL\n const verifyUrl = `${verifyRouteUrl}?token=${jwt}${callbackURL ? `&callbackURL=${encodeURIComponent(callbackURL)}` : ''}`\n\n return verifyUrl\n}\n"],"names":["SignJWT","generateVerifyEmailUrl","userEmail","secret","expiresIn","verifyRouteUrl","callbackURL","Error","jwt","email","iat","Math","floor","Date","now","exp","setProtectedHeader","alg","sign","TextEncoder","encode","verifyUrl","encodeURIComponent"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAM;AAE9B;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,MAAMC,yBAAyB,OAAO,EAC3CC,SAAS,EACTC,MAAM,EACNC,YAAY,IAAI,EAChBC,cAAc,EACdC,cAAc,GAAG,EAOlB;IACC,IAAI,CAACJ,WAAW;QACd,MAAM,IAAIK,MAAM;IAClB;IAEA,IAAI,CAACJ,QAAQ;QACX,MAAM,IAAII,MAAM;IAClB;IAEA,IAAI,CAACF,gBAAgB;QACnB,MAAM,IAAIE,MAAM;IAClB;IAEA,gCAAgC;IAChC,MAAMC,MAAM,MAAM,IAAIR,QAAQ;QAC5BS,OAAOP;QACPQ,KAAKC,KAAKC,KAAK,CAACC,KAAKC,GAAG,KAAK;QAC7BC,KAAKJ,KAAKC,KAAK,CAACC,KAAKC,GAAG,KAAK,QAAQV;IACvC,GACGY,kBAAkB,CAAC;QAAEC,KAAK;IAAQ,GAClCC,IAAI,CAAC,IAAIC,cAAcC,MAAM,CAACjB;IAEjC,6BAA6B;IAC7B,MAAMkB,YAAY,GAAGhB,eAAe,OAAO,EAAEG,MAAMF,cAAc,CAAC,aAAa,EAAEgB,mBAAmBhB,cAAc,GAAG,IAAI;IAEzH,OAAOe;AACT,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/helpers/get-ip.ts"],"sourcesContent":["import type { BetterAuthOptions } from 'better-auth'\n\nexport function getIp(headers: Headers, options: BetterAuthOptions): string | null {\n if (options.advanced?.ipAddress?.disableIpTracking) {\n return null\n }\n const testIP = '127.0.0.1'\n if ((process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'development') ?? false) {\n return testIP\n }\n const ipHeaders = options.advanced?.ipAddress?.ipAddressHeaders\n const keys = ipHeaders || [\n 'x-client-ip',\n 'x-forwarded-for',\n 'cf-connecting-ip',\n 'fastly-client-ip',\n 'x-real-ip',\n 'x-cluster-client-ip',\n 'x-forwarded',\n 'forwarded-for',\n 'forwarded',\n ]\n for (const key of keys) {\n const value = headers.get(key)\n if (typeof value === 'string') {\n const ip = value.split(',')[0].trim()\n if (ip) return ip\n }\n }\n return null\n}\n"],"names":["getIp","headers","options","advanced","ipAddress","disableIpTracking","testIP","process","env","NODE_ENV","ipHeaders","ipAddressHeaders","keys","key","value","get","ip","split","trim"],"mappings":"AAEA,OAAO,SAASA,MAAMC,OAAgB,EAAEC,OAA0B;IAChE,IAAIA,QAAQC,QAAQ,EAAEC,WAAWC,mBAAmB;QAClD,OAAO;IACT;IACA,MAAMC,SAAS;IACf,IAAI,AAACC,CAAAA,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUF,QAAQC,GAAG,CAACC,QAAQ,KAAK,aAAY,KAAM,OAAO;QACxF,OAAOH;IACT;IACA,MAAMI,YAAYR,QAAQC,QAAQ,EAAEC,WAAWO;IAC/C,MAAMC,OAAOF,aAAa;QACxB;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IACD,KAAK,MAAMG,OAAOD,KAAM;QACtB,MAAME,QAAQb,QAAQc,GAAG,CAACF;QAC1B,IAAI,OAAOC,UAAU,UAAU;YAC7B,MAAME,KAAKF,MAAMG,KAAK,CAAC,IAAI,CAAC,EAAE,CAACC,IAAI;YACnC,IAAIF,IAAI,OAAOA;QACjB;IACF;IACA,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/helpers/index.ts"],"sourcesContent":["export { generateVerifyEmailUrl } from './generate-verify-email-url'; "],"names":["generateVerifyEmailUrl"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,8BAA8B"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/helpers/serialize-cookie.ts"],"sourcesContent":["import { subtle } from 'uncrypto'\n\ntype CookiePrefixOptions = 'host' | 'secure'\n\ntype CookieOptions = {\n /**\n * Domain of the cookie\n *\n * The Domain attribute specifies which server can receive a cookie. If specified, cookies are\n * available on the specified server and its subdomains. If the it is not\n * specified, the cookies are available on the server that sets it but not on\n * its subdomains.\n *\n * @example\n * `domain: \"example.com\"`\n */\n domain?: string\n /**\n * A lifetime of a cookie. Permanent cookies are deleted after the date specified in the\n * Expires attribute:\n *\n * Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and\n * takes precedence when both are set. The rationale behind this is that when you set an\n * Expires date and time, they're relative to the client the cookie is being set on. If the\n * server is set to a different time, this could cause errors\n */\n expires?: Date\n /**\n * Forbids JavaScript from accessing the cookie, for example, through the Document.cookie\n * property. Note that a cookie that has been created with HttpOnly will still be sent with\n * JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().\n * This mitigates attacks against cross-site scripting\n */\n httpOnly?: boolean\n /**\n * Indicates the number of seconds until the cookie expires. A zero or negative number will\n * expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.\n *\n * @example 604800 - 7 days\n */\n maxAge?: number\n /**\n * Indicates the path that must exist in the requested URL for the browser to send the Cookie\n * header.\n *\n * @example\n * \"/docs\"\n * // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.\n */\n path?: string\n /**\n * Indicates that the cookie is sent to the server only when a request is made with the https:\n * scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.\n */\n secure?: boolean\n /**\n * Controls whether or not a cookie is sent with cross-site requests, providing some protection\n * against cross-site request forgery attacks (CSRF).\n *\n * Strict - Means that the browser sends the cookie only for same-site requests, that is,\n * requests originating from the same site that set the cookie. If a request originates from a\n * different domain or scheme (even with the same domain), no cookies with the SameSite=Strict\n * attribute are sent.\n *\n * Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load\n * images or frames, but is sent when a user is navigating to the origin site from an external\n * site (for example, when following a link). This is the default behavior if the SameSite\n * attribute is not specified.\n *\n * None - Means that the browser sends the cookie with both cross-site and same-site requests.\n * The Secure attribute must also be set when setting this value.\n */\n sameSite?: 'Strict' | 'Lax' | 'None' | 'strict' | 'lax' | 'none'\n /**\n * Indicates that the cookie should be stored using partitioned storage. Note that if this is\n * set, the Secure directive must also be set.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies\n */\n partitioned?: boolean\n /**\n * Cooke Prefix\n *\n * - secure: `__Secure-` -> `__Secure-cookie-name`\n * - host: `__Host-` -> `__Host-cookie-name`\n *\n * `secure` must be set to true to use prefixes\n */\n prefix?: CookiePrefixOptions\n}\n\nexport const verifySignature = async (\n base64Signature: string,\n value: string,\n secret: CryptoKey,\n): Promise<boolean> => {\n try {\n const signatureBinStr = atob(base64Signature)\n const signature = new Uint8Array(signatureBinStr.length)\n for (let i = 0, len = signatureBinStr.length; i < len; i++) {\n signature[i] = signatureBinStr.charCodeAt(i)\n }\n return await subtle.verify(algorithm, secret, signature, new TextEncoder().encode(value))\n } catch (e) {\n return false\n }\n}\n\nconst _serialize = (key: string, value: string, opt: CookieOptions = {}) => {\n let cookie: string\n\n if (opt?.prefix === 'secure') {\n cookie = `${`__Secure-${key}`}=${value}`\n } else if (opt?.prefix === 'host') {\n cookie = `${`__Host-${key}`}=${value}`\n } else {\n cookie = `${key}=${value}`\n }\n\n if (key.startsWith('__Secure-') && !opt.secure) {\n opt.secure = true\n }\n\n if (key.startsWith('__Host-')) {\n if (!opt.secure) {\n opt.secure = true\n }\n\n if (opt.path !== '/') {\n opt.path = '/'\n }\n\n if (opt.domain) {\n opt.domain = undefined\n }\n }\n\n if (opt && typeof opt.maxAge === 'number' && opt.maxAge >= 0) {\n if (opt.maxAge > 34560000) {\n throw new Error(\n 'Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.',\n )\n }\n cookie += `; Max-Age=${Math.floor(opt.maxAge)}`\n }\n\n if (opt.domain && opt.prefix !== 'host') {\n cookie += `; Domain=${opt.domain}`\n }\n\n if (opt.path) {\n cookie += `; Path=${opt.path}`\n }\n\n if (opt.expires) {\n if (opt.expires.getTime() - Date.now() > 34560000_000) {\n throw new Error(\n 'Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.',\n )\n }\n cookie += `; Expires=${opt.expires.toUTCString()}`\n }\n\n if (opt.httpOnly) {\n cookie += '; HttpOnly'\n }\n\n if (opt.secure) {\n cookie += '; Secure'\n }\n\n if (opt.sameSite) {\n cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`\n }\n\n if (opt.partitioned) {\n if (!opt.secure) {\n opt.secure = true\n }\n cookie += '; Partitioned'\n }\n\n return cookie\n}\n\nconst algorithm = { name: 'HMAC', hash: 'SHA-256' }\n\nconst getCryptoKey = async (secret: string | BufferSource) => {\n const secretBuf = typeof secret === 'string' ? new TextEncoder().encode(secret) : secret\n return await subtle.importKey('raw', secretBuf, algorithm, false, ['sign', 'verify'])\n}\n\nconst makeSignature = async (value: string, secret: string | BufferSource): Promise<string> => {\n const key = await getCryptoKey(secret)\n const signature = await subtle.sign(algorithm.name, key, new TextEncoder().encode(value))\n // the returned base64 encoded signature will always be 44 characters long and end with one or two equal signs\n return btoa(String.fromCharCode(...new Uint8Array(signature)))\n}\n\nexport const signCookieValue = async (value: string, secret: string | BufferSource) => {\n const signature = await makeSignature(value, secret)\n value = `${value}.${signature}`\n value = encodeURIComponent(value)\n value = decodeURIComponent(value)\n return value\n}\n\nexport const serializeCookie = (key: string, value: string, opt?: CookieOptions) => {\n value = encodeURIComponent(value)\n return _serialize(key, value, opt)\n}\n\nexport const serializeSignedCookie = async (\n key: string,\n value: string,\n secret: string,\n opt?: CookieOptions,\n) => {\n value = await signCookieValue(value, secret)\n return _serialize(key, value, opt)\n}\n\nexport const getCookieKey = (key: string, prefix?: CookiePrefixOptions) => {\n let finalKey = key\n if (prefix) {\n if (prefix === 'secure') {\n finalKey = '__Secure-' + key\n } else if (prefix === 'host') {\n finalKey = '__Host-' + key\n } else {\n return undefined\n }\n }\n return finalKey\n}\n\nexport function tryDecode(str: string) {\n try {\n return str.includes('%') ? decodeURIComponent(str) : str\n } catch {\n return str\n }\n}\n\n/**\n * Parse an HTTP Cookie header string and returning an object of all cookie\n * name-value pairs.\n *\n * Inspired by https://github.com/unjs/cookie-es/blob/main/src/cookie/parse.ts\n *\n * @param str the string representing a `Cookie` header value\n */\nexport function parseCookies(str: string) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string')\n }\n\n const cookies: Map<string, string> = new Map()\n\n let index = 0\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index)\n\n if (eqIdx === -1) {\n break\n }\n\n let endIdx = str.indexOf(';', index)\n\n if (endIdx === -1) {\n endIdx = str.length\n } else if (endIdx < eqIdx) {\n index = str.lastIndexOf(';', eqIdx - 1) + 1\n continue\n }\n\n const key = str.slice(index, eqIdx).trim()\n if (!cookies.has(key)) {\n let val = str.slice(eqIdx + 1, endIdx).trim()\n if (val.codePointAt(0) === 0x22) {\n val = val.slice(1, -1)\n }\n cookies.set(key, tryDecode(val))\n }\n\n index = endIdx + 1\n }\n\n return cookies\n}\n\nexport const getSignedCookie = async (\n key: string,\n secret: string,\n headers: Headers,\n prefix?: CookiePrefixOptions,\n) => {\n const finalKey = getCookieKey(key, prefix)\n if (!finalKey) {\n return null\n }\n const cookieHeader = headers.get('cookie')\n const parsedCookies = cookieHeader ? parseCookies(cookieHeader) : undefined\n const value = parsedCookies?.get(finalKey)\n if (!value) {\n return null\n }\n const signatureStartPos = value.lastIndexOf('.')\n if (signatureStartPos < 1) {\n return null\n }\n const signedValue = value.substring(0, signatureStartPos)\n const signature = value.substring(signatureStartPos + 1)\n if (signature.length !== 44 || !signature.endsWith('=')) {\n return null\n }\n const secretKey = await getCryptoKey(secret)\n const isVerified = await verifySignature(signature, signedValue, secretKey)\n return isVerified ? signedValue : false\n}\n"],"names":["subtle","verifySignature","base64Signature","value","secret","signatureBinStr","atob","signature","Uint8Array","length","i","len","charCodeAt","verify","algorithm","TextEncoder","encode","e","_serialize","key","opt","cookie","prefix","startsWith","secure","path","domain","undefined","maxAge","Error","Math","floor","expires","getTime","Date","now","toUTCString","httpOnly","sameSite","charAt","toUpperCase","slice","partitioned","name","hash","getCryptoKey","secretBuf","importKey","makeSignature","sign","btoa","String","fromCharCode","signCookieValue","encodeURIComponent","decodeURIComponent","serializeCookie","serializeSignedCookie","getCookieKey","finalKey","tryDecode","str","includes","parseCookies","TypeError","cookies","Map","index","eqIdx","indexOf","endIdx","lastIndexOf","trim","has","val","codePointAt","set","getSignedCookie","headers","cookieHeader","get","parsedCookies","signatureStartPos","signedValue","substring","endsWith","secretKey","isVerified"],"mappings":"AAAA,SAASA,MAAM,QAAQ,WAAU;AA2FjC,OAAO,MAAMC,kBAAkB,OAC7BC,iBACAC,OACAC;IAEA,IAAI;QACF,MAAMC,kBAAkBC,KAAKJ;QAC7B,MAAMK,YAAY,IAAIC,WAAWH,gBAAgBI,MAAM;QACvD,IAAK,IA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,gBAAgBM,WAAW4E,aAAaG;IACjE,OAAOC,aAAaJ,cAAc;AACpC,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/plugin/index.ts"],"sourcesContent":["import type { BasePayload, Config } from 'payload'\nimport type { PayloadBetterAuthPluginOptions } from './types'\nimport { sanitizeBetterAuthOptions } from './lib/sanitize-auth-options'\nimport { getRequiredCollectionSlugs } from './lib/get-required-collection-slugs'\nimport { buildCollectionConfigs } from './lib/build-collection-configs'\nimport { respectSaveToJwtFieldsMiddleware } from './lib/respect-save-to-jwt-fields-middleware'\nimport { initBetterAuth } from './lib/init-better-auth'\n\nexport * from './types'\nexport * from './helpers'\nexport { sanitizeBetterAuthOptions } from './lib/sanitize-auth-options'\nexport { getPayloadAuth } from './lib/get-payload-auth'\n\nexport function betterAuthPlugin(pluginOptions: PayloadBetterAuthPluginOptions) {\n return (config: Config): Config => {\n if (pluginOptions.disabled) {\n return config\n }\n config.custom = {\n ...config.custom,\n hasBetterAuthPlugin: true,\n }\n\n if (!config.collections) {\n config.collections = []\n }\n\n let sanitzedBetterAuthOptions = sanitizeBetterAuthOptions(pluginOptions)\n\n // Determine which collections to add based on the options and plugins\n const requiredCollectionSlugs = getRequiredCollectionSlugs({\n logTables: pluginOptions.logTables ?? false,\n pluginOptions,\n sanitizedBAOptions: sanitzedBetterAuthOptions,\n })\n\n // Update with the required collections + existing collections\n config.collections = buildCollectionConfigs({\n incomingCollections: config.collections ?? [],\n requiredCollectionSlugs,\n pluginOptions,\n sanitizedBAOptions: sanitzedBetterAuthOptions,\n })\n\n respectSaveToJwtFieldsMiddleware({\n sanitizedOptions: sanitzedBetterAuthOptions,\n payloadConfig: config,\n pluginOptions,\n })\n\n const incomingOnInit = config.onInit\n\n config.onInit = async (payload) => {\n // Ensure we are executing any existing onInit functions before running our own.\n if (incomingOnInit) {\n await incomingOnInit(payload)\n }\n\n // Initialize and set the betterAuth instance\n const auth = initBetterAuth<NonNullable<typeof sanitzedBetterAuthOptions.plugins>>({\n payload,\n options: {\n ...sanitzedBetterAuthOptions,\n enableDebugLogs: pluginOptions.enableDebugLogs,\n plugins: [...(sanitzedBetterAuthOptions.plugins ?? [])],\n },\n })\n ;(payload as BasePayload & { betterAuth: typeof auth }).betterAuth = auth\n }\n return config\n }\n}\n"],"names":["sanitizeBetterAuthOptions","getRequiredCollectionSlugs","buildCollectionConfigs","respectSaveToJwtFieldsMiddleware","initBetterAuth","getPayloadAuth","betterAuthPlugin","pluginOptions","config","disabled","custom","hasBetterAuthPlugin","collections","sanitzedBetterAuthOptions","requiredCollectionSlugs","logTables","sanitizedBAOptions","incomingCollections","sanitizedOptions","payloadConfig","incomingOnInit","onInit","payload","auth","options","enableDebugLogs","plugins","betterAuth"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,8BAA6B;AACvE,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,sBAAsB,QAAQ,iCAAgC;AACvE,SAASC,gCAAgC,QAAQ,8CAA6C;AAC9F,SAASC,cAAc,QAAQ,yBAAwB;AAEvD,cAAc,UAAS;AACvB,cAAc,YAAW;AACzB,SAASJ,yBAAyB,QAAQ,8BAA6B;AACvE,SAASK,cAAc,QAAQ,yBAAwB;AAEvD,OAAO,SAASC,iBAAiBC,aAA6C;IAC5E,OAAO,CAACC;QACN,IAAID,cAAcE,QAAQ,EAAE;YAC1B,OAAOD;QACT;QACAA,OAAOE,MAAM,GAAG;YACd,GAAGF,OAAOE,MAAM;YAChBC,qBAAqB;QACvB;QAEA,IAAI,CAACH,OAAOI,WAAW,EAAE;YACvBJ,OAAOI,WAAW,GAAG,EAAE;QACzB;QAEA,IAAIC,4BAA4Bb,0BAA0BO;QAE1D,sEAAsE;QACtE,MAAMO,0BAA0Bb,2BAA2B;YACzDc,WAAWR,cAAcQ,SAAS,IAAI;YACtCR;YACAS,oBAAoBH;QACtB;QAEA,8DAA8D;QAC9DL,OAAOI,WAAW,GAAGV,uBAAuB;YAC1Ce,qBAAqBT,OAAOI,WAAW,IAAI,EAAE;YAC7CE;YACAP;YACAS,oBAAoBH;QACtB;QAEAV,iCAAiC;YAC/Be,kBAAkBL;YAClBM,eAAeX;YACfD;QACF;QAEA,MAAMa,iBAAiBZ,OAAOa,MAAM;QAEpCb,OAAOa,MAAM,GAAG,OAAOC;YACrB,gFAAgF;YAChF,IAAIF,gBAAgB;gBAClB,MAAMA,eAAeE;YACvB;YAEA,6CAA6C;YAC7C,MAAMC,OAAOnB,eAAsE;gBACjFkB;gBACAE,SAAS;oBACP,GAAGX,yBAAyB;oBAC5BY,iBAAiBlB,cAAckB,eAAe;oBAC9CC,SAAS;2BAAKb,0BAA0Ba,OAAO,IAAI,EAAE;qBAAE;gBACzD;YACF;YACEJ,QAAsDK,UAAU,GAAGJ;QACvE;QACA,OAAOf;IACT;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/auth-strategy.ts"],"sourcesContent":["import type { AuthStrategy } from 'payload'\nimport { getPayloadAuth } from './get-payload-auth'\nimport type { TPlugins } from '..'\n\n/**\n * Auth strategy for BetterAuth\n * @param adminRoles - Admin roles\n * @param userSlug - User collection slug\n * @returns Auth strategy\n */\nexport function betterAuthStrategy(adminRoles?: string[], userSlug?: string): AuthStrategy {\n return {\n name: 'better-auth',\n authenticate: async ({ payload, headers }) => {\n const payloadAuth = await getPayloadAuth<NonNullable<TPlugins>>(payload.config)\n const session = await payloadAuth.betterAuth.api.getSession({ headers })\n const sessionUserIdField = payloadAuth.betterAuth.options.session?.fields?.userId ?? 'userId'\n const userId = (session?.session as any)?.[sessionUserIdField] ?? session?.user?.id\n\n if (!session || !userId) {\n return { user: null }\n }\n try {\n const user = await payloadAuth.findByID({\n collection: userSlug ?? 'users',\n id: userId,\n })\n\n if (!user) {\n return { user: null }\n }\n\n return {\n user: {\n ...user,\n collection: userSlug ?? 'users',\n _strategy: 'better-auth',\n },\n }\n } catch {\n return { user: null }\n }\n },\n }\n}\n"],"names":["getPayloadAuth","betterAuthStrategy","adminRoles","userSlug","name","authenticate","payload","headers","payloadAuth","config","session","betterAuth","api","getSession","sessionUserIdField","options","fields","userId","user","id","findByID","collection","_strategy"],"mappings":"AACA,SAASA,cAAc,QAAQ,qBAAoB;AAGnD;;;;;CAKC,GACD,OAAO,SAASC,mBAAmBC,UAAqB,EAAEC,QAAiB;IACzE,OAAO;QACLC,MAAM;QACNC,cAAc,OAAO,EAAEC,OAAO,EAAEC,OAAO,EAAE;YACvC,MAAMC,cAAc,MAAMR,eAAsCM,QAAQG,MAAM;YAC9E,MAAMC,UAAU,MAAMF,YAAYG,UAAU,CAACC,GAAG,CAACC,UAAU,CAAC;gBAAEN;YAAQ;YACtE,MAAMO,qBAAqBN,YAAYG,UAAU,CAACI,OAAO,CAACL,OAAO,EAAEM,QAAQC,UAAU;YACrF,MAAMA,SAAS,AAACP,SAASA,SAAiB,CAACI,mBAAmB,IAAIJ,SAASQ,MAAMC;YAEjF,IAAI,CAACT,WAAW,CAACO,QAAQ;gBACvB,OAAO;oBAAEC,MAAM;gBAAK;YACtB;YACA,IAAI;gBACF,MAAMA,OAAO,MAAMV,YAAYY,QAAQ,CAAC;oBACtCC,YAAYlB,YAAY;oBACxBgB,IAAIF;gBACN;gBAEA,IAAI,CAACC,MAAM;oBACT,OAAO;wBAAEA,MAAM;oBAAK;gBACtB;gBAEA,OAAO;oBACLA,MAAM;wBACJ,GAAGA,IAAI;wBACPG,YAAYlB,YAAY;wBACxBmB,WAAW;oBACb;gBACF;YACF,EAAE,OAAM;gBACN,OAAO;oBAAEJ,MAAM;gBAAK;YACtB;QACF;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/build-collection-configs.ts"],"sourcesContent":["import type { PayloadBetterAuthPluginOptions, SanitizedBetterAuthOptions } from '..'\nimport { baseCollectionSlugs, betterAuthPluginSlugs } from './config'\nimport { betterAuthStrategy } from './auth-strategy'\nimport { getAfterLogoutHook } from '../collections/users/hooks/after-logout'\nimport { getRefreshTokenEndpoint } from '../collections/users/endpoints/refresh-token'\nimport {\n isAdminOrCurrentUserUpdateWithAllowedFields,\n isAdminOrCurrentUserWithRoles,\n isAdminWithRoles,\n} from './payload-access'\nimport { cleanUpUserAfterDelete } from '../collections/users/hooks/clean-up-user-after-delete'\nimport { getSyncPasswordToUserHook } from '../collections/accounts/hooks/sync-password-to-user'\nimport { getSyncAccountHook } from '../collections/users/hooks/sync-account'\nimport { onVerifiedChange } from '../collections/users/hooks/on-verified-change'\nimport { getAfterLoginHook } from '../collections/users/hooks/after-login'\nimport { getBeforeLoginHook } from '../collections/users/hooks/before-login'\nimport { CollectionConfig, Field } from 'payload'\n/**\n * Builds the required collections based on the BetterAuth options and plugins\n */\nexport function buildCollectionConfigs({\n incomingCollections,\n requiredCollectionSlugs,\n pluginOptions,\n sanitizedBAOptions,\n}: {\n incomingCollections: CollectionConfig[]\n requiredCollectionSlugs: Set<string>\n pluginOptions: PayloadBetterAuthPluginOptions\n sanitizedBAOptions: SanitizedBetterAuthOptions\n}): CollectionConfig[] {\n const userSlug = pluginOptions.users?.slug ?? baseCollectionSlugs.users\n const accountSlug = pluginOptions.accounts?.slug ?? baseCollectionSlugs.accounts\n const sessionSlug = pluginOptions.sessions?.slug ?? baseCollectionSlugs.sessions\n const verificationSlug = pluginOptions.verifications?.slug ?? baseCollectionSlugs.verifications\n const baPlugins = sanitizedBAOptions.plugins ?? null\n const adminRoles = pluginOptions.users?.adminRoles ?? ['admin']\n\n const getTimestampFields = ({\n saveUpdatedAtToJWT = true,\n saveCreatedAtToJWT = true,\n }: {\n saveUpdatedAtToJWT?: boolean\n saveCreatedAtToJWT?: boolean\n } = {}): Field[] => {\n return [\n {\n name: 'updatedAt',\n type: 'date',\n saveToJWT: saveUpdatedAtToJWT,\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n index: true,\n label: ({ t }) => t('general:updatedAt'),\n },\n {\n name: 'createdAt',\n saveToJWT: saveCreatedAtToJWT,\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n type: 'date',\n index: true,\n label: ({ t }) => t('general:createdAt'),\n },\n ]\n }\n\n const enhancedCollections: CollectionConfig[] = []\n\n requiredCollectionSlugs.forEach((slug) => {\n switch (slug as keyof typeof baseCollectionSlugs | keyof typeof betterAuthPluginSlugs) {\n case baseCollectionSlugs.users:\n const existingUserCollection = incomingCollections.find(\n (collection) => collection.slug === userSlug,\n ) as CollectionConfig | undefined\n const allowedFields = pluginOptions.users?.allowedFields ?? ['name']\n let usersCollection: CollectionConfig = {\n ...existingUserCollection,\n slug: userSlug,\n admin: {\n defaultColumns: ['email'],\n useAsTitle: 'email',\n ...existingUserCollection?.admin,\n hidden: pluginOptions.users?.hidden ?? false,\n },\n access: {\n admin: ({ req }) => adminRoles.includes((req.user?.role as string) ?? 'user'),\n read: isAdminOrCurrentUserWithRoles({ adminRoles, idField: 'id' }),\n create: isAdminWithRoles({ adminRoles }),\n delete: isAdminOrCurrentUserWithRoles({ adminRoles, idField: 'id' }),\n update: isAdminOrCurrentUserUpdateWithAllowedFields({\n allowedFields,\n adminRoles,\n userSlug,\n }),\n ...(existingUserCollection?.access ?? {}),\n },\n endpoints: [\n ...(existingUserCollection?.endpoints ? existingUserCollection.endpoints : []),\n getRefreshTokenEndpoint({ userSlug }),\n ],\n hooks: {\n beforeChange: [\n ...(existingUserCollection?.hooks?.beforeChange ?? []),\n onVerifiedChange,\n ],\n afterChange: [\n ...(existingUserCollection?.hooks?.afterChange ?? []),\n getSyncAccountHook({\n userSlug,\n accountSlug,\n }),\n ],\n beforeLogin: [\n ...(existingUserCollection?.hooks?.beforeLogin ?? []),\n getBeforeLoginHook(),\n ],\n afterLogin: [\n ...(existingUserCollection?.hooks?.afterLogin ?? []),\n getAfterLoginHook({\n sessionsCollectionSlug: sessionSlug,\n usersCollectionSlug: userSlug,\n }),\n ],\n afterLogout: [\n ...(existingUserCollection?.hooks?.afterLogout ?? []),\n getAfterLogoutHook({ sessionsCollectionSlug: sessionSlug }),\n ],\n afterDelete: [\n ...(existingUserCollection?.hooks?.afterDelete ?? []),\n (args) => cleanUpUserAfterDelete(args as any),\n ],\n },\n auth: {\n ...(existingUserCollection && typeof existingUserCollection.auth === 'object'\n ? existingUserCollection.auth\n : {}),\n //disableLocalStrategy: false,\n strategies: [betterAuthStrategy(adminRoles, userSlug)],\n },\n fields: [\n ...(existingUserCollection?.fields ?? []),\n {\n name: 'betterAuthAdminButtons',\n type: 'ui',\n admin: {\n position: 'sidebar',\n components: {\n Field: {\n path: 'payload-auth/better-auth/plugin/client#AdminButtons',\n clientProps: () => {\n return {\n userSlug,\n }\n },\n },\n },\n condition: () => {\n // Only show the impersonate button if the admin plugin is enabled\n return (baPlugins && baPlugins.some((plugin) => plugin.id === 'admin')) ?? false\n },\n },\n },\n {\n name: 'name',\n type: 'text',\n label: 'Name',\n saveToJWT: true,\n admin: {\n description: 'Users chosen display name',\n },\n },\n {\n name: 'email',\n type: 'text',\n required: true,\n unique: true,\n index: true,\n label: 'Email',\n admin: {\n description: 'The email of the user',\n },\n },\n {\n name: 'emailVerified',\n type: 'checkbox',\n required: true,\n defaultValue: false,\n saveToJWT: true,\n label: 'Email Verified',\n admin: {\n description: 'Whether the email of the user has been verified',\n },\n },\n {\n name: 'image',\n type: 'text',\n label: 'Image',\n saveToJWT: true,\n admin: {\n description: 'The image of the user',\n },\n },\n {\n name: 'role',\n type: 'select',\n required: true,\n defaultValue: 'user',\n saveToJWT: true,\n options: [\n ...(\n pluginOptions.users?.roles ?? [\n { label: 'Admin', value: 'admin' },\n { label: 'User', value: 'user' },\n ]\n ).map((role) => {\n if (typeof role === 'string') {\n return {\n label: role.charAt(0).toUpperCase() + role.slice(1),\n value: role,\n }\n }\n return role\n }),\n ],\n label: 'Role',\n admin: {\n description: 'The role of the user',\n },\n },\n ...getTimestampFields({ saveUpdatedAtToJWT: false, saveCreatedAtToJWT: false }),\n ],\n }\n if (baPlugins) {\n baPlugins.forEach((plugin) => {\n switch (plugin.id) {\n case 'two-factor':\n usersCollection.fields.push({\n name: 'twoFactorEnabled',\n type: 'checkbox',\n defaultValue: false,\n label: 'Two Factor Enabled',\n admin: {\n description: 'Whether the user has two factor authentication enabled',\n },\n })\n break\n case 'username':\n usersCollection.fields.push(\n {\n name: 'username',\n type: 'text',\n unique: true,\n required: false, // TODO: decide if this should be required, will have to tell users they need to add ui for it.\n label: 'Username',\n admin: {\n description: 'The username of the user',\n },\n },\n {\n name: 'displayUsername',\n type: 'text',\n required: true,\n label: 'Display Username',\n admin: {\n description: 'The display username of the user',\n },\n },\n )\n break\n case 'anonymous':\n usersCollection.fields.push({\n name: 'isAnonymous',\n type: 'checkbox',\n defaultValue: false,\n label: 'Is Anonymous',\n admin: {\n description: 'Whether the user is anonymous.',\n },\n })\n break\n case 'phone-number':\n usersCollection.fields.push(\n {\n name: 'phoneNumber',\n type: 'text',\n label: 'Phone Number',\n admin: {\n description: 'The phone number of the user',\n },\n },\n {\n name: 'phoneNumberVerified',\n type: 'checkbox',\n defaultValue: false,\n label: 'Phone Number Verified',\n admin: {\n description: 'Whether the phone number of the user has been verified',\n },\n },\n )\n break\n case 'admin':\n usersCollection.fields.push(\n {\n name: 'banned',\n type: 'checkbox',\n defaultValue: false,\n label: 'Banned',\n admin: {\n description: 'Whether the user is banned from the platform',\n },\n },\n {\n name: 'banReason',\n type: 'text',\n label: 'Ban Reason',\n admin: {\n description: 'The reason for the ban',\n },\n },\n {\n name: 'banExpires',\n type: 'date',\n label: 'Ban Expires',\n admin: {\n description: 'The date and time when the ban will expire',\n },\n },\n )\n break\n case 'harmony-email':\n usersCollection.fields.push({\n name: 'normalizedEmail',\n type: 'text',\n required: false,\n unique: true,\n admin: {\n readOnly: true,\n description: 'The normalized email of the user',\n },\n })\n break\n default:\n break\n }\n })\n }\n\n if (pluginOptions.users?.collectionOverrides) {\n usersCollection = pluginOptions.users.collectionOverrides({ collection: usersCollection })\n }\n\n enhancedCollections.push(usersCollection)\n break\n case baseCollectionSlugs.accounts:\n const existingAccountCollection = incomingCollections.find(\n (collection) => collection.slug === accountSlug,\n ) as CollectionConfig | undefined\n let accountCollection: CollectionConfig = {\n slug: accountSlug,\n admin: {\n useAsTitle: 'accountId',\n description: 'Accounts are used to store user accounts for authentication providers',\n ...existingAccountCollection?.admin,\n hidden: pluginOptions.accounts?.hidden,\n },\n hooks: {\n afterChange: [\n ...(existingAccountCollection?.hooks?.afterChange ?? []),\n getSyncPasswordToUserHook({\n userSlug,\n accountSlug,\n }),\n ],\n },\n access: {\n create: isAdminWithRoles({ adminRoles }),\n delete: isAdminWithRoles({ adminRoles }),\n read: isAdminOrCurrentUserWithRoles({ adminRoles, idField: 'user' }),\n update: isAdminWithRoles({ adminRoles }),\n ...(existingAccountCollection?.access ?? {}),\n },\n fields: [\n ...(existingAccountCollection?.fields ?? []),\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n index: true,\n label: 'User',\n admin: {\n readOnly: true,\n description: 'The user that the account belongs to',\n },\n },\n {\n name: 'accountId',\n type: 'text',\n label: 'Account ID',\n required: true,\n index: true,\n admin: {\n readOnly: true,\n description:\n 'The id of the account as provided by the SSO or equal to userId for credential accounts',\n },\n },\n {\n name: 'providerId',\n type: 'text',\n required: true,\n label: 'Provider ID',\n admin: {\n readOnly: true,\n description: 'The id of the provider as provided by the SSO',\n },\n },\n {\n name: 'accessToken',\n type: 'text',\n label: 'Access Token',\n admin: {\n readOnly: true,\n description: 'The access token of the account. Returned by the provider',\n },\n },\n {\n name: 'refreshToken',\n type: 'text',\n label: 'Refresh Token',\n admin: {\n readOnly: true,\n description: 'The refresh token of the account. Returned by the provider',\n },\n },\n {\n name: 'accessTokenExpiresAt',\n type: 'date',\n label: 'Access Token Expires At',\n admin: {\n readOnly: true,\n description: 'The date and time when the access token will expire',\n },\n },\n {\n name: 'refreshTokenExpiresAt',\n type: 'date',\n label: 'Refresh Token Expires At',\n admin: {\n readOnly: true,\n description: 'The date and time when the refresh token will expire',\n },\n },\n {\n name: 'scope',\n type: 'text',\n label: 'Scope',\n admin: {\n readOnly: true,\n description: 'The scope of the account. Returned by the provider',\n },\n },\n {\n name: 'idToken',\n type: 'text',\n label: 'ID Token',\n admin: {\n readOnly: true,\n description: 'The id token for the account. Returned by the provider',\n },\n },\n {\n name: 'password',\n type: 'text',\n label: 'Password',\n admin: {\n readOnly: true,\n hidden: true,\n description:\n 'The hashed password of the account. Mainly used for email and password authentication',\n },\n },\n ...getTimestampFields(),\n ],\n ...existingAccountCollection,\n }\n if (pluginOptions.accounts?.collectionOverrides) {\n accountCollection = pluginOptions.accounts.collectionOverrides({\n collection: accountCollection,\n })\n }\n\n enhancedCollections.push(accountCollection)\n break\n case baseCollectionSlugs.sessions:\n const existingSessionCollection = incomingCollections.find(\n (collection) => collection.slug === sessionSlug,\n ) as CollectionConfig | undefined\n let sessionCollection: CollectionConfig = {\n slug: sessionSlug,\n admin: {\n ...existingSessionCollection?.admin,\n hidden: pluginOptions.sessions?.hidden,\n description:\n 'Sessions are active sessions for users. They are used to authenticate users with a session token',\n },\n fields: [\n ...(existingSessionCollection?.fields ?? []),\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n saveToJWT: true,\n index: true,\n admin: {\n readOnly: true,\n description: 'The user that the session belongs to',\n },\n },\n {\n name: 'token',\n type: 'text',\n required: true,\n unique: true,\n index: true,\n saveToJWT: true,\n label: 'Token',\n admin: {\n description: 'The unique session token',\n readOnly: true,\n },\n },\n {\n name: 'expiresAt',\n type: 'date',\n required: true,\n label: 'Expires At',\n saveToJWT: true,\n admin: {\n description: 'The date and time when the session will expire',\n readOnly: true,\n },\n },\n {\n name: 'ipAddress',\n type: 'text',\n label: 'IP Address',\n saveToJWT: true,\n admin: {\n description: 'The IP address of the device',\n readOnly: true,\n },\n },\n {\n name: 'userAgent',\n type: 'text',\n label: 'User Agent',\n saveToJWT: true,\n admin: {\n description: 'The user agent information of the device',\n readOnly: true,\n },\n },\n ...getTimestampFields(),\n ],\n ...existingSessionCollection,\n }\n if (baPlugins) {\n baPlugins.forEach((plugin) => {\n switch (plugin.id) {\n case 'admin':\n sessionCollection.fields.push({\n name: 'impersonatedBy',\n type: 'relationship',\n relationTo: userSlug,\n required: false,\n label: 'Impersonated By',\n admin: {\n readOnly: true,\n description: 'The admin who is impersonating this session',\n },\n })\n break\n case 'organization':\n sessionCollection.fields.push({\n name: 'activeOrganization',\n type: 'relationship',\n relationTo: betterAuthPluginSlugs.organizations,\n label: 'Active Organization',\n admin: {\n readOnly: true,\n description: 'The currently active organization for the session',\n },\n })\n break\n default:\n break\n }\n })\n }\n\n if (pluginOptions.sessions?.collectionOverrides) {\n sessionCollection = pluginOptions.sessions.collectionOverrides({\n collection: sessionCollection,\n })\n }\n\n enhancedCollections.push(sessionCollection)\n break\n case baseCollectionSlugs.verifications:\n const existingVerificationCollection = incomingCollections.find(\n (collection) => collection.slug === verificationSlug,\n )\n const verificationCollection: CollectionConfig = {\n slug: verificationSlug,\n admin: {\n ...existingVerificationCollection?.admin,\n hidden: pluginOptions.verifications?.hidden,\n useAsTitle: 'identifier',\n description: 'Verifications are used to verify authentication requests',\n },\n fields: [\n ...(existingVerificationCollection?.fields ?? []),\n {\n name: 'identifier',\n type: 'text',\n required: true,\n index: true,\n label: 'Identifier',\n admin: {\n description: 'The identifier of the verification request',\n readOnly: true,\n },\n },\n {\n name: 'value',\n type: 'text',\n required: true,\n label: 'Value',\n admin: {\n description: 'The value to be verified',\n readOnly: true,\n },\n },\n {\n name: 'expiresAt',\n type: 'date',\n required: true,\n label: 'Expires At',\n admin: {\n description: 'The date and time when the verification request will expire',\n readOnly: true,\n },\n },\n ],\n timestamps: true,\n ...existingVerificationCollection,\n }\n enhancedCollections.push(verificationCollection)\n break\n case betterAuthPluginSlugs.organizations:\n const organizationCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.organizations,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'name',\n description:\n 'Organizations are groups of users that share access to certain resources.',\n },\n fields: [\n {\n name: 'name',\n type: 'text',\n required: true,\n label: 'Name',\n admin: {\n description: 'The name of the organization.',\n },\n },\n {\n name: 'slug',\n type: 'text',\n unique: true,\n index: true,\n label: 'Slug',\n admin: {\n description: 'The slug of the organization.',\n },\n },\n {\n name: 'logo',\n type: 'text',\n label: 'Logo',\n admin: {\n description: 'The logo of the organization.',\n },\n },\n {\n name: 'metadata',\n type: 'json',\n label: 'Metadata',\n admin: {\n description: 'Additional metadata for the organization.',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(organizationCollection)\n break\n case betterAuthPluginSlugs.members:\n const memberCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.members,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'organization',\n description: 'Members of an organization.',\n },\n fields: [\n {\n name: 'organization',\n type: 'relationship',\n relationTo: betterAuthPluginSlugs.organizations,\n required: true,\n index: true,\n label: 'Organization',\n admin: {\n readOnly: true,\n description: 'The organization that the member belongs to.',\n },\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n index: true,\n label: 'User',\n admin: {\n readOnly: true,\n description: 'The user that is a member of the organization.',\n },\n },\n {\n name: 'team',\n type: 'relationship',\n relationTo: betterAuthPluginSlugs.teams,\n required: false,\n label: 'Team',\n admin: {\n description: 'The team that the member belongs to.',\n },\n },\n {\n name: 'role',\n type: 'text',\n required: true,\n defaultValue: 'member',\n label: 'Role',\n admin: {\n description: 'The role of the member in the organization.',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(memberCollection)\n break\n case betterAuthPluginSlugs.invitations:\n const invitationCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.invitations,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'email',\n description: 'Invitations to join an organization',\n },\n fields: [\n {\n name: 'email',\n type: 'text',\n required: true,\n index: true,\n label: 'Email',\n admin: {\n description: 'The email of the user being invited.',\n readOnly: true,\n },\n },\n {\n name: 'inviter',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n label: 'Inviter',\n admin: {\n description: 'The user who invited the user.',\n readOnly: true,\n },\n },\n {\n name: 'organization',\n type: 'relationship',\n relationTo: betterAuthPluginSlugs.organizations,\n required: true,\n index: true,\n label: 'Organization',\n admin: {\n description: 'The organization that the user is being invited to.',\n readOnly: true,\n },\n },\n {\n name: 'role',\n type: 'text',\n required: true,\n label: 'Role',\n admin: {\n description: 'The role of the user being invited.',\n readOnly: true,\n },\n },\n {\n name: 'status',\n type: 'text',\n required: true,\n defaultValue: 'pending',\n label: 'Status',\n admin: {\n description: 'The status of the invitation.',\n readOnly: true,\n },\n },\n {\n name: 'expiresAt',\n type: 'date',\n required: true,\n label: 'Expires At',\n admin: {\n description: 'The date and time when the invitation will expire.',\n readOnly: true,\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(invitationCollection)\n break\n case betterAuthPluginSlugs.teams:\n const teamCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.teams,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'name',\n description: 'Teams are groups of users that share access to certain resources.',\n },\n fields: [\n {\n name: 'name',\n type: 'text',\n required: true,\n label: 'Name',\n admin: {\n description: 'The name of the team.',\n },\n },\n {\n name: 'organization',\n type: 'relationship',\n relationTo: betterAuthPluginSlugs.organizations,\n required: true,\n label: 'Organization',\n admin: {\n readOnly: true,\n description: 'The organization that the team belongs to.',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(teamCollection)\n break\n case betterAuthPluginSlugs.jwks:\n const jwksCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.jwks,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'publicKey',\n description: 'JWKS are used to verify the signature of the JWT token',\n },\n fields: [\n {\n name: 'publicKey',\n type: 'text',\n required: true,\n index: true,\n label: 'Public Key',\n admin: {\n description: 'The public part of the web key',\n },\n },\n {\n name: 'privateKey',\n type: 'text',\n required: true,\n label: 'Private Key',\n admin: {\n description: 'The private part of the web key',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(jwksCollection)\n break\n case betterAuthPluginSlugs.apiKeys:\n const apiKeyCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.apiKeys,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'name',\n description: 'API keys are used to authenticate requests to the API.',\n },\n fields: [\n {\n name: 'name',\n type: 'text',\n label: 'Name',\n admin: {\n readOnly: true,\n description: 'The name of the API key.',\n },\n },\n {\n name: 'start',\n type: 'text',\n label: 'Starting Characters',\n admin: {\n readOnly: true,\n description:\n 'The starting characters of the API key. Useful for showing the first few characters of the API key in the UI for the users to easily identify.',\n },\n },\n {\n name: 'prefix',\n type: 'text',\n label: 'Prefix',\n admin: {\n readOnly: true,\n description: 'The API Key prefix. Stored as plain text.',\n },\n },\n {\n name: 'key',\n type: 'text',\n required: true,\n label: 'API Key',\n admin: {\n readOnly: true,\n description: 'The hashed API key itself.',\n },\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n label: 'User',\n admin: {\n readOnly: true,\n description: 'The user associated with the API key.',\n },\n },\n {\n name: 'refillInterval',\n type: 'number',\n label: 'Refill Interval',\n admin: {\n readOnly: true,\n description: 'The interval to refill the key in milliseconds.',\n },\n },\n {\n name: 'refillAmount',\n type: 'number',\n label: 'Refill Amount',\n admin: {\n readOnly: true,\n description: 'The amount to refill the remaining count of the key.',\n },\n },\n {\n name: 'lastRefillAt',\n type: 'date',\n label: 'Last Refill At',\n admin: {\n readOnly: true,\n description: 'The date and time when the key was last refilled.',\n },\n },\n {\n name: 'enabled',\n type: 'checkbox',\n defaultValue: true,\n label: 'Enabled',\n admin: {\n readOnly: true,\n description: 'Whether the API key is enabled.',\n },\n },\n {\n name: 'rateLimitEnabled',\n type: 'checkbox',\n defaultValue: true,\n label: 'Rate Limit Enabled',\n admin: {\n readOnly: true,\n description: 'Whether the API key has rate limiting enabled.',\n },\n },\n {\n name: 'rateLimitTimeWindow',\n type: 'number',\n label: 'Rate Limit Time Window',\n admin: {\n readOnly: true,\n description: 'The time window in milliseconds for the rate limit.',\n },\n },\n {\n name: 'rateLimitMax',\n type: 'number',\n label: 'The maximum number of requests allowed within the `rateLimitTimeWindow`.',\n admin: {\n readOnly: true,\n description:\n 'The maximum number of requests allowed within the rate limit time window.',\n },\n },\n {\n name: 'requstCount',\n type: 'number',\n label: 'Request Count',\n required: true,\n admin: {\n readOnly: true,\n description: 'The number of requests made within the rate limit time window.',\n },\n },\n {\n name: 'remaining',\n type: 'number',\n label: 'Remaining Requests',\n admin: {\n readOnly: true,\n description: 'The number of requests remaining.',\n },\n },\n {\n name: 'lastRequest',\n type: 'date',\n label: 'Last Request At',\n admin: {\n readOnly: true,\n description: 'The date and time of the last request made to the key.',\n },\n },\n {\n name: 'expiresAt',\n type: 'date',\n label: 'Expires At',\n admin: {\n readOnly: true,\n description: 'The date and time of when the API key will expire.',\n },\n },\n {\n name: 'permissions',\n type: 'text',\n label: 'Permissions',\n admin: {\n readOnly: true,\n description: 'The permissions for the API key.',\n },\n },\n {\n name: 'metadata',\n type: 'json',\n label: 'Metadata',\n admin: {\n readOnly: true,\n description: 'Any additional metadata you want to store with the key.',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(apiKeyCollection)\n break\n case betterAuthPluginSlugs.twoFactors:\n const twoFactorCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.twoFactors,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'secret',\n description: 'Two factor authentication secrets',\n },\n fields: [\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n label: 'User',\n admin: {\n readOnly: true,\n description: 'The user that the two factor authentication secret belongs to',\n },\n },\n {\n name: 'secret',\n type: 'text',\n label: 'Secret',\n index: true,\n admin: {\n readOnly: true,\n description: 'The secret used to generate the TOTP code.',\n },\n },\n {\n name: 'backupCodes',\n type: 'text',\n required: true,\n label: 'Backup Codes',\n admin: {\n readOnly: true,\n description:\n 'The backup codes used to recover access to the account if the user loses access to their phone or email',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(twoFactorCollection)\n break\n case betterAuthPluginSlugs.oauthAccessTokens:\n const oauthAccessTokenCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.oauthAccessTokens,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'accessToken',\n description: 'OAuth access tokens for custom OAuth clients',\n },\n fields: [\n {\n name: 'accessToken',\n type: 'text',\n required: true,\n index: true,\n label: 'Access Token',\n admin: {\n readOnly: true,\n description: 'Access token issued to the client',\n },\n },\n {\n name: 'refreshToken',\n type: 'text',\n required: true,\n label: 'Refresh Token',\n admin: {\n readOnly: true,\n description: 'Refresh token issued to the client',\n },\n },\n {\n name: 'accessTokenExpiresAt',\n type: 'date',\n required: true,\n label: 'Access Token Expires At',\n admin: {\n readOnly: true,\n description: 'Expiration date of the access token',\n },\n },\n {\n name: 'refreshTokenExpiresAt',\n type: 'date',\n required: true,\n label: 'Refresh Token Expires At',\n admin: {\n readOnly: true,\n description: 'Expiration date of the refresh token',\n },\n },\n {\n name: 'client',\n type: 'relationship',\n relationTo: betterAuthPluginSlugs.oauthApplications,\n required: true,\n label: 'Client',\n admin: {\n readOnly: true,\n description: 'OAuth application associated with the access token',\n },\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n label: 'User',\n admin: {\n readOnly: true,\n description: 'User associated with the access token',\n },\n },\n {\n name: 'scopes',\n type: 'text',\n required: true,\n label: 'Scopes',\n admin: {\n description: 'Comma-separated list of scopes granted',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(oauthAccessTokenCollection)\n break\n case betterAuthPluginSlugs.oauthApplications:\n const oauthApplicationCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.oauthApplications,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'name',\n description: 'OAuth applications are custom OAuth clients',\n },\n fields: [\n {\n name: 'clientId',\n type: 'text',\n unique: true,\n index: true,\n required: true,\n label: 'Client ID',\n admin: {\n readOnly: true,\n description: 'Unique identifier for each OAuth client',\n },\n },\n {\n name: 'clientSecret',\n type: 'text',\n required: true,\n label: 'Client Secret',\n admin: {\n readOnly: true,\n description: 'Secret key for the OAuth client',\n },\n },\n {\n name: 'name',\n type: 'text',\n required: true,\n index: true,\n label: 'Name',\n admin: {\n description: 'Name of the OAuth application',\n },\n },\n {\n name: 'redirectURLs',\n type: 'text',\n required: true,\n label: 'Redirect URLs',\n admin: {\n description: 'Comma-separated list of redirect URLs',\n },\n },\n {\n name: 'metadata',\n type: 'json',\n admin: {\n readOnly: true,\n description: 'Additional metadata for the OAuth application',\n },\n },\n {\n name: 'type',\n type: 'text',\n required: true,\n label: 'Type',\n admin: {\n readOnly: true,\n description: 'Type of OAuth client (e.g., web, mobile)',\n },\n },\n {\n name: 'disabled',\n type: 'checkbox',\n defaultValue: false,\n required: true,\n label: 'Disabled',\n admin: {\n description: 'Indicates if the client is disabled',\n },\n },\n {\n name: 'icon',\n type: 'text',\n label: 'Icon',\n admin: {\n description: 'Icon of the OAuth application',\n },\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: false,\n label: 'User',\n admin: {\n readOnly: true,\n description: 'ID of the user who owns the client. (optional)',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(oauthApplicationCollection)\n break\n case betterAuthPluginSlugs.oauthConsents:\n const oauthConsentCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.oauthConsents,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n description: 'OAuth consents are used to store user consents for OAuth clients',\n },\n fields: [\n {\n name: 'client',\n type: 'relationship',\n relationTo: betterAuthPluginSlugs.oauthApplications,\n required: true,\n label: 'Client',\n admin: {\n readOnly: true,\n description: 'OAuth client associated with the consent',\n },\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n label: 'User',\n admin: {\n readOnly: true,\n description: 'User associated with the consent',\n },\n },\n {\n name: 'scopes',\n type: 'text',\n required: true,\n label: 'Scopes',\n admin: {\n readOnly: true,\n description: 'Comma-separated list of scopes consented to',\n },\n },\n {\n name: 'consentGiven',\n type: 'checkbox',\n defaultValue: false,\n required: true,\n label: 'Consent Given',\n admin: {\n readOnly: true,\n description: '\tIndicates if consent was given',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(oauthConsentCollection)\n break\n case betterAuthPluginSlugs.passkeys:\n const passkeyCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.passkeys,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'name',\n description: 'Passkeys are used to authenticate users',\n },\n fields: [\n {\n name: 'name',\n type: 'text',\n label: 'Name',\n admin: {\n readOnly: true,\n description: 'The name of the passkey',\n },\n },\n {\n name: 'publicKey',\n type: 'text',\n required: true,\n index: true,\n label: 'Public Key',\n admin: {\n readOnly: true,\n description: 'The public key of the passkey',\n },\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n index: true,\n label: 'User',\n admin: {\n readOnly: true,\n description: 'The user that the passkey belongs to',\n },\n },\n {\n name: 'credentialID',\n type: 'text',\n required: true,\n unique: true,\n label: 'Credential ID',\n admin: {\n readOnly: true,\n description: 'The unique identifier of the registered credential',\n },\n },\n {\n name: 'counter',\n type: 'number',\n required: true,\n label: 'Counter',\n admin: {\n readOnly: true,\n description: 'The counter of the passkey',\n },\n },\n {\n name: 'deviceType',\n type: 'text',\n required: true,\n label: 'Device Type',\n admin: {\n readOnly: true,\n description: 'The type of device used to register the passkey',\n },\n },\n {\n name: 'backedUp',\n type: 'checkbox',\n required: true,\n label: 'Backed Up',\n admin: {\n readOnly: true,\n description: 'Whether the passkey is backed up',\n },\n },\n {\n name: 'transports',\n type: 'text',\n required: true,\n label: 'Transports',\n admin: {\n readOnly: true,\n description: 'The transports used to register the passkey',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(passkeyCollection)\n break\n case betterAuthPluginSlugs.ssoProviders:\n const ssoProviderCollection: CollectionConfig = {\n slug: betterAuthPluginSlugs.ssoProviders,\n admin: {\n hidden: pluginOptions.hidePluginCollections ?? false,\n useAsTitle: 'issuer',\n description: 'SSO providers are used to authenticate users with an external provider',\n },\n fields: [\n {\n name: 'issuer',\n type: 'text',\n required: true,\n index: true,\n label: 'Issuer',\n admin: {\n description: 'The issuer of the SSO provider',\n },\n },\n {\n name: 'domain',\n type: 'text',\n required: true,\n label: 'Domain',\n admin: {\n description: 'The domain of the SSO provider',\n },\n },\n {\n name: 'oidcConfig',\n type: 'text',\n required: true,\n label: 'OIDC Config',\n admin: {\n description: 'The OIDC config of the SSO provider',\n },\n },\n {\n name: 'user',\n type: 'relationship',\n relationTo: userSlug,\n required: true,\n label: 'User',\n admin: {\n description: 'The user associated with the SSO provider',\n },\n },\n {\n name: 'providerId',\n type: 'text',\n required: true,\n label: 'Provider ID',\n admin: {\n readOnly: true,\n description:\n 'The provider id. Used to identify a provider and to generate a redirect url',\n },\n },\n {\n name: 'organizationId',\n type: 'text',\n required: true,\n label: 'Organization ID',\n admin: {\n readOnly: true,\n description: 'The organization Id. If provider is linked to an organization',\n },\n },\n ],\n timestamps: true,\n }\n enhancedCollections.push(ssoProviderCollection)\n break\n default:\n break\n }\n })\n\n const restOfCollections = incomingCollections.filter((collection) => {\n return !enhancedCollections.some(\n (enhancedCollection) => enhancedCollection.slug === collection.slug,\n )\n })\n\n return [...enhancedCollections, ...restOfCollections]\n}\n"],"names":["baseCollectionSlugs","betterAuthPluginSlugs","betterAuthStrategy","getAfterLogoutHook","getRefreshTokenEndpoint","isAdminOrCurrentUserUpdateWithAllowedFields","isAdminOrCurrentUserWithRoles","isAdminWithRoles","cleanUpUserAfterDelete","getSyncPasswordToUserHook","getSyncAccountHook","onVerifiedChange","getAfterLoginHook","getBeforeLoginHook","buildCollectionConfigs","incomingCollections","requiredCollectionSlugs","pluginOptions","sanitizedBAOptions","userSlug","users","slug","accountSlug","accounts","sessionSlug","sessions","verificationSlug","verifications","baPlugins","plugins","adminRoles","getTimestampFields","saveUpdatedAtToJWT","saveCreatedAtToJWT","name","type","saveToJWT","admin","disableBulkEdit","hidden","index","label","t","enhancedCollections","forEach","existingUserCollection","find","collection","allowedFields","usersCollection","defaultColumns","useAsTitle","access","req","includes","user","role","read","idField","create","delete","update","endpoints","hooks","beforeChange","afterChange","beforeLogin","afterLogin","sessionsCollectionSlug","usersCollectionSlug","afterLogout","afterDelete","args","auth","strategies","fields","position","components","Field","path","clientProps","condition","some","plugin","id","description","required","unique","defaultValue","options","roles","value","map","charAt","toUpperCase","slice","push","readOnly","collectionOverrides","existingAccountCollection","accountCollection","relationTo","existingSessionCollection","sessionCollection","organizations","existingVerificationCollection","verificationCollection","timestamps","organizationCollection","hidePluginCollections","members","memberCollection","teams","invitations","invitationCollection","teamCollection","jwks","jwksCollection","apiKeys","apiKeyCollection","twoFactors","twoFactorCollection","oauthAccessTokens","oauthAccessTokenCollection","oauthApplications","oauthApplicationCollection","oauthConsents","oauthConsentCollection","passkeys","passkeyCollection","ssoProviders","ssoProviderCollection","restOfCollections","filter","enhancedCollection"],"mappings":"AACA,SAASA,mBAAmB,EAAEC,qBAAqB,QAAQ,WAAU;AACrE,SAASC,kBAAkB,QAAQ,kBAAiB;AACpD,SAASC,kBAAkB,QAAQ,0CAAyC;AAC5E,SAASC,uBAAuB,QAAQ,+CAA8C;AACtF,SACEC,2CAA2C,EAC3CC,6BAA6B,EAC7BC,gBAAgB,QACX,mBAAkB;AACzB,SAASC,sBAAsB,QAAQ,wDAAuD;AAC9F,SAASC,yBAAyB,QAAQ,sDAAqD;AAC/F,SAASC,kBAAkB,QAAQ,0CAAyC;AAC5E,SAASC,gBAAgB,QAAQ,gDAA+C;AAChF,SAASC,iBAAiB,QAAQ,yCAAwC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I,CAC9B,CAACoD,qBAAuBA,mBAAmBjH,IAAI,KAAK0B,WAAW1B,IAAI;IAEvE;IAEA,OAAO;WAAIsB;WAAwByF;KAAkB;AACvD"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/config.ts"],"sourcesContent":["export const supportedBetterAuthPluginIds = {\n harmonyEmail: 'harmony-email',\n harmonyPhoneNumber: 'harmony-phone-number',\n twoFactor: 'two-factor',\n username: 'username',\n anonymous: 'anonymous',\n phoneNumber: 'phone-number',\n magicLink: 'magic-link',\n emailOtp: 'email-otp',\n passkey: 'passkey',\n oneTap: 'one-tap',\n admin: 'admin',\n apiKey: 'api-key',\n organization: 'organization',\n multiSession: 'multi-session',\n openApi: 'open-api',\n jwt: 'jwt',\n nextCookies: 'next-cookies',\n sso: 'sso',\n oidc: 'oidc',\n} as const\n\nexport const baseCollectionSlugs = {\n users: 'users',\n sessions: 'sessions',\n accounts: 'accounts',\n verifications: 'verifications',\n} as const\n\nexport const betterAuthPluginSlugs = {\n apiKeys: 'apiKeys',\n jwks: 'jwks',\n twoFactors: 'twoFactors',\n passkeys: 'passkeys',\n oauthApplications: 'oauthApplications',\n oauthAccessTokens: 'oauthAccessTokens',\n oauthConsents: 'oauthConsents',\n ssoProviders: 'ssoProviders',\n organizations: 'organizations',\n invitations: 'invitations',\n members: 'members',\n teams: 'teams',\n} as const\n"],"names":["supportedBetterAuthPluginIds","harmonyEmail","harmonyPhoneNumber","twoFactor","username","anonymous","phoneNumber","magicLink","emailOtp","passkey","oneTap","admin","apiKey","organization","multiSession","openApi","jwt","nextCookies","sso","oidc","baseCollectionSlugs","users","sessions","accounts","verifications","betterAuthPluginSlugs","apiKeys","jwks","twoFactors","passkeys","oauthApplications","oauthAccessTokens","oauthConsents","ssoProviders","organizations","invitations","members","teams"],"mappings":"AAAA,OAAO,MAAMA,+BAA+B;IAC1CC,cAAc;IACdC,oBAAoB;IACpBC,WAAW;IACXC,UAAU;IACVC,WAAW;IACXC,aAAa;IACbC,WAAW;IACXC,UAAU;IACVC,SAAS;IACTC,QAAQ;IACRC,OAAO;IACPC,QAAQ;IACRC,cAAc;IACdC,cAAc;IACdC,SAAS;IACTC,KAAK;IACLC,aAAa;IACbC,KAAK;IACLC,MAAM;AACR,EAAU;AAEV,OAAO,MAAMC,sBAAsB;IACjCC,OAAO;IACPC,UAAU;IACVC,UAAU;IACVC,eAAe;AACjB,EAAU;AAEV,OAAO,MAAMC,wBAAwB;IACnCC,SAAS;IACTC,MAAM;IACNC,YAAY;IACZC,UAAU;IACVC,mBAAmB;IACnBC,mBAAmB;IACnBC,eAAe;IACfC,cAAc;IACdC,eAAe;IACfC,aAAa;IACbC,SAAS;IACTC,OAAO;AACT,EAAU"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/ensure-password-set-before-create.ts"],"sourcesContent":["import type { SanitizedBetterAuthOptions } from '..'\n\n/**\n * Adds a before hook to the user create operation to ensure the password is set.\n * This is necessary because the password is not set in the user create operation\n * and is instead set in the sync password accounts hook.\n */\nexport function ensurePasswordSetBeforeUserCreate(options: SanitizedBetterAuthOptions) {\n if (typeof options.databaseHooks !== 'object') options.databaseHooks = {}\n if (typeof options.databaseHooks.user !== 'object') options.databaseHooks.user = {}\n if (typeof options.databaseHooks.user.create !== 'object') options.databaseHooks.user.create = {}\n const initialBeforeUserCreateHook = options.databaseHooks.user.create.before ?? null\n\n options.databaseHooks.user.create.before = async (user, ctx) => {\n if (!(user as any).password) {\n ;(user as any).password =\n ctx?.body?.password ??\n Array(3)\n .fill(0)\n .map(() => Math.random().toString(36).slice(2))\n .join('')\n }\n if (typeof initialBeforeUserCreateHook === 'function') {\n return initialBeforeUserCreateHook(user, ctx)\n }\n return { data: user }\n }\n}\n"],"names":["ensurePasswordSetBeforeUserCreate","options","databaseHooks","user","create","initialBeforeUserCreateHook","before","ctx","password","body","Array","fill","map","Math","random","toString","slice","join","data"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,SAASA,kCAAkCC,OAAmC;IACnF,IAAI,OAAOA,QAAQC,aAAa,KAAK,UAAUD,QAAQC,aAAa,GAAG,CAAC;IACxE,IAAI,OAAOD,QAAQC,aAAa,CAACC,IAAI,KAAK,UAAUF,QAAQC,aAAa,CAACC,IAAI,GAAG,CAAC;IAClF,IAAI,OAAOF,QAAQC,aAAa,CAACC,IAAI,CAACC,MAAM,KAAK,UAAUH,QAAQC,aAAa,CAACC,IAAI,CAACC,MAAM,GAAG,CAAC;IAChG,MAAMC,8BAA8BJ,QAAQC,aAAa,CAACC,IAAI,CAACC,MAAM,CAACE,MAAM,IAAI;IAEhFL,QAAQC,aAAa,CAACC,IAAI,CAACC,MAAM,CAACE,MAAM,GAAG,OAAOH,MAAMI;QACtD,IAAI,CAAC,AAACJ,KAAaK,QAAQ,EAAE;;YACzBL,KAAaK,QAAQ,GACrBD,KAAKE,MAAMD,YACXE,MAAM,GACHC,IAAI,CAAC,GACLC,GAAG,CAAC,IAAMC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,KAAK,CAAC,IAC3CC,IAAI,CAAC;QACZ;QACA,IAAI,OAAOZ,gCAAgC,YAAY;YACrD,OAAOA,4BAA4BF,MAAMI;QAC3C;QACA,OAAO;YAAEW,MAAMf;QAAK;IACtB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/get-payload-auth.ts"],"sourcesContent":["import type { BasePayload, SanitizedConfig } from 'payload'\nimport { BetterAuthReturn, TPlugins } from '../types'\nimport { getPayload } from 'payload'\nexport async function getPayloadAuth<P extends TPlugins>(\n config: Promise<SanitizedConfig> | SanitizedConfig,\n): Promise<BasePayload & { betterAuth: BetterAuthReturn<P> }> {\n const payload = (await getPayload({ config })) as BasePayload & {\n betterAuth: BetterAuthReturn<P>\n }\n return payload\n}\n"],"names":["getPayload","getPayloadAuth","config","payload"],"mappings":"AAEA,SAASA,UAAU,QAAQ,UAAS;AACpC,OAAO,eAAeC,eACpBC,MAAkD;IAElD,MAAMC,UAAW,MAAMH,WAAW;QAAEE;IAAO;IAG3C,OAAOC;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/get-required-collection-slugs.ts"],"sourcesContent":["import { getAuthTables } from 'better-auth/db'\nimport type { PayloadBetterAuthPluginOptions, SanitizedBetterAuthOptions } from '..'\n\n/**\n * Determines which collections are required based on the BetterAuth options and plugins\n */\nexport function getRequiredCollectionSlugs({\n logTables,\n pluginOptions,\n sanitizedBAOptions,\n}: {\n logTables: boolean\n pluginOptions: PayloadBetterAuthPluginOptions\n sanitizedBAOptions: SanitizedBetterAuthOptions\n}) {\n // Always include the base required collections (User, Account, Session, Verification)\n const userCollectionSlug = pluginOptions.users?.slug ?? 'users'\n const accountCollectionSlug = pluginOptions.accounts?.slug ?? 'accounts'\n const sessionCollectionSlug = pluginOptions.sessions?.slug ?? 'sessions'\n const verificationCollectionSlug = pluginOptions.verifications?.slug ?? 'verifications'\n\n const requiredCollectionSlugs = new Set([\n userCollectionSlug,\n accountCollectionSlug,\n sessionCollectionSlug,\n verificationCollectionSlug,\n ])\n\n // If we have better auth options, use getAuthTables to determine additional tables needed\n if (sanitizedBAOptions) {\n try {\n // Get the tables required by the auth configuration\n const tables = getAuthTables({\n ...sanitizedBAOptions,\n })\n\n const plugins = sanitizedBAOptions.plugins ?? []\n if (logTables) {\n console.log(\n 'Better Auth plugins:',\n plugins.map((plugin) => plugin.id),\n )\n console.log(\n 'Better Auth tables required:',\n Object.keys(tables).map((key) => tables[key].modelName),\n )\n }\n\n // Add all table slugs to the required collections set\n Object.values(tables).forEach((table) => {\n if (table.modelName) {\n requiredCollectionSlugs.add(table.modelName)\n }\n })\n } catch (error) {\n console.error('Error determining required auth tables:', error)\n console.warn('Falling back to base collections only')\n\n // Log the plugins that were attempted to be used\n if (sanitizedBAOptions.plugins?.length ?? 0 > 0) {\n console.warn(\n 'Plugins that may have caused the error:',\n sanitizedBAOptions.plugins?.map((plugin) => {\n // Type-safe way to get plugin identification\n return typeof plugin === 'object' && plugin !== null && 'name' in plugin\n ? plugin.name\n : 'unnamed plugin'\n }),\n )\n }\n }\n }\n\n // if (enable_debug_logs) {\n // console.log('Required collection slugs: ', Array.from(requiredCollectionSlugs))\n // }\n\n return requiredCollectionSlugs\n}\n"],"names":["getAuthTables","getRequiredCollectionSlugs","logTables","pluginOptions","sanitizedBAOptions","userCollectionSlug","users","slug","accountCollectionSlug","accounts","sessionCollectionSlug","sessions","verificationCollectionSlug","verifications","requiredCollectionSlugs","Set","tables","plugins","console","log","map","plugin","id","Object","keys","key","modelName","values","forEach","table","add","error","warn","length","name"],"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAgB;AAG9C;;CAEC,GACD,OAAO,SAASC,2BAA2B,EACzCC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAKnB;IACC,sFAAsF;IACtF,MAAMC,qBAAqBF,cAAcG,KAAK,EAAEC,QAAQ;IACxD,MAAMC,wBAAwBL,cAAcM,QAAQ,EAAEF,QAAQ;IAC9D,MAAMG,wBAAwBP,cAAcQ,QAAQ,EAAEJ,QAAQ;IAC9D,MAAMK,6BAA6BT,cAAcU,aAAa,EAAEN,QAAQ;IAExE,MAAMO,0BAA0B,IAAIC,IAAI;QACtCV;QACAG;QACAE;QACAE;KACD;IAED,0FAA0F;IAC1F,IAAIR,oBAAoB;QACtB,IAAI;YACF,oDAAoD;YACpD,MAAMY,SAAShB,cAAc;gBAC3B,GAAGI,kBAAkB;YACvB;YAEA,MAAMa,UAAUb,mBAAmBa,OAAO,IAAI,EAAE;YAChD,IAAIf,WAAW;gBACbgB,QAAQC,GAAG,CACT,wBACAF,QAAQG,GAAG,CAAC,CAACC,SAAWA,OAAOC,EAAE;gBAEnCJ,QAAQC,GAAG,CACT,gCACAI,OAAOC,IAAI,CAACR,QAAQI,GAAG,CAAC,CAACK,MAAQT,MAAM,CAACS,IAAI,CAACC,SAAS;YAE1D;YAEA,sDAAsD;YACtDH,OAAOI,MAAM,CAACX,QAAQY,OAAO,CAAC,CAACC;gBAC7B,IAAIA,MAAMH,SAAS,EAAE;oBACnBZ,wBAAwBgB,GAAG,CAACD,MAAMH,SAAS;gBAC7C;YACF;QACF,EAAE,OAAOK,OAAO;YACdb,QAAQa,KAAK,CAAC,2CAA2CA;YACzDb,QAAQc,IAAI,CAAC;YAEb,iDAAiD;YACjD,IAAI5B,mBAAmBa,OAAO,EAAEgB,UAAU,IAAI,GAAG;gBAC/Cf,QAAQc,IAAI,CACV,2CACA5B,mBAAmBa,OAAO,EAAEG,IAAI,CAACC;oBAC/B,6CAA6C;oBAC7C,OAAO,OAAOA,WAAW,YAAYA,WAAW,QAAQ,UAAUA,SAC9DA,OAAOa,IAAI,GACX;gBACN;YAEJ;QACF;IACF;IAEA,2BAA2B;IAC3B,oFAAoF;IACpF,IAAI;IAEJ,OAAOpB;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/init-better-auth.ts"],"sourcesContent":["import { betterAuth } from \"better-auth\"\nimport { BetterAuthFunctionOptions, BetterAuthReturn, TPlugins } from \"../types\"\nimport { BasePayload } from \"payload\"\nimport { payloadAdapter } from \"payload-auth/better-auth/adapter\"\n\nexport function initBetterAuth<P extends TPlugins>({\n payload,\n options,\n}: {\n payload: BasePayload\n options: BetterAuthFunctionOptions<P>\n}): BetterAuthReturn<P> {\n const auth = betterAuth({\n ...options,\n database: payloadAdapter(payload, {\n enableDebugLogs: options.enableDebugLogs ?? false,\n }),\n })\n\n return auth as unknown as BetterAuthReturn<P>\n}\n"],"names":["betterAuth","payloadAdapter","initBetterAuth","payload","options","auth","database","enableDebugLogs"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAa;AAGxC,SAASC,cAAc,QAAQ,mCAAkC;AAEjE,OAAO,SAASC,eAAmC,EACjDC,OAAO,EACPC,OAAO,EAIR;IACC,MAAMC,OAAOL,WAAW;QACtB,GAAGI,OAAO;QACVE,UAAUL,eAAeE,SAAS;YAChCI,iBAAiBH,QAAQG,eAAe,IAAI;QAC9C;IACF;IAEA,OAAOF;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/password.ts"],"sourcesContent":["import crypto from 'crypto'\n\n/**\n * Mimics Payload's internal password hashing using pbkdf2\n *\n * This generates a hash compatible with Payload's internal auth system\n * so that passwords set via better-auth can be used with Payload admin panel\n */\nfunction pbkdf2Promisified(password: string, salt: string): Promise<Buffer> {\n return new Promise((resolve, reject) =>\n crypto.pbkdf2(password, salt, 25000, 512, 'sha256', (err, hashRaw) =>\n err ? reject(err) : resolve(hashRaw),\n ),\n )\n}\n\n/**\n * Generates random bytes for the salt\n */\nfunction randomBytes(): Promise<Buffer> {\n return new Promise((resolve, reject) =>\n crypto.randomBytes(32, (err, saltBuffer) => (err ? reject(err) : resolve(saltBuffer))),\n )\n}\n\n/**\n * Custom implementation of password hashing that matches Payload's format\n *\n * Instead of using better-auth's scrypt, this uses pbkdf2 with the same\n * parameters as Payload CMS\n *\n * @param password The password to hash\n * @returns A string in the format {salt}:{hash}\n */\nexport const hashPassword = async (password: string): Promise<string> => {\n const saltBuffer = await randomBytes()\n const salt = saltBuffer.toString('hex')\n\n const hashRaw = await pbkdf2Promisified(password, salt)\n const hash = hashRaw.toString('hex')\n\n return `${salt}:${hash}`\n}\n\n/**\n * Verifies a password against a stored hash\n *\n * This function is flexible and can handle:\n * 1. A combined string in format {salt}:{hash} (for account passwords)\n * 2. When salt and hash need to be combined from user records\n *\n * @param params Object containing the hash and password\n * @returns Boolean indicating if the password matches\n */\nexport const verifyPassword = async ({\n hash,\n password,\n salt,\n}: {\n hash: string\n password: string\n salt?: string\n}): Promise<boolean> => {\n let saltValue: string\n let storedHash: string\n\n // If salt is provided separately (from user record), use it with the hash\n if (salt) {\n saltValue = salt\n storedHash = hash\n } else {\n // Otherwise, split the combined format (from account.password)\n const parts = hash.split(':')\n if (parts.length !== 2) {\n return false\n }\n ;[saltValue, storedHash] = parts\n }\n\n if (!saltValue || !storedHash) {\n return false\n }\n\n const hashRaw = await pbkdf2Promisified(password, saltValue)\n const computedHash = hashRaw.toString('hex')\n\n return storedHash === computedHash\n}\n"],"names":["crypto","pbkdf2Promisified","password","salt","Promise","resolve","reject","pbkdf2","err","hashRaw","randomBytes","saltBuffer","hashPassword","toString","hash","verifyPassword","saltValue","storedHash","parts","split","length","computedHash"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAE3B;;;;;CAKC,GACD,SAASC,kBAAkBC,QAAgB,EAAEC,IAAY;IACvD,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAC3BN,OAAOO,MAAM,CAACL,UAAUC,MAAM,OAAO,KAAK,UAAU,CAACK,KAAKC,UACxDD,MAAMF,OAAOE,OAAOH,QAAQI;AAGlC;AAEA;;CAEC,GACD,SAASC;IACP,OAAO,IAAIN,QAAQ,CAACC,SAASC,SAC3BN,OAAOU,WAAW,CAAC,IAAI,CAACF,KAAKG,aAAgBH,MAAMF,OAAOE,OAAOH,QAAQM;AAE7E;AAEA;;;;;;;;CAQC,GACD,OAAO,MAAMC,eAAe,OAAOV;IACjC,MAAMS,aAAa,MAAMD;IACzB,MAAMP,OAAOQ,WAAWE,QAAQ,CAAC;IAEjC,MAAMJ,UAAU,MAAMR,kBAAkBC,UAAUC;IAClD,MAAMW,OAAOL,QAAQI,QAAQ,CAAC;IAE9B,OAAO,GAAGV,KAAK,CAAC,EAAEW,MAAM;AAC1B,EAAC;AAED;;;;;;;;;CASC,GACD,OAAO,MAAMC,iBAAiB,OAAO,EACnCD,IAAI,EACJZ,QAAQ,EACRC,IAAI,EAKL;IACC,IAAIa;IACJ,IAAIC;IAEJ,0EAA0E;IAC1E,IAAId,MAAM;QACRa,YAAYb;QACZc,aAAaH;IACf,OAAO;QACL,+DAA+D;QAC/D,MAAMI,QAAQJ,KAAKK,KAAK,CAAC;QACzB,IAAID,MAAME,MAAM,KAAK,GAAG;YACtB,OAAO;QACT;;QACC,CAACJ,WAAWC,WAAW,GAAGC;IAC7B;IAEA,IAAI,CAACF,aAAa,CAACC,YAAY;QAC7B,OAAO;IACT;IAEA,MAAMR,UAAU,MAAMR,kBAAkBC,UAAUc;IAClD,MAAMK,eAAeZ,QAAQI,QAAQ,CAAC;IAEtC,OAAOI,eAAeI;AACxB,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/payload-access.ts"],"sourcesContent":["import type { Access, FieldAccess } from 'payload'\n\nexport type AdminRolesConfig = {\n adminRoles?: string[]\n}\n\nexport type AdminOrCurrentUserConfig = AdminRolesConfig & {\n idField?: string\n}\n\nexport type AdminOrCurrentUserUpdateConfig = AdminOrCurrentUserConfig & {\n allowedFields?: string[]\n userSlug: string\n}\n\nexport const isAdminWithRoles =\n (config: AdminRolesConfig = {}): FieldAccess =>\n ({ req }) => {\n const { adminRoles = ['admin'] } = config\n if (!req?.user || !req.user.role || !adminRoles.includes(req.user.role)) return false\n return true\n }\n\nexport const isAdminOrCurrentUserWithRoles =\n (config: AdminOrCurrentUserConfig = {}): Access =>\n ({ req }) => {\n const { adminRoles = ['admin'], idField = 'id' } = config\n if (isAdminWithRoles({ adminRoles })({ req })) return true\n if (!req?.user) return false\n return {\n [idField]: {\n equals: req?.user?.id,\n },\n }\n }\n\nexport const isAdminOrCurrentUserUpdateWithAllowedFields = (\n config: AdminOrCurrentUserUpdateConfig,\n): Access => {\n return async ({ req, id, data }) => {\n const { adminRoles = ['admin'], allowedFields = [], userSlug, idField = 'id' } = config\n const user = req.user\n\n if (isAdminWithRoles({ adminRoles })({ req })) return true\n\n if (!user) return false\n\n if (user[idField] === id && data) {\n const dataKeys = Object.keys(data)\n\n const hasCurrentPassword = dataKeys.includes('currentPassword')\n const hasPassword = dataKeys.includes('password')\n\n if (hasPassword || hasCurrentPassword) {\n if (!(hasCurrentPassword && hasPassword)) return false\n try {\n if (!user.email) return false\n\n const result = await req.payload.login({\n collection: userSlug,\n data: {\n email: user.email,\n password: data.currentPassword,\n },\n })\n\n if (!result) return false\n\n allowedFields.push('password', 'currentPassword')\n } catch (error) {\n return false\n }\n }\n\n const hasDisallowedField = dataKeys.some((key) => !allowedFields.includes(key))\n\n return !hasDisallowedField\n }\n\n return false\n }\n}\n"],"names":["isAdminWithRoles","config","req","adminRoles","user","role","includes","isAdminOrCurrentUserWithRoles","idField","equals","id","isAdminOrCurrentUserUpdateWithAllowedFields","data","allowedFields","userSlug","dataKeys","Object","keys","hasCurrentPassword","hasPassword","email","result","payload","login","collection","password","currentPassword","push","error","hasDisallowedField","some","key"],"mappings":"AAeA,OAAO,MAAMA,mBACX,CAACC,SAA2B,CAAC,CAAC,GAC9B,CAAC,EAAEC,GAAG,EAAE;QACN,MAAM,EAAEC,aAAa;YAAC;SAAQ,EAAE,GAAGF;QACnC,IAAI,CAACC,KAAKE,QAAQ,CAACF,IAAIE,IAAI,CAACC,IAAI,IAAI,CAACF,WAAWG,QAAQ,CAACJ,IAAIE,IAAI,CAACC,IAAI,GAAG,OAAO;QAChF,OAAO;IACT,EAAC;AAEH,OAAO,MAAME,gCACX,CAACN,SAAmC,CAAC,CAAC,GACtC,CAAC,EAAEC,GAAG,EAAE;QACN,MAAM,EAAEC,aAAa;YAAC;SAAQ,EAAEK,UAAU,IAAI,EAAE,GAAGP;QACnD,IAAID,iBAAiB;YAAEG;QAAW,GAAG;YAAED;QAAI,IAAI,OAAO;QACtD,IAAI,CAACA,KAAKE,MAAM,OAAO;QACvB,OAAO;YACL,CAACI,QAAQ,EAAE;gBACTC,QAAQP,KAAKE,MAAMM;YACrB;QACF;IACF,EAAC;AAEH,OAAO,MAAMC,8CAA8C,CACzDV;IAEA,OAAO,OAAO,EAAEC,GAAG,EAAEQ,EAAE,EAAEE,IAAI,EAAE;QAC7B,MAAM,EAAET,aAAa;YAAC;SAAQ,EAAEU,gBAAgB,EAAE,EAAEC,QAAQ,EAAEN,UAAU,IAAI,EAAE,GAAGP;QACjF,MAAMG,OAAOF,IAAIE,IAAI;QAErB,IAAIJ,iBAAiB;YAAEG;QAAW,GAAG;YAAED;QAAI,IAAI,OAAO;QAEtD,IAAI,CAACE,MAAM,OAAO;QAElB,IAAIA,IAAI,CAACI,QAAQ,KAAKE,MAAME,MAAM;YAChC,MAAMG,WAAWC,OAAOC,IAAI,CAACL;YAE7B,MAAMM,qBAAqBH,SAAST,QAAQ,CAAC;YAC7C,MAAMa,cAAcJ,SAAST,QAAQ,CAAC;YAEtC,IAAIa,eAAeD,oBAAoB;gBACrC,IAAI,CAAEA,CAAAA,sBAAsBC,WAAU,GAAI,OAAO;gBACjD,IAAI;oBACF,IAAI,CAACf,KAAKgB,KAAK,EAAE,OAAO;oBAExB,MAAMC,SAAS,MAAMnB,IAAIoB,OAAO,CAACC,KAAK,CAAC;wBACrCC,YAAYV;wBACZF,MAAM;4BACJQ,OAAOhB,KAAKgB,KAAK;4BACjBK,UAAUb,KAAKc,eAAe;wBAChC;oBACF;oBAEA,IAAI,CAACL,QAAQ,OAAO;oBAEpBR,cAAcc,IAAI,CAAC,YAAY;gBACjC,EAAE,OAAOC,OAAO;oBACd,OAAO;gBACT;YACF;YAEA,MAAMC,qBAAqBd,SAASe,IAAI,CAAC,CAACC,MAAQ,CAAClB,cAAcP,QAAQ,CAACyB;YAE1E,OAAO,CAACF;QACV;QAEA,OAAO;IACT;AACF,EAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/prepare-session-data.ts"],"sourcesContent":["import { getFieldsToSign } from 'payload'\nimport type { Config, Payload } from 'payload'\n\ntype CollectionSlugs = {\n userCollectionSlug: string\n sessionCollectionSlug: string\n}\n\n/**\n * Prepares session data for cookie cache by filtering user and session objects\n * based on the payload configuration's 'saveToJwt' property\n */\nexport async function prepareSessionData({\n newSession,\n payloadConfig,\n collectionSlugs,\n}: {\n newSession: {\n user: any\n session: any\n }\n payloadConfig: Payload['config'] | Config\n collectionSlugs: CollectionSlugs\n}) {\n if (!newSession || !newSession.user) {\n return null\n }\n\n const { userCollectionSlug, sessionCollectionSlug } = collectionSlugs\n\n const userCollection = payloadConfig?.collections?.find((c) => c.slug === userCollectionSlug)\n const sessionCollection = payloadConfig?.collections?.find(\n (c) => c.slug === sessionCollectionSlug,\n )\n\n if (!userCollection) {\n throw new Error(`User collection with slug '${userCollectionSlug}' not found`)\n }\n\n const filteredUser = getFieldsToSign({\n collectionConfig: userCollection,\n email: newSession.user.email,\n user: newSession.user,\n })\n\n let filteredSession = newSession.session\n const isImpersonated = newSession.session.impersonatedBy\n if (sessionCollection && newSession.session) {\n filteredSession = getFieldsToSign({\n collectionConfig: sessionCollection,\n email: newSession.user.email,\n user: newSession.session,\n }) as typeof newSession.session\n\n // getFieldsToSign is meant for auth collections so we remove the email and collection fields\n delete filteredSession.email\n delete filteredSession.collection\n }\n\n if (isImpersonated) {\n filteredSession.impersonatedBy = newSession.session.impersonatedBy\n }\n\n return {\n ...newSession,\n user: filteredUser,\n session: filteredSession,\n }\n}\n"],"names":["getFieldsToSign","prepareSessionData","newSession","payloadConfig","collectionSlugs","user","userCollectionSlug","sessionCollectionSlug","userCollection","collections","find","c","slug","sessionCollection","Error","filteredUser","collectionConfig","email","filteredSession","session","isImpersonated","impersonatedBy","collection"],"mappings":"AAAA,SAASA,eAAe,QAAQ,UAAS;AAQzC;;;CAGC,GACD,OAAO,eAAeC,mBAAmB,EACvCC,UAAU,EACVC,aAAa,EACbC,eAAe,EAQhB;IACC,IAAI,CAACF,cAAc,CAACA,WAAWG,IAAI,EAAE;QACnC,OAAO;IACT;IAEA,MAAM,EAAEC,kBAAkB,EAAEC,qBAAqB,EAAE,GAAGH;IAEtD,MAAMI,iBAAiBL,eAAeM,aAAaC,KAAK,CAACC,IAAMA,EAAEC,IAAI,KAAKN;IAC1E,MAAMO,oBAAoBV,eAAeM,aAAaC,KACpD,CAACC,IAAMA,EAAEC,IAAI,KAAKL;IAGpB,IAAI,CAACC,gBAAgB;QACnB,MAAM,IAAIM,MAAM,CAAC,2BAA2B,EAAER,mBAAmB,WAAW,CAAC;IAC/E;IAEA,MAAMS,eAAef,gBAAgB;QACnCgB,kBAAkBR;QAClBS,OAAOf,WAAWG,IAAI,CAACY,KAAK;QAC5BZ,MAAMH,WAAWG,IAAI;IACvB;IAEA,IAAIa,kBAAkBhB,WAAWiB,OAAO;IACxC,MAAMC,iBAAiBlB,WAAWiB,OAAO,CAACE,cAAc;IACxD,IAAIR,qBAAqBX,WAAWiB,OAAO,EAAE;QAC3CD,kBAAkBlB,gBAAgB;YAChCgB,kBAAkBH;YAClBI,OAAOf,WAAWG,IAAI,CAACY,KAAK;YAC5BZ,MAAMH,WAAWiB,OAAO;QAC1B;QAEA,6FAA6F;QAC7F,OAAOD,gBAAgBD,KAAK;QAC5B,OAAOC,gBAAgBI,UAAU;IACnC;IAEA,IAAIF,gBAAgB;QAClBF,gBAAgBG,cAAc,GAAGnB,WAAWiB,OAAO,CAACE,cAAc;IACpE;IAEA,OAAO;QACL,GAAGnB,UAAU;QACbG,MAAMU;QACNI,SAASD;IACX;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/respect-save-to-jwt-fields-middleware.ts"],"sourcesContent":["import { setCookieCache } from 'better-auth/cookies'\nimport { createAuthMiddleware } from 'better-auth/api'\nimport type { SanitizedBetterAuthOptions, PayloadBetterAuthPluginOptions } from '..'\nimport type { Config, Payload } from 'payload'\nimport { prepareSessionData } from './prepare-session-data'\n\n/**\n * Sets up a middleware that enforces the saveToJwt configuration when setting session data.\n * This ensures that only fields specified in saveToJwt are included in the cookie cache\n * for both user and session objects.\n *\n * The middleware runs after authentication and filters the session data based on\n * the collection configurations before storing it in the cookie cache.\n */\nexport function respectSaveToJwtFieldsMiddleware({\n sanitizedOptions,\n payloadConfig,\n pluginOptions,\n}: {\n sanitizedOptions: SanitizedBetterAuthOptions\n payloadConfig: Payload['config'] | Config\n pluginOptions: PayloadBetterAuthPluginOptions\n}) {\n if (typeof sanitizedOptions.hooks !== 'object') sanitizedOptions.hooks = {}\n\n sanitizedOptions.hooks.after = createAuthMiddleware(async (ctx) => {\n const newSession = ctx.context?.newSession\n if (!newSession) return\n\n const filteredSessionData = await prepareSessionData({\n newSession,\n payloadConfig,\n collectionSlugs: {\n userCollectionSlug: pluginOptions.users?.slug ?? 'users',\n sessionCollectionSlug: pluginOptions.sessions?.slug ?? 'sessions',\n },\n })\n\n if (filteredSessionData) {\n await setCookieCache(ctx, filteredSessionData as any)\n }\n })\n}\n"],"names":["setCookieCache","createAuthMiddleware","prepareSessionData","respectSaveToJwtFieldsMiddleware","sanitizedOptions","payloadConfig","pluginOptions","hooks","after","ctx","newSession","context","filteredSessionData","collectionSlugs","userCollectionSlug","users","slug","sessionCollectionSlug","sessions"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAqB;AACpD,SAASC,oBAAoB,QAAQ,kBAAiB;AAGtD,SAASC,kBAAkB,QAAQ,yBAAwB;AAE3D;;;;;;;CAOC,GACD,OAAO,SAASC,iCAAiC,EAC/CC,gBAAgB,EAChBC,aAAa,EACbC,aAAa,EAKd;IACC,IAAI,OAAOF,iBAAiBG,KAAK,KAAK,UAAUH,iBAAiBG,KAAK,GAAG,CAAC;IAE1EH,iBAAiBG,KAAK,CAACC,KAAK,GAAGP,qBAAqB,OAAOQ;QACzD,MAAMC,aAAaD,IAAIE,OAAO,EAAED;QAChC,IAAI,CAACA,YAAY;QAEjB,MAAME,sBAAsB,MAAMV,mBAAmB;YACnDQ;YACAL;YACAQ,iBAAiB;gBACfC,oBAAoBR,cAAcS,KAAK,EAAEC,QAAQ;gBACjDC,uBAAuBX,cAAcY,QAAQ,EAAEF,QAAQ;YACzD;QACF;QAEA,IAAIJ,qBAAqB;YACvB,MAAMZ,eAAeS,KAAKG;QAC5B;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugin/lib/sanitize-auth-options.ts"],"sourcesContent":["import type { PayloadBetterAuthPluginOptions, SanitizedBetterAuthOptions } from '..'\nimport { supportedBetterAuthPluginIds, betterAuthPluginSlugs, baseCollectionSlugs } from './config'\nimport { ensurePasswordSetBeforeUserCreate } from './ensure-password-set-before-create'\nimport { verifyPassword, hashPassword } from './password'\n\n/**\n * Sanitizes the BetterAuth options\n */\nexport function sanitizeBetterAuthOptions(\n options: PayloadBetterAuthPluginOptions,\n): SanitizedBetterAuthOptions {\n const baOptions = options.betterAuthOptions\n const userCollectionSlug = options.users?.slug ?? 'users'\n const accountCollectionSlug = options.accounts?.slug ?? 'accounts'\n const sessionCollectionSlug = options.sessions?.slug ?? 'sessions'\n const verificationCollectionSlug = options.verifications?.slug ?? 'verifications'\n\n const res: SanitizedBetterAuthOptions = { ...baOptions }\n\n res.user = {\n ...(baOptions?.user ?? {}),\n modelName: userCollectionSlug,\n }\n\n res.account = {\n ...(baOptions?.account ?? {}),\n modelName: accountCollectionSlug,\n fields: {\n userId: 'user',\n },\n }\n\n res.session = {\n ...(baOptions?.session ?? {}),\n modelName: sessionCollectionSlug,\n fields: {\n userId: 'user',\n },\n }\n\n res.verification = {\n ...(baOptions?.verification ?? {}),\n modelName: verificationCollectionSlug,\n }\n\n res.emailAndPassword = {\n ...(baOptions?.emailAndPassword ?? {}),\n enabled: baOptions?.emailAndPassword?.enabled ?? true,\n }\n\n if (res.emailAndPassword.enabled) {\n res.emailAndPassword.password = {\n ...(res.emailAndPassword.password ?? {}),\n verify: async ({ hash, password }) => {\n return await verifyPassword({ hash, password })\n },\n hash: async (password) => {\n return await hashPassword(password)\n },\n }\n }\n\n if (Boolean(options.users?.blockFirstBetterAuthVerificationEmail)) {\n const originalSendVerificationEmail = baOptions?.emailVerification?.sendVerificationEmail\n // Only override sendVerificationEmail if the developer provided their own implementation\n if (typeof originalSendVerificationEmail === 'function') {\n res.emailVerification = res?.emailVerification || {}\n res.emailVerification.sendVerificationEmail = async (data, request) => {\n try {\n const user = data.user\n const createdAt = new Date(user.createdAt)\n const now = new Date()\n // If the user was created less than one minute ago, don't send the verification email\n // as we rely on payload to send the initial email\n if (now.getTime() - createdAt.getTime() < 60000) {\n return\n }\n\n await originalSendVerificationEmail(data, request)\n } catch (error) {\n console.error('Error sending verification email:', error)\n }\n }\n }\n }\n\n ensurePasswordSetBeforeUserCreate(res)\n\n if (res.plugins) {\n try {\n const supportedPlugins = res.plugins.filter((plugin) => {\n return Object.values(supportedBetterAuthPluginIds).includes(\n plugin.id as (typeof supportedBetterAuthPluginIds)[keyof typeof supportedBetterAuthPluginIds],\n )\n })\n\n if (supportedPlugins.length !== res.plugins.length) {\n console.warn(\n `Unsupported BetterAuth plugins detected: ${res.plugins\n .filter(\n (p) =>\n !Object.values(supportedBetterAuthPluginIds).includes(\n p.id as (typeof supportedBetterAuthPluginIds)[keyof typeof supportedBetterAuthPluginIds],\n ),\n )\n .map((p) => p.id)\n .join(', ')}. Supported plugins are: ${Object.values(supportedBetterAuthPluginIds).join(\n ', ',\n )}. \n These plugins will be ignored.`,\n )\n }\n\n // Add the schema to the supported plugins\n if (supportedPlugins.length > 0) {\n supportedPlugins.forEach((plugin) => {\n const pluginId =\n plugin.id as (typeof supportedBetterAuthPluginIds)[keyof typeof supportedBetterAuthPluginIds]\n\n switch (pluginId) {\n case supportedBetterAuthPluginIds.admin:\n const adminPlugin = plugin as any\n if (!adminPlugin.adminRoles)\n adminPlugin.adminRoles = options.users?.adminRoles ?? ['admin']\n adminPlugin.adminRoles = options.users?.adminRoles ?? ['admin']\n Object.assign(plugin, adminPlugin)\n break\n case supportedBetterAuthPluginIds.apiKey:\n const apiKeyPlugin = plugin as any\n if (!apiKeyPlugin.schema) apiKeyPlugin.schema = {}\n if (!apiKeyPlugin.schema.apikey) apiKeyPlugin.schema.apikey = {}\n apiKeyPlugin.schema.apikey = {\n ...apiKeyPlugin.schema.apikey,\n modelName: betterAuthPluginSlugs.apiKeys,\n fields: {\n ...(plugin.schema?.apikey?.fields ?? {}),\n userId: {\n ...(plugin.schema?.apikey?.fields?.userId ?? {}),\n fieldName: 'user',\n },\n },\n }\n Object.assign(plugin, apiKeyPlugin)\n break\n case supportedBetterAuthPluginIds.passkey:\n const passkeyPlugin = plugin as any\n if (!passkeyPlugin.schema) passkeyPlugin.schema = {}\n if (!passkeyPlugin.schema.passkey) passkeyPlugin.schema.passkey = {}\n passkeyPlugin.schema.passkey = {\n ...passkeyPlugin.schema.passkey,\n modelName: betterAuthPluginSlugs.passkeys,\n fields: {\n ...(passkeyPlugin.schema.passkey.fields || {}),\n userId: {\n ...passkeyPlugin.schema.passkey.fields.userId,\n fieldName: 'user',\n },\n },\n }\n Object.assign(plugin, passkeyPlugin)\n break\n case supportedBetterAuthPluginIds.organization:\n const organizationPlugin = plugin as any\n if (!organizationPlugin.schema) organizationPlugin.schema = {}\n if (!organizationPlugin.schema.organization) organizationPlugin.schema.member = {}\n if (!organizationPlugin.schema.invitation) organizationPlugin.schema.invitation = {}\n if (!organizationPlugin.schema.team) organizationPlugin.schema.team = {}\n if (!organizationPlugin.schema.session) organizationPlugin.schema.session = {}\n organizationPlugin.schema = {\n ...organizationPlugin.schema,\n organization: {\n ...organizationPlugin.schema.organization,\n modelName: betterAuthPluginSlugs.organizations,\n fields: {\n ...(organizationPlugin.schema.organization.fields ?? {}),\n },\n },\n member: {\n ...organizationPlugin.schema.member,\n modelName: betterAuthPluginSlugs.members,\n fields: {\n ...(organizationPlugin.schema.member.fields ?? {}),\n organizationId: {\n ...(organizationPlugin.schema.member.fields?.organizationId ?? {}),\n fieldName: 'organization',\n },\n userId: {\n ...(organizationPlugin.schema.member.fields?.userId ?? {}),\n fieldName: 'user',\n },\n teamId: {\n ...(organizationPlugin.schema.member.fields?.teamId ?? {}),\n fieldName: 'team',\n },\n },\n },\n invitation: {\n ...organizationPlugin.schema.invitation,\n modelName: betterAuthPluginSlugs.invitations,\n fields: {\n ...(organizationPlugin.schema.invitation.fields ?? {}),\n organizationId: {\n ...(organizationPlugin.schema.invitation.fields?.organizationId ?? {}),\n fieldName: 'organization',\n },\n inviterId: {\n ...(organizationPlugin.schema.invitation.fields?.inviterId ?? {}),\n fieldName: 'inviter',\n },\n teamId: {\n ...(organizationPlugin.schema.invitation.fields?.teamId ?? {}),\n fieldName: 'team',\n },\n },\n },\n team: {\n ...organizationPlugin.schema.team,\n modelName: betterAuthPluginSlugs.teams,\n fields: {\n ...(organizationPlugin.schema.team.fields ?? {}),\n organizationId: {\n ...(organizationPlugin.schema.team.fields?.organizationId ?? {}),\n fieldName: 'organization',\n },\n },\n },\n session: {\n ...organizationPlugin.schema.session,\n modelName: baseCollectionSlugs.sessions,\n fields: {\n ...(organizationPlugin.schema.session.fields ?? {}),\n activeOrganizationId: {\n ...(organizationPlugin.schema.session.fields?.activeOrganizationId ?? {}),\n fieldName: 'activeOrganization',\n },\n },\n },\n }\n Object.assign(plugin, organizationPlugin)\n break\n case supportedBetterAuthPluginIds.sso:\n const ssoPlugin = plugin as any\n if (!ssoPlugin.schema) ssoPlugin.schema = {}\n if (!ssoPlugin.schema.sso) ssoPlugin.schema.sso = {}\n ssoPlugin.schema.sso = {\n ...ssoPlugin.schema.sso,\n modelName: betterAuthPluginSlugs.ssoProviders,\n fields: {\n ...(ssoPlugin.schema.sso.fields ?? {}),\n userId: {\n ...(ssoPlugin.schema.sso.fields?.userId ?? {}),\n fieldName: 'user',\n },\n },\n }\n Object.assign(plugin, ssoPlugin)\n break\n case supportedBetterAuthPluginIds.oidc:\n const oidcPlugin = plugin as any\n if (!oidcPlugin.schema) oidcPlugin.schema = {}\n if (!oidcPlugin.schema.oauthApplication) oidcPlugin.schema.oauthApplication = {}\n if (!oidcPlugin.schema.oauthAccessToken) oidcPlugin.schema.oauthAccessToken = {}\n if (!oidcPlugin.schema.oauthConsent) oidcPlugin.schema.oauthConsent = {}\n oidcPlugin.schema = {\n ...oidcPlugin.schema,\n oauthApplication: {\n ...oidcPlugin.schema.oauthApplication,\n modelName: betterAuthPluginSlugs.oauthApplications,\n fields: {\n ...(oidcPlugin.schema.oauthApplication.fields ?? {}),\n userId: {\n ...(oidcPlugin.schema.oauthApplication.fields?.userId ?? {}),\n fieldName: 'user',\n },\n },\n },\n oauthAccessToken: {\n ...oidcPlugin.schema.oauthAccessToken,\n modelName: betterAuthPluginSlugs.oauthAccessTokens,\n fields: {\n ...(oidcPlugin.schema.oauthAccessToken.fields ?? {}),\n userId: {\n ...(oidcPlugin.schema.oauthAccessToken.fields?.userId ?? {}),\n fieldName: 'user',\n },\n clientId: {\n ...(oidcPlugin.schema.oauthAccessToken.fields?.clientId ?? {}),\n fieldName: 'client',\n },\n },\n },\n oauthConsent: {\n ...oidcPlugin.schema.oauthConsent,\n modelName: betterAuthPluginSlugs.oauthConsents,\n fields: {\n ...(oidcPlugin.schema.oauthConsent.fields ?? {}),\n userId: {\n ...(oidcPlugin.schema.oauthConsent.fields?.userId ?? {}),\n fieldName: 'user',\n },\n clientId: {\n ...(oidcPlugin.schema.oauthConsent.fields?.clientId ?? {}),\n fieldName: 'client',\n },\n },\n },\n }\n Object.assign(plugin, oidcPlugin)\n break\n default:\n break\n }\n })\n }\n // Make sure only the supported plugins are used\n Object.assign(res.plugins, supportedPlugins)\n } catch (error) {\n throw new Error(`Error sanitizing BetterAuth plugins: ${error}`)\n }\n }\n\n return res\n}\n"],"names":["supportedBetterAuthPluginIds","betterAuthPluginSlugs","baseCollectionSlugs","ensurePasswordSetBeforeUserCreate","verifyPassword","hashPassword","sanitizeBetterAuthOptions","options","baOptions","betterAuthOptions","userCollectionSlug","users","slug","accountCollectionSlug","accounts","sessionCollectionSlug","sessions","verificationCollectionSlug","verifications","res","user","modelName","account","fields","userId","session","verification","emailAndPassword","enabled","password","verify","hash","Boolean","blockFirstBetterAuthVerificationEmail","originalSendVerificationEmail","emailVerification","sendVerificationEmail","data","request","createdAt","Date","now","getTime","error","console","plugins","supportedPlugins","filter","plugin","Object","values","includes","id","length","warn","p","map","join","forEach","pluginId","admin","adminPlugin","adminRoles","assign","apiKey","apiKeyPlugin","schema","apikey","apiKeys","fieldName","passkey","passkeyPlugin","passkeys","organization","organizationPlugin","member","invitation","team","organizations","members","organizationId","teamId","invitations","inviterId","teams","activeOrganizationId","sso","ssoPlugin","ssoProviders","oidc","oidcPlugin","oauthApplication","oauthAccessToken","oauthConsent","oauthApplications","oauthAccessTokens","clientId","oauthConsents","Error"],"mappings":"AACA,SAASA,4BAA4B,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ,WAAU;AACnG,SAASC,iCAAiC,QAAQ,sCAAqC;AACvF,SAASC,cAAc,EAAEC,YAAY,QAAQ,aAAY;AAEzD;;CAEC,GACD,OAAO,SAASC,0BACdC,OAAuC;IAEvC,MAAMC,YAAYD,QAAQE,iBAAiB;IAC3C,MAAMC,qBAAqBH,QAAQI,KAAK,EAAEC,QAAQ;IAClD,MAAMC,wBAAwBN,QAAQO,QAAQ,EAAEF,QAAQ;IACxD,MAAMG,wBAAwBR,QAAQS,QAAQ,EAAEJ,QAAQ;IACxD,MAAMK,6BAA6BV,QAAQW,aAAa,EAAEN,QAAQ;IAElE,MAAMO,MAAkC;QAAE,GAAGX,SAAS;IAAC;IAEvDW,IAAIC,IAAI,GAAG;QACT,GAAIZ,WAAWY,QAAQ,CAAC,CAAC;QACzBC,WAAWX;IACb;IAEAS,IAAIG,OAAO,GAAG;QACZ,GAAId,WAAWc,WAAW,CAAC,CAAC;QAC5BD,WAAWR;QACXU,QAAQ;YACNC,QAAQ;QACV;IACF;IAEAL,IAAIM,OAAO,GAAG;QACZ,GAAIjB,WAAWiB,WAAW,CAAC,CAAC;QAC5BJ,WAAWN;QACXQ,QAAQ;YACNC,QAAQ;QACV;IACF;IAEAL,IAAIO,YAAY,GAAG;QACjB,GAAIlB,WAAWkB,gBAAgB,CAAC,CAAC;QACjCL,WAAWJ;IACb;IAEAE,IAAIQ,gBAAgB,GAAG;QACrB,GAAInB,WAAWmB,oBAAoB,CAAC,CAAC;QACrCC,SAASpB,WAAWmB,kBAAkBC,WAAW;IACnD;IAEA,IAAIT,IAAIQ,gBAAgB,CAACC,OAAO,EAAE;QAChCT,IAAIQ,gBAAgB,CAACE,QAA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C7D3B,WAAW;wCACb;oCACF;gCACF;gCACAwB,cAAc;oCACZ,GAAGH,WAAWxB,MAAM,CAAC2B,YAAY;oCACjCxE,WAAWpB,sBAAsBgG,aAAa;oCAC9C1E,QAAQ;wCACN,GAAImE,WAAWxB,MAAM,CAAC2B,YAAY,CAACtE,MAAM,IAAI,CAAC,CAAC;wCAC/CC,QAAQ;4CACN,GAAIkE,WAAWxB,MAAM,CAAC2B,YAAY,CAACtE,MAAM,EAAEC,UAAU,CAAC,CAAC;4CACvD6C,WAAW;wCACb;wCACA2B,UAAU;4CACR,GAAIN,WAAWxB,MAAM,CAAC2B,YAAY,CAACtE,MAAM,EAAEyE,YAAY,CAAC,CAAC;4CACzD3B,WAAW;wCACb;oCACF;gCACF;4BACF;4BACApB,OAAOc,MAAM,CAACf,QAAQ0C;4BACtB;wBACF;4BACE;oBACJ;gBACF;YACF;YACA,gDAAgD;YAChDzC,OAAOc,MAAM,CAAC5C,IAAI0B,OAAO,EAAEC;QAC7B,EAAE,OAAOH,OAAO;YACd,MAAM,IAAIuD,MAAM,CAAC,qCAAqC,EAAEvD,OAAO;QACjE;IACF;IAEA,OAAOxB;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/plugin/payload/components/admin-buttons.tsx"],"sourcesContent":["'use client'\n\nimport React, { useEffect, useState } from 'react'\nimport { adminClient } from 'better-auth/client/plugins'\nimport { createAuthClient } from 'better-auth/react'\nimport { useParams, usePathname, useRouter } from 'next/navigation'\nimport { toast } from 'sonner'\nimport { Toaster } from 'sonner'\nimport { Button } from '@payloadcms/ui'\nimport './styles.css'\n\nimport '@payloadcms/ui/styles.css'\n\nasync function getDocumentData(id: string, path: string) {\n const apiUrl = `${path}/api`\n try {\n // Try to load the /api page and parse the HTML response\n const response = await fetch(apiUrl)\n if (response.ok) {\n const htmlResponse = await response.text()\n // Parse the HTML to extract user data\n try {\n let documentData: any = null\n const parser = new DOMParser()\n const doc = parser.parseFromString(htmlResponse, 'text/html')\n\n // Look for the JSON data in the query inspector\n const jsonRows = doc.querySelectorAll('.query-inspector__row-line')\n if (jsonRows.length > 0) {\n documentData = {}\n\n jsonRows.forEach((row) => {\n const keyMatch = row.innerHTML.match(/\"([^\"]+)\"\\s*:/)\n if (keyMatch) {\n const key = keyMatch[1].trim()\n const valueElement = row.querySelector('.query-inspector__value')\n if (valueElement) {\n let value = valueElement.textContent?.trim() ?? ''\n\n // Convert values to appropriate types\n if (value === 'true') value = 'true'\n else if (value === 'false') value = 'false'\n else if (value === 'null') value = 'null'\n else if (!isNaN(Number(value))) value = Number(value).toString()\n else if (value.startsWith('\"') && value.endsWith('\"')) {\n value = value.substring(1, value.length - 1).trim()\n }\n\n documentData[key] = value\n }\n }\n })\n }\n\n return documentData\n } catch (parseError) {\n console.error('Error parsing document data from HTML:', parseError)\n return null\n }\n }\n } catch (apiError) {\n console.error('Error fetching document data from API:', apiError)\n }\n}\n\nexport default function AdminButtons({ userSlug }: { userSlug: string }) {\n const router = useRouter()\n const path = usePathname()\n const params = useParams()\n const [id, setId] = useState('')\n const [documentData, setDocumentData] = useState<any>(null)\n\n const authClient = createAuthClient({\n plugins: [adminClient()],\n })\n\n useEffect(() => {\n async function fetchDocumentData() {\n // Get the ID from the params.segments array\n const segments = params.segments as string[]\n const userSlugIndex = segments.findIndex((segment) => segment === userSlug)\n const id =\n userSlugIndex !== -1 && userSlugIndex < segments.length - 1\n ? segments[userSlugIndex + 1]\n : segments[segments.length - 1]\n\n const documentData = await getDocumentData(id, path)\n setId(id)\n setDocumentData(documentData)\n }\n fetchDocumentData()\n }, [params, path, userSlug])\n\n const handleImpersonate = async () => {\n await authClient.admin.impersonateUser({\n userId: id,\n fetchOptions: {\n onSuccess() {\n router.push('/')\n },\n onError(error: any) {\n console.error('Error impersonating user:', error)\n toast.error('Failed to impersonate user')\n },\n },\n })\n }\n\n const handleBan = async () => {\n await authClient.admin.banUser({\n userId: id,\n fetchOptions: {\n onSuccess() {\n toast.success('User banned successfully')\n router.refresh()\n },\n onError(error: any) {\n console.error('Error banning user:', error)\n toast.error('Failed to ban user')\n },\n },\n })\n }\n\n const handleUnban = async () => {\n await authClient.admin.unbanUser({\n userId: id,\n fetchOptions: {\n onSuccess() {\n toast.success('User unbanned successfully')\n router.refresh()\n },\n onError(error: any) {\n console.error('Error unbanning user:', error)\n toast.error('Failed to unban user')\n },\n },\n })\n }\n\n const handleRevokeAllSessions = async () => {\n await authClient.admin.revokeUserSessions({\n userId: id,\n fetchOptions: {\n onSuccess() {\n toast.success('All sessions revoked successfully')\n router.refresh()\n },\n onError(error: any) {\n console.error('Error revoking all sessions:', error)\n toast.error('Failed to revoke all sessions')\n },\n },\n })\n }\n\n return (\n <>\n <style>{`\n .admin-actions-container {\n display: flex;\n flex-direction: column;\n }\n .admin-actions-container h3 {\n margin-bottom: 1rem;\n }\n .admin-actions-container .btn {\n margin-block: 0.5rem;\n }\n .ban-button {\n background-color: oklch(0.258 0.092 26.042);\n color: oklch(0.577 0.245 27.325);\n border: 1px solid oklch(0.396 0.141 25.723);\n &:hover {\n color: #fff;\n background-color: oklch(0.505 0.213 27.518);\n }\n }\n .revoke-sessions-button {\n --theme-elevation-800: oklch(0.396 0.141 25.723);\n color: oklch(0.637 0.237 25.331);\n &:hover {\n --theme-elevation-400: oklch(0.396 0.141 25.723);\n color: #fff;\n background-color: oklch(0.396 0.141 25.723);\n }\n }\n `}</style>\n <div className=\"admin-actions-container\">\n <h3>Admin Actions</h3>\n <div style={{ display: 'flex', flexWrap: 'wrap', columnGap: '0.5rem' }}>\n <Button onClick={handleImpersonate} buttonStyle=\"primary\">\n Impersonate\n </Button>\n <Button\n onClick={handleRevokeAllSessions}\n buttonStyle=\"secondary\"\n className=\"revoke-sessions-button\"\n >\n Revoke All Sessions\n </Button>\n <Button onClick={handleBan} buttonStyle=\"error\" className=\"ban-button\">\n Ban\n </Button>\n <Button onClick={handleUnban} buttonStyle=\"primary\">\n Unban\n </Button>\n </div>\n </div>\n <Toaster />\n </>\n )\n}\n"],"names":["React","useEffect","useState","adminClient","createAuthClient","useParams","usePathname","useRouter","toast","Toaster","Button","getDocumentData","id","path","apiUrl","response","fetch","ok","htmlResponse","text","documentData","parser","DOMParser","doc","parseFromString","jsonRows","querySelectorAll","length","forEach","row","keyMatch","innerHTML","match","key","trim","valueElement","querySelector","value","textContent","isNaN","Number","toString","startsWith","endsWith","substring","parseError","console","error","apiError","AdminButtons","userSlug","router","params","setId","setDocumentData","authClient","plugins","fetchDocumentData","segments","userSlugIndex","findIndex","segment","handleImpersonate","admin","impersonateUser","userId","fetchOptions","onSuccess","push","onError","handleBan","banUser","success","refresh","handleUnban","unbanUser","handleRevokeAllSessions","revokeUserSessions","style","div","className","h3","display","flexWrap","columnGap","onClick","buttonStyle"],"mappings":"AAAA;;AAEA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAClD,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,gBAAgB,QAAQ,oBAAmB;AACpD,SAASC,SAAS,EAAEC,WAAW,EAAEC,SAAS,QAAQ,kBAAiB;AACnE,SAASC,KAAK,QAAQ,SAAQ;AAC9B,SAASC,OAAO,QAAQ,SAAQ;AAChC,SAASC,MAAM,QAAQ,iBAAgB;AACvC,OAAO,eAAc;AAErB,OAAO,4BAA2B;AAElC,eAAeC,gBAAgBC,EAAU,EAAEC,IAAY;IACrD,MAAMC,SAAS,GAAGD,KAAK,IAAI,CAAC;IAC5B,IAAI;QACF,wDAAwD;QACxD,MAAME,WAAW,MAAMC,MAAMF;QAC7B,IAAIC,SAASE,EAAE,EAAE;YACf,MAAMC,eAAe,MAAMH,SAASI,IAAI;YACxC,sCAAsC;YACtC,IAAI;gBACF,IAAIC,eAAoB;gBACxB,MAAMC,SAAS,IAAIC;gBACnB,MAAMC,MAAMF,OAAOG,eAAe,CAACN,cAAc;gBAEjD,gDAAgD;gBAChD,MAAMO,WAAWF,IAAIG,gBAAgB,CAAC;gBACtC,IAAID,SAASE,MAAM,GAAG,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D,cAAc;gBACZC;oBACE3D,MAAMgE,OAAO,CAAC;oBACdrB,OAAOsB,OAAO;gBAChB;gBACAJ,SAAQtB,KAAU;oBAChBD,QAAQC,KAAK,CAAC,gCAAgCA;oBAC9CvC,MAAMuC,KAAK,CAAC;gBACd;YACF;QACF;IACF;IAEA,qBACE;;0BACE,KAAC+B;0BAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA6BT,CAAC;;0BACD,MAACC;gBAAIC,WAAU;;kCACb,KAACC;kCAAG;;kCACJ,MAACF;wBAAID,OAAO;4BAAEI,SAAS;4BAAQC,UAAU;4BAAQC,WAAW;wBAAS;;0CACnE,KAAC1E;gCAAO2E,SAASvB;gCAAmBwB,aAAY;0CAAU;;0CAG1D,KAAC5E;gCACC2E,SAAST;gCACTU,aAAY;gCACZN,WAAU;0CACX;;0CAGD,KAACtE;gCAAO2E,SAASf;gCAAWgB,aAAY;gCAAQN,WAAU;0CAAa;;0CAGvE,KAACtE;gCAAO2E,SAASX;gCAAaY,aAAY;0CAAU;;;;;;0BAKxD,KAAC7E;;;AAGP"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/plugin/payload/components/login-redirect.tsx"],"sourcesContent":["import { redirect } from 'next/navigation'\n\nexport default function LoginRedirect() {\n redirect('/admin/login')\n}\n"],"names":["redirect","LoginRedirect"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,kBAAiB;AAE1C,eAAe,SAASC;IACtBD,SAAS;AACX"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/plugin/payload/components/logo.tsx"],"sourcesContent":["import React from 'react'\n\nexport default function Logo() {\n return (\n <div className=\"flex items-center justify-center w-full mb-8\">\n <svg\n width=\"60\"\n height=\"45\"\n viewBox=\"0 0 60 45\"\n fill=\"none\"\n className=\"w-5 h-5\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M0 0H15V15H30V30H15V45H0V30V15V0ZM45 30V15H30V0H45H60V15V30V45H45H30V30H45Z\"\n className=\"fill-black dark:fill-white\"\n />\n </svg>\n <div className=\"ml-2 font-semibold text-black dark:text-white\">\n Payload <span className=\"text-blue-600 dark:text-blue-400\">&times;</span> Better Auth\n </div>\n </div>\n )\n}\n"],"names":["React","Logo","div","className","svg","width","height","viewBox","fill","xmlns","path","fillRule","clipRule","d","span"],"mappings":";AAAA,OAAOA,WAAW,QAAO;AAEzB,eAAe,SAASC;IACtB,qBACE,MAACC;QAAIC,WAAU;;0BACb,KAACC;gBACCC,OAAM;gBACNC,QAAO;gBACPC,SAAQ;gBACRC,MAAK;gBACLL,WAAU;gBACVM,OAAM;0BAEN,cAAA,KAACC;oBACCC,UAAS;oBACTC,UAAS;oBACTC,GAAE;oBACFV,WAAU;;;0BAGd,MAACD;gBAAIC,WAAU;;oBAAgD;kCACrD,KAACW;wBAAKX,WAAU;kCAAmC;;oBAAc;;;;;AAIjF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/plugin/payload/components/logout.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { Loader2, LogOut } from 'lucide-react'\nimport { createAuthClient } from 'better-auth/react'\n\nexport default function LogoutButton() {\n const [loading, setLoading] = React.useState(false)\n const router = useRouter()\n\n const handleLogout = async () => {\n setLoading(true)\n try {\n await createAuthClient().signOut({\n fetchOptions: {\n onResponse: () => {\n setLoading(false)\n },\n onError: () => {\n setLoading(false)\n },\n onSuccess: () => {\n router.refresh()\n },\n },\n })\n } catch (error) {\n setLoading(false)\n }\n }\n\n return (\n <button\n onClick={handleLogout}\n disabled={loading}\n style={{\n background: 'transparent',\n border: 'none',\n cursor: 'pointer',\n padding: '8px',\n borderRadius: '4px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n transition: 'background-color 0.2s ease',\n }}\n onMouseOver={(e) => (e.currentTarget.style.backgroundColor = 'rgba(0, 0, 0, 0.05)')}\n onMouseOut={(e) => (e.currentTarget.style.backgroundColor = 'transparent')}\n >\n {loading ? (\n <Loader2 style={{ height: '32px', width: '32px', animation: 'spin 1s linear infinite' }} />\n ) : (\n <LogOut style={{ height: '32px', width: '32px' }} />\n )}\n </button>\n )\n}\n"],"names":["React","useRouter","Loader2","LogOut","createAuthClient","LogoutButton","loading","setLoading","useState","router","handleLogout","signOut","fetchOptions","onResponse","onError","onSuccess","refresh","error","button","onClick","disabled","style","background","border","cursor","padding","borderRadius","display","alignItems","justifyContent","transition","onMouseOver","e","currentTarget","backgroundColor","onMouseOut","height","width","animation"],"mappings":"AAAA;;AACA,OAAOA,WAAW,QAAO;AACzB,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,SAASC,OAAO,EAAEC,MAAM,QAAQ,eAAc;AAC9C,SAASC,gBAAgB,QAAQ,oBAAmB;AAEpD,eAAe,SAASC;IACtB,MAAM,CAACC,SAASC,WAAW,GAAGP,MAAMQ,QAAQ,CAAC;IAC7C,MAAMC,SAASR;IAEf,MAAMS,eAAe;QACnBH,WAAW;QACX,IAAI;YACF,MAAMH,mBAAmBO,OAAO,CAAC;gBAC/BC,cAAc;oBACZC,YAAY;wBACVN,WAAW;oBACb;oBACAO,SAAS;wBACPP,WAAW;oBACb;oBACAQ,WAAW;wBACTN,OAAOO,OAAO;oBAChB;gBACF;YACF;QACF,EAAE,OAAOC,OAAO;YACdV,WAAW;QACb;IACF;IAEA,qBACE,KAACW;QACCC,SAAST;QACTU,UAAUd;QACVe,OAAO;YACLC,YAAY;YACZC,QAAQ;YACRC,QAAQ;YACRC,SAAS;YACTC,cAAc;YACdC,SAAS;YACTC,YAAY;YACZC,gBAAgB;YAChBC,YAAY;QACd;QACAC,aAAa,CAACC,IAAOA,EAAEC,aAAa,CAACZ,KAAK,CAACa,eAAe,GAAG;QAC7DC,YAAY,CAACH,IAAOA,EAAEC,aAAa,CAACZ,KAAK,CAACa,eAAe,GAAG;kBAE3D5B,wBACC,KAACJ;YAAQmB,OAAO;gBAAEe,QAAQ;gBAAQC,OAAO;gBAAQC,WAAW;YAA0B;2BAEtF,KAACnC;YAAOkB,OAAO;gBAAEe,QAAQ;gBAAQC,OAAO;YAAO;;;AAIvD"}