@astrasyncai/verification-gateway 3.12.0 → 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 +85 -8
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +85 -8
- 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 +90 -8
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +90 -8
- 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 +86 -8
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +86 -8
- 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 +71 -8
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +71 -8
- 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 +71 -8
- package/dist/bin/astrasync-codex-hook.js +71 -8
- package/dist/bin/astrasync-guard.js +71 -8
- package/dist/bin/astrasync.js +71 -8
- package/dist/browser/background.js +71 -8
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +71 -8
- 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 +71 -8
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +71 -8
- 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 +71 -8
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +71 -8
- 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-B39o89gf.d.mts → express-BZajRs4i.d.mts} +1 -1
- package/dist/{express-BuxKNO_q.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 +71 -8
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +71 -8
- 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-DME3w3lf.d.mts → index-B0cyMZDL.d.mts} +1 -1
- package/dist/{index-CqydB4ks.d.mts → index-BRYteOqO.d.mts} +1 -1
- package/dist/{index-BG62SXso.d.ts → index-BZQdVqNw.d.ts} +1 -1
- package/dist/{index-CLHdqs2M.d.ts → index-adgKhujR.d.ts} +1 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +119 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -8
- 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-Ddlw_J1J.d.ts → nextjs-D_iFf5k-.d.ts} +1 -1
- package/dist/{nextjs-D74W7wt-.d.mts → nextjs-DeUTnOBd.d.mts} +1 -1
- package/dist/{sdk-CT7gdkfR.d.ts → sdk-BM3mwEAq.d.ts} +1 -1
- package/dist/{sdk-Bn6bj7kt.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-BntuzEEn.d.mts → types-BcDf9Kk0.d.mts} +15 -0
- package/dist/{types-DHu7m9HI.d.ts → types-CHKCgDFC.d.ts} +1 -1
- package/dist/{types-Djw4GLtz.d.mts → types-DfnP7JiM.d.mts} +1 -1
- package/dist/{types-SDu4Llbe.d.ts → types-fTQD448H.d.ts} +15 -0
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +4 -2
- package/dist/verify.d.ts +4 -2
- package/dist/verify.js +76 -8
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +75 -8
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -65,7 +65,7 @@ function getTrustLevel(score) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// src/version.ts
|
|
68
|
-
var SDK_VERSION = "
|
|
68
|
+
var SDK_VERSION = "4.0.0";
|
|
69
69
|
|
|
70
70
|
// src/well-known.ts
|
|
71
71
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -143,7 +143,7 @@ var DEFAULT_CONFIG = {
|
|
|
143
143
|
};
|
|
144
144
|
var initCheckPerformed = false;
|
|
145
145
|
var deprecationWarningShown = false;
|
|
146
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
146
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
147
147
|
initCheckPerformed = true;
|
|
148
148
|
try {
|
|
149
149
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -160,6 +160,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
|
160
160
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
|
+
if (apiKey) {
|
|
164
|
+
const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
|
|
165
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
166
|
+
});
|
|
167
|
+
if (selfCheck.status === 401) {
|
|
168
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
169
|
+
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}` : "") + `.`;
|
|
170
|
+
if (strictInit) {
|
|
171
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
172
|
+
}
|
|
173
|
+
console.error(message);
|
|
174
|
+
} else if (selfCheck.ok) {
|
|
175
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
176
|
+
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
177
|
+
console.warn(
|
|
178
|
+
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
179
|
+
);
|
|
180
|
+
} else if (debug) {
|
|
181
|
+
console.log("[VerificationGateway] API key self-check passed");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
163
185
|
} catch (err) {
|
|
164
186
|
if (strictInit) {
|
|
165
187
|
throw err;
|
|
@@ -271,8 +293,17 @@ function extractCredentials(headers, query) {
|
|
|
271
293
|
function createGuidanceResponse(_config, reason, options = {}) {
|
|
272
294
|
const source = options.source ?? "no_credentials";
|
|
273
295
|
const isApiError = source === "api_error";
|
|
296
|
+
const isMisconfig = source === "merchant_misconfig";
|
|
274
297
|
const urls = options.urls;
|
|
275
|
-
const guidance =
|
|
298
|
+
const guidance = isMisconfig ? {
|
|
299
|
+
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.",
|
|
300
|
+
registrationUrl: urls?.registrationUrl ?? "",
|
|
301
|
+
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
302
|
+
steps: [
|
|
303
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
|
|
304
|
+
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
305
|
+
]
|
|
306
|
+
} : isApiError ? {
|
|
276
307
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
277
308
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
278
309
|
documentationUrl: urls?.documentationUrl ?? "",
|
|
@@ -310,13 +341,22 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
310
341
|
// partners (and their custom onDenied handlers) can branch on
|
|
311
342
|
// dimension. Without this, the synthesised stub was indistinguishable
|
|
312
343
|
// from a real policy deny.
|
|
313
|
-
failures:
|
|
344
|
+
failures: isMisconfig ? [
|
|
345
|
+
{
|
|
346
|
+
dimension: "verify_access.merchant_misconfigured",
|
|
347
|
+
message: reason ?? "The integration API key was rejected by AstraSync",
|
|
348
|
+
guidance: guidance.message
|
|
349
|
+
}
|
|
350
|
+
] : isApiError ? [
|
|
314
351
|
{
|
|
315
352
|
dimension: "verify_access.api_error",
|
|
316
353
|
message: reason ?? "Verification temporarily unavailable",
|
|
317
354
|
guidance: guidance.message
|
|
318
355
|
}
|
|
319
356
|
] : void 0,
|
|
357
|
+
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
358
|
+
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
359
|
+
...isMisconfig && { misconfigured: true },
|
|
320
360
|
correlationId: options.correlationId,
|
|
321
361
|
attemptId: options.attemptId,
|
|
322
362
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
@@ -371,7 +411,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
371
411
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
372
412
|
method: "POST",
|
|
373
413
|
headers,
|
|
374
|
-
body: JSON.stringify(body)
|
|
414
|
+
body: JSON.stringify(body),
|
|
415
|
+
signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
|
|
375
416
|
});
|
|
376
417
|
const data = await response.json();
|
|
377
418
|
if (response.status === 410) {
|
|
@@ -395,6 +436,17 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
395
436
|
};
|
|
396
437
|
}
|
|
397
438
|
if (!response.ok) {
|
|
439
|
+
if (response.status === 401) {
|
|
440
|
+
return {
|
|
441
|
+
success: false,
|
|
442
|
+
error: data.message || data.error || "Integration API key rejected",
|
|
443
|
+
misconfig: true,
|
|
444
|
+
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
445
|
+
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
446
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
447
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
448
|
+
};
|
|
449
|
+
}
|
|
398
450
|
return {
|
|
399
451
|
success: false,
|
|
400
452
|
error: data.message || data.error || `API returned ${response.status}`,
|
|
@@ -416,9 +468,19 @@ async function verify(config, request, options) {
|
|
|
416
468
|
const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
|
|
417
469
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
418
470
|
if (mergedConfig.strictInit) {
|
|
419
|
-
await performInitCheck(
|
|
471
|
+
await performInitCheck(
|
|
472
|
+
mergedConfig.apiBaseUrl,
|
|
473
|
+
mergedConfig.debug,
|
|
474
|
+
true,
|
|
475
|
+
mergedConfig.apiKey
|
|
476
|
+
);
|
|
420
477
|
} else {
|
|
421
|
-
void performInitCheck(
|
|
478
|
+
void performInitCheck(
|
|
479
|
+
mergedConfig.apiBaseUrl,
|
|
480
|
+
mergedConfig.debug,
|
|
481
|
+
false,
|
|
482
|
+
mergedConfig.apiKey
|
|
483
|
+
);
|
|
422
484
|
}
|
|
423
485
|
}
|
|
424
486
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
@@ -457,9 +519,10 @@ async function verify(config, request, options) {
|
|
|
457
519
|
const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
|
|
458
520
|
if (!apiResponse.success) {
|
|
459
521
|
return createGuidanceResponse(mergedConfig, apiResponse.error, {
|
|
460
|
-
source: "api_error",
|
|
522
|
+
source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
|
|
461
523
|
correlationId: apiResponse.correlationId,
|
|
462
524
|
attemptId: apiResponse.attemptId,
|
|
525
|
+
remediation: apiResponse.remediation,
|
|
463
526
|
urls
|
|
464
527
|
});
|
|
465
528
|
}
|
|
@@ -1016,6 +1079,20 @@ function dedupeFailures(result) {
|
|
|
1016
1079
|
}
|
|
1017
1080
|
}
|
|
1018
1081
|
function defaultOnDenied(result, _req, res) {
|
|
1082
|
+
if (result.misconfigured) {
|
|
1083
|
+
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
1084
|
+
res.status(503).json({
|
|
1085
|
+
success: false,
|
|
1086
|
+
error: {
|
|
1087
|
+
code: "MERCHANT_VERIFICATION_MISCONFIGURED",
|
|
1088
|
+
message: result.denialReasons?.[0] || "This site's AstraSync integration is misconfigured",
|
|
1089
|
+
guidance: result.guidance,
|
|
1090
|
+
failures: result.failures,
|
|
1091
|
+
correlationId: result.correlationId
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1019
1096
|
const statusCode = !result.identityVerified ? 401 : 403;
|
|
1020
1097
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
1021
1098
|
res.status(statusCode).json({
|