@astrasyncai/verification-gateway 3.5.0 → 3.7.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.
Files changed (89) hide show
  1. package/README.md +16 -0
  2. package/dist/adapter-interface/interface.d.mts +2 -2
  3. package/dist/adapter-interface/interface.d.ts +2 -2
  4. package/dist/adapters/express.d.mts +2 -2
  5. package/dist/adapters/express.d.ts +2 -2
  6. package/dist/adapters/express.js +96 -20
  7. package/dist/adapters/express.js.map +1 -1
  8. package/dist/adapters/express.mjs +96 -20
  9. package/dist/adapters/express.mjs.map +1 -1
  10. package/dist/adapters/mcp.d.mts +1 -1
  11. package/dist/adapters/mcp.d.ts +1 -1
  12. package/dist/adapters/mcp.js +96 -20
  13. package/dist/adapters/mcp.js.map +1 -1
  14. package/dist/adapters/mcp.mjs +96 -20
  15. package/dist/adapters/mcp.mjs.map +1 -1
  16. package/dist/adapters/nextjs.d.mts +2 -2
  17. package/dist/adapters/nextjs.d.ts +2 -2
  18. package/dist/adapters/nextjs.js +101 -20
  19. package/dist/adapters/nextjs.js.map +1 -1
  20. package/dist/adapters/nextjs.mjs +101 -20
  21. package/dist/adapters/nextjs.mjs.map +1 -1
  22. package/dist/adapters/sdk.d.mts +2 -2
  23. package/dist/adapters/sdk.d.ts +2 -2
  24. package/dist/adapters/sdk.js +19 -16
  25. package/dist/adapters/sdk.js.map +1 -1
  26. package/dist/adapters/sdk.mjs +19 -16
  27. package/dist/adapters/sdk.mjs.map +1 -1
  28. package/dist/agent/index.d.mts +2 -2
  29. package/dist/agent/index.d.ts +2 -2
  30. package/dist/bin/astrasync-claude-hook.js +4791 -0
  31. package/dist/bin/astrasync-guard.js +5990 -0
  32. package/dist/bin/astrasync.js +6840 -330
  33. package/dist/browser/background.js +22 -16
  34. package/dist/browser/background.js.map +1 -1
  35. package/dist/browser/background.mjs +22 -16
  36. package/dist/browser/background.mjs.map +1 -1
  37. package/dist/browser/browser-adapter.d.mts +2 -2
  38. package/dist/browser/browser-adapter.d.ts +2 -2
  39. package/dist/claude-code/claude-code-adapter.d.mts +96 -0
  40. package/dist/claude-code/claude-code-adapter.d.ts +96 -0
  41. package/dist/claude-code/claude-code-adapter.js +277 -0
  42. package/dist/claude-code/claude-code-adapter.js.map +1 -0
  43. package/dist/claude-code/claude-code-adapter.mjs +249 -0
  44. package/dist/claude-code/claude-code-adapter.mjs.map +1 -0
  45. package/dist/cli/index.d.mts +2 -2
  46. package/dist/cli/index.d.ts +2 -2
  47. package/dist/cursor/cursor-adapter.d.mts +2 -2
  48. package/dist/cursor/cursor-adapter.d.ts +2 -2
  49. package/dist/cursor/extension.d.mts +2 -2
  50. package/dist/cursor/extension.d.ts +2 -2
  51. package/dist/cursor/extension.js +22 -16
  52. package/dist/cursor/extension.js.map +1 -1
  53. package/dist/cursor/extension.mjs +22 -16
  54. package/dist/cursor/extension.mjs.map +1 -1
  55. package/dist/{express-BH5ADAyb.d.mts → express-BnMO-H3y.d.mts} +1 -1
  56. package/dist/{express-jUzLIoep.d.ts → express-DQhDzNAt.d.ts} +1 -1
  57. package/dist/gateway/gateway.d.mts +2 -2
  58. package/dist/gateway/gateway.d.ts +2 -2
  59. package/dist/gateway/gateway.js +22 -16
  60. package/dist/gateway/gateway.js.map +1 -1
  61. package/dist/gateway/gateway.mjs +22 -16
  62. package/dist/gateway/gateway.mjs.map +1 -1
  63. package/dist/git-trigger/git-hooks.d.mts +2 -2
  64. package/dist/git-trigger/git-hooks.d.ts +2 -2
  65. package/dist/{index-aZHAWujT.d.mts → index-BT_aRn-I.d.mts} +1 -1
  66. package/dist/{index-DlCnmpJH.d.ts → index-D8-dvUFA.d.ts} +1 -1
  67. package/dist/{index-BR2nmxBU.d.mts → index-WHKq2v17.d.mts} +1 -1
  68. package/dist/{index-DEixUCu0.d.ts → index-rftma0ln.d.ts} +1 -1
  69. package/dist/index.d.mts +55 -9
  70. package/dist/index.d.ts +55 -9
  71. package/dist/index.js +145 -30
  72. package/dist/index.js.map +1 -1
  73. package/dist/index.mjs +143 -30
  74. package/dist/index.mjs.map +1 -1
  75. package/dist/local-evaluator/evaluator.d.mts +2 -2
  76. package/dist/local-evaluator/evaluator.d.ts +2 -2
  77. package/dist/{nextjs-LTeoPqMH.d.mts → nextjs-DFKYhxe6.d.mts} +1 -1
  78. package/dist/{nextjs-DfXOd0Au.d.ts → nextjs-DPj7ZNlq.d.ts} +1 -1
  79. package/dist/{sdk-LmvyDVpL.d.ts → sdk-CAcHgB5x.d.ts} +1 -1
  80. package/dist/{sdk-DKhwVL9X.d.mts → sdk-Cy3wAmDt.d.mts} +1 -1
  81. package/dist/transport/index.d.mts +2 -2
  82. package/dist/transport/index.d.ts +2 -2
  83. package/dist/{types-C8HyQEaz.d.mts → types-B-ubjHER.d.mts} +1 -1
  84. package/dist/{types-xofemo0G.d.ts → types-Bgn5gxHQ.d.ts} +1 -1
  85. package/dist/{types-DrDIouvO.d.mts → types-CKe8O0lR.d.mts} +41 -1
  86. package/dist/{types-DrDIouvO.d.ts → types-CKe8O0lR.d.ts} +41 -1
  87. package/dist/ui/index.d.mts +1 -1
  88. package/dist/ui/index.d.ts +1 -1
  89. package/package.json +9 -2
