@schemavaults/auth-server-sdk 0.34.0 → 0.35.0
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/README.md +58 -1
- package/dist/cli.cjs +2 -2
- package/dist/env/get-schemavaults-resource-url.d.ts +35 -0
- package/dist/env/get-schemavaults-resource-url.js +74 -0
- package/dist/env/get-schemavaults-resource-url.js.map +1 -0
- package/dist/oauth-protected-resource/index.d.ts +3 -0
- package/dist/oauth-protected-resource/index.js +4 -0
- package/dist/oauth-protected-resource/index.js.map +1 -0
- package/dist/oauth-protected-resource/protected-resource-metadata.d.ts +70 -0
- package/dist/oauth-protected-resource/protected-resource-metadata.js +76 -0
- package/dist/oauth-protected-resource/protected-resource-metadata.js.map +1 -0
- package/dist/oauth-protected-resource/route.d.ts +47 -0
- package/dist/oauth-protected-resource/route.js +83 -0
- package/dist/oauth-protected-resource/route.js.map +1 -0
- package/dist/openapi-operations/create-schemavaults-auth-resolvers.d.ts +4 -1
- package/dist/openapi-operations/create-schemavaults-auth-resolvers.js +12 -1
- package/dist/openapi-operations/create-schemavaults-auth-resolvers.js.map +1 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -98,6 +98,63 @@ changes, and only for tokens whose header names one of the listed URLs
|
|
|
98
98
|
(`resolveExpectedTokenAudience()`). Tokens with any other `aud` fail as
|
|
99
99
|
before.
|
|
100
100
|
|
|
101
|
+
`createSchemaVaultsAuthResolvers()` (see below) also accepts the resource URL
|
|
102
|
+
in `SCHEMAVAULTS_RESOURCE_URL` without configuration, with or without a
|
|
103
|
+
trailing slash; elsewhere, list them yourself with `getSchemaVaultsResourceUrl()`
|
|
104
|
+
(null when unset) and `resourceUrlAudiences(url)` from
|
|
105
|
+
`@schemavaults/auth-server-sdk/oauth-protected-resource`.
|
|
106
|
+
|
|
107
|
+
## Protected resource metadata (RFC 9728)
|
|
108
|
+
|
|
109
|
+
OAuth clients that start from nothing but your server's URL (MCP clients do)
|
|
110
|
+
discover which authorization server to use, and which `resource` URL to request
|
|
111
|
+
tokens for, from `/.well-known/oauth-protected-resource`.
|
|
112
|
+
`@schemavaults/auth-server-sdk/oauth-protected-resource` serves that document. In
|
|
113
|
+
Next.js, `app/.well-known/oauth-protected-resource/[[...path]]/route.ts` (the
|
|
114
|
+
optional catch-all also answers the path-suffixed URLs of RFC 9728 §3.1, e.g.
|
|
115
|
+
`/.well-known/oauth-protected-resource/mcp` for `https://api.example.com/mcp`):
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { createOAuthProtectedResourceMetadataRoute } from "@schemavaults/auth-server-sdk/oauth-protected-resource";
|
|
119
|
+
|
|
120
|
+
export const { GET, OPTIONS } = createOAuthProtectedResourceMetadataRoute({
|
|
121
|
+
resource_name: "My API", // optional
|
|
122
|
+
resource_documentation: "/docs", // optional; paths resolve against the resource URL
|
|
123
|
+
scopes_supported: ["mcp:tools"], // optional
|
|
124
|
+
});
|
|
125
|
+
export const dynamic = "force-dynamic";
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"resource": "https://api.example.com/mcp",
|
|
131
|
+
"authorization_servers": ["https://auth.example.com"],
|
|
132
|
+
"bearer_methods_supported": ["header"],
|
|
133
|
+
"resource_name": "My API",
|
|
134
|
+
"resource_documentation": "https://api.example.com/docs"
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- `resource` is `SCHEMAVAULTS_RESOURCE_URL` (or the `resource` option): an
|
|
139
|
+
absolute http(s) URL without query or fragment, `https` in production and
|
|
140
|
+
staging. It is what clients send as RFC 8707 `resource`, so it becomes the
|
|
141
|
+
`aud` of their access tokens; the auth resolvers accept it (above). On the
|
|
142
|
+
auth server the URL must resolve to your API server, or token requests for it
|
|
143
|
+
fail with `invalid_target`: register its origin as one of the API server's
|
|
144
|
+
domains, with `prefix` resource URL matching when the resource URL has a path
|
|
145
|
+
(`exact` suffices when it is the origin itself), and turn on
|
|
146
|
+
`allow_dynamic_clients` for dynamically registered clients.
|
|
147
|
+
- `authorization_servers` is the auth server URL (`SCHEMAVAULTS_AUTH_SERVER_URL`,
|
|
148
|
+
or the environment's default), which is the auth server's issuer.
|
|
149
|
+
- The document is public: `Access-Control-Allow-Origin: *`, cached for an hour,
|
|
150
|
+
and `OPTIONS` answers CORS preflights.
|
|
151
|
+
- Without a resource URL the route answers 404 (no metadata is published); a
|
|
152
|
+
path-suffixed request for a path that is neither the resource's nor below it is
|
|
153
|
+
a 404 too; an invalid resource URL is a 500.
|
|
154
|
+
|
|
155
|
+
`buildOAuthProtectedResourceMetadata()` and `oauthProtectedResourceMetadataUrl()`
|
|
156
|
+
(the RFC 9728 §3.1 metadata URL of a resource URL) are exported for other hosts.
|
|
157
|
+
|
|
101
158
|
## When the JWKS cannot be loaded
|
|
102
159
|
|
|
103
160
|
Route guards verify tokens with the JWKS that `RemoteJwtKeyManager` downloads from the
|
|
@@ -181,7 +238,7 @@ export const api = createOperationsAppFactory<ApiContext, UserData>({
|
|
|
181
238
|
// all optional; environment-derived defaults are read on first request
|
|
182
239
|
apiServerId, // default SCHEMAVAULTS_API_SERVER_ID
|
|
183
240
|
environment, // default getAppEnvironment()
|
|
184
|
-
acceptedAudiences: ["https://mcp.example.com/mcp"], // RFC 8707 resource URLs (see above)
|
|
241
|
+
acceptedAudiences: ["https://mcp.example.com/mcp"], // more RFC 8707 resource URLs; SCHEMAVAULTS_RESOURCE_URL is always accepted (see above)
|
|
185
242
|
isTokenRevoked, // optional revocation hook
|
|
186
243
|
}),
|
|
187
244
|
});
|
package/dist/cli.cjs
CHANGED
|
@@ -89,7 +89,7 @@ var init_resolve_codegen_templates_directory = __esm({
|
|
|
89
89
|
|
|
90
90
|
// src/NextjsAppDirectoryPlugin/codegen-marker.ts
|
|
91
91
|
function getCodegenMarkerComment() {
|
|
92
|
-
const version = true ? "0.
|
|
92
|
+
const version = true ? "0.35.0" : "unknown";
|
|
93
93
|
return `${CODEGEN_MARKER_PREFIX}${version}`;
|
|
94
94
|
}
|
|
95
95
|
function hasCodegenMarker(firstLine) {
|
|
@@ -345,7 +345,7 @@ async function main() {
|
|
|
345
345
|
return;
|
|
346
346
|
}
|
|
347
347
|
if (args.includes("--version") || args.includes("-v")) {
|
|
348
|
-
console.log(`${PACKAGE_NAME}@${"0.
|
|
348
|
+
console.log(`${PACKAGE_NAME}@${"0.35.0"}`);
|
|
349
349
|
return;
|
|
350
350
|
}
|
|
351
351
|
const command = args.find((arg) => !arg.startsWith("-")) ?? "codegen";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type SchemaVaultsAppEnvironment } from "@schemavaults/app-definitions";
|
|
2
|
+
/**
|
|
3
|
+
* The environment variable holding this resource server's resource
|
|
4
|
+
* identifier: the URL clients name it by (an RFC 8707 `resource`), the
|
|
5
|
+
* `resource` of its RFC 9728 protected resource metadata, and therefore
|
|
6
|
+
* the `aud` of the access tokens such clients obtain for it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RESOURCE_URL_ENV_VAR_NAME: "SCHEMAVAULTS_RESOURCE_URL";
|
|
9
|
+
/**
|
|
10
|
+
* @description Validates a resource identifier (RFC 9728 §1.2 / RFC 8707
|
|
11
|
+
* §2): an absolute http(s) URL without query or fragment. `https` is
|
|
12
|
+
* required in production and staging. The value is returned verbatim
|
|
13
|
+
* (only surrounding whitespace is trimmed), since it becomes a token
|
|
14
|
+
* audience that is compared byte for byte.
|
|
15
|
+
*
|
|
16
|
+
* @throws TypeError when the value is not a usable resource identifier.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseResourceUrl(value: string, environment?: SchemaVaultsAppEnvironment): string;
|
|
19
|
+
/**
|
|
20
|
+
* @returns The resource URL configured in `SCHEMAVAULTS_RESOURCE_URL`, or
|
|
21
|
+
* null when it is unset or empty.
|
|
22
|
+
* @throws TypeError when it is set to something that is not a usable
|
|
23
|
+
* resource identifier (see {@link parseResourceUrl}).
|
|
24
|
+
*/
|
|
25
|
+
export declare function getSchemaVaultsResourceUrl(environment?: SchemaVaultsAppEnvironment): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* @description The token audiences a resource URL stands for: the URL
|
|
28
|
+
* itself and its twin with (or without) one trailing slash. Clients that
|
|
29
|
+
* normalize the URL they read from the protected resource metadata
|
|
30
|
+
* (`new URL("https://api.example.com").href` is `https://api.example.com/`)
|
|
31
|
+
* request their tokens with the other spelling; the auth server resolves
|
|
32
|
+
* both to the same API server, and both are this server's own audience.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resourceUrlAudiences(resource_url: string): readonly string[];
|
|
35
|
+
export default getSchemaVaultsResourceUrl;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { getAppEnvironment, } from "@schemavaults/app-definitions";
|
|
2
|
+
/**
|
|
3
|
+
* The environment variable holding this resource server's resource
|
|
4
|
+
* identifier: the URL clients name it by (an RFC 8707 `resource`), the
|
|
5
|
+
* `resource` of its RFC 9728 protected resource metadata, and therefore
|
|
6
|
+
* the `aud` of the access tokens such clients obtain for it.
|
|
7
|
+
*/
|
|
8
|
+
export const RESOURCE_URL_ENV_VAR_NAME = "SCHEMAVAULTS_RESOURCE_URL";
|
|
9
|
+
/**
|
|
10
|
+
* @description Validates a resource identifier (RFC 9728 §1.2 / RFC 8707
|
|
11
|
+
* §2): an absolute http(s) URL without query or fragment. `https` is
|
|
12
|
+
* required in production and staging. The value is returned verbatim
|
|
13
|
+
* (only surrounding whitespace is trimmed), since it becomes a token
|
|
14
|
+
* audience that is compared byte for byte.
|
|
15
|
+
*
|
|
16
|
+
* @throws TypeError when the value is not a usable resource identifier.
|
|
17
|
+
*/
|
|
18
|
+
export function parseResourceUrl(value, environment = getAppEnvironment()) {
|
|
19
|
+
const trimmed = value.trim();
|
|
20
|
+
let url;
|
|
21
|
+
try {
|
|
22
|
+
url = new URL(trimmed);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw new TypeError(`Resource URL is not an absolute URL: '${value}'`);
|
|
26
|
+
}
|
|
27
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
28
|
+
throw new TypeError(`Resource URL must be an http(s) URL: '${value}'`);
|
|
29
|
+
}
|
|
30
|
+
if (url.protocol !== "https:" && (environment === "production" || environment === "staging")) {
|
|
31
|
+
throw new TypeError(`Resource URL must use https in ${environment}: '${value}'`);
|
|
32
|
+
}
|
|
33
|
+
if (trimmed.includes("?") || trimmed.includes("#")) {
|
|
34
|
+
throw new TypeError(`Resource URL must not include a query or fragment: '${value}'`);
|
|
35
|
+
}
|
|
36
|
+
if (url.username || url.password) {
|
|
37
|
+
throw new TypeError(`Resource URL must not include credentials: '${value}'`);
|
|
38
|
+
}
|
|
39
|
+
return trimmed;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @returns The resource URL configured in `SCHEMAVAULTS_RESOURCE_URL`, or
|
|
43
|
+
* null when it is unset or empty.
|
|
44
|
+
* @throws TypeError when it is set to something that is not a usable
|
|
45
|
+
* resource identifier (see {@link parseResourceUrl}).
|
|
46
|
+
*/
|
|
47
|
+
export function getSchemaVaultsResourceUrl(environment) {
|
|
48
|
+
const raw = process.env[RESOURCE_URL_ENV_VAR_NAME];
|
|
49
|
+
if (typeof raw !== "string" || raw.trim().length === 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return parseResourceUrl(raw, environment);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
throw new TypeError(`Invalid '${RESOURCE_URL_ENV_VAR_NAME}' environment variable: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @description The token audiences a resource URL stands for: the URL
|
|
61
|
+
* itself and its twin with (or without) one trailing slash. Clients that
|
|
62
|
+
* normalize the URL they read from the protected resource metadata
|
|
63
|
+
* (`new URL("https://api.example.com").href` is `https://api.example.com/`)
|
|
64
|
+
* request their tokens with the other spelling; the auth server resolves
|
|
65
|
+
* both to the same API server, and both are this server's own audience.
|
|
66
|
+
*/
|
|
67
|
+
export function resourceUrlAudiences(resource_url) {
|
|
68
|
+
const without = resource_url.endsWith("/")
|
|
69
|
+
? resource_url.slice(0, -1)
|
|
70
|
+
: resource_url;
|
|
71
|
+
return [resource_url, resource_url === without ? `${without}/` : without];
|
|
72
|
+
}
|
|
73
|
+
export default getSchemaVaultsResourceUrl;
|
|
74
|
+
//# sourceMappingURL=get-schemavaults-resource-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-schemavaults-resource-url.js","sourceRoot":"","sources":["../../src/env/get-schemavaults-resource-url.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAElB,MAAM,+BAA+B,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAAoC,CAAC;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAa,EACb,cAA0C,iBAAiB,EAAE;IAE7D,MAAM,OAAO,GAAW,KAAK,CAAC,IAAI,EAAE,CAAC;IACrC,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,SAAS,CAAC,yCAAyC,KAAK,GAAG,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAC1D,MAAM,IAAI,SAAS,CAAC,yCAAyC,KAAK,GAAG,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,WAAW,KAAK,YAAY,IAAI,WAAW,KAAK,SAAS,CAAC,EAAE,CAAC;QAC7F,MAAM,IAAI,SAAS,CAAC,kCA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C;IACjB,OAAO,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5E,CAAC;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createOAuthProtectedResourceMetadataRoute, type OAuthProtectedResourceMetadataRouteHandler, type OAuthProtectedResourceMetadataRouteOptions, } from "./route";
|
|
2
|
+
export { OAUTH_PROTECTED_RESOURCE_WELL_KNOWN_PATH, buildOAuthProtectedResourceMetadata, isMetadataRequestForResource, oauthProtectedResourceMetadataUrl, type BuildOAuthProtectedResourceMetadataOptions, type OAuthProtectedResourceMetadata, type OAuthProtectedResourceMetadataDetails, } from "./protected-resource-metadata";
|
|
3
|
+
export { RESOURCE_URL_ENV_VAR_NAME, getSchemaVaultsResourceUrl, parseResourceUrl, resourceUrlAudiences, } from "../env/get-schemavaults-resource-url";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createOAuthProtectedResourceMetadataRoute, } from "./route";
|
|
2
|
+
export { OAUTH_PROTECTED_RESOURCE_WELL_KNOWN_PATH, buildOAuthProtectedResourceMetadata, isMetadataRequestForResource, oauthProtectedResourceMetadataUrl, } from "./protected-resource-metadata";
|
|
3
|
+
export { RESOURCE_URL_ENV_VAR_NAME, getSchemaVaultsResourceUrl, parseResourceUrl, resourceUrlAudiences, } from "../env/get-schemavaults-resource-url";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/oauth-protected-resource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yCAAyC,GAG1C,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,wCAAwC,EACxC,mCAAmC,EACnC,4BAA4B,EAC5B,iCAAiC,GAIlC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The well-known path suffix of OAuth 2.0 Protected Resource Metadata
|
|
3
|
+
* (RFC 9728 §3).
|
|
4
|
+
*/
|
|
5
|
+
export declare const OAUTH_PROTECTED_RESOURCE_WELL_KNOWN_PATH: "/.well-known/oauth-protected-resource";
|
|
6
|
+
/**
|
|
7
|
+
* OAuth 2.0 Protected Resource Metadata (RFC 9728 §2), as served by
|
|
8
|
+
* resource servers built on this SDK. Tokens for them are presented as
|
|
9
|
+
* `Authorization: Bearer` headers (the first-party access-token cookie is
|
|
10
|
+
* not an RFC 6750 method, so it is not advertised).
|
|
11
|
+
*/
|
|
12
|
+
export interface OAuthProtectedResourceMetadata {
|
|
13
|
+
/** The resource identifier: the URL clients request tokens for (RFC 8707 `resource`). */
|
|
14
|
+
readonly resource: string;
|
|
15
|
+
/** Issuer identifiers of the authorization servers that issue tokens for this resource. */
|
|
16
|
+
readonly authorization_servers: readonly string[];
|
|
17
|
+
readonly bearer_methods_supported: readonly ["header"];
|
|
18
|
+
readonly scopes_supported?: readonly string[];
|
|
19
|
+
readonly resource_name?: string;
|
|
20
|
+
readonly resource_documentation?: string;
|
|
21
|
+
readonly resource_policy_uri?: string;
|
|
22
|
+
readonly resource_tos_uri?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Human-readable / optional members of the metadata a resource server may set. */
|
|
25
|
+
export interface OAuthProtectedResourceMetadataDetails {
|
|
26
|
+
/** Scope values clients may request for this resource (`scopes_supported`). */
|
|
27
|
+
readonly scopes_supported?: readonly string[];
|
|
28
|
+
/** Name of the resource intended for display to end users (`resource_name`). */
|
|
29
|
+
readonly resource_name?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Developer documentation of the resource (`resource_documentation`). A
|
|
32
|
+
* path (`/docs`) is resolved against the resource URL's origin.
|
|
33
|
+
*/
|
|
34
|
+
readonly resource_documentation?: string;
|
|
35
|
+
/** Policy on how clients may use the resource's data. Paths resolve like `resource_documentation`. */
|
|
36
|
+
readonly resource_policy_uri?: string;
|
|
37
|
+
/** Terms of service of the resource. Paths resolve like `resource_documentation`. */
|
|
38
|
+
readonly resource_tos_uri?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface BuildOAuthProtectedResourceMetadataOptions extends OAuthProtectedResourceMetadataDetails {
|
|
41
|
+
/** The resource identifier, verbatim. */
|
|
42
|
+
readonly resource: string;
|
|
43
|
+
/** Issuer identifiers; one trailing slash is removed from each (issuers never carry one). */
|
|
44
|
+
readonly authorization_servers: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @description Builds the protected resource metadata document. Optional
|
|
48
|
+
* members are omitted when not set; `scopes_supported` is omitted when
|
|
49
|
+
* empty.
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildOAuthProtectedResourceMetadata(options: BuildOAuthProtectedResourceMetadataOptions): OAuthProtectedResourceMetadata;
|
|
52
|
+
/**
|
|
53
|
+
* @description The URL a client fetches a resource's metadata from (RFC
|
|
54
|
+
* 9728 §3.1): the well-known path inserted between the host and the
|
|
55
|
+
* resource's path, without the path's terminating slash.
|
|
56
|
+
*
|
|
57
|
+
* `https://api.example.com` → `https://api.example.com/.well-known/oauth-protected-resource`;
|
|
58
|
+
* `https://api.example.com/mcp` → `https://api.example.com/.well-known/oauth-protected-resource/mcp`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function oauthProtectedResourceMetadataUrl(resource_url: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* @description Whether a metadata request for `request_pathname` is about
|
|
63
|
+
* `resource_url`. The bare well-known path (and a request that reached
|
|
64
|
+
* the handler under any other path, e.g. through a rewrite) is answered
|
|
65
|
+
* for every resource; a path-suffixed request (RFC 9728 §3.1) only when
|
|
66
|
+
* the suffix is the resource's path or a `/`-delimited path below it, as
|
|
67
|
+
* MCP clients ask about their server URL (`/mcp/v1`) before falling back
|
|
68
|
+
* to the bare path.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isMetadataRequestForResource(request_pathname: string, resource_url: string): boolean;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The well-known path suffix of OAuth 2.0 Protected Resource Metadata
|
|
3
|
+
* (RFC 9728 §3).
|
|
4
|
+
*/
|
|
5
|
+
export const OAUTH_PROTECTED_RESOURCE_WELL_KNOWN_PATH = "/.well-known/oauth-protected-resource";
|
|
6
|
+
function stripTrailingSlash(value) {
|
|
7
|
+
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
8
|
+
}
|
|
9
|
+
function resolveAgainstResource(value, resource) {
|
|
10
|
+
return value.startsWith("/") ? new URL(value, new URL(resource).origin).href : value;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @description Builds the protected resource metadata document. Optional
|
|
14
|
+
* members are omitted when not set; `scopes_supported` is omitted when
|
|
15
|
+
* empty.
|
|
16
|
+
*/
|
|
17
|
+
export function buildOAuthProtectedResourceMetadata(options) {
|
|
18
|
+
const { resource } = options;
|
|
19
|
+
const uri = (value) => typeof value === "string" && value.length > 0
|
|
20
|
+
? resolveAgainstResource(value, resource)
|
|
21
|
+
: undefined;
|
|
22
|
+
const resource_documentation = uri(options.resource_documentation);
|
|
23
|
+
const resource_policy_uri = uri(options.resource_policy_uri);
|
|
24
|
+
const resource_tos_uri = uri(options.resource_tos_uri);
|
|
25
|
+
return {
|
|
26
|
+
resource,
|
|
27
|
+
authorization_servers: options.authorization_servers.map(stripTrailingSlash),
|
|
28
|
+
bearer_methods_supported: ["header"],
|
|
29
|
+
...(options.scopes_supported && options.scopes_supported.length > 0
|
|
30
|
+
? { scopes_supported: [...options.scopes_supported] }
|
|
31
|
+
: {}),
|
|
32
|
+
...(options.resource_name ? { resource_name: options.resource_name } : {}),
|
|
33
|
+
...(resource_documentation ? { resource_documentation } : {}),
|
|
34
|
+
...(resource_policy_uri ? { resource_policy_uri } : {}),
|
|
35
|
+
...(resource_tos_uri ? { resource_tos_uri } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @description The URL a client fetches a resource's metadata from (RFC
|
|
40
|
+
* 9728 §3.1): the well-known path inserted between the host and the
|
|
41
|
+
* resource's path, without the path's terminating slash.
|
|
42
|
+
*
|
|
43
|
+
* `https://api.example.com` → `https://api.example.com/.well-known/oauth-protected-resource`;
|
|
44
|
+
* `https://api.example.com/mcp` → `https://api.example.com/.well-known/oauth-protected-resource/mcp`.
|
|
45
|
+
*/
|
|
46
|
+
export function oauthProtectedResourceMetadataUrl(resource_url) {
|
|
47
|
+
const url = new URL(resource_url);
|
|
48
|
+
const path = url.pathname === "/" ? "" : stripTrailingSlash(url.pathname);
|
|
49
|
+
return `${url.origin}${OAUTH_PROTECTED_RESOURCE_WELL_KNOWN_PATH}${path}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @description Whether a metadata request for `request_pathname` is about
|
|
53
|
+
* `resource_url`. The bare well-known path (and a request that reached
|
|
54
|
+
* the handler under any other path, e.g. through a rewrite) is answered
|
|
55
|
+
* for every resource; a path-suffixed request (RFC 9728 §3.1) only when
|
|
56
|
+
* the suffix is the resource's path or a `/`-delimited path below it, as
|
|
57
|
+
* MCP clients ask about their server URL (`/mcp/v1`) before falling back
|
|
58
|
+
* to the bare path.
|
|
59
|
+
*/
|
|
60
|
+
export function isMetadataRequestForResource(request_pathname, resource_url) {
|
|
61
|
+
if (!request_pathname.startsWith(OAUTH_PROTECTED_RESOURCE_WELL_KNOWN_PATH)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
const suffix = stripTrailingSlash(request_pathname.slice(OAUTH_PROTECTED_RESOURCE_WELL_KNOWN_PATH.length));
|
|
65
|
+
if (suffix.length === 0) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (!suffix.startsWith("/")) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const resource_path = stripTrailingSlash(new URL(resource_url).pathname);
|
|
72
|
+
return (resource_path.length === 0 ||
|
|
73
|
+
suffix === resource_path ||
|
|
74
|
+
suffix.startsWith(`${resource_path}/`));
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=protected-resource-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected-resource-metadata.js","sourceRoot":"","sources":["../../src/oauth-protected-resource/protected-resource-metadata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,wCAAwC,GACnD,uCAAgD,CAAC;AA8CnD,SAAS,kBAAkB,CAAC,KAAa;IACvC,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;AAED,SAAS,sBAAsB,CAAC,KAAa,EAAE,QAAgB;IAC7D,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACvF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CACjD,OAAmD;IAEnD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,GAAG,GAAG,CAAC,KAAyB,EAAsB,EAAE,CAC5D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAC3C,CAAC,CAAC,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC;QACzC,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,sBAAsB,GAAG,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;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AG,IAAI,EAAE,CAAC;AAC3E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B,CAC1C,gBAAwB,EACxB,YAAoB;IAEpB,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,wCAAwC,CAAC,EAAE,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAW,kBAAkB,CACvC,gBAAgB,CAAC,KAAK,CAAC,wCAAwC,CAAC,MAAM,CAAC,CACxE,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,aAAa,GAAW,kBAAkB,CAAC,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAAC;IACjF,OAAO,CACL,aAAa,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM,KAAK,aAAa;QACxB,MAAM,CAAC,UAAU,CAAC,GAAG,aAAa,GAAG,CAAC,CACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SchemaVaultsAppEnvironment } from "@schemavaults/app-definitions";
|
|
2
|
+
import { type OAuthProtectedResourceMetadataDetails } from "./protected-resource-metadata";
|
|
3
|
+
export interface OAuthProtectedResourceMetadataRouteOptions extends OAuthProtectedResourceMetadataDetails {
|
|
4
|
+
/**
|
|
5
|
+
* The resource identifier. Default: `SCHEMAVAULTS_RESOURCE_URL`, which
|
|
6
|
+
* `createSchemaVaultsAuthResolvers()` also accepts as a token audience;
|
|
7
|
+
* when you set it here instead, pass the same URL to their
|
|
8
|
+
* `acceptedAudiences`.
|
|
9
|
+
*/
|
|
10
|
+
readonly resource?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Issuer identifiers of the authorization servers. Default: the auth
|
|
13
|
+
* server URL (`SCHEMAVAULTS_AUTH_SERVER_URL`, or the environment's
|
|
14
|
+
* default auth server).
|
|
15
|
+
*/
|
|
16
|
+
readonly authorization_servers?: readonly string[];
|
|
17
|
+
/** Default: `getAppEnvironment()`, read per request. */
|
|
18
|
+
readonly environment?: SchemaVaultsAppEnvironment;
|
|
19
|
+
}
|
|
20
|
+
export type OAuthProtectedResourceMetadataRouteHandler = (request: Request) => Promise<Response>;
|
|
21
|
+
/**
|
|
22
|
+
* The OAuth 2.0 Protected Resource Metadata route (RFC 9728): tells
|
|
23
|
+
* OAuth clients (MCP clients, for one) which authorization server issues
|
|
24
|
+
* tokens for this resource server and which `resource` URL to request
|
|
25
|
+
* them for. In Next.js, `app/.well-known/oauth-protected-resource/[[...path]]/route.ts`
|
|
26
|
+
* (the optional catch-all also answers the path-suffixed URLs of RFC 9728
|
|
27
|
+
* §3.1):
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* export const { GET, OPTIONS } = createOAuthProtectedResourceMetadataRoute({
|
|
31
|
+
* resource_name: "My API",
|
|
32
|
+
* resource_documentation: "/docs",
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* `GET` answers the document with `Access-Control-Allow-Origin: *` (it is
|
|
37
|
+
* public; browser-based clients read it cross-origin) and a one-hour
|
|
38
|
+
* cache; `OPTIONS` answers CORS preflights. Without a resource URL
|
|
39
|
+
* (`SCHEMAVAULTS_RESOURCE_URL` unset) the route answers 404: the server
|
|
40
|
+
* publishes no metadata. A path-suffixed request for a different resource
|
|
41
|
+
* is a 404 too; an invalid resource URL is a 500.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createOAuthProtectedResourceMetadataRoute(options?: OAuthProtectedResourceMetadataRouteOptions): {
|
|
44
|
+
GET: OAuthProtectedResourceMetadataRouteHandler;
|
|
45
|
+
OPTIONS: OAuthProtectedResourceMetadataRouteHandler;
|
|
46
|
+
};
|
|
47
|
+
export default createOAuthProtectedResourceMetadataRoute;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import getSchemaVaultsAuthServerUrl from "../env/get-schemavaults-auth-server-url";
|
|
2
|
+
import { RESOURCE_URL_ENV_VAR_NAME, getSchemaVaultsResourceUrl, parseResourceUrl, } from "../env/get-schemavaults-resource-url";
|
|
3
|
+
import { buildOAuthProtectedResourceMetadata, isMetadataRequestForResource, } from "./protected-resource-metadata";
|
|
4
|
+
const CORS_HEADERS = { "Access-Control-Allow-Origin": "*" };
|
|
5
|
+
function jsonResponse(status, body, cache_control) {
|
|
6
|
+
return new Response(JSON.stringify(body), {
|
|
7
|
+
status,
|
|
8
|
+
headers: {
|
|
9
|
+
...CORS_HEADERS,
|
|
10
|
+
"Content-Type": "application/json",
|
|
11
|
+
"Cache-Control": cache_control,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function errorResponse(status, error, message) {
|
|
16
|
+
return jsonResponse(status, { error, message }, "no-store");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The OAuth 2.0 Protected Resource Metadata route (RFC 9728): tells
|
|
20
|
+
* OAuth clients (MCP clients, for one) which authorization server issues
|
|
21
|
+
* tokens for this resource server and which `resource` URL to request
|
|
22
|
+
* them for. In Next.js, `app/.well-known/oauth-protected-resource/[[...path]]/route.ts`
|
|
23
|
+
* (the optional catch-all also answers the path-suffixed URLs of RFC 9728
|
|
24
|
+
* §3.1):
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* export const { GET, OPTIONS } = createOAuthProtectedResourceMetadataRoute({
|
|
28
|
+
* resource_name: "My API",
|
|
29
|
+
* resource_documentation: "/docs",
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* `GET` answers the document with `Access-Control-Allow-Origin: *` (it is
|
|
34
|
+
* public; browser-based clients read it cross-origin) and a one-hour
|
|
35
|
+
* cache; `OPTIONS` answers CORS preflights. Without a resource URL
|
|
36
|
+
* (`SCHEMAVAULTS_RESOURCE_URL` unset) the route answers 404: the server
|
|
37
|
+
* publishes no metadata. A path-suffixed request for a different resource
|
|
38
|
+
* is a 404 too; an invalid resource URL is a 500.
|
|
39
|
+
*/
|
|
40
|
+
export function createOAuthProtectedResourceMetadataRoute(options = {}) {
|
|
41
|
+
let warned_not_configured = false;
|
|
42
|
+
const GET = async (request) => {
|
|
43
|
+
let resource;
|
|
44
|
+
let authorization_servers;
|
|
45
|
+
try {
|
|
46
|
+
resource =
|
|
47
|
+
options.resource !== undefined
|
|
48
|
+
? parseResourceUrl(options.resource, options.environment)
|
|
49
|
+
: getSchemaVaultsResourceUrl(options.environment);
|
|
50
|
+
authorization_servers = options.authorization_servers ?? [getSchemaVaultsAuthServerUrl()];
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
console.error("[oauth-protected-resource] The protected resource metadata is misconfigured:", e);
|
|
54
|
+
return errorResponse(500, "server_misconfiguration", "The protected resource metadata of this server is misconfigured.");
|
|
55
|
+
}
|
|
56
|
+
if (resource === null) {
|
|
57
|
+
if (!warned_not_configured) {
|
|
58
|
+
warned_not_configured = true;
|
|
59
|
+
console.warn(`[oauth-protected-resource] '${RESOURCE_URL_ENV_VAR_NAME}' is not set; answering 404 to protected resource metadata requests.`);
|
|
60
|
+
}
|
|
61
|
+
return errorResponse(404, "not_found", "This server does not publish protected resource metadata.");
|
|
62
|
+
}
|
|
63
|
+
if (!isMetadataRequestForResource(new URL(request.url).pathname, resource)) {
|
|
64
|
+
return errorResponse(404, "not_found", "No protected resource is published at this path.");
|
|
65
|
+
}
|
|
66
|
+
return jsonResponse(200, buildOAuthProtectedResourceMetadata({ ...options, resource, authorization_servers }), "public, max-age=3600");
|
|
67
|
+
};
|
|
68
|
+
const OPTIONS = async (request) => {
|
|
69
|
+
const requested_headers = request.headers.get("Access-Control-Request-Headers");
|
|
70
|
+
return new Response(null, {
|
|
71
|
+
status: 204,
|
|
72
|
+
headers: {
|
|
73
|
+
...CORS_HEADERS,
|
|
74
|
+
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
75
|
+
...(requested_headers ? { "Access-Control-Allow-Headers": requested_headers } : {}),
|
|
76
|
+
"Access-Control-Max-Age": "86400",
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
return { GET, OPTIONS };
|
|
81
|
+
}
|
|
82
|
+
export default createOAuthProtectedResourceMetadataRoute;
|
|
83
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/oauth-protected-resource/route.ts"],"names":[],"mappings":"AACA,OAAO,4BAA4B,MAAM,wCAAwC,CAAC;AAClF,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,mCAAmC,EACnC,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AAuBvC,MAAM,YAAY,GAAG,EAAE,6BAA6B,EAAE,GAAG,EAAW,CAAC;AAErE,SAAS,YAAY,CAAC,MAAc,EAAE,IAAa,EAAE,aAAqB;IACxE,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;QACxC,MAAM;QACN,OAAO,EAAE;YACP,GAAG,YAAY;YACf,cAAc,EAAE,kBAAkB;YAClC,eAAe,EAAE,aAAa;SAC/B;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAC,MAAiB,EAAE,KAAa,EAAE,OAAe;IACtE,OAAO,YAAY,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,yCAAyC,CACvD,UAAsD,EAAE;IAKxD,IAAI,qBAAqB,GAAY,KAAK,CAAC;IAE3C,M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AA+C,KAAK,EAAE,OAAO,EAAE,EAAE;QAC5E,MAAM,iBAAiB,GAAkB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAC/F,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;YACxB,MAAM,EAAE,GAAG;YACX,OAAO,EAAE;gBACP,GAAG,YAAY;gBACf,8BAA8B,EAAE,cAAc;gBAC9C,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnF,wBAAwB,EAAE,OAAO;aAClC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC1B,CAAC;AAED,eAAe,yCAAyC,CAAC"}
|
|
@@ -27,7 +27,10 @@ export interface CreateSchemaVaultsAuthResolversOptions {
|
|
|
27
27
|
/**
|
|
28
28
|
* RFC 8707 resource URL(s) this resource server is known by; access
|
|
29
29
|
* tokens whose `aud` is one of them are accepted too. See
|
|
30
|
-
* `RouteGuardFactory`'s `accepted_audiences`.
|
|
30
|
+
* `RouteGuardFactory`'s `accepted_audiences`. The resource URL in
|
|
31
|
+
* `SCHEMAVAULTS_RESOURCE_URL` (the one the protected resource metadata
|
|
32
|
+
* route advertises), with or without a trailing slash, is always
|
|
33
|
+
* accepted in addition, read on first use.
|
|
31
34
|
*/
|
|
32
35
|
readonly acceptedAudiences?: readonly string[];
|
|
33
36
|
/**
|
|
@@ -4,6 +4,7 @@ import { OperationError, schemaVaultsAccessTokenBearerScheme, } from "@schemavau
|
|
|
4
4
|
import { AccessTokenCookieName } from "../AccessTokenCookieNames";
|
|
5
5
|
import getSchemavaultsApiServerId from "../env/get-schemavaults-api-server-id";
|
|
6
6
|
import getSchemaVaultsAuthServerUrl from "../env/get-schemavaults-auth-server-url";
|
|
7
|
+
import { RESOURCE_URL_ENV_VAR_NAME, getSchemaVaultsResourceUrl, resourceUrlAudiences, } from "../env/get-schemavaults-resource-url";
|
|
7
8
|
import loadJwksAccessPrivateKey, { JWKS_ACCESS_PRIVATE_KEY_ENV_VAR_NAME, } from "../env/loadJwksAccessPrivateKey";
|
|
8
9
|
import isUserInOrganization from "../isUserInOrganization";
|
|
9
10
|
import listUserOrganizations from "../listUserOrganizations";
|
|
@@ -162,12 +163,22 @@ export function createSchemaVaultsAuthResolvers(options = {}) {
|
|
|
162
163
|
const resolveFactory = () => {
|
|
163
164
|
if (factory === undefined) {
|
|
164
165
|
const env = resolveEnvironment();
|
|
166
|
+
let resourceUrl;
|
|
167
|
+
try {
|
|
168
|
+
resourceUrl = getSchemaVaultsResourceUrl(env);
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
throw notConfigured(`the '${RESOURCE_URL_ENV_VAR_NAME}' environment variable is not a valid resource URL`, e);
|
|
172
|
+
}
|
|
165
173
|
try {
|
|
166
174
|
factory = new RouteGuardFactory({
|
|
167
175
|
environment: env,
|
|
168
176
|
jwt_keys_manager: keysManager,
|
|
169
177
|
is_token_revoked: options.isTokenRevoked,
|
|
170
|
-
accepted_audiences:
|
|
178
|
+
accepted_audiences: [
|
|
179
|
+
...(options.acceptedAudiences ?? []),
|
|
180
|
+
...(resourceUrl !== null ? resourceUrlAudiences(resourceUrl) : []),
|
|
181
|
+
],
|
|
171
182
|
debug,
|
|
172
183
|
});
|
|
173
184
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-schemavaults-auth-resolvers.js","sourceRoot":"","sources":["../../src/openapi-operations/create-schemavaults-auth-resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,oBAAoB,GAGrB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,cAAc,EACd,mCAAmC,GAMpC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,0BAA0B,MAAM,sCAAsC,CAAC;AAC9E,OAAO,4BAA4B,MAAM,wCAAwC,CAAC;AAClF,OAAO,wBAAwB,EAAE,EAC/B,oCAAoC,GACrC,MAAM,gCAAgC,CAAC;AACxC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,kCAAkC,EAAE,MAAM,oDAAoD,CAAC;AAExG,OAAO,iBAAiB,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,uDAAuD;AACvD,MAAM,CAAC,MAAM,4CAA4C,GACvD,mCAAmC,CAAC,IAAI,CAAC;AAC3C,MAAM,CAAC,MAAM,4CAA4C,GACvD,kCAA2C,CAAC;AAE9C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,sCAAsC,GAAG;IACpD,cAAc,EAAE,iBAAiB;IACjC,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,eAAe;IAC7B,eAAe,EAAE,kBAAkB;IACnC,aAAa,EAAE,qBAAqB;CAC5B,CAAC;
|
|
1
|
+
{"version":3,"file":"create-schemavaults-auth-resolvers.js","sourceRoot":"","sources":["../../src/openapi-operations/create-schemavaults-auth-resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,oBAAoB,GAGrB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,cAAc,EACd,mCAAmC,GAMpC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,0BAA0B,MAAM,sCAAsC,CAAC;AAC9E,OAAO,4BAA4B,MAAM,wCAAwC,CAAC;AAClF,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,oBA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
|
"description": "TypeScript SDK for building authenticated endpoints/middlewares for the Auth Server and Resource Servers",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.35.0",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"repository": {
|
|
@@ -162,6 +162,11 @@
|
|
|
162
162
|
"types": "./dist/auth-session-route/index.d.ts",
|
|
163
163
|
"import": "./dist/auth-session-route/index.js",
|
|
164
164
|
"require": "./dist/auth-session-route/index.js"
|
|
165
|
+
},
|
|
166
|
+
"./oauth-protected-resource": {
|
|
167
|
+
"types": "./dist/oauth-protected-resource/index.d.ts",
|
|
168
|
+
"import": "./dist/oauth-protected-resource/index.js",
|
|
169
|
+
"require": "./dist/oauth-protected-resource/index.js"
|
|
165
170
|
}
|
|
166
171
|
},
|
|
167
172
|
"peerDependencies": {
|