@eduwork/dsh-remote-access 0.1.3 → 0.1.4
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/lib/index.js +7 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -6401,8 +6401,8 @@ var BUNDLE_HEADERS = ["content-type", "cache-control", "etag", "last-modified"];
|
|
|
6401
6401
|
function createHostAdapter(dsh, distIndex) {
|
|
6402
6402
|
const api = dsh.connection.createSharedFetchHandler("/api");
|
|
6403
6403
|
const distRoot = dirname2(distIndex);
|
|
6404
|
-
async function document() {
|
|
6405
|
-
const html = dsh.webServer.renderIndex(await readFile2(distIndex, "utf8"));
|
|
6404
|
+
async function document(peer) {
|
|
6405
|
+
const html = dsh.webServer.renderIndex(await readFile2(distIndex, "utf8"), peer);
|
|
6406
6406
|
return new Response(html, { headers: { "content-type": TYPES[".html"], "cache-control": "no-store" } });
|
|
6407
6407
|
}
|
|
6408
6408
|
async function distFile(pathname) {
|
|
@@ -6431,11 +6431,11 @@ function createHostAdapter(dsh, distIndex) {
|
|
|
6431
6431
|
}
|
|
6432
6432
|
return {
|
|
6433
6433
|
createPeer: () => dsh.connection.createPeer({ principal: { kind: "owner" }, interactions: "answer" }),
|
|
6434
|
-
async page(request) {
|
|
6434
|
+
async page(request, peer) {
|
|
6435
6435
|
if (request.method !== "GET" && request.method !== "HEAD") return new Response(null, { status: 405 });
|
|
6436
6436
|
const url2 = new URL(request.url);
|
|
6437
6437
|
const pathname = decodeURIComponent(url2.pathname);
|
|
6438
|
-
if (pathname === "/" || pathname === "/index.html") return document();
|
|
6438
|
+
if (pathname === "/" || pathname === "/index.html") return document(peer);
|
|
6439
6439
|
if (pathname.startsWith("/plugins/")) return bundle(url2, request.signal);
|
|
6440
6440
|
return distFile(pathname);
|
|
6441
6441
|
},
|
|
@@ -6639,8 +6639,8 @@ function compressPages(adapter) {
|
|
|
6639
6639
|
const compress = async (response) => new Uint8Array(await gzipAsync(await response.arrayBuffer()));
|
|
6640
6640
|
return {
|
|
6641
6641
|
...adapter,
|
|
6642
|
-
async page(request) {
|
|
6643
|
-
const response = await adapter.page(request);
|
|
6642
|
+
async page(request, peer) {
|
|
6643
|
+
const response = await adapter.page(request, peer);
|
|
6644
6644
|
const { headers } = response;
|
|
6645
6645
|
const eligible = request.method === "GET" && response.status === 200 && !headers.has("content-encoding") && TEXT.test(headers.get("content-type") ?? "") && /\bgzip\b/.test(request.headers.get("accept-encoding") ?? "");
|
|
6646
6646
|
if (!eligible) return response;
|
|
@@ -7294,7 +7294,7 @@ function remoteHandler(adapter, peer, onRefused) {
|
|
|
7294
7294
|
return {
|
|
7295
7295
|
async fetch(request) {
|
|
7296
7296
|
const { pathname } = new URL(request.url);
|
|
7297
|
-
if (pathname !== "/api" && !pathname.startsWith("/api/")) return adapter.page(request);
|
|
7297
|
+
if (pathname !== "/api" && !pathname.startsWith("/api/")) return adapter.page(request, peer);
|
|
7298
7298
|
if (allowsApiRequest(request.method, pathname)) return adapter.api(request, peer);
|
|
7299
7299
|
const body = request.method === "POST" ? await request.text() : "";
|
|
7300
7300
|
const call = rpcCall(body);
|
package/package.json
CHANGED