@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
package/dist/adapters/express.js
CHANGED
|
@@ -26,7 +26,7 @@ __export(express_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(express_exports);
|
|
27
27
|
|
|
28
28
|
// src/version.ts
|
|
29
|
-
var SDK_VERSION = "5.
|
|
29
|
+
var SDK_VERSION = "5.13.0";
|
|
30
30
|
|
|
31
31
|
// src/http.ts
|
|
32
32
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -236,7 +236,7 @@ var DEFAULT_CONFIG = {
|
|
|
236
236
|
};
|
|
237
237
|
var initCheckPerformed = false;
|
|
238
238
|
var deprecationWarningShown = false;
|
|
239
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
239
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
240
240
|
initCheckPerformed = true;
|
|
241
241
|
try {
|
|
242
242
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -254,7 +254,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
254
254
|
);
|
|
255
255
|
}
|
|
256
256
|
if (apiKey) {
|
|
257
|
-
const
|
|
257
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
258
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
258
259
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
259
260
|
});
|
|
260
261
|
if (selfCheck.status === 401) {
|
|
@@ -266,6 +267,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
266
267
|
console.error(message);
|
|
267
268
|
} else if (selfCheck.ok) {
|
|
268
269
|
const body = await selfCheck.json().catch(() => ({}));
|
|
270
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
271
|
+
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.`;
|
|
272
|
+
if (strictInit) {
|
|
273
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
274
|
+
}
|
|
275
|
+
console.error(message);
|
|
276
|
+
}
|
|
269
277
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
270
278
|
console.warn(
|
|
271
279
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -404,11 +412,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
404
412
|
const isMisconfig = source === "merchant_misconfig";
|
|
405
413
|
const urls = options.urls;
|
|
406
414
|
const guidance = isMisconfig ? {
|
|
407
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
415
|
+
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.",
|
|
408
416
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
409
417
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
410
418
|
steps: [
|
|
411
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
419
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
412
420
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
413
421
|
]
|
|
414
422
|
} : isApiError ? {
|
|
@@ -620,12 +628,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
620
628
|
};
|
|
621
629
|
}
|
|
622
630
|
if (!response.ok) {
|
|
623
|
-
|
|
631
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
632
|
+
if (response.status === 401 || keyMismatch) {
|
|
624
633
|
return {
|
|
625
634
|
success: false,
|
|
626
635
|
error: data.message || data.error || "Integration API key rejected",
|
|
627
636
|
misconfig: true,
|
|
628
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
637
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
629
638
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
630
639
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
631
640
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -658,14 +667,22 @@ async function verify(config, request, options) {
|
|
|
658
667
|
mergedConfig.apiBaseUrl,
|
|
659
668
|
mergedConfig.debug,
|
|
660
669
|
true,
|
|
661
|
-
mergedConfig.apiKey
|
|
670
|
+
mergedConfig.apiKey,
|
|
671
|
+
{
|
|
672
|
+
id: mergedConfig.counterpartyId,
|
|
673
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
674
|
+
}
|
|
662
675
|
);
|
|
663
676
|
} else {
|
|
664
677
|
void performInitCheck(
|
|
665
678
|
mergedConfig.apiBaseUrl,
|
|
666
679
|
mergedConfig.debug,
|
|
667
680
|
false,
|
|
668
|
-
mergedConfig.apiKey
|
|
681
|
+
mergedConfig.apiKey,
|
|
682
|
+
{
|
|
683
|
+
id: mergedConfig.counterpartyId,
|
|
684
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
685
|
+
}
|
|
669
686
|
);
|
|
670
687
|
}
|
|
671
688
|
}
|
|
@@ -854,6 +871,7 @@ async function recordDecision(config, sessionId, decision, reason) {
|
|
|
854
871
|
}).catch(() => {
|
|
855
872
|
});
|
|
856
873
|
}
|
|
874
|
+
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
857
875
|
async function fetchRoutes(config, counterpartyId) {
|
|
858
876
|
if (!counterpartyId) return null;
|
|
859
877
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -866,7 +884,15 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
866
884
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
|
|
867
885
|
{ method: "GET", headers }
|
|
868
886
|
);
|
|
869
|
-
if (!response.ok)
|
|
887
|
+
if (!response.ok) {
|
|
888
|
+
if ((response.status === 401 || response.status === 403 || response.status === 404) && !refusedPolicyReads.has(counterpartyId)) {
|
|
889
|
+
refusedPolicyReads.add(counterpartyId);
|
|
890
|
+
console.error(
|
|
891
|
+
`[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.`
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
return null;
|
|
895
|
+
}
|
|
870
896
|
const body = await response.json();
|
|
871
897
|
return body.data?.routes ?? [];
|
|
872
898
|
} catch {
|