@gscdump/cli 5.4.0 → 5.6.0

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.
@@ -3,7 +3,7 @@ import { clearAuthentication, formatHostedSync, getHostedAccount, noSitesNextSte
3
3
  import { authCommandMeta } from "../command-meta.mjs";
4
4
  import { loadConfig, saveConfig } from "../config.mjs";
5
5
  import { OUTPUT_ARGS, applyOutputMode, logger } from "../utils.mjs";
6
- import { ACCESS_NOT_SET_UP, clearTokens, formatAuthProvenance, getAuth, loadServiceAccount, loadTokens, resolveBYOK, saveTokens } from "../auth.mjs";
6
+ import { ACCESS_NOT_SET_UP, clearTokens, formatAuthProvenance, getAuth, isStaleServiceAccountPointer, loadServiceAccount, loadTokens, resolveBYOK, resolveServiceAccount, saveTokens } from "../auth.mjs";
7
7
  import { missingRequiredScopes } from "../auth-scopes.mjs";
8
8
  import { clearBingCredentials, getBingClient, inspectBingCredentials } from "../bing-auth.mjs";
9
9
  import { loginWithHostedSession } from "../hosted-auth.mjs";
@@ -92,8 +92,9 @@ async function loginHosted(args) {
92
92
  }
93
93
  async function resolveLiveAuthState() {
94
94
  const tokens = await loadTokens();
95
- const byok = resolveBYOK();
96
- const source = byok ?? (tokens ? await getAuth({ interactive: false }).catch((error) => error instanceof Error ? error : new Error(String(error))) : null);
95
+ const serviceAccount = await resolveServiceAccount().catch((error) => isStaleServiceAccountPointer(error) ? null : error instanceof Error ? error : new Error(String(error)));
96
+ const byok = serviceAccount ? null : resolveBYOK();
97
+ const source = serviceAccount ?? byok ?? (tokens ? await getAuth({ interactive: false }).catch((error) => error instanceof Error ? error : new Error(String(error))) : null);
97
98
  const current = source === null ? null : source instanceof Error ? {
98
99
  kind: "failed",
99
100
  detail: redactTokens(source.message)
@@ -105,6 +106,7 @@ async function resolveLiveAuthState() {
105
106
  const scopes = tokenInfo?.scope ? tokenInfo.scope.split(/\s+/).filter(Boolean) : [];
106
107
  const missing = missingRequiredScopes(scopes);
107
108
  return {
109
+ serviceAccount,
108
110
  byok,
109
111
  tokens: tokens && !byok ? await loadTokens() : tokens,
110
112
  liveToken,
@@ -170,7 +172,7 @@ async function runStatus(args) {
170
172
  }
171
173
  return;
172
174
  }
173
- const { byok, tokens, tokenInfo, failure, scopes, missing } = await resolveLiveAuthState();
175
+ const { serviceAccount, byok, tokens, tokenInfo, failure, scopes, missing } = await resolveLiveAuthState();
174
176
  const googleAuthenticated = tokenInfo !== null;
175
177
  const bingCredentials = await inspectBingCredentials();
176
178
  const bingResult = bingCredentials._tag === "Missing" ? null : await getBingClient().then((client) => client.getUserSites({ signal: AbortSignal.timeout(1e4) })).catch(() => null);
@@ -187,7 +189,7 @@ async function runStatus(args) {
187
189
  googleAuthenticated,
188
190
  googleError: failure,
189
191
  bing,
190
- source: byok ? "env" : tokens ? "saved-tokens" : null,
192
+ source: serviceAccount ? "service-account" : byok ? "env" : tokens ? "saved-tokens" : null,
191
193
  envCredential: byokKind,
192
194
  scopes,
193
195
  tokenAccount: tokenInfo?.email ?? null,
@@ -212,6 +214,13 @@ async function runStatus(args) {
212
214
  console.log(` \x1B[90mRun \`gscdump auth login --force\` to re-consent.\x1B[0m`);
213
215
  }
214
216
  };
217
+ if (serviceAccount) {
218
+ if (googleAuthenticated) logger.success("Authenticated (service account)");
219
+ else logger.warn(`Service-account credentials failed verification: ${failure}`);
220
+ if (tokenInfo?.email) console.log(` Account: ${tokenInfo.email}`);
221
+ reportScopes();
222
+ return;
223
+ }
215
224
  if (byok) {
216
225
  if (googleAuthenticated) logger.success(`Authenticated with environment credentials (${byokKind})`);
217
226
  else logger.warn(`Environment credentials (${byokKind}) failed verification: ${failure}`);
package/dist/package.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var version = "5.4.0";
1
+ var version = "5.6.0";
2
2
  export { version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/cli",
3
3
  "type": "module",
4
- "version": "5.4.0",
4
+ "version": "5.6.0",
5
5
  "description": "CLI for Google Search Console and Bing with hosted or local authentication, data exports, and an MCP server",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -44,16 +44,16 @@
44
44
  "dependencies": {
45
45
  "@clack/prompts": "^1.8.1",
46
46
  "@duckdb/node-api": "1.5.5-r.5",
47
- "@gscdump/analysis": "^5.3.0",
48
- "@gscdump/contracts": "^5.3.0",
49
- "@gscdump/engine": "^5.3.0",
50
- "@gscdump/engine-gsc-api": "^5.3.0",
51
- "@gscdump/sdk": "^5.3.1",
47
+ "@gscdump/analysis": "^5.6.0",
48
+ "@gscdump/contracts": "^5.6.0",
49
+ "@gscdump/engine": "^5.6.0",
50
+ "@gscdump/engine-gsc-api": "^5.6.0",
51
+ "@gscdump/sdk": "^5.6.0",
52
52
  "@modelcontextprotocol/sdk": "^1.30.1",
53
53
  "citty": "^0.2.2",
54
54
  "consola": "^3.4.2",
55
55
  "google-auth-library": "^11.1.0",
56
- "gscdump": "^5.3.1",
56
+ "gscdump": "^5.6.0",
57
57
  "ofetch": "^1.5.1",
58
58
  "open": "^11.0.4",
59
59
  "proper-lockfile": "^4.1.2",