@kodelyth/google-meet 2026.5.39 → 2026.5.42

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.
Files changed (46) hide show
  1. package/dist/calendar-CEiBGUl2.js +136 -0
  2. package/dist/chrome-create-DMyPCiEd.js +965 -0
  3. package/dist/cli-BMVhSIb8.js +1390 -0
  4. package/dist/create-IbyMXB3V.js +108 -0
  5. package/dist/doctor-contract-api.js +56 -0
  6. package/dist/index.js +4979 -0
  7. package/dist/oauth-7_sWAae1.js +141 -0
  8. package/doctor-contract-api.ts +1 -0
  9. package/google-meet.live.test.ts +82 -0
  10. package/index.create.test.ts +671 -0
  11. package/index.test.ts +5051 -0
  12. package/index.ts +1224 -0
  13. package/klaw.plugin.json +12 -46
  14. package/node-host.test.ts +241 -0
  15. package/package.json +3 -3
  16. package/src/agent-consult.ts +158 -0
  17. package/src/calendar.ts +252 -0
  18. package/src/cli.test.ts +1234 -0
  19. package/src/cli.ts +2350 -0
  20. package/src/config-compat.test.ts +98 -0
  21. package/src/config-compat.ts +84 -0
  22. package/src/config.ts +589 -0
  23. package/src/create.ts +157 -0
  24. package/src/drive.ts +72 -0
  25. package/src/google-api-errors.ts +20 -0
  26. package/src/meet.ts +1024 -0
  27. package/src/node-host.ts +520 -0
  28. package/src/oauth.test.ts +73 -0
  29. package/src/oauth.ts +229 -0
  30. package/src/realtime-node.ts +780 -0
  31. package/src/realtime.ts +1334 -0
  32. package/src/runtime.ts +1008 -0
  33. package/src/setup.ts +285 -0
  34. package/src/test-support/plugin-harness.ts +232 -0
  35. package/src/transports/chrome-browser-proxy.test.ts +39 -0
  36. package/src/transports/chrome-browser-proxy.ts +204 -0
  37. package/src/transports/chrome-create.ts +364 -0
  38. package/src/transports/chrome.test.ts +12 -0
  39. package/src/transports/chrome.ts +1065 -0
  40. package/src/transports/twilio.ts +57 -0
  41. package/src/transports/types.ts +147 -0
  42. package/src/voice-call-gateway.test.ts +152 -0
  43. package/src/voice-call-gateway.ts +241 -0
  44. package/tsconfig.json +16 -0
  45. package/doctor-contract-api.js +0 -7
  46. package/index.js +0 -7
