authhero 9.40.0 → 9.42.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/assets/u/widget/authhero-widget.esm.js +1 -1
- package/dist/assets/u/widget/index.esm.js +1 -1
- package/dist/assets/u/widget/p-6774edd2.entry.js +1 -0
- package/dist/authhero.cjs +114 -111
- package/dist/authhero.d.ts +707 -431
- package/dist/authhero.mjs +16567 -12663
- package/dist/{mfa-BlaRHQgI.js → mfa-C8qBEQeH.js} +2 -2
- package/dist/{mfa-Ddp9JT1l.mjs → mfa-CVF4Wbdz.mjs} +106 -106
- package/dist/mfa-attempts-CzGjIGzD.js +395 -0
- package/dist/{mfa-attempts-YsmteBp0.mjs → mfa-attempts-sV0Xs59R.mjs} +5651 -5026
- package/dist/{passkey-enrollment-CLg7RteL.js → passkey-enrollment-CAb2zWEF.js} +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/authentication-flows/mfa-attempts.d.ts +7 -0
- package/dist/types/authentication-flows/passwordless.d.ts +2 -2
- package/dist/types/generated/locale-types.d.ts +6 -0
- package/dist/types/helpers/client.d.ts +26 -0
- package/dist/types/helpers/login-migration.d.ts +56 -0
- package/dist/types/helpers/login-version.d.ts +18 -0
- package/dist/types/helpers/management-audience.d.ts +11 -0
- package/dist/types/helpers/reserved-claims.d.ts +2 -2
- package/dist/types/helpers/saml-connection-options.d.ts +24 -0
- package/dist/types/helpers/saml-request-signature.d.ts +36 -0
- package/dist/types/hooks/codehooks.d.ts +45 -0
- package/dist/types/hooks/lifecycle-codehooks.d.ts +1 -1
- package/dist/types/index.d.ts +426 -207
- package/dist/types/routes/auth-api/authorize.d.ts +13 -13
- package/dist/types/routes/auth-api/callback.d.ts +42 -6
- package/dist/types/routes/auth-api/device.d.ts +13 -13
- package/dist/types/routes/auth-api/index.d.ts +103 -67
- package/dist/types/routes/auth-api/logout.d.ts +2 -2
- package/dist/types/routes/auth-api/oidc-logout.d.ts +3 -3
- package/dist/types/routes/auth-api/passwordless.d.ts +16 -16
- package/dist/types/routes/auth-api/revoke.d.ts +6 -6
- package/dist/types/routes/auth-api/token.d.ts +12 -12
- package/dist/types/routes/management-api/action-executions.d.ts +1 -1
- package/dist/types/routes/management-api/action-triggers.d.ts +25 -25
- package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
- package/dist/types/routes/management-api/branding.d.ts +3 -3
- package/dist/types/routes/management-api/clients.d.ts +30 -0
- package/dist/types/routes/management-api/connections.d.ts +91 -1
- package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
- package/dist/types/routes/management-api/email-templates.d.ts +18 -18
- package/dist/types/routes/management-api/failed-events.d.ts +2 -2
- package/dist/types/routes/management-api/forms.d.ts +152 -152
- package/dist/types/routes/management-api/guardian.d.ts +5 -5
- package/dist/types/routes/management-api/helpers.d.ts +1 -1
- package/dist/types/routes/management-api/hooks.d.ts +21 -21
- package/dist/types/routes/management-api/index.d.ts +233 -113
- package/dist/types/routes/management-api/keys.d.ts +16 -16
- package/dist/types/routes/management-api/log-streams.d.ts +6 -6
- package/dist/types/routes/management-api/logs.d.ts +4 -4
- 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 +6 -6
- package/dist/types/routes/management-api/roles.d.ts +1 -1
- package/dist/types/routes/management-api/rollouts.d.ts +6 -6
- package/dist/types/routes/management-api/self-service-profiles.d.ts +7 -7
- package/dist/types/routes/management-api/tenant-operations.d.ts +5 -5
- package/dist/types/routes/management-api/tenants.d.ts +13 -9
- package/dist/types/routes/management-api/users.d.ts +35 -35
- package/dist/types/routes/saml/index.d.ts +72 -9
- package/dist/types/routes/saml/samlp.d.ts +72 -9
- package/dist/types/routes/universal-login/common.d.ts +2 -0
- package/dist/types/routes/universal-login/continue.d.ts +4 -4
- package/dist/types/routes/universal-login/flow-api.d.ts +12 -12
- package/dist/types/routes/universal-login/identifier.d.ts +2 -2
- package/dist/types/routes/universal-login/impersonate.d.ts +4 -4
- package/dist/types/routes/universal-login/index.d.ts +8 -8
- package/dist/types/routes/universal-login/screens/login-otp.d.ts +79 -5
- package/dist/types/routes/universal-login/screens/magic-link-sent.d.ts +8 -1
- package/dist/types/routes/universal-login/u2-index.d.ts +9 -9
- package/dist/types/routes/universal-login/u2-routes.d.ts +8 -7
- package/dist/types/state-machines/login-session-data.d.ts +36 -1
- package/dist/types/state-machines/login-session.d.ts +17 -1
- package/dist/types/strategies/index.d.ts +2 -0
- package/dist/types/strategies/samlp.d.ts +58 -0
- package/dist/types/types/AuthHeroConfig.d.ts +15 -1
- package/dist/types/types/Bindings.d.ts +2 -1
- package/dist/types/types/Variables.d.ts +2 -0
- package/dist/types/utils/ssrf-fetch.d.ts +2 -0
- package/dist/types/variables.d.ts +7 -6
- package/package.json +9 -6
- package/dist/assets/u/widget/p-d0eb5acc.entry.js +0 -1
- package/dist/mfa-attempts-bPJnyu2c.js +0 -385
|
@@ -40,6 +40,13 @@ export declare function resetMfaFailures(ctx: MfaContext, tenantId: string, logi
|
|
|
40
40
|
* Count an MFA SMS send on the login session and consume the per-user (or,
|
|
41
41
|
* without a user, per-number) rate limit. Throws MfaSmsRateLimitError when
|
|
42
42
|
* either limit is reached. Counted before sending, so failed sends count too.
|
|
43
|
+
*
|
|
44
|
+
* Order: check the session without writing (finalized or expired sessions
|
|
45
|
+
* throw FinalizedLoginSessionError, at the cap MfaSmsRateLimitError), then the
|
|
46
|
+
* rate limit, then reserve the slot atomically (see
|
|
47
|
+
* reserveLoginSessionCounter). Neither a finished session nor a send the rate
|
|
48
|
+
* limit rejects uses up the shared rate limit or the session's allowance, and
|
|
49
|
+
* concurrent sends on one session cannot exceed MFA_MAX_SMS_SENDS.
|
|
43
50
|
*/
|
|
44
51
|
export declare function enforceMfaSmsSendLimit(ctx: MfaContext, tenantId: string, loginSessionId: string, phoneNumber: string, userId?: string): Promise<void>;
|
|
45
52
|
export {};
|
|
@@ -175,8 +175,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
|
|
|
175
175
|
authenticated_at?: string | undefined;
|
|
176
176
|
tenant_id?: string | undefined;
|
|
177
177
|
};
|
|
178
|
-
connectionType: "
|
|
179
|
-
authConnection: "
|
|
178
|
+
connectionType: "email" | "username" | "sms";
|
|
179
|
+
authConnection: "email" | "username" | "sms";
|
|
180
180
|
session_id: string | undefined;
|
|
181
181
|
authParams: {
|
|
182
182
|
audience?: string | undefined;
|
|
@@ -324,6 +324,8 @@ export interface EmailOtpChallengeScreen {
|
|
|
324
324
|
clientName: string;
|
|
325
325
|
}) => string;
|
|
326
326
|
resendText: () => string;
|
|
327
|
+
resendSuccess: () => string;
|
|
328
|
+
resendFailed: () => string;
|
|
327
329
|
sessionExpired: () => string;
|
|
328
330
|
title: () => string;
|
|
329
331
|
unexpectedError: () => string;
|
|
@@ -609,6 +611,8 @@ export interface MagicLinkSentScreen {
|
|
|
609
611
|
username: string;
|
|
610
612
|
}) => string;
|
|
611
613
|
resendText: () => string;
|
|
614
|
+
resendSuccess: () => string;
|
|
615
|
+
resendFailed: () => string;
|
|
612
616
|
spamText: () => string;
|
|
613
617
|
title: () => string;
|
|
614
618
|
}
|
|
@@ -985,6 +989,8 @@ export interface SmsOtpChallengeScreen {
|
|
|
985
989
|
clientName: string;
|
|
986
990
|
}) => string;
|
|
987
991
|
resendText: () => string;
|
|
992
|
+
resendSuccess: () => string;
|
|
993
|
+
resendFailed: () => string;
|
|
988
994
|
sessionExpired: () => string;
|
|
989
995
|
title: () => string;
|
|
990
996
|
unexpectedError: () => string;
|
|
@@ -236,6 +236,10 @@ export declare const enrichedClientSchema: z.ZodObject<{
|
|
|
236
236
|
use_scope_descriptions_for_consent: z.ZodOptional<z.ZodBoolean>;
|
|
237
237
|
inherit_global_permissions_in_organizations: z.ZodOptional<z.ZodBoolean>;
|
|
238
238
|
restrict_undefined_scopes: z.ZodOptional<z.ZodBoolean>;
|
|
239
|
+
universal_login_version: z.ZodOptional<z.ZodEnum<{
|
|
240
|
+
1: "1";
|
|
241
|
+
2: "2";
|
|
242
|
+
}>>;
|
|
239
243
|
}, z.core.$strip>>;
|
|
240
244
|
sandbox_version: z.ZodOptional<z.ZodString>;
|
|
241
245
|
legacy_sandbox_version: z.ZodOptional<z.ZodString>;
|
|
@@ -547,6 +551,28 @@ export declare const enrichedClientSchema: z.ZodObject<{
|
|
|
547
551
|
on_first_login: "on_first_login";
|
|
548
552
|
never_on_login: "never_on_login";
|
|
549
553
|
}>>;
|
|
554
|
+
signInEndpoint: z.ZodOptional<z.ZodString>;
|
|
555
|
+
signOutEndpoint: z.ZodOptional<z.ZodString>;
|
|
556
|
+
signingCert: z.ZodOptional<z.ZodString>;
|
|
557
|
+
signingCerts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
558
|
+
metadataUrl: z.ZodOptional<z.ZodString>;
|
|
559
|
+
metadataXml: z.ZodOptional<z.ZodString>;
|
|
560
|
+
signSAMLRequest: z.ZodOptional<z.ZodBoolean>;
|
|
561
|
+
signatureAlgorithm: z.ZodOptional<z.ZodEnum<{
|
|
562
|
+
"rsa-sha256": "rsa-sha256";
|
|
563
|
+
"rsa-sha1": "rsa-sha1";
|
|
564
|
+
}>>;
|
|
565
|
+
digestAlgorithm: z.ZodOptional<z.ZodEnum<{
|
|
566
|
+
sha256: "sha256";
|
|
567
|
+
sha1: "sha1";
|
|
568
|
+
}>>;
|
|
569
|
+
protocolBinding: z.ZodOptional<z.ZodEnum<{
|
|
570
|
+
"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect";
|
|
571
|
+
"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST";
|
|
572
|
+
}>>;
|
|
573
|
+
user_id_attribute: z.ZodOptional<z.ZodString>;
|
|
574
|
+
fieldsMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
575
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
550
576
|
}, z.core.$strip>>>;
|
|
551
577
|
enabled_clients: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
|
|
552
578
|
response_type: z.ZodOptional<z.ZodEnum<typeof import("@authhero/adapter-interfaces").AuthorizationResponseType>>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Client, DataAdapters, Tenant } from "@authhero/adapter-interfaces";
|
|
2
|
+
import { LoginRoutePrefix } from "./login-version";
|
|
3
|
+
/**
|
|
4
|
+
* Tooling for moving tenants from the classic login (/u) to the widget login
|
|
5
|
+
* (/u2). Adapter-agnostic so the CLI in `scripts/login-migration.ts` can run
|
|
6
|
+
* it against any database.
|
|
7
|
+
*/
|
|
8
|
+
export type LoginMigrationData = Pick<DataAdapters, "tenants" | "clients" | "promptSettings" | "themes" | "branding" | "universalLoginTemplates" | "customText" | "promptPartials">;
|
|
9
|
+
export type CheckStatus = "ok" | "warn" | "info";
|
|
10
|
+
export interface LoginMigrationCheck {
|
|
11
|
+
id: string;
|
|
12
|
+
status: CheckStatus;
|
|
13
|
+
message: string;
|
|
14
|
+
}
|
|
15
|
+
export interface LoginMigrationClient {
|
|
16
|
+
client_id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
override?: string;
|
|
19
|
+
prefix: LoginRoutePrefix;
|
|
20
|
+
}
|
|
21
|
+
export interface LoginMigrationReport {
|
|
22
|
+
tenant_id: string;
|
|
23
|
+
/** The tenant flag `flags.universal_login_version`, if set. */
|
|
24
|
+
tenant_version?: string;
|
|
25
|
+
clients: LoginMigrationClient[];
|
|
26
|
+
/** Clients that resolve to /u today. */
|
|
27
|
+
unmigrated: number;
|
|
28
|
+
checks: LoginMigrationCheck[];
|
|
29
|
+
}
|
|
30
|
+
export declare function listAllClients(data: Pick<DataAdapters, "clients">, tenantId: string): Promise<Client[]>;
|
|
31
|
+
export declare function listAllTenants(data: Pick<DataAdapters, "tenants">): Promise<Tenant[]>;
|
|
32
|
+
/** How each of a tenant's clients resolves today. */
|
|
33
|
+
export declare function resolveTenantClients(tenant: Tenant, clients: Client[]): LoginMigrationClient[];
|
|
34
|
+
export declare function auditLoginMigration(data: LoginMigrationData, tenantId: string): Promise<LoginMigrationReport>;
|
|
35
|
+
/**
|
|
36
|
+
* Probes whether the widget bundle is served from a deployment. The database
|
|
37
|
+
* can't tell whether `widgetHandler` is mounted, and deployments that ship the
|
|
38
|
+
* bundle as static assets have no handler at all.
|
|
39
|
+
*/
|
|
40
|
+
export declare function checkWidgetServed(baseUrl: string, fetchFn?: typeof fetch): Promise<LoginMigrationCheck>;
|
|
41
|
+
export interface SetTenantVersionResult {
|
|
42
|
+
tenant_id: string;
|
|
43
|
+
from?: string;
|
|
44
|
+
to?: string;
|
|
45
|
+
/** Clients pinned to /u by a "1" override, which stay on /u. */
|
|
46
|
+
pinned: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets (or with `undefined`, removes) the tenant flag
|
|
50
|
+
* `flags.universal_login_version`. Client overrides are left untouched.
|
|
51
|
+
* Removing the flag restores the earlier routing only if the tenant had no
|
|
52
|
+
* flag or "1" before; `from` in the result reports the previous value.
|
|
53
|
+
*/
|
|
54
|
+
export declare function setTenantLoginVersion(data: Pick<LoginMigrationData, "tenants" | "clients">, tenantId: string, version: "1" | "2" | undefined, { dryRun }?: {
|
|
55
|
+
dryRun?: boolean;
|
|
56
|
+
}): Promise<SetTenantVersionResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type LoginRoutePrefix = "/u" | "/u2";
|
|
2
|
+
type ClientLike = {
|
|
3
|
+
client_metadata?: Record<string, unknown> | null;
|
|
4
|
+
tenant?: {
|
|
5
|
+
flags?: {
|
|
6
|
+
universal_login_version?: string;
|
|
7
|
+
} | null;
|
|
8
|
+
} | null;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Picks the universal login a client uses.
|
|
12
|
+
*
|
|
13
|
+
* A client can override the tenant with `client_metadata.universal_login_version`
|
|
14
|
+
* ("2" → /u2, "1" → /u). Without an override the tenant flag
|
|
15
|
+
* `flags.universal_login_version` decides ("2" → /u2, "1" or unset → /u).
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveLoginRoutePrefix(client: ClientLike): LoginRoutePrefix;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import type { Bindings, Variables } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* True when `audience` is one the Management API accepts for this tenant: the
|
|
5
|
+
* built-in `urn:authhero:management` identifier, or one of the extra audiences
|
|
6
|
+
* the deployment configured with `init({ additionalManagementAudiences })`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isManagementApiAudience(ctx: Context<{
|
|
9
|
+
Bindings: Bindings;
|
|
10
|
+
Variables: Variables;
|
|
11
|
+
}>, tenantId: string | undefined, audience: string): Promise<boolean>;
|
|
@@ -14,9 +14,9 @@ export declare const USERINFO_RESERVED_CLAIMS: readonly ["iss", "sub", "aud", "e
|
|
|
14
14
|
* vendor/tenant for downstream APIs while `sub` stays `auth-service`.
|
|
15
15
|
* Client-bound mints keep `azp` locked (see below).
|
|
16
16
|
*/
|
|
17
|
-
export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("
|
|
17
|
+
export declare const SERVICE_TOKEN_RESERVED_CLAIMS: ("scope" | "client_id" | "sid" | "tenant_id" | "org_name" | "iss" | "sub" | "aud" | "exp" | "iat" | "auth_time" | "acr" | "amr" | "jti" | "permissions" | "org_id" | "gty" | "nbf" | "act" | "requested_userinfo_claims")[];
|
|
18
18
|
/** Client-bound mints: `azp` must stay the registered client id. */
|
|
19
|
-
export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("
|
|
19
|
+
export declare const CLIENT_SERVICE_TOKEN_RESERVED_CLAIMS: ("scope" | "client_id" | "sid" | "tenant_id" | "org_name" | "iss" | "sub" | "aud" | "exp" | "iat" | "auth_time" | "acr" | "amr" | "azp" | "jti" | "permissions" | "org_id" | "gty" | "nbf" | "act" | "requested_userinfo_claims")[];
|
|
20
20
|
export type AccessTokenReservedClaim = (typeof ACCESS_TOKEN_RESERVED_CLAIMS)[number];
|
|
21
21
|
export type IdTokenReservedClaim = (typeof ID_TOKEN_RESERVED_CLAIMS)[number];
|
|
22
22
|
/**
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Context } from "hono";
|
|
2
|
+
import { Connection } from "@authhero/adapter-interfaces";
|
|
3
|
+
import { Bindings, Variables } from "../types";
|
|
4
|
+
type ConnectionOptions = Connection["options"];
|
|
5
|
+
/**
|
|
6
|
+
* Fills a `samlp` connection's options from IdP metadata, the way Auth0 does
|
|
7
|
+
* when `metadataXml` or `metadataUrl` is set: signInEndpoint, signOutEndpoint,
|
|
8
|
+
* signingCert(s) and the IdP entity ID (stored as `issuer`, which responses
|
|
9
|
+
* are then checked against).
|
|
10
|
+
*
|
|
11
|
+
* Metadata is (re)read when it is new or changed, when clearing
|
|
12
|
+
* `metadataXml` leaves `metadataUrl` as the only source, when the request
|
|
13
|
+
* binding changed, or when the options still lack a sign-in endpoint or
|
|
14
|
+
* certificate, so the saved values always come from the current source and
|
|
15
|
+
* the saved endpoint is one the IdP offers for the saved binding.
|
|
16
|
+
* Then validates the result, so a bad configuration fails the save rather
|
|
17
|
+
* than every login: certificates must parse as X.509, and signed requests
|
|
18
|
+
* need the HTTP-Redirect binding.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveSamlConnectionOptions(ctx: Context<{
|
|
21
|
+
Bindings: Bindings;
|
|
22
|
+
Variables: Variables;
|
|
23
|
+
}>, options: ConnectionOptions, previous?: ConnectionOptions): Promise<ConnectionOptions>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Context } from "hono";
|
|
2
|
+
import { Bindings, Variables } from "../types";
|
|
3
|
+
import { EnrichedClient } from "./client";
|
|
4
|
+
type SamlRequestToVerify = {
|
|
5
|
+
binding: "redirect";
|
|
6
|
+
/** The raw, still URL-encoded query string of the request. */
|
|
7
|
+
rawQuery: string;
|
|
8
|
+
} | {
|
|
9
|
+
binding: "post";
|
|
10
|
+
xml: string;
|
|
11
|
+
/** The root element the signature must cover. */
|
|
12
|
+
rootElement: "AuthnRequest" | "LogoutRequest";
|
|
13
|
+
};
|
|
14
|
+
export declare class SamlRequestSignatureError extends Error {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Enforces signed SAML requests from a service provider, as Auth0 does: when
|
|
19
|
+
* the client's samlp addon has a `signingCert`, every AuthnRequest and
|
|
20
|
+
* LogoutRequest must be signed with it. `require_signed_requests` without a
|
|
21
|
+
* certificate fails closed, since nothing can be verified.
|
|
22
|
+
*
|
|
23
|
+
* HTTP-Redirect signatures are checked with WebCrypto. HTTP-POST requests
|
|
24
|
+
* carry an XML signature, checked with `ctx.env.samlVerifier`; it must cover
|
|
25
|
+
* the document's root request element itself: a signed reference counts only
|
|
26
|
+
* when its root has exactly the posted root's ID, and IDs are unique (the
|
|
27
|
+
* verifier refuses duplicates), so a signed element wrapped in an unsigned
|
|
28
|
+
* request is refused.
|
|
29
|
+
*
|
|
30
|
+
* @throws SamlRequestSignatureError when the request must be signed and isn't.
|
|
31
|
+
*/
|
|
32
|
+
export declare function verifySamlRequestSignature(ctx: Context<{
|
|
33
|
+
Bindings: Bindings;
|
|
34
|
+
Variables: Variables;
|
|
35
|
+
}>, client: EnrichedClient, request: SamlRequestToVerify): Promise<void>;
|
|
36
|
+
export {};
|
|
@@ -74,12 +74,44 @@ export declare function replayApiCalls(apiCalls: Array<{
|
|
|
74
74
|
method: string;
|
|
75
75
|
args: unknown[];
|
|
76
76
|
}>, api: CodeHookApi): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Why an action produced no usable result: it ran past the host's timeout, or
|
|
79
|
+
* it failed (threw, returned `success: false`, its code is missing, or no code
|
|
80
|
+
* executor is configured). Used by the fail-closed option (issue #1816).
|
|
81
|
+
*/
|
|
82
|
+
export type CodeHookFailure = "action_timeout" | "action_failed";
|
|
77
83
|
export type HandleCodeHookOutcome = {
|
|
78
84
|
result: ActionExecutionResult;
|
|
79
85
|
logs: CodeExecutionLog[];
|
|
80
86
|
/** True if the executor recorded an API call that cancels the flow. */
|
|
81
87
|
denied: boolean;
|
|
88
|
+
/** Set when the action did not run to completion. */
|
|
89
|
+
failure?: CodeHookFailure;
|
|
82
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Hook `metadata` key: `true` makes a failing action deny the request instead
|
|
93
|
+
* of letting it continue. Shared with `pre-screen`, which reads the same key.
|
|
94
|
+
*/
|
|
95
|
+
export declare const HOOK_FAIL_CLOSED_METADATA_KEY = "fail_closed";
|
|
96
|
+
/**
|
|
97
|
+
* True when the hook binding opted into failing closed: a timeout, a failed
|
|
98
|
+
* execution or a non-HTTP throw denies the request (issue #1816). Off by
|
|
99
|
+
* default, so an action that breaks lets the request through as before.
|
|
100
|
+
*/
|
|
101
|
+
export declare function isFailClosedHook(hook: {
|
|
102
|
+
metadata?: Record<string, unknown>;
|
|
103
|
+
}): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The outcome to record for an action that threw outside the executor (for
|
|
106
|
+
* example a replayed API call throwing a plain `Error`).
|
|
107
|
+
*/
|
|
108
|
+
export declare function thrownOutcome(actionName: string, err: unknown, denied?: boolean): HandleCodeHookOutcome;
|
|
109
|
+
/**
|
|
110
|
+
* The outcome to record when no code executor (or no tenant) was available to
|
|
111
|
+
* run a bound action. Only recorded for fail-closed bindings: a fail-open
|
|
112
|
+
* binding keeps skipping silently, as before.
|
|
113
|
+
*/
|
|
114
|
+
export declare function unavailableOutcome(actionName: string): HandleCodeHookOutcome;
|
|
83
115
|
/**
|
|
84
116
|
* Core code-hook execution, decoupled from the Hono request `ctx`.
|
|
85
117
|
*
|
|
@@ -180,9 +212,22 @@ export declare function persistActionExecution(data: Pick<DataAdapters, "actionE
|
|
|
180
212
|
* surrounding tenant log (the standard token-exchange log entry). The
|
|
181
213
|
* execution record itself follows Auth0's shape — see
|
|
182
214
|
* GET /api/v2/actions/executions/:id.
|
|
215
|
+
*
|
|
216
|
+
* `api.access.deny` stops token issuance: the execution is persisted as
|
|
217
|
+
* canceled and the 400 from `deny` is rethrown, so no tokens are signed and
|
|
218
|
+
* later actions don't run. A binding with `metadata.fail_closed` also denies
|
|
219
|
+
* when its action times out, fails or throws (issue #1816).
|
|
183
220
|
*/
|
|
184
221
|
export declare function handleCredentialsExchangeCodeHooks(ctx: Context<{
|
|
185
222
|
Bindings: Bindings;
|
|
186
223
|
Variables: Variables;
|
|
187
224
|
}>, hooks: any[], event: HookEvent, api: OnExecuteCredentialsExchangeAPI): Promise<string | null>;
|
|
225
|
+
/**
|
|
226
|
+
* Store the execution record of a denied request, then rethrow the denial.
|
|
227
|
+
* Storing it must not replace the denial with a 500.
|
|
228
|
+
*/
|
|
229
|
+
export declare function persistThenThrow(ctx: Context<{
|
|
230
|
+
Bindings: Bindings;
|
|
231
|
+
Variables: Variables;
|
|
232
|
+
}>, persist: () => Promise<string | null>, err: unknown): Promise<never>;
|
|
188
233
|
export {};
|
|
@@ -10,7 +10,7 @@ export declare function listEnabledCodeHooks(ctx: Context<{
|
|
|
10
10
|
Bindings: Bindings;
|
|
11
11
|
Variables: Variables;
|
|
12
12
|
}>, tenantId: string, triggerId: string): Promise<{
|
|
13
|
-
trigger_id: "
|
|
13
|
+
trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "post-user-update" | "validate-registration-username" | "pre-user-deletion" | "post-user-deletion" | "credentials-exchange" | "pre-user-update" | "pre-screen" | "custom-email-provider" | "custom-phone-provider";
|
|
14
14
|
enabled: boolean;
|
|
15
15
|
synchronous: boolean;
|
|
16
16
|
created_at: string;
|