@pezkuwi/extension-base 0.62.8
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/README.md +12 -0
- package/build/background/RequestBytesSign.d.ts +12 -0
- package/build/background/RequestBytesSign.js +15 -0
- package/build/background/RequestExtrinsicSign.d.ts +12 -0
- package/build/background/RequestExtrinsicSign.js +14 -0
- package/build/background/handlers/Extension.d.ts +49 -0
- package/build/background/handlers/Extension.js +645 -0
- package/build/background/handlers/State.d.ts +96 -0
- package/build/background/handlers/State.js +732 -0
- package/build/background/handlers/Tabs.d.ts +25 -0
- package/build/background/handlers/Tabs.js +313 -0
- package/build/background/handlers/helpers.d.ts +1 -0
- package/build/background/handlers/helpers.js +13 -0
- package/build/background/handlers/index.d.ts +3 -0
- package/build/background/handlers/index.js +45 -0
- package/build/background/handlers/subscriptions.d.ts +3 -0
- package/build/background/handlers/subscriptions.js +22 -0
- package/build/background/index.d.ts +1 -0
- package/build/background/index.js +3 -0
- package/build/background/types.d.ts +343 -0
- package/build/background/types.js +3 -0
- package/build/bundle.d.ts +1 -0
- package/build/bundle.js +3 -0
- package/build/defaults.d.ts +9 -0
- package/build/defaults.js +17 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +5 -0
- package/build/packageDetect.d.ts +1 -0
- package/build/packageDetect.js +10 -0
- package/build/packageInfo.d.ts +6 -0
- package/build/packageInfo.js +4 -0
- package/build/page/Accounts.d.ts +7 -0
- package/build/page/Accounts.js +26 -0
- package/build/page/Injected.d.ts +13 -0
- package/build/page/Injected.js +21 -0
- package/build/page/Metadata.d.ts +7 -0
- package/build/page/Metadata.js +17 -0
- package/build/page/PostMessageProvider.d.ts +63 -0
- package/build/page/PostMessageProvider.js +234 -0
- package/build/page/Signer.d.ts +8 -0
- package/build/page/Signer.js +92 -0
- package/build/page/index.d.ts +16 -0
- package/build/page/index.js +102 -0
- package/build/page/types.d.ts +6 -0
- package/build/page/types.js +3 -0
- package/build/stores/Accounts.d.ts +6 -0
- package/build/stores/Accounts.js +83 -0
- package/build/stores/Base.d.ts +9 -0
- package/build/stores/Base.js +250 -0
- package/build/stores/Metadata.d.ts +5 -0
- package/build/stores/Metadata.js +29 -0
- package/build/stores/index.d.ts +2 -0
- package/build/stores/index.js +4 -0
- package/build/types.d.ts +9 -0
- package/build/types.js +3 -0
- package/build/utils/canDerive.d.ts +2 -0
- package/build/utils/canDerive.js +5 -0
- package/build/utils/getId.d.ts +1 -0
- package/build/utils/getId.js +7 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +3 -0
- package/build/utils/portUtils.d.ts +14 -0
- package/build/utils/portUtils.js +106 -0
- package/package.json +45 -0
- 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/src/defaults.ts +26 -0
- package/src/index.ts +7 -0
- package/src/packageDetect.ts +14 -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/src/stores/index.ts +5 -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
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import type { InjectedAccount, InjectedMetadataKnown, MetadataDef, ProviderList, ProviderMeta } from '@pezkuwi/extension-inject/types';
|
|
2
|
+
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '@pezkuwi/keyring/types';
|
|
3
|
+
import type { JsonRpcResponse } from '@pezkuwi/rpc-provider/types';
|
|
4
|
+
import type { Registry, SignerPayloadJSON, SignerPayloadRaw } from '@pezkuwi/types/types';
|
|
5
|
+
import type { KeyringPairs$Json } from '@pezkuwi/ui-keyring/types';
|
|
6
|
+
import type { HexString } from '@pezkuwi/util/types';
|
|
7
|
+
import type { KeypairType } from '@pezkuwi/util-crypto/types';
|
|
8
|
+
import type { ALLOWED_PATH } from '../defaults.js';
|
|
9
|
+
import type { AuthResponse } from './handlers/State.js';
|
|
10
|
+
type KeysWithDefinedValues<T> = {
|
|
11
|
+
[K in keyof T]: T[K] extends undefined ? never : K;
|
|
12
|
+
}[keyof T];
|
|
13
|
+
type NoUndefinedValues<T> = {
|
|
14
|
+
[K in KeysWithDefinedValues<T>]: T[K];
|
|
15
|
+
};
|
|
16
|
+
type IsNull<T, K extends keyof T> = {
|
|
17
|
+
[K1 in Exclude<keyof T, K>]: T[K1];
|
|
18
|
+
} & T[K] extends null ? K : never;
|
|
19
|
+
type NullKeys<T> = {
|
|
20
|
+
[K in keyof T]: IsNull<T, K>;
|
|
21
|
+
}[keyof T];
|
|
22
|
+
export type AuthUrls = Record<string, AuthUrlInfo>;
|
|
23
|
+
export interface AuthUrlInfo {
|
|
24
|
+
count: number;
|
|
25
|
+
id: string;
|
|
26
|
+
isAllowed?: boolean;
|
|
27
|
+
origin: string;
|
|
28
|
+
url: string;
|
|
29
|
+
authorizedAccounts: string[];
|
|
30
|
+
}
|
|
31
|
+
export type SeedLengths = 12 | 24;
|
|
32
|
+
export interface AccountJson extends KeyringPair$Meta {
|
|
33
|
+
address: string;
|
|
34
|
+
}
|
|
35
|
+
export type AccountWithChildren = AccountJson & {
|
|
36
|
+
children?: AccountWithChildren[];
|
|
37
|
+
};
|
|
38
|
+
export interface AccountsContext {
|
|
39
|
+
accounts: AccountJson[];
|
|
40
|
+
hierarchy: AccountWithChildren[];
|
|
41
|
+
master?: AccountJson;
|
|
42
|
+
selectedAccounts?: AccountJson['address'][];
|
|
43
|
+
setSelectedAccounts?: (address: AccountJson['address'][]) => void;
|
|
44
|
+
}
|
|
45
|
+
export interface AuthorizeRequest {
|
|
46
|
+
id: string;
|
|
47
|
+
request: RequestAuthorizeTab;
|
|
48
|
+
url: string;
|
|
49
|
+
}
|
|
50
|
+
export interface MetadataRequest {
|
|
51
|
+
id: string;
|
|
52
|
+
request: MetadataDef;
|
|
53
|
+
url: string;
|
|
54
|
+
}
|
|
55
|
+
export interface SigningRequest {
|
|
56
|
+
account: AccountJson;
|
|
57
|
+
id: string;
|
|
58
|
+
request: RequestSign;
|
|
59
|
+
url: string;
|
|
60
|
+
}
|
|
61
|
+
export type ConnectedTabsUrlResponse = string[];
|
|
62
|
+
export interface RequestSignatures {
|
|
63
|
+
'pri(accounts.create.external)': [RequestAccountCreateExternal, boolean];
|
|
64
|
+
'pri(accounts.create.hardware)': [RequestAccountCreateHardware, boolean];
|
|
65
|
+
'pri(accounts.create.suri)': [RequestAccountCreateSuri, boolean];
|
|
66
|
+
'pri(accounts.edit)': [RequestAccountEdit, boolean];
|
|
67
|
+
'pri(accounts.export)': [RequestAccountExport, ResponseAccountExport];
|
|
68
|
+
'pri(accounts.batchExport)': [RequestAccountBatchExport, ResponseAccountsExport];
|
|
69
|
+
'pri(accounts.forget)': [RequestAccountForget, boolean];
|
|
70
|
+
'pri(accounts.list)': [RequestAccountList, InjectedAccount[]];
|
|
71
|
+
'pri(accounts.show)': [RequestAccountShow, boolean];
|
|
72
|
+
'pri(accounts.tie)': [RequestAccountTie, boolean];
|
|
73
|
+
'pri(accounts.subscribe)': [RequestAccountSubscribe, boolean, AccountJson[]];
|
|
74
|
+
'pri(accounts.validate)': [RequestAccountValidate, boolean];
|
|
75
|
+
'pri(accounts.changePassword)': [RequestAccountChangePassword, boolean];
|
|
76
|
+
'pri(authorize.approve)': [RequestAuthorizeApprove, boolean];
|
|
77
|
+
'pri(authorize.list)': [null, ResponseAuthorizeList];
|
|
78
|
+
'pri(authorize.requests)': [RequestAuthorizeSubscribe, boolean, AuthorizeRequest[]];
|
|
79
|
+
'pri(authorize.remove)': [string, ResponseAuthorizeList];
|
|
80
|
+
'pri(authorize.reject)': [string, void];
|
|
81
|
+
'pri(authorize.cancel)': [string, void];
|
|
82
|
+
'pri(authorize.update)': [RequestUpdateAuthorizedAccounts, void];
|
|
83
|
+
'pri(activeTabsUrl.update)': [RequestActiveTabsUrlUpdate, void];
|
|
84
|
+
'pri(connectedTabsUrl.get)': [null, ConnectedTabsUrlResponse];
|
|
85
|
+
'pri(derivation.create)': [RequestDeriveCreate, boolean];
|
|
86
|
+
'pri(derivation.validate)': [RequestDeriveValidate, ResponseDeriveValidate];
|
|
87
|
+
'pri(json.restore)': [RequestJsonRestore, void];
|
|
88
|
+
'pri(json.batchRestore)': [RequestBatchRestore, void];
|
|
89
|
+
'pri(json.account.info)': [KeyringPair$Json, ResponseJsonGetAccountInfo];
|
|
90
|
+
'pri(metadata.approve)': [RequestMetadataApprove, boolean];
|
|
91
|
+
'pri(metadata.get)': [string | null, MetadataDef | null];
|
|
92
|
+
'pri(metadata.reject)': [RequestMetadataReject, boolean];
|
|
93
|
+
'pri(metadata.requests)': [RequestMetadataSubscribe, boolean, MetadataRequest[]];
|
|
94
|
+
'pri(metadata.list)': [null, MetadataDef[]];
|
|
95
|
+
'pri(ping)': [null, boolean];
|
|
96
|
+
'pri(seed.create)': [RequestSeedCreate, ResponseSeedCreate];
|
|
97
|
+
'pri(seed.validate)': [RequestSeedValidate, ResponseSeedValidate];
|
|
98
|
+
'pri(settings.notification)': [string, boolean];
|
|
99
|
+
'pri(signing.approve.password)': [RequestSigningApprovePassword, boolean];
|
|
100
|
+
'pri(signing.approve.signature)': [RequestSigningApproveSignature, boolean];
|
|
101
|
+
'pri(signing.cancel)': [RequestSigningCancel, boolean];
|
|
102
|
+
'pri(signing.isLocked)': [RequestSigningIsLocked, ResponseSigningIsLocked];
|
|
103
|
+
'pri(signing.requests)': [RequestSigningSubscribe, boolean, SigningRequest[]];
|
|
104
|
+
'pri(window.open)': [AllowedPath, boolean];
|
|
105
|
+
'pub(accounts.list)': [RequestAccountList, InjectedAccount[]];
|
|
106
|
+
'pub(accounts.subscribe)': [RequestAccountSubscribe, string, InjectedAccount[]];
|
|
107
|
+
'pub(accounts.unsubscribe)': [RequestAccountUnsubscribe, boolean];
|
|
108
|
+
'pub(authorize.tab)': [RequestAuthorizeTab, Promise<AuthResponse>];
|
|
109
|
+
'pub(bytes.sign)': [SignerPayloadRaw, ResponseSigning];
|
|
110
|
+
'pub(extrinsic.sign)': [SignerPayloadJSON, ResponseSigning];
|
|
111
|
+
'pub(metadata.list)': [null, InjectedMetadataKnown[]];
|
|
112
|
+
'pub(metadata.provide)': [MetadataDef, boolean];
|
|
113
|
+
'pub(phishing.redirectIfDenied)': [null, boolean];
|
|
114
|
+
'pub(ping)': [null, boolean];
|
|
115
|
+
'pub(rpc.listProviders)': [void, ResponseRpcListProviders];
|
|
116
|
+
'pub(rpc.send)': [RequestRpcSend, JsonRpcResponse<unknown>];
|
|
117
|
+
'pub(rpc.startProvider)': [string, ProviderMeta];
|
|
118
|
+
'pub(rpc.subscribe)': [RequestRpcSubscribe, number, JsonRpcResponse<unknown>];
|
|
119
|
+
'pub(rpc.subscribeConnected)': [null, boolean, boolean];
|
|
120
|
+
'pub(rpc.unsubscribe)': [RequestRpcUnsubscribe, boolean];
|
|
121
|
+
}
|
|
122
|
+
export type MessageTypes = keyof RequestSignatures;
|
|
123
|
+
export type RequestTypes = {
|
|
124
|
+
[MessageType in keyof RequestSignatures]: RequestSignatures[MessageType][0];
|
|
125
|
+
};
|
|
126
|
+
export type MessageTypesWithNullRequest = NullKeys<RequestTypes>;
|
|
127
|
+
export interface TransportRequestMessage<TMessageType extends MessageTypes> {
|
|
128
|
+
id: string;
|
|
129
|
+
message: TMessageType;
|
|
130
|
+
origin: string;
|
|
131
|
+
request: RequestTypes[TMessageType];
|
|
132
|
+
}
|
|
133
|
+
export interface RequestAuthorizeTab {
|
|
134
|
+
origin: string;
|
|
135
|
+
}
|
|
136
|
+
export interface RequestAuthorizeApprove {
|
|
137
|
+
id: string;
|
|
138
|
+
authorizedAccounts: string[];
|
|
139
|
+
}
|
|
140
|
+
export interface RequestUpdateAuthorizedAccounts {
|
|
141
|
+
url: string;
|
|
142
|
+
authorizedAccounts: string[];
|
|
143
|
+
}
|
|
144
|
+
export type RequestAuthorizeSubscribe = null;
|
|
145
|
+
export interface RequestMetadataApprove {
|
|
146
|
+
id: string;
|
|
147
|
+
}
|
|
148
|
+
export interface RequestMetadataReject {
|
|
149
|
+
id: string;
|
|
150
|
+
}
|
|
151
|
+
export type RequestMetadataSubscribe = null;
|
|
152
|
+
export interface RequestAccountCreateExternal {
|
|
153
|
+
address: string;
|
|
154
|
+
genesisHash?: HexString | null;
|
|
155
|
+
name: string;
|
|
156
|
+
}
|
|
157
|
+
export interface RequestAccountCreateSuri {
|
|
158
|
+
name: string;
|
|
159
|
+
genesisHash?: HexString | null;
|
|
160
|
+
password: string;
|
|
161
|
+
suri: string;
|
|
162
|
+
type?: KeypairType;
|
|
163
|
+
}
|
|
164
|
+
export interface RequestAccountCreateHardware {
|
|
165
|
+
accountIndex: number;
|
|
166
|
+
address: string;
|
|
167
|
+
addressOffset: number;
|
|
168
|
+
genesisHash: HexString;
|
|
169
|
+
hardwareType: string;
|
|
170
|
+
name: string;
|
|
171
|
+
type: KeypairType;
|
|
172
|
+
}
|
|
173
|
+
export interface RequestAccountChangePassword {
|
|
174
|
+
address: string;
|
|
175
|
+
oldPass: string;
|
|
176
|
+
newPass: string;
|
|
177
|
+
}
|
|
178
|
+
export interface RequestAccountEdit {
|
|
179
|
+
address: string;
|
|
180
|
+
genesisHash?: HexString | null;
|
|
181
|
+
name: string;
|
|
182
|
+
}
|
|
183
|
+
export interface RequestAccountForget {
|
|
184
|
+
address: string;
|
|
185
|
+
}
|
|
186
|
+
export interface RequestAccountShow {
|
|
187
|
+
address: string;
|
|
188
|
+
isShowing: boolean;
|
|
189
|
+
}
|
|
190
|
+
export interface RequestAccountTie {
|
|
191
|
+
address: string;
|
|
192
|
+
genesisHash: HexString | null;
|
|
193
|
+
}
|
|
194
|
+
export interface RequestAccountValidate {
|
|
195
|
+
address: string;
|
|
196
|
+
password: string;
|
|
197
|
+
}
|
|
198
|
+
export interface RequestDeriveCreate {
|
|
199
|
+
name: string;
|
|
200
|
+
genesisHash?: HexString | null;
|
|
201
|
+
suri: string;
|
|
202
|
+
parentAddress: string;
|
|
203
|
+
parentPassword: string;
|
|
204
|
+
password: string;
|
|
205
|
+
}
|
|
206
|
+
export interface RequestDeriveValidate {
|
|
207
|
+
suri: string;
|
|
208
|
+
parentAddress: string;
|
|
209
|
+
parentPassword: string;
|
|
210
|
+
}
|
|
211
|
+
export interface RequestAccountExport {
|
|
212
|
+
address: string;
|
|
213
|
+
password: string;
|
|
214
|
+
}
|
|
215
|
+
export interface RequestAccountBatchExport {
|
|
216
|
+
addresses: string[];
|
|
217
|
+
password: string;
|
|
218
|
+
}
|
|
219
|
+
export interface RequestAccountList {
|
|
220
|
+
anyType?: boolean;
|
|
221
|
+
}
|
|
222
|
+
export type RequestAccountSubscribe = null;
|
|
223
|
+
export interface RequestActiveTabsUrlUpdate {
|
|
224
|
+
urls: string[];
|
|
225
|
+
}
|
|
226
|
+
export interface RequestAccountUnsubscribe {
|
|
227
|
+
id: string;
|
|
228
|
+
}
|
|
229
|
+
export interface RequestRpcSend {
|
|
230
|
+
method: string;
|
|
231
|
+
params: unknown[];
|
|
232
|
+
}
|
|
233
|
+
export interface RequestRpcSubscribe extends RequestRpcSend {
|
|
234
|
+
type: string;
|
|
235
|
+
}
|
|
236
|
+
export interface RequestRpcUnsubscribe {
|
|
237
|
+
method: string;
|
|
238
|
+
subscriptionId: number | string;
|
|
239
|
+
type: string;
|
|
240
|
+
}
|
|
241
|
+
export interface RequestSigningApprovePassword {
|
|
242
|
+
id: string;
|
|
243
|
+
password?: string;
|
|
244
|
+
savePass: boolean;
|
|
245
|
+
}
|
|
246
|
+
export interface RequestSigningApproveSignature {
|
|
247
|
+
id: string;
|
|
248
|
+
signature: HexString;
|
|
249
|
+
signedTransaction?: HexString;
|
|
250
|
+
}
|
|
251
|
+
export interface RequestSigningCancel {
|
|
252
|
+
id: string;
|
|
253
|
+
}
|
|
254
|
+
export interface RequestSigningIsLocked {
|
|
255
|
+
id: string;
|
|
256
|
+
}
|
|
257
|
+
export interface ResponseSigningIsLocked {
|
|
258
|
+
isLocked: boolean;
|
|
259
|
+
remainingTime: number;
|
|
260
|
+
}
|
|
261
|
+
export type RequestSigningSubscribe = null;
|
|
262
|
+
export interface RequestSeedCreate {
|
|
263
|
+
length?: SeedLengths;
|
|
264
|
+
seed?: string;
|
|
265
|
+
type?: KeypairType;
|
|
266
|
+
}
|
|
267
|
+
export interface RequestSeedValidate {
|
|
268
|
+
suri: string;
|
|
269
|
+
type?: KeypairType;
|
|
270
|
+
}
|
|
271
|
+
export type ResponseTypes = {
|
|
272
|
+
[MessageType in keyof RequestSignatures]: RequestSignatures[MessageType][1];
|
|
273
|
+
};
|
|
274
|
+
export type ResponseType<TMessageType extends keyof RequestSignatures> = RequestSignatures[TMessageType][1];
|
|
275
|
+
interface TransportResponseMessageSub<TMessageType extends MessageTypesWithSubscriptions> {
|
|
276
|
+
error?: string;
|
|
277
|
+
id: string;
|
|
278
|
+
response?: ResponseTypes[TMessageType];
|
|
279
|
+
subscription?: SubscriptionMessageTypes[TMessageType];
|
|
280
|
+
}
|
|
281
|
+
interface TransportResponseMessageNoSub<TMessageType extends MessageTypesWithNoSubscriptions> {
|
|
282
|
+
error?: string;
|
|
283
|
+
id: string;
|
|
284
|
+
response?: ResponseTypes[TMessageType];
|
|
285
|
+
}
|
|
286
|
+
export type TransportResponseMessage<TMessageType extends MessageTypes> = TMessageType extends MessageTypesWithNoSubscriptions ? TransportResponseMessageNoSub<TMessageType> : TMessageType extends MessageTypesWithSubscriptions ? TransportResponseMessageSub<TMessageType> : never;
|
|
287
|
+
export interface ResponseSigning {
|
|
288
|
+
id: string;
|
|
289
|
+
signature: HexString;
|
|
290
|
+
signedTransaction?: HexString;
|
|
291
|
+
}
|
|
292
|
+
export interface ResponseDeriveValidate {
|
|
293
|
+
address: string;
|
|
294
|
+
suri: string;
|
|
295
|
+
}
|
|
296
|
+
export interface ResponseSeedCreate {
|
|
297
|
+
address: string;
|
|
298
|
+
seed: string;
|
|
299
|
+
}
|
|
300
|
+
export interface ResponseSeedValidate {
|
|
301
|
+
address: string;
|
|
302
|
+
suri: string;
|
|
303
|
+
}
|
|
304
|
+
export interface ResponseAccountExport {
|
|
305
|
+
exportedJson: KeyringPair$Json;
|
|
306
|
+
}
|
|
307
|
+
export interface ResponseAccountsExport {
|
|
308
|
+
exportedJson: KeyringPairs$Json;
|
|
309
|
+
}
|
|
310
|
+
export type ResponseRpcListProviders = ProviderList;
|
|
311
|
+
export type SubscriptionMessageTypes = NoUndefinedValues<{
|
|
312
|
+
[MessageType in keyof RequestSignatures]: RequestSignatures[MessageType][2];
|
|
313
|
+
}>;
|
|
314
|
+
export type MessageTypesWithSubscriptions = keyof SubscriptionMessageTypes;
|
|
315
|
+
export type MessageTypesWithNoSubscriptions = Exclude<MessageTypes, keyof SubscriptionMessageTypes>;
|
|
316
|
+
export interface RequestSign {
|
|
317
|
+
readonly payload: SignerPayloadJSON | SignerPayloadRaw;
|
|
318
|
+
sign(registry: Registry, pair: KeyringPair): {
|
|
319
|
+
signature: HexString;
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
export interface RequestJsonRestore {
|
|
323
|
+
file: KeyringPair$Json;
|
|
324
|
+
password: string;
|
|
325
|
+
}
|
|
326
|
+
export interface RequestBatchRestore {
|
|
327
|
+
file: KeyringPairs$Json;
|
|
328
|
+
password: string;
|
|
329
|
+
}
|
|
330
|
+
export interface ResponseJsonRestore {
|
|
331
|
+
error: string | null;
|
|
332
|
+
}
|
|
333
|
+
export type AllowedPath = typeof ALLOWED_PATH[number];
|
|
334
|
+
export interface ResponseJsonGetAccountInfo {
|
|
335
|
+
address: string;
|
|
336
|
+
name: string;
|
|
337
|
+
genesisHash: HexString;
|
|
338
|
+
type: KeypairType;
|
|
339
|
+
}
|
|
340
|
+
export interface ResponseAuthorizeList {
|
|
341
|
+
list: AuthUrls;
|
|
342
|
+
}
|
|
343
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { packageInfo } from './packageInfo.js';
|
package/build/bundle.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const EXTENSION_PREFIX: string;
|
|
2
|
+
export declare const PORT_CONTENT: string;
|
|
3
|
+
export declare const PORT_EXTENSION: string;
|
|
4
|
+
export declare const MESSAGE_ORIGIN_PAGE: string;
|
|
5
|
+
export declare const MESSAGE_ORIGIN_CONTENT: string;
|
|
6
|
+
export declare const ALLOWED_PATH: readonly ["/", "/account/import-ledger", "/account/restore-json"];
|
|
7
|
+
export declare const PASSWORD_EXPIRY_MIN = 15;
|
|
8
|
+
export declare const PASSWORD_EXPIRY_MS: number;
|
|
9
|
+
export declare const PHISHING_PAGE_REDIRECT = "/phishing-page-detected";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2019-2025 @pezkuwi/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// this _must_ be changed for each extension
|
|
4
|
+
export var EXTENSION_PREFIX = process.env['EXTENSION_PREFIX'] || '';
|
|
5
|
+
if (!EXTENSION_PREFIX && !process.env['PORT_PREFIX']) {
|
|
6
|
+
throw new Error('CRITICAL: The extension does not define an own EXTENSION_PREFIX environment variable as part of the build, this is required to ensure that messages are not shared between extensions. Failure to do so will yield messages sent to multiple extensions.');
|
|
7
|
+
}
|
|
8
|
+
var PORT_PREFIX = "".concat(EXTENSION_PREFIX || 'unknown', "-").concat(process.env['PORT_PREFIX'] || 'unknown');
|
|
9
|
+
export var PORT_CONTENT = "".concat(PORT_PREFIX, "-content");
|
|
10
|
+
export var PORT_EXTENSION = "".concat(PORT_PREFIX, "-extension");
|
|
11
|
+
export var MESSAGE_ORIGIN_PAGE = "".concat(PORT_PREFIX, "-page");
|
|
12
|
+
export var MESSAGE_ORIGIN_CONTENT = "".concat(PORT_PREFIX, "-content");
|
|
13
|
+
export var ALLOWED_PATH = ['/', '/account/import-ledger', '/account/restore-json'];
|
|
14
|
+
export var PASSWORD_EXPIRY_MIN = 15;
|
|
15
|
+
export var PASSWORD_EXPIRY_MS = PASSWORD_EXPIRY_MIN * 60 * 1000;
|
|
16
|
+
export var PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
|
|
17
|
+
// console.log(`Extension is sending and receiving messages on ${PORT_PREFIX}-*`);
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bundle.js';
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2017-2025 @pezkuwi/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Do not edit, auto-generated by @pezkuwi/dev
|
|
4
|
+
// (packageInfo imports will be kept as-is, user-editable)
|
|
5
|
+
import { packageInfo as chainsInfo } from '@pezkuwi/extension-chains/packageInfo';
|
|
6
|
+
import { packageInfo as dappInfo } from '@pezkuwi/extension-dapp/packageInfo';
|
|
7
|
+
import { packageInfo as injectInfo } from '@pezkuwi/extension-inject/packageInfo';
|
|
8
|
+
import { detectPackage } from '@pezkuwi/util';
|
|
9
|
+
import { packageInfo } from './packageInfo.js';
|
|
10
|
+
detectPackage(packageInfo, null, [chainsInfo, dappInfo, injectInfo]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InjectedAccount, InjectedAccounts, Unsubcall } from '@pezkuwi/extension-inject/types';
|
|
2
|
+
import type { SendRequest } from './types.js';
|
|
3
|
+
export default class Accounts implements InjectedAccounts {
|
|
4
|
+
constructor(_sendRequest: SendRequest);
|
|
5
|
+
get(anyType?: boolean): Promise<InjectedAccount[]>;
|
|
6
|
+
subscribe(cb: (accounts: InjectedAccount[]) => unknown): Unsubcall;
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2019-2025 @pezkuwi/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// External to class, this.# is not private enough (yet)
|
|
4
|
+
var sendRequest;
|
|
5
|
+
var Accounts = /** @class */ (function () {
|
|
6
|
+
function Accounts(_sendRequest) {
|
|
7
|
+
sendRequest = _sendRequest;
|
|
8
|
+
}
|
|
9
|
+
Accounts.prototype.get = function (anyType) {
|
|
10
|
+
return sendRequest('pub(accounts.list)', { anyType: anyType });
|
|
11
|
+
};
|
|
12
|
+
Accounts.prototype.subscribe = function (cb) {
|
|
13
|
+
var id = null;
|
|
14
|
+
sendRequest('pub(accounts.subscribe)', null, cb)
|
|
15
|
+
.then(function (subId) {
|
|
16
|
+
id = subId;
|
|
17
|
+
})
|
|
18
|
+
.catch(console.error);
|
|
19
|
+
return function () {
|
|
20
|
+
id && sendRequest('pub(accounts.unsubscribe)', { id: id })
|
|
21
|
+
.catch(console.error);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
return Accounts;
|
|
25
|
+
}());
|
|
26
|
+
export default Accounts;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Injected } from '@pezkuwi/extension-inject/types';
|
|
2
|
+
import type { SendRequest } from './types.js';
|
|
3
|
+
import Accounts from './Accounts.js';
|
|
4
|
+
import Metadata from './Metadata.js';
|
|
5
|
+
import PostMessageProvider from './PostMessageProvider.js';
|
|
6
|
+
import Signer from './Signer.js';
|
|
7
|
+
export default class implements Injected {
|
|
8
|
+
readonly accounts: Accounts;
|
|
9
|
+
readonly metadata: Metadata;
|
|
10
|
+
readonly provider: PostMessageProvider;
|
|
11
|
+
readonly signer: Signer;
|
|
12
|
+
constructor(sendRequest: SendRequest);
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2019-2025 @pezkuwi/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import Accounts from './Accounts.js';
|
|
4
|
+
import Metadata from './Metadata.js';
|
|
5
|
+
import PostMessageProvider from './PostMessageProvider.js';
|
|
6
|
+
import Signer from './Signer.js';
|
|
7
|
+
var default_1 = /** @class */ (function () {
|
|
8
|
+
function default_1(sendRequest) {
|
|
9
|
+
this.accounts = new Accounts(sendRequest);
|
|
10
|
+
this.metadata = new Metadata(sendRequest);
|
|
11
|
+
this.provider = new PostMessageProvider(sendRequest);
|
|
12
|
+
this.signer = new Signer(sendRequest);
|
|
13
|
+
setInterval(function () {
|
|
14
|
+
sendRequest('pub(ping)', null).catch(function () {
|
|
15
|
+
console.error('Extension unavailable, ping failed');
|
|
16
|
+
});
|
|
17
|
+
}, 5000 + Math.floor(Math.random() * 5000));
|
|
18
|
+
}
|
|
19
|
+
return default_1;
|
|
20
|
+
}());
|
|
21
|
+
export default default_1;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InjectedMetadata, InjectedMetadataKnown, MetadataDef } from '@pezkuwi/extension-inject/types';
|
|
2
|
+
import type { SendRequest } from './types.js';
|
|
3
|
+
export default class Metadata implements InjectedMetadata {
|
|
4
|
+
constructor(_sendRequest: SendRequest);
|
|
5
|
+
get(): Promise<InjectedMetadataKnown[]>;
|
|
6
|
+
provide(definition: MetadataDef): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2019-2025 @pezkuwi/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// External to class, this.# is not private enough (yet)
|
|
4
|
+
var sendRequest;
|
|
5
|
+
var Metadata = /** @class */ (function () {
|
|
6
|
+
function Metadata(_sendRequest) {
|
|
7
|
+
sendRequest = _sendRequest;
|
|
8
|
+
}
|
|
9
|
+
Metadata.prototype.get = function () {
|
|
10
|
+
return sendRequest('pub(metadata.list)');
|
|
11
|
+
};
|
|
12
|
+
Metadata.prototype.provide = function (definition) {
|
|
13
|
+
return sendRequest('pub(metadata.provide)', definition);
|
|
14
|
+
};
|
|
15
|
+
return Metadata;
|
|
16
|
+
}());
|
|
17
|
+
export default Metadata;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { InjectedProvider, ProviderList, ProviderMeta } from '@pezkuwi/extension-inject/types';
|
|
2
|
+
import type { ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@pezkuwi/rpc-provider/types';
|
|
3
|
+
import type { AnyFunction } from '@pezkuwi/types/types';
|
|
4
|
+
import type { SendRequest } from './types.js';
|
|
5
|
+
type CallbackHandler = (error?: null | Error, value?: unknown) => void;
|
|
6
|
+
interface SubscriptionHandler {
|
|
7
|
+
callback: CallbackHandler;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @name PostMessageProvider
|
|
12
|
+
*
|
|
13
|
+
* @description Extension provider to be used by dapps
|
|
14
|
+
*/
|
|
15
|
+
export default class PostMessageProvider implements InjectedProvider {
|
|
16
|
+
#private;
|
|
17
|
+
/**
|
|
18
|
+
* @param {function} sendRequest The function to be called to send requests to the node
|
|
19
|
+
* @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
|
|
20
|
+
*/
|
|
21
|
+
constructor(_sendRequest: SendRequest);
|
|
22
|
+
get isClonable(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @description Returns a clone of the object
|
|
25
|
+
*/
|
|
26
|
+
clone(): PostMessageProvider;
|
|
27
|
+
/**
|
|
28
|
+
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
29
|
+
*/
|
|
30
|
+
connect(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
33
|
+
*/
|
|
34
|
+
disconnect(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* @summary `true` when this provider supports subscriptions
|
|
37
|
+
*/
|
|
38
|
+
get hasSubscriptions(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* @summary Whether the node is connected or not.
|
|
41
|
+
* @return {boolean} true if connected
|
|
42
|
+
*/
|
|
43
|
+
get isConnected(): boolean;
|
|
44
|
+
listProviders(): Promise<ProviderList>;
|
|
45
|
+
/**
|
|
46
|
+
* @summary Listens on events after having subscribed using the [[subscribe]] function.
|
|
47
|
+
* @param {ProviderInterfaceEmitted} type Event
|
|
48
|
+
* @param {ProviderInterfaceEmitCb} sub Callback
|
|
49
|
+
* @return unsubscribe function
|
|
50
|
+
*/
|
|
51
|
+
on(type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void;
|
|
52
|
+
send(method: string, params: unknown[], _?: boolean, subscription?: SubscriptionHandler): Promise<any>;
|
|
53
|
+
/**
|
|
54
|
+
* @summary Spawn a provider on the extension background.
|
|
55
|
+
*/
|
|
56
|
+
startProvider(key: string): Promise<ProviderMeta>;
|
|
57
|
+
subscribe(type: string, method: string, params: unknown[], callback: AnyFunction): Promise<number>;
|
|
58
|
+
/**
|
|
59
|
+
* @summary Allows unsubscribing to subscriptions made with [[subscribe]].
|
|
60
|
+
*/
|
|
61
|
+
unsubscribe(type: string, method: string, id: number): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
export {};
|