@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 @@
1
+ {"version":3,"file":"details-field.d.ts","sourceRoot":"","sources":["../src/details-field.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGtE,KAAK,OAAO,GAAG,SAAS,wBAAwB,EAAE,CAAC;AAEnD,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,MAAO;IACpC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpD;;;;CAOG,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,MAAO;IACtC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnD;;;0BAgByC,wBAAwB,EAAE;CACnE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ /** Seconds a lapsed device authorization stays, so a replayed poll is still told from an unknown device code: 24 hours. */
3
+ export declare const DEVICE_GRACE_SECONDS: number;
4
+ export declare const oauthDeviceAuthorizations: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
5
+ _id: z.ZodString;
6
+ userCodeHash: z.ZodString;
7
+ clientId: z.ZodString;
8
+ resource: z.ZodString;
9
+ scopes: z.ZodArray<z.ZodString>;
10
+ intervalMs: z.ZodNumber;
11
+ lastPolledAt: z.ZodNullable<z.ZodDate>;
12
+ status: z.ZodEnum<{
13
+ approved: "approved";
14
+ denied: "denied";
15
+ pending: "pending";
16
+ }>;
17
+ userId: z.ZodOptional<z.ZodString>;
18
+ grantId: z.ZodOptional<z.ZodString>;
19
+ createdAt: z.ZodDate;
20
+ expiresAt: z.ZodDate;
21
+ consumedAt: z.ZodNullable<z.ZodDate>;
22
+ authorizationDetails: z.ZodOptional<z.ZodString>;
23
+ nonce: z.ZodOptional<z.ZodString>;
24
+ authTime: z.ZodOptional<z.ZodDate>;
25
+ amr: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ acr: z.ZodOptional<z.ZodString>;
27
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
28
+ //# sourceMappingURL=device-collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-collection.d.ts","sourceRoot":"","sources":["../src/device-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,2HAA2H;AAC3H,eAAO,MAAM,oBAAoB,QAAe,CAAC;AAEjD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;mGAyCpC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The spent DPoP proofs of `createMongoDPoPReplayCache`: `_id` is the key
4
+ * (`replayKey(jkt, jti)`), so the unique index on it is what makes a spend
5
+ * atomic. The TTL index (`expireAfterSeconds: 0`) is storage hygiene only:
6
+ * the monitor runs about every sixty seconds, and a lapsed but unreaped
7
+ * document counts as unused (the adapter compares `expiresAt` itself).
8
+ */
9
+ export declare const oauthDpopReplay: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
10
+ _id: z.ZodString;
11
+ expiresAt: z.ZodDate;
12
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
13
+ //# sourceMappingURL=dpop-replay-collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dpop-replay-collection.d.ts","sourceRoot":"","sources":["../src/dpop-replay-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;mGAS1B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type Clock } from '@softistx/janus';
2
+ import type { DPoPReplayCache } from '@softistx/janus-oauth';
3
+ import type { Db } from 'mongodb';
4
+ /** What `createMongoDPoPReplayCache` takes. */
5
+ export interface MongoDPoPReplayCacheOptions {
6
+ /** The time a spent key is compared with. Default: the system clock. Specs pass a fixed one. */
7
+ readonly clock?: Clock;
8
+ }
9
+ /**
10
+ * The `DPoPReplayCache` of `@softistx/janus-oauth` over one MongoDB database,
11
+ * in the `oauthDpopReplay` collection that `syncMongoOAuth` creates.
12
+ *
13
+ * ```ts
14
+ * const replay = createMongoDPoPReplayCache(db);
15
+ * const oauth = createOAuthServer({ auth, store, dpop: { replay }, ... });
16
+ * ```
17
+ *
18
+ * `spend` is **one atomic upsert**: it matches the key only when its stored
19
+ * `expiresAt` has passed, and otherwise tries to insert it. A key never
20
+ * spent, or lapsed, is written and answers `true`; a held key hits the unique
21
+ * `_id` and answers `false`, so of several simultaneous spends exactly one
22
+ * wins. A lapsed document the TTL monitor has not yet dropped counts as
23
+ * unused. Any other error is a `StoreFailure`: never `true` and never `false`
24
+ * for an outage.
25
+ */
26
+ export declare function createMongoDPoPReplayCache(db: Db, options?: MongoDPoPReplayCacheOptions): DPoPReplayCache;
27
+ //# sourceMappingURL=dpop-replay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dpop-replay.d.ts","sourceRoot":"","sources":["../src/dpop-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAc,EAAE,EAAE,MAAM,SAAS,CAAC;AAI9C,+CAA+C;AAC/C,MAAM,WAAW,2BAA2B;IAC3C,gGAAgG;IAChG,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CACzC,EAAE,EAAE,EAAE,EACN,OAAO,GAAE,2BAAgC,GACvC,eAAe,CA+BjB"}
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ export declare const oauthGrants: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
3
+ _id: z.ZodString;
4
+ userId: z.ZodString;
5
+ clientId: z.ZodString;
6
+ resource: z.ZodString;
7
+ scopes: z.ZodArray<z.ZodString>;
8
+ createdAt: z.ZodDate;
9
+ updatedAt: z.ZodDate;
10
+ revokedAt: z.ZodNullable<z.ZodDate>;
11
+ bound: z.ZodOptional<z.ZodObject<{
12
+ type: z.ZodString;
13
+ id: z.ZodString;
14
+ }, z.core.$strip>>;
15
+ authorizationDetails: z.ZodOptional<z.ZodString>;
16
+ }, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
17
+ //# sourceMappingURL=grants-collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grants-collection.d.ts","sourceRoot":"","sources":["../src/grants-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;mGAyCtB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `@softistx/janus-oauth-mongo` — the MongoDB store for `@softistx/janus-oauth`.
3
+ *
4
+ * Implements the `OAuthStore` port over one database, on `@softistx/mongo`:
5
+ * `createMongoOAuth(db)` is the store, `purgeMongoOAuthPartition(db, { partition })` the destructive removal of one partition, `createMongoSigningKeys(db, { encryptionKey })` the encrypted `SigningKeyStore` for JWT access tokens (`resealMongoSigningKeys` moves its records to a new master key), and `createMongoDPoPReplayCache(db)` the `DPoPReplayCache` for DPoP proofs (collection `oauthDpopReplay`), and `syncMongoOAuth(db)` the
6
+ * deployment step that creates its collections and indexes. It defines **no
7
+ * error class**: every refusal is `@softistx/janus`'s own `StoreFailure`.
8
+ */
9
+ export { CLIENT_GRACE_SECONDS, CODE_GRACE_SECONDS, DEVICE_GRACE_SECONDS, oauthAccessTokens, oauthClients, oauthCodes, oauthCollections, oauthDeviceAuthorizations, oauthDpopReplay, oauthGrants, oauthRefreshTokens, oauthRequests, oauthSigningKeys, } from './collections';
10
+ export { createMongoDPoPReplayCache, type MongoDPoPReplayCacheOptions, } from './dpop-replay';
11
+ export { oauthPartitionedAccessTokens, oauthPartitionedClients, oauthPartitionedCodes, oauthPartitionedCollections, oauthPartitionedDeviceAuthorizations, oauthPartitionedGrants, oauthPartitionedRefreshTokens, oauthPartitionedRequests, } from './partitioned';
12
+ export { type MongoOAuthPartitionPurge, type PurgeMongoOAuthPartitionOptions, purgeMongoOAuthPartition, } from './purge';
13
+ export { createMongoSigningKeys, type MongoSigningKeysOptions, type MongoSigningKeysResealed, resealMongoSigningKeys, } from './signing-keys';
14
+ export { createMongoOAuth, type MongoOAuthOptions } from './store';
15
+ export { syncMongoOAuth, syncMongoOAuthPartitioned } from './sync';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,0BAA0B,EAC1B,KAAK,2BAA2B,GAChC,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,4BAA4B,EAC5B,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,EAC3B,oCAAoC,EACpC,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,wBAAwB,GACxB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC"}