@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/verify.d.mts
CHANGED
|
@@ -79,16 +79,6 @@ interface ReportAttemptOptions {
|
|
|
79
79
|
retried: boolean;
|
|
80
80
|
}) => void;
|
|
81
81
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Fetch the per-route policy for an endpoint from the AstraSync backend.
|
|
84
|
-
* v2.9.7 moved policy authority into the dashboard — the SDK no longer
|
|
85
|
-
* accepts `routes` from merchant-side source code, it fetches them from
|
|
86
|
-
* here on init (and refreshes periodically).
|
|
87
|
-
*
|
|
88
|
-
* Returns `null` when the request fails for any reason — the caller decides
|
|
89
|
-
* how to fall back (the middleware allows-all when no policy is loaded so
|
|
90
|
-
* a misconfigured init doesn't take down the merchant's API).
|
|
91
|
-
*/
|
|
92
82
|
declare function fetchRoutes(config: GatewayConfig, counterpartyId: string): Promise<RouteAccessConfigShape[] | null>;
|
|
93
83
|
/**
|
|
94
84
|
* Minimal shape of an EndpointRoute as the SDK consumes it. Mirrors the
|
package/dist/verify.d.ts
CHANGED
|
@@ -79,16 +79,6 @@ interface ReportAttemptOptions {
|
|
|
79
79
|
retried: boolean;
|
|
80
80
|
}) => void;
|
|
81
81
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Fetch the per-route policy for an endpoint from the AstraSync backend.
|
|
84
|
-
* v2.9.7 moved policy authority into the dashboard — the SDK no longer
|
|
85
|
-
* accepts `routes` from merchant-side source code, it fetches them from
|
|
86
|
-
* here on init (and refreshes periodically).
|
|
87
|
-
*
|
|
88
|
-
* Returns `null` when the request fails for any reason — the caller decides
|
|
89
|
-
* how to fall back (the middleware allows-all when no policy is loaded so
|
|
90
|
-
* a misconfigured init doesn't take down the merchant's API).
|
|
91
|
-
*/
|
|
92
82
|
declare function fetchRoutes(config: GatewayConfig, counterpartyId: string): Promise<RouteAccessConfigShape[] | null>;
|
|
93
83
|
/**
|
|
94
84
|
* Minimal shape of an EndpointRoute as the SDK consumes it. Mirrors the
|
package/dist/verify.js
CHANGED
|
@@ -37,7 +37,7 @@ __export(verify_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(verify_exports);
|
|
38
38
|
|
|
39
39
|
// src/version.ts
|
|
40
|
-
var SDK_VERSION = "5.
|
|
40
|
+
var SDK_VERSION = "5.13.0";
|
|
41
41
|
|
|
42
42
|
// src/http.ts
|
|
43
43
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -110,7 +110,7 @@ function _resetInitCheck() {
|
|
|
110
110
|
initCheckPerformed = false;
|
|
111
111
|
}
|
|
112
112
|
var deprecationWarningShown = false;
|
|
113
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
113
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
114
114
|
initCheckPerformed = true;
|
|
115
115
|
try {
|
|
116
116
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -128,7 +128,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
128
128
|
);
|
|
129
129
|
}
|
|
130
130
|
if (apiKey) {
|
|
131
|
-
const
|
|
131
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
132
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
132
133
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
133
134
|
});
|
|
134
135
|
if (selfCheck.status === 401) {
|
|
@@ -140,6 +141,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
140
141
|
console.error(message);
|
|
141
142
|
} else if (selfCheck.ok) {
|
|
142
143
|
const body = await selfCheck.json().catch(() => ({}));
|
|
144
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
145
|
+
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.`;
|
|
146
|
+
if (strictInit) {
|
|
147
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
148
|
+
}
|
|
149
|
+
console.error(message);
|
|
150
|
+
}
|
|
143
151
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
144
152
|
console.warn(
|
|
145
153
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -284,11 +292,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
284
292
|
const isMisconfig = source === "merchant_misconfig";
|
|
285
293
|
const urls = options.urls;
|
|
286
294
|
const guidance = isMisconfig ? {
|
|
287
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
295
|
+
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.",
|
|
288
296
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
289
297
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
290
298
|
steps: [
|
|
291
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
299
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
292
300
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
293
301
|
]
|
|
294
302
|
} : isApiError ? {
|
|
@@ -500,12 +508,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
500
508
|
};
|
|
501
509
|
}
|
|
502
510
|
if (!response.ok) {
|
|
503
|
-
|
|
511
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
512
|
+
if (response.status === 401 || keyMismatch) {
|
|
504
513
|
return {
|
|
505
514
|
success: false,
|
|
506
515
|
error: data.message || data.error || "Integration API key rejected",
|
|
507
516
|
misconfig: true,
|
|
508
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
517
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
509
518
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
510
519
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
511
520
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -538,14 +547,22 @@ async function verify(config, request, options) {
|
|
|
538
547
|
mergedConfig.apiBaseUrl,
|
|
539
548
|
mergedConfig.debug,
|
|
540
549
|
true,
|
|
541
|
-
mergedConfig.apiKey
|
|
550
|
+
mergedConfig.apiKey,
|
|
551
|
+
{
|
|
552
|
+
id: mergedConfig.counterpartyId,
|
|
553
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
554
|
+
}
|
|
542
555
|
);
|
|
543
556
|
} else {
|
|
544
557
|
void performInitCheck(
|
|
545
558
|
mergedConfig.apiBaseUrl,
|
|
546
559
|
mergedConfig.debug,
|
|
547
560
|
false,
|
|
548
|
-
mergedConfig.apiKey
|
|
561
|
+
mergedConfig.apiKey,
|
|
562
|
+
{
|
|
563
|
+
id: mergedConfig.counterpartyId,
|
|
564
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
565
|
+
}
|
|
549
566
|
);
|
|
550
567
|
}
|
|
551
568
|
}
|
|
@@ -776,6 +793,7 @@ async function reportAttempt(config, report, options = {}) {
|
|
|
776
793
|
timer.unref?.();
|
|
777
794
|
}
|
|
778
795
|
var ATTEMPT_REPORT_MAX_RETRY_DELAY_MS = 2e3;
|
|
796
|
+
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
779
797
|
async function fetchRoutes(config, counterpartyId) {
|
|
780
798
|
if (!counterpartyId) return null;
|
|
781
799
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -788,7 +806,15 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
788
806
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
|
|
789
807
|
{ method: "GET", headers }
|
|
790
808
|
);
|
|
791
|
-
if (!response.ok)
|
|
809
|
+
if (!response.ok) {
|
|
810
|
+
if ((response.status === 401 || response.status === 403 || response.status === 404) && !refusedPolicyReads.has(counterpartyId)) {
|
|
811
|
+
refusedPolicyReads.add(counterpartyId);
|
|
812
|
+
console.error(
|
|
813
|
+
`[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.`
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
return null;
|
|
817
|
+
}
|
|
792
818
|
const body = await response.json();
|
|
793
819
|
return body.data?.routes ?? [];
|
|
794
820
|
} catch {
|