@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.mjs CHANGED
@@ -1009,21 +1009,43 @@ var Auth = class {
1009
1009
  };
1010
1010
  }
1011
1011
  }
1012
- // ============================================================================
1013
- // OAuth Authentication
1014
- // ============================================================================
1015
- /**
1016
- * Sign in with OAuth provider using PKCE flow
1017
- */
1018
- async signInWithOAuth(options) {
1012
+ async signInWithOAuth(providerOrOptions, options) {
1019
1013
  try {
1020
- const { provider, redirectTo, skipBrowserRedirect } = options;
1014
+ let signInOptions;
1015
+ if (typeof providerOrOptions === "object") {
1016
+ signInOptions = providerOrOptions;
1017
+ } else if (options) {
1018
+ signInOptions = { provider: providerOrOptions, ...options };
1019
+ } else {
1020
+ return {
1021
+ data: {},
1022
+ error: new InsForgeError(
1023
+ "OAuth sign-in options are required",
1024
+ 400,
1025
+ ERROR_CODES.INVALID_INPUT
1026
+ )
1027
+ };
1028
+ }
1029
+ if (!signInOptions || !signInOptions.redirectTo) {
1030
+ return {
1031
+ data: {},
1032
+ error: new InsForgeError(
1033
+ "Redirect URI is required",
1034
+ 400,
1035
+ ERROR_CODES.INVALID_INPUT
1036
+ )
1037
+ };
1038
+ }
1039
+ const { provider } = signInOptions;
1021
1040
  const providerKey = encodeURIComponent(provider.toLowerCase());
1022
1041
  const codeVerifier = generateCodeVerifier();
1023
1042
  const codeChallenge = await generateCodeChallenge(codeVerifier);
1024
1043
  storePkceVerifier(codeVerifier);
1025
- const params = { code_challenge: codeChallenge };
1026
- if (redirectTo) params.redirect_uri = redirectTo;
1044
+ const params = {
1045
+ ...signInOptions.additionalParams ?? {},
1046
+ redirect_uri: signInOptions.redirectTo,
1047
+ code_challenge: codeChallenge
1048
+ };
1027
1049
  const isBuiltInProvider = oAuthProvidersSchema.options.includes(
1028
1050
  providerKey
1029
1051
  );
@@ -1032,7 +1054,7 @@ var Auth = class {
1032
1054
  params,
1033
1055
  skipAuthRefresh: true
1034
1056
  });
1035
- if (!this.isServerMode() && typeof window !== "undefined" && !skipBrowserRedirect) {
1057
+ if (!this.isServerMode() && typeof window !== "undefined" && !signInOptions.skipBrowserRedirect) {
1036
1058
  window.location.href = response.authUrl;
1037
1059
  return { data: {}, error: null };
1038
1060
  }