@zuplo/runtime 6.70.50 → 6.70.51

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.
@@ -22,5 +22,5 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{f as v,i as u}from"./chunk-GK7ZF3JA.js";import{Gc as y,Hc as x,S as r,T as j,ec as h,fc as k,gc as l,jb as m,jc as b,kc as f}from"./chunk-OATPYDFL.js";import"./chunk-JRXZBVXH.js";import"./chunk-4SACVMDH.js";import{a}from"./chunk-ZIKV2LUM.js";j();import{createRemoteJWKSet as C,errors as d,jwtVerify as T}from"jose";var I=r.object({id_token:r.string().min(1),token_type:r.string().min(1).optional(),expires_in:r.number().optional(),access_token:r.string().min(1).optional(),refresh_token:r.string().min(1).optional(),scope:r.string().min(1).optional()}),U=r.object({error:r.string().min(1).optional(),error_description:r.string().min(1).optional(),error_uri:r.string().min(1).optional()});function J(e){let t=U.safeParse(e);if(!t.success)return{};let n={};return t.data.error!==void 0&&(n.idpError=t.data.error),t.data.error_description!==void 0&&(n.idpErrorDescription=t.data.error_description.slice(0,256)),t.data.error_uri!==void 0&&(n.idpErrorUri=t.data.error_uri.slice(0,256)),n}a(J,"readIdpErrorFields");function M(e){return e instanceof d.JWTExpired?"expired":e instanceof d.JWTClaimValidationFailed?"claim":e instanceof d.JWSSignatureVerificationFailed?"signature":e instanceof d.JWKSNoMatchingKey?"jwks_no_match":e instanceof d.JWTInvalid?"invalid":e instanceof r.ZodError?"schema":"other"}a(M,"readJwtFailureKind");var P=r.object({sub:y,nonce:r.string().min(1)}).catchall(r.unknown()),p;function q(e){return e instanceof Error&&"cause"in e?e.cause:e}a(q,"readErrorCause");function H(e){if(e!==null&&typeof e=="object"&&"extensionMembers"in e)return e.extensionMembers?.gatewayCode}a(H,"readRuntimeGatewayCode");function L(){if(!p){let e=m();p=C(new URL(e.oidc.jwksUrl),{timeoutDuration:e.browserLogin.remoteTimeoutMs})}return p}a(L,"readFederatedJwks");async function Z(e){let t=m(),n=u("tokenUrl"),w=u("clientId"),E=u("clientSecret"),F=new URL("/oauth/callback",h(e.requestUrl,e.requestHeaders)).toString(),R=new URLSearchParams({grant_type:"authorization_code",code:e.code,redirect_uri:F,client_id:w,client_secret:E});try{let{response:i,json:s}=await v(n,{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:R},{maxResponseBytes:32768,problemCode:"browser_login_verification_failed",timeoutMs:t.browserLogin.remoteTimeoutMs,...e.context===void 0?{}:{context:e.context}});if(!i.ok){let o=J(s);throw e.context?.log.warn({event:"federated_token_exchange_failed",code:"provider_access_denied",idpHost:l(n),idpStatus:i.status,...o},"Federated browser login token exchange returned non-2xx from the identity provider"),f({code:"provider_access_denied",privateDetail:"Federated browser login token exchange failed.",cause:new Error(`IdP token exchange failed (status=${i.status}${o.idpError?` idp_error=${o.idpError}`:""}${o.idpErrorDescription?` idp_error_description=${o.idpErrorDescription}`:""})`)})}let S=I.parse(s),c;try{({payload:c}=await T(S.id_token,L(),{issuer:t.oidc.issuer,audience:w}))}catch(o){let _={};throw k(_,"error",o),e.context?.log.warn({event:"federated_id_token_verification_failed",code:"browser_login_verification_failed",failureKind:M(o),idpHost:l(n),expectedIssuer:t.oidc.issuer,..._},"Federated id_token failed jose verification"),o}if(c.nonce!==e.nonce)throw e.context?.log.warn({event:"federated_nonce_mismatch",code:"oauth_callback_mismatch",idpHost:l(n),nonceMissingFromIdToken:c.nonce===void 0},"Federated id_token nonce did not match the signed gateway state"),f("oauth_callback_mismatch","Federated browser login nonce did not match the signed gateway state.");let g=P.parse(c);return x({sub:g.sub,data:g},e.requestUrl)}catch(i){let s=b(i)??H(i);throw s!==void 0&&s!=="browser_login_verification_failed"?i:f("browser_login_verification_failed","Federated browser login callback could not be verified.",q(i))}}a(Z,"exchangeFederatedAuthorizationCode");export{Z as exchangeFederatedAuthorizationCode};
26
- //# sourceMappingURL=browser-login-idp-NPHGGA54.js.map
25
+ import{f as v,i as u}from"./chunk-WASXKKBJ.js";import{Gc as y,Hc as x,S as r,T as j,ec as h,fc as k,gc as l,jb as m,jc as b,kc as f}from"./chunk-ORBTGJIA.js";import"./chunk-JRXZBVXH.js";import"./chunk-4SACVMDH.js";import{a}from"./chunk-ZIKV2LUM.js";j();import{createRemoteJWKSet as C,errors as d,jwtVerify as T}from"jose";var I=r.object({id_token:r.string().min(1),token_type:r.string().min(1).optional(),expires_in:r.number().optional(),access_token:r.string().min(1).optional(),refresh_token:r.string().min(1).optional(),scope:r.string().min(1).optional()}),U=r.object({error:r.string().min(1).optional(),error_description:r.string().min(1).optional(),error_uri:r.string().min(1).optional()});function J(e){let t=U.safeParse(e);if(!t.success)return{};let n={};return t.data.error!==void 0&&(n.idpError=t.data.error),t.data.error_description!==void 0&&(n.idpErrorDescription=t.data.error_description.slice(0,256)),t.data.error_uri!==void 0&&(n.idpErrorUri=t.data.error_uri.slice(0,256)),n}a(J,"readIdpErrorFields");function M(e){return e instanceof d.JWTExpired?"expired":e instanceof d.JWTClaimValidationFailed?"claim":e instanceof d.JWSSignatureVerificationFailed?"signature":e instanceof d.JWKSNoMatchingKey?"jwks_no_match":e instanceof d.JWTInvalid?"invalid":e instanceof r.ZodError?"schema":"other"}a(M,"readJwtFailureKind");var P=r.object({sub:y,nonce:r.string().min(1)}).catchall(r.unknown()),p;function q(e){return e instanceof Error&&"cause"in e?e.cause:e}a(q,"readErrorCause");function H(e){if(e!==null&&typeof e=="object"&&"extensionMembers"in e)return e.extensionMembers?.gatewayCode}a(H,"readRuntimeGatewayCode");function L(){if(!p){let e=m();p=C(new URL(e.oidc.jwksUrl),{timeoutDuration:e.browserLogin.remoteTimeoutMs})}return p}a(L,"readFederatedJwks");async function Z(e){let t=m(),n=u("tokenUrl"),w=u("clientId"),E=u("clientSecret"),F=new URL("/oauth/callback",h(e.requestUrl,e.requestHeaders)).toString(),R=new URLSearchParams({grant_type:"authorization_code",code:e.code,redirect_uri:F,client_id:w,client_secret:E});try{let{response:i,json:s}=await v(n,{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:R},{maxResponseBytes:32768,problemCode:"browser_login_verification_failed",timeoutMs:t.browserLogin.remoteTimeoutMs,...e.context===void 0?{}:{context:e.context}});if(!i.ok){let o=J(s);throw e.context?.log.warn({event:"federated_token_exchange_failed",code:"provider_access_denied",idpHost:l(n),idpStatus:i.status,...o},"Federated browser login token exchange returned non-2xx from the identity provider"),f({code:"provider_access_denied",privateDetail:"Federated browser login token exchange failed.",cause:new Error(`IdP token exchange failed (status=${i.status}${o.idpError?` idp_error=${o.idpError}`:""}${o.idpErrorDescription?` idp_error_description=${o.idpErrorDescription}`:""})`)})}let S=I.parse(s),c;try{({payload:c}=await T(S.id_token,L(),{issuer:t.oidc.issuer,audience:w}))}catch(o){let _={};throw k(_,"error",o),e.context?.log.warn({event:"federated_id_token_verification_failed",code:"browser_login_verification_failed",failureKind:M(o),idpHost:l(n),expectedIssuer:t.oidc.issuer,..._},"Federated id_token failed jose verification"),o}if(c.nonce!==e.nonce)throw e.context?.log.warn({event:"federated_nonce_mismatch",code:"oauth_callback_mismatch",idpHost:l(n),nonceMissingFromIdToken:c.nonce===void 0},"Federated id_token nonce did not match the signed gateway state"),f("oauth_callback_mismatch","Federated browser login nonce did not match the signed gateway state.");let g=P.parse(c);return x({sub:g.sub,data:g},e.requestUrl)}catch(i){let s=b(i)??H(i);throw s!==void 0&&s!=="browser_login_verification_failed"?i:f("browser_login_verification_failed","Federated browser login callback could not be verified.",q(i))}}a(Z,"exchangeFederatedAuthorizationCode");export{Z as exchangeFederatedAuthorizationCode};
26
+ //# sourceMappingURL=browser-login-idp-QZEGTRKY.js.map
@@ -318,5 +318,5 @@ Signature verification is impossible without access to the original signed mater
318
318
  `);let b=new h("!xml"),C=b,_="",$="";this.entityExpansionCount=0,this.currentExpandedLength=0;let A=new v(this.options.processEntities);for(let j=0;j<g.length;j++)if(g[j]==="<")if(g[j+1]==="/"){let H=qt(g,">",j,"Closing Tag is not closed."),q=g.substring(j+2,H).trim();if(this.options.removeNSPrefix){let St=q.indexOf(":");St!==-1&&(q=q.substr(St+1))}this.options.transformTagName&&(q=this.options.transformTagName(q)),C&&(_=this.saveTextToParentTag(_,C,$));let _e=$.substring($.lastIndexOf(".")+1);if(q&&this.options.unpairedTags.indexOf(q)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${q}>`);let pe=0;_e&&this.options.unpairedTags.indexOf(_e)!==-1?(pe=$.lastIndexOf(".",$.lastIndexOf(".")-1),this.tagsNodeStack.pop()):pe=$.lastIndexOf("."),$=$.substring(0,pe),C=this.tagsNodeStack.pop(),_="",j=H}else if(g[j+1]==="?"){let H=Dr(g,j,!1,"?>");if(!H)throw new Error("Pi Tag is not closed.");if(_=this.saveTextToParentTag(_,C,$),!(this.options.ignoreDeclaration&&H.tagName==="?xml"||this.options.ignorePiTags)){let q=new h(H.tagName);q.add(this.options.textNodeName,""),H.tagName!==H.tagExp&&H.attrExpPresent&&(q[":@"]=this.buildAttributesMap(H.tagExp,$,H.tagName)),this.addChild(C,q,$,j)}j=H.closeIndex+1}else if(g.substr(j+1,3)==="!--"){let H=qt(g,"-->",j+4,"Comment is not closed.");if(this.options.commentPropName){let q=g.substring(j+4,H-2);_=this.saveTextToParentTag(_,C,$),C.add(this.options.commentPropName,[{[this.options.textNodeName]:q}])}j=H}else if(g.substr(j+1,2)==="!D"){let H=A.readDocType(g,j);this.docTypeEntities=H.entities,j=H.i}else if(g.substr(j+1,2)==="!["){let H=qt(g,"]]>",j,"CDATA is not closed.")-2,q=g.substring(j+9,H);_=this.saveTextToParentTag(_,C,$);let _e=this.parseTextData(q,C.tagname,$,!0,!1,!0,!0);_e==null&&(_e=""),this.options.cdataPropName?C.add(this.options.cdataPropName,[{[this.options.textNodeName]:q}]):C.add(this.options.textNodeName,_e),j=H+2}else{let H=Dr(g,j,this.options.removeNSPrefix),q=H.tagName,_e=H.rawTagName,pe=H.tagExp,St=H.attrExpPresent,Ub=H.closeIndex;if(this.options.transformTagName){let xt=this.options.transformTagName(q);pe===q&&(pe=xt),q=xt}C&&_&&C.tagname!=="!xml"&&(_=this.saveTextToParentTag(_,C,$,!1));let Nb=C;Nb&&this.options.unpairedTags.indexOf(Nb.tagname)!==-1&&(C=this.tagsNodeStack.pop(),$=$.substring(0,$.lastIndexOf("."))),q!==b.tagname&&($+=$?"."+q:q);let Pu=j;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,$,q)){let xt="";if(pe.length>0&&pe.lastIndexOf("/")===pe.length-1)q[q.length-1]==="/"?(q=q.substr(0,q.length-1),$=$.substr(0,$.length-1),pe=q):pe=pe.substr(0,pe.length-1),j=H.closeIndex;else if(this.options.unpairedTags.indexOf(q)!==-1)j=H.closeIndex;else{let Cu=this.readStopNodeData(g,_e,Ub+1);if(!Cu)throw new Error(`Unexpected end of ${_e}`);j=Cu.i,xt=Cu.tagContent}let An=new h(q);q!==pe&&St&&(An[":@"]=this.buildAttributesMap(pe,$,q)),xt&&(xt=this.parseTextData(xt,q,$,!0,St,!0,!0)),$=$.substr(0,$.lastIndexOf(".")),An.add(this.options.textNodeName,xt),this.addChild(C,An,$,Pu)}else{if(pe.length>0&&pe.lastIndexOf("/")===pe.length-1){if(q[q.length-1]==="/"?(q=q.substr(0,q.length-1),$=$.substr(0,$.length-1),pe=q):pe=pe.substr(0,pe.length-1),this.options.transformTagName){let An=this.options.transformTagName(q);pe===q&&(pe=An),q=An}let xt=new h(q);q!==pe&&St&&(xt[":@"]=this.buildAttributesMap(pe,$,q)),this.addChild(C,xt,$,Pu),$=$.substr(0,$.lastIndexOf("."))}else{let xt=new h(q);this.tagsNodeStack.push(C),q!==pe&&St&&(xt[":@"]=this.buildAttributesMap(pe,$,q)),this.addChild(C,xt,$,Pu),C=xt}_="",j=Ub}}else _+=g[j];return b.child},"parseXml");function Re(g,b,C,_){this.options.captureMetaData||(_=void 0);let $=this.options.updateTag(b.tagname,C,b[":@"]);$===!1||(typeof $=="string"&&(b.tagname=$),g.addChild(b,_))}s(Re,"addChild"),r(Re,"addChild");var Me=r(function(g,b,C){if(g.indexOf("&")===-1)return g;let _=this.options.processEntities;if(!_.enabled||_.allowedTags&&!_.allowedTags.includes(b)||_.tagFilter&&!_.tagFilter(b,C))return g;for(let $ in this.docTypeEntities){let A=this.docTypeEntities[$],j=g.match(A.regx);if(j){if(this.entityExpansionCount+=j.length,_.maxTotalExpansions&&this.entityExpansionCount>_.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${_.maxTotalExpansions}`);let ae=g.length;if(g=g.replace(A.regx,A.val),_.maxExpandedLength&&(this.currentExpandedLength+=g.length-ae,this.currentExpandedLength>_.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${_.maxExpandedLength}`)}}if(g.indexOf("&")===-1)return g;for(let $ in this.lastEntities){let A=this.lastEntities[$];g=g.replace(A.regex,A.val)}if(g.indexOf("&")===-1)return g;if(this.options.htmlEntities)for(let $ in this.htmlEntities){let A=this.htmlEntities[$];g=g.replace(A.regex,A.val)}return g=g.replace(this.ampEntity.regex,this.ampEntity.val),g},"replaceEntitiesValue");function Pe(g,b,C,_){return g&&(_===void 0&&(_=b.child.length===0),g=this.parseTextData(g,b.tagname,C,!1,b[":@"]?Object.keys(b[":@"]).length!==0:!1,_),g!==void 0&&g!==""&&b.add(this.options.textNodeName,g),g=""),g}s(Pe,"saveTextToParentTag"),r(Pe,"saveTextToParentTag");function bt(g,b,C,_){return!!(b&&b.has(_)||g&&g.has(C))}s(bt,"isItStopNode"),r(bt,"isItStopNode");function dr(g,b,C=">"){let _,$="";for(let A=b;A<g.length;A++){let j=g[A];if(_)j===_&&(_="");else if(j==='"'||j==="'")_=j;else if(j===C[0])if(C[1]){if(g[A+1]===C[1])return{data:$,index:A}}else return{data:$,index:A};else j===" "&&(j=" ");$+=j}}s(dr,"tagExpWithClosingIndex"),r(dr,"tagExpWithClosingIndex");function qt(g,b,C,_){let $=g.indexOf(b,C);if($===-1)throw new Error(_);return $+b.length-1}s(qt,"findClosingIndex"),r(qt,"findClosingIndex");function Dr(g,b,C,_=">"){let $=dr(g,b+1,_);if(!$)return;let A=$.data,j=$.index,ae=A.search(/\s/),H=A,q=!0;ae!==-1&&(H=A.substring(0,ae),A=A.substring(ae+1).trimStart());let _e=H;if(C){let pe=H.indexOf(":");pe!==-1&&(H=H.substr(pe+1),q=H!==$.data.substr(pe+1))}return{tagName:H,tagExp:A,closeIndex:j,attrExpPresent:q,rawTagName:_e}}s(Dr,"readTagExp"),r(Dr,"readTagExp");function On(g,b,C){let _=C,$=1;for(;C<g.length;C++)if(g[C]==="<")if(g[C+1]==="/"){let A=qt(g,">",C,`${b} is not closed`);if(g.substring(C+2,A).trim()===b&&($--,$===0))return{tagContent:g.substring(_,C),i:A};C=A}else if(g[C+1]==="?")C=qt(g,"?>",C+1,"StopNode is not closed.");else if(g.substr(C+1,3)==="!--")C=qt(g,"-->",C+3,"StopNode is not closed.");else if(g.substr(C+1,2)==="![")C=qt(g,"]]>",C,"StopNode is not closed.")-2;else{let A=Dr(g,C,">");A&&((A&&A.tagName)===b&&A.tagExp[A.tagExp.length-1]!=="/"&&$++,C=A.closeIndex)}}s(On,"readStopNodeData"),r(On,"readStopNodeData");function Ps(g,b,C){if(b&&typeof g=="string"){let _=g.trim();return _==="true"?!0:_==="false"?!1:Z(g,C)}else return f(g)?g:""}s(Ps,"parseValue"),r(Ps,"parseValue");function bu(g,b,C){let _=Number.parseInt(g,b);return _>=0&&_<=1114111?String.fromCodePoint(_):C+g+";"}s(bu,"fromCodePoint"),r(bu,"fromCodePoint");var wu=h.getMetaDataSymbol();function kb(g,b){return vu(g,b)}s(kb,"prettify"),r(kb,"prettify");function vu(g,b,C){let _,$={};for(let A=0;A<g.length;A++){let j=g[A],ae=Ob(j),H="";if(C===void 0?H=ae:H=C+"."+ae,ae===b.textNodeName)_===void 0?_=j[ae]:_+=""+j[ae];else{if(ae===void 0)continue;if(j[ae]){let q=vu(j[ae],b,H),_e=Ab(q,b);j[wu]!==void 0&&(q[wu]=j[wu]),j[":@"]?_b(q,j[":@"],H,b):Object.keys(q).length===1&&q[b.textNodeName]!==void 0&&!b.alwaysCreateTextNode?q=q[b.textNodeName]:Object.keys(q).length===0&&(b.alwaysCreateTextNode?q[b.textNodeName]="":q=""),$[ae]!==void 0&&$.hasOwnProperty(ae)?(Array.isArray($[ae])||($[ae]=[$[ae]]),$[ae].push(q)):b.isArray(ae,H,_e)?$[ae]=[q]:$[ae]=q}}}return typeof _=="string"?_.length>0&&($[b.textNodeName]=_):_!==void 0&&($[b.textNodeName]=_),$}s(vu,"compress"),r(vu,"compress");function Ob(g){let b=Object.keys(g);for(let C=0;C<b.length;C++){let _=b[C];if(_!==":@")return _}}s(Ob,"propName"),r(Ob,"propName");function _b(g,b,C,_){if(b){let $=Object.keys(b),A=$.length;for(let j=0;j<A;j++){let ae=$[j];_.isArray(ae,C+"."+ae,!0,!0)?g[ae]=[b[ae]]:g[ae]=b[ae]}}}s(_b,"assignAttributes"),r(_b,"assignAttributes");function Ab(g,b){let{textNodeName:C}=b,_=Object.keys(g).length;return!!(_===0||_===1&&(g[C]||typeof g[C]=="boolean"||g[C]===0))}s(Ab,"isLeafTag"),r(Ab,"isLeafTag");var yk={allowBooleanAttributes:!1,unpairedTags:[]};function Eb(g,b){b=Object.assign({},yk,b);let C=[],_=!1,$=!1;g[0]==="\uFEFF"&&(g=g.substr(1));for(let A=0;A<g.length;A++)if(g[A]==="<"&&g[A+1]==="?"){if(A+=2,A=Su(g,A),A.err)return A}else if(g[A]==="<"){let j=A;if(A++,g[A]==="!"){A=xu(g,A);continue}else{let ae=!1;g[A]==="/"&&(ae=!0,A++);let H="";for(;A<g.length&&g[A]!==">"&&g[A]!==" "&&g[A]!==" "&&g[A]!==`
319
319
  `&&g[A]!=="\r";A++)H+=g[A];if(H=H.trim(),H[H.length-1]==="/"&&(H=H.substring(0,H.length-1),A--),!L(H)){let pe;return H.trim().length===0?pe="Invalid space after '<'.":pe="Tag '"+H+"' is an invalid name.",Xe("InvalidTag",pe,wt(g,A))}let q=$b(g,A);if(q===!1)return Xe("InvalidAttr","Attributes for '"+H+"' have open quote.",wt(g,A));let _e=q.value;if(A=q.index,_e[_e.length-1]==="/"){let pe=A-_e.length;_e=_e.substring(0,_e.length-1);let St=Iu(_e,b);if(St===!0)_=!0;else return Xe(St.err.code,St.err.msg,wt(g,pe+St.err.line))}else if(ae)if(q.tagClosed){if(_e.trim().length>0)return Xe("InvalidTag","Closing tag '"+H+"' can't have attributes or invalid starting.",wt(g,j));if(C.length===0)return Xe("InvalidTag","Closing tag '"+H+"' has not been opened.",wt(g,j));{let pe=C.pop();if(H!==pe.tagName){let St=wt(g,pe.tagStartPos);return Xe("InvalidTag","Expected closing tag '"+pe.tagName+"' (opened in line "+St.line+", col "+St.col+") instead of closing tag '"+H+"'.",wt(g,j))}C.length==0&&($=!0)}}else return Xe("InvalidTag","Closing tag '"+H+"' doesn't have proper closing.",wt(g,A));else{let pe=Iu(_e,b);if(pe!==!0)return Xe(pe.err.code,pe.err.msg,wt(g,A-_e.length+pe.err.line));if($===!0)return Xe("InvalidXml","Multiple possible root nodes found.",wt(g,A));b.unpairedTags.indexOf(H)!==-1||C.push({tagName:H,tagStartPos:j}),_=!0}for(A++;A<g.length;A++)if(g[A]==="<")if(g[A+1]==="!"){A++,A=xu(g,A);continue}else if(g[A+1]==="?"){if(A=Su(g,++A),A.err)return A}else break;else if(g[A]==="&"){let pe=Lb(g,A);if(pe==-1)return Xe("InvalidChar","char '&' is not expected.",wt(g,A));A=pe}else if($===!0&&!Ru(g[A]))return Xe("InvalidXml","Extra text at the end",wt(g,A));g[A]==="<"&&A--}}else{if(Ru(g[A]))continue;return Xe("InvalidChar","char '"+g[A]+"' is not expected.",wt(g,A))}if(_){if(C.length==1)return Xe("InvalidTag","Unclosed tag '"+C[0].tagName+"'.",wt(g,C[0].tagStartPos));if(C.length>0)return Xe("InvalidXml","Invalid '"+JSON.stringify(C.map(A=>A.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return Xe("InvalidXml","Start tag expected.",1);return!0}s(Eb,"validate"),r(Eb,"validate");function Ru(g){return g===" "||g===" "||g===`
320
320
  `||g==="\r"}s(Ru,"isWhiteSpace"),r(Ru,"isWhiteSpace");function Su(g,b){let C=b;for(;b<g.length;b++)if(g[b]=="?"||g[b]==" "){let _=g.substr(C,b-C);if(b>5&&_==="xml")return Xe("InvalidXml","XML declaration allowed only at the start of the document.",wt(g,b));if(g[b]=="?"&&g[b+1]==">"){b++;break}else continue}return b}s(Su,"readPI"),r(Su,"readPI");function xu(g,b){if(g.length>b+5&&g[b+1]==="-"&&g[b+2]==="-"){for(b+=3;b<g.length;b++)if(g[b]==="-"&&g[b+1]==="-"&&g[b+2]===">"){b+=2;break}}else if(g.length>b+8&&g[b+1]==="D"&&g[b+2]==="O"&&g[b+3]==="C"&&g[b+4]==="T"&&g[b+5]==="Y"&&g[b+6]==="P"&&g[b+7]==="E"){let C=1;for(b+=8;b<g.length;b++)if(g[b]==="<")C++;else if(g[b]===">"&&(C--,C===0))break}else if(g.length>b+9&&g[b+1]==="["&&g[b+2]==="C"&&g[b+3]==="D"&&g[b+4]==="A"&&g[b+5]==="T"&&g[b+6]==="A"&&g[b+7]==="["){for(b+=8;b<g.length;b++)if(g[b]==="]"&&g[b+1]==="]"&&g[b+2]===">"){b+=2;break}}return b}s(xu,"readCommentAndCDATA"),r(xu,"readCommentAndCDATA");var bk='"',wk="'";function $b(g,b){let C="",_="",$=!1;for(;b<g.length;b++){if(g[b]===bk||g[b]===wk)_===""?_=g[b]:_!==g[b]||(_="");else if(g[b]===">"&&_===""){$=!0;break}C+=g[b]}return _!==""?!1:{value:C,index:b,tagClosed:$}}s($b,"readAttributeStr"),r($b,"readAttributeStr");var vk=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Iu(g,b){let C=p(g,vk),_={};for(let $=0;$<C.length;$++){if(C[$][1].length===0)return Xe("InvalidAttr","Attribute '"+C[$][2]+"' has no space in starting.",_n(C[$]));if(C[$][3]!==void 0&&C[$][4]===void 0)return Xe("InvalidAttr","Attribute '"+C[$][2]+"' is without value.",_n(C[$]));if(C[$][3]===void 0&&!b.allowBooleanAttributes)return Xe("InvalidAttr","boolean attribute '"+C[$][2]+"' is not allowed.",_n(C[$]));let A=C[$][2];if(!zb(A))return Xe("InvalidAttr","Attribute '"+A+"' is an invalid name.",_n(C[$]));if(!_.hasOwnProperty(A))_[A]=1;else return Xe("InvalidAttr","Attribute '"+A+"' is repeated.",_n(C[$]))}return!0}s(Iu,"validateAttributeString"),r(Iu,"validateAttributeString");function Mb(g,b){let C=/\d/;for(g[b]==="x"&&(b++,C=/[\da-fA-F]/);b<g.length;b++){if(g[b]===";")return b;if(!g[b].match(C))break}return-1}s(Mb,"validateNumberAmpersand"),r(Mb,"validateNumberAmpersand");function Lb(g,b){if(b++,g[b]===";")return-1;if(g[b]==="#")return b++,Mb(g,b);let C=0;for(;b<g.length;b++,C++)if(!(g[b].match(/\w/)&&C<20)){if(g[b]===";")break;return-1}return b}s(Lb,"validateAmpersand"),r(Lb,"validateAmpersand");function Xe(g,b,C){return{err:{code:g,msg:b,line:C.line||C,col:C.col}}}s(Xe,"getErrorObject"),r(Xe,"getErrorObject");function zb(g){return m(g)}s(zb,"validateAttrName"),r(zb,"validateAttrName");function L(g){return m(g)}s(L,"validateTagName"),r(L,"validateTagName");function wt(g,b){let C=g.substring(0,b).split(/\r?\n/);return{line:C.length,col:C[C.length-1].length+1}}s(wt,"getLineNumberForPosition"),r(wt,"getLineNumberForPosition");function _n(g){return g.startIndex+g[1].length}s(_n,"getPositionFromMatch"),r(_n,"getPositionFromMatch");var Rk=class{static{s(this,"XMLParser")}static{r(this,"XMLParser")}constructor(g){this.externalEntities={},this.options=i(g)}parse(g,b){if(typeof g!="string"&&g.toString)g=g.toString();else if(typeof g!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(b){b===!0&&(b={});let $=Eb(g,b);if($!==!0)throw Error(`${$.err.msg}:${$.err.line}:${$.err.col}`)}let C=new Le(this.options);C.addExternalEntities(this.externalEntities);let _=C.parseXml(g);return this.options.preserveOrder||_===void 0?_:kb(_,this.options)}addEntity(g,b){if(b.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(g.indexOf("&")!==-1||g.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(b==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[g]=b}static getMetaDataSymbol(){return h.getMetaDataSymbol()}};return new Rk(t)},"getXmlParser");var Pb=class extends qr{static{s(this,"XmlToJsonOutboundPolicy")}parser;parseOnStatusCodes;constructor(e,r){super(e,r),x("policy.outbound.xml-to-json"),ve(this.options,this.policyName).optional("removeNSPrefix","boolean").optional("ignoreProcessingInstructions","boolean").optional("ignoreDeclarations","boolean").optional("ignoreAttributes","boolean").optional("stopNodes","array").optional("attributeNamePrefix","string").optional("textNodeName","string").optional("trimValues","boolean"),this.parseOnStatusCodes=e.parseOnStatusCodes?gr(e.parseOnStatusCodes):void 0,this.parser=uk({removeNSPrefix:e?.removeNSPrefix??!0,ignorePiTags:e?.ignoreProcessingInstructions??!0,ignoreDeclaration:e?.ignoreDeclarations??!0,ignoreAttributes:e?.ignoreAttributes??!0,stopNodes:e?.stopNodes??[],attributeNamePrefix:e?.attributeNamePrefix??"@_",textNodeName:e?.textNodeName??"#text",trimValues:e?.trimValues??!0})}async handler(e,r,o){if(this.parseOnStatusCodes&&!this.parseOnStatusCodes.includes(e.status))return e;let n;try{let c=await e.text();n=this.parser.parse(c)}catch(c){let u=`XmlToJsonOutboundPolicy - Error parsing XML contents in policy '${this.policyName}'.`;throw o.log.error(u,c),new D(u)}let i=new Headers(e.headers);return i.set("content-type","application/json"),new Response(JSON.stringify(n),{status:e.status,statusText:e.statusText,headers:i})}};var Cb=class{static{s(this,"ServiceProviderImpl")}services=new Map;addService(e,r){if(this.services.get(e))throw new Se(`A service with the name ${e} already exists -- you cannot have duplicate services`);this.services.set(e,r)}getService(e){return this.services.get(e)}};var Tb=class{static{s(this,"ApiKeyConsumerClient")}bucketId;cacheDurationSeconds;cacheNamePromise;constructor(e){this.bucketId=e?.bucketId,this.cacheDurationSeconds=e?.cacheDurationSeconds??60}getCacheName(e){return this.cacheNamePromise||(this.cacheNamePromise=Oe("zuplo-get-consumer",void 0,{bucketId:e})),this.cacheNamePromise}async get(e){x("utility.get-consumer");let r=ti(),o=this.bucketId??We.ZUPLO_SERVICE_BUCKET_ID;if(!o)throw new R("ApiKeyConsumerClient - no bucketId provided and no default bucket is configured for this environment. Pass `bucketId` explicitly (find it in the Zuplo portal under Settings > API Key Buckets).");if(!o.startsWith("bckt_"))throw new R(`ApiKeyConsumerClient - bucketId "${o}" is not a valid bucket id. Bucket ids start with "bckt_" (e.g. "bckt_2HaK3odRyJle6NJSu8mzNKBC30BYxllxL"); a bucket name (e.g. "zprj-...-working-copy") is not accepted here. Find the bucket id in the Zuplo portal under Settings > API Key Buckets.`);if(!e||e.trim()==="")throw new R("ApiKeyConsumerClient.get - consumerId is required and cannot be empty");let n=await this.getCacheName(o),i=new Ce(n,r);if(this.cacheDurationSeconds>0){let d=await i.get(e);if(d)return d}let a=`/v2/key-auth/${encodeURIComponent(o)}/consumers/${encodeURIComponent(e)}`,c=await Ou(a),u={id:c.id,name:c.name,createdOn:c.createdOn,updatedOn:c.updatedOn};return c.description!==void 0&&(u.description=c.description),c.metadata!==void 0&&(u.metadata=c.metadata),this.cacheDurationSeconds>0&&i.put(e,u,this.cacheDurationSeconds),u}};var lk=10,dk=3e4,ss=class{static{s(this,"BackgroundLoader")}#e=new Map;#t;#n;#r;#o;#i={};constructor(e,r){if(typeof r=="number"){let o=r;this.#n=o*1e3,this.#o=dk,this.#r=lk}else{let o=r;this.#n=o.ttlSeconds*1e3,this.#o=o.loaderTimeoutSeconds?o.loaderTimeoutSeconds*1e3:dk,this.#r=lk}this.#t=e}#s(e){return e.expiry<=new Date}#a(e){let r=this.#i[e];return!(r===void 0||r===0)}#u(e){let r=this.#e.get(e);if(r&&!this.#s(r))return r.data}async get(e){let r=this.#u(e);if(r)return this.#l(e),r;if(this.#a(e))try{await aZ(()=>this.#u(e)!==void 0||!this.#a(e),this.#o+this.#r+1,this.#r);let o=this.#u(e);if(o)return o}catch{}return this.#c(e)}#l(e){if(!this.#a(e)){let r=this.#c(e);Hr().waitUntil(r)}}async#c(e){try{this.#i[e]===void 0&&(this.#i[e]=0),this.#i[e]++;let r=await Promise.race([this.#t(e),scheduler.wait(this.#o)]);if(r===void 0)throw new R(`BackgroundLoader: Loader timed out after ${this.#o} ms.`);return this.#e.set(e,{data:r,expiry:new Date(Date.now()+this.#n)}),r}finally{this.#i[e]--}}};async function aZ(t,e,r){let o=Date.now();for(;!t();){let n=Date.now()-o;if(n>e)throw new R(`BackgroundLoader: Timeout waiting for an on-going loader after ${n} ms.`);await scheduler.wait(r)}}s(aZ,"waitUntilTrue");import{SpanStatusCode as pk,trace as mk}from"@opentelemetry/api";var fk=s(async(t,e,r)=>{let o=Ee.instance.routeData.policies,n=Zn([t],o);if(n.length===0)throw new D(`Invalid 'invokeInboundPolicy call' - no policy '${t}' found.`);let i=n[0];return await mk.getTracer("pipeline").startActiveSpan(`policy:${i.policyName}`,async u=>{try{let d=await i.handler(e,r);if(d instanceof Request||d instanceof me||d instanceof Response)return d instanceof Response||d instanceof me?d:new me(d);{let p=new R(`Invalid state - invalid handler on policy '${i.policyName}' invoked via 'invokeInboundPolicy' on route '${r.route.path}'. The result of an inbound policy must be a Response or Request.`);throw u.setStatus({code:pk.ERROR}),u.recordException(p),p}}finally{u.end()}})},"invokeInboundPolicy"),gk=s(async(t,e,r,o)=>{let n=Ee.instance.routeData.policies,i=Jo([t],n);if(i.length===0)throw new D(`Invalid 'invokeOutboundPolicy call' - no policy '${t}' found.`);let a=i[0];return await mk.getTracer("pipeline").startActiveSpan(`policy:${a.policyName}`,async d=>{try{let p=await a.handler(e,r,o);if(p instanceof Response)return p;{let m=new R(`Invalid state - invalid handler on policy '${a.policyName}' invoked via 'invokeOutboundPolicy' on route '${o.route.path}. The result of an outbound policy must be a Response.`);throw d.setStatus({code:pk.ERROR}),d.recordException(m),m}}finally{d.end()}})},"invokeOutboundPolicy");function cZ(t){let e={};if(!t)return e;try{let r=t.split(","),o={};return r.forEach(n=>{let[i,a]=n.split("=");i&&a&&(o[i.trim()]=a.trim())}),o.asnum&&(e[Es]=o.asnum),o.zip&&(e[$s]=o.zip.split("+")[0]),o.dma&&(e[Ms]=o.dma),o.region_code&&(e[Ls]=o.region_code),o.timezone&&(e[zs]=o.timezone),o.city&&(e[Ts]=o.city),o.continent&&(e[ks]=o.continent),o.country_code&&(e[Os]=o.country_code),o.long&&(e[_s]=o.long),o.lat&&(e[As]=o.lat),e}catch{return{}}}s(cZ,"parseEdgeScapeHeader");function hk(t,e){let r=cZ(e);for(let[o,n]of Object.entries(r))t.has(o)||t.set(o,n)}s(hk,"setZpHeadersFromAkamaiEdgeScapeHeader");var la=class{static{s(this,"HeaderIncomingRequestProperties")}#e;constructor(e){this.#e=e;let r=e.get(mw);if(r){let o=new Headers(e);hk(o,r),this.#e=o}}get asn(){try{let e=this.#e.get(Es);if(typeof e=="string")return parseInt(e,10)}catch{}}get asOrganization(){return this.#e.get(cw)??void 0}get city(){return this.#e.get(Fb)??this.#e.get(Ts)??void 0}get continent(){return this.#e.get(Gb)??this.#e.get(ks)??void 0}get country(){return this.#e.get(Bb)??this.#e.get(Os)??void 0}get latitude(){return this.#e.get(Jb)??this.#e.get(As)??void 0}get longitude(){return this.#e.get(Vb)??this.#e.get(_s)??void 0}get colo(){return this.#e.get(uw)??void 0}get postalCode(){return this.#e.get(Yb)??this.#e.get($s)??void 0}get metroCode(){return this.#e.get(Qb)??this.#e.get(Ms)??void 0}get region(){return this.#e.get(Wb)??this.#e.get(lw)??void 0}get regionCode(){return this.#e.get(Kb)??this.#e.get(Ls)??void 0}get timezone(){return this.#e.get(Xb)??this.#e.get(zs)??void 0}get httpProtocol(){return this.#e.get(dw)??void 0}get clientCert(){return this.#e.get(ew)??void 0}get clientMtlsVerificationStatus(){return this.#e.get(tw)??void 0}get clientMtlsVerificationReason(){return this.#e.get(rw)??void 0}get clientCertFingerprintSha256(){return this.#e.get(nw)??void 0}get clientCertNotBefore(){return this.#e.get(ow)??void 0}get clientCertNotAfter(){return this.#e.get(iw)??void 0}get clientCertIssuerDn(){return this.#e.get(sw)??void 0}get clientCertSubjectDn(){return this.#e.get(aw)??void 0}toJSON(){return{asn:this.asn,asOrganization:this.asOrganization,city:this.city,continent:this.continent,country:this.country,latitude:this.latitude,longitude:this.longitude,colo:this.colo,postalCode:this.postalCode,metroCode:this.metroCode,region:this.region,regionCode:this.regionCode,timezone:this.timezone,httpProtocol:this.httpProtocol,clientCert:this.clientCert,clientMtlsVerificationStatus:this.clientMtlsVerificationStatus,clientMtlsVerificationReason:this.clientMtlsVerificationReason,clientCertFingerprintSha256:this.clientCertFingerprintSha256,clientCertNotBefore:this.clientCertNotBefore,clientCertNotAfter:this.clientCertNotAfter,clientCertIssuerDn:this.clientCertIssuerDn,clientCertSubjectDn:this.clientCertSubjectDn}}};function Xr(t){return{contextId:t.contextId,incomingRequestProperties:t.incomingRequestProperties,requestId:t.requestId,route:t.route,custom:t.custom,parentContext:t.parentContext,analyticsContext:t.analyticsContext}}s(Xr,"createRewriteContext");var Bo=class extends Event{static{s(this,"ResponseSendingEvent")}constructor(e,r){super("responseSending"),this.request=e,this.mutableResponse=r}request;mutableResponse},Vo=class extends Event{static{s(this,"ResponseSentEvent")}constructor(e,r){super("responseSent"),this.request=e,this.response=r}request;response},nt=class t{static{s(this,"ZuploContextExtensions")}static#e=new WeakMap;static initialize(e,r){if(!t.#e.has(e)){let o=new t(r);return t.#e.set(e,o),o}throw new Error(`ZuploContextExtensions already initialized for context with requestId '${e.requestId}'`)}static getContextExtensions(e){let r=t.#e.get(e);if(!r)throw new D(`Invalid state, could not get ZuploContext extensions for context with requestId '${e.requestId}'`);return r}latestRequest;#t;#n;#r;constructor(e){this.latestRequest=e,this.#t=[],this.#n=[],this.#r=[]}addResponseSendingHook(e){this.#n.push(e)}addResponseSendingFinalHook(e){this.#t.push(e)}addHandlerResponseHook(e){this.#r.push(e)}onResponseSendingFinal=s(async(e,r,o)=>{for(let n of this.#t)await n(e,r,o)},"onResponseSendingFinal");onResponseSending=s(async(e,r,o)=>{let n=e,i=P.instance.build.COMPATIBILITY_FLAGS.chainResponseSendingHooks;for(let a of this.#n)n=await a(i?n:e,r,o);return n},"onResponseSending");onHandlerResponse=s(async(e,r,o)=>{for(let n of this.#r)await n(e,r,o)},"onHandlerResponse")},da=class extends EventTarget{static{s(this,"SystemZuploContext")}constructor({logger:e,route:r,requestId:o,event:n,custom:i,incomingRequestProperties:a,parentContext:c}){super(),this.log=Object.freeze(e),this.route=r,this.requestId=o,this.custom=i,this.incomingRequestProperties=a,this.parentContext=c,this.#e=n,this.invokeInboundPolicy=(u,d)=>fk(u,d,this),this.contextId=crypto.randomUUID(),this.invokeOutboundPolicy=(u,d,p)=>gk(u,d,p,this),this.invokeRoute=async(u,d)=>{let p=u;typeof u=="string"&&u.startsWith("/")&&(p=new URL(u,"http://localhost"));let m=new me(p,d);return Ee.instance.handleRequest(m,this,{parentContext:this})},this.waitUntil=u=>{this.#e.waitUntil(u)},this.addResponseSendingHook=u=>{nt.getContextExtensions(this).addResponseSendingHook(u)},this.addResponseSendingFinalHook=u=>{nt.getContextExtensions(this).addResponseSendingFinalHook(u)},this.analyticsContext=new bw(o),Object.freeze(this)}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;invokeInboundPolicy;invokeOutboundPolicy;invokeRoute;waitUntil;addResponseSendingHook;addResponseSendingFinalHook;addEventListener(e,r,o){x("context.addEventListener");let n=s(i=>{try{typeof r=="function"?r(i):r.handleEvent(i)}catch(a){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),a}},"wrapped");super.addEventListener(e,n,o)}removeEventListener(e,r,o){x("context.removeEventListener"),super.removeEventListener(e,r,o)}};export{x as a,Ou as b,Do as c,Ce as d,$u as e,nn as f,jo as g,on as h,z as i,et as j,sn as k,me as l,Lu as m,zu as n,fe as o,Ot as p,Pr as q,de as r,qr as s,Hu as t,Ju as u,Un as v,Bo as w,Vo as x,he as y,vl as z,Ct as A,ZO as B,XO as C,e_ as D,Zv as E,c_ as F,Ol as G,M as H,tE as I,Ae as J,st as K,TE as L,ke as M,te as N,vt as O,le as P,BE as Q,lg as R,l as S,be as T,dM as U,mM as V,gM as W,hM as X,bM as Y,vM as Z,SM as _,CM as $,zg as aa,Ng as ba,jg as ca,Hg as da,Gg as ea,Vg as fa,Wg as ga,Qg as ha,eh as ia,nh as ja,sh as ka,uh as la,dh as ma,ph as na,rs as oa,ns as pa,os as qa,yh as ra,as as sa,vh as ta,Rh as ua,aL as va,Sh as wa,xh as xa,lL as ya,pL as za,fL as Aa,yL as Ba,bL as Ca,wL as Da,vL as Ea,_L as Fa,EL as Ga,Eh as Ha,$L as Ia,$h as Ja,zL as Ka,kt as La,FL as Ma,Nh as Na,Dh as Oa,BL as Pa,Zh as Qa,nz as Ra,oz as Sa,iz as Ta,sz as Ua,az as Va,cz as Wa,gz as Xa,Kh as Ya,Iz as Za,Pz as _a,Cz as $a,kz as ab,Oz as bb,Ez as cb,$z as db,Lz as eb,zz as fb,kI as gb,tn as hb,Je as ib,LI as jb,Ze as kb,Yh as lb,Xh as mb,ey as nb,ty as ob,ry as pb,ny as qb,oy as rb,sy as sb,ay as tb,cy as ub,uy as vb,xU as wb,PU as xb,lle as yb,sr as zb,fle as Ab,gle as Bb,hle as Cb,yle as Db,ms as Eb,ble as Fb,xn as Gb,ly as Hb,xle as Ib,Jt as Jb,Wt as Kb,ar as Lb,yP as Mb,Yc as Nb,$U as Ob,Kc as Pb,RP as Qb,i0 as Rb,fy as Sb,GP as Tb,BP as Ub,Jle as Vb,JP as Wb,N0 as Xb,nde as Yb,ode as Zb,WP as _b,tu as $b,ide as ac,KP as bc,ude as cc,rn as dc,ws as ec,Z0 as fc,H0 as gc,Py as hc,Pde as ic,nu as jc,vs as kc,_o as lc,Ode as mc,$de as nc,Mde as oc,Rr as pc,Nr as qc,tD as rc,rD as sc,Zde as tc,Hde as uc,Fde as vc,Gde as wc,Sr as xc,ope as yc,ipe as zc,iD as Ac,spe as Bc,sC as Cc,ype as Dc,Ay as Ec,aD as Fc,lt as Gc,hD as Hc,uC as Ic,dC as Jc,pC as Kc,mC as Lc,$y as Mc,Gpe as Nc,Bpe as Oc,Vpe as Pc,uu as Qc,My as Rc,rme as Sc,nme as Tc,ome as Uc,ime as Vc,uT as Wc,Yt as Xc,$me as Yc,dT as Zc,Mme as _c,Qy as $c,$j as ad,Uj as bd,jj as cd,rb as dd,Vj as ed,ob as fd,Xj as gd,ib as hd,ab as id,eq as jd,rq as kd,nq as ld,lb as md,ZT as nd,uq as od,lq as pd,dq as qd,pq as rd,mq as sd,fq as td,KT as ud,gq as vd,hq as wd,bq as xd,Iq as yd,Pq as zd,Cq as Ad,Tq as Bd,kq as Cd,Oq as Dd,_q as Ed,Eq as Fd,hb as Gd,Zq as Hd,Hq as Id,Gq as Jd,Jq as Kd,Is as Ld,wb as Md,Wq as Nd,Qq as Od,xb as Pd,Yq as Qd,sZ as Rd,Pb as Sd,Cb as Td,Tb as Ud,ss as Vd};
321
- /*! For license information please see chunk-OATPYDFL.js.LEGAL.txt */
322
- //# sourceMappingURL=chunk-OATPYDFL.js.map
321
+ /*! For license information please see chunk-ORBTGJIA.js.LEGAL.txt */
322
+ //# sourceMappingURL=chunk-ORBTGJIA.js.map