@agent-score/commerce 2.4.0 → 2.5.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 (59) hide show
  1. package/dist/challenge/index.d.mts +5 -1
  2. package/dist/challenge/index.d.ts +5 -1
  3. package/dist/challenge/index.js +11 -4
  4. package/dist/challenge/index.js.map +1 -1
  5. package/dist/challenge/index.mjs +11 -4
  6. package/dist/challenge/index.mjs.map +1 -1
  7. package/dist/{checkout-B-MIzYzW.d.ts → checkout-McfNpZJf.d.ts} +72 -1
  8. package/dist/{checkout-Bn7ZKIBD.d.mts → checkout-o17dIxHi.d.mts} +72 -1
  9. package/dist/core.d.mts +23 -1
  10. package/dist/core.d.ts +23 -1
  11. package/dist/core.js +25 -11
  12. package/dist/core.js.map +1 -1
  13. package/dist/core.mjs +25 -11
  14. package/dist/core.mjs.map +1 -1
  15. package/dist/discovery/index.d.mts +17 -2
  16. package/dist/discovery/index.d.ts +17 -2
  17. package/dist/discovery/index.js +14 -4
  18. package/dist/discovery/index.js.map +1 -1
  19. package/dist/discovery/index.mjs +14 -4
  20. package/dist/discovery/index.mjs.map +1 -1
  21. package/dist/gate-CWP10xPQ.d.mts +339 -0
  22. package/dist/gate-CWP10xPQ.d.ts +339 -0
  23. package/dist/identity/express.d.mts +26 -1
  24. package/dist/identity/express.d.ts +26 -1
  25. package/dist/identity/express.js +587 -13
  26. package/dist/identity/express.js.map +1 -1
  27. package/dist/identity/express.mjs +583 -12
  28. package/dist/identity/express.mjs.map +1 -1
  29. package/dist/identity/fastify.d.mts +12 -2
  30. package/dist/identity/fastify.d.ts +12 -2
  31. package/dist/identity/fastify.js +595 -13
  32. package/dist/identity/fastify.js.map +1 -1
  33. package/dist/identity/fastify.mjs +591 -12
  34. package/dist/identity/fastify.mjs.map +1 -1
  35. package/dist/identity/hono.d.mts +26 -1
  36. package/dist/identity/hono.d.ts +26 -1
  37. package/dist/identity/hono.js +576 -13
  38. package/dist/identity/hono.js.map +1 -1
  39. package/dist/identity/hono.mjs +572 -12
  40. package/dist/identity/hono.mjs.map +1 -1
  41. package/dist/identity/nextjs.d.mts +3 -0
  42. package/dist/identity/nextjs.d.ts +3 -0
  43. package/dist/identity/nextjs.js +581 -13
  44. package/dist/identity/nextjs.js.map +1 -1
  45. package/dist/identity/nextjs.mjs +577 -12
  46. package/dist/identity/nextjs.mjs.map +1 -1
  47. package/dist/identity/web.d.mts +24 -1
  48. package/dist/identity/web.d.ts +24 -1
  49. package/dist/identity/web.js +581 -13
  50. package/dist/identity/web.js.map +1 -1
  51. package/dist/identity/web.mjs +577 -12
  52. package/dist/identity/web.mjs.map +1 -1
  53. package/dist/index.d.mts +119 -3
  54. package/dist/index.d.ts +119 -3
  55. package/dist/index.js +893 -35
  56. package/dist/index.js.map +1 -1
  57. package/dist/index.mjs +873 -35
  58. package/dist/index.mjs.map +1 -1
  59. package/package.json +11 -11
@@ -1,5 +1,7 @@
1
+ import { b as AipGateOptions, r as buildAipErrorBody, V as VerifiedAit } from '../gate-CWP10xPQ.mjs';
1
2
  import { AgentScoreCoreOptions, AgentIdentity, DenialReason, CreateSessionOnMissing, AssessResult, FailOpenInfraReason, GateQuotaInfo, SignerVerdict } from '../core.mjs';
2
3
  import { Request, Response, NextFunction } from 'express';
4
+ import 'jose';
3
5
  import '../signer-3FAit11j.mjs';
4
6
 
