@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
package/dist/adapters/mcp.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request, Response, RequestHandler } from 'express';
|
|
2
|
-
import { a as AccessLevel, G as GatewayConfig, w as VerificationResult } from '../types-
|
|
2
|
+
import { a as AccessLevel, G as GatewayConfig, w as VerificationResult } from '../types-BcDf9Kk0.mjs';
|
|
3
3
|
import '../metadata-capture.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/adapters/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request, Response, RequestHandler } from 'express';
|
|
2
|
-
import { a as AccessLevel, G as GatewayConfig, w as VerificationResult } from '../types-
|
|
2
|
+
import { a as AccessLevel, G as GatewayConfig, w as VerificationResult } from '../types-fTQD448H.js';
|
|
3
3
|
import '../metadata-capture.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/adapters/mcp.js
CHANGED
|
@@ -40,7 +40,7 @@ function getTrustLevel(score) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// src/version.ts
|
|
43
|
-
var SDK_VERSION = "
|
|
43
|
+
var SDK_VERSION = "4.0.0";
|
|
44
44
|
|
|
45
45
|
// src/well-known.ts
|
|
46
46
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -118,7 +118,7 @@ var DEFAULT_CONFIG = {
|
|
|
118
118
|
};
|
|
119
119
|
var initCheckPerformed = false;
|
|
120
120
|
var deprecationWarningShown = false;
|
|
121
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
121
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
122
122
|
initCheckPerformed = true;
|
|
123
123
|
try {
|
|
124
124
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -135,6 +135,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
|
135
135
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
|
+
if (apiKey) {
|
|
139
|
+
const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
|
|
140
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
141
|
+
});
|
|
142
|
+
if (selfCheck.status === 401) {
|
|
143
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
144
|
+
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}` : "") + `.`;
|
|
145
|
+
if (strictInit) {
|
|
146
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
147
|
+
}
|
|
148
|
+
console.error(message);
|
|
149
|
+
} else if (selfCheck.ok) {
|
|
150
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
151
|
+
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
152
|
+
console.warn(
|
|
153
|
+
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
154
|
+
);
|
|
155
|
+
} else if (debug) {
|
|
156
|
+
console.log("[VerificationGateway] API key self-check passed");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
138
160
|
} catch (err) {
|
|
139
161
|
if (strictInit) {
|
|
140
162
|
throw err;
|
|
@@ -246,8 +268,17 @@ function extractCredentials(headers, query) {
|
|
|
246
268
|
function createGuidanceResponse(_config, reason, options = {}) {
|
|
247
269
|
const source = options.source ?? "no_credentials";
|
|
248
270
|
const isApiError = source === "api_error";
|
|
271
|
+
const isMisconfig = source === "merchant_misconfig";
|
|
249
272
|
const urls = options.urls;
|
|
250
|
-
const guidance =
|
|
273
|
+
const guidance = isMisconfig ? {
|
|
274
|
+
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.",
|
|
275
|
+
registrationUrl: urls?.registrationUrl ?? "",
|
|
276
|
+
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
277
|
+
steps: [
|
|
278
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
|
|
279
|
+
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
280
|
+
]
|
|
281
|
+
} : isApiError ? {
|
|
251
282
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
252
283
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
253
284
|
documentationUrl: urls?.documentationUrl ?? "",
|
|
@@ -285,13 +316,22 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
285
316
|
// partners (and their custom onDenied handlers) can branch on
|
|
286
317
|
// dimension. Without this, the synthesised stub was indistinguishable
|
|
287
318
|
// from a real policy deny.
|
|
288
|
-
failures:
|
|
319
|
+
failures: isMisconfig ? [
|
|
320
|
+
{
|
|
321
|
+
dimension: "verify_access.merchant_misconfigured",
|
|
322
|
+
message: reason ?? "The integration API key was rejected by AstraSync",
|
|
323
|
+
guidance: guidance.message
|
|
324
|
+
}
|
|
325
|
+
] : isApiError ? [
|
|
289
326
|
{
|
|
290
327
|
dimension: "verify_access.api_error",
|
|
291
328
|
message: reason ?? "Verification temporarily unavailable",
|
|
292
329
|
guidance: guidance.message
|
|
293
330
|
}
|
|
294
331
|
] : void 0,
|
|
332
|
+
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
333
|
+
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
334
|
+
...isMisconfig && { misconfigured: true },
|
|
295
335
|
correlationId: options.correlationId,
|
|
296
336
|
attemptId: options.attemptId,
|
|
297
337
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
@@ -346,7 +386,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
346
386
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
347
387
|
method: "POST",
|
|
348
388
|
headers,
|
|
349
|
-
body: JSON.stringify(body)
|
|
389
|
+
body: JSON.stringify(body),
|
|
390
|
+
signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
|
|
350
391
|
});
|
|
351
392
|
const data = await response.json();
|
|
352
393
|
if (response.status === 410) {
|
|
@@ -370,6 +411,17 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
370
411
|
};
|
|
371
412
|
}
|
|
372
413
|
if (!response.ok) {
|
|
414
|
+
if (response.status === 401) {
|
|
415
|
+
return {
|
|
416
|
+
success: false,
|
|
417
|
+
error: data.message || data.error || "Integration API key rejected",
|
|
418
|
+
misconfig: true,
|
|
419
|
+
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
420
|
+
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
421
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
422
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
423
|
+
};
|
|
424
|
+
}
|
|
373
425
|
return {
|
|
374
426
|
success: false,
|
|
375
427
|
error: data.message || data.error || `API returned ${response.status}`,
|
|
@@ -391,9 +443,19 @@ async function verify(config, request, options) {
|
|
|
391
443
|
const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
|
|
392
444
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
393
445
|
if (mergedConfig.strictInit) {
|
|
394
|
-
await performInitCheck(
|
|
446
|
+
await performInitCheck(
|
|
447
|
+
mergedConfig.apiBaseUrl,
|
|
448
|
+
mergedConfig.debug,
|
|
449
|
+
true,
|
|
450
|
+
mergedConfig.apiKey
|
|
451
|
+
);
|
|
395
452
|
} else {
|
|
396
|
-
void performInitCheck(
|
|
453
|
+
void performInitCheck(
|
|
454
|
+
mergedConfig.apiBaseUrl,
|
|
455
|
+
mergedConfig.debug,
|
|
456
|
+
false,
|
|
457
|
+
mergedConfig.apiKey
|
|
458
|
+
);
|
|
397
459
|
}
|
|
398
460
|
}
|
|
399
461
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
@@ -432,9 +494,10 @@ async function verify(config, request, options) {
|
|
|
432
494
|
const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
|
|
433
495
|
if (!apiResponse.success) {
|
|
434
496
|
return createGuidanceResponse(mergedConfig, apiResponse.error, {
|
|
435
|
-
source: "api_error",
|
|
497
|
+
source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
|
|
436
498
|
correlationId: apiResponse.correlationId,
|
|
437
499
|
attemptId: apiResponse.attemptId,
|
|
500
|
+
remediation: apiResponse.remediation,
|
|
438
501
|
urls
|
|
439
502
|
});
|
|
440
503
|
}
|
|
@@ -788,6 +851,24 @@ function dedupeFailures(result) {
|
|
|
788
851
|
}
|
|
789
852
|
function defaultMcpDenied(result, req, res) {
|
|
790
853
|
const id = req.body?.id ?? null;
|
|
854
|
+
if (result.misconfigured) {
|
|
855
|
+
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
856
|
+
res.status(503).json({
|
|
857
|
+
jsonrpc: "2.0",
|
|
858
|
+
id,
|
|
859
|
+
error: {
|
|
860
|
+
// -32002 → merchant verification misconfigured (see -32000/-32001 below)
|
|
861
|
+
code: -32002,
|
|
862
|
+
message: result.denialReasons?.[0] ?? "This server's AstraSync integration is misconfigured",
|
|
863
|
+
data: {
|
|
864
|
+
guidance: result.guidance,
|
|
865
|
+
failures: result.failures,
|
|
866
|
+
correlationId: result.correlationId
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
791
872
|
const status = !result.identityVerified ? 401 : 403;
|
|
792
873
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
793
874
|
res.status(status).json({
|
|
@@ -797,6 +878,7 @@ function defaultMcpDenied(result, req, res) {
|
|
|
797
878
|
// JSON-RPC error codes:
|
|
798
879
|
// -32000 → unauthorized (no identity resolved)
|
|
799
880
|
// -32001 → insufficient access (identity OK, policy denied)
|
|
881
|
+
// -32002 → merchant verification misconfigured (handled above)
|
|
800
882
|
code: !result.identityVerified ? -32e3 : -32001,
|
|
801
883
|
message: result.denialReasons?.[0] ?? "Access denied",
|
|
802
884
|
data: {
|