@tstdl/base 0.82.6 → 0.82.8

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.
Files changed (169) hide show
  1. package/api/client/client.js +2 -1
  2. package/api/client/client.js.map +1 -1
  3. package/api/types.d.ts +3 -3
  4. package/authentication/authentication.api.d.ts +98 -14
  5. package/authentication/authentication.api.js +31 -27
  6. package/authentication/authentication.api.js.map +1 -1
  7. package/authentication/client/api.client.d.ts +50 -0
  8. package/authentication/client/api.client.js +27 -0
  9. package/authentication/client/api.client.js.map +1 -0
  10. package/authentication/client/authentication.service.d.ts +39 -0
  11. package/authentication/client/authentication.service.js +176 -0
  12. package/authentication/client/authentication.service.js.map +1 -0
  13. package/authentication/client/index.d.ts +4 -0
  14. package/authentication/client/index.js +21 -0
  15. package/authentication/client/index.js.map +1 -0
  16. package/authentication/client/module.d.ts +8 -0
  17. package/authentication/client/module.js +16 -0
  18. package/authentication/client/module.js.map +1 -0
  19. package/authentication/client/tokens.d.ts +4 -0
  20. package/authentication/client/tokens.js +7 -0
  21. package/authentication/client/tokens.js.map +1 -0
  22. package/authentication/index.d.ts +2 -0
  23. package/authentication/index.js +19 -0
  24. package/authentication/index.js.map +1 -0
  25. package/authentication/models/authentication-session.model.d.ts +0 -2
  26. package/authentication/models/authentication-session.model.js +0 -10
  27. package/authentication/models/authentication-session.model.js.map +1 -1
  28. package/authentication/models/index.d.ts +1 -0
  29. package/authentication/models/index.js +1 -0
  30. package/authentication/models/index.js.map +1 -1
  31. package/authentication/models/token-payload-base.model.d.ts +7 -0
  32. package/authentication/models/token-payload-base.model.js +19 -0
  33. package/authentication/models/token-payload-base.model.js.map +1 -1
  34. package/authentication/models/token.model.d.ts +16 -0
  35. package/authentication/models/token.model.js +3 -0
  36. package/authentication/models/token.model.js.map +1 -0
  37. package/authentication/{authentication-credentials.repository.d.ts → server/authentication-credentials.repository.d.ts} +2 -2
  38. package/authentication/{authentication-credentials.repository.js → server/authentication-credentials.repository.js} +1 -1
  39. package/authentication/server/authentication-credentials.repository.js.map +1 -0
  40. package/authentication/{authentication-session.repository.d.ts → server/authentication-session.repository.d.ts} +2 -3
  41. package/authentication/{authentication-session.repository.js → server/authentication-session.repository.js} +0 -0
  42. package/authentication/server/authentication-session.repository.js.map +1 -0
  43. package/authentication/server/authentication-token-payload.provider.d.ts +3 -0
  44. package/authentication/{authentication-token-payload.provider.js → server/authentication-token-payload.provider.js} +1 -1
  45. package/authentication/server/authentication-token-payload.provider.js.map +1 -0
  46. package/authentication/server/authentication.api-controller.d.ts +13 -0
  47. package/authentication/server/authentication.api-controller.js +65 -0
  48. package/authentication/server/authentication.api-controller.js.map +1 -0
  49. package/authentication/{authentication.service.d.ts → server/authentication.service.d.ts} +23 -11
  50. package/authentication/{authentication.service.js → server/authentication.service.js} +92 -47
  51. package/authentication/server/authentication.service.js.map +1 -0
  52. package/authentication/server/helper.d.ts +13 -0
  53. package/authentication/server/helper.js +62 -0
  54. package/authentication/server/helper.js.map +1 -0
  55. package/authentication/server/index.d.ts +8 -0
  56. package/authentication/server/index.js +25 -0
  57. package/authentication/server/index.js.map +1 -0
  58. package/authentication/server/module.d.ts +12 -0
  59. package/authentication/server/module.js +19 -0
  60. package/authentication/server/module.js.map +1 -0
  61. package/authentication/server/mongo/index.d.ts +2 -0
  62. package/authentication/server/mongo/index.js +19 -0
  63. package/authentication/server/mongo/index.js.map +1 -0
  64. package/authentication/{mongo → server/mongo}/mongo-authentication-credentials.repository.d.ts +15 -18
  65. package/authentication/{mongo → server/mongo}/mongo-authentication-credentials.repository.js +36 -27
  66. package/authentication/server/mongo/mongo-authentication-credentials.repository.js.map +1 -0
  67. package/authentication/{mongo → server/mongo}/mongo-authentication-session.repository.d.ts +12 -15
  68. package/authentication/{mongo → server/mongo}/mongo-authentication-session.repository.js +27 -22
  69. package/authentication/server/mongo/mongo-authentication-session.repository.js.map +1 -0
  70. package/authentication/{tokens.d.ts → server/tokens.d.ts} +1 -1
  71. package/authentication/{tokens.js → server/tokens.js} +1 -1
  72. package/authentication/server/tokens.js.map +1 -0
  73. package/container/token.d.ts +2 -2
  74. package/container/types.d.ts +2 -1
  75. package/cookie/cookie.d.ts +14 -0
  76. package/cookie/cookie.js +58 -0
  77. package/cookie/cookie.js.map +1 -0
  78. package/cookie/index.d.ts +1 -0
  79. package/cookie/index.js +18 -0
  80. package/cookie/index.js.map +1 -0
  81. package/examples/api/authentication.d.ts +1 -0
  82. package/examples/api/authentication.js +51 -0
  83. package/examples/api/authentication.js.map +1 -0
  84. package/examples/api/basic-overview.js +4 -4
  85. package/examples/api/basic-overview.js.map +1 -1
  86. package/examples/api/custom-authentication.d.ts +1 -0
  87. package/examples/api/custom-authentication.js +89 -0
  88. package/examples/api/custom-authentication.js.map +1 -0
  89. package/examples/api/streaming.js +10 -8
  90. package/examples/api/streaming.js.map +1 -1
  91. package/http/cookie-parser.d.ts +1 -3
  92. package/http/cookie-parser.js +10 -19
  93. package/http/cookie-parser.js.map +1 -1
  94. package/http/http-headers.d.ts +2 -2
  95. package/http/http-headers.js +11 -11
  96. package/http/http-headers.js.map +1 -1
  97. package/http/http-value-map.js +13 -13
  98. package/http/http-value-map.js.map +1 -1
  99. package/http/server/http-server-response.d.ts +8 -3
  100. package/http/server/http-server-response.js +8 -0
  101. package/http/server/http-server-response.js.map +1 -1
  102. package/http/server/node/module.d.ts +2 -2
  103. package/http/server/node/module.js +3 -5
  104. package/http/server/node/module.js.map +1 -1
  105. package/mail/clients/nodemailer.mail-client.js +1 -1
  106. package/mail/clients/nodemailer.mail-client.js.map +1 -1
  107. package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.d.ts +1 -1
  108. package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js +21 -2
  109. package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js.map +1 -1
  110. package/message-bus/broadcast-channel/broadcast-channel-message-bus.d.ts +4 -4
  111. package/message-bus/broadcast-channel/broadcast-channel-message-bus.js +27 -4
  112. package/message-bus/broadcast-channel/broadcast-channel-message-bus.js.map +1 -1
  113. package/message-bus/broadcast-channel/index.d.ts +1 -0
  114. package/message-bus/broadcast-channel/index.js +1 -0
  115. package/message-bus/broadcast-channel/index.js.map +1 -1
  116. package/message-bus/broadcast-channel/module.d.ts +4 -0
  117. package/message-bus/broadcast-channel/module.js +17 -0
  118. package/message-bus/broadcast-channel/module.js.map +1 -0
  119. package/message-bus/local/index.d.ts +1 -0
  120. package/message-bus/local/index.js +1 -0
  121. package/message-bus/local/index.js.map +1 -1
  122. package/message-bus/local/local-message-bus-provider.d.ts +0 -5
  123. package/message-bus/local/local-message-bus-provider.js +1 -13
  124. package/message-bus/local/local-message-bus-provider.js.map +1 -1
  125. package/message-bus/local/local-message-bus.d.ts +1 -1
  126. package/message-bus/local/local-message-bus.js +2 -2
  127. package/message-bus/local/local-message-bus.js.map +1 -1
  128. package/message-bus/local/module.d.ts +4 -0
  129. package/message-bus/local/module.js +17 -0
  130. package/message-bus/local/module.js.map +1 -0
  131. package/message-bus/message-bus-base.d.ts +1 -1
  132. package/message-bus/message-bus-base.js +1 -1
  133. package/message-bus/message-bus-base.js.map +1 -1
  134. package/message-bus/message-bus.d.ts +1 -0
  135. package/message-bus/message-bus.js +3 -0
  136. package/message-bus/message-bus.js.map +1 -1
  137. package/notification/notification.service.js +2 -2
  138. package/notification/notification.service.js.map +1 -1
  139. package/object-storage/s3/s3.object.js +3 -3
  140. package/object-storage/s3/s3.object.js.map +1 -1
  141. package/package.json +4 -4
  142. package/schema/schemas/assign.js +2 -0
  143. package/schema/schemas/assign.js.map +1 -1
  144. package/schema/schemas/object.d.ts +1 -0
  145. package/schema/schemas/object.js +2 -1
  146. package/schema/schemas/object.js.map +1 -1
  147. package/schema/types/types.d.ts +1 -1
  148. package/schema/utils/schema.js.map +1 -1
  149. package/utils/array/array.js +2 -2
  150. package/utils/array/array.js.map +1 -1
  151. package/utils/string/index.d.ts +1 -0
  152. package/utils/string/index.js +1 -0
  153. package/utils/string/index.js.map +1 -1
  154. package/utils/string/title-case.d.ts +1 -0
  155. package/utils/string/title-case.js +13 -0
  156. package/utils/string/title-case.js.map +1 -0
  157. package/utils/type-guards.d.ts +1 -1
  158. package/utils/type-guards.js.map +1 -1
  159. package/utils/type-of.d.ts +1 -1
  160. package/utils/type-of.js +3 -4
  161. package/utils/type-of.js.map +1 -1
  162. package/authentication/authentication-credentials.repository.js.map +0 -1
  163. package/authentication/authentication-session.repository.js.map +0 -1
  164. package/authentication/authentication-token-payload.provider.d.ts +0 -3
  165. package/authentication/authentication-token-payload.provider.js.map +0 -1
  166. package/authentication/authentication.service.js.map +0 -1
  167. package/authentication/mongo/mongo-authentication-credentials.repository.js.map +0 -1
  168. package/authentication/mongo/mongo-authentication-session.repository.js.map +0 -1
  169. package/authentication/tokens.js.map +0 -1
