gogcli-mcp-drive 4.4.0 → 4.5.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.
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "metadata": {
9
9
  "description": "Extended Google Drive for Claude via gogcli — auth + full Drive support (upload, download, permissions, comments, shared drives)",
10
- "version": "4.4.0"
10
+ "version": "4.5.0"
11
11
  },
12
12
  "plugins": [
13
13
  {
@@ -15,7 +15,7 @@
15
15
  "displayName": "gogcli (Drive)",
16
16
  "source": "./",
17
17
  "description": "Extended Google Drive for Claude via gogcli — auth + full Drive support (upload, download, permissions, comments, shared drives)",
18
- "version": "4.4.0",
18
+ "version": "4.5.0",
19
19
  "author": {
20
20
  "name": "Chris Hall"
21
21
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gogcli-mcp-drive",
3
3
  "displayName": "gogcli (Drive)",
4
- "version": "4.4.0",
4
+ "version": "4.5.0",
5
5
  "description": "Extended Google Drive for Claude via gogcli — auth + full Drive support (upload, download, permissions, comments, shared drives)",
6
6
  "author": {
7
7
  "name": "Chris Hall",
package/dist/index.js CHANGED
@@ -34554,10 +34554,8 @@ function errorResult(message) {
34554
34554
 
34555
34555
  // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34556
34556
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
34557
- var DEFAULT_REQUEST_KEY = "confirmation";
34558
- var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34559
- var UNSUPPORTED_NOTE = "Nothing was done because this client cannot show a confirmation prompt (it declares no MCP elicitation capability), and this action is never taken without one";
34560
- var STATE_PREFIX = "mcpu.confirm.v1.";
34557
+
34558
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/canonical.js
34561
34559
  function canonicalJson(value) {
34562
34560
  if (value === null || typeof value === "string" || typeof value === "boolean")
34563
34561
  return JSON.stringify(value);
@@ -34568,7 +34566,7 @@ function canonicalJson(value) {
34568
34566
  if (typeof value === "bigint")
34569
34567
  return `{"$bigint":"${value.toString()}"}`;
34570
34568
  if (typeof value === "function" || typeof value === "symbol") {
34571
- throw new TypeError(`requireConfirmation: cannot bind a ${typeof value} argument value.`);
34569
+ throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
34572
34570
  }
34573
34571
  if (Array.isArray(value))
34574
34572
  return `[${value.map(canonicalJson).join(",")}]`;
@@ -34590,7 +34588,7 @@ function canonicalJson(value) {
34590
34588
  }
34591
34589
  const proto = Object.getPrototypeOf(value);
34592
34590
  if (proto !== Object.prototype && proto !== null) {
34593
- throw new TypeError("requireConfirmation: cannot bind a non-plain object argument value (class instance).");
34591
+ throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
34594
34592
  }
34595
34593
  const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
34596
34594
  return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
@@ -34598,6 +34596,12 @@ function canonicalJson(value) {
34598
34596
  function escapeKey(key) {
34599
34597
  return key.startsWith("$") ? `$${key}` : key;
34600
34598
  }
34599
+
34600
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34601
+ var DEFAULT_REQUEST_KEY = "confirmation";
34602
+ var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34603
+ var UNSUPPORTED_NOTE = "Nothing was done because this client cannot show a confirmation prompt (it declares no MCP elicitation capability), and this action is never taken without one";
34604
+ var STATE_PREFIX = "mcpu.confirm.v1.";
34601
34605
  function bindingKey(binding) {
34602
34606
  if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
34603
34607
  throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
@@ -34700,6 +34704,264 @@ ${JSON.stringify(preview, null, 2)}`,
34700
34704
  });
34701
34705
  }
34702
34706
 
34707
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
34708
+ import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
34709
+ function createSpentTokenStore() {
34710
+ const spent2 = /* @__PURE__ */ new Map();
34711
+ return {
34712
+ has: (nonce) => spent2.has(nonce),
34713
+ add: (nonce, exp) => {
34714
+ spent2.set(nonce, exp);
34715
+ },
34716
+ prune: (now) => {
34717
+ for (const [nonce, exp] of spent2)
34718
+ if (exp < now)
34719
+ spent2.delete(nonce);
34720
+ },
34721
+ clear: () => spent2.clear(),
34722
+ get size() {
34723
+ return spent2.size;
34724
+ }
34725
+ };
34726
+ }
34727
+ var PROCESS_SPENT = createSpentTokenStore();
34728
+ var PREFIX = "mcpu.token.v1.";
34729
+ var DEFAULT_TTL_SECONDS = 600;
34730
+ function tokenKey(key) {
34731
+ const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
34732
+ if (bytes.length < 32)
34733
+ throw new RangeError("confirm token: key must be at least 32 bytes.");
34734
+ return bytes;
34735
+ }
34736
+ function ttlOf(ttlSeconds) {
34737
+ if (ttlSeconds === void 0)
34738
+ return DEFAULT_TTL_SECONDS;
34739
+ if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
34740
+ throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
34741
+ }
34742
+ return ttlSeconds;
34743
+ }
34744
+ function sign(key, body) {
34745
+ return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
34746
+ }
34747
+ function hashConfirmPayload(payload) {
34748
+ return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
34749
+ }
34750
+ function issueConfirmToken(key, binding, options = {}) {
34751
+ const k = tokenKey(key);
34752
+ const now = options.now ?? Date.now();
34753
+ const exp = now + ttlOf(options.ttlSeconds) * 1e3;
34754
+ const claims = {
34755
+ t: binding.tool,
34756
+ ...binding.account === void 0 ? {} : { a: binding.account },
34757
+ g: binding.target,
34758
+ ...binding.revision === void 0 ? {} : { r: binding.revision },
34759
+ h: binding.payloadHash,
34760
+ exp,
34761
+ n: randomBytes(16).toString("base64url")
34762
+ };
34763
+ const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
34764
+ return { token: `${PREFIX}${body}.${sign(k, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
34765
+ }
34766
+ function parseClaims(body) {
34767
+ try {
34768
+ const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34769
+ return claims && typeof claims === "object" ? claims : void 0;
34770
+ } catch {
34771
+ return void 0;
34772
+ }
34773
+ }
34774
+ function verifyConfirmToken(key, token, binding, options = {}) {
34775
+ const k = tokenKey(key);
34776
+ const now = options.now ?? Date.now();
34777
+ const spent2 = options.spent ?? PROCESS_SPENT;
34778
+ spent2.prune(now);
34779
+ if (!token.startsWith(PREFIX))
34780
+ return { ok: false, error: "TOKEN_INVALID" };
34781
+ const rest = token.slice(PREFIX.length);
34782
+ const dot = rest.indexOf(".");
34783
+ const body = dot < 0 ? "" : rest.slice(0, dot);
34784
+ const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
34785
+ const expected = sign(k, body);
34786
+ if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
34787
+ return { ok: false, error: "TOKEN_INVALID" };
34788
+ const claims = parseClaims(body);
34789
+ if (!claims)
34790
+ return { ok: false, error: "TOKEN_INVALID" };
34791
+ if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
34792
+ return { ok: false, error: "TOKEN_INVALID" };
34793
+ }
34794
+ if (spent2.has(claims.n))
34795
+ return { ok: false, error: "TOKEN_REUSED" };
34796
+ if (now > claims.exp)
34797
+ return { ok: false, error: "TOKEN_EXPIRED" };
34798
+ if (claims.r !== binding.revision)
34799
+ return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
34800
+ if (claims.h !== binding.payloadHash)
34801
+ return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
34802
+ spent2.add(claims.n, claims.exp);
34803
+ return { ok: true };
34804
+ }
34805
+ var CONFIRM_TOKEN_INSTRUCTION = "Show this preview to the user verbatim and proceed only after they explicitly approve in chat. Then call again with confirmToken.";
34806
+ var confirmTokenParam = external_exports.string().optional().describe(`ONLY for the two-step confirmation fallback (a client without MCP elicitation). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat \u2014 never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.`);
34807
+ var TOKEN_ERROR_NOTE = {
34808
+ TOKEN_EXPIRED: "Nothing was sent or changed: the confirmToken expired. Call again WITHOUT confirmToken for a fresh preview, and ask the user to approve it again.",
34809
+ TOKEN_REUSED: "Nothing was sent or changed by this call: this confirmToken was already used, and one approval acts once. If doing it again is really intended, call again WITHOUT confirmToken and get a new approval.",
34810
+ TOKEN_INVALID: "Nothing was sent or changed: this confirmToken was not issued by this server for this tool, account and target (or the server has restarted since). Call again WITHOUT confirmToken for a fresh preview and approval."
34811
+ };
34812
+ var CHANGED_NOTE = {
34813
+ "revision-changed": "Nothing was sent or changed: the target was edited since the user approved it (its version rotated), so what would happen is not what they saw.",
34814
+ "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
34815
+ };
34816
+ function isToolResult(value) {
34817
+ return Array.isArray(value.content);
34818
+ }
34819
+ function rejection2(data) {
34820
+ return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
34821
+ }
34822
+ async function tokenConfirmation(action, fb) {
34823
+ const subject = await fb.subject();
34824
+ if (isToolResult(subject))
34825
+ return subject;
34826
+ const binding = {
34827
+ tool: fb.tool,
34828
+ ...fb.account === void 0 ? {} : { account: fb.account },
34829
+ target: subject.target,
34830
+ ...subject.revision === void 0 ? {} : { revision: subject.revision },
34831
+ payloadHash: hashConfirmPayload(subject.payload)
34832
+ };
34833
+ const phaseOne = () => {
34834
+ const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
34835
+ return {
34836
+ action,
34837
+ preview: subject.preview,
34838
+ confirmToken: token,
34839
+ expiresAt,
34840
+ ttlSeconds: ttlOf(fb.ttlSeconds),
34841
+ instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
34842
+ };
34843
+ };
34844
+ if (!fb.confirmToken) {
34845
+ return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
34846
+ }
34847
+ const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
34848
+ if (verdict.ok)
34849
+ return void 0;
34850
+ if (verdict.error === "DRAFT_CHANGED") {
34851
+ return rejection2({
34852
+ error: "DRAFT_CHANGED",
34853
+ reason: verdict.reason,
34854
+ note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
34855
+ ...phaseOne()
34856
+ });
34857
+ }
34858
+ return rejection2({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
34859
+ }
34860
+ async function requireConfirmationWithFallback(ctx, options) {
34861
+ const { tokenFallback, ...confirmation } = options;
34862
+ if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
34863
+ return tokenConfirmation(options.action, tokenFallback);
34864
+ }
34865
+ return requireConfirmation(ctx, confirmation);
34866
+ }
34867
+
34868
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34869
+ import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
34870
+
34871
+ // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34872
+ import { homedir } from "node:os";
34873
+ import { isAbsolute, join, resolve } from "node:path";
34874
+ var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34875
+ function readEnvVar(key, opts = {}) {
34876
+ const env = opts.env ?? process.env;
34877
+ const raw = env[key];
34878
+ if (typeof raw === "string") {
34879
+ const trimmed = raw.trim();
34880
+ if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
34881
+ return trimmed;
34882
+ }
34883
+ }
34884
+ return opts.default;
34885
+ }
34886
+ var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
34887
+ var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
34888
+ function parseBoolEnv(key, opts = {}) {
34889
+ const fallback = opts.default ?? false;
34890
+ const raw = readEnvVar(key, { env: opts.env });
34891
+ if (raw === void 0)
34892
+ return fallback;
34893
+ const token = raw.toLowerCase();
34894
+ if (TRUE_TOKENS.has(token))
34895
+ return true;
34896
+ if (FALSE_TOKENS.has(token))
34897
+ return false;
34898
+ return fallback;
34899
+ }
34900
+ function expandPath(p) {
34901
+ let expanded = p;
34902
+ if (p === "~") {
34903
+ expanded = homedir();
34904
+ } else if (p.startsWith("~/")) {
34905
+ expanded = join(homedir(), p.slice(2));
34906
+ }
34907
+ return isAbsolute(expanded) ? expanded : resolve(expanded);
34908
+ }
34909
+
34910
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34911
+ var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
34912
+ var DEFAULT_TTL_SECONDS2 = 600;
34913
+ var warned = /* @__PURE__ */ new Set();
34914
+ function readConfirmMode(env = process.env) {
34915
+ const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
34916
+ if (!raw)
34917
+ return "ask-user";
34918
+ if (MODES.has(raw))
34919
+ return raw;
34920
+ if (!warned.has(raw)) {
34921
+ warned.add(raw);
34922
+ process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
34923
+ `);
34924
+ }
34925
+ return "refuse";
34926
+ }
34927
+ function confirmTtlFromEnv(env = process.env) {
34928
+ const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
34929
+ return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
34930
+ }
34931
+ var processKey;
34932
+ function confirmKeyFromEnv(env = process.env) {
34933
+ const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
34934
+ if (secret)
34935
+ return createHash3("sha256").update(secret, "utf8").digest();
34936
+ processKey ??= randomBytes2(32);
34937
+ return processKey;
34938
+ }
34939
+ var CONFIRM_TOKEN_AUTO_INSTRUCTION = "Nothing has been done yet. Review this preview; if it is what was intended, call again with the same arguments plus confirmToken. (This server runs with MCP_CONFIRM_MODE=auto, so the user's approval in chat is not required.)";
34940
+ var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
34941
+ function confirmationFromEnv(options) {
34942
+ const { tool, account, confirmToken, subject, instruction, spent: spent2, env = process.env, ...confirmation } = options;
34943
+ const mode = readConfirmMode(env);
34944
+ if (mode === "refuse") {
34945
+ return {
34946
+ ...confirmation,
34947
+ unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
34948
+ };
34949
+ }
34950
+ return {
34951
+ ...confirmation,
34952
+ tokenFallback: {
34953
+ key: confirmKeyFromEnv(env),
34954
+ tool,
34955
+ ...account === void 0 ? {} : { account },
34956
+ ...confirmToken === void 0 ? {} : { confirmToken },
34957
+ subject,
34958
+ ttlSeconds: confirmTtlFromEnv(env),
34959
+ instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
34960
+ ...spent2 === void 0 ? {} : { spent: spent2 }
34961
+ }
34962
+ };
34963
+ }
34964
+
34703
34965
  // ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
34704
34966
  var SERVER_PROTOCOL_VERSIONS = Object.freeze([
34705
34967
  "2026-07-28",
@@ -34875,45 +35137,6 @@ function runMcp(opts) {
34875
35137
  return handle;
34876
35138
  }
34877
35139
 
34878
- // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34879
- import { homedir } from "node:os";
34880
- import { isAbsolute, join, resolve } from "node:path";
34881
- var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34882
- function readEnvVar(key, opts = {}) {
34883
- const env = opts.env ?? process.env;
34884
- const raw = env[key];
34885
- if (typeof raw === "string") {
34886
- const trimmed = raw.trim();
34887
- if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
34888
- return trimmed;
34889
- }
34890
- }
34891
- return opts.default;
34892
- }
34893
- var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
34894
- var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
34895
- function parseBoolEnv(key, opts = {}) {
34896
- const fallback = opts.default ?? false;
34897
- const raw = readEnvVar(key, { env: opts.env });
34898
- if (raw === void 0)
34899
- return fallback;
34900
- const token = raw.toLowerCase();
34901
- if (TRUE_TOKENS.has(token))
34902
- return true;
34903
- if (FALSE_TOKENS.has(token))
34904
- return false;
34905
- return fallback;
34906
- }
34907
- function expandPath(p) {
34908
- let expanded = p;
34909
- if (p === "~") {
34910
- expanded = homedir();
34911
- } else if (p.startsWith("~/")) {
34912
- expanded = join(homedir(), p.slice(2));
34913
- }
34914
- return isAbsolute(expanded) ? expanded : resolve(expanded);
34915
- }
34916
-
34917
35140
  // ../../node_modules/@chrischall/mcp-utils/dist/fs/confine.js
34918
35141
  import { existsSync, realpathSync } from "node:fs";
34919
35142
  import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
@@ -35794,167 +36017,36 @@ function formatAuthHealth(raw, now) {
35794
36017
  }
35795
36018
 
35796
36019
  // ../gogcli-mcp/src/send-confirm-token.ts
35797
- import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
35798
- var CONFIRM_TOKEN_TTL_DEFAULT_SECONDS = 600;
35799
- var PREFIX = "gct1";
35800
- var secret;
35801
- var spent = /* @__PURE__ */ new Map();
35802
- function sendConfirmFallbackEnabled() {
35803
- return readEnvVar("GOG_SEND_CONFIRM_FALLBACK")?.trim().toLowerCase() === "token";
35804
- }
35805
- function confirmTokenTtlSeconds() {
35806
- const raw = readEnvVar("GOG_CONFIRM_TTL_SECONDS")?.trim();
35807
- if (raw && /^\d+$/.test(raw)) {
35808
- const n = Number(raw);
35809
- if (n > 0) return n;
35810
- }
35811
- return CONFIRM_TOKEN_TTL_DEFAULT_SECONDS;
35812
- }
35813
- function hmacKey() {
35814
- if (!secret) {
35815
- const configured = readEnvVar("GOG_CONFIRM_SECRET");
35816
- secret = configured ? Buffer.from(configured, "utf8") : randomBytes(32);
35817
- }
35818
- return secret;
35819
- }
35820
- function canonicalize(value) {
35821
- if (Array.isArray(value)) return value.map(canonicalize);
35822
- if (value && typeof value === "object") {
35823
- const out = {};
35824
- for (const key of Object.keys(value).sort()) {
35825
- const v = value[key];
35826
- if (v !== void 0) out[key] = canonicalize(v);
35827
- }
35828
- return out;
35829
- }
35830
- return value;
35831
- }
35832
- function hashSendPayload(payload) {
35833
- return createHash2("sha256").update(JSON.stringify(canonicalize(payload))).digest("hex");
35834
- }
35835
- function sign(body) {
35836
- return createHmac2("sha256", hmacKey()).update(`${PREFIX}.${body}`).digest("base64url");
35837
- }
35838
- function issueConfirmToken(binding, now = Date.now()) {
35839
- const exp = now + confirmTokenTtlSeconds() * 1e3;
35840
- const claims = {
35841
- t: binding.tool,
35842
- a: binding.account,
35843
- g: binding.target,
35844
- ...binding.revision === void 0 ? {} : { r: binding.revision },
35845
- h: binding.payloadHash,
35846
- iat: now,
35847
- exp,
35848
- n: randomBytes(16).toString("base64url")
35849
- };
35850
- const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
35851
- return { token: `${PREFIX}.${body}.${sign(body)}`, expiresAt: new Date(exp).toISOString() };
35852
- }
35853
- function signatureMatches(body, sig) {
35854
- const expected = Buffer.from(sign(body), "utf8");
35855
- const actual = Buffer.from(sig, "utf8");
35856
- return expected.length === actual.length && timingSafeEqual2(expected, actual);
35857
- }
35858
- function parseClaims(body) {
35859
- try {
35860
- return JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
35861
- } catch {
35862
- return void 0;
35863
- }
35864
- }
35865
- function verifyConfirmToken(token, binding, now = Date.now()) {
35866
- for (const [nonce, exp] of spent) if (exp < now) spent.delete(nonce);
35867
- const parts = token.split(".");
35868
- if (parts.length !== 3 || parts[0] !== PREFIX || !parts[1] || !parts[2]) return { ok: false, error: "TOKEN_INVALID" };
35869
- const [, body, sig] = parts;
35870
- if (!signatureMatches(body, sig)) return { ok: false, error: "TOKEN_INVALID" };
35871
- const claims = parseClaims(body);
35872
- if (!claims) return { ok: false, error: "TOKEN_INVALID" };
35873
- if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
35874
- return { ok: false, error: "TOKEN_INVALID" };
35875
- }
35876
- if (spent.has(claims.n)) return { ok: false, error: "TOKEN_REUSED" };
35877
- if (now > claims.exp) return { ok: false, error: "TOKEN_EXPIRED" };
35878
- if (claims.r !== binding.revision) return { ok: false, error: "DRAFT_CHANGED", reason: "message-id-rotated" };
35879
- if (claims.h !== binding.payloadHash) return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
35880
- spent.set(claims.n, claims.exp);
35881
- return { ok: true };
36020
+ var spent = createSpentTokenStore();
36021
+ function confirmSpentStore() {
36022
+ return spent;
35882
36023
  }
35883
36024
 
35884
36025
  // ../gogcli-mcp/src/dispatch-confirmation.ts
35885
- var CONFIRM_ACTION_INSTRUCTION = "Show this preview to the user verbatim and proceed only after they explicitly approve in chat. Then call again with confirmToken.";
35886
- var FALLBACK_HINT = "Or set GOG_SEND_CONFIRM_FALLBACK=token to enable two-step confirmation.";
35887
- var CONFIRM_FALLBACK_DESCRIPTION = ' If the client cannot show that prompt (no MCP elicitation, e.g. claude.ai) and the server sets GOG_SEND_CONFIRM_FALLBACK=token, a two-step flow applies instead: call WITHOUT confirmToken and nothing is sent or changed \u2014 the result has status "confirmation-required", the full preview and a confirmToken. Show that preview to the user verbatim; only after they explicitly approve it in chat, call again with the SAME arguments plus confirmToken. The tool re-reads what it would act on and refuses (DRAFT_CHANGED, with a fresh preview and token) if it changed; TOKEN_EXPIRED / TOKEN_REUSED / TOKEN_INVALID also do nothing.';
35888
- var confirmTokenParam = external_exports.string().optional().describe(
35889
- `ONLY for the two-step fallback (client without MCP elicitation, server with GOG_SEND_CONFIRM_FALLBACK=token). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat \u2014 never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.`
35890
- );
35891
- var TOKEN_ERROR_NOTE = {
35892
- TOKEN_EXPIRED: "Nothing was sent or changed: the confirmToken expired. Call again WITHOUT confirmToken for a fresh preview, and ask the user to approve it again.",
35893
- TOKEN_REUSED: "Nothing was sent or changed by this call: this confirmToken was already used, and one approval acts once. If doing it again is really intended, call again WITHOUT confirmToken and get a new approval.",
35894
- TOKEN_INVALID: "Nothing was sent or changed: this confirmToken was not issued by this server for this tool, account and target (or the server has restarted since). Call again WITHOUT confirmToken for a fresh preview and approval."
35895
- };
35896
- var DRAFT_CHANGED_NOTE = {
35897
- "message-id-rotated": "Nothing was sent or changed: the target was edited since the user approved it (a draft's messageId or an event's version rotated), so what would happen is not what they saw.",
35898
- "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
35899
- };
35900
- function isToolResult(value) {
35901
- return Array.isArray(value.content);
35902
- }
35903
- function rejection2(data) {
35904
- return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
35905
- }
35906
- async function tokenConfirmation(op, fallback) {
35907
- const subject = await fallback.subject();
35908
- if (isToolResult(subject)) return subject;
35909
- const binding = {
35910
- tool: fallback.tool,
35911
- account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
35912
- target: subject.target,
35913
- ...subject.revision === void 0 ? {} : { revision: subject.revision },
35914
- payloadHash: hashSendPayload(subject.payload)
35915
- };
35916
- const phaseOne = () => {
35917
- const { token, expiresAt } = issueConfirmToken(binding);
35918
- return {
35919
- action: op,
35920
- preview: subject.preview,
35921
- confirmToken: token,
35922
- expiresAt,
35923
- ttlSeconds: confirmTokenTtlSeconds(),
35924
- instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION
35925
- };
35926
- };
35927
- if (!fallback.confirmToken) {
35928
- return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
35929
- }
35930
- const verdict = verifyConfirmToken(fallback.confirmToken, binding);
35931
- if (verdict.ok) return void 0;
35932
- if (verdict.error === "DRAFT_CHANGED") {
35933
- return rejection2({
35934
- error: "DRAFT_CHANGED",
35935
- reason: verdict.reason,
35936
- note: `${DRAFT_CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
35937
- ...phaseOne()
35938
- });
35939
- }
35940
- return rejection2({ error: verdict.error, action: op, note: TOKEN_ERROR_NOTE[verdict.error] });
35941
- }
36026
+ var CONFIRM_ACTION_INSTRUCTION = CONFIRM_TOKEN_INSTRUCTION;
36027
+ var CONFIRM_FALLBACK_DESCRIPTION = ' If the client cannot show that prompt (no MCP elicitation, e.g. claude.ai), a two-step flow applies instead: call WITHOUT confirmToken and nothing is sent or changed \u2014 the result has status "confirmation-required", the full preview and a confirmToken. Follow its instruction (by default: show the preview to the user verbatim and only after they explicitly approve it in chat, call again with the SAME arguments plus confirmToken). The tool re-reads what it would act on and refuses (DRAFT_CHANGED, with a fresh preview and token) if it changed; TOKEN_EXPIRED / TOKEN_REUSED / TOKEN_INVALID also do nothing. A server set to MCP_CONFIRM_MODE=refuse refuses instead.';
35942
36028
  function gatedElsewhere(what, via, does, tool) {
35943
36029
  return `${what} ${does} and is not available through ${via}. Use ${tool}, which asks the user to confirm.`;
35944
36030
  }
35945
36031
  async function requireDispatchConfirmation(ctx, options) {
35946
36032
  const { action, fallback } = options;
35947
- if (fallback && callerAcceptsFormElicitation(ctx) === false && sendConfirmFallbackEnabled()) {
35948
- return tokenConfirmation(action, fallback);
35949
- }
35950
- const note = fallback ? [options.unsupportedNote, FALLBACK_HINT].filter(Boolean).join(" ") : options.unsupportedNote;
35951
- return requireConfirmation(ctx, {
36033
+ const confirmation = {
35952
36034
  action,
35953
36035
  message: options.message,
35954
36036
  details: options.details,
35955
36037
  confirmationLabel: options.confirmationLabel,
35956
- ...note ? { unsupportedNote: note } : {}
35957
- });
36038
+ ...options.unsupportedNote ? { unsupportedNote: options.unsupportedNote } : {}
36039
+ };
36040
+ if (!fallback) return requireConfirmationWithFallback(ctx, confirmation);
36041
+ return requireConfirmationWithFallback(ctx, confirmationFromEnv({
36042
+ ...confirmation,
36043
+ tool: fallback.tool,
36044
+ account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
36045
+ confirmToken: fallback.confirmToken,
36046
+ subject: fallback.subject,
36047
+ instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION,
36048
+ spent: confirmSpentStore()
36049
+ }));
35958
36050
  }
35959
36051
  function resultText(result) {
35960
36052
  const first = result.content[0];
@@ -36480,7 +36572,7 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
36480
36572
  );
36481
36573
 
36482
36574
  // ../gogcli-mcp/src/server.ts
36483
- var VERSION = true ? "4.4.0" : "0.0.0";
36575
+ var VERSION = true ? "4.5.0" : "0.0.0";
36484
36576
 
36485
36577
  // ../gogcli-mcp/src/bootstrap-auth.ts
36486
36578
  import { join as join5 } from "node:path";
@@ -36517,12 +36609,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
36517
36609
  const [clientId, clientSecret, refreshToken, account] = values;
36518
36610
  const { spawner } = options;
36519
36611
  try {
36520
- const { createHash: createHash3 } = await import("node:crypto");
36612
+ const { createHash: createHash4 } = await import("node:crypto");
36521
36613
  const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
36522
36614
  const home = options.home ?? (await import("node:os")).homedir();
36523
36615
  const dir = join5(home, ".gogcli-mcp");
36524
36616
  const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
36525
- const fingerprint = createHash3("sha256").update(values.join("\0")).digest("hex");
36617
+ const fingerprint = createHash4("sha256").update(values.join("\0")).digest("hex");
36526
36618
  const previous = await readFile(marker, "utf8").catch(() => void 0);
36527
36619
  if (previous === fingerprint && await accountListed(account, spawner)) return "present";
36528
36620
  await run(
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "gogcli-mcp-drive",
5
5
  "display_name": "gogcli (Drive)",
6
- "version": "4.4.0",
6
+ "version": "4.5.0",
7
7
  "description": "Extended Google Drive for Claude via gogcli — auth + full Drive support (upload, download, permissions, comments, shared drives)",
8
8
  "author": {
9
9
  "name": "Chris Hall",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gogcli-mcp-drive",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "mcpName": "io.github.chrischall/gogcli-mcp-drive",
5
5
  "description": "Extended Google Drive MCP server via gogcli — auth + full Drive support (upload/download/permissions/comments/shared drives)",
6
6
  "author": "Claude Code (AI) <https://www.anthropic.com/claude>",
@@ -24,7 +24,7 @@
24
24
  "test:coverage": "vitest run --coverage"
25
25
  },
26
26
  "dependencies": {
27
- "@chrischall/mcp-utils": "^2.4.0",
27
+ "@chrischall/mcp-utils": "^2.6.0",
28
28
  "@modelcontextprotocol/server": "^2.0.0",
29
29
  "zod": "^4.6.1"
30
30
  },
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "source": "github",
8
8
  "subfolder": "packages/gogcli-mcp-drive"
9
9
  },
10
- "version": "4.4.0",
10
+ "version": "4.5.0",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "gogcli-mcp-drive",
15
- "version": "4.4.0",
15
+ "version": "4.5.0",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },