@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.
- 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/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/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/examples/mail/templates/hello-name.js +1 -1
- package/examples/mail/templates/hello-name.js.map +1 -1
- package/examples/pdf/templates/hello-name.js +1 -1
- package/examples/pdf/templates/hello-name.js.map +1 -1
- package/examples/template/templates/hello-jsx.js +1 -1
- package/examples/template/templates/hello-jsx.js.map +1 -1
- package/examples/template/templates/hello-name.js +1 -1
- package/examples/template/templates/hello-name.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/mail/mail.service.d.ts +4 -3
- package/mail/mail.service.js +5 -8
- package/mail/mail.service.js.map +1 -1
- package/mail/models/mail-log.model.d.ts +1 -1
- package/mail/models/mail-template.model.d.ts +1 -1
- package/mail/models/mail-template.model.js +2 -1
- package/mail/models/mail-template.model.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 +6 -6
- package/pdf/pdf.service.d.ts +5 -4
- package/pdf/pdf.service.js +7 -6
- package/pdf/pdf.service.js.map +1 -1
- 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/templates/providers/file.template-provider.d.ts +1 -1
- package/templates/providers/file.template-provider.js +1 -1
- package/templates/providers/file.template-provider.js.map +1 -1
- package/templates/providers/memory.template-provider.d.ts +1 -1
- package/templates/providers/memory.template-provider.js +1 -1
- package/templates/providers/memory.template-provider.js.map +1 -1
- package/templates/template.model.d.ts +3 -1
- package/templates/template.model.js +8 -1
- package/templates/template.model.js.map +1 -1
- package/templates/template.provider.d.ts +1 -1
- package/templates/template.renderer.d.ts +3 -2
- package/templates/template.renderer.js.map +1 -1
- package/templates/template.service.d.ts +3 -2
- package/templates/template.service.js +6 -1
- package/templates/template.service.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":"authentication.service.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAAwE;AACxE,yEAAgE;AAEhE,mDAA4C;AAC5C,2DAAuD;AACvD,qDAA2G;AAC3G,+CAA8C;AAC9C,yCAAmF;AACnF,+CAAiE;AACjE,yDAAkD;AAClD,6CAA0E;AAE1E,mGAA8F;AAC9F,2FAAsF;AACtF,mGAA6F;AAC7F,qCAA8C;AAC9C,qCAA0D;AAsC1D,MAAM,sBAAsB,GA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,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAEhI,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF,CAAA;AAlNY,qBAAqB;IADjC,IAAA,qBAAS,GAAE;IAiBP,WAAA,IAAA,oBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,kBAAM,EAAC,uCAA8B,CAAC,CAAA;qCAHnB,2EAAmC;QACpC,mEAA+B;QACT,0EAAkC;GAhBlE,qBAAqB,CAkNjC;AAlNY,sDAAqB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HttpServerRequest } from "../../http/server";
|
|
2
|
+
import type { Record } from "../../types";
|
|
3
|
+
import type { Token } from '../models';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param request
|
|
7
|
+
* @param cookieName (default "authorization")
|
|
8
|
+
* @returns token string
|
|
9
|
+
*/
|
|
10
|
+
export declare function tryGetAuthorizationTokenStringFromRequest(request: HttpServerRequest, cookieName?: string): string | undefined;
|
|
11
|
+
export declare function tryGetTokenFromRequest<AdditionalTokenPayload = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload> | undefined>;
|
|
12
|
+
export declare function getTokenFromRequest<AdditionalTokenPayload = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload>>;
|
|
13
|
+
export declare function getTokenFromString<AdditionalTokenPayload = Record<never>>(tokenString: string, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload>>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTokenFromString = exports.getTokenFromRequest = exports.tryGetTokenFromRequest = exports.tryGetAuthorizationTokenStringFromRequest = void 0;
|
|
4
|
+
const bad_request_error_1 = require("../../error/bad-request.error");
|
|
5
|
+
const invalid_token_error_1 = require("../../error/invalid-token.error");
|
|
6
|
+
const unauthorized_error_1 = require("../../error/unauthorized.error");
|
|
7
|
+
const date_time_1 = require("../../utils/date-time");
|
|
8
|
+
const jwt_1 = require("../../utils/jwt");
|
|
9
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param request
|
|
13
|
+
* @param cookieName (default "authorization")
|
|
14
|
+
* @returns token string
|
|
15
|
+
*/
|
|
16
|
+
function tryGetAuthorizationTokenStringFromRequest(request, cookieName = 'authorization') {
|
|
17
|
+
const authorizationHeaders = request.headers.tryGet('Authorization');
|
|
18
|
+
const authorizationString = ((0, type_guards_1.isArray)(authorizationHeaders) ? authorizationHeaders[0] : authorizationHeaders)
|
|
19
|
+
?? request.cookies.tryGet(cookieName);
|
|
20
|
+
if ((0, type_guards_1.isDefined)(authorizationString)) {
|
|
21
|
+
const authorizationSchemeEnd = authorizationString.indexOf(' ');
|
|
22
|
+
const authorizationScheme = authorizationString.slice(0, authorizationSchemeEnd).trim().toLowerCase();
|
|
23
|
+
if (authorizationScheme == 'bearer') {
|
|
24
|
+
throw new bad_request_error_1.BadRequestError(`Unsupported authorization scheme "${authorizationScheme}".`);
|
|
25
|
+
}
|
|
26
|
+
const authorization = authorizationString.slice(authorizationSchemeEnd).trim();
|
|
27
|
+
return authorization;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
exports.tryGetAuthorizationTokenStringFromRequest = tryGetAuthorizationTokenStringFromRequest;
|
|
32
|
+
async function tryGetTokenFromRequest(request, tokenVersion, secret) {
|
|
33
|
+
const tokenString = tryGetAuthorizationTokenStringFromRequest(request);
|
|
34
|
+
if ((0, type_guards_1.isUndefined)(tokenString)) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return getTokenFromString(tokenString, tokenVersion, secret);
|
|
38
|
+
}
|
|
39
|
+
exports.tryGetTokenFromRequest = tryGetTokenFromRequest;
|
|
40
|
+
async function getTokenFromRequest(request, tokenVersion, secret) {
|
|
41
|
+
const token = await tryGetTokenFromRequest(request, tokenVersion, secret);
|
|
42
|
+
if ((0, type_guards_1.isUndefined)(token)) {
|
|
43
|
+
throw new unauthorized_error_1.UnauthorizedError('Missing authorization.');
|
|
44
|
+
}
|
|
45
|
+
return token;
|
|
46
|
+
}
|
|
47
|
+
exports.getTokenFromRequest = getTokenFromRequest;
|
|
48
|
+
async function getTokenFromString(tokenString, tokenVersion, secret) {
|
|
49
|
+
if ((0, type_guards_1.isUndefined)(tokenString)) {
|
|
50
|
+
throw new unauthorized_error_1.UnauthorizedError('Missing authorization.');
|
|
51
|
+
}
|
|
52
|
+
const validatedToken = await (0, jwt_1.parseAndValidateJwtTokenString)(tokenString, 'HS256', secret);
|
|
53
|
+
if (validatedToken.header.v != tokenVersion) {
|
|
54
|
+
throw new invalid_token_error_1.InvalidTokenError('Invalid token version.');
|
|
55
|
+
}
|
|
56
|
+
if (validatedToken.payload.exp <= (0, date_time_1.currentTimestampSeconds)()) {
|
|
57
|
+
throw new invalid_token_error_1.InvalidTokenError('Token expired.');
|
|
58
|
+
}
|
|
59
|
+
return validatedToken;
|
|
60
|
+
}
|
|
61
|
+
exports.getTokenFromString = getTokenFromString;
|
|
62
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../source/authentication/server/helper.ts"],"names":[],"mappings":";;;AAAA,qEAA4D;AAC5D,yEAAgE;AAChE,uEAA+D;AAG/D,qDAA4D;AAC5D,yCAA6D;AAC7D,yDAAsE;AAGtE;;;;;GAKG;AACH,SAAgB,yCAAyC,CAAC,OAA0B,EAAE,aAAqB,eAAe;IACxH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,YAAY,EAAE,MAAM,CAAC,CAAC;IAElG,IAAI,IAAA,yBAAW,EAAC,KAAK,CAAC,EAAE;QACtB,MAAM,IAAI,sCAAiB,CAAC,wBAAwB,CAAC,CAAC;KACvD;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AARD,kDAQC;AAEM,KAAK,UAAU,kBAAkB,CAAyC,WAAmB,EAAE,YAAoB,EAAE,MAA2B;IACrJ,IAAI,IAAA,yBAAW,EAAC,WAAW,CAAC,EAAE;QAC5B,MAAM,IAAI,sCAAiB,CAAC,wBAAwB,CAAC,CAAC;KACvD;IAED,MAAM,cAAc,GAAG,MAAM,IAAA,oCAA8B,EAAgC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAEzH,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,YAAY,EAAE;QAC3C,MAAM,IAAI,uCAAiB,CAAC,wBAAwB,CAAC,CAAC;KACvD;IAED,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,IAAI,IAAA,mCAAuB,GAAE,EAAE;QAC3D,MAAM,IAAI,uCAAiB,CAAC,gBAAgB,CAAC,CAAC;KAC/C;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAhBD,gDAgBC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Type } from "../../types";
|
|
2
|
+
import { AuthenticationCredentialsRepository } from './authentication-credentials.repository';
|
|
3
|
+
import { AuthenticationSessionRepository } from './authentication-session.repository';
|
|
4
|
+
import { AuthenticationTokenPayloadProvider } from './authentication-token-payload.provider';
|
|
5
|
+
import type { AuthenticationServiceOptions } from './authentication.service';
|
|
6
|
+
export type AuthenticationModuleConfig = {
|
|
7
|
+
serviceOptions: AuthenticationServiceOptions;
|
|
8
|
+
credentialsRepository: Type<AuthenticationCredentialsRepository>;
|
|
9
|
+
sessionRepository: Type<AuthenticationSessionRepository>;
|
|
10
|
+
tokenPayloadProvider?: Type<AuthenticationTokenPayloadProvider>;
|
|
11
|
+
};
|
|
12
|
+
export declare function configureAuthenticationServer(config: AuthenticationModuleConfig): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureAuthenticationServer = void 0;
|
|
4
|
+
const container_1 = require("../../container");
|
|
5
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
6
|
+
const authentication_credentials_repository_1 = require("./authentication-credentials.repository");
|
|
7
|
+
const authentication_session_repository_1 = require("./authentication-session.repository");
|
|
8
|
+
const authentication_token_payload_provider_1 = require("./authentication-token-payload.provider");
|
|
9
|
+
const tokens_1 = require("./tokens");
|
|
10
|
+
function configureAuthenticationServer(config) {
|
|
11
|
+
container_1.container.register(tokens_1.AUTHENTICATION_SERVICE_OPTIONS, { useValue: config.serviceOptions });
|
|
12
|
+
container_1.container.registerSingleton(authentication_credentials_repository_1.AuthenticationCredentialsRepository, { useToken: config.credentialsRepository });
|
|
13
|
+
container_1.container.registerSingleton(authentication_session_repository_1.AuthenticationSessionRepository, { useToken: config.sessionRepository });
|
|
14
|
+
if ((0, type_guards_1.isDefined)(config.tokenPayloadProvider)) {
|
|
15
|
+
container_1.container.registerSingleton(authentication_token_payload_provider_1.AuthenticationTokenPayloadProvider, { useToken: config.tokenPayloadProvider });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.configureAuthenticationServer = configureAuthenticationServer;
|
|
19
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../source/authentication/server/module.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAExC,yDAAgD;AAChD,mGAA8F;AAC9F,2FAAsF;AACtF,mGAA6F;AAE7F,qCAA0D;AAS1D,SAAgB,6BAA6B,CAAC,MAAkC;IAC9E,qBAAS,CAAC,QAAQ,CAAC,uCAA8B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IACxF,qBAAS,CAAC,iBAAiB,CAAC,2EAAmC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC7G,qBAAS,CAAC,iBAAiB,CAAC,mEAA+B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAErG,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE;QAC1C,qBAAS,CAAC,iBAAiB,CAAC,0EAAkC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,oBAAoB,EAAE,CAAC,CAAC;KAC5G;AACH,CAAC;AARD,sEAQC"}
|
|
@@ -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("./mongo-authentication-credentials.repository"), exports);
|
|
18
|
+
__exportStar(require("./mongo-authentication-session.repository"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../source/authentication/server/mongo/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gFAA8D;AAC9D,4EAA0D"}
|
package/authentication/{mongo → server/mongo}/mongo-authentication-credentials.repository.d.ts
RENAMED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import type { Injectable } from "
|
|
2
|
-
import { resolveArgumentType } from "
|
|
3
|
-
import { MaybeNewEntity } from "
|
|
4
|
-
import type { CollectionArgument } from "
|
|
5
|
-
import { Collection, MongoEntityRepository } from "
|
|
6
|
-
import { Logger } from "
|
|
1
|
+
import type { Injectable } from "../../../container";
|
|
2
|
+
import { resolveArgumentType } from "../../../container";
|
|
3
|
+
import type { MaybeNewEntity } from "../../../database";
|
|
4
|
+
import type { CollectionArgument } from "../../../database/mongo";
|
|
5
|
+
import { Collection, MongoEntityRepository } from "../../../database/mongo";
|
|
6
|
+
import { Logger } from "../../../logger";
|
|
7
|
+
import type { AuthenticationCredentials, NewAuthenticationCredentials } from '../../models';
|
|
7
8
|
import { AuthenticationCredentialsRepository } from '../authentication-credentials.repository';
|
|
8
|
-
import type { AuthenticationCredentials, NewAuthenticationCredentials } from '../models';
|
|
9
|
-
export type MongoAuthenticationCredentialsRepositoryConfig = {
|
|
10
|
-
config?: MongoAuthenticationCredentialsRepositoryArgument;
|
|
11
|
-
};
|
|
12
9
|
export type MongoAuthenticationCredentialsRepositoryArgument = CollectionArgument<AuthenticationCredentials>;
|
|
13
|
-
export
|
|
14
|
-
export declare class MongoAuthenticationCredentialsRepository extends AuthenticationCredentialsRepository {
|
|
15
|
-
private readonly repository;
|
|
16
|
-
constructor(repository: InternalMongoAuthenticationCredentialsRepository);
|
|
17
|
-
tryLoad(id: string): Promise<AuthenticationCredentials | undefined>;
|
|
18
|
-
save(credentials: AuthenticationCredentials | NewAuthenticationCredentials): Promise<void>;
|
|
19
|
-
}
|
|
10
|
+
export type MongoAuthenticationCredentialsRepositoryConfig = MongoAuthenticationCredentialsRepositoryArgument;
|
|
20
11
|
export declare class InternalMongoAuthenticationCredentialsRepository extends MongoEntityRepository<AuthenticationCredentials> implements Injectable<MongoAuthenticationCredentialsRepositoryArgument> {
|
|
21
12
|
readonly [resolveArgumentType]: MongoAuthenticationCredentialsRepositoryArgument;
|
|
22
13
|
constructor(collection: Collection<AuthenticationCredentials>, logger: Logger);
|
|
23
14
|
upsert(credentials: MaybeNewEntity<AuthenticationCredentials>): Promise<void>;
|
|
24
15
|
}
|
|
25
|
-
export declare
|
|
16
|
+
export declare class MongoAuthenticationCredentialsRepository extends AuthenticationCredentialsRepository {
|
|
17
|
+
private readonly repository;
|
|
18
|
+
constructor(repository: InternalMongoAuthenticationCredentialsRepository);
|
|
19
|
+
tryLoadBySubject(subject: string): Promise<AuthenticationCredentials | undefined>;
|
|
20
|
+
save(credentials: AuthenticationCredentials | NewAuthenticationCredentials): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare function configureMongoAuthenticationCredentialsRepository(config: MongoAuthenticationCredentialsRepositoryConfig): void;
|
package/authentication/{mongo → server/mongo}/mongo-authentication-credentials.repository.js
RENAMED
|
@@ -12,34 +12,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.configureMongoAuthenticationCredentialsRepository = exports.
|
|
16
|
-
const container_1 = require("
|
|
17
|
-
const database_1 = require("
|
|
18
|
-
const mongo_1 = require("
|
|
19
|
-
const logger_1 = require("
|
|
15
|
+
exports.configureMongoAuthenticationCredentialsRepository = exports.MongoAuthenticationCredentialsRepository = exports.InternalMongoAuthenticationCredentialsRepository = void 0;
|
|
16
|
+
const container_1 = require("../../../container");
|
|
17
|
+
const database_1 = require("../../../database");
|
|
18
|
+
const mongo_1 = require("../../../database/mongo");
|
|
19
|
+
const logger_1 = require("../../../logger");
|
|
20
|
+
const type_guards_1 = require("../../../utils/type-guards");
|
|
20
21
|
const authentication_credentials_repository_1 = require("../authentication-credentials.repository");
|
|
21
|
-
|
|
22
|
+
let defaultArgument;
|
|
22
23
|
const indexes = [
|
|
23
24
|
{ key: { subject: 1 }, unique: true }
|
|
24
25
|
];
|
|
25
|
-
let MongoAuthenticationCredentialsRepository = class MongoAuthenticationCredentialsRepository extends authentication_credentials_repository_1.AuthenticationCredentialsRepository {
|
|
26
|
-
repository;
|
|
27
|
-
constructor(repository) {
|
|
28
|
-
super();
|
|
29
|
-
this.repository = repository;
|
|
30
|
-
}
|
|
31
|
-
async tryLoad(id) {
|
|
32
|
-
return this.repository.tryLoad(id);
|
|
33
|
-
}
|
|
34
|
-
async save(credentials) {
|
|
35
|
-
await this.repository.upsert(credentials);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
MongoAuthenticationCredentialsRepository = __decorate([
|
|
39
|
-
(0, container_1.singleton)(),
|
|
40
|
-
__metadata("design:paramtypes", [InternalMongoAuthenticationCredentialsRepository])
|
|
41
|
-
], MongoAuthenticationCredentialsRepository);
|
|
42
|
-
exports.MongoAuthenticationCredentialsRepository = MongoAuthenticationCredentialsRepository;
|
|
43
26
|
let InternalMongoAuthenticationCredentialsRepository = class InternalMongoAuthenticationCredentialsRepository extends mongo_1.MongoEntityRepository {
|
|
44
27
|
[container_1.resolveArgumentType];
|
|
45
28
|
constructor(collection, logger) {
|
|
@@ -52,14 +35,40 @@ let InternalMongoAuthenticationCredentialsRepository = class InternalMongoAuthen
|
|
|
52
35
|
};
|
|
53
36
|
InternalMongoAuthenticationCredentialsRepository = __decorate([
|
|
54
37
|
(0, container_1.singleton)({
|
|
55
|
-
defaultArgumentProvider: () =>
|
|
38
|
+
defaultArgumentProvider: () => defaultArgument
|
|
56
39
|
}),
|
|
57
40
|
__param(0, (0, container_1.forwardArg)()),
|
|
58
41
|
__metadata("design:paramtypes", [mongo_1.Collection, logger_1.Logger])
|
|
59
42
|
], InternalMongoAuthenticationCredentialsRepository);
|
|
60
43
|
exports.InternalMongoAuthenticationCredentialsRepository = InternalMongoAuthenticationCredentialsRepository;
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
let MongoAuthenticationCredentialsRepository = class MongoAuthenticationCredentialsRepository extends authentication_credentials_repository_1.AuthenticationCredentialsRepository {
|
|
45
|
+
repository;
|
|
46
|
+
constructor(repository) {
|
|
47
|
+
super();
|
|
48
|
+
this.repository = repository;
|
|
49
|
+
}
|
|
50
|
+
async tryLoadBySubject(subject) {
|
|
51
|
+
const credentials = await this.repository.tryLoadByFilter({ subject });
|
|
52
|
+
if ((0, type_guards_1.isUndefined)(credentials)) {
|
|
53
|
+
return credentials;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...credentials,
|
|
57
|
+
salt: credentials.salt.buffer,
|
|
58
|
+
hash: credentials.hash.buffer
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async save(credentials) {
|
|
62
|
+
await this.repository.upsert(credentials);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
MongoAuthenticationCredentialsRepository = __decorate([
|
|
66
|
+
(0, container_1.singleton)(),
|
|
67
|
+
__metadata("design:paramtypes", [InternalMongoAuthenticationCredentialsRepository])
|
|
68
|
+
], MongoAuthenticationCredentialsRepository);
|
|
69
|
+
exports.MongoAuthenticationCredentialsRepository = MongoAuthenticationCredentialsRepository;
|
|
70
|
+
function configureMongoAuthenticationCredentialsRepository(config) {
|
|
71
|
+
defaultArgument = config;
|
|
63
72
|
}
|
|
64
73
|
exports.configureMongoAuthenticationCredentialsRepository = configureMongoAuthenticationCredentialsRepository;
|
|
65
74
|
//# sourceMappingURL=mongo-authentication-credentials.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo-authentication-credentials.repository.js","sourceRoot":"","sources":["../../../../source/authentication/server/mongo/mongo-authentication-credentials.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAAyE;AAEzE,gDAA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;QACpC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAEvE,IAAI,IAAA,yBAAW,EAAC,WAAW,CAAC,EAAE;YAC5B,OAAO,WAAW,CAAC;SACpB;QAED,OAAO;YACL,GAAG,WAAW;YACd,IAAI,EAAG,WAAW,CAAC,IAA0B,CAAC,MAAM;YACpD,IAAI,EAAG,WAAW,CAAC,IAA0B,CAAC,MAAM;SACrD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,WAAqE;QAC9E,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;CACF,CAAA;AAzBY,wCAAwC;IADpD,IAAA,qBAAS,GAAE;qCAIc,gDAAgD;GAH7D,wCAAwC,CAyBpD;AAzBY,4FAAwC;AA2BrD,SAAgB,iDAAiD,CAAC,MAAsD;IACtH,eAAe,GAAG,MAAM,CAAC;AAC3B,CAAC;AAFD,8GAEC"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import type { Injectable } from "
|
|
2
|
-
import { resolveArgumentType } from "
|
|
3
|
-
import type { CollectionArgument } from "
|
|
4
|
-
import { Collection, MongoEntityRepository } from "
|
|
5
|
-
import { Logger } from "
|
|
1
|
+
import type { Injectable } from "../../../container";
|
|
2
|
+
import { resolveArgumentType } from "../../../container";
|
|
3
|
+
import type { CollectionArgument } from "../../../database/mongo";
|
|
4
|
+
import { Collection, MongoEntityRepository } from "../../../database/mongo";
|
|
5
|
+
import { Logger } from "../../../logger";
|
|
6
|
+
import type { AuthenticationSession, NewAuthenticationSession } from '../../models';
|
|
6
7
|
import type { AuthenticationSessionExtendData } from '../authentication-session.repository';
|
|
7
8
|
import { AuthenticationSessionRepository } from '../authentication-session.repository';
|
|
8
|
-
|
|
9
|
-
export type MongoAuthenticationSessionRepositoryConfig = {
|
|
10
|
-
config?: MongoAuthenticationSessionRepositoryArgument;
|
|
11
|
-
};
|
|
9
|
+
export type MongoAuthenticationSessionRepositoryConfig = MongoAuthenticationSessionRepositoryArgument;
|
|
12
10
|
export type MongoAuthenticationSessionRepositoryArgument = CollectionArgument<AuthenticationSession>;
|
|
13
|
-
export declare
|
|
11
|
+
export declare class InternalMongoAuthenticationSessionRepository extends MongoEntityRepository<AuthenticationSession> implements Injectable<MongoAuthenticationSessionRepositoryArgument> {
|
|
12
|
+
readonly [resolveArgumentType]: MongoAuthenticationSessionRepositoryArgument;
|
|
13
|
+
constructor(collection: Collection<AuthenticationSession>, logger: Logger);
|
|
14
|
+
}
|
|
14
15
|
export declare class MongoAuthenticationSessionRepository extends AuthenticationSessionRepository {
|
|
15
16
|
private readonly repository;
|
|
16
17
|
constructor(repository: InternalMongoAuthenticationSessionRepository);
|
|
@@ -19,8 +20,4 @@ export declare class MongoAuthenticationSessionRepository extends Authentication
|
|
|
19
20
|
extend(id: string, data: AuthenticationSessionExtendData): Promise<void>;
|
|
20
21
|
end(id: string, timestamp: number): Promise<void>;
|
|
21
22
|
}
|
|
22
|
-
export declare
|
|
23
|
-
readonly [resolveArgumentType]: MongoAuthenticationSessionRepositoryArgument;
|
|
24
|
-
constructor(collection: Collection<AuthenticationSession>, logger: Logger);
|
|
25
|
-
}
|
|
26
|
-
export declare function configureMongoAuthenticationSessionRepository(config?: Partial<MongoAuthenticationSessionRepositoryConfig>): void;
|
|
23
|
+
export declare function configureMongoAuthenticationSessionRepository(config: MongoAuthenticationSessionRepositoryConfig): void;
|
|
@@ -12,13 +12,27 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.configureMongoAuthenticationSessionRepository = exports.
|
|
16
|
-
const container_1 = require("
|
|
17
|
-
const mongo_1 = require("
|
|
18
|
-
const logger_1 = require("
|
|
15
|
+
exports.configureMongoAuthenticationSessionRepository = exports.MongoAuthenticationSessionRepository = exports.InternalMongoAuthenticationSessionRepository = void 0;
|
|
16
|
+
const container_1 = require("../../../container");
|
|
17
|
+
const mongo_1 = require("../../../database/mongo");
|
|
18
|
+
const logger_1 = require("../../../logger");
|
|
19
19
|
const authentication_session_repository_1 = require("../authentication-session.repository");
|
|
20
|
-
|
|
20
|
+
let defaultArgument;
|
|
21
21
|
const indexes = [];
|
|
22
|
+
let InternalMongoAuthenticationSessionRepository = class InternalMongoAuthenticationSessionRepository extends mongo_1.MongoEntityRepository {
|
|
23
|
+
[container_1.resolveArgumentType];
|
|
24
|
+
constructor(collection, logger) {
|
|
25
|
+
super(collection, mongo_1.noopTransformer, { logger, indexes });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
InternalMongoAuthenticationSessionRepository = __decorate([
|
|
29
|
+
(0, container_1.singleton)({
|
|
30
|
+
defaultArgumentProvider: () => defaultArgument
|
|
31
|
+
}),
|
|
32
|
+
__param(0, (0, container_1.forwardArg)()),
|
|
33
|
+
__metadata("design:paramtypes", [mongo_1.Collection, logger_1.Logger])
|
|
34
|
+
], InternalMongoAuthenticationSessionRepository);
|
|
35
|
+
exports.InternalMongoAuthenticationSessionRepository = InternalMongoAuthenticationSessionRepository;
|
|
22
36
|
let MongoAuthenticationSessionRepository = class MongoAuthenticationSessionRepository extends authentication_session_repository_1.AuthenticationSessionRepository {
|
|
23
37
|
repository;
|
|
24
38
|
constructor(repository) {
|
|
@@ -29,7 +43,12 @@ let MongoAuthenticationSessionRepository = class MongoAuthenticationSessionRepos
|
|
|
29
43
|
return this.repository.insert(authenticationSession);
|
|
30
44
|
}
|
|
31
45
|
async load(id) {
|
|
32
|
-
|
|
46
|
+
const session = await this.repository.load(id);
|
|
47
|
+
return {
|
|
48
|
+
...session,
|
|
49
|
+
refreshTokenSalt: session.refreshTokenSalt.buffer,
|
|
50
|
+
refreshTokenHash: session.refreshTokenHash.buffer
|
|
51
|
+
};
|
|
33
52
|
}
|
|
34
53
|
async extend(id, data) {
|
|
35
54
|
await this.repository.patchByFilter({ id }, data);
|
|
@@ -43,22 +62,8 @@ MongoAuthenticationSessionRepository = __decorate([
|
|
|
43
62
|
__metadata("design:paramtypes", [InternalMongoAuthenticationSessionRepository])
|
|
44
63
|
], MongoAuthenticationSessionRepository);
|
|
45
64
|
exports.MongoAuthenticationSessionRepository = MongoAuthenticationSessionRepository;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
constructor(collection, logger) {
|
|
49
|
-
super(collection, mongo_1.noopTransformer, { logger, indexes });
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
InternalMongoAuthenticationSessionRepository = __decorate([
|
|
53
|
-
(0, container_1.singleton)({
|
|
54
|
-
defaultArgumentProvider: () => exports.mongoAuthenticationSessionRepositoryConfig.config
|
|
55
|
-
}),
|
|
56
|
-
__param(0, (0, container_1.forwardArg)()),
|
|
57
|
-
__metadata("design:paramtypes", [mongo_1.Collection, logger_1.Logger])
|
|
58
|
-
], InternalMongoAuthenticationSessionRepository);
|
|
59
|
-
exports.InternalMongoAuthenticationSessionRepository = InternalMongoAuthenticationSessionRepository;
|
|
60
|
-
function configureMongoAuthenticationSessionRepository(config = {}) {
|
|
61
|
-
exports.mongoAuthenticationSessionRepositoryConfig.config = config.config ?? exports.mongoAuthenticationSessionRepositoryConfig.config;
|
|
65
|
+
function configureMongoAuthenticationSessionRepository(config) {
|
|
66
|
+
defaultArgument = config;
|
|
62
67
|
}
|
|
63
68
|
exports.configureMongoAuthenticationSessionRepository = configureMongoAuthenticationSessionRepository;
|
|
64
69
|
//# sourceMappingURL=mongo-authentication-session.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo-authentication-session.repository.js","sourceRoot":"","sources":["../../../../source/authentication/server/mongo/mongo-authentication-session.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAAyE;AAEzE,mDAAsF;AACtF,4CAAkC;AAIlC,4F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,KAAK,CAAC,GAAG,CAAC,EAAU,EAAE,SAAiB;QACrC,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AA7BY,oCAAoC;IADhD,IAAA,qBAAS,GAAE;qCAIc,4CAA4C;GAHzD,oCAAoC,CA6BhD;AA7BY,oFAAoC;AA+BjD,SAAgB,6CAA6C,CAAC,MAAkD;IAC9G,eAAe,GAAG,MAAM,CAAC;AAC3B,CAAC;AAFD,sGAEC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { AuthenticationServiceOptions } from './authentication.service';
|
|
2
|
-
export declare const AUTHENTICATION_SERVICE_OPTIONS: import("
|
|
2
|
+
export declare const AUTHENTICATION_SERVICE_OPTIONS: import("../../container").InjectionToken<AuthenticationServiceOptions, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AUTHENTICATION_SERVICE_OPTIONS = void 0;
|
|
4
|
-
const container_1 = require("
|
|
4
|
+
const container_1 = require("../../container");
|
|
5
5
|
exports.AUTHENTICATION_SERVICE_OPTIONS = (0, container_1.injectionToken)('AUTHENTICATION_SERVICE_OPTIONS');
|
|
6
6
|
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../source/authentication/server/tokens.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAGhC,QAAA,8BAA8B,GAAG,IAAA,0BAAc,EAA+B,gCAAgC,CAAC,CAAC"}
|
package/container/token.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AbstractConstructor } from "../types";
|
|
2
2
|
declare const parameter: unique symbol;
|
|
3
3
|
export type ParameterizedInjectionToken<T, A> = SimpleInjectionToken<T> & {
|
|
4
4
|
[parameter]?: A;
|
|
5
5
|
};
|
|
6
|
-
export type SimpleInjectionToken<T> =
|
|
6
|
+
export type SimpleInjectionToken<T> = AbstractConstructor<T> | object | string | symbol;
|
|
7
7
|
export type InjectionToken<T = any, A = any> = SimpleInjectionToken<T> | ParameterizedInjectionToken<T, A>;
|
|
8
8
|
export declare function injectionToken<T, A = any>(token: InjectionToken<T, A>): InjectionToken<T, A>;
|
|
9
9
|
export declare function getTokenName(token: InjectionToken | undefined): string;
|
package/container/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AbstractConstructor } from "../types";
|
|
1
2
|
import type { Container } from './container';
|
|
2
3
|
import type { InjectionToken } from './token';
|
|
3
4
|
export type ResolveContext = Pick<Container, 'resolve' | 'resolveAsync'> & {
|
|
@@ -5,4 +6,4 @@ export type ResolveContext = Pick<Container, 'resolve' | 'resolveAsync'> & {
|
|
|
5
6
|
};
|
|
6
7
|
export type Mapper<T = any, U = unknown> = (value: T) => U | Promise<U>;
|
|
7
8
|
export type ArgumentProvider<T = unknown> = (context: ResolveContext) => T | Promise<T>;
|
|
8
|
-
export type ForwardRefInjectionToken<T = any, A = any> = Exclude<InjectionToken<T, A>,
|
|
9
|
+
export type ForwardRefInjectionToken<T = any, A = any> = Exclude<InjectionToken<T, A>, AbstractConstructor> | (() => InjectionToken<T, A>);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type SetCookieOptions = {
|
|
2
|
+
domain?: string;
|
|
3
|
+
/** date or timestamp in milliseconds */
|
|
4
|
+
expires?: Date | number;
|
|
5
|
+
httpOnly?: boolean;
|
|
6
|
+
/** in seconds */
|
|
7
|
+
maxAge?: number;
|
|
8
|
+
partitioned?: boolean;
|
|
9
|
+
path?: string;
|
|
10
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
11
|
+
secure?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function formatSetCookie(name: string, value: string, options?: SetCookieOptions): string;
|
|
14
|
+
export declare function parseCookieString(cookieString: string): Map<string, string>;
|
package/cookie/cookie.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCookieString = exports.formatSetCookie = void 0;
|
|
4
|
+
const not_supported_error_1 = require("../error/not-supported.error");
|
|
5
|
+
const type_guards_1 = require("../utils/type-guards");
|
|
6
|
+
const sameSiteMap = {
|
|
7
|
+
none: 'None',
|
|
8
|
+
lax: 'Lax',
|
|
9
|
+
strict: 'Strict'
|
|
10
|
+
};
|
|
11
|
+
function formatSetCookie(name, value, options = {}) {
|
|
12
|
+
const encodedValue = encodeURIComponent(value);
|
|
13
|
+
let cookie = `${name}="${encodedValue}"`;
|
|
14
|
+
if ((0, type_guards_1.isDefined)(options.domain)) {
|
|
15
|
+
cookie = `${cookie}; Domain=${options.domain}`;
|
|
16
|
+
}
|
|
17
|
+
if ((0, type_guards_1.isDefined)(options.expires)) {
|
|
18
|
+
const date = (0, type_guards_1.isNumber)(options.expires) ? new Date(options.expires) : options.expires;
|
|
19
|
+
cookie = `${cookie}; Expires=${date.toUTCString()}`;
|
|
20
|
+
}
|
|
21
|
+
if ((0, type_guards_1.isDefined)(options.httpOnly) && options.httpOnly) {
|
|
22
|
+
cookie = `${cookie}; HttpOnly`;
|
|
23
|
+
}
|
|
24
|
+
if ((0, type_guards_1.isDefined)(options.maxAge)) {
|
|
25
|
+
cookie = `${cookie}; Max-Age=${options.maxAge}`;
|
|
26
|
+
}
|
|
27
|
+
if ((0, type_guards_1.isDefined)(options.partitioned) && options.partitioned) {
|
|
28
|
+
cookie = `${cookie}; Partitioned`;
|
|
29
|
+
}
|
|
30
|
+
if ((0, type_guards_1.isDefined)(options.path)) {
|
|
31
|
+
cookie = `${cookie}; Path=${options.path}`;
|
|
32
|
+
}
|
|
33
|
+
if ((0, type_guards_1.isDefined)(options.sameSite)) {
|
|
34
|
+
const sameSiteValue = sameSiteMap[options.sameSite];
|
|
35
|
+
if ((0, type_guards_1.isUndefined)(sameSiteValue)) {
|
|
36
|
+
throw new not_supported_error_1.NotSupportedError(`Unknown option SameSite "${options.sameSite}".`);
|
|
37
|
+
}
|
|
38
|
+
cookie = `${cookie}; SameSite=${sameSiteValue}`;
|
|
39
|
+
}
|
|
40
|
+
if ((0, type_guards_1.isDefined)(options.secure) && options.secure) {
|
|
41
|
+
cookie = `${cookie}; Secure`;
|
|
42
|
+
}
|
|
43
|
+
return cookie;
|
|
44
|
+
}
|
|
45
|
+
exports.formatSetCookie = formatSetCookie;
|
|
46
|
+
function parseCookieString(cookieString) {
|
|
47
|
+
const cookieEntries = cookieString
|
|
48
|
+
.split(';')
|
|
49
|
+
.map((cookiePartString) => {
|
|
50
|
+
const splitIndex = cookiePartString.indexOf('=');
|
|
51
|
+
const name = cookiePartString.slice(0, splitIndex).trim();
|
|
52
|
+
const value = decodeURIComponent(cookiePartString.slice(splitIndex + 1).trim());
|
|
53
|
+
return [name, value];
|
|
54
|
+
});
|
|
55
|
+
return new Map(cookieEntries);
|
|
56
|
+
}
|
|
57
|
+
exports.parseCookieString = parseCookieString;
|
|
58
|
+
//# sourceMappingURL=cookie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../source/cookie/cookie.ts"],"names":[],"mappings":";;;AAAA,sEAAgE;AAChE,sDAAuE;AAevE,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX,SAAgB,eAAe,CAAC,IAAY,EAAE,KAAa,EAAE,UAA4B,EAAE;IACzF,MAAM,YAAY,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAE/C,IAAI,MAAM,GAAG,GAAG,IAAI,KAAK,YAAY,GAAG,CAAC;IAEzC,IAAI,IAAA,uBAAS,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,GAAG,GAAG,MAAM,cAAc,aAAa,EAAE,CAAC;KACjD;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE;QAC/C,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC;KAC9B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA7CD,0CA6CC;AAED,SAAgB,iBAAiB,CAAC,YAAoB;IACpD,MAAM,aAAa,GAAG,YAAY;SAC/B,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE;QACxB,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAEhF,OAAO,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;IAChC,CAAC,CAAC,CAAC;IAEL,OAAO,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;AAChC,CAAC;AAZD,8CAYC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cookie';
|
package/cookie/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cookie"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/cookie/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|