@it-enterprise/digital-signature 1.4.6 → 1.4.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
CHANGED
package/src/DigitalSignature.js
CHANGED
|
@@ -81,9 +81,8 @@ export default class DigitalSignature {
|
|
|
81
81
|
if (type != null && type != undefined) {
|
|
82
82
|
this._preferredKeyType = type;
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
await this.initialise();
|
|
86
84
|
this.keyType = type;
|
|
85
|
+
await this.initialise();
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
/**
|
|
@@ -321,7 +320,7 @@ export default class DigitalSignature {
|
|
|
321
320
|
case DigitalSignatureKeyType.Token:
|
|
322
321
|
return await this.readHardwareKey(keyInfo.keyMedia, keyInfo.certificates);
|
|
323
322
|
case DigitalSignatureKeyType.KSP:
|
|
324
|
-
return await this.readPrivateKeyKSP(keyInfo.ksp, keyInfo.
|
|
323
|
+
return await this.readPrivateKeyKSP(keyInfo.ksp, keyInfo.userId, false, keyInfo.keyId);
|
|
325
324
|
case DigitalSignatureKeyType.UmCAService:
|
|
326
325
|
return await this.readPrivateKeyUmCAService(keyInfo.keyMedia);
|
|
327
326
|
case DigitalSignatureKeyType.WindowsCertStore:
|
|
@@ -515,16 +514,26 @@ export default class DigitalSignature {
|
|
|
515
514
|
* @param {boolean?} getCerts - Получать информацию о ключе пользователя. Это приведёт к дополнительному запросу на подписание
|
|
516
515
|
* @param {string?} keyId Идентификатор ключа
|
|
517
516
|
* @param {KSPPrivateKeyAuthData?} authData Параметры авторизации ключа
|
|
517
|
+
* @param {Array<Uint8Array|File>?} certs - Сертификаты ключа (при необходимости)
|
|
518
518
|
*/
|
|
519
|
-
async readPrivateKeyKSP(ksp, userId, getCerts = false, keyId, authData) {
|
|
519
|
+
async readPrivateKeyKSP(ksp, userId, getCerts = false, keyId, authData, certs) {
|
|
520
520
|
await this.setLibraryType(DigitalSignatureKeyType.KSP);
|
|
521
521
|
|
|
522
522
|
if (ksp.ksp === EndUserConstants.EU_KSP_DIIA) {
|
|
523
523
|
await this._diiaCheckAccess(ksp);
|
|
524
524
|
}
|
|
525
525
|
|
|
526
|
-
|
|
527
|
-
|
|
526
|
+
if (Array.isArray(certs) && certs.length > 0) {
|
|
527
|
+
certs = await Promise.all(certs.map(cert =>
|
|
528
|
+
cert instanceof File || cert instanceof Blob? readFile(cert)
|
|
529
|
+
: cert instanceof EndUserCertificate ? cert.data
|
|
530
|
+
: cert));
|
|
531
|
+
} else {
|
|
532
|
+
certs = null;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const ownerInfo = await this._euSign.ReadPrivateKeyKSP(userId, ksp.name, getCerts, keyId, null, authData, certs);
|
|
536
|
+
if ((getCerts || certs) && !ownerInfo) {
|
|
528
537
|
throw {
|
|
529
538
|
code: EndUserError.EU_ERROR_KEY_MEDIAS_READ_FAILED,
|
|
530
539
|
message: this._resourses.PrivateKeyNotReaded
|
|
@@ -533,7 +542,7 @@ export default class DigitalSignature {
|
|
|
533
542
|
this._readedKey = new KspPrivateKeyInfo(
|
|
534
543
|
DigitalSignatureKeyType.KSP,
|
|
535
544
|
ownerInfo,
|
|
536
|
-
getCerts ? await this._euSign.GetOwnCertificates() : [],
|
|
545
|
+
(getCerts || certs) ? await this._euSign.GetOwnCertificates() : [],
|
|
537
546
|
userId,
|
|
538
547
|
ksp,
|
|
539
548
|
keyId
|