seo 0.2.39 → 0.2.40

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/index.d.ts CHANGED
@@ -22,13 +22,13 @@ declare const providerCapabilitySchema: z.ZodEnum<{
22
22
  "ranked-keywords": "ranked-keywords";
23
23
  "serp-competitors": "serp-competitors";
24
24
  "keyword-metrics": "keyword-metrics";
25
- "relevant-pages": "relevant-pages";
25
+ "local-search": "local-search";
26
+ "serp-snapshot": "serp-snapshot";
26
27
  "keyword-discovery": "keyword-discovery";
28
+ "relevant-pages": "relevant-pages";
27
29
  "link-summary": "link-summary";
28
30
  "referring-domains": "referring-domains";
29
31
  backlinks: "backlinks";
30
- "serp-snapshot": "serp-snapshot";
31
- "local-search": "local-search";
32
32
  "ai-mentions": "ai-mentions";
33
33
  "ai-prompt-observation": "ai-prompt-observation";
34
34
  }>;
@@ -6091,12 +6091,12 @@ declare const providerPackageNameSchema: z.ZodString;
6091
6091
  declare const providerExactVersionSchema: z.ZodString;
6092
6092
  declare const providerIntegritySchema: z.ZodString;
6093
6093
  declare const providerKindSchema: z.ZodEnum<{
6094
- "local-search": "local-search";
6095
6094
  "traffic-analytics": "traffic-analytics";
6096
6095
  "search-results": "search-results";
6097
6096
  "keyword-data": "keyword-data";
6098
6097
  "domain-data": "domain-data";
6099
6098
  "link-data": "link-data";
6099
+ "local-search": "local-search";
6100
6100
  "ai-data": "ai-data";
6101
6101
  other: "other";
6102
6102
  }>;
@@ -6139,12 +6139,12 @@ declare const providerRegistrationSchema: z.ZodObject<{
6139
6139
  displayName: z.ZodString;
6140
6140
  description: z.ZodString;
6141
6141
  kinds: z.ZodArray<z.ZodEnum<{
6142
- "local-search": "local-search";
6143
6142
  "traffic-analytics": "traffic-analytics";
6144
6143
  "search-results": "search-results";
6145
6144
  "keyword-data": "keyword-data";
6146
6145
  "domain-data": "domain-data";
6147
6146
  "link-data": "link-data";
6147
+ "local-search": "local-search";
6148
6148
  "ai-data": "ai-data";
6149
6149
  other: "other";
6150
6150
  }>>;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __seoCreateRequire } from 'node:module'; const require = __seoCreateRequire(import.meta.url);
2
- import { n as version, t as load } from "./esm-B7pkHZCI.js";
2
+ import { n as version, t as load } from "./esm-CvQ3n1rk.js";
3
3
  import { SEO_PROVIDER_API_VERSION } from "./provider-sdk.js";
4
4
  import crypto, { createHash, randomBytes, randomUUID, sign } from "node:crypto";
5
5
  import { chmodSync, createReadStream, createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -6905,10 +6905,15 @@ function callbackCopy(options) {
6905
6905
  heading: "Google account connected.",
6906
6906
  detail: "This tab can be closed."
6907
6907
  };
6908
+ if (options.status === "cancelled") return {
6909
+ title: "Google sign-in cancelled",
6910
+ heading: "Google sign-in was cancelled.",
6911
+ detail: "No account was connected. Return to your terminal when you are ready."
6912
+ };
6908
6913
  if (options.status === "permissions-missing") return {
6909
- title: "Google permissions not granted",
6910
- heading: "Google permissions were not granted.",
6911
- detail: `Return to your terminal and run seo auth login again. Select all permission boxes for ${options.missing.join(" and ")}.`
6914
+ title: "Google permissions not selected",
6915
+ heading: "Required Google permissions were not selected.",
6916
+ detail: `The login needs read-only access for ${options.missing.join(" and ")}. Return to your terminal and run seo auth login again. On Google's permissions screen, choose Select all, then continue.`
6912
6917
  };
6913
6918
  return {
6914
6919
  title: "Google connection failed",
@@ -6934,10 +6939,18 @@ function oauthCallbackPage(options = { status: "connected" }) {
6934
6939
  }
6935
6940
  //#endregion
6936
6941
  //#region packages/core/src/gsc/auth/loopback-callback.ts
6942
+ const OAUTH_CALLBACK_TIMEOUT_MS = 3e5;
6943
+ function timeoutError() {
6944
+ return new SeoError("AUTH_REQUIRED", "Google sign-in timed out. No account was connected. Run `seo auth login` again and finish the browser steps within five minutes. Keep the terminal open while you sign in.");
6945
+ }
6946
+ function callbackError(error) {
6947
+ if (error === "access_denied") return new SeoError("ACCESS_DENIED", "Google sign-in was cancelled. No account was connected. Run `seo auth login` again when you are ready.");
6948
+ return new SeoError("AUTH_REQUIRED", "Google sign-in could not finish. No account was connected. Run `seo auth login` again.");
6949
+ }
6937
6950
  function waitForCode(input) {
6938
6951
  return new Promise((resolve, reject) => {
6939
6952
  const callbackPath = new URL(input.redirectUri).pathname;
6940
- const timer = setTimeout(() => reject(/* @__PURE__ */ new Error("OAuth flow timed out after 5 minutes.")), 3e5);
6953
+ const timer = setTimeout(() => reject(timeoutError()), input.timeoutMs ?? OAUTH_CALLBACK_TIMEOUT_MS);
6941
6954
  input.server.on("request", (req, res) => {
6942
6955
  try {
6943
6956
  const reqUrl = new URL(req.url ?? "/", input.redirectUri);
@@ -6952,7 +6965,13 @@ function waitForCode(input) {
6952
6965
  return;
6953
6966
  }
6954
6967
  const error = reqUrl.searchParams.get("error");
6955
- if (error) throw new Error(`OAuth error: ${error}`);
6968
+ if (error) {
6969
+ res.writeHead(400, { "content-type": "text/html; charset=utf-8" });
6970
+ res.end(oauthCallbackPage({ status: error === "access_denied" ? "cancelled" : "failed" }));
6971
+ clearTimeout(timer);
6972
+ reject(callbackError(error));
6973
+ return;
6974
+ }
6956
6975
  const incomingCode = reqUrl.searchParams.get("code");
6957
6976
  if (!incomingCode) throw new Error("OAuth code missing.");
6958
6977
  let responded = false;
@@ -7043,7 +7062,7 @@ async function loginWithLoopback(clientConfig = getClientConfig()) {
7043
7062
  status: "permissions-missing",
7044
7063
  missing: labels
7045
7064
  }));
7046
- throw new SeoError("ACCESS_DENIED", `Google login did not grant ${labels.join(" and ")} read-only access. Run \`seo auth login\` again, choose Select all, and approve both permission boxes.`);
7065
+ throw new SeoError("ACCESS_DENIED", `Google sign-in finished without the required read-only access for ${labels.join(" and ")}. No account was saved. Run \`seo auth login\` again. On Google's permissions screen, choose Select all, then continue.`);
7047
7066
  }
7048
7067
  const accountEmail = decodeJwtEmail(tokenJson.id_token) ?? await fetchUserEmail(tokenJson.access_token);
7049
7068
  if (!accountEmail) throw new Error("Google login succeeded but account email could not be determined.");