@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/bin/astrasync.js
CHANGED
|
@@ -36,7 +36,7 @@ var SDK_VERSION;
|
|
|
36
36
|
var init_version = __esm({
|
|
37
37
|
"src/version.ts"() {
|
|
38
38
|
"use strict";
|
|
39
|
-
SDK_VERSION = "5.
|
|
39
|
+
SDK_VERSION = "5.14.0";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -5072,7 +5072,7 @@ var init_failure_posture = __esm({
|
|
|
5072
5072
|
});
|
|
5073
5073
|
|
|
5074
5074
|
// src/verify.ts
|
|
5075
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
5075
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
5076
5076
|
initCheckPerformed = true;
|
|
5077
5077
|
try {
|
|
5078
5078
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -5090,7 +5090,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
5090
5090
|
);
|
|
5091
5091
|
}
|
|
5092
5092
|
if (apiKey) {
|
|
5093
|
-
const
|
|
5093
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
5094
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
5094
5095
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
5095
5096
|
});
|
|
5096
5097
|
if (selfCheck.status === 401) {
|
|
@@ -5102,6 +5103,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
5102
5103
|
console.error(message);
|
|
5103
5104
|
} else if (selfCheck.ok) {
|
|
5104
5105
|
const body = await selfCheck.json().catch(() => ({}));
|
|
5106
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
5107
|
+
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.`;
|
|
5108
|
+
if (strictInit) {
|
|
5109
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
5110
|
+
}
|
|
5111
|
+
console.error(message);
|
|
5112
|
+
}
|
|
5105
5113
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
5106
5114
|
console.warn(
|
|
5107
5115
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -5204,11 +5212,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
5204
5212
|
const isMisconfig = source === "merchant_misconfig";
|
|
5205
5213
|
const urls = options.urls;
|
|
5206
5214
|
const guidance = isMisconfig ? {
|
|
5207
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
5215
|
+
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.",
|
|
5208
5216
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
5209
5217
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
5210
5218
|
steps: [
|
|
5211
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
5219
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
5212
5220
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
5213
5221
|
]
|
|
5214
5222
|
} : isApiError ? {
|
|
@@ -5419,12 +5427,13 @@ async function callVerifyAccessAPI(config, request2) {
|
|
|
5419
5427
|
};
|
|
5420
5428
|
}
|
|
5421
5429
|
if (!response.ok) {
|
|
5422
|
-
|
|
5430
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
5431
|
+
if (response.status === 401 || keyMismatch) {
|
|
5423
5432
|
return {
|
|
5424
5433
|
success: false,
|
|
5425
5434
|
error: data.message || data.error || "Integration API key rejected",
|
|
5426
5435
|
misconfig: true,
|
|
5427
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
5436
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
5428
5437
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
5429
5438
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
5430
5439
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -5457,14 +5466,22 @@ async function verify(config, request2, options) {
|
|
|
5457
5466
|
mergedConfig.apiBaseUrl,
|
|
5458
5467
|
mergedConfig.debug,
|
|
5459
5468
|
true,
|
|
5460
|
-
mergedConfig.apiKey
|
|
5469
|
+
mergedConfig.apiKey,
|
|
5470
|
+
{
|
|
5471
|
+
id: mergedConfig.counterpartyId,
|
|
5472
|
+
url: mergedConfig.counterpartyUrl ?? request2.counterpartyUrl
|
|
5473
|
+
}
|
|
5461
5474
|
);
|
|
5462
5475
|
} else {
|
|
5463
5476
|
void performInitCheck(
|
|
5464
5477
|
mergedConfig.apiBaseUrl,
|
|
5465
5478
|
mergedConfig.debug,
|
|
5466
5479
|
false,
|
|
5467
|
-
mergedConfig.apiKey
|
|
5480
|
+
mergedConfig.apiKey,
|
|
5481
|
+
{
|
|
5482
|
+
id: mergedConfig.counterpartyId,
|
|
5483
|
+
url: mergedConfig.counterpartyUrl ?? request2.counterpartyUrl
|
|
5484
|
+
}
|
|
5468
5485
|
);
|
|
5469
5486
|
}
|
|
5470
5487
|
}
|
|
@@ -5800,7 +5817,7 @@ async function withBudget(promise, ms) {
|
|
|
5800
5817
|
if (timer) clearTimeout(timer);
|
|
5801
5818
|
}
|
|
5802
5819
|
}
|
|
5803
|
-
var destKeyOf, BeaconBuffer, beaconBuffer;
|
|
5820
|
+
var CONTAINER_ID, destKeyOf, BeaconBuffer, beaconBuffer;
|
|
5804
5821
|
var init_events = __esm({
|
|
5805
5822
|
"src/edge-core/events.ts"() {
|
|
5806
5823
|
"use strict";
|
|
@@ -5808,6 +5825,11 @@ var init_events = __esm({
|
|
|
5808
5825
|
init_metadata_capture();
|
|
5809
5826
|
init_version();
|
|
5810
5827
|
init_request();
|
|
5828
|
+
CONTAINER_ID = (() => {
|
|
5829
|
+
const c = globalThis.crypto;
|
|
5830
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
5831
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
5832
|
+
})();
|
|
5811
5833
|
destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
|
|
5812
5834
|
BeaconBuffer = class {
|
|
5813
5835
|
constructor(options = {}) {
|
|
@@ -5815,6 +5837,7 @@ var init_events = __esm({
|
|
|
5815
5837
|
this.droppedSinceLast = 0;
|
|
5816
5838
|
this.droppedTotal = 0;
|
|
5817
5839
|
this.deliveredTotal = 0;
|
|
5840
|
+
this.enqueuedTotal = 0;
|
|
5818
5841
|
this.backoffUntil = 0;
|
|
5819
5842
|
this.collapse = /* @__PURE__ */ new Map();
|
|
5820
5843
|
/** Keys the backend answered 401 for — later batches go unauthenticated. */
|
|
@@ -5827,13 +5850,16 @@ var init_events = __esm({
|
|
|
5827
5850
|
collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
|
|
5828
5851
|
requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
|
|
5829
5852
|
retryBackoffMs: options.retryBackoffMs ?? 1e3,
|
|
5853
|
+
holdRepeats: options.holdRepeats ?? false,
|
|
5854
|
+
containerId: options.containerId ?? CONTAINER_ID,
|
|
5830
5855
|
now: options.now ?? Date.now
|
|
5831
5856
|
};
|
|
5832
5857
|
}
|
|
5833
5858
|
/**
|
|
5834
5859
|
* Queue one beacon. With a `collapseKey`, a repeat inside the window is
|
|
5835
|
-
* merged into
|
|
5836
|
-
*
|
|
5860
|
+
* merged into this key's item while that item is still queued (not yet in
|
|
5861
|
+
* flight). Once it has left, the repeat becomes a new item, sendable on
|
|
5862
|
+
* this flush — nothing waits for a later invocation (round 27.6).
|
|
5837
5863
|
*/
|
|
5838
5864
|
enqueue(dest, item, collapseKey) {
|
|
5839
5865
|
const now = this.opts.now();
|
|
@@ -5846,12 +5872,15 @@ var init_events = __esm({
|
|
|
5846
5872
|
return;
|
|
5847
5873
|
}
|
|
5848
5874
|
}
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5875
|
+
if (this.opts.holdRepeats) {
|
|
5876
|
+
entry.held = this.push(
|
|
5877
|
+
dest,
|
|
5878
|
+
{ ...item, repeatCount: 1 },
|
|
5879
|
+
entry.firstSeenAt + this.opts.collapseWindowMs
|
|
5880
|
+
);
|
|
5881
|
+
return;
|
|
5882
|
+
}
|
|
5883
|
+
entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
|
|
5855
5884
|
return;
|
|
5856
5885
|
}
|
|
5857
5886
|
this.collapse.delete(collapseKey);
|
|
@@ -5887,6 +5916,7 @@ var init_events = __esm({
|
|
|
5887
5916
|
droppedSinceLast: this.droppedSinceLast,
|
|
5888
5917
|
droppedTotal: this.droppedTotal,
|
|
5889
5918
|
deliveredTotal: this.deliveredTotal,
|
|
5919
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
5890
5920
|
flushing: this.inFlight !== void 0
|
|
5891
5921
|
};
|
|
5892
5922
|
}
|
|
@@ -5901,6 +5931,7 @@ var init_events = __esm({
|
|
|
5901
5931
|
inFlight: false
|
|
5902
5932
|
};
|
|
5903
5933
|
this.queue.push(entry);
|
|
5934
|
+
this.enqueuedTotal += 1;
|
|
5904
5935
|
return entry;
|
|
5905
5936
|
}
|
|
5906
5937
|
dropOldest() {
|
|
@@ -5946,7 +5977,11 @@ var init_events = __esm({
|
|
|
5946
5977
|
droppedSinceLast: reportedDropped,
|
|
5947
5978
|
queueDepth: this.queue.length,
|
|
5948
5979
|
adapter: dest.adapter ?? "edge-core",
|
|
5949
|
-
version: SDK_VERSION
|
|
5980
|
+
version: SDK_VERSION,
|
|
5981
|
+
containerId: this.opts.containerId,
|
|
5982
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
5983
|
+
deliveredTotal: this.deliveredTotal,
|
|
5984
|
+
droppedTotal: this.droppedTotal
|
|
5950
5985
|
};
|
|
5951
5986
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
5952
5987
|
const response = await withBudget(
|
|
@@ -3988,7 +3988,7 @@ function getTrustLevel(score) {
|
|
|
3988
3988
|
}
|
|
3989
3989
|
|
|
3990
3990
|
// src/version.ts
|
|
3991
|
-
var SDK_VERSION = "5.
|
|
3991
|
+
var SDK_VERSION = "5.14.0";
|
|
3992
3992
|
|
|
3993
3993
|
// src/http.ts
|
|
3994
3994
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -4035,7 +4035,7 @@ var DEFAULT_CONFIG = {
|
|
|
4035
4035
|
};
|
|
4036
4036
|
var initCheckPerformed = false;
|
|
4037
4037
|
var deprecationWarningShown = false;
|
|
4038
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
4038
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
|
|
4039
4039
|
initCheckPerformed = true;
|
|
4040
4040
|
try {
|
|
4041
4041
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -4053,7 +4053,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
4053
4053
|
);
|
|
4054
4054
|
}
|
|
4055
4055
|
if (apiKey) {
|
|
4056
|
-
const
|
|
4056
|
+
const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
|
|
4057
|
+
const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
|
|
4057
4058
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4058
4059
|
});
|
|
4059
4060
|
if (selfCheck.status === 401) {
|
|
@@ -4065,6 +4066,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
|
4065
4066
|
console.error(message);
|
|
4066
4067
|
} else if (selfCheck.ok) {
|
|
4067
4068
|
const body = await selfCheck.json().catch(() => ({}));
|
|
4069
|
+
if (body.counterparty && body.counterparty.canVerify === false) {
|
|
4070
|
+
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.`;
|
|
4071
|
+
if (strictInit) {
|
|
4072
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
4073
|
+
}
|
|
4074
|
+
console.error(message);
|
|
4075
|
+
}
|
|
4068
4076
|
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
4069
4077
|
console.warn(
|
|
4070
4078
|
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
@@ -4169,11 +4177,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
4169
4177
|
const isMisconfig = source === "merchant_misconfig";
|
|
4170
4178
|
const urls = options.urls;
|
|
4171
4179
|
const guidance = isMisconfig ? {
|
|
4172
|
-
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or
|
|
4180
|
+
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.",
|
|
4173
4181
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
4174
4182
|
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
4175
4183
|
steps: [
|
|
4176
|
-
"Report the failure to the site operator \u2014 their AstraSync API key needs
|
|
4184
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
|
|
4177
4185
|
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
4178
4186
|
]
|
|
4179
4187
|
} : isApiError ? {
|
|
@@ -4385,12 +4393,13 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4385
4393
|
};
|
|
4386
4394
|
}
|
|
4387
4395
|
if (!response.ok) {
|
|
4388
|
-
|
|
4396
|
+
const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
|
|
4397
|
+
if (response.status === 401 || keyMismatch) {
|
|
4389
4398
|
return {
|
|
4390
4399
|
success: false,
|
|
4391
4400
|
error: data.message || data.error || "Integration API key rejected",
|
|
4392
4401
|
misconfig: true,
|
|
4393
|
-
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
4402
|
+
misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
|
|
4394
4403
|
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
4395
4404
|
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4396
4405
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
@@ -4423,14 +4432,22 @@ async function verify(config, request, options) {
|
|
|
4423
4432
|
mergedConfig.apiBaseUrl,
|
|
4424
4433
|
mergedConfig.debug,
|
|
4425
4434
|
true,
|
|
4426
|
-
mergedConfig.apiKey
|
|
4435
|
+
mergedConfig.apiKey,
|
|
4436
|
+
{
|
|
4437
|
+
id: mergedConfig.counterpartyId,
|
|
4438
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4439
|
+
}
|
|
4427
4440
|
);
|
|
4428
4441
|
} else {
|
|
4429
4442
|
void performInitCheck(
|
|
4430
4443
|
mergedConfig.apiBaseUrl,
|
|
4431
4444
|
mergedConfig.debug,
|
|
4432
4445
|
false,
|
|
4433
|
-
mergedConfig.apiKey
|
|
4446
|
+
mergedConfig.apiKey,
|
|
4447
|
+
{
|
|
4448
|
+
id: mergedConfig.counterpartyId,
|
|
4449
|
+
url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
|
|
4450
|
+
}
|
|
4434
4451
|
);
|
|
4435
4452
|
}
|
|
4436
4453
|
}
|
|
@@ -4641,6 +4658,11 @@ async function withBudget(promise, ms) {
|
|
|
4641
4658
|
if (timer) clearTimeout(timer);
|
|
4642
4659
|
}
|
|
4643
4660
|
}
|
|
4661
|
+
var CONTAINER_ID = (() => {
|
|
4662
|
+
const c = globalThis.crypto;
|
|
4663
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
4664
|
+
return `c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
4665
|
+
})();
|
|
4644
4666
|
var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
|
|
4645
4667
|
var BeaconBuffer = class {
|
|
4646
4668
|
constructor(options = {}) {
|
|
@@ -4648,6 +4670,7 @@ var BeaconBuffer = class {
|
|
|
4648
4670
|
this.droppedSinceLast = 0;
|
|
4649
4671
|
this.droppedTotal = 0;
|
|
4650
4672
|
this.deliveredTotal = 0;
|
|
4673
|
+
this.enqueuedTotal = 0;
|
|
4651
4674
|
this.backoffUntil = 0;
|
|
4652
4675
|
this.collapse = /* @__PURE__ */ new Map();
|
|
4653
4676
|
/** Keys the backend answered 401 for — later batches go unauthenticated. */
|
|
@@ -4660,13 +4683,16 @@ var BeaconBuffer = class {
|
|
|
4660
4683
|
collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
|
|
4661
4684
|
requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
|
|
4662
4685
|
retryBackoffMs: options.retryBackoffMs ?? 1e3,
|
|
4686
|
+
holdRepeats: options.holdRepeats ?? false,
|
|
4687
|
+
containerId: options.containerId ?? CONTAINER_ID,
|
|
4663
4688
|
now: options.now ?? Date.now
|
|
4664
4689
|
};
|
|
4665
4690
|
}
|
|
4666
4691
|
/**
|
|
4667
4692
|
* Queue one beacon. With a `collapseKey`, a repeat inside the window is
|
|
4668
|
-
* merged into
|
|
4669
|
-
*
|
|
4693
|
+
* merged into this key's item while that item is still queued (not yet in
|
|
4694
|
+
* flight). Once it has left, the repeat becomes a new item, sendable on
|
|
4695
|
+
* this flush — nothing waits for a later invocation (round 27.6).
|
|
4670
4696
|
*/
|
|
4671
4697
|
enqueue(dest, item, collapseKey) {
|
|
4672
4698
|
const now = this.opts.now();
|
|
@@ -4679,12 +4705,15 @@ var BeaconBuffer = class {
|
|
|
4679
4705
|
return;
|
|
4680
4706
|
}
|
|
4681
4707
|
}
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4708
|
+
if (this.opts.holdRepeats) {
|
|
4709
|
+
entry.held = this.push(
|
|
4710
|
+
dest,
|
|
4711
|
+
{ ...item, repeatCount: 1 },
|
|
4712
|
+
entry.firstSeenAt + this.opts.collapseWindowMs
|
|
4713
|
+
);
|
|
4714
|
+
return;
|
|
4715
|
+
}
|
|
4716
|
+
entry.first = this.push(dest, { ...item, repeatCount: 1 }, now);
|
|
4688
4717
|
return;
|
|
4689
4718
|
}
|
|
4690
4719
|
this.collapse.delete(collapseKey);
|
|
@@ -4720,6 +4749,7 @@ var BeaconBuffer = class {
|
|
|
4720
4749
|
droppedSinceLast: this.droppedSinceLast,
|
|
4721
4750
|
droppedTotal: this.droppedTotal,
|
|
4722
4751
|
deliveredTotal: this.deliveredTotal,
|
|
4752
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4723
4753
|
flushing: this.inFlight !== void 0
|
|
4724
4754
|
};
|
|
4725
4755
|
}
|
|
@@ -4734,6 +4764,7 @@ var BeaconBuffer = class {
|
|
|
4734
4764
|
inFlight: false
|
|
4735
4765
|
};
|
|
4736
4766
|
this.queue.push(entry);
|
|
4767
|
+
this.enqueuedTotal += 1;
|
|
4737
4768
|
return entry;
|
|
4738
4769
|
}
|
|
4739
4770
|
dropOldest() {
|
|
@@ -4779,7 +4810,11 @@ var BeaconBuffer = class {
|
|
|
4779
4810
|
droppedSinceLast: reportedDropped,
|
|
4780
4811
|
queueDepth: this.queue.length,
|
|
4781
4812
|
adapter: dest.adapter ?? "edge-core",
|
|
4782
|
-
version: SDK_VERSION
|
|
4813
|
+
version: SDK_VERSION,
|
|
4814
|
+
containerId: this.opts.containerId,
|
|
4815
|
+
enqueuedTotal: this.enqueuedTotal,
|
|
4816
|
+
deliveredTotal: this.deliveredTotal,
|
|
4817
|
+
droppedTotal: this.droppedTotal
|
|
4783
4818
|
};
|
|
4784
4819
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
4785
4820
|
const response = await withBudget(
|