@authhero/adapter-interfaces 4.7.0 → 4.8.1
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/adapter-interfaces.cjs +1 -1
- package/dist/adapter-interfaces.d.ts +84 -2
- package/dist/adapter-interfaces.mjs +327 -286
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/adapters/Analytics.d.ts +10 -1
- package/dist/types/types/Analytics.d.ts +45 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/session-retention.d.ts +7 -1
- package/dist/types/utils/username-validation.d.ts +21 -0
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|