@seamless-auth/types 0.27.0 → 0.29.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @seamless-auth/types
2
2
 
3
+ ## 0.29.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c386361: Add `binding` to the OAuth start response and the callback request. The auth server returns a
8
+ random `binding` from `/oauth/:providerId/start` and checks it on `/oauth/:providerId/callback`,
9
+ so a `state` can only be finished by the client that started the sign-in. Both fields are
10
+ optional in the schemas so a client can still parse a response from an older auth server.
11
+
12
+ ### Patch Changes
13
+
14
+ - 14077a9: Raise the `zod` dependency floor from `^4.3.6` to `^4.5.0`. The published declarations use the two-argument `ZodPreprocess` type, which zod 4.3.x does not export and zod 4.4.x declares with a single type parameter, so a consumer resolving zod below 4.5.0 with `skipLibCheck: false` got TS2724 or TS2707 from this package's `.d.ts` files. Consumers pinned to zod 4.4.x or older should upgrade to zod 4.5.0 or later.
15
+
16
+ ## 0.28.0
17
+
18
+ ### Minor Changes
19
+
20
+ - e2d2a28: Time ranges for the dashboard metrics and security anomalies (fells-code/seamless-auth-api#132).
21
+
22
+ - `DashboardMetricsQuerySchema` (`from`, `to`) and `SecurityAnomaliesQuerySchema` (`from`, `to`, `limit` 1 to 200 with a default of 200, `offset` with a default of 0). The range rules are the same as `MetricsQuerySchema`'s, which now shares them.
23
+ - `DashboardMetricsResponseSchema` gains optional `window`, `newUsers`, `loginSuccess`, `loginFailed`, `successRate`, `otpUsage` and `passkeyUsage`, which cover the requested window. The `*24h` fields keep meaning the last 24 hours.
24
+ - `SecurityAnomaliesResponseSchema` gains optional `window`, `limit` and `offset`, and `total` is documented as every matching event in the window.
25
+
26
+ All the new response fields are optional, so a response from a server without ranges still parses.
27
+
3
28
  ## 0.27.0
4
29
 
5
30
  ### Minor Changes
package/README.md CHANGED
@@ -19,6 +19,23 @@ contracts built on top of them. Every layer of the stack validates against the s
19
19
  Because everything downstream imports these contracts, a change here is treated as
20
20
  breaking by default. See [Versioning and stability](#versioning-and-stability).
21
21
 
22
+ ## Start here
23
+
24
+ New to Seamless Auth? The [self-hosted quickstart](https://docs.seamlessauth.com/start/quickstart/) runs the full stack locally with Docker. If Seamless hosts your auth instance, follow the [managed quickstart](https://docs.seamlessauth.com/start/managed-quickstart/) instead.
25
+
26
+ This package is not a node in the diagram below because it sits under all of them: `seamless-auth-api`, the server adapters (through `@seamless-auth/core`), the React and React Native SDKs, the admin dashboard, and the CLI all validate against these schemas.
27
+
28
+ ```mermaid
29
+ flowchart LR
30
+ browser["Browser<br/>@seamless-auth/react"] -- "signed httpOnly cookies" --> backend
31
+ native["Native app<br/>@seamless-auth/react-native"] -- "bearer tokens" --> backend
32
+ backend["Your backend<br/>@seamless-auth/express, fastify, or nextjs<br/>mounted at /auth"] -- "bearer token + service token" --> api
33
+ api["seamless-auth-api<br/>owns the session"] --> db[("Postgres")]
34
+ backend -. "verifies tokens with JWKS" .-> api
35
+ ```
36
+
37
+ [How the pieces connect](https://docs.seamlessauth.com/start/overview/#how-the-pieces-connect) explains each hop. [Compatibility matrix](https://docs.seamlessauth.com/build/ecosystem/#compatibility-matrix) lists which package versions work together.
38
+
22
39
  ## Requirements
23
40
 
24
41
  | | |
@@ -185,7 +202,7 @@ history.
185
202
  ## Security
186
203
 
187
204
  Do not open a public issue for a vulnerability. Report it privately to
188
- **security@seamlessauth.com**. See [SECURITY.md](SECURITY.md) for what to include, our
205
+ **security@fellscode.com**. See [SECURITY.md](SECURITY.md) for what to include, our
189
206
  acknowledgement window, and the coordinated disclosure process.
190
207
 
191
208
  ## Development
@@ -224,6 +241,10 @@ existing schema as breaking until you can argue otherwise.
224
241
 
225
242
  [Apache-2.0](LICENSE) © Fells Code, LLC
226
243
 
244
+ Project governance, including the
245
+ [Seamless Auth License Pledge](https://github.com/fells-code/.github/blob/main/GOVERNANCE.md#the-seamless-auth-license-pledge),
246
+ is in the fells-code [GOVERNANCE.md](https://github.com/fells-code/.github/blob/main/GOVERNANCE.md).
247
+
227
248
  ## Links
228
249
 
229
250
  - [npm package](https://www.npmjs.com/package/@seamless-auth/types)
@@ -68,6 +68,25 @@ export declare const PartialAuthEventSchema: z.ZodObject<{
68
68
  updated_at: z.ZodOptional<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>;
69
69
  }, z.core.$strip>;
70
70
  export type PartialAuthEvent = z.infer<typeof PartialAuthEventSchema>;
71
+ /** The window a ranged response covers, as resolved by the server. */
72
+ export declare const MetricsWindowSchema: z.ZodObject<{
73
+ from: z.ZodString;
74
+ to: z.ZodString;
75
+ }, z.core.$strip>;
76
+ export type MetricsWindow = z.infer<typeof MetricsWindowSchema>;
77
+ /** `from`/`to` default to the last 24 hours, as the endpoints did before they took a range. */
78
+ export declare const DashboardMetricsQuerySchema: z.ZodObject<{
79
+ from: z.ZodOptional<z.ZodString>;
80
+ to: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>;
82
+ export type DashboardMetricsQuery = z.infer<typeof DashboardMetricsQuerySchema>;
83
+ export declare const SecurityAnomaliesQuerySchema: z.ZodObject<{
84
+ from: z.ZodOptional<z.ZodString>;
85
+ to: z.ZodOptional<z.ZodString>;
86
+ limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
87
+ offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
88
+ }, z.core.$strip>;
89
+ export type SecurityAnomaliesQuery = z.infer<typeof SecurityAnomaliesQuerySchema>;
71
90
  export declare const SecurityAnomaliesResponseSchema: z.ZodObject<{
72
91
  suspiciousEvents: z.ZodArray<z.ZodObject<{
73
92
  id: z.ZodOptional<z.ZodString>;
@@ -87,6 +106,12 @@ export declare const SecurityAnomaliesResponseSchema: z.ZodObject<{
87
106
  updated_at: z.ZodOptional<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>;
88
107
  }, z.core.$strip>>;
89
108
  total: z.ZodNumber;
109
+ window: z.ZodOptional<z.ZodObject<{
110
+ from: z.ZodString;
111
+ to: z.ZodString;
112
+ }, z.core.$strip>>;
113
+ limit: z.ZodOptional<z.ZodNumber>;
114
+ offset: z.ZodOptional<z.ZodNumber>;
90
115
  }, z.core.$strip>;
91
116
  export type SecurityAnomaliesResponse = z.infer<typeof SecurityAnomaliesResponseSchema>;
92
117
  export declare const DashboardMetricsResponseSchema: z.ZodObject<{
@@ -99,6 +124,16 @@ export declare const DashboardMetricsResponseSchema: z.ZodObject<{
99
124
  otpUsage24h: z.ZodNumber;
100
125
  passkeyUsage24h: z.ZodNumber;
101
126
  databaseSize: z.ZodNumber;
127
+ window: z.ZodOptional<z.ZodObject<{
128
+ from: z.ZodString;
129
+ to: z.ZodString;
130
+ }, z.core.$strip>>;
131
+ newUsers: z.ZodOptional<z.ZodNumber>;
132
+ loginSuccess: z.ZodOptional<z.ZodNumber>;
133
+ loginFailed: z.ZodOptional<z.ZodNumber>;
134
+ successRate: z.ZodOptional<z.ZodNumber>;
135
+ otpUsage: z.ZodOptional<z.ZodNumber>;
136
+ passkeyUsage: z.ZodOptional<z.ZodNumber>;
102
137
  }, z.core.$strip>;
103
138
  export type DashboardMetricsResponse = z.infer<typeof DashboardMetricsResponseSchema>;
104
139
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/metrics/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,qBAAqB;;;EAA0B,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,kBAAkB;;;;;;;;iBAuC3B,CAAC;AAEL,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;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KiB,CAAC;AAE1D,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,4BAA4B;;;;;iBAOgB,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;iBAU1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;iBAsBzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC"}
@@ -2,40 +2,44 @@ import { z } from 'zod';
2
2
  import { AuthEventSchema } from '../authEvent/schema.js';
3
3
  const MAX_METRICS_WINDOW_MS = 1000 * 60 * 60 * 24 * 366; // ~1 year
4
4
  export const MetricsIntervalSchema = z.enum(['hour', 'day']);
5
- export const MetricsQuerySchema = z
6
- .object({
7
- userId: z.string().optional(),
8
- from: z.string().optional(),
9
- to: z.string().optional(),
10
- interval: MetricsIntervalSchema.optional().default('hour'),
11
- })
12
- .superRefine((data, ctx) => {
5
+ // Shared by every metrics query that takes a range, so they agree on what a valid window is.
6
+ function timeRangeIssues(data) {
13
7
  const fromDate = data.from ? new Date(data.from) : undefined;
14
8
  const toDate = data.to ? new Date(data.to) : undefined;
15
9
  const fromValid = fromDate !== undefined && !Number.isNaN(fromDate.getTime());
16
10
  const toValid = toDate !== undefined && !Number.isNaN(toDate.getTime());
11
+ const issues = [];
17
12
  if (data.from !== undefined && !fromValid) {
18
- ctx.addIssue({ code: 'custom', path: ['from'], message: 'Invalid from date' });
13
+ issues.push({ path: ['from'], message: 'Invalid from date' });
19
14
  }
20
15
  if (data.to !== undefined && !toValid) {
21
- ctx.addIssue({ code: 'custom', path: ['to'], message: 'Invalid to date' });
16
+ issues.push({ path: ['to'], message: 'Invalid to date' });
22
17
  }
23
18
  if (!fromValid || !toValid || !fromDate || !toDate) {
24
- return;
19
+ return issues;
25
20
  }
26
21
  if (fromDate.getTime() > toDate.getTime()) {
27
- ctx.addIssue({ code: 'custom', path: ['to'], message: 'from must be on or before to' });
28
- return;
22
+ return [{ path: ['to'], message: 'from must be on or before to' }];
29
23
  }
30
24
  // Unbounded windows let a single request scan the whole event table.
31
25
  if (toDate.getTime() - fromDate.getTime() > MAX_METRICS_WINDOW_MS) {
32
- ctx.addIssue({
33
- code: 'custom',
34
- path: ['to'],
35
- message: 'time range exceeds the maximum window',
36
- });
26
+ return [{ path: ['to'], message: 'time range exceeds the maximum window' }];
37
27
  }
38
- });
28
+ return issues;
29
+ }
30
+ function refineTimeRange(data, ctx) {
31
+ for (const issue of timeRangeIssues(data)) {
32
+ ctx.addIssue({ code: 'custom', ...issue });
33
+ }
34
+ }
35
+ export const MetricsQuerySchema = z
36
+ .object({
37
+ userId: z.string().optional(),
38
+ from: z.string().optional(),
39
+ to: z.string().optional(),
40
+ interval: MetricsIntervalSchema.optional().default('hour'),
41
+ })
42
+ .superRefine((data, ctx) => refineTimeRange(data, ctx));
39
43
  export const AuthEventSummaryItemSchema = z.object({
40
44
  type: z.string(),
41
45
  count: z.number(),
@@ -61,9 +65,33 @@ export const LoginStatsResponseSchema = z.object({
61
65
  * event is still worth surfacing, so every field is optional here.
62
66
  */
63
67
  export const PartialAuthEventSchema = AuthEventSchema.partial();
68
+ /** The window a ranged response covers, as resolved by the server. */
69
+ export const MetricsWindowSchema = z.object({ from: z.string(), to: z.string() });
70
+ /** `from`/`to` default to the last 24 hours, as the endpoints did before they took a range. */
71
+ export const DashboardMetricsQuerySchema = z
72
+ .object({
73
+ from: z.string().optional(),
74
+ to: z.string().optional(),
75
+ })
76
+ .superRefine((data, ctx) => refineTimeRange(data, ctx));
77
+ export const SecurityAnomaliesQuerySchema = z
78
+ .object({
79
+ from: z.string().optional(),
80
+ to: z.string().optional(),
81
+ limit: z.coerce.number().int().min(1).max(200).optional().default(200),
82
+ offset: z.coerce.number().int().min(0).optional().default(0),
83
+ })
84
+ .superRefine((data, ctx) => refineTimeRange(data, ctx));
64
85
  export const SecurityAnomaliesResponseSchema = z.object({
65
86
  suspiciousEvents: z.array(PartialAuthEventSchema),
87
+ /**
88
+ * Every matching event in the window. Servers before the range was added reported
89
+ * the number returned, at most 200, here instead.
90
+ */
66
91
  total: z.number().int().nonnegative(),
92
+ window: MetricsWindowSchema.optional(),
93
+ limit: z.number().int().optional(),
94
+ offset: z.number().int().optional(),
67
95
  });
68
96
  export const DashboardMetricsResponseSchema = z.object({
69
97
  totalUsers: z.number(),
@@ -75,5 +103,17 @@ export const DashboardMetricsResponseSchema = z.object({
75
103
  otpUsage24h: z.number(),
76
104
  passkeyUsage24h: z.number(),
77
105
  databaseSize: z.number(),
106
+ /**
107
+ * The same figures as the `*24h` fields, over the requested window instead of the
108
+ * last 24 hours. The `*24h` fields keep their meaning whatever window is asked for.
109
+ * Optional because servers before the range was added do not send them.
110
+ */
111
+ window: MetricsWindowSchema.optional(),
112
+ newUsers: z.number().optional(),
113
+ loginSuccess: z.number().optional(),
114
+ loginFailed: z.number().optional(),
115
+ successRate: z.number().optional(),
116
+ otpUsage: z.number().optional(),
117
+ passkeyUsage: z.number().optional(),
78
118
  });
79
119
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/metrics/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,UAAU;AAEnE,MAAM,CAAC,MAAM,qBAAq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AC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB;;;;OAIG;IACH,MAAM,EAAE,mBAAmB,CAAC,QAAQ,EAAE;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC"}
@@ -31,11 +31,13 @@ export declare const StartOAuthLoginResponseSchema: z.ZodObject<{
31
31
  }, z.core.$strip>;
32
32
  state: z.ZodString;
33
33
  authorizationUrl: z.ZodURL;
34
+ binding: z.ZodOptional<z.ZodString>;
34
35
  }, z.core.$strip>;
35
36
  export type StartOAuthLoginResponse = z.infer<typeof StartOAuthLoginResponseSchema>;
36
37
  export declare const FinishOAuthLoginRequestSchema: z.ZodObject<{
37
38
  code: z.ZodString;
38
39
  state: z.ZodString;
40
+ binding: z.ZodOptional<z.ZodString>;
39
41
  }, z.core.$strip>;
40
42
  export type FinishOAuthLoginRequest = z.infer<typeof FinishOAuthLoginRequestSchema>;
41
43
  export declare const OAuthLoginSuccessResponseSchema: z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/oauth/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,wBAAwB;;iBAEnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,wFAAwF;AACxF,eAAO,MAAM,yBAAyB;;;;iBAIpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,4BAA4B;;;;;;iBAEvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,eAAO,MAAM,6BAA6B;;;;;;;;iBAIxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,6BAA6B;;;iBAGxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,+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AM,6BAA6B;;;;iBAKxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;iBAoB1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,iBAAiB,2IAOpB,CAAC;AAEX,eAAO,MAAM,oBAAoB;;;;;;EAA4B,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,6BAA6B;;;;;;;;;;iBAIxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC"}
@@ -22,10 +22,18 @@ export const StartOAuthLoginResponseSchema = z.object({
22
22
  provider: PublicOAuthProviderSchema,
23
23
  state: z.string(),
24
24
  authorizationUrl: z.url(),
25
+ /**
26
+ * Binds `state` to the client that started the sign-in. The client keeps it and sends
27
+ * it back with the callback; it never goes to the provider. Optional only so a client
28
+ * can parse a response from an auth server that predates it.
29
+ */
30
+ binding: z.string().optional(),
25
31
  });
26
32
  export const FinishOAuthLoginRequestSchema = z.object({
27
33
  code: z.string().trim().min(1),
28
34
  state: z.string().trim().min(1),
35
+ /** The `binding` the start response returned to this client. */
36
+ binding: z.string().trim().min(1).optional(),
29
37
  });
30
38
  export const OAuthLoginSuccessResponseSchema = RefreshSuccessResponseSchema.omit({
31
39
  sessionId: true,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/oauth/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;A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AAS,EAAE,IAAI;CAChB,CAAC,CAAC,MAAM,CAAC;IACR;;;;;;;;OAQG;IACH,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,EAAE;IACzC;;;;;OAKG;IACH,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,qBAAqB;IACrB,0BAA0B;IAC1B,uBAAuB;IACvB,wBAAwB;IACxB,iFAAiF;IACjF,wBAAwB;CAChB,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AAI9D,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,oBAAoB,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamless-auth/types",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "Shared TypeScript types and Zod schemas for SeamlessAuth.",
5
5
  "author": "Fells Code, LLC",
6
6
  "license": "Apache-2.0",
@@ -60,6 +60,7 @@
60
60
  "prepublishOnly": "npm run build",
61
61
  "test": "vitest run",
62
62
  "test:watch": "vitest",
63
+ "test:zod-floor": "node scripts/check-zod-floor.mjs",
63
64
  "changeset": "changeset",
64
65
  "version-packages": "changeset version",
65
66
  "release:stable": "npm run build && changeset publish",
@@ -75,7 +76,7 @@
75
76
  ]
76
77
  },
77
78
  "dependencies": {
78
- "zod": "^4.3.6"
79
+ "zod": "^4.5.0"
79
80
  },
80
81
  "devDependencies": {
81
82
  "@changesets/cli": "^3.0.2",
@@ -87,7 +88,7 @@
87
88
  "eslint-config-prettier": "^10.1.8",
88
89
  "husky": "^9.1.7",
89
90
  "lint-staged": "^17.2.0",
90
- "prettier": "3.9.9",
91
+ "prettier": "3.9.10",
91
92
  "typescript": "^5.9.3",
92
93
  "vitest": "^5.0.3"
93
94
  },
@@ -7,6 +7,53 @@ export const MetricsIntervalSchema = z.enum(['hour', 'day']);
7
7
 
8
8
  export type MetricsInterval = z.infer<typeof MetricsIntervalSchema>;
9
9
 
10
+ type RangeIssue = { path: ['from'] | ['to']; message: string };
11
+
12
+ // Shared by every metrics query that takes a range, so they agree on what a valid window is.
13
+ function timeRangeIssues(data: {
14
+ from?: string | undefined;
15
+ to?: string | undefined;
16
+ }): RangeIssue[] {
17
+ const fromDate = data.from ? new Date(data.from) : undefined;
18
+ const toDate = data.to ? new Date(data.to) : undefined;
19
+
20
+ const fromValid = fromDate !== undefined && !Number.isNaN(fromDate.getTime());
21
+ const toValid = toDate !== undefined && !Number.isNaN(toDate.getTime());
22
+ const issues: RangeIssue[] = [];
23
+
24
+ if (data.from !== undefined && !fromValid) {
25
+ issues.push({ path: ['from'], message: 'Invalid from date' });
26
+ }
27
+
28
+ if (data.to !== undefined && !toValid) {
29
+ issues.push({ path: ['to'], message: 'Invalid to date' });
30
+ }
31
+
32
+ if (!fromValid || !toValid || !fromDate || !toDate) {
33
+ return issues;
34
+ }
35
+
36
+ if (fromDate.getTime() > toDate.getTime()) {
37
+ return [{ path: ['to'], message: 'from must be on or before to' }];
38
+ }
39
+
40
+ // Unbounded windows let a single request scan the whole event table.
41
+ if (toDate.getTime() - fromDate.getTime() > MAX_METRICS_WINDOW_MS) {
42
+ return [{ path: ['to'], message: 'time range exceeds the maximum window' }];
43
+ }
44
+
45
+ return issues;
46
+ }
47
+
48
+ function refineTimeRange<T extends { from?: string | undefined; to?: string | undefined }>(
49
+ data: T,
50
+ ctx: z.RefinementCtx<T>,
51
+ ) {
52
+ for (const issue of timeRangeIssues(data)) {
53
+ ctx.addIssue({ code: 'custom', ...issue });
54
+ }
55
+ }
56
+
10
57
  export const MetricsQuerySchema = z
11
58
  .object({
12
59
  userId: z.string().optional(),
@@ -14,39 +61,7 @@ export const MetricsQuerySchema = z
14
61
  to: z.string().optional(),
15
62
  interval: MetricsIntervalSchema.optional().default('hour'),
16
63
  })
17
- .superRefine((data, ctx) => {
18
- const fromDate = data.from ? new Date(data.from) : undefined;
19
- const toDate = data.to ? new Date(data.to) : undefined;
20
-
21
- const fromValid = fromDate !== undefined && !Number.isNaN(fromDate.getTime());
22
- const toValid = toDate !== undefined && !Number.isNaN(toDate.getTime());
23
-
24
- if (data.from !== undefined && !fromValid) {
25
- ctx.addIssue({ code: 'custom', path: ['from'], message: 'Invalid from date' });
26
- }
27
-
28
- if (data.to !== undefined && !toValid) {
29
- ctx.addIssue({ code: 'custom', path: ['to'], message: 'Invalid to date' });
30
- }
31
-
32
- if (!fromValid || !toValid || !fromDate || !toDate) {
33
- return;
34
- }
35
-
36
- if (fromDate.getTime() > toDate.getTime()) {
37
- ctx.addIssue({ code: 'custom', path: ['to'], message: 'from must be on or before to' });
38
- return;
39
- }
40
-
41
- // Unbounded windows let a single request scan the whole event table.
42
- if (toDate.getTime() - fromDate.getTime() > MAX_METRICS_WINDOW_MS) {
43
- ctx.addIssue({
44
- code: 'custom',
45
- path: ['to'],
46
- message: 'time range exceeds the maximum window',
47
- });
48
- }
49
- });
64
+ .superRefine((data, ctx) => refineTimeRange(data, ctx));
50
65
 
51
66
  export type MetricsQuery = z.infer<typeof MetricsQuerySchema>;
52
67
 
@@ -93,9 +108,42 @@ export const PartialAuthEventSchema = AuthEventSchema.partial();
93
108
 
94
109
  export type PartialAuthEvent = z.infer<typeof PartialAuthEventSchema>;
95
110
 
111
+ /** The window a ranged response covers, as resolved by the server. */
112
+ export const MetricsWindowSchema = z.object({ from: z.string(), to: z.string() });
113
+
114
+ export type MetricsWindow = z.infer<typeof MetricsWindowSchema>;
115
+
116
+ /** `from`/`to` default to the last 24 hours, as the endpoints did before they took a range. */
117
+ export const DashboardMetricsQuerySchema = z
118
+ .object({
119
+ from: z.string().optional(),
120
+ to: z.string().optional(),
121
+ })
122
+ .superRefine((data, ctx) => refineTimeRange(data, ctx));
123
+
124
+ export type DashboardMetricsQuery = z.infer<typeof DashboardMetricsQuerySchema>;
125
+
126
+ export const SecurityAnomaliesQuerySchema = z
127
+ .object({
128
+ from: z.string().optional(),
129
+ to: z.string().optional(),
130
+ limit: z.coerce.number().int().min(1).max(200).optional().default(200),
131
+ offset: z.coerce.number().int().min(0).optional().default(0),
132
+ })
133
+ .superRefine((data, ctx) => refineTimeRange(data, ctx));
134
+
135
+ export type SecurityAnomaliesQuery = z.infer<typeof SecurityAnomaliesQuerySchema>;
136
+
96
137
  export const SecurityAnomaliesResponseSchema = z.object({
97
138
  suspiciousEvents: z.array(PartialAuthEventSchema),
139
+ /**
140
+ * Every matching event in the window. Servers before the range was added reported
141
+ * the number returned, at most 200, here instead.
142
+ */
98
143
  total: z.number().int().nonnegative(),
144
+ window: MetricsWindowSchema.optional(),
145
+ limit: z.number().int().optional(),
146
+ offset: z.number().int().optional(),
99
147
  });
100
148
 
101
149
  export type SecurityAnomaliesResponse = z.infer<typeof SecurityAnomaliesResponseSchema>;
@@ -110,6 +158,18 @@ export const DashboardMetricsResponseSchema = z.object({
110
158
  otpUsage24h: z.number(),
111
159
  passkeyUsage24h: z.number(),
112
160
  databaseSize: z.number(),
161
+ /**
162
+ * The same figures as the `*24h` fields, over the requested window instead of the
163
+ * last 24 hours. The `*24h` fields keep their meaning whatever window is asked for.
164
+ * Optional because servers before the range was added do not send them.
165
+ */
166
+ window: MetricsWindowSchema.optional(),
167
+ newUsers: z.number().optional(),
168
+ loginSuccess: z.number().optional(),
169
+ loginFailed: z.number().optional(),
170
+ successRate: z.number().optional(),
171
+ otpUsage: z.number().optional(),
172
+ passkeyUsage: z.number().optional(),
113
173
  });
114
174
 
115
175
  export type DashboardMetricsResponse = z.infer<typeof DashboardMetricsResponseSchema>;
@@ -35,6 +35,12 @@ export const StartOAuthLoginResponseSchema = z.object({
35
35
  provider: PublicOAuthProviderSchema,
36
36
  state: z.string(),
37
37
  authorizationUrl: z.url(),
38
+ /**
39
+ * Binds `state` to the client that started the sign-in. The client keeps it and sends
40
+ * it back with the callback; it never goes to the provider. Optional only so a client
41
+ * can parse a response from an auth server that predates it.
42
+ */
43
+ binding: z.string().optional(),
38
44
  });
39
45
 
40
46
  export type StartOAuthLoginResponse = z.infer<typeof StartOAuthLoginResponseSchema>;
@@ -42,6 +48,8 @@ export type StartOAuthLoginResponse = z.infer<typeof StartOAuthLoginResponseSche
42
48
  export const FinishOAuthLoginRequestSchema = z.object({
43
49
  code: z.string().trim().min(1),
44
50
  state: z.string().trim().min(1),
51
+ /** The `binding` the start response returned to this client. */
52
+ binding: z.string().trim().min(1).optional(),
45
53
  });
46
54
 
47
55
  export type FinishOAuthLoginRequest = z.infer<typeof FinishOAuthLoginRequestSchema>;