@it-enterprise/digital-signature 1.4.1 → 1.4.3

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.
@@ -163,9 +163,9 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
163
163
  }), n.d(t, "EndUserKeysType", function() {
164
164
  return K;
165
165
  }), n.d(t, "EU_KEYS_LENGTH_DS_UA_191", function() {
166
- return re;
167
- }), n.d(t, "EU_KEYS_LENGTH_DS_UA_257", function() {
168
166
  return ie;
167
+ }), n.d(t, "EU_KEYS_LENGTH_DS_UA_257", function() {
168
+ return Y;
169
169
  }), n.d(t, "EU_KEYS_LENGTH_DS_UA_307", function() {
170
170
  return X;
171
171
  }), n.d(t, "EU_KEYS_LENGTH_DS_UA_FILE", function() {
@@ -173,7 +173,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
173
173
  }), n.d(t, "EU_KEYS_LENGTH_DS_UA_CERT", function() {
174
174
  return Q;
175
175
  }), n.d(t, "EndUserKeysLengthDSUA", function() {
176
- return Y;
176
+ return re;
177
177
  }), n.d(t, "EU_KEYS_LENGTH_KEP_UA_257", function() {
178
178
  return ae;
179
179
  }), n.d(t, "EU_KEYS_LENGTH_KEP_UA_431", function() {
@@ -415,10 +415,10 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
415
415
  (function(e) {
416
416
  e[e.None = q] = "None", e[e.DSTUAndECDHWithGOST = J] = "DSTUAndECDHWithGOST", e[e.RSAWithSHA = ee] = "RSAWithSHA", e[e.ECDSAWithSHA = te] = "ECDSAWithSHA", e[e.DSTUAndECDHWithDSTU = ne] = "DSTUAndECDHWithDSTU";
417
417
  })(K ||= {});
418
- var Y, re = 1, ie = 2, X = 3, Z = 4, Q = 5;
418
+ var re, ie = 1, Y = 2, X = 3, Z = 4, Q = 5;
419
419
  (function(e) {
420
- e[e.EC_191 = re] = "EC_191", e[e.EC_257 = ie] = "EC_257", e[e.EC_307 = X] = "EC_307", e[e.File = Z] = "File", e[e.Cert = Q] = "Cert";
421
- })(Y ||= {});
420
+ e[e.EC_191 = ie] = "EC_191", e[e.EC_257 = Y] = "EC_257", e[e.EC_307 = X] = "EC_307", e[e.File = Z] = "File", e[e.Cert = Q] = "Cert";
421
+ })(re ||= {});
422
422
  var $, ae = 1, oe = 2, se = 3, ce = 4, le = 5;
