@astrasyncai/verification-gateway 2.1.0 → 2.2.3

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 (84) hide show
  1. package/README.md +64 -30
  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 +74 -95
  7. package/dist/adapters/express.js.map +1 -1
  8. package/dist/adapters/express.mjs +74 -95
  9. package/dist/adapters/express.mjs.map +1 -1
  10. package/dist/adapters/nextjs.d.mts +2 -2
  11. package/dist/adapters/nextjs.d.ts +2 -2
  12. package/dist/adapters/nextjs.js +74 -115
  13. package/dist/adapters/nextjs.js.map +1 -1
  14. package/dist/adapters/nextjs.mjs +74 -115
  15. package/dist/adapters/nextjs.mjs.map +1 -1
  16. package/dist/adapters/sdk.d.mts +2 -2
  17. package/dist/adapters/sdk.d.ts +2 -2
  18. package/dist/adapters/sdk.js +56 -55
  19. package/dist/adapters/sdk.js.map +1 -1
  20. package/dist/adapters/sdk.mjs +56 -55
  21. package/dist/adapters/sdk.mjs.map +1 -1
  22. package/dist/agent/index.d.mts +2 -2
  23. package/dist/agent/index.d.ts +2 -2
  24. package/dist/agent/index.js +68 -2
  25. package/dist/agent/index.js.map +1 -1
  26. package/dist/agent/index.mjs +66 -2
  27. package/dist/agent/index.mjs.map +1 -1
  28. package/dist/browser/background.js +56 -55
  29. package/dist/browser/background.js.map +1 -1
  30. package/dist/browser/background.mjs +56 -55
  31. package/dist/browser/background.mjs.map +1 -1
  32. package/dist/browser/browser-adapter.d.mts +2 -2
  33. package/dist/browser/browser-adapter.d.ts +2 -2
  34. package/dist/cli/index.d.mts +2 -2
  35. package/dist/cli/index.d.ts +2 -2
  36. package/dist/cursor/cursor-adapter.d.mts +2 -2
  37. package/dist/cursor/cursor-adapter.d.ts +2 -2
  38. package/dist/cursor/extension.d.mts +2 -2
  39. package/dist/cursor/extension.d.ts +2 -2
  40. package/dist/cursor/extension.js +56 -55
  41. package/dist/cursor/extension.js.map +1 -1
  42. package/dist/cursor/extension.mjs +56 -55
  43. package/dist/cursor/extension.mjs.map +1 -1
  44. package/dist/{express-Bcl-uBUE.d.ts → express-BtKlLI8U.d.ts} +2 -2
  45. package/dist/{express-CtwDIZyF.d.mts → express-DgwpS8Ha.d.mts} +2 -2
  46. package/dist/gateway/gateway.d.mts +2 -2
  47. package/dist/gateway/gateway.d.ts +2 -2
  48. package/dist/gateway/gateway.js +56 -55
  49. package/dist/gateway/gateway.js.map +1 -1
  50. package/dist/gateway/gateway.mjs +56 -55
  51. package/dist/gateway/gateway.mjs.map +1 -1
  52. package/dist/git-trigger/git-hooks.d.mts +2 -2
  53. package/dist/git-trigger/git-hooks.d.ts +2 -2
  54. package/dist/{index-BY8yQ8N8.d.mts → index-AzhK20t0.d.mts} +46 -3
  55. package/dist/{index-CME6r4uH.d.ts → index-Ba0Lvsjo.d.ts} +1 -1
  56. package/dist/{index-3NRaBNvp.d.mts → index-BaxpmTGA.d.mts} +1 -1
  57. package/dist/{index-CtYSYwn3.d.ts → index-DpJS1JEI.d.ts} +46 -3
  58. package/dist/index.d.mts +7 -7
  59. package/dist/index.d.ts +7 -7
  60. package/dist/index.js +158 -117
  61. package/dist/index.js.map +1 -1
  62. package/dist/index.mjs +158 -117
  63. package/dist/index.mjs.map +1 -1
  64. package/dist/local-evaluator/evaluator.d.mts +2 -2
  65. package/dist/local-evaluator/evaluator.d.ts +2 -2
  66. package/dist/{nextjs-CEldnIJ9.d.ts → nextjs-B2kg19c1.d.ts} +1 -1
  67. package/dist/{nextjs-BQyMCSx_.d.mts → nextjs-ZymQ8jDh.d.mts} +1 -1
  68. package/dist/{sdk-BhvuJSrH.d.mts → sdk-B7id0VFS.d.mts} +2 -2
  69. package/dist/{sdk-BlyVSC_S.d.ts → sdk-Bso0FSI0.d.ts} +2 -2
  70. package/dist/transport/index.d.mts +2 -2
  71. package/dist/transport/index.d.ts +2 -2
  72. package/dist/{types-79qS7aON.d.ts → types-BYKAY6Cc.d.ts} +1 -1
  73. package/dist/{types-jJnPXStc.d.mts → types-CgXPKUwi.d.mts} +1 -1
  74. package/dist/{types-CxQwJKbd.d.mts → types-DOrqNMgy.d.mts} +79 -13
  75. package/dist/{types-CxQwJKbd.d.ts → types-DOrqNMgy.d.ts} +79 -13
  76. package/dist/ui/index.d.mts +1 -1
  77. package/dist/ui/index.d.ts +1 -1
  78. package/dist/webhooks.d.mts +59 -0
  79. package/dist/webhooks.d.ts +59 -0
  80. package/dist/webhooks.js +81 -0
  81. package/dist/webhooks.js.map +1 -0
  82. package/dist/webhooks.mjs +55 -0
  83. package/dist/webhooks.mjs.map +1 -0
  84. package/package.json +8 -3
@@ -1,5 +1,5 @@
1
- import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-jJnPXStc.mjs';
2
- import '../types-CxQwJKbd.mjs';
1
+ import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-CgXPKUwi.mjs';
2
+ import '../types-DOrqNMgy.mjs';
3
3
 
