@zuplo/runtime 5.1817.0 → 5.1819.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -2417,11 +2417,39 @@ export declare class MemoryZoneReadThroughCache<T = unknown> {
2417
2417
 
2418
2418
  /* Excluded from this release type: MeteringPlugin */
2419
2419
 
2420
- /* Excluded from this release type: MeteringRegions */
2420
+ /**
2421
+ * @beta
2422
+ */
2423
+ declare type MeteringRegions = "us-central1" | "europe-west4";
2421
2424
 
2422
- /* Excluded from this release type: MeteringSubscription */
2425
+ /**
2426
+ * @beta
2427
+ */
2428
+ declare interface MeteringSubscription {
2429
+ status: MeteringSubscriptionStatus;
2430
+ type: "credits" | "periodic";
2431
+ region: MeteringRegions;
2432
+ renewalStrategy: "hourly" | "monthly" | "yearly";
2433
+ customerKey: string;
2434
+ /**
2435
+ * Array of Stripe product ids, they start with "prod_"
2436
+ */
2437
+ planExternalIds: string[];
2438
+ /**
2439
+ * Stripe subscription id, starts with "sub_"
2440
+ */
2441
+ subscriptionExternalId?: string;
2442
+ /**
2443
+ * Stripe customer id, starts with "cus_"
2444
+ */
2445
+ customerExternalId?: string;
2446
+ metadata?: Record<string, string>;
2447
+ }
2423
2448
 
2424
- /* Excluded from this release type: MeteringSubscriptionStatus */
2449
+ /**
2450
+ * @beta
2451
+ */
2452
+ declare type MeteringSubscriptionStatus = "active" | "inactive" | "incomplete" | "incomplete-expired" | "trialing" | "past-due" | "canceled" | "unpaid";
2425
2453
 
2426
2454
  /* Excluded from this release type: MetricsData */
2427
2455
 
@@ -2565,7 +2593,24 @@ declare type MonetizationPolicyMeters = {
2565
2593
  [Key in string]: number;
2566
2594
  };
2567
2595
 
2568
- /* Excluded from this release type: MonetizationSubscription */
2596
+ /**
2597
+ * @beta
2598
+ */
2599
+ export declare interface MonetizationSubscription extends MeteringSubscription {
2600
+ /**
2601
+ * Metering subscription id, starts with "sbsc_"
2602
+ */
2603
+ id: string;
2604
+ createdOn: string;
2605
+ updatedOn: string;
2606
+ quotaResetAnchor?: Date;
2607
+ meters: {
2608
+ [Key in string]: {
2609
+ consumed: number;
2610
+ max: number;
2611
+ };
2612
+ };
2613
+ }
2569
2614
 
2570
2615
  declare interface NotFoundOptions {
2571
2616
  routesMatchedByPathOnly: RouteConfiguration[];
@@ -3659,9 +3704,45 @@ export declare interface SleepInboundPolicyOptions {
3659
3704
 
3660
3705
  /* Excluded from this release type: StandardEnv */
3661
3706
 
3662
- /* Excluded from this release type: StripeMeteringPlugin */
3707
+ /**
3708
+ * Adds stripe metering routes and configuration
3709
+ * @beta
3710
+ */
3711
+ export declare class StripeMeteringPlugin extends MeteringPlugin {
3712
+ private options;
3713
+ constructor(options: StripeMeteringPluginOptions);
3714
+ registerRoutes(router: Router, gateway: Gateway): void;
3715
+ }
3663
3716
 
3664
- /* Excluded from this release type: StripeMeteringPluginOptions */
3717
+ /**
3718
+ * @beta
3719
+ */
3720
+ export declare interface StripeMeteringPluginOptions {
3721
+ /**
3722
+ * Stripe Webhook settings
3723
+ */
3724
+ webhooks: StripeWebhookVerificationInboundPolicyOptions & {
3725
+ /**
3726
+ * The URL path where the webhook is registered.
3727
+ * Defaults to `/_zuplo/stripe-webhook`
3728
+ */
3729
+ routePath?: string;
3730
+ };
3731
+ /**
3732
+ * The ID of the Zuplo metering bucket.
3733
+ */
3734
+ meteringBucketId?: string;
3735
+ /**
3736
+ * The region of the Zuplo metering bucket.
3737
+ */
3738
+ meteringBucketRegion?: string;
3739
+ apiKeyBucketName?: string;
3740
+ /**
3741
+ * The Stripe account's secret key
3742
+ */
3743
+ stripeSecretKey: string;
3744
+ /* Excluded from this release type: __testMode */
3745
+ }
3665
3746
 
3666
3747
  /**
3667
3748
  * The Stripe Webhook policy validates the authenticity of an incoming Stripe webhook.
package/index.minified.js CHANGED
@@ -64,7 +64,7 @@
64
64
  `)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
65
65
  `,this.signedHeaders,await this.hexBodyHash()].join(`
66
66
  `)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256");if(e==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new L("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=Br(await ns(this.body||""))}return e}};async function vt(t,e){let n=await crypto.subtle.importKey("raw",typeof t=="string"?jr.encode(t):t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",n,jr.encode(e))}s(vt,"hmac");async function ns(t){return crypto.subtle.digest("SHA-256",typeof t=="string"?jr.encode(t):t)}s(ns,"hash");function Br(t){return Array.prototype.map.call(new Uint8Array(t),e=>("0"+e.toString(16)).slice(-2)).join("")}s(Br,"buf2hex");function rs(t){return t.replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())}s(rs,"encodeRfc3986");function Jc(t,e){let{hostname:n,pathname:r}=t,o=n.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[i,a]=(o||["",""]).slice(1,3);if(a==="us-gov")a="us-gov-west-1";else if(a==="s3"||a==="s3-accelerate")a="us-east-1",i="s3";else if(i==="iot")n.startsWith("iot.")?i="execute-api":n.startsWith("data.jobs.iot.")?i="iot-jobs-data":i=r==="/mqtt"?"iotdevicegateway":"iotdata";else if(i==="autoscaling"){let u=(e.get("X-Amz-Target")||"").split(".")[0];u==="AnyScaleFrontendService"?i="application-autoscaling":u==="AnyScaleScalingPlannerFrontendService"&&(i="autoscaling-plans")}else a==null&&i.startsWith("s3-")?(a=i.slice(3).replace(/^fips-|^external-1/,""),i="s3"):i.endsWith("-fips")?i=i.slice(0,-5):a&&/-\d$/.test(i)&&!/-\d$/.test(a)&&([i,a]=[a,i]);return i in ts?[ts[i],a]:[i,a]}s(Jc,"guessServiceRegion");function Kc(t){return t>64&&t<91?t-65:t>96&&t<123?t-71:t>47&&t<58?t+4:t===43?62:t===47?63:0}s(Kc,"b64ToUint6");function is(t,e){let n=t.replace(/[^A-Za-z0-9+/]/g,""),r=n.length,o=e?Math.ceil((r*3+1>>2)/e)*e:r*3+1>>2,i=new Uint8Array(o),a,u,c=0,l=0;for(let p=0;p<r;p++)if(u=p&3,c|=Kc(n.charCodeAt(p))<<6*(3-u),u===3||r-p===1){for(a=0;a<3&&l<o;)i[l]=c>>>(16>>>a&24)&255,a++,l++;c=0}return i}s(is,"base64Decode");function mn(t){return t<26?t+65:t<52?t+71:t<62?t-4:t===62?43:t===63?47:65}s(mn,"uint6ToB64");function ss(t){let e=2,n="",r=t.length,o=0;for(let i=0;i<r;i++)e=i%3,o|=t[i]<<(16>>>e&24),(e===2||t.length-i===1)&&(n+=String.fromCodePoint(mn(o>>>18&63),mn(o>>>12&63),mn(o>>>6&63),mn(o&63)),o=0);return n.substring(0,n.length-2+e)+(e===2?"":e===1?"=":"==")}s(ss,"base64Encode");function et(t){let e=t.toString();return`${e.length===1?"0":""}${e}`}s(et,"numberToString");function Yc(t){let e=t.getTimezoneOffset(),n=Math.abs(e),r=e>0?"-":"+",o=et(Math.floor(n/60)),i=et(n%60);return`${r}${o}${i}`}s(Yc,"getCLFOffset");function zr(t=new Date){if(!(t instanceof Date))throw new Error("clf-date: invalid parameter");let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=et(t.getDate()),r=e[t.getMonth()],o=t.getFullYear(),i=et(t.getHours()),a=et(t.getMinutes()),u=et(t.getSeconds()),c=Yc(t);return`${n}/${r}/${o}:${i}:${a}:${u} ${c}`}s(zr,"toCLFDate");var as=(0,us.debug)("zuplo:runtime"),Qc="X-Amzn-Trace-Id",Xc="x-amzn-errortype",cs=[],el=s(async(t,e,n)=>{let r=n;for await(let o of cs)r=await o(t,e,n);return r},"onSendingAwsLambdaEvent"),ue=class extends L{static{s(this,"AwsLambdaError")}traceId;errorType;constructor(e,n){super(`Failed to invoke AWS Lambda function. ${e}`),this.traceId=n.get(Qc)??void 0,this.errorType=n.get(Xc)??void 0}},ls={addSendingAwsLambdaEventHook:t=>{cs.push(t)}};async function ds(t,e){let{accessKeyId:n,secretAccessKey:r,region:o,functionName:i,useLambdaProxyIntegration:a=!0,useAwsResourcePathStyle:u=!1,binaryMediaTypes:c}=e.route.handler.options;if(!n)throw new y("awsAccessKeyId is not set in the handler options");if(!r)throw new y("secretAccessKey is not set in the handler options");if(!o)throw new y("region is not set in the handler options");if(!i)throw new y("functionName is not set in the handler options");let l=new Xe({accessKeyId:n,secretAccessKey:r}),p=`https://lambda.${o}.amazonaws.com/2015-03-31/functions/${i}/invocations`;if(as(`AWS Lambda URL: ${p}`),!a)return l.fetch(p,{body:await t.arrayBuffer()});let[d,g]=await ol(t,{binaryMediaTypes:c}),{options:m}=e.route.handler,R;m&&typeof m=="object"&&"payloadFormatVersion"in m&&m.payloadFormatVersion==="2.0"?R=rl(t,e):R=await nl(t,e,{useAwsResourcePathStyle:u}),as("Calling onSendingAwsLambdaEvent hook");let w=await el(t,e,R);w.body=d,w.isBase64Encoded=g;let I=await l.fetch(p,{body:JSON.stringify(w)});try{return tl(I)}catch(T){if(T instanceof ue){let f=m&&typeof m=="object"&&"returnAmazonTraceIdHeader"in m&&m.returnAmazonTraceIdHeader&&T.traceId?{AMZN_TRACE_ID_HEADER:T.traceId}:void 0;return S.internalServerError(t,e,void 0,f)}throw T}}s(ds,"awsLambdaHandler");async function tl(t){let e;try{e=await t.json()}catch{throw new ue("Lambda response did not contain valid JSON",t.headers)}if(t.status!==200)throw e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?new ue(e.message,t.headers):new ue(`Status: ${t.statusText}`,t.headers);if(e&&typeof e=="object"&&"errorMessage"in e&&typeof e.errorMessage=="string")throw new ue(e.errorMessage,t.headers);if(!e||typeof e!="object"||!("statusCode"in e)||typeof e.statusCode!="number")return new Response(JSON.stringify(e),{status:t.status,headers:{"content-type":"application/json"}});let n=new Headers;if("headers"in e&&e.headers){if(typeof e.headers!="object")throw new ue(`Response headers must be an object. Received ${typeof e.headers}`,t.headers);for(let[o,i]of Object.entries(e.headers))n.set(o,i)}if("cookies"in e&&e.cookies){if(!Array.isArray(e.cookies))throw new ue(`Response cookies must be an array. Received ${typeof e.cookies}`,t.headers);n.set("cookie",e.cookies.join(";"))}let r;if("isBase64Encoded"in e&&typeof e.isBase64Encoded!="boolean")throw new ue(`Response property isBase64Encoded must be a boolean. Received ${typeof e.isBase64Encoded}`,t.headers);if("isBase64Encoded"in e&&e.isBase64Encoded===!0){if(!("body"in e))throw new ue("Response was set to base64 encoded but no body was set",t.headers);if(typeof e.body!="string")throw new ue("Response was set to base64 encoded but body was not a string",t.headers);r=is(e.body)}else"body"in e&&typeof e.body=="string"?r=e.statusCode===204&&e.body===""?null:e.body:"body"in e&&e.body!==null&&e.body!==void 0?r=JSON.stringify(e.body):r=null;if(r!==null&&"bodyEncoding"in e){if(typeof e.bodyEncoding!="string"||!(e.bodyEncoding==="gzip"||e.bodyEncoding==="deflate"))throw new ue(`Response property bodyEncoding can only be set to 'gzip' or 'deflate'. Received ${e.bodyEncoding}`,t.headers);let o=new Blob([r]).stream().pipeThrough(new DecompressionStream(e.bodyEncoding));r=await new Response(o).arrayBuffer()}return new Response(r,{headers:n,status:e.statusCode})}s(tl,"getResponse");async function nl(t,e,{useAwsResourcePathStyle:n}){let r={},o={};t.headers.forEach((l,p)=>{r[p]=l,o[p]=[l]});let i=t.query,a={};for(let[l,p]of Object.entries(i))a[l]=[p];let u=new URL(t.url);return{version:"1.0",resource:u.pathname,path:u.pathname,httpMethod:t.method,headers:r,multiValueHeaders:o,queryStringParameters:i,multiValueQueryStringParameters:a,requestContext:{accountId:null,apiId:null,authorizer:{claims:{},scopes:[]},domainName:u.hostname,domainPrefix:null,extendedRequestId:e.requestId,httpMethod:t.method,identity:{accessKey:null,accountId:null,caller:null,cognitoAuthenticationProvider:null,cognitoAuthenticationType:null,cognitoIdentityId:null,cognitoIdentityPoolId:null,principalOrgId:null,sourceIp:t.headers.get("CF-Connecting-IP"),user:null,userAgent:t.headers.get("user-agent"),userArn:null,clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},path:u.pathname,protocol:"HTTP/1.1",requestId:e.requestId,requestTime:zr(),requestTimeEpoch:new Date().valueOf(),resourceId:e.route.operationId??null,resourcePath:sl(e.route.path,n),stage:null},pathParameters:t.params,stageVariables:null}}s(nl,"buildEventVersion1");function rl(t,e){let n={};t.headers.forEach((i,a)=>{n[a]=i});let r=new URL(t.url);return{version:"2.0",routeKey:null,rawPath:r.pathname,rawQueryString:r.search,cookies:[],headers:n,queryStringParameters:t.query,requestContext:{accountId:null,apiId:null,authentication:{clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},authorizer:{jwt:{claims:{},scopes:[]}},domainName:r.hostname,domainPrefix:null,http:{method:t.method,path:r.pathname,protocol:"HTTP/1.1",sourceIp:t.headers.get("CF-Connecting-IP"),userAgent:t.headers.get("user-agent")},requestId:e.requestId,routeKey:null,stage:null,time:zr(),timeEpoch:new Date().valueOf()},pathParameters:t.params,stageVariables:null}}s(rl,"buildEventVersion2");async function ol(t,{binaryMediaTypes:e}){let n,r=!1,o=t.headers.get("content-type");if(t.method==="GET"||t.method==="HEAD")n=null;else if(e&&o&&il(e,o)){let i=await t.arrayBuffer();n=ss(new Uint8Array(i)),r=!0}else n=await t.clone().text();return[n,r]}s(ol,"getBodyResult");function il(t,e){let n=e.split(";")[0].trim().toLowerCase();return t.findIndex(r=>r==="*/*"?!0:r.toLowerCase()===n)>-1}s(il,"matchesContentType");function sl(t,e=!1){if(!e)return t;let n=Fr(t),r=es(t),o={};return n.forEach(i=>{typeof i=="string"?o[i]=`{${i}}`:o[i.name]=`{${i.name}}`}),r(o)}s(sl,"getResourcePath");var al=[502,503,504];async function tt(t,e){if(al.includes(t.status)){let n=F.getLogger(e),o=await t.clone().text(),i={};for(let[a,u]of t.headers)i[a]=u;n.warn(`BadGatewayResponse ${t.status}`,{status:t.status,statusText:t.statusText,body:o,headers:i})}}s(tt,"logBadGatewayResponses");var Gr;function _e(t){if(Gr===void 0){let n=x.instance.runtime.ZUPLO_HANDLER_WRITE_LOG_LEVEL;["debug","info","warn","error"].includes(n??"")||(n="debug"),Gr=n}return t.log[Gr]}s(_e,"getHandlerUserLogFunction");async function ps(t,e){let n=x.instance.build.BUILD_ID,{buildAssetsUrl:r}=x.instance,o=e.route.handler.options,{openApiFilePath:i}=o;if(!i)throw new y("Open API Spec Handler must have 'openApiFilePath' specified");let a=ul(i);if(!a.isValid)throw new y(a.error);let u;x.instance.isLocalDevelopment?u=`${r}/${i.substring(1)}`:u=`${r}/${n}${i.substring(1)}`;let c=await fetch(u,{method:t.method,body:t.body,headers:t.headers});if(c.status!==200)return S.notFound(t,e,{detail:"OpenAPI file could not be found."});let l=new Response(c.body,{headers:{"content-type":"application/json"},status:c.status,statusText:c.statusText});return tt(l,e),l}s(ps,"openApiSpecHandler");var ul=s(t=>t.startsWith("./")?t.startsWith("./config")?t.endsWith(".oas.json")?{isValid:!0}:{isValid:!1,error:"'openApiFilePath' must point to a file ending in '.oas.json'"}:{isValid:!1,error:"'openApiFilePath' must point to a file in your /config directory"}:{isValid:!1,error:"'openApiFilePath' must start with './'"},"validateOpenApiPath");async function gs(t,e){let n=e.route.handler.options;if(!n.location)throw new y("Redirect Handler must have 'location' specified");let r=n.status??302;return new Response(null,{status:r,headers:{location:n.location}})}s(gs,"redirectHandler");function cl(t,e){let n=t.endsWith("/"),r=e.startsWith("/");return n&&r?`${t.substring(0,t.length-1)}${e}`:!n&&!r?`${t}/${e}`:`${t}${e}`}s(cl,"join");async function ms(t,e){let n=_e(e),r=e.route.handler.options,o=r.forwardSearch!==!1;if(!r.baseUrl)throw new Error("URL Forward Handler must have 'baseUrl' specified");if(!r||typeof r.__rewriteFunction!="function")throw new y("Invalid options for this route");let i={incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom},a=new URL(t.url),u=r.__rewriteFunction(t,i),c=cl(u,a.pathname),l=o?`${c}${a.search}`:c.toString(),p=Date.now();n(`URL Forwarding to '${l}'`);let d=await fetch(l,{method:t.method,body:t.body,headers:t.headers}),g=Date.now()-p;return n(`URL Forward received response ${d.status} - ${d.statusText} in ${g}ms`),tt(d,e),d}s(ms,"urlForwardHandler");var ll=s((t,e)=>{let n=new URL(t),r=new URL(e);for(let[o,i]of r.searchParams.entries())n.searchParams.append(o,i);return n.toString()},"addQuery");async function fs(t,e){let n=_e(e),r=e.route.handler.options,o=r.forwardSearch!==!1,i=r.followRedirects??!1;if(!r||typeof r.__rewriteFunction!="function")throw new y("Invalid options for this route");let a={incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom},u=r.__rewriteFunction(t,a),c=o?ll(u,t.url):u,l=Date.now();n(`URL Rewriting to '${c}'`);let p=await fetch(c.toString(),{method:t.method,body:t.body,headers:t.headers,redirect:i?"follow":"manual"}),d=Date.now()-l;return n(`URL Rewrite received response ${p.status} - ${p.statusText} in ${d}ms`),tt(p,e),p}s(fs,"urlRewriteHandler");async function hs(t,e){let n=x.instance,r=e.route.handler.options,o=_e(e);if(!r||!r.rewritePattern)throw new y("WebSocket Handler must have option 'rewritePattern' specified");let i=t.headers.get("Upgrade");if(!i||i!=="websocket")return S.badRequest(t,e,{detail:"Request must include header 'Upgrade: websocket'"});if(!r||typeof r.__rewriteFunction!="function")throw new y("Invalid options for this route");let a={incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom},u=r.__rewriteFunction(t,a),c=Date.now();if(o(`Attempting WebSocket connection to '${u}'`),n.isDeno){let d=new Headers(t.headers);if(u.startsWith("service:")){let m=await Ji(u),R=new URL(u);u=new URL(`${m.serviceBaseUrl}${R.pathname}${R.search}`).toString();for(let I in m.tunnelHeaders)d.set(I,m.tunnelHeaders[I])}u=u.replace(/^(http)/,"ws");try{if(d.get("Authorization")){let m=d.get("Authorization")?.replace("Bearer ","");u+=`?apiKey=${m}`}}catch{}let g=JSON.stringify({url:u});return new Response(g,{headers:d})}u=u.replace(/^(ws)/,"http");let l=await fetch(u,{method:t.method,headers:t.headers,body:t.body});if(l.status!==101||!l.webSocket){let d=await l.text(),g=`WebSocket connection error - ${l.status}: ${l.statusText}, content: '${d}'`;throw new Error(g)}let p=Date.now()-c;return o(`WebSocket connected, received response ${l.status} - ${l.statusText} in ${p}ms`),new Response(null,{status:101,webSocket:l.webSocket})}s(hs,"webSocketHandler");var Wr=s((t,e)=>t.map((r,o)=>{let i;if(typeof r.module=="object"&&(i=r.module[r.export]),!i||typeof i!="function"){let a=e==="inbound"?"WebSocketInboundPolicy":"WebSocketOutboundPolicy",u=`policy in position: ${o+1}, export name: ${r.export}`;throw new y(`${a} - Websocket policy must be a valid function (${u})`)}return i}),"getWebSocketPolicyFunctions"),ys=s(async(t,e,n,r,o,i)=>{let a=t.data;if(i&&i.length>0){let u=[...i];for(;u.length>0;){let c=u.shift();if(!c)return a;if(a=await c(a,n,e,r,o),a===void 0)return}}return a},"webSocketPolicyProcessor");function bs(t,e,n,r,o){t.addEventListener("close",()=>{e.close()}),t.addEventListener("error",i=>{r.log.error("WebSocket error: ",i),e.send(JSON.stringify(i))}),t.addEventListener("message",i=>{try{let u=s(async c=>{let l=await ys(c,t,e,n,r,o);l!==void 0&&e.send(l)},"innerPipeline")(i).catch(r.log.error);r.waitUntil(u)}catch(a){r.log.error(a)}})}s(bs,"wireUpListeners");async function ws(t,e){let n=x.instance,r=e.route.handler.options,o=_e(e);if(!r||!r.rewritePattern)throw new y("WebSocket Pipeline Handler must have option 'rewritePattern' specified");let i=t.headers.get("Upgrade");if(!i||i!=="websocket")return S.badRequest(t,e,{detail:"Request must include header 'Upgrade: websocket'"});if(!r||typeof r.__rewriteFunction!="function")throw new y("Invalid options for this route");let a={incomingRequestProperties:e.incomingRequestProperties,requestId:e.requestId,route:e.route,custom:e.custom},u=r.__rewriteFunction(t,a),c=Date.now();if(o(`Attempting WebSocket connection to '${u}'`),n.isDeno)throw new y("Websocket pipeline handler is currently not supported on working-copy environments");u=u.replace(/^(ws)/,"http");let l=await fetch(u,{method:t.method,headers:t.headers,body:t.body});if(l.status!==101||!l.webSocket){let T=await l.text(),f=`WebSocket connection error - ${l.status}: ${l.statusText}, content: '${T}'`;throw new Error(f)}let p=new WebSocketPair,[d,g]=Object.values(p),m=Date.now()-c;o(`WebSocket connected, received response ${l.status} - ${l.statusText} in ${m}ms`);let R=l.webSocket;R.accept(),g.accept();let w=r.policies&&r.policies.inbound?Wr(r.policies.inbound,"inbound"):[],I=r.policies&&r.policies.outbound?Wr(r.policies.outbound,"outbound"):[];return bs(g,R,t,e,w),bs(R,g,t,e,I),new Response(null,{status:101,webSocket:d})}s(ws,"webSocketPipelineHandler");var fn=class extends K{constructor(n){super();this.options=n}static{s(this,"DynaTraceLoggingPlugin")}getTransport(){return new Jr(this.options)}},Jr=class{static{s(this,"DynaTraceTransport")}constructor(e){this.#e=e.url,this.#t=e.apiToken,this.#r=x.instance.loggingEnvironmentType,this.#o=x.instance.loggingEnvironmentStage,this.#n=x.instance.deploymentName}#e;#t;#n;#r;#o;log(e,n){e.messages.forEach(r=>{let o={timestamp:new Date().toISOString(),message:xe(oe(r)),severity:e.level,"log.source":e.logSource,requestId:e.requestId,"custom.environment":this.#n,"custom.environmentStage":this.#o,"custom.environmentType":this.#r,"custom.loggingId":e.loggingId,"custom.rayId":e.rayId===null?void 0:e.rayId};this.batcher.enqueue(o)}),n.waitUntil(this.batcher.waitUntilFlushed())}#i=async e=>{e.length!==0&&await fetch(this.#e,{method:"POST",body:JSON.stringify(e),headers:{"content-type":"application/json; charset=utf-8",authorization:`Api-Token ${this.#t}`}})};batcher=new B("dyna-trace-log-transport",10,this.#i)};var hn=class extends K{constructor(n){super();this.options=n}static{s(this,"LokiLoggingPlugin")}getTransport(){return new Yr(this.options)}},Kr=class{static{s(this,"LokiStream")}constructor(e,n,r,o,i){this.level=e,this.environment=n,this.environmentType=r,this.environmentStage=o,this.requestId=i}job="zuplo";level;environment;environmentType;environmentStage;requestId;equals=e=>this.level===e.level&&this.requestId===e.requestId};function dl(t,e){return btoa(`${t}:${e}`)}s(dl,"createBasicDigest");var Yr=class{static{s(this,"LokiTransport")}constructor(e){this.#e=e.url,this.#t=dl(e.username,e.password),this.#r=x.instance.loggingEnvironmentType,this.#o=x.instance.loggingEnvironmentStage,this.#n=x.instance.deploymentName}#e;#t;#n;#r;#o;log(e,n){let r=new Kr(e.level,this.#n,this.#r,this.#o,e.requestId);e.messages.forEach(o=>{let i={stream:r,message:xe(oe(o)),nanoSecondEpoch:`${e.timestamp.getTime()}000000`};this.batcher.enqueue(i)}),n.waitUntil(this.batcher.waitUntilFlushed())}#i=e=>{let n={streams:[]};return e.forEach(r=>{let o=n.streams.find(i=>i.stream.equals(r.stream));o||(o={stream:r.stream,values:[]},n.streams.push(o)),o.values.push([r.nanoSecondEpoch,r.message])}),n};#s=async e=>{if(e.length===0)return;let n=this.#i(e);await fetch(this.#e,{method:"POST",body:JSON.stringify(n),headers:{"content-type":"application/json",authorization:`Basic ${this.#t}`}})};batcher=new B("loki-log-transport",10,this.#s)};var yn=class extends K{constructor(n){super();this.options=n}static{s(this,"SumoLogicLoggingPlugin")}getTransport(){return new Qr(this.options)}},Qr=class{static{s(this,"SumoLogicTransport")}constructor(e){this.#e=e.url,this.#o=e.category,this.#i=e.name,this.#n=x.instance.loggingEnvironmentType,this.#r=x.instance.loggingEnvironmentStage,this.#t=x.instance.deploymentName}#e;#t;#n;#r;#o;#i;log(e,n){e.messages.forEach(r=>{let o={timestamp:new Date().toISOString(),message:xe(oe(r)),severity:e.level,source:e.logSource,requestId:e.requestId,environment:this.#t,environmentType:this.#n,environmentStage:this.#r,rayId:e.rayId===null?void 0:e.rayId};this.batcher.enqueue(o)}),n.waitUntil(this.batcher.waitUntilFlushed())}#s=async e=>{if(e.length===0)return;let n=e.map(o=>JSON.stringify(o)).join(`
67
- `),r=new Headers({"content-type":"application/json; charset=utf-8"});this.#i&&r.set("X-Sumo-Name",this.#i),this.#o&&r.set("X-Sumo-Category",this.#o),await fetch(this.#e,{method:"POST",body:n,headers:r})};batcher=new B("sumo-logic-log-transport",10,this.#s)};var pl="d3a5b78f823648f5b1df4fe269d41172",bn=class extends K{constructor(n){super();this.options=n}static{s(this,"VMWareLogInsightLoggingPlugin")}getTransport(){return new Xr(this.options)}},Xr=class{static{s(this,"VMWareLogInsightTransport")}constructor(e){let n;try{n=new URL(e.url),n.pathname==="/"&&(n.pathname=`/api/v1/events/ingest/${e.agentId??pl}`)}catch{throw new y(`Invalid option 'url' on 'VMWareLogInsightTransport' plugin. Must be a valid URL, received '${e.url}'`)}this.#e=n.origin,this.#r=x.instance.loggingEnvironmentType,this.#o=x.instance.loggingEnvironmentStage,this.#n=x.instance.deploymentName,this.#i=e.onMessageSending,this.#t=e.textReplacements,e.fields&&(this.#s=Object.entries(e.fields).map(([r,o])=>({name:r,content:o})))}#e;#t;#n;#r;#o;#i;#s;log(e,n){let r=this.buildEntry(e,n);this.batcher.enqueue(r),n.waitUntil(this.batcher.waitUntilFlushed())}buildEntry(e,n){let r=Zi(e.messages);this.#t?.forEach(i=>{r=r.replaceAll(i[0],i[1])});let o={timestamp:Date.now(),text:r,fields:[{name:"severity",content:e.level.toUpperCase()},{name:"request_id",content:e.requestId},{name:"environment_type",content:this.#r},{name:"environment_stage",content:this.#o},{name:"log_source",content:e.logSource},{name:"atomic_counter",content:e.vectorClock}]};return e.rayId&&o.fields.push({name:"request_ray_id",content:e.rayId}),this.#n&&o.fields.push({name:"environment",content:this.#n}),this.#s&&o.fields.push(...this.#s),n.custom&&Object.entries(n.custom).forEach(([i,a])=>{let u=_r(a);u&&o.fields.push({name:i,content:u})}),this.#i&&(o=this.#i(o)),o}#a=async e=>{if(e.length===0)return;let n=await fetch(this.#e,{method:"POST",body:JSON.stringify({events:e}),headers:{"content-type":"application/json; charset=utf-8"}});if(n.status!==200)try{let r=await n.text();console.error("Error logging to Log Insight",r)}catch(r){console.error(r)}};batcher=new B("vmware-log-insights-log-transport",10,this.#a)};var wn=class extends K{constructor(n){super();this.options=n}static{s(this,"AWSLoggingPlugin")}getTransport(){return new eo(this.options)}},eo=class{static{s(this,"AWSLogTransport")}awsClient;environment;environmentType;logGroupName;logStreamName;region;batcher=new B("aws-log-transport",10,async e=>{if(e.length===0)return;let n=JSON.stringify({logGroupName:this.logGroupName,logStreamName:this.logStreamName,logEvents:e});await this.awsClient.fetch(`https://logs.${this.region}.amazonaws.com`,{headers:{"Content-Type":"application/x-amz-json-1.1","x-amz-Target":"Logs_20140328.PutLogEvents"},body:n,aws:{accessKeyId:this.awsClient.accessKeyId,secretAccessKey:this.awsClient.secretAccessKey,service:this.awsClient.service,region:this.awsClient.region}})});constructor({accessKeyId:e,logStreamName:n,logGroupName:r,secretAccessKey:o,region:i}){this.awsClient=new Xe({accessKeyId:e,secretAccessKey:o,service:"logs",region:i}),this.logGroupName=r,this.logStreamName=n,this.region=i,this.environmentType=x.instance.loggingEnvironmentType,this.environment=x.instance.deploymentName}log(e,n){e.messages.forEach(r=>{let o={timestamp:new Date().getTime(),message:JSON.stringify({data:xe(oe(r)),severity:e.level,source:e.logSource,environment:this.environment,requestId:e.requestId,environmentType:this.environmentType,rayId:e.rayId===null?void 0:e.rayId})};this.batcher.enqueue(o)}),n.waitUntil(this.batcher.waitUntilFlushed())}};var to=new WeakMap,gl={tags:[]},Rn=class extends Ae{constructor(n){super();this.options=n}static{s(this,"DataDogMetricsPlugin")}getTransport(){return new no(this.options)}static setContext(n,r){let o=to.get(n);o||(o=gl);let i=Object.assign({...o},r);to.set(n,i)}},no=class{static{s(this,"DataDogMetricsTransport")}#e;#t;#n;#r;#o;#i=void 0;constructor(e){this.#e=e.apiKey,this.#t=e.url??"https://api.datadoghq.com/api/v2/series",this.#n=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},e.metrics),this.#o=e.include??{},this.#r=e.tags??[]}pushMetrics(e,n){this.#i===void 0&&(this.#i=new B("data-dog-metrics-transport",10,this.dispatchFunction,F.getLogger(n)));let r=Math.floor(e.timestamp.getTime()/1e3),o=this.#r.concat(to.get(n)?.tags??[]);if(this.#o.country&&o.push(`country:${e.country}`),this.#o.httpMethod&&o.push(`httpMethod:${e.method}`),this.#o.statusCode&&o.push(`statusCode:${e.statusCode}`),this.#o.path){let i=e.systemRouteName||e.routePath;o.push(`path:${i}`)}this.#n.latency&&this.#i.enqueue({metric:"zuplo.request.latency",type:3,points:[{timestamp:r,value:e.durationMs}],tags:o}),this.#n.requestContentLength&&e.requestContentLength&&this.#i.enqueue({metric:"zuplo.request.content_length",type:3,points:[{timestamp:r,value:e.requestContentLength}],tags:o}),this.#n.responseContentLength&&e.responseContentLength&&this.#i.enqueue({metric:"zuplo.response.content_length",type:3,points:[{timestamp:r,value:e.responseContentLength}],tags:o}),n.waitUntil(this.#i.waitUntilFlushed())}dispatchFunction=async e=>{if(e.length===0)return;let n=JSON.stringify({series:e}),r=await fetch(this.#t,{method:"POST",body:n,headers:{"content-type":"application/json","DD-API-KEY":this.#e}});if(!r.ok)throw new ro(await r.text())}},ro=class t extends Error{static{s(this,"DataDogMetricsError")}constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};var oo=new WeakMap,ml={dimensions:[]},Pn=class extends Ae{constructor(n){super();this.options=n}static{s(this,"DynatraceMetricsPlugin")}getTransport(){return new io(this.options)}static setContext(n,r){let o=oo.get(n);o||(o=ml);let i=Object.assign({...o},r);oo.set(n,i)}},io=class{static{s(this,"DynaTraceMetricsTransport")}apiToken;#e;#t;dimensions;#n;#r=void 0;constructor(e){this.apiToken=e.apiToken,this.#e=e.url,this.#t=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},e.metrics),this.#n=e.include??{},this.dimensions=e.dimensions??[]}pushMetrics(e,n){this.#r===void 0&&(this.#r=new B("dynatrace-metrics-transport",10,this.dispatchFunction,F.getLogger(n)));let r=Math.floor(e.timestamp.getTime()),o=this.dimensions.concat(oo.get(n)?.dimensions??[]);if(this.#n.country&&o.push(`country="${e.country}"`),this.#n.httpMethod&&o.push(`http_method="${e.method}"`),this.#n.statusCode&&o.push(`status_code="${e.statusCode}"`),this.#n.path){let a=e.systemRouteName||e.routePath;o.push(`path="${a}"`)}let i=o.join(",");this.#t.latency&&this.#r.enqueue(`zuplo.request.latency,${i} ${e.durationMs} ${r}`),this.#t.requestContentLength&&e.requestContentLength&&this.#r.enqueue(`zuplo.request.content_length,${i} ${e.requestContentLength} ${r}`),this.#t.responseContentLength&&e.responseContentLength&&this.#r.enqueue(`zuplo.response.content_length,${i} ${e.responseContentLength} ${r}`),n.waitUntil(this.#r.waitUntilFlushed())}dispatchFunction=async e=>{if(e.length===0)return;let n=e.join(`
67
+ `),r=new Headers({"content-type":"application/json; charset=utf-8"});this.#i&&r.set("X-Sumo-Name",this.#i),this.#o&&r.set("X-Sumo-Category",this.#o),await fetch(this.#e,{method:"POST",body:n,headers:r})};batcher=new B("sumo-logic-log-transport",10,this.#s)};var pl="d3a5b78f823648f5b1df4fe269d41172",bn=class extends K{constructor(n){super();this.options=n}static{s(this,"VMWareLogInsightLoggingPlugin")}getTransport(){return new Xr(this.options)}},Xr=class{static{s(this,"VMWareLogInsightTransport")}constructor(e){if(!URL.canParse(e.url))throw new y(`VMWareLogInsightTransport - The option 'url' must be a valid URL. The value provided '${e.url}' could not be parsed.`);let n;try{n=new URL(e.url),n.pathname==="/"&&(n.pathname=`/api/v1/events/ingest/${e.agentId??pl}`)}catch{throw new y(`Invalid option 'url' on 'VMWareLogInsightTransport' plugin. Must be a valid URL, received '${e.url}'`)}this.#e=n.toString(),this.#r=x.instance.loggingEnvironmentType,this.#o=x.instance.loggingEnvironmentStage,this.#n=x.instance.deploymentName,this.#i=e.onMessageSending,this.#t=e.textReplacements,e.fields&&(this.#s=Object.entries(e.fields).map(([r,o])=>({name:r,content:o})))}#e;#t;#n;#r;#o;#i;#s;log(e,n){let r=this.buildEntry(e,n);this.batcher.enqueue(r),n.waitUntil(this.batcher.waitUntilFlushed())}buildEntry(e,n){let r=Zi(e.messages);this.#t?.forEach(i=>{r=r.replaceAll(i[0],i[1])});let o={timestamp:Date.now(),text:r,fields:[{name:"severity",content:e.level.toUpperCase()},{name:"request_id",content:e.requestId},{name:"environment_type",content:this.#r},{name:"environment_stage",content:this.#o},{name:"log_source",content:e.logSource},{name:"atomic_counter",content:e.vectorClock}]};return e.rayId&&o.fields.push({name:"request_ray_id",content:e.rayId}),this.#n&&o.fields.push({name:"environment",content:this.#n}),this.#s&&o.fields.push(...this.#s),n.custom&&Object.entries(n.custom).forEach(([i,a])=>{let u=_r(a);u&&o.fields.push({name:i,content:u})}),this.#i&&(o=this.#i(o)),o}#a=async e=>{if(e.length===0)return;let n=await fetch(this.#e,{method:"POST",body:JSON.stringify({events:e}),headers:{"content-type":"application/json; charset=utf-8"}});if(n.status!==200)try{let r=await n.text();console.error("Error logging to Log Insight",r)}catch(r){console.error(r)}};batcher=new B("vmware-log-insights-log-transport",10,this.#a)};var wn=class extends K{constructor(n){super();this.options=n}static{s(this,"AWSLoggingPlugin")}getTransport(){return new eo(this.options)}},eo=class{static{s(this,"AWSLogTransport")}awsClient;environment;environmentType;logGroupName;logStreamName;region;batcher=new B("aws-log-transport",10,async e=>{if(e.length===0)return;let n=JSON.stringify({logGroupName:this.logGroupName,logStreamName:this.logStreamName,logEvents:e});await this.awsClient.fetch(`https://logs.${this.region}.amazonaws.com`,{headers:{"Content-Type":"application/x-amz-json-1.1","x-amz-Target":"Logs_20140328.PutLogEvents"},body:n,aws:{accessKeyId:this.awsClient.accessKeyId,secretAccessKey:this.awsClient.secretAccessKey,service:this.awsClient.service,region:this.awsClient.region}})});constructor({accessKeyId:e,logStreamName:n,logGroupName:r,secretAccessKey:o,region:i}){this.awsClient=new Xe({accessKeyId:e,secretAccessKey:o,service:"logs",region:i}),this.logGroupName=r,this.logStreamName=n,this.region=i,this.environmentType=x.instance.loggingEnvironmentType,this.environment=x.instance.deploymentName}log(e,n){e.messages.forEach(r=>{let o={timestamp:new Date().getTime(),message:JSON.stringify({data:xe(oe(r)),severity:e.level,source:e.logSource,environment:this.environment,requestId:e.requestId,environmentType:this.environmentType,rayId:e.rayId===null?void 0:e.rayId})};this.batcher.enqueue(o)}),n.waitUntil(this.batcher.waitUntilFlushed())}};var to=new WeakMap,gl={tags:[]},Rn=class extends Ae{constructor(n){super();this.options=n}static{s(this,"DataDogMetricsPlugin")}getTransport(){return new no(this.options)}static setContext(n,r){let o=to.get(n);o||(o=gl);let i=Object.assign({...o},r);to.set(n,i)}},no=class{static{s(this,"DataDogMetricsTransport")}#e;#t;#n;#r;#o;#i=void 0;constructor(e){this.#e=e.apiKey,this.#t=e.url??"https://api.datadoghq.com/api/v2/series",this.#n=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},e.metrics),this.#o=e.include??{},this.#r=e.tags??[]}pushMetrics(e,n){this.#i===void 0&&(this.#i=new B("data-dog-metrics-transport",10,this.dispatchFunction,F.getLogger(n)));let r=Math.floor(e.timestamp.getTime()/1e3),o=this.#r.concat(to.get(n)?.tags??[]);if(this.#o.country&&o.push(`country:${e.country}`),this.#o.httpMethod&&o.push(`httpMethod:${e.method}`),this.#o.statusCode&&o.push(`statusCode:${e.statusCode}`),this.#o.path){let i=e.systemRouteName||e.routePath;o.push(`path:${i}`)}this.#n.latency&&this.#i.enqueue({metric:"zuplo.request.latency",type:3,points:[{timestamp:r,value:e.durationMs}],tags:o}),this.#n.requestContentLength&&e.requestContentLength&&this.#i.enqueue({metric:"zuplo.request.content_length",type:3,points:[{timestamp:r,value:e.requestContentLength}],tags:o}),this.#n.responseContentLength&&e.responseContentLength&&this.#i.enqueue({metric:"zuplo.response.content_length",type:3,points:[{timestamp:r,value:e.responseContentLength}],tags:o}),n.waitUntil(this.#i.waitUntilFlushed())}dispatchFunction=async e=>{if(e.length===0)return;let n=JSON.stringify({series:e}),r=await fetch(this.#t,{method:"POST",body:n,headers:{"content-type":"application/json","DD-API-KEY":this.#e}});if(!r.ok)throw new ro(await r.text())}},ro=class t extends Error{static{s(this,"DataDogMetricsError")}constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};var oo=new WeakMap,ml={dimensions:[]},Pn=class extends Ae{constructor(n){super();this.options=n}static{s(this,"DynatraceMetricsPlugin")}getTransport(){return new io(this.options)}static setContext(n,r){let o=oo.get(n);o||(o=ml);let i=Object.assign({...o},r);oo.set(n,i)}},io=class{static{s(this,"DynaTraceMetricsTransport")}apiToken;#e;#t;dimensions;#n;#r=void 0;constructor(e){this.apiToken=e.apiToken,this.#e=e.url,this.#t=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},e.metrics),this.#n=e.include??{},this.dimensions=e.dimensions??[]}pushMetrics(e,n){this.#r===void 0&&(this.#r=new B("dynatrace-metrics-transport",10,this.dispatchFunction,F.getLogger(n)));let r=Math.floor(e.timestamp.getTime()),o=this.dimensions.concat(oo.get(n)?.dimensions??[]);if(this.#n.country&&o.push(`country="${e.country}"`),this.#n.httpMethod&&o.push(`http_method="${e.method}"`),this.#n.statusCode&&o.push(`status_code="${e.statusCode}"`),this.#n.path){let a=e.systemRouteName||e.routePath;o.push(`path="${a}"`)}let i=o.join(",");this.#t.latency&&this.#r.enqueue(`zuplo.request.latency,${i} ${e.durationMs} ${r}`),this.#t.requestContentLength&&e.requestContentLength&&this.#r.enqueue(`zuplo.request.content_length,${i} ${e.requestContentLength} ${r}`),this.#t.responseContentLength&&e.responseContentLength&&this.#r.enqueue(`zuplo.response.content_length,${i} ${e.responseContentLength} ${r}`),n.waitUntil(this.#r.waitUntilFlushed())}dispatchFunction=async e=>{if(e.length===0)return;let n=e.join(`
68
68
  `),r=await fetch(this.#e,{method:"POST",body:n,headers:{"content-type":"text/plain",Authorization:`Api-Token ${this.apiToken}`}});if(!r.ok)throw new so(await r.text())}},so=class t extends Error{static{s(this,"DynaTraceMetricsError")}constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};var En=class{static{s(this,"AuditLogDataStaxProvider")}constructor(e){this.#e=e}#e;writeLogBatch=async e=>{await Promise.allSettled(e.map(async n=>{await fetch(this.#e.url,{method:"POST",headers:{"X-Cassandra-Token":this.#e.xCassandraToken,"content-type":"application/json"},body:JSON.stringify(n)})}))}};var In=class extends Ee{static{s(this,"AuditLogPlugin")}constructor(e,n){super(),this.#e=e,this.#t=n}#e;#t;async initialize(e){new ao(e,this.#e,this.#t)}},Rs=s(t=>{let e={};return t.forEach((n,r)=>{e[r]=n}),e},"serializableHeaders"),fl={requestFilter:async()=>!0,include:{request:{headers:!0,body:!0},response:{headers:!0,body:!0}}},ao=class{static{s(this,"AuditPluginImpl")}constructor(e,n,r){this.#t=n;let o={...fl};r?.requestFilter&&(o.requestFilter=r.requestFilter),r?.include?.request&&Object.assign(o,r.include.request),r?.include?.response&&Object.assign(o,r.include.response),this.#e=o,e.addRequestHook(this.#i),this.#n=new B("audit-log",10,this.#r)}#e;#t;#n;#r=async e=>{await this.#t.writeLogBatch(e)};#o=async(e,n,r,o,i,a)=>{try{let u={timestamp:o,durationMs:i,routePath:r.route.path,requestId:r.requestId,userSub:a,request:{url:n.url,method:n.method,headers:this.#e.include?.request?.headers?Rs(n.headers):void 0,body:this.#e.include?.request?.body?await n.text():void 0},response:{status:e.status,statusText:e.statusText,headers:this.#e.include?.response?.headers?Rs(e.headers):void 0,body:this.#e.include?.response?.body?await e.text():void 0}};this.#n.enqueue(u),r.waitUntil(this.#n.waitUntilFlushed())}catch(u){r.log.error(u)}};#i=async(e,n)=>{try{if(!await this.#e.requestFilter(e,n))return e;let o=new Date,i=Date.now(),a=e.clone();return n.addResponseSendingFinalHook(async(u,c)=>{let l=Date.now(),p=u.clone(),d=this.#o(p,a,n,o,l-i,c.user?.sub).catch(g=>{n.log.error(g)});n.waitUntil(d)}),e}catch(r){return n.log.error(r),e}}};var uo=class extends Error{static{s(this,"StripeError")}message;type;raw;rawType;headers;requestId;code;doc_url;param;detail;statusCode;charge;decline_code;payment_method_type;payment_intent;payment_method;setup_intent;source;constructor(e={}){super(e.message),this.type=this.constructor.name,this.raw=e,this.rawType=e.type,this.code=e.code,this.doc_url=e.doc_url,this.param=e.param,this.detail=e.detail,this.headers=e.headers,this.requestId=e.requestId,this.statusCode=e.statusCode,this.message=e.message,this.charge=e.charge,this.decline_code=e.decline_code,this.payment_intent=e.payment_intent,this.payment_method=e.payment_method,this.payment_method_type=e.payment_method_type,this.setup_intent=e.setup_intent,this.source=e.source}},Pe=class extends uo{static{s(this,"StripeSignatureVerificationError")}header;payload;constructor(e,n,r={}){super(r),this.header=e,this.payload=n}};var hl="v1",yl=300;async function Ps(t,e,n,r=yl,o){return await wl(t,e,n,r,o),t instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(t)):JSON.parse(t)}s(Ps,"constructEventAsync");function bl(t,e){return`${e.timestamp}.${t}`}s(bl,"makeHMACContent");async function wl(t,e,n,r,o){let{decodedHeader:i,decodedPayload:a,details:u,suspectPayloadType:c}=Rl(t,e,hl),l=/\s/.test(n),p=await xl(bl(a,u),n);return Pl(a,i,u,p,r,c,l,o)}s(wl,"verifyHeaderAsync");function Rl(t,e,n){if(!t)throw new Pe(e,t,{message:"No webhook payload was provided."});let r=typeof t!="string"&&!(t instanceof Uint8Array),o=new TextDecoder("utf8"),i=t instanceof Uint8Array?o.decode(t):t;if(Array.isArray(e))throw new Error("Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.");if(e==null||e=="")throw new Pe(e,t,{message:"No stripe-signature header value was provided."});let a=e instanceof Uint8Array?o.decode(e):e,u=El(a,n);if(!u||u.timestamp===-1)throw new Pe(a,i,{message:"Unable to extract timestamp and signatures from header"});if(!u.signatures.length)throw new Pe(a,i,{message:"No signatures found with expected scheme"});return{decodedPayload:i,decodedHeader:a,details:u,suspectPayloadType:r}}s(Rl,"parseEventDetails");function Pl(t,e,n,r,o,i,a,u){let c=!!n.signatures.filter(g=>Il(g,r)).length,l=`
69
69
  Learn more about webhook signing and explore webhook integration examples for various frameworks at https://github.com/stripe/stripe-node#webhook-signing`,p=a?`
70
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
- "version": "5.1817.0",
3
+ "version": "5.1819.0",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "exports": {