myrtex-mf-signer 1.1.0

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.
Files changed (60) hide show
  1. package/README.md +35 -0
  2. package/esm2020/lib/components/certificate-select/certificate-select.component.mjs +22 -0
  3. package/esm2020/lib/components/sign-modal/sign-modal.component.mjs +148 -0
  4. package/esm2020/lib/models/certificate.model.mjs +2 -0
  5. package/esm2020/lib/models/index.mjs +5 -0
  6. package/esm2020/lib/models/internal/verify.cert.model.mjs +2 -0
  7. package/esm2020/lib/models/internal/verify.cert.response.model.mjs +2 -0
  8. package/esm2020/lib/models/sign-request.model.mjs +2 -0
  9. package/esm2020/lib/models/sign-validate-response.model.mjs +2 -0
  10. package/esm2020/lib/models/signed-result.model.mjs +2 -0
  11. package/esm2020/lib/myrtex-signer.module.mjs +75 -0
  12. package/esm2020/lib/providers/crypto.provider.mjs +99 -0
  13. package/esm2020/lib/providers/cryptojinn.provider.mjs +47 -0
  14. package/esm2020/lib/providers/cryptots.provider.mjs +56 -0
  15. package/esm2020/lib/providers/empty.provider.mjs +19 -0
  16. package/esm2020/lib/providers/interfaces/isign.provider.mjs +2 -0
  17. package/esm2020/lib/providers/signprovider.factory.mjs +35 -0
  18. package/esm2020/lib/services/certificate.adjuster.mjs +66 -0
  19. package/esm2020/lib/services/crypto.api.service.mjs +28 -0
  20. package/esm2020/lib/services/crypto.base.service.mjs +15 -0
  21. package/esm2020/lib/services/crypto.service.mjs +116 -0
  22. package/esm2020/lib/services/cryptopro/crypto.pro.async.service.mjs +30 -0
  23. package/esm2020/lib/services/cryptopro/crypto.pro.base.service.mjs +47 -0
  24. package/esm2020/lib/services/cryptopro/crypto.pro.ts.service.mjs +50 -0
  25. package/esm2020/lib/services/download.service.mjs +36 -0
  26. package/esm2020/lib/services/public.sign.service.mjs +44 -0
  27. package/esm2020/myrtex-mf-signer.mjs +5 -0
  28. package/esm2020/public-api.mjs +12 -0
  29. package/fesm2015/myrtex-mf-signer.mjs +895 -0
  30. package/fesm2015/myrtex-mf-signer.mjs.map +1 -0
  31. package/fesm2020/myrtex-mf-signer.mjs +871 -0
  32. package/fesm2020/myrtex-mf-signer.mjs.map +1 -0
  33. package/lib/components/certificate-select/certificate-select.component.d.ts +16 -0
  34. package/lib/components/sign-modal/sign-modal.component.d.ts +46 -0
  35. package/lib/models/certificate.model.d.ts +18 -0
  36. package/lib/models/index.d.ts +4 -0
  37. package/lib/models/internal/verify.cert.model.d.ts +5 -0
  38. package/lib/models/internal/verify.cert.response.model.d.ts +4 -0
  39. package/lib/models/sign-request.model.d.ts +17 -0
  40. package/lib/models/sign-validate-response.model.d.ts +4 -0
  41. package/lib/models/signed-result.model.d.ts +23 -0
  42. package/lib/myrtex-signer.module.d.ts +13 -0
  43. package/lib/providers/crypto.provider.d.ts +17 -0
  44. package/lib/providers/cryptojinn.provider.d.ts +15 -0
  45. package/lib/providers/cryptots.provider.d.ts +15 -0
  46. package/lib/providers/empty.provider.d.ts +8 -0
  47. package/lib/providers/interfaces/isign.provider.d.ts +4 -0
  48. package/lib/providers/signprovider.factory.d.ts +17 -0
  49. package/lib/services/certificate.adjuster.d.ts +15 -0
  50. package/lib/services/crypto.api.service.d.ts +19 -0
  51. package/lib/services/crypto.base.service.d.ts +6 -0
  52. package/lib/services/crypto.service.d.ts +27 -0
  53. package/lib/services/cryptopro/crypto.pro.async.service.d.ts +7 -0
  54. package/lib/services/cryptopro/crypto.pro.base.service.d.ts +13 -0
  55. package/lib/services/cryptopro/crypto.pro.ts.service.d.ts +8 -0
  56. package/lib/services/download.service.d.ts +15 -0
  57. package/lib/services/public.sign.service.d.ts +12 -0
  58. package/myrtex-mf-signer.d.ts +5 -0
  59. package/package.json +39 -0
  60. package/public-api.d.ts +4 -0
