@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
package/dist/cookies/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Session, User } from "../types/models.mjs";
|
|
2
|
-
import "../types/index.mjs";
|
|
3
|
-
import { CookieAttributes, HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, applySetCookies, cookieNameRegex, parseCookies, parseSetCookieHeader, setCookieToHeader, setRequestCookie, splitSetCookieHeader, stripSecureCookiePrefix, toCookieOptions } from "./cookie-utils.mjs";
|
|
4
|
-
import { createSessionStore, getAccountCookie, getChunkedCookie, setAccountCookie } from "./session-store.mjs";
|
|
5
2
|
import { Awaitable, CookieCachePayload, EntroAuthCookie, EntroAuthCookies, EntroAuthOptions, GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
6
3
|
import { CookieOptions } from "better-call";
|
|
7
4
|
import { JSONWebKeySet } from "jose";
|
|
5
|
+
import "../types/index.mjs";
|
|
6
|
+
import { CookieAttributes, HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, applySetCookies, cookieNameRegex, parseCookies, parseSetCookieHeader, setCookieToHeader, setRequestCookie, splitSetCookieHeader, stripSecureCookiePrefix, toCookieOptions } from "./cookie-utils.mjs";
|
|
7
|
+
import { createSessionStore, getAccountCookie, getChunkedCookie, setAccountCookie } from "./session-store.mjs";
|
|
8
8
|
export declare function createCookieGetter(options: EntroAuthOptions): (cookieName: string, overrideAttributes?: Partial<CookieOptions>) => {
|
|
9
9
|
name: string;
|
|
10
10
|
attributes: {
|
package/dist/cookies/index.mjs
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { base64Url } from "@better-auth/utils/base64";
|
|
2
|
+
import { binary } from "@better-auth/utils/binary";
|
|
3
|
+
import { createHMAC } from "@better-auth/utils/hmac";
|
|
4
|
+
import { env, isProduction } from "@entro314labs/entro-auth-core/env";
|
|
5
|
+
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
6
|
+
import { filterOutputFields } from "@entro314labs/entro-auth-core/utils/db";
|
|
7
|
+
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
1
8
|
import { shouldBindAccountCookieToSessionUser } from "../context/store-capabilities.mjs";
|
|
2
9
|
import { signJWT, symmetricDecodeJWT, symmetricEncodeJWT, verifyJWT } from "../crypto/jwt.mjs";
|
|
3
10
|
import { parseUserOutput } from "../db/schema.mjs";
|
|
@@ -9,13 +16,6 @@ import { parseCompactCookieCache, parseCookieCachePayload } from "./cache.mjs";
|
|
|
9
16
|
import { HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, applySetCookies, cookieNameRegex, parseCookies, parseSetCookieHeader, setCookieToHeader, setRequestCookie, splitSetCookieHeader, stripSecureCookiePrefix, toCookieOptions } from "./cookie-utils.mjs";
|
|
10
17
|
import { verifySessionCookieJwtWithJwks } from "./jwt.mjs";
|
|
11
18
|
import { createAccountStore, createSessionStore, getAccountCookie, getChunkedCookie, setAccountCookie } from "./session-store.mjs";
|
|
12
|
-
import { env, isProduction } from "@entro314labs/entro-auth-core/env";
|
|
13
|
-
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
14
|
-
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
15
|
-
import { base64Url } from "@better-auth/utils/base64";
|
|
16
|
-
import { binary } from "@better-auth/utils/binary";
|
|
17
|
-
import { createHMAC } from "@better-auth/utils/hmac";
|
|
18
|
-
import { filterOutputFields } from "@entro314labs/entro-auth-core/utils/db";
|
|
19
19
|
// src/cookies/index.ts
|
|
20
20
|
function createCookieGetter(options) {
|
|
21
21
|
const baseURLString = typeof options.baseURL === "string" ? options.baseURL : void 0;
|
package/dist/cookies/jwt.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { parseCookieCachePayload } from "./cache.mjs";
|
|
2
1
|
import { decodeProtectedHeader, importJWK, jwtVerify } from "jose";
|
|
2
|
+
import { parseCookieCachePayload } from "./cache.mjs";
|
|
3
3
|
// src/cookies/jwt.ts
|
|
4
4
|
const SESSION_COOKIE_JWT_TYPE = "entro-auth.session-cache+jwt";
|
|
5
5
|
const SESSION_COOKIE_JWT_AUDIENCE = "entro-auth:session-cache";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { symmetricDecodeJWT, symmetricEncodeJWT } from "../crypto/jwt.mjs";
|
|
2
|
-
import { parseCookies } from "./cookie-utils.mjs";
|
|
3
1
|
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
4
2
|
import { serializeCookie } from "better-call";
|
|
5
3
|
import * as z from "zod";
|
|
4
|
+
import { symmetricDecodeJWT, symmetricEncodeJWT } from "../crypto/jwt.mjs";
|
|
5
|
+
import { parseCookies } from "./cookie-utils.mjs";
|
|
6
6
|
// src/cookies/session-store.ts
|
|
7
7
|
/**
|
|
8
8
|
* Per-cookie byte ceiling.
|
|
@@ -52,7 +52,7 @@ function readExistingChunks(cookieName, ctx) {
|
|
|
52
52
|
*/
|
|
53
53
|
function chunkCookie(storeName, cookie, chunks, logger) {
|
|
54
54
|
const chunkSize = getMaxCookieValueSize(`${cookie.name}.99`, cookie.attributes);
|
|
55
|
-
const chunkCount = chunkSize > 0 ? Math.ceil(cookie.value.length / chunkSize) :
|
|
55
|
+
const chunkCount = chunkSize > 0 ? Math.ceil(cookie.value.length / chunkSize) : 1e400;
|
|
56
56
|
if (chunkCount <= 1) {
|
|
57
57
|
chunks[cookie.name] = cookie.value;
|
|
58
58
|
return [cookie];
|
package/dist/crypto/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { SecretConfig } from "@entro314labs/entro-auth-core";
|
|
1
2
|
import { deriveEncryptionKey } from "./purpose.mjs";
|
|
2
3
|
import { constantTimeEqual } from "./buffer.mjs";
|
|
3
4
|
import { signJWT, symmetricDecodeJWT, symmetricEncodeJWT, verifyJWT } from "./jwt.mjs";
|
|
4
5
|
import { hashPassword, verifyPassword } from "./password.mjs";
|
|
5
6
|
import { generateRandomString } from "./random.mjs";
|
|
6
|
-
import { SecretConfig } from "@entro314labs/entro-auth-core";
|
|
7
7
|
export declare function parseEnvelope(data: string): {
|
|
8
8
|
version: number;
|
|
9
9
|
ciphertext: string;
|
package/dist/crypto/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { getWebcryptoSubtle } from "@better-auth/utils";
|
|
2
|
+
import { createHash } from "@better-auth/utils/hash";
|
|
3
|
+
import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
4
|
+
import { bytesToHex, hexToBytes, managedNonce, utf8ToBytes } from "@noble/ciphers/utils.js";
|
|
1
5
|
import { deriveEncryptionKey } from "./purpose.mjs";
|
|
2
6
|
import { constantTimeEqual } from "./buffer.mjs";
|
|
3
7
|
import { signJWT, symmetricDecodeJWT, symmetricEncodeJWT, verifyJWT } from "./jwt.mjs";
|
|
4
8
|
import { hashPassword, verifyPassword } from "./password.mjs";
|
|
5
9
|
import { generateRandomString } from "./random.mjs";
|
|
6
|
-
import { getWebcryptoSubtle } from "@better-auth/utils";
|
|
7
|
-
import { createHash } from "@better-auth/utils/hash";
|
|
8
|
-
import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
9
|
-
import { bytesToHex, hexToBytes, managedNonce, utf8ToBytes } from "@noble/ciphers/utils.js";
|
|
10
10
|
// src/crypto/index.ts
|
|
11
11
|
const algorithm = {
|
|
12
12
|
name: "HMAC",
|
package/dist/crypto/jwt.mjs
CHANGED
|
@@ -128,8 +128,7 @@ async function symmetricDecodeJWT(token, secret, salt) {
|
|
|
128
128
|
const secrets = getAllSecrets(secret);
|
|
129
129
|
if (secrets.length <= 1) return null;
|
|
130
130
|
for (let i = 1; i < secrets.length; i++) try {
|
|
131
|
-
const
|
|
132
|
-
const encryptionSecret = deriveEncryptionSecret(s.value, salt);
|
|
131
|
+
const encryptionSecret = deriveEncryptionSecret(secrets[i].value, salt);
|
|
133
132
|
const { payload } = await jwtDecrypt(token, encryptionSecret, jwtDecryptOpts);
|
|
134
133
|
return payload;
|
|
135
134
|
} catch {
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `@better-auth/utils/password` uses the "node" export condition in package.json
|
|
3
|
+
* to automatically pick the right implementation:
|
|
4
|
+
* - Node.js / Bun / Deno → `node:crypto scrypt` (libuv thread pool, non-blocking)
|
|
5
|
+
* - Unsupported runtimes → `@noble/hashes scrypt` (pure JS fallback)
|
|
6
|
+
*/
|
|
7
|
+
import { hashPassword as hashPassword$1 } from "@better-auth/utils/password";
|
|
8
|
+
export declare const hashPassword: typeof hashPassword$1;
|
|
9
|
+
export declare const verifyPassword: ({ hash, password }: {
|
|
4
10
|
hash: string;
|
|
5
11
|
password: string;
|
|
6
|
-
}) => Promise<boolean>;
|
|
7
|
-
export { hashPassword$1 as hashPassword, verifyPassword$1 as verifyPassword };
|
|
12
|
+
}) => Promise<boolean>;
|
package/dist/crypto/password.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hashPassword, verifyPassword } from "@better-auth/utils/password";
|
|
1
|
+
import { hashPassword as hashPassword$1, verifyPassword as verifyPassword$1 } from "@better-auth/utils/password";
|
|
2
2
|
// src/crypto/password.ts
|
|
3
3
|
/**
|
|
4
4
|
* `@better-auth/utils/password` uses the "node" export condition in package.json
|
|
@@ -6,8 +6,8 @@ import { hashPassword, verifyPassword } from "@better-auth/utils/password";
|
|
|
6
6
|
* - Node.js / Bun / Deno → `node:crypto scrypt` (libuv thread pool, non-blocking)
|
|
7
7
|
* - Unsupported runtimes → `@noble/hashes scrypt` (pure JS fallback)
|
|
8
8
|
*/
|
|
9
|
-
const hashPassword
|
|
10
|
-
const verifyPassword
|
|
11
|
-
return verifyPassword(hash, password);
|
|
9
|
+
const hashPassword = hashPassword$1;
|
|
10
|
+
const verifyPassword = async ({ hash, password }) => {
|
|
11
|
+
return verifyPassword$1(hash, password);
|
|
12
12
|
};
|
|
13
|
-
export { hashPassword
|
|
13
|
+
export { hashPassword, verifyPassword };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getBaseAdapter } from "./adapter-base.mjs";
|
|
2
1
|
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
2
|
+
import { getBaseAdapter } from "./adapter-base.mjs";
|
|
3
3
|
// src/db/adapter-kysely.ts
|
|
4
4
|
async function getAdapter(options) {
|
|
5
5
|
return getBaseAdapter(options, async (opts) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EntroAuthOptions } from "@entro314labs/entro-auth-core";
|
|
2
2
|
import { DBFieldAttribute, DBFieldType } from "@entro314labs/entro-auth-core/db";
|
|
3
|
-
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
4
3
|
import { ResolvedDBTableIndex } from "@entro314labs/entro-auth-core/db/internal";
|
|
4
|
+
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
5
5
|
import { KyselyDatabaseType } from "@entro314labs/entro-auth-kysely-adapter";
|
|
6
6
|
/**
|
|
7
7
|
* Thrown when {@link getMigrations} refuses to add a required column with no
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { buildSchema } from "./get-schema.mjs";
|
|
2
|
-
import { createLogger } from "@entro314labs/entro-auth-core/env";
|
|
3
|
-
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
4
1
|
import { initGetFieldName, initGetModelName } from "@entro314labs/entro-auth-core/db/adapter";
|
|
5
2
|
import { diffSchema, formatSchemaFinding, getDatabaseFieldIndexName, getDatabaseIndexStringLength, getPortableDatabaseIdentifierKey, invalidateSchemaChecks } from "@entro314labs/entro-auth-core/db/internal";
|
|
3
|
+
import { createLogger } from "@entro314labs/entro-auth-core/env";
|
|
4
|
+
import { EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
6
5
|
import { createKyselyAdapter, getMssqlSchema, getPostgresSchema, introspectPostgresTables, toIntrospectedTables, toPhysicalSchema } from "@entro314labs/entro-auth-kysely-adapter";
|
|
7
6
|
import { sql } from "kysely";
|
|
7
|
+
import { buildSchema } from "./get-schema.mjs";
|
|
8
8
|
// src/db/get-migration.ts
|
|
9
9
|
const map = {
|
|
10
10
|
postgres: {
|
|
@@ -448,9 +448,9 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
|
|
|
448
448
|
const tableData = {
|
|
449
449
|
table: key,
|
|
450
450
|
fields: value.fields,
|
|
451
|
-
order: value.order ||
|
|
451
|
+
order: value.order || 1e400
|
|
452
452
|
};
|
|
453
|
-
const insertIndex = toBeCreated.findIndex((t) => (t.order ||
|
|
453
|
+
const insertIndex = toBeCreated.findIndex((t) => (t.order || 1e400) > tableData.order);
|
|
454
454
|
if (insertIndex === -1) {
|
|
455
455
|
if (tIndex === -1) toBeCreated.push(tableData);
|
|
456
456
|
else toBeCreated[tIndex].fields = {
|
|
@@ -474,7 +474,7 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
|
|
|
474
474
|
if (Object.keys(toBeAddedFields).length > 0) toBeAdded.push({
|
|
475
475
|
table: key,
|
|
476
476
|
fields: toBeAddedFields,
|
|
477
|
-
order: value.order ||
|
|
477
|
+
order: value.order || 1e400
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
480
|
const migrations = [];
|
package/dist/db/get-schema.mjs
CHANGED
package/dist/db/index.mjs
CHANGED
|
@@ -28,7 +28,7 @@ var db_exports = /* @__PURE__ */ __exportAll({
|
|
|
28
28
|
parseUserOutput: () => parseUserOutput,
|
|
29
29
|
revokeUnprovenAccountAccess: () => revokeUnprovenAccountAccess,
|
|
30
30
|
toZodSchema: () => toZodSchema
|
|
31
|
-
});
|
|
31
|
+
}, 2);
|
|
32
32
|
import * as import__entro314labs_entro_auth_core_db from "@entro314labs/entro-auth-core/db";
|
|
33
33
|
__reExport(db_exports, import__entro314labs_entro_auth_core_db);
|
|
34
34
|
export { buildSyntheticUserOutput, convertFromDB, convertToDB, createInternalAdapter, db_exports, getSchema, getSessionDefaultFields, getWithHooks, mergeSchema, parseAccountInput, parseAccountOutput, parseAdditionalUserInput, parseAdditionalUserInputFromProviderProfile, parseInputData, parseSessionInput, parseSessionOutput, parseUserInput, parseUserOutput, revokeUnprovenAccountAccess, toZodSchema };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DatabaseHooksEntry } from "./with-hooks.mjs";
|
|
2
1
|
import { AuthContext, EntroAuthOptions, InternalAdapter } from "@entro314labs/entro-auth-core";
|
|
3
|
-
import { InternalLogger } from "@entro314labs/entro-auth-core/env";
|
|
4
2
|
import { DBAdapter } from "@entro314labs/entro-auth-core/db/adapter";
|
|
3
|
+
import { InternalLogger } from "@entro314labs/entro-auth-core/env";
|
|
4
|
+
import { DatabaseHooksEntry } from "./with-hooks.mjs";
|
|
5
5
|
export declare const createInternalAdapter: (adapter: DBAdapter<EntroAuthOptions>, ctx: {
|
|
6
6
|
options: Omit<EntroAuthOptions, "logger">;
|
|
7
7
|
logger: InternalLogger;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { assertValidUserInfo, assertValidUserInfoSource } from "../utils/validate-user-info.mjs";
|
|
3
|
-
import { getSessionDefaultFields, parseSessionOutput, parseUserOutput } from "./schema.mjs";
|
|
4
|
-
import { getStorageOption, processIdentifier } from "./verification-token-storage.mjs";
|
|
5
|
-
import { getWithHooks } from "./with-hooks.mjs";
|
|
1
|
+
import { createHash } from "@better-auth/utils/hash";
|
|
6
2
|
import { getCurrentAdapter, getCurrentAuthEndpointContext, queueAfterTransactionHook, runWithTransaction, tryGetCurrentAuthEndpointContext } from "@entro314labs/entro-auth-core/context";
|
|
3
|
+
import { encodeDeterministicId } from "@entro314labs/entro-auth-core/db/internal";
|
|
7
4
|
import { isWorkerd } from "@entro314labs/entro-auth-core/env";
|
|
8
5
|
import { APIError, BASE_ERROR_CODES, EntroAuthError } from "@entro314labs/entro-auth-core/error";
|
|
9
6
|
import { generateId } from "@entro314labs/entro-auth-core/utils/id";
|
|
10
|
-
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
11
|
-
import { encodeDeterministicId } from "@entro314labs/entro-auth-core/db/internal";
|
|
12
7
|
import { getIP } from "@entro314labs/entro-auth-core/utils/ip";
|
|
13
|
-
import {
|
|
8
|
+
import { safeJSONParse } from "@entro314labs/entro-auth-core/utils/json";
|
|
9
|
+
import { getDate } from "../utils/date.mjs";
|
|
10
|
+
import { assertValidUserInfo, assertValidUserInfoSource } from "../utils/validate-user-info.mjs";
|
|
11
|
+
import { getSessionDefaultFields, parseSessionOutput, parseUserOutput } from "./schema.mjs";
|
|
12
|
+
import { getStorageOption, processIdentifier } from "./verification-token-storage.mjs";
|
|
13
|
+
import { getWithHooks } from "./with-hooks.mjs";
|
|
14
14
|
// src/db/internal-adapter.ts
|
|
15
15
|
function getTTLSeconds(expiresAt, now = Date.now()) {
|
|
16
16
|
const expiresMs = typeof expiresAt === "number" ? expiresAt : expiresAt.getTime();
|
|
@@ -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
|
/**
|
|
5
5
|
* Strip every account link and session a pre-existing account accrued before
|
|
6
6
|
* control of its email was proven.
|
package/dist/db/schema.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Account, Session as Session$1, User as User$1 } from "../types/models.mjs";
|
|
2
|
-
import "../types/index.mjs";
|
|
3
2
|
import { EntroAuthOptions } from "@entro314labs/entro-auth-core";
|
|
4
3
|
import { DBFieldAttribute, EntroAuthPluginDBSchema } from "@entro314labs/entro-auth-core/db";
|
|
4
|
+
import "../types/index.mjs";
|
|
5
5
|
export declare function parseUserOutput<T extends User$1>(options: EntroAuthOptions, user: T): T;
|
|
6
6
|
/**
|
|
7
7
|
* Builds a synthetic user object that matches the shape of a real user
|
|
@@ -17,7 +17,7 @@ export declare function parseUserOutput<T extends User$1>(options: EntroAuthOpti
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function buildSyntheticUserOutput(options: EntroAuthOptions, data: Record<string, unknown>): Record<string, unknown>;
|
|
19
19
|
export declare function parseSessionOutput<T extends Session$1>(options: EntroAuthOptions, session: T): T;
|
|
20
|
-
export declare function parseAccountOutput<T extends Account>(options: EntroAuthOptions, account: T): Omit<T, "
|
|
20
|
+
export declare function parseAccountOutput<T extends Account>(options: EntroAuthOptions, account: T): Omit<T, "password" | "accessToken" | "refreshToken" | "idToken" | "accessTokenExpiresAt" | "refreshTokenExpiresAt">;
|
|
21
21
|
export declare function parseInputData<T extends Record<string, any>>(data: T, schema: {
|
|
22
22
|
fields: Record<string, DBFieldAttribute>;
|
|
23
23
|
action?: ("create" | "update") | undefined;
|
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
|
};
|
|
@@ -273,8 +273,8 @@ export declare const admin: <O extends AdminOptions>(options?: O | undefined) =>
|
|
|
273
273
|
query: import("zod").ZodObject<{
|
|
274
274
|
searchValue: import("zod").ZodOptional<import("zod").ZodString>;
|
|
275
275
|
searchField: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
276
|
-
name: "name";
|
|
277
276
|
email: "email";
|
|
277
|
+
name: "name";
|
|
278
278
|
}>>;
|
|
279
279
|
searchOperator: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
280
280
|
contains: "contains";
|
|
@@ -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;
|