@crvouga/mockingbird-service-oauth 1.2.1 → 1.4.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-2JIADQOV.js";
7
- import "./chunk-XP2AEPEJ.js";
6
+ } from "./chunk-D4IAZYMT.js";
7
+ import "./chunk-SYFF4UFD.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -775,6 +775,29 @@ declare class BehaviorState {
775
775
  decisions(): Decisions;
776
776
  }
777
777
 
778
+ /** A caller-supplied RS256 signing key pair. `kid` is published in the JWKS and token headers. */
779
+ type SigningKey = {
780
+ privateJwk: JsonWebKey;
781
+ publicJwk: JsonWebKey;
782
+ kid: string;
783
+ };
784
+ /**
785
+ * Opt-in control over every opaque value the provider mints. With none of these set the provider
786
+ * uses cryptographic randomness, exactly as before.
787
+ */
788
+ type CredentialOptions = {
789
+ /**
790
+ * Derive authorization codes, tokens, transaction ids, session ids, CSP nonces and signing keys
791
+ * from `seed` (default 0) instead of `crypto`, so the same seed and the same requests replay
792
+ * byte-for-byte. Test-only: the values are guessable.
793
+ */
794
+ deterministicCredentials?: boolean;
795
+ /** Replaces `crypto.getRandomValues` for every minted value, and wins over the seeded source. */
796
+ randomBytes?: (length: number) => Uint8Array;
797
+ /** Signing keys used in order: the first is current and each rotation takes the next. */
798
+ signingKeys?: SigningKey[];
799
+ };
800
+
778
801
  type Provider = "google" | "apple" | "oidc" | "microsoft" | "github";
