shogun-button-react 1.7.3 → 1.7.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.
@@ -205,18 +205,47 @@ export function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, o
205
205
  }
206
206
  console.log(`🔧 Login result:`, result);
207
207
  if (result.success) {
208
- const userPub = result.userPub || ((_c = (_b = sdk.gun.user()) === null || _b === void 0 ? void 0 : _b.is) === null || _c === void 0 ? void 0 : _c.pub) || "";
209
- const displayName = result.alias || username || userPub.slice(0, 8) + "...";
208
+ // Try multiple ways to get userPub
209
+ let userPub = result.userPub;
210
+ if (!userPub) {
211
+ console.log(`🔧 userPub not in result, trying sdk.gun.user()?.is?.pub`);
212
+ userPub = (_c = (_b = sdk.gun.user()) === null || _b === void 0 ? void 0 : _b.is) === null || _c === void 0 ? void 0 : _c.pub;
213
+ }
214
+ if (!userPub) {
215
+ console.log(`🔧 userPub still not available, trying to get from gun user object`);
216
+ const gunUser = sdk.gun.user();
217
+ console.log(`🔧 Gun user object:`, gunUser);
218
+ if (gunUser && gunUser.is) {
219
+ userPub = gunUser.is.pub;
220
+ console.log(`🔧 Found userPub in gun user:`, userPub ? userPub.slice(0, 8) + "..." : "null");
221
+ }
222
+ }
223
+ if (!userPub) {
224
+ console.error(`🔧 Could not get userPub after successful login`);
225
+ // Try to get it from the result object if available
226
+ if (result &&
227
+ typeof result === "object" &&
228
+ "user" in result &&
229
+ result.user &&
230
+ typeof result.user === "object" &&
231
+ "pub" in result.user) {
232
+ userPub = result.user.pub;
233
+ console.log(`🔧 Got userPub from result.user:`, userPub ? userPub.slice(0, 8) + "..." : "null");
234
+ }
235
+ }
236
+ const displayName = result.alias ||
237
+ username ||
238
+ (userPub ? userPub.slice(0, 8) + "..." : "Unknown User");
210
239
  console.log(`🔧 Login successful! Setting user state:`, {
211
- userPub: userPub.slice(0, 8) + "...",
240
+ userPub: userPub ? userPub.slice(0, 8) + "..." : "null",
212
241
  displayName,
213
242
  authMethod,
214
243
  });
215
244
  setIsLoggedIn(true);
216
- setUserPub(userPub);
245
+ setUserPub(userPub || "");
217
246
  setUsername(displayName);
218
247
  onLoginSuccess === null || onLoginSuccess === void 0 ? void 0 : onLoginSuccess({
219
- userPub: userPub,
248
+ userPub: userPub || "",
220
249
  username: displayName,
221
250
  authMethod: authMethod,
222
251
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shogun-button-react",
3
3
  "description": "Shogun connector button",
4
- "version": "1.7.3",
4
+ "version": "1.7.4",
5
5
  "files": [
6
6
  "dist",
7
7
  "src/styles/index.css"