@tstdl/base 0.82.5 → 0.82.7

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 (196) 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/models/authentication-session.model.d.ts +0 -2
  23. package/authentication/models/authentication-session.model.js +0 -10
  24. package/authentication/models/authentication-session.model.js.map +1 -1
  25. package/authentication/models/index.d.ts +1 -0
  26. package/authentication/models/index.js +1 -0
  27. package/authentication/models/index.js.map +1 -1
  28. package/authentication/models/token-payload-base.model.d.ts +7 -0
  29. package/authentication/models/token-payload-base.model.js +19 -0
  30. package/authentication/models/token-payload-base.model.js.map +1 -1
  31. package/authentication/models/token.model.d.ts +16 -0
  32. package/authentication/models/token.model.js +3 -0
  33. package/authentication/models/token.model.js.map +1 -0
  34. package/authentication/{authentication-credentials.repository.d.ts → server/authentication-credentials.repository.d.ts} +2 -2
  35. package/authentication/{authentication-credentials.repository.js → server/authentication-credentials.repository.js} +1 -1
  36. package/authentication/server/authentication-credentials.repository.js.map +1 -0
  37. package/authentication/{authentication-session.repository.d.ts → server/authentication-session.repository.d.ts} +2 -3
  38. package/authentication/{authentication-session.repository.js → server/authentication-session.repository.js} +0 -0
  39. package/authentication/server/authentication-session.repository.js.map +1 -0
  40. package/authentication/server/authentication-token-payload.provider.d.ts +3 -0
  41. package/authentication/{authentication-token-payload.provider.js → server/authentication-token-payload.provider.js} +1 -1
  42. package/authentication/server/authentication-token-payload.provider.js.map +1 -0
  43. package/authentication/server/authentication.api-controller.d.ts +13 -0
  44. package/authentication/server/authentication.api-controller.js +65 -0
  45. package/authentication/server/authentication.api-controller.js.map +1 -0
  46. package/authentication/{authentication.service.d.ts → server/authentication.service.d.ts} +23 -11
  47. package/authentication/{authentication.service.js → server/authentication.service.js} +92 -47
  48. package/authentication/server/authentication.service.js.map +1 -0
  49. package/authentication/server/helper.d.ts +13 -0
  50. package/authentication/server/helper.js +62 -0
  51. package/authentication/server/helper.js.map +1 -0
  52. package/authentication/server/module.d.ts +12 -0
  53. package/authentication/server/module.js +19 -0
  54. package/authentication/server/module.js.map +1 -0
  55. package/authentication/server/mongo/index.d.ts +2 -0
  56. package/authentication/server/mongo/index.js +19 -0
  57. package/authentication/server/mongo/index.js.map +1 -0
  58. package/authentication/{mongo → server/mongo}/mongo-authentication-credentials.repository.d.ts +15 -18
  59. package/authentication/{mongo → server/mongo}/mongo-authentication-credentials.repository.js +36 -27
  60. package/authentication/server/mongo/mongo-authentication-credentials.repository.js.map +1 -0
  61. package/authentication/{mongo → server/mongo}/mongo-authentication-session.repository.d.ts +12 -15
  62. package/authentication/{mongo → server/mongo}/mongo-authentication-session.repository.js +27 -22
  63. package/authentication/server/mongo/mongo-authentication-session.repository.js.map +1 -0
  64. package/authentication/{tokens.d.ts → server/tokens.d.ts} +1 -1
  65. package/authentication/{tokens.js → server/tokens.js} +1 -1
  66. package/authentication/server/tokens.js.map +1 -0
  67. package/container/token.d.ts +2 -2
  68. package/container/types.d.ts +2 -1
  69. package/cookie/cookie.d.ts +14 -0
  70. package/cookie/cookie.js +58 -0
  71. package/cookie/cookie.js.map +1 -0
  72. package/cookie/index.d.ts +1 -0
  73. package/cookie/index.js +18 -0
  74. package/cookie/index.js.map +1 -0
  75. package/examples/api/authentication.d.ts +1 -0
  76. package/examples/api/authentication.js +51 -0
  77. package/examples/api/authentication.js.map +1 -0
  78. package/examples/api/basic-overview.js +4 -4
  79. package/examples/api/basic-overview.js.map +1 -1
  80. package/examples/api/custom-authentication.d.ts +1 -0
  81. package/examples/api/custom-authentication.js +89 -0
  82. package/examples/api/custom-authentication.js.map +1 -0
  83. package/examples/api/streaming.js +10 -8
  84. package/examples/api/streaming.js.map +1 -1
  85. package/examples/mail/templates/hello-name.js +1 -1
  86. package/examples/mail/templates/hello-name.js.map +1 -1
  87. package/examples/pdf/templates/hello-name.js +1 -1
  88. package/examples/pdf/templates/hello-name.js.map +1 -1
  89. package/examples/template/templates/hello-jsx.js +1 -1
  90. package/examples/template/templates/hello-jsx.js.map +1 -1
  91. package/examples/template/templates/hello-name.js +1 -1
  92. package/examples/template/templates/hello-name.js.map +1 -1
  93. package/http/cookie-parser.d.ts +1 -3
  94. package/http/cookie-parser.js +10 -19
  95. package/http/cookie-parser.js.map +1 -1
  96. package/http/http-headers.d.ts +2 -2
  97. package/http/http-headers.js +11 -11
  98. package/http/http-headers.js.map +1 -1
  99. package/http/http-value-map.js +13 -13
  100. package/http/http-value-map.js.map +1 -1
  101. package/http/server/http-server-response.d.ts +8 -3
  102. package/http/server/http-server-response.js +8 -0
  103. package/http/server/http-server-response.js.map +1 -1
  104. package/http/server/node/module.d.ts +2 -2
  105. package/http/server/node/module.js +3 -5
  106. package/http/server/node/module.js.map +1 -1
  107. package/mail/clients/nodemailer.mail-client.js +1 -1
  108. package/mail/clients/nodemailer.mail-client.js.map +1 -1
  109. package/mail/mail.service.d.ts +4 -3
  110. package/mail/mail.service.js +5 -8
  111. package/mail/mail.service.js.map +1 -1
  112. package/mail/models/mail-log.model.d.ts +1 -1
  113. package/mail/models/mail-template.model.d.ts +1 -1
  114. package/mail/models/mail-template.model.js +2 -1
  115. package/mail/models/mail-template.model.js.map +1 -1
  116. package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.d.ts +1 -1
  117. package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js +21 -2
  118. package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js.map +1 -1
  119. package/message-bus/broadcast-channel/broadcast-channel-message-bus.d.ts +4 -4
  120. package/message-bus/broadcast-channel/broadcast-channel-message-bus.js +27 -4
  121. package/message-bus/broadcast-channel/broadcast-channel-message-bus.js.map +1 -1
  122. package/message-bus/broadcast-channel/index.d.ts +1 -0
  123. package/message-bus/broadcast-channel/index.js +1 -0
  124. package/message-bus/broadcast-channel/index.js.map +1 -1
  125. package/message-bus/broadcast-channel/module.d.ts +4 -0
  126. package/message-bus/broadcast-channel/module.js +17 -0
  127. package/message-bus/broadcast-channel/module.js.map +1 -0
  128. package/message-bus/local/index.d.ts +1 -0
  129. package/message-bus/local/index.js +1 -0
  130. package/message-bus/local/index.js.map +1 -1
  131. package/message-bus/local/local-message-bus-provider.d.ts +0 -5
  132. package/message-bus/local/local-message-bus-provider.js +1 -13
  133. package/message-bus/local/local-message-bus-provider.js.map +1 -1
  134. package/message-bus/local/local-message-bus.d.ts +1 -1
  135. package/message-bus/local/local-message-bus.js +2 -2
  136. package/message-bus/local/local-message-bus.js.map +1 -1
  137. package/message-bus/local/module.d.ts +4 -0
  138. package/message-bus/local/module.js +17 -0
  139. package/message-bus/local/module.js.map +1 -0
  140. package/message-bus/message-bus-base.d.ts +1 -1
  141. package/message-bus/message-bus-base.js +1 -1
  142. package/message-bus/message-bus-base.js.map +1 -1
  143. package/message-bus/message-bus.d.ts +1 -0
  144. package/message-bus/message-bus.js +3 -0
  145. package/message-bus/message-bus.js.map +1 -1
  146. package/notification/notification.service.js +2 -2
  147. package/notification/notification.service.js.map +1 -1
  148. package/object-storage/s3/s3.object.js +3 -3
  149. package/object-storage/s3/s3.object.js.map +1 -1
  150. package/package.json +6 -6
  151. package/pdf/pdf.service.d.ts +5 -4
  152. package/pdf/pdf.service.js +7 -6
  153. package/pdf/pdf.service.js.map +1 -1
  154. package/schema/schemas/assign.js +2 -0
  155. package/schema/schemas/assign.js.map +1 -1
  156. package/schema/schemas/object.d.ts +1 -0
  157. package/schema/schemas/object.js +2 -1
  158. package/schema/schemas/object.js.map +1 -1
  159. package/schema/types/types.d.ts +1 -1
  160. package/schema/utils/schema.js.map +1 -1
  161. package/templates/providers/file.template-provider.d.ts +1 -1
  162. package/templates/providers/file.template-provider.js +1 -1
  163. package/templates/providers/file.template-provider.js.map +1 -1
  164. package/templates/providers/memory.template-provider.d.ts +1 -1
  165. package/templates/providers/memory.template-provider.js +1 -1
  166. package/templates/providers/memory.template-provider.js.map +1 -1
  167. package/templates/template.model.d.ts +3 -1
  168. package/templates/template.model.js +8 -1
  169. package/templates/template.model.js.map +1 -1
  170. package/templates/template.provider.d.ts +1 -1
  171. package/templates/template.renderer.d.ts +3 -2
  172. package/templates/template.renderer.js.map +1 -1
  173. package/templates/template.service.d.ts +3 -2
  174. package/templates/template.service.js +6 -1
  175. package/templates/template.service.js.map +1 -1
  176. package/utils/array/array.js +2 -2
  177. package/utils/array/array.js.map +1 -1
  178. package/utils/string/index.d.ts +1 -0
  179. package/utils/string/index.js +1 -0
  180. package/utils/string/index.js.map +1 -1
  181. package/utils/string/title-case.d.ts +1 -0
  182. package/utils/string/title-case.js +13 -0
  183. package/utils/string/title-case.js.map +1 -0
  184. package/utils/type-guards.d.ts +1 -1
  185. package/utils/type-guards.js.map +1 -1
  186. package/utils/type-of.d.ts +1 -1
  187. package/utils/type-of.js +3 -4
  188. package/utils/type-of.js.map +1 -1
  189. package/authentication/authentication-credentials.repository.js.map +0 -1
  190. package/authentication/authentication-session.repository.js.map +0 -1
  191. package/authentication/authentication-token-payload.provider.d.ts +0 -3
  192. package/authentication/authentication-token-payload.provider.js.map +0 -1
  193. package/authentication/authentication.service.js.map +0 -1
  194. package/authentication/mongo/mongo-authentication-credentials.repository.js.map +0 -1
  195. package/authentication/mongo/mongo-authentication-session.repository.js.map +0 -1
  196. package/authentication/tokens.js.map +0 -1
