@takentrade/takentrade-libs 1.0.1 → 1.0.3
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/auth/auth.module.d.ts +2 -0
- package/dist/auth/auth.module.js +21 -0
- package/dist/auth/decorators/index.d.ts +3 -0
- package/dist/auth/decorators/index.js +19 -0
- package/dist/auth/decorators/public.decorator.d.ts +2 -0
- package/dist/auth/decorators/public.decorator.js +7 -0
- package/dist/auth/decorators/roles.decorator.d.ts +10 -0
- package/dist/auth/decorators/roles.decorator.js +15 -0
- package/dist/auth/decorators/users.decorator.d.ts +8 -0
- package/dist/auth/decorators/users.decorator.js +48 -0
- package/dist/auth/guards/auth.guard.d.ts +19 -0
- package/dist/auth/guards/auth.guard.js +66 -0
- package/dist/auth/guards/index.d.ts +2 -0
- package/dist/auth/guards/index.js +18 -0
- package/dist/auth/guards/roles.guard.d.ts +15 -0
- package/dist/auth/guards/roles.guard.js +41 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.js +20 -0
- package/dist/auth/interfaces/auth.interface.d.ts +18 -0
- package/dist/auth/interfaces/auth.interface.js +8 -0
- package/dist/auth/interfaces/index.d.ts +1 -0
- package/dist/auth/interfaces/index.js +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/interfaces/config.interface.d.ts +10 -0
- package/dist/utils/utils/configuration.js +15 -1
- package/package.json +3 -1
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TNTAuthModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const auth_guard_1 = require("./guards/auth.guard");
|
|
12
|
+
const roles_guard_1 = require("./guards/roles.guard");
|
|
13
|
+
let TNTAuthModule = class TNTAuthModule {
|
|
14
|
+
};
|
|
15
|
+
exports.TNTAuthModule = TNTAuthModule;
|
|
16
|
+
exports.TNTAuthModule = TNTAuthModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
providers: [auth_guard_1.TNTAuthGuard, roles_guard_1.RolesGuard],
|
|
19
|
+
exports: [auth_guard_1.TNTAuthGuard, roles_guard_1.RolesGuard],
|
|
20
|
+
})
|
|
21
|
+
], TNTAuthModule);
|
|
@@ -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("./public.decorator"), exports);
|
|
18
|
+
__exportStar(require("./users.decorator"), exports);
|
|
19
|
+
__exportStar(require("./roles.decorator"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Public = exports.IS_PUBLIC_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.IS_PUBLIC_KEY = 'isPublic';
|
|
6
|
+
const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
|
|
7
|
+
exports.Public = Public;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata key for storing roles in the decorator.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ROLES_KEY = "roles";
|
|
5
|
+
/**
|
|
6
|
+
* Decorator to set required roles for a route or controller.
|
|
7
|
+
* @param roles List of role names required to access the resource.
|
|
8
|
+
* @returns Custom metadata decorator for role-based access control.
|
|
9
|
+
*/
|
|
10
|
+
export declare const Roles: (...roles: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Roles = exports.ROLES_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
/**
|
|
6
|
+
* Metadata key for storing roles in the decorator.
|
|
7
|
+
*/
|
|
8
|
+
exports.ROLES_KEY = 'roles';
|
|
9
|
+
/**
|
|
10
|
+
* Decorator to set required roles for a route or controller.
|
|
11
|
+
* @param roles List of role names required to access the resource.
|
|
12
|
+
* @returns Custom metadata decorator for role-based access control.
|
|
13
|
+
*/
|
|
14
|
+
const Roles = (...roles) => (0, common_1.SetMetadata)(exports.ROLES_KEY, roles);
|
|
15
|
+
exports.Roles = Roles;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TokenPayload } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Custom decorator to extract user data from the request.
|
|
4
|
+
* @param data Optional key of the TokenPayload to extract a specific property.
|
|
5
|
+
* @param ctx Execution context to access the request.
|
|
6
|
+
* @returns The user object or the specified property value.
|
|
7
|
+
*/
|
|
8
|
+
export declare const GetUser: (...dataOrPipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>> | keyof TokenPayload | undefined)[]) => ParameterDecorator;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetUser = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
/**
|
|
6
|
+
* Extracts the user object or a specific property from the request's user payload.
|
|
7
|
+
* @param data Optional key of the TokenPayload to extract a specific property.
|
|
8
|
+
* @param ctx Execution context to access the request.
|
|
9
|
+
* @returns The entire user object or the specified property value.
|
|
10
|
+
* @throws UnauthorizedException if user or requested property is not found.
|
|
11
|
+
*/
|
|
12
|
+
const getUserHelpers = {
|
|
13
|
+
getUserFromRequest(request) {
|
|
14
|
+
const user = request.user;
|
|
15
|
+
if (!user) {
|
|
16
|
+
throw new common_1.UnauthorizedException('User not found in request');
|
|
17
|
+
}
|
|
18
|
+
return user;
|
|
19
|
+
},
|
|
20
|
+
getUserProperty(user, data) {
|
|
21
|
+
if (!data) {
|
|
22
|
+
return user;
|
|
23
|
+
}
|
|
24
|
+
if (data === 'sub') {
|
|
25
|
+
const value = user.id || user.sub;
|
|
26
|
+
if (!value) {
|
|
27
|
+
throw new common_1.UnauthorizedException('User ID not found');
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
const value = user[data];
|
|
32
|
+
if (value === undefined) {
|
|
33
|
+
throw new common_1.UnauthorizedException(`User ${data} not found`);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Custom decorator to extract user data from the request.
|
|
40
|
+
* @param data Optional key of the TokenPayload to extract a specific property.
|
|
41
|
+
* @param ctx Execution context to access the request.
|
|
42
|
+
* @returns The user object or the specified property value.
|
|
43
|
+
*/
|
|
44
|
+
exports.GetUser = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
45
|
+
const request = ctx.switchToHttp().getRequest();
|
|
46
|
+
const user = getUserHelpers.getUserFromRequest(request);
|
|
47
|
+
return getUserHelpers.getUserProperty(user, data);
|
|
48
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
declare const TNTAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
4
|
+
/**
|
|
5
|
+
* Custom guard to validate JWT tokens and authorize requests using Passport JWT strategy.
|
|
6
|
+
* Allows public routes to bypass authentication if decorated with @Public().
|
|
7
|
+
*/
|
|
8
|
+
export declare class TNTAuthGuard extends TNTAuthGuard_base implements CanActivate {
|
|
9
|
+
private readonly reflector;
|
|
10
|
+
constructor(reflector: Reflector);
|
|
11
|
+
/**
|
|
12
|
+
* Determines if the request is authorized based on JWT validation.
|
|
13
|
+
* @param context Execution context containing the request.
|
|
14
|
+
* @returns True if the request is authorized or public, false otherwise.
|
|
15
|
+
* @throws UnauthorizedException if token validation fails.
|
|
16
|
+
*/
|
|
17
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TNTAuthGuard = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const passport_1 = require("@nestjs/passport");
|
|
12
|
+
const public_decorator_1 = require("../decorators/public.decorator");
|
|
13
|
+
/**
|
|
14
|
+
* Validates if the decoded JWT payload contains required AuthUser properties.
|
|
15
|
+
* @param payload The decoded JWT payload.
|
|
16
|
+
* @returns The validated AuthUser object with id, email, phone, isActive, and optional role.
|
|
17
|
+
* @throws UnauthorizedException if required properties are missing.
|
|
18
|
+
*/
|
|
19
|
+
function validateAuthUser(payload) {
|
|
20
|
+
if (!payload || typeof payload !== 'object') {
|
|
21
|
+
throw new common_1.UnauthorizedException('Invalid token payload');
|
|
22
|
+
}
|
|
23
|
+
const { id, email, phone, isActive, role } = payload;
|
|
24
|
+
if (!id || !email || !phone || isActive === undefined) {
|
|
25
|
+
throw new common_1.UnauthorizedException('Token payload missing required properties');
|
|
26
|
+
}
|
|
27
|
+
return { id, email, phone, isActive, role };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Custom guard to validate JWT tokens and authorize requests using Passport JWT strategy.
|
|
31
|
+
* Allows public routes to bypass authentication if decorated with @Public().
|
|
32
|
+
*/
|
|
33
|
+
let TNTAuthGuard = class TNTAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
34
|
+
reflector;
|
|
35
|
+
constructor(reflector) {
|
|
36
|
+
super();
|
|
37
|
+
this.reflector = reflector;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Determines if the request is authorized based on JWT validation.
|
|
41
|
+
* @param context Execution context containing the request.
|
|
42
|
+
* @returns True if the request is authorized or public, false otherwise.
|
|
43
|
+
* @throws UnauthorizedException if token validation fails.
|
|
44
|
+
*/
|
|
45
|
+
async canActivate(context) {
|
|
46
|
+
const isPublic = this.reflector.getAllAndOverride(public_decorator_1.IS_PUBLIC_KEY, [
|
|
47
|
+
context.getHandler(),
|
|
48
|
+
context.getClass(),
|
|
49
|
+
]);
|
|
50
|
+
if (isPublic) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
const canActivate = await super.canActivate(context);
|
|
54
|
+
if (!canActivate) {
|
|
55
|
+
throw new common_1.UnauthorizedException('Invalid or expired token');
|
|
56
|
+
}
|
|
57
|
+
const request = context.switchToHttp().getRequest();
|
|
58
|
+
const user = request.user;
|
|
59
|
+
request.user = validateAuthUser(user);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
exports.TNTAuthGuard = TNTAuthGuard;
|
|
64
|
+
exports.TNTAuthGuard = TNTAuthGuard = __decorate([
|
|
65
|
+
(0, common_1.Injectable)()
|
|
66
|
+
], TNTAuthGuard);
|
|
@@ -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("./auth.guard"), exports);
|
|
18
|
+
__exportStar(require("./roles.guard"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
/**
|
|
4
|
+
* Guard to enforce role-based access control using the Roles decorator.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RolesGuard implements CanActivate {
|
|
7
|
+
private reflector;
|
|
8
|
+
constructor(reflector: Reflector);
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the user has one of the required roles to access the route.
|
|
11
|
+
* @param context Execution context containing the request.
|
|
12
|
+
* @returns True if the user has a required role or no roles are specified, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
canActivate(context: ExecutionContext): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RolesGuard = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const roles_decorator_1 = require("../decorators/roles.decorator");
|
|
12
|
+
/**
|
|
13
|
+
* Guard to enforce role-based access control using the Roles decorator.
|
|
14
|
+
*/
|
|
15
|
+
let RolesGuard = class RolesGuard {
|
|
16
|
+
reflector;
|
|
17
|
+
constructor(reflector) {
|
|
18
|
+
this.reflector = reflector;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the user has one of the required roles to access the route.
|
|
22
|
+
* @param context Execution context containing the request.
|
|
23
|
+
* @returns True if the user has a required role or no roles are specified, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
canActivate(context) {
|
|
26
|
+
const requiredRoles = this.reflector.getAllAndOverride(roles_decorator_1.ROLES_KEY, [context.getHandler(), context.getClass()]);
|
|
27
|
+
if (!requiredRoles || requiredRoles.length === 0) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
const request = context.switchToHttp().getRequest();
|
|
31
|
+
const user = request.user;
|
|
32
|
+
if (!user || !user.role) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return requiredRoles.includes(user.role);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.RolesGuard = RolesGuard;
|
|
39
|
+
exports.RolesGuard = RolesGuard = __decorate([
|
|
40
|
+
(0, common_1.Injectable)()
|
|
41
|
+
], RolesGuard);
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./guards"), exports);
|
|
18
|
+
__exportStar(require("./decorators"), exports);
|
|
19
|
+
__exportStar(require("./auth.module"), exports);
|
|
20
|
+
__exportStar(require("./interfaces"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface AuthUser {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
phone: string;
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
role?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare enum UserType {
|
|
9
|
+
CUSTOMER = "CUSTOMER",
|
|
10
|
+
STAFF = "STAFF"
|
|
11
|
+
}
|
|
12
|
+
export interface TokenPayload {
|
|
13
|
+
sub?: string;
|
|
14
|
+
id?: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
role?: string;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserType = void 0;
|
|
4
|
+
var UserType;
|
|
5
|
+
(function (UserType) {
|
|
6
|
+
UserType["CUSTOMER"] = "CUSTOMER";
|
|
7
|
+
UserType["STAFF"] = "STAFF";
|
|
8
|
+
})(UserType || (exports.UserType = UserType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth.interface';
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./auth.interface"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export interface Configuration {
|
|
|
2
2
|
PORT: number;
|
|
3
3
|
HOST: string;
|
|
4
4
|
DATABASE_URL: string;
|
|
5
|
+
NOTIFICATION_DB_URL: string;
|
|
5
6
|
JWT_ACCESS_TOKEN_SECRET: string;
|
|
6
7
|
JWT_ACCESS_TOKEN_EXPIRES_IN: string;
|
|
7
8
|
JWT_REFRESH_TOKEN_SECRET: string;
|
|
@@ -11,8 +12,10 @@ export interface Configuration {
|
|
|
11
12
|
REDIS_USERNAME?: string;
|
|
12
13
|
REDIS_PASSWORD?: string;
|
|
13
14
|
MAIL_HOST: string;
|
|
15
|
+
MAIL_PORT: number;
|
|
14
16
|
MAIL_USER: string;
|
|
15
17
|
MAIL_PASS: string;
|
|
18
|
+
MAIL_FROM: string;
|
|
16
19
|
PROVIDUS_BASE_URL: string;
|
|
17
20
|
PROVIDUS_SECRET_KEY: string;
|
|
18
21
|
PROVIDUS_PUBLIC_KEY: string;
|
|
@@ -36,5 +39,12 @@ export interface Configuration {
|
|
|
36
39
|
NATS_URL: string;
|
|
37
40
|
CORS_ORIGIN: string;
|
|
38
41
|
EXPO_ACCESS_TOKEN: string;
|
|
42
|
+
AFRICASTALKING_BASE_URL: string;
|
|
39
43
|
AFRICASTALKING_API_KEY: string;
|
|
44
|
+
AFRICASTALKING_USERNAME: string;
|
|
45
|
+
TERMII_API_KEY: string;
|
|
46
|
+
TERMII_SECRET_KEY: string;
|
|
47
|
+
TERMII_BASE_URL: string;
|
|
48
|
+
TERMII_SENDER_ID: string;
|
|
49
|
+
TERMII_DEFAULT_CHANNEL: string;
|
|
40
50
|
}
|
|
@@ -41,20 +41,25 @@ exports.config = Joi.object({
|
|
|
41
41
|
HOST: Joi.string().default('localhost'),
|
|
42
42
|
// Database
|
|
43
43
|
DATABASE_URL: Joi.string().uri().required(),
|
|
44
|
+
NOTIFICATION_DB_URL: Joi.string().uri().required(),
|
|
44
45
|
// JWT
|
|
45
46
|
JWT_ACCESS_TOKEN_SECRET: Joi.string().required(),
|
|
46
47
|
JWT_ACCESS_TOKEN_EXPIRES_IN: Joi.string().default('90d'),
|
|
47
48
|
JWT_REFRESH_TOKEN_SECRET: Joi.string().required(),
|
|
48
49
|
JWT_REFRESH_TOKEN_EXPIRES_IN: Joi.string().default('30d'),
|
|
49
|
-
// Redis
|
|
50
|
+
// Redis
|
|
50
51
|
REDIS_HOST: Joi.string().default('localhost'),
|
|
51
52
|
REDIS_PORT: Joi.number().default(6379),
|
|
52
53
|
REDIS_USERNAME: Joi.string().optional(),
|
|
53
54
|
REDIS_PASSWORD: Joi.string().optional(),
|
|
54
55
|
// Mail Settings
|
|
55
56
|
MAIL_HOST: Joi.string().required(),
|
|
57
|
+
MAIL_PORT: Joi.number().required().default(587),
|
|
56
58
|
MAIL_USER: Joi.string().required(),
|
|
57
59
|
MAIL_PASS: Joi.string().required(),
|
|
60
|
+
MAIL_FROM: Joi.string()
|
|
61
|
+
.required()
|
|
62
|
+
.default('TakeNTrade <support@takentrade.com>'),
|
|
58
63
|
// Providus Bank
|
|
59
64
|
PROVIDUS_BASE_URL: Joi.string().uri().required(),
|
|
60
65
|
PROVIDUS_SECRET_KEY: Joi.string().required(),
|
|
@@ -84,5 +89,14 @@ exports.config = Joi.object({
|
|
|
84
89
|
NATS_URL: Joi.string().uri().default('nats://localhost:4222'),
|
|
85
90
|
CORS_ORIGIN: Joi.string().default('*'),
|
|
86
91
|
EXPO_ACCESS_TOKEN: Joi.string().required(),
|
|
92
|
+
// AfricasTalking
|
|
93
|
+
AFRICASTALKING_BASE_URL: Joi.string().required(),
|
|
87
94
|
AFRICASTALKING_API_KEY: Joi.string().required(),
|
|
95
|
+
AFRICASTALKING_USERNAME: Joi.string().required(),
|
|
96
|
+
// Termii
|
|
97
|
+
TERMII_API_KEY: Joi.string().required(),
|
|
98
|
+
TERMII_SECRET_KEY: Joi.string().required(),
|
|
99
|
+
TERMII_BASE_URL: Joi.string().uri().required(),
|
|
100
|
+
TERMII_SENDER_ID: Joi.string().required(),
|
|
101
|
+
TERMII_DEFAULT_CHANNEL: Joi.string().required(),
|
|
88
102
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takentrade/takentrade-libs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "TakeNTrade shared libraries",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@nestjs/config": "^4.0.2",
|
|
33
33
|
"@nestjs/jwt": "^11.0.0",
|
|
34
34
|
"@nestjs/microservices": "^11.1.5",
|
|
35
|
+
"@nestjs/passport": "^11.0.5",
|
|
35
36
|
"@nestjs/swagger": "^11.2.0",
|
|
36
37
|
"@nestjs/terminus": "^11.0.0",
|
|
37
38
|
"@prisma/client": "^6.12.0",
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@types/node": "^24.1.0",
|
|
52
53
|
"@types/object-hash": "^3.0.6",
|
|
54
|
+
"@types/passport": "^1.0.17",
|
|
53
55
|
"prettier": "^3.6.2"
|
|
54
56
|
},
|
|
55
57
|
"exports": {
|