@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.
- package/LICENSE +21 -0
- package/README.md +262 -2
- package/dist/authorization-collections.d.ts +43 -0
- package/dist/authorization-collections.d.ts.map +1 -0
- package/dist/clients-collection.d.ts +29 -0
- package/dist/clients-collection.d.ts.map +1 -0
- package/dist/collection-fields.d.ts +23 -0
- package/dist/collection-fields.d.ts.map +1 -0
- package/dist/collections.d.ts +211 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/details-field.d.ts +25 -0
- package/dist/details-field.d.ts.map +1 -0
- package/dist/device-collection.d.ts +28 -0
- package/dist/device-collection.d.ts.map +1 -0
- package/dist/dpop-replay-collection.d.ts +13 -0
- package/dist/dpop-replay-collection.d.ts.map +1 -0
- package/dist/dpop-replay.d.ts +27 -0
- package/dist/dpop-replay.d.ts.map +1 -0
- package/dist/grants-collection.d.ts +17 -0
- package/dist/grants-collection.d.ts.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1671 -0
- package/dist/index.js.map +52 -0
- package/dist/partitioned.d.ts +97 -0
- package/dist/partitioned.d.ts.map +1 -0
- package/dist/purge.d.ts +124 -0
- package/dist/purge.d.ts.map +1 -0
- package/dist/record-fields.d.ts +57 -0
- package/dist/record-fields.d.ts.map +1 -0
- package/dist/records/clients.d.ts +7 -0
- package/dist/records/clients.d.ts.map +1 -0
- package/dist/records/grants.d.ts +7 -0
- package/dist/records/grants.d.ts.map +1 -0
- package/dist/records/index.d.ts +5 -0
- package/dist/records/index.d.ts.map +1 -0
- package/dist/records/requests.d.ts +10 -0
- package/dist/records/requests.d.ts.map +1 -0
- package/dist/records/tokens.d.ts +10 -0
- package/dist/records/tokens.d.ts.map +1 -0
- package/dist/records-device.d.ts +7 -0
- package/dist/records-device.d.ts.map +1 -0
- package/dist/signing-keys/context.d.ts +11 -0
- package/dist/signing-keys/context.d.ts.map +1 -0
- package/dist/signing-keys/index.d.ts +22 -0
- package/dist/signing-keys/index.d.ts.map +1 -0
- package/dist/signing-keys/keyring.d.ts +9 -0
- package/dist/signing-keys/keyring.d.ts.map +1 -0
- package/dist/signing-keys/options.d.ts +15 -0
- package/dist/signing-keys/options.d.ts.map +1 -0
- package/dist/signing-keys/promote.d.ts +7 -0
- package/dist/signing-keys/promote.d.ts.map +1 -0
- package/dist/signing-keys/read.d.ts +7 -0
- package/dist/signing-keys/read.d.ts.map +1 -0
- package/dist/signing-keys/records.d.ts +13 -0
- package/dist/signing-keys/records.d.ts.map +1 -0
- package/dist/signing-keys/reseal.d.ts +25 -0
- package/dist/signing-keys/reseal.d.ts.map +1 -0
- package/dist/signing-keys/seal.d.ts +19 -0
- package/dist/signing-keys/seal.d.ts.map +1 -0
- package/dist/signing-keys/write.d.ts +7 -0
- package/dist/signing-keys/write.d.ts.map +1 -0
- package/dist/signing-keys-collection.d.ts +52 -0
- package/dist/signing-keys-collection.d.ts.map +1 -0
- package/dist/store/clients.d.ts +7 -0
- package/dist/store/clients.d.ts.map +1 -0
- package/dist/store/codes.d.ts +7 -0
- package/dist/store/codes.d.ts.map +1 -0
- package/dist/store/context.d.ts +21 -0
- package/dist/store/context.d.ts.map +1 -0
- package/dist/store/device.d.ts +7 -0
- package/dist/store/device.d.ts.map +1 -0
- package/dist/store/grant-reads.d.ts +7 -0
- package/dist/store/grant-reads.d.ts.map +1 -0
- package/dist/store/grants.d.ts +7 -0
- package/dist/store/grants.d.ts.map +1 -0
- package/dist/store/index.d.ts +58 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/open.d.ts +9 -0
- package/dist/store/open.d.ts.map +1 -0
- package/dist/store/requests.d.ts +7 -0
- package/dist/store/requests.d.ts.map +1 -0
- package/dist/store/rotate.d.ts +6 -0
- package/dist/store/rotate.d.ts.map +1 -0
- package/dist/store/scope.d.ts +24 -0
- package/dist/store/scope.d.ts.map +1 -0
- package/dist/store/spend-devices.d.ts +20 -0
- package/dist/store/spend-devices.d.ts.map +1 -0
- package/dist/store/tokens.d.ts +7 -0
- package/dist/store/tokens.d.ts.map +1 -0
- package/dist/sync.d.ts +20 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/tokens-collections.d.ts +42 -0
- package/dist/tokens-collections.d.ts.map +1 -0
- package/dist/transaction.d.ts +13 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/translate.d.ts +34 -0
- package/dist/translate.d.ts.map +1 -0
- package/docs/README.md +13 -0
- package/docs/guide/partitions.md +141 -0
- package/docs/guide/wiring.md +133 -0
- package/docs/roadmap.md +46 -0
- package/docs/troubleshooting.md +226 -0
- package/package.json +68 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Steve Tsala
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,263 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @softistx/janus-oauth-mongo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The MongoDB store for [`@softistx/janus-oauth`](https://github.com/softistx/nxgt-janus/tree/develop/packages/janus-oauth),
|
|
4
|
+
on [`@softistx/mongo`](https://github.com/softistx/nxgt-data/blob/develop/packages/mongo/README.md): the clients,
|
|
5
|
+
pending authorization requests, codes, grants and hashed tokens of your
|
|
6
|
+
OAuth authorization server, in the database your application already runs.
|
|
7
|
+
|
|
8
|
+
It implements the `OAuthStore` port and passes the
|
|
9
|
+
`@softistx/janus-oauth/conformance` suite against a real `mongod`, outages
|
|
10
|
+
included, on every CI run.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
Public on npmjs:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
bun add @softistx/janus-oauth-mongo @softistx/janus-oauth @softistx/janus @softistx/mongo mongodb zod
|
|
18
|
+
bun add -d typescript # 6 or 7
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Every peer is required: `@softistx/janus-oauth`, whose port it implements;
|
|
22
|
+
`@softistx/janus`, whose `StoreFailure` it throws (a peer, so `instanceof` holds
|
|
23
|
+
in your code); `@softistx/mongo` (`>=0.27.0 <1`), `mongodb` (7.x) and `zod`
|
|
24
|
+
(4.x), the libraries the application already opened its connection with.
|
|
25
|
+
|
|
26
|
+
MongoDB must be a **replica set or a sharded cluster**: refresh-token
|
|
27
|
+
rotation is a transaction. See [the wiring page](docs/guide/wiring.md#what-mongodb-must-be).
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { createOAuthServer } from '@softistx/janus-oauth';
|
|
33
|
+
import { createMongoOAuth, syncMongoOAuth } from '@softistx/janus-oauth-mongo';
|
|
34
|
+
import { connectMongo } from '@softistx/mongo';
|
|
35
|
+
|
|
36
|
+
// MONGO_URI is yours and must point at a replica set; so are the issuer and the resource URL below.
|
|
37
|
+
const db = (await connectMongo(process.env.MONGO_URI ?? 'mongodb://localhost:27017')).db;
|
|
38
|
+
|
|
39
|
+
await syncMongoOAuth(db); // a deployment step: collections, validators, indexes
|
|
40
|
+
|
|
41
|
+
const oauth = createOAuthServer({
|
|
42
|
+
auth, // your janus() instance
|
|
43
|
+
store: createMongoOAuth(db),
|
|
44
|
+
issuer: 'https://auth.example.com',
|
|
45
|
+
resources: { 'https://api.example.com/mcp': { scopes: ['read'] } },
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For DPoP-bound tokens (RFC 9449), add the replay cache to the same database: `dpop: { replay: createMongoDPoPReplayCache(db) }`. **Run `syncMongoOAuth(db)` first**: four validators change, and it creates `oauthDpopReplay` ([wiring](docs/guide/wiring.md#collections-and-indexes-syncmongooauth)).
|
|
50
|
+
|
|
51
|
+
## What it holds
|
|
52
|
+
|
|
53
|
+
| Collection | Key (`_id`) | Dropped by the TTL monitor |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `oauthClients` | `client_id` | 24 h after `expiresAt` (a registered client has none and stays) |
|
|
56
|
+
| `oauthRequests` | request id (`par:` + hash for a pushed authorization request); an optional `authorizationDetails` (canonical JSON text, here and on codes, grants, tokens and device authorizations) | at `expiresAt` |
|
|
57
|
+
| `oauthCodes` | `sha256(code)` | 24 h after `expiresAt`, so a replay is still told from an unknown code |
|
|
58
|
+
| `oauthGrants` | grant id | never; unique on `(userId, clientId, resource)` |
|
|
59
|
+
| `oauthAccessTokens` | `sha256(token)`; an optional `actor` (`{ sub, clientId? }`) for a token delegated by a [token exchange](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-oauth/docs/guide/token-exchange.md) | at `expiresAt` |
|
|
60
|
+
| `oauthRefreshTokens` | `sha256(token)` | at `absoluteExpiresAt`, the 90-day chain cap |
|
|
61
|
+
| `oauthDeviceAuthorizations` | `sha256(device_code)` | 24 h after `expiresAt` (`DEVICE_GRACE_SECONDS`), so a replayed poll is still told from an unknown device code; unique on `userCodeHash`, indexed on `userId`, `clientId` and (sparse) `grantId` |
|
|
62
|
+
| `oauthDpopReplay` | `replayKey(jkt, jti)`, a spent DPoP proof | at its `expiresAt`; storage hygiene only, a lapsed document counts as unused |
|
|
63
|
+
| `oauthSigningKeys` | `[partition, kid]` as JSON | at `publishUntil`, so a retired key is dropped once published no longer; unique `current` and `next` per partition |
|
|
64
|
+
|
|
65
|
+
A device authorization (`oauthDeviceAuthorizations`, `oauthPartitionedDeviceAuthorizations` when partitioned) is stored for the device grant of `@softistx/janus-oauth`: the unique index on `userCodeHash` is created by `syncMongoOAuth` (or `syncMongoOAuthPartitioned`), so **run it before you enable the device grant**. It creates the `userCodeHash` unique index and the `userId`, `grantId` and `clientId` indexes; if it is skipped, the clients validator answers code 121 for a client that lists the device URN. Revoking a grant spends the approved device authorizations it covers. `purgeMongoOAuthPartition` empties the partition's device authorizations and counts them as `deviceAuthorizations`.
|
|
66
|
+
|
|
67
|
+
The OpenID Connect fields are optional in every schema and **absent when not
|
|
68
|
+
given**, never `null`: `nonce` on requests, codes and tokens; `acrValues`, `maxAge`, `prompt` and `loginHint` on requests; `authTime`, `amr`
|
|
69
|
+
and `acr` on codes and tokens; `tokenEndpointAuthMethod` and `secretHash` (the
|
|
70
|
+
`sha256` of a confidential client's secret) on clients. A document written
|
|
71
|
+
before them reads back unchanged, and `syncMongoOAuth` updates the validators
|
|
72
|
+
without touching a document.
|
|
73
|
+
|
|
74
|
+
No secret is stored in the clear: tokens and codes only as hashes, the hash being
|
|
75
|
+
the unique `_id`, and a signing key's private JWK only as AES-GCM ciphertext.
|
|
76
|
+
**TTL indexes are storage hygiene, not the expiry**: MongoDB's monitor runs
|
|
77
|
+
about every 60 seconds, so a lapsed record can be read for a minute or more;
|
|
78
|
+
the server compares `expiresAt` on every read.
|
|
79
|
+
|
|
80
|
+
Pushed authorization requests (RFC 9126) add no collection or index: a pushed request is a document of `oauthRequests` under its `par:` id, and a client's `requirePushedAuthorizationRequests` is stored as written (`true`, `false` or absent). On an existing database run `syncMongoOAuth(db)` (`syncMongoOAuthPartitioned(db)` in the partitioned layout) before deploying: the earlier `oauthClients` validator refuses the new field (`Document failed validation`, code 121) and the sync replaces it.
|
|
81
|
+
|
|
82
|
+
## Atomicity
|
|
83
|
+
|
|
84
|
+
- `consumeOAuthCode` and `rotateRefreshToken` decide the winner in one
|
|
85
|
+
conditional write on one document; the loser is told `replayed` / `reused`.
|
|
86
|
+
- `rotateRefreshToken` also stores the new pair, all or nothing, in a transaction.
|
|
87
|
+
- `revokeGrant` is idempotent, keeps the first `revokedAt`, and revokes again
|
|
88
|
+
the tokens stored since.
|
|
89
|
+
- `revokeGrantsByResource` revokes the standing grants and tokens of a resource
|
|
90
|
+
(or of every other one) with `updateMany`, or counts them with `dryRun`; a
|
|
91
|
+
second call changes nothing.
|
|
92
|
+
- `upsertGrant` keeps the existing grant's `id` and `createdAt`.
|
|
93
|
+
|
|
94
|
+
Details, the sync options and failures are in the [documentation](docs/README.md); an error message is looked up in [troubleshooting](docs/troubleshooting.md). The server it plugs into is wired end to end in [An MCP server, end to end](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-oauth/docs/guide/oauth.md).
|
|
95
|
+
|
|
96
|
+
## API
|
|
97
|
+
|
|
98
|
+
| Export | What it is |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `createMongoOAuth(db, { partition? })` | The `OAuthStore` of `@softistx/janus-oauth` over one `Db`: pass it as `store` to `createOAuthServer`. With `partition`, the store of one issuer among several in the database: partition-scoped keys and indexes, in seven `oauthPartitioned*` collections, plus `oauthSigningKeys` ([guide](docs/guide/partitions.md)) |
|
|
101
|
+
| `createMongoDPoPReplayCache(db, { clock? })` | The `DPoPReplayCache` of `@softistx/janus-oauth` (RFC 9449 §11.1) over one `Db`, collection `oauthDpopReplay`: `spend(key, expiresAt)` is one atomic upsert, `true` on first use, `false` on a replay, `StoreFailure` on an outage. `clock` is for specs. Its keys carry no partition, so `syncMongoOAuthPartitioned` syncs it too |
|
|
102
|
+
| `createMongoSigningKeys(db, { encryptionKey, partition? })` | The `SigningKeyStore` for JWT access tokens: private JWKs encrypted with AES-256-GCM, collection `oauthSigningKeys`. `encryptionKey` is 32 bytes (a `Uint8Array`), or a non-empty list of them to rotate it (the first seals, any opens); `partition` keeps several key sets apart (default `default`) |
|
|
103
|
+
| `resealMongoSigningKeys(db, { encryptionKey, partition? })` | Re-encrypts the partition's stored private keys under the first `encryptionKey` of the list, with a compare-and-set per record, and answers `{ resealed, current, skipped }`. Idempotent; a record no key opens rejects with `StoreFailure` ([rotating the master key](#rotating-the-master-key)) |
|
|
104
|
+
| `purgeMongoOAuthPartition(db, { partition, signingKeys? })` | **Destructive, not undoable.** Deletes every document of one partition in the seven `oauthPartitioned*` collections and the partition's signing keys, and answers `{ clients, requests, codes, deviceAuthorizations, grants, accessTokens, refreshTokens, signingKeys }`, the count deleted per collection. Idempotent (zeros the second time), never touches the default layout nor another partition, and throws a `TypeError` for a missing or empty `partition`. `signingKeys: false` keeps the keys; the partition named `default` must say which ([guide](docs/guide/partitions.md#purging-a-partition)). |
|
|
105
|
+
| `syncMongoOAuthPartitioned(db, options?)`, `oauthPartitionedCollections` | The deployment step and the definitions of the partitioned layout: seven `oauthPartitioned*` collections, the signing keys and `oauthDpopReplay`. Needed only with `partition` |
|
|
106
|
+
| `syncMongoOAuth(db, options?)` | The deployment step: the nine collections, their validators and indexes. Answers a `SyncReport` per collection and sends nothing the second time |
|
|
107
|
+
| `oauthClients`, `oauthRequests`, `oauthCodes`, `oauthGrants`, `oauthAccessTokens`, `oauthRefreshTokens`, `oauthDeviceAuthorizations`, `oauthDpopReplay`, `oauthSigningKeys`, `oauthCollections`, and `oauthPartitionedDeviceAuthorizations` beside the other `oauthPartitioned*` | The collection definitions, for `@softistx/mongo`'s own `syncAll` |
|
|
108
|
+
| `CODE_GRACE_SECONDS`, `CLIENT_GRACE_SECONDS`, `DEVICE_GRACE_SECONDS` | How long a lapsed code, a lapsed metadata client and a lapsed device authorization stay before the TTL monitor drops them: 24 hours |
|
|
109
|
+
|
|
110
|
+
To sync them with the rest of your collections, import the package before your own `syncAll`: importing registers the nine collections.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import '@softistx/janus-oauth-mongo'; // registers oauthCollections
|
|
114
|
+
import { syncAll } from '@softistx/mongo';
|
|
115
|
+
|
|
116
|
+
await syncAll(db); // yours and the nine OAuth collections, in one deployment step
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Encrypted signing keys
|
|
120
|
+
|
|
121
|
+
`createMongoSigningKeys` is the `SigningKeyStore` that JWT access tokens
|
|
122
|
+
(`accessTokens: { format: 'jwt', keys }`) read their keys from. The master key
|
|
123
|
+
is 32 random bytes from your secret manager, passed as a `Uint8Array`:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { rotateSigningKeys } from '@softistx/janus-oauth';
|
|
127
|
+
import { createMongoSigningKeys } from '@softistx/janus-oauth-mongo';
|
|
128
|
+
|
|
129
|
+
const encryptionKey = Buffer.from(process.env.JWKS_MASTER_KEY ?? '', 'base64'); // 32 bytes
|
|
130
|
+
const keys = createMongoSigningKeys(db, { encryptionKey });
|
|
131
|
+
|
|
132
|
+
const oauth = createOAuthServer({
|
|
133
|
+
auth,
|
|
134
|
+
store,
|
|
135
|
+
issuer,
|
|
136
|
+
resources,
|
|
137
|
+
accessTokens: { format: 'jwt', keys },
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// in your scheduled job (hourly is enough)
|
|
141
|
+
await rotateSigningKeys(keys, { now: new Date(), lead: '1h', retireAfter: '1h' });
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Each private JWK is encrypted with a fresh random 12-byte IV, its partition and
|
|
145
|
+
`kid` bound as additional data; the public JWK stays readable, since the JWKS
|
|
146
|
+
publishes it. A key that does not decrypt makes the call throw `StoreFailure`,
|
|
147
|
+
never answer `[]`. `promote` runs in a transaction, as a refresh rotation does.
|
|
148
|
+
`createMongoSigningKeys` throws a `TypeError` at wiring when `encryptionKey` is
|
|
149
|
+
not a 32-byte `Uint8Array`, or a list that is empty, holds a key of another
|
|
150
|
+
length, or holds the same key twice.
|
|
151
|
+
|
|
152
|
+
### Rotating the master key
|
|
153
|
+
|
|
154
|
+
`encryptionKey` also takes a list: the first key seals every new record and any
|
|
155
|
+
key of the list opens one. Both keys are 32 random bytes from your secret
|
|
156
|
+
manager, decoded as above. While instances roll out, they run different
|
|
157
|
+
versions of the list, and an instance on `oldKey` alone cannot open a record
|
|
158
|
+
another instance sealed under `newKey`. So the order matters:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import {
|
|
162
|
+
createMongoSigningKeys,
|
|
163
|
+
resealMongoSigningKeys,
|
|
164
|
+
} from '@softistx/janus-oauth-mongo';
|
|
165
|
+
|
|
166
|
+
const oldKey = Buffer.from(process.env.JWKS_MASTER_KEY ?? '', 'base64');
|
|
167
|
+
const newKey = Buffer.from(process.env.JWKS_MASTER_KEY_NEXT ?? '', 'base64');
|
|
168
|
+
const partition = 'default'; // the store's own, one run per partition
|
|
169
|
+
|
|
170
|
+
// 1. Deploy [oldKey, newKey]: the old key still seals, the new one already opens.
|
|
171
|
+
// 2. Once every instance runs it, deploy [newKey, oldKey]: the new key seals.
|
|
172
|
+
const encryptionKey = [newKey, oldKey];
|
|
173
|
+
const keys = createMongoSigningKeys(db, { encryptionKey, partition });
|
|
174
|
+
|
|
175
|
+
// 3. Re-seal what is still under the old key, from a script or a job.
|
|
176
|
+
const { resealed, skipped } = await resealMongoSigningKeys(db, {
|
|
177
|
+
encryptionKey,
|
|
178
|
+
partition,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// 4. When a run answers resealed: 0 and skipped: 0, deploy `encryptionKey: newKey` alone.
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`resealMongoSigningKeys` reads every key of the partition, published or not,
|
|
185
|
+
and rewrites only the ones sealed under a later key. A record changed by
|
|
186
|
+
someone else meanwhile is left alone and counted in `skipped`: run again. A
|
|
187
|
+
record no key opens stops the run (`StoreFailure`), the records before it stay
|
|
188
|
+
resealed and the ones after it wait for the next run. Dropping `oldKey` before
|
|
189
|
+
the last run leaves records unreadable: `findKeys` throws `StoreFailure`.
|
|
190
|
+
|
|
191
|
+
## Traps
|
|
192
|
+
|
|
193
|
+
**Run `syncMongoOAuth` (or `syncMongoOAuthPartitioned`) before deploying a version that stores authorization details.** Seven validators gain the `authorizationDetails` field (and clients `authorizationDetailsTypes`), and a write that carries one is refused with code 121 until the sync has run. No data migration ([wiring](docs/guide/wiring.md)).
|
|
194
|
+
|
|
195
|
+
**The DPoP replay cache reads two clocks.** `createMongoDPoPReplayCache` decides that a spent key has lapsed with the application's clock (`clock`), while the server's TTL monitor reaps documents on its own clock: keep the instances' clocks in sync.
|
|
196
|
+
|
|
197
|
+
**Losing the master key.** Encrypted keys become unreadable and
|
|
198
|
+
`findCurrentKey` (signing) and `findKeys` (rotation) throw `StoreFailure`: the
|
|
199
|
+
server can no longer sign. `findPublicKeys` reads the public fields only and
|
|
200
|
+
never decrypts, so verifying tokens and serving the JWKS keep working while you
|
|
201
|
+
recover.
|
|
202
|
+
Keep the master key in a secret manager, never in the repository, and back it up
|
|
203
|
+
apart from the database. To recover, point a new store at an empty `partition`
|
|
204
|
+
(or drop the documents) and let `rotateSigningKeys` create new keys; tokens signed
|
|
205
|
+
by the lost keys stop verifying once the JWKS no longer lists them. Changing the
|
|
206
|
+
master key you still hold is not a loss: see [rotating the master key](#rotating-the-master-key).
|
|
207
|
+
|
|
208
|
+
**Run `syncMongoOAuth` before enabling the device grant.** The `oauthClients` `$jsonSchema` that older syncs wrote lists the `grantTypes` it accepts and refuses the device URN with code 121; the write becomes a `StoreFailure`, and a device client cannot be created. Until the sync has run, the device collection also has no TTL index, so lapsed device authorizations stay. After that the TTL drops a record 24 h after its expiry: a replay of a dropped code answers `invalid_grant` without revoking the grant. `revokeGrant`, `revokeUserGrants`, `revokeClientGrants` and `revokeGrantsByResource` also spend the approved device authorizations they cover (status `denied`, so a poll answers `access_denied`); the `userId`, `clientId` and `grantId` indexes that `syncMongoOAuth` creates serve them, so run the sync after upgrading. The revokes spend held approvals: a held code then polls `access_denied`.
|
|
209
|
+
|
|
210
|
+
**MongoDB must be a replica set or a sharded cluster.** A refresh-token
|
|
211
|
+
rotation is a transaction; on a standalone `mongod` it fails the first time a
|
|
212
|
+
client refreshes, not at wiring.
|
|
213
|
+
|
|
214
|
+
**Sync is a deployment step.** `syncMongoOAuth` needs the `dbAdmin` role and runs
|
|
215
|
+
before the first request, never per request. Without it the collections have no
|
|
216
|
+
validators, no TTL index and no unique index on a grant's `(userId, clientId,
|
|
217
|
+
resource)`, and the store still starts: two concurrent approvals could then
|
|
218
|
+
write two grants. Or let your own `syncAll(db)` do it, as above.
|
|
219
|
+
|
|
220
|
+
**A TTL index is hygiene, not expiry.** MongoDB's monitor runs about every minute,
|
|
221
|
+
so a lapsed record can be read for that long; the server compares `expiresAt`
|
|
222
|
+
itself. A metadata client stays 24 hours past `expiresAt`, and a failed refetch is
|
|
223
|
+
`invalid_client`, never an answer from the stale copy.
|
|
224
|
+
|
|
225
|
+
**Grants never expire.** They are what a user allowed, and only a revocation or
|
|
226
|
+
`deleteUserGrants` removes one; there is no `deleteExpiredOAuthRecords`.
|
|
227
|
+
|
|
228
|
+
**Bound grants** (`listBoundGrants`, for `@softistx/janus-oauth`'s `approve(…, { bound })`) are implemented: grants carry an optional `bound: { type, id }`, read through a new partial index `bound` on `{ 'bound.type', 'bound.id', _id }` (only grants with a bound are in it; partition-prefixed in the partitioned layout). **Run `syncMongoOAuth(db)` (or `syncMongoOAuthPartitioned(db)`) after upgrading** **before deploying**: the validator an earlier version wrote refuses a grant with a `bound` (`Document failed validation`, code 121, surfaced as `STORE_FAILED`), and the sync both replaces it and creates the index.
|
|
229
|
+
|
|
230
|
+
**Listing by client** (`listClients`, `listClientGrants`, `revokeClientGrants`) is implemented, with a new `clientId` index on grants and tokens: run `syncMongoOAuth(db)` after upgrading.
|
|
231
|
+
|
|
232
|
+
**Partitions are a different layout** ([guide](docs/guide/partitions.md#traps)):
|
|
233
|
+
`createMongoOAuth(db, { partition })` reads and writes the `oauthPartitioned*`
|
|
234
|
+
collections, never the default ones, so turning it on over a database that
|
|
235
|
+
holds records starts with none: migrate them first. Run
|
|
236
|
+
`syncMongoOAuthPartitioned(db)`, not only `syncMongoOAuth`, or the unique grant
|
|
237
|
+
index and the validators are missing. A partition is a name you choose: two
|
|
238
|
+
issuers that share one share every record, so derive it from the issuer, not
|
|
239
|
+
from the request.
|
|
240
|
+
|
|
241
|
+
**A secret is never in the database.** Every `_id` of a code or a token is its
|
|
242
|
+
`sha256`; a dump cannot be replayed, and a record cannot be turned back into a
|
|
243
|
+
token.
|
|
244
|
+
|
|
245
|
+
## Documentation
|
|
246
|
+
|
|
247
|
+
- [Guides](docs/README.md) — wiring, what the database holds, atomicity
|
|
248
|
+
- [Partitions](docs/guide/partitions.md) — several issuers in one database, and the migration
|
|
249
|
+
- [Troubleshooting](docs/troubleshooting.md) — by the message you see
|
|
250
|
+
- [Roadmap](docs/roadmap.md) — what is next, and what is not planned
|
|
251
|
+
|
|
252
|
+
## Type safety, counted
|
|
253
|
+
|
|
254
|
+
**Fifteen plausible mistakes, fifteen refused at compile time.**
|
|
255
|
+
`test/types/refusals.ts` holds one `@ts-expect-error` per mistake, beside the
|
|
256
|
+
wiring that must keep compiling (`createMongoOAuth(db)` as the `store` of
|
|
257
|
+
`createOAuthServer`, `syncMongoOAuth(db)`): a `MongoClient` where a `Db` is
|
|
258
|
+
wanted, for the store and for the sync, no database at all, reading collections
|
|
259
|
+
off the store, a connection URI instead of a `Db`, `createMongoSigningKeys` with no options, an `encryptionKey` given as a string, and a `partition` that is a number or `null`, a purge with no options or no `partition`, and the keyring: a list of strings for either function, and `resealMongoSigningKeys` with no options or a string.
|
|
260
|
+
|
|
261
|
+
## Licence
|
|
262
|
+
|
|
263
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Seconds a lapsed authorization code stays, so a replay is still told from an unknown code: 24 hours. */
|
|
3
|
+
export declare const CODE_GRACE_SECONDS: number;
|
|
4
|
+
export declare const oauthRequests: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
5
|
+
_id: z.ZodString;
|
|
6
|
+
clientId: z.ZodString;
|
|
7
|
+
redirectUri: z.ZodString;
|
|
8
|
+
resource: z.ZodString;
|
|
9
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
10
|
+
state: z.ZodNullable<z.ZodString>;
|
|
11
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
12
|
+
dpopJkt: z.ZodOptional<z.ZodString>;
|
|
13
|
+
authorizationDetails: z.ZodOptional<z.ZodString>;
|
|
14
|
+
acrValues: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
|
+
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
prompt: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
loginHint: z.ZodOptional<z.ZodString>;
|
|
18
|
+
codeChallenge: z.ZodString;
|
|
19
|
+
codeChallengeMethod: z.ZodLiteral<"S256">;
|
|
20
|
+
createdAt: z.ZodDate;
|
|
21
|
+
expiresAt: z.ZodDate;
|
|
22
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
|
|
23
|
+
export declare const oauthCodes: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
24
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
25
|
+
authTime: z.ZodOptional<z.ZodDate>;
|
|
26
|
+
amr: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
acr: z.ZodOptional<z.ZodString>;
|
|
28
|
+
_id: z.ZodString;
|
|
29
|
+
clientId: z.ZodString;
|
|
30
|
+
userId: z.ZodString;
|
|
31
|
+
grantId: z.ZodString;
|
|
32
|
+
redirectUri: z.ZodString;
|
|
33
|
+
resource: z.ZodString;
|
|
34
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
35
|
+
codeChallenge: z.ZodString;
|
|
36
|
+
codeChallengeMethod: z.ZodLiteral<"S256">;
|
|
37
|
+
createdAt: z.ZodDate;
|
|
38
|
+
expiresAt: z.ZodDate;
|
|
39
|
+
consumedAt: z.ZodNullable<z.ZodDate>;
|
|
40
|
+
dpopJkt: z.ZodOptional<z.ZodString>;
|
|
41
|
+
authorizationDetails: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
|
|
43
|
+
//# sourceMappingURL=authorization-collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-collections.d.ts","sourceRoot":"","sources":["../src/authorization-collections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,2GAA2G;AAC3G,eAAO,MAAM,kBAAkB,QAAe,CAAC;AAE/C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;mGAsBxB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;mGA6BrB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** 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. */
|
|
3
|
+
export declare const CLIENT_GRACE_SECONDS: number;
|
|
4
|
+
export declare const oauthClients: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
5
|
+
_id: z.ZodString;
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
redirectUris: z.ZodArray<z.ZodString>;
|
|
8
|
+
source: z.ZodEnum<{
|
|
9
|
+
metadata: "metadata";
|
|
10
|
+
registered: "registered";
|
|
11
|
+
}>;
|
|
12
|
+
createdAt: z.ZodDate;
|
|
13
|
+
expiresAt: z.ZodNullable<z.ZodDate>;
|
|
14
|
+
tokenEndpointAuthMethod: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
client_secret_basic: "client_secret_basic";
|
|
16
|
+
none: "none";
|
|
17
|
+
}>>;
|
|
18
|
+
secretHash: z.ZodOptional<z.ZodString>;
|
|
19
|
+
grantTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
20
|
+
authorization_code: "authorization_code";
|
|
21
|
+
refresh_token: "refresh_token";
|
|
22
|
+
"urn:ietf:params:oauth:grant-type:device_code": "urn:ietf:params:oauth:grant-type:device_code";
|
|
23
|
+
"urn:ietf:params:oauth:grant-type:token-exchange": "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
24
|
+
}>>>;
|
|
25
|
+
requirePushedAuthorizationRequests: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
dpopBoundAccessTokens: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
authorizationDetailsTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
|
|
29
|
+
//# sourceMappingURL=clients-collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients-collection.d.ts","sourceRoot":"","sources":["../src/clients-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,2KAA2K;AAC3K,eAAO,MAAM,oBAAoB,QAAe,CAAC;AAEjD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;mGAwCvB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const at: z.ZodDate;
|
|
3
|
+
export declare const scopes: z.ZodArray<z.ZodString>;
|
|
4
|
+
/**
|
|
5
|
+
* The RFC 9396 authorization details of a record, as **one canonical JSON
|
|
6
|
+
* string** (keys sorted, no whitespace): a detail is arbitrary JSON, whose
|
|
7
|
+
* keys (`$x`, `a.b`) collide with MongoDB's field rules, and nothing queries
|
|
8
|
+
* it. Absent when the record has none (never `null`), so a document written
|
|
9
|
+
* before they existed is read back unchanged.
|
|
10
|
+
*/
|
|
11
|
+
export declare const authorizationDetails: z.ZodOptional<z.ZodString>;
|
|
12
|
+
/**
|
|
13
|
+
* What OpenID Connect adds to a record: all optional, **absent when the
|
|
14
|
+
* server gave none** (never `null`), so a document written before they
|
|
15
|
+
* existed is read back unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export declare const openIdFields: {
|
|
18
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
19
|
+
authTime: z.ZodOptional<z.ZodDate>;
|
|
20
|
+
amr: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
acr: z.ZodOptional<z.ZodString>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=collection-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-fields.d.ts","sourceRoot":"","sources":["../src/collection-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,EAAE,WAAW,CAAC;AAC3B,eAAO,MAAM,MAAM,yBAAsB,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,4BAAwB,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,YAAY;IACxB,KAAK;IACL,QAAQ;IACR,GAAG;IACH,GAAG;CACH,CAAC"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nine collections, as `@softistx/mongo` definitions.
|
|
3
|
+
*
|
|
4
|
+
* **What the database holds is the port's record**, with its key under `_id`:
|
|
5
|
+
* the id for a client, a request and a grant, and the `sha256` hash for a
|
|
6
|
+
* code and a token. `_id` is always unique, so **the unique index on each
|
|
7
|
+
* secret hash is the primary key itself**. Nothing else is renamed and
|
|
8
|
+
* nothing is encoded, so a record comes back byte for byte (rule 4).
|
|
9
|
+
*
|
|
10
|
+
* Defining them registers them with `@softistx/mongo`, so an application that
|
|
11
|
+
* deploys with `syncAll(db)` creates these with the rest of its own.
|
|
12
|
+
*
|
|
13
|
+
* **Every TTL index is storage hygiene, not the expiry.** MongoDB's TTL
|
|
14
|
+
* monitor runs about every sixty seconds, so a lapsed record stays readable
|
|
15
|
+
* for up to a minute (more on a loaded server) past its time plus its grace.
|
|
16
|
+
* The server compares `expiresAt` on every read, which is what expires a
|
|
17
|
+
* record.
|
|
18
|
+
*/
|
|
19
|
+
export { CODE_GRACE_SECONDS, oauthCodes, oauthRequests, } from './authorization-collections';
|
|
20
|
+
export { CLIENT_GRACE_SECONDS, oauthClients } from './clients-collection';
|
|
21
|
+
export { DEVICE_GRACE_SECONDS, oauthDeviceAuthorizations, } from './device-collection';
|
|
22
|
+
export { oauthDpopReplay } from './dpop-replay-collection';
|
|
23
|
+
export { oauthGrants } from './grants-collection';
|
|
24
|
+
export { oauthSigningKeys } from './signing-keys-collection';
|
|
25
|
+
export { oauthAccessTokens, oauthRefreshTokens } from './tokens-collections';
|
|
26
|
+
/** The nine definitions, in the order `syncMongoOAuth` syncs them. */
|
|
27
|
+
export declare const oauthCollections: readonly [import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
28
|
+
_id: import("zod").ZodString;
|
|
29
|
+
name: import("zod").ZodString;
|
|
30
|
+
redirectUris: import("zod").ZodArray<import("zod").ZodString>;
|
|
31
|
+
source: import("zod").ZodEnum<{
|
|
32
|
+
metadata: "metadata";
|
|
33
|
+
registered: "registered";
|
|
34
|
+
}>;
|
|
35
|
+
createdAt: import("zod").ZodDate;
|
|
36
|
+
expiresAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
37
|
+
tokenEndpointAuthMethod: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
38
|
+
client_secret_basic: "client_secret_basic";
|
|
39
|
+
none: "none";
|
|
40
|
+
}>>;
|
|
41
|
+
secretHash: import("zod").ZodOptional<import("zod").ZodString>;
|
|
42
|
+
grantTypes: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodEnum<{
|
|
43
|
+
authorization_code: "authorization_code";
|
|
44
|
+
refresh_token: "refresh_token";
|
|
45
|
+
"urn:ietf:params:oauth:grant-type:device_code": "urn:ietf:params:oauth:grant-type:device_code";
|
|
46
|
+
"urn:ietf:params:oauth:grant-type:token-exchange": "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
47
|
+
}>>>;
|
|
48
|
+
requirePushedAuthorizationRequests: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
49
|
+
dpopBoundAccessTokens: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
50
|
+
authorizationDetailsTypes: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
51
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
52
|
+
_id: import("zod").ZodString;
|
|
53
|
+
clientId: import("zod").ZodString;
|
|
54
|
+
redirectUri: import("zod").ZodString;
|
|
55
|
+
resource: import("zod").ZodString;
|
|
56
|
+
scopes: import("zod").ZodArray<import("zod").ZodString>;
|
|
57
|
+
state: import("zod").ZodNullable<import("zod").ZodString>;
|
|
58
|
+
nonce: import("zod").ZodOptional<import("zod").ZodString>;
|
|
59
|
+
dpopJkt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
60
|
+
authorizationDetails: import("zod").ZodOptional<import("zod").ZodString>;
|
|
61
|
+
acrValues: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
62
|
+
maxAge: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
63
|
+
prompt: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
64
|
+
loginHint: import("zod").ZodOptional<import("zod").ZodString>;
|
|
65
|
+
codeChallenge: import("zod").ZodString;
|
|
66
|
+
codeChallengeMethod: import("zod").ZodLiteral<"S256">;
|
|
67
|
+
createdAt: import("zod").ZodDate;
|
|
68
|
+
expiresAt: import("zod").ZodDate;
|
|
69
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
70
|
+
nonce: import("zod").ZodOptional<import("zod").ZodString>;
|
|
71
|
+
authTime: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
72
|
+
amr: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
73
|
+
acr: import("zod").ZodOptional<import("zod").ZodString>;
|
|
74
|
+
_id: import("zod").ZodString;
|
|
75
|
+
clientId: import("zod").ZodString;
|
|
76
|
+
userId: import("zod").ZodString;
|
|
77
|
+
grantId: import("zod").ZodString;
|
|
78
|
+
redirectUri: import("zod").ZodString;
|
|
79
|
+
resource: import("zod").ZodString;
|
|
80
|
+
scopes: import("zod").ZodArray<import("zod").ZodString>;
|
|
81
|
+
codeChallenge: import("zod").ZodString;
|
|
82
|
+
codeChallengeMethod: import("zod").ZodLiteral<"S256">;
|
|
83
|
+
createdAt: import("zod").ZodDate;
|
|
84
|
+
expiresAt: import("zod").ZodDate;
|
|
85
|
+
consumedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
86
|
+
dpopJkt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
87
|
+
authorizationDetails: import("zod").ZodOptional<import("zod").ZodString>;
|
|
88
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
89
|
+
_id: import("zod").ZodString;
|
|
90
|
+
userCodeHash: import("zod").ZodString;
|
|
91
|
+
clientId: import("zod").ZodString;
|
|
92
|
+
resource: import("zod").ZodString;
|
|
93
|
+
scopes: import("zod").ZodArray<import("zod").ZodString>;
|
|
94
|
+
intervalMs: import("zod").ZodNumber;
|
|
95
|
+
lastPolledAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
96
|
+
status: import("zod").ZodEnum<{
|
|
97
|
+
approved: "approved";
|
|
98
|
+
denied: "denied";
|
|
99
|
+
pending: "pending";
|
|
100
|
+
}>;
|
|
101
|
+
userId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
102
|
+
grantId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
103
|
+
createdAt: import("zod").ZodDate;
|
|
104
|
+
expiresAt: import("zod").ZodDate;
|
|
105
|
+
consumedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
106
|
+
authorizationDetails: import("zod").ZodOptional<import("zod").ZodString>;
|
|
107
|
+
nonce: import("zod").ZodOptional<import("zod").ZodString>;
|
|
108
|
+
authTime: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
109
|
+
amr: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
110
|
+
acr: import("zod").ZodOptional<import("zod").ZodString>;
|
|
111
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
112
|
+
_id: import("zod").ZodString;
|
|
113
|
+
userId: import("zod").ZodString;
|
|
114
|
+
clientId: import("zod").ZodString;
|
|
115
|
+
resource: import("zod").ZodString;
|
|
116
|
+
scopes: import("zod").ZodArray<import("zod").ZodString>;
|
|
117
|
+
createdAt: import("zod").ZodDate;
|
|
118
|
+
updatedAt: import("zod").ZodDate;
|
|
119
|
+
revokedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
120
|
+
bound: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
121
|
+
type: import("zod").ZodString;
|
|
122
|
+
id: import("zod").ZodString;
|
|
123
|
+
}, import("zod/v4/core").$strip>>;
|
|
124
|
+
authorizationDetails: import("zod").ZodOptional<import("zod").ZodString>;
|
|
125
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
126
|
+
nonce: import("zod").ZodOptional<import("zod").ZodString>;
|
|
127
|
+
authTime: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
128
|
+
amr: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
129
|
+
acr: import("zod").ZodOptional<import("zod").ZodString>;
|
|
130
|
+
_id: import("zod").ZodString;
|
|
131
|
+
grantId: import("zod").ZodString;
|
|
132
|
+
userId: import("zod").ZodString;
|
|
133
|
+
clientId: import("zod").ZodString;
|
|
134
|
+
resource: import("zod").ZodString;
|
|
135
|
+
scopes: import("zod").ZodArray<import("zod").ZodString>;
|
|
136
|
+
createdAt: import("zod").ZodDate;
|
|
137
|
+
expiresAt: import("zod").ZodDate;
|
|
138
|
+
revokedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
139
|
+
jkt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
140
|
+
authorizationDetails: import("zod").ZodOptional<import("zod").ZodString>;
|
|
141
|
+
actor: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
142
|
+
sub: import("zod").ZodString;
|
|
143
|
+
clientId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
144
|
+
}, import("zod/v4/core").$strip>>;
|
|
145
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
146
|
+
nonce: import("zod").ZodOptional<import("zod").ZodString>;
|
|
147
|
+
authTime: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
148
|
+
amr: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
149
|
+
acr: import("zod").ZodOptional<import("zod").ZodString>;
|
|
150
|
+
_id: import("zod").ZodString;
|
|
151
|
+
grantId: import("zod").ZodString;
|
|
152
|
+
userId: import("zod").ZodString;
|
|
153
|
+
clientId: import("zod").ZodString;
|
|
154
|
+
resource: import("zod").ZodString;
|
|
155
|
+
scopes: import("zod").ZodArray<import("zod").ZodString>;
|
|
156
|
+
createdAt: import("zod").ZodDate;
|
|
157
|
+
expiresAt: import("zod").ZodDate;
|
|
158
|
+
revokedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
159
|
+
jkt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
160
|
+
authorizationDetails: import("zod").ZodOptional<import("zod").ZodString>;
|
|
161
|
+
absoluteExpiresAt: import("zod").ZodDate;
|
|
162
|
+
rotatedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
163
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
164
|
+
_id: import("zod").ZodString;
|
|
165
|
+
partition: import("zod").ZodString;
|
|
166
|
+
kid: import("zod").ZodString;
|
|
167
|
+
alg: import("zod").ZodEnum<{
|
|
168
|
+
ES256: "ES256";
|
|
169
|
+
EdDSA: "EdDSA";
|
|
170
|
+
}>;
|
|
171
|
+
status: import("zod").ZodEnum<{
|
|
172
|
+
current: "current";
|
|
173
|
+
next: "next";
|
|
174
|
+
retired: "retired";
|
|
175
|
+
}>;
|
|
176
|
+
slot: import("zod").ZodNullable<import("zod").ZodEnum<{
|
|
177
|
+
current: "current";
|
|
178
|
+
next: "next";
|
|
179
|
+
}>>;
|
|
180
|
+
publicJwk: import("zod").ZodObject<{
|
|
181
|
+
kty: import("zod").ZodEnum<{
|
|
182
|
+
EC: "EC";
|
|
183
|
+
OKP: "OKP";
|
|
184
|
+
}>;
|
|
185
|
+
crv: import("zod").ZodEnum<{
|
|
186
|
+
Ed25519: "Ed25519";
|
|
187
|
+
"P-256": "P-256";
|
|
188
|
+
}>;
|
|
189
|
+
x: import("zod").ZodString;
|
|
190
|
+
y: import("zod").ZodOptional<import("zod").ZodString>;
|
|
191
|
+
kid: import("zod").ZodString;
|
|
192
|
+
alg: import("zod").ZodEnum<{
|
|
193
|
+
ES256: "ES256";
|
|
194
|
+
EdDSA: "EdDSA";
|
|
195
|
+
}>;
|
|
196
|
+
use: import("zod").ZodLiteral<"sig">;
|
|
197
|
+
}, import("zod/v4/core").$strip>;
|
|
198
|
+
sealed: import("zod").ZodObject<{
|
|
199
|
+
iv: import("zod").ZodString;
|
|
200
|
+
data: import("zod").ZodString;
|
|
201
|
+
}, import("zod/v4/core").$strip>;
|
|
202
|
+
createdAt: import("zod").ZodDate;
|
|
203
|
+
activateAt: import("zod").ZodDate;
|
|
204
|
+
activatedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
205
|
+
retiredAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
206
|
+
publishUntil: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
207
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>, import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
208
|
+
_id: import("zod").ZodString;
|
|
209
|
+
expiresAt: import("zod").ZodDate;
|
|
210
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>];
|
|
211
|
+
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACN,kBAAkB,EAClB,UAAU,EACV,aAAa,GACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EACN,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,sEAAsE;AACtE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oGAUnB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OAuthAuthorizationDetail } from '@softistx/janus-oauth';
|
|
2
|
+
type Details = readonly OAuthAuthorizationDetail[];
|
|
3
|
+
/** The document member of a record's details, only when it has some: an absent field stays absent. */
|
|
4
|
+
export declare const detailsToDocument: (r: {
|
|
5
|
+
readonly authorizationDetails?: Details | undefined;
|
|
6
|
+
}) => {
|
|
7
|
+
authorizationDetails?: never;
|
|
8
|
+
} | {
|
|
9
|
+
authorizationDetails: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The record member of a document's details, parsed again (a fresh copy, so a
|
|
13
|
+
* caller cannot reach the store). A value that is not a JSON list of objects
|
|
14
|
+
* is a `TypeError` naming the store, never the value: a store must not
|
|
15
|
+
* answer details it cannot read as a broader grant.
|
|
16
|
+
*/
|
|
17
|
+
export declare const detailsFromDocument: (d: {
|
|
18
|
+
readonly authorizationDetails?: string | undefined;
|
|
19
|
+
}) => {
|
|
20
|
+
authorizationDetails?: never;
|
|
21
|
+
} | {
|
|
22
|
+
authorizationDetails: OAuthAuthorizationDetail[];
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=details-field.d.ts.map
|