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