@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
|
@@ -3986,7 +3986,7 @@ function getTrustLevel(score) {
|
|
|
3986
3986
|
}
|
|
3987
3987
|
|
|
3988
3988
|
// src/version.ts
|
|
3989
|
-
var SDK_VERSION = "5.
|
|
3989
|
+
var SDK_VERSION = "5.14.0";
|
|
3990
3990
|
|
|
3991
3991
|
// src/http.ts
|
|
3992
3992
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -4033,7 +4033,7 @@ var DEFAULT_CONFIG = {
|
|
|
4033
4033
|
};
|
|
4034
4034
|
var initCheckPerformed = false;
|
|
4035
4035
|
var deprecationWarningShown = false;
|
|
4036
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
4036
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
4037
4037
|
initCheckPerformed = true;
|
|
4038
4038
|
try {
|
|
4039
4039
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -4051,7 +4051,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
4051
4051
|
);
|
|
4052
4052
|
}
|
|
4053
4053
|
if (apiKey) {
|
|
4054
|
-
const
|
|
4054
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
4055
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
4055
4056
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4056
4057
|
});
|
|
4057
4058
|
if (selfCheck.status === 401) {
|
|
@@ -4063,6 +4064,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
4063
4064
|
console.error(message);
|
|
4064
4065
|
} else if (selfCheck.ok) {
|
|
4065
4066
|
const body = await selfCheck.json().catch(() => ({}));
|
|
4067
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
4068
|
+
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.`;
|
|
4069
|
+
if (strictInit) {
|
|
4070
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
4071
|
+
}
|
|
4072
|
+
console.error(message);
|
|
4073
|
+
}
|
|
4066
4074
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
4067
4075
|
console.warn(
|
|
4068
4076
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -4167,11 +4175,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
4167
4175
|
const isMisconfig = source === "merchant_misconfig";
|
|
4168
4176
|
const urls = options.urls;
|
|
4169
4177
|
const guidance = isMisconfig ? {
|
|
4170
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
4178
|
+
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.",
|
|
4171
4179
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
4172
4180
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
4173
4181
|
steps: [
|
|
4174
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
4182
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
4175
4183
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
4176
4184
|
]
|
|
4177
4185
|
} : isApiError ? {
|
|
@@ -4383,12 +4391,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4383
4391
|
};
|
|
4384
4392
|
}
|
|
4385
4393
|
if (!response.ok) {
|
|
4386
|
-
|
|
4394
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
4395
|
+
if (response.status === 401 || keyMismatch) {
|
|
4387
4396
|
return {
|
|
4388
4397
|
success: false,
|
|
4389
4398
|
error: data.message || data.error || "Integration API key rejected",
|
|
4390
4399
|
misconfig: true,
|
|
4391
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
4400
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
4392
4401
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
4393
4402
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4394
4403
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -4421,14 +4430,22 @@ async function verify(config, request, options) {
|
|
|
4421
4430
|
mergedConfig.apiBaseUrl,
|
|
4422
4431
|
mergedConfig.debug,
|
|
4423
4432
|
true,
|
|
4424
|
-
mergedConfig.apiKey
|
|
4433
|
+
mergedConfig.apiKey,
|
|
4434
|
+
{
|
|
4435
|
+
id: mergedConfig.counterpartyId,
|
|
4436
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4437
|
+
}
|
|
4425
4438
|
);
|
|
4426
4439
|
} else {
|
|
4427
4440
|
void performInitCheck(
|
|
4428
4441
|
mergedConfig.apiBaseUrl,
|
|
4429
4442
|
mergedConfig.debug,
|
|
4430
4443
|
false,
|
|
4431
|
-
mergedConfig.apiKey
|
|
4444
|
+
mergedConfig.apiKey,
|
|
4445
|
+
{
|
|
4446
|
+
id: mergedConfig.counterpartyId,
|
|
4447
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4448
|
+
}
|
|
4432
4449
|
);
|
|
4433
4450
|
}
|
|
4434
4451
|
}
|
|
@@ -4639,6 +4656,11 @@ async function withBudget(promise, ms) {
|
|
|
4639
4656
|
if (timer) clearTimeout(timer);
|
|
4640
4657
|
}
|
|
4641
4658
|
}
|
|
4659
|
+
var CONTAINER_ID = (() => {
|
|
4660
|
+
const c = globalThis.crypto;
|
|
4661
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
4662
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
4663
|
+
})();
|
|
4642
4664
|
var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
|
|
4643
4665
|
var BeaconBuffer = class {
|
|
4644
4666
|
constructor(options = {}) {
|
|
@@ -4646,6 +4668,7 @@ var BeaconBuffer = class {
|
|
|
4646
4668
|
this.droppedSinceLast = 0;
|
|
4647
4669
|
this.droppedTotal = 0;
|
|
4648
4670
|
this.deliveredTotal = 0;
|
|
4671
|
+
this.enqueuedTotal = 0;
|
|
4649
4672
|
this.backoffUntil = 0;
|
|
4650
4673
|
this.collapse = /* @__PURE__ */ new Map();
|
|
4651
4674
|
/** Keys the backend answered 401 for — later batches go unauthenticated. */
|
|
@@ -4658,13 +4681,16 @@ var BeaconBuffer = class {
|
|
|
4658
4681
|
collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
|
|
4659
4682
|
requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
|
|
4660
4683
|
retryBackoffMs: options.retryBackoffMs ?? 1e3,
|
|
4684
|
+
holdRepeats: options.holdRepeats ?? false,
|
|
4685
|
+
containerId: options.containerId ?? CONTAINER_ID,
|
|
4661
4686
|
now: options.now ?? Date.now
|
|
4662
4687
|
};
|
|
4663
4688
|
}
|
|
4664
4689
|
/**
|
|
4665
4690
|
* Queue one beacon. With a `collapseKey`, a repeat inside the window is
|
|
4666
|
-
* merged into
|
|
4667
|
-
*
|
|
4691
|
+
* merged into this key's item while that item is still queued (not yet in
|
|
4692
|
+
* flight). Once it has left, the repeat becomes a new item, sendable on
|
|
4693
|
+
* this flush — nothing waits for a later invocation (round 27.6).
|
|
4668
4694
|
*/
|
|
4669
4695
|
enqueue(dest, item, collapseKey) {
|
|
4670
4696
|
const now = this.opts.now();
|
|
@@ -4677,12 +4703,15 @@ var BeaconBuffer = class {
|
|
|
4677
4703
|
return;
|
|
4678
4704
|
}
|
|
4679
4705
|
}
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4706
|
+
if (this.opts.holdRepeats) {
|
|
4707
|
+
entry.held = this.push(
|
|
4708
|
+
dest,
|
|
4709
|
+
{ ...item, repeatCount: 1 },
|
|
4710
|
+
entry.firstSeenAt + this.opts.collapseWindowMs
|
|
4711
|
+
);
|
|
4712
|
+
return;
|
|
4713
|
+
}
|
|
4714
|
+
entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
|
|
4686
4715
|
return;
|
|
4687
4716
|
}
|
|
4688
4717
|
this.collapse.delete(collapseKey);
|
|
@@ -4718,6 +4747,7 @@ var BeaconBuffer = class {
|
|
|
4718
4747
|
droppedSinceLast: this.droppedSinceLast,
|
|
4719
4748
|
droppedTotal: this.droppedTotal,
|
|
4720
4749
|
deliveredTotal: this.deliveredTotal,
|
|
4750
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4721
4751
|
flushing: this.inFlight !== void 0
|
|
4722
4752
|
};
|
|
4723
4753
|
}
|
|
@@ -4732,6 +4762,7 @@ var BeaconBuffer = class {
|
|
|
4732
4762
|
inFlight: false
|
|
4733
4763
|
};
|
|
4734
4764
|
this.queue.push(entry);
|
|
4765
|
+
this.enqueuedTotal += 1;
|
|
4735
4766
|
return entry;
|
|
4736
4767
|
}
|
|
4737
4768
|
dropOldest() {
|
|
@@ -4777,7 +4808,11 @@ var BeaconBuffer = class {
|
|
|
4777
4808
|
droppedSinceLast: reportedDropped,
|
|
4778
4809
|
queueDepth: this.queue.length,
|
|
4779
4810
|
adapter: dest.adapter ?? "edge-core",
|
|
4780
|
-
version: SDK_VERSION
|
|
4811
|
+
version: SDK_VERSION,
|
|
4812
|
+
containerId: this.opts.containerId,
|
|
4813
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4814
|
+
deliveredTotal: this.deliveredTotal,
|
|
4815
|
+
droppedTotal: this.droppedTotal
|
|
4781
4816
|
};
|
|
4782
4817
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
4783
4818
|
const response = await withBudget(
|