@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.mjs';
|
|
2
|
-
import { V as VerificationDecision, P as PDLSSContext } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { V as VerificationDecision, P as PDLSSContext } 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 { V as VerificationDecision, P as PDLSSContext } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { V as VerificationDecision, P as PDLSSContext } from '../types-CHKCgDFC.js';
|
|
3
|
+
import '../types-fTQD448H.js';
|
|
4
4
|
import '../metadata-capture.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { G as GatewayConfig,
|
|
2
|
-
export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, C as CommerceArtifactsPayload,
|
|
3
|
-
export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-
|
|
4
|
-
export { VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, reportUnregisteredAttempt, verify } from './verify.mjs';
|
|
5
|
-
export { e as express } from './express-
|
|
6
|
-
export { n as nextjs } from './nextjs-
|
|
7
|
-
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-
|
|
1
|
+
import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-BcDf9Kk0.mjs';
|
|
2
|
+
export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationRequest, w as VerificationResult, x as VerifiedAgent, y as VerifiedDeveloper, z as VerifiedOrganization } from './types-BcDf9Kk0.mjs';
|
|
3
|
+
export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-_il1Q41f.mjs';
|
|
4
|
+
export { VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, reportAttempt, reportUnregisteredAttempt, verify } from './verify.mjs';
|
|
5
|
+
export { e as express } from './express-BZajRs4i.mjs';
|
|
6
|
+
export { n as nextjs } from './nextjs-DeUTnOBd.mjs';
|
|
7
|
+
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-B0cyMZDL.mjs';
|
|
8
8
|
export { McpMiddlewareOptions, ToolGateConfig, createMcpMiddleware } from './adapters/mcp.mjs';
|
|
9
9
|
export { AgentProtocol, AgentRecord, AstraSync, AstraSyncConfig, AstraSyncError, AuthenticationError, BuildGuidanceParams, FrameworkConfig, GuidanceEnvelope, HealthResponse, KYDRequiredError, ModelConfig, PDLSSConfig, PDLSSDuration, PDLSSLimits, PDLSSPurpose, PDLSSScope, PDLSSSelfInstantiation, PendingRegistrationResponse, PollRegistrationResult, RegisterOptions, RegisterResult, RegistrationDeniedError, RegistrationExpiredError, RegistrationResponse, RegistrationTimeoutError, VerifyResponse, WaitForApprovalOptions, buildGuidance } from './registration/index.mjs';
|
|
10
|
-
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-
|
|
10
|
+
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-BRYteOqO.mjs';
|
|
11
11
|
export { DEFAULT_EDGE_CONFIG, EdgeConfig, EdgeMode, EdgePathRule, EdgeVerificationDepth, FetchEdgeConfigResult, FetchEdgeConfigSuccess, _resetEdgeConfigCache, degradeToObserve, fetchEdgeConfig, getEdgeConfig, isEdgeConfig, matchEdgePathRule } from './edge-config.mjs';
|
|
12
12
|
export { DynamicPlatformFingerprint, PLATFORM_AGENT_SIGNATURES, PlatformAgentVendor, PlatformDetectionInput, PlatformFingerprint, PlatformSignatureDef, detectPlatformFingerprint, matchPlatformSignature } from './platform-signatures.mjs';
|
|
13
13
|
export { MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, ObservedMetadata, SanitizeHeadersResult, extractApiKeyFormat, extractPlatformHeaders, sanitizeHeaders } from './metadata-capture.mjs';
|
|
@@ -145,6 +145,6 @@ declare function getCachedWellKnownUrls(apiBaseUrl: string): WellKnownAgenticCom
|
|
|
145
145
|
* is fine — bumping both in the release-ceremony commit keeps them
|
|
146
146
|
* lockstep.
|
|
147
147
|
*/
|
|
148
|
-
declare const SDK_VERSION = "
|
|
148
|
+
declare const SDK_VERSION = "4.0.0";
|
|
149
149
|
|
|
150
150
|
export { EnhancedVerificationResult, GatewayConfig, type SettlementDecision, type SettlementRequest, StepUpApprovalInfo, StepUpApprovalStatus, StepUpOutcome, SDK_VERSION as VERSION, type WellKnownAgenticCommerce, authorizeSettlement, awaitStepUpApproval, getCachedWellKnownUrls, getWellKnownUrls, pollStepUpStatus, prefetchWellKnown };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { G as GatewayConfig,
|
|
2
|
-
export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, C as CommerceArtifactsPayload,
|
|
3
|
-
export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-
|
|
4
|
-
export { VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, reportUnregisteredAttempt, verify } from './verify.js';
|
|
5
|
-
export { e as express } from './express-
|
|
6
|
-
export { n as nextjs } from './nextjs-
|
|
7
|
-
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-
|
|
1
|
+
import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-fTQD448H.js';
|
|
2
|
+
export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationRequest, w as VerificationResult, x as VerifiedAgent, y as VerifiedDeveloper, z as VerifiedOrganization } from './types-fTQD448H.js';
|
|
3
|
+
export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-BM3mwEAq.js';
|
|
4
|
+
export { VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, reportAttempt, reportUnregisteredAttempt, verify } from './verify.js';
|
|
5
|
+
export { e as express } from './express-CjCUB1k7.js';
|
|
6
|
+
export { n as nextjs } from './nextjs-D_iFf5k-.js';
|
|
7
|
+
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-adgKhujR.js';
|
|
8
8
|
export { McpMiddlewareOptions, ToolGateConfig, createMcpMiddleware } from './adapters/mcp.js';
|
|
9
9
|
export { AgentProtocol, AgentRecord, AstraSync, AstraSyncConfig, AstraSyncError, AuthenticationError, BuildGuidanceParams, FrameworkConfig, GuidanceEnvelope, HealthResponse, KYDRequiredError, ModelConfig, PDLSSConfig, PDLSSDuration, PDLSSLimits, PDLSSPurpose, PDLSSScope, PDLSSSelfInstantiation, PendingRegistrationResponse, PollRegistrationResult, RegisterOptions, RegisterResult, RegistrationDeniedError, RegistrationExpiredError, RegistrationResponse, RegistrationTimeoutError, VerifyResponse, WaitForApprovalOptions, buildGuidance } from './registration/index.js';
|
|
10
|
-
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-
|
|
10
|
+
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-BZQdVqNw.js';
|
|
11
11
|
export { DEFAULT_EDGE_CONFIG, EdgeConfig, EdgeMode, EdgePathRule, EdgeVerificationDepth, FetchEdgeConfigResult, FetchEdgeConfigSuccess, _resetEdgeConfigCache, degradeToObserve, fetchEdgeConfig, getEdgeConfig, isEdgeConfig, matchEdgePathRule } from './edge-config.js';
|
|
12
12
|
export { DynamicPlatformFingerprint, PLATFORM_AGENT_SIGNATURES, PlatformAgentVendor, PlatformDetectionInput, PlatformFingerprint, PlatformSignatureDef, detectPlatformFingerprint, matchPlatformSignature } from './platform-signatures.js';
|
|
13
13
|
export { MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, ObservedMetadata, SanitizeHeadersResult, extractApiKeyFormat, extractPlatformHeaders, sanitizeHeaders } from './metadata-capture.js';
|
|
@@ -145,6 +145,6 @@ declare function getCachedWellKnownUrls(apiBaseUrl: string): WellKnownAgenticCom
|
|
|
145
145
|
* is fine — bumping both in the release-ceremony commit keeps them
|
|
146
146
|
* lockstep.
|
|
147
147
|
*/
|
|
148
|
-
declare const SDK_VERSION = "
|
|
148
|
+
declare const SDK_VERSION = "4.0.0";
|
|
149
149
|
|
|
150
150
|
export { EnhancedVerificationResult, GatewayConfig, type SettlementDecision, type SettlementRequest, StepUpApprovalInfo, StepUpApprovalStatus, StepUpOutcome, SDK_VERSION as VERSION, type WellKnownAgenticCommerce, authorizeSettlement, awaitStepUpApproval, getCachedWellKnownUrls, getWellKnownUrls, pollStepUpStatus, prefetchWellKnown };
|
package/dist/index.js
CHANGED
|
@@ -82,6 +82,7 @@ __export(src_exports, {
|
|
|
82
82
|
prefetchWellKnown: () => prefetchWellKnown,
|
|
83
83
|
quickVerify: () => quickVerify,
|
|
84
84
|
recordDecision: () => recordDecision2,
|
|
85
|
+
reportAttempt: () => reportAttempt,
|
|
85
86
|
reportUnregisteredAttempt: () => reportUnregisteredAttempt,
|
|
86
87
|
sanitizeHeaders: () => sanitizeHeaders,
|
|
87
88
|
sdk: () => sdk_exports,
|
|
@@ -213,7 +214,7 @@ function getCapabilities(accessLevel) {
|
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
// src/version.ts
|
|
216
|
-
var SDK_VERSION = "
|
|
217
|
+
var SDK_VERSION = "4.0.0";
|
|
217
218
|
|
|
218
219
|
// src/well-known.ts
|
|
219
220
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -291,7 +292,7 @@ var DEFAULT_CONFIG = {
|
|
|
291
292
|
};
|
|
292
293
|
var initCheckPerformed = false;
|
|
293
294
|
var deprecationWarningShown = false;
|
|
294
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
295
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
295
296
|
initCheckPerformed = true;
|
|
296
297
|
try {
|
|
297
298
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -308,6 +309,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
|
308
309
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
309
310
|
);
|
|
310
311
|
}
|
|
312
|
+
if (apiKey) {
|
|
313
|
+
const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
|
|
314
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
315
|
+
});
|
|
316
|
+
if (selfCheck.status === 401) {
|
|
317
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
318
|
+
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}` : "") + `.`;
|
|
319
|
+
if (strictInit) {
|
|
320
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
321
|
+
}
|
|
322
|
+
console.error(message);
|
|
323
|
+
} else if (selfCheck.ok) {
|
|
324
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
325
|
+
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
326
|
+
console.warn(
|
|
327
|
+
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
328
|
+
);
|
|
329
|
+
} else if (debug) {
|
|
330
|
+
console.log("[VerificationGateway] API key self-check passed");
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
311
334
|
} catch (err) {
|
|
312
335
|
if (strictInit) {
|
|
313
336
|
throw err;
|
|
@@ -425,8 +448,17 @@ function hasCredentials(credentials) {
|
|
|
425
448
|
function createGuidanceResponse(_config, reason, options = {}) {
|
|
426
449
|
const source = options.source ?? "no_credentials";
|
|
427
450
|
const isApiError = source === "api_error";
|
|
451
|
+
const isMisconfig = source === "merchant_misconfig";
|
|
428
452
|
const urls = options.urls;
|
|
429
|
-
const guidance =
|
|
453
|
+
const guidance = isMisconfig ? {
|
|
454
|
+
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.",
|
|
455
|
+
registrationUrl: urls?.registrationUrl ?? "",
|
|
456
|
+
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
457
|
+
steps: [
|
|
458
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
|
|
459
|
+
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
460
|
+
]
|
|
461
|
+
} : isApiError ? {
|
|
430
462
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
431
463
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
432
464
|
documentationUrl: urls?.documentationUrl ?? "",
|
|
@@ -464,14 +496,24 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
464
496
|
// partners (and their custom onDenied handlers) can branch on
|
|
465
497
|
// dimension. Without this, the synthesised stub was indistinguishable
|
|
466
498
|
// from a real policy deny.
|
|
467
|
-
failures:
|
|
499
|
+
failures: isMisconfig ? [
|
|
500
|
+
{
|
|
501
|
+
dimension: "verify_access.merchant_misconfigured",
|
|
502
|
+
message: reason ?? "The integration API key was rejected by AstraSync",
|
|
503
|
+
guidance: guidance.message
|
|
504
|
+
}
|
|
505
|
+
] : isApiError ? [
|
|
468
506
|
{
|
|
469
507
|
dimension: "verify_access.api_error",
|
|
470
508
|
message: reason ?? "Verification temporarily unavailable",
|
|
471
509
|
guidance: guidance.message
|
|
472
510
|
}
|
|
473
511
|
] : void 0,
|
|
512
|
+
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
513
|
+
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
514
|
+
...isMisconfig && { misconfigured: true },
|
|
474
515
|
correlationId: options.correlationId,
|
|
516
|
+
attemptId: options.attemptId,
|
|
475
517
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
476
518
|
};
|
|
477
519
|
}
|
|
@@ -501,6 +543,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
501
543
|
body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
|
|
502
544
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
503
545
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
546
|
+
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
547
|
+
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
504
548
|
body.sdkVersion = SDK_VERSION;
|
|
505
549
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
506
550
|
const meta = {
|
|
@@ -522,12 +566,16 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
522
566
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
523
567
|
method: "POST",
|
|
524
568
|
headers,
|
|
525
|
-
body: JSON.stringify(body)
|
|
569
|
+
body: JSON.stringify(body),
|
|
570
|
+
signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
|
|
526
571
|
});
|
|
527
572
|
const data = await response.json();
|
|
528
573
|
if (response.status === 410) {
|
|
529
574
|
return {
|
|
530
575
|
success: true,
|
|
576
|
+
// 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
|
|
577
|
+
// the synthesised 410 deny shape (echoed on every branch).
|
|
578
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
|
|
531
579
|
access: {
|
|
532
580
|
allowed: false,
|
|
533
581
|
accessLevel: "none",
|
|
@@ -543,10 +591,22 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
543
591
|
};
|
|
544
592
|
}
|
|
545
593
|
if (!response.ok) {
|
|
594
|
+
if (response.status === 401) {
|
|
595
|
+
return {
|
|
596
|
+
success: false,
|
|
597
|
+
error: data.message || data.error || "Integration API key rejected",
|
|
598
|
+
misconfig: true,
|
|
599
|
+
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
600
|
+
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
601
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
602
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
603
|
+
};
|
|
604
|
+
}
|
|
546
605
|
return {
|
|
547
606
|
success: false,
|
|
548
607
|
error: data.message || data.error || `API returned ${response.status}`,
|
|
549
|
-
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
|
|
608
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
609
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
550
610
|
};
|
|
551
611
|
}
|
|
552
612
|
return data;
|
|
@@ -563,9 +623,19 @@ async function verify(config, request, options) {
|
|
|
563
623
|
const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
|
|
564
624
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
565
625
|
if (mergedConfig.strictInit) {
|
|
566
|
-
await performInitCheck(
|
|
626
|
+
await performInitCheck(
|
|
627
|
+
mergedConfig.apiBaseUrl,
|
|
628
|
+
mergedConfig.debug,
|
|
629
|
+
true,
|
|
630
|
+
mergedConfig.apiKey
|
|
631
|
+
);
|
|
567
632
|
} else {
|
|
568
|
-
void performInitCheck(
|
|
633
|
+
void performInitCheck(
|
|
634
|
+
mergedConfig.apiBaseUrl,
|
|
635
|
+
mergedConfig.debug,
|
|
636
|
+
false,
|
|
637
|
+
mergedConfig.apiKey
|
|
638
|
+
);
|
|
569
639
|
}
|
|
570
640
|
}
|
|
571
641
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
@@ -580,7 +650,13 @@ async function verify(config, request, options) {
|
|
|
580
650
|
if (mergedConfig.debug) {
|
|
581
651
|
console.log("[VerificationGateway] Returning cached result");
|
|
582
652
|
}
|
|
583
|
-
|
|
653
|
+
const hit = { ...cached };
|
|
654
|
+
if (request.attemptId) {
|
|
655
|
+
hit.attemptId = request.attemptId;
|
|
656
|
+
} else {
|
|
657
|
+
delete hit.attemptId;
|
|
658
|
+
}
|
|
659
|
+
return hit;
|
|
584
660
|
}
|
|
585
661
|
}
|
|
586
662
|
const enrichedRequest = { ...request };
|
|
@@ -598,8 +674,10 @@ async function verify(config, request, options) {
|
|
|
598
674
|
const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
|
|
599
675
|
if (!apiResponse.success) {
|
|
600
676
|
return createGuidanceResponse(mergedConfig, apiResponse.error, {
|
|
601
|
-
source: "api_error",
|
|
677
|
+
source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
|
|
602
678
|
correlationId: apiResponse.correlationId,
|
|
679
|
+
attemptId: apiResponse.attemptId,
|
|
680
|
+
remediation: apiResponse.remediation,
|
|
603
681
|
urls
|
|
604
682
|
});
|
|
605
683
|
}
|
|
@@ -635,6 +713,9 @@ async function verify(config, request, options) {
|
|
|
635
713
|
// Anonymous traffic has no session → correlationId is the per-attempt
|
|
636
714
|
// linking key (the sessionId-equivalent for anonymous callers).
|
|
637
715
|
correlationId: apiResponse.correlationId,
|
|
716
|
+
// 3.12.0 (Trust Record): server echoes the attempt-chain handle on
|
|
717
|
+
// every branch — denials included (the funnel outlives one deny).
|
|
718
|
+
attemptId: apiResponse.attemptId,
|
|
638
719
|
recommendation: apiResponse.recommendation,
|
|
639
720
|
recommendationReasons: apiResponse.recommendationReasons,
|
|
640
721
|
stepUpApproval: apiResponse.stepUpApproval,
|
|
@@ -686,6 +767,8 @@ async function verify(config, request, options) {
|
|
|
686
767
|
// v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
|
|
687
768
|
// (no session row exists for unverified callers).
|
|
688
769
|
correlationId: apiResponse.correlationId,
|
|
770
|
+
// 3.12.0 (Trust Record): server-echoed attempt-chain handle.
|
|
771
|
+
attemptId: apiResponse.attemptId,
|
|
689
772
|
runtimeChallenge: apiResponse.runtimeChallenge,
|
|
690
773
|
tokenGuidance: apiResponse.tokenGuidance,
|
|
691
774
|
recommendation: apiResponse.recommendation,
|
|
@@ -730,6 +813,24 @@ async function recordDecision(config, sessionId, decision, reason) {
|
|
|
730
813
|
}).catch(() => {
|
|
731
814
|
});
|
|
732
815
|
}
|
|
816
|
+
async function reportAttempt(config, report) {
|
|
817
|
+
const apiBaseUrl = config.apiBaseUrl || DEFAULT_CONFIG.apiBaseUrl;
|
|
818
|
+
const headers = { "Content-Type": "application/json" };
|
|
819
|
+
if (config.apiKey) {
|
|
820
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
821
|
+
headers["X-API-Key"] = config.apiKey;
|
|
822
|
+
}
|
|
823
|
+
const body = {
|
|
824
|
+
...report,
|
|
825
|
+
...!report.counterpartyId && config.counterpartyId && { counterpartyId: config.counterpartyId }
|
|
826
|
+
};
|
|
827
|
+
await fetch(`${apiBaseUrl}/agents/verify-access/attempt-report`, {
|
|
828
|
+
method: "POST",
|
|
829
|
+
headers,
|
|
830
|
+
body: JSON.stringify(body)
|
|
831
|
+
}).catch(() => {
|
|
832
|
+
});
|
|
833
|
+
}
|
|
733
834
|
async function fetchRoutes(config, counterpartyId) {
|
|
734
835
|
if (!counterpartyId) return null;
|
|
735
836
|
const headers = { "Content-Type": "application/json" };
|
|
@@ -1324,6 +1425,20 @@ function dedupeFailures(result) {
|
|
|
1324
1425
|
}
|
|
1325
1426
|
}
|
|
1326
1427
|
function defaultOnDenied(result, _req, res) {
|
|
1428
|
+
if (result.misconfigured) {
|
|
1429
|
+
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
1430
|
+
res.status(503).json({
|
|
1431
|
+
success: false,
|
|
1432
|
+
error: {
|
|
1433
|
+
code: "MERCHANT_VERIFICATION_MISCONFIGURED",
|
|
1434
|
+
message: result.denialReasons?.[0] || "This site's AstraSync integration is misconfigured",
|
|
1435
|
+
guidance: result.guidance,
|
|
1436
|
+
failures: result.failures,
|
|
1437
|
+
correlationId: result.correlationId
|
|
1438
|
+
}
|
|
1439
|
+
});
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1327
1442
|
const statusCode = !result.identityVerified ? 401 : 403;
|
|
1328
1443
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
1329
1444
|
res.status(statusCode).json({
|
|
@@ -2040,6 +2155,21 @@ function createMiddleware2(options) {
|
|
|
2040
2155
|
const approvalRequired = result.identityVerified && result.policyAllowed && requiresHumanApproval(result);
|
|
2041
2156
|
if (approvalRequired) annotateApprovalRequired(result);
|
|
2042
2157
|
if (!result.identityVerified || !result.policyAllowed || approvalRequired) {
|
|
2158
|
+
if (result.misconfigured && pathname.startsWith("/api/")) {
|
|
2159
|
+
return NextResponse.json(
|
|
2160
|
+
{
|
|
2161
|
+
success: false,
|
|
2162
|
+
error: {
|
|
2163
|
+
code: "MERCHANT_VERIFICATION_MISCONFIGURED",
|
|
2164
|
+
message: result.denialReasons?.[0] || "This site's AstraSync integration is misconfigured",
|
|
2165
|
+
guidance: result.guidance,
|
|
2166
|
+
failures: result.failures,
|
|
2167
|
+
correlationId: result.correlationId
|
|
2168
|
+
}
|
|
2169
|
+
},
|
|
2170
|
+
{ status: 503 }
|
|
2171
|
+
);
|
|
2172
|
+
}
|
|
2043
2173
|
if (pathname.startsWith("/api/")) {
|
|
2044
2174
|
return NextResponse.json(
|
|
2045
2175
|
{
|
|
@@ -4963,6 +5093,24 @@ function dedupeFailures2(result) {
|
|
|
4963
5093
|
}
|
|
4964
5094
|
function defaultMcpDenied(result, req, res) {
|
|
4965
5095
|
const id = req.body?.id ?? null;
|
|
5096
|
+
if (result.misconfigured) {
|
|
5097
|
+
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
5098
|
+
res.status(503).json({
|
|
5099
|
+
jsonrpc: "2.0",
|
|
5100
|
+
id,
|
|
5101
|
+
error: {
|
|
5102
|
+
// -32002 → merchant verification misconfigured (see -32000/-32001 below)
|
|
5103
|
+
code: -32002,
|
|
5104
|
+
message: result.denialReasons?.[0] ?? "This server's AstraSync integration is misconfigured",
|
|
5105
|
+
data: {
|
|
5106
|
+
guidance: result.guidance,
|
|
5107
|
+
failures: result.failures,
|
|
5108
|
+
correlationId: result.correlationId
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
});
|
|
5112
|
+
return;
|
|
5113
|
+
}
|
|
4966
5114
|
const status = !result.identityVerified ? 401 : 403;
|
|
4967
5115
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
4968
5116
|
res.status(status).json({
|
|
@@ -4972,6 +5120,7 @@ function defaultMcpDenied(result, req, res) {
|
|
|
4972
5120
|
// JSON-RPC error codes:
|
|
4973
5121
|
// -32000 → unauthorized (no identity resolved)
|
|
4974
5122
|
// -32001 → insufficient access (identity OK, policy denied)
|
|
5123
|
+
// -32002 → merchant verification misconfigured (handled above)
|
|
4975
5124
|
code: !result.identityVerified ? -32e3 : -32001,
|
|
4976
5125
|
message: result.denialReasons?.[0] ?? "Access denied",
|
|
4977
5126
|
data: {
|
|
@@ -6185,6 +6334,7 @@ function detectPlatformFingerprint(input) {
|
|
|
6185
6334
|
prefetchWellKnown,
|
|
6186
6335
|
quickVerify,
|
|
6187
6336
|
recordDecision,
|
|
6337
|
+
reportAttempt,
|
|
6188
6338
|
reportUnregisteredAttempt,
|
|
6189
6339
|
sanitizeHeaders,
|
|
6190
6340
|
sdk,
|