shogun-core 3.3.5 → 3.3.7
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/shogun-core.js +81267 -192044
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/{src/core.js → core.js} +2 -2
- package/dist/{src/gundb → gundb}/db.js +44 -15
- package/dist/{src/index.js → index.js} +0 -1
- package/dist/{src/managers → managers}/AuthManager.js +4 -3
- package/dist/{src/managers → managers}/CoreInitializer.js +1 -7
- package/dist/{src/storage → storage}/storage.js +0 -16
- package/dist/types/{src/core.d.ts → core.d.ts} +1 -1
- package/dist/types/{src/gundb → gundb}/db.d.ts +15 -6
- package/dist/types/{src/index.d.ts → index.d.ts} +0 -1
- package/dist/types/{src/interfaces → interfaces}/events.d.ts +1 -1
- package/dist/types/{src/interfaces → interfaces}/shogun.d.ts +7 -1
- package/dist/types/{src/managers → managers}/AuthManager.d.ts +1 -1
- package/package.json +10 -26
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_axios_index_js.shogun-core.js +0 -4078
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_axios_index_js.shogun-core.js.map +0 -1
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_is-ipfs_dist_src_index_js.shogun-core.js +0 -4908
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_is-ipfs_dist_src_index_js.shogun-core.js.map +0 -1
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_uint8-varint_dist_src_index_js-node_modu-0db5ba.shogun-core.js +0 -2109
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_uint8-varint_dist_src_index_js-node_modu-0db5ba.shogun-core.js.map +0 -1
- package/dist/ship/examples/identity-cli.js +0 -511
- package/dist/ship/examples/messenger-cli.js +0 -745
- package/dist/ship/examples/stealth-cli.js +0 -433
- package/dist/ship/examples/storage-cli.js +0 -615
- package/dist/ship/examples/vault-cli.js +0 -444
- package/dist/ship/examples/wallet-cli.js +0 -767
- package/dist/ship/implementation/SHIP_00.js +0 -478
- package/dist/ship/implementation/SHIP_01.js +0 -433
- package/dist/ship/implementation/SHIP_02.js +0 -1366
- package/dist/ship/implementation/SHIP_03.js +0 -855
- package/dist/ship/implementation/SHIP_04.js +0 -589
- package/dist/ship/implementation/SHIP_05.js +0 -1064
- package/dist/ship/implementation/SHIP_06.js +0 -635
- package/dist/ship/index.js +0 -17
- package/dist/ship/interfaces/ISHIP_00.js +0 -135
- package/dist/ship/interfaces/ISHIP_01.js +0 -128
- package/dist/ship/interfaces/ISHIP_02.js +0 -57
- package/dist/ship/interfaces/ISHIP_03.js +0 -61
- package/dist/ship/interfaces/ISHIP_04.js +0 -62
- package/dist/ship/interfaces/ISHIP_05.js +0 -59
- package/dist/ship/interfaces/ISHIP_06.js +0 -194
- package/dist/src/types/events.js +0 -70
- package/dist/src/types/shogun.js +0 -21
- package/dist/types/ship/examples/identity-cli.d.ts +0 -40
- package/dist/types/ship/examples/messenger-cli.d.ts +0 -37
- package/dist/types/ship/examples/stealth-cli.d.ts +0 -31
- package/dist/types/ship/examples/storage-cli.d.ts +0 -48
- package/dist/types/ship/examples/vault-cli.d.ts +0 -13
- package/dist/types/ship/examples/wallet-cli.d.ts +0 -131
- package/dist/types/ship/implementation/SHIP_00.d.ts +0 -113
- package/dist/types/ship/implementation/SHIP_01.d.ts +0 -80
- package/dist/types/ship/implementation/SHIP_02.d.ts +0 -297
- package/dist/types/ship/implementation/SHIP_03.d.ts +0 -127
- package/dist/types/ship/implementation/SHIP_04.d.ts +0 -76
- package/dist/types/ship/implementation/SHIP_05.d.ts +0 -70
- package/dist/types/ship/implementation/SHIP_06.d.ts +0 -101
- package/dist/types/ship/index.d.ts +0 -14
- package/dist/types/ship/interfaces/ISHIP_00.d.ts +0 -410
- package/dist/types/ship/interfaces/ISHIP_01.d.ts +0 -343
- package/dist/types/ship/interfaces/ISHIP_02.d.ts +0 -470
- package/dist/types/ship/interfaces/ISHIP_03.d.ts +0 -295
- package/dist/types/ship/interfaces/ISHIP_04.d.ts +0 -245
- package/dist/types/ship/interfaces/ISHIP_05.d.ts +0 -234
- package/dist/types/ship/interfaces/ISHIP_06.d.ts +0 -522
- package/dist/types/src/types/events.d.ts +0 -59
- package/dist/types/src/types/shogun.d.ts +0 -188
- /package/dist/{src/config → config}/simplified-config.js +0 -0
- /package/dist/{src/examples → examples}/api-test.js +0 -0
- /package/dist/{src/examples → examples}/simple-api-test.js +0 -0
- /package/dist/{src/gundb → gundb}/api.js +0 -0
- /package/dist/{src/gundb → gundb}/crypto.js +0 -0
- /package/dist/{src/gundb → gundb}/derive.js +0 -0
- /package/dist/{src/gundb → gundb}/errors.js +0 -0
- /package/dist/{src/gundb → gundb}/index.js +0 -0
- /package/dist/{src/gundb → gundb}/rxjs.js +0 -0
- /package/dist/{src/gundb → gundb}/types.js +0 -0
- /package/dist/{src/interfaces → interfaces}/common.js +0 -0
- /package/dist/{src/interfaces → interfaces}/events.js +0 -0
- /package/dist/{src/interfaces → interfaces}/plugin.js +0 -0
- /package/dist/{src/interfaces → interfaces}/shogun.js +0 -0
- /package/dist/{src/managers → managers}/EventManager.js +0 -0
- /package/dist/{src/managers → managers}/PluginManager.js +0 -0
- /package/dist/{src/migration-test.js → migration-test.js} +0 -0
- /package/dist/{src/plugins → plugins}/base.js +0 -0
- /package/dist/{src/plugins → plugins}/index.js +0 -0
- /package/dist/{src/plugins → plugins}/nostr/index.js +0 -0
- /package/dist/{src/plugins → plugins}/nostr/nostrConnector.js +0 -0
- /package/dist/{src/plugins → plugins}/nostr/nostrConnectorPlugin.js +0 -0
- /package/dist/{src/plugins → plugins}/nostr/nostrSigner.js +0 -0
- /package/dist/{src/plugins → plugins}/nostr/types.js +0 -0
- /package/dist/{src/plugins → plugins}/oauth/index.js +0 -0
- /package/dist/{src/plugins → plugins}/oauth/oauthConnector.js +0 -0
- /package/dist/{src/plugins → plugins}/oauth/oauthPlugin.js +0 -0
- /package/dist/{src/plugins → plugins}/oauth/types.js +0 -0
- /package/dist/{src/plugins → plugins}/web3/index.js +0 -0
- /package/dist/{src/plugins → plugins}/web3/types.js +0 -0
- /package/dist/{src/plugins → plugins}/web3/web3Connector.js +0 -0
- /package/dist/{src/plugins → plugins}/web3/web3ConnectorPlugin.js +0 -0
- /package/dist/{src/plugins → plugins}/web3/web3Signer.js +0 -0
- /package/dist/{src/plugins → plugins}/webauthn/index.js +0 -0
- /package/dist/{src/plugins → plugins}/webauthn/types.js +0 -0
- /package/dist/{src/plugins → plugins}/webauthn/webauthn.js +0 -0
- /package/dist/{src/plugins → plugins}/webauthn/webauthnPlugin.js +0 -0
- /package/dist/{src/plugins → plugins}/webauthn/webauthnSigner.js +0 -0
- /package/dist/types/{src/config → config}/simplified-config.d.ts +0 -0
- /package/dist/types/{src/examples → examples}/api-test.d.ts +0 -0
- /package/dist/types/{src/examples → examples}/simple-api-test.d.ts +0 -0
- /package/dist/types/{src/gundb → gundb}/api.d.ts +0 -0
- /package/dist/types/{src/gundb → gundb}/crypto.d.ts +0 -0
- /package/dist/types/{src/gundb → gundb}/derive.d.ts +0 -0
- /package/dist/types/{src/gundb → gundb}/errors.d.ts +0 -0
- /package/dist/types/{src/gundb → gundb}/index.d.ts +0 -0
- /package/dist/types/{src/gundb → gundb}/rxjs.d.ts +0 -0
- /package/dist/types/{src/gundb → gundb}/types.d.ts +0 -0
- /package/dist/types/{src/interfaces → interfaces}/common.d.ts +0 -0
- /package/dist/types/{src/interfaces → interfaces}/plugin.d.ts +0 -0
- /package/dist/types/{src/managers → managers}/CoreInitializer.d.ts +0 -0
- /package/dist/types/{src/managers → managers}/EventManager.d.ts +0 -0
- /package/dist/types/{src/managers → managers}/PluginManager.d.ts +0 -0
- /package/dist/types/{src/migration-test.d.ts → migration-test.d.ts} +0 -0
- /package/dist/types/{src/plugins → plugins}/base.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/index.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/nostr/index.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/nostr/nostrConnector.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/nostr/nostrSigner.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/nostr/types.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/oauth/index.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/oauth/oauthConnector.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/oauth/oauthPlugin.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/oauth/types.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/web3/index.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/web3/types.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/web3/web3Connector.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/web3/web3Signer.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/webauthn/index.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/webauthn/types.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/webauthn/webauthn.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/webauthn/webauthnPlugin.d.ts +0 -0
- /package/dist/types/{src/plugins → plugins}/webauthn/webauthnSigner.d.ts +0 -0
- /package/dist/types/{src/storage → storage}/storage.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/errorHandler.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/eventEmitter.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/validation.d.ts +0 -0
- /package/dist/{src/utils → utils}/errorHandler.js +0 -0
- /package/dist/{src/utils → utils}/eventEmitter.js +0 -0
- /package/dist/{src/utils → utils}/validation.js +0 -0
|
@@ -215,8 +215,8 @@ class ShogunCore {
|
|
|
215
215
|
* @description Authenticates user using a GunDB pair directly.
|
|
216
216
|
* Emits login event on success.
|
|
217
217
|
*/
|
|
218
|
-
async loginWithPair(pair) {
|
|
219
|
-
return this.authManager.loginWithPair(pair);
|
|
218
|
+
async loginWithPair(username, pair) {
|
|
219
|
+
return this.authManager.loginWithPair(username, pair);
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
222
|
* Register a new user with provided credentials
|
|
@@ -79,16 +79,11 @@ const CONFIG = {
|
|
|
79
79
|
},
|
|
80
80
|
};
|
|
81
81
|
class DataBase {
|
|
82
|
-
constructor(gun, appScope = "shogun"
|
|
82
|
+
constructor(gun, appScope = "shogun") {
|
|
83
83
|
this.user = null;
|
|
84
84
|
this.onAuthCallbacks = [];
|
|
85
|
-
this.disableAutoRecall = false;
|
|
86
|
-
this.silent = false;
|
|
87
85
|
// Initialize event emitter
|
|
88
86
|
this.eventEmitter = new eventEmitter_1.EventEmitter();
|
|
89
|
-
// Set options
|
|
90
|
-
this.disableAutoRecall = options?.disableAutoRecall || false;
|
|
91
|
-
this.silent = options?.silent || false;
|
|
92
87
|
// Validate Gun instance
|
|
93
88
|
if (!gun) {
|
|
94
89
|
throw new Error("Gun instance is required but was not provided");
|
|
@@ -107,14 +102,7 @@ class DataBase {
|
|
|
107
102
|
}
|
|
108
103
|
this.gun = gun;
|
|
109
104
|
// Recall only if NOT disabled and there's a "pair" in sessionStorage
|
|
110
|
-
|
|
111
|
-
typeof sessionStorage !== "undefined" &&
|
|
112
|
-
sessionStorage.getItem("pair")) {
|
|
113
|
-
this.user = this.gun.user().recall({ sessionStorage: true });
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
this.user = this.gun.user();
|
|
117
|
-
}
|
|
105
|
+
this.user = this.gun.user().recall({ sessionStorage: true });
|
|
118
106
|
this.subscribeToAuthEvents();
|
|
119
107
|
this.crypto = crypto;
|
|
120
108
|
this.sea = sea_1.default;
|
|
@@ -1409,6 +1397,13 @@ class DataBase {
|
|
|
1409
1397
|
: undefined,
|
|
1410
1398
|
};
|
|
1411
1399
|
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Performs login with username and password
|
|
1402
|
+
* @param username Username
|
|
1403
|
+
* @param password Password
|
|
1404
|
+
* @param pair SEA pair (optional)
|
|
1405
|
+
* @returns Promise resolving to AuthResult object
|
|
1406
|
+
*/
|
|
1412
1407
|
async login(username, password, pair) {
|
|
1413
1408
|
try {
|
|
1414
1409
|
const loginResult = await this.performAuthentication(username, password, pair);
|
|
@@ -1422,6 +1417,7 @@ class DataBase {
|
|
|
1422
1417
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1423
1418
|
const userPub = this.gun.user().is?.pub;
|
|
1424
1419
|
let alias = this.gun.user().is?.alias;
|
|
1420
|
+
let userPair = this.gun.user()?._?.sea;
|
|
1425
1421
|
if (!alias) {
|
|
1426
1422
|
alias = username;
|
|
1427
1423
|
}
|
|
@@ -1454,7 +1450,7 @@ class DataBase {
|
|
|
1454
1450
|
try {
|
|
1455
1451
|
const userInfo = {
|
|
1456
1452
|
alias: username,
|
|
1457
|
-
pair: pair ??
|
|
1453
|
+
pair: pair ?? userPair,
|
|
1458
1454
|
userPub: userPub,
|
|
1459
1455
|
};
|
|
1460
1456
|
this.saveCredentials(userInfo);
|
|
@@ -1469,6 +1465,39 @@ class DataBase {
|
|
|
1469
1465
|
return { success: false, error: String(error) };
|
|
1470
1466
|
}
|
|
1471
1467
|
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Performs login with GunDB pair directly
|
|
1470
|
+
* @param username Username
|
|
1471
|
+
* @param pair SEA pair
|
|
1472
|
+
* @returns Promise resolving to AuthResult object
|
|
1473
|
+
*/
|
|
1474
|
+
async loginWithPair(username, pair) {
|
|
1475
|
+
try {
|
|
1476
|
+
const loginResult = await this.performAuthentication(username, "", pair);
|
|
1477
|
+
if (!loginResult.success) {
|
|
1478
|
+
return {
|
|
1479
|
+
success: false,
|
|
1480
|
+
error: `User '${username}' not found. Please check your username or register first.`,
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
await this.runPostAuthOnAuthResult(username, pair.pub || "", {
|
|
1484
|
+
success: true,
|
|
1485
|
+
userPub: pair.pub,
|
|
1486
|
+
});
|
|
1487
|
+
try {
|
|
1488
|
+
await this.updateUserLastSeen(pair.pub);
|
|
1489
|
+
}
|
|
1490
|
+
catch (lastSeenError) {
|
|
1491
|
+
console.error(`Error updating last seen: ${lastSeenError}`);
|
|
1492
|
+
// Continue with login even if last seen update fails
|
|
1493
|
+
}
|
|
1494
|
+
return this.buildLoginResult(username, this.gun.user().is?.pub || "");
|
|
1495
|
+
}
|
|
1496
|
+
catch (error) {
|
|
1497
|
+
console.error(`Exception during login with pair: ${error}`);
|
|
1498
|
+
return { success: false, error: String(error) };
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1472
1501
|
saveCredentials(userInfo) {
|
|
1473
1502
|
try {
|
|
1474
1503
|
const sessionInfo = {
|
|
@@ -42,4 +42,3 @@ __exportStar(require("./utils/errorHandler"), exports);
|
|
|
42
42
|
__exportStar(require("./plugins"), exports);
|
|
43
43
|
__exportStar(require("./interfaces/shogun"), exports);
|
|
44
44
|
__exportStar(require("./config/simplified-config"), exports);
|
|
45
|
-
__exportStar(require("../ship"), exports);
|
|
@@ -82,7 +82,7 @@ class AuthManager {
|
|
|
82
82
|
* @description Authenticates user using a GunDB pair directly.
|
|
83
83
|
* Emits login event on success.
|
|
84
84
|
*/
|
|
85
|
-
async loginWithPair(pair) {
|
|
85
|
+
async loginWithPair(username, pair) {
|
|
86
86
|
try {
|
|
87
87
|
if (!pair || !pair.pub || !pair.priv || !pair.epub || !pair.epriv) {
|
|
88
88
|
return {
|
|
@@ -91,7 +91,7 @@ class AuthManager {
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
// Use the new loginWithPair method from GunInstance
|
|
94
|
-
const result = await this.core.db.
|
|
94
|
+
const result = await this.core.db.loginWithPair(username, pair);
|
|
95
95
|
if (result.success) {
|
|
96
96
|
// Include SEA pair in the response
|
|
97
97
|
const seaPair = this.core.user?._?.sea;
|
|
@@ -101,7 +101,8 @@ class AuthManager {
|
|
|
101
101
|
this.currentAuthMethod = "pair";
|
|
102
102
|
this.core.emit("auth:login", {
|
|
103
103
|
userPub: result.userPub ?? "",
|
|
104
|
-
method: "
|
|
104
|
+
method: "pair",
|
|
105
|
+
username,
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
else {
|
|
@@ -62,9 +62,6 @@ class CoreInitializer {
|
|
|
62
62
|
* Initialize Gun instance
|
|
63
63
|
*/
|
|
64
64
|
async initializeGun(config) {
|
|
65
|
-
if (!config.silent) {
|
|
66
|
-
console.log("Initialize Gun instance", config);
|
|
67
|
-
}
|
|
68
65
|
try {
|
|
69
66
|
if (config.gunInstance && config.gunOptions === undefined) {
|
|
70
67
|
if (!config.silent) {
|
|
@@ -100,10 +97,7 @@ class CoreInitializer {
|
|
|
100
97
|
throw new Error(`Failed to create Gun instance: ${error}`);
|
|
101
98
|
}
|
|
102
99
|
try {
|
|
103
|
-
|
|
104
|
-
console.log("Initialize Gun instance", this.core.gun);
|
|
105
|
-
}
|
|
106
|
-
this.core.db = new gundb_1.DataBase(this.core._gun, config.gunOptions?.scope || "", { disableAutoRecall: config.disableAutoRecall, silent: config.silent });
|
|
100
|
+
this.core.db = new gundb_1.DataBase(this.core._gun, config.gunOptions?.scope || "");
|
|
107
101
|
// Note: user is a getter that returns _user, so we don't need to assign it
|
|
108
102
|
}
|
|
109
103
|
catch (error) {
|
|
@@ -15,23 +15,12 @@ class ShogunStorage {
|
|
|
15
15
|
this.silent = silent;
|
|
16
16
|
this.isTestMode = process.env.NODE_ENV === "test";
|
|
17
17
|
this.useLocalStorage = false;
|
|
18
|
-
// Debug: log the environment (only if not silent)
|
|
19
|
-
if (!this.silent) {
|
|
20
|
-
console.log("ShogunStorage: NODE_ENV =", process.env.NODE_ENV);
|
|
21
|
-
console.log("ShogunStorage: isTestMode =", this.isTestMode);
|
|
22
|
-
}
|
|
23
18
|
// In test mode, don't use localStorage to avoid test pollution
|
|
24
19
|
if (this.isTestMode) {
|
|
25
20
|
this.useLocalStorage = false;
|
|
26
|
-
if (!this.silent) {
|
|
27
|
-
console.log("ShogunStorage: Test mode detected, localStorage disabled");
|
|
28
|
-
}
|
|
29
21
|
return;
|
|
30
22
|
}
|
|
31
23
|
if (typeof localStorage !== "undefined") {
|
|
32
|
-
if (!this.silent) {
|
|
33
|
-
console.log("ShogunStorage: localStorage is defined");
|
|
34
|
-
}
|
|
35
24
|
try {
|
|
36
25
|
// Probe localStorage without polluting expectations in tests
|
|
37
26
|
const testKey = "_shogun_test";
|
|
@@ -54,11 +43,6 @@ class ShogunStorage {
|
|
|
54
43
|
}
|
|
55
44
|
}
|
|
56
45
|
}
|
|
57
|
-
else {
|
|
58
|
-
if (!this.silent) {
|
|
59
|
-
console.log("ShogunStorage: localStorage is undefined");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
46
|
}
|
|
63
47
|
/**
|
|
64
48
|
* Gets the stored keypair asynchronously
|
|
@@ -237,7 +237,7 @@ export declare class ShogunCore implements IShogunCore {
|
|
|
237
237
|
* @description Authenticates user using a GunDB pair directly.
|
|
238
238
|
* Emits login event on success.
|
|
239
239
|
*/
|
|
240
|
-
loginWithPair(pair: ISEAPair): Promise<AuthResult>;
|
|
240
|
+
loginWithPair(username: string, pair: ISEAPair): Promise<AuthResult>;
|
|
241
241
|
/**
|
|
242
242
|
* Register a new user with provided credentials
|
|
243
243
|
* @param username - Username
|
|
@@ -29,12 +29,7 @@ declare class DataBase {
|
|
|
29
29
|
private readonly onAuthCallbacks;
|
|
30
30
|
private readonly eventEmitter;
|
|
31
31
|
private _rxjs?;
|
|
32
|
-
|
|
33
|
-
private silent;
|
|
34
|
-
constructor(gun: IGunInstance, appScope?: string, options?: {
|
|
35
|
-
disableAutoRecall?: boolean;
|
|
36
|
-
silent?: boolean;
|
|
37
|
-
});
|
|
32
|
+
constructor(gun: IGunInstance, appScope?: string);
|
|
38
33
|
/**
|
|
39
34
|
* Initialize the GunInstance asynchronously
|
|
40
35
|
* This method should be called after construction to perform async operations
|
|
@@ -280,7 +275,21 @@ declare class DataBase {
|
|
|
280
275
|
* Builds login result object
|
|
281
276
|
*/
|
|
282
277
|
private buildLoginResult;
|
|
278
|
+
/**
|
|
279
|
+
* Performs login with username and password
|
|
280
|
+
* @param username Username
|
|
281
|
+
* @param password Password
|
|
282
|
+
* @param pair SEA pair (optional)
|
|
283
|
+
* @returns Promise resolving to AuthResult object
|
|
284
|
+
*/
|
|
283
285
|
login(username: string, password: string, pair?: ISEAPair | null): Promise<AuthResult>;
|
|
286
|
+
/**
|
|
287
|
+
* Performs login with GunDB pair directly
|
|
288
|
+
* @param username Username
|
|
289
|
+
* @param pair SEA pair
|
|
290
|
+
* @returns Promise resolving to AuthResult object
|
|
291
|
+
*/
|
|
292
|
+
loginWithPair(username: string, pair: ISEAPair): Promise<AuthResult>;
|
|
284
293
|
private saveCredentials;
|
|
285
294
|
/**
|
|
286
295
|
* Sets up security questions and password hint
|
|
@@ -8,7 +8,6 @@ export * from "./utils/errorHandler";
|
|
|
8
8
|
export * from "./plugins";
|
|
9
9
|
export * from "./interfaces/shogun";
|
|
10
10
|
export * from "./config/simplified-config";
|
|
11
|
-
export * from "../ship";
|
|
12
11
|
export type * from "./interfaces/plugin";
|
|
13
12
|
export type { IGunUserInstance, IGunInstance, GunDataEventData, GunPeerEventData, DeriveOptions, TypedGunOperationResult, TypedAuthResult, };
|
|
14
13
|
export { Gun, ShogunCore, SEA, RxJS, crypto, derive, GunErrors, DataBase, SimpleGunAPI, QuickStart, quickStart, createSimpleAPI, AutoQuickStart, autoQuickStart, };
|
|
@@ -10,7 +10,7 @@ import { EventEmitter } from "../utils/eventEmitter";
|
|
|
10
10
|
export interface AuthEventData {
|
|
11
11
|
userPub?: string;
|
|
12
12
|
username?: string;
|
|
13
|
-
method: "password" | "webauthn" | "web3" | "nostr" | "oauth" | "bitcoin";
|
|
13
|
+
method: "password" | "webauthn" | "web3" | "nostr" | "oauth" | "bitcoin" | "pair";
|
|
14
14
|
provider?: string;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -40,6 +40,12 @@ export declare enum CorePlugins {
|
|
|
40
40
|
OAuth = "oauth"
|
|
41
41
|
}
|
|
42
42
|
export type AuthMethod = "password" | "webauthn" | "web3" | "nostr" | "oauth" | "pair";
|
|
43
|
+
export interface AuthEventData {
|
|
44
|
+
userPub?: string;
|
|
45
|
+
username?: string;
|
|
46
|
+
method: "password" | "webauthn" | "web3" | "nostr" | "oauth" | "pair";
|
|
47
|
+
provider?: string;
|
|
48
|
+
}
|
|
43
49
|
export interface AuthResult {
|
|
44
50
|
success: boolean;
|
|
45
51
|
error?: string;
|
|
@@ -133,7 +139,7 @@ export interface IShogunCore extends PluginManager {
|
|
|
133
139
|
emit<K extends keyof ShogunEventMap>(eventName: K, data?: ShogunEventMap[K] extends void ? never : ShogunEventMap[K]): boolean;
|
|
134
140
|
getRecentErrors(count?: number): ShogunError[];
|
|
135
141
|
login(username: string, password: string, pair?: ISEAPair | null): Promise<AuthResult>;
|
|
136
|
-
loginWithPair(pair: ISEAPair): Promise<AuthResult>;
|
|
142
|
+
loginWithPair(username: string, pair: ISEAPair): Promise<AuthResult>;
|
|
137
143
|
signUp(username: string, password?: string, pair?: ISEAPair | null): Promise<SignUpResult>;
|
|
138
144
|
getAuthenticationMethod(type: AuthMethod): any;
|
|
139
145
|
setAuthMethod(method: AuthMethod): void;
|
|
@@ -36,7 +36,7 @@ export declare class AuthManager {
|
|
|
36
36
|
* @description Authenticates user using a GunDB pair directly.
|
|
37
37
|
* Emits login event on success.
|
|
38
38
|
*/
|
|
39
|
-
loginWithPair(pair: ISEAPair): Promise<AuthResult>;
|
|
39
|
+
loginWithPair(username: string, pair: ISEAPair): Promise<AuthResult>;
|
|
40
40
|
/**
|
|
41
41
|
* Register a new user with provided credentials
|
|
42
42
|
* @param username - Username
|
package/package.json
CHANGED
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shogun-core",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.7",
|
|
4
4
|
"description": "SHOGUN CORE - Core library for Shogun Ecosystem",
|
|
5
|
-
"main": "./dist/
|
|
6
|
-
"module": "./dist/
|
|
7
|
-
"types": "./dist/types/
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/types/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/types/
|
|
11
|
-
"import": "./dist/
|
|
12
|
-
"require": "./dist/
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
13
|
"browser": "./dist/browser/shogun-core.js",
|
|
14
|
-
"default": "./dist/
|
|
15
|
-
"node": "./dist/
|
|
16
|
-
},
|
|
17
|
-
"./ship": {
|
|
18
|
-
"types": "./dist/types/ship/index.d.ts",
|
|
19
|
-
"import": "./dist/ship/index.js",
|
|
20
|
-
"require": "./dist/ship/index.js",
|
|
21
|
-
"default": "./dist/ship/index.js"
|
|
22
|
-
},
|
|
23
|
-
"./ship/interfaces/*": {
|
|
24
|
-
"types": "./dist/types/ship/interfaces/*.d.ts",
|
|
25
|
-
"import": "./dist/ship/interfaces/*.js",
|
|
26
|
-
"require": "./dist/ship/interfaces/*.js",
|
|
27
|
-
"default": "./dist/ship/interfaces/*.js"
|
|
14
|
+
"default": "./dist/index.js",
|
|
15
|
+
"node": "./dist/index.js"
|
|
28
16
|
}
|
|
29
17
|
},
|
|
30
18
|
"files": [
|
|
@@ -71,19 +59,15 @@
|
|
|
71
59
|
"constants-browserify": "^1.0.0",
|
|
72
60
|
"crypto-browserify": "^3.12.0",
|
|
73
61
|
"ethers": "^6.13.5",
|
|
74
|
-
"figlet": "^1.9.3",
|
|
75
|
-
"form-data": "^4.0.4",
|
|
76
62
|
"gun": "git+https://github.com/amark/gun.git",
|
|
77
63
|
"keccak256": "^1.0.6",
|
|
78
64
|
"nostr-tools": "^2.15.0",
|
|
79
65
|
"qs": "^6.14.0",
|
|
80
66
|
"rxjs": "^7.8.2",
|
|
81
|
-
"shogun-ipfs": "file:../shogun-ipfs",
|
|
82
67
|
"ts-node": "^10.9.2",
|
|
83
68
|
"url": "^0.11.4",
|
|
84
69
|
"uuid": "^11.1.0",
|
|
85
|
-
"vm-browserify": "^1.1.2"
|
|
86
|
-
"ws": "^8.18.3"
|
|
70
|
+
"vm-browserify": "^1.1.2"
|
|
87
71
|
},
|
|
88
72
|
"devDependencies": {
|
|
89
73
|
"@babel/core": "^7.24.3",
|