mirror of
https://github.com/titaniumnetwork-dev/Ultraviolet.git
synced 2025-05-13 12:00:01 -04:00
backport changes from main
This commit is contained in:
parent
c963d4511f
commit
3be0ded7bd
12 changed files with 104 additions and 82 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -1,3 +1,12 @@
|
||||||
|
# v3.0.1
|
||||||
|
|
||||||
|
- This version of Ultraviolet upgrades [bare-mux](https://www.npmjs.com/package/@mercuryworkshop/bare-mux). This solves an issue with websockets not being opened properly.
|
||||||
|
- This version of Ultraviolet allows error messages to be iframed on cross origin isolated pages.
|
||||||
|
|
||||||
|
# v3.0.0
|
||||||
|
|
||||||
|
- This version of Ultraviolet has support for using [bare-mux](https://github.com/MercuryWorkshop/bare-mux) transports, allowing for use for other implementations like [EpoxyTransport](https://github.com/MercuryWorkshop/EpoxyTransport), [CurlTransport](https://github.com/MercuryWorkshop/CurlTransport), and the existing implementation [Bare-Client](https://github.com/MercuryWorkshop/Bare-as-module3).
|
||||||
|
|
||||||
# v2.0.0
|
# v2.0.0
|
||||||
|
|
||||||
- This version of Ultraviolet has support for Bare server v3
|
- This version of Ultraviolet has support for Bare server v3
|
||||||
|
@ -65,4 +74,4 @@ self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event)));
|
||||||
|
|
||||||
- This is the first official release of the Ultraviolet library.
|
- This is the first official release of the Ultraviolet library.
|
||||||
- The `uv.bundle.js` script is built using Webpack, allowing users to easily bundle their own scripts and dependencies with Ultraviolet.
|
- The `uv.bundle.js` script is built using Webpack, allowing users to easily bundle their own scripts and dependencies with Ultraviolet.
|
||||||
- This project is still under active development, and future releases will include new features and improvements.
|
- This project is still under active development, and future releases will include new features and improvements.
|
16
README.md
16
README.md
|
@ -24,23 +24,23 @@ Some of the popular websites that Ultraviolet supports include:
|
||||||
|
|
||||||
## Used by
|
## Used by
|
||||||
|
|
||||||
|
- [Alu](https://github.com/titaniumnetwork-dev/Alu)
|
||||||
|
- [AnuraOS](https://github.com/MercuryWorkshop/anuraOS)
|
||||||
|
- [Nebula](https://github.com/NebulaServices/Nebula)
|
||||||
- [Holy Unblocker](https://github.com/holy-unblocker/website)
|
- [Holy Unblocker](https://github.com/holy-unblocker/website)
|
||||||
- [Hypertabs](https://hypertabs.cc/)
|
|
||||||
- [Terbium](https://github.com/TerbiumOS/webOS)
|
- [Terbium](https://github.com/TerbiumOS/webOS)
|
||||||
- [Incognito](https://github.com/caracal-js/Incognito)
|
- [Incognito](https://github.com/caracal-js/Incognito)
|
||||||
- [Nebula](https://github.com/NebulaServices/Nebula)
|
|
||||||
- [Noctura](https://github.com/NebulaServices/Noctura)
|
|
||||||
- [Metallic](https://github.com/Metallic-Web/Metallic)
|
- [Metallic](https://github.com/Metallic-Web/Metallic)
|
||||||
|
|
||||||
## Upgrading
|
## Upgrading
|
||||||
|
|
||||||
A guide for updating from v1 to v2 can be found [here](./docs/V2-UPGRADE-GUIDE.md).
|
A guide for updating from any version to v3 can be found [here](https://github.com/titaniumnetwork-dev/Ultraviolet/wiki/Upgrading).
|
||||||
|
|
||||||
## Older Bare servers
|
## Older Ultraviolet versions
|
||||||
|
|
||||||
Starting from v2, Ultraviolet only supports Bare servers v3+.
|
Starting from v3, Ultraviolet uses [bare-mux](https://github.com/MercuryWorkshop/bare-mux), a library that allows you to switch out your Bare client.
|
||||||
|
|
||||||
If you operate an outdated Bare server, we encourage you to update. If you're using an outdated Bare server, we encourage you to find an updated Bare server or host your own.
|
If you operate using an older Ultraviolet, we encourage you to update.
|
||||||
|
|
||||||
If you're too lazy to do either of the above, you can install an outdated and unsupported version of Ultraviolet.
|
If you're too lazy to do either of the above, you can install an outdated and unsupported version of Ultraviolet.
|
||||||
|
|
||||||
|
@ -58,4 +58,4 @@ This repository can be built, but it can't be deployed to any services. See [Ult
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Documentation can be found in the [wiki](https://github.com/titaniumnetwork-dev/Ultraviolet/wiki).
|
Documentation can be found in the [wiki](https://github.com/titaniumnetwork-dev/Ultraviolet/wiki).
|
1
build.js
1
build.js
|
@ -31,5 +31,6 @@ await build({
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
bundle: true,
|
bundle: true,
|
||||||
|
logLevel: 'info',
|
||||||
outdir: 'dist/',
|
outdir: 'dist/',
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
# Upgrade to Ultraviolet v2.x
|
|
||||||
|
|
||||||
## No support for older Bare servers.
|
|
||||||
|
|
||||||
In order to more effectively use newer APIs provided by newer implementations of bare-client, support folder older Bare servers has been dropped.
|
|
||||||
|
|
||||||
You need to upgrade your Bare server in order to use Ultraviolet.
|
|
||||||
|
|
||||||
See the [Bare server node upgrade guide](https://github.com/tomphttp/bare-server-node/blob/master/docs/V2-UPGRADE-GUIDE.md) for upgrading your Bare server.
|
|
69
package-lock.json
generated
69
package-lock.json
generated
|
@ -1,15 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "@titaniumnetwork-dev/ultraviolet",
|
"name": "@titaniumnetwork-dev/ultraviolet",
|
||||||
"version": "2.0.0",
|
"version": "3.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@titaniumnetwork-dev/ultraviolet",
|
"name": "@titaniumnetwork-dev/ultraviolet",
|
||||||
"version": "2.0.0",
|
"version": "3.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tomphttp/bare-client": "^2.2.0-alpha",
|
"@mercuryworkshop/bare-mux": "^1.0.7",
|
||||||
"css-tree": "^2.3.1",
|
"css-tree": "^2.3.1",
|
||||||
"esbuild": "^0.18.11",
|
"esbuild": "^0.18.11",
|
||||||
"eslint": "^8.28.0",
|
"eslint": "^8.28.0",
|
||||||
|
@ -476,6 +476,16 @@
|
||||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@mercuryworkshop/bare-mux": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mercuryworkshop/bare-mux/-/bare-mux-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-VUJvfLxlzpyCuKoGfaI+sUpHEK4tvmvpYvkalU2z604+O9UahfZoc53arO9pm9F3Fnv7ZNloSWMnvSlPAznkoA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/uuid": "^9.0.8",
|
||||||
|
"uuid": "^9.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@nodelib/fs.scandir": {
|
"node_modules/@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
|
@ -521,18 +531,18 @@
|
||||||
"node": ">=14"
|
"node": ">=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@tomphttp/bare-client": {
|
|
||||||
"version": "2.2.0-alpha",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tomphttp/bare-client/-/bare-client-2.2.0-alpha.tgz",
|
|
||||||
"integrity": "sha512-xhcflOpwr92tkpp8SoDhB3nK3LHMBIjx+vgow37XobQew2k0/mXSxmaU7BsDFpOIa1CcLCEsR8gWn0v7Cy9+7Q==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@types/estree": {
|
"node_modules/@types/estree": {
|
||||||
"version": "0.0.46",
|
"version": "0.0.46",
|
||||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.46.tgz",
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.46.tgz",
|
||||||
"integrity": "sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg==",
|
"integrity": "sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/uuid": {
|
||||||
|
"version": "9.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.8.tgz",
|
||||||
|
"integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/acorn": {
|
"node_modules/acorn": {
|
||||||
"version": "8.8.0",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
|
||||||
|
@ -1903,6 +1913,19 @@
|
||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "9.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
|
||||||
|
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
"https://github.com/sponsors/broofa",
|
||||||
|
"https://github.com/sponsors/ctavan"
|
||||||
|
],
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/which": {
|
"node_modules/which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
|
@ -2266,6 +2289,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@mercuryworkshop/bare-mux": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mercuryworkshop/bare-mux/-/bare-mux-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-VUJvfLxlzpyCuKoGfaI+sUpHEK4tvmvpYvkalU2z604+O9UahfZoc53arO9pm9F3Fnv7ZNloSWMnvSlPAznkoA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/uuid": "^9.0.8",
|
||||||
|
"uuid": "^9.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@nodelib/fs.scandir": {
|
"@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
|
@ -2299,18 +2332,18 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@tomphttp/bare-client": {
|
|
||||||
"version": "2.2.0-alpha",
|
|
||||||
"resolved": "https://registry.npmjs.org/@tomphttp/bare-client/-/bare-client-2.2.0-alpha.tgz",
|
|
||||||
"integrity": "sha512-xhcflOpwr92tkpp8SoDhB3nK3LHMBIjx+vgow37XobQew2k0/mXSxmaU7BsDFpOIa1CcLCEsR8gWn0v7Cy9+7Q==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"@types/estree": {
|
"@types/estree": {
|
||||||
"version": "0.0.46",
|
"version": "0.0.46",
|
||||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.46.tgz",
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.46.tgz",
|
||||||
"integrity": "sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg==",
|
"integrity": "sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/uuid": {
|
||||||
|
"version": "9.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.8.tgz",
|
||||||
|
"integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"acorn": {
|
"acorn": {
|
||||||
"version": "8.8.0",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
|
||||||
|
@ -3291,6 +3324,12 @@
|
||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"version": "9.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
|
||||||
|
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"which": {
|
"which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@titaniumnetwork-dev/ultraviolet",
|
"name": "@titaniumnetwork-dev/ultraviolet",
|
||||||
"version": "2.0.0",
|
"version": "3.1.0",
|
||||||
"description": "Highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers and more!",
|
"description": "Highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers and more!",
|
||||||
"main": "lib/index.cjs",
|
"main": "lib/index.cjs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -18,10 +18,12 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node build.js",
|
"build": "node build.js",
|
||||||
"dev": "node build.js --dev",
|
"dev": "node build.js --dev",
|
||||||
"prepack": "npm run build"
|
"prepack": "npm run build",
|
||||||
|
"publish": "npm run build && npm publish --access public",
|
||||||
|
"pack": "npm run build && npm pack"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tomphttp/bare-client": "^2.2.0-alpha",
|
"@mercuryworkshop/bare-mux": "^1.0.7",
|
||||||
"css-tree": "^2.3.1",
|
"css-tree": "^2.3.1",
|
||||||
"esbuild": "^0.18.11",
|
"esbuild": "^0.18.11",
|
||||||
"eslint": "^8.28.0",
|
"eslint": "^8.28.0",
|
||||||
|
|
|
@ -34,7 +34,7 @@ class UVClient extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {typeof globalThis} window
|
* @param {typeof globalThis} window
|
||||||
* @param {import('@tomphttp/bare-client').BareClient} bareClient
|
* @param {import('@mercuryworkshop/bare-mux').BareClient} bareClient
|
||||||
* @param {boolean} worker
|
* @param {boolean} worker
|
||||||
*/
|
*/
|
||||||
constructor(window = self, bareClient, worker = !window.window) {
|
constructor(window = self, bareClient, worker = !window.window) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import {
|
||||||
wrapEval,
|
wrapEval,
|
||||||
} from './rewrite.script.js';
|
} from './rewrite.script.js';
|
||||||
import { openDB } from 'idb';
|
import { openDB } from 'idb';
|
||||||
import { BareClient } from '@tomphttp/bare-client';
|
import { BareClient } from '@mercuryworkshop/bare-mux';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/*global Ultraviolet*/
|
/*global Ultraviolet*/
|
||||||
self.__uv$config = {
|
self.__uv$config = {
|
||||||
prefix: '/service/',
|
prefix: '/service/',
|
||||||
bare: '/bare/',
|
|
||||||
encodeUrl: Ultraviolet.codec.xor.encode,
|
encodeUrl: Ultraviolet.codec.xor.encode,
|
||||||
decodeUrl: Ultraviolet.codec.xor.decode,
|
decodeUrl: Ultraviolet.codec.xor.decode,
|
||||||
handler: '/uv.handler.js',
|
handler: '/uv.handler.js',
|
||||||
|
|
|
@ -14,7 +14,7 @@ const UVClient = self.UVClient;
|
||||||
const __uv$config = self.__uv$config;
|
const __uv$config = self.__uv$config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import('@tomphttp/bare-client').BareManifest}
|
* @type {import('@mercuryworkshop/bare-mux').BareManifest}
|
||||||
*/
|
*/
|
||||||
const __uv$bareData = self.__uv$bareData;
|
const __uv$bareData = self.__uv$bareData;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ function __uvHook(window) {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// websockets
|
// websockets
|
||||||
const bareClient = new Ultraviolet.BareClient(__uv$bareURL, __uv$bareData);
|
const bareClient = new Ultraviolet.BareClient();
|
||||||
|
|
||||||
const client = new UVClient(window, bareClient, worker);
|
const client = new UVClient(window, bareClient, worker);
|
||||||
const {
|
const {
|
||||||
|
@ -1023,28 +1023,12 @@ function __uvHook(window) {
|
||||||
if (cookieStr !== '') requestHeaders['Cookie'] = cookieStr.toString();
|
if (cookieStr !== '') requestHeaders['Cookie'] = cookieStr.toString();
|
||||||
|
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
bareClient.createWebSocket(event.data.args[0], event.data.args[1], {
|
bareClient.createWebSocket(
|
||||||
headers: requestHeaders,
|
event.data.args[0],
|
||||||
readyStateHook: (socket, getReadyState) => {
|
event.data.args[1],
|
||||||
socket.__uv$getReadyState = getReadyState;
|
event.target,
|
||||||
},
|
requestHeaders,
|
||||||
sendErrorHook: (socket, getSendError) => {
|
)
|
||||||
socket.__uv$getSendError = getSendError;
|
|
||||||
},
|
|
||||||
urlHook: (socket, url) => {
|
|
||||||
socket.__uv$socketUrl = url;
|
|
||||||
},
|
|
||||||
protocolHook: (socket, getProtocol) => {
|
|
||||||
socket.__uv$getProtocol = getProtocol;
|
|
||||||
},
|
|
||||||
setCookiesCallback: (setCookies) => {
|
|
||||||
// document.cookie is hooked
|
|
||||||
// so we can just call it
|
|
||||||
for (const cookie of setCookies)
|
|
||||||
window.document.cookie = cookie;
|
|
||||||
},
|
|
||||||
webSocketImpl: event.target,
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
22
src/uv.sw.js
22
src/uv.sw.js
|
@ -40,7 +40,7 @@ class UVServiceWorker extends Ultraviolet.EventEmitter {
|
||||||
/**
|
/**
|
||||||
* @type {InstanceType<Ultraviolet['BareClient']>}
|
* @type {InstanceType<Ultraviolet['BareClient']>}
|
||||||
*/
|
*/
|
||||||
this.bareClient = new Ultraviolet.BareClient(this.address);
|
this.bareClient = new Ultraviolet.BareClient();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -297,7 +297,7 @@ class ResponseContext {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {RequestContext} request
|
* @param {RequestContext} request
|
||||||
* @param {import("@tomphttp/bare-client").BareResponseFetch} response
|
* @param {import("@mercuryworkshop/bare-mux").BareResponseFetch} response
|
||||||
*/
|
*/
|
||||||
constructor(request, response) {
|
constructor(request, response) {
|
||||||
this.request = request;
|
this.request = request;
|
||||||
|
@ -413,6 +413,9 @@ function hostnameErrorTemplate(fetchedURL, bareServer) {
|
||||||
'<head>' +
|
'<head>' +
|
||||||
"<meta charset='utf-8' />" +
|
"<meta charset='utf-8' />" +
|
||||||
'<title>Error</title>' +
|
'<title>Error</title>' +
|
||||||
|
'<style>' +
|
||||||
|
'* { background-color: white }' +
|
||||||
|
'</style>' +
|
||||||
'</head>' +
|
'</head>' +
|
||||||
'<body>' +
|
'<body>' +
|
||||||
'<h1>This site can’t be reached</h1>' +
|
'<h1>This site can’t be reached</h1>' +
|
||||||
|
@ -483,6 +486,9 @@ function errorTemplate(
|
||||||
'<head>' +
|
'<head>' +
|
||||||
"<meta charset='utf-8' />" +
|
"<meta charset='utf-8' />" +
|
||||||
'<title>Error</title>' +
|
'<title>Error</title>' +
|
||||||
|
'<style>' +
|
||||||
|
'* { background-color: white }' +
|
||||||
|
'</style>' +
|
||||||
'</head>' +
|
'</head>' +
|
||||||
'<body>' +
|
'<body>' +
|
||||||
"<h1 id='errorTitle'></h1>" +
|
"<h1 id='errorTitle'></h1>" +
|
||||||
|
@ -520,7 +526,7 @@ function errorTemplate(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import("@tomphttp/bare-client").BareError} BareError
|
* @typedef {import("@mercuryworkshop/bare-mux").BareError} BareError
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -556,6 +562,12 @@ function renderError(err, fetchedURL, bareServer) {
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
let message;
|
let message;
|
||||||
|
let headers = {
|
||||||
|
'content-type': 'text/html',
|
||||||
|
};
|
||||||
|
if (crossOriginIsolated) {
|
||||||
|
headers['Cross-Origin-Embedder-Policy'] = 'require-corp';
|
||||||
|
}
|
||||||
|
|
||||||
if (isBareError(err)) {
|
if (isBareError(err)) {
|
||||||
status = err.status;
|
status = err.status;
|
||||||
|
@ -582,9 +594,7 @@ function renderError(err, fetchedURL, bareServer) {
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
status,
|
status,
|
||||||
headers: {
|
headers: headers
|
||||||
'content-type': 'text/html',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
13
uv.d.ts
vendored
13
uv.d.ts
vendored
|
@ -26,19 +26,6 @@ export type UVDecode = (input: Coded) => string;
|
||||||
* This interface defines the configuration options for the Ultraviolet library.
|
* This interface defines the configuration options for the Ultraviolet library.
|
||||||
*/
|
*/
|
||||||
export interface UVConfig {
|
export interface UVConfig {
|
||||||
/**
|
|
||||||
* The Bare server(s) to use.
|
|
||||||
* If an array is specified, the service worker will randomly select a server to use.
|
|
||||||
* The selected server will be used for the duration of the session.
|
|
||||||
* Both relative and absolute paths are accepted. Relative paths are resolved to the current URL.
|
|
||||||
* @example // A Bare server running on the subdomain `bare.`, automatically correcting the apex record:
|
|
||||||
* `${location.protocol}//bare.${location.host.replace(/^www\./, "")}
|
|
||||||
* @example `http://localhost:8080/`
|
|
||||||
* @example `http://localhost:8080/bare/`
|
|
||||||
* @defaultValue `/bare/`
|
|
||||||
* @see {@link|https://github.com/tomphttp/specifications/blob/master/BareServer.md}
|
|
||||||
*/
|
|
||||||
bare?: string | string[];
|
|
||||||
/**
|
/**
|
||||||
* The prefix for Ultraviolet to listen on.
|
* The prefix for Ultraviolet to listen on.
|
||||||
* This prefix will be used to create the URL for the service worker and the client script.
|
* This prefix will be used to create the URL for the service worker and the client script.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue