authhero 7.2.2 → 8.0.0
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/authhero.cjs +105 -105
- package/dist/authhero.d.ts +156 -202
- package/dist/authhero.mjs +8867 -8551
- package/dist/stats.html +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/authentication-flows/passwordless.d.ts +3 -3
- package/dist/types/helpers/bundle-write-purge.d.ts +16 -0
- package/dist/types/helpers/client-bundle.d.ts +51 -0
- package/dist/types/helpers/request-scoped-dedup.d.ts +8 -0
- package/dist/types/helpers/with-client-bundle.d.ts +31 -0
- package/dist/types/index.d.ts +153 -155
- package/dist/types/routes/auth-api/index.d.ts +9 -9
- package/dist/types/routes/auth-api/passwordless.d.ts +6 -6
- package/dist/types/routes/auth-api/register/index.d.ts +2 -2
- package/dist/types/routes/auth-api/well-known.d.ts +1 -1
- package/dist/types/routes/management-api/clients.d.ts +7 -7
- package/dist/types/routes/management-api/connections.d.ts +1 -1
- package/dist/types/routes/management-api/failed-events.d.ts +1 -1
- package/dist/types/routes/management-api/forms.d.ts +119 -119
- package/dist/types/routes/management-api/index.d.ts +138 -138
- package/dist/types/routes/management-api/logs.d.ts +3 -3
- package/dist/types/routes/management-api/organizations.d.ts +1 -1
- package/dist/types/routes/management-api/prompts.d.ts +4 -4
- package/dist/types/routes/management-api/users.d.ts +2 -2
- package/dist/types/routes/universal-login/common.d.ts +2 -2
- package/dist/types/routes/universal-login/flow-api.d.ts +12 -12
- package/dist/types/routes/universal-login/u2-index.d.ts +6 -6
- package/dist/types/routes/universal-login/u2-routes.d.ts +6 -6
- package/dist/types/types/AuthHeroConfig.d.ts +0 -12
- package/dist/types/utils/jwks.d.ts +2 -2
- package/package.json +5 -4
|
@@ -457,7 +457,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
|
|
|
457
457
|
custom_login_page_preview?: string | undefined;
|
|
458
458
|
form_template?: string | undefined;
|
|
459
459
|
addons?: Record<string, any> | undefined;
|
|
460
|
-
token_endpoint_auth_method?: "none" | "
|
|
460
|
+
token_endpoint_auth_method?: "none" | "private_key_jwt" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | undefined;
|
|
461
461
|
client_metadata?: Record<string, string> | undefined;
|
|
462
462
|
hide_sign_up_disabled_error?: boolean | undefined;
|
|
463
463
|
mobile?: Record<string, any> | undefined;
|
|
@@ -540,8 +540,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
|
|
|
540
540
|
} | undefined;
|
|
541
541
|
authenticated_at?: string | undefined;
|
|
542
542
|
};
|
|
543
|
-
connectionType: "
|
|
544
|
-
authConnection: "
|
|
543
|
+
connectionType: "username" | "sms" | "email";
|
|
544
|
+
authConnection: "username" | "sms" | "email";
|
|
545
545
|
session_id: string | undefined;
|
|
546
546
|
authParams: {
|
|
547
547
|
client_id: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CacheAdapter, DataAdapters } from "@authhero/adapter-interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a {@link DataAdapters} so that writes to bundle-covered entities
|
|
4
|
+
* purge the corresponding `client-bundle:{tenant_id}:{client_id}` cache
|
|
5
|
+
* entry — best-effort and local-edge only on Cloudflare's Cache API.
|
|
6
|
+
*
|
|
7
|
+
* Two write shapes:
|
|
8
|
+
* 1. Client-scoped writes (args = [tenant_id, client_id, ...]): purge the
|
|
9
|
+
* exact bundle key. Affects exactly one bundle.
|
|
10
|
+
* 2. Tenant-scoped writes (args = [tenant_id, ...]): attempt a prefix delete
|
|
11
|
+
* of `client-bundle:{tenant_id}:`. This is a no-op on Cloudflare Cache
|
|
12
|
+
* (which can't enumerate keys) but works on the in-memory adapter and
|
|
13
|
+
* on Redis-backed adapters. Tenant-scoped staleness is otherwise bounded
|
|
14
|
+
* by the bundle TTL.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addBundleWritePurge(data: DataAdapters, cache: CacheAdapter, keyPrefix?: string): DataAdapters;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CacheAdapter, Client, Connection, ClientWithTenantId, DataAdapters, ListConnectionsResponse, ListResourceServersResponse, ListHooksResponse, Branding, PromptSetting, Tenant } from "@authhero/adapter-interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* One snapshot of every per-(tenant, client) read that the request path
|
|
4
|
+
* touches outside of user-specific data. Loaded once per request and held
|
|
5
|
+
* in a 5-minute SWR cache.
|
|
6
|
+
*
|
|
7
|
+
* Tenant-scoped lists (connections, resourceServers, hooks) are stored as
|
|
8
|
+
* their full default-list response so callers calling list(tenant_id) with
|
|
9
|
+
* no params get an identical shape from the bundle.
|
|
10
|
+
*/
|
|
11
|
+
export interface ClientBundle {
|
|
12
|
+
tenant: Tenant | null;
|
|
13
|
+
client: Client | null;
|
|
14
|
+
connections: ListConnectionsResponse;
|
|
15
|
+
clientConnections: Connection[];
|
|
16
|
+
branding: Branding | null;
|
|
17
|
+
resourceServers: ListResourceServersResponse;
|
|
18
|
+
promptSettings: PromptSetting | null;
|
|
19
|
+
hooks: ListHooksResponse;
|
|
20
|
+
}
|
|
21
|
+
export interface ClientBundleConfig {
|
|
22
|
+
/** Seconds the bundle is served without a refresh. Default 300. */
|
|
23
|
+
freshSeconds?: number;
|
|
24
|
+
/** Seconds the bundle may be served stale while a background refresh runs. Default 600 (so total lifetime = fresh + stale). */
|
|
25
|
+
staleSeconds?: number;
|
|
26
|
+
/** Cache key prefix (per-deployment isolation). Default "client-bundle". */
|
|
27
|
+
keyPrefix?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function clientBundleKey(tenantId: string, clientId: string, prefix?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Look up — and on miss, populate — the per-(tenant, client) bundle.
|
|
32
|
+
*
|
|
33
|
+
* SWR semantics:
|
|
34
|
+
* - now < freshUntil → return immediately
|
|
35
|
+
* - freshUntil ≤ now < staleUntil → return immediately, schedule a refresh
|
|
36
|
+
* via `scheduleRefresh` (typically wired to `ctx.executionCtx.waitUntil`)
|
|
37
|
+
* - now ≥ staleUntil OR no entry → fetch synchronously
|
|
38
|
+
*
|
|
39
|
+
* `data` should be the underlying adapter (i.e. with hooks but without the
|
|
40
|
+
* bundle wrapper). Passing the bundle-wrapped adapter would deadlock on
|
|
41
|
+
* itself, since bundle reads route back into this function.
|
|
42
|
+
*/
|
|
43
|
+
export declare function loadClientBundle(data: DataAdapters, cache: CacheAdapter, tenantId: string, clientId: string, options?: {
|
|
44
|
+
config?: ClientBundleConfig;
|
|
45
|
+
/** Schedule a background promise. Provide `ctx.executionCtx.waitUntil.bind(ctx.executionCtx)` on Workers; otherwise omit and we'll skip the background refresh. */
|
|
46
|
+
scheduleRefresh?: (promise: Promise<unknown>) => void;
|
|
47
|
+
/** Override the "now" clock for testing. */
|
|
48
|
+
now?: () => number;
|
|
49
|
+
}): Promise<ClientBundle>;
|
|
50
|
+
/** Helper to extract the ClientWithTenantId shape from a bundle. */
|
|
51
|
+
export declare function bundleToClientWithTenantId(bundle: ClientBundle, tenantId: string): ClientWithTenantId | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataAdapters } from "@authhero/adapter-interfaces";
|
|
2
|
+
export interface RequestScopedDedupOptions {
|
|
3
|
+
/** Names of adapter entities to dedup. Entities outside this list pass through verbatim. Required — there is no safe default. */
|
|
4
|
+
dedupEntities: string[];
|
|
5
|
+
/** Shared Map for memoized Promises. Defaults to a fresh Map per call. */
|
|
6
|
+
dedup?: Map<string, Promise<unknown>>;
|
|
7
|
+
}
|
|
8
|
+
export declare function addRequestScopedDedup(data: DataAdapters, options: RequestScopedDedupOptions): DataAdapters;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Context } from "hono";
|
|
2
|
+
import { CacheAdapter, DataAdapters } from "@authhero/adapter-interfaces";
|
|
3
|
+
import { Bindings, Variables } from "../types";
|
|
4
|
+
import { ClientBundleConfig } from "./client-bundle";
|
|
5
|
+
type Ctx = Context<{
|
|
6
|
+
Bindings: Bindings;
|
|
7
|
+
Variables: Variables;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Route reads that match the request's (tenant_id, client_id) to a single
|
|
11
|
+
* cached {@link ClientBundle} instead of going entity-by-entity through the
|
|
12
|
+
* downstream cache. Calls with different tenants/clients, or with non-default
|
|
13
|
+
* pagination, fall through to {@link upstream}.
|
|
14
|
+
*
|
|
15
|
+
* The bundle is loaded lazily on the first matching read — `tenant_id` and
|
|
16
|
+
* `client_id` typically come from middleware and route entry, so by the time
|
|
17
|
+
* any bundle-covered method is hit they're set.
|
|
18
|
+
*
|
|
19
|
+
* Pass `upstream` (the layer below this wrapper) so bundle component fetches
|
|
20
|
+
* still benefit from request-scoped dedup / persistent cache / hooks.
|
|
21
|
+
*/
|
|
22
|
+
export declare function withClientBundle(ctx: Ctx, upstream: DataAdapters, cache: CacheAdapter, options?: {
|
|
23
|
+
config?: ClientBundleConfig;
|
|
24
|
+
}): DataAdapters;
|
|
25
|
+
/**
|
|
26
|
+
* Best-effort purge of a (tenant_id, client_id) bundle entry from cache.
|
|
27
|
+
* On Cloudflare this only affects the local edge; entries on other colos
|
|
28
|
+
* will expire via TTL.
|
|
29
|
+
*/
|
|
30
|
+
export declare function purgeClientBundle(cache: CacheAdapter, tenantId: string, clientId: string, keyPrefix?: string): Promise<void>;
|
|
31
|
+
export {};
|