tsledge 0.1.3 → 0.1.5
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/dist/core/types.d.ts +3 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/db/mongodb.d.ts +4 -0
- package/dist/db/mongodb.d.ts.map +1 -1
- package/dist/fluent-interface/{fluent-pattern-executor.d.ts → fluent-pattern-handler.d.ts} +4 -4
- package/dist/fluent-interface/fluent-pattern-handler.d.ts.map +1 -0
- package/dist/fluent-interface/index.d.ts +1 -1
- package/dist/fluent-interface/index.d.ts.map +1 -1
- package/dist/fluent-interface/types.d.ts +6 -2
- package/dist/fluent-interface/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1001 -24
- package/dist/middleware/authentication/index.d.ts +4 -0
- package/dist/middleware/authentication/index.d.ts.map +1 -0
- package/dist/middleware/authentication/session.d.ts +74 -0
- package/dist/middleware/authentication/session.d.ts.map +1 -0
- package/dist/middleware/authentication/types.d.ts +12 -0
- package/dist/middleware/authentication/types.d.ts.map +1 -0
- package/dist/middleware/authentication/validation.d.ts +55 -0
- package/dist/middleware/authentication/validation.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/logger.d.ts.map +1 -1
- package/dist/middleware/types.d.ts +2 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/models/auth-user.d.ts +14 -0
- package/dist/models/auth-user.d.ts.map +1 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/token-blocklist.d.ts +12 -0
- package/dist/models/token-blocklist.d.ts.map +1 -0
- package/dist/src/index.js +1000 -0
- package/dist/tests/main.js +932 -0
- package/dist/utils/encoding.d.ts +7 -0
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/env.d.ts +9 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +9 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/package.json +16 -6
- package/dist/app.js +0 -30
- package/dist/app.js.map +0 -1
- package/dist/core/http.js +0 -79
- package/dist/core/http.js.map +0 -1
- package/dist/core/index.js +0 -20
- package/dist/core/index.js.map +0 -1
- package/dist/core/query-builder.js +0 -271
- package/dist/core/query-builder.js.map +0 -1
- package/dist/core/types.js +0 -49
- package/dist/core/types.js.map +0 -1
- package/dist/db/index.js +0 -18
- package/dist/db/index.js.map +0 -1
- package/dist/db/mongodb.js +0 -24
- package/dist/db/mongodb.js.map +0 -1
- package/dist/exitCodes.js +0 -7
- package/dist/exitCodes.js.map +0 -1
- package/dist/fluent-interface/fluent-pattern-executor.d.ts.map +0 -1
- package/dist/fluent-interface/fluent-pattern-executor.js +0 -137
- package/dist/fluent-interface/fluent-pattern-executor.js.map +0 -1
- package/dist/fluent-interface/index.js +0 -19
- package/dist/fluent-interface/index.js.map +0 -1
- package/dist/fluent-interface/types.js +0 -3
- package/dist/fluent-interface/types.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/middleware/file-storage.js +0 -26
- package/dist/middleware/file-storage.js.map +0 -1
- package/dist/middleware/index.js +0 -19
- package/dist/middleware/index.js.map +0 -1
- package/dist/middleware/logger.js +0 -30
- package/dist/middleware/logger.js.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/utils/date.js +0 -8
- package/dist/utils/date.js.map +0 -1
- package/dist/utils/index.js +0 -20
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/mongo-relation.js +0 -89
- package/dist/utils/mongo-relation.js.map +0 -1
- package/dist/utils/validation.js +0 -17
- package/dist/utils/validation.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/authentication/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import express, { Request, Response } from 'express';
|
|
2
|
+
import { AuthUserDocument } from '../../models';
|
|
3
|
+
import { JWTCredentials, AuthUserPayload } from './types';
|
|
4
|
+
declare const router: import("express-serve-static-core").Router;
|
|
5
|
+
/**
|
|
6
|
+
* Handles user registration by validating input and creating a new user with a hashed password.
|
|
7
|
+
* Passes the new user without saving in ``res.locals.authUser`` for the next middleware to use.
|
|
8
|
+
* @param req
|
|
9
|
+
* @param res Response & { locals: { authUser: AuthUserDocument } }
|
|
10
|
+
* @param next
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function authRegister(req: Request, res: Response & {
|
|
14
|
+
locals: {
|
|
15
|
+
authUser: AuthUserDocument;
|
|
16
|
+
};
|
|
17
|
+
}, next: any): Promise<(express.Response<any, Record<string, any>> & {
|
|
18
|
+
locals: {
|
|
19
|
+
authUser: AuthUserDocument;
|
|
20
|
+
};
|
|
21
|
+
}) | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Handles user login by validating credentials and generating JWT tokens.
|
|
24
|
+
* Passes data in ``res.locals.credentials`` for the next middleware to use.
|
|
25
|
+
* @param req
|
|
26
|
+
* @param res
|
|
27
|
+
* @param next
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare function authLogin(req: Request, res: Response & {
|
|
31
|
+
locals: {
|
|
32
|
+
credentials: JWTCredentials;
|
|
33
|
+
};
|
|
34
|
+
}, next: any): Promise<(express.Response<any, Record<string, any>> & {
|
|
35
|
+
locals: {
|
|
36
|
+
credentials: JWTCredentials;
|
|
37
|
+
};
|
|
38
|
+
}) | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Handles user logout by invalidating the provided refresh token and optionally the access token.
|
|
41
|
+
* JWTRefresh Token is required
|
|
42
|
+
* @param req
|
|
43
|
+
* @param res Response & { locals: { user: AuthUserPayload; token: string } }
|
|
44
|
+
* @param next
|
|
45
|
+
*/
|
|
46
|
+
export declare function authLogout(req: Request, res: Response & {
|
|
47
|
+
locals: {
|
|
48
|
+
user: AuthUserPayload;
|
|
49
|
+
token: string;
|
|
50
|
+
};
|
|
51
|
+
}, next: any): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Handles refreshing JWT tokens by validating the provided refresh token and generating new credentials.
|
|
54
|
+
* Passes new credentials in ``res.locals.credentials`` for the next middleware to use.
|
|
55
|
+
* @param req
|
|
56
|
+
* @param res Response & { locals: { user: AuthUserPayload; token: string; credentials: JWTCredentials } }
|
|
57
|
+
* @param next
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
export declare function authRefresh(req: Request, res: Response & {
|
|
61
|
+
locals: {
|
|
62
|
+
user: AuthUserPayload;
|
|
63
|
+
token: string;
|
|
64
|
+
credentials: JWTCredentials;
|
|
65
|
+
};
|
|
66
|
+
}, next: any): Promise<(express.Response<any, Record<string, any>> & {
|
|
67
|
+
locals: {
|
|
68
|
+
user: AuthUserPayload;
|
|
69
|
+
token: string;
|
|
70
|
+
credentials: JWTCredentials;
|
|
71
|
+
};
|
|
72
|
+
}) | undefined>;
|
|
73
|
+
export default router;
|
|
74
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/middleware/authentication/session.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAY,gBAAgB,EAAkB,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAM1D,QAAA,MAAM,MAAM,4CAAmB,CAAC;AA2ChC;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,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AAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,GAAG,CAAC;CACd"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { AuthUserPayload } from './types';
|
|
3
|
+
export interface TokenVerificationResult {
|
|
4
|
+
isTokenValid: boolean;
|
|
5
|
+
isTokenExpired: boolean;
|
|
6
|
+
isUserBlocked: boolean;
|
|
7
|
+
payload: AuthUserPayload | any;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Express middleware to require a valid JWT token for access. Checks the token against the blocklist and user status.
|
|
11
|
+
* Adding user and access token to ``res.locals.user`` and ``res.locals.token``
|
|
12
|
+
* @param req
|
|
13
|
+
* @param res
|
|
14
|
+
* @param next
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function jwtRequired(req: Request, res: Response & {
|
|
18
|
+
locals: {
|
|
19
|
+
user: AuthUserPayload;
|
|
20
|
+
token: string;
|
|
21
|
+
};
|
|
22
|
+
}, next: any): Promise<(Response<any, Record<string, any>> & {
|
|
23
|
+
locals: {
|
|
24
|
+
user: AuthUserPayload;
|
|
25
|
+
token: string;
|
|
26
|
+
};
|
|
27
|
+
}) | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Express middleware to require a valid refresh JWT token for access. Checks the token against the blocklist and user status.
|
|
30
|
+
* Adding user and access token to ``res.locals.user`` and ``res.locals.token``
|
|
31
|
+
* @param req
|
|
32
|
+
* @param res
|
|
33
|
+
* @param next
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export declare function jwtRefreshRequired(req: Request, res: Response & {
|
|
37
|
+
locals: {
|
|
38
|
+
user: AuthUserPayload;
|
|
39
|
+
token: string;
|
|
40
|
+
};
|
|
41
|
+
}, next: any): Promise<(Response<any, Record<string, any>> & {
|
|
42
|
+
locals: {
|
|
43
|
+
user: AuthUserPayload;
|
|
44
|
+
token: string;
|
|
45
|
+
};
|
|
46
|
+
}) | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Verifies a JWT token and checks for blocklist and user status.
|
|
49
|
+
* @param token
|
|
50
|
+
* @param jwtSecret
|
|
51
|
+
* @returns An object containing validity, expiration status, and payload.
|
|
52
|
+
*/
|
|
53
|
+
export declare function verifyToken(token: string, jwtSecret: string): Promise<TokenVerificationResult>;
|
|
54
|
+
export declare function socketToken(_socket: any, _next: any): Promise<any>;
|
|
55
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/middleware/authentication/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,eAAe,GAAG,GAAG,CAAC;CAChC;AAKD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,GAAG;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACpE,IAAI,EAAE,GAAG;YAuFwD;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;gBApF1G;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,GAAG;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACpE,IAAI,EAAE,GAAG;YAuEwD;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;gBApE1G;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAgDpG;AAwCD,wBAAsB,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAqBzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/middleware/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/middleware/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,QAe5E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,QAG3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/middleware/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import mongoose, { Document } from "mongoose";
|
|
2
|
+
export interface AuthUserDocument extends Document {
|
|
3
|
+
identifier: string;
|
|
4
|
+
secretHash: string;
|
|
5
|
+
blockedSince: Date;
|
|
6
|
+
}
|
|
7
|
+
export declare const AuthUser: mongoose.Model<AuthUserDocument, {}, {}, {}, mongoose.Document<unknown, {}, AuthUserDocument, {}, mongoose.DefaultSchemaOptions> & AuthUserDocument & Required<{
|
|
8
|
+
_id: mongoose.Types.ObjectId;
|
|
9
|
+
}> & {
|
|
10
|
+
__v: number;
|
|
11
|
+
} & {
|
|
12
|
+
id: string;
|
|
13
|
+
}, any, AuthUserDocument>;
|
|
14
|
+
//# sourceMappingURL=auth-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-user.d.ts","sourceRoot":"","sources":["../../src/models/auth-user.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;CACpB;AAWD,eAAO,MAAM,QAAQ;;;;;;yBAA+D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
export interface TokenBlocklistDocument extends Document {
|
|
3
|
+
jti: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const TokenBlocklist: mongoose.Model<TokenBlocklistDocument, {}, {}, {}, mongoose.Document<unknown, {}, TokenBlocklistDocument, {}, mongoose.DefaultSchemaOptions> & TokenBlocklistDocument & {
|
|
6
|
+
_id: mongoose.Types.ObjectId;
|
|
7
|
+
} & {
|
|
8
|
+
__v: number;
|
|
9
|
+
} & {
|
|
10
|
+
id: string;
|
|
11
|
+
}, any, TokenBlocklistDocument>;
|
|
12
|
+
//# sourceMappingURL=token-blocklist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-blocklist.d.ts","sourceRoot":"","sources":["../../src/models/token-blocklist.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,WAAW,sBAAuB,SAAQ,QAAQ;IACtD,GAAG,EAAE,MAAM,CAAC;CACb;AASD,eAAO,MAAM,cAAc;;;;;;+BAAiF,CAAC"}
|