authhero 8.2.0 → 8.3.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 +108 -108
- package/dist/authhero.d.ts +337 -244
- package/dist/authhero.mjs +10549 -10425
- package/dist/stats.html +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/adapters/createEncryptedDataAdapter.d.ts +40 -0
- package/dist/types/adapters/index.d.ts +4 -2
- package/dist/types/authentication-flows/passwordless.d.ts +1 -1
- package/dist/types/helpers/compose-auth-data.d.ts +9 -1
- package/dist/types/helpers/server-timing.d.ts +44 -2
- package/dist/types/index.d.ts +224 -224
- package/dist/types/routes/auth-api/index.d.ts +16 -16
- package/dist/types/routes/auth-api/passwordless.d.ts +14 -14
- package/dist/types/routes/management-api/actions.d.ts +3 -3
- package/dist/types/routes/management-api/email-templates.d.ts +18 -18
- package/dist/types/routes/management-api/failed-events.d.ts +1 -1
- package/dist/types/routes/management-api/guardian.d.ts +5 -5
- package/dist/types/routes/management-api/index.d.ts +64 -64
- package/dist/types/routes/management-api/log-streams.d.ts +6 -6
- package/dist/types/routes/management-api/logs.d.ts +3 -3
- package/dist/types/routes/management-api/migration-sources.d.ts +6 -6
- package/dist/types/routes/management-api/organizations.d.ts +2 -2
- 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/u2-index.d.ts +6 -6
- package/dist/types/routes/universal-login/u2-routes.d.ts +6 -6
- package/dist/types/types/Bindings.d.ts +21 -0
- package/dist/types/types/IdToken.d.ts +1 -1
- package/dist/types/types/Variables.d.ts +4 -0
- package/dist/types/utils/field-encryption.d.ts +30 -0
- package/package.json +1 -1
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { DataAdapters } from "@authhero/adapter-interfaces";
|
|
2
|
+
import { KeyRing } from "../utils/field-encryption";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves which key id (if any) a tenant's secrets are encrypted under.
|
|
5
|
+
* Returning `undefined` uses the ring's default key and produces legacy,
|
|
6
|
+
* untagged `enc:v1:` ciphertext — byte-compatible with the single-key adapter.
|
|
7
|
+
*
|
|
8
|
+
* The canonical use: tag rows owned by the control plane tenant with a
|
|
9
|
+
* control-plane-only key id, so the same database can hold a tenant's own
|
|
10
|
+
* secrets (default key) alongside inherited control plane secrets the tenant
|
|
11
|
+
* operator cannot decrypt.
|
|
12
|
+
*/
|
|
13
|
+
export type EncryptKeyIdResolver = (tenantId: string) => string | undefined;
|
|
14
|
+
interface EncryptionOptions {
|
|
15
|
+
resolveEncryptKeyId?: EncryptKeyIdResolver;
|
|
16
|
+
}
|
|
2
17
|
/**
|
|
3
18
|
* Wraps a DataAdapters instance so that sensitive credential fields are
|
|
4
19
|
* transparently encrypted on write and decrypted on read. Only the adapters
|
|
@@ -16,3 +31,28 @@ import { DataAdapters } from "@authhero/adapter-interfaces";
|
|
|
16
31
|
* Private keys (keys.pkcs7, dkim_private_key) are intentionally NOT covered.
|
|
17
32
|
*/
|
|
18
33
|
export declare function createEncryptedDataAdapter(data: DataAdapters, key: CryptoKey): DataAdapters;
|
|
34
|
+
/**
|
|
35
|
+
* Like {@link createEncryptedDataAdapter}, but encrypts each tenant's secrets
|
|
36
|
+
* under a key selected from a {@link KeyRing}. On read, the key is chosen from
|
|
37
|
+
* the id embedded in the ciphertext, so a single database can mix values
|
|
38
|
+
* encrypted under different keys.
|
|
39
|
+
*
|
|
40
|
+
* `options.resolveEncryptKeyId(tenantId)` decides which key id new ciphertext is
|
|
41
|
+
* tagged with. Return `undefined` for the ring's default key (legacy untagged
|
|
42
|
+
* form). The intended use is to tag control plane tenant rows with a
|
|
43
|
+
* control-plane-only key id so an inheriting tenant can hold the inherited
|
|
44
|
+
* secrets at rest without being able to decrypt them.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const adapters = createEncryptedDataAdapterWithKeyRing(base, {
|
|
49
|
+
* default: tenantKey,
|
|
50
|
+
* keys: { cp: controlPlaneKey },
|
|
51
|
+
* }, {
|
|
52
|
+
* resolveEncryptKeyId: (tenantId) =>
|
|
53
|
+
* tenantId === CONTROL_PLANE_TENANT_ID ? "cp" : undefined,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function createEncryptedDataAdapterWithKeyRing(data: DataAdapters, ring: KeyRing, options?: EncryptionOptions): DataAdapters;
|
|
58
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export * from "./cache";
|
|
2
|
-
export { createEncryptedDataAdapter } from "./createEncryptedDataAdapter";
|
|
3
|
-
export {
|
|
2
|
+
export { createEncryptedDataAdapter, createEncryptedDataAdapterWithKeyRing, } from "./createEncryptedDataAdapter";
|
|
3
|
+
export type { EncryptKeyIdResolver } from "./createEncryptedDataAdapter";
|
|
4
|
+
export { loadEncryptionKey, encryptField, decryptField, encryptFieldWithRing, decryptFieldWithRing, parseKeyId, isEncrypted, } from "../utils/field-encryption";
|
|
5
|
+
export type { KeyRing } from "../utils/field-encryption";
|
|
@@ -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?: "
|
|
460
|
+
token_endpoint_auth_method?: "none" | "client_secret_post" | "client_secret_basic" | "client_secret_jwt" | "private_key_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;
|
|
@@ -8,12 +8,20 @@ import { Bindings, Variables } from "../types";
|
|
|
8
8
|
* between layers — in one place so individual apps can't drift.
|
|
9
9
|
*
|
|
10
10
|
* Layering (outermost first; that's the order callers hit on each read):
|
|
11
|
-
* addTimingLogs — server-timing instrumentation
|
|
12
11
|
* withClientBundle — L0: per-(tenant_id, client_id) snapshot
|
|
13
12
|
* addBundleWritePurge — local-edge bundle invalidation on writes
|
|
14
13
|
* addRequestScopedDedup — L1: in-request Promise memoization
|
|
15
14
|
* addCaching — L2: cross-request cache (CF Cache API in prod)
|
|
16
15
|
* addDataHooks — user lifecycle hooks
|
|
16
|
+
* addTimingLogs — server-timing instrumentation. Innermost on
|
|
17
|
+
* purpose: a read served by the bundle (L0), request
|
|
18
|
+
* dedup (L1), or cache (L2) is satisfied above this
|
|
19
|
+
* layer and never reaches it, so the Server-Timing
|
|
20
|
+
* header carries one line per genuine backend
|
|
21
|
+
* round-trip — with its true duration — instead of
|
|
22
|
+
* one line per surface call (cache/bundle hits
|
|
23
|
+
* included, the whole bundle's cost attributed to
|
|
24
|
+
* whichever call happened to trigger assembly).
|
|
17
25
|
* raw dataAdapter — underlying DB
|
|
18
26
|
*
|
|
19
27
|
* Apps declare only their `nonBundleEntities` — the long-tail entities they
|
|
@@ -1,6 +1,47 @@
|
|
|
1
|
-
import { Context } from "hono";
|
|
2
|
-
import { DataAdapters } from "@authhero/adapter-interfaces";
|
|
1
|
+
import { Context, MiddlewareHandler } from "hono";
|
|
2
|
+
import { CacheAdapter, DataAdapters } from "@authhero/adapter-interfaces";
|
|
3
3
|
import { Bindings, Variables } from "../types";
|
|
4
|
+
type TimingCtx = Context<{
|
|
5
|
+
Bindings: Bindings;
|
|
6
|
+
Variables: Variables;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Record one Server-Timing measurement on the request-scoped buffer
|
|
10
|
+
* (`ctx.var.serverTiming`). The measurement is NOT written to the response
|
|
11
|
+
* header here — {@link serverTimingMiddleware} decides at the end of the
|
|
12
|
+
* request whether to emit it to the client, log it server-side, or drop it.
|
|
13
|
+
* Used by the adapter wrappers below and by the webhook hook.
|
|
14
|
+
*/
|
|
15
|
+
export declare function recordServerTiming(ctx: TimingCtx, name: string, duration: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* Flushes the request-scoped Server-Timing buffer according to the
|
|
18
|
+
* `SERVER_TIMING` env. Mount this right after `applyConfigMiddleware` so that
|
|
19
|
+
* env is populated before it runs and the client `ip` is resolved by the time
|
|
20
|
+
* `next()` returns.
|
|
21
|
+
*
|
|
22
|
+
* Sinks (see {@link Bindings.SERVER_TIMING}):
|
|
23
|
+
* - "off"/unset → drop the buffer (default; nothing reaches the client).
|
|
24
|
+
* - "client" → set the `Server-Timing` header, optionally gated to
|
|
25
|
+
* `SERVER_TIMING_IPS`.
|
|
26
|
+
* - "log" → emit a structured log line; never sent to the client.
|
|
27
|
+
* - "both" → both of the above.
|
|
28
|
+
*
|
|
29
|
+
* Off by default because per-operation timings on the public auth endpoints are
|
|
30
|
+
* a user-enumeration / side-channel surface.
|
|
31
|
+
*/
|
|
32
|
+
export declare const serverTimingMiddleware: MiddlewareHandler<{
|
|
33
|
+
Bindings: Bindings;
|
|
34
|
+
Variables: Variables;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Wraps a {@link CacheAdapter} so each operation appends a Server-Timing entry
|
|
38
|
+
* labelled by the key's prefix, e.g. `cache-get:client-bundle`,
|
|
39
|
+
* `cache-get:customText`. The cache layers call this adapter directly — not
|
|
40
|
+
* through the timed data stack — so on Workers the Cache API `match()` / `put()`
|
|
41
|
+
* round-trips would otherwise be invisible. This makes that latency observable
|
|
42
|
+
* without exposing the full (id-bearing) cache key.
|
|
43
|
+
*/
|
|
44
|
+
export declare function addCacheTimingLogs(ctx: TimingCtx, cache: CacheAdapter): CacheAdapter;
|
|
4
45
|
/**
|
|
5
46
|
* Adds server-timing middleware logging to all adapter methods
|
|
6
47
|
* This wraps each method of the data adapter to measure its execution time
|
|
@@ -10,3 +51,4 @@ export declare function addTimingLogs(ctx: Context<{
|
|
|
10
51
|
Bindings: Bindings;
|
|
11
52
|
Variables: Variables;
|
|
12
53
|
}>, data: DataAdapters): DataAdapters;
|
|
54
|
+
export {};
|