@authhero/adapter-interfaces 4.8.0 → 4.9.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.
@@ -1,4 +1,18 @@
1
1
  import { RefreshToken, RefreshTokenInsert, Totals, ListParams } from "../types";
2
+ /**
3
+ * List params for refresh tokens, with `user_id` as a first-class exact
4
+ * predicate.
5
+ *
6
+ * Selecting a user through the `q` Lucene grammar is not safe here: both SQL
7
+ * adapters split `q` on ` OR ` *before* tokenizing, so a user id containing
8
+ * ` OR user_id:<other> OR ` yields a clean middle clause that matches another
9
+ * user's rows — quoting the value does not prevent it, because the quotes only
10
+ * bracket the first and last fragments. This field compiles to an equality
11
+ * comparison instead, so the id is never parsed as query syntax.
12
+ */
13
+ export interface RefreshTokenListParams extends ListParams {
14
+ user_id?: string;
15
+ }
2
16
  export interface ListRefreshTokenResponse extends Totals {
3
17
  refresh_tokens: RefreshToken[];
4
18
  }
@@ -23,9 +37,21 @@ export interface RefreshTokensAdapter {
23
37
  * matches. Callers must verify the secret hash before trusting the row.
24
38
  */
25
39
  getByLookup: (tenant_id: string, token_lookup: string) => Promise<RefreshToken | null>;
26
- list(tenant_id: string, params?: ListParams): Promise<ListRefreshTokenResponse>;
40
+ list(tenant_id: string, params?: RefreshTokenListParams): Promise<ListRefreshTokenResponse>;
27
41
  update: (tenant_id: string, id: string, refresh_token: Partial<RefreshToken>, options?: UpdateRefreshTokenOptions) => Promise<boolean>;
28
42
  remove: (tenant_id: string, id: string) => Promise<boolean>;
43
+ /**
44
+ * Soft-revoke every refresh token belonging to a user that isn't already
45
+ * revoked. Exact tenant + user predicates, so nothing goes through the `q`
46
+ * grammar.
47
+ *
48
+ * The `revoked_at IS NULL` guard also makes this safe to run concurrently:
49
+ * a second bulk revocation cannot overwrite the audit timestamp written by
50
+ * the first.
51
+ *
52
+ * Returns the number of tokens revoked.
53
+ */
54
+ revokeByUser: (tenant_id: string, user_id: string, revoked_at: string) => Promise<number>;
29
55
  revokeByLoginSession: (tenant_id: string, login_session_id: string, revoked_at: string) => Promise<number>;
30
56
  /**
31
57
  * Soft-revoke every refresh token that shares `family_id` and isn't already
@@ -2,6 +2,13 @@ import { z } from "@hono/zod-openapi";
2
2
  export declare const refreshTokenInsertSchema: z.ZodObject<{
3
3
  id: z.ZodString;
4
4
  login_id: z.ZodString;
5
+ session_id: z.ZodOptional<z.ZodString>;
6
+ organization: z.ZodOptional<z.ZodString>;
7
+ auth_connection: z.ZodOptional<z.ZodString>;
8
+ auth_strategy: z.ZodOptional<z.ZodObject<{
9
+ strategy: z.ZodString;
10
+ strategy_type: z.ZodString;
11
+ }, z.core.$strip>>;
5
12
  user_id: z.ZodString;
6
13
  client_id: z.ZodString;
7
14
  expires_at: z.ZodOptional<z.ZodString>;
@@ -30,6 +37,13 @@ export type RefreshTokenInsert = z.infer<typeof refreshTokenInsertSchema>;
30
37
  export declare const refreshTokenSchema: z.ZodObject<{
31
38
  id: z.ZodString;
32
39
  login_id: z.ZodString;
40
+ session_id: z.ZodOptional<z.ZodString>;
41
+ organization: z.ZodOptional<z.ZodString>;
42
+ auth_connection: z.ZodOptional<z.ZodString>;
43
+ auth_strategy: z.ZodOptional<z.ZodObject<{
44
+ strategy: z.ZodString;
45
+ strategy_type: z.ZodString;
46
+ }, z.core.$strip>>;
33
47
  user_id: z.ZodString;
34
48
  client_id: z.ZodString;
35
49
  expires_at: z.ZodOptional<z.ZodString>;
@@ -9,3 +9,4 @@ export * from "./hex";
9
9
  export * from "./cursor";
10
10
  export * from "./lucene";
11
11
  export * from "./session-retention";
12
+ export * from "./username-validation";
@@ -4,3 +4,4 @@
4
4
  * the query-string sanitization that enforces the tenant boundary.
5
5
  */
6
6
  export declare function sanitizeLuceneQuery(query: string, allowedFields: string[]): string;
7
+ export declare function isEmailSearchTerm(value: string): boolean;
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Split an Auth0-style `provider|id` identifier into its provider (here named
3
+ * `connection` for historical reasons) and the bare id Auth0 reports as
4
+ * `identities[].user_id`.
5
+ *
6
+ * Splits on the *first* pipe only. Enterprise identifiers embed pipes of their
7
+ * own — `samlp|okta-connection|jane` is provider `samlp` plus bare id
8
+ * `okta-connection|jane` — and returning just `okta-connection` would report an
9
+ * id that resolves to no user and that cannot be unlinked.
10
+ */
1
11
  export declare function parseUserId(user_id: string): {
2
12
  connection: string;
3
13
  id: string;
@@ -0,0 +1,21 @@
1
+ /** Mirrors Auth0's own wording, minus the "@" it allows and we don't. */
2
+ export declare const USERNAME_INVALID_CHARACTERS_MESSAGE = "Username can only contain alphanumeric characters and the following characters: '_', '+', '-', '.', '!', '#', '$', \"'\", '^', '`', '~'";
3
+ export declare const USERNAME_CONTAINS_AT_MESSAGE = "Usernames must not contain \"@\". Use the email field for email addresses.";
4
+ export declare function usernameHasOnlyAllowedCharacters(username: string): boolean;
5
+ /**
6
+ * Auth0 lowercases usernames on write, so `MyUser` and `myuser` are the same
7
+ * account. Applied at the write boundary only — never to values read back out
8
+ * of the database, which may predate this rule.
9
+ */
10
+ export declare function normalizeUsername(username: string): string;
11
+ export interface UsernameLengthBounds {
12
+ min: number;
13
+ max: number;
14
+ }
15
+ /**
16
+ * Returns an Auth0-shaped error message, or `null` when the username is valid.
17
+ * `bounds` comes from the connection's own configuration via
18
+ * `getConnectionIdentifierConfig`; omit it to skip the length check (the
19
+ * caller has no connection in hand).
20
+ */
21
+ export declare function validateUsername(username: string, bounds?: UsernameLengthBounds): string | null;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "4.8.0",
14
+ "version": "4.9.0",
15
15
  "files": [
16
16
  "dist"
17
17
  ],