@crvouga/mockingbird-service-oauth 3.6.0 → 3.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.
package/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-OYEO5VHR.js";
7
- import "./chunk-ANDSQ2HK.js";
6
+ } from "./chunk-AAKIJOPV.js";
7
+ import "./chunk-VAXKCT3L.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -172,6 +172,12 @@ declare class Collection<T> {
172
172
  }>;
173
173
  }
174
174
 
175
+ /**
176
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
177
+ * which derives the base from the wall clock when the runtime is created.
178
+ */
179
+ type IdBase = number | string;
180
+
175
181
  /** Options every provider constructor accepts. */
176
182
  type APIOptions = {
177
183
  /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
@@ -267,6 +273,15 @@ type FaultRule = {
267
273
  requestHeaders?: Record<string, string>;
268
274
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
269
275
  query?: Record<string, string>;
276
+ /**
277
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
278
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
279
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
280
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
281
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
282
+ * response a rule injects.
283
+ */
284
+ requestBody?: Record<string, RequestBodyValue>;
270
285
  /**
271
286
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
272
287
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -333,6 +348,8 @@ type FaultRule = {
333
348
  /** The preset this rule was expanded from, if any. */
334
349
  fromPreset?: string;
335
350
  };
351
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
352
+ type RequestBodyValue = string | number | boolean | null;
336
353
  /** A fault that fired for one request. */
337
354
  type FaultHit = {
338
355
  id: string;
@@ -370,6 +387,11 @@ type FaultCandidate = {
370
387
  /** Request headers and query, for rules that match on them. */
371
388
  headers?: Headers;
372
389
  query?: URLSearchParams;
390
+ /**
391
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
392
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
393
+ */
394
+ readJson?: () => Promise<unknown>;
373
395
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
374
396
  now?: number;
375
397
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -892,6 +914,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
892
914
  mount(prefix: string): MountedAPI;
893
915
  readonly sqlite: SqliteClient$1;
894
916
  readonly clock: Clock;
917
+ /**
918
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
919
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
920
+ * one run.
921
+ */
922
+ setIdBase(base: IdBase): number;
895
923
  readonly faults: FaultRegistry;
896
924
  /** Baseline response time per namespace. */
897
925
  readonly latency: LatencyRegistry;
@@ -1233,12 +1261,42 @@ type Account = {
1233
1261
  }[];
1234
1262
  };
1235
1263
  };
1264
+ type RedirectPolicy = {
1265
+ /**
1266
+ * RFC 8252 section 7.3: an `http://` loopback redirect (`127.0.0.1`, `[::1]` or `localhost`) may
1267
+ * use any port. It must match a registered loopback URI on the same host, path and query.
1268
+ */
1269
+ loopbackAnyPort?: boolean;
1270
+ /**
1271
+ * Custom schemes (for example `["exp:"]` for Expo dev clients) whose host and port may vary per
1272
+ * request, such as a LAN address. A request must still match a registered URI with the same
1273
+ * scheme, path and query. `http:`/`https:` and executable schemes are rejected.
1274
+ */
1275
+ schemes?: string[];
1276
+ };
1236
1277
  type Client = {
1237
1278
  id: string;
1238
1279
  name: string;
1239
1280
  redirectUris: string[];
1240
1281
  secret?: string;
1241
1282
  requirePkce?: boolean;
1283
+ /**
1284
+ * Cognito-style public app client: let a client without a secret omit PKCE. A challenge that is
1285
+ * sent is still verified. Default `false`: public clients must use S256 PKCE. Incompatible with
1286
+ * `requirePkce: true` and with a client `secret`/`apple` configuration.
1287
+ */
1288
+ pkceOptional?: boolean;
1289
+ /**
1290
+ * Cognito-style refresh tokens: every authorization-code exchange returns a `refresh_token`,
1291
+ * whether or not `offline_access` was requested. Default `false`: the profile's own rule applies
1292
+ * (`offline_access` for OIDC and Microsoft, `access_type=offline` for Google; Apple always).
1293
+ */
1294
+ alwaysIssueRefreshToken?: boolean;
1295
+ /**
1296
+ * Opt-in redirect matching for dev clients. Exact registered URIs always match; this adds
1297
+ * variants of registered URIs, never arbitrary URIs. Default: exact match only.
1298
+ */
1299
+ redirectPolicy?: RedirectPolicy;
1242
1300
  /** Apple developer/app grouping or OIDC pairwise identity sector. */
1243
1301
  subjectGroup?: string;
1244
1302
  /** Verify an Apple ES256 client-secret JWT instead of a static fixture secret. */
@@ -1589,4 +1647,4 @@ declare class OAuthAPI {
1589
1647
  }
1590
1648
 
1591
1649
  export { OAUTH_PRESETS, OAUTH_SCENARIOS, OAuthAPI, createMultiRuntime, createRuntime, document, operationIds, supportedOperationIds };
1592
- export type { Account, AppleNotificationType, BehaviorEvent, BehaviorInput, Client, CredentialOptions, EdgeCase, GrantView, NotificationDelivery, OAuthAPIOptions, OAuthBehavior, OAuthMount, OAuthMultiRuntime, OAuthMultiRuntimeOptions, OAuthRuntime, OAuthRuntimeOptions, OAuthScenario, Provider, SigningKey };
1650
+ export type { Account, AppleNotificationType, BehaviorEvent, BehaviorInput, Client, CredentialOptions, EdgeCase, GrantView, NotificationDelivery, OAuthAPIOptions, OAuthBehavior, OAuthMount, OAuthMultiRuntime, OAuthMultiRuntimeOptions, OAuthRuntime, OAuthRuntimeOptions, OAuthScenario, Provider, RedirectPolicy, SigningKey };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  document,
8
8
  operationIds,
9
9
  supportedOperationIds
10
- } from "./chunk-ANDSQ2HK.js";
10
+ } from "./chunk-VAXKCT3L.js";
11
11
  export {
12
12
  OAUTH_PRESETS,
13
13
  OAUTH_SCENARIOS,
package/dist/server.d.ts CHANGED
@@ -132,6 +132,12 @@ interface SqliteClient$2 {
132
132
  transaction<T>(fn: () => T): T;
133
133
  }
134
134
 
135
+ /**
136
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
137
+ * which derives the base from the wall clock when the runtime is created.
138
+ */
139
+ type IdBase$1 = number | string;
140
+
135
141
  /**
136
142
  * The single source of time for a service.
137
143
  *
@@ -214,6 +220,15 @@ type FaultRule$1 = {
214
220
  requestHeaders?: Record<string, string>;
215
221
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
216
222
  query?: Record<string, string>;
223
+ /**
224
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
225
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
226
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
227
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
228
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
229
+ * response a rule injects.
230
+ */
231
+ requestBody?: Record<string, RequestBodyValue$1>;
217
232
  /**
218
233
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
219
234
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -280,6 +295,8 @@ type FaultRule$1 = {
280
295
  /** The preset this rule was expanded from, if any. */
281
296
  fromPreset?: string;
282
297
  };
