@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.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(nextjs_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(nextjs_exports);
|
|
37
37
|
|
|
38
38
|
// src/version.ts
|
|
39
|
-
var SDK_VERSION = "5.
|
|
39
|
+
var SDK_VERSION = "5.13.0";
|
|
40
40
|
|
|
41
41
|
// src/http.ts
|
|
42
42
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -194,7 +194,7 @@ var DEFAULT_CONFIG = {
|
|
|
194
194
|
};
|
|
195
195
|
var initCheckPerformed = false;
|
|
196
196
|
var deprecationWarningShown = false;
|
|
197
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
197
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
198
198
|
initCheckPerformed = true;
|
|
199
199
|
try {
|
|
200
200
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -212,7 +212,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
if (apiKey) {
|
|
215
|
-
const
|
|
215
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
216
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
216
217
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
217
218
|
});
|
|
218
219
|
if (selfCheck.status === 401) {
|
|
@@ -224,6 +225,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
224
225
|
console.error(message);
|
|
225
226
|
} else if (selfCheck.ok) {
|
|
226
227
|
const body = await selfCheck.json().catch(() => ({}));
|
|
228
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
229
|
+
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.`;
|
|
230
|
+
if (strictInit) {
|
|
231
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
232
|
+
}
|
|
233
|
+
console.error(message);
|
|
234
|
+
}
|
|
227
235
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
228
236
|
console.warn(
|
|
229
237
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -362,11 +370,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
362
370
|
const isMisconfig = source === "merchant_misconfig";
|
|
363
371
|
const urls = options.urls;
|
|
364
372
|
const guidance = isMisconfig ? {
|
|
365
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
373
|
+
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.",
|
|
366
374
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
367
375
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
368
376
|
steps: [
|
|
369
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
377
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
370
378
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
371
379
|
]
|
|
372
380
|
} : isApiError ? {
|
|
@@ -578,12 +586,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
578
586
|
};
|
|
579
587
|
}
|
|
580
588
|
if (!response.ok) {
|
|
581
|
-
|
|
589
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
590
|
+
if (response.status === 401 || keyMismatch) {
|
|
582
591
|
return {
|
|
583
592
|
success: false,
|
|
584
593
|
error: data.message || data.error || "Integration API key rejected",
|
|
585
594
|
misconfig: true,
|
|
586
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
595
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
587
596
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
588
597
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
589
598
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -616,14 +625,22 @@ async function verify(config, request, options) {
|
|
|
616
625
|
mergedConfig.apiBaseUrl,
|
|
617
626
|
mergedConfig.debug,
|
|
618
627
|
true,
|
|
619
|
-
mergedConfig.apiKey
|
|
628
|
+
mergedConfig.apiKey,
|
|
629
|
+
{
|
|
630
|
+
id: mergedConfig.counterpartyId,
|
|
631
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
632
|
+
}
|
|
620
633
|
);
|
|
621
634
|
} else {
|
|
622
635
|
void performInitCheck(
|
|
623
636
|
mergedConfig.apiBaseUrl,
|
|
624
637
|
mergedConfig.debug,
|
|
625
638
|
false,
|
|
626
|
-
mergedConfig.apiKey
|
|
639
|
+
mergedConfig.apiKey,
|
|
640
|
+
{
|
|
641
|
+
id: mergedConfig.counterpartyId,
|
|
642
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
643
|
+
}
|
|
627
644
|
);
|
|
628
645
|
}
|
|
629
646
|
}
|
|
@@ -799,6 +816,7 @@ async function verify(config, request, options) {
|
|
|
799
816
|
}
|
|
800
817
|
return result;
|
|
801
818
|
}
|
|
819
|
+
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
802
820
|
async function fetchRoutes(config, counterpartyId) {
|
|
803
821
|
if (!counterpartyId) return null;
|
|
804
822
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -811,7 +829,15 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
811
829
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
|
|
812
830
|
{ method: "GET", headers }
|
|
813
831
|
);
|
|
814
|
-
if (!response.ok)
|
|
832
|
+
if (!response.ok) {
|
|
833
|
+
if ((response.status === 401 || response.status === 403 || response.status === 404) && !refusedPolicyReads.has(counterpartyId)) {
|
|
834
|
+
refusedPolicyReads.add(counterpartyId);
|
|
835
|
+
console.error(
|
|
836
|
+
`[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.`
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
return null;
|
|
840
|
+
}
|
|
815
841
|
const body = await response.json();
|
|
816
842
|
return body.data?.routes ?? [];
|
|
817
843
|
} catch {
|