@onexapis/cli 1.1.53 → 1.1.55

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.js CHANGED
@@ -1842,10 +1842,14 @@ async function getValidTokens() {
1842
1842
  }
1843
1843
  const data = await response.json();
1844
1844
  const body = data.statusCode ? data.body : data;
1845
+ if (!body.IdToken) {
1846
+ await clearAuthTokens();
1847
+ return null;
1848
+ }
1845
1849
  const refreshed = {
1846
1850
  ...tokens,
1847
1851
  accessToken: body.AccessToken || tokens.accessToken,
1848
- idToken: body.IdToken || tokens.idToken,
1852
+ idToken: body.IdToken,
1849
1853
  expiresAt: Math.floor(Date.now() / 1e3) + (body.ExpiresIn || 3600)
1850
1854
  };
1851
1855
  await saveAuthTokens(refreshed);
@@ -4752,6 +4756,18 @@ async function publishCommand(options) {
4752
4756
  process.exit(1);
4753
4757
  }
4754
4758
  logger.info(`Logged in as: ${tokens.user.email}`);
4759
+ try {
4760
+ const payload = JSON.parse(
4761
+ Buffer.from(tokens.idToken.split(".")[1], "base64").toString("utf-8")
4762
+ );
4763
+ logger.info(`[DEBUG] Token sub=${payload.sub}`);
4764
+ logger.info(`[DEBUG] Token company=${payload["custom:company_id"] || "(none)"}`);
4765
+ logger.info(`[DEBUG] Token exp=${new Date((payload.exp || 0) * 1e3).toISOString()}`);
4766
+ logger.info(`[DEBUG] Token iat=${new Date((payload.iat || 0) * 1e3).toISOString()}`);
4767
+ logger.info(`[DEBUG] API URL=${getApiUrl()}`);
4768
+ } catch {
4769
+ logger.info("[DEBUG] Could not decode token payload");
4770
+ }
4755
4771
  let themePath;
4756
4772
  if (options.theme) {
4757
4773
  themePath = path9__default.default.resolve(options.theme);
@@ -4820,10 +4836,14 @@ async function publishCommand(options) {
4820
4836
  );
4821
4837
  const regData = await regResponse.json();
4822
4838
  const regBody = regData.statusCode ? regData.body : regData;
4823
- if (!regResponse.ok && regBody.error && !regBody.error.includes("already registered")) {
4824
- logger.stopSpinner(false, "Registration failed");
4825
- logger.error(regBody.error);
4826
- process.exit(1);
4839
+ logger.info(`[DEBUG] Register status=${regResponse.status} body=${JSON.stringify(regBody).slice(0, 300)}`);
4840
+ if (!regResponse.ok) {
4841
+ const errMsg = regBody.error || regBody.message || "Registration failed";
4842
+ if (!errMsg.includes("already registered")) {
4843
+ logger.stopSpinner(false, "Registration failed");
4844
+ logger.error(errMsg);
4845
+ process.exit(1);
4846
+ }
4827
4847
  }
4828
4848
  logger.stopSpinner(true, regBody.message || "Theme registered");
4829
4849
  } catch (error) {