corsair 0.2.11 → 0.2.13
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/{chunk-VMOLHABP.js → chunk-3BGIQPKY.js} +19 -19
- package/dist/{connect-GUN4LLF6.js → connect-FYU35QW2.js} +1 -1
- package/dist/core.js +1 -1
- package/dist/http.d.ts +17 -2
- package/dist/http.js +1 -1
- package/dist/hub.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{loop-U5TG7ZRL.js → loop-TEXTFJP4.js} +1 -1
- package/dist/oauth.js +1 -1
- package/dist/{setup-VPZSPJJO.js → setup-7REGGECE.js} +1 -1
- package/dist/{setup-introspect-6UUWHZH2.js → setup-introspect-6FMVQWHC.js} +1 -1
- package/dist/setup.js +1 -1
- package/dist/tunnel.js +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as b,_ as a,aa as c}from"./chunk-
|
|
1
|
+
import{$ as b,_ as a,aa as c}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{c as createHubConnectSession,b as createHubConnectSessionForPlugin,a as postHubConnectSession};
|
package/dist/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$b as P,Ab as E,Bb as F,Cb as G,D as n,Db as H,E as o,Eb as I,F as p,G as q,Sb as J,Tb as K,Ub as L,Vb as M,Wb as N,_b as O,a,ac as Q,b,ba as r,bb as B,bc as R,c,ca as s,cc as S,dc as T,ec as U,fa as t,fc as V,ga as u,gc as W,ha as v,hc as X,ia as w,ic as Y,ja as x,jc as Z,ka as y,kc as _,la as z,lc as $,ma as A,mc as aa,nc as ba,oc as ca,pc as da,qc as ea,rc as fa,sc as ga,yb as C,zb as D}from"./chunk-
|
|
1
|
+
import{$b as P,Ab as E,Bb as F,Cb as G,D as n,Db as H,E as o,Eb as I,F as p,G as q,Sb as J,Tb as K,Ub as L,Vb as M,Wb as N,_b as O,a,ac as Q,b,ba as r,bb as B,bc as R,c,ca as s,cc as S,dc as T,ec as U,fa as t,fc as V,ga as u,gc as W,ha as v,hc as X,ia as w,ic as Y,ja as x,jc as Z,ka as y,kc as _,la as z,lc as $,ma as A,mc as aa,nc as ba,oc as ca,pc as da,qc as ea,rc as fa,sc as ga,yb as C,zb as D}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import{D as m,h as d,n as e,o as f,p as g,q as h,r as i,s as j,t as k,u as l}from"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{m as AccountSelectionError,B as AuthMissingError,d as BASE_AUTH_FIELDS,da as CORSAIR_INTERNAL,H as CloudApiError,C as CorsairKekMissingError,D as DB_METHOD_RISK,R as MS_GRAPH_API_BASE,A as ManagementApiError,M as OAuthRefreshError,s as PermissionRequiredError,a as ProviderDisplayNames,t as ReadonlyForbiddenError,c as ReconnectRequiredError,v as activeMode,Y as asRecord,z as assertModeAllows,y as assertReadonlyAllowed,G as callPluginDb,V as collectPluginWebhookMatchers,I as corsairCloud,o as createAccountKeyManager,ea as createCorsair,n as createIntegrationKeyManager,F as decodeDbArgs,ca as decodePubSubData,k as decryptConfig,g as decryptDEK,i as decryptWithDEK,E as encodeDbArgs,j as encryptConfig,f as encryptDEK,h as encryptWithDEK,L as exchangeCodeForTokens,$ as extractMicrosoftGraphValidationToken,ba as firstString,O as formatDocSchemaShape,b as formatProviderDisplayName,e as generateDEK,W as getHeader,N as getOAuthAccessToken,Q as googleChannelSubscribe,q as initializeAccountDEK,p as initializeIntegrationDEK,P as introspectPluginForDocs,aa as isMicrosoftGraphValidationHandshake,x as isReadonlyScopeActive,J as logEvent,K as logEventFromContext,T as matchWebhookPlugin,U as matchWebhookPluginAndTenant,S as msGraphSubscribe,l as reEncryptConfig,Z as readBodyRecord,_ as readQueryParam,r as resolveConnectLink,w as runReadonly,u as runWithMode,fa as shouldStartTunnel,ga as superviseTunnel,X as toExternalId};
|
package/dist/http.d.ts
CHANGED
|
@@ -154,17 +154,32 @@ type FileSink = (file: {
|
|
|
154
154
|
contentType: string;
|
|
155
155
|
filename?: string;
|
|
156
156
|
}) => string | null | undefined;
|
|
157
|
+
type FileSinkOptions = {
|
|
158
|
+
/**
|
|
159
|
+
* Most bytes the host returns inline. A larger file goes to the sink even
|
|
160
|
+
* when the endpoint passed a higher `maxBytes`, which then applies only
|
|
161
|
+
* where no sink is set. Defaults to FILE_OUTPUT_MAX_BYTES.
|
|
162
|
+
*/
|
|
163
|
+
inlineMaxBytes?: number;
|
|
164
|
+
/**
|
|
165
|
+
* Offer the sink every file, not only those over the limit. A file that
|
|
166
|
+
* fits comes back with its content and, when the sink keeps it, its `fileId`.
|
|
167
|
+
*/
|
|
168
|
+
everyFile?: boolean;
|
|
169
|
+
};
|
|
157
170
|
/**
|
|
158
171
|
* For a host: how toFileOutput finds the sink for the operation it is running
|
|
159
172
|
* in, usually an AsyncLocalStorage's getStore. Core keeps no async context of
|
|
160
173
|
* its own, so this module stays free of Node-only imports.
|
|
161
174
|
*/
|
|
162
|
-
declare function setFileSink(find: () => FileSink | undefined): void;
|
|
175
|
+
declare function setFileSink(find: () => FileSink | undefined, options?: FileSinkOptions): void;
|
|
163
176
|
/**
|
|
164
177
|
* Shapes downloaded bytes as a `FileOutput`. The content goes in when it was
|
|
165
178
|
* asked for and fits `maxBytes`; the size and type are always reported, so a
|
|
166
179
|
* caller that got no content still knows what it would be. Over the limit, a
|
|
167
180
|
* host's sink (setFileSink) may keep the file and the output carries its `fileId`.
|
|
181
|
+
* With a sink set, the limit is also capped at the host's `inlineMaxBytes`, so
|
|
182
|
+
* an endpoint can pass a generous `maxBytes` for callers without a host.
|
|
168
183
|
*
|
|
169
184
|
* A text file in UTF-8 comes back as `text` instead of base64, so a caller can
|
|
170
185
|
* read a CSV or JSON file as it is. A file served as application/octet-stream
|
|
@@ -249,4 +264,4 @@ declare function verifyHmacSignatureWithPrefix(payload: string | Buffer, secret:
|
|
|
249
264
|
declare function verifyHmacSha256Signature(payload: string, secret: string, timestamp: string, signature: string, maxAgeSeconds?: number): boolean;
|
|
250
265
|
declare function verifySlackSignature(payload: string, secret: string, timestamp: string, signature: string, maxAgeSeconds?: number): boolean;
|
|
251
266
|
|
|
252
|
-
export { ApiError, type ApiRequestOptions, type ApiResult, type BaseHandleWebhookResult, BaseWebhookHandler, type BinaryResponse, type DownloadDeps, type DownloadOptions, FILE_OUTPUT_MAX_BYTES, type FileInput, FileInputSchema, type FileOutput, FileOutputSchema, type FileSink, type OpenAPIConfig, type PublicDownload, type RateLimitConfig, type ResolveFileOptions, type ResolvedFile, UnsafeUrlError, type WebhookEventHandler, downloadPublicFile, isBlockedAddress, request, resolveFileInput, setFileSink, toFileOutput, verifyHmacSha256Signature, verifyHmacSignature, verifyHmacSignatureWithPrefix, verifySlackSignature };
|
|
267
|
+
export { ApiError, type ApiRequestOptions, type ApiResult, type BaseHandleWebhookResult, BaseWebhookHandler, type BinaryResponse, type DownloadDeps, type DownloadOptions, FILE_OUTPUT_MAX_BYTES, type FileInput, FileInputSchema, type FileOutput, FileOutputSchema, type FileSink, type FileSinkOptions, type OpenAPIConfig, type PublicDownload, type RateLimitConfig, type ResolveFileOptions, type ResolvedFile, UnsafeUrlError, type WebhookEventHandler, downloadPublicFile, isBlockedAddress, request, resolveFileInput, setFileSink, toFileOutput, verifyHmacSha256Signature, verifyHmacSignature, verifyHmacSignatureWithPrefix, verifySlackSignature };
|
package/dist/http.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-SOY77BN4.js";var ue=new Set(["apikey","xapikey","key","appkey","appid","token","apitoken","accesstoken","authtoken","clientsecret","secret","password"]);function C(t){let e=t;try{e=decodeURIComponent(t)}catch{e=t}return ue.has(e.toLowerCase().replace(/[-_]/g,""))}function fe(t){let e=t.indexOf("?");if(e===-1)return t;let n=t.indexOf("#",e),r=t.slice(0,e+1),i=n===-1?t.slice(e+1):t.slice(e+1,n),s=n===-1?"":t.slice(n),o=!1,a=i.split("&").map(l=>{if(!l)return l;let c=l.indexOf("="),f=c===-1?l:l.slice(0,c);return C(f)?(o=!0,`${f}=[REDACTED]`):l}).join("&");return o?r+a+s:t}function H(t){if(!t)return t;try{let e=/^[a-z]+:\/\//i.test(t),n=e?void 0:"http://localhost",r=new URL(t,n),i=!1;for(let s of[...r.searchParams.keys()])C(s)&&(r.searchParams.set(s,"[REDACTED]"),i=!0);return i?e?r.toString():r.pathname+r.search+r.hash:t}catch{return fe(t)}}function de(t){let e=H(t.url),n=!1,r=t.query;if(t.query){r={...t.query};for(let i of Object.keys(r))C(i)&&(r[i]="[REDACTED]",n=!0)}return!n&&e===t.url?t:{...t,url:e,...n?{query:r}:{}}}var h=class extends Error{url;status;statusText;body;request;retryAfter;rateLimitReset;rateLimitRemaining;rateLimitLimit;constructor(e,n,r,i){super(r),this.name="ApiError",this.url=H(n.url),this.status=n.status,this.statusText=n.statusText,this.body=n.body,this.request=de(e),this.retryAfter=i?.retryAfter,this.rateLimitReset=i?.rateLimitReset,this.rateLimitRemaining=i?.rateLimitRemaining,this.rateLimitLimit=i?.rateLimitLimit}isRateLimitError(){return this.status===429}};import{z as d}from"zod";import{lookup as me}from"dns/promises";import*as V from"http";import*as X from"https";import{pipeline as pe,Readable as he}from"stream";import*as x from"zlib";var ye=3e4,be=25*1024*1024,W=3,ge=[["0.0.0.0",8],["10.0.0.0",8],["100.64.0.0",10],["127.0.0.0",8],["169.254.0.0",16],["172.16.0.0",12],["192.0.0.0",24],["192.0.2.0",24],["192.88.99.0",24],["192.168.0.0",16],["198.18.0.0",15],["198.51.100.0",24],["203.0.113.0",24],["224.0.0.0",4],["240.0.0.0",4]];function L(t){let e=t.split(".");if(e.length!==4)return;let n=0;for(let r of e){if(!/^\d{1,3}$/.test(r))return;let i=Number(r);if(i>255)return;n=n*256+i}return n}function G(t){let e=L(t);return e===void 0?!0:ge.some(([n,r])=>{let i=L(n);if(i===void 0)return!1;let s=r===0?0:4294967295<<32-r>>>0;return(e&s)===(i&s)})}function Re(t){let e=t,n=e.indexOf("%");n!==-1&&(e=e.slice(0,n));let r=e.lastIndexOf(":");if(r===-1)return;let i=e.slice(r+1);if(i.includes(".")){let u=L(i);if(u===void 0)return;e=`${e.slice(0,r+1)}${(u>>>16).toString(16)}:${(u&65535).toString(16)}`}let s=e.split("::");if(s.length>2)return;let o=u=>u===""?[]:u.split(":").filter(R=>R!==""),a=o(s[0]??""),l=s.length===2?o(s[1]??""):[];if(![...a,...l].every(u=>/^[0-9a-fA-F]{1,4}$/.test(u)))return;if(s.length===1)return a.length===8?a.map(u=>Number.parseInt(u,16)):void 0;let c=8-a.length-l.length;return c<1?void 0:[...a,...Array(c).fill("0"),...l].map(u=>Number.parseInt(u,16))}function xe(t){let e=Re(t);if(!e)return!0;if(e.slice(0,5).every(r=>r===0)&&(e[5]===65535||e[5]===0)){let r=`${e[6]>>8}.${e[6]&255}.${e[7]>>8}.${e[7]&255}`;if(G(r))return!0}return!!(e.every(r=>r===0)||e.slice(0,7).every(r=>r===0)&&e[7]===1||(e[0]&65024)===64512||(e[0]&65472)===65152||(e[0]&65472)===65216||(e[0]&65280)===65280||e[0]===8194||e[0]===100&&e[1]===65435&&e.slice(2,6).every(r=>r===0)||e[0]===100&&e[1]===65435&&e[2]===1)}function J(t){let e=t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t;return e.includes(":")?xe(e):G(e)}var m=class extends Error{constructor(e){super(e),this.name="UnsafeUrlError"}};async function Te(t){return(await me(t,{all:!0,verbatim:!0})).map(n=>n.address)}function we(t){return((e,n,r)=>{let i=r,s=typeof n=="object"&&n!==null&&n.all===!0,o=t.map(l=>({address:l,family:l.includes(":")?6:4}));if(o.length===0){i(new Error("No address to connect to."),"",0);return}if(s){i(null,o);return}let a=o[0];i(null,a.address,a.family)})}var Ae=(t,e,n)=>{let r=t.protocol==="https:",i=t.hostname.replace(/^\[|\]$/g,""),s={method:"GET",protocol:t.protocol,hostname:i,port:t.port===""?void 0:Number(t.port),path:`${t.pathname}${t.search}`,headers:{Accept:"*/*","Accept-Encoding":"identity"},lookup:we(e),agent:!1,signal:n};return r&&(s.servername=i),new Promise((o,a)=>{let c=(r?X.request:V.request)(s,f=>{o({status:f.statusCode??0,headers:f.headers,body:f,cancel:()=>f.destroy()})});c.on("error",a),c.end()})};function ve(t,e){return e?e.aborted?Promise.reject(e.reason):new Promise((n,r)=>{let i=()=>r(e.reason);e.addEventListener("abort",i,{once:!0}),t.then(s=>{e.removeEventListener("abort",i),n(s)},s=>{e.removeEventListener("abort",i),r(s)})}):t}async function z(t,e={},n){let r;try{r=new URL(t)}catch{throw new m("The file URL must be an absolute URL.")}if(r.protocol!=="http:"&&r.protocol!=="https:")throw new m("The file URL must use http or https.");let i=r.hostname.replace(/^\[|\]$/g,"");if(i==="")throw new m("The file URL must include a host.");let o=i.includes(":")||L(i)!==void 0?[i]:await ve((e.resolve??Te)(i).catch(()=>{throw new m(`Could not resolve ${i}.`)}),n);if(o.length===0)throw new m(`Could not resolve ${i}.`);for(let a of o)if(J(a))throw new m(`The file URL points at ${i}, which resolves to a private or reserved address. Use a publicly reachable URL.`);return{url:r,addresses:o}}function Y(t,e){try{let n=new URL(t).pathname.split("/").pop();return n&&n.includes(".")?n:e}catch{return e}}function w(t,e){let n=t[e];return Array.isArray(n)?n[0]:n}function I(t){return new m(`The file is larger than the ${Math.round(t/(1024*1024))} MB limit.`)}async function*Le(t,e){let n=0;for await(let r of t){if(n+=r.byteLength,n>e)throw I(e);yield r}}async function Ee(t,e){let n=[],r=0;for await(let o of t){if(r+=o.byteLength,r>e)throw I(e);n.push(o)}let i=new Uint8Array(r),s=0;for(let o of n)i.set(o,s),s+=o.byteLength;return i}async function Oe(t,e,n){let r=e?.trim().toLowerCase();if(!r||r==="identity")return t;let i=r==="gzip"||r==="x-gzip"?x.createGunzip():r==="deflate"?x.createInflate():r==="br"?x.createBrotliDecompress():void 0;if(!i)throw new m(`The file was served with an unsupported Content-Encoding (${r}).`);return pe(he.from(Le(t,n)),i,s=>{s&&i.destroy(s)}),i}function E(t){if(t!==void 0&&!(Number.isSafeInteger(t)&&t>=0))throw new RangeError(`maxBytes must be a whole number of bytes, 0 or more; got ${t}.`)}function Se(t){if(!t)return;let e=/filename\*\s*=\s*(?:UTF-8|utf-8)''([^;]+)/.exec(t)?.[1];if(e)try{return decodeURIComponent(e.trim())}catch{}let n=/filename\s*=\s*("([^"]*)"|[^;]+)/.exec(t);return(n?.[2]??n?.[1]??"").trim()||void 0}async function P(t,e={},n={}){E(e.maxBytes);let r=e.maxBytes??be,i=n.transport??Ae,s=AbortSignal.timeout(e.timeoutMs??ye),o=await z(t,n,s);for(let a=0;;a++){let l=await i(o.url,o.addresses,s),c;try{let u=w(l.headers,"location");if(l.status>=300&&l.status<400&&u){if(l.cancel?.(),a>=W)throw new m(`The file URL redirected more than ${W} times.`);o=await z(new URL(u,o.url).toString(),n,s);continue}if(l.status<200||l.status>=300)throw new Error(`Could not download the file (${l.status}). Its URL must be publicly reachable.`);let R=Number(w(l.headers,"content-length"));if(Number.isFinite(R)&&R>r)throw I(r);c=await Ee(await Oe(l.body,w(l.headers,"content-encoding"),r),r)}catch(u){throw l.cancel?.(),u}let f=Se(w(l.headers,"content-disposition"));return{bytes:c,contentType:w(l.headers,"content-type")?.split(";")[0]?.trim()||"application/octet-stream",url:o.url.toString(),...f?{filename:f}:{}}}}var Q={filename:d.string().optional().describe("What to call the file. Defaults to the name in its URL."),contentType:d.string().optional().describe("Media type, for example application/pdf. Defaults to what the server states.")},Ue=d.union([d.string().min(1).describe("A public http(s) URL to the file."),d.object({url:d.string().min(1).describe("A public http(s) URL to the file."),...Q}),d.object({base64:d.string().min(1).describe("The file, base64-encoded."),...Q})]).describe("A file: a public URL to it, or {url, filename?, contentType?}, or {base64, filename?, contentType?} for a small one.");function Ce(t){return typeof Blob<"u"&&t instanceof Blob}function O(t,e,n){return{bytes:t,filename:e,contentType:n,file:new File([new Uint8Array(t)],e,{type:n})}}var Ie=/^data:([^;,]*)((?:;[^;,=]+=[^;,]*)*)(;base64)?,(.*)$/is,T=t=>new Error(`The file is larger than the ${Math.round(t/(1024*1024))} MB limit.`);function k(t,e){if(t.byteLength===0)throw new Error("The file is empty.");if(e!==void 0&&t.byteLength>e)throw T(e);return t}function Pe(t,e){if(e!==void 0&&Math.ceil(t.length/3)>e)throw T(e);let n=new TextEncoder().encode(t),r=new Uint8Array(e===void 0?n.length:Math.min(n.length,e)),i=0;for(let s=0;s<n.length;s++){if(e!==void 0&&i===e)throw T(e);let o=n[s]===37?String.fromCharCode(n[s+1]??0,n[s+2]??0):"";/^[0-9a-fA-F]{2}$/.test(o)?(r[i++]=Number.parseInt(o,16),s+=2):r[i++]=n[s]}return i===r.length?r:r.slice(0,i)}var K=()=>new Error("The file is not valid base64."),ke=new Set([9,10,11,12,13,32]);function De(t,e){if(!t.includes("%"))return t;let n=t.replace(/\s+/g,""),r=e===void 0?n.length:Math.min(n.length,Math.ceil(e/3)*4),i=new Uint8Array(r),s=0;for(let o=0;o<n.length;o++){let a=n.charCodeAt(o),l=a===37?n.slice(o+1,o+3):"";if(/^[0-9a-fA-F]{2}$/.test(l)&&(a=Number.parseInt(l,16),o+=2),!ke.has(a)){if(a>127)throw K();if(s===r)throw T(e??r);i[s++]=a}}return Buffer.from(i.buffer,0,s).toString("latin1")}function Z(t,e){let n=t.replace(/\s+/g,"");if(n.length%4===0&&(n.endsWith("==")?n=n.slice(0,-2):n.endsWith("=")&&(n=n.slice(0,-1))),n.length===0||n.length%4===1||!/^[A-Za-z0-9+/_-]+$/.test(n))throw K();if(e!==void 0&&Math.floor(n.length*3/4)>e)throw T(e);return k(new Uint8Array(Buffer.from(n,"base64")),e)}async function Fe(t,e={},n={}){E(e.maxBytes);let r=e.fallbackName??"file";if(Ce(t)){let a=typeof File<"u"&&t instanceof File&&t.name?t.name:r;if(e.maxBytes!==void 0&&t.size>e.maxBytes)throw T(e.maxBytes);return O(k(new Uint8Array(await t.arrayBuffer()),e.maxBytes),a,t.type||"application/octet-stream")}let i=typeof t=="string"?{url:t}:t;if("base64"in i)return O(Z(i.base64,e.maxBytes),i.filename??r,i.contentType??"application/octet-stream");let s=Ie.exec(i.url);if(s){let[,a,,l,c=""]=s,f=l?Z(De(c,e.maxBytes),e.maxBytes):k(Pe(c,e.maxBytes),e.maxBytes);return O(f,i.filename??r,i.contentType??(a||"application/octet-stream"))}let o=await P(i.url,e,n);return O(o.bytes,i.filename??o.filename??Y(o.url,r),i.contentType??o.contentType)}var Be=d.object({contentBase64:d.string().optional().describe("The file, base64-encoded. Missing when the file came back as text or contentOmitted is set."),text:d.string().optional().describe("The file as text, in place of contentBase64, when it is a text file (CSV, JSON, Markdown, XML and the like) in UTF-8."),contentType:d.string().describe("Media type of the file, for example application/pdf."),byteLength:d.number().describe("Size of the file in bytes."),filename:d.string().optional().describe("The file name, when known."),contentOmitted:d.enum(["not_requested","over_limit"]).optional().describe("Set when the content was left out: the caller did not ask for it, or the file was over the limit."),fileId:d.string().optional().describe("Where the host saved the file, in place of its content, when it was over the limit. On Corsair it is a Files id (fil_\u2026): pass it to another app wherever that app takes a file URL, or read a text file or PDF with files.read_text.")}),ee=7e5,te=()=>{};function Ne(t){te=t}var qe=new Set(["application/json","application/xml","application/javascript","application/ecmascript","application/x-javascript","application/yaml","application/x-yaml","application/toml","application/csv","application/ndjson","application/x-ndjson","application/sql","application/graphql","application/x-sh"]);function $e(t){let e=t.toLowerCase();return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||qe.has(e)}var je=new Set(["application/octet-stream","binary/octet-stream","application/unknown"]),_e=new Set(["txt","text","csv","tsv","md","markdown","json","jsonl","ndjson","xml","yaml","yml","toml","ini","log","html","htm","css","js","mjs","cjs","ts","tsx","jsx","sql","sh","py","rb","go","rs","java","svg","ics","vcf","srt","vtt"]);function Me(t,e){if($e(t))return!0;if(!je.has(t.toLowerCase()))return!1;let n=/\.([a-z0-9]+)$/.exec(e?.toLowerCase()??"")?.[1];return n!==void 0&&_e.has(n)}function He(t){try{return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return}}function We(t,e,n={}){E(n.maxBytes);let r={contentType:e?.split(";")[0]?.trim()||"application/octet-stream",byteLength:t.byteLength,...n.filename?{filename:n.filename}:{}};if(n.includeContent===!1)return{...r,contentOmitted:"not_requested"};if(t.byteLength>(n.maxBytes??ee)){let s=te()?.({...r,bytes:t});return s?{...r,fileId:s}:{...r,contentOmitted:"over_limit"}}let i=n.text!==!1&&Me(r.contentType,n.filename)?He(t):void 0;return i!==void 0?{...r,text:i}:{...r,contentBase64:Buffer.from(t).toString("base64")}}var D=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},S=class{#t;#n;#e;#r;#s;#o;#i;constructor(e){this.#t=!1,this.#n=!1,this.#e=!1,this.#r=[],this.#s=new Promise((n,r)=>{this.#o=n,this.#i=r;let i=a=>{this.#t||this.#n||this.#e||(this.#t=!0,this.#o&&this.#o(a))},s=a=>{this.#t||this.#n||this.#e||(this.#n=!0,this.#i&&this.#i(a))},o=a=>{this.#t||this.#n||this.#e||this.#r.push(a)};return Object.defineProperty(o,"isResolved",{get:()=>this.#t}),Object.defineProperty(o,"isRejected",{get:()=>this.#n}),Object.defineProperty(o,"isCancelled",{get:()=>this.#e}),e(i,s,o)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(e,n){return this.#s.then(e,n)}catch(e){return this.#s.catch(e)}finally(e){return this.#s.finally(e)}cancel(){if(!(this.#t||this.#n||this.#e)){if(this.#e=!0,this.#r.length)try{for(let e of this.#r)e()}catch(e){console.warn("Cancellation threw an error",e);return}this.#r.length=0,this.#i&&this.#i(new D("Request aborted"))}}get isCancelled(){return this.#e}};var ne={enabled:!0,maxRetries:3,initialRetryDelay:1e3,backoffMultiplier:2,headerNames:{retryAfter:"retry-after",resetTime:"x-ratelimit-reset",remaining:"x-ratelimit-remaining",limit:"x-ratelimit-limit"}};function re(t,e){let n={};if(e.headerNames.retryAfter){let r=t.headers.get(e.headerNames.retryAfter);if(r){let i=parseInt(r,10);isNaN(i)||(n.retryAfter=i*1e3)}}if(e.headerNames.resetTime){let r=t.headers.get(e.headerNames.resetTime);if(r){let i=parseInt(r,10);if(!isNaN(i)){let s=Date.now(),o=i>1e12?i:i*1e3;n.rateLimitReset=o,o>s&&(n.retryAfter=o-s)}}}if(e.headerNames.remaining){let r=t.headers.get(e.headerNames.remaining);if(r){let i=parseInt(r,10);isNaN(i)||(n.rateLimitRemaining=i)}}if(e.headerNames.limit){let r=t.headers.get(e.headerNames.limit);if(r){let i=parseInt(r,10);isNaN(i)||(n.rateLimitLimit=i)}}return n}function ie(t,e,n){return n.enabled?t===429?!0:n.isRateLimitError?n.isRateLimitError(t,e):!1:!1}function F(t,e,n){if(e.retryAfter)return e.retryAfter;let r=n.initialRetryDelay*Math.pow(n.backoffMultiplier,t-1);return Math.min(r,6e4)}async function B(t){return new Promise(e=>setTimeout(e,t))}var q=t=>t!=null,A=t=>typeof t=="string",N=t=>A(t)&&t!=="",$=t=>typeof t=="object"&&typeof t.type=="string"&&typeof t.stream=="function"&&typeof t.arrayBuffer=="function"&&typeof t.constructor=="function"&&typeof t.constructor.name=="string"&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag]),oe=t=>t instanceof FormData,ze=t=>{try{return btoa(t)}catch{return Buffer.from(t).toString("base64")}},Ve=t=>{let e=[],n=(i,s)=>{e.push(`${encodeURIComponent(i)}=${encodeURIComponent(String(s))}`)},r=(i,s)=>{q(s)&&(Array.isArray(s)?s.forEach(o=>{r(i,o)}):typeof s=="object"?Object.entries(s).forEach(([o,a])=>{r(`${i}[${o}]`,a)}):n(i,s))};return Object.entries(t).forEach(([i,s])=>{r(i,s)}),e.length>0?`?${e.join("&")}`:""},Xe=(t,e)=>{let n=t.ENCODE_PATH||encodeURI,r=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(a,l)=>e.path?.hasOwnProperty(l)?n(String(e.path[l])):a),i=t.BASE.endsWith("/")?t.BASE.slice(0,-1):t.BASE,s=r.startsWith("/")?r.slice(1):r,o=`${i}/${s}`;return e.query?`${o}${Ve(e.query)}`:o},Ge=t=>{if(t.formData){let e=new FormData,n=(r,i)=>{A(i)||$(i)?e.append(r,i):e.append(r,JSON.stringify(i))};return Object.entries(t.formData).filter(([r,i])=>q(i)).forEach(([r,i])=>{Array.isArray(i)?i.forEach(s=>n(r,s)):n(r,i)}),e}},U=async(t,e)=>typeof e=="function"?e(t):e,Je=async(t,e)=>{let[n,r,i,s]=await Promise.all([U(e,t.TOKEN),U(e,t.USERNAME),U(e,t.PASSWORD),U(e,t.HEADERS)]),o=Object.entries({Accept:"application/json",...s,...e.headers}).filter(([a,l])=>q(l)).reduce((a,[l,c])=>({...a,[l]:String(c)}),{});if(N(n)&&(o.Authorization=`Bearer ${n}`),N(r)&&N(i)){let a=ze(`${r}:${i}`);o.Authorization=`Basic ${a}`}return e.body!==void 0&&(e.mediaType?o["Content-Type"]=e.mediaType:$(e.body)?o["Content-Type"]=e.body.type||"application/octet-stream":A(e.body)?o["Content-Type"]="text/plain":oe(e.body)||(o["Content-Type"]="application/json")),new Headers(o)},Ye=t=>{if(t.body!==void 0)return t.mediaType?.includes("/json")?JSON.stringify(t.body):A(t.body)||$(t.body)||oe(t.body)?t.body:JSON.stringify(t.body)},Qe=async(t,e,n,r,i,s,o)=>{let a=new AbortController,l=t.TIMEOUT??2e4,c={headers:s,body:r??i,method:e.method,signal:AbortSignal.any([a.signal,AbortSignal.timeout(l)])};return t.WITH_CREDENTIALS&&(c.credentials=t.CREDENTIALS),o(()=>a.abort()),await fetch(n,c)},Ze=(t,e)=>{if(e){let n=t.headers.get(e);if(A(n))return n}},Ke=async(t,e)=>{if(e?.responseType==="binary"&&t.status===204)return{bytes:new Uint8Array(0),contentType:t.headers.get("Content-Type")};if(t.status!==204){if(e?.responseType==="binary"&&t.ok)return{bytes:new Uint8Array(await t.arrayBuffer()),contentType:t.headers.get("Content-Type")};try{let n=t.headers.get("Content-Type");if(n)return["application/json","application/problem+json"].some(s=>n.toLowerCase().startsWith(s))?await t.json():await t.text()}catch(n){console.error(n)}}},se=(t,e,n)=>{let i={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...t.errors}[e.status];if(i)throw new h(t,e,i,n);if(!e.ok){let s=e.status??"unknown",o=e.statusText??"unknown",a=(()=>{try{return JSON.stringify(e.body,null,2)}catch{return}})(),l=e.body?.message||e.body?.error||e.body?.detail||`Generic Error: status: ${s}; status text: ${o}; body: ${a}`;throw new h(t,e,l,n)}},et=(t,e,n)=>{let r=n?.rateLimitConfig||ne;return new S(async(i,s,o)=>{let a=0,l=r.maxRetries+1;for(;a<l;){a++;try{let c=Xe(t,e),f=Ge(e),u=Ye(e),R=await Je(t,e);if(o.isCancelled)return;let p=await Qe(t,e,c,u,f,R,o),_=await Ke(p,e),le=Ze(p,e.responseHeader),v={url:c,ok:p.ok,status:p.status,statusText:p.statusText,body:p.ok?le??_:_};if(r.enabled&&ie(p.status,v.body,r)){let M=re(p,r);if(a<l){let ce=F(a,M,r);await B(ce);continue}se(e,v,M)}se(e,v),i(v.body);return}catch(c){if(c instanceof h&&c.isRateLimitError()&&a<l){let f=c.retryAfter?c.retryAfter:F(a,{retryAfter:c.retryAfter,rateLimitReset:c.rateLimitReset},r);await B(f);continue}if(a>=l){s(c);return}if(c instanceof h&&c.isRateLimitError())continue;s(c);return}}})};var j=class{handlers=new Map;on(e,n){let r=this.handlers.get(e)||[];return r.push(n),this.handlers.set(e,r),this}off(e,n){let r=this.handlers.get(e)||[],i=r.indexOf(n);return i!==-1&&(r.splice(i,1),this.handlers.set(e,r)),this}getRegisteredEvents(){return Array.from(this.handlers.keys())}hasHandlers(e){let n=this.handlers.get(e);return!!n&&n.length>0}clearHandlers(e){return e?this.handlers.delete(e):this.handlers.clear(),this}async executeHandlers(e,n){let r=this.handlers.get(e)||[];for(let i of r)await i(n)}};import*as g from"crypto";function tt(t,e,n,r="sha256"){if(!n||!e)return!1;let i=g.createHmac(r,e).update(t).digest("hex");try{return g.timingSafeEqual(Buffer.from(n),Buffer.from(i))}catch{return!1}}function nt(t,e,n,r,i="sha256"){if(!n||!e||!n.startsWith(r))return!1;let s=n.slice(r.length),o=g.createHmac(i,e).update(t).digest("hex");try{return g.timingSafeEqual(Buffer.from(s),Buffer.from(o))}catch{return!1}}function ae(t,e,n,r,i=300){if(!e||!r||!n)return!1;let s=Math.floor(Date.now()/1e3),o=parseInt(n,10);if(Math.abs(s-o)>i)return!1;let a=`v0:${n}:${t}`,l="v0="+g.createHmac("sha256",e).update(a).digest("hex");try{return g.timingSafeEqual(Buffer.from(r),Buffer.from(l))}catch{return!1}}function rt(t,e,n,r,i=300){return ae(t,e,n,r,i)}export{h as ApiError,j as BaseWebhookHandler,ee as FILE_OUTPUT_MAX_BYTES,Ue as FileInputSchema,Be as FileOutputSchema,m as UnsafeUrlError,P as downloadPublicFile,J as isBlockedAddress,et as request,Fe as resolveFileInput,Ne as setFileSink,We as toFileOutput,ae as verifyHmacSha256Signature,tt as verifyHmacSignature,nt as verifyHmacSignatureWithPrefix,rt as verifySlackSignature};
|
|
1
|
+
import"./chunk-SOY77BN4.js";var fe=new Set(["apikey","xapikey","key","appkey","appid","token","apitoken","accesstoken","authtoken","clientsecret","secret","password"]);function k(t){let e=t;try{e=decodeURIComponent(t)}catch{e=t}return fe.has(e.toLowerCase().replace(/[-_]/g,""))}function de(t){let e=t.indexOf("?");if(e===-1)return t;let n=t.indexOf("#",e),r=t.slice(0,e+1),i=n===-1?t.slice(e+1):t.slice(e+1,n),s=n===-1?"":t.slice(n),o=!1,a=i.split("&").map(l=>{if(!l)return l;let c=l.indexOf("="),u=c===-1?l:l.slice(0,c);return k(u)?(o=!0,`${u}=[REDACTED]`):l}).join("&");return o?r+a+s:t}function z(t){if(!t)return t;try{let e=/^[a-z]+:\/\//i.test(t),n=e?void 0:"http://localhost",r=new URL(t,n),i=!1;for(let s of[...r.searchParams.keys()])k(s)&&(r.searchParams.set(s,"[REDACTED]"),i=!0);return i?e?r.toString():r.pathname+r.search+r.hash:t}catch{return de(t)}}function me(t){let e=z(t.url),n=!1,r=t.query;if(t.query){r={...t.query};for(let i of Object.keys(r))k(i)&&(r[i]="[REDACTED]",n=!0)}return!n&&e===t.url?t:{...t,url:e,...n?{query:r}:{}}}var h=class extends Error{url;status;statusText;body;request;retryAfter;rateLimitReset;rateLimitRemaining;rateLimitLimit;constructor(e,n,r,i){super(r),this.name="ApiError",this.url=z(n.url),this.status=n.status,this.statusText=n.statusText,this.body=n.body,this.request=me(e),this.retryAfter=i?.retryAfter,this.rateLimitReset=i?.rateLimitReset,this.rateLimitRemaining=i?.rateLimitRemaining,this.rateLimitLimit=i?.rateLimitLimit}isRateLimitError(){return this.status===429}};import{z as d}from"zod";import{lookup as pe}from"dns/promises";import*as G from"http";import*as J from"https";import{pipeline as he,Readable as ye}from"stream";import*as x from"zlib";var be=3e4,ge=25*1024*1024,V=3,Re=[["0.0.0.0",8],["10.0.0.0",8],["100.64.0.0",10],["127.0.0.0",8],["169.254.0.0",16],["172.16.0.0",12],["192.0.0.0",24],["192.0.2.0",24],["192.88.99.0",24],["192.168.0.0",16],["198.18.0.0",15],["198.51.100.0",24],["203.0.113.0",24],["224.0.0.0",4],["240.0.0.0",4]];function E(t){let e=t.split(".");if(e.length!==4)return;let n=0;for(let r of e){if(!/^\d{1,3}$/.test(r))return;let i=Number(r);if(i>255)return;n=n*256+i}return n}function Y(t){let e=E(t);return e===void 0?!0:Re.some(([n,r])=>{let i=E(n);if(i===void 0)return!1;let s=r===0?0:4294967295<<32-r>>>0;return(e&s)===(i&s)})}function xe(t){let e=t,n=e.indexOf("%");n!==-1&&(e=e.slice(0,n));let r=e.lastIndexOf(":");if(r===-1)return;let i=e.slice(r+1);if(i.includes(".")){let f=E(i);if(f===void 0)return;e=`${e.slice(0,r+1)}${(f>>>16).toString(16)}:${(f&65535).toString(16)}`}let s=e.split("::");if(s.length>2)return;let o=f=>f===""?[]:f.split(":").filter(R=>R!==""),a=o(s[0]??""),l=s.length===2?o(s[1]??""):[];if(![...a,...l].every(f=>/^[0-9a-fA-F]{1,4}$/.test(f)))return;if(s.length===1)return a.length===8?a.map(f=>Number.parseInt(f,16)):void 0;let c=8-a.length-l.length;return c<1?void 0:[...a,...Array(c).fill("0"),...l].map(f=>Number.parseInt(f,16))}function Te(t){let e=xe(t);if(!e)return!0;if(e.slice(0,5).every(r=>r===0)&&(e[5]===65535||e[5]===0)){let r=`${e[6]>>8}.${e[6]&255}.${e[7]>>8}.${e[7]&255}`;if(Y(r))return!0}return!!(e.every(r=>r===0)||e.slice(0,7).every(r=>r===0)&&e[7]===1||(e[0]&65024)===64512||(e[0]&65472)===65152||(e[0]&65472)===65216||(e[0]&65280)===65280||e[0]===8194||e[0]===100&&e[1]===65435&&e.slice(2,6).every(r=>r===0)||e[0]===100&&e[1]===65435&&e[2]===1)}function Q(t){let e=t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t;return e.includes(":")?Te(e):Y(e)}var m=class extends Error{constructor(e){super(e),this.name="UnsafeUrlError"}};async function Ae(t){return(await pe(t,{all:!0,verbatim:!0})).map(n=>n.address)}function we(t){return((e,n,r)=>{let i=r,s=typeof n=="object"&&n!==null&&n.all===!0,o=t.map(l=>({address:l,family:l.includes(":")?6:4}));if(o.length===0){i(new Error("No address to connect to."),"",0);return}if(s){i(null,o);return}let a=o[0];i(null,a.address,a.family)})}var ve=(t,e,n)=>{let r=t.protocol==="https:",i=t.hostname.replace(/^\[|\]$/g,""),s={method:"GET",protocol:t.protocol,hostname:i,port:t.port===""?void 0:Number(t.port),path:`${t.pathname}${t.search}`,headers:{Accept:"*/*","Accept-Encoding":"identity"},lookup:we(e),agent:!1,signal:n};return r&&(s.servername=i),new Promise((o,a)=>{let c=(r?J.request:G.request)(s,u=>{o({status:u.statusCode??0,headers:u.headers,body:u,cancel:()=>u.destroy()})});c.on("error",a),c.end()})};function Le(t,e){return e?e.aborted?Promise.reject(e.reason):new Promise((n,r)=>{let i=()=>r(e.reason);e.addEventListener("abort",i,{once:!0}),t.then(s=>{e.removeEventListener("abort",i),n(s)},s=>{e.removeEventListener("abort",i),r(s)})}):t}async function X(t,e={},n){let r;try{r=new URL(t)}catch{throw new m("The file URL must be an absolute URL.")}if(r.protocol!=="http:"&&r.protocol!=="https:")throw new m("The file URL must use http or https.");let i=r.hostname.replace(/^\[|\]$/g,"");if(i==="")throw new m("The file URL must include a host.");let o=i.includes(":")||E(i)!==void 0?[i]:await Le((e.resolve??Ae)(i).catch(()=>{throw new m(`Could not resolve ${i}.`)}),n);if(o.length===0)throw new m(`Could not resolve ${i}.`);for(let a of o)if(Q(a))throw new m(`The file URL points at ${i}, which resolves to a private or reserved address. Use a publicly reachable URL.`);return{url:r,addresses:o}}function Z(t,e){try{let n=new URL(t).pathname.split("/").pop();return n&&n.includes(".")?n:e}catch{return e}}function A(t,e){let n=t[e];return Array.isArray(n)?n[0]:n}function C(t){return new m(`The file is larger than the ${Math.round(t/(1024*1024))} MB limit.`)}async function*Ee(t,e){let n=0;for await(let r of t){if(n+=r.byteLength,n>e)throw C(e);yield r}}async function Oe(t,e){let n=[],r=0;for await(let o of t){if(r+=o.byteLength,r>e)throw C(e);n.push(o)}let i=new Uint8Array(r),s=0;for(let o of n)i.set(o,s),s+=o.byteLength;return i}async function Se(t,e,n){let r=e?.trim().toLowerCase();if(!r||r==="identity")return t;let i=r==="gzip"||r==="x-gzip"?x.createGunzip():r==="deflate"?x.createInflate():r==="br"?x.createBrotliDecompress():void 0;if(!i)throw new m(`The file was served with an unsupported Content-Encoding (${r}).`);return he(ye.from(Ee(t,n)),i,s=>{s&&i.destroy(s)}),i}function w(t){if(t!==void 0&&!(Number.isSafeInteger(t)&&t>=0))throw new RangeError(`maxBytes must be a whole number of bytes, 0 or more; got ${t}.`)}function Ue(t){if(!t)return;let e=/filename\*\s*=\s*(?:UTF-8|utf-8)''([^;]+)/.exec(t)?.[1];if(e)try{return decodeURIComponent(e.trim())}catch{}let n=/filename\s*=\s*("([^"]*)"|[^;]+)/.exec(t);return(n?.[2]??n?.[1]??"").trim()||void 0}async function F(t,e={},n={}){w(e.maxBytes);let r=e.maxBytes??ge,i=n.transport??ve,s=AbortSignal.timeout(e.timeoutMs??be),o=await X(t,n,s);for(let a=0;;a++){let l=await i(o.url,o.addresses,s),c;try{let f=A(l.headers,"location");if(l.status>=300&&l.status<400&&f){if(l.cancel?.(),a>=V)throw new m(`The file URL redirected more than ${V} times.`);o=await X(new URL(f,o.url).toString(),n,s);continue}if(l.status<200||l.status>=300)throw new Error(`Could not download the file (${l.status}). Its URL must be publicly reachable.`);let R=Number(A(l.headers,"content-length"));if(Number.isFinite(R)&&R>r)throw C(r);c=await Oe(await Se(l.body,A(l.headers,"content-encoding"),r),r)}catch(f){throw l.cancel?.(),f}let u=Ue(A(l.headers,"content-disposition"));return{bytes:c,contentType:A(l.headers,"content-type")?.split(";")[0]?.trim()||"application/octet-stream",url:o.url.toString(),...u?{filename:u}:{}}}}var K={filename:d.string().optional().describe("What to call the file. Defaults to the name in its URL."),contentType:d.string().optional().describe("Media type, for example application/pdf. Defaults to what the server states.")},ke=d.union([d.string().min(1).describe("A public http(s) URL to the file."),d.object({url:d.string().min(1).describe("A public http(s) URL to the file."),...K}),d.object({base64:d.string().min(1).describe("The file, base64-encoded."),...K})]).describe("A file: a public URL to it, or {url, filename?, contentType?}, or {base64, filename?, contentType?} for a small one.");function Ce(t){return typeof Blob<"u"&&t instanceof Blob}function O(t,e,n){return{bytes:t,filename:e,contentType:n,file:new File([new Uint8Array(t)],e,{type:n})}}var Fe=/^data:([^;,]*)((?:;[^;,=]+=[^;,]*)*)(;base64)?,(.*)$/is,T=t=>new Error(`The file is larger than the ${Math.round(t/(1024*1024))} MB limit.`);function I(t,e){if(t.byteLength===0)throw new Error("The file is empty.");if(e!==void 0&&t.byteLength>e)throw T(e);return t}function Ie(t,e){if(e!==void 0&&Math.ceil(t.length/3)>e)throw T(e);let n=new TextEncoder().encode(t),r=new Uint8Array(e===void 0?n.length:Math.min(n.length,e)),i=0;for(let s=0;s<n.length;s++){if(e!==void 0&&i===e)throw T(e);let o=n[s]===37?String.fromCharCode(n[s+1]??0,n[s+2]??0):"";/^[0-9a-fA-F]{2}$/.test(o)?(r[i++]=Number.parseInt(o,16),s+=2):r[i++]=n[s]}return i===r.length?r:r.slice(0,i)}var te=()=>new Error("The file is not valid base64."),Pe=new Set([9,10,11,12,13,32]);function De(t,e){if(!t.includes("%"))return t;let n=t.replace(/\s+/g,""),r=e===void 0?n.length:Math.min(n.length,Math.ceil(e/3)*4),i=new Uint8Array(r),s=0;for(let o=0;o<n.length;o++){let a=n.charCodeAt(o),l=a===37?n.slice(o+1,o+3):"";if(/^[0-9a-fA-F]{2}$/.test(l)&&(a=Number.parseInt(l,16),o+=2),!Pe.has(a)){if(a>127)throw te();if(s===r)throw T(e??r);i[s++]=a}}return Buffer.from(i.buffer,0,s).toString("latin1")}function ee(t,e){let n=t.replace(/\s+/g,"");if(n.length%4===0&&(n.endsWith("==")?n=n.slice(0,-2):n.endsWith("=")&&(n=n.slice(0,-1))),n.length===0||n.length%4===1||!/^[A-Za-z0-9+/_-]+$/.test(n))throw te();if(e!==void 0&&Math.floor(n.length*3/4)>e)throw T(e);return I(new Uint8Array(Buffer.from(n,"base64")),e)}async function Be(t,e={},n={}){w(e.maxBytes);let r=e.fallbackName??"file";if(Ce(t)){let a=typeof File<"u"&&t instanceof File&&t.name?t.name:r;if(e.maxBytes!==void 0&&t.size>e.maxBytes)throw T(e.maxBytes);return O(I(new Uint8Array(await t.arrayBuffer()),e.maxBytes),a,t.type||"application/octet-stream")}let i=typeof t=="string"?{url:t}:t;if("base64"in i)return O(ee(i.base64,e.maxBytes),i.filename??r,i.contentType??"application/octet-stream");let s=Fe.exec(i.url);if(s){let[,a,,l,c=""]=s,u=l?ee(De(c,e.maxBytes),e.maxBytes):I(Ie(c,e.maxBytes),e.maxBytes);return O(u,i.filename??r,i.contentType??(a||"application/octet-stream"))}let o=await F(i.url,e,n);return O(o.bytes,i.filename??o.filename??Z(o.url,r),i.contentType??o.contentType)}var Ne=d.object({contentBase64:d.string().optional().describe("The file, base64-encoded. Missing when the file came back as text or contentOmitted is set."),text:d.string().optional().describe("The file as text, in place of contentBase64, when it is a text file (CSV, JSON, Markdown, XML and the like) in UTF-8."),contentType:d.string().describe("Media type of the file, for example application/pdf."),byteLength:d.number().describe("Size of the file in bytes."),filename:d.string().optional().describe("The file name, when known."),contentOmitted:d.enum(["not_requested","over_limit"]).optional().describe("Set when the content was left out: the caller did not ask for it, or the file was over the limit."),fileId:d.string().optional().describe("Where the host saved the file. Over the limit it comes in place of the content; a host that keeps every file sets it beside the content too. On Corsair it is a Files id (fil_\u2026): pass it to another app wherever that app takes a file URL, or read a text file or PDF with files.read_text.")}),P=7e5,ne=()=>{},D={};function qe(t,e={}){w(e.inlineMaxBytes),ne=t,D=e}var $e=new Set(["application/json","application/xml","application/javascript","application/ecmascript","application/x-javascript","application/yaml","application/x-yaml","application/toml","application/csv","application/ndjson","application/x-ndjson","application/sql","application/graphql","application/x-sh"]);function Me(t){let e=t.toLowerCase();return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||$e.has(e)}var je=new Set(["application/octet-stream","binary/octet-stream","application/unknown"]),_e=new Set(["txt","text","csv","tsv","md","markdown","json","jsonl","ndjson","xml","yaml","yml","toml","ini","log","html","htm","css","js","mjs","cjs","ts","tsx","jsx","sql","sh","py","rb","go","rs","java","svg","ics","vcf","srt","vtt"]);function He(t,e){if(Me(t))return!0;if(!je.has(t.toLowerCase()))return!1;let n=/\.([a-z0-9]+)$/.exec(e?.toLowerCase()??"")?.[1];return n!==void 0&&_e.has(n)}function We(t){try{return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return}}function ze(t,e,n={}){w(n.maxBytes);let r={contentType:e?.split(";")[0]?.trim()||"application/octet-stream",byteLength:t.byteLength,...n.filename?{filename:n.filename}:{}};if(n.includeContent===!1)return{...r,contentOmitted:"not_requested"};let i=ne(),s=D.inlineMaxBytes??P,o=i?Math.min(n.maxBytes??s,s):n.maxBytes??P;if(t.byteLength>o){let u=i?.({...r,bytes:t});return u?{...r,fileId:u}:{...r,contentOmitted:"over_limit"}}let a=i&&D.everyFile?i({...r,bytes:t}):null,l=a?{...r,fileId:a}:r,c=n.text!==!1&&He(r.contentType,n.filename)?We(t):void 0;return c!==void 0?{...l,text:c}:{...l,contentBase64:Buffer.from(t).toString("base64")}}var B=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},S=class{#t;#n;#e;#r;#s;#o;#i;constructor(e){this.#t=!1,this.#n=!1,this.#e=!1,this.#r=[],this.#s=new Promise((n,r)=>{this.#o=n,this.#i=r;let i=a=>{this.#t||this.#n||this.#e||(this.#t=!0,this.#o&&this.#o(a))},s=a=>{this.#t||this.#n||this.#e||(this.#n=!0,this.#i&&this.#i(a))},o=a=>{this.#t||this.#n||this.#e||this.#r.push(a)};return Object.defineProperty(o,"isResolved",{get:()=>this.#t}),Object.defineProperty(o,"isRejected",{get:()=>this.#n}),Object.defineProperty(o,"isCancelled",{get:()=>this.#e}),e(i,s,o)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(e,n){return this.#s.then(e,n)}catch(e){return this.#s.catch(e)}finally(e){return this.#s.finally(e)}cancel(){if(!(this.#t||this.#n||this.#e)){if(this.#e=!0,this.#r.length)try{for(let e of this.#r)e()}catch(e){console.warn("Cancellation threw an error",e);return}this.#r.length=0,this.#i&&this.#i(new B("Request aborted"))}}get isCancelled(){return this.#e}};var re={enabled:!0,maxRetries:3,initialRetryDelay:1e3,backoffMultiplier:2,headerNames:{retryAfter:"retry-after",resetTime:"x-ratelimit-reset",remaining:"x-ratelimit-remaining",limit:"x-ratelimit-limit"}};function ie(t,e){let n={};if(e.headerNames.retryAfter){let r=t.headers.get(e.headerNames.retryAfter);if(r){let i=parseInt(r,10);isNaN(i)||(n.retryAfter=i*1e3)}}if(e.headerNames.resetTime){let r=t.headers.get(e.headerNames.resetTime);if(r){let i=parseInt(r,10);if(!isNaN(i)){let s=Date.now(),o=i>1e12?i:i*1e3;n.rateLimitReset=o,o>s&&(n.retryAfter=o-s)}}}if(e.headerNames.remaining){let r=t.headers.get(e.headerNames.remaining);if(r){let i=parseInt(r,10);isNaN(i)||(n.rateLimitRemaining=i)}}if(e.headerNames.limit){let r=t.headers.get(e.headerNames.limit);if(r){let i=parseInt(r,10);isNaN(i)||(n.rateLimitLimit=i)}}return n}function se(t,e,n){return n.enabled?t===429?!0:n.isRateLimitError?n.isRateLimitError(t,e):!1:!1}function N(t,e,n){if(e.retryAfter)return e.retryAfter;let r=n.initialRetryDelay*Math.pow(n.backoffMultiplier,t-1);return Math.min(r,6e4)}async function q(t){return new Promise(e=>setTimeout(e,t))}var M=t=>t!=null,v=t=>typeof t=="string",$=t=>v(t)&&t!=="",j=t=>typeof t=="object"&&typeof t.type=="string"&&typeof t.stream=="function"&&typeof t.arrayBuffer=="function"&&typeof t.constructor=="function"&&typeof t.constructor.name=="string"&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag]),ae=t=>t instanceof FormData,Ve=t=>{try{return btoa(t)}catch{return Buffer.from(t).toString("base64")}},Xe=t=>{let e=[],n=(i,s)=>{e.push(`${encodeURIComponent(i)}=${encodeURIComponent(String(s))}`)},r=(i,s)=>{M(s)&&(Array.isArray(s)?s.forEach(o=>{r(i,o)}):typeof s=="object"?Object.entries(s).forEach(([o,a])=>{r(`${i}[${o}]`,a)}):n(i,s))};return Object.entries(t).forEach(([i,s])=>{r(i,s)}),e.length>0?`?${e.join("&")}`:""},Ge=(t,e)=>{let n=t.ENCODE_PATH||encodeURI,r=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(a,l)=>e.path?.hasOwnProperty(l)?n(String(e.path[l])):a),i=t.BASE.endsWith("/")?t.BASE.slice(0,-1):t.BASE,s=r.startsWith("/")?r.slice(1):r,o=`${i}/${s}`;return e.query?`${o}${Xe(e.query)}`:o},Je=t=>{if(t.formData){let e=new FormData,n=(r,i)=>{v(i)||j(i)?e.append(r,i):e.append(r,JSON.stringify(i))};return Object.entries(t.formData).filter(([r,i])=>M(i)).forEach(([r,i])=>{Array.isArray(i)?i.forEach(s=>n(r,s)):n(r,i)}),e}},U=async(t,e)=>typeof e=="function"?e(t):e,Ye=async(t,e)=>{let[n,r,i,s]=await Promise.all([U(e,t.TOKEN),U(e,t.USERNAME),U(e,t.PASSWORD),U(e,t.HEADERS)]),o=Object.entries({Accept:"application/json",...s,...e.headers}).filter(([a,l])=>M(l)).reduce((a,[l,c])=>({...a,[l]:String(c)}),{});if($(n)&&(o.Authorization=`Bearer ${n}`),$(r)&&$(i)){let a=Ve(`${r}:${i}`);o.Authorization=`Basic ${a}`}return e.body!==void 0&&(e.mediaType?o["Content-Type"]=e.mediaType:j(e.body)?o["Content-Type"]=e.body.type||"application/octet-stream":v(e.body)?o["Content-Type"]="text/plain":ae(e.body)||(o["Content-Type"]="application/json")),new Headers(o)},Qe=t=>{if(t.body!==void 0)return t.mediaType?.includes("/json")?JSON.stringify(t.body):v(t.body)||j(t.body)||ae(t.body)?t.body:JSON.stringify(t.body)},Ze=async(t,e,n,r,i,s,o)=>{let a=new AbortController,l=t.TIMEOUT??2e4,c={headers:s,body:r??i,method:e.method,signal:AbortSignal.any([a.signal,AbortSignal.timeout(l)])};return t.WITH_CREDENTIALS&&(c.credentials=t.CREDENTIALS),o(()=>a.abort()),await fetch(n,c)},Ke=(t,e)=>{if(e){let n=t.headers.get(e);if(v(n))return n}},et=async(t,e)=>{if(e?.responseType==="binary"&&t.status===204)return{bytes:new Uint8Array(0),contentType:t.headers.get("Content-Type")};if(t.status!==204){if(e?.responseType==="binary"&&t.ok)return{bytes:new Uint8Array(await t.arrayBuffer()),contentType:t.headers.get("Content-Type")};try{let n=t.headers.get("Content-Type");if(n)return["application/json","application/problem+json"].some(s=>n.toLowerCase().startsWith(s))?await t.json():await t.text()}catch(n){console.error(n)}}},oe=(t,e,n)=>{let i={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...t.errors}[e.status];if(i)throw new h(t,e,i,n);if(!e.ok){let s=e.status??"unknown",o=e.statusText??"unknown",a=(()=>{try{return JSON.stringify(e.body,null,2)}catch{return}})(),l=e.body?.message||e.body?.error||e.body?.detail||`Generic Error: status: ${s}; status text: ${o}; body: ${a}`;throw new h(t,e,l,n)}},tt=(t,e,n)=>{let r=n?.rateLimitConfig||re;return new S(async(i,s,o)=>{let a=0,l=r.maxRetries+1;for(;a<l;){a++;try{let c=Ge(t,e),u=Je(e),f=Qe(e),R=await Ye(t,e);if(o.isCancelled)return;let p=await Ze(t,e,c,f,u,R,o),H=await et(p,e),ce=Ke(p,e.responseHeader),L={url:c,ok:p.ok,status:p.status,statusText:p.statusText,body:p.ok?ce??H:H};if(r.enabled&&se(p.status,L.body,r)){let W=ie(p,r);if(a<l){let ue=N(a,W,r);await q(ue);continue}oe(e,L,W)}oe(e,L),i(L.body);return}catch(c){if(c instanceof h&&c.isRateLimitError()&&a<l){let u=c.retryAfter?c.retryAfter:N(a,{retryAfter:c.retryAfter,rateLimitReset:c.rateLimitReset},r);await q(u);continue}if(a>=l){s(c);return}if(c instanceof h&&c.isRateLimitError())continue;s(c);return}}})};var _=class{handlers=new Map;on(e,n){let r=this.handlers.get(e)||[];return r.push(n),this.handlers.set(e,r),this}off(e,n){let r=this.handlers.get(e)||[],i=r.indexOf(n);return i!==-1&&(r.splice(i,1),this.handlers.set(e,r)),this}getRegisteredEvents(){return Array.from(this.handlers.keys())}hasHandlers(e){let n=this.handlers.get(e);return!!n&&n.length>0}clearHandlers(e){return e?this.handlers.delete(e):this.handlers.clear(),this}async executeHandlers(e,n){let r=this.handlers.get(e)||[];for(let i of r)await i(n)}};import*as g from"crypto";function nt(t,e,n,r="sha256"){if(!n||!e)return!1;let i=g.createHmac(r,e).update(t).digest("hex");try{return g.timingSafeEqual(Buffer.from(n),Buffer.from(i))}catch{return!1}}function rt(t,e,n,r,i="sha256"){if(!n||!e||!n.startsWith(r))return!1;let s=n.slice(r.length),o=g.createHmac(i,e).update(t).digest("hex");try{return g.timingSafeEqual(Buffer.from(s),Buffer.from(o))}catch{return!1}}function le(t,e,n,r,i=300){if(!e||!r||!n)return!1;let s=Math.floor(Date.now()/1e3),o=parseInt(n,10);if(Math.abs(s-o)>i)return!1;let a=`v0:${n}:${t}`,l="v0="+g.createHmac("sha256",e).update(a).digest("hex");try{return g.timingSafeEqual(Buffer.from(r),Buffer.from(l))}catch{return!1}}function it(t,e,n,r,i=300){return le(t,e,n,r,i)}export{h as ApiError,_ as BaseWebhookHandler,P as FILE_OUTPUT_MAX_BYTES,ke as FileInputSchema,Ne as FileOutputSchema,m as UnsafeUrlError,F as downloadPublicFile,Q as isBlockedAddress,tt as request,Be as resolveFileInput,qe as setFileSink,ze as toFileOutput,le as verifyHmacSha256Signature,nt as verifyHmacSignature,rt as verifyHmacSignatureWithPrefix,it as verifySlackSignature};
|
package/dist/hub.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$a as ca,A as z,Aa as T,B as A,Ba as U,C as B,Ca as V,Da as W,L as C,Qa as X,Ra as Y,Sa as Z,Xa as _,Ya as $,Za as aa,_a as ba,aa as D,ab as da,b as a,cb as ea,d as b,da as E,db as fa,e as c,ea as F,eb as ga,f as d,fb as ha,g as e,gb as ia,h as f,hb as ja,i as g,ib as ka,j as i,jb as la,k as j,kb as ma,l as k,lb as na,m as l,mb as oa,n as m,na as G,nb as pa,o as n,oa as H,ob as qa,p as o,pa as I,pb as ra,q as p,qa as J,qb as sa,r as q,ra as K,rb as ta,s as r,sa as L,sb as ua,t as s,ta as M,tb as va,u as t,ua as N,ub as wa,v as u,va as O,vb as xa,w as v,wa as P,wb as ya,x as w,xa as Q,xb as za,y as x,ya as R,z as y,za as S}from"./chunk-
|
|
1
|
+
import{$a as ca,A as z,Aa as T,B as A,Ba as U,C as B,Ca as V,Da as W,L as C,Qa as X,Ra as Y,Sa as Z,Xa as _,Ya as $,Za as aa,_a as ba,aa as D,ab as da,b as a,cb as ea,d as b,da as E,db as fa,e as c,ea as F,eb as ga,f as d,fb as ha,g as e,gb as ia,h as f,hb as ja,i as g,ib as ka,j as i,jb as la,k as j,kb as ma,l as k,lb as na,m as l,mb as oa,n as m,na as G,nb as pa,o as n,oa as H,ob as qa,p as o,pa as I,pb as ra,q as p,qa as J,qb as sa,r as q,ra as K,rb as ta,s as r,sa as L,sb as ua,t as s,ta as M,tb as va,u as t,ua as N,ub as wa,v as u,va as O,vb as xa,w as v,wa as P,wb as ya,x as w,xa as Q,xb as za,y as x,ya as R,z as y,za as S}from"./chunk-3BGIQPKY.js";import{a as h,b as Aa,c as Ba,d as Ca,e as Da,f as Ea}from"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{m as BROWSER_DELIVERY_TTL_MS,Ba as CORSAIR_TUNNEL_PATH,Aa as CORSAIR_TUNNEL_ZONE,u as DEFAULT_HUB_API_URL,Ca as FRPC_VERSION,w as HubCredentialsMissingError,v as HubNotConfiguredError,V as ManagedOAuthDeliveryError,n as SIGNED_TUNNEL_REPLAY_WINDOW_MS,fa as attachManagedRefreshAuth,p as buildBrowserDeliveryRedirectUrl,s as buildClientBridgeBrowserDeliveryUrl,la as createConnectSessionJti,qa as createConnectTokenJti,D as createHubConnectSession,E as createHubPermissionSession,ka as createHubRouteHandlers,ia as createManagedPricingCredentialCache,wa as createPermissionSessionJti,o as createSignedTokenJti,pa as decodeConnectSessionTokenFromPath,va as decodeConnectTokenFromPath,za as decodePermissionTokenFromPath,Q as deliverConnectCreateLink,U as deliverSignedEnvelope,S as describeDeliveryNetworkError,ua as encodeConnectTokenForPath,O as extractConnectLinkFromDeliveryAck,H as extractProbeFromDeliveryAck,G as extractRunFromDeliveryAck,N as extractSyncFromDeliveryAck,F as formatHubApprovalMessage,a as formatProviderDisplayName,T as formatServerDeliveryError,Da as frpcPlatformKey,ma as getConnectSessionExpiryMs,X as getConnectStatusForTenant,ra as getConnectTokenExpiryMs,z as getHubConfig,ea as getManagedAccessToken,ha as getManagedPricingApiKey,_ as handleHubDeliveryGet,$ as handleHubDeliveryPost,ba as handleHubDeliveryRequest,aa as hubDeliveryToResponse,B as inferHubEnvironmentSlug,i as isLoopbackUrl,M as isServerDeliveryAckSuccessful,Y as listHubProjectConnections,x as normalizeHubConfig,P as parseConnectLinkFromDeliveryBody,b as parseConnectSessionResponse,f as parseConnectStatusResponse,g as parseHubApiErrorBody,Z as parseManagedPricingCredentialsResponse,e as parseOAuthRefreshResponse,d as parsePermissionSessionResponse,c as parseProjectConnectionsResponse,L as parseServerDeliveryAckBody,R as parseSyncFromDeliveryBody,t as prepareClientBridgeDeliveryTransport,W as processManagedOAuthDelivery,C as registerHubWebhookTenantLink,ga as requireHubForManagedPricing,j as resolveDeliveryTransport,Ea as resolveFrpcBinary,y as resolveHubConfigInput,h as resolveHubDeliveryUrl,A as resolveHubOAuthCallbackUrl,ja as resolveManagedPricingApiKey,ca as respondToHubDelivery,da as respondToHubDeliveryFromRequest,q as signBrowserDeliveryToken,na as signConnectSessionToken,sa as signConnectToken,I as signDeliveryEnvelope,xa as signPermissionToken,k as usesBrowserDelivery,l as validateProductionDeliveryUrl,r as verifyBrowserDeliveryToken,oa as verifyConnectSessionToken,ta as verifyConnectToken,J as verifyDeliveryEnvelope,ya as verifyPermissionToken,K as verifySignedTunnelDelivery};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Db as J,Ea as q,Eb as Y,Fb as K,Gb as G,H as O,Hb as X,Ib as Q,Jb as V,Kb as nn,Lb as en,M as A,Ma as N,Mb as tn,N as L,Nb as rn,O as E,Ob as on,P as v,Pb as sn,Qb as an,Rb as un,Ta as j,Ua as B,Va as D,Wa as U,Xb as w,Yb as P,Zb as T,_b as x,ba as F,bb as Z,c as S,ca as M,dc as cn,ec as pn,fa as $,fc as ln,ga as _,gc as dn,hc as mn,ia as H,ic as gn,jc as Cn,ma as W,nc as fn,oc as yn,pc as I,qc as kn,yb as z}from"./chunk-
|
|
1
|
+
import{Db as J,Ea as q,Eb as Y,Fb as K,Gb as G,H as O,Hb as X,Ib as Q,Jb as V,Kb as nn,Lb as en,M as A,Ma as N,Mb as tn,N as L,Nb as rn,O as E,Ob as on,P as v,Pb as sn,Qb as an,Rb as un,Ta as j,Ua as B,Va as D,Wa as U,Xb as w,Yb as P,Zb as T,_b as x,ba as F,bb as Z,c as S,ca as M,dc as cn,ec as pn,fa as $,fc as ln,ga as _,gc as dn,hc as mn,ia as H,ic as gn,jc as Cn,ma as W,nc as fn,oc as yn,pc as I,qc as kn,yb as z}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";import{z as p}from"zod";function C(e){let t=e[I];if(!t)throw new Error("listOperations / getSchema: invalid corsair instance. Pass the value returned by createCorsair() or corsair.withTenant().");return t.plugins}function y(e,t){let o=P(C(e),t);return typeof o=="string"?o:Array.isArray(o)?o.join(`
|
|
2
2
|
`):Object.values(o).flat().join(`
|
|
3
3
|
`)}function hn(e,t){return T(C(e),t)}function k(e,t){return w(C(e),t)}function h(e,t){let o=C(e),n=t.toLowerCase(),i=n.indexOf(".");if(i===-1)return null;let u=n.slice(0,i),r=n.slice(i+1),s=o.find(c=>c.id===u);if(!s?.endpointSchemas)return null;let a=r;a.startsWith("api.")&&(a=a.slice(4));for(let[c,l]of Object.entries(s.endpointSchemas))if(c.toLowerCase()===a)return l.input??null;return null}function f(e){let t=wn(e);return e.description&&(t=t.describe(e.description)),e.optional&&(t=t.optional()),t}function wn(e){switch(e.kind){case"string":return e.enum&&e.enum.length>0?p.enum(e.enum):p.string();case"number":return p.number();case"boolean":return p.boolean();case"literal":return p.literal(e.value);case"object":{let t={};for(let[o,n]of Object.entries(e.fields))t[o]=f(n);return p.object(t)}case"array":return p.array(f(e.items));case"unknown":return p.unknown()}}function Pn(e,t){let o=t?.tenantId?In(e,t.tenantId):e;return(t?.operations??Tn(y(o,{plugin:t?.plugin,type:"api"}))).map(i=>{let u=k(o,i),s=h(o,i)??(u?.input?f(u.input):p.object({}));return{name:xn(i),operation:i,description:u?.description??i,schema:s,execute:a=>Rn(o,i,a??{})}})}function Tn(e){return e.split(`
|
|
4
4
|
`).map(t=>t.trim()).filter(Boolean)}function xn(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")}function In(e,t){let o=e.withTenant;return typeof o=="function"?o.call(e,t):e}async function Rn(e,t,o){let n=t.split("."),i=n.pop();if(!i)throw new Error(`Invalid operation path: ${t}`);let u=e;for(let s of n)if(u=u?.[s],u==null)throw new Error(`Unknown operation path: ${t}`);let r=u[i];if(typeof r!="function")throw new Error(`Operation is not callable: ${t}`);return r.call(u,o)}var d=class extends Error{status;code;extra;constructor(t,o,n,i={}){super(n),this.name="CorsairClientError",this.status=t,this.code=o,this.extra=i}};function bn(e){return e.endsWith("/")?e.slice(0,-1):e}async function R(e){let t={};try{t=await e.json()}catch{}let o=typeof t.error=="string"?t.error:"request_failed",n=typeof t.message=="string"?t.message:`Request failed (${e.status})`,{error:i,message:u,...r}=t;return new d(e.status,o,n,r)}function Sn(e){let t=bn(e.baseURL),o=e.fetch??((...r)=>globalThis.fetch(...r));async function n(r,s){let a=s&&Object.keys(s).length?`?${new URLSearchParams(s).toString()}`:"",c=await o(`${t}${r}${a}`,{method:"GET"});if(!c.ok)throw await R(c);return await c.json()}async function i(r,s){let a=await o(`${t}${r}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw await R(a);return await a.json()}let u=encodeURIComponent;return{ok:()=>n("/ok"),tenants:{list:()=>n("/tenants"),create:r=>i("/tenants",r),get:r=>n(`/tenants/${u(r)}`)},plugins:{list:()=>n("/plugins"),get:r=>n(`/plugins/${u(r)}`)},connectionStatus:{get:r=>{let s={};return r?.tenantId&&(s.tenantId=r.tenantId),n("/connection-status",s)}},permissions:{get:r=>"id"in r?n(`/permissions/${u(r.id)}`):i("/permissions/lookup-by-token",{token:r.token})},connect:{createLink:r=>i("/connect/links",r),resolve:r=>n("/connect/resolve",{state:r}),oauthCallback:r=>i("/connect/oauth/callback",r)},connectRequest:{get:r=>{let s={};return r?.tenantId&&(s.tenantId=r.tenantId),n("/connect/request",s)},clear:r=>i("/connect/request/clear",r??{})},call(r,s,a,c){return i(`/${u(a)}/${u(r)}/call/${u(s)}`,{args:c}).then(l=>l.data)}}}var On=Symbol.for("corsair:internal");function An(e,t){let o=e;for(let n of t){if(!o||typeof o!="object")return null;o=o[n]}return typeof o=="function"?o:null}function b(e){return e[On]?.database}async function Ln(e,t){let o=new Date().toISOString(),n=await e.permissions.find_by_token(t);if(!n)return console.error("executePermission: no permission found for token."),{error:"executePermission: no permission found for token."};if(n.status!=="approved")return console.error(`executePermission: permission '${n.id}' is '${n.status}', expected 'approved'.`),{endpoint:n.endpoint,plugin:n.plugin,result:null,error:`executePermission: permission '${n.id}' is '${n.status}', expected 'approved'.`};if(n.expires_at<o){let a=b(e);return a&&await a.db.updateTable("corsair_permissions").set({status:"expired",updated_at:new Date}).where("id","=",n.id).execute(),console.error(`executePermission: permission '${n.id}' has expired.`),{error:`executePermission: permission '${n.id}' has expired.`,endpoint:n.endpoint,plugin:n.plugin,result:null}}let i=n.tenant_id??"default",r=(e.withTenant?e.withTenant(i):e)[n.plugin];if(!r?.api)return console.error(`executePermission: plugin '${n.plugin}' not found or has no API on this corsair instance.`),{error:`executePermission: plugin '${n.plugin}' not found or has no API on this corsair instance.`,plugin:n.plugin,endpoint:n.endpoint,result:null};let s=An(r.api,n.endpoint.split("."));if(!s)return console.error(`executePermission: endpoint '${n.endpoint}' not found in plugin '${n.plugin}'.`),{endpoint:n.endpoint,plugin:n.plugin,result:null,error:`executePermission: endpoint '${n.endpoint}' not found in plugin '${n.plugin}'.`};await e.permissions.set_executing(n.id);try{let a=typeof n.args=="string"?JSON.parse(n.args):n.args,c=await s(a);return await e.permissions.set_completed(n.id),{plugin:n.plugin,endpoint:n.endpoint,result:c}}catch(a){let c=a instanceof Error?a.message:String(a),l=b(e);return l&&await l.db.updateTable("corsair_permissions").set({status:"failed",error:c,updated_at:new Date}).where("id","=",n.id).execute(),{plugin:n.plugin,endpoint:n.endpoint,result:null,error:c}}}export{Z as AuthMissingError,J as CloudApiError,d as CorsairClientError,z as CorsairKekMissingError,B as DEFAULT_BODY_STALL_TIMEOUT_MS,j as DEFAULT_MAX_BODY_BYTES,W as ManagementApiError,M as PermissionRequiredError,$ as ReadonlyForbiddenError,S as ReconnectRequiredError,gn as asRecord,Pn as buildCorsairTools,ln as collectPluginWebhookMatchers,Y as corsairCloud,kn as createCorsair,Sn as createCorsairClient,yn as decodePubSubData,Ln as executePermission,fn as firstString,f as formFieldToZod,x as formatDocSchemaShape,dn as getHeader,h as getInputSchema,hn as getSchema,k as getStructuredSchema,y as listOperations,K as managementHandler,cn as matchWebhookPlugin,pn as matchWebhookPluginAndTenant,N as processCorsair,q as processWebhook,Cn as readBodyRecord,X as registerCorsairRawBodyParser,L as resolveAccountFromWebhookLink,U as resolveBodyStallTimeoutMs,F as resolveConnectLink,D as resolveMaxBodyBytes,v as resolveTenantFromWebhookLink,E as resolveTenantIdFromWebhookLink,H as runReadonly,_ as runWithMode,A as setWebhookTenantLink,O as setupCorsair,on as toAstroHandler,G as toExpressHandler,mn as toExternalId,Q as toFastifyHandler,V as toHonoHandler,nn as toNextJsHandler,en as toNodeHandler,an as toNuxtHandler,rn as toRemixHandler,tn as toSvelteKitHandler,sn as toTanStackHandler,un as toWebHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Na as a,Oa as b,Pa as c}from"./chunk-
|
|
1
|
+
import{Na as a,Oa as b,Pa as c}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{a as deriveAck,b as pollOnce,c as startConnectLoop};
|
package/dist/oauth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{J as a,K as b,Q as c,R as d,S as e,T as f,U as g,V as h}from"./chunk-
|
|
1
|
+
import{J as a,K as b,Q as c,R as d,S as e,T as f,U as g,V as h}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{d as OAuthCallbackError,c as buildOAuthAuthorizeUrl,b as decodeOAuthState,a as encodeOAuthState,e as generateOAuthUrl,f as processOAuthCallback,g as renewSubscriptions,h as startSubscriptionRenewal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as a,I as b}from"./chunk-
|
|
1
|
+
import{H as a,I as b}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{b as applySetupCredentials,a as setupCorsair};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as a,X as b,Y as c,Z as d}from"./chunk-
|
|
1
|
+
import{W as a,X as b,Y as c,Z as d}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{b as buildConnectPluginManifest,a as buildConnectPluginManifestFromContext,d as ensureConnectAccountRows,c as ensureConnectAccountRowsFromContext};
|
package/dist/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as a,I as b}from"./chunk-
|
|
1
|
+
import{H as a,I as b}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{b as applySetupCredentials,a as setupCorsair};
|
package/dist/tunnel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fa as f,Ga as g,Ha as h,Ia as i,Ja as j,Ka as k,La as l,M as b,Ma as m,N as c,O as d,P as e,s as a}from"./chunk-
|
|
1
|
+
import{Fa as f,Ga as g,Ha as h,Ia as i,Ja as j,Ka as k,La as l,M as b,Ma as m,N as c,O as d,P as e,s as a}from"./chunk-3BGIQPKY.js";import"./chunk-6IURNA4L.js";import"./chunk-XCTHEKDP.js";import"./chunk-PQ2CF2OI.js";import"./chunk-XPXWKPFZ.js";import"./chunk-Z2KT4F2U.js";import"./chunk-SOY77BN4.js";export{l as applyPermissionDecision,f as executeWorkflowRun,h as isAuthCredentialsBrowserDelivery,k as isByoOAuthBrowserDelivery,j as isManagedBrowserDelivery,i as isPermissionBrowserDelivery,m as processCorsair,c as resolveAccountFromWebhookLink,e as resolveTenantFromWebhookLink,d as resolveTenantIdFromWebhookLink,g as runReadonlyProbe,b as setWebhookTenantLink,a as verifyBrowserDeliveryToken};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corsair",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "Open-source integration layer for AI agents and apps. Managed OAuth, webhooks, and one API for 350+ integrations, with credentials that stay in your own database.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -88,12 +88,12 @@
|
|
|
88
88
|
"zod": "^4.1.13"
|
|
89
89
|
},
|
|
90
90
|
"optionalDependencies": {
|
|
91
|
-
"@corsair-dev/frpc-linux-arm64": "0.1.117",
|
|
92
|
-
"@corsair-dev/frpc-linux-x64": "0.1.117",
|
|
93
91
|
"@corsair-dev/frpc-darwin-arm64": "0.1.117",
|
|
94
|
-
"@corsair-dev/frpc-
|
|
92
|
+
"@corsair-dev/frpc-win32-arm64": "0.1.117",
|
|
95
93
|
"@corsair-dev/frpc-win32-x64": "0.1.117",
|
|
96
|
-
"@corsair-dev/frpc-
|
|
94
|
+
"@corsair-dev/frpc-linux-x64": "0.1.117",
|
|
95
|
+
"@corsair-dev/frpc-darwin-x64": "0.1.117",
|
|
96
|
+
"@corsair-dev/frpc-linux-arm64": "0.1.117"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@testing-library/react": "^16.3.2",
|