@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/cursor/extension.js
CHANGED
|
@@ -3994,7 +3994,7 @@ function getTrustLevel(score) {
|
|
|
3994
3994
|
}
|
|
3995
3995
|
|
|
3996
3996
|
// src/version.ts
|
|
3997
|
-
var SDK_VERSION = "5.
|
|
3997
|
+
var SDK_VERSION = "5.14.0";
|
|
3998
3998
|
|
|
3999
3999
|
// src/http.ts
|
|
4000
4000
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -4041,7 +4041,7 @@ var DEFAULT_CONFIG = {
|
|
|
4041
4041
|
};
|
|
4042
4042
|
var initCheckPerformed = false;
|
|
4043
4043
|
var deprecationWarningShown = false;
|
|
4044
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
4044
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
4045
4045
|
initCheckPerformed = true;
|
|
4046
4046
|
try {
|
|
4047
4047
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -4059,7 +4059,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
4059
4059
|
);
|
|
4060
4060
|
}
|
|
4061
4061
|
if (apiKey) {
|
|
4062
|
-
const
|
|
4062
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
4063
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
4063
4064
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4064
4065
|
});
|
|
4065
4066
|
if (selfCheck.status === 401) {
|
|
@@ -4071,6 +4072,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
4071
4072
|
console.error(message);
|
|
4072
4073
|
} else if (selfCheck.ok) {
|
|
4073
4074
|
const body = await selfCheck.json().catch(() => ({}));
|
|
4075
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
4076
|
+
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.`;
|
|
4077
|
+
if (strictInit) {
|
|
4078
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
4079
|
+
}
|
|
4080
|
+
console.error(message);
|
|
4081
|
+
}
|
|
4074
4082
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
4075
4083
|
console.warn(
|
|
4076
4084
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -4175,11 +4183,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
4175
4183
|
const isMisconfig = source === "merchant_misconfig";
|
|
4176
4184
|
const urls = options.urls;
|
|
4177
4185
|
const guidance = isMisconfig ? {
|
|
4178
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
4186
|
+
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.",
|
|
4179
4187
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
4180
4188
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
4181
4189
|
steps: [
|
|
4182
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
4190
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
4183
4191
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
4184
4192
|
]
|
|
4185
4193
|
} : isApiError ? {
|
|
@@ -4391,12 +4399,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4391
4399
|
};
|
|
4392
4400
|
}
|
|
4393
4401
|
if (!response.ok) {
|
|
4394
|
-
|
|
4402
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
4403
|
+
if (response.status === 401 || keyMismatch) {
|
|
4395
4404
|
return {
|
|
4396
4405
|
success: false,
|
|
4397
4406
|
error: data.message || data.error || "Integration API key rejected",
|
|
4398
4407
|
misconfig: true,
|
|
4399
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
4408
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
4400
4409
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
4401
4410
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4402
4411
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -4429,14 +4438,22 @@ async function verify(config, request, options) {
|
|
|
4429
4438
|
mergedConfig.apiBaseUrl,
|
|
4430
4439
|
mergedConfig.debug,
|
|
4431
4440
|
true,
|
|
4432
|
-
mergedConfig.apiKey
|
|
4441
|
+
mergedConfig.apiKey,
|
|
4442
|
+
{
|
|
4443
|
+
id: mergedConfig.counterpartyId,
|
|
4444
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4445
|
+
}
|
|
4433
4446
|
);
|
|
4434
4447
|
} else {
|
|
4435
4448
|
void performInitCheck(
|
|
4436
4449
|
mergedConfig.apiBaseUrl,
|
|
4437
4450
|
mergedConfig.debug,
|
|
4438
4451
|
false,
|
|
4439
|
-
mergedConfig.apiKey
|
|
4452
|
+
mergedConfig.apiKey,
|
|
4453
|
+
{
|
|
4454
|
+
id: mergedConfig.counterpartyId,
|
|
4455
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4456
|
+
}
|
|
4440
4457
|
);
|
|
4441
4458
|
}
|
|
4442
4459
|
}
|
|
@@ -4647,6 +4664,11 @@ async function withBudget(promise, ms) {
|
|
|
4647
4664
|
if (timer) clearTimeout(timer);
|
|
4648
4665
|
}
|
|
4649
4666
|
}
|
|
4667
|
+
var CONTAINER_ID = (() => {
|
|
4668
|
+
const c = globalThis.crypto;
|
|
4669
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
4670
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
4671
|
+
})();
|
|
4650
4672
|
var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
|
|
4651
4673
|
var BeaconBuffer = class {
|
|
4652
4674
|
constructor(options = {}) {
|
|
@@ -4654,6 +4676,7 @@ var BeaconBuffer = class {
|
|
|
4654
4676
|
this.droppedSinceLast = 0;
|
|
4655
4677
|
this.droppedTotal = 0;
|
|
4656
4678
|
this.deliveredTotal = 0;
|
|
4679
|
+
this.enqueuedTotal = 0;
|
|
4657
4680
|
this.backoffUntil = 0;
|
|
4658
4681
|
this.collapse = /* @__PURE__ */ new Map();
|
|
4659
4682
|
/** Keys the backend answered 401 for — later batches go unauthenticated. */
|
|
@@ -4666,13 +4689,16 @@ var BeaconBuffer = class {
|
|
|
4666
4689
|
collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
|
|
4667
4690
|
requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
|
|
4668
4691
|
retryBackoffMs: options.retryBackoffMs ?? 1e3,
|
|
4692
|
+
holdRepeats: options.holdRepeats ?? false,
|
|
4693
|
+
containerId: options.containerId ?? CONTAINER_ID,
|
|
4669
4694
|
now: options.now ?? Date.now
|
|
4670
4695
|
};
|
|
4671
4696
|
}
|
|
4672
4697
|
/**
|
|
4673
4698
|
* Queue one beacon. With a `collapseKey`, a repeat inside the window is
|
|
4674
|
-
* merged into
|
|
4675
|
-
*
|
|
4699
|
+
* merged into this key's item while that item is still queued (not yet in
|
|
4700
|
+
* flight). Once it has left, the repeat becomes a new item, sendable on
|
|
4701
|
+
* this flush — nothing waits for a later invocation (round 27.6).
|
|
4676
4702
|
*/
|
|
4677
4703
|
enqueue(dest, item, collapseKey) {
|
|
4678
4704
|
const now = this.opts.now();
|
|
@@ -4685,12 +4711,15 @@ var BeaconBuffer = class {
|
|
|
4685
4711
|
return;
|
|
4686
4712
|
}
|
|
4687
4713
|
}
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4714
|
+
if (this.opts.holdRepeats) {
|
|
4715
|
+
entry.held = this.push(
|
|
4716
|
+
dest,
|
|
4717
|
+
{ ...item, repeatCount: 1 },
|
|
4718
|
+
entry.firstSeenAt + this.opts.collapseWindowMs
|
|
4719
|
+
);
|
|
4720
|
+
return;
|
|
4721
|
+
}
|
|
4722
|
+
entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
|
|
4694
4723
|
return;
|
|
4695
4724
|
}
|
|
4696
4725
|
this.collapse.delete(collapseKey);
|
|
@@ -4726,6 +4755,7 @@ var BeaconBuffer = class {
|
|
|
4726
4755
|
droppedSinceLast: this.droppedSinceLast,
|
|
4727
4756
|
droppedTotal: this.droppedTotal,
|
|
4728
4757
|
deliveredTotal: this.deliveredTotal,
|
|
4758
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4729
4759
|
flushing: this.inFlight !== void 0
|
|
4730
4760
|
};
|
|
4731
4761
|
}
|
|
@@ -4740,6 +4770,7 @@ var BeaconBuffer = class {
|
|
|
4740
4770
|
inFlight: false
|
|
4741
4771
|
};
|
|
4742
4772
|
this.queue.push(entry);
|
|
4773
|
+
this.enqueuedTotal += 1;
|
|
4743
4774
|
return entry;
|
|
4744
4775
|
}
|
|
4745
4776
|
dropOldest() {
|
|
@@ -4785,7 +4816,11 @@ var BeaconBuffer = class {
|
|
|
4785
4816
|
droppedSinceLast: reportedDropped,
|
|
4786
4817
|
queueDepth: this.queue.length,
|
|
4787
4818
|
adapter: dest.adapter ?? "edge-core",
|
|
4788
|
-
version: SDK_VERSION
|
|
4819
|
+
version: SDK_VERSION,
|
|
4820
|
+
containerId: this.opts.containerId,
|
|
4821
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4822
|
+
deliveredTotal: this.deliveredTotal,
|
|
4823
|
+
droppedTotal: this.droppedTotal
|
|
4789
4824
|
};
|
|
4790
4825
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
4791
4826
|
const response = await withBudget(
|