shogun-core 1.6.12 → 1.6.14
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.
|
@@ -96870,9 +96870,8 @@ class ShogunCore {
|
|
|
96870
96870
|
this.register(nostrConnectorPlugin);
|
|
96871
96871
|
}
|
|
96872
96872
|
if (config.oauth?.enabled) {
|
|
96873
|
-
const oauthPlugin = new oauthPlugin_1.OAuthPlugin();
|
|
96873
|
+
const oauthPlugin = new oauthPlugin_1.OAuthPlugin(config.oauth);
|
|
96874
96874
|
oauthPlugin._category = shogun_1.PluginCategory.Authentication;
|
|
96875
|
-
oauthPlugin.configure(config.oauth);
|
|
96876
96875
|
this.register(oauthPlugin);
|
|
96877
96876
|
}
|
|
96878
96877
|
}
|
|
@@ -99628,7 +99627,9 @@ exports.OAuthConnector = OAuthConnector;
|
|
|
99628
99627
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
99629
99628
|
exports.OAuthPlugin = void 0;
|
|
99630
99629
|
const base_1 = __webpack_require__(/*! ../base */ "./src/plugins/base.ts");
|
|
99630
|
+
const oauthConnector_1 = __webpack_require__(/*! ./oauthConnector */ "./src/plugins/oauth/oauthConnector.ts");
|
|
99631
99631
|
const errorHandler_1 = __webpack_require__(/*! ../../utils/errorHandler */ "./src/utils/errorHandler.ts");
|
|
99632
|
+
const storage_1 = __webpack_require__(/*! ../../storage/storage */ "./src/storage/storage.ts");
|
|
99632
99633
|
/**
|
|
99633
99634
|
* OAuth Plugin for ShogunCore
|
|
99634
99635
|
* Provides authentication with external OAuth providers
|
|
@@ -99640,12 +99641,26 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99640
99641
|
oauthConnector = null;
|
|
99641
99642
|
config = {};
|
|
99642
99643
|
storage = null;
|
|
99644
|
+
/**
|
|
99645
|
+
* Constructor for OAuthPlugin
|
|
99646
|
+
* @param config - Initial configuration for OAuth
|
|
99647
|
+
*/
|
|
99648
|
+
constructor(config) {
|
|
99649
|
+
super();
|
|
99650
|
+
if (config) {
|
|
99651
|
+
this.config = config;
|
|
99652
|
+
}
|
|
99653
|
+
}
|
|
99643
99654
|
/**
|
|
99644
99655
|
* @inheritdoc
|
|
99645
99656
|
*/
|
|
99646
99657
|
initialize(core) {
|
|
99647
99658
|
this.core = core;
|
|
99648
|
-
|
|
99659
|
+
this.storage = new storage_1.ShogunStorage();
|
|
99660
|
+
// Inizializziamo il connector OAuth con la configurazione già presente
|
|
99661
|
+
this.oauthConnector = new oauthConnector_1.OAuthConnector(this.config);
|
|
99662
|
+
// Valida la configurazione di sicurezza dopo l'inizializzazione
|
|
99663
|
+
this.validateOAuthSecurity();
|
|
99649
99664
|
}
|
|
99650
99665
|
/**
|
|
99651
99666
|
* Valida la configurazione di sicurezza OAuth
|
|
@@ -99665,7 +99680,6 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99665
99680
|
// Verifica che non ci sia client_secret nel browser (eccetto Google con PKCE)
|
|
99666
99681
|
if (providerConfig.clientSecret && typeof window !== "undefined") {
|
|
99667
99682
|
if (provider === "google" && providerConfig.usePKCE) {
|
|
99668
|
-
console.log(`[oauthPlugin] Provider ${provider} ha client_secret configurato - OK per Google con PKCE`);
|
|
99669
99683
|
// Non lanciare errore per Google con PKCE
|
|
99670
99684
|
continue;
|
|
99671
99685
|
}
|
|
@@ -99682,11 +99696,16 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99682
99696
|
*/
|
|
99683
99697
|
configure(config) {
|
|
99684
99698
|
this.config = { ...this.config, ...config };
|
|
99685
|
-
//
|
|
99686
|
-
if (this.oauthConnector) {
|
|
99699
|
+
// Inizializza il connector se non è già stato fatto
|
|
99700
|
+
if (!this.oauthConnector) {
|
|
99701
|
+
this.oauthConnector = new oauthConnector_1.OAuthConnector(this.config);
|
|
99702
|
+
}
|
|
99703
|
+
else {
|
|
99704
|
+
// Update connector configuration se già inizializzato
|
|
99687
99705
|
this.oauthConnector.updateConfig(this.config);
|
|
99688
|
-
console.log("[oauthPlugin] OAuth connector configuration updated", this.config.providers);
|
|
99689
99706
|
}
|
|
99707
|
+
// Validate security settings
|
|
99708
|
+
this.validateOAuthSecurity();
|
|
99690
99709
|
}
|
|
99691
99710
|
/**
|
|
99692
99711
|
* @inheritdoc
|
|
@@ -99696,8 +99715,8 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99696
99715
|
this.oauthConnector.cleanup();
|
|
99697
99716
|
}
|
|
99698
99717
|
this.oauthConnector = null;
|
|
99718
|
+
this.storage = null;
|
|
99699
99719
|
super.destroy();
|
|
99700
|
-
console.log("[oauthPlugin] OAuth plugin destroyed");
|
|
99701
99720
|
}
|
|
99702
99721
|
/**
|
|
99703
99722
|
* Ensure that the OAuth connector is initialized
|
|
@@ -99726,21 +99745,18 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99726
99745
|
* @inheritdoc
|
|
99727
99746
|
*/
|
|
99728
99747
|
async initiateOAuth(provider) {
|
|
99729
|
-
console.log(`Initiating OAuth flow with ${provider}`);
|
|
99730
99748
|
return this.assertOAuthConnector().initiateOAuth(provider);
|
|
99731
99749
|
}
|
|
99732
99750
|
/**
|
|
99733
99751
|
* @inheritdoc
|
|
99734
99752
|
*/
|
|
99735
99753
|
async completeOAuth(provider, authCode, state) {
|
|
99736
|
-
console.log(`Completing OAuth flow with ${provider}`);
|
|
99737
99754
|
return this.assertOAuthConnector().completeOAuth(provider, authCode, state);
|
|
99738
99755
|
}
|
|
99739
99756
|
/**
|
|
99740
99757
|
* @inheritdoc
|
|
99741
99758
|
*/
|
|
99742
99759
|
async generateCredentials(userInfo, provider) {
|
|
99743
|
-
console.log(`Generating credentials for ${provider} user`);
|
|
99744
99760
|
return this.assertOAuthConnector().generateCredentials(userInfo, provider);
|
|
99745
99761
|
}
|
|
99746
99762
|
/**
|
|
@@ -99752,10 +99768,8 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99752
99768
|
* happens in handleOAuthCallback when the provider redirects back.
|
|
99753
99769
|
*/
|
|
99754
99770
|
async login(provider) {
|
|
99755
|
-
console.log(`OAuth login with ${provider}`);
|
|
99756
99771
|
try {
|
|
99757
99772
|
const core = this.assertInitialized();
|
|
99758
|
-
console.log(`OAuth login attempt with provider: ${provider}`);
|
|
99759
99773
|
if (!provider) {
|
|
99760
99774
|
throw (0, errorHandler_1.createError)(errorHandler_1.ErrorType.VALIDATION, "PROVIDER_REQUIRED", "OAuth provider required for OAuth login");
|
|
99761
99775
|
}
|
|
@@ -99806,10 +99820,8 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99806
99820
|
* happens in handleOAuthCallback when the provider redirects back.
|
|
99807
99821
|
*/
|
|
99808
99822
|
async signUp(provider) {
|
|
99809
|
-
console.log(`OAuth signup with ${provider}`);
|
|
99810
99823
|
try {
|
|
99811
99824
|
const core = this.assertInitialized();
|
|
99812
|
-
console.log(`OAuth signup attempt with provider: ${provider}`);
|
|
99813
99825
|
if (!provider) {
|
|
99814
99826
|
throw (0, errorHandler_1.createError)(errorHandler_1.ErrorType.VALIDATION, "PROVIDER_REQUIRED", "OAuth provider required for OAuth signup");
|
|
99815
99827
|
}
|
|
@@ -99857,7 +99869,6 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99857
99869
|
*/
|
|
99858
99870
|
async handleOAuthCallback(provider, authCode, state) {
|
|
99859
99871
|
try {
|
|
99860
|
-
console.log(`Handling OAuth callback for ${provider}`);
|
|
99861
99872
|
const core = this.assertInitialized();
|
|
99862
99873
|
// Validazione di sicurezza pre-callback
|
|
99863
99874
|
if (!authCode || !state) {
|
|
@@ -99924,7 +99935,6 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99924
99935
|
return authResult;
|
|
99925
99936
|
}
|
|
99926
99937
|
catch (error) {
|
|
99927
|
-
console.error(`Error handling OAuth callback for ${provider}:`, error);
|
|
99928
99938
|
// Pulisci i dati OAuth anche in caso di errore
|
|
99929
99939
|
this.cleanupExpiredOAuthData();
|
|
99930
99940
|
return {
|
|
@@ -99988,7 +99998,6 @@ class OAuthPlugin extends base_1.BasePlugin {
|
|
|
99988
99998
|
* @deprecated Use handleOAuthCallback instead
|
|
99989
99999
|
*/
|
|
99990
100000
|
async handleSimpleOAuth(provider, authCode, state) {
|
|
99991
|
-
console.log(`handleSimpleOAuth called (alias for handleOAuthCallback) for ${provider}`);
|
|
99992
100001
|
return this.handleOAuthCallback(provider, authCode, state);
|
|
99993
100002
|
}
|
|
99994
100003
|
/**
|