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
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthManager = void 0;
|
|
4
|
-
const errorHandler_1 = require("../utils/errorHandler");
|
|
5
|
-
/**
|
|
6
|
-
* Manages authentication operations for ShogunCore
|
|
7
|
-
*/
|
|
8
|
-
class AuthManager {
|
|
9
|
-
constructor(core) {
|
|
10
|
-
this.core = core;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Check if user is logged in
|
|
14
|
-
* @returns {boolean} True if user is logged in, false otherwise
|
|
15
|
-
* @description Verifies authentication status by checking GunInstance login state
|
|
16
|
-
* and presence of authentication credentials in storage
|
|
17
|
-
*/
|
|
18
|
-
isLoggedIn() {
|
|
19
|
-
return this.core.db.isLoggedIn();
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Perform user logout
|
|
23
|
-
* @description Logs out the current user from GunInstance and emits logout event.
|
|
24
|
-
* If user is not authenticated, the logout operation is ignored.
|
|
25
|
-
*/
|
|
26
|
-
logout() {
|
|
27
|
-
try {
|
|
28
|
-
if (!this.isLoggedIn()) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
this.core.db.logout();
|
|
32
|
-
this.core.emit("auth:logout");
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.AUTHENTICATION, "LOGOUT_FAILED", error instanceof Error ? error.message : "Error during logout", error);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Authenticate user with username and password
|
|
40
|
-
* @param username - Username
|
|
41
|
-
* @param password - User password
|
|
42
|
-
* @returns {Promise<AuthResult>} Promise with authentication result
|
|
43
|
-
* @description Attempts to log in user with provided credentials.
|
|
44
|
-
* Emits login event on success.
|
|
45
|
-
*/
|
|
46
|
-
async login(username, password, pair) {
|
|
47
|
-
try {
|
|
48
|
-
if (!this.currentAuthMethod) {
|
|
49
|
-
this.currentAuthMethod = "password";
|
|
50
|
-
}
|
|
51
|
-
const result = await this.core.db.login(username, password, pair);
|
|
52
|
-
if (result.success) {
|
|
53
|
-
// Include SEA pair in the response
|
|
54
|
-
const seaPair = this.core.user?._?.sea;
|
|
55
|
-
if (seaPair) {
|
|
56
|
-
result.sea = seaPair;
|
|
57
|
-
}
|
|
58
|
-
this.core.emit("auth:login", {
|
|
59
|
-
userPub: result.userPub ?? "",
|
|
60
|
-
method: this.currentAuthMethod === "pair"
|
|
61
|
-
? "password"
|
|
62
|
-
: this.currentAuthMethod || "password",
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
result.error = result.error || "Wrong user or password";
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.AUTHENTICATION, "LOGIN_FAILED", error.message ?? "Unknown error during login", error);
|
|
72
|
-
return {
|
|
73
|
-
success: false,
|
|
74
|
-
error: error.message ?? "Unknown error during login",
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Login with GunDB pair directly
|
|
80
|
-
* @param pair - GunDB SEA pair for authentication
|
|
81
|
-
* @returns {Promise<AuthResult>} Promise with authentication result
|
|
82
|
-
* @description Authenticates user using a GunDB pair directly.
|
|
83
|
-
* Emits login event on success.
|
|
84
|
-
*/
|
|
85
|
-
async loginWithPair(username, pair) {
|
|
86
|
-
try {
|
|
87
|
-
if (!pair || !pair.pub || !pair.priv || !pair.epub || !pair.epriv) {
|
|
88
|
-
return {
|
|
89
|
-
success: false,
|
|
90
|
-
error: "Invalid pair structure - missing required keys",
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
// Use the new loginWithPair method from GunInstance
|
|
94
|
-
const result = await this.core.db.loginWithPair(username, pair);
|
|
95
|
-
if (result.success) {
|
|
96
|
-
// Include SEA pair in the response
|
|
97
|
-
const seaPair = this.core.user?._?.sea;
|
|
98
|
-
if (seaPair) {
|
|
99
|
-
result.sea = seaPair;
|
|
100
|
-
}
|
|
101
|
-
this.currentAuthMethod = "pair";
|
|
102
|
-
this.core.emit("auth:login", {
|
|
103
|
-
userPub: result.userPub ?? "",
|
|
104
|
-
method: "pair",
|
|
105
|
-
username,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
result.error =
|
|
110
|
-
result.error || "Authentication failed with provided pair";
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.AUTHENTICATION, "PAIR_LOGIN_FAILED", error.message ?? "Unknown error during pair login", error);
|
|
116
|
-
return {
|
|
117
|
-
success: false,
|
|
118
|
-
error: error.message ?? "Unknown error during pair login",
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Register a new user with provided credentials
|
|
124
|
-
* @param username - Username
|
|
125
|
-
* @param password - Password
|
|
126
|
-
* @param email - Email (optional)
|
|
127
|
-
* @param pair - Pair of keys
|
|
128
|
-
* @returns {Promise<SignUpResult>} Registration result
|
|
129
|
-
* @description Creates a new user account with the provided credentials.
|
|
130
|
-
* Validates password requirements and emits signup event on success.
|
|
131
|
-
*/
|
|
132
|
-
async signUp(username, password, pair) {
|
|
133
|
-
try {
|
|
134
|
-
if (!this.core.db) {
|
|
135
|
-
throw new Error("Database not initialized");
|
|
136
|
-
}
|
|
137
|
-
// For password-based signup, ensure password is provided
|
|
138
|
-
if (!pair && (!password || password.trim() === "")) {
|
|
139
|
-
throw new Error("Password is required for password-based signup");
|
|
140
|
-
}
|
|
141
|
-
const result = await this.core.db.signUp(username, password || "", pair);
|
|
142
|
-
if (result.success) {
|
|
143
|
-
// Update current authentication method
|
|
144
|
-
this.currentAuthMethod = pair ? "web3" : "password";
|
|
145
|
-
this.core.emit("auth:signup", {
|
|
146
|
-
userPub: result.userPub,
|
|
147
|
-
username,
|
|
148
|
-
method: this.currentAuthMethod,
|
|
149
|
-
});
|
|
150
|
-
this.core.emit("debug", {
|
|
151
|
-
action: "signup_success",
|
|
152
|
-
userPub: result.userPub,
|
|
153
|
-
method: this.currentAuthMethod,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
this.core.emit("debug", {
|
|
158
|
-
action: "signup_failed",
|
|
159
|
-
error: result.error,
|
|
160
|
-
username,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
return result;
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
if (typeof console !== "undefined" && console.error) {
|
|
167
|
-
console.error(`Error during registration for user ${username}:`, error);
|
|
168
|
-
}
|
|
169
|
-
this.core.emit("debug", {
|
|
170
|
-
action: "signup_error",
|
|
171
|
-
error: error instanceof Error ? error.message : String(error),
|
|
172
|
-
username,
|
|
173
|
-
});
|
|
174
|
-
return {
|
|
175
|
-
success: false,
|
|
176
|
-
error: `Registration failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Set the current authentication method
|
|
182
|
-
* This is used by plugins to indicate which authentication method was used
|
|
183
|
-
* @param method The authentication method used
|
|
184
|
-
*/
|
|
185
|
-
setAuthMethod(method) {
|
|
186
|
-
this.currentAuthMethod = method;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Get the current authentication method
|
|
190
|
-
* @returns The current authentication method or undefined if not set
|
|
191
|
-
*/
|
|
192
|
-
getAuthMethod() {
|
|
193
|
-
return this.currentAuthMethod;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Get an authentication method plugin by type
|
|
197
|
-
* @param type The type of authentication method
|
|
198
|
-
* @returns The authentication plugin or undefined if not available
|
|
199
|
-
* This is a more modern approach to accessing authentication methods
|
|
200
|
-
*/
|
|
201
|
-
getAuthenticationMethod(type) {
|
|
202
|
-
switch (type) {
|
|
203
|
-
case "webauthn":
|
|
204
|
-
return this.core.getPlugin("webauthn");
|
|
205
|
-
case "web3":
|
|
206
|
-
return this.core.getPlugin("web3");
|
|
207
|
-
case "nostr":
|
|
208
|
-
return this.core.getPlugin("nostr");
|
|
209
|
-
case "password":
|
|
210
|
-
default:
|
|
211
|
-
return {
|
|
212
|
-
login: async (username, password) => {
|
|
213
|
-
return await this.login(username, password);
|
|
214
|
-
},
|
|
215
|
-
signUp: async (username, password, confirm) => {
|
|
216
|
-
// For password-based signup, validate password confirmation
|
|
217
|
-
if (confirm && password !== confirm) {
|
|
218
|
-
throw new Error("Password and confirm password do not match");
|
|
219
|
-
}
|
|
220
|
-
return await this.signUp(username, password);
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
exports.AuthManager = AuthManager;
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoreInitializer = void 0;
|
|
4
|
-
const storage_1 = require("../storage/storage");
|
|
5
|
-
const errorHandler_1 = require("../utils/errorHandler");
|
|
6
|
-
const webauthnPlugin_1 = require("../plugins/webauthn/webauthnPlugin");
|
|
7
|
-
const web3ConnectorPlugin_1 = require("../plugins/web3/web3ConnectorPlugin");
|
|
8
|
-
const nostrConnectorPlugin_1 = require("../plugins/nostr/nostrConnectorPlugin");
|
|
9
|
-
const zkProofPlugin_1 = require("../plugins/zkproof/zkProofPlugin");
|
|
10
|
-
const db_1 = require("../gundb/db");
|
|
11
|
-
/**
|
|
12
|
-
* Handles initialization of ShogunCore components
|
|
13
|
-
*/
|
|
14
|
-
class CoreInitializer {
|
|
15
|
-
constructor(core) {
|
|
16
|
-
this.core = core;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Initialize the Shogun SDK
|
|
20
|
-
* @param config - SDK Configuration object
|
|
21
|
-
* @description Creates a new instance of ShogunCore with the provided configuration.
|
|
22
|
-
* Initializes all required components including storage, event emitter, GunInstance connection,
|
|
23
|
-
* and plugin system.
|
|
24
|
-
*/
|
|
25
|
-
async initialize(config) {
|
|
26
|
-
// Polyfill console for environments where it might be missing
|
|
27
|
-
if (typeof console === "undefined") {
|
|
28
|
-
global.console = {
|
|
29
|
-
log: () => { },
|
|
30
|
-
warn: () => { },
|
|
31
|
-
error: () => { },
|
|
32
|
-
info: () => { },
|
|
33
|
-
debug: () => { },
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
// Initialize storage
|
|
37
|
-
this.core.storage = new storage_1.ShogunStorage(config.silent);
|
|
38
|
-
// Setup error handler
|
|
39
|
-
errorHandler_1.ErrorHandler.addListener((error) => {
|
|
40
|
-
this.core.emit("error", {
|
|
41
|
-
action: error.code,
|
|
42
|
-
message: error.message,
|
|
43
|
-
type: error.type,
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
// Setup Gun instance
|
|
47
|
-
this.initializeGun(config);
|
|
48
|
-
// Setup Gun user
|
|
49
|
-
this.initializeGunUser();
|
|
50
|
-
// Setup Gun event forwarding
|
|
51
|
-
this.setupGunEventForwarding();
|
|
52
|
-
// Setup wallet derivation
|
|
53
|
-
this.setupWalletDerivation();
|
|
54
|
-
// Initialize RxJS
|
|
55
|
-
this.core.rx = new db_1.RxJS(this.core.gun);
|
|
56
|
-
// Register built-in plugins
|
|
57
|
-
this.registerBuiltinPlugins(config);
|
|
58
|
-
// Initialize async components
|
|
59
|
-
this.initializeDb();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Initialize Gun instance
|
|
63
|
-
*/
|
|
64
|
-
initializeGun(config) {
|
|
65
|
-
try {
|
|
66
|
-
if (!config.gunInstance) {
|
|
67
|
-
throw new Error("Gun instance is required but was not provided");
|
|
68
|
-
}
|
|
69
|
-
// Validate Gun instance
|
|
70
|
-
if (typeof config.gunInstance !== "object") {
|
|
71
|
-
throw new Error(`Gun instance must be an object, received: ${typeof config.gunInstance}`);
|
|
72
|
-
}
|
|
73
|
-
if (typeof config.gunInstance.user !== "function") {
|
|
74
|
-
throw new Error(`Gun instance is invalid: gun.user is not a function. Received gun.user type: ${typeof config.gunInstance.user}`);
|
|
75
|
-
}
|
|
76
|
-
if (typeof config.gunInstance.get !== "function") {
|
|
77
|
-
throw new Error(`Gun instance is invalid: gun.get is not a function. Received gun.get type: ${typeof config.gunInstance.get}`);
|
|
78
|
-
}
|
|
79
|
-
if (typeof config.gunInstance.on !== "function") {
|
|
80
|
-
throw new Error(`Gun instance is invalid: gun.on is not a function. Received gun.on type: ${typeof config.gunInstance.on}`);
|
|
81
|
-
}
|
|
82
|
-
console.log("Using provided Gun instance:", config.gunInstance);
|
|
83
|
-
this.core._gun = config.gunInstance;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
if (typeof console !== "undefined" && console.error) {
|
|
87
|
-
console.error("Error validating Gun instance:", error);
|
|
88
|
-
}
|
|
89
|
-
throw new Error(`Failed to validate Gun instance: ${error}`);
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
// Get SEA from Gun instance or global
|
|
93
|
-
let sea = this.core._gun.SEA || null;
|
|
94
|
-
if (!sea) {
|
|
95
|
-
// Try to find SEA in various global locations
|
|
96
|
-
if (typeof window !== "undefined" &&
|
|
97
|
-
window.Gun &&
|
|
98
|
-
window.Gun.SEA) {
|
|
99
|
-
sea = window.Gun.SEA;
|
|
100
|
-
}
|
|
101
|
-
else if (globalThis.Gun && globalThis.Gun.SEA) {
|
|
102
|
-
sea = globalThis.Gun.SEA;
|
|
103
|
-
}
|
|
104
|
-
else if (global.Gun && global.Gun.SEA) {
|
|
105
|
-
sea = global.Gun.SEA;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
this.core.db = new db_1.DataBase(this.core._gun, "shogun", // Default app scope
|
|
109
|
-
this.core, sea);
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
if (typeof console !== "undefined" && console.error) {
|
|
114
|
-
console.error("Error initializing DataBase:", error);
|
|
115
|
-
}
|
|
116
|
-
throw new Error(`Failed to initialize DataBase: ${error}`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Initialize Gun user
|
|
121
|
-
*/
|
|
122
|
-
initializeGunUser() {
|
|
123
|
-
try {
|
|
124
|
-
this.core._user = this.core.gun.user().recall({ sessionStorage: true });
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
if (typeof console !== "undefined" && console.error) {
|
|
128
|
-
console.error("Error initializing Gun user:", error);
|
|
129
|
-
}
|
|
130
|
-
throw new Error(`Failed to initialize Gun user: ${error}`);
|
|
131
|
-
}
|
|
132
|
-
this.core.gun.on("auth", (user) => {
|
|
133
|
-
this.core._user = this.core.gun.user().recall({ sessionStorage: true });
|
|
134
|
-
this.core.emit("auth:login", {
|
|
135
|
-
userPub: user.pub,
|
|
136
|
-
method: "password",
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Setup Gun event forwarding
|
|
142
|
-
*/
|
|
143
|
-
setupGunEventForwarding() {
|
|
144
|
-
const gunEvents = ["gun:put", "gun:get", "gun:set", "gun:remove"];
|
|
145
|
-
gunEvents.forEach((eventName) => {
|
|
146
|
-
this.core.db.on(eventName, (data) => {
|
|
147
|
-
this.core.emit(eventName, data);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
const peerEvents = [
|
|
151
|
-
"gun:peer:add",
|
|
152
|
-
"gun:peer:remove",
|
|
153
|
-
"gun:peer:connect",
|
|
154
|
-
"gun:peer:disconnect",
|
|
155
|
-
];
|
|
156
|
-
peerEvents.forEach((eventName) => {
|
|
157
|
-
this.core.db.on(eventName, (data) => {
|
|
158
|
-
this.core.emit(eventName, data);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Setup wallet derivation
|
|
164
|
-
*/
|
|
165
|
-
setupWalletDerivation() {
|
|
166
|
-
this.core.gun.on("auth", async (user) => {
|
|
167
|
-
if (!user.is)
|
|
168
|
-
return;
|
|
169
|
-
const priv = user._?.sea?.epriv;
|
|
170
|
-
const pub = user._?.sea?.epub;
|
|
171
|
-
this.core.wallets = await (0, db_1.derive)(priv, pub, {
|
|
172
|
-
includeSecp256k1Bitcoin: true,
|
|
173
|
-
includeSecp256k1Ethereum: true,
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Register built-in plugins based on configuration
|
|
179
|
-
*/
|
|
180
|
-
registerBuiltinPlugins(config) {
|
|
181
|
-
try {
|
|
182
|
-
// Register WebAuthn plugin if configuration is provided
|
|
183
|
-
if (config.webauthn) {
|
|
184
|
-
if (typeof console !== "undefined" && console.warn) {
|
|
185
|
-
console.warn("WebAuthn plugin will be registered with provided configuration");
|
|
186
|
-
}
|
|
187
|
-
const webauthnPlugin = new webauthnPlugin_1.WebauthnPlugin();
|
|
188
|
-
if (typeof webauthnPlugin.configure === "function") {
|
|
189
|
-
webauthnPlugin.configure(config.webauthn);
|
|
190
|
-
}
|
|
191
|
-
this.core.pluginManager.register(webauthnPlugin);
|
|
192
|
-
}
|
|
193
|
-
// Register Web3 plugin if configuration is provided
|
|
194
|
-
if (config.web3) {
|
|
195
|
-
if (typeof console !== "undefined" && console.warn) {
|
|
196
|
-
console.warn("Web3 plugin will be registered with provided configuration");
|
|
197
|
-
}
|
|
198
|
-
const web3Plugin = new web3ConnectorPlugin_1.Web3ConnectorPlugin();
|
|
199
|
-
if (typeof web3Plugin.configure === "function") {
|
|
200
|
-
web3Plugin.configure(config.web3);
|
|
201
|
-
}
|
|
202
|
-
this.core.pluginManager.register(web3Plugin);
|
|
203
|
-
}
|
|
204
|
-
// Register Nostr plugin if configuration is provided
|
|
205
|
-
if (config.nostr) {
|
|
206
|
-
if (typeof console !== "undefined" && console.warn) {
|
|
207
|
-
console.warn("Nostr plugin will be registered with provided configuration");
|
|
208
|
-
}
|
|
209
|
-
const nostrPlugin = new nostrConnectorPlugin_1.NostrConnectorPlugin();
|
|
210
|
-
if (typeof nostrPlugin.configure === "function") {
|
|
211
|
-
nostrPlugin.configure(config.nostr);
|
|
212
|
-
}
|
|
213
|
-
this.core.pluginManager.register(nostrPlugin);
|
|
214
|
-
}
|
|
215
|
-
// Register ZK-Proof plugin if configuration is provided
|
|
216
|
-
if (config.zkproof) {
|
|
217
|
-
if (typeof console !== "undefined" && console.warn) {
|
|
218
|
-
console.warn("ZK-Proof plugin will be registered with provided configuration");
|
|
219
|
-
}
|
|
220
|
-
const zkproofPlugin = new zkProofPlugin_1.ZkProofPlugin(config.zkproof);
|
|
221
|
-
this.core.pluginManager.register(zkproofPlugin);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
catch (error) {
|
|
225
|
-
if (typeof console !== "undefined" && console.error) {
|
|
226
|
-
console.error("Error registering builtin plugins:", error);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Initialize async components
|
|
232
|
-
*/
|
|
233
|
-
initializeDb() {
|
|
234
|
-
try {
|
|
235
|
-
this.core.db.initialize();
|
|
236
|
-
this.core.emit("debug", {
|
|
237
|
-
action: "core_initialized",
|
|
238
|
-
timestamp: Date.now(),
|
|
239
|
-
});
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
if (typeof console !== "undefined" && console.error) {
|
|
244
|
-
console.error("Error during Shogun Core initialization:", error);
|
|
245
|
-
}
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
exports.CoreInitializer = CoreInitializer;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CryptoIdentityManager - Wrapper per la generazione delle identità crypto
|
|
4
|
-
* Genera tutte le identità crypto disponibili. Il salvataggio sarà gestito lato frontend.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.CryptoIdentityManager = void 0;
|
|
8
|
-
const asymmetric_1 = require("../crypto/asymmetric");
|
|
9
|
-
const symmetric_1 = require("../crypto/symmetric");
|
|
10
|
-
const signal_protocol_1 = require("../crypto/signal-protocol");
|
|
11
|
-
const pgp_1 = require("../crypto/pgp");
|
|
12
|
-
const mls_1 = require("../crypto/mls");
|
|
13
|
-
const sframe_1 = require("../crypto/sframe");
|
|
14
|
-
const errorHandler_1 = require("../utils/errorHandler");
|
|
15
|
-
/**
|
|
16
|
-
* Manager per la generazione delle identità crypto
|
|
17
|
-
* Genera tutte le identità crypto disponibili. Il salvataggio sarà gestito lato frontend.
|
|
18
|
-
*/
|
|
19
|
-
class CryptoIdentityManager {
|
|
20
|
-
constructor() {
|
|
21
|
-
this.pgpManager = new pgp_1.PGPManager();
|
|
22
|
-
this.mlsManager = new mls_1.MLSManager("default-user");
|
|
23
|
-
this.sframeManager = new sframe_1.SFrameManager();
|
|
24
|
-
// Inizializza PGP Manager
|
|
25
|
-
this.pgpManager.initialize().catch((error) => {
|
|
26
|
-
console.warn("PGP Manager initialization failed:", error);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Genera tutte le identità crypto disponibili per un utente
|
|
31
|
-
* @param username - Nome utente
|
|
32
|
-
* @param seaPair - Coppia di chiavi SEA dell'utente
|
|
33
|
-
* @returns Promise con le identità generate
|
|
34
|
-
*/
|
|
35
|
-
async generateAllIdentities(username, seaPair) {
|
|
36
|
-
try {
|
|
37
|
-
console.log(`🔐 [CryptoIdentityManager] Generating crypto identities for: ${username}`);
|
|
38
|
-
const identities = {
|
|
39
|
-
createdAt: Date.now(),
|
|
40
|
-
version: "1.0.0",
|
|
41
|
-
};
|
|
42
|
-
// 1. Genera coppia di chiavi RSA-4096
|
|
43
|
-
console.log(`🔑 [${username}] Generating RSA key pair...`);
|
|
44
|
-
try {
|
|
45
|
-
identities.rsa = await (0, asymmetric_1.generateKeyPair)();
|
|
46
|
-
console.log(`✅ [${username}] RSA key pair generated`);
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
console.error(`❌ [${username}] RSA key generation failed:`, error);
|
|
50
|
-
}
|
|
51
|
-
// 2. Genera chiave simmetrica AES-256
|
|
52
|
-
console.log(`🔑 [${username}] Generating AES symmetric key...`);
|
|
53
|
-
try {
|
|
54
|
-
identities.aes = await (0, symmetric_1.generateSymmetricKey)();
|
|
55
|
-
console.log(`✅ [${username}] AES symmetric key generated`);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.error(`❌ [${username}] AES key generation failed:`, error);
|
|
59
|
-
}
|
|
60
|
-
// 3. Genera identità Signal Protocol
|
|
61
|
-
console.log(`🔑 [${username}] Generating Signal Protocol identity...`);
|
|
62
|
-
try {
|
|
63
|
-
identities.signal = await (0, signal_protocol_1.initializeSignalUser)(username);
|
|
64
|
-
console.log(`✅ [${username}] Signal Protocol identity generated`);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
console.error(`❌ [${username}] Signal Protocol generation failed:`, error);
|
|
68
|
-
}
|
|
69
|
-
// 4. Genera coppia di chiavi PGP
|
|
70
|
-
console.log(`🔑 [${username}] Generating PGP key pair...`);
|
|
71
|
-
try {
|
|
72
|
-
identities.pgp = await this.pgpManager.generateKeyPair(username, `${username}@example.com`);
|
|
73
|
-
console.log(`✅ [${username}] PGP key pair generated`);
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.error(`❌ [${username}] PGP key generation failed:`, error);
|
|
77
|
-
}
|
|
78
|
-
// 5. Inizializza MLS Manager e crea gruppo
|
|
79
|
-
console.log(`🔑 [${username}] Initializing MLS group...`);
|
|
80
|
-
try {
|
|
81
|
-
await this.mlsManager.initialize();
|
|
82
|
-
const groupId = `group_${username}_${Date.now()}`;
|
|
83
|
-
const groupInfo = await this.mlsManager.createGroup(groupId);
|
|
84
|
-
// Skip adding members for now due to MLS library issues
|
|
85
|
-
// await this.mlsManager.addMembers(groupId, [username]);
|
|
86
|
-
identities.mls = {
|
|
87
|
-
groupId: groupInfo.groupId.toString(),
|
|
88
|
-
memberId: username,
|
|
89
|
-
};
|
|
90
|
-
console.log(`✅ [${username}] MLS group created: ${groupId}`);
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
console.error(`❌ [${username}] MLS initialization failed:`, error);
|
|
94
|
-
}
|
|
95
|
-
// 6. Genera chiave SFrame
|
|
96
|
-
console.log(`🔑 [${username}] Generating SFrame key...`);
|
|
97
|
-
try {
|
|
98
|
-
await this.sframeManager.initialize();
|
|
99
|
-
const sframeKey = await this.sframeManager.generateKey(1);
|
|
100
|
-
identities.sframe = { keyId: sframeKey.keyId };
|
|
101
|
-
console.log(`✅ [${username}] SFrame key generated: ${sframeKey.keyId}`);
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
console.error(`❌ [${username}] SFrame key generation failed:`, error);
|
|
105
|
-
}
|
|
106
|
-
console.log(`✅ [CryptoIdentityManager] All crypto identities generated for: ${username}`);
|
|
107
|
-
// Force garbage collection after generation
|
|
108
|
-
if (typeof global !== "undefined" && global.gc) {
|
|
109
|
-
global.gc();
|
|
110
|
-
console.log(`🧹 [${username}] Forced garbage collection after identity generation`);
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
success: true,
|
|
114
|
-
identities,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
console.error(`❌ [CryptoIdentityManager] Identity generation failed:`, error);
|
|
119
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.ENCRYPTION, "IDENTITY_GENERATION_FAILED", error.message ?? "Failed to generate crypto identities", error);
|
|
120
|
-
return {
|
|
121
|
-
success: false,
|
|
122
|
-
error: error.message ?? "Failed to generate crypto identities",
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Genera le identità crypto per un utente
|
|
128
|
-
* Wrapper che chiama generateAllIdentities (mantenuto per compatibilità)
|
|
129
|
-
* @param username - Nome utente
|
|
130
|
-
* @param seaPair - Coppia di chiavi SEA dell'utente (opzionale, non più utilizzato ma mantenuto per compatibilità)
|
|
131
|
-
* @param forceRegenerate - Ignorato, genera sempre nuove identità
|
|
132
|
-
* @returns Promise con le identità generate
|
|
133
|
-
*/
|
|
134
|
-
async setupCryptoIdentities(username, seaPair, forceRegenerate = false) {
|
|
135
|
-
return this.generateAllIdentities(username, seaPair);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
exports.CryptoIdentityManager = CryptoIdentityManager;
|
package/dist/plugins/base.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BasePlugin = void 0;
|
|
4
|
-
const eventEmitter_1 = require("../utils/eventEmitter");
|
|
5
|
-
/**
|
|
6
|
-
* Classe base per tutti i plugin di ShogunCore
|
|
7
|
-
* Fornisce funzionalità comuni e implementazione base dell'interfaccia ShogunPlugin
|
|
8
|
-
*/
|
|
9
|
-
class BasePlugin extends eventEmitter_1.EventEmitter {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
/** Riferimento all'istanza di ShogunCore */
|
|
13
|
-
this.core = null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Inizializza il plugin con un'istanza di ShogunCore
|
|
17
|
-
* @param core Istanza di ShogunCore
|
|
18
|
-
*/
|
|
19
|
-
initialize(core) {
|
|
20
|
-
this.core = core;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Distrugge il plugin e libera le risorse
|
|
24
|
-
*/
|
|
25
|
-
destroy() {
|
|
26
|
-
try {
|
|
27
|
-
// Emetti evento di distruzione
|
|
28
|
-
this.emit("destroyed", {
|
|
29
|
-
name: this.name,
|
|
30
|
-
version: this.version,
|
|
31
|
-
});
|
|
32
|
-
this.core = null;
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.error(`[${this.name}] Error during plugin destruction:`, error);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Verifica che il plugin sia stato inizializzato prima di usare il core
|
|
40
|
-
* @throws Error se il plugin non è stato inizializzato
|
|
41
|
-
* @returns L'istanza di ShogunCore non null
|
|
42
|
-
*/
|
|
43
|
-
assertInitialized() {
|
|
44
|
-
if (!this.core) {
|
|
45
|
-
throw new Error(`Plugin ${this.name} not initialized`);
|
|
46
|
-
}
|
|
47
|
-
return this.core;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.BasePlugin = BasePlugin;
|