@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.mjs CHANGED
@@ -1799,10 +1799,14 @@ async function getValidTokens() {
1799
1799
  }
1800
1800
  const data = await response.json();
1801
1801
  const body = data.statusCode ? data.body : data;
1802
+ if (!body.IdToken) {
1803
+ await clearAuthTokens();
1804
+ return null;
1805
+ }
1802
1806
  const refreshed = {
1803
1807
  ...tokens,
1804
1808
  accessToken: body.AccessToken || tokens.accessToken,
1805
- idToken: body.IdToken || tokens.idToken,
1809
+ idToken: body.IdToken,
1806
1810
  expiresAt: Math.floor(Date.now() / 1e3) + (body.ExpiresIn || 3600)
1807
1811
  };
1808
1812
  await saveAuthTokens(refreshed);
@@ -4709,6 +4713,18 @@ async function publishCommand(options) {
4709
4713
  process.exit(1);
4710
4714
  }
4711
4715
  logger.info(`Logged in as: ${tokens.user.email}`);
4716
+ try {
4717
+ const payload = JSON.parse(
4718
+ Buffer.from(tokens.idToken.split(".")[1], "base64").toString("utf-8")
4719
+ );
4720
+ logger.info(`[DEBUG] Token sub=${payload.sub}`);
4721
+ logger.info(`[DEBUG] Token company=${payload["custom:company_id"] || "(none)"}`);
4722
+ logger.info(`[DEBUG] Token exp=${new Date((payload.exp || 0) * 1e3).toISOString()}`);
4723
+ logger.info(`[DEBUG] Token iat=${new Date((payload.iat || 0) * 1e3).toISOString()}`);
4724
+ logger.info(`[DEBUG] API URL=${getApiUrl()}`);
4725
+ } catch {
4726
+ logger.info("[DEBUG] Could not decode token payload");
4727
+ }
4712
4728
  let themePath;
4713
4729
  if (options.theme) {
4714
4730
  themePath = path9.resolve(options.theme);
@@ -4777,10 +4793,14 @@ async function publishCommand(options) {
4777
4793
  );
4778
4794
  const regData = await regResponse.json();
4779
4795
  const regBody = regData.statusCode ? regData.body : regData;
4780
- if (!regResponse.ok && regBody.error && !regBody.error.includes("already registered")) {
4781
- logger.stopSpinner(false, "Registration failed");
4782
- logger.error(regBody.error);
4783
- process.exit(1);
4796
+ logger.info(`[DEBUG] Register status=${regResponse.status} body=${JSON.stringify(regBody).slice(0, 300)}`);
4797
+ if (!regResponse.ok) {
4798
+ const errMsg = regBody.error || regBody.message || "Registration failed";
4799
+ if (!errMsg.includes("already registered")) {
4800
+ logger.stopSpinner(false, "Registration failed");
4801
+ logger.error(errMsg);
4802
+ process.exit(1);
4803
+ }
4784
4804
  }
4785
4805
  logger.stopSpinner(true, regBody.message || "Theme registered");
4786
4806
  } catch (error) {