@pezkuwi/extension-base 0.62.14 → 0.62.18
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/package.json +16 -470
- package/src/background/RequestBytesSign.ts +28 -0
- package/src/background/RequestExtrinsicSign.ts +22 -0
- package/src/background/handlers/Extension.spec.ts +478 -0
- package/src/background/handlers/Extension.ts +690 -0
- package/src/background/handlers/State.ts +664 -0
- package/src/background/handlers/Tabs.ts +289 -0
- package/src/background/handlers/helpers.ts +14 -0
- package/src/background/handlers/index.ts +60 -0
- package/src/background/handlers/subscriptions.ts +32 -0
- package/src/background/index.ts +4 -0
- package/src/background/types.ts +432 -0
- package/src/bundle.ts +4 -0
- package/{defaults.js → src/defaults.ts} +15 -2
- package/src/index.ts +7 -0
- package/{packageDetect.js → src/packageDetect.ts} +8 -0
- package/src/packageInfo.ts +6 -0
- package/src/page/Accounts.ts +33 -0
- package/src/page/Injected.ts +33 -0
- package/src/page/Metadata.ts +22 -0
- package/src/page/PostMessageProvider.ts +182 -0
- package/src/page/Signer.ts +45 -0
- package/src/page/index.ts +89 -0
- package/src/page/types.ts +10 -0
- package/src/stores/Accounts.ts +28 -0
- package/src/stores/Base.ts +93 -0
- package/src/stores/Metadata.ts +17 -0
- package/{stores/index.js → src/stores/index.ts} +3 -0
- package/src/types.ts +12 -0
- package/src/utils/canDerive.ts +8 -0
- package/src/utils/getId.ts +10 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/portUtils.ts +65 -0
- package/tsconfig.build.json +16 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.spec.json +18 -0
- package/tsconfig.spec.tsbuildinfo +1 -0
- package/LICENSE +0 -201
- package/background/RequestBytesSign.d.ts +0 -12
- package/background/RequestBytesSign.js +0 -12
- package/background/RequestExtrinsicSign.d.ts +0 -12
- package/background/RequestExtrinsicSign.js +0 -11
- package/background/handlers/Extension.d.ts +0 -49
- package/background/handlers/Extension.js +0 -489
- package/background/handlers/State.js +0 -478
- package/background/handlers/Tabs.d.ts +0 -25
- package/background/handlers/Tabs.js +0 -195
- package/background/handlers/helpers.js +0 -11
- package/background/handlers/index.d.ts +0 -3
- package/background/handlers/index.js +0 -40
- package/background/handlers/subscriptions.d.ts +0 -3
- package/background/handlers/subscriptions.js +0 -18
- package/background/index.d.ts +0 -1
- package/background/index.js +0 -1
- package/background/types.js +0 -1
- package/bundle.d.ts +0 -1
- package/bundle.js +0 -1
- package/cjs/background/RequestBytesSign.d.ts +0 -12
- package/cjs/background/RequestBytesSign.js +0 -15
- package/cjs/background/RequestExtrinsicSign.d.ts +0 -12
- package/cjs/background/RequestExtrinsicSign.js +0 -14
- package/cjs/background/handlers/Extension.d.ts +0 -49
- package/cjs/background/handlers/Extension.js +0 -492
- package/cjs/background/handlers/State.d.ts +0 -96
- package/cjs/background/handlers/State.js +0 -482
- package/cjs/background/handlers/Tabs.d.ts +0 -25
- package/cjs/background/handlers/Tabs.js +0 -199
- package/cjs/background/handlers/helpers.d.ts +0 -1
- package/cjs/background/handlers/helpers.js +0 -14
- package/cjs/background/handlers/index.d.ts +0 -3
- package/cjs/background/handlers/index.js +0 -46
- package/cjs/background/handlers/subscriptions.d.ts +0 -3
- package/cjs/background/handlers/subscriptions.js +0 -22
- package/cjs/background/index.d.ts +0 -1
- package/cjs/background/index.js +0 -7
- package/cjs/background/types.d.ts +0 -343
- package/cjs/background/types.js +0 -2
- package/cjs/bundle.d.ts +0 -1
- package/cjs/bundle.js +0 -5
- package/cjs/defaults.js +0 -16
- package/cjs/index.d.ts +0 -1
- package/cjs/index.js +0 -4
- package/cjs/package.json +0 -3
- package/cjs/packageDetect.d.ts +0 -1
- package/cjs/packageDetect.js +0 -8
- package/cjs/packageInfo.d.ts +0 -6
- package/cjs/packageInfo.js +0 -4
- package/cjs/page/Accounts.d.ts +0 -7
- package/cjs/page/Accounts.js +0 -24
- package/cjs/page/Injected.d.ts +0 -13
- package/cjs/page/Injected.js +0 -25
- package/cjs/page/Metadata.d.ts +0 -7
- package/cjs/page/Metadata.js +0 -15
- package/cjs/page/PostMessageProvider.d.ts +0 -63
- package/cjs/page/PostMessageProvider.js +0 -135
- package/cjs/page/Signer.d.ts +0 -8
- package/cjs/page/Signer.js +0 -29
- package/cjs/page/index.d.ts +0 -16
- package/cjs/page/index.js +0 -52
- package/cjs/page/types.d.ts +0 -6
- package/cjs/page/types.js +0 -2
- package/cjs/stores/Accounts.js +0 -21
- package/cjs/stores/Base.js +0 -70
- package/cjs/stores/Metadata.js +0 -13
- package/cjs/stores/index.js +0 -8
- package/cjs/types.js +0 -2
- package/cjs/utils/canDerive.d.ts +0 -2
- package/cjs/utils/canDerive.js +0 -6
- package/cjs/utils/getId.js +0 -8
- package/cjs/utils/index.d.ts +0 -1
- package/cjs/utils/index.js +0 -5
- package/cjs/utils/portUtils.d.ts +0 -13
- package/cjs/utils/portUtils.js +0 -49
- package/defaults.d.ts +0 -9
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/packageDetect.d.ts +0 -1
- package/packageInfo.d.ts +0 -6
- package/packageInfo.js +0 -1
- package/page/Accounts.d.ts +0 -7
- package/page/Accounts.js +0 -21
- package/page/Injected.d.ts +0 -13
- package/page/Injected.js +0 -21
- package/page/Metadata.d.ts +0 -7
- package/page/Metadata.js +0 -12
- package/page/PostMessageProvider.d.ts +0 -63
- package/page/PostMessageProvider.js +0 -132
- package/page/Signer.d.ts +0 -8
- package/page/Signer.js +0 -26
- package/page/index.d.ts +0 -16
- package/page/index.js +0 -45
- package/page/types.d.ts +0 -6
- package/page/types.js +0 -1
- package/stores/Accounts.d.ts +0 -6
- package/stores/Accounts.js +0 -17
- package/stores/Base.d.ts +0 -9
- package/stores/Base.js +0 -67
- package/stores/Metadata.d.ts +0 -5
- package/stores/Metadata.js +0 -9
- package/stores/index.d.ts +0 -2
- package/types.d.ts +0 -9
- package/types.js +0 -1
- package/utils/canDerive.d.ts +0 -2
- package/utils/canDerive.js +0 -3
- package/utils/getId.d.ts +0 -1
- package/utils/getId.js +0 -5
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -1
- package/utils/portUtils.d.ts +0 -13
- package/utils/portUtils.js +0 -43
- /package/{background → src/background}/handlers/State.d.ts +0 -0
- /package/{background → src/background}/handlers/helpers.d.ts +0 -0
- /package/{background → src/background}/types.d.ts +0 -0
- /package/{cjs → src}/defaults.d.ts +0 -0
- /package/{cjs → src}/stores/Accounts.d.ts +0 -0
- /package/{cjs → src}/stores/Base.d.ts +0 -0
- /package/{cjs → src}/stores/Metadata.d.ts +0 -0
- /package/{cjs → src}/stores/index.d.ts +0 -0
- /package/{cjs → src}/types.d.ts +0 -0
- /package/{cjs → src}/utils/getId.d.ts +0 -0
package/utils/portUtils.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Message } from '@pezkuwi/extension-base/types';
|
|
2
|
-
export declare function setupPort(portName: string, onMessageHandler: (data: Message['data']) => void, onDisconnectHandler: () => void): chrome.runtime.Port;
|
|
3
|
-
export declare function wakeUpServiceWorker(): Promise<{
|
|
4
|
-
status: string;
|
|
5
|
-
}>;
|
|
6
|
-
export declare const wakeUpServiceWorkerWrapper: {
|
|
7
|
-
wakeUpServiceWorker: typeof wakeUpServiceWorker;
|
|
8
|
-
};
|
|
9
|
-
export declare function ensurePortConnection(portRef: chrome.runtime.Port | undefined, portConfig: {
|
|
10
|
-
portName: string;
|
|
11
|
-
onPortMessageHandler: (data: Message['data']) => void;
|
|
12
|
-
onPortDisconnectHandler: () => void;
|
|
13
|
-
}): Promise<chrome.runtime.Port>;
|
package/utils/portUtils.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { chrome } from '@pezkuwi/extension-inject/chrome';
|
|
2
|
-
export function setupPort(portName, onMessageHandler, onDisconnectHandler) {
|
|
3
|
-
const port = chrome.runtime.connect({ name: portName });
|
|
4
|
-
port.onMessage.addListener(onMessageHandler);
|
|
5
|
-
port.onDisconnect.addListener(() => {
|
|
6
|
-
console.log(`Disconnected from ${portName}`);
|
|
7
|
-
onDisconnectHandler();
|
|
8
|
-
});
|
|
9
|
-
return port;
|
|
10
|
-
}
|
|
11
|
-
export async function wakeUpServiceWorker() {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
chrome.runtime.sendMessage({ type: 'wakeup' }, (response) => {
|
|
14
|
-
if (chrome.runtime.lastError) {
|
|
15
|
-
reject(new Error(chrome.runtime.lastError.message));
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
resolve(response);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export const wakeUpServiceWorkerWrapper = { wakeUpServiceWorker };
|
|
24
|
-
export async function ensurePortConnection(portRef, portConfig) {
|
|
25
|
-
const maxAttempts = 5;
|
|
26
|
-
const delayMs = 1000;
|
|
27
|
-
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
28
|
-
try {
|
|
29
|
-
const response = await wakeUpServiceWorkerWrapper.wakeUpServiceWorker();
|
|
30
|
-
if (response?.status === 'awake') {
|
|
31
|
-
if (!portRef) {
|
|
32
|
-
return setupPort(portConfig.portName, portConfig.onPortMessageHandler, portConfig.onPortDisconnectHandler);
|
|
33
|
-
}
|
|
34
|
-
return portRef;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.error(`Attempt ${attempt + 1} failed: ${error.message}`);
|
|
39
|
-
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
throw new Error('Failed to wake up the service worker and setup the port after multiple attempts');
|
|
43
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{cjs → src}/types.d.ts
RENAMED
|
File without changes
|
|
File without changes
|