@coopenomics/sdk 2.2.4 → 2.2.5
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/dist/index.cjs +451 -231
- package/dist/index.d.cts +647 -441
- package/dist/index.d.mts +647 -441
- package/dist/index.d.ts +647 -441
- package/dist/index.mjs +451 -231
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -11,17 +11,17 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
|
|
12
12
|
const WebSocket__default = /*#__PURE__*/_interopDefaultCompat(WebSocket);
|
|
13
13
|
|
|
14
|
-
var __defProp$
|
|
15
|
-
var __defNormalProp$
|
|
16
|
-
var __publicField$
|
|
17
|
-
__defNormalProp$
|
|
14
|
+
var __defProp$4 = Object.defineProperty;
|
|
15
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
|
+
var __publicField$4 = (obj, key, value) => {
|
|
17
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
18
18
|
return value;
|
|
19
19
|
};
|
|
20
20
|
class Account {
|
|
21
21
|
constructor() {
|
|
22
|
-
__publicField$
|
|
23
|
-
__publicField$
|
|
24
|
-
__publicField$
|
|
22
|
+
__publicField$4(this, "username");
|
|
23
|
+
__publicField$4(this, "private_key");
|
|
24
|
+
__publicField$4(this, "public_key");
|
|
25
25
|
this.username = Account.generateUsername();
|
|
26
26
|
const keys = Account.generateKeys();
|
|
27
27
|
this.private_key = keys.private_key;
|
|
@@ -54,52 +54,209 @@ class Account {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
var __defProp$
|
|
58
|
-
var __defNormalProp$
|
|
59
|
-
var __publicField$
|
|
60
|
-
__defNormalProp$
|
|
57
|
+
var __defProp$3 = Object.defineProperty;
|
|
58
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
59
|
+
var __publicField$3 = (obj, key, value) => {
|
|
60
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
61
|
+
return value;
|
|
62
|
+
};
|
|
63
|
+
class Blockchain {
|
|
64
|
+
/**
|
|
65
|
+
* Конструктор класса Blockchain.
|
|
66
|
+
* @param config Конфигурация блокчейна, включающая URL цепочки и идентификатор цепочки.
|
|
67
|
+
*/
|
|
68
|
+
constructor(config) {
|
|
69
|
+
this.config = config;
|
|
70
|
+
__publicField$3(this, "apiClient");
|
|
71
|
+
__publicField$3(this, "contractKit");
|
|
72
|
+
__publicField$3(this, "session");
|
|
73
|
+
this.apiClient = new antelope.APIClient({ url: config.chain_url });
|
|
74
|
+
this.contractKit = new contract.ContractKit({ client: this.apiClient });
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Получение информации о блокчейне.
|
|
78
|
+
* @returns Объект с информацией о текущем состоянии блокчейна.
|
|
79
|
+
*/
|
|
80
|
+
async getInfo() {
|
|
81
|
+
return this.apiClient.v1.chain.get_info();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Устанавливает приватный ключ (WIF) для текущей сессии.
|
|
85
|
+
* @param username Имя пользователя (аккаунт).
|
|
86
|
+
* @param wif Приватный ключ в формате WIF.
|
|
87
|
+
* @param permission Тип разрешения, который используется для подписания транзакции (по умолчанию = 'active')
|
|
88
|
+
* @returns Текущий экземпляр Blockchain для цепочного вызова.
|
|
89
|
+
*/
|
|
90
|
+
setWif(username, wif, permission = "active") {
|
|
91
|
+
this.session = new session.Session({
|
|
92
|
+
actor: username,
|
|
93
|
+
permission,
|
|
94
|
+
chain: {
|
|
95
|
+
id: this.config.chain_id,
|
|
96
|
+
url: this.config.chain_url
|
|
97
|
+
},
|
|
98
|
+
walletPlugin: new walletPluginPrivatekey.WalletPluginPrivateKey(antelope.PrivateKey.fromString(wif))
|
|
99
|
+
});
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Выполнение транзакции с передачей одного или нескольких действий.
|
|
104
|
+
* @param actionOrActions Действие или массив действий для выполнения.
|
|
105
|
+
* @param broadcast Если true, транзакция будет отправлена в сеть.
|
|
106
|
+
* @returns Результат выполнения транзакции.
|
|
107
|
+
* @throws Ошибка, если сессия не инициализирована.
|
|
108
|
+
*/
|
|
109
|
+
async transact(actionOrActions, broadcast = true) {
|
|
110
|
+
if (!this.session)
|
|
111
|
+
throw new Error("\u0421\u0435\u0441\u0441\u0438\u044F \u043D\u0435 \u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u0430.");
|
|
112
|
+
const actions = Array.isArray(actionOrActions) ? await Promise.all(actionOrActions.map((action) => this.formActionFromAbi(action))) : [await this.formActionFromAbi(actionOrActions)];
|
|
113
|
+
return this.session.transact({ actions }, { broadcast });
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Получение всех строк таблицы смарт-контракта.
|
|
117
|
+
* @param code Код (аккаунт) контракта.
|
|
118
|
+
* @param scope Область видимости (scope) таблицы.
|
|
119
|
+
* @param tableName Имя таблицы.
|
|
120
|
+
* @returns Массив строк таблицы.
|
|
121
|
+
*/
|
|
122
|
+
async getAllRows(code, scope, tableName) {
|
|
123
|
+
const abi = await this.getAbi(code);
|
|
124
|
+
const table = this.createTable(code, tableName, abi);
|
|
125
|
+
const rows = await table.all({ scope });
|
|
126
|
+
return JSON.parse(JSON.stringify(rows));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Запрос строк таблицы с использованием фильтров.
|
|
130
|
+
* @param code Код (аккаунт) контракта.
|
|
131
|
+
* @param scope Область видимости (scope) таблицы.
|
|
132
|
+
* @param tableName Имя таблицы.
|
|
133
|
+
* @param options Опции для фильтрации данных.
|
|
134
|
+
* @returns Массив строк, соответствующих фильтрам.
|
|
135
|
+
*/
|
|
136
|
+
async query(code, scope, tableName, options = { indexPosition: "primary" }) {
|
|
137
|
+
const { indexPosition = "primary", from, to, maxRows } = options;
|
|
138
|
+
const abi = await this.getAbi(code);
|
|
139
|
+
const table = this.createTable(code, tableName, abi);
|
|
140
|
+
const rows = await table.query({
|
|
141
|
+
scope,
|
|
142
|
+
index_position: indexPosition,
|
|
143
|
+
from,
|
|
144
|
+
to,
|
|
145
|
+
maxRows
|
|
146
|
+
});
|
|
147
|
+
return JSON.parse(JSON.stringify(rows));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Получение одной строки таблицы по первичному ключу.
|
|
151
|
+
* @param code Код (аккаунт) контракта.
|
|
152
|
+
* @param scope Область видимости (scope) таблицы.
|
|
153
|
+
* @param tableName Имя таблицы.
|
|
154
|
+
* @param primaryKey Первичный ключ строки.
|
|
155
|
+
* @param indexPosition Индекс для поиска строки (по умолчанию 'primary').
|
|
156
|
+
* @returns Строка таблицы или null, если не найдена.
|
|
157
|
+
*/
|
|
158
|
+
async getRow(code, scope, tableName, primaryKey, indexPosition = "primary") {
|
|
159
|
+
const abi = await this.getAbi(code);
|
|
160
|
+
const table = this.createTable(code, tableName, abi);
|
|
161
|
+
const row = await table.get(String(primaryKey), {
|
|
162
|
+
scope,
|
|
163
|
+
index_position: indexPosition
|
|
164
|
+
});
|
|
165
|
+
return row ? JSON.parse(JSON.stringify(row)) : null;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Создает объект действия (Action) из ABI контракта.
|
|
169
|
+
* @param action Объект действия.
|
|
170
|
+
* @returns Объект Action.
|
|
171
|
+
*/
|
|
172
|
+
async formActionFromAbi(action) {
|
|
173
|
+
const abi = await this.getAbi(action.account);
|
|
174
|
+
return antelope.Action.from(action, abi);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Получение ABI контракта.
|
|
178
|
+
* @param account Код (аккаунт) контракта.
|
|
179
|
+
* @returns ABI контракта.
|
|
180
|
+
* @throws Ошибка, если ABI не найден.
|
|
181
|
+
*/
|
|
182
|
+
async getAbi(account) {
|
|
183
|
+
const { abi } = await this.apiClient.v1.chain.get_abi(account);
|
|
184
|
+
if (!abi)
|
|
185
|
+
throw new Error(`ABI \u0434\u043B\u044F \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430 "${account}" \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D.`);
|
|
186
|
+
return abi;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Создает объект таблицы (Table) для работы с данными.
|
|
190
|
+
* @param code Код (аккаунт) контракта.
|
|
191
|
+
* @param tableName Имя таблицы.
|
|
192
|
+
* @param abi ABI контракта.
|
|
193
|
+
* @returns Объект Table.
|
|
194
|
+
*/
|
|
195
|
+
createTable(code, tableName, abi) {
|
|
196
|
+
return new contract.Table({
|
|
197
|
+
abi,
|
|
198
|
+
account: code,
|
|
199
|
+
name: tableName,
|
|
200
|
+
client: this.apiClient
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
var __defProp$2 = Object.defineProperty;
|
|
206
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
207
|
+
var __publicField$2 = (obj, key, value) => {
|
|
208
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
61
209
|
return value;
|
|
62
210
|
};
|
|
63
211
|
class Canvas {
|
|
212
|
+
/**
|
|
213
|
+
* Создаёт экземпляр класса `Canvas` и подготавливает холст для рисования подписи.
|
|
214
|
+
*
|
|
215
|
+
* @param container - HTML-элемент, внутри которого создаётся `<canvas>`.
|
|
216
|
+
* @param opts - Настройки:
|
|
217
|
+
* - `lineWidth` - Толщина линии для рисования (по умолчанию 5).
|
|
218
|
+
* - `strokeStyle` - Цвет линии для рисования (по умолчанию чёрный, `#000`).
|
|
219
|
+
*/
|
|
64
220
|
constructor(container, opts = {}) {
|
|
65
221
|
this.container = container;
|
|
66
222
|
this.opts = opts;
|
|
67
|
-
__publicField$
|
|
68
|
-
__publicField$
|
|
69
|
-
__publicField$
|
|
70
|
-
__publicField$
|
|
71
|
-
__publicField$
|
|
72
|
-
__publicField$
|
|
223
|
+
__publicField$2(this, "canvas");
|
|
224
|
+
__publicField$2(this, "ctx");
|
|
225
|
+
__publicField$2(this, "drawing", false);
|
|
226
|
+
__publicField$2(this, "lastX", 0);
|
|
227
|
+
__publicField$2(this, "lastY", 0);
|
|
228
|
+
__publicField$2(this, "onMouseDown", (e) => {
|
|
73
229
|
e.preventDefault();
|
|
74
230
|
this.drawing = true;
|
|
75
231
|
const rect = this.canvas.getBoundingClientRect();
|
|
76
232
|
this.lastX = e.clientX - rect.left;
|
|
77
233
|
this.lastY = e.clientY - rect.top;
|
|
78
234
|
});
|
|
79
|
-
__publicField$
|
|
235
|
+
__publicField$2(this, "onMouseMove", (e) => {
|
|
80
236
|
if (!this.drawing)
|
|
81
237
|
return;
|
|
82
238
|
e.preventDefault();
|
|
83
239
|
this.drawLine(e.clientX, e.clientY);
|
|
84
240
|
});
|
|
85
|
-
__publicField$
|
|
241
|
+
__publicField$2(this, "onMouseUp", () => {
|
|
86
242
|
this.drawing = false;
|
|
87
243
|
});
|
|
88
|
-
__publicField$
|
|
244
|
+
__publicField$2(this, "onTouchStart", (e) => {
|
|
89
245
|
e.preventDefault();
|
|
90
246
|
this.drawing = true;
|
|
91
247
|
const rect = this.canvas.getBoundingClientRect();
|
|
92
|
-
|
|
93
|
-
this.
|
|
248
|
+
const t = e.touches[0];
|
|
249
|
+
this.lastX = t.clientX - rect.left;
|
|
250
|
+
this.lastY = t.clientY - rect.top;
|
|
94
251
|
});
|
|
95
|
-
__publicField$
|
|
252
|
+
__publicField$2(this, "onTouchMove", (e) => {
|
|
96
253
|
if (!this.drawing)
|
|
97
254
|
return;
|
|
98
255
|
e.preventDefault();
|
|
99
256
|
const t = e.touches[0];
|
|
100
257
|
this.drawLine(t.clientX, t.clientY);
|
|
101
258
|
});
|
|
102
|
-
__publicField$
|
|
259
|
+
__publicField$2(this, "onTouchEnd", () => {
|
|
103
260
|
this.drawing = false;
|
|
104
261
|
});
|
|
105
262
|
this.canvas = document.createElement("canvas");
|
|
@@ -109,7 +266,7 @@ class Canvas {
|
|
|
109
266
|
container.appendChild(this.canvas);
|
|
110
267
|
const ctx = this.canvas.getContext("2d");
|
|
111
268
|
if (!ctx) {
|
|
112
|
-
throw new Error("Canvas
|
|
269
|
+
throw new Error("Canvas \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F");
|
|
113
270
|
}
|
|
114
271
|
this.ctx = ctx;
|
|
115
272
|
this.ctx.lineWidth = this.opts.lineWidth ?? 5;
|
|
@@ -119,19 +276,21 @@ class Canvas {
|
|
|
119
276
|
this.initEvents();
|
|
120
277
|
}
|
|
121
278
|
/**
|
|
122
|
-
*
|
|
279
|
+
* Очищает холст.
|
|
123
280
|
*/
|
|
124
281
|
clearCanvas() {
|
|
125
282
|
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
126
283
|
}
|
|
127
284
|
/**
|
|
128
|
-
*
|
|
285
|
+
* Возвращает содержимое холста (подпись) в формате base64 (PNG).
|
|
286
|
+
*
|
|
287
|
+
* @returns Подпись в формате base64.
|
|
129
288
|
*/
|
|
130
289
|
getSignature() {
|
|
131
290
|
return this.canvas.toDataURL("image/png");
|
|
132
291
|
}
|
|
133
292
|
/**
|
|
134
|
-
*
|
|
293
|
+
* Снимает все обработчики событий и очищает ресурсы.
|
|
135
294
|
*/
|
|
136
295
|
destroy() {
|
|
137
296
|
this.canvas.removeEventListener("mousedown", this.onMouseDown);
|
|
@@ -142,6 +301,9 @@ class Canvas {
|
|
|
142
301
|
this.canvas.removeEventListener("touchend", this.onTouchEnd);
|
|
143
302
|
}
|
|
144
303
|
// Внутренние методы
|
|
304
|
+
/**
|
|
305
|
+
* Навешивает обработчики событий мыши и тач-устройств.
|
|
306
|
+
*/
|
|
145
307
|
initEvents() {
|
|
146
308
|
this.canvas.addEventListener("mousedown", this.onMouseDown);
|
|
147
309
|
this.canvas.addEventListener("mousemove", this.onMouseMove);
|
|
@@ -163,101 +325,70 @@ class Canvas {
|
|
|
163
325
|
}
|
|
164
326
|
}
|
|
165
327
|
|
|
166
|
-
var __defProp = Object.defineProperty;
|
|
167
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
168
|
-
var __publicField = (obj, key, value) => {
|
|
169
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
328
|
+
var __defProp$1 = Object.defineProperty;
|
|
329
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
330
|
+
var __publicField$1 = (obj, key, value) => {
|
|
331
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
170
332
|
return value;
|
|
171
333
|
};
|
|
172
|
-
class
|
|
173
|
-
constructor(config) {
|
|
174
|
-
this.config = config;
|
|
175
|
-
__publicField(this, "apiClient");
|
|
176
|
-
__publicField(this, "contractKit");
|
|
177
|
-
__publicField(this, "session");
|
|
178
|
-
this.apiClient = new antelope.APIClient({ url: config.chain_url });
|
|
179
|
-
this.contractKit = new contract.ContractKit({ client: this.apiClient });
|
|
180
|
-
}
|
|
181
|
-
async getInfo() {
|
|
182
|
-
return this.apiClient.v1.chain.get_info();
|
|
183
|
-
}
|
|
334
|
+
class Document {
|
|
184
335
|
/**
|
|
185
|
-
*
|
|
186
|
-
* @param
|
|
187
|
-
* @param wif - приватный ключ
|
|
188
|
-
* @returns
|
|
336
|
+
* Инициализация класса Document с WIF-ключом.
|
|
337
|
+
* @param wifKey WIF-ключ, используемый для подписи.
|
|
189
338
|
*/
|
|
190
|
-
|
|
191
|
-
this
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
chain: {
|
|
195
|
-
id: this.config.chain_id,
|
|
196
|
-
url: this.config.chain_url
|
|
197
|
-
},
|
|
198
|
-
walletPlugin: new walletPluginPrivatekey.WalletPluginPrivateKey(antelope.PrivateKey.fromString(wif))
|
|
199
|
-
});
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
async transact(actionOrActions, broadcast = true) {
|
|
203
|
-
if (!this.session)
|
|
204
|
-
throw new Error("Session is not initialized.");
|
|
205
|
-
const actions = Array.isArray(actionOrActions) ? await Promise.all(actionOrActions.map((action) => this.formActionFromAbi(action))) : [await this.formActionFromAbi(actionOrActions)];
|
|
206
|
-
return this.session.transact({ actions }, { broadcast });
|
|
207
|
-
}
|
|
208
|
-
async getAllRows(code, scope, tableName) {
|
|
209
|
-
const abi = await this.getAbi(code);
|
|
210
|
-
const table = this.createTable(code, tableName, abi);
|
|
211
|
-
const rows = await table.all({ scope });
|
|
212
|
-
return JSON.parse(JSON.stringify(rows));
|
|
339
|
+
constructor(wifKey) {
|
|
340
|
+
__publicField$1(this, "wif");
|
|
341
|
+
if (wifKey)
|
|
342
|
+
this.wif = antelope.PrivateKey.fromString(wifKey);
|
|
213
343
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
index_position: indexPosition,
|
|
221
|
-
from,
|
|
222
|
-
to,
|
|
223
|
-
maxRows
|
|
224
|
-
});
|
|
225
|
-
return JSON.parse(JSON.stringify(rows));
|
|
226
|
-
}
|
|
227
|
-
async getRow(code, scope, tableName, primaryKey, indexPosition = "primary") {
|
|
228
|
-
const abi = await this.getAbi(code);
|
|
229
|
-
const table = this.createTable(code, tableName, abi);
|
|
230
|
-
const row = await table.get(String(primaryKey), {
|
|
231
|
-
scope,
|
|
232
|
-
index_position: indexPosition
|
|
233
|
-
});
|
|
234
|
-
return row ? JSON.parse(JSON.stringify(row)) : null;
|
|
235
|
-
}
|
|
236
|
-
async formActionFromAbi(action) {
|
|
237
|
-
const abi = await this.getAbi(action.account);
|
|
238
|
-
return antelope.Action.from(action, abi);
|
|
344
|
+
/**
|
|
345
|
+
* Замена текущего WIF-ключа на новый.
|
|
346
|
+
* @param wifKey Новый WIF-ключ.
|
|
347
|
+
*/
|
|
348
|
+
setWif(wifKey) {
|
|
349
|
+
this.wif = antelope.PrivateKey.fromString(wifKey);
|
|
239
350
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
351
|
+
/**
|
|
352
|
+
* Подписывает документ и возвращает его в формате ISignedDocument.
|
|
353
|
+
* @param document Сгенерированный документ для подписи.
|
|
354
|
+
* @returns Подписанный документ.
|
|
355
|
+
*/
|
|
356
|
+
async signDocument(document) {
|
|
357
|
+
const digitalSignature = this.signDigest(document.hash);
|
|
358
|
+
return {
|
|
359
|
+
hash: document.hash,
|
|
360
|
+
public_key: digitalSignature.public_key,
|
|
361
|
+
signature: digitalSignature.signature,
|
|
362
|
+
meta: document.meta
|
|
363
|
+
};
|
|
245
364
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Подписывает хэш (digest) документа и проверяет подпись.
|
|
367
|
+
* @param digest Хэш документа для подписи.
|
|
368
|
+
* @returns Детали подписи.
|
|
369
|
+
*/
|
|
370
|
+
signDigest(digest) {
|
|
371
|
+
if (!this.wif)
|
|
372
|
+
throw new Error(`\u041A\u043B\u044E\u0447 \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D, \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u0432\u044B\u0437\u043E\u0432 \u043C\u0435\u0442\u043E\u0434\u0430 setWif \u043F\u0435\u0440\u0435\u0434 \u043F\u043E\u0434\u043F\u0438\u0441\u044C\u044E \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430`);
|
|
373
|
+
const signed = this.wif.signDigest(digest);
|
|
374
|
+
const verified = signed.verifyDigest(digest, this.wif.toPublic());
|
|
375
|
+
if (!verified) {
|
|
376
|
+
throw new Error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438 \u043F\u043E\u0434\u043F\u0438\u0441\u0438");
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
message: digest,
|
|
380
|
+
signature: signed.toString(),
|
|
381
|
+
public_key: this.wif.toPublic().toString()
|
|
382
|
+
};
|
|
253
383
|
}
|
|
254
384
|
}
|
|
255
385
|
|
|
256
386
|
const Classes = {
|
|
257
387
|
__proto__: null,
|
|
258
388
|
Account: Account,
|
|
389
|
+
Blockchain: Blockchain,
|
|
259
390
|
Canvas: Canvas,
|
|
260
|
-
|
|
391
|
+
Document: Document
|
|
261
392
|
};
|
|
262
393
|
|
|
263
394
|
const AllTypesProps = {
|
|
@@ -333,7 +464,6 @@ const AllTypesProps = {
|
|
|
333
464
|
soviet: "SovietMemberInput"
|
|
334
465
|
},
|
|
335
466
|
JSON: `scalar.JSON`,
|
|
336
|
-
LangType: "enum",
|
|
337
467
|
LoginInput: {},
|
|
338
468
|
LogoutInput: {},
|
|
339
469
|
MetaDocumentInput: {},
|
|
@@ -891,7 +1021,7 @@ const ReturnTypes = {
|
|
|
891
1021
|
created_at: "String",
|
|
892
1022
|
decision_id: "Float",
|
|
893
1023
|
generator: "String",
|
|
894
|
-
lang: "
|
|
1024
|
+
lang: "String",
|
|
895
1025
|
links: "String",
|
|
896
1026
|
project_id: "String",
|
|
897
1027
|
registry_id: "Int",
|
|
@@ -928,7 +1058,7 @@ const ReturnTypes = {
|
|
|
928
1058
|
coopname: "String",
|
|
929
1059
|
created_at: "String",
|
|
930
1060
|
generator: "String",
|
|
931
|
-
lang: "
|
|
1061
|
+
lang: "String",
|
|
932
1062
|
links: "String",
|
|
933
1063
|
registry_id: "Int",
|
|
934
1064
|
timezone: "String",
|
|
@@ -1036,7 +1166,7 @@ const ReturnTypes = {
|
|
|
1036
1166
|
created_at: "String",
|
|
1037
1167
|
decision_id: "Float",
|
|
1038
1168
|
generator: "String",
|
|
1039
|
-
lang: "
|
|
1169
|
+
lang: "String",
|
|
1040
1170
|
links: "String",
|
|
1041
1171
|
registry_id: "Int",
|
|
1042
1172
|
timezone: "String",
|
|
@@ -1056,7 +1186,7 @@ const ReturnTypes = {
|
|
|
1056
1186
|
coopname: "String",
|
|
1057
1187
|
created_at: "String",
|
|
1058
1188
|
generator: "String",
|
|
1059
|
-
lang: "
|
|
1189
|
+
lang: "String",
|
|
1060
1190
|
links: "String",
|
|
1061
1191
|
registry_id: "Int",
|
|
1062
1192
|
timezone: "String",
|
|
@@ -1144,7 +1274,7 @@ const ReturnTypes = {
|
|
|
1144
1274
|
coopname: "String",
|
|
1145
1275
|
created_at: "String",
|
|
1146
1276
|
generator: "String",
|
|
1147
|
-
lang: "
|
|
1277
|
+
lang: "String",
|
|
1148
1278
|
links: "String",
|
|
1149
1279
|
project_id: "String",
|
|
1150
1280
|
registry_id: "Int",
|
|
@@ -1214,7 +1344,7 @@ const ReturnTypes = {
|
|
|
1214
1344
|
coopname: "String",
|
|
1215
1345
|
created_at: "String",
|
|
1216
1346
|
generator: "String",
|
|
1217
|
-
lang: "
|
|
1347
|
+
lang: "String",
|
|
1218
1348
|
links: "String",
|
|
1219
1349
|
registry_id: "Int",
|
|
1220
1350
|
timezone: "String",
|
|
@@ -1829,10 +1959,6 @@ var Country = /* @__PURE__ */ ((Country2) => {
|
|
|
1829
1959
|
Country2["Russia"] = "Russia";
|
|
1830
1960
|
return Country2;
|
|
1831
1961
|
})(Country || {});
|
|
1832
|
-
var LangType = /* @__PURE__ */ ((LangType2) => {
|
|
1833
|
-
LangType2["ru"] = "ru";
|
|
1834
|
-
return LangType2;
|
|
1835
|
-
})(LangType || {});
|
|
1836
1962
|
var OrganizationType = /* @__PURE__ */ ((OrganizationType2) => {
|
|
1837
1963
|
OrganizationType2["AO"] = "AO";
|
|
1838
1964
|
OrganizationType2["COOP"] = "COOP";
|
|
@@ -1873,7 +1999,7 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
|
1873
1999
|
return UserStatus2;
|
|
1874
2000
|
})(UserStatus || {});
|
|
1875
2001
|
|
|
1876
|
-
const index$
|
|
2002
|
+
const index$o = {
|
|
1877
2003
|
__proto__: null,
|
|
1878
2004
|
$: $,
|
|
1879
2005
|
AccountType: AccountType,
|
|
@@ -1886,7 +2012,6 @@ const index$k = {
|
|
|
1886
2012
|
HOST: HOST,
|
|
1887
2013
|
InternalArgsBuilt: InternalArgsBuilt,
|
|
1888
2014
|
InternalsBuildQuery: InternalsBuildQuery,
|
|
1889
|
-
LangType: LangType,
|
|
1890
2015
|
OrganizationType: OrganizationType,
|
|
1891
2016
|
PaymentStatus: PaymentStatus,
|
|
1892
2017
|
PrepareScalarPaths: PrepareScalarPaths,
|
|
@@ -1964,7 +2089,7 @@ const updateExtension = {
|
|
|
1964
2089
|
name: name$K
|
|
1965
2090
|
};
|
|
1966
2091
|
|
|
1967
|
-
const index$
|
|
2092
|
+
const index$n = {
|
|
1968
2093
|
__proto__: null,
|
|
1969
2094
|
InstallExtension: installExtension,
|
|
1970
2095
|
UninstallExtension: uninstallExtension,
|
|
@@ -2034,7 +2159,7 @@ const updateBankAccount = {
|
|
|
2034
2159
|
name: name$H
|
|
2035
2160
|
};
|
|
2036
2161
|
|
|
2037
|
-
const index$
|
|
2162
|
+
const index$m = {
|
|
2038
2163
|
__proto__: null,
|
|
2039
2164
|
CreateBankAccount: createBankAccount,
|
|
2040
2165
|
DeletePaymentMethod: deletePaymentMethod,
|
|
@@ -2600,7 +2725,7 @@ const selectBranch = {
|
|
|
2600
2725
|
|
|
2601
2726
|
const name$A = "generateSelectBranchDocument";
|
|
2602
2727
|
const mutation$q = Selector("Mutation")({
|
|
2603
|
-
[name$A]: [{ data: $("data", "SelectBranchGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2728
|
+
[name$A]: [{ data: $("data", "SelectBranchGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, generateSelectBranchDocumentSelector]
|
|
2604
2729
|
});
|
|
2605
2730
|
|
|
2606
2731
|
const generateSelectBranchDocument = {
|
|
@@ -2609,7 +2734,7 @@ const generateSelectBranchDocument = {
|
|
|
2609
2734
|
name: name$A
|
|
2610
2735
|
};
|
|
2611
2736
|
|
|
2612
|
-
const index$
|
|
2737
|
+
const index$l = {
|
|
2613
2738
|
__proto__: null,
|
|
2614
2739
|
AddTrustedAccount: addTrustedAccount,
|
|
2615
2740
|
CreateBranch: createBranch,
|
|
@@ -2632,7 +2757,7 @@ const projectFreeDecisionDocumentSelector = Selector("ProjectFreeDecisionDocumen
|
|
|
2632
2757
|
|
|
2633
2758
|
const name$z = "generateProjectOfFreeDecision";
|
|
2634
2759
|
const mutation$p = Selector("Mutation")({
|
|
2635
|
-
[name$z]: [{ data: $("data", "ProjectFreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2760
|
+
[name$z]: [{ data: $("data", "ProjectFreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, projectFreeDecisionDocumentSelector]
|
|
2636
2761
|
});
|
|
2637
2762
|
|
|
2638
2763
|
const generateProjectOfFreeDecisionDocument = {
|
|
@@ -2662,7 +2787,7 @@ const createdProjectFreeDecisionSelector = Selector("CreatedProjectFreeDecision"
|
|
|
2662
2787
|
|
|
2663
2788
|
const name$y = "generateFreeDecision";
|
|
2664
2789
|
const mutation$o = Selector("Mutation")({
|
|
2665
|
-
[name$y]: [{ data: $("data", "FreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2790
|
+
[name$y]: [{ data: $("data", "FreeDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, freeDecisionDocumentSelector]
|
|
2666
2791
|
});
|
|
2667
2792
|
|
|
2668
2793
|
const generateFreeDecision = {
|
|
@@ -2693,7 +2818,7 @@ const createProjectOfFreeDecision = {
|
|
|
2693
2818
|
name: name$w
|
|
2694
2819
|
};
|
|
2695
2820
|
|
|
2696
|
-
const index$
|
|
2821
|
+
const index$k = {
|
|
2697
2822
|
__proto__: null,
|
|
2698
2823
|
CreateProjectOfFreeDecision: createProjectOfFreeDecision,
|
|
2699
2824
|
GenerateFreeDecision: generateFreeDecision,
|
|
@@ -2761,7 +2886,7 @@ const resetKey = {
|
|
|
2761
2886
|
name: name$s
|
|
2762
2887
|
};
|
|
2763
2888
|
|
|
2764
|
-
const index$
|
|
2889
|
+
const index$j = {
|
|
2765
2890
|
__proto__: null,
|
|
2766
2891
|
RegisterAccount: registerAccount,
|
|
2767
2892
|
ResetKey: resetKey,
|
|
@@ -2802,7 +2927,7 @@ const login = {
|
|
|
2802
2927
|
name: name$p
|
|
2803
2928
|
};
|
|
2804
2929
|
|
|
2805
|
-
const index$
|
|
2930
|
+
const index$i = {
|
|
2806
2931
|
__proto__: null,
|
|
2807
2932
|
Login: login,
|
|
2808
2933
|
Logout: logout,
|
|
@@ -2853,7 +2978,7 @@ const updateSystem = {
|
|
|
2853
2978
|
name: name$l
|
|
2854
2979
|
};
|
|
2855
2980
|
|
|
2856
|
-
const index$
|
|
2981
|
+
const index$h = {
|
|
2857
2982
|
__proto__: null,
|
|
2858
2983
|
InitSystem: initSystem,
|
|
2859
2984
|
InstallSystem: installSystem,
|
|
@@ -2863,7 +2988,7 @@ const index$d = {
|
|
|
2863
2988
|
|
|
2864
2989
|
const name$k = "generateParticipantApplication";
|
|
2865
2990
|
const mutation$a = Selector("Mutation")({
|
|
2866
|
-
[name$k]: [{ data: $("data", "ParticipantApplicationGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
2991
|
+
[name$k]: [{ data: $("data", "ParticipantApplicationGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, participantApplicationDocumentSelector]
|
|
2867
2992
|
});
|
|
2868
2993
|
|
|
2869
2994
|
const generateParticipantApplication = {
|
|
@@ -2874,7 +2999,7 @@ const generateParticipantApplication = {
|
|
|
2874
2999
|
|
|
2875
3000
|
const name$j = "generateParticipantApplicationDecision";
|
|
2876
3001
|
const mutation$9 = Selector("Mutation")({
|
|
2877
|
-
[name$j]: [{ data: $("data", "ParticipantApplicationDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3002
|
+
[name$j]: [{ data: $("data", "ParticipantApplicationDecisionGenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, participantApplicationDecisionDocumentSelector]
|
|
2878
3003
|
});
|
|
2879
3004
|
|
|
2880
3005
|
const generateParticipantApplicationDecision = {
|
|
@@ -2905,7 +3030,7 @@ const addParticipant = {
|
|
|
2905
3030
|
name: name$h
|
|
2906
3031
|
};
|
|
2907
3032
|
|
|
2908
|
-
const index$
|
|
3033
|
+
const index$g = {
|
|
2909
3034
|
__proto__: null,
|
|
2910
3035
|
AddParticipant: addParticipant,
|
|
2911
3036
|
GenerateParticipantApplication: generateParticipantApplication,
|
|
@@ -2971,7 +3096,7 @@ const setPaymentStatus = {
|
|
|
2971
3096
|
name: name$e
|
|
2972
3097
|
};
|
|
2973
3098
|
|
|
2974
|
-
const index$
|
|
3099
|
+
const index$f = {
|
|
2975
3100
|
__proto__: null,
|
|
2976
3101
|
CreateDepositPayment: createDeposit,
|
|
2977
3102
|
CreateInitialPayment: createInitial,
|
|
@@ -2980,7 +3105,7 @@ const index$b = {
|
|
|
2980
3105
|
|
|
2981
3106
|
const name$d = "generatePrivacyAgreement";
|
|
2982
3107
|
const mutation$3 = Selector("Mutation")({
|
|
2983
|
-
[name$d]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3108
|
+
[name$d]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
2984
3109
|
});
|
|
2985
3110
|
|
|
2986
3111
|
const generatePrivacyAgreement = {
|
|
@@ -2991,7 +3116,7 @@ const generatePrivacyAgreement = {
|
|
|
2991
3116
|
|
|
2992
3117
|
const name$c = "generateSignatureAgreement";
|
|
2993
3118
|
const mutation$2 = Selector("Mutation")({
|
|
2994
|
-
[name$c]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3119
|
+
[name$c]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
2995
3120
|
});
|
|
2996
3121
|
|
|
2997
3122
|
const generateSignatureAgreement = {
|
|
@@ -3002,7 +3127,7 @@ const generateSignatureAgreement = {
|
|
|
3002
3127
|
|
|
3003
3128
|
const name$b = "generateWalletAgreement";
|
|
3004
3129
|
const mutation$1 = Selector("Mutation")({
|
|
3005
|
-
[name$b]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3130
|
+
[name$b]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
3006
3131
|
});
|
|
3007
3132
|
|
|
3008
3133
|
const generateWalletAgreement = {
|
|
@@ -3013,7 +3138,7 @@ const generateWalletAgreement = {
|
|
|
3013
3138
|
|
|
3014
3139
|
const name$a = "generateUserAgreement";
|
|
3015
3140
|
const mutation = Selector("Mutation")({
|
|
3016
|
-
[name$a]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput
|
|
3141
|
+
[name$a]: [{ data: $("data", "GenerateDocumentInput!"), options: $("options", "GenerateDocumentOptionsInput") }, documentSelector]
|
|
3017
3142
|
});
|
|
3018
3143
|
|
|
3019
3144
|
const generateUserAgreement = {
|
|
@@ -3022,7 +3147,7 @@ const generateUserAgreement = {
|
|
|
3022
3147
|
name: name$a
|
|
3023
3148
|
};
|
|
3024
3149
|
|
|
3025
|
-
const index$
|
|
3150
|
+
const index$e = {
|
|
3026
3151
|
__proto__: null,
|
|
3027
3152
|
GeneratePrivacyAgreement: generatePrivacyAgreement,
|
|
3028
3153
|
GenerateSignatureAgreement: generateSignatureAgreement,
|
|
@@ -3032,16 +3157,16 @@ const index$a = {
|
|
|
3032
3157
|
|
|
3033
3158
|
const Mutations = {
|
|
3034
3159
|
__proto__: null,
|
|
3035
|
-
Accounts: index$
|
|
3036
|
-
Agreements: index$
|
|
3037
|
-
Auth: index$
|
|
3038
|
-
Branches: index$
|
|
3039
|
-
Extensions: index$
|
|
3040
|
-
FreeDecisions: index$
|
|
3041
|
-
Participants: index$
|
|
3042
|
-
PaymentMethods: index$
|
|
3043
|
-
Payments: index$
|
|
3044
|
-
System: index$
|
|
3160
|
+
Accounts: index$j,
|
|
3161
|
+
Agreements: index$e,
|
|
3162
|
+
Auth: index$i,
|
|
3163
|
+
Branches: index$l,
|
|
3164
|
+
Extensions: index$n,
|
|
3165
|
+
FreeDecisions: index$k,
|
|
3166
|
+
Participants: index$g,
|
|
3167
|
+
PaymentMethods: index$m,
|
|
3168
|
+
Payments: index$f,
|
|
3169
|
+
System: index$h
|
|
3045
3170
|
};
|
|
3046
3171
|
|
|
3047
3172
|
const name$9 = "getExtensions";
|
|
@@ -3055,7 +3180,7 @@ const getExtensions = {
|
|
|
3055
3180
|
query: query$9
|
|
3056
3181
|
};
|
|
3057
3182
|
|
|
3058
|
-
const index$
|
|
3183
|
+
const index$d = {
|
|
3059
3184
|
__proto__: null,
|
|
3060
3185
|
GetExtensions: getExtensions
|
|
3061
3186
|
};
|
|
@@ -3080,7 +3205,7 @@ const getPaymentMethods = {
|
|
|
3080
3205
|
query: query$8
|
|
3081
3206
|
};
|
|
3082
3207
|
|
|
3083
|
-
const index$
|
|
3208
|
+
const index$c = {
|
|
3084
3209
|
__proto__: null,
|
|
3085
3210
|
GetPaymentMethods: getPaymentMethods
|
|
3086
3211
|
};
|
|
@@ -3096,7 +3221,7 @@ const getSystemInfo = {
|
|
|
3096
3221
|
query: query$7
|
|
3097
3222
|
};
|
|
3098
3223
|
|
|
3099
|
-
const index$
|
|
3224
|
+
const index$b = {
|
|
3100
3225
|
__proto__: null,
|
|
3101
3226
|
GetSystemInfo: getSystemInfo
|
|
3102
3227
|
};
|
|
@@ -3126,7 +3251,7 @@ const getAccounts = {
|
|
|
3126
3251
|
query: query$5
|
|
3127
3252
|
};
|
|
3128
3253
|
|
|
3129
|
-
const index$
|
|
3254
|
+
const index$a = {
|
|
3130
3255
|
__proto__: null,
|
|
3131
3256
|
GetAccount: getAccount,
|
|
3132
3257
|
GetAccounts: getAccounts
|
|
@@ -3154,7 +3279,7 @@ const getPublicBranches = {
|
|
|
3154
3279
|
query: query$3
|
|
3155
3280
|
};
|
|
3156
3281
|
|
|
3157
|
-
const index$
|
|
3282
|
+
const index$9 = {
|
|
3158
3283
|
__proto__: null,
|
|
3159
3284
|
GetBranches: getBranches,
|
|
3160
3285
|
GetPublicBranches: getPublicBranches
|
|
@@ -3171,7 +3296,7 @@ const getPayments = {
|
|
|
3171
3296
|
query: query$2
|
|
3172
3297
|
};
|
|
3173
3298
|
|
|
3174
|
-
const index$
|
|
3299
|
+
const index$8 = {
|
|
3175
3300
|
__proto__: null,
|
|
3176
3301
|
GetPayments: getPayments
|
|
3177
3302
|
};
|
|
@@ -3235,7 +3360,7 @@ const getDocuments = {
|
|
|
3235
3360
|
query: query$1
|
|
3236
3361
|
};
|
|
3237
3362
|
|
|
3238
|
-
const index$
|
|
3363
|
+
const index$7 = {
|
|
3239
3364
|
__proto__: null,
|
|
3240
3365
|
GetDocuments: getDocuments
|
|
3241
3366
|
};
|
|
@@ -3286,75 +3411,101 @@ const getAgenda = {
|
|
|
3286
3411
|
query: query
|
|
3287
3412
|
};
|
|
3288
3413
|
|
|
3289
|
-
const index$
|
|
3414
|
+
const index$6 = {
|
|
3290
3415
|
__proto__: null,
|
|
3291
3416
|
GetAgenda: getAgenda
|
|
3292
3417
|
};
|
|
3293
3418
|
|
|
3294
|
-
const index$
|
|
3419
|
+
const index$5 = {
|
|
3295
3420
|
__proto__: null,
|
|
3296
|
-
Accounts: index$
|
|
3297
|
-
Agenda: index$
|
|
3298
|
-
Branches: index$
|
|
3299
|
-
Documents: index$
|
|
3300
|
-
Extensions: index$
|
|
3301
|
-
PaymentMethods: index$
|
|
3302
|
-
Payments: index$
|
|
3303
|
-
System: index$
|
|
3421
|
+
Accounts: index$a,
|
|
3422
|
+
Agenda: index$6,
|
|
3423
|
+
Branches: index$9,
|
|
3424
|
+
Documents: index$7,
|
|
3425
|
+
Extensions: index$d,
|
|
3426
|
+
PaymentMethods: index$c,
|
|
3427
|
+
Payments: index$8,
|
|
3428
|
+
System: index$b
|
|
3304
3429
|
};
|
|
3305
3430
|
|
|
3306
|
-
const index = {
|
|
3431
|
+
const index$4 = {
|
|
3307
3432
|
__proto__: null
|
|
3308
3433
|
};
|
|
3309
3434
|
|
|
3435
|
+
const index$3 = {
|
|
3436
|
+
__proto__: null
|
|
3437
|
+
};
|
|
3438
|
+
|
|
3439
|
+
const index$2 = {
|
|
3440
|
+
__proto__: null
|
|
3441
|
+
};
|
|
3442
|
+
|
|
3443
|
+
const index$1 = {
|
|
3444
|
+
__proto__: null
|
|
3445
|
+
};
|
|
3446
|
+
|
|
3447
|
+
const index = {
|
|
3448
|
+
__proto__: null,
|
|
3449
|
+
Blockchain: index$4,
|
|
3450
|
+
Client: index$3,
|
|
3451
|
+
Controller: index$2,
|
|
3452
|
+
Document: index$1
|
|
3453
|
+
};
|
|
3454
|
+
|
|
3455
|
+
var __defProp = Object.defineProperty;
|
|
3456
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3457
|
+
var __publicField = (obj, key, value) => {
|
|
3458
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3459
|
+
return value;
|
|
3460
|
+
};
|
|
3310
3461
|
if (typeof globalThis.WebSocket === "undefined") {
|
|
3311
3462
|
globalThis.WebSocket = WebSocket__default;
|
|
3312
3463
|
}
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3464
|
+
const _Client = class _Client {
|
|
3465
|
+
constructor(options) {
|
|
3466
|
+
this.options = options;
|
|
3467
|
+
__publicField(this, "currentHeaders", {});
|
|
3468
|
+
__publicField(this, "blockchain");
|
|
3469
|
+
__publicField(this, "document");
|
|
3470
|
+
__publicField(this, "thunder");
|
|
3471
|
+
this.currentHeaders = options.headers || {};
|
|
3472
|
+
this.thunder = _Client.createThunder(options.api_url);
|
|
3473
|
+
this.blockchain = new Blockchain(options);
|
|
3474
|
+
this.document = new Document(options.wif);
|
|
3475
|
+
if (options.wif && options.username) {
|
|
3476
|
+
this.blockchain.setWif(options.username, options.wif);
|
|
3477
|
+
this.document.setWif(options.wif);
|
|
3478
|
+
} else if (options.wif && !options.username || !options.wif && options.username) {
|
|
3479
|
+
throw new Error("wif \u0438 username \u0434\u043E\u043B\u0436\u043D\u044B \u0431\u044B\u0442\u044C \u0443\u043A\u0430\u0437\u0430\u043D\u044B \u043E\u0434\u043D\u043E\u0432\u0440\u0435\u043C\u0435\u043D\u043D\u043E");
|
|
3480
|
+
}
|
|
3320
3481
|
}
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
"Content-Type": "application/json",
|
|
3329
|
-
...currentHeaders
|
|
3330
|
-
// Используем текущие заголовки, включая Authorization
|
|
3331
|
-
}
|
|
3332
|
-
});
|
|
3333
|
-
if (!response.ok) {
|
|
3334
|
-
return new Promise((resolve, reject) => {
|
|
3335
|
-
response.text().then((text) => {
|
|
3336
|
-
try {
|
|
3337
|
-
reject(JSON.parse(text));
|
|
3338
|
-
} catch (err) {
|
|
3339
|
-
reject(text);
|
|
3340
|
-
}
|
|
3341
|
-
}).catch(reject);
|
|
3342
|
-
});
|
|
3482
|
+
/**
|
|
3483
|
+
* Инициализация клиента с заданными опциями.
|
|
3484
|
+
* @param options Параметры соединения.
|
|
3485
|
+
*/
|
|
3486
|
+
static create(options) {
|
|
3487
|
+
if (!this.instance) {
|
|
3488
|
+
this.instance = new _Client(options);
|
|
3343
3489
|
}
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3490
|
+
return this.getInstance();
|
|
3491
|
+
}
|
|
3492
|
+
/**
|
|
3493
|
+
* Возвращает текущий экземпляр клиента.
|
|
3494
|
+
*/
|
|
3495
|
+
static getInstance() {
|
|
3496
|
+
if (!this.instance) {
|
|
3497
|
+
throw new Error("\u041A\u043B\u0438\u0435\u043D\u0442 \u043D\u0435 \u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D. \u0412\u044B\u0437\u043E\u0432\u0438\u0442\u0435 Client.create() \u043F\u0435\u0440\u0435\u0434 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435\u043C.");
|
|
3348
3498
|
}
|
|
3349
|
-
return
|
|
3350
|
-
}
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3499
|
+
return this.instance;
|
|
3500
|
+
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Логин пользователя с использованием email и WIF.
|
|
3503
|
+
* @param email Email пользователя.
|
|
3504
|
+
* @param wif Приватный ключ в формате WIF.
|
|
3505
|
+
* @returns Результат логина.
|
|
3506
|
+
*/
|
|
3507
|
+
async login(email, wif) {
|
|
3508
|
+
const now = (await this.blockchain.getInfo()).head_block_time.toString();
|
|
3358
3509
|
const privateKey = session.PrivateKey.fromString(wif);
|
|
3359
3510
|
const bytes = session.Bytes.fromString(now, "utf8");
|
|
3360
3511
|
const checksum = session.Checksum256.hash(bytes);
|
|
@@ -3366,35 +3517,104 @@ function createClient(options) {
|
|
|
3366
3517
|
signature
|
|
3367
3518
|
}
|
|
3368
3519
|
};
|
|
3369
|
-
const { [name$p]: result } = await thunder("mutation")(
|
|
3520
|
+
const { [name$p]: result } = await this.thunder("mutation")(
|
|
3370
3521
|
mutation$f,
|
|
3371
3522
|
{
|
|
3372
3523
|
variables
|
|
3373
3524
|
}
|
|
3374
3525
|
);
|
|
3375
|
-
|
|
3526
|
+
const username = result.account.username;
|
|
3527
|
+
this.blockchain.setWif(username, wif);
|
|
3528
|
+
this.document.setWif(wif);
|
|
3529
|
+
this.currentHeaders.Authorization = `Bearer ${result.tokens.access.token}`;
|
|
3376
3530
|
return result;
|
|
3377
3531
|
}
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3532
|
+
/**
|
|
3533
|
+
* Установка токена авторизации.
|
|
3534
|
+
* @param token Токен для заголовков Authorization.
|
|
3535
|
+
*/
|
|
3536
|
+
setToken(token) {
|
|
3537
|
+
this.currentHeaders.Authorization = `Bearer ${token}`;
|
|
3382
3538
|
}
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3539
|
+
/**
|
|
3540
|
+
* Доступ к Blockchain.
|
|
3541
|
+
*/
|
|
3542
|
+
get Blockchain() {
|
|
3543
|
+
return this.blockchain;
|
|
3544
|
+
}
|
|
3545
|
+
/**
|
|
3546
|
+
* Доступ к Document.
|
|
3547
|
+
*/
|
|
3548
|
+
get Document() {
|
|
3549
|
+
return this.document;
|
|
3550
|
+
}
|
|
3551
|
+
/**
|
|
3552
|
+
* Доступ к GraphQL-запросам.
|
|
3553
|
+
*/
|
|
3554
|
+
get Query() {
|
|
3555
|
+
return this.thunder("query");
|
|
3556
|
+
}
|
|
3557
|
+
/**
|
|
3558
|
+
* Доступ к GraphQL-мутациям.
|
|
3559
|
+
*/
|
|
3560
|
+
get Mutation() {
|
|
3561
|
+
return this.thunder("mutation");
|
|
3562
|
+
}
|
|
3563
|
+
/**
|
|
3564
|
+
* Подписка на GraphQL-события.
|
|
3565
|
+
*/
|
|
3566
|
+
get Subscription() {
|
|
3567
|
+
return Subscription(this.options.api_url.replace(/^http/, "ws"));
|
|
3568
|
+
}
|
|
3569
|
+
/**
|
|
3570
|
+
* Создает функцию Thunder для выполнения GraphQL-запросов.
|
|
3571
|
+
* @param baseUrl URL GraphQL API.
|
|
3572
|
+
* @returns Функция Thunder.
|
|
3573
|
+
*/
|
|
3574
|
+
static createThunder(baseUrl) {
|
|
3575
|
+
return Thunder(async (query, variables) => {
|
|
3576
|
+
const response = await fetch(baseUrl, {
|
|
3577
|
+
body: JSON.stringify({ query, variables }),
|
|
3578
|
+
method: "POST",
|
|
3579
|
+
headers: {
|
|
3580
|
+
"Content-Type": "application/json",
|
|
3581
|
+
..._Client.getInstance().currentHeaders
|
|
3582
|
+
}
|
|
3583
|
+
});
|
|
3584
|
+
if (!response.ok) {
|
|
3585
|
+
return new Promise((resolve, reject) => {
|
|
3586
|
+
response.text().then((text) => {
|
|
3587
|
+
try {
|
|
3588
|
+
reject(JSON.parse(text));
|
|
3589
|
+
} catch {
|
|
3590
|
+
reject(text);
|
|
3591
|
+
}
|
|
3592
|
+
}).catch(reject);
|
|
3593
|
+
});
|
|
3594
|
+
}
|
|
3595
|
+
const json = await response.json();
|
|
3596
|
+
if (json.errors) {
|
|
3597
|
+
console.log("json.errors", json.errors);
|
|
3598
|
+
throw json.errors;
|
|
3599
|
+
}
|
|
3600
|
+
return json.data;
|
|
3601
|
+
}, { scalars: _Client.scalars });
|
|
3602
|
+
}
|
|
3603
|
+
};
|
|
3604
|
+
__publicField(_Client, "instance", null);
|
|
3605
|
+
__publicField(_Client, "scalars", ZeusScalars({
|
|
3606
|
+
DateTime: {
|
|
3607
|
+
decode: (e) => new Date(e),
|
|
3608
|
+
// Преобразует строку в объект Date
|
|
3609
|
+
encode: (e) => e.toISOString()
|
|
3610
|
+
// Преобразует Date в ISO-строку
|
|
3611
|
+
}
|
|
3612
|
+
}));
|
|
3613
|
+
let Client = _Client;
|
|
3394
3614
|
|
|
3395
3615
|
exports.Classes = Classes;
|
|
3616
|
+
exports.Client = Client;
|
|
3396
3617
|
exports.Mutations = Mutations;
|
|
3397
|
-
exports.Queries = index$
|
|
3618
|
+
exports.Queries = index$5;
|
|
3398
3619
|
exports.Types = index;
|
|
3399
|
-
exports.Zeus = index$
|
|
3400
|
-
exports.createClient = createClient;
|
|
3620
|
+
exports.Zeus = index$o;
|