imzo-agnost 1.0.1 → 1.2.1

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 CHANGED
@@ -1108,12 +1108,383 @@ _init7 = __decoratorStart(_a7);
1108
1108
  IDCardPlugin = __decorateElement(_init7, 0, "IDCardPlugin", _IDCardPlugin_decorators, IDCardPlugin);
1109
1109
  __runInitializers(_init7, 1, IDCardPlugin);
1110
1110
 
1111
+ // src/core/session-manager.ts
1112
+ var EIMZOSessionManager = class {
1113
+ config;
1114
+ sessions = /* @__PURE__ */ new Map();
1115
+ cleanupInterval = null;
1116
+ constructor(config = {}) {
1117
+ this.config = {
1118
+ storageType: "sessionStorage",
1119
+ autoUnloadAfter: 6 * 60 * 60 * 1e3,
1120
+ // 6 hours default
1121
+ keyPrefix: "eimzo_key_",
1122
+ ...config
1123
+ };
1124
+ this.initializeFromStorage();
1125
+ this.startCleanupTimer();
1126
+ }
1127
+ /**
1128
+ * KeyId ni session storage ga saqlash
1129
+ */
1130
+ saveKeySession(keyId, certificateId, certificate, autoUnload = true) {
1131
+ const now = Date.now();
1132
+ const session = {
1133
+ keyId,
1134
+ certificateId,
1135
+ loadedAt: now,
1136
+ expiresAt: now + this.config.autoUnloadAfter,
1137
+ certificate,
1138
+ autoUnload
1139
+ };
1140
+ this.sessions.set(certificateId, session);
1141
+ this.saveToStorage(certificateId, session);
1142
+ console.log(
1143
+ `\u{1F511} Key session saved: ${certificateId} (expires in ${this.config.autoUnloadAfter / 1e3 / 60} minutes)`
1144
+ );
1145
+ }
1146
+ /**
1147
+ * Certificate ID bo'yicha keyId ni olish
1148
+ */
1149
+ getKeyId(certificateId) {
1150
+ const session = this.sessions.get(certificateId);
1151
+ if (!session) {
1152
+ this.loadFromStorage(certificateId);
1153
+ return this.sessions.get(certificateId)?.keyId ?? null;
1154
+ }
1155
+ if (Date.now() > session.expiresAt) {
1156
+ void this.removeKeySession(certificateId);
1157
+ return null;
1158
+ }
1159
+ return session.keyId;
1160
+ }
1161
+ /**
1162
+ * Barcha active key sessions ni olish
1163
+ */
1164
+ getActiveSessions() {
1165
+ const now = Date.now();
1166
+ const activeSessions = [];
1167
+ for (const [certId, session] of this.sessions.entries()) {
1168
+ if (now <= session.expiresAt) {
1169
+ activeSessions.push(session);
1170
+ } else {
1171
+ void this.removeKeySession(certId);
1172
+ }
1173
+ }
1174
+ return activeSessions;
1175
+ }
1176
+ /**
1177
+ * Session ni kengaytirish (6 soat yana qo'shish)
1178
+ */
1179
+ extendSession(certificateId) {
1180
+ const session = this.sessions.get(certificateId);
1181
+ if (!session) return false;
1182
+ const now = Date.now();
1183
+ session.expiresAt = now + this.config.autoUnloadAfter;
1184
+ void this.saveToStorage(certificateId, session);
1185
+ console.log(`\u23F0 Session extended for ${certificateId}`);
1186
+ return true;
1187
+ }
1188
+ /**
1189
+ * Key session ni o'chirish
1190
+ */
1191
+ async removeKeySession(certificateId) {
1192
+ const session = this.sessions.get(certificateId);
1193
+ if (session) {
1194
+ if (session.autoUnload) {
1195
+ await this.unloadKeyFromEIMZO(session.keyId);
1196
+ }
1197
+ this.sessions.delete(certificateId);
1198
+ this.removeFromStorage(certificateId);
1199
+ console.log(`\u{1F5D1}\uFE0F Key session removed: ${certificateId}`);
1200
+ }
1201
+ }
1202
+ /**
1203
+ * Barcha sessionlarni tozalash
1204
+ */
1205
+ async clearAllSessions() {
1206
+ const sessions = Array.from(this.sessions.keys());
1207
+ for (const certId of sessions) {
1208
+ await this.removeKeySession(certId);
1209
+ }
1210
+ console.log("\u{1F9F9} All key sessions cleared");
1211
+ }
1212
+ /**
1213
+ * Storage configuration ni o'zgartirish
1214
+ */
1215
+ updateConfig(newConfig) {
1216
+ this.config = { ...this.config, ...newConfig };
1217
+ if (this.cleanupInterval) {
1218
+ clearInterval(this.cleanupInterval);
1219
+ }
1220
+ this.startCleanupTimer();
1221
+ }
1222
+ // Private methods
1223
+ saveToStorage(certificateId, session) {
1224
+ const key = this.config.keyPrefix + certificateId;
1225
+ const data = JSON.stringify(session);
1226
+ try {
1227
+ switch (this.config.storageType) {
1228
+ case "sessionStorage":
1229
+ if (typeof sessionStorage !== "undefined") {
1230
+ sessionStorage.setItem(key, data);
1231
+ }
1232
+ break;
1233
+ case "localStorage":
1234
+ if (typeof localStorage !== "undefined") {
1235
+ localStorage.setItem(key, data);
1236
+ }
1237
+ break;
1238
+ case "cookie":
1239
+ this.setCookie(key, data, session.expiresAt);
1240
+ break;
1241
+ case "memory":
1242
+ break;
1243
+ }
1244
+ } catch (error) {
1245
+ console.warn("Failed to save to storage:", error);
1246
+ }
1247
+ }
1248
+ loadFromStorage(certificateId) {
1249
+ const key = this.config.keyPrefix + certificateId;
1250
+ try {
1251
+ let data = null;
1252
+ switch (this.config.storageType) {
1253
+ case "sessionStorage":
1254
+ if (typeof sessionStorage !== "undefined") {
1255
+ data = sessionStorage.getItem(key);
1256
+ }
1257
+ break;
1258
+ case "localStorage":
1259
+ if (typeof localStorage !== "undefined") {
1260
+ data = localStorage.getItem(key);
1261
+ }
1262
+ break;
1263
+ case "cookie":
1264
+ data = this.getCookie(key);
1265
+ break;
1266
+ case "memory":
1267
+ return null;
1268
+ }
1269
+ if (data) {
1270
+ const session = JSON.parse(data);
1271
+ if (Date.now() > session.expiresAt) {
1272
+ this.removeFromStorage(certificateId);
1273
+ return null;
1274
+ }
1275
+ this.sessions.set(certificateId, session);
1276
+ return session;
1277
+ }
1278
+ } catch (error) {
1279
+ console.warn("Failed to load from storage:", error);
1280
+ }
1281
+ return null;
1282
+ }
1283
+ removeFromStorage(certificateId) {
1284
+ const key = this.config.keyPrefix + certificateId;
1285
+ try {
1286
+ switch (this.config.storageType) {
1287
+ case "sessionStorage":
1288
+ if (typeof sessionStorage !== "undefined") {
1289
+ sessionStorage.removeItem(key);
1290
+ }
1291
+ break;
1292
+ case "localStorage":
1293
+ if (typeof localStorage !== "undefined") {
1294
+ localStorage.removeItem(key);
1295
+ }
1296
+ break;
1297
+ case "cookie":
1298
+ this.deleteCookie(key);
1299
+ break;
1300
+ case "memory":
1301
+ break;
1302
+ }
1303
+ } catch (error) {
1304
+ console.warn("Failed to remove from storage:", error);
1305
+ }
1306
+ }
1307
+ initializeFromStorage() {
1308
+ if (typeof window === "undefined") return;
1309
+ try {
1310
+ const keys = [];
1311
+ switch (this.config.storageType) {
1312
+ case "sessionStorage":
1313
+ if (typeof sessionStorage !== "undefined") {
1314
+ for (let i = 0; i < sessionStorage.length; i++) {
1315
+ const key = sessionStorage.key(i);
1316
+ if (key?.startsWith(this.config.keyPrefix)) {
1317
+ keys.push(key);
1318
+ }
1319
+ }
1320
+ }
1321
+ break;
1322
+ case "localStorage":
1323
+ if (typeof localStorage !== "undefined") {
1324
+ for (let i = 0; i < localStorage.length; i++) {
1325
+ const key = localStorage.key(i);
1326
+ if (key?.startsWith(this.config.keyPrefix)) {
1327
+ keys.push(key);
1328
+ }
1329
+ }
1330
+ }
1331
+ break;
1332
+ case "cookie":
1333
+ break;
1334
+ }
1335
+ keys.forEach((key) => {
1336
+ const certificateId = key.replace(this.config.keyPrefix, "");
1337
+ this.loadFromStorage(certificateId);
1338
+ });
1339
+ } catch (error) {
1340
+ console.warn("Failed to initialize from storage:", error);
1341
+ }
1342
+ }
1343
+ startCleanupTimer() {
1344
+ this.cleanupInterval = setInterval(
1345
+ () => {
1346
+ void this.cleanupExpiredSessions();
1347
+ },
1348
+ 10 * 60 * 1e3
1349
+ );
1350
+ }
1351
+ async cleanupExpiredSessions() {
1352
+ const now = Date.now();
1353
+ const expiredSessions = [];
1354
+ for (const [certId, session] of this.sessions.entries()) {
1355
+ if (now > session.expiresAt) {
1356
+ expiredSessions.push(certId);
1357
+ }
1358
+ }
1359
+ for (const certId of expiredSessions) {
1360
+ await this.removeKeySession(certId);
1361
+ }
1362
+ if (expiredSessions.length > 0) {
1363
+ console.log(`\u{1F552} Cleaned up ${expiredSessions.length} expired sessions`);
1364
+ }
1365
+ }
1366
+ async unloadKeyFromEIMZO(keyId) {
1367
+ try {
1368
+ if (typeof window !== "undefined") {
1369
+ const windowWithCAPiWS = window;
1370
+ if (windowWithCAPiWS.CAPIWS) {
1371
+ const CAPIWS2 = windowWithCAPiWS.CAPIWS;
1372
+ return new Promise((resolve) => {
1373
+ CAPIWS2.callFunction({
1374
+ plugin: "pfx",
1375
+ name: "unloadKey",
1376
+ arguments: [keyId],
1377
+ onSuccess: () => {
1378
+ console.log(`\u{1F513} Key unloaded from E-IMZO: ${keyId}`);
1379
+ resolve();
1380
+ },
1381
+ onError: (error, reason) => {
1382
+ console.warn(`Failed to unload key ${keyId}:`, reason);
1383
+ resolve();
1384
+ }
1385
+ });
1386
+ });
1387
+ }
1388
+ }
1389
+ } catch (error) {
1390
+ console.warn("Failed to unload key from E-IMZO:", error);
1391
+ }
1392
+ }
1393
+ // Cookie utility methods
1394
+ setCookie(name, value, expiresAt) {
1395
+ if (typeof document === "undefined") return;
1396
+ const expires = new Date(expiresAt).toUTCString();
1397
+ const options = this.config.cookieOptions ?? {};
1398
+ let cookieString = `${name}=${encodeURIComponent(value)}; expires=${expires}`;
1399
+ if (options.domain) cookieString += `; domain=${options.domain}`;
1400
+ if (options.path) cookieString += `; path=${options.path}`;
1401
+ if (options.secure) cookieString += "; secure";
1402
+ if (options.sameSite) cookieString += `; samesite=${options.sameSite}`;
1403
+ document.cookie = cookieString;
1404
+ }
1405
+ getCookie(name) {
1406
+ if (typeof document === "undefined") return null;
1407
+ const nameEQ = name + "=";
1408
+ const cookies = document.cookie.split(";");
1409
+ for (let cookie of cookies) {
1410
+ cookie = cookie.trim();
1411
+ if (cookie.startsWith(nameEQ)) {
1412
+ return decodeURIComponent(cookie.substring(nameEQ.length));
1413
+ }
1414
+ }
1415
+ return null;
1416
+ }
1417
+ deleteCookie(name) {
1418
+ if (typeof document === "undefined") return;
1419
+ const options = this.config.cookieOptions ?? {};
1420
+ let cookieString = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC`;
1421
+ if (options.domain) cookieString += `; domain=${options.domain}`;
1422
+ if (options.path) cookieString += `; path=${options.path}`;
1423
+ document.cookie = cookieString;
1424
+ }
1425
+ /**
1426
+ * Cleanup when instance is destroyed
1427
+ */
1428
+ destroy() {
1429
+ if (this.cleanupInterval) {
1430
+ clearInterval(this.cleanupInterval);
1431
+ this.cleanupInterval = null;
1432
+ }
1433
+ }
1434
+ };
1435
+ var sessionManager = new EIMZOSessionManager();
1436
+
1111
1437
  // src/plugins/pfx.ts
1112
1438
  var _PfxPlugin_decorators, _init8, _a8;
1113
1439
  _PfxPlugin_decorators = [RegisterPlugin];
1114
1440
  var PfxPlugin = class extends (_a8 = EIMZOPlugin) {
1115
1441
  name = "pfx";
1116
- description = "Plugin for working with PFX key storage files";
1442
+ description = "Plugin for working with PFX key storage files with session management";
1443
+ // Session management configuration
1444
+ updateSessionConfig(config) {
1445
+ sessionManager.updateConfig(config);
1446
+ }
1447
+ // Certificate cache for keyId lookup
1448
+ certificateCache = /* @__PURE__ */ new Map();
1449
+ /**
1450
+ * Get keyId from certificate identifier
1451
+ * Used for: await pfxPlugin.verifyPasswordAsync(keyId);
1452
+ * @param certificateId - Format: "disk:path:name:alias" or just "alias"
1453
+ * @returns keyId or null if not found
1454
+ */
1455
+ getKeyId(certificateId) {
1456
+ return sessionManager.getKeyId(certificateId);
1457
+ }
1458
+ /**
1459
+ * Get all active key sessions
1460
+ */
1461
+ getActiveSessions() {
1462
+ return sessionManager.getActiveSessions();
1463
+ }
1464
+ /**
1465
+ * Find certificate ID by partial match (alias, name, etc.)
1466
+ */
1467
+ findCertificateId(searchTerm) {
1468
+ for (const [certId, cert] of this.certificateCache.entries()) {
1469
+ if (cert.alias === searchTerm || cert.name === searchTerm || certId.includes(searchTerm)) {
1470
+ return certId;
1471
+ }
1472
+ }
1473
+ const sessions = sessionManager.getActiveSessions();
1474
+ for (const session of sessions) {
1475
+ if (session.certificateId.includes(searchTerm)) {
1476
+ return session.certificateId;
1477
+ }
1478
+ }
1479
+ return null;
1480
+ }
1481
+ /**
1482
+ * Clear all sessions
1483
+ */
1484
+ async clearAllSessions() {
1485
+ await sessionManager.clearAllSessions();
1486
+ this.certificateCache.clear();
1487
+ }
1117
1488
  // Callback-based methods
1118
1489
  /**
1119
1490
  * Get list of available disks
@@ -1134,10 +1505,60 @@ var PfxPlugin = class extends (_a8 = EIMZOPlugin) {
1134
1505
  this.callMethod("list_all_certificates", [], onSuccess, onError);
1135
1506
  };
1136
1507
  /**
1137
- * Load key and get key identifier
1508
+ * Load key and get key identifier with session management
1509
+ * @param disk - Storage disk name
1510
+ * @param path - Path to PFX file
1511
+ * @param name - File name
1512
+ * @param alias - Certificate alias
1513
+ * @param saveForHours - Save in session for automatic management (6 hours default)
1138
1514
  */
1139
- loadKey = (disk, path, name, alias, onSuccess, onError) => {
1140
- this.callMethod("load_key", [disk, path, name, alias], onSuccess, onError);
1515
+ loadKey = (disk, path, name, alias, onSuccess, onError, saveForHours) => {
1516
+ const originalOnSuccess = (event, response) => {
1517
+ if (!response.data) return;
1518
+ const keyResponse = response.data;
1519
+ const certificateId = `${disk}:${path}:${name}:${alias}`;
1520
+ const certificate = {
1521
+ disk,
1522
+ path,
1523
+ name,
1524
+ alias,
1525
+ serialNumber: "",
1526
+ subjectName: "",
1527
+ validFromDate: "",
1528
+ validToDate: "",
1529
+ issuerName: "",
1530
+ subjectId: "",
1531
+ publicKeyAlgorithm: "",
1532
+ signAlgorithm: "",
1533
+ keyUsage: "",
1534
+ extendedKeyUsage: "",
1535
+ crlDistributionPoints: "",
1536
+ authorityInfoAccess: "",
1537
+ subjectAltName: "",
1538
+ issuerAltName: "",
1539
+ subjectKeyIdentifier: "",
1540
+ authorityKeyIdentifier: "",
1541
+ basicConstraints: "",
1542
+ certificatePolicies: "",
1543
+ keyUsageNonRepudiation: false,
1544
+ keyUsageDigitalSignature: false,
1545
+ keyUsageContentCommitment: false,
1546
+ extendedKeyUsageTimeStamping: false
1547
+ };
1548
+ this.certificateCache.set(certificateId, certificate);
1549
+ if (saveForHours && saveForHours > 0 && keyResponse.keyId) {
1550
+ sessionManager.saveKeySession(
1551
+ keyResponse.keyId,
1552
+ certificateId,
1553
+ certificate,
1554
+ true
1555
+ // Auto unload enabled
1556
+ );
1557
+ console.log(`\u{1F4BE} Key session saved for ${saveForHours} hours: ${certificateId}`);
1558
+ }
1559
+ onSuccess(event, response);
1560
+ };
1561
+ this.callMethod("load_key", [disk, path, name, alias], originalOnSuccess, onError);
1141
1562
  };
1142
1563
  /**
1143
1564
  * Unload key by identifier
@@ -1203,11 +1624,32 @@ var PfxPlugin = class extends (_a8 = EIMZOPlugin) {
1203
1624
  */
1204
1625
  listAllCertificatesAsync = this.createPromiseMethod("list_all_certificates");
1205
1626
  /**
1206
- * Load key (Promise version)
1627
+ * Load key (Promise version) with session management
1628
+ * @param disk Storage disk name
1629
+ * @param path Path to PFX file
1630
+ * @param name File name
1631
+ * @param alias Certificate alias
1632
+ * @param saveForHours Save in session for automatic management
1207
1633
  */
1208
- loadKeyAsync = this.createPromiseMethod(
1209
- "load_key"
1210
- );
1634
+ loadKeyAsync = async (disk, path, name, alias, saveForHours) => {
1635
+ return new Promise((resolve, reject) => {
1636
+ this.loadKey(
1637
+ disk,
1638
+ path,
1639
+ name,
1640
+ alias,
1641
+ (event, response) => {
1642
+ if (response.success && response.data) {
1643
+ resolve(response.data);
1644
+ } else {
1645
+ reject(new Error(response.reason ?? "Unknown error"));
1646
+ }
1647
+ },
1648
+ reject,
1649
+ saveForHours
1650
+ );
1651
+ });
1652
+ };
1211
1653
  /**
1212
1654
  * Unload key (Promise version)
1213
1655
  */
@@ -1275,11 +1717,52 @@ _Pkcs7Plugin_decorators = [RegisterPlugin];
1275
1717
  var Pkcs7Plugin = class extends (_a10 = EIMZOPlugin) {
1276
1718
  name = "pkcs7";
1277
1719
  description = "Plugin for working with PKCS#7/CMS format";
1720
+ // Utility method to check if string is base64
1721
+ isBase64(str) {
1722
+ try {
1723
+ const base64Pattern = /^[A-Za-z0-9+/]*={0,2}$/;
1724
+ if (!base64Pattern.test(str)) return false;
1725
+ const decoded = atob(str);
1726
+ const encoded = btoa(decoded);
1727
+ return encoded === str;
1728
+ } catch {
1729
+ return false;
1730
+ }
1731
+ }
1278
1732
  // Callback-based methods
1279
1733
  /**
1280
- * Create PKCS#7/CMS document by signing with key
1734
+ * Create PKCS#7/CMS document by signing with key (enhanced version)
1735
+ * @param data - String data or already base64 encoded data
1736
+ * @param keyId - Key identifier
1737
+ * @param options - Creation options with smart defaults
1738
+ */
1739
+ createPkcs7Enhanced = (data, keyId, options = {}, onSuccess, onError) => {
1740
+ const {
1741
+ detached = false,
1742
+ // Default to attached (no)
1743
+ autoBase64 = true
1744
+ // Default to auto base64 encoding
1745
+ } = options;
1746
+ let data64 = data;
1747
+ if (autoBase64 && !this.isBase64(data)) {
1748
+ try {
1749
+ data64 = btoa(data);
1750
+ } catch (_error) {
1751
+ data64 = btoa(unescape(encodeURIComponent(data)));
1752
+ }
1753
+ }
1754
+ let detachedParam = "";
1755
+ if (typeof detached === "boolean") {
1756
+ detachedParam = detached ? "yes" : "no";
1757
+ } else {
1758
+ detachedParam = detached;
1759
+ }
1760
+ this.callMethod("create_pkcs7", [data64, keyId, detachedParam], onSuccess, onError);
1761
+ };
1762
+ /**
1763
+ * Create PKCS#7/CMS document by signing with key (original method)
1281
1764
  */
1282
- createPkcs7 = (data64, keyId, detached = "", onSuccess, onError) => {
1765
+ createPkcs7 = (data64, keyId, detached = "no", onSuccess, onError) => {
1283
1766
  this.callMethod("create_pkcs7", [data64, keyId, detached], onSuccess, onError);
1284
1767
  };
1285
1768
  /**
@@ -1289,7 +1772,21 @@ var Pkcs7Plugin = class extends (_a10 = EIMZOPlugin) {
1289
1772
  this.callMethod("get_pkcs7_attached_info", [pkcs764, trustStoreId], onSuccess, onError);
1290
1773
  };
1291
1774
  /**
1292
- * Get full information about PKCS#7/CMS document (detached)
1775
+ * Get full information about PKCS#7/CMS document (detached) with auto base64
1776
+ */
1777
+ getPkcs7DetachedInfoEnhanced = (data, pkcs764, trustStoreId = "", autoBase64 = true, onSuccess, onError) => {
1778
+ let data64 = data;
1779
+ if (autoBase64 && !this.isBase64(data)) {
1780
+ try {
1781
+ data64 = btoa(data);
1782
+ } catch (_error) {
1783
+ data64 = btoa(unescape(encodeURIComponent(data)));
1784
+ }
1785
+ }
1786
+ this.callMethod("get_pkcs7_detached_info", [data64, pkcs764, trustStoreId], onSuccess, onError);
1787
+ };
1788
+ /**
1789
+ * Get full information about PKCS#7/CMS document (detached) - original
1293
1790
  */
1294
1791
  getPkcs7DetachedInfo = (data64, pkcs764, trustStoreId = "", onSuccess, onError) => {
1295
1792
  this.callMethod("get_pkcs7_detached_info", [data64, pkcs764, trustStoreId], onSuccess, onError);
@@ -1305,6 +1802,25 @@ var Pkcs7Plugin = class extends (_a10 = EIMZOPlugin) {
1305
1802
  onError
1306
1803
  );
1307
1804
  };
1805
+ /**
1806
+ * Verify PKCS#7/CMS document (detached) with auto base64
1807
+ */
1808
+ verifyPkcs7DetachedEnhanced = (data, pkcs764, trustStoreId, requesterId = "", autoBase64 = true, onSuccess, onError) => {
1809
+ let data64 = data;
1810
+ if (autoBase64 && !this.isBase64(data)) {
1811
+ try {
1812
+ data64 = btoa(data);
1813
+ } catch (_error) {
1814
+ data64 = btoa(unescape(encodeURIComponent(data)));
1815
+ }
1816
+ }
1817
+ this.callMethod(
1818
+ "verify_pkcs7_detached",
1819
+ [data64, pkcs764, trustStoreId, requesterId],
1820
+ onSuccess,
1821
+ onError
1822
+ );
1823
+ };
1308
1824
  /**
1309
1825
  * Verify PKCS#7/CMS document (detached) - STUB
1310
1826
  */
@@ -1363,9 +1879,32 @@ var Pkcs7Plugin = class extends (_a10 = EIMZOPlugin) {
1363
1879
  };
1364
1880
  // Promise-based methods
1365
1881
  /**
1366
- * Create PKCS#7/CMS document (Promise version)
1882
+ * Create PKCS#7/CMS document (Enhanced Promise version)
1883
+ * @param data String data (auto base64 encoded) or base64 data
1884
+ * @param keyId Key identifier
1885
+ * @param options Creation options with smart defaults
1886
+ */
1887
+ createPkcs7Async = async (data, keyId, options = {}) => {
1888
+ return new Promise((resolve, reject) => {
1889
+ this.createPkcs7Enhanced(
1890
+ data,
1891
+ keyId,
1892
+ options,
1893
+ (_event, response) => {
1894
+ if (response.success && response.data) {
1895
+ resolve(response.data);
1896
+ } else {
1897
+ reject(new Error(response.reason ?? "Unknown error"));
1898
+ }
1899
+ },
1900
+ reject
1901
+ );
1902
+ });
1903
+ };
1904
+ /**
1905
+ * Create PKCS#7/CMS document (Original Promise version for backward compatibility)
1367
1906
  */
1368
- createPkcs7Async = this.createPromiseMethod("create_pkcs7");
1907
+ createPkcs7LegacyAsync = this.createPromiseMethod("create_pkcs7");
1369
1908
  /**
1370
1909
  * Get PKCS#7 attached info (Promise version)
1371
1910
  */
@@ -1373,17 +1912,60 @@ var Pkcs7Plugin = class extends (_a10 = EIMZOPlugin) {
1373
1912
  "get_pkcs7_attached_info"
1374
1913
  );
1375
1914
  /**
1376
- * Get PKCS#7 detached info (Promise version)
1915
+ * Get PKCS#7 detached info (Enhanced Promise version)
1377
1916
  */
1378
- getPkcs7DetachedInfoAsync = this.createPromiseMethod("get_pkcs7_detached_info");
1917
+ getPkcs7DetachedInfoAsync = async (data, pkcs764, trustStoreId = "", autoBase64 = true) => {
1918
+ return new Promise((resolve, reject) => {
1919
+ this.getPkcs7DetachedInfoEnhanced(
1920
+ data,
1921
+ pkcs764,
1922
+ trustStoreId,
1923
+ autoBase64,
1924
+ (_event, response) => {
1925
+ if (response.success && response.data) {
1926
+ resolve(response.data);
1927
+ } else {
1928
+ reject(new Error(response.reason ?? "Unknown error"));
1929
+ }
1930
+ },
1931
+ reject
1932
+ );
1933
+ });
1934
+ };
1935
+ /**
1936
+ * Get PKCS#7 detached info (Original Promise version)
1937
+ */
1938
+ getPkcs7DetachedInfoLegacyAsync = this.createPromiseMethod("get_pkcs7_detached_info");
1379
1939
  /**
1380
1940
  * Verify PKCS#7 attached (Promise version)
1381
1941
  */
1382
1942
  verifyPkcs7AttachedAsync = this.createPromiseMethod("verify_pkcs7_attached");
1383
1943
  /**
1384
- * Verify PKCS#7 detached (Promise version)
1944
+ * Verify PKCS#7 detached (Enhanced Promise version)
1945
+ */
1946
+ verifyPkcs7DetachedAsync = async (data, pkcs764, trustStoreId, requesterId = "", autoBase64 = true) => {
1947
+ return new Promise((resolve, reject) => {
1948
+ this.verifyPkcs7DetachedEnhanced(
1949
+ data,
1950
+ pkcs764,
1951
+ trustStoreId,
1952
+ requesterId,
1953
+ autoBase64,
1954
+ (_event, response) => {
1955
+ if (response.success && response.data) {
1956
+ resolve(response.data);
1957
+ } else {
1958
+ reject(new Error(response.reason ?? "Unknown error"));
1959
+ }
1960
+ },
1961
+ reject
1962
+ );
1963
+ });
1964
+ };
1965
+ /**
1966
+ * Verify PKCS#7 detached (Original Promise version)
1385
1967
  */
1386
- verifyPkcs7DetachedAsync = this.createPromiseMethod("verify_pkcs7_detached");
1968
+ verifyPkcs7DetachedLegacyAsync = this.createPromiseMethod("verify_pkcs7_detached");
1387
1969
  /**
1388
1970
  * Attach timestamp token (Promise version)
1389
1971
  */
@@ -1793,11 +2375,13 @@ exports.CAPIWS = capiws_default;
1793
2375
  exports.EIMZOApi = EIMZOApi;
1794
2376
  exports.EIMZOClient = e_imzo_client_default;
1795
2377
  exports.EIMZOPlugin = EIMZOPlugin;
2378
+ exports.EIMZOSessionManager = EIMZOSessionManager;
1796
2379
  exports.PluginManager = PluginManager;
1797
2380
  exports.dates = dates;
1798
2381
  exports.eimzoApi = eimzo_api_default;
1799
2382
  exports.ftjcPlugin = ftjcPlugin;
1800
2383
  exports.pfxPlugin = pfxPlugin;
1801
2384
  exports.pkcs7Plugin = pkcs7Plugin;
2385
+ exports.sessionManager = sessionManager;
1802
2386
  //# sourceMappingURL=index.cjs.map
1803
2387
  //# sourceMappingURL=index.cjs.map