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.
Files changed (83) hide show
  1. package/dist/core/types.d.ts +3 -0
  2. package/dist/core/types.d.ts.map +1 -1
  3. package/dist/db/mongodb.d.ts +4 -0
  4. package/dist/db/mongodb.d.ts.map +1 -1
  5. package/dist/fluent-interface/{fluent-pattern-executor.d.ts → fluent-pattern-handler.d.ts} +4 -4
  6. package/dist/fluent-interface/fluent-pattern-handler.d.ts.map +1 -0
  7. package/dist/fluent-interface/index.d.ts +1 -1
  8. package/dist/fluent-interface/index.d.ts.map +1 -1
  9. package/dist/fluent-interface/types.d.ts +6 -2
  10. package/dist/fluent-interface/types.d.ts.map +1 -1
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1001 -24
  14. package/dist/middleware/authentication/index.d.ts +4 -0
  15. package/dist/middleware/authentication/index.d.ts.map +1 -0
  16. package/dist/middleware/authentication/session.d.ts +74 -0
  17. package/dist/middleware/authentication/session.d.ts.map +1 -0
  18. package/dist/middleware/authentication/types.d.ts +12 -0
  19. package/dist/middleware/authentication/types.d.ts.map +1 -0
  20. package/dist/middleware/authentication/validation.d.ts +55 -0
  21. package/dist/middleware/authentication/validation.d.ts.map +1 -0
  22. package/dist/middleware/index.d.ts +2 -0
  23. package/dist/middleware/index.d.ts.map +1 -1
  24. package/dist/middleware/logger.d.ts.map +1 -1
  25. package/dist/middleware/types.d.ts +2 -0
  26. package/dist/middleware/types.d.ts.map +1 -0
  27. package/dist/models/auth-user.d.ts +14 -0
  28. package/dist/models/auth-user.d.ts.map +1 -0
  29. package/dist/models/index.d.ts +3 -0
  30. package/dist/models/index.d.ts.map +1 -0
  31. package/dist/models/token-blocklist.d.ts +12 -0
  32. package/dist/models/token-blocklist.d.ts.map +1 -0
  33. package/dist/src/index.js +1000 -0
  34. package/dist/tests/main.js +932 -0
  35. package/dist/utils/encoding.d.ts +7 -0
  36. package/dist/utils/encoding.d.ts.map +1 -0
  37. package/dist/utils/env.d.ts +9 -0
  38. package/dist/utils/env.d.ts.map +1 -0
  39. package/dist/utils/index.d.ts +2 -0
  40. package/dist/utils/index.d.ts.map +1 -1
  41. package/dist/utils/validation.d.ts +9 -0
  42. package/dist/utils/validation.d.ts.map +1 -1
  43. package/package.json +16 -6
  44. package/dist/app.js +0 -30
  45. package/dist/app.js.map +0 -1
  46. package/dist/core/http.js +0 -79
  47. package/dist/core/http.js.map +0 -1
  48. package/dist/core/index.js +0 -20
  49. package/dist/core/index.js.map +0 -1
  50. package/dist/core/query-builder.js +0 -271
  51. package/dist/core/query-builder.js.map +0 -1
  52. package/dist/core/types.js +0 -49
  53. package/dist/core/types.js.map +0 -1
  54. package/dist/db/index.js +0 -18
  55. package/dist/db/index.js.map +0 -1
  56. package/dist/db/mongodb.js +0 -24
  57. package/dist/db/mongodb.js.map +0 -1
  58. package/dist/exitCodes.js +0 -7
  59. package/dist/exitCodes.js.map +0 -1
  60. package/dist/fluent-interface/fluent-pattern-executor.d.ts.map +0 -1
  61. package/dist/fluent-interface/fluent-pattern-executor.js +0 -137
  62. package/dist/fluent-interface/fluent-pattern-executor.js.map +0 -1
  63. package/dist/fluent-interface/index.js +0 -19
  64. package/dist/fluent-interface/index.js.map +0 -1
  65. package/dist/fluent-interface/types.js +0 -3
  66. package/dist/fluent-interface/types.js.map +0 -1
  67. package/dist/index.js.map +0 -1
  68. package/dist/middleware/file-storage.js +0 -26
  69. package/dist/middleware/file-storage.js.map +0 -1
  70. package/dist/middleware/index.js +0 -19
  71. package/dist/middleware/index.js.map +0 -1
  72. package/dist/middleware/logger.js +0 -30
  73. package/dist/middleware/logger.js.map +0 -1
  74. package/dist/types.js +0 -3
  75. package/dist/types.js.map +0 -1
  76. package/dist/utils/date.js +0 -8
  77. package/dist/utils/date.js.map +0 -1
  78. package/dist/utils/index.js +0 -20
  79. package/dist/utils/index.js.map +0 -1
  80. package/dist/utils/mongo-relation.js +0 -89
  81. package/dist/utils/mongo-relation.js.map +0 -1
  82. package/dist/utils/validation.js +0 -17
  83. package/dist/utils/validation.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ export * from './session';
2
+ export * from './validation';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,OAAO,EACZ,GAAG,EAAE,QAAQ,GAAG;IAAE,MAAM,EAAE;QAAE,QAAQ,EAAE,gBAAgB,CAAA;KAAE,CAAA;CAAE,EAC1D,IAAI,EAAE,GAAG;YADiB;QAAE,QAAQ,EAAE,gBAAgB,CAAA;KAAE;gBAkBzD;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG;IAAE,MAAM,EAAE;QAAE,WAAW,EAAE,cAAc,CAAA;KAAE,CAAA;CAAE,EAAE,IAAI,EAAE,GAAG;YAA5C;QAAE,WAAW,EAAE,cAAc,CAAA;KAAE;gBAuBtG;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,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,iBA4BV;AAED;;;;;;;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,CAAC;QAAC,WAAW,EAAE,cAAc,CAAA;KAAE,CAAA;CAAE,EACjG,IAAI,EAAE,GAAG;YADiB;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,cAAc,CAAA;KAAE;gBAyChG;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface AuthUserPayload {
2
+ identifier: string;
3
+ jti: string;
4
+ exp?: number;
5
+ iat?: number;
6
+ }
7
+ export interface JWTCredentials {
8
+ accessToken: string;
9
+ refreshToken: string;
10
+ appUser: any;
11
+ }
12
+ //# 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,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,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,3 +1,5 @@
1
1
  export * from './file-storage';
2
2
  export * from './logger';
3
+ export * from './authentication/index';
4
+ export * from './types';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -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,QAc5E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,QAG3E"}
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,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,3 @@
1
+ export * from './auth-user';
2
+ export * from './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,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"}