@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
|
@@ -3969,7 +3969,7 @@ function getTrustLevel(score) {
|
|
|
3969
3969
|
}
|
|
3970
3970
|
|
|
3971
3971
|
// src/version.ts
|
|
3972
|
-
var SDK_VERSION = "5.
|
|
3972
|
+
var SDK_VERSION = "5.14.0";
|
|
3973
3973
|
|
|
3974
3974
|
// src/http.ts
|
|
3975
3975
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -4016,7 +4016,7 @@ var DEFAULT_CONFIG = {
|
|
|
4016
4016
|
};
|
|
4017
4017
|
var initCheckPerformed = false;
|
|
4018
4018
|
var deprecationWarningShown = false;
|
|
4019
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
4019
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
4020
4020
|
initCheckPerformed = true;
|
|
4021
4021
|
try {
|
|
4022
4022
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -4034,7 +4034,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
4034
4034
|
);
|
|
4035
4035
|
}
|
|
4036
4036
|
if (apiKey) {
|
|
4037
|
-
const
|
|
4037
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
4038
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
4038
4039
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4039
4040
|
});
|
|
4040
4041
|
if (selfCheck.status === 401) {
|
|
@@ -4046,6 +4047,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
4046
4047
|
console.error(message);
|
|
4047
4048
|
} else if (selfCheck.ok) {
|
|
4048
4049
|
const body = await selfCheck.json().catch(() => ({}));
|
|
4050
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
4051
|
+
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.`;
|
|
4052
|
+
if (strictInit) {
|
|
4053
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
4054
|
+
}
|
|
4055
|
+
console.error(message);
|
|
4056
|
+
}
|
|
4049
4057
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
4050
4058
|
console.warn(
|
|
4051
4059
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -4150,11 +4158,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
4150
4158
|
const isMisconfig = source === "merchant_misconfig";
|
|
4151
4159
|
const urls = options.urls;
|
|
4152
4160
|
const guidance = isMisconfig ? {
|
|
4153
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
4161
|
+
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.",
|
|
4154
4162
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
4155
4163
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
4156
4164
|
steps: [
|
|
4157
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
4165
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
4158
4166
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
4159
4167
|
]
|
|
4160
4168
|
} : isApiError ? {
|
|
@@ -4366,12 +4374,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4366
4374
|
};
|
|
4367
4375
|
}
|
|
4368
4376
|
if (!response.ok) {
|
|
4369
|
-
|
|
4377
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
4378
|
+
if (response.status === 401 || keyMismatch) {
|
|
4370
4379
|
return {
|
|
4371
4380
|
success: false,
|
|
4372
4381
|
error: data.message || data.error || "Integration API key rejected",
|
|
4373
4382
|
misconfig: true,
|
|
4374
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
4383
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
4375
4384
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
4376
4385
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4377
4386
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -4404,14 +4413,22 @@ async function verify(config, request, options) {
|
|
|
4404
4413
|
mergedConfig.apiBaseUrl,
|
|
4405
4414
|
mergedConfig.debug,
|
|
4406
4415
|
true,
|
|
4407
|
-
mergedConfig.apiKey
|
|
4416
|
+
mergedConfig.apiKey,
|
|
4417
|
+
{
|
|
4418
|
+
id: mergedConfig.counterpartyId,
|
|
4419
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4420
|
+
}
|
|
4408
4421
|
);
|
|
4409
4422
|
} else {
|
|
4410
4423
|
void performInitCheck(
|
|
4411
4424
|
mergedConfig.apiBaseUrl,
|
|
4412
4425
|
mergedConfig.debug,
|
|
4413
4426
|
false,
|
|
4414
|
-
mergedConfig.apiKey
|
|
4427
|
+
mergedConfig.apiKey,
|
|
4428
|
+
{
|
|
4429
|
+
id: mergedConfig.counterpartyId,
|
|
4430
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4431
|
+
}
|
|
4415
4432
|
);
|
|
4416
4433
|
}
|
|
4417
4434
|
}
|
|
@@ -4622,6 +4639,11 @@ async function withBudget(promise, ms) {
|
|
|
4622
4639
|
if (timer) clearTimeout(timer);
|
|
4623
4640
|
}
|
|
4624
4641
|
}
|
|
4642
|
+
var CONTAINER_ID = (() => {
|
|
4643
|
+
const c = globalThis.crypto;
|
|
4644
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
4645
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
4646
|
+
})();
|
|
4625
4647
|
var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
|
|
4626
4648
|
var BeaconBuffer = class {
|
|
4627
4649
|
constructor(options = {}) {
|
|
@@ -4629,6 +4651,7 @@ var BeaconBuffer = class {
|
|
|
4629
4651
|
this.droppedSinceLast = 0;
|
|
4630
4652
|
this.droppedTotal = 0;
|
|
4631
4653
|
this.deliveredTotal = 0;
|
|
4654
|
+
this.enqueuedTotal = 0;
|
|
4632
4655
|
this.backoffUntil = 0;
|
|
4633
4656
|
this.collapse = /* @__PURE__ */ new Map();
|
|
4634
4657
|
/** Keys the backend answered 401 for — later batches go unauthenticated. */
|
|
@@ -4641,13 +4664,16 @@ var BeaconBuffer = class {
|
|
|
4641
4664
|
collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
|
|
4642
4665
|
requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
|
|
4643
4666
|
retryBackoffMs: options.retryBackoffMs ?? 1e3,
|
|
4667
|
+
holdRepeats: options.holdRepeats ?? false,
|
|
4668
|
+
containerId: options.containerId ?? CONTAINER_ID,
|
|
4644
4669
|
now: options.now ?? Date.now
|
|
4645
4670
|
};
|
|
4646
4671
|
}
|
|
4647
4672
|
/**
|
|
4648
4673
|
* Queue one beacon. With a `collapseKey`, a repeat inside the window is
|
|
4649
|
-
* merged into
|
|
4650
|
-
*
|
|
4674
|
+
* merged into this key's item while that item is still queued (not yet in
|
|
4675
|
+
* flight). Once it has left, the repeat becomes a new item, sendable on
|
|
4676
|
+
* this flush — nothing waits for a later invocation (round 27.6).
|
|
4651
4677
|
*/
|
|
4652
4678
|
enqueue(dest, item, collapseKey) {
|
|
4653
4679
|
const now = this.opts.now();
|
|
@@ -4660,12 +4686,15 @@ var BeaconBuffer = class {
|
|
|
4660
4686
|
return;
|
|
4661
4687
|
}
|
|
4662
4688
|
}
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4689
|
+
if (this.opts.holdRepeats) {
|
|
4690
|
+
entry.held = this.push(
|
|
4691
|
+
dest,
|
|
4692
|
+
{ ...item, repeatCount: 1 },
|
|
4693
|
+
entry.firstSeenAt + this.opts.collapseWindowMs
|
|
4694
|
+
);
|
|
4695
|
+
return;
|
|
4696
|
+
}
|
|
4697
|
+
entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
|
|
4669
4698
|
return;
|
|
4670
4699
|
}
|
|
4671
4700
|
this.collapse.delete(collapseKey);
|
|
@@ -4701,6 +4730,7 @@ var BeaconBuffer = class {
|
|
|
4701
4730
|
droppedSinceLast: this.droppedSinceLast,
|
|
4702
4731
|
droppedTotal: this.droppedTotal,
|
|
4703
4732
|
deliveredTotal: this.deliveredTotal,
|
|
4733
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4704
4734
|
flushing: this.inFlight !== void 0
|
|
4705
4735
|
};
|
|
4706
4736
|
}
|
|
@@ -4715,6 +4745,7 @@ var BeaconBuffer = class {
|
|
|
4715
4745
|
inFlight: false
|
|
4716
4746
|
};
|
|
4717
4747
|
this.queue.push(entry);
|
|
4748
|
+
this.enqueuedTotal += 1;
|
|
4718
4749
|
return entry;
|
|
4719
4750
|
}
|
|
4720
4751
|
dropOldest() {
|
|
@@ -4760,7 +4791,11 @@ var BeaconBuffer = class {
|
|
|
4760
4791
|
droppedSinceLast: reportedDropped,
|
|
4761
4792
|
queueDepth: this.queue.length,
|
|
4762
4793
|
adapter: dest.adapter ?? "edge-core",
|
|
4763
|
-
version: SDK_VERSION
|
|
4794
|
+
version: SDK_VERSION,
|
|
4795
|
+
containerId: this.opts.containerId,
|
|
4796
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4797
|
+
deliveredTotal: this.deliveredTotal,
|
|
4798
|
+
droppedTotal: this.droppedTotal
|
|
4764
4799
|
};
|
|
4765
4800
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
4766
4801
|
const response = await withBudget(
|