@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/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ function getTrustLevel(score) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// src/version.ts
|
|
22
|
-
var SDK_VERSION = "5.
|
|
22
|
+
var SDK_VERSION = "5.14.0";
|
|
23
23
|
|
|
24
24
|
// src/http.ts
|
|
25
25
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -163,7 +163,7 @@ var DEFAULT_CONFIG = {
|
|
|
163
163
|
};
|
|
164
164
|
var initCheckPerformed = false;
|
|
165
165
|
var deprecationWarningShown = false;
|
|
166
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
166
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
167
167
|
initCheckPerformed = true;
|
|
168
168
|
try {
|
|
169
169
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -181,7 +181,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
181
181
|
);
|
|
182
182
|
}
|
|
183
183
|
if (apiKey) {
|
|
184
|
-
const
|
|
184
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
185
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
185
186
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
186
187
|
});
|
|
187
188
|
if (selfCheck.status === 401) {
|
|
@@ -193,6 +194,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
193
194
|
console.error(message);
|
|
194
195
|
} else if (selfCheck.ok) {
|
|
195
196
|
const body = await selfCheck.json().catch(() => ({}));
|
|
197
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
198
|
+
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.`;
|
|
199
|
+
if (strictInit) {
|
|
200
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
201
|
+
}
|
|
202
|
+
console.error(message);
|
|
203
|
+
}
|
|
196
204
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
197
205
|
console.warn(
|
|
198
206
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -337,11 +345,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
337
345
|
const isMisconfig = source === "merchant_misconfig";
|
|
338
346
|
const urls = options.urls;
|
|
339
347
|
const guidance = isMisconfig ? {
|
|
340
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
348
|
+
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.",
|
|
341
349
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
342
350
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
343
351
|
steps: [
|
|
344
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
352
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
345
353
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
346
354
|
]
|
|
347
355
|
} : isApiError ? {
|
|
@@ -553,12 +561,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
553
561
|
};
|
|
554
562
|
}
|
|
555
563
|
if (!response.ok) {
|
|
556
|
-
|
|
564
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
565
|
+
if (response.status === 401 || keyMismatch) {
|
|
557
566
|
return {
|
|
558
567
|
success: false,
|
|
559
568
|
error: data.message || data.error || "Integration API key rejected",
|
|
560
569
|
misconfig: true,
|
|
561
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
570
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
562
571
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
563
572
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
564
573
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -591,14 +600,22 @@ async function verify(config, request, options) {
|
|
|
591
600
|
mergedConfig.apiBaseUrl,
|
|
592
601
|
mergedConfig.debug,
|
|
593
602
|
true,
|
|
594
|
-
mergedConfig.apiKey
|
|
603
|
+
mergedConfig.apiKey,
|
|
604
|
+
{
|
|
605
|
+
id: mergedConfig.counterpartyId,
|
|
606
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
607
|
+
}
|
|
595
608
|
);
|
|
596
609
|
} else {
|
|
597
610
|
void performInitCheck(
|
|
598
611
|
mergedConfig.apiBaseUrl,
|
|
599
612
|
mergedConfig.debug,
|
|
600
613
|
false,
|
|
601
|
-
mergedConfig.apiKey
|
|
614
|
+
mergedConfig.apiKey,
|
|
615
|
+
{
|
|
616
|
+
id: mergedConfig.counterpartyId,
|
|
617
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
618
|
+
}
|
|
602
619
|
);
|
|
603
620
|
}
|
|
604
621
|
}
|
|
@@ -829,6 +846,7 @@ async function reportAttempt(config, report, options = {}) {
|
|
|
829
846
|
timer.unref?.();
|
|
830
847
|
}
|
|
831
848
|
var ATTEMPT_REPORT_MAX_RETRY_DELAY_MS = 2e3;
|
|
849
|
+
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
832
850
|
async function fetchRoutes(config, counterpartyId) {
|
|
833
851
|
if (!counterpartyId) return null;
|
|
834
852
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -841,7 +859,15 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
841
859
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
|
|
842
860
|
{ method: "GET", headers }
|
|
843
861
|
);
|
|
844
|
-
if (!response.ok)
|
|
862
|
+
if (!response.ok) {
|
|
863
|
+
if ((response.status === 401 || response.status === 403 || response.status === 404) && !refusedPolicyReads.has(counterpartyId)) {
|
|
864
|
+
refusedPolicyReads.add(counterpartyId);
|
|
865
|
+
console.error(
|
|
866
|
+
`[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.`
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
845
871
|
const body = await response.json();
|
|
846
872
|
return body.data?.routes ?? [];
|
|
847
873
|
} catch {
|
|
@@ -1788,6 +1814,11 @@ async function withBudget(promise, ms) {
|
|
|
1788
1814
|
if (timer) clearTimeout(timer);
|
|
1789
1815
|
}
|
|
1790
1816
|
}
|
|
1817
|
+
var CONTAINER_ID = (() => {
|
|
1818
|
+
const c = globalThis.crypto;
|
|
1819
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
1820
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
1821
|
+
})();
|
|
1791
1822
|
var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
|
|
1792
1823
|
var BeaconBuffer = class {
|
|
1793
1824
|
constructor(options = {}) {
|
|
@@ -1795,6 +1826,7 @@ var BeaconBuffer = class {
|
|
|
1795
1826
|
this.droppedSinceLast = 0;
|
|
1796
1827
|
this.droppedTotal = 0;
|
|
1797
1828
|
this.deliveredTotal = 0;
|
|
1829
|
+
this.enqueuedTotal = 0;
|
|
1798
1830
|
this.backoffUntil = 0;
|
|
1799
1831
|
this.collapse = /* @__PURE__ */ new Map();
|
|
1800
1832
|
/** Keys the backend answered 401 for — later batches go unauthenticated. */
|
|
@@ -1807,13 +1839,16 @@ var BeaconBuffer = class {
|
|
|
1807
1839
|
collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
|
|
1808
1840
|
requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
|
|
1809
1841
|
retryBackoffMs: options.retryBackoffMs ?? 1e3,
|
|
1842
|
+
holdRepeats: options.holdRepeats ?? false,
|
|
1843
|
+
containerId: options.containerId ?? CONTAINER_ID,
|
|
1810
1844
|
now: options.now ?? Date.now
|
|
1811
1845
|
};
|
|
1812
1846
|
}
|
|
1813
1847
|
/**
|
|
1814
1848
|
* Queue one beacon. With a `collapseKey`, a repeat inside the window is
|
|
1815
|
-
* merged into
|
|
1816
|
-
*
|
|
1849
|
+
* merged into this key's item while that item is still queued (not yet in
|
|
1850
|
+
* flight). Once it has left, the repeat becomes a new item, sendable on
|
|
1851
|
+
* this flush — nothing waits for a later invocation (round 27.6).
|
|
1817
1852
|
*/
|
|
1818
1853
|
enqueue(dest, item, collapseKey) {
|
|
1819
1854
|
const now = this.opts.now();
|
|
@@ -1826,12 +1861,15 @@ var BeaconBuffer = class {
|
|
|
1826
1861
|
return;
|
|
1827
1862
|
}
|
|
1828
1863
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1864
|
+
if (this.opts.holdRepeats) {
|
|
1865
|
+
entry.held = this.push(
|
|
1866
|
+
dest,
|
|
1867
|
+
{ ...item, repeatCount: 1 },
|
|
1868
|
+
entry.firstSeenAt + this.opts.collapseWindowMs
|
|
1869
|
+
);
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
|
|
1835
1873
|
return;
|
|
1836
1874
|
}
|
|
1837
1875
|
this.collapse.delete(collapseKey);
|
|
@@ -1867,6 +1905,7 @@ var BeaconBuffer = class {
|
|
|
1867
1905
|
droppedSinceLast: this.droppedSinceLast,
|
|
1868
1906
|
droppedTotal: this.droppedTotal,
|
|
1869
1907
|
deliveredTotal: this.deliveredTotal,
|
|
1908
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
1870
1909
|
flushing: this.inFlight !== void 0
|
|
1871
1910
|
};
|
|
1872
1911
|
}
|
|
@@ -1881,6 +1920,7 @@ var BeaconBuffer = class {
|
|
|
1881
1920
|
inFlight: false
|
|
1882
1921
|
};
|
|
1883
1922
|
this.queue.push(entry);
|
|
1923
|
+
this.enqueuedTotal += 1;
|
|
1884
1924
|
return entry;
|
|
1885
1925
|
}
|
|
1886
1926
|
dropOldest() {
|
|
@@ -1926,7 +1966,11 @@ var BeaconBuffer = class {
|
|
|
1926
1966
|
droppedSinceLast: reportedDropped,
|
|
1927
1967
|
queueDepth: this.queue.length,
|
|
1928
1968
|
adapter: dest.adapter ?? "edge-core",
|
|
1929
|
-
version: SDK_VERSION
|
|
1969
|
+
version: SDK_VERSION,
|
|
1970
|
+
containerId: this.opts.containerId,
|
|
1971
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
1972
|
+
deliveredTotal: this.deliveredTotal,
|
|
1973
|
+
droppedTotal: this.droppedTotal
|
|
1930
1974
|
};
|
|
1931
1975
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1932
1976
|
const response = await withBudget(
|