gogcli-mcp-classroom 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 Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
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 (Classroom)",
16
16
  "source": "./",
17
17
  "description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
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-classroom",
3
3
  "displayName": "gogcli (Classroom)",
4
- "version": "4.4.0",
4
+ "version": "4.5.0",
5
5
  "description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
6
6
  "author": {
7
7
  "name": "Chris Hall",
package/dist/index.js CHANGED
@@ -34533,10 +34533,8 @@ function errorResult(message) {
34533
34533
 
34534
34534
  // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34535
34535
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
34536
- var DEFAULT_REQUEST_KEY = "confirmation";
34537
- var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34538
- 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";
34539
- var STATE_PREFIX = "mcpu.confirm.v1.";
34536
+
34537
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/canonical.js
34540
34538
  function canonicalJson(value) {
34541
34539
  if (value === null || typeof value === "string" || typeof value === "boolean")
34542
34540
  return JSON.stringify(value);
@@ -34547,7 +34545,7 @@ function canonicalJson(value) {
34547
34545
  if (typeof value === "bigint")
34548
34546
  return `{"$bigint":"${value.toString()}"}`;
34549
34547
  if (typeof value === "function" || typeof value === "symbol") {
34550
- throw new TypeError(`requireConfirmation: cannot bind a ${typeof value} argument value.`);
34548
+ throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
34551
34549
  }
34552
34550
  if (Array.isArray(value))
34553
34551
  return `[${value.map(canonicalJson).join(",")}]`;
@@ -34569,7 +34567,7 @@ function canonicalJson(value) {
34569
34567
  }
34570
34568
  const proto = Object.getPrototypeOf(value);
34571
34569
  if (proto !== Object.prototype && proto !== null) {
34572
- throw new TypeError("requireConfirmation: cannot bind a non-plain object argument value (class instance).");
34570
+ throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
34573
34571
  }
34574
34572
  const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
34575
34573
  return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
@@ -34577,6 +34575,12 @@ function canonicalJson(value) {
34577
34575
  function escapeKey(key) {
34578
34576
  return key.startsWith("$") ? `$${key}` : key;
34579
34577
  }
34578
+
34579
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34580
+ var DEFAULT_REQUEST_KEY = "confirmation";
34581
+ var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34582
+ 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";
34583
+ var STATE_PREFIX = "mcpu.confirm.v1.";
34580
34584
  function bindingKey(binding) {
34581
34585
  if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
34582
34586
  throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
@@ -34679,6 +34683,264 @@ ${JSON.stringify(preview, null, 2)}`,
34679
34683
  });
34680
34684
  }
34681
34685
 
34686
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
34687
+ import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
34688
+ function createSpentTokenStore() {
34689
+ const spent2 = /* @__PURE__ */ new Map();
34690
+ return {
34691
+ has: (nonce) => spent2.has(nonce),
34692
+ add: (nonce, exp) => {
34693
+ spent2.set(nonce, exp);
34694
+ },
34695
+ prune: (now) => {
34696
+ for (const [nonce, exp] of spent2)
34697
+ if (exp < now)
34698
+ spent2.delete(nonce);
34699
+ },
34700
+ clear: () => spent2.clear(),
34701
+ get size() {
34702
+ return spent2.size;
34703
+ }
34704
+ };
34705
+ }
34706
+ var PROCESS_SPENT = createSpentTokenStore();
34707
+ var PREFIX = "mcpu.token.v1.";
34708
+ var DEFAULT_TTL_SECONDS = 600;
34709
+ function tokenKey(key) {
34710
+ const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
34711
+ if (bytes.length < 32)
34712
+ throw new RangeError("confirm token: key must be at least 32 bytes.");
34713
+ return bytes;
34714
+ }
34715
+ function ttlOf(ttlSeconds) {
34716
+ if (ttlSeconds === void 0)
34717
+ return DEFAULT_TTL_SECONDS;
34718
+ if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
34719
+ throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
34720
+ }
34721
+ return ttlSeconds;
34722
+ }
34723
+ function sign(key, body) {
34724
+ return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
34725
+ }
34726
+ function hashConfirmPayload(payload) {
34727
+ return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
34728
+ }
34729
+ function issueConfirmToken(key, binding, options = {}) {
34730
+ const k = tokenKey(key);
34731
+ const now = options.now ?? Date.now();
34732
+ const exp = now + ttlOf(options.ttlSeconds) * 1e3;
34733
+ const claims = {
34734
+ t: binding.tool,
34735
+ ...binding.account === void 0 ? {} : { a: binding.account },
34736
+ g: binding.target,
34737
+ ...binding.revision === void 0 ? {} : { r: binding.revision },
34738
+ h: binding.payloadHash,
34739
+ exp,
34740
+ n: randomBytes(16).toString("base64url")
34741
+ };
34742
+ const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
34743
+ return { token: `${PREFIX}${body}.${sign(k, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
34744
+ }
34745
+ function parseClaims(body) {
34746
+ try {
34747
+ const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34748
+ return claims && typeof claims === "object" ? claims : void 0;
34749
+ } catch {
34750
+ return void 0;
34751
+ }
34752
+ }
34753
+ function verifyConfirmToken(key, token, binding, options = {}) {
34754
+ const k = tokenKey(key);
34755
+ const now = options.now ?? Date.now();
34756
+ const spent2 = options.spent ?? PROCESS_SPENT;
34757
+ spent2.prune(now);
34758
+ if (!token.startsWith(PREFIX))
34759
+ return { ok: false, error: "TOKEN_INVALID" };
34760
+ const rest = token.slice(PREFIX.length);
34761
+ const dot = rest.indexOf(".");
34762
+ const body = dot < 0 ? "" : rest.slice(0, dot);
34763
+ const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
34764
+ const expected = sign(k, body);
34765
+ if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
34766
+ return { ok: false, error: "TOKEN_INVALID" };
34767
+ const claims = parseClaims(body);
34768
+ if (!claims)
34769
+ return { ok: false, error: "TOKEN_INVALID" };
34770
+ if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
34771
+ return { ok: false, error: "TOKEN_INVALID" };
34772
+ }
34773
+ if (spent2.has(claims.n))
34774
+ return { ok: false, error: "TOKEN_REUSED" };
34775
+ if (now > claims.exp)
34776
+ return { ok: false, error: "TOKEN_EXPIRED" };
34777
+ if (claims.r !== binding.revision)
34778
+ return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
34779
+ if (claims.h !== binding.payloadHash)
34780
+ return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
34781
+ spent2.add(claims.n, claims.exp);
34782
+ return { ok: true };
34783
+ }
34784
+ 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.";
34785
+ 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.`);
34786
+ var TOKEN_ERROR_NOTE = {
34787
+ 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.",
34788
+ 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.",
34789
+ 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."
34790
+ };
34791
+ var CHANGED_NOTE = {
34792
+ "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.",
34793
+ "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
34794
+ };
34795
+ function isToolResult(value) {
34796
+ return Array.isArray(value.content);
34797
+ }
34798
+ function rejection2(data) {
34799
+ return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
34800
+ }
34801
+ async function tokenConfirmation(action, fb) {
34802
+ const subject = await fb.subject();
34803
+ if (isToolResult(subject))
34804
+ return subject;
34805
+ const binding = {
34806
+ tool: fb.tool,
34807
+ ...fb.account === void 0 ? {} : { account: fb.account },
34808
+ target: subject.target,
34809
+ ...subject.revision === void 0 ? {} : { revision: subject.revision },
34810
+ payloadHash: hashConfirmPayload(subject.payload)
34811
+ };
34812
+ const phaseOne = () => {
34813
+ const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
34814
+ return {
34815
+ action,
34816
+ preview: subject.preview,
34817
+ confirmToken: token,
34818
+ expiresAt,
34819
+ ttlSeconds: ttlOf(fb.ttlSeconds),
34820
+ instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
34821
+ };
34822
+ };
34823
+ if (!fb.confirmToken) {
34824
+ return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
34825
+ }
34826
+ const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
34827
+ if (verdict.ok)
34828
+ return void 0;
34829
+ if (verdict.error === "DRAFT_CHANGED") {
34830
+ return rejection2({
34831
+ error: "DRAFT_CHANGED",
34832
+ reason: verdict.reason,
34833
+ note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
34834
+ ...phaseOne()
34835
+ });
34836
+ }
34837
+ return rejection2({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
34838
+ }
34839
+ async function requireConfirmationWithFallback(ctx, options) {
34840
+ const { tokenFallback, ...confirmation } = options;
34841
+ if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
34842
+ return tokenConfirmation(options.action, tokenFallback);
34843
+ }
34844
+ return requireConfirmation(ctx, confirmation);
34845
+ }
34846
+
34847
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34848
+ import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
34849
+
34850
+ // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34851
+ import { homedir } from "node:os";
34852
+ import { isAbsolute, join, resolve } from "node:path";
34853
+ var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34854
+ function readEnvVar(key, opts = {}) {
34855
+ const env = opts.env ?? process.env;
34856
+ const raw = env[key];
34857
+ if (typeof raw === "string") {
34858
+ const trimmed = raw.trim();
34859
+ if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
34860
+ return trimmed;
34861
+ }
34862
+ }
34863
+ return opts.default;
34864
+ }
34865
+ var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
34866
+ var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
34867
+ function parseBoolEnv(key, opts = {}) {
34868
+ const fallback = opts.default ?? false;
34869
+ const raw = readEnvVar(key, { env: opts.env });
34870
+ if (raw === void 0)
34871
+ return fallback;
34872
+ const token = raw.toLowerCase();
34873
+ if (TRUE_TOKENS.has(token))
34874
+ return true;
34875
+ if (FALSE_TOKENS.has(token))
34876
+ return false;
34877
+ return fallback;
34878
+ }
34879
+ function expandPath(p) {
34880
+ let expanded = p;
34881
+ if (p === "~") {
34882
+ expanded = homedir();
34883
+ } else if (p.startsWith("~/")) {
34884
+ expanded = join(homedir(), p.slice(2));
34885
+ }
34886
+ return isAbsolute(expanded) ? expanded : resolve(expanded);
34887
+ }
34888
+
34889
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34890
+ var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
34891
+ var DEFAULT_TTL_SECONDS2 = 600;
34892
+ var warned = /* @__PURE__ */ new Set();
34893
+ function readConfirmMode(env = process.env) {
34894
+ const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
34895
+ if (!raw)
34896
+ return "ask-user";
34897
+ if (MODES.has(raw))
34898
+ return raw;
34899
+ if (!warned.has(raw)) {
34900
+ warned.add(raw);
34901
+ process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
34902
+ `);
34903
+ }
34904
+ return "refuse";
34905
+ }
34906
+ function confirmTtlFromEnv(env = process.env) {
34907
+ const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
34908
+ return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
34909
+ }
34910
+ var processKey;
34911
+ function confirmKeyFromEnv(env = process.env) {
34912
+ const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
34913
+ if (secret)
34914
+ return createHash3("sha256").update(secret, "utf8").digest();
34915
+ processKey ??= randomBytes2(32);
34916
+ return processKey;
34917
+ }
34918
+ 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.)";
34919
+ var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
34920
+ function confirmationFromEnv(options) {
34921
+ const { tool, account, confirmToken, subject, instruction, spent: spent2, env = process.env, ...confirmation } = options;
34922
+ const mode = readConfirmMode(env);
34923
+ if (mode === "refuse") {
34924
+ return {
34925
+ ...confirmation,
34926
+ unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
34927
+ };
34928
+ }
34929
+ return {
34930
+ ...confirmation,
34931
+ tokenFallback: {
34932
+ key: confirmKeyFromEnv(env),
34933
+ tool,
34934
+ ...account === void 0 ? {} : { account },
34935
+ ...confirmToken === void 0 ? {} : { confirmToken },
34936
+ subject,
34937
+ ttlSeconds: confirmTtlFromEnv(env),
34938
+ instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
34939
+ ...spent2 === void 0 ? {} : { spent: spent2 }
34940
+ }
34941
+ };
34942
+ }
34943
+
34682
34944
  // ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
34683
34945
  var SERVER_PROTOCOL_VERSIONS = Object.freeze([
34684
34946
  "2026-07-28",
@@ -34854,45 +35116,6 @@ function runMcp(opts) {
34854
35116
  return handle;
34855
35117
  }
34856
35118
 
34857
- // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34858
- import { homedir } from "node:os";
34859
- import { isAbsolute, join, resolve } from "node:path";
34860
- var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34861
- function readEnvVar(key, opts = {}) {
34862
- const env = opts.env ?? process.env;
34863
- const raw = env[key];
34864
- if (typeof raw === "string") {
34865
- const trimmed = raw.trim();
34866
- if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
34867
- return trimmed;
34868
- }
34869
- }
34870
- return opts.default;
34871
- }
34872
- var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
34873
- var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
34874
- function parseBoolEnv(key, opts = {}) {
34875
- const fallback = opts.default ?? false;
34876
- const raw = readEnvVar(key, { env: opts.env });
34877
- if (raw === void 0)
34878
- return fallback;
34879
- const token = raw.toLowerCase();
34880
- if (TRUE_TOKENS.has(token))
34881
- return true;
34882
- if (FALSE_TOKENS.has(token))
34883
- return false;
34884
- return fallback;
34885
- }
34886
- function expandPath(p) {
34887
- let expanded = p;
34888
- if (p === "~") {
34889
- expanded = homedir();
34890
- } else if (p.startsWith("~/")) {
34891
- expanded = join(homedir(), p.slice(2));
34892
- }
34893
- return isAbsolute(expanded) ? expanded : resolve(expanded);
34894
- }
34895
-
34896
35119
  // ../../node_modules/@chrischall/mcp-utils/dist/fs/confine.js
34897
35120
  import { existsSync, realpathSync } from "node:fs";
34898
35121
  import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
@@ -35762,91 +35985,9 @@ function formatAuthHealth(raw, now) {
35762
35985
  }
35763
35986
 
35764
35987
  // ../gogcli-mcp/src/send-confirm-token.ts
35765
- import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
35766
- var CONFIRM_TOKEN_TTL_DEFAULT_SECONDS = 600;
35767
- var PREFIX = "gct1";
35768
- var secret;
35769
- var spent = /* @__PURE__ */ new Map();
35770
- function sendConfirmFallbackEnabled() {
35771
- return readEnvVar("GOG_SEND_CONFIRM_FALLBACK")?.trim().toLowerCase() === "token";
35772
- }
35773
- function confirmTokenTtlSeconds() {
35774
- const raw = readEnvVar("GOG_CONFIRM_TTL_SECONDS")?.trim();
35775
- if (raw && /^\d+$/.test(raw)) {
35776
- const n = Number(raw);
35777
- if (n > 0) return n;
35778
- }
35779
- return CONFIRM_TOKEN_TTL_DEFAULT_SECONDS;
35780
- }
35781
- function hmacKey() {
35782
- if (!secret) {
35783
- const configured = readEnvVar("GOG_CONFIRM_SECRET");
35784
- secret = configured ? Buffer.from(configured, "utf8") : randomBytes(32);
35785
- }
35786
- return secret;
35787
- }
35788
- function canonicalize(value) {
35789
- if (Array.isArray(value)) return value.map(canonicalize);
35790
- if (value && typeof value === "object") {
35791
- const out = {};
35792
- for (const key of Object.keys(value).sort()) {
35793
- const v = value[key];
35794
- if (v !== void 0) out[key] = canonicalize(v);
35795
- }
35796
- return out;
35797
- }
35798
- return value;
35799
- }
35800
- function hashSendPayload(payload) {
35801
- return createHash2("sha256").update(JSON.stringify(canonicalize(payload))).digest("hex");
35802
- }
35803
- function sign(body) {
35804
- return createHmac2("sha256", hmacKey()).update(`${PREFIX}.${body}`).digest("base64url");
35805
- }
35806
- function issueConfirmToken(binding, now = Date.now()) {
35807
- const exp = now + confirmTokenTtlSeconds() * 1e3;
35808
- const claims = {
35809
- t: binding.tool,
35810
- a: binding.account,
35811
- g: binding.target,
35812
- ...binding.revision === void 0 ? {} : { r: binding.revision },
35813
- h: binding.payloadHash,
35814
- iat: now,
35815
- exp,
35816
- n: randomBytes(16).toString("base64url")
35817
- };
35818
- const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
35819
- return { token: `${PREFIX}.${body}.${sign(body)}`, expiresAt: new Date(exp).toISOString() };
35820
- }
35821
- function signatureMatches(body, sig) {
35822
- const expected = Buffer.from(sign(body), "utf8");
35823
- const actual = Buffer.from(sig, "utf8");
35824
- return expected.length === actual.length && timingSafeEqual2(expected, actual);
35825
- }
35826
- function parseClaims(body) {
35827
- try {
35828
- return JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
35829
- } catch {
35830
- return void 0;
35831
- }
35832
- }
35833
- function verifyConfirmToken(token, binding, now = Date.now()) {
35834
- for (const [nonce, exp] of spent) if (exp < now) spent.delete(nonce);
35835
- const parts = token.split(".");
35836
- if (parts.length !== 3 || parts[0] !== PREFIX || !parts[1] || !parts[2]) return { ok: false, error: "TOKEN_INVALID" };
35837
- const [, body, sig] = parts;
35838
- if (!signatureMatches(body, sig)) return { ok: false, error: "TOKEN_INVALID" };
35839
- const claims = parseClaims(body);
35840
- if (!claims) return { ok: false, error: "TOKEN_INVALID" };
35841
- if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
35842
- return { ok: false, error: "TOKEN_INVALID" };
35843
- }
35844
- if (spent.has(claims.n)) return { ok: false, error: "TOKEN_REUSED" };
35845
- if (now > claims.exp) return { ok: false, error: "TOKEN_EXPIRED" };
35846
- if (claims.r !== binding.revision) return { ok: false, error: "DRAFT_CHANGED", reason: "message-id-rotated" };
35847
- if (claims.h !== binding.payloadHash) return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
35848
- spent.set(claims.n, claims.exp);
35849
- return { ok: true };
35988
+ var spent = createSpentTokenStore();
35989
+ function confirmSpentStore() {
35990
+ return spent;
35850
35991
  }
35851
35992
 
35852
35993
  // ../gogcli-mcp/src/dispatch-confirmation.ts
@@ -35856,63 +35997,8 @@ function bodyPreview(text) {
35856
35997
  if (text.length <= BODY_PREVIEW_MAX) return text;
35857
35998
  return `${text.slice(0, BODY_PREVIEW_MAX)}\u2026 [${text.length - BODY_PREVIEW_MAX} more characters not shown]`;
35858
35999
  }
35859
- 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.";
35860
- var FALLBACK_HINT = "Or set GOG_SEND_CONFIRM_FALLBACK=token to enable two-step confirmation.";
35861
- 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.';
35862
- var confirmTokenParam = external_exports.string().optional().describe(
35863
- `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.`
35864
- );
35865
- var TOKEN_ERROR_NOTE = {
35866
- 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.",
35867
- 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.",
35868
- 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."
35869
- };
35870
- var DRAFT_CHANGED_NOTE = {
35871
- "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.",
35872
- "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
35873
- };
35874
- function isToolResult(value) {
35875
- return Array.isArray(value.content);
35876
- }
35877
- function rejection2(data) {
35878
- return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
35879
- }
35880
- async function tokenConfirmation(op, fallback) {
35881
- const subject = await fallback.subject();
35882
- if (isToolResult(subject)) return subject;
35883
- const binding = {
35884
- tool: fallback.tool,
35885
- account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
35886
- target: subject.target,
35887
- ...subject.revision === void 0 ? {} : { revision: subject.revision },
35888
- payloadHash: hashSendPayload(subject.payload)
35889
- };
35890
- const phaseOne = () => {
35891
- const { token, expiresAt } = issueConfirmToken(binding);
35892
- return {
35893
- action: op,
35894
- preview: subject.preview,
35895
- confirmToken: token,
35896
- expiresAt,
35897
- ttlSeconds: confirmTokenTtlSeconds(),
35898
- instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION
35899
- };
35900
- };
35901
- if (!fallback.confirmToken) {
35902
- return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
35903
- }
35904
- const verdict = verifyConfirmToken(fallback.confirmToken, binding);
35905
- if (verdict.ok) return void 0;
35906
- if (verdict.error === "DRAFT_CHANGED") {
35907
- return rejection2({
35908
- error: "DRAFT_CHANGED",
35909
- reason: verdict.reason,
35910
- note: `${DRAFT_CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
35911
- ...phaseOne()
35912
- });
35913
- }
35914
- return rejection2({ error: verdict.error, action: op, note: TOKEN_ERROR_NOTE[verdict.error] });
35915
- }
36000
+ var CONFIRM_ACTION_INSTRUCTION = CONFIRM_TOKEN_INSTRUCTION;
36001
+ 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.';
35916
36002
  function gatedElsewhere(what, via, does, tool) {
35917
36003
  return `${what} ${does} and is not available through ${via}. Use ${tool}, which asks the user to confirm.`;
35918
36004
  }
@@ -35921,17 +36007,23 @@ function hasCommandWord(args, words) {
35921
36007
  }
35922
36008
  async function requireDispatchConfirmation(ctx, options) {
35923
36009
  const { action, fallback } = options;
35924
- if (fallback && callerAcceptsFormElicitation(ctx) === false && sendConfirmFallbackEnabled()) {
35925
- return tokenConfirmation(action, fallback);
35926
- }
35927
- const note = fallback ? [options.unsupportedNote, FALLBACK_HINT].filter(Boolean).join(" ") : options.unsupportedNote;
35928
- return requireConfirmation(ctx, {
36010
+ const confirmation = {
35929
36011
  action,
35930
36012
  message: options.message,
35931
36013
  details: options.details,
35932
36014
  confirmationLabel: options.confirmationLabel,
35933
- ...note ? { unsupportedNote: note } : {}
35934
- });
36015
+ ...options.unsupportedNote ? { unsupportedNote: options.unsupportedNote } : {}
36016
+ };
36017
+ if (!fallback) return requireConfirmationWithFallback(ctx, confirmation);
36018
+ return requireConfirmationWithFallback(ctx, confirmationFromEnv({
36019
+ ...confirmation,
36020
+ tool: fallback.tool,
36021
+ account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
36022
+ confirmToken: fallback.confirmToken,
36023
+ subject: fallback.subject,
36024
+ instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION,
36025
+ spent: confirmSpentStore()
36026
+ }));
35935
36027
  }
35936
36028
  function resultText(result) {
35937
36029
  const first = result.content[0];
@@ -36581,7 +36673,7 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
36581
36673
  );
36582
36674
 
36583
36675
  // ../gogcli-mcp/src/server.ts
36584
- var VERSION = true ? "4.4.0" : "0.0.0";
36676
+ var VERSION = true ? "4.5.0" : "0.0.0";
36585
36677
 
36586
36678
  // ../gogcli-mcp/src/bootstrap-auth.ts
36587
36679
  import { join as join5 } from "node:path";
@@ -36618,12 +36710,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
36618
36710
  const [clientId, clientSecret, refreshToken, account] = values;
36619
36711
  const { spawner } = options;
36620
36712
  try {
36621
- const { createHash: createHash3 } = await import("node:crypto");
36713
+ const { createHash: createHash4 } = await import("node:crypto");
36622
36714
  const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
36623
36715
  const home = options.home ?? (await import("node:os")).homedir();
36624
36716
  const dir = join5(home, ".gogcli-mcp");
36625
36717
  const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
36626
- const fingerprint = createHash3("sha256").update(values.join("\0")).digest("hex");
36718
+ const fingerprint = createHash4("sha256").update(values.join("\0")).digest("hex");
36627
36719
  const previous = await readFile(marker, "utf8").catch(() => void 0);
36628
36720
  if (previous === fingerprint && await accountListed(account, spawner)) return "present";
36629
36721
  await run(
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "gogcli-mcp-classroom",
5
5
  "display_name": "gogcli (Classroom)",
6
- "version": "4.4.0",
6
+ "version": "4.5.0",
7
7
  "description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
8
8
  "author": {
9
9
  "name": "Chris Hall",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gogcli-mcp-classroom",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "mcpName": "io.github.chrischall/gogcli-mcp-classroom",
5
5
  "description": "Extended Google Classroom MCP server via gogcli — auth + full Classroom support",
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-classroom"
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-classroom",
15
- "version": "4.4.0",
15
+ "version": "4.5.0",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
2
  import { registerExtraClassroomTools } from '../../src/tools/classroom-extra.js';
3
3
  import * as lib from '../../../gogcli-mcp/src/lib.js';
4
4
  import { createTestHarness, type TestHarness } from '@chrischall/mcp-utils/test';
@@ -15,6 +15,9 @@ vi.mock('../../../gogcli-mcp/src/lib.js', async (importOriginal) => {
15
15
 
16
16
  let harness: TestHarness;
17
17
 
18
+ // MCP_CONFIRM_MODE is read per call; a test that sets it must not leak it.
19
+ afterEach(() => { delete process.env.MCP_CONFIRM_MODE; });
20
+
18
21
  beforeEach(async () => {
19
22
  vi.clearAllMocks();
20
23
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
@@ -269,6 +272,8 @@ describe('gog_classroom_invitations_create', () => {
269
272
  });
270
273
 
271
274
  it('refuses a client that cannot be prompted', async () => {
275
+
276
+ process.env.MCP_CONFIRM_MODE = 'refuse';
272
277
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(COURSE);
273
278
  const h = await createTestHarness(registerExtraClassroomTools);
274
279
  const r = JSON.parse((await h.callTool('gog_classroom_invitations_create', { courseId: 'c1', userId: 'u1', role: 'STUDENT' })).content[0]!.text as string);
@@ -278,7 +283,7 @@ describe('gog_classroom_invitations_create', () => {
278
283
 
279
284
  it('token fallback: phase 1 previews, phase 2 invites', async () => {
280
285
  const ORIGINAL = { ...process.env };
281
- process.env.GOG_SEND_CONFIRM_FALLBACK = 'token';
286
+ process.env.MCP_CONFIRM_MODE = 'ask-user';
282
287
  try {
283
288
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(COURSE);
284
289
  const h = await createTestHarness(registerExtraClassroomTools);