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