@it-enterprise/digital-signature 1.4.0 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@it-enterprise/digital-signature",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "digital signature",
5
5
  "private": false,
6
6
  "main": "src/index.js",
package/readme.md CHANGED
@@ -886,7 +886,7 @@ const protectedReports = await ds.protectTaxReports({
886
886
  Після виконання шифрування, ключ необхідно очистити, викликавши функцію **ctxFreePrivateKey**
887
887
 
888
888
  ```javascript
889
- await ds.ctxReadHardwareKey(
889
+ await ds.ctxFreePrivateKey(
890
890
  // Зчитаний ключ
891
891
  keyInfo,
892
892
  );
@@ -1252,7 +1252,7 @@ export default class DigitalSignature {
1252
1252
  /**
1253
1253
  * Зашифрувати звіти в податкову
1254
1254
  * @param {ProtectTaxReportParams} params - Параметри шифрування
1255
- * @returns Promise<Array<EndUserTaxReport>>
1255
+ * @returns {Promise<Array<EndUserTaxReport>>}
1256
1256
  */
1257
1257
  async protectTaxReports(params) {
1258
1258
  return await this._euSign.ProtectTaxReports(
@@ -1286,7 +1286,7 @@ export default class DigitalSignature {
1286
1286
  };
1287
1287
  }
1288
1288
 
1289
- if (Array.isArray(certs)) {
1289
+ if (Array.isArray(certs) && certs.length > 0) {
1290
1290
  certs = await Promise.all(certs.map(cert =>
1291
1291
  cert instanceof File || cert instanceof Blob ? readFile(cert) :
1292
1292
  cert instanceof EndUserCertificate ? cert.data :
@@ -1295,7 +1295,7 @@ export default class DigitalSignature {
1295
1295
 
1296
1296
  try {
1297
1297
  const ctx = await this._euSign.CtxCreate();
1298
- const keyCtx = await this._euSign.CtxReadPrivateKey(keyMedia, certs, this._selectedIssuerCN);
1298
+ const keyCtx = await this._euSign.CtxReadPrivateKey(ctx, keyMedia, certs, this._selectedIssuerCN);
1299
1299
  const readedKey = new HardwarePrivateKeyInfo(
1300
1300
  DigitalSignatureKeyType.Token,
1301
1301
  keyCtx.ownerInfo,
@@ -1356,7 +1356,7 @@ export default class DigitalSignature {
1356
1356
  if (privateKey instanceof File || privateKey instanceof Blob) {
1357
1357
  privateKey = await readFile(privateKey);
1358
1358
  }
1359
- if (Array.isArray(certs)) {
1359
+ if (Array.isArray(certs) && certs.length > 0) {
1360
1360
  certs = await Promise.all(certs.map(cert =>
1361
1361
  cert instanceof File || cert instanceof Blob ? readFile(cert) :
1362
1362
  cert instanceof EndUserCertificate ? cert.data :
@@ -1406,7 +1406,7 @@ export default class DigitalSignature {
1406
1406
  * @param {PrivateKeyInfo} privateKeyContext - Контекст приватного ключа
1407
1407
  */
1408
1408
  async ctxFreePrivateKey(privateKeyContext) {
1409
- if (privateKeyContext instanceof HardwarePrivateKeyInfo) {
1409
+ if (privateKeyContext.keyType === DigitalSignatureKeyType.Token) {
1410
1410
  await this.setLibraryType(DigitalSignatureKeyType.Token);
1411
1411
  } else {
1412
1412
  await this.setLibraryType(DigitalSignatureKeyType.File);
package/src/GlSign.js CHANGED
@@ -104,7 +104,7 @@ export default class GlSign {
104
104
  }
105
105
 
106
106
  this.KSPs.forEach(element => {
107
- if (element.ksp === EndUserKSP.DIIA || element.ksp === EndUserKSP.IIT || element.ksp === EndUserKSP.PB) {
107
+ if (element.ksp === EndUserKSP.DIIA || element.ksp === EndUserKSP.IIT || element.ksp === EndUserKSP.PB || element.ksp === EndUserKSP.VTOKEN) {
108
108
  if (element.address.includes("cabinet.e-life.com.ua")
109
109
  || element.address.includes("sserver.amokey.com")
110
110
  || element.address.includes("smart-sign.dpsu.gov.ua")
package/src/Models.js CHANGED
@@ -370,6 +370,9 @@ export class PrivateKeyInfo {
370
370
  * Является ли ключ цифровой печаткой
371
371
  */
372
372
  isDigitalStamp() {
373
+ if (!Array.isArray(this.certificates) || this.certificates.length === 0) {
374
+ return false;
375
+ }
373
376
  const certificates = this.certificates;
374
377
  for (let certificate = 0; certificate < certificates.length; certificate++) {
375
378
  const infoEx = certificates[certificate].infoEx;
@@ -385,7 +388,7 @@ export class PrivateKeyInfo {
385
388
  * Ключ поддерживает электронную подпись
386
389
  */
387
390
  supportSigning() {
388
- if (this instanceof KspPrivateKeyInfo) {
391
+ if (this.keyType === DigitalSignatureKeyTypeKSP) {
389
392
  return true;
390
393
  }
391
394
 
@@ -403,6 +406,10 @@ export class PrivateKeyInfo {
403
406
  * Ключ поддерживает шифрование
404
407
  */
405
408
  supportEncryption() {
409
+ if (this.keyType === DigitalSignatureKeyTypeKSP) {
410
+ return false;
411
+ }
412
+
406
413
  const certificates = this.certificates;
407
414
  for (let certificate = 0; certificate < certificates.length; certificate++) {
408
415
  const infoEx = certificates[certificate].infoEx;
@@ -611,7 +618,7 @@ export function getDefaultKSPs(allowTest) {
611
618
  ugb.needQRCode = false;
612
619
 
613
620
  const alliance = new KSPSettings();
614
- alliance.id = "alliance";
621
+ alliance.id = "ALLIANCE";
615
622
  alliance.name = "Банк Альянс - хмарний підпис";
616
623
  alliance.ksp = EndUserKSP.VTOKEN;
617
624
  alliance.address = "https://cihsm-api.bankalliance.ua/vtco/api/v1";
@@ -621,7 +628,7 @@ export function getDefaultKSPs(allowTest) {
621
628
  alliance.needQRCode = false;
622
629
 
623
630
  const vtoken = new KSPSettings();
624
- vtoken.id = "vtoken";
631
+ vtoken.id = "VTOKEN";
625
632
  vtoken.name = "Хмарний сервіс Шифр-vToken (тестовий)";
626
633
  vtoken.ksp = EndUserKSP.VTOKEN;
627
634
  vtoken.address = "https://cihsm-dev-api.cipher.com.ua/vtco/api/v1";