@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.
@@ -8996,42 +8996,6 @@ EndUser.prototype.GetKeyMediasKSP = function (kspSettings, authData, onSuccess,
8996
8996
  if (!response[i].signatureKey) {
8997
8997
  continue;
8998
8998
  }
8999
- if (response[i].signatureKey.algorithmInfo.startsWith("1.2.804.2.1.1.1.1.3.6.1")) {
9000
- pThis.m_euKSP.vTokenKeysCache[response[i].uri] = {
9001
- signAlgo: EU_CTX_SIGN_DSTU4145_WITH_DSTU7564,
9002
- hashAlgo: EU_CTX_HASH_ALGO_DSTU7564_256
9003
- };
9004
- }
9005
- if (response[i].signatureKey.algorithmInfo.startsWith("1.2.804.2.1.1.1.1.3.6.2")) {
9006
- pThis.m_euKSP.vTokenKeysCache[response[i].uri] = {
9007
- signAlgo: EU_CTX_SIGN_DSTU4145_WITH_DSTU7564,
9008
- hashAlgo: EU_CTX_HASH_ALGO_DSTU7564_384
9009
- };
9010
- }
9011
- if (response[i].signatureKey.algorithmInfo.startsWith("1.2.804.2.1.1.1.1.3.6.3")) {
9012
- pThis.m_euKSP.vTokenKeysCache[response[i].uri] = {
9013
- signAlgo: EU_CTX_SIGN_DSTU4145_WITH_DSTU7564,
9014
- hashAlgo: EU_CTX_HASH_ALGO_DSTU7564_512
9015
- };
9016
- }
9017
- if (response[i].signatureKey.algorithmInfo.startsWith("1.2.804.2.1.1.1.1.3.1.1")) {
9018
- pThis.m_euKSP.vTokenKeysCache[response[i].uri] = {
9019
- signAlgo: EU_CTX_SIGN_DSTU4145_WITH_GOST34311,
9020
- hashAlgo: EU_CTX_HASH_ALGO_GOST34311
9021
- };
9022
- }
9023
- if (response[i].signatureKey.algorithmInfo.startsWith("1.2.840.10045.4.3")) {
9024
- pThis.m_euKSP.vTokenKeysCache[response[i].uri] = {
9025
- signAlgo: EU_CTX_SIGN_ECDSA_WITH_SHA,
9026
- hashAlgo: EU_CTX_HASH_ALGO_SHA256
9027
- };
9028
- }
9029
- if (response[i].signatureKey.algorithmInfo.startsWith("1.2.840.113549.1.1")) {
9030
- pThis.m_euKSP.vTokenKeysCache[response[i].uri] = {
9031
- signAlgo: EU_CTX_SIGN_RSA_WITH_SHA,
9032
- hashAlgo: EU_CTX_HASH_ALGO_SHA256
9033
- };
9034
- }
9035
8999
  keys.push({
9036
9000
  keyId: response[i].uri,
9037
9001
  visibleName: `${response[i].title} [${response[i].signatureKey.subjectCommonName}]`,
@@ -9259,12 +9223,8 @@ EndUserKSP.prototype._CtxReadPrivateKeyWithServer = function (_super) {
9259
9223
  return;
9260
9224
  }
9261
9225
  var pThis = this;
9262
- var signAlgos = kspSettings.signAlgos || [EU_CTX_SIGN_DSTU4145_WITH_GOST34311, /*EU_CTX_SIGN_DSTU4145_WITH_DSTU7564,*/
9263
- EU_CTX_SIGN_RSA_WITH_SHA, EU_CTX_SIGN_ECDSA_WITH_SHA];
9226
+ var signAlgos = kspSettings.signAlgos || [EU_CTX_SIGN_DSTU4145_WITH_GOST34311, EU_CTX_SIGN_DSTU4145_WITH_DSTU7564, EU_CTX_SIGN_RSA_WITH_SHA, EU_CTX_SIGN_ECDSA_WITH_SHA];
9264
9227
  var certIssuerCN = null;
9265
- if (kspSettings.ksp === EndUserKSP.EU_KSP_VTOKEN && pThisvTokenKeysCache[keyId]) {
9266
- signAlgos = [pThisvTokenKeysCache[keyId].signAlgo];
9267
- }
9268
9228
  var keyContext = new EndUserKSPKey(kspSettings, userId, keyId, signAlgos, pThis._GetKSPSignContainers(kspSettings), certIssuerCN, [], null);
9269
9229
  keyContext.authData = authData;
9270
9230
  if (!getCerts) {
@@ -9354,10 +9314,28 @@ EndUserKSP.prototype._CtxSignHashesWithServer = function (_super) {
9354
9314
  var item = hashes[i];
9355
9315
  hashesValues.push(item.val);
9356
9316
  }
9317
+ var hashAlgoes = {
9318
+ [EU_CERT_HASH_TYPE_GOST34311]: "GOST3411",
9319
+ [EU_CERT_HASH_TYPE_DSTU7564_256]: "DSTU7564256",
9320
+ [EU_CERT_HASH_TYPE_DSTU7564_384]: "DSTU7564384",
9321
+ [EU_CERT_HASH_TYPE_DSTU7564_512]: "DSTU7564512",
9322
+ [EU_CERT_HASH_TYPE_SHA1]: "SHA1",
9323
+ [EU_CERT_HASH_TYPE_SHA224]: "SHA224",
9324
+ [EU_CERT_HASH_TYPE_SHA256]: "SHA256",
9325
+ [EU_CERT_HASH_TYPE_SHA384]: "SHA384",
9326
+ [EU_CERT_HASH_TYPE_SHA512]: "SHA512"
9327
+ };
9328
+ var signFormats = {
9329
+ [EU_SIGN_TYPE_CADES_BES]: "CADES_BES",
9330
+ [EU_SIGN_TYPE_CADES_T]: "CADES_T",
9331
+ [EU_SIGN_TYPE_CADES_C]: "CADES_C",
9332
+ [EU_SIGN_TYPE_CADES_X_LONG]: "CADES_X_LONG",
9333
+ [EU_SIGN_TYPE_CADES_X_LONG_TRUSTED]: "CADES_X_LONG"
9334
+ };
9357
9335
  var signParams = {
9358
9336
  pin: keyContext.authData.pin,
9359
- hashAlgorithm: "GOST3411",
9360
- signatureFormat: "CADES_T",
9337
+ hashAlgorithm: hashAlgoes[pThis._GetHashAlgo(signAlgo)],
9338
+ signatureFormat: signFormats[signLevel],
9361
9339
  embedSignerCertificate: true,
9362
9340
  hashesToSign: hashesValues
9363
9341
  };
@@ -9770,7 +9770,7 @@ var k = () => Date.now() >= new Date(2026, 6, 1), A = class {
9770
9770
  console.error("error parsing KSPs from GlSign"), console.error(e);
9771
9771
  }
9772
9772
  (!this.KSPs || this.KSPs.length === 0) && (this.KSPs = q(this.AllowTestKeys)), this.KSPs.forEach((e) => {
9773
- if (e.ksp === V.DIIA || e.ksp === V.IIT || e.ksp === V.PB) {
9773
+ if (e.ksp === V.DIIA || e.ksp === V.IIT || e.ksp === V.PB || e.ksp === V.VTOKEN) {
9774
9774
  if (e.address.includes("cabinet.e-life.com.ua") || e.address.includes("sserver.amokey.com") || e.address.includes("smart-sign.dpsu.gov.ua") || e.address.includes("sign-ca.mvs.gov.ua") || e.address.includes("id.edin.ua") || e.address.includes("business.ukrsibbank.com")) return;
9775
9775
  (!Array.isArray(e.signAlgos) || e.signAlgos.length == 0) && (e.signAlgos = [f.EndUserConstants.EndUserSignAlgo.DSTU4145WithDSTU7564, f.EndUserConstants.EndUserSignAlgo.DSTU4145WithGOST34311]);
9776
9776
  }
@@ -9968,6 +9968,7 @@ var k = () => Date.now() >= new Date(2026, 6, 1), A = class {
9968
9968
  this.keyType = e, this.ownerInfo = t, this.certificates = n, this.visibleName = r, this.id = i;
9969
9969
  }
9970
9970
  isDigitalStamp() {
9971
+ if (!Array.isArray(this.certificates) || this.certificates.length === 0) return !1;
9971
9972
  let e = this.certificates;
9972
9973
  for (let t = 0; t < e.length; t++) {
9973
9974
  let n = e[t].infoEx;
@@ -9976,12 +9977,13 @@ var k = () => Date.now() >= new Date(2026, 6, 1), A = class {
9976
9977
  return !1;
9977
9978
  }
9978
9979
  supportSigning() {
9979
- if (this instanceof K) return !0;
9980
+ if (this.keyType === 2) return !0;
9980
9981
  let e = this.certificates;
9981
9982
  for (let t = 0; t < e.length; t++) if ((e[t].infoEx.keyUsageType & f.EndUserConstants.EndUserKeyUsage.DigitalSignature) == f.EndUserConstants.EndUserKeyUsage.DigitalSignature) return !0;
9982
9983
  return !1;
9983
9984
  }
9984
9985
  supportEncryption() {
9986
+ if (this.keyType === 2) return !1;
9985
9987
  let e = this.certificates;
9986
9988
  for (let t = 0; t < e.length; t++) if ((e[t].infoEx.keyUsageType & f.EndUserConstants.EndUserKeyUsage.KeyAgreement) == f.EndUserConstants.EndUserKeyUsage.KeyAgreement) return !0;
9987
9989
  return !1;
@@ -10042,9 +10044,9 @@ function q(e) {
10042
10044
  let u = new f.KSPSettings();
10043
10045
  u.id = "UGB", u.name = "Укргазбанк - хмарний підпис «EcoSign»", u.ksp = V.VTOKEN, u.address = "https://vtms-api-qca.ukrgasbank.com/vtco/api/v1", u.systemId = "cihsmVtcoServiceClientSmartTender", u.directAccess = !0, u.clientIdType = H.NamePassword, u.needQRCode = !1;
10044
10046
  let d = new f.KSPSettings();
10045
- d.id = "alliance", d.name = "Банк Альянс - хмарний підпис", d.ksp = V.VTOKEN, d.address = "https://cihsm-api.bankalliance.ua/vtco/api/v1", d.systemId = "cihsmVtcoServiceClientSmartTender", d.directAccess = !0, d.clientIdType = H.NamePassword, d.needQRCode = !1;
10047
+ d.id = "ALLIANCE", d.name = "Банк Альянс - хмарний підпис", d.ksp = V.VTOKEN, d.address = "https://cihsm-api.bankalliance.ua/vtco/api/v1", d.systemId = "cihsmVtcoServiceClientSmartTender", d.directAccess = !0, d.clientIdType = H.NamePassword, d.needQRCode = !1;
10046
10048
  let p = new f.KSPSettings();
10047
- p.id = "vtoken", p.name = "Хмарний сервіс Шифр-vToken (тестовий)", p.ksp = V.VTOKEN, p.address = "https://cihsm-dev-api.cipher.com.ua/vtco/api/v1", p.systemId = "cipherVTokenIntegrationClient", p.directAccess = !0, p.clientIdType = H.NamePassword, p.needQRCode = !1;
10049
+ p.id = "VTOKEN", p.name = "Хмарний сервіс Шифр-vToken (тестовий)", p.ksp = V.VTOKEN, p.address = "https://cihsm-dev-api.cipher.com.ua/vtco/api/v1", p.systemId = "cipherVTokenIntegrationClient", p.directAccess = !0, p.clientIdType = H.NamePassword, p.needQRCode = !1;
10048
10050
  let m = new f.KSPSettings();
10049
10051
  m.id = "AMOKEY", m.name = "АМО ФІНТЕХ – хмарний підпис AMOKEY", m.ksp = V.PB, m.address = "https://sserver.amokey.com", m.port = "443", m.clientIdPrefix = "", m.directAccess = !0, m.clientIdType = H.Name, m.needQRCode = !1;
10050
10052
  let h = new f.KSPSettings();
@@ -10824,9 +10826,9 @@ var J = class {
10824
10826
  code: f.EndUserError.EU_ERROR_BAD_PARAMETER,
10825
10827
  message: this._resourses.PasswordNotSet
10826
10828
  };
10827
- Array.isArray(t) && (t = await Promise.all(t.map((e) => e instanceof File || e instanceof Blob ? g(e) : e instanceof f.EndUserCertificate ? e.data : e)));
10829
+ Array.isArray(t) && t.length > 0 && (t = await Promise.all(t.map((e) => e instanceof File || e instanceof Blob ? g(e) : e instanceof f.EndUserCertificate ? e.data : e)));
10828
10830
  try {
10829
- let n = await this._euSign.CtxCreate(), r = await this._euSign.CtxReadPrivateKey(e, t, this._selectedIssuerCN), i = new G(B.Token, r.ownerInfo, await this._euSign.CtxGetOwnCertificates(r), e);
10831
+ let n = await this._euSign.CtxCreate(), r = await this._euSign.CtxReadPrivateKey(n, e, t, this._selectedIssuerCN), i = new G(B.Token, r.ownerInfo, await this._euSign.CtxGetOwnCertificates(r), e);
10830
10832
  return i.context = n, i.keyContext = r, i._glSign = this._glSign, i;
10831
10833
  } catch (e) {
10832
10834
  if (e && e.code === f.EndUserError.EU_ERROR_CERT_NOT_FOUND) {
@@ -10854,7 +10856,7 @@ var J = class {
10854
10856
  code: f.EndUserError.EU_ERROR_BAD_PARAMETER,
10855
10857
  message: this._resourses.PasswordNotSet
10856
10858
  };
10857
- (e instanceof File || e instanceof Blob) && (e = await g(e)), Array.isArray(n) && (n = await Promise.all(n.map((e) => e instanceof File || e instanceof Blob ? g(e) : e instanceof f.EndUserCertificate ? e.data : e)));
10859
+ (e instanceof File || e instanceof Blob) && (e = await g(e)), Array.isArray(n) && n.length > 0 && (n = await Promise.all(n.map((e) => e instanceof File || e instanceof Blob ? g(e) : e instanceof f.EndUserCertificate ? e.data : e)));
10858
10860
  try {
10859
10861
  let r = await this._euSign.CtxCreate(), i = await this._euSign.CtxReadPrivateKeyBinary(r, e, t, n, this._selectedIssuerCN), a = new W(B.File, i.ownerInfo, await this._euSign.CtxGetOwnCertificates(i), e, t);
10860
10862
  return a.context = r, a.keyContext = i, a._glSign = this._glSign, a;
@@ -10876,7 +10878,7 @@ var J = class {
10876
10878
  }
10877
10879
  }
10878
10880
  async ctxFreePrivateKey(e) {
10879
- e instanceof G ? await this.setLibraryType(B.Token) : await this.setLibraryType(B.File), await this._euSign.CtxFreePrivateKey(e.keyContext), await this._euSign.CtxFree(e.context);
10881
+ e.keyType === B.Token ? await this.setLibraryType(B.Token) : await this.setLibraryType(B.File), await this._euSign.CtxFreePrivateKey(e.keyContext), await this._euSign.CtxFree(e.context);
10880
10882
  }
10881
10883
  async getPrivateKeyInfoFromStorage(e, t) {
10882
10884
  let n = (e ? localStorage : sessionStorage)[this._userId + Z], r, i = [];