@php-wasm/web-service-worker
Advanced tools
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@php-wasm/scopes"),q=require("@php-wasm/universal");var R=typeof document<"u"?document.currentScript:null;const x=25e3;let v=0;function H(e,t,...o){const a=S();return e.postMessage({...t,requestId:a},...o),a}function S(){return++v}function U(e,t,o=x){return new Promise((a,s)=>{const r=i=>{i.data.type==="response"&&i.data.requestId===t&&(e.removeEventListener("message",r),clearTimeout(n),a(i.data.response))},n=setTimeout(()=>{s(new Error("Request timed out")),e.removeEventListener("message",r)},o);e.addEventListener("message",r)})}function I(e,t){return{type:"response",requestId:e,response:t}}async function A(e){let t=new URL(e.request.url);if(!d.isURLScoped(t))try{const c=new URL(e.request.referrer);t=d.setURLScope(t,d.getURLScope(c))}catch{}const o=e.request.headers.get("content-type"),a=e.request.method==="POST"?new Uint8Array(await e.request.clone().arrayBuffer()):void 0,s={};for(const c of e.request.headers.entries())s[c[0]]=c[1];let r;try{const c={method:"request",args:[{body:a,url:t.toString(),method:e.request.method,headers:{...s,Host:t.host,"User-agent":self.navigator.userAgent,"Content-type":o}}]},l=d.getURLScope(t);if(l===null)throw new Error(`The URL ${t.toString()} is not scoped. This should not happen.`);const u=await L(c,l);if(r=await U(self,u),delete r.headers["x-frame-options"],r.headers["content-security-policy"]){const f=r.headers["content-security-policy"].map(y=>C("frame-ancestors",y)).filter(y=>y.trim().length>0);f.length>0?r.headers["content-security-policy"]=f:delete r.headers["content-security-policy"]}}catch(c){throw console.error(c,{url:t.toString()}),c}if(r.httpStatusCode>=300&&r.httpStatusCode<=399&&r.headers.location){const c=d.getURLScope(t);let l=new URL(r.headers.location[0],t.toString());return c&&!d.isURLScoped(l)&&(l=d.setURLScope(l,c)),Response.redirect(l.toString(),r.httpStatusCode)}const n=[101,103,204,205,304].includes(r.httpStatusCode);let i=null;return n||(r.bodyPort?i=q.portToStream(r.bodyPort):i=r.bytes),new Response(i,{headers:r.headers,status:r.httpStatusCode})}async function L(e,t){const o=S();for(const a of await self.clients.matchAll({includeUncontrolled:!0}))a.postMessage({...e,scope:t,requestId:o});return o}async function g(e,t){let o;return["GET","HEAD"].includes(e.method)?o=void 0:"body"in t?o=t.body:!e.bodyUsed&&e.body?o=e.body:o=await e.arrayBuffer(),new Request(t.url||e.url,{body:o,method:e.method,headers:e.headers,referrer:e.referrer,referrerPolicy:e.referrerPolicy,mode:e.mode==="navigate"?"same-origin":e.mode,credentials:e.credentials,cache:e.cache,redirect:e.redirect,integrity:e.integrity,...o instanceof ReadableStream&&{duplex:"half"},...t})}let h;const O={resetStreamBodySupported(){h=void 0}};async function T(){if(h!==void 0)return h;try{const e=new ReadableStream({start(t){t.close()}});await fetch("data:,",{method:"POST",body:e,duplex:"half"}),h=!0}catch{h=!1}return h}function _(e){const t={};return e.headers.forEach((o,a)=>{t[a]=o}),t}function C(e,t){const o=/^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u,a=/[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u,s=/[\u{9}\u{A}\u{C}\u{D}\u{20}]/u;return t.split(";").filter(r=>{const n=r.replace(o,"").replace(a,""),[i]=n.split(s,1);return i.toLowerCase()!==e.toLowerCase()}).join(";")}class E extends Error{constructor(t,o,a){super(`Could not fetch ${t} – your network appears to be blocking this request (HTTP ${o}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.`),this.name="FirewallInterferenceError",this.url=t,this.status=o,this.statusText=a}}const B="X-Playground-Cors-Proxy";async function D(e,t,o,a){var l;let s=typeof e=="string"?new Request(e,t):e;const r=a?new URL(a):null;let n=r?new URL(s.url,r):new URL(s.url);if(n.hostname==="localhost"||n.hostname==="127.0.0.1"||n.hostname==="[::1]"||n.hostname==="::1")return await fetch(s);if(n.protocol==="http:"){n.protocol="https:";const u=n.toString();s=await g(s,{url:u}),n=new URL(u)}if(!o)return await fetch(s);if(r&&n.protocol===r.protocol&&n.hostname===r.hostname&&n.port===r.port&&n.pathname.startsWith(r.pathname))return await fetch(s);const c=s.clone();try{return await fetch(s)}catch{const u=new Headers(s.headers),f=((l=u.get("x-cors-proxy-allowed-request-headers"))==null?void 0:l.split(","))||[],y=f.includes("authorization")||f.includes("cookie"),w=u.get("content-type");w&&w.toLowerCase().includes("multipart/form-data")&&(u.set("x-cors-proxy-content-type",w),u.set("content-type","application/octet-stream"));let p=null;const b=s.method.toUpperCase();b!=="GET"&&b!=="HEAD"&&(await T()?p=c.body:p=await c.arrayBuffer()),p instanceof ReadableStream&&new URL(o,typeof document>"u"?require("url").pathToFileURL(__filename).href:R&&R.tagName.toUpperCase()==="SCRIPT"&&R.src||new URL("index.cjs",document.baseURI).href).protocol==="http:"&&(p=await new Response(p).arrayBuffer());const P=await g(s,{url:`${o}${s.url}`,headers:u,body:p,...y&&{credentials:"include"}}),m=await fetch(P);if(!m.headers.has(B))throw new E(s.url,m.status,m.statusText);return m}}exports.FirewallInterferenceError=E;exports.__testing=O;exports.awaitReply=U;exports.broadcastMessageExpectReply=L;exports.cloneRequest=g;exports.convertFetchEventToPHPRequest=A;exports.fetchWithCorsProxy=D;exports.getNextRequestId=S;exports.getRequestHeaders=_;exports.postMessageExpectReply=H;exports.removeContentSecurityPolicyDirective=C;exports.responseTo=I;exports.supportsReadableStreamBody=T; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@php-wasm/scopes"),H=require("@php-wasm/universal");var R=typeof document<"u"?document.currentScript:null;const q=25e3;let x=0;function v(e,t,...o){const n=g();return e.postMessage({...t,requestId:n},...o),n}function g(){return++x}function E(e,t,o=q){return new Promise((n,s)=>{const r=u=>{u.data.type==="response"&&u.data.requestId===t&&(e.removeEventListener("message",r),clearTimeout(a),n(u.data.response))},a=setTimeout(()=>{s(new Error("Request timed out")),e.removeEventListener("message",r)},o);e.addEventListener("message",r)})}function A(e,t){return{type:"response",requestId:e,response:t}}async function _(e){let t=new URL(e.request.url);if(!l.isURLScoped(t))try{const i=new URL(e.request.referrer);t=l.setURLScope(t,l.getURLScope(i))}catch{}const o=e.request.headers.get("content-type"),n=e.request.method==="POST"?new Uint8Array(await e.request.clone().arrayBuffer()):void 0,s={};for(const i of e.request.headers.entries())s[i[0]]=i[1];let r;try{const i={method:"request",args:[{body:n,url:t.toString(),method:e.request.method,headers:{...s,Host:t.host,"User-agent":self.navigator.userAgent,"Content-type":o}}]},c=l.getURLScope(t);if(c===null)throw new Error(`The URL ${t.toString()} is not scoped. This should not happen.`);const f=await b(i,c);if(r=await E(self,f),delete r.headers["x-frame-options"],r.headers["content-security-policy"]){const y=r.headers["content-security-policy"].map(d=>C("frame-ancestors",d)).filter(d=>d.trim().length>0);y.length>0?r.headers["content-security-policy"]=y:delete r.headers["content-security-policy"]}}catch(i){throw console.error(i,{url:t.toString()}),i}if(r.httpStatusCode>=300&&r.httpStatusCode<=399&&r.headers.location){const i=l.getURLScope(t);let c=new URL(r.headers.location[0],t.toString());return i&&!l.isURLScoped(c)&&(c=l.setURLScope(c,i)),Response.redirect(c.toString(),r.httpStatusCode)}const a=[101,103,204,205,304].includes(r.httpStatusCode);let u=null;return a||(r.bodyPort?u=H.portToStream(r.bodyPort):u=r.bytes),new Response(u,{headers:r.headers,status:r.httpStatusCode})}async function b(e,t){const o=g();for(const n of await self.clients.matchAll({includeUncontrolled:!0}))n.postMessage({...e,scope:t,requestId:o});return o}async function w(e,t){let o;return["GET","HEAD"].includes(e.method)?o=void 0:"body"in t?o=t.body:!e.bodyUsed&&e.body?o=e.body:o=await e.arrayBuffer(),new Request(t.url||e.url,{body:o,method:e.method,headers:e.headers,referrer:e.referrer,referrerPolicy:e.referrerPolicy,mode:e.mode==="navigate"?"same-origin":e.mode,credentials:e.credentials,cache:e.cache,redirect:e.redirect,integrity:e.integrity,...o instanceof ReadableStream&&{duplex:"half"},...t})}let h;const I={resetStreamBodySupported(){h=void 0}};async function T(){if(h!==void 0)return h;try{const e=new ReadableStream({start(t){t.close()}});await fetch("data:,",{method:"POST",body:e,duplex:"half"}),h=!0}catch{h=!1}return h}function O(e){const t={};return e.headers.forEach((o,n)=>{t[n]=o}),t}function C(e,t){const o=/^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u,n=/[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u,s=/[\u{9}\u{A}\u{C}\u{D}\u{20}]/u;return t.split(";").filter(r=>{const a=r.replace(o,"").replace(n,""),[u]=a.split(s,1);return u.toLowerCase()!==e.toLowerCase()}).join(";")}class U extends Error{constructor(t,o,n){super(`Could not fetch ${t} – your network appears to be blocking this request (HTTP ${o}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.`),this.name="FirewallInterferenceError",this.url=t,this.status=o,this.statusText=n}}const D="X-Playground-Cors-Proxy",L=new Map([["api.anthropic.com",{"anthropic-dangerous-direct-browser-access":"true"}],["api.openai.com",{}],["generativelanguage.googleapis.com",{}]]);async function B(e,t,o,n){var i;let s=typeof e=="string"?new Request(e,t):e;const r=n?new URL(n):null;let a=r?new URL(s.url,r):new URL(s.url);if(M(a))return await fetch(s);if(N(a))return s=await j(s,a),await fetch(s);if(a.protocol==="http:"){a.protocol="https:";const c=a.toString();s=await w(s,{url:c}),a=new URL(c)}if(!o)return await fetch(s);if(r&&a.protocol===r.protocol&&a.hostname===r.hostname&&a.port===r.port&&a.pathname.startsWith(r.pathname))return await fetch(s);const u=s.clone();try{return await fetch(s)}catch{const c=new Headers(s.headers),f=((i=c.get("x-cors-proxy-allowed-request-headers"))==null?void 0:i.split(","))||[],y=f.includes("authorization")||f.includes("cookie"),d=c.get("content-type");d&&d.toLowerCase().includes("multipart/form-data")&&(c.set("x-cors-proxy-content-type",d),c.set("content-type","application/octet-stream"));let p=null;const S=s.method.toUpperCase();S!=="GET"&&S!=="HEAD"&&(await T()?p=u.body:p=await u.arrayBuffer()),p instanceof ReadableStream&&new URL(o,typeof document>"u"?require("url").pathToFileURL(__filename).href:R&&R.tagName.toUpperCase()==="SCRIPT"&&R.src||new URL("index.cjs",document.baseURI).href).protocol==="http:"&&(p=await new Response(p).arrayBuffer());const P=await w(s,{url:`${o}${s.url}`,headers:c,body:p,...y&&{credentials:"include"}}),m=await fetch(P);if(!m.headers.has(D))throw new U(s.url,m.status,m.statusText);return m}}function M(e){return e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"||e.hostname==="::1"}function N(e){return e.protocol==="https:"&&L.has(e.hostname)}async function j(e,t){const o=L.get(t.hostname);if(!o)return e;const n=new Headers(e.headers);for(const[s,r]of Object.entries(o))n.has(s)||n.set(s,r);return await w(e,{headers:n})}exports.FirewallInterferenceError=U;exports.__testing=I;exports.awaitReply=E;exports.broadcastMessageExpectReply=b;exports.cloneRequest=w;exports.convertFetchEventToPHPRequest=_;exports.fetchWithCorsProxy=B;exports.getNextRequestId=g;exports.getRequestHeaders=O;exports.postMessageExpectReply=v;exports.removeContentSecurityPolicyDirective=C;exports.responseTo=A;exports.supportsReadableStreamBody=T; |
+147
-116
@@ -1,14 +0,14 @@ | ||
| import { isURLScoped as g, setURLScope as S, getURLScope as w } from "@php-wasm/scopes"; | ||
| import { isURLScoped as R, setURLScope as S, getURLScope as m } from "@php-wasm/scopes"; | ||
| import { portToStream as C } from "@php-wasm/universal"; | ||
| const L = 25e3; | ||
| let U = 0; | ||
| function D(e, t, ...o) { | ||
| const a = E(); | ||
| function M(e, t, ...r) { | ||
| const n = E(); | ||
| return e.postMessage( | ||
| { | ||
| ...t, | ||
| requestId: a | ||
| requestId: n | ||
| }, | ||
| ...o | ||
| ), a; | ||
| ...r | ||
| ), n; | ||
| } | ||
@@ -18,13 +18,13 @@ function E() { | ||
| } | ||
| function P(e, t, o = L) { | ||
| return new Promise((a, s) => { | ||
| const r = (c) => { | ||
| c.data.type === "response" && c.data.requestId === t && (e.removeEventListener("message", r), clearTimeout(n), a(c.data.response)); | ||
| }, n = setTimeout(() => { | ||
| s(new Error("Request timed out")), e.removeEventListener("message", r); | ||
| }, o); | ||
| e.addEventListener("message", r); | ||
| function H(e, t, r = L) { | ||
| return new Promise((n, s) => { | ||
| const o = (d) => { | ||
| d.data.type === "response" && d.data.requestId === t && (e.removeEventListener("message", o), clearTimeout(a), n(d.data.response)); | ||
| }, a = setTimeout(() => { | ||
| s(new Error("Request timed out")), e.removeEventListener("message", o); | ||
| }, r); | ||
| e.addEventListener("message", o); | ||
| }); | ||
| } | ||
| function v(e, t) { | ||
| function N(e, t) { | ||
| return { | ||
@@ -36,20 +36,20 @@ type: "response", | ||
| } | ||
| async function _(e) { | ||
| async function $(e) { | ||
| let t = new URL(e.request.url); | ||
| if (!g(t)) | ||
| if (!R(t)) | ||
| try { | ||
| const i = new URL(e.request.referrer); | ||
| t = S(t, w(i)); | ||
| const c = new URL(e.request.referrer); | ||
| t = S(t, m(c)); | ||
| } catch { | ||
| } | ||
| const o = e.request.headers.get("content-type"), a = e.request.method === "POST" ? new Uint8Array(await e.request.clone().arrayBuffer()) : void 0, s = {}; | ||
| for (const i of e.request.headers.entries()) | ||
| s[i[0]] = i[1]; | ||
| let r; | ||
| const r = e.request.headers.get("content-type"), n = e.request.method === "POST" ? new Uint8Array(await e.request.clone().arrayBuffer()) : void 0, s = {}; | ||
| for (const c of e.request.headers.entries()) | ||
| s[c[0]] = c[1]; | ||
| let o; | ||
| try { | ||
| const i = { | ||
| const c = { | ||
| method: "request", | ||
| args: [ | ||
| { | ||
| body: a, | ||
| body: n, | ||
| url: t.toString(), | ||
@@ -63,47 +63,47 @@ method: e.request.method, | ||
| "User-agent": self.navigator.userAgent, | ||
| "Content-type": o | ||
| "Content-type": r | ||
| } | ||
| } | ||
| ] | ||
| }, l = w(t); | ||
| if (l === null) | ||
| }, i = m(t); | ||
| if (i === null) | ||
| throw new Error( | ||
| `The URL ${t.toString()} is not scoped. This should not happen.` | ||
| ); | ||
| const u = await x(i, l); | ||
| if (r = await P(self, u), delete r.headers["x-frame-options"], r.headers["content-security-policy"]) { | ||
| const h = r.headers["content-security-policy"].map( | ||
| (f) => A( | ||
| const p = await P(c, i); | ||
| if (o = await H(self, p), delete o.headers["x-frame-options"], o.headers["content-security-policy"]) { | ||
| const f = o.headers["content-security-policy"].map( | ||
| (l) => x( | ||
| "frame-ancestors", | ||
| f | ||
| l | ||
| ) | ||
| ).filter((f) => f.trim().length > 0); | ||
| h.length > 0 ? r.headers["content-security-policy"] = h : delete r.headers["content-security-policy"]; | ||
| ).filter((l) => l.trim().length > 0); | ||
| f.length > 0 ? o.headers["content-security-policy"] = f : delete o.headers["content-security-policy"]; | ||
| } | ||
| } catch (i) { | ||
| throw console.error(i, { url: t.toString() }), i; | ||
| } catch (c) { | ||
| throw console.error(c, { url: t.toString() }), c; | ||
| } | ||
| if (r.httpStatusCode >= 300 && r.httpStatusCode <= 399 && r.headers.location) { | ||
| const i = w(t); | ||
| let l = new URL( | ||
| r.headers.location[0], | ||
| if (o.httpStatusCode >= 300 && o.httpStatusCode <= 399 && o.headers.location) { | ||
| const c = m(t); | ||
| let i = new URL( | ||
| o.headers.location[0], | ||
| t.toString() | ||
| ); | ||
| return i && !g(l) && (l = S(l, i)), Response.redirect( | ||
| l.toString(), | ||
| r.httpStatusCode | ||
| return c && !R(i) && (i = S(i, c)), Response.redirect( | ||
| i.toString(), | ||
| o.httpStatusCode | ||
| ); | ||
| } | ||
| const n = [101, 103, 204, 205, 304].includes( | ||
| r.httpStatusCode | ||
| const a = [101, 103, 204, 205, 304].includes( | ||
| o.httpStatusCode | ||
| ); | ||
| let c = null; | ||
| return n || (r.bodyPort ? c = C(r.bodyPort) : c = r.bytes), new Response(c, { | ||
| headers: r.headers, | ||
| status: r.httpStatusCode | ||
| let d = null; | ||
| return a || (o.bodyPort ? d = C(o.bodyPort) : d = o.bytes), new Response(d, { | ||
| headers: o.headers, | ||
| status: o.httpStatusCode | ||
| }); | ||
| } | ||
| async function x(e, t) { | ||
| const o = E(); | ||
| for (const a of await self.clients.matchAll({ | ||
| async function P(e, t) { | ||
| const r = E(); | ||
| for (const n of await self.clients.matchAll({ | ||
| // Sometimes the client that triggered the current fetch() | ||
@@ -115,3 +115,3 @@ // event is considered uncontrolled in Google Chrome. This | ||
| })) | ||
| a.postMessage({ | ||
| n.postMessage({ | ||
| ...e, | ||
@@ -126,10 +126,10 @@ /** | ||
| scope: t, | ||
| requestId: o | ||
| requestId: r | ||
| }); | ||
| return o; | ||
| return r; | ||
| } | ||
| async function b(e, t) { | ||
| let o; | ||
| return ["GET", "HEAD"].includes(e.method) ? o = void 0 : "body" in t ? o = t.body : !e.bodyUsed && e.body ? o = e.body : o = await e.arrayBuffer(), new Request(t.url || e.url, { | ||
| body: o, | ||
| async function w(e, t) { | ||
| let r; | ||
| return ["GET", "HEAD"].includes(e.method) ? r = void 0 : "body" in t ? r = t.body : !e.bodyUsed && e.body ? r = e.body : r = await e.arrayBuffer(), new Request(t.url || e.url, { | ||
| body: r, | ||
| method: e.method, | ||
@@ -156,15 +156,15 @@ headers: e.headers, | ||
| */ | ||
| ...o instanceof ReadableStream && { duplex: "half" }, | ||
| ...r instanceof ReadableStream && { duplex: "half" }, | ||
| ...t | ||
| }); | ||
| } | ||
| let p; | ||
| const $ = { | ||
| let h; | ||
| const j = { | ||
| resetStreamBodySupported() { | ||
| p = void 0; | ||
| h = void 0; | ||
| } | ||
| }; | ||
| async function q() { | ||
| if (p !== void 0) | ||
| return p; | ||
| async function A() { | ||
| if (h !== void 0) | ||
| return h; | ||
| try { | ||
@@ -180,18 +180,18 @@ const e = new ReadableStream({ | ||
| duplex: "half" | ||
| }), p = !0; | ||
| }), h = !0; | ||
| } catch { | ||
| p = !1; | ||
| h = !1; | ||
| } | ||
| return p; | ||
| return h; | ||
| } | ||
| function k(e) { | ||
| const t = {}; | ||
| return e.headers.forEach((o, a) => { | ||
| t[a] = o; | ||
| return e.headers.forEach((r, n) => { | ||
| t[n] = r; | ||
| }), t; | ||
| } | ||
| function A(e, t) { | ||
| const o = /^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u, a = /[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u, s = /[\u{9}\u{A}\u{C}\u{D}\u{20}]/u; | ||
| return t.split(";").filter((r) => { | ||
| const n = r.replace(o, "").replace(a, ""), [c] = n.split( | ||
| function x(e, t) { | ||
| const r = /^[\u{9}\u{A}\u{C}\u{D}\u{20}]+/u, n = /[\u{9}\u{A}\u{C}\u{D}\u{20}]+$/u, s = /[\u{9}\u{A}\u{C}\u{D}\u{20}]/u; | ||
| return t.split(";").filter((o) => { | ||
| const a = o.replace(r, "").replace(n, ""), [d] = a.split( | ||
| s, | ||
@@ -201,46 +201,60 @@ // The directive name is the first token. | ||
| ); | ||
| return c.toLowerCase() !== e.toLowerCase(); | ||
| return d.toLowerCase() !== e.toLowerCase(); | ||
| }).join(";"); | ||
| } | ||
| class H extends Error { | ||
| constructor(t, o, a) { | ||
| class O extends Error { | ||
| constructor(t, r, n) { | ||
| super( | ||
| `Could not fetch ${t} – your network appears to be blocking this request (HTTP ${o}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.` | ||
| ), this.name = "FirewallInterferenceError", this.url = t, this.status = o, this.statusText = a; | ||
| `Could not fetch ${t} – your network appears to be blocking this request (HTTP ${r}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.` | ||
| ), this.name = "FirewallInterferenceError", this.url = t, this.status = r, this.statusText = n; | ||
| } | ||
| } | ||
| const I = "X-Playground-Cors-Proxy"; | ||
| async function M(e, t, o, a) { | ||
| var l; | ||
| const q = "X-Playground-Cors-Proxy", b = /* @__PURE__ */ new Map([ | ||
| [ | ||
| "api.anthropic.com", | ||
| { | ||
| "anthropic-dangerous-direct-browser-access": "true" | ||
| } | ||
| ], | ||
| ["api.openai.com", {}], | ||
| ["generativelanguage.googleapis.com", {}] | ||
| ]); | ||
| async function W(e, t, r, n) { | ||
| var c; | ||
| let s = typeof e == "string" ? new Request(e, t) : e; | ||
| const r = a ? new URL(a) : null; | ||
| let n = r ? new URL(s.url, r) : new URL(s.url); | ||
| if (n.hostname === "localhost" || n.hostname === "127.0.0.1" || n.hostname === "[::1]" || n.hostname === "::1") | ||
| const o = n ? new URL(n) : null; | ||
| let a = o ? new URL(s.url, o) : new URL(s.url); | ||
| if (D(a)) | ||
| return await fetch(s); | ||
| if (n.protocol === "http:") { | ||
| n.protocol = "https:"; | ||
| const u = n.toString(); | ||
| s = await b(s, { url: u }), n = new URL(u); | ||
| if (B(a)) | ||
| return s = await I( | ||
| s, | ||
| a | ||
| ), await fetch(s); | ||
| if (a.protocol === "http:") { | ||
| a.protocol = "https:"; | ||
| const i = a.toString(); | ||
| s = await w(s, { url: i }), a = new URL(i); | ||
| } | ||
| if (!o) | ||
| if (!r) | ||
| return await fetch(s); | ||
| if (r && n.protocol === r.protocol && n.hostname === r.hostname && n.port === r.port && n.pathname.startsWith(r.pathname)) | ||
| if (o && a.protocol === o.protocol && a.hostname === o.hostname && a.port === o.port && a.pathname.startsWith(o.pathname)) | ||
| return await fetch(s); | ||
| const i = s.clone(); | ||
| const d = s.clone(); | ||
| try { | ||
| return await fetch(s); | ||
| } catch { | ||
| const u = new Headers(s.headers), h = ((l = u.get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : l.split(",")) || [], f = h.includes("authorization") || h.includes("cookie"), m = u.get("content-type"); | ||
| m && m.toLowerCase().includes("multipart/form-data") && (u.set("x-cors-proxy-content-type", m), u.set("content-type", "application/octet-stream")); | ||
| let d = null; | ||
| const R = s.method.toUpperCase(); | ||
| R !== "GET" && R !== "HEAD" && (await q() ? d = i.body : d = await i.arrayBuffer()), d instanceof ReadableStream && new URL(o, import.meta.url).protocol === "http:" && (d = await new Response(d).arrayBuffer()); | ||
| const T = await b(s, { | ||
| url: `${o}${s.url}`, | ||
| headers: u, | ||
| body: d, | ||
| const i = new Headers(s.headers), p = ((c = i.get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : c.split(",")) || [], f = p.includes("authorization") || p.includes("cookie"), l = i.get("content-type"); | ||
| l && l.toLowerCase().includes("multipart/form-data") && (i.set("x-cors-proxy-content-type", l), i.set("content-type", "application/octet-stream")); | ||
| let u = null; | ||
| const g = s.method.toUpperCase(); | ||
| g !== "GET" && g !== "HEAD" && (await A() ? u = d.body : u = await d.arrayBuffer()), u instanceof ReadableStream && new URL(r, import.meta.url).protocol === "http:" && (u = await new Response(u).arrayBuffer()); | ||
| const T = await w(s, { | ||
| url: `${r}${s.url}`, | ||
| headers: i, | ||
| body: u, | ||
| ...f && { credentials: "include" } | ||
| }), y = await fetch(T); | ||
| if (!y.headers.has(I)) | ||
| throw new H( | ||
| if (!y.headers.has(q)) | ||
| throw new O( | ||
| s.url, | ||
@@ -253,16 +267,33 @@ y.status, | ||
| } | ||
| function D(e) { | ||
| return e.hostname === "localhost" || e.hostname === "127.0.0.1" || e.hostname === "[::1]" || e.hostname === "::1"; | ||
| } | ||
| function B(e) { | ||
| return e.protocol === "https:" && b.has(e.hostname); | ||
| } | ||
| async function I(e, t) { | ||
| const r = b.get(t.hostname); | ||
| if (!r) | ||
| return e; | ||
| const n = new Headers(e.headers); | ||
| for (const [s, o] of Object.entries(r)) | ||
| n.has(s) || n.set(s, o); | ||
| return await w(e, { | ||
| headers: n | ||
| }); | ||
| } | ||
| export { | ||
| H as FirewallInterferenceError, | ||
| $ as __testing, | ||
| P as awaitReply, | ||
| x as broadcastMessageExpectReply, | ||
| b as cloneRequest, | ||
| _ as convertFetchEventToPHPRequest, | ||
| M as fetchWithCorsProxy, | ||
| O as FirewallInterferenceError, | ||
| j as __testing, | ||
| H as awaitReply, | ||
| P as broadcastMessageExpectReply, | ||
| w as cloneRequest, | ||
| $ as convertFetchEventToPHPRequest, | ||
| W as fetchWithCorsProxy, | ||
| E as getNextRequestId, | ||
| k as getRequestHeaders, | ||
| D as postMessageExpectReply, | ||
| A as removeContentSecurityPolicyDirective, | ||
| v as responseTo, | ||
| q as supportsReadableStreamBody | ||
| M as postMessageExpectReply, | ||
| x as removeContentSecurityPolicyDirective, | ||
| N as responseTo, | ||
| A as supportsReadableStreamBody | ||
| }; |
+4
-4
| { | ||
| "name": "@php-wasm/web-service-worker", | ||
| "version": "3.1.34", | ||
| "version": "3.1.35", | ||
| "description": "PHP.wasm – service worker utils", | ||
@@ -34,3 +34,3 @@ "repository": { | ||
| "license": "GPL-2.0-or-later", | ||
| "gitHead": "86daccc84fe31900eb57c4c8e1c3ba21a7ae8d13", | ||
| "gitHead": "9d29b73246e12465902d8ce42c0fe747125bc69a", | ||
| "engines": { | ||
@@ -41,4 +41,4 @@ "node": ">=20.10.0", | ||
| "dependencies": { | ||
| "@php-wasm/scopes": "3.1.34", | ||
| "@php-wasm/universal": "3.1.34" | ||
| "@php-wasm/scopes": "3.1.35", | ||
| "@php-wasm/universal": "3.1.35" | ||
| }, | ||
@@ -45,0 +45,0 @@ "packageManager": "npm@10.9.2", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
41017
2.72%480
7.38%14
16.67%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated