authhero 4.102.0 → 4.103.1
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/README.md +24 -25
- package/dist/assets/u/widget/index.esm.js +1 -1
- package/dist/authhero.cjs +87 -87
- package/dist/authhero.d.ts +131 -34
- package/dist/authhero.mjs +10759 -10518
- package/dist/stats.html +1 -1
- package/package.json +4 -4
package/dist/authhero.d.ts
CHANGED
|
@@ -46752,6 +46752,7 @@ export declare const refreshTokenSchema: z.ZodObject<{
|
|
|
46752
46752
|
}>, "many">;
|
|
46753
46753
|
rotating: z.ZodBoolean;
|
|
46754
46754
|
created_at: z.ZodString;
|
|
46755
|
+
revoked_at: z.ZodOptional<z.ZodString>;
|
|
46755
46756
|
}, "strip", z.ZodTypeAny, {
|
|
46756
46757
|
created_at: string;
|
|
46757
46758
|
id: string;
|
|
@@ -46772,6 +46773,7 @@ export declare const refreshTokenSchema: z.ZodObject<{
|
|
|
46772
46773
|
}[];
|
|
46773
46774
|
rotating: boolean;
|
|
46774
46775
|
expires_at?: string | undefined;
|
|
46776
|
+
revoked_at?: string | undefined;
|
|
46775
46777
|
idle_expires_at?: string | undefined;
|
|
46776
46778
|
last_exchanged_at?: string | undefined;
|
|
46777
46779
|
}, {
|
|
@@ -46794,6 +46796,7 @@ export declare const refreshTokenSchema: z.ZodObject<{
|
|
|
46794
46796
|
}[];
|
|
46795
46797
|
rotating: boolean;
|
|
46796
46798
|
expires_at?: string | undefined;
|
|
46799
|
+
revoked_at?: string | undefined;
|
|
46797
46800
|
idle_expires_at?: string | undefined;
|
|
46798
46801
|
last_exchanged_at?: string | undefined;
|
|
46799
46802
|
}>;
|
|
@@ -49004,6 +49007,7 @@ export interface RefreshTokensAdapter {
|
|
|
49004
49007
|
list(tenant_id: string, params?: ListParams): Promise<ListRefreshTokenResponse>;
|
|
49005
49008
|
update: (tenant_id: string, id: string, refresh_token: Partial<RefreshToken>) => Promise<boolean>;
|
|
49006
49009
|
remove: (tenant_id: string, id: string) => Promise<boolean>;
|
|
49010
|
+
revokeByLoginSession: (tenant_id: string, login_session_id: string, revoked_at: string) => Promise<number>;
|
|
49007
49011
|
}
|
|
49008
49012
|
export interface ListFormsResponse extends Totals {
|
|
49009
49013
|
forms: Form[];
|
|
@@ -51851,6 +51855,15 @@ export interface WebhookInvokerParams {
|
|
|
51851
51855
|
data: Record<string, unknown>;
|
|
51852
51856
|
/** The tenant ID */
|
|
51853
51857
|
tenant_id: string;
|
|
51858
|
+
/**
|
|
51859
|
+
* Outbox event id for this invocation. Matches the value the default
|
|
51860
|
+
* invoker sends as the `Idempotency-Key` header — custom invokers should
|
|
51861
|
+
* forward it as the same header (or an equivalent dedupe key) so
|
|
51862
|
+
* downstream receivers can dedupe on outbox retries. Only set when the
|
|
51863
|
+
* invocation originates from the transactional outbox; the legacy inline
|
|
51864
|
+
* dispatcher has no stable event id to forward.
|
|
51865
|
+
*/
|
|
51866
|
+
idempotency_key?: string;
|
|
51854
51867
|
/**
|
|
51855
51868
|
* Lazily creates a service token for authenticating with the webhook endpoint.
|
|
51856
51869
|
* Only creates the token when called — no overhead if you use your own auth.
|
|
@@ -52556,6 +52569,59 @@ export interface OutboxCleanupParams {
|
|
|
52556
52569
|
* Intended for use in a scheduled handler / cron job.
|
|
52557
52570
|
*/
|
|
52558
52571
|
export declare function cleanupOutbox(outbox: OutboxAdapter, params?: OutboxCleanupParams): Promise<number>;
|
|
52572
|
+
/**
|
|
52573
|
+
* Mints a Bearer token for a given tenant. `scope` is forwarded so a custom
|
|
52574
|
+
* `webhookInvoker` can request a non-default scope for its outbound call.
|
|
52575
|
+
*/
|
|
52576
|
+
export type GetServiceToken = (tenantId: string, scope?: string) => Promise<string>;
|
|
52577
|
+
export interface WebhookInvocation {
|
|
52578
|
+
eventId: string;
|
|
52579
|
+
tenantId: string;
|
|
52580
|
+
triggerId: string;
|
|
52581
|
+
payload: {
|
|
52582
|
+
tenant_id: string;
|
|
52583
|
+
trigger_id: string;
|
|
52584
|
+
user?: unknown;
|
|
52585
|
+
request?: unknown;
|
|
52586
|
+
};
|
|
52587
|
+
}
|
|
52588
|
+
export interface WebhookDestinationOptions {
|
|
52589
|
+
timeoutMs?: number;
|
|
52590
|
+
/**
|
|
52591
|
+
* Replaces the default HTTP invoker. When set, each matching webhook is
|
|
52592
|
+
* dispatched by calling `webhookInvoker({ hook, data, tenant_id,
|
|
52593
|
+
* createServiceToken })` instead of issuing a raw `fetch` with a Bearer
|
|
52594
|
+
* token. `createServiceToken(scope?)` lazily mints a token bound to the
|
|
52595
|
+
* invocation's tenant, matching the shape passed to the legacy inline
|
|
52596
|
+
* dispatcher in `hooks/webhooks.ts`.
|
|
52597
|
+
*/
|
|
52598
|
+
webhookInvoker?: WebhookInvoker;
|
|
52599
|
+
}
|
|
52600
|
+
/**
|
|
52601
|
+
* Delivers `hook.*` outbox events to HTTP webhooks configured for the matching
|
|
52602
|
+
* trigger_id. Each POST includes `Idempotency-Key: {event.id}` so downstream
|
|
52603
|
+
* webhook handlers can dedupe if the outbox retries.
|
|
52604
|
+
*
|
|
52605
|
+
* The destination is constructed per-request (via `outboxMiddleware`'s
|
|
52606
|
+
* `getDestinations(ctx)` factory) so it can close over a ctx-bound service
|
|
52607
|
+
* token generator. The same class is also used by the cron `runOutboxRelay`
|
|
52608
|
+
* helper — a consumer's `webhookInvoker` configured via `init()` propagates
|
|
52609
|
+
* to both paths so cron-drained deliveries don't diverge from per-request
|
|
52610
|
+
* ones.
|
|
52611
|
+
*/
|
|
52612
|
+
export declare class WebhookDestination implements EventDestination {
|
|
52613
|
+
name: string;
|
|
52614
|
+
private hooks;
|
|
52615
|
+
private getServiceToken;
|
|
52616
|
+
private timeoutMs;
|
|
52617
|
+
private webhookInvoker?;
|
|
52618
|
+
constructor(hooks: HooksAdapter, getServiceToken: GetServiceToken, options?: WebhookDestinationOptions);
|
|
52619
|
+
accepts(event: AuditEvent): boolean;
|
|
52620
|
+
transform(event: AuditEvent): WebhookInvocation;
|
|
52621
|
+
deliver(events: WebhookInvocation[]): Promise<void>;
|
|
52622
|
+
private invokeCustom;
|
|
52623
|
+
private invokeDefault;
|
|
52624
|
+
}
|
|
52559
52625
|
export interface CreateDefaultDestinationsConfig {
|
|
52560
52626
|
/**
|
|
52561
52627
|
* Data adapter — only the `logs`, `hooks`, and `users` adapters are used
|
|
@@ -52569,9 +52635,17 @@ export interface CreateDefaultDestinationsConfig {
|
|
|
52569
52635
|
* Required if you want `hook.*` events to be drained. Omit for cron
|
|
52570
52636
|
* drains that only need to sweep up log events.
|
|
52571
52637
|
*/
|
|
52572
|
-
getServiceToken?:
|
|
52638
|
+
getServiceToken?: GetServiceToken;
|
|
52573
52639
|
/** Webhook HTTP request timeout in ms (default: 10_000). */
|
|
52574
52640
|
webhookTimeoutMs?: number;
|
|
52641
|
+
/**
|
|
52642
|
+
* Custom webhook invoker — same shape as the `webhookInvoker` option on
|
|
52643
|
+
* `init()`. When provided, `hook.*` events are dispatched by calling this
|
|
52644
|
+
* function instead of issuing a raw `fetch` with a Bearer token. Use this
|
|
52645
|
+
* to match a consumer-configured invoker exactly, so cron-drained
|
|
52646
|
+
* deliveries don't diverge from inline per-request ones.
|
|
52647
|
+
*/
|
|
52648
|
+
webhookInvoker?: WebhookInvoker;
|
|
52575
52649
|
}
|
|
52576
52650
|
/**
|
|
52577
52651
|
* Build the same array of outbox destinations that authhero's per-request
|
|
@@ -52599,6 +52673,62 @@ export interface CreateDefaultDestinationsConfig {
|
|
|
52599
52673
|
* ```
|
|
52600
52674
|
*/
|
|
52601
52675
|
export declare function createDefaultDestinations(config: CreateDefaultDestinationsConfig): EventDestination[];
|
|
52676
|
+
export interface RunOutboxRelayConfig {
|
|
52677
|
+
/** Same `DataAdapters` passed to `init()`. Must include `outbox` to drain. */
|
|
52678
|
+
dataAdapter: DataAdapters;
|
|
52679
|
+
/**
|
|
52680
|
+
* Issuer URL used when minting per-tenant `auth-service` tokens (typically
|
|
52681
|
+
* your `env.ISSUER`). Webhook handlers that validate `iss` against this
|
|
52682
|
+
* URL will accept tokens from both the inline dispatcher and this cron
|
|
52683
|
+
* relay.
|
|
52684
|
+
*/
|
|
52685
|
+
issuer: string;
|
|
52686
|
+
/**
|
|
52687
|
+
* Optional webhook invoker — same shape as the one accepted by `init()`.
|
|
52688
|
+
* When provided, cron-drained `hook.*` events go through this invoker,
|
|
52689
|
+
* matching the inline per-request dispatch path exactly.
|
|
52690
|
+
*/
|
|
52691
|
+
webhookInvoker?: WebhookInvoker;
|
|
52692
|
+
/** Days to retain processed events before cleanup. Default 7. */
|
|
52693
|
+
retentionDays?: number;
|
|
52694
|
+
/** Forwarded to `drainOutbox`. */
|
|
52695
|
+
batchSize?: number;
|
|
52696
|
+
/** Forwarded to `drainOutbox`. */
|
|
52697
|
+
maxRetries?: number;
|
|
52698
|
+
/** Webhook HTTP timeout (ms), when the default invoker is used. */
|
|
52699
|
+
webhookTimeoutMs?: number;
|
|
52700
|
+
}
|
|
52701
|
+
/**
|
|
52702
|
+
* One-call outbox relay for cron / scheduled handlers.
|
|
52703
|
+
*
|
|
52704
|
+
* Internally:
|
|
52705
|
+
* 1. Skips gracefully when `dataAdapter.outbox` is undefined.
|
|
52706
|
+
* 2. Builds the same destination array as the inline dispatcher
|
|
52707
|
+
* (`LogsDestination`, `WebhookDestination`, `RegistrationFinalizerDestination`).
|
|
52708
|
+
* 3. Mints per-tenant service tokens via the same in-process path
|
|
52709
|
+
* (`createServiceTokenCore`) that the request-time webhookInvoker uses,
|
|
52710
|
+
* driven by the supplied dataAdapter.
|
|
52711
|
+
* 4. Runs `drainOutbox`, then `cleanupOutbox`.
|
|
52712
|
+
*
|
|
52713
|
+
* This is intended to be the entire body of a consumer's scheduled handler
|
|
52714
|
+
* for outbox maintenance — consumers should not need to call `drainOutbox` /
|
|
52715
|
+
* `cleanupOutbox` / `createDefaultDestinations` directly.
|
|
52716
|
+
*
|
|
52717
|
+
* @example
|
|
52718
|
+
* ```ts
|
|
52719
|
+
* export default {
|
|
52720
|
+
* async scheduled(_event, env) {
|
|
52721
|
+
* await runOutboxRelay({
|
|
52722
|
+
* dataAdapter,
|
|
52723
|
+
* issuer: env.ISSUER,
|
|
52724
|
+
* webhookInvoker, // same function passed to init()
|
|
52725
|
+
* retentionDays: 7,
|
|
52726
|
+
* });
|
|
52727
|
+
* },
|
|
52728
|
+
* };
|
|
52729
|
+
* ```
|
|
52730
|
+
*/
|
|
52731
|
+
export declare function runOutboxRelay(config: RunOutboxRelayConfig): Promise<void>;
|
|
52602
52732
|
export declare class LogsDestination implements EventDestination {
|
|
52603
52733
|
name: string;
|
|
52604
52734
|
private logs;
|
|
@@ -52617,39 +52747,6 @@ export declare class LogsDestination implements EventDestination {
|
|
|
52617
52747
|
log: LogInsert;
|
|
52618
52748
|
}[]): Promise<void>;
|
|
52619
52749
|
}
|
|
52620
|
-
export type GetServiceToken = (tenantId: string) => Promise<string>;
|
|
52621
|
-
export interface WebhookInvocation {
|
|
52622
|
-
eventId: string;
|
|
52623
|
-
tenantId: string;
|
|
52624
|
-
triggerId: string;
|
|
52625
|
-
payload: {
|
|
52626
|
-
tenant_id: string;
|
|
52627
|
-
trigger_id: string;
|
|
52628
|
-
user?: unknown;
|
|
52629
|
-
request?: unknown;
|
|
52630
|
-
};
|
|
52631
|
-
}
|
|
52632
|
-
/**
|
|
52633
|
-
* Delivers `hook.*` outbox events to HTTP webhooks configured for the matching
|
|
52634
|
-
* trigger_id. Each POST includes `Idempotency-Key: {event.id}` so downstream
|
|
52635
|
-
* webhook handlers can dedupe if the outbox retries.
|
|
52636
|
-
*
|
|
52637
|
-
* The destination is constructed per-request (via `outboxMiddleware`'s
|
|
52638
|
-
* `getDestinations(ctx)` factory) so it can close over a ctx-bound service
|
|
52639
|
-
* token generator.
|
|
52640
|
-
*/
|
|
52641
|
-
export declare class WebhookDestination implements EventDestination {
|
|
52642
|
-
name: string;
|
|
52643
|
-
private hooks;
|
|
52644
|
-
private getServiceToken;
|
|
52645
|
-
private timeoutMs;
|
|
52646
|
-
constructor(hooks: HooksAdapter, getServiceToken: GetServiceToken, options?: {
|
|
52647
|
-
timeoutMs?: number;
|
|
52648
|
-
});
|
|
52649
|
-
accepts(event: AuditEvent): boolean;
|
|
52650
|
-
transform(event: AuditEvent): WebhookInvocation;
|
|
52651
|
-
deliver(events: WebhookInvocation[]): Promise<void>;
|
|
52652
|
-
}
|
|
52653
52750
|
export interface FinalizationTask {
|
|
52654
52751
|
tenantId: string;
|
|
52655
52752
|
userId: string;
|