4
4
  /**
5
5
  * Local PDLSS Evaluator
@@ -1,5 +1,5 @@
1
- import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-79qS7aON.js';
2
- import '../types-CxQwJKbd.js';
1
+ import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-BYKAY6Cc.js';
2
+ import '../types-DOrqNMgy.js';
3
3
 
4
4
  /**
5
5
  * Local PDLSS Evaluator
@@ -1,6 +1,6 @@
1
1
  import * as next_server from 'next/server';
2
2
  import { NextRequest } from 'next/server';
3
- import { N as NextJsMiddlewareOptions } from './types-CxQwJKbd.js';
3
+ import { N as NextJsMiddlewareOptions } from './types-DOrqNMgy.js';
4
4
 
5
5
  /**
6
6
  * Create Next.js middleware for agent verification
@@ -1,6 +1,6 @@
1
1
  import * as next_server from 'next/server';
2
2
  import { NextRequest } from 'next/server';
3
- import { N as NextJsMiddlewareOptions } from './types-CxQwJKbd.mjs';
3
+ import { N as NextJsMiddlewareOptions } from './types-DOrqNMgy.mjs';
4
4
 
5
5
  /**
6
6
  * Create Next.js middleware for agent verification
@@ -1,4 +1,4 @@
1
- import { a as AccessLevel, i as TrustLevel, S as SDKOptions, V as VerificationResult } from './types-CxQwJKbd.mjs';
1
+ import { a as AccessLevel, i as TrustLevel, S as SDKOptions, V as VerificationResult } from './types-DOrqNMgy.mjs';
2
2
 
3
3
  /**
4
4
  * AstraSync Universal Verification Gateway - Access Level Definitions
@@ -69,7 +69,7 @@ declare function getCapabilities(accessLevel: AccessLevel): AccessCapabilities;
69
69
  * import { createClient } from '@astrasyncai/verification-gateway/sdk';
70
70
  *
71
71
  * const gateway = createClient({
72
- * apiBaseUrl: 'https://api.astrasync.ai',
72
+ * apiBaseUrl: 'https://astrasync.ai/api',
73
73
  * });
74
74
  *
75
75
  * // Verify another agent before interacting
@@ -1,4 +1,4 @@
1
- import { a as AccessLevel, i as TrustLevel, S as SDKOptions, V as VerificationResult } from './types-CxQwJKbd.js';
1
+ import { a as AccessLevel, i as TrustLevel, S as SDKOptions, V as VerificationResult } from './types-DOrqNMgy.js';
2
2
 
3
3
  /**
4
4
  * AstraSync Universal Verification Gateway - Access Level Definitions
@@ -69,7 +69,7 @@ declare function getCapabilities(accessLevel: AccessLevel): AccessCapabilities;
69
69
  * import { createClient } from '@astrasyncai/verification-gateway/sdk';
70
70
  *
71
71
  * const gateway = createClient({
72
- * apiBaseUrl: 'https://api.astrasync.ai',
72
+ * apiBaseUrl: 'https://astrasync.ai/api',
73
73
  * });
74
74
  *
75
75
  * // Verify another agent before interacting
@@ -1,3 +1,3 @@
1
- import '../types-CxQwJKbd.mjs';
2
- export { A as ACPEndpoint, a as ACPPaymentTokenType, b as ACPRequestContext, c as ACPRequestLike, d as ACPSignatureAlgorithm, e as ACPTotal, f as ACPVerifyInput, g as ACPVerifyResult, h as AP2CartMandateClaims, j as AP2ChainResult, k as AP2IntentMandateClaims, l as AP2MandateClaims, m as AP2MandateTriple, n as AP2MandateTripleInput, o as AP2MandateType, p as AP2PaymentDetailsTotal, q as AP2PaymentMandateClaims, r as AP2PaymentMandateForValue, s as AP2VerifyInput, C as CommerceContext, t as CommercePipelineInput, u as CommerceProtocol, v as CommercePurpose, w as CommerceSignatureStack, x as ConstraintEvalResult, y as ConstraintKey, z as ConstraintResult, E as ExtractorRequestLike, I as IdentityBindingResult, B as IdentityClaim, D as IdentityResolver, M as MPPChallengeForValue, F as MPPChallengeSummary, G as MPPCredentialSummary, H as MPPIntent, J as MPPKind, K as MPPReceiptSummary, L as MPPRequestContext, N as MPPRequestLike, O as MPPResponseLike, P as MPPVerifyInput, Q as MPPVerifyResult, R as ParsedRFC9421, S as PaymentMethodAllowlistInput, T as RFC9421SignatureParams, U as RFC9421Tag, V as RFC9421VerifyOptions, W as RFC9421VerifyRequest, X as RFC9421VerifyResult, Y as RegistryName, Z as RegistryResolver, _ as ResolveContext, $ as STRIPE_WEBHOOK_INFORMATIONAL_EVENTS, a0 as SpendingLimitInput, a1 as StripeWebhookInformationalEvent, a2 as TransactionContext, a3 as TransactionValueContext, a4 as TransportExtractor, a5 as UCPCheckoutContext, a6 as UCPManifestValidationResult, a7 as UCPRequestLike, a8 as UCPTotal, a9 as VIAllowedParty, aa as VIBudgetLimit, ab as VIClaimsForValue, ac as VIConstraintEvalInput, ad as VIConstraints, ae as VIExecutionMode, af as VIExtractedClaims, ag as VILayer, ah as VILineItem, ai as VIMandateType, aj as VIPaymentAmount, ak as VIRecurrence, al as VIVerifyInput, am as VIVerifyResult, an as VerifyStripeWebhookOptions, ao as VerifyStripeWebhookResult, ap as X402Kind, aq as X402RequestContext, ar as X402RequestForValue, as as X402RequestLike, at as X402RequirementsSummary, au as X402ResponseLike, av as applyCredentials, aw as bindIdentity, ax as claim, ay as clearTransportExtractors, az as createMastercardRegistry, aA as createVisaRegistry, aB as createWebBotAuthRegistry, aC as detectProtocol, aD as evaluatePaymentMethodAllowlist, aE as evaluateSpendingLimit, aF as evaluateVIConstraints, aG as extractA2ACredentials, aH as extractACPContext, aI as extractACPTransactionValue, aJ as extractAP2Mandate, aK as extractAP2Mandates, aL as extractAP2TransactionValue, aM as extractCredentialsFromProtocol, aN as extractHttpCredentials, aO as extractMPPContext, aP as extractMPPFromRequest, aQ as extractMPPFromResponse, aR as extractMPPTransactionValue, aS as extractMcpCredentials, aT as extractUCPContext, aU as extractUCPTransactionValue, aV as extractVIClaims, aW as extractVITransactionValue, aX as extractX402Context, aY as extractX402FromRequest, aZ as extractX402FromResponse, a_ as extractX402TransactionValue, a$ as fetchUCPManifest, b0 as getTransportExtractor, b1 as getTransportExtractors, b2 as isStripeWebhookInformational, b3 as mapACPRequestToPurpose, b4 as mapAP2MandateToPurpose, b5 as mapMPPRequestToPurpose, b6 as mapRFC9421TagToPurpose, b7 as mapUCPRequestToPurpose, b8 as mapVIMandateToPurpose, b9 as mapX402RequestToPurpose, ba as parseRFC9421, bb as registerTransportExtractor, bc as runCommercePipeline, bd as runMatchingExtractors, be as setA2AMetadata, bf as setHttpHeaders, bg as setMcpMeta, bh as validateUCPManifest, bi as verifyACPSignature, bj as verifyAP2Chain, bk as verifyMPP, bl as verifyRFC9421, bm as verifyStripeWebhook, bn as verifyVIChain } from '../index-3NRaBNvp.mjs';
1
+ import '../types-DOrqNMgy.mjs';
2
+ export { A as ACPEndpoint, a as ACPPaymentTokenType, b as ACPRequestContext, c as ACPRequestLike, d as ACPSignatureAlgorithm, e as ACPTotal, f as ACPVerifyInput, g as ACPVerifyResult, h as AP2CartMandateClaims, j as AP2ChainResult, k as AP2IntentMandateClaims, l as AP2MandateClaims, m as AP2MandateTriple, n as AP2MandateTripleInput, o as AP2MandateType, p as AP2PaymentDetailsTotal, q as AP2PaymentMandateClaims, r as AP2PaymentMandateForValue, s as AP2VerifyInput, C as CommerceContext, t as CommercePipelineInput, u as CommerceProtocol, v as CommercePurpose, w as CommerceSignatureStack, x as ConstraintEvalResult, y as ConstraintKey, z as ConstraintResult, E as ExtractorRequestLike, I as IdentityBindingResult, B as IdentityClaim, D as IdentityResolver, M as MPPChallengeForValue, F as MPPChallengeSummary, G as MPPCredentialSummary, H as MPPIntent, J as MPPKind, K as MPPReceiptSummary, L as MPPRequestContext, N as MPPRequestLike, O as MPPResponseLike, P as MPPVerifyInput, Q as MPPVerifyResult, R as ParsedRFC9421, S as PaymentMethodAllowlistInput, T as RFC9421SignatureParams, U as RFC9421Tag, V as RFC9421VerifyOptions, W as RFC9421VerifyRequest, X as RFC9421VerifyResult, Y as RegistryName, Z as RegistryResolver, _ as ResolveContext, $ as STRIPE_WEBHOOK_INFORMATIONAL_EVENTS, a0 as SpendingLimitInput, a1 as StripeWebhookInformationalEvent, a2 as TransactionContext, a3 as TransactionValueContext, a4 as TransportExtractor, a5 as UCPCheckoutContext, a6 as UCPManifestValidationResult, a7 as UCPRequestLike, a8 as UCPTotal, a9 as VIAllowedParty, aa as VIBudgetLimit, ab as VIClaimsForValue, ac as VIConstraintEvalInput, ad as VIConstraints, ae as VIExecutionMode, af as VIExtractedClaims, ag as VILayer, ah as VILineItem, ai as VIMandateType, aj as VIPaymentAmount, ak as VIRecurrence, al as VIVerifyInput, am as VIVerifyResult, an as VerifyStripeWebhookOptions, ao as VerifyStripeWebhookResult, ap as X402Kind, aq as X402RequestContext, ar as X402RequestForValue, as as X402RequestLike, at as X402RequirementsSummary, au as X402ResponseLike, av as applyCredentials, aw as bindIdentity, ax as claim, ay as clearTransportExtractors, az as createMastercardRegistry, aA as createVisaRegistry, aB as createWebBotAuthRegistry, aC as detectProtocol, aD as evaluatePaymentMethodAllowlist, aE as evaluateSpendingLimit, aF as evaluateVIConstraints, aG as extractA2ACredentials, aH as extractACPContext, aI as extractACPTransactionValue, aJ as extractAP2Mandate, aK as extractAP2Mandates, aL as extractAP2TransactionValue, aM as extractCredentialsFromProtocol, aN as extractHttpCredentials, aO as extractMPPContext, aP as extractMPPFromRequest, aQ as extractMPPFromResponse, aR as extractMPPTransactionValue, aS as extractMcpCredentials, aT as extractUCPContext, aU as extractUCPTransactionValue, aV as extractVIClaims, aW as extractVITransactionValue, aX as extractX402Context, aY as extractX402FromRequest, aZ as extractX402FromResponse, a_ as extractX402TransactionValue, a$ as fetchUCPManifest, b0 as getTransportExtractor, b1 as getTransportExtractors, b2 as isStripeWebhookInformational, b3 as mapACPRequestToPurpose, b4 as mapAP2MandateToPurpose, b5 as mapMPPRequestToPurpose, b6 as mapRFC9421TagToPurpose, b7 as mapUCPRequestToPurpose, b8 as mapVIMandateToPurpose, b9 as mapX402RequestToPurpose, ba as parseRFC9421, bb as registerTransportExtractor, bc as runCommercePipeline, bd as runMatchingExtractors, be as setA2AMetadata, bf as setHttpHeaders, bg as setMcpMeta, bh as validateUCPManifest, bi as verifyACPSignature, bj as verifyAP2Chain, bk as verifyMPP, bl as verifyRFC9421, bm as verifyStripeWebhook, bn as verifyVIChain } from '../index-BaxpmTGA.mjs';
3
3
  import 'jose';
@@ -1,3 +1,3 @@
1
- import '../types-CxQwJKbd.js';
2
- export { A as ACPEndpoint, a as ACPPaymentTokenType, b as ACPRequestContext, c as ACPRequestLike, d as ACPSignatureAlgorithm, e as ACPTotal, f as ACPVerifyInput, g as ACPVerifyResult, h as AP2CartMandateClaims, j as AP2ChainResult, k as AP2IntentMandateClaims, l as AP2MandateClaims, m as AP2MandateTriple, n as AP2MandateTripleInput, o as AP2MandateType, p as AP2PaymentDetailsTotal, q as AP2PaymentMandateClaims, r as AP2PaymentMandateForValue, s as AP2VerifyInput, C as CommerceContext, t as CommercePipelineInput, u as CommerceProtocol, v as CommercePurpose, w as CommerceSignatureStack, x as ConstraintEvalResult, y as ConstraintKey, z as ConstraintResult, E as ExtractorRequestLike, I as IdentityBindingResult, B as IdentityClaim, D as IdentityResolver, M as MPPChallengeForValue, F as MPPChallengeSummary, G as MPPCredentialSummary, H as MPPIntent, J as MPPKind, K as MPPReceiptSummary, L as MPPRequestContext, N as MPPRequestLike, O as MPPResponseLike, P as MPPVerifyInput, Q as MPPVerifyResult, R as ParsedRFC9421, S as PaymentMethodAllowlistInput, T as RFC9421SignatureParams, U as RFC9421Tag, V as RFC9421VerifyOptions, W as RFC9421VerifyRequest, X as RFC9421VerifyResult, Y as RegistryName, Z as RegistryResolver, _ as ResolveContext, $ as STRIPE_WEBHOOK_INFORMATIONAL_EVENTS, a0 as SpendingLimitInput, a1 as StripeWebhookInformationalEvent, a2 as TransactionContext, a3 as TransactionValueContext, a4 as TransportExtractor, a5 as UCPCheckoutContext, a6 as UCPManifestValidationResult, a7 as UCPRequestLike, a8 as UCPTotal, a9 as VIAllowedParty, aa as VIBudgetLimit, ab as VIClaimsForValue, ac as VIConstraintEvalInput, ad as VIConstraints, ae as VIExecutionMode, af as VIExtractedClaims, ag as VILayer, ah as VILineItem, ai as VIMandateType, aj as VIPaymentAmount, ak as VIRecurrence, al as VIVerifyInput, am as VIVerifyResult, an as VerifyStripeWebhookOptions, ao as VerifyStripeWebhookResult, ap as X402Kind, aq as X402RequestContext, ar as X402RequestForValue, as as X402RequestLike, at as X402RequirementsSummary, au as X402ResponseLike, av as applyCredentials, aw as bindIdentity, ax as claim, ay as clearTransportExtractors, az as createMastercardRegistry, aA as createVisaRegistry, aB as createWebBotAuthRegistry, aC as detectProtocol, aD as evaluatePaymentMethodAllowlist, aE as evaluateSpendingLimit, aF as evaluateVIConstraints, aG as extractA2ACredentials, aH as extractACPContext, aI as extractACPTransactionValue, aJ as extractAP2Mandate, aK as extractAP2Mandates, aL as extractAP2TransactionValue, aM as extractCredentialsFromProtocol, aN as extractHttpCredentials, aO as extractMPPContext, aP as extractMPPFromRequest, aQ as extractMPPFromResponse, aR as extractMPPTransactionValue, aS as extractMcpCredentials, aT as extractUCPContext, aU as extractUCPTransactionValue, aV as extractVIClaims, aW as extractVITransactionValue, aX as extractX402Context, aY as extractX402FromRequest, aZ as extractX402FromResponse, a_ as extractX402TransactionValue, a$ as fetchUCPManifest, b0 as getTransportExtractor, b1 as getTransportExtractors, b2 as isStripeWebhookInformational, b3 as mapACPRequestToPurpose, b4 as mapAP2MandateToPurpose, b5 as mapMPPRequestToPurpose, b6 as mapRFC9421TagToPurpose, b7 as mapUCPRequestToPurpose, b8 as mapVIMandateToPurpose, b9 as mapX402RequestToPurpose, ba as parseRFC9421, bb as registerTransportExtractor, bc as runCommercePipeline, bd as runMatchingExtractors, be as setA2AMetadata, bf as setHttpHeaders, bg as setMcpMeta, bh as validateUCPManifest, bi as verifyACPSignature, bj as verifyAP2Chain, bk as verifyMPP, bl as verifyRFC9421, bm as verifyStripeWebhook, bn as verifyVIChain } from '../index-CME6r4uH.js';
1
+ import '../types-DOrqNMgy.js';
2
+ export { A as ACPEndpoint, a as ACPPaymentTokenType, b as ACPRequestContext, c as ACPRequestLike, d as ACPSignatureAlgorithm, e as ACPTotal, f as ACPVerifyInput, g as ACPVerifyResult, h as AP2CartMandateClaims, j as AP2ChainResult, k as AP2IntentMandateClaims, l as AP2MandateClaims, m as AP2MandateTriple, n as AP2MandateTripleInput, o as AP2MandateType, p as AP2PaymentDetailsTotal, q as AP2PaymentMandateClaims, r as AP2PaymentMandateForValue, s as AP2VerifyInput, C as CommerceContext, t as CommercePipelineInput, u as CommerceProtocol, v as CommercePurpose, w as CommerceSignatureStack, x as ConstraintEvalResult, y as ConstraintKey, z as ConstraintResult, E as ExtractorRequestLike, I as IdentityBindingResult, B as IdentityClaim, D as IdentityResolver, M as MPPChallengeForValue, F as MPPChallengeSummary, G as MPPCredentialSummary, H as MPPIntent, J as MPPKind, K as MPPReceiptSummary, L as MPPRequestContext, N as MPPRequestLike, O as MPPResponseLike, P as MPPVerifyInput, Q as MPPVerifyResult, R as ParsedRFC9421, S as PaymentMethodAllowlistInput, T as RFC9421SignatureParams, U as RFC9421Tag, V as RFC9421VerifyOptions, W as RFC9421VerifyRequest, X as RFC9421VerifyResult, Y as RegistryName, Z as RegistryResolver, _ as ResolveContext, $ as STRIPE_WEBHOOK_INFORMATIONAL_EVENTS, a0 as SpendingLimitInput, a1 as StripeWebhookInformationalEvent, a2 as TransactionContext, a3 as TransactionValueContext, a4 as TransportExtractor, a5 as UCPCheckoutContext, a6 as UCPManifestValidationResult, a7 as UCPRequestLike, a8 as UCPTotal, a9 as VIAllowedParty, aa as VIBudgetLimit, ab as VIClaimsForValue, ac as VIConstraintEvalInput, ad as VIConstraints, ae as VIExecutionMode, af as VIExtractedClaims, ag as VILayer, ah as VILineItem, ai as VIMandateType, aj as VIPaymentAmount, ak as VIRecurrence, al as VIVerifyInput, am as VIVerifyResult, an as VerifyStripeWebhookOptions, ao as VerifyStripeWebhookResult, ap as X402Kind, aq as X402RequestContext, ar as X402RequestForValue, as as X402RequestLike, at as X402RequirementsSummary, au as X402ResponseLike, av as applyCredentials, aw as bindIdentity, ax as claim, ay as clearTransportExtractors, az as createMastercardRegistry, aA as createVisaRegistry, aB as createWebBotAuthRegistry, aC as detectProtocol, aD as evaluatePaymentMethodAllowlist, aE as evaluateSpendingLimit, aF as evaluateVIConstraints, aG as extractA2ACredentials, aH as extractACPContext, aI as extractACPTransactionValue, aJ as extractAP2Mandate, aK as extractAP2Mandates, aL as extractAP2TransactionValue, aM as extractCredentialsFromProtocol, aN as extractHttpCredentials, aO as extractMPPContext, aP as extractMPPFromRequest, aQ as extractMPPFromResponse, aR as extractMPPTransactionValue, aS as extractMcpCredentials, aT as extractUCPContext, aU as extractUCPTransactionValue, aV as extractVIClaims, aW as extractVITransactionValue, aX as extractX402Context, aY as extractX402FromRequest, aZ as extractX402FromResponse, a_ as extractX402TransactionValue, a$ as fetchUCPManifest, b0 as getTransportExtractor, b1 as getTransportExtractors, b2 as isStripeWebhookInformational, b3 as mapACPRequestToPurpose, b4 as mapAP2MandateToPurpose, b5 as mapMPPRequestToPurpose, b6 as mapRFC9421TagToPurpose, b7 as mapUCPRequestToPurpose, b8 as mapVIMandateToPurpose, b9 as mapX402RequestToPurpose, ba as parseRFC9421, bb as registerTransportExtractor, bc as runCommercePipeline, bd as runMatchingExtractors, be as setA2AMetadata, bf as setHttpHeaders, bg as setMcpMeta, bh as validateUCPManifest, bi as verifyACPSignature, bj as verifyAP2Chain, bk as verifyMPP, bl as verifyRFC9421, bm as verifyStripeWebhook, bn as verifyVIChain } from '../index-Ba0Lvsjo.js';
3
3
  import 'jose';
@@ -1,4 +1,4 @@
1
- import { a as AccessLevel, C as CounterpartyType, T as TokenGuidance } from './types-CxQwJKbd.js';
1
+ import { a as AccessLevel, C as CounterpartyType, T as TokenGuidance } from './types-DOrqNMgy.js';
2
2
 
3
3
  /**
4
4
  * AstraSync Gateway - Types for gateway modes, local evaluation, and adapter interface.
@@ -1,4 +1,4 @@
1
- import { a as AccessLevel, C as CounterpartyType, T as TokenGuidance } from './types-CxQwJKbd.mjs';
1
+ import { a as AccessLevel, C as CounterpartyType, T as TokenGuidance } from './types-DOrqNMgy.mjs';
2
2
 
3
3
  /**
4
4
  * AstraSync Gateway - Types for gateway modes, local evaluation, and adapter interface.
@@ -8,19 +8,32 @@
8
8
  */
