@coopenomics/sdk 2025.5.5 → 2025.5.13

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 CHANGED
@@ -5,23 +5,37 @@ const WebSocket = require('isomorphic-ws');
5
5
  const antelope = require('@wharfkit/antelope');
6
6
  const contract = require('@wharfkit/contract');
7
7
  const walletPluginPrivatekey = require('@wharfkit/wallet-plugin-privatekey');
8
+ const nodeCrypto = require('node:crypto');
8
9
  const graphqlWs = require('graphql-ws');
9
10
 
10
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
12
 
13
+ function _interopNamespaceCompat(e) {
14
+ if (e && typeof e === 'object' && 'default' in e) return e;
15
+ const n = Object.create(null);
16
+ if (e) {
17
+ for (const k in e) {
18
+ n[k] = e[k];
19
+ }
20
+ }
21
+ n.default = e;
22
+ return n;
23
+ }
24
+
12
25
  const WebSocket__default = /*#__PURE__*/_interopDefaultCompat(WebSocket);
26
+ const nodeCrypto__namespace = /*#__PURE__*/_interopNamespaceCompat(nodeCrypto);
13
27
 
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);
28
+ var __defProp$5 = Object.defineProperty;
29
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
30
+ var __publicField$5 = (obj, key, value) => {
31
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
18
32
  return value;
19
33
  };
20
34
  class Account {
21
35
  constructor() {
22
- __publicField$4(this, "username");
23
- __publicField$4(this, "private_key");
24
- __publicField$4(this, "public_key");
36
+ __publicField$5(this, "username");
37
+ __publicField$5(this, "private_key");
38
+ __publicField$5(this, "public_key");
25
39
  this.username = Account.generateUsername();
26
40
  const keys = Account.generateKeys();
27
41
  this.private_key = keys.private_key;
@@ -54,10 +68,10 @@ class Account {
54
68
  }
55
69
  }
56
70
 
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);
71
+ var __defProp$4 = Object.defineProperty;
72
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
73
+ var __publicField$4 = (obj, key, value) => {
74
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
61
75
  return value;
62
76
  };
63
77
  class Blockchain {
@@ -67,9 +81,9 @@ class Blockchain {
67
81
  */
68
82
  constructor(config) {
69
83
  this.config = config;
70
- __publicField$3(this, "apiClient");
71
- __publicField$3(this, "contractKit");
72
- __publicField$3(this, "session");
84
+ __publicField$4(this, "apiClient");
85
+ __publicField$4(this, "contractKit");
86
+ __publicField$4(this, "session");
73
87
  this.apiClient = new antelope.APIClient({ url: config.chain_url });
74
88
  this.contractKit = new contract.ContractKit({ client: this.apiClient });
75
89
  }
@@ -202,10 +216,10 @@ class Blockchain {
202
216
  }
203
217
  }
204
218
 
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);
219
+ var __defProp$3 = Object.defineProperty;
220
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
221
+ var __publicField$3 = (obj, key, value) => {
222
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
209
223
  return value;
210
224
  };