@@ -0,0 +1,141 @@
1
+ import { fetchWithSsrFGuard } from "klaw/plugin-sdk/ssrf-runtime";
2
+ import { generateHexPkceVerifierChallenge } from "klaw/plugin-sdk/provider-auth";
3
+ import { generateOAuthState, parseOAuthCallbackInput, waitForLocalOAuthCallback } from "klaw/plugin-sdk/provider-auth-runtime";
4
+ //#region extensions/google-meet/src/oauth.ts
5
+ const GOOGLE_MEET_REDIRECT_URI = "http://localhost:8085/oauth2callback";
6
+ const GOOGLE_MEET_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
7
+ const GOOGLE_MEET_TOKEN_URL = "https://oauth2.googleapis.com/token";
8
+ const GOOGLE_MEET_TOKEN_HOST = "oauth2.googleapis.com";
9
+ const GOOGLE_MEET_SCOPES = [
10
+ "https://www.googleapis.com/auth/meetings.space.created",
11
+ "https://www.googleapis.com/auth/meetings.space.readonly",
12
+ "https://www.googleapis.com/auth/meetings.space.settings",
13
+ "https://www.googleapis.com/auth/meetings.conference.media.readonly",
14
+ "https://www.googleapis.com/auth/calendar.events.readonly",
15
+ "https://www.googleapis.com/auth/drive.meet.readonly"
16
+ ];
17
+ function buildGoogleMeetAuthUrl(params) {
18
+ return `${GOOGLE_MEET_AUTH_URL}?${new URLSearchParams({
19
+ client_id: params.clientId,
20
+ response_type: "code",
21
+ redirect_uri: params.redirectUri ?? GOOGLE_MEET_REDIRECT_URI,
22
+ scope: (params.scopes ?? GOOGLE_MEET_SCOPES).join(" "),
23
+ code_challenge: params.challenge,
24
+ code_challenge_method: "S256",
25
+ access_type: "offline",
26
+ prompt: "consent",
27
+ state: params.state
28
+ }).toString()}`;
29
+ }
30
+ async function executeGoogleTokenRequest(body) {
31
+ const { response, release } = await fetchWithSsrFGuard({
32
+ url: GOOGLE_MEET_TOKEN_URL,
33
+ init: {
34
+ method: "POST",
35
+ headers: {
36
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
37
+ Accept: "application/json"
38
+ },
39
+ body
40
+ },
41
+ policy: { allowedHostnames: [GOOGLE_MEET_TOKEN_HOST] },
42
+ auditContext: "google-meet.oauth.token"
43
+ });
44
+ try {
45
+ if (!response.ok) {
46
+ const detail = await response.text();
47
+ throw new Error(`Google OAuth token request failed (${response.status}): ${detail}`);
48
+ }
49
+ const payload = await response.json();
50
+ const accessToken = payload.access_token?.trim();
51
+ if (!accessToken) throw new Error("Google OAuth token response was missing access_token");
52
+ const expiresInSeconds = typeof payload.expires_in === "number" && Number.isFinite(payload.expires_in) ? payload.expires_in : 3600;
53
+ return {
54
+ accessToken,
55
+ expiresAt: Date.now() + expiresInSeconds * 1e3,
56
+ refreshToken: payload.refresh_token?.trim() || void 0,
57
+ scope: payload.scope?.trim() || void 0,
58
+ tokenType: payload.token_type?.trim() || void 0
59
+ };
60
+ } finally {
61
+ await release();
62
+ }
63
+ }
64
+ function tokenRequestBody(values) {
65
+ const body = new URLSearchParams();
66
+ for (const [key, value] of Object.entries(values)) if (value?.trim()) body.set(key, value);
67
+ return body;
68
+ }
69
+ async function exchangeGoogleMeetAuthCode(params) {
70
+ return await executeGoogleTokenRequest(tokenRequestBody({
71
+ client_id: params.clientId,
72
+ client_secret: params.clientSecret,
73
+ code: params.code,
74
+ grant_type: "authorization_code",
75
+ redirect_uri: params.redirectUri ?? GOOGLE_MEET_REDIRECT_URI,
76
+ code_verifier: params.verifier
77
+ }));
78
+ }
79
+ async function refreshGoogleMeetAccessToken(params) {
80
+ return await executeGoogleTokenRequest(tokenRequestBody({
81
+ client_id: params.clientId,
82
+ client_secret: params.clientSecret,
83
+ grant_type: "refresh_token",
84
+ refresh_token: params.refreshToken
85
+ }));
86
+ }
87
+ function shouldUseCachedGoogleMeetAccessToken(params) {
88
+ const now = params.now ?? Date.now();
89
+ const safetyWindowMs = params.safetyWindowMs ?? 6e4;
90
+ return Boolean(params.accessToken?.trim() && typeof params.expiresAt === "number" && Number.isFinite(params.expiresAt) && params.expiresAt > now + safetyWindowMs);
91
+ }
92
+ async function resolveGoogleMeetAccessToken(params) {
93
+ if (shouldUseCachedGoogleMeetAccessToken(params)) return {
94
+ accessToken: params.accessToken.trim(),
95
+ expiresAt: params.expiresAt,
96
+ refreshed: false
97
+ };
98
+ if (!params.clientId?.trim() || !params.refreshToken?.trim()) throw new Error("Missing Google Meet OAuth credentials. Configure oauth.clientId and oauth.refreshToken, or pass --client-id and --refresh-token.");
99
+ const refreshed = await refreshGoogleMeetAccessToken({
100
+ clientId: params.clientId,
101
+ clientSecret: params.clientSecret,
102
+ refreshToken: params.refreshToken
103
+ });
104
+ return {
105
+ accessToken: refreshed.accessToken,
106
+ expiresAt: refreshed.expiresAt,
107
+ refreshed: true
108
+ };
109
+ }
110
+ function createGoogleMeetPkce() {
111
+ const { verifier, challenge } = generateHexPkceVerifierChallenge();
112
+ return {
113
+ verifier,
114
+ challenge
115
+ };
116
+ }
117
+ function createGoogleMeetOAuthState() {
118
+ return generateOAuthState();
119
+ }
120
+ async function waitForGoogleMeetAuthCode(params) {
121
+ params.writeLine(`Open this URL in your browser:\n\n${params.authUrl}\n`);
122
+ if (params.manual) {
123
+ const parsed = parseOAuthCallbackInput(await params.promptInput("Paste the full redirect URL here: "), {
124
+ missingState: "Missing 'state' parameter. Paste the full redirect URL.",
125
+ invalidInput: "Paste the full redirect URL, not just the code."
126
+ });
127
+ if ("error" in parsed) throw new Error(parsed.error);
128
+ if (parsed.state !== params.state) throw new Error("OAuth state mismatch - please try again");
129
+ return parsed.code;
130
+ }
131
+ return (await waitForLocalOAuthCallback({
132
+ expectedState: params.state,
133
+ timeoutMs: params.timeoutMs,
134
+ port: 8085,
135
+ callbackPath: "/oauth2callback",
136
+ redirectUri: GOOGLE_MEET_REDIRECT_URI,
137
+ successTitle: "Google Meet OAuth complete"
138
+ })).code;
139
+ }
140
+ //#endregion
141
+ export { buildGoogleMeetAuthUrl, createGoogleMeetOAuthState, createGoogleMeetPkce, exchangeGoogleMeetAuthCode, resolveGoogleMeetAccessToken, waitForGoogleMeetAuthCode };
@@ -0,0 +1 @@
1
+ export { legacyConfigRules, normalizeCompatibilityConfig } from "./src/config-compat.js";
@@ -0,0 +1,82 @@
1
+ import { isLiveTestEnabled } from "klaw/plugin-sdk/test-env";
2
+ import { describe, expect, it } from "vitest";
3
+ import { buildGoogleMeetExportManifest, googleMeetExportFileNames } from "./src/cli.js";
4
+ import {
5
+ fetchGoogleMeetArtifacts,
6
+ fetchGoogleMeetAttendance,
7
+ fetchLatestGoogleMeetConferenceRecord,
8
+ } from "./src/meet.js";
9
+ import { resolveGoogleMeetAccessToken } from "./src/oauth.js";
10
+
11
+ const LIVE_MEETING = process.env.KLAW_GOOGLE_MEET_LIVE_MEETING?.trim() ?? "";
12
+ const CLIENT_ID =
13
+ process.env.KLAW_GOOGLE_MEET_CLIENT_ID?.trim() ?? process.env.GOOGLE_MEET_CLIENT_ID?.trim() ?? "";
14
+ const CLIENT_SECRET =
15
+ process.env.KLAW_GOOGLE_MEET_CLIENT_SECRET?.trim() ??
16
+ process.env.GOOGLE_MEET_CLIENT_SECRET?.trim();
17
+ const REFRESH_TOKEN =
18
+ process.env.KLAW_GOOGLE_MEET_REFRESH_TOKEN?.trim() ??
19
+ process.env.GOOGLE_MEET_REFRESH_TOKEN?.trim() ??
20
+ "";
21
+ const ACCESS_TOKEN =
22
+ process.env.KLAW_GOOGLE_MEET_ACCESS_TOKEN?.trim() ?? process.env.GOOGLE_MEET_ACCESS_TOKEN?.trim();
23
+ const EXPIRES_AT = Number(
24
+ process.env.KLAW_GOOGLE_MEET_ACCESS_TOKEN_EXPIRES_AT ??
25
+ process.env.GOOGLE_MEET_ACCESS_TOKEN_EXPIRES_AT,
26
+ );
27
+
28
+ const LIVE =
29
+ isLiveTestEnabled() &&
30
+ LIVE_MEETING.length > 0 &&
31
+ ((CLIENT_ID.length > 0 && REFRESH_TOKEN.length > 0) || Boolean(ACCESS_TOKEN));
32
+ const describeLive = LIVE ? describe : describe.skip;
33
+
34
+ describeLive("google-meet live", () => {
35
+ it("resolves latest conference record and artifacts for a real meeting", async () => {
36
+ const token = await resolveGoogleMeetAccessToken({
37
+ clientId: CLIENT_ID,
38
+ clientSecret: CLIENT_SECRET,
39
+ refreshToken: REFRESH_TOKEN,
40
+ accessToken: ACCESS_TOKEN,
41
+ expiresAt: Number.isFinite(EXPIRES_AT) ? EXPIRES_AT : undefined,
42
+ });
43
+
44
+ const latest = await fetchLatestGoogleMeetConferenceRecord({
45
+ accessToken: token.accessToken,
46
+ meeting: LIVE_MEETING,
47
+ });
48
+ expect(latest.space.name).toMatch(/^spaces\//);
49
+
50
+ const artifacts = await fetchGoogleMeetArtifacts({
51
+ accessToken: token.accessToken,
52
+ meeting: LIVE_MEETING,
53
+ pageSize: 5,
54
+ });
55
+ expect(artifacts.conferenceRecords.length).toBeLessThanOrEqual(1);
56
+ expect(Array.isArray(artifacts.artifacts)).toBe(true);
57
+
58
+ const attendance = await fetchGoogleMeetAttendance({
59
+ accessToken: token.accessToken,
60
+ meeting: LIVE_MEETING,
61
+ pageSize: 5,
62
+ });
63
+ expect(attendance.conferenceRecords.length).toBe(artifacts.conferenceRecords.length);
64
+
65
+ const manifest = buildGoogleMeetExportManifest({
66
+ artifacts,
67
+ attendance,
68
+ files: googleMeetExportFileNames(),
69
+ request: {
70
+ meeting: LIVE_MEETING,
71
+ pageSize: 5,
72
+ includeTranscriptEntries: true,
73
+ includeDocumentBodies: false,
74
+ allConferenceRecords: false,
75
+ mergeDuplicateParticipants: true,
76
+ },
77
+ tokenSource: token.refreshed ? "refresh-token" : "cached-access-token",
78
+ });
79
+ expect(manifest.files).toContain("manifest.json");
80
+ expect(manifest.counts.conferenceRecords).toBe(artifacts.conferenceRecords.length);
81
+ }, 120_000);
82
+ });