@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/gateway/gateway.mjs
CHANGED
|
@@ -3722,7 +3722,7 @@ function getTrustLevel(score) {
|
|
|
3722
3722
|
}
|
|
3723
3723
|
|
|
3724
3724
|
// src/version.ts
|
|
3725
|
-
var SDK_VERSION = "5.
|
|
3725
|
+
var SDK_VERSION = "5.14.0";
|
|
3726
3726
|
|
|
3727
3727
|
// src/http.ts
|
|
3728
3728
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -3769,7 +3769,7 @@ var DEFAULT_CONFIG = {
|
|
|
3769
3769
|
};
|
|
3770
3770
|
var initCheckPerformed = false;
|
|
3771
3771
|
var deprecationWarningShown = false;
|
|
3772
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
3772
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
3773
3773
|
initCheckPerformed = true;
|
|
3774
3774
|
try {
|
|
3775
3775
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -3787,7 +3787,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
3787
3787
|
);
|
|
3788
3788
|
}
|
|
3789
3789
|
if (apiKey) {
|
|
3790
|
-
const
|
|
3790
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
3791
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
3791
3792
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
3792
3793
|
});
|
|
3793
3794
|
if (selfCheck.status === 401) {
|
|
@@ -3799,6 +3800,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
3799
3800
|
console.error(message);
|
|
3800
3801
|
} else if (selfCheck.ok) {
|
|
3801
3802
|
const body = await selfCheck.json().catch(() => ({}));
|
|
3803
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
3804
|
+
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.`;
|
|
3805
|
+
if (strictInit) {
|
|
3806
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
3807
|
+
}
|
|
3808
|
+
console.error(message);
|
|
3809
|
+
}
|
|
3802
3810
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
3803
3811
|
console.warn(
|
|
3804
3812
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -3903,11 +3911,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
3903
3911
|
const isMisconfig = source === "merchant_misconfig";
|
|
3904
3912
|
const urls = options.urls;
|
|
3905
3913
|
const guidance = isMisconfig ? {
|
|
3906
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
3914
|
+
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.",
|
|
3907
3915
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
3908
3916
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
3909
3917
|
steps: [
|
|
3910
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
3918
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
3911
3919
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
3912
3920
|
]
|
|
3913
3921
|
} : isApiError ? {
|
|
@@ -4119,12 +4127,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4119
4127
|
};
|
|
4120
4128
|
}
|
|
4121
4129
|
if (!response.ok) {
|
|
4122
|
-
|
|
4130
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
4131
|
+
if (response.status === 401 || keyMismatch) {
|
|
4123
4132
|
return {
|
|
4124
4133
|
success: false,
|
|
4125
4134
|
error: data.message || data.error || "Integration API key rejected",
|
|
4126
4135
|
misconfig: true,
|
|
4127
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
4136
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
4128
4137
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
4129
4138
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4130
4139
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -4157,14 +4166,22 @@ async function verify(config, request, options) {
|
|
|
4157
4166
|
mergedConfig.apiBaseUrl,
|
|
4158
4167
|
mergedConfig.debug,
|
|
4159
4168
|
true,
|
|
4160
|
-
mergedConfig.apiKey
|
|
4169
|
+
mergedConfig.apiKey,
|
|
4170
|
+
{
|
|
4171
|
+
id: mergedConfig.counterpartyId,
|
|
4172
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4173
|
+
}
|
|
4161
4174
|
);
|
|
4162
4175
|
} else {
|
|
4163
4176
|
void performInitCheck(
|
|
4164
4177
|
mergedConfig.apiBaseUrl,
|
|
4165
4178
|
mergedConfig.debug,
|
|
4166
4179
|
false,
|
|
4167
|
-
mergedConfig.apiKey
|
|
4180
|
+
mergedConfig.apiKey,
|
|
4181
|
+
{
|
|
4182
|
+
id: mergedConfig.counterpartyId,
|
|
4183
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4184
|
+
}
|
|
4168
4185
|
);
|
|
4169
4186
|
}
|
|
4170
4187
|
}
|
|
@@ -4375,6 +4392,11 @@ async function withBudget(promise, ms) {
|
|
|
4375
4392
|
if (timer) clearTimeout(timer);
|
|
4376
4393
|
}
|
|
4377
4394
|
}
|
|
4395
|
+
var CONTAINER_ID = (() => {
|
|
4396
|
+
const c = globalThis.crypto;
|
|
4397
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
4398
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
4399
|
+
})();
|
|
4378
4400
|
var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
|
|
4379
4401
|
var BeaconBuffer = class {
|
|
4380
4402
|
constructor(options = {}) {
|
|
@@ -4382,6 +4404,7 @@ var BeaconBuffer = class {
|
|
|
4382
4404
|
this.droppedSinceLast = 0;
|
|
4383
4405
|
this.droppedTotal = 0;
|
|
4384
4406
|
this.deliveredTotal = 0;
|
|
4407
|
+
this.enqueuedTotal = 0;
|
|
4385
4408
|
this.backoffUntil = 0;
|
|
4386
4409
|
this.collapse = /* @__PURE__ */ new Map();
|
|
4387
4410
|
/** Keys the backend answered 401 for — later batches go unauthenticated. */
|
|
@@ -4394,13 +4417,16 @@ var BeaconBuffer = class {
|
|
|
4394
4417
|
collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
|
|
4395
4418
|
requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
|
|
4396
4419
|
retryBackoffMs: options.retryBackoffMs ?? 1e3,
|
|
4420
|
+
holdRepeats: options.holdRepeats ?? false,
|
|
4421
|
+
containerId: options.containerId ?? CONTAINER_ID,
|
|
4397
4422
|
now: options.now ?? Date.now
|
|
4398
4423
|
};
|
|
4399
4424
|
}
|
|
4400
4425
|
/**
|
|
4401
4426
|
* Queue one beacon. With a `collapseKey`, a repeat inside the window is
|
|
4402
|
-
* merged into
|
|
4403
|
-
*
|
|
4427
|
+
* merged into this key's item while that item is still queued (not yet in
|
|
4428
|
+
* flight). Once it has left, the repeat becomes a new item, sendable on
|
|
4429
|
+
* this flush — nothing waits for a later invocation (round 27.6).
|
|
4404
4430
|
*/
|
|
4405
4431
|
enqueue(dest, item, collapseKey) {
|
|
4406
4432
|
const now = this.opts.now();
|
|
@@ -4413,12 +4439,15 @@ var BeaconBuffer = class {
|
|
|
4413
4439
|
return;
|
|
4414
4440
|
}
|
|
4415
4441
|
}
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4442
|
+
if (this.opts.holdRepeats) {
|
|
4443
|
+
entry.held = this.push(
|
|
4444
|
+
dest,
|
|
4445
|
+
{ ...item, repeatCount: 1 },
|
|
4446
|
+
entry.firstSeenAt + this.opts.collapseWindowMs
|
|
4447
|
+
);
|
|
4448
|
+
return;
|
|
4449
|
+
}
|
|
4450
|
+
entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
|
|
4422
4451
|
return;
|
|
4423
4452
|
}
|
|
4424
4453
|
this.collapse.delete(collapseKey);
|
|
@@ -4454,6 +4483,7 @@ var BeaconBuffer = class {
|
|
|
4454
4483
|
droppedSinceLast: this.droppedSinceLast,
|
|
4455
4484
|
droppedTotal: this.droppedTotal,
|
|
4456
4485
|
deliveredTotal: this.deliveredTotal,
|
|
4486
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4457
4487
|
flushing: this.inFlight !== void 0
|
|
4458
4488
|
};
|
|
4459
4489
|
}
|
|
@@ -4468,6 +4498,7 @@ var BeaconBuffer = class {
|
|
|
4468
4498
|
inFlight: false
|
|
4469
4499
|
};
|
|
4470
4500
|
this.queue.push(entry);
|
|
4501
|
+
this.enqueuedTotal += 1;
|
|
4471
4502
|
return entry;
|
|
4472
4503
|
}
|
|
4473
4504
|
dropOldest() {
|
|
@@ -4513,7 +4544,11 @@ var BeaconBuffer = class {
|
|
|
4513
4544
|
droppedSinceLast: reportedDropped,
|
|
4514
4545
|
queueDepth: this.queue.length,
|
|
4515
4546
|
adapter: dest.adapter ?? "edge-core",
|
|
4516
|
-
version: SDK_VERSION
|
|
4547
|
+
version: SDK_VERSION,
|
|
4548
|
+
containerId: this.opts.containerId,
|
|
4549
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4550
|
+
deliveredTotal: this.deliveredTotal,
|
|
4551
|
+
droppedTotal: this.droppedTotal
|
|
4517
4552
|
};
|
|
4518
4553
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
4519
4554
|
const response = await withBudget(
|