tsledge-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +100 -0
  3. package/dist/app.d.ts +14 -0
  4. package/dist/app.d.ts.map +1 -0
  5. package/dist/bin/repl.js +1181 -0
  6. package/dist/bin/repl.js.map +7 -0
  7. package/dist/core/http.d.ts +15 -0
  8. package/dist/core/http.d.ts.map +1 -0
  9. package/dist/core/index.d.ts +4 -0
  10. package/dist/core/index.d.ts.map +1 -0
  11. package/dist/core/query-builder.d.ts +96 -0
  12. package/dist/core/query-builder.d.ts.map +1 -0
  13. package/dist/core/types.d.ts +58 -0
  14. package/dist/core/types.d.ts.map +1 -0
  15. package/dist/db/index.d.ts +2 -0
  16. package/dist/db/index.d.ts.map +1 -0
  17. package/dist/db/mongodb.d.ts +6 -0
  18. package/dist/db/mongodb.d.ts.map +1 -0
  19. package/dist/exitCodes.d.ts +4 -0
  20. package/dist/exitCodes.d.ts.map +1 -0
  21. package/dist/fluent-interface/fluent-pattern-handler.d.ts +60 -0
  22. package/dist/fluent-interface/fluent-pattern-handler.d.ts.map +1 -0
  23. package/dist/fluent-interface/index.d.ts +3 -0
  24. package/dist/fluent-interface/index.d.ts.map +1 -0
  25. package/dist/fluent-interface/types.d.ts +26 -0
  26. package/dist/fluent-interface/types.d.ts.map +1 -0
  27. package/dist/index.d.ts +10 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/middleware/authentication/index.d.ts +4 -0
  30. package/dist/middleware/authentication/index.d.ts.map +1 -0
  31. package/dist/middleware/authentication/session.d.ts +63 -0
  32. package/dist/middleware/authentication/session.d.ts.map +1 -0
  33. package/dist/middleware/authentication/types.d.ts +34 -0
  34. package/dist/middleware/authentication/types.d.ts.map +1 -0
  35. package/dist/middleware/authentication/validation.d.ts +64 -0
  36. package/dist/middleware/authentication/validation.d.ts.map +1 -0
  37. package/dist/middleware/file-storage.d.ts +4 -0
  38. package/dist/middleware/file-storage.d.ts.map +1 -0
  39. package/dist/middleware/index.d.ts +5 -0
  40. package/dist/middleware/index.d.ts.map +1 -0
  41. package/dist/middleware/logger.d.ts +4 -0
  42. package/dist/middleware/logger.d.ts.map +1 -0
  43. package/dist/middleware/types.d.ts +2 -0
  44. package/dist/middleware/types.d.ts.map +1 -0
  45. package/dist/models/auth-token-blocklist.d.ts +13 -0
  46. package/dist/models/auth-token-blocklist.d.ts.map +1 -0
  47. package/dist/models/auth-user.d.ts +15 -0
  48. package/dist/models/auth-user.d.ts.map +1 -0
  49. package/dist/models/index.d.ts +3 -0
  50. package/dist/models/index.d.ts.map +1 -0
  51. package/dist/src/index.js +1159 -0
  52. package/dist/src/index.js.map +7 -0
  53. package/dist/tests/main.js +1111 -0
  54. package/dist/tests/main.js.map +7 -0
  55. package/dist/types.d.ts +26 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/dist/utils/date.d.ts +2 -0
  58. package/dist/utils/date.d.ts.map +1 -0
  59. package/dist/utils/encoding.d.ts +13 -0
  60. package/dist/utils/encoding.d.ts.map +1 -0
  61. package/dist/utils/env.d.ts +9 -0
  62. package/dist/utils/env.d.ts.map +1 -0
  63. package/dist/utils/index.d.ts +6 -0
  64. package/dist/utils/index.d.ts.map +1 -0
  65. package/dist/utils/mongo-relation.d.ts +21 -0
  66. package/dist/utils/mongo-relation.d.ts.map +1 -0
  67. package/dist/utils/validation.d.ts +59 -0
  68. package/dist/utils/validation.d.ts.map +1 -0
  69. package/package.json +76 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/middleware/authentication/session.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI1D,OAAO,EAAE,gBAAgB,EAA0C,MAAM,cAAc,CAAC;AA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+ * JWT id, is required
