@insforge/sdk 1.3.0 → 1.3.1

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/ssr.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as InsForgeConfig, I as InsForgeClient, m as AuthRefreshResponse, e as InsForgeError } from './client-CQfw9UsO.mjs';
1
+ import { a as InsForgeConfig, I as InsForgeClient, m as AuthRefreshResponse, e as InsForgeError } from './client-DTNmGqHB.mjs';
2
2
  import '@insforge/shared-schemas';
3
3
  import '@supabase/postgrest-js';
4
4
 
package/dist/ssr.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as InsForgeConfig, I as InsForgeClient, m as AuthRefreshResponse, e as InsForgeError } from './client-CQfw9UsO.js';
1
+ import { a as InsForgeConfig, I as InsForgeClient, m as AuthRefreshResponse, e as InsForgeError } from './client-DTNmGqHB.js';
2
2
  import '@insforge/shared-schemas';
3
3
  import '@supabase/postgrest-js';
4
4
 
package/dist/ssr.js CHANGED
@@ -1057,21 +1057,43 @@ var Auth = class {
1057
1057
  };
1058
1058
  }
1059
1059
  }
1060
- // ============================================================================
1061
- // OAuth Authentication
1062
- // ============================================================================
1063
- /**
1064
- * Sign in with OAuth provider using PKCE flow
1065
- */
1066
- async signInWithOAuth(options) {
1060
+ async signInWithOAuth(providerOrOptions, options) {
1067
1061
  try {
1068
- const { provider, redirectTo, skipBrowserRedirect } = options;
1062
+ let signInOptions;
1063
+ if (typeof providerOrOptions === "object") {
1064
+ signInOptions = providerOrOptions;
1065
+ } else if (options) {
1066
+ signInOptions = { provider: providerOrOptions, ...options };
1067
+ } else {
1068
+ return {
1069
+ data: {},
1070
+ error: new InsForgeError(
1071
+ "OAuth sign-in options are required",
1072
+ 400,
1073
+ import_shared_schemas.ERROR_CODES.INVALID_INPUT
1074
+ )
1075
+ };
1076
+ }
1077
+ if (!signInOptions || !signInOptions.redirectTo) {
1078
+ return {
1079
+ data: {},
1080
+ error: new InsForgeError(
1081
+ "Redirect URI is required",
1082
+ 400,
1083
+ import_shared_schemas.ERROR_CODES.INVALID_INPUT
1084
+ )
1085
+ };
1086
+ }
1087
+ const { provider } = signInOptions;
1069
1088
  const providerKey = encodeURIComponent(provider.toLowerCase());
1070
1089
  const codeVerifier = generateCodeVerifier();
1071
1090
  const codeChallenge = await generateCodeChallenge(codeVerifier);
1072
1091
  storePkceVerifier(codeVerifier);
1073
- const params = { code_challenge: codeChallenge };
1074
- if (redirectTo) params.redirect_uri = redirectTo;
1092
+ const params = {
1093
+ ...signInOptions.additionalParams ?? {},
1094
+ redirect_uri: signInOptions.redirectTo,
1095
+ code_challenge: codeChallenge
1096
+ };
1075
1097
  const isBuiltInProvider = import_shared_schemas.oAuthProvidersSchema.options.includes(
1076
1098
  providerKey
1077
1099
  );
@@ -1080,7 +1102,7 @@ var Auth = class {
1080
1102
  params,
1081
1103
  skipAuthRefresh: true
1082
1104
  });
1083
- if (!this.isServerMode() && typeof window !== "undefined" && !skipBrowserRedirect) {
1105
+ if (!this.isServerMode() && typeof window !== "undefined" && !signInOptions.skipBrowserRedirect) {
1084
1106
  window.location.href = response.authUrl;
1085
1107
  return { data: {}, error: null };
1086
1108
  }