@astrasyncai/verification-gateway 2.4.8 → 2.4.9
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 +29 -15
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +29 -15
- 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 +30 -14
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +30 -14
- 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 +37 -16
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +37 -16
- 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 +31 -13
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +31 -13
- 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/browser/background.js +25 -12
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +25 -12
- 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/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- 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 +25 -12
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +25 -12
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-DvVjR2H4.d.mts → express-4WStX3PV.d.mts} +1 -1
- package/dist/{express-714gJbaW.d.ts → express-C1ePFB7n.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 +25 -12
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +25 -12
- 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-DYFS9QVb.d.mts → index-ChPX4WHl.d.mts} +1 -1
- package/dist/{index-DO0oG8ED.d.ts → index-Cjm-zBeZ.d.ts} +1 -1
- package/dist/{index-2WAlxs2G.d.ts → index-CzJMCgEy.d.ts} +1 -1
- package/dist/{index-P9t7M_dJ.d.mts → index-D8IEntil.d.mts} +1 -1
- package/dist/index.d.mts +22 -11
- package/dist/index.d.ts +22 -11
- package/dist/index.js +80 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -25
- 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-CZ-MwSOT.d.ts → nextjs-BIORS__0.d.ts} +1 -1
- package/dist/{nextjs-BCoH7EqF.d.mts → nextjs-CjzHdaXA.d.mts} +1 -1
- package/dist/registration/index.d.mts +76 -1
- package/dist/registration/index.d.ts +76 -1
- package/dist/registration/index.js +27 -2
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +25 -1
- package/dist/registration/index.mjs.map +1 -1
- package/dist/{sdk-wwhFDXWX.d.mts → sdk-Chhz-FcT.d.mts} +9 -4
- package/dist/{sdk-kiA49vqJ.d.ts → sdk-CqTEQAc6.d.ts} +9 -4
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-DOAb89cm.d.mts → types-DNK2BgIf.d.mts} +1 -1
- package/dist/{types-aucqzfUa.d.ts → types-DoWIuzfj.d.ts} +1 -1
- package/dist/{types-BwDmjIdr.d.mts → types-L15pYd2c.d.mts} +21 -4
- package/dist/{types-BwDmjIdr.d.ts → types-L15pYd2c.d.ts} +21 -4
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +1 -1
- package/dist/ui/index.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-DNK2BgIf.mjs';
|
|
3
|
+
import '../types-L15pYd2c.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Git Trigger — Enterprise git push / PR verification
|
|
@@ -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-DoWIuzfj.js';
|
|
3
|
+
import '../types-L15pYd2c.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Git Trigger — Enterprise git push / PR verification
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { a as AgentCredentials, G as GatewayConfig, A as AccessLevel, V as VerificationRequest, i as VerificationResult } from './types-
|
|
2
|
-
export { b as AstraSyncCredentials, C as CommerceShieldProps, c as CounterpartyType, E as EnhancedVerificationResult, d as ExpressMiddlewareOptions, e as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, f as ProtocolTransport, R as RouteAccessConfig, g as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, h as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-
|
|
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 { e as express } from './express-
|
|
5
|
-
export { n as nextjs } from './nextjs-
|
|
6
|
-
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-
|
|
1
|
+
import { a as AgentCredentials, G as GatewayConfig, A as AccessLevel, V as VerificationRequest, i as VerificationResult } from './types-L15pYd2c.mjs';
|
|
2
|
+
export { b as AstraSyncCredentials, C as CommerceShieldProps, c as CounterpartyType, E as EnhancedVerificationResult, d as ExpressMiddlewareOptions, e as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, f as ProtocolTransport, R as RouteAccessConfig, g as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, h as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-L15pYd2c.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-Chhz-FcT.mjs';
|
|
4
|
+
export { e as express } from './express-4WStX3PV.mjs';
|
|
5
|
+
export { n as nextjs } from './nextjs-CjzHdaXA.mjs';
|
|
6
|
+
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-D8IEntil.mjs';
|
|
7
7
|
export { McpMiddlewareOptions, createMcpMiddleware } from './adapters/mcp.mjs';
|
|
8
|
-
export { AgentProtocol, AgentRecord, AstraSync, AstraSyncConfig, AstraSyncError, AuthenticationError, FrameworkConfig, HealthResponse, KYDRequiredError, ModelConfig, PDLSSConfig, PDLSSDuration, PDLSSLimits, PDLSSPurpose, PDLSSScope, PDLSSSelfInstantiation, PendingRegistrationResponse, PollRegistrationResult, RegisterOptions, RegisterResult, RegistrationDeniedError, RegistrationExpiredError, RegistrationResponse, RegistrationTimeoutError, VerifyResponse, WaitForApprovalOptions } from './registration/index.mjs';
|
|
9
|
-
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-
|
|
8
|
+
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';
|
|
9
|
+
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-ChPX4WHl.mjs';
|
|
10
10
|
import 'express';
|
|
11
11
|
import 'next/server';
|
|
12
12
|
import 'jose';
|
|
@@ -35,10 +35,17 @@ declare function hasCredentials(credentials: AgentCredentials): boolean;
|
|
|
35
35
|
*/
|
|
36
36
|
declare function verify(config: GatewayConfig, request: VerificationRequest): Promise<VerificationResult>;
|
|
37
37
|
/**
|
|
38
|
-
* Quick verification
|
|
38
|
+
* Quick verification — checks credentials and policy in one call.
|
|
39
|
+
*
|
|
40
|
+
* Round-18 G4: return shape mirrors `VerificationResult`'s split — partners
|
|
41
|
+
* writing custom handlers around `quickVerify` get the same identity/policy
|
|
42
|
+
* distinction as those calling `verify()` directly. Map to HTTP status the
|
|
43
|
+
* same way: `!identityVerified` → 401; `identityVerified && !policyAllowed`
|
|
44
|
+
* → 403.
|
|
39
45
|
*/
|
|
40
46
|
declare function quickVerify(config: GatewayConfig, credentials: AgentCredentials): Promise<{
|
|
41
|
-
|
|
47
|
+
identityVerified: boolean;
|
|
48
|
+
policyAllowed: boolean;
|
|
42
49
|
accessLevel: AccessLevel;
|
|
43
50
|
reason?: string;
|
|
44
51
|
}>;
|
|
@@ -56,9 +63,13 @@ declare function quickVerify(config: GatewayConfig, credentials: AgentCredential
|
|
|
56
63
|
* const credentials = extractCredentials(request.headers);
|
|
57
64
|
* const result = await verify(config, { credentials, purpose: 'data-access' });
|
|
58
65
|
*
|
|
59
|
-
* if (result.
|
|
66
|
+
* if (result.identityVerified && result.policyAllowed && result.accessLevel !== 'none') {
|
|
60
67
|
* // Grant access based on result.accessLevel
|
|
61
68
|
* }
|
|
69
|
+
*
|
|
70
|
+
* // Or map to HTTP status codes directly:
|
|
71
|
+
* if (!result.identityVerified) return res.status(401).json({ ... }); // re-auth
|
|
72
|
+
* if (!result.policyAllowed) return res.status(403).json({ ... }); // step up / update PDLSS
|
|
62
73
|
* ```
|
|
63
74
|
*
|
|
64
75
|
* @packageDocumentation
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { a as AgentCredentials, G as GatewayConfig, A as AccessLevel, V as VerificationRequest, i as VerificationResult } from './types-
|
|
2
|
-
export { b as AstraSyncCredentials, C as CommerceShieldProps, c as CounterpartyType, E as EnhancedVerificationResult, d as ExpressMiddlewareOptions, e as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, f as ProtocolTransport, R as RouteAccessConfig, g as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, h as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-
|
|
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 { e as express } from './express-
|
|
5
|
-
export { n as nextjs } from './nextjs-
|
|
6
|
-
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-
|
|
1
|
+
import { a as AgentCredentials, G as GatewayConfig, A as AccessLevel, V as VerificationRequest, i as VerificationResult } from './types-L15pYd2c.js';
|
|
2
|
+
export { b as AstraSyncCredentials, C as CommerceShieldProps, c as CounterpartyType, E as EnhancedVerificationResult, d as ExpressMiddlewareOptions, e as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, f as ProtocolTransport, R as RouteAccessConfig, g as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, h as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-L15pYd2c.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-CqTEQAc6.js';
|
|
4
|
+
export { e as express } from './express-C1ePFB7n.js';
|
|
5
|
+
export { n as nextjs } from './nextjs-BIORS__0.js';
|
|
6
|
+
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-CzJMCgEy.js';
|
|
7
7
|
export { McpMiddlewareOptions, createMcpMiddleware } from './adapters/mcp.js';
|
|
8
|
-
export { AgentProtocol, AgentRecord, AstraSync, AstraSyncConfig, AstraSyncError, AuthenticationError, FrameworkConfig, HealthResponse, KYDRequiredError, ModelConfig, PDLSSConfig, PDLSSDuration, PDLSSLimits, PDLSSPurpose, PDLSSScope, PDLSSSelfInstantiation, PendingRegistrationResponse, PollRegistrationResult, RegisterOptions, RegisterResult, RegistrationDeniedError, RegistrationExpiredError, RegistrationResponse, RegistrationTimeoutError, VerifyResponse, WaitForApprovalOptions } from './registration/index.js';
|
|
9
|
-
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-
|
|
8
|
+
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';
|
|
9
|
+
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-Cjm-zBeZ.js';
|
|
10
10
|
import 'express';
|
|
11
11
|
import 'next/server';
|
|
12
12
|
import 'jose';
|
|
@@ -35,10 +35,17 @@ declare function hasCredentials(credentials: AgentCredentials): boolean;
|
|
|
35
35
|
*/
|
|
36
36
|
declare function verify(config: GatewayConfig, request: VerificationRequest): Promise<VerificationResult>;
|
|
37
37
|
/**
|
|
38
|
-
* Quick verification
|
|
38
|
+
* Quick verification — checks credentials and policy in one call.
|
|
39
|
+
*
|
|
40
|
+
* Round-18 G4: return shape mirrors `VerificationResult`'s split — partners
|
|
41
|
+
* writing custom handlers around `quickVerify` get the same identity/policy
|
|
42
|
+
* distinction as those calling `verify()` directly. Map to HTTP status the
|
|
43
|
+
* same way: `!identityVerified` → 401; `identityVerified && !policyAllowed`
|
|
44
|
+
* → 403.
|
|
39
45
|
*/
|
|
40
46
|
declare function quickVerify(config: GatewayConfig, credentials: AgentCredentials): Promise<{
|
|
41
|
-
|
|
47
|
+
identityVerified: boolean;
|
|
48
|
+
policyAllowed: boolean;
|
|
42
49
|
accessLevel: AccessLevel;
|
|
43
50
|
reason?: string;
|
|
44
51
|
}>;
|
|
@@ -56,9 +63,13 @@ declare function quickVerify(config: GatewayConfig, credentials: AgentCredential
|
|
|
56
63
|
* const credentials = extractCredentials(request.headers);
|
|
57
64
|
* const result = await verify(config, { credentials, purpose: 'data-access' });
|
|
58
65
|
*
|
|
59
|
-
* if (result.
|
|
66
|
+
* if (result.identityVerified && result.policyAllowed && result.accessLevel !== 'none') {
|
|
60
67
|
* // Grant access based on result.accessLevel
|
|
61
68
|
* }
|
|
69
|
+
*
|
|
70
|
+
* // Or map to HTTP status codes directly:
|
|
71
|
+
* if (!result.identityVerified) return res.status(401).json({ ... }); // re-auth
|
|
72
|
+
* if (!result.policyAllowed) return res.status(403).json({ ... }); // step up / update PDLSS
|
|
62
73
|
* ```
|
|
63
74
|
*
|
|
64
75
|
* @packageDocumentation
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,7 @@ __export(src_exports, {
|
|
|
45
45
|
TRUST_LEVEL_RANGES: () => TRUST_LEVEL_RANGES,
|
|
46
46
|
VERSION: () => VERSION,
|
|
47
47
|
agent: () => agent_exports,
|
|
48
|
+
buildGuidance: () => buildGuidance,
|
|
48
49
|
clearCache: () => clearCache,
|
|
49
50
|
createMcpMiddleware: () => createMcpMiddleware,
|
|
50
51
|
determineAccessLevel: () => determineAccessLevel,
|
|
@@ -188,7 +189,7 @@ function getCapabilities(accessLevel) {
|
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
// src/version.ts
|
|
191
|
-
var SDK_VERSION = "2.4.
|
|
192
|
+
var SDK_VERSION = "2.4.9";
|
|
192
193
|
|
|
193
194
|
// src/verify.ts
|
|
194
195
|
var DEFAULT_CONFIG = {
|
|
@@ -305,12 +306,17 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
305
306
|
]
|
|
306
307
|
};
|
|
307
308
|
return {
|
|
308
|
-
|
|
309
|
+
// Round-18 G4: createGuidanceResponse fires for unverified-agent path or
|
|
310
|
+
// API-error fallback. Identity is not verified (no agent resolved);
|
|
311
|
+
// policy is not evaluated (we never reached the gate).
|
|
312
|
+
identityVerified: false,
|
|
313
|
+
policyAllowed: false,
|
|
309
314
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
310
|
-
// Adapters additionally short-circuit on
|
|
311
|
-
// the gate check, but the access level still has
|
|
312
|
-
// data layer so downstream consumers (SDK adapters
|
|
313
|
-
// custom integrations) inherit the correct
|
|
315
|
+
// Adapters additionally short-circuit on `!identityVerified ||
|
|
316
|
+
// !policyAllowed` before the gate check, but the access level still has
|
|
317
|
+
// to be honest at the data layer so downstream consumers (SDK adapters
|
|
318
|
+
// in other languages, custom integrations) inherit the correct
|
|
319
|
+
// semantics.
|
|
314
320
|
accessLevel: "none",
|
|
315
321
|
guidance,
|
|
316
322
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
@@ -454,15 +460,17 @@ async function verify(config, request) {
|
|
|
454
460
|
}
|
|
455
461
|
if (!apiResponse.access?.allowed) {
|
|
456
462
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
463
|
+
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true;
|
|
457
464
|
const result2 = {
|
|
458
|
-
|
|
465
|
+
identityVerified: idVerifiedFromBackend,
|
|
466
|
+
policyAllowed: false,
|
|
459
467
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
460
468
|
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
461
469
|
// colocated `guidance: {...}` help-payload object below and let
|
|
462
470
|
// denied requests pass any route gated at `'guidance'` because
|
|
463
471
|
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
464
|
-
// ALSO short-circuit on
|
|
465
|
-
// belt-and-braces.
|
|
472
|
+
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
473
|
+
// the gate check — belt-and-braces.
|
|
466
474
|
accessLevel: "none",
|
|
467
475
|
denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
|
|
468
476
|
failures: aggregatedFailures,
|
|
@@ -506,7 +514,13 @@ async function verify(config, request) {
|
|
|
506
514
|
const verificationContext = apiResponse.verificationContext;
|
|
507
515
|
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
508
516
|
const result = {
|
|
509
|
-
|
|
517
|
+
// Round-18 G4: backend allowed access. Identity is verified (we resolved
|
|
518
|
+
// the caller to an agent) and policy passed all gates. Read idVerified
|
|
519
|
+
// from verificationContext for symmetry with the deny branch; default true
|
|
520
|
+
// on success path since `access.allowed === true` implies identity was
|
|
521
|
+
// resolvable (anonymous-allow paths flow through createGuidanceResponse).
|
|
522
|
+
identityVerified: apiResponse.verificationContext?.idVerified !== false,
|
|
523
|
+
policyAllowed: true,
|
|
510
524
|
accessLevel,
|
|
511
525
|
agent,
|
|
512
526
|
developer,
|
|
@@ -529,7 +543,7 @@ async function verify(config, request) {
|
|
|
529
543
|
warningHeader: apiResponse.warningHeader
|
|
530
544
|
};
|
|
531
545
|
if (result.recommendation === "deny") {
|
|
532
|
-
result.
|
|
546
|
+
result.policyAllowed = false;
|
|
533
547
|
result.accessLevel = "none";
|
|
534
548
|
result.denialReasons = result.recommendationReasons || [
|
|
535
549
|
"Access denied by AstraSync recommendation"
|
|
@@ -629,7 +643,8 @@ async function quickVerify(config, credentials) {
|
|
|
629
643
|
purpose: "verification"
|
|
630
644
|
});
|
|
631
645
|
return {
|
|
632
|
-
|
|
646
|
+
identityVerified: result.identityVerified,
|
|
647
|
+
policyAllowed: result.policyAllowed,
|
|
633
648
|
accessLevel: result.accessLevel,
|
|
634
649
|
reason: result.denialReasons?.[0]
|
|
635
650
|
};
|
|
@@ -801,12 +816,12 @@ function findRouteConfig(routes, path, method) {
|
|
|
801
816
|
});
|
|
802
817
|
}
|
|
803
818
|
function defaultOnDenied(result, _req, res) {
|
|
804
|
-
const statusCode = result.
|
|
819
|
+
const statusCode = !result.identityVerified ? 401 : 403;
|
|
805
820
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
806
821
|
res.status(statusCode).json({
|
|
807
822
|
success: false,
|
|
808
823
|
error: {
|
|
809
|
-
code: result.
|
|
824
|
+
code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
|
|
810
825
|
message: result.denialReasons?.[0] || "Access denied",
|
|
811
826
|
accessLevel: result.accessLevel,
|
|
812
827
|
guidance: result.guidance,
|
|
@@ -900,7 +915,8 @@ function createMiddleware(options) {
|
|
|
900
915
|
const preCheckFailures = performCounterpartyPreCheck(routeConfig, astraCreds, purpose);
|
|
901
916
|
if (preCheckFailures.length > 0) {
|
|
902
917
|
const result2 = {
|
|
903
|
-
|
|
918
|
+
identityVerified: false,
|
|
919
|
+
policyAllowed: false,
|
|
904
920
|
accessLevel: "none",
|
|
905
921
|
denialReasons: preCheckFailures.map((f) => f.message),
|
|
906
922
|
guidance: {
|
|
@@ -949,7 +965,7 @@ function createMiddleware(options) {
|
|
|
949
965
|
});
|
|
950
966
|
req.agentVerification = result;
|
|
951
967
|
const sessionId = result.sessionId;
|
|
952
|
-
if (!result.
|
|
968
|
+
if (!result.identityVerified || !result.policyAllowed) {
|
|
953
969
|
if (shouldRecordDecisions && sessionId) {
|
|
954
970
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
955
971
|
});
|
|
@@ -1300,7 +1316,8 @@ function createMiddleware2(options) {
|
|
|
1300
1316
|
const preCheckFailures = performCounterpartyPreCheck(routeConfig, astraCreds, purpose);
|
|
1301
1317
|
if (preCheckFailures.length > 0) {
|
|
1302
1318
|
const preCheckResult = {
|
|
1303
|
-
|
|
1319
|
+
identityVerified: false,
|
|
1320
|
+
policyAllowed: false,
|
|
1304
1321
|
accessLevel: "none",
|
|
1305
1322
|
denialReasons: preCheckFailures.map((f) => f.message),
|
|
1306
1323
|
guidance: {
|
|
@@ -1363,20 +1380,22 @@ function createMiddleware2(options) {
|
|
|
1363
1380
|
agentCardUrl: request.headers.get("x-astrasync-agent-card") || void 0
|
|
1364
1381
|
}
|
|
1365
1382
|
});
|
|
1366
|
-
if (!result.
|
|
1383
|
+
if (!result.identityVerified || !result.policyAllowed || !hasMinimumAccess(result.accessLevel, routeConfig.minAccessLevel)) {
|
|
1367
1384
|
if (pathname.startsWith("/api/")) {
|
|
1368
1385
|
return NextResponse.json(
|
|
1369
1386
|
{
|
|
1370
1387
|
success: false,
|
|
1371
1388
|
error: {
|
|
1372
|
-
|
|
1389
|
+
// Round-18 G4: 401 → identity missing (re-auth); 403 → identity
|
|
1390
|
+
// OK, policy denied (update PDLSS / step up).
|
|
1391
|
+
code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
|
|
1373
1392
|
message: result.denialReasons?.[0] || "Access denied",
|
|
1374
1393
|
accessLevel: result.accessLevel,
|
|
1375
1394
|
required: routeConfig.minAccessLevel,
|
|
1376
1395
|
guidance: result.guidance
|
|
1377
1396
|
}
|
|
1378
1397
|
},
|
|
1379
|
-
{ status: result.
|
|
1398
|
+
{ status: !result.identityVerified ? 401 : 403 }
|
|
1380
1399
|
);
|
|
1381
1400
|
}
|
|
1382
1401
|
if (showCommerceShield) {
|
|
@@ -1391,7 +1410,12 @@ function createMiddleware2(options) {
|
|
|
1391
1410
|
return NextResponse.redirect(new URL("/unauthorized", request.url));
|
|
1392
1411
|
}
|
|
1393
1412
|
const response = NextResponse.next();
|
|
1394
|
-
response.headers.set(
|
|
1413
|
+
response.headers.set(
|
|
1414
|
+
"X-AstraSync-Verified",
|
|
1415
|
+
(result.identityVerified && result.policyAllowed).toString()
|
|
1416
|
+
);
|
|
1417
|
+
response.headers.set("X-AstraSync-Identity-Verified", result.identityVerified.toString());
|
|
1418
|
+
response.headers.set("X-AstraSync-Policy-Allowed", result.policyAllowed.toString());
|
|
1395
1419
|
response.headers.set("X-AstraSync-Access-Level", result.accessLevel);
|
|
1396
1420
|
if (result.agent) {
|
|
1397
1421
|
response.headers.set("X-AstraSync-Agent-Id", result.agent.astraId);
|
|
@@ -1459,7 +1483,11 @@ var VerificationGatewayClient = class {
|
|
|
1459
1483
|
);
|
|
1460
1484
|
}
|
|
1461
1485
|
/**
|
|
1462
|
-
* Quick verification
|
|
1486
|
+
* Quick verification — checks credentials and policy in one call.
|
|
1487
|
+
*
|
|
1488
|
+
* Round-18 G4: return shape mirrors `VerificationResult`'s identity/policy
|
|
1489
|
+
* split. Map to HTTP status the same way: `!identityVerified` → 401,
|
|
1490
|
+
* `identityVerified && !policyAllowed` → 403.
|
|
1463
1491
|
*/
|
|
1464
1492
|
async quickVerify(credentials) {
|
|
1465
1493
|
return this.executeWithRetry(() => quickVerify(this.config, credentials));
|
|
@@ -4102,13 +4130,16 @@ function readSingleHeader(value) {
|
|
|
4102
4130
|
}
|
|
4103
4131
|
function defaultMcpDenied(result, req, res) {
|
|
4104
4132
|
const id = req.body?.id ?? null;
|
|
4105
|
-
const status = result.
|
|
4133
|
+
const status = !result.identityVerified ? 401 : 403;
|
|
4106
4134
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
4107
4135
|
res.status(status).json({
|
|
4108
4136
|
jsonrpc: "2.0",
|
|
4109
4137
|
id,
|
|
4110
4138
|
error: {
|
|
4111
|
-
|
|
4139
|
+
// JSON-RPC error codes:
|
|
4140
|
+
// -32000 → unauthorized (no identity resolved)
|
|
4141
|
+
// -32001 → insufficient access (identity OK, policy denied)
|
|
4142
|
+
code: !result.identityVerified ? -32e3 : -32001,
|
|
4112
4143
|
message: result.denialReasons?.[0] ?? "Access denied",
|
|
4113
4144
|
data: {
|
|
4114
4145
|
accessLevel: result.accessLevel,
|
|
@@ -4242,7 +4273,7 @@ function createMcpMiddleware(options) {
|
|
|
4242
4273
|
req.agentVerification = result;
|
|
4243
4274
|
const sessionId = result.sessionId;
|
|
4244
4275
|
const correlationId = result.correlationId;
|
|
4245
|
-
if (!result.
|
|
4276
|
+
if (!result.identityVerified || !result.policyAllowed) {
|
|
4246
4277
|
if (shouldRecordDecisions && sessionId) {
|
|
4247
4278
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
4248
4279
|
});
|
|
@@ -4659,6 +4690,29 @@ var AstraSync = class {
|
|
|
4659
4690
|
}
|
|
4660
4691
|
};
|
|
4661
4692
|
|
|
4693
|
+
// src/registration/guidance.ts
|
|
4694
|
+
function buildGuidance(params) {
|
|
4695
|
+
const origin = params.origin.replace(/\/+$/, "");
|
|
4696
|
+
const docsPath = params.documentationPath ?? "/docs/agent-access";
|
|
4697
|
+
const message = params.message ?? "AstraSync registration requires credentials.";
|
|
4698
|
+
return {
|
|
4699
|
+
status: "credentials_required",
|
|
4700
|
+
message,
|
|
4701
|
+
guidance: {
|
|
4702
|
+
message: "AstraSync registration requires credentials. Get an account + API key, then call register_agent again.",
|
|
4703
|
+
registrationUrl: `${origin}/register`,
|
|
4704
|
+
documentationUrl: `${origin}${docsPath.startsWith("/") ? docsPath : `/${docsPath}`}`,
|
|
4705
|
+
steps: [
|
|
4706
|
+
"Visit registrationUrl and create an AstraSync account (or log in if you have one).",
|
|
4707
|
+
"Generate an API key from Settings \u2192 API Keys.",
|
|
4708
|
+
"Re-call register_agent with the apiKey populated.",
|
|
4709
|
+
"After registration returns status: pending_approval, the owner approves via email.",
|
|
4710
|
+
"Use poll_registration({ requestId }) to retrieve the astraId once approved."
|
|
4711
|
+
]
|
|
4712
|
+
}
|
|
4713
|
+
};
|
|
4714
|
+
}
|
|
4715
|
+
|
|
4662
4716
|
// src/agent/index.ts
|
|
4663
4717
|
var agent_exports = {};
|
|
4664
4718
|
__export(agent_exports, {
|
|
@@ -4992,6 +5046,7 @@ var VERSION = "2.0.0";
|
|
|
4992
5046
|
TRUST_LEVEL_RANGES,
|
|
4993
5047
|
VERSION,
|
|
4994
5048
|
agent,
|
|
5049
|
+
buildGuidance,
|
|
4995
5050
|
clearCache,
|
|
4996
5051
|
createMcpMiddleware,
|
|
4997
5052
|
determineAccessLevel,
|