hive-keychain-commons 1.2.2 → 1.2.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/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Operation, Transaction } from '@hiveio/dhive';
|
|
2
|
+
import { IStep } from '../swaps/swap.interface';
|
|
2
3
|
export declare enum KeychainRequestTypes {
|
|
3
4
|
decode = "decode",
|
|
4
5
|
encode = "encode",
|
|
@@ -27,7 +28,8 @@ export declare enum KeychainRequestTypes {
|
|
|
27
28
|
updateProposalVote = "updateProposalVote",
|
|
28
29
|
addAccount = "addAccount",
|
|
29
30
|
convert = "convert",
|
|
30
|
-
recurrentTransfer = "recurrentTransfer"
|
|
31
|
+
recurrentTransfer = "recurrentTransfer",
|
|
32
|
+
swap = "swap"
|
|
31
33
|
}
|
|
32
34
|
export declare enum KeychainKeyTypes {
|
|
33
35
|
posting = "Posting",
|
|
@@ -39,78 +41,78 @@ export declare enum KeychainKeyTypesLC {
|
|
|
39
41
|
active = "active",
|
|
40
42
|
memo = "memo"
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
type CommonRequestParams = {
|
|
43
45
|
rpc?: string;
|
|
44
46
|
domain: string;
|
|
45
47
|
key?: string;
|
|
46
48
|
};
|
|
47
|
-
export
|
|
49
|
+
export type RequestDecode = CommonRequestParams & {
|
|
48
50
|
type: KeychainRequestTypes.decode;
|
|
49
51
|
username: string;
|
|
50
52
|
message: string;
|
|
51
53
|
method: KeychainKeyTypes;
|
|
52
54
|
};
|
|
53
|
-
export
|
|
55
|
+
export type RequestEncode = CommonRequestParams & {
|
|
54
56
|
type: KeychainRequestTypes.encode;
|
|
55
57
|
username: string;
|
|
56
58
|
receiver: string;
|
|
57
59
|
message: string;
|
|
58
60
|
method: KeychainKeyTypes;
|
|
59
61
|
};
|
|
60
|
-
export
|
|
62
|
+
export type RequestEncodeWithKeys = CommonRequestParams & {
|
|
61
63
|
type: KeychainRequestTypes.encodeWithKeys;
|
|
62
64
|
username: string;
|
|
63
65
|
publicKeys: string[];
|
|
64
66
|
message: string;
|
|
65
67
|
method: KeychainKeyTypes;
|
|
66
68
|
};
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
+
export type ExcludeCommonParams<T> = Omit<T, 'rpc' | 'type' | 'key' | 'domain'>;
|
|
70
|
+
export type RequestSignBuffer = CommonRequestParams & {
|
|
69
71
|
type: KeychainRequestTypes.signBuffer;
|
|
70
72
|
username?: string;
|
|
71
73
|
message: string;
|
|
72
74
|
method: KeychainKeyTypes;
|
|
73
75
|
title?: string;
|
|
74
76
|
};
|
|
75
|
-
export
|
|
77
|
+
export type RequestBroadcast = CommonRequestParams & {
|
|
76
78
|
type: KeychainRequestTypes.broadcast;
|
|
77
79
|
username: string;
|
|
78
80
|
operations: string | Operation[];
|
|
79
81
|
method: KeychainKeyTypes;
|
|
80
82
|
};
|
|
81
|
-
export
|
|
83
|
+
export type RequestAddAccountAuthority = CommonRequestParams & {
|
|
82
84
|
type: KeychainRequestTypes.addAccountAuthority;
|
|
83
85
|
authorizedUsername: string;
|
|
84
86
|
role: KeychainKeyTypes;
|
|
85
87
|
weight: number;
|
|
86
88
|
username: string;
|
|
87
89
|
};
|
|
88
|
-
export
|
|
90
|
+
export type RequestRemoveAccountAuthority = CommonRequestParams & {
|
|
89
91
|
type: KeychainRequestTypes.removeAccountAuthority;
|
|
90
92
|
authorizedUsername: string;
|
|
91
93
|
role: KeychainKeyTypes;
|
|
92
94
|
username: string;
|
|
93
95
|
};
|
|
94
|
-
export
|
|
96
|
+
export type RequestAddKeyAuthority = CommonRequestParams & {
|
|
95
97
|
type: KeychainRequestTypes.addKeyAuthority;
|
|
96
98
|
authorizedKey: string;
|
|
97
99
|
role: KeychainKeyTypes;
|
|
98
100
|
username: string;
|
|
99
101
|
weight: number;
|
|
100
102
|
};
|
|
101
|
-
export
|
|
103
|
+
export type RequestRemoveKeyAuthority = CommonRequestParams & {
|
|
102
104
|
type: KeychainRequestTypes.removeKeyAuthority;
|
|
103
105
|
authorizedKey: string;
|
|
104
106
|
role: KeychainKeyTypes;
|
|
105
107
|
username: string;
|
|
106
108
|
};
|
|
107
|
-
export
|
|
109
|
+
export type RequestSignTx = CommonRequestParams & {
|
|
108
110
|
type: KeychainRequestTypes.signTx;
|
|
109
111
|
username: string;
|
|
110
112
|
tx: Transaction;
|
|
111
113
|
method: KeychainKeyTypes;
|
|
112
114
|
};
|
|
113
|
-
export
|
|
115
|
+
export type RequestPost = CommonRequestParams & {
|
|
114
116
|
type: KeychainRequestTypes.post;
|
|
115
117
|
username: string;
|
|
116
118
|
title?: string;
|
|
@@ -121,14 +123,14 @@ export declare type RequestPost = CommonRequestParams & {
|
|
|
121
123
|
permlink: string;
|
|
122
124
|
comment_options: string;
|
|
123
125
|
};
|
|
124
|
-
export
|
|
126
|
+
export type RequestVote = CommonRequestParams & {
|
|
125
127
|
type: KeychainRequestTypes.vote;
|
|
126
128
|
username: string;
|
|
127
129
|
permlink: string;
|
|
128
130
|
author: string;
|
|
129
131
|
weight: string | number;
|
|
130
132
|
};
|
|
131
|
-
export
|
|
133
|
+
export type RequestCustomJSON = CommonRequestParams & {
|
|
132
134
|
type: KeychainRequestTypes.custom;
|
|
133
135
|
username?: string;
|
|
134
136
|
id: string;
|
|
@@ -136,14 +138,14 @@ export declare type RequestCustomJSON = CommonRequestParams & {
|
|
|
136
138
|
json: string;
|
|
137
139
|
display_msg: string;
|
|
138
140
|
};
|
|
139
|
-
export
|
|
141
|
+
export type RequestSignedCall = CommonRequestParams & {
|
|
140
142
|
type: KeychainRequestTypes.signedCall;
|
|
141
143
|
username: string;
|
|
142
144
|
method: string;
|
|
143
145
|
params: string;
|
|
144
146
|
typeWif: KeychainKeyTypes;
|
|
145
147
|
};
|
|
146
|
-
export
|
|
148
|
+
export type RequestTransfer = CommonRequestParams & {
|
|
147
149
|
type: KeychainRequestTypes.transfer;
|
|
148
150
|
username?: string;
|
|
149
151
|
to: string;
|
|
@@ -152,7 +154,7 @@ export declare type RequestTransfer = CommonRequestParams & {
|
|
|
152
154
|
enforce: boolean;
|
|
153
155
|
currency: string;
|
|
154
156
|
};
|
|
155
|
-
export
|
|
157
|
+
export type RequestSendToken = CommonRequestParams & {
|
|
156
158
|
type: KeychainRequestTypes.sendToken;
|
|
157
159
|
username: string;
|
|
158
160
|
to: string;
|
|
@@ -160,36 +162,36 @@ export declare type RequestSendToken = CommonRequestParams & {
|
|
|
160
162
|
memo: string;
|
|
161
163
|
currency: string;
|
|
162
164
|
};
|
|
163
|
-
export
|
|
165
|
+
export type RequestDelegation = CommonRequestParams & {
|
|
164
166
|
type: KeychainRequestTypes.delegation;
|
|
165
167
|
username?: string;
|
|
166
168
|
delegatee: string;
|
|
167
169
|
amount: string;
|
|
168
170
|
unit: string;
|
|
169
171
|
};
|
|
170
|
-
export
|
|
172
|
+
export type RequestWitnessVote = CommonRequestParams & {
|
|
171
173
|
type: KeychainRequestTypes.witnessVote;
|
|
172
174
|
username?: string;
|
|
173
175
|
witness: string;
|
|
174
176
|
vote: boolean;
|
|
175
177
|
};
|
|
176
|
-
export
|
|
178
|
+
export type RequestProxy = CommonRequestParams & {
|
|
177
179
|
type: KeychainRequestTypes.proxy;
|
|
178
180
|
username?: string;
|
|
179
181
|
proxy: string;
|
|
180
182
|
};
|
|
181
|
-
export
|
|
183
|
+
export type RequestPowerUp = CommonRequestParams & {
|
|
182
184
|
type: KeychainRequestTypes.powerUp;
|
|
183
185
|
username: string;
|
|
184
186
|
recipient: string;
|
|
185
187
|
hive: string;
|
|
186
188
|
};
|
|
187
|
-
export
|
|
189
|
+
export type RequestPowerDown = CommonRequestParams & {
|
|
188
190
|
type: KeychainRequestTypes.powerDown;
|
|
189
191
|
username: string;
|
|
190
192
|
hive_power: string;
|
|
191
193
|
};
|
|
192
|
-
export
|
|
194
|
+
export type RequestCreateClaimedAccount = CommonRequestParams & {
|
|
193
195
|
type: KeychainRequestTypes.createClaimedAccount;
|
|
194
196
|
username: string;
|
|
195
197
|
new_account: string;
|
|
@@ -198,14 +200,14 @@ export declare type RequestCreateClaimedAccount = CommonRequestParams & {
|
|
|
198
200
|
posting: string;
|
|
199
201
|
memo: string;
|
|
200
202
|
};
|
|
201
|
-
export
|
|
203
|
+
export type RequestUpdateProposalVote = CommonRequestParams & {
|
|
202
204
|
type: KeychainRequestTypes.updateProposalVote;
|
|
203
205
|
username: string;
|
|
204
206
|
proposal_ids: string | number[];
|
|
205
207
|
approve: boolean;
|
|
206
208
|
extensions: string | any[];
|
|
207
209
|
};
|
|
208
|
-
export
|
|
210
|
+
export type RequestCreateProposal = CommonRequestParams & {
|
|
209
211
|
type: KeychainRequestTypes.createProposal;
|
|
210
212
|
username: string;
|
|
211
213
|
receiver: string;
|
|
@@ -216,29 +218,29 @@ export declare type RequestCreateProposal = CommonRequestParams & {
|
|
|
216
218
|
daily_pay: string;
|
|
217
219
|
extensions: string;
|
|
218
220
|
};
|
|
219
|
-
export
|
|
221
|
+
export type RequestRemoveProposal = CommonRequestParams & {
|
|
220
222
|
type: KeychainRequestTypes.removeProposal;
|
|
221
223
|
username: string;
|
|
222
224
|
proposal_ids: string | number[];
|
|
223
225
|
extensions: string;
|
|
224
226
|
};
|
|
225
|
-
export
|
|
227
|
+
export type RequestAddAccountKeys = {
|
|
226
228
|
posting?: string;
|
|
227
229
|
active?: string;
|
|
228
230
|
memo?: string;
|
|
229
231
|
};
|
|
230
|
-
export
|
|
232
|
+
export type RequestAddAccount = CommonRequestParams & {
|
|
231
233
|
type: KeychainRequestTypes.addAccount;
|
|
232
234
|
username: string;
|
|
233
235
|
keys: RequestAddAccountKeys;
|
|
234
236
|
};
|
|
235
|
-
export
|
|
237
|
+
export type RequestConvert = CommonRequestParams & {
|
|
236
238
|
type: KeychainRequestTypes.convert;
|
|
237
239
|
username: string;
|
|
238
240
|
amount: string;
|
|
239
241
|
collaterized: boolean;
|
|
240
242
|
};
|
|
241
|
-
export
|
|
243
|
+
export type RequestRecurrentTransfer = CommonRequestParams & {
|
|
242
244
|
type: KeychainRequestTypes.recurrentTransfer;
|
|
243
245
|
username?: string;
|
|
244
246
|
to: string;
|
|
@@ -248,36 +250,45 @@ export declare type RequestRecurrentTransfer = CommonRequestParams & {
|
|
|
248
250
|
recurrence: number;
|
|
249
251
|
executions: number;
|
|
250
252
|
};
|
|
251
|
-
export
|
|
253
|
+
export type RequestSwap = CommonRequestParams & {
|
|
254
|
+
type: KeychainRequestTypes.swap;
|
|
255
|
+
steps: IStep[];
|
|
256
|
+
slippage: number;
|
|
257
|
+
startToken: string;
|
|
258
|
+
endToken: string;
|
|
259
|
+
amount: number;
|
|
260
|
+
username?: string;
|
|
261
|
+
};
|
|
262
|
+
export type KeychainRequestData = (RequestDecode | RequestEncodeWithKeys | RequestEncode | RequestSignBuffer | RequestBroadcast | RequestAddAccountAuthority | RequestRemoveAccountAuthority | RequestAddKeyAuthority | RequestRemoveKeyAuthority | RequestSignTx | RequestPost | RequestVote | RequestCustomJSON | RequestSignedCall | RequestTransfer | RequestSendToken | RequestDelegation | RequestWitnessVote | RequestProxy | RequestPowerUp | RequestPowerDown | RequestCreateClaimedAccount | RequestUpdateProposalVote | RequestCreateProposal | RequestRemoveProposal | RequestAddAccount | RequestConvert | RequestRecurrentTransfer | RequestSwap) & {
|
|
252
263
|
redirect_uri?: string;
|
|
253
264
|
};
|
|
254
|
-
export
|
|
265
|
+
export type RequestId = {
|
|
255
266
|
request_id: number;
|
|
256
267
|
};
|
|
257
|
-
export
|
|
258
|
-
export
|
|
268
|
+
export type KeychainRequest = KeychainRequestData & RequestId;
|
|
269
|
+
export type HiveErrorMessage = {
|
|
259
270
|
message: string;
|
|
260
271
|
code: number;
|
|
261
272
|
data?: any;
|
|
262
273
|
};
|
|
263
|
-
export
|
|
274
|
+
export type RequestSuccess = {
|
|
264
275
|
data: KeychainRequestData;
|
|
265
276
|
request_id: number;
|
|
266
277
|
result: any;
|
|
267
278
|
message: string;
|
|
268
279
|
};
|
|
269
|
-
export
|
|
280
|
+
export type RequestError = {
|
|
270
281
|
data: KeychainRequestData;
|
|
271
282
|
request_id: number;
|
|
272
283
|
error: any;
|
|
273
284
|
message: string;
|
|
274
285
|
};
|
|
275
|
-
export
|
|
286
|
+
export type RequestResponse = {
|
|
276
287
|
success: boolean;
|
|
277
288
|
error: any | null;
|
|
278
289
|
result: any | null;
|
|
279
290
|
} & (RequestSuccess | RequestError);
|
|
280
|
-
export
|
|
291
|
+
export type KeychainRequestWrapper = {
|
|
281
292
|
command: string;
|
|
282
293
|
domain: string;
|
|
283
294
|
request: KeychainRequest;
|
|
@@ -31,6 +31,7 @@ var KeychainRequestTypes;
|
|
|
31
31
|
KeychainRequestTypes["addAccount"] = "addAccount";
|
|
32
32
|
KeychainRequestTypes["convert"] = "convert";
|
|
33
33
|
KeychainRequestTypes["recurrentTransfer"] = "recurrentTransfer";
|
|
34
|
+
KeychainRequestTypes["swap"] = "swap";
|
|
34
35
|
})(KeychainRequestTypes = exports.KeychainRequestTypes || (exports.KeychainRequestTypes = {}));
|
|
35
36
|
var KeychainKeyTypes;
|
|
36
37
|
(function (KeychainKeyTypes) {
|
package/lib/logger/logger.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface LoggerConfig {
|
|
|
9
9
|
declare const Logger: {
|
|
10
10
|
info: (message: string) => void;
|
|
11
11
|
warn: (message: string) => void;
|
|
12
|
-
error: (message: any, stacktrace?: Error
|
|
12
|
+
error: (message: any, stacktrace?: Error) => void;
|
|
13
13
|
technical: (message: string) => void;
|
|
14
14
|
operation: (message: string) => void;
|
|
15
15
|
debug: (message: string) => void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hive-keychain-commons",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "Platform
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"description": "Platform-agnostic functions used in Hive Keychain mobile and extensions",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/stoodkev/hive-keychain-commons#readme",
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@hiveio/dhive": "^1.2.7",
|
|
39
40
|
"@types/bytebuffer": "^5.0.44",
|
|
40
41
|
"@types/node": "^18.11.19",
|
|
41
42
|
"prettier": "^2.4.1",
|
|
@@ -44,7 +45,6 @@
|
|
|
44
45
|
"typescript": "^4.5.2"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@hiveio/dhive": "^1.2.5",
|
|
48
48
|
"moment": "^2.29.4",
|
|
49
49
|
"winston": "^3.8.1",
|
|
50
50
|
"winston-daily-rotate-file": "^4.7.1"
|