better-auth 1.6.23 → 1.6.25
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/dist/adapters/index.d.mts +1 -6
- package/dist/api/dispatch.d.mts +0 -1
- package/dist/api/index.d.mts +476 -478
- package/dist/api/middlewares/authorization.d.mts +12 -8
- package/dist/api/middlewares/authorization.mjs +2 -1
- package/dist/api/middlewares/index.d.mts +2 -1
- package/dist/api/middlewares/origin-check.d.mts +3 -5
- package/dist/api/routes/account.d.mts +10 -13
- package/dist/api/routes/account.mjs +35 -7
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +4 -0
- package/dist/api/routes/email-verification.d.mts +4 -8
- package/dist/api/routes/email-verification.mjs +15 -2
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/index.d.mts +2 -1
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/password.d.mts +7 -9
- package/dist/api/routes/password.mjs +14 -1
- package/dist/api/routes/session.d.mts +22 -24
- package/dist/api/routes/session.mjs +5 -1
- package/dist/api/routes/sign-in.d.mts +3 -5
- package/dist/api/routes/sign-in.mjs +84 -2
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-up.d.mts +3 -4
- package/dist/api/routes/sign-up.mjs +3 -2
- package/dist/api/routes/update-session.d.mts +3 -4
- package/dist/api/routes/update-user.d.mts +13 -14
- package/dist/api/routes/update-user.mjs +26 -1
- package/dist/auth/full.d.mts +1 -1
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/client/config.d.mts +12 -14
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +0 -1
- package/dist/client/index.d.mts +6 -5
- package/dist/client/lynx/index.d.mts +4 -5
- package/dist/client/lynx/lynx-store.d.mts +1 -2
- package/dist/client/parser.d.mts +7 -3
- package/dist/client/path-to-object.d.mts +3 -4
- package/dist/client/plugins/index.d.mts +1 -1
- package/dist/client/plugins/infer-plugin.d.mts +0 -1
- package/dist/client/query.d.mts +0 -1
- package/dist/client/query.mjs +38 -20
- package/dist/client/react/index.d.mts +4 -5
- package/dist/client/react/react-store.d.mts +1 -2
- package/dist/client/session-refresh.d.mts +0 -1
- package/dist/client/solid/index.d.mts +6 -6
- package/dist/client/solid/index.mjs +4 -2
- package/dist/client/svelte/index.d.mts +5 -6
- package/dist/client/types.d.mts +2 -2
- package/dist/client/vanilla.d.mts +2 -3
- package/dist/client/vue/index.d.mts +5 -6
- package/dist/context/create-context.mjs +3 -3
- package/dist/context/helpers.mjs +2 -2
- package/dist/cookies/cookie-utils.d.mts +1 -1
- package/dist/cookies/index.d.mts +6 -7
- package/dist/cookies/index.mjs +4 -0
- package/dist/cookies/session-store.d.mts +1 -0
- package/dist/cookies/session-store.mjs +6 -1
- package/dist/crypto/index.d.mts +2 -9
- package/dist/crypto/jwt.d.mts +0 -1
- package/dist/crypto/password.d.mts +1 -5
- package/dist/db/adapter-base.d.mts +0 -1
- package/dist/db/adapter-kysely.d.mts +0 -1
- package/dist/db/field-converter.d.mts +0 -1
- package/dist/db/field.d.mts +9 -10
- package/dist/db/get-migration.d.mts +0 -1
- package/dist/db/get-migration.mjs +8 -4
- package/dist/db/get-schema.d.mts +0 -1
- package/dist/db/internal-adapter.d.mts +0 -1
- package/dist/db/internal-adapter.mjs +61 -1
- package/dist/db/revoke-unproven-account-access.d.mts +0 -1
- package/dist/db/schema.d.mts +2 -2
- package/dist/db/to-zod.d.mts +3 -7
- package/dist/db/with-hooks.d.mts +0 -1
- package/dist/index.d.mts +4 -3
- package/dist/integrations/next-js.d.mts +4 -7
- package/dist/integrations/node.d.mts +2 -3
- package/dist/integrations/svelte-kit.d.mts +2 -9
- package/dist/integrations/tanstack-start-solid.d.mts +2 -5
- package/dist/integrations/tanstack-start.d.mts +2 -5
- package/dist/oauth2/link-account.d.mts +1 -1
- package/dist/oauth2/state.d.mts +0 -1
- package/dist/oauth2/utils.d.mts +0 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +0 -1
- package/dist/plugins/access/types.d.mts +4 -5
- package/dist/plugins/additional-fields/client.d.mts +0 -1
- package/dist/plugins/admin/access/statement.d.mts +1 -0
- package/dist/plugins/admin/admin.d.mts +120 -125
- package/dist/plugins/admin/client.d.mts +30 -30
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +23 -25
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +9 -0
- package/dist/plugins/admin/schema.d.mts +1 -1
- package/dist/plugins/admin/types.d.mts +3 -2
- package/dist/plugins/anonymous/client.d.mts +9 -11
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +8 -10
- package/dist/plugins/anonymous/index.d.mts +14 -18
- package/dist/plugins/anonymous/types.d.mts +1 -1
- package/dist/plugins/bearer/index.d.mts +4 -7
- package/dist/plugins/captcha/index.d.mts +5 -8
- package/dist/plugins/captcha/types.d.mts +0 -1
- package/dist/plugins/custom-session/client.d.mts +0 -1
- package/dist/plugins/custom-session/index.d.mts +7 -12
- package/dist/plugins/device-authorization/client.d.mts +0 -1
- package/dist/plugins/device-authorization/index.d.mts +19 -22
- package/dist/plugins/email-otp/client.d.mts +4 -6
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +3 -5
- package/dist/plugins/email-otp/index.d.mts +67 -73
- package/dist/plugins/email-otp/routes.mjs +2 -0
- package/dist/plugins/email-otp/types.d.mts +0 -1
- package/dist/plugins/generic-oauth/client.d.mts +10 -11
- package/dist/plugins/generic-oauth/client.mjs +1 -1
- package/dist/plugins/generic-oauth/error-codes.d.mts +8 -10
- package/dist/plugins/generic-oauth/index.d.mts +40 -44
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/index.d.mts +2 -1
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/line.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/okta.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/slack.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +0 -1
- package/dist/plugins/generic-oauth/routes.mjs +14 -0
- package/dist/plugins/generic-oauth/types.d.mts +1 -2
- package/dist/plugins/haveibeenpwned/index.d.mts +3 -6
- package/dist/plugins/index.d.mts +4 -1
- package/dist/plugins/jwt/client.d.mts +2 -4
- package/dist/plugins/jwt/index.d.mts +8 -11
- package/dist/plugins/jwt/sign.d.mts +2 -2
- package/dist/plugins/jwt/types.d.mts +1 -1
- package/dist/plugins/jwt/utils.d.mts +2 -4
- package/dist/plugins/jwt/verify.d.mts +0 -1
- package/dist/plugins/last-login-method/client.mjs +13 -0
- package/dist/plugins/last-login-method/index.d.mts +11 -5
- package/dist/plugins/last-login-method/index.mjs +8 -0
- package/dist/plugins/magic-link/client.d.mts +0 -1
- package/dist/plugins/magic-link/index.d.mts +4 -5
- package/dist/plugins/magic-link/index.mjs +32 -1
- package/dist/plugins/mcp/authorize.mjs +12 -0
- package/dist/plugins/mcp/client/adapters.d.mts +0 -1
- package/dist/plugins/mcp/client/index.d.mts +2 -0
- package/dist/plugins/mcp/client/index.mjs +36 -11
- package/dist/plugins/mcp/index.d.mts +10 -11
- package/dist/plugins/multi-session/client.d.mts +2 -4
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/index.d.mts +7 -11
- package/dist/plugins/multi-session/index.mjs +45 -0
- package/dist/plugins/oauth-popup/client.d.mts +6 -12
- package/dist/plugins/oauth-popup/client.mjs +5 -3
- package/dist/plugins/oauth-popup/error-codes.d.mts +4 -6
- package/dist/plugins/oauth-popup/index.d.mts +8 -12
- package/dist/plugins/oauth-popup/index.mjs +1 -1
- package/dist/plugins/oauth-popup/types.d.mts +1 -2
- package/dist/plugins/oauth-proxy/index.d.mts +6 -9
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oidc-provider/authorize.mjs +9 -0
- package/dist/plugins/oidc-provider/client.d.mts +1 -2
- package/dist/plugins/oidc-provider/index.d.mts +15 -17
- package/dist/plugins/oidc-provider/index.mjs +26 -2
- package/dist/plugins/oidc-provider/schema.d.mts +0 -1
- package/dist/plugins/oidc-provider/schema.mjs +37 -0
- package/dist/plugins/oidc-provider/types.d.mts +1 -1
- package/dist/plugins/one-tap/client.d.mts +3 -6
- package/dist/plugins/one-tap/client.mjs +3 -0
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +6 -1
- package/dist/plugins/one-time-token/client.d.mts +1 -2
- package/dist/plugins/one-time-token/index.d.mts +5 -6
- package/dist/plugins/one-time-token/index.mjs +30 -0
- package/dist/plugins/open-api/generator.d.mts +0 -1
- package/dist/plugins/open-api/generator.mjs +81 -5
- package/dist/plugins/open-api/index.d.mts +3 -5
- package/dist/plugins/organization/access/statement.d.mts +1 -0
- package/dist/plugins/organization/adapter.d.mts +56 -82
- package/dist/plugins/organization/adapter.mjs +17 -3
- package/dist/plugins/organization/client.d.mts +106 -105
- package/dist/plugins/organization/client.mjs +7 -4
- package/dist/plugins/organization/error-codes.d.mts +59 -61
- package/dist/plugins/organization/has-permission.d.mts +0 -1
- package/dist/plugins/organization/has-permission.mjs +1 -1
- package/dist/plugins/organization/index.d.mts +1 -1
- package/dist/plugins/organization/organization.d.mts +7 -7
- package/dist/plugins/organization/organization.mjs +434 -1
- package/dist/plugins/organization/permission.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +17 -17
- package/dist/plugins/organization/routes/crud-invites.d.mts +53 -54
- package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
- package/dist/plugins/organization/routes/crud-members.d.mts +44 -46
- package/dist/plugins/organization/routes/crud-members.mjs +4 -1
- package/dist/plugins/organization/routes/crud-org.d.mts +47 -48
- package/dist/plugins/organization/routes/crud-org.mjs +2 -2
- package/dist/plugins/organization/routes/crud-team.d.mts +50 -51
- package/dist/plugins/organization/schema.d.mts +4 -4
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +16 -16
- package/dist/plugins/phone-number/client.d.mts +13 -15
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +12 -14
- package/dist/plugins/phone-number/index.d.mts +41 -47
- package/dist/plugins/phone-number/routes.mjs +15 -0
- package/dist/plugins/phone-number/types.d.mts +1 -1
- package/dist/plugins/siwe/client.d.mts +0 -1
- package/dist/plugins/siwe/index.d.mts +4 -5
- package/dist/plugins/test-utils/index.d.mts +2 -4
- package/dist/plugins/test-utils/types.d.mts +1 -0
- package/dist/plugins/two-factor/backup-codes/index.d.mts +4 -6
- package/dist/plugins/two-factor/backup-codes/index.mjs +52 -1
- package/dist/plugins/two-factor/client.d.mts +12 -15
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +10 -12
- package/dist/plugins/two-factor/index.d.mts +27 -31
- package/dist/plugins/two-factor/index.mjs +30 -0
- package/dist/plugins/two-factor/otp/index.d.mts +2 -4
- package/dist/plugins/two-factor/otp/index.mjs +42 -1
- package/dist/plugins/two-factor/totp/index.d.mts +4 -6
- package/dist/plugins/two-factor/totp/index.mjs +47 -0
- package/dist/plugins/two-factor/types.d.mts +1 -1
- package/dist/plugins/username/client.d.mts +9 -11
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +8 -10
- package/dist/plugins/username/index.d.mts +17 -22
- package/dist/plugins/username/schema.d.mts +3 -5
- package/dist/state.d.mts +0 -1
- package/dist/state.mjs +4 -0
- package/dist/test-utils/test-instance.d.mts +5 -3
- package/dist/test-utils/test-instance.mjs +4 -1
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +1 -2
- package/dist/types/auth.d.mts +0 -1
- package/dist/types/helper.d.mts +5 -5
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +0 -1
- package/dist/types/plugins.d.mts +2 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/request.mjs +23 -0
- package/dist/utils/url.d.mts +0 -1
- package/package.json +11 -11
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
3
1
|
//#region src/plugins/multi-session/error-codes.d.ts
|
|
4
2
|
declare const MULTI_SESSION_ERROR_CODES: {
|
|
5
|
-
INVALID_SESSION_TOKEN:
|
|
3
|
+
INVALID_SESSION_TOKEN: import("@better-auth/core/utils/error-codes").RawError<"INVALID_SESSION_TOKEN">;
|
|
6
4
|
};
|
|
7
5
|
//#endregion
|
|
8
6
|
export { MULTI_SESSION_ERROR_CODES };
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { MULTI_SESSION_ERROR_CODES } from "./error-codes.mjs";
|
|
2
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
3
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
4
|
-
import * as better_call0 from "better-call";
|
|
5
2
|
import * as z from "zod";
|
|
6
|
-
|
|
7
3
|
//#region src/plugins/multi-session/index.d.ts
|
|
8
4
|
declare module "@better-auth/core" {
|
|
9
5
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -39,7 +35,7 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
39
35
|
*
|
|
40
36
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-list-device-sessions)
|
|
41
37
|
*/
|
|
42
|
-
listDeviceSessions:
|
|
38
|
+
listDeviceSessions: import("better-call").StrictEndpoint<"/multi-session/list-device-sessions", {
|
|
43
39
|
method: "GET";
|
|
44
40
|
requireHeaders: true;
|
|
45
41
|
}, {
|
|
@@ -78,7 +74,7 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
78
74
|
*
|
|
79
75
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-set-active)
|
|
80
76
|
*/
|
|
81
|
-
setActiveSession:
|
|
77
|
+
setActiveSession: import("better-call").StrictEndpoint<"/multi-session/set-active", {
|
|
82
78
|
method: "POST";
|
|
83
79
|
body: z.ZodObject<{
|
|
84
80
|
sessionToken: z.ZodString;
|
|
@@ -142,13 +138,13 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
142
138
|
*
|
|
143
139
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-revoke)
|
|
144
140
|
*/
|
|
145
|
-
revokeDeviceSession:
|
|
141
|
+
revokeDeviceSession: import("better-call").StrictEndpoint<"/multi-session/revoke", {
|
|
146
142
|
method: "POST";
|
|
147
143
|
body: z.ZodObject<{
|
|
148
144
|
sessionToken: z.ZodString;
|
|
149
145
|
}, z.core.$strip>;
|
|
150
146
|
requireHeaders: true;
|
|
151
|
-
use: ((inputContext:
|
|
147
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
152
148
|
session: {
|
|
153
149
|
session: Record<string, any> & {
|
|
154
150
|
id: string;
|
|
@@ -199,13 +195,13 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
199
195
|
};
|
|
200
196
|
hooks: {
|
|
201
197
|
after: {
|
|
202
|
-
matcher: (context:
|
|
203
|
-
handler: (inputContext:
|
|
198
|
+
matcher: (context: import("@better-auth/core").HookEndpointContext) => boolean;
|
|
199
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
204
200
|
}[];
|
|
205
201
|
};
|
|
206
202
|
options: MultiSessionConfig | undefined;
|
|
207
203
|
$ERROR_CODES: {
|
|
208
|
-
INVALID_SESSION_TOKEN:
|
|
204
|
+
INVALID_SESSION_TOKEN: import("@better-auth/core/utils/error-codes").RawError<"INVALID_SESSION_TOKEN">;
|
|
209
205
|
};
|
|
210
206
|
};
|
|
211
207
|
//#endregion
|
|
@@ -20,6 +20,21 @@ const multiSession = (options) => {
|
|
|
20
20
|
id: "multi-session",
|
|
21
21
|
version: PACKAGE_VERSION,
|
|
22
22
|
endpoints: {
|
|
23
|
+
/**
|
|
24
|
+
* ### Endpoint
|
|
25
|
+
*
|
|
26
|
+
* GET `/multi-session/list-device-sessions`
|
|
27
|
+
*
|
|
28
|
+
* ### API Methods
|
|
29
|
+
*
|
|
30
|
+
* **server:**
|
|
31
|
+
* `auth.api.listDeviceSessions`
|
|
32
|
+
*
|
|
33
|
+
* **client:**
|
|
34
|
+
* `authClient.multiSession.listDeviceSessions`
|
|
35
|
+
*
|
|
36
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-list-device-sessions)
|
|
37
|
+
*/
|
|
23
38
|
listDeviceSessions: createAuthEndpoint("/multi-session/list-device-sessions", {
|
|
24
39
|
method: "GET",
|
|
25
40
|
requireHeaders: true
|
|
@@ -38,6 +53,21 @@ const multiSession = (options) => {
|
|
|
38
53
|
user: parseUserOutput(ctx.context.options, item.user)
|
|
39
54
|
})));
|
|
40
55
|
}),
|
|
56
|
+
/**
|
|
57
|
+
* ### Endpoint
|
|
58
|
+
*
|
|
59
|
+
* POST `/multi-session/set-active`
|
|
60
|
+
*
|
|
61
|
+
* ### API Methods
|
|
62
|
+
*
|
|
63
|
+
* **server:**
|
|
64
|
+
* `auth.api.setActiveSession`
|
|
65
|
+
*
|
|
66
|
+
* **client:**
|
|
67
|
+
* `authClient.multiSession.setActive`
|
|
68
|
+
*
|
|
69
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-set-active)
|
|
70
|
+
*/
|
|
41
71
|
setActiveSession: createAuthEndpoint("/multi-session/set-active", {
|
|
42
72
|
method: "POST",
|
|
43
73
|
body: setActiveSessionBodySchema,
|
|
@@ -71,6 +101,21 @@ const multiSession = (options) => {
|
|
|
71
101
|
user: parseUserOutput(ctx.context.options, session.user)
|
|
72
102
|
});
|
|
73
103
|
}),
|
|
104
|
+
/**
|
|
105
|
+
* ### Endpoint
|
|
106
|
+
*
|
|
107
|
+
* POST `/multi-session/revoke`
|
|
108
|
+
*
|
|
109
|
+
* ### API Methods
|
|
110
|
+
*
|
|
111
|
+
* **server:**
|
|
112
|
+
* `auth.api.revokeDeviceSession`
|
|
113
|
+
*
|
|
114
|
+
* **client:**
|
|
115
|
+
* `authClient.multiSession.revoke`
|
|
116
|
+
*
|
|
117
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/multi-session#api-method-multi-session-revoke)
|
|
118
|
+
*/
|
|
74
119
|
revokeDeviceSession: createAuthEndpoint("/multi-session/revoke", {
|
|
75
120
|
method: "POST",
|
|
76
121
|
body: revokeDeviceSessionBodySchema,
|
|
@@ -2,9 +2,7 @@ import { POPUP_TOKEN_STORAGE_KEY } from "./constants.mjs";
|
|
|
2
2
|
import { OAUTH_POPUP_ERROR_CODES } from "./error-codes.mjs";
|
|
3
3
|
import { oauthPopup } from "./index.mjs";
|
|
4
4
|
import { BetterAuthClientOptions, ClientStore } from "@better-auth/core";
|
|
5
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
6
5
|
import { BetterFetch, BetterFetchPlugin } from "@better-fetch/fetch";
|
|
7
|
-
|
|
8
6
|
//#region src/plugins/oauth-popup/client.d.ts
|
|
9
7
|
/** Inputs for `authClient.signIn.popup`; mirror the redirect sign-in. */
|
|
10
8
|
interface SignInPopupOptions {
|
|
@@ -52,11 +50,7 @@ interface SignInPopupDeps {
|
|
|
52
50
|
* page to post the session token back, stores it for the bearer fetch plugin,
|
|
53
51
|
* and refreshes the reactive session.
|
|
54
52
|
*/
|
|
55
|
-
declare function createSignInPopup({
|
|
56
|
-
$fetch,
|
|
57
|
-
options,
|
|
58
|
-
notifySessionSignal
|
|
59
|
-
}: SignInPopupDeps): (opts: SignInPopupOptions) => Promise<SignInPopupResult>;
|
|
53
|
+
declare function createSignInPopup({ $fetch, options, notifySessionSignal }: SignInPopupDeps): (opts: SignInPopupOptions) => Promise<SignInPopupResult>;
|
|
60
54
|
/**
|
|
61
55
|
* Client plugin for popup OAuth sign-in. Adds `authClient.signIn.popup`. Pair
|
|
62
56
|
* with the server `oauthPopup` and `bearer` plugins.
|
|
@@ -66,10 +60,10 @@ declare const oauthPopupClient: () => {
|
|
|
66
60
|
version: string;
|
|
67
61
|
$InferServerPlugin: ReturnType<typeof oauthPopup>;
|
|
68
62
|
$ERROR_CODES: {
|
|
69
|
-
POPUP_SIGN_IN_FAILED:
|
|
70
|
-
POPUP_BLOCKED:
|
|
71
|
-
POPUP_CLOSED:
|
|
72
|
-
POPUP_TIMEOUT:
|
|
63
|
+
POPUP_SIGN_IN_FAILED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_SIGN_IN_FAILED">;
|
|
64
|
+
POPUP_BLOCKED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_BLOCKED">;
|
|
65
|
+
POPUP_CLOSED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_CLOSED">;
|
|
66
|
+
POPUP_TIMEOUT: import("@better-auth/core/utils/error-codes").RawError<"POPUP_TIMEOUT">;
|
|
73
67
|
};
|
|
74
68
|
fetchPlugins: BetterFetchPlugin[];
|
|
75
69
|
getActions: ($fetch: BetterFetch, $store: ClientStore, options: BetterAuthClientOptions | undefined) => {
|
|
@@ -79,4 +73,4 @@ declare const oauthPopupClient: () => {
|
|
|
79
73
|
};
|
|
80
74
|
};
|
|
81
75
|
//#endregion
|
|
82
|
-
export { SignInPopupOptions, SignInPopupResult, createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
76
|
+
export { OAUTH_POPUP_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, SignInPopupOptions, SignInPopupResult, createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
@@ -74,10 +74,12 @@ function popupError(code, status) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
function centeredFeatures() {
|
|
77
|
-
|
|
77
|
+
const left = window.screenX + (window.outerWidth - POPUP_WIDTH) / 2;
|
|
78
|
+
const top = window.screenY + (window.outerHeight - POPUP_HEIGHT) / 2;
|
|
79
|
+
return `width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${left},top=${top},menubar=no,toolbar=no`;
|
|
78
80
|
}
|
|
79
81
|
function randomNonce() {
|
|
80
|
-
const bytes = new Uint8Array(16);
|
|
82
|
+
const bytes = /* @__PURE__ */ new Uint8Array(16);
|
|
81
83
|
crypto.getRandomValues(bytes);
|
|
82
84
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
83
85
|
}
|
|
@@ -200,4 +202,4 @@ const oauthPopupClient = () => {
|
|
|
200
202
|
};
|
|
201
203
|
};
|
|
202
204
|
//#endregion
|
|
203
|
-
export { createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
205
|
+
export { OAUTH_POPUP_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY, createSignInPopup, getStoredPopupToken, oauthPopupClient, popupBearerFetchPlugin };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
3
1
|
//#region src/plugins/oauth-popup/error-codes.d.ts
|
|
4
2
|
declare const OAUTH_POPUP_ERROR_CODES: {
|
|
5
|
-
POPUP_SIGN_IN_FAILED:
|
|
6
|
-
POPUP_BLOCKED:
|
|
7
|
-
POPUP_CLOSED:
|
|
8
|
-
POPUP_TIMEOUT:
|
|
3
|
+
POPUP_SIGN_IN_FAILED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_SIGN_IN_FAILED">;
|
|
4
|
+
POPUP_BLOCKED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_BLOCKED">;
|
|
5
|
+
POPUP_CLOSED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_CLOSED">;
|
|
6
|
+
POPUP_TIMEOUT: import("@better-auth/core/utils/error-codes").RawError<"POPUP_TIMEOUT">;
|
|
9
7
|
};
|
|
10
8
|
//#endregion
|
|
11
9
|
export { OAUTH_POPUP_ERROR_CODES };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_MESSAGE_TYPE, POPUP_MARKER_COOKIE } from "./constants.mjs";
|
|
2
2
|
import { OAUTH_POPUP_ERROR_CODES } from "./error-codes.mjs";
|
|
3
3
|
import { OAuthPopupData, OAuthPopupMessage } from "./types.mjs";
|
|
4
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
5
|
-
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
6
|
-
import * as better_call0 from "better-call";
|
|
7
4
|
import * as z from "zod";
|
|
8
|
-
|
|
9
5
|
//#region src/plugins/oauth-popup/index.d.ts
|
|
10
6
|
declare module "@better-auth/core" {
|
|
11
7
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -32,13 +28,13 @@ declare const oauthPopup: () => {
|
|
|
32
28
|
id: "oauth-popup";
|
|
33
29
|
version: string;
|
|
34
30
|
$ERROR_CODES: {
|
|
35
|
-
POPUP_SIGN_IN_FAILED:
|
|
36
|
-
POPUP_BLOCKED:
|
|
37
|
-
POPUP_CLOSED:
|
|
38
|
-
POPUP_TIMEOUT:
|
|
31
|
+
POPUP_SIGN_IN_FAILED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_SIGN_IN_FAILED">;
|
|
32
|
+
POPUP_BLOCKED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_BLOCKED">;
|
|
33
|
+
POPUP_CLOSED: import("@better-auth/core/utils/error-codes").RawError<"POPUP_CLOSED">;
|
|
34
|
+
POPUP_TIMEOUT: import("@better-auth/core/utils/error-codes").RawError<"POPUP_TIMEOUT">;
|
|
39
35
|
};
|
|
40
36
|
endpoints: {
|
|
41
|
-
oauthPopupStart:
|
|
37
|
+
oauthPopupStart: import("better-call").StrictEndpoint<"/oauth-popup/start", {
|
|
42
38
|
method: "GET";
|
|
43
39
|
query: z.ZodObject<{
|
|
44
40
|
provider: z.ZodString;
|
|
@@ -58,10 +54,10 @@ declare const oauthPopup: () => {
|
|
|
58
54
|
};
|
|
59
55
|
hooks: {
|
|
60
56
|
after: {
|
|
61
|
-
matcher(context:
|
|
62
|
-
handler: (inputContext:
|
|
57
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
58
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
63
59
|
}[];
|
|
64
60
|
};
|
|
65
61
|
};
|
|
66
62
|
//#endregion
|
|
67
|
-
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_SCRIPT_CSP_HASH, oauthPopup };
|
|
63
|
+
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, type OAuthPopupData, type OAuthPopupMessage, POPUP_MARKER_COOKIE, oauthPopup };
|
|
@@ -225,4 +225,4 @@ const oauthPopup = () => {
|
|
|
225
225
|
};
|
|
226
226
|
};
|
|
227
227
|
//#endregion
|
|
228
|
-
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_SCRIPT_CSP_HASH, oauthPopup };
|
|
228
|
+
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, POPUP_MARKER_COOKIE, oauthPopup };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OAUTH_POPUP_MESSAGE_TYPE } from "./constants.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/plugins/oauth-popup/types.d.ts
|
|
4
3
|
/** OAuth error relayed to the opener when the flow fails. */
|
|
5
4
|
interface OAuthPopupError {
|
|
@@ -27,4 +26,4 @@ interface OAuthPopupData extends OAuthPopupMessage {
|
|
|
27
26
|
targetOrigin: string;
|
|
28
27
|
}
|
|
29
28
|
//#endregion
|
|
30
|
-
export { OAuthPopupData, OAuthPopupMessage };
|
|
29
|
+
export { OAuthPopupData, OAuthPopupError, OAuthPopupMessage };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
2
1
|
import { SecretConfig } from "@better-auth/core";
|
|
3
|
-
import * as better_call0 from "better-call";
|
|
4
2
|
import * as z from "zod";
|
|
5
|
-
|
|
6
3
|
//#region src/plugins/oauth-proxy/index.d.ts
|
|
7
4
|
declare module "@better-auth/core" {
|
|
8
5
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -58,14 +55,14 @@ declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
|
58
55
|
version: string;
|
|
59
56
|
options: NoInfer<O>;
|
|
60
57
|
endpoints: {
|
|
61
|
-
oAuthProxy:
|
|
58
|
+
oAuthProxy: import("better-call").StrictEndpoint<"/oauth-proxy-callback", {
|
|
62
59
|
method: "GET";
|
|
63
60
|
operationId: string;
|
|
64
61
|
query: z.ZodObject<{
|
|
65
62
|
callbackURL: z.ZodString;
|
|
66
63
|
profile: z.ZodOptional<z.ZodString>;
|
|
67
64
|
}, z.core.$strip>;
|
|
68
|
-
use: ((inputContext:
|
|
65
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
69
66
|
metadata: {
|
|
70
67
|
openapi: {
|
|
71
68
|
operationId: string;
|
|
@@ -100,12 +97,12 @@ declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
|
100
97
|
};
|
|
101
98
|
hooks: {
|
|
102
99
|
before: {
|
|
103
|
-
matcher(context:
|
|
104
|
-
handler: (inputContext:
|
|
100
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
101
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
105
102
|
}[];
|
|
106
103
|
after: {
|
|
107
|
-
matcher(context:
|
|
108
|
-
handler: (inputContext:
|
|
104
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
105
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
109
106
|
}[];
|
|
110
107
|
};
|
|
111
108
|
};
|
|
@@ -10,7 +10,7 @@ import { parseGenericState } from "../../state.mjs";
|
|
|
10
10
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
11
11
|
import { parseJSON } from "../../client/parser.mjs";
|
|
12
12
|
import { checkSkipProxy, resolveCurrentURL, stripTrailingSlash } from "./utils.mjs";
|
|
13
|
-
import { defu } from "defu";
|
|
13
|
+
import { defu as defu$1 } from "defu";
|
|
14
14
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
15
15
|
import * as z from "zod";
|
|
16
16
|
//#region src/plugins/oauth-proxy/index.ts
|
|
@@ -148,7 +148,7 @@ const oAuthProxy = (opts) => {
|
|
|
148
148
|
return context.path === "/callback/:id";
|
|
149
149
|
},
|
|
150
150
|
handler: createAuthMiddleware(async (ctx) => {
|
|
151
|
-
const callbackParams = defu(ctx.query, ctx.body);
|
|
151
|
+
const callbackParams = defu$1(ctx.query, ctx.body);
|
|
152
152
|
const state = callbackParams.state;
|
|
153
153
|
if (!state || typeof state !== "string") return;
|
|
154
154
|
let statePackage;
|
|
@@ -142,6 +142,15 @@ async function authorize(ctx, options) {
|
|
|
142
142
|
scope: requestScope,
|
|
143
143
|
userId: session.user.id,
|
|
144
144
|
authTime: new Date(session.session.createdAt).getTime(),
|
|
145
|
+
/**
|
|
146
|
+
* Consent is required per OIDC spec unless:
|
|
147
|
+
* 1. Client is trusted (skipConsent = true)
|
|
148
|
+
* 2. User has already consented (and prompt is not "consent")
|
|
149
|
+
*
|
|
150
|
+
* When consent is required, the code needs to be treated as a
|
|
151
|
+
* consent request. Once the user consents, the code will be
|
|
152
|
+
* updated with the actual authorization code.
|
|
153
|
+
*/
|
|
145
154
|
requireConsent,
|
|
146
155
|
state: requireConsent ? query.state : null,
|
|
147
156
|
codeChallenge: query.code_challenge,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthorizationQuery, Client, CodeVerificationValue, OAuthAccessToken, OIDCMetadata, OIDCOptions, TokenBody } from "./types.mjs";
|
|
2
2
|
import { oidcProvider } from "./index.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/plugins/oidc-provider/client.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* @deprecated Use `@better-auth/oauth-provider` instead. This plugin will be removed in the next major version.
|
|
@@ -13,4 +12,4 @@ declare const oidcClient: () => {
|
|
|
13
12
|
};
|
|
14
13
|
type OidcClientPlugin = ReturnType<typeof oidcClient>;
|
|
15
14
|
//#endregion
|
|
16
|
-
export { OidcClientPlugin, oidcClient };
|
|
15
|
+
export { type AuthorizationQuery, type Client, type CodeVerificationValue, type OAuthAccessToken, type OIDCMetadata, type OIDCOptions, OidcClientPlugin, type TokenBody, oidcClient };
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
2
2
|
import { schema } from "./schema.mjs";
|
|
3
3
|
import { AuthorizationQuery, Client, CodeVerificationValue, OAuthAccessToken, OIDCMetadata, OIDCOptions, TokenBody } from "./types.mjs";
|
|
4
|
+
import "../index.mjs";
|
|
4
5
|
import { GenericEndpointContext } from "@better-auth/core";
|
|
5
|
-
import * as _better_auth_core_db0 from "@better-auth/core/db";
|
|
6
|
-
import * as better_call0 from "better-call";
|
|
7
6
|
import { OpenAPIParameter } from "better-call";
|
|
8
7
|
import * as z from "zod";
|
|
9
|
-
|
|
10
8
|
//#region src/plugins/oidc-provider/index.d.ts
|
|
11
9
|
declare module "@better-auth/core" {
|
|
12
10
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -41,21 +39,21 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
41
39
|
hooks: {
|
|
42
40
|
after: {
|
|
43
41
|
matcher(): true;
|
|
44
|
-
handler: (inputContext:
|
|
42
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<Response | {
|
|
45
43
|
redirect: boolean;
|
|
46
44
|
url: string;
|
|
47
45
|
} | undefined>;
|
|
48
46
|
}[];
|
|
49
47
|
};
|
|
50
48
|
endpoints: {
|
|
51
|
-
getOpenIdConfig:
|
|
49
|
+
getOpenIdConfig: import("better-call").StrictEndpoint<"/.well-known/openid-configuration", {
|
|
52
50
|
method: "GET";
|
|
53
51
|
operationId: string;
|
|
54
52
|
metadata: {
|
|
55
53
|
readonly scope: "server";
|
|
56
54
|
};
|
|
57
55
|
}, OIDCMetadata>;
|
|
58
|
-
oAuth2authorize:
|
|
56
|
+
oAuth2authorize: import("better-call").StrictEndpoint<"/oauth2/authorize", {
|
|
59
57
|
method: "GET";
|
|
60
58
|
operationId: string;
|
|
61
59
|
query: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
@@ -82,14 +80,14 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
82
80
|
redirect: boolean;
|
|
83
81
|
url: string;
|
|
84
82
|
}>;
|
|
85
|
-
oAuthConsent:
|
|
83
|
+
oAuthConsent: import("better-call").StrictEndpoint<"/oauth2/consent", {
|
|
86
84
|
method: "POST";
|
|
87
85
|
operationId: string;
|
|
88
86
|
body: z.ZodObject<{
|
|
89
87
|
accept: z.ZodBoolean;
|
|
90
88
|
consent_code: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
91
89
|
}, z.core.$strip>;
|
|
92
|
-
use: ((inputContext:
|
|
90
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
93
91
|
session: {
|
|
94
92
|
session: Record<string, any> & {
|
|
95
93
|
id: string;
|
|
@@ -161,7 +159,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
161
159
|
}, {
|
|
162
160
|
redirectURI: string;
|
|
163
161
|
}>;
|
|
164
|
-
oAuth2token:
|
|
162
|
+
oAuth2token: import("better-call").StrictEndpoint<"/oauth2/token", {
|
|
165
163
|
method: "POST";
|
|
166
164
|
operationId: string;
|
|
167
165
|
body: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
@@ -183,7 +181,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
183
181
|
scope: string;
|
|
184
182
|
id_token: string | undefined;
|
|
185
183
|
}>;
|
|
186
|
-
oAuth2userInfo:
|
|
184
|
+
oAuth2userInfo: import("better-call").StrictEndpoint<"/oauth2/userinfo", {
|
|
187
185
|
method: "GET";
|
|
188
186
|
operationId: string;
|
|
189
187
|
metadata: {
|
|
@@ -275,7 +273,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
275
273
|
*
|
|
276
274
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/oidc-provider#api-method-oauth2-register)
|
|
277
275
|
*/
|
|
278
|
-
registerOAuthApplication:
|
|
276
|
+
registerOAuthApplication: import("better-call").StrictEndpoint<"/oauth2/register", {
|
|
279
277
|
method: "POST";
|
|
280
278
|
body: z.ZodObject<{
|
|
281
279
|
redirect_uris: z.ZodArray<z.ZodString>;
|
|
@@ -415,9 +413,9 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
415
413
|
client_secret?: string | undefined;
|
|
416
414
|
client_id: string;
|
|
417
415
|
}>;
|
|
418
|
-
getOAuthClient:
|
|
416
|
+
getOAuthClient: import("better-call").StrictEndpoint<"/oauth2/client/:id", {
|
|
419
417
|
method: "GET";
|
|
420
|
-
use: ((inputContext:
|
|
418
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
421
419
|
session: {
|
|
422
420
|
session: Record<string, any> & {
|
|
423
421
|
id: string;
|
|
@@ -488,7 +486,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
488
486
|
*
|
|
489
487
|
* @see [OpenID Connect RP-Initiated Logout Spec](https://openid.net/specs/openid-connect-rpinitiated-1_0.html)
|
|
490
488
|
*/
|
|
491
|
-
endSession:
|
|
489
|
+
endSession: import("better-call").StrictEndpoint<"/oauth2/endsession", {
|
|
492
490
|
method: ("GET" | "POST")[];
|
|
493
491
|
query: z.ZodOptional<z.ZodObject<{
|
|
494
492
|
id_token_hint: z.ZodOptional<z.ZodString>;
|
|
@@ -514,7 +512,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
514
512
|
scope: "server";
|
|
515
513
|
};
|
|
516
514
|
}, {
|
|
517
|
-
status: ("OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") |
|
|
515
|
+
status: ("OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") | import("better-call").Status;
|
|
518
516
|
body: ({
|
|
519
517
|
message?: string;
|
|
520
518
|
code?: string;
|
|
@@ -689,7 +687,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
689
687
|
allowPlainCodeChallengeMethod: boolean;
|
|
690
688
|
generateClientId?: (() => string) | undefined;
|
|
691
689
|
generateClientSecret?: (() => string) | undefined;
|
|
692
|
-
getAdditionalUserInfoClaim?: ((user:
|
|
690
|
+
getAdditionalUserInfoClaim?: ((user: import("@better-auth/core/db").User & Record<string, any>, scopes: string[], client: Client) => Record<string, any> | Promise<Record<string, any>>) | undefined;
|
|
693
691
|
trustedClients?: Client[] | undefined;
|
|
694
692
|
storeClientSecret: "plain" | "hashed" | "encrypted" | {
|
|
695
693
|
hash: (clientSecret: string) => Promise<string>;
|
|
@@ -702,4 +700,4 @@ declare const oidcProvider: (options: OIDCOptions) => {
|
|
|
702
700
|
};
|
|
703
701
|
};
|
|
704
702
|
//#endregion
|
|
705
|
-
export { AuthorizationQuery, Client, CodeVerificationValue, OAuthAccessToken, OIDCMetadata, OIDCOptions, TokenBody, getClient, getMetadata, oidcProvider };
|
|
703
|
+
export { type AuthorizationQuery, type Client, type CodeVerificationValue, type OAuthAccessToken, type OIDCMetadata, type OIDCOptions, type TokenBody, getClient, getMetadata, oidcProvider };
|
|
@@ -414,8 +414,7 @@ const oidcProvider = (options) => {
|
|
|
414
414
|
client_id = id;
|
|
415
415
|
client_secret = secret;
|
|
416
416
|
}
|
|
417
|
-
const
|
|
418
|
-
const iat = Math.floor(now / 1e3);
|
|
417
|
+
const iat = Math.floor(Date.now() / 1e3);
|
|
419
418
|
const exp = iat + (opts.accessTokenExpiresIn ?? 3600);
|
|
420
419
|
const accessTokenExpiresAt = /* @__PURE__ */ new Date(exp * 1e3);
|
|
421
420
|
const refreshTokenExpiresAt = /* @__PURE__ */ new Date((iat + (opts.refreshTokenExpiresIn ?? 604800)) * 1e3);
|
|
@@ -765,6 +764,21 @@ const oidcProvider = (options) => {
|
|
|
765
764
|
...userClaims
|
|
766
765
|
});
|
|
767
766
|
}),
|
|
767
|
+
/**
|
|
768
|
+
* ### Endpoint
|
|
769
|
+
*
|
|
770
|
+
* POST `/oauth2/register`
|
|
771
|
+
*
|
|
772
|
+
* ### API Methods
|
|
773
|
+
*
|
|
774
|
+
* **server:**
|
|
775
|
+
* `auth.api.registerOAuthApplication`
|
|
776
|
+
*
|
|
777
|
+
* **client:**
|
|
778
|
+
* `authClient.oauth2.register`
|
|
779
|
+
*
|
|
780
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/oidc-provider#api-method-oauth2-register)
|
|
781
|
+
*/
|
|
768
782
|
registerOAuthApplication: createAuthEndpoint("/oauth2/register", {
|
|
769
783
|
method: "POST",
|
|
770
784
|
body: registerOAuthApplicationBodySchema,
|
|
@@ -965,6 +979,16 @@ const oidcProvider = (options) => {
|
|
|
965
979
|
icon: client.icon || null
|
|
966
980
|
});
|
|
967
981
|
}),
|
|
982
|
+
/**
|
|
983
|
+
* ### Endpoint
|
|
984
|
+
*
|
|
985
|
+
* GET/POST `/oauth2/endsession`
|
|
986
|
+
*
|
|
987
|
+
* Implements RP-Initiated Logout as per OpenID Connect RP-Initiated Logout 1.0.
|
|
988
|
+
* Allows relying parties to request that an OpenID Provider log out the end-user.
|
|
989
|
+
*
|
|
990
|
+
* @see [OpenID Connect RP-Initiated Logout Spec](https://openid.net/specs/openid-connect-rpinitiated-1_0.html)
|
|
991
|
+
*/
|
|
968
992
|
endSession: createAuthEndpoint("/oauth2/endsession", {
|
|
969
993
|
method: ["GET", "POST"],
|
|
970
994
|
query: z.object({
|
|
@@ -1,17 +1,54 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
//#region src/plugins/oidc-provider/schema.ts
|
|
3
3
|
z.object({
|
|
4
|
+
/**
|
|
5
|
+
* Client ID
|
|
6
|
+
*
|
|
7
|
+
* size 32
|
|
8
|
+
*
|
|
9
|
+
* as described on https://www.rfc-editor.org/rfc/rfc6749.html#section-2.2
|
|
10
|
+
*/
|
|
4
11
|
clientId: z.string(),
|
|
12
|
+
/**
|
|
13
|
+
* Client Secret
|
|
14
|
+
*
|
|
15
|
+
* A secret for the client, if required by the authorization server.
|
|
16
|
+
* Optional for public clients using PKCE.
|
|
17
|
+
*
|
|
18
|
+
* size 32
|
|
19
|
+
*/
|
|
5
20
|
clientSecret: z.string().optional(),
|
|
21
|
+
/**
|
|
22
|
+
* The client type
|
|
23
|
+
*
|
|
24
|
+
* as described on https://www.rfc-editor.org/rfc/rfc6749.html#section-2.1
|
|
25
|
+
*
|
|
26
|
+
* - web - A web application
|
|
27
|
+
* - native - A mobile application
|
|
28
|
+
* - user-agent-based - A user-agent-based application
|
|
29
|
+
* - public - A public client (PKCE-enabled, no client_secret)
|
|
30
|
+
*/
|
|
6
31
|
type: z.enum([
|
|
7
32
|
"web",
|
|
8
33
|
"native",
|
|
9
34
|
"user-agent-based",
|
|
10
35
|
"public"
|
|
11
36
|
]),
|
|
37
|
+
/**
|
|
38
|
+
* The name of the client.
|
|
39
|
+
*/
|
|
12
40
|
name: z.string(),
|
|
41
|
+
/**
|
|
42
|
+
* The icon of the client.
|
|
43
|
+
*/
|
|
13
44
|
icon: z.string().optional(),
|
|
45
|
+
/**
|
|
46
|
+
* Additional metadata about the client.
|
|
47
|
+
*/
|
|
14
48
|
metadata: z.string().optional(),
|
|
49
|
+
/**
|
|
50
|
+
* Whether the client is disabled or not.
|
|
51
|
+
*/
|
|
15
52
|
disabled: z.boolean().optional().default(false),
|
|
16
53
|
redirectUrls: z.string(),
|
|
17
54
|
userId: z.string().optional(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
2
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
|
+
import "../../types/index.mjs";
|
|
3
4
|
import { OAuthApplication, schema } from "./schema.mjs";
|
|
4
|
-
|
|
5
5
|
//#region src/plugins/oidc-provider/types.d.ts
|
|
6
6
|
interface OIDCOptions {
|
|
7
7
|
/** @internal */
|