@softistx/janus-oidc 0.0.0-stage → 0.4.6
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 +175 -2
- package/dist/claims/scopes.d.ts +15 -0
- package/dist/claims/scopes.d.ts.map +1 -0
- package/dist/claims/types.d.ts +36 -0
- package/dist/claims/types.d.ts.map +1 -0
- package/dist/create.d.ts +19 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/http/discovery.d.ts +13 -0
- package/dist/http/discovery.d.ts.map +1 -0
- package/dist/http/handlers.d.ts +16 -0
- package/dist/http/handlers.d.ts.map +1 -0
- package/dist/http/respond.d.ts +8 -0
- package/dist/http/respond.d.ts.map +1 -0
- package/dist/http/source.d.ts +13 -0
- package/dist/http/source.d.ts.map +1 -0
- package/dist/http/urls.d.ts +7 -0
- package/dist/http/urls.d.ts.map +1 -0
- package/dist/http/userinfo.d.ts +15 -0
- package/dist/http/userinfo.d.ts.map +1 -0
- package/dist/id-token/at-hash.d.ts +4 -0
- package/dist/id-token/at-hash.d.ts.map +1 -0
- package/dist/id-token/hook.d.ts +15 -0
- package/dist/id-token/hook.d.ts.map +1 -0
- package/dist/id-token/sign.d.ts +16 -0
- package/dist/id-token/sign.d.ts.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +423 -0
- package/dist/index.js.map +20 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/docs/README.md +18 -0
- package/docs/guide/claims.md +92 -0
- package/docs/guide/discovery.md +51 -0
- package/docs/guide/getting-started.md +79 -0
- package/docs/guide/issuers.md +54 -0
- package/docs/roadmap.md +32 -0
- package/docs/troubleshooting.md +112 -0
- package/package.json +67 -5
package/dist/index.js
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
// src/create.ts
|
|
2
|
+
import { parseDuration } from "@softistx/janus";
|
|
3
|
+
import {
|
|
4
|
+
assertSigningKeyStore
|
|
5
|
+
} from "@softistx/janus-oauth";
|
|
6
|
+
|
|
7
|
+
// src/claims/scopes.ts
|
|
8
|
+
var STANDARD_SCOPE_CLAIMS = {
|
|
9
|
+
profile: [
|
|
10
|
+
"name",
|
|
11
|
+
"family_name",
|
|
12
|
+
"given_name",
|
|
13
|
+
"middle_name",
|
|
14
|
+
"nickname",
|
|
15
|
+
"preferred_username",
|
|
16
|
+
"profile",
|
|
17
|
+
"picture",
|
|
18
|
+
"website",
|
|
19
|
+
"gender",
|
|
20
|
+
"birthdate",
|
|
21
|
+
"zoneinfo",
|
|
22
|
+
"locale",
|
|
23
|
+
"updated_at"
|
|
24
|
+
],
|
|
25
|
+
email: ["email", "email_verified"],
|
|
26
|
+
address: ["address"],
|
|
27
|
+
phone: ["phone_number", "phone_number_verified"]
|
|
28
|
+
};
|
|
29
|
+
var RESERVED_CLAIMS = [
|
|
30
|
+
"iss",
|
|
31
|
+
"sub",
|
|
32
|
+
"aud",
|
|
33
|
+
"exp",
|
|
34
|
+
"iat",
|
|
35
|
+
"nbf",
|
|
36
|
+
"jti",
|
|
37
|
+
"auth_time",
|
|
38
|
+
"nonce",
|
|
39
|
+
"at_hash",
|
|
40
|
+
"c_hash",
|
|
41
|
+
"amr",
|
|
42
|
+
"acr",
|
|
43
|
+
"azp"
|
|
44
|
+
];
|
|
45
|
+
function mergedScopeClaims(own) {
|
|
46
|
+
return { ...STANDARD_SCOPE_CLAIMS, ...own };
|
|
47
|
+
}
|
|
48
|
+
function releasableClaims(table) {
|
|
49
|
+
return [...new Set(Object.values(table).flat())].filter((name) => !RESERVED_CLAIMS.includes(name)).sort();
|
|
50
|
+
}
|
|
51
|
+
function releasedClaims(claims, scopes, table) {
|
|
52
|
+
const allowed = new Set(scopes.flatMap((scope) => table[scope] ?? []));
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const [name, value] of Object.entries(claims)) {
|
|
55
|
+
if (allowed.has(name) && !RESERVED_CLAIMS.includes(name) && value !== undefined) {
|
|
56
|
+
out[name] = value;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/http/discovery.ts
|
|
63
|
+
import { DEFAULT_SIGNING_ALG } from "@softistx/janus-oauth";
|
|
64
|
+
|
|
65
|
+
// src/http/respond.ts
|
|
66
|
+
var NO_STORE = { "cache-control": "no-store", pragma: "no-cache" };
|
|
67
|
+
function privateJson(body, status = 200, headers = {}) {
|
|
68
|
+
return new Response(JSON.stringify(body), {
|
|
69
|
+
status,
|
|
70
|
+
headers: { "content-type": "application/json", ...NO_STORE, ...headers }
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function publicJson(body) {
|
|
74
|
+
return new Response(JSON.stringify(body), {
|
|
75
|
+
status: 200,
|
|
76
|
+
headers: {
|
|
77
|
+
"content-type": "application/json",
|
|
78
|
+
"cache-control": "public, max-age=300",
|
|
79
|
+
"access-control-allow-origin": "*"
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
var notFound = () => privateJson({ error: "not_found" }, 404);
|
|
84
|
+
var methodNotAllowed = (allow) => privateJson({
|
|
85
|
+
error: "invalid_request",
|
|
86
|
+
error_description: `use ${allow} on this endpoint`
|
|
87
|
+
}, 405, { allow });
|
|
88
|
+
|
|
89
|
+
// src/http/discovery.ts
|
|
90
|
+
var ID_TOKEN_CLAIMS = [
|
|
91
|
+
"sub",
|
|
92
|
+
"iss",
|
|
93
|
+
"aud",
|
|
94
|
+
"exp",
|
|
95
|
+
"iat",
|
|
96
|
+
"auth_time",
|
|
97
|
+
"nonce",
|
|
98
|
+
"at_hash",
|
|
99
|
+
"amr",
|
|
100
|
+
"acr"
|
|
101
|
+
];
|
|
102
|
+
async function discoveryDocument(ctx, oauth, metadata, userinfoEndpoint) {
|
|
103
|
+
if (oauth.jwks === undefined) {
|
|
104
|
+
throw new Error("createOidcProvider: the server issues opaque access tokens and has no JWKS: give createOAuthServer accessTokens: { format: 'jwt', keys }");
|
|
105
|
+
}
|
|
106
|
+
if (!oauth.scopes.includes("openid")) {
|
|
107
|
+
throw new Error("createOidcProvider: no resource of the server offers the 'openid' scope");
|
|
108
|
+
}
|
|
109
|
+
const published = [
|
|
110
|
+
...new Set((await oauth.jwks()).keys.map((key) => key.alg))
|
|
111
|
+
];
|
|
112
|
+
const algs = published.length === 0 ? [DEFAULT_SIGNING_ALG] : published;
|
|
113
|
+
return publicJson({
|
|
114
|
+
...metadata,
|
|
115
|
+
issuer: oauth.issuer,
|
|
116
|
+
userinfo_endpoint: userinfoEndpoint,
|
|
117
|
+
id_token_signing_alg_values_supported: algs,
|
|
118
|
+
subject_types_supported: ["public"],
|
|
119
|
+
response_types_supported: ["code"],
|
|
120
|
+
...ctx.acrValuesSupported.length === 0 ? {} : { acr_values_supported: [...ctx.acrValuesSupported] },
|
|
121
|
+
claim_types_supported: ["normal"],
|
|
122
|
+
claims_parameter_supported: false,
|
|
123
|
+
request_parameter_supported: false,
|
|
124
|
+
request_uri_parameter_supported: false,
|
|
125
|
+
claims_supported: [
|
|
126
|
+
...ID_TOKEN_CLAIMS,
|
|
127
|
+
...releasableClaims(ctx.scopeClaims)
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/http/urls.ts
|
|
133
|
+
var LOOPBACK = ["localhost", "127.0.0.1", "[::1]"];
|
|
134
|
+
function trimmed(pathname) {
|
|
135
|
+
return pathname === "/" ? "" : pathname.replace(/\/+$/, "");
|
|
136
|
+
}
|
|
137
|
+
function discoveryPath(issuer) {
|
|
138
|
+
return `/.well-known/openid-configuration${trimmed(new URL(issuer).pathname)}`;
|
|
139
|
+
}
|
|
140
|
+
function discoveryUrl(issuer) {
|
|
141
|
+
return `${new URL(issuer).origin}${discoveryPath(issuer)}`;
|
|
142
|
+
}
|
|
143
|
+
function userinfoUrl(issuer, configured) {
|
|
144
|
+
const base = new URL(issuer);
|
|
145
|
+
if (configured === undefined) {
|
|
146
|
+
return new URL(`${base.origin}${trimmed(base.pathname)}/userinfo`);
|
|
147
|
+
}
|
|
148
|
+
if (configured.startsWith("/")) {
|
|
149
|
+
if (configured.includes("#") || configured.startsWith("//")) {
|
|
150
|
+
throw new TypeError("createOidcProvider: paths.userinfo is not a path");
|
|
151
|
+
}
|
|
152
|
+
return new URL(configured, base.origin);
|
|
153
|
+
}
|
|
154
|
+
let url;
|
|
155
|
+
try {
|
|
156
|
+
url = new URL(configured);
|
|
157
|
+
} catch {
|
|
158
|
+
throw new TypeError("createOidcProvider: paths.userinfo is not a path or an absolute URL");
|
|
159
|
+
}
|
|
160
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && LOOPBACK.includes(url.hostname)) || configured.includes("#")) {
|
|
161
|
+
throw new TypeError("createOidcProvider: paths.userinfo must be an https: URL without a fragment (http: only for localhost)");
|
|
162
|
+
}
|
|
163
|
+
return url;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/http/userinfo.ts
|
|
167
|
+
var challenge = (params = "", scheme = "Bearer") => ({
|
|
168
|
+
"www-authenticate": `${scheme} realm="userinfo"${params}`
|
|
169
|
+
});
|
|
170
|
+
var quoted = (text) => text.replace(/[\\"]/g, "\\$&");
|
|
171
|
+
var descriptionOf = (refused) => refused.description === undefined ? "" : `, error_description="${quoted(refused.description)}"`;
|
|
172
|
+
var algsOf = (oauth) => oauth.dpop === false ? "" : `, algs="${oauth.dpop.algorithms.join(" ")}"`;
|
|
173
|
+
function unauthorized(oauth, refused) {
|
|
174
|
+
if (refused.error === "invalid_request") {
|
|
175
|
+
return privateJson({ error: "invalid_request" }, 401, challenge());
|
|
176
|
+
}
|
|
177
|
+
const algs = refused.scheme === "DPoP" ? algsOf(oauth) : "";
|
|
178
|
+
const body = refused.description === undefined ? { error: refused.error } : { error: refused.error, error_description: refused.description };
|
|
179
|
+
return privateJson(body, 401, {
|
|
180
|
+
...challenge(`, error="${refused.error}"${descriptionOf(refused)}${algs}`, refused.scheme),
|
|
181
|
+
...refused.nonce === undefined ? {} : { "dpop-nonce": refused.nonce }
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
async function userinfo(ctx, oauth, resource, request) {
|
|
185
|
+
if (request.method !== "GET" && request.method !== "POST") {
|
|
186
|
+
return methodNotAllowed("GET, POST");
|
|
187
|
+
}
|
|
188
|
+
const result = await oauth.authenticateRequest(request, { resource });
|
|
189
|
+
if ("refused" in result)
|
|
190
|
+
return unauthorized(oauth, result.refused);
|
|
191
|
+
const principal = result.ok;
|
|
192
|
+
if (!principal.scopes.includes("openid")) {
|
|
193
|
+
return privateJson({ error: "insufficient_scope" }, 403, principal.jkt === null ? challenge(', error="insufficient_scope", scope="openid"') : challenge(`, error="insufficient_scope"${algsOf(oauth)}, scope="openid"`, "DPoP"));
|
|
194
|
+
}
|
|
195
|
+
const claims = await ctx.claims({ id: principal.userId }, principal.scopes, {
|
|
196
|
+
issuer: oauth.issuer
|
|
197
|
+
});
|
|
198
|
+
return privateJson({
|
|
199
|
+
...releasedClaims(claims, principal.scopes, ctx.scopeClaims),
|
|
200
|
+
sub: principal.userId
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// src/http/handlers.ts
|
|
205
|
+
async function serverOf(ctx, source, request) {
|
|
206
|
+
const oauth = await source.serverFor(request);
|
|
207
|
+
if (oauth !== null && !ctx.hooked.has(oauth.issuer)) {
|
|
208
|
+
throw new Error(`createOidcProvider: no tokenResponse hook was made for this server's issuer: pass provider.tokenResponse({ issuer, keys }) to its createOAuthServer`);
|
|
209
|
+
}
|
|
210
|
+
return oauth;
|
|
211
|
+
}
|
|
212
|
+
function discoveryHandler(ctx, source) {
|
|
213
|
+
return async (request) => {
|
|
214
|
+
if (request.method !== "GET")
|
|
215
|
+
return methodNotAllowed("GET");
|
|
216
|
+
const oauth = await serverOf(ctx, source, request);
|
|
217
|
+
if (oauth === null || new URL(request.url).pathname !== discoveryPath(oauth.issuer)) {
|
|
218
|
+
return notFound();
|
|
219
|
+
}
|
|
220
|
+
return discoveryDocument(ctx, oauth, await source.metadata(request, oauth), userinfoUrl(oauth.issuer, ctx.userinfoPath).href);
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function userinfoHandler(ctx, source) {
|
|
224
|
+
return async (request) => {
|
|
225
|
+
const oauth = await serverOf(ctx, source, request);
|
|
226
|
+
if (oauth === null)
|
|
227
|
+
return notFound();
|
|
228
|
+
return userinfo(ctx, oauth, source.resource(oauth), request);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/http/source.ts
|
|
233
|
+
async function parsed(response) {
|
|
234
|
+
if (!response.ok) {
|
|
235
|
+
throw new Error(`createOidcProvider: the OAuth metadata endpoint answered ${response.status}`);
|
|
236
|
+
}
|
|
237
|
+
return await response.json();
|
|
238
|
+
}
|
|
239
|
+
function singleSource(oauth, endpoints, resource) {
|
|
240
|
+
return {
|
|
241
|
+
serverFor: async () => oauth,
|
|
242
|
+
metadata: async () => parsed(await endpoints.metadata(new Request(endpoints.urls.metadata))),
|
|
243
|
+
resource: () => resource
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function issuersSource(issuers, resource) {
|
|
247
|
+
return {
|
|
248
|
+
serverFor: (request) => issuers.serverFor(request),
|
|
249
|
+
async metadata(request, oauth) {
|
|
250
|
+
const issuer = new URL(oauth.issuer);
|
|
251
|
+
const path = `/.well-known/oauth-authorization-server${issuer.pathname === "/" ? "" : issuer.pathname.replace(/\/+$/, "")}`;
|
|
252
|
+
return parsed(await issuers.handle(new Request(new URL(path, request.url), { headers: request.headers })));
|
|
253
|
+
},
|
|
254
|
+
resource: (oauth) => typeof resource === "function" ? resource(oauth.issuer) : resource
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// src/id-token/hook.ts
|
|
259
|
+
import {
|
|
260
|
+
TOKEN_EXCHANGE_GRANT
|
|
261
|
+
} from "@softistx/janus-oauth";
|
|
262
|
+
|
|
263
|
+
// src/id-token/at-hash.ts
|
|
264
|
+
import { base64url } from "jose";
|
|
265
|
+
var hashOf = (alg) => alg === "EdDSA" ? "SHA-512" : "SHA-256";
|
|
266
|
+
async function atHash(alg, accessToken) {
|
|
267
|
+
const digest = await crypto.subtle.digest(hashOf(alg), new TextEncoder().encode(accessToken));
|
|
268
|
+
return base64url.encode(new Uint8Array(digest).slice(0, digest.byteLength / 2));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// src/id-token/sign.ts
|
|
272
|
+
import {
|
|
273
|
+
NoSigningKeyError
|
|
274
|
+
} from "@softistx/janus-oauth";
|
|
275
|
+
import { importJWK, SignJWT } from "jose";
|
|
276
|
+
async function currentKey(keys, now) {
|
|
277
|
+
const key = await keys.findCurrentKey(now);
|
|
278
|
+
if (key === null) {
|
|
279
|
+
throw new NoSigningKeyError("createOidcProvider: no current signing key: run rotateSigningKeys before issuing ID Tokens");
|
|
280
|
+
}
|
|
281
|
+
return key;
|
|
282
|
+
}
|
|
283
|
+
async function signIdToken(key, claims) {
|
|
284
|
+
const secret = await importJWK({ ...key.privateJwk }, key.alg);
|
|
285
|
+
return new SignJWT({ ...claims.extra }).setProtectedHeader({ alg: key.alg, typ: "JWT", kid: key.kid }).setIssuer(claims.iss).setSubject(claims.sub).setAudience(claims.aud).setIssuedAt(claims.iat).setExpirationTime(claims.exp).sign(secret);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// src/id-token/hook.ts
|
|
289
|
+
function authenticationClaims(c) {
|
|
290
|
+
return {
|
|
291
|
+
...c.authTime === undefined ? {} : { auth_time: Math.floor(c.authTime.getTime() / 1000) },
|
|
292
|
+
...c.nonce === undefined || c.grantType === "refresh_token" ? {} : { nonce: c.nonce },
|
|
293
|
+
...c.amr === undefined ? {} : { amr: [...c.amr] },
|
|
294
|
+
...c.acr === undefined ? {} : { acr: c.acr }
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function idTokenHook(ctx) {
|
|
298
|
+
return async (c) => {
|
|
299
|
+
if (c.issuer !== ctx.issuer) {
|
|
300
|
+
throw new TypeError(`createOidcProvider: the provider was wired for another issuer than the OAuth server's; the id_token would carry the wrong iss`);
|
|
301
|
+
}
|
|
302
|
+
if (c.grantType === TOKEN_EXCHANGE_GRANT)
|
|
303
|
+
return;
|
|
304
|
+
if (!c.scopes.includes("openid"))
|
|
305
|
+
return;
|
|
306
|
+
const key = await currentKey(ctx.keys, c.issuedAt);
|
|
307
|
+
const scopeClaims = ctx.includeClaims ? releasedClaims(await ctx.claims({ id: c.user.id }, c.scopes, {
|
|
308
|
+
issuer: ctx.issuer
|
|
309
|
+
}), c.scopes, ctx.scopeClaims) : {};
|
|
310
|
+
const lifetimeMs = ctx.lifetimeMs ?? c.tokens.expiresIn * 1000;
|
|
311
|
+
const idToken = await signIdToken(key, {
|
|
312
|
+
iss: ctx.issuer,
|
|
313
|
+
sub: c.user.id,
|
|
314
|
+
aud: c.client.id,
|
|
315
|
+
iat: c.issuedAt,
|
|
316
|
+
exp: new Date(c.issuedAt.getTime() + lifetimeMs),
|
|
317
|
+
extra: {
|
|
318
|
+
...scopeClaims,
|
|
319
|
+
...authenticationClaims(c),
|
|
320
|
+
at_hash: await atHash(key.alg, c.tokens.accessToken)
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
return { id_token: idToken };
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/create.ts
|
|
328
|
+
function checkedOptions(options) {
|
|
329
|
+
if (typeof options.claims !== "function") {
|
|
330
|
+
throw new TypeError("createOidcProvider: claims must be a function");
|
|
331
|
+
}
|
|
332
|
+
const acr = options.acrValuesSupported;
|
|
333
|
+
if (acr !== undefined && (!Array.isArray(acr) || acr.some((one) => typeof one !== "string" || one === "" || /\s/.test(one)))) {
|
|
334
|
+
throw new TypeError("createOidcProvider: acrValuesSupported must be a list of non-empty values without spaces");
|
|
335
|
+
}
|
|
336
|
+
for (const [scope, names] of Object.entries(options.scopeClaims ?? {})) {
|
|
337
|
+
if (!Array.isArray(names) || names.some((n) => typeof n !== "string")) {
|
|
338
|
+
throw new TypeError(`createOidcProvider: scopeClaims.${scope} must be a list of claim names`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function routeOf(request, issuer, userinfoPath) {
|
|
343
|
+
const path = new URL(request.url).pathname;
|
|
344
|
+
if (path === discoveryPath(issuer))
|
|
345
|
+
return "discovery";
|
|
346
|
+
if (path === userinfoUrl(issuer, userinfoPath).pathname)
|
|
347
|
+
return "userinfo";
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
function issuersOf(ctx, source) {
|
|
351
|
+
const discovery = discoveryHandler(ctx, source);
|
|
352
|
+
const userinfo = userinfoHandler(ctx, source);
|
|
353
|
+
return {
|
|
354
|
+
async handle(request) {
|
|
355
|
+
const oauth = await source.serverFor(request);
|
|
356
|
+
if (oauth === null)
|
|
357
|
+
return null;
|
|
358
|
+
const route = routeOf(request, oauth.issuer, ctx.userinfoPath);
|
|
359
|
+
if (route === null)
|
|
360
|
+
return null;
|
|
361
|
+
return route === "discovery" ? discovery(request) : userinfo(request);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function endpointsOf(ctx, oauth, oauthEndpoints, resource) {
|
|
366
|
+
if (oauth.jwks === undefined) {
|
|
367
|
+
throw new TypeError("createOidcProvider: the server has no JWKS: give createOAuthServer accessTokens: { format: 'jwt', keys }");
|
|
368
|
+
}
|
|
369
|
+
if (!ctx.hooked.has(oauth.issuer)) {
|
|
370
|
+
throw new TypeError(`createOidcProvider: no tokenResponse hook was made for this server's issuer: pass provider.tokenResponse({ issuer, keys }) to its createOAuthServer`);
|
|
371
|
+
}
|
|
372
|
+
const source = singleSource(oauth, oauthEndpoints, resource);
|
|
373
|
+
const discovery = discoveryHandler(ctx, source);
|
|
374
|
+
const userinfo = userinfoHandler(ctx, source);
|
|
375
|
+
const userinfoAt = userinfoUrl(oauth.issuer, ctx.userinfoPath);
|
|
376
|
+
return {
|
|
377
|
+
discovery,
|
|
378
|
+
userinfo,
|
|
379
|
+
urls: { discovery: discoveryUrl(oauth.issuer), userinfo: userinfoAt.href },
|
|
380
|
+
routes: [
|
|
381
|
+
{ method: "GET", path: discoveryPath(oauth.issuer), handler: discovery },
|
|
382
|
+
{ method: "GET", path: userinfoAt.pathname, handler: userinfo },
|
|
383
|
+
{ method: "POST", path: userinfoAt.pathname, handler: userinfo }
|
|
384
|
+
]
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function createOidcProvider(options) {
|
|
388
|
+
checkedOptions(options);
|
|
389
|
+
const lifetime = options.idToken?.lifetime;
|
|
390
|
+
const lifetimeMs = lifetime === undefined ? null : parseDuration(lifetime, "idToken.lifetime");
|
|
391
|
+
const base = {
|
|
392
|
+
claims: options.claims,
|
|
393
|
+
scopeClaims: mergedScopeClaims(options.scopeClaims),
|
|
394
|
+
userinfoPath: options.paths?.userinfo,
|
|
395
|
+
acrValuesSupported: [...new Set(options.acrValuesSupported ?? [])],
|
|
396
|
+
hooked: new Set
|
|
397
|
+
};
|
|
398
|
+
if (options.paths?.userinfo !== undefined) {
|
|
399
|
+
userinfoUrl("https://issuer.invalid", options.paths.userinfo);
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
tokenResponse({ issuer, keys }) {
|
|
403
|
+
assertSigningKeyStore(keys, "createOidcProvider: keys");
|
|
404
|
+
base.hooked.add(issuer);
|
|
405
|
+
return idTokenHook({
|
|
406
|
+
issuer,
|
|
407
|
+
keys,
|
|
408
|
+
lifetimeMs,
|
|
409
|
+
includeClaims: options.idToken?.includeClaims ?? false,
|
|
410
|
+
scopeClaims: base.scopeClaims,
|
|
411
|
+
claims: base.claims
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
endpoints: (oauth, oauthEndpoints, { resource }) => endpointsOf(base, oauth, oauthEndpoints, resource),
|
|
415
|
+
issuers: (issuers, { resource }) => issuersOf(base, issuersSource(issuers, resource))
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
export {
|
|
419
|
+
createOidcProvider
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
//# debugId=8EF503E1E5684FE364756E2164756E21
|
|
423
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/create.ts", "../src/claims/scopes.ts", "../src/http/discovery.ts", "../src/http/respond.ts", "../src/http/urls.ts", "../src/http/userinfo.ts", "../src/http/handlers.ts", "../src/http/source.ts", "../src/id-token/hook.ts", "../src/id-token/at-hash.ts", "../src/id-token/sign.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { parseDuration } from '@softistx/janus';\nimport {\n\tassertSigningKeyStore,\n\ttype OAuthEndpoints,\n\ttype OAuthServer,\n} from '@softistx/janus-oauth';\nimport { mergedScopeClaims } from './claims/scopes';\nimport {\n\tdiscoveryHandler,\n\ttype HandlerContext,\n\tuserinfoHandler,\n} from './http/handlers';\nimport { issuersSource, type ServerSource, singleSource } from './http/source';\nimport { discoveryPath, discoveryUrl, userinfoUrl } from './http/urls';\nimport { idTokenHook } from './id-token/hook';\nimport type {\n\tOidcEndpoints,\n\tOidcIssuers,\n\tOidcProvider,\n\tOidcProviderOptions,\n} from './types';\n\nfunction checkedOptions(options: OidcProviderOptions): void {\n\tif (typeof options.claims !== 'function') {\n\t\tthrow new TypeError('createOidcProvider: claims must be a function');\n\t}\n\tconst acr = options.acrValuesSupported;\n\tif (\n\t\tacr !== undefined &&\n\t\t(!Array.isArray(acr) ||\n\t\t\tacr.some(\n\t\t\t\t(one) => typeof one !== 'string' || one === '' || /\\s/.test(one),\n\t\t\t))\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'createOidcProvider: acrValuesSupported must be a list of non-empty values without spaces',\n\t\t);\n\t}\n\tfor (const [scope, names] of Object.entries(options.scopeClaims ?? {})) {\n\t\tif (!Array.isArray(names) || names.some((n) => typeof n !== 'string')) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`createOidcProvider: scopeClaims.${scope} must be a list of claim names`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Requests the two routes of one issuer answer, by pathname; `null` for any other. */\nfunction routeOf(\n\trequest: Request,\n\tissuer: string,\n\tuserinfoPath: string | undefined,\n): 'discovery' | 'userinfo' | null {\n\tconst path = new URL(request.url).pathname;\n\tif (path === discoveryPath(issuer)) return 'discovery';\n\tif (path === userinfoUrl(issuer, userinfoPath).pathname) return 'userinfo';\n\treturn null;\n}\n\nfunction issuersOf(ctx: HandlerContext, source: ServerSource): OidcIssuers {\n\tconst discovery = discoveryHandler(ctx, source);\n\tconst userinfo = userinfoHandler(ctx, source);\n\treturn {\n\t\tasync handle(request) {\n\t\t\tconst oauth = await source.serverFor(request);\n\t\t\tif (oauth === null) return null;\n\t\t\tconst route = routeOf(request, oauth.issuer, ctx.userinfoPath);\n\t\t\tif (route === null) return null;\n\t\t\treturn route === 'discovery' ? discovery(request) : userinfo(request);\n\t\t},\n\t};\n}\n\nfunction endpointsOf(\n\tctx: HandlerContext,\n\toauth: OAuthServer,\n\toauthEndpoints: OAuthEndpoints,\n\tresource: string,\n): OidcEndpoints {\n\tif (oauth.jwks === undefined) {\n\t\tthrow new TypeError(\n\t\t\t\"createOidcProvider: the server has no JWKS: give createOAuthServer accessTokens: { format: 'jwt', keys }\",\n\t\t);\n\t}\n\tif (!ctx.hooked.has(oauth.issuer)) {\n\t\tthrow new TypeError(\n\t\t\t`createOidcProvider: no tokenResponse hook was made for this server's issuer: pass provider.tokenResponse({ issuer, keys }) to its createOAuthServer`,\n\t\t);\n\t}\n\tconst source = singleSource(oauth, oauthEndpoints, resource);\n\tconst discovery = discoveryHandler(ctx, source);\n\tconst userinfo = userinfoHandler(ctx, source);\n\tconst userinfoAt = userinfoUrl(oauth.issuer, ctx.userinfoPath);\n\treturn {\n\t\tdiscovery,\n\t\tuserinfo,\n\t\turls: { discovery: discoveryUrl(oauth.issuer), userinfo: userinfoAt.href },\n\t\troutes: [\n\t\t\t{ method: 'GET', path: discoveryPath(oauth.issuer), handler: discovery },\n\t\t\t{ method: 'GET', path: userinfoAt.pathname, handler: userinfo },\n\t\t\t{ method: 'POST', path: userinfoAt.pathname, handler: userinfo },\n\t\t],\n\t};\n}\n\n/**\n * An OpenID Connect provider on top of `@softistx/janus-oauth`: the\n * `tokenResponse` hook that adds `id_token`, and the userinfo and discovery\n * handlers. It holds no state of its own beyond the issuers it made a hook\n * for. Wrong options are a `TypeError`, at wiring time.\n *\n * ```ts\n * const oidc = createOidcProvider({ claims: async ({ id }) => profileOf(id) });\n * const oauth = createOAuthServer({\n * …,\n * accessTokens: { format: 'jwt', keys },\n * tokenResponse: oidc.tokenResponse({ issuer, keys }),\n * });\n * const { routes } = oidc.endpoints(oauth, endpoints, { resource });\n * ```\n */\nexport function createOidcProvider(options: OidcProviderOptions): OidcProvider {\n\tcheckedOptions(options);\n\tconst lifetime = options.idToken?.lifetime;\n\tconst lifetimeMs =\n\t\tlifetime === undefined ? null : parseDuration(lifetime, 'idToken.lifetime');\n\tconst base = {\n\t\tclaims: options.claims,\n\t\tscopeClaims: mergedScopeClaims(options.scopeClaims),\n\t\tuserinfoPath: options.paths?.userinfo,\n\t\tacrValuesSupported: [...new Set(options.acrValuesSupported ?? [])],\n\t\thooked: new Set<string>(),\n\t};\n\tif (options.paths?.userinfo !== undefined) {\n\t\tuserinfoUrl('https://issuer.invalid', options.paths.userinfo);\n\t}\n\treturn {\n\t\ttokenResponse({ issuer, keys }) {\n\t\t\tassertSigningKeyStore(keys, 'createOidcProvider: keys');\n\t\t\tbase.hooked.add(issuer);\n\t\t\treturn idTokenHook({\n\t\t\t\tissuer,\n\t\t\t\tkeys,\n\t\t\t\tlifetimeMs,\n\t\t\t\tincludeClaims: options.idToken?.includeClaims ?? false,\n\t\t\t\tscopeClaims: base.scopeClaims,\n\t\t\t\tclaims: base.claims,\n\t\t\t});\n\t\t},\n\t\tendpoints: (oauth, oauthEndpoints, { resource }) =>\n\t\t\tendpointsOf(base, oauth, oauthEndpoints, resource),\n\t\tissuers: (issuers, { resource }) =>\n\t\t\tissuersOf(base, issuersSource(issuers, resource)),\n\t};\n}\n",
|
|
6
|
+
"/** Which claims a scope releases (OpenID Connect Core §5.4), and the filter that applies it. */\n\nexport const STANDARD_SCOPE_CLAIMS: Readonly<\n\tRecord<string, readonly string[]>\n> = {\n\tprofile: [\n\t\t'name',\n\t\t'family_name',\n\t\t'given_name',\n\t\t'middle_name',\n\t\t'nickname',\n\t\t'preferred_username',\n\t\t'profile',\n\t\t'picture',\n\t\t'website',\n\t\t'gender',\n\t\t'birthdate',\n\t\t'zoneinfo',\n\t\t'locale',\n\t\t'updated_at',\n\t],\n\temail: ['email', 'email_verified'],\n\taddress: ['address'],\n\tphone: ['phone_number', 'phone_number_verified'],\n};\n\n/** Claims the provider writes itself: a `claims` function can never set them. */\nexport const RESERVED_CLAIMS: readonly string[] = [\n\t'iss',\n\t'sub',\n\t'aud',\n\t'exp',\n\t'iat',\n\t'nbf',\n\t'jti',\n\t'auth_time',\n\t'nonce',\n\t'at_hash',\n\t'c_hash',\n\t'amr',\n\t'acr',\n\t'azp',\n];\n\n/** The standard table with the application's own scopes added (theirs win for a scope both name). */\nexport function mergedScopeClaims(\n\town: Readonly<Record<string, readonly string[]>> | undefined,\n): Readonly<Record<string, readonly string[]>> {\n\treturn { ...STANDARD_SCOPE_CLAIMS, ...own };\n}\n\n/** Every claim name any scope releases, sorted. */\nexport function releasableClaims(\n\ttable: Readonly<Record<string, readonly string[]>>,\n): string[] {\n\treturn [...new Set(Object.values(table).flat())]\n\t\t.filter((name) => !RESERVED_CLAIMS.includes(name))\n\t\t.sort();\n}\n\n/**\n * The claims the granted scopes release: a claim no scope names, a reserved\n * one and an `undefined` are dropped, so `claims` can return everything it\n * knows.\n */\nexport function releasedClaims(\n\tclaims: Readonly<Record<string, unknown>>,\n\tscopes: readonly string[],\n\ttable: Readonly<Record<string, readonly string[]>>,\n): Record<string, unknown> {\n\tconst allowed = new Set(scopes.flatMap((scope) => table[scope] ?? []));\n\tconst out: Record<string, unknown> = {};\n\tfor (const [name, value] of Object.entries(claims)) {\n\t\tif (\n\t\t\tallowed.has(name) &&\n\t\t\t!RESERVED_CLAIMS.includes(name) &&\n\t\t\tvalue !== undefined\n\t\t) {\n\t\t\tout[name] = value;\n\t\t}\n\t}\n\treturn out;\n}\n",
|
|
7
|
+
"/** The discovery document (OpenID Connect Discovery §3): the OAuth metadata plus what OpenID Connect adds. */\n\nimport { DEFAULT_SIGNING_ALG, type OAuthServer } from '@softistx/janus-oauth';\nimport { releasableClaims } from '../claims/scopes';\nimport { publicJson } from './respond';\n\nexport interface DiscoveryContext {\n\treadonly scopeClaims: Readonly<Record<string, readonly string[]>>;\n\treadonly acrValuesSupported: readonly string[];\n}\n\nconst ID_TOKEN_CLAIMS = [\n\t'sub',\n\t'iss',\n\t'aud',\n\t'exp',\n\t'iat',\n\t'auth_time',\n\t'nonce',\n\t'at_hash',\n\t'amr',\n\t'acr',\n];\n\n/**\n * `metadata` is the OAuth document of the same issuer, merged under the\n * OpenID Connect members. Throws when the server cannot do OpenID Connect:\n * no JWKS (access tokens are opaque) or no `openid` scope on any resource.\n */\nexport async function discoveryDocument(\n\tctx: DiscoveryContext,\n\toauth: OAuthServer,\n\tmetadata: Readonly<Record<string, unknown>>,\n\tuserinfoEndpoint: string,\n): Promise<Response> {\n\tif (oauth.jwks === undefined) {\n\t\tthrow new Error(\n\t\t\t\"createOidcProvider: the server issues opaque access tokens and has no JWKS: give createOAuthServer accessTokens: { format: 'jwt', keys }\",\n\t\t);\n\t}\n\tif (!oauth.scopes.includes('openid')) {\n\t\tthrow new Error(\n\t\t\t\"createOidcProvider: no resource of the server offers the 'openid' scope\",\n\t\t);\n\t}\n\tconst published = [\n\t\t...new Set((await oauth.jwks()).keys.map((key) => key.alg)),\n\t];\n\t// No key published yet: the algorithm the first rotation generates by default.\n\tconst algs = published.length === 0 ? [DEFAULT_SIGNING_ALG] : published;\n\treturn publicJson({\n\t\t...metadata,\n\t\tissuer: oauth.issuer,\n\t\tuserinfo_endpoint: userinfoEndpoint,\n\t\tid_token_signing_alg_values_supported: algs,\n\t\tsubject_types_supported: ['public'],\n\t\tresponse_types_supported: ['code'],\n\t\t...(ctx.acrValuesSupported.length === 0\n\t\t\t? {}\n\t\t\t: { acr_values_supported: [...ctx.acrValuesSupported] }),\n\t\tclaim_types_supported: ['normal'],\n\t\tclaims_parameter_supported: false,\n\t\trequest_parameter_supported: false,\n\t\trequest_uri_parameter_supported: false,\n\t\tclaims_supported: [\n\t\t\t...ID_TOKEN_CLAIMS,\n\t\t\t...releasableClaims(ctx.scopeClaims),\n\t\t],\n\t});\n}\n",
|
|
8
|
+
"/** The JSON answers of the discovery and userinfo endpoints. */\n\nconst NO_STORE = { 'cache-control': 'no-store', pragma: 'no-cache' } as const;\n\n/** A userinfo answer: it names a user, so it is never cached. */\nexport function privateJson(\n\tbody: unknown,\n\tstatus = 200,\n\theaders: Readonly<Record<string, string>> = {},\n): Response {\n\treturn new Response(JSON.stringify(body), {\n\t\tstatus,\n\t\theaders: { 'content-type': 'application/json', ...NO_STORE, ...headers },\n\t});\n}\n\n/** The discovery document: public, cacheable, readable from any origin. */\nexport function publicJson(body: unknown): Response {\n\treturn new Response(JSON.stringify(body), {\n\t\tstatus: 200,\n\t\theaders: {\n\t\t\t'content-type': 'application/json',\n\t\t\t'cache-control': 'public, max-age=300',\n\t\t\t'access-control-allow-origin': '*',\n\t\t},\n\t});\n}\n\nexport const notFound = (): Response =>\n\tprivateJson({ error: 'not_found' }, 404);\n\nexport const methodNotAllowed = (allow: string): Response =>\n\tprivateJson(\n\t\t{\n\t\t\terror: 'invalid_request',\n\t\t\terror_description: `use ${allow} on this endpoint`,\n\t\t},\n\t\t405,\n\t\t{ allow },\n\t);\n",
|
|
9
|
+
"/** Where the OpenID Connect endpoints live, derived from the issuer like the OAuth ones. */\n\nconst LOOPBACK = ['localhost', '127.0.0.1', '[::1]'];\n\nfunction trimmed(pathname: string): string {\n\treturn pathname === '/' ? '' : pathname.replace(/\\/+$/, '');\n}\n\n/** `/.well-known/openid-configuration` with the issuer's path appended (Discovery §4.1). */\nexport function discoveryPath(issuer: string): string {\n\treturn `/.well-known/openid-configuration${trimmed(new URL(issuer).pathname)}`;\n}\n\nexport function discoveryUrl(issuer: string): string {\n\treturn `${new URL(issuer).origin}${discoveryPath(issuer)}`;\n}\n\n/** Userinfo: a path from the origin, an absolute URL, or `<issuer>/userinfo`. */\nexport function userinfoUrl(issuer: string, configured?: string): URL {\n\tconst base = new URL(issuer);\n\tif (configured === undefined) {\n\t\treturn new URL(`${base.origin}${trimmed(base.pathname)}/userinfo`);\n\t}\n\tif (configured.startsWith('/')) {\n\t\tif (configured.includes('#') || configured.startsWith('//')) {\n\t\t\tthrow new TypeError('createOidcProvider: paths.userinfo is not a path');\n\t\t}\n\t\treturn new URL(configured, base.origin);\n\t}\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(configured);\n\t} catch {\n\t\tthrow new TypeError(\n\t\t\t'createOidcProvider: paths.userinfo is not a path or an absolute URL',\n\t\t);\n\t}\n\tif (\n\t\t(url.protocol !== 'https:' &&\n\t\t\t!(url.protocol === 'http:' && LOOPBACK.includes(url.hostname))) ||\n\t\tconfigured.includes('#')\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'createOidcProvider: paths.userinfo must be an https: URL without a fragment (http: only for localhost)',\n\t\t);\n\t}\n\treturn url;\n}\n",
|
|
10
|
+
"/** The userinfo endpoint (OpenID Connect Core §5.3): a bearer or DPoP token in, the released claims out. */\n\nimport type { OAuthRefusal, OAuthServer } from '@softistx/janus-oauth';\nimport { releasedClaims } from '../claims/scopes';\nimport type { OidcClaims, OidcClaimsContext, OidcSubject } from '../types';\nimport { methodNotAllowed, privateJson } from './respond';\n\nexport interface UserinfoContext {\n\treadonly scopeClaims: Readonly<Record<string, readonly string[]>>;\n\treadonly claims: (\n\t\tuser: OidcSubject,\n\t\tscopes: readonly string[],\n\t\tcontext: OidcClaimsContext,\n\t) => OidcClaims | Promise<OidcClaims>;\n}\n\nconst challenge = (\n\tparams = '',\n\tscheme: 'Bearer' | 'DPoP' = 'Bearer',\n): Record<string, string> => ({\n\t'www-authenticate': `${scheme} realm=\"userinfo\"${params}`,\n});\n\n/** RFC 7230 quoted-string: a backslash before `\\\\` and `\"`. */\nconst quoted = (text: string): string => text.replace(/[\\\\\"]/g, '\\\\$&');\n\n/** The `error_description` of a refused proof: the failed check, never the proof. */\nconst descriptionOf = (refused: OAuthRefusal): string =>\n\trefused.description === undefined\n\t\t? ''\n\t\t: `, error_description=\"${quoted(refused.description)}\"`;\n\n/** The `algs` challenge parameter of a DPoP challenge. */\nconst algsOf = (oauth: OAuthServer): string =>\n\toauth.dpop === false ? '' : `, algs=\"${oauth.dpop.algorithms.join(' ')}\"`;\n\n/**\n * RFC 6750 §3: no credentials gets a bare challenge, a refused token its\n * error. A DPoP refusal (RFC 9449 §7.1) answers the `DPoP` scheme with the\n * algorithms the server accepts, and the nonce to retry with.\n */\nfunction unauthorized(oauth: OAuthServer, refused: OAuthRefusal): Response {\n\tif (refused.error === 'invalid_request') {\n\t\treturn privateJson({ error: 'invalid_request' }, 401, challenge());\n\t}\n\tconst algs = refused.scheme === 'DPoP' ? algsOf(oauth) : '';\n\tconst body =\n\t\trefused.description === undefined\n\t\t\t? { error: refused.error }\n\t\t\t: { error: refused.error, error_description: refused.description };\n\treturn privateJson(body, 401, {\n\t\t...challenge(\n\t\t\t`, error=\"${refused.error}\"${descriptionOf(refused)}${algs}`,\n\t\t\trefused.scheme,\n\t\t),\n\t\t...(refused.nonce === undefined ? {} : { 'dpop-nonce': refused.nonce }),\n\t});\n}\n\n/**\n * `sub` and the claims the token's scopes release. A token for another\n * resource, a lapsed or revoked one, or a deactivated user is a 401; a token\n * without `openid` is a 403 `insufficient_scope`. A store or `claims` failure\n * rejects: answer 503, never 401.\n */\nexport async function userinfo(\n\tctx: UserinfoContext,\n\toauth: OAuthServer,\n\tresource: string,\n\trequest: Request,\n): Promise<Response> {\n\tif (request.method !== 'GET' && request.method !== 'POST') {\n\t\treturn methodNotAllowed('GET, POST');\n\t}\n\tconst result = await oauth.authenticateRequest(request, { resource });\n\tif ('refused' in result) return unauthorized(oauth, result.refused);\n\tconst principal = result.ok;\n\tif (!principal.scopes.includes('openid')) {\n\t\treturn privateJson(\n\t\t\t{ error: 'insufficient_scope' },\n\t\t\t403,\n\t\t\tprincipal.jkt === null\n\t\t\t\t? challenge(', error=\"insufficient_scope\", scope=\"openid\"')\n\t\t\t\t: challenge(\n\t\t\t\t\t\t`, error=\"insufficient_scope\"${algsOf(oauth)}, scope=\"openid\"`,\n\t\t\t\t\t\t'DPoP',\n\t\t\t\t\t),\n\t\t);\n\t}\n\tconst claims = await ctx.claims({ id: principal.userId }, principal.scopes, {\n\t\tissuer: oauth.issuer,\n\t});\n\treturn privateJson({\n\t\t...releasedClaims(claims, principal.scopes, ctx.scopeClaims),\n\t\tsub: principal.userId,\n\t});\n}\n",
|
|
11
|
+
"/** The two handlers over a `ServerSource`; each is one function. */\n\nimport type { OAuthHandler } from '@softistx/janus-oauth';\nimport type { OidcClaims, OidcClaimsContext, OidcSubject } from '../types';\nimport { discoveryDocument } from './discovery';\nimport { methodNotAllowed, notFound } from './respond';\nimport type { ServerSource } from './source';\nimport { discoveryPath, userinfoUrl } from './urls';\nimport { userinfo } from './userinfo';\n\nexport interface HandlerContext {\n\treadonly scopeClaims: Readonly<Record<string, readonly string[]>>;\n\treadonly claims: (\n\t\tuser: OidcSubject,\n\t\tscopes: readonly string[],\n\t\tcontext: OidcClaimsContext,\n\t) => OidcClaims | Promise<OidcClaims>;\n\treadonly userinfoPath: string | undefined;\n\t/** The `acr_values_supported` discovery publishes; empty publishes none. */\n\treadonly acrValuesSupported: readonly string[];\n\t/** The issuers a `tokenResponse` hook was made for: a server of another one signs no ID Token. */\n\treadonly hooked: ReadonlySet<string>;\n}\n\nasync function serverOf(\n\tctx: HandlerContext,\n\tsource: ServerSource,\n\trequest: Request,\n) {\n\tconst oauth = await source.serverFor(request);\n\tif (oauth !== null && !ctx.hooked.has(oauth.issuer)) {\n\t\tthrow new Error(\n\t\t\t`createOidcProvider: no tokenResponse hook was made for this server's issuer: pass provider.tokenResponse({ issuer, keys }) to its createOAuthServer`,\n\t\t);\n\t}\n\treturn oauth;\n}\n\nexport function discoveryHandler(\n\tctx: HandlerContext,\n\tsource: ServerSource,\n): OAuthHandler {\n\treturn async (request) => {\n\t\tif (request.method !== 'GET') return methodNotAllowed('GET');\n\t\tconst oauth = await serverOf(ctx, source, request);\n\t\tif (\n\t\t\toauth === null ||\n\t\t\tnew URL(request.url).pathname !== discoveryPath(oauth.issuer)\n\t\t) {\n\t\t\treturn notFound();\n\t\t}\n\t\treturn discoveryDocument(\n\t\t\tctx,\n\t\t\toauth,\n\t\t\tawait source.metadata(request, oauth),\n\t\t\tuserinfoUrl(oauth.issuer, ctx.userinfoPath).href,\n\t\t);\n\t};\n}\n\nexport function userinfoHandler(\n\tctx: HandlerContext,\n\tsource: ServerSource,\n): OAuthHandler {\n\treturn async (request) => {\n\t\tconst oauth = await serverOf(ctx, source, request);\n\t\tif (oauth === null) return notFound();\n\t\treturn userinfo(ctx, oauth, source.resource(oauth), request);\n\t};\n}\n",
|
|
12
|
+
"/** Where a request's server and its OAuth metadata come from: one server, or several issuers. */\n\nimport type {\n\tOAuthEndpoints,\n\tOAuthIssuers,\n\tOAuthServer,\n} from '@softistx/janus-oauth';\n\nexport interface ServerSource {\n\t/** The request's server, or `null` for a request no issuer claims. */\n\tserverFor(request: Request): Promise<OAuthServer | null>;\n\t/** The server's RFC 8414 document. */\n\tmetadata(\n\t\trequest: Request,\n\t\toauth: OAuthServer,\n\t): Promise<Record<string, unknown>>;\n\t/** The resource userinfo accepts tokens for. */\n\tresource(oauth: OAuthServer): string;\n}\n\nasync function parsed(response: Response): Promise<Record<string, unknown>> {\n\tif (!response.ok) {\n\t\tthrow new Error(\n\t\t\t`createOidcProvider: the OAuth metadata endpoint answered ${response.status}`,\n\t\t);\n\t}\n\treturn (await response.json()) as Record<string, unknown>;\n}\n\nexport function singleSource(\n\toauth: OAuthServer,\n\tendpoints: OAuthEndpoints,\n\tresource: string,\n): ServerSource {\n\treturn {\n\t\tserverFor: async () => oauth,\n\t\tmetadata: async () =>\n\t\t\tparsed(await endpoints.metadata(new Request(endpoints.urls.metadata))),\n\t\tresource: () => resource,\n\t};\n}\n\nexport function issuersSource(\n\tissuers: OAuthIssuers,\n\tresource: string | ((issuer: string) => string),\n): ServerSource {\n\treturn {\n\t\tserverFor: (request) => issuers.serverFor(request),\n\t\tasync metadata(request, oauth) {\n\t\t\tconst issuer = new URL(oauth.issuer);\n\t\t\tconst path = `/.well-known/oauth-authorization-server${\n\t\t\t\tissuer.pathname === '/' ? '' : issuer.pathname.replace(/\\/+$/, '')\n\t\t\t}`;\n\t\t\treturn parsed(\n\t\t\t\tawait issuers.handle(\n\t\t\t\t\tnew Request(new URL(path, request.url), { headers: request.headers }),\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t\tresource: (oauth) =>\n\t\t\ttypeof resource === 'function' ? resource(oauth.issuer) : resource,\n\t};\n}\n",
|
|
13
|
+
"/** The `tokenResponse` hook: one function, `id_token` for a grant that includes `openid`, except the token-exchange grant, which gets none even with `openid`. */\n\nimport {\n\ttype OAuthTokenResponseContext,\n\ttype OAuthTokenResponseHook,\n\ttype SigningKeyStore,\n\tTOKEN_EXCHANGE_GRANT,\n} from '@softistx/janus-oauth';\nimport { releasedClaims } from '../claims/scopes';\nimport type { OidcClaims, OidcClaimsContext, OidcSubject } from '../types';\nimport { atHash } from './at-hash';\nimport { currentKey, signIdToken } from './sign';\n\n/** Data only: what the hook reads, validated once at wiring. */\nexport interface IdTokenContext {\n\treadonly issuer: string;\n\treadonly keys: SigningKeyStore;\n\t/** `null`: the access token's `expires_in`. */\n\treadonly lifetimeMs: number | null;\n\treadonly includeClaims: boolean;\n\treadonly scopeClaims: Readonly<Record<string, readonly string[]>>;\n\treadonly claims: (\n\t\tuser: OidcSubject,\n\t\tscopes: readonly string[],\n\t\tcontext: OidcClaimsContext,\n\t) => OidcClaims | Promise<OidcClaims>;\n}\n\n/** `auth_time`, `nonce`, `amr` and `acr` as the record carries them; a refresh states no nonce. */\nfunction authenticationClaims(\n\tc: OAuthTokenResponseContext,\n): Record<string, unknown> {\n\treturn {\n\t\t...(c.authTime === undefined\n\t\t\t? {}\n\t\t\t: { auth_time: Math.floor(c.authTime.getTime() / 1000) }),\n\t\t...(c.nonce === undefined || c.grantType === 'refresh_token'\n\t\t\t? {}\n\t\t\t: { nonce: c.nonce }),\n\t\t...(c.amr === undefined ? {} : { amr: [...c.amr] }),\n\t\t...(c.acr === undefined ? {} : { acr: c.acr }),\n\t};\n}\n\nexport function idTokenHook(ctx: IdTokenContext): OAuthTokenResponseHook {\n\treturn async (c) => {\n\t\tif (c.issuer !== ctx.issuer) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`createOidcProvider: the provider was wired for another issuer than the OAuth server's; the id_token would carry the wrong iss`,\n\t\t\t);\n\t\t}\n\t\t// The exchanging client never saw the subject authenticate: an id_token\n\t\t// here would pass for a real sign-in, whatever the scopes carry over.\n\t\tif (c.grantType === TOKEN_EXCHANGE_GRANT) return undefined;\n\t\tif (!c.scopes.includes('openid')) return undefined;\n\t\tconst key = await currentKey(ctx.keys, c.issuedAt);\n\t\tconst scopeClaims = ctx.includeClaims\n\t\t\t? releasedClaims(\n\t\t\t\t\tawait ctx.claims({ id: c.user.id }, c.scopes, {\n\t\t\t\t\t\tissuer: ctx.issuer,\n\t\t\t\t\t}),\n\t\t\t\t\tc.scopes,\n\t\t\t\t\tctx.scopeClaims,\n\t\t\t\t)\n\t\t\t: {};\n\t\tconst lifetimeMs = ctx.lifetimeMs ?? c.tokens.expiresIn * 1000;\n\t\tconst idToken = await signIdToken(key, {\n\t\t\tiss: ctx.issuer,\n\t\t\tsub: c.user.id,\n\t\t\taud: c.client.id,\n\t\t\tiat: c.issuedAt,\n\t\t\texp: new Date(c.issuedAt.getTime() + lifetimeMs),\n\t\t\textra: {\n\t\t\t\t...scopeClaims,\n\t\t\t\t...authenticationClaims(c),\n\t\t\t\tat_hash: await atHash(key.alg, c.tokens.accessToken),\n\t\t\t},\n\t\t});\n\t\treturn { id_token: idToken };\n\t};\n}\n",
|
|
14
|
+
"/** `at_hash` (OpenID Connect Core §3.1.3.6): the left half of the access token's hash, base64url. */\n\nimport type { SigningAlg } from '@softistx/janus-oauth';\nimport { base64url } from 'jose';\n\n/** The hash the signing algorithm names: SHA-256 for ES256, SHA-512 for Ed25519 (EdDSA). */\nconst hashOf = (alg: SigningAlg): 'SHA-256' | 'SHA-512' =>\n\talg === 'EdDSA' ? 'SHA-512' : 'SHA-256';\n\nexport async function atHash(\n\talg: SigningAlg,\n\taccessToken: string,\n): Promise<string> {\n\tconst digest = await crypto.subtle.digest(\n\t\thashOf(alg),\n\t\tnew TextEncoder().encode(accessToken),\n\t);\n\treturn base64url.encode(\n\t\tnew Uint8Array(digest).slice(0, digest.byteLength / 2),\n\t);\n}\n",
|
|
15
|
+
"/** Signing an ID Token with the server's current signing key. */\n\nimport {\n\tNoSigningKeyError,\n\ttype SigningKeyRecord,\n\ttype SigningKeyStore,\n} from '@softistx/janus-oauth';\nimport { importJWK, SignJWT } from 'jose';\n\n/** The `current` key at `now`. A `NoSigningKeyError` (an `OAuthError` `temporarily_unavailable`, answered 503) when there is none: a failure to fix, never a client's mistake. */\nexport async function currentKey(\n\tkeys: SigningKeyStore,\n\tnow: Date,\n): Promise<SigningKeyRecord> {\n\tconst key = await keys.findCurrentKey(now);\n\tif (key === null) {\n\t\tthrow new NoSigningKeyError(\n\t\t\t'createOidcProvider: no current signing key: run rotateSigningKeys before issuing ID Tokens',\n\t\t);\n\t}\n\treturn key;\n}\n\nexport interface IdTokenClaims {\n\treadonly iss: string;\n\treadonly sub: string;\n\treadonly aud: string;\n\treadonly iat: Date;\n\treadonly exp: Date;\n\t/** The rest: `auth_time`, `nonce`, `at_hash`, `amr`, `acr`, scope claims. */\n\treadonly extra: Readonly<Record<string, unknown>>;\n}\n\n/** The compact JWT, with the key's `alg` and `kid` in the header. Only the private JWK is read. */\nexport async function signIdToken(\n\tkey: SigningKeyRecord,\n\tclaims: IdTokenClaims,\n): Promise<string> {\n\tconst secret = await importJWK({ ...key.privateJwk }, key.alg);\n\treturn new SignJWT({ ...claims.extra })\n\t\t.setProtectedHeader({ alg: key.alg, typ: 'JWT', kid: key.kid })\n\t\t.setIssuer(claims.iss)\n\t\t.setSubject(claims.sub)\n\t\t.setAudience(claims.aud)\n\t\t.setIssuedAt(claims.iat)\n\t\t.setExpirationTime(claims.exp)\n\t\t.sign(secret);\n}\n"
|
|
16
|
+
],
|
|
17
|
+
"mappings": ";AAAA;AACA;AAAA;AAAA;;;ACCO,IAAM,wBAET;AAAA,EACH,SAAS;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,OAAO,CAAC,SAAS,gBAAgB;AAAA,EACjC,SAAS,CAAC,SAAS;AAAA,EACnB,OAAO,CAAC,gBAAgB,uBAAuB;AAChD;AAGO,IAAM,kBAAqC;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAGO,SAAS,iBAAiB,CAChC,KAC8C;AAAA,EAC9C,OAAO,KAAK,0BAA0B,IAAI;AAAA;AAIpC,SAAS,gBAAgB,CA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E,QAAQ,QAAQ,MAAM,WAAW,UAAU,SAAS,SAAS;AAAA,IAChE;AAAA,EACD;AAAA;AAmBM,SAAS,kBAAkB,CAAC,SAA4C;AAAA,EAC9E,eAAe,OAAO;AAAA,EACtB,MAAM,WAAW,QAAQ,SAAS;AAAA,EAClC,MAAM,aACL,aAAa,YAAY,OAAO,cAAc,UAAU,kBAAkB;AAAA,EAC3E,MAAM,OAAO;AAAA,IACZ,QAAQ,QAAQ;AAAA,IAChB,aAAa,kBAAkB,QAAQ,WAAW;AAAA,IAClD,cAAc,QAAQ,OAAO;AAAA,IAC7B,oBAAoB,CAAC,GAAG,IAAI,IAAI,QAAQ,sBAAsB,CAAC,CAAC,CAAC;AAAA,IACjE,QAAQ,IAAI;AAAA,EACb;AAAA,EACA,IAAI,QAAQ,OAAO,aAAa,WAAW;AAAA,IAC1C,YAAY,0BAA0B,QAAQ,MAAM,QAAQ;AAAA,EAC7D;AAAA,EACA,OAAO;AAAA,IACN,aAAa,GAAG,QAAQ,QAAQ;AAAA,MAC/B,sBAAsB,MAAM,0BAA0B;AAAA,MACtD,KAAK,OAAO,IAAI,MAAM;AAAA,MACtB,OAAO,YAAY;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe,QAAQ,SAAS,iBAAiB;AAAA,QACjD,aAAa,KAAK;AAAA,QAClB,QAAQ,KAAK;AAAA,MACd,CAAC;AAAA;AAAA,IAEF,WAAW,CAAC,OAAO,kBAAkB,eACpC,YAAY,MAAM,OAAO,gBAAgB,QAAQ;AAAA,IAClD,SAAS,CAAC,WAAW,eACpB,UAAU,MAAM,cAAc,SAAS,QAAQ,CAAC;AAAA,EAClD;AAAA;",
|
|
18
|
+
"debugId": "8EF503E1E5684FE364756E2164756E21",
|
|
19
|
+
"names": []
|
|
20
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** The public types of the provider: claims, options and the shapes it answers. */
|
|
2
|
+
import type { Duration } from '@softistx/janus';
|
|
3
|
+
import type { OAuthEndpoints, OAuthHandler, OAuthIssuers, OAuthRoute, OAuthServer, OAuthTokenResponseHook, SigningKeyStore } from '@softistx/janus-oauth';
|
|
4
|
+
import type { OidcStandardClaims } from './claims/types';
|
|
5
|
+
/** The claims of a user: the standard ones, typed, and any claim of your own. */
|
|
6
|
+
export type OidcClaims = OidcStandardClaims & {
|
|
7
|
+
readonly [claim: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
/** Who `claims` is asked about: the id the access token belongs to. Look the user up with it. */
|
|
10
|
+
export interface OidcSubject {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Where the request came from: the issuer whose server authenticated the
|
|
15
|
+
* token (userinfo) or signed the ID Token. With `issuers()` it is the issuer
|
|
16
|
+
* `resolve` answered, so a partitioned user pool is looked up within it.
|
|
17
|
+
*/
|
|
18
|
+
export interface OidcClaimsContext {
|
|
19
|
+
/** The issuer identifier, exactly the one the server was given. */
|
|
20
|
+
readonly issuer: string;
|
|
21
|
+
}
|
|
22
|
+
export interface OidcProviderOptions {
|
|
23
|
+
/**
|
|
24
|
+
* The user's claims, given every claim you know: the provider keeps only
|
|
25
|
+
* those the granted `scopes` release (OpenID Connect Core §5.4). Called for
|
|
26
|
+
* each userinfo request, and for each ID Token when
|
|
27
|
+
* `idToken.includeClaims` is on. A failure rejects. The third argument
|
|
28
|
+
* names the issuer the request went through; a callback may ignore it.
|
|
29
|
+
*/
|
|
30
|
+
readonly claims: (user: OidcSubject, scopes: readonly string[], context: OidcClaimsContext) => OidcClaims | Promise<OidcClaims>;
|
|
31
|
+
/**
|
|
32
|
+
* Claims your own scopes release, by scope: `{ roles: ['roles'] }`. Added to
|
|
33
|
+
* the standard `profile`, `email`, `address` and `phone` scopes.
|
|
34
|
+
*/
|
|
35
|
+
readonly scopeClaims?: Readonly<Record<string, readonly string[]>>;
|
|
36
|
+
/**
|
|
37
|
+
* The Authentication Context Class References the application can reach,
|
|
38
|
+
* published as `acr_values_supported` in discovery (Discovery §3). Unset
|
|
39
|
+
* publishes no member. The package keeps `acr_values` on the pending
|
|
40
|
+
* request (`AuthorizationView.acrValues`); the application decides what
|
|
41
|
+
* proof each one demands.
|
|
42
|
+
*/
|
|
43
|
+
readonly acrValuesSupported?: readonly string[];
|
|
44
|
+
readonly idToken?: {
|
|
45
|
+
/** How long an ID Token is valid. Default: the access token's lifetime. */
|
|
46
|
+
readonly lifetime?: Duration;
|
|
47
|
+
/** Put the scope claims in the ID Token too (Core §5.4). Default `false`: they are at userinfo. */
|
|
48
|
+
readonly includeClaims?: boolean;
|
|
49
|
+
};
|
|
50
|
+
/** Where userinfo is served: a path from the origin or an absolute URL. Default `<issuer>/userinfo`. */
|
|
51
|
+
readonly paths?: {
|
|
52
|
+
readonly userinfo?: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** What signs the ID Tokens of one issuer. */
|
|
56
|
+
export interface OidcTokenSource {
|
|
57
|
+
/** The issuer identifier, exactly the one `createOAuthServer` was given. */
|
|
58
|
+
readonly issuer: string;
|
|
59
|
+
/** The signing keys: the ones the server's `accessTokens.keys` holds. */
|
|
60
|
+
readonly keys: SigningKeyStore;
|
|
61
|
+
}
|
|
62
|
+
export interface OidcEndpointOptions {
|
|
63
|
+
/** The resource (a key of the server's `resources`) userinfo accepts tokens for. */
|
|
64
|
+
readonly resource: string;
|
|
65
|
+
}
|
|
66
|
+
export interface OidcIssuersOptions {
|
|
67
|
+
/** The resource userinfo accepts tokens for: one for all issuers, or one per issuer. */
|
|
68
|
+
readonly resource: string | ((issuer: string) => string);
|
|
69
|
+
}
|
|
70
|
+
/** The handlers of one issuer. */
|
|
71
|
+
export interface OidcEndpoints {
|
|
72
|
+
/** `/.well-known/openid-configuration`: the OAuth metadata plus what OpenID Connect adds. */
|
|
73
|
+
readonly discovery: OAuthHandler;
|
|
74
|
+
/** GET and POST with a bearer token: `sub` and the claims the token's scopes release. */
|
|
75
|
+
readonly userinfo: OAuthHandler;
|
|
76
|
+
readonly urls: {
|
|
77
|
+
readonly discovery: string;
|
|
78
|
+
readonly userinfo: string;
|
|
79
|
+
};
|
|
80
|
+
/** Both handlers, with method and pathname, to mount in a loop. */
|
|
81
|
+
readonly routes: readonly OAuthRoute[];
|
|
82
|
+
}
|
|
83
|
+
/** The handlers of several issuers behind `createOAuthIssuers`. */
|
|
84
|
+
export interface OidcIssuers {
|
|
85
|
+
/** The response of the discovery or userinfo route of the request's issuer, or `null` for any other request: pass it on to `issuers.handle`. */
|
|
86
|
+
handle(request: Request): Promise<Response | null>;
|
|
87
|
+
}
|
|
88
|
+
export interface OidcProvider {
|
|
89
|
+
/**
|
|
90
|
+
* The `tokenResponse` hook for `createOAuthServer`: adds `id_token` when the
|
|
91
|
+
* granted scopes include `openid`. Make one per issuer.
|
|
92
|
+
*/
|
|
93
|
+
tokenResponse(source: OidcTokenSource): OAuthTokenResponseHook;
|
|
94
|
+
/** Discovery and userinfo for one server. Its issuer must have a `tokenResponse` made. */
|
|
95
|
+
endpoints(oauth: OAuthServer, oauthEndpoints: OAuthEndpoints, options: OidcEndpointOptions): OidcEndpoints;
|
|
96
|
+
/** Discovery and userinfo for the issuers `createOAuthIssuers` serves. */
|
|
97
|
+
issuers(issuers: OAuthIssuers, options: OidcIssuersOptions): OidcIssuers;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAEnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,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nC,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IAClC,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;CACzD;AAED,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC7B,6FAA6F;IAC7F,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;CACvC;AAED,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC3B,gJAAgJ;IAChJ,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,YAAY;IAC5B;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,sBAAsB,CAAC;IAC/D,0FAA0F;IAC1F,SAAS,CACR,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,mBAAmB,GAC1B,aAAa,CAAC;IACjB,0EAA0E;IAC1E,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAAC;CACzE"}
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @softistx/janus-oidc — documentation
|
|
2
|
+
|
|
3
|
+
The [README](../README.md) shows the wiring in one example; these pages give the
|
|
4
|
+
detail. The words — grant, code, resource, signing key — are
|
|
5
|
+
`@softistx/janus-oauth`'s, defined in
|
|
6
|
+
[its index](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-oauth/docs/README.md#words).
|
|
7
|
+
The OpenID Connect hooks this package uses (`nonce`, `authTime`, `amr`, `acr`,
|
|
8
|
+
`tokenResponse`) are described in
|
|
9
|
+
[its OpenID hooks page](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-oauth/docs/guide/openid-hooks.md).
|
|
10
|
+
|
|
11
|
+
| Page | Read it when |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| [Getting started](guide/getting-started.md) | You turn an OAuth server into an OpenID Provider: keys, the hook, the handlers, a first sign-in |
|
|
14
|
+
| [Claims and scopes](guide/claims.md) | You write `claims`, add scopes of your own, or want the claims in the ID Token |
|
|
15
|
+
| [Discovery](guide/discovery.md) | You need the document's members, its path, or what a client library reads from it |
|
|
16
|
+
| [Several issuers](guide/issuers.md) | One process serves several tenants with `createOAuthIssuers` |
|
|
17
|
+
| [Troubleshooting](troubleshooting.md) | You have an error message or an unexpected status and want its cause and fix |
|
|
18
|
+
| [Roadmap](roadmap.md) | You want to know what is coming and what is deliberately not planned |
|