prime-sdk 3.0.7-beta.0 → 3.0.7
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/.eslintrc.js +0 -4
- package/.vscode/settings.json +4 -0
- package/.yarn/install-state.gz +0 -0
- package/README.md +0 -307
- package/dist/external/aws/sns/sns.provider.d.ts +1 -0
- package/dist/external/aws/sns/sns.provider.js +8 -2
- package/dist/external/aws/sns/sns.provider.js.map +1 -1
- package/dist/external/aws/sns/sns.service.d.ts +4 -1
- package/dist/external/aws/sns/sns.service.js +21 -2
- package/dist/external/aws/sns/sns.service.js.map +1 -1
- package/dist/external/redis/interfaces/redis.interface.d.ts +1 -0
- package/dist/external/redis/interfaces/redis.interface.js.map +1 -1
- package/dist/external/redis/redis.service.d.ts +1 -0
- package/dist/external/redis/redis.service.js +13 -0
- package/dist/external/redis/redis.service.js.map +1 -1
- package/dist/index.d.ts +2 -15
- package/dist/index.js +1 -25
- package/dist/index.js.map +1 -1
- package/dist/lib/cache/cache.d.ts +1 -0
- package/dist/lib/cache/cache.js +3 -0
- package/dist/lib/cache/cache.js.map +1 -1
- package/dist/lib/cache/interfaces/cache.interface.d.ts +1 -0
- package/dist/lib/cache/interfaces/cache.interface.js.map +1 -1
- package/dist/lib/events/types/event.type.d.ts +2 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -4
- package/src/external/aws/sns/sns.provider.ts +9 -2
- package/src/external/aws/sns/sns.service.ts +26 -2
- package/src/external/redis/interfaces/redis.interface.ts +6 -0
- package/src/external/redis/redis.service.ts +17 -0
- package/src/index.ts +3 -42
- package/src/lib/cache/cache.ts +8 -0
- package/src/lib/cache/interfaces/cache.interface.ts +6 -0
- package/src/lib/events/types/event.type.ts +3 -0
- package/tsconfig.json +0 -1
- package/dist/lib/entraID/customError/entraID.exception.d.ts +0 -5
- package/dist/lib/entraID/customError/entraID.exception.js +0 -43
- package/dist/lib/entraID/customError/entraID.exception.js.map +0 -1
- package/dist/lib/entraID/decorators/current-user.decorator.d.ts +0 -1
- package/dist/lib/entraID/decorators/current-user.decorator.js +0 -9
- package/dist/lib/entraID/decorators/current-user.decorator.js.map +0 -1
- package/dist/lib/entraID/decorators/public.decorator.d.ts +0 -2
- package/dist/lib/entraID/decorators/public.decorator.js +0 -8
- package/dist/lib/entraID/decorators/public.decorator.js.map +0 -1
- package/dist/lib/entraID/decorators/roles.decorator.d.ts +0 -2
- package/dist/lib/entraID/decorators/roles.decorator.js +0 -8
- package/dist/lib/entraID/decorators/roles.decorator.js.map +0 -1
- package/dist/lib/entraID/entraID.constants.d.ts +0 -2
- package/dist/lib/entraID/entraID.constants.js +0 -6
- package/dist/lib/entraID/entraID.constants.js.map +0 -1
- package/dist/lib/entraID/entraID.module.d.ts +0 -14
- package/dist/lib/entraID/entraID.module.js +0 -56
- package/dist/lib/entraID/entraID.module.js.map +0 -1
- package/dist/lib/entraID/entraID.service.d.ts +0 -25
- package/dist/lib/entraID/entraID.service.js +0 -166
- package/dist/lib/entraID/entraID.service.js.map +0 -1
- package/dist/lib/entraID/guards/entra-auth.guard.d.ts +0 -21
- package/dist/lib/entraID/guards/entra-auth.guard.js +0 -70
- package/dist/lib/entraID/guards/entra-auth.guard.js.map +0 -1
- package/dist/lib/entraID/guards/roles.guard.d.ts +0 -7
- package/dist/lib/entraID/guards/roles.guard.js +0 -41
- package/dist/lib/entraID/guards/roles.guard.js.map +0 -1
- package/dist/lib/entraID/interfaces/entraID-service.interface.d.ts +0 -7
- package/dist/lib/entraID/interfaces/entraID-service.interface.js +0 -3
- package/dist/lib/entraID/interfaces/entraID-service.interface.js.map +0 -1
- package/dist/lib/entraID/internal-token/internal-token.module.d.ts +0 -2
- package/dist/lib/entraID/internal-token/internal-token.module.js +0 -21
- package/dist/lib/entraID/internal-token/internal-token.module.js.map +0 -1
- package/dist/lib/entraID/internal-token/internal-token.service.d.ts +0 -10
- package/dist/lib/entraID/internal-token/internal-token.service.js +0 -76
- package/dist/lib/entraID/internal-token/internal-token.service.js.map +0 -1
- package/dist/lib/entraID/microsoft/microsoft.module.d.ts +0 -2
- package/dist/lib/entraID/microsoft/microsoft.module.js +0 -21
- package/dist/lib/entraID/microsoft/microsoft.module.js.map +0 -1
- package/dist/lib/entraID/microsoft/microsoft.service.d.ts +0 -14
- package/dist/lib/entraID/microsoft/microsoft.service.js +0 -132
- package/dist/lib/entraID/microsoft/microsoft.service.js.map +0 -1
- package/dist/lib/entraID/security/security.module.d.ts +0 -2
- package/dist/lib/entraID/security/security.module.js +0 -21
- package/dist/lib/entraID/security/security.module.js.map +0 -1
- package/dist/lib/entraID/security/security.service.d.ts +0 -9
- package/dist/lib/entraID/security/security.service.js +0 -65
- package/dist/lib/entraID/security/security.service.js.map +0 -1
- package/dist/lib/entraID/types/entraID-module-init.types.d.ts +0 -18
- package/dist/lib/entraID/types/entraID-module-init.types.js +0 -3
- package/dist/lib/entraID/types/entraID-module-init.types.js.map +0 -1
- package/dist/lib/entraID/types/entraID.type.d.ts +0 -52
- package/dist/lib/entraID/types/entraID.type.js +0 -3
- package/dist/lib/entraID/types/entraID.type.js.map +0 -1
- package/dist/lib/entraID/utils/cookie.utils.d.ts +0 -7
- package/dist/lib/entraID/utils/cookie.utils.js +0 -42
- package/dist/lib/entraID/utils/cookie.utils.js.map +0 -1
- package/dist/lib/entraID/utils/crypto.utils.d.ts +0 -9
- package/dist/lib/entraID/utils/crypto.utils.js +0 -47
- package/dist/lib/entraID/utils/crypto.utils.js.map +0 -1
- package/dist/lib/entraID/utils/index.d.ts +0 -2
- package/dist/lib/entraID/utils/index.js +0 -8
- package/dist/lib/entraID/utils/index.js.map +0 -1
- package/dist/lib/entraID/utils/token.utils.d.ts +0 -6
- package/dist/lib/entraID/utils/token.utils.js +0 -24
- package/dist/lib/entraID/utils/token.utils.js.map +0 -1
- package/src/lib/entraID/customError/entraID.exception.ts +0 -43
- package/src/lib/entraID/decorators/current-user.decorator.ts +0 -8
- package/src/lib/entraID/decorators/public.decorator.ts +0 -5
- package/src/lib/entraID/decorators/roles.decorator.ts +0 -5
- package/src/lib/entraID/entraID.constants.ts +0 -2
- package/src/lib/entraID/entraID.module.ts +0 -78
- package/src/lib/entraID/entraID.service.ts +0 -206
- package/src/lib/entraID/guards/entra-auth.guard.ts +0 -77
- package/src/lib/entraID/guards/roles.guard.ts +0 -34
- package/src/lib/entraID/interfaces/entraID-service.interface.ts +0 -12
- package/src/lib/entraID/internal-token/internal-token.module.ts +0 -8
- package/src/lib/entraID/internal-token/internal-token.service.ts +0 -66
- package/src/lib/entraID/microsoft/microsoft.module.ts +0 -8
- package/src/lib/entraID/microsoft/microsoft.service.ts +0 -158
- package/src/lib/entraID/security/security.module.ts +0 -8
- package/src/lib/entraID/security/security.service.ts +0 -68
- package/src/lib/entraID/types/entraID-module-init.types.ts +0 -25
- package/src/lib/entraID/types/entraID.type.ts +0 -57
- package/src/lib/entraID/utils/cookie.utils.ts +0 -50
- package/src/lib/entraID/utils/crypto.utils.ts +0 -53
- package/src/lib/entraID/utils/index.ts +0 -2
- package/src/lib/entraID/utils/token.utils.ts +0 -20
package/.eslintrc.js
CHANGED
|
@@ -21,9 +21,5 @@ module.exports = {
|
|
|
21
21
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
22
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
23
23
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
24
|
-
'@typescript-eslint/no-unused-vars': [
|
|
25
|
-
'error',
|
|
26
|
-
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
27
|
-
],
|
|
28
24
|
},
|
|
29
25
|
};
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/README.md
CHANGED
|
@@ -270,310 +270,3 @@ export class AppService {
|
|
|
270
270
|
#### Next steps
|
|
271
271
|
|
|
272
272
|
- Interface for Class to facilite test
|
|
273
|
-
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
### EntraID (Microsoft Entra ID / Azure AD)
|
|
277
|
-
|
|
278
|
-
Módulo de autenticação SSO com Microsoft Entra ID via OAuth 2.0 + OIDC. Emite um JWT interno após validar o token do Azure, evitando expor o `access_token` da Microsoft para o frontend.
|
|
279
|
-
|
|
280
|
-
#### Pré-requisitos no Azure
|
|
281
|
-
|
|
282
|
-
No [Portal Azure](https://portal.azure.com), crie um **App Registration** e configure:
|
|
283
|
-
|
|
284
|
-
| Campo | Valor |
|
|
285
|
-
|---|---|
|
|
286
|
-
| Redirect URI | `https://seu-dominio.com/auth/sso/callback` (tipo: Web) |
|
|
287
|
-
| Client Secret | Gere em **Certificates & secrets** |
|
|
288
|
-
| API Permissions | `openid`, `profile`, `email`, `User.Read`, `User.ReadBasic.All` |
|
|
289
|
-
|
|
290
|
-
Anote o **Tenant ID**, **Client ID** e **Client Secret**.
|
|
291
|
-
|
|
292
|
-
#### Variáveis de ambiente
|
|
293
|
-
|
|
294
|
-
```env
|
|
295
|
-
TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
296
|
-
CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
297
|
-
CLIENT_SECRET=sua-secret-aqui
|
|
298
|
-
REDIRECT_URI=http://localhost:3000/auth/sso/callback
|
|
299
|
-
STATE_SECRET=string-aleatoria-32-chars
|
|
300
|
-
JWT_SECRET=string-aleatoria-32-chars
|
|
301
|
-
JWT_EXPIRES_IN=8h
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
#### 1. Registrar o módulo
|
|
305
|
-
|
|
306
|
-
```typescript
|
|
307
|
-
import { EntraIDModule } from 'prime-sdk';
|
|
308
|
-
|
|
309
|
-
@Module({
|
|
310
|
-
imports: [
|
|
311
|
-
EntraIDModule.forRoot({
|
|
312
|
-
tenantID: process.env.TENANT_ID!,
|
|
313
|
-
clientID: process.env.CLIENT_ID!,
|
|
314
|
-
clientSecret: process.env.CLIENT_SECRET!,
|
|
315
|
-
stateSecret: process.env.STATE_SECRET!,
|
|
316
|
-
redirectUri: process.env.REDIRECT_URI!,
|
|
317
|
-
jwtSecret: process.env.JWT_SECRET!,
|
|
318
|
-
jwtExpiresIn: process.env.JWT_EXPIRES_IN ?? '8h',
|
|
319
|
-
}),
|
|
320
|
-
],
|
|
321
|
-
})
|
|
322
|
-
export class AppModule {}
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
Com factory assíncrona (ex: usando `ConfigService`):
|
|
326
|
-
|
|
327
|
-
```typescript
|
|
328
|
-
EntraIDModule.forRootAsync({
|
|
329
|
-
imports: [ConfigModule],
|
|
330
|
-
inject: [ConfigService],
|
|
331
|
-
useFactory: (config: ConfigService) => ({
|
|
332
|
-
tenantID: config.get('TENANT_ID')!,
|
|
333
|
-
clientID: config.get('CLIENT_ID')!,
|
|
334
|
-
clientSecret: config.get('CLIENT_SECRET')!,
|
|
335
|
-
stateSecret: config.get('STATE_SECRET')!,
|
|
336
|
-
redirectUri: config.get('REDIRECT_URI')!,
|
|
337
|
-
jwtSecret: config.get('JWT_SECRET')!,
|
|
338
|
-
}),
|
|
339
|
-
}),
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
O módulo é registrado como **global** — não é necessário importá-lo em outros módulos.
|
|
343
|
-
|
|
344
|
-
#### 2. Implementar o controller de autenticação
|
|
345
|
-
|
|
346
|
-
```typescript
|
|
347
|
-
// auth.controller.ts
|
|
348
|
-
import { Controller, Get, Post, Body, Res, HttpCode, Redirect } from '@nestjs/common';
|
|
349
|
-
import { Response } from 'express';
|
|
350
|
-
import { EntraIDService, CallbackParams, CookieUtils } from 'prime-sdk';
|
|
351
|
-
|
|
352
|
-
@Controller('auth')
|
|
353
|
-
export class AuthController {
|
|
354
|
-
constructor(private readonly entraService: EntraIDService) {}
|
|
355
|
-
|
|
356
|
-
@Get('login')
|
|
357
|
-
@Redirect()
|
|
358
|
-
async login() {
|
|
359
|
-
const url = await this.entraService.initiateLogin();
|
|
360
|
-
return { url };
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Passo 2: a Microsoft faz POST aqui após o login bem-sucedido
|
|
364
|
-
@Post('sso/callback')
|
|
365
|
-
@HttpCode(302)
|
|
366
|
-
@Redirect()
|
|
367
|
-
async callback(@Body() body: CallbackParams, @Res({ passthrough: true }) res: Response) {
|
|
368
|
-
const { token, user, refreshToken } = await this.entraService.handleCallback(body);
|
|
369
|
-
|
|
370
|
-
CookieUtils.setAuthCookie(res, token); // cookie httpOnly com o JWT
|
|
371
|
-
CookieUtils.setUserDataCookie(res, user);
|
|
372
|
-
if (refreshToken) {
|
|
373
|
-
res.cookie('refresh_token', refreshToken, { httpOnly: true, path: '/' });
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
return { url: 'http://localhost:9000/dashboard' };
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// Renovar o JWT usando o refresh token
|
|
380
|
-
@Post('refresh')
|
|
381
|
-
@HttpCode(200)
|
|
382
|
-
async refresh(@Req() req: Request, @Res({ passthrough: true }) res: Response) {
|
|
383
|
-
const refreshToken = req.cookies?.refresh_token;
|
|
384
|
-
const { token, user } = await this.entraService.refresh(refreshToken);
|
|
385
|
-
|
|
386
|
-
CookieUtils.setAuthCookie(res, token);
|
|
387
|
-
CookieUtils.setUserDataCookie(res, user);
|
|
388
|
-
return { user };
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// Logout: revoga sessões no Azure e limpa cookies
|
|
392
|
-
@Post('logout')
|
|
393
|
-
@HttpCode(200)
|
|
394
|
-
async logout(@Req() req: Request, @Res({ passthrough: true }) res: Response) {
|
|
395
|
-
const token = req.cookies?.auth_token;
|
|
396
|
-
if (token) {
|
|
397
|
-
try {
|
|
398
|
-
const user = this.entraService.decodeLocalToken(token);
|
|
399
|
-
await this.entraService.logout(user.id);
|
|
400
|
-
} catch {}
|
|
401
|
-
}
|
|
402
|
-
CookieUtils.clearAuthCookies(res);
|
|
403
|
-
return { message: 'Logout realizado com sucesso' };
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
#### 3. Proteger rotas com `@UseGuards(EntraAuthGuard)`
|
|
409
|
-
|
|
410
|
-
```typescript
|
|
411
|
-
// profile.controller.ts
|
|
412
|
-
import { Controller, Get, UseGuards } from '@nestjs/common';
|
|
413
|
-
import { EntraAuthGuard, CurrentUser, EntraUser } from 'prime-sdk';
|
|
414
|
-
|
|
415
|
-
@Controller('profile')
|
|
416
|
-
@UseGuards(EntraAuthGuard) // protege todos os endpoints da classe
|
|
417
|
-
export class ProfileController {
|
|
418
|
-
|
|
419
|
-
@Get()
|
|
420
|
-
getProfile(@CurrentUser() user: EntraUser) {
|
|
421
|
-
return { user };
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
O `EntraAuthGuard` aceita o token via:
|
|
427
|
-
- Header `Authorization: Bearer <token>`
|
|
428
|
-
- Cookie `auth_token` (httpOnly)
|
|
429
|
-
|
|
430
|
-
#### 4. Controlar acesso por grupos do Azure AD com `@Roles()` e `RolesGuard`
|
|
431
|
-
|
|
432
|
-
As permissões vêm dos **grupos do Azure AD** aos quais o usuário pertence. Esses grupos são buscados automaticamente pelo SDK via Graph API e incluídos no JWT como `groups[]`. Não é necessário consultar banco de dados para autorização.
|
|
433
|
-
|
|
434
|
-
```typescript
|
|
435
|
-
import { Controller, Get, UseGuards } from '@nestjs/common';
|
|
436
|
-
import { EntraAuthGuard, CurrentUser, EntraUser, RolesGuard, Roles } from 'prime-sdk';
|
|
437
|
-
|
|
438
|
-
@Controller('pedidos')
|
|
439
|
-
@UseGuards(EntraAuthGuard)
|
|
440
|
-
export class PedidosController {
|
|
441
|
-
|
|
442
|
-
@Get()
|
|
443
|
-
listar(@CurrentUser() user: EntraUser) {
|
|
444
|
-
return { pedidos: [] };
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
@Get('aprovar')
|
|
448
|
-
@UseGuards(RolesGuard)
|
|
449
|
-
@Roles('portal-promo-dpsp-comercial-hml', 'portal-promo-dpsp-price-hml')
|
|
450
|
-
aprovar(@CurrentUser() user: EntraUser) {
|
|
451
|
-
// só chega aqui se user.groups[] contiver ao menos um dos grupos acima
|
|
452
|
-
return { aprovado: true };
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
O `RolesGuard` verifica se `user.groups[].displayName` contém **ao menos um** dos grupos declarados em `@Roles()`. Se nenhum grupo bater, retorna **403** com a mensagem indicando quais grupos são necessários.
|
|
458
|
-
|
|
459
|
-
> Os grupos são gerenciados exclusivamente pelo administrador do Azure AD — sem nenhuma alteração no código da aplicação.
|
|
460
|
-
|
|
461
|
-
#### 5. Liberar rotas com `@Public()`
|
|
462
|
-
|
|
463
|
-
Use `@Public()` em um método para que o guard **ignore a autenticação** naquele endpoint específico, mesmo que o controller inteiro seja protegido:
|
|
464
|
-
|
|
465
|
-
```typescript
|
|
466
|
-
import { Controller, Get, UseGuards } from '@nestjs/common';
|
|
467
|
-
import { EntraAuthGuard, Public } from 'prime-sdk';
|
|
468
|
-
|
|
469
|
-
@Controller('info')
|
|
470
|
-
@UseGuards(EntraAuthGuard)
|
|
471
|
-
export class InfoController {
|
|
472
|
-
|
|
473
|
-
@Get('status')
|
|
474
|
-
@Public() // acessível sem token
|
|
475
|
-
getStatus() {
|
|
476
|
-
return { status: 'online', timestamp: new Date().toISOString() };
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
@Get('me') // ainda requer autenticação
|
|
480
|
-
getMe(@CurrentUser() user: EntraUser) {
|
|
481
|
-
return { user };
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
#### 5. Enriquecer o JWT com dados da aplicação
|
|
487
|
-
|
|
488
|
-
Por padrão o JWT contém: `id`, `email`, `name`, `tenantId`, `matricula` e `groups`.
|
|
489
|
-
|
|
490
|
-
Para adicionar campos extras (ex: dados do banco de dados consultados pelo email), estenda o `InternalTokenService` e sobrescreva `enrichTokenPayload`:
|
|
491
|
-
|
|
492
|
-
```typescript
|
|
493
|
-
// custom-token.service.ts
|
|
494
|
-
import { Injectable } from '@nestjs/common';
|
|
495
|
-
import { InternalTokenService, TokenEnrichmentContext } from 'prime-sdk';
|
|
496
|
-
|
|
497
|
-
@Injectable()
|
|
498
|
-
export class CustomTokenService extends InternalTokenService {
|
|
499
|
-
protected override async enrichTokenPayload(
|
|
500
|
-
context: TokenEnrichmentContext,
|
|
501
|
-
): Promise<Record<string, unknown>> {
|
|
502
|
-
// context.user → dados base do usuário (EntraUser)
|
|
503
|
-
// context.accessToken → token da Microsoft (para chamadas ao Graph API)
|
|
504
|
-
|
|
505
|
-
// Exemplo: lookup no banco usando o email como chave
|
|
506
|
-
const profile = await this.userRepository.findByEmail(context.user.email);
|
|
507
|
-
|
|
508
|
-
return {
|
|
509
|
-
role: profile?.role ?? 'USER',
|
|
510
|
-
cargo: profile?.cargo,
|
|
511
|
-
departamento: profile?.departamento,
|
|
512
|
-
permissoes: profile?.permissoes ?? [],
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
Registre o serviço customizado na opção `internalTokenService` do `forRoot`:
|
|
519
|
-
|
|
520
|
-
```typescript
|
|
521
|
-
EntraIDModule.forRoot(
|
|
522
|
-
{
|
|
523
|
-
tenantID: process.env.TENANT_ID!,
|
|
524
|
-
// ... demais configurações
|
|
525
|
-
},
|
|
526
|
-
{ internalTokenService: CustomTokenService }, // <-- aqui
|
|
527
|
-
),
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
> **Atenção:** `enrichTokenPayload` não pode retornar claims reservados do JWT (`sub`, `iss`, `aud`, `exp`, `iat`, `nbf`, `jti`). O SDK lança `RESERVED_CLAIM_OVERRIDE` caso isso ocorra.
|
|
531
|
-
|
|
532
|
-
#### 6. Tipar o usuário enriquecido
|
|
533
|
-
|
|
534
|
-
Como `EntraUser` usa `& Record<string, unknown>` para os campos extras, crie uma interface própria para ter tipagem completa no seu projeto:
|
|
535
|
-
|
|
536
|
-
```typescript
|
|
537
|
-
// types/app-user.types.ts
|
|
538
|
-
export interface AppUser {
|
|
539
|
-
id: string;
|
|
540
|
-
email: string;
|
|
541
|
-
name: string;
|
|
542
|
-
tenantId: string;
|
|
543
|
-
matricula?: string | null;
|
|
544
|
-
groups: { displayName: string }[];
|
|
545
|
-
// campos adicionados pelo CustomTokenService
|
|
546
|
-
role: 'ADMIN' | 'USER';
|
|
547
|
-
cargo: string;
|
|
548
|
-
departamento: string;
|
|
549
|
-
permissoes: string[];
|
|
550
|
-
}
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
```typescript
|
|
554
|
-
@Get('profile')
|
|
555
|
-
getProfile(@CurrentUser() user: AppUser) {
|
|
556
|
-
return user;
|
|
557
|
-
}
|
|
558
|
-
```
|
|
559
|
-
|
|
560
|
-
#### 7. Referência das exportações
|
|
561
|
-
|
|
562
|
-
| Exportação | Tipo | Descrição |
|
|
563
|
-
|---|---|---|
|
|
564
|
-
| `EntraIDModule` | Module | Módulo principal — use `forRoot()` ou `forRootAsync()` |
|
|
565
|
-
| `EntraIDService` | Service | `initiateLogin()`, `handleCallback()`, `refresh()`, `logout()`, `decodeLocalToken()` |
|
|
566
|
-
| `EntraAuthGuard` | Guard | Valida o JWT no header ou cookie |
|
|
567
|
-
| `RolesGuard` | Guard | Verifica se `user.groups[]` contém os grupos exigidos por `@Roles()` |
|
|
568
|
-
| `InternalTokenService` | Service | Estenda para enriquecer o JWT via `enrichTokenPayload()` |
|
|
569
|
-
| `CurrentUser` | Decorator | Injeta o usuário autenticado no parâmetro do método |
|
|
570
|
-
| `Public` | Decorator | Marca um endpoint como público, ignorado pelo `EntraAuthGuard` |
|
|
571
|
-
| `Roles` | Decorator | Define os grupos do Azure AD exigidos pelo `RolesGuard` |
|
|
572
|
-
| `CookieUtils` | Class | `setAuthCookie()`, `setUserDataCookie()`, `clearAuthCookies()` |
|
|
573
|
-
| `TokenUtils` | Class | `extractFromRequest()`, `extractUserDataFromCookie()` |
|
|
574
|
-
| `EntraIDException` | Error | Erros tipados do SDK — acesse o código via `.code` |
|
|
575
|
-
| `EntraUser` | Type | Tipo base do usuário no JWT |
|
|
576
|
-
| `EntraIDSetup` | Type | Configuração do `forRoot()` |
|
|
577
|
-
| `TokenEnrichmentContext` | Type | Parâmetro de `enrichTokenPayload()` |
|
|
578
|
-
| `CallbackParams` | Type | Body do callback OAuth (`code`, `state`, `error`) |
|
|
579
|
-
| `AuthResult` | Type | Retorno de `handleCallback()` e `refresh()` |
|
|
@@ -24,8 +24,14 @@ class SNSModule {
|
|
|
24
24
|
const snsProvider = SNSProvider(params);
|
|
25
25
|
return {
|
|
26
26
|
module: SNSModule,
|
|
27
|
-
providers: [
|
|
28
|
-
|
|
27
|
+
providers: [
|
|
28
|
+
snsProvider,
|
|
29
|
+
{
|
|
30
|
+
provide: 'SNS_OPTIONS',
|
|
31
|
+
useValue: params,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
exports: [snsProvider, 'SNS_OPTIONS'],
|
|
29
35
|
};
|
|
30
36
|
}
|
|
31
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sns.provider.js","sourceRoot":"","sources":["../../../../src/external/aws/sns/sns.provider.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,iEAA4D;AAE5D,iCAA4C;
|
|
1
|
+
{"version":3,"file":"sns.provider.js","sourceRoot":"","sources":["../../../../src/external/aws/sns/sns.provider.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,iEAA4D;AAE5D,iCAA4C;AAc5C,MAAM,WAAW,GAAG,CAAC,MAAgB,EAAE,EAAE;IACvC,OAAO;QACL,OAAO,EAAE,gBAAgB;QACzB,UAAU,EAAE,GAAG,EAAE;YACf,OAAO,IAAI,sBAAS,CAAC;gBACnB,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrD,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,cAAc,EAAE,IAAI,mCAAe,CAAC;oBAClC,UAAU,EAAE,IAAI,aAAU,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;iBACpE,CAAC;aACH,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAa,SAAS;IACpB,MAAM,CAAC,OAAO,CAAC,MAAgB;QAC7B,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAExC,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE;gBACT,WAAW;gBACX;oBACE,OAAO,EAAE,aAAa;oBACtB,QAAQ,EAAE,MAAM;iBACjB;aACF;YACD,OAAO,EAAE,CAAC,WAAW,EAAE,aAAa,CAAC;SACtC,CAAC;IACJ,CAAC;CACF;AAhBD,8BAgBC"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { PublishCommandOutput, SNSClient } from '@aws-sdk/client-sns';
|
|
2
2
|
import { IEvent } from 'src/lib/events/interfaces/event.interface';
|
|
3
3
|
import { EventData, EventSmsData } from 'src/lib/events/types/event.type';
|
|
4
|
+
import { SNSSetup } from './sns.provider';
|
|
4
5
|
export declare class Sns implements IEvent {
|
|
5
6
|
private readonly client;
|
|
6
|
-
|
|
7
|
+
private readonly options?;
|
|
8
|
+
constructor(client: SNSClient, options?: SNSSetup);
|
|
7
9
|
publishSns(event: EventData): Promise<PublishCommandOutput>;
|
|
10
|
+
private getMessageAttributes;
|
|
8
11
|
publishSms(event: EventSmsData): Promise<PublishCommandOutput>;
|
|
9
12
|
}
|
|
@@ -16,16 +16,33 @@ exports.Sns = void 0;
|
|
|
16
16
|
const client_sns_1 = require("@aws-sdk/client-sns");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
let Sns = class Sns {
|
|
19
|
-
constructor(client) {
|
|
19
|
+
constructor(client, options) {
|
|
20
20
|
this.client = client;
|
|
21
|
+
this.options = options;
|
|
21
22
|
}
|
|
22
23
|
async publishSns(event) {
|
|
24
|
+
const messageAttributes = this.getMessageAttributes(event);
|
|
23
25
|
const command = new client_sns_1.PublishCommand({
|
|
24
26
|
TopicArn: event.topic,
|
|
25
27
|
Message: event.message,
|
|
28
|
+
...(messageAttributes && { MessageAttributes: messageAttributes }),
|
|
26
29
|
});
|
|
27
30
|
return await this.client.send(command);
|
|
28
31
|
}
|
|
32
|
+
getMessageAttributes(event) {
|
|
33
|
+
if (event.messageAttributes) {
|
|
34
|
+
return event.messageAttributes;
|
|
35
|
+
}
|
|
36
|
+
if (this.options?.messageAttributes) {
|
|
37
|
+
return {
|
|
38
|
+
enqueuedAt: {
|
|
39
|
+
DataType: 'Number',
|
|
40
|
+
StringValue: String(Date.now()),
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
29
46
|
async publishSms(event) {
|
|
30
47
|
const command = new client_sns_1.PublishCommand({
|
|
31
48
|
PhoneNumber: event.phoneNumber,
|
|
@@ -38,6 +55,8 @@ exports.Sns = Sns;
|
|
|
38
55
|
exports.Sns = Sns = __decorate([
|
|
39
56
|
(0, common_1.Injectable)(),
|
|
40
57
|
__param(0, (0, common_1.Inject)('CONNECTION_SNS')),
|
|
41
|
-
|
|
58
|
+
__param(1, (0, common_1.Optional)()),
|
|
59
|
+
__param(1, (0, common_1.Inject)('SNS_OPTIONS')),
|
|
60
|
+
__metadata("design:paramtypes", [client_sns_1.SNSClient, Object])
|
|
42
61
|
], Sns);
|
|
43
62
|
//# sourceMappingURL=sns.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sns.service.js","sourceRoot":"","sources":["../../../../src/external/aws/sns/sns.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAI6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"sns.service.js","sourceRoot":"","sources":["../../../../src/external/aws/sns/sns.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAI6B;AAC7B,2CAA8D;AAMvD,IAAM,GAAG,GAAT,MAAM,GAAG;IACd,YAC6C,MAAiB,EACR,OAAkB;QAD3B,WAAM,GAAN,MAAM,CAAW;QACR,YAAO,GAAP,OAAO,CAAW;IACrE,CAAC;IAEJ,KAAK,CAAC,UAAU,CAAC,KAAgB;QAC/B,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAE3D,MAAM,OAAO,GAAG,IAAI,2BAAc,CAAC;YACjC,QAAQ,EAAE,KAAK,CAAC,KAAK;YACrB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,GAAG,CAAC,iBAAiB,IAAI,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC;SACnE,CAAC,CAAC;QAEH,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,oBAAoB,CAAC,KAAgB;QAC3C,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,iBAAiB,CAAC;QACjC,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,iBAAiB,EAAE,CAAC;YACpC,OAAO;gBACL,UAAU,EAAE;oBACV,QAAQ,EAAE,QAAQ;oBAClB,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;iBAChC;aACF,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAmB;QAClC,MAAM,OAAO,GAAG,IAAI,2BAAc,CAAC;YACjC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;QAEH,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AA3CY,kBAAG;cAAH,GAAG;IADf,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;qCADiB,sBAAS;GAFnD,GAAG,CA2Cf"}
|
|
@@ -5,5 +5,6 @@ export interface IRedisService {
|
|
|
5
5
|
getRedisKey(key: string): Promise<string>;
|
|
6
6
|
deleteRedisKey(key: string): Promise<void>;
|
|
7
7
|
createPubSubClient(): Promise<PubSubRedis>;
|
|
8
|
+
setRedisKeyIfNotExists(key: string, value: Date | number | Buffer | string, ttl?: number): Promise<boolean>;
|
|
8
9
|
}
|
|
9
10
|
export declare const IRedisService: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.interface.js","sourceRoot":"","sources":["../../../../src/external/redis/interfaces/redis.interface.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"redis.interface.js","sourceRoot":"","sources":["../../../../src/external/redis/interfaces/redis.interface.ts"],"names":[],"mappings":";;;AAsBa,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -9,4 +9,5 @@ export declare class RedisService implements IRedisService {
|
|
|
9
9
|
getRedisKey(key: string): Promise<string>;
|
|
10
10
|
deleteRedisKey(key: string): Promise<void>;
|
|
11
11
|
createPubSubClient(): Promise<PubSubRedis>;
|
|
12
|
+
setRedisKeyIfNotExists(key: string, value: Date | number | Buffer | string, ttl?: number): Promise<boolean>;
|
|
12
13
|
}
|
|
@@ -41,6 +41,19 @@ let RedisService = class RedisService {
|
|
|
41
41
|
sub: this.client.duplicate(),
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
+
async setRedisKeyIfNotExists(key, value, ttl) {
|
|
45
|
+
if (value instanceof Date) {
|
|
46
|
+
value = value.toISOString();
|
|
47
|
+
}
|
|
48
|
+
let result;
|
|
49
|
+
if (ttl) {
|
|
50
|
+
result = await this.client.set(key, value, 'EX', ttl, 'NX');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
result = await this.client.set(key, value, 'NX');
|
|
54
|
+
}
|
|
55
|
+
return result === 'OK';
|
|
56
|
+
}
|
|
44
57
|
};
|
|
45
58
|
exports.RedisService = RedisService;
|
|
46
59
|
exports.RedisService = RedisService = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../../src/external/redis/redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAM7C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAC+C,MAAuB;QAAvB,WAAM,GAAN,MAAM,CAAiB;IACnE,CAAC;IAEJ,KAAK,CAAC,WAAW,CACf,GAAW,EACX,KAAsC,EACtC,GAAY;QAEZ,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;YAC1B,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,GAAW;QAC9B,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,MAAM;YAChB,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;SAC7B,CAAC;IACJ,CAAC;CACF,CAAA;
|
|
1
|
+
{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../../src/external/redis/redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAM7C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAC+C,MAAuB;QAAvB,WAAM,GAAN,MAAM,CAAiB;IACnE,CAAC;IAEJ,KAAK,CAAC,WAAW,CACf,GAAW,EACX,KAAsC,EACtC,GAAY;QAEZ,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;YAC1B,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,GAAW;QAC9B,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,MAAM;YAChB,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;SAC7B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,GAAW,EACX,KAAsC,EACtC,GAAY;QAEZ,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;YAC1B,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,MAAc,CAAC;QACnB,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,MAAM,KAAK,IAAI,CAAC;IACzB,CAAC;CACF,CAAA;AAlDY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;;GAFlB,YAAY,CAkDxB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,18 +20,5 @@ import { DocumentsModule } from './lib/documents/documents.module';
|
|
|
20
20
|
import { Documents } from './lib/documents/documents';
|
|
21
21
|
import { IBedrock, ITextract } from './lib/documents/interfaces/documents.interface';
|
|
22
22
|
import { SimpleRedisSetup, ClusterRedisSetup, TypeRedis, PubSubRedis } from './external/redis/types/ioredis.types';
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
import { EntraIDService } from './lib/entraID/entraID.service';
|
|
26
|
-
import { EntraAuthGuard } from './lib/entraID/guards/entra-auth.guard';
|
|
27
|
-
import { RolesGuard } from './lib/entraID/guards/roles.guard';
|
|
28
|
-
import { InternalTokenService } from './lib/entraID/internal-token/internal-token.service';
|
|
29
|
-
import { CurrentUser } from './lib/entraID/decorators/current-user.decorator';
|
|
30
|
-
import { Public } from './lib/entraID/decorators/public.decorator';
|
|
31
|
-
import { Roles } from './lib/entraID/decorators/roles.decorator';
|
|
32
|
-
import { CookieUtils, TokenUtils } from './lib/entraID/utils';
|
|
33
|
-
import { SecurityService } from './lib/entraID/security/security.service';
|
|
34
|
-
import { EntraIDException } from './lib/entraID/customError/entraID.exception';
|
|
35
|
-
import type { EntraUser, AuthResult, CallbackParams, TokenEnrichmentContext } from './lib/entraID/types/entraID.type';
|
|
36
|
-
import type { EntraIDSetup, EntraIDAsyncOptions } from './lib/entraID/types/entraID-module-init.types';
|
|
37
|
-
export { QueueModule, Queue, IConsumer, StorageModule, Storage, IStorage, EventModule, Events, IEvent, EmailModule, Email, IEmail, CryptoModule, Crypto, ICrypto, CacheModule, Cache, ICache, DocumentsModule, Documents, IBedrock, ITextract, SimpleRedisSetup, ClusterRedisSetup, TypeRedis, PubSubRedis, EntraIDModule, EntraIDModuleOptions, ENTRA_ID_CONFIG, EntraIDService, EntraAuthGuard, RolesGuard, InternalTokenService, CurrentUser, Public, Roles, CookieUtils, TokenUtils, SecurityService, EntraIDException, EntraIDSetup, EntraIDAsyncOptions, EntraUser, AuthResult, CallbackParams, TokenEnrichmentContext, };
|
|
23
|
+
import { SNSSetup } from './external/aws/sns/sns.provider';
|
|
24
|
+
export { QueueModule, Queue, IConsumer, StorageModule, Storage, IStorage, EventModule, Events, IEvent, SNSSetup, EmailModule, Email, IEmail, CryptoModule, Crypto, ICrypto, CacheModule, Cache, ICache, DocumentsModule, Documents, IBedrock, ITextract, SimpleRedisSetup, ClusterRedisSetup, TypeRedis, PubSubRedis, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TypeRedis = exports.ITextract = exports.IBedrock = exports.Documents = exports.DocumentsModule = exports.ICache = exports.Cache = exports.CacheModule = exports.ICrypto = exports.Crypto = exports.CryptoModule = exports.IEmail = exports.Email = exports.EmailModule = exports.IEvent = exports.Events = exports.EventModule = exports.IStorage = exports.Storage = exports.StorageModule = exports.IConsumer = exports.Queue = exports.QueueModule = void 0;
|
|
4
4
|
const queue_module_1 = require("./lib/queue/queue.module");
|
|
5
5
|
Object.defineProperty(exports, "QueueModule", { enumerable: true, get: function () { return queue_module_1.QueueModule; } });
|
|
6
6
|
const queue_1 = require("./lib/queue/queue");
|
|
@@ -46,28 +46,4 @@ Object.defineProperty(exports, "IBedrock", { enumerable: true, get: function ()
|
|
|
46
46
|
Object.defineProperty(exports, "ITextract", { enumerable: true, get: function () { return documents_interface_1.ITextract; } });
|
|
47
47
|
const ioredis_types_1 = require("./external/redis/types/ioredis.types");
|
|
48
48
|
Object.defineProperty(exports, "TypeRedis", { enumerable: true, get: function () { return ioredis_types_1.TypeRedis; } });
|
|
49
|
-
const entraID_module_1 = require("./lib/entraID/entraID.module");
|
|
50
|
-
Object.defineProperty(exports, "EntraIDModule", { enumerable: true, get: function () { return entraID_module_1.EntraIDModule; } });
|
|
51
|
-
Object.defineProperty(exports, "ENTRA_ID_CONFIG", { enumerable: true, get: function () { return entraID_module_1.ENTRA_ID_CONFIG; } });
|
|
52
|
-
const entraID_service_1 = require("./lib/entraID/entraID.service");
|
|
53
|
-
Object.defineProperty(exports, "EntraIDService", { enumerable: true, get: function () { return entraID_service_1.EntraIDService; } });
|
|
54
|
-
const entra_auth_guard_1 = require("./lib/entraID/guards/entra-auth.guard");
|
|
55
|
-
Object.defineProperty(exports, "EntraAuthGuard", { enumerable: true, get: function () { return entra_auth_guard_1.EntraAuthGuard; } });
|
|
56
|
-
const roles_guard_1 = require("./lib/entraID/guards/roles.guard");
|
|
57
|
-
Object.defineProperty(exports, "RolesGuard", { enumerable: true, get: function () { return roles_guard_1.RolesGuard; } });
|
|
58
|
-
const internal_token_service_1 = require("./lib/entraID/internal-token/internal-token.service");
|
|
59
|
-
Object.defineProperty(exports, "InternalTokenService", { enumerable: true, get: function () { return internal_token_service_1.InternalTokenService; } });
|
|
60
|
-
const current_user_decorator_1 = require("./lib/entraID/decorators/current-user.decorator");
|
|
61
|
-
Object.defineProperty(exports, "CurrentUser", { enumerable: true, get: function () { return current_user_decorator_1.CurrentUser; } });
|
|
62
|
-
const public_decorator_1 = require("./lib/entraID/decorators/public.decorator");
|
|
63
|
-
Object.defineProperty(exports, "Public", { enumerable: true, get: function () { return public_decorator_1.Public; } });
|
|
64
|
-
const roles_decorator_1 = require("./lib/entraID/decorators/roles.decorator");
|
|
65
|
-
Object.defineProperty(exports, "Roles", { enumerable: true, get: function () { return roles_decorator_1.Roles; } });
|
|
66
|
-
const utils_1 = require("./lib/entraID/utils");
|
|
67
|
-
Object.defineProperty(exports, "CookieUtils", { enumerable: true, get: function () { return utils_1.CookieUtils; } });
|
|
68
|
-
Object.defineProperty(exports, "TokenUtils", { enumerable: true, get: function () { return utils_1.TokenUtils; } });
|
|
69
|
-
const security_service_1 = require("./lib/entraID/security/security.service");
|
|
70
|
-
Object.defineProperty(exports, "SecurityService", { enumerable: true, get: function () { return security_service_1.SecurityService; } });
|
|
71
|
-
const entraID_exception_1 = require("./lib/entraID/customError/entraID.exception");
|
|
72
|
-
Object.defineProperty(exports, "EntraIDException", { enumerable: true, get: function () { return entraID_exception_1.EntraIDException; } });
|
|
73
49
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AAuCrD,4FAvCO,0BAAW,OAuCP;AAtCb,6CAA0C;AAuCxC,sFAvCO,aAAK,OAuCP;AAtCP,kFAAsE;AAuCpE,0FAvCO,8BAAS,OAuCP;AArCX,iEAA6D;AAsC3D,8FAtCO,8BAAa,OAsCP;AArCf,mDAAgD;AAsC9C,wFAtCO,iBAAO,OAsCP;AArCT,kFAAsE;AAsCpE,yFAtCO,4BAAQ,OAsCP;AApCV,4DAAwD;AAqCtD,4FArCO,0BAAW,OAqCP;AApCb,gDAA6C;AAqC3C,uFArCO,eAAM,OAqCP;AApCR,6EAAiE;AAqC/D,uFArCO,wBAAM,OAqCP;AAnCR,2DAAuD;AAqCrD,4FArCO,0BAAW,OAqCP;AApCb,6CAA0C;AAqCxC,sFArCO,aAAK,OAqCP;AApCP,4EAAgE;AAqC9D,uFArCO,wBAAM,OAqCP;AAnCR,8DAA0D;AAoCxD,6FApCO,4BAAY,OAoCP;AAnCd,gDAA6C;AAoC3C,uFApCO,eAAM,OAoCP;AAnCR,+EAAmE;AAoCjE,wFApCO,0BAAO,OAoCP;AAlCT,2DAAuD;AAmCrD,4FAnCO,0BAAW,OAmCP;AAlCb,6CAA0C;AAmCxC,sFAnCO,aAAK,OAmCP;AAlCP,4EAAgE;AAmC9D,uFAnCO,wBAAM,OAmCP;AAlCR,uEAAmE;AAmCjE,gGAnCO,kCAAe,OAmCP;AAlCjB,yDAAsD;AAmCpD,0FAnCO,qBAAS,OAmCP;AAlCX,wFAGwD;AAgCtD,yFAlCA,8BAAQ,OAkCA;AACR,0FAlCA,+BAAS,OAkCA;AAhCX,wEAK8C;AA8B5C,0FAhCA,yBAAS,OAgCA"}
|
|
@@ -9,4 +9,5 @@ export declare class Cache implements ICache {
|
|
|
9
9
|
get(key: string): Promise<string>;
|
|
10
10
|
delete(key: string): Promise<void>;
|
|
11
11
|
createPubSubClient(): Promise<PubSubRedis>;
|
|
12
|
+
setIfNotExists(key: string, value: Date | number | Buffer | string, ttl?: number): Promise<boolean>;
|
|
12
13
|
}
|
package/dist/lib/cache/cache.js
CHANGED
|
@@ -31,6 +31,9 @@ let Cache = class Cache {
|
|
|
31
31
|
async createPubSubClient() {
|
|
32
32
|
return await this.client.createPubSubClient();
|
|
33
33
|
}
|
|
34
|
+
async setIfNotExists(key, value, ttl) {
|
|
35
|
+
return await this.client.setRedisKeyIfNotExists(key, value, ttl);
|
|
36
|
+
}
|
|
34
37
|
};
|
|
35
38
|
exports.Cache = Cache;
|
|
36
39
|
exports.Cache = Cache = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/lib/cache/cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,qFAA8E;AAIvE,IAAM,KAAK,GAAX,MAAM,KAAK;IAChB,YAAoD,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAC7E,KAAK,CAAC,GAAG,CACP,GAAW,EACX,KAAsC,EACtC,GAAY;QAEZ,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAChD,CAAC;CACF,CAAA;
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/lib/cache/cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,qFAA8E;AAIvE,IAAM,KAAK,GAAX,MAAM,KAAK;IAChB,YAAoD,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAC7E,KAAK,CAAC,GAAG,CACP,GAAW,EACX,KAAsC,EACtC,GAAY;QAEZ,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,GAAW,EACX,KAAsC,EACtC,GAAY;QAEZ,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AA5BY,sBAAK;gBAAL,KAAK;IADjB,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,+BAAa,CAAC,CAAA;;GADvB,KAAK,CA4BjB"}
|
|
@@ -5,5 +5,6 @@ export interface ICache {
|
|
|
5
5
|
get(key: string): Promise<string>;
|
|
6
6
|
delete(key: string): Promise<void>;
|
|
7
7
|
createPubSubClient(): Promise<PubSubRedis>;
|
|
8
|
+
setIfNotExists(key: string, value: Date | number | Buffer | string, ttl?: number): Promise<boolean>;
|
|
8
9
|
}
|
|
9
10
|
export declare const ICache: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.interface.js","sourceRoot":"","sources":["../../../../src/lib/cache/interfaces/cache.interface.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"cache.interface.js","sourceRoot":"","sources":["../../../../src/lib/cache/interfaces/cache.interface.ts"],"names":[],"mappings":";;;AAsBa,QAAA,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC"}
|