@authhero/adapter-interfaces 4.6.0 → 4.8.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,4 @@
1
- import { AnalyticsQueryParams, AnalyticsQueryResponse, AnalyticsResource, SessionRetentionParams, SessionRetentionResponse } from "../types/Analytics";
1
+ import { AnalyticsQueryParams, AnalyticsQueryResponse, AnalyticsResource, RefreshTokenRetentionParams, RefreshTokenRetentionResponse, SessionRetentionParams, SessionRetentionResponse } from "../types/Analytics";
2
2
  export interface AnalyticsAdapter {
3
3
  /**
4
4
  * Run an analytics query for a tenant. The adapter is responsible for
@@ -13,4 +13,13 @@ export interface AnalyticsAdapter {
13
13
  * route responds 501 when it is absent.
14
14
  */
15
15
  sessionRetention?(tenantId: string, params: SessionRetentionParams): Promise<SessionRetentionResponse>;
16
+ /**
17
+ * Weekly refresh-token cohort retention, computed from the refresh_tokens
18
+ * table. Rotating tokens mint a new row per exchange, so rows are grouped
19
+ * into rotation families before folding: a family's cohort week comes from
20
+ * its first token's created_at_ts and its last-active week from the max of
21
+ * last_exchanged_at_ts/created_at_ts across the family. Optional for the
22
+ * same reason as sessionRetention.
23
+ */
24
+ refreshTokenRetention?(tenantId: string, params: RefreshTokenRetentionParams): Promise<RefreshTokenRetentionResponse>;
16
25
  }
@@ -96,6 +96,36 @@ export interface SessionRetentionResponse {
96
96
  to: string;
97
97
  cohorts: SessionRetentionCohort[];
98
98
  }
99
+ export interface RefreshTokenRetentionParams {
100
+ /** Number of weekly cohorts to include, counting back from the current week */
101
+ weeks: number;
102
+ /** Optional filter to one or more client IDs */
103
+ client_id?: string[];
104
+ }
105
+ export interface RefreshTokenRetentionCohort {
106
+ /** ISO date (UTC Monday) the cohort week starts on */
107
+ cohort: string;
108
+ /**
109
+ * Refresh-token families created during the cohort week. Rotating tokens
110
+ * mint a new row on every exchange, so the retention unit is the rotation
111
+ * family (a non-rotating token is a family of one).
112
+ */
113
+ tokens: number;
114
+ /**
115
+ * active[k] = token families still active k weeks after the cohort week,
116
+ * i.e. last exchanged during week k or later. active[0] === tokens. The
117
+ * array is truncated at the current week.
118
+ */
119
+ active: number[];
120
+ }
121
+ export interface RefreshTokenRetentionResponse {
122
+ interval: "week";
123
+ /** Inclusive lower bound of the first cohort week */
124
+ from: string;
125
+ /** Timestamp the query ran at; the last cohort week is still in progress */
126
+ to: string;
127
+ cohorts: RefreshTokenRetentionCohort[];
128
+ }
99
129
  export declare const sessionRetentionCohortSchema: z.ZodObject<{
100
130
  cohort: z.ZodString;
101
131
  sessions: z.ZodNumber;
@@ -111,6 +141,21 @@ export declare const sessionRetentionResponseSchema: z.ZodObject<{
111
141
  active: z.ZodArray<z.ZodNumber>;
112
142
  }, z.core.$strip>>;
113
143
  }, z.core.$strip>;
