@togglhq/cli 1.6.10 → 1.6.12

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/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as CommanderError, t as createProgram } from "./program-Cl1_dH7S.js";
2
+ import { n as CommanderError, t as createProgram } from "./program-BKSFh_rd.js";
3
3
  //#region src/cli.ts
4
4
  try {
5
5
  await createProgram({ enableUpdateNotification: true }).parseAsync(process.argv);
package/build/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createProgram } from "./program-Cl1_dH7S.js";
1
+ import { t as createProgram } from "./program-BKSFh_rd.js";
2
2
  export { createProgram };
@@ -10616,7 +10616,7 @@ const PublicMeEntryRequestSchema = /* @__PURE__ */ object$2({
10616
10616
  ]))
10617
10617
  });
10618
10618
  //#endregion
10619
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/org/invitation/requests.mjs
10619
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/org/invitation/requests.mjs
10620
10620
  async function getInvitations(httpClient, signal) {
10621
10621
  return (await httpClient.get(`invitations`, { signal })).json();
10622
10622
  }
@@ -10633,7 +10633,7 @@ async function resendInvitation(httpClient, organization_id, organization_user_i
10633
10633
  return (await httpClient.post(`organizations/${organization_id}/invitations/${organization_user_id}/resend`, { signal })).json();
10634
10634
  }
10635
10635
  //#endregion
