@softistx/janus-oauth-mongo 0.0.0-stage → 0.18.5

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.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +262 -2
  3. package/dist/authorization-collections.d.ts +43 -0
  4. package/dist/authorization-collections.d.ts.map +1 -0
  5. package/dist/clients-collection.d.ts +29 -0
  6. package/dist/clients-collection.d.ts.map +1 -0
  7. package/dist/collection-fields.d.ts +23 -0
  8. package/dist/collection-fields.d.ts.map +1 -0
  9. package/dist/collections.d.ts +211 -0
  10. package/dist/collections.d.ts.map +1 -0
  11. package/dist/details-field.d.ts +25 -0
  12. package/dist/details-field.d.ts.map +1 -0
  13. package/dist/device-collection.d.ts +28 -0
  14. package/dist/device-collection.d.ts.map +1 -0
  15. package/dist/dpop-replay-collection.d.ts +13 -0
  16. package/dist/dpop-replay-collection.d.ts.map +1 -0
  17. package/dist/dpop-replay.d.ts +27 -0
  18. package/dist/dpop-replay.d.ts.map +1 -0
  19. package/dist/grants-collection.d.ts +17 -0
  20. package/dist/grants-collection.d.ts.map +1 -0
  21. package/dist/index.d.ts +16 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +1671 -0
  24. package/dist/index.js.map +52 -0
  25. package/dist/partitioned.d.ts +97 -0
  26. package/dist/partitioned.d.ts.map +1 -0
  27. package/dist/purge.d.ts +124 -0
  28. package/dist/purge.d.ts.map +1 -0
  29. package/dist/record-fields.d.ts +57 -0
  30. package/dist/record-fields.d.ts.map +1 -0
  31. package/dist/records/clients.d.ts +7 -0
  32. package/dist/records/clients.d.ts.map +1 -0
  33. package/dist/records/grants.d.ts +7 -0
  34. package/dist/records/grants.d.ts.map +1 -0
  35. package/dist/records/index.d.ts +5 -0
  36. package/dist/records/index.d.ts.map +1 -0
  37. package/dist/records/requests.d.ts +10 -0
  38. package/dist/records/requests.d.ts.map +1 -0
  39. package/dist/records/tokens.d.ts +10 -0
  40. package/dist/records/tokens.d.ts.map +1 -0
  41. package/dist/records-device.d.ts +7 -0
  42. package/dist/records-device.d.ts.map +1 -0
  43. package/dist/signing-keys/context.d.ts +11 -0
  44. package/dist/signing-keys/context.d.ts.map +1 -0
  45. package/dist/signing-keys/index.d.ts +22 -0
  46. package/dist/signing-keys/index.d.ts.map +1 -0
  47. package/dist/signing-keys/keyring.d.ts +9 -0
  48. package/dist/signing-keys/keyring.d.ts.map +1 -0
  49. package/dist/signing-keys/options.d.ts +15 -0
  50. package/dist/signing-keys/options.d.ts.map +1 -0
  51. package/dist/signing-keys/promote.d.ts +7 -0
  52. package/dist/signing-keys/promote.d.ts.map +1 -0
  53. package/dist/signing-keys/read.d.ts +7 -0
  54. package/dist/signing-keys/read.d.ts.map +1 -0
  55. package/dist/signing-keys/records.d.ts +13 -0
  56. package/dist/signing-keys/records.d.ts.map +1 -0
  57. package/dist/signing-keys/reseal.d.ts +25 -0
  58. package/dist/signing-keys/reseal.d.ts.map +1 -0
  59. package/dist/signing-keys/seal.d.ts +19 -0
  60. package/dist/signing-keys/seal.d.ts.map +1 -0
  61. package/dist/signing-keys/write.d.ts +7 -0
  62. package/dist/signing-keys/write.d.ts.map +1 -0
  63. package/dist/signing-keys-collection.d.ts +52 -0
  64. package/dist/signing-keys-collection.d.ts.map +1 -0
  65. package/dist/store/clients.d.ts +7 -0
  66. package/dist/store/clients.d.ts.map +1 -0
  67. package/dist/store/codes.d.ts +7 -0
  68. package/dist/store/codes.d.ts.map +1 -0
  69. package/dist/store/context.d.ts +21 -0
  70. package/dist/store/context.d.ts.map +1 -0
  71. package/dist/store/device.d.ts +7 -0
  72. package/dist/store/device.d.ts.map +1 -0
  73. package/dist/store/grant-reads.d.ts +7 -0
  74. package/dist/store/grant-reads.d.ts.map +1 -0
  75. package/dist/store/grants.d.ts +7 -0
  76. package/dist/store/grants.d.ts.map +1 -0
  77. package/dist/store/index.d.ts +58 -0
  78. package/dist/store/index.d.ts.map +1 -0
  79. package/dist/store/open.d.ts +9 -0
  80. package/dist/store/open.d.ts.map +1 -0
  81. package/dist/store/requests.d.ts +7 -0
  82. package/dist/store/requests.d.ts.map +1 -0
  83. package/dist/store/rotate.d.ts +6 -0
  84. package/dist/store/rotate.d.ts.map +1 -0
  85. package/dist/store/scope.d.ts +24 -0
  86. package/dist/store/scope.d.ts.map +1 -0
  87. package/dist/store/spend-devices.d.ts +20 -0
  88. package/dist/store/spend-devices.d.ts.map +1 -0
  89. package/dist/store/tokens.d.ts +7 -0
  90. package/dist/store/tokens.d.ts.map +1 -0
  91. package/dist/sync.d.ts +20 -0
  92. package/dist/sync.d.ts.map +1 -0
  93. package/dist/tokens-collections.d.ts +42 -0
  94. package/dist/tokens-collections.d.ts.map +1 -0
  95. package/dist/transaction.d.ts +13 -0
  96. package/dist/transaction.d.ts.map +1 -0
  97. package/dist/translate.d.ts +34 -0
  98. package/dist/translate.d.ts.map +1 -0
  99. package/docs/README.md +13 -0
  100. package/docs/guide/partitions.md +141 -0
  101. package/docs/guide/wiring.md +133 -0
  102. package/docs/roadmap.md +46 -0
  103. package/docs/troubleshooting.md +226 -0
  104. package/package.json +68 -5
