@tsed/stripe 6.107.5 → 6.110.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.
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebhookEvent = void 0;
4
- const common_1 = require("@tsed/common");
4
+ const platform_middlewares_1 = require("@tsed/platform-middlewares");
5
+ const platform_params_1 = require("@tsed/platform-params");
5
6
  const core_1 = require("@tsed/core");
6
7
  const schema_1 = require("@tsed/schema");
7
8
  const constants_1 = require("../constants/constants");
@@ -14,7 +15,7 @@ const WebhookEventMiddleware_1 = require("../middlewares/WebhookEventMiddleware"
14
15
  * @input
15
16
  */
16
17
  function WebhookEvent(options) {
17
- return (0, core_1.useDecorators)((0, core_1.useMethodDecorators)((0, schema_1.In)("body").Type(Object).Required().Description("The raw webhook payload"), (0, schema_1.In)("header").Name("stripe-signature").Type(String).Required().Description("The stripe webhook signature"), (0, core_1.StoreSet)(WebhookEventMiddleware_1.WebhookEventMiddleware, options), (0, common_1.UseBefore)(WebhookEventMiddleware_1.WebhookEventMiddleware)), (0, common_1.Context)(constants_1.STRIPE_WEBHOOK_EVENT));
18
+ return (0, core_1.useDecorators)((0, core_1.useMethodDecorators)((0, schema_1.In)("body").Type(Object).Required().Description("The raw webhook payload"), (0, schema_1.In)("header").Name("stripe-signature").Type(String).Required().Description("The stripe webhook signature"), (0, core_1.StoreSet)(WebhookEventMiddleware_1.WebhookEventMiddleware, options), (0, platform_middlewares_1.UseBefore)(WebhookEventMiddleware_1.WebhookEventMiddleware)), (0, platform_params_1.Context)(constants_1.STRIPE_WEBHOOK_EVENT));
18
19
  }
19
20
  exports.WebhookEvent = WebhookEvent;
20
21
  //# sourceMappingURL=webhookEvent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhookEvent.js","sourceRoot":"","sources":["../../../src/decorators/webhookEvent.ts"],"names":[],"mappings":";;;AAAA,yCAAgD;AAChD,qCAAwE;AACxE,yCAAgC;AAChC,sDAA4D;AAC5D,kFAAkG;AAElG;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,OAAsC;IACjE,OAAO,IAAA,oBAAa,EAClB,IAAA,0BAAmB,EACjB,IAAA,WAAE,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,yBAAyB,CAAC,EACzE,IAAA,WAAE,EAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,8BAA8B,CAAC,EACzG,IAAA,eAAQ,EAAC,+CAAsB,EAAE,OAAO,CAAC,EACzC,IAAA,kBAAS,EAAC,+CAAsB,CAAC,CAClC,EACD,IAAA,gBAAO,EAAC,gCAAoB,CAAC,CAC9B,CAAC;AACJ,CAAC;AAVD,oCAUC","sourcesContent":["import {Context, UseBefore} from \"@tsed/common\";\nimport {StoreSet, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {In} from \"@tsed/schema\";\nimport {STRIPE_WEBHOOK_EVENT} from \"../constants/constants\";\nimport {WebhookEventMiddleware, WebhookEventOptions} from \"../middlewares/WebhookEventMiddleware\";\n\n/**\n * Get the stripe webhook event.\n *\n * @decorator\n * @operation\n * @input\n */\nexport function WebhookEvent(options?: Partial<WebhookEventOptions>) {\n return useDecorators(\n useMethodDecorators(\n In(\"body\").Type(Object).Required().Description(\"The raw webhook payload\"),\n In(\"header\").Name(\"stripe-signature\").Type(String).Required().Description(\"The stripe webhook signature\"),\n StoreSet(WebhookEventMiddleware, options),\n UseBefore(WebhookEventMiddleware)\n ),\n Context(STRIPE_WEBHOOK_EVENT)\n );\n}\n"]}
1
+ {"version":3,"file":"webhookEvent.js","sourceRoot":"","sources":["../../../src/decorators/webhookEvent.ts"],"names":[],"mappings":";;;AAAA,qEAAqD;AACrD,2DAA8C;AAC9C,qCAAwE;AACxE,yCAAgC;AAChC,sDAA4D;AAC5D,kFAAkG;AAElG;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,OAAsC;IACjE,OAAO,IAAA,oBAAa,EAClB,IAAA,0BAAmB,EACjB,IAAA,WAAE,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,yBAAyB,CAAC,EACzE,IAAA,WAAE,EAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,8BAA8B,CAAC,EACzG,IAAA,eAAQ,EAAC,+CAAsB,EAAE,OAAO,CAAC,EACzC,IAAA,gCAAS,EAAC,+CAAsB,CAAC,CAClC,EACD,IAAA,yBAAO,EAAC,gCAAoB,CAAC,CAC9B,CAAC;AACJ,CAAC;AAVD,oCAUC","sourcesContent":["import {UseBefore} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {StoreSet, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {In} from \"@tsed/schema\";\nimport {STRIPE_WEBHOOK_EVENT} from \"../constants/constants\";\nimport {WebhookEventMiddleware, WebhookEventOptions} from \"../middlewares/WebhookEventMiddleware\";\n\n/**\n * Get the stripe webhook event.\n *\n * @decorator\n * @operation\n * @input\n */\nexport function WebhookEvent(options?: Partial<WebhookEventOptions>) {\n return useDecorators(\n useMethodDecorators(\n In(\"body\").Type(Object).Required().Description(\"The raw webhook payload\"),\n In(\"header\").Name(\"stripe-signature\").Type(String).Required().Description(\"The stripe webhook signature\"),\n StoreSet(WebhookEventMiddleware, options),\n UseBefore(WebhookEventMiddleware)\n ),\n Context(STRIPE_WEBHOOK_EVENT)\n );\n}\n"]}
package/lib/cjs/index.js CHANGED
@@ -4,9 +4,9 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tslib_1 = require("tslib");
7
- (0, tslib_1.__exportStar)(require("./constants/constants"), exports);
8
- (0, tslib_1.__exportStar)(require("./decorators/webhookEvent"), exports);
9
- (0, tslib_1.__exportStar)(require("./domain/StripSettings"), exports);
10
- (0, tslib_1.__exportStar)(require("./middlewares/WebhookEventMiddleware"), exports);
11
- (0, tslib_1.__exportStar)(require("./services/StripeFactory"), exports);
7
+ tslib_1.__exportStar(require("./constants/constants"), exports);
8
+ tslib_1.__exportStar(require("./decorators/webhookEvent"), exports);
9
+ tslib_1.__exportStar(require("./domain/StripSettings"), exports);
10
+ tslib_1.__exportStar(require("./middlewares/WebhookEventMiddleware"), exports);
11
+ tslib_1.__exportStar(require("./services/StripeFactory"), exports);
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qEAAsC;AACtC,yEAA0C;AAC1C,sEAAuC;AACvC,oFAAqD;AACrD,wEAAyC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/webhookEvent\";\nexport * from \"./domain/StripSettings\";\nexport * from \"./middlewares/WebhookEventMiddleware\";\nexport * from \"./services/StripeFactory\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,gEAAsC;AACtC,oEAA0C;AAC1C,iEAAuC;AACvC,+EAAqD;AACrD,mEAAyC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/webhookEvent\";\nexport * from \"./domain/StripSettings\";\nexport * from \"./middlewares/WebhookEventMiddleware\";\nexport * from \"./services/StripeFactory\";\n"]}
@@ -3,7 +3,9 @@ var WebhookEventMiddleware_1;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.WebhookEventMiddleware = void 0;
5
5
  const tslib_1 = require("tslib");