@@ -4,6 +4,7 @@ exports.compileClient = exports.apiDefinitionSymbol = exports.httpClientSymbol =
4
4
  const container_1 = require("../../container");
5
5
  const client_1 = require("../../http/client");
6
6
  const schema_1 = require("../../schema");
7
+ const title_case_1 = require("../../utils/string/title-case");
7
8
  const type_guards_1 = require("../../utils/type-guards");
8
9
  const types_1 = require("../types");
9
10
  const utils_1 = require("../utils");
@@ -12,7 +13,7 @@ exports.apiDefinitionSymbol = Symbol('ApiDefinition');
12
13
  // eslint-disable-next-line max-lines-per-function
13
14
  function compileClient(definition, options = {}) {
14
15
  const { resource: path, endpoints } = definition;
15
- const constructedApiName = (path[0]?.toUpperCase() ?? '') + path.slice(1);
16
+ const constructedApiName = (0, title_case_1.toTitleCase)(path[0] ?? '');
16
17
  const apiName = `${constructedApiName}ApiClient`;
17
18
  const api = {
18
19
  [apiName]: class {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../source/api/client/client.ts"],"names":[],"mappings":";;;AACA,+CAA6D;AAE7D,8CAA8D;AAC9D,yCAAkC;AAElC,yDAA6G;AAE7G,oCAAmE;AACnE,oCAAsD;AAkBzC,QAAA,gBAAgB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAC1C,QAAA,mBAAmB,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAE3D,kDAAkD;AAClD,SAAgB,aAAa,CAA0B,UAAa,EAAE,UAAyB,EAAE;IAC/F,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;IACjD,MAAM,kBAAkB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1E,MAAM,OAAO,G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ClC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;QAClC,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,eAAM,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAqB,CAAC;AACxE,CAAC"}
package/api/types.d.ts CHANGED
@@ -68,16 +68,16 @@ export type ApiEndpointDefinition = {
68
68
  cors?: ApiEndpointDefinitionCors;
69
69
  };
70
70
  export type ApiEndpointsDefinition = Record<string, ApiEndpointDefinition | (() => ApiEndpointDefinition)>;
71
- export type ApiDefinition = {
71
+ export type ApiDefinition<Resource extends string = string, Endpoints extends ApiEndpointsDefinition = ApiEndpointsDefinition> = {
72
72
  /**
73
73
  * Default root resource for endpoints.
74
74
  */
75
- resource: string;
75
+ resource: Resource;
76
76
  /**
77
77
  * Endpoint prefix. Overwrites default from gateway.
78
78
  */
79
79
  prefix?: string | null;
80
- endpoints: ApiEndpointsDefinition;
80
+ endpoints: Endpoints;
81
81
  };
82
82
  export type ApiEndpointKeys<T extends ApiDefinition> = keyof T['endpoints'];
83
83
  export type NormalizedApiEndpoints<T extends ApiDefinition['endpoints']> = {
@@ -1,28 +1,112 @@
1
- import type { ObjectSchema, SchemaOutput } from "../schema/types/types";
2
- import type { AbstractConstructor } from "../types";
1
+ import type { ApiDefinition } from "../api/types";
2
+ import type { SchemaTestable } from "../schema/schema";
3
+ import type { ObjectSchemaOrType } from "../schema/types";
3
4
  import { TokenPayloadBase } from './models';
4
- export declare class GetTokenParameters {
5
- subject: string;
6
- secret: string;
7
- }
8
- export declare function getAuthenticationApiEndpointsDefinition<AuthenticationDataSchema extends ObjectSchema<GetTokenParameters> | AbstractConstructor<GetTokenParameters>, TokenPayloadSchema extends ObjectSchema<TokenPayloadBase> | AbstractConstructor<TokenPayloadBase>>(options?: {
9
- tokenPayloadSchema?: TokenPayloadSchema;
10
- authenticationDataSchema?: AuthenticationDataSchema;
11
- }): {
5
+ type GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload = unknown, AuthenticationData = unknown> = typeof getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>;
6
+ type AuthenticationApiEndpointsDefinition<AdditionalTokenPayload = unknown, AuthenticationData = unknown> = ReturnType<GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>>;
7
+ export type AuthenticationApiDefinition<AdditionalTokenPayload = unknown, AuthenticationData = unknown> = ApiDefinition<string, AuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>>;
8
+ export declare const authenticationApiDefinition: {
9
+ resource: string;
10
+ endpoints: {
11
+ token: {
12
+ resource: string;
13
+ method: "POST";
14
+ parameters: import("../schema/types").ObjectSchema<{
15
+ subject: string;
16
+ secret: string;
17
+ data: unknown;
18
+ }>;
19
+ result: import("../schema/types").ObjectSchema<{
20
+ jti: string;
21
+ iat: number;
22
+ exp: number;
23
+ refreshTokenExp: number;
24
+ sessionId: string;
25
+ subject: string;
26
+ }>;
27
+ };
28
+ refresh: {
29
+ resource: string;
30
+ method: "POST";
31
+ parameters: import("../schema/types").ObjectSchema<{
32
+ data: unknown;
33
+ }>;
34
+ result: import("../schema/types").ObjectSchema<{
35
+ jti: string;
36
+ iat: number;
37
+ exp: number;
38
+ refreshTokenExp: number;
39
+ sessionId: string;
40
+ subject: string;
41
+ }>;
42
+ };
43
+ endSession: {
44
+ resource: string;
45
+ method: "POST";
46
+ result: import("../schema/types").ValueSchema<"ok">;
47
+ };
48
+ timestamp: {
49
+ result: import("../schema/types").ValueSchema<number>;
50
+ };
51
+ };
52
+ };
53
+ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalEndpoints>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, resource?: string, additionalEndpoints?: AdditionalEndpoints): {
54
+ resource: string;
55
+ endpoints: {
56
+ token: {
57
+ resource: string;
58
+ method: "POST";
59
+ parameters: import("../schema/types").ObjectSchema<{
60
+ subject: string;
61
+ secret: string;
62
+ data: AuthenticationData;
63
+ }>;
64
+ result: import("../schema/types").ObjectSchema<import("type-fest").Simplify<import("type-fest/source/merge").Merge_<TokenPayloadBase, AdditionalTokenPayload>, {}>>;
65
+ };
66
+ refresh: {
67
+ resource: string;
68
+ method: "POST";
69
+ parameters: import("../schema/types").ObjectSchema<{
70
+ data: AuthenticationData;
71
+ }>;
72
+ result: import("../schema/types").ObjectSchema<import("type-fest").Simplify<import("type-fest/source/merge").Merge_<TokenPayloadBase, AdditionalTokenPayload>, {}>>;
73
+ };
74
+ endSession: {
75
+ resource: string;
76
+ method: "POST";
77
+ result: import("../schema/types").ValueSchema<"ok">;
78
+ };
79
+ timestamp: {
80
+ result: import("../schema/types").ValueSchema<number>;
81
+ };
82
+ };
83
+ };
84
+ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>): {
12
85
  token: {
13
86
  resource: string;
14
87
  method: "POST";
15
- parameters: ObjectSchema<SchemaOutput<AuthenticationDataSchema>> | AbstractConstructor<SchemaOutput<AuthenticationDataSchema>, any>;
16
- result: ObjectSchema<SchemaOutput<TokenPayloadSchema>> | AbstractConstructor<SchemaOutput<TokenPayloadSchema>, any>;
88
+ parameters: import("../schema/types").ObjectSchema<{
89
+ subject: string;
90
+ secret: string;
91
+ data: AuthenticationData;
92
+ }>;
93
+ result: import("../schema/types").ObjectSchema<import("type-fest").Simplify<import("type-fest/source/merge").Merge_<TokenPayloadBase, AdditionalTokenPayload>, {}>>;
17
94
  };
18
95
  refresh: {
19
96
  resource: string;
20
97
  method: "POST";
21
- result: ObjectSchema<SchemaOutput<TokenPayloadSchema>> | AbstractConstructor<SchemaOutput<TokenPayloadSchema>, any>;
98
+ parameters: import("../schema/types").ObjectSchema<{
99
+ data: AuthenticationData;
100
+ }>;
101
+ result: import("../schema/types").ObjectSchema<import("type-fest").Simplify<import("type-fest/source/merge").Merge_<TokenPayloadBase, AdditionalTokenPayload>, {}>>;
22
102
  };
23
103
  endSession: {
24
104
  resource: string;
25
105
  method: "POST";
26
- result: import("../schema/types/types").ValueSchema<"ok">;
106
+ result: import("../schema/types").ValueSchema<"ok">;
107
+ };
108
+ timestamp: {
109
+ result: import("../schema/types").ValueSchema<number>;
27
110
  };
28
111
  };
112
+ export {};
@@ -1,51 +1,55 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getAuthenticationApiEndpointsDefinition = exports.GetTokenParameters = void 0;
13
- const property_1 = require("../schema/decorators/property");
3
+ exports.getAuthenticationApiEndpointsDefinition = exports.getAuthenticationApiDefinition = exports.authenticationApiDefinition = void 0;
4
+ const types_1 = require("../api/types");
5
+ const assign_1 = require("../schema/schemas/assign");
14
6
  const literal_1 = require("../schema/schemas/literal");
7
+ const number_1 = require("../schema/schemas/number");
8
+ const object_1 = require("../schema/schemas/object");
9
+ const string_1 = require("../schema/schemas/string");
10
+ const unknown_1 = require("../schema/schemas/unknown");
15
11
  const models_1 = require("./models");
16
- class GetTokenParameters {
17
- subject;
18
- secret;
12
+ exports.authenticationApiDefinition = getAuthenticationApiDefinition(object_1.emptyObjectSchema, (0, unknown_1.unknown)());
13
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
14
+ function getAuthenticationApiDefinition(additionalTokenPayloadSchema, authenticationDataSchema, resource, additionalEndpoints) {
15
+ return (0, types_1.defineApi)({
16
+ resource: resource ?? 'auth',
17
+ endpoints: {
18
+ ...getAuthenticationApiEndpointsDefinition(additionalTokenPayloadSchema, authenticationDataSchema),
19
+ ...additionalEndpoints
20
+ }
21
+ });
19
22
  }
20
- __decorate([
21
- (0, property_1.Property)(),
22
- __metadata("design:type", String)
23
- ], GetTokenParameters.prototype, "subject", void 0);
24
- __decorate([
25
- (0, property_1.Property)(),
26
- __metadata("design:type", String)
27
- ], GetTokenParameters.prototype, "secret", void 0);
28
- exports.GetTokenParameters = GetTokenParameters;
23
+ exports.getAuthenticationApiDefinition = getAuthenticationApiDefinition;
29
24
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30
- function getAuthenticationApiEndpointsDefinition(options = {}) {
31
- const tokenParametersSchema = (options.authenticationDataSchema ?? GetTokenParameters);
32
- const tokenResultSchema = (options.tokenPayloadSchema ?? models_1.TokenPayloadBase);
25
+ function getAuthenticationApiEndpointsDefinition(additionalTokenPayloadSchema, authenticationDataSchema) {
26
+ const tokenResultSchema = (0, assign_1.assign)(models_1.TokenPayloadBase, additionalTokenPayloadSchema);
33
27
  return {
34
28
  token: {
35
29
  resource: 'token',
36
30
  method: 'POST',
37
- parameters: tokenParametersSchema,
31
+ parameters: (0, object_1.explicitObject)({
32
+ subject: (0, string_1.string)(),
33
+ secret: (0, string_1.string)(),
34
+ data: authenticationDataSchema
35
+ }),
38
36
  result: tokenResultSchema
39
37
  },
40
38
  refresh: {
41
39
  resource: 'refresh',
42
40
  method: 'POST',
41
+ parameters: (0, object_1.explicitObject)({
42
+ data: authenticationDataSchema
43
+ }),
43
44
  result: tokenResultSchema
44
45
  },
45
46
  endSession: {
46
47
  resource: 'end-session',
47
48
  method: 'POST',
48
49
  result: (0, literal_1.literal)('ok')
50
+ },
51
+ timestamp: {
52
+ result: (0, number_1.number)()
49
53
  }
50
54
  };
51
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.api.js","sourceRoot":"","sources":["../../source/authentication/authentication.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,4DAAwD;AACxD,uDAAmD;AAGnD,qCAA4C;AAE5C,MAAa,kBAAkB;IAE7B,OAAO,CAAS;IAGhB,MAAM,CAAS;CAChB;AALC;IAAC,IAAA,mBAAQ,GAAE;;mDACK;AAEhB;IAAC,IAAA,mBAAQ,GAAE;;kDACI;AALjB,gDAMC;AAED,4EAA4E;AAC5E,SAAgB,uCAAuC,CAIrD,UAGI,EAAE;IAEN,MAAM,qBAAqB,GAAG,CAAC,OAAO,CAAC,wBAAwB,IAAI,kBAAkB,CAAuH,CAAA;IAC5M,MAAM,iBAAiB,GAAG,CAAC,OAAO,CAAC,kBAAkB,IAAI,yBAAgB,CAA2G,CAAC;IAErL,OAAO;QACL,KAAK,EAAE;YACL,QAAQ,EAAE,OAAO;YACjB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,qBAAqB;YACjC,MAAM,EAAE,iBAAiB;SAC1B;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,iBAAiB;SAC1B;QACD,UAAU,EAAE;YACV,QAAQ,EAAE,aAAa;YACvB,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,IAAA,iBAAO,EAAC,IAAa,CAAC;SAC/B;KAC+B,CAAC;AACrC,CAAC;AA9BD,0FA8BC"}
1
+ {"version":3,"file":"authentication.api.js","sourceRoot":"","sources":["../../source/authentication/authentication.api.ts"],"names":[],"mappings":";;;AACA,wCAAwC;AAExC,qDAAiD;AACjD,uDAAmD;AACnD,qDAAiD;AACjD,qDAA4E;AAC5E,qDAAiD;AACjD,uDAAmD;AAEnD,qCAA4C;AAU/B,QAAA,2BAA2B,GAAG,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enticationApiClient_base: import("../../api/client").ApiClient<{
3
+ resource: string;
4
+ endpoints: {
5
+ token: {
6
+ resource: string;
7
+ method: "POST";
8
+ parameters: import("../../schema").ObjectSchema<{
9
+ subject: string;
10
+ secret: string;
11
+ data: unknown;
12
+ }>;
13
+ result: import("../../schema").ObjectSchema<{
14
+ jti: string;
15
+ iat: number;
16
+ exp: number;
17
+ refreshTokenExp: number;
18
+ sessionId: string;
19
+ subject: string;
20
+ }>;
21
+ };
22
+ refresh: {
23
+ resource: string;
24
+ method: "POST";
25
+ parameters: import("../../schema").ObjectSchema<{
26
+ data: unknown;
27
+ }>;
28
+ result: import("../../schema").ObjectSchema<{
29
+ jti: string;
30
+ iat: number;
31
+ exp: number;
32
+ refreshTokenExp: number;
33
+ sessionId: string;
34
+ subject: string;
35
+ }>;
36
+ };
37
+ endSession: {
38
+ resource: string;
39
+ method: "POST";
40
+ result: import("../../schema").ValueSchema<"ok">;
41
+ };
42
+ timestamp: {
43
+ result: import("../../schema").ValueSchema<number>;
44
+ };
45
+ };
46
+ }>;
47
+ export declare class AuthenticationApiClient extends AuthenticationApiClient_base {
48
+ constructor(httpClient: HttpClient);
49
+ }
50
+ export {};
@@ -0,0 +1,27 @@
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.AuthenticationApiClient = void 0;
13
+ const client_1 = require("../../api/client");
14
+ const container_1 = require("../../container");
15
+ const http_client_1 = require("../../http/client/http-client");
16
+ const authentication_api_1 = require("../authentication.api");
17
+ let AuthenticationApiClient = class AuthenticationApiClient extends (0, client_1.compileClient)(authentication_api_1.authenticationApiDefinition) {
18
+ constructor(httpClient) {
19
+ super(httpClient);
20
+ }
21
+ };
22
+ AuthenticationApiClient = __decorate([
23
+ (0, container_1.singleton)(),
24
+ __metadata("design:paramtypes", [http_client_1.HttpClient])
25
+ ], AuthenticationApiClient);
26
+ exports.AuthenticationApiClient = AuthenticationApiClient;
27
+ //# sourceMappingURL=api.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.client.js","sourceRoot":"","sources":["../../../source/authentication/client/api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA6C;AAC7C,+CAAwC;AACxC,+DAAuD;AACvD,8DAAoE;AAG7D,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,IAAA,sBAAa,EAAC,gDAA2B,CAAC;IACrF,YAAY,UAAsB;QAChC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpB,CAAC;CACF,CAAA;AAJY,uBAAuB;IADnC,IAAA,qBAAS,GAAE;qCAEc,wBAAU;GADvB,uBAAuB,CAInC;AAJY,0DAAuB"}
@@ -0,0 +1,39 @@
1
+ import type { ApiClient } from "../../api/client";
2
+ import type { AfterResolve } from "../../container";
3
+ import { afterResolve } from "../../container";
4
+ import { AsyncDisposable, disposeAsync } from "../../disposable";
5
+ import { Logger } from "../../logger";
6
+ import { MessageBus } from "../../message-bus";
7
+ import type { Observable } from 'rxjs';
8
+ import type { AuthenticationApiDefinition } from '../authentication.api';
9
+ import type { TokenPayload } from '../models';
10
+ export declare class AuthenticationService<AdditionalTokenPayload, AuthenticationData> implements AfterResolve, AsyncDisposable {
11
+ private readonly client;
12
+ private readonly errorSubject;
13
+ private readonly tokenSubject;
14
+ private readonly tokenUpdateBus;
15
+ private readonly logger;
16
+ private readonly disposeToken;
17
+ private authenticationData;
18
+ readonly error$: Observable<Error>;
19
+ readonly token$: Observable<TokenPayload<AdditionalTokenPayload> | undefined>;
20
+ readonly definedToken$: Observable<TokenPayload<AdditionalTokenPayload>>;
21
+ readonly loggedIn$: Observable<boolean>;
22
+ get loggedIn(): boolean;
23
+ get token(): TokenPayload<AdditionalTokenPayload> | undefined;
24
+ get definedToken(): TokenPayload<AdditionalTokenPayload>;
25
+ constructor(client: InstanceType<ApiClient<AuthenticationApiDefinition<TokenPayload<AdditionalTokenPayload>, AuthenticationData>>>, tokenUpdateBus: MessageBus<TokenPayload<AdditionalTokenPayload> | undefined> | undefined, initialAuthenticationData: AuthenticationData | undefined, logger: Logger);
26
+ [afterResolve](): void;
27
+ initialize(): void;
28
+ [disposeAsync](): Promise<void>;
29
+ dispose(): Promise<void>;
30
+ setAdditionalData(data: AuthenticationData): void;
31
+ login(subject: string, secret: string, data?: AuthenticationData): Promise<void>;
32
+ logout(): Promise<void>;
33
+ refresh(data?: AuthenticationData): Promise<void>;
34
+ private saveToken;
35
+ private loadToken;
36
+ private setNewToken;
37
+ private refreshLoop;
38
+ private handleError;
39
+ }
@@ -0,0 +1,176 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AuthenticationService = void 0;
16
+ const container_1 = require("../../container");
17
+ const core_1 = require("../../core");
18
+ const disposable_1 = require("../../disposable");
19
+ const invalid_token_error_1 = require("../../error/invalid-token.error");
20
+ const logger_1 = require("../../logger");
21
+ const message_bus_1 = require("../../message-bus");
22
+ const cancellation_token_1 = require("../../utils/cancellation-token");
23
+ const date_time_1 = require("../../utils/date-time");
24
+ const timing_1 = require("../../utils/timing");
25
+ const type_guards_1 = require("../../utils/type-guards");
26
+ const rxjs_1 = require("rxjs");
27
+ const tokens_1 = require("./tokens");
28
+ const tokenStorageKey = 'AuthenticationService:token';
29
+ const tokenUpdateBusName = 'AuthenticationService:tokenUpdate';
30
+ let AuthenticationService = class AuthenticationService {
31
+ client;
32
+ errorSubject;
33
+ tokenSubject;
34
+ tokenUpdateBus;
35
+ logger;
36
+ disposeToken;
37
+ authenticationData;
38
+ error$;
39
+ token$;
40
+ definedToken$;
41
+ loggedIn$;
42
+ get loggedIn() {
43
+ return (0, type_guards_1.isDefined)(this.tokenSubject.value);
44
+ }
45
+ get token() {
46
+ return this.tokenSubject.value;
47
+ }
48
+ get definedToken() {
49
+ return (0, type_guards_1.assertDefinedPass)(this.tokenSubject.value, 'No token available.');
50
+ }
51
+ constructor(client, tokenUpdateBus, initialAuthenticationData, logger) {
52
+ this.client = client;
53
+ this.tokenUpdateBus = tokenUpdateBus;
54
+ this.authenticationData = initialAuthenticationData;
55
+ this.logger = logger;
56
+ this.disposeToken = new cancellation_token_1.CancellationToken();
57
+ this.errorSubject = new rxjs_1.Subject();
58
+ this.tokenSubject = new rxjs_1.BehaviorSubject(undefined);
59
+ this.error$ = this.errorSubject.asObservable();
60
+ this.token$ = this.tokenSubject.asObservable();
61
+ this.definedToken$ = this.token$.pipe((0, rxjs_1.filter)(type_guards_1.isDefined));
62
+ this.loggedIn$ = this.token$.pipe((0, rxjs_1.map)(type_guards_1.isDefined));
63
+ }
64
+ [container_1.afterResolve]() {
65
+ this.initialize();
66
+ core_1.disposer.add(this);
67
+ }
68
+ initialize() {
69
+ this.loadToken();
70
+ this.tokenUpdateBus?.messages$.subscribe((token) => this.tokenSubject.next(token));
71
+ void this.refreshLoop();
72
+ }
73
+ async [disposable_1.disposeAsync]() {
74
+ await this.dispose();
75
+ }
76
+ async dispose() {
77
+ this.disposeToken.set();
78
+ await this.tokenUpdateBus?.dispose();
79
+ this.tokenSubject.complete();
80
+ this.errorSubject.complete();
81
+ }
82
+ setAdditionalData(data) {
83
+ this.authenticationData = data;
84
+ }
85
+ async login(subject, secret, data) {
86
+ if ((0, type_guards_1.isDefined)(data)) {
87
+ this.setAdditionalData(data);
88
+ }
89
+ const token = await this.client.token({ subject, secret, data: this.authenticationData });
90
+ this.setNewToken(token);
91
+ }
92
+ async logout() {
93
+ try {
94
+ await this.client.endSession();
95
+ }
96
+ finally {
97
+ this.setNewToken(undefined);
98
+ }
99
+ }
100
+ async refresh(data) {
101
+ if ((0, type_guards_1.isDefined)(data)) {
102
+ this.setAdditionalData(data);
103
+ }
104
+ try {
105
+ const token = await this.client.refresh({ data: this.authenticationData });
106
+ this.setNewToken(token);
107
+ }
108
+ catch (error) {
109
+ await this.handleError(error);
110
+ throw error;
111
+ }
112
+ }
113
+ saveToken(token) {
114
+ if ((0, type_guards_1.isUndefined)(globalThis.localStorage)) {
115
+ return;
116
+ }
117
+ if ((0, type_guards_1.isNullOrUndefined)(token)) {
118
+ localStorage.removeItem(tokenStorageKey);
119
+ }
120
+ else {
121
+ const serialized = JSON.stringify(token);
122
+ localStorage.setItem(tokenStorageKey, serialized);
123
+ }
124
+ }
125
+ loadToken() {
126
+ if ((0, type_guards_1.isUndefined)(globalThis.localStorage)) {
127
+ return;
128
+ }
129
+ const existingSerializedToken = localStorage.getItem(tokenStorageKey);
130
+ const token = (0, type_guards_1.isString)(existingSerializedToken)
131
+ ? JSON.parse(existingSerializedToken)
132
+ : undefined;
133
+ this.tokenSubject.next(token);
134
+ }
135
+ setNewToken(token) {
136
+ this.saveToken(token);
137
+ this.tokenSubject.next(token);
138
+ this.tokenUpdateBus?.publishAndForget(token);
139
+ }
140
+ async refreshLoop() {
141
+ while (this.disposeToken.isUnset) {
142
+ try {
143
+ const token = await (0, rxjs_1.firstValueFrom)((0, rxjs_1.race)([this.definedToken$, this.disposeToken]));
144
+ if ((0, type_guards_1.isUndefined)(token)) {
145
+ return;
146
+ }
147
+ if ((0, date_time_1.currentTimestampSeconds)() >= (token.exp - 60)) {
148
+ await this.refresh();
149
+ }
150
+ await (0, timing_1.cancelableTimeout)(2500, this.disposeToken);
151
+ }
152
+ catch {
153
+ await (0, timing_1.cancelableTimeout)(5000, this.disposeToken);
154
+ }
155
+ }
156
+ }
157
+ async handleError(error) {
158
+ this.logger.error(error);
159
+ this.errorSubject.next(error);
160
+ if (error instanceof invalid_token_error_1.InvalidTokenError) {
161
+ await this.logout();
162
+ }
163
+ }
164
+ };
165
+ AuthenticationService = __decorate([
166
+ (0, container_1.singleton)(),
167
+ __param(0, (0, container_1.inject)(tokens_1.AUTHENTICATION_API_CLIENT)),
168
+ __param(1, (0, container_1.inject)(message_bus_1.MessageBus, tokenUpdateBusName)),
169
+ __param(1, (0, container_1.optional)()),
170
+ __param(2, (0, container_1.inject)(tokens_1.INITIAL_AUTHENTICATION_DATA)),
171
+ __param(2, (0, container_1.optional)()),
172
+ __param(3, (0, container_1.resolveArg)('AuthenticationService')),
173
+ __metadata("design:paramtypes", [void 0, Object, Object, logger_1.Logger])
174
+ ], AuthenticationService);
175
+ exports.AuthenticationService = AuthenticationService;
176
+ //# sourceMappingURL=authentication.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../source/authentication/client/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,+CAAoF;AACpF,qCAAkC;AAClC,iDAA6D;AAC7D,yEAAgE;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CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE9B,IAAI,KAAK,YAAY,uCAAiB,EAAE;YACtC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;SACrB;IACH,CAAC;CACF,CAAA;AA3KY,qBAAqB;IADjC,IAAA,qBAAS,GAAE;IA6BP,WAAA,IAAA,kBAAM,EAAC,kCAAyB,CAAC,CAAA;IACjC,WAAA,IAAA,kBAAM,EAAC,wBAAU,EAAE,kBAAkB,CAAC,CAAA;IAAE,WAAA,IAAA,oBAAQ,GAAE,CAAA;IAClD,WAAA,IAAA,kBAAM,EAAC,oCAA2B,CAAC,CAAA;IAAE,WAAA,IAAA,oBAAQ,GAAE,CAAA;IAC/C,WAAA,IAAA,sBAAU,EAAiB,uBAAuB,CAAC,CAAA;6DAAS,eAAM;GA/B1D,qBAAqB,CA2KjC;AA3KY,sDAAqB"}
@@ -0,0 +1,4 @@
1
+ export * from './api.client';
2
+ export * from './authentication.service';
3
+ export * from './module';
4
+ export * from './tokens';
@@ -0,0 +1,21 @@
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("./api.client"), exports);
18
+ __exportStar(require("./authentication.service"), exports);
19
+ __exportStar(require("./module"), exports);
20
+ __exportStar(require("./tokens"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/authentication/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,2DAAyC;AACzC,2CAAyB;AACzB,2CAAyB"}
@@ -0,0 +1,8 @@
1
+ import type { ApiClientImplementation } from "../../api";
2
+ import type { Type } from "../../types";
3
+ import type { AuthenticationApiDefinition } from '../authentication.api';
4
+ export type AuthenticationModuleConfig = {
5
+ authenticationApiClient: Type<ApiClientImplementation<AuthenticationApiDefinition<any, any>>>;
6
+ initialAuthenticationData: unknown;
7
+ };
8
+ export declare function configureAuthenticationClient(config?: Partial<AuthenticationModuleConfig>): void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureAuthenticationClient = void 0;
4
+ const container_1 = require("../../container");
5
+ const type_guards_1 = require("../../utils/type-guards");
6
+ const tokens_1 = require("./tokens");
7
+ function configureAuthenticationClient(config = {}) {
8
+ if ((0, type_guards_1.isDefined)(config.authenticationApiClient)) {
9
+ container_1.container.registerSingleton(tokens_1.AUTHENTICATION_API_CLIENT, { useToken: config.authenticationApiClient });
10
+ }
11
+ if ((0, type_guards_1.isDefined)(config.initialAuthenticationData)) {
12
+ container_1.container.register(tokens_1.INITIAL_AUTHENTICATION_DATA, { useValue: config.initialAuthenticationData });
13
+ }
14
+ }
15
+ exports.configureAuthenticationClient = configureAuthenticationClient;
16
+ //# sourceMappingURL=module.js.map