@astrasyncai/verification-gateway 5.12.0 → 5.13.0
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/adapters/express.js +36 -10
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +36 -10
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.js +26 -9
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +26 -9
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.js +36 -10
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +36 -10
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.js +26 -9
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +26 -9
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +1 -1
- package/dist/agent/index.mjs.map +1 -1
- package/dist/bin/astrasync-claude-hook.js +26 -9
- package/dist/bin/astrasync-codex-hook.js +26 -9
- package/dist/bin/astrasync-guard.js +26 -9
- package/dist/bin/astrasync.js +26 -9
- package/dist/browser/background.js +26 -9
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +26 -9
- package/dist/browser/background.mjs.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/codex/index.js +26 -9
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +26 -9
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +26 -9
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +26 -9
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.js +1 -1
- package/dist/edge-config.js.map +1 -1
- package/dist/edge-config.mjs +1 -1
- package/dist/edge-config.mjs.map +1 -1
- package/dist/edge-core/index.js +26 -9
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +26 -9
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +26 -9
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +26 -9
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/index.d.mts +2 -12
- package/dist/index.d.ts +2 -12
- package/dist/index.js +36 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -10
- package/dist/index.mjs.map +1 -1
- package/dist/registration/index.js +1 -1
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +1 -1
- package/dist/registration/index.mjs.map +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +1 -1
- package/dist/transport/index.mjs.map +1 -1
- package/dist/verify.d.mts +0 -10
- package/dist/verify.d.ts +0 -10
- package/dist/verify.js +36 -10
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +36 -10
- package/dist/verify.mjs.map +1 -1
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "5.
|
|
2
|
+
var SDK_VERSION = "5.13.0";
|
|
3
3
|
|
|
4
4
|
// src/http.ts
|
|
5
5
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -209,7 +209,7 @@ var DEFAULT_CONFIG = {
|
|
|
209
209
|
};
|
|
210
210
|
var initCheckPerformed = false;
|
|
211
211
|
var deprecationWarningShown = false;
|
|
212
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
212
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
213
213
|
initCheckPerformed = true;
|
|
214
214
|
try {
|
|
215
215
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -227,7 +227,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
227
227
|
);
|
|
228
228
|
}
|
|
229
229
|
if (apiKey) {
|
|
230
|
-
const
|
|
230
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
231
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
231
232
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
232
233
|
});
|
|
233
234
|
if (selfCheck.status === 401) {
|
|
@@ -239,6 +240,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
239
240
|
console.error(message);
|
|
240
241
|
} else if (selfCheck.ok) {
|
|
241
242
|
const body = await selfCheck.json().catch(() => ({}));
|
|
243
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
244
|
+
const message = `[VerificationGateway] the configured AstraSync API key cannot verify for this endpoint (${body.counterparty.message ?? "endpoint not found or owned by another account"}). Every inbound agent will be turned away until the key or counterparty is corrected.`;
|
|
245
|
+
if (strictInit) {
|
|
246
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
247
|
+
}
|
|
248
|
+
console.error(message);
|
|
249
|
+
}
|
|
242
250
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
243
251
|
console.warn(
|
|
244
252
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -377,11 +385,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
377
385
|
const isMisconfig = source === "merchant_misconfig";
|
|
378
386
|
const urls = options.urls;
|
|
379
387
|
const guidance = isMisconfig ? {
|
|
380
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
388
|
+
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, rotated, or belongs to another account). Your identity and the AstraSync platform are fine \u2014 contact the site operator. Retrying will not help.",
|
|
381
389
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
382
390
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
383
391
|
steps: [
|
|
384
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
392
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
385
393
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
386
394
|
]
|
|
387
395
|
} : isApiError ? {
|
|
@@ -593,12 +601,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
593
601
|
};
|
|
594
602
|
}
|
|
595
603
|
if (!response.ok) {
|
|
596
|
-
|
|
604
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
605
|
+
if (response.status === 401 || keyMismatch) {
|
|
597
606
|
return {
|
|
598
607
|
success: false,
|
|
599
608
|
error: data.message || data.error || "Integration API key rejected",
|
|
600
609
|
misconfig: true,
|
|
601
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
610
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
602
611
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
603
612
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
604
613
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -631,14 +640,22 @@ async function verify(config, request, options) {
|
|
|
631
640
|
mergedConfig.apiBaseUrl,
|
|
632
641
|
mergedConfig.debug,
|
|
633
642
|
true,
|
|
634
|
-
mergedConfig.apiKey
|
|
643
|
+
mergedConfig.apiKey,
|
|
644
|
+
{
|
|
645
|
+
id: mergedConfig.counterpartyId,
|
|
646
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
647
|
+
}
|
|
635
648
|
);
|
|
636
649
|
} else {
|
|
637
650
|
void performInitCheck(
|
|
638
651
|
mergedConfig.apiBaseUrl,
|
|
639
652
|
mergedConfig.debug,
|
|
640
653
|
false,
|
|
641
|
-
mergedConfig.apiKey
|
|
654
|
+
mergedConfig.apiKey,
|
|
655
|
+
{
|
|
656
|
+
id: mergedConfig.counterpartyId,
|
|
657
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
658
|
+
}
|
|
642
659
|
);
|
|
643
660
|
}
|
|
644
661
|
}
|
|
@@ -827,6 +844,7 @@ async function recordDecision(config, sessionId, decision, reason) {
|
|
|
827
844
|
}).catch(() => {
|
|
828
845
|
});
|
|
829
846
|
}
|
|
847
|
+
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
830
848
|
async function fetchRoutes(config, counterpartyId) {
|
|
831
849
|
if (!counterpartyId) return null;
|
|
832
850
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -839,7 +857,15 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
839
857
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
|
|
840
858
|
{ method: "GET", headers }
|
|
841
859
|
);
|
|
842
|
-
if (!response.ok)
|
|
860
|
+
if (!response.ok) {
|
|
861
|
+
if ((response.status === 401 || response.status === 403 || response.status === 404) && !refusedPolicyReads.has(counterpartyId)) {
|
|
862
|
+
refusedPolicyReads.add(counterpartyId);
|
|
863
|
+
console.error(
|
|
864
|
+
`[VerificationGateway] the configured API key cannot read the route policy for ${counterpartyId} (HTTP ${response.status}). The key belongs to an account that does not own this endpoint, or the counterpartyId is wrong. The gateway is in PASS-THROUGH mode: no agent is being verified.`
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
843
869
|
const body = await response.json();
|
|
844
870
|
return body.data?.routes ?? [];
|
|
845
871
|
} catch {
|