@delmaredigital/payload-better-auth 0.1.4 → 0.2.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 (62) hide show
  1. package/LICENSE +21 -73
  2. package/README.md +165 -290
  3. package/dist/adapter/collections.d.ts +52 -0
  4. package/dist/adapter/collections.d.ts.map +1 -0
  5. package/dist/adapter/collections.js +150 -0
  6. package/dist/adapter/collections.js.map +1 -0
  7. package/dist/adapter/index.d.ts +6 -9
  8. package/dist/adapter/index.d.ts.map +1 -0
  9. package/dist/adapter/index.js +399 -350
  10. package/dist/adapter/index.js.map +1 -1
  11. package/dist/components/BeforeLogin.d.ts +11 -0
  12. package/dist/components/BeforeLogin.d.ts.map +1 -0
  13. package/dist/components/BeforeLogin.js +25 -0
  14. package/dist/components/BeforeLogin.js.map +1 -0
  15. package/dist/components/LoginView.d.ts +21 -0
  16. package/dist/components/LoginView.d.ts.map +1 -0
  17. package/dist/components/LoginView.js +214 -0
  18. package/dist/components/LoginView.js.map +1 -0
  19. package/dist/components/LogoutButton.d.ts +7 -0
  20. package/dist/components/LogoutButton.d.ts.map +1 -0
  21. package/dist/components/LogoutButton.js +43 -0
  22. package/dist/components/LogoutButton.js.map +1 -0
  23. package/dist/exports/client.d.ts +6 -0
  24. package/dist/exports/client.d.ts.map +1 -0
  25. package/dist/exports/client.js +6 -0
  26. package/dist/exports/client.js.map +1 -0
  27. package/dist/exports/components.d.ts +12 -0
  28. package/dist/exports/components.d.ts.map +1 -0
  29. package/dist/exports/components.js +10 -0
  30. package/dist/exports/components.js.map +1 -0
  31. package/dist/index.d.ts +14 -115
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +18 -610
  34. package/dist/index.js.map +1 -1
  35. package/dist/plugin/index.d.ts +68 -16
  36. package/dist/plugin/index.d.ts.map +1 -0
  37. package/dist/plugin/index.js +268 -76
  38. package/dist/plugin/index.js.map +1 -1
  39. package/dist/utils/detectAuthConfig.d.ts +18 -0
  40. package/dist/utils/detectAuthConfig.d.ts.map +1 -0
  41. package/dist/utils/detectAuthConfig.js +31 -0
  42. package/dist/utils/detectAuthConfig.js.map +1 -0
  43. package/dist/utils/session.d.ts +63 -0
  44. package/dist/utils/session.d.ts.map +1 -0
  45. package/dist/utils/session.js +65 -0
  46. package/dist/utils/session.js.map +1 -0
  47. package/package.json +22 -23
  48. package/dist/adapter/index.d.mts +0 -70
  49. package/dist/adapter/index.mjs +0 -366
  50. package/dist/adapter/index.mjs.map +0 -1
  51. package/dist/client.d.mts +0 -1
  52. package/dist/client.d.ts +0 -1
  53. package/dist/client.js +0 -12
  54. package/dist/client.js.map +0 -1
  55. package/dist/client.mjs +0 -3
  56. package/dist/client.mjs.map +0 -1
  57. package/dist/index.d.mts +0 -120
  58. package/dist/index.mjs +0 -603
  59. package/dist/index.mjs.map +0 -1
  60. package/dist/plugin/index.d.mts +0 -78
  61. package/dist/plugin/index.mjs +0 -82
  62. package/dist/plugin/index.mjs.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,120 +1,19 @@
