@volter/tabnode 0.5.35 → 0.5.36
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/dist/__sw__.js +16 -12
- package/package.json +1 -1
package/dist/__sw__.js
CHANGED
|
@@ -796,6 +796,16 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
796
796
|
bodyBase64Length: response.bodyBase64?.length,
|
|
797
797
|
});
|
|
798
798
|
|
|
799
|
+
// The frame's embedding policy goes on every answer, an empty one too:
|
|
800
|
+
// the page is cross-origin isolated, and a document without these
|
|
801
|
+
// headers is blocked in its frame (an empty 200 lost the preview).
|
|
802
|
+
const respHeaders = new Headers(response.headers);
|
|
803
|
+
respHeaders.set('Cross-Origin-Embedder-Policy', 'credentialless');
|
|
804
|
+
respHeaders.set('Cross-Origin-Opener-Policy', 'same-origin');
|
|
805
|
+
respHeaders.set('Cross-Origin-Resource-Policy', 'cross-origin');
|
|
806
|
+
// Remove any headers that might block iframe loading
|
|
807
|
+
respHeaders.delete('X-Frame-Options');
|
|
808
|
+
|
|
799
809
|
// Decode base64 body and create response
|
|
800
810
|
let finalResponse;
|
|
801
811
|
if (response.bodyBase64 && response.bodyBase64.length > 0) {
|
|
@@ -803,19 +813,13 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
803
813
|
const bytes = base64ToBytes(response.bodyBase64);
|
|
804
814
|
DEBUG && console.log('[SW] Decoded body length:', bytes.length);
|
|
805
815
|
|
|
806
|
-
// Use Blob to ensure proper body handling
|
|
807
|
-
|
|
816
|
+
// Use Blob to ensure proper body handling. Its type is the server's,
|
|
817
|
+
// or none: a document the server gave no type is the browser's to
|
|
818
|
+
// sniff, and an invented octet-stream made a page a download.
|
|
819
|
+
const declared = new Headers(response.headers).get('content-type');
|
|
820
|
+
const blob = new Blob([bytes], declared ? { type: declared } : {});
|
|
808
821
|
DEBUG && console.log('[SW] Created blob size:', blob.size);
|
|
809
822
|
|
|
810
|
-
// Merge response headers with CORP/COEP headers to allow iframe embedding
|
|
811
|
-
// The parent page has COEP: credentialless, so we need matching headers
|
|
812
|
-
const respHeaders = new Headers(response.headers);
|
|
813
|
-
respHeaders.set('Cross-Origin-Embedder-Policy', 'credentialless');
|
|
814
|
-
respHeaders.set('Cross-Origin-Opener-Policy', 'same-origin');
|
|
815
|
-
respHeaders.set('Cross-Origin-Resource-Policy', 'cross-origin');
|
|
816
|
-
// Remove any headers that might block iframe loading
|
|
817
|
-
respHeaders.delete('X-Frame-Options');
|
|
818
|
-
|
|
819
823
|
finalResponse = new Response(blob, {
|
|
820
824
|
status: response.statusCode,
|
|
821
825
|
statusText: response.statusMessage,
|
|
@@ -832,7 +836,7 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
832
836
|
finalResponse = new Response(null, {
|
|
833
837
|
status: response.statusCode,
|
|
834
838
|
statusText: response.statusMessage,
|
|
835
|
-
headers:
|
|
839
|
+
headers: respHeaders,
|
|
836
840
|
});
|
|
837
841
|
}
|
|
838
842
|
|