@stackone/transport 2.45.3 → 2.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -220,4 +220,4 @@ $1`);let n=t.match(/(-----BEGIN [A-Z0-9 ]+-----)\n?([^-]+)(-----END [A-Z0-9 ]+--
|
|
|
220
220
|
`),O=`${d}/${l}/${s}/aws4_request`,k=[`AWS4-HMAC-SHA256`,u,O,hash(D)].join(`
|
|
221
221
|
`),A=getSigningKey(i,d,l,s),j={Authorization:`AWS4-HMAC-SHA256 Credential=${r}/${O}, SignedHeaders=${E}, Signature=${(0,g.createHmac)(`sha256`,A).update(k).digest(`hex`)}`,"x-amz-date":u,"x-amz-content-sha256":y};return a&&(j[`x-amz-security-token`]=a),C!==void 0&&(j[`x-amz-checksum-sha256`]=C),j},ot=[`sha256`,`sha512`],isValidAlgorithm=e=>ot.includes(e),hashPayload=e=>(0,g.createHash)(`sha256`).update(e).digest(`hex`),byteCompare=(e,t)=>e<t?-1:+(e>t),rfc3986Encode=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),hmacSigningStrategy=(e,t,n)=>{if(n.strategy!==`hmac`)throw Error(`hmacSigningStrategy invoked with strategy "${n.strategy}" — registry misconfiguration`);let r=t.secretKey;if(!r)throw Error(`HMAC signing requires secretKey in credentials`);let i=n;if(requiresExtendedSigning(i))return signWithExtendedOptions(e,r,i);let{algorithm:a,headerName:o,prefix:s}=i;if(a!==void 0&&!isValidAlgorithm(a))throw Error(`Unsupported HMAC algorithm "${a}". Use "sha256" or "sha512".`);let c=a??`sha256`,l=o??`X-Signature`,u=s??`hmac-${c}`,d=(/* @__PURE__ */ new Date()).toISOString(),f=new URL(e.url),p=[];for(let[e,t]of f.searchParams.entries())p.push([e,t]);p.push(...flattenQueryParams(e.query)),p.sort(([e,t],[n,r])=>{let i=byteCompare(e,n);return i===0?byteCompare(t,r):i});let m=p.map(([e,t])=>`${rfc3986Encode(e)}=${rfc3986Encode(t)}`).join(`&`),h=serializeRequestBodyForSigning(e.body,e.headers??{}),_=hashPayload(h),v=[d,e.method.toUpperCase(),f.pathname,m,_].join(`
|
|
222
222
|
`),y=(0,g.createHmac)(c,r).update(v).digest(`hex`);return{[l]:`${u} ${y}`,"X-Timestamp":d}},st=[`sha1`,`sha256`,`sha512`],formatRfc2822Date=e=>e.toUTCString().replace(`GMT`,`-0000`),extractBodyParams=e=>{let t=[];for(let[n,r]of Object.entries(e)){if(r==null)continue;let e=Array.isArray(r)?r:[r];for(let r of e)t.push([n,String(r)])}return t};function requiresExtendedSigning(e){let{algorithm:t,dateFormat:n,includeHost:r,includeBodyHash:i,outputFormat:a,username:o}=e;return!!(n===`rfc2822`||r===!0||i===!1||a===`basic`||o||t===`sha1`)}function signWithExtendedOptions(e,t,n){let{algorithm:r,headerName:i,prefix:a,dateFormat:o=`iso8601`,includeHost:s=!1,includeBodyHash:c=!0,outputFormat:l=`header`,username:u}=n;if(r&&!st.includes(r))throw Error(`Unsupported HMAC algorithm "${r}". Use "sha1", "sha256", or "sha512".`);if(l===`basic`&&!u)throw Error(`HMAC signing with outputFormat "basic" requires username`);if(u&&/[:\r\n]/.test(u))throw Error(`HMAC signing username cannot contain ":", "\\r", or "\\n"`);let d=r??`sha256`,f=new URL(e.url),p=/* @__PURE__ */ new Date,m=o===`rfc2822`?formatRfc2822Date(p):p.toISOString(),h=[...f.searchParams.entries(),...flattenQueryParams(e.query)];!c&&e.body&&typeof e.body==`object`&&!Array.isArray(e.body)&&(e.headers?.[`content-type`]??e.headers?.[`Content-Type`]??``).toLowerCase().includes(`application/x-www-form-urlencoded`)&&h.push(...extractBodyParams(e.body)),h.sort(([e,t],[n,r])=>byteCompare(e,n)||byteCompare(t,r));let _=h.map(([e,t])=>`${rfc3986Encode(e)}=${rfc3986Encode(t)}`).join(`&`),v=[m,e.method.toUpperCase()];s&&v.push(f.hostname.toLowerCase()),v.push(f.pathname,_),c&&v.push(hashPayload(serializeRequestBodyForSigning(e.body,e.headers??{})));let y=(0,g.createHmac)(d,t).update(v.join(`
|
|
223
|
-
`)).digest(`hex`);return l===`basic`?{Authorization:`Basic ${Buffer.from(`${u}:${y}`).toString(`base64`)}`,Date:m}:{[i??`X-Signature`]:`${a??`hmac-${d}`} ${y}`,"X-Timestamp":m}}const ct={},registerSigningStrategy=(e,t)=>{ct[e]=t},getSigningStrategy=e=>ct[e];registerSigningStrategy(`aws4`,aws4SigningStrategy),registerSigningStrategy(`hmac`,hmacSigningStrategy),exports.CUSTOM_ERROR_CONFIG_SCHEMA=ce,exports.ConcurrencyManager=ConcurrencyManager,exports.ConflictingProxyError=ConflictingProxyError,exports.EgressProxyError=EgressProxyError,exports.EventClient=EventClient,exports.HttpClient=HttpClient,exports.HttpClientManager=HttpClientManager,exports.HttpErrorMessages=F,exports.HttpMethods=ze,exports.HttpResponseError=R,exports.HttpTransportFactory=HttpTransportFactory,exports.InstanceManager=V,exports.InvalidEgressProxyUrlError=InvalidEgressProxyUrlError,exports.LockManager=LockManager,exports.McpClient=McpClient,exports.MemoryStore=MemoryStore,exports.PersistentInstanceManager=J,exports.QueryArrayFormats=$e,exports.QueueManager=QueueManager,exports.RateLimitManager=RateLimitManager,exports.RedisClient=re,exports.RequestAbortedError=RequestAbortedError,exports.RequestClientFactory=RequestClientFactory,exports.RequestParameterLocations=Qe,exports.ScriptManager=ScriptManager,exports.SubscriptionManager=SubscriptionManager,exports.TransportManagersUnavailableError=TransportManagersUnavailableError,exports.UntunnelledTransportError=UntunnelledTransportError,exports.buildHttpClientInstance=buildHttpClientInstance,exports.buildHttpsAgent=buildHttpsAgent,exports.convertError=convertError,exports.createAuthorizationHeaders=createAuthorizationHeaders,exports.createEgressProxyFetch=createEgressProxyFetch,exports.discoverMcpOAuthServerInfo=discoverMcpOAuthServerInfo,exports.discoverSameSiteAuthorizationServerMetadata=discoverSameSiteAuthorizationServerMetadata,exports.findEgressProxyError=findEgressProxyError,exports.findMcpIcon=findMcpIcon,exports.getCancelledCallCount=getCancelledCallCount,exports.getRetryAfterWaitTime=getRetryAfterWaitTime,exports.getSigningStrategy=getSigningStrategy,exports.getTransportInstance=getTransportInstance,exports.getTransportManagers=getTransportManagers,exports.initializeTransportSystem=initializeTransportSystem,exports.isEgressProxyError=isEgressProxyError,exports.isFailedStatusCode=isFailedStatusCode,exports.isInfoStatusCode=isInfoStatusCode,exports.isRequestAbortedError=isRequestAbortedError,exports.isSameSiteIssuer=isSameSiteIssuer,exports.isSuccessStatusCode=isSuccessStatusCode,exports.isTransportSystemReady=isTransportSystemReady,exports.mcpResourceIndicator=mcpResourceIndicator,exports.parseRequestParameters=parseRequestParameters,exports.probeMcpServer=probeMcpServer,exports.registerSigningStrategy=registerSigningStrategy,exports.serializeHttpResponseError=serializeHttpResponseError,exports.shutdownTransportSystem=shutdownTransportSystem,exports.superNormalizeHeaders=superNormalizeHeaders,exports.translateCustomError=translateCustomError;
|
|
223
|
+
`)).digest(`hex`);return l===`basic`?{Authorization:`Basic ${Buffer.from(`${u}:${y}`).toString(`base64`)}`,Date:m}:{[i??`X-Signature`]:`${a??`hmac-${d}`} ${y}`,"X-Timestamp":m}}const ct={},registerSigningStrategy=(e,t)=>{ct[e]=t},getSigningStrategy=e=>ct[e];registerSigningStrategy(`aws4`,aws4SigningStrategy),registerSigningStrategy(`hmac`,hmacSigningStrategy),exports.CUSTOM_ERROR_CONFIG_SCHEMA=ce,exports.ConcurrencyManager=ConcurrencyManager,exports.ConflictingProxyError=ConflictingProxyError,exports.EgressProxyError=EgressProxyError,exports.EventClient=EventClient,exports.HttpClient=HttpClient,exports.HttpClientManager=HttpClientManager,exports.HttpErrorMessages=F,exports.HttpMethods=ze,exports.HttpResponseError=R,exports.HttpTransportFactory=HttpTransportFactory,exports.InstanceManager=V,exports.InvalidEgressProxyUrlError=InvalidEgressProxyUrlError,exports.LockManager=LockManager,exports.McpClient=McpClient,exports.MemoryStore=MemoryStore,exports.PersistentInstanceManager=J,exports.QueryArrayFormats=$e,exports.QueueManager=QueueManager,exports.RateLimitManager=RateLimitManager,exports.RedisClient=re,exports.RequestAbortedError=RequestAbortedError,exports.RequestClientFactory=RequestClientFactory,exports.RequestParameterLocations=Qe,exports.ScriptManager=ScriptManager,exports.SubscriptionManager=SubscriptionManager,exports.TransportManagersUnavailableError=TransportManagersUnavailableError,exports.UntunnelledTransportError=UntunnelledTransportError,exports.buildHttpClientInstance=buildHttpClientInstance,exports.buildHttpsAgent=buildHttpsAgent,exports.convertError=convertError,exports.createAuthorizationHeaders=createAuthorizationHeaders,exports.createEgressProxyFetch=createEgressProxyFetch,exports.discoverMcpOAuthServerInfo=discoverMcpOAuthServerInfo,exports.discoverSameSiteAuthorizationServerMetadata=discoverSameSiteAuthorizationServerMetadata,exports.findEgressProxyError=findEgressProxyError,exports.findMcpIcon=findMcpIcon,exports.getCancelledCallCount=getCancelledCallCount,exports.getRetryAfterWaitTime=getRetryAfterWaitTime,exports.getSigningStrategy=getSigningStrategy,exports.getTransportInstance=getTransportInstance,exports.getTransportManagers=getTransportManagers,exports.initializeTransportSystem=initializeTransportSystem,exports.isEgressProxyError=isEgressProxyError,exports.isFailedStatusCode=isFailedStatusCode,exports.isInfoStatusCode=isInfoStatusCode,exports.isRequestAbortedError=isRequestAbortedError,exports.isSameSite=isSameSite,exports.isSameSiteIssuer=isSameSiteIssuer,exports.isSuccessStatusCode=isSuccessStatusCode,exports.isTransportSystemReady=isTransportSystemReady,exports.mcpResourceIndicator=mcpResourceIndicator,exports.parseRequestParameters=parseRequestParameters,exports.probeMcpServer=probeMcpServer,exports.registerSigningStrategy=registerSigningStrategy,exports.serializeHttpResponseError=serializeHttpResponseError,exports.shutdownTransportSystem=shutdownTransportSystem,exports.superNormalizeHeaders=superNormalizeHeaders,exports.translateCustomError=translateCustomError;
|
package/dist/index.d.cts
CHANGED
|
@@ -899,6 +899,7 @@ export declare class McpClient implements IMcpClient {
|
|
|
899
899
|
private buildRequestOptions;
|
|
900
900
|
}
|
|
901
901
|
type McpIconFinder = (serverUrl: string, advertisedIconUrl?: string) => Promise<string | undefined>;
|
|
902
|
+
export declare const isSameSite: (url: URL, server: URL) => boolean;
|
|
902
903
|
export declare const findMcpIcon: (serverUrl: string, advertisedIconUrl?: string, fetchFn?: typeof fetch) => Promise<string | undefined>;
|
|
903
904
|
type SameSiteIssuerFallback = {
|
|
904
905
|
expectedIssuer: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -899,6 +899,7 @@ export declare class McpClient implements IMcpClient {
|
|
|
899
899
|
private buildRequestOptions;
|
|
900
900
|
}
|
|
901
901
|
type McpIconFinder = (serverUrl: string, advertisedIconUrl?: string) => Promise<string | undefined>;
|
|
902
|
+
export declare const isSameSite: (url: URL, server: URL) => boolean;
|
|
902
903
|
export declare const findMcpIcon: (serverUrl: string, advertisedIconUrl?: string, fetchFn?: typeof fetch) => Promise<string | undefined>;
|
|
903
904
|
type SameSiteIssuerFallback = {
|
|
904
905
|
expectedIssuer: string;
|
package/dist/index.mjs
CHANGED
|
@@ -220,4 +220,4 @@ $1`);let n=t.match(/(-----BEGIN [A-Z0-9 ]+-----)\n?([^-]+)(-----END [A-Z0-9 ]+--
|
|
|
220
220
|
`),D=`${d}/${l}/${s}/aws4_request`,O=[`AWS4-HMAC-SHA256`,u,D,hash(E)].join(`
|
|
221
221
|
`),ee=getSigningKey(i,d,l,s),j={Authorization:`AWS4-HMAC-SHA256 Credential=${r}/${D}, SignedHeaders=${T}, Signature=${A(`sha256`,ee).update(O).digest(`hex`)}`,"x-amz-date":u,"x-amz-content-sha256":v};return a&&(j[`x-amz-security-token`]=a),S!==void 0&&(j[`x-amz-checksum-sha256`]=S),j},Ft=[`sha256`,`sha512`],isValidAlgorithm=e=>Ft.includes(e),hashPayload=e=>k(`sha256`).update(e).digest(`hex`),byteCompare=(e,t)=>e<t?-1:+(e>t),rfc3986Encode=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),hmacSigningStrategy=(e,t,n)=>{if(n.strategy!==`hmac`)throw Error(`hmacSigningStrategy invoked with strategy "${n.strategy}" — registry misconfiguration`);let r=t.secretKey;if(!r)throw Error(`HMAC signing requires secretKey in credentials`);let i=n;if(requiresExtendedSigning(i))return signWithExtendedOptions(e,r,i);let{algorithm:a,headerName:o,prefix:s}=i;if(a!==void 0&&!isValidAlgorithm(a))throw Error(`Unsupported HMAC algorithm "${a}". Use "sha256" or "sha512".`);let c=a??`sha256`,l=o??`X-Signature`,u=s??`hmac-${c}`,d=(/* @__PURE__ */ new Date()).toISOString(),f=new URL(e.url),p=[];for(let[e,t]of f.searchParams.entries())p.push([e,t]);p.push(...flattenQueryParams(e.query)),p.sort(([e,t],[n,r])=>{let i=byteCompare(e,n);return i===0?byteCompare(t,r):i});let m=p.map(([e,t])=>`${rfc3986Encode(e)}=${rfc3986Encode(t)}`).join(`&`),h=serializeRequestBodyForSigning(e.body,e.headers??{}),g=hashPayload(h),_=[d,e.method.toUpperCase(),f.pathname,m,g].join(`
|
|
222
222
|
`),v=A(c,r).update(_).digest(`hex`);return{[l]:`${u} ${v}`,"X-Timestamp":d}},It=[`sha1`,`sha256`,`sha512`],formatRfc2822Date=e=>e.toUTCString().replace(`GMT`,`-0000`),extractBodyParams=e=>{let t=[];for(let[n,r]of Object.entries(e)){if(r==null)continue;let e=Array.isArray(r)?r:[r];for(let r of e)t.push([n,String(r)])}return t};function requiresExtendedSigning(e){let{algorithm:t,dateFormat:n,includeHost:r,includeBodyHash:i,outputFormat:a,username:o}=e;return!!(n===`rfc2822`||r===!0||i===!1||a===`basic`||o||t===`sha1`)}function signWithExtendedOptions(e,t,n){let{algorithm:r,headerName:i,prefix:a,dateFormat:o=`iso8601`,includeHost:s=!1,includeBodyHash:c=!0,outputFormat:l=`header`,username:u}=n;if(r&&!It.includes(r))throw Error(`Unsupported HMAC algorithm "${r}". Use "sha1", "sha256", or "sha512".`);if(l===`basic`&&!u)throw Error(`HMAC signing with outputFormat "basic" requires username`);if(u&&/[:\r\n]/.test(u))throw Error(`HMAC signing username cannot contain ":", "\\r", or "\\n"`);let d=r??`sha256`,f=new URL(e.url),p=/* @__PURE__ */ new Date,m=o===`rfc2822`?formatRfc2822Date(p):p.toISOString(),h=[...f.searchParams.entries(),...flattenQueryParams(e.query)];!c&&e.body&&typeof e.body==`object`&&!Array.isArray(e.body)&&(e.headers?.[`content-type`]??e.headers?.[`Content-Type`]??``).toLowerCase().includes(`application/x-www-form-urlencoded`)&&h.push(...extractBodyParams(e.body)),h.sort(([e,t],[n,r])=>byteCompare(e,n)||byteCompare(t,r));let g=h.map(([e,t])=>`${rfc3986Encode(e)}=${rfc3986Encode(t)}`).join(`&`),_=[m,e.method.toUpperCase()];s&&_.push(f.hostname.toLowerCase()),_.push(f.pathname,g),c&&_.push(hashPayload(serializeRequestBodyForSigning(e.body,e.headers??{})));let v=A(d,t).update(_.join(`
|
|
223
|
-
`)).digest(`hex`);return l===`basic`?{Authorization:`Basic ${Buffer.from(`${u}:${v}`).toString(`base64`)}`,Date:m}:{[i??`X-Signature`]:`${a??`hmac-${d}`} ${v}`,"X-Timestamp":m}}const Lt={},registerSigningStrategy=(e,t)=>{Lt[e]=t},getSigningStrategy=e=>Lt[e];registerSigningStrategy(`aws4`,aws4SigningStrategy),registerSigningStrategy(`hmac`,hmacSigningStrategy);export{Ne as CUSTOM_ERROR_CONFIG_SCHEMA,ConcurrencyManager,ConflictingProxyError,EgressProxyError,EventClient,HttpClient,HttpClientManager,z as HttpErrorMessages,mt as HttpMethods,B as HttpResponseError,HttpTransportFactory,H as InstanceManager,InvalidEgressProxyUrlError,LockManager,McpClient,MemoryStore,J as PersistentInstanceManager,Ot as QueryArrayFormats,QueueManager,RateLimitManager,Oe as RedisClient,RequestAbortedError,RequestClientFactory,Dt as RequestParameterLocations,ScriptManager,SubscriptionManager,TransportManagersUnavailableError,UntunnelledTransportError,buildHttpClientInstance,buildHttpsAgent,convertError,createAuthorizationHeaders,createEgressProxyFetch,discoverMcpOAuthServerInfo,discoverSameSiteAuthorizationServerMetadata,findEgressProxyError,findMcpIcon,getCancelledCallCount,getRetryAfterWaitTime,getSigningStrategy,getTransportInstance,getTransportManagers,initializeTransportSystem,isEgressProxyError,isFailedStatusCode,isInfoStatusCode,isRequestAbortedError,isSameSiteIssuer,isSuccessStatusCode,isTransportSystemReady,mcpResourceIndicator,parseRequestParameters,probeMcpServer,registerSigningStrategy,serializeHttpResponseError,shutdownTransportSystem,superNormalizeHeaders,translateCustomError};
|
|
223
|
+
`)).digest(`hex`);return l===`basic`?{Authorization:`Basic ${Buffer.from(`${u}:${v}`).toString(`base64`)}`,Date:m}:{[i??`X-Signature`]:`${a??`hmac-${d}`} ${v}`,"X-Timestamp":m}}const Lt={},registerSigningStrategy=(e,t)=>{Lt[e]=t},getSigningStrategy=e=>Lt[e];registerSigningStrategy(`aws4`,aws4SigningStrategy),registerSigningStrategy(`hmac`,hmacSigningStrategy);export{Ne as CUSTOM_ERROR_CONFIG_SCHEMA,ConcurrencyManager,ConflictingProxyError,EgressProxyError,EventClient,HttpClient,HttpClientManager,z as HttpErrorMessages,mt as HttpMethods,B as HttpResponseError,HttpTransportFactory,H as InstanceManager,InvalidEgressProxyUrlError,LockManager,McpClient,MemoryStore,J as PersistentInstanceManager,Ot as QueryArrayFormats,QueueManager,RateLimitManager,Oe as RedisClient,RequestAbortedError,RequestClientFactory,Dt as RequestParameterLocations,ScriptManager,SubscriptionManager,TransportManagersUnavailableError,UntunnelledTransportError,buildHttpClientInstance,buildHttpsAgent,convertError,createAuthorizationHeaders,createEgressProxyFetch,discoverMcpOAuthServerInfo,discoverSameSiteAuthorizationServerMetadata,findEgressProxyError,findMcpIcon,getCancelledCallCount,getRetryAfterWaitTime,getSigningStrategy,getTransportInstance,getTransportManagers,initializeTransportSystem,isEgressProxyError,isFailedStatusCode,isInfoStatusCode,isRequestAbortedError,isSameSite,isSameSiteIssuer,isSuccessStatusCode,isTransportSystemReady,mcpResourceIndicator,parseRequestParameters,probeMcpServer,registerSigningStrategy,serializeHttpResponseError,shutdownTransportSystem,superNormalizeHeaders,translateCustomError};
|