@@ -1,6 +1,6 @@
1
1
  import { AstraSyncGateway } from '../gateway/gateway.mjs';
2
- import { V as VerificationDecision, P as PDLSSContext } from '../types-C8HyQEaz.mjs';
3
- import '../types-DrDIouvO.mjs';
2
+ import { V as VerificationDecision, P as PDLSSContext } from '../types-B-ubjHER.mjs';
3
+ import '../types-CKe8O0lR.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-xofemo0G.js';
3
- import '../types-DrDIouvO.js';
2
+ import { V as VerificationDecision, P as PDLSSContext } from '../types-Bgn5gxHQ.js';
3
+ import '../types-CKe8O0lR.js';
4
4
 
5
5
  /**
6
6
  * Git Trigger — Enterprise git push / PR verification
@@ -1,4 +1,4 @@
1
- import { c as AstraSyncCredentials, g as ProtocolTransport, G as GatewayConfig } from './types-DrDIouvO.mjs';
1
+ import { c as AstraSyncCredentials, g as ProtocolTransport, G as GatewayConfig } from './types-CKe8O0lR.mjs';
2
2
 
3
3
  /**
4
4
  * AgentClient — Credential Presentation
@@ -1,4 +1,4 @@
1
- import { c as AstraSyncCredentials, g as ProtocolTransport, G as GatewayConfig } from './types-DrDIouvO.js';
1
+ import { c as AstraSyncCredentials, g as ProtocolTransport, G as GatewayConfig } from './types-CKe8O0lR.js';
2
2
 
3
3
  /**
4
4
  * AgentClient — Credential Presentation
@@ -1,4 +1,4 @@
1
- import { c as AstraSyncCredentials, g as ProtocolTransport } from './types-DrDIouvO.mjs';
1
+ import { c as AstraSyncCredentials, g as ProtocolTransport } from './types-CKe8O0lR.mjs';
2
2
  import { JWK } from 'jose';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { c as AstraSyncCredentials, g as ProtocolTransport } from './types-DrDIouvO.js';
1
+ import { c as AstraSyncCredentials, g as ProtocolTransport } from './types-CKe8O0lR.js';
2
2
  import { JWK } from 'jose';
3
3
 
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
- import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, V as VerificationRequest, l as VerificationResult, E as EnhancedVerificationResult, A as AccessFailure, j as StepUpApprovalInfo } from './types-DrDIouvO.mjs';
2
- export { c as AstraSyncCredentials, C as CommerceShieldProps, d as CounterpartyType, e as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, i as SettlementArtifact, T as TokenGuidance, k as TrustLevel, m as VerifiedAgent, n as VerifiedDeveloper, o as VerifiedOrganization } from './types-DrDIouvO.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-DKhwVL9X.mjs';
4
- export { e as express } from './express-BH5ADAyb.mjs';
5
- export { n as nextjs } from './nextjs-LTeoPqMH.mjs';
6
- export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-BR2nmxBU.mjs';
1
+ import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, V as VerificationRequest, n as VerificationResult, j as StepUpApprovalInfo, l as StepUpOutcome, k as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-CKe8O0lR.mjs';
2
+ export { c as AstraSyncCredentials, C as CommerceShieldProps, d as CounterpartyType, e as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, i as SettlementArtifact, T as TokenGuidance, m as TrustLevel, o as VerifiedAgent, p as VerifiedDeveloper, q as VerifiedOrganization } from './types-CKe8O0lR.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-Cy3wAmDt.mjs';
4
+ export { e as express } from './express-BnMO-H3y.mjs';
5
+ export { n as nextjs } from './nextjs-DFKYhxe6.mjs';
6
+ export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-WHKq2v17.mjs';
7
7
  export { McpMiddlewareOptions, ToolGateConfig, createMcpMiddleware } from './adapters/mcp.mjs';
8
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-aZHAWujT.mjs';
9
+ export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-BT_aRn-I.mjs';
10
10
  import 'express';
11
11
  import 'next/server';
12
12
  import 'jose';
@@ -30,10 +30,23 @@ declare function extractCredentials(headers: Record<string, string | string[] |
30
30
  * Check if credentials are present
31
31
  */