298
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
299
+ type RequestBodyValue$1 = string | number | boolean | null;
283
300
  /** A fault that fired for one request. */
284
301
  type FaultHit$1 = {
285
302
  id: string;
@@ -304,6 +321,11 @@ type FaultCandidate$1 = {
304
321
  /** Request headers and query, for rules that match on them. */
305
322
  headers?: Headers;
306
323
  query?: URLSearchParams;
324
+ /**
325
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
326
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
327
+ */
328
+ readJson?: () => Promise<unknown>;
307
329
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
308
330
  now?: number;
309
331
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -826,6 +848,12 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$1 & {
826
848
  mount(prefix: string): MountedAPI$1;
827
849
  readonly sqlite: SqliteClient$2;
828
850
  readonly clock: Clock$1;
851
+ /**
852
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
853
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
854
+ * one run.
855
+ */
856
+ setIdBase(base: IdBase$1): number;
829
857
  readonly faults: FaultRegistry$1;
830
858
  /** Baseline response time per namespace. */
831
859
  readonly latency: LatencyRegistry$1;
@@ -931,6 +959,12 @@ type CommonServeOptions = {
931
959
  /** Synthetic provider fixture objects supplied by a fleet entry. */
932
960
  fixtures?: Record<string, unknown>;
933
961
  baseUrl?: string;
962
+ /**
963
+ * Boot settings from `--settings`, `MOCKINGBIRD_SETTINGS` or a fleet entry's `settings`,
964
+ * already checked by the target's {@link ServeTarget.parseSettings}. Pass them to the
965
+ * service's own `settings` option so they become every namespace's defaults.
966
+ */
967
+ settings?: Record<string, unknown>;
934
968
  };
935
969
  /**
936
970
  * What a service contributes to `serve`: how to build its runtime from CLI flags,
@@ -943,6 +977,13 @@ type ServeTarget = {
943
977
  defaultPort: number;
944
978
  /** Serve flags beyond the common ones. */
945
979
  options?: Record<string, CliOption>;
980
+ /**
981
+ * Check the boot settings a caller supplied (`--settings`, `MOCKINGBIRD_SETTINGS`, a fleet
982
+ * entry's `settings`) against the service's settings schema, returning them normalized
983
+ * or throwing a message naming the bad field. A target without one takes no boot settings,
984
+ * and supplying some is refused before a port is bound.
985
+ */
986
+ parseSettings?(settings: Record<string, unknown>): Record<string, unknown>;
946
987
  create(values: CliValues, common: CommonServeOptions): Promise<ServiceRuntime$1<ServiceInstance$1>> | ServiceRuntime$1<ServiceInstance$1>;
947
988
  /** Startup lines after the listen address, e.g. the loaded corpus version. */
948
989
  banner?(runtime: ServiceRuntime$1<ServiceInstance$1>): string[];
@@ -1124,6 +1165,12 @@ declare class Collection<T> {
1124
1165
  }>;
1125
1166
  }
1126
1167
 
1168
+ /**
1169
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
1170
+ * which derives the base from the wall clock when the runtime is created.
1171
+ */
1172
+ type IdBase = number | string;
1173
+
1127
1174
  /** Options every provider constructor accepts. */
1128
1175
  type APIOptions = {
1129
1176
  /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
@@ -1219,6 +1266,15 @@ type FaultRule = {
1219
1266
  requestHeaders?: Record<string, string>;
1220
1267
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
1221
1268
  query?: Record<string, string>;
1269
+ /**
1270
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
1271
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
1272
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
1273
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
1274
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
1275
+ * response a rule injects.
1276
+ */
1277
+ requestBody?: Record<string, RequestBodyValue>;
1222
1278
  /**
1223
1279
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
1224
1280
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -1285,6 +1341,8 @@ type FaultRule = {
1285
1341
  /** The preset this rule was expanded from, if any. */
1286
1342
  fromPreset?: string;
1287
1343
  };
1344
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
1345
+ type RequestBodyValue = string | number | boolean | null;
1288
1346
  /** A fault that fired for one request. */
1289
1347
  type FaultHit = {
1290
1348
  id: string;
@@ -1309,6 +1367,11 @@ type FaultCandidate = {
1309
1367
  /** Request headers and query, for rules that match on them. */
1310
1368
  headers?: Headers;
1311
1369
  query?: URLSearchParams;
1370
+ /**
1371
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
1372
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
1373
+ */
1374
+ readJson?: () => Promise<unknown>;
1312
1375
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
1313
1376
  now?: number;
1314
1377
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -1831,6 +1894,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
1831
1894
  mount(prefix: string): MountedAPI;
1832
1895
  readonly sqlite: SqliteClient$1;
1833
1896
  readonly clock: Clock;
1897
+ /**
1898
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
1899
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
1900
+ * one run.
1901
+ */
1902
+ setIdBase(base: IdBase): number;
1834
1903
  readonly faults: FaultRegistry;
1835
1904
  /** Baseline response time per namespace. */
1836
1905
  readonly latency: LatencyRegistry;
@@ -2172,12 +2241,42 @@ type Account = {
2172
2241
  }[];
2173
2242
  };
2174
2243
  };
2244
+ type RedirectPolicy = {
2245
+ /**
2246
+ * RFC 8252 section 7.3: an `http://` loopback redirect (`127.0.0.1`, `[::1]` or `localhost`) may
2247
+ * use any port. It must match a registered loopback URI on the same host, path and query.
2248
+ */
2249
+ loopbackAnyPort?: boolean;
2250
+ /**
2251
+ * Custom schemes (for example `["exp:"]` for Expo dev clients) whose host and port may vary per
2252
+ * request, such as a LAN address. A request must still match a registered URI with the same
2253
+ * scheme, path and query. `http:`/`https:` and executable schemes are rejected.
2254
+ */
2255
+ schemes?: string[];
2256
+ };
2175
2257
  type Client = {
2176
2258
  id: string;
2177
2259
  name: string;
2178
2260
  redirectUris: string[];
2179
2261
  secret?: string;
2180
2262
  requirePkce?: boolean;
2263
+ /**
2264
+ * Cognito-style public app client: let a client without a secret omit PKCE. A challenge that is
2265
+ * sent is still verified. Default `false`: public clients must use S256 PKCE. Incompatible with
2266
+ * `requirePkce: true` and with a client `secret`/`apple` configuration.
2267
+ */
2268
+ pkceOptional?: boolean;
2269
+ /**
2270
+ * Cognito-style refresh tokens: every authorization-code exchange returns a `refresh_token`,
2271
+ * whether or not `offline_access` was requested. Default `false`: the profile's own rule applies
2272
+ * (`offline_access` for OIDC and Microsoft, `access_type=offline` for Google; Apple always).
2273
+ */
2274
+ alwaysIssueRefreshToken?: boolean;
2275
+ /**
2276
+ * Opt-in redirect matching for dev clients. Exact registered URIs always match; this adds
2277
+ * variants of registered URIs, never arbitrary URIs. Default: exact match only.
2278
+ */
2279
+ redirectPolicy?: RedirectPolicy;
2181
2280
  /** Apple developer/app grouping or OIDC pairwise identity sector. */
2182
2281
  subjectGroup?: string;
2183
2282
  /** Verify an Apple ES256 client-secret JWT instead of a static fixture secret. */
package/dist/server.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  createMultiServer,
4
4
  createServer,
5
5
  serveTarget
6
- } from "./chunk-OYEO5VHR.js";
7
- import "./chunk-ANDSQ2HK.js";
6
+ } from "./chunk-AAKIJOPV.js";
7
+ import "./chunk-VAXKCT3L.js";
8
8
  export {
9
9
  DEFAULT_PORT,
10
10
  createMultiServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-oauth",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "Social-login emulator with Google, Apple, Microsoft, GitHub and generic OIDC profiles, private relay identities, reproducible edge cases, signed tokens and an accessible UI.",
5
5
  "license": "MIT",
6
6
  "type": "module",