@softistx/janus-oauth-mongo 0.0.0-stage → 0.18.4
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/dist/purge.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { Db } from 'mongodb';
|
|
2
|
+
export interface PurgeMongoOAuthPartitionOptions {
|
|
3
|
+
/** The partition to empty: the name given to `createMongoOAuth` and `createMongoSigningKeys`. Required, a non-empty string. */
|
|
4
|
+
readonly partition: string;
|
|
5
|
+
/**
|
|
6
|
+
* Whether the partition's signing keys are deleted too. Default `true`.
|
|
7
|
+
* `false` keeps them, for a key set that outlives its store. It must be
|
|
8
|
+
* said for the partition named `default`, which is also the key set of an
|
|
9
|
+
* unpartitioned deployment (`createMongoSigningKeys(db)` with no partition).
|
|
10
|
+
*/
|
|
11
|
+
readonly signingKeys?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** What `purgeMongoOAuthPartition` deleted: the number of documents per collection. All zeros when the partition held nothing. */
|
|
14
|
+
export interface MongoOAuthPartitionPurge {
|
|
15
|
+
readonly clients: number;
|
|
16
|
+
readonly requests: number;
|
|
17
|
+
readonly codes: number;
|
|
18
|
+
readonly deviceAuthorizations: number;
|
|
19
|
+
readonly grants: number;
|
|
20
|
+
readonly accessTokens: number;
|
|
21
|
+
readonly refreshTokens: number;
|
|
22
|
+
/** `0` when `signingKeys` is `false`. */
|
|
23
|
+
readonly signingKeys: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What a purge empties, in the order it does: the secrets first (tokens,
|
|
27
|
+
* codes, requests), then the grants and the clients, and the signing keys
|
|
28
|
+
* last, so a purge that stops half-way leaves nothing a client can still
|
|
29
|
+
* spend. `partitions.purge.spec.ts` holds this list equal to
|
|
30
|
+
* `oauthPartitionedCollections`: a collection added to the layout and not
|
|
31
|
+
* here fails it.
|
|
32
|
+
*/
|
|
33
|
+
export declare const PURGED: readonly [readonly ['accessTokens', import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
34
|
+
[x: string]: any;
|
|
35
|
+
partition: import("zod").ZodString;
|
|
36
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>], readonly ['refreshTokens', import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
37
|
+
[x: string]: any;
|
|
38
|
+
partition: import("zod").ZodString;
|
|
39
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>], readonly ['codes', import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
40
|
+
[x: string]: any;
|
|
41
|
+
partition: import("zod").ZodString;
|
|
42
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>], readonly ['deviceAuthorizations', import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
43
|
+
[x: string]: any;
|
|
44
|
+
partition: import("zod").ZodString;
|
|
45
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>], readonly ['requests', import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
46
|
+
[x: string]: any;
|
|
47
|
+
partition: import("zod").ZodString;
|
|
48
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>], readonly ['grants', import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
49
|
+
[x: string]: any;
|
|
50
|
+
partition: import("zod").ZodString;
|
|
51
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>], readonly ['clients', import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
52
|
+
[x: string]: any;
|
|
53
|
+
partition: import("zod").ZodString;
|
|
54
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>], readonly ['signingKeys', import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
55
|
+
_id: import("zod").ZodString;
|
|
56
|
+
partition: import("zod").ZodString;
|
|
57
|
+
kid: import("zod").ZodString;
|
|
58
|
+
alg: import("zod").ZodEnum<{
|
|
59
|
+
ES256: "ES256";
|
|
60
|
+
EdDSA: "EdDSA";
|
|
61
|
+
}>;
|
|
62
|
+
status: import("zod").ZodEnum<{
|
|
63
|
+
current: "current";
|
|
64
|
+
next: "next";
|
|
65
|
+
retired: "retired";
|
|
66
|
+
}>;
|
|
67
|
+
slot: import("zod").ZodNullable<import("zod").ZodEnum<{
|
|
68
|
+
current: "current";
|
|
69
|
+
next: "next";
|
|
70
|
+
}>>;
|
|
71
|
+
publicJwk: import("zod").ZodObject<{
|
|
72
|
+
kty: import("zod").ZodEnum<{
|
|
73
|
+
EC: "EC";
|
|
74
|
+
OKP: "OKP";
|
|
75
|
+
}>;
|
|
76
|
+
crv: import("zod").ZodEnum<{
|
|
77
|
+
Ed25519: "Ed25519";
|
|
78
|
+
"P-256": "P-256";
|
|
79
|
+
}>;
|
|
80
|
+
x: import("zod").ZodString;
|
|
81
|
+
y: import("zod").ZodOptional<import("zod").ZodString>;
|
|
82
|
+
kid: import("zod").ZodString;
|
|
83
|
+
alg: import("zod").ZodEnum<{
|
|
84
|
+
ES256: "ES256";
|
|
85
|
+
EdDSA: "EdDSA";
|
|
86
|
+
}>;
|
|
87
|
+
use: import("zod").ZodLiteral<"sig">;
|
|
88
|
+
}, import("zod/v4/core").$strip>;
|
|
89
|
+
sealed: import("zod").ZodObject<{
|
|
90
|
+
iv: import("zod").ZodString;
|
|
91
|
+
data: import("zod").ZodString;
|
|
92
|
+
}, import("zod/v4/core").$strip>;
|
|
93
|
+
createdAt: import("zod").ZodDate;
|
|
94
|
+
activateAt: import("zod").ZodDate;
|
|
95
|
+
activatedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
96
|
+
retiredAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
97
|
+
publishUntil: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
98
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>]];
|
|
99
|
+
/**
|
|
100
|
+
* **Destructive, and not undoable**: deletes every document of one partition
|
|
101
|
+
* in the seven partitioned OAuth collections (clients, authorization requests,
|
|
102
|
+
* codes, device authorizations, grants, access tokens, refresh tokens) and the partition's signing
|
|
103
|
+
* keys. For the day an issuer is deleted for good.
|
|
104
|
+
*
|
|
105
|
+
* ```ts
|
|
106
|
+
* const deleted = await purgeMongoOAuthPartition(db, { partition: 'issuer-a' });
|
|
107
|
+
* // { clients: 2, requests: 0, codes: 1, deviceAuthorizations: 0, grants: 5, accessTokens: 9, refreshTokens: 5, signingKeys: 2 }
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* - It never touches the default (unpartitioned) collections, nor another
|
|
111
|
+
* partition: every delete is filtered on the exact `partition`.
|
|
112
|
+
* - It is idempotent: a second run, or a partition that never existed,
|
|
113
|
+
* answers zeros.
|
|
114
|
+
* - A missing, empty or non-string `partition` is a `TypeError`, before any
|
|
115
|
+
* I/O. There is no "purge everything".
|
|
116
|
+
* - It is not a transaction: the collections are emptied one after the
|
|
117
|
+
* other. A failure is a `StoreFailure`; run it again to finish.
|
|
118
|
+
* - Stop serving the issuer first: a request still in flight can write a
|
|
119
|
+
* record after its collection was emptied. A second run removes it.
|
|
120
|
+
* - Once the signing keys are gone, no JWT access token of the partition
|
|
121
|
+
* verifies any more, and the keys cannot be recovered.
|
|
122
|
+
*/
|
|
123
|
+
export declare function purgeMongoOAuthPartition(db: Db, options: PurgeMongoOAuthPartitionOptions): Promise<MongoOAuthPartitionPurge>;
|
|
124
|
+
//# sourceMappingURL=purge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purge.d.ts","sourceRoot":"","sources":["../src/purge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAgBlC,MAAM,WAAW,+BAA+B;IAC/C,+HAA+H;IAC/H,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,kIAAkI;AAClI,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,yCAAyC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,sBACjB,cAAc;;;gHACd,eAAe;;;gHACf,OAAO;;;gHACP,sBAAsB;;;gHACtB,UAAU;;;gHACV,QAAQ;;;gHACR,SAAS;;;gHACT,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qGACL,CAAC;AAyBX;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,wBAAwB,CAC7C,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,+BAA+B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CA4BnC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare const date: (value: Date) => Date;
|
|
2
|
+
export declare const dateOrNull: (value: Date | null) => Date | null;
|
|
3
|
+
/** The OpenID fields a record or a document has, only those: an absent key stays absent. */
|
|
4
|
+
export declare const openId: (r: {
|
|
5
|
+
readonly nonce?: string | undefined;
|
|
6
|
+
readonly authTime?: Date | undefined;
|
|
7
|
+
readonly amr?: readonly string[] | undefined;
|
|
8
|
+
readonly acr?: string | undefined;
|
|
9
|
+
}) => {
|
|
10
|
+
nonce?: string;
|
|
11
|
+
authTime?: Date;
|
|
12
|
+
amr?: string[];
|
|
13
|
+
acr?: string;
|
|
14
|
+
};
|
|
15
|
+
/** What the request's authentication parameters left (a copy), only those it has: an absent key stays absent. */
|
|
16
|
+
export declare const authenticationHints: (r: {
|
|
17
|
+
readonly acrValues?: readonly string[] | undefined;
|
|
18
|
+
readonly maxAge?: number | undefined;
|
|
19
|
+
readonly prompt?: readonly string[] | undefined;
|
|
20
|
+
readonly loginHint?: string | undefined;
|
|
21
|
+
}) => {
|
|
22
|
+
acrValues?: string[];
|
|
23
|
+
maxAge?: number;
|
|
24
|
+
prompt?: string[];
|
|
25
|
+
loginHint?: string;
|
|
26
|
+
};
|
|
27
|
+
/** The DPoP key thumbprint of a token, only when it has one. */
|
|
28
|
+
export declare const jkt: (r: {
|
|
29
|
+
readonly jkt?: string | undefined;
|
|
30
|
+
}) => {
|
|
31
|
+
jkt?: never;
|
|
32
|
+
} | {
|
|
33
|
+
jkt: string;
|
|
34
|
+
};
|
|
35
|
+
/** The DPoP key thumbprint a request or a code carries, only when it has one. */
|
|
36
|
+
export declare const dpopJkt: (r: {
|
|
37
|
+
readonly dpopJkt?: string | undefined;
|
|
38
|
+
}) => {
|
|
39
|
+
dpopJkt?: never;
|
|
40
|
+
} | {
|
|
41
|
+
dpopJkt: string;
|
|
42
|
+
};
|
|
43
|
+
/** The actor of a delegated access token (a copy), only when it has one. */
|
|
44
|
+
export declare const actor: (r: {
|
|
45
|
+
readonly actor?: {
|
|
46
|
+
readonly sub: string;
|
|
47
|
+
readonly clientId?: string | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
}) => {
|
|
50
|
+
actor?: never;
|
|
51
|
+
} | {
|
|
52
|
+
actor: {
|
|
53
|
+
sub: string;
|
|
54
|
+
clientId?: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=record-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-fields.d.ts","sourceRoot":"","sources":["../src/record-fields.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,UAAW,IAAI,KAAG,IAAiC,CAAC;AACrE,eAAO,MAAM,UAAU,UAAW,IAAI,GAAG,IAAI,KAAG,IAAI,GAAG,IACnB,CAAC;AAErC,4FAA4F;AAC5F,eAAO,MAAM,MAAM,MAAO;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;;;;;CAKC,CAAC;AAEH,iHAAiH;AACjH,eAAO,MAAM,mBAAmB,MAAO;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACnD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;;;;;CAKC,CAAC;AAEH,gEAAgE;AAChE,eAAO,MAAM,GAAG,MAAO;IAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE;;;;CAClB,CAAC;AAE3C,iFAAiF;AACjF,eAAO,MAAM,OAAO,MAAO;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE;;;;CACd,CAAC;AAEvD,4EAA4E;AAC5E,eAAO,MAAM,KAAK,MAAO;IACxB,QAAQ,CAAC,KAAK,CAAC,EACZ;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GAChE,SAAS,CAAC;CACb;;;;;;;CAUG,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OAuthClientRecord } from '@softistx/janus-oauth';
|
|
2
|
+
import type { DocumentOf } from '@softistx/mongo';
|
|
3
|
+
import type { oauthClients } from '../collections';
|
|
4
|
+
export type ClientDocument = DocumentOf<typeof oauthClients>;
|
|
5
|
+
export declare const toClientDocument: (r: OAuthClientRecord) => ClientDocument;
|
|
6
|
+
export declare const toClient: (d: ClientDocument) => OAuthClientRecord;
|
|
7
|
+
//# sourceMappingURL=clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../src/records/clients.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,iBAAiB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAgDnD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAE7D,eAAO,MAAM,gBAAgB,MAAO,iBAAiB,KAAG,cAYtD,CAAC;AAEH,eAAO,MAAM,QAAQ,MAAO,cAAc,KAAG,iBAY3C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OAuthGrantRecord } from '@softistx/janus-oauth';
|
|
2
|
+
import type { DocumentOf } from '@softistx/mongo';
|
|
3
|
+
import type { oauthGrants } from '../collections';
|
|
4
|
+
export type GrantDocument = DocumentOf<typeof oauthGrants>;
|
|
5
|
+
export declare const toGrantDocument: (r: OAuthGrantRecord) => GrantDocument;
|
|
6
|
+
export declare const toGrant: (d: GrantDocument) => OAuthGrantRecord;
|
|
7
|
+
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../src/records/grants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAE3D,eAAO,MAAM,eAAe,MAAO,gBAAgB,KAAG,aAapD,CAAC;AAEH,eAAO,MAAM,OAAO,MAAO,aAAa,KAAG,gBAazC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/records/index.ts"],"names":[],"mappings":"AAKA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OAuthAuthorizationRequestRecord, OAuthCodeRecord } from '@softistx/janus-oauth';
|
|
2
|
+
import type { DocumentOf } from '@softistx/mongo';
|
|
3
|
+
import type { oauthCodes, oauthRequests } from '../collections';
|
|
4
|
+
export type RequestDocument = DocumentOf<typeof oauthRequests>;
|
|
5
|
+
export type CodeDocument = DocumentOf<typeof oauthCodes>;
|
|
6
|
+
export declare const toRequestDocument: (r: OAuthAuthorizationRequestRecord) => RequestDocument;
|
|
7
|
+
export declare const toRequest: (d: RequestDocument) => OAuthAuthorizationRequestRecord;
|
|
8
|
+
export declare const toCodeDocument: (r: OAuthCodeRecord) => CodeDocument;
|
|
9
|
+
export declare const toCode: (d: CodeDocument) => OAuthCodeRecord;
|
|
10
|
+
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/records/requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,+BAA+B,EAC/B,eAAe,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAUhE,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAC/D,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAEzD,eAAO,MAAM,iBAAiB,MAC1B,+BAA+B,KAChC,eAeD,CAAC;AAEH,eAAO,MAAM,SAAS,MAClB,eAAe,KAChB,+BAeD,CAAC;AAEH,eAAO,MAAM,cAAc,MAAO,eAAe,KAAG,YAgBlD,CAAC;AAEH,eAAO,MAAM,MAAM,MAAO,YAAY,KAAG,eAgBvC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OAuthAccessTokenRecord, OAuthRefreshTokenRecord } from '@softistx/janus-oauth';
|
|
2
|
+
import type { DocumentOf } from '@softistx/mongo';
|
|
3
|
+
import type { oauthAccessTokens, oauthRefreshTokens } from '../collections';
|
|
4
|
+
export type AccessDocument = DocumentOf<typeof oauthAccessTokens>;
|
|
5
|
+
export type RefreshDocument = DocumentOf<typeof oauthRefreshTokens>;
|
|
6
|
+
export declare const toAccessDocument: (r: OAuthAccessTokenRecord) => AccessDocument;
|
|
7
|
+
export declare const toAccess: (d: AccessDocument) => OAuthAccessTokenRecord;
|
|
8
|
+
export declare const toRefreshDocument: (r: OAuthRefreshTokenRecord) => RefreshDocument;
|
|
9
|
+
export declare const toRefresh: (d: RefreshDocument) => OAuthRefreshTokenRecord;
|
|
10
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/records/tokens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAI5E,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,eAAO,MAAM,gBAAgB,MACzB,sBAAsB,KACvB,cAcD,CAAC;AAEH,eAAO,MAAM,QAAQ,MAAO,cAAc,KAAG,sBAc3C,CAAC;AAEH,eAAO,MAAM,iBAAiB,MAC1B,uBAAuB,KACxB,eAeD,CAAC;AAEH,eAAO,MAAM,SAAS,MAAO,eAAe,KAAG,uBAe7C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OAuthDeviceAuthorizationRecord } from '@softistx/janus-oauth';
|
|
2
|
+
import type { DocumentOf } from '@softistx/mongo';
|
|
3
|
+
import type { oauthDeviceAuthorizations } from './device-collection';
|
|
4
|
+
export type DeviceDocument = DocumentOf<typeof oauthDeviceAuthorizations>;
|
|
5
|
+
export declare const toDeviceDocument: (r: OAuthDeviceAuthorizationRecord) => DeviceDocument;
|
|
6
|
+
export declare const toDevice: (d: DeviceDocument) => OAuthDeviceAuthorizationRecord;
|
|
7
|
+
//# sourceMappingURL=records-device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records-device.d.ts","sourceRoot":"","sources":["../src/records-device.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGrE,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE1E,eAAO,MAAM,gBAAgB,MACzB,8BAA8B,KAC/B,cAgBD,CAAC;AAEH,eAAO,MAAM,QAAQ,MACjB,cAAc,KACf,8BAgBD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Collection, Db } from 'mongodb';
|
|
2
|
+
import type { SigningKeyDocument } from './records';
|
|
3
|
+
import type { Sealer } from './seal';
|
|
4
|
+
/** What every signing-key module takes. Data only: no behaviour. */
|
|
5
|
+
export interface SigningKeysContext {
|
|
6
|
+
readonly db: Db;
|
|
7
|
+
readonly keys: Collection<SigningKeyDocument>;
|
|
8
|
+
readonly partition: string;
|
|
9
|
+
readonly sealer: Sealer;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/signing-keys/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SigningKeyStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { Db } from 'mongodb';
|
|
3
|
+
import { type MongoSigningKeysOptions } from './options';
|
|
4
|
+
/**
|
|
5
|
+
* The `SigningKeyStore` of `@softistx/janus-oauth` over one MongoDB database,
|
|
6
|
+
* the private JWKs encrypted at rest with AES-256-GCM (WebCrypto, a fresh
|
|
7
|
+
* random 12-byte IV per record, the partition and `kid` as additional data).
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const keys = createMongoSigningKeys(db, { encryptionKey }); // 32 bytes
|
|
11
|
+
* const oauth = createOAuthServer({ auth, store, accessTokens: { format: 'jwt', keys }, ... });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* `encryptionKey` may be a list for rotating the master key: the first key
|
|
15
|
+
* seals, any opens. A key sealed under another master key fails to decrypt: `findKeys` throws
|
|
16
|
+
* `StoreFailure`, never an empty list. `promote` runs in a transaction (a
|
|
17
|
+
* replica set), like `rotateRefreshToken`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createMongoSigningKeys(db: Db, options: MongoSigningKeysOptions): SigningKeyStore;
|
|
20
|
+
export type { MongoSigningKeysOptions } from './options';
|
|
21
|
+
export { type MongoSigningKeysResealed, resealMongoSigningKeys, } from './reseal';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signing-keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EACN,KAAK,uBAAuB,EAE5B,MAAM,WAAW,CAAC;AAMnB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,uBAAuB,GAC9B,eAAe,CAajB;AAED,YAAY,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACN,KAAK,wBAAwB,EAC7B,sBAAsB,GACtB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 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). */
|
|
2
|
+
export declare function assertEncryptionKey(key: unknown, where?: string, name?: string): asserts key is Uint8Array;
|
|
3
|
+
/**
|
|
4
|
+
* The `encryptionKey` option as a keyring: a single key is a list of one. A
|
|
5
|
+
* list must be non-empty, hold 32-byte keys only and no key twice (compared by
|
|
6
|
+
* bytes); a message names the entry (`encryptionKey[1]`) and never a byte.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseKeyring(encryptionKey: unknown, where: string): readonly Uint8Array[];
|
|
9
|
+
//# sourceMappingURL=keyring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyring.d.ts","sourceRoot":"","sources":["../../src/signing-keys/keyring.ts"],"names":[],"mappings":"AAEA,uLAAuL;AACvL,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,OAAO,EACZ,KAAK,SAA2B,EAChC,IAAI,SAAkB,GACpB,OAAO,CAAC,GAAG,IAAI,UAAU,CAW3B;AAKD;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,aAAa,EAAE,OAAO,EACtB,KAAK,EAAE,MAAM,GACX,SAAS,UAAU,EAAE,CAwBvB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Collection, Db } from 'mongodb';
|
|
2
|
+
import type { SigningKeyDocument } from './records';
|
|
3
|
+
export interface MongoSigningKeysOptions {
|
|
4
|
+
/** 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. */
|
|
5
|
+
readonly encryptionKey: Uint8Array | readonly Uint8Array[];
|
|
6
|
+
/** Keeps several key sets in one collection (one per issuer, say). Defaults to `default`; two partitions never see each other's keys. */
|
|
7
|
+
readonly partition?: string;
|
|
8
|
+
}
|
|
9
|
+
/** The arguments of a signing-keys entry point checked, or a `TypeError` naming `where`. */
|
|
10
|
+
export declare function parseSigningKeysArguments(db: Db, options: MongoSigningKeysOptions, where: string): {
|
|
11
|
+
readonly keyring: readonly Uint8Array[];
|
|
12
|
+
readonly partition: string;
|
|
13
|
+
readonly keys: Collection<SigningKeyDocument>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/signing-keys/options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,WAAW,uBAAuB;IACvC,8RAA8R;IAC9R,QAAQ,CAAC,aAAa,EAAE,UAAU,GAAG,SAAS,UAAU,EAAE,CAAC;IAC3D,yIAAyI;IACzI,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,4FAA4F;AAC5F,wBAAgB,yBAAyB,CACxC,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,MAAM,GACX;IACF,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;CAC9C,CAmBA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SigningKeyStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { SigningKeysContext } from './context';
|
|
3
|
+
type PromoteMethods = Pick<SigningKeyStore, 'promote'>;
|
|
4
|
+
/** All or nothing: the `current` keys retire and the `next` key becomes current, in one transaction. */
|
|
5
|
+
export declare function promoteSigningKey({ db, keys, partition, }: SigningKeysContext): PromoteMethods;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=promote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../src/signing-keys/promote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD,KAAK,cAAc,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;AAEvD,wGAAwG;AACxG,wBAAgB,iBAAiB,CAAC,EACjC,EAAE,EACF,IAAI,EACJ,SAAS,GACT,EAAE,kBAAkB,GAAG,cAAc,CA4CrC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SigningKeyStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { SigningKeysContext } from './context';
|
|
3
|
+
type ReadMethods = Pick<SigningKeyStore, 'findKeys' | 'findCurrentKey' | 'findPublicKeys'>;
|
|
4
|
+
type Ctx = SigningKeysContext;
|
|
5
|
+
export declare function readSigningKeys(ctx: Ctx): ReadMethods;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/signing-keys/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD,KAAK,WAAW,GAAG,IAAI,CACtB,eAAe,EACf,UAAU,GAAG,gBAAgB,GAAG,gBAAgB,CAChD,CAAC;AACF,KAAK,GAAG,GAAG,kBAAkB,CAAC;AAmB9B,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAmCrD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type NewSigningKey, type PublicSigningKey, type SigningKeyRecord } from '@softistx/janus-oauth';
|
|
2
|
+
import type { DocumentOf } from '@softistx/mongo';
|
|
3
|
+
import type { oauthSigningKeys } from '../collections';
|
|
4
|
+
import type { Sealer } from './seal';
|
|
5
|
+
export type SigningKeyDocument = DocumentOf<typeof oauthSigningKeys>;
|
|
6
|
+
export declare const documentId: (partition: string, kid: string) => string;
|
|
7
|
+
/** The document for a new key: the private JWK only as `sealed`. */
|
|
8
|
+
export declare function toSigningKeyDocument(key: NewSigningKey, partition: string, sealer: Sealer): Promise<SigningKeyDocument>;
|
|
9
|
+
/** The port's public record: the sealed private JWK is not opened, so a lost master key does not stop it. */
|
|
10
|
+
export declare function toPublicSigningKey(doc: Omit<SigningKeyDocument, 'sealed'>): PublicSigningKey;
|
|
11
|
+
/** The port's record: the private JWK decrypted, which throws when the master key is not the one that sealed it. */
|
|
12
|
+
export declare function toSigningKey(doc: SigningKeyDocument, sealer: Sealer): Promise<SigningKeyRecord>;
|
|
13
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/signing-keys/records.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7C,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAMrE,eAAO,MAAM,UAAU,cAAe,MAAM,OAAO,MAAM,KAAG,MAC3B,CAAC;AAElC,oEAAoE;AACpE,wBAAsB,oBAAoB,CACzC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,CAAC,CAiB7B;AAED,6GAA6G;AAC7G,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,GACrC,gBAAgB,CAYlB;AAED,oHAAoH;AACpH,wBAAsB,YAAY,CACjC,GAAG,EAAE,kBAAkB,EACvB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC,CAa3B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Db } from 'mongodb';
|
|
2
|
+
import { type MongoSigningKeysOptions } from './options';
|
|
3
|
+
/** 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). */
|
|
4
|
+
export interface MongoSigningKeysResealed {
|
|
5
|
+
readonly resealed: number;
|
|
6
|
+
readonly current: number;
|
|
7
|
+
readonly skipped: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Re-encrypts the partition's stored private keys under the first key of
|
|
11
|
+
* `encryptionKey`, the step between deploying `[newKey, oldKey]` and dropping
|
|
12
|
+
* `oldKey`. Every record is read, published or not; one already under the
|
|
13
|
+
* first key is left alone, and one under a later key is rewritten with a
|
|
14
|
+
* compare-and-set on its old ciphertext, so a concurrent writer is never
|
|
15
|
+
* overwritten (counted as `skipped`: run again until `resealed` and `skipped` are 0). Idempotent: the second run answers
|
|
16
|
+
* `resealed: 0`. A record no key opens rejects with `StoreFailure`: the
|
|
17
|
+
* run stops there, the records before it stay resealed and the ones after it
|
|
18
|
+
* are left for the next run.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* await resealMongoSigningKeys(db, { encryptionKey: [newKey, oldKey] });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function resealMongoSigningKeys(db: Db, options: MongoSigningKeysOptions): Promise<MongoSigningKeysResealed>;
|
|
25
|
+
//# sourceMappingURL=reseal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reseal.d.ts","sourceRoot":"","sources":["../../src/signing-keys/reseal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EACN,KAAK,uBAAuB,EAE5B,MAAM,WAAW,CAAC;AAGnB,iLAAiL;AACjL,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sBAAsB,CAC3C,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,uBAAuB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CAuCnC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PrivateJwk } from '@softistx/janus-oauth';
|
|
2
|
+
/** A private JWK, encrypted: base64url `iv` and `data` (ciphertext followed by the GCM tag). */
|
|
3
|
+
export interface Sealed {
|
|
4
|
+
readonly iv: string;
|
|
5
|
+
readonly data: string;
|
|
6
|
+
}
|
|
7
|
+
/** 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. */
|
|
8
|
+
export interface Sealer {
|
|
9
|
+
seal(jwk: PrivateJwk, partition: string, kid: string): Promise<Sealed>;
|
|
10
|
+
open(sealed: Sealed, partition: string, kid: string): Promise<PrivateJwk>;
|
|
11
|
+
/** Like `open`, and says which key (its index in the keyring) opened the record. */
|
|
12
|
+
openWith(sealed: Sealed, partition: string, kid: string): Promise<{
|
|
13
|
+
readonly jwk: PrivateJwk;
|
|
14
|
+
readonly index: number;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
/** `keys` is a validated keyring (see `keyring.ts`); the buffers are copied, so the caller zeroing its own later does not break the store. */
|
|
18
|
+
export declare function createSealer(keys: readonly Uint8Array[]): Sealer;
|
|
19
|
+
//# sourceMappingURL=seal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../src/signing-keys/seal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,gGAAgG;AAChG,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAaD,8OAA8O;AAC9O,MAAM,WAAW,MAAM;IACtB,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1E,oFAAoF;IACpF,QAAQ,CACP,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC;QAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjE;AAED,8IAA8I;AAC9I,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAmEhE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SigningKeyStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { SigningKeysContext } from './context';
|
|
3
|
+
type WriteMethods = Pick<SigningKeyStore, 'insertKey' | 'retire'>;
|
|
4
|
+
type Ctx = SigningKeysContext;
|
|
5
|
+
export declare function writeSigningKeys({ keys, partition, sealer, }: Ctx): WriteMethods;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/signing-keys/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD,KAAK,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAC;AAClE,KAAK,GAAG,GAAG,kBAAkB,CAAC;AAE9B,wBAAgB,gBAAgB,CAAC,EAChC,IAAI,EACJ,SAAS,EACT,MAAM,GACN,EAAE,GAAG,GAAG,YAAY,CAqCpB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The signing keys of `createMongoSigningKeys`. **The private JWK is never a
|
|
4
|
+
* field**: `sealed` is its AES-GCM ciphertext, so no `d` (nor any other
|
|
5
|
+
* private member) is stored in the clear. The public JWK is public.
|
|
6
|
+
*/
|
|
7
|
+
export declare const oauthSigningKeys: import("@softistx/mongo").CollectionDefinition<import("@softistx/mongo").StampedSchema<{
|
|
8
|
+
_id: z.ZodString;
|
|
9
|
+
partition: z.ZodString;
|
|
10
|
+
kid: z.ZodString;
|
|
11
|
+
alg: z.ZodEnum<{
|
|
12
|
+
ES256: "ES256";
|
|
13
|
+
EdDSA: "EdDSA";
|
|
14
|
+
}>;
|
|
15
|
+
status: z.ZodEnum<{
|
|
16
|
+
current: "current";
|
|
17
|
+
next: "next";
|
|
18
|
+
retired: "retired";
|
|
19
|
+
}>;
|
|
20
|
+
slot: z.ZodNullable<z.ZodEnum<{
|
|
21
|
+
current: "current";
|
|
22
|
+
next: "next";
|
|
23
|
+
}>>;
|
|
24
|
+
publicJwk: z.ZodObject<{
|
|
25
|
+
kty: z.ZodEnum<{
|
|
26
|
+
EC: "EC";
|
|
27
|
+
OKP: "OKP";
|
|
28
|
+
}>;
|
|
29
|
+
crv: z.ZodEnum<{
|
|
30
|
+
Ed25519: "Ed25519";
|
|
31
|
+
"P-256": "P-256";
|
|
32
|
+
}>;
|
|
33
|
+
x: z.ZodString;
|
|
34
|
+
y: z.ZodOptional<z.ZodString>;
|
|
35
|
+
kid: z.ZodString;
|
|
36
|
+
alg: z.ZodEnum<{
|
|
37
|
+
ES256: "ES256";
|
|
38
|
+
EdDSA: "EdDSA";
|
|
39
|
+
}>;
|
|
40
|
+
use: z.ZodLiteral<"sig">;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
sealed: z.ZodObject<{
|
|
43
|
+
iv: z.ZodString;
|
|
44
|
+
data: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
createdAt: z.ZodDate;
|
|
47
|
+
activateAt: z.ZodDate;
|
|
48
|
+
activatedAt: z.ZodNullable<z.ZodDate>;
|
|
49
|
+
retiredAt: z.ZodNullable<z.ZodDate>;
|
|
50
|
+
publishUntil: z.ZodNullable<z.ZodDate>;
|
|
51
|
+
}, false, false, false, false>, import("@softistx/mongo").StampNamesOf<false, false, false, false>>;
|
|
52
|
+
//# sourceMappingURL=signing-keys-collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing-keys-collection.d.ts","sourceRoot":"","sources":["../src/signing-keys-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mGA0C3B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type OAuthStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { StoreContext } from './context';
|
|
3
|
+
type ClientMethods = Required<Pick<OAuthStore, 'upsertClient' | 'findClient' | 'deleteClient' | 'listClients'>>;
|
|
4
|
+
/** The registered clients. */
|
|
5
|
+
export declare function clientStore({ collections, partition, }: StoreContext): ClientMethods;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../src/store/clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,uBAAuB,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,KAAK,aAAa,GAAG,QAAQ,CAC5B,IAAI,CACH,UAAU,EACV,cAAc,GAAG,YAAY,GAAG,cAAc,GAAG,aAAa,CAC9D,CACD,CAAC;AAEF,8BAA8B;AAC9B,wBAAgB,WAAW,CAAC,EAC3B,WAAW,EACX,SAAS,GACT,EAAE,YAAY,GAAG,aAAa,CAgD9B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OAuthStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { StoreContext } from './context';
|
|
3
|
+
type CodeMethods = Pick<OAuthStore, 'insertOAuthCode' | 'consumeOAuthCode'>;
|
|
4
|
+
/** The authorization codes. */
|
|
5
|
+
export declare function codeStore({ collections, partition, }: StoreContext): CodeMethods;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/store/codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,KAAK,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,iBAAiB,GAAG,kBAAkB,CAAC,CAAC;AAE5E,+BAA+B;AAC/B,wBAAgB,SAAS,CAAC,EACzB,WAAW,EACX,SAAS,GACT,EAAE,YAAY,GAAG,WAAW,CAsC5B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Collection } from 'mongodb';
|
|
2
|
+
import type { AccessDocument, ClientDocument, CodeDocument, GrantDocument, RefreshDocument, RequestDocument } from '../records';
|
|
3
|
+
import type { DeviceDocument } from '../records-device';
|
|
4
|
+
import type { Partition } from './scope';
|
|
5
|
+
/** The seven collections, each opened on the primary. Data only: no behaviour. */
|
|
6
|
+
export interface OAuthCollections {
|
|
7
|
+
readonly clients: Collection<ClientDocument>;
|
|
8
|
+
readonly requests: Collection<RequestDocument>;
|
|
9
|
+
readonly codes: Collection<CodeDocument>;
|
|
10
|
+
readonly devices: Collection<DeviceDocument>;
|
|
11
|
+
readonly grants: Collection<GrantDocument>;
|
|
12
|
+
readonly access: Collection<AccessDocument>;
|
|
13
|
+
readonly refresh: Collection<RefreshDocument>;
|
|
14
|
+
}
|
|
15
|
+
/** What every store module takes. */
|
|
16
|
+
export interface StoreContext {
|
|
17
|
+
readonly collections: OAuthCollections;
|
|
18
|
+
/** `null` for the default layout; a name for `createMongoOAuth(db, { partition })`. */
|
|
19
|
+
readonly partition: Partition;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/store/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EACX,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,eAAe,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;CAC9C;AAED,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC,uFAAuF;IACvF,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC9B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type OAuthStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { StoreContext } from './context';
|
|
3
|
+
type DeviceMethods = Required<Pick<OAuthStore, 'insertDeviceAuthorization' | 'findDeviceAuthorization' | 'decideDeviceAuthorization' | 'pollDeviceAuthorization'>>;
|
|
4
|
+
/** The device authorizations (RFC 8628): one document per request, keyed by the device code's hash. */
|
|
5
|
+
export declare function deviceStore(context: StoreContext): DeviceMethods;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/store/device.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,KAAK,UAAU,EACf,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,KAAK,aAAa,GAAG,QAAQ,CAC5B,IAAI,CACH,UAAU,EACR,2BAA2B,GAC3B,yBAAyB,GACzB,2BAA2B,GAC3B,yBAAyB,CAC3B,CACD,CAAC;AA0IF,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAoDhE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type OAuthStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { StoreContext } from './context';
|
|
3
|
+
type GrantReads = Required<Pick<OAuthStore, 'findGrant' | 'findUserGrant' | 'listUserGrants' | 'listClientGrants' | 'listBoundGrants'>>;
|
|
4
|
+
/** The grant reads: one grant, a user's, and the pages of a client's or an object's. */
|
|
5
|
+
export declare function grantReads(ctx: StoreContext): GrantReads;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=grant-reads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant-reads.d.ts","sourceRoot":"","sources":["../../src/store/grant-reads.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,UAAU,EAEf,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,KAAK,UAAU,GAAG,QAAQ,CACzB,IAAI,CACH,UAAU,EACR,WAAW,GACX,eAAe,GACf,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,CACnB,CACD,CAAC;AA+BF,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,GAAG,EAAE,YAAY,GAAG,UAAU,CAsCxD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OAuthStore } from '@softistx/janus-oauth';
|
|
2
|
+
import type { StoreContext } from './context';
|
|
3
|
+
type GrantMethods = Required<Pick<OAuthStore, 'upsertGrant' | 'findGrant' | 'findUserGrant' | 'listUserGrants' | 'revokeGrant' | 'revokeUserGrants' | 'revokeGrantsByResource' | 'deleteUserGrants' | 'listClientGrants' | 'revokeClientGrants' | 'listBoundGrants'>>;
|
|
4
|
+
/** The grants, and the sweeps of a grant's or a user's tokens that go with revoking or deleting them. */
|
|
5
|
+
export declare function grantStore(ctx: StoreContext): GrantMethods;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=grants.d.ts.map
|