423
423
  (function(e) {
424
424
  e[e.EC_257 = ae] = "EC_257", e[e.EC_431 = oe] = "EC_431", e[e.EC_571 = se] = "EC_571", e[e.File = Z] = "File", e[e.Cert = Q] = "Cert";
@@ -2962,22 +2962,22 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
2962
2962
  }, ne.prototype.GetOwnerInfo = function() {
2963
2963
  return this.ownerInfo;
2964
2964
  };
2965
- var Y = function(e, t) {
2965
+ var re = function(e, t) {
2966
2966
  this.setClassInfo("EndUserReference", 1), this.fields = {
2967
2967
  name: "string",
2968
2968
  data: "byteArray"
2969
2969
  }, this.initializeFields(), this.name = e, this.data = t;
2970
2970
  };
2971
- h.makeTransferable(Y), Y.prototype.GetName = function() {
2971
+ h.makeTransferable(re), re.prototype.GetName = function() {
2972
2972
  return this.name;
2973
- }, Y.prototype.SetName = function(e) {
2973
+ }, re.prototype.SetName = function(e) {
2974
2974
  this.name = e;
2975
- }, Y.prototype.GetData = function() {
2975
+ }, re.prototype.GetData = function() {
2976
2976
  return this.data;
2977
- }, Y.prototype.SetData = function(e) {
2977
+ }, re.prototype.SetData = function(e) {
2978
2978
  this.data = e;
2979
2979
  };
2980
- var re = function(e, t, n, r, i) {
2980
+ var ie = function(e, t, n, r, i) {
2981
2981
  this.setClassInfo("EndUserSSSignHashResult", 1), this.fields = {
2982
2982
  error: "number",
2983
2983
  hash: "string",
@@ -2986,33 +2986,33 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
2986
2986
  status: "string"
2987
2987
  }, this.initializeFields(), this.error = e, this.hash = t, this.signature = n, this.statusCode = r, this.status = i;
2988
2988
  };
2989
- h.makeTransferable(re), re.prototype.GetError = function() {
2989
+ h.makeTransferable(ie), ie.prototype.GetError = function() {
2990
2990
  return this.error;
2991
- }, re.prototype.GetHash = function() {
2991
+ }, ie.prototype.GetHash = function() {
2992
2992
  return this.hash;
2993
- }, re.prototype.GetSignature = function() {
2993
+ }, ie.prototype.GetSignature = function() {
2994
2994
  return this.signature;
2995
- }, re.prototype.GetStatusCode = function() {
2995
+ }, ie.prototype.GetStatusCode = function() {
2996
2996
  return this.statusCode;
2997
- }, re.prototype.GetStatus = function() {
2997
+ }, ie.prototype.GetStatus = function() {
2998
2998
  return this.status;
2999
2999
  };
3000
- var ie = function() {
3000
+ var Y = function() {
3001
3001
  this.setClassInfo("EndUserMakeCertificateResult", 1), this.fields = {
3002
3002
  privateKey: "byteArray",
3003
3003
  certificates: "array",
3004
3004
  cmpRequest: "byteArray"
3005
3005
  }, this.initializeFields();
3006
3006
  };
3007
- h.makeTransferable(ie), ie.prototype.GetPrivateKey = function() {
3007
+ h.makeTransferable(Y), Y.prototype.GetPrivateKey = function() {
3008
3008
  return this.privateKey;
3009
- }, ie.prototype.GetCertificate = function(e) {
3009
+ }, Y.prototype.GetCertificate = function(e) {
3010
3010
  return e < 0 || e >= this.certificates.length ? null : this.certificates[e];
3011
- }, ie.prototype.GetCertificatesCount = function() {
3011
+ }, Y.prototype.GetCertificatesCount = function() {
3012
3012
  return this.certificates.length;
3013
- }, ie.prototype.GetCertificates = function() {
3013
+ }, Y.prototype.GetCertificates = function() {
3014
3014
  return this.certificates;
3015
- }, ie.prototype.GetCMPRequest = function() {
3015
+ }, Y.prototype.GetCMPRequest = function() {
3016
3016
  return this.cmpRequest;
3017
3017
  };
3018
3018
  var X = function() {
@@ -5225,7 +5225,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
5225
5225
  n
5226
5226
  ]), this._funcCall("CtxSetParameter", a, r, i, null);
5227
5227
  }, $.prototype.CreateReference = function(e, t) {
5228
- return new Y(e, t);
5228
+ return new re(e, t);
5229
5229
  }, $.prototype.ASiCGetASiCType = function(e, t, n) {
5230
5230
  var r;
5231
5231
  if (typeof e != "string" || (e = this._base64Decode(e, n)) != null) return r = this._funcMakeParams([new g(e)]), this._funcCall("ASiCGetASiCType", r, t, n, null);
@@ -9818,7 +9818,7 @@ var k = () => Date.now() >= new Date(2026, 6, 1), A = class {
9818
9818
  LegacyCertificatesProvider: () => R,
9819
9819
  LegacySettingsProvider: () => F,
9820
9820
  PrivateKeyInfo: () => U,
9821
- ProtectTaxReportParams: () => Y,
9821
+ ProtectTaxReportParams: () => re,
9822
9822
  WebserviceSettingProvider: () => P,
9823
9823
  getDefaultKSPs: () => q
9824
9824
  }), M = class {
@@ -10093,11 +10093,11 @@ var J = class {
10093
10093
  constructor(e, t, n) {
10094
10094
  this.pin = e, this.token = t, this.twoFactorCode = n;
10095
10095
  }
10096
- }, Y = class {
10096
+ }, re = class {
10097
10097
  constructor(e, t, n, r, i, a, o) {
10098
10098
  this.accountantPrivateKeyContext = e, this.directorPrivateKeyContext = t, this.stampPrivateKeyContext = n, this.senderEMail = r, this.recipientCertificate = i, this.reports = a, this.returnIntermediateSign = o;
10099
10099
  }
10100
- }, re = class {
10100
+ }, ie = class {
10101
10101
  constructor(e) {
10102
10102
  e ||= "25989", typeof e != "string" && (e = String(e)), this.baseUrl = `https://localhost:${e.trim()}/`;
10103
10103
  }
@@ -10128,12 +10128,19 @@ var J = class {
10128
10128
  };
10129
10129
  });
10130
10130
  }
10131
- async signData(e, t, n) {
10132
- let r;
10133
- n.type === f.EndUserConstants.EU_SIGN_CONTAINER_TYPE_PADES ? r = "pdf-attached" : (r = n.signLevel >= f.EndUserConstants.EU_SIGN_TYPE_CADES_C ? "cades-x-ts-signtime-ocsp-stdua" : "cms-ts-signtime", n.subType === f.EndUserConstants.EU_CADES_TYPE_ENVELOPED && (r += "-attached"));
10134
- let i = !0;
10135
- Array.isArray(t) || (i = !1, t = [t]);
10136
- let a = [];
10131
+ async signData(e, t, n, r) {
10132
+ let i;
10133
+ n.type === f.EndUserConstants.EU_SIGN_CONTAINER_TYPE_PADES ? i = "pdf-attached" : (i = n.signLevel >= f.EndUserConstants.EU_SIGN_TYPE_CADES_C ? "cades-x-ts-signtime-ocsp-stdua" : "cms-ts-signtime", n.subType === f.EndUserConstants.EU_CADES_TYPE_ENVELOPED && (i += "-attached"));
10134
+ let a = !0;
10135
+ Array.isArray(data) ? data = [...data] : (a = !1, data = [data]);
10136
+ for (let e = 0; e < data.length; e++) {
10137
+ let t = data[e];
10138
+ t.val ? data[e] = {
10139
+ name: t.name,
10140
+ val: Y(t.val, !0)
10141
+ } : data[e] = Y(t, !0);
10142
+ }
10143
+ let o = [];
10137
10144
  for (let n of t) {
10138
10145
  let t = new Request(this.baseUrl + "sign", {
10139
10146
  method: "POST",
@@ -10142,28 +10149,35 @@ var J = class {
10142
10149
  Data: n.val ? n.val : n,
10143
10150
  Certificate: e.certificates[0],
10144
10151
  Pin: e.password,
10145
- SigType: r,
10152
+ SigType: i,
10146
10153
  AsBlob: !1,
10147
10154
  AsResource: !1,
10148
10155
  DataAsLink: !1
10149
10156
  })
10150
- }), i = await fetch(t);
10151
- if (!i.ok) {
10152
- let e = await i.json();
10157
+ }), r = await fetch(t);
10158
+ if (!r.ok) {
10159
+ let e = await r.json();
10153
10160
  throw {
10154
10161
  code: f.EndUserError.EU_ERROR_TRANSMIT_REQUEST,
10155
10162
  message: e.Message
10156
10163
  };
10157
10164
  }
10158
- let o = await i.json();
10159
- a.push(n.name ? {
10165
+ let a = await r.json();
10166
+ o.push(n.name ? {
10160
10167
  name: n.name,
10161
- val: o
10162
- } : o);
10168
+ val: a
10169
+ } : a);
10163
10170
  }
10164
- return i ? a : a[0];
10171
+ for (let e = 0; e < o.length; e++) {
10172
+ let t = o[e];
10173
+ t.val ? o[e] = {
10174
+ name: t.name,
10175
+ val: Y(t.val, !r)
10176
+ } : o[e] = Y(t, !r);
10177
+ }
10178
+ return a ? o : o[0];
10165
10179
  }
10166
- }, ie = {
10180
+ }, Y = (e, t) => t && typeof e != "string" ? _(e) : !t && typeof e == "string" ? v(e) : e, X = {
10167
10181
  uk: {
10168
10182
  LibraryNotSupported: "Бібліотека web-підпису не підтримується в вашому браузері або ОС.",
10169
10183
  LibraryNeedsInstall: "Бібліотека web-підпису не запущена або потребує встановлення. Будь ласка, запустіть або встановіть бібліотеку за посиланням та оновіть сторінку.",
@@ -10239,7 +10253,7 @@ var J = class {
10239
10253
  UmCAServiceConnectError: "Unable to connect to UmCAService. Check if the service is running. If using a non-standard port, specify it in the global parameter GlSign.",
10240
10254
  UmCAServiceWrongPassword: "Wrong password"
10241
10255
  }
10242
- }, X = "PKType", Z = "PKInfo", Q = class {
10256
+ }, Z = "PKType", Q = "PKInfo", $ = class {
10243
10257
  constructor(e) {
10244
10258
  this._settingsProvider = e, this._glSign = null, this._settings = null, this._euSignFile, this._euSignKeyMedia, this._euSign = null, this._selectedCA = null, this._KSPs = [], this._readedKey = null;
10245
10259
  }
@@ -10268,7 +10282,7 @@ var J = class {
10268
10282
  e != null && e != null && (this._preferredKeyType = e), await this.initialise(), this.keyType = e;
10269
10283
  }
10270
10284
  async initialise() {
10271
- if (this._glSign ||= await Promise.resolve(this._settingsProvider.getGlSign()), this._settings ||= await Promise.resolve(this._settingsProvider.getSettings(this._glSign.AllowTestKeys)), this._euSignFile ||= new f.EndUser(this._settings.libraryUrl, f.EndUserConstants.EndUserLibraryType.JS, this._glSign.WebClientFileSize), this._euSignKeyMedia ||= new f.EndUser(this._settings.libraryUrl, f.EndUserConstants.EndUserLibraryType.SW, this._glSign.WebClientFileSize), this._euSign || (this._euSign = this._glSign.PreferHarware ? this._euSignKeyMedia : this._euSignFile, this.keyType = this._glSign.PreferHarware ? B.Token : this._preferredKeyType), this.keyType === B.UmCAService && (this.UmCAService ||= new re(this.glSign.UmcaservicePort), !await this.UmCAService.tryConnect())) throw {
10285
+ if (this._glSign ||= await Promise.resolve(this._settingsProvider.getGlSign()), this._settings ||= await Promise.resolve(this._settingsProvider.getSettings(this._glSign.AllowTestKeys)), this._euSignFile ||= new f.EndUser(this._settings.libraryUrl, f.EndUserConstants.EndUserLibraryType.JS, this._glSign.WebClientFileSize), this._euSignKeyMedia ||= new f.EndUser(this._settings.libraryUrl, f.EndUserConstants.EndUserLibraryType.SW, this._glSign.WebClientFileSize), this._euSign || (this._euSign = this._glSign.PreferHarware ? this._euSignKeyMedia : this._euSignFile, this.keyType = this._glSign.PreferHarware ? B.Token : this._preferredKeyType), this.keyType === B.UmCAService && (this.UmCAService ||= new ie(this.glSign.UmcaservicePort), !await this.UmCAService.tryConnect())) throw {
10272
10286
  code: f.EndUserError.EU_ERROR_LIBRARY_LOAD,
10273
10287
  message: this._resourses.UmCAServiceConnectError
10274
10288
  };
@@ -10523,8 +10537,10 @@ var J = class {
10523
10537
  return this._glSign.KSPs;
10524
10538
  }
10525
10539
  async isPrivateKeyReaded() {
10540
+ if (!this._readedKey) return !1;
10541
+ if (this._readedKey.keyType === B.WindowsCertStore || this._readedKey.keyType === B.UmCAService) return !0;
10526
10542
  try {
10527
- return !!this._readedKey && (this._readedKey.keyType == B.WindowsCertStore || this._readedKey.keyType == B.UmCAService || await this._euSign.IsPrivateKeyReaded());
10543
+ return await this._euSign.IsPrivateKeyReaded();
10528
10544
  } catch {
10529
10545
  return !1;
10530
10546
  }
@@ -10572,18 +10588,7 @@ var J = class {
10572
10588
  code: f.EndUserError.EU_ERROR_NOT_SUPPORTED,
10573
10589
  message: this._resourses.KSPSignFormatError
10574
10590
  };
10575
- let r = (e, t) => t && typeof e != "string" ? _(e) : !t && typeof e == "string" ? v(e) : e, i = !0;
10576
- Array.isArray(e) || (i = !1, e = [e]);
10577
- for (let t = 0; t < e.length; t++) {
10578
- let n = e[t];
10579
- n.val ? n.val = r(n.val, !0) : e[t] = r(n, !0);
10580
- }
10581
- let a = await this.UmCAService.signData(this._readedKey.keyMedia, e, t);
10582
- for (let e = 0; e < a.length; e++) {
10583
- let t = a[e];
10584
- t.val ? t.val = r(t.val, !n) : a[e] = r(t, !n);
10585
- }
10586
- return i ? a : a[0];
10591
+ return await this.UmCAService.signData(this._readedKey.keyMedia, e, t, n);
10587
10592
  }
10588
10593
  let r = this._readedKey.getSignAlgo();
10589
10594
  if (t.type === f.EndUserConstants.EndUserSignContainerType.ASiC) {
@@ -10826,9 +10831,9 @@ var J = class {
10826
10831
  code: f.EndUserError.EU_ERROR_BAD_PARAMETER,
10827
10832
  message: this._resourses.PasswordNotSet
10828
10833
  };
10829
- 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)));
10834
+ 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)));
10830
10835
  try {
10831
- 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);
10836
+ 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);
10832
10837
  return i.context = n, i.keyContext = r, i._glSign = this._glSign, i;
