Skip to content

Commit

Permalink
Merge branch 'main' into frontend-update-branding
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Sep 19, 2024
2 parents 338682c + 692dece commit 0a56b41
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 46 deletions.
Binary file modified build/icon.icns
Binary file not shown.
Binary file removed build/icon.ico
Binary file not shown.
Binary file modified build/icon.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@webrecorder/archivewebpage",
"productName": "ArchiveWeb.page",
"version": "0.12.3",
"version": "0.12.8",
"main": "index.js",
"description": "Create Web Archives directly in your browser",
"repository": "https://github.com/webrecorder/archiveweb.page",
Expand All @@ -11,9 +11,9 @@
"@fortawesome/fontawesome-free": "^5.13.0",
"@ipld/car": "^5.3.1",
"@webrecorder/awp-sw": "^0.4.4",
"@webrecorder/wabac": "^2.19.2",
"@webrecorder/wabac": "^2.19.9",
"auto-js-ipfs": "^2.3.0",
"browsertrix-behaviors": "^0.6.0",
"browsertrix-behaviors": "^0.6.4",
"btoa": "^1.2.1",
"bulma": "^0.9.3",
"client-zip": "^2.2.2",
Expand All @@ -26,7 +26,11 @@
"stream-browserify": "^3.0.0",
"unused-filename": "^4.0.1",
"uuid": "^8.3.2",
"warcio": "^2.2.1"
"warcio": "^2.3.1"
},
"resolutions": {
"@webrecorder/wabac": "^2.19.9",
"replaywebpage": "1.8.17"
},
"devDependencies": {
"copy-webpack-plugin": "^9.0.1",
Expand Down
19 changes: 19 additions & 0 deletions src/electron/electron-recorder-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ class ElectronRecorderApp extends ElectronReplayApp
this.createRecordWindow(opts);
});

sesh.webRequest.onHeadersReceived((details, callback) => {
const { url, responseHeaders, method } = details;

// Allow access to Browsertrix APIs
if (url.indexOf("/api") >= 0) {
let { statusLine } = details;

if (method === "OPTIONS") {
statusLine = "HTTP/1.1 200 OK";
responseHeaders["Access-Control-Allow-Headers"] = "Authorization, Content-Type";
responseHeaders["Access-Control-Allow-Methods"] = "GET, PUT, POST";
}
responseHeaders["Access-Control-Allow-Origin"] = "*";
callback({responseHeaders, statusLine});
} else {
callback({responseHeaders});
}
});

