authhero 9.0.0 → 9.1.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-52a70476.entry.js → p-cdfc4555.entry.js} +1 -1
- package/dist/assets/u/widget/{p-f6babd26.entry.js → p-eca60302.entry.js} +1 -1
- package/dist/authhero.cjs +143 -140
- package/dist/authhero.d.ts +88 -59
- package/dist/authhero.mjs +14326 -13074
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/authentication-flows/passwordless.d.ts +3 -2
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/generated/locale-types.d.ts +2 -0
- package/dist/types/helpers/client.d.ts +2 -2
- package/dist/types/helpers/revoke-user-sessions.d.ts +15 -0
- package/dist/types/helpers/scim/default-mapping.d.ts +10 -0
- package/dist/types/helpers/scim/discovery.d.ts +49 -0
- package/dist/types/helpers/scim/filter.d.ts +58 -0
- package/dist/types/helpers/scim/mint-token.d.ts +11 -0
- package/dist/types/helpers/scim/patch.d.ts +23 -0
- package/dist/types/helpers/scim/responses.d.ts +36 -0
- package/dist/types/helpers/scim/user-mapping.d.ts +76 -0
- package/dist/types/helpers/users.d.ts +73 -1
- package/dist/types/hooks/user-registration.d.ts +1 -0
- package/dist/types/index.d.ts +86 -57
- package/dist/types/middlewares/scim-auth.d.ts +19 -0
- package/dist/types/routes/auth-api/index.d.ts +14 -14
- package/dist/types/routes/auth-api/passwordless.d.ts +14 -14
- package/dist/types/routes/management-api/authentication-methods.d.ts +1 -1
- package/dist/types/routes/management-api/branding.d.ts +1 -1
- 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/forms.d.ts +14 -0
- package/dist/types/routes/management-api/guardian.d.ts +5 -5
- package/dist/types/routes/management-api/index.d.ts +63 -38
- package/dist/types/routes/management-api/logs.d.ts +4 -4
- package/dist/types/routes/management-api/organizations.d.ts +2 -2
- package/dist/types/routes/management-api/prompts.d.ts +6 -4
- package/dist/types/routes/management-api/scim.d.ts +187 -0
- package/dist/types/routes/management-api/tenants.d.ts +6 -6
- package/dist/types/routes/management-api/users-by-email.d.ts +1 -0
- package/dist/types/routes/management-api/users.d.ts +10 -2
- package/dist/types/routes/scim/index.d.ts +6 -0
- package/dist/types/routes/universal-login/common.d.ts +1 -0
- package/dist/types/routes/universal-login/screens/types.d.ts +9 -0
- package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
- package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
- package/dist/types/types/AuthError.d.ts +1 -1
- package/dist/types/utils/cookies.d.ts +11 -0
- package/package.json +6 -6
|
@@ -83,6 +83,7 @@ export declare function passwordlessGrantUser(ctx: Context<{
|
|
|
83
83
|
verify_email?: boolean | undefined;
|
|
84
84
|
last_ip?: string | undefined;
|
|
85
85
|
last_login?: string | undefined;
|
|
86
|
+
blocked?: boolean | undefined;
|
|
86
87
|
registration_completed_at?: string | undefined;
|
|
87
88
|
email?: string | undefined;
|
|
88
89
|
identities?: {
|
|
@@ -549,8 +550,8 @@ export declare function passwordlessGrantUser(ctx: Context<{
|
|
|
549
550
|
} | undefined;
|
|
550
551
|
authenticated_at?: string | undefined;
|
|
551
552
|
};
|
|
552
|
-
connectionType: "
|
|
553
|
-
authConnection: "
|
|
553
|
+
connectionType: "username" | "email" | "sms";
|
|
554
|
+
authConnection: "username" | "email" | "sms";
|
|
554
555
|
session_id: string | undefined;
|
|
555
556
|
authParams: {
|
|
556
557
|
client_id: string;
|
|
@@ -3,6 +3,8 @@ export declare const JWKS_CACHE_TIMEOUT_IN_SECONDS: number;
|
|
|
3
3
|
export declare const SILENT_AUTH_MAX_AGE_IN_SECONDS: number;
|
|
4
4
|
export declare const UNIVERSAL_AUTH_SESSION_EXPIRES_IN_SECONDS: number;
|
|
5
5
|
export declare const SILENT_COOKIE_NAME = "auth-token";
|
|
6
|
+
export declare const LAST_USED_CONNECTION_COOKIE_NAME = "last-used-connection";
|
|
7
|
+
export declare const LAST_USED_CONNECTION_MAX_AGE_IN_SECONDS: number;
|
|
6
8
|
export declare const OTP_EXPIRATION_TIME: number;
|
|
7
9
|
export declare const EMAIL_VERIFICATION_EXPIRATION_TIME: number;
|
|
8
10
|
export declare const AUTHORIZATION_CODE_EXPIRES_IN_SECONDS: number;
|
|
@@ -101,6 +101,7 @@ export interface LoginScreen {
|
|
|
101
101
|
federatedConnectionButtonText: (vars: {
|
|
102
102
|
connectionName: string;
|
|
103
103
|
}) => string;
|
|
104
|
+
lastUsedText: () => string;
|
|
104
105
|
footerLinkText: () => string;
|
|
105
106
|
footerText: () => string;
|
|
106
107
|
forgotPasswordText: () => string;
|
|
@@ -162,6 +163,7 @@ export interface LoginIdScreen {
|
|
|
162
163
|
federatedConnectionButtonText: (vars: {
|
|
163
164
|
connectionName: string;
|
|
164
165
|
}) => string;
|
|
166
|
+
lastUsedText: () => string;
|
|
165
167
|
footerLinkText: () => string;
|
|
166
168
|
footerText: () => string;
|
|
167
169
|
forgotPasswordText: () => string;
|
|
@@ -500,8 +500,8 @@ export declare const enrichedClientSchema: z.ZodObject<{
|
|
|
500
500
|
}>>;
|
|
501
501
|
}, z.core.$strip>>>;
|
|
502
502
|
enabled_clients: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
|
|
503
|
-
response_type: z.ZodOptional<z.
|
|
504
|
-
response_mode: z.ZodOptional<z.
|
|
503
|
+
response_type: z.ZodOptional<z.ZodEnum<typeof import("@authhero/adapter-interfaces").AuthorizationResponseType>>;
|
|
504
|
+
response_mode: z.ZodOptional<z.ZodEnum<typeof import("@authhero/adapter-interfaces").AuthorizationResponseMode>>;
|
|
505
505
|
is_domain_connection: z.ZodOptional<z.ZodBoolean>;
|
|
506
506
|
show_as_button: z.ZodOptional<z.ZodBoolean>;
|
|
507
507
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Context } from "hono";
|
|
2
|
+
import { Bindings, Variables } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Revoke all of a user's sessions and the refresh tokens issued under them.
|
|
5
|
+
* Used when a user is blocked — Auth0 terminates a user's sessions on block —
|
|
6
|
+
* and reused by SCIM deactivation (Phase 2, #1191).
|
|
7
|
+
*
|
|
8
|
+
* Returns the number of refresh tokens revoked. Sessions are gathered up front
|
|
9
|
+
* (across pages) before any mutation, so revoking in place cannot interfere
|
|
10
|
+
* with pagination.
|
|
11
|
+
*/
|
|
12
|
+
export declare function revokeUserSessions(ctx: Context<{
|
|
13
|
+
Bindings: Bindings;
|
|
14
|
+
Variables: Variables;
|
|
15
|
+
}>, tenant_id: string, user_id: string): Promise<number>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ScimMappingEntry } from "@authhero/adapter-interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Default SCIM ↔ AuthHero attribute mapping, mirroring Auth0's default
|
|
4
|
+
* inbound-provisioning mapping. `scim` is the SCIM resource attribute path,
|
|
5
|
+
* `auth0` the AuthHero user field. The `active` → `blocked` entry maps SCIM
|
|
6
|
+
* account status onto AuthHero's block flag; the inversion (active=false ⇒
|
|
7
|
+
* blocked=true) is applied by the provisioning layer in Phase 2, not here.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_SCIM_MAPPING: ScimMappingEntry[];
|
|
10
|
+
export declare const DEFAULT_USER_ID_ATTRIBUTE = "externalId";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ScimListResponse } from "./responses";
|
|
2
|
+
/**
|
|
3
|
+
* Static SCIM discovery documents (RFC 7643 §5–7). The capability set mirrors
|
|
4
|
+
* what AuthHero actually implements and what Auth0 advertises: PATCH and
|
|
5
|
+
* filtering yes; bulk, sort, etag, changePassword no.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Largest page the `/Users` endpoints return, advertised as
|
|
9
|
+
* `filter.maxResults` in ServiceProviderConfig. The route clamps `count` to
|
|
10
|
+
* this so the advertised ceiling and the served page size can't drift apart.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SCIM_MAX_RESULTS = 200;
|
|
13
|
+
export declare function serviceProviderConfig(location: string): {
|
|
14
|
+
schemas: string[];
|
|
15
|
+
documentationUri: string;
|
|
16
|
+
patch: {
|
|
17
|
+
supported: boolean;
|
|
18
|
+
};
|
|
19
|
+
bulk: {
|
|
20
|
+
supported: boolean;
|
|
21
|
+
maxOperations: number;
|
|
22
|
+
maxPayloadSize: number;
|
|
23
|
+
};
|
|
24
|
+
filter: {
|
|
25
|
+
supported: boolean;
|
|
26
|
+
maxResults: number;
|
|
27
|
+
};
|
|
28
|
+
changePassword: {
|
|
29
|
+
supported: boolean;
|
|
30
|
+
};
|
|
31
|
+
sort: {
|
|
32
|
+
supported: boolean;
|
|
33
|
+
};
|
|
34
|
+
etag: {
|
|
35
|
+
supported: boolean;
|
|
36
|
+
};
|
|
37
|
+
authenticationSchemes: {
|
|
38
|
+
type: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
primary: boolean;
|
|
42
|
+
}[];
|
|
43
|
+
meta: {
|
|
44
|
+
resourceType: string;
|
|
45
|
+
location: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare function resourceTypes(baseUrl: string): ScimListResponse<unknown>;
|
|
49
|
+
export declare function schemas(baseUrl: string): ScimListResponse<unknown>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal SCIM 2.0 filter support (RFC 7644 §3.4.2.2), scoped to what Okta and
|
|
3
|
+
* Microsoft Entra actually send when provisioning: equality (`eq`) on a small
|
|
4
|
+
* set of attributes, optionally combined with `and` / `or` and parentheses.
|
|
5
|
+
* Anything outside this subset throws `UnsupportedFilterError`, which the route
|
|
6
|
+
* layer turns into a SCIM 501 error — we never silently mis-evaluate a filter.
|
|
7
|
+
*
|
|
8
|
+
* Auth0's inbound SCIM documents exactly this operator set (eq / and / or), so
|
|
9
|
+
* the subset is also the parity target.
|
|
10
|
+
*/
|
|
11
|
+
export declare class UnsupportedFilterError extends Error {
|
|
12
|
+
}
|
|
13
|
+
export declare class InvalidFilterError extends Error {
|
|
14
|
+
}
|
|
15
|
+
export type ScimFilterValue = string | boolean | number;
|
|
16
|
+
export type ScimFilterNode = {
|
|
17
|
+
type: "eq";
|
|
18
|
+
attribute: string;
|
|
19
|
+
value: ScimFilterValue;
|
|
20
|
+
} | {
|
|
21
|
+
type: "and";
|
|
22
|
+
left: ScimFilterNode;
|
|
23
|
+
right: ScimFilterNode;
|
|
24
|
+
} | {
|
|
25
|
+
type: "or";
|
|
26
|
+
left: ScimFilterNode;
|
|
27
|
+
right: ScimFilterNode;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Recursive-descent parser. Grammar (precedence: or < and < comparison):
|
|
31
|
+
* filter := orExpr
|
|
32
|
+
* orExpr := andExpr ( "or" andExpr )*
|
|
33
|
+
* andExpr := primary ( "and" primary )*
|
|
34
|
+
* primary := "(" filter ")" | comparison
|
|
35
|
+
* comparison := ATTR "eq" VALUE
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseScimFilter(input: string): ScimFilterNode;
|
|
38
|
+
/**
|
|
39
|
+
* Evaluate a parsed filter against a flat attribute map (a SCIM resource
|
|
40
|
+
* projected to the attributes we support: `userName`, `externalId`, `active`,
|
|
41
|
+
* `emails.value`/`emails`). Attribute matching is case-insensitive on the name
|
|
42
|
+
* (SCIM attribute names are case-insensitive), and so is string value
|
|
43
|
+
* comparison: `userName` and `emails.value` are `caseExact: false` in our
|
|
44
|
+
* schema, and the targeted `userName` lookup is case-insensitive too, so an
|
|
45
|
+
* exact comparison here would make the same filter behave differently
|
|
46
|
+
* depending on which path served it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function evaluateScimFilter(node: ScimFilterNode, attributes: Record<string, ScimFilterValue | undefined>): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* If the filter is a single `attr eq "value"` (the overwhelmingly common IdP
|
|
51
|
+
* case — lookup before create), return that pair so the route can do a
|
|
52
|
+
* targeted DB lookup instead of scanning the connection. Returns null for
|
|
53
|
+
* compound filters.
|
|
54
|
+
*/
|
|
55
|
+
export declare function asSingleEquality(node: ScimFilterNode): {
|
|
56
|
+
attribute: string;
|
|
57
|
+
value: ScimFilterValue;
|
|
58
|
+
} | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface GeneratedScimToken {
|
|
2
|
+
token_id: string;
|
|
3
|
+
token: string;
|
|
4
|
+
token_hash: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* SHA-256 hex of the raw bearer token. The SCIM auth middleware (Phase 2)
|
|
8
|
+
* hashes the presented token the same way and looks it up via `getByHash`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hashScimToken(token: string): Promise<string>;
|
|
11
|
+
export declare function mintScimToken(): Promise<GeneratedScimToken>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal SCIM 2.0 PATCH support (RFC 7644 §3.5.2), scoped to what Okta and
|
|
3
|
+
* Microsoft Entra send when provisioning users: `add` / `replace` / `remove`
|
|
4
|
+
* with either no path (a value object merged into the resource), a simple
|
|
5
|
+
* dotted path (`active`, `name.givenName`, `displayName`), or a single
|
|
6
|
+
* value-filtered multi-valued path (`emails[type eq "work"].value`).
|
|
7
|
+
*
|
|
8
|
+
* Operates on and returns a plain SCIM resource object; the route layer maps
|
|
9
|
+
* the patched resource back to AuthHero user fields. Anything outside the
|
|
10
|
+
* supported shape throws, which the route turns into a SCIM 400/501.
|
|
11
|
+
*/
|
|
12
|
+
export declare class InvalidPatchError extends Error {
|
|
13
|
+
}
|
|
14
|
+
export declare class UnsupportedPatchError extends Error {
|
|
15
|
+
}
|
|
16
|
+
export interface ScimPatchOperation {
|
|
17
|
+
op: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
value?: unknown;
|
|
20
|
+
}
|
|
21
|
+
type Json = Record<string, unknown>;
|
|
22
|
+
export declare function applyScimPatch(resource: Json, operations: ScimPatchOperation[]): Json;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ContentfulStatusCode } from "hono/utils/http-status";
|
|
2
|
+
export declare const SCIM_ERROR_URN = "urn:ietf:params:scim:api:messages:2.0:Error";
|
|
3
|
+
export declare const SCIM_LIST_URN = "urn:ietf:params:scim:api:messages:2.0:ListResponse";
|
|
4
|
+
export declare const SCIM_PATCH_OP_URN = "urn:ietf:params:scim:api:messages:2.0:PatchOp";
|
|
5
|
+
export declare const SCIM_CONTENT_TYPE = "application/scim+json";
|
|
6
|
+
export interface ScimErrorBody {
|
|
7
|
+
schemas: string[];
|
|
8
|
+
detail: string;
|
|
9
|
+
status: string;
|
|
10
|
+
scimType?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* SCIM error object (RFC 7644 §3.12). `status` is a string, and `scimType` is
|
|
14
|
+
* only meaningful for 400s (e.g. `uniqueness`, `invalidFilter`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function scimErrorBody(status: number, detail: string, scimType?: string): ScimErrorBody;
|
|
17
|
+
/**
|
|
18
|
+
* Thrown from SCIM middleware/helpers; rendered by the SCIM app's `onError`
|
|
19
|
+
* into a proper SCIM error object with the SCIM content type.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ScimError extends Error {
|
|
22
|
+
status: ContentfulStatusCode;
|
|
23
|
+
scimType?: string;
|
|
24
|
+
constructor(status: ContentfulStatusCode, detail: string, scimType?: string);
|
|
25
|
+
}
|
|
26
|
+
export interface ScimListResponse<T> {
|
|
27
|
+
schemas: string[];
|
|
28
|
+
totalResults: number;
|
|
29
|
+
startIndex: number;
|
|
30
|
+
itemsPerPage: number;
|
|
31
|
+
Resources: T[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* SCIM ListResponse envelope (RFC 7644 §3.4.2). `startIndex` is 1-based.
|
|
35
|
+
*/
|
|
36
|
+
export declare function scimListResponse<T>(resources: T[], totalResults: number, startIndex: number, itemsPerPage: number): ScimListResponse<T>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { User } from "@authhero/adapter-interfaces";
|
|
2
|
+
import { ScimFilterValue } from "./filter";
|
|
3
|
+
export declare const SCIM_USER_SCHEMA_URN = "urn:ietf:params:scim:schemas:core:2.0:User";
|
|
4
|
+
export interface ScimEmail {
|
|
5
|
+
value: string;
|
|
6
|
+
primary?: boolean;
|
|
7
|
+
type?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ScimUserResource {
|
|
10
|
+
schemas: string[];
|
|
11
|
+
id: string;
|
|
12
|
+
externalId?: string;
|
|
13
|
+
userName?: string;
|
|
14
|
+
name?: {
|
|
15
|
+
givenName?: string;
|
|
16
|
+
familyName?: string;
|
|
17
|
+
};
|
|
18
|
+
displayName?: string;
|
|
19
|
+
emails?: ScimEmail[];
|
|
20
|
+
active: boolean;
|
|
21
|
+
meta: {
|
|
22
|
+
resourceType: "User";
|
|
23
|
+
created?: string;
|
|
24
|
+
lastModified?: string;
|
|
25
|
+
location: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The subset of user fields SCIM writes. `blocked` carries the inverse of the
|
|
30
|
+
* SCIM `active` attribute (active:false → blocked:true); `externalId` is
|
|
31
|
+
* persisted out-of-band in the scim_external_ids table by the route, not on
|
|
32
|
+
* the user row.
|
|
33
|
+
*/
|
|
34
|
+
export interface MappedUserFields {
|
|
35
|
+
email?: string;
|
|
36
|
+
username?: string;
|
|
37
|
+
given_name?: string;
|
|
38
|
+
family_name?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
blocked?: boolean;
|
|
41
|
+
externalId?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Project an AuthHero user to a SCIM User resource. Mirrors Auth0's default
|
|
45
|
+
* mapping: SCIM `id` is the AuthHero `user_id`, `active` is the inverse of
|
|
46
|
+
* `blocked`, and `externalId` comes from the connection's external-id table.
|
|
47
|
+
*/
|
|
48
|
+
export declare function userToScimResource(user: User, externalId: string | undefined, location: string): ScimUserResource;
|
|
49
|
+
/**
|
|
50
|
+
* Map a SCIM User resource (as sent on create/replace, or the result of
|
|
51
|
+
* applying a PATCH) to AuthHero user fields. `userName` becomes `email` when it
|
|
52
|
+
* looks like an address, otherwise `username`. `active` maps to the inverse of
|
|
53
|
+
* `blocked`.
|
|
54
|
+
*
|
|
55
|
+
* Attributes the resource does not carry are **omitted from the result**, not
|
|
56
|
+
* set to `undefined`: the callers spread this straight into `users.update`, and
|
|
57
|
+
* an explicit key would be indistinguishable from "clear this field". Absent
|
|
58
|
+
* therefore means "leave unchanged" — a partial PATCH never unblocks a user or
|
|
59
|
+
* wipes their name.
|
|
60
|
+
*/
|
|
61
|
+
export declare function scimResourceToUserFields(resource: {
|
|
62
|
+
userName?: string;
|
|
63
|
+
externalId?: string;
|
|
64
|
+
name?: {
|
|
65
|
+
givenName?: string;
|
|
66
|
+
familyName?: string;
|
|
67
|
+
};
|
|
68
|
+
displayName?: string;
|
|
69
|
+
emails?: ScimEmail[];
|
|
70
|
+
active?: boolean;
|
|
71
|
+
}): MappedUserFields;
|
|
72
|
+
/**
|
|
73
|
+
* Flatten a user (+ its externalId) to the attribute map the filter evaluator
|
|
74
|
+
* expects. Keys mirror the SCIM attribute names real IdPs filter on.
|
|
75
|
+
*/
|
|
76
|
+
export declare function userToFilterAttributes(user: User, externalId: string | undefined): Record<string, ScimFilterValue | undefined>;
|
|
@@ -21,12 +21,84 @@ export declare function getUserByProvider({ userAdapter, tenant_id, username, pr
|
|
|
21
21
|
* same millisecond).
|
|
22
22
|
*/
|
|
23
23
|
export declare function compareUsersByAge(a: User, b: User): number;
|
|
24
|
+
/**
|
|
25
|
+
* Order users by how recently they were used to log in (most recent first).
|
|
26
|
+
*
|
|
27
|
+
* Distinct from {@link compareUsersByAge}: that encodes the *linking* policy
|
|
28
|
+
* ("the older account is canonical"), while this answers "which of these
|
|
29
|
+
* accounts is the person actually using?" — the question behind the login
|
|
30
|
+
* screen's last-used-strategy hint.
|
|
31
|
+
*
|
|
32
|
+
* Users that have never logged in sort last. Ties fall back to
|
|
33
|
+
* `compareUsersByAge` so the ordering is fully deterministic.
|
|
34
|
+
*/
|
|
35
|
+
export declare function compareUsersByLastLogin(a: User, b: User): number;
|
|
36
|
+
interface UserExistsByEmailParams {
|
|
37
|
+
userAdapter: UserDataAdapter;
|
|
38
|
+
tenant_id: string;
|
|
39
|
+
email: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* True when any user row carries this email — primary or secondary.
|
|
43
|
+
*
|
|
44
|
+
* The login screens' signup gates only need to know whether an account exists
|
|
45
|
+
* for the address, never which row is canonical. Asking that narrower question
|
|
46
|
+
* directly (rather than via {@link getPrimaryUserByEmail}) keeps them correct
|
|
47
|
+
* on tenants running with user linking off, where several unlinked primaries
|
|
48
|
+
* legitimately share an email, and avoids throwing on a dangling `linked_to`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function userExistsByEmail({ userAdapter, tenant_id, email, }: UserExistsByEmailParams): Promise<boolean>;
|
|
24
51
|
interface GetPrimaryUserByEmailParams {
|
|
25
52
|
userAdapter: UserDataAdapter;
|
|
26
53
|
tenant_id: string;
|
|
27
54
|
email: string;
|
|
55
|
+
/**
|
|
56
|
+
* Log when more than one primary shares the email. Only meaningful on
|
|
57
|
+
* account-linking paths, where duplicate primaries mean linking failed to
|
|
58
|
+
* converge. With `userLinkingMode: "off"` several primaries per email is the
|
|
59
|
+
* expected steady state (it's Auth0's default behaviour), so read paths
|
|
60
|
+
* leave this off rather than logging an error on every login.
|
|
61
|
+
*/
|
|
62
|
+
warnOnMultiplePrimaries?: boolean;
|
|
28
63
|
}
|
|
29
|
-
export declare function getPrimaryUserByEmail({ userAdapter, tenant_id, email, }: GetPrimaryUserByEmailParams): Promise<User | undefined>;
|
|
64
|
+
export declare function getPrimaryUserByEmail({ userAdapter, tenant_id, email, warnOnMultiplePrimaries, }: GetPrimaryUserByEmailParams): Promise<User | undefined>;
|
|
65
|
+
interface GetLastUsedUserByEmailParams {
|
|
66
|
+
userAdapter: UserDataAdapter;
|
|
67
|
+
tenant_id: string;
|
|
68
|
+
email: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The account for `email` that was most recently logged in to.
|
|
72
|
+
*
|
|
73
|
+
* Used for UI hints that describe *this person's habits* — chiefly the
|
|
74
|
+
* last-used-strategy shortcut on the identifier screen. When linking is off, an
|
|
75
|
+
* email can map to several primaries (say a password account and a Google one);
|
|
76
|
+
* picking the oldest, as {@link getPrimaryUserByEmail} does, would hand back
|
|
77
|
+
* whichever account they happened to create first and hint at a login method
|
|
78
|
+
* they may have abandoned. Picking by `last_login` follows the account actually
|
|
79
|
+
* in use.
|
|
80
|
+
*
|
|
81
|
+
* Deliberately *not* provider-biased: preferring the password account would
|
|
82
|
+
* push habitual social users to the password screen.
|
|
83
|
+
*
|
|
84
|
+
* When only secondaries match, the cluster root is returned — login updates
|
|
85
|
+
* land on the primary, so that's where the hint lives. Unlike
|
|
86
|
+
* `getPrimaryUserByEmail` a dangling `linked_to` yields `undefined` rather than
|
|
87
|
+
* throwing; callers fall back to the tenant's default strategy, which is the
|
|
88
|
+
* right outcome for a hint.
|
|
89
|
+
*/
|
|
90
|
+
export declare function getLastUsedUserByEmail({ userAdapter, tenant_id, email, }: GetLastUsedUserByEmailParams): Promise<User | undefined>;
|
|
91
|
+
/**
|
|
92
|
+
* Resolve a user to the primary of its linked cluster. Follows a single
|
|
93
|
+
* `linked_to` hop — the linking invariants keep clusters one level deep
|
|
94
|
+
* (see {@link repointPrimary}) — and falls back to the given user on a
|
|
95
|
+
* dangling link so callers never lose the identity they started with.
|
|
96
|
+
*
|
|
97
|
+
* Used by the forms engine so that post-login profile forms evaluate
|
|
98
|
+
* router conditions against, and stamp submitted values onto, the primary
|
|
99
|
+
* identity even when the session points at a secondary.
|
|
100
|
+
*/
|
|
101
|
+
export declare function resolvePrimaryUser(userAdapter: UserDataAdapter, tenant_id: string, user: User): Promise<User>;
|
|
30
102
|
interface RepointPrimaryParams {
|
|
31
103
|
userAdapter: UserDataAdapter;
|
|
32
104
|
tenant_id: string;
|
|
@@ -61,6 +61,7 @@ export declare function createUserHooks(ctx: Context<{
|
|
|
61
61
|
verify_email?: boolean | undefined;
|
|
62
62
|
last_ip?: string | undefined;
|
|
63
63
|
last_login?: string | undefined;
|
|
64
|
+
blocked?: boolean | undefined;
|
|
64
65
|
registration_completed_at?: string | undefined;
|
|
65
66
|
email?: string | undefined;
|
|
66
67
|
identities?: {
|