@dereekb/nestjs 13.38.0 → 13.40.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/eslint/package.json +7 -7
- package/mailgun/package.json +11 -11
- package/openai/package.json +11 -11
- package/openrouter/package.json +8 -8
- package/package.json +27 -35
- package/stripe/package.json +11 -11
- package/twilio/index.esm.js +18 -1
- package/twilio/package.json +11 -11
- package/twilio/src/lib/twilio.api.d.ts +1 -1
- package/twilio/src/lib/twilio.interop.d.ts +7 -0
- package/typeform/package.json +11 -11
- package/vapiai/package.json +11 -11
- package/eslint/index.cjs.default.js +0 -1
- package/eslint/index.cjs.js +0 -418
- package/eslint/index.cjs.mjs +0 -2
- package/index.cjs.default.js +0 -1
- package/index.cjs.js +0 -2789
- package/index.cjs.mjs +0 -2
- package/mailgun/index.cjs.default.js +0 -1
- package/mailgun/index.cjs.js +0 -1802
- package/mailgun/index.cjs.mjs +0 -2
- package/openai/index.cjs.default.js +0 -1
- package/openai/index.cjs.js +0 -1068
- package/openai/index.cjs.mjs +0 -2
- package/openrouter/index.cjs.default.js +0 -1
- package/openrouter/index.cjs.js +0 -1200
- package/openrouter/index.cjs.mjs +0 -2
- package/stripe/index.cjs.default.js +0 -1
- package/stripe/index.cjs.js +0 -780
- package/stripe/index.cjs.mjs +0 -2
- package/twilio/index.cjs.default.js +0 -1
- package/twilio/index.cjs.js +0 -2184
- package/twilio/index.cjs.mjs +0 -2
- package/typeform/index.cjs.default.js +0 -1
- package/typeform/index.cjs.js +0 -1182
- package/typeform/index.cjs.mjs +0 -2
- package/vapiai/index.cjs.default.js +0 -1
- package/vapiai/index.cjs.js +0 -1055
- package/vapiai/index.cjs.mjs +0 -2
package/stripe/index.cjs.js
DELETED
|
@@ -1,780 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var util = require('@dereekb/util');
|
|
4
|
-
var nestjs = require('@dereekb/nestjs');
|
|
5
|
-
var common = require('@nestjs/common');
|
|
6
|
-
var Stripe = require('stripe');
|
|
7
|
-
var config = require('@nestjs/config');
|
|
8
|
-
|
|
9
|
-
function _define_property$4(obj, key, value) {
|
|
10
|
-
if (key in obj) {
|
|
11
|
-
Object.defineProperty(obj, key, {
|
|
12
|
-
value: value,
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true
|
|
16
|
-
});
|
|
17
|
-
} else {
|
|
18
|
-
obj[key] = value;
|
|
19
|
-
}
|
|
20
|
-
return obj;
|
|
21
|
-
}
|
|
22
|
-
function _object_spread(target) {
|
|
23
|
-
for(var i = 1; i < arguments.length; i++){
|
|
24
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
25
|
-
var ownKeys = Object.keys(source);
|
|
26
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
27
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
28
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
ownKeys.forEach(function(key) {
|
|
32
|
-
_define_property$4(target, key, source[key]);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
}
|
|
37
|
-
function ownKeys(object, enumerableOnly) {
|
|
38
|
-
var keys = Object.keys(object);
|
|
39
|
-
if (Object.getOwnPropertySymbols) {
|
|
40
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
41
|
-
keys.push.apply(keys, symbols);
|
|
42
|
-
}
|
|
43
|
-
return keys;
|
|
44
|
-
}
|
|
45
|
-
function _object_spread_props(target, source) {
|
|
46
|
-
source = source != null ? source : {};
|
|
47
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
48
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
49
|
-
} else {
|
|
50
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
51
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return target;
|
|
55
|
-
}
|
|
56
|
-
exports.StripeWebhookEventType = void 0;
|
|
57
|
-
(function(StripeWebhookEventType) {
|
|
58
|
-
StripeWebhookEventType["CUSTOMER_SUBSCRIPTION_TRIAL_WILL_END"] = "customer.subscription.trial_will_end";
|
|
59
|
-
StripeWebhookEventType["CUSTOMER_SUBSCRIPTION_DELETED"] = "customer.subscription.deleted";
|
|
60
|
-
StripeWebhookEventType["CUSTOMER_SUBSCRIPTION_CREATED"] = "customer.subscription.created";
|
|
61
|
-
StripeWebhookEventType["CUSTOMER_SUBSCRIPTION_UPDATED"] = "customer.subscription.updated";
|
|
62
|
-
StripeWebhookEventType["CHECKOUT_SESSION_COMPLETED"] = "checkout.session.completed";
|
|
63
|
-
StripeWebhookEventType["CHECKOUT_SESSION_ASYNC_PAYMENT_FAILED"] = "checkout.session.async_payment_failed";
|
|
64
|
-
StripeWebhookEventType["CHECKOUT_SESSION_ASYNC_PAYMENT_SUCCEEDED"] = "checkout.session.async_payment_succeeded";
|
|
65
|
-
StripeWebhookEventType["SUBSCRIPTION_SCHEDULE_ABORTED"] = "subscription_schedule.aborted";
|
|
66
|
-
StripeWebhookEventType["SUBSCRIPTION_SCHEDULE_CANCELLED"] = "subscription_schedule.canceled";
|
|
67
|
-
StripeWebhookEventType["SUBSCRIPTION_SCHEDULE_COMPLETED"] = "subscription_schedule.completed";
|
|
68
|
-
StripeWebhookEventType["SUBSCRIPTION_SCHEDULE_CREATED"] = "subscription_schedule.created";
|
|
69
|
-
StripeWebhookEventType["SUBSCRIPTION_SCHEDULE_EXPIRING"] = "subscription_schedule.expiring";
|
|
70
|
-
StripeWebhookEventType["SUBSCRIPTION_SCHEDULE_RELEASED"] = "subscription_schedule.released";
|
|
71
|
-
StripeWebhookEventType["SUBSCRIPTION_SCHEDULE_UPDATED"] = "subscription_schedule.updated";
|
|
72
|
-
})(exports.StripeWebhookEventType || (exports.StripeWebhookEventType = {}));
|
|
73
|
-
/**
|
|
74
|
-
* Creates a StripeWebhookEvent and treats the data as the input type.
|
|
75
|
-
*
|
|
76
|
-
* @param event - The raw Stripe event.
|
|
77
|
-
* @returns A typed StripeWebhookEvent.
|
|
78
|
-
*/ function stripeWebhookEvent(event) {
|
|
79
|
-
return {
|
|
80
|
-
event: event,
|
|
81
|
-
data: event.data.object
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Creates a mapper function that transforms a raw Stripe.Event into a StripeWebhookEvent using the provided mapping function.
|
|
86
|
-
*
|
|
87
|
-
* Use this when the event data object needs custom transformation before being wrapped in a StripeWebhookEvent.
|
|
88
|
-
*
|
|
89
|
-
* @param mapFn - Function to transform the event data object.
|
|
90
|
-
* @returns Mapper that converts a raw Stripe.Event into a StripeWebhookEvent using `mapFn`.
|
|
91
|
-
*/ function stripeWebhookEventMapper(mapFn) {
|
|
92
|
-
return function(event) {
|
|
93
|
-
return {
|
|
94
|
-
event: event,
|
|
95
|
-
data: mapFn(event.data.object, event)
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
var stripeEventHandlerFactory = util.handlerFactory(function(x) {
|
|
100
|
-
return x.type;
|
|
101
|
-
});
|
|
102
|
-
var stripeEventHandlerConfigurerFactory = util.handlerConfigurerFactory({
|
|
103
|
-
configurerForAccessor: function configurerForAccessor(accessor) {
|
|
104
|
-
var fnWithKey = util.handlerMappedSetFunctionFactory(accessor, stripeWebhookEvent);
|
|
105
|
-
var configurer = _object_spread_props(_object_spread({}, accessor), {
|
|
106
|
-
handleCheckoutSessionComplete: fnWithKey(exports.StripeWebhookEventType.CHECKOUT_SESSION_COMPLETED),
|
|
107
|
-
handleCheckoutSessionAsyncPaymentFailed: fnWithKey(exports.StripeWebhookEventType.CHECKOUT_SESSION_ASYNC_PAYMENT_FAILED),
|
|
108
|
-
handleCheckoutSessionAsyncPaymentSuccess: fnWithKey(exports.StripeWebhookEventType.CHECKOUT_SESSION_ASYNC_PAYMENT_SUCCEEDED),
|
|
109
|
-
handleCustomerSubscriptionCreated: fnWithKey(exports.StripeWebhookEventType.CUSTOMER_SUBSCRIPTION_CREATED),
|
|
110
|
-
handleCustomerSubscriptionUpdated: fnWithKey(exports.StripeWebhookEventType.CUSTOMER_SUBSCRIPTION_UPDATED),
|
|
111
|
-
handleCustomerSubscriptionDeleted: fnWithKey(exports.StripeWebhookEventType.CUSTOMER_SUBSCRIPTION_DELETED),
|
|
112
|
-
handleSubscriptionScheduleAborted: fnWithKey(exports.StripeWebhookEventType.SUBSCRIPTION_SCHEDULE_ABORTED),
|
|
113
|
-
handleSubscriptionScheduleCancelled: fnWithKey(exports.StripeWebhookEventType.SUBSCRIPTION_SCHEDULE_CANCELLED),
|
|
114
|
-
handleSubscriptionScheduleCompleted: fnWithKey(exports.StripeWebhookEventType.SUBSCRIPTION_SCHEDULE_COMPLETED),
|
|
115
|
-
handleSubscriptionScheduleCreated: fnWithKey(exports.StripeWebhookEventType.SUBSCRIPTION_SCHEDULE_CREATED),
|
|
116
|
-
handleSubscriptionScheduleExpiring: fnWithKey(exports.StripeWebhookEventType.SUBSCRIPTION_SCHEDULE_EXPIRING),
|
|
117
|
-
handleSubscriptionScheduleReleased: fnWithKey(exports.StripeWebhookEventType.SUBSCRIPTION_SCHEDULE_RELEASED),
|
|
118
|
-
handleSubscriptionScheduleUpdated: fnWithKey(exports.StripeWebhookEventType.SUBSCRIPTION_SCHEDULE_UPDATED)
|
|
119
|
-
});
|
|
120
|
-
return configurer;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
function _type_of(obj) {
|
|
125
|
-
"@swc/helpers - typeof";
|
|
126
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
127
|
-
}
|
|
128
|
-
function __decorate(decorators, target, key, desc) {
|
|
129
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
130
|
-
if ((typeof Reflect === "undefined" ? "undefined" : _type_of(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
131
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
132
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
133
|
-
}
|
|
134
|
-
function __param(paramIndex, decorator) {
|
|
135
|
-
return function(target, key) {
|
|
136
|
-
decorator(target, key, paramIndex);
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
140
|
-
var e = new Error(message);
|
|
141
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
function _class_call_check$5(instance, Constructor) {
|
|
145
|
-
if (!(instance instanceof Constructor)) {
|
|
146
|
-
throw new TypeError("Cannot call a class as a function");
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function _defineProperties$3(target, props) {
|
|
150
|
-
for(var i = 0; i < props.length; i++){
|
|
151
|
-
var descriptor = props[i];
|
|
152
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
153
|
-
descriptor.configurable = true;
|
|
154
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
155
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function _create_class$3(Constructor, protoProps, staticProps) {
|
|
159
|
-
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
160
|
-
return Constructor;
|
|
161
|
-
}
|
|
162
|
-
function _define_property$3(obj, key, value) {
|
|
163
|
-
if (key in obj) {
|
|
164
|
-
Object.defineProperty(obj, key, {
|
|
165
|
-
value: value,
|
|
166
|
-
enumerable: true,
|
|
167
|
-
configurable: true,
|
|
168
|
-
writable: true
|
|
169
|
-
});
|
|
170
|
-
} else {
|
|
171
|
-
obj[key] = value;
|
|
172
|
-
}
|
|
173
|
-
return obj;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Configuration for StripeService
|
|
177
|
-
*/ var StripeServiceConfig = /*#__PURE__*/ function() {
|
|
178
|
-
function StripeServiceConfig() {
|
|
179
|
-
_class_call_check$5(this, StripeServiceConfig);
|
|
180
|
-
_define_property$3(this, "stripe", void 0);
|
|
181
|
-
}
|
|
182
|
-
_create_class$3(StripeServiceConfig, null, [
|
|
183
|
-
{
|
|
184
|
-
key: "assertValidConfig",
|
|
185
|
-
value: function assertValidConfig(config) {
|
|
186
|
-
if (!config.stripe.secret) {
|
|
187
|
-
throw new Error('No stripe secret specified.');
|
|
188
|
-
} else if (!config.stripe.webhookSecret) {
|
|
189
|
-
throw new Error('No stripe webhook secret specified.');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
]);
|
|
194
|
-
return StripeServiceConfig;
|
|
195
|
-
}
|
|
196
|
-
();
|
|
197
|
-
|
|
198
|
-
function _class_call_check$4(instance, Constructor) {
|
|
199
|
-
if (!(instance instanceof Constructor)) {
|
|
200
|
-
throw new TypeError("Cannot call a class as a function");
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function _defineProperties$2(target, props) {
|
|
204
|
-
for(var i = 0; i < props.length; i++){
|
|
205
|
-
var descriptor = props[i];
|
|
206
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
207
|
-
descriptor.configurable = true;
|
|
208
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
209
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
function _create_class$2(Constructor, protoProps, staticProps) {
|
|
213
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
214
|
-
return Constructor;
|
|
215
|
-
}
|
|
216
|
-
function _define_property$2(obj, key, value) {
|
|
217
|
-
if (key in obj) {
|
|
218
|
-
Object.defineProperty(obj, key, {
|
|
219
|
-
value: value,
|
|
220
|
-
enumerable: true,
|
|
221
|
-
configurable: true,
|
|
222
|
-
writable: true
|
|
223
|
-
});
|
|
224
|
-
} else {
|
|
225
|
-
obj[key] = value;
|
|
226
|
-
}
|
|
227
|
-
return obj;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Injectable service that wraps the Stripe SDK for payment operations.
|
|
231
|
-
*
|
|
232
|
-
* Provides methods for constructing and verifying Stripe webhook events.
|
|
233
|
-
*/ exports.StripeApi = /*#__PURE__*/ function() {
|
|
234
|
-
function StripeApi(config) {
|
|
235
|
-
_class_call_check$4(this, StripeApi);
|
|
236
|
-
_define_property$2(this, "config", void 0);
|
|
237
|
-
_define_property$2(this, "stripe", void 0);
|
|
238
|
-
this.config = config;
|
|
239
|
-
this.stripe = new Stripe(config.stripe.secret, config.stripe.config);
|
|
240
|
-
}
|
|
241
|
-
_create_class$2(StripeApi, [
|
|
242
|
-
{
|
|
243
|
-
// MARK: Event
|
|
244
|
-
/**
|
|
245
|
-
* Verifies the Stripe signature and constructs a Stripe.Event from an incoming webhook request.
|
|
246
|
-
*
|
|
247
|
-
* @param req - The incoming Express request containing the stripe-signature header.
|
|
248
|
-
* @param rawBody - The raw request body buffer required for signature verification.
|
|
249
|
-
* @returns The verified and parsed Stripe.Event.
|
|
250
|
-
* @throws {BadRequestException} When the stripe-signature header is missing or verification fails.
|
|
251
|
-
*/ key: "readStripeEventFromWebhookRequest",
|
|
252
|
-
value: function readStripeEventFromWebhookRequest(req, rawBody) {
|
|
253
|
-
var signature = req.get('stripe-signature');
|
|
254
|
-
if (!signature) {
|
|
255
|
-
throw new common.BadRequestException("missing stripe-signature");
|
|
256
|
-
}
|
|
257
|
-
var event;
|
|
258
|
-
try {
|
|
259
|
-
event = this.stripe.webhooks.constructEvent(rawBody, signature, this.config.stripe.webhookSecret);
|
|
260
|
-
} catch (e) {
|
|
261
|
-
throw new common.BadRequestException("stripe signature read error: ".concat(e.message));
|
|
262
|
-
}
|
|
263
|
-
return event;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
]);
|
|
267
|
-
return StripeApi;
|
|
268
|
-
}();
|
|
269
|
-
exports.StripeApi = __decorate([
|
|
270
|
-
common.Injectable(),
|
|
271
|
-
__param(0, common.Inject(StripeServiceConfig))
|
|
272
|
-
], exports.StripeApi);
|
|
273
|
-
|
|
274
|
-
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
275
|
-
try {
|
|
276
|
-
var info = gen[key](arg);
|
|
277
|
-
var value = info.value;
|
|
278
|
-
} catch (error) {
|
|
279
|
-
reject(error);
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
if (info.done) {
|
|
283
|
-
resolve(value);
|
|
284
|
-
} else {
|
|
285
|
-
Promise.resolve(value).then(_next, _throw);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
function _async_to_generator$1(fn) {
|
|
289
|
-
return function() {
|
|
290
|
-
var self = this, args = arguments;
|
|
291
|
-
return new Promise(function(resolve, reject) {
|
|
292
|
-
var gen = fn.apply(self, args);
|
|
293
|
-
function _next(value) {
|
|
294
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
295
|
-
}
|
|
296
|
-
function _throw(err) {
|
|
297
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
298
|
-
}
|
|
299
|
-
_next(undefined);
|
|
300
|
-
});
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
function _class_call_check$3(instance, Constructor) {
|
|
304
|
-
if (!(instance instanceof Constructor)) {
|
|
305
|
-
throw new TypeError("Cannot call a class as a function");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function _defineProperties$1(target, props) {
|
|
309
|
-
for(var i = 0; i < props.length; i++){
|
|
310
|
-
var descriptor = props[i];
|
|
311
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
312
|
-
descriptor.configurable = true;
|
|
313
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
314
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
318
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
319
|
-
return Constructor;
|
|
320
|
-
}
|
|
321
|
-
function _define_property$1(obj, key, value) {
|
|
322
|
-
if (key in obj) {
|
|
323
|
-
Object.defineProperty(obj, key, {
|
|
324
|
-
value: value,
|
|
325
|
-
enumerable: true,
|
|
326
|
-
configurable: true,
|
|
327
|
-
writable: true
|
|
328
|
-
});
|
|
329
|
-
} else {
|
|
330
|
-
obj[key] = value;
|
|
331
|
-
}
|
|
332
|
-
return obj;
|
|
333
|
-
}
|
|
334
|
-
function _ts_generator$1(thisArg, body) {
|
|
335
|
-
var f, y, t, _ = {
|
|
336
|
-
label: 0,
|
|
337
|
-
sent: function() {
|
|
338
|
-
if (t[0] & 1) throw t[1];
|
|
339
|
-
return t[1];
|
|
340
|
-
},
|
|
341
|
-
trys: [],
|
|
342
|
-
ops: []
|
|
343
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
344
|
-
return d(g, "next", {
|
|
345
|
-
value: verb(0)
|
|
346
|
-
}), d(g, "throw", {
|
|
347
|
-
value: verb(1)
|
|
348
|
-
}), d(g, "return", {
|
|
349
|
-
value: verb(2)
|
|
350
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
351
|
-
value: function() {
|
|
352
|
-
return this;
|
|
353
|
-
}
|
|
354
|
-
}), g;
|
|
355
|
-
function verb(n) {
|
|
356
|
-
return function(v) {
|
|
357
|
-
return step([
|
|
358
|
-
n,
|
|
359
|
-
v
|
|
360
|
-
]);
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
function step(op) {
|
|
364
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
365
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
366
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
367
|
-
if (y = 0, t) op = [
|
|
368
|
-
op[0] & 2,
|
|
369
|
-
t.value
|
|
370
|
-
];
|
|
371
|
-
switch(op[0]){
|
|
372
|
-
case 0:
|
|
373
|
-
case 1:
|
|
374
|
-
t = op;
|
|
375
|
-
break;
|
|
376
|
-
case 4:
|
|
377
|
-
_.label++;
|
|
378
|
-
return {
|
|
379
|
-
value: op[1],
|
|
380
|
-
done: false
|
|
381
|
-
};
|
|
382
|
-
case 5:
|
|
383
|
-
_.label++;
|
|
384
|
-
y = op[1];
|
|
385
|
-
op = [
|
|
386
|
-
0
|
|
387
|
-
];
|
|
388
|
-
continue;
|
|
389
|
-
case 7:
|
|
390
|
-
op = _.ops.pop();
|
|
391
|
-
_.trys.pop();
|
|
392
|
-
continue;
|
|
393
|
-
default:
|
|
394
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
395
|
-
_ = 0;
|
|
396
|
-
continue;
|
|
397
|
-
}
|
|
398
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
399
|
-
_.label = op[1];
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
403
|
-
_.label = t[1];
|
|
404
|
-
t = op;
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
if (t && _.label < t[2]) {
|
|
408
|
-
_.label = t[2];
|
|
409
|
-
_.ops.push(op);
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
if (t[2]) _.ops.pop();
|
|
413
|
-
_.trys.pop();
|
|
414
|
-
continue;
|
|
415
|
-
}
|
|
416
|
-
op = body.call(thisArg, _);
|
|
417
|
-
} catch (e) {
|
|
418
|
-
op = [
|
|
419
|
-
6,
|
|
420
|
-
e
|
|
421
|
-
];
|
|
422
|
-
y = 0;
|
|
423
|
-
} finally{
|
|
424
|
-
f = t = 0;
|
|
425
|
-
}
|
|
426
|
-
if (op[0] & 5) throw op[1];
|
|
427
|
-
return {
|
|
428
|
-
value: op[0] ? op[1] : void 0,
|
|
429
|
-
done: true
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Service that makes system changes based on Stripe webhook events.
|
|
435
|
-
*/ exports.StripeWebhookService = /*#__PURE__*/ function() {
|
|
436
|
-
function StripeWebhookService(stripeApi) {
|
|
437
|
-
_class_call_check$3(this, StripeWebhookService);
|
|
438
|
-
_define_property$1(this, "logger", new common.Logger('StripeWebhookService'));
|
|
439
|
-
_define_property$1(this, "_stripeApi", void 0);
|
|
440
|
-
_define_property$1(this, "handler", stripeEventHandlerFactory());
|
|
441
|
-
_define_property$1(this, "configure", stripeEventHandlerConfigurerFactory(this.handler));
|
|
442
|
-
this._stripeApi = stripeApi;
|
|
443
|
-
}
|
|
444
|
-
_create_class$1(StripeWebhookService, [
|
|
445
|
-
{
|
|
446
|
-
key: "updateForWebhook",
|
|
447
|
-
value: function updateForWebhook(req, rawBody) {
|
|
448
|
-
return _async_to_generator$1(function() {
|
|
449
|
-
var event;
|
|
450
|
-
return _ts_generator$1(this, function(_state) {
|
|
451
|
-
event = this._stripeApi.readStripeEventFromWebhookRequest(req, rawBody);
|
|
452
|
-
return [
|
|
453
|
-
2,
|
|
454
|
-
this.updateForStripeEvent(event)
|
|
455
|
-
];
|
|
456
|
-
});
|
|
457
|
-
}).call(this);
|
|
458
|
-
}
|
|
459
|
-
},
|
|
460
|
-
{
|
|
461
|
-
key: "updateForStripeEvent",
|
|
462
|
-
value: function updateForStripeEvent(event) {
|
|
463
|
-
return _async_to_generator$1(function() {
|
|
464
|
-
var handled;
|
|
465
|
-
return _ts_generator$1(this, function(_state) {
|
|
466
|
-
switch(_state.label){
|
|
467
|
-
case 0:
|
|
468
|
-
return [
|
|
469
|
-
4,
|
|
470
|
-
this.handler(event)
|
|
471
|
-
];
|
|
472
|
-
case 1:
|
|
473
|
-
handled = _state.sent();
|
|
474
|
-
if (!handled) {
|
|
475
|
-
this.logger.warn('Received unexpected/unhandled stripe event: ', event);
|
|
476
|
-
}
|
|
477
|
-
return [
|
|
478
|
-
2,
|
|
479
|
-
handled
|
|
480
|
-
];
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
}).call(this);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
]);
|
|
487
|
-
return StripeWebhookService;
|
|
488
|
-
}();
|
|
489
|
-
exports.StripeWebhookService = __decorate([
|
|
490
|
-
common.Injectable(),
|
|
491
|
-
__param(0, common.Inject(exports.StripeApi))
|
|
492
|
-
], exports.StripeWebhookService);
|
|
493
|
-
|
|
494
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
495
|
-
try {
|
|
496
|
-
var info = gen[key](arg);
|
|
497
|
-
var value = info.value;
|
|
498
|
-
} catch (error) {
|
|
499
|
-
reject(error);
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
if (info.done) {
|
|
503
|
-
resolve(value);
|
|
504
|
-
} else {
|
|
505
|
-
Promise.resolve(value).then(_next, _throw);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
function _async_to_generator(fn) {
|
|
509
|
-
return function() {
|
|
510
|
-
var self = this, args = arguments;
|
|
511
|
-
return new Promise(function(resolve, reject) {
|
|
512
|
-
var gen = fn.apply(self, args);
|
|
513
|
-
function _next(value) {
|
|
514
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
515
|
-
}
|
|
516
|
-
function _throw(err) {
|
|
517
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
518
|
-
}
|
|
519
|
-
_next(undefined);
|
|
520
|
-
});
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
function _class_call_check$2(instance, Constructor) {
|
|
524
|
-
if (!(instance instanceof Constructor)) {
|
|
525
|
-
throw new TypeError("Cannot call a class as a function");
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
function _defineProperties(target, props) {
|
|
529
|
-
for(var i = 0; i < props.length; i++){
|
|
530
|
-
var descriptor = props[i];
|
|
531
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
532
|
-
descriptor.configurable = true;
|
|
533
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
534
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
538
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
539
|
-
return Constructor;
|
|
540
|
-
}
|
|
541
|
-
function _define_property(obj, key, value) {
|
|
542
|
-
if (key in obj) {
|
|
543
|
-
Object.defineProperty(obj, key, {
|
|
544
|
-
value: value,
|
|
545
|
-
enumerable: true,
|
|
546
|
-
configurable: true,
|
|
547
|
-
writable: true
|
|
548
|
-
});
|
|
549
|
-
} else {
|
|
550
|
-
obj[key] = value;
|
|
551
|
-
}
|
|
552
|
-
return obj;
|
|
553
|
-
}
|
|
554
|
-
function _ts_generator(thisArg, body) {
|
|
555
|
-
var f, y, t, _ = {
|
|
556
|
-
label: 0,
|
|
557
|
-
sent: function() {
|
|
558
|
-
if (t[0] & 1) throw t[1];
|
|
559
|
-
return t[1];
|
|
560
|
-
},
|
|
561
|
-
trys: [],
|
|
562
|
-
ops: []
|
|
563
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
564
|
-
return d(g, "next", {
|
|
565
|
-
value: verb(0)
|
|
566
|
-
}), d(g, "throw", {
|
|
567
|
-
value: verb(1)
|
|
568
|
-
}), d(g, "return", {
|
|
569
|
-
value: verb(2)
|
|
570
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
571
|
-
value: function() {
|
|
572
|
-
return this;
|
|
573
|
-
}
|
|
574
|
-
}), g;
|
|
575
|
-
function verb(n) {
|
|
576
|
-
return function(v) {
|
|
577
|
-
return step([
|
|
578
|
-
n,
|
|
579
|
-
v
|
|
580
|
-
]);
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
function step(op) {
|
|
584
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
585
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
586
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
587
|
-
if (y = 0, t) op = [
|
|
588
|
-
op[0] & 2,
|
|
589
|
-
t.value
|
|
590
|
-
];
|
|
591
|
-
switch(op[0]){
|
|
592
|
-
case 0:
|
|
593
|
-
case 1:
|
|
594
|
-
t = op;
|
|
595
|
-
break;
|
|
596
|
-
case 4:
|
|
597
|
-
_.label++;
|
|
598
|
-
return {
|
|
599
|
-
value: op[1],
|
|
600
|
-
done: false
|
|
601
|
-
};
|
|
602
|
-
case 5:
|
|
603
|
-
_.label++;
|
|
604
|
-
y = op[1];
|
|
605
|
-
op = [
|
|
606
|
-
0
|
|
607
|
-
];
|
|
608
|
-
continue;
|
|
609
|
-
case 7:
|
|
610
|
-
op = _.ops.pop();
|
|
611
|
-
_.trys.pop();
|
|
612
|
-
continue;
|
|
613
|
-
default:
|
|
614
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
615
|
-
_ = 0;
|
|
616
|
-
continue;
|
|
617
|
-
}
|
|
618
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
619
|
-
_.label = op[1];
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
623
|
-
_.label = t[1];
|
|
624
|
-
t = op;
|
|
625
|
-
break;
|
|
626
|
-
}
|
|
627
|
-
if (t && _.label < t[2]) {
|
|
628
|
-
_.label = t[2];
|
|
629
|
-
_.ops.push(op);
|
|
630
|
-
break;
|
|
631
|
-
}
|
|
632
|
-
if (t[2]) _.ops.pop();
|
|
633
|
-
_.trys.pop();
|
|
634
|
-
continue;
|
|
635
|
-
}
|
|
636
|
-
op = body.call(thisArg, _);
|
|
637
|
-
} catch (e) {
|
|
638
|
-
op = [
|
|
639
|
-
6,
|
|
640
|
-
e
|
|
641
|
-
];
|
|
642
|
-
y = 0;
|
|
643
|
-
} finally{
|
|
644
|
-
f = t = 0;
|
|
645
|
-
}
|
|
646
|
-
if (op[0] & 5) throw op[1];
|
|
647
|
-
return {
|
|
648
|
-
value: op[0] ? op[1] : void 0,
|
|
649
|
-
done: true
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
exports.StripeWebhookController = /*#__PURE__*/ function() {
|
|
654
|
-
function StripeWebhookController(stripeWebhookService) {
|
|
655
|
-
_class_call_check$2(this, StripeWebhookController);
|
|
656
|
-
_define_property(this, "_stripeWebhookService", void 0);
|
|
657
|
-
this._stripeWebhookService = stripeWebhookService;
|
|
658
|
-
}
|
|
659
|
-
_create_class(StripeWebhookController, [
|
|
660
|
-
{
|
|
661
|
-
key: "handleStripeWebhook",
|
|
662
|
-
value: function handleStripeWebhook(req, rawBody) {
|
|
663
|
-
return _async_to_generator(function() {
|
|
664
|
-
return _ts_generator(this, function(_state) {
|
|
665
|
-
switch(_state.label){
|
|
666
|
-
case 0:
|
|
667
|
-
return [
|
|
668
|
-
4,
|
|
669
|
-
this._stripeWebhookService.updateForWebhook(req, rawBody)
|
|
670
|
-
];
|
|
671
|
-
case 1:
|
|
672
|
-
_state.sent();
|
|
673
|
-
return [
|
|
674
|
-
2
|
|
675
|
-
];
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
}).call(this);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
]);
|
|
682
|
-
return StripeWebhookController;
|
|
683
|
-
}();
|
|
684
|
-
__decorate([
|
|
685
|
-
common.Post(),
|
|
686
|
-
__param(0, common.Req()),
|
|
687
|
-
__param(1, nestjs.RawBody())
|
|
688
|
-
], exports.StripeWebhookController.prototype, "handleStripeWebhook", null);
|
|
689
|
-
exports.StripeWebhookController = __decorate([
|
|
690
|
-
common.Controller('/webhook/stripe'),
|
|
691
|
-
__param(0, common.Inject(exports.StripeWebhookService))
|
|
692
|
-
], exports.StripeWebhookController);
|
|
693
|
-
|
|
694
|
-
function _class_call_check$1(instance, Constructor) {
|
|
695
|
-
if (!(instance instanceof Constructor)) {
|
|
696
|
-
throw new TypeError("Cannot call a class as a function");
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
var DEFAULT_STRIPE_API_VERSION = '2026-02-25.clover';
|
|
700
|
-
/**
|
|
701
|
-
* Factory that creates a StripeServiceConfig from environment variables.
|
|
702
|
-
*
|
|
703
|
-
* Reads STRIPE_SECRET and STRIPE_WEBHOOK_SECRET from environment variables using the default API version.
|
|
704
|
-
*
|
|
705
|
-
* @param configService - NestJS config service for reading environment variables.
|
|
706
|
-
* @returns A validated StripeServiceConfig.
|
|
707
|
-
*/ function stripeServiceConfigFactory(configService) {
|
|
708
|
-
var config = {
|
|
709
|
-
stripe: {
|
|
710
|
-
secret: configService.get('STRIPE_SECRET'),
|
|
711
|
-
webhookSecret: configService.get('STRIPE_WEBHOOK_SECRET'),
|
|
712
|
-
config: {
|
|
713
|
-
apiVersion: DEFAULT_STRIPE_API_VERSION
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
};
|
|
717
|
-
StripeServiceConfig.assertValidConfig(config);
|
|
718
|
-
return config;
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* NestJS module that provides the StripeApi service.
|
|
722
|
-
*
|
|
723
|
-
* Reads Stripe API credentials and webhook secret from environment variables.
|
|
724
|
-
*/ exports.StripeModule = function StripeModule() {
|
|
725
|
-
_class_call_check$1(this, StripeModule);
|
|
726
|
-
};
|
|
727
|
-
exports.StripeModule = __decorate([
|
|
728
|
-
common.Module({
|
|
729
|
-
imports: [
|
|
730
|
-
config.ConfigModule
|
|
731
|
-
],
|
|
732
|
-
providers: [
|
|
733
|
-
{
|
|
734
|
-
provide: StripeServiceConfig,
|
|
735
|
-
inject: [
|
|
736
|
-
config.ConfigService
|
|
737
|
-
],
|
|
738
|
-
useFactory: stripeServiceConfigFactory
|
|
739
|
-
},
|
|
740
|
-
exports.StripeApi
|
|
741
|
-
],
|
|
742
|
-
exports: [
|
|
743
|
-
exports.StripeApi
|
|
744
|
-
]
|
|
745
|
-
})
|
|
746
|
-
], exports.StripeModule);
|
|
747
|
-
|
|
748
|
-
function _class_call_check(instance, Constructor) {
|
|
749
|
-
if (!(instance instanceof Constructor)) {
|
|
750
|
-
throw new TypeError("Cannot call a class as a function");
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
exports.StripeWebhookModule = function StripeWebhookModule() {
|
|
754
|
-
_class_call_check(this, StripeWebhookModule);
|
|
755
|
-
};
|
|
756
|
-
exports.StripeWebhookModule = __decorate([
|
|
757
|
-
common.Module({
|
|
758
|
-
controllers: [
|
|
759
|
-
exports.StripeWebhookController
|
|
760
|
-
],
|
|
761
|
-
imports: [
|
|
762
|
-
exports.StripeModule
|
|
763
|
-
],
|
|
764
|
-
exports: [
|
|
765
|
-
exports.StripeModule,
|
|
766
|
-
exports.StripeWebhookService
|
|
767
|
-
],
|
|
768
|
-
providers: [
|
|
769
|
-
exports.StripeWebhookService
|
|
770
|
-
]
|
|
771
|
-
})
|
|
772
|
-
], exports.StripeWebhookModule);
|
|
773
|
-
|
|
774
|
-
exports.DEFAULT_STRIPE_API_VERSION = DEFAULT_STRIPE_API_VERSION;
|
|
775
|
-
exports.StripeServiceConfig = StripeServiceConfig;
|
|
776
|
-
exports.stripeEventHandlerConfigurerFactory = stripeEventHandlerConfigurerFactory;
|
|
777
|
-
exports.stripeEventHandlerFactory = stripeEventHandlerFactory;
|
|
778
|
-
exports.stripeServiceConfigFactory = stripeServiceConfigFactory;
|
|
779
|
-
exports.stripeWebhookEvent = stripeWebhookEvent;
|
|
780
|
-
exports.stripeWebhookEventMapper = stripeWebhookEventMapper;
|