@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.
- package/api/client/client.js +2 -1
- package/api/client/client.js.map +1 -1
- package/api/types.d.ts +3 -3
- package/authentication/authentication.api.d.ts +98 -14
- package/authentication/authentication.api.js +31 -27
- package/authentication/authentication.api.js.map +1 -1
- package/authentication/client/api.client.d.ts +50 -0
- package/authentication/client/api.client.js +27 -0
- package/authentication/client/api.client.js.map +1 -0
- package/authentication/client/authentication.service.d.ts +39 -0
- package/authentication/client/authentication.service.js +176 -0
- package/authentication/client/authentication.service.js.map +1 -0
- package/authentication/client/index.d.ts +4 -0
- package/authentication/client/index.js +21 -0
- package/authentication/client/index.js.map +1 -0
- package/authentication/client/module.d.ts +8 -0
- package/authentication/client/module.js +16 -0
- package/authentication/client/module.js.map +1 -0
- package/authentication/client/tokens.d.ts +4 -0
- package/authentication/client/tokens.js +7 -0
- package/authentication/client/tokens.js.map +1 -0
- package/authentication/index.d.ts +2 -0
- package/authentication/index.js +19 -0
- package/authentication/index.js.map +1 -0
- package/authentication/models/authentication-session.model.d.ts +0 -2
- package/authentication/models/authentication-session.model.js +0 -10
- package/authentication/models/authentication-session.model.js.map +1 -1
- package/authentication/models/index.d.ts +1 -0
- package/authentication/models/index.js +1 -0
- package/authentication/models/index.js.map +1 -1
- package/authentication/models/token-payload-base.model.d.ts +7 -0
- package/authentication/models/token-payload-base.model.js +19 -0
- package/authentication/models/token-payload-base.model.js.map +1 -1
- package/authentication/models/token.model.d.ts +16 -0
- package/authentication/models/token.model.js +3 -0
- package/authentication/models/token.model.js.map +1 -0
- package/authentication/{authentication-credentials.repository.d.ts → server/authentication-credentials.repository.d.ts} +2 -2
- package/authentication/{authentication-credentials.repository.js → server/authentication-credentials.repository.js} +1 -1
- package/authentication/server/authentication-credentials.repository.js.map +1 -0
- package/authentication/{authentication-session.repository.d.ts → server/authentication-session.repository.d.ts} +2 -3
- package/authentication/{authentication-session.repository.js → server/authentication-session.repository.js} +0 -0
- package/authentication/server/authentication-session.repository.js.map +1 -0
- package/authentication/server/authentication-token-payload.provider.d.ts +3 -0
- package/authentication/{authentication-token-payload.provider.js → server/authentication-token-payload.provider.js} +1 -1
- package/authentication/server/authentication-token-payload.provider.js.map +1 -0
- package/authentication/server/authentication.api-controller.d.ts +13 -0
- package/authentication/server/authentication.api-controller.js +65 -0
- package/authentication/server/authentication.api-controller.js.map +1 -0
- package/authentication/{authentication.service.d.ts → server/authentication.service.d.ts} +23 -11
- package/authentication/{authentication.service.js → server/authentication.service.js} +92 -47
- package/authentication/server/authentication.service.js.map +1 -0
- package/authentication/server/helper.d.ts +13 -0
- package/authentication/server/helper.js +62 -0
- package/authentication/server/helper.js.map +1 -0
- package/authentication/server/index.d.ts +8 -0
- package/authentication/server/index.js +25 -0
- package/authentication/server/index.js.map +1 -0
- package/authentication/server/module.d.ts +12 -0
- package/authentication/server/module.js +19 -0
- package/authentication/server/module.js.map +1 -0
- package/authentication/server/mongo/index.d.ts +2 -0
- package/authentication/server/mongo/index.js +19 -0
- package/authentication/server/mongo/index.js.map +1 -0
- package/authentication/{mongo → server/mongo}/mongo-authentication-credentials.repository.d.ts +15 -18
- package/authentication/{mongo → server/mongo}/mongo-authentication-credentials.repository.js +36 -27
- package/authentication/server/mongo/mongo-authentication-credentials.repository.js.map +1 -0
- package/authentication/{mongo → server/mongo}/mongo-authentication-session.repository.d.ts +12 -15
- package/authentication/{mongo → server/mongo}/mongo-authentication-session.repository.js +27 -22
- package/authentication/server/mongo/mongo-authentication-session.repository.js.map +1 -0
- package/authentication/{tokens.d.ts → server/tokens.d.ts} +1 -1
- package/authentication/{tokens.js → server/tokens.js} +1 -1
- package/authentication/server/tokens.js.map +1 -0
- package/container/token.d.ts +2 -2
- package/container/types.d.ts +2 -1
- package/cookie/cookie.d.ts +14 -0
- package/cookie/cookie.js +58 -0
- package/cookie/cookie.js.map +1 -0
- package/cookie/index.d.ts +1 -0
- package/cookie/index.js +18 -0
- package/cookie/index.js.map +1 -0
- package/examples/api/authentication.d.ts +1 -0
- package/examples/api/authentication.js +51 -0
- package/examples/api/authentication.js.map +1 -0
- package/examples/api/basic-overview.js +4 -4
- package/examples/api/basic-overview.js.map +1 -1
- package/examples/api/custom-authentication.d.ts +1 -0
- package/examples/api/custom-authentication.js +89 -0
- package/examples/api/custom-authentication.js.map +1 -0
- package/examples/api/streaming.js +10 -8
- package/examples/api/streaming.js.map +1 -1
- package/http/cookie-parser.d.ts +1 -3
- package/http/cookie-parser.js +10 -19
- package/http/cookie-parser.js.map +1 -1
- package/http/http-headers.d.ts +2 -2
- package/http/http-headers.js +11 -11
- package/http/http-headers.js.map +1 -1
- package/http/http-value-map.js +13 -13
- package/http/http-value-map.js.map +1 -1
- package/http/server/http-server-response.d.ts +8 -3
- package/http/server/http-server-response.js +8 -0
- package/http/server/http-server-response.js.map +1 -1
- package/http/server/node/module.d.ts +2 -2
- package/http/server/node/module.js +3 -5
- package/http/server/node/module.js.map +1 -1
- package/mail/clients/nodemailer.mail-client.js +1 -1
- package/mail/clients/nodemailer.mail-client.js.map +1 -1
- package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.d.ts +1 -1
- package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js +21 -2
- package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js.map +1 -1
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.d.ts +4 -4
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.js +27 -4
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.js.map +1 -1
- package/message-bus/broadcast-channel/index.d.ts +1 -0
- package/message-bus/broadcast-channel/index.js +1 -0
- package/message-bus/broadcast-channel/index.js.map +1 -1
- package/message-bus/broadcast-channel/module.d.ts +4 -0
- package/message-bus/broadcast-channel/module.js +17 -0
- package/message-bus/broadcast-channel/module.js.map +1 -0
- package/message-bus/local/index.d.ts +1 -0
- package/message-bus/local/index.js +1 -0
- package/message-bus/local/index.js.map +1 -1
- package/message-bus/local/local-message-bus-provider.d.ts +0 -5
- package/message-bus/local/local-message-bus-provider.js +1 -13
- package/message-bus/local/local-message-bus-provider.js.map +1 -1
- package/message-bus/local/local-message-bus.d.ts +1 -1
- package/message-bus/local/local-message-bus.js +2 -2
- package/message-bus/local/local-message-bus.js.map +1 -1
- package/message-bus/local/module.d.ts +4 -0
- package/message-bus/local/module.js +17 -0
- package/message-bus/local/module.js.map +1 -0
- package/message-bus/message-bus-base.d.ts +1 -1
- package/message-bus/message-bus-base.js +1 -1
- package/message-bus/message-bus-base.js.map +1 -1
- package/message-bus/message-bus.d.ts +1 -0
- package/message-bus/message-bus.js +3 -0
- package/message-bus/message-bus.js.map +1 -1
- package/notification/notification.service.js +2 -2
- package/notification/notification.service.js.map +1 -1
- package/object-storage/s3/s3.object.js +3 -3
- package/object-storage/s3/s3.object.js.map +1 -1
- package/package.json +4 -4
- package/schema/schemas/assign.js +2 -0
- package/schema/schemas/assign.js.map +1 -1
- package/schema/schemas/object.d.ts +1 -0
- package/schema/schemas/object.js +2 -1
- package/schema/schemas/object.js.map +1 -1
- package/schema/types/types.d.ts +1 -1
- package/schema/utils/schema.js.map +1 -1
- package/utils/array/array.js +2 -2
- package/utils/array/array.js.map +1 -1
- package/utils/string/index.d.ts +1 -0
- package/utils/string/index.js +1 -0
- package/utils/string/index.js.map +1 -1
- package/utils/string/title-case.d.ts +1 -0
- package/utils/string/title-case.js +13 -0
- package/utils/string/title-case.js.map +1 -0
- package/utils/type-guards.d.ts +1 -1
- package/utils/type-guards.js.map +1 -1
- package/utils/type-of.d.ts +1 -1
- package/utils/type-of.js +3 -4
- package/utils/type-of.js.map +1 -1
- package/authentication/authentication-credentials.repository.js.map +0 -1
- package/authentication/authentication-session.repository.js.map +0 -1
- package/authentication/authentication-token-payload.provider.d.ts +0 -3
- package/authentication/authentication-token-payload.provider.js.map +0 -1
- package/authentication/authentication.service.js.map +0 -1
- package/authentication/mongo/mongo-authentication-credentials.repository.js.map +0 -1
- package/authentication/mongo/mongo-authentication-session.repository.js.map +0 -1
- 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,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,
|
|
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"}
|
|
@@ -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;
|
|
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 @@
|
|
|
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 '
|
|
1
|
+
import type { AuthenticationCredentials, NewAuthenticationCredentials } from '../models';
|
|
2
2
|
export declare abstract class AuthenticationCredentialsRepository {
|
|
3
|
-
abstract
|
|
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("
|
|
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 "
|
|
2
|
-
import type { AuthenticationSession } from '
|
|
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;
|
|
File without changes
|
|
@@ -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"}
|
|
@@ -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("
|
|
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 {
|
|
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
|
|
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<
|
|
35
|
-
getToken(subject: string,
|
|
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(
|
|
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
|
}
|