9
9
  type TrustLevel = 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM';
10
10
  /**
11
- * Access levels granted based on verification result
12
- * - none: No credentials provided, show guidance
13
- * - guidance: Commerce Shield overlay with registration info
14
- * - read-only: Can browse, no mutations
15
- * - standard: Normal access per PDLSS
16
- * - full: Full access for high-trust agents
17
- * - internal: Internal org access (same organization)
11
+ * Access levels granted based on verification result. Server is the single
12
+ * source of truth these values are the resolved decision the server returns
13
+ * in `access.accessLevel`. SDK reads them verbatim (no client-side remap).
14
+ *
15
+ * For ANONYMOUS / unverified callers, the level is determined by the
16
+ * endpoint's `unverifiedAgentPolicy` per the verify-access canonical flow
17
+ * (see `docs/research/adapter-architecture-technical-requirements.md` §21):
18
+ * - Branch A (deny): `none` — caller is denied + advised to register
19
+ * - Branch B (allow_partial): `guidance` — reduced/browse-only access + advised
20
+ * - Branch C (allow_full): `standard` — unrestricted + advised to register for next time
21
+ * Every branch ALWAYS emits a verification event + queues a blockchain record.
22
+ *
23
+ * For VERIFIED callers (Branch D), the level is resolved server-side from the
24
+ * agent's live trust score plus the endpoint's `trust_score_requirement`:
25
+ * - none: agent below endpoint gate (denied; access.allowed=false)
26
+ * - guidance: 0–19 trust score
27
+ * - read-only: 20–39 trust score (browse, no mutations)
28
+ * - standard: 40–69 trust score (PDLSS-scoped operations)
29
+ * - full: 70+ trust score (PDLSS-scoped, high-trust)
30
+ * - internal: same-org membership, regardless of score
18
31
  */
