@subwallet/extension-base 0.3.6-0 → 0.3.6-3
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/{build/background → background}/KoniTypes.d.ts +0 -0
- package/{build/background → background}/KoniTypes.js +0 -0
- package/{build/background → background}/RequestBytesSign.d.ts +0 -0
- package/{build/background → background}/RequestBytesSign.js +0 -0
- package/{build/background → background}/RequestExtrinsicSign.d.ts +0 -0
- package/{build/background → background}/RequestExtrinsicSign.js +0 -0
- package/{build/background → background}/handlers/Extension.d.ts +1 -1
- package/{build/background → background}/handlers/Extension.js +2 -2
- package/{build/background → background}/handlers/State.d.ts +0 -0
- package/{build/background → background}/handlers/State.js +0 -0
- package/{build/background → background}/handlers/Tabs.d.ts +0 -0
- package/{build/background → background}/handlers/Tabs.js +0 -0
- package/{build/background → background}/handlers/helpers.d.ts +0 -0
- package/{build/background → background}/handlers/helpers.js +0 -0
- package/{build/background → background}/handlers/index.d.ts +0 -0
- package/{build/background → background}/handlers/index.js +0 -0
- package/{build/background → background}/handlers/subscriptions.d.ts +0 -0
- package/{build/background → background}/handlers/subscriptions.js +0 -0
- package/{build/background → background}/types.d.ts +0 -0
- package/{build/background → background}/types.js +0 -0
- package/{build/bundle.d.ts → bundle.d.ts} +0 -0
- package/{build/bundle.js → bundle.js} +0 -0
- package/{build-cjs → cjs}/background/KoniTypes.js +0 -0
- package/{build-cjs → cjs}/background/RequestBytesSign.js +0 -0
- package/{build-cjs → cjs}/background/RequestExtrinsicSign.js +0 -0
- package/{build/cjs → cjs}/background/handlers/Extension.js +4 -4
- package/{build-cjs → cjs}/background/handlers/State.js +0 -0
- package/{build-cjs → cjs}/background/handlers/Tabs.js +0 -0
- package/{build-cjs → cjs}/background/handlers/helpers.js +0 -0
- package/{build-cjs → cjs}/background/handlers/index.js +0 -0
- package/{build-cjs → cjs}/background/handlers/subscriptions.js +0 -0
- package/{build-cjs → cjs}/background/types.js +0 -0
- package/{build-cjs → cjs}/bundle.js +0 -0
- package/{build-cjs → cjs}/defaults.js +0 -0
- package/{build-cjs → cjs}/detectOther.js +0 -0
- package/{build-cjs → cjs}/detectPackage.js +0 -0
- package/{build-cjs → cjs}/index.js +0 -0
- package/{build/cjs → cjs}/package.json +0 -0
- package/{build-cjs → cjs}/packageInfo.js +1 -1
- package/{build-cjs → cjs}/page/Accounts.js +0 -0
- package/{build-cjs → cjs}/page/Injected.js +0 -0
- package/{build-cjs → cjs}/page/Metadata.js +0 -0
- package/{build-cjs → cjs}/page/PostMessageProvider.js +0 -0
- package/{build-cjs → cjs}/page/Signer.js +0 -0
- package/{build-cjs → cjs}/page/index.js +0 -0
- package/{build-cjs → cjs}/page/types.js +0 -0
- package/{build-cjs → cjs}/stores/Accounts.js +0 -0
- package/{build-cjs → cjs}/stores/Base.js +0 -0
- package/{build-cjs → cjs}/stores/Metadata.js +0 -0
- package/{build-cjs → cjs}/stores/index.js +0 -0
- package/{build-cjs → cjs}/types.js +0 -0
- package/{build-cjs → cjs}/utils/canDerive.js +0 -0
- package/{build-cjs → cjs}/utils/getId.js +0 -0
- package/{build-cjs → cjs}/utils/index.js +0 -0
- package/{build/defaults.d.ts → defaults.d.ts} +0 -0
- package/{build/defaults.js → defaults.js} +0 -0
- package/{build/detectOther.d.ts → detectOther.d.ts} +0 -0
- package/{build/detectOther.js → detectOther.js} +0 -0
- package/{build/detectPackage.d.ts → detectPackage.d.ts} +0 -0
- package/{build/detectPackage.js → detectPackage.js} +0 -0
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/{build/index.js → index.js} +0 -0
- package/package.json +174 -10
- package/{build/packageInfo.d.ts → packageInfo.d.ts} +0 -0
- package/{build/packageInfo.js → packageInfo.js} +1 -1
- package/{build/page → page}/Accounts.d.ts +0 -0
- package/{build/page → page}/Accounts.js +0 -0
- package/{build/page → page}/Injected.d.ts +0 -0
- package/{build/page → page}/Injected.js +0 -0
- package/{build/page → page}/Metadata.d.ts +0 -0
- package/{build/page → page}/Metadata.js +0 -0
- package/{build/page → page}/PostMessageProvider.d.ts +0 -0
- package/{build/page → page}/PostMessageProvider.js +0 -0
- package/{build/page → page}/Signer.d.ts +0 -0
- package/{build/page → page}/Signer.js +0 -0
- package/{build/page → page}/index.d.ts +1 -1
- package/{build/page → page}/index.js +0 -0
- package/{build/page → page}/types.d.ts +0 -0
- package/{build/page → page}/types.js +0 -0
- package/{build/stores → stores}/Accounts.d.ts +0 -0
- package/{build/stores → stores}/Accounts.js +0 -0
- package/{build/stores → stores}/Base.d.ts +0 -0
- package/{build/stores → stores}/Base.js +0 -0
- package/{build/stores → stores}/Metadata.d.ts +0 -0
- package/{build/stores → stores}/Metadata.js +0 -0
- package/{build/stores → stores}/index.d.ts +0 -0
- package/{build/stores → stores}/index.js +0 -0
- package/{build/types.d.ts → types.d.ts} +0 -0
- package/{build/types.js → types.js} +0 -0
- package/{build/utils → utils}/canDerive.d.ts +0 -0
- package/{build/utils → utils}/canDerive.js +0 -0
- package/{build/utils → utils}/getId.d.ts +0 -0
- package/{build/utils → utils}/getId.js +0 -0
- package/{build/utils → utils}/index.d.ts +0 -0
- package/{build/utils → utils}/index.js +0 -0
- package/build/LICENSE +0 -201
- package/build/README.md +0 -10
- package/build/cjs/background/KoniTypes.js +0 -69
- package/build/cjs/background/RequestBytesSign.js +0 -27
- package/build/cjs/background/RequestExtrinsicSign.js +0 -23
- package/build/cjs/background/handlers/State.js +0 -472
- package/build/cjs/background/handlers/Tabs.js +0 -273
- package/build/cjs/background/handlers/helpers.js +0 -20
- package/build/cjs/background/handlers/index.js +0 -60
- package/build/cjs/background/handlers/subscriptions.js +0 -32
- package/build/cjs/background/types.js +0 -1
- package/build/cjs/bundle.js +0 -13
- package/build/cjs/defaults.js +0 -26
- package/build/cjs/detectOther.js +0 -17
- package/build/cjs/detectPackage.js +0 -14
- package/build/cjs/index.js +0 -18
- package/build/cjs/packageInfo.js +0 -16
- package/build/cjs/page/Accounts.js +0 -31
- package/build/cjs/page/Injected.js +0 -30
- package/build/cjs/page/Metadata.js +0 -27
- package/build/cjs/page/PostMessageProvider.js +0 -184
- package/build/cjs/page/Signer.js +0 -44
- package/build/cjs/page/index.js +0 -76
- package/build/cjs/page/types.js +0 -1
- package/build/cjs/stores/Accounts.js +0 -33
- package/build/cjs/stores/Base.js +0 -84
- package/build/cjs/stores/Metadata.js +0 -23
- package/build/cjs/stores/index.js +0 -23
- package/build/cjs/types.js +0 -1
- package/build/cjs/utils/canDerive.js +0 -12
- package/build/cjs/utils/getId.js +0 -16
- package/build/cjs/utils/index.js +0 -13
- package/build/package.json +0 -210
- package/build-cjs/background/handlers/Extension.js +0 -764
- package/src/background/KoniTypes.ts +0 -537
- package/src/background/RequestBytesSign.ts +0 -30
- package/src/background/RequestExtrinsicSign.ts +0 -23
- package/src/background/handlers/Extension.spec.ts +0 -456
- package/src/background/handlers/Extension.ts +0 -627
- package/src/background/handlers/State.ts +0 -513
- package/src/background/handlers/Tabs.ts +0 -223
- package/src/background/handlers/helpers.ts +0 -14
- package/src/background/handlers/index.ts +0 -49
- package/src/background/handlers/subscriptions.ts +0 -30
- package/src/background/types.ts +0 -437
- package/src/bundle.ts +0 -4
- package/src/defaults.ts +0 -24
- package/src/detectOther.ts +0 -8
- package/src/detectPackage.ts +0 -11
- package/src/index.ts +0 -7
- package/src/packageInfo.ts +0 -6
- package/src/page/Accounts.ts +0 -27
- package/src/page/Injected.ts +0 -27
- package/src/page/Metadata.ts +0 -22
- package/src/page/PostMessageProvider.ts +0 -178
- package/src/page/Signer.ts +0 -45
- package/src/page/index.ts +0 -87
- package/src/page/types.ts +0 -10
- package/src/stores/Accounts.ts +0 -24
- package/src/stores/Base.ts +0 -81
- package/src/stores/Metadata.ts +0 -13
- package/src/stores/index.ts +0 -5
- package/src/types.ts +0 -12
- package/src/utils/canDerive.ts +0 -8
- package/src/utils/getId.ts +0 -10
- package/src/utils/index.ts +0 -4
- package/tsconfig.build.json +0 -18
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -14
package/src/background/types.ts
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/* eslint-disable no-use-before-define */
|
|
5
|
-
|
|
6
|
-
import type { InjectedAccount, InjectedMetadataKnown, MetadataDef, ProviderList, ProviderMeta } from '@subwallet/extension-inject/types';
|
|
7
|
-
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '@polkadot/keyring/types';
|
|
8
|
-
import type { JsonRpcResponse } from '@polkadot/rpc-provider/types';
|
|
9
|
-
import type { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
|
|
10
|
-
import type { KeyringPairs$Json } from '@polkadot/ui-keyring/types';
|
|
11
|
-
import type { HexString } from '@polkadot/util/types';
|
|
12
|
-
import type { KeypairType } from '@polkadot/util-crypto/types';
|
|
13
|
-
|
|
14
|
-
import { CurrentNetworkInfo, KoniRequestSignatures } from '@subwallet/extension-base/background/KoniTypes';
|
|
15
|
-
|
|
16
|
-
import { TypeRegistry } from '@polkadot/types';
|
|
17
|
-
|
|
18
|
-
import { ALLOWED_PATH } from '../defaults';
|
|
19
|
-
import { AuthUrls } from './handlers/State';
|
|
20
|
-
|
|
21
|
-
type KeysWithDefinedValues<T> = {
|
|
22
|
-
[K in keyof T]: T[K] extends undefined ? never : K
|
|
23
|
-
}[keyof T];
|
|
24
|
-
|
|
25
|
-
type NoUndefinedValues<T> = {
|
|
26
|
-
[K in KeysWithDefinedValues<T>]: T[K]
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type IsNull<T, K extends keyof T> = { [K1 in Exclude<keyof T, K>]: T[K1] } & T[K] extends null ? K : never;
|
|
30
|
-
|
|
31
|
-
type NullKeys<T> = { [K in keyof T]: IsNull<T, K> }[keyof T];
|
|
32
|
-
|
|
33
|
-
export type SeedLengths = 12 | 24;
|
|
34
|
-
|
|
35
|
-
export interface AccountJson extends KeyringPair$Meta {
|
|
36
|
-
address: string;
|
|
37
|
-
genesisHash?: string | null;
|
|
38
|
-
isExternal?: boolean;
|
|
39
|
-
isHardware?: boolean;
|
|
40
|
-
isHidden?: boolean;
|
|
41
|
-
name?: string;
|
|
42
|
-
parentAddress?: string;
|
|
43
|
-
suri?: string;
|
|
44
|
-
type?: KeypairType;
|
|
45
|
-
whenCreated?: number;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// all Accounts and the address of the current Account
|
|
49
|
-
export interface AccountsWithCurrentAddress {
|
|
50
|
-
accounts: AccountJson[];
|
|
51
|
-
currentAddress?: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface CurrentAccountInfo {
|
|
55
|
-
address: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type AccountWithChildren = AccountJson & {
|
|
59
|
-
children?: AccountWithChildren[];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type AccountsContext = {
|
|
63
|
-
accounts: AccountJson[];
|
|
64
|
-
hierarchy: AccountWithChildren[];
|
|
65
|
-
master?: AccountJson;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export type CurrentAccContext = {
|
|
69
|
-
currentAccount: AccountJson | null;
|
|
70
|
-
setCurrentAccount: (account: AccountJson | null) => void;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export type AccNetworkContext = {
|
|
74
|
-
network: CurrentNetworkInfo;
|
|
75
|
-
setNetwork: (network: CurrentNetworkInfo) => void;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface AuthorizeRequest {
|
|
79
|
-
id: string;
|
|
80
|
-
request: RequestAuthorizeTab;
|
|
81
|
-
url: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface MetadataRequest {
|
|
85
|
-
id: string;
|
|
86
|
-
request: MetadataDef;
|
|
87
|
-
url: string;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface SigningRequest {
|
|
91
|
-
account: AccountJson;
|
|
92
|
-
id: string;
|
|
93
|
-
request: RequestSign;
|
|
94
|
-
url: string;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// [MessageType]: [RequestType, ResponseType, SubscriptionMessageType?]
|
|
98
|
-
export interface RequestSignatures extends KoniRequestSignatures {
|
|
99
|
-
// private/internal requests, i.e. from a popup
|
|
100
|
-
'pri(accounts.create.external)': [RequestAccountCreateExternal, boolean];
|
|
101
|
-
'pri(accounts.create.hardware)': [RequestAccountCreateHardware, boolean];
|
|
102
|
-
'pri(accounts.create.suri)': [RequestAccountCreateSuri, boolean];
|
|
103
|
-
'pri(accounts.edit)': [RequestAccountEdit, boolean];
|
|
104
|
-
'pri(accounts.export)': [RequestAccountExport, ResponseAccountExport];
|
|
105
|
-
'pri(accounts.batchExport)': [RequestAccountBatchExport, ResponseAccountsExport]
|
|
106
|
-
'pri(accounts.forget)': [RequestAccountForget, boolean];
|
|
107
|
-
'pri(accounts.show)': [RequestAccountShow, boolean];
|
|
108
|
-
'pri(accounts.tie)': [RequestAccountTie, boolean];
|
|
109
|
-
'pri(accounts.subscribe)': [RequestAccountSubscribe, boolean, AccountJson[]];
|
|
110
|
-
'pri(accounts.validate)': [RequestAccountValidate, boolean];
|
|
111
|
-
'pri(accounts.changePassword)': [RequestAccountChangePassword, boolean];
|
|
112
|
-
'pri(authorize.approve)': [RequestAuthorizeApprove, boolean];
|
|
113
|
-
'pri(authorize.list)': [null, ResponseAuthorizeList];
|
|
114
|
-
'pri(authorize.reject)': [RequestAuthorizeReject, boolean];
|
|
115
|
-
'pri(authorize.requests)': [RequestAuthorizeSubscribe, boolean, AuthorizeRequest[]];
|
|
116
|
-
'pri(authorize.toggle)': [string, ResponseAuthorizeList];
|
|
117
|
-
'pri(derivation.create)': [RequestDeriveCreate, boolean];
|
|
118
|
-
'pri(derivation.validate)': [RequestDeriveValidate, ResponseDeriveValidate];
|
|
119
|
-
'pri(json.restore)': [RequestJsonRestore, void];
|
|
120
|
-
'pri(json.batchRestore)': [RequestBatchRestore, void];
|
|
121
|
-
'pri(json.validate.password)': [];
|
|
122
|
-
'pri(json.account.info)': [KeyringPair$Json, ResponseJsonGetAccountInfo];
|
|
123
|
-
'pri(metadata.approve)': [RequestMetadataApprove, boolean];
|
|
124
|
-
'pri(metadata.get)': [string | null, MetadataDef | null];
|
|
125
|
-
'pri(metadata.reject)': [RequestMetadataReject, boolean];
|
|
126
|
-
'pri(metadata.requests)': [RequestMetadataSubscribe, boolean, MetadataRequest[]];
|
|
127
|
-
'pri(metadata.list)': [null, MetadataDef[]];
|
|
128
|
-
'pri(seed.create)': [RequestSeedCreate, ResponseSeedCreate];
|
|
129
|
-
'pri(seed.validate)': [RequestSeedValidate, ResponseSeedValidate];
|
|
130
|
-
'pri(settings.notification)': [string, boolean];
|
|
131
|
-
'pri(signing.approve.password)': [RequestSigningApprovePassword, boolean];
|
|
132
|
-
'pri(signing.approve.signature)': [RequestSigningApproveSignature, boolean];
|
|
133
|
-
'pri(signing.cancel)': [RequestSigningCancel, boolean];
|
|
134
|
-
'pri(signing.isLocked)': [RequestSigningIsLocked, ResponseSigningIsLocked];
|
|
135
|
-
'pri(signing.requests)': [RequestSigningSubscribe, boolean, SigningRequest[]];
|
|
136
|
-
'pri(window.open)': [AllowedPath, boolean];
|
|
137
|
-
// public/external requests, i.e. from a page
|
|
138
|
-
'pub(accounts.list)': [RequestAccountList, InjectedAccount[]];
|
|
139
|
-
'pub(accounts.subscribe)': [RequestAccountSubscribe, boolean, InjectedAccount[]];
|
|
140
|
-
'pub(authorize.tab)': [RequestAuthorizeTab, null];
|
|
141
|
-
'pub(authorize.tabV2)': [RequestAuthorizeTab, null];
|
|
142
|
-
'pub(bytes.sign)': [SignerPayloadRaw, ResponseSigning];
|
|
143
|
-
'pub(extrinsic.sign)': [SignerPayloadJSON, ResponseSigning];
|
|
144
|
-
'pub(metadata.list)': [null, InjectedMetadataKnown[]];
|
|
145
|
-
'pub(metadata.provide)': [MetadataDef, boolean];
|
|
146
|
-
'pub(phishing.redirectIfDenied)': [null, boolean];
|
|
147
|
-
'pub(rpc.listProviders)': [void, ResponseRpcListProviders];
|
|
148
|
-
'pub(rpc.send)': [RequestRpcSend, JsonRpcResponse];
|
|
149
|
-
'pub(rpc.startProvider)': [string, ProviderMeta];
|
|
150
|
-
'pub(rpc.subscribe)': [RequestRpcSubscribe, number, JsonRpcResponse];
|
|
151
|
-
'pub(rpc.subscribeConnected)': [null, boolean, boolean];
|
|
152
|
-
'pub(rpc.unsubscribe)': [RequestRpcUnsubscribe, boolean];
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export type MessageTypes = keyof RequestSignatures;
|
|
156
|
-
|
|
157
|
-
// Requests
|
|
158
|
-
|
|
159
|
-
export type RequestTypes = {
|
|
160
|
-
[MessageType in keyof RequestSignatures]: RequestSignatures[MessageType][0]
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export type MessageTypesWithNullRequest = NullKeys<RequestTypes>
|
|
164
|
-
|
|
165
|
-
export interface TransportRequestMessage<TMessageType extends MessageTypes> {
|
|
166
|
-
id: string;
|
|
167
|
-
message: TMessageType;
|
|
168
|
-
origin: 'page' | 'extension' | string;
|
|
169
|
-
request: RequestTypes[TMessageType];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export interface RequestAuthorizeTab {
|
|
173
|
-
origin: string;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export interface RequestAuthorizeApprove {
|
|
177
|
-
id: string;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export interface RequestAuthorizeReject {
|
|
181
|
-
id: string;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export type RequestAuthorizeSubscribe = null;
|
|
185
|
-
|
|
186
|
-
export interface RequestMetadataApprove {
|
|
187
|
-
id: string;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface RequestCurrentAccountAddress {
|
|
191
|
-
address: string;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export interface RequestMetadataReject {
|
|
195
|
-
id: string;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export type RequestMetadataSubscribe = null;
|
|
199
|
-
|
|
200
|
-
export interface RequestAccountCreateExternal {
|
|
201
|
-
address: string;
|
|
202
|
-
genesisHash?: string | null;
|
|
203
|
-
name: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export interface RequestAccountCreateSuri {
|
|
207
|
-
name: string;
|
|
208
|
-
genesisHash?: string | null;
|
|
209
|
-
password: string;
|
|
210
|
-
suri: string;
|
|
211
|
-
type?: KeypairType;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export interface RequestAccountCreateHardware {
|
|
215
|
-
accountIndex: number;
|
|
216
|
-
address: string;
|
|
217
|
-
addressOffset: number;
|
|
218
|
-
genesisHash: string;
|
|
219
|
-
hardwareType: string;
|
|
220
|
-
name: string;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export interface RequestAccountChangePassword {
|
|
224
|
-
address: string;
|
|
225
|
-
oldPass: string;
|
|
226
|
-
newPass: string;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export interface RequestAccountEdit {
|
|
230
|
-
address: string;
|
|
231
|
-
genesisHash?: string | null;
|
|
232
|
-
name: string;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export interface RequestAccountForget {
|
|
236
|
-
address: string;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export interface RequestAccountShow {
|
|
240
|
-
address: string;
|
|
241
|
-
isShowing: boolean;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export interface RequestAccountTie {
|
|
245
|
-
address: string;
|
|
246
|
-
genesisHash: string | null;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export interface RequestAccountValidate {
|
|
250
|
-
address: string;
|
|
251
|
-
password: string;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export interface RequestDeriveCreate {
|
|
255
|
-
name: string;
|
|
256
|
-
genesisHash?: string | null;
|
|
257
|
-
suri: string;
|
|
258
|
-
parentAddress: string;
|
|
259
|
-
parentPassword: string;
|
|
260
|
-
password: string;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export interface RequestDeriveValidate {
|
|
264
|
-
suri: string;
|
|
265
|
-
parentAddress: string;
|
|
266
|
-
parentPassword: string;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export interface RequestAccountExport {
|
|
270
|
-
address: string;
|
|
271
|
-
password: string;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export interface RequestAccountBatchExport {
|
|
275
|
-
addresses: string[];
|
|
276
|
-
password: string;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export interface RequestAccountList {
|
|
280
|
-
anyType?: boolean;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export type RequestAccountSubscribe = null;
|
|
284
|
-
|
|
285
|
-
export interface RequestRpcSend {
|
|
286
|
-
method: string;
|
|
287
|
-
params: unknown[];
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export interface RequestRpcSubscribe extends RequestRpcSend {
|
|
291
|
-
type: string;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export interface RequestRpcUnsubscribe {
|
|
295
|
-
method: string;
|
|
296
|
-
subscriptionId: number | string;
|
|
297
|
-
type: string;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export interface RequestSigningApprovePassword {
|
|
301
|
-
id: string;
|
|
302
|
-
password?: string;
|
|
303
|
-
savePass: boolean;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export interface RequestSigningApproveSignature {
|
|
307
|
-
id: string;
|
|
308
|
-
signature: HexString;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export interface RequestSigningCancel {
|
|
312
|
-
id: string;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export interface RequestSigningIsLocked {
|
|
316
|
-
id: string;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export interface ResponseSigningIsLocked {
|
|
320
|
-
isLocked: boolean;
|
|
321
|
-
remainingTime: number;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export type RequestSigningSubscribe = null;
|
|
325
|
-
|
|
326
|
-
export interface RequestSeedCreate {
|
|
327
|
-
length?: SeedLengths;
|
|
328
|
-
seed?: string;
|
|
329
|
-
type?: KeypairType;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export interface RequestSeedValidate {
|
|
333
|
-
suri: string;
|
|
334
|
-
type?: KeypairType;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Responses
|
|
338
|
-
|
|
339
|
-
export type ResponseTypes = {
|
|
340
|
-
[MessageType in keyof RequestSignatures]: RequestSignatures[MessageType][1]
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
export type ResponseType<TMessageType extends keyof RequestSignatures> = RequestSignatures[TMessageType][1];
|
|
344
|
-
|
|
345
|
-
interface TransportResponseMessageSub<TMessageType extends MessageTypesWithSubscriptions> {
|
|
346
|
-
error?: string;
|
|
347
|
-
id: string;
|
|
348
|
-
response?: ResponseTypes[TMessageType];
|
|
349
|
-
subscription?: SubscriptionMessageTypes[TMessageType];
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
interface TransportResponseMessageNoSub<TMessageType extends MessageTypesWithNoSubscriptions> {
|
|
353
|
-
error?: string;
|
|
354
|
-
id: string;
|
|
355
|
-
response?: ResponseTypes[TMessageType];
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
export type TransportResponseMessage<TMessageType extends MessageTypes> =
|
|
359
|
-
TMessageType extends MessageTypesWithNoSubscriptions
|
|
360
|
-
? TransportResponseMessageNoSub<TMessageType>
|
|
361
|
-
: TMessageType extends MessageTypesWithSubscriptions
|
|
362
|
-
? TransportResponseMessageSub<TMessageType>
|
|
363
|
-
: never;
|
|
364
|
-
|
|
365
|
-
export interface ResponseSigning {
|
|
366
|
-
id: string;
|
|
367
|
-
signature: HexString;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
export interface ResponseDeriveValidate {
|
|
371
|
-
address: string;
|
|
372
|
-
suri: string;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
export interface ResponseSeedCreate {
|
|
376
|
-
address: string;
|
|
377
|
-
seed: string;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
export interface ResponseSeedValidate {
|
|
381
|
-
address: string;
|
|
382
|
-
suri: string;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
export interface ResponseAccountExport {
|
|
386
|
-
exportedJson: KeyringPair$Json;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
export interface ResponseAccountsExport {
|
|
390
|
-
exportedJson: KeyringPairs$Json;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
export type ResponseRpcListProviders = ProviderList;
|
|
394
|
-
|
|
395
|
-
// Subscriptions
|
|
396
|
-
|
|
397
|
-
export type SubscriptionMessageTypes = NoUndefinedValues<{
|
|
398
|
-
[MessageType in keyof RequestSignatures]: RequestSignatures[MessageType][2]
|
|
399
|
-
}>;
|
|
400
|
-
|
|
401
|
-
export type MessageTypesWithSubscriptions = keyof SubscriptionMessageTypes;
|
|
402
|
-
export type MessageTypesWithNoSubscriptions = Exclude<MessageTypes, keyof SubscriptionMessageTypes>
|
|
403
|
-
|
|
404
|
-
export interface RequestSign {
|
|
405
|
-
readonly payload: SignerPayloadJSON | SignerPayloadRaw;
|
|
406
|
-
|
|
407
|
-
sign (registry: TypeRegistry, pair: KeyringPair): { signature: HexString };
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
export interface RequestJsonRestore {
|
|
411
|
-
file: KeyringPair$Json;
|
|
412
|
-
password: string;
|
|
413
|
-
address: string;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
export interface RequestBatchRestore {
|
|
417
|
-
file: KeyringPairs$Json;
|
|
418
|
-
password: string;
|
|
419
|
-
address: string;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
export interface ResponseJsonRestore {
|
|
423
|
-
error: string | null;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
export type AllowedPath = typeof ALLOWED_PATH[number];
|
|
427
|
-
|
|
428
|
-
export interface ResponseJsonGetAccountInfo {
|
|
429
|
-
address: string;
|
|
430
|
-
name: string;
|
|
431
|
-
genesisHash: string;
|
|
432
|
-
type: KeypairType;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export interface ResponseAuthorizeList {
|
|
436
|
-
list: AuthUrls;
|
|
437
|
-
}
|
package/src/bundle.ts
DELETED
package/src/defaults.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
const ALLOWED_PATH = ['/', '/account/import-ledger', '/account/restore-json', '/account/create'] as const;
|
|
5
|
-
const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
|
|
6
|
-
const EXTENSION_PREFIX = process.env.EXTENSION_PREFIX as string || '';
|
|
7
|
-
const PORT_CONTENT = `${EXTENSION_PREFIX}koni-content`;
|
|
8
|
-
const PORT_EXTENSION = `${EXTENSION_PREFIX}koni-extension`;
|
|
9
|
-
const MESSAGE_ORIGIN_PAGE = `${EXTENSION_PREFIX}koni-page`;
|
|
10
|
-
const MESSAGE_ORIGIN_CONTENT = `${EXTENSION_PREFIX}koni-content`;
|
|
11
|
-
const PASSWORD_EXPIRY_MIN = 15;
|
|
12
|
-
const PASSWORD_EXPIRY_MS = PASSWORD_EXPIRY_MIN * 60 * 1000;
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
ALLOWED_PATH,
|
|
16
|
-
PASSWORD_EXPIRY_MIN,
|
|
17
|
-
PASSWORD_EXPIRY_MS,
|
|
18
|
-
PHISHING_PAGE_REDIRECT,
|
|
19
|
-
EXTENSION_PREFIX,
|
|
20
|
-
PORT_CONTENT,
|
|
21
|
-
PORT_EXTENSION,
|
|
22
|
-
MESSAGE_ORIGIN_PAGE,
|
|
23
|
-
MESSAGE_ORIGIN_CONTENT
|
|
24
|
-
};
|
package/src/detectOther.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2022 @subwallet/extension-base authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { packageInfo as chainsInfo } from '@subwallet/extension-chains/packageInfo';
|
|
5
|
-
import { packageInfo as dappInfo } from '@subwallet/extension-dapp/packageInfo';
|
|
6
|
-
import { packageInfo as injectInfo } from '@subwallet/extension-inject/packageInfo';
|
|
7
|
-
|
|
8
|
-
export default [chainsInfo, dappInfo, injectInfo];
|
package/src/detectPackage.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2022 @subwallet/extension-base authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
// Do not edit, auto-generated by @polkadot/dev
|
|
5
|
-
|
|
6
|
-
import { detectPackage } from '@polkadot/util';
|
|
7
|
-
|
|
8
|
-
import others from './detectOther';
|
|
9
|
-
import { packageInfo } from './packageInfo';
|
|
10
|
-
|
|
11
|
-
detectPackage(packageInfo, null, others);
|
package/src/index.ts
DELETED
package/src/packageInfo.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2022 @subwallet/extension-base authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
// Do not edit, auto-generated by @polkadot/dev
|
|
5
|
-
|
|
6
|
-
export const packageInfo = { name: '@subwallet/extension-base', path: 'auto', type: 'auto', version: '0.3.6-0' };
|
package/src/page/Accounts.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { InjectedAccount, InjectedAccounts, Unsubcall } from '@subwallet/extension-inject/types';
|
|
5
|
-
import type { SendRequest } from './types';
|
|
6
|
-
|
|
7
|
-
// External to class, this.# is not private enough (yet)
|
|
8
|
-
let sendRequest: SendRequest;
|
|
9
|
-
|
|
10
|
-
export default class Accounts implements InjectedAccounts {
|
|
11
|
-
constructor (_sendRequest: SendRequest) {
|
|
12
|
-
sendRequest = _sendRequest;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public get (anyType?: boolean): Promise<InjectedAccount[]> {
|
|
16
|
-
return sendRequest('pub(accounts.listV2)', { anyType });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public subscribe (cb: (accounts: InjectedAccount[]) => unknown): Unsubcall {
|
|
20
|
-
sendRequest('pub(accounts.subscribeV2)', null, cb)
|
|
21
|
-
.catch((error: Error) => console.error(error));
|
|
22
|
-
|
|
23
|
-
return (): void => {
|
|
24
|
-
// FIXME we need the ability to unsubscribe
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
package/src/page/Injected.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { Injected } from '@subwallet/extension-inject/types';
|
|
5
|
-
import type { SendRequest } from './types';
|
|
6
|
-
|
|
7
|
-
import Accounts from './Accounts';
|
|
8
|
-
import Metadata from './Metadata';
|
|
9
|
-
import PostMessageProvider from './PostMessageProvider';
|
|
10
|
-
import Signer from './Signer';
|
|
11
|
-
|
|
12
|
-
export default class implements Injected {
|
|
13
|
-
public readonly accounts: Accounts;
|
|
14
|
-
|
|
15
|
-
public readonly metadata: Metadata;
|
|
16
|
-
|
|
17
|
-
public readonly provider: PostMessageProvider;
|
|
18
|
-
|
|
19
|
-
public readonly signer: Signer;
|
|
20
|
-
|
|
21
|
-
constructor (sendRequest: SendRequest) {
|
|
22
|
-
this.accounts = new Accounts(sendRequest);
|
|
23
|
-
this.metadata = new Metadata(sendRequest);
|
|
24
|
-
this.provider = new PostMessageProvider(sendRequest);
|
|
25
|
-
this.signer = new Signer(sendRequest);
|
|
26
|
-
}
|
|
27
|
-
}
|
package/src/page/Metadata.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { InjectedMetadata, InjectedMetadataKnown, MetadataDef } from '@subwallet/extension-inject/types';
|
|
5
|
-
import type { SendRequest } from './types';
|
|
6
|
-
|
|
7
|
-
// External to class, this.# is not private enough (yet)
|
|
8
|
-
let sendRequest: SendRequest;
|
|
9
|
-
|
|
10
|
-
export default class Metadata implements InjectedMetadata {
|
|
11
|
-
constructor (_sendRequest: SendRequest) {
|
|
12
|
-
sendRequest = _sendRequest;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public get (): Promise<InjectedMetadataKnown[]> {
|
|
16
|
-
return sendRequest('pub(metadata.list)');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public provide (definition: MetadataDef): Promise<boolean> {
|
|
20
|
-
return sendRequest('pub(metadata.provide)', definition);
|
|
21
|
-
}
|
|
22
|
-
}
|