mcp-google-multi 6.0.0-beta.2 → 6.0.0-beta.4

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 (181) hide show
  1. package/README.md +5 -5
  2. package/dist/accounts.d.ts +20 -4
  3. package/dist/accounts.js +68 -44
  4. package/dist/api-probe.d.ts +5 -0
  5. package/dist/api-probe.js +20 -15
  6. package/dist/arg-normalize.js +19 -38
  7. package/dist/arg-strict.d.ts +7 -0
  8. package/dist/arg-strict.js +38 -28
  9. package/dist/auth.d.ts +5 -4
  10. package/dist/auth.js +16 -23
  11. package/dist/boot-gates.d.ts +26 -0
  12. package/dist/boot-gates.js +36 -0
  13. package/dist/cimd-cache.d.ts +38 -0
  14. package/dist/cimd-cache.js +111 -0
  15. package/dist/client-config.d.ts +2 -2
  16. package/dist/client-config.js +8 -14
  17. package/dist/client.d.ts +32 -2
  18. package/dist/client.js +0 -0
  19. package/dist/compose.d.ts +18 -0
  20. package/dist/compose.js +109 -0
  21. package/dist/config-file.d.ts +13 -0
  22. package/dist/config-file.js +41 -10
  23. package/dist/discover.js +7 -10
  24. package/dist/discovery-client.d.ts +3 -0
  25. package/dist/discovery-client.js +36 -32
  26. package/dist/doctor.d.ts +9 -5
  27. package/dist/doctor.js +119 -29
  28. package/dist/env-load.js +2 -5
  29. package/dist/executor.d.ts +3 -0
  30. package/dist/executor.js +6 -6
  31. package/dist/fanout.d.ts +9 -1
  32. package/dist/fanout.js +47 -22
  33. package/dist/fs-atomic.d.ts +8 -0
  34. package/dist/fs-atomic.js +216 -29
  35. package/dist/hint-provider.d.ts +129 -0
  36. package/dist/hint-provider.js +58 -0
  37. package/dist/http-config.d.ts +2 -2
  38. package/dist/http-config.js +3 -7
  39. package/dist/http-transport.d.ts +67 -9
  40. package/dist/http-transport.js +318 -52
  41. package/dist/identity.d.ts +6 -3
  42. package/dist/identity.js +24 -8
  43. package/dist/index.js +76 -160
  44. package/dist/master-key.d.ts +3 -3
  45. package/dist/master-key.js +16 -19
  46. package/dist/mcp-token.d.ts +126 -19
  47. package/dist/mcp-token.js +557 -76
  48. package/dist/metrics-cli.d.ts +1 -1
  49. package/dist/metrics-cli.js +1 -1
  50. package/dist/metrics-tap.js +2 -5
  51. package/dist/migrate-config.d.ts +1 -2
  52. package/dist/migrate-config.js +5 -7
  53. package/dist/net-tuning.js +2 -4
  54. package/dist/oauth-as.d.ts +104 -4
  55. package/dist/oauth-as.js +368 -114
  56. package/dist/oauth-consent.d.ts +10 -0
  57. package/dist/oauth-consent.js +20 -10
  58. package/dist/outbound-allowlist.js +9 -11
  59. package/dist/reauth-hint.d.ts +1 -1
  60. package/dist/reauth-hint.js +11 -10
  61. package/dist/registry-transfer.d.ts +5 -0
  62. package/dist/registry-transfer.js +63 -11
  63. package/dist/registry.d.ts +13 -4
  64. package/dist/registry.js +100 -72
  65. package/dist/scope-catalog.d.ts +16 -0
  66. package/dist/scope-catalog.js +40 -13
  67. package/dist/scope-observability.d.ts +10 -9
  68. package/dist/scope-observability.js +34 -24
  69. package/dist/services.d.ts +18 -10
  70. package/dist/services.js +61 -22
  71. package/dist/ssrf-guard.d.ts +23 -9
  72. package/dist/ssrf-guard.js +106 -78
  73. package/dist/tenant-purge.d.ts +26 -0
  74. package/dist/tenant-purge.js +65 -0
  75. package/dist/token-store.d.ts +20 -2
  76. package/dist/token-store.js +0 -0
  77. package/dist/tools/_coerce.d.ts +4 -4
  78. package/dist/tools/_errors.d.ts +3 -0
  79. package/dist/tools/_errors.js +72 -60
  80. package/dist/tools/_local-files.d.ts +9 -0
  81. package/dist/tools/_local-files.js +22 -8
  82. package/dist/tools/account-wizard.d.ts +13 -3
  83. package/dist/tools/account-wizard.js +107 -56
  84. package/dist/tools/accounts-tool.d.ts +8 -1
  85. package/dist/tools/accounts-tool.js +35 -19
  86. package/dist/tools/admin.d.ts +10 -1
  87. package/dist/tools/admin.js +14 -11
  88. package/dist/tools/analytics.d.ts +10 -1
  89. package/dist/tools/analytics.js +14 -10
  90. package/dist/tools/calendar.d.ts +2 -1
  91. package/dist/tools/calendar.js +19 -18
  92. package/dist/tools/chat.d.ts +10 -1
  93. package/dist/tools/chat.js +12 -8
  94. package/dist/tools/contacts.d.ts +2 -1
  95. package/dist/tools/contacts.js +22 -19
  96. package/dist/tools/docs.d.ts +2 -1
  97. package/dist/tools/docs.js +35 -36
  98. package/dist/tools/drive.d.ts +2 -1
  99. package/dist/tools/drive.js +80 -74
  100. package/dist/tools/forms.d.ts +10 -1
  101. package/dist/tools/forms.js +18 -12
  102. package/dist/tools/generated/_shared.d.ts +2 -1
  103. package/dist/tools/generated/_shared.js +7 -3
  104. package/dist/tools/generated/admin.d.ts +2 -1
  105. package/dist/tools/generated/admin.js +265 -265
  106. package/dist/tools/generated/analytics.d.ts +2 -1
  107. package/dist/tools/generated/analytics.js +125 -125
  108. package/dist/tools/generated/appsmarket.d.ts +2 -1
  109. package/dist/tools/generated/appsmarket.js +5 -5
  110. package/dist/tools/generated/calendar.d.ts +2 -1
  111. package/dist/tools/generated/calendar.js +55 -55
  112. package/dist/tools/generated/chat.d.ts +2 -1
  113. package/dist/tools/generated/chat.js +95 -95
  114. package/dist/tools/generated/classroom.d.ts +2 -1
  115. package/dist/tools/generated/classroom.js +209 -209
  116. package/dist/tools/generated/cloudidentity.d.ts +2 -1
  117. package/dist/tools/generated/cloudidentity.js +133 -133
  118. package/dist/tools/generated/cloudsearch.d.ts +2 -1
  119. package/dist/tools/generated/cloudsearch.js +99 -99
  120. package/dist/tools/generated/contacts.d.ts +2 -1
  121. package/dist/tools/generated/contacts.js +29 -29
  122. package/dist/tools/generated/drive.d.ts +2 -1
  123. package/dist/tools/generated/drive.js +71 -71
  124. package/dist/tools/generated/driveactivity.d.ts +2 -1
  125. package/dist/tools/generated/driveactivity.js +3 -3
  126. package/dist/tools/generated/drivelabels.d.ts +2 -1
  127. package/dist/tools/generated/drivelabels.js +53 -53
  128. package/dist/tools/generated/forms.d.ts +2 -1
  129. package/dist/tools/generated/forms.js +7 -7
  130. package/dist/tools/generated/gmail.d.ts +2 -1
  131. package/dist/tools/generated/gmail.js +117 -117
  132. package/dist/tools/generated/groupsmigration.d.ts +2 -1
  133. package/dist/tools/generated/groupsmigration.js +3 -3
  134. package/dist/tools/generated/groupssettings.d.ts +2 -1
  135. package/dist/tools/generated/groupssettings.js +7 -7
  136. package/dist/tools/generated/index.d.ts +2 -1
  137. package/dist/tools/generated/keep.d.ts +2 -1
  138. package/dist/tools/generated/keep.js +15 -15
  139. package/dist/tools/generated/licensing.d.ts +2 -1
  140. package/dist/tools/generated/licensing.js +15 -15
  141. package/dist/tools/generated/meet.d.ts +2 -1
  142. package/dist/tools/generated/meet.js +27 -27
  143. package/dist/tools/generated/postmaster.d.ts +2 -1
  144. package/dist/tools/generated/postmaster.js +9 -9
  145. package/dist/tools/generated/reseller.d.ts +2 -1
  146. package/dist/tools/generated/reseller.js +35 -35
  147. package/dist/tools/generated/script.d.ts +2 -1
  148. package/dist/tools/generated/script.js +33 -33
  149. package/dist/tools/generated/searchconsole.d.ts +2 -1
  150. package/dist/tools/generated/searchconsole.js +3 -3
  151. package/dist/tools/generated/sheets.d.ts +2 -1
  152. package/dist/tools/generated/sheets.js +15 -15
  153. package/dist/tools/generated/tasks.d.ts +2 -1
  154. package/dist/tools/generated/tasks.js +5 -5
  155. package/dist/tools/generated/vault.d.ts +2 -1
  156. package/dist/tools/generated/vault.js +67 -67
  157. package/dist/tools/generated/workspaceevents.d.ts +2 -1
  158. package/dist/tools/generated/workspaceevents.js +31 -31
  159. package/dist/tools/gmail-mime.d.ts +1 -1
  160. package/dist/tools/gmail-mime.js +7 -12
  161. package/dist/tools/gmail.d.ts +4 -3
  162. package/dist/tools/gmail.js +67 -69
  163. package/dist/tools/google-api.d.ts +2 -3
  164. package/dist/tools/google-api.js +34 -22
  165. package/dist/tools/meet.d.ts +10 -1
  166. package/dist/tools/meet.js +12 -9
  167. package/dist/tools/searchconsole.d.ts +2 -1
  168. package/dist/tools/searchconsole.js +16 -13
  169. package/dist/tools/sheets.d.ts +2 -1
  170. package/dist/tools/sheets.js +35 -32
  171. package/dist/tools/slides.d.ts +10 -1
  172. package/dist/tools/slides.js +16 -10
  173. package/dist/tools/tasks.d.ts +2 -1
  174. package/dist/tools/tasks.js +18 -15
  175. package/dist/trim.d.ts +5 -0
  176. package/dist/trim.js +19 -0
  177. package/dist/usage-metrics.d.ts +23 -0
  178. package/dist/usage-metrics.js +67 -56
  179. package/dist/write-control.d.ts +4 -8
  180. package/dist/write-control.js +13 -6
  181. package/package.json +47 -21
