@tsed/stripe 7.0.0-beta.2 → 7.0.0-beta.20
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 +14 -0
- package/lib/cjs/constants/{index.js → constants.js} +1 -1
- package/lib/cjs/constants/constants.js.map +1 -0
- package/lib/cjs/decorators/webhookEvent.js +4 -3
- package/lib/cjs/decorators/webhookEvent.js.map +1 -1
- package/lib/cjs/index.js +8 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/middlewares/WebhookEventMiddleware.js +21 -17
- package/lib/cjs/middlewares/WebhookEventMiddleware.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/esm/constants/{index.js → constants.js} +1 -1
- package/lib/esm/constants/constants.js.map +1 -0
- package/lib/esm/decorators/webhookEvent.js +4 -3
- package/lib/esm/decorators/webhookEvent.js.map +1 -1
- package/lib/esm/index.js +8 -5
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/middlewares/WebhookEventMiddleware.js +7 -3
- package/lib/esm/middlewares/WebhookEventMiddleware.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/types/constants/{index.d.ts → constants.d.ts} +0 -0
- package/lib/types/index.d.ts +5 -2
- package/lib/types/middlewares/WebhookEventMiddleware.d.ts +2 -1
- package/package.json +39 -19
- package/readme.md +93 -73
- package/tsconfig.compile.esm.json +1 -12
- package/.mocharc.js +0 -5
- package/lib/cjs/constants/index.js.map +0 -1
- package/lib/cjs/domain/index.js +0 -5
- package/lib/cjs/domain/index.js.map +0 -1
- package/lib/esm/constants/index.js.map +0 -1
- package/lib/esm/domain/index.js +0 -2
- package/lib/esm/domain/index.js.map +0 -1
- package/lib/types/domain/index.d.ts +0 -1
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
|
+
};
|
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.STRIPE_WEBHOOK_SIGNATURE = exports.STRIPE_WEBHOOK_EVENT = void 0;
|
|
4
4
|
exports.STRIPE_WEBHOOK_EVENT = "strip_webhook_event";
|
|
5
5
|
exports.STRIPE_WEBHOOK_SIGNATURE = "strip_webhook_signature";
|
|
6
|
-
//# sourceMappingURL=
|
|
6
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,qBAAqB,CAAC;AAC7C,QAAA,wBAAwB,GAAG,yBAAyB,CAAC","sourcesContent":["export const STRIPE_WEBHOOK_EVENT = \"strip_webhook_event\";\nexport const STRIPE_WEBHOOK_SIGNATURE = \"strip_webhook_signature\";\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebhookEvent = void 0;
|
|
4
|
-
const
|
|
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
|
-
const constants_1 = require("../constants");
|
|
8
|
+
const constants_1 = require("../constants/constants");
|
|
8
9
|
const WebhookEventMiddleware_1 = require("../middlewares/WebhookEventMiddleware");
|
|
9
10
|
/**
|
|
10
11
|
* Get the stripe webhook event.
|
|
@@ -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,
|
|
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,
|
|
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
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Automatically generated by barrelsby.
|
|
4
|
+
*/
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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);
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;
|
|
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,12 +3,16 @@ 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
|
|
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
|
-
const constants_1 = require("../constants");
|
|
11
|
+
const constants_1 = require("../constants/constants");
|
|
10
12
|
require("../services/StripeFactory");
|
|
11
13
|
let WebhookEventMiddleware = WebhookEventMiddleware_1 = class WebhookEventMiddleware {
|
|
14
|
+
stripe;
|
|
15
|
+
webhooks;
|
|
12
16
|
use(signature, body, ctx) {
|
|
13
17
|
const { secret, tolerance } = {
|
|
14
18
|
...this.webhooks,
|
|
@@ -26,24 +30,24 @@ let WebhookEventMiddleware = WebhookEventMiddleware_1 = class WebhookEventMiddle
|
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
};
|
|
29
|
-
|
|
30
|
-
(0,
|
|
31
|
-
|
|
33
|
+
tslib_1.__decorate([
|
|
34
|
+
(0, di_1.Inject)(),
|
|
35
|
+
tslib_1.__metadata("design:type", stripe_1.Stripe)
|
|
32
36
|
], WebhookEventMiddleware.prototype, "stripe", void 0);
|
|
33
|
-
|
|
34
|
-
(0,
|
|
35
|
-
|
|
37
|
+
tslib_1.__decorate([
|
|
38
|
+
(0, di_1.Constant)("stripe.webhooks"),
|
|
39
|
+
tslib_1.__metadata("design:type", Object)
|
|
36
40
|
], WebhookEventMiddleware.prototype, "webhooks", void 0);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
tslib_1.__decorate([
|
|
42
|
+
tslib_1.__param(0, (0, platform_params_1.HeaderParams)("stripe-signature")),
|
|
43
|
+
tslib_1.__param(1, (0, platform_params_1.RawBodyParams)()),
|
|
44
|
+
tslib_1.__param(2, (0, platform_params_1.Context)()),
|
|
45
|
+
tslib_1.__metadata("design:type", Function),
|
|
46
|
+
tslib_1.__metadata("design:paramtypes", [String, Buffer, Object]),
|
|
47
|
+
tslib_1.__metadata("design:returntype", Object)
|
|
44
48
|
], WebhookEventMiddleware.prototype, "use", null);
|
|
45
|
-
WebhookEventMiddleware = WebhookEventMiddleware_1 =
|
|
46
|
-
(0,
|
|
49
|
+
WebhookEventMiddleware = WebhookEventMiddleware_1 = tslib_1.__decorate([
|
|
50
|
+
(0, platform_middlewares_1.Middleware)()
|
|
47
51
|
], WebhookEventMiddleware);
|
|
48
52
|
exports.WebhookEventMiddleware = WebhookEventMiddleware;
|
|
49
53
|
//# sourceMappingURL=WebhookEventMiddleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookEventMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/WebhookEventMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,CAAC","sourcesContent":["export const STRIPE_WEBHOOK_EVENT = \"strip_webhook_event\";\nexport const STRIPE_WEBHOOK_SIGNATURE = \"strip_webhook_signature\";\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
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
|
-
import { STRIPE_WEBHOOK_EVENT } from "../constants";
|
|
5
|
-
import { WebhookEventMiddleware } from "../middlewares/WebhookEventMiddleware";
|
|
5
|
+
import { STRIPE_WEBHOOK_EVENT } from "../constants/constants.js";
|
|
6
|
+
import { WebhookEventMiddleware } from "../middlewares/WebhookEventMiddleware.js";
|
|
6
7
|
/**
|
|
7
8
|
* Get the stripe webhook event.
|
|
8
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhookEvent.js","sourceRoot":"","sources":["../../../src/decorators/webhookEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,
|
|
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"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./constants/constants.js";
|
|
5
|
+
export * from "./decorators/webhookEvent.js";
|
|
6
|
+
export * from "./domain/StripSettings.js";
|
|
7
|
+
export * from "./middlewares/WebhookEventMiddleware.js";
|
|
8
|
+
export * from "./services/StripeFactory.js";
|
|
6
9
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sCAAsC,CAAC;AACrD,cAAc,0BAA0B,CAAC","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,11 +1,15 @@
|
|
|
1
1
|
var WebhookEventMiddleware_1;
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
-
import {
|
|
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
|
-
import { STRIPE_WEBHOOK_EVENT, STRIPE_WEBHOOK_SIGNATURE } from "../constants";
|
|
7
|
-
import "../services/StripeFactory";
|
|
8
|
+
import { STRIPE_WEBHOOK_EVENT, STRIPE_WEBHOOK_SIGNATURE } from "../constants/constants.js";
|
|
9
|
+
import "../services/StripeFactory.js";
|
|
8
10
|
let WebhookEventMiddleware = WebhookEventMiddleware_1 = class WebhookEventMiddleware {
|
|
11
|
+
stripe;
|
|
12
|
+
webhooks;
|
|
9
13
|
use(signature, body, ctx) {
|
|
10
14
|
const { secret, tolerance } = {
|
|
11
15
|
...this.webhooks,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookEventMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/WebhookEventMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,
|
|
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"]}
|
|
File without changes
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./constants/constants";
|
|
3
5
|
export * from "./decorators/webhookEvent";
|
|
6
|
+
export * from "./domain/StripSettings";
|
|
4
7
|
export * from "./middlewares/WebhookEventMiddleware";
|
|
5
8
|
export * from "./services/StripeFactory";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Context
|
|
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": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.20",
|
|
4
4
|
"description": "Stripe package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"source": "./src/index.ts",
|
|
16
16
|
"main": "./lib/cjs/index.js",
|
|
17
|
+
"module": "./lib/esm/index.js",
|
|
17
18
|
"typings": "./lib/types/index.d.ts",
|
|
18
19
|
"exports": {
|
|
19
20
|
"types": "./lib/types/index.d.ts",
|
|
@@ -22,39 +23,58 @@
|
|
|
22
23
|
"default": "./lib/esm/index.js"
|
|
23
24
|
},
|
|
24
25
|
"scripts": {
|
|
25
|
-
"build": "yarn run build:esm && yarn run build:cjs",
|
|
26
|
+
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
26
27
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
27
28
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
28
|
-
"
|
|
29
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
30
|
+
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
31
|
-
"tslib": "2.
|
|
33
|
+
"tslib": "2.4.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
|
-
"@tsed/
|
|
35
|
-
"@tsed/
|
|
36
|
-
"@tsed/
|
|
37
|
-
"@tsed/
|
|
38
|
-
"@tsed/
|
|
39
|
-
"@tsed/schema": "7.0.0-beta.
|
|
36
|
+
"@tsed/core": "7.0.0-beta.20",
|
|
37
|
+
"@tsed/di": "7.0.0-beta.20",
|
|
38
|
+
"@tsed/exceptions": "7.0.0-beta.20",
|
|
39
|
+
"@tsed/platform-middlewares": "7.0.0-beta.20",
|
|
40
|
+
"@tsed/platform-params": "7.0.0-beta.20",
|
|
41
|
+
"@tsed/schema": "7.0.0-beta.20",
|
|
40
42
|
"stripe": "^8.129.0"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
|
-
"@tsed/
|
|
44
|
-
"@tsed/
|
|
45
|
-
"@tsed/
|
|
46
|
-
"@tsed/
|
|
47
|
-
"@tsed/openspec": "^7.0.0-beta.2",
|
|
48
|
-
"@tsed/schema": "^7.0.0-beta.2",
|
|
45
|
+
"@tsed/exceptions": "^7.0.0-beta.20",
|
|
46
|
+
"@tsed/platform-middlewares": "^7.0.0-beta.20",
|
|
47
|
+
"@tsed/platform-params": "^7.0.0-beta.20",
|
|
48
|
+
"@tsed/schema": "^7.0.0-beta.20",
|
|
49
49
|
"@types/body-parser": "^1.19.0",
|
|
50
50
|
"body-parser": "^1.19.0",
|
|
51
|
-
"stripe": "^
|
|
51
|
+
"stripe": "^9.16.0"
|
|
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
|
+
}
|
|
52
69
|
},
|
|
53
70
|
"repository": "https://github.com/tsedio/tsed",
|
|
54
71
|
"bugs": {
|
|
55
72
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
56
73
|
},
|
|
57
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
74
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/third-parties/stripe",
|
|
58
75
|
"author": "Romain Lenzotti",
|
|
59
|
-
"license": "MIT"
|
|
76
|
+
"license": "MIT",
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"tag": "beta"
|
|
79
|
+
}
|
|
60
80
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -32,7 +33,7 @@ A package of Ts.ED framework. See website: https://tsed.io/tutorials/stripe.html
|
|
|
32
33
|
## Feature
|
|
33
34
|
|
|
34
35
|
Currently, `@tsed/stripe` allows you:
|
|
35
|
-
|
|
36
|
+
|
|
36
37
|
- Configure stripe,
|
|
37
38
|
- Create webhooks,
|
|
38
39
|
- Use stripe API.
|
|
@@ -50,33 +51,59 @@ Then import `@tsed/stripe` in your Server:
|
|
|
50
51
|
|
|
51
52
|
```typescript
|
|
52
53
|
import {Configuration, PlatformApplication} from "@tsed/common";
|
|
53
|
-
import "@tsed/stripe";
|
|
54
|
+
import "@tsed/stripe";
|
|
54
55
|
import {Stripe} from "stripe";
|
|
55
56
|
|
|
56
57
|
@Configuration({
|
|
57
58
|
stripe: {
|
|
58
59
|
apiKey: process.env.STRIPE_SECRET_KEY,
|
|
59
60
|
webhooks: {
|
|
60
|
-
secret: process.env.STRIPE_WEBHOOK_SECRET
|
|
61
|
+
secret: process.env.STRIPE_WEBHOOK_SECRET
|
|
61
62
|
},
|
|
62
63
|
// Stripe options
|
|
63
|
-
apiVersion:
|
|
64
|
-
httpProxy: new ProxyAgent(process.env.http_proxy)
|
|
64
|
+
apiVersion: "2019-08-08",
|
|
65
|
+
httpProxy: new ProxyAgent(process.env.http_proxy)
|
|
65
66
|
}
|
|
66
67
|
})
|
|
67
68
|
export class Server {
|
|
68
69
|
@Inject()
|
|
69
70
|
stripe: Stripe;
|
|
70
|
-
|
|
71
|
+
|
|
71
72
|
$afterInit() {
|
|
72
73
|
// do something with stripe
|
|
73
74
|
// this.stripe.customers
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
```
|
|
78
|
+
|
|
77
79
|
> See Stripe options for more details: https://www.npmjs.com/package/stripe
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
::: warning
|
|
82
|
+
Stripe needs to validate signature transaction when you received a webhook notification.
|
|
83
|
+
To work properly, you have to remove bodyParser add on `$beforeRoutesInit`.
|
|
84
|
+
|
|
85
|
+
```diff
|
|
86
|
+
@Configuration({
|
|
87
|
+
+ middlewares: [
|
|
88
|
+
+ bodyParser.json(),
|
|
89
|
+
+ bodyParser.urlencoded({extended: true})
|
|
90
|
+
+ ]
|
|
91
|
+
})
|
|
92
|
+
export class Server {
|
|
93
|
+
@Inject()
|
|
94
|
+
protected app: PlatformApplication;
|
|
95
|
+
|
|
96
|
+
$beforeRoutesInit() {
|
|
97
|
+
- this.app
|
|
98
|
+
- .use(bodyParser.json())
|
|
99
|
+
- .use(bodyParser.urlencoded({extended: true}));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
::
|
|
105
|
+
|
|
106
|
+
## Inject Stripe
|
|
80
107
|
|
|
81
108
|
```typescript
|
|
82
109
|
import {Injectable} from "@tsed/di";
|
|
@@ -85,15 +112,13 @@ import {Injectable} from "@tsed/di";
|
|
|
85
112
|
class MyStripeService {
|
|
86
113
|
@Inject()
|
|
87
114
|
stripe: Stripe;
|
|
88
|
-
|
|
115
|
+
|
|
89
116
|
$onInit() {
|
|
90
117
|
// do something with stripe
|
|
91
|
-
this.stripe.on(
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
protected onRequest(request: any) {
|
|
95
|
-
|
|
118
|
+
this.stripe.on("request", this.onRequest.bind(this));
|
|
96
119
|
}
|
|
120
|
+
|
|
121
|
+
protected onRequest(request: any) {}
|
|
97
122
|
}
|
|
98
123
|
```
|
|
99
124
|
|
|
@@ -102,7 +127,7 @@ class MyStripeService {
|
|
|
102
127
|
Stripe can optionally sign the webhook events it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it [here](https://stripe.com/docs/webhooks#signatures).
|
|
103
128
|
|
|
104
129
|
To register a Stripe webhook with Ts.ED, just use the `@WebhookEvent` decorator. It'll call for you the `stripe.webhooks.constructEvent` with the right parameters:
|
|
105
|
-
|
|
130
|
+
|
|
106
131
|
```typescript
|
|
107
132
|
import {RawBodyParams, HeaderParams, Controller, Context} from "@tsed/common";
|
|
108
133
|
import {Stripe} from "stripe";
|
|
@@ -111,15 +136,12 @@ import {Stripe} from "stripe";
|
|
|
111
136
|
export class StripWebhookCtrl {
|
|
112
137
|
@Inject()
|
|
113
138
|
stripe: Stripe;
|
|
114
|
-
|
|
139
|
+
|
|
115
140
|
@Post("/callback")
|
|
116
|
-
successPaymentHook(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
ctx.logger.info({name: 'Webhook success', event});
|
|
121
|
-
|
|
122
|
-
return {received: true}
|
|
141
|
+
successPaymentHook(@WebhookEvent() event: Stripe.Event, @Context() ctx: Context) {
|
|
142
|
+
ctx.logger.info({name: "Webhook success", event});
|
|
143
|
+
|
|
144
|
+
return {received: true};
|
|
123
145
|
}
|
|
124
146
|
}
|
|
125
147
|
```
|
|
@@ -133,41 +155,43 @@ import {Stripe} from "stripe";
|
|
|
133
155
|
import {PlatformTest} from "@tsed/common";
|
|
134
156
|
import {StripWebhookCtrl} from "./StripWebhookCtrl";
|
|
135
157
|
|
|
136
|
-
describe(
|
|
137
|
-
beforeEach(() =>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
describe("StripWebhookCtrl", () => {
|
|
159
|
+
beforeEach(() =>
|
|
160
|
+
PlatformTest.create({
|
|
161
|
+
stripe: {
|
|
162
|
+
apiKey: "fake_api_key",
|
|
163
|
+
webhooks: {
|
|
164
|
+
secret: "whsec_test_secret"
|
|
165
|
+
},
|
|
166
|
+
// Stripe options
|
|
167
|
+
apiVersion: "2019-08-08"
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
afterEach(PlatformTest.reset);
|
|
148
172
|
it("should call event", async () => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
const stripe = PlatformTest.get<Stripe>(Stripe);
|
|
174
|
+
const payload = {
|
|
175
|
+
id: "evt_test_webhook",
|
|
176
|
+
object: "event"
|
|
177
|
+
};
|
|
178
|
+
const payloadString = JSON.stringify(payload, null, 2);
|
|
179
|
+
|
|
180
|
+
const header = stripe.webhooks.generateTestHeaderString({
|
|
181
|
+
payload: payloadString,
|
|
182
|
+
secret: "whsec_test_secret"
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const event = stripe.webhooks.constructEvent(payloadString, header, secret);
|
|
186
|
+
const ctx = PlatformTest.createRequestContext();
|
|
187
|
+
|
|
188
|
+
const ctrl = await PlatformTest.invoke<StripWebhookCtrl>(StripWebhookCtrl);
|
|
189
|
+
|
|
190
|
+
const result = ctrl.successPaymentHook(event, ctx);
|
|
191
|
+
|
|
192
|
+
expect(result).toEqual({received: true});
|
|
169
193
|
});
|
|
170
|
-
})
|
|
194
|
+
});
|
|
171
195
|
```
|
|
172
196
|
|
|
173
197
|
With SuperTest:
|
|
@@ -180,10 +204,9 @@ import {expect} from "chai";
|
|
|
180
204
|
import {Stripe} from "stripe";
|
|
181
205
|
import SuperTest from "supertest";
|
|
182
206
|
import {StripeWebhooksCtrl} from "./StripWebhookCtrl";
|
|
183
|
-
import {
|
|
207
|
+
import {Server} from "../Server";
|
|
184
208
|
|
|
185
209
|
const utils = PlatformTestUtils.create({
|
|
186
|
-
rootDir,
|
|
187
210
|
platform: PlatformExpress,
|
|
188
211
|
server: Server,
|
|
189
212
|
logger: {
|
|
@@ -193,11 +216,13 @@ const utils = PlatformTestUtils.create({
|
|
|
193
216
|
|
|
194
217
|
describe("Stripe", () => {
|
|
195
218
|
let request: SuperTest.SuperTest<SuperTest.Test>;
|
|
196
|
-
beforeEach(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
219
|
+
beforeEach(
|
|
220
|
+
utils.bootstrap({
|
|
221
|
+
mount: {
|
|
222
|
+
"/rest": [StripWebhookCtrl]
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
);
|
|
201
226
|
beforeEach(() => {
|
|
202
227
|
request = SuperTest.agent(PlatformTest.callback());
|
|
203
228
|
});
|
|
@@ -217,33 +242,28 @@ describe("Stripe", () => {
|
|
|
217
242
|
secret: "whsec_test_secret"
|
|
218
243
|
});
|
|
219
244
|
|
|
220
|
-
const response = await request
|
|
221
|
-
.post("/rest/webhooks/callback")
|
|
222
|
-
.send(payloadString)
|
|
223
|
-
.set("stripe-signature", signature)
|
|
224
|
-
.expect(200);
|
|
245
|
+
const response = await request.post("/rest/webhooks/callback").send(payloadString).set("stripe-signature", signature).expect(200);
|
|
225
246
|
|
|
226
247
|
expect(response.body).to.deep.eq({
|
|
227
|
-
|
|
228
|
-
|
|
248
|
+
event: payload,
|
|
249
|
+
received: true
|
|
229
250
|
});
|
|
230
251
|
});
|
|
231
252
|
});
|
|
232
253
|
```
|
|
233
254
|
|
|
234
255
|
## Contributors
|
|
256
|
+
|
|
235
257
|
Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
|
|
236
258
|
|
|
237
259
|
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
238
260
|
|
|
239
|
-
|
|
240
261
|
## Backers
|
|
241
262
|
|
|
242
263
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
243
264
|
|
|
244
265
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
|
|
245
266
|
|
|
246
|
-
|
|
247
267
|
## Sponsors
|
|
248
268
|
|
|
249
269
|
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
|
|
@@ -252,7 +272,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
252
272
|
|
|
253
273
|
The MIT License (MIT)
|
|
254
274
|
|
|
255
|
-
Copyright (c) 2016 -
|
|
275
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
256
276
|
|
|
257
277
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
258
278
|
|
|
@@ -8,16 +8,5 @@
|
|
|
8
8
|
"declaration": true,
|
|
9
9
|
"declarationDir": "./lib/types"
|
|
10
10
|
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"test",
|
|
14
|
-
"lib",
|
|
15
|
-
"benchmark",
|
|
16
|
-
"coverage",
|
|
17
|
-
"spec",
|
|
18
|
-
"**/*.benchmark.ts",
|
|
19
|
-
"**/*.spec.ts",
|
|
20
|
-
"keys",
|
|
21
|
-
"jest.config.js"
|
|
22
|
-
]
|
|
11
|
+
"exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
|
|
23
12
|
}
|
package/.mocharc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,qBAAqB,CAAC;AAC7C,QAAA,wBAAwB,GAAG,yBAAyB,CAAC","sourcesContent":["export const STRIPE_WEBHOOK_EVENT = \"strip_webhook_event\";\nexport const STRIPE_WEBHOOK_SIGNATURE = \"strip_webhook_signature\";\n"]}
|
package/lib/cjs/domain/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/index.ts"],"names":[],"mappings":";;;AAAA,+DAAgC","sourcesContent":["export * from \"./StripSettings\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,CAAC","sourcesContent":["export const STRIPE_WEBHOOK_EVENT = \"strip_webhook_event\";\nexport const STRIPE_WEBHOOK_SIGNATURE = \"strip_webhook_signature\";\n"]}
|
package/lib/esm/domain/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC","sourcesContent":["export * from \"./StripSettings\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./StripSettings";
|