@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.js
CHANGED
|
@@ -3748,7 +3748,7 @@ function getTrustLevel(score) {
|
|
|
3748
3748
|
}
|
|
3749
3749
|
|
|
3750
3750
|
// src/version.ts
|
|
3751
|
-
var SDK_VERSION = "5.
|
|
3751
|
+
var SDK_VERSION = "5.14.0";
|
|
3752
3752
|
|
|
3753
3753
|
// src/http.ts
|
|
3754
3754
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -3795,7 +3795,7 @@ var DEFAULT_CONFIG = {
|
|
|
3795
3795
|
};
|
|
3796
3796
|
var initCheckPerformed = false;
|
|
3797
3797
|
var deprecationWarningShown = false;
|
|
3798
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
3798
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
3799
3799
|
initCheckPerformed = true;
|
|
3800
3800
|
try {
|
|
3801
3801
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -3813,7 +3813,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
3813
3813
|
);
|
|
3814
3814
|
}
|
|
3815
3815
|
if (apiKey) {
|
|
3816
|
-
const
|
|
3816
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
3817
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
3817
3818
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
3818
3819
|
});
|
|
3819
3820
|
if (selfCheck.status === 401) {
|
|
@@ -3825,6 +3826,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
3825
3826
|
console.error(message);
|
|
3826
3827
|
} else if (selfCheck.ok) {
|
|
3827
3828
|
const body = await selfCheck.json().catch(() => ({}));
|
|
3829
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
3830
|
+
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.`;
|
|
3831
|
+
if (strictInit) {
|
|
3832
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
3833
|
+
}
|
|
3834
|
+
console.error(message);
|
|
3835
|
+
}
|
|
3828
3836
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
3829
3837
|
console.warn(
|
|
3830
3838
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -3929,11 +3937,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
3929
3937
|
const isMisconfig = source === "merchant_misconfig";
|
|
3930
3938
|
const urls = options.urls;
|
|
3931
3939
|
const guidance = isMisconfig ? {
|
|
3932
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
3940
|
+
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.",
|
|
3933
3941
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
3934
3942
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
3935
3943
|
steps: [
|
|
3936
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
3944
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
3937
3945
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
3938
3946
|
]
|
|
3939
3947
|
} : isApiError ? {
|
|
@@ -4145,12 +4153,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4145
4153
|
};
|
|
4146
4154
|
}
|
|
4147
4155
|
if (!response.ok) {
|
|
4148
|
-
|
|
4156
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
4157
|
+
if (response.status === 401 || keyMismatch) {
|
|
4149
4158
|
return {
|
|
4150
4159
|
success: false,
|
|
4151
4160
|
error: data.message || data.error || "Integration API key rejected",
|
|
4152
4161
|
misconfig: true,
|
|
4153
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
4162
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
4154
4163
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
4155
4164
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4156
4165
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -4183,14 +4192,22 @@ async function verify(config, request, options) {
|
|
|
4183
4192
|
mergedConfig.apiBaseUrl,
|
|
4184
4193
|
mergedConfig.debug,
|
|
4185
4194
|
true,
|
|
4186
|
-
mergedConfig.apiKey
|
|
4195
|
+
mergedConfig.apiKey,
|
|
4196
|
+
{
|
|
4197
|
+
id: mergedConfig.counterpartyId,
|
|
4198
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4199
|
+
}
|
|
4187
4200
|
);
|
|
4188
4201
|
} else {
|
|
4189
4202
|
void performInitCheck(
|
|
4190
4203
|
mergedConfig.apiBaseUrl,
|
|
4191
4204
|
mergedConfig.debug,
|
|
4192
4205
|
false,
|
|
4193
|
-
mergedConfig.apiKey
|
|
4206
|
+
mergedConfig.apiKey,
|
|
4207
|
+
{
|
|
4208
|
+
id: mergedConfig.counterpartyId,
|
|
4209
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4210
|
+
}
|
|
4194
4211
|
);
|
|
4195
4212
|
}
|
|
4196
4213
|
}
|
|
@@ -4401,6 +4418,11 @@ async function withBudget(promise, ms) {
|
|
|
4401
4418
|
if (timer) clearTimeout(timer);
|
|
4402
4419
|
}
|
|
4403
4420
|
}
|
|
4421
|
+
var CONTAINER_ID = (() => {
|
|
4422
|
+
const c = globalThis.crypto;
|
|
4423
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
4424
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
4425
|
+
})();
|
|
4404
4426
|
var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
|
|
4405
4427
|
var BeaconBuffer = class {
|
|
4406
4428
|
constructor(options = {}) {
|
|
@@ -4408,6 +4430,7 @@ var BeaconBuffer = class {
|
|
|
4408
4430
|
this.droppedSinceLast = 0;
|
|
4409
4431
|
this.droppedTotal = 0;
|
|
4410
4432
|
this.deliveredTotal = 0;
|
|
4433
|
+
this.enqueuedTotal = 0;
|
|
4411
4434
|
this.backoffUntil = 0;
|
|
4412
4435
|
this.collapse = /* @__PURE__ */ new Map();
|
|
4413
4436
|
/** Keys the backend answered 401 for — later batches go unauthenticated. */
|
|
@@ -4420,13 +4443,16 @@ var BeaconBuffer = class {
|
|
|
4420
4443
|
collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
|
|
4421
4444
|
requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
|
|
4422
4445
|
retryBackoffMs: options.retryBackoffMs ?? 1e3,
|
|
4446
|
+
holdRepeats: options.holdRepeats ?? false,
|
|
4447
|
+
containerId: options.containerId ?? CONTAINER_ID,
|
|
4423
4448
|
now: options.now ?? Date.now
|
|
4424
4449
|
};
|
|
4425
4450
|
}
|
|
4426
4451
|
/**
|
|
4427
4452
|
* Queue one beacon. With a `collapseKey`, a repeat inside the window is
|
|
4428
|
-
* merged into
|
|
4429
|
-
*
|
|
4453
|
+
* merged into this key's item while that item is still queued (not yet in
|
|
4454
|
+
* flight). Once it has left, the repeat becomes a new item, sendable on
|
|
4455
|
+
* this flush — nothing waits for a later invocation (round 27.6).
|
|
4430
4456
|
*/
|
|
4431
4457
|
enqueue(dest, item, collapseKey) {
|
|
4432
4458
|
const now = this.opts.now();
|
|
@@ -4439,12 +4465,15 @@ var BeaconBuffer = class {
|
|
|
4439
4465
|
return;
|
|
4440
4466
|
}
|
|
4441
4467
|
}
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4468
|
+
if (this.opts.holdRepeats) {
|
|
4469
|
+
entry.held = this.push(
|
|
4470
|
+
dest,
|
|
4471
|
+
{ ...item, repeatCount: 1 },
|
|
4472
|
+
entry.firstSeenAt + this.opts.collapseWindowMs
|
|
4473
|
+
);
|
|
4474
|
+
return;
|
|
4475
|
+
}
|
|
4476
|
+
entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
|
|
4448
4477
|
return;
|
|
4449
4478
|
}
|
|
4450
4479
|
this.collapse.delete(collapseKey);
|
|
@@ -4480,6 +4509,7 @@ var BeaconBuffer = class {
|
|
|
4480
4509
|
droppedSinceLast: this.droppedSinceLast,
|
|
4481
4510
|
droppedTotal: this.droppedTotal,
|
|
4482
4511
|
deliveredTotal: this.deliveredTotal,
|
|
4512
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4483
4513
|
flushing: this.inFlight !== void 0
|
|
4484
4514
|
};
|
|
4485
4515
|
}
|
|
@@ -4494,6 +4524,7 @@ var BeaconBuffer = class {
|
|
|
4494
4524
|
inFlight: false
|
|
4495
4525
|
};
|
|
4496
4526
|
this.queue.push(entry);
|
|
4527
|
+
this.enqueuedTotal += 1;
|
|
4497
4528
|
return entry;
|
|
4498
4529
|
}
|
|
4499
4530
|
dropOldest() {
|
|
@@ -4539,7 +4570,11 @@ var BeaconBuffer = class {
|
|
|
4539
4570
|
droppedSinceLast: reportedDropped,
|
|
4540
4571
|
queueDepth: this.queue.length,
|
|
4541
4572
|
adapter: dest.adapter ?? "edge-core",
|
|
4542
|
-
version: SDK_VERSION
|
|
4573
|
+
version: SDK_VERSION,
|
|
4574
|
+
containerId: this.opts.containerId,
|
|
4575
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4576
|
+
deliveredTotal: this.deliveredTotal,
|
|
4577
|
+
droppedTotal: this.droppedTotal
|
|
4543
4578
|
};
|
|
4544
4579
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
4545
4580
|
const response = await withBudget(
|