sesh.on("will-download", (event, item, webContents) => {
const origFilename = item.getFilename();

Expand Down
12 changes: 8 additions & 4 deletions src/recorder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RequestResponseInfo } from "./requestresponseinfo.js";

import { baseRules as baseDSRules, htmlRules as htmlDSRules } from "@webrecorder/wabac/src/rewrite";
import { getCustomRewriter } from "@webrecorder/wabac/src/rewrite";
import { rewriteDASH, rewriteHLS } from "@webrecorder/wabac/src/rewrite/rewriteVideo";
import { Buffer } from "buffer";

Expand Down Expand Up @@ -1009,10 +1009,9 @@ class Recorder {
case "text/javascript":
case "application/javascript":
case "application/x-javascript": {
const rules = ct === "text/html" ? htmlDSRules : baseDSRules;
const rw = rules.getRewriter(url);
const rw = getCustomRewriter(url, ct === "text/html");

if (rw !== rules.defaultRewriter) {
if (rw) {
string = payload.toString();
newString = rw.rewrite(string, {live: true, save: extraOpts});
}
Expand Down Expand Up @@ -1108,6 +1107,11 @@ class Recorder {
try {
const data = reqresp.toDBRecord(reqresp.payload, this.pageInfo);

// top-level URL is a non-GET request
if (data && data.requestUrl && data.requestUrl === this.pageInfo.url && !sessions.length) {
this.pageInfo.url = data.url;
}

// top-level page resource
if (data && !sessions.length && reqresp.url === this.pageInfo.url) {
this.pageInfo.ts = reqresp.ts;
Expand Down
26 changes: 15 additions & 11 deletions src/requestresponseinfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

import { getCustomRewriter } from "@webrecorder/wabac/src/rewrite";
import { getStatusText } from "@webrecorder/wabac/src/utils";

import { postToGetUrl } from "warcio";
Expand Down Expand Up @@ -191,20 +192,23 @@ class RequestResponseInfo
postData: this.postData || "",
};
if (postToGetUrl(convData)) {
//this.requestBody = convData.requestBody;
// truncate to avoid extra long URLs
try {
const url = new URL(convData.url);
for (const [key, value] of url.searchParams.entries()) {
if (value && value.length > MAX_ARG_LEN) {
url.searchParams.set(key, value.slice(0, MAX_ARG_LEN));
// if URL for custom rewriting, keep as is, otherwise truncate to avoid extra long URLs
if (getCustomRewriter(this.url, mime === "text/html")) {
this.url = convData.url;
} else {
try {
const url = new URL(convData.url);
for (const [key, value] of url.searchParams.entries()) {
if (value && value.length > MAX_ARG_LEN) {
url.searchParams.set(key, value.slice(0, MAX_ARG_LEN));
}
}
convData.url = url.href;
} catch (e) {
//ignore
}
convData.url = url.href;
} catch (e) {
//ignore
this.url = convData.url.slice(0, MAX_URL_LENGTH);
}
this.url = convData.url.slice(0, MAX_URL_LENGTH);
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { html, css, wrapCss, IS_APP, apiPrefix } from "replaywebpage/src/misc";
// replaywebpage imports
import { ReplayWebApp, Embed, Loader } from "replaywebpage";

import { SWManager } from "replaywebpage/src/swmanager";

import fasHelp from "@fortawesome/fontawesome-free/svgs/solid/question-circle.svg";
import fasPlus from "@fortawesome/fontawesome-free/svgs/solid/plus.svg";

Expand Down Expand Up @@ -142,15 +144,27 @@ class ArchiveWebApp extends ReplayWebApp
}
}

async checkDoubleSW() {
async checkSW() {
const regs = await navigator.serviceWorker.getRegistrations();
// Remove double SW
for (const reg of regs) {
if (reg.active && reg.active.scriptURL.endsWith("/replay/sw.js")) {
if (await reg.unregister()) {
self.location.reload();
}
}
}

// For App: If no SW, register here
if (IS_APP && !regs.length) {
this.swmanager = new SWManager({ name: this.swName, appName: this.appName });
this.swmanager
.register()
.catch(
() =>
(this.swErrorMsg = this.swmanager.renderErrorReport(this.mainLogo)),
);
}
}

firstUpdated() {
Expand All @@ -160,7 +174,7 @@ class ArchiveWebApp extends ReplayWebApp
return super.firstUpdated();
}

this.checkDoubleSW();
this.checkSW();

this.initRoute();

Expand Down
88 changes: 63 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@
integrity sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==

"@lit-labs/ssr-dom-shim@^1.0.0", "@lit-labs/ssr-dom-shim@^1.1.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz#353ce4a76c83fadec272ea5674ede767650762fd"
integrity sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g==
version "1.2.1"
resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.1.tgz#2f3a8f1d688935c704dbc89132394a41029acbb8"
integrity sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==

"@lit/reactive-element@^1.3.0", "@lit/reactive-element@^1.6.0":
version "1.6.3"
Expand Down Expand Up @@ -737,6 +737,11 @@
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz#56e2cc26c397c038fab0e3a917a12d5c5909e901"
integrity sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==

"@types/pako@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@types/pako/-/pako-1.0.7.tgz#aa0e4af9855d81153a29ff84cc44cce25298eda9"
integrity sha512-YBtzT2ztNF6R/9+UXj2wTGFnC9NklAnASt3sC0h2m1bbH7G6FyBIkt4AN8ThZpNfxUo1b2iMVO0UawiJymEt8A==

"@types/plist@^3.0.1":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@types/plist/-/plist-3.0.5.tgz#9a0c49c0f9886c8c8696a7904dd703f6284036e0"
Expand Down Expand Up @@ -803,6 +808,13 @@
dependencies:
"@types/node" "*"

"@types/stream-buffers@^3.0.7":
version "3.0.7"
resolved "https://registry.yarnpkg.com/@types/stream-buffers/-/stream-buffers-3.0.7.tgz#0b719fa1bd2ca2cc0908205a440e5e569e1aa21e"
integrity sha512-azOCy05sXVXrO+qklf0c/B07H/oHaIuDDAiHPVwlk3A9Ek+ksHyTeMajLZl3r76FxpPpxem//4Te61G1iW3Giw==
dependencies:
"@types/node" "*"

"@types/trusted-types@^2.0.2":
version "2.0.7"
resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.7.tgz#baccb07a970b91707df3a3e8ba6896c57ead2d11"
Expand Down Expand Up @@ -984,21 +996,21 @@
uuid "^9.0.0"
warcio "^2.2.1"

"@webrecorder/wabac@^2.17.3", "@webrecorder/wabac@^2.18.1", "@webrecorder/wabac@^2.19.2":
version "2.19.2"
resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.19.2.tgz#2591980e7e14275d6b885f850ecff2b82e898669"
integrity sha512-rj048+Ri0Q1Q7MSPu5w/y7utR5MgCxaJaUtfy257GSZbaHs0RBsKW8RJMunEZPUL5ANC/THBdUMEV7dvlJBC6A==
"@webrecorder/wabac@^2.17.3", "@webrecorder/wabac@^2.18.1", "@webrecorder/wabac@^2.19.9":
version "2.19.9"
resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.19.9.tgz#21d357077bc2a85419e7a6002c81a4bc4fec2514"
integrity sha512-lyvbKVrdUZMUGxwKg5ZFQnyjGUSqZSGOF3NFG9rXLA+Ni0YcQjZCMexGSmqCwY+BksyrVJISCMs3xQ2WQAekgw==
dependencies:
"@peculiar/asn1-ecc" "^2.3.4"
"@peculiar/asn1-schema" "^2.3.3"
"@peculiar/x509" "^1.9.2"
"@webrecorder/wombat" "^3.7.10"
"@webrecorder/wombat" "^3.8.2"
acorn "^8.10.0"
auto-js-ipfs "^2.1.1"
base64-js "^1.5.1"
brotli "^1.3.3"
buffer "^6.0.3"
fast-xml-parser "^4.2.5"
fast-xml-parser "^4.4.1"
hash-wasm "^4.9.0"
http-link-header "^1.1.3"
http-status-codes "^2.1.4"
Expand All @@ -1011,14 +1023,14 @@
path-parser "^6.1.0"
process "^0.11.10"
stream-browserify "^3.0.0"
warcio "^2.2.1"
warcio "^2.3.0"

"@webrecorder/wombat@^3.7.10":
version "3.7.10"
resolved "https://registry.yarnpkg.com/@webrecorder/wombat/-/wombat-3.7.10.tgz#c6d3f69b52f170a3166b4124b94b301d47064cde"
integrity sha512-UUXQAbDk0UfTGng7O2gbF3dzJDklMD1SqmLkGI4CxqqlUzvqvIxNrmkyI5cPPha9fOlDybtsUqQ5JFtXzhVE5w==
"@webrecorder/wombat@^3.8.2":
version "3.8.2"
resolved "https://registry.yarnpkg.com/@webrecorder/wombat/-/wombat-3.8.2.tgz#e46e18719834d633175eec52ce753a4dc4e48e27"
integrity sha512-uUZr9V4UYpVOpM64Tm27ND/hMjDbT37+/qyNaNV6loqDuVzBVQh5w7SfTEy0Bbjj1MYyNZP244mOtWtotTpUEA==
dependencies:
warcio "^2.2.0"
warcio "^2.3.1"

"@xmldom/xmldom@^0.8.8":
version "0.8.10"
Expand Down Expand Up @@ -1415,10 +1427,12 @@ browserslist@^4.21.10:
node-releases "^2.0.14"
update-browserslist-db "^1.0.13"

browsertrix-behaviors@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/browsertrix-behaviors/-/browsertrix-behaviors-0.6.0.tgz#e16345e4b414b18e6441548d517d01b4316f744e"
integrity sha512-BdfEPHmDjhEIFrn80UKnwGT6HRgnmq2shNybu8BEfAHJQsqZdvP/VVKWvNGnWML1jjUKiwtvtkdFhtHedFQkzA==
browsertrix-behaviors@^0.6.4:
version "0.6.4"
resolved "https://registry.yarnpkg.com/browsertrix-behaviors/-/browsertrix-behaviors-0.6.4.tgz#33fe9a433108f2faac3a03af91aff940433e5b87"
integrity sha512-xaiO/VqqeSd5FnAkIKQINxC/q3Med33Lqw3LGxD4NBtkcMSh1Anz/+830QHVlQbp08nIPUXYV96hDrx1Uv0PmQ==
dependencies:
query-selector-shadow-dom "^1.0.1"

btoa@^1.2.1:
version "1.2.1"
Expand Down Expand Up @@ -2537,10 +2551,10 @@ fast-uri@^2.3.0:
resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-2.3.0.tgz#bdae493942483d299e7285dcb4627767d42e2793"
integrity sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==

fast-xml-parser@^4.2.5:
version "4.4.0"
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.4.0.tgz#341cc98de71e9ba9e651a67f41f1752d1441a501"
integrity sha512-kLY3jFlwIYwBNDojclKsNAC12sfD6NwW74QB2CoNGPvtVxjliYehVunB3HYyNi+n4Tt1dAcgwYvmKF/Z18flqg==
fast-xml-parser@^4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz#86dbf3f18edf8739326447bcaac31b4ae7f6514f"
integrity sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==
dependencies:
strnum "^1.0.5"

Expand Down Expand Up @@ -4611,6 +4625,11 @@ [email protected]:
dependencies:
side-channel "^1.0.4"

query-selector-shadow-dom@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/query-selector-shadow-dom/-/query-selector-shadow-dom-1.0.1.tgz#1c7b0058eff4881ac44f45d8f84ede32e9a2f349"
integrity sha512-lT5yCqEBgfoMYpf3F2xQRK7zEr1rhIIZuceDK6+xRkJQ4NMbHTwXqk4NkwDwQMNqXgG9r9fyHnzwNVs6zV5KRw==

queue-microtask@^1.2.2:
version "1.2.3"
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
Expand Down Expand Up @@ -5610,11 +5629,16 @@ tslib@^1.10.0, tslib@^1.9.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2.0.0, tslib@^2.1.0, tslib@^2.4.0, tslib@^2.6.1, tslib@^2.6.2:
tslib@^2.0.0, tslib@^2.4.0, tslib@^2.6.1, tslib@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==

tslib@^2.1.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01"
integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==

tsyringe@^4.8.0:
version "4.8.0"
resolved "https://registry.yarnpkg.com/tsyringe/-/tsyringe-4.8.0.tgz#d599651b36793ba872870fee4f845bd484a5cac1"
Expand Down Expand Up @@ -5819,7 +5843,7 @@ verror@^1.10.0:
core-util-is "1.0.2"
extsprintf "^1.2.0"

warcio@^2.2.0, warcio@^2.2.1:
warcio@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/warcio/-/warcio-2.2.1.tgz#3619728fde716291c9b364744c276362a94bacec"
integrity sha512-KPLoz3aFtdTjexG+QQaubMyuLiNANzvcadGMyNKdpcmhl0k6lBHQQVpxZw3Hx9+4pbyqDXyiF4cr/h2tS8kvcw==
Expand All @@ -5831,6 +5855,20 @@ warcio@^2.2.0, warcio@^2.2.1:
uuid-random "^1.3.2"
yargs "^17.6.2"

warcio@^2.3.0, warcio@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/warcio/-/warcio-2.3.1.tgz#8ac9de897de1a556161168f2a3938b60929908ca"
integrity sha512-PjcWqzXfs6HdWfHi1V/i8MoMmV5M0Csg3rOa2mqCJ1dmCJXswVfQ0VXbEVumwavNIW2oFFj6LJoCHHeL4Ls/zw==
dependencies:
"@types/pako" "^1.0.7"
"@types/stream-buffers" "^3.0.7"
base32-encode "^2.0.0"
hash-wasm "^4.9.0"
pako "^1.0.11"
tempy "^3.1.0"
uuid-random "^1.3.2"
yargs "^17.6.2"

watchpack@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.1.tgz#29308f2cac150fa8e4c92f90e0ec954a9fed7fff"
Expand Down

0 comments on commit 0a56b41

Please sign in to comment.