779
802
  type Account = {
780
803
  id: string;
@@ -839,6 +862,16 @@ type NotificationDelivery = {
839
862
  status?: number;
840
863
  error?: string;
841
864
  };
865
+ /** What one client sees for one account: see `OAuthAPI.grant`. */
866
+ type GrantView = {
867
+ subject: string;
868
+ granted: boolean;
869
+ scopes: string[];
870
+ emailChoice: "share" | "hide" | null;
871
+ email: string;
872
+ isPrivateEmail: boolean;
873
+ userDisclosed: boolean;
874
+ };
842
875
 
843
876
  /**
844
877
  * The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
@@ -1043,7 +1076,7 @@ type OAuthMultiRuntime = {
1043
1076
  /** Compose independent provider runtimes behind exact path mounts on one listener. */
1044
1077
  declare function createMultiRuntime(options: OAuthMultiRuntimeOptions): OAuthMultiRuntime;
1045
1078
 
1046
- type OAuthAPIOptions = APIOptions & {
1079
+ type OAuthAPIOptions = APIOptions & CredentialOptions & {
1047
1080
  /** Browser Fetch forbids Cookie/Set-Cookie; local transports may explicitly remap them. */
1048
1081
  cookieHeaders?: {
1049
1082
  request: string;
@@ -1058,7 +1091,7 @@ type OAuthAPIOptions = APIOptions & {
1058
1091
  accounts?: Account[];
1059
1092
  clients?: Client[];
1060
1093
  behavior?: BehaviorInput;
1061
- /** Replays behavior choices, never credentials. */
1094
+ /** Replays behavior choices; also credentials when `deterministicCredentials` is set. */
1062
1095
  seed?: number | string;
1063
1096
  /** CSP nonce source for form-post responses. Defaults to `crypto.randomUUID`. */
1064
1097
  nonce?: () => string;
@@ -1078,9 +1111,10 @@ declare class OAuthAPI {
1078
1111
  private readonly sessions;
1079
1112
  private readonly consents;
1080
1113
  private signer;
1114
+ private readonly credentials;
1081
1115
  private previousSigners;
1082
1116
  /** Never published: signs ID tokens for `tokens.idTokenSigningKey: "unpublished"`. */
1083
- private unpublishedSigner?;
1117
+ private unpublishedSigner;
1084
1118
  readonly behavior: BehaviorState;
1085
1119
  private readonly identities;
1086
1120
  private readonly appleDisclosures;
@@ -1119,6 +1153,16 @@ declare class OAuthAPI {
1119
1153
  private notify;
1120
1154
  /** Drops one client's grant for an account: consent, identity, first-use disclosure, codes, tokens. */
1121
1155
  private forget;
1156
+ /**
1157
+ * What `clientId` sees for `accountId` (a test control mirroring private provider state), or
1158
+ * `null` for an unknown client or account. For a client that never authorized the account,
1159
+ * `subject` is the id token `sub` it would receive and `email` the real address.
1160
+ */
1161
+ grant(clientId: string, accountId: string): Promise<GrantView | null>;
1162
+ /** The grant view of every account that has authorized `clientId`, oldest account first. */
1163
+ grants(clientId: string): Promise<(GrantView & {
1164
+ accountId: string;
1165
+ })[] | null>;
1122
1166
  private paths;
1123
1167
  private supportedScopes;
1124
1168
  private identityKey;
@@ -1140,4 +1184,4 @@ declare class OAuthAPI {
1140
1184
  }
1141
1185
 
1142
1186
  export { OAUTH_PRESETS, OAUTH_SCENARIOS, OAuthAPI, createMultiRuntime, createRuntime, document, operationIds, supportedOperationIds };
1143
- export type { Account, AppleNotificationType, BehaviorEvent, BehaviorInput, Client, EdgeCase, NotificationDelivery, OAuthAPIOptions, OAuthBehavior, OAuthMount, OAuthMultiRuntime, OAuthMultiRuntimeOptions, OAuthRuntime, OAuthRuntimeOptions, OAuthScenario, Provider };
1187
+ export type { Account, AppleNotificationType, BehaviorEvent, BehaviorInput, Client, CredentialOptions, EdgeCase, GrantView, NotificationDelivery, OAuthAPIOptions, OAuthBehavior, OAuthMount, OAuthMultiRuntime, OAuthMultiRuntimeOptions, OAuthRuntime, OAuthRuntimeOptions, OAuthScenario, Provider, SigningKey };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  document,
8
8
  operationIds,
9
9
  supportedOperationIds
10
- } from "./chunk-XP2AEPEJ.js";
10
+ } from "./chunk-SYFF4UFD.js";
11
11
  export {
12
12
  OAUTH_PRESETS,
13
13
  OAUTH_SCENARIOS,
package/dist/server.d.ts CHANGED
@@ -1314,6 +1314,29 @@ declare class BehaviorState {
1314
1314
  decisions(): Decisions;
1315
1315
  }
1316
1316
 
1317
+ /** A caller-supplied RS256 signing key pair. `kid` is published in the JWKS and token headers. */
1318
+ type SigningKey = {
1319
+ privateJwk: JsonWebKey;
1320
+ publicJwk: JsonWebKey;
1321
+ kid: string;
1322
+ };
1323
+ /**
1324
+ * Opt-in control over every opaque value the provider mints. With none of these set the provider
1325
+ * uses cryptographic randomness, exactly as before.
1326
+ */
1327
+ type CredentialOptions = {
1328
+ /**
1329
+ * Derive authorization codes, tokens, transaction ids, session ids, CSP nonces and signing keys
1330
+ * from `seed` (default 0) instead of `crypto`, so the same seed and the same requests replay
1331
+ * byte-for-byte. Test-only: the values are guessable.
1332
+ */
1333
+ deterministicCredentials?: boolean;
1334
+ /** Replaces `crypto.getRandomValues` for every minted value, and wins over the seeded source. */
1335
+ randomBytes?: (length: number) => Uint8Array;
1336
+ /** Signing keys used in order: the first is current and each rotation takes the next. */
1337
+ signingKeys?: SigningKey[];
1338
+ };
1339
+
1317
1340
  type Provider = "google" | "apple" | "oidc" | "microsoft" | "github";
1318
1341
  type Account = {
1319
1342
  id: string;
@@ -1378,8 +1401,18 @@ type NotificationDelivery = {
1378
1401
  status?: number;
1379
1402
  error?: string;
1380
1403
  };
1404
+ /** What one client sees for one account: see `OAuthAPI.grant`. */
1405
+ type GrantView = {
1406
+ subject: string;
1407
+ granted: boolean;
1408
+ scopes: string[];
1409
+ emailChoice: "share" | "hide" | null;
1410
+ email: string;
1411
+ isPrivateEmail: boolean;
1412
+ userDisclosed: boolean;
1413
+ };
1381
1414
 
1382
- type OAuthAPIOptions = APIOptions & {
1415
+ type OAuthAPIOptions = APIOptions & CredentialOptions & {
1383
1416
  /** Browser Fetch forbids Cookie/Set-Cookie; local transports may explicitly remap them. */
1384
1417
  cookieHeaders?: {
1385
1418
  request: string;
@@ -1394,7 +1427,7 @@ type OAuthAPIOptions = APIOptions & {
1394
1427
  accounts?: Account[];
1395
1428
  clients?: Client[];
1396
1429
  behavior?: BehaviorInput;
1397
- /** Replays behavior choices, never credentials. */
1430
+ /** Replays behavior choices; also credentials when `deterministicCredentials` is set. */
1398
1431
  seed?: number | string;
1399
1432
  /** CSP nonce source for form-post responses. Defaults to `crypto.randomUUID`. */
1400
1433
  nonce?: () => string;
@@ -1414,9 +1447,10 @@ declare class OAuthAPI {
1414
1447
  private readonly sessions;
1415
1448
  private readonly consents;
1416
1449
  private signer;
1450
+ private readonly credentials;
1417
1451
  private previousSigners;
1418
1452
  /** Never published: signs ID tokens for `tokens.idTokenSigningKey: "unpublished"`. */
1419
- private unpublishedSigner?;
1453
+ private unpublishedSigner;
1420
1454
  readonly behavior: BehaviorState;
1421
1455
  private readonly identities;
1422
1456
  private readonly appleDisclosures;
@@ -1455,6 +1489,16 @@ declare class OAuthAPI {
1455
1489
  private notify;
1456
1490
  /** Drops one client's grant for an account: consent, identity, first-use disclosure, codes, tokens. */
1457
1491
  private forget;
1492
+ /**
1493
+ * What `clientId` sees for `accountId` (a test control mirroring private provider state), or
1494
+ * `null` for an unknown client or account. For a client that never authorized the account,
1495
+ * `subject` is the id token `sub` it would receive and `email` the real address.
1496
+ */
1497
+ grant(clientId: string, accountId: string): Promise<GrantView | null>;
1498
+ /** The grant view of every account that has authorized `clientId`, oldest account first. */
1499
+ grants(clientId: string): Promise<(GrantView & {
1500
+ accountId: string;
1501
+ })[] | null>;
1458
1502
  private paths;
1459
1503
  private supportedScopes;
1460
1504
  private identityKey;
package/dist/server.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  createMultiServer,
4
4
  createServer,
5
5
  serveTarget
6
- } from "./chunk-2JIADQOV.js";
7
- import "./chunk-XP2AEPEJ.js";
6
+ } from "./chunk-D4IAZYMT.js";
7
+ import "./chunk-SYFF4UFD.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": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "Portable social-login mock 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",