10636
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/org/utils/requests.mjs
10636
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/org/utils/requests.mjs
10637
10637
  function buildSearchParams$1(params, flattenArrays = false) {
10638
10638
  const searchParams = new URLSearchParams();
10639
10639
  Object.entries(params).forEach(([key, value]) => {
@@ -10645,7 +10645,7 @@ function buildSearchParams$1(params, flattenArrays = false) {
10645
10645
  return searchParams;
10646
10646
  }
10647
10647
  //#endregion
10648
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/org/organization-user/requests.mjs
10648
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/org/organization-user/requests.mjs
10649
10649
  async function getOrganizationUser(httpClient, organization_id, organization_user_id, signal) {
10650
10650
  return (await httpClient.get(`organizations/${organization_id}/users/${organization_user_id}`, { signal })).json();
10651
10651
  }
@@ -10659,7 +10659,7 @@ async function patchOrganizationUserActive(httpClient, organization_id, organiza
10659
10659
  return (await httpClient.patch(`organizations/${organization_id}/users/${organization_user_id}/active_status/${status}`, { signal })).json();
10660
10660
  }
10661
10661
  //#endregion
10662
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/org/workspace/requests.mjs
10662
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/org/workspace/requests.mjs
10663
10663
  async function getWorkspaces(httpClient, organization_id, signal) {
10664
10664
  return (await httpClient.get(`organizations/${organization_id}/workspaces`, { signal })).json();
10665
10665
  }
@@ -10679,7 +10679,7 @@ const WorkingHoursUpdateInputSchema = /* @__PURE__ */ object$2({
10679
10679
  });
10680
10680
  const StatusOKSchema = /* @__PURE__ */ object$2({ status: /* @__PURE__ */ string$1() });
10681
10681
  //#endregion
10682
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/shared-data/utils/requests.mjs
10682
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/shared-data/utils/requests.mjs
10683
10683
  const META_SYMBOL = Symbol.for("querygen:response:meta");
10684
10684
  function withResponseMeta(data, headers, status) {
10685
10685
  if (!data) return data;
@@ -10706,7 +10706,7 @@ function buildSearchParams(params, flattenArrays = false) {
10706
10706
  return searchParams;
10707
10707
  }
10708
10708
  //#endregion
10709
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/shared-data/public-holidays/requests.mjs
10709
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/shared-data/public-holidays/requests.mjs
10710
10710
  async function getPublicHolidays(httpClient, year, { country, organization_id } = {}, signal) {
10711
10711
  const response = await httpClient.get(`shared_data/api/publicholidays/${year}`, {
10712
10712
  signal,
@@ -10718,12 +10718,12 @@ async function getPublicHolidays(httpClient, year, { country, organization_id }
10718
10718
  return withResponseMeta(await response.json(), response.headers, response.status);
10719
10719
  }
10720
10720
  //#endregion
10721
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/shared-data/status/requests.mjs
10721
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/shared-data/status/requests.mjs
10722
10722
  async function getStatus(httpClient, signal) {
10723
10723
  return (await httpClient.get(`shared_data/api/status`, { signal })).json();
10724
10724
  }
10725
10725
  //#endregion
10726
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/org/timeoff/requests.mjs
10726
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/org/timeoff/requests.mjs
10727
10727
  async function timeoffListMyEntries(httpClient, organization_id, { from, to }, signal) {
10728
10728
  return (await httpClient.get(`timeoff/organizations/${organization_id}/me`, {
10729
10729
  signal,
@@ -10751,7 +10751,7 @@ async function timeoffDeleteMyEntry(httpClient, organization_id, id, signal) {
10751
10751
  return response.json();
10752
10752
  }
10753
10753
  //#endregion
10754
- //#region ../../node_modules/.pnpm/@toggl+queries@2.1.164_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_77656fe242eb74c7cd228bfcb8dd35f3/node_modules/@toggl/queries/dist/shared-data/working-hours/requests.mjs
10754
+ //#region ../../node_modules/.pnpm/@toggl+queries@2.1.166_@tanstack+react-query@5.99.0_react@19.2.5__@toggl+sync@0.2.4_rea_b9ef901081a7cec6604674123c2e8f01/node_modules/@toggl/queries/dist/shared-data/working-hours/requests.mjs
10755
10755
  async function getMyWorkingHours(httpClient, organization_id, signal) {
10756
10756
  return (await httpClient.get(`shared_data/api/workinghours/${organization_id}/me`, { signal })).json();
10757
10757
  }
@@ -11730,6 +11730,10 @@ function openAuthBrowser(url) {
11730
11730
  });
11731
11731
  }
11732
11732
  const TOGGL_OAUTH_CLIENT_ID = "000000";
11733
+ /** Production accounts-be client for hosted `/focus/cli/auth-code` redirects. */
11734
+ const TOGGL_OAUTH_MANUAL_CLIENT_ID = "2ca88f39-18c5-4686-9101-3d3b7bd24470";
11735
+ /** Staging accounts-be client for hosted `/focus/cli/auth-code` redirects. */
11736
+ const TOGGL_OAUTH_MANUAL_STAGING_CLIENT_ID = "88972024-c0b3-46d1-8191-e48fb876434c";
11733
11737
  const TOGGL_OAUTH_CALLBACK_PORT = 8716;
11734
11738
  const TOGGL_OAUTH_LOGIN_TIMEOUT_MS = 12e4;
11735
11739
  const TOGGL_OAUTH_MANUAL_CALLBACK_PATH = "/focus/cli/auth-code";
@@ -11743,6 +11747,16 @@ function togglOAuthRedirectUri(port = TOGGL_OAUTH_CALLBACK_PORT) {
11743
11747
  function togglOAuthManualRedirectUri(accountsApiUrl) {
11744
11748
  return `${accountsApiUrl.replace(/\/$/, "")}${TOGGL_OAUTH_MANUAL_CALLBACK_PATH}`;
11745
11749
  }
11750
+ /**
11751
+ * Localhost CLI login keeps the test client (`000000`, domain `http://localhost`).
11752
+ * Manual/headless login uses dedicated first-party clients whose domain prefixes
11753
+ * match the hosted auth-code page. Do not send `000000` with a hosted redirect.
11754
+ */
11755
+ function resolveTogglOAuthClientId(flowMode, accountsApiUrl) {
11756
+ if (flowMode !== "manual") return TOGGL_OAUTH_CLIENT_ID;
11757
+ if (accountsApiUrl.replace(/\/$/, "") === "https://accounts.toggl.space") return TOGGL_OAUTH_MANUAL_STAGING_CLIENT_ID;
11758
+ return TOGGL_OAUTH_MANUAL_CLIENT_ID;
11759
+ }
11746
11760
  const BACKGROUND_DARK_SVG = `<svg width="1440" height="900" viewBox="0 0 1440 900" fill="none" xmlns="http://www.w3.org/2000/svg">
11747
11761
  <g clip-path="url(#clip0_11555_363)">
11748
11762
  <g clip-path="url(#clip1_11555_363)">
@@ -12091,12 +12105,12 @@ function waitForOAuthCallback(port = TOGGL_OAUTH_CALLBACK_PORT, timeoutMs = TOGG
12091
12105
  });
12092
12106
  });
12093
12107
  }
12094
- async function exchangeAuthorizationCode(accountsApiUrl, code, verifier, redirectUri = togglOAuthRedirectUri()) {
12108
+ async function exchangeAuthorizationCode(accountsApiUrl, code, verifier, redirectUri = togglOAuthRedirectUri(), clientId = TOGGL_OAUTH_CLIENT_ID) {
12095
12109
  const params = new URLSearchParams({
12096
12110
  grant_type: "authorization_code",
12097
12111
  code,
12098
12112
  code_verifier: verifier,
12099
- client_id: TOGGL_OAUTH_CLIENT_ID,
12113
+ client_id: clientId,
12100
12114
  redirect_uri: redirectUri
12101
12115
  });
12102
12116
  const response = await fetch(`${accountsApiUrl}/api/oauth/token?${params}`, { method: "POST" });
@@ -12133,7 +12147,7 @@ function resolveTogglOAuthFlowMode(options) {
12133
12147
  }
12134
12148
  function buildTogglOAuthAuthorizationUrl(options) {
12135
12149
  return `${options.accountsApiUrl.replace(/\/$/, "")}/focus/login/?${new URLSearchParams({
12136
- client_id: TOGGL_OAUTH_CLIENT_ID,
12150
+ client_id: resolveTogglOAuthClientId(options.flowMode, options.accountsApiUrl),
12137
12151
  code_challenge: options.codeChallenge,
12138
12152
  code_challenge_method: "S256",
12139
12153
  redirect_uri: options.redirectUri,
@@ -12149,6 +12163,7 @@ async function obtainTogglOAuthAuthorizationCode(options) {
12149
12163
  authorizationCode: options.authorizationCode
12150
12164
  });
12151
12165
  const redirectUri = resolveTogglOAuthRedirectUri(options.accountsApiUrl, flowMode);
12166
+ const clientId = resolveTogglOAuthClientId(flowMode, options.accountsApiUrl);
12152
12167
  const { verifier, challenge } = generateOAuthPKCE();
12153
12168
  const authUrl = buildTogglOAuthAuthorizationUrl({
12154
12169
  accountsApiUrl: options.accountsApiUrl,
@@ -12186,6 +12201,7 @@ async function obtainTogglOAuthAuthorizationCode(options) {
12186
12201
  code,
12187
12202
  verifier,
12188
12203
  redirectUri,
12204
+ clientId,
12189
12205
  flowMode
12190
12206
  };
12191
12207
  }
@@ -12251,7 +12267,7 @@ async function runCliAuthFlow(options = {}) {
12251
12267
  const focusApiUrl = options.focusApiUrl ?? "https://focus.toggl.com";
12252
12268
  const explicitProfileName = options.profileName;
12253
12269
  log("Toggl CLI — Authentication\n");
12254
- const { code, verifier, redirectUri } = await obtainTogglOAuthAuthorizationCode({
12270
+ const { code, verifier, redirectUri, clientId } = await obtainTogglOAuthAuthorizationCode({
12255
12271
  accountsApiUrl,
12256
12272
  flowMode: options.oauthFlowMode ?? (options.manualPrompt ? "manual" : "local"),
12257
12273
  authorizationCode: options.authorizationCode,
@@ -12259,7 +12275,7 @@ async function runCliAuthFlow(options = {}) {
12259
12275
  log
12260
12276
  });
12261
12277
  log("Exchanging authorization code...");
12262
- const tokens = await exchangeAuthorizationCode(accountsApiUrl, code, verifier, redirectUri);
12278
+ const tokens = await exchangeAuthorizationCode(accountsApiUrl, code, verifier, redirectUri, clientId);
12263
12279
  log("Fetching account info...");
12264
12280
  const user = await fetchAccountsApiMe(accountsApiUrl, tokens.access_token);
12265
12281
  if (!user.user_account_id) throw new Error("Could not determine user ID from API response.");
@@ -12281,6 +12297,7 @@ async function runCliAuthFlow(options = {}) {
12281
12297
  focus_api_url: focusApiUrl,
12282
12298
  accounts_api_url: accountsApiUrl,
12283
12299
  authenticated_at: (/* @__PURE__ */ new Date()).toISOString(),
12300
+ oauth_client_id: clientId,
12284
12301
  workspaces
12285
12302
  };
12286
12303
  const profileName = explicitProfileName ?? (options.deriveProfileName ?? deriveCliProfileName)({
@@ -12308,11 +12325,11 @@ const PUBLIC_CLI_PACKAGE_SPEC = `${PUBLIC_CLI_PACKAGE_NAME}@latest`;
12308
12325
  function npxMcpAuthCommand() {
12309
12326
  return `npx ${PUBLIC_MCP_PACKAGE_NAME} auth`;
12310
12327
  }
12311
- async function refreshTokens(accountsApiUrl, refreshToken) {
12328
+ async function refreshTokens(accountsApiUrl, refreshToken, clientId = TOGGL_OAUTH_CLIENT_ID) {
12312
12329
  const params = new URLSearchParams({
12313
12330
  grant_type: "refresh_token",
12314
12331
  refresh_token: refreshToken,
12315
- client_id: TOGGL_OAUTH_CLIENT_ID
12332
+ client_id: clientId
12316
12333
  });
12317
12334
  const response = await fetch(`${accountsApiUrl}/api/oauth/token?${params}`, { method: "POST" });
12318
12335
  if (!response.ok) {
@@ -12326,7 +12343,7 @@ async function getValidToken(scope = "cli", profile) {
12326
12343
  if (!authConfig) throw new Error(scope === "cli" ? "Not authenticated. Run `toggl auth` to sign in." : `Not authenticated. Run \`${npxMcpAuthCommand()}\` to sign in.`);
12327
12344
  const now = Date.now() / 1e3;
12328
12345
  if (authConfig.expires_at > now + 60) return authConfig.access_token;
12329
- const tokens = await refreshTokens(authConfig.accounts_api_url, authConfig.refresh_token);
12346
+ const tokens = await refreshTokens(authConfig.accounts_api_url, authConfig.refresh_token, authConfig.oauth_client_id ?? "000000");
12330
12347
  authConfig.access_token = tokens.access_token;
12331
12348
  authConfig.refresh_token = tokens.refresh_token;
12332
12349
  authConfig.expires_at = now + tokens.expires_in;
@@ -25080,4 +25097,4 @@ Common commands:
25080
25097
  //#endregion
25081
25098
  export { CommanderError as n, createProgram as t };
25082
25099
 
25083
- //# sourceMappingURL=program-Cl1_dH7S.js.map
25100
+ //# sourceMappingURL=program-BKSFh_rd.js.map
package/build/program.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createProgram } from "./program-Cl1_dH7S.js";
1
+ import { t as createProgram } from "./program-BKSFh_rd.js";
2
2
  export { createProgram };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@togglhq/cli",
3
- "version": "1.6.10",
3
+ "version": "1.6.12",
4
4
  "description": "Toggl CLI for Toggl 2.0 API operations.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -55,7 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@toggl/cli-core": "workspace:^",
57
57
  "@toggl/operations": "workspace:^",
58
- "@toggl/queries": "2.1.164",
58
+ "@toggl/queries": "2.1.166",
59
59
  "@types/node": "22.19.11",
60
60
  "tsdown": "0.21.8",
61
61
  "typescript": "5.9.3",