144
+ export declare const refreshTokenRetentionCohortSchema: z.ZodObject<{
145
+ cohort: z.ZodString;
146
+ tokens: z.ZodNumber;
147
+ active: z.ZodArray<z.ZodNumber>;
148
+ }, z.core.$strip>;
149
+ export declare const refreshTokenRetentionResponseSchema: z.ZodObject<{
150
+ interval: z.ZodLiteral<"week">;
151
+ from: z.ZodString;
152
+ to: z.ZodString;
153
+ cohorts: z.ZodArray<z.ZodObject<{
154
+ cohort: z.ZodString;
155
+ tokens: z.ZodNumber;
156
+ active: z.ZodArray<z.ZodNumber>;
157
+ }, z.core.$strip>>;
158
+ }, z.core.$strip>;
114
159
  export declare const analyticsColumnMetaSchema: z.ZodObject<{
115
160
  name: z.ZodString;
116
161
  type: z.ZodString;
@@ -9,6 +9,9 @@ export declare const connectionOptionsSchema: z.ZodObject<{
9
9
  client_secret: z.ZodOptional<z.ZodString>;
10
10
  app_secret: z.ZodOptional<z.ZodString>;
11
11
  scope: z.ZodOptional<z.ZodString>;
12
+ client_secret_hint: z.ZodOptional<z.ZodString>;
13
+ app_secret_hint: z.ZodOptional<z.ZodString>;
14
+ twilio_token_hint: z.ZodOptional<z.ZodString>;
12
15
  authorization_endpoint: z.ZodOptional<z.ZodString>;
13
16
  token_endpoint: z.ZodOptional<z.ZodString>;
14
17
  userinfo_endpoint: z.ZodOptional<z.ZodString>;
@@ -55,6 +58,7 @@ export declare const connectionOptionsSchema: z.ZodObject<{
55
58
  userinfo_endpoint: z.ZodOptional<z.ZodString>;
56
59
  client_id: z.ZodOptional<z.ZodString>;
57
60
  client_secret: z.ZodOptional<z.ZodString>;
61
+ client_secret_hint: z.ZodOptional<z.ZodString>;
58
62
  realm: z.ZodOptional<z.ZodString>;
59
63
  }, z.core.$strip>>;
60
64
  attributes: z.ZodOptional<z.ZodObject<{
@@ -160,6 +164,9 @@ export declare const connectionInsertSchema: z.ZodObject<{
160
164
  client_secret: z.ZodOptional<z.ZodString>;
161
165
  app_secret: z.ZodOptional<z.ZodString>;
162
166
  scope: z.ZodOptional<z.ZodString>;
167
+ client_secret_hint: z.ZodOptional<z.ZodString>;
168
+ app_secret_hint: z.ZodOptional<z.ZodString>;
169
+ twilio_token_hint: z.ZodOptional<z.ZodString>;
163
170
  authorization_endpoint: z.ZodOptional<z.ZodString>;
164
171
  token_endpoint: z.ZodOptional<z.ZodString>;
165
172
  userinfo_endpoint: z.ZodOptional<z.ZodString>;
@@ -206,6 +213,7 @@ export declare const connectionInsertSchema: z.ZodObject<{
206
213
  userinfo_endpoint: z.ZodOptional<z.ZodString>;
207
214
  client_id: z.ZodOptional<z.ZodString>;
208
215
  client_secret: z.ZodOptional<z.ZodString>;
216
+ client_secret_hint: z.ZodOptional<z.ZodString>;
209
217
  realm: z.ZodOptional<z.ZodString>;
210
218
  }, z.core.$strip>>;
211
219
  attributes: z.ZodOptional<z.ZodObject<{
@@ -322,6 +330,9 @@ export declare const connectionSchema: z.ZodObject<{
322
330
  client_secret: z.ZodOptional<z.ZodString>;
323
331
  app_secret: z.ZodOptional<z.ZodString>;
324
332
  scope: z.ZodOptional<z.ZodString>;
333
+ client_secret_hint: z.ZodOptional<z.ZodString>;
334
+ app_secret_hint: z.ZodOptional<z.ZodString>;
335
+ twilio_token_hint: z.ZodOptional<z.ZodString>;
325
336
  authorization_endpoint: z.ZodOptional<z.ZodString>;
326
337
  token_endpoint: z.ZodOptional<z.ZodString>;
327
338
  userinfo_endpoint: z.ZodOptional<z.ZodString>;
@@ -368,6 +379,7 @@ export declare const connectionSchema: z.ZodObject<{
368
379
  userinfo_endpoint: z.ZodOptional<z.ZodString>;
369
380
  client_id: z.ZodOptional<z.ZodString>;
370
381
  client_secret: z.ZodOptional<z.ZodString>;
382
+ client_secret_hint: z.ZodOptional<z.ZodString>;
371
383
  realm: z.ZodOptional<z.ZodString>;
372
384
  }, z.core.$strip>>;
373
385
  attributes: z.ZodOptional<z.ZodObject<{
@@ -1,4 +1,15 @@
1
1
  import { z } from "@hono/zod-openapi";
2
+ /**
3
+ * Triggers the given stored hook is allowed to run on, or `undefined` when the
4
+ * value isn't a recognisable hook.
5
+ *
6
+ * Needed because the update path validates a union of *partial* variant
7
+ * schemas: a body carrying only `trigger_id` matches whichever member has no
8
+ * other required field left, so the stored hook's type is invisible to the
9
+ * request validator. Callers re-check the incoming trigger against the row
10
+ * they're about to modify.
11
+ */
12
+ export declare function allowedTriggersForHook(hook: unknown): readonly string[] | undefined;
2
13
  /**
3
14
  * Built-in universal-login pages a page hook can interrupt the login with.
4
15
  * The runtime redirects to `/u/{page_id}` (or `/u2/{page_id}`), so this enum
@@ -44,12 +55,7 @@ export declare const hookInsertSchema: z.ZodUnion<readonly [z.ZodObject<{
44
55
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
45
56
  }, z.core.$strip>, z.ZodObject<{
46
57
  trigger_id: z.ZodEnum<{
47
- "pre-user-registration": "pre-user-registration";
48
- "post-user-registration": "post-user-registration";
49
58
  "post-user-login": "post-user-login";
50
- "validate-registration-username": "validate-registration-username";
51
- "pre-user-deletion": "pre-user-deletion";
52
- "post-user-deletion": "post-user-deletion";
53
59
  }>;
54
60
  form_id: z.ZodString;
55
61
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -122,12 +128,7 @@ export declare const hookSchema: z.ZodUnion<readonly [z.ZodObject<{
122
128
  url: z.ZodString;
123
129
  }, z.core.$strip>, z.ZodObject<{
124
130
  trigger_id: z.ZodEnum<{
125
- "pre-user-registration": "pre-user-registration";
126
- "post-user-registration": "post-user-registration";
127
131
  "post-user-login": "post-user-login";
128
- "validate-registration-username": "validate-registration-username";
129
- "pre-user-deletion": "pre-user-deletion";
130
- "post-user-deletion": "post-user-deletion";
131
132
  }>;
132
133
  enabled: z.ZodDefault<z.ZodBoolean>;
133
134
  synchronous: z.ZodDefault<z.ZodBoolean>;
@@ -1,4 +1,4 @@
1
- import { SessionRetentionResponse } from "../types/Analytics";
1
+ import { RefreshTokenRetentionResponse, SessionRetentionResponse } from "../types/Analytics";
2
2
  export declare const WEEK_MS: number;
3
3
  /**
4
4
  * The Unix epoch (1970-01-01) was a Thursday; adding 3 days before dividing
@@ -30,3 +30,9 @@ export interface SessionRetentionRawRow {
30
30
  * enough to reconstruct the whole retention triangle.
31
31
  */
32
32
  export declare function buildSessionRetention(rows: SessionRetentionRawRow[], weeks: number, now?: number): SessionRetentionResponse;
33
+ /**
34
+ * Same fold as {@link buildSessionRetention}, but the rows count refresh-token
35
+ * families (created-week = the family's first token, used-week = its last
36
+ * exchange) and the per-cohort total is reported as `tokens`.
37
+ */
38
+ export declare function buildRefreshTokenRetention(rows: SessionRetentionRawRow[], weeks: number, now?: number): RefreshTokenRetentionResponse;
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.6.0",
14
+ "version": "4.8.0",
15
15
  "files": [
16
16
  "dist"
17
17
  ],