@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/nextjs.mjs
CHANGED
|
@@ -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}`;
|
|
@@ -157,7 +157,7 @@ var DEFAULT_CONFIG = {
|
|
|
157
157
|
};
|
|
158
158
|
var initCheckPerformed = false;
|
|
159
159
|
var deprecationWarningShown = false;
|
|
160
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
160
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
161
161
|
initCheckPerformed = true;
|
|
162
162
|
try {
|
|
163
163
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -175,7 +175,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
177
|
if (apiKey) {
|
|
178
|
-
const
|
|
178
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
179
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
179
180
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
180
181
|
});
|
|
181
182
|
if (selfCheck.status === 401) {
|
|
@@ -187,6 +188,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
187
188
|
console.error(message);
|
|
188
189
|
} else if (selfCheck.ok) {
|
|
189
190
|
const body = await selfCheck.json().catch(() => ({}));
|
|
191
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
192
|
+
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.`;
|
|
193
|
+
if (strictInit) {
|
|
194
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
195
|
+
}
|
|
196
|
+
console.error(message);
|
|
197
|
+
}
|
|
190
198
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
191
199
|
console.warn(
|
|
192
200
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -325,11 +333,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
325
333
|
const isMisconfig = source === "merchant_misconfig";
|
|
326
334
|
const urls = options.urls;
|
|
327
335
|
const guidance = isMisconfig ? {
|
|
328
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
336
|
+
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.",
|
|
329
337
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
330
338
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
331
339
|
steps: [
|
|
332
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
340
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
333
341
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
334
342
|
]
|
|
335
343
|
} : isApiError ? {
|
|
@@ -541,12 +549,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
541
549
|
};
|
|
542
550
|
}
|
|
543
551
|
if (!response.ok) {
|
|
544
|
-
|
|
552
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
553
|
+
if (response.status === 401 || keyMismatch) {
|
|
545
554
|
return {
|
|
546
555
|
success: false,
|
|
547
556
|
error: data.message || data.error || "Integration API key rejected",
|
|
548
557
|
misconfig: true,
|
|
549
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
558
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
550
559
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
551
560
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
552
561
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -579,14 +588,22 @@ async function verify(config, request, options) {
|
|
|
579
588
|
mergedConfig.apiBaseUrl,
|
|
580
589
|
mergedConfig.debug,
|
|
581
590
|
true,
|
|
582
|
-
mergedConfig.apiKey
|
|
591
|
+
mergedConfig.apiKey,
|
|
592
|
+
{
|
|
593
|
+
id: mergedConfig.counterpartyId,
|
|
594
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
595
|
+
}
|
|
583
596
|
);
|
|
584
597
|
} else {
|
|
585
598
|
void performInitCheck(
|
|
586
599
|
mergedConfig.apiBaseUrl,
|
|
587
600
|
mergedConfig.debug,
|
|
588
601
|
false,
|
|
589
|
-
mergedConfig.apiKey
|
|
602
|
+
mergedConfig.apiKey,
|
|
603
|
+
{
|
|
604
|
+
id: mergedConfig.counterpartyId,
|
|
605
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
606
|
+
}
|
|
590
607
|
);
|
|
591
608
|
}
|
|
592
609
|
}
|
|
@@ -762,6 +779,7 @@ async function verify(config, request, options) {
|
|
|
762
779
|
}
|
|
763
780
|
return result;
|
|
764
781
|
}
|
|
782
|
+
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
765
783
|
async function fetchRoutes(config, counterpartyId) {
|
|
766
784
|
if (!counterpartyId) return null;
|
|
767
785
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -774,7 +792,15 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
774
792
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
|
|
775
793
|
{ method: "GET", headers }
|
|
776
794
|
);
|
|
777
|
-
if (!response.ok)
|
|
795
|
+
if (!response.ok) {
|
|
796
|
+
if ((response.status === 401 || response.status === 403 || response.status === 404) && !refusedPolicyReads.has(counterpartyId)) {
|
|
797
|
+
refusedPolicyReads.add(counterpartyId);
|
|
798
|
+
console.error(
|
|
799
|
+
`[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.`
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
778
804
|
const body = await response.json();
|
|
779
805
|
return body.data?.routes ?? [];
|
|
780
806
|
} catch {
|