@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../source/authentication/client/module.ts"],"names":[],"mappings":";;;AACA,+CAAwC;AAExC,yDAAgD;AAEhD,qCAAkF;AAOlF,SAAgB,6BAA6B,CAAC,SAA8C,EAAE;IAC5F,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE;QAC7C,qBAAS,CAAC,iBAAiB,CAAC,kCAAyB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,uBAAuB,EAAE,CAAC,CAAC;KACtG;IAED,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,yBAAyB,CAAC,EAAE;QAC/C,qBAAS,CAAC,QAAQ,CAAC,oCAA2B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,yBAAyB,EAAE,CAAC,CAAC;KACjG;AACH,CAAC;AARD,sEAQC"}
@@ -0,0 +1,4 @@
1
+ import type { ApiClient } from "../../api/client";
2
+ import type { AuthenticationApiDefinition } from '../authentication.api';
3
+ export declare const AUTHENTICATION_API_CLIENT: import("../../container").InjectionToken<ApiClient<AuthenticationApiDefinition<any, any>>, any>;
4
+ export declare const INITIAL_AUTHENTICATION_DATA: import("../../container").InjectionToken<unknown, any>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INITIAL_AUTHENTICATION_DATA = exports.AUTHENTICATION_API_CLIENT = void 0;
4
+ const container_1 = require("../../container");
5
+ exports.AUTHENTICATION_API_CLIENT = (0, container_1.injectionToken)('AUTHENTICATION_API_CLIENT');
6
+ exports.INITIAL_AUTHENTICATION_DATA = (0, container_1.injectionToken)('INITIAL_AUTHENTICATION_DATA');
7
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../source/authentication/client/tokens.ts"],"names":[],"mappings":";;;AACA,+CAA6C;AAGhC,QAAA,yBAAyB,GAAG,IAAA,0BAAc,EAAmD,2BAA2B,CAAC,CAAC;AAE1H,QAAA,2BAA2B,GAAG,IAAA,0BAAc,EAAC,6BAA6B,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './authentication.api';
2
+ export * from './models';
@@ -0,0 +1,19 @@
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("./authentication.api"), exports);
18
+ __exportStar(require("./models"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/authentication/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,2CAAyB"}
@@ -5,7 +5,6 @@ export declare class AuthenticationSession {
5
5
  begin: number;
6
6
  /** timestamp */
7
7
  end: number;
8
- tokenId: string;
9
8
  refreshTokenHashVersion: number;
10
9
  refreshTokenSalt: Uint8Array;
11
10
  refreshTokenHash: Uint8Array;
@@ -14,7 +13,6 @@ export declare class NewAuthenticationSession {
14
13
  subject: string;
15
14
  begin: number;
16
15
  end: number;
17
- tokenId: string;
18
16
  refreshTokenHashVersion: number;
19
17
  refreshTokenSalt: Uint8Array;
20
18
  refreshTokenHash: Uint8Array;
@@ -18,7 +18,6 @@ class AuthenticationSession {
18
18
  begin;
19
19
  /** timestamp */
20
20
  end;
21
- tokenId;
22
21
  refreshTokenHashVersion;
23
22
  refreshTokenSalt;
24
23
  refreshTokenHash;
@@ -39,10 +38,6 @@ __decorate([
39
38
  (0, schema_1.Property)(),
40
39
  __metadata("design:type", Number)
41
40
  ], AuthenticationSession.prototype, "end", void 0);
42
- __decorate([
43
- (0, schema_1.Property)(),
44
- __metadata("design:type", String)
45
- ], AuthenticationSession.prototype, "tokenId", void 0);
46
41
  __decorate([
47
42
  (0, schema_1.Property)(),
48
43
  __metadata("design:type", Number)
@@ -60,7 +55,6 @@ class NewAuthenticationSession {
60
55
  subject;
61
56
  begin;
62
57
  end;
63
- tokenId;
64
58
  refreshTokenHashVersion;
65
59
  refreshTokenSalt;
66
60
  refreshTokenHash;
@@ -77,10 +71,6 @@ __decorate([
77
71
  (0, schema_1.Property)(),
78
72
  __metadata("design:type", Number)
79
73
  ], NewAuthenticationSession.prototype, "end", void 0);
80
- __decorate([
81
- (0, schema_1.Property)(),
82
- __metadata("design:type", String)
83
- ], NewAuthenticationSession.prototype, "tokenId", void 0);
84
74
  __decorate([
85
75
  (0, schema_1.Property)(),
86
76
  __metadata("design:type", Number)
@@ -1 +1 @@
1
- {"version":3,"file":"authentication-session.model.js","sourceRoot":"","sources":["../../../source/authentication/models/authentication-session.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoC;AAEpC,MAAa,qBAAqB;IAEhC,EAAE,CAAS;IAGX,OAAO,CAAS;IAEhB,gBAAgB;IAEhB,KAAK,CAAS;IAEd,gBAAgB;IAEhB,GAAG,CAAS;IAGZ,OAAO,CAAS;IAGhB,uBAAuB,CAAS;IAGhC,gBAAgB,CAAa;IAG7B,gBAAgB,CAAa;CAC9B;AAzBC;IAAC,IAAA,iBAAQ,GAAE;;iDACA;AAEX;IAAC,IAAA,iBAAQ,GAAE;;sDACK;AAGhB;IAAC,IAAA,iBAAQ,GAAE;;oDACG;AAGd;IAAC,IAAA,iBAAQ,GAAE;;kDACC;AAEZ;IAAC,IAAA,iBAAQ,GAAE;;sDACK;AAEhB;IAAC,IAAA,iBAAQ,GAAE;;sEACqB;AAEhC;IAAC,IAAA,iBAAQ,GAAE;8BACO,UAAU;+DAAC;AAE7B;IAAC,IAAA,iBAAQ,GAAE;8BACO,UAAU;+DAAC;AAzB/B,sDA0BC;AAED,MAAa,wBAAwB;IAEnC,OAAO,CAAS;IAGhB,KAAK,CAAS;IAGd,GAAG,CAAS;IAGZ,OAAO,CAAS;IAGhB,uBAAuB,CAAS;IAGhC,gBAAgB,CAAa;IAG7B,gBAAgB,CAAa;CAC9B;AApBC;IAAC,IAAA,iBAAQ,GAAE;;yDACK;AAEhB;IAAC,IAAA,iBAAQ,GAAE;;uDACG;AAEd;IAAC,IAAA,iBAAQ,GAAE;;qDACC;AAEZ;IAAC,IAAA,iBAAQ,GAAE;;yDACK;AAEhB;IAAC,IAAA,iBAAQ,GAAE;;yEACqB;AAEhC;IAAC,IAAA,iBAAQ,GAAE;8BACO,UAAU;kEAAC;AAE7B;IAAC,IAAA,iBAAQ,GAAE;8BACO,UAAU;kEAAC;AApB/B,4DAqBC"}
1
+ {"version":3,"file":"authentication-session.model.js","sourceRoot":"","sources":["../../../source/authentication/models/authentication-session.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoC;AAEpC,MAAa,qBAAqB;IAEhC,EAAE,CAAS;IAGX,OAAO,CAAS;IAEhB,gBAAgB;IAEhB,KAAK,CAAS;IAEd,gBAAgB;IAEhB,GAAG,CAAS;IAGZ,uBAAuB,CAAS;IAGhC,gBAAgB,CAAa;IAG7B,gBAAgB,CAAa;CAC9B;AAtBC;IAAC,IAAA,iBAAQ,GAAE;;iDACA;AAEX;IAAC,IAAA,iBAAQ,GAAE;;sDACK;AAGhB;IAAC,IAAA,iBAAQ,GAAE;;oDACG;AAGd;IAAC,IAAA,iBAAQ,GAAE;;kDACC;AAEZ;IAAC,IAAA,iBAAQ,GAAE;;sEACqB;AAEhC;IAAC,IAAA,iBAAQ,GAAE;8BACO,UAAU;+DAAC;AAE7B;IAAC,IAAA,iBAAQ,GAAE;8BACO,UAAU;+DAAC;AAtB/B,sDAuBC;AAED,MAAa,wBAAwB;IAEnC,OAAO,CAAS;IAGhB,KAAK,CAAS;IAGd,GAAG,CAAS;IAGZ,uBAAuB,CAAS;IAGhC,gBAAgB,CAAa;IAG7B,gBAAgB,CAAa;CAC9B;AAjBC;IAAC,IAAA,iBAAQ,GAAE;;yDACK;AAEhB;IAAC,IAAA,iBAAQ,GAAE;;uDACG;AAEd;IAAC,IAAA,iBAAQ,GAAE;;qDACC;AAEZ;IAAC,IAAA,iBAAQ,GAAE;;yEACqB;AAEhC;IAAC,IAAA,iBAAQ,GAAE;8BACO,UAAU;kEAAC;AAE7B;IAAC,IAAA,iBAAQ,GAAE;8BACO,UAAU;kEAAC;AAjB/B,4DAkBC"}
@@ -1,3 +1,4 @@
1
1
  export * from './authentication-credentials.model';
2
2
  export * from './authentication-session.model';
3
3
  export * from './token-payload-base.model';
4
+ export * from './token.model';
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./authentication-credentials.model"), exports);
18
18
  __exportStar(require("./authentication-session.model"), exports);
19
19
  __exportStar(require("./token-payload-base.model"), exports);
20
+ __exportStar(require("./token.model"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/authentication/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAmD;AACnD,iEAA+C;AAC/C,6DAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/authentication/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAmD;AACnD,iEAA+C;AAC/C,6DAA2C;AAC3C,gDAA8B"}
@@ -1,5 +1,12 @@
1
1
  export declare class TokenPayloadBase {
2
+ /** token id */
2
3
  jti: string;
4
+ /** issue timestamp in seconds */
3
5
  iat: number;
6
+ /** expiration timestamp in seconds */
4
7
  exp: number;
8
+ /** refresh token expiration timestamp in seconds */
9
+ refreshTokenExp: number;
10
+ sessionId: string;
11
+ subject: string;
5
12
  }
@@ -12,9 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TokenPayloadBase = void 0;
13
13
  const property_1 = require("../../schema/decorators/property");
14
14
  class TokenPayloadBase {
15
+ /** token id */
15
16
  jti;
17
+ /** issue timestamp in seconds */
16
18
  iat;
19
+ /** expiration timestamp in seconds */
17
20
  exp;
21
+ /** refresh token expiration timestamp in seconds */
22
+ refreshTokenExp;
23
+ sessionId;
24
+ subject;
18
25
  }
19
26
  __decorate([
20
27
  (0, property_1.Property)(),
@@ -28,5 +35,17 @@ __decorate([
28
35
  (0, property_1.Property)(),
29
36
  __metadata("design:type", Number)
30
37
  ], TokenPayloadBase.prototype, "exp", void 0);
38
+ __decorate([
39
+ (0, property_1.Property)(),
40
+ __metadata("design:type", Number)
41
+ ], TokenPayloadBase.prototype, "refreshTokenExp", void 0);
42
+ __decorate([
43
+ (0, property_1.Property)(),
44
+ __metadata("design:type", String)
45
+ ], TokenPayloadBase.prototype, "sessionId", void 0);
46
+ __decorate([
47
+ (0, property_1.Property)(),
48
+ __metadata("design:type", String)
49
+ ], TokenPayloadBase.prototype, "subject", void 0);
31
50
  exports.TokenPayloadBase = TokenPayloadBase;
32
51
  //# sourceMappingURL=token-payload-base.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-payload-base.model.js","sourceRoot":"","sources":["../../../source/authentication/models/token-payload-base.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAAwD;AAExD,MAAa,gBAAgB;IAE3B,GAAG,CAAS;IAGZ,GAAG,CAAS;IAGZ,GAAG,CAAS;CACb;AARC;IAAC,IAAA,mBAAQ,GAAE;;6CACC;AAEZ;IAAC,IAAA,mBAAQ,GAAE;;6CACC;AAEZ;IAAC,IAAA,mBAAQ,GAAE;;6CACC;AARd,4CASC"}
1
+ {"version":3,"file":"token-payload-base.model.js","sourceRoot":"","sources":["../../../source/authentication/models/token-payload-base.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAAwD;AAExD,MAAa,gBAAgB;IAC3B,eAAe;IAEf,GAAG,CAAS;IAEZ,iCAAiC;IAEjC,GAAG,CAAS;IAEZ,sCAAsC;IAEtC,GAAG,CAAS;IAEZ,oDAAoD;IAEpD,eAAe,CAAS;IAGxB,SAAS,CAAS;IAGlB,OAAO,CAAS;CACjB;AApBC;IAAC,IAAA,mBAAQ,GAAE;;6CACC;AAGZ;IAAC,IAAA,mBAAQ,GAAE;;6CACC;AAGZ;IAAC,IAAA,mBAAQ,GAAE;;6CACC;AAGZ;IAAC,IAAA,mBAAQ,GAAE;;yDACa;AAExB;IAAC,IAAA,mBAAQ,GAAE;;mDACO;AAElB;IAAC,IAAA,mBAAQ,GAAE;;iDACK;AArBlB,4CAsBC"}
@@ -0,0 +1,16 @@
1
+ import type { Record } from "../../types";
2
+ import type { JwtToken, JwtTokenHeader } from "../../utils/jwt";
3
+ import type { TokenPayloadBase } from '../models';
4
+ export type TokenHeader = {
5
+ v: number;
6
+ };
7
+ export type Token<AdditionalTokenPayload = Record<never>> = JwtToken<AdditionalTokenPayload & TokenPayloadBase, JwtTokenHeader<TokenHeader>>;
8
+ export type TokenPayload<T> = T & TokenPayloadBase;
9
+ export type RefreshTokenPayload = {
10
+ /** expiration timestamp in seconds */
11
+ exp: number;
12
+ subject: string;
13
+ sessionId: string;
14
+ secret: string;
15
+ };
16
+ export type RefreshToken = JwtToken<RefreshTokenPayload>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=token.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.model.js","sourceRoot":"","sources":["../../../source/authentication/models/token.model.ts"],"names":[],"mappings":""}
@@ -1,5 +1,5 @@
1
- import type { AuthenticationCredentials, NewAuthenticationCredentials } from './models';
1
+ import type { AuthenticationCredentials, NewAuthenticationCredentials } from '../models';
2
2
  export declare abstract class AuthenticationCredentialsRepository {
3
- abstract tryLoad(subject: string): Promise<AuthenticationCredentials | undefined>;
3
+ abstract tryLoadBySubject(subject: string): Promise<AuthenticationCredentials | undefined>;
4
4
  abstract save(credentials: NewAuthenticationCredentials | AuthenticationCredentials): Promise<void>;
5
5
  }
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.AuthenticationCredentialsRepository = void 0;
10
- const reflection_1 = require("../reflection");
10
+ const reflection_1 = require("../../reflection");
11
11
  let AuthenticationCredentialsRepository = class AuthenticationCredentialsRepository {
12
12
  };
13
13
  AuthenticationCredentialsRepository = __decorate([
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-credentials.repository.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication-credentials.repository.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iDAAqC;AAI9B,IAAe,mCAAmC,GAAlD,MAAe,mCAAmC;CAGxD,CAAA;AAHqB,mCAAmC;IADxD,IAAA,kBAAK,GAAE;GACc,mCAAmC,CAGxD;AAHqB,kFAAmC"}
@@ -1,8 +1,7 @@
1
- import type { NewEntity } from "../database";
2
- import type { AuthenticationSession } from './models';
1
+ import type { NewEntity } from "../../database";
2
+ import type { AuthenticationSession } from '../models';
3
3
  export type AuthenticationSessionExtendData = {
4
4
  end: number;
5
- tokenId: string;
6
5
  refreshTokenHashVersion: number;
7
6
  refreshTokenSalt: Uint8Array;
8
7
  refreshTokenHash: Uint8Array;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-session.repository.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication-session.repository.ts"],"names":[],"mappings":";;;AAUA,MAAsB,+BAA+B;CAQpD;AARD,0EAQC"}
@@ -0,0 +1,3 @@
1
+ export declare abstract class AuthenticationTokenPayloadProvider<TokenPayload = any, AuthenticationData = any> {
2
+ abstract getTokenPayload(subject: string, authenticationData: AuthenticationData): TokenPayload | Promise<TokenPayload>;
3
+ }
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.AuthenticationTokenPayloadProvider = void 0;
10
- const reflection_1 = require("../reflection");
10
+ const reflection_1 = require("../../reflection");
11
11
  let AuthenticationTokenPayloadProvider = class AuthenticationTokenPayloadProvider {
12
12
  };
13
13
  AuthenticationTokenPayloadProvider = __decorate([
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-token-payload.provider.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication-token-payload.provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iDAAqC;AAG9B,IAAe,kCAAkC,GAAjD,MAAe,kCAAkC;CAEvD,CAAA;AAFqB,kCAAkC;IADvD,IAAA,kBAAK,GAAE;GACc,kCAAkC,CAEvD;AAFqB,gFAAkC"}
@@ -0,0 +1,13 @@
1
+ import type { ApiController, ApiRequestData, ApiServerResult } from "../../api/types";
2
+ import type { AuthenticationApiDefinition } from '../authentication.api';
3
+ import type { TokenPayloadBase } from '../models';
4
+ import { AuthenticationService } from './authentication.service';
5
+ export declare class AuthenticationApiController<TokenPayload extends TokenPayloadBase, AuthenticationData> implements ApiController<AuthenticationApiDefinition<TokenPayload, AuthenticationData>> {
6
+ readonly authenticationService: AuthenticationService<TokenPayload, AuthenticationData>;
7
+ constructor(authenticationService: AuthenticationService<TokenPayload, AuthenticationData>);
8
+ token({ parameters }: ApiRequestData<AuthenticationApiDefinition<TokenPayload, AuthenticationData>, 'token'>): Promise<ApiServerResult<AuthenticationApiDefinition<TokenPayload, AuthenticationData>, 'token'>>;
9
+ refresh({ request, parameters }: ApiRequestData<AuthenticationApiDefinition<TokenPayload, AuthenticationData>, 'refresh'>): Promise<ApiServerResult<AuthenticationApiDefinition<TokenPayload, AuthenticationData>, 'refresh'>>;
10
+ endSession({ request }: ApiRequestData<AuthenticationApiDefinition<TokenPayload, AuthenticationData>, 'endSession'>): Promise<ApiServerResult<AuthenticationApiDefinition<TokenPayload, AuthenticationData>, 'endSession'>>;
11
+ timestamp(): ApiServerResult<AuthenticationApiDefinition<TokenPayload, AuthenticationData>, 'timestamp'>;
12
+ private getAuthenticationResponse;
13
+ }
@@ -0,0 +1,65 @@
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
+ exports.AuthenticationApiController = void 0;
13
+ const server_1 = require("../../api/server");
14
+ const unauthorized_error_1 = require("../../error/unauthorized.error");
15
+ const server_2 = require("../../http/server");
16
+ const date_time_1 = require("../../utils/date-time");
17
+ const authentication_api_1 = require("../authentication.api");
18
+ const authentication_service_1 = require("./authentication.service");
19
+ const helper_1 = require("./helper");
20
+ let AuthenticationApiController = class AuthenticationApiController {
21
+ authenticationService;
22
+ constructor(authenticationService) {
23
+ this.authenticationService = authenticationService;
24
+ }
25
+ async token({ parameters }) {
26
+ const authenticationResult = await this.authenticationService.authenticate(parameters.subject, parameters.secret);
27
+ if (!authenticationResult.success) {
28
+ throw new unauthorized_error_1.UnauthorizedError('Invalid credentials.');
29
+ }
30
+ const result = await this.authenticationService.getToken(authenticationResult.subject, parameters.data);
31
+ return this.getAuthenticationResponse(result);
32
+ }
33
+ async refresh({ request, parameters }) {
34
+ const tokenString = (0, helper_1.tryGetAuthorizationTokenStringFromRequest)(request, 'refreshToken') ?? '';
35
+ const result = await this.authenticationService.refresh(tokenString, parameters.data);
36
+ return this.getAuthenticationResponse(result);
37
+ }
38
+ async endSession({ request }) {
39
+ const tokenString = (0, helper_1.tryGetAuthorizationTokenStringFromRequest)(request) ?? '';
40
+ const token = await this.authenticationService.validateToken(tokenString);
41
+ await this.authenticationService.endSession(token.payload.sessionId);
42
+ return 'ok';
43
+ }
44
+ timestamp() {
45
+ return (0, date_time_1.currentTimestamp)();
46
+ }
47
+ getAuthenticationResponse({ token, jsonToken, refreshToken }) {
48
+ const result = jsonToken.payload;
49
+ return new server_2.HttpServerResponse({
50
+ cookies: {
51
+ authorization: { value: `Bearer ${token}`, httpOnly: true, secure: true, sameSite: 'strict', expires: jsonToken.payload.refreshTokenExp * 1000 },
52
+ refreshToken: { value: `Bearer ${refreshToken}`, httpOnly: true, secure: true, sameSite: 'strict', expires: jsonToken.payload.refreshTokenExp * 1000 }
53
+ },
54
+ body: {
55
+ json: result
56
+ }
57
+ });
58
+ }
59
+ };
60
+ AuthenticationApiController = __decorate([
61
+ (0, server_1.apiController)(authentication_api_1.authenticationApiDefinition),
62
+ __metadata("design:paramtypes", [authentication_service_1.AuthenticationService])
63
+ ], AuthenticationApiController);
64
+ exports.AuthenticationApiController = AuthenticationApiController;
65
+ //# sourceMappingURL=authentication.api-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.api-controller.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication.api-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA6C;AAE7C,uEAA+D;AAC/D,8CAAmD;AACnD,qDAAqD;AAErD,8DAAoE;AAGpE,qEAAiE;AACjE,qCAAqE;AAG9D,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAC7B,qBAAqB,CAA0D;IAExF,YAAY,qBAA8E;QACxF,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,EAAE,UAAU,EAA0F;QAChH,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAElH,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE;YACjC,MAAM,IAAI,sCAAiB,CAAC,sBAAsB,CAAC,CAAC;SACrD;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAExG,OAAO,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAA4F;QAC7H,MAAM,WAAW,GAAG,IAAA,kDAAyC,EAAC,OAAO,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC;QAC7F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAEtF,OAAO,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAE,OAAO,EAA+F;QACvH,MAAM,WAAW,GAAG,IAAA,kDAAyC,EAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAC7E,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAC1E,MAAM,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAErE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS;QACP,OAAO,IAAA,4BAAgB,GAAE,CAAC;IAC5B,CAAC;IAEO,yBAAyB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAA6B;QAC7F,MAAM,MAAM,GAA4F,SAAS,CAAC,OAAO,CAAC;QAE1H,OAAO,IAAI,2BAAkB,CAAC;YAC5B,OAAO,EAAE;gBACP,aAAa,EAAE,EAAE,KAAK,EAAE,UAAU,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,eAAe,GAAG,IAAI,EAAE;gBAChJ,YAAY,EAAE,EAAE,KAAK,EAAE,UAAU,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,eAAe,GAAG,IAAI,EAAE;aACvJ;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;aACb;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnDY,2BAA2B;IADvC,IAAA,sBAAa,EAAC,gDAA2B,CAAC;qCAIN,8CAAqB;GAH7C,2BAA2B,CAmDvC;AAnDY,kEAA2B"}
@@ -1,14 +1,12 @@
1
- import type { JwtToken, JwtTokenHeader } from "../utils/jwt";
1
+ import type { AfterResolve } from "../../container";
2
+ import { afterResolve } from "../../container";
3
+ import type { Record } from "../../types";
4
+ import type { RefreshToken, Token } from '../models';
2
5
  import { AuthenticationCredentialsRepository } from './authentication-credentials.repository';
3
6
  import { AuthenticationSessionRepository } from './authentication-session.repository';
4
7
  import { AuthenticationTokenPayloadProvider } from './authentication-token-payload.provider';
5
- import type { TokenPayloadBase } from './models';
6
- export type Token<AdditionalTokenPayload> = JwtToken<AdditionalTokenPayload & TokenPayloadBase, JwtTokenHeader<TokenHeader>>;
7
- export type TokenHeader = {
8
- v: number;
9
- };
10
8
  export type AuthenticationServiceOptions = {
11
- /** Secret used for signing tokens */
9
+ /** Secret used for signing tokens and refreshTokens */
12
10
  secret: string;
13
11
  /** Token version, forces refresh on mismatch (useful if payload changes) */
14
12
  version?: number;
@@ -18,10 +16,18 @@ export type AuthenticationServiceOptions = {
18
16
  sessionTimeToLive?: number;
19
17
  };
20
18
  export type AuthenticationResult = {
19
+ success: true;
20
+ subject: string;
21
+ } | {
22
+ success: false;
23
+ subject?: undefined;
24
+ };
25
+ export type TokenResult<AdditionalTokenPayload = Record<never>> = {
21
26
  token: string;
27
+ jsonToken: Token<AdditionalTokenPayload>;
22
28
  refreshToken: string;
23
29
  };
24
- export declare class AuthenticationService<AdditionalTokenPayload, AdditionalAuthenticationData> {
30
+ export declare class AuthenticationService<AdditionalTokenPayload = Record<never>, AdditionalAuthenticationData = Record<never>> implements AfterResolve {
25
31
  private readonly credentialsRepository;
26
32
  private readonly sessionRepository;
27
33
  private readonly tokenPayloadProviderService;
@@ -29,14 +35,20 @@ export declare class AuthenticationService<AdditionalTokenPayload, AdditionalAut
29
35
  private readonly tokenVersion;
30
36
  private readonly tokenTimeToLive;
31
37
  private readonly sessionTimeToLive;
38
+ private derivedTokenSigningSecret;
39
+ private derivedRefreshTokenSigningSecret;
32
40
  constructor(credentialsService: AuthenticationCredentialsRepository, sessionRepository: AuthenticationSessionRepository, tokenPayloadProviderService: AuthenticationTokenPayloadProvider<AdditionalTokenPayload, AdditionalAuthenticationData>, options: AuthenticationServiceOptions);
41
+ [afterResolve](): Promise<void>;
42
+ initialize(): Promise<void>;
33
43
  setCredentials(subject: string, secret: string): Promise<void>;
34
- authenticate(subject: string, secret: string): Promise<boolean>;
35
- getToken(subject: string, secret: string, additionalAuthenticationData: AdditionalAuthenticationData): Promise<AuthenticationResult>;
44
+ authenticate(subject: string, secret: string): Promise<AuthenticationResult>;
45
+ getToken(subject: string, additionalAuthenticationData: AdditionalAuthenticationData): Promise<TokenResult<AdditionalTokenPayload>>;
36
46
  endSession(sessionId: string): Promise<void>;
37
- refresh(sessionId: string, refreshToken: string, additionalAuthenticationData: AdditionalAuthenticationData): Promise<AuthenticationResult>;
47
+ refresh(refreshToken: string, additionalAuthenticationData: AdditionalAuthenticationData): Promise<TokenResult<AdditionalTokenPayload>>;
38
48
  validateToken(token: string): Promise<Token<AdditionalTokenPayload>>;
49
+ validateRefreshToken(token: string): Promise<RefreshToken>;
39
50
  private createToken;
40
51
  private createRefreshToken;
52
+ private deriveSigningSecrets;
41
53
  private getHash;
42
54
  }