@delmaredigital/payload-better-auth 0.1.5 → 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.
- package/README.md +165 -250
- package/dist/adapter/collections.d.ts +52 -0
- package/dist/adapter/collections.d.ts.map +1 -0
- package/dist/adapter/collections.js +150 -0
- package/dist/adapter/collections.js.map +1 -0
- package/dist/adapter/index.d.ts +6 -9
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +399 -350
- package/dist/adapter/index.js.map +1 -1
- package/dist/components/BeforeLogin.d.ts +11 -0
- package/dist/components/BeforeLogin.d.ts.map +1 -0
- package/dist/components/BeforeLogin.js +25 -0
- package/dist/components/BeforeLogin.js.map +1 -0
- package/dist/components/LoginView.d.ts +21 -0
- package/dist/components/LoginView.d.ts.map +1 -0
- package/dist/components/LoginView.js +214 -0
- package/dist/components/LoginView.js.map +1 -0
- package/dist/components/LogoutButton.d.ts +7 -0
- package/dist/components/LogoutButton.d.ts.map +1 -0
- package/dist/components/LogoutButton.js +43 -0
- package/dist/components/LogoutButton.js.map +1 -0
- package/dist/exports/client.d.ts +6 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +6 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/components.d.ts +12 -0
- package/dist/exports/components.d.ts.map +1 -0
- package/dist/exports/components.js +10 -0
- package/dist/exports/components.js.map +1 -0
- package/dist/index.d.ts +14 -115
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -610
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +68 -16
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +268 -76
- package/dist/plugin/index.js.map +1 -1
- package/dist/utils/detectAuthConfig.d.ts +18 -0
- package/dist/utils/detectAuthConfig.d.ts.map +1 -0
- package/dist/utils/detectAuthConfig.js +31 -0
- package/dist/utils/detectAuthConfig.js.map +1 -0
- package/dist/utils/session.d.ts +63 -0
- package/dist/utils/session.d.ts.map +1 -0
- package/dist/utils/session.js +65 -0
- package/dist/utils/session.js.map +1 -0
- package/package.json +22 -23
- package/dist/adapter/index.d.mts +0 -70
- package/dist/adapter/index.mjs +0 -366
- package/dist/adapter/index.mjs.map +0 -1
- package/dist/client.d.mts +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/client.js +0 -12
- package/dist/client.js.map +0 -1
- package/dist/client.mjs +0 -3
- package/dist/client.mjs.map +0 -1
- package/dist/index.d.mts +0 -120
- package/dist/index.mjs +0 -603
- package/dist/index.mjs.map +0 -1
- package/dist/plugin/index.d.mts +0 -78
- package/dist/plugin/index.mjs +0 -82
- package/dist/plugin/index.mjs.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility to detect auth configuration in Payload config
|
|
3
|
+
*/
|
|
4
|
+
import type { Config, CollectionConfig } from 'payload';
|
|
5
|
+
export type AuthDetectionResult = {
|
|
6
|
+
/** Whether any collection has disableLocalStrategy: true */
|
|
7
|
+
hasDisableLocalStrategy: boolean;
|
|
8
|
+
/** The slug of the auth collection (if found) */
|
|
9
|
+
authCollectionSlug: string | null;
|
|
10
|
+
/** The auth collection config (if found) */
|
|
11
|
+
authCollectionConfig: CollectionConfig | null;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Scans Payload config to detect if any collection uses disableLocalStrategy.
|
|
15
|
+
* Used to determine whether to auto-inject admin components.
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectAuthConfig(config: Config): AuthDetectionResult;
|
|
18
|
+
//# sourceMappingURL=detectAuthConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectAuthConfig.d.ts","sourceRoot":"","sources":["../../src/utils/detectAuthConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAEvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,4DAA4D;IAC5D,uBAAuB,EAAE,OAAO,CAAA;IAChC,iDAAiD;IACjD,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,4CAA4C;IAC5C,oBAAoB,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC9C,CAAA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CA2BpE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility to detect auth configuration in Payload config
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Scans Payload config to detect if any collection uses disableLocalStrategy.
|
|
6
|
+
* Used to determine whether to auto-inject admin components.
|
|
7
|
+
*/
|
|
8
|
+
export function detectAuthConfig(config) {
|
|
9
|
+
const collections = config.collections ?? [];
|
|
10
|
+
for (const collection of collections) {
|
|
11
|
+
if (collection.auth) {
|
|
12
|
+
const auth = collection.auth;
|
|
13
|
+
// disableLocalStrategy can be `true` or an object with options
|
|
14
|
+
if (auth === true ||
|
|
15
|
+
(typeof auth === 'object' && auth.disableLocalStrategy)) {
|
|
16
|
+
return {
|
|
17
|
+
hasDisableLocalStrategy: auth === true ||
|
|
18
|
+
(typeof auth === 'object' && !!auth.disableLocalStrategy),
|
|
19
|
+
authCollectionSlug: collection.slug,
|
|
20
|
+
authCollectionConfig: collection,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
hasDisableLocalStrategy: false,
|
|
27
|
+
authCollectionSlug: null,
|
|
28
|
+
authCollectionConfig: null,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=detectAuthConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectAuthConfig.js","sourceRoot":"","sources":["../../src/utils/detectAuthConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,CAAA;IAE5C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;YAC5B,+DAA+D;YAC/D,IACE,IAAI,KAAK,IAAI;gBACb,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,oBAAoB,CAAC,EACvD,CAAC;gBACD,OAAO;oBACL,uBAAuB,EACrB,IAAI,KAAK,IAAI;wBACb,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC;oBAC3D,kBAAkB,EAAE,UAAU,CAAC,IAAI;oBACnC,oBAAoB,EAAE,UAAU;iBACjC,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,uBAAuB,EAAE,KAAK;QAC9B,kBAAkB,EAAE,IAAI;QACxB,oBAAoB,EAAE,IAAI;KAC3B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side session utilities
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { BasePayload } from 'payload';
|
|
7
|
+
export type Session = {
|
|
8
|
+
user: {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
image?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
session: {
|
|
16
|
+
id: string;
|
|
17
|
+
expiresAt: Date;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Get the current session from headers.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { headers } from 'next/headers'
|
|
27
|
+
* import { getServerSession } from '@delmare/payload-better-auth'
|
|
28
|
+
*
|
|
29
|
+
* export default async function Page() {
|
|
30
|
+
* const headersList = await headers()
|
|
31
|
+
* const session = await getServerSession(payload, headersList)
|
|
32
|
+
*
|
|
33
|
+
* if (!session) {
|
|
34
|
+
* redirect('/login')
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* return <div>Hello {session.user.name}</div>
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function getServerSession(payload: BasePayload, headers: Headers): Promise<Session | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Get the current user from the session.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { headers } from 'next/headers'
|
|
48
|
+
* import { getServerUser } from '@delmare/payload-better-auth'
|
|
49
|
+
*
|
|
50
|
+
* export default async function Page() {
|
|
51
|
+
* const headersList = await headers()
|
|
52
|
+
* const user = await getServerUser(payload, headersList)
|
|
53
|
+
*
|
|
54
|
+
* if (!user) {
|
|
55
|
+
* redirect('/login')
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* return <div>Hello {user.name}</div>
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function getServerUser(payload: BasePayload, headers: Headers): Promise<Session['user'] | null>;
|
|
63
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,CAAA;IACD,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,IAAI,CAAA;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,CAAA;CACF,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAezB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAGjC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side session utilities
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Get the current session from headers.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { headers } from 'next/headers'
|
|
12
|
+
* import { getServerSession } from '@delmare/payload-better-auth'
|
|
13
|
+
*
|
|
14
|
+
* export default async function Page() {
|
|
15
|
+
* const headersList = await headers()
|
|
16
|
+
* const session = await getServerSession(payload, headersList)
|
|
17
|
+
*
|
|
18
|
+
* if (!session) {
|
|
19
|
+
* redirect('/login')
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* return <div>Hello {session.user.name}</div>
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export async function getServerSession(payload, headers) {
|
|
27
|
+
try {
|
|
28
|
+
const payloadWithAuth = payload;
|
|
29
|
+
if (!payloadWithAuth.betterAuth) {
|
|
30
|
+
console.error('[session] Better Auth not initialized');
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const session = await payloadWithAuth.betterAuth.api.getSession({ headers });
|
|
34
|
+
return session;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error('[session] Error getting session:', error);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the current user from the session.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { headers } from 'next/headers'
|
|
47
|
+
* import { getServerUser } from '@delmare/payload-better-auth'
|
|
48
|
+
*
|
|
49
|
+
* export default async function Page() {
|
|
50
|
+
* const headersList = await headers()
|
|
51
|
+
* const user = await getServerUser(payload, headersList)
|
|
52
|
+
*
|
|
53
|
+
* if (!user) {
|
|
54
|
+
* redirect('/login')
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* return <div>Hello {user.name}</div>
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export async function getServerUser(payload, headers) {
|
|
62
|
+
const session = await getServerSession(payload, headers);
|
|
63
|
+
return session?.user ?? null;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAoB,EACpB,OAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,OAA0B,CAAA;QAElD,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;YAChC,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAA;YACtD,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;QAC5E,OAAO,OAAyB,CAAA;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAA;QACxD,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAoB,EACpB,OAAgB;IAEhB,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACxD,OAAO,OAAO,EAAE,IAAI,IAAI,IAAI,CAAA;AAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delmaredigital/payload-better-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Better Auth adapter and plugins for Payload CMS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"require": "./dist/index.js"
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
13
|
},
|
|
14
14
|
"./adapter": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"require": "./dist/adapter/index.js"
|
|
15
|
+
"import": "./dist/adapter/index.js",
|
|
16
|
+
"types": "./dist/adapter/index.d.ts"
|
|
18
17
|
},
|
|
19
18
|
"./plugin": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"require": "./dist/plugin/index.js"
|
|
19
|
+
"import": "./dist/plugin/index.js",
|
|
20
|
+
"types": "./dist/plugin/index.d.ts"
|
|
23
21
|
},
|
|
24
22
|
"./client": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
23
|
+
"import": "./dist/exports/client.js",
|
|
24
|
+
"types": "./dist/exports/client.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./components": {
|
|
27
|
+
"import": "./dist/exports/components.js",
|
|
28
|
+
"types": "./dist/exports/components.d.ts"
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
31
|
"files": [
|
|
31
|
-
"dist"
|
|
32
|
-
"README.md"
|
|
32
|
+
"dist"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"dev": "
|
|
37
|
-
"
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"dev": "tsc --watch",
|
|
37
|
+
"dev-publish": "pnpm build && pnpm version prerelease --preid=dev && pnpm publish --registry http://localhost:4873",
|
|
38
|
+
"clean": "rm -rf dist",
|
|
38
39
|
"prepublishOnly": "pnpm build"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"better-auth": ">=1.0.0",
|
|
42
|
-
"next": ">=15.
|
|
43
|
+
"next": ">=14.0.0 || >=15.0.0 || >=16.0.0",
|
|
43
44
|
"payload": ">=3.0.0",
|
|
44
|
-
"react": ">=18.0.0"
|
|
45
|
+
"react": ">=18.0.0 || >=19.0.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/node": "^25.0.3",
|
|
@@ -50,7 +51,6 @@
|
|
|
50
51
|
"next": "^16.1.1",
|
|
51
52
|
"payload": "^3.69.0",
|
|
52
53
|
"react": "^19.2.3",
|
|
53
|
-
"tsup": "^8.5.1",
|
|
54
54
|
"typescript": "^5.9.3"
|
|
55
55
|
},
|
|
56
56
|
"keywords": [
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"node": "^18.20.2 || >=20.9.0"
|
|
66
66
|
},
|
|
67
67
|
"author": "Delmare Digital",
|
|
68
|
-
"license": "MIT",
|
|
69
68
|
"repository": {
|
|
70
69
|
"type": "git",
|
|
71
70
|
"url": "git+https://github.com/delmaredigital/payload-better-auth.git"
|
package/dist/adapter/index.d.mts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { BetterAuthOptions, Adapter } from 'better-auth';
|
|
2
|
-
export { Adapter, BetterAuthOptions } from 'better-auth';
|
|
3
|
-
import { BasePayload } from 'payload';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Payload CMS Adapter for Better Auth
|
|
7
|
-
*
|
|
8
|
-
* A clean adapter that bridges Better Auth to Payload collections.
|
|
9
|
-
* Follows the same factory pattern as payload-auth for compatibility.
|
|
10
|
-
*
|
|
11
|
-
* @packageDocumentation
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
type PayloadAdapterConfig = {
|
|
15
|
-
/**
|
|
16
|
-
* The Payload instance or a function that returns it.
|
|
17
|
-
* Use a function for lazy initialization.
|
|
18
|
-
*/
|
|
19
|
-
payloadClient: BasePayload | (() => Promise<BasePayload>);
|
|
20
|
-
/**
|
|
21
|
-
* Adapter configuration options
|
|
22
|
-
*/
|
|
23
|
-
adapterConfig: {
|
|
24
|
-
/**
|
|
25
|
-
* Map Better Auth model names to Payload collection slugs.
|
|
26
|
-
* Defaults: { user: 'users', session: 'sessions', account: 'accounts', verification: 'verifications' }
|
|
27
|
-
*/
|
|
28
|
-
collections?: Record<string, string>;
|
|
29
|
-
/**
|
|
30
|
-
* Enable debug logging for troubleshooting
|
|
31
|
-
*/
|
|
32
|
-
enableDebugLogs?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* ID type used by Payload
|
|
35
|
-
* - 'number' for SERIAL/auto-increment (recommended - Payload default)
|
|
36
|
-
* - 'text' for UUID (requires idType: 'uuid' in Payload's db adapter)
|
|
37
|
-
*/
|
|
38
|
-
idType: 'number' | 'text';
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Creates a Better Auth adapter that uses Payload CMS as the database.
|
|
43
|
-
*
|
|
44
|
-
* Returns a factory function that Better Auth calls with its options.
|
|
45
|
-
* This matches the pattern used by other Better Auth adapters.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* import { payloadAdapter } from '@delmare/payload-better-auth/adapter'
|
|
50
|
-
*
|
|
51
|
-
* const auth = betterAuth({
|
|
52
|
-
* database: payloadAdapter({
|
|
53
|
-
* payloadClient: payload,
|
|
54
|
-
* adapterConfig: {
|
|
55
|
-
* idType: 'number', // Use Payload's default SERIAL IDs
|
|
56
|
-
* collections: { user: 'users' },
|
|
57
|
-
* },
|
|
58
|
-
* }),
|
|
59
|
-
* // Required when using serial/integer IDs
|
|
60
|
-
* advanced: {
|
|
61
|
-
* database: {
|
|
62
|
-
* generateId: 'serial',
|
|
63
|
-
* },
|
|
64
|
-
* },
|
|
65
|
-
* })
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
declare function payloadAdapter({ payloadClient, adapterConfig, }: PayloadAdapterConfig): (options: BetterAuthOptions) => Adapter;
|
|
69
|
-
|
|
70
|
-
export { type PayloadAdapterConfig, payloadAdapter };
|