32
32
  declare function hasCredentials(credentials: AgentCredentials): boolean;
33
+ /**
34
+ * Options for a single verify() call (as opposed to GatewayConfig, which is
35
+ * per-gateway). Mirrors the Java SDK's `verify(request, bypassCache)`.
36
+ */
37
+ interface VerifyOptions {
38
+ /**
39
+ * Skip the cache READ for this call so the request is guaranteed to reach
40
+ * the backend (the result is still written to the cache if cacheable).
41
+ * Used by the step-up hold-and-poll retry: the re-verify after an approval
42
+ * must hit the server to redeem the single-use approval.
43
+ */
44
+ bypassCache?: boolean;
45
+ }
33
46
  /**
34
47
  * Main verification function
35
48
  */
36
- declare function verify(config: GatewayConfig, request: VerificationRequest): Promise<VerificationResult>;
49
+ declare function verify(config: GatewayConfig, request: VerificationRequest, options?: VerifyOptions): Promise<VerificationResult>;
37
50
  /**
38
51
  * Quick verification — checks credentials and policy in one call.
39
52
  *
@@ -50,6 +63,39 @@ declare function quickVerify(config: GatewayConfig, credentials: AgentCredential
50
63
  reason?: string;
51
64
  }>;
52
65
 
66
+ /**
67
+ * Step-up hold-and-poll (3.6.0) — the synchronous half of the MFA-style gate,
68
+ * mirroring the Java SDK's `awaitStepUpApproval` / `pollStepUpStatus`.
69
+ *
70
+ * A verify() that comes back step_up_required carries a `stepUpApproval`
71
+ * handle: `{ approvalId, pollUrl, expiresAt }`. The adapter HOLDS the original
72
+ * request, polls the approval status, and on 'approved' re-verifies the same
73
+ * request once (cache-bypassed) so the backend redeems the single-use approval
74
+ * and returns a grant. Any other terminal outcome falls into the adapter's
75
+ * normal fail-closed deny path.
76
+ *
77
+ * The poll endpoint is deliberately unauthenticated (it sits above the
78
+ * backend router's `authenticate` middleware): the unguessable UUIDv4
79
+ * approvalId is the capability token, and the route is rate-limited
80
+ * (60/min/IP). No Authorization header is sent.
81
+ */
82
+
83
+ /**
84
+ * One GET of the approval's poll endpoint. Returns the status string, or
85
+ * null on any error / non-2xx / unparsable body — the hold loop treats null
86
+ * as transient and just polls again.
87
+ */
88
+ declare function pollStepUpStatus(config: GatewayConfig, approval: StepUpApprovalInfo): Promise<StepUpApprovalStatus | null>;
89
+ /**
90
+ * Block until a pending step-up approval reaches a terminal state or the wait
91
+ * budget runs out. Returns the terminal status, or 'timeout'.
92
+ *
93
+ * Unknown non-pending statuses (a future backend state) still terminate the
94
+ * hold — they are returned as-is and land in the deny path, which is the safe
95
+ * reading of "not approved".
96
+ */
97
+ declare function awaitStepUpApproval(config: GatewayConfig, approval: StepUpApprovalInfo): Promise<StepUpOutcome>;
98
+
53
99
  /**
54
100
  * Settlement authorization — the value-aware, FAIL-CLOSED gate a direct merchant
55
101
  * MUST call before settling a priced cart (post-#447 partner round, finding #1).
@@ -156,4 +202,4 @@ declare function getCachedWellKnownUrls(apiBaseUrl: string): WellKnownAgenticCom
156
202
 
157
203
  declare const VERSION = "3.4.0";
158
204
 
159
- export { AccessLevel, AgentCredentials, EnhancedVerificationResult, GatewayConfig, type SettlementDecision, type SettlementRequest, StepUpApprovalInfo, VERSION, VerificationRequest, VerificationResult, type WellKnownAgenticCommerce, authorizeSettlement, clearCache, extractCredentials, getCachedWellKnownUrls, getWellKnownUrls, hasCredentials, prefetchWellKnown, quickVerify, verify };
205
+ export { AccessLevel, AgentCredentials, EnhancedVerificationResult, GatewayConfig, type SettlementDecision, type SettlementRequest, StepUpApprovalInfo, StepUpApprovalStatus, StepUpOutcome, VERSION, VerificationRequest, VerificationResult, type VerifyOptions, type WellKnownAgenticCommerce, authorizeSettlement, awaitStepUpApproval, clearCache, extractCredentials, getCachedWellKnownUrls, getWellKnownUrls, hasCredentials, pollStepUpStatus, prefetchWellKnown, quickVerify, verify };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, V as VerificationRequest, l as VerificationResult, E as EnhancedVerificationResult, A as AccessFailure, j as StepUpApprovalInfo } from './types-DrDIouvO.js';
2
- export { c as AstraSyncCredentials, C as CommerceShieldProps, d as CounterpartyType, e as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, i as SettlementArtifact, T as TokenGuidance, k as TrustLevel, m as VerifiedAgent, n as VerifiedDeveloper, o as VerifiedOrganization } from './types-DrDIouvO.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-LmvyDVpL.js';
4
- export { e as express } from './express-jUzLIoep.js';
5
- export { n as nextjs } from './nextjs-DfXOd0Au.js';
6
- export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-DEixUCu0.js';
1
+ import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, V as VerificationRequest, n as VerificationResult, j as StepUpApprovalInfo, l as StepUpOutcome, k as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-CKe8O0lR.js';
2
+ export { c as AstraSyncCredentials, C as CommerceShieldProps, d as CounterpartyType, e as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, i as SettlementArtifact, T as TokenGuidance, m as TrustLevel, o as VerifiedAgent, p as VerifiedDeveloper, q as VerifiedOrganization } from './types-CKe8O0lR.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-CAcHgB5x.js';
4
+ export { e as express } from './express-DQhDzNAt.js';
5
+ export { n as nextjs } from './nextjs-DPj7ZNlq.js';
6
+ export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-rftma0ln.js';
7
7
  export { McpMiddlewareOptions, ToolGateConfig, createMcpMiddleware } from './adapters/mcp.js';
8
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-DlCnmpJH.js';
9
+ export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-D8-dvUFA.js';
10
10
  import 'express';
11
11
  import 'next/server';
12
12
  import 'jose';
@@ -30,10 +30,23 @@ declare function extractCredentials(headers: Record<string, string | string[] |
30
30
  * Check if credentials are present
31
31
  */
