@entro314labs/entro-auth-core 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/api/index.d.mts +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/context/endpoint-context.d.mts +2 -2
- package/dist/context/endpoint-context.mjs +1 -1
- package/dist/context/global.d.mts +1 -1
- package/dist/context/global.mjs +1 -1
- package/dist/context/request-state.mjs +1 -1
- package/dist/context/transaction.d.mts +1 -1
- package/dist/context/transaction.mjs +1 -1
- package/dist/db/adapter/atomic-fallback.mjs +1 -1
- package/dist/db/adapter/factory.mjs +1 -1
- package/dist/db/adapter/get-id-field.mjs +2 -2
- package/dist/db/database-index.mjs +1 -1
- package/dist/db/schema/account.d.mts +1 -1
- package/dist/db/schema/account.mjs +1 -1
- package/dist/db/schema/rate-limit.d.mts +1 -1
- package/dist/db/schema/session.d.mts +1 -1
- package/dist/db/schema/session.mjs +1 -1
- package/dist/db/schema/user.d.mts +1 -1
- package/dist/db/schema/user.mjs +1 -1
- package/dist/db/schema/verification.d.mts +1 -1
- package/dist/db/schema/verification.mjs +1 -1
- package/dist/db/schema-check.d.mts +6 -0
- package/dist/db/type.d.mts +1 -1
- package/dist/error/index.d.mts +1 -1
- package/dist/error/index.mjs +1 -1
- package/dist/instrumentation/noop.mjs +1 -2
- package/dist/instrumentation/pure.index.d.mts +11 -0
- package/dist/instrumentation/tracer.mjs +1 -1
- package/dist/oauth2/authorization-params.mjs +1 -1
- package/dist/oauth2/client-credentials-token.d.mts +1 -1
- package/dist/oauth2/dpop.d.mts +1 -1
- package/dist/oauth2/dpop.mjs +1 -1
- package/dist/oauth2/oauth-provider.d.mts +1 -1
- package/dist/oauth2/pushed-authorization-request.d.mts +1 -1
- package/dist/oauth2/refresh-access-token.d.mts +1 -1
- package/dist/oauth2/reject-redirects.mjs +1 -1
- package/dist/oauth2/validate-authorization-code.d.mts +3 -3
- package/dist/oauth2/verify-id-token.d.mts +3 -1
- package/dist/oauth2/verify.d.mts +1 -1
- package/dist/oauth2/verify.mjs +2 -2
- package/dist/social-providers/apple.d.mts +2 -2
- package/dist/social-providers/apple.mjs +1 -1
- package/dist/social-providers/atlassian.mjs +1 -1
- package/dist/social-providers/cloudflare.mjs +1 -1
- package/dist/social-providers/cognito.d.mts +2 -2
- package/dist/social-providers/cognito.mjs +2 -2
- package/dist/social-providers/discord.mjs +1 -1
- package/dist/social-providers/dropbox.mjs +1 -1
- package/dist/social-providers/facebook.d.mts +1 -8
- package/dist/social-providers/facebook.mjs +2 -2
- package/dist/social-providers/figma.mjs +1 -1
- package/dist/social-providers/github.mjs +1 -1
- package/dist/social-providers/gitlab.mjs +1 -1
- package/dist/social-providers/google.d.mts +2 -2
- package/dist/social-providers/google.mjs +1 -1
- package/dist/social-providers/huggingface.mjs +1 -1
- package/dist/social-providers/index.d.mts +7 -21
- package/dist/social-providers/index.mjs +1 -1
- package/dist/social-providers/kakao.d.mts +1 -8
- package/dist/social-providers/kakao.mjs +2 -2
- package/dist/social-providers/kick.mjs +1 -1
- package/dist/social-providers/line.mjs +2 -2
- package/dist/social-providers/linear.mjs +1 -1
- package/dist/social-providers/linkedin.mjs +1 -1
- package/dist/social-providers/microsoft-entra-id.d.mts +2 -2
- package/dist/social-providers/microsoft-entra-id.mjs +3 -3
- package/dist/social-providers/naver.mjs +1 -1
- package/dist/social-providers/notion.mjs +1 -1
- package/dist/social-providers/paybin.mjs +2 -2
- package/dist/social-providers/paypal.mjs +2 -2
- package/dist/social-providers/polar.mjs +1 -1
- package/dist/social-providers/railway.mjs +1 -1
- package/dist/social-providers/reddit.mjs +1 -1
- package/dist/social-providers/roblox.mjs +1 -1
- package/dist/social-providers/salesforce.mjs +1 -1
- package/dist/social-providers/slack.mjs +1 -1
- package/dist/social-providers/spotify.mjs +1 -1
- package/dist/social-providers/tiktok.mjs +1 -1
- package/dist/social-providers/twitch.mjs +2 -2
- package/dist/social-providers/twitter.mjs +1 -1
- package/dist/social-providers/vercel.mjs +1 -1
- package/dist/social-providers/vk.mjs +1 -1
- package/dist/social-providers/wechat.mjs +1 -1
- package/dist/social-providers/zoom.mjs +1 -1
- package/dist/types/context.d.mts +1 -1
- package/dist/types/cookie.d.mts +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/types/init-options.d.mts +4 -4
- package/dist/types/plugin-client.d.mts +2 -2
- package/dist/types/plugin.d.mts +2 -2
- package/dist/utils/host.mjs +1 -1
- package/dist/utils/ip.mjs +1 -1
- package/dist/utils/is-api-error.mjs +1 -1
- package/dist/utils/redirect-uri.mjs +1 -1
- package/package.json +16 -16
package/dist/api/index.d.mts
CHANGED
|
@@ -6,8 +6,8 @@ import { SchemaCheck } from "../db/schema-check.mjs";
|
|
|
6
6
|
import { AuthContext } from "../types/context.mjs";
|
|
7
7
|
import "../db/index.mjs";
|
|
8
8
|
import { OAuthProvider } from "../oauth2/oauth-provider.mjs";
|
|
9
|
-
import "../types/index.mjs";
|
|
10
9
|
import { EndpointHandler, EndpointOptions, MiddlewareHandler, StrictEndpoint } from "better-call";
|
|
10
|
+
import "../types/index.mjs";
|
|
11
11
|
/**
|
|
12
12
|
* Response headers that forbid any intermediary (proxy, CDN, browser) from
|
|
13
13
|
* caching a response body. Credential-bearing responses (access/refresh tokens,
|
package/dist/api/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createEndpoint, createMiddleware, kAPIErrorHeaderSymbol } from "better-call";
|
|
1
2
|
import { runWithEndpointContext } from "../context/endpoint-context.mjs";
|
|
2
3
|
import { isAPIError } from "../utils/is-api-error.mjs";
|
|
3
|
-
import { createEndpoint, createMiddleware, kAPIErrorHeaderSymbol } from "better-call";
|
|
4
4
|
// src/api/index.ts
|
|
5
5
|
/**
|
|
6
6
|
* Response headers that forbid any intermediary (proxy, CDN, browser) from
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthContext } from "../types/context.mjs";
|
|
2
|
-
import "../types/index.mjs";
|
|
3
|
-
import { EndpointContext, InputContext } from "better-call";
|
|
4
2
|
import { AsyncLocalStorage } from "@entro314labs/entro-auth-core/async_hooks";
|
|
3
|
+
import { EndpointContext, InputContext } from "better-call";
|
|
4
|
+
import "../types/index.mjs";
|
|
5
5
|
export type AuthEndpointContext = Partial<InputContext<string, any> & EndpointContext<string, any>> & {
|
|
6
6
|
context: AuthContext;
|
|
7
7
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __getCurrentEndpointContext, __getEntroAuthGlobal } from "./global.mjs";
|
|
2
1
|
import { getAsyncLocalStorage } from "@entro314labs/entro-auth-core/async_hooks";
|
|
2
|
+
import { __getCurrentEndpointContext, __getEntroAuthGlobal } from "./global.mjs";
|
|
3
3
|
// src/context/endpoint-context.ts
|
|
4
4
|
const getExistingEndpointContextStorage = () => {
|
|
5
5
|
return __getEntroAuthGlobal().context.endpointContextAsyncStorage;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@entro314labs/entro-auth-core/async_hooks";
|
|
2
2
|
export declare function getEntroAuthVersion(): string;
|
package/dist/context/global.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __getEntroAuthGlobal } from "./global.mjs";
|
|
2
1
|
import { getAsyncLocalStorage } from "@entro314labs/entro-auth-core/async_hooks";
|
|
2
|
+
import { __getEntroAuthGlobal } from "./global.mjs";
|
|
3
3
|
// src/context/request-state.ts
|
|
4
4
|
const ensureAsyncStorage = async () => {
|
|
5
5
|
const entroAuthGlobal = __getEntroAuthGlobal();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "@entro314labs/entro-auth-core/async_hooks";
|
|
1
2
|
import { DBAdapter, DBTransactionAdapter } from "../db/adapter/index.mjs";
|
|
2
3
|
import { EntroAuthOptions } from "../types/init-options.mjs";
|
|
3
4
|
import "../types/index.mjs";
|
|
4
|
-
import { AsyncLocalStorage } from "@entro314labs/entro-auth-core/async_hooks";
|
|
5
5
|
type StoredAdapter = DBTransactionAdapter<EntroAuthOptions>;
|
|
6
6
|
type HookContext = {
|
|
7
7
|
adapter: StoredAdapter;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getAsyncLocalStorage } from "@entro314labs/entro-auth-core/async_hooks";
|
|
1
2
|
import { runtimeSchemaCheckFor } from "../db/schema-check.mjs";
|
|
2
3
|
import { logger } from "../env/logger.mjs";
|
|
3
4
|
import { __getEntroAuthGlobal } from "./global.mjs";
|
|
4
|
-
import { getAsyncLocalStorage } from "@entro314labs/entro-auth-core/async_hooks";
|
|
5
5
|
// src/context/transaction.ts
|
|
6
6
|
const ensureAsyncStorage = async () => {
|
|
7
7
|
const entroAuthGlobal = __getEntroAuthGlobal();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME, createWithSpan } from "@entro314labs/entro-auth-core/instrumentation";
|
|
1
2
|
import { TTY_COLORS, createLogger } from "../../env/logger.mjs";
|
|
2
3
|
import { getColorDepth } from "../../env/color-depth.mjs";
|
|
3
4
|
import { EntroAuthError } from "../../error/index.mjs";
|
|
@@ -11,7 +12,6 @@ import { initGetFieldName } from "./get-field-name.mjs";
|
|
|
11
12
|
import { initGetIdField } from "./get-id-field.mjs";
|
|
12
13
|
import { initGetModelName } from "./get-model-name.mjs";
|
|
13
14
|
import { withApplyDefault } from "./utils.mjs";
|
|
14
|
-
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_OPERATION_NAME, createWithSpan } from "@entro314labs/entro-auth-core/instrumentation";
|
|
15
15
|
// src/db/adapter/factory.ts
|
|
16
16
|
let debugLogs = [];
|
|
17
17
|
let transactionId = -1;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { base64Url } from "@better-auth/utils/base64";
|
|
2
|
+
import { hex } from "@better-auth/utils/hex";
|
|
1
3
|
import { logger } from "../../env/logger.mjs";
|
|
2
4
|
import { generateId } from "../../utils/id.mjs";
|
|
3
5
|
import { initGetDefaultModelName } from "./get-default-model-name.mjs";
|
|
4
|
-
import { base64Url } from "@better-auth/utils/base64";
|
|
5
|
-
import { hex } from "@better-auth/utils/hex";
|
|
6
6
|
// src/db/adapter/get-id-field.ts
|
|
7
7
|
let warnedSerialDeterministicId = false;
|
|
8
8
|
/**
|
|
@@ -20,7 +20,7 @@ function truncateUtf8(value, maxBytes) {
|
|
|
20
20
|
return result;
|
|
21
21
|
}
|
|
22
22
|
function getStableIndexNameHash(value) {
|
|
23
|
-
let hash =
|
|
23
|
+
let hash = 0x811c9dc5;
|
|
24
24
|
for (let index = 0; index < value.length; index++) {
|
|
25
25
|
hash ^= value.charCodeAt(index);
|
|
26
26
|
hash = Math.imul(hash, 16777619);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
1
2
|
import "../../types/index.mjs";
|
|
2
3
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
4
|
import { EntroAuthOptions } from "../../types/init-options.mjs";
|
|
4
5
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
5
|
-
import * as z from "zod";
|
|
6
6
|
export declare const accountSchema: z.ZodObject<{
|
|
7
7
|
id: z.ZodString;
|
|
8
8
|
createdAt: z.ZodDefault<z.ZodDate>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
1
2
|
import "../../types/index.mjs";
|
|
2
3
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
4
|
import { EntroAuthOptions } from "../../types/init-options.mjs";
|
|
4
5
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
5
|
-
import * as z from "zod";
|
|
6
6
|
export declare const rateLimitSchema: z.ZodObject<{
|
|
7
7
|
key: z.ZodString;
|
|
8
8
|
count: z.ZodNumber;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
1
2
|
import "../../types/index.mjs";
|
|
2
3
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
4
|
import { EntroAuthOptions } from "../../types/init-options.mjs";
|
|
4
5
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
5
|
-
import * as z from "zod";
|
|
6
6
|
export declare const sessionSchema: z.ZodObject<{
|
|
7
7
|
id: z.ZodString;
|
|
8
8
|
createdAt: z.ZodDefault<z.ZodDate>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
1
2
|
import "../../types/index.mjs";
|
|
2
3
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
4
|
import { EntroAuthOptions } from "../../types/init-options.mjs";
|
|
4
5
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
5
|
-
import * as z from "zod";
|
|
6
6
|
export declare const userSchema: z.ZodObject<{
|
|
7
7
|
id: z.ZodString;
|
|
8
8
|
createdAt: z.ZodDefault<z.ZodDate>;
|
package/dist/db/schema/user.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
1
2
|
import "../../types/index.mjs";
|
|
2
3
|
import { Prettify } from "../../types/helper.mjs";
|
|
3
4
|
import { EntroAuthOptions } from "../../types/init-options.mjs";
|
|
4
5
|
import { InferDBFieldsFromOptions, InferDBFieldsFromPlugins } from "../type.mjs";
|
|
5
|
-
import * as z from "zod";
|
|
6
6
|
export declare const verificationSchema: z.ZodObject<{
|
|
7
7
|
id: z.ZodString;
|
|
8
8
|
createdAt: z.ZodDefault<z.ZodDate>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal schema validation infrastructure for built-in adapters.
|
|
3
|
+
*
|
|
4
|
+
* Intended to become a public core extension point for community database
|
|
5
|
+
* adapter authors once the registration and lifecycle contracts are stabilized.
|
|
6
|
+
*/
|
|
1
7
|
import { Awaitable } from "../types/helper.mjs";
|
|
2
8
|
import { EntroAuthOptions } from "../types/init-options.mjs";
|
|
3
9
|
import "../types/index.mjs";
|
package/dist/db/type.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Awaitable, LiteralString, UnionToIntersection } from "../types/helper.mjs";
|
|
2
2
|
import { EntroAuthOptions } from "../types/init-options.mjs";
|
|
3
|
-
import "../types/index.mjs";
|
|
4
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
+
import "../types/index.mjs";
|
|
5
5
|
export type BaseModelNames = "user" | "account" | "session" | "verification";
|
|
6
6
|
export type ModelNames<T extends string = LiteralString> = BaseModelNames | T | "rate-limit";
|
|
7
7
|
export type InferDBValueType<T extends DBFieldType> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "date" ? Date : T extends "json" ? Record<string, any> : T extends `${infer U}[]` ? U extends "string" ? string[] : number[] : T extends Array<any> ? T[number] : never;
|
package/dist/error/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { APIError as APIError$1 } from "better-call/error";
|
|
1
2
|
import { RawError } from "../utils/error-codes.mjs";
|
|
2
3
|
import { APIErrorCode, BASE_ERROR_CODES } from "./codes.mjs";
|
|
3
|
-
import { APIError as APIError$1 } from "better-call/error";
|
|
4
4
|
export declare class EntroAuthError extends Error {
|
|
5
5
|
constructor(message: string, options?: {
|
|
6
6
|
cause?: unknown | undefined;
|
package/dist/error/index.mjs
CHANGED
|
@@ -13,8 +13,7 @@ function createNoopSpan() {
|
|
|
13
13
|
}
|
|
14
14
|
function createNoopTracer(noopSpan) {
|
|
15
15
|
function startActiveSpan(_name, ...rest) {
|
|
16
|
-
|
|
17
|
-
return fn(noopSpan);
|
|
16
|
+
return (0, rest[rest.length - 1])(noopSpan);
|
|
18
17
|
}
|
|
19
18
|
return { startActiveSpan };
|
|
20
19
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noop variant of `./instrumentation` for runtimes where the dynamic
|
|
3
|
+
* `import("@opentelemetry/api")` in `./api` throws synchronously instead of
|
|
4
|
+
* rejecting its returned promise. Convex's V8 isolate is the reproducer: bare
|
|
5
|
+
* specifiers are rejected at resolve time in `get-convex/convex-backend`
|
|
6
|
+
* `crates/isolate/src/request_scope.rs`, so the `.catch()` in
|
|
7
|
+
* `getOpenTelemetryAPI` never runs and every `withSpan` call surfaces an
|
|
8
|
+
* uncaught error.
|
|
9
|
+
*
|
|
10
|
+
* Public surface must stay identical to `./index` (enforced by `pure.test.ts`).
|
|
11
|
+
*/
|
|
1
12
|
import { EntroAuthOptions } from "../types/init-options.mjs";
|
|
2
13
|
import "../types/index.mjs";
|
|
3
14
|
import { noopWithSpan } from "./noop.mjs";
|
|
@@ -3,7 +3,7 @@ import { ATTR_HTTP_RESPONSE_STATUS_CODE } from "./attributes.mjs";
|
|
|
3
3
|
import { noopWithSpan } from "./noop.mjs";
|
|
4
4
|
// src/instrumentation/tracer.ts
|
|
5
5
|
const INSTRUMENTATION_SCOPE = "entro-auth";
|
|
6
|
-
const INSTRUMENTATION_VERSION = "1.8.0-beta.
|
|
6
|
+
const INSTRUMENTATION_VERSION = "1.8.0-beta.13";
|
|
7
7
|
/**
|
|
8
8
|
* Entro-auth uses `throw ctx.redirect(url)` for flow control (e.g. OAuth
|
|
9
9
|
* callbacks). These are APIErrors with 3xx status codes and should not be
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RESERVED_AUTHORIZATION_PARAMS, RESERVED_AUTHORIZATION_PARAMS_SET } from "./create-authorization-url.mjs";
|
|
2
1
|
import * as z from "zod";
|
|
2
|
+
import { RESERVED_AUTHORIZATION_PARAMS, RESERVED_AUTHORIZATION_PARAMS_SET } from "./create-authorization-url.mjs";
|
|
3
3
|
// src/oauth2/authorization-params.ts
|
|
4
4
|
/**
|
|
5
5
|
* Zod schema for the `additionalParams` field on social sign-in and
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AwaitableFunction } from "../types/helper.mjs";
|
|
2
|
+
import { BetterFetchOption } from "@better-fetch/fetch";
|
|
2
3
|
import "../types/index.mjs";
|
|
3
4
|
import { OAuth2Tokens, ProviderOptions } from "./oauth-provider.mjs";
|
|
4
5
|
import { TokenEndpointAuth, TokenEndpointSecretAuthentication } from "./token-endpoint-auth.mjs";
|
|
5
|
-
import { BetterFetchOption } from "@better-fetch/fetch";
|
|
6
6
|
interface ClientCredentialsTokenRequestInput {
|
|
7
7
|
options: AwaitableFunction<ProviderOptions>;
|
|
8
8
|
scope?: string | undefined;
|
package/dist/oauth2/dpop.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { JWK, JWTPayload } from "jose";
|
|
1
2
|
import { SecondaryStorage } from "../db/type.mjs";
|
|
2
3
|
import { AccessTokenAuthorization, AccessTokenAuthorizationScheme, BEARER_AUTHORIZATION_SCHEME, DPOP_AUTHORIZATION_SCHEME, DPOP_NONCE_HEADER, DPOP_PROOF_TYPE, DPOP_SIGNING_ALGORITHMS, DpopSigningAlgorithm, deriveDpopAth, normalizeDpopHtu, parseAccessTokenAuthorization, stripAccessTokenAuthorizationScheme } from "./dpop-protocol.mjs";
|
|
3
|
-
import { JWK, JWTPayload } from "jose";
|
|
4
4
|
/**
|
|
5
5
|
* `use_dpop_nonce` means the proof was otherwise valid but lacked a current
|
|
6
6
|
* server-provided nonce (RFC 9449 §8, §9); the client retries with the nonce
|
package/dist/oauth2/dpop.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BEARER_AUTHORIZATION_SCHEME, DPOP_AUTHORIZATION_SCHEME, DPOP_NONCE_HEADER, DPOP_PROOF_TYPE, DPOP_SIGNING_ALGORITHMS, deriveDpopAth, normalizeDpopHtu, parseAccessTokenAuthorization, stripAccessTokenAuthorizationScheme } from "./dpop-protocol.mjs";
|
|
2
1
|
import { base64url, calculateJwkThumbprint, decodeJwt, decodeProtectedHeader, importJWK, jwtVerify } from "jose";
|
|
2
|
+
import { BEARER_AUTHORIZATION_SCHEME, DPOP_AUTHORIZATION_SCHEME, DPOP_NONCE_HEADER, DPOP_PROOF_TYPE, DPOP_SIGNING_ALGORITHMS, deriveDpopAth, normalizeDpopHtu, parseAccessTokenAuthorization, stripAccessTokenAuthorizationScheme } from "./dpop-protocol.mjs";
|
|
3
3
|
// src/oauth2/dpop.ts
|
|
4
4
|
const DEFAULT_DPOP_PROOF_MAX_AGE_SECONDS = 300;
|
|
5
5
|
const MAX_DPOP_JTI_LENGTH = 512;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Awaitable, LiteralString } from "../types/helper.mjs";
|
|
2
2
|
import { GenericEndpointContext } from "../types/context.mjs";
|
|
3
|
-
import "../types/index.mjs";
|
|
4
3
|
import { JWTVerifyGetKey } from "jose";
|
|
4
|
+
import "../types/index.mjs";
|
|
5
5
|
/**
|
|
6
6
|
* id_token verification config for a social provider.
|
|
7
7
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AwaitableFunction } from "../types/helper.mjs";
|
|
2
|
+
import { BetterFetchOption } from "@better-fetch/fetch";
|
|
2
3
|
import "../types/index.mjs";
|
|
3
4
|
import { ProviderOptions } from "./oauth-provider.mjs";
|
|
4
5
|
import { TokenEndpointAuth, TokenEndpointSecretAuthentication } from "./token-endpoint-auth.mjs";
|
|
5
|
-
import { BetterFetchOption } from "@better-fetch/fetch";
|
|
6
6
|
export interface PushAuthorizationRequestInput {
|
|
7
7
|
/**
|
|
8
8
|
* The complete front-channel authorization URL, as built by
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AwaitableFunction } from "../types/helper.mjs";
|
|
2
|
+
import { BetterFetchOption } from "@better-fetch/fetch";
|
|
2
3
|
import "../types/index.mjs";
|
|
3
4
|
import { OAuth2Tokens, ProviderOptions } from "./oauth-provider.mjs";
|
|
4
5
|
import { TokenEndpointAuth, TokenEndpointSecretAuthentication } from "./token-endpoint-auth.mjs";
|
|
5
|
-
import { BetterFetchOption } from "@better-fetch/fetch";
|
|
6
6
|
interface RefreshAccessTokenRequestInput {
|
|
7
7
|
refreshToken: string;
|
|
8
8
|
options: AwaitableFunction<Partial<ProviderOptions>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AwaitableFunction } from "../types/helper.mjs";
|
|
2
2
|
import { OAuth2Tokens, ProviderOptions } from "./oauth-provider.mjs";
|
|
3
|
+
import { BetterFetchOption } from "@better-fetch/fetch";
|
|
4
|
+
import { JWTPayload } from "jose";
|
|
3
5
|
import "../types/index.mjs";
|
|
4
6
|
import "./index.mjs";
|
|
5
7
|
import { TokenEndpointAuth, TokenEndpointSecretAuthentication } from "./token-endpoint-auth.mjs";
|
|
6
|
-
import { JWTPayload } from "jose";
|
|
7
|
-
import { BetterFetchOption } from "@better-fetch/fetch";
|
|
8
8
|
interface AuthorizationCodeRequestInput {
|
|
9
9
|
code: string;
|
|
10
10
|
redirectURI: string;
|
|
@@ -61,5 +61,5 @@ export declare function validateToken<PayloadType = JWTPayload>(token: string, j
|
|
|
61
61
|
* Allowed clock skew in seconds. Defaults to zero.
|
|
62
62
|
*/
|
|
63
63
|
clockTolerance?: number;
|
|
64
|
-
}): Promise<import("jose").JWTVerifyResult<PayloadType> & import("jose").ResolvedKey
|
|
64
|
+
}): Promise<import("jose").JWTVerifyResult<PayloadType> & import("jose").ResolvedKey<Uint8Array<ArrayBufferLike> | CryptoKey>>;
|
|
65
65
|
export {};
|
|
@@ -11,7 +11,9 @@ type ProviderWithIdTokenConfig = Pick<OAuthProvider, "id" | "idToken" | "options
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function verifyIdToken(token: string, config: Extract<OAuthIdTokenConfig, {
|
|
13
13
|
jwks: unknown;
|
|
14
|
-
}>, nonce?: string): Promise<import("jose").JWTVerifyResult<
|
|
14
|
+
}>, nonce?: string): Promise<Omit<import("jose").JWTVerifyResult<unknown>, "payload"> & {
|
|
15
|
+
payload: import("jose").JWTPayload;
|
|
16
|
+
} & import("jose").ResolvedKey<Uint8Array<ArrayBufferLike> | CryptoKey>>;
|
|
15
17
|
/**
|
|
16
18
|
* Whether a provider can verify a client-submitted id_token.
|
|
17
19
|
*
|
package/dist/oauth2/verify.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DpopNonceOptions, DpopReplayStore } from "./dpop.mjs";
|
|
2
1
|
import { APIError } from "better-call";
|
|
3
2
|
import { JSONWebKeySet, JWTPayload, JWTVerifyOptions } from "jose";
|
|
3
|
+
import { DpopNonceOptions, DpopReplayStore } from "./dpop.mjs";
|
|
4
4
|
type JwksFetchOptions = {
|
|
5
5
|
/** Jwks url or promise of a Jwks */
|
|
6
6
|
jwksFetch: string | (() => Promise<JSONWebKeySet | undefined>);
|
package/dist/oauth2/verify.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { APIError } from "better-call";
|
|
2
|
+
import { UnsecuredJWT, createLocalJWKSet, decodeProtectedHeader, errors, jwtVerify } from "jose";
|
|
1
3
|
import { logger } from "../env/logger.mjs";
|
|
2
4
|
import { isAPIError } from "../utils/is-api-error.mjs";
|
|
3
5
|
import { DPOP_NONCE_HEADER, parseAccessTokenAuthorization } from "./dpop-protocol.mjs";
|
|
4
6
|
import { createDpopNonce, createInMemoryDpopReplayStore, enforceDpopBinding, getDpopJktFromPayload, isDpopBindingError } from "./dpop.mjs";
|
|
5
7
|
import { fetchRefusingRedirects } from "./reject-redirects.mjs";
|
|
6
|
-
import { APIError } from "better-call";
|
|
7
|
-
import { UnsecuredJWT, createLocalJWKSet, decodeProtectedHeader, errors, jwtVerify } from "jose";
|
|
8
8
|
// src/oauth2/verify.ts
|
|
9
9
|
const joseInfrastructureErrorCodes = /* @__PURE__ */ new Set([
|
|
10
10
|
errors.JWKSTimeout.code,
|
|
@@ -85,7 +85,7 @@ export declare const apple: (options: AppleOptions) => {
|
|
|
85
85
|
deviceId?: string | undefined;
|
|
86
86
|
}) => Promise<OAuth2Tokens>;
|
|
87
87
|
idToken: {
|
|
88
|
-
jwks: (header: import("jose").
|
|
88
|
+
jwks: (header: import("jose").CompactJWSHeaderParameters) => Promise<CryptoKey | Uint8Array<ArrayBufferLike>>;
|
|
89
89
|
issuer: string;
|
|
90
90
|
algorithms: string[];
|
|
91
91
|
audience: string | string[];
|
|
@@ -108,4 +108,4 @@ export declare const apple: (options: AppleOptions) => {
|
|
|
108
108
|
} | null>;
|
|
109
109
|
options: AppleOptions;
|
|
110
110
|
};
|
|
111
|
-
export declare const getApplePublicKey: (kid: string, jwksEndpoint?: string) => Promise<Uint8Array<ArrayBufferLike
|
|
111
|
+
export declare const getApplePublicKey: (kid: string, jwksEndpoint?: string) => Promise<CryptoKey | Uint8Array<ArrayBufferLike>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeJwt, importJWK } from "jose";
|
|
1
2
|
import { logger } from "../env/logger.mjs";
|
|
2
3
|
import { APIError, EntroAuthError } from "../error/index.mjs";
|
|
3
4
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
@@ -5,7 +6,6 @@ import { getPrimaryClientId, parseStringBoolean } from "../oauth2/utils.mjs";
|
|
|
5
6
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
6
7
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
7
8
|
import { fetchRefusingRedirects } from "../oauth2/reject-redirects.mjs";
|
|
8
|
-
import { decodeJwt, importJWK } from "jose";
|
|
9
9
|
// src/social-providers/apple.ts
|
|
10
10
|
const apple = (options) => {
|
|
11
11
|
const tokenEndpoint = "https://appleid.apple.com/auth/token";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { logger } from "../env/logger.mjs";
|
|
2
3
|
import { EntroAuthError } from "../error/index.mjs";
|
|
3
4
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
4
5
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
5
6
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
6
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
7
7
|
// src/social-providers/atlassian.ts
|
|
8
8
|
const atlassian = (options) => {
|
|
9
9
|
const tokenEndpoint = "https://auth.atlassian.com/oauth/token";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { logger } from "../env/logger.mjs";
|
|
2
3
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
4
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
4
5
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
5
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
6
6
|
// src/social-providers/cloudflare.ts
|
|
7
7
|
const authorizationEndpoint = "https://dash.cloudflare.com/oauth2/auth";
|
|
8
8
|
const tokenEndpoint = "https://dash.cloudflare.com/oauth2/token";
|
|
@@ -70,7 +70,7 @@ export declare const cognito: (options: CognitoOptions) => {
|
|
|
70
70
|
}) => Promise<OAuth2Tokens>;
|
|
71
71
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
72
72
|
idToken: {
|
|
73
|
-
jwks: (header: import("jose").
|
|
73
|
+
jwks: (header: import("jose").CompactJWSHeaderParameters, jws: import("jose").FlattenedJWSInput) => Promise<CryptoKey | Uint8Array<ArrayBufferLike>>;
|
|
74
74
|
issuer: string[];
|
|
75
75
|
audience: string | string[];
|
|
76
76
|
algorithms: string[];
|
|
@@ -119,4 +119,4 @@ export declare const cognito: (options: CognitoOptions) => {
|
|
|
119
119
|
} | null>;
|
|
120
120
|
options: CognitoOptions;
|
|
121
121
|
};
|
|
122
|
-
export declare const getCognitoPublicKey: (kid: string, region: string, userPoolId: string, issuer?: string, jwksEndpoint?: string) => Promise<Uint8Array<ArrayBufferLike
|
|
122
|
+
export declare const getCognitoPublicKey: (kid: string, region: string, userPoolId: string, issuer?: string, jwksEndpoint?: string) => Promise<CryptoKey | Uint8Array<ArrayBufferLike>>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
import { decodeJwt, importJWK } from "jose";
|
|
1
3
|
import { logger } from "../env/logger.mjs";
|
|
2
4
|
import { APIError, EntroAuthError } from "../error/index.mjs";
|
|
3
5
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
@@ -5,8 +7,6 @@ import { getPrimaryClientId, parseStringBoolean } from "../oauth2/utils.mjs";
|
|
|
5
7
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
6
8
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
7
9
|
import { fetchRefusingRedirects } from "../oauth2/reject-redirects.mjs";
|
|
8
|
-
import { decodeJwt, importJWK } from "jose";
|
|
9
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
10
10
|
// src/social-providers/cognito.ts
|
|
11
11
|
const cognito = (options) => {
|
|
12
12
|
if (!options.domain || !options.region || !options.userPoolId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
2
3
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
3
4
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
4
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
5
5
|
// src/social-providers/discord.ts
|
|
6
6
|
const discord = (options) => {
|
|
7
7
|
const tokenEndpoint = "https://discord.com/api/oauth2/token";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
2
3
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
3
4
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
4
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
5
5
|
// src/social-providers/dropbox.ts
|
|
6
6
|
const dropbox = (options) => {
|
|
7
7
|
const tokenEndpoint = "https://api.dropboxapi.com/oauth2/token";
|
|
@@ -55,14 +55,7 @@ export declare const facebook: (options: FacebookOptions) => {
|
|
|
55
55
|
deviceId?: string | undefined;
|
|
56
56
|
}) => Promise<OAuth2Tokens>;
|
|
57
57
|
idToken: {
|
|
58
|
-
jwks:
|
|
59
|
-
(protectedHeader?: import("jose").JWSHeaderParameters, token?: import("jose").FlattenedJWSInput): Promise<import("jose").CryptoKey>;
|
|
60
|
-
coolingDown: boolean;
|
|
61
|
-
fresh: boolean;
|
|
62
|
-
reloading: boolean;
|
|
63
|
-
reload: () => Promise<void>;
|
|
64
|
-
jwks: () => import("jose").JSONWebKeySet | undefined;
|
|
65
|
-
};
|
|
58
|
+
jwks: import("jose").RemoteJWKSet;
|
|
66
59
|
issuer: string;
|
|
67
60
|
audience: string | string[];
|
|
68
61
|
algorithms: string[];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
+
import { createRemoteJWKSet, decodeJwt } from "jose";
|
|
1
3
|
import { logger } from "../env/logger.mjs";
|
|
2
4
|
import { EntroAuthError } from "../error/index.mjs";
|
|
3
5
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
@@ -6,8 +8,6 @@ import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
|
6
8
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
7
9
|
import { fetchRefusingRedirects } from "../oauth2/reject-redirects.mjs";
|
|
8
10
|
import { appendQueryParams } from "../utils/url.mjs";
|
|
9
|
-
import { createRemoteJWKSet, decodeJwt } from "jose";
|
|
10
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
11
11
|
// src/social-providers/facebook.ts
|
|
12
12
|
/**
|
|
13
13
|
* `debug_token` sits next to the Graph `/me` endpoint, so a `userInfoEndpoint`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { logger } from "../env/logger.mjs";
|
|
2
3
|
import { EntroAuthError } from "../error/index.mjs";
|
|
3
4
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
4
5
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
5
6
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
6
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
7
7
|
// src/social-providers/figma.ts
|
|
8
8
|
const figma = (options) => {
|
|
9
9
|
const tokenEndpoint = "https://api.figma.com/v1/oauth/token";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { logger } from "../env/logger.mjs";
|
|
2
3
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
3
4
|
import { getOAuth2Tokens } from "../oauth2/utils.mjs";
|
|
4
5
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
5
6
|
import { fetchRefusingRedirects } from "../oauth2/reject-redirects.mjs";
|
|
6
7
|
import { authorizationCodeRequest } from "../oauth2/validate-authorization-code.mjs";
|
|
7
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
8
8
|
// src/social-providers/github.ts
|
|
9
9
|
const github = (options) => {
|
|
10
10
|
const tokenEndpoint = "https://github.com/login/oauth/access_token";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
1
2
|
import { createAuthorizationURL } from "../oauth2/create-authorization-url.mjs";
|
|
2
3
|
import { refreshAccessToken } from "../oauth2/refresh-access-token.mjs";
|
|
3
4
|
import { validateAuthorizationCode } from "../oauth2/validate-authorization-code.mjs";
|
|
4
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
5
5
|
// src/social-providers/gitlab.ts
|
|
6
6
|
const cleanDoubleSlashes = (input = "") => {
|
|
7
7
|
return input.split("://").map((str) => str.replace(/\/{2,}/g, "/")).join("://");
|
|
@@ -100,7 +100,7 @@ export declare const google: (options: GoogleOptions) => {
|
|
|
100
100
|
}) => Promise<OAuth2Tokens>;
|
|
101
101
|
refreshAccessToken: (refreshToken: string) => Promise<OAuth2Tokens>;
|
|
102
102
|
idToken: {
|
|
103
|
-
jwks: (header: import("jose").
|
|
103
|
+
jwks: (header: import("jose").CompactJWSHeaderParameters) => Promise<CryptoKey | Uint8Array<ArrayBufferLike>>;
|
|
104
104
|
issuer: string[];
|
|
105
105
|
audience: string | string[];
|
|
106
106
|
algorithms: "RS256"[];
|
|
@@ -122,4 +122,4 @@ export declare const google: (options: GoogleOptions) => {
|
|
|
122
122
|
} | null>;
|
|
123
123
|
options: GoogleOptions;
|
|
124
124
|
};
|
|
125
|
-
export declare const getGooglePublicKey: (kid: string, jwksEndpoint?: string) => Promise<Uint8Array<ArrayBufferLike
|
|
125
|
+
export declare const getGooglePublicKey: (kid: string, jwksEndpoint?: string) => Promise<CryptoKey | Uint8Array<ArrayBufferLike>>;
|