@@ -12,13 +12,27 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.configureMongoAuthenticationSessionRepository = exports.InternalMongoAuthenticationSessionRepository = exports.MongoAuthenticationSessionRepository = exports.mongoAuthenticationSessionRepositoryConfig = void 0;
16
- const container_1 = require("../../container");
17
- const mongo_1 = require("../../database/mongo");
18
- const logger_1 = require("../../logger");
15
+ exports.configureMongoAuthenticationSessionRepository = exports.MongoAuthenticationSessionRepository = exports.InternalMongoAuthenticationSessionRepository = void 0;
16
+ const container_1 = require("../../../container");
17
+ const mongo_1 = require("../../../database/mongo");
18
+ const logger_1 = require("../../../logger");
19
19
  const authentication_session_repository_1 = require("../authentication-session.repository");
20
- exports.mongoAuthenticationSessionRepositoryConfig = {};
20
+ let defaultArgument;
21
21
  const indexes = [];
22
+ let InternalMongoAuthenticationSessionRepository = class InternalMongoAuthenticationSessionRepository extends mongo_1.MongoEntityRepository {
23
+ [container_1.resolveArgumentType];
24
+ constructor(collection, logger) {
25
+ super(collection, mongo_1.noopTransformer, { logger, indexes });
26
+ }
27
+ };
28
+ InternalMongoAuthenticationSessionRepository = __decorate([
29
+ (0, container_1.singleton)({
30
+ defaultArgumentProvider: () => defaultArgument
31
+ }),
32
+ __param(0, (0, container_1.forwardArg)()),
33
+ __metadata("design:paramtypes", [mongo_1.Collection, logger_1.Logger])
34
+ ], InternalMongoAuthenticationSessionRepository);
35
+ exports.InternalMongoAuthenticationSessionRepository = InternalMongoAuthenticationSessionRepository;
22
36
  let MongoAuthenticationSessionRepository = class MongoAuthenticationSessionRepository extends authentication_session_repository_1.AuthenticationSessionRepository {
23
37
  repository;
24
38
  constructor(repository) {
@@ -29,7 +43,12 @@ let MongoAuthenticationSessionRepository = class MongoAuthenticationSessionRepos
29
43
  return this.repository.insert(authenticationSession);
30
44
  }
31
45
  async load(id) {
32
- return this.repository.load(id);
46
+ const session = await this.repository.load(id);
47
+ return {
48
+ ...session,
49
+ refreshTokenSalt: session.refreshTokenSalt.buffer,
50
+ refreshTokenHash: session.refreshTokenHash.buffer
51
+ };
33
52
  }
34
53
  async extend(id, data) {
35
54
  await this.repository.patchByFilter({ id }, data);
@@ -43,22 +62,8 @@ MongoAuthenticationSessionRepository = __decorate([
43
62
  __metadata("design:paramtypes", [InternalMongoAuthenticationSessionRepository])
44
63
  ], MongoAuthenticationSessionRepository);
45
64
  exports.MongoAuthenticationSessionRepository = MongoAuthenticationSessionRepository;
46
- let InternalMongoAuthenticationSessionRepository = class InternalMongoAuthenticationSessionRepository extends mongo_1.MongoEntityRepository {
47
- [container_1.resolveArgumentType];
48
- constructor(collection, logger) {
49
- super(collection, mongo_1.noopTransformer, { logger, indexes });
50
- }
51
- };
52
- InternalMongoAuthenticationSessionRepository = __decorate([
53
- (0, container_1.singleton)({
54
- defaultArgumentProvider: () => exports.mongoAuthenticationSessionRepositoryConfig.config
55
- }),
56
- __param(0, (0, container_1.forwardArg)()),
57
- __metadata("design:paramtypes", [mongo_1.Collection, logger_1.Logger])
58
- ], InternalMongoAuthenticationSessionRepository);
59
- exports.InternalMongoAuthenticationSessionRepository = InternalMongoAuthenticationSessionRepository;
60
- function configureMongoAuthenticationSessionRepository(config = {}) {
61
- exports.mongoAuthenticationSessionRepositoryConfig.config = config.config ?? exports.mongoAuthenticationSessionRepositoryConfig.config;
65
+ function configureMongoAuthenticationSessionRepository(config) {
66
+ defaultArgument = config;
62
67
  }
63
68
  exports.configureMongoAuthenticationSessionRepository = configureMongoAuthenticationSessionRepository;
64
69
  //# sourceMappingURL=mongo-authentication-session.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo-authentication-session.repository.js","sourceRoot":"","sources":["../../../../source/authentication/server/mongo/mongo-authentication-session.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAAyE;AAEzE,mDAAsF;AACtF,4CAAkC;AAIlC,4FAAuF;AAMvF,IAAI,eAAyE,CAAC;AAE9E,MAAM,OAAO,GAAmD,EAAE,CAAC;AAK5D,IAAM,4CAA4C,GAAlD,MAAM,4CAA6C,SAAQ,6BAA4C;IACnG,CAAC,+BAAmB,CAAC,CAA+C;IAE7E,YAA0B,UAA6C,EAAE,MAAc;QACrF,KAAK,CAAC,UAAU,EAAE,uBAAe,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AANY,4CAA4C;IAHxD,IAAA,qBAAS,EAAC;QACT,uBAAuB,EAAE,GAAG,EAAE,CAAC,eAAe;KAC/C,CAAC;IAIa,WAAA,IAAA,sBAAU,GAAE,CAAA;qCAAa,kBAAU,EAAiC,eAAM;GAH5E,4CAA4C,CAMxD;AANY,oGAA4C;AASlD,IAAM,oCAAoC,GAA1C,MAAM,oCAAqC,SAAQ,mEAA+B;IACtE,UAAU,CAA+C;IAE1E,YAAY,UAAwD;QAClE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,qBAA+C;QAC1D,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAU;QACnB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE/C,OAAO;YACL,GAAG,OAAO;YACV,gBAAgB,EAAG,OAAO,CAAC,gBAAsC,CAAC,MAAM;YACxE,gBAAgB,EAAG,OAAO,CAAC,gBAAsC,CAAC,MAAM;SACzE,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,IAAqC;QAC5D,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU,EAAE,SAAiB;QACrC,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AA7BY,oCAAoC;IADhD,IAAA,qBAAS,GAAE;qCAIc,4CAA4C;GAHzD,oCAAoC,CA6BhD;AA7BY,oFAAoC;AA+BjD,SAAgB,6CAA6C,CAAC,MAAkD;IAC9G,eAAe,GAAG,MAAM,CAAC;AAC3B,CAAC;AAFD,sGAEC"}
@@ -1,2 +1,2 @@
1
1
  import type { AuthenticationServiceOptions } from './authentication.service';
2
- export declare const AUTHENTICATION_SERVICE_OPTIONS: import("../container").InjectionToken<AuthenticationServiceOptions, any>;
2
+ export declare const AUTHENTICATION_SERVICE_OPTIONS: import("../../container").InjectionToken<AuthenticationServiceOptions, any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AUTHENTICATION_SERVICE_OPTIONS = void 0;
4
- const container_1 = require("../container");
4
+ const container_1 = require("../../container");
5
5
  exports.AUTHENTICATION_SERVICE_OPTIONS = (0, container_1.injectionToken)('AUTHENTICATION_SERVICE_OPTIONS');
6
6
  //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../source/authentication/server/tokens.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAGhC,QAAA,8BAA8B,GAAG,IAAA,0BAAc,EAA+B,gCAAgC,CAAC,CAAC"}
@@ -1,9 +1,9 @@
1
- import type { Constructor } from "../types";
1
+ import type { AbstractConstructor } from "../types";
2
2
  declare const parameter: unique symbol;
3
3
  export type ParameterizedInjectionToken<T, A> = SimpleInjectionToken<T> & {
4
4
  [parameter]?: A;
5
5
  };
6
- export type SimpleInjectionToken<T> = Constructor<T> | Function | object | string | symbol;
6
+ export type SimpleInjectionToken<T> = AbstractConstructor<T> | object | string | symbol;
7
7
  export type InjectionToken<T = any, A = any> = SimpleInjectionToken<T> | ParameterizedInjectionToken<T, A>;
8
8
  export declare function injectionToken<T, A = any>(token: InjectionToken<T, A>): InjectionToken<T, A>;
9
9
  export declare function getTokenName(token: InjectionToken | undefined): string;
@@ -1,3 +1,4 @@
1
+ import type { AbstractConstructor } from "../types";
1
2
  import type { Container } from './container';
2
3
  import type { InjectionToken } from './token';
3
4
  export type ResolveContext = Pick<Container, 'resolve' | 'resolveAsync'> & {
@@ -5,4 +6,4 @@ export type ResolveContext = Pick<Container, 'resolve' | 'resolveAsync'> & {
5
6
  };
6
7
  export type Mapper<T = any, U = unknown> = (value: T) => U | Promise<U>;
7
8
  export type ArgumentProvider<T = unknown> = (context: ResolveContext) => T | Promise<T>;
8
- export type ForwardRefInjectionToken<T = any, A = any> = Exclude<InjectionToken<T, A>, Function> | (() => InjectionToken<T, A>);
9
+ export type ForwardRefInjectionToken<T = any, A = any> = Exclude<InjectionToken<T, A>, AbstractConstructor> | (() => InjectionToken<T, A>);
@@ -0,0 +1,14 @@
1
+ export type SetCookieOptions = {
2
+ domain?: string;
3
+ /** date or timestamp in milliseconds */
4
+ expires?: Date | number;
5
+ httpOnly?: boolean;
6
+ /** in seconds */
7
+ maxAge?: number;
8
+ partitioned?: boolean;
9
+ path?: string;
10
+ sameSite?: 'strict' | 'lax' | 'none';
11
+ secure?: boolean;
12
+ };
13
+ export declare function formatSetCookie(name: string, value: string, options?: SetCookieOptions): string;
14
+ export declare function parseCookieString(cookieString: string): Map<string, string>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCookieString = exports.formatSetCookie = void 0;
4
+ const not_supported_error_1 = require("../error/not-supported.error");
5
+ const type_guards_1 = require("../utils/type-guards");
6
+ const sameSiteMap = {
7
+ none: 'None',
8
+ lax: 'Lax',
9
+ strict: 'Strict'
10
+ };
11
+ function formatSetCookie(name, value, options = {}) {
12
+ const encodedValue = encodeURIComponent(value);
13
+ let cookie = `${name}="${encodedValue}"`;
14
+ if ((0, type_guards_1.isDefined)(options.domain)) {
15
+ cookie = `${cookie}; Domain=${options.domain}`;
16
+ }
17
+ if ((0, type_guards_1.isDefined)(options.expires)) {
18
+ const date = (0, type_guards_1.isNumber)(options.expires) ? new Date(options.expires) : options.expires;
19
+ cookie = `${cookie}; Expires=${date.toUTCString()}`;
20
+ }
21
+ if ((0, type_guards_1.isDefined)(options.httpOnly) && options.httpOnly) {
22
+ cookie = `${cookie}; HttpOnly`;
23
+ }
24
+ if ((0, type_guards_1.isDefined)(options.maxAge)) {
25
+ cookie = `${cookie}; Max-Age=${options.maxAge}`;
26
+ }
27
+ if ((0, type_guards_1.isDefined)(options.partitioned) && options.partitioned) {
28
+ cookie = `${cookie}; Partitioned`;
29
+ }
30
+ if ((0, type_guards_1.isDefined)(options.path)) {
31
+ cookie = `${cookie}; Path=${options.path}`;
32
+ }
33
+ if ((0, type_guards_1.isDefined)(options.sameSite)) {
34
+ const sameSiteValue = sameSiteMap[options.sameSite];
35
+ if ((0, type_guards_1.isUndefined)(sameSiteValue)) {
36
+ throw new not_supported_error_1.NotSupportedError(`Unknown option SameSite "${options.sameSite}".`);
37
+ }
38
+ cookie = `${cookie}; SameSite=${sameSiteValue}`;
39
+ }
40
+ if ((0, type_guards_1.isDefined)(options.secure) && options.secure) {
41
+ cookie = `${cookie}; Secure`;
42
+ }
43
+ return cookie;
44
+ }
45
+ exports.formatSetCookie = formatSetCookie;
46
+ function parseCookieString(cookieString) {
47
+ const cookieEntries = cookieString
48
+ .split(';')
49
+ .map((cookiePartString) => {
50
+ const splitIndex = cookiePartString.indexOf('=');
51
+ const name = cookiePartString.slice(0, splitIndex).trim();
52
+ const value = decodeURIComponent(cookiePartString.slice(splitIndex + 1).trim());
53
+ return [name, value];
54
+ });
55
+ return new Map(cookieEntries);
56
+ }
57
+ exports.parseCookieString = parseCookieString;
58
+ //# sourceMappingURL=cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../source/cookie/cookie.ts"],"names":[],"mappings":";;;AAAA,sEAAgE;AAChE,sDAAuE;AAevE,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX,SAAgB,eAAe,CAAC,IAAY,EAAE,KAAa,EAAE,UAA4B,EAAE;IACzF,MAAM,YAAY,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAE/C,IAAI,MAAM,GAAG,GAAG,IAAI,KAAK,YAAY,GAAG,CAAC;IAEzC,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC7B,MAAM,GAAG,GAAG,MAAM,YAAY,OAAO,CAAC,MAAM,EAAE,CAAC;KAChD;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,MAAM,IAAI,GAAG,IAAA,sBAAQ,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,I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oB;IACpD,MAAM,aAAa,GAAG,YAAY;SAC/B,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE;QACxB,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAEhF,OAAO,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;IAChC,CAAC,CAAC,CAAC;IAEL,OAAO,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;AAChC,CAAC;AAZD,8CAYC"}
@@ -0,0 +1 @@
1
+ export * from './cookie';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./cookie"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/cookie/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable max-classes-per-file */
4
+ const server_1 = require("../../api/server");
5
+ const application_1 = require("../../application");
6
+ const client_1 = require("../../authentication/client");
7
+ const authentication_api_controller_1 = require("../../authentication/server/authentication.api-controller");
8
+ const authentication_service_1 = require("../../authentication/server/authentication.service");
9
+ const module_1 = require("../../authentication/server/module");
10
+ const mongo_authentication_credentials_repository_1 = require("../../authentication/server/mongo/mongo-authentication-credentials.repository");
11
+ const mongo_authentication_session_repository_1 = require("../../authentication/server/mongo/mongo-authentication-session.repository");
12
+ const container_1 = require("../../container");
13
+ const http_1 = require("../../http");
14
+ const undici_http_client_adapter_1 = require("../../http/client/adapters/undici-http-client.adapter");
15
+ const node_1 = require("../../http/server/node");
16
+ const local_1 = require("../../message-bus/local");
17
+ const modules_1 = require("../../module/modules");
18
+ const timing_1 = require("../../utils/timing");
19
+ const undici_1 = require("undici");
20
+ (0, module_1.configureAuthenticationServer)({
21
+ serviceOptions: { secret: 'djp0fq23576aq' },
22
+ credentialsRepository: mongo_authentication_credentials_repository_1.MongoAuthenticationCredentialsRepository,
23
+ sessionRepository: mongo_authentication_session_repository_1.MongoAuthenticationSessionRepository
24
+ });
25
+ (0, mongo_authentication_credentials_repository_1.configureMongoAuthenticationCredentialsRepository)({ collection: 'credentials' });
26
+ (0, mongo_authentication_session_repository_1.configureMongoAuthenticationSessionRepository)({ collection: 'sessions' });
27
+ (0, client_1.configureAuthenticationClient)({
28
+ authenticationApiClient: client_1.AuthenticationApiClient
29
+ });
30
+ (0, local_1.configureLocalMessageBus)();
31
+ async function serverTest() {
32
+ const authenticationService = await container_1.container.resolveAsync(authentication_service_1.AuthenticationService);
33
+ await authenticationService.setCredentials('foobar', 'supersecret');
34
+ }
35
+ async function clientTest() {
36
+ await (0, timing_1.timeout)(250); // allow server to initialize
37
+ const authenticationService = container_1.container.resolve(client_1.AuthenticationService);
38
+ authenticationService.initialize();
39
+ await authenticationService.login('foobar', 'supersecret');
40
+ authenticationService.token$.subscribe((token) => console.log({ token }));
41
+ }
42
+ function main() {
43
+ (0, node_1.configureNodeHttpServer)();
44
+ (0, server_1.configureApiServer)({ controllers: [authentication_api_controller_1.AuthenticationApiController] });
45
+ (0, undici_http_client_adapter_1.configureUndiciHttpClientAdapter)({ dispatcher: new undici_1.Agent({ keepAliveMaxTimeout: 1 }) });
46
+ container_1.container.register(http_1.HTTP_CLIENT_OPTIONS, { useValue: { baseUrl: 'http://localhost:8000' } });
47
+ application_1.Application.run(modules_1.WebServerModule);
48
+ }
49
+ main();
50
+ void serverTest().then(async () => clientTest()).catch((error) => console.error(error)).then(async () => application_1.Application.shutdown());
51
+ //# sourceMappingURL=authentication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../source/examples/api/authentication.ts"],"names":[],"mappings":";;AAAA,yCAAyC;AACzC,6CAAkD;AAClD,mDAA4C;AAC5C,wDAAuJ;AACvJ,6GAAoG;AACpG,+FAAsH;AACtH,+DAA+E;AAC/E,+IAAwL;AACxL,uIAA4K;AAC5K,+CAAwC;AACxC,qCAA6C;AAC7C,sGAAqG;AACrG,iDAA6D;AAC7D,mDAA+D;AAC/D,kDAAmD;AACnD,+CAAyC;AACzC,mCAA+B;AAE/B,IAAA,sCAA6B,EAAC;IAC5B,cAAc,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE;IAC3C,qBAAqB,EAAE,sFAAwC;IAC/D,iBAAiB,EAAE,8EAAoC;CACxD,CAAC,CAAC;AAEH,IAAA,+FAAiD,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC,CAAC;AACjF,IAAA,uFAA6C,EAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;AAE1E,IAAA,sCAA6B,EAAC;IAC5B,uBAAuB,EAAE,gCAAuB;CACjD,CAAC,CAAC;AAEH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KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,yBAAW,CAAC,QAAQ,EAAE,CAAC,CAAC"}
@@ -19,7 +19,7 @@ const undici_http_client_adapter_1 = require("../../http/client/adapters/undici-
19
19
  const node_1 = require("../../http/server/node");
20
20
  const modules_1 = require("../../module/modules");
21
21
  const schema_1 = require("../../schema");
22
- const utils_1 = require("../../utils");
22
+ const timing_1 = require("../../utils/timing");
23
23
  const undici_1 = require("undici");
24
24
  class User {
25
25
  id;
@@ -83,7 +83,7 @@ UserApi = __decorate([
83
83
  ], UserApi);
84
84
  const UserApiClient = (0, client_1.compileClient)(usersApiDefinition);
85
85
  async function clientTest() {
86
- await (0, utils_1.timeout)(250); // allow server to start
86
+ await (0, timing_1.timeout)(250); // allow server to start
87
87
  const userApiClient = container_1.container.resolve(UserApiClient);
88
88
  const allUsers = await userApiClient.loadAll();
89
89
  console.log(allUsers);
@@ -92,7 +92,7 @@ async function clientTest() {
92
92
  console.log(allUsersAfterDelete);
93
93
  }
94
94
  async function main() {
95
- (0, node_1.configureNodeHttpServer)(true);
95
+ (0, node_1.configureNodeHttpServer)();
96
96
  (0, server_1.configureApiServer)({ controllers: [UserApi] });
97
97
  (0, undici_http_client_adapter_1.configureUndiciHttpClientAdapter)({ dispatcher: new undici_1.Agent({ keepAliveMaxTimeout: 1 }) });
98
98
  container_1.container.register(http_1.HTTP_CLIENT_OPTIONS, { useValue: { baseUrl: 'http://localhost:8000' } });
@@ -100,5 +100,5 @@ async function main() {
100
100
  await application_1.Application.run();
101
101
  }
102
102
  void main();
103
- void clientTest().catch((error) => console.error(error)).then(async () => (0, utils_1.timeout)(1000)).then(async () => application_1.Application.shutdown());
103
+ void clientTest().catch((error) => console.error(error)).then(async () => (0, timing_1.timeout)(1000)).then(async () => application_1.Application.shutdown());
104
104
  //# sourceMappingURL=basic-overview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"basic-overview.js","sourceRoot":"","sources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,MAAM,yBAAW,CAAC,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,KAAK,IAAI,EAAE,CAAC;AACZ,KAAK,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,IAAA,gBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,yBAAW,CAAC,QAAQ,EAAE,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /* eslint-disable max-classes-per-file */
13
+ const client_1 = require("../../api/client");
14
+ const server_1 = require("../../api/server");
15
+ const application_1 = require("../../application");
16
+ const authentication_api_1 = require("../../authentication/authentication.api");
17
+ const client_2 = require("../../authentication/client");
18
+ const authentication_token_payload_provider_1 = require("../../authentication/server/authentication-token-payload.provider");
19
+ const authentication_api_controller_1 = require("../../authentication/server/authentication.api-controller");
20
+ const authentication_service_1 = require("../../authentication/server/authentication.service");
21
+ const module_1 = require("../../authentication/server/module");
22
+ const mongo_authentication_credentials_repository_1 = require("../../authentication/server/mongo/mongo-authentication-credentials.repository");
23
+ const mongo_authentication_session_repository_1 = require("../../authentication/server/mongo/mongo-authentication-session.repository");
24
+ const container_1 = require("../../container");
25
+ const http_1 = require("../../http");
26
+ const undici_http_client_adapter_1 = require("../../http/client/adapters/undici-http-client.adapter");
27
+ const node_1 = require("../../http/server/node");
28
+ const local_1 = require("../../message-bus/local");
29
+ const modules_1 = require("../../module/modules");
30
+ const schema_1 = require("../../schema");
31
+ const timing_1 = require("../../utils/timing");
32
+ const undici_1 = require("undici");
33
+ class CustomTokenPaylod {
34
+ deviceRegistrationId;
35
+ }
36
+ __decorate([
37
+ (0, schema_1.Property)(),
38
+ __metadata("design:type", String)
39
+ ], CustomTokenPaylod.prototype, "deviceRegistrationId", void 0);
40
+ class AuthenticationData {
41
+ deviceId;
42
+ }
43
+ __decorate([
44
+ (0, schema_1.Property)(),
45
+ __metadata("design:type", String)
46
+ ], AuthenticationData.prototype, "deviceId", void 0);
47
+ let CustomTokenPayloadProvider = class CustomTokenPayloadProvider extends authentication_token_payload_provider_1.AuthenticationTokenPayloadProvider {
48
+ getTokenPayload(_subject, authenticationData) {
49
+ return { deviceRegistrationId: `registration:${authenticationData.deviceId}` };
50
+ }
51
+ };
52
+ CustomTokenPayloadProvider = __decorate([
53
+ (0, container_1.singleton)()
54
+ ], CustomTokenPayloadProvider);
55
+ (0, module_1.configureAuthenticationServer)({
56
+ serviceOptions: { secret: 'djp0fq23576aq' },
57
+ credentialsRepository: mongo_authentication_credentials_repository_1.MongoAuthenticationCredentialsRepository,
58
+ sessionRepository: mongo_authentication_session_repository_1.MongoAuthenticationSessionRepository,
59
+ tokenPayloadProvider: CustomTokenPayloadProvider
60
+ });
61
+ (0, mongo_authentication_credentials_repository_1.configureMongoAuthenticationCredentialsRepository)({ collection: 'credentials' });
62
+ (0, mongo_authentication_session_repository_1.configureMongoAuthenticationSessionRepository)({ collection: 'sessions' });
63
+ const customAuthenticationApiDefinition = (0, authentication_api_1.getAuthenticationApiDefinition)(CustomTokenPaylod, AuthenticationData);
64
+ const CustomAuthenticationApiClient = (0, client_1.compileClient)(customAuthenticationApiDefinition);
65
+ (0, client_2.configureAuthenticationClient)({
66
+ authenticationApiClient: CustomAuthenticationApiClient
67
+ });
68
+ (0, local_1.configureLocalMessageBus)();
69
+ async function serverTest() {
70
+ const authenticationService = await container_1.container.resolveAsync(authentication_service_1.AuthenticationService);
71
+ await authenticationService.setCredentials('foobar', 'supersecret');
72
+ }
73
+ async function clientTest() {
74
+ await (0, timing_1.timeout)(250); // allow server to initialize
75
+ const authenticationService = container_1.container.resolve(client_2.AuthenticationService);
76
+ authenticationService.initialize();
77
+ await authenticationService.login('foobar', 'supersecret', { deviceId: 'my-device' });
78
+ authenticationService.token$.subscribe((token) => console.log({ token }));
79
+ }
80
+ function main() {
81
+ (0, node_1.configureNodeHttpServer)();
82
+ (0, server_1.configureApiServer)({ controllers: [authentication_api_controller_1.AuthenticationApiController] });
83
+ (0, undici_http_client_adapter_1.configureUndiciHttpClientAdapter)({ dispatcher: new undici_1.Agent({ keepAliveMaxTimeout: 1 }) });
84
+ container_1.container.register(http_1.HTTP_CLIENT_OPTIONS, { useValue: { baseUrl: 'http://localhost:8000' } });
85
+ application_1.Application.run(modules_1.WebServerModule);
86
+ }
87
+ main();
88
+ void serverTest().then(async () => clientTest()).catch((error) => console.error(error)).then(async () => application_1.Application.shutdown());
89
+ //# sourceMappingURL=custom-authentication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-authentication.js","sourceRoot":"","sources":["../../../source/examples/api/custom-authentication.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,yCAAyC;AACzC,6CAA6C;AAC7C,6CAAkD;AAClD,mDAA4C;AAC5C,gFAAqF;AACrF,wDAA8H;AAC9H,6HAAmH;AACnH,6GAAoG;AACpG,+FAAsH;AACtH,+DAA+E;AAC/E,+IAAwL;AACxL,uIAA4K;AAC5K,+CAAmD;AACnD,qCAA6C;AAC7C,sGAAqG;AACrG,iDAA6D;A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const server_2 = require("../../http/server");
18
18
  const node_1 = require("../../http/server/node");
19
19
  const modules_1 = require("../../module/modules");
20
20
  const sse_1 = require("../../sse");
21
- const utils_1 = require("../../utils");
21
+ const encoding_1 = require("../../utils/encoding");
22
22
  const stream_1 = require("../../utils/stream");
23
+ const timing_1 = require("../../utils/timing");
24
+ const type_guards_1 = require("../../utils/type-guards");
23
25
  const undici_1 = require("undici");
24
26
  const logger = container_1.container.resolve(core_1.CORE_LOGGER);
25
27
  const streamingApiDefinition = (0, api_1.defineApi)({
@@ -70,21 +72,21 @@ async function* counter() {
70
72
  while (application_1.Application.shutdownToken.isUnset && (currentNumber < 15)) {
71
73
  yield (`${++currentNumber}`).toString();
72
74
  logger.info(`yield: "${currentNumber}"`);
73
- await (0, utils_1.cancelableTimeout)(1000, application_1.Application.shutdownToken);
75
+ await (0, timing_1.cancelableTimeout)(1000, application_1.Application.shutdownToken);
74
76
  }
75
77
  }
76
78
  const StreamingApiClient = (0, client_1.compileClient)(streamingApiDefinition);
77
79
  async function clientTest() {
78
- await (0, utils_1.timeout)(250); // allow server to start
80
+ await (0, timing_1.timeout)(250); // allow server to start
79
81
  const streamingApiClient = container_1.container.resolve(StreamingApiClient);
80
- const response = await streamingApiClient.echo(undefined, (0, stream_1.getReadableStreamFromIterable)(counter()).pipeThrough((0, utils_1.encodeUtf8Stream)()));
81
- for await (const responseChunk of (0, stream_1.getReadableStreamIterable)(response.pipeThrough((0, utils_1.decodeTextStream)()))) {
82
+ const response = await streamingApiClient.echo(undefined, (0, stream_1.getReadableStreamFromIterable)(counter()).pipeThrough((0, encoding_1.encodeUtf8Stream)()));
83
+ for await (const responseChunk of (0, stream_1.getReadableStreamIterable)(response.pipeThrough((0, encoding_1.decodeTextStream)()))) {
82
84
  logger.info(`response: "${responseChunk}"\n`);
83
85
  }
84
86
  // await Application.shutdown();
85
87
  }
86
88
  function main() {
87
- (0, node_1.configureNodeHttpServer)(true);
89
+ (0, node_1.configureNodeHttpServer)();
88
90
  (0, server_1.configureApiServer)({ controllers: [StreamingApi] });
89
91
  (0, undici_http_client_adapter_1.configureUndiciHttpClientAdapter)({ dispatcher: new undici_1.Agent({ keepAliveMaxTimeout: 1 }) });
90
92
  container_1.container.register(http_1.HTTP_CLIENT_OPTIONS, { useValue: { baseUrl: 'http://localhost:8000' } });
@@ -96,11 +98,11 @@ function eventsSource() {
96
98
  const events = new sse_1.SeverSentEvents();
97
99
  void (async () => {
98
100
  for (let i = 1; i <= 10; i++) {
99
- if (events.closed || (0, utils_1.isDefined)(events.error)) {
101
+ if (events.closed || (0, type_guards_1.isDefined)(events.error)) {
100
102
  return;
101
103
  }
102
104
  await events.sendJson({ name: 'time', id: i.toString(), data: { dateTime: `${new Date().toLocaleString()}`, uptime: performance.now() }, retry: 1000 });
103
- await (0, utils_1.timeout)(1000);
105
+ await (0, timing_1.timeout)(1000);
104
106
  }
105
107
  await events.close();
106
108
  })().catch((error) => console.error(error));
@@ -1 +1 @@
1
- {"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../../source/examples/api/streaming.ts"],"names":[],"mappings":";;;;;;;;AAEA,mCAAkC;AAClC,6CAA6C;AAC7C,6CAAiE;AACjE,mDAA4C;AAC5C,+CAAwC;AACxC,qCAAqC;AACrC,qCAA6C;AAC7C,sGAAqG;AACrG,8CAAmD;AACnD,iDAA6D;AAC7D,kDAAmD;AACnD,mCAAwC;AACxC,uCAAoG;AACpG,+CAA0F;AAC1F,mCAA+B;AAE/B,MAAM,MAAM,GAAG,qBAAS,CAAC,OAAO,CAAC,kBAAW,CAAC,CAAC;AAI9C,MAAM,sBAAsB,GAAG,IAAA,eAAS,EAAC;IACvC,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE;QACT,IAAI,EAAE;YACJ,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE,cAAc;SACvB;QACD,MAAM,EAAE;YACN,MAAM,EAAE,KAAK;YACb,QAAQ,EA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I,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,MAAM,CAAC,MAAM,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC5C,OAAO;aACR;YAED,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACxJ,MAAM,IAAA,gBAAO,EAAC,IAAI,CAAC,CAAC;SACrB;QAED,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAE5C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,9 +1,7 @@
1
1
  import type { HttpHeaders } from './http-headers';
2
2
  export declare class CookieParser {
3
- private readonly httpHeaders;
4
3
  private readonly cookies;
5
4
  constructor(httpHeaders: HttpHeaders);
6
5
  has(name: string): boolean;
7
- get(name: string): string | undefined;
8
- private parseCookies;
6
+ tryGet(name: string): string | undefined;
9
7
  }
@@ -1,36 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CookieParser = void 0;
4
+ const cookie_1 = require("../cookie");
4
5
  const lazy_property_1 = require("../utils/object/lazy-property");
5
6
  const type_guards_1 = require("../utils/type-guards");
6
7
  class CookieParser {
7
- httpHeaders;
8
8
  cookies;
9
9
  constructor(httpHeaders) {
10
- this.httpHeaders = httpHeaders;
11
- (0, lazy_property_1.lazyProperty)(this, 'cookies', () => this.parseCookies());
10
+ (0, lazy_property_1.lazyProperty)(this, 'cookies', () => getCookies(httpHeaders));
12
11
  }
13
12
  has(name) {
14
13
  return this.cookies.has(name);
15
14
  }
16
- get(name) {
15
+ tryGet(name) {
17
16
  return this.cookies.get(name);
18
17
  }
19
- parseCookies() {
20
- const cookie = this.httpHeaders.tryGetSingle('Cookie');
21
- if ((0, type_guards_1.isUndefined)(cookie)) {
22
- return new Map();
23
- }
24
- const entries = cookie.split(';')
25
- .map((value) => value.trim())
26
- .map((value) => {
27
- const equalsIndex = value.indexOf('=');
28
- const name = value.slice(0, equalsIndex);
29
- const cookieValue = value.slice(equalsIndex + 1);
30
- return [name, cookieValue];
31
- });
32
- return new Map(entries);
33
- }
34
18
  }
35
19
  exports.CookieParser = CookieParser;
20
+ function getCookies(httpHeaders) {
21
+ const cookieString = httpHeaders.tryGetSingle('Cookie');
22
+ if ((0, type_guards_1.isUndefined)(cookieString)) {
23
+ return new Map();
24
+ }
25
+ return (0, cookie_1.parseCookieString)(cookieString);
26
+ }
36
27
  //# sourceMappingURL=cookie-parser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie-parser.js","sourceRoot":"","sources":["../../source/http/cookie-parser.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,sDAAkD;AAGlD,MAAa,YAAY;IACN,WAAW,CAAc;IACzB,OAAO,CAAsB;IAE9C,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAA,4BAAY,EAAC,IAAW,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC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AC;IAChC,CAAC;CACF;AAdD,oCAcC;AAED,SAAS,UAAU,CAAC,WAAwB;IAC1C,MAAM,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAuB,CAAC;IAE9E,IAAI,IAAA,yBAAW,EAAC,YAAY,CAAC,EAAE;QAC7B,OAAO,IAAI,GAAG,EAAE,CAAC;KAClB;IAED,OAAO,IAAA,0BAAiB,EAAC,YAAY,CAAC,CAAC;AACzC,CAAC"}
@@ -21,6 +21,6 @@ export declare class HttpHeaders extends HttpValueMap<HttpHeaders> {
21
21
  get charset(): string | undefined;
22
22
  constructor(input?: HttpValueMapInput);
23
23
  clone(): HttpHeaders;
24
- private getNumberHeader;
25
- private getStringHeader;
24
+ private tryGetNumberHeader;
25
+ private tryGetStringHeader;
26
26
  }