@entro314labs/entro-auth 1.8.0-beta.11 → 1.8.0-beta.13
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/_virtual/_rolldown/runtime.mjs +4 -4
- package/dist/api/dispatch.d.mts +1 -1
- package/dist/api/dispatch.mjs +4 -4
- package/dist/api/index.d.mts +20 -20
- package/dist/api/index.mjs +7 -7
- package/dist/api/middlewares/authorization.mjs +1 -1
- package/dist/api/middlewares/origin-check.mjs +4 -4
- package/dist/api/rate-limiter/index.mjs +1 -1
- package/dist/api/routes/account.d.mts +2 -2
- package/dist/api/routes/account.mjs +5 -5
- package/dist/api/routes/callback.d.mts +1 -1
- package/dist/api/routes/callback.mjs +3 -3
- package/dist/api/routes/email-verification.d.mts +1 -1
- package/dist/api/routes/email-verification.mjs +6 -6
- package/dist/api/routes/error.mjs +2 -2
- package/dist/api/routes/id-token-nonce.d.mts +1 -1
- package/dist/api/routes/id-token-nonce.mjs +3 -3
- package/dist/api/routes/ok.mjs +1 -1
- package/dist/api/routes/password.mjs +4 -4
- package/dist/api/routes/session.d.mts +2 -2
- package/dist/api/routes/session.mjs +3 -3
- package/dist/api/routes/sign-in.d.mts +2 -2
- package/dist/api/routes/sign-in.mjs +5 -5
- package/dist/api/routes/sign-out.mjs +2 -2
- package/dist/api/routes/sign-up.d.mts +1 -1
- package/dist/api/routes/sign-up.mjs +6 -6
- package/dist/api/routes/update-session.d.mts +1 -1
- package/dist/api/routes/update-session.mjs +3 -3
- package/dist/api/routes/update-user.d.mts +1 -1
- package/dist/api/routes/update-user.mjs +4 -4
- package/dist/api/to-auth-endpoints.mjs +2 -2
- package/dist/auth/base.mjs +2 -2
- package/dist/auth/full.d.mts +1 -1
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/auth/trusted-origins.mjs +1 -1
- package/dist/client/config.d.mts +10 -10
- package/dist/client/config.mjs +2 -2
- package/dist/client/index.d.mts +2 -2
- package/dist/client/lynx/index.d.mts +3 -3
- package/dist/client/lynx/index.mjs +1 -1
- package/dist/client/lynx/lynx-store.d.mts +1 -1
- package/dist/client/lynx/lynx-store.mjs +1 -1
- package/dist/client/path-to-object.d.mts +3 -3
- package/dist/client/proxy.mjs +2 -2
- package/dist/client/query.d.mts +2 -2
- package/dist/client/query.mjs +1 -1
- package/dist/client/react/index.d.mts +3 -3
- package/dist/client/react/index.mjs +1 -1
- package/dist/client/react/react-store.mjs +1 -1
- package/dist/client/session-atom.d.mts +2 -2
- package/dist/client/session-atom.mjs +1 -1
- package/dist/client/solid/index.d.mts +4 -4
- package/dist/client/solid/index.mjs +1 -1
- package/dist/client/svelte/index.d.mts +4 -4
- package/dist/client/svelte/index.mjs +1 -1
- package/dist/client/types.d.mts +9 -9
- package/dist/client/vanilla.d.mts +4 -4
- package/dist/client/vanilla.mjs +1 -1
- package/dist/client/vue/index.d.mts +4 -4
- package/dist/client/vue/index.mjs +1 -1
- package/dist/context/create-context.mjs +9 -9
- package/dist/context/helpers.mjs +4 -4
- package/dist/context/init-minimal.mjs +1 -1
- package/dist/context/init.mjs +1 -1
- package/dist/context/secret-utils.mjs +1 -1
- package/dist/cookies/index.d.mts +3 -3
- package/dist/cookies/index.mjs +7 -7
- package/dist/cookies/jwt.mjs +1 -1
- package/dist/cookies/session-store.mjs +3 -3
- package/dist/crypto/index.d.mts +1 -1
- package/dist/crypto/index.mjs +4 -4
- package/dist/crypto/jwt.mjs +1 -2
- package/dist/crypto/password.d.mts +10 -5
- package/dist/crypto/password.mjs +5 -5
- package/dist/db/adapter-kysely.mjs +1 -1
- package/dist/db/get-migration.d.mts +1 -1
- package/dist/db/get-migration.mjs +6 -6
- package/dist/db/get-schema.mjs +1 -1
- package/dist/db/index.mjs +1 -1
- package/dist/db/internal-adapter.d.mts +2 -2
- package/dist/db/internal-adapter.mjs +8 -8
- package/dist/db/revoke-unproven-account-access.d.mts +1 -1
- package/dist/db/schema.d.mts +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/integrations/next-js.mjs +1 -1
- package/dist/integrations/node.d.mts +1 -1
- package/dist/integrations/svelte-kit.d.mts +1 -1
- package/dist/integrations/svelte-kit.mjs +1 -1
- package/dist/integrations/tanstack-start-solid.mjs +1 -1
- package/dist/integrations/tanstack-start.mjs +1 -1
- package/dist/oauth2/account-key.mjs +1 -2
- package/dist/oauth2/callback.mjs +1 -1
- package/dist/oauth2/link-account.d.mts +1 -1
- package/dist/oauth2/link-account.mjs +4 -4
- package/dist/oauth2/state.d.mts +1 -1
- package/dist/oauth2/state.mjs +1 -1
- package/dist/{package.mjs → package.json.mjs} +1 -1
- package/dist/plugins/access/types.d.mts +1 -1
- package/dist/plugins/admin/admin.d.mts +6 -6
- package/dist/plugins/admin/admin.mjs +2 -2
- package/dist/plugins/admin/client.d.mts +1 -1
- package/dist/plugins/admin/error-codes.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +5 -5
- package/dist/plugins/admin/types.d.mts +1 -1
- package/dist/plugins/anonymous/index.mjs +4 -4
- package/dist/plugins/anonymous/types.d.mts +2 -2
- package/dist/plugins/bearer/index.mjs +3 -3
- package/dist/plugins/captcha/index.mjs +11 -2
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +1 -1
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +1 -1
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +1 -1
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +1 -1
- package/dist/plugins/custom-session/client.d.mts +1 -1
- package/dist/plugins/custom-session/index.mjs +1 -1
- package/dist/plugins/device-authorization/index.d.mts +8 -8
- package/dist/plugins/device-authorization/index.mjs +2 -2
- package/dist/plugins/device-authorization/routes.d.mts +2 -2
- package/dist/plugins/device-authorization/routes.mjs +5 -4
- package/dist/plugins/email-otp/index.mjs +1 -1
- package/dist/plugins/email-otp/routes.mjs +4 -4
- package/dist/plugins/generic-oauth/index.d.mts +2 -2
- package/dist/plugins/generic-oauth/index.mjs +6 -6
- package/dist/plugins/generic-oauth/providers/index.d.mts +38 -0
- package/dist/plugins/generic-oauth/providers/line.mjs +1 -1
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +2 -2
- package/dist/plugins/haveibeenpwned/index.mjs +4 -4
- package/dist/plugins/jwt/client.d.mts +3 -3
- package/dist/plugins/jwt/cookie-cache.mjs +2 -2
- package/dist/plugins/jwt/index.d.mts +2 -2
- package/dist/plugins/jwt/index.mjs +3 -3
- package/dist/plugins/jwt/sign.d.mts +1 -1
- package/dist/plugins/jwt/sign.mjs +2 -2
- package/dist/plugins/jwt/types.d.mts +2 -2
- package/dist/plugins/jwt/utils.d.mts +1 -1
- package/dist/plugins/jwt/utils.mjs +1 -1
- package/dist/plugins/jwt/verify.d.mts +1 -1
- package/dist/plugins/jwt/verify.mjs +4 -4
- package/dist/plugins/last-login-method/index.mjs +1 -1
- package/dist/plugins/magic-link/index.mjs +2 -2
- package/dist/plugins/multi-session/index.d.mts +1 -1
- package/dist/plugins/multi-session/index.mjs +2 -2
- package/dist/plugins/oauth-popup/client.d.mts +2 -2
- package/dist/plugins/oauth-popup/index.mjs +4 -4
- package/dist/plugins/oauth-proxy/index.mjs +4 -4
- package/dist/plugins/oauth-proxy/utils.mjs +1 -1
- package/dist/plugins/one-tap/client.d.mts +1 -1
- package/dist/plugins/one-tap/client.mjs +1 -1
- package/dist/plugins/one-tap/index.mjs +5 -5
- package/dist/plugins/one-time-token/index.d.mts +1 -1
- package/dist/plugins/one-time-token/index.mjs +3 -4
- package/dist/plugins/open-api/generator.d.mts +4 -4
- package/dist/plugins/open-api/generator.mjs +1 -1
- package/dist/plugins/open-api/index.mjs +1 -1
- package/dist/plugins/organization/adapter.d.mts +3 -3
- package/dist/plugins/organization/adapter.mjs +4 -4
- package/dist/plugins/organization/call.mjs +1 -1
- package/dist/plugins/organization/client.d.mts +3 -3
- package/dist/plugins/organization/client.mjs +1 -1
- package/dist/plugins/organization/has-permission.d.mts +1 -1
- package/dist/plugins/organization/has-permission.mjs +2 -2
- package/dist/plugins/organization/organization.d.mts +1 -1
- package/dist/plugins/organization/organization.mjs +3 -3
- package/dist/plugins/organization/routes/crud-access-control.d.mts +1 -1
- package/dist/plugins/organization/routes/crud-access-control.mjs +3 -3
- package/dist/plugins/organization/routes/crud-invites.d.mts +24 -24
- package/dist/plugins/organization/routes/crud-invites.mjs +4 -4
- package/dist/plugins/organization/routes/crud-members.d.mts +19 -19
- package/dist/plugins/organization/routes/crud-members.mjs +4 -4
- package/dist/plugins/organization/routes/crud-org.d.mts +16 -16
- package/dist/plugins/organization/routes/crud-org.mjs +3 -3
- package/dist/plugins/organization/routes/crud-team.d.mts +1 -1
- package/dist/plugins/organization/routes/crud-team.mjs +4 -4
- package/dist/plugins/organization/schema.d.mts +4 -4
- package/dist/plugins/organization/types.d.mts +2 -2
- package/dist/plugins/phone-number/client.d.mts +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +1 -1
- package/dist/plugins/phone-number/index.d.mts +1 -1
- package/dist/plugins/phone-number/index.mjs +2 -2
- package/dist/plugins/phone-number/routes.mjs +4 -4
- package/dist/plugins/phone-number/types.d.mts +1 -1
- package/dist/plugins/siwe/index.d.mts +1 -1
- package/dist/plugins/siwe/index.mjs +4 -4
- package/dist/plugins/test-utils/auth-helpers.mjs +1 -1
- package/dist/plugins/test-utils/cookie-builder.mjs +2 -4
- package/dist/plugins/two-factor/backup-codes/index.d.mts +1 -1
- package/dist/plugins/two-factor/backup-codes/index.mjs +4 -4
- package/dist/plugins/two-factor/claim.d.mts +1 -1
- package/dist/plugins/two-factor/claim.mjs +1 -1
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/index.d.mts +4 -4
- package/dist/plugins/two-factor/index.mjs +6 -6
- package/dist/plugins/two-factor/otp/index.d.mts +1 -1
- package/dist/plugins/two-factor/otp/index.mjs +3 -3
- package/dist/plugins/two-factor/totp/index.d.mts +1 -1
- package/dist/plugins/two-factor/totp/index.mjs +10 -5
- package/dist/plugins/two-factor/types.d.mts +1 -1
- package/dist/plugins/two-factor/verify-two-factor.d.mts +1 -1
- package/dist/plugins/two-factor/verify-two-factor.mjs +2 -2
- package/dist/plugins/username/client.d.mts +1 -1
- package/dist/plugins/username/error-codes.d.mts +1 -1
- package/dist/plugins/username/index.d.mts +6 -6
- package/dist/plugins/username/index.mjs +4 -4
- package/dist/plugins/username/schema.d.mts +4 -4
- package/dist/state.d.mts +2 -2
- package/dist/state.mjs +3 -3
- package/dist/test-utils/http-test-instance.d.mts +10 -10
- package/dist/test-utils/http-test-instance.mjs +1 -1
- package/dist/test-utils/test-instance.d.mts +2 -2
- package/dist/test-utils/test-instance.mjs +4 -4
- package/dist/types/adapter.d.mts +2 -2
- package/dist/types/api.d.mts +1 -1
- package/dist/types/auth.d.mts +2 -2
- package/dist/types/index.d.mts +1 -1
- package/dist/types/models.d.mts +3 -3
- package/dist/types/plugins.d.mts +1 -1
- package/dist/utils/hashing.mjs +1 -1
- package/dist/utils/url.mjs +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +28 -28
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
3
|
+
import * as z from "zod";
|
|
1
4
|
import { getSessionFromCtx, requestOnlySessionMiddleware } from "../../../api/routes/session.mjs";
|
|
2
5
|
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
3
6
|
import { toZodSchema } from "../../../db/to-zod.mjs";
|
|
@@ -5,9 +8,6 @@ import { getOrgAdapter } from "../adapter.mjs";
|
|
|
5
8
|
import { orgMiddleware, orgSessionMiddleware } from "../call.mjs";
|
|
6
9
|
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
7
10
|
import { canViewInvitations, hasPermission, withoutCreatorRoleInvitations } from "../has-permission.mjs";
|
|
8
|
-
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
9
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
10
|
-
import * as z from "zod";
|
|
11
11
|
// src/plugins/organization/routes/crud-org.ts
|
|
12
12
|
const baseOrganizationSchema = z.object({
|
|
13
13
|
name: z.string().min(1).meta({ description: "The name of the organization" }),
|
|
@@ -3,11 +3,11 @@ import "../access/index.mjs";
|
|
|
3
3
|
import { Role } from "../../access/types.mjs";
|
|
4
4
|
import "../../index.mjs";
|
|
5
5
|
import "../../../db/index.mjs";
|
|
6
|
+
import * as z from "zod";
|
|
6
7
|
import { PrettifyDeep } from "../../../types/helper.mjs";
|
|
7
8
|
import { teamSchema } from "../schema.mjs";
|
|
8
9
|
import { defaultRoles } from "../access/statement.mjs";
|
|
9
10
|
import { OrganizationOptions } from "../types.mjs";
|
|
10
|
-
import * as z from "zod";
|
|
11
11
|
declare const teamBaseSchema: z.ZodObject<{
|
|
12
12
|
name: z.ZodString;
|
|
13
13
|
organizationId: z.ZodOptional<z.ZodString>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { getCurrentAdapter, runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
3
|
+
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
4
|
+
import * as z from "zod";
|
|
1
5
|
import { getSessionFromCtx } from "../../../api/routes/session.mjs";
|
|
2
6
|
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
3
7
|
import { toZodSchema } from "../../../db/to-zod.mjs";
|
|
@@ -6,10 +10,6 @@ import { orgMiddleware, orgSessionMiddleware } from "../call.mjs";
|
|
|
6
10
|
import { ORGANIZATION_ERROR_CODES } from "../error-codes.mjs";
|
|
7
11
|
import { hasPermission } from "../has-permission.mjs";
|
|
8
12
|
import { teamSchema } from "../schema.mjs";
|
|
9
|
-
import { getCurrentAdapter, runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
10
|
-
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
11
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
12
|
-
import * as z from "zod";
|
|
13
13
|
// src/plugins/organization/routes/crud-team.ts
|
|
14
14
|
const teamBaseSchema = z.object({
|
|
15
15
|
name: z.string().meta({ description: "The name of the team. Eg: \"my-team\"" }),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FieldAttributeToObject, RemoveFieldsWithReturnedFalse } from "../../db/field.mjs";
|
|
2
|
-
import "../../db/index.mjs";
|
|
3
|
-
import { OrganizationOptions } from "./types.mjs";
|
|
4
2
|
import { DBFieldAttribute, EntroAuthPluginDBSchema } from "@entro314labs/entro-auth-core/db";
|
|
5
3
|
import { Prettify } from "better-call";
|
|
6
4
|
import * as z from "zod";
|
|
5
|
+
import "../../db/index.mjs";
|
|
6
|
+
import { OrganizationOptions } from "./types.mjs";
|
|
7
7
|
type InferSchema<Schema extends EntroAuthPluginDBSchema, TableName extends string, DefaultFields> = {
|
|
8
8
|
modelName: Schema[TableName] extends {
|
|
9
9
|
modelName: infer M;
|
|
@@ -245,8 +245,8 @@ export declare const roleSchema: z.ZodString;
|
|
|
245
245
|
export declare const invitationStatus: z.ZodDefault<z.ZodEnum<{
|
|
246
246
|
pending: "pending";
|
|
247
247
|
accepted: "accepted";
|
|
248
|
-
canceled: "canceled";
|
|
249
248
|
rejected: "rejected";
|
|
249
|
+
canceled: "canceled";
|
|
250
250
|
}>>;
|
|
251
251
|
export declare const organizationSchema: z.ZodObject<{
|
|
252
252
|
id: z.ZodDefault<z.ZodString>;
|
|
@@ -271,8 +271,8 @@ export declare const invitationSchema: z.ZodObject<{
|
|
|
271
271
|
status: z.ZodDefault<z.ZodEnum<{
|
|
272
272
|
pending: "pending";
|
|
273
273
|
accepted: "accepted";
|
|
274
|
-
canceled: "canceled";
|
|
275
274
|
rejected: "rejected";
|
|
275
|
+
canceled: "canceled";
|
|
276
276
|
}>>;
|
|
277
277
|
teamId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
278
278
|
inviterId: z.ZodString;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Session as Session$1, User as User$1 } from "../../types/models.mjs";
|
|
2
|
+
import { AuthContext, Awaitable, GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
3
|
+
import { DBFieldAttribute } from "@entro314labs/entro-auth-core/db";
|
|
2
4
|
import "../../types/index.mjs";
|
|
3
5
|
import { AccessControl, Role } from "../access/types.mjs";
|
|
4
6
|
import "../access/index.mjs";
|
|
5
7
|
import { Invitation, Member, Organization, OrganizationRole, Team, TeamMember } from "./schema.mjs";
|
|
6
|
-
import { AuthContext, Awaitable, GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
7
|
-
import { DBFieldAttribute } from "@entro314labs/entro-auth-core/db";
|
|
8
8
|
export interface OrganizationOptions {
|
|
9
9
|
/**
|
|
10
10
|
* Configure whether new users are able to create new organizations.
|
|
@@ -10,11 +10,11 @@ export declare const phoneNumberClient: () => {
|
|
|
10
10
|
signal: "$sessionSignal";
|
|
11
11
|
}[];
|
|
12
12
|
$ERROR_CODES: {
|
|
13
|
+
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
13
14
|
INVALID_PHONE_NUMBER: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
14
15
|
PHONE_NUMBER_EXIST: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
15
16
|
PHONE_NUMBER_NOT_EXIST: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
16
17
|
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
17
|
-
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
18
18
|
OTP_NOT_FOUND: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
19
19
|
OTP_EXPIRED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
20
20
|
INVALID_OTP: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const PHONE_NUMBER_ERROR_CODES: {
|
|
2
|
+
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
2
3
|
INVALID_PHONE_NUMBER: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
3
4
|
PHONE_NUMBER_EXIST: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
4
5
|
PHONE_NUMBER_NOT_EXIST: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
5
6
|
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
6
|
-
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
7
7
|
OTP_NOT_FOUND: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
8
8
|
OTP_EXPIRED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
9
9
|
INVALID_OTP: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
@@ -357,11 +357,11 @@ export declare const phoneNumber: (options?: PhoneNumberOptions | undefined) =>
|
|
|
357
357
|
}[];
|
|
358
358
|
options: PhoneNumberOptions | undefined;
|
|
359
359
|
$ERROR_CODES: {
|
|
360
|
+
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
360
361
|
INVALID_PHONE_NUMBER: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER">;
|
|
361
362
|
PHONE_NUMBER_EXIST: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"PHONE_NUMBER_EXIST">;
|
|
362
363
|
PHONE_NUMBER_NOT_EXIST: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"PHONE_NUMBER_NOT_EXIST">;
|
|
363
364
|
INVALID_PHONE_NUMBER_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_PHONE_NUMBER_OR_PASSWORD">;
|
|
364
|
-
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
365
365
|
OTP_NOT_FOUND: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"OTP_NOT_FOUND">;
|
|
366
366
|
OTP_EXPIRED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"OTP_EXPIRED">;
|
|
367
367
|
INVALID_OTP: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_OTP">;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
1
3
|
import { mergeSchema } from "../../db/schema.mjs";
|
|
2
4
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
3
5
|
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes.mjs";
|
|
4
6
|
import { consumePhoneNumberOTP, requestPasswordResetPhoneNumber, resetPasswordPhoneNumber, sendPhoneNumberOTP, signInPhoneNumber, verifyPhoneNumber } from "./routes.mjs";
|
|
5
7
|
import { schema } from "./schema.mjs";
|
|
6
|
-
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
7
|
-
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
8
8
|
// src/plugins/phone-number/index.ts
|
|
9
9
|
const phoneNumber = (options) => {
|
|
10
10
|
const opts = {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { getCurrentAdapter, runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
3
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
4
|
+
import * as z from "zod";
|
|
1
5
|
import { getAuthoritativeSessionFromCtx } from "../../api/routes/session.mjs";
|
|
2
6
|
import { expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
3
7
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
@@ -6,10 +10,6 @@ import { HIDE_METADATA } from "../../utils/hide-metadata.mjs";
|
|
|
6
10
|
import { getDate } from "../../utils/date.mjs";
|
|
7
11
|
import { assertPasswordNotTooLong, assertPasswordNotTooShort, resetCredentialPassword } from "../../utils/password.mjs";
|
|
8
12
|
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes.mjs";
|
|
9
|
-
import { getCurrentAdapter, runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
10
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
11
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
12
|
-
import * as z from "zod";
|
|
13
13
|
// src/plugins/phone-number/routes.ts
|
|
14
14
|
const PHONE_CREDENTIAL_PROOF_COOKIE = "phone_credential_proof";
|
|
15
15
|
const PHONE_CREDENTIAL_PROOF_PREFIX = "phone-credential-proof:";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
|
+
import { Awaitable, GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
2
3
|
import "../../types/index.mjs";
|
|
3
4
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
4
5
|
import { schema } from "./schema.mjs";
|
|
5
|
-
import { Awaitable, GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
6
6
|
export interface UserWithPhoneNumber extends User {
|
|
7
7
|
phoneNumber: string;
|
|
8
8
|
phoneNumberVerified: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
2
|
+
import * as z from "zod";
|
|
2
3
|
import "../../types/index.mjs";
|
|
3
4
|
import { WalletAddressSchema, schema } from "./schema.mjs";
|
|
4
5
|
import { ENSLookupArgs, ENSLookupResult, SIWEVerifyMessageArgs } from "./types.mjs";
|
|
5
|
-
import * as z from "zod";
|
|
6
6
|
declare module "@entro314labs/entro-auth-core" {
|
|
7
7
|
interface EntroAuthPluginRegistry<AuthOptions, Options> {
|
|
8
8
|
siwe: {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { getCurrentAdapter, runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
3
|
+
import { createPlaceholderEmail } from "@entro314labs/entro-auth-core/utils/email";
|
|
4
|
+
import * as z from "zod";
|
|
1
5
|
import { APIError } from "../../api/index.mjs";
|
|
2
6
|
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
3
7
|
import { mergeSchema } from "../../db/schema.mjs";
|
|
@@ -6,10 +10,6 @@ import { isAPIError } from "../../utils/is-api-error.mjs";
|
|
|
6
10
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
7
11
|
import { normalizeSiweDomain, parseSiweMessage } from "./parse-message.mjs";
|
|
8
12
|
import { schema } from "./schema.mjs";
|
|
9
|
-
import { getCurrentAdapter, runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
10
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
11
|
-
import * as z from "zod";
|
|
12
|
-
import { createPlaceholderEmail } from "@entro314labs/entro-auth-core/utils/email";
|
|
13
13
|
// src/plugins/siwe/index.ts
|
|
14
14
|
const signedWalletAddressSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/).length(42);
|
|
15
15
|
const SIWE_VERIFICATION_IDENTIFIER_PREFIX = "siwe:";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createCookieHeaders, createTestCookie } from "./cookie-builder.mjs";
|
|
2
1
|
import { sessionSchema } from "@entro314labs/entro-auth-core/db";
|
|
2
|
+
import { createCookieHeaders, createTestCookie } from "./cookie-builder.mjs";
|
|
3
3
|
// src/plugins/test-utils/auth-helpers.ts
|
|
4
4
|
function createSession(ctx, opts) {
|
|
5
5
|
const additionalFields = Object.fromEntries(Object.entries(opts.session ?? {}).filter(([key]) => !Object.hasOwn(sessionSchema.shape, key)));
|
|
@@ -10,8 +10,7 @@ async function signCookieValue(value, secret) {
|
|
|
10
10
|
* Creates a test cookie with proper signing and attributes
|
|
11
11
|
*/
|
|
12
12
|
async function createTestCookie(ctx, sessionToken, domain) {
|
|
13
|
-
const
|
|
14
|
-
const signedToken = await signCookieValue(sessionToken, secret);
|
|
13
|
+
const signedToken = await signCookieValue(sessionToken, ctx.secret);
|
|
15
14
|
const cookieName = ctx.authCookies.sessionToken.name;
|
|
16
15
|
const cookieAttrs = ctx.authCookies.sessionToken.attributes;
|
|
17
16
|
return [{
|
|
@@ -29,8 +28,7 @@ async function createTestCookie(ctx, sessionToken, domain) {
|
|
|
29
28
|
* Creates a Headers object with the cookie header set
|
|
30
29
|
*/
|
|
31
30
|
async function createCookieHeaders(ctx, sessionToken) {
|
|
32
|
-
const
|
|
33
|
-
const signedToken = await signCookieValue(sessionToken, secret);
|
|
31
|
+
const signedToken = await signCookieValue(sessionToken, ctx.secret);
|
|
34
32
|
const cookieName = ctx.authCookies.sessionToken.name;
|
|
35
33
|
const headers = new Headers();
|
|
36
34
|
headers.set("cookie", `${cookieName}=${signedToken}`);
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
3
|
+
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
4
|
+
import * as z from "zod";
|
|
1
5
|
import { sessionMiddleware } from "../../../api/routes/session.mjs";
|
|
2
6
|
import { symmetricDecrypt, symmetricEncrypt } from "../../../crypto/index.mjs";
|
|
3
7
|
import { generateRandomString } from "../../../crypto/random.mjs";
|
|
@@ -8,10 +12,6 @@ import { withTwoFactorClaim } from "../claim.mjs";
|
|
|
8
12
|
import "../constant.mjs";
|
|
9
13
|
import { TWO_FACTOR_ERROR_CODES } from "../error-code.mjs";
|
|
10
14
|
import { assertTwoFactorNotLocked, recordTwoFactorFailure, resetTwoFactorFailures, twoFactorIsOn, verifyTwoFactor } from "../verify-two-factor.mjs";
|
|
11
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
12
|
-
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
13
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
14
|
-
import * as z from "zod";
|
|
15
15
|
// src/plugins/two-factor/backup-codes/index.ts
|
|
16
16
|
function generateBackupCodesFn(options) {
|
|
17
17
|
return Array.from({ length: options?.amount ?? 10 }).fill(null).map(() => generateRandomString(options?.length ?? 10, "a-z", "0-9", "A-Z")).map((code) => `${code.slice(0, 5)}-${code.slice(5)}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
|
-
import "../../types/index.mjs";
|
|
3
2
|
import { GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
3
|
+
import "../../types/index.mjs";
|
|
4
4
|
/** What a change does through the claim it holds. */
|
|
5
5
|
export type TwoFactorClaim = {
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
1
2
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
2
3
|
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
3
4
|
import { removePasskey } from "./passkey.mjs";
|
|
4
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
5
5
|
// src/plugins/two-factor/claim.ts
|
|
6
6
|
/** Longer than a request takes: the claim of one that died is gone by then. */
|
|
7
7
|
const CLAIM_SECONDS = 30;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { isSafeUrlScheme } from "@entro314labs/entro-auth-core/utils/url";
|
|
1
2
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
2
3
|
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
3
|
-
import { isSafeUrlScheme } from "@entro314labs/entro-auth-core/utils/url";
|
|
4
4
|
// src/plugins/two-factor/client.ts
|
|
5
5
|
const twoFactorClient = (options) => {
|
|
6
6
|
return {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BackupCodeOptions, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode } from "./backup-codes/index.mjs";
|
|
2
2
|
import { OTPOptions, otp2fa } from "./otp/index.mjs";
|
|
3
3
|
import { TOTPOptions, totp2fa } from "./totp/index.mjs";
|
|
4
|
+
import * as z from "zod";
|
|
4
5
|
import { TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor } from "./types.mjs";
|
|
5
6
|
import { TwoFactorClaim, withTwoFactorClaim } from "./claim.mjs";
|
|
6
7
|
import { BACKUP_CODES_ONLY, DEFAULT_TWO_FACTOR_ALLOWED_ATTEMPTS } from "./constant.mjs";
|
|
7
8
|
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
8
9
|
import { assertTwoFactorNotLocked, discardUnfinishedEnrollment, recordTwoFactorFailure, resetTwoFactorFailures, twoFactorIsOn, verifyTwoFactor } from "./verify-two-factor.mjs";
|
|
9
10
|
import { twoFactorClient } from "./client.mjs";
|
|
10
|
-
import * as z from "zod";
|
|
11
11
|
declare module "@entro314labs/entro-auth-core" {
|
|
12
12
|
interface EntroAuthPluginRegistry<AuthOptions, Options> {
|
|
13
13
|
"two-factor": {
|
|
@@ -55,16 +55,16 @@ export declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
55
55
|
password: z.ZodOptional<z.ZodString>;
|
|
56
56
|
method: z.ZodDefault<z.ZodEnum<{
|
|
57
57
|
otp: "otp";
|
|
58
|
-
totp: "totp";
|
|
59
58
|
passkey: "passkey";
|
|
59
|
+
totp: "totp";
|
|
60
60
|
}>>;
|
|
61
61
|
issuer: z.ZodOptional<z.ZodString>;
|
|
62
62
|
}, z.core.$strip> | z.ZodObject<{
|
|
63
63
|
password: z.ZodString;
|
|
64
64
|
method: z.ZodDefault<z.ZodEnum<{
|
|
65
65
|
otp: "otp";
|
|
66
|
-
totp: "totp";
|
|
67
66
|
passkey: "passkey";
|
|
67
|
+
totp: "totp";
|
|
68
68
|
}>>;
|
|
69
69
|
issuer: z.ZodOptional<z.ZodString>;
|
|
70
70
|
}, z.core.$strip>;
|
|
@@ -646,7 +646,7 @@ export declare const twoFactor: <O extends TwoFactorOptions>(options?: O) => {
|
|
|
646
646
|
matcher(context: import("@entro314labs/entro-auth-core").HookEndpointContext): boolean;
|
|
647
647
|
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
648
648
|
twoFactorRedirect: boolean;
|
|
649
|
-
twoFactorMethods: ("otp" | "
|
|
649
|
+
twoFactorMethods: ("otp" | "passkey" | "totp")[];
|
|
650
650
|
twoFactorBackupCodes: boolean;
|
|
651
651
|
} | undefined>>;
|
|
652
652
|
}[];
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { createHMAC } from "@better-auth/utils/hmac";
|
|
2
|
+
import { createOTP } from "@better-auth/utils/otp";
|
|
3
|
+
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
4
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
5
|
+
import { setPendingSecondFactorUser } from "@entro314labs/entro-auth-core/utils/auth-completion";
|
|
6
|
+
import * as z from "zod";
|
|
1
7
|
import { sensitiveSessionMiddleware } from "../../api/routes/session.mjs";
|
|
2
8
|
import { asSignInGate } from "../../api/dispatch.mjs";
|
|
3
9
|
import { deleteSessionCookie, expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
@@ -16,12 +22,6 @@ import { schema } from "./schema.mjs";
|
|
|
16
22
|
import { totp2fa } from "./totp/index.mjs";
|
|
17
23
|
import { assertTwoFactorNotLocked, discardUnfinishedEnrollment, recordTwoFactorFailure, resetTwoFactorFailures, secondSteps, turnTwoFactorOff, twoFactorIsOn, verifyTwoFactor } from "./verify-two-factor.mjs";
|
|
18
24
|
import { twoFactorClient } from "./client.mjs";
|
|
19
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
20
|
-
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
21
|
-
import * as z from "zod";
|
|
22
|
-
import { createHMAC } from "@better-auth/utils/hmac";
|
|
23
|
-
import { setPendingSecondFactorUser } from "@entro314labs/entro-auth-core/utils/auth-completion";
|
|
24
|
-
import { createOTP } from "@better-auth/utils/otp";
|
|
25
25
|
// src/plugins/two-factor/index.ts
|
|
26
26
|
const conflict = () => APIError.from("CONFLICT", TWO_FACTOR_ERROR_CODES.SETUP_ALREADY_STARTED);
|
|
27
27
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserWithTwoFactor } from "../types.mjs";
|
|
2
1
|
import { Awaitable, GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
3
2
|
import * as z from "zod";
|
|
3
|
+
import { UserWithTwoFactor } from "../types.mjs";
|
|
4
4
|
export interface OTPOptions {
|
|
5
5
|
/**
|
|
6
6
|
* How long the opt will be valid for in
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
3
|
+
import * as z from "zod";
|
|
1
4
|
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
2
5
|
import { constantTimeEqual } from "../../../crypto/buffer.mjs";
|
|
3
6
|
import { generateRandomString } from "../../../crypto/random.mjs";
|
|
@@ -8,9 +11,6 @@ import { withTwoFactorClaim } from "../claim.mjs";
|
|
|
8
11
|
import { TWO_FACTOR_ERROR_CODES } from "../error-code.mjs";
|
|
9
12
|
import { defaultKeyHasher } from "../utils.mjs";
|
|
10
13
|
import { assertTwoFactorNotLocked, discardUnfinishedEnrollment, recordTwoFactorFailure, resetTwoFactorFailures, twoFactorIsOn, verifyTwoFactor } from "../verify-two-factor.mjs";
|
|
11
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
12
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
13
|
-
import * as z from "zod";
|
|
14
14
|
// src/plugins/two-factor/otp/index.ts
|
|
15
15
|
const verifyOTPBodySchema = z.object({
|
|
16
16
|
code: z.string().meta({ description: "The otp code to verify. Eg: \"012345\"" }),
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { base32 } from "@better-auth/utils/base32";
|
|
2
|
+
import { createOTP } from "@better-auth/utils/otp";
|
|
3
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
4
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
5
|
+
import * as z from "zod";
|
|
1
6
|
import { sessionMiddleware } from "../../../api/routes/session.mjs";
|
|
2
7
|
import { setSessionCookie } from "../../../cookies/index.mjs";
|
|
3
8
|
import { symmetricDecrypt } from "../../../crypto/index.mjs";
|
|
9
|
+
import { parseUserOutput } from "../../../db/schema.mjs";
|
|
4
10
|
import { shouldRequirePassword } from "../../../utils/password.mjs";
|
|
5
11
|
import { PACKAGE_VERSION } from "../../../version.mjs";
|
|
6
12
|
import { withTwoFactorClaim } from "../claim.mjs";
|
|
7
13
|
import "../constant.mjs";
|
|
8
14
|
import { TWO_FACTOR_ERROR_CODES } from "../error-code.mjs";
|
|
9
15
|
import { assertTwoFactorNotLocked, recordTwoFactorFailure, resetTwoFactorFailures, twoFactorIsOn, verifyTwoFactor } from "../verify-two-factor.mjs";
|
|
10
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
11
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
12
|
-
import * as z from "zod";
|
|
13
|
-
import { createOTP } from "@better-auth/utils/otp";
|
|
14
|
-
import { base32 } from "@better-auth/utils/base32";
|
|
15
16
|
// src/plugins/two-factor/totp/index.ts
|
|
16
17
|
const BASE32_PREFIX = "base32:";
|
|
17
18
|
/**
|
|
@@ -232,6 +233,10 @@ const totp2fa = (options) => {
|
|
|
232
233
|
user: turnedOn
|
|
233
234
|
});
|
|
234
235
|
await ctx.context.internalAdapter.deleteSession(activeSession.token);
|
|
236
|
+
return ctx.json({
|
|
237
|
+
token: newSession.token,
|
|
238
|
+
user: parseUserOutput(ctx.context.options, turnedOn)
|
|
239
|
+
});
|
|
235
240
|
}
|
|
236
241
|
return valid(ctx);
|
|
237
242
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { User } from "../../types/models.mjs";
|
|
2
2
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
|
+
import { EntroAuthPlugin, LiteralString } from "@entro314labs/entro-auth-core";
|
|
3
4
|
import "../../types/index.mjs";
|
|
4
5
|
import { BackupCodeOptions } from "./backup-codes/index.mjs";
|
|
5
6
|
import { OTPOptions } from "./otp/index.mjs";
|
|
6
7
|
import { schema } from "./schema.mjs";
|
|
7
8
|
import { TOTPOptions } from "./totp/index.mjs";
|
|
8
|
-
import { EntroAuthPlugin, LiteralString } from "@entro314labs/entro-auth-core";
|
|
9
9
|
export interface TwoFactorOptions {
|
|
10
10
|
/**
|
|
11
11
|
* Application Name
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
1
2
|
import "./claim.mjs";
|
|
2
3
|
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
3
4
|
import { TwoFactorTable, UserWithTwoFactor } from "./types.mjs";
|
|
4
|
-
import { GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
5
5
|
export declare function verifyTwoFactor(ctx: GenericEndpointContext): Promise<{
|
|
6
6
|
valid: (ctx: GenericEndpointContext) => Promise<{
|
|
7
7
|
token: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createHMAC } from "@better-auth/utils/hmac";
|
|
2
|
+
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
1
3
|
import { getAuthoritativeSessionFromCtx } from "../../api/routes/session.mjs";
|
|
2
4
|
import { expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
3
5
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
@@ -5,8 +7,6 @@ import { parseUserOutput } from "../../db/schema.mjs";
|
|
|
5
7
|
import { TRUST_DEVICE_COOKIE_NAME, TWO_FACTOR_COOKIE_NAME } from "./constant.mjs";
|
|
6
8
|
import { TWO_FACTOR_ERROR_CODES } from "./error-code.mjs";
|
|
7
9
|
import { hasPasskey, passkeySecondFactorEnabled } from "./passkey.mjs";
|
|
8
|
-
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
9
|
-
import { createHMAC } from "@better-auth/utils/hmac";
|
|
10
10
|
// src/plugins/two-factor/verify-two-factor.ts
|
|
11
11
|
async function verifyTwoFactor(ctx) {
|
|
12
12
|
const invalid = (errorKey) => {
|
|
@@ -20,9 +20,9 @@ export declare const usernameClient: <O extends UsernameClientOptions = Username
|
|
|
20
20
|
signal: "$sessionSignal";
|
|
21
21
|
}[];
|
|
22
22
|
$ERROR_CODES: {
|
|
23
|
+
INVALID_USERNAME_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
23
24
|
EMAIL_NOT_VERIFIED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"EMAIL_NOT_VERIFIED">;
|
|
24
25
|
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
25
|
-
INVALID_USERNAME_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
26
26
|
USERNAME_IS_ALREADY_TAKEN: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
27
27
|
USERNAME_TOO_SHORT: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_TOO_SHORT">;
|
|
28
28
|
USERNAME_TOO_LONG: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_TOO_LONG">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const USERNAME_ERROR_CODES: {
|
|
2
|
+
INVALID_USERNAME_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
2
3
|
EMAIL_NOT_VERIFIED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"EMAIL_NOT_VERIFIED">;
|
|
3
4
|
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
4
|
-
INVALID_USERNAME_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
5
5
|
USERNAME_IS_ALREADY_TAKEN: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
6
6
|
USERNAME_TOO_SHORT: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_TOO_SHORT">;
|
|
7
7
|
USERNAME_TOO_LONG: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_TOO_LONG">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
1
2
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
2
3
|
import { UsernameSchema } from "./schema.mjs";
|
|
3
4
|
import { USERNAME_ERROR_CODES } from "./error-codes.mjs";
|
|
4
|
-
import * as z from "zod";
|
|
5
5
|
declare module "@entro314labs/entro-auth-core" {
|
|
6
6
|
interface EntroAuthPluginRegistry<AuthOptions, Options> {
|
|
7
7
|
username: {
|
|
@@ -260,14 +260,14 @@ declare const usernameImpl: <IncludeDisplayUsername extends boolean>(options: Us
|
|
|
260
260
|
unique: true;
|
|
261
261
|
returned: true;
|
|
262
262
|
transform: {
|
|
263
|
-
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean |
|
|
263
|
+
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean | unknown[] | Date | Record<string, unknown> | null | undefined;
|
|
264
264
|
};
|
|
265
265
|
};
|
|
266
266
|
displayUsername: {
|
|
267
267
|
type: "string";
|
|
268
268
|
required: false;
|
|
269
269
|
transform: {
|
|
270
|
-
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean |
|
|
270
|
+
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean | unknown[] | Date | Record<string, unknown> | null | undefined;
|
|
271
271
|
};
|
|
272
272
|
};
|
|
273
273
|
}, "username"> : {
|
|
@@ -278,14 +278,14 @@ declare const usernameImpl: <IncludeDisplayUsername extends boolean>(options: Us
|
|
|
278
278
|
unique: true;
|
|
279
279
|
returned: true;
|
|
280
280
|
transform: {
|
|
281
|
-
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean |
|
|
281
|
+
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean | unknown[] | Date | Record<string, unknown> | null | undefined;
|
|
282
282
|
};
|
|
283
283
|
};
|
|
284
284
|
displayUsername: {
|
|
285
285
|
type: "string";
|
|
286
286
|
required: false;
|
|
287
287
|
transform: {
|
|
288
|
-
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean |
|
|
288
|
+
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean | unknown[] | Date | Record<string, unknown> | null | undefined;
|
|
289
289
|
};
|
|
290
290
|
};
|
|
291
291
|
};
|
|
@@ -299,9 +299,9 @@ declare const usernameImpl: <IncludeDisplayUsername extends boolean>(options: Us
|
|
|
299
299
|
};
|
|
300
300
|
options: UsernameOptions | undefined;
|
|
301
301
|
$ERROR_CODES: {
|
|
302
|
+
INVALID_USERNAME_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
302
303
|
EMAIL_NOT_VERIFIED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"EMAIL_NOT_VERIFIED">;
|
|
303
304
|
UNEXPECTED_ERROR: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"UNEXPECTED_ERROR">;
|
|
304
|
-
INVALID_USERNAME_OR_PASSWORD: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_USERNAME_OR_PASSWORD">;
|
|
305
305
|
USERNAME_IS_ALREADY_TAKEN: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_IS_ALREADY_TAKEN">;
|
|
306
306
|
USERNAME_TOO_SHORT: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_TOO_SHORT">;
|
|
307
307
|
USERNAME_TOO_LONG: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USERNAME_TOO_LONG">;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { getCurrentAdapter } from "@entro314labs/entro-auth-core/context";
|
|
3
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
4
|
+
import * as z from "zod";
|
|
1
5
|
import { createEmailVerificationToken } from "../../api/routes/email-verification.mjs";
|
|
2
6
|
import { setSessionCookie } from "../../cookies/index.mjs";
|
|
3
7
|
import { mergeSchema, parseUserOutput } from "../../db/schema.mjs";
|
|
@@ -5,10 +9,6 @@ import { assertPasswordNotTooLong } from "../../utils/password.mjs";
|
|
|
5
9
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
6
10
|
import { USERNAME_ERROR_CODES } from "./error-codes.mjs";
|
|
7
11
|
import { getSchema } from "./schema.mjs";
|
|
8
|
-
import { getCurrentAdapter } from "@entro314labs/entro-auth-core/context";
|
|
9
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
10
|
-
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
11
|
-
import * as z from "zod";
|
|
12
12
|
// src/plugins/username/index.ts
|
|
13
13
|
function defaultUsernameValidator(username) {
|
|
14
14
|
return /^[a-zA-Z0-9_.]+$/.test(username);
|
|
@@ -11,14 +11,14 @@ export declare const getSchema: <IncludeDisplayUsername extends boolean = true>(
|
|
|
11
11
|
unique: true;
|
|
12
12
|
returned: true;
|
|
13
13
|
transform: {
|
|
14
|
-
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean |
|
|
14
|
+
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean | unknown[] | Date | Record<string, unknown> | null | undefined;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
displayUsername: {
|
|
18
18
|
type: "string";
|
|
19
19
|
required: false;
|
|
20
20
|
transform: {
|
|
21
|
-
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean |
|
|
21
|
+
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean | unknown[] | Date | Record<string, unknown> | null | undefined;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
}, "username"> : {
|
|
@@ -29,14 +29,14 @@ export declare const getSchema: <IncludeDisplayUsername extends boolean = true>(
|
|
|
29
29
|
unique: true;
|
|
30
30
|
returned: true;
|
|
31
31
|
transform: {
|
|
32
|
-
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean |
|
|
32
|
+
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean | unknown[] | Date | Record<string, unknown> | null | undefined;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
displayUsername: {
|
|
36
36
|
type: "string";
|
|
37
37
|
required: false;
|
|
38
38
|
transform: {
|
|
39
|
-
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean |
|
|
39
|
+
input(value: import("@entro314labs/entro-auth-core/db").DBPrimitive): string | number | boolean | unknown[] | Date | Record<string, unknown> | null | undefined;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
};
|