@insforge/sdk 1.2.0 → 1.2.1-dev.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/dist/index.mjs CHANGED
@@ -609,6 +609,7 @@ function cleanUrlParams(...params) {
609
609
  }
610
610
 
611
611
  // src/modules/auth/auth.ts
612
+ import { oAuthProvidersSchema } from "@insforge/shared-schemas";
612
613
  var Auth = class {
613
614
  constructor(http, tokenManager, options = {}) {
614
615
  this.http = http;
@@ -755,18 +756,23 @@ var Auth = class {
755
756
  async signInWithOAuth(options) {
756
757
  try {
757
758
  const { provider, redirectTo, skipBrowserRedirect } = options;
759
+ const providerKey = encodeURIComponent(provider.toLowerCase());
758
760
  const codeVerifier = generateCodeVerifier();
759
761
  const codeChallenge = await generateCodeChallenge(codeVerifier);
760
762
  storePkceVerifier(codeVerifier);
761
763
  const params = { code_challenge: codeChallenge };
762
764
  if (redirectTo) params.redirect_uri = redirectTo;
763
- const response = await this.http.get(`/api/auth/oauth/${provider}`, { params });
765
+ const isBuiltInProvider = oAuthProvidersSchema.options.includes(
766
+ providerKey
767
+ );
768
+ const oauthPath = isBuiltInProvider ? `/api/auth/oauth/${providerKey}` : `/api/auth/oauth/custom/${providerKey}`;
769
+ const response = await this.http.get(oauthPath, { params });
764
770
  if (!this.isServerMode() && typeof window !== "undefined" && !skipBrowserRedirect) {
765
771
  window.location.href = response.authUrl;
766
772
  return { data: {}, error: null };
767
773
  }
768
774
  return {
769
- data: { url: response.authUrl, provider, codeVerifier },
775
+ data: { url: response.authUrl, provider: providerKey, codeVerifier },
770
776
  error: null
771
777
  };
772
778
  } catch (error) {