@it-enterprise/digital-signature 1.1.6 → 1.1.7
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 +1 -1
- package/src/DigitalSignature.js +54 -45
package/package.json
CHANGED
package/src/DigitalSignature.js
CHANGED
|
@@ -78,7 +78,6 @@ export default class DigitalSignature {
|
|
|
78
78
|
* @param {number} type
|
|
79
79
|
*/
|
|
80
80
|
async setLibraryType(type) {
|
|
81
|
-
|
|
82
81
|
if (this._euSign) {
|
|
83
82
|
await this._euSign.ResetPrivateKey();
|
|
84
83
|
}
|
|
@@ -92,7 +91,9 @@ export default class DigitalSignature {
|
|
|
92
91
|
break;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
|
|
94
|
+
if (type != null && type != undefined) {
|
|
95
|
+
this._preferredKeyType = type;
|
|
96
|
+
}
|
|
96
97
|
|
|
97
98
|
await this.initialise();
|
|
98
99
|
this.keyType = type;
|
|
@@ -185,38 +186,43 @@ export default class DigitalSignature {
|
|
|
185
186
|
return this.getLibraryType();
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
189
|
+
if (!this._euSettings) {
|
|
190
|
+
const certificates = await this._settings.certificatesProvider.loadCertificates();
|
|
191
|
+
|
|
192
|
+
this._euSettings = {
|
|
193
|
+
language: this._settings.language,
|
|
194
|
+
encoding: "UTF-16LE",
|
|
195
|
+
httpProxyServiceURL: this._settings.httpProxyServiceURL,
|
|
196
|
+
directAccess: true,
|
|
197
|
+
CAs: certificates.CAs,
|
|
198
|
+
CACertificates: certificates.CACertificates,
|
|
199
|
+
mssServiceURL: this._settings.mssServiceURL,
|
|
200
|
+
KSPs: this._KSPs,
|
|
201
|
+
allowedKeyMediaTypes: [
|
|
202
|
+
"е.ключ BIFIT iToken",
|
|
203
|
+
"криптомод. ІІТ Гряда-61",
|
|
204
|
+
"криптомод. ІІТ Гряда-301",
|
|
205
|
+
"е.ключ ІІТ Алмаз-1К",
|
|
206
|
+
"е.ключ ІІТ Кристал-1",
|
|
207
|
+
"ID-карта громадянина (БЕН)",
|
|
208
|
+
"е.ключ ІІТ Алмаз-1К (PKCS#11)",
|
|
209
|
+
"е.ключ ІІТ Кристал-1 (PKCS#11)",
|
|
210
|
+
"е.ключ чи смарт-карта Avest (PKCS#11)",
|
|
211
|
+
"е.ключ Ефіт Key (PKCS#11)",
|
|
212
|
+
"е.ключ чи смарт-карта Автор (PKCS#11)",
|
|
213
|
+
"е.ключ чи смарт-карта Автор 338 (PKCS#11)",
|
|
214
|
+
"смарт-карта Техноконс. TEllipse3 (PKCS#11)",
|
|
215
|
+
"смарт-карта Техноконс. TEllipse",
|
|
216
|
+
"смарт-карта Техноконс. TEllipse2/3",
|
|
217
|
+
"е.ключ SafeNet iKey (PKCS#11, RSA)"
|
|
218
|
+
]
|
|
219
|
+
};
|
|
220
|
+
}
|
|
218
221
|
|
|
219
|
-
await euSign.Initialize(
|
|
222
|
+
await euSign.Initialize(this._euSettings);
|
|
223
|
+
if (euSign === this._euSignKeyMedia && !await this._euSignFile.IsInitialized()) {
|
|
224
|
+
this._euSignFile.Initialize(this._euSettings);
|
|
225
|
+
}
|
|
220
226
|
if (this._glSign.ApplyProxySettings) {
|
|
221
227
|
const { UseProxy, ProxyAddress, ProxyPort, ProxyUser, ProxyPassword } = this._glSign;
|
|
222
228
|
const proxy = new EndUserProxySettings();
|
|
@@ -228,10 +234,15 @@ export default class DigitalSignature {
|
|
|
228
234
|
proxy.password = ProxyPassword;
|
|
229
235
|
proxy.savePassword = true;
|
|
230
236
|
await euSign.SetProxySettings(proxy);
|
|
237
|
+
if (euSign === this._euSignKeyMedia && !await this._euSignFile.IsInitialized()) {
|
|
238
|
+
this._euSignFile.SetProxySettings(proxy);
|
|
239
|
+
}
|
|
231
240
|
}
|
|
232
241
|
|
|
233
242
|
await euSign.SetRuntimeParameter(EndUserConstants.EU_SIGN_TYPE_PARAMETER, EndUserConstants.EndUserSignType.CAdES_X_Long);
|
|
234
|
-
|
|
243
|
+
if (euSign === this._euSignKeyMedia && !await this._euSignFile.IsInitialized()) {
|
|
244
|
+
this._euSignFile.SetRuntimeParameter(EndUserConstants.EU_SIGN_TYPE_PARAMETER, EndUserConstants.EndUserSignType.CAdES_X_Long);
|
|
245
|
+
}
|
|
235
246
|
return this.getLibraryType();
|
|
236
247
|
}
|
|
237
248
|
|
|
@@ -329,7 +340,7 @@ export default class DigitalSignature {
|
|
|
329
340
|
}
|
|
330
341
|
|
|
331
342
|
/**
|
|
332
|
-
* Считать ключ с
|
|
343
|
+
* Считать ключ с DepositSign
|
|
333
344
|
* @param {string} userId - Идентификатор пользователя
|
|
334
345
|
* @param {boolean?} getCerts - Получать информацию о ключе пользователя. Это приведёт к дополнительному запросу на подписание
|
|
335
346
|
*/
|
|
@@ -345,7 +356,7 @@ export default class DigitalSignature {
|
|
|
345
356
|
const diia = "DIIA";
|
|
346
357
|
if (sessionStorage[diia] != "+") {
|
|
347
358
|
try {
|
|
348
|
-
sessionStorage[diia] = await downloadData(
|
|
359
|
+
sessionStorage[diia] = await downloadData(new URL(this.KSPs[1].address).origin + "/diia");
|
|
349
360
|
} catch {
|
|
350
361
|
throw {
|
|
351
362
|
message: this._resourses.DiiaError + `<a target="_blank" href="${window.origin}">${window.origin}</a></li><ul>`
|
|
@@ -361,14 +372,16 @@ export default class DigitalSignature {
|
|
|
361
372
|
* @param {string} userId - Идентификатор пользователя
|
|
362
373
|
* @param {string|KSPSettings} ksp - Идентификатор облачного провайдера
|
|
363
374
|
* @param {boolean?} getCerts - Получать информацию о ключе пользователя. Это приведёт к дополнительному запросу на подписание
|
|
375
|
+
* @param {number?} keyType - Тип ключа
|
|
364
376
|
*/
|
|
365
377
|
async readPrivateKeyKSP(userId, ksp, getCerts = false) {
|
|
366
|
-
if (this._euSign != this._euSignFile) {
|
|
367
|
-
await this.setLibraryType(DigitalSignatureKeyType.KSP);
|
|
368
|
-
}
|
|
369
378
|
if (ksp != EndUserConstants.EndUserKSP.DIIA && typeof ksp !== "string") {
|
|
370
379
|
ksp = ksp.name;
|
|
371
380
|
}
|
|
381
|
+
const keyType = ksp == "DepositSign" ? DigitalSignatureKeyType.Depositsign : ksp == "diia" ? DigitalSignatureKeyType.Diia : DigitalSignatureKeyType.KSP;
|
|
382
|
+
if (this._euSign != this._euSignFile) {
|
|
383
|
+
await this.setLibraryType(keyType);
|
|
384
|
+
}
|
|
372
385
|
const ownerInfo = await this._euSign.ReadPrivateKeyKSP(userId, ksp, getCerts);
|
|
373
386
|
if (getCerts && !ownerInfo) {
|
|
374
387
|
throw {
|
|
@@ -376,7 +389,7 @@ export default class DigitalSignature {
|
|
|
376
389
|
};
|
|
377
390
|
}
|
|
378
391
|
this._readedKey = new KspPrivateKeyInfo(
|
|
379
|
-
|
|
392
|
+
keyType,
|
|
380
393
|
ownerInfo,
|
|
381
394
|
getCerts ? await this._euSign.GetOwnCertificates() : [],
|
|
382
395
|
userId,
|
|
@@ -395,11 +408,7 @@ export default class DigitalSignature {
|
|
|
395
408
|
* @param {authenticationCallback} event - Коллбэк. Вызывается при запросе на подписание.
|
|
396
409
|
*/
|
|
397
410
|
async addConfirmKSPOperationEventListener(event) {
|
|
398
|
-
|
|
399
|
-
await this.setLibraryType(DigitalSignatureKeyType.KSP);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
await this._euSign.AddEventListener(EndUserConstants.EndUserEventType.ConfirmKSPOperation, function(data) {
|
|
411
|
+
await this._euSignFile.AddEventListener(EndUserConstants.EndUserEventType.ConfirmKSPOperation, function(data) {
|
|
403
412
|
data.qrCode = "data:image/bmp;base64," + data.qrCode;
|
|
404
413
|
event(data);
|
|
405
414
|
});
|