8
+ */
9
+ jti: string;
10
+ /**
11
+ * JWT expires, is set by express in sign()
12
+ */
13
+ exp?: number;
14
+ /**
15
+ * JWT issued at, is set by express in sign()
16
+ */
17
+ iat?: number;
18
+ }
19
+ export interface JWTCredentials {
20
+ /**
21
+ * JWT Access Token, expires in 15 minutes, signed with JwtSecret
22
+ */
23
+ accessToken: string;
24
+ /**
25
+ * JWT Refresh Token, expires in 7 days, signed with JwtRefreshSecret
26
+ */
27
+ refreshToken: string;
28
+ /**
29
+ * Encoded string of AuthUserModel in base64 format.
30
+ * Use encodeToBase64 to encode your own user document to a string and decodeFromBase64 to decode it back to an object.
31
+ */
32
+ appUser: string;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/middleware/authentication/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,64 @@
1
+ import { Request, Response } from 'express';
2
+ import { AuthUserPayload } from './types';
3
+ export interface TokenVerificationResult {
4
+ /**
5
+ * Indicates if the token is valid (signature is correct, not blocked, and user is not blocked).
6
+ */
7
+ isTokenValid: boolean;
8
+ /**
9
+ * Indicates if the token is expired.
10
+ */
11
+ isTokenExpired: boolean;
12
+ /**
13
+ * Indicates if the user associated with the token is blocked.
14
+ */
15
+ isUserBlocked: boolean;
16
+ /**
17
+ * The decoded payload from the JWT token, which should contain user information.
18
+ */
19
+ payload: AuthUserPayload | any;
20
+ }
21
+ /**
22
+ * Express middleware to require a valid JWT token for access. Checks the token against the blocklist and user status.
23
+ * Adding user and access token to ``res.locals.authUserPayload`` and ``res.locals.token``
24
+ * @param req
25
+ * @param res
26
+ * @param next
27
+ * @returns
28
+ */
29
+ export declare function jwtRequired(req: Request, res: Response & {
30
+ locals: {
31
+ authUserPayload: AuthUserPayload;
32
+ token: string;
33
+ };
34
+ }, next: any): Promise<void>;
35
+ /**
36
+ * Express middleware to require a valid refresh JWT token for access. Checks the token against the blocklist and user status.
37
+ * Adding user and access token to ``res.locals.authUserPayload`` and ``res.locals.token``
38
+ * @param req
39
+ * @param res
40
+ * @param next
41
+ * @returns
42
+ */
43
+ export declare function jwtRefreshRequired(req: Request, res: Response & {
44
+ locals: {
45
+ authUserPayload: AuthUserPayload;
46
+ token: string;
47
+ };
48
+ }, next: any): Promise<void>;
49
+ /**
50
+ * Verifies a JWT token and checks for blocklist and user status.
51
+ * @param token
52
+ * @param jwtSecret
53
+ * @returns An object containing validity, expiration status, and payload.
54
+ */
55
+ export declare function verifyToken(token: string, jwtSecret: string): Promise<TokenVerificationResult>;
56
+ /**
57
+ * @test TODO not rly tested
58
+ *
59
+ * @param _socket
60
+ * @param _next
61
+ * @returns
62
+ */
63
+ export declare function socketToken(_socket: any, _next: any): Promise<any>;
64
+ //# 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;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI1C,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,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,eAAe,EAAE,eAAe,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAC/E,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,GAAG;IAAE,MAAM,EAAE;QAAE,eAAe,EAAE,eAAe,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAC/E,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,uBAAuB,CAAC,CAgDlC;AAqDD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAsBzD"}
@@ -0,0 +1,4 @@
1
+ import multer from 'multer';
2
+ export declare const diskFileUpload: multer.Multer;
3
+ export declare const memoryFileUpload: multer.Multer;
4
+ //# sourceMappingURL=file-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-storage.d.ts","sourceRoot":"","sources":["../../src/middleware/file-storage.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAsB5B,eAAO,MAAM,cAAc,eAAmC,CAAC;AAC/D,eAAO,MAAM,gBAAgB,eAAqC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './file-storage';
2
+ export * from './logger';
3
+ export * from './authentication/index';
4
+ export * from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ export declare function requestLogger(req: Request, res: Response, next: NextFunction): void;
3
+ export declare function errorLogger(err: any, req: any, res: any, next: NextFunction): void;
4
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +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,QAe5E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,QAG3E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/middleware/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import mongoose from "mongoose";
2
+ export interface AuthTokenBlocklist {
3
+ jti: string;
4
+ }
5
+ export type AuthTokenBlocklistDocument = AuthTokenBlocklist & mongoose.Document;
6
+ export declare const AuthTokenBlocklistModel: mongoose.Model<AuthTokenBlocklistDocument, {}, {}, {}, mongoose.Document<unknown, {}, AuthTokenBlocklistDocument, {}, mongoose.DefaultSchemaOptions> & AuthTokenBlocklist & mongoose.Document<mongoose.Types.ObjectId, any, any, Record<string, any>, {}> & Required<{
7
+ _id: mongoose.Types.ObjectId;
8
+ }> & {
9
+ __v: number;
10
+ } & {
11
+ id: string;
12
+ }, any, AuthTokenBlocklistDocument>;
13
+ //# sourceMappingURL=auth-token-blocklist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-token-blocklist.d.ts","sourceRoot":"","sources":["../../src/models/auth-token-blocklist.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,0BAA0B,GAAG,kBAAkB,GAAG,QAAQ,CAAC,QAAQ,CAAC;AAShF,eAAO,MAAM,uBAAuB;;;;;;mCAGnC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import mongoose from "mongoose";
2
+ export interface AuthUser {
3
+ identifier: string;
4
+ secretHash: string;
5
+ blockedSince: Date;
6
+ }
7
+ export type AuthUserDocument = AuthUser & mongoose.Document;
8
+ export declare const AuthUserModel: mongoose.Model<AuthUserDocument, {}, {}, {}, mongoose.Document<unknown, {}, AuthUserDocument, {}, mongoose.DefaultSchemaOptions> & AuthUser & mongoose.Document<mongoose.Types.ObjectId, any, any, Record<string, any>, {}> & Required<{
9
+ _id: mongoose.Types.ObjectId;
10
+ }> & {
11
+ __v: number;
12
+ } & {
13
+ id: string;
14
+ }, any, AuthUserDocument>;
15
+ //# 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,MAAM,UAAU,CAAC;AAEhC,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;AAW5D,eAAO,MAAM,aAAa;;;;;;yBAA+D,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './auth-user';
2
+ export * from './auth-token-blocklist';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC"}