towards webextension working again
This commit is contained in:
parent
c2dcad8efe
commit
172a51a43a
1
packages/taler-wallet-webextension/.gitignore
vendored
Normal file
1
packages/taler-wallet-webextension/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
taler-wallet-*.zip
|
@ -18,8 +18,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"32": "img/icon.png",
|
"32": "static/img/icon.png",
|
||||||
"128": "img/logo.png"
|
"128": "static/img/logo.png"
|
||||||
},
|
},
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
@ -36,14 +36,14 @@
|
|||||||
|
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_icon": {
|
"default_icon": {
|
||||||
"32": "img/icon.png"
|
"32": "static/img/icon.png"
|
||||||
},
|
},
|
||||||
"default_title": "Taler",
|
"default_title": "Taler",
|
||||||
"default_popup": "popup.html"
|
"default_popup": "static/popup.html"
|
||||||
},
|
},
|
||||||
|
|
||||||
"background": {
|
"background": {
|
||||||
"page": "background.html",
|
"page": "static/background.html",
|
||||||
"persistent": true
|
"persistent": true
|
||||||
}
|
}
|
||||||
}
|
}
|
15
packages/taler-wallet-webextension/pack.sh
Executable file
15
packages/taler-wallet-webextension/pack.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if [[ ! -e package.json ]]; then
|
||||||
|
echo "Please run this from the root of the repo.">&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
vers_manifest=$(jq -r '.version' manifest.json)
|
||||||
|
|
||||||
|
zipfile="taler-wallet-${vers_manifest}.zip"
|
||||||
|
|
||||||
|
rm -f -- "$zipfile"
|
||||||
|
zip -r "$zipfile" dist static manifest.json
|
@ -9,7 +9,8 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tsc && ava",
|
"test": "tsc && ava",
|
||||||
"compile": "tsc"
|
"clean": "rimraf dist lib tsconfig.tsbuildinfo",
|
||||||
|
"compile": "tsc && rollup -c"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"moment": "^2.27.0",
|
"moment": "^2.27.0",
|
||||||
@ -33,7 +34,9 @@
|
|||||||
"enzyme-adapter-react-16": "^1.15.2",
|
"enzyme-adapter-react-16": "^1.15.2",
|
||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"react-dom": "^16.13.1",
|
"react-dom": "^16.13.1",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "^2.23.0",
|
"rollup": "^2.23.0",
|
||||||
|
"rollup-plugin-ignore": "^1.0.9",
|
||||||
"rollup-plugin-sourcemaps": "^0.6.2",
|
"rollup-plugin-sourcemaps": "^0.6.2",
|
||||||
"rollup-plugin-terser": "^6.1.0",
|
"rollup-plugin-terser": "^6.1.0",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^3.9.7"
|
||||||
|
@ -2,210 +2,96 @@
|
|||||||
import commonjs from "@rollup/plugin-commonjs";
|
import commonjs from "@rollup/plugin-commonjs";
|
||||||
import nodeResolve from "@rollup/plugin-node-resolve";
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
||||||
import json from "@rollup/plugin-json";
|
import json from "@rollup/plugin-json";
|
||||||
import replace from "@rollup/plugin-replace";
|
|
||||||
import builtins from "builtin-modules";
|
import builtins from "builtin-modules";
|
||||||
import { terser } from "rollup-plugin-terser";
|
import replace from "@rollup/plugin-replace";
|
||||||
import typescript from "@rollup/plugin-typescript";
|
import ignore from "rollup-plugin-ignore"
|
||||||
|
|
||||||
// Base settings to use
|
|
||||||
const baseTypescriptCompilerSettings = {
|
|
||||||
target: "ES6",
|
|
||||||
jsx: "react",
|
|
||||||
reactNamespace: "React",
|
|
||||||
moduleResolution: "node",
|
|
||||||
sourceMap: true,
|
|
||||||
lib: ["es6", "dom"],
|
|
||||||
noImplicitReturns: true,
|
|
||||||
noFallthroughCasesInSwitch: true,
|
|
||||||
strict: true,
|
|
||||||
strictPropertyInitialization: false,
|
|
||||||
noImplicitAny: true,
|
|
||||||
noImplicitThis: true,
|
|
||||||
allowJs: true,
|
|
||||||
checkJs: true,
|
|
||||||
incremental: false,
|
|
||||||
esModuleInterop: true,
|
|
||||||
importHelpers: true,
|
|
||||||
module: "ESNext",
|
|
||||||
include: ["src/**/*.+(ts|tsx)"],
|
|
||||||
rootDir: "./src",
|
|
||||||
};
|
|
||||||
|
|
||||||
const walletCli = {
|
|
||||||
input: "src/headless/taler-wallet-cli.ts",
|
|
||||||
output: {
|
|
||||||
file: "dist/standalone/taler-wallet-cli.js",
|
|
||||||
format: "cjs",
|
|
||||||
},
|
|
||||||
external: builtins,
|
|
||||||
plugins: [
|
|
||||||
nodeResolve({
|
|
||||||
preferBuiltins: true,
|
|
||||||
}),
|
|
||||||
|
|
||||||
commonjs({
|
|
||||||
include: ["node_modules/**", "dist/node/**"],
|
|
||||||
extensions: [".js", ".ts"],
|
|
||||||
ignoreGlobal: false, // Default: false
|
|
||||||
sourceMap: false,
|
|
||||||
ignore: ["taler-wallet"],
|
|
||||||
}),
|
|
||||||
|
|
||||||
json(),
|
|
||||||
|
|
||||||
typescript({
|
|
||||||
tsconfig: false,
|
|
||||||
...baseTypescriptCompilerSettings,
|
|
||||||
sourceMap: false,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const walletAndroid = {
|
|
||||||
input: "src/android/index.ts",
|
|
||||||
output: {
|
|
||||||
//dir: "dist/standalone",
|
|
||||||
file: "dist/standalone/taler-wallet-android.js",
|
|
||||||
format: "cjs",
|
|
||||||
exports: "named",
|
|
||||||
},
|
|
||||||
external: builtins,
|
|
||||||
plugins: [
|
|
||||||
json(),
|
|
||||||
|
|
||||||
nodeResolve({
|
|
||||||
preferBuiltins: true,
|
|
||||||
}),
|
|
||||||
|
|
||||||
commonjs({
|
|
||||||
include: ["node_modules/**"],
|
|
||||||
extensions: [".js"],
|
|
||||||
sourceMap: false,
|
|
||||||
ignore: ["taler-wallet"],
|
|
||||||
}),
|
|
||||||
|
|
||||||
typescript({
|
|
||||||
tsconfig: false,
|
|
||||||
...baseTypescriptCompilerSettings,
|
|
||||||
sourceMap: false,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const webExtensionPageEntryPoint = {
|
const webExtensionPageEntryPoint = {
|
||||||
input: "src/webex/pageEntryPoint.ts",
|
input: "lib/pageEntryPoint.js",
|
||||||
output: {
|
output: {
|
||||||
file: "dist/webextension/pageEntryPoint.js",
|
file: "dist/pageEntryPoint.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
exports: "none",
|
exports: "none",
|
||||||
name: "webExtensionPageEntry",
|
name: "webExtensionPageEntry",
|
||||||
},
|
},
|
||||||
external: builtins,
|
|
||||||
plugins: [
|
plugins: [
|
||||||
json(),
|
json(),
|
||||||
|
|
||||||
|
ignore(builtins),
|
||||||
|
|
||||||
nodeResolve({
|
nodeResolve({
|
||||||
preferBuiltins: true,
|
browser: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
terser(),
|
//terser(),
|
||||||
|
|
||||||
replace({
|
replace({
|
||||||
"process.env.NODE_ENV": JSON.stringify("production"),
|
"process.env.NODE_ENV": JSON.stringify("production"),
|
||||||
|
"__filename": "'__webextension__'",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
commonjs({
|
commonjs(),
|
||||||
include: ["node_modules/**", "dist/node/**"],
|
|
||||||
extensions: [".js"],
|
|
||||||
sourceMap: false,
|
|
||||||
ignore: ["taler-wallet"],
|
|
||||||
}),
|
|
||||||
|
|
||||||
typescript({
|
|
||||||
tsconfig: false,
|
|
||||||
...baseTypescriptCompilerSettings,
|
|
||||||
sourceMap: false,
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const webExtensionBackgroundPageScript = {
|
const webExtensionBackgroundPageScript = {
|
||||||
input: "src/webex/background.ts",
|
input: "lib/background.js",
|
||||||
output: {
|
output: {
|
||||||
file: "dist/webextension/background.js",
|
file: "dist/background.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
exports: "none",
|
exports: "none",
|
||||||
name: "webExtensionBackgroundScript",
|
name: "webExtensionBackgroundScript",
|
||||||
},
|
},
|
||||||
external: builtins,
|
|
||||||
plugins: [
|
plugins: [
|
||||||
json(),
|
json(),
|
||||||
|
|
||||||
|
ignore(builtins),
|
||||||
|
|
||||||
nodeResolve({
|
nodeResolve({
|
||||||
preferBuiltins: true,
|
browser: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
terser(),
|
//terser(),
|
||||||
|
|
||||||
replace({
|
replace({
|
||||||
"process.env.NODE_ENV": JSON.stringify("production"),
|
"process.env.NODE_ENV": JSON.stringify("production"),
|
||||||
|
"__filename": "'__webextension__'",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
commonjs({
|
commonjs()
|
||||||
include: ["node_modules/**", "dist/node/**"],
|
|
||||||
extensions: [".js"],
|
|
||||||
sourceMap: false,
|
|
||||||
ignore: ["taler-wallet", "crypto"],
|
|
||||||
}),
|
|
||||||
|
|
||||||
typescript({
|
|
||||||
tsconfig: false,
|
|
||||||
...baseTypescriptCompilerSettings,
|
|
||||||
sourceMap: false,
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const webExtensionCryptoWorker = {
|
const webExtensionCryptoWorker = {
|
||||||
input: "src/crypto/workers/browserWorkerEntry.ts",
|
input: "lib/browserWorkerEntry.js",
|
||||||
output: {
|
output: {
|
||||||
file: "dist/webextension/browserWorkerEntry.js",
|
file: "dist/browserWorkerEntry.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
exports: "none",
|
exports: "none",
|
||||||
name: "webExtensionCryptoWorker",
|
name: "webExtensionCryptoWorker",
|
||||||
},
|
},
|
||||||
external: builtins,
|
|
||||||
plugins: [
|
plugins: [
|
||||||
json(),
|
json(),
|
||||||
|
|
||||||
|
ignore(builtins),
|
||||||
|
|
||||||
nodeResolve({
|
nodeResolve({
|
||||||
preferBuiltins: true,
|
browser: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
terser(),
|
//terser(),
|
||||||
|
|
||||||
replace({
|
replace({
|
||||||
"process.env.NODE_ENV": JSON.stringify("production"),
|
"process.env.NODE_ENV": JSON.stringify("production"),
|
||||||
|
"__filename": "'__webextension__'",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
commonjs({
|
commonjs(),
|
||||||
include: ["node_modules/**", "dist/node/**"],
|
|
||||||
extensions: [".js"],
|
|
||||||
sourceMap: false,
|
|
||||||
ignore: ["taler-wallet", "crypto"],
|
|
||||||
}),
|
|
||||||
|
|
||||||
typescript({
|
|
||||||
tsconfig: false,
|
|
||||||
...baseTypescriptCompilerSettings,
|
|
||||||
sourceMap: false,
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
walletCli,
|
|
||||||
walletAndroid,
|
|
||||||
webExtensionPageEntryPoint,
|
webExtensionPageEntryPoint,
|
||||||
webExtensionBackgroundPageScript,
|
webExtensionBackgroundPageScript,
|
||||||
webExtensionCryptoWorker,
|
webExtensionCryptoWorker,
|
||||||
|
@ -24,7 +24,7 @@ import type { CryptoWorker, CryptoWorkerFactory } from "taler-wallet-core";
|
|||||||
export class BrowserCryptoWorkerFactory implements CryptoWorkerFactory {
|
export class BrowserCryptoWorkerFactory implements CryptoWorkerFactory {
|
||||||
startWorker(): CryptoWorker {
|
startWorker(): CryptoWorker {
|
||||||
const workerCtor = Worker;
|
const workerCtor = Worker;
|
||||||
const workerPath = "/browserWorkerEntry.js";
|
const workerPath = "/dist/browserWorkerEntry.js";
|
||||||
return new workerCtor(workerPath) as CryptoWorker;
|
return new workerCtor(workerPath) as CryptoWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,8 @@ function setupHeaderListener(): void {
|
|||||||
// Handlers for catching HTTP requests
|
// Handlers for catching HTTP requests
|
||||||
getPermissionsApi().contains(extendedPermissions, (result: boolean) => {
|
getPermissionsApi().contains(extendedPermissions, (result: boolean) => {
|
||||||
if (
|
if (
|
||||||
chrome.webRequest.onHeadersReceived &&
|
"webRequest" in chrome &&
|
||||||
|
"onHeadersReceived" in chrome.webRequest &&
|
||||||
chrome.webRequest.onHeadersReceived.hasListener(headerListener)
|
chrome.webRequest.onHeadersReceived.hasListener(headerListener)
|
||||||
) {
|
) {
|
||||||
chrome.webRequest.onHeadersReceived.removeListener(headerListener);
|
chrome.webRequest.onHeadersReceived.removeListener(headerListener);
|
||||||
@ -509,11 +510,13 @@ function setupHeaderListener(): void {
|
|||||||
["responseHeaders", "blocking"],
|
["responseHeaders", "blocking"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
chrome.webRequest.handlerBehaviorChanged(() => {
|
if ("webRequest" in chrome) {
|
||||||
if (chrome.runtime.lastError) {
|
chrome.webRequest.handlerBehaviorChanged(() => {
|
||||||
console.error(chrome.runtime.lastError);
|
if (chrome.runtime.lastError) {
|
||||||
}
|
console.error(chrome.runtime.lastError);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<script src="/background.js"></script>
|
<script src="/dist/background.js"></script>
|
||||||
<title>(wallet bg page)</title>
|
<title>(wallet bg page)</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<img id="taler-logo" src="/img/icon.png" />
|
<img id="taler-logo" src="/static/img/icon.png" />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 830 B |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
@ -3,17 +3,20 @@
|
|||||||
"composite": true,
|
"composite": true,
|
||||||
"lib": ["es6", "DOM"],
|
"lib": ["es6", "DOM"],
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
|
"moduleResolution": "Node",
|
||||||
"reactNamespace": "React",
|
"reactNamespace": "React",
|
||||||
"module": "commonjs",
|
"module": "ESNext",
|
||||||
"target": "es5",
|
"target": "ES6",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"declaration": true,
|
|
||||||
"noEmitOnError": true,
|
"noEmitOnError": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true,
|
||||||
|
"importHelpers": true,
|
||||||
|
"rootDir": "./src",
|
||||||
|
"typeRoots": ["./node_modules/@types"]
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"]
|
"include": ["src/**/*"]
|
||||||
}
|
}
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
if [[ ! -e package.json ]]; then
|
|
||||||
echo "Please run this from the root of the repo.">&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
vers_manifest=$(jq -r '.version' webextension/manifest.json)
|
|
||||||
|
|
||||||
rm -rf dist/wx
|
|
||||||
mkdir -p dist/wx
|
|
||||||
cp webextension/manifest.json dist/wx/
|
|
||||||
cp -r webextension/static/* dist/wx/
|
|
||||||
cp -r dist/webextension/* dist/wx/
|
|
||||||
|
|
||||||
cd dist/wx
|
|
||||||
|
|
||||||
zipfile="../taler-wallet-${vers_manifest}.zip"
|
|
||||||
|
|
||||||
rm -f -- "$zipfile"
|
|
||||||
zip -r "$zipfile" ./*
|
|
@ -199,7 +199,9 @@ importers:
|
|||||||
enzyme-adapter-react-16: 1.15.2_df2dc313d8031f8c2dbd009d86ca7fc7
|
enzyme-adapter-react-16: 1.15.2_df2dc313d8031f8c2dbd009d86ca7fc7
|
||||||
react: 16.13.1
|
react: 16.13.1
|
||||||
react-dom: 16.13.1_react@16.13.1
|
react-dom: 16.13.1_react@16.13.1
|
||||||
|
rimraf: 3.0.2
|
||||||
rollup: 2.23.0
|
rollup: 2.23.0
|
||||||
|
rollup-plugin-ignore: 1.0.9
|
||||||
rollup-plugin-sourcemaps: 0.6.2_1bb4f16ce5b550396581a296af208cfa
|
rollup-plugin-sourcemaps: 0.6.2_1bb4f16ce5b550396581a296af208cfa
|
||||||
rollup-plugin-terser: 6.1.0_rollup@2.23.0
|
rollup-plugin-terser: 6.1.0_rollup@2.23.0
|
||||||
typescript: 3.9.7
|
typescript: 3.9.7
|
||||||
@ -221,7 +223,9 @@ importers:
|
|||||||
moment: ^2.27.0
|
moment: ^2.27.0
|
||||||
react: ^16.13.1
|
react: ^16.13.1
|
||||||
react-dom: ^16.13.1
|
react-dom: ^16.13.1
|
||||||
|
rimraf: ^3.0.2
|
||||||
rollup: ^2.23.0
|
rollup: ^2.23.0
|
||||||
|
rollup-plugin-ignore: ^1.0.9
|
||||||
rollup-plugin-sourcemaps: ^0.6.2
|
rollup-plugin-sourcemaps: ^0.6.2
|
||||||
rollup-plugin-terser: ^6.1.0
|
rollup-plugin-terser: ^6.1.0
|
||||||
taler-wallet-core: 'workspace:*'
|
taler-wallet-core: 'workspace:*'
|
||||||
@ -4109,6 +4113,10 @@ packages:
|
|||||||
hasBin: true
|
hasBin: true
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
|
integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
|
||||||
|
/rollup-plugin-ignore/1.0.9:
|
||||||
|
dev: true
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-+Q2jmD4gbO3ByFuljkDEfpEcYvll7J5+ZadUuk/Pu35x2KGrbHxKtt3+s+dPIgXX1mG7zCxG4s/NdRqztR5Ruw==
|
||||||
/rollup-plugin-sourcemaps/0.6.2_1bb4f16ce5b550396581a296af208cfa:
|
/rollup-plugin-sourcemaps/0.6.2_1bb4f16ce5b550396581a296af208cfa:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@rollup/pluginutils': 3.1.0_rollup@2.23.0
|
'@rollup/pluginutils': 3.1.0_rollup@2.23.0
|
||||||
|
Loading…
Reference in New Issue
Block a user