211
225
  class Canvas {
@@ -220,28 +234,28 @@ class Canvas {
220
234
  constructor(container, opts = {}) {
221
235
  this.container = container;
222
236
  this.opts = opts;
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) => {
237
+ __publicField$3(this, "canvas");
238
+ __publicField$3(this, "ctx");
239
+ __publicField$3(this, "drawing", false);
240
+ __publicField$3(this, "lastX", 0);
241
+ __publicField$3(this, "lastY", 0);
242
+ __publicField$3(this, "onMouseDown", (e) => {
229
243
  e.preventDefault();
230
244
  this.drawing = true;
231
245
  const rect = this.canvas.getBoundingClientRect();
232
246
  this.lastX = e.clientX - rect.left;
233
247
  this.lastY = e.clientY - rect.top;
234
248
  });
235
- __publicField$2(this, "onMouseMove", (e) => {
249
+ __publicField$3(this, "onMouseMove", (e) => {
236
250
  if (!this.drawing)
237
251
  return;
238
252
  e.preventDefault();
239
253
  this.drawLine(e.clientX, e.clientY);
240
254
  });
241
- __publicField$2(this, "onMouseUp", () => {
255
+ __publicField$3(this, "onMouseUp", () => {
242
256
  this.drawing = false;
243
257
  });
244
- __publicField$2(this, "onTouchStart", (e) => {
258
+ __publicField$3(this, "onTouchStart", (e) => {
245
259
  e.preventDefault();
246
260
  this.drawing = true;
247
261
  const rect = this.canvas.getBoundingClientRect();
@@ -249,14 +263,14 @@ class Canvas {
249
263
  this.lastX = t.clientX - rect.left;
250
264
  this.lastY = t.clientY - rect.top;
251
265
  });
252
- __publicField$2(this, "onTouchMove", (e) => {
266
+ __publicField$3(this, "onTouchMove", (e) => {
253
267
  if (!this.drawing)
254
268
  return;
255
269
  e.preventDefault();
256
270
  const t = e.touches[0];
257
271
  this.drawLine(t.clientX, t.clientY);
258
272
  });
259
- __publicField$2(this, "onTouchEnd", () => {
273
+ __publicField$3(this, "onTouchEnd", () => {
260
274
  this.drawing = false;
261
275
  });
262
276
  this.canvas = document.createElement("canvas");
@@ -325,10 +339,35 @@ class Canvas {
325
339
  }
326
340
  }
327
341
 
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);
342
+ class Crypto {
343
+ /**
344
+ * Получить sha256-хэш от строки или числа (hex-строка).
345
+ * Работает как в Node.js, так и в браузере (если доступен Web Crypto API).
346
+ * @param data Данные для хэширования (строка или число)
347
+ * @returns Хэш в виде hex-строки
348
+ */
349
+ static async sha256(data) {
350
+ const str = String(data);
351
+ const isBrowser = typeof window !== "undefined" && typeof window.crypto !== "undefined" && typeof window.crypto.subtle !== "undefined";
352
+ if (isBrowser) {
353
+ const encoder = new TextEncoder();
354
+ const hashBuffer = await window.crypto.subtle.digest("SHA-256", encoder.encode(str));
355
+ return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
356
+ } else {
357
+ try {
358
+ return nodeCrypto__namespace.createHash("sha256").update(str).digest("hex");
359
+ } catch (error) {
360
+ console.warn("Node.js crypto \u043C\u043E\u0434\u0443\u043B\u044C \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D", error);
361
+ throw new Error("\u041A\u0440\u0438\u043F\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043A\u0438\u0435 \u0444\u0443\u043D\u043A\u0446\u0438\u0438 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044E\u0442\u0441\u044F \u0432 \u044D\u0442\u043E\u043C \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u0438");
362
+ }
363
+ }
364
+ }
365
+ }
366
+
367
+ var __defProp$2 = Object.defineProperty;
368
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
369
+ var __publicField$2 = (obj, key, value) => {
370
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
332
371
  return value;
333
372
  };
334
373
  class Document {
@@ -337,7 +376,7 @@ class Document {
337
376
  * @param wifKey WIF-ключ, используемый для подписи.
338
377
  */
339
378
  constructor(wifKey) {
340
- __publicField$1(this, "wif");
379
+ __publicField$2(this, "wif");
341
380
  if (wifKey)
342
381
  this.wif = antelope.PrivateKey.fromString(wifKey);
343
382
  }
@@ -348,18 +387,50 @@ class Document {
348
387
  setWif(wifKey) {
349
388
  this.wif = antelope.PrivateKey.fromString(wifKey);
350
389
  }
390
+ /**
391
+ * Вычисляет meta_hash, hash и signed_hash по актуальной логике в зависимости от версии.
392
+ */
393
+ async calculateHashes({ meta, documentHash, signed_at, version = "1.0.0" }) {
394
+ if (version === "1.0.0" || !version) {
395
+ const meta_hash = await Crypto.sha256(JSON.stringify(meta));
396
+ const hash = await Crypto.sha256(meta_hash + documentHash);
397
+ const signed_hash = await Crypto.sha256(hash + signed_at);
398
+ return { meta_hash, hash, signed_hash };
399
+ }
400
+ throw new Error(`\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F \u0430\u043B\u0433\u043E\u0440\u0438\u0442\u043C\u0430: ${version}`);
401
+ }
351
402
  /**
352
403
  * Подписывает документ и возвращает его в формате ISignedDocument.
353
404
  * @param document Сгенерированный документ для подписи.
405
+ * @param account Имя аккаунта подписывающего (signer)
406
+ * @param signatureId ID подписи (обычно 1 для первой подписи)
354
407
  * @returns Подписанный документ.
355
408
  */
356
- async signDocument(document) {
357
- const digitalSignature = this.signDigest(document.hash);
358
- return {
359
- hash: document.hash,
409
+ async signDocument(document, account, signatureId = 1) {
410
+ const version = "1.0.0";
411
+ if (!this.wif)
412
+ 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`);
413
+ const now = /* @__PURE__ */ new Date();
414
+ const signed_at = now.toISOString().split(".")[0];
415
+ const { meta_hash, hash, signed_hash } = await this.calculateHashes({ meta: document.meta, documentHash: document.hash, signed_at, version });
416
+ const digitalSignature = this.signDigest(signed_hash);
417
+ const signatureInfo = {
418
+ id: signatureId,
419
+ signer: account,
360
420
  public_key: digitalSignature.public_key,
361
421
  signature: digitalSignature.signature,
362
- meta: document.meta
422
+ signed_at,
423
+ signed_hash,
424
+ meta: ""
425
+ };
426
+ return {
427
+ version,
428
+ hash,
429
+ doc_hash: document.hash,
430
+ // TODO: после миграции фабрики заменить здесь на doc_hash
431
+ meta_hash,
432
+ meta: document.meta,
433
+ signatures: [signatureInfo]
363
434
  };
364
435
  }
365
436
  /**
@@ -381,6 +452,241 @@ class Document {
381
452
  public_key: this.wif.toPublic().toString()
382
453
  };
383
454
  }
455
+ /**
456
+ * Статический метод для валидации подписанного документа.
457
+ * Проверяет корректность дат, подписей и их порядок.
458
+ *
459
+ * @param document Подписанный документ для проверки
460
+ * @returns true если документ валиден, иначе false
461
+ */
462
+ static validateDocument(document) {
463
+ try {
464
+ const { signatures } = document;
465
+ if (!signatures || signatures.length === 0) {
466
+ return false;
467
+ }
468
+ for (let i = 0; i < signatures.length; i++) {
469
+ if (signatures[i].id !== i && signatures[i].id !== i + 1) {
470
+ return false;
471
+ }
472
+ try {
473
+ const publicKeyObj = antelope.PublicKey.from(signatures[i].public_key);
474
+ const signatureObj = antelope.Signature.from(signatures[i].signature);
475
+ const verified = signatureObj.verifyDigest(signatures[i].signed_hash, publicKeyObj);
476
+ if (!verified) {
477
+ return false;
478
+ }
479
+ } catch (_) {
480
+ return false;
481
+ }
482
+ }
483
+ return true;
484
+ } catch (_) {
485
+ return false;
486
+ }
487
+ }
488
+ /**
489
+ * Статический метод для преобразования подписанного документа в формат для блокчейна.
490
+ * Преобразует метаданные в строки JSON.
491
+ *
492
+ * @param document Подписанный документ для финализации
493
+ * @returns Документ в формате для отправки в блокчейн
494
+ */
495
+ static finalize(document) {
496
+ const stringifiedMeta = JSON.stringify(document.meta);
497
+ const finalizedSignatures = document.signatures.map((sig) => ({
498
+ ...sig,
499
+ meta: typeof sig.meta === "object" ? JSON.stringify(sig.meta) : sig.meta
500
+ }));
501
+ return {
502
+ version: document.version,
503
+ hash: document.hash,
504
+ doc_hash: document.doc_hash,
505
+ meta_hash: document.meta_hash,
506
+ meta: stringifiedMeta,
507
+ signatures: finalizedSignatures
508
+ };
509
+ }
510
+ /**
511
+ * Статический метод для преобразования документа из формата блокчейна в стандартный формат.
512
+ * Преобразует строки JSON метаданных в объекты.
513
+ *
514
+ * @param document Документ в формате блокчейна
515
+ * @returns Стандартный подписанный документ
516
+ */
517
+ static parse(document) {
518
+ const parsedMeta = typeof document.meta === "string" ? JSON.parse(document.meta) : document.meta;
519
+ const parsedSignatures = document.signatures.map((sig) => ({
520
+ ...sig,
521
+ meta: typeof sig.meta === "string" && sig.meta !== "" ? JSON.parse(sig.meta) : sig.meta
522
+ }));
523
+ return {
524
+ version: document.version,
525
+ hash: document.hash,
526
+ doc_hash: document.doc_hash,
527
+ meta_hash: document.meta_hash,
528
+ meta: parsedMeta,
529
+ signatures: parsedSignatures
530
+ };
531
+ }
532
+ /**
533
+ * Статический метод для валидации отдельной подписи документа.
534
+ * Проверяет корректность даты и цифровой подписи.
535
+ *
536
+ * @param signature Информация о подписи для проверки
537
+ * @returns true если подпись валидна, иначе false
538
+ */
539
+ static validateSignature(signature) {
540
+ try {
541
+ const publicKeyObj = antelope.PublicKey.from(signature.public_key);
542
+ const signatureObj = antelope.Signature.from(signature.signature);
543
+ const verified = signatureObj.verifyDigest(signature.signed_hash, publicKeyObj);
544
+ return verified;
545
+ } catch (_) {
546
+ return false;
547
+ }
548
+ }
549
+ }
550
+
551
+ var __defProp$1 = Object.defineProperty;
552
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
553
+ var __publicField$1 = (obj, key, value) => {
554
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
555
+ return value;
556
+ };
557
+ class Vote {
558
+ /**
559
+ * Инициализация класса Vote с WIF-ключом.
560
+ * @param wifKey WIF-ключ, используемый для подписи.
561
+ */
562
+ constructor(wifKey) {
563
+ __publicField$1(this, "wif");
564
+ if (wifKey)
565
+ this.wif = antelope.PrivateKey.fromString(wifKey);
566
+ }
567
+ /**
568
+ * Замена текущего WIF-ключа на новый.
569
+ * @param wifKey Новый WIF-ключ.
570
+ */
571
+ setWif(wifKey) {
572
+ this.wif = antelope.PrivateKey.fromString(wifKey);
573
+ }
574
+ /**
575
+ * Создает подпись для голосования
576
+ *
577
+ * @param decision_id ID решения
578
+ * @returns Объект подписи голосования
579
+ */
580
+ async signVote(decision_id) {
581
+ if (!this.wif)
582
+ 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 \u0433\u043E\u043B\u043E\u0441\u0430");
583
+ const version = "1.0.0";
584
+ const now = /* @__PURE__ */ new Date();
585
+ const signed_at = now.toISOString().split(".")[0];
586
+ const signed_hash = await Crypto.sha256(String(decision_id) + signed_at);
587
+ const signature = this.wif.signDigest(signed_hash);
588
+ const verified = signature.verifyDigest(signed_hash, this.wif.toPublic());
589
+ if (!verified) {
590
+ throw new Error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438 \u043F\u043E\u0434\u043F\u0438\u0441\u0438");
591
+ }
592
+ return {
593
+ version,
594
+ signed_at,
595
+ signed_hash,
596
+ signature: signature.toString(),
597
+ public_key: this.wif.toPublic().toString()
598
+ };
599
+ }
600
+ /**
601
+ * Подписывает голос "ЗА" решение
602
+ *
603
+ * @param coopname Имя кооператива
604
+ * @param username Имя пользователя (члена совета)
605
+ * @param decision_id ID решения
606
+ * @returns Объект с параметрами для вызова транзакции votefor
607
+ */
608
+ async voteFor(coopname, username, decision_id) {
609
+ const voteSignature = await this.signVote(decision_id);
610
+ return {
611
+ version: voteSignature.version,
612
+ coopname,
613
+ username,
614
+ decision_id,
615
+ signed_at: voteSignature.signed_at,
616
+ signed_hash: voteSignature.signed_hash,
617
+ signature: voteSignature.signature,
618
+ public_key: voteSignature.public_key
619
+ };
620
+ }
621
+ /**
622
+ * Подписывает голос "ПРОТИВ" решения
623
+ *
624
+ * @param coopname Имя кооператива
625
+ * @param username Имя пользователя (члена совета)
626
+ * @param decision_id ID решения
627
+ * @returns Объект с параметрами для вызова транзакции voteagainst
628
+ */
629
+ async voteAgainst(coopname, username, decision_id) {
630
+ const voteSignature = await this.signVote(decision_id);
631
+ return {
632
+ version: voteSignature.version,
633
+ coopname,
634
+ username,
635
+ decision_id,
636
+ signed_at: voteSignature.signed_at,
637
+ signed_hash: voteSignature.signed_hash,
638
+ signature: voteSignature.signature,
639
+ public_key: voteSignature.public_key
640
+ };
641
+ }
642
+ /**
643
+ * Статический метод для валидации подписи голоса.
644
+ *
645
+ * @param data Объект с данными голосования
646
+ * @returns true если подпись валидна, иначе false
647
+ */
648
+ static validateVote(data) {
649
+ try {
650
+ if (data.version !== "1.0.0") {
651
+ return false;
652
+ }
653
+ const signedAtDate = new Date(data.signed_at);
654
+ if (signedAtDate > /* @__PURE__ */ new Date()) {
655
+ return false;
656
+ }
657
+ const publicKeyObj = antelope.PublicKey.from(data.public_key);
658
+ const signatureObj = antelope.Signature.from(data.signature);
659
+ return signatureObj.verifyDigest(data.signed_hash, publicKeyObj);
660
+ } catch (_) {
661
+ return false;
662
+ }
663
+ }
664
+ /**
665
+ * Асинхронная версия метода проверки подписи голоса, которая также проверяет корректность signedHash.
666
+ *
667
+ * @param data Объект с данными голосования
668
+ * @returns Promise<boolean>, который разрешается в true если подпись валидна, иначе false
669
+ */
670
+ static async validateVoteWithHashCheck(data) {
671
+ try {
672
+ if (data.version !== "1.0.0") {
673
+ return false;
674
+ }
675
+ const signedAtDate = new Date(data.signed_at);
676
+ if (signedAtDate > /* @__PURE__ */ new Date()) {
677
+ return false;
678
+ }
679
+ const calculatedSignedHash = await Crypto.sha256(String(data.decision_id) + data.signed_at);
680
+ if (calculatedSignedHash !== data.signed_hash) {
681
+ return false;
682
+ }
683
+ const publicKeyObj = antelope.PublicKey.from(data.public_key);
684
+ const signatureObj = antelope.Signature.from(data.signature);
685
+ return signatureObj.verifyDigest(data.signed_hash, publicKeyObj);
686
+ } catch (_) {
687
+ return false;
688
+ }
689
+ }
384
690
  }
385
691
 
386
692
  const Classes = {
@@ -388,7 +694,9 @@ const Classes = {
388
694
  Account: Account,
389
695
  Blockchain: Blockchain,
390
696
  Canvas: Canvas,
391
- Document: Document
697
+ Crypto: Crypto,
698
+ Document: Document,
699
+ Vote: Vote
392
700
  };
393
701
 
394
702
  const AllTypesProps = {
@@ -407,24 +715,28 @@ const AllTypesProps = {
407
715
  AgreementInput: {},
408
716
  AnnualGeneralMeetingAgendaGenerateDocumentInput: {},
409
717
  AnnualGeneralMeetingAgendaSignedDocumentInput: {
410
- meta: "AnnualGeneralMeetingAgendaSignedMetaDocumentInput"
718
+ meta: "AnnualGeneralMeetingAgendaSignedMetaDocumentInput",
719
+ signatures: "SignatureInfoInput"
411
720
  },
412
721
  AnnualGeneralMeetingAgendaSignedMetaDocumentInput: {},
413
722
  AnnualGeneralMeetingDecisionGenerateDocumentInput: {},
414
723
  AnnualGeneralMeetingDecisionSignedDocumentInput: {
415
- meta: "AnnualGeneralMeetingDecisionSignedMetaDocumentInput"
724
+ meta: "AnnualGeneralMeetingDecisionSignedMetaDocumentInput",
725
+ signatures: "SignatureInfoInput"
416
726
  },
417
727
  AnnualGeneralMeetingDecisionSignedMetaDocumentInput: {},
418
728
  AnnualGeneralMeetingNotificationGenerateDocumentInput: {},
419
729
  AnnualGeneralMeetingSovietDecisionGenerateDocumentInput: {},
420
730
  AnnualGeneralMeetingVotingBallotGenerateDocumentInput: {},
421
731
  AnnualGeneralMeetingVotingBallotSignedDocumentInput: {
422
- meta: "AnnualGeneralMeetingVotingBallotSignedMetaDocumentInput"
732
+ meta: "AnnualGeneralMeetingVotingBallotSignedMetaDocumentInput",
733
+ signatures: "SignatureInfoInput"
423
734
  },
424
735
  AnnualGeneralMeetingVotingBallotSignedMetaDocumentInput: {},
425
736
  AssetContributionActGenerateDocumentInput: {},
426
737
  AssetContributionActSignedDocumentInput: {
427
- meta: "AssetContributionActSignedMetaDocumentInput"
738
+ meta: "AssetContributionActSignedMetaDocumentInput",
739
+ signatures: "SignatureInfoInput"
428
740
  },
429
741
  AssetContributionActSignedMetaDocumentInput: {},
430
742
  AssetContributionDecisionGenerateDocumentInput: {},
@@ -432,7 +744,8 @@ const AllTypesProps = {
432
744
  request: "CommonRequestInput"
433
745
  },
434
746
  AssetContributionStatementSignedDocumentInput: {
435
- meta: "AssetContributionStatementSignedMetaDocumentInput"
747
+ meta: "AssetContributionStatementSignedMetaDocumentInput",
748
+ signatures: "SignatureInfoInput"
436
749
  },
437
750
  AssetContributionStatementSignedMetaDocumentInput: {
438
751
  request: "CommonRequestInput"
@@ -771,7 +1084,8 @@ const AllTypesProps = {
771
1084
  ParticipantApplicationDecisionGenerateDocumentInput: {},
772
1085
  ParticipantApplicationGenerateDocumentInput: {},
773
1086
  ParticipantApplicationSignedDocumentInput: {
774
- meta: "ParticipantApplicationSignedMetaDocumentInput"
1087
+ meta: "ParticipantApplicationSignedMetaDocumentInput",
1088
+ signatures: "SignatureInfoInput"
775
1089
  },
776
1090
  ParticipantApplicationSignedMetaDocumentInput: {},
777
1091
  PassportInput: {},
@@ -779,7 +1093,8 @@ const AllTypesProps = {
779
1093
  ProhibitRequestInput: {},
780
1094
  ProjectFreeDecisionGenerateDocumentInput: {},
781
1095
  ProjectFreeDecisionSignedDocumentInput: {
782
- meta: "ProjectFreeDecisionSignedMetaDocumentInput"
1096
+ meta: "ProjectFreeDecisionSignedMetaDocumentInput",
1097
+ signatures: "SignatureInfoInput"
783
1098
  },
784
1099
  ProjectFreeDecisionSignedMetaDocumentInput: {},
785
1100
  PublishProjectFreeDecisionInput: {
@@ -843,7 +1158,8 @@ const AllTypesProps = {
843
1158
  },
844
1159
  ReturnByAssetActGenerateDocumentInput: {},
845
1160
  ReturnByAssetActSignedDocumentInput: {
846
- meta: "ReturnByAssetActSignedMetaDocumentInput"
1161
+ meta: "ReturnByAssetActSignedMetaDocumentInput",
1162
+ signatures: "SignatureInfoInput"
847
1163
  },
848
1164
  ReturnByAssetActSignedMetaDocumentInput: {},
849
1165
  ReturnByAssetDecisionGenerateDocumentInput: {},
@@ -851,7 +1167,8 @@ const AllTypesProps = {
851
1167
  request: "CommonRequestInput"
852
1168
  },
853
1169
  ReturnByAssetStatementSignedDocumentInput: {
854
- meta: "ReturnByAssetStatementSignedMetaDocumentInput"
1170
+ meta: "ReturnByAssetStatementSignedMetaDocumentInput",
1171
+ signatures: "SignatureInfoInput"
855
1172
  },
856
1173
  ReturnByAssetStatementSignedMetaDocumentInput: {
857
1174
  request: "CommonRequestInput"
@@ -861,7 +1178,8 @@ const AllTypesProps = {
861
1178
  document: "SelectBranchSignedDocumentInput"
862
1179
  },
863
1180
  SelectBranchSignedDocumentInput: {
864
- meta: "SelectBranchSignedMetaDocumentInput"
1181
+ meta: "SelectBranchSignedMetaDocumentInput",
1182
+ signatures: "SignatureInfoInput"
865
1183
  },
866
1184
  SelectBranchSignedMetaDocumentInput: {},
867
1185
  SetPaymentStatusInput: {
@@ -874,8 +1192,12 @@ const AllTypesProps = {
874
1192
  SignBySecretaryOnAnnualGeneralMeetInput: {
875
1193
  secretary_decision: "AnnualGeneralMeetingDecisionSignedDocumentInput"
876
1194
  },
1195
+ SignatureInfoInput: {
1196
+ meta: "JSON"
1197
+ },
877
1198
  SignedDigitalDocumentInput: {
878
- meta: "MetaDocumentInput"
1199
+ meta: "MetaDocumentInput",
1200
+ signatures: "SignatureInfoInput"
879
1201
  },
880
1202
  SovietMemberInput: {
881
1203
  individual_data: "CreateIndividualDataInput"
@@ -1170,9 +1492,9 @@ const ReturnTypes = {
1170
1492
  title: "String"
1171
1493
  },
1172
1494
  DocumentAggregate: {
1495
+ document: "SignedDigitalDocument",
1173
1496
  hash: "String",
1174
- rawDocument: "GeneratedDocument",
1175
- signatures: "SignedDigitalDocument"
1497
+ rawDocument: "GeneratedDocument"
1176
1498
  },
1177
1499
  DocumentPackageAggregate: {
1178
1500
  acts: "ActDetailAggregate",
@@ -1575,19 +1897,32 @@ const ReturnTypes = {
1575
1897
  SbpAccount: {
1576
1898
  phone: "String"
1577
1899
  },
1900
+ SignatureInfo: {
1901
+ id: "Float",
1902
+ is_valid: "Boolean",
1903
+ meta: "JSON",
1904
+ public_key: "String",
1905
+ signature: "String",
1906
+ signed_at: "String",
1907
+ signed_hash: "String",
1908
+ signer: "String",
1909
+ signer_info: "UserDataUnion"
1910
+ },
1578
1911
  SignedBlockchainDocument: {
1912
+ doc_hash: "String",
1579
1913
  hash: "String",
1580
1914
  meta: "String",
1581
- public_key: "String",
1582
- signature: "String"
1915
+ meta_hash: "String",
1916
+ signatures: "SignatureInfo",
1917
+ version: "String"
1583
1918
  },
1584
1919
  SignedDigitalDocument: {
1920
+ doc_hash: "String",
1585
1921
  hash: "String",
1586
- is_valid: "Boolean",
1587
1922
  meta: "JSON",
1588
- public_key: "String",
1589
- signature: "String",
1590
- signer: "UserDataUnion"
1923
+ meta_hash: "String",
1924
+ signatures: "SignatureInfo",
1925
+ version: "String"
1591
1926
  },
1592
1927
  StatementDetailAggregate: {
1593
1928
  action: "ExtendedBlockchainAction",
@@ -2188,9 +2523,9 @@ const $ = (name, graphqlType) => {
2188
2523
  return START_VAR_NAME + name + GRAPHQL_TYPE_SEPARATOR + graphqlType;
2189
2524
  };
2190
2525
  var AccountType = /* @__PURE__ */ ((AccountType2) => {
2191
- AccountType2["Entrepreneur"] = "Entrepreneur";
2192
- AccountType2["Individual"] = "Individual";
2193
- AccountType2["Organization"] = "Organization";
2526
+ AccountType2["entrepreneur"] = "entrepreneur";
2527
+ AccountType2["individual"] = "individual";
2528
+ AccountType2["organization"] = "organization";
2194
2529
  return AccountType2;
2195
2530
  })(AccountType || {});
2196
2531
  var Country = /* @__PURE__ */ ((Country2) => {
@@ -2729,25 +3064,36 @@ const rawFreeProjectSelector = {
2729
3064
  };
2730
3065
  const createdProjectFreeDecisionSelector = Selector("CreatedProjectFreeDecision")(rawFreeProjectSelector);
2731
3066
 
2732
- const rawDocumentSignatureSelector = {
3067
+ const rawGeneratedDocumentSelector = {
2733
3068
  hash: true,
3069
+ binary: true,
3070
+ full_title: true,
3071
+ html: true,
3072
+ meta: true
3073
+ };
3074
+ const rawSignatureInfoSelector$1 = {
3075
+ id: true,
3076
+ signer: true,
2734
3077
  public_key: true,
2735
3078
  signature: true,
2736
- meta: true,
3079
+ signed_at: true,
2737
3080
  is_valid: true,
2738
- signer: rawUserUnionSelector
3081
+ signer_info: rawUserUnionSelector,
3082
+ signed_hash: true,
3083
+ meta: true
2739
3084
  };
2740
- const rawRawDocumentSelector = {
3085
+ const rawDocumentSignatureSelector = {
3086
+ version: true,
2741
3087
  hash: true,
2742
- binary: true,
2743
- full_title: true,
2744
- html: true,
2745
- meta: true
3088
+ doc_hash: true,
3089
+ meta_hash: true,
3090
+ meta: true,
3091
+ signatures: rawSignatureInfoSelector$1
2746
3092
  };
2747
3093
  const rawDocumentAggregateSelector = {
2748
3094
  hash: true,
2749
- signatures: rawDocumentSignatureSelector,
2750
- rawDocument: rawRawDocumentSelector
3095
+ document: rawDocumentSignatureSelector,
3096
+ rawDocument: rawGeneratedDocumentSelector
2751
3097
  };
2752
3098
 
2753
3099
  const rawAgendaMeetPointSelector = {
@@ -2857,17 +3203,35 @@ Selector("BlockchainInfoDTO")(
2857
3203
  rawBlockchainInfoSelector
2858
3204
  );
2859
3205
 
3206
+ const rawSignatureInfoSelector = {
3207
+ id: true,
3208
+ signer: true,
3209
+ public_key: true,
3210
+ signature: true,
3211
+ signed_at: true,
3212
+ is_valid: true,
3213
+ signer_info: rawUserUnionSelector,
3214
+ signed_hash: true,
3215
+ meta: true
3216
+ };
3217
+ Selector("SignatureInfo")(rawSignatureInfoSelector);
3218
+
3219
+ const rawSignedBlockchainDocumentSelector = {
3220
+ version: true,
3221
+ hash: true,
3222
+ doc_hash: true,
3223
+ meta_hash: true,
3224
+ meta: true,
3225
+ signatures: rawSignatureInfoSelector
3226
+ };
3227
+ Selector("SignedBlockchainDocument")(rawSignedBlockchainDocumentSelector);
3228
+
2860
3229
  const rawCooperatorAccountSelector = {
2861
3230
  announce: true,
2862
3231
  coop_type: true,
2863
3232
  created_at: true,
2864
3233
  description: true,
2865
- document: {
2866
- hash: true,
2867
- public_key: true,
2868
- meta: true,
2869
- signature: true
2870
- },
3234
+ document: rawSignedBlockchainDocumentSelector,
2871
3235
  initial: true,
2872
3236
  is_branched: true,
2873
3237
  is_cooperative: true,
@@ -2899,57 +3263,45 @@ Selector("CooperativeOperatorAccount")(
2899
3263
  rawCooperatorAccountSelector
2900
3264
  );
2901
3265
 
3266
+ const rawPublicChairmanSelector = {
3267
+ first_name: true,
3268
+ last_name: true,
3269
+ middle_name: true
3270
+ };
3271
+ const rawOrganizationDetailsSelector = {
3272
+ inn: true,
3273
+ kpp: true,
3274
+ ogrn: true
3275
+ };
2902
3276
  const rawContactsSelector = {
2903
- chairman: {
2904
- first_name: true,
2905
- last_name: true,
2906
- middle_name: true
2907
- },
2908
- details: {
2909
- inn: true,
2910
- kpp: true,
2911
- ogrn: true
2912
- },
3277
+ chairman: rawPublicChairmanSelector,
3278
+ details: rawOrganizationDetailsSelector,
2913
3279
  email: true,
2914
3280
  full_address: true,
2915
3281
  full_name: true,
2916
3282
  phone: true
2917
3283
  };
3284
+ const rawAgreementVarSelector = {
3285
+ protocol_day_month_year: true,
3286
+ protocol_number: true
3287
+ };
2918
3288
  const rawVarsSelector = {
2919
3289
  confidential_email: true,
2920
3290
  confidential_link: true,
2921
3291
  contact_email: true,
2922
- coopenomics_agreement: {
2923
- protocol_day_month_year: true,
2924
- protocol_number: true
2925
- },
3292
+ coopenomics_agreement: rawAgreementVarSelector,
2926
3293
  coopname: true,
2927
3294
  full_abbr: true,
2928
3295
  full_abbr_dative: true,
2929
3296
  full_abbr_genitive: true,
2930
3297
  name: true,
2931
- participant_application: {
2932
- protocol_day_month_year: true,
2933
- protocol_number: true
2934
- },
3298
+ participant_application: rawAgreementVarSelector,
2935
3299
  passport_request: true,
2936
- privacy_agreement: {
2937
- protocol_day_month_year: true,
2938
- protocol_number: true
2939
- },
3300
+ privacy_agreement: rawAgreementVarSelector,
2940
3301
  short_abbr: true,
2941
- signature_agreement: {
2942
- protocol_day_month_year: true,
2943
- protocol_number: true
2944
- },
2945
- user_agreement: {
2946
- protocol_day_month_year: true,
2947
- protocol_number: true
2948
- },
2949
- wallet_agreement: {
2950
- protocol_day_month_year: true,
2951
- protocol_number: true
2952
- },
3302
+ signature_agreement: rawAgreementVarSelector,
3303
+ user_agreement: rawAgreementVarSelector,
3304
+ wallet_agreement: rawAgreementVarSelector,
2953
3305
  website: true
2954
3306
  };
2955
3307
  const rawSystemInfoSelector = {
@@ -3939,14 +4291,6 @@ const index$f = {
3939
4291
  GetAccounts: getAccounts
3940
4292
  };
3941
4293
 
3942
- const rawSignedBlockchainDocumentSelector = {
3943
- hash: true,
3944
- meta: true,
3945
- public_key: true,
3946
- signature: true
3947
- };
3948
- Selector("SignedBlockchainDocument")(rawSignedBlockchainDocumentSelector);
3949
-
3950
4294
  const rawBlockchainDecisionSelector = {
3951
4295
  approved: true,
3952
4296
  authorization: rawSignedBlockchainDocumentSelector,
@@ -4249,16 +4593,23 @@ const _Client = class _Client {
4249
4593
  constructor(options) {
4250
4594
  this.options = options;
4251
4595
  __publicField(this, "currentHeaders", {});
4596
+ __publicField(this, "account");
4252
4597
  __publicField(this, "blockchain");
4253
4598
  __publicField(this, "document");
4599
+ __publicField(this, "crypto");
4600
+ __publicField(this, "vote");
4254
4601
  __publicField(this, "thunder");
4255
4602
  this.currentHeaders = options.headers || {};
4256
4603
  this.thunder = _Client.createThunder(options.api_url);
4604
+ this.account = new Account();
4257
4605
  this.blockchain = new Blockchain(options);
4258
4606
  this.document = new Document(options.wif);
4607
+ this.crypto = new Crypto();
4608
+ this.vote = new Vote(options.wif);
4259
4609
  if (options.wif && options.username) {
4260
4610
  this.blockchain.setWif(options.username, options.wif);
4261
4611
  this.document.setWif(options.wif);
4612
+ this.vote.setWif(options.wif);
4262
4613
  } else if (options.wif && !options.username || !options.wif && options.username) {
4263
4614
  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");
4264
4615
  }
@@ -4310,6 +4661,7 @@ const _Client = class _Client {
4310
4661
  const username = result.account.username;
4311
4662
  this.blockchain.setWif(username, wif);
4312
4663
  this.document.setWif(wif);
4664
+ this.vote.setWif(wif);
4313
4665
  this.currentHeaders.Authorization = `Bearer ${result.tokens.access.token}`;
4314
4666
  return result;
4315
4667
  }
@@ -4320,18 +4672,45 @@ const _Client = class _Client {
4320
4672
  setToken(token) {
4321
4673
  this.currentHeaders.Authorization = `Bearer ${token}`;
4322
4674
  }
4675
+ /**
4676
+ * Установка WIF.
4677
+ * @param wif WIF для установки.
4678
+ */
4679
+ setWif(username, wif) {
4680
+ this.blockchain.setWif(username, wif);
4681
+ this.document.setWif(wif);
4682
+ this.vote.setWif(wif);
4683
+ }
4323
4684
  /**
4324
4685
  * Доступ к Blockchain.
4325
4686
  */
4326
4687
  get Blockchain() {
4327
4688
  return this.blockchain;
4328
4689
  }
4690
+ /**
4691
+ * Доступ к Account.
4692
+ */
4693
+ get Account() {
4694
+ return this.account;
4695
+ }
4329
4696
  /**
4330
4697
  * Доступ к Document.
4331
4698
  */
4332
4699
  get Document() {
4333
4700
  return this.document;
4334
4701
  }
4702
+ /**
4703
+ * Доступ к Crypto.
4704
+ */
4705
+ get Crypto() {
4706
+ return this.crypto;
4707
+ }
4708
+ /**
4709
+ * Доступ к Vote.
4710
+ */
4711
+ get Vote() {
4712
+ return this.vote;
4713
+ }
4335
4714
  /**
4336
4715
  * Доступ к GraphQL-запросам.
4337
4716
  */