5
7
  interface AgentScoreGateOptions extends Omit<AgentScoreCoreOptions, 'createSessionOnMissing'> {
@@ -60,5 +62,28 @@ declare function getSignerVerdict(req: Request): SignerVerdict | undefined;
60
62
  * unauthenticated and the handler emits a 402 with all rails; settle legs
61
63
  * trigger the full gate. */
62
64
  declare function conditionalAgentscoreGate(options: AgentScoreGateOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
65
+ interface AipGateExpressOptions extends AipGateOptions {
66
+ /** Custom denial responder. Defaults to a 401/403 `application/problem+json` body. */
67
+ onDenied?: (req: Request, res: Response, body: ReturnType<typeof buildAipErrorBody>) => void;
68
+ }
69
+ /**
70
+ * Express middleware that requires a valid AIT on every request it guards.
71
+ *
72
+ * ```ts
73
+ * import { JwksCache } from '@agent-score/commerce';
74
+ * import { aipGate, getVerifiedAit } from '@agent-score/commerce/identity/express';
75
+ *
76
+ * const jwks = new JwksCache({ trustedIssuers: ['https://issuer.example'] }); // AgentScore always trusted
77
+ * app.post('/checkout', aipGate({ jwks }), (req, res) => {
78
+ * const ait = getVerifiedAit(req)!;
79
+ * res.json({ buyer: ait.payload.identity?.email });
80
+ * });
81
+ * ```
82
+ */
83
+ declare function aipGate(options: AipGateExpressOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
84
+ /** Wrap {@link aipGate} so it only runs when an `Agent-Identity` header is present. */
85
+ declare function conditionalAipGate(options: AipGateExpressOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
86
+ /** Read the verified AIT attached to an Express request by {@link aipGate}. */
87
+ declare function getVerifiedAit(req: Request): VerifiedAit | undefined;
63
88
 
64
- export { agentscoreGate, captureWallet, conditionalAgentscoreGate, getAgentScoreData, getGateDegradedState, getGateQuotaInfo, getSignerVerdict };
89
+ export { type AipGateExpressOptions, agentscoreGate, aipGate, captureWallet, conditionalAgentscoreGate, conditionalAipGate, getAgentScoreData, getGateDegradedState, getGateQuotaInfo, getSignerVerdict, getVerifiedAit };
@@ -1,5 +1,7 @@
1
+ import { b as AipGateOptions, r as buildAipErrorBody, V as VerifiedAit } from '../gate-CWP10xPQ.js';
1
2
  import { AgentScoreCoreOptions, AgentIdentity, DenialReason, CreateSessionOnMissing, AssessResult, FailOpenInfraReason, GateQuotaInfo, SignerVerdict } from '../core.js';
2
3
  import { Request, Response, NextFunction } from 'express';
4
+ import 'jose';
3
5
  import '../signer-3FAit11j.js';
4
6
 
5
7
  interface AgentScoreGateOptions extends Omit<AgentScoreCoreOptions, 'createSessionOnMissing'> {
@@ -60,5 +62,28 @@ declare function getSignerVerdict(req: Request): SignerVerdict | undefined;
60
62
  * unauthenticated and the handler emits a 402 with all rails; settle legs
61
63
  * trigger the full gate. */
62
64
  declare function conditionalAgentscoreGate(options: AgentScoreGateOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
65
+ interface AipGateExpressOptions extends AipGateOptions {
66
+ /** Custom denial responder. Defaults to a 401/403 `application/problem+json` body. */
67
+ onDenied?: (req: Request, res: Response, body: ReturnType<typeof buildAipErrorBody>) => void;
68
+ }
69
+ /**
70
+ * Express middleware that requires a valid AIT on every request it guards.
71
+ *
72
+ * ```ts
73
+ * import { JwksCache } from '@agent-score/commerce';
74
+ * import { aipGate, getVerifiedAit } from '@agent-score/commerce/identity/express';
75
+ *
76
+ * const jwks = new JwksCache({ trustedIssuers: ['https://issuer.example'] }); // AgentScore always trusted
77
+ * app.post('/checkout', aipGate({ jwks }), (req, res) => {
78
+ * const ait = getVerifiedAit(req)!;
79
+ * res.json({ buyer: ait.payload.identity?.email });
80
+ * });
81
+ * ```
82
+ */
83
+ declare function aipGate(options: AipGateExpressOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
84
+ /** Wrap {@link aipGate} so it only runs when an `Agent-Identity` header is present. */
85
+ declare function conditionalAipGate(options: AipGateExpressOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
86
+ /** Read the verified AIT attached to an Express request by {@link aipGate}. */
87
+ declare function getVerifiedAit(req: Request): VerifiedAit | undefined;
63
88
 
64
- export { agentscoreGate, captureWallet, conditionalAgentscoreGate, getAgentScoreData, getGateDegradedState, getGateQuotaInfo, getSignerVerdict };
89
+ export { type AipGateExpressOptions, agentscoreGate, aipGate, captureWallet, conditionalAgentscoreGate, conditionalAipGate, getAgentScoreData, getGateDegradedState, getGateQuotaInfo, getSignerVerdict, getVerifiedAit };