better-auth 1.7.12 → 1.7.14
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 +5 -10
- package/dist/api/dispatch.d.mts +3 -5
- package/dist/api/dispatch.mjs +6 -4
- package/dist/api/index.d.mts +506 -508
- package/dist/api/index.mjs +35 -34
- package/dist/api/middlewares/authorization.d.mts +15 -12
- 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 +4 -7
- package/dist/api/routes/account.d.mts +11 -15
- package/dist/api/routes/account.mjs +7 -4
- package/dist/api/routes/callback.d.mts +2 -5
- package/dist/api/routes/callback.mjs +4 -2
- package/dist/api/routes/email-verification.d.mts +7 -12
- package/dist/api/routes/error.d.mts +2 -5
- package/dist/api/routes/index.d.mts +2 -1
- package/dist/api/routes/ok.d.mts +2 -5
- package/dist/api/routes/password.d.mts +8 -11
- package/dist/api/routes/password.mjs +3 -2
- package/dist/api/routes/session.d.mts +26 -29
- package/dist/api/routes/sign-in.d.mts +4 -6
- package/dist/api/routes/sign-out.d.mts +2 -5
- package/dist/api/routes/sign-up.d.mts +4 -6
- package/dist/api/routes/update-session.d.mts +4 -6
- package/dist/api/routes/update-user.d.mts +14 -16
- package/dist/api/routes/update-user.mjs +1 -1
- package/dist/api/state/oauth.d.mts +0 -3
- package/dist/api/state/oauth.mjs +2 -1
- package/dist/auth/full.d.mts +3 -4
- package/dist/auth/minimal.d.mts +3 -3
- package/dist/client/broadcast-channel.d.mts +6 -7
- package/dist/client/config.d.mts +15 -19
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +3 -5
- package/dist/client/focus-manager.d.mts +4 -5
- package/dist/client/index.d.mts +8 -7
- package/dist/client/lynx/index.d.mts +6 -7
- package/dist/client/lynx/index.mjs +3 -2
- package/dist/client/lynx/lynx-store.d.mts +3 -4
- package/dist/client/online-manager.d.mts +4 -5
- package/dist/client/parser.d.mts +9 -5
- package/dist/client/path-to-object.d.mts +13 -14
- package/dist/client/plugins/index.d.mts +1 -1
- package/dist/client/plugins/infer-plugin.d.mts +2 -4
- package/dist/client/query.d.mts +4 -6
- package/dist/client/react/index.d.mts +6 -7
- package/dist/client/react/index.mjs +3 -2
- package/dist/client/react/react-store.d.mts +3 -4
- package/dist/client/session-atom.d.mts +4 -4
- package/dist/client/session-refresh.d.mts +3 -5
- package/dist/client/solid/index.d.mts +6 -7
- package/dist/client/solid/index.mjs +3 -2
- package/dist/client/svelte/index.d.mts +6 -7
- package/dist/client/svelte/index.mjs +3 -2
- package/dist/client/types.d.mts +11 -11
- package/dist/client/vanilla.d.mts +4 -5
- package/dist/client/vanilla.mjs +3 -2
- package/dist/client/vue/index.d.mts +6 -7
- package/dist/client/vue/index.mjs +3 -2
- package/dist/context/create-context.mjs +7 -7
- package/dist/context/helpers.mjs +9 -7
- package/dist/cookies/cookie-utils.d.mts +13 -13
- package/dist/cookies/cookie-utils.mjs +1 -3
- package/dist/cookies/index.d.mts +17 -18
- package/dist/cookies/index.mjs +11 -7
- package/dist/cookies/jwt.mjs +2 -1
- package/dist/cookies/session-store.d.mts +6 -5
- package/dist/cookies/session-store.mjs +3 -2
- package/dist/crypto/buffer.d.mts +2 -3
- package/dist/crypto/index.d.mts +9 -16
- package/dist/crypto/index.mjs +2 -1
- package/dist/crypto/jwt.d.mts +5 -7
- package/dist/crypto/jwt.mjs +2 -1
- package/dist/crypto/password.d.mts +1 -5
- package/dist/crypto/random.d.mts +2 -3
- package/dist/db/adapter-base.d.mts +2 -4
- package/dist/db/adapter-kysely.d.mts +2 -4
- package/dist/db/field-converter.d.mts +3 -5
- package/dist/db/field.d.mts +11 -12
- package/dist/db/get-migration.d.mts +4 -8
- package/dist/db/get-migration.mjs +22 -22
- package/dist/db/get-schema.d.mts +2 -4
- package/dist/db/internal-adapter.d.mts +2 -4
- package/dist/db/internal-adapter.mjs +6 -4
- package/dist/db/revoke-unproven-account-access.d.mts +3 -4
- package/dist/db/schema.d.mts +15 -16
- package/dist/db/schema.mjs +6 -3
- package/dist/db/to-zod.d.mts +5 -9
- package/dist/db/with-hooks.d.mts +3 -5
- package/dist/index.d.mts +4 -3
- package/dist/integrations/next-js.d.mts +7 -11
- package/dist/integrations/node.d.mts +5 -7
- package/dist/integrations/node.mjs +4 -2
- package/dist/integrations/solid-start.d.mts +2 -3
- package/dist/integrations/svelte-kit.d.mts +6 -14
- package/dist/integrations/tanstack-start-solid.d.mts +4 -8
- package/dist/integrations/tanstack-start.d.mts +4 -8
- package/dist/oauth2/link-account.d.mts +5 -11
- package/dist/oauth2/link-account.mjs +12 -6
- package/dist/oauth2/state.d.mts +5 -7
- package/dist/oauth2/state.mjs +1 -1
- package/dist/oauth2/utils.d.mts +4 -6
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +4 -6
- package/dist/plugins/access/index.mjs +1 -2
- package/dist/plugins/access/types.d.mts +12 -14
- package/dist/plugins/additional-fields/client.d.mts +2 -4
- package/dist/plugins/admin/access/index.mjs +1 -2
- package/dist/plugins/admin/access/statement.d.mts +7 -7
- package/dist/plugins/admin/admin.d.mts +122 -128
- package/dist/plugins/admin/client.d.mts +32 -32
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +25 -28
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/index.mjs +1 -2
- package/dist/plugins/admin/schema.d.mts +3 -4
- package/dist/plugins/admin/types.d.mts +8 -8
- package/dist/plugins/anonymous/client.d.mts +10 -12
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +10 -13
- package/dist/plugins/anonymous/index.d.mts +17 -21
- package/dist/plugins/anonymous/schema.d.mts +2 -3
- package/dist/plugins/anonymous/types.d.mts +5 -6
- package/dist/plugins/bearer/index.d.mts +7 -11
- package/dist/plugins/captcha/constants.d.mts +2 -3
- package/dist/plugins/captcha/index.d.mts +6 -9
- package/dist/plugins/captcha/types.d.mts +11 -13
- package/dist/plugins/custom-session/client.d.mts +2 -4
- package/dist/plugins/custom-session/index.d.mts +10 -16
- package/dist/plugins/device-authorization/client.d.mts +2 -4
- package/dist/plugins/device-authorization/index.d.mts +39 -44
- package/dist/plugins/device-authorization/index.mjs +10 -9
- package/dist/plugins/device-authorization/routes.d.mts +7 -5
- package/dist/plugins/device-authorization/routes.mjs +6 -5
- package/dist/plugins/device-authorization/schema.d.mts +2 -3
- package/dist/plugins/email-otp/client.d.mts +5 -7
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +5 -8
- package/dist/plugins/email-otp/index.d.mts +69 -76
- package/dist/plugins/email-otp/otp-token.mjs +19 -7
- package/dist/plugins/email-otp/types.d.mts +2 -4
- package/dist/plugins/generic-oauth/index.d.mts +9 -13
- package/dist/plugins/generic-oauth/index.mjs +6 -4
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +2 -1
- package/dist/plugins/generic-oauth/providers/index.d.mts +2 -1
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/line.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/okta.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/slack.d.mts +3 -5
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +3 -5
- package/dist/plugins/generic-oauth/types.d.mts +6 -7
- package/dist/plugins/haveibeenpwned/index.d.mts +7 -11
- package/dist/plugins/index.d.mts +4 -1
- package/dist/plugins/jwt/client.d.mts +2 -3
- package/dist/plugins/jwt/index.d.mts +11 -14
- package/dist/plugins/jwt/index.mjs +1 -1
- package/dist/plugins/jwt/schema.d.mts +2 -3
- package/dist/plugins/jwt/sign.d.mts +9 -8
- package/dist/plugins/jwt/types.d.mts +7 -8
- package/dist/plugins/jwt/utils.d.mts +6 -9
- package/dist/plugins/jwt/verify.d.mts +2 -4
- package/dist/plugins/last-login-method/client.d.mts +3 -4
- package/dist/plugins/last-login-method/index.d.mts +5 -9
- package/dist/plugins/last-login-method/index.mjs +1 -1
- package/dist/plugins/magic-link/client.d.mts +2 -4
- package/dist/plugins/magic-link/index.d.mts +7 -10
- package/dist/plugins/magic-link/index.mjs +20 -17
- package/dist/plugins/multi-session/client.d.mts +3 -5
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +3 -6
- package/dist/plugins/multi-session/index.d.mts +10 -14
- package/dist/plugins/oauth-popup/client.d.mts +11 -17
- package/dist/plugins/oauth-popup/client.mjs +6 -4
- package/dist/plugins/oauth-popup/constants.d.mts +5 -6
- package/dist/plugins/oauth-popup/error-codes.d.mts +6 -9
- package/dist/plugins/oauth-popup/index.d.mts +11 -15
- package/dist/plugins/oauth-popup/index.mjs +8 -7
- package/dist/plugins/oauth-popup/types.d.mts +4 -6
- package/dist/plugins/oauth-proxy/index.d.mts +11 -15
- package/dist/plugins/oauth-proxy/index.mjs +10 -7
- package/dist/plugins/one-tap/client.d.mts +6 -9
- package/dist/plugins/one-tap/index.d.mts +4 -7
- package/dist/plugins/one-time-token/client.d.mts +2 -3
- package/dist/plugins/one-time-token/index.d.mts +8 -10
- package/dist/plugins/open-api/generator.d.mts +8 -8
- package/dist/plugins/open-api/generator.mjs +5 -5
- package/dist/plugins/open-api/index.d.mts +5 -7
- package/dist/plugins/organization/access/index.mjs +1 -2
- package/dist/plugins/organization/access/statement.d.mts +8 -8
- package/dist/plugins/organization/adapter.d.mts +60 -87
- package/dist/plugins/organization/adapter.mjs +14 -10
- package/dist/plugins/organization/client.d.mts +108 -107
- package/dist/plugins/organization/client.mjs +9 -5
- package/dist/plugins/organization/error-codes.d.mts +61 -64
- package/dist/plugins/organization/has-permission.d.mts +2 -4
- 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 +20 -20
- package/dist/plugins/organization/organization.mjs +13 -8
- package/dist/plugins/organization/permission.d.mts +4 -5
- package/dist/plugins/organization/routes/crud-access-control.d.mts +28 -28
- package/dist/plugins/organization/routes/crud-invites.d.mts +64 -65
- package/dist/plugins/organization/routes/crud-invites.mjs +21 -18
- package/dist/plugins/organization/routes/crud-members.d.mts +53 -56
- package/dist/plugins/organization/routes/crud-members.mjs +23 -21
- package/dist/plugins/organization/routes/crud-org.d.mts +63 -65
- package/dist/plugins/organization/routes/crud-org.mjs +4 -2
- package/dist/plugins/organization/routes/crud-team.d.mts +65 -66
- package/dist/plugins/organization/routes/crud-team.mjs +4 -2
- package/dist/plugins/organization/schema.d.mts +33 -33
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +16 -17
- package/dist/plugins/phone-number/client.d.mts +14 -16
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +14 -17
- package/dist/plugins/phone-number/index.d.mts +48 -54
- package/dist/plugins/phone-number/schema.d.mts +2 -3
- package/dist/plugins/phone-number/types.d.mts +4 -5
- package/dist/plugins/siwe/client.d.mts +2 -4
- package/dist/plugins/siwe/index.d.mts +7 -9
- package/dist/plugins/siwe/index.mjs +1 -1
- package/dist/plugins/siwe/parse-message.mjs +1 -3
- package/dist/plugins/siwe/schema.d.mts +3 -4
- package/dist/plugins/siwe/types.d.mts +4 -4
- package/dist/plugins/test-utils/auth-helpers.mjs +4 -2
- package/dist/plugins/test-utils/index.d.mts +3 -5
- package/dist/plugins/test-utils/types.d.mts +7 -7
- package/dist/plugins/two-factor/backup-codes/index.d.mts +11 -14
- package/dist/plugins/two-factor/backup-codes/index.mjs +12 -6
- package/dist/plugins/two-factor/client.d.mts +16 -19
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/constant.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +15 -18
- package/dist/plugins/two-factor/index.d.mts +31 -35
- package/dist/plugins/two-factor/index.mjs +6 -3
- package/dist/plugins/two-factor/otp/index.d.mts +5 -8
- package/dist/plugins/two-factor/otp/index.mjs +159 -154
- package/dist/plugins/two-factor/schema.d.mts +2 -3
- package/dist/plugins/two-factor/totp/index.d.mts +7 -10
- package/dist/plugins/two-factor/totp/index.mjs +164 -148
- package/dist/plugins/two-factor/types.d.mts +6 -7
- package/dist/plugins/username/client.d.mts +12 -14
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +11 -14
- package/dist/plugins/username/index.d.mts +26 -31
- package/dist/plugins/username/schema.d.mts +7 -10
- package/dist/state.d.mts +4 -5
- package/dist/test-utils/headers.d.mts +2 -3
- package/dist/test-utils/http-test-instance.d.mts +26 -29
- package/dist/test-utils/test-instance.d.mts +7 -6
- package/dist/test-utils/test-instance.mjs +4 -2
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +4 -6
- package/dist/types/auth.d.mts +2 -4
- package/dist/types/helper.d.mts +11 -12
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +4 -5
- package/dist/types/plugins.d.mts +7 -8
- package/dist/utils/hide-metadata.d.mts +2 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/is-api-error.mjs +1 -2
- package/dist/utils/time.d.mts +4 -4
- package/dist/utils/url.d.mts +13 -15
- package/dist/utils/wildcard.mjs +5 -3
- package/package.json +12 -12
|
@@ -1,8 +1,5 @@
|
|
|
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
|
-
declare const MULTI_SESSION_ERROR_CODES: {
|
|
5
|
-
INVALID_SESSION_TOKEN:
|
|
2
|
+
export declare const MULTI_SESSION_ERROR_CODES: {
|
|
3
|
+
INVALID_SESSION_TOKEN: import("@better-auth/core/utils/error-codes").RawError<"INVALID_SESSION_TOKEN">;
|
|
6
4
|
};
|
|
7
|
-
//#endregion
|
|
8
|
-
export { MULTI_SESSION_ERROR_CODES };
|
|
5
|
+
//#endregion
|
|
@@ -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> {
|
|
@@ -12,7 +8,7 @@ declare module "@better-auth/core" {
|
|
|
12
8
|
};
|
|
13
9
|
}
|
|
14
10
|
}
|
|
15
|
-
interface MultiSessionConfig {
|
|
11
|
+
export interface MultiSessionConfig {
|
|
16
12
|
/**
|
|
17
13
|
* The maximum number of sessions a user can have
|
|
18
14
|
* at a time
|
|
@@ -20,7 +16,7 @@ interface MultiSessionConfig {
|
|
|
20
16
|
*/
|
|
21
17
|
maximumSessions?: number | undefined;
|
|
22
18
|
}
|
|
23
|
-
declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
19
|
+
export declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
24
20
|
id: "multi-session";
|
|
25
21
|
version: string;
|
|
26
22
|
endpoints: {
|
|
@@ -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:
|
|
147
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
152
148
|
session: {
|
|
153
149
|
session: Record<string, any> & {
|
|
154
150
|
id: string;
|
|
@@ -199,14 +195,14 @@ declare const multiSession: (options?: MultiSessionConfig | undefined) => {
|
|
|
199
195
|
};
|
|
200
196
|
hooks: {
|
|
201
197
|
after: {
|
|
202
|
-
matcher: (context:
|
|
203
|
-
handler:
|
|
198
|
+
matcher: (context: import("@better-auth/core").HookEndpointContext) => boolean;
|
|
199
|
+
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (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
|
|
212
|
-
export { MULTI_SESSION_ERROR_CODES as ERROR_CODES
|
|
208
|
+
export { MULTI_SESSION_ERROR_CODES as ERROR_CODES };
|
|
@@ -2,12 +2,10 @@ 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
|
-
interface SignInPopupOptions {
|
|
8
|
+
export interface SignInPopupOptions {
|
|
11
9
|
/** Built-in social provider id (e.g. `"google"`). */
|
|
12
10
|
provider?: string;
|
|
13
11
|
/** Generic OAuth provider id (registered via `genericOAuth`). */
|
|
@@ -23,7 +21,7 @@ interface SignInPopupOptions {
|
|
|
23
21
|
/** How long (ms) to wait for the popup to complete. Default 5 minutes. */
|
|
24
22
|
timeoutMs?: number;
|
|
25
23
|
}
|
|
26
|
-
interface SignInPopupResult {
|
|
24
|
+
export interface SignInPopupResult {
|
|
27
25
|
data: {
|
|
28
26
|
success: boolean;
|
|
29
27
|
} | null;
|
|
@@ -34,12 +32,12 @@ interface SignInPopupResult {
|
|
|
34
32
|
} | null;
|
|
35
33
|
}
|
|
36
34
|
/** Reads the stored popup token (browser-only; null otherwise). */
|
|
37
|
-
declare function getStoredPopupToken(): string | null;
|
|
35
|
+
export declare function getStoredPopupToken(): string | null;
|
|
38
36
|
/**
|
|
39
37
|
* Attaches the popup token as a bearer header when embedded (where the cookie is
|
|
40
38
|
* partitioned), and clears it once the session ends so it can't be reused.
|
|
41
39
|
*/
|
|
42
|
-
declare const popupBearerFetchPlugin: BetterFetchPlugin;
|
|
40
|
+
export declare const popupBearerFetchPlugin: BetterFetchPlugin;
|
|
43
41
|
interface SignInPopupDeps {
|
|
44
42
|
$fetch: BetterFetch;
|
|
45
43
|
options?: BetterAuthClientOptions | undefined;
|
|
@@ -52,24 +50,20 @@ 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
|
+
export 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.
|
|
63
57
|
*/
|
|
64
|
-
declare const oauthPopupClient: () => {
|
|
58
|
+
export declare const oauthPopupClient: () => {
|
|
65
59
|
id: "oauth-popup";
|
|
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 {
|
|
76
|
+
export { OAUTH_POPUP_ERROR_CODES, POPUP_TOKEN_STORAGE_KEY };
|
|
@@ -7,7 +7,7 @@ const POPUP_NAME = "better-auth-oauth";
|
|
|
7
7
|
const POPUP_WIDTH = 500;
|
|
8
8
|
const POPUP_HEIGHT = 600;
|
|
9
9
|
const CLOSED_POLL_MS = 500;
|
|
10
|
-
const DEFAULT_TIMEOUT_MS =
|
|
10
|
+
const DEFAULT_TIMEOUT_MS = 3e5;
|
|
11
11
|
/** True when embedded cross-origin, where the cookie may be partitioned. */
|
|
12
12
|
function isEmbedded() {
|
|
13
13
|
if (typeof window === "undefined" || window.self === window.top) return false;
|
|
@@ -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,10 @@
|
|
|
1
1
|
//#region src/plugins/oauth-popup/constants.d.ts
|
|
2
2
|
/** postMessage `type` the completion page posts to its opener. */
|
|
3
|
-
declare const OAUTH_POPUP_MESSAGE_TYPE = "better-auth:oauth-popup";
|
|
3
|
+
export declare const OAUTH_POPUP_MESSAGE_TYPE = "better-auth:oauth-popup";
|
|
4
4
|
/** DOM id of the inert JSON data block the completion page reads. */
|
|
5
|
-
declare const OAUTH_POPUP_DATA_ELEMENT_ID = "better-auth-oauth-popup";
|
|
5
|
+
export declare const OAUTH_POPUP_DATA_ELEMENT_ID = "better-auth-oauth-popup";
|
|
6
6
|
/** Signed cookie carrying the opener origin/nonce from sign-in to callback. */
|
|
7
|
-
declare const POPUP_MARKER_COOKIE = "oauth_popup";
|
|
7
|
+
export declare const POPUP_MARKER_COOKIE = "oauth_popup";
|
|
8
8
|
/** localStorage key the popup session token is persisted under. */
|
|
9
|
-
declare const POPUP_TOKEN_STORAGE_KEY = "better-auth.popup_token";
|
|
10
|
-
//#endregion
|
|
11
|
-
export { OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_MESSAGE_TYPE, POPUP_MARKER_COOKIE, POPUP_TOKEN_STORAGE_KEY };
|
|
9
|
+
export declare const POPUP_TOKEN_STORAGE_KEY = "better-auth.popup_token";
|
|
10
|
+
//#endregion
|
|
@@ -1,11 +1,8 @@
|
|
|
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
|
-
declare const OAUTH_POPUP_ERROR_CODES: {
|
|
5
|
-
POPUP_SIGN_IN_FAILED:
|
|
6
|
-
POPUP_BLOCKED:
|
|
7
|
-
POPUP_CLOSED:
|
|
8
|
-
POPUP_TIMEOUT:
|
|
2
|
+
export declare const OAUTH_POPUP_ERROR_CODES: {
|
|
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
|
-
//#endregion
|
|
11
|
-
export { OAUTH_POPUP_ERROR_CODES };
|
|
8
|
+
//#endregion
|
|
@@ -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> {
|
|
@@ -17,28 +13,28 @@ declare module "@better-auth/core" {
|
|
|
17
13
|
/**
|
|
18
14
|
* The completion-page script.
|
|
19
15
|
*/
|
|
20
|
-
declare const OAUTH_POPUP_COMPLETE_SCRIPT: string;
|
|
16
|
+
export declare const OAUTH_POPUP_COMPLETE_SCRIPT: string;
|
|
21
17
|
/**
|
|
22
18
|
* sha256 of `OAUTH_POPUP_COMPLETE_SCRIPT`, pinned in the completion CSP.
|
|
23
19
|
*/
|
|
24
|
-
declare const OAUTH_POPUP_SCRIPT_CSP_HASH = "sha256-tIo2K8VBC9SnhvdZ+9GsGkQoZm+jm/JcxL+d+i8b8KQ=";
|
|
20
|
+
export declare const OAUTH_POPUP_SCRIPT_CSP_HASH = "sha256-tIo2K8VBC9SnhvdZ+9GsGkQoZm+jm/JcxL+d+i8b8KQ=";
|
|
25
21
|
/**
|
|
26
22
|
* Server plugin for popup-based OAuth. `signIn.popup` navigates the popup to
|
|
27
23
|
* `/oauth-popup/start`; on the OAuth callback this plugin swaps the redirect for
|
|
28
24
|
* a page that posts the session token (or error) back to the opener. Pair with
|
|
29
25
|
* the `bearer` plugin and `oauthPopupClient`.
|
|
30
26
|
*/
|
|
31
|
-
declare const oauthPopup: () => {
|
|
27
|
+
export 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:
|
|
57
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
58
|
+
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
63
59
|
}[];
|
|
64
60
|
};
|
|
65
61
|
};
|
|
66
62
|
//#endregion
|
|
67
|
-
export {
|
|
63
|
+
export { OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, type OAuthPopupData, type OAuthPopupMessage, POPUP_MARKER_COOKIE };
|
|
@@ -65,15 +65,16 @@ function renderCompletion(c, popupOrigin, message) {
|
|
|
65
65
|
warnedMissingBearer = true;
|
|
66
66
|
c.context.logger.warn("OAuth popup hands the session token back via postMessage, but the `bearer` plugin is not registered, so an embedded (cross-site iframe) app cannot authenticate with it. Add bearer() to your auth `plugins`.");
|
|
67
67
|
}
|
|
68
|
+
const data = {
|
|
69
|
+
type: OAUTH_POPUP_MESSAGE_TYPE,
|
|
70
|
+
targetOrigin: popupOrigin,
|
|
71
|
+
...message
|
|
72
|
+
};
|
|
68
73
|
const html = `<!doctype html>
|
|
69
74
|
<html>
|
|
70
75
|
<head><meta charset="utf-8"><title>Completing sign-in</title></head>
|
|
71
76
|
<body>
|
|
72
|
-
<script type="application/json" id="${OAUTH_POPUP_DATA_ELEMENT_ID}">${inlineJSON(
|
|
73
|
-
type: OAUTH_POPUP_MESSAGE_TYPE,
|
|
74
|
-
targetOrigin: popupOrigin,
|
|
75
|
-
...message
|
|
76
|
-
})}<\/script>
|
|
77
|
+
<script type="application/json" id="${OAUTH_POPUP_DATA_ELEMENT_ID}">${inlineJSON(data)}<\/script>
|
|
77
78
|
<script>${OAUTH_POPUP_COMPLETE_SCRIPT}<\/script>
|
|
78
79
|
</body>
|
|
79
80
|
</html>`;
|
|
@@ -143,7 +144,7 @@ const oauthPopupStart = createAuthEndpoint("/oauth-popup/start", {
|
|
|
143
144
|
errorURL: c.query.errorCallbackURL,
|
|
144
145
|
newUserURL: c.query.newUserCallbackURL,
|
|
145
146
|
requestSignUp: c.query.requestSignUp === "true" ? true : void 0,
|
|
146
|
-
expiresAt: Date.now() +
|
|
147
|
+
expiresAt: Date.now() + 6e5
|
|
147
148
|
};
|
|
148
149
|
await setOAuthState(stateData);
|
|
149
150
|
const { state } = await generateGenericState(c, stateData);
|
|
@@ -229,4 +230,4 @@ const oauthPopup = () => {
|
|
|
229
230
|
};
|
|
230
231
|
};
|
|
231
232
|
//#endregion
|
|
232
|
-
export { OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_SCRIPT_CSP_HASH, oauthPopup };
|
|
233
|
+
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,8 +1,7 @@
|
|
|
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
|
-
interface OAuthPopupError {
|
|
4
|
+
export interface OAuthPopupError {
|
|
6
5
|
code: string;
|
|
7
6
|
description?: string;
|
|
8
7
|
}
|
|
@@ -10,7 +9,7 @@ interface OAuthPopupError {
|
|
|
10
9
|
* Message the completion page posts to its opener — success carries the token,
|
|
11
10
|
* failure carries the error.
|
|
12
11
|
*/
|
|
13
|
-
interface OAuthPopupMessage {
|
|
12
|
+
export interface OAuthPopupMessage {
|
|
14
13
|
type: typeof OAUTH_POPUP_MESSAGE_TYPE;
|
|
15
14
|
/** Echoes the request nonce so the opener can correlate the handoff. */
|
|
16
15
|
nonce: string;
|
|
@@ -22,9 +21,8 @@ interface OAuthPopupMessage {
|
|
|
22
21
|
error?: OAuthPopupError;
|
|
23
22
|
}
|
|
24
23
|
/** Payload embedded in the completion page's data block. */
|
|
25
|
-
interface OAuthPopupData extends OAuthPopupMessage {
|
|
24
|
+
export interface OAuthPopupData extends OAuthPopupMessage {
|
|
26
25
|
/** Exact origin the message is posted to (the trusted popup opener). */
|
|
27
26
|
targetOrigin: string;
|
|
28
27
|
}
|
|
29
|
-
//#endregion
|
|
30
|
-
export { OAuthPopupData, OAuthPopupMessage };
|
|
28
|
+
//#endregion
|
|
@@ -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> {
|
|
@@ -11,7 +8,7 @@ declare module "@better-auth/core" {
|
|
|
11
8
|
};
|
|
12
9
|
}
|
|
13
10
|
}
|
|
14
|
-
interface OAuthProxyOptions {
|
|
11
|
+
export interface OAuthProxyOptions {
|
|
15
12
|
/**
|
|
16
13
|
* The current URL of the application.
|
|
17
14
|
* The plugin will attempt to infer the current URL from your environment
|
|
@@ -52,7 +49,7 @@ interface OAuthProxyOptions {
|
|
|
52
49
|
*/
|
|
53
50
|
secret?: string | SecretConfig | undefined;
|
|
54
51
|
}
|
|
55
|
-
declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
52
|
+
export declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
56
53
|
id: "oauth-proxy";
|
|
57
54
|
version: string;
|
|
58
55
|
options: NoInfer<O>;
|
|
@@ -61,14 +58,14 @@ declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
|
61
58
|
* @deprecated OAuth proxy callbacks now use `/callback/:id/oauth-proxy`.
|
|
62
59
|
* This endpoint will be removed in the next minor release.
|
|
63
60
|
*/
|
|
64
|
-
oAuthProxy:
|
|
61
|
+
oAuthProxy: import("better-call").StrictEndpoint<"/oauth-proxy-callback", {
|
|
65
62
|
method: "GET";
|
|
66
63
|
operationId: string;
|
|
67
64
|
query: z.ZodObject<{
|
|
68
65
|
callbackURL: z.ZodString;
|
|
69
66
|
profile: z.ZodOptional<z.ZodString>;
|
|
70
67
|
}, z.core.$strip>;
|
|
71
|
-
use:
|
|
68
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>[];
|
|
72
69
|
metadata: {
|
|
73
70
|
openapi: {
|
|
74
71
|
operationId: string;
|
|
@@ -101,14 +98,14 @@ declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
|
101
98
|
};
|
|
102
99
|
};
|
|
103
100
|
}, never>;
|
|
104
|
-
oAuthProxyCompletion:
|
|
101
|
+
oAuthProxyCompletion: import("better-call").StrictEndpoint<"/callback/:id/oauth-proxy", {
|
|
105
102
|
method: "GET";
|
|
106
103
|
operationId: string;
|
|
107
104
|
query: z.ZodObject<{
|
|
108
105
|
callbackURL: z.ZodString;
|
|
109
106
|
profile: z.ZodOptional<z.ZodString>;
|
|
110
107
|
}, z.core.$strip>;
|
|
111
|
-
use:
|
|
108
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>[];
|
|
112
109
|
metadata: {
|
|
113
110
|
scope: "http";
|
|
114
111
|
};
|
|
@@ -116,14 +113,13 @@ declare const oAuthProxy: <O extends OAuthProxyOptions>(opts?: O) => {
|
|
|
116
113
|
};
|
|
117
114
|
hooks: {
|
|
118
115
|
before: {
|
|
119
|
-
matcher(context:
|
|
120
|
-
handler:
|
|
116
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
117
|
+
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
121
118
|
}[];
|
|
122
119
|
after: {
|
|
123
|
-
matcher(context:
|
|
124
|
-
handler:
|
|
120
|
+
matcher(context: import("@better-auth/core").HookEndpointContext): boolean;
|
|
121
|
+
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
125
122
|
}[];
|
|
126
123
|
};
|
|
127
124
|
};
|
|
128
|
-
//#endregion
|
|
129
|
-
export { OAuthProxyOptions, oAuthProxy };
|
|
125
|
+
//#endregion
|
|
@@ -14,7 +14,7 @@ import { PACKAGE_VERSION } from "../../version.mjs";
|
|
|
14
14
|
import { parseJSON } from "../../client/parser.mjs";
|
|
15
15
|
import { checkSkipProxy, resolveCurrentURL, stripTrailingSlash } from "./utils.mjs";
|
|
16
16
|
import { accountSchema, userSchema } from "@better-auth/core/db";
|
|
17
|
-
import { defu } from "defu";
|
|
17
|
+
import { defu as defu$1 } from "defu";
|
|
18
18
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
19
19
|
import * as z from "zod";
|
|
20
20
|
//#region src/plugins/oauth-proxy/index.ts
|
|
@@ -220,15 +220,16 @@ const oAuthProxy = (opts) => {
|
|
|
220
220
|
return context.path === "/callback/:id";
|
|
221
221
|
},
|
|
222
222
|
handler: createAuthMiddleware(async (ctx) => {
|
|
223
|
-
const callbackParams = defu(ctx.query, ctx.body);
|
|
223
|
+
const callbackParams = defu$1(ctx.query, ctx.body);
|
|
224
224
|
const state = callbackParams.state;
|
|
225
225
|
if (!state || typeof state !== "string") return;
|
|
226
226
|
let statePackage;
|
|
227
227
|
try {
|
|
228
|
-
|
|
228
|
+
const decryptedPackage = await symmetricDecrypt({
|
|
229
229
|
key: getEncryptionKey(ctx, "oauth-proxy-package"),
|
|
230
230
|
data: state
|
|
231
|
-
})
|
|
231
|
+
});
|
|
232
|
+
statePackage = parseJSON(decryptedPackage);
|
|
232
233
|
} catch {
|
|
233
234
|
ctx.context.logger.debug("OAuth proxy: could not decrypt state package, falling back to regular callback");
|
|
234
235
|
return;
|
|
@@ -245,10 +246,11 @@ const oAuthProxy = (opts) => {
|
|
|
245
246
|
const { code, error, user: userData, iss, device_id: deviceId } = query.data;
|
|
246
247
|
let stateData;
|
|
247
248
|
try {
|
|
248
|
-
|
|
249
|
+
const decryptedState = await symmetricDecrypt({
|
|
249
250
|
key: getEncryptionKey(ctx, "oauth-proxy-state"),
|
|
250
251
|
data: statePackage.stateCookie
|
|
251
|
-
})
|
|
252
|
+
});
|
|
253
|
+
stateData = parseJSON(decryptedState);
|
|
252
254
|
} catch (e) {
|
|
253
255
|
ctx.context.logger.error("Failed to decrypt OAuth proxy state cookie:", e);
|
|
254
256
|
return;
|
|
@@ -377,7 +379,8 @@ const oAuthProxy = (opts) => {
|
|
|
377
379
|
handler: createAuthMiddleware(async (ctx) => {
|
|
378
380
|
const location = ctx.context.responseHeaders?.get("location");
|
|
379
381
|
if (!location?.includes("/oauth-proxy?callbackURL") && !location?.includes("/oauth-proxy-callback?callbackURL") || !location.startsWith("http")) return;
|
|
380
|
-
const
|
|
382
|
+
const productionURL = opts?.productionURL || (typeof ctx.context.options.baseURL === "string" ? ctx.context.options.baseURL : void 0) || ctx.context.baseURL;
|
|
383
|
+
const productionOrigin = getOrigin(productionURL);
|
|
381
384
|
const locationURL = new URL(location);
|
|
382
385
|
if (locationURL.origin === productionOrigin) {
|
|
383
386
|
const newLocation = locationURL.searchParams.get("callbackURL");
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { BetterAuthClientOptions, ClientFetchOption, ClientStore } from "@better-auth/core";
|
|
2
|
-
import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
|
|
3
2
|
import { BetterFetch } from "@better-fetch/fetch";
|
|
4
|
-
|
|
5
3
|
//#region src/plugins/one-tap/client.d.ts
|
|
6
4
|
declare global {
|
|
7
5
|
interface Window {
|
|
8
6
|
googleScriptInitialized?: boolean | undefined;
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
|
-
interface GsiButtonConfiguration {
|
|
9
|
+
export interface GsiButtonConfiguration {
|
|
12
10
|
/**
|
|
13
11
|
* The button type: icon, or standard button.
|
|
14
12
|
*/
|
|
@@ -69,7 +67,7 @@ interface GsiButtonConfiguration {
|
|
|
69
67
|
*/
|
|
70
68
|
state?: string;
|
|
71
69
|
}
|
|
72
|
-
interface GoogleOneTapOptions {
|
|
70
|
+
export interface GoogleOneTapOptions {
|
|
73
71
|
/**
|
|
74
72
|
* Google client ID
|
|
75
73
|
*/
|
|
@@ -129,7 +127,7 @@ interface GoogleOneTapOptions {
|
|
|
129
127
|
fedCM?: boolean | undefined;
|
|
130
128
|
} | undefined;
|
|
131
129
|
}
|
|
132
|
-
interface GoogleOneTapActionOptions extends Omit<GoogleOneTapOptions, "clientId" | "promptOptions"> {
|
|
130
|
+
export interface GoogleOneTapActionOptions extends Omit<GoogleOneTapOptions, "clientId" | "promptOptions"> {
|
|
133
131
|
fetchOptions?: ClientFetchOption | undefined;
|
|
134
132
|
/**
|
|
135
133
|
* Callback URL.
|
|
@@ -157,14 +155,14 @@ interface GoogleOneTapActionOptions extends Omit<GoogleOneTapOptions, "clientId"
|
|
|
157
155
|
config?: GsiButtonConfiguration | undefined;
|
|
158
156
|
} | undefined;
|
|
159
157
|
}
|
|
160
|
-
declare const oneTapClient: (options: GoogleOneTapOptions) => {
|
|
158
|
+
export declare const oneTapClient: (options: GoogleOneTapOptions) => {
|
|
161
159
|
id: "one-tap";
|
|
162
160
|
version: string;
|
|
163
161
|
fetchPlugins: {
|
|
164
162
|
id: string;
|
|
165
163
|
name: string;
|
|
166
164
|
hooks: {
|
|
167
|
-
onResponse(ctx:
|
|
165
|
+
onResponse(ctx: import("@better-fetch/fetch").ResponseContext): Promise<void>;
|
|
168
166
|
};
|
|
169
167
|
}[];
|
|
170
168
|
getActions: ($fetch: BetterFetch, _$store: ClientStore, _options: BetterAuthClientOptions | undefined) => {
|
|
@@ -172,5 +170,4 @@ declare const oneTapClient: (options: GoogleOneTapOptions) => {
|
|
|
172
170
|
};
|
|
173
171
|
getAtoms($fetch: BetterFetch): {};
|
|
174
172
|
};
|
|
175
|
-
//#endregion
|
|
176
|
-
export { GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, oneTapClient };
|
|
173
|
+
//#endregion
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import * as _$better_call0 from "better-call";
|
|
2
1
|
import * as z from "zod";
|
|
3
|
-
|
|
4
2
|
//#region src/plugins/one-tap/index.d.ts
|
|
5
3
|
declare module "@better-auth/core" {
|
|
6
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -9,7 +7,7 @@ declare module "@better-auth/core" {
|
|
|
9
7
|
};
|
|
10
8
|
}
|
|
11
9
|
}
|
|
12
|
-
interface OneTapOptions {
|
|
10
|
+
export interface OneTapOptions {
|
|
13
11
|
/**
|
|
14
12
|
* Disable the signup flow
|
|
15
13
|
*
|
|
@@ -24,11 +22,11 @@ interface OneTapOptions {
|
|
|
24
22
|
*/
|
|
25
23
|
clientId?: string | undefined;
|
|
26
24
|
}
|
|
27
|
-
declare const oneTap: (options?: OneTapOptions | undefined) => {
|
|
25
|
+
export declare const oneTap: (options?: OneTapOptions | undefined) => {
|
|
28
26
|
id: "one-tap";
|
|
29
27
|
version: string;
|
|
30
28
|
endpoints: {
|
|
31
|
-
oneTapCallback:
|
|
29
|
+
oneTapCallback: import("better-call").StrictEndpoint<"/one-tap/callback", {
|
|
32
30
|
method: "POST";
|
|
33
31
|
body: z.ZodObject<{
|
|
34
32
|
idToken: z.ZodString;
|
|
@@ -78,5 +76,4 @@ declare const oneTap: (options?: OneTapOptions | undefined) => {
|
|
|
78
76
|
};
|
|
79
77
|
options: OneTapOptions | undefined;
|
|
80
78
|
};
|
|
81
|
-
//#endregion
|
|
82
|
-
export { OneTapOptions, oneTap };
|
|
79
|
+
//#endregion
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { OneTimeTokenOptions, oneTimeToken } from "./index.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/plugins/one-time-token/client.d.ts
|
|
4
|
-
declare const oneTimeTokenClient: () => {
|
|
3
|
+
export declare const oneTimeTokenClient: () => {
|
|
5
4
|
id: "one-time-token";
|
|
6
5
|
version: string;
|
|
7
6
|
$InferServerPlugin: ReturnType<typeof oneTimeToken>;
|
|
8
7
|
};
|
|
9
8
|
//#endregion
|
|
10
|
-
export {
|
|
9
|
+
export type { OneTimeTokenOptions };
|