@delmaredigital/payload-better-auth 0.4.4 → 0.5.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/README.md +1 -1
- package/dist/adapter/index.d.ts +3 -15
- package/dist/adapter/index.js +46 -179
- package/dist/components/management/ApiKeysManagementClient.js +2 -1
- package/dist/exports/client.d.ts +1124 -1929
- package/dist/exports/client.js +4 -2
- package/dist/generated-types.d.ts +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin/index.js +1 -1
- package/dist/scripts/generate-types.js +3 -2
- package/dist/types/betterAuth.d.ts +5 -70
- package/dist/utils/apiKeyAccess.d.ts +5 -3
- package/dist/utils/apiKeyAccess.js +16 -7
- package/dist/utils/betterAuthDefaults.d.ts +0 -1056
- package/dist/utils/betterAuthDefaults.js +11 -38
- package/package.json +10 -5
|
@@ -2,38 +2,7 @@
|
|
|
2
2
|
* Utility to apply sensible defaults to Better Auth options.
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* API Key plugin with sensible defaults for use with this package.
|
|
8
|
-
*
|
|
9
|
-
* Enables metadata storage by default so that scopes can be displayed
|
|
10
|
-
* in the admin UI after key creation.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { apiKeyWithDefaults } from '@delmaredigital/payload-better-auth'
|
|
15
|
-
*
|
|
16
|
-
* export const betterAuthOptions = {
|
|
17
|
-
* plugins: [
|
|
18
|
-
* apiKeyWithDefaults(), // metadata enabled by default
|
|
19
|
-
* ],
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @example With custom options
|
|
24
|
-
* ```ts
|
|
25
|
-
* apiKeyWithDefaults({
|
|
26
|
-
* rateLimit: { max: 100, window: 60 },
|
|
27
|
-
* // enableMetadata is already true
|
|
28
|
-
* })
|
|
29
|
-
* ```
|
|
30
|
-
*/ export function apiKeyWithDefaults(options) {
|
|
31
|
-
return betterAuthApiKey({
|
|
32
|
-
enableMetadata: true,
|
|
33
|
-
...options
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
5
|
+
*/ /**
|
|
37
6
|
* Applies sensible defaults to Better Auth options.
|
|
38
7
|
*
|
|
39
8
|
* Currently applies the following defaults:
|
|
@@ -78,13 +47,17 @@
|
|
|
78
47
|
return options;
|
|
79
48
|
}
|
|
80
49
|
// If baseURL is set, default trustedOrigins to [baseURL]
|
|
50
|
+
// In Better Auth 1.5, baseURL can be a string or an object with { fallback, allowedHosts, protocol }
|
|
81
51
|
if (options.baseURL) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
options
|
|
86
|
-
|
|
87
|
-
|
|
52
|
+
const origin = typeof options.baseURL === 'string' ? options.baseURL : options.baseURL.fallback;
|
|
53
|
+
if (origin) {
|
|
54
|
+
return {
|
|
55
|
+
...options,
|
|
56
|
+
trustedOrigins: [
|
|
57
|
+
origin
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
88
61
|
}
|
|
89
62
|
// No defaults to apply
|
|
90
63
|
return options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delmaredigital/payload-better-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Better Auth adapter and plugins for Payload CMS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -75,21 +75,26 @@
|
|
|
75
75
|
"prepublishOnly": "pnpm build"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@better-auth/
|
|
78
|
+
"@better-auth/api-key": ">=1.5.0",
|
|
79
|
+
"@better-auth/passkey": ">=1.5.0",
|
|
79
80
|
"@payloadcms/next": ">=3.69.0",
|
|
80
81
|
"@payloadcms/ui": ">=3.69.0",
|
|
81
|
-
"better-auth": ">=1.
|
|
82
|
+
"better-auth": ">=1.5.0",
|
|
82
83
|
"next": ">=15.4.8",
|
|
83
84
|
"payload": ">=3.69.0",
|
|
84
85
|
"react": ">=19.2.1"
|
|
85
86
|
},
|
|
86
87
|
"peerDependenciesMeta": {
|
|
88
|
+
"@better-auth/api-key": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
87
91
|
"@better-auth/passkey": {
|
|
88
92
|
"optional": true
|
|
89
93
|
}
|
|
90
94
|
},
|
|
91
95
|
"devDependencies": {
|
|
92
|
-
"@better-auth/
|
|
96
|
+
"@better-auth/api-key": "^1.5.0",
|
|
97
|
+
"@better-auth/passkey": "^1.5.0",
|
|
93
98
|
"@payloadcms/next": "^3.77.0",
|
|
94
99
|
"@payloadcms/ui": "^3.77.0",
|
|
95
100
|
"@swc/cli": "^0.6.0",
|
|
@@ -97,7 +102,7 @@
|
|
|
97
102
|
"@types/node": "^25.3.0",
|
|
98
103
|
"@types/react": "^19.2.14",
|
|
99
104
|
"@vitest/coverage-v8": "^2.1.9",
|
|
100
|
-
"better-auth": "^1.
|
|
105
|
+
"better-auth": "^1.5.0",
|
|
101
106
|
"next": "^16.1.6",
|
|
102
107
|
"payload": "^3.77.0",
|
|
103
108
|
"react": "^19.2.4",
|