@@ -1,7 +1,7 @@
1
1
  export declare const ACCESS_TTL_DEFAULT = 600;
2
2
  export declare const STATE_TTL_DEFAULT = 600;
3
3
  export declare const CODE_TTL_DEFAULT = 60;
4
- export declare const REPLAY_CAP_DEFAULT = 10000;
4
+ export declare const REPLAY_CAP_DEFAULT = 100000;
5
5
  /** Derive the HS256 secret (32 bytes) from the provisioned MCP_JWT_KEY string. */
6
6
  export declare function jwtSecretFrom(jwtKey: string): Uint8Array;
7
7
  export interface AccessTokenParams {
@@ -9,6 +9,7 @@ export interface AccessTokenParams {
9
9
  secret: Uint8Array;
10
10
  ttlSec?: number;
11
11
  iat: number;
12
+ sub: string;
12
13
  }
13
14
  export declare function signAccessToken(p: AccessTokenParams): Promise<string>;
14
15
  export interface AccessClaims {
@@ -19,63 +20,169 @@ export interface AccessClaims {
19
20
  /** Verify an access token for `/mcp`. Throws on bad sig / aud / iss / exp. */
20
21
  export declare function verifyAccessToken(token: string, base: string, secret: Uint8Array): Promise<AccessClaims>;
21
22
  export interface StatePayload {
22
- flow: 'owner_gate' | 'alias_reauth';
23
+ flow: 'owner_gate' | 'alias_reauth' | 'alias_add';
23
24
  client_id: string;
24
25
  redirect_uri: string;
25
26
  code_challenge: string;
26
27
  client_state?: string;
27
28
  resource: string;
28
29
  alias?: string;
30
+ /** alias_add only: the tenant the new alias binds under. Signed server-side
31
+ * at mint time — never caller-supplied at /authorize or /callback. */
32
+ tenantId?: string;
33
+ /** alias_add only: scope bundles chosen when the link was minted. */
34
+ bundles?: string[];
35
+ /** alias_add only: an opaque value the minting caller chose, signed like
36
+ * tenantId and handed back to its binder (e.g. a server-side link record). */
37
+ nonce?: string;
38
+ /** owner_gate only: base64url sha256 of the browser-binding cookie the
39
+ * Google redirect set; /callback refuses a browser that lacks it. */
40
+ bind?: string;
29
41
  }
30
42
  export interface CodePayload {
31
43
  redirect_uri: string;
32
44
  code_challenge: string;
33
45
  resource: string;
34
- sub: 'owner';
46
+ sub: string;
35
47
  }
36
48
  export declare function signState(payload: StatePayload, base: string, secret: Uint8Array, iat: number, ttlSec?: number): Promise<string>;
37
- export declare function verifyState(token: string, base: string, secret: Uint8Array): Promise<StatePayload & {
49
+ export declare function verifyState(token: string, base: string, secret: Uint8Array, nowSec?: number): Promise<StatePayload & {
38
50
  jti: string;
51
+ exp: number;
39
52
  }>;
53
+ /** A re-auth link is handed out in a tool error, so it has to survive until
54
+ * the user clicks it; an hour, not the 10-minute state TTL. */
55
+ export declare const REAUTH_LINK_TTL_SEC = 3600;
56
+ /** Query string of a server-issued alias_reauth link: the alias, an expiry and
57
+ * an HMAC over both. Synchronous, so the error hints that carry it stay so. */
58
+ export declare function signReauthLink(base: string, secret: Uint8Array, alias: string, nowSec: number): string;
59
+ /** The alias a link was issued for, or null when it is missing, forged or expired. */
60
+ export declare function verifyReauthLink(base: string, secret: Uint8Array, params: {
61
+ alias: string;
62
+ exp: string;
63
+ sig: string;
64
+ }, nowSec: number): string | null;
40
65
  /** A pending-authorization artifact for the DCR consent interstitial (same
41
66
  * shape as `state`, distinct purpose so the two can't be confused). */
42
67
  export declare function signPending(payload: StatePayload, base: string, secret: Uint8Array, iat: number, ttlSec?: number): Promise<string>;
43
- export declare function verifyPending(token: string, base: string, secret: Uint8Array): Promise<StatePayload & {
68
+ export declare function verifyPending(token: string, base: string, secret: Uint8Array, nowSec?: number): Promise<StatePayload & {
44
69
  jti: string;
70
+ exp: number;
45
71
  }>;
46
72
  export declare function signAuthzCode(payload: CodePayload, base: string, secret: Uint8Array, iat: number, ttlSec?: number): Promise<string>;
47
- export declare function verifyAuthzCode(token: string, base: string, secret: Uint8Array): Promise<CodePayload & {
73
+ export declare function verifyAuthzCode(token: string, base: string, secret: Uint8Array, nowSec?: number): Promise<CodePayload & {
48
74
  jti: string;
75
+ exp: number;
49
76
  }>;
77
+ /** `full`: there is no room without forgetting a jti that is still live. */
78
+ export type ReplaySpend = 'ok' | 'replay' | 'full';
50
79
  export declare class ReplayGuard {
51
80
  private readonly cap;
52
81
  private readonly seen;
82
+ private earliest;
83
+ private sweptAt;
53
84
  constructor(cap?: number);
54
- /** Record a jti as spent. Returns false if it was already spent (replay). */
85
+ /** Hold a slot for an artifact about to be handed out, so its spend can
86
+ * never meet a full guard. The flood then lands where the artifact is
87
+ * minted, and refusing there loses nothing. */
88
+ reserve(jti: string, ttlMs: number, nowMs: number): 'ok' | 'full';
89
+ /** Record a jti as spent. A full guard refuses instead of evicting a live
90
+ * jti: a flood of spends would otherwise make a spent artifact usable again,
91
+ * such as a callback the browser binding refused. `artifactExpMs`
92
+ * keeps the record alive as long as the artifact itself, even when the clock
93
+ * stepped back between its signing and this spend. */
94
+ spend(jti: string, ttlMs: number, nowMs: number, artifactExpMs?: number): ReplaySpend;
95
+ /** Undo a spend whose next step could not go ahead. The slot stays held, so
96
+ * nothing is forgotten, and the artifact can be spent once more. */
97
+ unspend(jti: string): void;
98
+ /** `spend` as a boolean: false for a replay and for a full guard alike. */
55
99
  consume(jti: string, ttlMs: number, nowMs: number): boolean;
56
100
  get size(): number;
57
- private evictExpired;
101
+ private record;
102
+ private room;
58
103
  }
104
+ /** An earlier release's record, keyed by its live token. */
59
105
  export interface RefreshRecord {
60
- sub: 'owner';
106
+ sub: string;
61
107
  issuedAt: number;
62
108
  family: string;
63
109
  }
64
110
  /**
65
- * Persisted (encrypted under MASTER_KEY) opaque refresh-token store. Rotates on
66
- * every use (a stolen token is usable at most once), and detects REUSE of a
67
- * rotated-away token as theft: the whole token family is revoked (#7 / C14).
68
- * All read-modify-write goes through a file lock so concurrent stdio+HTTP
69
- * processes can't lost-update or double-spend (#12).
111
+ * The family tag of a refresh token this `masterKey`'s store minted, or null
112
+ * for anything else. Derives the key once; the returned function does no I/O,
113
+ * so a host can key a pre-auth rate limit on it.
114
+ */
115
+ export declare function refreshFamilyTagger(masterKey: string): (token: string) => string | null;
116
+ /** Boot check for a refresh store file: returns when it is absent or this
117
+ * release can read it; throws when it does not decrypt under `masterKey`
118
+ * (E_REFRESH_STORE_UNREADABLE) or a newer release wrote it
119
+ * (E_REFRESH_STORE_FORMAT). */
120
+ export declare function assertRefreshStoreReadable(file: string, masterKey: string): void;
121
+ export interface RefreshStoreOptions {
122
+ /** Absolute family lifetime in seconds, counted from the sign-in. Unset: unlimited. */
123
+ maxAgeSec?: number;
124
+ /** Idle lifetime in seconds, counted from the last issue or rotation. Unset: unlimited. */
125
+ idleSec?: number;
126
+ /** Max live refresh-token families per subject (both formats). Unset:
127
+ * unlimited (default; the single-owner server passes none). When issuing a
128
+ * new family would put a subject over this, that subject's own
129
+ * least-recently-used family is dropped (by its last issue or rotation
130
+ * time) until it fits; a dropped family behaves exactly like a revoked
131
+ * one. Only the subject signing in ever triggers it, and only its own
132
+ * families are ever touched. */
133
+ maxFamiliesPerSub?: number;
134
+ /** Server-side log for a revoked, dropped or expired family. Never given a token or a subject. */
135
+ log?: (line: string) => void;
136
+ }
137
+ /**
138
+ * Persisted (encrypted under MASTER_KEY) refresh-token store. Rotates on every
139
+ * use, and a token carries its family and generation under a MAC, so
140
+ * presenting any generation the family has rotated past is REUSE: the family
141
+ * is revoked for the rest of its life. The store keeps one
142
+ * record per family, whatever its rotation count. Every read-modify-write goes
143
+ * through a file lock so concurrent stdio+HTTP processes can't lost-update or
144
+ * double-spend. See docs/internals.md.
70
145
  */
71
146
  export declare class RefreshStore {
72
147
  private readonly path;
73
148
  private readonly masterKey;
74
- constructor(path: string, masterKey: string);
149
+ private readonly log;
150
+ private readonly maxAgeMs;
151
+ private readonly idleMs;
152
+ private readonly maxFamiliesPerSub;
153
+ private macKey;
154
+ private legacyEmpty;
155
+ constructor(path: string, masterKey: string, options?: RefreshStoreOptions);
156
+ private get timed();
157
+ private live;
158
+ /** Drop expired sessions in both formats; the count of those dropped. */
159
+ private prune;
160
+ /** A session written while the clock ran ahead would otherwise outlive its
161
+ * limit by the size of the jump. */
162
+ private clamp;
163
+ private key;
164
+ /** With `nowMs` (every issue and rotation), also clamps and prunes. */
75
165
  private load;
76
166
  private save;
77
- issue(nowMs: number, family?: string): string;
78
- /** Rotate a presented refresh token; null if unknown OR if the presented
79
- * token was already rotated away (reuse => the family is revoked). */
80
- rotate(oldToken: string, nowMs: number): string | null;
167
+ private emit;
168
+ private enforceFamilyCap;
169
+ private newFamilyId;
170
+ issue(nowMs: number, sub: string): string;
171
+ /** Rotate a presented refresh token; null if it is unknown, malformed, or
172
+ * rotated away (reuse => the family is revoked). The record's sub is copied
173
+ * forward and returned so the caller can mint the matching access token
174
+ * without trusting anything client-supplied.
175
+ *
176
+ * `accept` (optional) is called inside the store lock, before any mutation,
177
+ * with the record's sub. false: every session of that sub is dropped and
178
+ * null returned. A throw: nothing is written and the error propagates, so
179
+ * the presented token stays valid. Absent: unchanged. */
180
+ rotate(oldToken: string, nowMs: number, accept?: (sub: string) => boolean): {
181
+ token: string;
182
+ sub: string;
183
+ } | null;
184
+ /** Drop every session minted under `sub`, in both formats (linear scan under
185
+ * the store lock); the save then drops the earlier-release spent entries of
186
+ * the families that died with them. Returns the number of sessions dropped. */
187
+ purgeTenant(sub: string): number;
81
188
  }