Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/extension-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"dependencies": {
"nanoevents": "^6.0.2",
"serialize-error": "^9.0.0",
"serialize-error": "9.1.0",
"tiny-uid": "^1.1.1",
"webextension-polyfill": "^0.8.0"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/extension/configs/base-build.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
const path = require("path");

const setConfig = (config) => {
config.devtool("source-map");
config.resolve.symlinks(false);
config.module
.rule("metaimport")
.test(/packageInfo\.js$/)
.include.add((path) => path.match(/@polkadot/))
.end()
.use("webpack-import-loader")
.loader("@open-wc/webpack-import-meta-loader")
.loader("./configs/meta-loader.js")
.end();
//polkadot-js has import.meta with # //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta
config.module
.rule("private-fields-loader")
.test(/\.js$/)
.test(/\.(js|cjs)$/)
.include.add((path) => path.match(/@polkadot/))
.end()
.use("private-fields-loader")
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/configs/chrome-build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const CopyWebpackPlugin = require("copy-webpack-plugin");

const scripts = {
background: "./src/scripts/background.ts",
background: "./src/scripts/chrome/background.ts",
};

const setConfig = (config) => {
Expand Down
13 changes: 13 additions & 0 deletions packages/extension/configs/meta-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const regex = /import\.meta/g;
module.exports = function (source) {
let found = false;
let rewrittenSource = source.replace(regex, () => {
found = true;
return false;
});
if (found) {
return rewrittenSource;
} else {
return source;
}
};
2 changes: 1 addition & 1 deletion packages/extension/configs/rollup.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export default {
commonjs(),
nodePolyfills(),
nodeResolve({ preferBuiltins: false }),
uglify(),
// uglify(),
],
};
3 changes: 1 addition & 2 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"@enkryptcom/utils": "^0.0.1",
"@polkadot/types": "^7.10.1",
"@polkadot/util": "^8.4.1",
"@types/chrome": "^0.0.180",
"@types/events": "^3.0.0",
"chai": "^4.3.6",
"concurrently": "^7.0.0",
"core-js": "^3.21.0",
"crx-hotreload": "^1.0.6",
"ethereumjs-util": "^7.1.4",
"eventemitter3": "^4.0.7",
"moment": "^2.29.1",
Expand All @@ -40,7 +40,6 @@
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@open-wc/webpack-import-meta-loader": "^0.4.7",
"@polkadot/api": "^7.10.1",
"@polkadot/extension-inject": "^0.42.7",
"@polkadot/rpc-provider": "^7.10.1",
Expand Down
42 changes: 0 additions & 42 deletions packages/extension/public/dev/hot-reload.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/extension/src/libs/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BackgroundHandler {
// this.#keyring.addEthereumAddress("abc").then((key) => {
// console.log("added", key);
// });
// this.#keyring.addPolkadotAddress("def").then((key) => {
// this.#keyring.addPolkadotAddress("def1").then((key) => {
// console.log("added", key);
// });
// });
Expand Down
21 changes: 14 additions & 7 deletions packages/extension/src/manifest/manifest-chrome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "https://www.enkrypt.com",
"homepage_url": "https://www.enkrypt.com",
"browser_action": {
"action": {
"default_icon": {
"16": "assets/img/icons/icon16.png",
"32": "assets/img/icons/icon32.png",
Expand All @@ -11,8 +11,8 @@
"default_title": "Enkrypt",
"default_popup": "popup.html"
},
"version": "0.1.0",
"manifest_version": 2,
"version": "0.3.0",
"manifest_version": 3,
"name": "Enkrypt",
"short_name": "Enkrypt",
"permissions": [
Expand All @@ -24,8 +24,7 @@
"tabs"
],
"background": {
"scripts": ["scripts/background.js", "dev/hot-reload.js"],
"persistent": true
"service_worker": "scripts/background.js"
},
"commands": {
"_execute_browser_action": {
Expand All @@ -52,7 +51,15 @@
"48": "assets/img/icons/icon48.png",
"192": "assets/img/icons/icon192.png"
},
"web_accessible_resources": ["scripts/inject.js"],
"web_accessible_resources": [
{
"resources": ["scripts/inject.js"],
"use_dynamic_url": false,
"matches": ["file://*/*", "http://*/*", "https://*/*"]
}
],
"minimum_chrome_version": "63",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import "./hot-reload";
import "@polkadot/wasm-crypto/initOnlyAsm"; //chrome extension v3 doesnt support webassembly

import {
backgroundOnMessageFromWindow,
backgroundOnMessageFromNewWindow,
Expand Down
63 changes: 63 additions & 0 deletions packages/extension/src/scripts/chrome/hot-reload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import browser from "webextension-polyfill";
import { keccakFromString } from "ethereumjs-util";
const filesToMonitor = {
content: {
path: "scripts/contentscript.js",
hash: "",
},
inject: {
path: "scripts/inject.js",
hash: "",
},
background: {
path: "scripts/background.js",
hash: "",
},
action: {
path: "action.html",
hash: "",
},
index: {
path: "index.html",
hash: "",
},
manifest: {
path: "manifest.json",
hash: "",
},
};
const checkFilesChanged = async () => {
let filesChanged = false;
for (const value of Object.values(filesToMonitor)) {
const exturl = browser.runtime.getURL(value.path);
await fetch(exturl)
.then((res) => res.text())
.then((content) => {
const hash = keccakFromString(content).toString("hex");
if (value.hash !== hash) {
filesChanged = true;
value.hash = hash;
}
});
}
return filesChanged;
};
const watchChanges = async () => {
await checkFilesChanged();
setInterval(async () => {
const filesChanged = await checkFilesChanged();
if (filesChanged) {
chrome.runtime.reload();
}
}, 2000);
};
browser.management.getSelf().then((self) => {
if (self.installType === "development") {
watchChanges();
chrome.tabs.query({ active: true, lastFocusedWindow: true }, (tabs) => {
if (tabs[0] && tabs[0].id) {
chrome.tabs.reload(tabs[0].id);
}
});
}
});
20 changes: 8 additions & 12 deletions packages/extension/src/scripts/contentscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ import { setContentScriptNamespace } from "@/libs/messenger/extension";

setContentScriptNamespace();

const injectURL = browser.runtime.getURL("scripts/inject.js");
fetch(injectURL).then((response) => {
response.text().then((inpageContent) => {
const inpageSuffix = `//# sourceURL=${injectURL}\n`;
const inpageBundle = inpageContent + inpageSuffix;
injectScript(inpageBundle);
});
});
function injectScript(content: string) {
function injectScript() {
try {
const injectURL = browser.runtime.getURL("scripts/inject.js");
const container = document.head || document.documentElement;
const scriptTag = document.createElement("script");
scriptTag.setAttribute("async", "false");
scriptTag.textContent = content;
scriptTag.src = injectURL;
scriptTag.onload = function () {
console.log("Hello from the content-script");
container.removeChild(scriptTag);
};
container.insertBefore(scriptTag, container.children[0]);
container.removeChild(scriptTag);
} catch (error) {
// eslint-disable-next-line no-console
console.error("Enkrypt: Provider injection failed.", error);
}
}
console.log("Hello from the content-script");
injectScript();
2 changes: 1 addition & 1 deletion packages/extension/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"sourceMap": true,
"types": ["mocha", "webpack-env"],
"types": ["mocha", "webpack-env", "chrome"],
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
Expand Down
2 changes: 1 addition & 1 deletion packages/request/.yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"yarn": true
}
}
}
}
3 changes: 2 additions & 1 deletion packages/request/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# @enkryptcom/request
## Network requests class for enkrypt extension

## Network requests class for enkrypt extension
1 change: 1 addition & 0 deletions packages/signers/polkadot/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"no-underscore-dangle": "off",
"no-continue": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-console": "off",
"no-plusplus": "off",
"class-methods-use-this": "off",
Expand Down
10 changes: 6 additions & 4 deletions packages/signers/polkadot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
"node": ">=14.15.0"
},
"dependencies": {
"@commitlint/cli": "^16.1.0",
"@enkryptcom/utils": "^0.0.1",
"@polkadot/util-crypto": "^8.4.1",
"@polkadot/wasm-crypto": "^4.5.1",
"@polkadot/util": "^8.5.1",
"@polkadot/util-crypto": "^8.6.1",
"@polkadot/wasm-crypto": "^5.0.1",
"assert": "^2.0.0",
"chai": "^4.3.6"
},
Expand All @@ -40,9 +42,9 @@
"ts-mocha": "^9.0.2",
"ts-node": "^10.5.0",
"tsconfig-paths": "^3.12.0",
"tsup": "^5.11.13",
"typescript": "^4.5.5",
"typescript-eslint": "0.0.1-alpha.0",
"tsup": "^5.11.13"
"typescript-eslint": "0.0.1-alpha.0"
},
"repository": {
"type": "git",
Expand Down
Loading