payload-auth 1.0.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.
- package/LICENSE.md +17 -0
- package/dist/authjs/index.d.ts +1 -0
- package/dist/authjs/index.js +3 -0
- package/dist/authjs/index.js.map +1 -0
- package/dist/better-auth/adapter/dev/bin/run.d.ts +1 -0
- package/dist/better-auth/adapter/dev/bin/run.js +64 -0
- package/dist/better-auth/adapter/dev/bin/run.js.map +1 -0
- package/dist/better-auth/adapter/dev/bin/schema.d.ts +22 -0
- package/dist/better-auth/adapter/dev/bin/schema.js +160 -0
- package/dist/better-auth/adapter/dev/bin/schema.js.map +1 -0
- package/dist/better-auth/adapter/dev/collections.d.ts +3 -0
- package/dist/better-auth/adapter/dev/collections.js +212 -0
- package/dist/better-auth/adapter/dev/collections.js.map +1 -0
- package/dist/better-auth/adapter/dev/index.d.ts +3 -0
- package/dist/better-auth/adapter/dev/index.js +168 -0
- package/dist/better-auth/adapter/dev/index.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +23 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +326 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +23 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/index.d.ts +4 -0
- package/dist/better-auth/adapter/generate-schema/index.js +19 -0
- package/dist/better-auth/adapter/generate-schema/index.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/utils.d.ts +2 -0
- package/dist/better-auth/adapter/generate-schema/utils.js +20 -0
- package/dist/better-auth/adapter/generate-schema/utils.js.map +1 -0
- package/dist/better-auth/adapter/index.d.ts +5 -0
- package/dist/better-auth/adapter/index.js +578 -0
- package/dist/better-auth/adapter/index.js.map +1 -0
- package/dist/better-auth/adapter/test/adapter.test.d.ts +1 -0
- package/dist/better-auth/adapter/test/adapter.test.js +181 -0
- package/dist/better-auth/adapter/test/adapter.test.js.map +1 -0
- package/dist/better-auth/adapter/test/better-auth-adapter-test.d.ts +7 -0
- package/dist/better-auth/adapter/test/better-auth-adapter-test.js +425 -0
- package/dist/better-auth/adapter/test/better-auth-adapter-test.js.map +1 -0
- package/dist/better-auth/adapter/test/schema.test.d.ts +1 -0
- package/dist/better-auth/adapter/test/schema.test.js +796 -0
- package/dist/better-auth/adapter/test/schema.test.js.map +1 -0
- package/dist/better-auth/adapter/test/test_payload1/schema.d.ts +23 -0
- package/dist/better-auth/adapter/test/test_payload1/schema.js +177 -0
- package/dist/better-auth/adapter/test/test_payload1/schema.js.map +1 -0
- package/dist/better-auth/adapter/test/test_payload2/schema.d.ts +23 -0
- package/dist/better-auth/adapter/test/test_payload2/schema.js +167 -0
- package/dist/better-auth/adapter/test/test_payload2/schema.js.map +1 -0
- package/dist/better-auth/adapter/test/test_payload3/schema.d.ts +23 -0
- package/dist/better-auth/adapter/test/test_payload3/schema.js +198 -0
- package/dist/better-auth/adapter/test/test_payload3/schema.js.map +1 -0
- package/dist/better-auth/adapter/transform/index.d.ts +16 -0
- package/dist/better-auth/adapter/transform/index.js +252 -0
- package/dist/better-auth/adapter/transform/index.js.map +1 -0
- package/dist/better-auth/adapter/types.d.ts +6 -0
- package/dist/better-auth/adapter/types.js +3 -0
- package/dist/better-auth/adapter/types.js.map +1 -0
- package/dist/better-auth/index.d.ts +6 -0
- package/dist/better-auth/index.js +8 -0
- package/dist/better-auth/index.js.map +1 -0
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.d.ts +7 -0
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js +47 -0
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.d.ts +6 -0
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js +106 -0
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-login.d.ts +11 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-login.js +71 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-login.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.d.ts +6 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.js +49 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/before-login.d.ts +5 -0
- package/dist/better-auth/plugin/collections/users/hooks/before-login.js +18 -0
- package/dist/better-auth/plugin/collections/users/hooks/before-login.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.d.ts +5 -0
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js +33 -0
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.d.ts +2 -0
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js +14 -0
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.d.ts +7 -0
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.js +82 -0
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.js.map +1 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +29 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +46 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-ip.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/get-ip.js +31 -0
- package/dist/better-auth/plugin/helpers/get-ip.js.map +1 -0
- package/dist/better-auth/plugin/helpers/index.d.ts +1 -0
- package/dist/better-auth/plugin/helpers/index.js +3 -0
- package/dist/better-auth/plugin/helpers/index.js.map +1 -0
- package/dist/better-auth/plugin/helpers/serialize-cookie.d.ts +104 -0
- package/dist/better-auth/plugin/helpers/serialize-cookie.js +186 -0
- package/dist/better-auth/plugin/helpers/serialize-cookie.js.map +1 -0
- package/dist/better-auth/plugin/index.d.ts +7 -0
- package/dist/better-auth/plugin/index.js +64 -0
- package/dist/better-auth/plugin/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/auth-strategy.d.ts +8 -0
- package/dist/better-auth/plugin/lib/auth-strategy.js +48 -0
- package/dist/better-auth/plugin/lib/auth-strategy.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collection-configs.d.ts +11 -0
- package/dist/better-auth/plugin/lib/build-collection-configs.js +1558 -0
- package/dist/better-auth/plugin/lib/build-collection-configs.js.map +1 -0
- package/dist/better-auth/plugin/lib/config.d.ts +41 -0
- package/dist/better-auth/plugin/lib/config.js +43 -0
- package/dist/better-auth/plugin/lib/config.js.map +1 -0
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.d.ts +7 -0
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js +24 -0
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js.map +1 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +5 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js +9 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.d.ts +9 -0
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.js +52 -0
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.js.map +1 -0
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +6 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js +13 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/password.d.ts +25 -0
- package/dist/better-auth/plugin/lib/password.js +63 -0
- package/dist/better-auth/plugin/lib/password.js.map +1 -0
- package/dist/better-auth/plugin/lib/payload-access.d.ts +14 -0
- package/dist/better-auth/plugin/lib/payload-access.js +64 -0
- package/dist/better-auth/plugin/lib/payload-access.js.map +1 -0
- package/dist/better-auth/plugin/lib/prepare-session-data.d.ts +21 -0
- package/dist/better-auth/plugin/lib/prepare-session-data.js +42 -0
- package/dist/better-auth/plugin/lib/prepare-session-data.js.map +1 -0
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.d.ts +15 -0
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js +30 -0
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-auth-options.d.ts +5 -0
- package/dist/better-auth/plugin/lib/sanitize-auth-options.js +298 -0
- package/dist/better-auth/plugin/lib/sanitize-auth-options.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons.d.ts +5 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons.js +222 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/login-redirect.d.ts +1 -0
- package/dist/better-auth/plugin/payload/components/login-redirect.js +6 -0
- package/dist/better-auth/plugin/payload/components/login-redirect.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/logo.d.ts +1 -0
- package/dist/better-auth/plugin/payload/components/logo.js +36 -0
- package/dist/better-auth/plugin/payload/components/logo.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/logout.d.ts +1 -0
- package/dist/better-auth/plugin/payload/components/logout.js +61 -0
- package/dist/better-auth/plugin/payload/components/logout.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/sign-in.d.ts +3 -0
- package/dist/better-auth/plugin/payload/components/sign-in.js +384 -0
- package/dist/better-auth/plugin/payload/components/sign-in.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/sign-up.d.ts +6 -0
- package/dist/better-auth/plugin/payload/components/sign-up.js +502 -0
- package/dist/better-auth/plugin/payload/components/sign-up.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/styles.css +73 -0
- package/dist/better-auth/plugin/payload/components/ui/button.d.ts +10 -0
- package/dist/better-auth/plugin/payload/components/ui/button.js +42 -0
- package/dist/better-auth/plugin/payload/components/ui/button.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/card.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/ui/card.js +55 -0
- package/dist/better-auth/plugin/payload/components/ui/card.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/checkbox.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/ui/checkbox.js +23 -0
- package/dist/better-auth/plugin/payload/components/ui/checkbox.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/cn.d.ts +2 -0
- package/dist/better-auth/plugin/payload/components/ui/cn.js +7 -0
- package/dist/better-auth/plugin/payload/components/ui/cn.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/input.d.ts +3 -0
- package/dist/better-auth/plugin/payload/components/ui/input.js +14 -0
- package/dist/better-auth/plugin/payload/components/ui/input.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/label.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/ui/label.js +15 -0
- package/dist/better-auth/plugin/payload/components/ui/label.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/password-input.d.ts +2 -0
- package/dist/better-auth/plugin/payload/components/ui/password-input.js +55 -0
- package/dist/better-auth/plugin/payload/components/ui/password-input.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/client.d.ts +3 -0
- package/dist/better-auth/plugin/payload/exports/client.js +5 -0
- package/dist/better-auth/plugin/payload/exports/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +5 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js +7 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.d.ts +4 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.js +112 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/login/index.d.ts +4 -0
- package/dist/better-auth/plugin/payload/views/login/index.js +78 -0
- package/dist/better-auth/plugin/payload/views/login/index.js.map +1 -0
- package/dist/better-auth/plugin/types.d.ts +224 -0
- package/dist/better-auth/plugin/types.js +3 -0
- package/dist/better-auth/plugin/types.js.map +1 -0
- package/dist/better-auth/types.d.ts +2 -0
- package/dist/better-auth/types.js +4 -0
- package/dist/better-auth/types.js.map +1 -0
- package/dist/clerk/index.d.ts +1 -0
- package/dist/clerk/index.js +3 -0
- package/dist/clerk/index.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/kinde/index.d.ts +1 -0
- package/dist/kinde/index.js +3 -0
- package/dist/kinde/index.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import type { UnionToIntersection, betterAuth } from 'better-auth';
|
|
2
|
+
import type { BetterAuthOptions, BetterAuthPlugin, InferAPI, InferPluginTypes } from 'better-auth/types';
|
|
3
|
+
import type { BasePayload, CollectionConfig, Config, Endpoint, PayloadRequest } from 'payload';
|
|
4
|
+
/**
|
|
5
|
+
* BetterAuth options with the following caveats:
|
|
6
|
+
* - The `database` option is removed as it is configured internally
|
|
7
|
+
* - The `user` `modelName` and `fields` is removed as it is configured internally
|
|
8
|
+
* - The `account` `modelName` and `fields` is removed as it is configured internally
|
|
9
|
+
* - The `session` `modelName` and `fields` is removed as it is configured internally
|
|
10
|
+
* - The `verification` `modelName` and `fields` is removed as it is configured internally
|
|
11
|
+
*
|
|
12
|
+
* @see https://www.better-auth.com/docs/reference/options
|
|
13
|
+
*/
|
|
14
|
+
export interface PayloadBetterAuthOptions extends Omit<BetterAuthOptions, 'database' | 'user' | 'account' | 'verification' | 'session' | 'advanced'> {
|
|
15
|
+
user?: Omit<NonNullable<BetterAuthOptions['user']>, 'modelName' | 'fields'> | undefined;
|
|
16
|
+
account?: Omit<NonNullable<BetterAuthOptions['account']>, 'modelName' | 'fields'> | undefined;
|
|
17
|
+
session?: Omit<NonNullable<BetterAuthOptions['session']>, 'modelName' | 'fields'> | undefined;
|
|
18
|
+
verification?: Omit<NonNullable<BetterAuthOptions['verification']>, 'modelName' | 'fields'> | undefined;
|
|
19
|
+
advanced?: Omit<NonNullable<BetterAuthOptions['advanced']>, 'generateId'> | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface SanitizedBetterAuthOptions extends Omit<BetterAuthOptions, 'database'> {
|
|
22
|
+
}
|
|
23
|
+
export interface PayloadBetterAuthPluginOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Disable the plugin
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Enable debug logs
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
enableDebugLogs?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Log the tables that are needed for better-auth on init
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
logTables?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Hide the plugin collections from the payload admin UI
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
hidePluginCollections?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Configure the Users collections:
|
|
46
|
+
*/
|
|
47
|
+
users?: {
|
|
48
|
+
/**
|
|
49
|
+
* Will set the `modelName` for the `user` table in better-auth
|
|
50
|
+
*
|
|
51
|
+
* and the `slug` for the `users` collection in payload
|
|
52
|
+
*
|
|
53
|
+
* @default 'users'
|
|
54
|
+
*/
|
|
55
|
+
slug?: string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Define better-auth admin plugin access control
|
|
58
|
+
*
|
|
59
|
+
* This will also set the role which gives the user access to the payload admin UI
|
|
60
|
+
* @see https://www.better-auth.com/docs/plugins/admin#access-control
|
|
61
|
+
*
|
|
62
|
+
* @default ["admin"]
|
|
63
|
+
*/
|
|
64
|
+
adminRoles?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Define roles for the users collection
|
|
67
|
+
*
|
|
68
|
+
* This should match the roles in the better-auth admin plugin if you are using it
|
|
69
|
+
* @see https://www.better-auth.com/docs/plugins/admin#access-control
|
|
70
|
+
*/
|
|
71
|
+
roles?: string[];
|
|
72
|
+
/**
|
|
73
|
+
* Hide the `users` collection from the payload admin UI
|
|
74
|
+
*/
|
|
75
|
+
hidden?: boolean | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Define which fields users can update themselves
|
|
78
|
+
*
|
|
79
|
+
* Password field is automatically included and doesn't need to be specified here
|
|
80
|
+
*
|
|
81
|
+
* @example ['name', 'dateOfBirth', 'phoneNumber']
|
|
82
|
+
* @default ['name']
|
|
83
|
+
*/
|
|
84
|
+
allowedFields?: string[] | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Function to override the collection configuration
|
|
87
|
+
*
|
|
88
|
+
* This allows modifying the collection config after it has been built
|
|
89
|
+
* Example use cases include adding saveToJwt to specific fields or
|
|
90
|
+
* modifying field descriptions
|
|
91
|
+
*
|
|
92
|
+
* @param options Object containing the collection config and potentially additional parameters
|
|
93
|
+
* @returns Modified collection config
|
|
94
|
+
*/
|
|
95
|
+
collectionOverrides?: (options: {
|
|
96
|
+
collection: CollectionConfig;
|
|
97
|
+
}) => CollectionConfig;
|
|
98
|
+
/**
|
|
99
|
+
* This will block the first on sign up verification email from better-auth.
|
|
100
|
+
* If you are using Payload's userCollection.verify option, you will want to set this to true.
|
|
101
|
+
* Function that will be blocked: options.emailVerificationsendVerificationEmail
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
blockFirstBetterAuthVerificationEmail?: boolean;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Configure the Accounts collections:
|
|
108
|
+
*/
|
|
109
|
+
accounts?: {
|
|
110
|
+
/**
|
|
111
|
+
* Will set the `modelName` for the `account` table in better-auth
|
|
112
|
+
*
|
|
113
|
+
* and the `slug` for the `accounts` collection in payload
|
|
114
|
+
*
|
|
115
|
+
* @default 'accounts'
|
|
116
|
+
*/
|
|
117
|
+
slug?: string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Hide the `accounts` collection from the payload admin UI
|
|
120
|
+
*/
|
|
121
|
+
hidden?: boolean | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Function to override the collection configuration
|
|
124
|
+
*
|
|
125
|
+
* This allows modifying the collection config after it has been built
|
|
126
|
+
*
|
|
127
|
+
* @param options Object containing the collection config and potentially additional parameters
|
|
128
|
+
* @returns Modified collection config
|
|
129
|
+
*/
|
|
130
|
+
collectionOverrides?: (options: {
|
|
131
|
+
collection: CollectionConfig;
|
|
132
|
+
}) => CollectionConfig;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Configure the Sessions collections:
|
|
136
|
+
*/
|
|
137
|
+
sessions?: {
|
|
138
|
+
/**
|
|
139
|
+
* Will set the `modelName` for the `session` table in better-auth
|
|
140
|
+
*
|
|
141
|
+
* and the `slug` for the `sessions` collection in payload
|
|
142
|
+
*
|
|
143
|
+
* @default 'sessions'
|
|
144
|
+
*/
|
|
145
|
+
slug?: string | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Hide the `sessions` collection from the payload admin UI
|
|
148
|
+
*/
|
|
149
|
+
hidden?: boolean | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Function to override the collection configuration
|
|
152
|
+
*
|
|
153
|
+
* This allows modifying the collection config after it has been built
|
|
154
|
+
*
|
|
155
|
+
* @param options Object containing the collection config and potentially additional parameters
|
|
156
|
+
* @returns Modified collection config
|
|
157
|
+
*/
|
|
158
|
+
collectionOverrides?: (options: {
|
|
159
|
+
collection: CollectionConfig;
|
|
160
|
+
}) => CollectionConfig;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Configure the Verifications collections:
|
|
164
|
+
*/
|
|
165
|
+
verifications?: {
|
|
166
|
+
/**
|
|
167
|
+
* Will set the `modelName` for the `verification` table in better-auth
|
|
168
|
+
*
|
|
169
|
+
* and the `slug` for the `verifications` collection in payload
|
|
170
|
+
*
|
|
171
|
+
* @default 'verifications'
|
|
172
|
+
*/
|
|
173
|
+
slug?: string | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* Hide the `verifications` collection from the payload admin UI
|
|
176
|
+
*/
|
|
177
|
+
hidden?: boolean | undefined;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* BetterAuth options with the following caveats:
|
|
181
|
+
* - The `database` option is removed as it is configured internally
|
|
182
|
+
* - The `user` `modelName` and `fields` is removed as it is configured internally
|
|
183
|
+
* - The `account` `modelName` and `fields` is removed as it is configured internally
|
|
184
|
+
* - The `session` `modelName` and `fields` is removed as it is configured internally
|
|
185
|
+
* - The `verification` `modelName` and `fields` is removed as it is configured internally
|
|
186
|
+
*
|
|
187
|
+
* @see https://www.better-auth.com/docs/reference/options
|
|
188
|
+
*/
|
|
189
|
+
betterAuthOptions?: PayloadBetterAuthOptions;
|
|
190
|
+
}
|
|
191
|
+
export interface PayloadBetterAuthPlugin {
|
|
192
|
+
(config: Config): Config;
|
|
193
|
+
pluginOptions: PayloadBetterAuthPluginOptions;
|
|
194
|
+
}
|
|
195
|
+
export interface PayloadRequestWithBetterAuth<TPlugins extends BetterAuthPlugin[] = []> extends PayloadRequest {
|
|
196
|
+
payload: BasePayload & {
|
|
197
|
+
betterAuth: BetterAuthReturn<TPlugins>;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
export type CollectionHookWithBetterAuth<T extends (args: any) => any> = T extends (args: infer A) => infer R ? (args: Omit<A, 'req'> & {
|
|
201
|
+
req: PayloadRequestWithBetterAuth;
|
|
202
|
+
}) => R : never;
|
|
203
|
+
export type EndpointWithBetterAuth = Omit<Endpoint, 'handler'> & {
|
|
204
|
+
handler: (req: PayloadRequestWithBetterAuth) => Promise<Response> | Response;
|
|
205
|
+
};
|
|
206
|
+
export type ExtractEndpoints<T> = T extends BetterAuthPlugin ? T extends {
|
|
207
|
+
endpoints?: infer E;
|
|
208
|
+
} ? E : {} : {};
|
|
209
|
+
export type TPlugins<TPlugins extends BetterAuthPlugin[] = BetterAuthPlugin[]> = TPlugins;
|
|
210
|
+
export type PluginInferTypes<T extends TPlugins> = {
|
|
211
|
+
[K in keyof InferPluginTypes<{
|
|
212
|
+
plugins: T;
|
|
213
|
+
}>]: InferPluginTypes<{
|
|
214
|
+
plugins: T;
|
|
215
|
+
}>[K];
|
|
216
|
+
};
|
|
217
|
+
export type BetterAuthReturn<T extends TPlugins> = Omit<ReturnType<typeof betterAuth>, '$Infer'> & {
|
|
218
|
+
api: T extends (infer P)[] ? InferAPI<UnionToIntersection<ExtractEndpoints<P>>> : {};
|
|
219
|
+
$Infer: ReturnType<typeof betterAuth>['$Infer'] & PluginInferTypes<T>;
|
|
220
|
+
};
|
|
221
|
+
export type BetterAuthFunctionOptions<P extends TPlugins> = Omit<BetterAuthOptions, 'database' | 'plugins'> & {
|
|
222
|
+
enableDebugLogs?: boolean;
|
|
223
|
+
plugins: P;
|
|
224
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/types.ts"],"sourcesContent":["import type { UnionToIntersection, betterAuth } from 'better-auth'\nimport type {\n BetterAuthOptions,\n BetterAuthPlugin,\n InferAPI,\n InferPluginTypes,\n} from 'better-auth/types'\nimport type { BasePayload, CollectionConfig, Config, Endpoint, PayloadRequest } from 'payload'\n\n/**\n * BetterAuth options with the following caveats:\n * - The `database` option is removed as it is configured internally\n * - The `user` `modelName` and `fields` is removed as it is configured internally\n * - The `account` `modelName` and `fields` is removed as it is configured internally\n * - The `session` `modelName` and `fields` is removed as it is configured internally\n * - The `verification` `modelName` and `fields` is removed as it is configured internally\n *\n * @see https://www.better-auth.com/docs/reference/options\n */\nexport interface PayloadBetterAuthOptions\n extends Omit<\n BetterAuthOptions,\n 'database' | 'user' | 'account' | 'verification' | 'session' | 'advanced'\n > {\n user?: Omit<NonNullable<BetterAuthOptions['user']>, 'modelName' | 'fields'> | undefined\n account?: Omit<NonNullable<BetterAuthOptions['account']>, 'modelName' | 'fields'> | undefined\n session?: Omit<NonNullable<BetterAuthOptions['session']>, 'modelName' | 'fields'> | undefined\n verification?:\n | Omit<NonNullable<BetterAuthOptions['verification']>, 'modelName' | 'fields'>\n | undefined\n advanced?: Omit<NonNullable<BetterAuthOptions['advanced']>, 'generateId'> | undefined\n}\n\nexport interface SanitizedBetterAuthOptions extends Omit<BetterAuthOptions, 'database'> {}\n\nexport interface PayloadBetterAuthPluginOptions {\n /**\n * Disable the plugin\n * @default false\n */\n disabled?: boolean\n /**\n * Enable debug logs\n * @default false\n */\n enableDebugLogs?: boolean\n /**\n * Log the tables that are needed for better-auth on init\n * @default false\n */\n logTables?: boolean\n /**\n * Hide the plugin collections from the payload admin UI\n * @default false\n */\n hidePluginCollections?: boolean\n /**\n * Configure the Users collections:\n */\n users?: {\n /**\n * Will set the `modelName` for the `user` table in better-auth\n *\n * and the `slug` for the `users` collection in payload\n *\n * @default 'users'\n */\n slug?: string | undefined\n /**\n * Define better-auth admin plugin access control\n *\n * This will also set the role which gives the user access to the payload admin UI\n * @see https://www.better-auth.com/docs/plugins/admin#access-control\n *\n * @default [\"admin\"]\n */\n adminRoles?: string[]\n /**\n * Define roles for the users collection\n *\n * This should match the roles in the better-auth admin plugin if you are using it\n * @see https://www.better-auth.com/docs/plugins/admin#access-control\n */\n roles?: string[]\n /**\n * Hide the `users` collection from the payload admin UI\n */\n hidden?: boolean | undefined\n /**\n * Define which fields users can update themselves\n *\n * Password field is automatically included and doesn't need to be specified here\n *\n * @example ['name', 'dateOfBirth', 'phoneNumber']\n * @default ['name']\n */\n allowedFields?: string[] | undefined\n /**\n * Function to override the collection configuration\n *\n * This allows modifying the collection config after it has been built\n * Example use cases include adding saveToJwt to specific fields or\n * modifying field descriptions\n *\n * @param options Object containing the collection config and potentially additional parameters\n * @returns Modified collection config\n */\n collectionOverrides?: (options: { collection: CollectionConfig }) => CollectionConfig\n /**\n * This will block the first on sign up verification email from better-auth.\n * If you are using Payload's userCollection.verify option, you will want to set this to true.\n * Function that will be blocked: options.emailVerificationsendVerificationEmail\n * @default false\n */\n blockFirstBetterAuthVerificationEmail?: boolean\n }\n /**\n * Configure the Accounts collections:\n */\n accounts?: {\n /**\n * Will set the `modelName` for the `account` table in better-auth\n *\n * and the `slug` for the `accounts` collection in payload\n *\n * @default 'accounts'\n */\n slug?: string | undefined\n /**\n * Hide the `accounts` collection from the payload admin UI\n */\n hidden?: boolean | undefined\n /**\n * Function to override the collection configuration\n *\n * This allows modifying the collection config after it has been built\n *\n * @param options Object containing the collection config and potentially additional parameters\n * @returns Modified collection config\n */\n collectionOverrides?: (options: { collection: CollectionConfig }) => CollectionConfig\n }\n /**\n * Configure the Sessions collections:\n */\n sessions?: {\n /**\n * Will set the `modelName` for the `session` table in better-auth\n *\n * and the `slug` for the `sessions` collection in payload\n *\n * @default 'sessions'\n */\n slug?: string | undefined\n /**\n * Hide the `sessions` collection from the payload admin UI\n */\n hidden?: boolean | undefined\n /**\n * Function to override the collection configuration\n *\n * This allows modifying the collection config after it has been built\n *\n * @param options Object containing the collection config and potentially additional parameters\n * @returns Modified collection config\n */\n collectionOverrides?: (options: { collection: CollectionConfig }) => CollectionConfig\n }\n /**\n * Configure the Verifications collections:\n */\n verifications?: {\n /**\n * Will set the `modelName` for the `verification` table in better-auth\n *\n * and the `slug` for the `verifications` collection in payload\n *\n * @default 'verifications'\n */\n slug?: string | undefined\n /**\n * Hide the `verifications` collection from the payload admin UI\n */\n hidden?: boolean | undefined\n }\n /**\n * BetterAuth options with the following caveats:\n * - The `database` option is removed as it is configured internally\n * - The `user` `modelName` and `fields` is removed as it is configured internally\n * - The `account` `modelName` and `fields` is removed as it is configured internally\n * - The `session` `modelName` and `fields` is removed as it is configured internally\n * - The `verification` `modelName` and `fields` is removed as it is configured internally\n *\n * @see https://www.better-auth.com/docs/reference/options\n */\n betterAuthOptions?: PayloadBetterAuthOptions\n}\n\nexport interface PayloadBetterAuthPlugin {\n (config: Config): Config\n pluginOptions: PayloadBetterAuthPluginOptions\n}\n\nexport interface PayloadRequestWithBetterAuth<TPlugins extends BetterAuthPlugin[] = []>\n extends PayloadRequest {\n payload: BasePayload & {\n betterAuth: BetterAuthReturn<TPlugins>\n }\n}\n\nexport type CollectionHookWithBetterAuth<T extends (args: any) => any> = T extends (\n args: infer A,\n) => infer R\n ? (args: Omit<A, 'req'> & { req: PayloadRequestWithBetterAuth }) => R\n : never\n\nexport type EndpointWithBetterAuth = Omit<Endpoint, 'handler'> & {\n handler: (req: PayloadRequestWithBetterAuth) => Promise<Response> | Response\n}\n\nexport type ExtractEndpoints<T> = T extends BetterAuthPlugin\n ? T extends { endpoints?: infer E }\n ? E\n : {}\n : {}\n\nexport type TPlugins<TPlugins extends BetterAuthPlugin[] = BetterAuthPlugin[]> = TPlugins\nexport type PluginInferTypes<T extends TPlugins> = {\n [K in keyof InferPluginTypes<{ plugins: T }>]: InferPluginTypes<{ plugins: T }>[K]\n}\n\nexport type BetterAuthReturn<T extends TPlugins> = Omit<ReturnType<typeof betterAuth>, '$Infer'> & {\n api: T extends (infer P)[] ? InferAPI<UnionToIntersection<ExtractEndpoints<P>>> : {}\n $Infer: ReturnType<typeof betterAuth>['$Infer'] & PluginInferTypes<T>\n}\n\nexport type BetterAuthFunctionOptions<P extends TPlugins> = Omit<\n BetterAuthOptions,\n 'database' | 'plugins'\n> & {\n enableDebugLogs?: boolean\n plugins: P\n}\n"],"names":[],"mappings":"AA4OA,WAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["export * from './adapter/types'\nexport * from './plugin/types'\n"],"names":[],"mappings":"AAAA,cAAc,kBAAiB;AAC/B,cAAc,iBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clerk = "clerk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const clerk = \"clerk\";\n"],"names":["clerk"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,QAAQ"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// These re-exports will be used by consumers of the library\nexport * from \"payload-auth/better-auth\";\nexport * from \"payload-auth/clerk\";\nexport * from \"payload-auth/kinde\";\nexport * from \"payload-auth/authjs\";\n"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,cAAc,2BAA2B;AACzC,cAAc,qBAAqB;AACnC,cAAc,qBAAqB;AACnC,cAAc,sBAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kinde = "kinde";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const kinde = \"kinde\";\n"],"names":["kinde"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,QAAQ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "payload-auth",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.mjs",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./better-auth": {
|
|
10
|
+
"import": "./dist/better-auth/index.js",
|
|
11
|
+
"types": "./dist/better-auth/index.d.ts",
|
|
12
|
+
"default": "./dist/better-auth/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./better-auth/adapter": {
|
|
15
|
+
"import": "./dist/better-auth/adapter/index.js",
|
|
16
|
+
"types": "./dist/better-auth/adapter/index.d.ts",
|
|
17
|
+
"default": "./dist/better-auth/adapter/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./better-auth/plugin": {
|
|
20
|
+
"import": "./dist/better-auth/plugin/index.js",
|
|
21
|
+
"types": "./dist/better-auth/plugin/index.d.ts",
|
|
22
|
+
"default": "./dist/better-auth/plugin/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./better-auth/plugin/client": {
|
|
25
|
+
"import": "./dist/better-auth/plugin/payload/exports/client.js",
|
|
26
|
+
"types": "./dist/better-auth/plugin/payload/exports/client.d.ts",
|
|
27
|
+
"default": "./dist/better-auth/plugin/payload/exports/client.js"
|
|
28
|
+
},
|
|
29
|
+
"./better-auth/plugin/rsc": {
|
|
30
|
+
"import": "./dist/better-auth/plugin/payload/exports/rsc.js",
|
|
31
|
+
"types": "./dist/better-auth/plugin/payload/exports/rsc.d.ts",
|
|
32
|
+
"default": "./dist/better-auth/plugin/payload/exports/rsc.js"
|
|
33
|
+
},
|
|
34
|
+
"./clerk": {
|
|
35
|
+
"import": "./dist/clerk/index.js",
|
|
36
|
+
"types": "./dist/clerk/index.d.ts",
|
|
37
|
+
"default": "./dist/clerk/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./kinde": {
|
|
40
|
+
"import": "./dist/kinde/index.js",
|
|
41
|
+
"types": "./dist/kinde/index.d.ts",
|
|
42
|
+
"default": "./dist/kinde/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./authjs": {
|
|
45
|
+
"import": "./dist/authjs/index.js",
|
|
46
|
+
"types": "./dist/authjs/index.d.ts",
|
|
47
|
+
"default": "./dist/authjs/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"sideEffects": false,
|
|
51
|
+
"files": [
|
|
52
|
+
"dist"
|
|
53
|
+
],
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@swc/cli": "0.6.0",
|
|
56
|
+
"@swc/core": "1.11.13",
|
|
57
|
+
"typescript": "5.8.2"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"next": "15.2.3",
|
|
61
|
+
"react": "19.0.0",
|
|
62
|
+
"react-dom": "19.0.0",
|
|
63
|
+
"@payloadcms/ui": "3.31",
|
|
64
|
+
"@radix-ui/react-checkbox": "1.1.4",
|
|
65
|
+
"@radix-ui/react-icons": "1.3.2",
|
|
66
|
+
"@radix-ui/react-label": "2.1.2",
|
|
67
|
+
"@radix-ui/react-slot": "1.1.2",
|
|
68
|
+
"@better-auth/utils": "0.2.4",
|
|
69
|
+
"better-auth": "1.2.5",
|
|
70
|
+
"class-variance-authority": "0.7.1",
|
|
71
|
+
"clsx": "2.1.1",
|
|
72
|
+
"jose": "^6.0.10",
|
|
73
|
+
"lucide-react": "0.482.0",
|
|
74
|
+
"payload": "3.31",
|
|
75
|
+
"sonner": "2.0.1",
|
|
76
|
+
"tailwind-merge": "3.0.2",
|
|
77
|
+
"uncrypto": "^0.1.3"
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo",
|
|
81
|
+
"build": "pnpm clean && pnpm copy:dist && pnpm build:swc",
|
|
82
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
83
|
+
"build:types": "tsc --project tsconfig.json",
|
|
84
|
+
"copy:dist": "pnpm copy:provider better-auth && pnpm copy:provider clerk && pnpm copy:provider kinde && pnpm copy:provider authjs",
|
|
85
|
+
"copy:provider": "./copy-provider.sh"
|
|
86
|
+
}
|
|
87
|
+
}
|