@astrasyncai/verification-gateway 3.11.1 → 4.0.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/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +2 -2
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.js +106 -10
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +106 -10
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/mcp.js +111 -10
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +111 -10
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +2 -2
- package/dist/adapters/nextjs.d.ts +2 -2
- package/dist/adapters/nextjs.js +107 -10
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +107 -10
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +2 -2
- package/dist/adapters/sdk.d.ts +2 -2
- package/dist/adapters/sdk.js +92 -10
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +92 -10
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/bin/astrasync-claude-hook.js +92 -10
- package/dist/bin/astrasync-codex-hook.js +92 -10
- package/dist/bin/astrasync-guard.js +92 -10
- package/dist/bin/astrasync.js +93 -10
- package/dist/browser/background.js +92 -10
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +92 -10
- package/dist/browser/background.mjs.map +1 -1
- package/dist/browser/browser-adapter.d.mts +2 -2
- package/dist/browser/browser-adapter.d.ts +2 -2
- package/dist/claude-code/claude-code-adapter.d.mts +2 -2
- package/dist/claude-code/claude-code-adapter.d.ts +2 -2
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/codex/index.d.mts +2 -2
- package/dist/codex/index.d.ts +2 -2
- package/dist/codex/index.js +92 -10
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +92 -10
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/cursor-adapter.d.mts +2 -2
- package/dist/cursor/cursor-adapter.d.ts +2 -2
- package/dist/cursor/extension.d.mts +2 -2
- package/dist/cursor/extension.d.ts +2 -2
- package/dist/cursor/extension.js +92 -10
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +92 -10
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +1 -1
- package/dist/edge-config.d.ts +1 -1
- package/dist/{express-DCXa1oqj.d.mts → express-BZajRs4i.d.mts} +1 -1
- package/dist/{express-ClNtDhhc.d.ts → express-CjCUB1k7.d.ts} +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +92 -10
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +92 -10
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +2 -2
- package/dist/git-trigger/git-hooks.d.ts +2 -2
- package/dist/{index-BrNKDmiR.d.mts → index-B0cyMZDL.d.mts} +1 -1
- package/dist/{index-Dr_XiN65.d.mts → index-BRYteOqO.d.mts} +1 -1
- package/dist/{index-CfHurO1P.d.ts → index-BZQdVqNw.d.ts} +1 -1
- package/dist/{index-D2ztkumS.d.ts → index-adgKhujR.d.ts} +1 -1
- package/dist/index.d.mts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +160 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -10
- package/dist/index.mjs.map +1 -1
- package/dist/local-evaluator/evaluator.d.mts +2 -2
- package/dist/local-evaluator/evaluator.d.ts +2 -2
- package/dist/{nextjs-CEBVBsdi.d.ts → nextjs-D_iFf5k-.d.ts} +1 -1
- package/dist/{nextjs-DcQIk6Zj.d.mts → nextjs-DeUTnOBd.d.mts} +1 -1
- package/dist/{sdk-H0JCLW2y.d.ts → sdk-BM3mwEAq.d.ts} +1 -1
- package/dist/{sdk-CZkbSOeO.d.mts → sdk-_il1Q41f.d.mts} +1 -1
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-sy3tq8lp.d.mts → types-BcDf9Kk0.d.mts} +118 -1
- package/dist/{types-DhFPiZ3t.d.ts → types-CHKCgDFC.d.ts} +1 -1
- package/dist/{types-cQVCMeNV.d.mts → types-DfnP7JiM.d.mts} +1 -1
- package/dist/{types-9tns4wyl.d.ts → types-fTQD448H.d.ts} +118 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +15 -2
- package/dist/verify.d.ts +15 -2
- package/dist/verify.js +117 -10
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +115 -10
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
package/dist/adapters/sdk.mjs
CHANGED
|
@@ -78,7 +78,7 @@ function getCapabilities(accessLevel) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// src/version.ts
|
|
81
|
-
var SDK_VERSION = "
|
|
81
|
+
var SDK_VERSION = "4.0.0";
|
|
82
82
|
|
|
83
83
|
// src/well-known.ts
|
|
84
84
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -104,7 +104,7 @@ var DEFAULT_CONFIG = {
|
|
|
104
104
|
};
|
|
105
105
|
var initCheckPerformed = false;
|
|
106
106
|
var deprecationWarningShown = false;
|
|
107
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
107
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
108
108
|
initCheckPerformed = true;
|
|
109
109
|
try {
|
|
110
110
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -121,6 +121,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
|
121
121
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
|
+
if (apiKey) {
|
|
125
|
+
const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
|
|
126
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
127
|
+
});
|
|
128
|
+
if (selfCheck.status === 401) {
|
|
129
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
130
|
+
const message = `[VerificationGateway] the configured AstraSync API key was REJECTED at startup (${body.code ?? "api_key_invalid"}: ${body.message ?? "invalid key"}). Every inbound agent will be turned away until the key is rotated` + (body.remediation?.manageUrl ? ` at ${body.remediation.manageUrl}` : "") + `.`;
|
|
131
|
+
if (strictInit) {
|
|
132
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
133
|
+
}
|
|
134
|
+
console.error(message);
|
|
135
|
+
} else if (selfCheck.ok) {
|
|
136
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
137
|
+
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
138
|
+
console.warn(
|
|
139
|
+
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
140
|
+
);
|
|
141
|
+
} else if (debug) {
|
|
142
|
+
console.log("[VerificationGateway] API key self-check passed");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
124
146
|
} catch (err) {
|
|
125
147
|
if (strictInit) {
|
|
126
148
|
throw err;
|
|
@@ -201,8 +223,17 @@ function clearCache() {
|
|
|
201
223
|
function createGuidanceResponse(_config, reason, options = {}) {
|
|
202
224
|
const source = options.source ?? "no_credentials";
|
|
203
225
|
const isApiError = source === "api_error";
|
|
226
|
+
const isMisconfig = source === "merchant_misconfig";
|
|
204
227
|
const urls = options.urls;
|
|
205
|
-
const guidance =
|
|
228
|
+
const guidance = isMisconfig ? {
|
|
229
|
+
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or rotated). Your identity and the AstraSync platform are fine \u2014 contact the site operator. Retrying will not help.",
|
|
230
|
+
registrationUrl: urls?.registrationUrl ?? "",
|
|
231
|
+
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
232
|
+
steps: [
|
|
233
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
|
|
234
|
+
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
235
|
+
]
|
|
236
|
+
} : isApiError ? {
|
|
206
237
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
207
238
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
208
239
|
documentationUrl: urls?.documentationUrl ?? "",
|
|
@@ -240,14 +271,24 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
240
271
|
// partners (and their custom onDenied handlers) can branch on
|
|
241
272
|
// dimension. Without this, the synthesised stub was indistinguishable
|
|
242
273
|
// from a real policy deny.
|
|
243
|
-
failures:
|
|
274
|
+
failures: isMisconfig ? [
|
|
275
|
+
{
|
|
276
|
+
dimension: "verify_access.merchant_misconfigured",
|
|
277
|
+
message: reason ?? "The integration API key was rejected by AstraSync",
|
|
278
|
+
guidance: guidance.message
|
|
279
|
+
}
|
|
280
|
+
] : isApiError ? [
|
|
244
281
|
{
|
|
245
282
|
dimension: "verify_access.api_error",
|
|
246
283
|
message: reason ?? "Verification temporarily unavailable",
|
|
247
284
|
guidance: guidance.message
|
|
248
285
|
}
|
|
249
286
|
] : void 0,
|
|
287
|
+
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
288
|
+
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
289
|
+
...isMisconfig && { misconfigured: true },
|
|
250
290
|
correlationId: options.correlationId,
|
|
291
|
+
attemptId: options.attemptId,
|
|
251
292
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
252
293
|
};
|
|
253
294
|
}
|
|
@@ -277,6 +318,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
277
318
|
body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
|
|
278
319
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
279
320
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
321
|
+
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
322
|
+
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
280
323
|
body.sdkVersion = SDK_VERSION;
|
|
281
324
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
282
325
|
const meta = {
|
|
@@ -298,12 +341,16 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
298
341
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
299
342
|
method: "POST",
|
|
300
343
|
headers,
|
|
301
|
-
body: JSON.stringify(body)
|
|
344
|
+
body: JSON.stringify(body),
|
|
345
|
+
signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
|
|
302
346
|
});
|
|
303
347
|
const data = await response.json();
|
|
304
348
|
if (response.status === 410) {
|
|
305
349
|
return {
|
|
306
350
|
success: true,
|
|
351
|
+
// 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
|
|
352
|
+
// the synthesised 410 deny shape (echoed on every branch).
|
|
353
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
|
|
307
354
|
access: {
|
|
308
355
|
allowed: false,
|
|
309
356
|
accessLevel: "none",
|
|
@@ -319,10 +366,22 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
319
366
|
};
|
|
320
367
|
}
|
|
321
368
|
if (!response.ok) {
|
|
369
|
+
if (response.status === 401) {
|
|
370
|
+
return {
|
|
371
|
+
success: false,
|
|
372
|
+
error: data.message || data.error || "Integration API key rejected",
|
|
373
|
+
misconfig: true,
|
|
374
|
+
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
375
|
+
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
376
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
377
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
378
|
+
};
|
|
379
|
+
}
|
|
322
380
|
return {
|
|
323
381
|
success: false,
|
|
324
382
|
error: data.message || data.error || `API returned ${response.status}`,
|
|
325
|
-
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
|
|
383
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
384
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
326
385
|
};
|
|
327
386
|
}
|
|
328
387
|
return data;
|
|
@@ -339,9 +398,19 @@ async function verify(config, request, options) {
|
|
|
339
398
|
const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
|
|
340
399
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
341
400
|
if (mergedConfig.strictInit) {
|
|
342
|
-
await performInitCheck(
|
|
401
|
+
await performInitCheck(
|
|
402
|
+
mergedConfig.apiBaseUrl,
|
|
403
|
+
mergedConfig.debug,
|
|
404
|
+
true,
|
|
405
|
+
mergedConfig.apiKey
|
|
406
|
+
);
|
|
343
407
|
} else {
|
|
344
|
-
void performInitCheck(
|
|
408
|
+
void performInitCheck(
|
|
409
|
+
mergedConfig.apiBaseUrl,
|
|
410
|
+
mergedConfig.debug,
|
|
411
|
+
false,
|
|
412
|
+
mergedConfig.apiKey
|
|
413
|
+
);
|
|
345
414
|
}
|
|
346
415
|
}
|
|
347
416
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
@@ -356,7 +425,13 @@ async function verify(config, request, options) {
|
|
|
356
425
|
if (mergedConfig.debug) {
|
|
357
426
|
console.log("[VerificationGateway] Returning cached result");
|
|
358
427
|
}
|
|
359
|
-
|
|
428
|
+
const hit = { ...cached };
|
|
429
|
+
if (request.attemptId) {
|
|
430
|
+
hit.attemptId = request.attemptId;
|
|
431
|
+
} else {
|
|
432
|
+
delete hit.attemptId;
|
|
433
|
+
}
|
|
434
|
+
return hit;
|
|
360
435
|
}
|
|
361
436
|
}
|
|
362
437
|
const enrichedRequest = { ...request };
|
|
@@ -374,8 +449,10 @@ async function verify(config, request, options) {
|
|
|
374
449
|
const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
|
|
375
450
|
if (!apiResponse.success) {
|
|
376
451
|
return createGuidanceResponse(mergedConfig, apiResponse.error, {
|
|
377
|
-
source: "api_error",
|
|
452
|
+
source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
|
|
378
453
|
correlationId: apiResponse.correlationId,
|
|
454
|
+
attemptId: apiResponse.attemptId,
|
|
455
|
+
remediation: apiResponse.remediation,
|
|
379
456
|
urls
|
|
380
457
|
});
|
|
381
458
|
}
|
|
@@ -411,6 +488,9 @@ async function verify(config, request, options) {
|
|
|
411
488
|
// Anonymous traffic has no session → correlationId is the per-attempt
|
|
412
489
|
// linking key (the sessionId-equivalent for anonymous callers).
|
|
413
490
|
correlationId: apiResponse.correlationId,
|
|
491
|
+
// 3.12.0 (Trust Record): server echoes the attempt-chain handle on
|
|
492
|
+
// every branch — denials included (the funnel outlives one deny).
|
|
493
|
+
attemptId: apiResponse.attemptId,
|
|
414
494
|
recommendation: apiResponse.recommendation,
|
|
415
495
|
recommendationReasons: apiResponse.recommendationReasons,
|
|
416
496
|
stepUpApproval: apiResponse.stepUpApproval,
|
|
@@ -462,6 +542,8 @@ async function verify(config, request, options) {
|
|
|
462
542
|
// v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
|
|
463
543
|
// (no session row exists for unverified callers).
|
|
464
544
|
correlationId: apiResponse.correlationId,
|
|
545
|
+
// 3.12.0 (Trust Record): server-echoed attempt-chain handle.
|
|
546
|
+
attemptId: apiResponse.attemptId,
|
|
465
547
|
runtimeChallenge: apiResponse.runtimeChallenge,
|
|
466
548
|
tokenGuidance: apiResponse.tokenGuidance,
|
|
467
549
|
recommendation: apiResponse.recommendation,
|