@revealui/auth 0.0.1-pre.0

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 (413) hide show
  1. package/LICENSE +202 -0
  2. package/dist/better-auth/adapter/__tests__/transform.test.js +213 -0
  3. package/dist/better-auth/adapter/__tests__/transform.test.js.map +1 -0
  4. package/dist/better-auth/adapter/generate-schema/biome.d.js +2 -0
  5. package/dist/better-auth/adapter/generate-schema/biome.d.js.map +1 -0
  6. package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +5 -0
  7. package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +482 -0
  8. package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +1 -0
  9. package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +1 -0
  10. package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +42 -0
  11. package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +1 -0
  12. package/dist/better-auth/adapter/generate-schema/index.d.ts +4 -0
  13. package/dist/better-auth/adapter/generate-schema/index.js +19 -0
  14. package/dist/better-auth/adapter/generate-schema/index.js.map +1 -0
  15. package/dist/better-auth/adapter/generate-schema/utils.d.ts +2 -0
  16. package/dist/better-auth/adapter/generate-schema/utils.js +20 -0
  17. package/dist/better-auth/adapter/generate-schema/utils.js.map +1 -0
  18. package/dist/better-auth/adapter/index.d.ts +15 -0
  19. package/dist/better-auth/adapter/index.js +731 -0
  20. package/dist/better-auth/adapter/index.js.map +1 -0
  21. package/dist/better-auth/adapter/tests/adapter.test.js +174 -0
  22. package/dist/better-auth/adapter/tests/adapter.test.js.map +1 -0
  23. package/dist/better-auth/adapter/tests/base-collections-tests.js +575 -0
  24. package/dist/better-auth/adapter/tests/base-collections-tests.js.map +1 -0
  25. package/dist/better-auth/adapter/tests/dev/index.js +117 -0
  26. package/dist/better-auth/adapter/tests/dev/index.js.map +1 -0
  27. package/dist/better-auth/adapter/tests/dev/migrate.js +26 -0
  28. package/dist/better-auth/adapter/tests/dev/migrate.js.map +1 -0
  29. package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js +218 -0
  30. package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js.map +1 -0
  31. package/dist/better-auth/adapter/tests/dev/schema.js +160 -0
  32. package/dist/better-auth/adapter/tests/dev/schema.js.map +1 -0
  33. package/dist/better-auth/adapter/tests/plugins-tests.js +2 -0
  34. package/dist/better-auth/adapter/tests/plugins-tests.js.map +1 -0
  35. package/dist/better-auth/adapter/transform/index.d.ts +27 -0
  36. package/dist/better-auth/adapter/transform/index.js +664 -0
  37. package/dist/better-auth/adapter/transform/index.js.map +1 -0
  38. package/dist/better-auth/adapter/types.d.ts +10 -0
  39. package/dist/better-auth/adapter/types.js +3 -0
  40. package/dist/better-auth/adapter/types.js.map +1 -0
  41. package/dist/better-auth/generated-types.d.ts +285 -0
  42. package/dist/better-auth/index.d.ts +3 -0
  43. package/dist/better-auth/index.js +5 -0
  44. package/dist/better-auth/index.js.map +1 -0
  45. package/dist/better-auth/plugin/__tests__/plugin.test.js +162 -0
  46. package/dist/better-auth/plugin/__tests__/plugin.test.js.map +1 -0
  47. package/dist/better-auth/plugin/constants.d.ts +220 -0
  48. package/dist/better-auth/plugin/constants.js +249 -0
  49. package/dist/better-auth/plugin/constants.js.map +1 -0
  50. package/dist/better-auth/plugin/helpers/check-plugin-exists.d.ts +12 -0
  51. package/dist/better-auth/plugin/helpers/check-plugin-exists.js +14 -0
  52. package/dist/better-auth/plugin/helpers/check-plugin-exists.js.map +1 -0
  53. package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +29 -0
  54. package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +46 -0
  55. package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +1 -0
  56. package/dist/better-auth/plugin/helpers/get-admin-access.d.ts +7 -0
  57. package/dist/better-auth/plugin/helpers/get-admin-access.js +22 -0
  58. package/dist/better-auth/plugin/helpers/get-admin-access.js.map +1 -0
  59. package/dist/better-auth/plugin/helpers/get-all-roles.d.ts +5 -0
  60. package/dist/better-auth/plugin/helpers/get-all-roles.js +20 -0
  61. package/dist/better-auth/plugin/helpers/get-all-roles.js.map +1 -0
  62. package/dist/better-auth/plugin/helpers/get-better-auth-schema.d.ts +18 -0
  63. package/dist/better-auth/plugin/helpers/get-better-auth-schema.js +70 -0
  64. package/dist/better-auth/plugin/helpers/get-better-auth-schema.js.map +1 -0
  65. package/dist/better-auth/plugin/helpers/get-collection-slug.d.ts +5 -0
  66. package/dist/better-auth/plugin/helpers/get-collection-slug.js +20 -0
  67. package/dist/better-auth/plugin/helpers/get-collection-slug.js.map +1 -0
  68. package/dist/better-auth/plugin/helpers/get-collection.d.ts +15 -0
  69. package/dist/better-auth/plugin/helpers/get-collection.js +29 -0
  70. package/dist/better-auth/plugin/helpers/get-collection.js.map +1 -0
  71. package/dist/better-auth/plugin/helpers/get-ip.d.ts +2 -0
  72. package/dist/better-auth/plugin/helpers/get-ip.js +31 -0
  73. package/dist/better-auth/plugin/helpers/get-ip.js.map +1 -0
  74. package/dist/better-auth/plugin/helpers/get-signed-cookie.d.ts +2 -0
  75. package/dist/better-auth/plugin/helpers/get-signed-cookie.js +65 -0
  76. package/dist/better-auth/plugin/helpers/get-signed-cookie.js.map +1 -0
  77. package/dist/better-auth/plugin/helpers/index.d.ts +1 -0
  78. package/dist/better-auth/plugin/helpers/index.js +3 -0
  79. package/dist/better-auth/plugin/helpers/index.js.map +1 -0
  80. package/dist/better-auth/plugin/helpers/prepare-session-data.d.ts +59 -0
  81. package/dist/better-auth/plugin/helpers/prepare-session-data.js +49 -0
  82. package/dist/better-auth/plugin/helpers/prepare-session-data.js.map +1 -0
  83. package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.d.ts +20 -0
  84. package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js +67 -0
  85. package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js.map +1 -0
  86. package/dist/better-auth/plugin/index.d.ts +11 -0
  87. package/dist/better-auth/plugin/index.js +125 -0
  88. package/dist/better-auth/plugin/index.js.map +1 -0
  89. package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.d.ts +12 -0
  90. package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js +87 -0
  91. package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js.map +1 -0
  92. package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.d.ts +3 -0
  93. package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js +60 -0
  94. package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js.map +1 -0
  95. package/dist/better-auth/plugin/lib/build-collections/accounts/index.d.ts +3 -0
  96. package/dist/better-auth/plugin/lib/build-collections/accounts/index.js +154 -0
  97. package/dist/better-auth/plugin/lib/build-collections/accounts/index.js.map +1 -0
  98. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.d.ts +5 -0
  99. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js +11 -0
  100. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js.map +1 -0
  101. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.d.ts +2 -0
  102. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js +8 -0
  103. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js.map +1 -0
  104. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.d.ts +6 -0
  105. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js +119 -0
  106. package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js.map +1 -0
  107. package/dist/better-auth/plugin/lib/build-collections/api-keys.d.ts +3 -0
  108. package/dist/better-auth/plugin/lib/build-collections/api-keys.js +177 -0
  109. package/dist/better-auth/plugin/lib/build-collections/api-keys.js.map +1 -0
  110. package/dist/better-auth/plugin/lib/build-collections/device-code.d.ts +3 -0
  111. package/dist/better-auth/plugin/lib/build-collections/device-code.js +50 -0
  112. package/dist/better-auth/plugin/lib/build-collections/device-code.js.map +1 -0
  113. package/dist/better-auth/plugin/lib/build-collections/index.d.ts +10 -0
  114. package/dist/better-auth/plugin/lib/build-collections/index.js +73 -0
  115. package/dist/better-auth/plugin/lib/build-collections/index.js.map +1 -0
  116. package/dist/better-auth/plugin/lib/build-collections/invitations.d.ts +3 -0
  117. package/dist/better-auth/plugin/lib/build-collections/invitations.js +94 -0
  118. package/dist/better-auth/plugin/lib/build-collections/invitations.js.map +1 -0
  119. package/dist/better-auth/plugin/lib/build-collections/jwks.d.ts +3 -0
  120. package/dist/better-auth/plugin/lib/build-collections/jwks.js +59 -0
  121. package/dist/better-auth/plugin/lib/build-collections/jwks.js.map +1 -0
  122. package/dist/better-auth/plugin/lib/build-collections/members.d.ts +3 -0
  123. package/dist/better-auth/plugin/lib/build-collections/members.js +73 -0
  124. package/dist/better-auth/plugin/lib/build-collections/members.js.map +1 -0
  125. package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.d.ts +3 -0
  126. package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js +107 -0
  127. package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js.map +1 -0
  128. package/dist/better-auth/plugin/lib/build-collections/oauth-applications.d.ts +3 -0
  129. package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js +118 -0
  130. package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js.map +1 -0
  131. package/dist/better-auth/plugin/lib/build-collections/oauth-consents.d.ts +3 -0
  132. package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js +89 -0
  133. package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js.map +1 -0
  134. package/dist/better-auth/plugin/lib/build-collections/organizations.d.ts +3 -0
  135. package/dist/better-auth/plugin/lib/build-collections/organizations.js +70 -0
  136. package/dist/better-auth/plugin/lib/build-collections/organizations.js.map +1 -0
  137. package/dist/better-auth/plugin/lib/build-collections/passkeys.d.ts +3 -0
  138. package/dist/better-auth/plugin/lib/build-collections/passkeys.js +115 -0
  139. package/dist/better-auth/plugin/lib/build-collections/passkeys.js.map +1 -0
  140. package/dist/better-auth/plugin/lib/build-collections/sessions.d.ts +3 -0
  141. package/dist/better-auth/plugin/lib/build-collections/sessions.js +170 -0
  142. package/dist/better-auth/plugin/lib/build-collections/sessions.js.map +1 -0
  143. package/dist/better-auth/plugin/lib/build-collections/sso-providers.d.ts +3 -0
  144. package/dist/better-auth/plugin/lib/build-collections/sso-providers.js +81 -0
  145. package/dist/better-auth/plugin/lib/build-collections/sso-providers.js.map +1 -0
  146. package/dist/better-auth/plugin/lib/build-collections/subscriptions.d.ts +3 -0
  147. package/dist/better-auth/plugin/lib/build-collections/subscriptions.js +111 -0
  148. package/dist/better-auth/plugin/lib/build-collections/subscriptions.js.map +1 -0
  149. package/dist/better-auth/plugin/lib/build-collections/team-members.d.ts +3 -0
  150. package/dist/better-auth/plugin/lib/build-collections/team-members.js +57 -0
  151. package/dist/better-auth/plugin/lib/build-collections/team-members.js.map +1 -0
  152. package/dist/better-auth/plugin/lib/build-collections/teams.d.ts +3 -0
  153. package/dist/better-auth/plugin/lib/build-collections/teams.js +76 -0
  154. package/dist/better-auth/plugin/lib/build-collections/teams.js.map +1 -0
  155. package/dist/better-auth/plugin/lib/build-collections/two-factors.d.ts +3 -0
  156. package/dist/better-auth/plugin/lib/build-collections/two-factors.js +67 -0
  157. package/dist/better-auth/plugin/lib/build-collections/two-factors.js.map +1 -0
  158. package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.d.ts +7 -0
  159. package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js +53 -0
  160. package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js.map +1 -0
  161. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.d.ts +11 -0
  162. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js +75 -0
  163. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js.map +1 -0
  164. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.d.ts +4 -0
  165. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js +6 -0
  166. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js.map +1 -0
  167. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.d.ts +2 -0
  168. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js +115 -0
  169. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js.map +1 -0
  170. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.d.ts +3 -0
  171. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js +64 -0
  172. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js.map +1 -0
  173. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.d.ts +3 -0
  174. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js +80 -0
  175. package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js.map +1 -0
  176. package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.d.ts +6 -0
  177. package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js +79 -0
  178. package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js.map +1 -0
  179. package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.d.ts +2 -0
  180. package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js +82 -0
  181. package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js.map +1 -0
  182. package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.d.ts +2 -0
  183. package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js +54 -0
  184. package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js.map +1 -0
  185. package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.d.ts +6 -0
  186. package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js +15 -0
  187. package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js.map +1 -0
  188. package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.d.ts +6 -0
  189. package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js +8 -0
  190. package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js.map +1 -0
  191. package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.d.ts +2 -0
  192. package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js +17 -0
  193. package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js.map +1 -0
  194. package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.d.ts +2 -0
  195. package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js +91 -0
  196. package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js.map +1 -0
  197. package/dist/better-auth/plugin/lib/build-collections/users/index.d.ts +3 -0
  198. package/dist/better-auth/plugin/lib/build-collections/users/index.js +341 -0
  199. package/dist/better-auth/plugin/lib/build-collections/users/index.js.map +1 -0
  200. package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.d.ts +15 -0
  201. package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js +24 -0
  202. package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js.map +1 -0
  203. package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.d.ts +10 -0
  204. package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js +67 -0
  205. package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js.map +1 -0
  206. package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.d.ts +9 -0
  207. package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js +94 -0
  208. package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js.map +1 -0
  209. package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.d.ts +7 -0
  210. package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js +35 -0
  211. package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js.map +1 -0
  212. package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.d.ts +12 -0
  213. package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js +25 -0
  214. package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js.map +1 -0
  215. package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.d.ts +14 -0
  216. package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js +67 -0
  217. package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js.map +1 -0
  218. package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.d.ts +20 -0
  219. package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js +98 -0
  220. package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js.map +1 -0
  221. package/dist/better-auth/plugin/lib/build-collections/verifications.d.ts +3 -0
  222. package/dist/better-auth/plugin/lib/build-collections/verifications.js +87 -0
  223. package/dist/better-auth/plugin/lib/build-collections/verifications.js.map +1 -0
  224. package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +5 -0
  225. package/dist/better-auth/plugin/lib/get-payload-auth.js +9 -0
  226. package/dist/better-auth/plugin/lib/get-payload-auth.js.map +1 -0
  227. package/dist/better-auth/plugin/lib/init-better-auth.d.ts +7 -0
  228. package/dist/better-auth/plugin/lib/init-better-auth.js +46 -0
  229. package/dist/better-auth/plugin/lib/init-better-auth.js.map +1 -0
  230. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.d.ts +2 -0
  231. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js +9 -0
  232. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js.map +1 -0
  233. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.d.ts +2 -0
  234. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js +10 -0
  235. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js.map +1 -0
  236. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.d.ts +2 -0
  237. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js +8 -0
  238. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js.map +1 -0
  239. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.d.ts +10 -0
  240. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js +156 -0
  241. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js.map +1 -0
  242. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.d.ts +2 -0
  243. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js +18 -0
  244. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js.map +1 -0
  245. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.d.ts +2 -0
  246. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js +34 -0
  247. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js.map +1 -0
  248. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.d.ts +2 -0
  249. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js +11 -0
  250. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js.map +1 -0
  251. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.d.ts +2 -0
  252. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js +10 -0
  253. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js.map +1 -0
  254. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.d.ts +2 -0
  255. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js +11 -0
  256. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js.map +1 -0
  257. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.d.ts +7 -0
  258. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js +23 -0
  259. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js.map +1 -0
  260. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.d.ts +25 -0
  261. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js +62 -0
  262. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js.map +1 -0
  263. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.d.ts +9 -0
  264. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js +47 -0
  265. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js.map +1 -0
  266. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.d.ts +15 -0
  267. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js +42 -0
  268. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js.map +1 -0
  269. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.d.ts +9 -0
  270. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js +63 -0
  271. package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js.map +1 -0
  272. package/dist/better-auth/plugin/lib/set-login-methods.d.ts +4 -0
  273. package/dist/better-auth/plugin/lib/set-login-methods.js +14 -0
  274. package/dist/better-auth/plugin/lib/set-login-methods.js.map +1 -0
  275. package/dist/better-auth/plugin/payload/components/admin-buttons/index.d.ts +9 -0
  276. package/dist/better-auth/plugin/payload/components/admin-buttons/index.js +143 -0
  277. package/dist/better-auth/plugin/payload/components/admin-buttons/index.js.map +1 -0
  278. package/dist/better-auth/plugin/payload/components/admin-invite-button/index.d.ts +10 -0
  279. package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js +219 -0
  280. package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js.map +1 -0
  281. package/dist/better-auth/plugin/payload/components/logout-button.d.ts +4 -0
  282. package/dist/better-auth/plugin/payload/components/logout-button.js +24 -0
  283. package/dist/better-auth/plugin/payload/components/logout-button.js.map +1 -0
  284. package/dist/better-auth/plugin/payload/components/passkeys/add-button.d.ts +8 -0
  285. package/dist/better-auth/plugin/payload/components/passkeys/add-button.js +117 -0
  286. package/dist/better-auth/plugin/payload/components/passkeys/add-button.js.map +1 -0
  287. package/dist/better-auth/plugin/payload/components/passkeys/client.d.ts +3 -0
  288. package/dist/better-auth/plugin/payload/components/passkeys/client.js +66 -0
  289. package/dist/better-auth/plugin/payload/components/passkeys/client.js.map +1 -0
  290. package/dist/better-auth/plugin/payload/components/passkeys/index.d.ts +4 -0
  291. package/dist/better-auth/plugin/payload/components/passkeys/index.js +52 -0
  292. package/dist/better-auth/plugin/payload/components/passkeys/index.js.map +1 -0
  293. package/dist/better-auth/plugin/payload/components/passkeys/list.d.ts +8 -0
  294. package/dist/better-auth/plugin/payload/components/passkeys/list.js +57 -0
  295. package/dist/better-auth/plugin/payload/components/passkeys/list.js.map +1 -0
  296. package/dist/better-auth/plugin/payload/components/passkeys/types.d.ts +22 -0
  297. package/dist/better-auth/plugin/payload/components/passkeys/types.js +3 -0
  298. package/dist/better-auth/plugin/payload/components/passkeys/types.js.map +1 -0
  299. package/dist/better-auth/plugin/payload/components/rsc-redirect.d.ts +6 -0
  300. package/dist/better-auth/plugin/payload/components/rsc-redirect.js +7 -0
  301. package/dist/better-auth/plugin/payload/components/rsc-redirect.js.map +1 -0
  302. package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.d.ts +15 -0
  303. package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js +157 -0
  304. package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js.map +1 -0
  305. package/dist/better-auth/plugin/payload/components/token-field.d.ts +4 -0
  306. package/dist/better-auth/plugin/payload/components/token-field.js +31 -0
  307. package/dist/better-auth/plugin/payload/components/token-field.js.map +1 -0
  308. package/dist/better-auth/plugin/payload/components/two-factor-auth/index.d.ts +8 -0
  309. package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js +300 -0
  310. package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js.map +1 -0
  311. package/dist/better-auth/plugin/payload/exports/client.d.ts +6 -0
  312. package/dist/better-auth/plugin/payload/exports/client.js +8 -0
  313. package/dist/better-auth/plugin/payload/exports/client.js.map +1 -0
  314. package/dist/better-auth/plugin/payload/exports/rsc.d.ts +8 -0
  315. package/dist/better-auth/plugin/payload/exports/rsc.js +10 -0
  316. package/dist/better-auth/plugin/payload/exports/rsc.js.map +1 -0
  317. package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.d.ts +2 -0
  318. package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js +9 -0
  319. package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js.map +1 -0
  320. package/dist/better-auth/plugin/payload/utils/get-safe-redirect.d.ts +1 -0
  321. package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js +22 -0
  322. package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js.map +1 -0
  323. package/dist/better-auth/plugin/payload/views/admin-login/client.d.ts +19 -0
  324. package/dist/better-auth/plugin/payload/views/admin-login/client.js +226 -0
  325. package/dist/better-auth/plugin/payload/views/admin-login/client.js.map +1 -0
  326. package/dist/better-auth/plugin/payload/views/admin-login/index.d.ts +10 -0
  327. package/dist/better-auth/plugin/payload/views/admin-login/index.js +150 -0
  328. package/dist/better-auth/plugin/payload/views/admin-login/index.js.map +1 -0
  329. package/dist/better-auth/plugin/payload/views/admin-signup/client.d.ts +16 -0
  330. package/dist/better-auth/plugin/payload/views/admin-signup/client.js +299 -0
  331. package/dist/better-auth/plugin/payload/views/admin-signup/client.js.map +1 -0
  332. package/dist/better-auth/plugin/payload/views/admin-signup/index.d.ts +9 -0
  333. package/dist/better-auth/plugin/payload/views/admin-signup/index.js +104 -0
  334. package/dist/better-auth/plugin/payload/views/admin-signup/index.js.map +1 -0
  335. package/dist/better-auth/plugin/payload/views/forgot-password/client.d.ts +7 -0
  336. package/dist/better-auth/plugin/payload/views/forgot-password/client.js +119 -0
  337. package/dist/better-auth/plugin/payload/views/forgot-password/client.js.map +1 -0
  338. package/dist/better-auth/plugin/payload/views/forgot-password/index.d.ts +8 -0
  339. package/dist/better-auth/plugin/payload/views/forgot-password/index.js +78 -0
  340. package/dist/better-auth/plugin/payload/views/forgot-password/index.js.map +1 -0
  341. package/dist/better-auth/plugin/payload/views/reset-password/client.d.ts +10 -0
  342. package/dist/better-auth/plugin/payload/views/reset-password/client.js +144 -0
  343. package/dist/better-auth/plugin/payload/views/reset-password/client.js.map +1 -0
  344. package/dist/better-auth/plugin/payload/views/reset-password/index.d.ts +8 -0
  345. package/dist/better-auth/plugin/payload/views/reset-password/index.js +96 -0
  346. package/dist/better-auth/plugin/payload/views/reset-password/index.js.map +1 -0
  347. package/dist/better-auth/plugin/payload/views/two-factor-verify/client.d.ts +6 -0
  348. package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js +96 -0
  349. package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js.map +1 -0
  350. package/dist/better-auth/plugin/payload/views/two-factor-verify/index.d.ts +9 -0
  351. package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js +56 -0
  352. package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js.map +1 -0
  353. package/dist/better-auth/plugin/types.d.ts +429 -0
  354. package/dist/better-auth/plugin/types.js +3 -0
  355. package/dist/better-auth/plugin/types.js.map +1 -0
  356. package/dist/better-auth/plugin/utils/set.d.ts +39 -0
  357. package/dist/better-auth/plugin/utils/set.js +103 -0
  358. package/dist/better-auth/plugin/utils/set.js.map +1 -0
  359. package/dist/better-auth/scripts/generate-types.d.ts +1 -0
  360. package/dist/better-auth/scripts/generate-types.js +234 -0
  361. package/dist/better-auth/scripts/generate-types.js.map +1 -0
  362. package/dist/better-auth/types.d.ts +2 -0
  363. package/dist/better-auth/types.js +4 -0
  364. package/dist/better-auth/types.js.map +1 -0
  365. package/dist/index.d.ts +1 -0
  366. package/dist/index.js +4 -0
  367. package/dist/index.js.map +1 -0
  368. package/dist/shared/components/icons.d.ts +7 -0
  369. package/dist/shared/components/icons.js +442 -0
  370. package/dist/shared/components/icons.js.map +1 -0
  371. package/dist/shared/components/logo.d.ts +3 -0
  372. package/dist/shared/components/logo.js +24 -0
  373. package/dist/shared/components/logo.js.map +1 -0
  374. package/dist/shared/form/components/submit.d.ts +7 -0
  375. package/dist/shared/form/components/submit.js +16 -0
  376. package/dist/shared/form/components/submit.js.map +1 -0
  377. package/dist/shared/form/fields/text-field.d.ts +8 -0
  378. package/dist/shared/form/fields/text-field.js +37 -0
  379. package/dist/shared/form/fields/text-field.js.map +1 -0
  380. package/dist/shared/form/index.d.ts +4 -0
  381. package/dist/shared/form/index.js +8 -0
  382. package/dist/shared/form/index.js.map +1 -0
  383. package/dist/shared/form/ui/header/index.d.ts +8 -0
  384. package/dist/shared/form/ui/header/index.js +24 -0
  385. package/dist/shared/form/ui/header/index.js.map +1 -0
  386. package/dist/shared/form/ui/index.d.ts +31 -0
  387. package/dist/shared/form/ui/index.js +57 -0
  388. package/dist/shared/form/ui/index.js.map +1 -0
  389. package/dist/shared/form/validation.d.ts +51 -0
  390. package/dist/shared/form/validation.js +127 -0
  391. package/dist/shared/form/validation.js.map +1 -0
  392. package/dist/shared/index.d.ts +2 -0
  393. package/dist/shared/index.js +4 -0
  394. package/dist/shared/index.js.map +1 -0
  395. package/dist/shared/payload/fields/field-copy-button/index.d.ts +3 -0
  396. package/dist/shared/payload/fields/field-copy-button/index.js +38 -0
  397. package/dist/shared/payload/fields/field-copy-button/index.js.map +1 -0
  398. package/dist/shared/payload/fields/generate-uuid-button/index.d.ts +3 -0
  399. package/dist/shared/payload/fields/generate-uuid-button/index.js +26 -0
  400. package/dist/shared/payload/fields/generate-uuid-button/index.js.map +1 -0
  401. package/dist/shared/payload/fields/index.d.ts +2 -0
  402. package/dist/shared/payload/fields/index.js +4 -0
  403. package/dist/shared/payload/fields/index.js.map +1 -0
  404. package/dist/shared/utils/regex.d.ts +2 -0
  405. package/dist/shared/utils/regex.js +4 -0
  406. package/dist/shared/utils/regex.js.map +1 -0
  407. package/dist/shared/utils/try-catch.d.ts +11 -0
  408. package/dist/shared/utils/try-catch.js +17 -0
  409. package/dist/shared/utils/try-catch.js.map +1 -0
  410. package/dist/shared/utils/value-or-default.d.ts +9 -0
  411. package/dist/shared/utils/value-or-default.js +12 -0
  412. package/dist/shared/utils/value-or-default.js.map +1 -0
  413. package/package.json +122 -0