1
- export { PayloadAdapterConfig, payloadAdapter } from './adapter/index.js';
2
- import { CollectionConfig, Plugin, BasePayload } from 'payload';
3
- import { BetterAuthOptions } from 'better-auth';
4
- export { Auth, BetterAuthPluginOptions, BetterAuthStrategyOptions, CreateAuthFunction, PayloadWithAuth, betterAuthStrategy, createBetterAuthPlugin, resetAuthInstance } from './plugin/index.js';
5
-
6
1
  /**
7
- * Auto-generate Payload collections from Better Auth schema
2
+ * @delmare/payload-better-auth
8
3
  *
9
- * @packageDocumentation
10
- */
11
-
12
- type BetterAuthCollectionsOptions = {
13
- /**
14
- * Better Auth options. Pass the same options you use for betterAuth().
15
- * The plugin reads the schema to generate collections.
16
- */
17
- betterAuthOptions?: BetterAuthOptions;
18
- /**
19
- * Override collection slugs (e.g., { user: 'users', session: 'sessions' })
20
- */
21
- slugOverrides?: Record<string, string>;
22
- /**
23
- * Collections to skip (they already exist in your config)
24
- * Default: ['user'] - assumes you have a Users collection
25
- */
26
- skipCollections?: string[];
27
- /**
28
- * Admin group name for generated collections
29
- * Default: 'Auth'
30
- */
31
- adminGroup?: string;
32
- /**
33
- * Custom access control for generated collections.
34
- * By default, only admins can read/delete, and create/update are disabled.
35
- */
36
- access?: CollectionConfig['access'];
37
- };
38
- /**
39
- * Payload plugin that auto-generates collections from Better Auth schema.
40
- *
41
- * @example
42
- * ```ts
43
- * import { betterAuthCollections } from '@delmare/payload-better-auth'
44
- *
45
- * export default buildConfig({
46
- * plugins: [
47
- * betterAuthCollections({
48
- * betterAuthOptions: { ... },
49
- * skipCollections: ['user'], // Define Users yourself
50
- * }),
51
- * ],
52
- * })
53
- * ```
54
- */
55
- declare function betterAuthCollections(options?: BetterAuthCollectionsOptions): Plugin;
56
-
57
- /**
58
- * Server-side session utilities
4
+ * Better Auth adapter and plugins for Payload CMS.
5
+ * Enables seamless integration between Better Auth and Payload.
59
6
  *
60
7
  * @packageDocumentation
61
8
  */
62
-
63
- type Session = {
64
- user: {
65
- id: string;
66
- email: string;
67
- name?: string;
68
- image?: string;
69
- [key: string]: unknown;
70
- };
71
- session: {
72
- id: string;
73
- expiresAt: Date;
74
- [key: string]: unknown;
75
- };
76
- };
77
- /**
78
- * Get the current session from headers.
79
- *
80
- * @example
81
- * ```ts
82
- * import { headers } from 'next/headers'
83
- * import { getServerSession } from '@delmare/payload-better-auth'
84
- *
85
- * export default async function Page() {
86
- * const headersList = await headers()
87
- * const session = await getServerSession(payload, headersList)
88
- *
89
- * if (!session) {
90
- * redirect('/login')
91
- * }
92
- *
93
- * return <div>Hello {session.user.name}</div>
94
- * }
95
- * ```
96
- */
97
- declare function getServerSession(payload: BasePayload, headers: Headers): Promise<Session | null>;
98
- /**
99
- * Get the current user from the session.
100
- *
101
- * @example
102
- * ```ts
103
- * import { headers } from 'next/headers'
104
- * import { getServerUser } from '@delmare/payload-better-auth'
105
- *
106
- * export default async function Page() {
107
- * const headersList = await headers()
108
- * const user = await getServerUser(payload, headersList)
109
- *
110
- * if (!user) {
111
- * redirect('/login')
112
- * }
113
- *
114
- * return <div>Hello {user.name}</div>
115
- * }
116
- * ```
117
- */
118
- declare function getServerUser(payload: BasePayload, headers: Headers): Promise<Session['user'] | null>;
119
-
120
- export { type BetterAuthCollectionsOptions, type Session, betterAuthCollections, getServerSession, getServerUser };
9
+ export { payloadAdapter } from './adapter/index.js';
10
+ export type { PayloadAdapterConfig } from './adapter/index.js';
11
+ export { betterAuthCollections } from './adapter/collections.js';
12
+ export type { BetterAuthCollectionsOptions } from './adapter/collections.js';
13
+ export { createBetterAuthPlugin, betterAuthStrategy, resetAuthInstance, } from './plugin/index.js';
14
+ export type { Auth, PayloadWithAuth, CreateAuthFunction, BetterAuthPluginOptions, BetterAuthPluginAdminOptions, BetterAuthStrategyOptions, } from './plugin/index.js';
15
+ export { detectAuthConfig } from './utils/detectAuthConfig.js';
16
+ export type { AuthDetectionResult } from './utils/detectAuthConfig.js';
17
+ export { getServerSession, getServerUser } from './utils/session.js';
18
+ export type { Session } from './utils/session.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAG9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,YAAY,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAG5E,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,IAAI,EACJ,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACpE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA"}