shogun-core 3.0.9 → 3.0.11
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.
|
@@ -88142,9 +88142,15 @@ class DataBase {
|
|
|
88142
88142
|
*/
|
|
88143
88143
|
getCurrentUser() {
|
|
88144
88144
|
try {
|
|
88145
|
-
const
|
|
88146
|
-
|
|
88147
|
-
|
|
88145
|
+
const _user = this.gun.user();
|
|
88146
|
+
return _user?.is?.pub
|
|
88147
|
+
? {
|
|
88148
|
+
pub: _user?.is?.pub,
|
|
88149
|
+
epub: _user?.is?.epub,
|
|
88150
|
+
alias: _user?.is?.alias,
|
|
88151
|
+
user: _user,
|
|
88152
|
+
}
|
|
88153
|
+
: null;
|
|
88148
88154
|
}
|
|
88149
88155
|
catch (error) {
|
|
88150
88156
|
console.error("Error getting current user:", error);
|
|
@@ -88722,13 +88728,19 @@ class DataBase {
|
|
|
88722
88728
|
}
|
|
88723
88729
|
console.log(`Setting up user profile for ${normalizedUsername} with userPub: ${userPub}`);
|
|
88724
88730
|
const existingUser = await this.gun.get(userPub).once().then();
|
|
88725
|
-
const isNewUser = !existingUser || !existingUser.
|
|
88731
|
+
const isNewUser = !existingUser || !existingUser.alias;
|
|
88726
88732
|
// Get user's encryption public key (epub) for comprehensive tracking
|
|
88727
88733
|
const userInstance = this.gun.user();
|
|
88728
88734
|
const userSea = userInstance?._?.sea;
|
|
88729
88735
|
const epub = userSea?.epub || null;
|
|
88730
88736
|
// Enhanced user tracking system
|
|
88731
|
-
await this.setupComprehensiveUserTracking(normalizedUsername, userPub, epub, isNewUser);
|
|
88737
|
+
const trackingResult = await this.setupComprehensiveUserTracking(normalizedUsername, userPub, epub, isNewUser);
|
|
88738
|
+
if (!trackingResult) {
|
|
88739
|
+
return {
|
|
88740
|
+
success: false,
|
|
88741
|
+
error: "Comprehensive user tracking setup failed",
|
|
88742
|
+
};
|
|
88743
|
+
}
|
|
88732
88744
|
return {
|
|
88733
88745
|
success: true,
|
|
88734
88746
|
userPub: userPub,
|
|
@@ -88758,6 +88770,9 @@ class DataBase {
|
|
|
88758
88770
|
* Creates multiple indexes for efficient user discovery
|
|
88759
88771
|
*/
|
|
88760
88772
|
async setupComprehensiveUserTracking(username, userPub, epub, isNewUser) {
|
|
88773
|
+
if (isNewUser) {
|
|
88774
|
+
return true;
|
|
88775
|
+
}
|
|
88761
88776
|
try {
|
|
88762
88777
|
// 1. Create alias index: ~@alias -> userPub (for GunDB compatibility)
|
|
88763
88778
|
await this.createAliasIndex(username, userPub);
|
|
@@ -88774,10 +88789,12 @@ class DataBase {
|
|
|
88774
88789
|
// 6. Create user metadata in user's own node
|
|
88775
88790
|
await this.createUserMetadata(username, userPub, epub);
|
|
88776
88791
|
console.log(`Comprehensive user tracking setup completed for ${username}`);
|
|
88792
|
+
return true;
|
|
88777
88793
|
}
|
|
88778
88794
|
catch (error) {
|
|
88779
88795
|
console.error(`Error in comprehensive user tracking setup: ${error}`);
|
|
88780
88796
|
// Don't throw - continue with other operations
|
|
88797
|
+
return false;
|
|
88781
88798
|
}
|
|
88782
88799
|
}
|
|
88783
88800
|
/**
|
|
@@ -89175,6 +89192,10 @@ class DataBase {
|
|
|
89175
89192
|
// Add a small delay to ensure user state is properly set
|
|
89176
89193
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
89177
89194
|
const userPub = this.gun.user().is?.pub;
|
|
89195
|
+
let alias = this.gun.user().is?.alias;
|
|
89196
|
+
if (!alias) {
|
|
89197
|
+
alias = username;
|
|
89198
|
+
}
|
|
89178
89199
|
console.log(`Login authentication successful, extracted userPub: ${userPub}`);
|
|
89179
89200
|
console.log(`User object:`, this.gun.user());
|
|
89180
89201
|
console.log(`User.is:`, this.gun.user().is);
|
|
@@ -89186,7 +89207,7 @@ class DataBase {
|
|
|
89186
89207
|
}
|
|
89187
89208
|
// Pass the userPub to runPostAuthOnAuthResult
|
|
89188
89209
|
try {
|
|
89189
|
-
await this.runPostAuthOnAuthResult(
|
|
89210
|
+
await this.runPostAuthOnAuthResult(alias, userPub, {
|
|
89190
89211
|
success: true,
|
|
89191
89212
|
userPub: userPub,
|
|
89192
89213
|
});
|
|
@@ -89206,7 +89227,7 @@ class DataBase {
|
|
|
89206
89227
|
// Save credentials for future sessions
|
|
89207
89228
|
try {
|
|
89208
89229
|
const userInfo = {
|
|
89209
|
-
username,
|
|
89230
|
+
alias: username,
|
|
89210
89231
|
pair: pair ?? null,
|
|
89211
89232
|
userPub: userPub,
|
|
89212
89233
|
};
|
|
@@ -89279,7 +89300,7 @@ class DataBase {
|
|
|
89279
89300
|
saveCredentials(userInfo) {
|
|
89280
89301
|
try {
|
|
89281
89302
|
const sessionInfo = {
|
|
89282
|
-
username: userInfo.
|
|
89303
|
+
username: userInfo.alias,
|
|
89283
89304
|
pair: userInfo.pair,
|
|
89284
89305
|
userPub: userInfo.userPub,
|
|
89285
89306
|
timestamp: Date.now(),
|
|
@@ -89932,7 +89953,7 @@ class SimpleGunAPI {
|
|
|
89932
89953
|
if (user) {
|
|
89933
89954
|
return {
|
|
89934
89955
|
pub: user.pub,
|
|
89935
|
-
username: user.
|
|
89956
|
+
username: user.alias,
|
|
89936
89957
|
};
|
|
89937
89958
|
}
|
|
89938
89959
|
return null;
|