@dereekb/nestjs 13.2.2 → 13.3.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/index.cjs.js CHANGED
@@ -6,206 +6,722 @@ var querystring = require('querystring');
6
6
  var bodyParser = require('body-parser');
7
7
  var util = require('@dereekb/util');
8
8
  var config = require('@nestjs/config');
9
+ var crypto = require('crypto');
9
10
 
10
11
  /**
11
- * Returns true if the request is from localhost:4200.
12
- */
13
- const IsRequestFromLocalHost = common.createParamDecorator((data, context) => {
12
+ * Returns true if the request is from localhost.
13
+ */ var IsRequestFromLocalHost = common.createParamDecorator(function(data, context) {
14
14
  return isLocalhost(context);
15
15
  });
16
16
  function isLocalhost(context) {
17
- const req = context.switchToHttp().getRequest();
18
- const origin = req.headers['origin'] ?? '';
17
+ var _req_headers_origin;
18
+ var req = context.switchToHttp().getRequest();
19
+ var origin = (_req_headers_origin = req.headers['origin']) !== null && _req_headers_origin !== void 0 ? _req_headers_origin : '';
19
20
  return origin.startsWith('http://localhost') || origin.startsWith('https://localhost');
20
21
  }
21
22
 
22
- const ParseRawBody = common.createParamDecorator(async (_, context) => {
23
- const req = context.switchToHttp().getRequest();
24
- if (!req.readable) {
25
- console.error('RawBody request was not readable. This is generally due to bad configuration.');
26
- throw new common.BadRequestException('Invalid body');
27
- }
28
- const body = await rawbody(req);
29
- return body;
23
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
24
+ try {
25
+ var info = gen[key](arg);
26
+ var value = info.value;
27
+ } catch (error) {
28
+ reject(error);
29
+ return;
30
+ }
31
+ if (info.done) {
32
+ resolve(value);
33
+ } else {
34
+ Promise.resolve(value).then(_next, _throw);
35
+ }
36
+ }
37
+ function _async_to_generator(fn) {
38
+ return function() {
39
+ var self = this, args = arguments;
40
+ return new Promise(function(resolve, reject) {
41
+ var gen = fn.apply(self, args);
42
+ function _next(value) {
43
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
44
+ }
45
+ function _throw(err) {
46
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
47
+ }
48
+ _next(undefined);
49
+ });
50
+ };
51
+ }
52
+ function _ts_generator(thisArg, body) {
53
+ var f, y, t, _ = {
54
+ label: 0,
55
+ sent: function() {
56
+ if (t[0] & 1) throw t[1];
57
+ return t[1];
58
+ },
59
+ trys: [],
60
+ ops: []
61
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
62
+ return d(g, "next", {
63
+ value: verb(0)
64
+ }), d(g, "throw", {
65
+ value: verb(1)
66
+ }), d(g, "return", {
67
+ value: verb(2)
68
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
69
+ value: function() {
70
+ return this;
71
+ }
72
+ }), g;
73
+ function verb(n) {
74
+ return function(v) {
75
+ return step([
76
+ n,
77
+ v
78
+ ]);
79
+ };
80
+ }
81
+ function step(op) {
82
+ if (f) throw new TypeError("Generator is already executing.");
83
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
84
+ 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;
85
+ if (y = 0, t) op = [
86
+ op[0] & 2,
87
+ t.value
88
+ ];
89
+ switch(op[0]){
90
+ case 0:
91
+ case 1:
92
+ t = op;
93
+ break;
94
+ case 4:
95
+ _.label++;
96
+ return {
97
+ value: op[1],
98
+ done: false
99
+ };
100
+ case 5:
101
+ _.label++;
102
+ y = op[1];
103
+ op = [
104
+ 0
105
+ ];
106
+ continue;
107
+ case 7:
108
+ op = _.ops.pop();
109
+ _.trys.pop();
110
+ continue;
111
+ default:
112
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
113
+ _ = 0;
114
+ continue;
115
+ }
116
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
117
+ _.label = op[1];
118
+ break;
119
+ }
120
+ if (op[0] === 6 && _.label < t[1]) {
121
+ _.label = t[1];
122
+ t = op;
123
+ break;
124
+ }
125
+ if (t && _.label < t[2]) {
126
+ _.label = t[2];
127
+ _.ops.push(op);
128
+ break;
129
+ }
130
+ if (t[2]) _.ops.pop();
131
+ _.trys.pop();
132
+ continue;
133
+ }
134
+ op = body.call(thisArg, _);
135
+ } catch (e) {
136
+ op = [
137
+ 6,
138
+ e
139
+ ];
140
+ y = 0;
141
+ } finally{
142
+ f = t = 0;
143
+ }
144
+ if (op[0] & 5) throw op[1];
145
+ return {
146
+ value: op[0] ? op[1] : void 0,
147
+ done: true
148
+ };
149
+ }
150
+ }
151
+ /**
152
+ * NestJS parameter decorator that reads the raw request body directly from the incoming stream.
153
+ *
154
+ * Requires the request to still be readable (i.e., no prior body-parsing middleware has consumed it).
155
+ *
156
+ * @throws {BadRequestException} When the request stream is not readable
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * @Post('webhook')
161
+ * handleWebhook(@ParseRawBody() body: RawBodyBuffer) { ... }
162
+ * ```
163
+ */ var ParseRawBody = common.createParamDecorator(function(_, context) {
164
+ return _async_to_generator(function() {
165
+ var req, body;
166
+ return _ts_generator(this, function(_state) {
167
+ switch(_state.label){
168
+ case 0:
169
+ req = context.switchToHttp().getRequest();
170
+ if (!req.readable) {
171
+ console.error('RawBody request was not readable. This is generally due to bad configuration.');
172
+ throw new common.BadRequestException('Invalid body');
173
+ }
174
+ return [
175
+ 4,
176
+ rawbody(req)
177
+ ];
178
+ case 1:
179
+ body = _state.sent();
180
+ return [
181
+ 2,
182
+ body
183
+ ];
184
+ }
185
+ });
186
+ })();
30
187
  });
31
- const RawBody = common.createParamDecorator(async (_, context) => {
32
- const req = context.switchToHttp().getRequest();
33
- const body = req.body;
34
- if (!Buffer.isBuffer(body)) {
35
- console.error('RawBody expected a buffer set to req.body.');
36
- throw new common.InternalServerErrorException('failed parsing body');
37
- }
38
- return body;
188
+ /**
189
+ * NestJS parameter decorator that retrieves the already-parsed raw body buffer from `req.body`.
190
+ *
191
+ * Expects that a prior middleware (e.g., raw body middleware) has already set `req.body` to a Buffer.
192
+ *
193
+ * @throws {InternalServerErrorException} When `req.body` is not a Buffer
194
+ *
195
+ * @example
196
+ * ```typescript
197
+ * @Post('webhook')
198
+ * handleWebhook(@RawBody() body: RawBodyBuffer) { ... }
199
+ * ```
200
+ */ var RawBody = common.createParamDecorator(function(_, context) {
201
+ return _async_to_generator(function() {
202
+ var req, body;
203
+ return _ts_generator(this, function(_state) {
204
+ req = context.switchToHttp().getRequest();
205
+ body = req.body;
206
+ if (!Buffer.isBuffer(body)) {
207
+ console.error('RawBody expected a buffer set to req.body.');
208
+ throw new common.InternalServerErrorException('failed parsing body');
209
+ }
210
+ return [
211
+ 2,
212
+ body
213
+ ];
214
+ });
215
+ })();
39
216
  });
40
- const ParsedQueryRawBody = common.createParamDecorator(async (_, context) => {
41
- const req = context.switchToHttp().getRequest();
42
- req.body = RawBodyToParsedQueryString(req.body);
43
- return req.body;
217
+ /**
218
+ * NestJS parameter decorator that parses the raw body buffer as a URL-encoded query string
219
+ * and replaces `req.body` with the parsed result.
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * @Post('form')
224
+ * handleForm(@ParsedQueryRawBody() body: ParsedUrlQuery) { ... }
225
+ * ```
226
+ */ var ParsedQueryRawBody = common.createParamDecorator(function(_, context) {
227
+ return _async_to_generator(function() {
228
+ var req;
229
+ return _ts_generator(this, function(_state) {
230
+ req = context.switchToHttp().getRequest();
231
+ req.body = RawBodyToParsedQueryString(req.body);
232
+ return [
233
+ 2,
234
+ req.body
235
+ ];
236
+ });
237
+ })();
44
238
  });
45
- function RawBodyToJson(rawBody) {
46
- const string = RawBodyToString(rawBody);
239
+ /**
240
+ * Parses a raw body buffer as JSON.
241
+ *
242
+ * @param rawBody - The raw body buffer to parse
243
+ * @returns The parsed JSON object
244
+ * @throws {SyntaxError} When the body is not valid JSON
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * const data = RawBodyToJson<{ id: string }>(rawBody);
249
+ * ```
250
+ */ function RawBodyToJson(rawBody) {
251
+ var string = RawBodyToString(rawBody);
47
252
  return JSON.parse(string);
48
253
  }
49
- function RawBodyToParsedQueryString(rawBody) {
50
- const string = RawBodyToString(rawBody);
254
+ /**
255
+ * Parses a raw body buffer as a URL-encoded query string.
256
+ *
257
+ * @param rawBody - The raw body buffer to parse
258
+ * @returns The parsed query parameters
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * const params = RawBodyToParsedQueryString(rawBody); // { key: "value" }
263
+ * ```
264
+ */ function RawBodyToParsedQueryString(rawBody) {
265
+ var string = RawBodyToString(rawBody);
51
266
  return querystring.parse(string);
52
267
  }
53
- function RawBodyToString(rawBody) {
268
+ /**
269
+ * Converts a raw body buffer to a trimmed UTF-8 string.
270
+ *
271
+ * @param rawBody - The raw body buffer to convert
272
+ * @returns The decoded and trimmed string content
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * const text = RawBodyToString(rawBody);
277
+ * ```
278
+ */ function RawBodyToString(rawBody) {
54
279
  return rawBody.toString('utf8').trim();
55
280
  }
56
281
 
57
- /******************************************************************************
58
- Copyright (c) Microsoft Corporation.
59
-
60
- Permission to use, copy, modify, and/or distribute this software for any
61
- purpose with or without fee is hereby granted.
62
-
63
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
64
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
65
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
66
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
67
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
68
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
69
- PERFORMANCE OF THIS SOFTWARE.
70
- ***************************************************************************** */
71
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
72
-
73
-
74
- function __decorate(decorators, target, key, desc) {
75
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
76
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
77
- 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;
78
- return c > 3 && r && Object.defineProperty(target, key, r), r;
79
- }
80
-
81
- function __param(paramIndex, decorator) {
82
- return function (target, key) { decorator(target, key, paramIndex); }
83
- }
84
-
85
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
86
- var e = new Error(message);
87
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
282
+ function _type_of$2(obj) {
283
+ "@swc/helpers - typeof";
284
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
285
+ }
286
+ function __decorate(decorators, target, key, desc) {
287
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
288
+ if ((typeof Reflect === "undefined" ? "undefined" : _type_of$2(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
289
+ 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;
290
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
291
+ }
292
+ function __param(paramIndex, decorator) {
293
+ return function(target, key) {
294
+ decorator(target, key, paramIndex);
295
+ };
296
+ }
297
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
298
+ var e = new Error(message);
299
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
88
300
  };
89
301
 
90
- exports.JsonBodyMiddleware = class JsonBodyMiddleware {
91
- use(req, res, next) {
92
- bodyParser.json()(req, res, next);
302
+ function _class_call_check$7(instance, Constructor) {
303
+ if (!(instance instanceof Constructor)) {
304
+ throw new TypeError("Cannot call a class as a function");
93
305
  }
94
- };
306
+ }
307
+ function _defineProperties$5(target, props) {
308
+ for(var i = 0; i < props.length; i++){
309
+ var descriptor = props[i];
310
+ descriptor.enumerable = descriptor.enumerable || false;
311
+ descriptor.configurable = true;
312
+ if ("value" in descriptor) descriptor.writable = true;
313
+ Object.defineProperty(target, descriptor.key, descriptor);
314
+ }
315
+ }
316
+ function _create_class$5(Constructor, protoProps, staticProps) {
317
+ if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
318
+ return Constructor;
319
+ }
320
+ /**
321
+ * NestJS middleware that applies JSON body parsing to incoming requests using `body-parser`.
322
+ *
323
+ * Useful when the global body parser is disabled and JSON parsing needs to be applied selectively to specific routes.
324
+ *
325
+ * @example
326
+ * ```typescript
327
+ * consumer.apply(JsonBodyMiddleware).forRoutes('api');
328
+ * ```
329
+ */ exports.JsonBodyMiddleware = /*#__PURE__*/ function() {
330
+ function JsonBodyMiddleware() {
331
+ _class_call_check$7(this, JsonBodyMiddleware);
332
+ }
333
+ _create_class$5(JsonBodyMiddleware, [
334
+ {
335
+ key: "use",
336
+ value: function use(req, res, next) {
337
+ bodyParser.json()(req, res, next);
338
+ }
339
+ }
340
+ ]);
341
+ return JsonBodyMiddleware;
342
+ }();
95
343
  exports.JsonBodyMiddleware = __decorate([
96
344
  common.Injectable()
97
345
  ], exports.JsonBodyMiddleware);
98
346
 
99
- exports.RawBodyMiddleware = class RawBodyMiddleware {
100
- use(req, res, next) {
101
- bodyParser.raw({ type: '*/*' })(req, res, next);
347
+ function _class_call_check$6(instance, Constructor) {
348
+ if (!(instance instanceof Constructor)) {
349
+ throw new TypeError("Cannot call a class as a function");
102
350
  }
103
- };
351
+ }
352
+ function _defineProperties$4(target, props) {
353
+ for(var i = 0; i < props.length; i++){
354
+ var descriptor = props[i];
355
+ descriptor.enumerable = descriptor.enumerable || false;
356
+ descriptor.configurable = true;
357
+ if ("value" in descriptor) descriptor.writable = true;
358
+ Object.defineProperty(target, descriptor.key, descriptor);
359
+ }
360
+ }
361
+ function _create_class$4(Constructor, protoProps, staticProps) {
362
+ if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
363
+ return Constructor;
364
+ }
365
+ exports.RawBodyMiddleware = /*#__PURE__*/ function() {
366
+ function RawBodyMiddleware() {
367
+ _class_call_check$6(this, RawBodyMiddleware);
368
+ }
369
+ _create_class$4(RawBodyMiddleware, [
370
+ {
371
+ key: "use",
372
+ value: function use(req, res, next) {
373
+ bodyParser.raw({
374
+ type: '*/*'
375
+ })(req, res, next);
376
+ }
377
+ }
378
+ ]);
379
+ return RawBodyMiddleware;
380
+ }();
104
381
  exports.RawBodyMiddleware = __decorate([
105
382
  common.Injectable()
106
383
  ], exports.RawBodyMiddleware);
107
384
 
108
- const DEFAULT_BASE_WEBHOOK_PATH = '/webhook';
109
- const DEFAULT_WEBHOOK_MIDDLEWARE_ROUTE_INFO = {
110
- path: `${DEFAULT_BASE_WEBHOOK_PATH}/*`,
385
+ function _assert_this_initialized(self) {
386
+ if (self === void 0) {
387
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
388
+ }
389
+ return self;
390
+ }
391
+ function _call_super(_this, derived, args) {
392
+ derived = _get_prototype_of(derived);
393
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
394
+ }
395
+ function _class_call_check$5(instance, Constructor) {
396
+ if (!(instance instanceof Constructor)) {
397
+ throw new TypeError("Cannot call a class as a function");
398
+ }
399
+ }
400
+ function _defineProperties$3(target, props) {
401
+ for(var i = 0; i < props.length; i++){
402
+ var descriptor = props[i];
403
+ descriptor.enumerable = descriptor.enumerable || false;
404
+ descriptor.configurable = true;
405
+ if ("value" in descriptor) descriptor.writable = true;
406
+ Object.defineProperty(target, descriptor.key, descriptor);
407
+ }
408
+ }
409
+ function _create_class$3(Constructor, protoProps, staticProps) {
410
+ if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
411
+ return Constructor;
412
+ }
413
+ function _define_property$3(obj, key, value) {
414
+ if (key in obj) {
415
+ Object.defineProperty(obj, key, {
416
+ value: value,
417
+ enumerable: true,
418
+ configurable: true,
419
+ writable: true
420
+ });
421
+ } else {
422
+ obj[key] = value;
423
+ }
424
+ return obj;
425
+ }
426
+ function _get(target, property, receiver) {
427
+ if (typeof Reflect !== "undefined" && Reflect.get) {
428
+ _get = Reflect.get;
429
+ } else {
430
+ _get = function get(target, property, receiver) {
431
+ var base = _super_prop_base(target, property);
432
+ if (!base) return;
433
+ var desc = Object.getOwnPropertyDescriptor(base, property);
434
+ if (desc.get) {
435
+ return desc.get.call(receiver || target);
436
+ }
437
+ return desc.value;
438
+ };
439
+ }
440
+ return _get(target, property, receiver || target);
441
+ }
442
+ function _get_prototype_of(o) {
443
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
444
+ return o.__proto__ || Object.getPrototypeOf(o);
445
+ };
446
+ return _get_prototype_of(o);
447
+ }
448
+ function _inherits(subClass, superClass) {
449
+ if (typeof superClass !== "function" && superClass !== null) {
450
+ throw new TypeError("Super expression must either be null or a function");
451
+ }
452
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
453
+ constructor: {
454
+ value: subClass,
455
+ writable: true,
456
+ configurable: true
457
+ }
458
+ });
459
+ if (superClass) _set_prototype_of(subClass, superClass);
460
+ }
461
+ function _possible_constructor_return(self, call) {
462
+ if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
463
+ return call;
464
+ }
465
+ return _assert_this_initialized(self);
466
+ }
467
+ function _set_prototype_of(o, p) {
468
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
469
+ o.__proto__ = p;
470
+ return o;
471
+ };
472
+ return _set_prototype_of(o, p);
473
+ }
474
+ function _super_prop_base(object, property) {
475
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
476
+ object = _get_prototype_of(object);
477
+ if (object === null) break;
478
+ }
479
+ return object;
480
+ }
481
+ function _type_of$1(obj) {
482
+ "@swc/helpers - typeof";
483
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
484
+ }
485
+ function _is_native_reflect_construct() {
486
+ try {
487
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
488
+ } catch (_) {}
489
+ return (_is_native_reflect_construct = function() {
490
+ return !!result;
491
+ })();
492
+ }
493
+ var DEFAULT_BASE_WEBHOOK_PATH = '/webhook';
494
+ var DEFAULT_WEBHOOK_MIDDLEWARE_ROUTE_INFO = {
495
+ path: "".concat(DEFAULT_BASE_WEBHOOK_PATH, "/{*path}"),
111
496
  method: common.RequestMethod.POST
112
497
  };
113
498
  /**
114
499
  * Convenience class that configures a nestjs module (typically the root app module) to apply the proper middleware for handling webhooks.
115
- */
116
- class AppModuleWithWebhooksEnabled {
117
- configure(consumer) {
118
- consumeWebhooksWithRawBodyMiddleware(consumer);
500
+ */ var AppModuleWithWebhooksEnabled = /*#__PURE__*/ function() {
501
+ function AppModuleWithWebhooksEnabled() {
502
+ _class_call_check$5(this, AppModuleWithWebhooksEnabled);
119
503
  }
120
- }
504
+ _create_class$3(AppModuleWithWebhooksEnabled, [
505
+ {
506
+ key: "configure",
507
+ value: function configure(consumer) {
508
+ consumeWebhooksWithRawBodyMiddleware(consumer);
509
+ }
510
+ }
511
+ ]);
512
+ return AppModuleWithWebhooksEnabled;
513
+ }();
121
514
  /**
122
515
  * Convenience class that extends AppWithWebhooksEnabled.
123
- */
124
- exports.ConfigureWebhookMiddlewareModule = class ConfigureWebhookMiddlewareModule extends AppModuleWithWebhooksEnabled {
125
- logger = new common.Logger('ConfigureWebhookMiddlewareModule');
126
- configure(consumer) {
127
- super.configure(consumer);
128
- this.logger.debug('Configured webhook routes with proper middleware.');
516
+ */ exports.ConfigureWebhookMiddlewareModule = /*#__PURE__*/ function(AppModuleWithWebhooksEnabled) {
517
+ _inherits(ConfigureWebhookMiddlewareModule, AppModuleWithWebhooksEnabled);
518
+ function ConfigureWebhookMiddlewareModule() {
519
+ _class_call_check$5(this, ConfigureWebhookMiddlewareModule);
520
+ var _this;
521
+ _this = _call_super(this, ConfigureWebhookMiddlewareModule, arguments), _define_property$3(_this, "logger", new common.Logger('ConfigureWebhookMiddlewareModule'));
522
+ return _this;
129
523
  }
130
- };
524
+ _create_class$3(ConfigureWebhookMiddlewareModule, [
525
+ {
526
+ key: "configure",
527
+ value: function configure(consumer) {
528
+ _get(_get_prototype_of(ConfigureWebhookMiddlewareModule.prototype), "configure", this).call(this, consumer);
529
+ this.logger.debug('Configured webhook routes with proper middleware.');
530
+ }
531
+ }
532
+ ]);
533
+ return ConfigureWebhookMiddlewareModule;
534
+ }(AppModuleWithWebhooksEnabled);
131
535
  exports.ConfigureWebhookMiddlewareModule = __decorate([
132
536
  common.Module({})
133
537
  ], exports.ConfigureWebhookMiddlewareModule);
134
538
  /**
135
- * Configures a MiddlewareConsumer to use RawBodyMiddleware for all POST requests to /webhook/*. All other routes are consumed with the JsonBodyMiddleware.
539
+ * Configures a MiddlewareConsumer to use RawBodyMiddleware for all POST requests to /webhook/{*path}. All other routes are consumed with the JsonBodyMiddleware.
136
540
  *
137
541
  * This is required for various webhooks that require the full body to properly parse content.
138
542
  *
139
543
  * Be sure to also set bodyParsing: false in the nest app options.
140
544
  *
141
545
  * @param consumer
142
- */
143
- function consumeWebhooksWithRawBodyMiddleware(consumer) {
546
+ */ function consumeWebhooksWithRawBodyMiddleware(consumer) {
144
547
  // Configure the app to not parse the body for our webhook routes.
145
548
  // https://stackoverflow.com/questions/54346465/access-raw-body-of-stripe-webhook-in-nest-js
146
- consumer.apply(exports.RawBodyMiddleware).forRoutes(DEFAULT_WEBHOOK_MIDDLEWARE_ROUTE_INFO).apply(exports.JsonBodyMiddleware).forRoutes('*');
549
+ consumer.apply(exports.RawBodyMiddleware).forRoutes(DEFAULT_WEBHOOK_MIDDLEWARE_ROUTE_INFO).apply(exports.JsonBodyMiddleware).forRoutes('{*path}');
147
550
  }
148
551
 
552
+ function _type_of(obj) {
553
+ "@swc/helpers - typeof";
554
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
555
+ }
149
556
  /**
150
557
  * Merges two module metadata entries together.
151
558
  *
152
559
  * @param base
153
560
  * @param additional
154
561
  * @returns
155
- */
156
- function mergeModuleMetadata(base, additional = {}) {
562
+ */ function mergeModuleMetadata(base) {
563
+ var additional = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
157
564
  return {
158
- controllers: util.mergeArrays([base.controllers, additional.controllers]),
159
- imports: util.mergeArrays([base.imports, additional.imports]),
160
- exports: util.mergeArrays([base.exports, additional.exports]),
161
- providers: util.mergeArrays([base.providers, additional.providers])
565
+ controllers: util.mergeArrays([
566
+ base.controllers,
567
+ additional.controllers
568
+ ]),
569
+ imports: util.mergeArrays([
570
+ base.imports,
571
+ additional.imports
572
+ ]),
573
+ exports: util.mergeArrays([
574
+ base.exports,
575
+ additional.exports
576
+ ]),
577
+ providers: util.mergeArrays([
578
+ base.providers,
579
+ additional.providers
580
+ ])
162
581
  };
163
582
  }
164
583
  function injectionTokensFromProviders(providers) {
165
- return util.asArray(providers).map((x) => {
166
- return typeof x === 'object' ? x.provide : x;
584
+ return util.asArray(providers).map(function(x) {
585
+ return (typeof x === "undefined" ? "undefined" : _type_of(x)) === 'object' ? x.provide : x;
167
586
  });
168
587
  }
169
588
 
170
589
  /**
171
590
  * Environment variable that specfies the ClientWebAppUrl for your application
172
- */
173
- const CLIENT_WEB_APP_URL_ENV_VAR = 'CLIENT_WEB_APP_URL';
591
+ */ var CLIENT_WEB_APP_URL_ENV_VAR = 'CLIENT_WEB_APP_URL';
174
592
 
175
- class ClientAppServiceConfig {
176
- client;
177
- static assertValidConfig(config) {
178
- if (!config.client.clientWebAppUrl) {
179
- throw new Error('No client app url specified.');
180
- }
593
+ function _class_call_check$4(instance, Constructor) {
594
+ if (!(instance instanceof Constructor)) {
595
+ throw new TypeError("Cannot call a class as a function");
181
596
  }
182
597
  }
183
-
598
+ function _defineProperties$2(target, props) {
599
+ for(var i = 0; i < props.length; i++){
600
+ var descriptor = props[i];
601
+ descriptor.enumerable = descriptor.enumerable || false;
602
+ descriptor.configurable = true;
603
+ if ("value" in descriptor) descriptor.writable = true;
604
+ Object.defineProperty(target, descriptor.key, descriptor);
605
+ }
606
+ }
607
+ function _create_class$2(Constructor, protoProps, staticProps) {
608
+ if (staticProps) _defineProperties$2(Constructor, staticProps);
609
+ return Constructor;
610
+ }
611
+ function _define_property$2(obj, key, value) {
612
+ if (key in obj) {
613
+ Object.defineProperty(obj, key, {
614
+ value: value,
615
+ enumerable: true,
616
+ configurable: true,
617
+ writable: true
618
+ });
619
+ } else {
620
+ obj[key] = value;
621
+ }
622
+ return obj;
623
+ }
184
624
  /**
185
- * Provides information about companion apps and websites for the project.
186
- */
187
- exports.ClientAppService = class ClientAppService {
188
- _config;
189
- constructor(config) {
190
- this._config = config;
625
+ * Abstract service configuration that provides access to the client application config.
626
+ *
627
+ * Subclass this to supply environment-specific client URLs to NestJS services.
628
+ */ var ClientAppServiceConfig = /*#__PURE__*/ function() {
629
+ function ClientAppServiceConfig() {
630
+ _class_call_check$4(this, ClientAppServiceConfig);
631
+ _define_property$2(this, "client", void 0);
191
632
  }
192
- get config() {
193
- return this._config;
633
+ _create_class$2(ClientAppServiceConfig, null, [
634
+ {
635
+ key: "assertValidConfig",
636
+ value: /**
637
+ * Validates that the configuration contains a non-empty client web app URL.
638
+ *
639
+ * @param config - The configuration to validate
640
+ * @throws {Error} When `clientWebAppUrl` is not specified
641
+ */ function assertValidConfig(config) {
642
+ if (!config.client.clientWebAppUrl) {
643
+ throw new Error('No client app url specified.');
644
+ }
645
+ }
646
+ }
647
+ ]);
648
+ return ClientAppServiceConfig;
649
+ }
650
+ ();
651
+
652
+ function _class_call_check$3(instance, Constructor) {
653
+ if (!(instance instanceof Constructor)) {
654
+ throw new TypeError("Cannot call a class as a function");
194
655
  }
195
- get webAppUrl() {
196
- return this.config.client.clientWebAppUrl;
656
+ }
657
+ function _defineProperties$1(target, props) {
658
+ for(var i = 0; i < props.length; i++){
659
+ var descriptor = props[i];
660
+ descriptor.enumerable = descriptor.enumerable || false;
661
+ descriptor.configurable = true;
662
+ if ("value" in descriptor) descriptor.writable = true;
663
+ Object.defineProperty(target, descriptor.key, descriptor);
197
664
  }
198
- get webAppHost() {
199
- return this.webAppUrl.split('://', 2)[1];
665
+ }
666
+ function _create_class$1(Constructor, protoProps, staticProps) {
667
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
668
+ return Constructor;
669
+ }
670
+ function _define_property$1(obj, key, value) {
671
+ if (key in obj) {
672
+ Object.defineProperty(obj, key, {
673
+ value: value,
674
+ enumerable: true,
675
+ configurable: true,
676
+ writable: true
677
+ });
678
+ } else {
679
+ obj[key] = value;
200
680
  }
201
- };
681
+ return obj;
682
+ }
683
+ /**
684
+ * Provides information about companion apps and websites for the project.
685
+ */ exports.ClientAppService = /*#__PURE__*/ function() {
686
+ function ClientAppService(config) {
687
+ _class_call_check$3(this, ClientAppService);
688
+ _define_property$1(this, "_config", void 0);
689
+ this._config = config;
690
+ }
691
+ _create_class$1(ClientAppService, [
692
+ {
693
+ key: "config",
694
+ get: function get() {
695
+ return this._config;
696
+ }
697
+ },
698
+ {
699
+ key: "webAppUrl",
700
+ get: function get() {
701
+ return this.config.client.clientWebAppUrl;
702
+ }
703
+ },
704
+ {
705
+ key: "webAppHost",
706
+ get: function get() {
707
+ return this.webAppUrl.split('://', 2)[1];
708
+ }
709
+ }
710
+ ]);
711
+ return ClientAppService;
712
+ }();
202
713
  exports.ClientAppService = __decorate([
203
714
  common.Injectable(),
204
715
  __param(0, common.Inject(ClientAppServiceConfig))
205
716
  ], exports.ClientAppService);
206
717
 
718
+ function _class_call_check$2(instance, Constructor) {
719
+ if (!(instance instanceof Constructor)) {
720
+ throw new TypeError("Cannot call a class as a function");
721
+ }
722
+ }
207
723
  function clientAppConfigFactory(configService) {
208
- const config = {
724
+ var config = {
209
725
  client: {
210
726
  clientWebAppUrl: configService.get(CLIENT_WEB_APP_URL_ENV_VAR)
211
727
  }
@@ -213,37 +729,49 @@ function clientAppConfigFactory(configService) {
213
729
  ClientAppServiceConfig.assertValidConfig(config);
214
730
  return config;
215
731
  }
216
- exports.ClientAppModule = class ClientAppModule {
732
+ exports.ClientAppModule = function ClientAppModule() {
733
+ _class_call_check$2(this, ClientAppModule);
217
734
  };
218
735
  exports.ClientAppModule = __decorate([
219
736
  common.Module({
220
- imports: [config.ConfigModule],
737
+ imports: [
738
+ config.ConfigModule
739
+ ],
221
740
  providers: [
222
741
  {
223
742
  provide: ClientAppServiceConfig,
224
- inject: [config.ConfigService],
743
+ inject: [
744
+ config.ConfigService
745
+ ],
225
746
  useFactory: clientAppConfigFactory
226
747
  }
227
748
  ],
228
- exports: [exports.ClientAppService]
749
+ exports: [
750
+ exports.ClientAppService
751
+ ]
229
752
  })
230
753
  ], exports.ClientAppModule);
231
754
 
755
+ function _class_call_check$1(instance, Constructor) {
756
+ if (!(instance instanceof Constructor)) {
757
+ throw new TypeError("Cannot call a class as a function");
758
+ }
759
+ }
232
760
  /**
233
761
  * A server environment configuration.
234
762
  *
235
763
  * Explicitly states whether or not this is a production environment, and optionally some other config.
236
764
  *
237
765
  * This config is not meant to replace other typical configurations, like .env files, but instead is part of the build system.
238
- */
239
- class ServerEnvironmentConfig {
240
- }
766
+ */ var ServerEnvironmentConfig = function ServerEnvironmentConfig() {
767
+ _class_call_check$1(this, ServerEnvironmentConfig);
768
+ }
769
+ ;
241
770
 
242
771
  // MARK: Tokens
243
772
  /**
244
773
  * Token to access a configured ServerEnvironmentServiceConfig for the app.
245
- */
246
- const SERVER_ENV_TOKEN = 'SERVER_ENV_TOKEN';
774
+ */ var SERVER_ENV_TOKEN = 'SERVER_ENV_TOKEN';
247
775
  function serverEnvTokenProvider(env) {
248
776
  return {
249
777
  provide: SERVER_ENV_TOKEN,
@@ -253,34 +781,274 @@ function serverEnvTokenProvider(env) {
253
781
 
254
782
  /**
255
783
  * Checks process.env.NODE_ENV for "test"
256
- */
257
- function isTestNodeEnv() {
784
+ */ function isTestNodeEnv() {
258
785
  return process.env['NODE_ENV'] === 'test';
259
786
  }
260
787
 
261
- exports.ServerEnvironmentService = class ServerEnvironmentService {
262
- env;
263
- constructor(env) {
264
- this.env = env;
265
- }
266
- get isTestingEnv() {
267
- return isTestNodeEnv();
788
+ function _class_call_check(instance, Constructor) {
789
+ if (!(instance instanceof Constructor)) {
790
+ throw new TypeError("Cannot call a class as a function");
268
791
  }
269
- get isProduction() {
270
- return this.env.production;
792
+ }
793
+ function _defineProperties(target, props) {
794
+ for(var i = 0; i < props.length; i++){
795
+ var descriptor = props[i];
796
+ descriptor.enumerable = descriptor.enumerable || false;
797
+ descriptor.configurable = true;
798
+ if ("value" in descriptor) descriptor.writable = true;
799
+ Object.defineProperty(target, descriptor.key, descriptor);
271
800
  }
272
- get isStaging() {
273
- return Boolean(this.env.staging);
801
+ }
802
+ function _create_class(Constructor, protoProps, staticProps) {
803
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
804
+ return Constructor;
805
+ }
806
+ function _define_property(obj, key, value) {
807
+ if (key in obj) {
808
+ Object.defineProperty(obj, key, {
809
+ value: value,
810
+ enumerable: true,
811
+ configurable: true,
812
+ writable: true
813
+ });
814
+ } else {
815
+ obj[key] = value;
274
816
  }
275
- get developerToolsEnabled() {
276
- return Boolean(!this.isProduction && this.env.developerToolsEnabled);
817
+ return obj;
818
+ }
819
+ exports.ServerEnvironmentService = /*#__PURE__*/ function() {
820
+ function ServerEnvironmentService(env) {
821
+ _class_call_check(this, ServerEnvironmentService);
822
+ _define_property(this, "env", void 0);
823
+ this.env = env;
277
824
  }
278
- };
825
+ _create_class(ServerEnvironmentService, [
826
+ {
827
+ key: "isTestingEnv",
828
+ get: function get() {
829
+ return isTestNodeEnv();
830
+ }
831
+ },
832
+ {
833
+ key: "isProduction",
834
+ get: function get() {
835
+ return this.env.production;
836
+ }
837
+ },
838
+ {
839
+ key: "isStaging",
840
+ get: function get() {
841
+ return Boolean(this.env.staging);
842
+ }
843
+ },
844
+ {
845
+ key: "developerToolsEnabled",
846
+ get: function get() {
847
+ return Boolean(!this.isProduction && this.env.developerToolsEnabled);
848
+ }
849
+ },
850
+ {
851
+ key: "appUrl",
852
+ get: function get() {
853
+ return this.env.appUrl;
854
+ }
855
+ }
856
+ ]);
857
+ return ServerEnvironmentService;
858
+ }();
279
859
  exports.ServerEnvironmentService = __decorate([
280
860
  common.Injectable(),
281
861
  __param(0, common.Inject(SERVER_ENV_TOKEN))
282
862
  ], exports.ServerEnvironmentService);
283
863
 
864
+ // MARK: Constants
865
+ /**
866
+ * AES-256-GCM encryption constants.
867
+ */ var ENCRYPTED_FIELD_ALGORITHM = 'aes-256-gcm';
868
+ var ENCRYPTED_FIELD_IV_LENGTH = 12;
869
+ var ENCRYPTED_FIELD_AUTH_TAG_LENGTH = 16;
870
+ var ENCRYPTED_FIELD_KEY_LENGTH = 32;
871
+ /**
872
+ * Validates that the given secret is a 64-character hexadecimal string (32 bytes for AES-256).
873
+ *
874
+ * @example
875
+ * ```typescript
876
+ * isValidAES256GCMEncryptionSecret('a'.repeat(64)); // true
877
+ * isValidAES256GCMEncryptionSecret('too-short'); // false
878
+ * ```
879
+ */ function isValidAES256GCMEncryptionSecret(secret) {
880
+ return secret.length === ENCRYPTED_FIELD_KEY_LENGTH * 2 && util.isHex(secret);
881
+ }
882
+ // MARK: Key Resolution
883
+ /**
884
+ * Factory that eagerly resolves and validates the encryption key from a secret source.
885
+ *
886
+ * The getter is called immediately and the key is validated on creation. The returned
887
+ * function provides the resolved Buffer without re-resolving or re-validating.
888
+ *
889
+ * @example
890
+ * ```typescript
891
+ * const getKey = resolveEncryptionKey('a'.repeat(64));
892
+ * const key: Buffer = getKey();
893
+ * ```
894
+ *
895
+ * @param source - The secret source configuration.
896
+ * @returns A getter that returns the resolved 32-byte Buffer for AES-256 encryption.
897
+ * @throws Error if the resolved key is not 64 hex characters.
898
+ */ function resolveEncryptionKey(source) {
899
+ var hex = util.getValueFromGetter(source);
900
+ if (!isValidAES256GCMEncryptionSecret(hex)) {
901
+ throw new Error("resolveEncryptionKey: expected a ".concat(ENCRYPTED_FIELD_KEY_LENGTH * 2, "-character hexadecimal key, got ").concat(hex.length, " characters. Ensure the key contains only hex characters (0-9, a-f)."));
902
+ }
903
+ var key = Buffer.from(hex, 'hex');
904
+ return function() {
905
+ return key;
906
+ };
907
+ }
908
+ /**
909
+ * Creates an `AES256GCMEncryption` instance that captures the resolved key in a closure.
910
+ *
911
+ * @example
912
+ * ```typescript
913
+ * const encryption = createAES256GCMEncryption('a'.repeat(64));
914
+ *
915
+ * const encrypted = encryption.encryptValue({ sensitive: 'data' });
916
+ * const decrypted = encryption.decryptValue<{ sensitive: string }>(encrypted);
917
+ *
918
+ * const encryptedStr = encryption.encryptString('hello');
919
+ * const decryptedStr = encryption.decryptString(encryptedStr);
920
+ * // decryptedStr === 'hello'
921
+ * ```
922
+ *
923
+ * @param source - The hex-encoded secret or getter for the AES-256 key.
924
+ * @returns An `AES256GCMEncryption` instance.
925
+ * @throws Error if the resolved key is not 64 hex characters.
926
+ */ function createAES256GCMEncryption(source) {
927
+ var getKey = resolveEncryptionKey(source);
928
+ function encryptStringFn(plaintext) {
929
+ var key = getKey();
930
+ var iv = crypto.randomBytes(ENCRYPTED_FIELD_IV_LENGTH);
931
+ var cipher = crypto.createCipheriv(ENCRYPTED_FIELD_ALGORITHM, key, iv);
932
+ var encrypted = Buffer.concat([
933
+ cipher.update(plaintext, 'utf8'),
934
+ cipher.final()
935
+ ]);
936
+ var authTag = cipher.getAuthTag();
937
+ var combined = Buffer.concat([
938
+ iv,
939
+ encrypted,
940
+ authTag
941
+ ]);
942
+ return combined.toString('base64');
943
+ }
944
+ function decryptStringFn(encoded) {
945
+ var key = getKey();
946
+ var combined = Buffer.from(encoded, 'base64');
947
+ var iv = combined.subarray(0, ENCRYPTED_FIELD_IV_LENGTH);
948
+ var authTag = combined.subarray(combined.length - ENCRYPTED_FIELD_AUTH_TAG_LENGTH);
949
+ var ciphertext = combined.subarray(ENCRYPTED_FIELD_IV_LENGTH, combined.length - ENCRYPTED_FIELD_AUTH_TAG_LENGTH);
950
+ var decipher = crypto.createDecipheriv(ENCRYPTED_FIELD_ALGORITHM, key, iv);
951
+ decipher.setAuthTag(authTag);
952
+ var decrypted = Buffer.concat([
953
+ decipher.update(ciphertext),
954
+ decipher.final()
955
+ ]);
956
+ return decrypted.toString('utf8');
957
+ }
958
+ var result = {
959
+ encryptString: encryptStringFn,
960
+ decryptString: decryptStringFn,
961
+ encryptValue: function encryptValue(value) {
962
+ return encryptStringFn(JSON.stringify(value));
963
+ },
964
+ decryptValue: function decryptValue(encoded) {
965
+ return JSON.parse(decryptStringFn(encoded));
966
+ }
967
+ };
968
+ return result;
969
+ }
970
+ // MARK: Standalone Functions (backwards compatibility)
971
+ /**
972
+ * Encrypts a JSON-serializable value to a base64-encoded string using AES-256-GCM.
973
+ *
974
+ * Format: base64(IV (12 bytes) + ciphertext + authTag (16 bytes))
975
+ *
976
+ * @example
977
+ * ```typescript
978
+ * const getKey = resolveEncryptionKey(mySecret);
979
+ * const encrypted = encryptValue({ sensitive: 'data' }, getKey());
980
+ * const decrypted = decryptValue<{ sensitive: string }>(encrypted, getKey());
981
+ * ```
982
+ *
983
+ * @param value - The value to encrypt (must be JSON-serializable).
984
+ * @param key - The 32-byte encryption key from `resolveEncryptionKey()`.
985
+ * @returns The encrypted value as a base64 string.
986
+ */ function encryptValue(value, key) {
987
+ var iv = crypto.randomBytes(ENCRYPTED_FIELD_IV_LENGTH);
988
+ var cipher = crypto.createCipheriv(ENCRYPTED_FIELD_ALGORITHM, key, iv);
989
+ var plaintext = JSON.stringify(value);
990
+ var encrypted = Buffer.concat([
991
+ cipher.update(plaintext, 'utf8'),
992
+ cipher.final()
993
+ ]);
994
+ var authTag = cipher.getAuthTag();
995
+ var combined = Buffer.concat([
996
+ iv,
997
+ encrypted,
998
+ authTag
999
+ ]);
1000
+ return combined.toString('base64');
1001
+ }
1002
+ /**
1003
+ * Decrypts a base64-encoded string back to the original value.
1004
+ *
1005
+ * @param encoded - The base64-encoded encrypted string (IV + ciphertext + authTag).
1006
+ * @param key - The 32-byte encryption key Buffer from calling the getter returned by `resolveEncryptionKey()`.
1007
+ * @returns The decrypted JSON-parsed value.
1008
+ */ function decryptValue(encoded, key) {
1009
+ var combined = Buffer.from(encoded, 'base64');
1010
+ var iv = combined.subarray(0, ENCRYPTED_FIELD_IV_LENGTH);
1011
+ var authTag = combined.subarray(combined.length - ENCRYPTED_FIELD_AUTH_TAG_LENGTH);
1012
+ var ciphertext = combined.subarray(ENCRYPTED_FIELD_IV_LENGTH, combined.length - ENCRYPTED_FIELD_AUTH_TAG_LENGTH);
1013
+ var decipher = crypto.createDecipheriv(ENCRYPTED_FIELD_ALGORITHM, key, iv);
1014
+ decipher.setAuthTag(authTag);
1015
+ var decrypted = Buffer.concat([
1016
+ decipher.update(ciphertext),
1017
+ decipher.final()
1018
+ ]);
1019
+ return JSON.parse(decrypted.toString('utf8'));
1020
+ }
1021
+ // MARK: StringEncryptionProvider
1022
+ /**
1023
+ * Creates a `StringEncryptionProvider` backed by AES-256-GCM from a secret source.
1024
+ *
1025
+ * The key is resolved and validated eagerly at creation time. The provider encrypts/decrypts
1026
+ * raw strings (no JSON serialization) — suitable for use with `selectiveFieldEncryptor`.
1027
+ *
1028
+ * @example
1029
+ * ```typescript
1030
+ * const provider = createAesStringEncryptionProvider('a'.repeat(64));
1031
+ * const encrypted = provider.encrypt('sensitive data');
1032
+ * const decrypted = provider.decrypt(encrypted);
1033
+ * // decrypted === 'sensitive data'
1034
+ * ```
1035
+ *
1036
+ * @param source - The hex-encoded secret or getter for the AES-256 key.
1037
+ * @returns A `StringEncryptionProvider` that encrypts/decrypts strings via AES-256-GCM.
1038
+ * @throws Error if the resolved key is not 64 hex characters.
1039
+ */ function createAesStringEncryptionProvider(source) {
1040
+ var encryption = createAES256GCMEncryption(source);
1041
+ var result = {
1042
+ encrypt: function encrypt(plaintext) {
1043
+ return encryption.encryptString(plaintext);
1044
+ },
1045
+ decrypt: function decrypt(ciphertext) {
1046
+ return encryption.decryptString(ciphertext);
1047
+ }
1048
+ };
1049
+ return result;
1050
+ }
1051
+
284
1052
  exports.AppModuleWithWebhooksEnabled = AppModuleWithWebhooksEnabled;
285
1053
  exports.CLIENT_WEB_APP_URL_ENV_VAR = CLIENT_WEB_APP_URL_ENV_VAR;
286
1054
  exports.ClientAppServiceConfig = ClientAppServiceConfig;
@@ -297,8 +1065,14 @@ exports.SERVER_ENV_TOKEN = SERVER_ENV_TOKEN;
297
1065
  exports.ServerEnvironmentConfig = ServerEnvironmentConfig;
298
1066
  exports.clientAppConfigFactory = clientAppConfigFactory;
299
1067
  exports.consumeWebhooksWithRawBodyMiddleware = consumeWebhooksWithRawBodyMiddleware;
1068
+ exports.createAES256GCMEncryption = createAES256GCMEncryption;
1069
+ exports.createAesStringEncryptionProvider = createAesStringEncryptionProvider;
1070
+ exports.decryptValue = decryptValue;
1071
+ exports.encryptValue = encryptValue;
300
1072
  exports.injectionTokensFromProviders = injectionTokensFromProviders;
301
1073
  exports.isLocalhost = isLocalhost;
302
1074
  exports.isTestNodeEnv = isTestNodeEnv;
1075
+ exports.isValidAES256GCMEncryptionSecret = isValidAES256GCMEncryptionSecret;
303
1076
  exports.mergeModuleMetadata = mergeModuleMetadata;
1077
+ exports.resolveEncryptionKey = resolveEncryptionKey;
304
1078
  exports.serverEnvTokenProvider = serverEnvTokenProvider;