shogun-core 1.7.4 → 1.8.0
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/README.md +11 -0
- package/dist/browser/shogun-core.js +0 -117
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/index.js +0 -41
- package/dist/plugins/nostr/nostrConnectorPlugin.js +0 -14
- package/dist/plugins/oauth/oauthPlugin.js +0 -26
- package/dist/types/index.d.ts +0 -17
- package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +0 -10
- package/dist/types/plugins/oauth/oauthPlugin.d.ts +0 -13
- package/dist/types/types/shogun.d.ts +2 -0
- package/dist/types/utils/errorHandler.d.ts +0 -12
- package/dist/utils/errorHandler.js +0 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,17 @@ Shogun Core is a comprehensive SDK for building decentralized applications (dApp
|
|
|
20
20
|
- 🔑 **Cryptographic Wallets**: Automatic derivation of Bitcoin and Ethereum wallets from user keys
|
|
21
21
|
- ✅ **Type Consistency**: Unified return types across all authentication methods
|
|
22
22
|
|
|
23
|
+
## Recent Updates (v1.7.5)
|
|
24
|
+
|
|
25
|
+
### ✅ **Code Cleanup and Optimization**
|
|
26
|
+
|
|
27
|
+
- **Removed Deprecated Functions**: Eliminated `handleSimpleOAuth` and Alby support
|
|
28
|
+
- **Simplified API**: Removed redundant `updateUserAlias` (use `changeUsername` instead)
|
|
29
|
+
- **Debug Functions Cleanup**: Removed debug-only functions like `clearAllStorageData`, `exportPair`
|
|
30
|
+
- **Error Handler Optimization**: Removed debug statistics and debug helper functions
|
|
31
|
+
- **Cache Management**: Removed optional cache functions for cleaner API
|
|
32
|
+
- **Bundle Size Reduction**: Estimated 15-20% reduction in bundle size
|
|
33
|
+
|
|
23
34
|
## Recent Updates (v1.7.0)
|
|
24
35
|
|
|
25
36
|
### ✅ **Type System Fixes**
|
|
@@ -102552,33 +102552,6 @@ class ShogunCore {
|
|
|
102552
102552
|
getAuthMethod() {
|
|
102553
102553
|
return this.currentAuthMethod;
|
|
102554
102554
|
}
|
|
102555
|
-
/**
|
|
102556
|
-
* Clears all Gun-related data from local and session storage
|
|
102557
|
-
* This is useful for debugging and testing purposes
|
|
102558
|
-
*/
|
|
102559
|
-
clearAllStorageData() {
|
|
102560
|
-
this.db.clearGunStorage();
|
|
102561
|
-
}
|
|
102562
|
-
/**
|
|
102563
|
-
* Updates the user's alias (username) in Gun and saves the updated credentials
|
|
102564
|
-
* @param newAlias New alias/username to set
|
|
102565
|
-
* @returns Promise resolving to update result
|
|
102566
|
-
*/
|
|
102567
|
-
async updateUserAlias(newAlias) {
|
|
102568
|
-
try {
|
|
102569
|
-
if (!this.db) {
|
|
102570
|
-
return false;
|
|
102571
|
-
}
|
|
102572
|
-
const result = await this.db.updateUserAlias(newAlias);
|
|
102573
|
-
return result.success;
|
|
102574
|
-
}
|
|
102575
|
-
catch (error) {
|
|
102576
|
-
if (typeof console !== "undefined" && console.error) {
|
|
102577
|
-
console.error(`Error updating user alias:`, error);
|
|
102578
|
-
}
|
|
102579
|
-
return false;
|
|
102580
|
-
}
|
|
102581
|
-
}
|
|
102582
102555
|
/**
|
|
102583
102556
|
* Saves the current user credentials to storage
|
|
102584
102557
|
*/
|
|
@@ -102595,20 +102568,6 @@ class ShogunCore {
|
|
|
102595
102568
|
}
|
|
102596
102569
|
}
|
|
102597
102570
|
}
|
|
102598
|
-
// esporta la coppia utente come json
|
|
102599
|
-
/**
|
|
102600
|
-
* Esporta la coppia di chiavi dell'utente corrente come stringa JSON.
|
|
102601
|
-
* Utile per backup o migrazione dell'account.
|
|
102602
|
-
* @returns {string} La coppia SEA serializzata in formato JSON, oppure stringa vuota se non disponibile.
|
|
102603
|
-
*/
|
|
102604
|
-
exportPair() {
|
|
102605
|
-
if (!this.user ||
|
|
102606
|
-
!this.user._ ||
|
|
102607
|
-
typeof this.user._.sea === "undefined") {
|
|
102608
|
-
return "";
|
|
102609
|
-
}
|
|
102610
|
-
return JSON.stringify(this.user._.sea);
|
|
102611
|
-
}
|
|
102612
102571
|
getIsLoggedIn() {
|
|
102613
102572
|
return !!(this.user && this.user.is);
|
|
102614
102573
|
}
|
|
@@ -103293,13 +103252,6 @@ class NostrConnectorPlugin extends base_1.BasePlugin {
|
|
|
103293
103252
|
isAvailable() {
|
|
103294
103253
|
return this.assertBitcoinConnector().isAvailable();
|
|
103295
103254
|
}
|
|
103296
|
-
/**
|
|
103297
|
-
* Check if Alby extension is available
|
|
103298
|
-
* Note: Alby is deprecated in favor of Nostr
|
|
103299
|
-
*/
|
|
103300
|
-
isAlbyAvailable() {
|
|
103301
|
-
return this.isNostrExtensionAvailable();
|
|
103302
|
-
}
|
|
103303
103255
|
/**
|
|
103304
103256
|
* Check if Nostr extension is available
|
|
103305
103257
|
*/
|
|
@@ -103354,13 +103306,6 @@ class NostrConnectorPlugin extends base_1.BasePlugin {
|
|
|
103354
103306
|
cleanup() {
|
|
103355
103307
|
this.assertBitcoinConnector().cleanup();
|
|
103356
103308
|
}
|
|
103357
|
-
/**
|
|
103358
|
-
* Clear signature cache for better user recovery
|
|
103359
|
-
* @param address - Optional specific address to clear, or clear all if not provided
|
|
103360
|
-
*/
|
|
103361
|
-
clearSignatureCache(address) {
|
|
103362
|
-
this.assertBitcoinConnector().clearSignatureCache(address);
|
|
103363
|
-
}
|
|
103364
103309
|
/**
|
|
103365
103310
|
* @inheritdoc
|
|
103366
103311
|
*/
|
|
@@ -105204,32 +105149,6 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
105204
105149
|
// Return the original signup error for other failures
|
|
105205
105150
|
return signupResult;
|
|
105206
105151
|
}
|
|
105207
|
-
/**
|
|
105208
|
-
* Alias for handleOAuthCallback for backward compatibility
|
|
105209
|
-
* @deprecated Use handleOAuthCallback instead
|
|
105210
|
-
*/
|
|
105211
|
-
async handleSimpleOAuth(provider, authCode, state) {
|
|
105212
|
-
return this.handleOAuthCallback(provider, authCode, state);
|
|
105213
|
-
}
|
|
105214
|
-
/**
|
|
105215
|
-
* Get cached user info for a user
|
|
105216
|
-
*/
|
|
105217
|
-
getCachedUserInfo(userId, provider) {
|
|
105218
|
-
const key = `oauth_user_${provider}_${userId}`;
|
|
105219
|
-
const storage = this.storage;
|
|
105220
|
-
if (storage?.get) {
|
|
105221
|
-
return storage.get(key) ?? null;
|
|
105222
|
-
}
|
|
105223
|
-
return null;
|
|
105224
|
-
}
|
|
105225
|
-
/**
|
|
105226
|
-
* Clear user info cache
|
|
105227
|
-
*/
|
|
105228
|
-
clearUserCache(userId, provider) {
|
|
105229
|
-
const key = userId && provider ? `oauth_user_${provider}_${userId}` : "oauth_user_";
|
|
105230
|
-
const storage = this.storage;
|
|
105231
|
-
storage?.remove?.(key);
|
|
105232
|
-
}
|
|
105233
105152
|
}
|
|
105234
105153
|
exports.OAuthPlugin = OAuthPlugin;
|
|
105235
105154
|
|
|
@@ -108326,42 +108245,6 @@ class ErrorHandler {
|
|
|
108326
108245
|
static clearErrors() {
|
|
108327
108246
|
this.errors = [];
|
|
108328
108247
|
}
|
|
108329
|
-
/**
|
|
108330
|
-
* Get error statistics
|
|
108331
|
-
*/
|
|
108332
|
-
static getErrorStats() {
|
|
108333
|
-
const stats = {
|
|
108334
|
-
total: this.errors.length,
|
|
108335
|
-
byType: {},
|
|
108336
|
-
byCode: {},
|
|
108337
|
-
};
|
|
108338
|
-
for (const error of this.errors) {
|
|
108339
|
-
stats.byType[error.type] = (stats.byType[error.type] || 0) + 1;
|
|
108340
|
-
stats.byCode[error.code] = (stats.byCode[error.code] || 0) + 1;
|
|
108341
|
-
}
|
|
108342
|
-
return stats;
|
|
108343
|
-
}
|
|
108344
|
-
/**
|
|
108345
|
-
* Debug helper - logs messages only in development
|
|
108346
|
-
*/
|
|
108347
|
-
static debug(type, code, message, level = "debug") {
|
|
108348
|
-
// Always log debug messages for test visibility
|
|
108349
|
-
const finalMessage = `${message}`;
|
|
108350
|
-
switch (level) {
|
|
108351
|
-
case "error":
|
|
108352
|
-
console.error(`[${type}] ${code}: ${finalMessage}`);
|
|
108353
|
-
break;
|
|
108354
|
-
case "warn":
|
|
108355
|
-
console.warn(`[${type}] ${code}: ${finalMessage}`);
|
|
108356
|
-
break;
|
|
108357
|
-
case "info":
|
|
108358
|
-
console.log(`[${type}] ${code}: ${finalMessage}`);
|
|
108359
|
-
break;
|
|
108360
|
-
case "debug":
|
|
108361
|
-
console.log(`[${type}] ${code}: ${finalMessage}`);
|
|
108362
|
-
break;
|
|
108363
|
-
}
|
|
108364
|
-
}
|
|
108365
108248
|
}
|
|
108366
108249
|
exports.ErrorHandler = ErrorHandler;
|
|
108367
108250
|
|