@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.mjs';
|
|
2
|
-
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-DfnP7JiM.mjs';
|
|
3
|
+
import '../types-BcDf9Kk0.mjs';
|
|
4
4
|
import '../metadata-capture.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.js';
|
|
2
|
-
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-CHKCgDFC.js';
|
|
3
|
+
import '../types-fTQD448H.js';
|
|
4
4
|
import '../metadata-capture.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-
|
|
2
|
+
import '../types-BcDf9Kk0.mjs';
|
|
3
|
+
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-BZajRs4i.mjs';
|
|
4
4
|
import '../metadata-capture.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-
|
|
2
|
+
import '../types-fTQD448H.js';
|
|
3
|
+
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-CjCUB1k7.js';
|
|
4
4
|
import '../metadata-capture.js';
|
package/dist/adapters/express.js
CHANGED
|
@@ -92,7 +92,7 @@ function getTrustLevel(score) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// src/version.ts
|
|
95
|
-
var SDK_VERSION = "
|
|
95
|
+
var SDK_VERSION = "4.0.0";
|
|
96
96
|
|
|
97
97
|
// src/well-known.ts
|
|
98
98
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -170,7 +170,7 @@ var DEFAULT_CONFIG = {
|
|
|
170
170
|
};
|
|
171
171
|
var initCheckPerformed = false;
|
|
172
172
|
var deprecationWarningShown = false;
|
|
173
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
173
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
174
174
|
initCheckPerformed = true;
|
|
175
175
|
try {
|
|
176
176
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -187,6 +187,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
|
187
187
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
188
188
|
);
|
|
189
189
|
}
|
|
190
|
+
if (apiKey) {
|
|
191
|
+
const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
|
|
192
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
193
|
+
});
|
|
194
|
+
if (selfCheck.status === 401) {
|
|
195
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
196
|
+
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}` : "") + `.`;
|
|
197
|
+
if (strictInit) {
|
|
198
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
199
|
+
}
|
|
200
|
+
console.error(message);
|
|
201
|
+
} else if (selfCheck.ok) {
|
|
202
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
203
|
+
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
204
|
+
console.warn(
|
|
205
|
+
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
206
|
+
);
|
|
207
|
+
} else if (debug) {
|
|
208
|
+
console.log("[VerificationGateway] API key self-check passed");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
190
212
|
} catch (err) {
|
|
191
213
|
if (strictInit) {
|
|
192
214
|
throw err;
|
|
@@ -298,8 +320,17 @@ function extractCredentials(headers, query) {
|
|
|
298
320
|
function createGuidanceResponse(_config, reason, options = {}) {
|
|
299
321
|
const source = options.source ?? "no_credentials";
|
|
300
322
|
const isApiError = source === "api_error";
|
|
323
|
+
const isMisconfig = source === "merchant_misconfig";
|
|
301
324
|
const urls = options.urls;
|
|
302
|
-
const guidance =
|
|
325
|
+
const guidance = isMisconfig ? {
|
|
326
|
+
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.",
|
|
327
|
+
registrationUrl: urls?.registrationUrl ?? "",
|
|
328
|
+
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
329
|
+
steps: [
|
|
330
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
|
|
331
|
+
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
332
|
+
]
|
|
333
|
+
} : isApiError ? {
|
|
303
334
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
304
335
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
305
336
|
documentationUrl: urls?.documentationUrl ?? "",
|
|
@@ -337,13 +368,22 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
337
368
|
// partners (and their custom onDenied handlers) can branch on
|
|
338
369
|
// dimension. Without this, the synthesised stub was indistinguishable
|
|
339
370
|
// from a real policy deny.
|
|
340
|
-
failures:
|
|
371
|
+
failures: isMisconfig ? [
|
|
372
|
+
{
|
|
373
|
+
dimension: "verify_access.merchant_misconfigured",
|
|
374
|
+
message: reason ?? "The integration API key was rejected by AstraSync",
|
|
375
|
+
guidance: guidance.message
|
|
376
|
+
}
|
|
377
|
+
] : isApiError ? [
|
|
341
378
|
{
|
|
342
379
|
dimension: "verify_access.api_error",
|
|
343
380
|
message: reason ?? "Verification temporarily unavailable",
|
|
344
381
|
guidance: guidance.message
|
|
345
382
|
}
|
|
346
383
|
] : void 0,
|
|
384
|
+
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
385
|
+
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
386
|
+
...isMisconfig && { misconfigured: true },
|
|
347
387
|
correlationId: options.correlationId,
|
|
348
388
|
attemptId: options.attemptId,
|
|
349
389
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
@@ -398,7 +438,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
398
438
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
399
439
|
method: "POST",
|
|
400
440
|
headers,
|
|
401
|
-
body: JSON.stringify(body)
|
|
441
|
+
body: JSON.stringify(body),
|
|
442
|
+
signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
|
|
402
443
|
});
|
|
403
444
|
const data = await response.json();
|
|
404
445
|
if (response.status === 410) {
|
|
@@ -422,6 +463,17 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
422
463
|
};
|
|
423
464
|
}
|
|
424
465
|
if (!response.ok) {
|
|
466
|
+
if (response.status === 401) {
|
|
467
|
+
return {
|
|
468
|
+
success: false,
|
|
469
|
+
error: data.message || data.error || "Integration API key rejected",
|
|
470
|
+
misconfig: true,
|
|
471
|
+
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
472
|
+
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
473
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
474
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
475
|
+
};
|
|
476
|
+
}
|
|
425
477
|
return {
|
|
426
478
|
success: false,
|
|
427
479
|
error: data.message || data.error || `API returned ${response.status}`,
|
|
@@ -443,9 +495,19 @@ async function verify(config, request, options) {
|
|
|
443
495
|
const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
|
|
444
496
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
445
497
|
if (mergedConfig.strictInit) {
|
|
446
|
-
await performInitCheck(
|
|
498
|
+
await performInitCheck(
|
|
499
|
+
mergedConfig.apiBaseUrl,
|
|
500
|
+
mergedConfig.debug,
|
|
501
|
+
true,
|
|
502
|
+
mergedConfig.apiKey
|
|
503
|
+
);
|
|
447
504
|
} else {
|
|
448
|
-
void performInitCheck(
|
|
505
|
+
void performInitCheck(
|
|
506
|
+
mergedConfig.apiBaseUrl,
|
|
507
|
+
mergedConfig.debug,
|
|
508
|
+
false,
|
|
509
|
+
mergedConfig.apiKey
|
|
510
|
+
);
|
|
449
511
|
}
|
|
450
512
|
}
|
|
451
513
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
@@ -484,9 +546,10 @@ async function verify(config, request, options) {
|
|
|
484
546
|
const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
|
|
485
547
|
if (!apiResponse.success) {
|
|
486
548
|
return createGuidanceResponse(mergedConfig, apiResponse.error, {
|
|
487
|
-
source: "api_error",
|
|
549
|
+
source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
|
|
488
550
|
correlationId: apiResponse.correlationId,
|
|
489
551
|
attemptId: apiResponse.attemptId,
|
|
552
|
+
remediation: apiResponse.remediation,
|
|
490
553
|
urls
|
|
491
554
|
});
|
|
492
555
|
}
|
|
@@ -1043,6 +1106,20 @@ function dedupeFailures(result) {
|
|
|
1043
1106
|
}
|
|
1044
1107
|
}
|
|
1045
1108
|
function defaultOnDenied(result, _req, res) {
|
|
1109
|
+
if (result.misconfigured) {
|
|
1110
|
+
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
1111
|
+
res.status(503).json({
|
|
1112
|
+
success: false,
|
|
1113
|
+
error: {
|
|
1114
|
+
code: "MERCHANT_VERIFICATION_MISCONFIGURED",
|
|
1115
|
+
message: result.denialReasons?.[0] || "This site's AstraSync integration is misconfigured",
|
|
1116
|
+
guidance: result.guidance,
|
|
1117
|
+
failures: result.failures,
|
|
1118
|
+
correlationId: result.correlationId
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1046
1123
|
const statusCode = !result.identityVerified ? 401 : 403;
|
|
1047
1124
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
1048
1125
|
res.status(statusCode).json({
|