shogun-core 4.2.4 → 4.2.5

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/core.js CHANGED
@@ -41,6 +41,17 @@ class ShogunCore {
41
41
  }
42
42
  });
43
43
  }
44
+ /**
45
+ * Manually initialize the Shogun SDK (for testing or delayed initialization)
46
+ * @returns Promise that resolves when initialization is complete
47
+ */
48
+ async initialize() {
49
+ // If already initialized, just wait a bit for any pending initialization
50
+ if (this._gun) {
51
+ return Promise.resolve();
52
+ }
53
+ return this.coreInitializer.initialize(this.config);
54
+ }
44
55
  /**
45
56
  * Access to the Gun instance
46
57
  * @returns The Gun instance
package/dist/gundb/db.js CHANGED
@@ -950,7 +950,15 @@ class DataBase {
950
950
  }
951
951
  console.log(`[POSTAUTH] Normalized username: ${normalizedUsername}`);
952
952
  console.log(`[POSTAUTH] Checking if user exists: ${userPub}`);
953
- const existingUser = await this.gun.get(userPub).then();
953
+ // Add timeout to prevent hanging
954
+ const existingUser = await Promise.race([
955
+ this.gun.get(userPub).then(),
956
+ new Promise((_, reject) => setTimeout(() => reject(new Error("Timeout checking user existence")), 5000)),
957
+ ]).catch((error) => {
958
+ console.error(`[POSTAUTH] Error or timeout checking user existence:`, error);
959
+ return null;
960
+ });
961
+ console.log(`[POSTAUTH] User existence check completed, existingUser:`, existingUser);
954
962
  const isNewUser = !existingUser || !existingUser.alias;
955
963
  console.log(`[POSTAUTH] User is ${isNewUser ? "NEW" : "EXISTING"}: ${userPub}`);
956
964
  // Get user's encryption public key (epub) for comprehensive tracking
@@ -40,6 +40,11 @@ export declare class ShogunCore implements IShogunCore {
40
40
  * and plugin system.
41
41
  */
42
42
  constructor(config: ShogunCoreConfig);
43
+ /**
44
+ * Manually initialize the Shogun SDK (for testing or delayed initialization)
45
+ * @returns Promise that resolves when initialization is complete
46
+ */
47
+ initialize(): Promise<void>;
43
48
  /**
44
49
  * Access to the Gun instance
45
50
  * @returns The Gun instance
@@ -123,6 +123,7 @@ export interface IShogunCore extends PluginManager {
123
123
  removeAllListeners(eventName?: string | symbol): this;
124
124
  emit<K extends keyof ShogunEventMap>(eventName: K, data?: ShogunEventMap[K] extends void ? never : ShogunEventMap[K]): boolean;
125
125
  getRecentErrors(count?: number): ShogunError[];
126
+ initialize(): Promise<void>;
126
127
  login(username: string, password: string, pair?: ISEAPair | null): Promise<AuthResult>;
127
128
  loginWithPair(username: string, pair: ISEAPair): Promise<AuthResult>;
128
129
  signUp(username: string, password?: string, pair?: ISEAPair | null): Promise<SignUpResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shogun-core",
3
- "version": "4.2.4",
3
+ "version": "4.2.5",
4
4
  "description": "SHOGUN CORE - Core library for Shogun Ecosystem",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",