@base44-preview/cli 0.0.49-pr.445.325d070 → 0.0.49-pr.445.fbdefc5

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/cli/index.js CHANGED
@@ -250811,44 +250811,59 @@ function getAuthPushCommand() {
250811
250811
  // src/cli/commands/auth/social-login.ts
250812
250812
  import { dirname as dirname10, join as join15 } from "node:path";
250813
250813
  var SOCIAL_PROVIDERS = {
250814
- google: { field: "enableGoogleLogin", label: "Google" },
250814
+ google: {
250815
+ field: "enableGoogleLogin",
250816
+ label: "Google",
250817
+ customOAuth: {
250818
+ modeField: "googleOAuthMode",
250819
+ clientIdField: "googleOAuthClientId",
250820
+ secretKey: "google_oauth_client_secret",
250821
+ envVar: "BASE44_GOOGLE_CLIENT_SECRET",
250822
+ promptMessage: "Enter Google OAuth client secret"
250823
+ }
250824
+ },
250815
250825
  microsoft: { field: "enableMicrosoftLogin", label: "Microsoft" },
250816
250826
  facebook: { field: "enableFacebookLogin", label: "Facebook" },
250817
250827
  apple: { field: "enableAppleLogin", label: "Apple" }
250818
250828
  };
250819
250829
  var VALID_PROVIDERS = Object.keys(SOCIAL_PROVIDERS);
250830
+ function hasCustomOAuthOptions(options) {
250831
+ return Boolean(options.clientId || options.clientSecret || options.clientSecretStdin);
250832
+ }
250820
250833
  async function socialLoginAction({ log, isNonInteractive }, provider, action, options) {
250821
250834
  const shouldEnable = action === "enable";
250822
250835
  const providerInfo = SOCIAL_PROVIDERS[provider];
250823
- const hasCustomOAuth = Boolean(options.clientId);
250836
+ const hasOAuthOptions = hasCustomOAuthOptions(options);
250837
+ if (hasOAuthOptions && !providerInfo.customOAuth) {
250838
+ throw new InvalidInputError(`Custom OAuth options are only supported for providers with custom OAuth (e.g., google). Use: base44 auth social-login ${provider} ${action}`);
250839
+ }
250840
+ if (hasOAuthOptions && !shouldEnable) {
250841
+ throw new InvalidInputError(`Custom OAuth options cannot be used with disable. To disable ${providerInfo.label} login: base44 auth social-login ${provider} disable`);
250842
+ }
250824
250843
  const { project: project2 } = await readProjectConfig();
250825
250844
  const configDir = dirname10(project2.configPath);
250826
250845
  const authDir = join15(configDir, project2.authDir);
250827
- if (provider !== "google" && (options.clientId || options.clientSecret || options.clientSecretStdin)) {
250828
- throw new InvalidInputError(`Custom OAuth options are only supported for Google. Use: base44 auth social-login ${provider} ${action}`);
250829
- }
250830
- if (provider === "google" && !shouldEnable && hasCustomOAuth) {
250831
- throw new InvalidInputError("Custom OAuth options cannot be used with disable. To disable Google login: base44 auth social-login google disable");
250832
- }
250846
+ const useCustomOAuth = shouldEnable && hasOAuthOptions && providerInfo.customOAuth;
250833
250847
  let clientSecret;
250834
- if (provider === "google" && shouldEnable && hasCustomOAuth) {
250848
+ if (useCustomOAuth) {
250849
+ const oauth = providerInfo.customOAuth;
250835
250850
  clientSecret = await resolveSecret({
250836
250851
  flagValue: options.clientSecret,
250837
250852
  fromStdin: options.clientSecretStdin,
250838
- envVar: "BASE44_GOOGLE_CLIENT_SECRET",
250839
- promptMessage: "Enter Google OAuth client secret",
250853
+ envVar: oauth.envVar,
250854
+ promptMessage: oauth.promptMessage,
250840
250855
  isNonInteractive,
250841
250856
  name: "client secret",
250842
250857
  hints: [
250843
250858
  {
250844
- message: "Provide via flag: base44 auth social-login google enable --client-id <id> --client-secret <secret>",
250845
- command: "base44 auth social-login google enable --client-id <id> --client-secret <secret>"
250859
+ message: `Provide via flag: base44 auth social-login ${provider} enable --client-id <id> --client-secret <secret>`,
250860
+ command: `base44 auth social-login ${provider} enable --client-id <id> --client-secret <secret>`
250846
250861
  },
250847
250862
  {
250848
- message: "Provide via stdin: echo <secret> | base44 auth social-login google enable --client-id <id> --client-secret-stdin"
250863
+ message: `Provide via stdin: echo <secret> | base44 auth social-login ${provider} enable --client-id <id> --client-secret-stdin`
250849
250864
  },
250850
250865
  {
250851
- message: "Provide via env: BASE44_GOOGLE_CLIENT_SECRET=<secret> base44 auth social-login google enable --client-id <id>"
250866
+ message: `Provide via env: ${oauth.envVar}=<secret> base44 auth social-login ${provider} enable --client-id <id>`
250852
250867
  }
250853
250868
  ]
250854
250869
  });
@@ -250859,32 +250874,31 @@ async function socialLoginAction({ log, isNonInteractive }, provider, action, op
250859
250874
  ...current,
250860
250875
  [providerInfo.field]: shouldEnable
250861
250876
  };
250862
- if (provider === "google" && shouldEnable) {
250863
- if (hasCustomOAuth) {
250864
- merged.googleOAuthMode = "custom";
250865
- merged.googleOAuthClientId = options.clientId;
250877
+ if (providerInfo.customOAuth) {
250878
+ const oauth = providerInfo.customOAuth;
250879
+ if (useCustomOAuth) {
250880
+ merged[oauth.modeField] = "custom";
250881
+ merged[oauth.clientIdField] = options.clientId;
250866
250882
  } else {
250867
- merged.googleOAuthMode = "default";
250868
- merged.googleOAuthClientId = null;
250883
+ merged[oauth.modeField] = "default";
250884
+ merged[oauth.clientIdField] = null;
250869
250885
  }
250870
250886
  }
250871
- if (provider === "google" && !shouldEnable) {
250872
- merged.googleOAuthMode = "default";
250873
- merged.googleOAuthClientId = null;
250874
- }
250875
250887
  await writeAuthConfig(authDir, merged);
250876
250888
  return merged;
250877
250889
  });
250878
- if (clientSecret) {
250890
+ if (clientSecret && providerInfo.customOAuth) {
250879
250891
  await runTask("Saving client secret", async () => {
250880
- await setSecrets({ google_oauth_client_secret: clientSecret });
250892
+ await setSecrets({
250893
+ [providerInfo.customOAuth.secretKey]: clientSecret
250894
+ });
250881
250895
  });
250882
250896
  }
250883
250897
  if (!shouldEnable && !hasAnyLoginMethod(updated)) {
250884
250898
  log.warn(`Disabling ${providerInfo.label} login will leave no login methods enabled. Users will be locked out.`);
250885
250899
  }
250886
250900
  const newStatus = shouldEnable ? "enabled" : "disabled";
250887
- const oauthNote = provider === "google" && shouldEnable && hasCustomOAuth ? " with custom OAuth" : "";
250901
+ const oauthNote = useCustomOAuth ? " with custom OAuth" : "";
250888
250902
  return {
250889
250903
  outroMessage: `${providerInfo.label} login ${newStatus}${oauthNote} in local config. Run \`base44 auth push\` or \`base44 deploy\` to apply.`
250890
250904
  };
@@ -250893,7 +250907,7 @@ function getSocialLoginCommand() {
250893
250907
  return new Base44Command("social-login").description("Enable or disable social login providers (google, microsoft, facebook, apple)").addArgument(new Argument("<provider>", "social login provider").choices(VALID_PROVIDERS)).addArgument(new Argument("<action>", "enable or disable the provider").choices([
250894
250908
  "enable",
250895
250909
  "disable"
250896
- ])).option("--client-id <id>", "Google OAuth client ID (enables custom OAuth mode)").option("--client-secret <secret>", "Google OAuth client secret").option("--client-secret-stdin", "Read client secret from stdin").action(socialLoginAction);
250910
+ ])).option("--client-id <id>", "custom OAuth client ID (supported providers: google)").option("--client-secret <secret>", "custom OAuth client secret").option("--client-secret-stdin", "Read client secret from stdin").action(socialLoginAction);
250897
250911
  }
250898
250912
 
250899
250913
  // src/cli/commands/auth/index.ts
@@ -260298,4 +260312,4 @@ export {
260298
260312
  CLIExitError
260299
260313
  };
260300
260314
 
260301
- //# debugId=A0E7889E1966515264756E2164756E21
260315
+ //# debugId=EA3E6BF0602CEA7664756E2164756E21