@bitpay-labs/bitcore-client 11.5.2
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 +131 -0
- package/bin/multi-sig/wallet-derive-address +149 -0
- package/bin/wallet +31 -0
- package/bin/wallet-balance +62 -0
- package/bin/wallet-balance-all +77 -0
- package/bin/wallet-broadcast +35 -0
- package/bin/wallet-bump-tx +65 -0
- package/bin/wallet-check +62 -0
- package/bin/wallet-create +46 -0
- package/bin/wallet-decrypt +31 -0
- package/bin/wallet-delete +21 -0
- package/bin/wallet-derive +70 -0
- package/bin/wallet-flags +84 -0
- package/bin/wallet-import +80 -0
- package/bin/wallet-list +31 -0
- package/bin/wallet-paypro +175 -0
- package/bin/wallet-register +29 -0
- package/bin/wallet-send +146 -0
- package/bin/wallet-sign +64 -0
- package/bin/wallet-sign-message +55 -0
- package/bin/wallet-storage +79 -0
- package/bin/wallet-token +73 -0
- package/bin/wallet-token-rm +33 -0
- package/bin/wallet-tx +106 -0
- package/bin/wallet-tx-list +92 -0
- package/bin/wallet-utxos +28 -0
- package/package.json +71 -0
- package/src/client.ts +271 -0
- package/src/encryption.ts +139 -0
- package/src/index.ts +21 -0
- package/src/storage/level.ts +171 -0
- package/src/storage/mongo.ts +187 -0
- package/src/storage/textFile.ts +250 -0
- package/src/storage.ts +192 -0
- package/src/stream-util.ts +80 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/storage.d.ts +1 -0
- package/src/types/wallet.d.ts +36 -0
- package/src/utils.ts +35 -0
- package/src/wallet.ts +983 -0
- package/test/unit/wallet.test.ts +552 -0
- package/ts_build/src/client.d.ts +77 -0
- package/ts_build/src/client.d.ts.map +1 -0
- package/ts_build/src/client.js +280 -0
- package/ts_build/src/client.js.map +1 -0
- package/ts_build/src/encryption.d.ts +27 -0
- package/ts_build/src/encryption.d.ts.map +1 -0
- package/ts_build/src/encryption.js +130 -0
- package/ts_build/src/encryption.js.map +1 -0
- package/ts_build/src/index.d.ts +11 -0
- package/ts_build/src/index.d.ts.map +1 -0
- package/ts_build/src/index.js +55 -0
- package/ts_build/src/index.js.map +1 -0
- package/ts_build/src/storage/level.d.ts +48 -0
- package/ts_build/src/storage/level.d.ts.map +1 -0
- package/ts_build/src/storage/level.js +194 -0
- package/ts_build/src/storage/level.js.map +1 -0
- package/ts_build/src/storage/mongo.d.ts +62 -0
- package/ts_build/src/storage/mongo.d.ts.map +1 -0
- package/ts_build/src/storage/mongo.js +173 -0
- package/ts_build/src/storage/mongo.js.map +1 -0
- package/ts_build/src/storage/textFile.d.ts +53 -0
- package/ts_build/src/storage/textFile.d.ts.map +1 -0
- package/ts_build/src/storage/textFile.js +268 -0
- package/ts_build/src/storage/textFile.js.map +1 -0
- package/ts_build/src/storage.d.ts +63 -0
- package/ts_build/src/storage.d.ts.map +1 -0
- package/ts_build/src/storage.js +172 -0
- package/ts_build/src/storage.js.map +1 -0
- package/ts_build/src/stream-util.d.ts +15 -0
- package/ts_build/src/stream-util.d.ts.map +1 -0
- package/ts_build/src/stream-util.js +81 -0
- package/ts_build/src/stream-util.js.map +1 -0
- package/ts_build/src/utils.d.ts +8 -0
- package/ts_build/src/utils.d.ts.map +1 -0
- package/ts_build/src/utils.js +37 -0
- package/ts_build/src/utils.js.map +1 -0
- package/ts_build/src/wallet.d.ts +229 -0
- package/ts_build/src/wallet.d.ts.map +1 -0
- package/ts_build/src/wallet.js +806 -0
- package/ts_build/src/wallet.js.map +1 -0
- package/ts_build/test/unit/wallet.test.d.ts +2 -0
- package/ts_build/test/unit/wallet.test.d.ts.map +1 -0
- package/ts_build/test/unit/wallet.test.js +533 -0
- package/ts_build/test/unit/wallet.test.js.map +1 -0
- package/tsconfig.json +40 -0
- package/tsconfig.prod.json +6 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Client = void 0;
|
|
40
|
+
const url_1 = require("url");
|
|
41
|
+
const crypto_wallet_core_1 = require("@bitpay-labs/crypto-wallet-core");
|
|
42
|
+
const request_1 = __importDefault(require("request"));
|
|
43
|
+
const request_promise_native_1 = __importDefault(require("request-promise-native"));
|
|
44
|
+
const secp256k1 = __importStar(require("secp256k1"));
|
|
45
|
+
const utils_1 = require("./utils");
|
|
46
|
+
const usingBrowser = global.window;
|
|
47
|
+
const URLClass = usingBrowser ? usingBrowser.URL : url_1.URL;
|
|
48
|
+
class Client {
|
|
49
|
+
constructor(params) {
|
|
50
|
+
this.getAddressTxos = async function (params) {
|
|
51
|
+
const { unspent, address } = params;
|
|
52
|
+
const args = unspent ? `?unspent=${unspent}` : '';
|
|
53
|
+
const url = `${this.apiUrl}/address/${address}${args}`;
|
|
54
|
+
return this._request({ method: 'GET', url, json: true });
|
|
55
|
+
};
|
|
56
|
+
this.apiUrl = params.apiUrl;
|
|
57
|
+
this.authKey = params.authKey;
|
|
58
|
+
}
|
|
59
|
+
async _request(params) {
|
|
60
|
+
try {
|
|
61
|
+
return await (0, request_promise_native_1.default)(params);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if (err.statusCode) {
|
|
65
|
+
throw new Error(`${err.statusCode} - ${params.method}: ${params.url} - "${JSON.stringify(err.error)}"`);
|
|
66
|
+
}
|
|
67
|
+
else if (err.error instanceof Error) {
|
|
68
|
+
throw err.error;
|
|
69
|
+
}
|
|
70
|
+
throw err;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
_buildQueryString(params) {
|
|
74
|
+
const query = [];
|
|
75
|
+
for (const [key, value] of Object.entries(params)) {
|
|
76
|
+
value && query.push(`${key}=${value}`);
|
|
77
|
+
}
|
|
78
|
+
return query.length ? `?${query.join('&')}` : '';
|
|
79
|
+
}
|
|
80
|
+
getMessage(params) {
|
|
81
|
+
const { method, url, payload = {} } = params;
|
|
82
|
+
const parsedUrl = new URLClass(url);
|
|
83
|
+
return [method, parsedUrl.pathname + parsedUrl.search, JSON.stringify(payload)].join('|');
|
|
84
|
+
}
|
|
85
|
+
sign(params) {
|
|
86
|
+
const message = this.getMessage(params);
|
|
87
|
+
const privateKey = this.authKey.toBuffer();
|
|
88
|
+
const messageHash = crypto_wallet_core_1.BitcoreLib.crypto.Hash.sha256sha256(Buffer.from(message));
|
|
89
|
+
return secp256k1.sign(messageHash, privateKey).signature.toString('hex');
|
|
90
|
+
}
|
|
91
|
+
async register(params) {
|
|
92
|
+
const { payload } = params;
|
|
93
|
+
const { baseUrl = this.apiUrl } = payload;
|
|
94
|
+
const url = `${baseUrl}/wallet`;
|
|
95
|
+
const signature = this.sign({ method: 'POST', url, payload });
|
|
96
|
+
return this._request({
|
|
97
|
+
method: 'POST',
|
|
98
|
+
url,
|
|
99
|
+
headers: { 'x-signature': signature },
|
|
100
|
+
body: payload,
|
|
101
|
+
json: true
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async getToken(contractAddress) {
|
|
105
|
+
const url = `${this.apiUrl}/token/${contractAddress}`;
|
|
106
|
+
return this._request({ method: 'GET', url, json: true });
|
|
107
|
+
}
|
|
108
|
+
async getSolanaTokens(address) {
|
|
109
|
+
const url = `${this.apiUrl}/ata/${address}`;
|
|
110
|
+
return this._request({ method: 'GET', url, json: true });
|
|
111
|
+
}
|
|
112
|
+
async getBalance(params) {
|
|
113
|
+
const { payload, pubKey, time, address, hex } = params;
|
|
114
|
+
let url = `${this.apiUrl}/wallet/${pubKey}/balance`;
|
|
115
|
+
if (time) {
|
|
116
|
+
url += `/${time}`;
|
|
117
|
+
}
|
|
118
|
+
const query = [];
|
|
119
|
+
if (payload?.tokenContractAddress) {
|
|
120
|
+
query.push(`tokenAddress=${payload.tokenContractAddress}`);
|
|
121
|
+
}
|
|
122
|
+
if (address) {
|
|
123
|
+
query.push(`address=${address}`);
|
|
124
|
+
}
|
|
125
|
+
if (hex) {
|
|
126
|
+
query.push('hex=true');
|
|
127
|
+
}
|
|
128
|
+
url += query.length ? `?${query.join('&')}` : '';
|
|
129
|
+
const signature = this.sign({ method: 'GET', url });
|
|
130
|
+
return this._request({
|
|
131
|
+
method: 'GET',
|
|
132
|
+
url,
|
|
133
|
+
headers: { 'x-signature': signature },
|
|
134
|
+
json: true
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async getTransaction(params) {
|
|
138
|
+
const { txid, populated } = params;
|
|
139
|
+
const url = `${this.apiUrl}/tx/${txid}${populated ? '/populated' : ''}`;
|
|
140
|
+
return this._request({ method: 'GET', url, json: true });
|
|
141
|
+
}
|
|
142
|
+
async getNonce(params) {
|
|
143
|
+
const { address } = params;
|
|
144
|
+
const url = `${this.apiUrl}/address/${address}/txs/count`;
|
|
145
|
+
return this._request({ method: 'GET', url, json: true });
|
|
146
|
+
}
|
|
147
|
+
getCoins(params) {
|
|
148
|
+
const { payload, pubKey, includeSpent } = params;
|
|
149
|
+
const url = `${this.apiUrl}/wallet/${pubKey}/utxos?includeSpent=${includeSpent}`;
|
|
150
|
+
const signature = this.sign({ method: 'GET', url, payload });
|
|
151
|
+
return request_1.default.get(url, {
|
|
152
|
+
headers: { 'x-signature': signature },
|
|
153
|
+
body: payload,
|
|
154
|
+
json: true
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
listTransactions(params) {
|
|
158
|
+
const { pubKey, startBlock, startDate, endBlock, endDate, includeMempool, payload, tokenContractAddress, limit } = params;
|
|
159
|
+
let url = `${this.apiUrl}/wallet/${pubKey}/transactions`;
|
|
160
|
+
let query = '';
|
|
161
|
+
if (startBlock) {
|
|
162
|
+
query += `startBlock=${startBlock}&`;
|
|
163
|
+
}
|
|
164
|
+
if (endBlock) {
|
|
165
|
+
query += `endBlock=${endBlock}&`;
|
|
166
|
+
}
|
|
167
|
+
if (startDate) {
|
|
168
|
+
query += `startDate=${startDate}&`;
|
|
169
|
+
}
|
|
170
|
+
if (endDate) {
|
|
171
|
+
query += `endDate=${endDate}&`;
|
|
172
|
+
}
|
|
173
|
+
if (includeMempool) {
|
|
174
|
+
query += 'includeMempool=true&';
|
|
175
|
+
}
|
|
176
|
+
if (tokenContractAddress) {
|
|
177
|
+
query += `tokenAddress=${tokenContractAddress}&`;
|
|
178
|
+
}
|
|
179
|
+
if (limit) {
|
|
180
|
+
query += `limit=${limit}&`;
|
|
181
|
+
}
|
|
182
|
+
query = query.endsWith('&') ? query.slice(0, -1) : query;
|
|
183
|
+
if (query) {
|
|
184
|
+
url += '?' + query;
|
|
185
|
+
}
|
|
186
|
+
const signature = this.sign({ method: 'GET', url, payload });
|
|
187
|
+
return request_1.default.get(url, {
|
|
188
|
+
headers: { 'x-signature': signature },
|
|
189
|
+
body: payload,
|
|
190
|
+
json: true
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async getFee(params) {
|
|
194
|
+
const { target, txType } = params;
|
|
195
|
+
const url = `${this.apiUrl}/fee/${target}${this._buildQueryString({ txType })}`;
|
|
196
|
+
const result = await this._request({ method: 'GET', url, json: true });
|
|
197
|
+
if (result.errors?.length) {
|
|
198
|
+
throw new Error(result.errors[0]);
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
async getPriorityFee(params) {
|
|
203
|
+
const { percentile } = params;
|
|
204
|
+
const url = `${this.apiUrl}/priorityFee/${percentile}`;
|
|
205
|
+
const result = await this._request({ method: 'GET', url, json: true });
|
|
206
|
+
if (result.errors?.length) {
|
|
207
|
+
throw new Error(result.errors[0]);
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
async importAddresses(params) {
|
|
212
|
+
const { payload, pubKey } = params;
|
|
213
|
+
const url = `${this.apiUrl}/wallet/${pubKey}`;
|
|
214
|
+
for (let i = 0; i < payload.length; i += 100) {
|
|
215
|
+
const body = payload.slice(i, i + 100);
|
|
216
|
+
console.log(`Importing addresses ${i + 1}-${i + body.length} of ${payload.length}`);
|
|
217
|
+
if (i >= 100) {
|
|
218
|
+
await utils_1.utils.sleep(1000);
|
|
219
|
+
}
|
|
220
|
+
const signature = this.sign({ method: 'POST', url, payload: body });
|
|
221
|
+
await this._request({
|
|
222
|
+
method: 'POST',
|
|
223
|
+
url,
|
|
224
|
+
headers: { 'x-signature': signature },
|
|
225
|
+
body,
|
|
226
|
+
json: true
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async broadcast(params) {
|
|
231
|
+
const { payload } = params;
|
|
232
|
+
const url = `${this.apiUrl}/tx/send`;
|
|
233
|
+
return this._request({ method: 'POST', url, body: payload, json: true });
|
|
234
|
+
}
|
|
235
|
+
async checkWallet(params) {
|
|
236
|
+
const { pubKey } = params;
|
|
237
|
+
const url = `${this.apiUrl}/wallet/${pubKey}/check`;
|
|
238
|
+
const signature = this.sign({ method: 'GET', url });
|
|
239
|
+
return this._request({
|
|
240
|
+
method: 'GET',
|
|
241
|
+
url,
|
|
242
|
+
headers: { 'x-signature': signature },
|
|
243
|
+
json: true
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
getAddresses(params) {
|
|
247
|
+
const { pubKey } = params;
|
|
248
|
+
const url = `${this.apiUrl}/wallet/${pubKey}/addresses`;
|
|
249
|
+
const signature = this.sign({ method: 'GET', url });
|
|
250
|
+
return this._request({
|
|
251
|
+
method: 'GET',
|
|
252
|
+
url,
|
|
253
|
+
headers: { 'x-signature': signature },
|
|
254
|
+
json: true
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
getAccountFlags(params) {
|
|
258
|
+
const { address } = params;
|
|
259
|
+
const url = `${this.apiUrl}/address/${address}/flags`;
|
|
260
|
+
return this._request({ method: 'GET', url, json: true });
|
|
261
|
+
}
|
|
262
|
+
estimateGas(params) {
|
|
263
|
+
const { to, from, data, value } = params;
|
|
264
|
+
const body = { to, from, data, value };
|
|
265
|
+
const url = `${this.apiUrl}/gas`;
|
|
266
|
+
return this._request({ method: 'POST', url, json: true, body });
|
|
267
|
+
}
|
|
268
|
+
getL1Fee(params) {
|
|
269
|
+
const { rawTx, safe } = params;
|
|
270
|
+
const body = { rawTx };
|
|
271
|
+
const url = `${this.apiUrl}/l1/fee${safe ? '?safe=true' : ''}`;
|
|
272
|
+
return this._request({ method: 'POST', url, json: true, body });
|
|
273
|
+
}
|
|
274
|
+
getBlockTip() {
|
|
275
|
+
const url = `${this.apiUrl}/block/tip`;
|
|
276
|
+
return this._request({ method: 'GET', url, json: true });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
exports.Client = Client;
|
|
280
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA0B;AAC1B,wEAA6D;AAC7D,sDAAoC;AACpC,oFAA6C;AAC7C,qDAAuC;AACvC,mCAAgC;AAEhC,MAAM,YAAY,GAAI,MAAc,CAAC,MAAM,CAAC;AAC5C,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,SAAG,CAAC;AACvD,MAAa,MAAM;IAIjB,YAAY,MAGX;QAsGD,mBAAc,GAAG,KAAK,WAAU,MAAM;YACpC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;YACpC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,YAAY,OAAO,GAAG,IAAI,EAAE,CAAC;YACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC;QA1GA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC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AQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,QAAQ,CAAC,MAAyC;QAChD,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QAC/B,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,UAAU,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,WAAW;QACT,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,YAAY,CAAC;QACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;CACF;AArQD,wBAqQC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare function shaHash(data: any, algo?: string): string;
|
|
2
|
+
export declare function encryptEncryptionKey(encryptionKey: any, password: any): string;
|
|
3
|
+
export declare function decryptEncryptionKey(encEncryptionKey: any, password: any): string;
|
|
4
|
+
export declare function encryptPrivateKey(privKey: any, pubKey: any, encryptionKey: any): string;
|
|
5
|
+
declare function decryptPrivateKey(encPrivateKey: string, pubKey: string, encryptionKey: string): string;
|
|
6
|
+
export declare function bitcoinCoreDecrypt(jsonl: Array<{
|
|
7
|
+
cipherText?: string;
|
|
8
|
+
derivationMethod?: string;
|
|
9
|
+
rounds?: number;
|
|
10
|
+
salt?: Buffer;
|
|
11
|
+
pubKey?: string;
|
|
12
|
+
address?: string;
|
|
13
|
+
}>, passphrase: string): {
|
|
14
|
+
jsonlDecrypted: any[];
|
|
15
|
+
master: any;
|
|
16
|
+
};
|
|
17
|
+
export declare function generateEncryptionKey(): Buffer<ArrayBufferLike>;
|
|
18
|
+
export declare const Encryption: {
|
|
19
|
+
encryptEncryptionKey: typeof encryptEncryptionKey;
|
|
20
|
+
decryptEncryptionKey: typeof decryptEncryptionKey;
|
|
21
|
+
encryptPrivateKey: typeof encryptPrivateKey;
|
|
22
|
+
decryptPrivateKey: typeof decryptPrivateKey;
|
|
23
|
+
generateEncryptionKey: typeof generateEncryptionKey;
|
|
24
|
+
bitcoinCoreDecrypt: typeof bitcoinCoreDecrypt;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/encryption.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO,CAAC,IAAI,KAAA,EAAE,IAAI,SAAW,UAO5C;AAMD,wBAAgB,oBAAoB,CAAC,aAAa,KAAA,EAAE,QAAQ,KAAA,UAO3D;AAED,wBAAgB,oBAAoB,CAAC,gBAAgB,KAAA,EAAE,QAAQ,KAAA,UAO9D;AAED,wBAAgB,iBAAiB,CAAC,OAAO,KAAA,EAAE,MAAM,KAAA,EAAE,aAAa,KAAA,UAO/D;AAED,iBAAS,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAOtF;AAkBD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC,EACF,UAAU,EAAE,MAAM;;;EAgCnB;AAkBD,wBAAgB,qBAAqB,4BAEpC;AAED,eAAO,MAAM,UAAU;;;;;;;CAOtB,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Encryption = void 0;
|
|
7
|
+
exports.shaHash = shaHash;
|
|
8
|
+
exports.encryptEncryptionKey = encryptEncryptionKey;
|
|
9
|
+
exports.decryptEncryptionKey = decryptEncryptionKey;
|
|
10
|
+
exports.encryptPrivateKey = encryptPrivateKey;
|
|
11
|
+
exports.bitcoinCoreDecrypt = bitcoinCoreDecrypt;
|
|
12
|
+
exports.generateEncryptionKey = generateEncryptionKey;
|
|
13
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
14
|
+
const crypto_wallet_core_1 = require("@bitpay-labs/crypto-wallet-core");
|
|
15
|
+
function shaHash(data, algo = 'sha256') {
|
|
16
|
+
const hash = crypto_1.default
|
|
17
|
+
.createHash(algo)
|
|
18
|
+
.update(data, 'utf8')
|
|
19
|
+
.digest('hex')
|
|
20
|
+
.toUpperCase();
|
|
21
|
+
return hash;
|
|
22
|
+
}
|
|
23
|
+
const SHA512 = data => shaHash(data, 'sha512');
|
|
24
|
+
const SHA256 = data => shaHash(data, 'sha256');
|
|
25
|
+
const algo = 'aes-256-cbc';
|
|
26
|
+
function encryptEncryptionKey(encryptionKey, password) {
|
|
27
|
+
const password_hash = Buffer.from(SHA512(password));
|
|
28
|
+
const key = password_hash.subarray(0, 32);
|
|
29
|
+
const iv = password_hash.subarray(32, 48);
|
|
30
|
+
const cipher = crypto_1.default.createCipheriv(algo, key, iv);
|
|
31
|
+
const encData = cipher.update(encryptionKey, 'hex', 'hex') + cipher.final('hex');
|
|
32
|
+
return encData;
|
|
33
|
+
}
|
|
34
|
+
function decryptEncryptionKey(encEncryptionKey, password) {
|
|
35
|
+
const password_hash = Buffer.from(SHA512(password));
|
|
36
|
+
const key = password_hash.subarray(0, 32);
|
|
37
|
+
const iv = password_hash.subarray(32, 48);
|
|
38
|
+
const decipher = crypto_1.default.createDecipheriv(algo, key, iv);
|
|
39
|
+
const decrypted = decipher.update(encEncryptionKey, 'hex', 'hex') + decipher.final('hex');
|
|
40
|
+
return decrypted;
|
|
41
|
+
}
|
|
42
|
+
function encryptPrivateKey(privKey, pubKey, encryptionKey) {
|
|
43
|
+
const key = Buffer.from(encryptionKey, 'hex');
|
|
44
|
+
const doubleHash = Buffer.from(SHA256(SHA256(pubKey)), 'hex');
|
|
45
|
+
const iv = doubleHash.subarray(0, 16);
|
|
46
|
+
const cipher = crypto_1.default.createCipheriv(algo, key, iv);
|
|
47
|
+
const encData = cipher.update(privKey, 'utf8', 'hex') + cipher.final('hex');
|
|
48
|
+
return encData;
|
|
49
|
+
}
|
|
50
|
+
function decryptPrivateKey(encPrivateKey, pubKey, encryptionKey) {
|
|
51
|
+
const key = Buffer.from(encryptionKey, 'hex');
|
|
52
|
+
const doubleHash = Buffer.from(SHA256(SHA256(pubKey)), 'hex');
|
|
53
|
+
const iv = doubleHash.subarray(0, 16);
|
|
54
|
+
const decipher = crypto_1.default.createDecipheriv(algo, key, iv);
|
|
55
|
+
const decrypted = decipher.update(encPrivateKey, 'hex', 'utf8') + decipher.final('utf8');
|
|
56
|
+
return decrypted;
|
|
57
|
+
}
|
|
58
|
+
function sha512KDF(passphrase, salt, derivationOptions) {
|
|
59
|
+
const rounds = derivationOptions.rounds || 1;
|
|
60
|
+
if (!Buffer.isBuffer(salt)) {
|
|
61
|
+
salt = Buffer.from(salt, 'hex');
|
|
62
|
+
}
|
|
63
|
+
let derivation = Buffer.concat([Buffer.from(''), Buffer.from(passphrase), salt]);
|
|
64
|
+
for (let i = 0; i < rounds; i++) {
|
|
65
|
+
derivation = crypto_1.default
|
|
66
|
+
.createHash('sha512')
|
|
67
|
+
.update(derivation)
|
|
68
|
+
.digest();
|
|
69
|
+
}
|
|
70
|
+
return derivation.toString('hex');
|
|
71
|
+
}
|
|
72
|
+
function bitcoinCoreDecrypt(jsonl, passphrase) {
|
|
73
|
+
const derivationMethods = { SHA512: 0 };
|
|
74
|
+
let master = null;
|
|
75
|
+
const jsonlDecrypted = [];
|
|
76
|
+
for (const line of jsonl) {
|
|
77
|
+
const cipherText = line.cipherText;
|
|
78
|
+
if (line.derivationMethod) {
|
|
79
|
+
const salt = line.salt;
|
|
80
|
+
const derivationOptions = {
|
|
81
|
+
method: derivationMethods[line.derivationMethod],
|
|
82
|
+
rounds: line.rounds
|
|
83
|
+
};
|
|
84
|
+
const key = sha512KDF(passphrase, salt, derivationOptions);
|
|
85
|
+
master = decrypt({ cipherText, key });
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const privKey = decrypt({
|
|
89
|
+
key: master,
|
|
90
|
+
iv: crypto_wallet_core_1.BitcoreLib.crypto.Hash.sha256sha256(Buffer.from(line.pubKey, 'hex')),
|
|
91
|
+
cipherText
|
|
92
|
+
});
|
|
93
|
+
const address = line.address.split(':');
|
|
94
|
+
const keyObj = {
|
|
95
|
+
privKey,
|
|
96
|
+
pubKey: line.pubKey,
|
|
97
|
+
address: address[address.length - 1]
|
|
98
|
+
};
|
|
99
|
+
jsonlDecrypted.push(keyObj);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { jsonlDecrypted, master };
|
|
103
|
+
}
|
|
104
|
+
function decrypt(opts) {
|
|
105
|
+
const key = Buffer.from(opts.key, 'hex');
|
|
106
|
+
let secondHalf;
|
|
107
|
+
if (opts.iv) {
|
|
108
|
+
secondHalf = opts.iv.slice(0, 16);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
secondHalf = key.subarray(32, 48);
|
|
112
|
+
}
|
|
113
|
+
const cipherText = Buffer.from(opts.cipherText, 'hex');
|
|
114
|
+
const firstHalf = key.subarray(0, 32);
|
|
115
|
+
const AESDecipher = crypto_1.default.createDecipheriv(algo, firstHalf, secondHalf);
|
|
116
|
+
const plainText = Buffer.concat([AESDecipher.update(cipherText), AESDecipher.final()]).toString('hex');
|
|
117
|
+
return plainText;
|
|
118
|
+
}
|
|
119
|
+
function generateEncryptionKey() {
|
|
120
|
+
return crypto_1.default.randomBytes(32);
|
|
121
|
+
}
|
|
122
|
+
exports.Encryption = {
|
|
123
|
+
encryptEncryptionKey,
|
|
124
|
+
decryptEncryptionKey,
|
|
125
|
+
encryptPrivateKey,
|
|
126
|
+
decryptPrivateKey,
|
|
127
|
+
generateEncryptionKey,
|
|
128
|
+
bitcoinCoreDecrypt
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=encryption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../../src/encryption.ts"],"names":[],"mappings":";;;;;;AAGA,0BAOC;AAMD,oDAOC;AAED,oDAOC;AAED,8CAOC;AA2BD,gDAyCC;AAkBD,sDAEC;AAjID,oDAA4B;AAC5B,wEAAwE;AAExE,SAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ;IAC3C,MAAM,IAAI,GAAG,gBAAM;SAChB,UAAU,CAAC,IAAI,CAAC;SAChB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;SACpB,MAAM,CAAC,KAAK,CAAC;SACb,WAAW,EAAE,CAAC;IACjB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC/C,MAAM,IAAI,GAAG,aAAa,CAAC;AAE3B,SAAgB,oBAAoB,CAAC,aAAa,EAAE,QAAQ;IA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C,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEvG,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,gBAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAEY,QAAA,UAAU,GAAG;IACxB,oBAAoB;IACpB,oBAAoB;IACpB,iBAAiB;IACjB,iBAAiB;IACjB,qBAAqB;IACrB,kBAAkB;CACnB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'source-map-support/register';
|
|
2
|
+
import * as CryptoWalletCore from '@bitpay-labs/crypto-wallet-core';
|
|
3
|
+
import { Client } from './client';
|
|
4
|
+
import { Encryption } from './encryption';
|
|
5
|
+
import { Storage } from './storage';
|
|
6
|
+
import { ParseApiStream, StreamUtil } from './stream-util';
|
|
7
|
+
import { Wallet } from './wallet';
|
|
8
|
+
export * from './wallet';
|
|
9
|
+
export { Wallet, Client, Storage, ParseApiStream, Encryption, StreamUtil, CryptoWalletCore };
|
|
10
|
+
export type * as Types from './types';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,KAAK,gBAAgB,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,cAAc,EACd,UAAU,EACV,UAAU,EACV,gBAAgB,EACjB,CAAC;AAGF,YAAY,KAAK,KAAK,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.CryptoWalletCore = exports.StreamUtil = exports.Encryption = exports.ParseApiStream = exports.Storage = exports.Client = exports.Wallet = void 0;
|
|
40
|
+
require("source-map-support/register");
|
|
41
|
+
const CryptoWalletCore = __importStar(require("@bitpay-labs/crypto-wallet-core"));
|
|
42
|
+
exports.CryptoWalletCore = CryptoWalletCore;
|
|
43
|
+
const client_1 = require("./client");
|
|
44
|
+
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
45
|
+
const encryption_1 = require("./encryption");
|
|
46
|
+
Object.defineProperty(exports, "Encryption", { enumerable: true, get: function () { return encryption_1.Encryption; } });
|
|
47
|
+
const storage_1 = require("./storage");
|
|
48
|
+
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return storage_1.Storage; } });
|
|
49
|
+
const stream_util_1 = require("./stream-util");
|
|
50
|
+
Object.defineProperty(exports, "ParseApiStream", { enumerable: true, get: function () { return stream_util_1.ParseApiStream; } });
|
|
51
|
+
Object.defineProperty(exports, "StreamUtil", { enumerable: true, get: function () { return stream_util_1.StreamUtil; } });
|
|
52
|
+
const wallet_1 = require("./wallet");
|
|
53
|
+
Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return wallet_1.Wallet; } });
|
|
54
|
+
__exportStar(require("./wallet"), exports);
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAqC;AACrC,kFAAoE;AAelE,4CAAgB;AAdlB,qCAAkC;AAShC,uFATO,eAAM,OASP;AARR,6CAA0C;AAWxC,2FAXO,uBAAU,OAWP;AAVZ,uCAAoC;AAQlC,wFARO,iBAAO,OAQP;AAPT,+CAA2D;AAQzD,+FARO,4BAAc,OAQP;AAEd,2FAVuB,wBAAU,OAUvB;AATZ,qCAAkC;AAIhC,uFAJO,eAAM,OAIP;AAFR,2CAAyB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { LevelUp } from 'levelup';
|
|
2
|
+
export declare class Level {
|
|
3
|
+
path: string;
|
|
4
|
+
db: LevelUp;
|
|
5
|
+
constructor(params: {
|
|
6
|
+
path?: string;
|
|
7
|
+
createIfMissing: boolean;
|
|
8
|
+
errorIfExists: boolean;
|
|
9
|
+
});
|
|
10
|
+
loadWallet(params: {
|
|
11
|
+
name: string;
|
|
12
|
+
}): Promise<string>;
|
|
13
|
+
deleteWallet(params: {
|
|
14
|
+
name: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
listWallets(): Promise<any>;
|
|
17
|
+
listKeys(): Promise<any>;
|
|
18
|
+
saveWallet(params: any): Promise<any>;
|
|
19
|
+
getKey(params: {
|
|
20
|
+
address: string;
|
|
21
|
+
name: string;
|
|
22
|
+
keepAlive: boolean;
|
|
23
|
+
open: boolean;
|
|
24
|
+
}): Promise<string>;
|
|
25
|
+
addKeys(params: {
|
|
26
|
+
name: string;
|
|
27
|
+
key: any;
|
|
28
|
+
toStore: string;
|
|
29
|
+
keepAlive: boolean;
|
|
30
|
+
open: boolean;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
getAddress(params: {
|
|
33
|
+
name: string;
|
|
34
|
+
address: string;
|
|
35
|
+
keepAlive: boolean;
|
|
36
|
+
open: boolean;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
address: string;
|
|
39
|
+
pubKey: any;
|
|
40
|
+
path: any;
|
|
41
|
+
}>;
|
|
42
|
+
getAddresses(params: {
|
|
43
|
+
name: string;
|
|
44
|
+
limit?: number;
|
|
45
|
+
skip?: number;
|
|
46
|
+
}): Promise<unknown>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=level.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../../../src/storage/level.ts"],"names":[],"mappings":"AAIA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAK3C,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;gBAEA,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,OAAO,CAAA;KAAE;IAkCjF,UAAU,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAKnC,YAAY,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IA2BrC,WAAW;IAgBX,QAAQ;IAkBR,UAAU,CAAC,MAAM,KAAA;IAMjB,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE;IAKnF,OAAO,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE;IAK9F,UAAU,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE;;;;;IAUvF,YAAY,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,K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