@tsed/stripe 7.3.0 → 7.4.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/lib/cjs/domain/{StripSettings.js → StripeSettings.js} +1 -1
- package/lib/cjs/domain/StripeSettings.js.map +1 -0
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/middlewares/WebhookEventMiddleware.js +1 -0
- package/lib/cjs/middlewares/WebhookEventMiddleware.js.map +1 -1
- package/lib/cjs/services/StripeFactory.js +3 -0
- package/lib/cjs/services/StripeFactory.js.map +1 -1
- package/lib/esm/domain/StripeSettings.js +2 -0
- package/lib/esm/domain/StripeSettings.js.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/middlewares/WebhookEventMiddleware.js +1 -0
- package/lib/esm/middlewares/WebhookEventMiddleware.js.map +1 -1
- package/lib/esm/services/StripeFactory.js +2 -0
- package/lib/esm/services/StripeFactory.js.map +1 -1
- package/lib/types/domain/{StripSettings.d.ts → StripeSettings.d.ts} +0 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/StripeFactory.d.ts +2 -1
- package/package.json +11 -11
- package/readme.md +3 -2
- package/lib/cjs/domain/StripSettings.js.map +0 -1
- package/lib/esm/domain/StripSettings.js +0 -2
- package/lib/esm/domain/StripSettings.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeSettings.js","sourceRoot":"","sources":["../../../src/domain/StripeSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Stripe} from \"stripe\";\n\nexport interface StripeSettings extends Stripe.StripeConfig {\n /**\n * Stripe ApiKey\n */\n apiKey: string;\n /**\n * Webhooks settings\n */\n webhooks?: {\n /**\n * Your Webhook Signing Secret for this endpoint (e.g., 'whsec_...').\n * You can get this [in your dashboard](https://dashboard.stripe.com/webhooks).\n */\n secret: string;\n /**\n * Seconds of tolerance on timestamps.\n */\n tolerance?: number;\n };\n}\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n stripe: StripeSettings;\n }\n }\n}\n"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
tslib_1.__exportStar(require("./constants/constants"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./decorators/webhookEvent"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./domain/
|
|
9
|
+
tslib_1.__exportStar(require("./domain/StripeSettings"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./middlewares/WebhookEventMiddleware"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./services/StripeFactory"), exports);
|
|
12
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":";AAAA;;GAEG;;;AAEH,gEAAsC;AACtC,oEAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,gEAAsC;AACtC,oEAA0C;AAC1C,kEAAwC;AACxC,+EAAqD;AACrD,mEAAyC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/webhookEvent\";\nexport * from \"./domain/StripeSettings\";\nexport * from \"./middlewares/WebhookEventMiddleware\";\nexport * from \"./services/StripeFactory\";\n"]}
|
|
@@ -14,6 +14,7 @@ let WebhookEventMiddleware = WebhookEventMiddleware_1 = class WebhookEventMiddle
|
|
|
14
14
|
stripe;
|
|
15
15
|
webhooks;
|
|
16
16
|
use(signature, body, ctx) {
|
|
17
|
+
console.log(Buffer);
|
|
17
18
|
const { secret, tolerance } = {
|
|
18
19
|
...this.webhooks,
|
|
19
20
|
...ctx.endpoint.store.get(WebhookEventMiddleware_1)
|
|
@@ -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;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;
|
|
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,sD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\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 console.log(Buffer);\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,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StripeFactory = void 0;
|
|
3
4
|
const di_1 = require("@tsed/di");
|
|
4
5
|
const stripe_1 = require("stripe");
|
|
6
|
+
exports.StripeFactory = stripe_1.Stripe;
|
|
5
7
|
(0, di_1.registerProvider)({
|
|
6
8
|
provide: stripe_1.Stripe,
|
|
7
9
|
deps: [di_1.Configuration],
|
|
8
10
|
useFactory(settings) {
|
|
9
11
|
const { apiKey, webhooks, ...options } = settings.get("stripe", {});
|
|
12
|
+
settings.set("rawBody", true);
|
|
10
13
|
if (apiKey) {
|
|
11
14
|
return new stripe_1.Stripe(apiKey, {
|
|
12
15
|
...options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StripeFactory.js","sourceRoot":"","sources":["../../../src/services/StripeFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StripeFactory.js","sourceRoot":"","sources":["../../../src/services/StripeFactory.ts"],"names":[],"mappings":";;;AAAA,iCAAyD;AACzD,mCAA8B;AAGjB,QAAA,aAAa,GAAG,eAAM,CAAC;AAEpC,IAAA,qBAAgB,EAAC;IACf,OAAO,EAAE,eAAM;IACf,IAAI,EAAE,CAAC,kBAAa,CAAC;IACrB,UAAU,CAAC,QAAuB;QAChC,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAC,GAAG,QAAQ,CAAC,GAAG,CAAiB,QAAQ,EAAE,EAAS,CAAC,CAAC;QAEzF,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE9B,IAAI,MAAM,EAAE;YACV,OAAO,IAAI,eAAM,CAAC,MAAM,EAAE;gBACxB,GAAG,OAAO;gBACV,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;SACJ;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, registerProvider} from \"@tsed/di\";\nimport {Stripe} from \"stripe\";\nimport {StripeSettings} from \"../domain/StripeSettings\";\n\nexport const StripeFactory = Stripe;\n\nregisterProvider({\n provide: Stripe,\n deps: [Configuration],\n useFactory(settings: Configuration) {\n const {apiKey, webhooks, ...options} = settings.get<StripeSettings>(\"stripe\", {} as any);\n\n settings.set(\"rawBody\", true);\n\n if (apiKey) {\n return new Stripe(apiKey, {\n ...options,\n typescript: true\n });\n }\n\n return {};\n }\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeSettings.js","sourceRoot":"","sources":["../../../src/domain/StripeSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Stripe} from \"stripe\";\n\nexport interface StripeSettings extends Stripe.StripeConfig {\n /**\n * Stripe ApiKey\n */\n apiKey: string;\n /**\n * Webhooks settings\n */\n webhooks?: {\n /**\n * Your Webhook Signing Secret for this endpoint (e.g., 'whsec_...').\n * You can get this [in your dashboard](https://dashboard.stripe.com/webhooks).\n */\n secret: string;\n /**\n * Seconds of tolerance on timestamps.\n */\n tolerance?: number;\n };\n}\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n stripe: StripeSettings;\n }\n }\n}\n"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export * from "./constants/constants.js";
|
|
5
5
|
export * from "./decorators/webhookEvent.js";
|
|
6
|
-
export * from "./domain/
|
|
6
|
+
export * from "./domain/StripeSettings.js";
|
|
7
7
|
export * from "./middlewares/WebhookEventMiddleware.js";
|
|
8
8
|
export * from "./services/StripeFactory.js";
|
|
9
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;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,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,yBAAyB,CAAC;AACxC,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/StripeSettings\";\nexport * from \"./middlewares/WebhookEventMiddleware\";\nexport * from \"./services/StripeFactory\";\n"]}
|
|
@@ -11,6 +11,7 @@ let WebhookEventMiddleware = WebhookEventMiddleware_1 = class WebhookEventMiddle
|
|
|
11
11
|
stripe;
|
|
12
12
|
webhooks;
|
|
13
13
|
use(signature, body, ctx) {
|
|
14
|
+
console.log(Buffer);
|
|
14
15
|
const { secret, tolerance } = {
|
|
15
16
|
...this.webhooks,
|
|
16
17
|
...ctx.endpoint.store.get(WebhookEventMiddleware_1)
|
|
@@ -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;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,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AAI,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;AAzBC;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;;iDAmBrF;AA1BU,sBAAsB;IADlC,UAAU,EAAE;GACA,sBAAsB,CA2BlC;SA3BY,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 console.log(Buffer);\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,10 +1,12 @@
|
|
|
1
1
|
import { Configuration, registerProvider } from "@tsed/di";
|
|
2
2
|
import { Stripe } from "stripe";
|
|
3
|
+
export const StripeFactory = Stripe;
|
|
3
4
|
registerProvider({
|
|
4
5
|
provide: Stripe,
|
|
5
6
|
deps: [Configuration],
|
|
6
7
|
useFactory(settings) {
|
|
7
8
|
const { apiKey, webhooks, ...options } = settings.get("stripe", {});
|
|
9
|
+
settings.set("rawBody", true);
|
|
8
10
|
if (apiKey) {
|
|
9
11
|
return new Stripe(apiKey, {
|
|
10
12
|
...options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StripeFactory.js","sourceRoot":"","sources":["../../../src/services/StripeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAG9B,gBAAgB,CAAC;IACf,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,UAAU,CAAC,QAAuB;QAChC,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAC,GAAG,QAAQ,CAAC,GAAG,CAAiB,QAAQ,EAAE,EAAS,CAAC,CAAC;QAEzF,IAAI,MAAM,EAAE;YACV,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE;gBACxB,GAAG,OAAO;gBACV,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;SACJ;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, registerProvider} from \"@tsed/di\";\nimport {Stripe} from \"stripe\";\nimport {StripeSettings} from \"../domain/
|
|
1
|
+
{"version":3,"file":"StripeFactory.js","sourceRoot":"","sources":["../../../src/services/StripeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAG9B,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAEpC,gBAAgB,CAAC;IACf,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,UAAU,CAAC,QAAuB;QAChC,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAC,GAAG,QAAQ,CAAC,GAAG,CAAiB,QAAQ,EAAE,EAAS,CAAC,CAAC;QAEzF,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE9B,IAAI,MAAM,EAAE;YACV,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE;gBACxB,GAAG,OAAO;gBACV,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;SACJ;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, registerProvider} from \"@tsed/di\";\nimport {Stripe} from \"stripe\";\nimport {StripeSettings} from \"../domain/StripeSettings\";\n\nexport const StripeFactory = Stripe;\n\nregisterProvider({\n provide: Stripe,\n deps: [Configuration],\n useFactory(settings: Configuration) {\n const {apiKey, webhooks, ...options} = settings.get<StripeSettings>(\"stripe\", {} as any);\n\n settings.set(\"rawBody\", true);\n\n if (apiKey) {\n return new Stripe(apiKey, {\n ...options,\n typescript: true\n });\n }\n\n return {};\n }\n});\n"]}
|
|
File without changes
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export * from "./constants/constants";
|
|
5
5
|
export * from "./decorators/webhookEvent";
|
|
6
|
-
export * from "./domain/
|
|
6
|
+
export * from "./domain/StripeSettings";
|
|
7
7
|
export * from "./middlewares/WebhookEventMiddleware";
|
|
8
8
|
export * from "./services/StripeFactory";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Stripe } from "stripe";
|
|
2
|
+
export declare const StripeFactory: typeof Stripe;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/stripe",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "Stripe package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"tslib": "2.4.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@tsed/core": "7.
|
|
37
|
-
"@tsed/di": "7.
|
|
38
|
-
"@tsed/exceptions": "7.
|
|
39
|
-
"@tsed/platform-middlewares": "7.
|
|
40
|
-
"@tsed/platform-params": "7.
|
|
41
|
-
"@tsed/schema": "7.
|
|
36
|
+
"@tsed/core": "7.4.0",
|
|
37
|
+
"@tsed/di": "7.4.0",
|
|
38
|
+
"@tsed/exceptions": "7.4.0",
|
|
39
|
+
"@tsed/platform-middlewares": "7.4.0",
|
|
40
|
+
"@tsed/platform-params": "7.4.0",
|
|
41
|
+
"@tsed/schema": "7.4.0",
|
|
42
42
|
"stripe": "^8.129.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@tsed/exceptions": "^7.
|
|
46
|
-
"@tsed/platform-middlewares": "^7.
|
|
47
|
-
"@tsed/platform-params": "^7.
|
|
48
|
-
"@tsed/schema": "^7.
|
|
45
|
+
"@tsed/exceptions": "^7.4.0",
|
|
46
|
+
"@tsed/platform-middlewares": "^7.4.0",
|
|
47
|
+
"@tsed/platform-params": "^7.4.0",
|
|
48
|
+
"@tsed/schema": "^7.4.0",
|
|
49
49
|
"@types/body-parser": "^1.19.0",
|
|
50
50
|
"body-parser": "^1.19.0",
|
|
51
51
|
"stripe": "^9.16.0"
|
package/readme.md
CHANGED
|
@@ -84,9 +84,10 @@ To work properly, you have to remove bodyParser add on `$beforeRoutesInit`.
|
|
|
84
84
|
|
|
85
85
|
```diff
|
|
86
86
|
@Configuration({
|
|
87
|
+
+ rawBody: true,
|
|
87
88
|
+ middlewares: [
|
|
88
|
-
+
|
|
89
|
-
+
|
|
89
|
+
+ {use: 'json-parser'},
|
|
90
|
+
+ {use: 'urlencoded-parser', options: {extended: true})
|
|
90
91
|
+ ]
|
|
91
92
|
})
|
|
92
93
|
export class Server {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StripSettings.js","sourceRoot":"","sources":["../../../src/domain/StripSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Stripe} from \"stripe\";\n\nexport interface StripeSettings extends Stripe.StripeConfig {\n /**\n * Stripe ApiKey\n */\n apiKey: string;\n /**\n * Webhooks settings\n */\n webhooks?: {\n /**\n * Your Webhook Signing Secret for this endpoint (e.g., 'whsec_...').\n * You can get this [in your dashboard](https://dashboard.stripe.com/webhooks).\n */\n secret: string;\n /**\n * Seconds of tolerance on timestamps.\n */\n tolerance?: number;\n };\n}\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n stripe: StripeSettings;\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StripSettings.js","sourceRoot":"","sources":["../../../src/domain/StripSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Stripe} from \"stripe\";\n\nexport interface StripeSettings extends Stripe.StripeConfig {\n /**\n * Stripe ApiKey\n */\n apiKey: string;\n /**\n * Webhooks settings\n */\n webhooks?: {\n /**\n * Your Webhook Signing Secret for this endpoint (e.g., 'whsec_...').\n * You can get this [in your dashboard](https://dashboard.stripe.com/webhooks).\n */\n secret: string;\n /**\n * Seconds of tolerance on timestamps.\n */\n tolerance?: number;\n };\n}\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n stripe: StripeSettings;\n }\n }\n}\n"]}
|