@tstdl/base 0.85.26 → 0.86.0-beta10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_container/decorators.d.ts +76 -0
- package/_container/decorators.js +110 -0
- package/_container/index.d.ts +10 -0
- package/_container/index.js +27 -0
- package/_container/interfaces.d.ts +16 -0
- package/_container/interfaces.js +26 -0
- package/_container/token.d.ts +18 -0
- package/_container/token.js +41 -0
- package/api/client/client.d.ts +2 -2
- package/api/client/client.js +5 -3
- package/api/server/api-controller.d.ts +2 -2
- package/api/server/api-controller.js +5 -4
- package/api/server/api-request-token.provider.js +2 -2
- package/api/server/gateway.d.ts +5 -6
- package/api/server/gateway.js +25 -12
- package/api/server/module.js +4 -4
- package/api/server/tokens.d.ts +4 -1
- package/api/server/tokens.js +8 -2
- package/application/application.d.ts +13 -10
- package/application/application.js +38 -45
- package/authentication/client/api.client.js +3 -3
- package/authentication/client/authentication.service.d.ts +4 -4
- package/authentication/client/authentication.service.js +20 -21
- package/authentication/client/http-client.middleware.d.ts +3 -5
- package/authentication/client/http-client.middleware.js +3 -12
- package/authentication/client/module.d.ts +2 -1
- package/authentication/client/module.js +15 -7
- package/authentication/client/tokens.d.ts +2 -2
- package/authentication/client/tokens.js +5 -4
- package/authentication/server/authentication-api-request-token.provider.js +2 -2
- package/authentication/server/authentication-secret-requirements.validator.js +2 -2
- package/authentication/server/authentication.service.d.ts +2 -2
- package/authentication/server/authentication.service.js +9 -9
- package/authentication/server/module.d.ts +2 -1
- package/authentication/server/module.js +8 -7
- package/authentication/server/mongo/mongo-authentication-credentials.repository.d.ts +3 -3
- package/authentication/server/mongo/mongo-authentication-credentials.repository.js +4 -4
- package/authentication/server/mongo/mongo-authentication-session.repository.d.ts +3 -3
- package/authentication/server/mongo/mongo-authentication-session.repository.js +4 -4
- package/browser/browser-context-controller.d.ts +4 -4
- package/browser/browser-context-controller.js +15 -9
- package/browser/browser-controller.d.ts +12 -5
- package/browser/browser-controller.js +24 -10
- package/browser/browser.service.d.ts +12 -6
- package/browser/browser.service.js +13 -10
- package/browser/module.js +2 -2
- package/container/decorators.d.ts +2 -76
- package/container/decorators.js +12 -88
- package/container/index.d.ts +0 -7
- package/container/index.js +0 -7
- package/container/interfaces.d.ts +2 -16
- package/container/interfaces.js +3 -4
- package/container/token.d.ts +2 -18
- package/container/token.js +4 -19
- package/core.d.ts +4 -2
- package/core.js +15 -8
- package/database/mongo/classes.d.ts +5 -5
- package/database/mongo/classes.js +5 -4
- package/database/mongo/module.js +24 -16
- package/database/mongo/mongo-entity-repository.d.ts +2 -2
- package/database/mongo/mongo-entity-repository.js +2 -2
- package/disposable/async-disposer.d.ts +4 -4
- package/distributed-loop/distributed-loop.d.ts +3 -3
- package/distributed-loop/distributed-loop.js +3 -3
- package/distributed-loop/provider.js +2 -2
- package/examples/api/authentication.js +17 -10
- package/examples/api/basic-overview.js +4 -5
- package/examples/api/custom-authentication.js +9 -6
- package/examples/api/streaming.js +5 -5
- package/examples/browser/basic.js +5 -5
- package/examples/http/client.js +6 -4
- package/examples/mail/basic.js +9 -4
- package/examples/pdf/basic.js +9 -5
- package/examples/template/basic.js +8 -6
- package/function/log.js +1 -1
- package/http/client/adapters/undici-http-client.adapter.js +7 -6
- package/http/client/http-client-options.d.ts +0 -5
- package/http/client/http-client-options.js +0 -4
- package/http/client/http-client.d.ts +5 -8
- package/http/client/http-client.js +10 -7
- package/http/client/middleware.d.ts +6 -0
- package/http/client/middleware.js +16 -0
- package/http/client/module.d.ts +6 -1
- package/http/client/module.js +10 -5
- package/http/client/tokens.d.ts +2 -0
- package/http/client/tokens.js +25 -0
- package/http/server/node/module.js +2 -2
- package/http/server/node/node-http-server.d.ts +1 -4
- package/http/server/node/node-http-server.js +3 -7
- package/image-service/imgproxy/imgproxy-image-service.d.ts +6 -8
- package/image-service/imgproxy/imgproxy-image-service.js +17 -16
- package/injector/decorators.d.ts +12 -6
- package/injector/decorators.js +14 -0
- package/injector/index.d.ts +11 -0
- package/injector/index.js +28 -0
- package/injector/inject.d.ts +6 -1
- package/injector/inject.js +14 -2
- package/injector/injector.d.ts +14 -34
- package/injector/injector.js +91 -48
- package/injector/interfaces.d.ts +7 -5
- package/injector/provider.d.ts +19 -14
- package/injector/token.d.ts +10 -3
- package/injector/token.js +1 -1
- package/injector/type-info.d.ts +2 -0
- package/injector/types.d.ts +13 -7
- package/key-value-store/key-value.store.d.ts +3 -3
- package/key-value-store/key-value.store.js +1 -1
- package/key-value-store/mongo/module.js +4 -4
- package/key-value-store/mongo/mongo-key-value-store.provider.js +2 -2
- package/key-value-store/mongo/mongo-key-value.repository.d.ts +3 -3
- package/key-value-store/mongo/mongo-key-value.repository.js +4 -4
- package/key-value-store/mongo/mongo-key-value.store.js +3 -3
- package/key-value-store/mongo/tokens.d.ts +1 -1
- package/key-value-store/mongo/tokens.js +1 -1
- package/lock/lock.d.ts +3 -2
- package/lock/lock.js +1 -0
- package/lock/mongo/lock.js +4 -4
- package/lock/mongo/module.js +3 -3
- package/lock/mongo/mongo-lock-repository.d.ts +3 -3
- package/lock/mongo/mongo-lock-repository.js +3 -3
- package/lock/mongo/provider.js +5 -5
- package/lock/provider.d.ts +3 -2
- package/lock/provider.js +1 -0
- package/lock/web/module.js +3 -3
- package/lock/web/web-lock.js +2 -2
- package/lock/web/web-lock.provider.js +3 -3
- package/logger/console/logger.js +2 -2
- package/logger/logger.d.ts +3 -2
- package/logger/logger.js +1 -0
- package/mail/clients/nodemailer.mail-client.js +6 -5
- package/mail/mail.client.d.ts +3 -2
- package/mail/mail.client.js +1 -0
- package/mail/mail.service.js +7 -7
- package/mail/module.js +5 -5
- package/mail/repositories/mongo-mail-log.repository.d.ts +3 -3
- package/mail/repositories/mongo-mail-log.repository.js +3 -3
- package/mail/tokens.d.ts +1 -1
- package/mail/tokens.js +2 -2
- package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js +3 -3
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.d.ts +1 -1
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.js +3 -3
- package/message-bus/broadcast-channel/module.js +3 -3
- package/message-bus/local/local-message-bus-provider.js +4 -4
- package/message-bus/local/local-message-bus.d.ts +1 -1
- package/message-bus/local/local-message-bus.js +3 -3
- package/message-bus/local/module.js +3 -3
- package/message-bus/message-bus.d.ts +3 -3
- package/message-bus/message-bus.js +1 -0
- package/migration/index.d.ts +1 -1
- package/migration/index.js +1 -1
- package/migration/migrator.js +4 -4
- package/migration/mongo/migration-state-repository.d.ts +3 -3
- package/migration/mongo/migration-state-repository.js +4 -4
- package/migration/mongo/module.js +2 -2
- package/module/modules/web-server.module.d.ts +5 -10
- package/module/modules/web-server.module.js +16 -36
- package/notification/notification.service.js +2 -2
- package/object-storage/object-storage.d.ts +3 -3
- package/object-storage/object-storage.js +1 -0
- package/object-storage/s3/s3.object-storage-provider.js +6 -5
- package/object-storage/s3/s3.object-storage.d.ts +2 -2
- package/object-storage/s3/s3.object-storage.js +4 -4
- package/openid-connect/cached-oidc-configuration.service.js +3 -3
- package/openid-connect/index.d.ts +1 -1
- package/openid-connect/index.js +3 -3
- package/openid-connect/mongo-oidc-state.repository.d.ts +3 -3
- package/openid-connect/mongo-oidc-state.repository.js +6 -5
- package/openid-connect/oidc-configuration.service.js +2 -2
- package/openid-connect/oidc.service.js +4 -4
- package/package.json +1 -1
- package/pdf/pdf.service.d.ts +3 -3
- package/pdf/pdf.service.js +5 -5
- package/process-shutdown.d.ts +2 -2
- package/process-shutdown.js +6 -8
- package/queue/mongo/mongo-job.repository.d.ts +3 -3
- package/queue/mongo/mongo-job.repository.js +4 -4
- package/queue/mongo/queue.js +4 -4
- package/queue/mongo/queue.provider.d.ts +3 -3
- package/queue/mongo/queue.provider.js +8 -6
- package/queue/queue.d.ts +3 -3
- package/queue/queue.js +1 -1
- package/search-index/elastic/config.d.ts +3 -3
- package/search-index/elastic/config.js +4 -3
- package/search-index/elastic/module.d.ts +1 -3
- package/search-index/elastic/module.js +21 -18
- package/search-index/elastic/search-index.d.ts +2 -2
- package/search-index/elastic/search-index.js +2 -2
- package/templates/module.d.ts +2 -2
- package/templates/module.js +12 -26
- package/templates/providers/file.template-provider.d.ts +3 -3
- package/templates/providers/file.template-provider.js +5 -4
- package/templates/providers/memory.template-provider.js +2 -2
- package/templates/renderers/handlebars.template-renderer.js +2 -2
- package/templates/renderers/jsx.template-renderer.js +2 -2
- package/templates/renderers/mjml.template-renderer.js +3 -3
- package/templates/renderers/string.template-renderer.js +2 -2
- package/templates/resolvers/file.template-resolver.d.ts +3 -3
- package/templates/resolvers/file.template-resolver.js +6 -5
- package/templates/resolvers/jsx.template-resolver.js +2 -2
- package/templates/resolvers/string.template-resolver.js +2 -2
- package/templates/template-renderer.provider.js +3 -3
- package/templates/template-resolver.provider.js +3 -3
- package/templates/template.service.js +4 -4
- package/templates/tokens.d.ts +2 -2
- package/templates/tokens.js +3 -3
- package/text/dynamic-text.model.js +3 -4
- package/text/localization.service.js +3 -3
- package/theme/theme-service.d.ts +1 -1
- package/theme/theme-service.js +7 -6
- package/tokens.d.ts +1 -1
- package/tokens.js +2 -2
- /package/{container → _container}/container.d.ts +0 -0
- /package/{container → _container}/container.js +0 -0
- /package/{container → _container}/provider.d.ts +0 -0
- /package/{container → _container}/provider.js +0 -0
- /package/{container → _container}/resolve-chain.d.ts +0 -0
- /package/{container → _container}/resolve-chain.js +0 -0
- /package/{container → _container}/resolve.error.d.ts +0 -0
- /package/{container → _container}/resolve.error.js +0 -0
- /package/{container → _container}/type-info.d.ts +0 -0
- /package/{container → _container}/type-info.js +0 -0
- /package/{container → _container}/types.d.ts +0 -0
- /package/{container → _container}/types.js +0 -0
- /package/{container → _container}/utils.d.ts +0 -0
- /package/{container → _container}/utils.js +0 -0
|
@@ -21,8 +21,11 @@ __export(application_exports, {
|
|
|
21
21
|
Application: () => Application
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(application_exports);
|
|
24
|
-
var import_container = require("../container/index.js");
|
|
25
24
|
var import_core = require("../core.js");
|
|
25
|
+
var import_decorators = require("../injector/decorators.js");
|
|
26
|
+
var import_inject = require("../injector/inject.js");
|
|
27
|
+
var import_injector = require("../injector/injector.js");
|
|
28
|
+
var import_interfaces = require("../injector/interfaces.js");
|
|
26
29
|
var import_logger = require("../logger/index.js");
|
|
27
30
|
var import_module_base = require("../module/module-base.js");
|
|
28
31
|
var import_module = require("../module/module.js");
|
|
@@ -42,17 +45,7 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
42
45
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
43
46
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
44
47
|
};
|
|
45
|
-
var __metadata = function(k, v) {
|
|
46
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
47
|
-
return Reflect.metadata(k, v);
|
|
48
|
-
};
|
|
49
|
-
var __param = function(paramIndex, decorator) {
|
|
50
|
-
return function(target, key) {
|
|
51
|
-
decorator(target, key, paramIndex);
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
48
|
var Application_1;
|
|
55
|
-
(0, import_process_shutdown.initializeSignals)();
|
|
56
49
|
let Application = class Application2 {
|
|
57
50
|
static {
|
|
58
51
|
Application_1 = this;
|
|
@@ -60,27 +53,23 @@ let Application = class Application2 {
|
|
|
60
53
|
static _instance;
|
|
61
54
|
static get instance() {
|
|
62
55
|
if ((0, import_type_guards.isUndefined)(this._instance)) {
|
|
63
|
-
this._instance =
|
|
64
|
-
this._instance
|
|
56
|
+
this._instance = import_core.rootInjector.resolve(Application_1, "App");
|
|
57
|
+
this._instance.#shutdownToken = import_process_shutdown.shutdownToken;
|
|
65
58
|
}
|
|
66
59
|
return this._instance;
|
|
67
60
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
#name = (0, import_inject.injectArgument)(this);
|
|
62
|
+
#injector = (0, import_inject.inject)(import_injector.Injector).fork(`${this.#name}Injector`);
|
|
63
|
+
#logger = this.#injector.resolve(import_logger.Logger, this.#name);
|
|
64
|
+
#moduleTypesAndInstances = /* @__PURE__ */ new Set();
|
|
65
|
+
#shutdownPromise = new import_deferred_promise.DeferredPromise();
|
|
66
|
+
#shutdownToken = import_process_shutdown.shutdownToken.createChild();
|
|
72
67
|
get shutdownToken() {
|
|
73
|
-
return this.
|
|
68
|
+
return this.#shutdownToken.asReadonly();
|
|
74
69
|
}
|
|
75
70
|
static get shutdownToken() {
|
|
76
71
|
return Application_1.instance.shutdownToken;
|
|
77
72
|
}
|
|
78
|
-
constructor(logger) {
|
|
79
|
-
this.logger = logger;
|
|
80
|
-
this.moduleTypesAndInstances = /* @__PURE__ */ new Set();
|
|
81
|
-
this.shutdownPromise = new import_deferred_promise.DeferredPromise();
|
|
82
|
-
this._shutdownToken = import_process_shutdown.shutdownToken.createChild();
|
|
83
|
-
}
|
|
84
73
|
static registerModule(moduleType) {
|
|
85
74
|
Application_1.instance.registerModule(moduleType);
|
|
86
75
|
}
|
|
@@ -100,29 +89,31 @@ let Application = class Application2 {
|
|
|
100
89
|
Application_1.instance.requestShutdown();
|
|
101
90
|
}
|
|
102
91
|
registerModule(moduleType) {
|
|
103
|
-
this
|
|
92
|
+
this.#moduleTypesAndInstances.add(moduleType);
|
|
104
93
|
}
|
|
105
94
|
registerModuleFunction(fn) {
|
|
106
95
|
const module2 = new import_function_module.FunctionModule(fn);
|
|
107
96
|
this.registerModule(module2);
|
|
108
97
|
}
|
|
109
|
-
run(...
|
|
110
|
-
|
|
98
|
+
run(...optionsFunctionsAndModules) {
|
|
99
|
+
const options = optionsFunctionsAndModules.length > 0 && (0, import_type_guards.isObject)(optionsFunctionsAndModules[0]) ? optionsFunctionsAndModules[0] : void 0;
|
|
100
|
+
const functionsAndModules = (0, import_type_guards.isUndefined)(options) ? optionsFunctionsAndModules : optionsFunctionsAndModules.slice(1);
|
|
101
|
+
void this._run(functionsAndModules, options);
|
|
111
102
|
}
|
|
112
103
|
async shutdown() {
|
|
113
104
|
this.requestShutdown();
|
|
114
|
-
await this
|
|
105
|
+
await this.#shutdownPromise;
|
|
115
106
|
}
|
|
116
107
|
requestShutdown() {
|
|
117
108
|
if (this.shutdownToken.isSet) {
|
|
118
109
|
return;
|
|
119
110
|
}
|
|
120
|
-
this.
|
|
111
|
+
this.#shutdownToken.set();
|
|
121
112
|
}
|
|
122
113
|
async waitForShutdown() {
|
|
123
|
-
return this
|
|
114
|
+
return this.#shutdownPromise;
|
|
124
115
|
}
|
|
125
|
-
async _run(
|
|
116
|
+
async _run(functionsAndModules, options = {}) {
|
|
126
117
|
for (const fnOrModule of functionsAndModules.flatMap((fns) => fns)) {
|
|
127
118
|
if (fnOrModule.prototype instanceof import_module_base.ModuleBase) {
|
|
128
119
|
this.registerModule(fnOrModule);
|
|
@@ -130,31 +121,35 @@ let Application = class Application2 {
|
|
|
130
121
|
this.registerModuleFunction(fnOrModule);
|
|
131
122
|
}
|
|
132
123
|
}
|
|
133
|
-
|
|
124
|
+
if ((0, import_type_guards.isDefined)(options.bootstrap)) {
|
|
125
|
+
await (0, import_inject.runInInjectionContext)(this.#injector, options.bootstrap);
|
|
126
|
+
}
|
|
127
|
+
const modules = await (0, import_to_array.toArrayAsync)((0, import_map.mapAsync)(this.#moduleTypesAndInstances, async (instanceOrType) => (0, import_type_guards.isFunction)(instanceOrType) ? this.#injector.resolveAsync(instanceOrType) : instanceOrType));
|
|
134
128
|
try {
|
|
135
129
|
await Promise.race([
|
|
136
130
|
this.runModules(modules),
|
|
137
131
|
this.shutdownToken
|
|
138
132
|
]);
|
|
139
133
|
} catch (error) {
|
|
140
|
-
this
|
|
134
|
+
this.#logger.error(error, { includeRest: true, includeStack: true });
|
|
141
135
|
} finally {
|
|
142
136
|
this.requestShutdown();
|
|
143
|
-
this
|
|
137
|
+
this.#logger.info("Shutting down");
|
|
144
138
|
await this.stopModules(modules);
|
|
139
|
+
await this.#injector.dispose();
|
|
145
140
|
await (0, import_core.disposeInstances)();
|
|
146
|
-
this
|
|
141
|
+
this.#logger.info("Bye");
|
|
147
142
|
}
|
|
148
|
-
this
|
|
143
|
+
this.#shutdownPromise.resolve();
|
|
149
144
|
}
|
|
150
145
|
async runModules(modules) {
|
|
151
146
|
const promises = modules.map(async (module2) => {
|
|
152
147
|
try {
|
|
153
|
-
this
|
|
154
|
-
await module2.run();
|
|
155
|
-
this
|
|
148
|
+
this.#logger.info(`Starting module ${module2.name}`);
|
|
149
|
+
await (0, import_inject.runInInjectionContext)(this.#injector, async () => module2.run());
|
|
150
|
+
this.#logger.info(`Module ${module2.name} stopped.`);
|
|
156
151
|
} catch (error) {
|
|
157
|
-
this
|
|
152
|
+
this.#logger.error(error);
|
|
158
153
|
this.requestShutdown();
|
|
159
154
|
}
|
|
160
155
|
});
|
|
@@ -165,11 +160,11 @@ let Application = class Application2 {
|
|
|
165
160
|
if (module2.state == import_module.ModuleState.Stopped) {
|
|
166
161
|
return;
|
|
167
162
|
}
|
|
168
|
-
this
|
|
163
|
+
this.#logger.info(`Stopping module ${module2.name}`);
|
|
169
164
|
try {
|
|
170
165
|
await module2.stop();
|
|
171
166
|
} catch (error) {
|
|
172
|
-
this
|
|
167
|
+
this.#logger.error(error);
|
|
173
168
|
this.requestShutdown();
|
|
174
169
|
}
|
|
175
170
|
});
|
|
@@ -177,7 +172,5 @@ let Application = class Application2 {
|
|
|
177
172
|
}
|
|
178
173
|
};
|
|
179
174
|
Application = Application_1 = __decorate([
|
|
180
|
-
(0,
|
|
181
|
-
__param(0, (0, import_container.resolveArg)("App")),
|
|
182
|
-
__metadata("design:paramtypes", [import_logger.Logger])
|
|
175
|
+
(0, import_decorators.Singleton)()
|
|
183
176
|
], Application);
|
|
@@ -23,8 +23,8 @@ __export(api_client_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(api_client_exports);
|
|
25
25
|
var import_client = require("../../api/client/index.js");
|
|
26
|
-
var import_container = require("../../container/index.js");
|
|
27
26
|
var import_http_client = require("../../http/client/http-client.js");
|
|
27
|
+
var import_injector = require("../../injector/index.js");
|
|
28
28
|
var import_object = require("../../schema/schemas/object.js");
|
|
29
29
|
var import_unknown = require("../../schema/schemas/unknown.js");
|
|
30
30
|
var import_authentication_api = require("../authentication.api.js");
|
|
@@ -50,7 +50,7 @@ function getAuthenticationApiClient(additionalTokenPayloadSchema, authentication
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
AuthenticationApiClient3 = __decorate([
|
|
53
|
-
(0,
|
|
53
|
+
(0, import_injector.Singleton)(),
|
|
54
54
|
__metadata("design:paramtypes", [import_http_client.HttpClient])
|
|
55
55
|
], AuthenticationApiClient3);
|
|
56
56
|
return AuthenticationApiClient3;
|
|
@@ -59,5 +59,5 @@ const defaultAuthenticationApiClient = getAuthenticationApiClient(import_object.
|
|
|
59
59
|
let AuthenticationApiClient = class AuthenticationApiClient2 extends defaultAuthenticationApiClient {
|
|
60
60
|
};
|
|
61
61
|
AuthenticationApiClient = __decorate([
|
|
62
|
-
(0,
|
|
62
|
+
(0, import_injector.ReplaceClass)(defaultAuthenticationApiClient)
|
|
63
63
|
], AuthenticationApiClient);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
1
2
|
import type { ApiClient } from '../../api/client/index.js';
|
|
2
|
-
import type { AfterResolve } from '../../container/index.js';
|
|
3
|
-
import { afterResolve } from '../../container/index.js';
|
|
4
3
|
import type { AsyncDisposable } from '../../disposable/index.js';
|
|
5
4
|
import { disposeAsync } from '../../disposable/index.js';
|
|
5
|
+
import type { AfterResolve } from '../../injector/index.js';
|
|
6
|
+
import { afterResolve } from '../../injector/index.js';
|
|
6
7
|
import { Lock } from '../../lock/index.js';
|
|
7
8
|
import { Logger } from '../../logger/index.js';
|
|
8
9
|
import { MessageBus } from '../../message-bus/index.js';
|
|
9
10
|
import type { Record } from '../../types.js';
|
|
10
|
-
import type { Observable } from 'rxjs';
|
|
11
11
|
import type { AuthenticationApiDefinition } from '../authentication.api.js';
|
|
12
12
|
import type { SecretCheckResult, TokenPayload } from '../models/index.js';
|
|
13
|
-
export declare class AuthenticationService<AdditionalTokenPayload extends Record = Record
|
|
13
|
+
export declare class AuthenticationService<AdditionalTokenPayload extends Record = Record, AuthenticationData = any> implements AfterResolve, AsyncDisposable {
|
|
14
14
|
private readonly client;
|
|
15
15
|
private readonly errorSubject;
|
|
16
16
|
private readonly tokenUpdateBus;
|
|
@@ -21,8 +21,7 @@ __export(authentication_service_exports, {
|
|
|
21
21
|
AuthenticationService: () => AuthenticationService
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(authentication_service_exports);
|
|
24
|
-
var
|
|
25
|
-
var import_core = require("../../core.js");
|
|
24
|
+
var import_rxjs = require("rxjs");
|
|
26
25
|
var import_disposable = require("../../disposable/index.js");
|
|
27
26
|
var import_bad_request_error = require("../../error/bad-request.error.js");
|
|
28
27
|
var import_forbidden_error = require("../../error/forbidden.error.js");
|
|
@@ -30,6 +29,7 @@ var import_invalid_token_error = require("../../error/invalid-token.error.js");
|
|
|
30
29
|
var import_not_found_error = require("../../error/not-found.error.js");
|
|
31
30
|
var import_not_supported_error = require("../../error/not-supported.error.js");
|
|
32
31
|
var import_unauthorized_error = require("../../error/unauthorized.error.js");
|
|
32
|
+
var import_injector = require("../../injector/index.js");
|
|
33
33
|
var import_lock = require("../../lock/index.js");
|
|
34
34
|
var import_logger = require("../../logger/index.js");
|
|
35
35
|
var import_message_bus = require("../../message-bus/index.js");
|
|
@@ -38,7 +38,6 @@ var import_cancellation_token = require("../../utils/cancellation-token.js");
|
|
|
38
38
|
var import_date_time = require("../../utils/date-time.js");
|
|
39
39
|
var import_timing = require("../../utils/timing.js");
|
|
40
40
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
41
|
-
var import_rxjs = require("rxjs");
|
|
42
41
|
var import_tokens = require("./tokens.js");
|
|
43
42
|
var __decorate = function(decorators, target, key, desc) {
|
|
44
43
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -64,6 +63,7 @@ const authenticationDataStorageKey = "AuthenticationService:authentication-data"
|
|
|
64
63
|
const tokenUpdateBusName = "AuthenticationService:tokenUpdate";
|
|
65
64
|
const loggedOutBusName = "AuthenticationService:loggedOut";
|
|
66
65
|
const refreshLockResource = "AuthenticationService:refresh";
|
|
66
|
+
const localStorage = globalThis.localStorage;
|
|
67
67
|
let AuthenticationService = class AuthenticationService2 {
|
|
68
68
|
client;
|
|
69
69
|
errorSubject;
|
|
@@ -89,18 +89,18 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
89
89
|
loggedOut$;
|
|
90
90
|
get authenticationData() {
|
|
91
91
|
try {
|
|
92
|
-
const data = localStorage
|
|
93
|
-
return (0, import_type_guards.
|
|
92
|
+
const data = localStorage?.getItem(authenticationDataStorageKey);
|
|
93
|
+
return (0, import_type_guards.isNullOrUndefined)(data) ? void 0 : JSON.parse(data);
|
|
94
94
|
} catch {
|
|
95
95
|
return void 0;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
set authenticationData(data) {
|
|
99
99
|
if ((0, import_type_guards.isUndefined)(data)) {
|
|
100
|
-
localStorage
|
|
100
|
+
localStorage?.removeItem(authenticationDataStorageKey);
|
|
101
101
|
} else {
|
|
102
102
|
const json = JSON.stringify(data);
|
|
103
|
-
localStorage
|
|
103
|
+
localStorage?.setItem(authenticationDataStorageKey, json);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
get definedToken() {
|
|
@@ -130,9 +130,8 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
130
130
|
this.error$ = this.errorSubject.asObservable();
|
|
131
131
|
this.loggedOut$ = loggedOutBus.allMessages$;
|
|
132
132
|
}
|
|
133
|
-
[
|
|
133
|
+
[import_injector.afterResolve]() {
|
|
134
134
|
this.initialize();
|
|
135
|
-
import_core.disposer.add(this);
|
|
136
135
|
}
|
|
137
136
|
initialize() {
|
|
138
137
|
this.loadToken();
|
|
@@ -200,14 +199,14 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
200
199
|
return;
|
|
201
200
|
}
|
|
202
201
|
if ((0, import_type_guards.isNullOrUndefined)(token)) {
|
|
203
|
-
localStorage
|
|
202
|
+
localStorage?.removeItem(tokenStorageKey);
|
|
204
203
|
} else {
|
|
205
204
|
const serialized = JSON.stringify(token);
|
|
206
|
-
localStorage
|
|
205
|
+
localStorage?.setItem(tokenStorageKey, serialized);
|
|
207
206
|
}
|
|
208
207
|
}
|
|
209
208
|
loadToken() {
|
|
210
|
-
if ((0, import_type_guards.isUndefined)(
|
|
209
|
+
if ((0, import_type_guards.isUndefined)(localStorage)) {
|
|
211
210
|
return;
|
|
212
211
|
}
|
|
213
212
|
const existingSerializedToken = localStorage.getItem(tokenStorageKey);
|
|
@@ -252,15 +251,15 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
252
251
|
}
|
|
253
252
|
};
|
|
254
253
|
AuthenticationService = __decorate([
|
|
255
|
-
(0,
|
|
256
|
-
__param(0, (0,
|
|
257
|
-
__param(1, (0,
|
|
258
|
-
__param(2, (0,
|
|
259
|
-
__param(3, (0,
|
|
260
|
-
__param(3, (0,
|
|
261
|
-
__param(4, (0,
|
|
262
|
-
__param(4, (0,
|
|
263
|
-
__param(5, (0,
|
|
254
|
+
(0, import_injector.Singleton)(),
|
|
255
|
+
__param(0, (0, import_injector.Inject)(import_tokens.AUTHENTICATION_API_CLIENT)),
|
|
256
|
+
__param(1, (0, import_injector.ResolveArg)(tokenUpdateBusName)),
|
|
257
|
+
__param(2, (0, import_injector.ResolveArg)(loggedOutBusName)),
|
|
258
|
+
__param(3, (0, import_injector.Inject)(import_lock.Lock, refreshLockResource)),
|
|
259
|
+
__param(3, (0, import_injector.Optional)()),
|
|
260
|
+
__param(4, (0, import_injector.Inject)(import_tokens.INITIAL_AUTHENTICATION_DATA)),
|
|
261
|
+
__param(4, (0, import_injector.Optional)()),
|
|
262
|
+
__param(5, (0, import_injector.ResolveArg)("AuthenticationService")),
|
|
264
263
|
__metadata("design:paramtypes", [
|
|
265
264
|
void 0,
|
|
266
265
|
import_message_bus.MessageBus,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { HttpClientMiddleware } from '../../http/client/
|
|
2
|
-
import { AuthenticationService } from './authentication.service.js';
|
|
3
|
-
export
|
|
4
|
-
export declare const defaultAuthenticationServiceProvider: () => Promise<AuthenticationService<import("../../types.js").Record, unknown>>;
|
|
5
|
-
export declare function waitForAuthenticationCredentialsMiddleware(authenticationService?: AuthenticationService | AuthenticationServiceProvider): HttpClientMiddleware;
|
|
1
|
+
import type { HttpClientMiddleware } from '../../http/client/middleware.js';
|
|
2
|
+
import type { AuthenticationService } from './authentication.service.js';
|
|
3
|
+
export declare function waitForAuthenticationCredentialsMiddleware(authenticationService: AuthenticationService): HttpClientMiddleware;
|
|
@@ -18,26 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var http_client_middleware_exports = {};
|
|
20
20
|
__export(http_client_middleware_exports, {
|
|
21
|
-
defaultAuthenticationServiceProvider: () => defaultAuthenticationServiceProvider,
|
|
22
21
|
waitForAuthenticationCredentialsMiddleware: () => waitForAuthenticationCredentialsMiddleware
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(http_client_middleware_exports);
|
|
25
|
-
var import_container = require("../../container/index.js");
|
|
26
|
-
var import_type_guards = require("../../utils/type-guards.js");
|
|
27
24
|
var import_rxjs = require("rxjs");
|
|
28
25
|
var import_authentication_api = require("../authentication.api.js");
|
|
29
|
-
|
|
30
|
-
const defaultAuthenticationServiceProvider = async () => import_container.container.resolveAsync(import_authentication_service.AuthenticationService);
|
|
31
|
-
function waitForAuthenticationCredentialsMiddleware(authenticationService = defaultAuthenticationServiceProvider) {
|
|
32
|
-
let service = (0, import_type_guards.isNotFunction)(authenticationService) ? authenticationService : void 0;
|
|
26
|
+
function waitForAuthenticationCredentialsMiddleware(authenticationService) {
|
|
33
27
|
async function waitForAuthenticationCredentialsMiddleware2(request, next, context) {
|
|
34
28
|
const endpoint = context?.endpoint;
|
|
35
29
|
if (endpoint?.credentials == true && endpoint.data?.[import_authentication_api.dontWaitForValidToken] != true) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
while (!service.hasValidToken) {
|
|
40
|
-
await (0, import_rxjs.firstValueFrom)(service.validToken$);
|
|
30
|
+
while (!authenticationService.hasValidToken) {
|
|
31
|
+
await (0, import_rxjs.firstValueFrom)(authenticationService.validToken$);
|
|
41
32
|
}
|
|
42
33
|
}
|
|
43
34
|
return next(request);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApiClientImplementation } from '../../api/index.js';
|
|
2
|
+
import { Injector } from '../../injector/injector.js';
|
|
2
3
|
import type { Type } from '../../types.js';
|
|
3
4
|
import type { AuthenticationApiDefinition } from '../authentication.api.js';
|
|
4
5
|
export type AuthenticationModuleConfig = {
|
|
@@ -6,4 +7,4 @@ export type AuthenticationModuleConfig = {
|
|
|
6
7
|
initialAuthenticationData?: unknown;
|
|
7
8
|
registerMiddleware?: boolean;
|
|
8
9
|
};
|
|
9
|
-
export declare function configureAuthenticationClient(config?:
|
|
10
|
+
export declare function configureAuthenticationClient(config: AuthenticationModuleConfig, injector?: Injector | null): void;
|
|
@@ -21,19 +21,27 @@ __export(module_exports, {
|
|
|
21
21
|
configureAuthenticationClient: () => configureAuthenticationClient
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(module_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var import_tokens = require("../../http/client/tokens.js");
|
|
25
|
+
var import_inject = require("../../injector/inject.js");
|
|
26
|
+
var import_injector = require("../../injector/injector.js");
|
|
26
27
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
28
|
+
var import_authentication_service = require("./authentication.service.js");
|
|
27
29
|
var import_http_client_middleware = require("./http-client.middleware.js");
|
|
28
|
-
var
|
|
29
|
-
function configureAuthenticationClient(config =
|
|
30
|
+
var import_tokens2 = require("./tokens.js");
|
|
31
|
+
function configureAuthenticationClient(config, injector = (0, import_inject.getCurrentInjector)()) {
|
|
30
32
|
if ((0, import_type_guards.isDefined)(config.authenticationApiClient)) {
|
|
31
|
-
|
|
33
|
+
(injector ?? import_injector.Injector).registerSingleton(import_tokens2.AUTHENTICATION_API_CLIENT, { useToken: config.authenticationApiClient });
|
|
32
34
|
}
|
|
33
35
|
if ((0, import_type_guards.isDefined)(config.initialAuthenticationData)) {
|
|
34
|
-
|
|
36
|
+
(injector ?? import_injector.Injector).register(import_tokens2.INITIAL_AUTHENTICATION_DATA, { useValue: config.initialAuthenticationData });
|
|
35
37
|
}
|
|
36
38
|
if ((0, import_type_guards.isDefined)(config.registerMiddleware)) {
|
|
37
|
-
(0,
|
|
39
|
+
(0, import_type_guards.assertNotNull)(injector);
|
|
40
|
+
injector.register(import_tokens.HTTP_CLIENT_MIDDLEWARE, {
|
|
41
|
+
useFactory(_, context) {
|
|
42
|
+
const authenticationService = context.resolve(import_authentication_service.AuthenticationService);
|
|
43
|
+
return (0, import_http_client_middleware.waitForAuthenticationCredentialsMiddleware)(authenticationService);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
38
46
|
}
|
|
39
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ApiClientImplementation } from '../../api/index.js';
|
|
2
2
|
import type { AuthenticationApiDefinition } from '../authentication.api.js';
|
|
3
|
-
export declare const AUTHENTICATION_API_CLIENT: import("../../
|
|
4
|
-
export declare const INITIAL_AUTHENTICATION_DATA: import("../../
|
|
3
|
+
export declare const AUTHENTICATION_API_CLIENT: import("../../injector/token.js").InjectionToken<ApiClientImplementation<AuthenticationApiDefinition<any, any>>, never>;
|
|
4
|
+
export declare const INITIAL_AUTHENTICATION_DATA: import("../../injector/token.js").InjectionToken<unknown, never>;
|
|
@@ -22,8 +22,9 @@ __export(tokens_exports, {
|
|
|
22
22
|
INITIAL_AUTHENTICATION_DATA: () => INITIAL_AUTHENTICATION_DATA
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(tokens_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_injector = require("../../injector/injector.js");
|
|
26
|
+
var import_token = require("../../injector/token.js");
|
|
26
27
|
var import_api_client = require("./api.client.js");
|
|
27
|
-
const AUTHENTICATION_API_CLIENT = (0,
|
|
28
|
-
const INITIAL_AUTHENTICATION_DATA = (0,
|
|
29
|
-
|
|
28
|
+
const AUTHENTICATION_API_CLIENT = (0, import_token.injectionToken)("ApiClientImplementation");
|
|
29
|
+
const INITIAL_AUTHENTICATION_DATA = (0, import_token.injectionToken)("initial authentication data");
|
|
30
|
+
import_injector.Injector.registerSingleton(AUTHENTICATION_API_CLIENT, { useToken: import_api_client.AuthenticationApiClient });
|
|
@@ -22,7 +22,7 @@ __export(authentication_api_request_token_provider_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(authentication_api_request_token_provider_exports);
|
|
24
24
|
var import_api_request_token_provider = require("../../api/server/api-request-token.provider.js");
|
|
25
|
-
var
|
|
25
|
+
var import_decorators = require("../../injector/decorators.js");
|
|
26
26
|
var import_authentication_service = require("./authentication.service.js");
|
|
27
27
|
var import_helper = require("./helper.js");
|
|
28
28
|
var __decorate = function(decorators, target, key, desc) {
|
|
@@ -52,6 +52,6 @@ let AuthenticationApiRequestTokenProvider = class AuthenticationApiRequestTokenP
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
AuthenticationApiRequestTokenProvider = __decorate([
|
|
55
|
-
(0,
|
|
55
|
+
(0, import_decorators.Singleton)(),
|
|
56
56
|
__metadata("design:paramtypes", [import_authentication_service.AuthenticationService])
|
|
57
57
|
], AuthenticationApiRequestTokenProvider);
|
|
@@ -22,7 +22,7 @@ __export(authentication_secret_requirements_validator_exports, {
|
|
|
22
22
|
DefaultAuthenticationSecretRequirementsValidator: () => DefaultAuthenticationSecretRequirementsValidator
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(authentication_secret_requirements_validator_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_injector = require("../../injector/index.js");
|
|
26
26
|
var import_password_check_result_model = require("../../password/password-check-result.model.js");
|
|
27
27
|
var import_password_check = require("../../password/password-check.js");
|
|
28
28
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
@@ -61,5 +61,5 @@ let DefaultAuthenticationSecretRequirementsValidator = class DefaultAuthenticati
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
DefaultAuthenticationSecretRequirementsValidator = __decorate([
|
|
64
|
-
(0,
|
|
64
|
+
(0, import_injector.Singleton)({ alias: AuthenticationSecretRequirementsValidator })
|
|
65
65
|
], DefaultAuthenticationSecretRequirementsValidator);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AfterResolve } from '../../
|
|
2
|
-
import { afterResolve } from '../../
|
|
1
|
+
import type { AfterResolve } from '../../injector/index.js';
|
|
2
|
+
import { afterResolve } from '../../injector/index.js';
|
|
3
3
|
import type { Record } from '../../types.js';
|
|
4
4
|
import type { RefreshToken, SecretCheckResult, SecretResetToken, Token } from '../models/index.js';
|
|
5
5
|
import { AuthenticationCredentialsRepository } from './authentication-credentials.repository.js';
|
|
@@ -22,9 +22,9 @@ __export(authentication_service_exports, {
|
|
|
22
22
|
AuthenticationServiceOptions: () => AuthenticationServiceOptions
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(authentication_service_exports);
|
|
25
|
-
var import_container = require("../../container/index.js");
|
|
26
25
|
var import_invalid_token_error = require("../../error/invalid-token.error.js");
|
|
27
26
|
var import_not_implemented_error = require("../../error/not-implemented.error.js");
|
|
27
|
+
var import_injector = require("../../injector/index.js");
|
|
28
28
|
var import_alphabet = require("../../utils/alphabet.js");
|
|
29
29
|
var import_cryptography = require("../../utils/cryptography.js");
|
|
30
30
|
var import_date_time = require("../../utils/date-time.js");
|
|
@@ -104,7 +104,7 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
104
104
|
this.refreshTokenTimeToLive = options.refreshTokenTimeToLive ?? 5 * import_units.millisecondsPerDay;
|
|
105
105
|
this.secretResetTokenTimeToLive = options.secretResetTokenTimeToLive ?? 10 * import_units.millisecondsPerMinute;
|
|
106
106
|
}
|
|
107
|
-
async [
|
|
107
|
+
async [import_injector.afterResolve]() {
|
|
108
108
|
await this.initialize();
|
|
109
109
|
}
|
|
110
110
|
async initialize() {
|
|
@@ -304,13 +304,13 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
304
304
|
}
|
|
305
305
|
};
|
|
306
306
|
AuthenticationService = __decorate([
|
|
307
|
-
(0,
|
|
308
|
-
__param(3, (0,
|
|
309
|
-
__param(3, (0,
|
|
310
|
-
__param(4, (0,
|
|
311
|
-
__param(4, (0,
|
|
312
|
-
__param(5, (0,
|
|
313
|
-
__param(5, (0,
|
|
307
|
+
(0, import_injector.Singleton)(),
|
|
308
|
+
__param(3, (0, import_injector.Inject)(import_authentication_subject_resolver.AuthenticationSubjectResolver)),
|
|
309
|
+
__param(3, (0, import_injector.Optional)()),
|
|
310
|
+
__param(4, (0, import_injector.Inject)(import_authentication_token_payload_provider.AuthenticationTokenPayloadProvider)),
|
|
311
|
+
__param(4, (0, import_injector.Optional)()),
|
|
312
|
+
__param(5, (0, import_injector.Inject)(import_authentication_secret_reset_handler.AuthenticationSecretResetHandler)),
|
|
313
|
+
__param(5, (0, import_injector.Optional)()),
|
|
314
314
|
__metadata("design:paramtypes", [
|
|
315
315
|
import_authentication_credentials_repository.AuthenticationCredentialsRepository,
|
|
316
316
|
import_authentication_session_repository.AuthenticationSessionRepository,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Provider } from '../../injector/provider.js';
|
|
2
|
+
import type { InjectionToken } from '../../injector/token.js';
|
|
2
3
|
import { AuthenticationCredentialsRepository } from './authentication-credentials.repository.js';
|
|
3
4
|
import { AuthenticationSessionRepository } from './authentication-session.repository.js';
|
|
4
5
|
import { AuthenticationSubjectResolver } from './authentication-subject.resolver.js';
|
|
@@ -21,7 +21,8 @@ __export(module_exports, {
|
|
|
21
21
|
configureAuthenticationServer: () => configureAuthenticationServer
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(module_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_injector = require("../../injector/injector.js");
|
|
25
|
+
var import_provider = require("../../injector/provider.js");
|
|
25
26
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
26
27
|
var import_authentication_credentials_repository = require("./authentication-credentials.repository.js");
|
|
27
28
|
var import_authentication_session_repository = require("./authentication-session.repository.js");
|
|
@@ -30,19 +31,19 @@ var import_authentication_token_payload_provider = require("./authentication-tok
|
|
|
30
31
|
var import_authentication_service = require("./authentication.service.js");
|
|
31
32
|
function configureAuthenticationServer(config) {
|
|
32
33
|
if ((0, import_type_guards.isDefined)(config.serviceOptions)) {
|
|
33
|
-
|
|
34
|
+
import_injector.Injector.register(import_authentication_service.AuthenticationServiceOptions, (0, import_provider.isProvider)(config.serviceOptions) ? config.serviceOptions : { useValue: config.serviceOptions });
|
|
34
35
|
} else {
|
|
35
36
|
throw new Error("Either serviceOptions or serviceOptionsToken must be provided.");
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
import_injector.Injector.registerSingleton(import_authentication_credentials_repository.AuthenticationCredentialsRepository, { useToken: config.credentialsRepository });
|
|
39
|
+
import_injector.Injector.registerSingleton(import_authentication_session_repository.AuthenticationSessionRepository, { useToken: config.sessionRepository });
|
|
39
40
|
if ((0, import_type_guards.isDefined)(config.authenticationService)) {
|
|
40
|
-
|
|
41
|
+
import_injector.Injector.registerSingleton(import_authentication_service.AuthenticationService, { useToken: config.authenticationService });
|
|
41
42
|
}
|
|
42
43
|
if ((0, import_type_guards.isDefined)(config.tokenPayloadProvider)) {
|
|
43
|
-
|
|
44
|
+
import_injector.Injector.registerSingleton(import_authentication_token_payload_provider.AuthenticationTokenPayloadProvider, { useToken: config.tokenPayloadProvider });
|
|
44
45
|
}
|
|
45
46
|
if ((0, import_type_guards.isDefined)(config.subjectResolver)) {
|
|
46
|
-
|
|
47
|
+
import_injector.Injector.registerSingleton(import_authentication_subject_resolver.AuthenticationSubjectResolver, { useToken: config.subjectResolver });
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { Injectable } from '../../../container/index.js';
|
|
2
|
-
import { type resolveArgumentType } from '../../../container/index.js';
|
|
3
1
|
import type { MaybeNewEntity } from '../../../database/index.js';
|
|
4
2
|
import type { CollectionArgument } from '../../../database/mongo/index.js';
|
|
5
3
|
import { Collection, MongoEntityRepository } from '../../../database/mongo/index.js';
|
|
4
|
+
import { resolveArgumentType } from '../../../injector/index.js';
|
|
5
|
+
import type { Resolvable } from '../../../injector/interfaces.js';
|
|
6
6
|
import { Logger } from '../../../logger/index.js';
|
|
7
7
|
import type { AuthenticationCredentials, NewAuthenticationCredentials } from '../../models/index.js';
|
|
8
8
|
import { AuthenticationCredentialsRepository } from '../authentication-credentials.repository.js';
|
|
9
9
|
export type MongoAuthenticationCredentialsRepositoryArgument = CollectionArgument<AuthenticationCredentials>;
|
|
10
10
|
export type MongoAuthenticationCredentialsRepositoryConfig = MongoAuthenticationCredentialsRepositoryArgument;
|
|
11
|
-
export declare class InternalMongoAuthenticationCredentialsRepository extends MongoEntityRepository<AuthenticationCredentials> implements
|
|
11
|
+
export declare class InternalMongoAuthenticationCredentialsRepository extends MongoEntityRepository<AuthenticationCredentials> implements Resolvable<MongoAuthenticationCredentialsRepositoryArgument> {
|
|
12
12
|
readonly [resolveArgumentType]: MongoAuthenticationCredentialsRepositoryArgument;
|
|
13
13
|
constructor(collection: Collection<AuthenticationCredentials>, logger: Logger);
|
|
14
14
|
upsert(credentials: MaybeNewEntity<AuthenticationCredentials>): Promise<void>;
|
|
@@ -23,9 +23,9 @@ __export(mongo_authentication_credentials_repository_exports, {
|
|
|
23
23
|
configureMongoAuthenticationCredentialsRepository: () => configureMongoAuthenticationCredentialsRepository
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(mongo_authentication_credentials_repository_exports);
|
|
26
|
-
var import_container = require("../../../container/index.js");
|
|
27
26
|
var import_database = require("../../../database/index.js");
|
|
28
27
|
var import_mongo = require("../../../database/mongo/index.js");
|
|
28
|
+
var import_injector = require("../../../injector/index.js");
|
|
29
29
|
var import_logger = require("../../../logger/index.js");
|
|
30
30
|
var import_type_guards = require("../../../utils/type-guards.js");
|
|
31
31
|
var import_authentication_credentials_repository = require("../authentication-credentials.repository.js");
|
|
@@ -62,10 +62,10 @@ let InternalMongoAuthenticationCredentialsRepository = class InternalMongoAuthen
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
InternalMongoAuthenticationCredentialsRepository = __decorate([
|
|
65
|
-
(0,
|
|
65
|
+
(0, import_injector.Singleton)({
|
|
66
66
|
defaultArgumentProvider: () => defaultArgument
|
|
67
67
|
}),
|
|
68
|
-
__param(0, (0,
|
|
68
|
+
__param(0, (0, import_injector.ForwardArg)()),
|
|
69
69
|
__metadata("design:paramtypes", [import_mongo.Collection, import_logger.Logger])
|
|
70
70
|
], InternalMongoAuthenticationCredentialsRepository);
|
|
71
71
|
let MongoAuthenticationCredentialsRepository = class MongoAuthenticationCredentialsRepository2 extends import_authentication_credentials_repository.AuthenticationCredentialsRepository {
|
|
@@ -90,7 +90,7 @@ let MongoAuthenticationCredentialsRepository = class MongoAuthenticationCredenti
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
MongoAuthenticationCredentialsRepository = __decorate([
|
|
93
|
-
(0,
|
|
93
|
+
(0, import_injector.Singleton)(),
|
|
94
94
|
__metadata("design:paramtypes", [InternalMongoAuthenticationCredentialsRepository])
|
|
95
95
|
], MongoAuthenticationCredentialsRepository);
|
|
96
96
|
function configureMongoAuthenticationCredentialsRepository(config) {
|