Update domain references to pezkuwichain.app and rebrand from polkadot

This commit is contained in:
2026-01-06 12:21:11 +03:00
commit c2913a65d9
401 changed files with 23179 additions and 0 deletions
+109
View File
@@ -0,0 +1,109 @@
// Copyright 2019-2025 @pezkuwi/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Runs in the extension background, handling all keyring access
/* global chrome */
import '@pezkuwi/extension-inject/crossenv';
import type { RequestSignatures, TransportRequestMessage } from '@pezkuwi/extension-base/background/types';
import { handlers, withErrorLog } from '@pezkuwi/extension-base/background';
import { PORT_CONTENT, PORT_EXTENSION } from '@pezkuwi/extension-base/defaults';
import { AccountsStore } from '@pezkuwi/extension-base/stores';
import { keyring } from '@pezkuwi/ui-keyring';
import { assert } from '@pezkuwi/util';
import { cryptoWaitReady } from '@pezkuwi/util-crypto';
// setup the notification (same a FF default background, white text)
withErrorLog(() => chrome.action.setBadgeBackgroundColor({ color: '#d90000' }));
// listen to all messages and handle appropriately
chrome.runtime.onConnect.addListener((port): void => {
// shouldn't happen, however... only listen to what we know about
assert([PORT_CONTENT, PORT_EXTENSION].includes(port.name), `Unknown connection from ${port.name}`);
// message and disconnect handlers
port.onMessage.addListener((data: TransportRequestMessage<keyof RequestSignatures>) => handlers(data, port));
port.onDisconnect.addListener(() => console.log(`Disconnected from ${port.name}`));
});
function isValidUrl (url: string) {
try {
const urlObj = new URL(url);
return urlObj.protocol === 'http:' || urlObj.protocol === 'https:';
} catch (_e) {
return false;
}
}
function getActiveTabs () {
// queriing the current active tab in the current window should only ever return 1 tab
// although an array is specified here
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
// get the urls of the active tabs. Only http or https urls are supported. Other urls will be filtered out.
// e.g. browser tabs like chrome://newtab/, chrome://extensions/, about:addons etc will be filtered out
// we filter these out
const urls: string[] = tabs
.map(({ url }) => url)
.filter((url) => !!url && isValidUrl(url)) as string[];
const request: TransportRequestMessage<'pri(activeTabsUrl.update)'> = {
id: 'background',
message: 'pri(activeTabsUrl.update)',
origin: 'background',
request: { urls }
};
handlers(request);
});
}
chrome.runtime.onMessage.addListener((message: { type: string }, _, sendResponse) => {
if (message.type === 'wakeup') {
sendResponse({ status: 'awake' });
}
});
// listen to tab updates this is fired on url change
chrome.tabs.onUpdated.addListener((_, changeInfo) => {
// we are only interested in url change
if (!changeInfo.url) {
return;
}
getActiveTabs();
});
// the list of active tab changes when switching window
// in a mutli window setup
chrome.windows.onFocusChanged.addListener(() =>
getActiveTabs()
);
// when clicking on an existing tab or opening a new tab this will be fired
// before the url is entered by users
chrome.tabs.onActivated.addListener(() => {
getActiveTabs();
});
// when deleting a tab this will be fired
chrome.tabs.onRemoved.addListener(() => {
getActiveTabs();
});
// initial setup
cryptoWaitReady()
.then((): void => {
console.log('crypto initialized');
// load all the keyring data
keyring.loadAll({ store: new AccountsStore(), type: 'sr25519' });
console.log('initialization completed');
})
.catch((error): void => {
console.error('initialization failed', error);
});
+51
View File
@@ -0,0 +1,51 @@
// Copyright 2019-2025 @pezkuwi/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Message } from '@pezkuwi/extension-base/types';
import { MESSAGE_ORIGIN_CONTENT, MESSAGE_ORIGIN_PAGE, PORT_CONTENT } from '@pezkuwi/extension-base/defaults';
import { ensurePortConnection } from '@pezkuwi/extension-base/utils/portUtils';
import { chrome } from '@pezkuwi/extension-inject/chrome';
let port: chrome.runtime.Port | undefined;
function onPortMessageHandler (data: Message['data']): void {
window.postMessage({ ...data, origin: MESSAGE_ORIGIN_CONTENT }, '*');
}
function onPortDisconnectHandler (): void {
port = undefined;
}
const portConfig = {
onPortDisconnectHandler,
onPortMessageHandler,
portName: PORT_CONTENT
};
// all messages from the page, pass them to the extension
window.addEventListener('message', ({ data, source }: Message): void => {
// only allow messages from our window, by the inject
if (source !== window || data.origin !== MESSAGE_ORIGIN_PAGE) {
return;
}
ensurePortConnection(port, portConfig).then((connectedPort) => {
connectedPort.postMessage(data);
port = connectedPort;
}).catch((error) => console.error(`Failed to send message: ${(error as Error).message}`));
});
// inject our data injector
const script = document.createElement('script');
script.src = chrome.runtime.getURL('page.js');
script.onload = (): void => {
// remove the injecting tag when loaded
if (script.parentNode) {
script.parentNode.removeChild(script);
}
};
(document.head || document.documentElement).appendChild(script);
+8
View File
@@ -0,0 +1,8 @@
// Copyright 2019-2025 @pezkuwi/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
import '@pezkuwi/extension-inject/crossenv';
import { createView, Popup } from '@pezkuwi/extension-ui';
createView(Popup);
+11
View File
@@ -0,0 +1,11 @@
// Copyright 2017-2025 @pezkuwi/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Do not edit, auto-generated by @pezkuwi/dev
// (packageInfo imports will be kept as-is, user-editable)
import { detectPackage } from '@pezkuwi/util';
import { packageInfo } from './packageInfo.js';
detectPackage(packageInfo, null, []);
+6
View File
@@ -0,0 +1,6 @@
// Copyright 2017-2025 @pezkuwi/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Do not edit, auto-generated by @pezkuwi/dev
export const packageInfo = { name: '@pezkuwi/extension', path: 'auto', type: 'auto', version: '0.62.6' };
+35
View File
@@ -0,0 +1,35 @@
// Copyright 2019-2025 @pezkuwi/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { RequestSignatures, TransportRequestMessage } from '@pezkuwi/extension-base/background/types';
import type { Message } from '@pezkuwi/extension-base/types';
import { MESSAGE_ORIGIN_CONTENT } from '@pezkuwi/extension-base/defaults';
import { enable, handleResponse, redirectIfPhishing } from '@pezkuwi/extension-base/page';
import { injectExtension } from '@pezkuwi/extension-inject';
import { packageInfo } from './packageInfo.js';
function inject () {
injectExtension(enable, {
name: 'polkadot-js',
version: packageInfo.version
});
}
// setup a response listener (events created by the loader for extension responses)
window.addEventListener('message', ({ data, source }: Message): void => {
// only allow messages from our window, by the loader
if (source !== window || data.origin !== MESSAGE_ORIGIN_CONTENT) {
return;
}
if (data.id) {
handleResponse(data as TransportRequestMessage<keyof RequestSignatures>);
} else {
console.error('Missing id for response.');
}
});
inject();
redirectIfPhishing().catch((e) => console.warn(`Unable to determine if the site is in the phishing list: ${(e as Error).message}`));