shogun-core 1.3.2 → 1.3.4
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.
|
@@ -925,6 +925,8 @@ class GunInstance {
|
|
|
925
925
|
sessionStorage.removeItem("gun/");
|
|
926
926
|
sessionStorage.removeItem("gun/user");
|
|
927
927
|
sessionStorage.removeItem("gun/auth");
|
|
928
|
+
sessionStorage.removeItem("gun/pair");
|
|
929
|
+
sessionStorage.removeItem("gun/session");
|
|
928
930
|
(0, logger_1.log)("Session storage cleared");
|
|
929
931
|
}
|
|
930
932
|
(0, logger_1.log)("Logout completed successfully");
|
|
@@ -1024,10 +1026,25 @@ class GunInstance {
|
|
|
1024
1026
|
(0, logger_1.logError)("Error encrypting hint:", encryptError);
|
|
1025
1027
|
return { success: false, error: "Failed to encrypt password hint" };
|
|
1026
1028
|
}
|
|
1027
|
-
// Save
|
|
1028
|
-
|
|
1029
|
+
// Save to the public graph, readable by anyone but only decryptable with the right answers.
|
|
1030
|
+
const userPub = currentUser.pub;
|
|
1031
|
+
const securityPayload = {
|
|
1029
1032
|
questions: JSON.stringify(securityQuestions),
|
|
1030
1033
|
hint: encryptedHint,
|
|
1034
|
+
};
|
|
1035
|
+
await new Promise((resolve, reject) => {
|
|
1036
|
+
this.gun.get(userPub)
|
|
1037
|
+
.get("security")
|
|
1038
|
+
.put(securityPayload, (ack) => {
|
|
1039
|
+
if (ack.err) {
|
|
1040
|
+
(0, logger_1.logError)("Error saving security data to public graph:", ack.err);
|
|
1041
|
+
reject(new Error(ack.err));
|
|
1042
|
+
}
|
|
1043
|
+
else {
|
|
1044
|
+
(0, logger_1.log)(`Security data saved to public graph for ${userPub}`);
|
|
1045
|
+
resolve();
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1031
1048
|
});
|
|
1032
1049
|
return { success: true };
|
|
1033
1050
|
}
|
|
@@ -1045,16 +1062,19 @@ class GunInstance {
|
|
|
1045
1062
|
async forgotPassword(username, securityAnswers) {
|
|
1046
1063
|
(0, logger_1.log)("Attempting password recovery for:", username);
|
|
1047
1064
|
try {
|
|
1048
|
-
// Find the user's
|
|
1049
|
-
const
|
|
1050
|
-
if (!
|
|
1065
|
+
// Find the user's data
|
|
1066
|
+
const userData = await this.checkUsernameExists(username);
|
|
1067
|
+
if (!userData || !userData.pub) {
|
|
1051
1068
|
return { success: false, error: "User not found" };
|
|
1052
1069
|
}
|
|
1053
|
-
//
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1070
|
+
// Extract the public key from user data
|
|
1071
|
+
const userPub = userData.pub;
|
|
1072
|
+
(0, logger_1.log)(`Found user public key for password recovery: ${userPub}`);
|
|
1073
|
+
// Access the user's security data directly from their public key node
|
|
1074
|
+
// Security data is stored in the user's private space, so we need to access it via their public key
|
|
1056
1075
|
const securityData = await new Promise((resolve) => {
|
|
1057
|
-
|
|
1076
|
+
this.gun.get(userPub).get("security").once((data) => {
|
|
1077
|
+
(0, logger_1.log)(`Retrieved security data for user ${username}:`, data ? "found" : "not found");
|
|
1058
1078
|
resolve(data);
|
|
1059
1079
|
});
|
|
1060
1080
|
});
|