@entro314labs/entro-auth 1.8.0-beta.12 → 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 +6 -6
- 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.mjs +5 -5
- 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.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 +1 -1
- package/dist/api/routes/session.mjs +3 -3
- 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 +6 -6
- 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 +5 -5
- 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 +1 -1
- 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 +2 -2
- package/dist/plugins/organization/types.d.mts +2 -2
- package/dist/plugins/phone-number/client.d.mts +4 -4
- package/dist/plugins/phone-number/error-codes.d.mts +4 -4
- package/dist/plugins/phone-number/index.d.mts +4 -4
- 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 +5 -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 +7 -7
- 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
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,8 @@ import { FilteredAPI, InferAPI, InferSessionAPI } from "./types/api.mjs";
|
|
|
5
5
|
import { Account, AdditionalSessionFieldsInput, AdditionalUserFieldsInput, InferPluginTypes, RateLimit, Session, User, Verification } from "./types/models.mjs";
|
|
6
6
|
import { InferOptionSchema, InferPluginContext, InferPluginErrorCodes, InferPluginIDs } from "./types/plugins.mjs";
|
|
7
7
|
import { Auth } from "./types/auth.mjs";
|
|
8
|
+
import { StandardSchemaV1 } from "@entro314labs/entro-auth-core";
|
|
9
|
+
import { getCurrentAdapter } from "@entro314labs/entro-auth-core/context";
|
|
8
10
|
import { entroAuth } from "./auth/full.mjs";
|
|
9
11
|
import { EntroAuthAdvancedOptions, EntroAuthCookies, EntroAuthOptions, EntroAuthPlugin, EntroAuthRateLimitOptions, StoreIdentifierOption, UserProvisioningSource, ValidateUserInfoAction, ValidateUserInfoMethod, ValidateUserInfoOAuthInfo, ValidateUserInfoResult, ValidateUserInfoSSOInfo, ValidateUserInfoSource } from "./types/index.mjs";
|
|
10
12
|
import { StateData, generateGenericState, getAuthStateVerificationIdentifier, parseGenericState } from "./state.mjs";
|
|
@@ -12,10 +14,8 @@ import { GenerateStateOptions, generateIdTokenNonce, generateState, parseState }
|
|
|
12
14
|
import { HIDE_METADATA } from "./utils/hide-metadata.mjs";
|
|
13
15
|
import { getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProtocolFromSource, isDynamicBaseURLConfig, isRequestLike, matchesHostPattern, resolveBaseURL, resolveDynamicBaseURL, trimTrailingSlashes } from "./utils/url.mjs";
|
|
14
16
|
import "./utils/index.mjs";
|
|
15
|
-
import { APIError } from "./api/index.mjs";
|
|
16
|
-
import { StandardSchemaV1 } from "@entro314labs/entro-auth-core";
|
|
17
|
-
import { getCurrentAdapter } from "@entro314labs/entro-auth-core/context";
|
|
18
17
|
import { JSONWebKeySet, JWTPayload } from "jose";
|
|
18
|
+
import { APIError } from "./api/index.mjs";
|
|
19
19
|
export * from "@entro314labs/entro-auth-core";
|
|
20
20
|
export * from "@entro314labs/entro-auth-core/db";
|
|
21
21
|
export * from "@entro314labs/entro-auth-core/env";
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { getBaseURL, getHost, getHostFromSource, getOrigin, getProtocol, getProt
|
|
|
2
2
|
import { generateGenericState, getAuthStateVerificationIdentifier, parseGenericState } from "./state.mjs";
|
|
3
3
|
import { generateIdTokenNonce, generateState, parseState } from "./oauth2/state.mjs";
|
|
4
4
|
import { HIDE_METADATA } from "./utils/hide-metadata.mjs";
|
|
5
|
+
import { getCurrentAdapter } from "@entro314labs/entro-auth-core/context";
|
|
5
6
|
import { entroAuth } from "./auth/full.mjs";
|
|
6
7
|
import { APIError } from "./api/index.mjs";
|
|
7
|
-
import { getCurrentAdapter } from "@entro314labs/entro-auth-core/context";
|
|
8
8
|
export * from "@entro314labs/entro-auth-core";
|
|
9
9
|
export * from "@entro314labs/entro-auth-core/db";
|
|
10
10
|
export * from "@entro314labs/entro-auth-core/env";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
1
2
|
import { setShouldSkipSessionRefresh } from "../api/state/should-session-refresh.mjs";
|
|
2
3
|
import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.mjs";
|
|
3
4
|
import { PACKAGE_VERSION } from "../version.mjs";
|
|
4
5
|
import { warnIfCookiePluginNotLast } from "./cookie-plugin-guard.mjs";
|
|
5
|
-
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
6
6
|
// src/integrations/next-js.ts
|
|
7
7
|
function toNextJsHandler(auth) {
|
|
8
8
|
const handler = async (request) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Auth } from "../types/auth.mjs";
|
|
2
|
-
import "../types/index.mjs";
|
|
3
2
|
import { IncomingHttpHeaders } from "node:http";
|
|
3
|
+
import "../types/index.mjs";
|
|
4
4
|
export declare const toNodeHandler: (auth: {
|
|
5
5
|
handler: Auth["handler"];
|
|
6
6
|
} | Auth["handler"]) => (req: import("node:http").IncomingMessage, res: import("node:http").ServerResponse) => Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EntroAuthOptions } from "../types/index.mjs";
|
|
2
1
|
import { RequestEvent } from "@sveltejs/kit";
|
|
2
|
+
import { EntroAuthOptions } from "../types/index.mjs";
|
|
3
3
|
export declare const toSvelteKitHandler: (auth: {
|
|
4
4
|
handler: (request: Request) => Response | Promise<Response>;
|
|
5
5
|
options: EntroAuthOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
1
2
|
import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.mjs";
|
|
2
3
|
import { PACKAGE_VERSION } from "../version.mjs";
|
|
3
4
|
import { warnIfCookiePluginNotLast } from "./cookie-plugin-guard.mjs";
|
|
4
|
-
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
5
5
|
// src/integrations/svelte-kit.ts
|
|
6
6
|
const toSvelteKitHandler = (auth) => {
|
|
7
7
|
return (event) => auth.handler(event.request);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
1
2
|
import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.mjs";
|
|
2
3
|
import { PACKAGE_VERSION } from "../version.mjs";
|
|
3
4
|
import { warnIfCookiePluginNotLast } from "./cookie-plugin-guard.mjs";
|
|
4
|
-
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
5
5
|
// src/integrations/tanstack-start-solid.ts
|
|
6
6
|
/**
|
|
7
7
|
* TanStack Start cookie plugin for Solid.js.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
1
2
|
import { parseSetCookieHeader, toCookieOptions } from "../cookies/cookie-utils.mjs";
|
|
2
3
|
import { PACKAGE_VERSION } from "../version.mjs";
|
|
3
4
|
import { warnIfCookiePluginNotLast } from "./cookie-plugin-guard.mjs";
|
|
4
|
-
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
5
5
|
// src/integrations/tanstack-start.ts
|
|
6
6
|
/**
|
|
7
7
|
* TanStack Start cookie plugin for React.
|
|
@@ -16,8 +16,7 @@ async function resolveOAuthAccountKey(provider, tokens, profile) {
|
|
|
16
16
|
tokens,
|
|
17
17
|
profile
|
|
18
18
|
};
|
|
19
|
-
const
|
|
20
|
-
const resolvedSubject = await accountSubject(accountKeyContext);
|
|
19
|
+
const resolvedSubject = await (0, provider.accountSubject)(accountKeyContext);
|
|
21
20
|
const accountId = String(resolvedSubject);
|
|
22
21
|
if (typeof resolvedSubject === "number" && !Number.isFinite(resolvedSubject) || accountId.trim().length === 0 || accountId === "undefined" || accountId === "null") throw new EntroAuthError("OAUTH_ACCOUNT_SUBJECT_INVALID");
|
|
23
22
|
return {
|
package/dist/oauth2/callback.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
1
2
|
import { resolveOAuthAccountKey, toOAuthProfileRecord } from "./account-key.mjs";
|
|
2
3
|
import { OAUTH_CALLBACK_ERROR_CODES } from "./errors.mjs";
|
|
3
4
|
import { getOAuthCallbackPath } from "./utils.mjs";
|
|
4
|
-
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
5
5
|
// src/oauth2/callback.ts
|
|
6
6
|
/**
|
|
7
7
|
* Turns a provider callback into a verified identity. It checks that the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Account, User } from "../types/models.mjs";
|
|
2
|
+
import { GenericEndpointContext, UserProvisioningSource } from "@entro314labs/entro-auth-core";
|
|
2
3
|
import { StateData } from "../state.mjs";
|
|
3
4
|
import "../types/index.mjs";
|
|
4
|
-
import { GenericEndpointContext, UserProvisioningSource } from "@entro314labs/entro-auth-core";
|
|
5
5
|
type OAuthAccountData = Omit<Account, "id" | "userId" | "createdAt" | "updatedAt">;
|
|
6
6
|
/**
|
|
7
7
|
* Provider profile a freshly linked account may copy onto the local user.
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { queueAfterTransactionHook, runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
2
|
+
import { isDevelopment } from "@entro314labs/entro-auth-core/env";
|
|
3
|
+
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
4
|
+
import { mergeScopes, parseStringBoolean } from "@entro314labs/entro-auth-core/oauth2";
|
|
1
5
|
import { createEmailVerificationToken } from "../api/routes/email-verification.mjs";
|
|
2
6
|
import { isStateful } from "../api/routes/session.mjs";
|
|
3
7
|
import { setAccountCookie } from "../cookies/session-store.mjs";
|
|
@@ -8,10 +12,6 @@ import { isAPIError } from "../utils/is-api-error.mjs";
|
|
|
8
12
|
import { assertValidUserInfo } from "../utils/validate-user-info.mjs";
|
|
9
13
|
import { OAUTH_CALLBACK_ERROR_CODES, redirectOnError } from "./errors.mjs";
|
|
10
14
|
import { encryptAccountTokens } from "./utils.mjs";
|
|
11
|
-
import { queueAfterTransactionHook, runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
12
|
-
import { isDevelopment } from "@entro314labs/entro-auth-core/env";
|
|
13
|
-
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
14
|
-
import { mergeScopes, parseStringBoolean } from "@entro314labs/entro-auth-core/oauth2";
|
|
15
15
|
// src/oauth2/link-account.ts
|
|
16
16
|
function linkOAuthAccountFailure(code, message) {
|
|
17
17
|
return {
|
package/dist/oauth2/state.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StateData } from "../state.mjs";
|
|
2
1
|
import { GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
2
|
+
import { StateData } from "../state.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Mint the OIDC `nonce` for the redirect flow, or `undefined` when the provider
|
|
5
5
|
* does not require ID-token nonce binding. Every redirect entrypoint (social
|
package/dist/oauth2/state.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
1
2
|
import { getOAuthServerContext, setOAuthState } from "../api/state/oauth.mjs";
|
|
2
3
|
import { generateRandomString } from "../crypto/random.mjs";
|
|
3
4
|
import { StateError, generateGenericState, parseGenericState } from "../state.mjs";
|
|
4
5
|
import { redirectOnError } from "./errors.mjs";
|
|
5
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
6
6
|
// src/oauth2/state.ts
|
|
7
7
|
/**
|
|
8
8
|
* Mint the OIDC `nonce` for the redirect flow, or `undefined` when the provider
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthorizeResponse, createAccessControl } from "./access.mjs";
|
|
2
1
|
import { LiteralString } from "@entro314labs/entro-auth-core";
|
|
2
|
+
import { AuthorizeResponse, createAccessControl } from "./access.mjs";
|
|
3
3
|
export type ArrayElement<T> = T extends readonly (infer E)[] ? E : never;
|
|
4
4
|
export type SubArray<T extends unknown[] | readonly unknown[] | any[]> = T[number][] | ReadonlyArray<T[number]>;
|
|
5
5
|
export type Subset<K extends keyof R, R extends Record<string | LiteralString, readonly string[] | readonly LiteralString[]>> = { [P in K]: SubArray<R[P]>; };
|
|
@@ -110,7 +110,7 @@ export declare const admin: <O extends AdminOptions>(options?: O | undefined) =>
|
|
|
110
110
|
$Infer: {
|
|
111
111
|
body: {
|
|
112
112
|
userId: string;
|
|
113
|
-
role: InferAdminRolesFromOption<O & Required<Pick<AdminOptions, "
|
|
113
|
+
role: InferAdminRolesFromOption<O & Required<Pick<AdminOptions, "adminRoles" | "defaultRole" | "bannedUserMessage">>> | InferAdminRolesFromOption<O & Required<Pick<AdminOptions, "adminRoles" | "defaultRole" | "bannedUserMessage">>>[];
|
|
114
114
|
};
|
|
115
115
|
};
|
|
116
116
|
};
|
|
@@ -199,7 +199,7 @@ export declare const admin: <O extends AdminOptions>(options?: O | undefined) =>
|
|
|
199
199
|
email: string;
|
|
200
200
|
password?: string | undefined;
|
|
201
201
|
name: string;
|
|
202
|
-
role?: InferAdminRolesFromOption<O & Required<Pick<AdminOptions, "
|
|
202
|
+
role?: InferAdminRolesFromOption<O & Required<Pick<AdminOptions, "adminRoles" | "defaultRole" | "bannedUserMessage">>> | InferAdminRolesFromOption<O & Required<Pick<AdminOptions, "adminRoles" | "defaultRole" | "bannedUserMessage">>>[] | undefined;
|
|
203
203
|
data?: Record<string, any> | undefined;
|
|
204
204
|
};
|
|
205
205
|
};
|
|
@@ -291,13 +291,13 @@ export declare const admin: <O extends AdminOptions>(options?: O | undefined) =>
|
|
|
291
291
|
filterField: import("zod").ZodOptional<import("zod").ZodString>;
|
|
292
292
|
filterValue: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, import("zod").ZodBoolean]>, import("zod").ZodArray<import("zod").ZodString>]>, import("zod").ZodArray<import("zod").ZodNumber>]>>;
|
|
293
293
|
filterOperator: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
294
|
-
in: "in";
|
|
295
|
-
lte: "lte";
|
|
296
294
|
eq: "eq";
|
|
297
295
|
ne: "ne";
|
|
298
296
|
lt: "lt";
|
|
297
|
+
lte: "lte";
|
|
299
298
|
gt: "gt";
|
|
300
299
|
gte: "gte";
|
|
300
|
+
in: "in";
|
|
301
301
|
not_in: "not_in";
|
|
302
302
|
contains: "contains";
|
|
303
303
|
starts_with: "starts_with";
|
|
@@ -839,9 +839,9 @@ export declare const admin: <O extends AdminOptions>(options?: O | undefined) =>
|
|
|
839
839
|
}>;
|
|
840
840
|
};
|
|
841
841
|
$ERROR_CODES: {
|
|
842
|
-
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
|
|
843
842
|
FAILED_TO_CREATE_USER: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"FAILED_TO_CREATE_USER">;
|
|
844
843
|
USER_ALREADY_EXISTS: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS">;
|
|
844
|
+
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
|
|
845
845
|
YOU_CANNOT_BAN_YOURSELF: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_CANNOT_BAN_YOURSELF">;
|
|
846
846
|
YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
|
|
847
847
|
YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { APIError, EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
1
3
|
import { mergeSchema } from "../../db/schema.mjs";
|
|
2
4
|
import { getEndpointResponse } from "../../utils/plugin-helper.mjs";
|
|
3
5
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
@@ -5,8 +7,6 @@ import { defaultRoles } from "./access/statement.mjs";
|
|
|
5
7
|
import { ADMIN_ERROR_CODES } from "./error-codes.mjs";
|
|
6
8
|
import { adminUpdateUser, banUser, createUser, getUser, impersonateUser, listUserSessions, listUsers, removeUser, revokeUserSession, revokeUserSessions, setRole, setUserPassword, stopImpersonating, unbanUser, userHasPermission } from "./routes.mjs";
|
|
7
9
|
import { schema } from "./schema.mjs";
|
|
8
|
-
import { APIError, EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
9
|
-
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
10
10
|
// src/plugins/admin/admin.ts
|
|
11
11
|
const admin = (options) => {
|
|
12
12
|
const opts = {
|
|
@@ -51,9 +51,9 @@ export declare const adminClient: <O extends AdminClientOptions>(options?: O | u
|
|
|
51
51
|
signal: "$sessionSignal";
|
|
52
52
|
}[];
|
|
53
53
|
$ERROR_CODES: {
|
|
54
|
-
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
|
|
55
54
|
FAILED_TO_CREATE_USER: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"FAILED_TO_CREATE_USER">;
|
|
56
55
|
USER_ALREADY_EXISTS: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS">;
|
|
56
|
+
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
|
|
57
57
|
YOU_CANNOT_BAN_YOURSELF: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_CANNOT_BAN_YOURSELF">;
|
|
58
58
|
YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
|
|
59
59
|
YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const ADMIN_ERROR_CODES: {
|
|
2
|
-
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
|
|
3
2
|
FAILED_TO_CREATE_USER: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"FAILED_TO_CREATE_USER">;
|
|
4
3
|
USER_ALREADY_EXISTS: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS">;
|
|
4
|
+
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL">;
|
|
5
5
|
YOU_CANNOT_BAN_YOURSELF: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_CANNOT_BAN_YOURSELF">;
|
|
6
6
|
YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE">;
|
|
7
7
|
YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS">;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
3
|
+
import { whereOperators } from "@entro314labs/entro-auth-core/db/adapter";
|
|
4
|
+
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
5
|
+
import * as z from "zod";
|
|
1
6
|
import { getAuthoritativeSessionFromCtx, getSessionFromCtx } from "../../api/routes/session.mjs";
|
|
2
7
|
import { deleteSessionCookie, expireCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
3
8
|
import { parseSessionOutput, parseUserOutput } from "../../db/schema.mjs";
|
|
@@ -7,11 +12,6 @@ import { withTwoFactorClaim } from "../two-factor/claim.mjs";
|
|
|
7
12
|
import { discardUnfinishedEnrollment, secondSteps, turnTwoFactorOff, twoFactorIsOn } from "../two-factor/verify-two-factor.mjs";
|
|
8
13
|
import { ADMIN_ERROR_CODES } from "./error-codes.mjs";
|
|
9
14
|
import { hasPermission } from "./has-permission.mjs";
|
|
10
|
-
import { runWithTransaction } from "@entro314labs/entro-auth-core/context";
|
|
11
|
-
import { APIError, BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
12
|
-
import { whereOperators } from "@entro314labs/entro-auth-core/db/adapter";
|
|
13
|
-
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
14
|
-
import * as z from "zod";
|
|
15
15
|
// src/plugins/admin/routes.ts
|
|
16
16
|
/**
|
|
17
17
|
* Ensures a valid session, if not will throw.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Session, User } from "../../types/models.mjs";
|
|
2
2
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
|
+
import { Awaitable } from "@entro314labs/entro-auth-core";
|
|
3
4
|
import "../../types/index.mjs";
|
|
4
5
|
import { AccessControl, Role } from "../access/types.mjs";
|
|
5
6
|
import "../access/index.mjs";
|
|
6
7
|
import { AdminSchema } from "./schema.mjs";
|
|
7
|
-
import { Awaitable } from "@entro314labs/entro-auth-core";
|
|
8
8
|
export interface UserWithRole extends User {
|
|
9
9
|
role?: string | undefined;
|
|
10
10
|
banned: boolean | null;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { formCsrfMiddleware } from "../../api/middlewares/origin-check.mjs";
|
|
2
|
+
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
3
|
+
import { createPlaceholderEmail } from "@entro314labs/entro-auth-core/utils/email";
|
|
4
|
+
import { generateId } from "@entro314labs/entro-auth-core/utils/id";
|
|
5
|
+
import * as z from "zod";
|
|
2
6
|
import { APIError } from "../../api/index.mjs";
|
|
3
7
|
import { parseSetCookieHeader } from "../../cookies/cookie-utils.mjs";
|
|
4
8
|
import { deleteSessionCookie, setSessionCookie } from "../../cookies/index.mjs";
|
|
@@ -8,10 +12,6 @@ import { mergeSchema, parseUserOutput } from "../../db/schema.mjs";
|
|
|
8
12
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
9
13
|
import { ANONYMOUS_ERROR_CODES } from "./error-codes.mjs";
|
|
10
14
|
import { schema } from "./schema.mjs";
|
|
11
|
-
import { generateId } from "@entro314labs/entro-auth-core/utils/id";
|
|
12
|
-
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
13
|
-
import * as z from "zod";
|
|
14
|
-
import { createPlaceholderEmail } from "@entro314labs/entro-auth-core/utils/email";
|
|
15
15
|
// src/plugins/anonymous/index.ts
|
|
16
16
|
/**
|
|
17
17
|
* Resolves the anonymous session being upgraded during an account-link callback.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Session, User } from "../../types/models.mjs";
|
|
2
2
|
import { InferOptionSchema } from "../../types/plugins.mjs";
|
|
3
|
-
import "../../types/index.mjs";
|
|
4
|
-
import { schema } from "./schema.mjs";
|
|
5
3
|
import { AuthContext, Awaitable, GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
6
4
|
import { EndpointContext } from "better-call";
|
|
5
|
+
import "../../types/index.mjs";
|
|
6
|
+
import { schema } from "./schema.mjs";
|
|
7
7
|
export type AnonymousSession = {
|
|
8
8
|
session: Session;
|
|
9
9
|
user: User;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { createHMAC } from "@better-auth/utils/hmac";
|
|
2
|
+
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
3
|
+
import { serializeSignedCookie } from "better-call";
|
|
1
4
|
import { parseSetCookieHeader, setRequestCookie } from "../../cookies/cookie-utils.mjs";
|
|
2
5
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
3
|
-
import { serializeSignedCookie } from "better-call";
|
|
4
|
-
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
5
|
-
import { createHMAC } from "@better-auth/utils/hmac";
|
|
6
6
|
// src/plugins/bearer/index.ts
|
|
7
7
|
const BEARER_SCHEME = "bearer ";
|
|
8
8
|
function tryDecode(str) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getIP } from "@entro314labs/entro-auth-core/utils/ip";
|
|
1
2
|
import { middlewareResponse } from "../../utils/middleware-response.mjs";
|
|
2
3
|
import { wildcardMatch } from "../../utils/wildcard.mjs";
|
|
3
4
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
@@ -8,7 +9,6 @@ import { cloudflareTurnstile } from "./verify-handlers/cloudflare-turnstile.mjs"
|
|
|
8
9
|
import { googleRecaptcha } from "./verify-handlers/google-recaptcha.mjs";
|
|
9
10
|
import { hCaptcha } from "./verify-handlers/h-captcha.mjs";
|
|
10
11
|
import { vercelBotId } from "./verify-handlers/vercel-botid.mjs";
|
|
11
|
-
import { getIP } from "@entro314labs/entro-auth-core/utils/ip";
|
|
12
12
|
// src/plugins/captcha/index.ts
|
|
13
13
|
const normalizeEndpointPath = (pathname, basePath) => {
|
|
14
14
|
let normalizedPathname = (pathname.startsWith(basePath) ? pathname.slice(basePath.length) : pathname).replace(/\/{2,}/g, "/");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { middlewareResponse } from "../../../utils/middleware-response.mjs";
|
|
2
3
|
import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
3
4
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
5
|
import { encodeToURLParams } from "../utils.mjs";
|
|
5
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
6
6
|
// src/plugins/captcha/verify-handlers/captchafox.ts
|
|
7
7
|
const captchaFox = async ({ siteVerifyURL, captchaResponse, secretKey, siteKey, remoteIP }) => {
|
|
8
8
|
const response = await betterFetch(siteVerifyURL, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { middlewareResponse } from "../../../utils/middleware-response.mjs";
|
|
2
3
|
import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
3
4
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
5
5
|
// src/plugins/captcha/verify-handlers/cloudflare-turnstile.ts
|
|
6
6
|
const cloudflareTurnstile = async ({ siteVerifyURL, captchaResponse, secretKey, logger, remoteIP, expectedAction, allowedHostnames }) => {
|
|
7
7
|
const response = await betterFetch(siteVerifyURL, {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { middlewareResponse } from "../../../utils/middleware-response.mjs";
|
|
2
3
|
import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
3
4
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
5
|
import { encodeToURLParams } from "../utils.mjs";
|
|
5
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
6
6
|
// src/plugins/captcha/verify-handlers/google-recaptcha.ts
|
|
7
7
|
const isV3 = (response) => {
|
|
8
8
|
return "score" in response && typeof response.score === "number";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { middlewareResponse } from "../../../utils/middleware-response.mjs";
|
|
2
3
|
import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
3
4
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
5
|
import { encodeToURLParams } from "../utils.mjs";
|
|
5
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
6
6
|
// src/plugins/captcha/verify-handlers/h-captcha.ts
|
|
7
7
|
const hCaptcha = async ({ siteVerifyURL, captchaResponse, secretKey, siteKey, remoteIP }) => {
|
|
8
8
|
const response = await betterFetch(siteVerifyURL, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EntroAuthOptions } from "../../types/index.mjs";
|
|
2
1
|
import { Auth } from "@entro314labs/entro-auth";
|
|
2
|
+
import { EntroAuthOptions } from "../../types/index.mjs";
|
|
3
3
|
export declare const customSessionClient: <A extends Auth | {
|
|
4
4
|
options: EntroAuthOptions;
|
|
5
5
|
}>() => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
1
2
|
import { getSession } from "../../api/routes/session.mjs";
|
|
2
3
|
import { parseSetCookieHeader, toCookieOptions } from "../../cookies/cookie-utils.mjs";
|
|
3
4
|
import { getSessionQuerySchema } from "../../cookies/session-store.mjs";
|
|
4
5
|
import { getEndpointResponse } from "../../utils/plugin-helper.mjs";
|
|
5
6
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
6
|
-
import { createAuthEndpoint, createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
7
7
|
// src/plugins/custom-session/index.ts
|
|
8
8
|
const customSession = (fn, options, pluginOptions) => {
|
|
9
9
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TimeString, ms, sec } from "../../utils/time.mjs";
|
|
2
|
-
import { DeviceCodeRedemptionAuthorization, DeviceCodeRedemptionPreparation, DeviceCodeRedemptionResult, assertDeviceCodePending, buildVerificationUris, decideDeviceCode, findDeviceCodeByUserCode, prepareDeviceCodeRedemption, redeemDeviceCode } from "./routes.mjs";
|
|
3
|
-
import { DeviceCode } from "./schema.mjs";
|
|
4
1
|
import { GenericEndpointContext, StandardSchemaV1 } from "@entro314labs/entro-auth-core";
|
|
5
2
|
import { DBFieldAttribute } from "@entro314labs/entro-auth-core/db";
|
|
6
3
|
import * as z from "zod";
|
|
4
|
+
import { TimeString, ms, sec } from "../../utils/time.mjs";
|
|
5
|
+
import { DeviceCodeRedemptionAuthorization, DeviceCodeRedemptionPreparation, DeviceCodeRedemptionResult, assertDeviceCodePending, buildVerificationUris, decideDeviceCode, findDeviceCodeByUserCode, prepareDeviceCodeRedemption, redeemDeviceCode } from "./routes.mjs";
|
|
6
|
+
import { DeviceCode } from "./schema.mjs";
|
|
7
7
|
declare module "@entro314labs/entro-auth-core" {
|
|
8
8
|
interface EntroAuthPluginRegistry<AuthOptions, Options> {
|
|
9
9
|
"device-authorization": {
|
|
@@ -154,7 +154,7 @@ export declare const deviceAuthorization: <Grant extends DeviceAuthorizationGran
|
|
|
154
154
|
deviceCode: import("better-call").StrictEndpoint<"/device/code", {
|
|
155
155
|
method: "POST";
|
|
156
156
|
cloneRequest: true;
|
|
157
|
-
body: z.ZodObject<(("scope" | "
|
|
157
|
+
body: z.ZodObject<(("scope" | "client_id" | "user_id") & keyof (Grant extends DeviceAuthorizationGrant<infer RequestFields extends Readonly<{
|
|
158
158
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
159
159
|
}>> ? RequestFields : Record<never, never>) extends never ? {
|
|
160
160
|
client_id: z.ZodString;
|
|
@@ -170,7 +170,7 @@ export declare const deviceAuthorization: <Grant extends DeviceAuthorizationGran
|
|
|
170
170
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
171
171
|
}>> ? RequestFields : Record<never, never>) ? never : K]: T_2[K]; } : never) & (((Grant extends DeviceAuthorizationGrant<infer RequestFields extends Readonly<{
|
|
172
172
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
173
|
-
}>> ? RequestFields : Record<never, never>) extends (infer T_4) ? { -readonly [P in keyof T_4]: T_4[P]; } : never) extends (infer T_3 extends z.core.util.SomeObject) ? { [K_1 in keyof T_3]: T_3[K_1]; } : never)) extends (infer T) ? { [k in keyof T]: T[k]; } : never, z.core.$strip> | z.ZodObject<(("scope" | "
|
|
173
|
+
}>> ? RequestFields : Record<never, never>) extends (infer T_4) ? { -readonly [P in keyof T_4]: T_4[P]; } : never) extends (infer T_3 extends z.core.util.SomeObject) ? { [K_1 in keyof T_3]: T_3[K_1]; } : never)) extends (infer T) ? { [k in keyof T]: T[k]; } : never, z.core.$strip> | z.ZodObject<(("scope" | "client_id" | "user_id") & keyof (Grant extends DeviceAuthorizationGrant<infer RequestFields extends Readonly<{
|
|
174
174
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
175
175
|
}>> ? RequestFields : Record<never, never>) extends never ? {
|
|
176
176
|
user_id: z.ZodOptional<z.ZodString>;
|
|
@@ -302,11 +302,11 @@ export declare const deviceAuthorization: <Grant extends DeviceAuthorizationGran
|
|
|
302
302
|
error: z.ZodObject<{
|
|
303
303
|
error: z.ZodEnum<{
|
|
304
304
|
invalid_request: "invalid_request";
|
|
305
|
-
expired_token: "expired_token";
|
|
306
|
-
access_denied: "access_denied";
|
|
307
305
|
invalid_client: "invalid_client";
|
|
308
306
|
authorization_pending: "authorization_pending";
|
|
309
307
|
slow_down: "slow_down";
|
|
308
|
+
expired_token: "expired_token";
|
|
309
|
+
access_denied: "access_denied";
|
|
310
310
|
invalid_grant: "invalid_grant";
|
|
311
311
|
}>;
|
|
312
312
|
error_description: z.ZodString;
|
|
@@ -503,7 +503,6 @@ export declare const deviceAuthorization: <Grant extends DeviceAuthorizationGran
|
|
|
503
503
|
}[];
|
|
504
504
|
$ERROR_CODES: {
|
|
505
505
|
USER_NOT_FOUND: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"USER_NOT_FOUND">;
|
|
506
|
-
FAILED_TO_CREATE_SESSION: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"FAILED_TO_CREATE_SESSION">;
|
|
507
506
|
INVALID_DEVICE_CODE: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_DEVICE_CODE">;
|
|
508
507
|
EXPIRED_DEVICE_CODE: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"EXPIRED_DEVICE_CODE">;
|
|
509
508
|
EXPIRED_USER_CODE: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"EXPIRED_USER_CODE">;
|
|
@@ -513,6 +512,7 @@ export declare const deviceAuthorization: <Grant extends DeviceAuthorizationGran
|
|
|
513
512
|
DEVICE_CODE_ALREADY_PROCESSED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"DEVICE_CODE_ALREADY_PROCESSED">;
|
|
514
513
|
DEVICE_CODE_NOT_CLAIMED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"DEVICE_CODE_NOT_CLAIMED">;
|
|
515
514
|
POLLING_TOO_FREQUENTLY: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"POLLING_TOO_FREQUENTLY">;
|
|
515
|
+
FAILED_TO_CREATE_SESSION: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"FAILED_TO_CREATE_SESSION">;
|
|
516
516
|
INVALID_DEVICE_CODE_STATUS: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"INVALID_DEVICE_CODE_STATUS">;
|
|
517
517
|
AUTHENTICATION_REQUIRED: import("@entro314labs/entro-auth-core/utils/error-codes").RawError<"AUTHENTICATION_REQUIRED">;
|
|
518
518
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
2
|
+
import * as z from "zod";
|
|
1
3
|
import { mergeSchema } from "../../db/schema.mjs";
|
|
2
4
|
import { ms } from "../../utils/time.mjs";
|
|
3
5
|
import { PACKAGE_VERSION } from "../../version.mjs";
|
|
4
6
|
import { DEVICE_AUTHORIZATION_ERROR_CODES } from "./error-codes.mjs";
|
|
5
7
|
import { assertDeviceCodePending, buildVerificationUris, decideDeviceCode, deviceCode, deviceDecisionEndpoint, deviceToken, deviceVerify, findDeviceCodeByUserCode, prepareDeviceCodeRedemption, redeemDeviceCode } from "./routes.mjs";
|
|
6
8
|
import { schema } from "./schema.mjs";
|
|
7
|
-
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
8
|
-
import * as z from "zod";
|
|
9
9
|
// src/plugins/device-authorization/index.ts
|
|
10
10
|
const timeStringSchema = z.custom((val) => {
|
|
11
11
|
if (typeof val !== "string") return false;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
2
|
+
import "zod";
|
|
1
3
|
import "../../types/index.mjs";
|
|
2
4
|
import { User } from "../../types/models.mjs";
|
|
3
5
|
import { Where } from "../../types/adapter.mjs";
|
|
4
6
|
import "./index.mjs";
|
|
5
7
|
import { DeviceCode } from "./schema.mjs";
|
|
6
|
-
import { GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
7
|
-
import "zod";
|
|
8
8
|
/**
|
|
9
9
|
* Preserve exact custom user codes, and normalize only default-alphabet codes.
|
|
10
10
|
*/
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
2
|
+
import { isUniqueViolation } from "@entro314labs/entro-auth-core/db/internal";
|
|
3
|
+
import { APIError } from "@entro314labs/entro-auth-core/error";
|
|
4
|
+
import * as z from "zod";
|
|
1
5
|
import { getAuthoritativeSessionFromCtx } from "../../api/routes/session.mjs";
|
|
2
6
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
3
7
|
import { ms } from "../../utils/time.mjs";
|
|
4
8
|
import { DEVICE_AUTHORIZATION_ERROR_CODES } from "./error-codes.mjs";
|
|
5
|
-
import
|
|
6
|
-
import { isUniqueViolation } from "@entro314labs/entro-auth-core/db/internal";
|
|
7
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
8
|
-
import * as z from "zod";
|
|
9
|
+
import "./schema.mjs";
|
|
9
10
|
// src/plugins/device-authorization/routes.ts
|
|
10
11
|
const defaultCharset = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
11
12
|
const MAX_DEVICE_CODE_GENERATION_ATTEMPTS = 3;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
1
2
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
2
3
|
import { getDate } from "../../utils/date.mjs";
|
|
3
4
|
import { getEndpointResponse } from "../../utils/plugin-helper.mjs";
|
|
@@ -6,7 +7,6 @@ import { EMAIL_OTP_ERROR_CODES } from "./error-codes.mjs";
|
|
|
6
7
|
import { storeOTP } from "./otp-token.mjs";
|
|
7
8
|
import { changeEmailEmailOTP, checkVerificationOTP, createVerificationOTP, forgetPasswordEmailOTP, getVerificationOTP, requestEmailChangeEmailOTP, requestPasswordResetEmailOTP, resetPasswordEmailOTP, sendVerificationOTP, signInEmailOTP, verifyEmailOTP } from "./routes.mjs";
|
|
8
9
|
import { toOTPIdentifier } from "./utils.mjs";
|
|
9
|
-
import { createAuthMiddleware } from "@entro314labs/entro-auth-core/api";
|
|
10
10
|
// src/plugins/email-otp/index.ts
|
|
11
11
|
const defaultOTPGenerator = (options) => generateRandomString(options.otpLength ?? 6, "0-9");
|
|
12
12
|
const emailOTP = (options) => {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { formCsrfMiddleware } from "../../api/middlewares/origin-check.mjs";
|
|
2
|
+
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
3
|
+
import { BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
4
|
+
import { deprecate } from "@entro314labs/entro-auth-core/utils/deprecate";
|
|
5
|
+
import * as z from "zod";
|
|
2
6
|
import { APIError as APIError$1 } from "../../api/index.mjs";
|
|
3
7
|
import { setCookieCache, setSessionCookie } from "../../cookies/index.mjs";
|
|
4
8
|
import { generateRandomString } from "../../crypto/random.mjs";
|
|
@@ -11,10 +15,6 @@ import { assertPasswordNotTooLong, assertPasswordNotTooShort, resetCredentialPas
|
|
|
11
15
|
import { EMAIL_OTP_ERROR_CODES } from "./error-codes.mjs";
|
|
12
16
|
import { storeOTP, tryReuseOTP, verifyStoredOTP } from "./otp-token.mjs";
|
|
13
17
|
import { splitAtLastColon, toOTPIdentifier } from "./utils.mjs";
|
|
14
|
-
import { BASE_ERROR_CODES } from "@entro314labs/entro-auth-core/error";
|
|
15
|
-
import { createAuthEndpoint } from "@entro314labs/entro-auth-core/api";
|
|
16
|
-
import { deprecate } from "@entro314labs/entro-auth-core/utils/deprecate";
|
|
17
|
-
import * as z from "zod";
|
|
18
18
|
// src/plugins/email-otp/routes.ts
|
|
19
19
|
const types = [
|
|
20
20
|
"email-verification",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AuthContext } from "@entro314labs/entro-auth-core";
|
|
2
|
+
import { OAuthProvider } from "@entro314labs/entro-auth-core/oauth2";
|
|
1
3
|
import { GenericOAuthConfig, GenericOAuthOptions, GenericOAuthUserInfo } from "./types.mjs";
|
|
2
4
|
import { Auth0Options, auth0 } from "./providers/auth0.mjs";
|
|
3
5
|
import { GumroadOptions, gumroad } from "./providers/gumroad.mjs";
|
|
@@ -10,8 +12,6 @@ import { PatreonOptions, patreon } from "./providers/patreon.mjs";
|
|
|
10
12
|
import { SlackOptions, slack } from "./providers/slack.mjs";
|
|
11
13
|
import { YandexOptions, yandex } from "./providers/yandex.mjs";
|
|
12
14
|
import "./providers/index.mjs";
|
|
13
|
-
import { AuthContext } from "@entro314labs/entro-auth-core";
|
|
14
|
-
import { OAuthProvider } from "@entro314labs/entro-auth-core/oauth2";
|
|
15
15
|
declare module "@entro314labs/entro-auth-core" {
|
|
16
16
|
interface EntroAuthPluginRegistry<AuthOptions, Options> {
|
|
17
17
|
"generic-oauth": {
|