@@ -0,0 +1,895 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Component, Injectable, NgModule } from '@angular/core';
3
+ import * as i3 from 'myrtex-ui-composite';
4
+ import { EndpointBaseService, DialogColor, DialogType, Utilities, MyrtexUiCompositeModule } from 'myrtex-ui-composite';
5
+ import * as i1$2 from 'ngx-simple-modal';
6
+ import { SimpleModalComponent } from 'ngx-simple-modal';
7
+ import { Base64 } from 'js-base64';
8
+ import { __awaiter } from 'tslib';
9
+ import getCadesplugin from 'async-cadesplugin';
10
+ import * as i1 from '@angular/common';
11
+ import { CommonModule } from '@angular/common';
12
+ import * as i1$1 from '@angular/common/http';
13
+ import { HttpHeaders, HttpClientModule } from '@angular/common/http';
14
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
15
+ import { NgSelectModule } from '@ng-select/ng-select';
16
+
17
+ class CryptoBaseService {
18
+ constructor() {
19
+ this.available = false;
20
+ this.options = {};
21
+ }
22
+ init() {
23
+ return Promise.reject('Not implemented');
24
+ }
25
+ ;
26
+ auth() {
27
+ return Promise.resolve(true);
28
+ }
29
+ ;
30
+ }
31
+
32
+ class CertificateAdjuster {
33
+ extract(s, name) {
34
+ if (typeof (name) === 'string') {
35
+ name = [name];
36
+ }
37
+ for (var i = 0; i < name.length; i++) {
38
+ var n = name[i];
39
+ var re = new RegExp(n + '\s*=\s*\"?([^,\\/\"]+)');
40
+ var matches = s.match(re);
41
+ if (matches && matches.length > 1) {
42
+ return matches[1].trim();
43
+ }
44
+ }
45
+ return '';
46
+ }
47
+ ;
48
+ Print2Digit(digit) {
49
+ return (digit < 10) ? '0' + digit : digit;
50
+ }
51
+ ;
52
+ GetCertDate(paramDate) {
53
+ let certDate = new Date(paramDate);
54
+ return this.Print2Digit(certDate.getUTCDate()) + '.' + this.Print2Digit(certDate.getMonth() + 1) +
55
+ '.' + certDate.getFullYear() + ' ' +
56
+ this.Print2Digit(certDate.getUTCHours()) + ':' + this.Print2Digit(certDate.getUTCMinutes()) +
57
+ ':' + this.Print2Digit(certDate.getUTCSeconds());
58
+ }
59
+ ;
60
+ GetCertFio(certSubjectName) {
61
+ const lastName = this.extract(certSubjectName, 'SN');
62
+ const name = this.extract(certSubjectName, 'G');
63
+ return lastName + ' ' + name;
64
+ }
65
+ ;
66
+ GetCertPost(certSubjectName) {
67
+ return this.extract(certSubjectName, 'T');
68
+ }
69
+ ;
70
+ GetCertOgrn(certSubjectName) {
71
+ return this.extract(certSubjectName, ['OGRN', 'ОГРН', '1.2.643.100.1']);
72
+ }
73
+ ;
74
+ GetCertOrg(certSubjectName) {
75
+ return this.extract(certSubjectName, 'O');
76
+ }
77
+ ;
78
+ GetCertInn(certSubjectName) {
79
+ return this.extract(certSubjectName, ['INN', 'ИНН', '1.2.643.3.131.1.1']);
80
+ }
81
+ ;
82
+ GetCertName(certSubjectName) {
83
+ return this.extract(certSubjectName, 'CN');
84
+ }
85
+ ;
86
+ GetIssuer(certIssuerName) {
87
+ return this.extract(certIssuerName, 'CN');
88
+ }
89
+ ;
90
+ GetCertInfoString(certSubjectName, certFromDate) {
91
+ return this.extract(certSubjectName, 'CN') + '; Выдан: ' + this.GetCertDate(certFromDate);
92
+ }
93
+ ;
94
+ }
95
+ const instance = new CertificateAdjuster();
96
+
97
+ class CryptoProBaseService extends CryptoBaseService {
98
+ constructor() {
99
+ super();
100
+ }
101
+ init() {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ yield getCadesplugin();
104
+ return Promise.resolve(this);
105
+ });
106
+ }
107
+ ;
108
+ getCertificates() {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const store = yield window.cadesplugin.CreateObjectAsync("CAdESCOM.Store" /* Store */);
111
+ yield store.Open(2 /* CAPICOM_CURRENT_USER_STORE */, "My" /* CAPICOM_MY_STORE */, 2 /* CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED */);
112
+ let storeCerts = yield store.Certificates;
113
+ let count = yield storeCerts.Count;
114
+ let certificates = [];
115
+ for (let i = 1; i <= count; i++) {
116
+ let cert = yield storeCerts.Item(i);
117
+ let validFromDate = new Date(yield cert.ValidFromDate);
118
+ let validToDate = new Date(yield cert.ValidToDate);
119
+ const subjectName = yield cert.SubjectName;
120
+ certificates.push({
121
+ id: i,
122
+ certificate: cert,
123
+ subjectName: subjectName,
124
+ name: instance.GetCertInfoString(subjectName, validFromDate),
125
+ cn: instance.GetCertName(subjectName),
126
+ fio: instance.GetCertFio(subjectName),
127
+ post: instance.GetCertPost(subjectName),
128
+ ogrn: instance.GetCertOgrn(subjectName),
129
+ organization: instance.GetCertOrg(subjectName),
130
+ inn: instance.GetCertInn(subjectName),
131
+ validFromDate: validFromDate.toLocaleDateString('ru-RU'),
132
+ validToDate: validToDate.toLocaleDateString('ru-RU'),
133
+ thumbprint: yield cert.Thumbprint,
134
+ issuerName: yield cert.IssuerName,
135
+ serialNumber: yield cert.SerialNumber,
136
+ isExpired: validToDate < new Date()
137
+ });
138
+ }
139
+ yield store.Close();
140
+ return certificates;
141
+ });
142
+ }
143
+ }
144
+
145
+ class CryptoProAsyncService extends CryptoProBaseService {
146
+ constructor() {
147
+ super();
148
+ }
149
+ signXml(certificate, data) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ let signer = yield window.cadesplugin.CreateObjectAsync("CAdESCOM.CPSigner" /* CPSigner */);
152
+ yield signer.propset_Certificate(certificate);
153
+ let timestamp_service_url = 'http://testca.cryptopro.ru/tsp/tsp.srf';
154
+ yield signer.propset_TSAAddress(timestamp_service_url);
155
+ let signed = yield window.cadesplugin.CreateObjectAsync("CAdESCOM.SignedXML" /* SignedXML */);
156
+ let encodedXml = btoa(unescape(encodeURIComponent(data)));
157
+ yield signed.propset_Content(encodedXml);
158
+ let cades_xml_signature_type_enveloped = 80;
159
+ yield signed.propset_SignatureType(cades_xml_signature_type_enveloped);
160
+ const signedData = yield signed.Sign(signer);
161
+ return signedData;
162
+ });
163
+ }
164
+ signBase64(certificate, data, detached = false) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ let signer = yield window.cadesplugin.CreateObjectAsync("CAdESCOM.CPSigner" /* CPSigner */);
167
+ yield signer.propset_Certificate(certificate);
168
+ let signed = yield window.cadesplugin.CreateObjectAsync("CAdESCOM.CadesSignedData" /* CadesSignedData */);
169
+ yield signed.propset_ContentEncoding(1 /* CADESCOM_BASE64_TO_BINARY */);
170
+ yield signed.propset_Content(data);
171
+ const signedData = yield signed.SignCades(signer, 1 /* CADESCOM_CADES_BES */, detached);
172
+ return signedData;
173
+ });
174
+ }
175
+ }
176
+ CryptoProAsyncService.key = 'cryptoproasync';
177
+
178
+ class CertificateSelectComponent extends SimpleModalComponent {
179
+ constructor() {
180
+ super();
181
+ this.certificates = [];
182
+ this.result = {};
183
+ }
184
+ ok(cert) {
185
+ this.result = { selected: cert };
186
+ this.close();
187
+ }
188
+ }
189
+ CertificateSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CertificateSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
190
+ CertificateSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: CertificateSelectComponent, selector: "lib-certificate-select", usesInheritance: true, ngImport: i0, template: "<div class=\"modal-content open accent-head certificate\">\r\n <div class=\"modal-header\">\r\n <div class=\"modal-title\" [innerHTML]=\"'\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043A\u0430\u0442'\">\r\n </div>\r\n <span class='close close-click' (click)=\"close()\">\r\n <svg width='14' height='14' fill='none' xmlns='http://www.w3.org/2000/svg'>\r\n <path d='M13 1L1 13M1 1l12 12' stroke='#3A3A3A' stroke-width='1.5' stroke-linecap='round'\r\n stroke-linejoin='round' />\r\n </svg>\r\n </span>\r\n </div>\r\n <div class=\"modal-body text-center\">\r\n\r\n <div class=\"modal-body-other\">\r\n <div *ngFor=\"let cert of certificates\"> \r\n <div class=\"modal-body-info\" *ngIf=\"!cert.isExpired\">\r\n <div class=\"modal-body-info__item\">\r\n <span class=\"text\">\r\n \u0412\u043B\u0430\u0434\u0435\u043B\u0435\u0446:\r\n </span>\r\n <span class=\"text\">\r\n {{cert.cn}}<br/>\r\n {{cert.fio}}<span *ngIf=\"cert.post\">, {{cert.post}}</span>\r\n </span>\r\n </div>\r\n <div class=\"modal-body-info__item\">\r\n <span class=\"text\">\r\n \u0421\u0440\u043E\u043A \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044F:\r\n </span>\r\n <span class=\"text\">\r\n {{cert.validFromDate}} - {{cert.validToDate}}\r\n </span>\r\n </div>\r\n <div class=\"modal-body-info__item\">\r\n <span class=\"text hash\">\r\n {{cert.thumbprint}} {{cert.isExpired ? \"(\u0438\u0441\u0442\u0435\u043A)\" : \"\"}}\r\n </span>\r\n </div>\r\n <button\r\n (click)=\"ok(cert)\"\r\n [disabled]=\"cert.isExpired\"\r\n class=\"btn btn-md\">\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043F\u043E\u0434\u043F\u0438\u0441\u044C</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"modal-footer\">\r\n </div>\r\n</div>", styles: [":host{display:contents}:host textarea{width:100%;height:600px;border:0}\n"], directives: [{ type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
191
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CertificateSelectComponent, decorators: [{
192
+ type: Component,
193
+ args: [{ selector: 'lib-certificate-select', template: "<div class=\"modal-content open accent-head certificate\">\r\n <div class=\"modal-header\">\r\n <div class=\"modal-title\" [innerHTML]=\"'\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043A\u0430\u0442'\">\r\n </div>\r\n <span class='close close-click' (click)=\"close()\">\r\n <svg width='14' height='14' fill='none' xmlns='http://www.w3.org/2000/svg'>\r\n <path d='M13 1L1 13M1 1l12 12' stroke='#3A3A3A' stroke-width='1.5' stroke-linecap='round'\r\n stroke-linejoin='round' />\r\n </svg>\r\n </span>\r\n </div>\r\n <div class=\"modal-body text-center\">\r\n\r\n <div class=\"modal-body-other\">\r\n <div *ngFor=\"let cert of certificates\"> \r\n <div class=\"modal-body-info\" *ngIf=\"!cert.isExpired\">\r\n <div class=\"modal-body-info__item\">\r\n <span class=\"text\">\r\n \u0412\u043B\u0430\u0434\u0435\u043B\u0435\u0446:\r\n </span>\r\n <span class=\"text\">\r\n {{cert.cn}}<br/>\r\n {{cert.fio}}<span *ngIf=\"cert.post\">, {{cert.post}}</span>\r\n </span>\r\n </div>\r\n <div class=\"modal-body-info__item\">\r\n <span class=\"text\">\r\n \u0421\u0440\u043E\u043A \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044F:\r\n </span>\r\n <span class=\"text\">\r\n {{cert.validFromDate}} - {{cert.validToDate}}\r\n </span>\r\n </div>\r\n <div class=\"modal-body-info__item\">\r\n <span class=\"text hash\">\r\n {{cert.thumbprint}} {{cert.isExpired ? \"(\u0438\u0441\u0442\u0435\u043A)\" : \"\"}}\r\n </span>\r\n </div>\r\n <button\r\n (click)=\"ok(cert)\"\r\n [disabled]=\"cert.isExpired\"\r\n class=\"btn btn-md\">\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043F\u043E\u0434\u043F\u0438\u0441\u044C</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"modal-footer\">\r\n </div>\r\n</div>", styles: [":host{display:contents}:host textarea{width:100%;height:600px;border:0}\n"] }]
194
+ }], ctorParameters: function () { return []; } });
195
+
196
+ class CryptoProTsService extends CryptoProBaseService {
197
+ constructor() {
198
+ super();
199
+ }
200
+ get TIMESTAMP_SERVICE_URL() {
201
+ return 'http://testca.cryptopro.ru/tsp/tsp.srf';
202
+ }
203
+ sign(certificate, data) {
204
+ return __awaiter(this, void 0, void 0, function* () {
205
+ const store = yield window.cadesplugin.CreateObjectAsync("CAdESCOM.Store" /* Store */);
206
+ yield store.Open(2 /* CAPICOM_CURRENT_USER_STORE */, "My" /* CAPICOM_MY_STORE */, 2 /* CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED */);
207
+ let signer = yield window.cadesplugin.CreateObjectAsync("CAdESCOM.CPSigner" /* CPSigner */);
208
+ yield signer.propset_Certificate(certificate);
209
+ let signedXML = yield window.cadesplugin.CreateObjectAsync("CAdESCOM.SignedXML" /* SignedXML */);
210
+ let publicKey = yield certificate.PublicKey();
211
+ let algorithm = yield publicKey.Algorithm;
212
+ let algorithmOid = yield algorithm.Value;
213
+ let { signMethod, digestMethod } = this.getSigningMethods(algorithmOid);
214
+ //await signer.propset_Options(api.CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN);
215
+ yield signer.propset_TSAAddress(this.TIMESTAMP_SERVICE_URL);
216
+ if (data) {
217
+ let encodedXml = btoa(unescape(encodeURIComponent(data)));
218
+ yield signedXML.propset_Content(encodedXml);
219
+ }
220
+ yield signedXML.propset_SignatureType(0 /* CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED */);
221
+ yield signedXML.propset_SignatureMethod(signMethod);
222
+ yield signedXML.propset_DigestMethod(digestMethod);
223
+ let signature = yield signedXML.Sign(signer);
224
+ yield store.Close();
225
+ return signature;
226
+ });
227
+ }
228
+ getSigningMethods(algorithmOid) {
229
+ let signMethod = '', digestMethod = '';
230
+ if (algorithmOid == '1.2.643.7.1.1.1.1') { // алгоритм подписи ГОСТ Р 34.10-2012 с ключом 256 бит
231
+ signMethod = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102012-gostr34112012-256';
232
+ digestMethod = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-256';
233
+ }
234
+ else if (algorithmOid == '1.2.643.7.1.1.1.2') { // алгоритм подписи ГОСТ Р 34.10-2012 с ключом 512 бит
235
+ signMethod = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102012-gostr34112012-512';
236
+ digestMethod = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-512';
237
+ }
238
+ else if (algorithmOid == '1.2.643.2.2.19') { // алгоритм ГОСТ Р 34.10-2001
239
+ signMethod = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411';
240
+ digestMethod = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411';
241
+ }
242
+ return { signMethod, digestMethod };
243
+ }
244
+ }
245
+ CryptoProTsService.key = 'cryptoprots';
246
+
247
+ class CryptoService {
248
+ constructor() {
249
+ this.handlers = new Map();
250
+ this.selectPromise = null;
251
+ this._initialized = false;
252
+ this._withLog = false;
253
+ }
254
+ startUp(withLog) {
255
+ return __awaiter(this, void 0, void 0, function* () {
256
+ this._withLog = !!withLog;
257
+ if (!this._initialized) {
258
+ this.registerHandler({
259
+ key: CryptoProAsyncService.key,
260
+ name: 'КриптоПро',
261
+ service: new CryptoProAsyncService(),
262
+ sign: true,
263
+ default: true
264
+ });
265
+ this.registerHandler({
266
+ key: CryptoProTsService.key,
267
+ name: 'КриптоПро',
268
+ service: new CryptoProTsService(),
269
+ sign: true,
270
+ default: false
271
+ });
272
+ yield this.init();
273
+ this._initialized = true;
274
+ }
275
+ this.log('Handlers init completed');
276
+ return Promise.resolve();
277
+ });
278
+ }
279
+ registerHandler(options) {
280
+ this.log('Register handler', options);
281
+ options.disabled = false;
282
+ this.handlers.set(options.key, options);
283
+ }
284
+ ;
285
+ disableHandler(key) {
286
+ const handler = this.handlers.get(key);
287
+ if (handler) {
288
+ handler.disabled = true;
289
+ }
290
+ }
291
+ ;
292
+ getHandler(key) {
293
+ const handler = this.getActiveHandlers()
294
+ .find(x => x.key == key);
295
+ if (handler) {
296
+ return Promise.resolve(handler);
297
+ }
298
+ return Promise.reject(`Not found ${key} handler`);
299
+ }
300
+ ;
301
+ getDefaultHandler() {
302
+ const handler = this.getActiveHandlers()
303
+ .find(x => x.default);
304
+ if (handler) {
305
+ return Promise.resolve(handler);
306
+ }
307
+ return Promise.reject(`Not found default handler`);
308
+ }
309
+ ;
310
+ getService(key) {
311
+ const handler = this.handlers.get(key);
312
+ if (handler) {
313
+ return Promise.resolve(handler.service);
314
+ }
315
+ return Promise.reject(`Not found ${key}`);
316
+ }
317
+ ;
318
+ getActiveHandlers() {
319
+ const active = new Array();
320
+ this.handlers.forEach(s => {
321
+ if (!s.disabled) {
322
+ active.push(s);
323
+ }
324
+ });
325
+ return active;
326
+ }
327
+ ;
328
+ log(...args) {
329
+ if (this._withLog) {
330
+ console.log(args);
331
+ }
332
+ }
333
+ ;
334
+ init() {
335
+ return __awaiter(this, void 0, void 0, function* () {
336
+ this.log('Initialize handlers');
337
+ const promises = [];
338
+ this.handlers.forEach(handler => {
339
+ handler.service.available = false;
340
+ this.log('Initialize ' + handler.name);
341
+ const promise = handler.service.init().then((result) => {
342
+ result.available = true;
343
+ this.log('Handler init success', result);
344
+ }).catch(reason => {
345
+ this.log('Handler init fail', reason);
346
+ });
347
+ promises.push(promise);
348
+ });
349
+ return yield Promise.all(promises);
350
+ });
351
+ }
352
+ ;
353
+ }
354
+ CryptoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
355
+ CryptoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoService, providedIn: 'root' });
356
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoService, decorators: [{
357
+ type: Injectable,
358
+ args: [{
359
+ providedIn: 'root'
360
+ }]
361
+ }] });
362
+
363
+ class CryptoApiService extends EndpointBaseService {
364
+ constructor(http, injector) {
365
+ super(http, injector);
366
+ this.http = http;
367
+ this.injector = injector;
368
+ this.urlCrypto = '/cryptopro/api';
369
+ this.urlSigner = '/signer/api/v1';
370
+ }
371
+ verify(data) {
372
+ return this.http.post(`${this.urlCrypto}/cryptopro/verify`, data);
373
+ }
374
+ validate(data) {
375
+ return this.http.post(`${this.urlSigner}/jinn/validate`, { data });
376
+ }
377
+ }
378
+ CryptoApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoApiService, deps: [{ token: i1$1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
379
+ CryptoApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoApiService, providedIn: 'root' });
380
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoApiService, decorators: [{
381
+ type: Injectable,
382
+ args: [{
383
+ providedIn: 'root'
384
+ }]
385
+ }], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: i0.Injector }]; } });
386
+
387
+ class CryptoProvider {
388
+ constructor(simpleModalService, cryptoService, alertService, cryptoApiService) {
389
+ this.simpleModalService = simpleModalService;
390
+ this.cryptoService = cryptoService;
391
+ this.alertService = alertService;
392
+ this.cryptoApiService = cryptoApiService;
393
+ }
394
+ sign(data, withLog, options) {
395
+ var _a, _b, _c, _d;
396
+ return __awaiter(this, void 0, void 0, function* () {
397
+ yield this.cryptoService.startUp(withLog);
398
+ const service = yield this.cryptoService.getService(CryptoProAsyncService.key);
399
+ const list = yield service.getCertificates();
400
+ const modalResult = yield this.simpleModalService
401
+ .addModal(CertificateSelectComponent, { certificates: list }).toPromise();
402
+ if (!modalResult.selected) {
403
+ if (withLog) {
404
+ console.log('No certificate selected, rejecting');
405
+ }
406
+ return Promise.reject();
407
+ }
408
+ let certificateFail = 0;
409
+ if (window.CRYPTO_SKIP_CHECK !== true) {
410
+ if (options.checkFio &&
411
+ modalResult.selected.fio.toLowerCase() !== options.checkFio.toLowerCase()) {
412
+ certificateFail = 1;
413
+ }
414
+ if ((options.checkOgrn || options.checkOrganization) &&
415
+ (((_a = modalResult.selected.ogrn) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== ((_b = options.checkOgrn) === null || _b === void 0 ? void 0 : _b.toLowerCase()) &&
416
+ ((_c = modalResult.selected.organization) === null || _c === void 0 ? void 0 : _c.toLowerCase()) !== ((_d = options.checkOrganization) === null || _d === void 0 ? void 0 : _d.toLowerCase()))) {
417
+ certificateFail = 2;
418
+ }
419
+ // if (this.options.checkInn &&
420
+ // result.inn.toLowerCase() == this.options.checkFio.toLowerCase()) {
421
+ // certificateFail = true;
422
+ // }
423
+ }
424
+ if (certificateFail > 0) {
425
+ this.alertService.showDialog({
426
+ title: 'Ошибка сертификата',
427
+ message: certificateFail == 1 ?
428
+ 'Данные лица, подписывающего заявку не совпадают с данными усиленной квалифицированной подписи.' :
429
+ 'Данные организации не совпадают с данными усиленной квалифицированной подписи. ' +
430
+ 'Убедитесь, что вы используете сертификат, выданные от организации.',
431
+ color: DialogColor.red,
432
+ type: DialogType.alert,
433
+ okCallback: (ok) => {
434
+ //
435
+ }
436
+ });
437
+ return Promise.reject();
438
+ }
439
+ if (withLog) {
440
+ console.log('Signing data', data);
441
+ }
442
+ const signedData = yield service.signBase64(modalResult.selected.certificate, data, true);
443
+ if (withLog) {
444
+ console.log('Signing data', data);
445
+ }
446
+ if (!options.skipServerCheck) {
447
+ const verifyResult = yield this.cryptoApiService.verify({
448
+ data: data,
449
+ signature: Base64.encode(signedData),
450
+ detached: true
451
+ }).toPromise();
452
+ return {
453
+ data,
454
+ success: verifyResult.success,
455
+ signed: signedData,
456
+ certificate: modalResult.selected,
457
+ };
458
+ }
459
+ else {
460
+ return {
461
+ data,
462
+ success: true,
463
+ signed: signedData,
464
+ certificate: modalResult.selected,
465
+ };
466
+ }
467
+ });
468
+ }
469
+ }
470
+ CryptoProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoProvider, deps: [{ token: i1$2.SimpleModalService }, { token: CryptoService }, { token: i3.AlertService }, { token: CryptoApiService }], target: i0.ɵɵFactoryTarget.Injectable });
471
+ CryptoProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoProvider, providedIn: 'root' });
472
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoProvider, decorators: [{
473
+ type: Injectable,
474
+ args: [{
475
+ providedIn: 'root'
476
+ }]
477
+ }], ctorParameters: function () { return [{ type: i1$2.SimpleModalService }, { type: CryptoService }, { type: i3.AlertService }, { type: CryptoApiService }]; } });
478
+
479
+ class CryptoJinnProvider {
480
+ constructor(simpleModalService, cryptoService, cryptoApiService) {
481
+ this.simpleModalService = simpleModalService;
482
+ this.cryptoService = cryptoService;
483
+ this.cryptoApiService = cryptoApiService;
484
+ }
485
+ sign(data, withLog, options) {
486
+ return __awaiter(this, void 0, void 0, function* () {
487
+ yield this.cryptoService.startUp(withLog);
488
+ const service = yield this.cryptoService.getService(CryptoProAsyncService.key);
489
+ const list = yield service.getCertificates();
490
+ const modalResult = yield this.simpleModalService
491
+ .addModal(CertificateSelectComponent, { certificates: list }).toPromise();
492
+ if (!modalResult.selected) {
493
+ if (withLog) {
494
+ console.log('No certificate selected, rejecting');
495
+ }
496
+ return Promise.reject();
497
+ }
498
+ if (withLog) {
499
+ console.log('Signing data', data);
500
+ }
501
+ const signedData = yield service.signXml(modalResult.selected.certificate, data);
502
+ const verifyResult = yield this.cryptoApiService.validate(signedData).toPromise();
503
+ return {
504
+ data: signedData,
505
+ success: verifyResult.success,
506
+ certificate: modalResult.selected,
507
+ validateResult: verifyResult.validateResult
508
+ };
509
+ });
510
+ }
511
+ }
512
+ CryptoJinnProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoJinnProvider, deps: [{ token: i1$2.SimpleModalService }, { token: CryptoService }, { token: CryptoApiService }], target: i0.ɵɵFactoryTarget.Injectable });
513
+ CryptoJinnProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoJinnProvider, providedIn: 'root' });
514
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoJinnProvider, decorators: [{
515
+ type: Injectable,
516
+ args: [{
517
+ providedIn: 'root'
518
+ }]
519
+ }], ctorParameters: function () { return [{ type: i1$2.SimpleModalService }, { type: CryptoService }, { type: CryptoApiService }]; } });
520
+
521
+ class CryptoTsProvider {
522
+ constructor(simpleModalService, cryptoService, cryptoApiService) {
523
+ this.simpleModalService = simpleModalService;
524
+ this.cryptoService = cryptoService;
525
+ this.cryptoApiService = cryptoApiService;
526
+ }
527
+ sign(data, withLog, options) {
528
+ return __awaiter(this, void 0, void 0, function* () {
529
+ yield this.cryptoService.startUp(withLog);
530
+ const service = yield this.cryptoService.getService(CryptoProTsService.key);
531
+ const list = yield service.getCertificates();
532
+ const modalResult = yield this.simpleModalService
533
+ .addModal(CertificateSelectComponent, { certificates: list }).toPromise();
534
+ if (!modalResult.selected) {
535
+ if (withLog) {
536
+ console.log('No certificate selected, rejecting');
537
+ }
538
+ return Promise.reject();
539
+ }
540
+ const signedData = yield service.sign(modalResult.selected.certificate, data);
541
+ if (!options.skipServerCheck) {
542
+ const validateResult = yield this.cryptoApiService.validate(signedData).toPromise();
543
+ return {
544
+ data,
545
+ signed: signedData,
546
+ success: validateResult.success,
547
+ validateResult: validateResult.validateResult,
548
+ certificate: modalResult.selected,
549
+ };
550
+ }
551
+ else {
552
+ return {
553
+ data,
554
+ signed: signedData,
555
+ success: true,
556
+ validateResult: '',
557
+ certificate: modalResult.selected,
558
+ };
559
+ }
560
+ });
561
+ }
562
+ }
563
+ CryptoTsProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoTsProvider, deps: [{ token: i1$2.SimpleModalService }, { token: CryptoService }, { token: CryptoApiService }], target: i0.ɵɵFactoryTarget.Injectable });
564
+ CryptoTsProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoTsProvider, providedIn: 'root' });
565
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: CryptoTsProvider, decorators: [{
566
+ type: Injectable,
567
+ args: [{
568
+ providedIn: 'root'
569
+ }]
570
+ }], ctorParameters: function () { return [{ type: i1$2.SimpleModalService }, { type: CryptoService }, { type: CryptoApiService }]; } });
571
+
572
+ class EmptyProvider {
573
+ sign(data, withLog, options) {
574
+ return __awaiter(this, void 0, void 0, function* () {
575
+ return Promise.resolve({
576
+ data: data,
577
+ success: true
578
+ });
579
+ });
580
+ }
581
+ }
582
+ EmptyProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: EmptyProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
583
+ EmptyProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: EmptyProvider, providedIn: 'root' });
584
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: EmptyProvider, decorators: [{
585
+ type: Injectable,
586
+ args: [{
587
+ providedIn: 'root'
588
+ }]
589
+ }] });
590
+
591
+ class SignProviderFactory {
592
+ constructor(cryptoProvider, cryptoJinnProvider, cryptoTsProvider, emptyProvider) {
593
+ this.cryptoProvider = cryptoProvider;
594
+ this.cryptoJinnProvider = cryptoJinnProvider;
595
+ this.cryptoTsProvider = cryptoTsProvider;
596
+ this.emptyProvider = emptyProvider;
597
+ }
598
+ create(providerType) {
599
+ switch (providerType) {
600
+ case 'crypto':
601
+ return this.cryptoProvider;
602
+ case 'cryptojinn':
603
+ return this.cryptoJinnProvider;
604
+ case 'cryptots':
605
+ return this.cryptoTsProvider;
606
+ case 'empty':
607
+ return this.emptyProvider;
608
+ }
609
+ }
610
+ }
611
+ SignProviderFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SignProviderFactory, deps: [{ token: CryptoProvider }, { token: CryptoJinnProvider }, { token: CryptoTsProvider }, { token: EmptyProvider }], target: i0.ɵɵFactoryTarget.Injectable });
612
+ SignProviderFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SignProviderFactory, providedIn: 'root' });
613
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SignProviderFactory, decorators: [{
614
+ type: Injectable,
615
+ args: [{
616
+ providedIn: 'root'
617
+ }]
618
+ }], ctorParameters: function () { return [{ type: CryptoProvider }, { type: CryptoJinnProvider }, { type: CryptoTsProvider }, { type: EmptyProvider }]; } });
619
+
620
+ class DownloadService extends EndpointBaseService {
621
+ constructor(http, injector) {
622
+ super(http, injector);
623
+ this.http = http;
624
+ this.injector = injector;
625
+ this.url = '/signer/api/v1/download';
626
+ }
627
+ xml(url) {
628
+ return this.http.get(url, {
629
+ headers: new HttpHeaders()
630
+ .set('Content-Type', 'text/xml'),
631
+ responseType: 'text'
632
+ });
633
+ }
634
+ pdf(url) {
635
+ return this.http.get(url, {
636
+ headers: new HttpHeaders()
637
+ .set('Content-Type', 'application/pdf'),
638
+ responseType: 'blob'
639
+ });
640
+ }
641
+ }
642
+ DownloadService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DownloadService, deps: [{ token: i1$1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
643
+ DownloadService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DownloadService, providedIn: 'root' });
644
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: DownloadService, decorators: [{
645
+ type: Injectable,
646
+ args: [{
647
+ providedIn: 'root'
648
+ }]
649
+ }], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: i0.Injector }]; } });
650
+
651
+ class SignModalComponent extends SimpleModalComponent {
652
+ constructor(signProviderFactory, downloadService, alertService) {
653
+ super();
654
+ this.signProviderFactory = signProviderFactory;
655
+ this.downloadService = downloadService;
656
+ this.alertService = alertService;
657
+ this.title = '';
658
+ this.okLabel = '';
659
+ this.cancelLabel = '';
660
+ this.provider = 'empty';
661
+ this.signType = 'xml';
662
+ this.xmlToSign = '';
663
+ this.pdfToSign = '';
664
+ this.downloadingPdf = false;
665
+ this.result = { result: false };
666
+ }
667
+ get disabled() {
668
+ // todo как можно дизеблить кнопу
669
+ return false;
670
+ }
671
+ get pdfViewUrl() {
672
+ return this.pdfUrl ?
673
+ `/signer/pdfjs/web/viewer.html?file=${encodeURIComponent(this.pdfUrl)}` : '';
674
+ }
675
+ ngOnInit() {
676
+ this.downloadXml();
677
+ this.downloadPdf();
678
+ }
679
+ ok() {
680
+ if (!this.signType) {
681
+ this.signType = 'xml';
682
+ }
683
+ let signData = this.xmlToSign;
684
+ switch (this.signType) {
685
+ case 'xml':
686
+ signData = Base64.encode(this.xmlToSign);
687
+ break;
688
+ case 'pdf':
689
+ signData = this.pdfToSign;
690
+ break;
691
+ case 'xmlts':
692
+ signData = this.xmlToSign;
693
+ break;
694
+ }
695
+ this.signProviderFactory.create(this.provider)
696
+ .sign(signData, this.withLog, {
697
+ skipServerCheck: this.skipServerCheck,
698
+ checkFio: this.checkFio,
699
+ checkOgrn: this.checkOgrn,
700
+ checkOrganization: this.checkOrganization,
701
+ checkInn: this.checkInn
702
+ })
703
+ .then((ok) => {
704
+ this.processResult(ok);
705
+ }).catch((error) => {
706
+ this.processError(error);
707
+ });
708
+ }
709
+ cancel() {
710
+ this.close();
711
+ }
712
+ processResult(signResult) {
713
+ if (signResult.success) {
714
+ this.result = { model: signResult, result: true };
715
+ this.close();
716
+ }
717
+ else {
718
+ this.alertService.showDialog({
719
+ title: 'Ошибка проверки подписи',
720
+ message: 'Подпись не валидна',
721
+ color: DialogColor.red,
722
+ type: DialogType.alert,
723
+ okCallback: (ok) => {
724
+ }
725
+ });
726
+ }
727
+ }
728
+ processError(error) {
729
+ if (this.withLog) {
730
+ console.error(error);
731
+ }
732
+ this.alertService.showDialog({
733
+ title: 'Ошибка проверки подписи',
734
+ message: JSON.stringify(error),
735
+ color: DialogColor.red,
736
+ type: DialogType.alert,
737
+ okCallback: (ok) => {
738
+ }
739
+ });
740
+ }
741
+ downloadXml() {
742
+ if (!this.xmlUrl) {
743
+ return;
744
+ }
745
+ if (this.withLog) {
746
+ console.log('Downloading xml');
747
+ }
748
+ this.downloadService.xml(this.xmlUrl).subscribe(result => {
749
+ if (this.withLog) {
750
+ console.log('xmlToSign = ', result);
751
+ }
752
+ this.xmlToSign = result;
753
+ });
754
+ }
755
+ downloadPdf() {
756
+ if (!this.pdfUrl) {
757
+ return;
758
+ }
759
+ if (this.withLog) {
760
+ console.log('Downloading pdf');
761
+ }
762
+ this.downloadingPdf = true;
763
+ this.downloadService.pdf(this.pdfUrl)
764
+ .subscribe(result => {
765
+ this.downloadingPdf = false;
766
+ // todo подумать, как правильно читать файл
767
+ // const blob = new Blob([result], {type: 'application/pdf'});
768
+ const reader = new FileReader();
769
+ reader.readAsDataURL(result);
770
+ reader.onloadend = () => {
771
+ let base64data = reader.result;
772
+ base64data = base64data.replace('data:application/pdf;base64,', '');
773
+ if (this.withLog) {
774
+ console.log('pdfToSign = ', base64data);
775
+ }
776
+ this.pdfToSign = base64data;
777
+ };
778
+ }, () => {
779
+ this.downloadingPdf = false;
780
+ });
781
+ }
782
+ }
783
+ SignModalComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SignModalComponent, deps: [{ token: SignProviderFactory }, { token: DownloadService }, { token: i3.AlertService }], target: i0.ɵɵFactoryTarget.Component });
784
+ SignModalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: SignModalComponent, selector: "lib-sign-modal", usesInheritance: true, ngImport: i0, template: "<div class=\"modal-content accent-head\">\r\n <div class=\"modal-header\">\r\n <div class=\"modal-title uppercase\">\r\n <h4 class=\"ng-binding\">{{title || '\u041F\u043E\u0434\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430'}}</h4>\r\n </div>\r\n <span class=\"close close-click\" (click)=\"close()\">\r\n <svg width=\"14\" height=\"14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M13 1L1 13M1 1l12 12\" stroke=\"#3A3A3A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"></path>\r\n </svg>\r\n </span>\r\n </div>\r\n\r\n <div class=\"modal-body text-center\">\r\n <div class=\"widget\">\r\n <my-tabs>\r\n <app-tab tabTitle=\"\u0412\u0438\u0437\u0443\u0430\u043B\u0438\u0437\u0430\u0446\u0438\u044F \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\" *ngIf=\"pdfUrl\">\r\n <pre *ngIf=\"downloadingPdf\">\r\n \u041F\u043E\u0434\u043E\u0436\u0434\u0438\u0442\u0435, \u0438\u0434\u0435\u0442 \u0444\u043E\u0440\u043C\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\r\n </pre>\r\n <iframe *ngIf=\"!downloadingPdf\" [src]=\"pdfViewUrl | safeurl\"\r\n title=\"webviewer\" frameborder=\"0\" width=\"100%\" height=\"800\"></iframe>\r\n </app-tab>\r\n <app-tab tabTitle=\"\u041F\u043E\u0434\u043F\u0438\u0441\u044B\u0432\u0430\u0435\u043C\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435\" *ngIf=\"xmlUrl\">\r\n <pre [innerText]=\"xmlToSign\"></pre>\r\n </app-tab>\r\n </my-tabs>\r\n </div>\r\n </div>\r\n\r\n <div class=\"modal-footer\">\r\n <div *ngIf=\"pdfUrl || xmlUrl\"\r\n class=\"modal-footer-item\">\r\n <a *ngIf=\"pdfUrl\"\r\n class=\"modal-footer-item__link\"\r\n target=\"_blank\"\r\n [href]=\"pdfUrl\">\r\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path\r\n d=\"M18 21.25H6C5.30964 21.25 4.75 20.6904 4.75 20V4C4.75 3.30964 5.30964 2.75 6 2.75H13.1893L19.25 8.81066V20C19.25 20.6904 18.6904 21.25 18 21.25Z\"\r\n stroke=\"#282828\" stroke-width=\"1.5\"/>\r\n </svg>\r\n <span>\u0421\u043A\u0430\u0447\u0430\u0442\u044C \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442</span>\r\n </a>\r\n <a *ngIf=\"xmlUrl\"\r\n class=\"modal-footer-item__link\"\r\n target=\"_blank\"\r\n [href]=\"xmlUrl\">\r\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M6 16L2 12L6 8\" stroke=\"#282828\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\r\n <path d=\"M18 16L22 12L18 8\" stroke=\"#282828\" stroke-width=\"1.5\" stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"/>\r\n <path d=\"M7.56689 19.1782L15.5669 5.32182\" stroke=\"#282828\" stroke-width=\"1.5\" stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"/>\r\n </svg>\r\n <span>\u0421\u043A\u0430\u0447\u0430\u0442\u044C XML-\u0434\u0430\u043D\u043D\u044B\u0435</span>\r\n </a>\r\n </div>\r\n <div class=\"modal-footer-item\">\r\n <button\r\n class=\"mrx-btn mrx-btn-secondary mrx-btn-md wpx-120 mr-3\"\r\n (click)=\"cancel()\"\r\n >\r\n <div class=\"mrx-btn-label\">{{cancelLabel || '\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C'}}</div>\r\n </button>\r\n <button\r\n class=\"mrx-btn mrx-btn-primary mrx-btn-md wpx-120\"\r\n [disabled]=\"disabled\"\r\n (click)=\"ok()\"\r\n >\r\n <div class=\"mrx-btn-label\">{{okLabel || '\u041F\u043E\u0434\u043F\u0438\u0441\u0430\u0442\u044C'}}</div>\r\n </button>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [":host{display:contents}:host pre{width:100%;height:600px;border:0;text-align:left;overflow-y:scroll}.modal-footer{justify-content:space-between;align-items:center}.modal-footer-item__link{display:inline-flex;align-items:center;font-family:PT Sans,sans-serif;font-weight:700;font-size:14px;line-height:160%;color:var(--Main1);margin-right:16px}.modal-footer-item__link svg{margin-right:4px}.modal-body iframe{height:600px}pre{height:600px;overflow:scroll}\n"], components: [{ type: i3.TabsComponent, selector: "my-tabs" }, { type: i3.TabComponent, selector: "app-tab", inputs: ["tabTitle", "active"] }], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "safeurl": i3.SafeUrlPipe } });
785
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SignModalComponent, decorators: [{
786
+ type: Component,
787
+ args: [{ selector: 'lib-sign-modal', template: "<div class=\"modal-content accent-head\">\r\n <div class=\"modal-header\">\r\n <div class=\"modal-title uppercase\">\r\n <h4 class=\"ng-binding\">{{title || '\u041F\u043E\u0434\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430'}}</h4>\r\n </div>\r\n <span class=\"close close-click\" (click)=\"close()\">\r\n <svg width=\"14\" height=\"14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M13 1L1 13M1 1l12 12\" stroke=\"#3A3A3A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"></path>\r\n </svg>\r\n </span>\r\n </div>\r\n\r\n <div class=\"modal-body text-center\">\r\n <div class=\"widget\">\r\n <my-tabs>\r\n <app-tab tabTitle=\"\u0412\u0438\u0437\u0443\u0430\u043B\u0438\u0437\u0430\u0446\u0438\u044F \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\" *ngIf=\"pdfUrl\">\r\n <pre *ngIf=\"downloadingPdf\">\r\n \u041F\u043E\u0434\u043E\u0436\u0434\u0438\u0442\u0435, \u0438\u0434\u0435\u0442 \u0444\u043E\u0440\u043C\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\r\n </pre>\r\n <iframe *ngIf=\"!downloadingPdf\" [src]=\"pdfViewUrl | safeurl\"\r\n title=\"webviewer\" frameborder=\"0\" width=\"100%\" height=\"800\"></iframe>\r\n </app-tab>\r\n <app-tab tabTitle=\"\u041F\u043E\u0434\u043F\u0438\u0441\u044B\u0432\u0430\u0435\u043C\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435\" *ngIf=\"xmlUrl\">\r\n <pre [innerText]=\"xmlToSign\"></pre>\r\n </app-tab>\r\n </my-tabs>\r\n </div>\r\n </div>\r\n\r\n <div class=\"modal-footer\">\r\n <div *ngIf=\"pdfUrl || xmlUrl\"\r\n class=\"modal-footer-item\">\r\n <a *ngIf=\"pdfUrl\"\r\n class=\"modal-footer-item__link\"\r\n target=\"_blank\"\r\n [href]=\"pdfUrl\">\r\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path\r\n d=\"M18 21.25H6C5.30964 21.25 4.75 20.6904 4.75 20V4C4.75 3.30964 5.30964 2.75 6 2.75H13.1893L19.25 8.81066V20C19.25 20.6904 18.6904 21.25 18 21.25Z\"\r\n stroke=\"#282828\" stroke-width=\"1.5\"/>\r\n </svg>\r\n <span>\u0421\u043A\u0430\u0447\u0430\u0442\u044C \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442</span>\r\n </a>\r\n <a *ngIf=\"xmlUrl\"\r\n class=\"modal-footer-item__link\"\r\n target=\"_blank\"\r\n [href]=\"xmlUrl\">\r\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M6 16L2 12L6 8\" stroke=\"#282828\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\r\n <path d=\"M18 16L22 12L18 8\" stroke=\"#282828\" stroke-width=\"1.5\" stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"/>\r\n <path d=\"M7.56689 19.1782L15.5669 5.32182\" stroke=\"#282828\" stroke-width=\"1.5\" stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"/>\r\n </svg>\r\n <span>\u0421\u043A\u0430\u0447\u0430\u0442\u044C XML-\u0434\u0430\u043D\u043D\u044B\u0435</span>\r\n </a>\r\n </div>\r\n <div class=\"modal-footer-item\">\r\n <button\r\n class=\"mrx-btn mrx-btn-secondary mrx-btn-md wpx-120 mr-3\"\r\n (click)=\"cancel()\"\r\n >\r\n <div class=\"mrx-btn-label\">{{cancelLabel || '\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C'}}</div>\r\n </button>\r\n <button\r\n class=\"mrx-btn mrx-btn-primary mrx-btn-md wpx-120\"\r\n [disabled]=\"disabled\"\r\n (click)=\"ok()\"\r\n >\r\n <div class=\"mrx-btn-label\">{{okLabel || '\u041F\u043E\u0434\u043F\u0438\u0441\u0430\u0442\u044C'}}</div>\r\n </button>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: [":host{display:contents}:host pre{width:100%;height:600px;border:0;text-align:left;overflow-y:scroll}.modal-footer{justify-content:space-between;align-items:center}.modal-footer-item__link{display:inline-flex;align-items:center;font-family:PT Sans,sans-serif;font-weight:700;font-size:14px;line-height:160%;color:var(--Main1);margin-right:16px}.modal-footer-item__link svg{margin-right:4px}.modal-body iframe{height:600px}pre{height:600px;overflow:scroll}\n"] }]
788
+ }], ctorParameters: function () { return [{ type: SignProviderFactory }, { type: DownloadService }, { type: i3.AlertService }]; } });
789
+
790
+ class SignService {
791
+ constructor(simpleModalService, tmpTokenService) {
792
+ this.simpleModalService = simpleModalService;
793
+ this.tmpTokenService = tmpTokenService;
794
+ }
795
+ sign(request, ok, cancel) {
796
+ const baseUrl = Utilities.commonPart(request.xmlUrl, request.pdfUrl);
797
+ this.tmpTokenService.generate(baseUrl).subscribe(token => {
798
+ const ph = `${window.location.protocol}//${window.location.host}`;
799
+ if (request.xmlUrl) {
800
+ request.xmlUrl = ph + Utilities.updateQueryStringParameter(request.xmlUrl, 'authToken', token);
801
+ }
802
+ if (request.pdfUrl) {
803
+ request.pdfUrl = ph + Utilities.updateQueryStringParameter(request.pdfUrl, 'authToken', token);
804
+ }
805
+ this.simpleModalService.addModal(SignModalComponent, request, { wrapperClass: 'in xl' })
806
+ .subscribe(result => {
807
+ if (result && result.result) {
808
+ ok(result.model);
809
+ }
810
+ else {
811
+ if (cancel) {
812
+ cancel();
813
+ }
814
+ }
815
+ });
816
+ });
817
+ }
818
+ }
819
+ SignService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SignService, deps: [{ token: i1$2.SimpleModalService }, { token: i3.TmpTokenService }], target: i0.ɵɵFactoryTarget.Injectable });
820
+ SignService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SignService, providedIn: 'root' });
821
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SignService, decorators: [{
822
+ type: Injectable,
823
+ args: [{
824
+ providedIn: 'root',
825
+ }]
826
+ }], ctorParameters: function () { return [{ type: i1$2.SimpleModalService }, { type: i3.TmpTokenService }]; } });
827
+
828
+ class MyrtexSignerModule {
829
+ }
830
+ MyrtexSignerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MyrtexSignerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
831
+ MyrtexSignerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MyrtexSignerModule, declarations: [SignModalComponent,
832
+ CertificateSelectComponent], imports: [CommonModule,
833
+ FormsModule,
834
+ ReactiveFormsModule,
835
+ HttpClientModule,
836
+ NgSelectModule,
837
+ MyrtexUiCompositeModule], exports: [SignModalComponent] });
838
+ MyrtexSignerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MyrtexSignerModule, providers: [
839
+ SignProviderFactory,
840
+ CryptoProvider,
841
+ CryptoJinnProvider,
842
+ CryptoTsProvider,
843
+ EmptyProvider,
844
+ CryptoApiService,
845
+ SignService,
846
+ DownloadService
847
+ ], imports: [[
848
+ CommonModule,
849
+ FormsModule,
850
+ ReactiveFormsModule,
851
+ HttpClientModule,
852
+ NgSelectModule,
853
+ MyrtexUiCompositeModule
854
+ ]] });
855
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MyrtexSignerModule, decorators: [{
856
+ type: NgModule,
857
+ args: [{
858
+ declarations: [
859
+ SignModalComponent,
860
+ CertificateSelectComponent
861
+ ],
862
+ imports: [
863
+ CommonModule,
864
+ FormsModule,
865
+ ReactiveFormsModule,
866
+ HttpClientModule,
867
+ NgSelectModule,
868
+ MyrtexUiCompositeModule
869
+ ],
870
+ exports: [
871
+ SignModalComponent
872
+ ],
873
+ providers: [
874
+ SignProviderFactory,
875
+ CryptoProvider,
876
+ CryptoJinnProvider,
877
+ CryptoTsProvider,
878
+ EmptyProvider,
879
+ CryptoApiService,
880
+ SignService,
881
+ DownloadService
882
+ ]
883
+ }]
884
+ }] });
885
+
886
+ /*
887
+ * Public API Surface of myrtex-mf-signer
888
+ */
889
+
890
+ /**
891
+ * Generated bundle index. Do not edit.
892
+ */
893
+
894
+ export { MyrtexSignerModule, SignModalComponent, SignService };
895
+ //# sourceMappingURL=myrtex-mf-signer.mjs.map