@zuplo/runtime 6.59.8 → 6.59.10
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/out/esm/{chunk-6JMEGIXE.js → chunk-B77APQ6Y.js} +2 -2
- package/out/esm/{chunk-XGTJ3NUE.js → chunk-QROYR45R.js} +1 -1
- package/out/esm/{chunk-ZI6BEEZC.js → chunk-V5YKH6RW.js} +1 -1
- package/out/esm/index.js +36 -36
- package/out/esm/internal/index.js +1 -1
- package/out/esm/mocks/index.js +1 -1
- package/out/types/index.d.ts +145 -0
- package/package.json +1 -1
- /package/out/esm/{chunk-6JMEGIXE.js.LEGAL.txt → chunk-B77APQ6Y.js.LEGAL.txt} +0 -0
|
@@ -32,5 +32,5 @@ var de=Object.create;var P=Object.defineProperty;var ge=Object.getOwnPropertyDes
|
|
|
32
32
|
`))):l=e.stylize("[Circular]","special")),ee(i)){if(u&&o.match(/^\d+$/))return l;i=JSON.stringify(""+o),i.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(i=i.substr(1,i.length-2),i=e.stylize(i,"name")):(i=i.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),i=e.stylize(i,"string"))}return i+": "+l}r(H,"formatProperty");function qe(e,t){if(ee(t))return e.stylize("undefined","undefined");if(te(t)){let n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(Ye(t))return e.stylize(""+t,"number");if(ke(t))return e.stylize(""+t,"boolean");if(ne(t))return e.stylize("null","null")}r(qe,"formatPrimitive");function Je(e,t,n){let s=0;return e.reduce(function(u,i){return s++,i.indexOf(`
|
|
33
33
|
`)>=0&&s++,u+i.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(t===""?"":t+`
|
|
34
34
|
`)+" "+e.join(`,
|
|
35
|
-
`)+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}r(Je,"reduceToSingleString");var oe=r((e,...t)=>X(R,e,t),"format");var G=class{static{r(this,"Debugger")}manager;ns;color;last;enabled;constructor(t,n){this.manager=t,this.ns=n,this.color=K(n),this.last=0,this.enabled=t.enabled.some(s=>s.test(n))}log(...t){if(!this.enabled)return;let n,s=t[0];typeof s=="function"?n=s():n=String(s);let o=Date.now()-(this.last||Date.now());n=oe(n,...t);let u=`${this.color(this.ns)} ${n} ${this.color(`+${o}ms`)}`;console.log(u),this.last=Date.now()}},$=class{static{r(this,"DebugManager")}debuggers;enabled;constructor(t){this.debuggers=new Map,this.enabled=t??[]}};function Ke(e){return!e||e.length===0?[]:(e=e.replace(/\s/g,"").replace(/\*/g,".+"),e.split(",").map(t=>new RegExp(`^${t}$`)))}r(Ke,"extract");var U;function ie(e){let t=globalThis.DEBUG;U||(U=new $(Ke(t)));let n=new G(U,e);return U.debuggers.set(e,n),Object.assign(n.log.bind(n),{self:n})}r(ie,"debug");function Xe(e){if(e.length>=255)throw new TypeError("Alphabet too long");let t=new Uint8Array(256);for(let c=0;c<t.length;c++)t[c]=255;for(let c=0;c<e.length;c++){let a=e.charAt(c),d=a.charCodeAt(0);if(t[d]!==255)throw new TypeError(a+" is ambiguous");t[d]=c}let n=e.length,s=e.charAt(0),o=Math.log(n)/Math.log(256),u=Math.log(256)/Math.log(n);function i(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let a=0,d=0,g=0,_=c.length;for(;g!==_&&c[g]===0;)g++,a++;let h=(_-g)*u+1>>>0,E=new Uint8Array(h);for(;g!==_;){let f=c[g],A=0;for(let O=h-1;(f!==0||A<d)&&O!==-1;O--,A++)f+=256*E[O]>>>0,E[O]=f%n>>>0,f=f/n>>>0;if(f!==0)throw new Error("Non-zero carry");d=A,g++}let m=h-d;for(;m!==h&&E[m]===0;)m++;let S=s.repeat(a);for(;m<h;++m)S+=e.charAt(E[m]);return S}r(i,"encode");function l(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let a=0,d=0,g=0;for(;c[a]===s;)d++,a++;let _=(c.length-a)*o+1>>>0,h=new Uint8Array(_);for(;c[a];){let f=t[c.charCodeAt(a)];if(f===255)return;let A=0;for(let O=_-1;(f!==0||A<g)&&O!==-1;O--,A++)f+=n*h[O]>>>0,h[O]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");g=A,a++}let E=_-g;for(;E!==_&&h[E]===0;)E++;let m=new Uint8Array(d+(_-E)),S=d;for(;E!==_;)m[S++]=h[E++];return m}r(l,"decodeUnsafe");function p(c){let a=l(c);if(a)return a;throw new Error("Non-base"+n+" character")}return r(p,"decode"),{encode:i,decodeUnsafe:l,decode:p}}r(Xe,"base");var se=Xe;var Qe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ce=se(Qe);var x=ie("zuplo:runtime:external-service");function et(){let e,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:t}=b.instance.runtime;if(t&&t!=="undefined")try{let n=atob(t);e=JSON.parse(n)}catch{}return e}r(et,"getServiceAuth");async function le(e,t){let n=et();if(n)if(x(`Using external service auth. ClientId: ${n.clientId})`),typeof e=="string"){let s=new URL(e),o=s.hostname,u=t??{},i=new Headers(u.headers||{});i.set("CF-Access-Client-Id",n.clientId),i.set("CF-Access-Client-Secret",n.clientSecret),u.headers=i;let l;if(n.customServiceMapping&&n.customServiceMapping[o])l=`https://${n.customServiceMapping[o]}`;else if(b.instance.useLegacyServiceRouting)l=`https://${o}.zuptunnel.com`;else{x("Using sha256 service routing");let a=b.instance.build;if(a.ACCOUNT_NAME&&a.PROJECT_NAME&&a.ENVIRONMENT_TYPE){let d=await tt(o,a.ACCOUNT_NAME,a.PROJECT_NAME,a.ENVIRONMENT_TYPE),g=ae(a.ENVIRONMENT_TYPE),_=await V(`${a.ACCOUNT_NAME}-${a.PROJECT_NAME}-${g}`);_==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||_==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?l=`https://${d}.zuptunnel.com`:l=`https://${d}.t.zuplo.app`}else throw x("Cannot use sha256 service routing, missing build variables"),new y("Failed to generate fully qualified tunnel url.")}let p=new URL(`${l}${s.pathname}${s.search}`);x(`Calling external service: ${p.toString()}`);let c=await I(p.toString(),u);if(c.status===403&&c.headers.get("cf-access-domain")!==null)throw C.console.error("403 Forbidden when calling external service.",{clientId:n.clientId,tunnelHost:l}),new y("Could not connect to secure tunnel.");return c}else throw x("Cannot call external service with Request object"),new y("Currently, we only support fetch(<some_string>, ...).");else throw x("There is no external service auth configured for this zup."),new y("There are no external services configured for this zup.")}r(le,"externalServiceHandler");async function ue(e,t){if(typeof e=="string"){let n=new URL(e),s=n.hostname,o=t??{},u=`http://${s}.zuplo.svc.cluster.local:9000`,i=new URL(`${u}${n.pathname}${n.search}`),l=new Headers(o.headers||{});return l.set(N,s),o.headers=l,await I(i.toString(),o)}else throw new y("Currently, we only support fetch(<some_string>, ...).")}r(ue,"clusterServiceHandler");async function tt(e,t,n,s){let o=e.toLowerCase(),u=t.toLowerCase(),i=n.toLowerCase(),l=ae(s);x(`Hashing service name: ${u}-${o}.${u}-${i}-${l}`);let p=await V(`${u}-${o}`),c=await V(`${u}-${i}-${l}`);return`${p}.${c}`}r(tt,"hashServiceName");async function V(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(u=>u.toString(16).padStart(2,"0")).join("").slice(0,-1)}r(V,"hashSegment");function ae(e){let t=e.toLowerCase();switch(t){case"production":case"preview":return t;default:return"working-copy"}}r(ae,"sanitizeEnvironmentType");var k=new Map;k.set("service:",le);k.set("local:",ue);var I=globalThis.fetch;function B(e,t){let n=nt(t);if(typeof e=="string"){let s=new URL(e),o=k.get(s.protocol);return o?o(e,n):I(e,n)}else return I(e,n)}r(B,"internalFetch");globalThis.fetch=B;var nt=r(e=>{if(!e||e instanceof Request)return e;let t=e;if(!t.zuplo)return e;let n=e;return n.cf={cacheEverything:t.zuplo?.cacheEverything,cacheTtl:t.zuplo?.cacheTtlSeconds},delete e.zuplo,e},"transformInit");var rt={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:B},C=rt;var Y="2025-02-06",pe=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function fe(){return new b({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:Y,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:pe[Y]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:""}})}r(fe,"getMockEnvironment");var b=class e{static{r(this,"Environment")}config;static#e;static#t=!1;static initialize(t){this.#e||(this.#e=new e(t),this.#t=!0)}static get instance(){return this.#t||(C.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#e=fe()),this.#e}constructor({build:t,runtime:n}){let s;try{if(n.ZUPLO_SYSTEM_CONFIGURATIONS){let o=new TextDecoder().decode(ce.decode(n.ZUPLO_SYSTEM_CONFIGURATIONS)),u=JSON.parse(o);for(let i of Object.keys(u))n[i]||(n[i]=u[i])}if(n.__ZUPLO_CONFIG){let o=atob(n.__ZUPLO_CONFIG);s=JSON.parse(o)}}catch(o){C.console.error("Failed to parse runtime configuration",o)}this.config=s??{},this.build=t,this.runtime=n,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let t=typeof globalThis.Deno<"u"&&globalThis.Deno.version&&globalThis.Deno.version.deno;return typeof WebSocketPair!="function"&&t}}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}get rateLimitServiceTimeoutMs(){let t=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,n=this.config.rate_limit_service_timeout_ms,s=t??n;if(!s)return 500;let o=Number(s);return Number.isFinite(o)&&o>0?o:500}};export{r as a,ot as b,it as c,st as d,ct as e,lt as f,ie as g,W as h,y as i,q as j,b as k,ft as l,me as m,Oe as n,ye as o,dt as p,gt as q,_t as r,Re as s,be as t,Ae as u,xe as v,Le as w,Et as x,ht as y,mt as z,Ot as A,yt as B,Rt as C,bt as D,At as E,xt as F,Lt as G,Te as H,Pe as I,Ie as J,Ce as K,Se as L,we as M,Ue as N,Ne as O,Tt as P,N as Q,De as R,Pt as S,It as T,Ct as U,St as V,wt as W,Ut as X,Nt as Y,C as Z};
|
|
36
|
-
/*! For license information please see chunk-
|
|
35
|
+
`)+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}r(Je,"reduceToSingleString");var oe=r((e,...t)=>X(R,e,t),"format");var G=class{static{r(this,"Debugger")}manager;ns;color;last;enabled;constructor(t,n){this.manager=t,this.ns=n,this.color=K(n),this.last=0,this.enabled=t.enabled.some(s=>s.test(n))}log(...t){if(!this.enabled)return;let n,s=t[0];typeof s=="function"?n=s():n=String(s);let o=Date.now()-(this.last||Date.now());n=oe(n,...t);let u=`${this.color(this.ns)} ${n} ${this.color(`+${o}ms`)}`;console.log(u),this.last=Date.now()}},$=class{static{r(this,"DebugManager")}debuggers;enabled;constructor(t){this.debuggers=new Map,this.enabled=t??[]}};function Ke(e){return!e||e.length===0?[]:(e=e.replace(/\s/g,"").replace(/\*/g,".+"),e.split(",").map(t=>new RegExp(`^${t}$`)))}r(Ke,"extract");var U;function ie(e){let t=globalThis.DEBUG;U||(U=new $(Ke(t)));let n=new G(U,e);return U.debuggers.set(e,n),Object.assign(n.log.bind(n),{self:n})}r(ie,"debug");function Xe(e){if(e.length>=255)throw new TypeError("Alphabet too long");let t=new Uint8Array(256);for(let c=0;c<t.length;c++)t[c]=255;for(let c=0;c<e.length;c++){let a=e.charAt(c),d=a.charCodeAt(0);if(t[d]!==255)throw new TypeError(a+" is ambiguous");t[d]=c}let n=e.length,s=e.charAt(0),o=Math.log(n)/Math.log(256),u=Math.log(256)/Math.log(n);function i(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let a=0,d=0,g=0,_=c.length;for(;g!==_&&c[g]===0;)g++,a++;let h=(_-g)*u+1>>>0,E=new Uint8Array(h);for(;g!==_;){let f=c[g],A=0;for(let O=h-1;(f!==0||A<d)&&O!==-1;O--,A++)f+=256*E[O]>>>0,E[O]=f%n>>>0,f=f/n>>>0;if(f!==0)throw new Error("Non-zero carry");d=A,g++}let m=h-d;for(;m!==h&&E[m]===0;)m++;let S=s.repeat(a);for(;m<h;++m)S+=e.charAt(E[m]);return S}r(i,"encode");function l(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let a=0,d=0,g=0;for(;c[a]===s;)d++,a++;let _=(c.length-a)*o+1>>>0,h=new Uint8Array(_);for(;c[a];){let f=t[c.charCodeAt(a)];if(f===255)return;let A=0;for(let O=_-1;(f!==0||A<g)&&O!==-1;O--,A++)f+=n*h[O]>>>0,h[O]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");g=A,a++}let E=_-g;for(;E!==_&&h[E]===0;)E++;let m=new Uint8Array(d+(_-E)),S=d;for(;E!==_;)m[S++]=h[E++];return m}r(l,"decodeUnsafe");function p(c){let a=l(c);if(a)return a;throw new Error("Non-base"+n+" character")}return r(p,"decode"),{encode:i,decodeUnsafe:l,decode:p}}r(Xe,"base");var se=Xe;var Qe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ce=se(Qe);var x=ie("zuplo:runtime:external-service");function et(){let e,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:t}=b.instance.runtime;if(t&&t!=="undefined")try{let n=atob(t);e=JSON.parse(n)}catch{}return e}r(et,"getServiceAuth");async function le(e,t){let n=et();if(n)if(x(`Using external service auth. ClientId: ${n.clientId})`),typeof e=="string"){let s=new URL(e),o=s.hostname,u=t??{},i=new Headers(u.headers||{});i.set("CF-Access-Client-Id",n.clientId),i.set("CF-Access-Client-Secret",n.clientSecret),u.headers=i;let l;if(n.customServiceMapping&&n.customServiceMapping[o])l=`https://${n.customServiceMapping[o]}`;else if(b.instance.useLegacyServiceRouting)l=`https://${o}.zuptunnel.com`;else{x("Using sha256 service routing");let a=b.instance.build;if(a.ACCOUNT_NAME&&a.PROJECT_NAME&&a.ENVIRONMENT_TYPE){let d=await tt(o,a.ACCOUNT_NAME,a.PROJECT_NAME,a.ENVIRONMENT_TYPE),g=ae(a.ENVIRONMENT_TYPE),_=await V(`${a.ACCOUNT_NAME}-${a.PROJECT_NAME}-${g}`);_==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||_==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?l=`https://${d}.zuptunnel.com`:l=`https://${d}.t.zuplo.app`}else throw x("Cannot use sha256 service routing, missing build variables"),new y("Failed to generate fully qualified tunnel url.")}let p=new URL(`${l}${s.pathname}${s.search}`);x(`Calling external service: ${p.toString()}`);let c=await I(p.toString(),u);if(c.status===403&&c.headers.get("cf-access-domain")!==null)throw C.console.error("403 Forbidden when calling external service.",{clientId:n.clientId,tunnelHost:l}),new y("Could not connect to secure tunnel.");return c}else throw x("Cannot call external service with Request object"),new y("Currently, we only support fetch(<some_string>, ...).");else throw x("There is no external service auth configured for this zup."),new y("There are no external services configured for this zup.")}r(le,"externalServiceHandler");async function ue(e,t){if(typeof e=="string"){let n=new URL(e),s=n.hostname,o=t??{},u=`http://${s}.zuplo.svc.cluster.local:9000`,i=new URL(`${u}${n.pathname}${n.search}`),l=new Headers(o.headers||{});return l.set(N,s),o.headers=l,await I(i.toString(),o)}else throw new y("Currently, we only support fetch(<some_string>, ...).")}r(ue,"clusterServiceHandler");async function tt(e,t,n,s){let o=e.toLowerCase(),u=t.toLowerCase(),i=n.toLowerCase(),l=ae(s);x(`Hashing service name: ${u}-${o}.${u}-${i}-${l}`);let p=await V(`${u}-${o}`),c=await V(`${u}-${i}-${l}`);return`${p}.${c}`}r(tt,"hashServiceName");async function V(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(u=>u.toString(16).padStart(2,"0")).join("").slice(0,-1)}r(V,"hashSegment");function ae(e){let t=e.toLowerCase();switch(t){case"production":case"preview":return t;default:return"working-copy"}}r(ae,"sanitizeEnvironmentType");var k=new Map;k.set("service:",le);k.set("local:",ue);var I=globalThis.fetch;function B(e,t){let n=nt(t);if(typeof e=="string"){let s=new URL(e),o=k.get(s.protocol);return o?o(e,n):I(e,n)}else return I(e,n)}r(B,"internalFetch");globalThis.fetch=B;var nt=r(e=>{if(!e||e instanceof Request)return e;let t=e;if(!t.zuplo)return e;let n=e;return n.cf={cacheEverything:t.zuplo?.cacheEverything,cacheTtl:t.zuplo?.cacheTtlSeconds},delete e.zuplo,e},"transformInit");var rt={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:B},C=rt;var Y="2025-02-06",pe=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function fe(){return new b({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:Y,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:pe[Y]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:"",ZUPLO_SERVICE_BUCKET_ID:"mock-bucket-id"}})}r(fe,"getMockEnvironment");var b=class e{static{r(this,"Environment")}config;static#e;static#t=!1;static initialize(t){this.#e||(this.#e=new e(t),this.#t=!0)}static get instance(){return this.#t||(C.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#e=fe()),this.#e}constructor({build:t,runtime:n}){let s;try{if(n.ZUPLO_SYSTEM_CONFIGURATIONS){let o=new TextDecoder().decode(ce.decode(n.ZUPLO_SYSTEM_CONFIGURATIONS)),u=JSON.parse(o);for(let i of Object.keys(u))n[i]||(n[i]=u[i])}if(n.__ZUPLO_CONFIG){let o=atob(n.__ZUPLO_CONFIG);s=JSON.parse(o)}}catch(o){C.console.error("Failed to parse runtime configuration",o)}this.config=s??{},this.build=t,this.runtime=n,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let t=typeof globalThis.Deno<"u"&&globalThis.Deno.version&&globalThis.Deno.version.deno;return typeof WebSocketPair!="function"&&t}}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}get rateLimitServiceTimeoutMs(){let t=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,n=this.config.rate_limit_service_timeout_ms,s=t??n;if(!s)return 500;let o=Number(s);return Number.isFinite(o)&&o>0?o:500}};export{r as a,ot as b,it as c,st as d,ct as e,lt as f,ie as g,W as h,y as i,q as j,b as k,ft as l,me as m,Oe as n,ye as o,dt as p,gt as q,_t as r,Re as s,be as t,Ae as u,xe as v,Le as w,Et as x,ht as y,mt as z,Ot as A,yt as B,Rt as C,bt as D,At as E,xt as F,Lt as G,Te as H,Pe as I,Ie as J,Ce as K,Se as L,we as M,Ue as N,Ne as O,Tt as P,N as Q,De as R,Pt as S,It as T,Ct as U,St as V,wt as W,Ut as X,Nt as Y,C as Z};
|
|
36
|
+
/*! For license information please see chunk-B77APQ6Y.js.LEGAL.txt */
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
import{a as e,k as o}from"./chunk-
|
|
25
|
+
import{a as e,k as o}from"./chunk-B77APQ6Y.js";var s={MCP_TOOL_USAGE:"mcp_tool_usage"};var r=class{static{e(this,"BaseAnalyticsEvent")}eventId;requestId;timestamp;accountName;projectName;deploymentName;unit;value;constructor(t){this.eventId=t.eventId,this.requestId=t.requestId,this.timestamp=t.timestamp??new Date,this.accountName=t.accountName,this.projectName=t.projectName,this.deploymentName=t.deploymentName,this.unit=t.unit,this.value=t.value}};var i=class extends r{static{e(this,"McpToolUsageEvent")}eventType=s.MCP_TOOL_USAGE;metadata;constructor(t){t.metadata.toolName.trim()||(t.metadata.toolName="unknown"),t.metadata.toolVersion.trim()||(t.metadata.toolVersion="unknown"),t.metadata.toolPath.trim()||(t.metadata.toolPath="unknown"),t.metadata.toolMethod.trim()||(t.metadata.toolMethod="unknown"),t.metadata.toolOperationId.trim()||(t.metadata.toolOperationId="unknown"),super(t),this.metadata=t.metadata}};var d={[s.MCP_TOOL_USAGE]:i};function c(a,t){let n=d[a];return new n(t)}e(c,"createAnalyticsEvent");var v=class{static{e(this,"ZuploGatewayAnalyticsContext")}#t;#e;constructor(t){this.#t=[],this.#e=t}addAnalyticsEvent(t,n,p,m){let l=this.createAnalyticsEvent(t,n,p,m);this.#t.push(l)}getAnalyticsEvents(){return this.#t}createAnalyticsEvent(t,n,p,m){return c(n,{eventId:crypto.randomUUID(),requestId:this.#e,accountName:o.instance.build.ACCOUNT_NAME??"unknown",projectName:o.instance.build.PROJECT_NAME??"unknown",deploymentName:o.instance.deploymentName??"unknown",metadata:p,unit:m,value:t})}};export{v as a};
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
import{a as i,k as o}from"./chunk-
|
|
25
|
+
import{a as i,k as o}from"./chunk-B77APQ6Y.js";var p=(n=>(n.Build="build-data",n.CorsPreflight="cors-preflight",n.DeveloperPortal="developer-portal",n.ZudokuPortal="zudoku-portal",n.DeveloperPortalLegacy="developer-portal-legacy",n.StripePlugin="stripe-plugin",n.EmptyGatewayCatchall="empty-gateway-catchall",n.Ping="ping",n.UnmatchedPath="unmatched-path",n))(p||{});var g=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function l(e){return e.startsWith("__ZUPLO")||e.startsWith("ZUPLO_")?!g.includes(e)&&!e.startsWith("ZUPLO_PUBLIC_"):e.startsWith("ZUDOKU_")?!e.startsWith("ZUDOKU_PUBLIC_"):!1}i(l,"isRestrictedEnvVariableName");function _(e){return!!e.startsWith("ZUPLO_")}i(_,"isZuploReadableEnvVariableName");var d=new Proxy({},{get(e,t){let r=String(t);switch(r){case"ZUPLO_ENVIRONMENT_TYPE":return o.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return o.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return o.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return o.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return o.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return o.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return o.instance.build.COMPATIBILITY_DATE}if(!(l(r)&&!_(r)))return o.instance.runtime[r]}});function f(e,t,r){return`_${a(`${e}_${t}_${r}`)}`}i(f,"getRawOperationDataIdentifierName");function L(e,t,r,s){return`_${a(e.toLowerCase())}_${t.toLowerCase()}_${r.toLowerCase()}_${s.toLowerCase()}`}i(L,"getIdForParameterSchema");function E(e,t,r){return`_${a(e.toLowerCase())}_${t.toLowerCase()}_rb_${a(r.toLowerCase())}`}i(E,"getIdForRequestBodySchema");function C(e,t){return`_${a(e)}_${a(t)}`}i(C,"getIdForRefSchema");function a(e){let t=e.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(t)||(t="_"+t),t}i(a,"sanitizedIdentifierName");export{p as a,l as b,_ as c,d,f as e,L as f,E as g,C as h,a as i};
|