@authhero/adapter-interfaces 4.8.1 → 4.10.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,10 +37,39 @@ 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>;
56
+ /**
57
+ * Soft-revoke every refresh token owned by a session that isn't already
58
+ * revoked. This is the cascade behind "revoking a session revokes its
59
+ * refresh tokens" — deliberate revocation only.
60
+ *
61
+ * It must never be called for a session that merely *expired* or that
62
+ * cleanup removed: a refresh token is designed to outlive its session, and
63
+ * killing tokens on an SSO timeout would log out every long-lived native
64
+ * client. Lifetime does not couple; revocation does.
65
+ *
66
+ * Rows minted before `session_id` existed carry no value here and are not
67
+ * matched — callers sweep `revokeByLoginSession` alongside this until those
68
+ * rows have aged out (#1259).
69
+ *
70
+ * Returns the number of tokens revoked.
71
+ */
72
+ revokeBySession: (tenant_id: string, session_id: string, revoked_at: string) => Promise<number>;
30
73
  /**
31
74
  * Soft-revoke every refresh token that shares `family_id` and isn't already
32
75
  * revoked. Used for reuse detection (entire rotation chain torched) and for
@@ -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>;
@@ -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;
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.1",
14
+ "version": "4.10.0",
15
15
  "files": [
16
16
  "dist"
17
17
  ],