shogun-core 6.2.3 → 6.3.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/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js +93 -341
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js.map +1 -1
- package/dist/browser/shogun-core.js +138850 -146638
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/{core.js → src/core.js} +167 -107
- package/dist/src/crypto/asymmetric.js +168 -0
- package/dist/src/crypto/double-ratchet.js +908 -0
- package/dist/src/crypto/file-encryption.js +352 -0
- package/dist/src/crypto/hashing.js +160 -0
- package/dist/src/crypto/index.js +18 -0
- package/dist/{crypto → src/crypto}/mls-codec.js +24 -34
- package/dist/src/crypto/mls.js +734 -0
- package/dist/src/crypto/pgp.js +619 -0
- package/dist/{crypto → src/crypto}/random-generation.js +125 -103
- package/dist/src/crypto/sframe.js +466 -0
- package/dist/src/crypto/signal-protocol.js +943 -0
- package/dist/src/crypto/symmetric.js +165 -0
- package/dist/src/crypto/utils.js +220 -0
- package/dist/src/examples/auth-test.js +535 -0
- package/dist/src/examples/crypto-identity-example.js +294 -0
- package/dist/src/examples/crypto-working-test.js +149 -0
- package/dist/src/examples/double-ratchet-test.js +240 -0
- package/dist/src/examples/mls-3-member-test.js +183 -0
- package/dist/src/examples/mls-multi-member.js +439 -0
- package/dist/src/examples/mls-sframe-test.js +491 -0
- package/dist/src/examples/mls-simple-test.js +122 -0
- package/dist/src/examples/pgp-example.js +354 -0
- package/dist/src/examples/random-generation-test.js +191 -0
- package/dist/src/examples/shogun-core-example.js +204 -0
- package/dist/src/examples/signal-protocol-test.js +82 -0
- package/dist/src/examples/zkproof-credentials-example.js +357 -0
- package/dist/src/examples/zkproof-example.js +357 -0
- package/dist/src/gundb/crypto.js +420 -0
- package/dist/src/gundb/db.js +728 -0
- package/dist/src/gundb/derive.js +327 -0
- package/dist/src/gundb/errors.js +115 -0
- package/dist/src/gundb/gun-es.js +8 -0
- package/dist/src/gundb/index.js +5 -0
- package/dist/{gundb → src/gundb}/rxjs.js +147 -111
- package/dist/{gundb → src/gundb}/types.js +1 -2
- package/dist/src/index.js +19 -0
- package/dist/src/interfaces/events.js +57 -0
- package/dist/{interfaces → src/interfaces}/shogun.js +4 -7
- package/dist/src/managers/AuthManager.js +301 -0
- package/dist/src/managers/CoreInitializer.js +304 -0
- package/dist/src/managers/CryptoIdentityManager.js +230 -0
- package/dist/{managers → src/managers}/EventManager.js +19 -21
- package/dist/{managers → src/managers}/PluginManager.js +123 -89
- package/dist/src/plugins/base.js +90 -0
- package/dist/src/plugins/index.js +17 -0
- package/dist/src/plugins/nostr/index.js +4 -0
- package/dist/src/plugins/nostr/nostrConnector.js +539 -0
- package/dist/src/plugins/nostr/nostrConnectorPlugin.js +663 -0
- package/dist/src/plugins/nostr/nostrSigner.js +414 -0
- package/dist/src/plugins/smartwallet/index.js +2 -0
- package/dist/src/plugins/smartwallet/smartWalletPlugin.js +824 -0
- package/dist/src/plugins/web3/index.js +4 -0
- package/dist/src/plugins/web3/types.js +1 -0
- package/dist/src/plugins/web3/web3Connector.js +738 -0
- package/dist/src/plugins/web3/web3ConnectorPlugin.js +639 -0
- package/dist/src/plugins/web3/web3Signer.js +432 -0
- package/dist/src/plugins/webauthn/index.js +3 -0
- package/dist/{plugins → src/plugins}/webauthn/types.js +2 -5
- package/dist/src/plugins/webauthn/webauthn.js +647 -0
- package/dist/src/plugins/webauthn/webauthnPlugin.js +689 -0
- package/dist/src/plugins/webauthn/webauthnSigner.js +419 -0
- package/dist/{plugins → src/plugins}/zkproof/index.js +3 -10
- package/dist/src/plugins/zkproof/types.js +1 -0
- package/dist/src/plugins/zkproof/zkCredentials.js +287 -0
- package/dist/src/plugins/zkproof/zkProofConnector.js +267 -0
- package/dist/src/plugins/zkproof/zkProofPlugin.js +405 -0
- package/dist/src/storage/storage.js +189 -0
- package/dist/src/utils/errorHandler.js +339 -0
- package/dist/{utils → src/utils}/eventEmitter.js +26 -26
- package/dist/{utils → src/utils}/seedPhrase.js +23 -32
- package/dist/{utils → src/utils}/validation.js +14 -21
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/{crypto → src/crypto}/double-ratchet.d.ts +1 -1
- package/dist/types/{crypto → src/crypto}/signal-protocol.d.ts +25 -0
- package/dist/types/{crypto → src/crypto}/types.d.ts +3 -1
- package/dist/types/src/examples/crypto-working-test.d.ts +1 -0
- package/dist/types/src/examples/double-ratchet-test.d.ts +1 -0
- package/dist/types/src/examples/mls-sframe-test.d.ts +1 -0
- package/dist/types/src/examples/random-generation-test.d.ts +1 -0
- package/dist/types/src/examples/signal-protocol-test.d.ts +1 -0
- package/dist/types/{gundb → src/gundb}/db.d.ts +14 -1
- package/dist/types/src/gundb/gun-es.d.ts +8 -0
- package/dist/types/src/gundb/min.d.ts +3 -0
- package/dist/types/{index.d.ts → src/index.d.ts} +1 -0
- package/package.json +14 -11
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js +0 -1651
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js.map +0 -1
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js +0 -1608
- package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js.map +0 -1
- package/dist/crypto/asymmetric.js +0 -99
- package/dist/crypto/double-ratchet.js +0 -370
- package/dist/crypto/file-encryption.js +0 -213
- package/dist/crypto/hashing.js +0 -87
- package/dist/crypto/index.js +0 -34
- package/dist/crypto/mls.js +0 -569
- package/dist/crypto/pgp.js +0 -390
- package/dist/crypto/sframe.js +0 -352
- package/dist/crypto/signal-protocol.js +0 -456
- package/dist/crypto/symmetric.js +0 -91
- package/dist/crypto/types.js +0 -2
- package/dist/crypto/utils.js +0 -140
- package/dist/examples/auth-test.js +0 -453
- package/dist/examples/crypto-identity-example.js +0 -196
- package/dist/examples/crypto-working-test.js +0 -83
- package/dist/examples/double-ratchet-test.js +0 -155
- package/dist/examples/mls-3-member-test.js +0 -97
- package/dist/examples/mls-multi-member.js +0 -153
- package/dist/examples/mls-sframe-test.js +0 -307
- package/dist/examples/mls-simple-test.js +0 -58
- package/dist/examples/pgp-example.js +0 -200
- package/dist/examples/random-generation-test.js +0 -151
- package/dist/examples/shogun-core-example.js +0 -150
- package/dist/examples/signal-protocol-test.js +0 -38
- package/dist/examples/zkproof-credentials-example.js +0 -217
- package/dist/examples/zkproof-example.js +0 -242
- package/dist/gundb/crypto.js +0 -306
- package/dist/gundb/db.js +0 -485
- package/dist/gundb/derive.js +0 -232
- package/dist/gundb/errors.js +0 -76
- package/dist/gundb/gun-es.js +0 -12
- package/dist/gundb/index.js +0 -21
- package/dist/gundb/min.js +0 -10
- package/dist/index.esm.js +0 -22
- package/dist/index.js +0 -47
- package/dist/interfaces/common.js +0 -2
- package/dist/interfaces/events.js +0 -40
- package/dist/interfaces/plugin.js +0 -2
- package/dist/managers/AuthManager.js +0 -226
- package/dist/managers/CoreInitializer.js +0 -250
- package/dist/managers/CryptoIdentityManager.js +0 -138
- package/dist/plugins/base.js +0 -50
- package/dist/plugins/index.js +0 -32
- package/dist/plugins/nostr/index.js +0 -20
- package/dist/plugins/nostr/nostrConnector.js +0 -419
- package/dist/plugins/nostr/nostrConnectorPlugin.js +0 -453
- package/dist/plugins/nostr/nostrSigner.js +0 -319
- package/dist/plugins/nostr/types.js +0 -2
- package/dist/plugins/smartwallet/index.js +0 -18
- package/dist/plugins/smartwallet/smartWalletPlugin.js +0 -511
- package/dist/plugins/smartwallet/types.js +0 -2
- package/dist/plugins/web3/index.js +0 -20
- package/dist/plugins/web3/types.js +0 -2
- package/dist/plugins/web3/web3Connector.js +0 -533
- package/dist/plugins/web3/web3ConnectorPlugin.js +0 -455
- package/dist/plugins/web3/web3Signer.js +0 -314
- package/dist/plugins/webauthn/index.js +0 -19
- package/dist/plugins/webauthn/webauthn.js +0 -496
- package/dist/plugins/webauthn/webauthnPlugin.js +0 -490
- package/dist/plugins/webauthn/webauthnSigner.js +0 -310
- package/dist/plugins/zkproof/types.js +0 -2
- package/dist/plugins/zkproof/zkCredentials.js +0 -216
- package/dist/plugins/zkproof/zkProofConnector.js +0 -198
- package/dist/plugins/zkproof/zkProofPlugin.js +0 -272
- package/dist/storage/storage.js +0 -145
- package/dist/types/gundb/gun-es.d.ts +0 -8
- package/dist/utils/errorHandler.js +0 -246
- /package/dist/{types/examples/crypto-working-test.d.ts → src/crypto/types.js} +0 -0
- /package/dist/{types/gundb/min.d.ts → src/gundb/min.js} +0 -0
- /package/dist/{types/examples/double-ratchet-test.d.ts → src/interfaces/common.js} +0 -0
- /package/dist/{types/examples/mls-sframe-test.d.ts → src/interfaces/plugin.js} +0 -0
- /package/dist/{types/examples/random-generation-test.d.ts → src/plugins/nostr/types.js} +0 -0
- /package/dist/{types/examples/signal-protocol-test.d.ts → src/plugins/smartwallet/types.js} +0 -0
- /package/dist/types/{core.d.ts → src/core.d.ts} +0 -0
- /package/dist/types/{crypto → src/crypto}/asymmetric.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/file-encryption.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/hashing.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/index.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/mls-codec.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/mls.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/pgp.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/random-generation.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/sframe.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/symmetric.d.ts +0 -0
- /package/dist/types/{crypto → src/crypto}/utils.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/auth-test.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/crypto-identity-example.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/mls-3-member-test.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/mls-multi-member.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/mls-simple-test.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/pgp-example.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/shogun-core-example.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/zkproof-credentials-example.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/zkproof-example.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/crypto.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/derive.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/errors.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/index.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/rxjs.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/types.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/common.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/events.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/plugin.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/shogun.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/AuthManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/CoreInitializer.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/CryptoIdentityManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/EventManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/PluginManager.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/base.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrConnector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrSigner.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/smartwallet/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/smartwallet/smartWalletPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/smartwallet/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3Connector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3Signer.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthn.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthnPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthnSigner.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/zkCredentials.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/zkProofConnector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/zkproof/zkProofPlugin.d.ts +0 -0
- /package/dist/types/{storage → src/storage}/storage.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/errorHandler.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/eventEmitter.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/seedPhrase.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CryptoIdentityManager - Wrapper per la generazione delle identità crypto
|
|
3
|
+
* Genera tutte le identità crypto disponibili. Il salvataggio sarà gestito lato frontend.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
15
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
16
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
17
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
18
|
+
function step(op) {
|
|
19
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
20
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
21
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
22
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
23
|
+
switch (op[0]) {
|
|
24
|
+
case 0: case 1: t = op; break;
|
|
25
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
26
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
27
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
28
|
+
default:
|
|
29
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
30
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
31
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
32
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
33
|
+
if (t[2]) _.ops.pop();
|
|
34
|
+
_.trys.pop(); continue;
|
|
35
|
+
}
|
|
36
|
+
op = body.call(thisArg, _);
|
|
37
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
38
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
import { generateKeyPair as generateRSAKeyPair } from "../crypto/asymmetric.js";
|
|
42
|
+
import { generateSymmetricKey as generateAESKey } from "../crypto/symmetric.js";
|
|
43
|
+
import { initializeSignalUser } from "../crypto/signal-protocol.js";
|
|
44
|
+
import { PGPManager } from "../crypto/pgp.js";
|
|
45
|
+
import { MLSManager } from "../crypto/mls.js";
|
|
46
|
+
import { SFrameManager } from "../crypto/sframe.js";
|
|
47
|
+
import { ErrorHandler, ErrorType } from "../utils/errorHandler.js";
|
|
48
|
+
/**
|
|
49
|
+
* Manager per la generazione delle identità crypto
|
|
50
|
+
* Genera tutte le identità crypto disponibili. Il salvataggio sarà gestito lato frontend.
|
|
51
|
+
*/
|
|
52
|
+
var CryptoIdentityManager = /** @class */ (function () {
|
|
53
|
+
function CryptoIdentityManager() {
|
|
54
|
+
this.pgpManager = new PGPManager();
|
|
55
|
+
this.mlsManager = new MLSManager("default-user");
|
|
56
|
+
this.sframeManager = new SFrameManager();
|
|
57
|
+
// Inizializza PGP Manager
|
|
58
|
+
this.pgpManager.initialize().catch(function (error) {
|
|
59
|
+
console.warn("PGP Manager initialization failed:", error);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Genera tutte le identità crypto disponibili per un utente
|
|
64
|
+
* @param username - Nome utente
|
|
65
|
+
* @param seaPair - Coppia di chiavi SEA dell'utente
|
|
66
|
+
* @returns Promise con le identità generate
|
|
67
|
+
*/
|
|
68
|
+
CryptoIdentityManager.prototype.generateAllIdentities = function (username, seaPair) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var identities, _a, error_1, _b, error_2, _c, error_3, _d, error_4, groupId, groupInfo, error_5, sframeKey, error_6, error_7;
|
|
71
|
+
var _e, _f;
|
|
72
|
+
return __generator(this, function (_g) {
|
|
73
|
+
switch (_g.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
_g.trys.push([0, 27, , 28]);
|
|
76
|
+
console.log("\uD83D\uDD10 [CryptoIdentityManager] Generating crypto identities for: ".concat(username));
|
|
77
|
+
identities = {
|
|
78
|
+
createdAt: Date.now(),
|
|
79
|
+
version: "1.0.0",
|
|
80
|
+
};
|
|
81
|
+
// 1. Genera coppia di chiavi RSA-4096
|
|
82
|
+
console.log("\uD83D\uDD11 [".concat(username, "] Generating RSA key pair..."));
|
|
83
|
+
_g.label = 1;
|
|
84
|
+
case 1:
|
|
85
|
+
_g.trys.push([1, 3, , 4]);
|
|
86
|
+
_a = identities;
|
|
87
|
+
return [4 /*yield*/, generateRSAKeyPair()];
|
|
88
|
+
case 2:
|
|
89
|
+
_a.rsa = _g.sent();
|
|
90
|
+
console.log("\u2705 [".concat(username, "] RSA key pair generated"));
|
|
91
|
+
return [3 /*break*/, 4];
|
|
92
|
+
case 3:
|
|
93
|
+
error_1 = _g.sent();
|
|
94
|
+
console.error("\u274C [".concat(username, "] RSA key generation failed:"), error_1);
|
|
95
|
+
return [3 /*break*/, 4];
|
|
96
|
+
case 4:
|
|
97
|
+
// 2. Genera chiave simmetrica AES-256
|
|
98
|
+
console.log("\uD83D\uDD11 [".concat(username, "] Generating AES symmetric key..."));
|
|
99
|
+
_g.label = 5;
|
|
100
|
+
case 5:
|
|
101
|
+
_g.trys.push([5, 7, , 8]);
|
|
102
|
+
_b = identities;
|
|
103
|
+
return [4 /*yield*/, generateAESKey()];
|
|
104
|
+
case 6:
|
|
105
|
+
_b.aes = _g.sent();
|
|
106
|
+
console.log("\u2705 [".concat(username, "] AES symmetric key generated"));
|
|
107
|
+
return [3 /*break*/, 8];
|
|
108
|
+
case 7:
|
|
109
|
+
error_2 = _g.sent();
|
|
110
|
+
console.error("\u274C [".concat(username, "] AES key generation failed:"), error_2);
|
|
111
|
+
return [3 /*break*/, 8];
|
|
112
|
+
case 8:
|
|
113
|
+
// 3. Genera identità Signal Protocol
|
|
114
|
+
console.log("\uD83D\uDD11 [".concat(username, "] Generating Signal Protocol identity..."));
|
|
115
|
+
_g.label = 9;
|
|
116
|
+
case 9:
|
|
117
|
+
_g.trys.push([9, 11, , 12]);
|
|
118
|
+
_c = identities;
|
|
119
|
+
return [4 /*yield*/, initializeSignalUser(username)];
|
|
120
|
+
case 10:
|
|
121
|
+
_c.signal = _g.sent();
|
|
122
|
+
console.log("\u2705 [".concat(username, "] Signal Protocol identity generated"));
|
|
123
|
+
return [3 /*break*/, 12];
|
|
124
|
+
case 11:
|
|
125
|
+
error_3 = _g.sent();
|
|
126
|
+
console.error("\u274C [".concat(username, "] Signal Protocol generation failed:"), error_3);
|
|
127
|
+
return [3 /*break*/, 12];
|
|
128
|
+
case 12:
|
|
129
|
+
// 4. Genera coppia di chiavi PGP
|
|
130
|
+
console.log("\uD83D\uDD11 [".concat(username, "] Generating PGP key pair..."));
|
|
131
|
+
_g.label = 13;
|
|
132
|
+
case 13:
|
|
133
|
+
_g.trys.push([13, 15, , 16]);
|
|
134
|
+
_d = identities;
|
|
135
|
+
return [4 /*yield*/, this.pgpManager.generateKeyPair(username, "".concat(username, "@example.com"))];
|
|
136
|
+
case 14:
|
|
137
|
+
_d.pgp = _g.sent();
|
|
138
|
+
console.log("\u2705 [".concat(username, "] PGP key pair generated"));
|
|
139
|
+
return [3 /*break*/, 16];
|
|
140
|
+
case 15:
|
|
141
|
+
error_4 = _g.sent();
|
|
142
|
+
console.error("\u274C [".concat(username, "] PGP key generation failed:"), error_4);
|
|
143
|
+
return [3 /*break*/, 16];
|
|
144
|
+
case 16:
|
|
145
|
+
// 5. Inizializza MLS Manager e crea gruppo
|
|
146
|
+
console.log("\uD83D\uDD11 [".concat(username, "] Initializing MLS group..."));
|
|
147
|
+
_g.label = 17;
|
|
148
|
+
case 17:
|
|
149
|
+
_g.trys.push([17, 20, , 21]);
|
|
150
|
+
return [4 /*yield*/, this.mlsManager.initialize()];
|
|
151
|
+
case 18:
|
|
152
|
+
_g.sent();
|
|
153
|
+
groupId = "group_".concat(username, "_").concat(Date.now());
|
|
154
|
+
return [4 /*yield*/, this.mlsManager.createGroup(groupId)];
|
|
155
|
+
case 19:
|
|
156
|
+
groupInfo = _g.sent();
|
|
157
|
+
// Skip adding members for now due to MLS library issues
|
|
158
|
+
// await this.mlsManager.addMembers(groupId, [username]);
|
|
159
|
+
identities.mls = {
|
|
160
|
+
groupId: groupInfo.groupId.toString(),
|
|
161
|
+
memberId: username,
|
|
162
|
+
};
|
|
163
|
+
console.log("\u2705 [".concat(username, "] MLS group created: ").concat(groupId));
|
|
164
|
+
return [3 /*break*/, 21];
|
|
165
|
+
case 20:
|
|
166
|
+
error_5 = _g.sent();
|
|
167
|
+
console.error("\u274C [".concat(username, "] MLS initialization failed:"), error_5);
|
|
168
|
+
return [3 /*break*/, 21];
|
|
169
|
+
case 21:
|
|
170
|
+
// 6. Genera chiave SFrame
|
|
171
|
+
console.log("\uD83D\uDD11 [".concat(username, "] Generating SFrame key..."));
|
|
172
|
+
_g.label = 22;
|
|
173
|
+
case 22:
|
|
174
|
+
_g.trys.push([22, 25, , 26]);
|
|
175
|
+
return [4 /*yield*/, this.sframeManager.initialize()];
|
|
176
|
+
case 23:
|
|
177
|
+
_g.sent();
|
|
178
|
+
return [4 /*yield*/, this.sframeManager.generateKey(1)];
|
|
179
|
+
case 24:
|
|
180
|
+
sframeKey = _g.sent();
|
|
181
|
+
identities.sframe = { keyId: sframeKey.keyId };
|
|
182
|
+
console.log("\u2705 [".concat(username, "] SFrame key generated: ").concat(sframeKey.keyId));
|
|
183
|
+
return [3 /*break*/, 26];
|
|
184
|
+
case 25:
|
|
185
|
+
error_6 = _g.sent();
|
|
186
|
+
console.error("\u274C [".concat(username, "] SFrame key generation failed:"), error_6);
|
|
187
|
+
return [3 /*break*/, 26];
|
|
188
|
+
case 26:
|
|
189
|
+
console.log("\u2705 [CryptoIdentityManager] All crypto identities generated for: ".concat(username));
|
|
190
|
+
// Force garbage collection after generation
|
|
191
|
+
if (typeof global !== "undefined" && global.gc) {
|
|
192
|
+
global.gc();
|
|
193
|
+
console.log("\uD83E\uDDF9 [".concat(username, "] Forced garbage collection after identity generation"));
|
|
194
|
+
}
|
|
195
|
+
return [2 /*return*/, {
|
|
196
|
+
success: true,
|
|
197
|
+
identities: identities,
|
|
198
|
+
}];
|
|
199
|
+
case 27:
|
|
200
|
+
error_7 = _g.sent();
|
|
201
|
+
console.error("\u274C [CryptoIdentityManager] Identity generation failed:", error_7);
|
|
202
|
+
ErrorHandler.handle(ErrorType.ENCRYPTION, "IDENTITY_GENERATION_FAILED", (_e = error_7.message) !== null && _e !== void 0 ? _e : "Failed to generate crypto identities", error_7);
|
|
203
|
+
return [2 /*return*/, {
|
|
204
|
+
success: false,
|
|
205
|
+
error: (_f = error_7.message) !== null && _f !== void 0 ? _f : "Failed to generate crypto identities",
|
|
206
|
+
}];
|
|
207
|
+
case 28: return [2 /*return*/];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Genera le identità crypto per un utente
|
|
214
|
+
* Wrapper che chiama generateAllIdentities (mantenuto per compatibilità)
|
|
215
|
+
* @param username - Nome utente
|
|
216
|
+
* @param seaPair - Coppia di chiavi SEA dell'utente (opzionale, non più utilizzato ma mantenuto per compatibilità)
|
|
217
|
+
* @param forceRegenerate - Ignorato, genera sempre nuove identità
|
|
218
|
+
* @returns Promise con le identità generate
|
|
219
|
+
*/
|
|
220
|
+
CryptoIdentityManager.prototype.setupCryptoIdentities = function (username_1, seaPair_1) {
|
|
221
|
+
return __awaiter(this, arguments, void 0, function (username, seaPair, forceRegenerate) {
|
|
222
|
+
if (forceRegenerate === void 0) { forceRegenerate = false; }
|
|
223
|
+
return __generator(this, function (_a) {
|
|
224
|
+
return [2 /*return*/, this.generateAllIdentities(username, seaPair)];
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
return CryptoIdentityManager;
|
|
229
|
+
}());
|
|
230
|
+
export { CryptoIdentityManager };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventManager = void 0;
|
|
4
|
-
const events_1 = require("../interfaces/events");
|
|
1
|
+
import { ShogunEventEmitter } from "../interfaces/events.js";
|
|
5
2
|
/**
|
|
6
3
|
* Manages event operations for ShogunCore
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.eventEmitter = new
|
|
5
|
+
var EventManager = /** @class */ (function () {
|
|
6
|
+
function EventManager() {
|
|
7
|
+
this.eventEmitter = new ShogunEventEmitter();
|
|
11
8
|
}
|
|
12
9
|
/**
|
|
13
10
|
* Emits an event through the core's event emitter.
|
|
@@ -16,55 +13,56 @@ class EventManager {
|
|
|
16
13
|
* @param data The data to pass with the event.
|
|
17
14
|
* @returns {boolean} Indicates if the event had listeners.
|
|
18
15
|
*/
|
|
19
|
-
emit(eventName, data) {
|
|
16
|
+
EventManager.prototype.emit = function (eventName, data) {
|
|
20
17
|
return this.eventEmitter.emit(eventName, data);
|
|
21
|
-
}
|
|
18
|
+
};
|
|
22
19
|
/**
|
|
23
20
|
* Add an event listener
|
|
24
21
|
* @param eventName The name of the event to listen for
|
|
25
22
|
* @param listener The callback function to execute when the event is emitted
|
|
26
23
|
* @returns {this} Returns this instance for method chaining
|
|
27
24
|
*/
|
|
28
|
-
on(eventName, listener) {
|
|
25
|
+
EventManager.prototype.on = function (eventName, listener) {
|
|
29
26
|
this.eventEmitter.on(eventName, listener);
|
|
30
27
|
return this;
|
|
31
|
-
}
|
|
28
|
+
};
|
|
32
29
|
/**
|
|
33
30
|
* Add a one-time event listener
|
|
34
31
|
* @param eventName The name of the event to listen for
|
|
35
32
|
* @param listener The callback function to execute when the event is emitted
|
|
36
33
|
* @returns {this} Returns this instance for method chaining
|
|
37
34
|
*/
|
|
38
|
-
once(eventName, listener) {
|
|
35
|
+
EventManager.prototype.once = function (eventName, listener) {
|
|
39
36
|
this.eventEmitter.once(eventName, listener);
|
|
40
37
|
return this;
|
|
41
|
-
}
|
|
38
|
+
};
|
|
42
39
|
/**
|
|
43
40
|
* Remove an event listener
|
|
44
41
|
* @param eventName The name of the event to stop listening for
|
|
45
42
|
* @param listener The callback function to remove
|
|
46
43
|
* @returns {this} Returns this instance for method chaining
|
|
47
44
|
*/
|
|
48
|
-
off(eventName, listener) {
|
|
45
|
+
EventManager.prototype.off = function (eventName, listener) {
|
|
49
46
|
this.eventEmitter.off(eventName, listener);
|
|
50
47
|
return this;
|
|
51
|
-
}
|
|
48
|
+
};
|
|
52
49
|
/**
|
|
53
50
|
* Remove all listeners for a specific event or all events
|
|
54
51
|
* @param eventName Optional. The name of the event to remove listeners for.
|
|
55
52
|
* If not provided, all listeners for all events are removed.
|
|
56
53
|
* @returns {this} Returns this instance for method chaining
|
|
57
54
|
*/
|
|
58
|
-
removeAllListeners(eventName) {
|
|
55
|
+
EventManager.prototype.removeAllListeners = function (eventName) {
|
|
59
56
|
this.eventEmitter.removeAllListeners(eventName);
|
|
60
57
|
return this;
|
|
61
|
-
}
|
|
58
|
+
};
|
|
62
59
|
/**
|
|
63
60
|
* Get the underlying event emitter instance
|
|
64
61
|
* @returns The ShogunEventEmitter instance
|
|
65
62
|
*/
|
|
66
|
-
getEventEmitter() {
|
|
63
|
+
EventManager.prototype.getEventEmitter = function () {
|
|
67
64
|
return this.eventEmitter;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
};
|
|
66
|
+
return EventManager;
|
|
67
|
+
}());
|
|
68
|
+
export { EventManager };
|