@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
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { MessageTypes, TransportRequestMessage } from '../types.js';
|
|
2
|
-
export { withErrorLog } from './helpers.js';
|
|
3
|
-
export default function handler<TMessageType extends MessageTypes>({ id, message, request }: TransportRequestMessage<TMessageType>, port?: chrome.runtime.Port, extensionPortName?: string): void;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { assert } from '@pezkuwi/util';
|
|
2
|
-
import { PORT_EXTENSION } from '../../defaults.js';
|
|
3
|
-
import Extension from './Extension.js';
|
|
4
|
-
import State from './State.js';
|
|
5
|
-
import Tabs from './Tabs.js';
|
|
6
|
-
export { withErrorLog } from './helpers.js';
|
|
7
|
-
const state = new State();
|
|
8
|
-
await state.init();
|
|
9
|
-
const extension = new Extension(state);
|
|
10
|
-
const tabs = new Tabs(state);
|
|
11
|
-
export default function handler({ id, message, request }, port, extensionPortName = PORT_EXTENSION) {
|
|
12
|
-
const isExtension = !port || port?.name === extensionPortName;
|
|
13
|
-
const sender = port?.sender;
|
|
14
|
-
if (!isExtension && !sender) {
|
|
15
|
-
throw new Error('Unable to extract message sender');
|
|
16
|
-
}
|
|
17
|
-
const from = isExtension
|
|
18
|
-
? 'extension'
|
|
19
|
-
: sender?.url || sender?.tab?.url || '<unknown>';
|
|
20
|
-
const source = `${from}: ${id}: ${message}`;
|
|
21
|
-
console.log(` [in] ${source}`); // :: ${JSON.stringify(request)}`);
|
|
22
|
-
const promise = isExtension
|
|
23
|
-
? extension.handle(id, message, request, port)
|
|
24
|
-
: tabs.handle(id, message, request, from, port);
|
|
25
|
-
promise
|
|
26
|
-
.then((response) => {
|
|
27
|
-
console.log(`[out] ${source}`); // :: ${JSON.stringify(response)}`);
|
|
28
|
-
// between the start and the end of the promise, the user may have closed
|
|
29
|
-
// the tab, in which case port will be undefined
|
|
30
|
-
assert(port, 'Port has been disconnected');
|
|
31
|
-
port.postMessage({ id, response });
|
|
32
|
-
})
|
|
33
|
-
.catch((error) => {
|
|
34
|
-
console.log(`[err] ${source}:: ${error.message}`);
|
|
35
|
-
// only send message back to port if it's still connected
|
|
36
|
-
if (port) {
|
|
37
|
-
port.postMessage({ error: error.message, id });
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { MessageTypesWithSubscriptions, SubscriptionMessageTypes } from '../types.js';
|
|
2
|
-
export declare function createSubscription<TMessageType extends MessageTypesWithSubscriptions>(id: string, port: chrome.runtime.Port): (data: SubscriptionMessageTypes[TMessageType]) => void;
|
|
3
|
-
export declare function unsubscribe(id: string): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const subscriptions = {};
|
|
2
|
-
export function createSubscription(id, port) {
|
|
3
|
-
subscriptions[id] = port;
|
|
4
|
-
return (subscription) => {
|
|
5
|
-
if (subscriptions[id]) {
|
|
6
|
-
port.postMessage({ id, subscription });
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export function unsubscribe(id) {
|
|
11
|
-
if (subscriptions[id]) {
|
|
12
|
-
console.log(`Unsubscribing from ${id}`);
|
|
13
|
-
delete subscriptions[id];
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
console.error(`Unable to unsubscribe from ${id}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
package/background/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as handlers, withErrorLog } from './handlers/index.js';
|
package/background/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as handlers, withErrorLog } from './handlers/index.js';
|
package/background/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/bundle.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { packageInfo } from './packageInfo.js';
|
package/bundle.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { packageInfo } from './packageInfo.js';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { KeyringPair } from '@pezkuwi/keyring/types';
|
|
2
|
-
import type { TypeRegistry } from '@pezkuwi/types';
|
|
3
|
-
import type { SignerPayloadRaw } from '@pezkuwi/types/types';
|
|
4
|
-
import type { HexString } from '@pezkuwi/util/types';
|
|
5
|
-
import type { RequestSign } from './types.js';
|
|
6
|
-
export default class RequestBytesSign implements RequestSign {
|
|
7
|
-
readonly payload: SignerPayloadRaw;
|
|
8
|
-
constructor(payload: SignerPayloadRaw);
|
|
9
|
-
sign(_registry: TypeRegistry, pair: KeyringPair): {
|
|
10
|
-
signature: HexString;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const util_1 = require("@pezkuwi/util");
|
|
4
|
-
class RequestBytesSign {
|
|
5
|
-
payload;
|
|
6
|
-
constructor(payload) {
|
|
7
|
-
this.payload = payload;
|
|
8
|
-
}
|
|
9
|
-
sign(_registry, pair) {
|
|
10
|
-
return {
|
|
11
|
-
signature: (0, util_1.u8aToHex)(pair.sign((0, util_1.u8aWrapBytes)(this.payload.data)))
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.default = RequestBytesSign;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { KeyringPair } from '@pezkuwi/keyring/types';
|
|
2
|
-
import type { TypeRegistry } from '@pezkuwi/types';
|
|
3
|
-
import type { SignerPayloadJSON } from '@pezkuwi/types/types';
|
|
4
|
-
import type { HexString } from '@pezkuwi/util/types';
|
|
5
|
-
import type { RequestSign } from './types.js';
|
|
6
|
-
export default class RequestExtrinsicSign implements RequestSign {
|
|
7
|
-
readonly payload: SignerPayloadJSON;
|
|
8
|
-
constructor(payload: SignerPayloadJSON);
|
|
9
|
-
sign(registry: TypeRegistry, pair: KeyringPair): {
|
|
10
|
-
signature: HexString;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class RequestExtrinsicSign {
|
|
4
|
-
payload;
|
|
5
|
-
constructor(payload) {
|
|
6
|
-
this.payload = payload;
|
|
7
|
-
}
|
|
8
|
-
sign(registry, pair) {
|
|
9
|
-
return registry
|
|
10
|
-
.createType('ExtrinsicPayload', this.payload, { version: this.payload.version })
|
|
11
|
-
.sign(pair);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.default = RequestExtrinsicSign;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { MessageTypes, RequestTypes, ResponseType } from '../types.js';
|
|
2
|
-
import type State from './State.js';
|
|
3
|
-
export default class Extension {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(state: State);
|
|
6
|
-
private transformAccounts;
|
|
7
|
-
private accountsCreateExternal;
|
|
8
|
-
private accountsCreateHardware;
|
|
9
|
-
private accountsCreateSuri;
|
|
10
|
-
private accountsChangePassword;
|
|
11
|
-
private accountsEdit;
|
|
12
|
-
private accountsExport;
|
|
13
|
-
private accountsBatchExport;
|
|
14
|
-
private accountsForget;
|
|
15
|
-
private refreshAccountPasswordCache;
|
|
16
|
-
private accountsShow;
|
|
17
|
-
private accountsTie;
|
|
18
|
-
private accountsValidate;
|
|
19
|
-
private accountsSubscribe;
|
|
20
|
-
private authorizeApprove;
|
|
21
|
-
private authorizeUpdate;
|
|
22
|
-
private getAuthList;
|
|
23
|
-
private authorizeSubscribe;
|
|
24
|
-
private metadataApprove;
|
|
25
|
-
private metadataGet;
|
|
26
|
-
private metadataList;
|
|
27
|
-
private metadataReject;
|
|
28
|
-
private metadataSubscribe;
|
|
29
|
-
private jsonRestore;
|
|
30
|
-
private batchRestore;
|
|
31
|
-
private jsonGetAccountInfo;
|
|
32
|
-
private seedCreate;
|
|
33
|
-
private seedValidate;
|
|
34
|
-
private signingApprovePassword;
|
|
35
|
-
private signingApproveSignature;
|
|
36
|
-
private signingCancel;
|
|
37
|
-
private signingIsLocked;
|
|
38
|
-
private signingSubscribe;
|
|
39
|
-
private windowOpen;
|
|
40
|
-
private derive;
|
|
41
|
-
private derivationValidate;
|
|
42
|
-
private derivationCreate;
|
|
43
|
-
private removeAuthorization;
|
|
44
|
-
private rejectAuthRequest;
|
|
45
|
-
private cancelAuthRequest;
|
|
46
|
-
private updateCurrentTabs;
|
|
47
|
-
private getConnectedTabsUrl;
|
|
48
|
-
handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port?: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
|
|
49
|
-
}
|