@agentconnect.md/setup 1.61.0-rc.205 → 1.61.0-rc.206
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.
- package/dist/index.js +27 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45151,8 +45151,8 @@ function createRemoteJWKSet(url, options) {
|
|
|
45151
45151
|
/** Google Chat credential validation shared by the Setup Server and the Control Plane (google-chat-integration.md §3). */
|
|
45152
45152
|
/** Google's fixed OAuth token endpoint; the key's own `token_uri` is never followed. */
|
|
45153
45153
|
const GOOGLE_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
|
|
45154
|
-
/** The one bounded read that proves the credential; nothing is ever posted. */
|
|
45155
|
-
const GOOGLE_CHAT_PROBE_URL = `https://chat.googleapis.com/v1/spaces?pageSize=
|
|
45154
|
+
/** The one bounded read that proves the credential, and shows which Workspace customers own the named Spaces the app is in (§10.3); nothing is ever posted. */
|
|
45155
|
+
const GOOGLE_CHAT_PROBE_URL = `https://chat.googleapis.com/v1/spaces?pageSize=100&filter=${encodeURIComponent("spaceType = \"SPACE\"")}`;
|
|
45156
45156
|
/** App authentication only: no user impersonation and no domain-wide delegation (§3). */
|
|
45157
45157
|
const GOOGLE_CHAT_BOT_SCOPE = "https://www.googleapis.com/auth/chat.bot";
|
|
45158
45158
|
/** Read-only scope for resolving the key's own project number; a `chat.bot` token cannot read it. */
|
|
@@ -45268,10 +45268,14 @@ async function probeGoogleChatCredential(key, fetchImpl, now = () => /* @__PURE_
|
|
|
45268
45268
|
} catch {
|
|
45269
45269
|
return unreachable("the Google Chat API");
|
|
45270
45270
|
}
|
|
45271
|
-
if (chatResponse.ok)
|
|
45272
|
-
|
|
45273
|
-
|
|
45274
|
-
|
|
45271
|
+
if (chatResponse.ok) {
|
|
45272
|
+
const customerId = soleCustomerOf(await readJson(chatResponse));
|
|
45273
|
+
return {
|
|
45274
|
+
status: "ok",
|
|
45275
|
+
message: `${key.clientEmail} authenticated to the Google Chat API as the project's Chat app`,
|
|
45276
|
+
...customerId ? { customerId } : {}
|
|
45277
|
+
};
|
|
45278
|
+
}
|
|
45275
45279
|
if (chatResponse.status >= 500 || chatResponse.status === 429) return unavailable("the Google Chat API", chatResponse.status);
|
|
45276
45280
|
const reason = detail((await readJson(chatResponse))?.error?.message) ?? "no details";
|
|
45277
45281
|
if (chatResponse.status === 401) return {
|
|
@@ -45354,8 +45358,23 @@ async function checkGoogleChatApp(input, fetchImpl, now = () => /* @__PURE__ */
|
|
|
45354
45358
|
status: "ok",
|
|
45355
45359
|
key: checked.key,
|
|
45356
45360
|
projectNumber: resolved.projectNumber,
|
|
45357
|
-
message: probe.message
|
|
45358
|
-
|
|
45361
|
+
message: probe.message,
|
|
45362
|
+
...probe.customerId ? { customerId: probe.customerId } : {}
|
|
45363
|
+
};
|
|
45364
|
+
}
|
|
45365
|
+
/** The bare id of the one `customers/…` every listed named Space carries; undefined for none, several, or a list with more pages. */
|
|
45366
|
+
function soleCustomerOf(body) {
|
|
45367
|
+
if (!body || body.nextPageToken) return void 0;
|
|
45368
|
+
const spaces = Array.isArray(body.spaces) ? body.spaces : [];
|
|
45369
|
+
const customers = /* @__PURE__ */ new Set();
|
|
45370
|
+
for (const space of spaces) {
|
|
45371
|
+
const entry = typeof space === "object" && space !== null ? space : void 0;
|
|
45372
|
+
if (entry?.spaceType !== "SPACE") continue;
|
|
45373
|
+
const customer = typeof entry.customer === "string" ? /^customers\/([A-Za-z0-9_-]{1,128})$/.exec(entry.customer)?.[1] : void 0;
|
|
45374
|
+
if (!customer) return void 0;
|
|
45375
|
+
customers.add(customer);
|
|
45376
|
+
}
|
|
45377
|
+
return customers.size === 1 ? [...customers][0] : void 0;
|
|
45359
45378
|
}
|
|
45360
45379
|
/** One app-authenticated access token for `scope`, from Google's fixed token endpoint. */
|
|
45361
45380
|
async function mintAccessToken(key, scope, fetchImpl, now) {
|