@@ -0,0 +1,20 @@
1
+ export function getAllRoleOptions(pluginOptions) {
2
+ const adminRoles = pluginOptions.users?.adminRoles ?? [
3
+ 'admin'
4
+ ];
5
+ const roles = pluginOptions.users?.roles ?? [
6
+ 'user'
7
+ ];
8
+ const allRoleOptions = [
9
+ ...new Set([
10
+ ...adminRoles,
11
+ ...roles
12
+ ])
13
+ ].map((role)=>({
14
+ label: role.split(/[-_\s]/).map((word)=>word.charAt(0).toUpperCase() + word.slice(1)).join(' '),
15
+ value: role
16
+ }));
17
+ return allRoleOptions;
18
+ }
19
+
20
+ //# sourceMappingURL=get-all-roles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/plugin/helpers/get-all-roles.ts"],"sourcesContent":["import type { BetterAuthPluginOptions } from '../types';\n\nexport function getAllRoleOptions(pluginOptions: BetterAuthPluginOptions) {\n const adminRoles = pluginOptions.users?.adminRoles ?? ['admin'];\n const roles = pluginOptions.users?.roles ?? ['user'];\n const allRoleOptions = [...new Set([...adminRoles, ...roles])].map(role => ({\n label: role\n .split(/[-_\\s]/)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' '),\n value: role,\n }));\n return allRoleOptions;\n}\n"],"names":["getAllRoleOptions","pluginOptions","adminRoles","users","roles","allRoleOptions","Set","map","role","label","split","word","charAt","toUpperCase","slice","join","value"],"mappings":"AAEA,OAAO,SAASA,kBAAkBC,aAAsC;IACtE,MAAMC,aAAaD,cAAcE,KAAK,EAAED,cAAc;QAAC;KAAQ;IAC/D,MAAME,QAAQH,cAAcE,KAAK,EAAEC,SAAS;QAAC;KAAO;IACpD,MAAMC,iBAAiB;WAAI,IAAIC,IAAI;eAAIJ;eAAeE;SAAM;KAAE,CAACG,GAAG,CAACC,CAAAA,OAAS,CAAA;YAC1EC,OAAOD,KACJE,KAAK,CAAC,UACNH,GAAG,CAACI,CAAAA,OAAQA,KAAKC,MAAM,CAAC,GAAGC,WAAW,KAAKF,KAAKG,KAAK,CAAC,IACtDC,IAAI,CAAC;YACRC,OAAOR;QACT,CAAA;IACA,OAAOH;AACT"}
@@ -0,0 +1,18 @@
1
+ import type { BetterAuthPluginOptions, BetterAuthSchemas } from '../types';
2
+ /**
3
+ * A consistent BetterAuth schema generator.
4
+ *
5
+ * Differences from the original `getSchema` implementation in BetterAuth:
6
+ * 1. Keys in the returned object are always the **static table identifiers** coming from
7
+ * `getAuthTables`, never the possibly-overridden `modelName`. This guarantees that
8
+ * subsequent look-ups remain stable even if the user renames collections.
9
+ * 2. Each schema entry now contains an explicit `modelName` property exposing the current
10
+ * (potentially user-overridden) model name, while `fields` continue to be referenced by
11
+ * their static BetterAuth field keys.
12
+ * 3. When converting fields, we store them under their original key (`actualFields[key] = field`)
13
+ * instead of `field.fieldName || key` to avoid accidental renames.
14
+ *
15
+ * @param config - The BetterAuth options fed into `getAuthTables`.
16
+ * @returns A map keyed by static table keys, each value containing `{ modelName, fields, order }`.
17
+ */
18
+ export declare function getDefaultBetterAuthSchema(pluginOptions: BetterAuthPluginOptions): BetterAuthSchemas;
@@ -0,0 +1,70 @@
1
+ import { getAuthTables } from "better-auth/db";
2
+ import { baModelFieldKeysToFieldNames } from "../constants";
3
+ import { getDefaultCollectionSlug } from "./get-collection-slug";
4
+ /**
5
+ * A consistent BetterAuth schema generator.
6
+ *
7
+ * Differences from the original `getSchema` implementation in BetterAuth:
8
+ * 1. Keys in the returned object are always the **static table identifiers** coming from
9
+ * `getAuthTables`, never the possibly-overridden `modelName`. This guarantees that
10
+ * subsequent look-ups remain stable even if the user renames collections.
11
+ * 2. Each schema entry now contains an explicit `modelName` property exposing the current
12
+ * (potentially user-overridden) model name, while `fields` continue to be referenced by
13
+ * their static BetterAuth field keys.
14
+ * 3. When converting fields, we store them under their original key (`actualFields[key] = field`)
15
+ * instead of `field.fieldName || key` to avoid accidental renames.
16
+ *
17
+ * @param config - The BetterAuth options fed into `getAuthTables`.
18
+ * @returns A map keyed by static table keys, each value containing `{ modelName, fields, order }`.
19
+ */ export function getDefaultBetterAuthSchema(pluginOptions) {
20
+ const betterAuthOptions = pluginOptions.betterAuthOptions ?? {};
21
+ const tables = getAuthTables(betterAuthOptions);
22
+ const schema = {};
23
+ for (const modelKey of Object.keys(tables)){
24
+ const table = tables[modelKey];
25
+ // Skip if table is undefined
26
+ if (!table) continue;
27
+ // Resolve the canonical collection slug / model name for this key
28
+ const resolvedModelName = getDefaultCollectionSlug({
29
+ modelKey,
30
+ pluginOptions
31
+ });
32
+ const defaultFieldMap = baModelFieldKeysToFieldNames[modelKey] ?? {};
33
+ const actualFields = {};
34
+ Object.entries(table.fields ?? {}).forEach(([fieldKey, fieldValue])=>{
35
+ // Build the field ensuring a fieldName exists
36
+ const newField = {
37
+ ...fieldValue,
38
+ fieldName: defaultFieldMap[fieldKey] ?? fieldKey
39
+ };
40
+ // Rewrite references to use the resolved modelName for the target table
41
+ if (fieldValue.references) {
42
+ const refModelKey = fieldValue.references.model;
43
+ const resolvedRefModelName = getDefaultCollectionSlug({
44
+ modelKey: refModelKey,
45
+ pluginOptions
46
+ });
47
+ newField.references = {
48
+ field: fieldValue.references.field,
49
+ model: resolvedRefModelName
50
+ };
51
+ }
52
+ actualFields[fieldKey] = newField;
53
+ });
54
+ if (schema[modelKey]) {
55
+ schema[modelKey].fields = {
56
+ ...schema[modelKey].fields,
57
+ ...actualFields
58
+ };
59
+ continue;
60
+ }
61
+ schema[modelKey] = {
62
+ fields: actualFields,
63
+ modelName: resolvedModelName,
64
+ order: table.order ?? Number.POSITIVE_INFINITY
65
+ };
66
+ }
67
+ return schema;
68
+ }
69
+
70
+ //# sourceMappingURL=get-better-auth-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/plugin/helpers/get-better-auth-schema.ts"],"sourcesContent":["import type { ModelKey } from '@/better-auth/generated-types';\nimport { getAuthTables } from 'better-auth/db';\nimport type { DBFieldAttribute } from 'better-auth/db';\nimport type { BetterAuthOptions as BetterAuthOptionsType } from 'better-auth/types';\nimport { baModelFieldKeysToFieldNames } from '../constants';\nimport type { BetterAuthPluginOptions, BetterAuthSchemas } from '../types';\nimport { getDefaultCollectionSlug } from './get-collection-slug';\n\n/**\n * A consistent BetterAuth schema generator.\n *\n * Differences from the original `getSchema` implementation in BetterAuth:\n * 1. Keys in the returned object are always the **static table identifiers** coming from\n * `getAuthTables`, never the possibly-overridden `modelName`. This guarantees that\n * subsequent look-ups remain stable even if the user renames collections.\n * 2. Each schema entry now contains an explicit `modelName` property exposing the current\n * (potentially user-overridden) model name, while `fields` continue to be referenced by\n * their static BetterAuth field keys.\n * 3. When converting fields, we store them under their original key (`actualFields[key] = field`)\n * instead of `field.fieldName || key` to avoid accidental renames.\n *\n * @param config - The BetterAuth options fed into `getAuthTables`.\n * @returns A map keyed by static table keys, each value containing `{ modelName, fields, order }`.\n */\nexport function getDefaultBetterAuthSchema(\n pluginOptions: BetterAuthPluginOptions\n): BetterAuthSchemas {\n const betterAuthOptions = pluginOptions.betterAuthOptions ?? {};\n const tables = getAuthTables(betterAuthOptions as BetterAuthOptionsType);\n\n const schema: Partial<BetterAuthSchemas> = {};\n\n for (const modelKey of Object.keys(tables) as ModelKey[]) {\n const table = tables[modelKey];\n\n // Skip if table is undefined\n if (!table) continue;\n\n // Resolve the canonical collection slug / model name for this key\n const resolvedModelName = getDefaultCollectionSlug({ modelKey, pluginOptions });\n\n const defaultFieldMap =\n (baModelFieldKeysToFieldNames as Record<string, Record<string, string>>)[modelKey] ?? {};\n\n const actualFields: Record<string, DBFieldAttribute> = {};\n\n Object.entries(table.fields ?? {}).forEach(([fieldKey, fieldValue]) => {\n // Build the field ensuring a fieldName exists\n const newField: DBFieldAttribute = {\n ...fieldValue,\n fieldName: defaultFieldMap[fieldKey] ?? fieldKey,\n };\n\n // Rewrite references to use the resolved modelName for the target table\n if (fieldValue.references) {\n const refModelKey = fieldValue.references.model as string;\n const resolvedRefModelName = getDefaultCollectionSlug({\n modelKey: refModelKey,\n pluginOptions,\n });\n newField.references = {\n field: fieldValue.references.field,\n model: resolvedRefModelName,\n };\n }\n\n actualFields[fieldKey] = newField;\n });\n\n if (schema[modelKey]) {\n schema[modelKey].fields = {\n ...schema[modelKey].fields,\n ...actualFields,\n };\n continue;\n }\n\n schema[modelKey] = {\n fields: actualFields,\n modelName: resolvedModelName,\n order: table.order ?? Number.POSITIVE_INFINITY,\n };\n }\n\n return schema as BetterAuthSchemas;\n}\n"],"names":["getAuthTables","baModelFieldKeysToFieldNames","getDefaultCollectionSlug","getDefaultBetterAuthSchema","pluginOptions","betterAuthOptions","tables","schema","modelKey","Object","keys","table","resolvedModelName","defaultFieldMap","actualFields","entries","fields","forEach","fieldKey","fieldValue","newField","fieldName","references","refModelKey","model","resolvedRefModelName","field","modelName","order","Number","POSITIVE_INFINITY"],"mappings":"AACA,SAASA,aAAa,QAAQ,iBAAiB;AAG/C,SAASC,4BAA4B,QAAQ,eAAe;AAE5D,SAASC,wBAAwB,QAAQ,wBAAwB;AAEjE;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,2BACdC,aAAsC;IAEtC,MAAMC,oBAAoBD,cAAcC,iBAAiB,IAAI,CAAC;IAC9D,MAAMC,SAASN,cAAcK;IAE7B,MAAME,SAAqC,CAAC;IAE5C,KAAK,MAAMC,YAAYC,OAAOC,IAAI,CAACJ,QAAuB;QACxD,MAAMK,QAAQL,MAAM,CAACE,SAAS;QAE9B,6BAA6B;QAC7B,IAAI,CAACG,OAAO;QAEZ,kEAAkE;QAClE,MAAMC,oBAAoBV,yBAAyB;YAAEM;YAAUJ;QAAc;QAE7E,MAAMS,kBACJ,AAACZ,4BAAuE,CAACO,SAAS,IAAI,CAAC;QAEzF,MAAMM,eAAiD,CAAC;QAExDL,OAAOM,OAAO,CAACJ,MAAMK,MAAM,IAAI,CAAC,GAAGC,OAAO,CAAC,CAAC,CAACC,UAAUC,WAAW;YAChE,8CAA8C;YAC9C,MAAMC,WAA6B;gBACjC,GAAGD,UAAU;gBACbE,WAAWR,eAAe,CAACK,SAAS,IAAIA;YAC1C;YAEA,wEAAwE;YACxE,IAAIC,WAAWG,UAAU,EAAE;gBACzB,MAAMC,cAAcJ,WAAWG,UAAU,CAACE,KAAK;gBAC/C,MAAMC,uBAAuBvB,yBAAyB;oBACpDM,UAAUe;oBACVnB;gBACF;gBACAgB,SAASE,UAAU,GAAG;oBACpBI,OAAOP,WAAWG,UAAU,CAACI,KAAK;oBAClCF,OAAOC;gBACT;YACF;YAEAX,YAAY,CAACI,SAAS,GAAGE;QAC3B;QAEA,IAAIb,MAAM,CAACC,SAAS,EAAE;YACpBD,MAAM,CAACC,SAAS,CAACQ,MAAM,GAAG;gBACxB,GAAGT,MAAM,CAACC,SAAS,CAACQ,MAAM;gBAC1B,GAAGF,YAAY;YACjB;YACA;QACF;QAEAP,MAAM,CAACC,SAAS,GAAG;YACjBQ,QAAQF;YACRa,WAAWf;YACXgB,OAAOjB,MAAMiB,KAAK,IAAIC,OAAOC,iBAAiB;QAChD;IACF;IAEA,OAAOvB;AACT"}
@@ -0,0 +1,5 @@
1
+ import type { BetterAuthPluginOptions } from '../types';
2
+ export declare function getDefaultCollectionSlug({ pluginOptions, modelKey, }: {
3
+ pluginOptions: BetterAuthPluginOptions;
4
+ modelKey: string;
5
+ }): string;
@@ -0,0 +1,20 @@
1
+ import { baModelKeyToSlug, baseSlugs } from "../constants";
2
+ export function getDefaultCollectionSlug({ pluginOptions, modelKey }) {
3
+ const baseSlug = baModelKeyToSlug[modelKey] ?? modelKey;
4
+ switch(modelKey){
5
+ case 'user':
6
+ return pluginOptions.users?.slug ?? baseSlugs.users;
7
+ case 'account':
8
+ return pluginOptions.accounts?.slug ?? baseSlugs.accounts;
9
+ case 'session':
10
+ return pluginOptions.sessions?.slug ?? baseSlugs.sessions;
11
+ case 'verification':
12
+ return pluginOptions.verifications?.slug ?? baseSlugs.verifications;
13
+ case 'adminInvitation':
14
+ return pluginOptions.adminInvitations?.slug ?? baseSlugs.adminInvitations;
15
+ default:
16
+ return baseSlug;
17
+ }
18
+ }
19
+
20
+ //# sourceMappingURL=get-collection-slug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/plugin/helpers/get-collection-slug.ts"],"sourcesContent":["import { baModelKeyToSlug, baseSlugs } from '../constants';\nimport type { BetterAuthPluginOptions } from '../types';\n\nexport function getDefaultCollectionSlug({\n pluginOptions,\n modelKey,\n}: {\n pluginOptions: BetterAuthPluginOptions;\n modelKey: string;\n}): string {\n const baseSlug = baModelKeyToSlug[modelKey as keyof typeof baModelKeyToSlug] ?? modelKey;\n\n switch (modelKey) {\n case 'user':\n return pluginOptions.users?.slug ?? baseSlugs.users;\n case 'account':\n return pluginOptions.accounts?.slug ?? baseSlugs.accounts;\n case 'session':\n return pluginOptions.sessions?.slug ?? baseSlugs.sessions;\n case 'verification':\n return pluginOptions.verifications?.slug ?? baseSlugs.verifications;\n case 'adminInvitation':\n return pluginOptions.adminInvitations?.slug ?? baseSlugs.adminInvitations;\n default:\n return baseSlug;\n }\n}\n"],"names":["baModelKeyToSlug","baseSlugs","getDefaultCollectionSlug","pluginOptions","modelKey","baseSlug","users","slug","accounts","sessions","verifications","adminInvitations"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,SAAS,QAAQ,eAAe;AAG3D,OAAO,SAASC,yBAAyB,EACvCC,aAAa,EACbC,QAAQ,EAIT;IACC,MAAMC,WAAWL,gBAAgB,CAACI,SAA0C,IAAIA;IAEhF,OAAQA;QACN,KAAK;YACH,OAAOD,cAAcG,KAAK,EAAEC,QAAQN,UAAUK,KAAK;QACrD,KAAK;YACH,OAAOH,cAAcK,QAAQ,EAAED,QAAQN,UAAUO,QAAQ;QAC3D,KAAK;YACH,OAAOL,cAAcM,QAAQ,EAAEF,QAAQN,UAAUQ,QAAQ;QAC3D,KAAK;YACH,OAAON,cAAcO,aAAa,EAAEH,QAAQN,UAAUS,aAAa;QACrE,KAAK;YACH,OAAOP,cAAcQ,gBAAgB,EAAEJ,QAAQN,UAAUU,gBAAgB;QAC3E;YACE,OAAON;IACX;AACF"}
@@ -0,0 +1,15 @@
1
+ import type { BetterAuthFullSchema, ModelKey } from '@/better-auth/generated-types';
2
+ import { type Collection, type CollectionConfig } from 'payload';
3
+ export declare function getCollectionByModelKey(collections: Record<string, Collection>, modelKey: ModelKey): CollectionConfig;
4
+ /**
5
+ * Retrieves the field name from a collection based on the field key
6
+ *
7
+ * This function searches through the fields of a collection to find a field
8
+ * that has a matching custom property betterAuthFieldKey.
9
+ *
10
+ * @param collection - The collection configuration to search through
11
+ * @param model - The model key of the collection (This is really just for type hinting)
12
+ * @param fieldKey - The key of the field to search for
13
+ * @returns The name of the field if found, otherwise the field key itself
14
+ */
15
+ export declare function getCollectionFieldNameByFieldKey<M extends ModelKey>(collection: CollectionConfig, _model: M, fieldKey: Extract<keyof BetterAuthFullSchema[M], string>): string;
@@ -0,0 +1,29 @@
1
+ import { flattenAllFields } from "payload";
2
+ export function getCollectionByModelKey(collections, modelKey) {
3
+ const collection = Object.values(collections).find((collectionItem)=>{
4
+ const customConfig = collectionItem.config?.custom;
5
+ return customConfig?.betterAuthModelKey === modelKey;
6
+ });
7
+ if (!collection) {
8
+ throw new Error(`Collection with key ${modelKey} not found`);
9
+ }
10
+ return collection.config;
11
+ }
12
+ /**
13
+ * Retrieves the field name from a collection based on the field key
14
+ *
15
+ * This function searches through the fields of a collection to find a field
16
+ * that has a matching custom property betterAuthFieldKey.
17
+ *
18
+ * @param collection - The collection configuration to search through
19
+ * @param model - The model key of the collection (This is really just for type hinting)
20
+ * @param fieldKey - The key of the field to search for
21
+ * @returns The name of the field if found, otherwise the field key itself
22
+ */ export function getCollectionFieldNameByFieldKey(collection, _model, fieldKey) {
23
+ const fields = flattenAllFields({
24
+ fields: collection.fields
25
+ });
26
+ return fields.find((field)=>field.custom?.betterAuthFieldKey === fieldKey)?.name ?? fieldKey;
27
+ }
28
+
29
+ //# sourceMappingURL=get-collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/plugin/helpers/get-collection.ts"],"sourcesContent":["import type { BetterAuthFullSchema, ModelKey } from '@/better-auth/generated-types';\nimport { type Collection, type CollectionConfig, flattenAllFields } from 'payload';\n\nexport function getCollectionByModelKey(\n collections: Record<string, Collection>,\n modelKey: ModelKey\n): CollectionConfig {\n const collection = Object.values(collections).find(collectionItem => {\n const customConfig = collectionItem.config?.custom as\n | { betterAuthModelKey?: string }\n | undefined;\n return customConfig?.betterAuthModelKey === modelKey;\n });\n\n if (!collection) {\n throw new Error(`Collection with key ${modelKey} not found`);\n }\n\n return collection.config;\n}\n\n/**\n * Retrieves the field name from a collection based on the field key\n *\n * This function searches through the fields of a collection to find a field\n * that has a matching custom property betterAuthFieldKey.\n *\n * @param collection - The collection configuration to search through\n * @param model - The model key of the collection (This is really just for type hinting)\n * @param fieldKey - The key of the field to search for\n * @returns The name of the field if found, otherwise the field key itself\n */\nexport function getCollectionFieldNameByFieldKey<M extends ModelKey>(\n collection: CollectionConfig,\n _model: M,\n fieldKey: Extract<keyof BetterAuthFullSchema[M], string>\n): string {\n const fields = flattenAllFields({ fields: collection.fields });\n return fields.find(field => field.custom?.betterAuthFieldKey === fieldKey)?.name ?? fieldKey;\n}\n"],"names":["flattenAllFields","getCollectionByModelKey","collections","modelKey","collection","Object","values","find","collectionItem","customConfig","config","custom","betterAuthModelKey","Error","getCollectionFieldNameByFieldKey","_model","fieldKey","fields","field","betterAuthFieldKey","name"],"mappings":"AACA,SAAiDA,gBAAgB,QAAQ,UAAU;AAEnF,OAAO,SAASC,wBACdC,WAAuC,EACvCC,QAAkB;IAElB,MAAMC,aAAaC,OAAOC,MAAM,CAACJ,aAAaK,IAAI,CAACC,CAAAA;QACjD,MAAMC,eAAeD,eAAeE,MAAM,EAAEC;QAG5C,OAAOF,cAAcG,uBAAuBT;IAC9C;IAEA,IAAI,CAACC,YAAY;QACf,MAAM,IAAIS,MAAM,CAAC,oBAAoB,EAAEV,SAAS,UAAU,CAAC;IAC7D;IAEA,OAAOC,WAAWM,MAAM;AAC1B;AAEA;;;;;;;;;;CAUC,GACD,OAAO,SAASI,iCACdV,UAA4B,EAC5BW,MAAS,EACTC,QAAwD;IAExD,MAAMC,SAASjB,iBAAiB;QAAEiB,QAAQb,WAAWa,MAAM;IAAC;IAC5D,OAAOA,OAAOV,IAAI,CAACW,CAAAA,QAASA,MAAMP,MAAM,EAAEQ,uBAAuBH,WAAWI,QAAQJ;AACtF"}
@@ -0,0 +1,2 @@
1
+ import type { BetterAuthOptions } from 'better-auth';
2
+ export declare function getIp(headers: Headers, options: BetterAuthOptions): string | null;
@@ -0,0 +1,31 @@
1
+ export function getIp(headers, options) {
2
+ if (options.advanced?.ipAddress?.disableIpTracking) {
3
+ return null;
4
+ }
5
+ const testIP = '127.0.0.1';
6
+ if ((process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'development') ?? false) {
7
+ return testIP;
8
+ }
9
+ const ipHeaders = options.advanced?.ipAddress?.ipAddressHeaders;
10
+ const keys = ipHeaders ?? [
11
+ 'x-client-ip',
12
+ 'x-forwarded-for',
13
+ 'cf-connecting-ip',
14
+ 'fastly-client-ip',
15
+ 'x-real-ip',
16
+ 'x-cluster-client-ip',
17
+ 'x-forwarded',
18
+ 'forwarded-for',
19
+ 'forwarded'
20
+ ];
21
+ for (const key of keys){
22
+ const value = headers.get(key);
23
+ if (typeof value === 'string') {
24
+ const ip = value.split(',')[0]?.trim();
25
+ if (ip) return ip;
26
+ }
27
+ }
28
+ return null;
29
+ }
30
+
31
+ //# sourceMappingURL=get-ip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/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,EAAEC;YAChC,IAAIF,IAAI,OAAOA;QACjB;IACF;IACA,OAAO;AACT"}
@@ -0,0 +1,2 @@
1
+ import type { CookiePrefixOptions } from 'better-auth';
2
+ export declare function getSignedCookie(cookies: string, key: string, secret: string, prefix?: CookiePrefixOptions): Promise<string | false>;
@@ -0,0 +1,65 @@
1
+ import { getWebcryptoSubtle } from "@better-auth/utils";
2
+ import { parseCookies } from "better-auth/cookies";
3
+ const algorithm = {
4
+ name: 'HMAC',
5
+ hash: 'SHA-256'
6
+ };
7
+ const getCookieKey = (key, prefix)=>{
8
+ let finalKey = key;
9
+ if (prefix) {
10
+ if (prefix === 'secure') {
11
+ finalKey = `__Secure-${key}`;
12
+ } else if (prefix === 'host') {
13
+ finalKey = `__Host-${key}`;
14
+ } else {
15
+ return undefined;
16
+ }
17
+ }
18
+ return finalKey;
19
+ };
20
+ const getCryptoKey = async (secret)=>{
21
+ const secretBuf = typeof secret === 'string' ? new TextEncoder().encode(secret) : secret;
22
+ return await getWebcryptoSubtle().importKey('raw', secretBuf, algorithm, false, [
23
+ 'sign',
24
+ 'verify'
25
+ ]);
26
+ };
27
+ const verifySignature = async (base64Signature, value, secret)=>{
28
+ try {
29
+ const signatureBinStr = atob(base64Signature);
30
+ const signature = new Uint8Array(signatureBinStr.length);
31
+ for(let i = 0, len = signatureBinStr.length; i < len; i++){
32
+ signature[i] = signatureBinStr.charCodeAt(i);
33
+ }
34
+ return await getWebcryptoSubtle().verify(algorithm, secret, signature, new TextEncoder().encode(value));
35
+ } catch (_e) {
36
+ // Signature verification failed - invalid signature format or crypto error
37
+ // Error details are intentionally not logged to avoid exposing sensitive cryptographic information
38
+ return false;
39
+ }
40
+ };
41
+ export async function getSignedCookie(cookies, key, secret, prefix) {
42
+ const parsedCookies = cookies ? parseCookies(cookies) : undefined;
43
+ const finalKey = getCookieKey(key, prefix);
44
+ if (!finalKey) {
45
+ return null;
46
+ }
47
+ const value = parsedCookies?.get(finalKey);
48
+ if (!value) {
49
+ return null;
50
+ }
51
+ const signatureStartPos = value.lastIndexOf('.');
52
+ if (signatureStartPos < 1) {
53
+ return null;
54
+ }
55
+ const signedValue = value.substring(0, signatureStartPos);
56
+ const signature = value.substring(signatureStartPos + 1);
57
+ if (signature.length !== 44 || !signature.endsWith('=')) {
58
+ return null;
59
+ }
60
+ const secretKey = await getCryptoKey(secret);
61
+ const isVerified = await verifySignature(signature, signedValue, secretKey);
62
+ return isVerified ? signedValue : false;
63
+ }
64
+
65
+ //# sourceMappingURL=get-signed-cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/plugin/helpers/get-signed-cookie.ts"],"sourcesContent":["import { getWebcryptoSubtle } from '@better-auth/utils';\nimport type { CookiePrefixOptions } from 'better-auth';\nimport { parseCookies } from 'better-auth/cookies';\n\nconst algorithm = { name: 'HMAC', hash: 'SHA-256' };\n\nconst 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\nconst getCryptoKey = async (secret: string | BufferSource) => {\n const secretBuf = typeof secret === 'string' ? new TextEncoder().encode(secret) : secret;\n return await getWebcryptoSubtle().importKey('raw', secretBuf, algorithm, false, [\n 'sign',\n 'verify',\n ]);\n};\n\nconst 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 getWebcryptoSubtle().verify(\n algorithm,\n secret,\n signature,\n new TextEncoder().encode(value)\n );\n } catch (_e) {\n // Signature verification failed - invalid signature format or crypto error\n // Error details are intentionally not logged to avoid exposing sensitive cryptographic information\n return false;\n }\n};\n\nexport async function getSignedCookie(\n cookies: string,\n key: string,\n secret: string,\n prefix?: CookiePrefixOptions\n) {\n const parsedCookies = cookies ? parseCookies(cookies) : undefined;\n\n const finalKey = getCookieKey(key, prefix);\n if (!finalKey) {\n return null;\n }\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":["getWebcryptoSubtle","parseCookies","algorithm","name","hash","getCookieKey","key","prefix","finalKey","undefined","getCryptoKey","secret","secretBuf","TextEncoder","encode","importKey","verifySignature","base64Signature","value","signatureBinStr","atob","signature","Uint8Array","length","i","len","charCodeAt","verify","_e","getSignedCookie","cookies","parsedCookies","get","signatureStartPos","lastIndexOf","signedValue","substring","endsWith","secretKey","isVerified"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,qBAAqB;AAExD,SAASC,YAAY,QAAQ,sBAAsB;AAEnD,MAAMC,YAAY;IAAEC,MAAM;IAAQC,MAAM;AAAU;AAElD,MAAMC,eAAe,CAACC,KAAaC;IACjC,IAAIC,WAAWF;IACf,IAAIC,QAAQ;QACV,IAAIA,WAAW,UAAU;YACvBC,WAAW,CAAC,SAAS,EAAEF,KAAK;QAC9B,OAAO,IAAIC,WAAW,QAAQ;YAC5BC,WAAW,CAAC,OAAO,EAAEF,KAAK;QAC5B,OAAO;YACL,OAAOG;QACT;IACF;IACA,OAAOD;AACT;AAEA,MAAME,eAAe,OAAOC;IAC1B,MAAMC,YAAY,OAAOD,WAAW,WAAW,IAAIE,cAAcC,MAAM,CAACH,UAAUA;IAClF,OAAO,MAAMX,qBAAqBe,SAAS,CAAC,OAAOH,WAAWV,WAAW,OAAO;QAC9E;QACA;KACD;AACH;AAEA,MAAMc,kBAAkB,OACtBC,iBACAC,OACAP;IAEA,IAAI;QACF,MAAMQ,kBAAkBC,KAAKH;QAC7B,MAAMI,YAAY,IAAIC,WAAWH,gBAAgBI,MAAM;QACvD,IAAK,IAAIC,IAAI,GAAGC,MAAMN,gBAAgBI,MAAM,EAAEC,IAAIC,KAAKD,IAAK;YAC1DH,SAAS,CAACG,EAAE,GAAGL,gBAAgBO,UAAU,CAACF;QAC5C;QACA,OAAO,MAAMxB,qBAAqB2B,MAAM,CACtCzB,WACAS,QACAU,WACA,IAAIR,cAAcC,MAAM,CAACI;IAE7B,EAAE,OAAOU,IAAI;QACX,2EAA2E;QAC3E,mGAAmG;QACnG,OAAO;IACT;AACF;AAEA,OAAO,eAAeC,gBACpBC,OAAe,EACfxB,GAAW,EACXK,MAAc,EACdJ,MAA4B;IAE5B,MAAMwB,gBAAgBD,UAAU7B,aAAa6B,WAAWrB;IAExD,MAAMD,WAAWH,aAAaC,KAAKC;IACnC,IAAI,CAACC,UAAU;QACb,OAAO;IACT;IACA,MAAMU,QAAQa,eAAeC,IAAIxB;IACjC,IAAI,CAACU,OAAO;QACV,OAAO;IACT;IACA,MAAMe,oBAAoBf,MAAMgB,WAAW,CAAC;IAC5C,IAAID,oBAAoB,GAAG;QACzB,OAAO;IACT;IACA,MAAME,cAAcjB,MAAMkB,SAAS,CAAC,GAAGH;IACvC,MAAMZ,YAAYH,MAAMkB,SAAS,CAACH,oBAAoB;IACtD,IAAIZ,UAAUE,MAAM,KAAK,MAAM,CAACF,UAAUgB,QAAQ,CAAC,MAAM;QACvD,OAAO;IACT;IACA,MAAMC,YAAY,MAAM5B,aAAaC;IACrC,MAAM4B,aAAa,MAAMvB,gBAAgBK,WAAWc,aAAaG;IACjE,OAAOC,aAAaJ,cAAc;AACpC"}
@@ -0,0 +1 @@
1
+ export { generateVerifyEmailUrl } from './generate-verify-email-url';
@@ -0,0 +1,3 @@
1
+ export { generateVerifyEmailUrl } from "./generate-verify-email-url";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/plugin/helpers/index.ts"],"sourcesContent":["export { generateVerifyEmailUrl } from './generate-verify-email-url';\n"],"names":["generateVerifyEmailUrl"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,8BAA8B"}
@@ -0,0 +1,59 @@
1
+ import type { Session, User } from 'better-auth';
2
+ import type { CollectionConfig } from 'payload';
3
+ export declare function prepareUser({ user, userCollection, }: {
4
+ user: User & Record<string, any>;
5
+ userCollection: CollectionConfig;
6
+ }): Promise<{
7
+ id: string;
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ emailVerified: boolean;
11
+ name: string;
12
+ email?: string;
13
+ image?: string;
14
+ } & Record<string, any>>;
15
+ export declare function prepareSession({ session, sessionCollection, }: {
16
+ session: Session & Record<string, any>;
17
+ sessionCollection: CollectionConfig;
18
+ }): Promise<{
19
+ id: string;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ userId: string;
23
+ expiresAt: Date;
24
+ token: string;
25
+ ipAddress?: string;
26
+ userAgent?: string;
27
+ } & Record<string, any>>;
28
+ /**
29
+ * Prepares session data for cookie cache by filtering user and session objects
30
+ * based on the payload configuration's 'saveToJwt' property
31
+ */
32
+ export declare function prepareSessionData({ sessionData, sessionsCollection, usersCollection, }: {
33
+ sessionData: {
34
+ session: Session & Record<string, any>;
35
+ user: User & Record<string, any>;
36
+ };
37
+ usersCollection: CollectionConfig;
38
+ sessionsCollection: CollectionConfig;
39
+ }): Promise<{
40
+ session: {
41
+ id: string;
42
+ createdAt: Date;
43
+ updatedAt: Date;
44
+ userId: string;
45
+ expiresAt: Date;
46
+ token: string;
47
+ ipAddress?: string;
48
+ userAgent?: string;
49
+ } & Record<string, any>;
50
+ user: {
51
+ id: string;
52
+ createdAt: Date;
53
+ updatedAt: Date;
54
+ emailVerified: boolean;
55
+ name: string;
56
+ email?: string;
57
+ image?: string;
58
+ } & Record<string, any>;
59
+ }>;
@@ -0,0 +1,49 @@
1
+ import { getFieldsToSign } from "payload";
2
+ export async function prepareUser({ user, userCollection }) {
3
+ const newUser = getFieldsToSign({
4
+ collectionConfig: userCollection,
5
+ email: user.email,
6
+ user: {
7
+ ...user,
8
+ collection: userCollection.slug
9
+ }
10
+ });
11
+ return newUser;
12
+ }
13
+ export async function prepareSession({ session, sessionCollection }) {
14
+ const filteredSession = getFieldsToSign({
15
+ collectionConfig: sessionCollection,
16
+ email: '',
17
+ user: {
18
+ ...session,
19
+ collection: sessionCollection.slug
20
+ }
21
+ });
22
+ filteredSession.email = undefined;
23
+ filteredSession.collection = undefined;
24
+ Object.assign(filteredSession, {
25
+ userId: session.userId
26
+ });
27
+ return filteredSession;
28
+ }
29
+ /**
30
+ * Prepares session data for cookie cache by filtering user and session objects
31
+ * based on the payload configuration's 'saveToJwt' property
32
+ */ export async function prepareSessionData({ sessionData, sessionsCollection, usersCollection }) {
33
+ if (!sessionData || !sessionData.user) return null;
34
+ const newUser = await prepareUser({
35
+ user: sessionData.user,
36
+ userCollection: usersCollection
37
+ });
38
+ const newSession = await prepareSession({
39
+ session: sessionData.session,
40
+ sessionCollection: sessionsCollection
41
+ });
42
+ const newSessionData = {
43
+ session: newSession,
44
+ user: newUser
45
+ };
46
+ return newSessionData;
47
+ }
48
+
49
+ //# sourceMappingURL=prepare-session-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/plugin/helpers/prepare-session-data.ts"],"sourcesContent":["import { getFieldsToSign } from 'payload';\n\nimport type { Session, User } from 'better-auth';\nimport type { CollectionConfig } from 'payload';\n\nexport async function prepareUser({\n user,\n userCollection,\n}: {\n user: User & Record<string, any>;\n userCollection: CollectionConfig;\n}) {\n const newUser = getFieldsToSign({\n collectionConfig: userCollection,\n email: user.email,\n user: {\n ...user,\n collection: userCollection.slug as 'users',\n } as any,\n });\n\n return newUser as User & Record<string, any>;\n}\n\nexport async function prepareSession({\n session,\n sessionCollection,\n}: {\n session: Session & Record<string, any>;\n sessionCollection: CollectionConfig;\n}) {\n const filteredSession = getFieldsToSign({\n collectionConfig: sessionCollection,\n email: '',\n user: {\n ...session,\n collection: sessionCollection.slug as 'sessions',\n } as any,\n });\n\n filteredSession.email = undefined;\n filteredSession.collection = undefined;\n Object.assign(filteredSession, {\n userId: session.userId,\n });\n\n return filteredSession as Session & Record<string, any>;\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 sessionData,\n sessionsCollection,\n usersCollection,\n}: {\n sessionData: {\n session: Session & Record<string, any>;\n user: User & Record<string, any>;\n };\n usersCollection: CollectionConfig;\n sessionsCollection: CollectionConfig;\n}) {\n if (!sessionData || !sessionData.user) return null;\n\n const newUser = await prepareUser({ user: sessionData.user, userCollection: usersCollection });\n const newSession = await prepareSession({\n session: sessionData.session,\n sessionCollection: sessionsCollection,\n });\n\n const newSessionData = {\n session: newSession,\n user: newUser,\n };\n\n return newSessionData;\n}\n"],"names":["getFieldsToSign","prepareUser","user","userCollection","newUser","collectionConfig","email","collection","slug","prepareSession","session","sessionCollection","filteredSession","undefined","Object","assign","userId","prepareSessionData","sessionData","sessionsCollection","usersCollection","newSession","newSessionData"],"mappings":"AAAA,SAASA,eAAe,QAAQ,UAAU;AAK1C,OAAO,eAAeC,YAAY,EAChCC,IAAI,EACJC,cAAc,EAIf;IACC,MAAMC,UAAUJ,gBAAgB;QAC9BK,kBAAkBF;QAClBG,OAAOJ,KAAKI,KAAK;QACjBJ,MAAM;YACJ,GAAGA,IAAI;YACPK,YAAYJ,eAAeK,IAAI;QACjC;IACF;IAEA,OAAOJ;AACT;AAEA,OAAO,eAAeK,eAAe,EACnCC,OAAO,EACPC,iBAAiB,EAIlB;IACC,MAAMC,kBAAkBZ,gBAAgB;QACtCK,kBAAkBM;QAClBL,OAAO;QACPJ,MAAM;YACJ,GAAGQ,OAAO;YACVH,YAAYI,kBAAkBH,IAAI;QACpC;IACF;IAEAI,gBAAgBN,KAAK,GAAGO;IACxBD,gBAAgBL,UAAU,GAAGM;IAC7BC,OAAOC,MAAM,CAACH,iBAAiB;QAC7BI,QAAQN,QAAQM,MAAM;IACxB;IAEA,OAAOJ;AACT;AAEA;;;CAGC,GACD,OAAO,eAAeK,mBAAmB,EACvCC,WAAW,EACXC,kBAAkB,EAClBC,eAAe,EAQhB;IACC,IAAI,CAACF,eAAe,CAACA,YAAYhB,IAAI,EAAE,OAAO;IAE9C,MAAME,UAAU,MAAMH,YAAY;QAAEC,MAAMgB,YAAYhB,IAAI;QAAEC,gBAAgBiB;IAAgB;IAC5F,MAAMC,aAAa,MAAMZ,eAAe;QACtCC,SAASQ,YAAYR,OAAO;QAC5BC,mBAAmBQ;IACrB;IAEA,MAAMG,iBAAiB;QACrBZ,SAASW;QACTnB,MAAME;IACR;IAEA,OAAOkB;AACT"}
@@ -0,0 +1,20 @@
1
+ import type { CollectionConfig } from 'payload';
2
+ import type { BetterAuthSchemas } from '../types';
3
+ /**
4
+ * Syncs a BetterAuth `ResolvedSchema` object with the *actual* collection
5
+ * definitions created by this plugin.
6
+ *
7
+ * This must run **after** the first call to `buildCollections`, because only
8
+ * then do we know the user-overridden slugs / field names. The algorithm is
9
+ * kept deliberately simple:
10
+ *
11
+ * 1. Build a `modelKey → newSlug` map from each collection's
12
+ * `custom.betterAuthModelKey` property.
13
+ * 2. Update `schema.modelName` for all affected tables.
14
+ * 3. Rewrite `references.model` in *every* table field according to the new
15
+ * slugs. We do this in a dedicated pass so referencing tables no longer
16
+ * depend on the original slugs.
17
+ * 4. Finally, iterate collections once more to apply any *field* renames via
18
+ * the `custom.betterAuthFieldKey` property.
19
+ */
20
+ export declare function syncResolvedSchemaWithCollectionMap(resolvedSchemas: BetterAuthSchemas, collectionMap: Record<string, CollectionConfig>): BetterAuthSchemas;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Syncs a BetterAuth `ResolvedSchema` object with the *actual* collection
3
+ * definitions created by this plugin.
4
+ *
5
+ * This must run **after** the first call to `buildCollections`, because only
6
+ * then do we know the user-overridden slugs / field names. The algorithm is
7
+ * kept deliberately simple:
8
+ *
9
+ * 1. Build a `modelKey → newSlug` map from each collection's
10
+ * `custom.betterAuthModelKey` property.
11
+ * 2. Update `schema.modelName` for all affected tables.
12
+ * 3. Rewrite `references.model` in *every* table field according to the new
13
+ * slugs. We do this in a dedicated pass so referencing tables no longer
14
+ * depend on the original slugs.
15
+ * 4. Finally, iterate collections once more to apply any *field* renames via
16
+ * the `custom.betterAuthFieldKey` property.
17
+ */ export function syncResolvedSchemaWithCollectionMap(resolvedSchemas, collectionMap) {
18
+ const collections = Object.values(collectionMap);
19
+ // Helper to update references across the whole schema
20
+ const updateReferences = (oldSlug, newSlug)=>{
21
+ for (const schema of Object.values(resolvedSchemas)){
22
+ for (const fieldAttr of Object.values(schema.fields)){
23
+ const ref = fieldAttr.references;
24
+ if (ref?.model === oldSlug) {
25
+ ref.model = newSlug;
26
+ }
27
+ }
28
+ }
29
+ };
30
+ for (const [modelKey, schema] of Object.entries(resolvedSchemas)){
31
+ const collection = collections.find((collectionItem)=>{
32
+ const custom = collectionItem.custom;
33
+ return custom?.betterAuthModelKey === modelKey;
34
+ });
35
+ if (!collection) {
36
+ // Configuration-time error - logger not available during schema sync
37
+ console.error(`Collection not found for model key: ${modelKey}`);
38
+ continue;
39
+ }
40
+ // ───── Sync slug ─────────────────────────────────────────────────────────
41
+ const oldSlug = schema.modelName;
42
+ const newSlug = collection.slug;
43
+ if (oldSlug !== newSlug) {
44
+ // First, rewrite *all* references that still point to the old slug
45
+ updateReferences(oldSlug, newSlug);
46
+ // Now store the new slug on the schema itself
47
+ schema.modelName = newSlug;
48
+ }
49
+ // ───── Sync field names ───────────────────────────────────────────────────
50
+ const collectionFields = Array.isArray(collection.fields) ? collection.fields : [];
51
+ for (const [fieldKey, schemaField] of Object.entries(schema.fields)){
52
+ const matchingField = collectionFields.find((field)=>field.custom?.betterAuthFieldKey === fieldKey);
53
+ if (!matchingField) {
54
+ // Configuration-time error - logger not available during schema sync
55
+ console.error(`Field not found for key "${fieldKey}" in collection "${collection.slug}"`);
56
+ continue;
57
+ }
58
+ const newName = matchingField.name;
59
+ if (newName && schemaField.fieldName !== newName) {
60
+ schemaField.fieldName = newName;
61
+ }
62
+ }
63
+ }
64
+ return resolvedSchemas;
65
+ }
66
+
67
+ //# sourceMappingURL=sync-resolved-schema-with-collection-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload';\nimport type { ModelKey } from '../../generated-types';\nimport type { BetterAuthSchemas, FieldWithIds } from '../types';\n\ntype BetterAuthCollectionCustom = {\n betterAuthModelKey?: string;\n betterAuthFieldKey?: string;\n};\n\n/**\n * Syncs a BetterAuth `ResolvedSchema` object with the *actual* collection\n * definitions created by this plugin.\n *\n * This must run **after** the first call to `buildCollections`, because only\n * then do we know the user-overridden slugs / field names. The algorithm is\n * kept deliberately simple:\n *\n * 1. Build a `modelKey → newSlug` map from each collection's\n * `custom.betterAuthModelKey` property.\n * 2. Update `schema.modelName` for all affected tables.\n * 3. Rewrite `references.model` in *every* table field according to the new\n * slugs. We do this in a dedicated pass so referencing tables no longer\n * depend on the original slugs.\n * 4. Finally, iterate collections once more to apply any *field* renames via\n * the `custom.betterAuthFieldKey` property.\n */\nexport function syncResolvedSchemaWithCollectionMap(\n resolvedSchemas: BetterAuthSchemas,\n collectionMap: Record<string, CollectionConfig>\n): BetterAuthSchemas {\n const collections = Object.values(collectionMap);\n\n // Helper to update references across the whole schema\n const updateReferences = (oldSlug: string, newSlug: string): void => {\n for (const schema of Object.values(resolvedSchemas)) {\n for (const fieldAttr of Object.values(schema.fields)) {\n const ref = fieldAttr.references;\n if (ref?.model === oldSlug) {\n ref.model = newSlug;\n }\n }\n }\n };\n\n for (const [modelKey, schema] of Object.entries(resolvedSchemas) as [\n ModelKey,\n (typeof resolvedSchemas)[ModelKey],\n ][]) {\n const collection = collections.find(collectionItem => {\n const custom = collectionItem.custom as BetterAuthCollectionCustom | undefined;\n return custom?.betterAuthModelKey === modelKey;\n });\n if (!collection) {\n // Configuration-time error - logger not available during schema sync\n\n console.error(`Collection not found for model key: ${modelKey}`);\n continue;\n }\n\n // ───── Sync slug ─────────────────────────────────────────────────────────\n const oldSlug = schema.modelName;\n const newSlug = collection.slug;\n\n if (oldSlug !== newSlug) {\n // First, rewrite *all* references that still point to the old slug\n updateReferences(oldSlug, newSlug);\n\n // Now store the new slug on the schema itself\n schema.modelName = newSlug;\n }\n\n // ───── Sync field names ───────────────────────────────────────────────────\n const collectionFields: FieldWithIds[] = Array.isArray(collection.fields)\n ? (collection.fields as FieldWithIds[])\n : [];\n\n for (const [fieldKey, schemaField] of Object.entries(schema.fields)) {\n const matchingField = collectionFields.find(\n field => field.custom?.betterAuthFieldKey === fieldKey\n );\n\n if (!matchingField) {\n // Configuration-time error - logger not available during schema sync\n\n console.error(`Field not found for key \"${fieldKey}\" in collection \"${collection.slug}\"`);\n continue;\n }\n\n const newName = matchingField.name;\n if (newName && schemaField.fieldName !== newName) {\n schemaField.fieldName = newName;\n }\n }\n }\n\n return resolvedSchemas;\n}\n"],"names":["syncResolvedSchemaWithCollectionMap","resolvedSchemas","collectionMap","collections","Object","values","updateReferences","oldSlug","newSlug","schema","fieldAttr","fields","ref","references","model","modelKey","entries","collection","find","collectionItem","custom","betterAuthModelKey","console","error","modelName","slug","collectionFields","Array","isArray","fieldKey","schemaField","matchingField","field","betterAuthFieldKey","newName","name","fieldName"],"mappings":"AASA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASA,oCACdC,eAAkC,EAClCC,aAA+C;IAE/C,MAAMC,cAAcC,OAAOC,MAAM,CAACH;IAElC,sDAAsD;IACtD,MAAMI,mBAAmB,CAACC,SAAiBC;QACzC,KAAK,MAAMC,UAAUL,OAAOC,MAAM,CAACJ,iBAAkB;YACnD,KAAK,MAAMS,aAAaN,OAAOC,MAAM,CAACI,OAAOE,MAAM,EAAG;gBACpD,MAAMC,MAAMF,UAAUG,UAAU;gBAChC,IAAID,KAAKE,UAAUP,SAAS;oBAC1BK,IAAIE,KAAK,GAAGN;gBACd;YACF;QACF;IACF;IAEA,KAAK,MAAM,CAACO,UAAUN,OAAO,IAAIL,OAAOY,OAAO,CAACf,iBAG3C;QACH,MAAMgB,aAAad,YAAYe,IAAI,CAACC,CAAAA;YAClC,MAAMC,SAASD,eAAeC,MAAM;YACpC,OAAOA,QAAQC,uBAAuBN;QACxC;QACA,IAAI,CAACE,YAAY;YACf,qEAAqE;YAErEK,QAAQC,KAAK,CAAC,CAAC,oCAAoC,EAAER,UAAU;YAC/D;QACF;QAEA,4EAA4E;QAC5E,MAAMR,UAAUE,OAAOe,SAAS;QAChC,MAAMhB,UAAUS,WAAWQ,IAAI;QAE/B,IAAIlB,YAAYC,SAAS;YACvB,mEAAmE;YACnEF,iBAAiBC,SAASC;YAE1B,8CAA8C;YAC9CC,OAAOe,SAAS,GAAGhB;QACrB;QAEA,6EAA6E;QAC7E,MAAMkB,mBAAmCC,MAAMC,OAAO,CAACX,WAAWN,MAAM,IACnEM,WAAWN,MAAM,GAClB,EAAE;QAEN,KAAK,MAAM,CAACkB,UAAUC,YAAY,IAAI1B,OAAOY,OAAO,CAACP,OAAOE,MAAM,EAAG;YACnE,MAAMoB,gBAAgBL,iBAAiBR,IAAI,CACzCc,CAAAA,QAASA,MAAMZ,MAAM,EAAEa,uBAAuBJ;YAGhD,IAAI,CAACE,eAAe;gBAClB,qEAAqE;gBAErET,QAAQC,KAAK,CAAC,CAAC,yBAAyB,EAAEM,SAAS,iBAAiB,EAAEZ,WAAWQ,IAAI,CAAC,CAAC,CAAC;gBACxF;YACF;YAEA,MAAMS,UAAUH,cAAcI,IAAI;YAClC,IAAID,WAAWJ,YAAYM,SAAS,KAAKF,SAAS;gBAChDJ,YAAYM,SAAS,GAAGF;YAC1B;QACF;IACF;IAEA,OAAOjC;AACT"}
@@ -0,0 +1,11 @@
1
+ import type { BetterAuthOptions } from 'better-auth/types';
2
+ import { type Config, type SanitizedConfig } from 'payload';
3
+ import type { BetterAuthPluginOptions } from './types';
4
+ export * from './helpers/index';
5
+ export { getPayloadAuth } from './lib/get-payload-auth';
6
+ export { sanitizeBetterAuthOptions } from './lib/sanitize-better-auth-options/index';
7
+ export * from './types';
8
+ export declare function betterAuthPlugin(pluginOptions: BetterAuthPluginOptions): (config: Config) => Config;
9
+ export declare function withPayloadAuth({ payloadConfig, }: {
10
+ payloadConfig: SanitizedConfig;
11
+ }): BetterAuthOptions;