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