apiblaze 0.19.20 → 0.19.21
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/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -932,7 +932,7 @@ var import_commander = require("commander");
|
|
|
932
932
|
var import_chalk44 = __toESM(require("chalk"));
|
|
933
933
|
|
|
934
934
|
// package.json
|
|
935
|
-
var version = "0.19.
|
|
935
|
+
var version = "0.19.21";
|
|
936
936
|
|
|
937
937
|
// src/index.ts
|
|
938
938
|
init_types();
|
|
@@ -6516,15 +6516,15 @@ async function mintDurableProxyKey(teamId, tenant2) {
|
|
|
6516
6516
|
if (!out?.key) throw new Error("key mint returned no key");
|
|
6517
6517
|
return out.key;
|
|
6518
6518
|
}
|
|
6519
|
-
async function fetchAcceptedMethods(
|
|
6519
|
+
async function fetchAcceptedMethods(teamId, projectId, apiVersion) {
|
|
6520
6520
|
try {
|
|
6521
6521
|
const listing = await admin({
|
|
6522
6522
|
method: "GET",
|
|
6523
|
-
path: `/projects?team_id=${encodeURIComponent(
|
|
6524
|
-
summary: `Read the access policy for ${
|
|
6523
|
+
path: `/projects?team_id=${encodeURIComponent(teamId)}`,
|
|
6524
|
+
summary: `Read the access policy for ${projectId}`
|
|
6525
6525
|
});
|
|
6526
6526
|
const rows = listing?.projects ?? [];
|
|
6527
|
-
const row = rows.find((r) => r.project_id ===
|
|
6527
|
+
const row = rows.find((r) => r.project_id === projectId && r.api_version === apiVersion) ?? rows.find((r) => r.project_id === projectId);
|
|
6528
6528
|
const policy = row?.config?.requests_policy;
|
|
6529
6529
|
if (!policy || policy.mode !== "authenticate") return null;
|
|
6530
6530
|
return Array.isArray(policy.methods) && policy.methods.length ? policy.methods : null;
|
|
@@ -6539,7 +6539,7 @@ async function openServerProxy(project) {
|
|
|
6539
6539
|
const tenant2 = project.tenant || project.projectId;
|
|
6540
6540
|
const me = loadCredentials()?.apiblazeUserId;
|
|
6541
6541
|
const prior = loadApichats().find((a) => a.projectId === project.projectId);
|
|
6542
|
-
const acceptedMethods = await fetchAcceptedMethods(project);
|
|
6542
|
+
const acceptedMethods = await fetchAcceptedMethods(project.teamId, project.projectId, project.apiVersion);
|
|
6543
6543
|
const acceptsApiKey = acceptedMethods === null || acceptedMethods.includes("api_key");
|
|
6544
6544
|
let dpKey = prior?.dpKey;
|
|
6545
6545
|
let consumerAuth = false;
|
|
@@ -6591,6 +6591,8 @@ async function openServerProxy(project) {
|
|
|
6591
6591
|
version: version2,
|
|
6592
6592
|
environment,
|
|
6593
6593
|
mcpHost,
|
|
6594
|
+
teamId: project.teamId,
|
|
6595
|
+
tenant: tenant2,
|
|
6594
6596
|
dpKey,
|
|
6595
6597
|
consumerAuth,
|
|
6596
6598
|
anon: false,
|
|
@@ -6670,14 +6672,31 @@ async function noArgsMenu(opts) {
|
|
|
6670
6672
|
]);
|
|
6671
6673
|
if (mode === "resume") messages = a.messages.slice();
|
|
6672
6674
|
}
|
|
6675
|
+
let savedKey = a.dpKey;
|
|
6676
|
+
let savedConsumerAuth = a.consumerAuth;
|
|
6677
|
+
const resumeTeamId = a.teamId ?? creds?.teamId;
|
|
6678
|
+
if (!a.anon && resumeTeamId) {
|
|
6679
|
+
const methods = await fetchAcceptedMethods(resumeTeamId, a.projectId, a.version);
|
|
6680
|
+
const acceptsApiKey = methods === null || methods.includes("api_key");
|
|
6681
|
+
if (!acceptsApiKey) {
|
|
6682
|
+
savedConsumerAuth = true;
|
|
6683
|
+
savedKey = void 0;
|
|
6684
|
+
await ensureConsumerLogin(resumeTeamId, a.tenant ?? a.projectId);
|
|
6685
|
+
} else if (savedConsumerAuth && !savedKey) {
|
|
6686
|
+
savedConsumerAuth = false;
|
|
6687
|
+
}
|
|
6688
|
+
if (savedConsumerAuth !== a.consumerAuth || savedKey !== a.dpKey) {
|
|
6689
|
+
upsertApichat({ ...a, teamId: resumeTeamId, dpKey: savedKey, consumerAuth: savedConsumerAuth });
|
|
6690
|
+
}
|
|
6691
|
+
}
|
|
6673
6692
|
const p = {
|
|
6674
6693
|
projectId: a.projectId,
|
|
6675
6694
|
version: a.version,
|
|
6676
6695
|
environment: a.environment,
|
|
6677
|
-
dpKey:
|
|
6696
|
+
dpKey: savedKey,
|
|
6678
6697
|
// Carry the door forward — resuming an OAuth-only chat must not fall back to
|
|
6679
6698
|
// looking for a key that was never minted.
|
|
6680
|
-
consumerAuth:
|
|
6699
|
+
consumerAuth: savedConsumerAuth,
|
|
6681
6700
|
mcpHost: a.mcpHost,
|
|
6682
6701
|
proxyUrl: void 0,
|
|
6683
6702
|
anon: a.anon,
|