imzo-agnost 1.0.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.
package/dist/index.js ADDED
@@ -0,0 +1,1823 @@
1
+ var EIMZOAgnost = (function (exports) {
2
+ 'use strict';
3
+
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
+ var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
14
+ var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
15
+ var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
16
+ var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
17
+ var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
18
+ var __runInitializers = (array, flags, self, value) => {
19
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) fns[i].call(self) ;
20
+ return value;
21
+ };
22
+ var __decorateElement = (array, flags, name, decorators, target, extra) => {
23
+ var it, done, ctx, k = flags & 7, p = false;
24
+ var j = 0;
25
+ var extraInitializers = array[j] || (array[j] = []);
26
+ var desc = k && ((target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(target , name));
27
+ __name(target, name);
28
+ for (var i = decorators.length - 1; i >= 0; i--) {
29
+ ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
30
+ it = (0, decorators[i])(target, ctx), done._ = 1;
31
+ __expectFn(it) && (target = it);
32
+ }
33
+ return __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
34
+ };
35
+
36
+ // src/e-imzo/capiws.ts
37
+ var CAPIWS = typeof EIMZOEXT !== "undefined" ? EIMZOEXT : {
38
+ URL: (window.location.protocol.toLowerCase() === "https:" ? "wss://127.0.0.1:64443" : "ws://127.0.0.1:64646") + "/service/cryptapi",
39
+ callFunction: function(funcDef, callback, error) {
40
+ if (!window.WebSocket) {
41
+ if (error) error();
42
+ return;
43
+ }
44
+ let socket;
45
+ try {
46
+ socket = new WebSocket(this.URL);
47
+ } catch (e) {
48
+ if (error) error(e);
49
+ return;
50
+ }
51
+ socket.onclose = function(e) {
52
+ if (error) {
53
+ if (e.code !== 1e3) {
54
+ error(e.code);
55
+ }
56
+ }
57
+ };
58
+ socket.onmessage = function(event) {
59
+ const data = JSON.parse(event.data);
60
+ socket.close();
61
+ callback(event, data);
62
+ };
63
+ socket.onopen = function() {
64
+ socket.send(JSON.stringify(funcDef));
65
+ };
66
+ },
67
+ version: function(callback, error) {
68
+ if (!window.WebSocket) {
69
+ if (error) error();
70
+ return;
71
+ }
72
+ let socket;
73
+ try {
74
+ socket = new WebSocket(this.URL);
75
+ } catch (e) {
76
+ if (error) error(e);
77
+ return;
78
+ }
79
+ socket.onclose = function(e) {
80
+ if (error) {
81
+ if (e.code !== 1e3) {
82
+ error(e.code);
83
+ }
84
+ }
85
+ };
86
+ socket.onmessage = function(event) {
87
+ const data = JSON.parse(event.data);
88
+ socket.close();
89
+ callback(event, data);
90
+ };
91
+ socket.onopen = function() {
92
+ const o = { name: "version" };
93
+ socket.send(JSON.stringify(o));
94
+ };
95
+ },
96
+ apidoc: function(callback, error) {
97
+ if (!window.WebSocket) {
98
+ if (error) error();
99
+ return;
100
+ }
101
+ let socket;
102
+ try {
103
+ socket = new WebSocket(this.URL);
104
+ } catch (e) {
105
+ if (error) error(e);
106
+ return;
107
+ }
108
+ socket.onclose = function(e) {
109
+ if (error) {
110
+ if (e.code !== 1e3) {
111
+ error(e.code);
112
+ }
113
+ }
114
+ };
115
+ socket.onmessage = function(event) {
116
+ const data = JSON.parse(event.data);
117
+ socket.close();
118
+ callback(event, data);
119
+ };
120
+ socket.onopen = function() {
121
+ const o = { name: "apidoc" };
122
+ socket.send(JSON.stringify(o));
123
+ };
124
+ },
125
+ apikey: function(domainAndKey, callback, error) {
126
+ if (!window.WebSocket) {
127
+ if (error) error();
128
+ return;
129
+ }
130
+ let socket;
131
+ try {
132
+ socket = new WebSocket(this.URL);
133
+ } catch (e) {
134
+ if (error) error(e);
135
+ return;
136
+ }
137
+ socket.onclose = function(e) {
138
+ if (error) {
139
+ if (e.code !== 1e3) {
140
+ error(e.code);
141
+ }
142
+ }
143
+ };
144
+ socket.onmessage = function(event) {
145
+ const data = JSON.parse(event.data);
146
+ socket.close();
147
+ callback(event, data);
148
+ };
149
+ socket.onopen = function() {
150
+ const o = { name: "apikey", arguments: domainAndKey };
151
+ socket.send(JSON.stringify(o));
152
+ };
153
+ }
154
+ };
155
+ var capiws_default = CAPIWS;
156
+
157
+ // src/e-imzo-client.ts
158
+ Date.prototype.yyyymmdd = function() {
159
+ const yyyy = this.getFullYear().toString();
160
+ const mm = (this.getMonth() + 1).toString();
161
+ const dd = this.getDate().toString();
162
+ return yyyy + (mm[1] ? mm : "0" + mm[0]) + (dd[1] ? dd : "0" + dd[0]);
163
+ };
164
+ Date.prototype.ddmmyyyy = function() {
165
+ const yyyy = this.getFullYear().toString();
166
+ const mm = (this.getMonth() + 1).toString();
167
+ const dd = this.getDate().toString();
168
+ return (dd[1] ? dd : "0" + dd[0]) + "." + (mm[1] ? mm : "0" + mm[0]) + "." + yyyy;
169
+ };
170
+ var dates = {
171
+ convert(d) {
172
+ if (d instanceof Date) {
173
+ return d;
174
+ } else if (Array.isArray(d) && d.length >= 3) {
175
+ return new Date(d[0] || 0, d[1] || 0, d[2] || 0);
176
+ } else if (typeof d === "number") {
177
+ return new Date(d);
178
+ } else if (typeof d === "string") {
179
+ return new Date(d);
180
+ } else if (typeof d === "object" && d !== null) {
181
+ const dateObj = d;
182
+ return new Date(dateObj.year || 0, dateObj.month || 0, dateObj.date || 0);
183
+ }
184
+ return NaN;
185
+ },
186
+ compare(a, b) {
187
+ const aVal = this.convert(a).valueOf();
188
+ const bVal = this.convert(b).valueOf();
189
+ return isFinite(aVal) && isFinite(bVal) ? (aVal > bVal ? 1 : 0) - (aVal < bVal ? 1 : 0) : NaN;
190
+ },
191
+ inRange(d, start, end) {
192
+ const dVal = this.convert(d).valueOf();
193
+ const startVal = this.convert(start).valueOf();
194
+ const endVal = this.convert(end).valueOf();
195
+ return isFinite(dVal) && isFinite(startVal) && isFinite(endVal) ? startVal <= dVal && dVal <= endVal : NaN;
196
+ }
197
+ };
198
+ String.prototype.splitKeep = function(splitter, ahead) {
199
+ const result = [];
200
+ if (splitter !== "") {
201
+ let getSubst2 = function(value) {
202
+ const substChar = value[0] === "0" ? "1" : "0";
203
+ let subst = "";
204
+ for (let i = 0; i < value.length; i++) {
205
+ subst += substChar;
206
+ }
207
+ return subst;
208
+ };
209
+ const matches = [];
210
+ if (splitter instanceof RegExp) {
211
+ this.replace(splitter, (m, ...args) => {
212
+ const offset = args[args.length - 2];
213
+ matches.push({ value: m, index: offset });
214
+ return getSubst2(m);
215
+ });
216
+ } else {
217
+ this.replaceAll(splitter, (m, offset) => {
218
+ matches.push({ value: m, index: offset });
219
+ return getSubst2(m);
220
+ });
221
+ }
222
+ let lastIndex = 0;
223
+ for (let i = 0; i < matches.length; i++) {
224
+ const m = matches[i];
225
+ if (m) {
226
+ const nextIndex = ahead === true ? m.index : m.index + m.value.length;
227
+ if (nextIndex !== lastIndex) {
228
+ const part = this.substring(lastIndex, nextIndex);
229
+ result.push(part);
230
+ lastIndex = nextIndex;
231
+ }
232
+ }
233
+ }
234
+ if (lastIndex < this.length) {
235
+ const part = this.substring(lastIndex, this.length);
236
+ result.push(part);
237
+ }
238
+ } else {
239
+ result.push(this.toString());
240
+ }
241
+ return result;
242
+ };
243
+ var EIMZOClient = {
244
+ NEW_API: false,
245
+ NEW_API2: false,
246
+ API_KEYS: [
247
+ "localhost",
248
+ "96D0C1491615C82B9A54D9989779DF825B690748224C2B04F500F370D51827CE2644D8D4A82C18184D73AB8530BB8ED537269603F61DB0D03D2104ABF789970B",
249
+ "127.0.0.1",
250
+ "A7BCFA5D490B351BE0754130DF03A068F855DB4333D43921125B9CF2670EF6A40370C646B90401955E1F7BC9CDBF59CE0B2C5467D820BE189C845D0B79CFC96F"
251
+ ],
252
+ checkVersion(success, fail) {
253
+ capiws_default.version(
254
+ (event, data) => {
255
+ if (data.success === true) {
256
+ if (data.major && data.minor) {
257
+ const installedVersion = parseInt(data.major) * 100 + parseInt(data.minor);
258
+ EIMZOClient.NEW_API = installedVersion >= 336;
259
+ EIMZOClient.NEW_API2 = installedVersion >= 412;
260
+ success(data.major, data.minor);
261
+ } else {
262
+ fail(null, "E-IMZO Version is undefined");
263
+ }
264
+ } else {
265
+ fail(null, data.reason || "Unknown error");
266
+ }
267
+ },
268
+ (e) => {
269
+ fail(e, null);
270
+ }
271
+ );
272
+ },
273
+ installApiKeys(success, fail) {
274
+ capiws_default.apikey(
275
+ EIMZOClient.API_KEYS,
276
+ (event, data) => {
277
+ if (data.success) {
278
+ success();
279
+ } else {
280
+ fail(null, data.reason || "Unknown error");
281
+ }
282
+ },
283
+ (e) => {
284
+ fail(e, null);
285
+ }
286
+ );
287
+ },
288
+ listAllUserKeys(itemIdGen, itemUiGen, success, fail) {
289
+ const items = [];
290
+ const errors = [];
291
+ if (!EIMZOClient.NEW_API) {
292
+ fail(null, "Please install new version of E-IMZO");
293
+ } else {
294
+ if (EIMZOClient.NEW_API2) {
295
+ EIMZOClient._findPfxs2(itemIdGen, itemUiGen, items, errors, (firstItmId2) => {
296
+ if (items.length === 0 && errors.length > 0) {
297
+ const firstError = errors[0];
298
+ if (firstError) {
299
+ fail(firstError.e, firstError.r || null);
300
+ }
301
+ } else {
302
+ let firstId = null;
303
+ if (items.length === 1 && firstItmId2) {
304
+ firstId = firstItmId2;
305
+ }
306
+ success(items, firstId);
307
+ }
308
+ });
309
+ } else {
310
+ EIMZOClient._findPfxs2(itemIdGen, itemUiGen, items, errors, (firstItmId2) => {
311
+ EIMZOClient._findTokens2(itemIdGen, itemUiGen, items, errors, (firstItmId3) => {
312
+ if (items.length === 0 && errors.length > 0) {
313
+ const firstError = errors[0];
314
+ if (firstError) {
315
+ fail(firstError.e, firstError.r || null);
316
+ }
317
+ } else {
318
+ let firstId = null;
319
+ if (items.length === 1) {
320
+ if (firstItmId2) {
321
+ firstId = firstItmId2;
322
+ } else if (firstItmId3) {
323
+ firstId = firstItmId3;
324
+ }
325
+ }
326
+ success(items, firstId);
327
+ }
328
+ });
329
+ });
330
+ }
331
+ }
332
+ },
333
+ idCardIsPLuggedIn(success, fail) {
334
+ if (!EIMZOClient.NEW_API2) {
335
+ console.log("E-IMZO version should be 4.12 or newer");
336
+ success(false);
337
+ } else {
338
+ capiws_default.callFunction(
339
+ { plugin: "idcard", name: "list_readers" },
340
+ (event, data) => {
341
+ if (data.success) {
342
+ success((data.readers?.length || 0) > 0);
343
+ } else {
344
+ fail(null, data.reason || "Unknown error");
345
+ }
346
+ },
347
+ (e) => {
348
+ fail(e, null);
349
+ }
350
+ );
351
+ }
352
+ },
353
+ loadKey(itemObject, success, fail, verifyPassword) {
354
+ if (itemObject) {
355
+ const vo = itemObject;
356
+ if (vo.type === "pfx") {
357
+ capiws_default.callFunction(
358
+ {
359
+ plugin: "pfx",
360
+ name: "load_key",
361
+ arguments: [vo.disk, vo.path, vo.name, vo.alias]
362
+ },
363
+ (event, data) => {
364
+ if (data.success && data.keyId) {
365
+ const id = data.keyId;
366
+ if (verifyPassword) {
367
+ capiws_default.callFunction(
368
+ { name: "verify_password", plugin: "pfx", arguments: [id] },
369
+ (event2, data2) => {
370
+ if (data2.success) {
371
+ success(id);
372
+ } else {
373
+ fail(null, data2.reason || "Password verification failed");
374
+ }
375
+ },
376
+ (e) => {
377
+ fail(e, null);
378
+ }
379
+ );
380
+ } else {
381
+ success(id);
382
+ }
383
+ } else {
384
+ fail(null, data.reason || "Failed to load key");
385
+ }
386
+ },
387
+ (e) => {
388
+ fail(e, null);
389
+ }
390
+ );
391
+ } else if (vo.type === "ftjc") {
392
+ capiws_default.callFunction(
393
+ { plugin: "ftjc", name: "load_key", arguments: [vo.cardUID] },
394
+ (event, data) => {
395
+ if (data.success && data.keyId) {
396
+ const id = data.keyId;
397
+ if (verifyPassword) {
398
+ capiws_default.callFunction(
399
+ { plugin: "ftjc", name: "verify_pin", arguments: [id, "1"] },
400
+ (event2, data2) => {
401
+ if (data2.success) {
402
+ success(id);
403
+ } else {
404
+ fail(null, data2.reason || "PIN verification failed");
405
+ }
406
+ },
407
+ (e) => {
408
+ fail(e, null);
409
+ }
410
+ );
411
+ } else {
412
+ success(id);
413
+ }
414
+ } else {
415
+ fail(null, data.reason || "Failed to load key");
416
+ }
417
+ },
418
+ (e) => {
419
+ fail(e, null);
420
+ }
421
+ );
422
+ }
423
+ }
424
+ },
425
+ changeKeyPassword(itemObject, success, fail) {
426
+ if (itemObject) {
427
+ const vo = itemObject;
428
+ if (vo.type === "pfx") {
429
+ capiws_default.callFunction(
430
+ {
431
+ plugin: "pfx",
432
+ name: "load_key",
433
+ arguments: [vo.disk, vo.path, vo.name, vo.alias]
434
+ },
435
+ (event, data) => {
436
+ if (data.success && data.keyId) {
437
+ const id = data.keyId;
438
+ capiws_default.callFunction(
439
+ { name: "change_password", plugin: "pfx", arguments: [id] },
440
+ (event2, data2) => {
441
+ if (data2.success) {
442
+ success();
443
+ } else {
444
+ fail(null, data2.reason || "Failed to change password");
445
+ }
446
+ },
447
+ (e) => {
448
+ fail(e, null);
449
+ }
450
+ );
451
+ } else {
452
+ fail(null, data.reason || "Failed to load key");
453
+ }
454
+ },
455
+ (e) => {
456
+ fail(e, null);
457
+ }
458
+ );
459
+ } else if (vo.type === "ftjc") {
460
+ capiws_default.callFunction(
461
+ { plugin: "ftjc", name: "load_key", arguments: [vo.cardUID] },
462
+ (event, data) => {
463
+ if (data.success && data.keyId) {
464
+ const id = data.keyId;
465
+ capiws_default.callFunction(
466
+ { name: "change_pin", plugin: "ftjc", arguments: [id, "1"] },
467
+ (event2, data2) => {
468
+ if (data2.success) {
469
+ success();
470
+ } else {
471
+ fail(null, data2.reason || "Failed to change PIN");
472
+ }
473
+ },
474
+ (e) => {
475
+ fail(e, null);
476
+ }
477
+ );
478
+ } else {
479
+ fail(null, data.reason || "Failed to load key");
480
+ }
481
+ },
482
+ (e) => {
483
+ fail(e, null);
484
+ }
485
+ );
486
+ }
487
+ }
488
+ },
489
+ createPkcs7(id, data, timestamper, success, fail, detached, isDataBase64Encoded) {
490
+ let data64;
491
+ if (isDataBase64Encoded === true) {
492
+ data64 = data;
493
+ } else {
494
+ data64 = globalThis.Base64?.encode(data) || btoa(data);
495
+ }
496
+ const detachedStr = detached === true ? "yes" : "no";
497
+ capiws_default.callFunction(
498
+ {
499
+ plugin: "pkcs7",
500
+ name: "create_pkcs7",
501
+ arguments: [data64, id, detachedStr]
502
+ },
503
+ (event, data2) => {
504
+ if (data2.success && data2.pkcs7_64) {
505
+ const pkcs7 = data2.pkcs7_64;
506
+ success(pkcs7);
507
+ } else {
508
+ fail(null, data2.reason || "Failed to create PKCS7");
509
+ }
510
+ },
511
+ (e) => {
512
+ fail(e, null);
513
+ }
514
+ );
515
+ },
516
+ _getX500Val(s, f) {
517
+ const res = s.splitKeep(/,[A-Z]+=/g, true);
518
+ for (const i in res) {
519
+ const resItem = res[i];
520
+ if (resItem) {
521
+ const n = resItem.search((parseInt(i) > 0 ? "," : "") + f + "=");
522
+ if (n !== -1) {
523
+ return resItem.slice(n + f.length + 1 + (parseInt(i) > 0 ? 1 : 0));
524
+ }
525
+ }
526
+ }
527
+ return "";
528
+ },
529
+ _findPfxs2(itemIdGen, itemUiGen, items, errors, callback) {
530
+ let itmkey0;
531
+ capiws_default.callFunction(
532
+ { plugin: "pfx", name: "list_all_certificates" },
533
+ (event, data) => {
534
+ if (data.success && data.certificates) {
535
+ for (const rec in data.certificates) {
536
+ const el = data.certificates[rec];
537
+ if (!el) continue;
538
+ let x500name_ex = el.alias.toUpperCase();
539
+ x500name_ex = x500name_ex.replace("1.2.860.3.16.1.1=", "INN=");
540
+ x500name_ex = x500name_ex.replace("1.2.860.3.16.1.2=", "PINFL=");
541
+ const vo = {
542
+ disk: el.disk,
543
+ path: el.path,
544
+ name: el.name,
545
+ alias: el.alias,
546
+ serialNumber: EIMZOClient._getX500Val(x500name_ex, "SERIALNUMBER"),
547
+ validFrom: new Date(
548
+ EIMZOClient._getX500Val(x500name_ex, "VALIDFROM").replace(/\./g, "-").replace(" ", "T")
549
+ ),
550
+ validTo: new Date(
551
+ EIMZOClient._getX500Val(x500name_ex, "VALIDTO").replace(/\./g, "-").replace(" ", "T")
552
+ ),
553
+ CN: EIMZOClient._getX500Val(x500name_ex, "CN"),
554
+ TIN: EIMZOClient._getX500Val(x500name_ex, "INN") || EIMZOClient._getX500Val(x500name_ex, "UID"),
555
+ UID: EIMZOClient._getX500Val(x500name_ex, "UID"),
556
+ PINFL: EIMZOClient._getX500Val(x500name_ex, "PINFL"),
557
+ O: EIMZOClient._getX500Val(x500name_ex, "O"),
558
+ T: EIMZOClient._getX500Val(x500name_ex, "T"),
559
+ type: "pfx"
560
+ };
561
+ if (!vo.TIN && !vo.PINFL) continue;
562
+ const itmkey = itemIdGen(vo, rec);
563
+ if (!itmkey0) {
564
+ itmkey0 = itmkey;
565
+ }
566
+ const itm = itemUiGen(itmkey, vo);
567
+ items.push(itm);
568
+ }
569
+ } else {
570
+ errors.push({ r: data.reason || "Failed to list certificates" });
571
+ }
572
+ callback(itmkey0);
573
+ },
574
+ (e) => {
575
+ errors.push({ e });
576
+ callback(itmkey0);
577
+ }
578
+ );
579
+ },
580
+ _findTokens2(itemIdGen, itemUiGen, items, errors, callback) {
581
+ let itmkey0;
582
+ capiws_default.callFunction(
583
+ { plugin: "ftjc", name: "list_all_keys", arguments: [""] },
584
+ (event, data) => {
585
+ if (data.success && data.tokens) {
586
+ for (const rec in data.tokens) {
587
+ const el = data.tokens[rec];
588
+ if (!el) continue;
589
+ let x500name_ex = el.info.toUpperCase();
590
+ x500name_ex = x500name_ex.replace("1.2.860.3.16.1.1=", "INN=");
591
+ x500name_ex = x500name_ex.replace("1.2.860.3.16.1.2=", "PINFL=");
592
+ const vo = {
593
+ cardUID: el.cardUID,
594
+ statusInfo: el.statusInfo,
595
+ ownerName: el.ownerName,
596
+ info: el.info,
597
+ serialNumber: EIMZOClient._getX500Val(x500name_ex, "SERIALNUMBER"),
598
+ validFrom: new Date(EIMZOClient._getX500Val(x500name_ex, "VALIDFROM")),
599
+ validTo: new Date(EIMZOClient._getX500Val(x500name_ex, "VALIDTO")),
600
+ CN: EIMZOClient._getX500Val(x500name_ex, "CN"),
601
+ TIN: EIMZOClient._getX500Val(x500name_ex, "INN") || EIMZOClient._getX500Val(x500name_ex, "UID"),
602
+ UID: EIMZOClient._getX500Val(x500name_ex, "UID"),
603
+ PINFL: EIMZOClient._getX500Val(x500name_ex, "PINFL"),
604
+ O: EIMZOClient._getX500Val(x500name_ex, "O"),
605
+ T: EIMZOClient._getX500Val(x500name_ex, "T"),
606
+ type: "ftjc"
607
+ };
608
+ if (!vo.TIN && !vo.PINFL) continue;
609
+ const itmkey = itemIdGen(vo, rec);
610
+ if (!itmkey0) {
611
+ itmkey0 = itmkey;
612
+ }
613
+ const itm = itemUiGen(itmkey, vo);
614
+ items.push(itm);
615
+ }
616
+ } else {
617
+ errors.push({ r: data.reason || "Failed to list tokens" });
618
+ }
619
+ callback(itmkey0);
620
+ },
621
+ (e) => {
622
+ errors.push({ e });
623
+ callback(itmkey0);
624
+ }
625
+ );
626
+ }
627
+ };
628
+ var e_imzo_client_default = EIMZOClient;
629
+
630
+ // src/core/plugin-base.ts
631
+ var EIMZOPlugin = class {
632
+ version = "1.0.0";
633
+ description = "";
634
+ /**
635
+ * Execute a plugin method call through CAPIWS
636
+ */
637
+ callMethod(methodName, args = [], onSuccess, onError) {
638
+ const call = {
639
+ plugin: this.name,
640
+ name: methodName,
641
+ ...args.length > 0 && { arguments: args }
642
+ };
643
+ capiws_default.callFunction(call, onSuccess, onError);
644
+ }
645
+ /**
646
+ * Create a promise-based wrapper for plugin methods
647
+ */
648
+ createPromiseMethod(methodName) {
649
+ return (...args) => {
650
+ return new Promise((resolve, reject) => {
651
+ this.callMethod(
652
+ methodName,
653
+ args,
654
+ (_event, data) => {
655
+ if (data.success) {
656
+ resolve(data);
657
+ } else {
658
+ reject(new Error(data.reason ?? "Unknown error"));
659
+ }
660
+ },
661
+ (error) => reject(error instanceof Error ? error : new Error(String(error)))
662
+ );
663
+ });
664
+ };
665
+ }
666
+ /**
667
+ * Create both callback and promise versions of a method
668
+ */
669
+ createMethod(methodName) {
670
+ const promiseMethod = this.createPromiseMethod(methodName);
671
+ const callbackMethod = (...args) => {
672
+ const methodArgs = args.slice(0, -2);
673
+ const onSuccess = args[args.length - 2];
674
+ const onError = args[args.length - 1];
675
+ this.callMethod(methodName, methodArgs, onSuccess, onError);
676
+ };
677
+ return {
678
+ promise: promiseMethod,
679
+ callback: callbackMethod
680
+ };
681
+ }
682
+ };
683
+ var PluginManager = class {
684
+ static plugins = /* @__PURE__ */ new Map();
685
+ static register(plugin) {
686
+ this.plugins.set(plugin.name, plugin);
687
+ }
688
+ static get(name) {
689
+ return this.plugins.get(name);
690
+ }
691
+ static getAll() {
692
+ return Array.from(this.plugins.values());
693
+ }
694
+ static has(name) {
695
+ return this.plugins.has(name);
696
+ }
697
+ };
698
+ function RegisterPlugin(constructor) {
699
+ const instance = new constructor();
700
+ PluginManager.register(instance);
701
+ return constructor;
702
+ }
703
+
704
+ // src/plugins/certkey.ts
705
+ var _CertKeyPlugin_decorators, _init, _a;
706
+ _CertKeyPlugin_decorators = [RegisterPlugin];
707
+ var CertKeyPlugin = class extends (_a = EIMZOPlugin) {
708
+ name = "certkey";
709
+ description = "Plugin for working with electronic keys and certificates";
710
+ /**
711
+ * Удалить загруженные ключи по идентификатору
712
+ */
713
+ unloadKey = (keyId, onSuccess, onError) => {
714
+ this.callMethod("unload_key", [keyId], onSuccess, onError);
715
+ };
716
+ /**
717
+ * Получить список дисков
718
+ */
719
+ listDisks = (onSuccess, onError) => {
720
+ this.callMethod("list_disks", [], onSuccess, onError);
721
+ };
722
+ /**
723
+ * Получить список сертификатов пользователя
724
+ */
725
+ listCertificates = (diskPath, onSuccess, onError) => {
726
+ this.callMethod("list_certificates", [diskPath], onSuccess, onError);
727
+ };
728
+ /**
729
+ * Получить список всех сертификатов пользователя
730
+ */
731
+ listAllCertificates = (onSuccess, onError) => {
732
+ this.callMethod("list_all_certificates", [], onSuccess, onError);
733
+ };
734
+ /**
735
+ * Загрузить ключ и получить идентификатор ключа
736
+ */
737
+ loadKey = (keyPath, password, onSuccess, onError) => {
738
+ this.callMethod("load_key", [keyPath, password], onSuccess, onError);
739
+ };
740
+ };
741
+ _init = __decoratorStart(_a);
742
+ CertKeyPlugin = __decorateElement(_init, 0, "CertKeyPlugin", _CertKeyPlugin_decorators, CertKeyPlugin);
743
+ __runInitializers(_init, 1, CertKeyPlugin);
744
+
745
+ // src/plugins/cipher.ts
746
+ var _CipherPlugin_decorators, _init2, _a2;
747
+ _CipherPlugin_decorators = [RegisterPlugin];
748
+ var CipherPlugin = class extends (_a2 = EIMZOPlugin) {
749
+ name = "cipher";
750
+ description = "Plugin for encryption/decryption using GOST-28147 and ECDH-SHA256";
751
+ /**
752
+ * Создать зашифрованный документ
753
+ */
754
+ encryptDocument = (data, recipientCertificate, senderKeyId, onSuccess, onError) => {
755
+ this.callMethod(
756
+ "encrypt_document",
757
+ [data, recipientCertificate, senderKeyId],
758
+ onSuccess,
759
+ onError
760
+ );
761
+ };
762
+ /**
763
+ * Дешифровать зашифрованный документ
764
+ */
765
+ decryptDocument = (encryptedData, recipientKeyId, onSuccess, onError) => {
766
+ this.callMethod("decrypt_document", [encryptedData, recipientKeyId], onSuccess, onError);
767
+ };
768
+ };
769
+ _init2 = __decoratorStart(_a2);
770
+ CipherPlugin = __decorateElement(_init2, 0, "CipherPlugin", _CipherPlugin_decorators, CipherPlugin);
771
+ __runInitializers(_init2, 1, CipherPlugin);
772
+
773
+ // src/plugins/crl.ts
774
+ var _CRLPlugin_decorators, _init3, _a3;
775
+ _CRLPlugin_decorators = [RegisterPlugin];
776
+ var CRLPlugin = class extends (_a3 = EIMZOPlugin) {
777
+ name = "crl";
778
+ description = "Plugin for working with Certificate Revocation Lists";
779
+ /**
780
+ * Открывает CRL
781
+ */
782
+ openCrl = (crlData, onSuccess, onError) => {
783
+ this.callMethod("open_crl", [crlData], onSuccess, onError);
784
+ };
785
+ /**
786
+ * Открывает CRL из файла
787
+ */
788
+ openCrlFile = (filePath, onSuccess, onError) => {
789
+ this.callMethod("open_crl_file", [filePath], onSuccess, onError);
790
+ };
791
+ /**
792
+ * Проверка статуса сертификата по CRL
793
+ */
794
+ checkCertificate = (certificate, crlId, onSuccess, onError) => {
795
+ this.callMethod("check_certificate", [certificate, crlId], onSuccess, onError);
796
+ };
797
+ /**
798
+ * Получить информацию о CRL
799
+ */
800
+ getCrlInfo = (crlId, onSuccess, onError) => {
801
+ this.callMethod("get_crl_info", [crlId], onSuccess, onError);
802
+ };
803
+ /**
804
+ * Верификация CRL
805
+ */
806
+ verifyCrl = (crlId, issuerCertificate, onSuccess, onError) => {
807
+ this.callMethod("verify_crl", [crlId, issuerCertificate], onSuccess, onError);
808
+ };
809
+ };
810
+ _init3 = __decoratorStart(_a3);
811
+ CRLPlugin = __decorateElement(_init3, 0, "CRLPlugin", _CRLPlugin_decorators, CRLPlugin);
812
+ __runInitializers(_init3, 1, CRLPlugin);
813
+
814
+ // src/plugins/cryptoauth.ts
815
+ var _CryptoAuthPlugin_decorators, _init4, _a4;
816
+ _CryptoAuthPlugin_decorators = [RegisterPlugin];
817
+ var CryptoAuthPlugin = class extends (_a4 = EIMZOPlugin) {
818
+ name = "cryptoauth";
819
+ description = "Plugin for low-level cryptographic operations";
820
+ /**
821
+ * Подписать данные ключем задаваемым идентификатором
822
+ */
823
+ getSignature = (keyId, data, onSuccess, onError) => {
824
+ this.callMethod("get_signature", [keyId, data], onSuccess, onError);
825
+ };
826
+ /**
827
+ * Вычислить хеш (в формате HEX) данных по алгоритму OZDST-1106-2009-2-A
828
+ */
829
+ getDigestHex = (data, onSuccess, onError) => {
830
+ this.callMethod("get_digest_hex", [data], onSuccess, onError);
831
+ };
832
+ /**
833
+ * Верифицировать подпись данных сертификатом
834
+ */
835
+ verifySignatureWithCertificate = (data, signature, certificate, onSuccess, onError) => {
836
+ this.callMethod(
837
+ "verify_signature_with_certificate",
838
+ [data, signature, certificate],
839
+ onSuccess,
840
+ onError
841
+ );
842
+ };
843
+ /**
844
+ * Верифицировать подпись хеша (в формате HEX) ключем задаваемым идентификатором
845
+ */
846
+ verifyDigestHexSignatureWithId = (digestHex, signature, keyId, onSuccess, onError) => {
847
+ this.callMethod(
848
+ "verify_digest_hex_signature_with_id",
849
+ [digestHex, signature, keyId],
850
+ onSuccess,
851
+ onError
852
+ );
853
+ };
854
+ /**
855
+ * Подписать хеш (в формате HEX) ключем задаваемым идентификатором
856
+ */
857
+ getDigestHexSignature = (digestHex, keyId, onSuccess, onError) => {
858
+ this.callMethod("get_digest_hex_signature", [digestHex, keyId], onSuccess, onError);
859
+ };
860
+ /**
861
+ * Верифицировать подпись данных ключем задаваемым идентификатором
862
+ */
863
+ verifySignatureWithId = (data, signature, keyId, onSuccess, onError) => {
864
+ this.callMethod("verify_signature_with_id", [data, signature, keyId], onSuccess, onError);
865
+ };
866
+ /**
867
+ * Верифицировать подпись хеша (в формате HEX) сертификатом
868
+ */
869
+ verifyDigestHexSignatureWithCertificate = (digestHex, signature, certificate, onSuccess, onError) => {
870
+ this.callMethod(
871
+ "verify_digest_hex_signature_with_certificate",
872
+ [digestHex, signature, certificate],
873
+ onSuccess,
874
+ onError
875
+ );
876
+ };
877
+ };
878
+ _init4 = __decoratorStart(_a4);
879
+ CryptoAuthPlugin = __decorateElement(_init4, 0, "CryptoAuthPlugin", _CryptoAuthPlugin_decorators, CryptoAuthPlugin);
880
+ __runInitializers(_init4, 1, CryptoAuthPlugin);
881
+
882
+ // src/plugins/fileio.ts
883
+ var _FileIOPlugin_decorators, _init5, _a5;
884
+ _FileIOPlugin_decorators = [RegisterPlugin];
885
+ var FileIOPlugin = class extends (_a5 = EIMZOPlugin) {
886
+ name = "fileio";
887
+ description = "Plugin for file input/output operations";
888
+ /**
889
+ * Загруить файл
890
+ */
891
+ loadFile = (filePath, onSuccess, onError) => {
892
+ this.callMethod("load_file", [filePath], onSuccess, onError);
893
+ };
894
+ /**
895
+ * Записать содержимое zip файла на диск
896
+ */
897
+ writeFile = (zipContent, destinationPath, onSuccess, onError) => {
898
+ this.callMethod("write_file", [zipContent, destinationPath], onSuccess, onError);
899
+ };
900
+ };
901
+ _init5 = __decoratorStart(_a5);
902
+ FileIOPlugin = __decorateElement(_init5, 0, "FileIOPlugin", _FileIOPlugin_decorators, FileIOPlugin);
903
+ __runInitializers(_init5, 1, FileIOPlugin);
904
+
905
+ // src/plugins/ftjc.ts
906
+ var _FtjcPlugin_decorators, _init6, _a6;
907
+ _FtjcPlugin_decorators = [RegisterPlugin];
908
+ var FtjcPlugin = class extends (_a6 = EIMZOPlugin) {
909
+ name = "ftjc";
910
+ description = "Plugin for working with USB FT Javacard tokens - STUB";
911
+ // Callback-based methods
912
+ /**
913
+ * Get list of all keys from connected tokens
914
+ */
915
+ listAllKeys = (exceptCards = "", onSuccess, onError) => {
916
+ this.callMethod("list_all_keys", [exceptCards], onSuccess, onError);
917
+ };
918
+ /**
919
+ * Get list of tokens
920
+ */
921
+ listTokens = (onSuccess, onError) => {
922
+ this.callMethod("list_tokens", [], onSuccess, onError);
923
+ };
924
+ /**
925
+ * Load key and get key identifier
926
+ */
927
+ loadKey = (cardUID, onSuccess, onError) => {
928
+ this.callMethod("load_key", [cardUID], onSuccess, onError);
929
+ };
930
+ /**
931
+ * Unload key by identifier
932
+ */
933
+ unloadKey = (tokenId, onSuccess, onError) => {
934
+ this.callMethod("unload_key", [tokenId], onSuccess, onError);
935
+ };
936
+ /**
937
+ * Verify PIN code of token
938
+ * @param pinType 0 - Initialization, 1 - User, 2 - Reset
939
+ */
940
+ verifyPin = (tokenId, pinType, onSuccess, onError) => {
941
+ this.callMethod("verify_pin", [tokenId, pinType], onSuccess, onError);
942
+ };
943
+ /**
944
+ * Change PIN code of token
945
+ * @param pinType 0 - Initialization, 1 - User, 2 - Reset
946
+ */
947
+ changePin = (tokenId, pinType, onSuccess, onError) => {
948
+ this.callMethod("change_pin", [tokenId, pinType], onSuccess, onError);
949
+ };
950
+ /**
951
+ * Set name for USB token
952
+ */
953
+ setName = (tokenId, name, onSuccess, onError) => {
954
+ this.callMethod("set_name", [tokenId, name], onSuccess, onError);
955
+ };
956
+ /**
957
+ * Store certificates in USB token
958
+ */
959
+ storeCertificates = (tokenId, subjectCertificate64, caCertificate64, rootCertificate64, onSuccess, onError) => {
960
+ this.callMethod(
961
+ "store_certificates",
962
+ [tokenId, subjectCertificate64, caCertificate64, rootCertificate64],
963
+ onSuccess,
964
+ onError
965
+ );
966
+ };
967
+ /**
968
+ * Get user data from token
969
+ */
970
+ getUserData = (tokenId, onSuccess, onError) => {
971
+ this.callMethod("get_user_data", [tokenId], onSuccess, onError);
972
+ };
973
+ /**
974
+ * Set or delete user data in token
975
+ * @param data64 Data in BASE64 encoding or empty string to delete
976
+ */
977
+ setUserData = (tokenId, data64, onSuccess, onError) => {
978
+ this.callMethod("set_user_data", [tokenId, data64], onSuccess, onError);
979
+ };
980
+ /**
981
+ * Generate random data in USB token
982
+ */
983
+ getRandomData = (tokenId, onSuccess, onError) => {
984
+ this.callMethod("get_random_data", [tokenId], onSuccess, onError);
985
+ };
986
+ /**
987
+ * Install applet in USB token
988
+ */
989
+ installApplet = (cardUID, applet64, signatureHex, onSuccess, onError) => {
990
+ this.callMethod("install_applet", [cardUID, applet64, signatureHex], onSuccess, onError);
991
+ };
992
+ // Promise-based methods
993
+ /**
994
+ * List all keys (Promise version)
995
+ */
996
+ listAllKeysAsync = this.createPromiseMethod("list_all_keys");
997
+ /**
998
+ * List tokens (Promise version)
999
+ */
1000
+ listTokensAsync = this.createPromiseMethod("list_tokens");
1001
+ /**
1002
+ * Load key (Promise version)
1003
+ */
1004
+ loadKeyAsync = this.createPromiseMethod("load_key");
1005
+ /**
1006
+ * Unload key (Promise version)
1007
+ */
1008
+ unloadKeyAsync = this.createPromiseMethod("unload_key");
1009
+ /**
1010
+ * Verify PIN (Promise version)
1011
+ */
1012
+ verifyPinAsync = this.createPromiseMethod(
1013
+ "verify_pin"
1014
+ );
1015
+ /**
1016
+ * Change PIN (Promise version)
1017
+ */
1018
+ changePinAsync = this.createPromiseMethod(
1019
+ "change_pin"
1020
+ );
1021
+ /**
1022
+ * Set name (Promise version)
1023
+ */
1024
+ setNameAsync = this.createPromiseMethod("set_name");
1025
+ /**
1026
+ * Store certificates (Promise version)
1027
+ */
1028
+ storeCertificatesAsync = this.createPromiseMethod("store_certificates");
1029
+ /**
1030
+ * Get user data (Promise version)
1031
+ */
1032
+ getUserDataAsync = this.createPromiseMethod("get_user_data");
1033
+ /**
1034
+ * Set user data (Promise version)
1035
+ */
1036
+ setUserDataAsync = this.createPromiseMethod("set_user_data");
1037
+ /**
1038
+ * Get random data (Promise version)
1039
+ */
1040
+ getRandomDataAsync = this.createPromiseMethod("get_random_data");
1041
+ /**
1042
+ * Install applet (Promise version)
1043
+ */
1044
+ installAppletAsync = this.createPromiseMethod(
1045
+ "install_applet"
1046
+ );
1047
+ };
1048
+ _init6 = __decoratorStart(_a6);
1049
+ FtjcPlugin = __decorateElement(_init6, 0, "FtjcPlugin", _FtjcPlugin_decorators, FtjcPlugin);
1050
+ __runInitializers(_init6, 1, FtjcPlugin);
1051
+ var ftjcPlugin = new FtjcPlugin();
1052
+
1053
+ // src/plugins/idcard.ts
1054
+ var _IDCardPlugin_decorators, _init7, _a7;
1055
+ _IDCardPlugin_decorators = [RegisterPlugin];
1056
+ var IDCardPlugin = class extends (_a7 = EIMZOPlugin) {
1057
+ name = "idcard";
1058
+ description = "Plugin for working with E-IMZO ID cards";
1059
+ /**
1060
+ * Проверить пароль хранилища ключей (заглушка)
1061
+ */
1062
+ verifyPassword = (password, onSuccess, onError) => {
1063
+ this.callMethod("verify_password", [password], onSuccess, onError);
1064
+ };
1065
+ /**
1066
+ * Персонализировать ID-карту записав новые сертификаты и установив PIN-код
1067
+ */
1068
+ personalize = (certificates, pinCode, onSuccess, onError) => {
1069
+ this.callMethod("personalize", [certificates, pinCode], onSuccess, onError);
1070
+ };
1071
+ /**
1072
+ * Получить список считывателей
1073
+ */
1074
+ listReaders = (onSuccess, onError) => {
1075
+ this.callMethod("list_readers", [], onSuccess, onError);
1076
+ };
1077
+ /**
1078
+ * Получить список всех сертификатов пользователя (заглушка)
1079
+ */
1080
+ listAllCertificates = (onSuccess, onError) => {
1081
+ this.callMethod("list_all_certificates", [], onSuccess, onError);
1082
+ };
1083
+ /**
1084
+ * Получить зашифрованный и подписанный заводской номер USB-токена
1085
+ */
1086
+ getEncryptedSignedCplc = (onSuccess, onError) => {
1087
+ this.callMethod("get_encrypted_signed_cplc", [], onSuccess, onError);
1088
+ };
1089
+ /**
1090
+ * Загрузить ключ и получить идентификатор ключа. Ключ будет доступен определенное время (заглушка)
1091
+ */
1092
+ loadKey = (cardIndex, password, onSuccess, onError) => {
1093
+ this.callMethod("load_key", [cardIndex, password], onSuccess, onError);
1094
+ };
1095
+ };
1096
+ _init7 = __decoratorStart(_a7);
1097
+ IDCardPlugin = __decorateElement(_init7, 0, "IDCardPlugin", _IDCardPlugin_decorators, IDCardPlugin);
1098
+ __runInitializers(_init7, 1, IDCardPlugin);
1099
+
1100
+ // src/plugins/pfx.ts
1101
+ var _PfxPlugin_decorators, _init8, _a8;
1102
+ _PfxPlugin_decorators = [RegisterPlugin];
1103
+ var PfxPlugin = class extends (_a8 = EIMZOPlugin) {
1104
+ name = "pfx";
1105
+ description = "Plugin for working with PFX key storage files";
1106
+ // Callback-based methods
1107
+ /**
1108
+ * Get list of available disks
1109
+ */
1110
+ listDisks = (onSuccess, onError) => {
1111
+ this.callMethod("list_disks", [], onSuccess, onError);
1112
+ };
1113
+ /**
1114
+ * Get list of certificates from specific disk
1115
+ */
1116
+ listCertificates = (disk, onSuccess, onError) => {
1117
+ this.callMethod("list_certificates", [disk], onSuccess, onError);
1118
+ };
1119
+ /**
1120
+ * Get list of all certificates from all disks
1121
+ */
1122
+ listAllCertificates = (onSuccess, onError) => {
1123
+ this.callMethod("list_all_certificates", [], onSuccess, onError);
1124
+ };
1125
+ /**
1126
+ * Load key and get key identifier
1127
+ */
1128
+ loadKey = (disk, path, name, alias, onSuccess, onError) => {
1129
+ this.callMethod("load_key", [disk, path, name, alias], onSuccess, onError);
1130
+ };
1131
+ /**
1132
+ * Unload key by identifier
1133
+ */
1134
+ unloadKey = (keyId, onSuccess, onError) => {
1135
+ this.callMethod("unload_key", [keyId], onSuccess, onError);
1136
+ };
1137
+ /**
1138
+ * Verify password for key storage
1139
+ */
1140
+ verifyPassword = (keyId, onSuccess, onError) => {
1141
+ this.callMethod("verify_password", [keyId], onSuccess, onError);
1142
+ };
1143
+ /**
1144
+ * Change password for key storage
1145
+ */
1146
+ changePassword = (keyId, onSuccess, onError) => {
1147
+ this.callMethod("change_password", [keyId], onSuccess, onError);
1148
+ };
1149
+ /**
1150
+ * Save key pair and certificates to new PFX file
1151
+ */
1152
+ savePfx = (disk, path, name, alias, id, newKeyPassword, subjectCertificate64, caCertificate64, rootCertificate64, onSuccess, onError) => {
1153
+ this.callMethod(
1154
+ "save_pfx",
1155
+ [
1156
+ disk,
1157
+ path,
1158
+ name,
1159
+ alias,
1160
+ id,
1161
+ newKeyPassword,
1162
+ subjectCertificate64,
1163
+ caCertificate64,
1164
+ rootCertificate64
1165
+ ],
1166
+ onSuccess,
1167
+ onError
1168
+ );
1169
+ };
1170
+ /**
1171
+ * Save temporary PFX with self-signed certificate
1172
+ */
1173
+ saveTemporaryPfx = (disk, path, name, alias, id, password, subjectX500Name, onSuccess, onError) => {
1174
+ this.callMethod(
1175
+ "save_temporary_pfx",
1176
+ [disk, path, name, alias, id, password, subjectX500Name],
1177
+ onSuccess,
1178
+ onError
1179
+ );
1180
+ };
1181
+ // Promise-based methods
1182
+ /**
1183
+ * Get list of available disks (Promise version)
1184
+ */
1185
+ listDisksAsync = this.createPromiseMethod("list_disks");
1186
+ /**
1187
+ * Get list of certificates from specific disk (Promise version)
1188
+ */
1189
+ listCertificatesAsync = this.createPromiseMethod("list_certificates");
1190
+ /**
1191
+ * Get list of all certificates (Promise version)
1192
+ */
1193
+ listAllCertificatesAsync = this.createPromiseMethod("list_all_certificates");
1194
+ /**
1195
+ * Load key (Promise version)
1196
+ */
1197
+ loadKeyAsync = this.createPromiseMethod(
1198
+ "load_key"
1199
+ );
1200
+ /**
1201
+ * Unload key (Promise version)
1202
+ */
1203
+ unloadKeyAsync = this.createPromiseMethod("unload_key");
1204
+ /**
1205
+ * Verify password (Promise version)
1206
+ */
1207
+ verifyPasswordAsync = this.createPromiseMethod("verify_password");
1208
+ /**
1209
+ * Change password (Promise version)
1210
+ */
1211
+ changePasswordAsync = this.createPromiseMethod("change_password");
1212
+ /**
1213
+ * Save PFX (Promise version)
1214
+ */
1215
+ savePfxAsync = this.createPromiseMethod("save_pfx");
1216
+ /**
1217
+ * Save temporary PFX (Promise version)
1218
+ */
1219
+ saveTemporaryPfxAsync = this.createPromiseMethod("save_temporary_pfx");
1220
+ };
1221
+ _init8 = __decoratorStart(_a8);
1222
+ PfxPlugin = __decorateElement(_init8, 0, "PfxPlugin", _PfxPlugin_decorators, PfxPlugin);
1223
+ __runInitializers(_init8, 1, PfxPlugin);
1224
+ var pfxPlugin = new PfxPlugin();
1225
+
1226
+ // src/plugins/pkcs10.ts
1227
+ var _PKCS10Plugin_decorators, _init9, _a9;
1228
+ _PKCS10Plugin_decorators = [RegisterPlugin];
1229
+ var PKCS10Plugin = class extends (_a9 = EIMZOPlugin) {
1230
+ name = "pkcs10";
1231
+ description = "Plugin for generating key pairs and PKCS#10 certificate requests";
1232
+ /**
1233
+ * Формировать запрос на сертификат формата PKCS#10 из существующего ключа
1234
+ */
1235
+ createPkcs10FromKey = (keyId, subject, onSuccess, onError) => {
1236
+ this.callMethod("create_pkcs10_from_key", [keyId, subject], onSuccess, onError);
1237
+ };
1238
+ /**
1239
+ * Сгенерировать ключевую пару
1240
+ */
1241
+ generateKeypair = (keySize, onSuccess, onError) => {
1242
+ this.callMethod("generate_keypair", [keySize], onSuccess, onError);
1243
+ };
1244
+ /**
1245
+ * Формировать запрос на сертификат формата PKCS#10
1246
+ */
1247
+ createPkcs10 = (subject, keySize, onSuccess, onError) => {
1248
+ this.callMethod("create_pkcs10", [subject, keySize], onSuccess, onError);
1249
+ };
1250
+ /**
1251
+ * Получить информацию о запросе PKCS#10
1252
+ */
1253
+ getPkcs10Info = (pkcs10, onSuccess, onError) => {
1254
+ this.callMethod("get_pkcs10_info", [pkcs10], onSuccess, onError);
1255
+ };
1256
+ };
1257
+ _init9 = __decoratorStart(_a9);
1258
+ PKCS10Plugin = __decorateElement(_init9, 0, "PKCS10Plugin", _PKCS10Plugin_decorators, PKCS10Plugin);
1259
+ __runInitializers(_init9, 1, PKCS10Plugin);
1260
+
1261
+ // src/plugins/pkcs7.ts
1262
+ var _Pkcs7Plugin_decorators, _init10, _a10;
1263
+ _Pkcs7Plugin_decorators = [RegisterPlugin];
1264
+ var Pkcs7Plugin = class extends (_a10 = EIMZOPlugin) {
1265
+ name = "pkcs7";
1266
+ description = "Plugin for working with PKCS#7/CMS format";
1267
+ // Callback-based methods
1268
+ /**
1269
+ * Create PKCS#7/CMS document by signing with key
1270
+ */
1271
+ createPkcs7 = (data64, keyId, detached = "", onSuccess, onError) => {
1272
+ this.callMethod("create_pkcs7", [data64, keyId, detached], onSuccess, onError);
1273
+ };
1274
+ /**
1275
+ * Get full information about PKCS#7/CMS document (attached)
1276
+ */
1277
+ getPkcs7AttachedInfo = (pkcs764, trustStoreId = "", onSuccess, onError) => {
1278
+ this.callMethod("get_pkcs7_attached_info", [pkcs764, trustStoreId], onSuccess, onError);
1279
+ };
1280
+ /**
1281
+ * Get full information about PKCS#7/CMS document (detached)
1282
+ */
1283
+ getPkcs7DetachedInfo = (data64, pkcs764, trustStoreId = "", onSuccess, onError) => {
1284
+ this.callMethod("get_pkcs7_detached_info", [data64, pkcs764, trustStoreId], onSuccess, onError);
1285
+ };
1286
+ /**
1287
+ * Verify PKCS#7/CMS document (attached) - STUB
1288
+ */
1289
+ verifyPkcs7Attached = (pkcs764, trustStoreId, requesterId = "", onSuccess, onError) => {
1290
+ this.callMethod(
1291
+ "verify_pkcs7_attached",
1292
+ [pkcs764, trustStoreId, requesterId],
1293
+ onSuccess,
1294
+ onError
1295
+ );
1296
+ };
1297
+ /**
1298
+ * Verify PKCS#7/CMS document (detached) - STUB
1299
+ */
1300
+ verifyPkcs7Detached = (data64, pkcs764, trustStoreId, requesterId = "", onSuccess, onError) => {
1301
+ this.callMethod(
1302
+ "verify_pkcs7_detached",
1303
+ [data64, pkcs764, trustStoreId, requesterId],
1304
+ onSuccess,
1305
+ onError
1306
+ );
1307
+ };
1308
+ /**
1309
+ * Verify PKCS#7/CMS document with CRL (attached) - STUB
1310
+ */
1311
+ verifyPkcs7AttachedCrl = (pkcs764, trustStoreId, crlId, onSuccess, onError) => {
1312
+ this.callMethod(
1313
+ "verify_pkcs7_attached_crl",
1314
+ [pkcs764, trustStoreId, crlId],
1315
+ onSuccess,
1316
+ onError
1317
+ );
1318
+ };
1319
+ /**
1320
+ * Verify PKCS#7/CMS document with CRL (detached) - STUB
1321
+ */
1322
+ verifyPkcs7DetachedCrl = (data64, pkcs764, trustStoreId, crlId, onSuccess, onError) => {
1323
+ this.callMethod(
1324
+ "verify_pkcs7_detached_crl",
1325
+ [data64, pkcs764, trustStoreId, crlId],
1326
+ onSuccess,
1327
+ onError
1328
+ );
1329
+ };
1330
+ /**
1331
+ * Attach timestamp token to PKCS#7/CMS document - STUB
1332
+ */
1333
+ attachTimestampTokenPkcs7 = (pkcs764, signerSerialNumber, timestampToken64, onSuccess, onError) => {
1334
+ this.callMethod(
1335
+ "attach_timestamp_token_pkcs7",
1336
+ [pkcs764, signerSerialNumber, timestampToken64],
1337
+ onSuccess,
1338
+ onError
1339
+ );
1340
+ };
1341
+ /**
1342
+ * Add signature to existing PKCS#7/CMS document (attached) - DEPRECATED
1343
+ */
1344
+ appendPkcs7Attached = (pkcs764, keyId, onSuccess, onError) => {
1345
+ this.callMethod("append_pkcs7_attached", [pkcs764, keyId], onSuccess, onError);
1346
+ };
1347
+ /**
1348
+ * Add signature to existing PKCS#7/CMS document (detached) - DEPRECATED
1349
+ */
1350
+ appendPkcs7Detached = (data64, pkcs764, keyId, onSuccess, onError) => {
1351
+ this.callMethod("append_pkcs7_detached", [data64, pkcs764, keyId], onSuccess, onError);
1352
+ };
1353
+ // Promise-based methods
1354
+ /**
1355
+ * Create PKCS#7/CMS document (Promise version)
1356
+ */
1357
+ createPkcs7Async = this.createPromiseMethod("create_pkcs7");
1358
+ /**
1359
+ * Get PKCS#7 attached info (Promise version)
1360
+ */
1361
+ getPkcs7AttachedInfoAsync = this.createPromiseMethod(
1362
+ "get_pkcs7_attached_info"
1363
+ );
1364
+ /**
1365
+ * Get PKCS#7 detached info (Promise version)
1366
+ */
1367
+ getPkcs7DetachedInfoAsync = this.createPromiseMethod("get_pkcs7_detached_info");
1368
+ /**
1369
+ * Verify PKCS#7 attached (Promise version)
1370
+ */
1371
+ verifyPkcs7AttachedAsync = this.createPromiseMethod("verify_pkcs7_attached");
1372
+ /**
1373
+ * Verify PKCS#7 detached (Promise version)
1374
+ */
1375
+ verifyPkcs7DetachedAsync = this.createPromiseMethod("verify_pkcs7_detached");
1376
+ /**
1377
+ * Attach timestamp token (Promise version)
1378
+ */
1379
+ attachTimestampTokenPkcs7Async = this.createPromiseMethod("attach_timestamp_token_pkcs7");
1380
+ };
1381
+ _init10 = __decoratorStart(_a10);
1382
+ Pkcs7Plugin = __decorateElement(_init10, 0, "Pkcs7Plugin", _Pkcs7Plugin_decorators, Pkcs7Plugin);
1383
+ __runInitializers(_init10, 1, Pkcs7Plugin);
1384
+ var pkcs7Plugin = new Pkcs7Plugin();
1385
+
1386
+ // src/plugins/pki.ts
1387
+ var _PKIPlugin_decorators, _init11, _a11;
1388
+ _PKIPlugin_decorators = [RegisterPlugin];
1389
+ var PKIPlugin = class extends (_a11 = EIMZOPlugin) {
1390
+ name = "pki";
1391
+ description = "Plugin for PKI (Public Key Infrastructure) interaction";
1392
+ /**
1393
+ * Шаг №1 для получения ключа PFX
1394
+ */
1395
+ enrollPfxStep1 = (request, onSuccess, onError) => {
1396
+ this.callMethod("enroll_pfx_step1", [request], onSuccess, onError);
1397
+ };
1398
+ /**
1399
+ * Шаг №2 для получения ключа PFX
1400
+ */
1401
+ enrollPfxStep2 = (response, onSuccess, onError) => {
1402
+ this.callMethod("enroll_pfx_step2", [response], onSuccess, onError);
1403
+ };
1404
+ };
1405
+ _init11 = __decoratorStart(_a11);
1406
+ PKIPlugin = __decorateElement(_init11, 0, "PKIPlugin", _PKIPlugin_decorators, PKIPlugin);
1407
+ __runInitializers(_init11, 1, PKIPlugin);
1408
+
1409
+ // src/plugins/truststore-jks.ts
1410
+ var _TruststoreJKSPlugin_decorators, _init12, _a12;
1411
+ _TruststoreJKSPlugin_decorators = [RegisterPlugin];
1412
+ var TruststoreJKSPlugin = class extends (_a12 = EIMZOPlugin) {
1413
+ name = "truststore-jks";
1414
+ description = "Plugin for working with JKS trust stores";
1415
+ /**
1416
+ * Открывает хранилище доверенных сертификатов 'truststore.jks' в домашней директории пользователя
1417
+ */
1418
+ openTruststore = (onSuccess, onError) => {
1419
+ this.callMethod("open_truststore", [], onSuccess, onError);
1420
+ };
1421
+ // Promise-based methods
1422
+ /**
1423
+ * Открывает хранилище доверенных сертификатов 'truststore.jks' в домашней директории пользователя
1424
+ */
1425
+ async openTruststoreAsync() {
1426
+ return new Promise((resolve, reject) => {
1427
+ this.openTruststore(
1428
+ (event, data) => {
1429
+ if (data.success) {
1430
+ resolve(data);
1431
+ } else {
1432
+ reject(new Error(data.reason ?? "Unknown error"));
1433
+ }
1434
+ },
1435
+ (error) => reject(new Error(String(error)))
1436
+ );
1437
+ });
1438
+ }
1439
+ };
1440
+ _init12 = __decoratorStart(_a12);
1441
+ TruststoreJKSPlugin = __decorateElement(_init12, 0, "TruststoreJKSPlugin", _TruststoreJKSPlugin_decorators, TruststoreJKSPlugin);
1442
+ __runInitializers(_init12, 1, TruststoreJKSPlugin);
1443
+
1444
+ // src/plugins/truststore.ts
1445
+ var _TruststorePlugin_decorators, _init13, _a13;
1446
+ _TruststorePlugin_decorators = [RegisterPlugin];
1447
+ var TruststorePlugin = class extends (_a13 = EIMZOPlugin) {
1448
+ name = "truststore";
1449
+ description = "Plugin for working with trust stores";
1450
+ /**
1451
+ * Получить список доверенных сертификатов (ЗАГЛУШКА)
1452
+ */
1453
+ listTruststore = (onSuccess, onError) => {
1454
+ this.callMethod("list_truststore", [], onSuccess, onError);
1455
+ };
1456
+ };
1457
+ _init13 = __decoratorStart(_a13);
1458
+ TruststorePlugin = __decorateElement(_init13, 0, "TruststorePlugin", _TruststorePlugin_decorators, TruststorePlugin);
1459
+ __runInitializers(_init13, 1, TruststorePlugin);
1460
+
1461
+ // src/plugins/tsaclient.ts
1462
+ var _TSAClientPlugin_decorators, _init14, _a14;
1463
+ _TSAClientPlugin_decorators = [RegisterPlugin];
1464
+ var TSAClientPlugin = class extends (_a14 = EIMZOPlugin) {
1465
+ name = "tsaclient";
1466
+ description = "Plugin for working with timestamp tokens";
1467
+ /**
1468
+ * Получить запрос на получения токена штампа времени для данных
1469
+ */
1470
+ getTimestampTokenRequestForData = (data, onSuccess, onError) => {
1471
+ this.callMethod("get_timestamp_token_request_for_data", [data], onSuccess, onError);
1472
+ };
1473
+ /**
1474
+ * Получить токен штампа времени на подпись от службы штампов времени по веб-ссылке
1475
+ */
1476
+ getTimestampTokenForSignature = (signature, tsaUrl, onSuccess, onError) => {
1477
+ this.callMethod("get_timestamp_token_for_signature", [signature, tsaUrl], onSuccess, onError);
1478
+ };
1479
+ /**
1480
+ * Получить токен штампа времени на данные от службы штампов времени по веб-ссылке
1481
+ */
1482
+ getTimestampTokenForData = (data, tsaUrl, onSuccess, onError) => {
1483
+ this.callMethod("get_timestamp_token_for_data", [data, tsaUrl], onSuccess, onError);
1484
+ };
1485
+ /**
1486
+ * Получить информацию о токене штампа времени
1487
+ */
1488
+ getTimestampTokenInfo = (token, onSuccess, onError) => {
1489
+ this.callMethod("get_timestamp_token_info", [token], onSuccess, onError);
1490
+ };
1491
+ /**
1492
+ * Получить запрос на получения токена штампа времени для подписи
1493
+ */
1494
+ getTimestampTokenRequestForSignature = (signature, onSuccess, onError) => {
1495
+ this.callMethod("get_timestamp_token_request_for_signature", [signature], onSuccess, onError);
1496
+ };
1497
+ };
1498
+ _init14 = __decoratorStart(_a14);
1499
+ TSAClientPlugin = __decorateElement(_init14, 0, "TSAClientPlugin", _TSAClientPlugin_decorators, TSAClientPlugin);
1500
+ __runInitializers(_init14, 1, TSAClientPlugin);
1501
+
1502
+ // src/plugins/tunnel.ts
1503
+ var _TunnelPlugin_decorators, _init15, _a15;
1504
+ _TunnelPlugin_decorators = [RegisterPlugin];
1505
+ var TunnelPlugin = class extends (_a15 = EIMZOPlugin) {
1506
+ name = "tunnel";
1507
+ description = "Plugin for establishing encrypted connections using GOST-28147";
1508
+ /**
1509
+ * Создать зашифрованного соединения с сервером и вернуть TCP-порт для приема/передачи данных
1510
+ */
1511
+ createTunnel = (serverHost, serverPort, keyId, onSuccess, onError) => {
1512
+ this.callMethod("create_tunnel", [serverHost, serverPort, keyId], onSuccess, onError);
1513
+ };
1514
+ // Promise-based wrapper (если нужен)
1515
+ async createTunnelAsync(serverHost, serverPort, keyId) {
1516
+ return new Promise((resolve, reject) => {
1517
+ this.createTunnel(
1518
+ serverHost,
1519
+ serverPort,
1520
+ keyId,
1521
+ (event, data) => {
1522
+ if (data.success) {
1523
+ resolve(data);
1524
+ } else {
1525
+ reject(new Error(data.reason ?? "Unknown error"));
1526
+ }
1527
+ },
1528
+ (error) => reject(new Error(String(error)))
1529
+ );
1530
+ });
1531
+ }
1532
+ };
1533
+ _init15 = __decoratorStart(_a15);
1534
+ TunnelPlugin = __decorateElement(_init15, 0, "TunnelPlugin", _TunnelPlugin_decorators, TunnelPlugin);
1535
+ __runInitializers(_init15, 1, TunnelPlugin);
1536
+
1537
+ // src/plugins/x509.ts
1538
+ var _X509Plugin_decorators, _init16, _a16;
1539
+ _X509Plugin_decorators = [RegisterPlugin];
1540
+ var X509Plugin = class extends (_a16 = EIMZOPlugin) {
1541
+ name = "x509";
1542
+ description = "Plugin for working with X.509 certificates";
1543
+ /**
1544
+ * Верификация подписи сертификата субъектка сертификатом издателя
1545
+ */
1546
+ verifyCertificate = (subjectCert, issuerCert, onSuccess, onError) => {
1547
+ this.callMethod("verify_certificate", [subjectCert, issuerCert], onSuccess, onError);
1548
+ };
1549
+ /**
1550
+ * Получить цепочку сертификатов в кодировке BASE64 по идентификатору ключа
1551
+ */
1552
+ getCertificateChain = (keyId, onSuccess, onError) => {
1553
+ this.callMethod("get_certificate_chain", [keyId], onSuccess, onError);
1554
+ };
1555
+ /**
1556
+ * Получить информацию о сертификате
1557
+ */
1558
+ getCertificateInfo = (certificate, onSuccess, onError) => {
1559
+ this.callMethod("get_certificate_info", [certificate], onSuccess, onError);
1560
+ };
1561
+ };
1562
+ _init16 = __decoratorStart(_a16);
1563
+ X509Plugin = __decorateElement(_init16, 0, "X509Plugin", _X509Plugin_decorators, X509Plugin);
1564
+ __runInitializers(_init16, 1, X509Plugin);
1565
+
1566
+ // src/plugins/ytks.ts
1567
+ var _YTKSPlugin_decorators, _init17, _a17;
1568
+ _YTKSPlugin_decorators = [RegisterPlugin];
1569
+ var YTKSPlugin = class extends (_a17 = EIMZOPlugin) {
1570
+ name = "ytks";
1571
+ description = "Plugin for working with YTKS key storage files";
1572
+ /**
1573
+ * Удалить загруженные ключи по идентификатору
1574
+ */
1575
+ unloadKey = (keyId, onSuccess, onError) => {
1576
+ this.callMethod("unload_key", [keyId], onSuccess, onError);
1577
+ };
1578
+ /**
1579
+ * Изменить пароль хранилища ключей
1580
+ */
1581
+ changePassword = (disk, path, name, oldPassword, newPassword, onSuccess, onError) => {
1582
+ this.callMethod(
1583
+ "change_password",
1584
+ [disk, path, name, oldPassword, newPassword],
1585
+ onSuccess,
1586
+ onError
1587
+ );
1588
+ };
1589
+ /**
1590
+ * Получить список дисков
1591
+ */
1592
+ listDisks = (onSuccess, onError) => {
1593
+ this.callMethod("list_disks", [], onSuccess, onError);
1594
+ };
1595
+ /**
1596
+ * Получить список сертификатов пользователя
1597
+ */
1598
+ listCertificates = (disk, onSuccess, onError) => {
1599
+ this.callMethod("list_certificates", [disk], onSuccess, onError);
1600
+ };
1601
+ /**
1602
+ * Проверить пароль хранилища ключей
1603
+ */
1604
+ verifyPassword = (disk, path, name, password, onSuccess, onError) => {
1605
+ this.callMethod("verify_password", [disk, path, name, password], onSuccess, onError);
1606
+ };
1607
+ /**
1608
+ * Получить список всех сертификатов пользователя
1609
+ */
1610
+ listAllCertificates = (onSuccess, onError) => {
1611
+ this.callMethod("list_all_certificates", [], onSuccess, onError);
1612
+ };
1613
+ /**
1614
+ * Загрузить ключ и получить идентификатор ключа
1615
+ */
1616
+ loadKey = (disk, path, name, alias, onSuccess, onError) => {
1617
+ this.callMethod("load_key", [disk, path, name, alias], onSuccess, onError);
1618
+ };
1619
+ /**
1620
+ * Сохранить ключевую пару или существующий ключ и новые сертификаты в новый файл формата YTKS
1621
+ */
1622
+ saveYtks = (disk, path, name, password, keyId, certificates, onSuccess, onError) => {
1623
+ this.callMethod(
1624
+ "save_ytks",
1625
+ [disk, path, name, password, keyId, certificates],
1626
+ onSuccess,
1627
+ onError
1628
+ );
1629
+ };
1630
+ };
1631
+ _init17 = __decoratorStart(_a17);
1632
+ YTKSPlugin = __decorateElement(_init17, 0, "YTKSPlugin", _YTKSPlugin_decorators, YTKSPlugin);
1633
+ __runInitializers(_init17, 1, YTKSPlugin);
1634
+
1635
+ // src/eimzo-api.ts
1636
+ var EIMZOApi = class {
1637
+ // Core CAPIWS access
1638
+ capiws = capiws_default;
1639
+ // Legacy client for backward compatibility
1640
+ client = e_imzo_client_default;
1641
+ // Plugin manager for accessing plugins
1642
+ plugins = PluginManager;
1643
+ // Direct plugin access
1644
+ pfx = PluginManager.get("pfx");
1645
+ pkcs7 = PluginManager.get("pkcs7");
1646
+ ftjc = PluginManager.get("ftjc");
1647
+ cryptoauth = PluginManager.get("cryptoauth");
1648
+ truststoreJks = PluginManager.get("truststore-jks");
1649
+ tunnel = PluginManager.get("tunnel");
1650
+ certkey = PluginManager.get("certkey");
1651
+ x509 = PluginManager.get("x509");
1652
+ cipher = PluginManager.get("cipher");
1653
+ pki = PluginManager.get("pki");
1654
+ pkcs10 = PluginManager.get("pkcs10");
1655
+ idcard = PluginManager.get("idcard");
1656
+ truststore = PluginManager.get("truststore");
1657
+ crl = PluginManager.get("crl");
1658
+ fileio = PluginManager.get("fileio");
1659
+ tsaclient = PluginManager.get("tsaclient");
1660
+ ytks = PluginManager.get("ytks");
1661
+ /**
1662
+ * Initialize E-IMZO API and check version
1663
+ */
1664
+ async initialize() {
1665
+ return new Promise((resolve, reject) => {
1666
+ this.client.checkVersion(
1667
+ (major, minor) => resolve({ major, minor }),
1668
+ (error, reason) => reject(new Error(reason ?? "Version check failed"))
1669
+ );
1670
+ });
1671
+ }
1672
+ /**
1673
+ * Install API keys
1674
+ */
1675
+ async installApiKeys() {
1676
+ return new Promise((resolve, reject) => {
1677
+ this.client.installApiKeys(
1678
+ () => resolve(),
1679
+ (error, reason) => reject(new Error(reason ?? "API key installation failed"))
1680
+ );
1681
+ });
1682
+ }
1683
+ /**
1684
+ * Check if ID card is plugged in
1685
+ */
1686
+ async isIdCardPluggedIn() {
1687
+ return new Promise((resolve, reject) => {
1688
+ this.client.idCardIsPLuggedIn(
1689
+ (isPlugged) => resolve(isPlugged),
1690
+ (error, reason) => reject(new Error(reason ?? "ID card check failed"))
1691
+ );
1692
+ });
1693
+ }
1694
+ /**
1695
+ * Get version information
1696
+ */
1697
+ async getVersion() {
1698
+ return new Promise((resolve, reject) => {
1699
+ this.capiws.version(
1700
+ (event, data) => {
1701
+ if (data.success && data.major && data.minor) {
1702
+ resolve({ major: data.major, minor: data.minor });
1703
+ } else {
1704
+ reject(new Error(data.reason ?? "Failed to get version"));
1705
+ }
1706
+ },
1707
+ (error) => reject(new Error(String(error) || "Version check failed"))
1708
+ );
1709
+ });
1710
+ }
1711
+ /**
1712
+ * Get API documentation
1713
+ */
1714
+ async getApiDoc() {
1715
+ return new Promise((resolve, reject) => {
1716
+ this.capiws.apidoc(
1717
+ (event, data) => {
1718
+ if (data.success) {
1719
+ resolve(data);
1720
+ } else {
1721
+ reject(new Error(data.reason ?? "Failed to get API documentation"));
1722
+ }
1723
+ },
1724
+ (error) => reject(new Error(String(error) || "API documentation request failed"))
1725
+ );
1726
+ });
1727
+ }
1728
+ /**
1729
+ * Setup API keys
1730
+ */
1731
+ async setupApiKeys(domainAndKey) {
1732
+ return new Promise((resolve, reject) => {
1733
+ this.capiws.apikey(
1734
+ domainAndKey,
1735
+ (event, data) => {
1736
+ if (data.success) {
1737
+ resolve();
1738
+ } else {
1739
+ reject(new Error(data.reason ?? "Failed to setup API keys"));
1740
+ }
1741
+ },
1742
+ (error) => reject(new Error(String(error) || "API keys setup failed"))
1743
+ );
1744
+ });
1745
+ }
1746
+ /**
1747
+ * Get all available plugins
1748
+ */
1749
+ getAvailablePlugins() {
1750
+ return this.plugins.getAll().map((plugin) => plugin.name);
1751
+ }
1752
+ /**
1753
+ * Check if a plugin is available
1754
+ */
1755
+ hasPlugin(name) {
1756
+ return this.plugins.has(name);
1757
+ }
1758
+ /**
1759
+ * Get plugin by name with type safety
1760
+ */
1761
+ getPlugin(name) {
1762
+ return this.plugins.get(name);
1763
+ }
1764
+ };
1765
+ var eimzoApi = new EIMZOApi();
1766
+ var eimzo_api_default = eimzoApi;
1767
+
1768
+ // src/global.ts
1769
+ function setupGlobalObjects() {
1770
+ if (typeof window !== "undefined") {
1771
+ const win = window;
1772
+ win.CAPIWS = capiws_default;
1773
+ win.EIMZOClient = e_imzo_client_default;
1774
+ win.capiws = capiws_default;
1775
+ win.eimzoApi = eimzoApi;
1776
+ const processEnv = process.env;
1777
+ const isDev = typeof process !== "undefined" && processEnv.NODE_ENV === "development";
1778
+ if (isDev) {
1779
+ win.imzoPlugins = {
1780
+ version: "1.0.0",
1781
+ loaded: true,
1782
+ plugins: [],
1783
+ debug: true
1784
+ };
1785
+ console.info("\u{1F527} E-IMZO Agnostic Library - Development Mode");
1786
+ console.info("Available APIs:", {
1787
+ CAPIWS: "Main CAPIWS client for E-IMZO communication",
1788
+ EIMZOClient: "Legacy E-IMZO client wrapper",
1789
+ capiws: "Legacy alias for CAPIWS",
1790
+ eimzoApi: "Modern plugin-based E-IMZO API",
1791
+ imzoPlugins: "Plugin system information"
1792
+ });
1793
+ }
1794
+ if (isDev) {
1795
+ console.info("\u2705 E-IMZO Global Setup - Success");
1796
+ console.info("Global status:", {
1797
+ CAPIWS: Boolean(win.CAPIWS),
1798
+ EIMZOClient: Boolean(win.EIMZOClient),
1799
+ capiws: Boolean(win.capiws),
1800
+ eimzoApi: Boolean(win.eimzoApi),
1801
+ imzoPlugins: Boolean(win.imzoPlugins)
1802
+ });
1803
+ }
1804
+ }
1805
+ }
1806
+ setupGlobalObjects();
1807
+
1808
+ exports.CAPIWS = capiws_default;
1809
+ exports.EIMZOApi = EIMZOApi;
1810
+ exports.EIMZOClient = e_imzo_client_default;
1811
+ exports.EIMZOPlugin = EIMZOPlugin;
1812
+ exports.PluginManager = PluginManager;
1813
+ exports.dates = dates;
1814
+ exports.eimzoApi = eimzo_api_default;
1815
+ exports.ftjcPlugin = ftjcPlugin;
1816
+ exports.pfxPlugin = pfxPlugin;
1817
+ exports.pkcs7Plugin = pkcs7Plugin;
1818
+
1819
+ return exports;
1820
+
1821
+ })({});
1822
+ //# sourceMappingURL=index.js.map
1823
+ //# sourceMappingURL=index.js.map