Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/codemode-plugins/googleCalendar/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ function applyEventFields(
// ─── Plugin ──────────────────────────────────────────────────────

const SCOPES = ["https://www.googleapis.com/auth/calendar"];
// Meet settings are separate from Calendar access. Include them in user consent
// so Calendar extensions can configure recording on Calendar-created meetings.
// Keep Calendar request/service-account scopes unchanged.
const CONSENT_SCOPES = [
...SCOPES,
"https://www.googleapis.com/auth/meetings.space.settings",
];

const optionalPositiveInteger = t.Optional(PositiveInteger);
const calendarId = NonEmptyString;
Expand Down Expand Up @@ -615,7 +622,7 @@ export default function googleCalendar(rl: CodemodePluginAPI) {
rl.setVersion("0.1.0");
rl.setCredential(googleCredential("googleCalendar", SCOPES));

rl.setOAuth(googleOAuth("googleCalendar", SCOPES, "GOOGLE_CALENDAR"));
rl.setOAuth(googleOAuth("googleCalendar", CONSENT_SCOPES, "GOOGLE_CALENDAR"));

rl.setConnectionSchema(t.Object(googleConnection("GOOGLE_CALENDAR")));

Expand Down
8 changes: 6 additions & 2 deletions packages/codemode/src/tests/credential-declaration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe("registry-backed plugins declare their credential", () => {
});
}

it("Google and Microsoft sign for exactly the scopes their consent asks for", () => {
it("Google and Microsoft sign for their required scopes, with Calendar-only service accounts preserved", () => {
const { privateKey } = generateKeyPairSync("rsa", {
modulusLength: 2048,
privateKeyEncoding: { type: "pkcs8", format: "pem" },
Expand Down Expand Up @@ -126,7 +126,11 @@ describe("registry-backed plugins declare their credential", () => {
assert.equal(auth?.kind, "oauth2");
assert.deepEqual(
auth?.kind === "oauth2" ? auth.scopes : undefined,
def.oauth?.scopes,
// Calendar user consent additionally authorizes Meet extensions. Existing
// service-account Calendar calls must not require new admin delegation.
def.name === "googleCalendar"
? ["https://www.googleapis.com/auth/calendar"]
: def.oauth?.scopes,
def.name,
);
assert.equal(selection?.jwtIdentity?.issuer, "robot@example.com");
Expand Down
16 changes: 16 additions & 0 deletions packages/codemode/src/tests/google-calendar-meet-consent.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import assert from "node:assert/strict";
import { it } from "node:test";
import googleCalendar from "../../../codemode-plugins/googleCalendar/src/index.js";
import { createPluginAPI } from "../plugin/api.js";

it("Calendar consent includes Meet settings without dropping Calendar access", () => {
const { api, resolve } = createPluginAPI("googleCalendar");
googleCalendar(api);
const plugin = resolve();
assert.deepEqual(plugin.oauth?.scopes, [
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/meetings.space.settings",
]);
assert.equal(plugin.oauth?.grant, "google");
assert.ok(plugin.actions.some((action) => action.name === "event.create"));
});