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,11 +1,12 @@
|
|
|
1
1
|
import { Session as Session$1, User as User$1 } from "../../types/models.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
import { AccessControl, Role } from "../access/types.mjs";
|
|
4
|
+
import "../access/index.mjs";
|
|
3
5
|
import { Invitation, Member, Organization, OrganizationRole, Team, TeamMember } from "./schema.mjs";
|
|
4
6
|
import { AuthContext, Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
5
7
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
6
|
-
|
|
7
8
|
//#region src/plugins/organization/types.d.ts
|
|
8
|
-
interface OrganizationOptions {
|
|
9
|
+
export interface OrganizationOptions {
|
|
9
10
|
/**
|
|
10
11
|
* Configure whether new users are able to create new organizations.
|
|
11
12
|
* You can also pass a function that returns a boolean.
|
|
@@ -59,7 +60,7 @@ interface OrganizationOptions {
|
|
|
59
60
|
/**
|
|
60
61
|
* Custom permissions for roles.
|
|
61
62
|
*/
|
|
62
|
-
roles?: { [key in string]?: Role<any
|
|
63
|
+
roles?: { [key in string]?: Role<any>; } | undefined;
|
|
63
64
|
/**
|
|
64
65
|
* Dynamic access control for the organization plugin.
|
|
65
66
|
*/
|
|
@@ -242,7 +243,6 @@ interface OrganizationOptions {
|
|
|
242
243
|
/**
|
|
243
244
|
* The request object
|
|
244
245
|
*/
|
|
245
|
-
|
|
246
246
|
request?: Request) => Promise<void>) | undefined;
|
|
247
247
|
/**
|
|
248
248
|
* The schema for the organization plugin.
|
|
@@ -256,32 +256,32 @@ interface OrganizationOptions {
|
|
|
256
256
|
};
|
|
257
257
|
organization?: {
|
|
258
258
|
modelName?: string;
|
|
259
|
-
fields?: { [key in keyof Omit<Organization, "id">]?: string };
|
|
260
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
259
|
+
fields?: { [key in keyof Omit<Organization, "id">]?: string; };
|
|
260
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
261
261
|
};
|
|
262
262
|
member?: {
|
|
263
263
|
modelName?: string;
|
|
264
|
-
fields?: { [key in keyof Omit<Member, "id">]?: string };
|
|
265
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
264
|
+
fields?: { [key in keyof Omit<Member, "id">]?: string; };
|
|
265
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
266
266
|
};
|
|
267
267
|
invitation?: {
|
|
268
268
|
modelName?: string;
|
|
269
|
-
fields?: { [key in keyof Omit<Invitation, "id">]?: string };
|
|
270
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
269
|
+
fields?: { [key in keyof Omit<Invitation, "id">]?: string; };
|
|
270
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
271
271
|
};
|
|
272
272
|
team?: {
|
|
273
273
|
modelName?: string;
|
|
274
|
-
fields?: { [key in keyof Omit<Team, "id"> | "memberCount"]?: string };
|
|
275
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
274
|
+
fields?: { [key in keyof Omit<Team, "id"> | "memberCount"]?: string; };
|
|
275
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
276
276
|
};
|
|
277
277
|
teamMember?: {
|
|
278
278
|
modelName?: string;
|
|
279
|
-
fields?: { [key in keyof Omit<TeamMember, "id"> | "membershipKey"]?: string };
|
|
279
|
+
fields?: { [key in keyof Omit<TeamMember, "id"> | "membershipKey"]?: string; };
|
|
280
280
|
};
|
|
281
281
|
organizationRole?: {
|
|
282
282
|
modelName?: string;
|
|
283
|
-
fields?: { [key in keyof Omit<OrganizationRole, "id">]?: string };
|
|
284
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
283
|
+
fields?: { [key in keyof Omit<OrganizationRole, "id">]?: string; };
|
|
284
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
285
285
|
};
|
|
286
286
|
} | undefined;
|
|
287
287
|
/**
|
|
@@ -687,5 +687,4 @@ interface OrganizationOptions {
|
|
|
687
687
|
}) => Promise<void>;
|
|
688
688
|
} | undefined;
|
|
689
689
|
}
|
|
690
|
-
//#endregion
|
|
691
|
-
export { OrganizationOptions };
|
|
690
|
+
//#endregion
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { PhoneNumberOptions, UserWithPhoneNumber } from "./types.mjs";
|
|
2
2
|
import { phoneNumber } from "./index.mjs";
|
|
3
3
|
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes.mjs";
|
|
4
|
-
import * as _$_better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
5
|
-
|
|
6
4
|
//#region src/plugins/phone-number/client.d.ts
|
|
7
|
-
declare const phoneNumberClient: () => {
|
|
5
|
+
export declare const phoneNumberClient: () => {
|
|
8
6
|
id: "phoneNumber";
|
|
9
7
|
version: string;
|
|
10
8
|
$InferServerPlugin: ReturnType<typeof phoneNumber>;
|
|
@@ -13,19 +11,19 @@ declare const phoneNumberClient: () => {
|
|
|
13
11
|
signal: "$sessionSignal";
|
|
14
12
|
}[];
|
|
15
13
|
$ERROR_CODES: {
|
|
16
|
-
OTP_EXPIRED:
|
|
17
|
-
INVALID_OTP:
|
|
18
|
-
TOO_MANY_ATTEMPTS:
|
|
19
|
-
INVALID_PHONE_NUMBER:
|
|
20
|
-
PHONE_NUMBER_EXIST:
|
|
21
|
-
PHONE_NUMBER_NOT_EXIST:
|
|
22
|
-
INVALID_PHONE_NUMBER_OR_PASSWORD:
|
|
23
|
-
UNEXPECTED_ERROR:
|
|
24
|
-
OTP_NOT_FOUND:
|
|
25
|
-
PHONE_NUMBER_NOT_VERIFIED:
|
|
26
|
-
PHONE_NUMBER_CANNOT_BE_UPDATED:
|
|
27
|
-
SEND_OTP_NOT_IMPLEMENTED:
|
|
14
|
+
OTP_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
15
|
+
INVALID_OTP: import("@better-auth/core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
16
|
+
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
17
|
+
INVALID_PHONE_NUMBER: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
18
|
+
PHONE_NUMBER_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
19
|
+
PHONE_NUMBER_NOT_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
20
|
+
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
21
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
22
|
+
OTP_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
23
|
+
PHONE_NUMBER_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_VERIFIED">;
|
|
24
|
+
PHONE_NUMBER_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_CANNOT_BE_UPDATED">;
|
|
25
|
+
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
28
26
|
};
|
|
29
27
|
};
|
|
30
28
|
//#endregion
|
|
31
|
-
export {
|
|
29
|
+
export { PHONE_NUMBER_ERROR_CODES, type PhoneNumberOptions, type UserWithPhoneNumber };
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import * as _$_better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
2
|
-
|
|
3
1
|
//#region src/plugins/phone-number/error-codes.d.ts
|
|
4
|
-
declare const PHONE_NUMBER_ERROR_CODES: {
|
|
5
|
-
OTP_EXPIRED:
|
|
6
|
-
INVALID_OTP:
|
|
7
|
-
TOO_MANY_ATTEMPTS:
|
|
8
|
-
INVALID_PHONE_NUMBER:
|
|
9
|
-
PHONE_NUMBER_EXIST:
|
|
10
|
-
PHONE_NUMBER_NOT_EXIST:
|
|
11
|
-
INVALID_PHONE_NUMBER_OR_PASSWORD:
|
|
12
|
-
UNEXPECTED_ERROR:
|
|
13
|
-
OTP_NOT_FOUND:
|
|
14
|
-
PHONE_NUMBER_NOT_VERIFIED:
|
|
15
|
-
PHONE_NUMBER_CANNOT_BE_UPDATED:
|
|
16
|
-
SEND_OTP_NOT_IMPLEMENTED:
|
|
2
|
+
export declare const PHONE_NUMBER_ERROR_CODES: {
|
|
3
|
+
OTP_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
4
|
+
INVALID_OTP: import("@better-auth/core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
5
|
+
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
6
|
+
INVALID_PHONE_NUMBER: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
7
|
+
PHONE_NUMBER_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
8
|
+
PHONE_NUMBER_NOT_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
9
|
+
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
10
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
11
|
+
OTP_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
12
|
+
PHONE_NUMBER_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_VERIFIED">;
|
|
13
|
+
PHONE_NUMBER_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_CANNOT_BE_UPDATED">;
|
|
14
|
+
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
17
15
|
};
|
|
18
|
-
//#endregion
|
|
19
|
-
export { PHONE_NUMBER_ERROR_CODES };
|
|
16
|
+
//#endregion
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { PhoneNumberOptions, UserWithPhoneNumber } from "./types.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
|
-
import * as _$zod from "zod";
|
|
6
|
-
import * as _$zod_v4_core0 from "zod/v4/core";
|
|
7
|
-
|
|
8
2
|
//#region src/plugins/phone-number/index.d.ts
|
|
9
3
|
declare module "@better-auth/core" {
|
|
10
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -13,7 +7,7 @@ declare module "@better-auth/core" {
|
|
|
13
7
|
};
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
|
-
declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
10
|
+
export declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
17
11
|
id: "phone-number";
|
|
18
12
|
version: string;
|
|
19
13
|
init(): {
|
|
@@ -48,18 +42,18 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
48
42
|
};
|
|
49
43
|
hooks: {
|
|
50
44
|
before: {
|
|
51
|
-
matcher: (ctx:
|
|
52
|
-
handler:
|
|
45
|
+
matcher: (ctx: import("@better-auth/core").HookEndpointContext) => boolean;
|
|
46
|
+
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<never>>;
|
|
53
47
|
}[];
|
|
54
48
|
};
|
|
55
49
|
endpoints: {
|
|
56
|
-
signInPhoneNumber:
|
|
50
|
+
signInPhoneNumber: import("better-call").StrictEndpoint<"/sign-in/phone-number", {
|
|
57
51
|
method: "POST";
|
|
58
|
-
body:
|
|
59
|
-
phoneNumber:
|
|
60
|
-
password:
|
|
61
|
-
rememberMe:
|
|
62
|
-
},
|
|
52
|
+
body: import("zod").ZodObject<{
|
|
53
|
+
phoneNumber: import("zod").ZodString;
|
|
54
|
+
password: import("zod").ZodString;
|
|
55
|
+
rememberMe: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
56
|
+
}, import("zod/v4/core").$strip>;
|
|
63
57
|
metadata: {
|
|
64
58
|
openapi: {
|
|
65
59
|
summary: string;
|
|
@@ -93,11 +87,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
93
87
|
token: string;
|
|
94
88
|
user: UserWithPhoneNumber;
|
|
95
89
|
}>;
|
|
96
|
-
sendPhoneNumberOTP:
|
|
90
|
+
sendPhoneNumberOTP: import("better-call").StrictEndpoint<"/phone-number/send-otp", {
|
|
97
91
|
method: "POST";
|
|
98
|
-
body:
|
|
99
|
-
phoneNumber:
|
|
100
|
-
},
|
|
92
|
+
body: import("zod").ZodObject<{
|
|
93
|
+
phoneNumber: import("zod").ZodString;
|
|
94
|
+
}, import("zod/v4/core").$strip>;
|
|
101
95
|
metadata: {
|
|
102
96
|
openapi: {
|
|
103
97
|
summary: string;
|
|
@@ -124,26 +118,26 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
124
118
|
}, {
|
|
125
119
|
message: string;
|
|
126
120
|
}>;
|
|
127
|
-
consumePhoneNumberOTP:
|
|
121
|
+
consumePhoneNumberOTP: import("better-call").StrictEndpoint<string, {
|
|
128
122
|
method: "POST";
|
|
129
|
-
body:
|
|
130
|
-
phoneNumber:
|
|
131
|
-
code:
|
|
132
|
-
},
|
|
123
|
+
body: import("zod").ZodObject<{
|
|
124
|
+
phoneNumber: import("zod").ZodString;
|
|
125
|
+
code: import("zod").ZodString;
|
|
126
|
+
}, import("zod/v4/core").$strip>;
|
|
133
127
|
metadata: {
|
|
134
128
|
readonly scope: "server";
|
|
135
129
|
};
|
|
136
130
|
}, {
|
|
137
131
|
status: boolean;
|
|
138
132
|
}>;
|
|
139
|
-
verifyPhoneNumber:
|
|
133
|
+
verifyPhoneNumber: import("better-call").StrictEndpoint<"/phone-number/verify", {
|
|
140
134
|
method: "POST";
|
|
141
|
-
body:
|
|
142
|
-
phoneNumber:
|
|
143
|
-
code:
|
|
144
|
-
disableSession:
|
|
145
|
-
updatePhoneNumber:
|
|
146
|
-
},
|
|
135
|
+
body: import("zod").ZodIntersection<import("zod").ZodObject<{
|
|
136
|
+
phoneNumber: import("zod").ZodString;
|
|
137
|
+
code: import("zod").ZodString;
|
|
138
|
+
disableSession: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
139
|
+
updatePhoneNumber: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
140
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
147
141
|
metadata: {
|
|
148
142
|
openapi: {
|
|
149
143
|
summary: string;
|
|
@@ -247,11 +241,11 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
247
241
|
token: null;
|
|
248
242
|
user: UserWithPhoneNumber;
|
|
249
243
|
}>;
|
|
250
|
-
requestPasswordResetPhoneNumber:
|
|
244
|
+
requestPasswordResetPhoneNumber: import("better-call").StrictEndpoint<"/phone-number/request-password-reset", {
|
|
251
245
|
method: "POST";
|
|
252
|
-
body:
|
|
253
|
-
phoneNumber:
|
|
254
|
-
},
|
|
246
|
+
body: import("zod").ZodObject<{
|
|
247
|
+
phoneNumber: import("zod").ZodString;
|
|
248
|
+
}, import("zod/v4/core").$strip>;
|
|
255
249
|
metadata: {
|
|
256
250
|
openapi: {
|
|
257
251
|
description: string;
|
|
@@ -280,13 +274,13 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
280
274
|
}, {
|
|
281
275
|
status: boolean;
|
|
282
276
|
}>;
|
|
283
|
-
resetPasswordPhoneNumber:
|
|
277
|
+
resetPasswordPhoneNumber: import("better-call").StrictEndpoint<"/phone-number/reset-password", {
|
|
284
278
|
method: "POST";
|
|
285
|
-
body:
|
|
286
|
-
otp:
|
|
287
|
-
phoneNumber:
|
|
288
|
-
newPassword:
|
|
289
|
-
},
|
|
279
|
+
body: import("zod").ZodObject<{
|
|
280
|
+
otp: import("zod").ZodString;
|
|
281
|
+
phoneNumber: import("zod").ZodString;
|
|
282
|
+
newPassword: import("zod").ZodString;
|
|
283
|
+
}, import("zod/v4/core").$strip>;
|
|
290
284
|
metadata: {
|
|
291
285
|
openapi: {
|
|
292
286
|
description: string;
|
|
@@ -342,19 +336,19 @@ declare const phoneNumber: (options?: PhoneNumberOptions | undefined) => {
|
|
|
342
336
|
}[];
|
|
343
337
|
options: PhoneNumberOptions | undefined;
|
|
344
338
|
$ERROR_CODES: {
|
|
345
|
-
OTP_EXPIRED:
|
|
346
|
-
INVALID_OTP:
|
|
347
|
-
TOO_MANY_ATTEMPTS:
|
|
348
|
-
INVALID_PHONE_NUMBER:
|
|
349
|
-
PHONE_NUMBER_EXIST:
|
|
350
|
-
PHONE_NUMBER_NOT_EXIST:
|
|
351
|
-
INVALID_PHONE_NUMBER_OR_PASSWORD:
|
|
352
|
-
UNEXPECTED_ERROR:
|
|
353
|
-
OTP_NOT_FOUND:
|
|
354
|
-
PHONE_NUMBER_NOT_VERIFIED:
|
|
355
|
-
PHONE_NUMBER_CANNOT_BE_UPDATED:
|
|
356
|
-
SEND_OTP_NOT_IMPLEMENTED:
|
|
339
|
+
OTP_EXPIRED: import("@better-auth/core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
340
|
+
INVALID_OTP: import("@better-auth/core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
341
|
+
TOO_MANY_ATTEMPTS: import("@better-auth/core/utils/error-codes").RawError<"TOO_MANY_ATTEMPTS">;
|
|
342
|
+
INVALID_PHONE_NUMBER: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
343
|
+
PHONE_NUMBER_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
344
|
+
PHONE_NUMBER_NOT_EXIST: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
345
|
+
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@better-auth/core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
346
|
+
UNEXPECTED_ERROR: import("@better-auth/core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
347
|
+
OTP_NOT_FOUND: import("@better-auth/core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
348
|
+
PHONE_NUMBER_NOT_VERIFIED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_VERIFIED">;
|
|
349
|
+
PHONE_NUMBER_CANNOT_BE_UPDATED: import("@better-auth/core/utils/error-codes").RawError<"PHONE_NUMBER_CANNOT_BE_UPDATED">;
|
|
350
|
+
SEND_OTP_NOT_IMPLEMENTED: import("@better-auth/core/utils/error-codes").RawError<"SEND_OTP_NOT_IMPLEMENTED">;
|
|
357
351
|
};
|
|
358
352
|
};
|
|
359
353
|
//#endregion
|
|
360
|
-
export {
|
|
354
|
+
export type { PhoneNumberOptions, UserWithPhoneNumber };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/plugins/phone-number/schema.d.ts
|
|
2
|
-
declare const schema: {
|
|
2
|
+
export declare const schema: {
|
|
3
3
|
user: {
|
|
4
4
|
fields: {
|
|
5
5
|
phoneNumber: {
|
|
@@ -18,5 +18,4 @@ declare const schema: {
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
|
-
export { schema };
|
|
21
|
+
//#endregion
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
2
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
|
+
import "../../types/index.mjs";
|
|
3
4
|
import { schema } from "./schema.mjs";
|
|
4
5
|
import { Awaitable, GenericEndpointContext } from "@better-auth/core";
|
|
5
|
-
|
|
6
6
|
//#region src/plugins/phone-number/types.d.ts
|
|
7
|
-
interface UserWithPhoneNumber extends User {
|
|
7
|
+
export interface UserWithPhoneNumber extends User {
|
|
8
8
|
phoneNumber: string;
|
|
9
9
|
phoneNumberVerified: boolean;
|
|
10
10
|
}
|
|
11
|
-
interface PhoneNumberOptions {
|
|
11
|
+
export interface PhoneNumberOptions {
|
|
12
12
|
/**
|
|
13
13
|
* Length of the OTP code
|
|
14
14
|
* @default 6
|
|
@@ -112,5 +112,4 @@ interface PhoneNumberOptions {
|
|
|
112
112
|
*/
|
|
113
113
|
allowedAttempts?: number | undefined;
|
|
114
114
|
}
|
|
115
|
-
//#endregion
|
|
116
|
-
export { PhoneNumberOptions, UserWithPhoneNumber };
|
|
115
|
+
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { siwe } from "./index.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/plugins/siwe/client.d.ts
|
|
4
|
-
declare const siweClient: () => {
|
|
3
|
+
export declare const siweClient: () => {
|
|
5
4
|
id: "siwe";
|
|
6
5
|
version: string;
|
|
7
6
|
$InferServerPlugin: ReturnType<typeof siwe>;
|
|
@@ -10,5 +9,4 @@ declare const siweClient: () => {
|
|
|
10
9
|
"/siwe/get-nonce": "POST";
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { siweClient };
|
|
12
|
+
//#endregion
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
import { WalletAddressSchema, schema } from "./schema.mjs";
|
|
3
4
|
import { ENSLookupArgs, ENSLookupResult, SIWEVerifyMessageArgs } from "./types.mjs";
|
|
4
|
-
import * as _$better_call0 from "better-call";
|
|
5
5
|
import * as z from "zod";
|
|
6
|
-
|
|
7
6
|
//#region src/plugins/siwe/index.d.ts
|
|
8
7
|
declare module "@better-auth/core" {
|
|
9
8
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -12,7 +11,7 @@ declare module "@better-auth/core" {
|
|
|
12
11
|
};
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
|
-
interface SIWEPluginOptions {
|
|
14
|
+
export interface SIWEPluginOptions {
|
|
16
15
|
domain: string;
|
|
17
16
|
emailDomainName?: string | undefined;
|
|
18
17
|
anonymous?: boolean | undefined;
|
|
@@ -21,24 +20,24 @@ interface SIWEPluginOptions {
|
|
|
21
20
|
ensLookup?: ((args: ENSLookupArgs) => Promise<ENSLookupResult>) | undefined;
|
|
22
21
|
schema?: InferOptionSchema<typeof schema> | undefined;
|
|
23
22
|
}
|
|
24
|
-
declare const siwe: (options: SIWEPluginOptions) => {
|
|
23
|
+
export declare const siwe: (options: SIWEPluginOptions) => {
|
|
25
24
|
id: "siwe";
|
|
26
25
|
version: string;
|
|
27
26
|
schema: WalletAddressSchema;
|
|
28
27
|
endpoints: {
|
|
29
|
-
getSiweNonce:
|
|
28
|
+
getSiweNonce: import("better-call").StrictEndpoint<"/siwe/nonce" | "/siwe/get-nonce", {
|
|
30
29
|
method: "POST";
|
|
31
30
|
body: z.ZodOptional<z.ZodObject<{}, z.core.$strict>>;
|
|
32
31
|
}, {
|
|
33
32
|
nonce: string;
|
|
34
33
|
}>;
|
|
35
|
-
getNonce:
|
|
34
|
+
getNonce: import("better-call").StrictEndpoint<"/siwe/nonce" | "/siwe/get-nonce", {
|
|
36
35
|
method: "POST";
|
|
37
36
|
body: z.ZodOptional<z.ZodObject<{}, z.core.$strict>>;
|
|
38
37
|
}, {
|
|
39
38
|
nonce: string;
|
|
40
39
|
}>;
|
|
41
|
-
verifySiweMessage:
|
|
40
|
+
verifySiweMessage: import("better-call").StrictEndpoint<"/siwe/verify", {
|
|
42
41
|
method: "POST";
|
|
43
42
|
body: z.ZodObject<{
|
|
44
43
|
message: z.ZodString;
|
|
@@ -58,5 +57,4 @@ declare const siwe: (options: SIWEPluginOptions) => {
|
|
|
58
57
|
};
|
|
59
58
|
options: SIWEPluginOptions;
|
|
60
59
|
};
|
|
61
|
-
//#endregion
|
|
62
|
-
export { SIWEPluginOptions, siwe };
|
|
60
|
+
//#endregion
|
|
@@ -30,7 +30,7 @@ const siwe = (options) => {
|
|
|
30
30
|
await ctx.context.internalAdapter.createVerificationValue({
|
|
31
31
|
identifier: `${SIWE_VERIFICATION_IDENTIFIER_PREFIX}${nonce}`,
|
|
32
32
|
value: nonce,
|
|
33
|
-
expiresAt: new Date(Date.now() +
|
|
33
|
+
expiresAt: new Date(Date.now() + 9e5)
|
|
34
34
|
});
|
|
35
35
|
return ctx.json({ nonce });
|
|
36
36
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/plugins/siwe/schema.d.ts
|
|
2
|
-
declare const schema: {
|
|
2
|
+
export declare const schema: {
|
|
3
3
|
walletAddress: {
|
|
4
4
|
fields: {
|
|
5
5
|
userId: {
|
|
@@ -30,6 +30,5 @@ declare const schema: {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
type WalletAddressSchema = typeof schema;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { WalletAddressSchema, schema };
|
|
33
|
+
export type WalletAddressSchema = typeof schema;
|
|
34
|
+
//#endregion
|
|
@@ -25,19 +25,19 @@ interface Cacao {
|
|
|
25
25
|
m?: string | undefined;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
interface SIWEVerifyMessageArgs {
|
|
28
|
+
export interface SIWEVerifyMessageArgs {
|
|
29
29
|
message: string;
|
|
30
30
|
signature: string;
|
|
31
31
|
address: string;
|
|
32
32
|
chainId: number;
|
|
33
33
|
cacao?: Cacao | undefined;
|
|
34
34
|
}
|
|
35
|
-
interface ENSLookupArgs {
|
|
35
|
+
export interface ENSLookupArgs {
|
|
36
36
|
walletAddress: string;
|
|
37
37
|
}
|
|
38
|
-
interface ENSLookupResult {
|
|
38
|
+
export interface ENSLookupResult {
|
|
39
39
|
name: string;
|
|
40
40
|
avatar: string;
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
|
-
export {
|
|
43
|
+
export {};
|
|
@@ -21,12 +21,14 @@ function createLogin(ctx) {
|
|
|
21
21
|
}
|
|
22
22
|
function createGetAuthHeaders(ctx) {
|
|
23
23
|
return async (opts) => {
|
|
24
|
-
|
|
24
|
+
const session = await createSession(ctx, opts);
|
|
25
|
+
return createCookieHeaders(ctx, session.token);
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
function createGetCookies(ctx) {
|
|
28
29
|
return async (opts) => {
|
|
29
|
-
|
|
30
|
+
const session = await createSession(ctx, opts);
|
|
31
|
+
return createTestCookie(ctx, session.token, opts.domain);
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
//#endregion
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions } from "./types.mjs";
|
|
2
|
-
import * as _$_better_auth_core0 from "@better-auth/core";
|
|
3
|
-
|
|
4
2
|
//#region src/plugins/test-utils/index.d.ts
|
|
5
3
|
declare module "@better-auth/core" {
|
|
6
4
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
@@ -47,10 +45,10 @@ declare module "@better-auth/core" {
|
|
|
47
45
|
* const { headers, cookies } = await test.login({ userId: user.id });
|
|
48
46
|
* ```
|
|
49
47
|
*/
|
|
50
|
-
declare const testUtils: (options?: TestUtilsOptions) => {
|
|
48
|
+
export declare const testUtils: (options?: TestUtilsOptions) => {
|
|
51
49
|
id: "test-utils";
|
|
52
50
|
version: string;
|
|
53
|
-
init(ctx:
|
|
51
|
+
init(ctx: import("@better-auth/core").AuthContext): {
|
|
54
52
|
context: {
|
|
55
53
|
test: TestHelpers;
|
|
56
54
|
};
|
|
@@ -70,4 +68,4 @@ declare const testUtils: (options?: TestUtilsOptions) => {
|
|
|
70
68
|
options: TestUtilsOptions;
|
|
71
69
|
};
|
|
72
70
|
//#endregion
|
|
73
|
-
export {
|
|
71
|
+
export type { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Session, User } from "../../types/models.mjs";
|
|
2
|
+
import "../../types/index.mjs";
|
|
2
3
|
//#region src/plugins/test-utils/types.d.ts
|
|
3
|
-
interface TestUtilsOptions {
|
|
4
|
+
export interface TestUtilsOptions {
|
|
4
5
|
/** Capture OTPs in memory when created (doesn't prevent sending) */
|
|
5
6
|
captureOTP?: boolean;
|
|
6
7
|
}
|
|
7
|
-
interface TestCookie {
|
|
8
|
+
export interface TestCookie {
|
|
8
9
|
name: string;
|
|
9
10
|
value: string;
|
|
10
11
|
domain: string;
|
|
@@ -14,7 +15,7 @@ interface TestCookie {
|
|
|
14
15
|
sameSite?: "Lax" | "Strict" | "None";
|
|
15
16
|
expires?: number;
|
|
16
17
|
}
|
|
17
|
-
interface LoginResult {
|
|
18
|
+
export interface LoginResult {
|
|
18
19
|
session: Session;
|
|
19
20
|
user: User;
|
|
20
21
|
headers: Headers;
|
|
@@ -22,12 +23,12 @@ interface LoginResult {
|
|
|
22
23
|
token: string;
|
|
23
24
|
}
|
|
24
25
|
/** Options for creating a session with the test auth helpers. */
|
|
25
|
-
interface TestAuthOptions {
|
|
26
|
+
export interface TestAuthOptions {
|
|
26
27
|
userId: string;
|
|
27
28
|
/** Additional session fields. Standard session fields are ignored. */
|
|
28
29
|
session?: Record<string, unknown>;
|
|
29
30
|
}
|
|
30
|
-
interface TestHelpers {
|
|
31
|
+
export interface TestHelpers {
|
|
31
32
|
createUser(overrides?: Partial<User> & Record<string, unknown>): User;
|
|
32
33
|
createOrganization?(overrides?: Record<string, unknown>): Record<string, unknown>;
|
|
33
34
|
saveUser(user: User): Promise<User>;
|
|
@@ -47,5 +48,4 @@ interface TestHelpers {
|
|
|
47
48
|
getOTP?(identifier: string): string | undefined;
|
|
48
49
|
clearOTPs?(): void;
|
|
49
50
|
}
|
|
50
|
-
//#endregion
|
|
51
|
-
export { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions };
|
|
51
|
+
//#endregion
|