19
32
  type AccessLevel = 'none' | 'guidance' | 'read-only' | 'standard' | 'full' | 'internal';
20
33
  /**
21
34
  * Types of counterparties that can integrate the gateway
22
35
  */
23
- type CounterpartyType = 'agent' | 'api' | 'mcp_server' | 'website' | 'other';
36
+ type CounterpartyType = 'agent' | 'api' | 'mcp_server' | 'website' | 'other' | 'unknown';
24
37
  /**
25
38
  * Agent credentials extracted from request
26
39
  */
@@ -40,13 +53,21 @@ interface AgentCredentials {
40
53
  interface GatewayConfig {
41
54
  /** AstraSync API base URL */
42
55
  apiBaseUrl: string;
43
- /** API key for authenticating with AstraSync (optional for public endpoints) */
56
+ /** API key for authenticating with AstraSync. */
44
57
  apiKey?: string;
45
58
  /** Default access level for unverified requests */
46
59
  defaultAccessLevel?: AccessLevel;
47
- /** Minimum trust score required for standard access */
60
+ /**
61
+ * @deprecated Removed in v2.3.0 — server is the single source of truth for
62
+ * access-level decisions. Setting this no longer affects access decisions
63
+ * (the SDK reads `access.accessLevel` from the verify-access response).
64
+ * If you need a higher gate for an endpoint, configure it server-side via
65
+ * the endpoint's `trust_score_requirement`.
66
+ */
48
67
  minTrustScore?: number;
49
- /** Minimum trust score required for full access */
68
+ /**
69
+ * @deprecated Removed in v2.3.0 — see `minTrustScore` above.
70
+ */
50
71
  minTrustScoreForFull?: number;
51
72
  /** Cache verification results (TTL in seconds) */
52
73
  cacheTtl?: number;
@@ -58,6 +79,24 @@ interface GatewayConfig {
58
79
  counterpartyUrl?: string;
59
80
  /** This counterparty's type (sent with verify-access requests for analytics) */
60
81
  counterpartyType?: CounterpartyType;
82
+ /**
83
+ * This counterparty's ASTRAE-id (issued at endpoint registration). When set,
84
+ * the SDK forwards it on verify-access calls so the server attributes traffic
85
+ * directly to this endpoint rather than resolving by URL. Useful when:
86
+ * - The merchant has multiple endpoints under the same origin (each running
87
+ * its own SDK instance with its own counterpartyId)
88
+ * - The endpoint URL might be served behind a proxy / different host than
89
+ * the registered origin
90
+ */
91
+ counterpartyId?: string;
92
+ /**
93
+ * Disable the one-time init self-test. The SDK normally fires a HEAD/OPTIONS
94
+ * to `${apiBaseUrl}/agents/verify-access` on first verify() call and warns
95
+ * if the response is HTML (indicating apiBaseUrl is pointing at a marketing
96
+ * site rather than the API). Set true for tests or environments where the
97
+ * extra request is undesirable.
98
+ */
99
+ disableInitChecks?: boolean;
61
100
  }
62
101
  /**
63
102
  * Verified agent information
@@ -173,6 +212,26 @@ interface VerificationResult {
173
212
  /**
174
213
  * Request context for verification
175
214
  */
215
+ /**
216
+ * Caller metadata forwarded from the agent's original HTTP request so the
217
+ * endpoint owner can see the real agent-side fingerprint in activity views.
218
+ * Without this, IP/UA recorded on platform_events would be the counterparty
219
+ * server's (useless for endpoint-side forensics).
220
+ */
221
+ interface CallerMetadata {
222
+ /** Agent-side source IP (honours X-Forwarded-For if set). */
223
+ sourceIp?: string;
224
+ /** Agent's User-Agent header. */
225
+ userAgent?: string;
226
+ /** Referer header (where the agent navigated from, if applicable). */
227
+ referer?: string;
228
+ /** Host the agent called (this counterparty's public hostname). */
229
+ host?: string;
230
+ /** Raw X-Forwarded-For chain for audit. */
231
+ forwardedFor?: string;
232
+ /** Published agent card URL, if the agent advertised one (future: from agent headers). */
233
+ agentCardUrl?: string;
234
+ }
176
235
  interface VerificationRequest {
177
236
  /** Agent credentials */
178
237
  credentials: AgentCredentials;
@@ -196,10 +255,17 @@ interface VerificationRequest {
196
255
  parentAgentId?: string;
197
256
  /** Depth of sub-agent chain */
198
257
  subAgentDepth?: number;
199
- /** Client IP address */
258
+ /** Client IP address (deprecated — use callerMetadata.sourceIp) */
200
259
  clientIp?: string;
201
- /** User agent string */
260
+ /** User agent string (deprecated — use callerMetadata.userAgent) */
202
261
  userAgent?: string;
262
+ /**
263
+ * Forwarded request metadata from the agent's original call.
264
+ * When the SDK is embedded in a counterparty server, these describe
265
+ * the agent-side fingerprint — not the counterparty server itself.
266
+ * The express/nextjs adapters auto-populate these from `req`.
267
+ */
268
+ callerMetadata?: CallerMetadata;
203
269
  /** Enable runtime challenge for this request */
204
270
  enableRuntimeChallenge?: boolean;
205
271
  /** Create a verification session (returns sessionId) */
@@ -8,19 +8,32 @@
8
8
  */
9
9
  type TrustLevel = 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM';
10
10
  /**
11
- * Access levels granted based on verification result
12
- * - none: No credentials provided, show guidance
13
- * - guidance: Commerce Shield overlay with registration info
14
- * - read-only: Can browse, no mutations
15
- * - standard: Normal access per PDLSS
16
- * - full: Full access for high-trust agents
17
- * - internal: Internal org access (same organization)
11
+ * Access levels granted based on verification result. Server is the single
12
+ * source of truth these values are the resolved decision the server returns
13
+ * in `access.accessLevel`. SDK reads them verbatim (no client-side remap).
14
+ *
15
+ * For ANONYMOUS / unverified callers, the level is determined by the
16
+ * endpoint's `unverifiedAgentPolicy` per the verify-access canonical flow
17
+ * (see `docs/research/adapter-architecture-technical-requirements.md` §21):
18
+ * - Branch A (deny): `none` — caller is denied + advised to register
19
+ * - Branch B (allow_partial): `guidance` — reduced/browse-only access + advised
20
+ * - Branch C (allow_full): `standard` — unrestricted + advised to register for next time
21
+ * Every branch ALWAYS emits a verification event + queues a blockchain record.
22
+ *
23
+ * For VERIFIED callers (Branch D), the level is resolved server-side from the
24
+ * agent's live trust score plus the endpoint's `trust_score_requirement`:
25
+ * - none: agent below endpoint gate (denied; access.allowed=false)
26
+ * - guidance: 0–19 trust score
27
+ * - read-only: 20–39 trust score (browse, no mutations)
28
+ * - standard: 40–69 trust score (PDLSS-scoped operations)
29
+ * - full: 70+ trust score (PDLSS-scoped, high-trust)
30
+ * - internal: same-org membership, regardless of score
18
31
  */
19
32
  type AccessLevel = 'none' | 'guidance' | 'read-only' | 'standard' | 'full' | 'internal';
20
33
  /**
21
34
  * Types of counterparties that can integrate the gateway
22
35
  */
23
- type CounterpartyType = 'agent' | 'api' | 'mcp_server' | 'website' | 'other';
36
+ type CounterpartyType = 'agent' | 'api' | 'mcp_server' | 'website' | 'other' | 'unknown';
24
37
  /**
25
38
  * Agent credentials extracted from request
26
39
  */
@@ -40,13 +53,21 @@ interface AgentCredentials {
40
53
  interface GatewayConfig {
41
54
  /** AstraSync API base URL */
42
55
  apiBaseUrl: string;
43
- /** API key for authenticating with AstraSync (optional for public endpoints) */
56
+ /** API key for authenticating with AstraSync. */
44
57
  apiKey?: string;
45
58
  /** Default access level for unverified requests */
46
59
  defaultAccessLevel?: AccessLevel;
47
- /** Minimum trust score required for standard access */
60
+ /**
61
+ * @deprecated Removed in v2.3.0 — server is the single source of truth for
62
+ * access-level decisions. Setting this no longer affects access decisions
63
+ * (the SDK reads `access.accessLevel` from the verify-access response).
64
+ * If you need a higher gate for an endpoint, configure it server-side via
65
+ * the endpoint's `trust_score_requirement`.
66
+ */
48
67
  minTrustScore?: number;
49
- /** Minimum trust score required for full access */
68
+ /**
69
+ * @deprecated Removed in v2.3.0 — see `minTrustScore` above.
70
+ */
50
71
  minTrustScoreForFull?: number;
51
72
  /** Cache verification results (TTL in seconds) */
52
73
  cacheTtl?: number;
@@ -58,6 +79,24 @@ interface GatewayConfig {
58
79
  counterpartyUrl?: string;
59
80
  /** This counterparty's type (sent with verify-access requests for analytics) */
60
81
  counterpartyType?: CounterpartyType;
82
+ /**
83
+ * This counterparty's ASTRAE-id (issued at endpoint registration). When set,
84
+ * the SDK forwards it on verify-access calls so the server attributes traffic
85
+ * directly to this endpoint rather than resolving by URL. Useful when:
86
+ * - The merchant has multiple endpoints under the same origin (each running
87
+ * its own SDK instance with its own counterpartyId)
88
+ * - The endpoint URL might be served behind a proxy / different host than
89
+ * the registered origin
90
+ */
91
+ counterpartyId?: string;
92
+ /**
93
+ * Disable the one-time init self-test. The SDK normally fires a HEAD/OPTIONS
94
+ * to `${apiBaseUrl}/agents/verify-access` on first verify() call and warns
95
+ * if the response is HTML (indicating apiBaseUrl is pointing at a marketing
96
+ * site rather than the API). Set true for tests or environments where the
97
+ * extra request is undesirable.
98
+ */
99
+ disableInitChecks?: boolean;
61
100
  }
62
101
  /**
63
102
  * Verified agent information
@@ -173,6 +212,26 @@ interface VerificationResult {
173
212
  /**
174
213
  * Request context for verification
175
214
  */
215
+ /**
216
+ * Caller metadata forwarded from the agent's original HTTP request so the
217
+ * endpoint owner can see the real agent-side fingerprint in activity views.
218
+ * Without this, IP/UA recorded on platform_events would be the counterparty
219
+ * server's (useless for endpoint-side forensics).
220
+ */
221
+ interface CallerMetadata {
222
+ /** Agent-side source IP (honours X-Forwarded-For if set). */
223
+ sourceIp?: string;
224
+ /** Agent's User-Agent header. */
225
+ userAgent?: string;
226
+ /** Referer header (where the agent navigated from, if applicable). */
227
+ referer?: string;
228
+ /** Host the agent called (this counterparty's public hostname). */
229
+ host?: string;
230
+ /** Raw X-Forwarded-For chain for audit. */
231
+ forwardedFor?: string;
232
+ /** Published agent card URL, if the agent advertised one (future: from agent headers). */
233
+ agentCardUrl?: string;
234
+ }
176
235
  interface VerificationRequest {
177
236
  /** Agent credentials */
178
237
  credentials: AgentCredentials;
@@ -196,10 +255,17 @@ interface VerificationRequest {
196
255
  parentAgentId?: string;
197
256
  /** Depth of sub-agent chain */
198
257
  subAgentDepth?: number;
199
- /** Client IP address */
258
+ /** Client IP address (deprecated — use callerMetadata.sourceIp) */
200
259
  clientIp?: string;
201
- /** User agent string */
260
+ /** User agent string (deprecated — use callerMetadata.userAgent) */
202
261
  userAgent?: string;
262
+ /**
263
+ * Forwarded request metadata from the agent's original call.
264
+ * When the SDK is embedded in a counterparty server, these describe
265
+ * the agent-side fingerprint — not the counterparty server itself.
266
+ * The express/nextjs adapters auto-populate these from `req`.
267
+ */
268
+ callerMetadata?: CallerMetadata;
203
269
  /** Enable runtime challenge for this request */
204
270
  enableRuntimeChallenge?: boolean;
205
271
  /** Create a verification session (returns sessionId) */
@@ -1,4 +1,4 @@
1
- import { d as CommerceShieldProps, V as VerificationResult, b as AgentCredentials, f as GuidanceInfo, i as TrustLevel } from '../types-CxQwJKbd.mjs';
1
+ import { d as CommerceShieldProps, V as VerificationResult, b as AgentCredentials, f as GuidanceInfo, i as TrustLevel } from '../types-DOrqNMgy.mjs';
2
2
 
3
3
  /**
4
4
  * AstraSync Commerce Shield Component
@@ -1,4 +1,4 @@
1
- import { d as CommerceShieldProps, V as VerificationResult, b as AgentCredentials, f as GuidanceInfo, i as TrustLevel } from '../types-CxQwJKbd.js';
1
+ import { d as CommerceShieldProps, V as VerificationResult, b as AgentCredentials, f as GuidanceInfo, i as TrustLevel } from '../types-DOrqNMgy.js';
2
2
 
3
3
  /**
4
4
  * AstraSync Commerce Shield Component
@@ -0,0 +1,59 @@
1
+ /**
2
+ * AstraSync webhook signature verification.
3
+ *
4
+ * AstraSync signs every webhook delivery with HMAC-SHA256 over
5
+ * `${unix_timestamp}.${rawBody}` using the merchant's webhook secret
6
+ * (returned ONCE at endpoint registration). The signature is sent in
7
+ * the `X-AstraSync-Signature` header in the form:
8
+ *
9
+ * X-AstraSync-Signature: t=<unix-ts>,v1=<hex-hmac>
10
+ *
11
+ * This pattern mirrors Stripe's `Stripe-Signature` to ease adoption.
12
+ *
13
+ * Usage:
14
+ * import { verifyAstraSyncWebhook } from '@astrasyncai/verification-gateway/webhooks';
15
+ *
16
+ * app.post('/webhooks/astrasync', express.raw({type:'application/json'}), (req, res) => {
17
+ * const result = verifyAstraSyncWebhook(req.body.toString('utf8'), req.headers, secret);
18
+ * if (!result.ok) return res.status(401).json({error: result.reason});
19
+ * // ... process event
20
+ * });
21
+ */
22
+ interface VerifyWebhookOptions {
23
+ /**
24
+ * Maximum age (seconds) for the signature timestamp. Older deliveries
25
+ * are rejected as replays. Default 300 (5 minutes) — matches Stripe.
26
+ */
27
+ toleranceSeconds?: number;
28
+ /**
29
+ * Override "now" for tests. Defaults to Date.now().
30
+ */
31
+ nowMs?: number;
32
+ }
33
+ interface VerifyWebhookResult {
34
+ ok: boolean;
35
+ reason?: string;
36
+ }
37
+ /**
38
+ * Verify an AstraSync-issued webhook delivery.
39
+ *
40
+ * @param rawBody - The raw request body as a string (NOT the parsed JSON).
41
+ * Use `express.raw({type:'application/json'})` to preserve bytes.
42
+ * @param headers - Incoming request headers (case-insensitive).
43
+ * @param secret - The merchant's webhook secret from endpoint registration.
44
+ * @param options - Optional tolerance overrides.
45
+ * @returns - `{ok: true}` on success, `{ok: false, reason}` on failure.
46
+ */
47
+ declare function verifyAstraSyncWebhook(rawBody: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): VerifyWebhookResult;
48
+ /**
49
+ * Server-side companion: produce an `X-AstraSync-Signature` header value for
50
+ * an outbound webhook delivery. Exposed for completeness and for test
51
+ * harnesses that want to verify the verifier; the AstraSync platform itself
52
+ * uses an internal version of the same logic.
53
+ */
54
+ declare function signAstraSyncWebhook(rawBody: string, secret: string, nowMs?: number): {
55
+ header: string;
56
+ timestamp: number;
57
+ };
58
+
59
+ export { type VerifyWebhookOptions, type VerifyWebhookResult, signAstraSyncWebhook, verifyAstraSyncWebhook };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * AstraSync webhook signature verification.
3
+ *
4
+ * AstraSync signs every webhook delivery with HMAC-SHA256 over
5
+ * `${unix_timestamp}.${rawBody}` using the merchant's webhook secret
6
+ * (returned ONCE at endpoint registration). The signature is sent in
7
+ * the `X-AstraSync-Signature` header in the form:
8
+ *
9
+ * X-AstraSync-Signature: t=<unix-ts>,v1=<hex-hmac>
10
+ *
11
+ * This pattern mirrors Stripe's `Stripe-Signature` to ease adoption.
12
+ *
13
+ * Usage:
14
+ * import { verifyAstraSyncWebhook } from '@astrasyncai/verification-gateway/webhooks';
15
+ *
16
+ * app.post('/webhooks/astrasync', express.raw({type:'application/json'}), (req, res) => {
17
+ * const result = verifyAstraSyncWebhook(req.body.toString('utf8'), req.headers, secret);
18
+ * if (!result.ok) return res.status(401).json({error: result.reason});
19
+ * // ... process event
20
+ * });
21
+ */
22
+ interface VerifyWebhookOptions {
23
+ /**
24
+ * Maximum age (seconds) for the signature timestamp. Older deliveries
25
+ * are rejected as replays. Default 300 (5 minutes) — matches Stripe.
26
+ */
27
+ toleranceSeconds?: number;
28
+ /**
29
+ * Override "now" for tests. Defaults to Date.now().
30
+ */
31
+ nowMs?: number;
32
+ }
33
+ interface VerifyWebhookResult {
34
+ ok: boolean;
35
+ reason?: string;
36
+ }
37
+ /**
38
+ * Verify an AstraSync-issued webhook delivery.
39
+ *
40
+ * @param rawBody - The raw request body as a string (NOT the parsed JSON).
41
+ * Use `express.raw({type:'application/json'})` to preserve bytes.
42
+ * @param headers - Incoming request headers (case-insensitive).
43
+ * @param secret - The merchant's webhook secret from endpoint registration.
44
+ * @param options - Optional tolerance overrides.
45
+ * @returns - `{ok: true}` on success, `{ok: false, reason}` on failure.
46
+ */
47
+ declare function verifyAstraSyncWebhook(rawBody: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): VerifyWebhookResult;
48
+ /**
49
+ * Server-side companion: produce an `X-AstraSync-Signature` header value for
50
+ * an outbound webhook delivery. Exposed for completeness and for test
51
+ * harnesses that want to verify the verifier; the AstraSync platform itself
52
+ * uses an internal version of the same logic.
53
+ */
54
+ declare function signAstraSyncWebhook(rawBody: string, secret: string, nowMs?: number): {
55
+ header: string;
56
+ timestamp: number;
57
+ };
58
+
59
+ export { type VerifyWebhookOptions, type VerifyWebhookResult, signAstraSyncWebhook, verifyAstraSyncWebhook };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/webhooks.ts
21
+ var webhooks_exports = {};
22
+ __export(webhooks_exports, {
23
+ signAstraSyncWebhook: () => signAstraSyncWebhook,
24
+ verifyAstraSyncWebhook: () => verifyAstraSyncWebhook
25
+ });
26
+ module.exports = __toCommonJS(webhooks_exports);
27
+ var import_crypto = require("crypto");
28
+ var DEFAULT_TOLERANCE_SECONDS = 300;
29
+ function parseSignatureHeader(header) {
30
+ const parts = {};
31
+ for (const segment of header.split(",")) {
32
+ const [k, v] = segment.split("=");
33
+ if (k === "t" || k === "v1") parts[k] = v;
34
+ }
35
+ return parts;
36
+ }
37
+ function computeHmac(secret, signedPayload) {
38
+ return (0, import_crypto.createHmac)("sha256", secret).update(signedPayload, "utf8").digest("hex");
39
+ }
40
+ function constantTimeEquals(a, b) {
41
+ const aBuf = Buffer.from(a, "utf8");
42
+ const bBuf = Buffer.from(b, "utf8");
43
+ if (aBuf.length !== bBuf.length) return false;
44
+ return (0, import_crypto.timingSafeEqual)(aBuf, bBuf);
45
+ }
46
+ function verifyAstraSyncWebhook(rawBody, headers, secret, options = {}) {
47
+ if (!secret) return { ok: false, reason: "no_secret_provided" };
48
+ const rawHeader = headers["x-astrasync-signature"] ?? headers["X-Astrasync-Signature"] ?? headers["X-AstraSync-Signature"] ?? headers["X-ASTRASYNC-SIGNATURE"];
49
+ if (!rawHeader) return { ok: false, reason: "missing_signature_header" };
50
+ const headerValue = Array.isArray(rawHeader) ? rawHeader[0] : rawHeader;
51
+ const { t: timestamp, v1: receivedSignature } = parseSignatureHeader(headerValue);
52
+ if (!timestamp || !receivedSignature) {
53
+ return { ok: false, reason: "malformed_signature_header" };
54
+ }
55
+ const tolerance = options.toleranceSeconds ?? DEFAULT_TOLERANCE_SECONDS;
56
+ const now = options.nowMs ?? Date.now();
57
+ const tsSeconds = Number(timestamp);
58
+ if (!Number.isFinite(tsSeconds)) {
59
+ return { ok: false, reason: "invalid_timestamp" };
60
+ }
61
+ const ageSeconds = Math.abs(now / 1e3 - tsSeconds);
62
+ if (ageSeconds > tolerance) {
63
+ return { ok: false, reason: "timestamp_outside_tolerance" };
64
+ }
65
+ const expectedSignature = computeHmac(secret, `${timestamp}.${rawBody}`);
66
+ if (!constantTimeEquals(expectedSignature, receivedSignature)) {
67
+ return { ok: false, reason: "signature_mismatch" };
68
+ }
69
+ return { ok: true };
70
+ }
71
+ function signAstraSyncWebhook(rawBody, secret, nowMs = Date.now()) {
72
+ const timestamp = Math.floor(nowMs / 1e3);
73
+ const v1 = computeHmac(secret, `${timestamp}.${rawBody}`);
74
+ return { header: `t=${timestamp},v1=${v1}`, timestamp };
75
+ }
76
+ // Annotate the CommonJS export names for ESM import in node:
77
+ 0 && (module.exports = {
78
+ signAstraSyncWebhook,
79
+ verifyAstraSyncWebhook
80
+ });
81
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/webhooks.ts"],"sourcesContent":["/**\n * AstraSync webhook signature verification.\n *\n * AstraSync signs every webhook delivery with HMAC-SHA256 over\n * `${unix_timestamp}.${rawBody}` using the merchant's webhook secret\n * (returned ONCE at endpoint registration). The signature is sent in\n * the `X-AstraSync-Signature` header in the form:\n *\n * X-AstraSync-Signature: t=<unix-ts>,v1=<hex-hmac>\n *\n * This pattern mirrors Stripe's `Stripe-Signature` to ease adoption.\n *\n * Usage:\n * import { verifyAstraSyncWebhook } from '@astrasyncai/verification-gateway/webhooks';\n *\n * app.post('/webhooks/astrasync', express.raw({type:'application/json'}), (req, res) => {\n * const result = verifyAstraSyncWebhook(req.body.toString('utf8'), req.headers, secret);\n * if (!result.ok) return res.status(401).json({error: result.reason});\n * // ... process event\n * });\n */\n\nimport { createHmac, timingSafeEqual } from 'crypto';\n\nexport interface VerifyWebhookOptions {\n /**\n * Maximum age (seconds) for the signature timestamp. Older deliveries\n * are rejected as replays. Default 300 (5 minutes) — matches Stripe.\n */\n toleranceSeconds?: number;\n /**\n * Override \"now\" for tests. Defaults to Date.now().\n */\n nowMs?: number;\n}\n\nexport interface VerifyWebhookResult {\n ok: boolean;\n reason?: string;\n}\n\nconst DEFAULT_TOLERANCE_SECONDS = 300;\n\nfunction parseSignatureHeader(header: string): { t?: string; v1?: string } {\n const parts: { t?: string; v1?: string } = {};\n for (const segment of header.split(',')) {\n const [k, v] = segment.split('=');\n if (k === 't' || k === 'v1') parts[k] = v;\n }\n return parts;\n}\n\nfunction computeHmac(secret: string, signedPayload: string): string {\n return createHmac('sha256', secret).update(signedPayload, 'utf8').digest('hex');\n}\n\nfunction constantTimeEquals(a: string, b: string): boolean {\n const aBuf = Buffer.from(a, 'utf8');\n const bBuf = Buffer.from(b, 'utf8');\n if (aBuf.length !== bBuf.length) return false;\n return timingSafeEqual(aBuf, bBuf);\n}\n\n/**\n * Verify an AstraSync-issued webhook delivery.\n *\n * @param rawBody - The raw request body as a string (NOT the parsed JSON).\n * Use `express.raw({type:'application/json'})` to preserve bytes.\n * @param headers - Incoming request headers (case-insensitive).\n * @param secret - The merchant's webhook secret from endpoint registration.\n * @param options - Optional tolerance overrides.\n * @returns - `{ok: true}` on success, `{ok: false, reason}` on failure.\n */\nexport function verifyAstraSyncWebhook(\n rawBody: string,\n headers: Record<string, string | string[] | undefined>,\n secret: string,\n options: VerifyWebhookOptions = {}\n): VerifyWebhookResult {\n if (!secret) return { ok: false, reason: 'no_secret_provided' };\n\n // Header lookup is case-insensitive — support common variants.\n const rawHeader =\n headers['x-astrasync-signature'] ??\n headers['X-Astrasync-Signature'] ??\n headers['X-AstraSync-Signature'] ??\n headers['X-ASTRASYNC-SIGNATURE'];\n if (!rawHeader) return { ok: false, reason: 'missing_signature_header' };\n\n const headerValue = Array.isArray(rawHeader) ? rawHeader[0] : rawHeader;\n const { t: timestamp, v1: receivedSignature } = parseSignatureHeader(headerValue);\n if (!timestamp || !receivedSignature) {\n return { ok: false, reason: 'malformed_signature_header' };\n }\n\n const tolerance = options.toleranceSeconds ?? DEFAULT_TOLERANCE_SECONDS;\n const now = options.nowMs ?? Date.now();\n const tsSeconds = Number(timestamp);\n if (!Number.isFinite(tsSeconds)) {\n return { ok: false, reason: 'invalid_timestamp' };\n }\n const ageSeconds = Math.abs(now / 1000 - tsSeconds);\n if (ageSeconds > tolerance) {\n return { ok: false, reason: 'timestamp_outside_tolerance' };\n }\n\n const expectedSignature = computeHmac(secret, `${timestamp}.${rawBody}`);\n if (!constantTimeEquals(expectedSignature, receivedSignature)) {\n return { ok: false, reason: 'signature_mismatch' };\n }\n\n return { ok: true };\n}\n\n/**\n * Server-side companion: produce an `X-AstraSync-Signature` header value for\n * an outbound webhook delivery. Exposed for completeness and for test\n * harnesses that want to verify the verifier; the AstraSync platform itself\n * uses an internal version of the same logic.\n */\nexport function signAstraSyncWebhook(\n rawBody: string,\n secret: string,\n nowMs: number = Date.now()\n): { header: string; timestamp: number } {\n const timestamp = Math.floor(nowMs / 1000);\n const v1 = computeHmac(secret, `${timestamp}.${rawBody}`);\n return { header: `t=${timestamp},v1=${v1}`, timestamp };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBA,oBAA4C;AAmB5C,IAAM,4BAA4B;AAElC,SAAS,qBAAqB,QAA6C;AACzE,QAAM,QAAqC,CAAC;AAC5C,aAAW,WAAW,OAAO,MAAM,GAAG,GAAG;AACvC,UAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,MAAM,GAAG;AAChC,QAAI,MAAM,OAAO,MAAM,KAAM,OAAM,CAAC,IAAI;AAAA,EAC1C;AACA,SAAO;AACT;AAEA,SAAS,YAAY,QAAgB,eAA+B;AAClE,aAAO,0BAAW,UAAU,MAAM,EAAE,OAAO,eAAe,MAAM,EAAE,OAAO,KAAK;AAChF;AAEA,SAAS,mBAAmB,GAAW,GAAoB;AACzD,QAAM,OAAO,OAAO,KAAK,GAAG,MAAM;AAClC,QAAM,OAAO,OAAO,KAAK,GAAG,MAAM;AAClC,MAAI,KAAK,WAAW,KAAK,OAAQ,QAAO;AACxC,aAAO,+BAAgB,MAAM,IAAI;AACnC;AAYO,SAAS,uBACd,SACA,SACA,QACA,UAAgC,CAAC,GACZ;AACrB,MAAI,CAAC,OAAQ,QAAO,EAAE,IAAI,OAAO,QAAQ,qBAAqB;AAG9D,QAAM,YACJ,QAAQ,uBAAuB,KAC/B,QAAQ,uBAAuB,KAC/B,QAAQ,uBAAuB,KAC/B,QAAQ,uBAAuB;AACjC,MAAI,CAAC,UAAW,QAAO,EAAE,IAAI,OAAO,QAAQ,2BAA2B;AAEvE,QAAM,cAAc,MAAM,QAAQ,SAAS,IAAI,UAAU,CAAC,IAAI;AAC9D,QAAM,EAAE,GAAG,WAAW,IAAI,kBAAkB,IAAI,qBAAqB,WAAW;AAChF,MAAI,CAAC,aAAa,CAAC,mBAAmB;AACpC,WAAO,EAAE,IAAI,OAAO,QAAQ,6BAA6B;AAAA,EAC3D;AAEA,QAAM,YAAY,QAAQ,oBAAoB;AAC9C,QAAM,MAAM,QAAQ,SAAS,KAAK,IAAI;AACtC,QAAM,YAAY,OAAO,SAAS;AAClC,MAAI,CAAC,OAAO,SAAS,SAAS,GAAG;AAC/B,WAAO,EAAE,IAAI,OAAO,QAAQ,oBAAoB;AAAA,EAClD;AACA,QAAM,aAAa,KAAK,IAAI,MAAM,MAAO,SAAS;AAClD,MAAI,aAAa,WAAW;AAC1B,WAAO,EAAE,IAAI,OAAO,QAAQ,8BAA8B;AAAA,EAC5D;AAEA,QAAM,oBAAoB,YAAY,QAAQ,GAAG,SAAS,IAAI,OAAO,EAAE;AACvE,MAAI,CAAC,mBAAmB,mBAAmB,iBAAiB,GAAG;AAC7D,WAAO,EAAE,IAAI,OAAO,QAAQ,qBAAqB;AAAA,EACnD;AAEA,SAAO,EAAE,IAAI,KAAK;AACpB;AAQO,SAAS,qBACd,SACA,QACA,QAAgB,KAAK,IAAI,GACc;AACvC,QAAM,YAAY,KAAK,MAAM,QAAQ,GAAI;AACzC,QAAM,KAAK,YAAY,QAAQ,GAAG,SAAS,IAAI,OAAO,EAAE;AACxD,SAAO,EAAE,QAAQ,KAAK,SAAS,OAAO,EAAE,IAAI,UAAU;AACxD;","names":[]}