shogun-core 6.5.0 → 6.5.1
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 +244 -85
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/src/gundb/db-holster.js +81 -11
- package/dist/src/gundb/db.js +50 -6
- package/dist/src/managers/CoreInitializer.js +113 -68
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/gundb/db-holster.d.ts +2 -0
- package/dist/types/src/gundb/db.d.ts +2 -0
- package/dist/types/src/managers/CoreInitializer.d.ts +5 -0
- package/package.json +1 -1
|
@@ -123276,6 +123276,7 @@ var DataBase = /** @class */ (function () {
|
|
|
123276
123276
|
/** Whether the database instance has been destroyed */
|
|
123277
123277
|
this._isDestroyed = false;
|
|
123278
123278
|
this.eventEmitter = new EventEmitter();
|
|
123279
|
+
this.core = core;
|
|
123279
123280
|
if (!gun) {
|
|
123280
123281
|
throw new Error("Gun instance is required but was not provided");
|
|
123281
123282
|
}
|
|
@@ -123403,6 +123404,7 @@ var DataBase = /** @class */ (function () {
|
|
|
123403
123404
|
*/
|
|
123404
123405
|
DataBase.prototype.logout = function () {
|
|
123405
123406
|
try {
|
|
123407
|
+
var wasLoggedIn = !!this.user;
|
|
123406
123408
|
var currentUser = this.gun.user();
|
|
123407
123409
|
if (currentUser && currentUser.is) {
|
|
123408
123410
|
currentUser.leave();
|
|
@@ -123411,6 +123413,10 @@ var DataBase = /** @class */ (function () {
|
|
|
123411
123413
|
if (typeof sessionStorage !== "undefined") {
|
|
123412
123414
|
sessionStorage.removeItem("gunSessionData");
|
|
123413
123415
|
}
|
|
123416
|
+
// Emit auth:logout event if core is available and user was logged in
|
|
123417
|
+
if (wasLoggedIn && this.core && typeof this.core.emit === "function") {
|
|
123418
|
+
this.core.emit("auth:logout", undefined);
|
|
123419
|
+
}
|
|
123414
123420
|
}
|
|
123415
123421
|
catch (error) {
|
|
123416
123422
|
console.error("[DB] Error during logout:", error);
|
|
@@ -123528,13 +123534,11 @@ var DataBase = /** @class */ (function () {
|
|
|
123528
123534
|
var _this = this;
|
|
123529
123535
|
return db_generator(this, function (_a) {
|
|
123530
123536
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
123537
|
+
// Check if username exists by looking up ~@username
|
|
123531
123538
|
_this.gun.get("~@".concat(alias)).once(function (user) {
|
|
123532
|
-
|
|
123533
|
-
|
|
123534
|
-
|
|
123535
|
-
else {
|
|
123536
|
-
resolve(true);
|
|
123537
|
-
}
|
|
123539
|
+
// If user exists, alias is taken (return true)
|
|
123540
|
+
// If user is null/undefined, alias is available (return false)
|
|
123541
|
+
resolve(!!user);
|
|
123538
123542
|
});
|
|
123539
123543
|
})];
|
|
123540
123544
|
});
|
|
@@ -123731,6 +123735,14 @@ var DataBase = /** @class */ (function () {
|
|
|
123731
123735
|
pair: pair !== null && pair !== void 0 ? pair : userPair,
|
|
123732
123736
|
userPub: userPub,
|
|
123733
123737
|
});
|
|
123738
|
+
// Emit auth:signup event if core is available (pair-based signup)
|
|
123739
|
+
if (_this.core && typeof _this.core.emit === "function") {
|
|
123740
|
+
_this.core.emit("auth:signup", {
|
|
123741
|
+
userPub: userPub,
|
|
123742
|
+
username: normalizedUsername,
|
|
123743
|
+
method: "pair",
|
|
123744
|
+
});
|
|
123745
|
+
}
|
|
123734
123746
|
resolve(_this.buildLoginResult(alias || normalizedUsername, userPub));
|
|
123735
123747
|
});
|
|
123736
123748
|
})];
|
|
@@ -123830,6 +123842,14 @@ var DataBase = /** @class */ (function () {
|
|
|
123830
123842
|
console.error("[DB] Alias registration failed:", registerError_1);
|
|
123831
123843
|
return [3 /*break*/, 4];
|
|
123832
123844
|
case 4:
|
|
123845
|
+
// Emit auth:signup event if core is available
|
|
123846
|
+
if (this.core && typeof this.core.emit === "function") {
|
|
123847
|
+
this.core.emit("auth:signup", {
|
|
123848
|
+
userPub: authenticatedUserPub,
|
|
123849
|
+
username: normalizedUsername,
|
|
123850
|
+
method: pair ? "pair" : "password",
|
|
123851
|
+
});
|
|
123852
|
+
}
|
|
123833
123853
|
sea = (_d = user === null || user === void 0 ? void 0 : user._) === null || _d === void 0 ? void 0 : _d.sea;
|
|
123834
123854
|
resolve({
|
|
123835
123855
|
success: true,
|
|
@@ -123901,6 +123921,14 @@ var DataBase = /** @class */ (function () {
|
|
|
123901
123921
|
catch (saveError) {
|
|
123902
123922
|
// Ignore save errors
|
|
123903
123923
|
}
|
|
123924
|
+
// Emit auth:login event if core is available (pair-based login)
|
|
123925
|
+
if (_this.core && typeof _this.core.emit === "function") {
|
|
123926
|
+
_this.core.emit("auth:login", {
|
|
123927
|
+
userPub: userPub,
|
|
123928
|
+
username: alias || normalizedUsername,
|
|
123929
|
+
method: "pair",
|
|
123930
|
+
});
|
|
123931
|
+
}
|
|
123904
123932
|
resolve(_this.buildLoginResult(alias || normalizedUsername, userPub));
|
|
123905
123933
|
});
|
|
123906
123934
|
}
|
|
@@ -123931,6 +123959,14 @@ var DataBase = /** @class */ (function () {
|
|
|
123931
123959
|
catch (saveError) {
|
|
123932
123960
|
// Ignore save errors
|
|
123933
123961
|
}
|
|
123962
|
+
// Emit auth:login event if core is available (password-based login)
|
|
123963
|
+
if (_this.core && typeof _this.core.emit === "function") {
|
|
123964
|
+
_this.core.emit("auth:login", {
|
|
123965
|
+
userPub: userPub,
|
|
123966
|
+
username: alias || normalizedUsername,
|
|
123967
|
+
method: "password",
|
|
123968
|
+
});
|
|
123969
|
+
}
|
|
123934
123970
|
resolve(_this.buildLoginResult(alias || normalizedUsername, userPub));
|
|
123935
123971
|
});
|
|
123936
123972
|
}
|
|
@@ -124021,6 +124057,14 @@ var DataBase = /** @class */ (function () {
|
|
|
124021
124057
|
catch (saveError) {
|
|
124022
124058
|
// Ignore save errors
|
|
124023
124059
|
}
|
|
124060
|
+
// Emit auth:login event if core is available (loginWithPair)
|
|
124061
|
+
if (_this.core && typeof _this.core.emit === "function") {
|
|
124062
|
+
_this.core.emit("auth:login", {
|
|
124063
|
+
userPub: userPub,
|
|
124064
|
+
username: alias || normalizedUsername,
|
|
124065
|
+
method: "pair",
|
|
124066
|
+
});
|
|
124067
|
+
}
|
|
124024
124068
|
resolve(_this.buildLoginResult(alias || normalizedUsername, userPub));
|
|
124025
124069
|
});
|
|
124026
124070
|
})];
|
|
@@ -124589,6 +124633,7 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
124589
124633
|
/** Last known user state */
|
|
124590
124634
|
this.lastUserState = null;
|
|
124591
124635
|
this.eventEmitter = new EventEmitter();
|
|
124636
|
+
this.core = core;
|
|
124592
124637
|
if (!holster) {
|
|
124593
124638
|
throw new Error("Holster instance is required but was not provided");
|
|
124594
124639
|
}
|
|
@@ -124637,13 +124682,31 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
124637
124682
|
var user = _this.holster.user();
|
|
124638
124683
|
var currentState = user.is;
|
|
124639
124684
|
if (currentState !== _this.lastUserState) {
|
|
124685
|
+
var previousState = _this.lastUserState;
|
|
124640
124686
|
_this.lastUserState = currentState;
|
|
124641
124687
|
if (currentState) {
|
|
124688
|
+
// User logged in
|
|
124642
124689
|
_this.notifyAuthListeners(currentState.pub || "");
|
|
124690
|
+
// Emit auth:login event if core is available and user just logged in
|
|
124691
|
+
if (_this.core &&
|
|
124692
|
+
typeof _this.core.emit === "function" &&
|
|
124693
|
+
!previousState) {
|
|
124694
|
+
_this.core.emit("auth:login", {
|
|
124695
|
+
userPub: currentState.pub || "",
|
|
124696
|
+
username: currentState.username || "",
|
|
124697
|
+
method: "password",
|
|
124698
|
+
});
|
|
124699
|
+
}
|
|
124643
124700
|
}
|
|
124644
124701
|
else {
|
|
124645
124702
|
// User logged out
|
|
124646
124703
|
_this.notifyAuthListeners("");
|
|
124704
|
+
// Emit auth:logout event if core is available and user just logged out
|
|
124705
|
+
if (_this.core &&
|
|
124706
|
+
typeof _this.core.emit === "function" &&
|
|
124707
|
+
previousState) {
|
|
124708
|
+
_this.core.emit("auth:logout", undefined);
|
|
124709
|
+
}
|
|
124647
124710
|
}
|
|
124648
124711
|
}
|
|
124649
124712
|
}, 100);
|
|
@@ -124726,6 +124789,7 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
124726
124789
|
*/
|
|
124727
124790
|
DataBaseHolster.prototype.logout = function () {
|
|
124728
124791
|
try {
|
|
124792
|
+
var wasLoggedIn = !!this.user;
|
|
124729
124793
|
var currentUser = this.holster.user();
|
|
124730
124794
|
if (currentUser && currentUser.is) {
|
|
124731
124795
|
currentUser.leave();
|
|
@@ -124734,6 +124798,10 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
124734
124798
|
if (typeof sessionStorage !== "undefined") {
|
|
124735
124799
|
sessionStorage.removeItem("gunSessionData");
|
|
124736
124800
|
}
|
|
124801
|
+
// Emit auth:logout event if core is available and user was logged in
|
|
124802
|
+
if (wasLoggedIn && this.core && typeof this.core.emit === "function") {
|
|
124803
|
+
this.core.emit("auth:logout", undefined);
|
|
124804
|
+
}
|
|
124737
124805
|
}
|
|
124738
124806
|
catch (error) {
|
|
124739
124807
|
console.error("[DB] Error during logout:", error);
|
|
@@ -124838,13 +124906,11 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
124838
124906
|
return db_holster_generator(this, function (_a) {
|
|
124839
124907
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
124840
124908
|
// Holster: use .get().next() for chaining
|
|
124909
|
+
// Check if username exists by looking up ~@username
|
|
124841
124910
|
_this.holster.get("~@".concat(alias)).next(null, null, function (user) {
|
|
124842
|
-
|
|
124843
|
-
|
|
124844
|
-
|
|
124845
|
-
else {
|
|
124846
|
-
resolve(true);
|
|
124847
|
-
}
|
|
124911
|
+
// If user exists, alias is taken (return true)
|
|
124912
|
+
// If user is null/undefined, alias is available (return false)
|
|
124913
|
+
resolve(!!user);
|
|
124848
124914
|
});
|
|
124849
124915
|
})];
|
|
124850
124916
|
});
|
|
@@ -125079,6 +125145,14 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
125079
125145
|
console.error("[DB] Alias registration failed:", registerError_1);
|
|
125080
125146
|
return [3 /*break*/, 4];
|
|
125081
125147
|
case 4:
|
|
125148
|
+
// Emit auth:signup event if core is available
|
|
125149
|
+
if (this.core && typeof this.core.emit === "function") {
|
|
125150
|
+
this.core.emit("auth:signup", {
|
|
125151
|
+
userPub: authenticatedUserPub,
|
|
125152
|
+
username: normalizedUsername,
|
|
125153
|
+
method: "password",
|
|
125154
|
+
});
|
|
125155
|
+
}
|
|
125082
125156
|
resolve({
|
|
125083
125157
|
success: true,
|
|
125084
125158
|
userPub: authenticatedUserPub,
|
|
@@ -125156,6 +125230,14 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
125156
125230
|
catch (saveError) {
|
|
125157
125231
|
// Ignore save errors
|
|
125158
125232
|
}
|
|
125233
|
+
// Emit auth:login event if core is available
|
|
125234
|
+
if (_this.core && typeof _this.core.emit === "function") {
|
|
125235
|
+
_this.core.emit("auth:login", {
|
|
125236
|
+
userPub: userPub,
|
|
125237
|
+
username: alias || normalizedUsername,
|
|
125238
|
+
method: "password",
|
|
125239
|
+
});
|
|
125240
|
+
}
|
|
125159
125241
|
resolve(_this.buildLoginResult(alias || normalizedUsername, userPub));
|
|
125160
125242
|
});
|
|
125161
125243
|
})];
|
|
@@ -125294,6 +125376,14 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
125294
125376
|
catch (saveError) {
|
|
125295
125377
|
// Ignore save errors
|
|
125296
125378
|
}
|
|
125379
|
+
// Emit auth:login event if core is available (existing user)
|
|
125380
|
+
if (_this.core && typeof _this.core.emit === "function") {
|
|
125381
|
+
_this.core.emit("auth:login", {
|
|
125382
|
+
userPub: pair.pub,
|
|
125383
|
+
username: normalizedUsername,
|
|
125384
|
+
method: "pair",
|
|
125385
|
+
});
|
|
125386
|
+
}
|
|
125297
125387
|
resolve(_this.buildLoginResult(normalizedUsername, pair.pub));
|
|
125298
125388
|
}, { wait: 5000 });
|
|
125299
125389
|
return [2 /*return*/];
|
|
@@ -125403,6 +125493,19 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
125403
125493
|
catch (saveError) {
|
|
125404
125494
|
// Ignore save errors
|
|
125405
125495
|
}
|
|
125496
|
+
// Emit auth:signup event (new user created) and auth:login event if core is available
|
|
125497
|
+
if (this.core && typeof this.core.emit === "function") {
|
|
125498
|
+
this.core.emit("auth:signup", {
|
|
125499
|
+
userPub: pair.pub,
|
|
125500
|
+
username: normalizedUsername,
|
|
125501
|
+
method: "pair",
|
|
125502
|
+
});
|
|
125503
|
+
this.core.emit("auth:login", {
|
|
125504
|
+
userPub: pair.pub,
|
|
125505
|
+
username: normalizedUsername,
|
|
125506
|
+
method: "pair",
|
|
125507
|
+
});
|
|
125508
|
+
}
|
|
125406
125509
|
resolve(this.buildLoginResult(normalizedUsername, pair.pub));
|
|
125407
125510
|
return [2 /*return*/];
|
|
125408
125511
|
}
|
|
@@ -125563,17 +125666,28 @@ var DataBaseHolster = /** @class */ (function () {
|
|
|
125563
125666
|
once: function (callback) {
|
|
125564
125667
|
// Implement .once() using .on()
|
|
125565
125668
|
var called = false;
|
|
125669
|
+
var unsubscribe = null;
|
|
125566
125670
|
var wrappedCallback = function (data) {
|
|
125567
125671
|
if (!called) {
|
|
125568
125672
|
called = true;
|
|
125569
125673
|
callback(data);
|
|
125674
|
+
// Unsubscribe immediately after callback
|
|
125675
|
+
if (unsubscribe) {
|
|
125676
|
+
unsubscribe();
|
|
125677
|
+
unsubscribe = null;
|
|
125678
|
+
}
|
|
125679
|
+
else if (chain.off) {
|
|
125680
|
+
chain.off(wrappedCallback);
|
|
125681
|
+
}
|
|
125570
125682
|
}
|
|
125571
125683
|
};
|
|
125572
|
-
|
|
125573
|
-
|
|
125574
|
-
|
|
125575
|
-
|
|
125576
|
-
|
|
125684
|
+
// Subscribe and store unsubscribe function
|
|
125685
|
+
if (chain.on) {
|
|
125686
|
+
var unsub = chain.on(wrappedCallback);
|
|
125687
|
+
if (typeof unsub === "function") {
|
|
125688
|
+
unsubscribe = unsub;
|
|
125689
|
+
}
|
|
125690
|
+
}
|
|
125577
125691
|
return createChainProxy(chain);
|
|
125578
125692
|
},
|
|
125579
125693
|
on: function (callback) {
|
|
@@ -125862,6 +125976,21 @@ var CoreInitializer = /** @class */ (function () {
|
|
|
125862
125976
|
throw new Error("Failed to initialize DataBaseHolster: ".concat(error));
|
|
125863
125977
|
}
|
|
125864
125978
|
};
|
|
125979
|
+
/**
|
|
125980
|
+
* Check if we're using Holster instead of Gun
|
|
125981
|
+
* Holster has a 'next' method that Gun doesn't have
|
|
125982
|
+
*/
|
|
125983
|
+
CoreInitializer.prototype.isHolster = function () {
|
|
125984
|
+
// Check if gun has 'next' method (Holster-specific)
|
|
125985
|
+
if (typeof this.core.gun.next === "function") {
|
|
125986
|
+
return true;
|
|
125987
|
+
}
|
|
125988
|
+
// Check if db is DataBaseHolster instance
|
|
125989
|
+
if (this.core.db && this.core.db.constructor.name === "DataBaseHolster") {
|
|
125990
|
+
return true;
|
|
125991
|
+
}
|
|
125992
|
+
return false;
|
|
125993
|
+
};
|
|
125865
125994
|
/**
|
|
125866
125995
|
* Initialize Gun/Holster user
|
|
125867
125996
|
*/
|
|
@@ -125891,28 +126020,48 @@ var CoreInitializer = /** @class */ (function () {
|
|
|
125891
126020
|
}
|
|
125892
126021
|
throw new Error("Failed to initialize user: ".concat(error));
|
|
125893
126022
|
}
|
|
125894
|
-
// Setup auth event listener
|
|
125895
|
-
|
|
125896
|
-
|
|
125897
|
-
|
|
125898
|
-
|
|
125899
|
-
|
|
125900
|
-
|
|
125901
|
-
|
|
126023
|
+
// Setup auth event listener
|
|
126024
|
+
// Gun has native "auth" events, but Holster doesn't support global events
|
|
126025
|
+
// Holster uses polling in DataBaseHolster.subscribeToAuthEvents() instead
|
|
126026
|
+
if (this.isHolster()) {
|
|
126027
|
+
// Holster doesn't support global "auth" events
|
|
126028
|
+
// Auth events are handled via polling in DataBaseHolster
|
|
126029
|
+
// The DataBaseHolster will emit auth events via its onAuth callbacks
|
|
126030
|
+
if (typeof console !== "undefined" && console.log) {
|
|
126031
|
+
console.log("[CoreInitializer] Using Holster - auth events handled via DataBaseHolster polling");
|
|
126032
|
+
}
|
|
126033
|
+
}
|
|
126034
|
+
else if (typeof this.core.gun.on === "function") {
|
|
126035
|
+
// Gun has native "auth" events
|
|
126036
|
+
try {
|
|
126037
|
+
this.core.gun.on("auth", function (user) {
|
|
126038
|
+
var _a;
|
|
126039
|
+
var userInstance = _this.core.gun.user();
|
|
126040
|
+
if (typeof userInstance.recall === "function") {
|
|
126041
|
+
if (userInstance.recall.length > 0) {
|
|
126042
|
+
_this.core._user = userInstance.recall({ sessionStorage: true });
|
|
126043
|
+
}
|
|
126044
|
+
else {
|
|
126045
|
+
userInstance.recall();
|
|
126046
|
+
_this.core._user = userInstance.is ? userInstance : null;
|
|
126047
|
+
}
|
|
125902
126048
|
}
|
|
125903
126049
|
else {
|
|
125904
|
-
userInstance
|
|
125905
|
-
_this.core._user = userInstance.is ? userInstance : null;
|
|
126050
|
+
_this.core._user = userInstance;
|
|
125906
126051
|
}
|
|
125907
|
-
|
|
125908
|
-
|
|
125909
|
-
|
|
125910
|
-
|
|
125911
|
-
_this.core.emit("auth:login", {
|
|
125912
|
-
userPub: user.pub || ((_a = user.is) === null || _a === void 0 ? void 0 : _a.pub),
|
|
125913
|
-
method: "password",
|
|
126052
|
+
_this.core.emit("auth:login", {
|
|
126053
|
+
userPub: user.pub || ((_a = user.is) === null || _a === void 0 ? void 0 : _a.pub),
|
|
126054
|
+
method: "password",
|
|
126055
|
+
});
|
|
125914
126056
|
});
|
|
125915
|
-
}
|
|
126057
|
+
}
|
|
126058
|
+
catch (error) {
|
|
126059
|
+
// If gun.on("auth") fails, it might be because we're using Holster
|
|
126060
|
+
// but the detection didn't work. Log and continue.
|
|
126061
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
126062
|
+
console.warn("[CoreInitializer] Failed to register auth event listener:", error);
|
|
126063
|
+
}
|
|
126064
|
+
}
|
|
125916
126065
|
}
|
|
125917
126066
|
};
|
|
125918
126067
|
/**
|
|
@@ -125943,57 +126092,67 @@ var CoreInitializer = /** @class */ (function () {
|
|
|
125943
126092
|
*/
|
|
125944
126093
|
CoreInitializer.prototype.setupWalletDerivation = function () {
|
|
125945
126094
|
var _this = this;
|
|
125946
|
-
|
|
125947
|
-
|
|
125948
|
-
this.core.
|
|
125949
|
-
|
|
125950
|
-
|
|
125951
|
-
|
|
125952
|
-
|
|
125953
|
-
|
|
125954
|
-
|
|
125955
|
-
|
|
125956
|
-
|
|
125957
|
-
|
|
125958
|
-
|
|
125959
|
-
|
|
125960
|
-
|
|
125961
|
-
|
|
125962
|
-
|
|
125963
|
-
|
|
125964
|
-
|
|
125965
|
-
|
|
125966
|
-
|
|
125967
|
-
|
|
125968
|
-
|
|
125969
|
-
|
|
125970
|
-
|
|
126095
|
+
if (this.isHolster()) {
|
|
126096
|
+
// For Holster, wallet derivation is handled via onAuth callbacks in DataBaseHolster
|
|
126097
|
+
if (this.core.db && typeof this.core.db.onAuth === "function") {
|
|
126098
|
+
this.core.db.onAuth(function (user) { return CoreInitializer_awaiter(_this, void 0, void 0, function () {
|
|
126099
|
+
var priv, pub, _a;
|
|
126100
|
+
var _b, _c;
|
|
126101
|
+
return CoreInitializer_generator(this, function (_d) {
|
|
126102
|
+
switch (_d.label) {
|
|
126103
|
+
case 0:
|
|
126104
|
+
if (!user.is)
|
|
126105
|
+
return [2 /*return*/];
|
|
126106
|
+
priv = (_b = user.is) === null || _b === void 0 ? void 0 : _b.epriv;
|
|
126107
|
+
pub = (_c = user.is) === null || _c === void 0 ? void 0 : _c.epub;
|
|
126108
|
+
if (!(priv && pub)) return [3 /*break*/, 2];
|
|
126109
|
+
_a = this.core;
|
|
126110
|
+
return [4 /*yield*/, derive(priv, pub, {
|
|
126111
|
+
includeSecp256k1Bitcoin: true,
|
|
126112
|
+
includeSecp256k1Ethereum: true,
|
|
126113
|
+
})];
|
|
126114
|
+
case 1:
|
|
126115
|
+
_a.wallets = _d.sent();
|
|
126116
|
+
_d.label = 2;
|
|
126117
|
+
case 2: return [2 /*return*/];
|
|
126118
|
+
}
|
|
126119
|
+
});
|
|
126120
|
+
}); });
|
|
126121
|
+
}
|
|
125971
126122
|
}
|
|
125972
|
-
else {
|
|
125973
|
-
//
|
|
125974
|
-
|
|
125975
|
-
|
|
125976
|
-
|
|
125977
|
-
|
|
125978
|
-
|
|
125979
|
-
|
|
125980
|
-
|
|
125981
|
-
|
|
125982
|
-
|
|
125983
|
-
|
|
125984
|
-
|
|
125985
|
-
|
|
125986
|
-
|
|
125987
|
-
|
|
125988
|
-
|
|
125989
|
-
|
|
125990
|
-
|
|
125991
|
-
|
|
125992
|
-
|
|
125993
|
-
|
|
125994
|
-
|
|
125995
|
-
|
|
125996
|
-
|
|
126123
|
+
else if (typeof this.core.gun.on === "function") {
|
|
126124
|
+
// Gun has native "auth" events
|
|
126125
|
+
try {
|
|
126126
|
+
this.core.gun.on("auth", function (user) { return CoreInitializer_awaiter(_this, void 0, void 0, function () {
|
|
126127
|
+
var priv, pub, _a;
|
|
126128
|
+
var _b, _c, _d, _e, _f, _g;
|
|
126129
|
+
return CoreInitializer_generator(this, function (_h) {
|
|
126130
|
+
switch (_h.label) {
|
|
126131
|
+
case 0:
|
|
126132
|
+
if (!user.is)
|
|
126133
|
+
return [2 /*return*/];
|
|
126134
|
+
priv = ((_c = (_b = user._) === null || _b === void 0 ? void 0 : _b.sea) === null || _c === void 0 ? void 0 : _c.epriv) || ((_d = user.is) === null || _d === void 0 ? void 0 : _d.epriv);
|
|
126135
|
+
pub = ((_f = (_e = user._) === null || _e === void 0 ? void 0 : _e.sea) === null || _f === void 0 ? void 0 : _f.epub) || ((_g = user.is) === null || _g === void 0 ? void 0 : _g.epub);
|
|
126136
|
+
if (!(priv && pub)) return [3 /*break*/, 2];
|
|
126137
|
+
_a = this.core;
|
|
126138
|
+
return [4 /*yield*/, derive(priv, pub, {
|
|
126139
|
+
includeSecp256k1Bitcoin: true,
|
|
126140
|
+
includeSecp256k1Ethereum: true,
|
|
126141
|
+
})];
|
|
126142
|
+
case 1:
|
|
126143
|
+
_a.wallets = _h.sent();
|
|
126144
|
+
_h.label = 2;
|
|
126145
|
+
case 2: return [2 /*return*/];
|
|
126146
|
+
}
|
|
126147
|
+
});
|
|
126148
|
+
}); });
|
|
126149
|
+
}
|
|
126150
|
+
catch (error) {
|
|
126151
|
+
// If gun.on("auth") fails, log and continue
|
|
126152
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
126153
|
+
console.warn("[CoreInitializer] Failed to register wallet derivation listener:", error);
|
|
126154
|
+
}
|
|
126155
|
+
}
|
|
125997
126156
|
}
|
|
125998
126157
|
};
|
|
125999
126158
|
/**
|