prime-sdk 3.0.8-beta.0 → 3.0.9
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/README.md +10 -307
- package/dist/external/aws/kms/kms.service.d.ts +2 -2
- package/dist/external/aws/s3/s3.service.d.ts +2 -0
- package/dist/external/aws/s3/s3.service.js +50 -0
- package/dist/external/aws/s3/s3.service.js.map +1 -1
- package/dist/external/aws/ses/ses.service.d.ts +2 -2
- package/dist/external/aws/sns/sns.service.d.ts +2 -2
- package/dist/external/aws/sqs/sqs.service.d.ts +1 -1
- package/dist/external/redis/interfaces/redis.interface.d.ts +0 -1
- package/dist/external/redis/redis.service.d.ts +0 -1
- package/dist/index.d.ts +1 -15
- package/dist/index.js +1 -25
- package/dist/index.js.map +1 -1
- package/dist/lib/cache/cache.d.ts +2 -3
- package/dist/lib/cache/interfaces/cache.interface.d.ts +1 -2
- package/dist/lib/crypto/crypto.module.d.ts +1 -1
- package/dist/lib/crypto/types/crypto.type.d.ts +0 -1
- package/dist/lib/documents/types/bedrock.type.d.ts +0 -1
- package/dist/lib/email/email.module.d.ts +1 -1
- package/dist/lib/storage/interfaces/storage.interface.d.ts +1 -0
- package/dist/lib/storage/interfaces/storage.interface.js.map +1 -1
- package/dist/lib/storage/storage.d.ts +1 -1
- package/dist/lib/storage/storage.js +3 -0
- package/dist/lib/storage/storage.js.map +1 -1
- package/dist/lib/storage/types/storage.type.d.ts +1 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -4
- package/src/external/aws/s3/s3.service.ts +70 -0
- package/src/index.ts +0 -42
- package/src/lib/storage/interfaces/storage.interface.ts +1 -0
- package/src/lib/storage/storage.ts +4 -0
- package/src/lib/storage/types/storage.type.ts +1 -0
- package/tsconfig.json +0 -1
- package/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +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/README.md
CHANGED
|
@@ -145,6 +145,16 @@ export class AppService implements IConsumer {
|
|
|
145
145
|
file: file,
|
|
146
146
|
nameFile: 'teste.txt',
|
|
147
147
|
path: 'prime-sdk',
|
|
148
|
+
contentType: 'text/plain',
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// upload via presigned PUT url (server-side)
|
|
152
|
+
this.storage.uploadFileViaPresignedUrl({
|
|
153
|
+
bucket: 'sample-bucket',
|
|
154
|
+
file: file,
|
|
155
|
+
nameFile: 'teste-presigned.txt',
|
|
156
|
+
path: 'prime-sdk',
|
|
157
|
+
contentType: 'text/plain',
|
|
148
158
|
});
|
|
149
159
|
}
|
|
150
160
|
}
|
|
@@ -270,310 +280,3 @@ export class AppService {
|
|
|
270
280
|
#### Next steps
|
|
271
281
|
|
|
272
282
|
- 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()` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DecryptCommandOutput, EncryptCommandOutput, KMSClient } from '@aws-sdk/client-kms';
|
|
2
|
-
import { ICrypto } from
|
|
3
|
-
import { DecryptData, EncryptData } from
|
|
2
|
+
import { ICrypto } from "../../../lib/crypto/interfaces/crypto.interface";
|
|
3
|
+
import { DecryptData, EncryptData } from "../../../lib/crypto/types/crypto.type";
|
|
4
4
|
export declare class KMS implements ICrypto {
|
|
5
5
|
private readonly client;
|
|
6
6
|
constructor(client: KMSClient);
|
|
@@ -5,6 +5,8 @@ export declare class S3 implements IStorage {
|
|
|
5
5
|
private readonly client;
|
|
6
6
|
constructor(client: S3Client);
|
|
7
7
|
uploadFile(file: UploadFile): Promise<PutObjectCommandOutput>;
|
|
8
|
+
uploadFileViaPresignedUrl(file: UploadFile): Promise<void>;
|
|
9
|
+
private resolveFileBody;
|
|
8
10
|
generateSignUrlFile(file: GetFile): Promise<string>;
|
|
9
11
|
getFile(file: GetFile): Promise<GetObjectCommandOutput>;
|
|
10
12
|
listFiles(data: ListFiles): Promise<ListObjectsV2CommandOutput>;
|
|
@@ -16,6 +16,7 @@ exports.S3 = void 0;
|
|
|
16
16
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
19
|
+
const PRESIGNED_PUT_EXPIRES_IN_SECONDS = 3600;
|
|
19
20
|
let S3 = class S3 {
|
|
20
21
|
constructor(client) {
|
|
21
22
|
this.client = client;
|
|
@@ -25,6 +26,7 @@ let S3 = class S3 {
|
|
|
25
26
|
Bucket: file.bucket,
|
|
26
27
|
Key: `${file.path}/${file.nameFile}`,
|
|
27
28
|
Body: file.file,
|
|
29
|
+
...(file.contentType && { ContentType: file.contentType }),
|
|
28
30
|
...(file.metadata && { Metadata: file.metadata }),
|
|
29
31
|
...(file.tagging && {
|
|
30
32
|
Tagging: file.tagging,
|
|
@@ -33,6 +35,54 @@ let S3 = class S3 {
|
|
|
33
35
|
const response = await this.client.send(command);
|
|
34
36
|
return response;
|
|
35
37
|
}
|
|
38
|
+
async uploadFileViaPresignedUrl(file) {
|
|
39
|
+
const key = `${file.path}/${file.nameFile}`;
|
|
40
|
+
const contentType = file.contentType || 'application/octet-stream';
|
|
41
|
+
const body = await this.resolveFileBody(file.file);
|
|
42
|
+
const command = new client_s3_1.PutObjectCommand({
|
|
43
|
+
Bucket: file.bucket,
|
|
44
|
+
Key: key,
|
|
45
|
+
ContentType: contentType,
|
|
46
|
+
...(file.metadata && { Metadata: file.metadata }),
|
|
47
|
+
...(file.tagging && { Tagging: file.tagging }),
|
|
48
|
+
});
|
|
49
|
+
const presignedUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.client, command, {
|
|
50
|
+
expiresIn: PRESIGNED_PUT_EXPIRES_IN_SECONDS,
|
|
51
|
+
});
|
|
52
|
+
const headers = {
|
|
53
|
+
'Content-Type': contentType,
|
|
54
|
+
};
|
|
55
|
+
if (file.metadata) {
|
|
56
|
+
for (const [k, v] of Object.entries(file.metadata)) {
|
|
57
|
+
headers[`x-amz-meta-${k}`] = v;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (file.tagging) {
|
|
61
|
+
headers['x-amz-tagging'] = file.tagging;
|
|
62
|
+
}
|
|
63
|
+
const response = await fetch(presignedUrl, {
|
|
64
|
+
method: 'PUT',
|
|
65
|
+
headers,
|
|
66
|
+
body: new Uint8Array(body),
|
|
67
|
+
});
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
throw new Error(`s3_presigned_upload_failed: ${response.status} ${response.statusText}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async resolveFileBody(file) {
|
|
73
|
+
if (Buffer.isBuffer(file)) {
|
|
74
|
+
return file;
|
|
75
|
+
}
|
|
76
|
+
if (typeof file === 'string') {
|
|
77
|
+
return Buffer.from(file);
|
|
78
|
+
}
|
|
79
|
+
const chunks = [];
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
file.on('data', (chunk) => chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));
|
|
82
|
+
file.on('end', () => resolve(Buffer.concat(chunks)));
|
|
83
|
+
file.on('error', reject);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
36
86
|
async generateSignUrlFile(file) {
|
|
37
87
|
const params = {
|
|
38
88
|
Bucket: file.bucket,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3.service.js","sourceRoot":"","sources":["../../../../src/external/aws/s3/s3.service.ts"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E,MAAM,OAAO,GAAG,IAAI,gCAAoB,CAAC,MAAM,CAAC,CAAC;QAEjD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAc;QAC3B,MAAM,MAAM,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,6BAAiB,CAAC,MAAM,CAAC,CAAC;QAE9C,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AA3JY,gBAAE;aAAF,EAAE;IADd,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;qCAA0B,oBAAQ;GAD3D,EAAE,CA2Jd"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SendEmailCommandOutput, SendRawEmailCommandOutput, SESClient } from '@aws-sdk/client-ses';
|
|
2
|
-
import { IEmail } from
|
|
3
|
-
import { SendMail, SendRawMail } from
|
|
2
|
+
import { IEmail } from "../../../lib/email/interfaces/email.interface";
|
|
3
|
+
import { SendMail, SendRawMail } from "../../../lib/email/types/email.type";
|
|
4
4
|
export declare class SES implements IEmail {
|
|
5
5
|
private readonly client;
|
|
6
6
|
constructor(client: SESClient);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublishCommandOutput, SNSClient } from '@aws-sdk/client-sns';
|
|
2
|
-
import { IEvent } from
|
|
3
|
-
import { EventData, EventSmsData } from
|
|
2
|
+
import { IEvent } from "../../../lib/events/interfaces/event.interface";
|
|
3
|
+
import { EventData, EventSmsData } from "../../../lib/events/types/event.type";
|
|
4
4
|
import { SNSSetup } from './sns.provider';
|
|
5
5
|
export declare class Sns implements IEvent {
|
|
6
6
|
private readonly client;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeleteMessageCommand, ReceiveMessageCommand, ReceiveMessageResult, SQSClient } from '@aws-sdk/client-sqs';
|
|
2
|
-
import { IQueue } from
|
|
2
|
+
import { IQueue } from "../../../lib/queue/interfaces/queue.interface";
|
|
3
3
|
export declare class Sqs implements IQueue {
|
|
4
4
|
private readonly client;
|
|
5
5
|
private queueUrl;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,19 +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 { EntraIDModule, ENTRA_ID_CONFIG } from './lib/entraID/entraID.module';
|
|
24
|
-
import type { EntraIDModuleOptions } from './lib/entraID/entraID.module';
|
|
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
23
|
import { SNSSetup } from './external/aws/sns/sns.provider';
|
|
38
|
-
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,
|
|
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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { ICache } from './interfaces/cache.interface';
|
|
3
|
-
import { IRedisService } from
|
|
4
|
-
import { PubSubRedis } from
|
|
2
|
+
import { IRedisService } from "../../external/redis/interfaces/redis.interface";
|
|
3
|
+
import { PubSubRedis } from "../../external/redis/types/ioredis.types";
|
|
5
4
|
export declare class Cache implements ICache {
|
|
6
5
|
private readonly client;
|
|
7
6
|
constructor(client: IRedisService);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { PubSubRedis } from 'src/external/redis/types/ioredis.types';
|
|
1
|
+
import { PubSubRedis } from "../../../external/redis/types/ioredis.types";
|
|
3
2
|
export interface ICache {
|
|
4
3
|
set(key: string, value: Date | number | Buffer | string, ttl?: number): Promise<void>;
|
|
5
4
|
get(key: string): Promise<string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { KMSSetup } from
|
|
2
|
+
import { KMSSetup } from "../../external/aws/kms/kms.provider";
|
|
3
3
|
export declare class CryptoModule {
|
|
4
4
|
static forRoot(params: KMSSetup): DynamicModule;
|
|
5
5
|
}
|
|
@@ -2,6 +2,7 @@ import { CopyObjectCommandOutput, DeleteObjectCommandOutput, DeleteObjectsOutput
|
|
|
2
2
|
import { CopyFile, DeleteFile, DeleteFiles, GetFile, ListFiles, UploadFile } from '../types/storage.type';
|
|
3
3
|
export interface IStorage {
|
|
4
4
|
uploadFile(file: UploadFile): Promise<PutObjectCommandOutput>;
|
|
5
|
+
uploadFileViaPresignedUrl(file: UploadFile): Promise<void>;
|
|
5
6
|
generateSignUrlFile(file: GetFile): Promise<string>;
|
|
6
7
|
getFile(file: GetFile): Promise<GetObjectCommandOutput>;
|
|
7
8
|
listFiles(data: ListFiles): Promise<ListObjectsV2CommandOutput>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.interface.js","sourceRoot":"","sources":["../../../../src/lib/storage/interfaces/storage.interface.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"storage.interface.js","sourceRoot":"","sources":["../../../../src/lib/storage/interfaces/storage.interface.ts"],"names":[],"mappings":";;;AA4Ba,QAAA,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { IStorage } from './interfaces/storage.interface';
|
|
3
2
|
import { CopyObjectCommandOutput, DeleteObjectCommandOutput, DeleteObjectsOutput, GetObjectCommandOutput, ListObjectsV2CommandOutput, PutObjectCommandOutput } from '@aws-sdk/client-s3';
|
|
4
3
|
import { CopyFile, DeleteFile, DeleteFiles, GetFile, ListFiles, UploadFile } from './types/storage.type';
|
|
@@ -6,6 +5,7 @@ export declare class Storage {
|
|
|
6
5
|
private readonly storage;
|
|
7
6
|
constructor(storage: IStorage);
|
|
8
7
|
uploadFile(file: UploadFile): Promise<PutObjectCommandOutput>;
|
|
8
|
+
uploadFileViaPresignedUrl(file: UploadFile): Promise<void>;
|
|
9
9
|
generateSignUrlFile(file: GetFile): Promise<string>;
|
|
10
10
|
getFile(file: GetFile): Promise<GetObjectCommandOutput>;
|
|
11
11
|
listFiles(data: ListFiles): Promise<ListObjectsV2CommandOutput>;
|
|
@@ -22,6 +22,9 @@ let Storage = class Storage {
|
|
|
22
22
|
async uploadFile(file) {
|
|
23
23
|
return this.storage.uploadFile(file);
|
|
24
24
|
}
|
|
25
|
+
async uploadFileViaPresignedUrl(file) {
|
|
26
|
+
return this.storage.uploadFileViaPresignedUrl(file);
|
|
27
|
+
}
|
|
25
28
|
async generateSignUrlFile(file) {
|
|
26
29
|
return this.storage.generateSignUrlFile(file);
|
|
27
30
|
}
|