6
- const common_1 = require("@tsed/common");
6
+ const platform_params_1 = require("@tsed/platform-params");
7
+ const platform_middlewares_1 = require("@tsed/platform-middlewares");
8
+ const di_1 = require("@tsed/di");
7
9
  const exceptions_1 = require("@tsed/exceptions");
8
10
  const stripe_1 = require("stripe");
9
11
  const constants_1 = require("../constants/constants");
@@ -26,24 +28,24 @@ let WebhookEventMiddleware = WebhookEventMiddleware_1 = class WebhookEventMiddle
26
28
  }
27
29
  }
28
30
  };
29
- (0, tslib_1.__decorate)([
30
- (0, common_1.Inject)(),
31
- (0, tslib_1.__metadata)("design:type", stripe_1.Stripe)
31
+ tslib_1.__decorate([
32
+ (0, di_1.Inject)(),
33
+ tslib_1.__metadata("design:type", stripe_1.Stripe)
32
34
  ], WebhookEventMiddleware.prototype, "stripe", void 0);
33
- (0, tslib_1.__decorate)([
34
- (0, common_1.Constant)("stripe.webhooks"),
35
- (0, tslib_1.__metadata)("design:type", Object)
35
+ tslib_1.__decorate([
36
+ (0, di_1.Constant)("stripe.webhooks"),
37
+ tslib_1.__metadata("design:type", Object)
36
38
  ], WebhookEventMiddleware.prototype, "webhooks", void 0);
37
- (0, tslib_1.__decorate)([
38
- (0, tslib_1.__param)(0, (0, common_1.HeaderParams)("stripe-signature")),
39
- (0, tslib_1.__param)(1, (0, common_1.RawBodyParams)()),
40
- (0, tslib_1.__param)(2, (0, common_1.Context)()),
41
- (0, tslib_1.__metadata)("design:type", Function),
42
- (0, tslib_1.__metadata)("design:paramtypes", [String, Buffer, Object]),
43
- (0, tslib_1.__metadata)("design:returntype", Object)
39
+ tslib_1.__decorate([
40
+ tslib_1.__param(0, (0, platform_params_1.HeaderParams)("stripe-signature")),
41
+ tslib_1.__param(1, (0, platform_params_1.RawBodyParams)()),
42
+ tslib_1.__param(2, (0, platform_params_1.Context)()),
43
+ tslib_1.__metadata("design:type", Function),
44
+ tslib_1.__metadata("design:paramtypes", [String, Buffer, Object]),
45
+ tslib_1.__metadata("design:returntype", Object)
44
46
  ], WebhookEventMiddleware.prototype, "use", null);
45
- WebhookEventMiddleware = WebhookEventMiddleware_1 = (0, tslib_1.__decorate)([
46
- (0, common_1.Middleware)()
47
+ WebhookEventMiddleware = WebhookEventMiddleware_1 = tslib_1.__decorate([
48
+ (0, platform_middlewares_1.Middleware)()
47
49
  ], WebhookEventMiddleware);
48
50
  exports.WebhookEventMiddleware = WebhookEventMiddleware;
49
51
  //# sourceMappingURL=WebhookEventMiddleware.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebhookEventMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/WebhookEventMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmH;AACnH,iDAAiE;AACjE,mCAA8B;AAC9B,sDAAsF;AACtF,qCAAmC;AAQnC,IAAa,sBAAsB,8BAAnC,MAAa,sBAAsB;IAOjC,GAAG,CAAmC,SAAiB,EAAmB,IAAY,EAAa,GAAY;QAC7G,MAAM,EAAC,MAAM,EAAE,SAAS,EAAC,GAAwB;YAC/C,GAAG,IAAI,CAAC,QAAQ;YAChB,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAsB,CAAC;SAClD,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,gCAAmB,CAC3B,qHAAqH,CACtH,CAAC;SACH;QAED,IAAI;YACF,GAAG,CAAC,GAAG,CAAC,oCAAwB,EAAE,SAAS,CAAC,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,gCAAoB,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;SACxG;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,uBAAU,CAAC,yBAAyB,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;SACnE;IACH,CAAC;CACF,CAAA;AAxBC;IADC,IAAA,eAAM,GAAE;2CACS,eAAM;sDAAC;AAGzB;IADC,IAAA,iBAAQ,EAAC,iBAAiB,CAAC;;wDACY;AAExC;IAAK,wBAAA,IAAA,qBAAY,EAAC,kBAAkB,CAAC,CAAA;IAAqB,wBAAA,IAAA,sBAAa,GAAE,CAAA;IAAgB,wBAAA,IAAA,gBAAO,GAAE,CAAA;;0DAAlB,MAAM;;iDAkBrF;AAzBU,sBAAsB;IADlC,IAAA,mBAAU,GAAE;GACA,sBAAsB,CA0BlC;AA1BY,wDAAsB","sourcesContent":["import {Constant, Context, HeaderParams, Inject, Middleware, MiddlewareMethods, RawBodyParams} from \"@tsed/common\";\nimport {BadRequest, InternalServerError} from \"@tsed/exceptions\";\nimport {Stripe} from \"stripe\";\nimport {STRIPE_WEBHOOK_EVENT, STRIPE_WEBHOOK_SIGNATURE} from \"../constants/constants\";\nimport \"../services/StripeFactory\";\n\nexport interface WebhookEventOptions {\n secret: string;\n tolerance: number;\n}\n\n@Middleware()\nexport class WebhookEventMiddleware implements MiddlewareMethods {\n @Inject()\n protected stripe: Stripe;\n\n @Constant(\"stripe.webhooks\")\n protected webhooks: WebhookEventOptions;\n\n use(@HeaderParams(\"stripe-signature\") signature: string, @RawBodyParams() body: Buffer, @Context() ctx: Context): any {\n const {secret, tolerance}: WebhookEventOptions = {\n ...this.webhooks,\n ...ctx.endpoint.store.get(WebhookEventMiddleware)\n };\n\n if (!secret) {\n throw new InternalServerError(\n \"Missing Stripe webhooks secret key. You can get this in your dashboard. See: https://dashboard.stripe.com/webhooks.\"\n );\n }\n\n try {\n ctx.set(STRIPE_WEBHOOK_SIGNATURE, signature);\n ctx.set(STRIPE_WEBHOOK_EVENT, this.stripe.webhooks.constructEvent(body, signature, secret, tolerance));\n } catch (err) {\n throw new BadRequest(`Stripe webhook error: ${err.message}`, err);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"WebhookEventMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/WebhookEventMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,2DAA2E;AAC3E,qEAAyE;AACzE,iCAA0C;AAC1C,iDAAiE;AACjE,mCAA8B;AAC9B,sDAAsF;AACtF,qCAAmC;AAQnC,IAAa,sBAAsB,8BAAnC,MAAa,sBAAsB;IAOjC,GAAG,CAAmC,SAAiB,EAAmB,IAAY,EAAa,GAAY;QAC7G,MAAM,EAAC,MAAM,EAAE,SAAS,EAAC,GAAwB;YAC/C,GAAG,IAAI,CAAC,QAAQ;YAChB,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAsB,CAAC;SAClD,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,gCAAmB,CAC3B,qHAAqH,CACtH,CAAC;SACH;QAED,IAAI;YACF,GAAG,CAAC,GAAG,CAAC,oCAAwB,EAAE,SAAS,CAAC,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,gCAAoB,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;SACxG;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,uBAAU,CAAC,yBAAyB,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;SACnE;IACH,CAAC;CACF,CAAA;AAxBC;IADC,IAAA,WAAM,GAAE;sCACS,eAAM;sDAAC;AAGzB;IADC,IAAA,aAAQ,EAAC,iBAAiB,CAAC;;wDACY;AAExC;IAAK,mBAAA,IAAA,8BAAY,EAAC,kBAAkB,CAAC,CAAA;IAAqB,mBAAA,IAAA,+BAAa,GAAE,CAAA;IAAgB,mBAAA,IAAA,yBAAO,GAAE,CAAA;;qDAAlB,MAAM;;iDAkBrF;AAzBU,sBAAsB;IADlC,IAAA,iCAAU,GAAE;GACA,sBAAsB,CA0BlC;AA1BY,wDAAsB","sourcesContent":["import {Context, HeaderParams, RawBodyParams} from \"@tsed/platform-params\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Constant, Inject} from \"@tsed/di\";\nimport {BadRequest, InternalServerError} from \"@tsed/exceptions\";\nimport {Stripe} from \"stripe\";\nimport {STRIPE_WEBHOOK_EVENT, STRIPE_WEBHOOK_SIGNATURE} from \"../constants/constants\";\nimport \"../services/StripeFactory\";\n\nexport interface WebhookEventOptions {\n secret: string;\n tolerance: number;\n}\n\n@Middleware()\nexport class WebhookEventMiddleware implements MiddlewareMethods {\n @Inject()\n protected stripe: Stripe;\n\n @Constant(\"stripe.webhooks\")\n protected webhooks: WebhookEventOptions;\n\n use(@HeaderParams(\"stripe-signature\") signature: string, @RawBodyParams() body: Buffer, @Context() ctx: Context): any {\n const {secret, tolerance}: WebhookEventOptions = {\n ...this.webhooks,\n ...ctx.endpoint.store.get(WebhookEventMiddleware)\n };\n\n if (!secret) {\n throw new InternalServerError(\n \"Missing Stripe webhooks secret key. You can get this in your dashboard. See: https://dashboard.stripe.com/webhooks.\"\n );\n }\n\n try {\n ctx.set(STRIPE_WEBHOOK_SIGNATURE, signature);\n ctx.set(STRIPE_WEBHOOK_EVENT, this.stripe.webhooks.constructEvent(body, signature, secret, tolerance));\n } catch (err) {\n throw new BadRequest(`Stripe webhook error: ${err.message}`, err);\n }\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { Context, UseBefore } from "@tsed/common";
1
+ import { UseBefore } from "@tsed/platform-middlewares";
2
+ import { Context } from "@tsed/platform-params";
2
3
  import { StoreSet, useDecorators, useMethodDecorators } from "@tsed/core";
3
4
  import { In } from "@tsed/schema";
4
5
  import { STRIPE_WEBHOOK_EVENT } from "../constants/constants.js";
@@ -1 +1 @@
1
- {"version":3,"file":"webhookEvent.js","sourceRoot":"","sources":["../../../src/decorators/webhookEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAChD,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAAM,YAAY,CAAC;AACxE,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAC;AAChC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,sBAAsB,EAAsB,MAAM,uCAAuC,CAAC;AAElG;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAsC;IACjE,OAAO,aAAa,CAClB,mBAAmB,CACjB,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,yBAAyB,CAAC,EACzE,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,8BAA8B,CAAC,EACzG,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC,EACzC,SAAS,CAAC,sBAAsB,CAAC,CAClC,EACD,OAAO,CAAC,oBAAoB,CAAC,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import {Context, UseBefore} from \"@tsed/common\";\nimport {StoreSet, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {In} from \"@tsed/schema\";\nimport {STRIPE_WEBHOOK_EVENT} from \"../constants/constants\";\nimport {WebhookEventMiddleware, WebhookEventOptions} from \"../middlewares/WebhookEventMiddleware\";\n\n/**\n * Get the stripe webhook event.\n *\n * @decorator\n * @operation\n * @input\n */\nexport function WebhookEvent(options?: Partial<WebhookEventOptions>) {\n return useDecorators(\n useMethodDecorators(\n In(\"body\").Type(Object).Required().Description(\"The raw webhook payload\"),\n In(\"header\").Name(\"stripe-signature\").Type(String).Required().Description(\"The stripe webhook signature\"),\n StoreSet(WebhookEventMiddleware, options),\n UseBefore(WebhookEventMiddleware)\n ),\n Context(STRIPE_WEBHOOK_EVENT)\n );\n}\n"]}
1
+ {"version":3,"file":"webhookEvent.js","sourceRoot":"","sources":["../../../src/decorators/webhookEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAAM,YAAY,CAAC;AACxE,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAC;AAChC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,sBAAsB,EAAsB,MAAM,uCAAuC,CAAC;AAElG;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAsC;IACjE,OAAO,aAAa,CAClB,mBAAmB,CACjB,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,yBAAyB,CAAC,EACzE,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,8BAA8B,CAAC,EACzG,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC,EACzC,SAAS,CAAC,sBAAsB,CAAC,CAClC,EACD,OAAO,CAAC,oBAAoB,CAAC,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import {UseBefore} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {StoreSet, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {In} from \"@tsed/schema\";\nimport {STRIPE_WEBHOOK_EVENT} from \"../constants/constants\";\nimport {WebhookEventMiddleware, WebhookEventOptions} from \"../middlewares/WebhookEventMiddleware\";\n\n/**\n * Get the stripe webhook event.\n *\n * @decorator\n * @operation\n * @input\n */\nexport function WebhookEvent(options?: Partial<WebhookEventOptions>) {\n return useDecorators(\n useMethodDecorators(\n In(\"body\").Type(Object).Required().Description(\"The raw webhook payload\"),\n In(\"header\").Name(\"stripe-signature\").Type(String).Required().Description(\"The stripe webhook signature\"),\n StoreSet(WebhookEventMiddleware, options),\n UseBefore(WebhookEventMiddleware)\n ),\n Context(STRIPE_WEBHOOK_EVENT)\n );\n}\n"]}
@@ -1,6 +1,8 @@
1
1
  var WebhookEventMiddleware_1;
2
2
  import { __decorate, __metadata, __param } from "tslib";
3
- import { Constant, Context, HeaderParams, Inject, Middleware, RawBodyParams } from "@tsed/common";
3
+ import { Context, HeaderParams, RawBodyParams } from "@tsed/platform-params";
4
+ import { Middleware } from "@tsed/platform-middlewares";
5
+ import { Constant, Inject } from "@tsed/di";
4
6
  import { BadRequest, InternalServerError } from "@tsed/exceptions";
5
7
  import { Stripe } from "stripe";
6
8
  import { STRIPE_WEBHOOK_EVENT, STRIPE_WEBHOOK_SIGNATURE } from "../constants/constants.js";
@@ -1 +1 @@
1
- {"version":3,"file":"WebhookEventMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/WebhookEventMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAqB,aAAa,EAAC,MAAM,cAAc,CAAC;AACnH,OAAO,EAAC,UAAU,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAC,oBAAoB,EAAE,wBAAwB,EAAC,MAAM,wBAAwB,CAAC;AACtF,OAAO,2BAA2B,CAAC;AAQnC,IAAa,sBAAsB,8BAAnC,MAAa,sBAAsB;IAOjC,GAAG,CAAmC,SAAiB,EAAmB,IAAY,EAAa,GAAY;QAC7G,MAAM,EAAC,MAAM,EAAE,SAAS,EAAC,GAAwB;YAC/C,GAAG,IAAI,CAAC,QAAQ;YAChB,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAsB,CAAC;SAClD,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,mBAAmB,CAC3B,qHAAqH,CACtH,CAAC;SACH;QAED,IAAI;YACF,GAAG,CAAC,GAAG,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;SACxG;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,UAAU,CAAC,yBAAyB,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;SACnE;IACH,CAAC;CACF,CAAA;AAxBC;IADC,MAAM,EAAE;8BACS,MAAM;sDAAC;AAGzB;IADC,QAAQ,CAAC,iBAAiB,CAAC;;wDACY;AAExC;IAAK,WAAA,YAAY,CAAC,kBAAkB,CAAC,CAAA;IAAqB,WAAA,aAAa,EAAE,CAAA;IAAgB,WAAA,OAAO,EAAE,CAAA;;6CAAlB,MAAM;;iDAkBrF;AAzBU,sBAAsB;IADlC,UAAU,EAAE;GACA,sBAAsB,CA0BlC;SA1BY,sBAAsB","sourcesContent":["import {Constant, Context, HeaderParams, Inject, Middleware, MiddlewareMethods, RawBodyParams} from \"@tsed/common\";\nimport {BadRequest, InternalServerError} from \"@tsed/exceptions\";\nimport {Stripe} from \"stripe\";\nimport {STRIPE_WEBHOOK_EVENT, STRIPE_WEBHOOK_SIGNATURE} from \"../constants/constants\";\nimport \"../services/StripeFactory\";\n\nexport interface WebhookEventOptions {\n secret: string;\n tolerance: number;\n}\n\n@Middleware()\nexport class WebhookEventMiddleware implements MiddlewareMethods {\n @Inject()\n protected stripe: Stripe;\n\n @Constant(\"stripe.webhooks\")\n protected webhooks: WebhookEventOptions;\n\n use(@HeaderParams(\"stripe-signature\") signature: string, @RawBodyParams() body: Buffer, @Context() ctx: Context): any {\n const {secret, tolerance}: WebhookEventOptions = {\n ...this.webhooks,\n ...ctx.endpoint.store.get(WebhookEventMiddleware)\n };\n\n if (!secret) {\n throw new InternalServerError(\n \"Missing Stripe webhooks secret key. You can get this in your dashboard. See: https://dashboard.stripe.com/webhooks.\"\n );\n }\n\n try {\n ctx.set(STRIPE_WEBHOOK_SIGNATURE, signature);\n ctx.set(STRIPE_WEBHOOK_EVENT, this.stripe.webhooks.constructEvent(body, signature, secret, tolerance));\n } catch (err) {\n throw new BadRequest(`Stripe webhook error: ${err.message}`, err);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"WebhookEventMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/WebhookEventMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAC,oBAAoB,EAAE,wBAAwB,EAAC,MAAM,wBAAwB,CAAC;AACtF,OAAO,2BAA2B,CAAC;AAQnC,IAAa,sBAAsB,8BAAnC,MAAa,sBAAsB;IAOjC,GAAG,CAAmC,SAAiB,EAAmB,IAAY,EAAa,GAAY;QAC7G,MAAM,EAAC,MAAM,EAAE,SAAS,EAAC,GAAwB;YAC/C,GAAG,IAAI,CAAC,QAAQ;YAChB,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAsB,CAAC;SAClD,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,mBAAmB,CAC3B,qHAAqH,CACtH,CAAC;SACH;QAED,IAAI;YACF,GAAG,CAAC,GAAG,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;SACxG;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,UAAU,CAAC,yBAAyB,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;SACnE;IACH,CAAC;CACF,CAAA;AAxBC;IADC,MAAM,EAAE;8BACS,MAAM;sDAAC;AAGzB;IADC,QAAQ,CAAC,iBAAiB,CAAC;;wDACY;AAExC;IAAK,WAAA,YAAY,CAAC,kBAAkB,CAAC,CAAA;IAAqB,WAAA,aAAa,EAAE,CAAA;IAAgB,WAAA,OAAO,EAAE,CAAA;;6CAAlB,MAAM;;iDAkBrF;AAzBU,sBAAsB;IADlC,UAAU,EAAE;GACA,sBAAsB,CA0BlC;SA1BY,sBAAsB","sourcesContent":["import {Context, HeaderParams, RawBodyParams} from \"@tsed/platform-params\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Constant, Inject} from \"@tsed/di\";\nimport {BadRequest, InternalServerError} from \"@tsed/exceptions\";\nimport {Stripe} from \"stripe\";\nimport {STRIPE_WEBHOOK_EVENT, STRIPE_WEBHOOK_SIGNATURE} from \"../constants/constants\";\nimport \"../services/StripeFactory\";\n\nexport interface WebhookEventOptions {\n secret: string;\n tolerance: number;\n}\n\n@Middleware()\nexport class WebhookEventMiddleware implements MiddlewareMethods {\n @Inject()\n protected stripe: Stripe;\n\n @Constant(\"stripe.webhooks\")\n protected webhooks: WebhookEventOptions;\n\n use(@HeaderParams(\"stripe-signature\") signature: string, @RawBodyParams() body: Buffer, @Context() ctx: Context): any {\n const {secret, tolerance}: WebhookEventOptions = {\n ...this.webhooks,\n ...ctx.endpoint.store.get(WebhookEventMiddleware)\n };\n\n if (!secret) {\n throw new InternalServerError(\n \"Missing Stripe webhooks secret key. You can get this in your dashboard. See: https://dashboard.stripe.com/webhooks.\"\n );\n }\n\n try {\n ctx.set(STRIPE_WEBHOOK_SIGNATURE, signature);\n ctx.set(STRIPE_WEBHOOK_EVENT, this.stripe.webhooks.constructEvent(body, signature, secret, tolerance));\n } catch (err) {\n throw new BadRequest(`Stripe webhook error: ${err.message}`, err);\n }\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { Context, MiddlewareMethods } from "@tsed/common";
2
+ import { Context } from "@tsed/platform-params";
3
+ import { MiddlewareMethods } from "@tsed/platform-middlewares";
3
4
  import { Stripe } from "stripe";
4
5
  import "../services/StripeFactory";
5
6
  export interface WebhookEventOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/stripe",
3
- "version": "6.107.5",
3
+ "version": "6.110.0",
4
4
  "description": "Stripe package for Ts.ED framework",
5
5
  "private": false,
6
6
  "keywords": [
@@ -30,28 +30,43 @@
30
30
  "test": "cross-env NODE_ENV=test nyc mocha"
31
31
  },
32
32
  "dependencies": {
33
- "tslib": "2.2.0"
33
+ "tslib": "2.3.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@tsed/common": "6.107.5",
37
- "@tsed/core": "6.107.5",
38
- "@tsed/di": "6.107.5",
39
- "@tsed/json-mapper": "6.107.5",
40
- "@tsed/openspec": "6.107.5",
41
- "@tsed/schema": "6.107.5",
36
+ "@tsed/core": "6.110.0",
37
+ "@tsed/di": "6.110.0",
38
+ "@tsed/exceptions": "6.110.0",
39
+ "@tsed/platform-middlewares": "6.110.0",
40
+ "@tsed/platform-params": "6.110.0",
41
+ "@tsed/schema": "6.110.0",
42
42
  "stripe": "^8.129.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@tsed/common": "^6.107.5",
46
- "@tsed/core": "^6.107.5",
47
- "@tsed/di": "^6.107.5",
48
- "@tsed/json-mapper": "^6.107.5",
49
- "@tsed/openspec": "^6.107.5",
50
- "@tsed/schema": "^6.107.5",
45
+ "@tsed/exceptions": "^6.110.0",
46
+ "@tsed/platform-middlewares": "^6.110.0",
47
+ "@tsed/platform-params": "^6.110.0",
48
+ "@tsed/schema": "^6.110.0",
51
49
  "@types/body-parser": "^1.19.0",
52
50
  "body-parser": "^1.19.0",
53
51
  "stripe": "^8.129.0"
54
52
  },
53
+ "peerDependenciesMeta": {
54
+ "@tsed/platform-middlewares": {
55
+ "optional": false
56
+ },
57
+ "@tsed/platform-params": {
58
+ "optional": false
59
+ },
60
+ "@tsed/schema": {
61
+ "optional": false
62
+ },
63
+ "@tsed/exceptions": {
64
+ "optional": false
65
+ },
66
+ "stripe": {
67
+ "optional": false
68
+ }
69
+ },
55
70
  "repository": "https://github.com/tsedio/tsed",
56
71
  "bugs": {
57
72
  "url": "https://github.com/tsedio/tsed/issues"
package/readme.md CHANGED
@@ -178,10 +178,9 @@ import {expect} from "chai";
178
178
  import {Stripe} from "stripe";
179
179
  import SuperTest from "supertest";
180
180
  import {StripeWebhooksCtrl} from "./StripWebhookCtrl";
181
- import {rootDir, Server} from "../Server";
181
+ import {Server} from "../Server";
182
182
 
183
183
  const utils = PlatformTestUtils.create({
184
- rootDir,
185
184
  platform: PlatformExpress,
186
185
  server: Server,
187
186
  logger: {