@contractkit/plugin-typescript 0.25.4 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractkit/plugin-typescript",
3
- "version": "0.25.4",
3
+ "version": "0.26.0",
4
4
  "description": "ContractKit built-in plugin: TypeScript codegen (SDK clients, Koa routers, Zod schemas, plain types)",
5
5
  "author": {
6
6
  "name": "Marooned Software",
@@ -26,11 +26,11 @@
26
26
  ".": "./dist/index.js"
27
27
  },
28
28
  "dependencies": {
29
- "@contractkit/core": "0.20.0"
29
+ "@contractkit/core": "0.21.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@repo/config-eslint": "0.3.1",
33
- "@repo/config-typescript": "0.1.0"
32
+ "@repo/config-typescript": "0.1.0",
33
+ "@repo/config-eslint": "0.3.1"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration",
@@ -260,7 +260,10 @@ function generateHandler(route: OpRouteNode, op: OpOperationNode, root: OpRootNo
260
260
  middlewares.push(`bodyParserMiddleware([${tokensExpr}])`);
261
261
  }
262
262
  if (op.signature) {
263
- middlewares.push(`requireSignature('${op.signature}')`);
263
+ const sigArgs = op.signaturePolicy
264
+ ? `'${op.signature}', { policy: '${op.signaturePolicy}' }`
265
+ : `'${op.signature}'`;
266
+ middlewares.push(`requireSignature(${sigArgs})`);
264
267
  }
265
268
  const middlewareStr = middlewares.length > 0 ? `, ${middlewares.join(', ')},` : ',';
266
269
 
@@ -851,6 +851,17 @@ describe('generateOp — route modifiers JSDoc', () => {
851
851
  expect(out).toContain(`requireSignature('MODERN_TREASURY_WEBHOOK')`);
852
852
  });
853
853
 
854
+ it('passes the signature policy to requireSignature when set', () => {
855
+ const op = opOperation('post', {
856
+ signature: 'SLACK_WEBHOOK',
857
+ signaturePolicy: 'slackSignatureValid',
858
+ request: opRequest('Payload'),
859
+ });
860
+ const root = opRoot([opRoute('/webhooks', [op])]);
861
+ const out = generateOp(root);
862
+ expect(out).toContain(`requireSignature('SLACK_WEBHOOK', { policy: 'slackSignatureValid' })`);
863
+ });
864
+
854
865
  it('places requireSignature after bodyParserMiddleware in the route line', () => {
855
866
  const op = opOperation('post', {
856
867
  signature: 'MY_KEY',