@@ -0,0 +1,52 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/authorization-collections.ts", "../src/collection-fields.ts", "../src/clients-collection.ts", "../src/device-collection.ts", "../src/dpop-replay-collection.ts", "../src/grants-collection.ts", "../src/signing-keys-collection.ts", "../src/tokens-collections.ts", "../src/collections.ts", "../src/dpop-replay.ts", "../src/translate.ts", "../src/partitioned.ts", "../src/purge.ts", "../src/signing-keys/options.ts", "../src/signing-keys/keyring.ts", "../src/transaction.ts", "../src/signing-keys/records.ts", "../src/signing-keys/promote.ts", "../src/signing-keys/read.ts", "../src/signing-keys/seal.ts", "../src/signing-keys/write.ts", "../src/signing-keys/reseal.ts", "../src/signing-keys/index.ts", "../src/store/clients.ts", "../src/record-fields.ts", "../src/records/clients.ts", "../src/details-field.ts", "../src/records/grants.ts", "../src/records/requests.ts", "../src/records/tokens.ts", "../src/store/scope.ts", "../src/store/codes.ts", "../src/store/device.ts", "../src/records-device.ts", "../src/store/grant-reads.ts", "../src/store/spend-devices.ts", "../src/store/grants.ts", "../src/store/open.ts", "../src/store/requests.ts", "../src/store/rotate.ts", "../src/store/tokens.ts", "../src/store/index.ts", "../src/sync.ts"],
4
+ "sourcesContent": [
5
+ "import { defineCollection } from '@softistx/mongo';\nimport { z } from 'zod';\nimport {\n\tat,\n\tauthorizationDetails,\n\topenIdFields,\n\tscopes,\n} from './collection-fields';\n\n/** Seconds a lapsed authorization code stays, so a replay is still told from an unknown code: 24 hours. */\nexport const CODE_GRACE_SECONDS = 24 * 60 * 60;\n\nexport const oauthRequests = defineCollection({\n\tname: 'oauthRequests',\n\tschema: z.object({\n\t\t_id: z.string(),\n\t\tclientId: z.string(),\n\t\tredirectUri: z.string(),\n\t\tresource: z.string(),\n\t\tscopes,\n\t\tstate: z.string().nullable(),\n\t\tnonce: z.string().optional(),\n\t\tdpopJkt: z.string().optional(),\n\t\tauthorizationDetails,\n\t\tacrValues: z.array(z.string()).optional(),\n\t\tmaxAge: z.number().int().nonnegative().optional(),\n\t\tprompt: z.array(z.string()).optional(),\n\t\tloginHint: z.string().optional(),\n\t\tcodeChallenge: z.string(),\n\t\tcodeChallengeMethod: z.literal('S256'),\n\t\tcreatedAt: at,\n\t\texpiresAt: at,\n\t}),\n\tindexes: [{ key: { expiresAt: 1 }, name: 'expiry', expireAfterSeconds: 0 }],\n});\n\nexport const oauthCodes = defineCollection({\n\tname: 'oauthCodes',\n\tschema: z.object({\n\t\t/** `sha256(code)`. */\n\t\t_id: z.string(),\n\t\tclientId: z.string(),\n\t\tuserId: z.string(),\n\t\tgrantId: z.string(),\n\t\tredirectUri: z.string(),\n\t\tresource: z.string(),\n\t\tscopes,\n\t\tcodeChallenge: z.string(),\n\t\tcodeChallengeMethod: z.literal('S256'),\n\t\tcreatedAt: at,\n\t\texpiresAt: at,\n\t\tconsumedAt: at.nullable(),\n\t\tdpopJkt: z.string().optional(),\n\t\tauthorizationDetails,\n\t\t...openIdFields,\n\t}),\n\tindexes: [\n\t\t/** `deleteUserGrants` removes one user's codes. */\n\t\t{ key: { userId: 1 }, name: 'userId' },\n\t\t{\n\t\t\tkey: { expiresAt: 1 },\n\t\t\tname: 'expiry',\n\t\t\texpireAfterSeconds: CODE_GRACE_SECONDS,\n\t\t},\n\t],\n});\n",
6
+ "import { z } from 'zod';\n\nexport const at = z.date();\nexport const scopes = z.array(z.string());\n\n/**\n * The RFC 9396 authorization details of a record, as **one canonical JSON\n * string** (keys sorted, no whitespace): a detail is arbitrary JSON, whose\n * keys (`$x`, `a.b`) collide with MongoDB's field rules, and nothing queries\n * it. Absent when the record has none (never `null`), so a document written\n * before they existed is read back unchanged.\n */\nexport const authorizationDetails = z.string().optional();\n\n/**\n * What OpenID Connect adds to a record: all optional, **absent when the\n * server gave none** (never `null`), so a document written before they\n * existed is read back unchanged.\n */\nexport const openIdFields = {\n\tnonce: z.string().optional(),\n\tauthTime: at.optional(),\n\tamr: z.array(z.string()).optional(),\n\tacr: z.string().optional(),\n};\n",
7
+ "import { defineCollection } from '@softistx/mongo';\nimport { z } from 'zod';\nimport { at } from './collection-fields';\n\n/** Seconds a lapsed metadata client stays before the TTL monitor drops it: 24 hours. Storage hygiene only: the server never serves a stale copy after a failed refetch. */\nexport const CLIENT_GRACE_SECONDS = 24 * 60 * 60;\n\nexport const oauthClients = defineCollection({\n\tname: 'oauthClients',\n\tschema: z.object({\n\t\t/** The `client_id`: an opaque id, or the HTTPS URL of a metadata document. */\n\t\t_id: z.string(),\n\t\tname: z.string(),\n\t\tredirectUris: z.array(z.string()),\n\t\tsource: z.enum(['registered', 'metadata']),\n\t\tcreatedAt: at,\n\t\t/** `null` for a registered client, which the TTL monitor then never drops. */\n\t\texpiresAt: at.nullable(),\n\t\t/** Absent for a public client (`none`). */\n\t\ttokenEndpointAuthMethod: z.enum(['none', 'client_secret_basic']).optional(),\n\t\t/** `sha256(client secret)`, hex; the secret itself is never stored. Absent for a public client. */\n\t\tsecretHash: z.string().optional(),\n\t\t/** Absent means both grant types. */\n\t\tgrantTypes: z\n\t\t\t.array(\n\t\t\t\tz.enum([\n\t\t\t\t\t'authorization_code',\n\t\t\t\t\t'refresh_token',\n\t\t\t\t\t'urn:ietf:params:oauth:grant-type:device_code',\n\t\t\t\t\t'urn:ietf:params:oauth:grant-type:token-exchange',\n\t\t\t\t]),\n\t\t\t)\n\t\t\t.optional(),\n\t\t/** Absent means not required. */\n\t\trequirePushedAuthorizationRequests: z.boolean().optional(),\n\t\t/** Absent means not required. */\n\t\tdpopBoundAccessTokens: z.boolean().optional(),\n\t\t/** The authorization details types the client may use (RFC 9396 §10.2); absent means none. */\n\t\tauthorizationDetailsTypes: z.array(z.string()).optional(),\n\t}),\n\tindexes: [\n\t\t{\n\t\t\tkey: { expiresAt: 1 },\n\t\t\tname: 'expiry',\n\t\t\texpireAfterSeconds: CLIENT_GRACE_SECONDS,\n\t\t},\n\t],\n});\n",
8
+ "import { defineCollection } from '@softistx/mongo';\nimport { z } from 'zod';\nimport { authorizationDetails } from './collection-fields';\n\nconst at = z.date();\n\n/** Seconds a lapsed device authorization stays, so a replayed poll is still told from an unknown device code: 24 hours. */\nexport const DEVICE_GRACE_SECONDS = 24 * 60 * 60;\n\nexport const oauthDeviceAuthorizations = defineCollection({\n\tname: 'oauthDeviceAuthorizations',\n\tschema: z.object({\n\t\t/** `sha256(device_code)`. */\n\t\t_id: z.string(),\n\t\t/** `sha256` of the normalised user code; unique. */\n\t\tuserCodeHash: z.string(),\n\t\tclientId: z.string(),\n\t\tresource: z.string(),\n\t\tscopes: z.array(z.string()),\n\t\tintervalMs: z.number(),\n\t\tlastPolledAt: at.nullable(),\n\t\tstatus: z.enum(['pending', 'approved', 'denied']),\n\t\t/** Set by an approval. */\n\t\tuserId: z.string().optional(),\n\t\t/** Set by an approval. */\n\t\tgrantId: z.string().optional(),\n\t\tcreatedAt: at,\n\t\texpiresAt: at,\n\t\tconsumedAt: at.nullable(),\n\t\tauthorizationDetails,\n\t\tnonce: z.string().optional(),\n\t\tauthTime: at.optional(),\n\t\tamr: z.array(z.string()).optional(),\n\t\tacr: z.string().optional(),\n\t}),\n\tindexes: [\n\t\t/** The verification page looks a request up by the code the user typed, and two requests never share one. */\n\t\t{ key: { userCodeHash: 1 }, name: 'userCodeHashUnique', unique: true },\n\t\t/** `deleteUserGrants` removes one user's device authorizations. */\n\t\t{ key: { userId: 1 }, name: 'userId' },\n\t\t/** `revokeGrant` spends the approvals of one grant; only approved records carry a `grantId`. */\n\t\t{ key: { grantId: 1 }, name: 'grantId', sparse: true },\n\t\t/** `revokeClientGrants` spends the approvals of one client. */\n\t\t{ key: { clientId: 1 }, name: 'clientId' },\n\t\t{\n\t\t\tkey: { expiresAt: 1 },\n\t\t\tname: 'expiry',\n\t\t\texpireAfterSeconds: DEVICE_GRACE_SECONDS,\n\t\t},\n\t],\n});\n",
9
+ "import { defineCollection } from '@softistx/mongo';\nimport { z } from 'zod';\n\n/**\n * The spent DPoP proofs of `createMongoDPoPReplayCache`: `_id` is the key\n * (`replayKey(jkt, jti)`), so the unique index on it is what makes a spend\n * atomic. The TTL index (`expireAfterSeconds: 0`) is storage hygiene only:\n * the monitor runs about every sixty seconds, and a lapsed but unreaped\n * document counts as unused (the adapter compares `expiresAt` itself).\n */\nexport const oauthDpopReplay = defineCollection({\n\tname: 'oauthDpopReplay',\n\tschema: z.object({\n\t\t/** `base64url(sha256(jkt:jti))`. */\n\t\t_id: z.string(),\n\t\t/** When the proof can no longer be replayed: the end of its freshness window. */\n\t\texpiresAt: z.date(),\n\t}),\n\tindexes: [{ key: { expiresAt: 1 }, name: 'expiry', expireAfterSeconds: 0 }],\n});\n",
10
+ "import { defineCollection } from '@softistx/mongo';\nimport { z } from 'zod';\nimport { at, authorizationDetails, scopes } from './collection-fields';\n\nexport const oauthGrants = defineCollection({\n\tname: 'oauthGrants',\n\tschema: z.object({\n\t\t/** The UUIDv7 the server minted: `_id` order is creation order. */\n\t\t_id: z.string(),\n\t\tuserId: z.string(),\n\t\tclientId: z.string(),\n\t\tresource: z.string(),\n\t\tscopes,\n\t\tcreatedAt: at,\n\t\tupdatedAt: at,\n\t\trevokedAt: at.nullable(),\n\t\t/** The one object the grant acts in; absent on a grant bound to none. */\n\t\tbound: z.object({ type: z.string(), id: z.string() }).optional(),\n\t\tauthorizationDetails,\n\t}),\n\tindexes: [\n\t\t/**\n\t\t * One grant per user x client x resource. It is what makes `upsertGrant`\n\t\t * atomic: of concurrent upserts, the index lets one insert, and the\n\t\t * others update it. Its prefix serves `findUserGrant`, the user's\n\t\t * listing and the per-user revoke and delete.\n\t\t */\n\t\t{\n\t\t\tkey: { userId: 1, clientId: 1, resource: 1 },\n\t\t\tname: 'userClientResourceUnique',\n\t\t\tunique: true,\n\t\t},\n\t\t/** `listClientGrants` and `revokeClientGrants` look a client's grants up. */\n\t\t{ key: { clientId: 1 }, name: 'clientId' },\n\t\t/**\n\t\t * `listBoundGrants` reads one object's grants in `_id` order. Partial: a\n\t\t * grant bound to none is not in it, so unbound grants cost the index\n\t\t * nothing.\n\t\t */\n\t\t{\n\t\t\tkey: { 'bound.type': 1, 'bound.id': 1, _id: 1 },\n\t\t\tname: 'bound',\n\t\t\tpartialFilterExpression: { 'bound.type': { $exists: true } },\n\t\t},\n\t],\n});\n",
11
+ "import { defineCollection } from '@softistx/mongo';\nimport { z } from 'zod';\n\nconst at = z.date();\n\nconst jwk = z.object({\n\tkty: z.enum(['EC', 'OKP']),\n\tcrv: z.enum(['P-256', 'Ed25519']),\n\tx: z.string(),\n\ty: z.string().optional(),\n\tkid: z.string(),\n\talg: z.enum(['ES256', 'EdDSA']),\n\tuse: z.literal('sig'),\n});\n\n/**\n * The signing keys of `createMongoSigningKeys`. **The private JWK is never a\n * field**: `sealed` is its AES-GCM ciphertext, so no `d` (nor any other\n * private member) is stored in the clear. The public JWK is public.\n */\nexport const oauthSigningKeys = defineCollection({\n\tname: 'oauthSigningKeys',\n\tschema: z.object({\n\t\t/** `JSON.stringify([partition, kid])`, so no two partitions share an id. */\n\t\t_id: z.string(),\n\t\tpartition: z.string(),\n\t\tkid: z.string(),\n\t\talg: z.enum(['ES256', 'EdDSA']),\n\t\tstatus: z.enum(['current', 'next', 'retired']),\n\t\t/** Equal to `status` while `current` or `next`, `null` once retired: what the unique index holds to one of each per partition. */\n\t\tslot: z.enum(['current', 'next']).nullable(),\n\t\tpublicJwk: jwk,\n\t\t/** The private JWK, encrypted: base64url `iv` (12 bytes) and `data` (ciphertext and tag). */\n\t\tsealed: z.object({ iv: z.string(), data: z.string() }),\n\t\tcreatedAt: at,\n\t\tactivateAt: at,\n\t\tactivatedAt: at.nullable(),\n\t\tretiredAt: at.nullable(),\n\t\tpublishUntil: at.nullable(),\n\t}),\n\tindexes: [\n\t\t/** `findKeys` reads a partition's standing keys; `findCurrentKey` one of them by status. */\n\t\t{ key: { partition: 1, status: 1 }, name: 'partitionStatus' },\n\t\t/** At most one `current` and one `next` key per partition: what makes `insertKey` atomic. */\n\t\t{\n\t\t\tkey: { partition: 1, slot: 1 },\n\t\t\tname: 'partitionSlotUnique',\n\t\t\tunique: true,\n\t\t\tpartialFilterExpression: { slot: { $type: 'string' } },\n\t\t},\n\t\t/**\n\t\t * Drops a retired key once its `publishUntil` has passed. Storage\n\t\t * hygiene, not the expiry: `findKeys` and `findPublicKeys` compare\n\t\t * `publishUntil` on every read. `current` and `next` keys hold `null`\n\t\t * there, which a TTL index never expires.\n\t\t */\n\t\t{\n\t\t\tkey: { publishUntil: 1 },\n\t\t\tname: 'publishUntilExpiry',\n\t\t\texpireAfterSeconds: 0,\n\t\t},\n\t],\n});\n",
12
+ "import { defineCollection } from '@softistx/mongo';\nimport { z } from 'zod';\nimport {\n\tat,\n\tauthorizationDetails,\n\topenIdFields,\n\tscopes,\n} from './collection-fields';\n\n/** What an access token and a refresh token share. */\nconst tokenFields = {\n\t/** `sha256(token)`. */\n\t_id: z.string(),\n\tgrantId: z.string(),\n\tuserId: z.string(),\n\tclientId: z.string(),\n\tresource: z.string(),\n\tscopes,\n\tcreatedAt: at,\n\texpiresAt: at,\n\trevokedAt: at.nullable(),\n\t/** The DPoP key thumbprint; absent when not bound. */\n\tjkt: z.string().optional(),\n\tauthorizationDetails,\n\t...openIdFields,\n};\n\nexport const oauthAccessTokens = defineCollection({\n\tname: 'oauthAccessTokens',\n\tschema: z.object({\n\t\t...tokenFields,\n\t\t/** The actor of a delegated token (RFC 8693); absent when not delegated. */\n\t\tactor: z\n\t\t\t.object({ sub: z.string(), clientId: z.string().optional() })\n\t\t\t.optional(),\n\t}),\n\tindexes: [\n\t\t/** `revokeGrant` sweeps a grant's tokens. */\n\t\t{ key: { grantId: 1 }, name: 'grantId' },\n\t\t/** `revokeUserGrants` and `deleteUserGrants` sweep a user's. */\n\t\t{ key: { userId: 1 }, name: 'userId' },\n\t\t/** `revokeClientGrants` sweeps a client's. */\n\t\t{ key: { clientId: 1 }, name: 'clientId' },\n\t\t{ key: { expiresAt: 1 }, name: 'expiry', expireAfterSeconds: 0 },\n\t],\n});\n\nexport const oauthRefreshTokens = defineCollection({\n\tname: 'oauthRefreshTokens',\n\tschema: z.object({\n\t\t...tokenFields,\n\t\tabsoluteExpiresAt: at,\n\t\trotatedAt: at.nullable(),\n\t}),\n\tindexes: [\n\t\t{ key: { grantId: 1 }, name: 'grantId' },\n\t\t{ key: { userId: 1 }, name: 'userId' },\n\t\t{ key: { clientId: 1 }, name: 'clientId' },\n\t\t/**\n\t\t * **On the 90-day cap, not on the sliding `expiresAt`.** A token that was\n\t\t * rotated has to stay as long as its chain can live, or a stolen copy\n\t\t * replayed after its own expiry would answer `absent` instead of\n\t\t * `reused`, and the grant would not be revoked. `absoluteExpiresAt` is\n\t\t * that bound: no token of the chain outlives it.\n\t\t */\n\t\t{\n\t\t\tkey: { absoluteExpiresAt: 1 },\n\t\t\tname: 'expiry',\n\t\t\texpireAfterSeconds: 0,\n\t\t},\n\t],\n});\n",
13
+ "import { oauthCodes, oauthRequests } from './authorization-collections';\nimport { oauthClients } from './clients-collection';\nimport { oauthDeviceAuthorizations } from './device-collection';\nimport { oauthDpopReplay } from './dpop-replay-collection';\nimport { oauthGrants } from './grants-collection';\nimport { oauthSigningKeys } from './signing-keys-collection';\nimport { oauthAccessTokens, oauthRefreshTokens } from './tokens-collections';\n\n/**\n * The nine collections, as `@softistx/mongo` definitions.\n *\n * **What the database holds is the port's record**, with its key under `_id`:\n * the id for a client, a request and a grant, and the `sha256` hash for a\n * code and a token. `_id` is always unique, so **the unique index on each\n * secret hash is the primary key itself**. Nothing else is renamed and\n * nothing is encoded, so a record comes back byte for byte (rule 4).\n *\n * Defining them registers them with `@softistx/mongo`, so an application that\n * deploys with `syncAll(db)` creates these with the rest of its own.\n *\n * **Every TTL index is storage hygiene, not the expiry.** MongoDB's TTL\n * monitor runs about every sixty seconds, so a lapsed record stays readable\n * for up to a minute (more on a loaded server) past its time plus its grace.\n * The server compares `expiresAt` on every read, which is what expires a\n * record.\n */\n\nexport {\n\tCODE_GRACE_SECONDS,\n\toauthCodes,\n\toauthRequests,\n} from './authorization-collections';\nexport { CLIENT_GRACE_SECONDS, oauthClients } from './clients-collection';\nexport {\n\tDEVICE_GRACE_SECONDS,\n\toauthDeviceAuthorizations,\n} from './device-collection';\nexport { oauthDpopReplay } from './dpop-replay-collection';\nexport { oauthGrants } from './grants-collection';\nexport { oauthSigningKeys } from './signing-keys-collection';\nexport { oauthAccessTokens, oauthRefreshTokens } from './tokens-collections';\n\n/** The nine definitions, in the order `syncMongoOAuth` syncs them. */\nexport const oauthCollections = [\n\toauthClients,\n\toauthRequests,\n\toauthCodes,\n\toauthDeviceAuthorizations,\n\toauthGrants,\n\toauthAccessTokens,\n\toauthRefreshTokens,\n\toauthSigningKeys,\n\toauthDpopReplay,\n] as const;\n",
14
+ "import { type Clock, systemClock } from '@softistx/janus';\nimport type { DPoPReplayCache } from '@softistx/janus-oauth';\nimport { type DocumentOf, getCollection } from '@softistx/mongo';\nimport type { Collection, Db } from 'mongodb';\nimport { oauthDpopReplay } from './dpop-replay-collection';\nimport { isDuplicateKey, run } from './translate';\n\n/** What `createMongoDPoPReplayCache` takes. */\nexport interface MongoDPoPReplayCacheOptions {\n\t/** The time a spent key is compared with. Default: the system clock. Specs pass a fixed one. */\n\treadonly clock?: Clock;\n}\n\n/**\n * The `DPoPReplayCache` of `@softistx/janus-oauth` over one MongoDB database,\n * in the `oauthDpopReplay` collection that `syncMongoOAuth` creates.\n *\n * ```ts\n * const replay = createMongoDPoPReplayCache(db);\n * const oauth = createOAuthServer({ auth, store, dpop: { replay }, ... });\n * ```\n *\n * `spend` is **one atomic upsert**: it matches the key only when its stored\n * `expiresAt` has passed, and otherwise tries to insert it. A key never\n * spent, or lapsed, is written and answers `true`; a held key hits the unique\n * `_id` and answers `false`, so of several simultaneous spends exactly one\n * wins. A lapsed document the TTL monitor has not yet dropped counts as\n * unused. Any other error is a `StoreFailure`: never `true` and never `false`\n * for an outage.\n */\nexport function createMongoDPoPReplayCache(\n\tdb: Db,\n\toptions: MongoDPoPReplayCacheOptions = {},\n): DPoPReplayCache {\n\tif (typeof db?.collection !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t`createMongoDPoPReplayCache: pass the Db your app opened with @softistx/mongo (got ${db === null ? 'null' : typeof db})`,\n\t\t);\n\t}\n\tconst clock = options.clock ?? systemClock;\n\tconst keys = db.collection(\n\t\tgetCollection(db, oauthDpopReplay).raw.collectionName,\n\t\t{ readPreference: 'primary' },\n\t) as Collection<DocumentOf<typeof oauthDpopReplay>>;\n\treturn {\n\t\tspend: (key, expiresAt) =>\n\t\t\trun(\n\t\t\t\t'spend',\n\t\t\t\tasync () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait keys.updateOne(\n\t\t\t\t\t\t\t{ _id: key, expiresAt: { $lte: clock.now() } },\n\t\t\t\t\t\t\t{ $set: { expiresAt } },\n\t\t\t\t\t\t\t{ upsert: true },\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (isDuplicateKey(error)) return false;\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t'dpopReplay',\n\t\t\t),\n\t};\n}\n",
15
+ "import { JanusError, StoreFailure } from '@softistx/janus';\n\n/**\n * **The driver's errors, as the port's.** One file, and one default.\n *\n * | What happens | Becomes |\n * | --- | --- |\n * | A duplicate key on `_id` of an insert | nothing — the insert is a retry and writes nothing |\n * | A duplicate key on `_id` or `userCodeHash` of a device authorization insert | **`false`** — the port's \"already held\", nothing written |\n * | A duplicate key anywhere else | **`StoreFailure`**: an index this adapter never meant to collide on is a bug |\n * | A `$jsonSchema` validation failure (121) | **`StoreFailure`** |\n * | Anything else, absolutely | `StoreFailure`, with the driver error as `cause` |\n *\n * **The default is a failure, not an absence**: nothing here answers `null`,\n * `false`, `0` or `absent` for an error, which is the port's first rule.\n */\n\n/** Runs one port method, and makes every rejection one the port allows. `prefix` names the port in the message. */\nexport async function run<T>(\n\toperation: string,\n\tbody: () => Promise<T>,\n\tprefix = 'oauthStore',\n): Promise<T> {\n\ttry {\n\t\treturn await body();\n\t} catch (error) {\n\t\tif (error instanceof JanusError) throw error;\n\t\tthrow new StoreFailure(\n\t\t\t`${prefix}.${operation}: the store could not answer`,\n\t\t\t{ operation, cause: error },\n\t\t);\n\t}\n}\n\n/** The shape of the driver's `E11000`, as far as this file reads it. */\nexport interface DuplicateKey {\n\treadonly code: 11000;\n\treadonly keyPattern?: Readonly<Record<string, unknown>>;\n}\n\nexport function isDuplicateKey(error: unknown): error is DuplicateKey {\n\treturn (\n\t\ttypeof error === 'object' &&\n\t\terror !== null &&\n\t\t(error as { code?: unknown }).code === 11000\n\t);\n}\n\n/** The duplicate-key error behind a write, `null` when it landed; any other rejection is rethrown. */\nexport async function duplicateOf(\n\twrite: Promise<unknown>,\n): Promise<DuplicateKey | null> {\n\ttry {\n\t\tawait write;\n\t\treturn null;\n\t} catch (error) {\n\t\tif (isDuplicateKey(error)) return error;\n\t\tthrow error;\n\t}\n}\n\n/** A duplicate on an index the adapter never meant to collide on: a bug, reported as one. */\nexport function unexpectedDuplicate(\n\toperation: string,\n\tduplicate: DuplicateKey,\n): StoreFailure {\n\treturn new StoreFailure(\n\t\t`oauthStore.${operation}: a duplicate key on ${Object.keys(duplicate.keyPattern ?? {}).join(', ') || 'an unknown index'}, which this adapter never writes on purpose`,\n\t\t{ operation, cause: duplicate },\n\t);\n}\n\n/** The duplicate is on `_id`, the key of every collection: the insert is a retry. */\nexport function onId(duplicate: DuplicateKey): boolean {\n\tconst keys = Object.keys(duplicate.keyPattern ?? {});\n\treturn keys.length === 1 && keys[0] === '_id';\n}\n\n/** The duplicate is on the grant's `(userId, clientId, resource)` index. */\nexport function onKey(duplicate: DuplicateKey): boolean {\n\treturn 'userId' in (duplicate.keyPattern ?? {});\n}\n\n/** The duplicate is on a key of a device authorization: its `_id` (the device code) or its unique `userCodeHash`. */\nexport function onDeviceCode(duplicate: DuplicateKey): boolean {\n\tconst keys = Object.keys(duplicate.keyPattern ?? {});\n\treturn keys.includes('_id') || keys.includes('userCodeHash');\n}\n",
16
+ "import { defineCollection } from '@softistx/mongo';\nimport type { IndexDescription } from 'mongodb';\nimport { z } from 'zod';\nimport {\n\toauthAccessTokens,\n\toauthClients,\n\toauthCodes,\n\toauthDeviceAuthorizations,\n\toauthGrants,\n\toauthRefreshTokens,\n\toauthRequests,\n\toauthSigningKeys,\n} from './collections';\n\n/**\n * The partitioned layout, for `createMongoOAuth(db, { partition })`: the same\n * seven collections under other names, so the default layout is untouched.\n *\n * Each document carries its `partition` and its `_id` is\n * `JSON.stringify([partition, id])`, the form the signing keys already use,\n * so no two partitions share a key (a client id, a secret hash, a grant id).\n * Every index that is not a TTL index starts with `partition`, and a unique\n * one is unique inside a partition: two issuers can hold a grant for the\n * same user, client and resource. A TTL index stays on its own field, since\n * MongoDB only expires on a single-field index.\n *\n * They are derived from the default definitions, so a field or an index\n * added there reaches both layouts.\n */\n\nfunction partitionIndex(index: IndexDescription): IndexDescription {\n\tif (index.expireAfterSeconds !== undefined) return index;\n\treturn { ...index, key: { partition: 1, ...index.key } };\n}\n\nfunction partitioned(\n\tdefinition: {\n\t\treadonly schema: z.ZodObject;\n\t\treadonly indexes: readonly IndexDescription[];\n\t},\n\tname: string,\n) {\n\treturn defineCollection({\n\t\tname,\n\t\tschema: definition.schema.extend({ partition: z.string() }),\n\t\t// The cast: `defineCollection` types index keys on this schema's literal shape, which a derived definition cannot name; the keys are the base ones plus `partition`.\n\t\tindexes: definition.indexes.map(partitionIndex) as never,\n\t});\n}\n\nexport const oauthPartitionedClients = partitioned(\n\toauthClients,\n\t'oauthPartitionedClients',\n);\nexport const oauthPartitionedRequests = partitioned(\n\toauthRequests,\n\t'oauthPartitionedRequests',\n);\nexport const oauthPartitionedCodes = partitioned(\n\toauthCodes,\n\t'oauthPartitionedCodes',\n);\nexport const oauthPartitionedDeviceAuthorizations = partitioned(\n\toauthDeviceAuthorizations,\n\t'oauthPartitionedDeviceAuthorizations',\n);\nexport const oauthPartitionedGrants = partitioned(\n\toauthGrants,\n\t'oauthPartitionedGrants',\n);\nexport const oauthPartitionedAccessTokens = partitioned(\n\toauthAccessTokens,\n\t'oauthPartitionedAccessTokens',\n);\nexport const oauthPartitionedRefreshTokens = partitioned(\n\toauthRefreshTokens,\n\t'oauthPartitionedRefreshTokens',\n);\n\n/** The partitioned layout's definitions, in the order `syncMongoOAuthPartitioned` syncs them; the signing keys are the default layout's, already partitioned. */\nexport const oauthPartitionedCollections = [\n\toauthPartitionedClients,\n\toauthPartitionedRequests,\n\toauthPartitionedCodes,\n\toauthPartitionedDeviceAuthorizations,\n\toauthPartitionedGrants,\n\toauthPartitionedAccessTokens,\n\toauthPartitionedRefreshTokens,\n\toauthSigningKeys,\n] as const;\n",
17
+ "import { getCollection } from '@softistx/mongo';\nimport type { Db } from 'mongodb';\nimport { oauthSigningKeys } from './collections';\nimport {\n\toauthPartitionedAccessTokens,\n\toauthPartitionedClients,\n\toauthPartitionedCodes,\n\toauthPartitionedDeviceAuthorizations,\n\toauthPartitionedGrants,\n\toauthPartitionedRefreshTokens,\n\toauthPartitionedRequests,\n} from './partitioned';\nimport { run } from './translate';\n\n/** The partition `createMongoSigningKeys(db)` uses when it is given none: the key set of the unpartitioned layout. */\nconst DEFAULT_KEYS_PARTITION = 'default';\n\nexport interface PurgeMongoOAuthPartitionOptions {\n\t/** The partition to empty: the name given to `createMongoOAuth` and `createMongoSigningKeys`. Required, a non-empty string. */\n\treadonly partition: string;\n\t/**\n\t * Whether the partition's signing keys are deleted too. Default `true`.\n\t * `false` keeps them, for a key set that outlives its store. It must be\n\t * said for the partition named `default`, which is also the key set of an\n\t * unpartitioned deployment (`createMongoSigningKeys(db)` with no partition).\n\t */\n\treadonly signingKeys?: boolean;\n}\n\n/** What `purgeMongoOAuthPartition` deleted: the number of documents per collection. All zeros when the partition held nothing. */\nexport interface MongoOAuthPartitionPurge {\n\treadonly clients: number;\n\treadonly requests: number;\n\treadonly codes: number;\n\treadonly deviceAuthorizations: number;\n\treadonly grants: number;\n\treadonly accessTokens: number;\n\treadonly refreshTokens: number;\n\t/** `0` when `signingKeys` is `false`. */\n\treadonly signingKeys: number;\n}\n\n/**\n * What a purge empties, in the order it does: the secrets first (tokens,\n * codes, requests), then the grants and the clients, and the signing keys\n * last, so a purge that stops half-way leaves nothing a client can still\n * spend. `partitions.purge.spec.ts` holds this list equal to\n * `oauthPartitionedCollections`: a collection added to the layout and not\n * here fails it.\n */\nexport const PURGED = [\n\t['accessTokens', oauthPartitionedAccessTokens],\n\t['refreshTokens', oauthPartitionedRefreshTokens],\n\t['codes', oauthPartitionedCodes],\n\t['deviceAuthorizations', oauthPartitionedDeviceAuthorizations],\n\t['requests', oauthPartitionedRequests],\n\t['grants', oauthPartitionedGrants],\n\t['clients', oauthPartitionedClients],\n\t['signingKeys', oauthSigningKeys],\n] as const;\n\nfunction optionsOf(options: PurgeMongoOAuthPartitionOptions): {\n\tpartition: string;\n\tsigningKeys: boolean;\n} {\n\tconst where = 'purgeMongoOAuthPartition';\n\tif (typeof options !== 'object' || options === null) {\n\t\tthrow new TypeError(`${where}: pass { partition }`);\n\t}\n\tconst { partition, signingKeys } = options;\n\tif (typeof partition !== 'string' || partition === '') {\n\t\tthrow new TypeError(`${where}: partition must be a non-empty string`);\n\t}\n\tif (signingKeys !== undefined && typeof signingKeys !== 'boolean') {\n\t\tthrow new TypeError(`${where}: signingKeys is a boolean`);\n\t}\n\tif (partition === DEFAULT_KEYS_PARTITION && signingKeys === undefined) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: the signing keys of the partition 'default' are also those of an unpartitioned deployment; say signingKeys: true to delete them or false to keep them`,\n\t\t);\n\t}\n\treturn { partition, signingKeys: signingKeys ?? true };\n}\n\n/**\n * **Destructive, and not undoable**: deletes every document of one partition\n * in the seven partitioned OAuth collections (clients, authorization requests,\n * codes, device authorizations, grants, access tokens, refresh tokens) and the partition's signing\n * keys. For the day an issuer is deleted for good.\n *\n * ```ts\n * const deleted = await purgeMongoOAuthPartition(db, { partition: 'issuer-a' });\n * // { clients: 2, requests: 0, codes: 1, deviceAuthorizations: 0, grants: 5, accessTokens: 9, refreshTokens: 5, signingKeys: 2 }\n * ```\n *\n * - It never touches the default (unpartitioned) collections, nor another\n * partition: every delete is filtered on the exact `partition`.\n * - It is idempotent: a second run, or a partition that never existed,\n * answers zeros.\n * - A missing, empty or non-string `partition` is a `TypeError`, before any\n * I/O. There is no \"purge everything\".\n * - It is not a transaction: the collections are emptied one after the\n * other. A failure is a `StoreFailure`; run it again to finish.\n * - Stop serving the issuer first: a request still in flight can write a\n * record after its collection was emptied. A second run removes it.\n * - Once the signing keys are gone, no JWT access token of the partition\n * verifies any more, and the keys cannot be recovered.\n */\nexport async function purgeMongoOAuthPartition(\n\tdb: Db,\n\toptions: PurgeMongoOAuthPartitionOptions,\n): Promise<MongoOAuthPartitionPurge> {\n\tif (typeof db?.collection !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t`purgeMongoOAuthPartition: pass the Db your app opened with @softistx/mongo (got ${db === null ? 'null' : typeof db})`,\n\t\t);\n\t}\n\tconst { partition, signingKeys } = optionsOf(options);\n\tconst deleted: Record<(typeof PURGED)[number][0], number> = {\n\t\tclients: 0,\n\t\trequests: 0,\n\t\tcodes: 0,\n\t\tdeviceAuthorizations: 0,\n\t\tgrants: 0,\n\t\taccessTokens: 0,\n\t\trefreshTokens: 0,\n\t\tsigningKeys: 0,\n\t};\n\tawait run('purgePartition', async () => {\n\t\tfor (const [key, definition] of PURGED) {\n\t\t\tif (key === 'signingKeys' && !signingKeys) continue;\n\t\t\tconst { deletedCount } = await getCollection(\n\t\t\t\tdb,\n\t\t\t\tdefinition,\n\t\t\t).raw.deleteMany({ partition });\n\t\t\tdeleted[key] = deletedCount;\n\t\t}\n\t});\n\treturn deleted;\n}\n",
18
+ "import { getCollection } from '@softistx/mongo';\nimport type { Collection, Db } from 'mongodb';\nimport { oauthSigningKeys } from '../collections';\nimport { parseKeyring } from './keyring';\nimport type { SigningKeyDocument } from './records';\n\nexport interface MongoSigningKeysOptions {\n\t/** The master key: 32 random bytes (AES-256-GCM), from your secret manager. Losing it makes every stored key unreadable. A list is a keyring for rotating it: the first key seals, any of them opens (see `resealMongoSigningKeys`). It holds at least one key, 32 bytes each, none twice. */\n\treadonly encryptionKey: Uint8Array | readonly Uint8Array[];\n\t/** Keeps several key sets in one collection (one per issuer, say). Defaults to `default`; two partitions never see each other's keys. */\n\treadonly partition?: string;\n}\n\n/** The arguments of a signing-keys entry point checked, or a `TypeError` naming `where`. */\nexport function parseSigningKeysArguments(\n\tdb: Db,\n\toptions: MongoSigningKeysOptions,\n\twhere: string,\n): {\n\treadonly keyring: readonly Uint8Array[];\n\treadonly partition: string;\n\treadonly keys: Collection<SigningKeyDocument>;\n} {\n\tif (typeof db?.collection !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t`${where}: pass the Db your app opened with @softistx/mongo (got ${db === null ? 'null' : typeof db})`,\n\t\t);\n\t}\n\tif (typeof options !== 'object' || options === null) {\n\t\tthrow new TypeError(`${where}: pass { encryptionKey }`);\n\t}\n\tconst keyring = parseKeyring(options.encryptionKey, where);\n\tconst partition = options.partition ?? 'default';\n\tif (typeof partition !== 'string' || partition === '') {\n\t\tthrow new TypeError(`${where}: partition must be a non-empty string`);\n\t}\n\tconst keys = db.collection(\n\t\tgetCollection(db, oauthSigningKeys).raw.collectionName,\n\t\t{ readPreference: 'primary' },\n\t) as Collection<SigningKeyDocument>;\n\treturn { keyring, partition, keys };\n}\n",
19
+ "const KEY_BYTES = 32;\n\n/** The master key checked: 32 bytes (AES-256), or a `TypeError` saying what was passed. `name` is how the message calls the key (`encryptionKey`, or `encryptionKey[1]` in a list). */\nexport function assertEncryptionKey(\n\tkey: unknown,\n\twhere = 'createMongoSigningKeys',\n\tname = 'encryptionKey',\n): asserts key is Uint8Array {\n\tif (!(key instanceof Uint8Array)) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: ${name} must be a Uint8Array of ${KEY_BYTES} bytes (got ${key === null ? 'null' : typeof key})`,\n\t\t);\n\t}\n\tif (key.byteLength !== KEY_BYTES) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: ${name} must be ${KEY_BYTES} bytes for AES-256-GCM (got ${key.byteLength})`,\n\t\t);\n\t}\n}\n\nconst sameBytes = (a: Uint8Array, b: Uint8Array): boolean =>\n\ta.byteLength === b.byteLength && a.every((byte, i) => byte === b[i]);\n\n/**\n * The `encryptionKey` option as a keyring: a single key is a list of one. A\n * list must be non-empty, hold 32-byte keys only and no key twice (compared by\n * bytes); a message names the entry (`encryptionKey[1]`) and never a byte.\n */\nexport function parseKeyring(\n\tencryptionKey: unknown,\n\twhere: string,\n): readonly Uint8Array[] {\n\tif (!Array.isArray(encryptionKey)) {\n\t\tassertEncryptionKey(encryptionKey, where);\n\t\treturn [encryptionKey];\n\t}\n\tif (encryptionKey.length === 0) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: encryptionKey must hold at least one key (got an empty list)`,\n\t\t);\n\t}\n\tconst keys: Uint8Array[] = [];\n\t// By index, not forEach: a hole in the list is visited and refused too.\n\tfor (let index = 0; index < encryptionKey.length; index++) {\n\t\tconst key: unknown = encryptionKey[index];\n\t\tassertEncryptionKey(key, where, `encryptionKey[${index}]`);\n\t\tconst twin = keys.findIndex((seen) => sameBytes(seen, key));\n\t\tif (twin !== -1) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${where}: encryptionKey[${index}] is the same key as encryptionKey[${twin}]`,\n\t\t\t);\n\t\t}\n\t\tkeys.push(key);\n\t}\n\treturn keys;\n}\n",
20
+ "import { type ClientSession, type Db, MongoError } from 'mongodb';\n\n/** Attempts a transaction gets when the server labels its failure transient (a write conflict between concurrent rotations). */\nconst TRANSACTION_ATTEMPTS = 7;\n\n/** The pause before attempt `n + 1` is random between these bounds, times `n`: at most 25 * (1 + ... + 6) = 525 ms in all. */\nconst BACKOFF_MIN_MS = 5;\nconst BACKOFF_MAX_MS = 25;\n\n/** Jittered, so contenders that conflicted together do not come back together. */\nfunction backoff(attempt: number): Promise<void> {\n\tconst jitter =\n\t\tBACKOFF_MIN_MS + Math.random() * (BACKOFF_MAX_MS - BACKOFF_MIN_MS);\n\treturn new Promise((resolve) => setTimeout(resolve, jitter * attempt));\n}\n\n/**\n * Runs `body` in a transaction and commits it, running it again when the\n * server labels the failure `TransientTransactionError`, at most\n * `TRANSACTION_ATTEMPTS` times, with a short jittered pause growing with the\n * attempt (an immediate retry meets the same contenders again, and with 8\n * callers one used up its attempts). The commit is inside the same `try`, so\n * a labelled conflict at `commitTransaction` is retried the same way. **Not the driver's `withTransaction`**, which\n * retries for up to 120 seconds: under an outage a request would hang that\n * long before the port heard of the failure.\n */\nexport async function inTransaction<T>(\n\tdb: Db,\n\tbody: (session: ClientSession) => Promise<T>,\n): Promise<T> {\n\treturn db.client.withSession(async (session) => {\n\t\tfor (let attempt = 1; ; attempt += 1) {\n\t\t\tsession.startTransaction();\n\t\t\ttry {\n\t\t\t\tconst result = await body(session);\n\t\t\t\tawait commit(session);\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tawait session.abortTransaction().catch(() => undefined);\n\t\t\t\tconst transient =\n\t\t\t\t\terror instanceof MongoError &&\n\t\t\t\t\terror.hasErrorLabel('TransientTransactionError');\n\t\t\t\tif (!transient || attempt === TRANSACTION_ATTEMPTS) throw error;\n\t\t\t\tawait backoff(attempt);\n\t\t\t}\n\t\t}\n\t});\n}\n\n/** A commit, asked again once when the server could not say whether it landed (it is idempotent). */\nasync function commit(session: ClientSession): Promise<void> {\n\ttry {\n\t\tawait session.commitTransaction();\n\t} catch (error) {\n\t\tif (\n\t\t\terror instanceof MongoError &&\n\t\t\terror.hasErrorLabel('UnknownTransactionCommitResult')\n\t\t) {\n\t\t\tawait session.commitTransaction();\n\t\t\treturn;\n\t\t}\n\t\tthrow error;\n\t}\n}\n",
21
+ "import {\n\ttype NewSigningKey,\n\ttype PublicSigningKey,\n\tpublicMembers,\n\ttype SigningKeyRecord,\n} from '@softistx/janus-oauth';\nimport type { DocumentOf } from '@softistx/mongo';\nimport type { oauthSigningKeys } from '../collections';\nimport type { Sealed, Sealer } from './seal';\n\nexport type SigningKeyDocument = DocumentOf<typeof oauthSigningKeys>;\n\nconst date = (value: Date): Date => new Date(value.getTime());\nconst dateOrNull = (value: Date | null): Date | null =>\n\tvalue === null ? null : date(value);\n\nexport const documentId = (partition: string, kid: string): string =>\n\tJSON.stringify([partition, kid]);\n\n/** The document for a new key: the private JWK only as `sealed`. */\nexport async function toSigningKeyDocument(\n\tkey: NewSigningKey,\n\tpartition: string,\n\tsealer: Sealer,\n): Promise<SigningKeyDocument> {\n\tconst sealed: Sealed = await sealer.seal(key.privateJwk, partition, key.kid);\n\treturn {\n\t\t_id: documentId(partition, key.kid),\n\t\tpartition,\n\t\tkid: key.kid,\n\t\talg: key.alg,\n\t\tstatus: key.status,\n\t\tslot: key.status,\n\t\tpublicJwk: publicMembers(key.publicJwk),\n\t\tsealed,\n\t\tcreatedAt: date(key.createdAt),\n\t\tactivateAt: date(key.activateAt),\n\t\tactivatedAt: dateOrNull(key.activatedAt),\n\t\tretiredAt: null,\n\t\tpublishUntil: null,\n\t};\n}\n\n/** The port's public record: the sealed private JWK is not opened, so a lost master key does not stop it. */\nexport function toPublicSigningKey(\n\tdoc: Omit<SigningKeyDocument, 'sealed'>,\n): PublicSigningKey {\n\treturn {\n\t\tkid: doc.kid,\n\t\talg: doc.alg,\n\t\tstatus: doc.status,\n\t\tpublicJwk: publicMembers(doc.publicJwk),\n\t\tcreatedAt: date(doc.createdAt),\n\t\tactivateAt: date(doc.activateAt),\n\t\tactivatedAt: dateOrNull(doc.activatedAt),\n\t\tretiredAt: dateOrNull(doc.retiredAt),\n\t\tpublishUntil: dateOrNull(doc.publishUntil),\n\t};\n}\n\n/** The port's record: the private JWK decrypted, which throws when the master key is not the one that sealed it. */\nexport async function toSigningKey(\n\tdoc: SigningKeyDocument,\n\tsealer: Sealer,\n): Promise<SigningKeyRecord> {\n\treturn {\n\t\tkid: doc.kid,\n\t\talg: doc.alg,\n\t\tstatus: doc.status,\n\t\tpublicJwk: publicMembers(doc.publicJwk),\n\t\tprivateJwk: await sealer.open(doc.sealed, doc.partition, doc.kid),\n\t\tcreatedAt: date(doc.createdAt),\n\t\tactivateAt: date(doc.activateAt),\n\t\tactivatedAt: dateOrNull(doc.activatedAt),\n\t\tretiredAt: dateOrNull(doc.retiredAt),\n\t\tpublishUntil: dateOrNull(doc.publishUntil),\n\t};\n}\n",
22
+ "import type { SigningKeyStore } from '@softistx/janus-oauth';\nimport { inTransaction } from '../transaction';\nimport { run } from '../translate';\nimport type { SigningKeysContext } from './context';\nimport { documentId } from './records';\n\ntype PromoteMethods = Pick<SigningKeyStore, 'promote'>;\n\n/** All or nothing: the `current` keys retire and the `next` key becomes current, in one transaction. */\nexport function promoteSigningKey({\n\tdb,\n\tkeys,\n\tpartition,\n}: SigningKeysContext): PromoteMethods {\n\treturn {\n\t\tpromote: (kid, at, publishUntil) =>\n\t\t\trun(\n\t\t\t\t'promote',\n\t\t\t\t() =>\n\t\t\t\t\tinTransaction(db, async (session) => {\n\t\t\t\t\t\tconst id = documentId(partition, kid);\n\t\t\t\t\t\t// Read first: a gone `next` key writes nothing.\n\t\t\t\t\t\tconst next = await keys.findOne(\n\t\t\t\t\t\t\t{ _id: id, status: 'next' },\n\t\t\t\t\t\t\t{ session },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (next === null) return false;\n\t\t\t\t\t\tawait keys.updateMany(\n\t\t\t\t\t\t\t{ partition, status: 'current' },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\t\tstatus: 'retired',\n\t\t\t\t\t\t\t\t\tslot: null,\n\t\t\t\t\t\t\t\t\tretiredAt: new Date(at.getTime()),\n\t\t\t\t\t\t\t\t\tpublishUntil: new Date(publishUntil.getTime()),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ session },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst promoted = await keys.updateOne(\n\t\t\t\t\t\t\t{ _id: id, status: 'next' },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\t\tstatus: 'current',\n\t\t\t\t\t\t\t\t\tslot: 'current',\n\t\t\t\t\t\t\t\t\tactivatedAt: new Date(at.getTime()),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ session },\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// A concurrent promote won between the read and the write: the\n\t\t\t\t\t\t// transaction conflicts and retries, so this is a defence only.\n\t\t\t\t\t\treturn promoted.modifiedCount === 1;\n\t\t\t\t\t}),\n\t\t\t\t'signingKeys',\n\t\t\t),\n\t};\n}\n",
23
+ "import type { SigningKeyStore } from '@softistx/janus-oauth';\nimport type { Document } from 'mongodb';\nimport { run } from '../translate';\nimport type { SigningKeysContext } from './context';\nimport { toPublicSigningKey, toSigningKey } from './records';\n\ntype ReadMethods = Pick<\n\tSigningKeyStore,\n\t'findKeys' | 'findCurrentKey' | 'findPublicKeys'\n>;\ntype Ctx = SigningKeysContext;\n\n/** The keys published at `now`, oldest first; `projection` leaves fields unread. */\nfunction published({ keys, partition }: Ctx, now: Date, projection?: Document) {\n\treturn keys\n\t\t.find(\n\t\t\t{\n\t\t\t\tpartition,\n\t\t\t\t$or: [\n\t\t\t\t\t{ status: { $in: ['current', 'next'] } },\n\t\t\t\t\t{ status: 'retired', publishUntil: { $gt: now } },\n\t\t\t\t],\n\t\t\t},\n\t\t\tprojection === undefined ? {} : { projection },\n\t\t)\n\t\t.sort({ createdAt: 1, kid: 1 })\n\t\t.toArray();\n}\n\nexport function readSigningKeys(ctx: Ctx): ReadMethods {\n\treturn {\n\t\tfindKeys: (now) =>\n\t\t\trun(\n\t\t\t\t'findKeys',\n\t\t\t\tasync () => {\n\t\t\t\t\tconst docs = await published(ctx, now);\n\t\t\t\t\treturn Promise.all(docs.map((doc) => toSigningKey(doc, ctx.sealer)));\n\t\t\t\t},\n\t\t\t\t'signingKeys',\n\t\t\t),\n\t\t// One read, one decryption: the other keys' `sealed` is never touched.\n\t\tfindCurrentKey: () =>\n\t\t\trun(\n\t\t\t\t'findCurrentKey',\n\t\t\t\tasync () => {\n\t\t\t\t\tconst doc = await ctx.keys.findOne({\n\t\t\t\t\t\tpartition: ctx.partition,\n\t\t\t\t\t\tstatus: 'current',\n\t\t\t\t\t});\n\t\t\t\t\treturn doc === null ? null : toSigningKey(doc, ctx.sealer);\n\t\t\t\t},\n\t\t\t\t'signingKeys',\n\t\t\t),\n\t\t// Never reads `sealed`, so nothing is decrypted.\n\t\tfindPublicKeys: (now) =>\n\t\t\trun(\n\t\t\t\t'findPublicKeys',\n\t\t\t\tasync () => {\n\t\t\t\t\tconst docs = await published(ctx, now, { sealed: 0 });\n\t\t\t\t\treturn docs.map((doc) => toPublicSigningKey(doc));\n\t\t\t\t},\n\t\t\t\t'signingKeys',\n\t\t\t),\n\t};\n}\n",
24
+ "import type { PrivateJwk } from '@softistx/janus-oauth';\n\n/** A private JWK, encrypted: base64url `iv` and `data` (ciphertext followed by the GCM tag). */\nexport interface Sealed {\n\treadonly iv: string;\n\treadonly data: string;\n}\n\nconst IV_BYTES = 12;\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nconst toBase64Url = (bytes: Uint8Array): string =>\n\tBuffer.from(bytes).toString('base64url');\nconst fromBase64Url = (text: string): Uint8Array<ArrayBuffer> => {\n\tconst buffer = Buffer.from(text, 'base64url');\n\treturn new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n};\n\n/** Encrypts and decrypts private JWKs with an AES-256-GCM keyring: `seal` uses the first key, `open` tries them in order. The record's partition and `kid` are the additional data, so a ciphertext moved to another record does not open. */\nexport interface Sealer {\n\tseal(jwk: PrivateJwk, partition: string, kid: string): Promise<Sealed>;\n\topen(sealed: Sealed, partition: string, kid: string): Promise<PrivateJwk>;\n\t/** Like `open`, and says which key (its index in the keyring) opened the record. */\n\topenWith(\n\t\tsealed: Sealed,\n\t\tpartition: string,\n\t\tkid: string,\n\t): Promise<{ readonly jwk: PrivateJwk; readonly index: number }>;\n}\n\n/** `keys` is a validated keyring (see `keyring.ts`); the buffers are copied, so the caller zeroing its own later does not break the store. */\nexport function createSealer(keys: readonly Uint8Array[]): Sealer {\n\tconst raws = keys.map((key) => new Uint8Array(key));\n\tconst imported: (Promise<CryptoKey> | undefined)[] = raws.map(\n\t\t() => undefined,\n\t);\n\tconst key = (index: number): Promise<CryptoKey> => {\n\t\timported[index] ??= crypto.subtle\n\t\t\t.importKey(\n\t\t\t\t'raw',\n\t\t\t\traws[index] as Uint8Array<ArrayBuffer>,\n\t\t\t\t'AES-GCM',\n\t\t\t\tfalse,\n\t\t\t\t['encrypt', 'decrypt'],\n\t\t\t)\n\t\t\t.catch((error) => {\n\t\t\t\timported[index] = undefined;\n\t\t\t\tthrow error;\n\t\t\t});\n\t\treturn imported[index] as Promise<CryptoKey>;\n\t};\n\tconst aad = (partition: string, kid: string) =>\n\t\tencoder.encode(JSON.stringify([partition, kid]));\n\n\tconst openWith: Sealer['openWith'] = async (sealed, partition, kid) => {\n\t\tconst params = {\n\t\t\tname: 'AES-GCM',\n\t\t\tiv: fromBase64Url(sealed.iv),\n\t\t\tadditionalData: aad(partition, kid),\n\t\t};\n\t\tconst data = fromBase64Url(sealed.data);\n\t\tlet last: unknown;\n\t\tfor (let index = 0; index < raws.length; index++) {\n\t\t\tconst cryptoKey = await key(index);\n\t\t\tlet plain: ArrayBuffer;\n\t\t\ttry {\n\t\t\t\tplain = await crypto.subtle.decrypt(params, cryptoKey, data);\n\t\t\t} catch (error) {\n\t\t\t\t// An authentication failure: this is not the key that sealed it.\n\t\t\t\t// Anything else (a bad IV, a runtime fault) is not a reason to try on.\n\t\t\t\tif (!(error instanceof DOMException && error.name === 'OperationError'))\n\t\t\t\t\tthrow error;\n\t\t\t\tlast = error;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tjwk: JSON.parse(decoder.decode(plain)) as PrivateJwk,\n\t\t\t\tindex,\n\t\t\t};\n\t\t}\n\t\tthrow last;\n\t};\n\n\treturn {\n\t\tasync seal(jwk, partition, kid) {\n\t\t\tconst iv = crypto.getRandomValues(new Uint8Array(IV_BYTES));\n\t\t\tconst data = await crypto.subtle.encrypt(\n\t\t\t\t{ name: 'AES-GCM', iv, additionalData: aad(partition, kid) },\n\t\t\t\tawait key(0),\n\t\t\t\tencoder.encode(JSON.stringify(jwk)),\n\t\t\t);\n\t\t\treturn { iv: toBase64Url(iv), data: toBase64Url(new Uint8Array(data)) };\n\t\t},\n\t\tasync open(sealed, partition, kid) {\n\t\t\treturn (await openWith(sealed, partition, kid)).jwk;\n\t\t},\n\t\topenWith,\n\t};\n}\n",
25
+ "import type { SigningKeyStore } from '@softistx/janus-oauth';\nimport { duplicateOf, run } from '../translate';\nimport type { SigningKeysContext } from './context';\nimport { documentId, toSigningKeyDocument } from './records';\n\ntype WriteMethods = Pick<SigningKeyStore, 'insertKey' | 'retire'>;\ntype Ctx = SigningKeysContext;\n\nexport function writeSigningKeys({\n\tkeys,\n\tpartition,\n\tsealer,\n}: Ctx): WriteMethods {\n\treturn {\n\t\tinsertKey: (key) =>\n\t\t\trun(\n\t\t\t\t'insertKey',\n\t\t\t\tasync () => {\n\t\t\t\t\tconst doc = await toSigningKeyDocument(key, partition, sealer);\n\t\t\t\t\tconst duplicate = await duplicateOf(keys.insertOne(doc));\n\t\t\t\t\t// Either index: the kid is held (a retry), or the status is.\n\t\t\t\t\treturn duplicate === null;\n\t\t\t\t},\n\t\t\t\t'signingKeys',\n\t\t\t),\n\n\t\tretire: (kid, at, publishUntil) =>\n\t\t\trun(\n\t\t\t\t'retire',\n\t\t\t\tasync () => {\n\t\t\t\t\tconst result = await keys.updateOne(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_id: documentId(partition, kid),\n\t\t\t\t\t\t\tstatus: { $in: ['current', 'next'] },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\tstatus: 'retired',\n\t\t\t\t\t\t\t\tslot: null,\n\t\t\t\t\t\t\t\tretiredAt: new Date(at.getTime()),\n\t\t\t\t\t\t\t\tpublishUntil: new Date(publishUntil.getTime()),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\treturn result.modifiedCount === 1;\n\t\t\t\t},\n\t\t\t\t'signingKeys',\n\t\t\t),\n\t};\n}\n",
26
+ "import type { Db } from 'mongodb';\nimport { run } from '../translate';\nimport {\n\ttype MongoSigningKeysOptions,\n\tparseSigningKeysArguments,\n} from './options';\nimport { createSealer } from './seal';\n\n/** What `resealMongoSigningKeys` did: the records moved to the first key, the ones already under it, and the ones skipped because someone changed them meanwhile (run again). */\nexport interface MongoSigningKeysResealed {\n\treadonly resealed: number;\n\treadonly current: number;\n\treadonly skipped: number;\n}\n\n/**\n * Re-encrypts the partition's stored private keys under the first key of\n * `encryptionKey`, the step between deploying `[newKey, oldKey]` and dropping\n * `oldKey`. Every record is read, published or not; one already under the\n * first key is left alone, and one under a later key is rewritten with a\n * compare-and-set on its old ciphertext, so a concurrent writer is never\n * overwritten (counted as `skipped`: run again until `resealed` and `skipped` are 0). Idempotent: the second run answers\n * `resealed: 0`. A record no key opens rejects with `StoreFailure`: the\n * run stops there, the records before it stay resealed and the ones after it\n * are left for the next run.\n *\n * ```ts\n * await resealMongoSigningKeys(db, { encryptionKey: [newKey, oldKey] });\n * ```\n */\nexport async function resealMongoSigningKeys(\n\tdb: Db,\n\toptions: MongoSigningKeysOptions,\n): Promise<MongoSigningKeysResealed> {\n\tconst { keyring, partition, keys } = parseSigningKeysArguments(\n\t\tdb,\n\t\toptions,\n\t\t'resealMongoSigningKeys',\n\t);\n\tconst sealer = createSealer(keyring);\n\treturn run(\n\t\t'reseal',\n\t\tasync () => {\n\t\t\tlet resealed = 0;\n\t\t\tlet current = 0;\n\t\t\tlet skipped = 0;\n\t\t\tfor (const doc of await keys.find({ partition }).toArray()) {\n\t\t\t\tconst { jwk, index } = await sealer.openWith(\n\t\t\t\t\tdoc.sealed,\n\t\t\t\t\tdoc.partition,\n\t\t\t\t\tdoc.kid,\n\t\t\t\t);\n\t\t\t\tif (index === 0) {\n\t\t\t\t\tcurrent++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst sealed = await sealer.seal(jwk, doc.partition, doc.kid);\n\t\t\t\tconst result = await keys.updateOne(\n\t\t\t\t\t{\n\t\t\t\t\t\t_id: doc._id,\n\t\t\t\t\t\t'sealed.iv': doc.sealed.iv,\n\t\t\t\t\t\t'sealed.data': doc.sealed.data,\n\t\t\t\t\t},\n\t\t\t\t\t{ $set: { sealed } },\n\t\t\t\t);\n\t\t\t\tif (result.modifiedCount === 1) resealed++;\n\t\t\t\telse skipped++;\n\t\t\t}\n\t\t\treturn { resealed, current, skipped };\n\t\t},\n\t\t'signingKeys',\n\t);\n}\n",
27
+ "import type { SigningKeyStore } from '@softistx/janus-oauth';\nimport type { Db } from 'mongodb';\nimport type { SigningKeysContext } from './context';\nimport {\n\ttype MongoSigningKeysOptions,\n\tparseSigningKeysArguments,\n} from './options';\nimport { promoteSigningKey } from './promote';\nimport { readSigningKeys } from './read';\nimport { createSealer } from './seal';\nimport { writeSigningKeys } from './write';\n\n/**\n * The `SigningKeyStore` of `@softistx/janus-oauth` over one MongoDB database,\n * the private JWKs encrypted at rest with AES-256-GCM (WebCrypto, a fresh\n * random 12-byte IV per record, the partition and `kid` as additional data).\n *\n * ```ts\n * const keys = createMongoSigningKeys(db, { encryptionKey }); // 32 bytes\n * const oauth = createOAuthServer({ auth, store, accessTokens: { format: 'jwt', keys }, ... });\n * ```\n *\n * `encryptionKey` may be a list for rotating the master key: the first key\n * seals, any opens. A key sealed under another master key fails to decrypt: `findKeys` throws\n * `StoreFailure`, never an empty list. `promote` runs in a transaction (a\n * replica set), like `rotateRefreshToken`.\n */\nexport function createMongoSigningKeys(\n\tdb: Db,\n\toptions: MongoSigningKeysOptions,\n): SigningKeyStore {\n\tconst { keyring, partition, keys } = parseSigningKeysArguments(\n\t\tdb,\n\t\toptions,\n\t\t'createMongoSigningKeys',\n\t);\n\tconst sealer = createSealer(keyring);\n\tconst ctx: SigningKeysContext = { db, keys, partition, sealer };\n\treturn {\n\t\t...readSigningKeys(ctx),\n\t\t...writeSigningKeys(ctx),\n\t\t...promoteSigningKey(ctx),\n\t};\n}\n\nexport type { MongoSigningKeysOptions } from './options';\nexport {\n\ttype MongoSigningKeysResealed,\n\tresealMongoSigningKeys,\n} from './reseal';\n",
28
+ "import { type OAuthStore, oauthPageLimit } from '@softistx/janus-oauth';\nimport { toClient, toClientDocument } from '../records';\nimport { run } from '../translate';\nimport type { StoreContext } from './context';\nimport { decode, encode, keyOf, where } from './scope';\n\ntype ClientMethods = Required<\n\tPick<\n\t\tOAuthStore,\n\t\t'upsertClient' | 'findClient' | 'deleteClient' | 'listClients'\n\t>\n>;\n\n/** The registered clients. */\nexport function clientStore({\n\tcollections,\n\tpartition,\n}: StoreContext): ClientMethods {\n\tconst { clients } = collections;\n\treturn {\n\t\tupsertClient: (client) =>\n\t\t\trun('upsertClient', async () => {\n\t\t\t\tawait clients.replaceOne(\n\t\t\t\t\t{ _id: keyOf(partition, client.id) },\n\t\t\t\t\tencode(partition, toClientDocument(client)),\n\t\t\t\t\t{ upsert: true },\n\t\t\t\t);\n\t\t\t}),\n\n\t\tfindClient: (id) =>\n\t\t\trun('findClient', async () => {\n\t\t\t\tconst found = await clients.findOne({ _id: keyOf(partition, id) });\n\t\t\t\treturn found === null ? null : toClient(decode(partition, found));\n\t\t\t}),\n\n\t\tlistClients: (options) =>\n\t\t\trun('listClients', async () => {\n\t\t\t\tconst limit = oauthPageLimit(options);\n\t\t\t\tconst cursor = options?.cursor;\n\t\t\t\tconst found = await clients\n\t\t\t\t\t.find({\n\t\t\t\t\t\t...where(partition),\n\t\t\t\t\t\t...(cursor === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: { _id: { $gt: keyOf(partition, cursor) } }),\n\t\t\t\t\t})\n\t\t\t\t\t.sort({ _id: 1 })\n\t\t\t\t\t.limit(limit + 1)\n\t\t\t\t\t.toArray();\n\t\t\t\tconst page = found\n\t\t\t\t\t.slice(0, limit)\n\t\t\t\t\t.map((document) => toClient(decode(partition, document)));\n\t\t\t\tconst last = page.at(-1);\n\t\t\t\treturn {\n\t\t\t\t\titems: page,\n\t\t\t\t\tnextCursor: found.length > limit && last ? last.id : null,\n\t\t\t\t};\n\t\t\t}),\n\n\t\tdeleteClient: (id) =>\n\t\t\trun('deleteClient', async () => {\n\t\t\t\tconst result = await clients.deleteOne({ _id: keyOf(partition, id) });\n\t\t\t\treturn result.deletedCount === 1;\n\t\t\t}),\n\t};\n}\n",
29
+ "// Field copies every record mapper shares: dates and lists are copied in both directions, so neither side can reach the other's.\n\nexport const date = (value: Date): Date => new Date(value.getTime());\nexport const dateOrNull = (value: Date | null): Date | null =>\n\tvalue === null ? null : date(value);\n\n/** The OpenID fields a record or a document has, only those: an absent key stays absent. */\nexport const openId = (r: {\n\treadonly nonce?: string | undefined;\n\treadonly authTime?: Date | undefined;\n\treadonly amr?: readonly string[] | undefined;\n\treadonly acr?: string | undefined;\n}) => ({\n\t...(r.nonce === undefined ? {} : { nonce: r.nonce }),\n\t...(r.authTime === undefined ? {} : { authTime: date(r.authTime) }),\n\t...(r.amr === undefined ? {} : { amr: [...r.amr] }),\n\t...(r.acr === undefined ? {} : { acr: r.acr }),\n});\n\n/** What the request's authentication parameters left (a copy), only those it has: an absent key stays absent. */\nexport const authenticationHints = (r: {\n\treadonly acrValues?: readonly string[] | undefined;\n\treadonly maxAge?: number | undefined;\n\treadonly prompt?: readonly string[] | undefined;\n\treadonly loginHint?: string | undefined;\n}) => ({\n\t...(r.acrValues === undefined ? {} : { acrValues: [...r.acrValues] }),\n\t...(r.maxAge === undefined ? {} : { maxAge: r.maxAge }),\n\t...(r.prompt === undefined ? {} : { prompt: [...r.prompt] }),\n\t...(r.loginHint === undefined ? {} : { loginHint: r.loginHint }),\n});\n\n/** The DPoP key thumbprint of a token, only when it has one. */\nexport const jkt = (r: { readonly jkt?: string | undefined }) =>\n\tr.jkt === undefined ? {} : { jkt: r.jkt };\n\n/** The DPoP key thumbprint a request or a code carries, only when it has one. */\nexport const dpopJkt = (r: { readonly dpopJkt?: string | undefined }) =>\n\tr.dpopJkt === undefined ? {} : { dpopJkt: r.dpopJkt };\n\n/** The actor of a delegated access token (a copy), only when it has one. */\nexport const actor = (r: {\n\treadonly actor?:\n\t\t| { readonly sub: string; readonly clientId?: string | undefined }\n\t\t| undefined;\n}) =>\n\tr.actor === undefined\n\t\t? {}\n\t\t: {\n\t\t\t\tactor: {\n\t\t\t\t\tsub: r.actor.sub,\n\t\t\t\t\t...(r.actor.clientId === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { clientId: r.actor.clientId }),\n\t\t\t\t},\n\t\t\t};\n",
30
+ "import type {\n\tOAuthClientGrantType,\n\tOAuthClientRecord,\n} from '@softistx/janus-oauth';\nimport type { DocumentOf } from '@softistx/mongo';\nimport type { oauthClients } from '../collections';\nimport { date, dateOrNull } from '../record-fields';\n\n// copied in both directions, so neither side can reach the other's.\n\n/** The client's authentication fields, only those it has. */\nconst clientAuth = (r: {\n\treadonly tokenEndpointAuthMethod?: 'none' | 'client_secret_basic' | undefined;\n\treadonly secretHash?: string | undefined;\n}) => ({\n\t...(r.tokenEndpointAuthMethod === undefined\n\t\t? {}\n\t\t: { tokenEndpointAuthMethod: r.tokenEndpointAuthMethod }),\n\t...(r.secretHash === undefined ? {} : { secretHash: r.secretHash }),\n});\n\n/** The grant types a client has, only when it has them. */\nconst grantTypes = (r: {\n\treadonly grantTypes?: readonly OAuthClientGrantType[] | undefined;\n}) => (r.grantTypes === undefined ? {} : { grantTypes: [...r.grantTypes] });\n\n/** The pushed-request flag of a client, only when it has one (`false` stays `false`). */\nconst requirePar = (r: {\n\treadonly requirePushedAuthorizationRequests?: boolean | undefined;\n}) =>\n\tr.requirePushedAuthorizationRequests === undefined\n\t\t? {}\n\t\t: {\n\t\t\t\trequirePushedAuthorizationRequests:\n\t\t\t\t\tr.requirePushedAuthorizationRequests,\n\t\t\t};\n\n/** The DPoP flag of a client, only when it has one (`false` stays `false`). */\nconst dpopBound = (r: {\n\treadonly dpopBoundAccessTokens?: boolean | undefined;\n}) =>\n\tr.dpopBoundAccessTokens === undefined\n\t\t? {}\n\t\t: { dpopBoundAccessTokens: r.dpopBoundAccessTokens };\n\n/** The authorization details types a client has, only when it has them (an empty list stays empty). */\nconst detailsTypes = (r: {\n\treadonly authorizationDetailsTypes?: readonly string[] | undefined;\n}) =>\n\tr.authorizationDetailsTypes === undefined\n\t\t? {}\n\t\t: { authorizationDetailsTypes: [...r.authorizationDetailsTypes] };\n\nexport type ClientDocument = DocumentOf<typeof oauthClients>;\n\nexport const toClientDocument = (r: OAuthClientRecord): ClientDocument => ({\n\t_id: r.id,\n\tname: r.name,\n\tredirectUris: [...r.redirectUris],\n\tsource: r.source,\n\tcreatedAt: date(r.createdAt),\n\texpiresAt: dateOrNull(r.expiresAt),\n\t...clientAuth(r),\n\t...grantTypes(r),\n\t...requirePar(r),\n\t...dpopBound(r),\n\t...detailsTypes(r),\n});\n\nexport const toClient = (d: ClientDocument): OAuthClientRecord => ({\n\tid: d._id,\n\tname: d.name,\n\tredirectUris: [...d.redirectUris],\n\tsource: d.source,\n\tcreatedAt: date(d.createdAt),\n\texpiresAt: dateOrNull(d.expiresAt),\n\t...clientAuth(d),\n\t...grantTypes(d),\n\t...requirePar(d),\n\t...dpopBound(d),\n\t...detailsTypes(d),\n});\n",
31
+ "// The authorization details of a record, in and out of their stored form: one canonical JSON string (see `authorizationDetails` in collection-fields.ts).\n\nimport type { OAuthAuthorizationDetail } from '@softistx/janus-oauth';\nimport { canonicalAuthorizationDetails } from '@softistx/janus-oauth';\n\ntype Details = readonly OAuthAuthorizationDetail[];\n\n/** The document member of a record's details, only when it has some: an absent field stays absent. */\nexport const detailsToDocument = (r: {\n\treadonly authorizationDetails?: Details | undefined;\n}) =>\n\tr.authorizationDetails === undefined\n\t\t? {}\n\t\t: {\n\t\t\t\tauthorizationDetails: canonicalAuthorizationDetails(\n\t\t\t\t\tr.authorizationDetails,\n\t\t\t\t),\n\t\t\t};\n\n/**\n * The record member of a document's details, parsed again (a fresh copy, so a\n * caller cannot reach the store). A value that is not a JSON list of objects\n * is a `TypeError` naming the store, never the value: a store must not\n * answer details it cannot read as a broader grant.\n */\nexport const detailsFromDocument = (d: {\n\treadonly authorizationDetails?: string | undefined;\n}) => {\n\tif (d.authorizationDetails === undefined) return {};\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(d.authorizationDetails);\n\t} catch {\n\t\tthrow corrupt();\n\t}\n\tif (\n\t\t!Array.isArray(parsed) ||\n\t\t!parsed.every(\n\t\t\t(one) => typeof one === 'object' && one !== null && !Array.isArray(one),\n\t\t)\n\t) {\n\t\tthrow corrupt();\n\t}\n\treturn { authorizationDetails: parsed as OAuthAuthorizationDetail[] };\n};\n\nconst corrupt = () =>\n\tnew TypeError(\n\t\t'the Mongo OAuth store holds authorization details that are not a JSON list of objects',\n\t);\n",
32
+ "import type { Id } from '@softistx/janus';\nimport type { OAuthGrantRecord } from '@softistx/janus-oauth';\nimport type { DocumentOf } from '@softistx/mongo';\nimport type { oauthGrants } from '../collections';\nimport { detailsFromDocument, detailsToDocument } from '../details-field';\nimport { date, dateOrNull } from '../record-fields';\n\nexport type GrantDocument = DocumentOf<typeof oauthGrants>;\n\nexport const toGrantDocument = (r: OAuthGrantRecord): GrantDocument => ({\n\t_id: r.id,\n\tuserId: r.userId,\n\tclientId: r.clientId,\n\tresource: r.resource,\n\tscopes: [...r.scopes],\n\tcreatedAt: date(r.createdAt),\n\tupdatedAt: date(r.updatedAt),\n\trevokedAt: dateOrNull(r.revokedAt),\n\t...(r.bound === undefined\n\t\t? {}\n\t\t: { bound: { type: r.bound.type, id: r.bound.id } }),\n\t...detailsToDocument(r),\n});\n\nexport const toGrant = (d: GrantDocument): OAuthGrantRecord => ({\n\tid: d._id,\n\tuserId: d.userId as Id,\n\tclientId: d.clientId,\n\tresource: d.resource,\n\tscopes: [...d.scopes],\n\tcreatedAt: date(d.createdAt),\n\tupdatedAt: date(d.updatedAt),\n\trevokedAt: dateOrNull(d.revokedAt),\n\t...(d.bound === undefined\n\t\t? {}\n\t\t: { bound: { type: d.bound.type, id: d.bound.id } }),\n\t...detailsFromDocument(d),\n});\n",
33
+ "import type { Id } from '@softistx/janus';\nimport type {\n\tOAuthAuthorizationRequestRecord,\n\tOAuthCodeRecord,\n} from '@softistx/janus-oauth';\nimport type { DocumentOf } from '@softistx/mongo';\nimport type { oauthCodes, oauthRequests } from '../collections';\nimport { detailsFromDocument, detailsToDocument } from '../details-field';\nimport {\n\tauthenticationHints,\n\tdate,\n\tdateOrNull,\n\tdpopJkt,\n\topenId,\n} from '../record-fields';\n\nexport type RequestDocument = DocumentOf<typeof oauthRequests>;\nexport type CodeDocument = DocumentOf<typeof oauthCodes>;\n\nexport const toRequestDocument = (\n\tr: OAuthAuthorizationRequestRecord,\n): RequestDocument => ({\n\t_id: r.id,\n\tclientId: r.clientId,\n\tredirectUri: r.redirectUri,\n\tresource: r.resource,\n\tscopes: [...r.scopes],\n\tstate: r.state,\n\t...(r.nonce === undefined ? {} : { nonce: r.nonce }),\n\t...dpopJkt(r),\n\t...detailsToDocument(r),\n\t...authenticationHints(r),\n\tcodeChallenge: r.codeChallenge,\n\tcodeChallengeMethod: r.codeChallengeMethod,\n\tcreatedAt: date(r.createdAt),\n\texpiresAt: date(r.expiresAt),\n});\n\nexport const toRequest = (\n\td: RequestDocument,\n): OAuthAuthorizationRequestRecord => ({\n\tid: d._id,\n\tclientId: d.clientId,\n\tredirectUri: d.redirectUri,\n\tresource: d.resource,\n\tscopes: [...d.scopes],\n\tstate: d.state,\n\t...(d.nonce === undefined ? {} : { nonce: d.nonce }),\n\t...dpopJkt(d),\n\t...detailsFromDocument(d),\n\t...authenticationHints(d),\n\tcodeChallenge: d.codeChallenge,\n\tcodeChallengeMethod: d.codeChallengeMethod,\n\tcreatedAt: date(d.createdAt),\n\texpiresAt: date(d.expiresAt),\n});\n\nexport const toCodeDocument = (r: OAuthCodeRecord): CodeDocument => ({\n\t_id: r.codeHash,\n\tclientId: r.clientId,\n\tuserId: r.userId,\n\tgrantId: r.grantId,\n\tredirectUri: r.redirectUri,\n\tresource: r.resource,\n\tscopes: [...r.scopes],\n\tcodeChallenge: r.codeChallenge,\n\tcodeChallengeMethod: r.codeChallengeMethod,\n\tcreatedAt: date(r.createdAt),\n\texpiresAt: date(r.expiresAt),\n\tconsumedAt: dateOrNull(r.consumedAt),\n\t...dpopJkt(r),\n\t...detailsToDocument(r),\n\t...openId(r),\n});\n\nexport const toCode = (d: CodeDocument): OAuthCodeRecord => ({\n\tcodeHash: d._id,\n\tclientId: d.clientId,\n\tuserId: d.userId as Id,\n\tgrantId: d.grantId,\n\tredirectUri: d.redirectUri,\n\tresource: d.resource,\n\tscopes: [...d.scopes],\n\tcodeChallenge: d.codeChallenge,\n\tcodeChallengeMethod: d.codeChallengeMethod,\n\tcreatedAt: date(d.createdAt),\n\texpiresAt: date(d.expiresAt),\n\tconsumedAt: dateOrNull(d.consumedAt),\n\t...dpopJkt(d),\n\t...detailsFromDocument(d),\n\t...openId(d),\n});\n",
34
+ "import type { Id } from '@softistx/janus';\nimport type {\n\tOAuthAccessTokenRecord,\n\tOAuthRefreshTokenRecord,\n} from '@softistx/janus-oauth';\nimport type { DocumentOf } from '@softistx/mongo';\nimport type { oauthAccessTokens, oauthRefreshTokens } from '../collections';\nimport { detailsFromDocument, detailsToDocument } from '../details-field';\nimport { actor, date, dateOrNull, jkt, openId } from '../record-fields';\n\nexport type AccessDocument = DocumentOf<typeof oauthAccessTokens>;\nexport type RefreshDocument = DocumentOf<typeof oauthRefreshTokens>;\n\nexport const toAccessDocument = (\n\tr: OAuthAccessTokenRecord,\n): AccessDocument => ({\n\t_id: r.tokenHash,\n\tgrantId: r.grantId,\n\tuserId: r.userId,\n\tclientId: r.clientId,\n\tresource: r.resource,\n\tscopes: [...r.scopes],\n\tcreatedAt: date(r.createdAt),\n\texpiresAt: date(r.expiresAt),\n\trevokedAt: dateOrNull(r.revokedAt),\n\t...jkt(r),\n\t...actor(r),\n\t...detailsToDocument(r),\n\t...openId(r),\n});\n\nexport const toAccess = (d: AccessDocument): OAuthAccessTokenRecord => ({\n\ttokenHash: d._id,\n\tgrantId: d.grantId,\n\tuserId: d.userId as Id,\n\tclientId: d.clientId,\n\tresource: d.resource,\n\tscopes: [...d.scopes],\n\tcreatedAt: date(d.createdAt),\n\texpiresAt: date(d.expiresAt),\n\trevokedAt: dateOrNull(d.revokedAt),\n\t...jkt(d),\n\t...actor(d),\n\t...detailsFromDocument(d),\n\t...openId(d),\n});\n\nexport const toRefreshDocument = (\n\tr: OAuthRefreshTokenRecord,\n): RefreshDocument => ({\n\t_id: r.tokenHash,\n\tgrantId: r.grantId,\n\tuserId: r.userId,\n\tclientId: r.clientId,\n\tresource: r.resource,\n\tscopes: [...r.scopes],\n\tcreatedAt: date(r.createdAt),\n\texpiresAt: date(r.expiresAt),\n\tabsoluteExpiresAt: date(r.absoluteExpiresAt),\n\trotatedAt: dateOrNull(r.rotatedAt),\n\trevokedAt: dateOrNull(r.revokedAt),\n\t...jkt(r),\n\t...detailsToDocument(r),\n\t...openId(r),\n});\n\nexport const toRefresh = (d: RefreshDocument): OAuthRefreshTokenRecord => ({\n\ttokenHash: d._id,\n\tgrantId: d.grantId,\n\tuserId: d.userId as Id,\n\tclientId: d.clientId,\n\tresource: d.resource,\n\tscopes: [...d.scopes],\n\tcreatedAt: date(d.createdAt),\n\texpiresAt: date(d.expiresAt),\n\tabsoluteExpiresAt: date(d.absoluteExpiresAt),\n\trotatedAt: dateOrNull(d.rotatedAt),\n\trevokedAt: dateOrNull(d.revokedAt),\n\t...jkt(d),\n\t...detailsFromDocument(d),\n\t...openId(d),\n});\n",
35
+ "/**\n * How a partition shows in a document: its `_id`, its `partition` field and\n * the filters on any other field. Pure functions of the partition, which is\n * `null` for the default layout, where every one of them is the identity (the\n * storage is byte for byte what it was before partitions).\n */\n\nimport type { ClientDocument } from '../records';\n\nexport type Partition = string | null;\n\n/** Any of the six documents: they all have a string `_id`. */\ntype Keyed = Pick<ClientDocument, '_id'>;\n\n/** The `_id` to store or look up for the port's key. */\nexport function keyOf(partition: Partition, id: string): string {\n\treturn partition === null ? id : JSON.stringify([partition, id]);\n}\n\n/** The port's key behind a stored `_id`. */\nexport function plainOf(partition: Partition, stored: string): string {\n\tif (partition === null) return stored;\n\tconst parsed: unknown = JSON.parse(stored);\n\tif (\n\t\t!Array.isArray(parsed) ||\n\t\tparsed.length !== 2 ||\n\t\tparsed[0] !== partition ||\n\t\ttypeof parsed[1] !== 'string'\n\t) {\n\t\tthrow new Error('a stored _id does not belong to this partition');\n\t}\n\treturn parsed[1];\n}\n\n/** The document to write: keyed, and carrying its partition. */\nexport function encode<D extends Keyed>(partition: Partition, document: D): D {\n\tif (partition === null) return document;\n\treturn { ...document, _id: keyOf(partition, document._id), partition };\n}\n\n/** The document as the port's converters read it: its `_id` is the port's key. */\nexport function decode<D extends Keyed>(partition: Partition, document: D): D {\n\tif (partition === null) return document;\n\treturn { ...document, _id: plainOf(partition, document._id) };\n}\n\n/** What every filter on a field other than `_id` adds. */\nexport function where(partition: Partition): { partition?: string } {\n\treturn partition === null ? {} : { partition };\n}\n",
36
+ "import type { OAuthStore } from '@softistx/janus-oauth';\nimport { toCode, toCodeDocument } from '../records';\nimport { duplicateOf, onId, run, unexpectedDuplicate } from '../translate';\nimport type { StoreContext } from './context';\nimport { decode, encode, keyOf } from './scope';\n\ntype CodeMethods = Pick<OAuthStore, 'insertOAuthCode' | 'consumeOAuthCode'>;\n\n/** The authorization codes. */\nexport function codeStore({\n\tcollections,\n\tpartition,\n}: StoreContext): CodeMethods {\n\tconst { codes } = collections;\n\treturn {\n\t\tinsertOAuthCode: (code) =>\n\t\t\trun('insertOAuthCode', async () => {\n\t\t\t\tconst duplicate = await duplicateOf(\n\t\t\t\t\tcodes.insertOne(encode(partition, toCodeDocument(code))),\n\t\t\t\t);\n\t\t\t\tif (duplicate !== null && !onId(duplicate)) {\n\t\t\t\t\tthrow unexpectedDuplicate('insertOAuthCode', duplicate);\n\t\t\t\t}\n\t\t\t}),\n\n\t\tconsumeOAuthCode: (codeHash, now) =>\n\t\t\trun('consumeOAuthCode', async () => {\n\t\t\t\t// **One conditional write**, answering the document as it was\n\t\t\t\t// before: exactly one caller ever matches `consumedAt: null`.\n\t\t\t\tconst spent = await codes.findOneAndUpdate(\n\t\t\t\t\t{\n\t\t\t\t\t\t_id: keyOf(partition, codeHash),\n\t\t\t\t\t\tconsumedAt: null,\n\t\t\t\t\t\texpiresAt: { $gt: now },\n\t\t\t\t\t},\n\t\t\t\t\t{ $set: { consumedAt: new Date(now.getTime()) } },\n\t\t\t\t\t{ returnDocument: 'before' },\n\t\t\t\t);\n\t\t\t\tif (spent !== null)\n\t\t\t\t\treturn { status: 'consumed', code: toCode(decode(partition, spent)) };\n\n\t\t\t\t// Not matched: spent before (a replay, even a lapsed one),\n\t\t\t\t// lapsed unspent, or never there.\n\t\t\t\tconst found = await codes.findOne({ _id: keyOf(partition, codeHash) });\n\t\t\t\tif (found !== null && found.consumedAt !== null) {\n\t\t\t\t\treturn { status: 'replayed', code: toCode(decode(partition, found)) };\n\t\t\t\t}\n\t\t\t\treturn { status: 'absent' };\n\t\t\t}),\n\t};\n}\n",
37
+ "import { StoreFailure } from '@softistx/janus';\nimport {\n\tOAUTH_DEVICE_SLOW_DOWN_MS,\n\ttype OAuthDeviceDecision,\n\ttype OAuthDevicePoll,\n\ttype OAuthDevicePollExpectation,\n\ttype OAuthStore,\n} from '@softistx/janus-oauth';\nimport type { Filter } from 'mongodb';\nimport { detailsToDocument } from '../details-field';\nimport { toDevice, toDeviceDocument } from '../records-device';\nimport {\n\tduplicateOf,\n\tonDeviceCode,\n\trun,\n\tunexpectedDuplicate,\n} from '../translate';\nimport type { StoreContext } from './context';\nimport { decode, encode, keyOf, where } from './scope';\n\ntype DeviceMethods = Required<\n\tPick<\n\t\tOAuthStore,\n\t\t| 'insertDeviceAuthorization'\n\t\t| 'findDeviceAuthorization'\n\t\t| 'decideDeviceAuthorization'\n\t\t| 'pollDeviceAuthorization'\n\t>\n>;\n\ntype Document = Parameters<\n\tStoreContext['collections']['devices']['insertOne']\n>[0];\n\n/** A poll that lost a race with another poll of the same device code reads again; this many rounds, which only a hammering client ever uses up. */\nconst POLL_ROUNDS = 5;\n\n/** What a decision writes: its status, and for an approval the user, the grant, the scopes, the authorization details and the OpenID fields it carries. */\nfunction decisionFields(\n\tdecision: OAuthDeviceDecision,\n): Record<string, unknown> {\n\tif (decision.status === 'denied') return { status: 'denied' };\n\treturn {\n\t\tstatus: 'approved',\n\t\tuserId: decision.userId,\n\t\tgrantId: decision.grantId,\n\t\tscopes: [...decision.scopes],\n\t\t...(decision.authTime === undefined\n\t\t\t? {}\n\t\t\t: { authTime: new Date(decision.authTime.getTime()) }),\n\t\t...(decision.amr === undefined ? {} : { amr: [...decision.amr] }),\n\t\t...(decision.acr === undefined ? {} : { acr: decision.acr }),\n\t\t...detailsToDocument(decision),\n\t};\n}\n\n/**\n * Whether the record may be polled at `now`: never polled, or `intervalMs`\n * has passed since the last poll. The filter form of the memory store's\n * `tooFast`, decided by the server with the `now` the caller passes.\n */\nconst respected = (now: Date) => ({\n\t$expr: {\n\t\t$or: [\n\t\t\t{ $eq: ['$lastPolledAt', null] },\n\t\t\t{ $lte: [{ $add: ['$lastPolledAt', '$intervalMs'] }, now] },\n\t\t],\n\t},\n});\n\n/** What a poll that matched nothing answers from the record it reads back; `undefined` when the record is still open, so the poll lost a race and looks again. */\nfunction classify(\n\tpartition: StoreContext['partition'],\n\tfound: Document | null,\n\tnow: Date,\n): OAuthDevicePoll | undefined {\n\tif (found === null) return { status: 'absent' };\n\tif (found.consumedAt !== null) {\n\t\treturn {\n\t\t\tstatus: 'replayed',\n\t\t\tauthorization: toDevice(decode(partition, found)),\n\t\t};\n\t}\n\tif (found.expiresAt.getTime() <= now.getTime()) return { status: 'expired' };\n\tif (found.status === 'denied') return { status: 'denied' };\n\treturn undefined;\n}\n\n/**\n * One poll, in the order of the port. Each step is **one conditional write**\n * on one document, so of concurrent polls exactly one wins each transition;\n * a poll that matched nothing reads the record to say why.\n */\nasync function poll(\n\t{ collections, partition }: StoreContext,\n\tdeviceCodeHash: string,\n\tnow: Date,\n\texpect: OAuthDevicePollExpectation,\n): Promise<OAuthDevicePoll> {\n\tconst { devices } = collections;\n\t// A foreign client or resource never matches any filter below, and the\n\t// read-back answers `absent` for it: nothing is written.\n\tconst mine: Filter<Document> = {\n\t\t_id: keyOf(partition, deviceCodeHash),\n\t\tclientId: expect.clientId,\n\t\t...(expect.resource === null ? {} : { resource: expect.resource }),\n\t};\n\tconst live = { ...mine, consumedAt: null, expiresAt: { $gt: now } };\n\tconst stamp = new Date(now.getTime());\n\n\tfor (let round = 0; round < POLL_ROUNDS; round += 1) {\n\t\tconst approved = await devices.findOneAndUpdate(\n\t\t\t{ ...live, status: 'approved', ...respected(now) },\n\t\t\t{ $set: { consumedAt: stamp, lastPolledAt: stamp } },\n\t\t\t{ returnDocument: 'before' },\n\t\t);\n\t\tif (approved !== null) {\n\t\t\treturn {\n\t\t\t\tstatus: 'approved',\n\t\t\t\tauthorization: toDevice(decode(partition, approved)),\n\t\t\t};\n\t\t}\n\t\tconst pending = await devices.findOneAndUpdate(\n\t\t\t{ ...live, status: 'pending', ...respected(now) },\n\t\t\t{ $set: { lastPolledAt: stamp } },\n\t\t\t{ projection: { _id: 1 } },\n\t\t);\n\t\tif (pending !== null) return { status: 'pending' };\n\n\t\t// Too fast, still open: +5 s on the stored interval, and the poll counts.\n\t\tconst slowed = await devices.findOneAndUpdate(\n\t\t\t{\n\t\t\t\t...live,\n\t\t\t\tstatus: { $in: ['pending', 'approved'] },\n\t\t\t\t$nor: [respected(now)],\n\t\t\t},\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tintervalMs: { $add: ['$intervalMs', OAUTH_DEVICE_SLOW_DOWN_MS] },\n\t\t\t\t\t\tlastPolledAt: stamp,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\t{ returnDocument: 'after' },\n\t\t);\n\t\tif (slowed !== null) {\n\t\t\treturn { status: 'slow_down', intervalMs: slowed.intervalMs };\n\t\t}\n\n\t\t// Nothing matched: it is handed over, lapsed, denied, not this poller's or not there.\n\t\tconst verdict = classify(partition, await devices.findOne(mine), now);\n\t\tif (verdict !== undefined) return verdict;\n\t\t// Still open: another poll changed it between our writes; look again.\n\t}\n\tthrow new StoreFailure(\n\t\t'oauthStore.pollDeviceAuthorization: the store could not answer',\n\t\t{\n\t\t\toperation: 'pollDeviceAuthorization',\n\t\t\tcause: new Error(\n\t\t\t\t`the poll kept losing to concurrent polls of the same device code, ${POLL_ROUNDS} rounds`,\n\t\t\t),\n\t\t},\n\t);\n}\n\n/** The device authorizations (RFC 8628): one document per request, keyed by the device code's hash. */\nexport function deviceStore(context: StoreContext): DeviceMethods {\n\tconst { collections, partition } = context;\n\tconst { devices } = collections;\n\treturn {\n\t\tinsertDeviceAuthorization: (authorization) =>\n\t\t\trun('insertDeviceAuthorization', async () => {\n\t\t\t\tconst duplicate = await duplicateOf(\n\t\t\t\t\tdevices.insertOne(encode(partition, toDeviceDocument(authorization))),\n\t\t\t\t);\n\t\t\t\tif (duplicate === null) return true;\n\t\t\t\t// Either unique key held: the port answers `false` and writes nothing.\n\t\t\t\tif (onDeviceCode(duplicate)) return false;\n\t\t\t\tthrow unexpectedDuplicate('insertDeviceAuthorization', duplicate);\n\t\t\t}),\n\n\t\tfindDeviceAuthorization: (userCodeHash) =>\n\t\t\trun('findDeviceAuthorization', async () => {\n\t\t\t\tconst found = await devices.findOne({\n\t\t\t\t\t...where(partition),\n\t\t\t\t\tuserCodeHash,\n\t\t\t\t});\n\t\t\t\treturn found === null ? null : toDevice(decode(partition, found));\n\t\t\t}),\n\n\t\tdecideDeviceAuthorization: (userCodeHash, decision, now) =>\n\t\t\trun('decideDeviceAuthorization', async () => {\n\t\t\t\t// **One conditional write**: of concurrent decisions, one matches `pending`.\n\t\t\t\tconst decided = await devices.findOneAndUpdate(\n\t\t\t\t\t{\n\t\t\t\t\t\t...where(partition),\n\t\t\t\t\t\tuserCodeHash,\n\t\t\t\t\t\tstatus: 'pending',\n\t\t\t\t\t\texpiresAt: { $gt: now },\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$set: decisionFields(decision),\n\t\t\t\t\t\t// An approval carrying no details removes the asked ones.\n\t\t\t\t\t\t...(decision.status === 'approved' &&\n\t\t\t\t\t\tdecision.authorizationDetails === undefined\n\t\t\t\t\t\t\t? { $unset: { authorizationDetails: '' as const } }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t},\n\t\t\t\t\t{ returnDocument: 'after' },\n\t\t\t\t);\n\t\t\t\treturn decided === null ? null : toDevice(decode(partition, decided));\n\t\t\t}),\n\n\t\tpollDeviceAuthorization: (deviceCodeHash, now, expect) =>\n\t\t\trun('pollDeviceAuthorization', () =>\n\t\t\t\tpoll(context, deviceCodeHash, now, expect),\n\t\t\t),\n\t};\n}\n",
38
+ "import type { Id } from '@softistx/janus';\nimport type { OAuthDeviceAuthorizationRecord } from '@softistx/janus-oauth';\nimport type { DocumentOf } from '@softistx/mongo';\nimport { detailsFromDocument, detailsToDocument } from './details-field';\nimport type { oauthDeviceAuthorizations } from './device-collection';\nimport { date, dateOrNull, openId } from './record-fields';\n\nexport type DeviceDocument = DocumentOf<typeof oauthDeviceAuthorizations>;\n\nexport const toDeviceDocument = (\n\tr: OAuthDeviceAuthorizationRecord,\n): DeviceDocument => ({\n\t_id: r.deviceCodeHash,\n\tuserCodeHash: r.userCodeHash,\n\tclientId: r.clientId,\n\tresource: r.resource,\n\tscopes: [...r.scopes],\n\tintervalMs: r.intervalMs,\n\tlastPolledAt: dateOrNull(r.lastPolledAt),\n\tstatus: r.status,\n\t...(r.userId === undefined ? {} : { userId: r.userId }),\n\t...(r.grantId === undefined ? {} : { grantId: r.grantId }),\n\tcreatedAt: date(r.createdAt),\n\texpiresAt: date(r.expiresAt),\n\tconsumedAt: dateOrNull(r.consumedAt),\n\t...detailsToDocument(r),\n\t...openId(r),\n});\n\nexport const toDevice = (\n\td: DeviceDocument,\n): OAuthDeviceAuthorizationRecord => ({\n\tdeviceCodeHash: d._id,\n\tuserCodeHash: d.userCodeHash,\n\tclientId: d.clientId,\n\tresource: d.resource,\n\tscopes: [...d.scopes],\n\tintervalMs: d.intervalMs,\n\tlastPolledAt: dateOrNull(d.lastPolledAt),\n\tstatus: d.status,\n\t...(d.userId === undefined ? {} : { userId: d.userId as Id }),\n\t...(d.grantId === undefined ? {} : { grantId: d.grantId }),\n\tcreatedAt: date(d.createdAt),\n\texpiresAt: date(d.expiresAt),\n\tconsumedAt: dateOrNull(d.consumedAt),\n\t...detailsFromDocument(d),\n\t...openId(d),\n});\n",
39
+ "import {\n\ttype OAuthGrantRecord,\n\ttype OAuthPage,\n\ttype OAuthPageOptions,\n\ttype OAuthStore,\n\toauthPageLimit,\n} from '@softistx/janus-oauth';\nimport { toGrant } from '../records';\nimport { run } from '../translate';\nimport type { StoreContext } from './context';\nimport { decode, keyOf, where } from './scope';\n\ntype GrantReads = Required<\n\tPick<\n\t\tOAuthStore,\n\t\t| 'findGrant'\n\t\t| 'findUserGrant'\n\t\t| 'listUserGrants'\n\t\t| 'listClientGrants'\n\t\t| 'listBoundGrants'\n\t>\n>;\n\n/** One page of the grants matching `filter`, in `_id` order. */\nasync function pageOf(\n\t{ collections, partition }: StoreContext,\n\tfilter: Record<string, string>,\n\toptions: OAuthPageOptions | undefined,\n): Promise<OAuthPage<OAuthGrantRecord>> {\n\tconst limit = oauthPageLimit(options);\n\tconst cursor = options?.cursor;\n\tconst found = await collections.grants\n\t\t.find({\n\t\t\t...where(partition),\n\t\t\t...filter,\n\t\t\t...(cursor === undefined\n\t\t\t\t? {}\n\t\t\t\t: { _id: { $gt: keyOf(partition, cursor) } }),\n\t\t})\n\t\t.sort({ _id: 1 })\n\t\t.limit(limit + 1)\n\t\t.toArray();\n\tconst page = found\n\t\t.slice(0, limit)\n\t\t.map((document) => toGrant(decode(partition, document)));\n\tconst last = page.at(-1);\n\treturn {\n\t\titems: page,\n\t\tnextCursor: found.length > limit && last ? last.id : null,\n\t};\n}\n\n/** The grant reads: one grant, a user's, and the pages of a client's or an object's. */\nexport function grantReads(ctx: StoreContext): GrantReads {\n\tconst { grants } = ctx.collections;\n\tconst { partition } = ctx;\n\treturn {\n\t\tfindGrant: (id) =>\n\t\t\trun('findGrant', async () => {\n\t\t\t\tconst found = await grants.findOne({ _id: keyOf(partition, id) });\n\t\t\t\treturn found === null ? null : toGrant(decode(partition, found));\n\t\t\t}),\n\t\tfindUserGrant: (userId, clientId, resource) =>\n\t\t\trun('findUserGrant', async () => {\n\t\t\t\tconst found = await grants.findOne({\n\t\t\t\t\t...where(partition),\n\t\t\t\t\tuserId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tresource,\n\t\t\t\t});\n\t\t\t\treturn found === null ? null : toGrant(decode(partition, found));\n\t\t\t}),\n\t\tlistUserGrants: (userId) =>\n\t\t\trun('listUserGrants', async () => {\n\t\t\t\tconst found = await grants\n\t\t\t\t\t.find({ ...where(partition), userId })\n\t\t\t\t\t.sort({ _id: 1 })\n\t\t\t\t\t.toArray();\n\t\t\t\treturn found.map((document) => toGrant(decode(partition, document)));\n\t\t\t}),\n\t\tlistClientGrants: (clientId, options) =>\n\t\t\trun('listClientGrants', () => pageOf(ctx, { clientId }, options)),\n\t\tlistBoundGrants: (bound, options) =>\n\t\t\trun('listBoundGrants', () =>\n\t\t\t\tpageOf(\n\t\t\t\t\tctx,\n\t\t\t\t\t{ 'bound.type': bound.type, 'bound.id': bound.id },\n\t\t\t\t\toptions,\n\t\t\t\t),\n\t\t\t),\n\t};\n}\n",
40
+ "import type { StoreContext } from './context';\nimport { where } from './scope';\n\n/** Which approvals a revoke spends: a grant's, a user's, a client's or a resource's. */\nexport type SpendScope =\n\t| { readonly grantId: string }\n\t| { readonly userId: string }\n\t| { readonly clientId: string }\n\t| { readonly resource: string | Readonly<Record<'$ne', string>> };\n\n/**\n * Spends the approved, unconsumed device authorizations a revoke covers, at\n * `at`: `status: 'denied'` with `consumedAt` left null, so a later poll\n * answers `denied` (`access_denied`) and revokes nothing. A pending record has\n * no grant yet; a handed-over one is a replay and stays one. `spare` is the\n * `userCodeHash` of the approval that is being given right now.\n */\nexport async function spendDevices(\n\t{ collections, partition }: StoreContext,\n\tscope: SpendScope,\n\tspare?: string,\n): Promise<void> {\n\tawait collections.devices.updateMany(\n\t\t{\n\t\t\t...where(partition),\n\t\t\t...scope,\n\t\t\tstatus: 'approved',\n\t\t\tconsumedAt: null,\n\t\t\t...(spare === undefined ? {} : { userCodeHash: { $ne: spare } }),\n\t\t},\n\t\t{ $set: { status: 'denied' } },\n\t);\n}\n",
41
+ "import type {\n\tOAuthGrantRecord,\n\tOAuthResourceRevocation,\n\tOAuthResourceSelector,\n\tOAuthStore,\n} from '@softistx/janus-oauth';\nimport { toGrant, toGrantDocument } from '../records';\nimport { duplicateOf, onKey, run, unexpectedDuplicate } from '../translate';\nimport type { StoreContext } from './context';\nimport { grantReads } from './grant-reads';\nimport { decode, encode, keyOf, where } from './scope';\nimport { spendDevices } from './spend-devices';\n\ntype GrantMethods = Required<\n\tPick<\n\t\tOAuthStore,\n\t\t| 'upsertGrant'\n\t\t| 'findGrant'\n\t\t| 'findUserGrant'\n\t\t| 'listUserGrants'\n\t\t| 'revokeGrant'\n\t\t| 'revokeUserGrants'\n\t\t| 'revokeGrantsByResource'\n\t\t| 'deleteUserGrants'\n\t\t| 'listClientGrants'\n\t\t| 'revokeClientGrants'\n\t\t| 'listBoundGrants'\n\t>\n>;\n\ntype Ctx = StoreContext;\n\n/** Stamps `at` on every still-open token matching `filter`. */\nasync function closeTokens(\n\t{ collections, partition }: Ctx,\n\tfilter: { grantId: string } | { userId: string } | { clientId: string },\n\tat: Date,\n): Promise<void> {\n\tconst stamp = { $set: { revokedAt: new Date(at.getTime()) } };\n\tconst open = { ...where(partition), ...filter, revokedAt: null };\n\tawait collections.access.updateMany(open, stamp);\n\tawait collections.refresh.updateMany(open, stamp);\n}\n\n/** The members of a grant a consent without them removes. */\nconst unsetOf = (document: {\n\treadonly bound?: unknown;\n\treadonly authorizationDetails?: unknown;\n}) => [\n\t...(document.bound === undefined ? ['bound' as const] : []),\n\t...(document.authorizationDetails === undefined\n\t\t? ['authorizationDetails' as const]\n\t\t: []),\n];\n\nfunction upsertGrant(\n\t{ collections, partition }: Ctx,\n\tgrant: OAuthGrantRecord,\n): Promise<OAuthGrantRecord> {\n\tconst { grants } = collections;\n\treturn run('upsertGrant', async () => {\n\t\tconst key = {\n\t\t\t...where(partition),\n\t\t\tuserId: grant.userId,\n\t\t\tclientId: grant.clientId,\n\t\t\tresource: grant.resource,\n\t\t};\n\t\tconst document = encode(partition, toGrantDocument(grant));\n\t\t// Two concurrent upserts on a new key can both try to insert; the\n\t\t// unique index refuses the second, which then finds the first.\n\t\tfor (let attempt = 0; ; attempt += 1) {\n\t\t\ttry {\n\t\t\t\tconst stored = await grants.findOneAndUpdate(\n\t\t\t\t\tkey,\n\t\t\t\t\t{\n\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\tscopes: document.scopes,\n\t\t\t\t\t\t\tupdatedAt: document.updatedAt,\n\t\t\t\t\t\t\trevokedAt: null,\n\t\t\t\t\t\t\t...(document.bound === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { bound: document.bound }),\n\t\t\t\t\t\t\t...(document.authorizationDetails === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { authorizationDetails: document.authorizationDetails }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t$setOnInsert: {\n\t\t\t\t\t\t\t_id: document._id,\n\t\t\t\t\t\t\tcreatedAt: document.createdAt,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t// The new grant's bound object and details replace the old\n\t\t\t\t\t\t// ones, or none.\n\t\t\t\t\t\t...(unsetOf(document).length === 0\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t$unset: Object.fromEntries(\n\t\t\t\t\t\t\t\t\t\tunsetOf(document).map((k) => [k, '']),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\t{ upsert: true, returnDocument: 'after' },\n\t\t\t\t);\n\t\t\t\tif (stored === null) {\n\t\t\t\t\tthrow new Error('the upsert answered no document');\n\t\t\t\t}\n\t\t\t\treturn toGrant(decode(partition, stored));\n\t\t\t} catch (error) {\n\t\t\t\tconst duplicate = await duplicateOf(Promise.reject(error));\n\t\t\t\tif (duplicate === null) throw error;\n\t\t\t\tif (attempt === 0 && onKey(duplicate)) continue;\n\t\t\t\tthrow unexpectedDuplicate('upsertGrant', duplicate);\n\t\t\t}\n\t\t}\n\t});\n}\n\n/** Un-transacted by contract: the grant is marked BEFORE its tokens are swept, so a token stored after the mark is closed by a second call. */\nfunction revokeGrant(\n\tctx: Ctx,\n\tid: string,\n\tat: Date,\n\tspare?: string,\n): Promise<boolean> {\n\treturn run('revokeGrant', async () => {\n\t\t// A pipeline, so a grant already revoked keeps its first\n\t\t// `revokedAt` and still counts as matched.\n\t\tconst result = await ctx.collections.grants.updateOne(\n\t\t\t{ _id: keyOf(ctx.partition, id) },\n\t\t\t[{ $set: { revokedAt: { $ifNull: ['$revokedAt', at] } } }],\n\t\t);\n\t\t// Always, even when the grant was revoked before: a token stored\n\t\t// since (a rotation that raced the first revoke) is closed here.\n\t\tif (result.matchedCount === 1) await closeTokens(ctx, { grantId: id }, at);\n\t\tawait spendDevices(ctx, { grantId: id }, spare);\n\t\treturn result.matchedCount === 1;\n\t});\n}\n\nfunction revokeUserGrants(ctx: Ctx, userId: string, at: Date): Promise<number> {\n\treturn run('revokeUserGrants', async () => {\n\t\tconst result = await ctx.collections.grants.updateMany(\n\t\t\t{ ...where(ctx.partition), userId, revokedAt: null },\n\t\t\t{ $set: { revokedAt: new Date(at.getTime()) } },\n\t\t);\n\t\tawait closeTokens(ctx, { userId }, at);\n\t\tawait spendDevices(ctx, { userId });\n\t\treturn result.modifiedCount;\n\t});\n}\n\nfunction revokeClientGrants(\n\tctx: Ctx,\n\tclientId: string,\n\tat: Date,\n): Promise<number> {\n\treturn run('revokeClientGrants', async () => {\n\t\tconst result = await ctx.collections.grants.updateMany(\n\t\t\t{ ...where(ctx.partition), clientId, revokedAt: null },\n\t\t\t{ $set: { revokedAt: new Date(at.getTime()) } },\n\t\t);\n\t\t// Always, even when no grant was open: a token stored since is closed.\n\t\tawait closeTokens(ctx, { clientId }, at);\n\t\tawait spendDevices(ctx, { clientId });\n\t\treturn result.modifiedCount;\n\t});\n}\n\nfunction revokeGrantsByResource(\n\tctx: Ctx,\n\tselector: OAuthResourceSelector,\n\tat: Date,\n\tdryRun: boolean,\n): Promise<OAuthResourceRevocation> {\n\tconst { grants, access, refresh } = ctx.collections;\n\tconst { partition } = ctx;\n\tconst { equals, differs } = selector ?? {};\n\tif (\n\t\t(equals === undefined) === (differs === undefined) ||\n\t\ttypeof (equals ?? differs) !== 'string'\n\t) {\n\t\treturn Promise.reject(\n\t\t\tnew TypeError(\n\t\t\t\t'revokeGrantsByResource: pass exactly one of { equals } or { differs }, as a string',\n\t\t\t),\n\t\t);\n\t}\n\treturn run('revokeGrantsByResource', async () => {\n\t\tconst resource =\n\t\t\tselector.equals !== undefined\n\t\t\t\t? selector.equals\n\t\t\t\t: { $ne: selector.differs };\n\t\tconst open = { ...where(partition), resource, revokedAt: null };\n\t\tif (dryRun) {\n\t\t\treturn {\n\t\t\t\tgrants: await grants.countDocuments(open),\n\t\t\t\taccessTokens: await access.countDocuments(open),\n\t\t\t\trefreshTokens: await refresh.countDocuments(open),\n\t\t\t};\n\t\t}\n\t\tconst stamp = { $set: { revokedAt: new Date(at.getTime()) } };\n\t\t// Grants first and readable, then the tokens: the order of `revokeGrant`.\n\t\tconst revokedGrants = await grants.updateMany(open, stamp);\n\t\tconst revokedAccess = await access.updateMany(open, stamp);\n\t\tconst revokedRefresh = await refresh.updateMany(open, stamp);\n\t\tawait spendDevices(ctx, { resource });\n\t\treturn {\n\t\t\tgrants: revokedGrants.modifiedCount,\n\t\t\taccessTokens: revokedAccess.modifiedCount,\n\t\t\trefreshTokens: revokedRefresh.modifiedCount,\n\t\t};\n\t});\n}\n\nfunction deleteUserGrants(\n\t{ collections, partition }: Ctx,\n\tuserId: string,\n): Promise<number> {\n\tconst { grants, access, refresh, codes, devices } = collections;\n\treturn run('deleteUserGrants', async () => {\n\t\t// Grants last: the count is theirs, and a retry after a failure\n\t\t// half-way still finds them.\n\t\tconst mine = { ...where(partition), userId };\n\t\tawait access.deleteMany(mine);\n\t\tawait refresh.deleteMany(mine);\n\t\tawait codes.deleteMany(mine);\n\t\tawait devices.deleteMany(mine);\n\t\tconst result = await grants.deleteMany(mine);\n\t\treturn result.deletedCount;\n\t});\n}\n\n/** The grants, and the sweeps of a grant's or a user's tokens that go with revoking or deleting them. */\nexport function grantStore(ctx: StoreContext): GrantMethods {\n\treturn {\n\t\tupsertGrant: (grant) => upsertGrant(ctx, grant),\n\t\t...grantReads(ctx),\n\t\trevokeClientGrants: (clientId, at) => revokeClientGrants(ctx, clientId, at),\n\t\trevokeGrant: (id, at, options) => revokeGrant(ctx, id, at, options?.spare),\n\t\trevokeUserGrants: (userId, at) => revokeUserGrants(ctx, userId, at),\n\t\trevokeGrantsByResource: (selector, at, options) =>\n\t\t\trevokeGrantsByResource(ctx, selector, at, options?.dryRun === true),\n\t\tdeleteUserGrants: (userId) => deleteUserGrants(ctx, userId),\n\t};\n}\n",
42
+ "import { getCollection } from '@softistx/mongo';\nimport type { Collection, Db, Document } from 'mongodb';\nimport {\n\toauthAccessTokens,\n\toauthClients,\n\toauthCodes,\n\toauthDeviceAuthorizations,\n\toauthGrants,\n\toauthRefreshTokens,\n\toauthRequests,\n} from '../collections';\nimport {\n\toauthPartitionedAccessTokens,\n\toauthPartitionedClients,\n\toauthPartitionedCodes,\n\toauthPartitionedDeviceAuthorizations,\n\toauthPartitionedGrants,\n\toauthPartitionedRefreshTokens,\n\toauthPartitionedRequests,\n} from '../partitioned';\nimport type {\n\tAccessDocument,\n\tClientDocument,\n\tCodeDocument,\n\tGrantDocument,\n\tRefreshDocument,\n\tRequestDocument,\n} from '../records';\nimport type { DeviceDocument } from '../records-device';\nimport type { OAuthCollections } from './context';\n\n/** A collection opened on the primary, so a read sees the latest acknowledged write. */\nfunction primary<T extends Document>(db: Db, name: string): Collection<T> {\n\treturn db.collection<T>(name, { readPreference: 'primary' });\n}\n\n/**\n * The seven collections of the default layout, or of the partitioned one. The\n * partitioned documents carry a `partition` field the port's records do not\n * read, so both layouts share the document types.\n */\nexport function openCollections(\n\tdb: Db,\n\tpartitioned: boolean,\n): OAuthCollections {\n\tconst names = partitioned\n\t\t? {\n\t\t\t\tclients: oauthPartitionedClients,\n\t\t\t\trequests: oauthPartitionedRequests,\n\t\t\t\tcodes: oauthPartitionedCodes,\n\t\t\t\tdevices: oauthPartitionedDeviceAuthorizations,\n\t\t\t\tgrants: oauthPartitionedGrants,\n\t\t\t\taccess: oauthPartitionedAccessTokens,\n\t\t\t\trefresh: oauthPartitionedRefreshTokens,\n\t\t\t}\n\t\t: {\n\t\t\t\tclients: oauthClients,\n\t\t\t\trequests: oauthRequests,\n\t\t\t\tcodes: oauthCodes,\n\t\t\t\tdevices: oauthDeviceAuthorizations,\n\t\t\t\tgrants: oauthGrants,\n\t\t\t\taccess: oauthAccessTokens,\n\t\t\t\trefresh: oauthRefreshTokens,\n\t\t\t};\n\tconst open = <T extends Document>(\n\t\tdefinition: Parameters<typeof getCollection>[1],\n\t): Collection<T> =>\n\t\tprimary<T>(db, getCollection(db, definition).raw.collectionName);\n\treturn {\n\t\tclients: open<ClientDocument>(names.clients),\n\t\trequests: open<RequestDocument>(names.requests),\n\t\tcodes: open<CodeDocument>(names.codes),\n\t\tdevices: open<DeviceDocument>(names.devices),\n\t\tgrants: open<GrantDocument>(names.grants),\n\t\taccess: open<AccessDocument>(names.access),\n\t\trefresh: open<RefreshDocument>(names.refresh),\n\t};\n}\n",
43
+ "import type { OAuthStore } from '@softistx/janus-oauth';\nimport { toRequest, toRequestDocument } from '../records';\nimport { duplicateOf, onId, run, unexpectedDuplicate } from '../translate';\nimport type { StoreContext } from './context';\nimport { decode, encode, keyOf } from './scope';\n\ntype RequestMethods = Pick<\n\tOAuthStore,\n\t| 'insertAuthorizationRequest'\n\t| 'findAuthorizationRequest'\n\t| 'consumeAuthorizationRequest'\n>;\n\n/** The pending authorization requests. */\nexport function requestStore({\n\tcollections,\n\tpartition,\n}: StoreContext): RequestMethods {\n\tconst { requests } = collections;\n\treturn {\n\t\tinsertAuthorizationRequest: (request) =>\n\t\t\trun('insertAuthorizationRequest', async () => {\n\t\t\t\t// `_id` is the only unique index: a duplicate is a retry.\n\t\t\t\tconst duplicate = await duplicateOf(\n\t\t\t\t\trequests.insertOne(encode(partition, toRequestDocument(request))),\n\t\t\t\t);\n\t\t\t\tif (duplicate !== null && !onId(duplicate)) {\n\t\t\t\t\tthrow unexpectedDuplicate('insertAuthorizationRequest', duplicate);\n\t\t\t\t}\n\t\t\t}),\n\n\t\tfindAuthorizationRequest: (id) =>\n\t\t\trun('findAuthorizationRequest', async () => {\n\t\t\t\tconst found = await requests.findOne({ _id: keyOf(partition, id) });\n\t\t\t\treturn found === null ? null : toRequest(decode(partition, found));\n\t\t\t}),\n\n\t\tconsumeAuthorizationRequest: (id, now) =>\n\t\t\trun('consumeAuthorizationRequest', async () => {\n\t\t\t\t// One delete answering the document: of concurrent calls, one\n\t\t\t\t// receives it. A lapsed request is taken out and answers `null`.\n\t\t\t\tconst taken = await requests.findOneAndDelete({\n\t\t\t\t\t_id: keyOf(partition, id),\n\t\t\t\t});\n\t\t\t\tif (taken === null) return null;\n\t\t\t\treturn taken.expiresAt.getTime() > now.getTime()\n\t\t\t\t\t? toRequest(decode(partition, taken))\n\t\t\t\t\t: null;\n\t\t\t}),\n\t};\n}\n",
44
+ "import type { OAuthRotation, OAuthStore } from '@softistx/janus-oauth';\nimport type { ClientSession, Db } from 'mongodb';\nimport { toAccessDocument, toRefresh, toRefreshDocument } from '../records';\nimport { inTransaction } from '../transaction';\nimport { run } from '../translate';\nimport type { StoreContext } from './context';\nimport { decode, encode, keyOf } from './scope';\n\ntype NextTokens = Parameters<OAuthStore['rotateRefreshToken']>[1];\n\n/** The one method that writes several documents, so the one that runs in a transaction. */\nexport function rotateStore(\n\tcontext: StoreContext,\n\tdb: Db,\n): Pick<OAuthStore, 'rotateRefreshToken'> {\n\treturn {\n\t\trotateRefreshToken: (currentHash, next, now) =>\n\t\t\trun('rotateRefreshToken', () =>\n\t\t\t\tinTransaction(db, (session) =>\n\t\t\t\t\trotate(context, session, currentHash, next, now),\n\t\t\t\t),\n\t\t\t),\n\t};\n}\n\n/**\n * The body of the transaction, which the driver may run again after a\n * write conflict: it reads and writes through `session` only, and its\n * inserts are upserts that change nothing when the document is there.\n */\nasync function rotate(\n\t{ collections, partition }: StoreContext,\n\tsession: ClientSession,\n\tcurrentHash: string,\n\tnext: NextTokens,\n\tnow: Date,\n): Promise<OAuthRotation> {\n\tconst { access, refresh } = collections;\n\t// The single-document claim: of concurrent calls, one matches\n\t// `rotatedAt: null`.\n\tconst before = await refresh.findOneAndUpdate(\n\t\t{\n\t\t\t_id: keyOf(partition, currentHash),\n\t\t\trevokedAt: null,\n\t\t\trotatedAt: null,\n\t\t\texpiresAt: { $gt: now },\n\t\t},\n\t\t{ $set: { rotatedAt: new Date(now.getTime()) } },\n\t\t{ returnDocument: 'before', session },\n\t);\n\n\tif (before === null) {\n\t\tconst found = await refresh.findOne(\n\t\t\t{ _id: keyOf(partition, currentHash) },\n\t\t\t{ session },\n\t\t);\n\t\tif (found === null || found.revokedAt !== null) {\n\t\t\treturn { status: 'absent' };\n\t\t}\n\t\tif (found.rotatedAt !== null) {\n\t\t\treturn {\n\t\t\t\tstatus: 'reused',\n\t\t\t\tprevious: toRefresh(decode(partition, found)),\n\t\t\t};\n\t\t}\n\t\treturn { status: 'absent' };\n\t}\n\n\tconst { _id: accessId, ...accessFields } = encode(\n\t\tpartition,\n\t\ttoAccessDocument(next.accessToken),\n\t);\n\tawait access.updateOne(\n\t\t{ _id: accessId },\n\t\t{ $setOnInsert: accessFields },\n\t\t{ upsert: true, session },\n\t);\n\tconst { _id: refreshId, ...refreshFields } = encode(\n\t\tpartition,\n\t\ttoRefreshDocument(next.refreshToken),\n\t);\n\tawait refresh.updateOne(\n\t\t{ _id: refreshId },\n\t\t{ $setOnInsert: refreshFields },\n\t\t{ upsert: true, session },\n\t);\n\treturn { status: 'rotated', previous: toRefresh(decode(partition, before)) };\n}\n",
45
+ "import type { OAuthStore } from '@softistx/janus-oauth';\nimport {\n\ttoAccess,\n\ttoAccessDocument,\n\ttoRefresh,\n\ttoRefreshDocument,\n} from '../records';\nimport { duplicateOf, onId, run, unexpectedDuplicate } from '../translate';\nimport type { StoreContext } from './context';\nimport { decode, encode, keyOf } from './scope';\n\ntype TokenMethods = Pick<\n\tOAuthStore,\n\t| 'insertAccessToken'\n\t| 'findAccessToken'\n\t| 'revokeAccessToken'\n\t| 'insertRefreshToken'\n\t| 'findRefreshToken'\n\t| 'revokeRefreshToken'\n>;\n\n/** The access and refresh tokens; the rotation, which spans both, is `rotate.ts`. */\nexport function tokenStore({\n\tcollections,\n\tpartition,\n}: StoreContext): TokenMethods {\n\tconst { access, refresh } = collections;\n\treturn {\n\t\tinsertAccessToken: (token) =>\n\t\t\trun('insertAccessToken', async () => {\n\t\t\t\tconst duplicate = await duplicateOf(\n\t\t\t\t\taccess.insertOne(encode(partition, toAccessDocument(token))),\n\t\t\t\t);\n\t\t\t\tif (duplicate !== null && !onId(duplicate)) {\n\t\t\t\t\tthrow unexpectedDuplicate('insertAccessToken', duplicate);\n\t\t\t\t}\n\t\t\t}),\n\n\t\tfindAccessToken: (tokenHash) =>\n\t\t\trun('findAccessToken', async () => {\n\t\t\t\tconst found = await access.findOne({\n\t\t\t\t\t_id: keyOf(partition, tokenHash),\n\t\t\t\t});\n\t\t\t\treturn found === null ? null : toAccess(decode(partition, found));\n\t\t\t}),\n\n\t\trevokeAccessToken: (tokenHash, at) =>\n\t\t\trun('revokeAccessToken', async () => {\n\t\t\t\tconst result = await access.updateOne(\n\t\t\t\t\t{ _id: keyOf(partition, tokenHash) },\n\t\t\t\t\t[{ $set: { revokedAt: { $ifNull: ['$revokedAt', at] } } }],\n\t\t\t\t);\n\t\t\t\treturn result.matchedCount === 1;\n\t\t\t}),\n\n\t\tinsertRefreshToken: (token) =>\n\t\t\trun('insertRefreshToken', async () => {\n\t\t\t\tconst duplicate = await duplicateOf(\n\t\t\t\t\trefresh.insertOne(encode(partition, toRefreshDocument(token))),\n\t\t\t\t);\n\t\t\t\tif (duplicate !== null && !onId(duplicate)) {\n\t\t\t\t\tthrow unexpectedDuplicate('insertRefreshToken', duplicate);\n\t\t\t\t}\n\t\t\t}),\n\n\t\tfindRefreshToken: (tokenHash) =>\n\t\t\trun('findRefreshToken', async () => {\n\t\t\t\tconst found = await refresh.findOne({\n\t\t\t\t\t_id: keyOf(partition, tokenHash),\n\t\t\t\t});\n\t\t\t\treturn found === null ? null : toRefresh(decode(partition, found));\n\t\t\t}),\n\n\t\trevokeRefreshToken: (tokenHash, at) =>\n\t\t\trun('revokeRefreshToken', async () => {\n\t\t\t\tconst result = await refresh.updateOne(\n\t\t\t\t\t{ _id: keyOf(partition, tokenHash) },\n\t\t\t\t\t[{ $set: { revokedAt: { $ifNull: ['$revokedAt', at] } } }],\n\t\t\t\t);\n\t\t\t\treturn result.matchedCount === 1;\n\t\t\t}),\n\t};\n}\n",
46
+ "import type { OAuthStore } from '@softistx/janus-oauth';\nimport type { Db } from 'mongodb';\nimport { clientStore } from './clients';\nimport { codeStore } from './codes';\nimport type { StoreContext } from './context';\nimport { deviceStore } from './device';\nimport { grantStore } from './grants';\nimport { openCollections } from './open';\nimport { requestStore } from './requests';\nimport { rotateStore } from './rotate';\nimport { tokenStore } from './tokens';\n\nexport interface MongoOAuthOptions {\n\t/** Keeps several stores in one database (one per issuer, say). Default: none, the unpartitioned layout. Two partitions never see each other's records. */\n\treadonly partition?: string;\n}\n\n/**\n * The `OAuthStore` of `@softistx/janus-oauth`, over one MongoDB database.\n *\n * `{ partition }` keeps several stores in one database, one per issuer (see\n * `createOAuthIssuers`): the same store over the partitioned collections,\n * where every key and every index is scoped by the partition, so a client, a\n * code, a token or a grant of one partition does not exist in another. It is\n * opt-in and a different layout: run `syncMongoOAuthPartitioned(db)`, and\n * `docs/guide/partitions.md` has the migration. Without it the storage is\n * what it always was.\n *\n * ```ts\n * await syncMongoOAuth(db); // a deployment step: creates the indexes\n * const store = createMongoOAuth(db); // an OAuthStore\n * const oauth = createOAuthServer({ auth, store, issuer, resources });\n * ```\n *\n * **Every conditional write is one driver call** on a single document, so\n * the database decides who wins:\n *\n * - `consumeOAuthCode` is one `findOneAndUpdate` filtered on\n * `consumedAt: null` and `expiresAt > now`; the loser reads the document\n * to tell `replayed` from `absent`;\n * - `consumeAuthorizationRequest` is one `findOneAndDelete`;\n * - `decideDeviceAuthorization` and every step of `pollDeviceAuthorization`\n * (approved once, pending, `slow_down`) are one `findOneAndUpdate` on the\n * device code's document, with the server's `now`;\n * - `upsertGrant` is one upsert on the unique `(userId, clientId, resource)`\n * index, and `$setOnInsert` is what keeps an existing grant's `id` and\n * `createdAt`;\n * - `revokeGrant` keeps a first `revokedAt` with a pipeline update and\n * **always sweeps the grant's tokens that are still standing**, so a second\n * call closes the window a racing rotation left.\n *\n * **`rotateRefreshToken` is the one method that writes several documents**,\n * and the port asks it to be all or nothing, so it runs in a transaction:\n * MongoDB must be a replica set or a sharded cluster, as it must be for\n * `@softistx/janus-mongo`'s relation store. A standalone `mongod` rejects it with\n * a `StoreFailure`.\n *\n * The seven collections are opened with `readPreference: 'primary'`: the server\n * re-reads a grant after storing tokens and must see the latest revoke.\n *\n * Reads reach for the driver's `findOne` and answer a lapsed or revoked\n * record as it is stored; an absence is `null`, and everything that rejects is\n * a `StoreFailure`.\n *\n * `deleteExpiredOAuthRecords` is not implemented: TTL indexes drop lapsed\n * records, which is what the port asks of a store with its own expiry.\n */\nexport function createMongoOAuth(\n\tdb: Db,\n\toptions: MongoOAuthOptions = {},\n): OAuthStore {\n\tif (typeof db?.collection !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t`createMongoOAuth: pass the Db your app opened with @softistx/mongo (got ${db === null ? 'null' : typeof db})`,\n\t\t);\n\t}\n\tif (typeof options !== 'object' || options === null) {\n\t\tthrow new TypeError('createMongoOAuth: options must be an object');\n\t}\n\t// Omitting the key keeps the default layout; a key that is present must be a name.\n\tconst partition: string | null =\n\t\t'partition' in options ? (options.partition as string) : null;\n\tif (\n\t\t'partition' in options &&\n\t\t(typeof partition !== 'string' || partition === '')\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'createMongoOAuth: partition must be a non-empty string',\n\t\t);\n\t}\n\tconst context: StoreContext = {\n\t\tcollections: openCollections(db, partition !== null),\n\t\tpartition,\n\t};\n\n\treturn {\n\t\t...clientStore(context),\n\t\t...requestStore(context),\n\t\t...codeStore(context),\n\t\t...deviceStore(context),\n\t\t...grantStore(context),\n\t\t...tokenStore(context),\n\t\t...rotateStore(context, db),\n\t};\n}\n",
47
+ "import {\n\ttype SyncOptions,\n\ttype SyncReport,\n\tsyncCollections,\n} from '@softistx/mongo';\nimport type { Db } from 'mongodb';\nimport { oauthCollections } from './collections';\nimport { oauthDpopReplay } from './dpop-replay-collection';\nimport { oauthPartitionedCollections } from './partitioned';\n\n/**\n * Creates the nine collections, their validators and their indexes, and says\n * what it changed. Run it twice and the second run sends nothing.\n *\n * A deployment step, never a request-time one: it needs the `dbAdmin` role.\n * An application that deploys with `@softistx/mongo`'s `syncAll(db)` already\n * syncs them with its own.\n */\nexport function syncMongoOAuth(\n\tdb: Db,\n\toptions?: SyncOptions,\n): Promise<SyncReport[]> {\n\treturn syncCollections(db, oauthCollections, options);\n}\n\n/**\n * `syncMongoOAuth` for the partitioned layout (`createMongoOAuth(db, { partition })`):\n * the seven partitioned collections, the signing keys (whose collection is\n * partitioned already) and `oauthDpopReplay` (its keys carry no partition). It leaves the default collections alone, so both\n * layouts can sit in one database while a deployment moves from one to the\n * other (`docs/guide/partitions.md`).\n */\nexport function syncMongoOAuthPartitioned(\n\tdb: Db,\n\toptions?: SyncOptions,\n): Promise<SyncReport[]> {\n\treturn syncCollections(\n\t\tdb,\n\t\t[...oauthPartitionedCollections, oauthDpopReplay],\n\t\toptions,\n\t);\n}\n"
48
+ ],
49
+ "mappings": ";AAAA;AACA,cAAS;;;ACDT;AAEO,IAAM,KAAK,EAAE,KAAK;AAClB,IAAM,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC;AASjC,IAAM,uBAAuB,EAAE,OAAO,EAAE,SAAS;AAOjD,IAAM,eAAe;AAAA,EAC3B,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,UAAU,GAAG,SAAS;AAAA,EACtB,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EAClC,KAAK,EAAE,OAAO,EAAE,SAAS;AAC1B;;;ADdO,IAAM,qBAAqB,KAAK,KAAK;AAErC,IAAM,gBAAgB,iBAAiB;AAAA,EAC7C,MAAM;AAAA,EACN,QAAQ,GAAE,OAAO;AAAA,IAChB,KAAK,GAAE,OAAO;AAAA,IACd,UAAU,GAAE,OAAO;AAAA,IACnB,aAAa,GAAE,OAAO;AAAA,IACtB,UAAU,GAAE,OAAO;AAAA,IACnB;AAAA,IACA,OAAO,GAAE,OAAO,EAAE,SAAS;AAAA,IAC3B,OAAO,GAAE,OAAO,EAAE,SAAS;AAAA,IAC3B,SAAS,GAAE,OAAO,EAAE,SAAS;AAAA,IAC7B;AAAA,IACA,WAAW,GAAE,MAAM,GAAE,OAAO,CAAC,EAAE,SAAS;AAAA,IACxC,QAAQ,GAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS;AAAA,IAChD,QAAQ,GAAE,MAAM,GAAE,OAAO,CAAC,EAAE,SAAS;AAAA,IACrC,WAAW,GAAE,OAAO,EAAE,SAAS;AAAA,IAC/B,eAAe,GAAE,OAAO;A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E,WAAW,EAAE,SAAS,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,CAAC,CAC1D;AAAA,MACA,OAAO,OAAO,iBAAiB;AAAA,KAC/B;AAAA,EACH;AAAA;;;ACdM,SAAS,gBAAgB,CAC/B,IACA,UAA6B,CAAC,GACjB;AAAA,EACb,IAAI,OAAO,IAAI,eAAe,YAAY;AAAA,IACzC,MAAM,IAAI,UACT,2EAA2E,OAAO,OAAO,SAAS,OAAO,KAC1G;AAAA,EACD;AAAA,EACA,IAAI,OAAO,YAAY,YAAY,YAAY,MAAM;AAAA,IACpD,MAAM,IAAI,UAAU,6CAA6C;AAAA,EAClE;AAAA,EAEA,MAAM,YACL,eAAe,UAAW,QAAQ,YAAuB;AAAA,EAC1D,IACC,eAAe,YACd,OAAO,cAAc,YAAY,cAAc,KAC/C;AAAA,IACD,MAAM,IAAI,UACT,wDACD;AAAA,EACD;AAAA,EACA,MAAM,UAAwB;AAAA,IAC7B,aAAa,gBAAgB,IAAI,cAAc,IAAI;AAAA,IACnD;AAAA,EACD;AAAA,EAEA,OAAO;AAAA,OACH,YAAY,OAAO;AAAA,OACnB,aAAa,OAAO;AAAA,OACpB,UAAU,OAAO;AAAA,OACjB,YAAY,OAAO;AAAA,OACnB,WAAW,OAAO;AAAA,OAClB,WAAW,OAAO;AAAA,OAClB,YAAY,SAAS,EAAE;AAAA,EAC3B;AAAA;;ACvGD;AAAA;AAAA;AAkBO,SAAS,cAAc,CAC7B,IACA,SACwB;AAAA,EACxB,OAAO,gBAAgB,IAAI,kBAAkB,OAAO;AAAA;AAU9C,SAAS,yBAAyB,CACxC,IACA,SACwB;AAAA,EACxB,OAAO,gBACN,IACA,CAAC,GAAG,6BAA6B,eAAe,GAChD,OACD;AAAA;",
50
+ "debugId": "0530A846CFA3262D64756E2164756E21",
51
+ "names": []
52
+ }
@@ -0,0 +1,97 @@
1
+ import { z } from 'zod';
2
+ export declare const oauthPartitionedClients: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
3
+ [x: string]: any;
4
+ partition: z.ZodString;
5
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
6
+ export declare const oauthPartitionedRequests: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
7
+ [x: string]: any;
8
+ partition: z.ZodString;
9
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
10
+ export declare const oauthPartitionedCodes: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
11
+ [x: string]: any;
12
+ partition: z.ZodString;
13
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
14
+ export declare const oauthPartitionedDeviceAuthorizations: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
15
+ [x: string]: any;
16
+ partition: z.ZodString;
17
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
18
+ export declare const oauthPartitionedGrants: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
19
+ [x: string]: any;
20
+ partition: z.ZodString;
21
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
22
+ export declare const oauthPartitionedAccessTokens: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
23
+ [x: string]: any;
24
+ partition: z.ZodString;
25
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
26
+ export declare const oauthPartitionedRefreshTokens: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
27
+ [x: string]: any;
28
+ partition: z.ZodString;
29
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
30
+ /** The partitioned layout's definitions, in the order `syncMongoOAuthPartitioned` syncs them; the signing keys are the default layout's, already partitioned. */
31
+ export declare const oauthPartitionedCollections: readonly [import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
32
+ [x: string]: any;
33
+ partition: z.ZodString;
34
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
35
+ [x: string]: any;
36
+ partition: z.ZodString;
37
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
38
+ [x: string]: any;
39
+ partition: z.ZodString;
40
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
41
+ [x: string]: any;
42
+ partition: z.ZodString;
43
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
44
+ [x: string]: any;
45
+ partition: z.ZodString;
46
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
47
+ [x: string]: any;
48
+ partition: z.ZodString;
49
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
50
+ [x: string]: any;
51
+ partition: z.ZodString;
52
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
53
+ _id: z.ZodString;
54
+ partition: z.ZodString;
55
+ kid: z.ZodString;
56
+ alg: z.ZodEnum<{
57
+ ES256: "ES256";
58
+ EdDSA: "EdDSA";
59
+ }>;
60
+ status: z.ZodEnum<{
61
+ current: "current";
62
+ next: "next";
63
+ retired: "retired";
64
+ }>;
65
+ slot: z.ZodNullable<z.ZodEnum<{
66
+ current: "current";
67
+ next: "next";
68
+ }>>;
69
+ publicJwk: z.ZodObject<{
70
+ kty: z.ZodEnum<{
71
+ EC: "EC";
72
+ OKP: "OKP";
73
+ }>;
74
+ crv: z.ZodEnum<{
75
+ Ed25519: "Ed25519";
76
+ "P-256": "P-256";
77
+ }>;
78
+ x: z.ZodString;
79
+ y: z.ZodOptional<z.ZodString>;
80
+ kid: z.ZodString;
81
+ alg: z.ZodEnum<{
82
+ ES256: "ES256";
83
+ EdDSA: "EdDSA";
84
+ }>;
85
+ use: z.ZodLiteral<"sig">;
86
+ }, z.core.$strip>;
87
+ sealed: z.ZodObject<{
88
+ iv: z.ZodString;
89
+ data: z.ZodString;
90
+ }, z.core.$strip>;
91
+ createdAt: z.ZodDate;
92
+ activateAt: z.ZodDate;
93
+ activatedAt: z.ZodNullable<z.ZodDate>;
94
+ retiredAt: z.ZodNullable<z.ZodDate>;
95
+ publishUntil: z.ZodNullable<z.ZodDate>;
96
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>];
97
+ //# sourceMappingURL=partitioned.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partitioned.d.ts","sourceRoot":"","sources":["../src/partitioned.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgDxB,eAAO,MAAM,uBAAuB;;;mGAGnC,CAAC;AACF,eAAO,MAAM,wBAAwB;;;mGAGpC,CAAC;AACF,eAAO,MAAM,qBAAqB;;;mGAGjC,CAAC;AACF,eAAO,MAAM,oCAAoC;;;mGAGhD,CAAC;AACF,eAAO,MAAM,sBAAsB;;;mGAGlC,CAAC;AACF,eAAO,MAAM,4BAA4B;;;mGAGxC,CAAC;AACF,eAAO,MAAM,6BAA6B;;;mGAGzC,CAAC;AAEF,iKAAiK;AACjK,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oGAS9B,CAAC"}