@astrasyncai/verification-gateway 5.12.0 → 5.14.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 +63 -19
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +63 -19
- 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 +63 -19
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +63 -19
- 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 +53 -18
- package/dist/bin/astrasync-codex-hook.js +53 -18
- package/dist/bin/astrasync-guard.js +53 -18
- package/dist/bin/astrasync.js +54 -19
- package/dist/browser/background.js +53 -18
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +53 -18
- 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 +53 -18
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +53 -18
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +53 -18
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +53 -18
- 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.d.mts +32 -4
- package/dist/edge-core/index.d.ts +32 -4
- package/dist/edge-core/index.js +53 -18
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +53 -18
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +53 -18
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +53 -18
- 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 +63 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -19
- 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.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "5.
|
|
2
|
+
var SDK_VERSION = "5.14.0";
|
|
3
3
|
|
|
4
4
|
// src/http.ts
|
|
5
5
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -72,7 +72,7 @@ function _resetInitCheck() {
|
|
|
72
72
|
initCheckPerformed = false;
|
|
73
73
|
}
|
|
74
74
|
var deprecationWarningShown = false;
|
|
75
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
75
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
76
76
|
initCheckPerformed = true;
|
|
77
77
|
try {
|
|
78
78
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -90,7 +90,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
if (apiKey) {
|
|
93
|
-
const
|
|
93
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
94
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
94
95
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
95
96
|
});
|
|
96
97
|
if (selfCheck.status === 401) {
|
|
@@ -102,6 +103,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
102
103
|
console.error(message);
|
|
103
104
|
} else if (selfCheck.ok) {
|
|
104
105
|
const body = await selfCheck.json().catch(() => ({}));
|
|
106
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
107
|
+
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.`;
|
|
108
|
+
if (strictInit) {
|
|
109
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
110
|
+
}
|
|
111
|
+
console.error(message);
|
|
112
|
+
}
|
|
105
113
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
106
114
|
console.warn(
|
|
107
115
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -246,11 +254,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
246
254
|
const isMisconfig = source === "merchant_misconfig";
|
|
247
255
|
const urls = options.urls;
|
|
248
256
|
const guidance = isMisconfig ? {
|
|
249
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
257
|
+
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.",
|
|
250
258
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
251
259
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
252
260
|
steps: [
|
|
253
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
261
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
254
262
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
255
263
|
]
|
|
256
264
|
} : isApiError ? {
|
|
@@ -462,12 +470,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
462
470
|
};
|
|
463
471
|
}
|
|
464
472
|
if (!response.ok) {
|
|
465
|
-
|
|
473
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
474
|
+
if (response.status === 401 || keyMismatch) {
|
|
466
475
|
return {
|
|
467
476
|
success: false,
|
|
468
477
|
error: data.message || data.error || "Integration API key rejected",
|
|
469
478
|
misconfig: true,
|
|
470
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
479
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
471
480
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
472
481
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
473
482
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -500,14 +509,22 @@ async function verify(config, request, options) {
|
|
|
500
509
|
mergedConfig.apiBaseUrl,
|
|
501
510
|
mergedConfig.debug,
|
|
502
511
|
true,
|
|
503
|
-
mergedConfig.apiKey
|
|
512
|
+
mergedConfig.apiKey,
|
|
513
|
+
{
|
|
514
|
+
id: mergedConfig.counterpartyId,
|
|
515
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
516
|
+
}
|
|
504
517
|
);
|
|
505
518
|
} else {
|
|
506
519
|
void performInitCheck(
|
|
507
520
|
mergedConfig.apiBaseUrl,
|
|
508
521
|
mergedConfig.debug,
|
|
509
522
|
false,
|
|
510
|
-
mergedConfig.apiKey
|
|
523
|
+
mergedConfig.apiKey,
|
|
524
|
+
{
|
|
525
|
+
id: mergedConfig.counterpartyId,
|
|
526
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
527
|
+
}
|
|
511
528
|
);
|
|
512
529
|
}
|
|
513
530
|
}
|
|
@@ -738,6 +755,7 @@ async function reportAttempt(config, report, options = {}) {
|
|
|
738
755
|
timer.unref?.();
|
|
739
756
|
}
|
|
740
757
|
var ATTEMPT_REPORT_MAX_RETRY_DELAY_MS = 2e3;
|
|
758
|
+
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
741
759
|
async function fetchRoutes(config, counterpartyId) {
|
|
742
760
|
if (!counterpartyId) return null;
|
|
743
761
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -750,7 +768,15 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
750
768
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
|
|
751
769
|
{ method: "GET", headers }
|
|
752
770
|
);
|
|
753
|
-
if (!response.ok)
|
|
771
|
+
if (!response.ok) {
|
|
772
|
+
if ((response.status === 401 || response.status === 403 || response.status === 404) && !refusedPolicyReads.has(counterpartyId)) {
|
|
773
|
+
refusedPolicyReads.add(counterpartyId);
|
|
774
|
+
console.error(
|
|
775
|
+
`[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.`
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
754
780
|
const body = await response.json();
|
|
755
781
|
return body.data?.routes ?? [];
|
|
756
782
|
} catch {
|