shogun-core 1.6.12 → 1.6.13

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.
@@ -99628,7 +99628,9 @@ exports.OAuthConnector = OAuthConnector;
99628
99628
  Object.defineProperty(exports, "__esModule", ({ value: true }));
99629
99629
  exports.OAuthPlugin = void 0;
99630
99630
  const base_1 = __webpack_require__(/*! ../base */ "./src/plugins/base.ts");
99631
+ const oauthConnector_1 = __webpack_require__(/*! ./oauthConnector */ "./src/plugins/oauth/oauthConnector.ts");
99631
99632
  const errorHandler_1 = __webpack_require__(/*! ../../utils/errorHandler */ "./src/utils/errorHandler.ts");
99633
+ const storage_1 = __webpack_require__(/*! ../../storage/storage */ "./src/storage/storage.ts");
99632
99634
  /**
99633
99635
  * OAuth Plugin for ShogunCore
99634
99636
  * Provides authentication with external OAuth providers
@@ -99645,7 +99647,9 @@ class OAuthPlugin extends base_1.BasePlugin {
99645
99647
  */
99646
99648
  initialize(core) {
99647
99649
  this.core = core;
99648
- // this.setupConnectors();
99650
+ this.storage = new storage_1.ShogunStorage();
99651
+ // Inizializziamo il connector OAuth
99652
+ this.oauthConnector = new oauthConnector_1.OAuthConnector();
99649
99653
  }
99650
99654
  /**
99651
99655
  * Valida la configurazione di sicurezza OAuth
@@ -99665,7 +99669,6 @@ class OAuthPlugin extends base_1.BasePlugin {
99665
99669
  // Verifica che non ci sia client_secret nel browser (eccetto Google con PKCE)
99666
99670
  if (providerConfig.clientSecret && typeof window !== "undefined") {
99667
99671
  if (provider === "google" && providerConfig.usePKCE) {
99668
- console.log(`[oauthPlugin] Provider ${provider} ha client_secret configurato - OK per Google con PKCE`);
99669
99672
  // Non lanciare errore per Google con PKCE
99670
99673
  continue;
99671
99674
  }
@@ -99682,11 +99685,14 @@ class OAuthPlugin extends base_1.BasePlugin {
99682
99685
  */
99683
99686
  configure(config) {
99684
99687
  this.config = { ...this.config, ...config };
99685
- // If connector is already initialized, update its configuration
99686
- if (this.oauthConnector) {
99687
- this.oauthConnector.updateConfig(this.config);
99688
- console.log("[oauthPlugin] OAuth connector configuration updated", this.config.providers);
99688
+ // Inizializza il connector se non è già stato fatto
99689
+ if (!this.oauthConnector) {
99690
+ this.oauthConnector = new oauthConnector_1.OAuthConnector();
99689
99691
  }
99692
+ // Update connector configuration
99693
+ this.oauthConnector.updateConfig(this.config);
99694
+ // Validate security settings
99695
+ this.validateOAuthSecurity();
99690
99696
  }
99691
99697
  /**
99692
99698
  * @inheritdoc
@@ -99696,8 +99702,8 @@ class OAuthPlugin extends base_1.BasePlugin {
99696
99702
  this.oauthConnector.cleanup();
99697
99703
  }
99698
99704
  this.oauthConnector = null;
99705
+ this.storage = null;
99699
99706
  super.destroy();
99700
- console.log("[oauthPlugin] OAuth plugin destroyed");
99701
99707
  }
99702
99708
  /**
99703
99709
  * Ensure that the OAuth connector is initialized
@@ -99726,21 +99732,18 @@ class OAuthPlugin extends base_1.BasePlugin {
99726
99732
  * @inheritdoc
99727
99733
  */
99728
99734
  async initiateOAuth(provider) {
99729
- console.log(`Initiating OAuth flow with ${provider}`);
99730
99735
  return this.assertOAuthConnector().initiateOAuth(provider);
99731
99736
  }
99732
99737
  /**
99733
99738
  * @inheritdoc
99734
99739
  */
99735
99740
  async completeOAuth(provider, authCode, state) {
99736
- console.log(`Completing OAuth flow with ${provider}`);
99737
99741
  return this.assertOAuthConnector().completeOAuth(provider, authCode, state);
99738
99742
  }
99739
99743
  /**
99740
99744
  * @inheritdoc
99741
99745
  */
99742
99746
  async generateCredentials(userInfo, provider) {
99743
- console.log(`Generating credentials for ${provider} user`);
99744
99747
  return this.assertOAuthConnector().generateCredentials(userInfo, provider);
99745
99748
  }
99746
99749
  /**
@@ -99752,10 +99755,8 @@ class OAuthPlugin extends base_1.BasePlugin {
99752
99755
  * happens in handleOAuthCallback when the provider redirects back.
99753
99756
  */
99754
99757
  async login(provider) {
99755
- console.log(`OAuth login with ${provider}`);
99756
99758
  try {
99757
99759
  const core = this.assertInitialized();
99758
- console.log(`OAuth login attempt with provider: ${provider}`);
99759
99760
  if (!provider) {
99760
99761
  throw (0, errorHandler_1.createError)(errorHandler_1.ErrorType.VALIDATION, "PROVIDER_REQUIRED", "OAuth provider required for OAuth login");
99761
99762
  }
@@ -99806,10 +99807,8 @@ class OAuthPlugin extends base_1.BasePlugin {
99806
99807
  * happens in handleOAuthCallback when the provider redirects back.
99807
99808
  */
99808
99809
  async signUp(provider) {
99809
- console.log(`OAuth signup with ${provider}`);
99810
99810
  try {
99811
99811
  const core = this.assertInitialized();
99812
- console.log(`OAuth signup attempt with provider: ${provider}`);
99813
99812
  if (!provider) {
99814
99813
  throw (0, errorHandler_1.createError)(errorHandler_1.ErrorType.VALIDATION, "PROVIDER_REQUIRED", "OAuth provider required for OAuth signup");
99815
99814
  }
@@ -99857,7 +99856,6 @@ class OAuthPlugin extends base_1.BasePlugin {
99857
99856
  */
99858
99857
  async handleOAuthCallback(provider, authCode, state) {
99859
99858
  try {
99860
- console.log(`Handling OAuth callback for ${provider}`);
99861
99859
  const core = this.assertInitialized();
99862
99860
  // Validazione di sicurezza pre-callback
99863
99861
  if (!authCode || !state) {
@@ -99924,7 +99922,6 @@ class OAuthPlugin extends base_1.BasePlugin {
99924
99922
  return authResult;
99925
99923
  }
99926
99924
  catch (error) {
99927
- console.error(`Error handling OAuth callback for ${provider}:`, error);
99928
99925
  // Pulisci i dati OAuth anche in caso di errore
99929
99926
  this.cleanupExpiredOAuthData();
99930
99927
  return {
@@ -99988,7 +99985,6 @@ class OAuthPlugin extends base_1.BasePlugin {
99988
99985
  * @deprecated Use handleOAuthCallback instead
99989
99986
  */
99990
99987
  async handleSimpleOAuth(provider, authCode, state) {
99991
- console.log(`handleSimpleOAuth called (alias for handleOAuthCallback) for ${provider}`);
99992
99988
  return this.handleOAuthCallback(provider, authCode, state);
99993
99989
  }
99994
99990
  /**