@dveloxsoft/dvs-client-nestjs 0.0.1
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/README.md +171 -0
- package/dist/client/axios-http-client.d.ts +17 -0
- package/dist/client/axios-http-client.d.ts.map +1 -0
- package/dist/client/axios-http-client.js +67 -0
- package/dist/client/axios-http-client.js.map +1 -0
- package/dist/client/dvs-auth.client.d.ts +68 -0
- package/dist/client/dvs-auth.client.d.ts.map +1 -0
- package/dist/client/dvs-auth.client.js +141 -0
- package/dist/client/dvs-auth.client.js.map +1 -0
- package/dist/client/dvs-notification.client.d.ts +29 -0
- package/dist/client/dvs-notification.client.d.ts.map +1 -0
- package/dist/client/dvs-notification.client.js +145 -0
- package/dist/client/dvs-notification.client.js.map +1 -0
- package/dist/client/dvs-user.client.d.ts +69 -0
- package/dist/client/dvs-user.client.d.ts.map +1 -0
- package/dist/client/dvs-user.client.js +178 -0
- package/dist/client/dvs-user.client.js.map +1 -0
- package/dist/client/http-client.interface.d.ts +32 -0
- package/dist/client/http-client.interface.d.ts.map +1 -0
- package/dist/client/http-client.interface.js +3 -0
- package/dist/client/http-client.interface.js.map +1 -0
- package/dist/client/types.d.ts +29 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +10 -0
- package/dist/client/types.js.map +1 -0
- package/dist/dto/auth/index.d.ts +35 -0
- package/dist/dto/auth/index.d.ts.map +1 -0
- package/dist/dto/auth/index.js +3 -0
- package/dist/dto/auth/index.js.map +1 -0
- package/dist/dto/notification/index.d.ts +36 -0
- package/dist/dto/notification/index.d.ts.map +1 -0
- package/dist/dto/notification/index.js +3 -0
- package/dist/dto/notification/index.js.map +1 -0
- package/dist/dto/user/index.d.ts +49 -0
- package/dist/dto/user/index.d.ts.map +1 -0
- package/dist/dto/user/index.js +3 -0
- package/dist/dto/user/index.js.map +1 -0
- package/dist/dvs-client.module.d.ts +15 -0
- package/dist/dvs-client.module.d.ts.map +1 -0
- package/dist/dvs-client.module.js +133 -0
- package/dist/dvs-client.module.js.map +1 -0
- package/dist/exceptions/auth-errors.enum.d.ts +14 -0
- package/dist/exceptions/auth-errors.enum.d.ts.map +1 -0
- package/dist/exceptions/auth-errors.enum.js +29 -0
- package/dist/exceptions/auth-errors.enum.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/auth-response.interface.d.ts +10 -0
- package/dist/interfaces/auth-response.interface.d.ts.map +1 -0
- package/dist/interfaces/auth-response.interface.js +3 -0
- package/dist/interfaces/auth-response.interface.js.map +1 -0
- package/dist/interfaces/email-response.interface.d.ts +12 -0
- package/dist/interfaces/email-response.interface.d.ts.map +1 -0
- package/dist/interfaces/email-response.interface.js +3 -0
- package/dist/interfaces/email-response.interface.js.map +1 -0
- package/dist/interfaces/page-config.interface.d.ts +21 -0
- package/dist/interfaces/page-config.interface.d.ts.map +1 -0
- package/dist/interfaces/page-config.interface.js +3 -0
- package/dist/interfaces/page-config.interface.js.map +1 -0
- package/dist/interfaces/user-response.interface.d.ts +17 -0
- package/dist/interfaces/user-response.interface.d.ts.map +1 -0
- package/dist/interfaces/user-response.interface.js +3 -0
- package/dist/interfaces/user-response.interface.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @dveloxsoft/dvs-client-nestjs
|
|
2
|
+
|
|
3
|
+
Cliente HTTP para microservicios DVS-Auth, DVS-User y DVS-Notification del ecosistema DveloxSoft.
|
|
4
|
+
|
|
5
|
+
## Instalación
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @dveloxsoft/dvs-client-nestjs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Variables de Entorno
|
|
12
|
+
|
|
13
|
+
Esta librería utiliza las siguientes variables de entorno para funcionar:
|
|
14
|
+
|
|
15
|
+
| Variable | Descripción | Requerido | Valor por defecto |
|
|
16
|
+
|----------|-------------|-----------|-------------------|
|
|
17
|
+
| `DVELOXSOFT_MS_AUTH_TOKEN` | JWT token para autenticación con el gateway | Sí | (ninguno) |
|
|
18
|
+
| `DVELOXSOFT_MS_BASE_URL` | URL base del gateway | No | `https://ms.dveloxsoft.com` |
|
|
19
|
+
| `DVELOXSOFT_MS_ORIGIN` | Origen HTTP para headers | Sí | (ninguno) |
|
|
20
|
+
| `DVELOXSOFT_MS_REFERER` | Referer HTTP para headers | Sí | (ninguno) |
|
|
21
|
+
| `HTTP_REQUEST_TIMEOUT` | Timeout en milisegundos | No | `30000` |
|
|
22
|
+
|
|
23
|
+
## Uso
|
|
24
|
+
|
|
25
|
+
### En aplicación NestJS
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Module } from '@nestjs/common';
|
|
29
|
+
import { DVSClientModule } from '@dveloxsoft/dvs-client-nestjs';
|
|
30
|
+
|
|
31
|
+
@Module({
|
|
32
|
+
imports: [
|
|
33
|
+
DVSClientModule.forRoot({
|
|
34
|
+
// DVELOXSOFT_MS_AUTH_TOKEN es requerido
|
|
35
|
+
authToken: process.env.DVELOXSOFT_MS_AUTH_TOKEN,
|
|
36
|
+
// DVELOXSOFT_MS_BASE_URL tiene un valor por defecto: https://ms.dveloxsoft.com
|
|
37
|
+
// Solo es necesario sobrescribirlo si se usa un gateway diferente
|
|
38
|
+
baseUrl: process.env.DVELOXSOFT_MS_BASE_URL, // Opcional
|
|
39
|
+
// DVELOXSOFT_MS_ORIGIN y DVELOXSOFT_MS_REFERER son requeridos
|
|
40
|
+
defaultOrigin: process.env.DVELOXSOFT_MS_ORIGIN,
|
|
41
|
+
defaultReferer: process.env.DVELOXSOFT_MS_REFERER,
|
|
42
|
+
timeout: 30000,
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
})
|
|
46
|
+
export class AppModule {}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Ejemplo mínimo (usando valor por defecto para baseUrl)
|
|
50
|
+
|
|
51
|
+
Si su gateway está en `https://ms.dveloxsoft.com`, solo necesita proporcionar las variables requeridas:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
@Module({
|
|
55
|
+
imports: [
|
|
56
|
+
DVSClientModule.forRoot({
|
|
57
|
+
authToken: process.env.DVELOXSOFT_MS_AUTH_TOKEN, // Requerido
|
|
58
|
+
defaultOrigin: process.env.DVELOXSOFT_MS_ORIGIN, // Requerido
|
|
59
|
+
defaultReferer: process.env.DVELOXSOFT_MS_REFERER, // Requerido
|
|
60
|
+
// baseUrl usa por defecto: https://ms.dveloxsoft.com
|
|
61
|
+
}),
|
|
62
|
+
],
|
|
63
|
+
})
|
|
64
|
+
export class AppModule {}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Usar los clientes
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { Injectable } from '@nestjs/common';
|
|
71
|
+
import { DVSAuthClient, DVSUserClient, DVSNotificationClient } from '@dveloxsoft/dvs-client-nestjs';
|
|
72
|
+
|
|
73
|
+
@Injectable()
|
|
74
|
+
export class MyService {
|
|
75
|
+
constructor(
|
|
76
|
+
private readonly authClient: DVSAuthClient,
|
|
77
|
+
private readonly userClient: DVSUserClient,
|
|
78
|
+
private readonly notificationClient: DVSNotificationClient,
|
|
79
|
+
) {}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Access Token (Authorization Bearer)
|
|
83
|
+
|
|
84
|
+
Algunos endpoints requieren el header `Authorization: Bearer <accessToken>` en adición al `x-ms-authorization-token`.
|
|
85
|
+
|
|
86
|
+
### Configurar access token
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// Después del login
|
|
90
|
+
const { access_token } = await authClient.login({ email, password });
|
|
91
|
+
userClient.setAccessToken(access_token);
|
|
92
|
+
|
|
93
|
+
// Para logout
|
|
94
|
+
authClient.setAccessToken(access_token);
|
|
95
|
+
await authClient.logout(refresh_token);
|
|
96
|
+
|
|
97
|
+
// Limpiar token
|
|
98
|
+
userClient.clearAccessToken();
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Validación
|
|
102
|
+
|
|
103
|
+
La librería lanzará un error al intentar crear los clientes si faltan las siguientes variables de entorno requeridas:
|
|
104
|
+
|
|
105
|
+
- `DVELOXSOFT_MS_AUTH_TOKEN` - Token JWT para autenticación con el gateway
|
|
106
|
+
- `DVELOXSOFT_MS_ORIGIN` - Origen HTTP para headers
|
|
107
|
+
- `DVELOXSOFT_MS_REFERER` - Referer HTTP para headers
|
|
108
|
+
|
|
109
|
+
La variable `DVELOXSOFT_MS_BASE_URL` tiene un valor por defecto (`https://ms.dveloxsoft.com`) y no es estrictamente requerida. Si no está definida, se usará el valor por defecto.
|
|
110
|
+
|
|
111
|
+
Ejemplo de error si faltan variables requeridas:
|
|
112
|
+
```
|
|
113
|
+
Error: DVELOXSOFT_MS_AUTH_TOKEN is required. Provide it via forRoot() or set it as an environment variable.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## API
|
|
117
|
+
|
|
118
|
+
### DVSAuthClient
|
|
119
|
+
|
|
120
|
+
- `login(dto: LoginDto)` - Iniciar sesión
|
|
121
|
+
- `register(dto: RegisterDto)` - Registrar usuario
|
|
122
|
+
- `refreshToken(dto: RefreshTokenDto)` - Refrescar token
|
|
123
|
+
- `requestPasswordReset(dto: PasswordResetRequestDto)` - Solicitar reset de contraseña
|
|
124
|
+
- `validateResetToken(token: string)` - Validar token de reset
|
|
125
|
+
- `resetPassword(dto: ResetPasswordDto)` - Resetear contraseña
|
|
126
|
+
- `activateAccount(code: string, pageId: string)` - Activar cuenta
|
|
127
|
+
- `resendConfirmationToken(email: string)` - Reenviar token de confirmación
|
|
128
|
+
- `verifyTwoFactor(dto: TwoFactorDto)` - Verificar 2FA
|
|
129
|
+
- `setupTwoFactor(userId: string)` - Configurar 2FA
|
|
130
|
+
- `confirmTwoFactorSetup(dto: TwoFactorDto)` - Confirmar configuración 2FA
|
|
131
|
+
- `disableTwoFactor(userId: string)` - Deshabilitar 2FA
|
|
132
|
+
- `logout(refreshToken?)` - Cerrar sesión
|
|
133
|
+
|
|
134
|
+
### DVSUserClient
|
|
135
|
+
|
|
136
|
+
- `create(dto: CreateUserDto)` - Crear usuario
|
|
137
|
+
- `findAll(options?)` - Listar usuarios con paginación
|
|
138
|
+
- `findOne(id)` - Obtener usuario por ID
|
|
139
|
+
- `findByEmail(email, includePassword?)` - Buscar por email
|
|
140
|
+
- `update(id, dto)` - Actualizar usuario
|
|
141
|
+
- `delete(id)` - Eliminar usuario
|
|
142
|
+
- `deleteWithData(id)` - Eliminar con datos relacionados
|
|
143
|
+
- `search(email, companyId?)` - Buscar usuarios
|
|
144
|
+
- `getFullDetail(email, pages)` - Obtener detalle completo
|
|
145
|
+
- `findPartner(email)` - Buscar partner
|
|
146
|
+
- `updateLastLogin(userId)` - Actualizar último login
|
|
147
|
+
- `resetPassword(email, password, pageId?)` - Resetear contraseña
|
|
148
|
+
- `verifyTwoFactor(userId, code)` - Verificar 2FA
|
|
149
|
+
- `setupTwoFactor(dto)` - Configurar 2FA
|
|
150
|
+
- `confirmTwoFactorSetup(userId, code)` - Confirmar 2FA
|
|
151
|
+
- `enableTwoFactor(userId)` - Habilitar 2FA
|
|
152
|
+
- `disableTwoFactor(userId)` - Deshabilitar 2FA
|
|
153
|
+
- `subscribeNewsletter(email, pageId?)` - Suscribir a newsletter
|
|
154
|
+
|
|
155
|
+
### DVSNotificationClient
|
|
156
|
+
|
|
157
|
+
#### Send Email
|
|
158
|
+
- `sendEmail(dto: SendEmailDto)` - Enviar correo directamente
|
|
159
|
+
- `sendEmailByTrigger(dto: SendEmailTriggerDto)` - Enviar correo por trigger
|
|
160
|
+
|
|
161
|
+
#### Email Templates
|
|
162
|
+
- `createTemplate(dto: CreateEmailTemplateDto)` - Crear plantilla
|
|
163
|
+
- `getAllTemplates(options?)` - Listar todas las plantillas
|
|
164
|
+
- `getTemplatesByCompany(companyId, options?)` - Listar por empresa
|
|
165
|
+
- `getTemplate(id)` - Obtener plantilla por ID
|
|
166
|
+
- `updateTemplate(id, dto)` - Actualizar plantilla
|
|
167
|
+
- `deleteTemplate(id)` - Eliminar plantilla
|
|
168
|
+
- `testTemplate(template)` - Probar plantilla
|
|
169
|
+
- `testEmailConfig(config)` - Probar configuración SMTP
|
|
170
|
+
- `deleteAllTemplates(ids)` - Eliminar múltiples plantillas
|
|
171
|
+
- `deleteTemplatesByCompany(companyId)` - Eliminar por empresa
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpClient, HttpRequestConfig, HttpResponse, HttpClientConfig } from './http-client.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Default Axios implementation of HttpClient interface
|
|
4
|
+
* This is the standard HTTP client used by all DVS clients unless overridden
|
|
5
|
+
*/
|
|
6
|
+
export declare class AxiosHttpClient implements HttpClient {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(config: HttpClientConfig);
|
|
9
|
+
get<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
10
|
+
post<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
11
|
+
put<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
12
|
+
delete<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
13
|
+
request<T = any>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
14
|
+
private buildConfig;
|
|
15
|
+
private toHttpResponse;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=axios-http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-http-client.d.ts","sourceRoot":"","sources":["../../src/client/axios-http-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExG;;;GAGG;AACH,qBAAa,eAAgB,YAAW,UAAU;IAChD,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,gBAAgB;IAkB9B,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAK/E,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAK5F,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAK3F,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAKlF,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAK3E,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,cAAc;CAQvB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AxiosHttpClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
/**
|
|
9
|
+
* Default Axios implementation of HttpClient interface
|
|
10
|
+
* This is the standard HTTP client used by all DVS clients unless overridden
|
|
11
|
+
*/
|
|
12
|
+
class AxiosHttpClient {
|
|
13
|
+
client;
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.client = axios_1.default.create({
|
|
16
|
+
baseURL: config.baseUrl,
|
|
17
|
+
timeout: config.timeout,
|
|
18
|
+
headers: config.defaultHeaders,
|
|
19
|
+
});
|
|
20
|
+
// Apply default error response interceptor
|
|
21
|
+
this.client.interceptors.response.use((response) => response, (error) => {
|
|
22
|
+
const status = error.response?.status || 500;
|
|
23
|
+
const message = error.response?.data?.message || error.message || 'Error en la petic�n';
|
|
24
|
+
throw new Error(JSON.stringify({ status, message, data: error.response?.data }));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async get(url, config) {
|
|
28
|
+
const response = await this.client.get(url, this.buildConfig(config));
|
|
29
|
+
return this.toHttpResponse(response);
|
|
30
|
+
}
|
|
31
|
+
async post(url, data, config) {
|
|
32
|
+
const response = await this.client.post(url, data, this.buildConfig(config));
|
|
33
|
+
return this.toHttpResponse(response);
|
|
34
|
+
}
|
|
35
|
+
async put(url, data, config) {
|
|
36
|
+
const response = await this.client.put(url, data, this.buildConfig(config));
|
|
37
|
+
return this.toHttpResponse(response);
|
|
38
|
+
}
|
|
39
|
+
async delete(url, config) {
|
|
40
|
+
const response = await this.client.delete(url, this.buildConfig(config));
|
|
41
|
+
return this.toHttpResponse(response);
|
|
42
|
+
}
|
|
43
|
+
async request(config) {
|
|
44
|
+
const response = await this.client.request(this.buildConfig(config));
|
|
45
|
+
return this.toHttpResponse(response);
|
|
46
|
+
}
|
|
47
|
+
buildConfig(config) {
|
|
48
|
+
if (!config)
|
|
49
|
+
return {};
|
|
50
|
+
return {
|
|
51
|
+
headers: config.headers,
|
|
52
|
+
params: config.params,
|
|
53
|
+
timeout: config.timeout,
|
|
54
|
+
data: config.data,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
toHttpResponse(response) {
|
|
58
|
+
return {
|
|
59
|
+
data: response.data,
|
|
60
|
+
status: response.status,
|
|
61
|
+
statusText: response.statusText,
|
|
62
|
+
headers: response.headers,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.AxiosHttpClient = AxiosHttpClient;
|
|
67
|
+
//# sourceMappingURL=axios-http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-http-client.js","sourceRoot":"","sources":["../../src/client/axios-http-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAgF;AAGhF;;;GAGG;AACH,MAAa,eAAe;IAClB,MAAM,CAAgB;IAE9B,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,cAAc;SAC/B,CAAC,CAAC;QAEH,2CAA2C;QAC3C,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CACnC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EACtB,CAAC,KAAK,EAAE,EAAE;YACR,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,CAAC;YAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,IAAI,qBAAqB,CAAC;YACxF,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,CAAC,CACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAU,GAAW,EAAE,MAA0B;QACxD,MAAM,QAAQ,GAAqB,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC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;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC;IACJ,CAAC;IAEO,cAAc,CAAI,QAA0B;QAClD,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,OAAO,EAAE,QAAQ,CAAC,OAAiC;SACpD,CAAC;IACJ,CAAC;CACF;AAhED,0CAgEC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { LoginDto, RegisterDto, RefreshTokenDto, ResetPasswordDto, PasswordResetRequestDto, TwoFactorDto } from '../dto/auth';
|
|
2
|
+
import { AuthResponse } from '../interfaces/auth-response.interface';
|
|
3
|
+
import { ClientConfig } from './types';
|
|
4
|
+
export declare class DVSAuthClient {
|
|
5
|
+
private httpClient;
|
|
6
|
+
private baseUrl;
|
|
7
|
+
private authToken;
|
|
8
|
+
private defaultOrigin;
|
|
9
|
+
private defaultReferer;
|
|
10
|
+
private accessToken;
|
|
11
|
+
constructor(config?: ClientConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Set the user access token for authenticated requests
|
|
14
|
+
*/
|
|
15
|
+
setAccessToken(token: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Clear the user access token
|
|
18
|
+
*/
|
|
19
|
+
clearAccessToken(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get the current access token
|
|
22
|
+
*/
|
|
23
|
+
getAccessToken(): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Build headers with optional Authorization Bearer token
|
|
26
|
+
*/
|
|
27
|
+
private buildAuthHeaders;
|
|
28
|
+
login(dto: LoginDto): Promise<AuthResponse>;
|
|
29
|
+
register(dto: RegisterDto): Promise<AuthResponse & {
|
|
30
|
+
autoActivated?: boolean;
|
|
31
|
+
message?: string;
|
|
32
|
+
}>;
|
|
33
|
+
refreshToken(dto: RefreshTokenDto): Promise<AuthResponse>;
|
|
34
|
+
requestPasswordReset(dto: PasswordResetRequestDto): Promise<{
|
|
35
|
+
message: string;
|
|
36
|
+
}>;
|
|
37
|
+
validateResetToken(token: string): Promise<{
|
|
38
|
+
valid: boolean;
|
|
39
|
+
email: string;
|
|
40
|
+
}>;
|
|
41
|
+
resetPassword(dto: ResetPasswordDto): Promise<{
|
|
42
|
+
message: string;
|
|
43
|
+
}>;
|
|
44
|
+
activateAccount(code: string, pageId: string): Promise<{
|
|
45
|
+
message: string;
|
|
46
|
+
}>;
|
|
47
|
+
resendConfirmationToken(email: string): Promise<{
|
|
48
|
+
message: string;
|
|
49
|
+
}>;
|
|
50
|
+
verifyTwoFactor(dto: TwoFactorDto): Promise<AuthResponse>;
|
|
51
|
+
setupTwoFactor(userId: string): Promise<{
|
|
52
|
+
secret: string;
|
|
53
|
+
otpauthUrl: string;
|
|
54
|
+
backupCodes: string[];
|
|
55
|
+
message: string;
|
|
56
|
+
}>;
|
|
57
|
+
confirmTwoFactorSetup(dto: TwoFactorDto): Promise<{
|
|
58
|
+
message: string;
|
|
59
|
+
twoFactorEnabled: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
disableTwoFactor(userId: string): Promise<{
|
|
62
|
+
message: string;
|
|
63
|
+
}>;
|
|
64
|
+
logout(refreshToken?: string): Promise<{
|
|
65
|
+
message: string;
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=dvs-auth.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dvs-auth.client.d.ts","sourceRoot":"","sources":["../../src/client/dvs-auth.client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE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KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAMpE,eAAe,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAMzD,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAUvH,qBAAqB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAA;KAAE,CAAC;IAMjG,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAM9D,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAKlE"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DVSAuthClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const types_1 = require("./types");
|
|
9
|
+
class DVSAuthClient {
|
|
10
|
+
httpClient;
|
|
11
|
+
baseUrl;
|
|
12
|
+
authToken;
|
|
13
|
+
defaultOrigin;
|
|
14
|
+
defaultReferer;
|
|
15
|
+
accessToken = null;
|
|
16
|
+
constructor(config = {}) {
|
|
17
|
+
this.baseUrl = config.baseUrl || process.env.DVELOXSOFT_MS_BASE_URL || types_1.DEFAULT_BASE_URL;
|
|
18
|
+
this.authToken = config.authToken || process.env.DVELOXSOFT_MS_AUTH_TOKEN || types_1.DEFAULT_AUTH_TOKEN;
|
|
19
|
+
this.defaultOrigin = config.defaultOrigin || process.env.DVELOXSOFT_MS_ORIGIN || types_1.DEFAULT_ORIGIN;
|
|
20
|
+
this.defaultReferer = config.defaultReferer || process.env.DVELOXSOFT_MS_REFERER || types_1.DEFAULT_REFERER;
|
|
21
|
+
// Validate required configuration
|
|
22
|
+
if (!this.authToken) {
|
|
23
|
+
throw new Error('DVELOXSOFT_MS_AUTH_TOKEN is required. Set it as an environment variable or pass it to forRoot().');
|
|
24
|
+
}
|
|
25
|
+
this.httpClient = axios_1.default.create({
|
|
26
|
+
baseURL: this.baseUrl,
|
|
27
|
+
timeout: config.timeout ?? types_1.DEFAULT_TIMEOUT,
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
'x-ms-authorization-token': this.authToken,
|
|
31
|
+
Origin: this.defaultOrigin,
|
|
32
|
+
Referer: this.defaultReferer,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
this.httpClient.interceptors.response.use(response => response, error => {
|
|
36
|
+
const status = error.response?.status || 500;
|
|
37
|
+
const message = error.response?.data?.message || error.message || 'Error en la petición';
|
|
38
|
+
throw new Error(JSON.stringify({ status, message, data: error.response?.data }));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set the user access token for authenticated requests
|
|
43
|
+
*/
|
|
44
|
+
setAccessToken(token) {
|
|
45
|
+
this.accessToken = token;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Clear the user access token
|
|
49
|
+
*/
|
|
50
|
+
clearAccessToken() {
|
|
51
|
+
this.accessToken = null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the current access token
|
|
55
|
+
*/
|
|
56
|
+
getAccessToken() {
|
|
57
|
+
return this.accessToken;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build headers with optional Authorization Bearer token
|
|
61
|
+
*/
|
|
62
|
+
buildAuthHeaders() {
|
|
63
|
+
const headers = {
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
|
+
'x-ms-authorization-token': this.authToken,
|
|
66
|
+
Origin: this.defaultOrigin,
|
|
67
|
+
Referer: this.defaultReferer,
|
|
68
|
+
};
|
|
69
|
+
if (this.accessToken) {
|
|
70
|
+
headers['Authorization'] = `Bearer ${this.accessToken}`;
|
|
71
|
+
}
|
|
72
|
+
return headers;
|
|
73
|
+
}
|
|
74
|
+
// Public endpoints - no accessToken required
|
|
75
|
+
async login(dto) {
|
|
76
|
+
const response = await this.httpClient.post('/auth/login', dto);
|
|
77
|
+
return response.data;
|
|
78
|
+
}
|
|
79
|
+
async register(dto) {
|
|
80
|
+
const response = await this.httpClient.post('/auth/register', dto);
|
|
81
|
+
return response.data;
|
|
82
|
+
}
|
|
83
|
+
// Protected endpoints - include Authorization header when accessToken is set
|
|
84
|
+
async refreshToken(dto) {
|
|
85
|
+
const headers = this.buildAuthHeaders();
|
|
86
|
+
const response = await this.httpClient.post('/auth/refresh', dto, { headers });
|
|
87
|
+
return response.data;
|
|
88
|
+
}
|
|
89
|
+
async requestPasswordReset(dto) {
|
|
90
|
+
const headers = this.buildAuthHeaders();
|
|
91
|
+
const response = await this.httpClient.post('/auth/request-password-reset', dto, { headers });
|
|
92
|
+
return response.data;
|
|
93
|
+
}
|
|
94
|
+
async validateResetToken(token) {
|
|
95
|
+
const response = await this.httpClient.get('/auth/validate-reset-token', {
|
|
96
|
+
params: { token },
|
|
97
|
+
});
|
|
98
|
+
return response.data;
|
|
99
|
+
}
|
|
100
|
+
async resetPassword(dto) {
|
|
101
|
+
const response = await this.httpClient.post('/auth/reset-password', dto);
|
|
102
|
+
return response.data;
|
|
103
|
+
}
|
|
104
|
+
async activateAccount(code, pageId) {
|
|
105
|
+
const headers = this.buildAuthHeaders();
|
|
106
|
+
const response = await this.httpClient.post('/auth/activate', { code, pageId }, { headers });
|
|
107
|
+
return response.data;
|
|
108
|
+
}
|
|
109
|
+
async resendConfirmationToken(email) {
|
|
110
|
+
const headers = this.buildAuthHeaders();
|
|
111
|
+
const response = await this.httpClient.get(`/auth/send-confirmation-token/${email}`, { headers });
|
|
112
|
+
return response.data;
|
|
113
|
+
}
|
|
114
|
+
async verifyTwoFactor(dto) {
|
|
115
|
+
const headers = this.buildAuthHeaders();
|
|
116
|
+
const response = await this.httpClient.post('/auth/verify-two-factor', dto, { headers });
|
|
117
|
+
return response.data;
|
|
118
|
+
}
|
|
119
|
+
async setupTwoFactor(userId) {
|
|
120
|
+
const headers = this.buildAuthHeaders();
|
|
121
|
+
const response = await this.httpClient.post(`/auth/setup-two-factor/${userId}`, {}, { headers });
|
|
122
|
+
return response.data;
|
|
123
|
+
}
|
|
124
|
+
async confirmTwoFactorSetup(dto) {
|
|
125
|
+
const headers = this.buildAuthHeaders();
|
|
126
|
+
const response = await this.httpClient.post('/auth/confirm-two-factor-setup', dto, { headers });
|
|
127
|
+
return response.data;
|
|
128
|
+
}
|
|
129
|
+
async disableTwoFactor(userId) {
|
|
130
|
+
const headers = this.buildAuthHeaders();
|
|
131
|
+
const response = await this.httpClient.post(`/auth/disable-two-factor/${userId}`, {}, { headers });
|
|
132
|
+
return response.data;
|
|
133
|
+
}
|
|
134
|
+
async logout(refreshToken) {
|
|
135
|
+
const headers = this.buildAuthHeaders();
|
|
136
|
+
const response = await this.httpClient.post('/auth/logout', { refreshToken }, { headers });
|
|
137
|
+
return response.data;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.DVSAuthClient = DVSAuthClient;
|
|
141
|
+
//# sourceMappingURL=dvs-auth.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dvs-auth.client.js","sourceRoot":"","sources":["../../src/client/dvs-auth.client.ts"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAU1B,mCAA+H;AAE/H,MAAa,aAAa;IA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AC,gBAAgB,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAsB,4BAA4B,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACxH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,YAAqB;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAsB,cAAc,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAChH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAhKD,sCAgKC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SendEmailDto, SendEmailTriggerDto, CreateEmailTemplateDto, UpdateEmailTemplateDto, TestEmailDto } from '../dto/notification';
|
|
2
|
+
import { EmailResponse, EmailTemplateResponse } from '../interfaces/email-response.interface';
|
|
3
|
+
import { ClientConfig, PaginationOptions, PaginatedResponse } from './types';
|
|
4
|
+
export declare class DVSNotificationClient {
|
|
5
|
+
private httpClient;
|
|
6
|
+
private baseUrl;
|
|
7
|
+
private authToken;
|
|
8
|
+
private defaultOrigin;
|
|
9
|
+
private defaultReferer;
|
|
10
|
+
private accessToken;
|
|
11
|
+
constructor(config?: ClientConfig);
|
|
12
|
+
setAccessToken(token: string): void;
|
|
13
|
+
clearAccessToken(): void;
|
|
14
|
+
getAccessToken(): string | null;
|
|
15
|
+
private buildAuthHeaders;
|
|
16
|
+
sendEmail(dto: SendEmailDto): Promise<EmailResponse>;
|
|
17
|
+
sendEmailByTrigger(dto: SendEmailTriggerDto): Promise<EmailResponse>;
|
|
18
|
+
createTemplate(dto: CreateEmailTemplateDto): Promise<EmailTemplateResponse>;
|
|
19
|
+
getAllTemplates(options?: PaginationOptions): Promise<PaginatedResponse<EmailTemplateResponse>>;
|
|
20
|
+
getTemplatesByCompany(companyId: string, options?: PaginationOptions): Promise<PaginatedResponse<EmailTemplateResponse>>;
|
|
21
|
+
getTemplate(id: string): Promise<EmailTemplateResponse>;
|
|
22
|
+
updateTemplate(id: string, dto: UpdateEmailTemplateDto): Promise<EmailResponse>;
|
|
23
|
+
deleteTemplate(id: string): Promise<EmailResponse>;
|
|
24
|
+
testTemplate(template: string): Promise<EmailResponse>;
|
|
25
|
+
testEmailConfig(config: TestEmailDto): Promise<EmailResponse>;
|
|
26
|
+
deleteAllTemplates(ids: string[]): Promise<EmailResponse>;
|
|
27
|
+
deleteTemplatesByCompany(companyId: string): Promise<EmailResponse>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=dvs-notification.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dvs-notification.client.d.ts","sourceRoot":"","sources":["../../src/client/dvs-notification.client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EAMlB,MAAM,SAAS,CAAC;AAEjB,qBAAa,qBAAqB;IAChC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,WAAW,CAAuB;gBAE9B,MAAM,GAAE,YAAiB;IAiCrC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC,gBAAgB,IAAI,IAAI;IAIxB,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B,OA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