10833
10838
  } catch (e) {
10834
10839
  if (e && e.code === f.EndUserError.EU_ERROR_CERT_NOT_FOUND) {
@@ -10856,7 +10861,7 @@ var J = class {
10856
10861
  code: f.EndUserError.EU_ERROR_BAD_PARAMETER,
10857
10862
  message: this._resourses.PasswordNotSet
10858
10863
  };
10859
- (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)));
10864
+ (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)));
10860
10865
  try {
10861
10866
  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);
10862
10867
  return a.context = r, a.keyContext = i, a._glSign = this._glSign, a;
@@ -10878,10 +10883,10 @@ var J = class {
10878
10883
  }
10879
10884
  }
10880
10885
  async ctxFreePrivateKey(e) {
10881
- 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);
10886
+ 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);
10882
10887
  }
10883
10888
  async getPrivateKeyInfoFromStorage(e, t) {
10884
- let n = (e ? localStorage : sessionStorage)[this._userId + Z], r, i = [];
10889
+ let n = (e ? localStorage : sessionStorage)[this._userId + Q], r, i = [];
10885
10890
  if (!n) return i;
10886
10891
  let a = await this._euSignFile.UnprotectDataByPassword(n, "", !0);
10887
10892
  try {
@@ -10906,7 +10911,7 @@ var J = class {
10906
10911
  let r = await this.getPrivateKeyInfoFromStorage(t);
10907
10912
  r.push(e);
10908
10913
  let i = await this._euSignFile.ProtectDataByPassword(JSON.stringify(r), "", !0);
10909
- n[this._userId + Z] = i;
10914
+ n[this._userId + Q] = i;
10910
10915
  }
10911
10916
  }
10912
10917
  async getStoredPrivateKeyInfo(e) {
@@ -10914,25 +10919,25 @@ var J = class {
10914
10919
  return t.concat(n);
10915
10920
  }
10916
10921
  async removeStoredPrivateKeyInfo(e) {
10917
- if (e === void 0) localStorage.removeItem(this._userId + Z), sessionStorage.removeItem(this._userId + Z);
10922
+ if (e === void 0) localStorage.removeItem(this._userId + Q), sessionStorage.removeItem(this._userId + Q);
10918
10923
  else {
10919
10924
  let t = await this.getPrivateKeyInfoFromStorage(!0), n = await this.getPrivateKeyInfoFromStorage(!1), r = t.filter((t) => t.id == e).length > 0 ? localStorage : sessionStorage, i = r == localStorage ? t : n, a = i.findIndex((t) => t.id == e);
10920
10925
  if (a > -1) {
10921
10926
  i.splice(a, 1);
10922
10927
  let e = await this._euSignFile.ProtectDataByPassword(JSON.stringify(i), "", !0);
10923
- r[this._userId + Z] = e;
10928
+ r[this._userId + Q] = e;
10924
10929
  }
10925
10930
  }
10926
10931
  }
10927
10932
  get _preferredKeyType() {
10928
- let e = parseInt(localStorage[this._userId + X]);
10929
- return typeof e == "number" && e > -1 ? e : (localStorage[this._userId + X] = B.File, B.File);
10933
+ let e = parseInt(localStorage[this._userId + Z]);
10934
+ return typeof e == "number" && e > -1 ? e : (localStorage[this._userId + Z] = B.File, B.File);
10930
10935
  }
10931
10936
  set _preferredKeyType(e) {
10932
- typeof e == "number" && e > -1 && (localStorage[this._userId + X] = e);
10937
+ typeof e == "number" && e > -1 && (localStorage[this._userId + Z] = e);
10933
10938
  }
10934
10939
  get _resourses() {
10935
- return ie[this._language];
10940
+ return X[this._language];
10936
10941
  }
10937
10942
  get _userId() {
10938
10943
  return typeof this._settingsProvider.userId == "function" ? this._settingsProvider.userId() : this._settingsProvider.userId;
@@ -10964,6 +10969,6 @@ var J = class {
10964
10969
  }
10965
10970
  };
10966
10971
  //#endregion
10967
- export { Q as DigitalSignature, f as EUSignCP, A as GlSign, j as Models, d as Utils };
10972
+ export { $ as DigitalSignature, f as EUSignCP, A as GlSign, j as Models, d as Utils };
10968
10973
 
10969
10974
  //# sourceMappingURL=it-digital-signature.mjs.map