@tsed/stripe 6.114.15 → 6.114.18

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/jest.config.js ADDED
@@ -0,0 +1,14 @@
1
+ // For a detailed explanation regarding each configuration property, visit:
2
+ // https://jestjs.io/docs/en/configuration.html
3
+
4
+ module.exports = {
5
+ ...require("@tsed/jest-config")(__dirname, "stripe"),
6
+ coverageThreshold: {
7
+ global: {
8
+ statements: 97.29,
9
+ branches: 100,
10
+ functions: 100,
11
+ lines: 97.14
12
+ }
13
+ }
14
+ };
@@ -11,6 +11,8 @@ const stripe_1 = require("stripe");
11
11
  const constants_1 = require("../constants/constants");
12
12
  require("../services/StripeFactory");
13
13
  let WebhookEventMiddleware = WebhookEventMiddleware_1 = class WebhookEventMiddleware {
14
+ stripe;
15
+ webhooks;
14
16
  use(signature, body, ctx) {
15
17
  const { secret, tolerance } = {
16
18
  ...this.webhooks,
@@ -1 +1 @@
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
+ {"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;IAEvB,MAAM,CAAS;IAGf,QAAQ,CAAsB;IAExC,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"]}
@@ -8,6 +8,8 @@ import { Stripe } from "stripe";
8
8
  import { STRIPE_WEBHOOK_EVENT, STRIPE_WEBHOOK_SIGNATURE } from "../constants/constants.js";
9
9
  import "../services/StripeFactory.js";
10
10
  let WebhookEventMiddleware = WebhookEventMiddleware_1 = class WebhookEventMiddleware {
11
+ stripe;
12
+ webhooks;
11
13
  use(signature, body, ctx) {
12
14
  const { secret, tolerance } = {
13
15
  ...this.webhooks,
@@ -1 +1 @@
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
+ {"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;IAEvB,MAAM,CAAS;IAGf,QAAQ,CAAsB;IAExC,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/stripe",
3
- "version": "6.114.15",
3
+ "version": "6.114.18",
4
4
  "description": "Stripe package for Ts.ED framework",
5
5
  "private": false,
6
6
  "keywords": [
@@ -27,25 +27,25 @@
27
27
  "build:cjs": "tsc --build tsconfig.compile.json",
28
28
  "build:esm": "tsc --build tsconfig.compile.esm.json",
29
29
  "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
30
- "test": "cross-env NODE_ENV=test nyc mocha"
30
+ "test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
31
31
  },
32
32
  "dependencies": {
33
- "tslib": "2.3.1"
33
+ "tslib": "2.4.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@tsed/core": "6.114.15",
37
- "@tsed/di": "6.114.15",
38
- "@tsed/exceptions": "6.114.15",
39
- "@tsed/platform-middlewares": "6.114.15",
40
- "@tsed/platform-params": "6.114.15",
41
- "@tsed/schema": "6.114.15",
36
+ "@tsed/core": "6.114.18",
37
+ "@tsed/di": "6.114.18",
38
+ "@tsed/exceptions": "6.114.18",
39
+ "@tsed/platform-middlewares": "6.114.18",
40
+ "@tsed/platform-params": "6.114.18",
41
+ "@tsed/schema": "6.114.18",
42
42
  "stripe": "^8.129.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@tsed/exceptions": "^6.114.15",
46
- "@tsed/platform-middlewares": "^6.114.15",
47
- "@tsed/platform-params": "^6.114.15",
48
- "@tsed/schema": "^6.114.15",
45
+ "@tsed/exceptions": "^6.114.18",
46
+ "@tsed/platform-middlewares": "^6.114.18",
47
+ "@tsed/platform-params": "^6.114.18",
48
+ "@tsed/schema": "^6.114.18",
49
49
  "@types/body-parser": "^1.19.0",
50
50
  "body-parser": "^1.19.0",
51
51
  "stripe": "^8.129.0"
package/.mocharc.js DELETED
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- ...require("@tsed/mocha-config")(),
3
- spec: ["{src,test}/**/*.spec.ts"],
4
- exclude: []
5
- };