32
32
  declare function hasCredentials(credentials: AgentCredentials): boolean;
33
+ /**
34
+ * Options for a single verify() call (as opposed to GatewayConfig, which is
35
+ * per-gateway). Mirrors the Java SDK's `verify(request, bypassCache)`.
36
+ */
37
+ interface VerifyOptions {
38
+ /**
39
+ * Skip the cache READ for this call so the request is guaranteed to reach
40
+ * the backend (the result is still written to the cache if cacheable).
41
+ * Used by the step-up hold-and-poll retry: the re-verify after an approval
42
+ * must hit the server to redeem the single-use approval.
43
+ */
44
+ bypassCache?: boolean;
45
+ }
33
46
  /**
34
47
  * Main verification function
35
48
  */
36
- declare function verify(config: GatewayConfig, request: VerificationRequest): Promise<VerificationResult>;
49
+ declare function verify(config: GatewayConfig, request: VerificationRequest, options?: VerifyOptions): Promise<VerificationResult>;
37
50
  /**
38
51
  * Quick verification — checks credentials and policy in one call.
39
52
  *
@@ -50,6 +63,39 @@ declare function quickVerify(config: GatewayConfig, credentials: AgentCredential
50
63
  reason?: string;
51
64
  }>;
52
65
 
66
+ /**
67
+ * Step-up hold-and-poll (3.6.0) — the synchronous half of the MFA-style gate,
68
+ * mirroring the Java SDK's `awaitStepUpApproval` / `pollStepUpStatus`.
69
+ *
70
+ * A verify() that comes back step_up_required carries a `stepUpApproval`
71
+ * handle: `{ approvalId, pollUrl, expiresAt }`. The adapter HOLDS the original
72
+ * request, polls the approval status, and on 'approved' re-verifies the same
73
+ * request once (cache-bypassed) so the backend redeems the single-use approval
74
+ * and returns a grant. Any other terminal outcome falls into the adapter's
75
+ * normal fail-closed deny path.
76
+ *
77
+ * The poll endpoint is deliberately unauthenticated (it sits above the
78
+ * backend router's `authenticate` middleware): the unguessable UUIDv4
79
+ * approvalId is the capability token, and the route is rate-limited
80
+ * (60/min/IP). No Authorization header is sent.
81
+ */
82
+
83
+ /**
84
+ * One GET of the approval's poll endpoint. Returns the status string, or
85
+ * null on any error / non-2xx / unparsable body — the hold loop treats null
86
+ * as transient and just polls again.
87
+ */
88
+ declare function pollStepUpStatus(config: GatewayConfig, approval: StepUpApprovalInfo): Promise<StepUpApprovalStatus | null>;
89
+ /**
90
+ * Block until a pending step-up approval reaches a terminal state or the wait
91
+ * budget runs out. Returns the terminal status, or 'timeout'.
92
+ *
93
+ * Unknown non-pending statuses (a future backend state) still terminate the
94
+ * hold — they are returned as-is and land in the deny path, which is the safe
95
+ * reading of "not approved".
96
+ */
97
+ declare function awaitStepUpApproval(config: GatewayConfig, approval: StepUpApprovalInfo): Promise<StepUpOutcome>;
98
+
53
99
  /**
54
100
  * Settlement authorization — the value-aware, FAIL-CLOSED gate a direct merchant
55
101
  * MUST call before settling a priced cart (post-#447 partner round, finding #1).
@@ -156,4 +202,4 @@ declare function getCachedWellKnownUrls(apiBaseUrl: string): WellKnownAgenticCom
156
202
 
157
203
  declare const VERSION = "3.4.0";
158
204
 
159
- export { AccessLevel, AgentCredentials, EnhancedVerificationResult, GatewayConfig, type SettlementDecision, type SettlementRequest, StepUpApprovalInfo, VERSION, VerificationRequest, VerificationResult, type WellKnownAgenticCommerce, authorizeSettlement, clearCache, extractCredentials, getCachedWellKnownUrls, getWellKnownUrls, hasCredentials, prefetchWellKnown, quickVerify, verify };
205
+ export { AccessLevel, AgentCredentials, EnhancedVerificationResult, GatewayConfig, type SettlementDecision, type SettlementRequest, StepUpApprovalInfo, StepUpApprovalStatus, StepUpOutcome, VERSION, VerificationRequest, VerificationResult, type VerifyOptions, type WellKnownAgenticCommerce, authorizeSettlement, awaitStepUpApproval, clearCache, extractCredentials, getCachedWellKnownUrls, getWellKnownUrls, hasCredentials, pollStepUpStatus, prefetchWellKnown, quickVerify, verify };
package/dist/index.js CHANGED
@@ -46,6 +46,7 @@ __export(src_exports, {
46
46
  VERSION: () => VERSION,
47
47
  agent: () => agent_exports,
48
48
  authorizeSettlement: () => authorizeSettlement,
49
+ awaitStepUpApproval: () => awaitStepUpApproval,
49
50
  buildGuidance: () => buildGuidance,
50
51
  clearCache: () => clearCache,
51
52
  createMcpMiddleware: () => createMcpMiddleware,
@@ -61,6 +62,7 @@ __export(src_exports, {
61
62
  hasCredentials: () => hasCredentials,
62
63
  hasMinimumAccess: () => hasMinimumAccess,
63
64
  nextjs: () => nextjs_exports,
65
+ pollStepUpStatus: () => pollStepUpStatus,
64
66
  prefetchWellKnown: () => prefetchWellKnown,
65
67
  quickVerify: () => quickVerify,
66
68
  recordDecision: () => recordDecision2,
@@ -193,7 +195,7 @@ function getCapabilities(accessLevel) {
193
195
  }
194
196
 
195
197
  // src/version.ts
196
- var SDK_VERSION = "3.5.0";
198
+ var SDK_VERSION = "3.7.0";
197
199
 
198
200
  // src/well-known.ts
199
201
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -263,10 +265,10 @@ var DEFAULT_CONFIG = {
263
265
  // through (`hasMinimumAccess('guidance', 'guidance') === true`).
264
266
  defaultAccessLevel: "none",
265
267
  // minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
266
- // Round-18.5 F4: cacheTtl deliberately unset. When undefined, cacheResult
267
- // applies the split default (60s autonomous / 300s step-up). When the
268
- // caller sets cacheTtl explicitly, that value is honoured uniformly.
269
- // Set cacheTtl: 0 to disable caching entirely.
268
+ // cacheTtl deliberately unset. When undefined, cacheResult applies the 60s
269
+ // default; the caller's explicit value is honoured for cacheable results.
270
+ // Denials and step-up escalations are NEVER cached (3.6.0) regardless of
271
+ // cacheTtl. Set cacheTtl: 0 to disable caching entirely.
270
272
  debug: false
271
273
  };
272
274
  var initCheckPerformed = false;
@@ -353,10 +355,9 @@ function getCachedResult(request, counterpartyId) {
353
355
  }
354
356
  return null;
355
357
  }
356
- var DEFAULT_AUTONOMOUS_TTL_SECONDS = 60;
357
- var DEFAULT_STEP_UP_TTL_SECONDS = 300;
358
+ var DEFAULT_CACHE_TTL_SECONDS = 60;
358
359
  function cacheResult(request, result, configuredTtl, counterpartyId) {
359
- const ttlSeconds = configuredTtl && configuredTtl > 0 ? configuredTtl : result.requiresStepUp ? DEFAULT_STEP_UP_TTL_SECONDS : DEFAULT_AUTONOMOUS_TTL_SECONDS;
360
+ const ttlSeconds = configuredTtl && configuredTtl > 0 ? configuredTtl : DEFAULT_CACHE_TTL_SECONDS;
360
361
  const key = getCacheKey(request, counterpartyId);
361
362
  verificationCache.set(key, {
362
363
  result,
@@ -538,7 +539,7 @@ async function callVerifyAccessAPI(config, request) {
538
539
  };
539
540
  }
540
541
  }
541
- async function verify(config, request) {
542
+ async function verify(config, request, options) {
542
543
  const mergedConfig = { ...DEFAULT_CONFIG, ...config };
543
544
  const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
544
545
  if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
@@ -554,7 +555,7 @@ async function verify(config, request) {
554
555
  "[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access-level decisions (the SDK reads access.accessLevel from the verify-access response). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
555
556
  );
556
557
  }
557
- if (mergedConfig.cacheTtl !== 0) {
558
+ if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
558
559
  const cached = getCachedResult(request, mergedConfig.counterpartyId);
559
560
  if (cached) {
560
561
  if (mergedConfig.debug) {
@@ -574,6 +575,8 @@ async function verify(config, request) {
574
575
  console.log("[VerificationGateway] Calling verify-access API");
575
576
  }
576
577
  const apiResponse = await callVerifyAccessAPI(mergedConfig, enrichedRequest);
578
+ const rawServerDenialReasons = apiResponse.denialReasons;
579
+ const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
577
580
  if (!apiResponse.success) {
578
581
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
579
582
  source: "api_error",
@@ -595,7 +598,10 @@ async function verify(config, request) {
595
598
  // ALSO short-circuit on `!identityVerified || !policyAllowed` before
596
599
  // the gate check — belt-and-braces.
597
600
  accessLevel: "none",
598
- denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
601
+ // 3.6.0: the server now emits top-level denialReasons on every deny
602
+ // path — prefer it verbatim; the failure-message reconstruction remains
603
+ // as the fallback for older backends.
604
+ denialReasons: serverDenialReasons ?? (aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"]),
599
605
  failures: aggregatedFailures,
600
606
  requiresStepUp: apiResponse.access?.requiresStepUp,
601
607
  requiresApproval: apiResponse.access?.requiresApproval,
@@ -672,9 +678,7 @@ async function verify(config, request) {
672
678
  if (result.recommendation === "deny") {
673
679
  result.policyAllowed = false;
674
680
  result.accessLevel = "none";
675
- result.denialReasons = result.recommendationReasons || [
676
- "Access denied by AstraSync recommendation"
677
- ];
681
+ result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Access denied by AstraSync recommendation"];
678
682
  result.guidance = result.runtimeChallenge ? {
679
683
  message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
680
684
  registrationUrl: urls?.registrationUrl ?? "",
@@ -686,9 +690,10 @@ async function verify(config, request) {
686
690
  };
687
691
  } else if (result.recommendation === "step_up_required") {
688
692
  result.requiresStepUp = true;
689
- result.denialReasons = result.recommendationReasons || ["Step-up verification required"];
693
+ result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Step-up verification required"];
690
694
  }
691
- if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny") {
695
+ const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
696
+ if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
692
697
  cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
693
698
  }
694
699
  return result;
@@ -747,6 +752,64 @@ async function quickVerify(config, credentials) {
747
752
  };
748
753
  }
749
754
 
755
+ // src/adapters/stepup-poll.ts
756
+ var DEFAULT_POLL_INTERVAL_MS = 3e3;
757
+ var MIN_POLL_INTERVAL_MS = 250;
758
+ var FALLBACK_MAX_WAIT_MS = 5 * 60 * 1e3;
759
+ var EXPIRY_GRACE_MS = 5e3;
760
+ var POLL_REQUEST_TIMEOUT_MS = 1e4;
761
+ function resolvePollUrl(config, pollUrl) {
762
+ if (pollUrl.startsWith("http")) return pollUrl;
763
+ const origin = (config.apiBaseUrl ?? "").replace(/\/api\/?$/, "");
764
+ return origin + pollUrl;
765
+ }
766
+ async function pollStepUpStatus(config, approval) {
767
+ if (!approval.pollUrl) return null;
768
+ try {
769
+ const res = await fetch(resolvePollUrl(config, approval.pollUrl), {
770
+ method: "GET",
771
+ signal: AbortSignal.timeout(POLL_REQUEST_TIMEOUT_MS)
772
+ });
773
+ if (!res.ok) return null;
774
+ const body = await res.json();
775
+ const data = body?.data;
776
+ const status = data && typeof data === "object" ? data.status : body?.status;
777
+ return typeof status === "string" ? status : null;
778
+ } catch {
779
+ return null;
780
+ }
781
+ }
782
+ function resolveDeadline(config, approval) {
783
+ const now = Date.now();
784
+ const maxWait = config.stepUpMaxWaitMs ?? 0;
785
+ if (maxWait > 0) return now + maxWait;
786
+ if (approval.expiresAt) {
787
+ const expiry = Date.parse(approval.expiresAt);
788
+ if (!Number.isNaN(expiry)) return Math.max(now, expiry) + EXPIRY_GRACE_MS;
789
+ }
790
+ return now + FALLBACK_MAX_WAIT_MS;
791
+ }
792
+ function sleep(ms) {
793
+ return new Promise((resolve) => setTimeout(resolve, ms));
794
+ }
795
+ async function awaitStepUpApproval(config, approval) {
796
+ const deadline = resolveDeadline(config, approval);
797
+ const pollInterval = Math.max(
798
+ MIN_POLL_INTERVAL_MS,
799
+ config.stepUpPollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS
800
+ );
801
+ while (Date.now() < deadline) {
802
+ const status = await pollStepUpStatus(config, approval);
803
+ if (status && status !== "pending") {
804
+ return status;
805
+ }
806
+ const remaining = deadline - Date.now();
807
+ if (remaining <= 0) break;
808
+ await sleep(Math.min(pollInterval, remaining));
809
+ }
810
+ return "timeout";
811
+ }
812
+
750
813
  // src/adapters/approval-gate.ts
751
814
  var APPROVAL_REASON = "Transaction is above the autonomous limit and requires human approval. The agent owner can approve or deny this transaction in the AstraSync dashboard.";
752
815
  function requiresHumanApproval(result) {
@@ -1093,7 +1156,10 @@ function defaultOnDenied(result, _req, res) {
1093
1156
  // Round-10: aggregated per-dimension detail + correlation handle.
1094
1157
  failures: result.failures,
1095
1158
  correlationId: result.correlationId,
1096
- stepUpApproval: result.stepUpApproval
1159
+ stepUpApproval: result.stepUpApproval,
1160
+ // 3.6.0: terminal outcome of an opt-in hold-and-poll wait (denied /
1161
+ // expired / consumed / timeout). Absent when the feature is off.
1162
+ ...result.stepUpOutcome && { stepUpOutcome: result.stepUpOutcome }
1097
1163
  }
1098
1164
  });
1099
1165
  }
@@ -1258,7 +1324,7 @@ function createMiddleware(options) {
1258
1324
  }
1259
1325
  }
1260
1326
  }
1261
- const result = await verify(config, {
1327
+ const verificationRequest = {
1262
1328
  credentials,
1263
1329
  purpose,
1264
1330
  action: pdlssPair.action,
@@ -1278,9 +1344,21 @@ function createMiddleware(options) {
1278
1344
  forwardedFor: forwardedForStr,
1279
1345
  agentCardUrl
1280
1346
  }
1281
- });
1347
+ };
1348
+ let result = await verify(config, verificationRequest);
1282
1349
  req.agentVerification = result;
1283
- const sessionId = result.sessionId;
1350
+ let sessionId = result.sessionId;
1351
+ if (config.stepUpMaxWaitMs !== void 0 && result.identityVerified && requiresHumanApproval(result) && result.stepUpApproval?.pollUrl) {
1352
+ const outcome = await awaitStepUpApproval(config, result.stepUpApproval);
1353
+ res.setHeader("X-Astra-Step-Up", outcome);
1354
+ if (outcome === "approved") {
1355
+ result = await verify(config, verificationRequest, { bypassCache: true });
1356
+ req.agentVerification = result;
1357
+ sessionId = result.sessionId;
1358
+ } else {
1359
+ result.stepUpOutcome = outcome;
1360
+ }
1361
+ }
1284
1362
  if (!result.identityVerified || !result.policyAllowed) {
1285
1363
  if (shouldRecordDecisions && sessionId) {
1286
1364
  recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
@@ -1729,7 +1807,7 @@ function createMiddleware2(options) {
1729
1807
  }
1730
1808
  const forwardedFor = request.headers.get("x-forwarded-for") || void 0;
1731
1809
  const originalClientIp = forwardedFor?.split(",")[0]?.trim();
1732
- const result = await verify(config, {
1810
+ const verificationRequest = {
1733
1811
  credentials,
1734
1812
  purpose,
1735
1813
  action: pdlssPair.action,
@@ -1746,7 +1824,17 @@ function createMiddleware2(options) {
1746
1824
  forwardedFor,
1747
1825
  agentCardUrl: request.headers.get("x-astrasync-agent-card") || void 0
1748
1826
  }
1749
- });
1827
+ };
1828
+ let result = await verify(config, verificationRequest);
1829
+ let stepUpHoldOutcome;
1830
+ if (config.stepUpMaxWaitMs !== void 0 && result.identityVerified && requiresHumanApproval(result) && result.stepUpApproval?.pollUrl) {
1831
+ stepUpHoldOutcome = await awaitStepUpApproval(config, result.stepUpApproval);
1832
+ if (stepUpHoldOutcome === "approved") {
1833
+ result = await verify(config, verificationRequest, { bypassCache: true });
1834
+ } else {
1835
+ result.stepUpOutcome = stepUpHoldOutcome;
1836
+ }
1837
+ }
1750
1838
  const approvalRequired = result.identityVerified && result.policyAllowed && requiresHumanApproval(result);
1751
1839
  if (approvalRequired) annotateApprovalRequired(result);
1752
1840
  if (!result.identityVerified || !result.policyAllowed || approvalRequired) {
@@ -1761,10 +1849,17 @@ function createMiddleware2(options) {
1761
1849
  message: result.denialReasons?.[0] || "Access denied",
1762
1850
  guidance: result.guidance,
1763
1851
  failures: result.failures,
1764
- stepUpApproval: result.stepUpApproval
1852
+ stepUpApproval: result.stepUpApproval,
1853
+ // 3.6.0: terminal outcome of an opt-in hold-and-poll wait.
1854
+ ...result.stepUpOutcome && { stepUpOutcome: result.stepUpOutcome }
1765
1855
  }
1766
1856
  },
1767
- { status: !result.identityVerified ? 401 : 403 }
1857
+ {
1858
+ status: !result.identityVerified ? 401 : 403,
1859
+ ...stepUpHoldOutcome && {
1860
+ headers: { "X-Astra-Step-Up": stepUpHoldOutcome }
1861
+ }
1862
+ }
1768
1863
  );
1769
1864
  }
1770
1865
  if (showCommerceShield) {
@@ -1783,6 +1878,9 @@ function createMiddleware2(options) {
1783
1878
  "X-AstraSync-Verified",
1784
1879
  (result.identityVerified && result.policyAllowed).toString()
1785
1880
  );
1881
+ if (stepUpHoldOutcome) {
1882
+ response.headers.set("X-Astra-Step-Up", stepUpHoldOutcome);
1883
+ }
1786
1884
  response.headers.set("X-AstraSync-Identity-Verified", result.identityVerified.toString());
1787
1885
  response.headers.set("X-AstraSync-Policy-Allowed", result.policyAllowed.toString());
1788
1886
  response.headers.set("X-AstraSync-Access-Level", result.accessLevel);
@@ -4680,7 +4778,10 @@ function defaultMcpDenied(result, req, res) {
4680
4778
  // Round-10: aggregated per-dimension detail + correlation handle.
4681
4779
  failures: result.failures,
4682
4780
  correlationId: result.correlationId,
4683
- stepUpApproval: result.stepUpApproval
4781
+ stepUpApproval: result.stepUpApproval,
4782
+ // 3.6.0: terminal outcome of an opt-in hold-and-poll wait (denied /
4783
+ // expired / consumed / timeout). Absent when the feature is off.
4784
+ ...result.stepUpOutcome && { stepUpOutcome: result.stepUpOutcome }
4684
4785
  }
4685
4786
  }
4686
4787
  });
@@ -4821,7 +4922,7 @@ function createMcpMiddleware(options) {
4821
4922
  }
4822
4923
  const counterpartyUrl = config.counterpartyUrl || `${req.protocol}://${req.get("host")}${req.path}`;
4823
4924
  const shouldRecordDecisions = recordDecisions !== false;
4824
- const result = await verify(config, {
4925
+ const verificationRequest = {
4825
4926
  credentials,
4826
4927
  purpose: pdlss.purpose,
4827
4928
  action: pdlss.action,
@@ -4839,9 +4940,21 @@ function createMcpMiddleware(options) {
4839
4940
  userAgent: req.headers["user-agent"],
4840
4941
  host: req.headers.host
4841
4942
  }
4842
- });
4943
+ };
4944
+ let result = await verify(config, verificationRequest);
4843
4945
  req.agentVerification = result;
4844
- const sessionId = result.sessionId;
4946
+ let sessionId = result.sessionId;
4947
+ if (config.stepUpMaxWaitMs !== void 0 && result.identityVerified && requiresHumanApproval(result) && result.stepUpApproval?.pollUrl) {
4948
+ const outcome = await awaitStepUpApproval(config, result.stepUpApproval);
4949
+ res.setHeader("X-Astra-Step-Up", outcome);
4950
+ if (outcome === "approved") {
4951
+ result = await verify(config, verificationRequest, { bypassCache: true });
4952
+ req.agentVerification = result;
4953
+ sessionId = result.sessionId;
4954
+ } else {
4955
+ result.stepUpOutcome = outcome;
4956
+ }
4957
+ }
4845
4958
  if (!result.identityVerified || !result.policyAllowed) {
4846
4959
  if (shouldRecordDecisions && sessionId) {
4847
4960
  recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
@@ -4995,7 +5108,7 @@ var RegistrationTimeoutError = class extends AstraSyncError {
4995
5108
 
4996
5109
  // src/registration/api.ts
4997
5110
  var DEFAULT_BASE_URL = "https://astrasync.ai";
4998
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
5111
+ var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
4999
5112
  var AstraSync = class {
5000
5113
  constructor(config = {}) {
5001
5114
  let raw = (config.baseUrl || process.env.ASTRASYNC_API_URL || DEFAULT_BASE_URL).replace(
@@ -5157,7 +5270,7 @@ var AstraSync = class {
5157
5270
  if (result.state === "expired") {
5158
5271
  throw new RegistrationExpiredError(requestId);
5159
5272
  }
5160
- await sleep(pollIntervalMs);
5273
+ await sleep2(pollIntervalMs);
5161
5274
  }
5162
5275
  throw new RegistrationTimeoutError(requestId);
5163
5276
  }
@@ -5627,6 +5740,7 @@ var VERSION = "3.4.0";
5627
5740
  VERSION,
5628
5741
  agent,
5629
5742
  authorizeSettlement,
5743
+ awaitStepUpApproval,
5630
5744
  buildGuidance,
5631
5745
  clearCache,
5632
5746
  createMcpMiddleware,
@@ -5642,6 +5756,7 @@ var VERSION = "3.4.0";
5642
5756
  hasCredentials,
5643
5757
  hasMinimumAccess,
5644
5758
  nextjs,
5759
+ pollStepUpStatus,
5645
5760
  prefetchWellKnown,
5646
5761
  quickVerify,
5647
5762
  recordDecision,