avancement planning

This commit is contained in:
2026-05-26 11:58:39 +02:00
parent 619a2b240a
commit 150b97cd2e
4892 changed files with 99214 additions and 429382 deletions
@@ -1 +1 @@
{"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../../src/shared/auth-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAI,GAAG,CAIhE;AAED;;;;;;;;GAQG;AACF,wBAAgB,oBAAoB,CAClC,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,EAAE;IACzC,iBAAiB,EAAE,GAAG,GAAG,MAAM,CAAC;IAChC,kBAAkB,EAAE,GAAG,GAAG,MAAM,CAAA;CACjC,GACA,OAAO,CAwBT"}
{"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../../src/shared/auth-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,GAAG,CAI/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,EACjC,iBAAiB,EACjB,kBAAkB,EACrB,EAAE;IACC,iBAAiB,EAAE,GAAG,GAAG,MAAM,CAAC;IAChC,kBAAkB,EAAE,GAAG,GAAG,MAAM,CAAC;CACpC,GAAG,OAAO,CAwBV"}
+3 -3
View File
@@ -11,7 +11,7 @@ exports.checkResourceAllowed = checkResourceAllowed;
* Keeps everything else unchanged (scheme, domain, port, path, query).
*/
function resourceUrlFromServerUrl(url) {
const resourceURL = typeof url === "string" ? new URL(url) : new URL(url.href);
const resourceURL = typeof url === 'string' ? new URL(url) : new URL(url.href);
resourceURL.hash = ''; // Remove fragment
return resourceURL;
}
@@ -25,8 +25,8 @@ function resourceUrlFromServerUrl(url) {
* @returns true if the requested resource matches the configured resource, false otherwise
*/
function checkResourceAllowed({ requestedResource, configuredResource }) {
const requested = typeof requestedResource === "string" ? new URL(requestedResource) : new URL(requestedResource.href);
const configured = typeof configuredResource === "string" ? new URL(configuredResource) : new URL(configuredResource.href);
const requested = typeof requestedResource === 'string' ? new URL(requestedResource) : new URL(requestedResource.href);
const configured = typeof configuredResource === 'string' ? new URL(configuredResource) : new URL(configuredResource.href);
// Compare the origin (scheme, domain, and port)
if (requested.origin !== configured.origin) {
return false;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"auth-utils.js","sourceRoot":"","sources":["../../../src/shared/auth-utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAOH,4DAIC;AAWA,oDA6BC;AAjDF;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,GAAiB;IACxD,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/E,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,kBAAkB;IACzC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACF,SAAgB,oBAAoB,CAClC,EAAE,iBAAiB,EAAE,kBAAkB,EAGtC;IAED,MAAM,SAAS,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvH,MAAM,UAAU,GAAG,OAAO,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAE3H,gDAAgD;IAChD,IAAI,SAAS,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,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AC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvH,MAAM,UAAU,GAAG,OAAO,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAE3H,gDAAgD;IAChD,IAAI,SAAS,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,wDAAwD;IACxD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,8DAA8D;IAC9D,qDAAqD;IACrD,mEAAmE;IACnE,8DAA8D;IAC9D,kEAAkE;IAClE,4DAA4D;IAC5D,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,GAAG,GAAG,CAAC;IACvG,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,GAAG,GAAG,CAAC;IAE3G,OAAO,aAAa,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACpD,CAAC"}
+124 -501
View File
@@ -1,398 +1,137 @@
import { z } from "zod";
import * as z from 'zod/v4';
/**
* Reusable URL validation that disallows javascript: scheme
*/
export declare const SafeUrlSchema: z.ZodURL;
/**
* RFC 9728 OAuth Protected Resource Metadata
*/
export declare const OAuthProtectedResourceMetadataSchema: z.ZodObject<{
resource: z.ZodString;
authorization_servers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
authorization_servers: z.ZodOptional<z.ZodArray<z.ZodURL>>;
jwks_uri: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
bearer_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
resource_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
bearer_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
resource_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
resource_name: z.ZodOptional<z.ZodString>;
resource_documentation: z.ZodOptional<z.ZodString>;
resource_policy_uri: z.ZodOptional<z.ZodString>;
resource_tos_uri: z.ZodOptional<z.ZodString>;
tls_client_certificate_bound_access_tokens: z.ZodOptional<z.ZodBoolean>;
authorization_details_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
authorization_details_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
dpop_bound_access_tokens_required: z.ZodOptional<z.ZodBoolean>;
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
resource: z.ZodString;
authorization_servers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
jwks_uri: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
bearer_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
resource_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
resource_name: z.ZodOptional<z.ZodString>;
resource_documentation: z.ZodOptional<z.ZodString>;
resource_policy_uri: z.ZodOptional<z.ZodString>;
resource_tos_uri: z.ZodOptional<z.ZodString>;
tls_client_certificate_bound_access_tokens: z.ZodOptional<z.ZodBoolean>;
authorization_details_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
dpop_bound_access_tokens_required: z.ZodOptional<z.ZodBoolean>;
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
resource: z.ZodString;
authorization_servers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
jwks_uri: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
bearer_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
resource_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
resource_name: z.ZodOptional<z.ZodString>;
resource_documentation: z.ZodOptional<z.ZodString>;
resource_policy_uri: z.ZodOptional<z.ZodString>;
resource_tos_uri: z.ZodOptional<z.ZodString>;
tls_client_certificate_bound_access_tokens: z.ZodOptional<z.ZodBoolean>;
authorization_details_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
dpop_bound_access_tokens_required: z.ZodOptional<z.ZodBoolean>;
}, z.ZodTypeAny, "passthrough">>;
}, z.core.$loose>;
/**
* RFC 8414 OAuth 2.0 Authorization Server Metadata
*/
export declare const OAuthMetadataSchema: z.ZodObject<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
revocation_endpoint: z.ZodOptional<z.ZodString>;
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
authorization_endpoint: z.ZodURL;
token_endpoint: z.ZodURL;
registration_endpoint: z.ZodOptional<z.ZodURL>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
response_types_supported: z.ZodArray<z.ZodString>;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
service_documentation: z.ZodOptional<z.ZodURL>;
revocation_endpoint: z.ZodOptional<z.ZodURL>;
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
introspection_endpoint: z.ZodOptional<z.ZodString>;
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
revocation_endpoint: z.ZodOptional<z.ZodString>;
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint: z.ZodOptional<z.ZodString>;
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
revocation_endpoint: z.ZodOptional<z.ZodString>;
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint: z.ZodOptional<z.ZodString>;
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, z.ZodTypeAny, "passthrough">>;
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
}, z.core.$loose>;
/**
* OpenID Connect Discovery 1.0 Provider Metadata
* see: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
*/
export declare const OpenIdProviderMetadataSchema: z.ZodObject<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
userinfo_endpoint: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
subject_types_supported: z.ZodArray<z.ZodString, "many">;
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString, "many">;
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
authorization_endpoint: z.ZodURL;
token_endpoint: z.ZodURL;
userinfo_endpoint: z.ZodOptional<z.ZodURL>;
jwks_uri: z.ZodURL;
registration_endpoint: z.ZodOptional<z.ZodURL>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
response_types_supported: z.ZodArray<z.ZodString>;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
subject_types_supported: z.ZodArray<z.ZodString>;
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
service_documentation: z.ZodOptional<z.ZodString>;
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
op_policy_uri: z.ZodOptional<z.ZodString>;
op_tos_uri: z.ZodOptional<z.ZodString>;
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
userinfo_endpoint: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
subject_types_supported: z.ZodArray<z.ZodString, "many">;
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString, "many">;
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
op_policy_uri: z.ZodOptional<z.ZodString>;
op_tos_uri: z.ZodOptional<z.ZodString>;
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
userinfo_endpoint: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
subject_types_supported: z.ZodArray<z.ZodString, "many">;
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString, "many">;
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
op_policy_uri: z.ZodOptional<z.ZodString>;
op_tos_uri: z.ZodOptional<z.ZodString>;
}, z.ZodTypeAny, "passthrough">>;
op_policy_uri: z.ZodOptional<z.ZodURL>;
op_tos_uri: z.ZodOptional<z.ZodURL>;
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
}, z.core.$loose>;
/**
* OpenID Connect Discovery metadata that may include OAuth 2.0 fields
* This schema represents the real-world scenario where OIDC providers
* return a mix of OpenID Connect and OAuth 2.0 metadata fields
*/
export declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<z.objectUtil.extendShape<{
export declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
userinfo_endpoint: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
subject_types_supported: z.ZodArray<z.ZodString, "many">;
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString, "many">;
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
authorization_endpoint: z.ZodURL;
token_endpoint: z.ZodURL;
userinfo_endpoint: z.ZodOptional<z.ZodURL>;
jwks_uri: z.ZodURL;
registration_endpoint: z.ZodOptional<z.ZodURL>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
response_types_supported: z.ZodArray<z.ZodString>;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
subject_types_supported: z.ZodArray<z.ZodString>;
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
service_documentation: z.ZodOptional<z.ZodString>;
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
op_policy_uri: z.ZodOptional<z.ZodString>;
op_tos_uri: z.ZodOptional<z.ZodString>;
}, Pick<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
revocation_endpoint: z.ZodOptional<z.ZodString>;
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint: z.ZodOptional<z.ZodString>;
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "code_challenge_methods_supported">>, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
userinfo_endpoint: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
subject_types_supported: z.ZodArray<z.ZodString, "many">;
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString, "many">;
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
op_policy_uri: z.ZodOptional<z.ZodString>;
op_tos_uri: z.ZodOptional<z.ZodString>;
}, Pick<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
revocation_endpoint: z.ZodOptional<z.ZodString>;
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint: z.ZodOptional<z.ZodString>;
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "code_challenge_methods_supported">>, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
userinfo_endpoint: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
subject_types_supported: z.ZodArray<z.ZodString, "many">;
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString, "many">;
id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
op_policy_uri: z.ZodOptional<z.ZodString>;
op_tos_uri: z.ZodOptional<z.ZodString>;
}, Pick<{
issuer: z.ZodString;
authorization_endpoint: z.ZodString;
token_endpoint: z.ZodString;
registration_endpoint: z.ZodOptional<z.ZodString>;
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types_supported: z.ZodArray<z.ZodString, "many">;
response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
service_documentation: z.ZodOptional<z.ZodString>;
revocation_endpoint: z.ZodOptional<z.ZodString>;
revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint: z.ZodOptional<z.ZodString>;
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "code_challenge_methods_supported">>, z.ZodTypeAny, "passthrough">>;
op_policy_uri: z.ZodOptional<z.ZodURL>;
op_tos_uri: z.ZodOptional<z.ZodURL>;
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>;
/**
* OAuth 2.1 token response
*/
@@ -400,24 +139,10 @@ export declare const OAuthTokensSchema: z.ZodObject<{
access_token: z.ZodString;
id_token: z.ZodOptional<z.ZodString>;
token_type: z.ZodString;
expires_in: z.ZodOptional<z.ZodNumber>;
expires_in: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
scope: z.ZodOptional<z.ZodString>;
refresh_token: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
access_token: string;
token_type: string;
id_token?: string | undefined;
expires_in?: number | undefined;
scope?: string | undefined;
refresh_token?: string | undefined;
}, {
access_token: string;
token_type: string;
id_token?: string | undefined;
expires_in?: number | undefined;
scope?: string | undefined;
refresh_token?: string | undefined;
}>;
}, z.core.$strip>;
/**
* OAuth 2.1 error response
*/
@@ -425,70 +150,32 @@ export declare const OAuthErrorResponseSchema: z.ZodObject<{
error: z.ZodString;
error_description: z.ZodOptional<z.ZodString>;
error_uri: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
error: string;
error_description?: string | undefined;
error_uri?: string | undefined;
}, {
error: string;
error_description?: string | undefined;
error_uri?: string | undefined;
}>;
}, z.core.$strip>;
/**
* Optional version of SafeUrlSchema that allows empty string for retrocompatibility on tos_uri and logo_uri
*/
export declare const OptionalSafeUrlSchema: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
/**
* RFC 7591 OAuth 2.0 Dynamic Client Registration metadata
*/
export declare const OAuthClientMetadataSchema: z.ZodObject<{
redirect_uris: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
redirect_uris: z.ZodArray<z.ZodURL>;
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
grant_types: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
client_name: z.ZodOptional<z.ZodString>;
client_uri: z.ZodOptional<z.ZodString>;
logo_uri: z.ZodOptional<z.ZodString>;
client_uri: z.ZodOptional<z.ZodURL>;
logo_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
scope: z.ZodOptional<z.ZodString>;
contacts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
tos_uri: z.ZodOptional<z.ZodString>;
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
tos_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
policy_uri: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodOptional<z.ZodURL>;
jwks: z.ZodOptional<z.ZodAny>;
software_id: z.ZodOptional<z.ZodString>;
software_version: z.ZodOptional<z.ZodString>;
software_statement: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
redirect_uris: string[];
jwks_uri?: string | undefined;
scope?: string | undefined;
token_endpoint_auth_method?: string | undefined;
grant_types?: string[] | undefined;
response_types?: string[] | undefined;
client_name?: string | undefined;
client_uri?: string | undefined;
logo_uri?: string | undefined;
contacts?: string[] | undefined;
tos_uri?: string | undefined;
policy_uri?: string | undefined;
jwks?: any;
software_id?: string | undefined;
software_version?: string | undefined;
software_statement?: string | undefined;
}, {
redirect_uris: string[];
jwks_uri?: string | undefined;
scope?: string | undefined;
token_endpoint_auth_method?: string | undefined;
grant_types?: string[] | undefined;
response_types?: string[] | undefined;
client_name?: string | undefined;
client_uri?: string | undefined;
logo_uri?: string | undefined;
contacts?: string[] | undefined;
tos_uri?: string | undefined;
policy_uri?: string | undefined;
jwks?: any;
software_id?: string | undefined;
software_version?: string | undefined;
software_statement?: string | undefined;
}>;
}, z.core.$strip>;
/**
* RFC 7591 OAuth 2.0 Dynamic Client Registration client information
*/
@@ -497,111 +184,46 @@ export declare const OAuthClientInformationSchema: z.ZodObject<{
client_secret: z.ZodOptional<z.ZodString>;
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
client_id: string;
client_secret?: string | undefined;
client_id_issued_at?: number | undefined;
client_secret_expires_at?: number | undefined;
}, {
client_id: string;
client_secret?: string | undefined;
client_id_issued_at?: number | undefined;
client_secret_expires_at?: number | undefined;
}>;
}, z.core.$strip>;
/**
* RFC 7591 OAuth 2.0 Dynamic Client Registration full response (client information plus metadata)
*/
export declare const OAuthClientInformationFullSchema: z.ZodObject<z.objectUtil.extendShape<{
redirect_uris: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
export declare const OAuthClientInformationFullSchema: z.ZodObject<{
redirect_uris: z.ZodArray<z.ZodURL>;
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
grant_types: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
response_types: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
client_name: z.ZodOptional<z.ZodString>;
client_uri: z.ZodOptional<z.ZodString>;
logo_uri: z.ZodOptional<z.ZodString>;
client_uri: z.ZodOptional<z.ZodURL>;
logo_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
scope: z.ZodOptional<z.ZodString>;
contacts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
tos_uri: z.ZodOptional<z.ZodString>;
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
tos_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
policy_uri: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodOptional<z.ZodString>;
jwks_uri: z.ZodOptional<z.ZodURL>;
jwks: z.ZodOptional<z.ZodAny>;
software_id: z.ZodOptional<z.ZodString>;
software_version: z.ZodOptional<z.ZodString>;
software_statement: z.ZodOptional<z.ZodString>;
}, {
client_id: z.ZodString;
client_secret: z.ZodOptional<z.ZodString>;
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
}>, "strip", z.ZodTypeAny, {
redirect_uris: string[];
client_id: string;
jwks_uri?: string | undefined;
scope?: string | undefined;
token_endpoint_auth_method?: string | undefined;
grant_types?: string[] | undefined;
response_types?: string[] | undefined;
client_name?: string | undefined;
client_uri?: string | undefined;
logo_uri?: string | undefined;
contacts?: string[] | undefined;
tos_uri?: string | undefined;
policy_uri?: string | undefined;
jwks?: any;
software_id?: string | undefined;
software_version?: string | undefined;
software_statement?: string | undefined;
client_secret?: string | undefined;
client_id_issued_at?: number | undefined;
client_secret_expires_at?: number | undefined;
}, {
redirect_uris: string[];
client_id: string;
jwks_uri?: string | undefined;
scope?: string | undefined;
token_endpoint_auth_method?: string | undefined;
grant_types?: string[] | undefined;
response_types?: string[] | undefined;
client_name?: string | undefined;
client_uri?: string | undefined;
logo_uri?: string | undefined;
contacts?: string[] | undefined;
tos_uri?: string | undefined;
policy_uri?: string | undefined;
jwks?: any;
software_id?: string | undefined;
software_version?: string | undefined;
software_statement?: string | undefined;
client_secret?: string | undefined;
client_id_issued_at?: number | undefined;
client_secret_expires_at?: number | undefined;
}>;
}, z.core.$strip>;
/**
* RFC 7591 OAuth 2.0 Dynamic Client Registration error response
*/
export declare const OAuthClientRegistrationErrorSchema: z.ZodObject<{
error: z.ZodString;
error_description: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
error: string;
error_description?: string | undefined;
}, {
error: string;
error_description?: string | undefined;
}>;
}, z.core.$strip>;
/**
* RFC 7009 OAuth 2.0 Token Revocation request
*/
export declare const OAuthTokenRevocationRequestSchema: z.ZodObject<{
token: z.ZodString;
token_type_hint: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
token: string;
token_type_hint?: string | undefined;
}, {
token: string;
token_type_hint?: string | undefined;
}>;
}, z.core.$strip>;
export type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;
export type OpenIdProviderMetadata = z.infer<typeof OpenIdProviderMetadataSchema>;
export type OpenIdProviderDiscoveryMetadata = z.infer<typeof OpenIdProviderDiscoveryMetadataSchema>;
@@ -610,6 +232,7 @@ export type OAuthErrorResponse = z.infer<typeof OAuthErrorResponseSchema>;
export type OAuthClientMetadata = z.infer<typeof OAuthClientMetadataSchema>;
export type OAuthClientInformation = z.infer<typeof OAuthClientInformationSchema>;
export type OAuthClientInformationFull = z.infer<typeof OAuthClientInformationFullSchema>;
export type OAuthClientInformationMixed = OAuthClientInformation | OAuthClientInformationFull;
export type OAuthClientRegistrationError = z.infer<typeof OAuthClientRegistrationErrorSchema>;
export type OAuthTokenRevocationRequest = z.infer<typeof OAuthTokenRevocationRequestSchema>;
export type OAuthProtectedResourceMetadata = z.infer<typeof OAuthProtectedResourceMetadataSchema>;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/shared/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAiBjC,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA6BhB,CAAC;AAEjB;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA4CzB,CAAC;AAEjB;;;;GAIG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sEAK/C,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EASpB,CAAC;AAEX;;GAEG;AACH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MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAEpG,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAC1F,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,GAAG,0BAA0B,CAAC;AAC9F,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAC9F,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAC5F,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC;AAGlG,MAAM,MAAM,2BAA2B,GAAG,aAAa,GAAG,+BAA+B,CAAC"}
+180 -142
View File
@@ -1,170 +1,204 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OAuthTokenRevocationRequestSchema = exports.OAuthClientRegistrationErrorSchema = exports.OAuthClientInformationFullSchema = exports.OAuthClientInformationSchema = exports.OAuthClientMetadataSchema = exports.OAuthErrorResponseSchema = exports.OAuthTokensSchema = exports.OpenIdProviderDiscoveryMetadataSchema = exports.OpenIdProviderMetadataSchema = exports.OAuthMetadataSchema = exports.OAuthProtectedResourceMetadataSchema = void 0;
const zod_1 = require("zod");
exports.OAuthTokenRevocationRequestSchema = exports.OAuthClientRegistrationErrorSchema = exports.OAuthClientInformationFullSchema = exports.OAuthClientInformationSchema = exports.OAuthClientMetadataSchema = exports.OptionalSafeUrlSchema = exports.OAuthErrorResponseSchema = exports.OAuthTokensSchema = exports.OpenIdProviderDiscoveryMetadataSchema = exports.OpenIdProviderMetadataSchema = exports.OAuthMetadataSchema = exports.OAuthProtectedResourceMetadataSchema = exports.SafeUrlSchema = void 0;
const z = __importStar(require("zod/v4"));
/**
* Reusable URL validation that disallows javascript: scheme
*/
exports.SafeUrlSchema = z
.url()
.superRefine((val, ctx) => {
if (!URL.canParse(val)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'URL must be parseable',
fatal: true
});
return z.NEVER;
}
})
.refine(url => {
const u = new URL(url);
return u.protocol !== 'javascript:' && u.protocol !== 'data:' && u.protocol !== 'vbscript:';
}, { message: 'URL cannot use javascript:, data:, or vbscript: scheme' });
/**
* RFC 9728 OAuth Protected Resource Metadata
*/
exports.OAuthProtectedResourceMetadataSchema = zod_1.z
.object({
resource: zod_1.z.string().url(),
authorization_servers: zod_1.z.array(zod_1.z.string().url()).optional(),
jwks_uri: zod_1.z.string().url().optional(),
scopes_supported: zod_1.z.array(zod_1.z.string()).optional(),
bearer_methods_supported: zod_1.z.array(zod_1.z.string()).optional(),
resource_signing_alg_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
resource_name: zod_1.z.string().optional(),
resource_documentation: zod_1.z.string().optional(),
resource_policy_uri: zod_1.z.string().url().optional(),
resource_tos_uri: zod_1.z.string().url().optional(),
tls_client_certificate_bound_access_tokens: zod_1.z.boolean().optional(),
authorization_details_types_supported: zod_1.z.array(zod_1.z.string()).optional(),
dpop_signing_alg_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
dpop_bound_access_tokens_required: zod_1.z.boolean().optional(),
})
.passthrough();
exports.OAuthProtectedResourceMetadataSchema = z.looseObject({
resource: z.string().url(),
authorization_servers: z.array(exports.SafeUrlSchema).optional(),
jwks_uri: z.string().url().optional(),
scopes_supported: z.array(z.string()).optional(),
bearer_methods_supported: z.array(z.string()).optional(),
resource_signing_alg_values_supported: z.array(z.string()).optional(),
resource_name: z.string().optional(),
resource_documentation: z.string().optional(),
resource_policy_uri: z.string().url().optional(),
resource_tos_uri: z.string().url().optional(),
tls_client_certificate_bound_access_tokens: z.boolean().optional(),
authorization_details_types_supported: z.array(z.string()).optional(),
dpop_signing_alg_values_supported: z.array(z.string()).optional(),
dpop_bound_access_tokens_required: z.boolean().optional()
});
/**
* RFC 8414 OAuth 2.0 Authorization Server Metadata
*/
exports.OAuthMetadataSchema = zod_1.z
.object({
issuer: zod_1.z.string(),
authorization_endpoint: zod_1.z.string(),
token_endpoint: zod_1.z.string(),
registration_endpoint: zod_1.z.string().optional(),
scopes_supported: zod_1.z.array(zod_1.z.string()).optional(),
response_types_supported: zod_1.z.array(zod_1.z.string()),
response_modes_supported: zod_1.z.array(zod_1.z.string()).optional(),
grant_types_supported: zod_1.z.array(zod_1.z.string()).optional(),
token_endpoint_auth_methods_supported: zod_1.z.array(zod_1.z.string()).optional(),
token_endpoint_auth_signing_alg_values_supported: zod_1.z
.array(zod_1.z.string())
.optional(),
service_documentation: zod_1.z.string().optional(),
revocation_endpoint: zod_1.z.string().optional(),
revocation_endpoint_auth_methods_supported: zod_1.z.array(zod_1.z.string()).optional(),
revocation_endpoint_auth_signing_alg_values_supported: zod_1.z
.array(zod_1.z.string())
.optional(),
introspection_endpoint: zod_1.z.string().optional(),
introspection_endpoint_auth_methods_supported: zod_1.z
.array(zod_1.z.string())
.optional(),
introspection_endpoint_auth_signing_alg_values_supported: zod_1.z
.array(zod_1.z.string())
.optional(),
code_challenge_methods_supported: zod_1.z.array(zod_1.z.string()).optional(),
})
.passthrough();
exports.OAuthMetadataSchema = z.looseObject({
issuer: z.string(),
authorization_endpoint: exports.SafeUrlSchema,
token_endpoint: exports.SafeUrlSchema,
registration_endpoint: exports.SafeUrlSchema.optional(),
scopes_supported: z.array(z.string()).optional(),
response_types_supported: z.array(z.string()),
response_modes_supported: z.array(z.string()).optional(),
grant_types_supported: z.array(z.string()).optional(),
token_endpoint_auth_methods_supported: z.array(z.string()).optional(),
token_endpoint_auth_signing_alg_values_supported: z.array(z.string()).optional(),
service_documentation: exports.SafeUrlSchema.optional(),
revocation_endpoint: exports.SafeUrlSchema.optional(),
revocation_endpoint_auth_methods_supported: z.array(z.string()).optional(),
revocation_endpoint_auth_signing_alg_values_supported: z.array(z.string()).optional(),
introspection_endpoint: z.string().optional(),
introspection_endpoint_auth_methods_supported: z.array(z.string()).optional(),
introspection_endpoint_auth_signing_alg_values_supported: z.array(z.string()).optional(),
code_challenge_methods_supported: z.array(z.string()).optional(),
client_id_metadata_document_supported: z.boolean().optional()
});
/**
* OpenID Connect Discovery 1.0 Provider Metadata
* see: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
*/
exports.OpenIdProviderMetadataSchema = zod_1.z
.object({
issuer: zod_1.z.string(),
authorization_endpoint: zod_1.z.string(),
token_endpoint: zod_1.z.string(),
userinfo_endpoint: zod_1.z.string().optional(),
jwks_uri: zod_1.z.string(),
registration_endpoint: zod_1.z.string().optional(),
scopes_supported: zod_1.z.array(zod_1.z.string()).optional(),
response_types_supported: zod_1.z.array(zod_1.z.string()),
response_modes_supported: zod_1.z.array(zod_1.z.string()).optional(),
grant_types_supported: zod_1.z.array(zod_1.z.string()).optional(),
acr_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
subject_types_supported: zod_1.z.array(zod_1.z.string()),
id_token_signing_alg_values_supported: zod_1.z.array(zod_1.z.string()),
id_token_encryption_alg_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
id_token_encryption_enc_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
userinfo_signing_alg_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
userinfo_encryption_alg_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
userinfo_encryption_enc_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
request_object_signing_alg_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
request_object_encryption_alg_values_supported: zod_1.z
.array(zod_1.z.string())
.optional(),
request_object_encryption_enc_values_supported: zod_1.z
.array(zod_1.z.string())
.optional(),
token_endpoint_auth_methods_supported: zod_1.z.array(zod_1.z.string()).optional(),
token_endpoint_auth_signing_alg_values_supported: zod_1.z
.array(zod_1.z.string())
.optional(),
display_values_supported: zod_1.z.array(zod_1.z.string()).optional(),
claim_types_supported: zod_1.z.array(zod_1.z.string()).optional(),
claims_supported: zod_1.z.array(zod_1.z.string()).optional(),
service_documentation: zod_1.z.string().optional(),
claims_locales_supported: zod_1.z.array(zod_1.z.string()).optional(),
ui_locales_supported: zod_1.z.array(zod_1.z.string()).optional(),
claims_parameter_supported: zod_1.z.boolean().optional(),
request_parameter_supported: zod_1.z.boolean().optional(),
request_uri_parameter_supported: zod_1.z.boolean().optional(),
require_request_uri_registration: zod_1.z.boolean().optional(),
op_policy_uri: zod_1.z.string().optional(),
op_tos_uri: zod_1.z.string().optional(),
})
.passthrough();
exports.OpenIdProviderMetadataSchema = z.looseObject({
issuer: z.string(),
authorization_endpoint: exports.SafeUrlSchema,
token_endpoint: exports.SafeUrlSchema,
userinfo_endpoint: exports.SafeUrlSchema.optional(),
jwks_uri: exports.SafeUrlSchema,
registration_endpoint: exports.SafeUrlSchema.optional(),
scopes_supported: z.array(z.string()).optional(),
response_types_supported: z.array(z.string()),
response_modes_supported: z.array(z.string()).optional(),
grant_types_supported: z.array(z.string()).optional(),
acr_values_supported: z.array(z.string()).optional(),
subject_types_supported: z.array(z.string()),
id_token_signing_alg_values_supported: z.array(z.string()),
id_token_encryption_alg_values_supported: z.array(z.string()).optional(),
id_token_encryption_enc_values_supported: z.array(z.string()).optional(),
userinfo_signing_alg_values_supported: z.array(z.string()).optional(),
userinfo_encryption_alg_values_supported: z.array(z.string()).optional(),
userinfo_encryption_enc_values_supported: z.array(z.string()).optional(),
request_object_signing_alg_values_supported: z.array(z.string()).optional(),
request_object_encryption_alg_values_supported: z.array(z.string()).optional(),
request_object_encryption_enc_values_supported: z.array(z.string()).optional(),
token_endpoint_auth_methods_supported: z.array(z.string()).optional(),
token_endpoint_auth_signing_alg_values_supported: z.array(z.string()).optional(),
display_values_supported: z.array(z.string()).optional(),
claim_types_supported: z.array(z.string()).optional(),
claims_supported: z.array(z.string()).optional(),
service_documentation: z.string().optional(),
claims_locales_supported: z.array(z.string()).optional(),
ui_locales_supported: z.array(z.string()).optional(),
claims_parameter_supported: z.boolean().optional(),
request_parameter_supported: z.boolean().optional(),
request_uri_parameter_supported: z.boolean().optional(),
require_request_uri_registration: z.boolean().optional(),
op_policy_uri: exports.SafeUrlSchema.optional(),
op_tos_uri: exports.SafeUrlSchema.optional(),
client_id_metadata_document_supported: z.boolean().optional()
});
/**
* OpenID Connect Discovery metadata that may include OAuth 2.0 fields
* This schema represents the real-world scenario where OIDC providers
* return a mix of OpenID Connect and OAuth 2.0 metadata fields
*/
exports.OpenIdProviderDiscoveryMetadataSchema = exports.OpenIdProviderMetadataSchema.merge(exports.OAuthMetadataSchema.pick({
code_challenge_methods_supported: true,
}));
exports.OpenIdProviderDiscoveryMetadataSchema = z.object({
...exports.OpenIdProviderMetadataSchema.shape,
...exports.OAuthMetadataSchema.pick({
code_challenge_methods_supported: true
}).shape
});
/**
* OAuth 2.1 token response
*/
exports.OAuthTokensSchema = zod_1.z
exports.OAuthTokensSchema = z
.object({
access_token: zod_1.z.string(),
id_token: zod_1.z.string().optional(), // Optional for OAuth 2.1, but necessary in OpenID Connect
token_type: zod_1.z.string(),
expires_in: zod_1.z.number().optional(),
scope: zod_1.z.string().optional(),
refresh_token: zod_1.z.string().optional(),
access_token: z.string(),
id_token: z.string().optional(), // Optional for OAuth 2.1, but necessary in OpenID Connect
token_type: z.string(),
expires_in: z.coerce.number().optional(),
scope: z.string().optional(),
refresh_token: z.string().optional()
})
.strip();
/**
* OAuth 2.1 error response
*/
exports.OAuthErrorResponseSchema = zod_1.z
.object({
error: zod_1.z.string(),
error_description: zod_1.z.string().optional(),
error_uri: zod_1.z.string().optional(),
exports.OAuthErrorResponseSchema = z.object({
error: z.string(),
error_description: z.string().optional(),
error_uri: z.string().optional()
});
/**
* Optional version of SafeUrlSchema that allows empty string for retrocompatibility on tos_uri and logo_uri
*/
exports.OptionalSafeUrlSchema = exports.SafeUrlSchema.optional().or(z.literal('').transform(() => undefined));
/**
* RFC 7591 OAuth 2.0 Dynamic Client Registration metadata
*/
exports.OAuthClientMetadataSchema = zod_1.z.object({
redirect_uris: zod_1.z.array(zod_1.z.string()).refine((uris) => uris.every((uri) => URL.canParse(uri)), { message: "redirect_uris must contain valid URLs" }),
token_endpoint_auth_method: zod_1.z.string().optional(),
grant_types: zod_1.z.array(zod_1.z.string()).optional(),
response_types: zod_1.z.array(zod_1.z.string()).optional(),
client_name: zod_1.z.string().optional(),
client_uri: zod_1.z.string().optional(),
logo_uri: zod_1.z.string().optional(),
scope: zod_1.z.string().optional(),
contacts: zod_1.z.array(zod_1.z.string()).optional(),
tos_uri: zod_1.z.string().optional(),
policy_uri: zod_1.z.string().optional(),
jwks_uri: zod_1.z.string().optional(),
jwks: zod_1.z.any().optional(),
software_id: zod_1.z.string().optional(),
software_version: zod_1.z.string().optional(),
software_statement: zod_1.z.string().optional(),
}).strip();
exports.OAuthClientMetadataSchema = z
.object({
redirect_uris: z.array(exports.SafeUrlSchema),
token_endpoint_auth_method: z.string().optional(),
grant_types: z.array(z.string()).optional(),
response_types: z.array(z.string()).optional(),
client_name: z.string().optional(),
client_uri: exports.SafeUrlSchema.optional(),
logo_uri: exports.OptionalSafeUrlSchema,
scope: z.string().optional(),
contacts: z.array(z.string()).optional(),
tos_uri: exports.OptionalSafeUrlSchema,
policy_uri: z.string().optional(),
jwks_uri: exports.SafeUrlSchema.optional(),
jwks: z.any().optional(),
software_id: z.string().optional(),
software_version: z.string().optional(),
software_statement: z.string().optional()
})
.strip();
/**
* RFC 7591 OAuth 2.0 Dynamic Client Registration client information
*/
exports.OAuthClientInformationSchema = zod_1.z.object({
client_id: zod_1.z.string(),
client_secret: zod_1.z.string().optional(),
client_id_issued_at: zod_1.z.number().optional(),
client_secret_expires_at: zod_1.z.number().optional(),
}).strip();
exports.OAuthClientInformationSchema = z
.object({
client_id: z.string(),
client_secret: z.string().optional(),
client_id_issued_at: z.number().optional(),
client_secret_expires_at: z.number().optional()
})
.strip();
/**
* RFC 7591 OAuth 2.0 Dynamic Client Registration full response (client information plus metadata)
*/
@@ -172,15 +206,19 @@ exports.OAuthClientInformationFullSchema = exports.OAuthClientMetadataSchema.mer
/**
* RFC 7591 OAuth 2.0 Dynamic Client Registration error response
*/
exports.OAuthClientRegistrationErrorSchema = zod_1.z.object({
error: zod_1.z.string(),
error_description: zod_1.z.string().optional(),
}).strip();
exports.OAuthClientRegistrationErrorSchema = z
.object({
error: z.string(),
error_description: z.string().optional()
})
.strip();
/**
* RFC 7009 OAuth 2.0 Token Revocation request
*/
exports.OAuthTokenRevocationRequestSchema = zod_1.z.object({
token: zod_1.z.string(),
token_type_hint: zod_1.z.string().optional(),
}).strip();
exports.OAuthTokenRevocationRequestSchema = z
.object({
token: z.string(),
token_type_hint: z.string().optional()
})
.strip();
//# sourceMappingURL=auth.js.map
File diff suppressed because one or more lines are too long
+6 -2
View File
@@ -1,4 +1,4 @@
import { BaseMetadata } from "../types.js";
import { BaseMetadata } from '../types.js';
/**
* Utilities for working with BaseMetadata objects.
*/
@@ -8,5 +8,9 @@ import { BaseMetadata } from "../types.js";
* For other objects: title → name
* This implements the spec requirement: "if no title is provided, name should be used for display purposes"
*/
export declare function getDisplayName(metadata: BaseMetadata): string;
export declare function getDisplayName(metadata: BaseMetadata | (BaseMetadata & {
annotations?: {
title?: string;
};
})): string;
//# sourceMappingURL=metadataUtils.d.ts.map
@@ -1 +1 @@
{"version":3,"file":"metadataUtils.d.ts","sourceRoot":"","sources":["../../../src/shared/metadataUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;GAEG;AAEH;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAgB7D"}
{"version":3,"file":"metadataUtils.d.ts","sourceRoot":"","sources":["../../../src/shared/metadataUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;GAEG;AAEH;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,CAAC,YAAY,GAAG;IAAE,WAAW,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,GAAG,MAAM,CAarH"}
+2 -6
View File
@@ -11,17 +11,13 @@ exports.getDisplayName = getDisplayName;
* This implements the spec requirement: "if no title is provided, name should be used for display purposes"
*/
function getDisplayName(metadata) {
var _a;
// First check for title (not undefined and not empty string)
if (metadata.title !== undefined && metadata.title !== '') {
return metadata.title;
}
// Then check for annotations.title (only present in Tool objects)
if ('annotations' in metadata) {
const metadataWithAnnotations = metadata;
if ((_a = metadataWithAnnotations.annotations) === null || _a === void 0 ? void 0 : _a.title) {
return metadataWithAnnotations.annotations.title;
}
if ('annotations' in metadata && metadata.annotations?.title) {
return metadata.annotations.title;
}
// Finally fall back to name
return metadata.name;
@@ -1 +1 @@
{"version":3,"file":"metadataUtils.js","sourceRoot":"","sources":["../../../src/shared/metadataUtils.ts"],"names":[],"mappings":";;AAYA,wCAgBC;AA1BD;;GAEG;AAEH;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,QAAsB;;IACnD,6DAA6D;IAC7D,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,KAAK,EAAE,EAAE,CAAC;QAC1D,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC;IAED,kEAAkE;IAClE,IAAI,aAAa,IAAI,QAAQ,EAAE,CAAC;QAC9B,MAAM,uBAAuB,GAAG,QAA+D,CAAC;QAChG,IAAI,MAAA,uBAAuB,CAAC,WAAW,0CAAE,KAAK,EAAE,CAAC;YAC/C,OAAO,uBAAuB,CAAC,WAAW,CAAC,KAAK,CAAC;QACnD,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC"}
{"version":3,"file":"metadataUtils.js","sourceRoot":"","sources":["../../../src/shared/metadataUtils.ts"],"names":[],"mappings":";;AAYA,wCAaC;AAvBD;;GAEG;AAEH;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,QAA8E;IACzG,6DAA6D;IAC7D,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,KAAK,EAAE,EAAE,CAAC;QACxD,OAAO,QAAQ,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,kEAAkE;IAClE,IAAI,aAAa,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC;QAC3D,OAAO,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC;IACtC,CAAC;IAED,4BAA4B;IAC5B,OAAO,QAAQ,CAAC,IAAI,CAAC;AACzB,CAAC"}
+230 -16
View File
@@ -1,7 +1,9 @@
import { ZodLiteral, ZodObject, ZodType, z } from "zod";
import { ClientCapabilities, JSONRPCRequest, Notification, Progress, Request, RequestId, Result, ServerCapabilities, RequestMeta, RequestInfo } from "../types.js";
import { Transport, TransportSendOptions } from "./transport.js";
import { AuthInfo } from "../server/auth/types.js";
import { AnySchema, AnyObjectSchema, SchemaOutput } from '../server/zod-compat.js';
import { ClientCapabilities, GetTaskRequest, GetTaskPayloadRequest, ListTasksResultSchema, CancelTaskResultSchema, JSONRPCRequest, Progress, RequestId, Result, ServerCapabilities, RequestMeta, RequestInfo, GetTaskResult, TaskCreationParams, RelatedTaskMetadata, Task, Request, Notification } from '../types.js';
import { Transport, TransportSendOptions } from './transport.js';
import { AuthInfo } from '../server/auth/types.js';
import { TaskStore, TaskMessageQueue, CreateTaskOptions } from '../experimental/tasks/interfaces.js';
import { ResponseMessage } from './responseMessage.js';
/**
* Callback for progress notifications.
*/
@@ -25,6 +27,29 @@ export type ProtocolOptions = {
* e.g., ['notifications/tools/list_changed']
*/
debouncedNotificationMethods?: string[];
/**
* Optional task storage implementation. If provided, enables task-related request handlers
* and provides task storage capabilities to request handlers.
*/
taskStore?: TaskStore;
/**
* Optional task message queue implementation for managing server-initiated messages
* that will be delivered through the tasks/result response stream.
*/
taskMessageQueue?: TaskMessageQueue;
/**
* Default polling interval (in milliseconds) for task status checks when no pollInterval
* is provided by the server. Defaults to 5000ms if not specified.
*/
defaultTaskPollInterval?: number;
/**
* Maximum number of messages that can be queued per task for side-channel delivery.
* If undefined, the queue size is unbounded.
* When the limit is exceeded, the TaskMessageQueue implementation's enqueue() method
* will throw an error. It's the implementation's responsibility to handle overflow
* appropriately (e.g., by failing the task, dropping messages, etc.).
*/
maxTaskQueueSize?: number;
};
/**
* The default request timeout, in miliseconds.
@@ -36,6 +61,8 @@ export declare const DEFAULT_REQUEST_TIMEOUT_MSEC = 60000;
export type RequestOptions = {
/**
* If set, requests progress notifications from the remote end (if supported). When progress notifications are received, this callback will be invoked.
*
* For task-augmented requests: progress notifications continue after CreateTaskResult is returned and stop automatically when the task reaches a terminal status.
*/
onprogress?: ProgressCallback;
/**
@@ -60,6 +87,14 @@ export type RequestOptions = {
* If not specified, there is no maximum total timeout.
*/
maxTotalTimeout?: number;
/**
* If provided, augments the request with task creation parameters to enable call-now, fetch-later execution patterns.
*/
task?: TaskCreationParams;
/**
* If provided, associates this request with a related task.
*/
relatedTask?: RelatedTaskMetadata;
} & TransportSendOptions;
/**
* Options that can be given per notification.
@@ -69,7 +104,69 @@ export type NotificationOptions = {
* May be used to indicate to the transport which incoming request to associate this outgoing notification with.
*/
relatedRequestId?: RequestId;
/**
* If provided, associates this notification with a related task.
*/
relatedTask?: RelatedTaskMetadata;
};
/**
* Options that can be given per request.
*/
export type TaskRequestOptions = Omit<RequestOptions, 'relatedTask'>;
/**
* Request-scoped TaskStore interface.
*/
export interface RequestTaskStore {
/**
* Creates a new task with the given creation parameters.
* The implementation generates a unique taskId and createdAt timestamp.
*
* @param taskParams - The task creation parameters from the request
* @returns The created task object
*/
createTask(taskParams: CreateTaskOptions): Promise<Task>;
/**
* Gets the current status of a task.
*
* @param taskId - The task identifier
* @returns The task object
* @throws If the task does not exist
*/
getTask(taskId: string): Promise<Task>;
/**
* Stores the result of a task and sets its final status.
*
* @param taskId - The task identifier
* @param status - The final status: 'completed' for success, 'failed' for errors
* @param result - The result to store
*/
storeTaskResult(taskId: string, status: 'completed' | 'failed', result: Result): Promise<void>;
/**
* Retrieves the stored result of a task.
*
* @param taskId - The task identifier
* @returns The stored result
*/
getTaskResult(taskId: string): Promise<Result>;
/**
* Updates a task's status (e.g., to 'cancelled', 'failed', 'completed').
*
* @param taskId - The task identifier
* @param status - The new status
* @param statusMessage - Optional diagnostic message for failed tasks or other status information
*/
updateTaskStatus(taskId: string, status: Task['status'], statusMessage?: string): Promise<void>;
/**
* Lists tasks, optionally starting from a pagination cursor.
*
* @param cursor - Optional cursor for pagination
* @returns An object containing the tasks array and an optional nextCursor
*/
listTasks(cursor?: string): Promise<{
tasks: Task[];
nextCursor?: string;
}>;
}
/**
* Extra data given to request handlers.
*/
@@ -95,6 +192,9 @@ export type RequestHandlerExtra<SendRequestT extends Request, SendNotificationT
* This can be useful for tracking or logging purposes.
*/
requestId: RequestId;
taskId?: string;
taskStore?: RequestTaskStore;
taskRequestedTtl?: number | null;
/**
* The original HTTP request.
*/
@@ -110,7 +210,19 @@ export type RequestHandlerExtra<SendRequestT extends Request, SendNotificationT
*
* This is used by certain transports to correctly associate related messages.
*/
sendRequest: <U extends ZodType<object>>(request: SendRequestT, resultSchema: U, options?: RequestOptions) => Promise<z.infer<U>>;
sendRequest: <U extends AnySchema>(request: SendRequestT, resultSchema: U, options?: TaskRequestOptions) => Promise<SchemaOutput<U>>;
/**
* Closes the SSE stream for this request, triggering client reconnection.
* Only available when using StreamableHTTPServerTransport with eventStore configured.
* Use this to implement polling behavior during long-running operations.
*/
closeSSEStream?: () => void;
/**
* Closes the standalone GET SSE stream, triggering client reconnection.
* Only available when using StreamableHTTPServerTransport with eventStore configured.
* Use this to implement polling behavior for server-initiated notifications.
*/
closeStandaloneSSEStream?: () => void;
};
/**
* Implements MCP protocol framing on top of a pluggable transport, including
@@ -127,6 +239,10 @@ export declare abstract class Protocol<SendRequestT extends Request, SendNotific
private _progressHandlers;
private _timeoutInfo;
private _pendingDebouncedNotifications;
private _taskProgressTokens;
private _taskStore?;
private _taskMessageQueue?;
private _requestResolvers;
/**
* Callback for when the connection is closed for any reason.
*
@@ -148,6 +264,7 @@ export declare abstract class Protocol<SendRequestT extends Request, SendNotific
*/
fallbackNotificationHandler?: (notification: Notification) => Promise<void>;
constructor(_options?: ProtocolOptions | undefined);
private _oncancel;
private _setupTimeout;
private _resetTimeout;
private _cleanupTimeout;
@@ -173,13 +290,13 @@ export declare abstract class Protocol<SendRequestT extends Request, SendNotific
*
* This should be implemented by subclasses.
*/
protected abstract assertCapabilityForMethod(method: SendRequestT["method"]): void;
protected abstract assertCapabilityForMethod(method: SendRequestT['method']): void;
/**
* A method to check if a notification is supported by the local side, for the given method to be sent.
*
* This should be implemented by subclasses.
*/
protected abstract assertNotificationCapability(method: SendNotificationT["method"]): void;
protected abstract assertNotificationCapability(method: SendNotificationT['method']): void;
/**
* A method to check if a request handler is supported by the local side, for the given method to be handled.
*
@@ -187,11 +304,79 @@ export declare abstract class Protocol<SendRequestT extends Request, SendNotific
*/
protected abstract assertRequestHandlerCapability(method: string): void;
/**
* Sends a request and wait for a response.
* A method to check if task creation is supported for the given request method.
*
* This should be implemented by subclasses.
*/
protected abstract assertTaskCapability(method: string): void;
/**
* A method to check if task handler is supported by the local side, for the given method to be handled.
*
* This should be implemented by subclasses.
*/
protected abstract assertTaskHandlerCapability(method: string): void;
/**
* Sends a request and returns an AsyncGenerator that yields response messages.
* The generator is guaranteed to end with either a 'result' or 'error' message.
*
* @example
* ```typescript
* const stream = protocol.requestStream(request, resultSchema, options);
* for await (const message of stream) {
* switch (message.type) {
* case 'taskCreated':
* console.log('Task created:', message.task.taskId);
* break;
* case 'taskStatus':
* console.log('Task status:', message.task.status);
* break;
* case 'result':
* console.log('Final result:', message.result);
* break;
* case 'error':
* console.error('Error:', message.error);
* break;
* }
* }
* ```
*
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
*/
protected requestStream<T extends AnySchema>(request: SendRequestT, resultSchema: T, options?: RequestOptions): AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void>;
/**
* Sends a request and waits for a response.
*
* Do not use this method to emit notifications! Use notification() instead.
*/
request<T extends ZodType<object>>(request: SendRequestT, resultSchema: T, options?: RequestOptions): Promise<z.infer<T>>;
request<T extends AnySchema>(request: SendRequestT, resultSchema: T, options?: RequestOptions): Promise<SchemaOutput<T>>;
/**
* Gets the current status of a task.
*
* @experimental Use `client.experimental.tasks.getTask()` to access this method.
*/
protected getTask(params: GetTaskRequest['params'], options?: RequestOptions): Promise<GetTaskResult>;
/**
* Retrieves the result of a completed task.
*
* @experimental Use `client.experimental.tasks.getTaskResult()` to access this method.
*/
protected getTaskResult<T extends AnySchema>(params: GetTaskPayloadRequest['params'], resultSchema: T, options?: RequestOptions): Promise<SchemaOutput<T>>;
/**
* Lists tasks, optionally starting from a pagination cursor.
*
* @experimental Use `client.experimental.tasks.listTasks()` to access this method.
*/
protected listTasks(params?: {
cursor?: string;
}, options?: RequestOptions): Promise<SchemaOutput<typeof ListTasksResultSchema>>;
/**
* Cancels a specific task.
*
* @experimental Use `client.experimental.tasks.cancelTask()` to access this method.
*/
protected cancelTask(params: {
taskId: string;
}, options?: RequestOptions): Promise<SchemaOutput<typeof CancelTaskResultSchema>>;
/**
* Emits a notification, which is a one-way message that does not expect a response.
*/
@@ -201,9 +386,7 @@ export declare abstract class Protocol<SendRequestT extends Request, SendNotific
*
* Note that this will replace any previous request handler for the same method.
*/
setRequestHandler<T extends ZodObject<{
method: ZodLiteral<string>;
}>>(requestSchema: T, handler: (request: z.infer<T>, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
setRequestHandler<T extends AnyObjectSchema>(requestSchema: T, handler: (request: SchemaOutput<T>, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
/**
* Removes the request handler for the given method.
*/
@@ -217,13 +400,44 @@ export declare abstract class Protocol<SendRequestT extends Request, SendNotific
*
* Note that this will replace any previous notification handler for the same method.
*/
setNotificationHandler<T extends ZodObject<{
method: ZodLiteral<string>;
}>>(notificationSchema: T, handler: (notification: z.infer<T>) => void | Promise<void>): void;
setNotificationHandler<T extends AnyObjectSchema>(notificationSchema: T, handler: (notification: SchemaOutput<T>) => void | Promise<void>): void;
/**
* Removes the notification handler for the given method.
*/
removeNotificationHandler(method: string): void;
/**
* Cleans up the progress handler associated with a task.
* This should be called when a task reaches a terminal status.
*/
private _cleanupTaskProgressHandler;
/**
* Enqueues a task-related message for side-channel delivery via tasks/result.
* @param taskId The task ID to associate the message with
* @param message The message to enqueue
* @param sessionId Optional session ID for binding the operation to a specific session
* @throws Error if taskStore is not configured or if enqueue fails (e.g., queue overflow)
*
* Note: If enqueue fails, it's the TaskMessageQueue implementation's responsibility to handle
* the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
* simply propagates the error.
*/
private _enqueueTaskMessage;
/**
* Clears the message queue for a task and rejects any pending request resolvers.
* @param taskId The task ID whose queue should be cleared
* @param sessionId Optional session ID for binding the operation to a specific session
*/
private _clearTaskQueue;
/**
* Waits for a task update (new messages or status change) with abort signal support.
* Uses polling to check for updates at the task's configured poll interval.
* @param taskId The task ID to wait for
* @param signal Abort signal to cancel the wait
* @returns Promise that resolves when an update occurs or rejects if aborted
*/
private _waitForTaskUpdate;
private requestTaskStore;
}
export declare function mergeCapabilities<T extends ServerCapabilities | ClientCapabilities>(base: T, additional: T): T;
export declare function mergeCapabilities(base: ServerCapabilities, additional: Partial<ServerCapabilities>): ServerCapabilities;
export declare function mergeCapabilities(base: ClientCapabilities, additional: Partial<ClientCapabilities>): ClientCapabilities;
//# sourceMappingURL=protocol.d.ts.map
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,4 +1,4 @@
import { JSONRPCMessage } from "../types.js";
import { JSONRPCMessage } from '../types.js';
/**
* Buffers a continuous stdio stream into discrete JSON-RPC messages.
*/
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../../src/shared/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AAEnE;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI3B,WAAW,IAAI,cAAc,GAAG,IAAI;IAepC,KAAK,IAAI,IAAI;CAGd;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAE/D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAEhE"}
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../../src/shared/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AAEnE;;GAEG;AACH,qBAAa,UAAU;IACnB,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI3B,WAAW,IAAI,cAAc,GAAG,IAAI;IAepC,KAAK,IAAI,IAAI;CAGhB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAE/D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAEhE"}
+3 -3
View File
@@ -15,11 +15,11 @@ class ReadBuffer {
if (!this._buffer) {
return null;
}
const index = this._buffer.indexOf("\n");
const index = this._buffer.indexOf('\n');
if (index === -1) {
return null;
}
const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, '');
const line = this._buffer.toString('utf8', 0, index).replace(/\r$/, '');
this._buffer = this._buffer.subarray(index + 1);
return deserializeMessage(line);
}
@@ -32,6 +32,6 @@ function deserializeMessage(line) {
return types_js_1.JSONRPCMessageSchema.parse(JSON.parse(line));
}
function serializeMessage(message) {
return JSON.stringify(message) + "\n";
return JSON.stringify(message) + '\n';
}
//# sourceMappingURL=stdio.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../../src/shared/stdio.ts"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ageExtraInfo, RequestId } from "../types.js";
import { JSONRPCMessage, MessageExtraInfo, RequestId } from '../types.js';
export type FetchLike = (url: string | URL, init?: RequestInit) => Promise<Response>;
/**
* Normalizes HeadersInit to a plain Record<string, string> for manipulation.
* Handles Headers objects, arrays of tuples, and plain objects.
*/
export declare function normalizeHeaders(headers: HeadersInit | undefined): Record<string, string>;
/**
* Creates a fetch function that includes base RequestInit options.
* This ensures requests inherit settings like credentials, mode, headers, etc. from the base init.
*
* @param baseFetch - The base fetch function to wrap (defaults to global fetch)
* @param baseInit - The base RequestInit to merge with each request
* @returns A wrapped fetch function that merges base options with call-specific options
*/
export declare function createFetchWithInit(baseFetch?: FetchLike, baseInit?: RequestInit): FetchLike;
/**
* Options for sending a JSON-RPC message.
*/
@@ -22,7 +36,7 @@ export type TransportSendOptions = {
onresumptiontoken?: (token: string) => void;
};
/**
* Describes the minimal contract for a MCP transport that a client or server can communicate over.
* Describes the minimal contract for an MCP transport that a client or server can communicate over.
*/
export interface Transport {
/**
@@ -62,7 +76,7 @@ export interface Transport {
*
* The requestInfo can be used to get the original request information (headers, etc.)
*/
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
onmessage?: <T extends JSONRPCMessage>(message: T, extra?: MessageExtraInfo) => void;
/**
* The session ID generated for this connection.
*/
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/shared/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE1E,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAE7B;;;;OAIG;IACH,eAA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AAmB,CAAC,SAAS,GAAE,SAAiB,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,SAAS,CAenG;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAE7B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C,CAAC;AACF;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB;;;;;;OAMG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7E;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,cAAc,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAErF;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD"}
+40
View File
@@ -1,3 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeHeaders = normalizeHeaders;
exports.createFetchWithInit = createFetchWithInit;
/**
* Normalizes HeadersInit to a plain Record<string, string> for manipulation.
* Handles Headers objects, arrays of tuples, and plain objects.
*/
function normalizeHeaders(headers) {
if (!headers)
return {};
if (headers instanceof Headers) {
return Object.fromEntries(headers.entries());
}
if (Array.isArray(headers)) {
return Object.fromEntries(headers);
}
return { ...headers };
}
/**
* Creates a fetch function that includes base RequestInit options.
* This ensures requests inherit settings like credentials, mode, headers, etc. from the base init.
*
* @param baseFetch - The base fetch function to wrap (defaults to global fetch)
* @param baseInit - The base RequestInit to merge with each request
* @returns A wrapped fetch function that merges base options with call-specific options
*/
function createFetchWithInit(baseFetch = fetch, baseInit) {
if (!baseInit) {
return baseFetch;
}
// Return a wrapped fetch that merges base RequestInit with call-specific init
return async (url, init) => {
const mergedInit = {
...baseInit,
...init,
// Headers need special handling - merge instead of replace
headers: init?.headers ? { ...normalizeHeaders(baseInit.headers), ...normalizeHeaders(init.headers) } : baseInit.headers
};
return baseFetch(url, mergedInit);
};
}
//# sourceMappingURL=transport.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/shared/transport.ts"],"names":[],"mappings":""}
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/shared/transport.ts"],"names":[],"mappings":";;AAQA,4CAYC;AAUD,kDAeC;AAzCD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,OAAgC;IAC7D,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,EAAE,GAAI,OAAkC,EAAE,CAAC;AACtD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,YAAuB,KAAK,EAAE,QAAsB;IACpF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ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G,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;CA2CrC"}
{"version":3,"file":"uriTemplate.d.ts","sourceRoot":"","sources":["../../../src/shared/uriTemplate.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAO1D,qBAAa,WAAW;IACpB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAMvC,OAAO,CAAC,MAAM,CAAC,cAAc;IAK7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyF;IAE/G,IAAI,aAAa,IAAI,MAAM,EAAE,CAE5B;gBAEW,QAAQ,EAAE,MAAM;IAM5B,QAAQ,IAAI,MAAM;IAIlB,OAAO,CAAC,KAAK;IA8Cb,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,UAAU;IAsDlB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM;IA4BpC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAkDpB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;CAuCvC"}
+69 -71
View File
@@ -23,10 +23,10 @@ class UriTemplate {
}
}
get variableNames() {
return this.parts.flatMap((part) => typeof part === 'string' ? [] : part.names);
return this.parts.flatMap(part => (typeof part === 'string' ? [] : part.names));
}
constructor(template) {
UriTemplate.validateLength(template, MAX_TEMPLATE_LENGTH, "Template");
UriTemplate.validateLength(template, MAX_TEMPLATE_LENGTH, 'Template');
this.template = template;
this.parts = this.parse(template);
}
@@ -35,30 +35,30 @@ class UriTemplate {
}
parse(template) {
const parts = [];
let currentText = "";
let currentText = '';
let i = 0;
let expressionCount = 0;
while (i < template.length) {
if (template[i] === "{") {
if (template[i] === '{') {
if (currentText) {
parts.push(currentText);
currentText = "";
currentText = '';
}
const end = template.indexOf("}", i);
const end = template.indexOf('}', i);
if (end === -1)
throw new Error("Unclosed template expression");
throw new Error('Unclosed template expression');
expressionCount++;
if (expressionCount > MAX_TEMPLATE_EXPRESSIONS) {
throw new Error(`Template contains too many expressions (max ${MAX_TEMPLATE_EXPRESSIONS})`);
}
const expr = template.slice(i + 1, end);
const operator = this.getOperator(expr);
const exploded = expr.includes("*");
const exploded = expr.includes('*');
const names = this.getNames(expr);
const name = names[0];
// Validate variable name length
for (const name of names) {
UriTemplate.validateLength(name, MAX_VARIABLE_LENGTH, "Variable name");
UriTemplate.validateLength(name, MAX_VARIABLE_LENGTH, 'Variable name');
}
parts.push({ name, operator, names, exploded });
i = end + 1;
@@ -74,75 +74,73 @@ class UriTemplate {
return parts;
}
getOperator(expr) {
const operators = ["+", "#", ".", "/", "?", "&"];
return operators.find((op) => expr.startsWith(op)) || "";
const operators = ['+', '#', '.', '/', '?', '&'];
return operators.find(op => expr.startsWith(op)) || '';
}
getNames(expr) {
const operator = this.getOperator(expr);
return expr
.slice(operator.length)
.split(",")
.map((name) => name.replace("*", "").trim())
.filter((name) => name.length > 0);
.split(',')
.map(name => name.replace('*', '').trim())
.filter(name => name.length > 0);
}
encodeValue(value, operator) {
UriTemplate.validateLength(value, MAX_VARIABLE_LENGTH, "Variable value");
if (operator === "+" || operator === "#") {
UriTemplate.validateLength(value, MAX_VARIABLE_LENGTH, 'Variable value');
if (operator === '+' || operator === '#') {
return encodeURI(value);
}
return encodeURIComponent(value);
}
expandPart(part, variables) {
if (part.operator === "?" || part.operator === "&") {
if (part.operator === '?' || part.operator === '&') {
const pairs = part.names
.map((name) => {
.map(name => {
const value = variables[name];
if (value === undefined)
return "";
return '';
const encoded = Array.isArray(value)
? value.map((v) => this.encodeValue(v, part.operator)).join(",")
? value.map(v => this.encodeValue(v, part.operator)).join(',')
: this.encodeValue(value.toString(), part.operator);
return `${name}=${encoded}`;
})
.filter((pair) => pair.length > 0);
.filter(pair => pair.length > 0);
if (pairs.length === 0)
return "";
const separator = part.operator === "?" ? "?" : "&";
return separator + pairs.join("&");
return '';
const separator = part.operator === '?' ? '?' : '&';
return separator + pairs.join('&');
}
if (part.names.length > 1) {
const values = part.names
.map((name) => variables[name])
.filter((v) => v !== undefined);
const values = part.names.map(name => variables[name]).filter(v => v !== undefined);
if (values.length === 0)
return "";
return values.map((v) => (Array.isArray(v) ? v[0] : v)).join(",");
return '';
return values.map(v => (Array.isArray(v) ? v[0] : v)).join(',');
}
const value = variables[part.name];
if (value === undefined)
return "";
return '';
const values = Array.isArray(value) ? value : [value];
const encoded = values.map((v) => this.encodeValue(v, part.operator));
const encoded = values.map(v => this.encodeValue(v, part.operator));
switch (part.operator) {
case "":
return encoded.join(",");
case "+":
return encoded.join(",");
case "#":
return "#" + encoded.join(",");
case ".":
return "." + encoded.join(".");
case "/":
return "/" + encoded.join("/");
case '':
return encoded.join(',');
case '+':
return encoded.join(',');
case '#':
return '#' + encoded.join(',');
case '.':
return '.' + encoded.join('.');
case '/':
return '/' + encoded.join('/');
default:
return encoded.join(",");
return encoded.join(',');
}
}
expand(variables) {
let result = "";
let result = '';
let hasQueryParam = false;
for (const part of this.parts) {
if (typeof part === "string") {
if (typeof part === 'string') {
result += part;
continue;
}
@@ -150,34 +148,34 @@ class UriTemplate {
if (!expanded)
continue;
// Convert ? to & if we already have a query parameter
if ((part.operator === "?" || part.operator === "&") && hasQueryParam) {
result += expanded.replace("?", "&");
if ((part.operator === '?' || part.operator === '&') && hasQueryParam) {
result += expanded.replace('?', '&');
}
else {
result += expanded;
}
if (part.operator === "?" || part.operator === "&") {
if (part.operator === '?' || part.operator === '&') {
hasQueryParam = true;
}
}
return result;
}
escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
partToRegExp(part) {
const patterns = [];
// Validate variable name length for matching
for (const name of part.names) {
UriTemplate.validateLength(name, MAX_VARIABLE_LENGTH, "Variable name");
UriTemplate.validateLength(name, MAX_VARIABLE_LENGTH, 'Variable name');
}
if (part.operator === "?" || part.operator === "&") {
if (part.operator === '?' || part.operator === '&') {
for (let i = 0; i < part.names.length; i++) {
const name = part.names[i];
const prefix = i === 0 ? "\\" + part.operator : "&";
const prefix = i === 0 ? '\\' + part.operator : '&';
patterns.push({
pattern: prefix + this.escapeRegExp(name) + "=([^&]+)",
name,
pattern: prefix + this.escapeRegExp(name) + '=([^&]+)',
name
});
}
return patterns;
@@ -185,31 +183,31 @@ class UriTemplate {
let pattern;
const name = part.name;
switch (part.operator) {
case "":
pattern = part.exploded ? "([^/]+(?:,[^/]+)*)" : "([^/,]+)";
case '':
pattern = part.exploded ? '([^/,]+(?:,[^/,]+)*)' : '([^/,]+)';
break;
case "+":
case "#":
pattern = "(.+)";
case '+':
case '#':
pattern = '(.+)';
break;
case ".":
pattern = "\\.([^/,]+)";
case '.':
pattern = '\\.([^/,]+)';
break;
case "/":
pattern = "/" + (part.exploded ? "([^/]+(?:,[^/]+)*)" : "([^/,]+)");
case '/':
pattern = '/' + (part.exploded ? '([^/,]+(?:,[^/,]+)*)' : '([^/,]+)');
break;
default:
pattern = "([^/]+)";
pattern = '([^/]+)';
}
patterns.push({ pattern, name });
return patterns;
}
match(uri) {
UriTemplate.validateLength(uri, MAX_TEMPLATE_LENGTH, "URI");
let pattern = "^";
UriTemplate.validateLength(uri, MAX_TEMPLATE_LENGTH, 'URI');
let pattern = '^';
const names = [];
for (const part of this.parts) {
if (typeof part === "string") {
if (typeof part === 'string') {
pattern += this.escapeRegExp(part);
}
else {
@@ -220,8 +218,8 @@ class UriTemplate {
}
}
}
pattern += "$";
UriTemplate.validateLength(pattern, MAX_REGEX_LENGTH, "Generated regex pattern");
pattern += '$';
UriTemplate.validateLength(pattern, MAX_REGEX_LENGTH, 'Generated regex pattern');
const regex = new RegExp(pattern);
const match = uri.match(regex);
if (!match)
@@ -230,9 +228,9 @@ class UriTemplate {
for (let i = 0; i < names.length; i++) {
const { name, exploded } = names[i];
const value = match[i + 1];
const cleanName = name.replace("*", "");
if (exploded && value.includes(",")) {
result[cleanName] = value.split(",");
const cleanName = name.replace('*', '');
if (exploded && value.includes(',')) {
result[cleanName] = value.split(',');
}
else {
result[cleanName] = value;
File diff suppressed because one or more lines are too long