@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/README.md CHANGED
@@ -55,9 +55,9 @@ const { data, error } = await insforge.auth.signInWithPassword({
55
55
  password: 'securePassword123'
56
56
  });
57
57
 
58
- // OAuth authentication (Google, GitHub)
58
+ // OAuth authentication (built-in or custom provider key)
59
59
  await insforge.auth.signInWithOAuth({
60
- provider: 'google',
60
+ provider: 'google', // e.g. built-in: "google", custom: "auth0-acme"
61
61
  redirectTo: 'http://localhost:3000/dashboard'
62
62
  });
63
63
 
package/dist/index.d.mts CHANGED
@@ -304,7 +304,7 @@ declare class Auth {
304
304
  * Sign in with OAuth provider using PKCE flow
305
305
  */
306
306
  signInWithOAuth(options: {
307
- provider: OAuthProvidersSchema;
307
+ provider: OAuthProvidersSchema | string;
308
308
  redirectTo?: string;
309
309
  skipBrowserRedirect?: boolean;
310
310
  }): Promise<{
package/dist/index.d.ts CHANGED
@@ -304,7 +304,7 @@ declare class Auth {
304
304
  * Sign in with OAuth provider using PKCE flow
305
305
  */
306
306
  signInWithOAuth(options: {
307
- provider: OAuthProvidersSchema;
307
+ provider: OAuthProvidersSchema | string;
308
308
  redirectTo?: string;
309
309
  skipBrowserRedirect?: boolean;
310
310
  }): Promise<{
package/dist/index.js CHANGED
@@ -649,6 +649,7 @@ function cleanUrlParams(...params) {
649
649
  }
650
650
 
651
651
  // src/modules/auth/auth.ts
652
+ var import_shared_schemas = require("@insforge/shared-schemas");
652
653
  var Auth = class {
653
654
  constructor(http, tokenManager, options = {}) {
654
655
  this.http = http;
@@ -795,18 +796,23 @@ var Auth = class {
795
796
  async signInWithOAuth(options) {
796
797
  try {
797
798
  const { provider, redirectTo, skipBrowserRedirect } = options;
799
+ const providerKey = encodeURIComponent(provider.toLowerCase());
798
800
  const codeVerifier = generateCodeVerifier();
799
801
  const codeChallenge = await generateCodeChallenge(codeVerifier);
800
802
  storePkceVerifier(codeVerifier);
801
803
  const params = { code_challenge: codeChallenge };
802
804
  if (redirectTo) params.redirect_uri = redirectTo;
803
- const response = await this.http.get(`/api/auth/oauth/${provider}`, { params });
805
+ const isBuiltInProvider = import_shared_schemas.oAuthProvidersSchema.options.includes(
806
+ providerKey
807
+ );
808
+ const oauthPath = isBuiltInProvider ? `/api/auth/oauth/${providerKey}` : `/api/auth/oauth/custom/${providerKey}`;
809
+ const response = await this.http.get(oauthPath, { params });
804
810
  if (!this.isServerMode() && typeof window !== "undefined" && !skipBrowserRedirect) {
805
811
  window.location.href = response.authUrl;
806
812
  return { data: {}, error: null };
807
813
  }
808
814
  return {
809
- data: { url: response.authUrl, provider, codeVerifier },
815
+ data: { url: response.authUrl, provider: providerKey, codeVerifier },
810
816
  error: null
811
817
  };
812
818
  } catch (error) {