@titaniumnetwork-dev/ultraviolet
Advanced tools
Comparing version 3.2.6 to 3.2.7
@@ -8,3 +8,3 @@ "use strict";(()=>{var h=self.Ultraviolet,C=["cross-origin-embedder-policy","cross-origin-opener-policy","cross-origin-resource-policy","content-security-policy","content-security-policy-report-only","expect-ct","feature-policy","origin-isolation","strict-transport-security","upgrade-insecure-requests","x-content-type-options","x-download-options","x-frame-options","x-permitted-cross-domain-policies","x-powered-by","x-xss-protection"],E=["GET","HEAD"],g=class extends h.EventEmitter{constructor(e=__uv$config){super(),e.prefix||(e.prefix="/service/"),this.config=e,this.bareClient=new h.BareClient}route({request:e}){return!!e.url.startsWith(location.origin+this.config.prefix)}async fetch({request:e}){let s;try{if(!e.url.startsWith(location.origin+this.config.prefix))return await fetch(e);let t=new h(this.config);typeof this.config.construct=="function"&&this.config.construct(t,"service");let v=await t.cookie.db();t.meta.origin=location.origin,t.meta.base=t.meta.url=new URL(t.sourceUrl(e.url));let o=new w(e,t,E.includes(e.method.toUpperCase())?null:await e.blob());if(t.meta.url.protocol==="blob:"&&(o.blob=!0,o.base=o.url=new URL(o.url.pathname)),e.referrer&&e.referrer.startsWith(location.origin)){let i=new URL(t.sourceUrl(e.referrer));(o.headers.origin||t.meta.url.origin!==i.origin&&e.mode==="cors")&&(o.headers.origin=i.origin),o.headers.referer=i.href}let f=await t.cookie.getCookies(v)||[],x=t.cookie.serialize(f,t.meta,!1);o.headers["user-agent"]=navigator.userAgent,x&&(o.headers.cookie=x);let p=new u(o,null,null);if(this.emit("request",p),p.intercepted)return p.returnValue;s=o.blob?"blob:"+location.origin+o.url.pathname:o.url;let c=await this.bareClient.fetch(s,{headers:o.headers,method:o.method,body:o.body,credentials:o.credentials,mode:o.mode,cache:o.cache,redirect:o.redirect}),r=new y(o,c),l=new u(r,null,null);if(this.emit("beforemod",l),l.intercepted)return l.returnValue;for(let i of C)r.headers[i]&&delete r.headers[i];if(r.headers.location&&(r.headers.location=t.rewriteUrl(r.headers.location)),["document","iframe"].includes(e.destination)){let i=r.getHeader("content-disposition");if(!/\s*?((inline|attachment);\s*?)filename=/i.test(i)){let n=/^\s*?attachment/i.test(i)?"attachment":"inline",[m]=new URL(c.finalURL).pathname.split("/").slice(-1);r.headers["content-disposition"]=`${n}; filename=${JSON.stringify(m)}`}}if(r.headers["set-cookie"]&&(Promise.resolve(t.cookie.setCookies(r.headers["set-cookie"],v,t.meta)).then(()=>{self.clients.matchAll().then(function(i){i.forEach(function(n){n.postMessage({msg:"updateCookies",url:t.meta.url.href})})})}),delete r.headers["set-cookie"]),r.body)switch(e.destination){case"script":r.body=t.js.rewrite(await c.text());break;case"worker":{let i=[t.bundleScript,t.clientScript,t.configScript,t.handlerScript].map(n=>JSON.stringify(n)).join(",");r.body=`(async ()=>{${t.createJsInject(t.cookie.serialize(f,t.meta,!0),e.referrer)} importScripts(${i}); await __uv$promise; | ||
reload.addEventListener("click", () => location.reload()); | ||
uvVersion.textContent = ${JSON.stringify("3.2.6")}; | ||
uvVersion.textContent = ${JSON.stringify("3.2.7")}; | ||
`;return`<!DOCTYPE html> | ||
@@ -11,0 +11,0 @@ <html> |
{ | ||
"name": "@titaniumnetwork-dev/ultraviolet", | ||
"version": "3.2.6", | ||
"version": "3.2.7", | ||
"description": "Highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers and more!", | ||
@@ -19,3 +19,3 @@ "main": "lib/index.cjs", | ||
"devDependencies": { | ||
"@mercuryworkshop/bare-mux": "^2.0.3", | ||
"@mercuryworkshop/bare-mux": "^2.0.4", | ||
"astring": "^1.8.6", | ||
@@ -22,0 +22,0 @@ "esbuild": "^0.18.11", |
22
uv.d.ts
@@ -24,2 +24,19 @@ const Ultraviolet: typeof import('./src/rewrite/index').default; | ||
export type UVInject = { | ||
/** | ||
* The host(s) to inject the HTML on. | ||
* This is a regex that's tested against the proxied URL's host. | ||
*/ | ||
host: RegExp; | ||
/** | ||
* Where to inject the HTML | ||
* Possible values: `"head" | "body"` | ||
*/ | ||
injectTo: "head" | "body"; | ||
/** | ||
* The HTML to inject. | ||
*/ | ||
html: string; | ||
} | ||
/** | ||
@@ -92,2 +109,7 @@ * The Ultraviolet configuration object. | ||
decodeUrl?: UVDecode; | ||
/** | ||
* HTML inject settings. | ||
* This property expects an array of `UVInject`. | ||
*/ | ||
inject?: UVInject[]; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1922
1966423