@boopkit/cap-oauth-server 0.1.4 → 0.3.1
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/capability.json +14 -2
- package/dist/authorization-code-service.d.ts +40 -11
- package/dist/authorization-code-service.d.ts.map +1 -1
- package/dist/authorization-code-service.js +93 -41
- package/dist/authorization-code-service.js.map +1 -1
- package/dist/bearer.d.ts +27 -4
- package/dist/bearer.d.ts.map +1 -1
- package/dist/bearer.js +4 -4
- package/dist/bearer.js.map +1 -1
- package/dist/client-prune.d.ts +102 -0
- package/dist/client-prune.d.ts.map +1 -0
- package/dist/client-prune.js +51 -0
- package/dist/client-prune.js.map +1 -0
- package/dist/client-registry-service.d.ts +85 -8
- package/dist/client-registry-service.d.ts.map +1 -1
- package/dist/client-registry-service.js +267 -64
- package/dist/client-registry-service.js.map +1 -1
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/connections-controller.js +1 -1
- package/dist/connections-controller.js.map +1 -1
- package/dist/consent-controller.d.ts +80 -6
- package/dist/consent-controller.d.ts.map +1 -1
- package/dist/consent-controller.js +134 -18
- package/dist/consent-controller.js.map +1 -1
- package/dist/discovery-controller.d.ts +2 -1
- package/dist/discovery-controller.d.ts.map +1 -1
- package/dist/discovery-controller.js +14 -4
- package/dist/discovery-controller.js.map +1 -1
- package/dist/discovery.d.ts +26 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +55 -1
- package/dist/discovery.js.map +1 -1
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +59 -0
- package/dist/errors.js.map +1 -1
- package/dist/grant-service.d.ts +11 -4
- package/dist/grant-service.d.ts.map +1 -1
- package/dist/grant-service.js +6 -3
- package/dist/grant-service.js.map +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/metadata-document.d.ts +22 -0
- package/dist/metadata-document.d.ts.map +1 -1
- package/dist/metadata-document.js +44 -2
- package/dist/metadata-document.js.map +1 -1
- package/dist/outbound-target.d.ts +48 -0
- package/dist/outbound-target.d.ts.map +1 -0
- package/dist/outbound-target.js +211 -0
- package/dist/outbound-target.js.map +1 -0
- package/dist/rate-limit.d.ts +53 -11
- package/dist/rate-limit.d.ts.map +1 -1
- package/dist/rate-limit.js +27 -4
- package/dist/rate-limit.js.map +1 -1
- package/dist/redirect-uri.d.ts +17 -9
- package/dist/redirect-uri.d.ts.map +1 -1
- package/dist/redirect-uri.js +26 -10
- package/dist/redirect-uri.js.map +1 -1
- package/dist/registration-controller.d.ts +10 -0
- package/dist/registration-controller.d.ts.map +1 -1
- package/dist/registration-controller.js +10 -0
- package/dist/registration-controller.js.map +1 -1
- package/dist/request-client.d.ts +7 -1
- package/dist/request-client.d.ts.map +1 -1
- package/dist/request-client.js +31 -13
- package/dist/request-client.js.map +1 -1
- package/dist/revocation-controller.d.ts +5 -0
- package/dist/revocation-controller.d.ts.map +1 -1
- package/dist/revocation-controller.js +5 -1
- package/dist/revocation-controller.js.map +1 -1
- package/dist/same-site.d.ts +54 -0
- package/dist/same-site.d.ts.map +1 -0
- package/dist/same-site.js +124 -0
- package/dist/same-site.js.map +1 -0
- package/dist/token-controller.d.ts +26 -0
- package/dist/token-controller.d.ts.map +1 -1
- package/dist/token-controller.js +44 -19
- package/dist/token-controller.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/scaffold/reference/oauth-server.ref.md +359 -11
- package/scaffold/src/middleware/oauth-server.ts +33 -17
- package/scaffold/src/scripts/prune-oauth-clients.ts +86 -0
- package/scaffold/src/services/oauth-server.service.ts +24 -0
- package/scaffold/views/oauth-consent-error.hbs +10 -3
package/dist/discovery.js
CHANGED
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
* match exactly as clients enter it.
|
|
33
33
|
*/
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.DISCOVERY_MAX_AGE_SECONDS = exports.DEFAULT_SCOPES_SUPPORTED = exports.DEVICE_CODE_GRANT_TYPE = exports.CODE_CHALLENGE_METHODS_SUPPORTED = void 0;
|
|
35
|
+
exports.PROTECTED_RESOURCE_METADATA_PATH = exports.DISCOVERY_MAX_AGE_SECONDS = exports.DEFAULT_SCOPES_SUPPORTED = exports.DEVICE_CODE_GRANT_TYPE = exports.CODE_CHALLENGE_METHODS_SUPPORTED = void 0;
|
|
36
36
|
exports.buildAuthorizationServerMetadata = buildAuthorizationServerMetadata;
|
|
37
|
+
exports.protectedResourceMetadataPaths = protectedResourceMetadataPaths;
|
|
37
38
|
exports.buildProtectedResourceMetadata = buildProtectedResourceMetadata;
|
|
38
39
|
/** Only S256. `plain` is not a PKCE method, it is the absence of one. */
|
|
39
40
|
exports.CODE_CHALLENGE_METHODS_SUPPORTED = ['S256'];
|
|
@@ -81,6 +82,59 @@ function buildAuthorizationServerMetadata(config) {
|
|
|
81
82
|
metadata.service_documentation = config.documentationUri;
|
|
82
83
|
return metadata;
|
|
83
84
|
}
|
|
85
|
+
/** Where RFC 9728 puts the document for a resource mounted at the root. */
|
|
86
|
+
exports.PROTECTED_RESOURCE_METADATA_PATH = '/.well-known/oauth-protected-resource';
|
|
87
|
+
/**
|
|
88
|
+
* Every path the protected-resource document should answer at, bare path first.
|
|
89
|
+
*
|
|
90
|
+
* RFC 9728 3.1 locates the document by inserting the well-known segment
|
|
91
|
+
* between the resource URL's host and its path, so a resource at
|
|
92
|
+
* `https://host/api/mcp` publishes at
|
|
93
|
+
* `https://host/.well-known/oauth-protected-resource/api/mcp`. A resource at
|
|
94
|
+
* the root has nothing to insert before, and gets the bare path alone.
|
|
95
|
+
*
|
|
96
|
+
* The bare path is kept for a resource that is *not* at the root, because that
|
|
97
|
+
* is where clients in the field look after the specified location answers 404
|
|
98
|
+
* — observed 2026-09-06 with the Claude desktop app, which asks for the
|
|
99
|
+
* suffixed form first and falls back. Serving both costs one more literal
|
|
100
|
+
* route carrying the same body.
|
|
101
|
+
*
|
|
102
|
+
* The suffix comes from configuration read at boot and never from request
|
|
103
|
+
* input, so the routes below are fixed strings: there is no parameter to
|
|
104
|
+
* traverse with, for the same reason the documents themselves are computed
|
|
105
|
+
* rather than read off disk. Two inputs yield the bare path alone rather than
|
|
106
|
+
* a route built out of something that is not one: a `resource` that will not
|
|
107
|
+
* parse as a URL, and a path Express would read as a pattern — see
|
|
108
|
+
* `LITERAL_PATH` below.
|
|
109
|
+
*/
|
|
110
|
+
function protectedResourceMetadataPaths(resource) {
|
|
111
|
+
let pathname;
|
|
112
|
+
try {
|
|
113
|
+
pathname = new URL(resource).pathname;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return [exports.PROTECTED_RESOURCE_METADATA_PATH];
|
|
117
|
+
}
|
|
118
|
+
const suffix = pathname.replace(/\/+$/, '');
|
|
119
|
+
if (suffix === '' || !LITERAL_PATH.test(suffix))
|
|
120
|
+
return [exports.PROTECTED_RESOURCE_METADATA_PATH];
|
|
121
|
+
return [exports.PROTECTED_RESOURCE_METADATA_PATH, `${exports.PROTECTED_RESOURCE_METADATA_PATH}${suffix}`];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A path Express will match as the literal string it is.
|
|
125
|
+
*
|
|
126
|
+
* Express 5 parses its route paths, and several characters RFC 3986 allows in
|
|
127
|
+
* a path mean something to that parser: `:name` becomes a parameter matching
|
|
128
|
+
* any segment — silently, so the route would match the wrong URLs and not the
|
|
129
|
+
* right one — while `(`, `+` and `[` throw as the router is built, which for a
|
|
130
|
+
* value read at boot means the application does not start.
|
|
131
|
+
*
|
|
132
|
+
* So the suffixed route is offered only for a path made of characters that
|
|
133
|
+
* carry no meaning to the parser. Anything else keeps the bare path and loses
|
|
134
|
+
* only the second location; an app that refuses to boot over a discovery
|
|
135
|
+
* document's address would be the worse trade by far.
|
|
136
|
+
*/
|
|
137
|
+
const LITERAL_PATH = /^[A-Za-z0-9\-._~%!$&',;=@/]+$/;
|
|
84
138
|
/** RFC 9728. */
|
|
85
139
|
function buildProtectedResourceMetadata(config) {
|
|
86
140
|
const metadata = {
|
package/dist/discovery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AAiEH,4EAmCC;
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AAiEH,4EAmCC;AAoCD,wEAYC;AAmBD,wEAiBC;AAxJD,yEAAyE;AAC5D,QAAA,gCAAgC,GAAG,CAAC,MAAM,CAAU,CAAC;AAElE,6EAA6E;AAChE,QAAA,sBAAsB,GAAG,8CAA8C,CAAC;AAErF,6EAA6E;AAChE,QAAA,wBAAwB,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAE/E,gFAAgF;AACnE,QAAA,yBAAyB,GAAG,IAAI,CAAC;AAE9C,0EAA0E;AAC1E,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1D,CAAC;AAiBD,gEAAgE;AAChE,SAAgB,gCAAgC,CAC9C,MAAuB;IAEvB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEnC,MAAM,UAAU,GAAG,CAAC,oBAAoB,EAAE,eAAe,CAAC,CAAC;IAC3D,IAAI,MAAM,CAAC,iBA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AK,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,wCAAgC,CAAC,CAAC;IAE3F,OAAO,CAAC,wCAAgC,EAAE,GAAG,wCAAgC,GAAG,MAAM,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD,gBAAgB;AAChB,SAAgB,8BAA8B,CAC5C,MAAuB;IAEvB,MAAM,QAAQ,GAA8B;QAC1C,iEAAiE;QACjE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,0EAA0E;QAC1E,wCAAwC;QACxC,qBAAqB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9C,gBAAgB,EAAE,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC;QAC7C,0EAA0E;QAC1E,gCAAgC;QAChC,wBAAwB,EAAE,CAAC,QAAQ,CAAC;KACrC,CAAC;IAEF,IAAI,MAAM,CAAC,gBAAgB;QAAE,QAAQ,CAAC,sBAAsB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACvF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -23,4 +23,42 @@ export declare class ClientRegistryError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
/** Is this one of ours? Narrower than `instanceof` across module instances. */
|
|
25
25
|
export declare function isClientRegistryError(err: unknown): err is ClientRegistryError;
|
|
26
|
+
/**
|
|
27
|
+
* Did the store refuse this write because a unique index already holds the
|
|
28
|
+
* value — Prisma's `P2002`?
|
|
29
|
+
*
|
|
30
|
+
* The registry's two create paths each do a find, then a create, with at least
|
|
31
|
+
* one `await` in between, so two callers can both look, both see nothing, and
|
|
32
|
+
* both write. Postgres settles that with the unique index on `client_id`, and
|
|
33
|
+
* the losing caller gets a `P2002`. Recognising it is what lets the loser
|
|
34
|
+
* converge on the winner's row instead of surfacing a database error to
|
|
35
|
+
* somebody who asked a perfectly ordinary question.
|
|
36
|
+
*
|
|
37
|
+
* `field` narrows the check to one column, and callers should pass it. A
|
|
38
|
+
* `P2002` on `public_id` is a generated-identifier collision, which is a
|
|
39
|
+
* genuinely exceptional thing and must not be mistaken for a lost race on a
|
|
40
|
+
* `client_id` somebody else was registering at the same moment.
|
|
41
|
+
*
|
|
42
|
+
* ## Why `field` is matched in two spellings
|
|
43
|
+
*
|
|
44
|
+
* Pass the **Prisma field name** — `clientId`. What arrives in `meta.target`
|
|
45
|
+
* may be either that or the mapped column name, and which one depends on the
|
|
46
|
+
* connector rather than on anything the caller can see:
|
|
47
|
+
*
|
|
48
|
+
* PostgreSQL target: ['client_id'] the column, from the constraint
|
|
49
|
+
* MySQL target: ['clientId'] the field
|
|
50
|
+
*
|
|
51
|
+
* So both are accepted, derived here rather than spelled out at each call site.
|
|
52
|
+
* This is not defensive padding; it is a measured result.
|
|
53
|
+
* `tests/integration/oauth-clients-postgres.test.ts` was written because an
|
|
54
|
+
* in-memory delegate gets to decide what its own errors look like, and the
|
|
55
|
+
* first thing real Postgres said was that the delegate had chosen the wrong
|
|
56
|
+
* spelling. A predicate matching only `clientId` passes every mock test in the
|
|
57
|
+
* suite and recovers from nothing in production.
|
|
58
|
+
*
|
|
59
|
+
* Matched structurally rather than with `instanceof PrismaClientKnownRequestError`,
|
|
60
|
+
* for the same reason `isClientRegistryError` is: this package never imports
|
|
61
|
+
* `@prisma/client`, and the delegate it is handed belongs to the application.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isUniqueConstraintViolation(err: unknown, field?: string): boolean;
|
|
26
64
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,wDAAwD;AACxD,MAAM,MAAM,uBA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(exports, "__esModule", { value: true });
|
|
13
13
|
exports.ClientRegistryError = void 0;
|
|
14
14
|
exports.isClientRegistryError = isClientRegistryError;
|
|
15
|
+
exports.isUniqueConstraintViolation = isUniqueConstraintViolation;
|
|
15
16
|
/** HTTP status a controller should answer a given code with. */
|
|
16
17
|
const STATUS_BY_CODE = {
|
|
17
18
|
invalid_client_metadata: 400,
|
|
@@ -38,4 +39,62 @@ function isClientRegistryError(err) {
|
|
|
38
39
|
err.name === 'ClientRegistryError' &&
|
|
39
40
|
typeof err.code === 'string');
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Did the store refuse this write because a unique index already holds the
|
|
44
|
+
* value — Prisma's `P2002`?
|
|
45
|
+
*
|
|
46
|
+
* The registry's two create paths each do a find, then a create, with at least
|
|
47
|
+
* one `await` in between, so two callers can both look, both see nothing, and
|
|
48
|
+
* both write. Postgres settles that with the unique index on `client_id`, and
|
|
49
|
+
* the losing caller gets a `P2002`. Recognising it is what lets the loser
|
|
50
|
+
* converge on the winner's row instead of surfacing a database error to
|
|
51
|
+
* somebody who asked a perfectly ordinary question.
|
|
52
|
+
*
|
|
53
|
+
* `field` narrows the check to one column, and callers should pass it. A
|
|
54
|
+
* `P2002` on `public_id` is a generated-identifier collision, which is a
|
|
55
|
+
* genuinely exceptional thing and must not be mistaken for a lost race on a
|
|
56
|
+
* `client_id` somebody else was registering at the same moment.
|
|
57
|
+
*
|
|
58
|
+
* ## Why `field` is matched in two spellings
|
|
59
|
+
*
|
|
60
|
+
* Pass the **Prisma field name** — `clientId`. What arrives in `meta.target`
|
|
61
|
+
* may be either that or the mapped column name, and which one depends on the
|
|
62
|
+
* connector rather than on anything the caller can see:
|
|
63
|
+
*
|
|
64
|
+
* PostgreSQL target: ['client_id'] the column, from the constraint
|
|
65
|
+
* MySQL target: ['clientId'] the field
|
|
66
|
+
*
|
|
67
|
+
* So both are accepted, derived here rather than spelled out at each call site.
|
|
68
|
+
* This is not defensive padding; it is a measured result.
|
|
69
|
+
* `tests/integration/oauth-clients-postgres.test.ts` was written because an
|
|
70
|
+
* in-memory delegate gets to decide what its own errors look like, and the
|
|
71
|
+
* first thing real Postgres said was that the delegate had chosen the wrong
|
|
72
|
+
* spelling. A predicate matching only `clientId` passes every mock test in the
|
|
73
|
+
* suite and recovers from nothing in production.
|
|
74
|
+
*
|
|
75
|
+
* Matched structurally rather than with `instanceof PrismaClientKnownRequestError`,
|
|
76
|
+
* for the same reason `isClientRegistryError` is: this package never imports
|
|
77
|
+
* `@prisma/client`, and the delegate it is handed belongs to the application.
|
|
78
|
+
*/
|
|
79
|
+
function isUniqueConstraintViolation(err, field) {
|
|
80
|
+
if (typeof err !== 'object' || err === null)
|
|
81
|
+
return false;
|
|
82
|
+
if (err.code !== 'P2002')
|
|
83
|
+
return false;
|
|
84
|
+
if (field === undefined)
|
|
85
|
+
return true;
|
|
86
|
+
const target = err.meta?.target;
|
|
87
|
+
// Prisma reports `target` as a list of names, but as a bare string on some
|
|
88
|
+
// connectors and an array on others.
|
|
89
|
+
const reported = typeof target === 'string' ? [target] : Array.isArray(target) ? target : [];
|
|
90
|
+
// A P2002 with no usable target could be about any column. An empty list
|
|
91
|
+
// matches nothing, so the caller rethrows rather than guessing it was the
|
|
92
|
+
// race it hoped for.
|
|
93
|
+
const accepted = [field, snakeCase(field)];
|
|
94
|
+
return reported.some((name) => typeof name === 'string' && accepted.includes(name));
|
|
95
|
+
}
|
|
96
|
+
/** `clientId` -> `client_id`, the mapping the schema's `@map` names follow. */
|
|
97
|
+
function snakeCase(field) {
|
|
98
|
+
return field.replace(/[A-Z]/g, (ch) => `_${ch.toLowerCase()}`);
|
|
99
|
+
}
|
|
41
100
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAuCH,sDAOC;
|
|
1
|
+
{"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C3E,qCAAqC;IACrC,MAAM,QAAQ,GACZ,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9E,yEAAyE;IACzE,0EAA0E;IAC1E,qBAAqB;IACrB,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,+EAA+E;AAC/E,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/grant-service.d.ts
CHANGED
|
@@ -12,9 +12,12 @@ import type { PropertyStore } from './user-store.js';
|
|
|
12
12
|
* under a wider set is bound by the grant's current, narrower one on its very
|
|
13
13
|
* next call — no revocation, no new mechanism, and a test says so.
|
|
14
14
|
*
|
|
15
|
-
* RFC 8707 `resource` is the exception and
|
|
16
|
-
* property of a credential
|
|
17
|
-
* cautious client
|
|
15
|
+
* RFC 8707 `resource` is the planned exception, and the reasoning is that an
|
|
16
|
+
* audience is a property of a credential rather than of a relationship, which
|
|
17
|
+
* is exactly why a cautious client should be able to ask for a narrow token
|
|
18
|
+
* against an unchanged grant. None of that is built yet: the indicator is
|
|
19
|
+
* recorded on the grant below as last requested, no token carries an audience,
|
|
20
|
+
* and nothing enforces one. See boop-vdh0.
|
|
18
21
|
*
|
|
19
22
|
* ## Re-consent replaces, it does not union
|
|
20
23
|
*
|
|
@@ -46,7 +49,11 @@ export interface OAuthGrantRecord {
|
|
|
46
49
|
client_public_id: string;
|
|
47
50
|
/** The current approved set. Replaced wholesale on re-consent. */
|
|
48
51
|
scopes: string[];
|
|
49
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* RFC 8707, as last requested. Recorded, not enforced: per-token audience
|
|
54
|
+
* binding is unimplemented, so no token carries this value and nothing checks
|
|
55
|
+
* it. See boop-vdh0.
|
|
56
|
+
*/
|
|
50
57
|
resource: string | null;
|
|
51
58
|
/**
|
|
52
59
|
* The identity key of the grant's **current** refresh token, or `null`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant-service.d.ts","sourceRoot":"","sources":["../src/grant-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"grant-service.d.ts","sourceRoot":"","sources":["../src/grant-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAEpD,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,gBAAgB,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;;;;;OAQG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,C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,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzF,4EAA4E;IAC5E,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACxF;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAE9D;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAoH7E"}
|
package/dist/grant-service.js
CHANGED
|
@@ -18,9 +18,12 @@ const property_array_js_1 = require("./property-array.js");
|
|
|
18
18
|
* under a wider set is bound by the grant's current, narrower one on its very
|
|
19
19
|
* next call — no revocation, no new mechanism, and a test says so.
|
|
20
20
|
*
|
|
21
|
-
* RFC 8707 `resource` is the exception and
|
|
22
|
-
* property of a credential
|
|
23
|
-
* cautious client
|
|
21
|
+
* RFC 8707 `resource` is the planned exception, and the reasoning is that an
|
|
22
|
+
* audience is a property of a credential rather than of a relationship, which
|
|
23
|
+
* is exactly why a cautious client should be able to ask for a narrow token
|
|
24
|
+
* against an unchanged grant. None of that is built yet: the indicator is
|
|
25
|
+
* recorded on the grant below as last requested, no token carries an audience,
|
|
26
|
+
* and nothing enforces one. See boop-vdh0.
|
|
24
27
|
*
|
|
25
28
|
* ## Re-consent replaces, it does not union
|
|
26
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant-service.js","sourceRoot":"","sources":["../src/grant-service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"grant-service.js","sourceRoot":"","sources":["../src/grant-service.ts"],"names":[],"mappings":";;;AAsHA,sCAEC;AAED,gDAoHC;AA9OD,6CA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,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;YAChD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;YAC1D,IAAI,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAC;YACzB,oEAAoE;YACpE,oEAAoE;YACpE,oEAAoE;YACpE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;gBAAE,OAAO,MAAM,CAAC;YAE1C,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;YACtC,MAAM,KAAK,GAAqB;gBAC9B,GAAG,MAAM;gBACT,oEAAoE;gBACpE,oEAAoE;gBACpE,WAAW,EAAE,IAAI;gBACjB,QAAQ,EAAE,SAAS;gBACnB,YAAY,EAAE,MAAM;gBACpB,UAAU,EAAE,SAAS;aACtB,CAAC;YACF,MAAM,KAAK,CACT,MAAM,EACN,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACvD,QAAQ,CACT,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,11 +23,12 @@ export type { RedirectUriClassification, RedirectUriShape } from './redirect-uri
|
|
|
23
23
|
export { generateClientPublicId, isValidClientPublicId, CLIENT_PUBLIC_ID_ALPHABET, CLIENT_PUBLIC_ID_LENGTH, } from './public-id.js';
|
|
24
24
|
export { ClientRegistryError, isClientRegistryError } from './errors.js';
|
|
25
25
|
export type { ClientRegistryErrorCode } from './errors.js';
|
|
26
|
-
export { createClientRegistryService, validateRedirectUris, DEFAULT_GRANT_TYPES, DEFAULT_RESPONSE_TYPES, DEFAULT_METADATA_MAX_AGE_MS, DEFAULT_ABANDONED_CLIENT_TTL_MS, DEFAULT_MAX_REGISTERED_CLIENTS, } from './client-registry-service.js';
|
|
26
|
+
export { createClientRegistryService, validateRedirectUris, STRANGER_CREATED_MODES, DEFAULT_GRANT_TYPES, DEFAULT_RESPONSE_TYPES, DEFAULT_METADATA_MAX_AGE_MS, DEFAULT_ABANDONED_CLIENT_TTL_MS, DEFAULT_MAX_REGISTERED_CLIENTS, } from './client-registry-service.js';
|
|
27
27
|
export type { ClientRegistryService, ClientRegistryServiceOptions, PruneOptions, } from './client-registry-service.js';
|
|
28
|
+
export { blockedHostReason, isBlockedAddress } from './outbound-target.js';
|
|
28
29
|
export { fetchMetadataDocument, isValidMetadataUri, DEFAULT_METADATA_TIMEOUT_MS, DEFAULT_METADATA_MAX_BYTES, DEFAULT_METADATA_MAX_REDIRECTS, } from './metadata-document.js';
|
|
29
30
|
export type { FetchLike, FetchLikeResponse, MetadataFetchOptions, } from './metadata-document.js';
|
|
30
|
-
export { buildAuthorizationServerMetadata, buildProtectedResourceMetadata, CODE_CHALLENGE_METHODS_SUPPORTED, DEVICE_CODE_GRANT_TYPE, DEFAULT_SCOPES_SUPPORTED, DISCOVERY_MAX_AGE_SECONDS, } from './discovery.js';
|
|
31
|
+
export { buildAuthorizationServerMetadata, buildProtectedResourceMetadata, CODE_CHALLENGE_METHODS_SUPPORTED, DEVICE_CODE_GRANT_TYPE, DEFAULT_SCOPES_SUPPORTED, DISCOVERY_MAX_AGE_SECONDS, PROTECTED_RESOURCE_METADATA_PATH, protectedResourceMetadataPaths, } from './discovery.js';
|
|
31
32
|
export type { DiscoveryConfig, AuthorizationServerMetadata, ProtectedResourceMetadata, } from './discovery.js';
|
|
32
33
|
export { readServerConfig, clampTtlSeconds, OauthServerConfigError, DEFAULT_ACCESS_TOKEN_TTL_SECONDS, DEFAULT_REFRESH_TOKEN_TTL_SECONDS, ACCESS_TOKEN_TTL_BOUNDS, REFRESH_TOKEN_TTL_BOUNDS, } from './config.js';
|
|
33
34
|
export type { ServerConfig, ReadConfigOptions } from './config.js';
|
|
@@ -35,8 +36,8 @@ export { createDiscoveryHandlers, createDiscoveryRouter } from './discovery-cont
|
|
|
35
36
|
export type { DiscoveryHandlers } from './discovery-controller.js';
|
|
36
37
|
export { createRegistrationHandlers, createRegistrationRouter, toRegistrationResponse, } from './registration-controller.js';
|
|
37
38
|
export type { RegistrationHandlerDeps, RegistrationRouterOptions, } from './registration-controller.js';
|
|
38
|
-
export { createRegistrationRateLimiter, DEFAULT_REGISTRATION_RATE_LIMIT, DEFAULT_REGISTRATION_RATE_WINDOW_MS, } from './rate-limit.js';
|
|
39
|
-
export type { RateLimiterOptions, RegistrationRateLimiter } from './rate-limit.js';
|
|
39
|
+
export { createFixedWindowRateLimiter, createRegistrationRateLimiter, rateLimitAddress, DEFAULT_METADATA_RESOLUTION_RATE_LIMIT, DEFAULT_REGISTRATION_RATE_LIMIT, DEFAULT_REGISTRATION_RATE_WINDOW_MS, } from './rate-limit.js';
|
|
40
|
+
export type { FixedWindowRateLimiter, RateLimiterOptions, RegistrationRateLimiter, } from './rate-limit.js';
|
|
40
41
|
export { CLIENT_MODES } from './types.js';
|
|
41
42
|
export type { ClientMode, ClientStatus, OauthClient, OauthClientDelegate, ClientMetadataInput, ClientIdMetadataDocument, StaticClientInput, } from './types.js';
|
|
42
43
|
export { createTokenService, buildIdentityKey, AUTHORIZATION_CODE_TTL_SECONDS, OAUTH_CODE_DOMAIN, OAUTH_ACCESS_DOMAIN, OAUTH_REFRESH_DOMAIN, } from './token-service.js';
|
|
@@ -52,12 +53,16 @@ export { isStaleWriteError } from './user-store.js';
|
|
|
52
53
|
export type { IdentityStore, PropertyStore, PropertyWriteOptions, StoredIdentity, StoredProperty, } from './user-store.js';
|
|
53
54
|
export { readArray, writeArray } from './property-array.js';
|
|
54
55
|
export type { ArraySnapshot } from './property-array.js';
|
|
55
|
-
export { createConsentHandlers, createConsentRouter, defaultIsSignedIn, monogramFor, provenanceFor,
|
|
56
|
+
export { createConsentHandlers, createConsentRouter, defaultIsSignedIn, monogramFor, provenanceFor, safeHttpsUri, scopeDescriptionsFrom, toScopeViews, warnUndescribedScopes, SCOPE_DESCRIPTIONS_LOCAL, } from './consent-controller.js';
|
|
56
57
|
export type { AuthorizationRequest, ConsentCredentials, ConsentHandlers, ConsentHandlerDeps, ConsentRegister, ConsentRegistration, ConsentRouterOptions, ConsentScopeView, ConsentSession, ConsentSignIn, ConsentSignedIn, ConsentVariant, ScopeDescriptions, } from './consent-controller.js';
|
|
58
|
+
export { isSameSiteRequest } from './same-site.js';
|
|
59
|
+
export type { SameSiteRequest } from './same-site.js';
|
|
57
60
|
export { createTokenHandlers, createTokenRouter, parseScopes, OFFLINE_ACCESS_SCOPE, } from './token-controller.js';
|
|
58
61
|
export type { TokenHandlerDeps, TokenRouterOptions, TokenResponse, } from './token-controller.js';
|
|
59
62
|
export { createOAuthBearerMiddleware, createOAuthResourceServer, createOAuthTokenResolver, missingScopes, requireOAuth, DEFAULT_BEARER_CHALLENGE, } from './bearer.js';
|
|
60
63
|
export type { OAuthBearerOptions, OAuthResourceServer, ResolvedOAuthPrincipal, } from './bearer.js';
|
|
64
|
+
export { createClientInUsePredicate, createClientPruneJob } from './client-prune.js';
|
|
65
|
+
export type { ClientInUseOptions, ClientPruneJob, ClientPruneOptions, ClientPruneResult, } from './client-prune.js';
|
|
61
66
|
export { createRevocationService, REVOKED_BY_CLIENT, REVOKED_BY_USER, REVOKED_CLIENT_WIDE, } from './revocation-service.js';
|
|
62
67
|
export type { RevocationService, RevocationServiceOptions, RevokedGrant, } from './revocation-service.js';
|
|
63
68
|
export { createRevocationHandlers, createRevocationRouter, } from './revocation-controller.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,cAAc,CAAC;AAEtB,OAAO,EACL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ErB,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACrF,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
* that mechanically.
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
22
|
+
exports.DEFAULT_REGISTRATION_RATE_LIMIT = exports.DEFAULT_METADATA_RESOLUTION_RATE_LIMIT = exports.rateLimitAddress = exports.createRegistrationRateLimiter = exports.createFixedWindowRateLimiter = exports.toRegistrationResponse = exports.createRegistrationRouter = exports.createRegistrationHandlers = exports.createDiscoveryRouter = exports.createDiscoveryHandlers = exports.REFRESH_TOKEN_TTL_BOUNDS = exports.ACCESS_TOKEN_TTL_BOUNDS = exports.DEFAULT_REFRESH_TOKEN_TTL_SECONDS = exports.DEFAULT_ACCESS_TOKEN_TTL_SECONDS = exports.OauthServerConfigError = exports.clampTtlSeconds = exports.readServerConfig = exports.protectedResourceMetadataPaths = exports.PROTECTED_RESOURCE_METADATA_PATH = exports.DISCOVERY_MAX_AGE_SECONDS = exports.DEFAULT_SCOPES_SUPPORTED = exports.DEVICE_CODE_GRANT_TYPE = exports.CODE_CHALLENGE_METHODS_SUPPORTED = exports.buildProtectedResourceMetadata = exports.buildAuthorizationServerMetadata = exports.DEFAULT_METADATA_MAX_REDIRECTS = exports.DEFAULT_METADATA_MAX_BYTES = exports.DEFAULT_METADATA_TIMEOUT_MS = exports.isValidMetadataUri = exports.fetchMetadataDocument = exports.isBlockedAddress = exports.blockedHostReason = exports.DEFAULT_MAX_REGISTERED_CLIENTS = exports.DEFAULT_ABANDONED_CLIENT_TTL_MS = exports.DEFAULT_METADATA_MAX_AGE_MS = exports.DEFAULT_RESPONSE_TYPES = exports.DEFAULT_GRANT_TYPES = exports.STRANGER_CREATED_MODES = exports.validateRedirectUris = exports.createClientRegistryService = exports.isClientRegistryError = exports.ClientRegistryError = exports.CLIENT_PUBLIC_ID_LENGTH = exports.CLIENT_PUBLIC_ID_ALPHABET = exports.isValidClientPublicId = exports.generateClientPublicId = exports.isLoopbackHost = exports.matchesAnyRedirectUri = exports.matchRedirectUri = exports.classifyRedirectUri = void 0;
|
|
23
|
+
exports.REVOKED_BY_CLIENT = exports.createRevocationService = exports.createClientPruneJob = exports.createClientInUsePredicate = exports.DEFAULT_BEARER_CHALLENGE = exports.requireOAuth = exports.missingScopes = exports.createOAuthTokenResolver = exports.createOAuthResourceServer = exports.createOAuthBearerMiddleware = exports.OFFLINE_ACCESS_SCOPE = exports.parseScopes = exports.createTokenRouter = exports.createTokenHandlers = exports.isSameSiteRequest = exports.SCOPE_DESCRIPTIONS_LOCAL = exports.warnUndescribedScopes = exports.toScopeViews = exports.scopeDescriptionsFrom = exports.safeHttpsUri = exports.provenanceFor = exports.monogramFor = exports.defaultIsSignedIn = exports.createConsentRouter = exports.createConsentHandlers = exports.writeArray = exports.readArray = exports.isStaleWriteError = exports.isOAuthError = exports.OAuthError = exports.verifyCodeChallenge = exports.isValidCodeVerifier = exports.isValidCodeChallenge = exports.deriveCodeChallenge = exports.CODE_CHALLENGE_METHOD = exports.OAUTH_CODES_INFO_SCHEMA = exports.OAUTH_CODES_PROPERTY = exports.createAuthorizationCodeService = exports.OAUTH_GRANTS_INFO_SCHEMA = exports.OAUTH_GRANTS_PROPERTY = exports.isGrantActive = exports.createGrantService = exports.OAUTH_REFRESH_DOMAIN = exports.OAUTH_ACCESS_DOMAIN = exports.OAUTH_CODE_DOMAIN = exports.AUTHORIZATION_CODE_TTL_SECONDS = exports.buildIdentityKey = exports.createTokenService = exports.CLIENT_MODES = exports.DEFAULT_REGISTRATION_RATE_WINDOW_MS = void 0;
|
|
24
|
+
exports.ACCOUNT_COVERAGE_STATEMENT = exports.createConnectionsRouter = exports.createConnectionsHandlers = exports.createRevocationRouter = exports.createRevocationHandlers = exports.REVOKED_CLIENT_WIDE = exports.REVOKED_BY_USER = void 0;
|
|
24
25
|
// Side-effect import: the Express request augmentation this capability's
|
|
25
26
|
// middleware writes (`req.oauthGrant`) and its consent controller reads
|
|
26
27
|
// (`req.user`). Importing the package is what gives an application those
|
|
@@ -42,11 +43,15 @@ Object.defineProperty(exports, "isClientRegistryError", { enumerable: true, get:
|
|
|
42
43
|
var client_registry_service_js_1 = require("./client-registry-service.js");
|
|
43
44
|
Object.defineProperty(exports, "createClientRegistryService", { enumerable: true, get: function () { return client_registry_service_js_1.createClientRegistryService; } });
|
|
44
45
|
Object.defineProperty(exports, "validateRedirectUris", { enumerable: true, get: function () { return client_registry_service_js_1.validateRedirectUris; } });
|
|
46
|
+
Object.defineProperty(exports, "STRANGER_CREATED_MODES", { enumerable: true, get: function () { return client_registry_service_js_1.STRANGER_CREATED_MODES; } });
|
|
45
47
|
Object.defineProperty(exports, "DEFAULT_GRANT_TYPES", { enumerable: true, get: function () { return client_registry_service_js_1.DEFAULT_GRANT_TYPES; } });
|
|
46
48
|
Object.defineProperty(exports, "DEFAULT_RESPONSE_TYPES", { enumerable: true, get: function () { return client_registry_service_js_1.DEFAULT_RESPONSE_TYPES; } });
|
|
47
49
|
Object.defineProperty(exports, "DEFAULT_METADATA_MAX_AGE_MS", { enumerable: true, get: function () { return client_registry_service_js_1.DEFAULT_METADATA_MAX_AGE_MS; } });
|
|
48
50
|
Object.defineProperty(exports, "DEFAULT_ABANDONED_CLIENT_TTL_MS", { enumerable: true, get: function () { return client_registry_service_js_1.DEFAULT_ABANDONED_CLIENT_TTL_MS; } });
|
|
49
51
|
Object.defineProperty(exports, "DEFAULT_MAX_REGISTERED_CLIENTS", { enumerable: true, get: function () { return client_registry_service_js_1.DEFAULT_MAX_REGISTERED_CLIENTS; } });
|
|
52
|
+
var outbound_target_js_1 = require("./outbound-target.js");
|
|
53
|
+
Object.defineProperty(exports, "blockedHostReason", { enumerable: true, get: function () { return outbound_target_js_1.blockedHostReason; } });
|
|
54
|
+
Object.defineProperty(exports, "isBlockedAddress", { enumerable: true, get: function () { return outbound_target_js_1.isBlockedAddress; } });
|
|
50
55
|
var metadata_document_js_1 = require("./metadata-document.js");
|
|
51
56
|
Object.defineProperty(exports, "fetchMetadataDocument", { enumerable: true, get: function () { return metadata_document_js_1.fetchMetadataDocument; } });
|
|
52
57
|
Object.defineProperty(exports, "isValidMetadataUri", { enumerable: true, get: function () { return metadata_document_js_1.isValidMetadataUri; } });
|
|
@@ -60,6 +65,8 @@ Object.defineProperty(exports, "CODE_CHALLENGE_METHODS_SUPPORTED", { enumerable:
|
|
|
60
65
|
Object.defineProperty(exports, "DEVICE_CODE_GRANT_TYPE", { enumerable: true, get: function () { return discovery_js_1.DEVICE_CODE_GRANT_TYPE; } });
|
|
61
66
|
Object.defineProperty(exports, "DEFAULT_SCOPES_SUPPORTED", { enumerable: true, get: function () { return discovery_js_1.DEFAULT_SCOPES_SUPPORTED; } });
|
|
62
67
|
Object.defineProperty(exports, "DISCOVERY_MAX_AGE_SECONDS", { enumerable: true, get: function () { return discovery_js_1.DISCOVERY_MAX_AGE_SECONDS; } });
|
|
68
|
+
Object.defineProperty(exports, "PROTECTED_RESOURCE_METADATA_PATH", { enumerable: true, get: function () { return discovery_js_1.PROTECTED_RESOURCE_METADATA_PATH; } });
|
|
69
|
+
Object.defineProperty(exports, "protectedResourceMetadataPaths", { enumerable: true, get: function () { return discovery_js_1.protectedResourceMetadataPaths; } });
|
|
63
70
|
var config_js_1 = require("./config.js");
|
|
64
71
|
Object.defineProperty(exports, "readServerConfig", { enumerable: true, get: function () { return config_js_1.readServerConfig; } });
|
|
65
72
|
Object.defineProperty(exports, "clampTtlSeconds", { enumerable: true, get: function () { return config_js_1.clampTtlSeconds; } });
|
|
@@ -76,7 +83,10 @@ Object.defineProperty(exports, "createRegistrationHandlers", { enumerable: true,
|
|
|
76
83
|
Object.defineProperty(exports, "createRegistrationRouter", { enumerable: true, get: function () { return registration_controller_js_1.createRegistrationRouter; } });
|
|
77
84
|
Object.defineProperty(exports, "toRegistrationResponse", { enumerable: true, get: function () { return registration_controller_js_1.toRegistrationResponse; } });
|
|
78
85
|
var rate_limit_js_1 = require("./rate-limit.js");
|
|
86
|
+
Object.defineProperty(exports, "createFixedWindowRateLimiter", { enumerable: true, get: function () { return rate_limit_js_1.createFixedWindowRateLimiter; } });
|
|
79
87
|
Object.defineProperty(exports, "createRegistrationRateLimiter", { enumerable: true, get: function () { return rate_limit_js_1.createRegistrationRateLimiter; } });
|
|
88
|
+
Object.defineProperty(exports, "rateLimitAddress", { enumerable: true, get: function () { return rate_limit_js_1.rateLimitAddress; } });
|
|
89
|
+
Object.defineProperty(exports, "DEFAULT_METADATA_RESOLUTION_RATE_LIMIT", { enumerable: true, get: function () { return rate_limit_js_1.DEFAULT_METADATA_RESOLUTION_RATE_LIMIT; } });
|
|
80
90
|
Object.defineProperty(exports, "DEFAULT_REGISTRATION_RATE_LIMIT", { enumerable: true, get: function () { return rate_limit_js_1.DEFAULT_REGISTRATION_RATE_LIMIT; } });
|
|
81
91
|
Object.defineProperty(exports, "DEFAULT_REGISTRATION_RATE_WINDOW_MS", { enumerable: true, get: function () { return rate_limit_js_1.DEFAULT_REGISTRATION_RATE_WINDOW_MS; } });
|
|
82
92
|
var types_js_1 = require("./types.js");
|
|
@@ -117,11 +127,13 @@ Object.defineProperty(exports, "createConsentRouter", { enumerable: true, get: f
|
|
|
117
127
|
Object.defineProperty(exports, "defaultIsSignedIn", { enumerable: true, get: function () { return consent_controller_js_1.defaultIsSignedIn; } });
|
|
118
128
|
Object.defineProperty(exports, "monogramFor", { enumerable: true, get: function () { return consent_controller_js_1.monogramFor; } });
|
|
119
129
|
Object.defineProperty(exports, "provenanceFor", { enumerable: true, get: function () { return consent_controller_js_1.provenanceFor; } });
|
|
120
|
-
Object.defineProperty(exports, "
|
|
130
|
+
Object.defineProperty(exports, "safeHttpsUri", { enumerable: true, get: function () { return consent_controller_js_1.safeHttpsUri; } });
|
|
121
131
|
Object.defineProperty(exports, "scopeDescriptionsFrom", { enumerable: true, get: function () { return consent_controller_js_1.scopeDescriptionsFrom; } });
|
|
122
132
|
Object.defineProperty(exports, "toScopeViews", { enumerable: true, get: function () { return consent_controller_js_1.toScopeViews; } });
|
|
123
133
|
Object.defineProperty(exports, "warnUndescribedScopes", { enumerable: true, get: function () { return consent_controller_js_1.warnUndescribedScopes; } });
|
|
124
134
|
Object.defineProperty(exports, "SCOPE_DESCRIPTIONS_LOCAL", { enumerable: true, get: function () { return consent_controller_js_1.SCOPE_DESCRIPTIONS_LOCAL; } });
|
|
135
|
+
var same_site_js_1 = require("./same-site.js");
|
|
136
|
+
Object.defineProperty(exports, "isSameSiteRequest", { enumerable: true, get: function () { return same_site_js_1.isSameSiteRequest; } });
|
|
125
137
|
var token_controller_js_1 = require("./token-controller.js");
|
|
126
138
|
Object.defineProperty(exports, "createTokenHandlers", { enumerable: true, get: function () { return token_controller_js_1.createTokenHandlers; } });
|
|
127
139
|
Object.defineProperty(exports, "createTokenRouter", { enumerable: true, get: function () { return token_controller_js_1.createTokenRouter; } });
|
|
@@ -134,6 +146,9 @@ Object.defineProperty(exports, "createOAuthTokenResolver", { enumerable: true, g
|
|
|
134
146
|
Object.defineProperty(exports, "missingScopes", { enumerable: true, get: function () { return bearer_js_1.missingScopes; } });
|
|
135
147
|
Object.defineProperty(exports, "requireOAuth", { enumerable: true, get: function () { return bearer_js_1.requireOAuth; } });
|
|
136
148
|
Object.defineProperty(exports, "DEFAULT_BEARER_CHALLENGE", { enumerable: true, get: function () { return bearer_js_1.DEFAULT_BEARER_CHALLENGE; } });
|
|
149
|
+
var client_prune_js_1 = require("./client-prune.js");
|
|
150
|
+
Object.defineProperty(exports, "createClientInUsePredicate", { enumerable: true, get: function () { return client_prune_js_1.createClientInUsePredicate; } });
|
|
151
|
+
Object.defineProperty(exports, "createClientPruneJob", { enumerable: true, get: function () { return client_prune_js_1.createClientPruneJob; } });
|
|
137
152
|
var revocation_service_js_1 = require("./revocation-service.js");
|
|
138
153
|
Object.defineProperty(exports, "createRevocationService", { enumerable: true, get: function () { return revocation_service_js_1.createRevocationService; } });
|
|
139
154
|
Object.defineProperty(exports, "REVOKED_BY_CLIENT", { enumerable: true, get: function () { return revocation_service_js_1.REVOKED_BY_CLIENT; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;AAEH,yEAAyE;AACzE,wEAAwE;AACxE,yEAAyE;AACzE,uEAAuE;AACvE,wBAAsB;AAEtB,qDAK2B;AAJzB,sHAAA,mBAAmB,OAAA;AACnB,mHAAA,gBAAgB,OAAA;AAChB,wHAAA,qBAAqB,OAAA;AACrB,iHAAA,cAAc,OAAA;AAIhB,+CAKwB;AAJtB,sHAAA,sBAAsB,OAAA;AACtB,qHAAA,qBAAqB,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B,OAAA;AAkB1B,+CAAmD;AAA1C,iHAAA,iBAAiB,OAAA;AAG1B,6DAK+B;AAJ7B,0HAAA,mBAAmB,OAAA;AACnB,wHAAA,iBAAiB,OAAA;AACjB,kHAAA,WAAW,OAAA;AACX,2HAAA,oBAAoB,OAAA;AAQtB,yCAOqB;AANnB,wHAAA,2BAA2B,OAAA;AAC3B,sHAAA,yBAAyB,OAAA;AACzB,qHAAA,wBAAwB,OAAA;AACxB,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,qHAAA,wBAAwB,OAAA;AAQ1B,qDAAqF;AAA5E,6HAAA,0BAA0B,OAAA;AAAE,uHAAA,oBAAoB,OAAA;AAQzD,iEAKiC;AAJ/B,gIAAA,uBAAuB,OAAA;AACvB,0HAAA,iBAAiB,OAAA;AACjB,wHAAA,eAAe,OAAA;AACf,4HAAA,mBAAmB,OAAA;AAQrB,uEAGoC;AAFlC,oIAAA,wBAAwB,OAAA;AACxB,kIAAA,sBAAsB,OAAA;AAQxB,yEAIqC;AAHnC,sIAAA,yBAAyB,OAAA;AACzB,oIAAA,uBAAuB,OAAA;AACvB,uIAAA,0BAA0B,OAAA"}
|
|
@@ -11,6 +11,16 @@ import type { ClientIdMetadataDocument } from './types.js';
|
|
|
11
11
|
* drive it directly: what a failing fetch, an oversized body or a lying
|
|
12
12
|
* document do is behaviour worth pinning, and none of it is reachable through a
|
|
13
13
|
* real network in a test suite.
|
|
14
|
+
*
|
|
15
|
+
* ## Where the URL may point
|
|
16
|
+
*
|
|
17
|
+
* The bounds below — timeout, size, hop count — bound what a fetch can *cost*.
|
|
18
|
+
* They say nothing about where it goes, and for a while nothing did: an
|
|
19
|
+
* unauthenticated `GET /oauth/authorize` naming any https URL made this server
|
|
20
|
+
* issue a request to it, so the response time answered "is there something at
|
|
21
|
+
* `10.0.0.5:443`?" for anyone who asked (boop-jd4x). `outbound-target.ts` is
|
|
22
|
+
* that guard, and it runs **before every hop**, including the ones a redirect
|
|
23
|
+
* chooses.
|
|
14
24
|
*/
|
|
15
25
|
/** The `fetch` shape this module needs. Narrower than the global on purpose. */
|
|
16
26
|
export type FetchLike = (url: string, init: {
|
|
@@ -36,6 +46,18 @@ export interface MetadataFetchOptions {
|
|
|
36
46
|
maxBytes?: number;
|
|
37
47
|
/** How many `https`→`https` hops to follow before giving up. */
|
|
38
48
|
maxRedirects?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve a hostname to the addresses it points at.
|
|
51
|
+
*
|
|
52
|
+
* Optional. Without it, every *literal* private, loopback or link-local
|
|
53
|
+
* target is still refused, and so are the names reserved for a local network;
|
|
54
|
+
* with it, a perfectly ordinary name that answers `10.0.0.5` is refused too.
|
|
55
|
+
* Injected rather than imported because a capability package has no business
|
|
56
|
+
* reaching for `node:dns`, and because a resolver in the module body is a
|
|
57
|
+
* resolver no test can stand in front of. The scaffold wires
|
|
58
|
+
* `dns.promises.lookup`.
|
|
59
|
+
*/
|
|
60
|
+
resolveHost?: (hostname: string) => Promise<string[]>;
|
|
39
61
|
}
|
|
40
62
|
export declare const DEFAULT_METADATA_TIMEOUT_MS = 3000;
|
|
41
63
|
export declare const DEFAULT_METADATA_MAX_BYTES: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-document.d.ts","sourceRoot":"","sources":["../src/metadata-document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata-document.d.ts","sourceRoot":"","sources":["../src/metadata-document.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,gFAAgF;AAChF,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,KACE,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEhC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9C,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACvD;AAED,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AACjD,eAAO,MAAM,0BAA0B,QAAY,CAAC;AACpD,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAKhD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAczD;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAoDnC"}
|
|
@@ -4,6 +4,7 @@ exports.DEFAULT_METADATA_MAX_REDIRECTS = exports.DEFAULT_METADATA_MAX_BYTES = ex
|
|
|
4
4
|
exports.isValidMetadataUri = isValidMetadataUri;
|
|
5
5
|
exports.fetchMetadataDocument = fetchMetadataDocument;
|
|
6
6
|
const errors_js_1 = require("./errors.js");
|
|
7
|
+
const outbound_target_js_1 = require("./outbound-target.js");
|
|
7
8
|
exports.DEFAULT_METADATA_TIMEOUT_MS = 3000;
|
|
8
9
|
exports.DEFAULT_METADATA_MAX_BYTES = 64 * 1024;
|
|
9
10
|
exports.DEFAULT_METADATA_MAX_REDIRECTS = 3;
|
|
@@ -44,7 +45,12 @@ async function fetchMetadataDocument(clientId, fetchImpl, options = {}) {
|
|
|
44
45
|
if (!isValidMetadataUri(clientId)) {
|
|
45
46
|
throw unusable(`client_id is not a usable https metadata document URL: ${clientId}`);
|
|
46
47
|
}
|
|
47
|
-
const body = await readDocument(clientId, fetchImpl, {
|
|
48
|
+
const body = await readDocument(clientId, fetchImpl, {
|
|
49
|
+
timeoutMs,
|
|
50
|
+
maxBytes,
|
|
51
|
+
maxRedirects,
|
|
52
|
+
resolveHost: options.resolveHost,
|
|
53
|
+
});
|
|
48
54
|
let parsed;
|
|
49
55
|
try {
|
|
50
56
|
parsed = JSON.parse(body);
|
|
@@ -78,10 +84,46 @@ async function fetchMetadataDocument(clientId, fetchImpl, options = {}) {
|
|
|
78
84
|
}
|
|
79
85
|
return doc;
|
|
80
86
|
}
|
|
81
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Refuse a target that is not on the public internet.
|
|
89
|
+
*
|
|
90
|
+
* Called before the request rather than after it, because the request *is* the
|
|
91
|
+
* leak: the body is discarded on a refusal either way, and what an attacker
|
|
92
|
+
* reads is whether the connection was made and how long it took.
|
|
93
|
+
*/
|
|
94
|
+
async function assertPublicTarget(url, resolveHost) {
|
|
95
|
+
const { hostname } = new URL(url);
|
|
96
|
+
const reason = (0, outbound_target_js_1.blockedHostReason)(hostname);
|
|
97
|
+
if (reason !== null)
|
|
98
|
+
throw unusable(`metadata document at ${url} is not fetchable: ${reason}`);
|
|
99
|
+
if (!resolveHost)
|
|
100
|
+
return;
|
|
101
|
+
let addresses;
|
|
102
|
+
try {
|
|
103
|
+
addresses = await resolveHost(hostname);
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
// Fail closed. A name we could not resolve is a name we cannot vouch for,
|
|
107
|
+
// and "could not check" must never read as "checked and fine".
|
|
108
|
+
throw unusable(`metadata document at ${url} could not be resolved: ${describe(err)}`);
|
|
109
|
+
}
|
|
110
|
+
// An empty answer is not a clean bill of health: it means nothing was
|
|
111
|
+
// checked, which is the same position as a resolver that threw.
|
|
112
|
+
if (addresses.length === 0) {
|
|
113
|
+
throw unusable(`metadata document at ${url} resolves to no address`);
|
|
114
|
+
}
|
|
115
|
+
const blocked = addresses.find((address) => (0, outbound_target_js_1.isBlockedAddress)(address));
|
|
116
|
+
if (blocked !== undefined) {
|
|
117
|
+
throw unusable(`metadata document at ${url} resolves to ${blocked}, which is not a public address`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** The transport half: target guard, redirects, timeout, size cap. */
|
|
82
121
|
async function readDocument(startUrl, fetchImpl, limits) {
|
|
83
122
|
let url = startUrl;
|
|
84
123
|
for (let hop = 0; hop <= limits.maxRedirects; hop += 1) {
|
|
124
|
+
// Every hop, not just the first: a public URL that redirects to
|
|
125
|
+
// `https://169.254.169.254` is the same probe with one step in front of it.
|
|
126
|
+
await assertPublicTarget(url, limits.resolveHost);
|
|
85
127
|
const controller = new AbortController();
|
|
86
128
|
const timer = setTimeout(() => controller.abort(), limits.timeoutMs);
|
|
87
129
|
let response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-document.js","sourceRoot":"","sources":["../src/metadata-document.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"metadata-document.js","sourceRoot":"","sources":["../src/metadata-document.ts"],"names":[],"mappings":";;;AAoFA,gDAcC;AASD,sDAwDC;AAnKD,2CAAkD;AAClD,6DAA2E;AAoE9D,QAAA,2BAA2B,GAAG,IAAK,CAAC;AACpC,QAAA,0BAA0B,GAAG,EAAE,GAAG,IAAI,CAAC;AACvC,QAAA,8BAA8B,GAAG,CAAC,CAAC;AAEhD,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAE,EAAE,CACnC,IAAI,+BAAmB,CAAC,iCAAiC,E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