gogcli-mcp 3.0.0 → 4.0.1

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 (50) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/dist/index.js +474 -947
  4. package/dist/lib.js +575 -983
  5. package/manifest.json +2 -2
  6. package/mint.yaml +41 -37
  7. package/package.json +3 -3
  8. package/server.json +2 -2
  9. package/src/attachments.ts +28 -34
  10. package/src/blob-upload.ts +165 -134
  11. package/src/blob-urls.ts +3 -5
  12. package/src/bootstrap-auth.ts +97 -0
  13. package/src/index.ts +3 -4
  14. package/src/lib.ts +14 -9
  15. package/src/runner.ts +27 -176
  16. package/src/tools/appscript.ts +1 -1
  17. package/src/tools/auth.ts +5 -5
  18. package/src/tools/drive.ts +1 -3
  19. package/src/tools/gmail.ts +9 -9
  20. package/src/tools/utils.ts +12 -58
  21. package/tests/attachments.test.ts +11 -14
  22. package/tests/blob-upload.test.ts +235 -160
  23. package/tests/bootstrap-auth.test.ts +245 -0
  24. package/tests/runner-file-args.test.ts +1 -13
  25. package/tests/runner.test.ts +53 -96
  26. package/tests/sdk-single-copy.test.ts +4 -12
  27. package/tests/tools/auth-401-shapes.test.ts +2 -3
  28. package/tests/tools/auth.test.ts +5 -4
  29. package/tests/tools/drive.test.ts +11 -3
  30. package/tests/tools/gmail.test.ts +2 -2
  31. package/tests/tools/utils.test.ts +1 -50
  32. package/tests/zod-single-copy.test.ts +6 -14
  33. package/tsconfig.json +1 -2
  34. package/vitest.config.ts +2 -12
  35. package/src/auth-log.ts +0 -205
  36. package/src/connector-auth.ts +0 -319
  37. package/src/connector-login.ts +0 -87
  38. package/src/connector-runtime.ts +0 -910
  39. package/src/google-probe.ts +0 -113
  40. package/src/google-token.ts +0 -391
  41. package/src/remote-runner.ts +0 -77
  42. package/src/worker.ts +0 -117
  43. package/tests/auth-log.test.ts +0 -530
  44. package/tests/connector-auth.test.ts +0 -559
  45. package/tests/connector-login.test.ts +0 -151
  46. package/tests/connector-runtime.test.ts +0 -1664
  47. package/tests/google-probe.test.ts +0 -116
  48. package/tests/google-token.test.ts +0 -425
  49. package/tests/remote-runner.test.ts +0 -202
  50. package/tests/worker.test.ts +0 -167
@@ -1,87 +0,0 @@
1
- import type { ConnectorAuth } from './connector-auth.js';
2
-
3
- function escapeHtml(value: unknown): string {
4
- return String(value)
5
- .replaceAll('&', '&')
6
- .replaceAll('<', '&lt;')
7
- .replaceAll('>', '&gt;')
8
- .replaceAll('"', '&quot;')
9
- .replaceAll("'", '&#39;');
10
- }
11
-
12
- function encodeOauthRequest(value: unknown): string {
13
- return btoa(JSON.stringify(value));
14
- }
15
-
16
- function renderLoginPage<Props>(
17
- auth: ConnectorAuth<Props>,
18
- options: { oauthReq: unknown; error?: string },
19
- ): string {
20
- const fields = auth.fields.map((field) => `
21
- <label>${escapeHtml(field.label)}
22
- <input name="${escapeHtml(field.name)}" type="${field.type ?? 'text'}" required>
23
- </label>`).join('');
24
- return `<!doctype html>
25
- <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width">
26
- <title>Connect ${escapeHtml(auth.service)}</title>
27
- <style>body{font:16px system-ui;max-width:34rem;margin:4rem auto;padding:0 1rem;color:#202124}form{display:grid;gap:1rem}label{display:grid;gap:.4rem}input,button{font:inherit;padding:.7rem}button{color:white;background:${escapeHtml(auth.accent ?? '#444')};border:0;border-radius:.3rem}.error{color:#b3261e}</style>
28
- </head><body><h1>Connect ${escapeHtml(auth.service)}</h1>
29
- ${options.error ? `<p class="error">${escapeHtml(options.error)}</p>` : ''}
30
- <form method="post">${fields}
31
- <input type="hidden" name="oauthReq" value="${escapeHtml(encodeOauthRequest(options.oauthReq))}">
32
- <button type="submit">Authorize</button></form>
33
- ${auth.privacyNote ? `<p>${escapeHtml(auth.privacyNote)}</p>` : ''}
34
- </body></html>`;
35
- }
36
-
37
- function messageOf(error: unknown): string {
38
- return error instanceof Error ? error.message : String(error);
39
- }
40
-
41
- /** Serve the connector's GET login form and POST authorization completion. */
42
- export async function handleAuthorize<Props>(
43
- request: Request,
44
- env: {
45
- OAUTH_PROVIDER: {
46
- parseAuthRequest(request: Request): Promise<unknown>;
47
- completeAuthorization(input: unknown): Promise<{ redirectTo: string }>;
48
- };
49
- },
50
- auth: ConnectorAuth<Props>,
51
- ): Promise<Response> {
52
- if (request.method === 'GET') {
53
- const oauthReq = await env.OAUTH_PROVIDER.parseAuthRequest(request);
54
- return new Response(renderLoginPage(auth, { oauthReq }), {
55
- headers: { 'content-type': 'text/html' },
56
- });
57
- }
58
-
59
- const formData = await request.formData();
60
- const encodedOauthReq = formData.get('oauthReq');
61
- const oauthReq = typeof encodedOauthReq === 'string'
62
- ? JSON.parse(atob(encodedOauthReq))
63
- : undefined;
64
- const fields = Object.fromEntries(auth.fields.map((field) => {
65
- const value = formData.get(field.name);
66
- return [field.name, typeof value === 'string' ? value : ''];
67
- }));
68
-
69
- try {
70
- const props = await auth.login(fields, env);
71
- const firstField = auth.fields[0];
72
- const userId = auth.userId ?? (firstField ? fields[firstField.name] : 'public');
73
- const { redirectTo } = await env.OAUTH_PROVIDER.completeAuthorization({
74
- request: oauthReq,
75
- userId,
76
- scope: [],
77
- metadata: {},
78
- props,
79
- });
80
- return Response.redirect(redirectTo, 302);
81
- } catch (error) {
82
- return new Response(renderLoginPage(auth, { oauthReq, error: messageOf(error) }), {
83
- status: 200,
84
- headers: { 'content-type': 'text/html' },
85
- });
86
- }
87
- }