
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@tc-libs/helper
Advanced tools
Package di utilita condivise per NestJS. Espone un `HelperModule` registrabile e una serie di servizi iniettabili per:
Package di utilita condivise per NestJS. Espone un HelperModule registrabile e una serie di servizi iniettabili per:
Usa questa libreria quando vuoi centralizzare logica tecnica riusabile invece di duplicare helper statici nei singoli servizi applicativi.
I package authentication, pagination, request, setting, task e altri dipendono gia da questi servizi.
import { Module } from '@nestjs/common';
import { HelperModule } from '@tc-libs/helper';
@Module({
imports: [
HelperModule.register(
{
jwt: {
defaultSecretKey: process.env.JWT_DEFAULT_SECRET!,
defaultExpirationTime: 3600,
},
auth: {
subject: 'access',
audience: 'my-api',
issuer: 'my-service',
accessToken: {
secretKey: process.env.ACCESS_TOKEN_SECRET!,
expirationTime: 3600,
notBeforeExpirationTime: 0,
encryptKey: process.env.ACCESS_TOKEN_ENCRYPT_KEY!,
encryptIv: process.env.ACCESS_TOKEN_ENCRYPT_IV!,
},
refreshToken: {
secretKey: process.env.REFRESH_TOKEN_SECRET!,
expirationTime: 86400,
expirationTimeRememberMe: 2592000,
notBeforeExpirationTime: 0,
encryptKey: process.env.REFRESH_TOKEN_ENCRYPT_KEY!,
encryptIv: process.env.REFRESH_TOKEN_ENCRYPT_IV!,
},
permissionToken: {
secretKey: process.env.PERMISSION_TOKEN_SECRET!,
expirationTime: 900,
notBeforeExpirationTime: 0,
encryptKey: process.env.PERMISSION_TOKEN_ENCRYPT_KEY!,
encryptIv: process.env.PERMISSION_TOKEN_ENCRYPT_IV!,
},
},
},
true,
),
],
})
export class AppModule {}
HelperModule.registerAsync(
{
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
jwt: {
defaultSecretKey: configService.getOrThrow<string>('JWT_DEFAULT_SECRET'),
defaultExpirationTime: 3600,
},
auth: {
subject: 'access',
audience: 'my-api',
issuer: 'my-service',
accessToken: {
secretKey: configService.getOrThrow<string>('ACCESS_TOKEN_SECRET'),
expirationTime: 3600,
notBeforeExpirationTime: 0,
encryptKey: configService.getOrThrow<string>('ACCESS_TOKEN_ENCRYPT_KEY'),
encryptIv: configService.getOrThrow<string>('ACCESS_TOKEN_ENCRYPT_IV'),
},
refreshToken: {
secretKey: configService.getOrThrow<string>('REFRESH_TOKEN_SECRET'),
expirationTime: 86400,
expirationTimeRememberMe: 2592000,
notBeforeExpirationTime: 0,
encryptKey: configService.getOrThrow<string>('REFRESH_TOKEN_ENCRYPT_KEY'),
encryptIv: configService.getOrThrow<string>('REFRESH_TOKEN_ENCRYPT_IV'),
},
permissionToken: {
secretKey: configService.getOrThrow<string>('PERMISSION_TOKEN_SECRET'),
expirationTime: 900,
notBeforeExpirationTime: 0,
encryptKey: configService.getOrThrow<string>('PERMISSION_TOKEN_ENCRYPT_KEY'),
encryptIv: configService.getOrThrow<string>('PERMISSION_TOKEN_ENCRYPT_IV'),
},
},
}),
},
true,
);
import {
DateService,
EncryptionService,
GeoService,
HashService,
NumberService,
PasswordService,
StringService,
TokenService,
} from '@tc-libs/helper';
DateServiceOperazioni principali:
Esempio:
const expiresAt = this.dateService.forwardInMinutes(15);
const age = this.dateService.calculateAge(user.birthDate);
StringServiceOperazioni principali:
Esempio:
const slug = this.stringService.slugify('Listino Prezzi 2026');
const reference = this.stringService.randomReference(6, 'ORD');
NumberServiceOperazioni principali:
numberconst code = this.numberService.random(6);
const completion = this.numberService.percent(done, total);
HashServiceEspone:
sha1Base64sha256const digest = this.hashService.sha256(payload);
PasswordServiceWrapper su bcryptjs per hashing e confronto password:
const hashed = await this.passwordService.hashPassword(plainPassword);
const isValid = await this.passwordService.compare(plainPassword, hashed);
EncryptionServiceEspone primitive per:
const encrypted = this.encryptionService.aes256Encrypt(data, key, iv);
const token = this.encryptionService.jwtEncrypt(payload, {
secretKey,
expiredIn: 3600,
audience: 'my-api',
issuer: 'my-service',
subject: 'access',
});
TokenServiceServizio ad alto livello costruito sopra EncryptionService e configurazione auth.
Casi d'uso principali:
rememberMeconst payload = this.tokenService.createPayloadAccessToken(
{ user: user._id, email: user.email },
false,
);
const encryptedPayload = await this.tokenService.encryptAccessToken(payload);
const accessToken = this.tokenService.createAccessToken(encryptedPayload);
GeoServiceControlla se un punto e dentro un raggio espresso in metri:
const allowed = this.geoService.inRadius(
{ latitude: 45.4642, longitude: 9.19, radiusInMeters: 500 },
{ latitude: 45.465, longitude: 9.191 },
);
Oltre ai servizi, il package esporta:
ENUM_DATE_FORMAT e ENUM_DATE_DIFFHELPER_CONFIG_OPTIONSHelperOptions e HelperAsyncOptionsTokenService dipende dalla registrazione di HelperModule con configurazione completa.EncryptionService usa JwtService, quindi va risolto tramite DI Nest invece di essere istanziato manualmente.nx build helper
nx test helper
FAQs
Package di utilita condivise per NestJS. Espone un `HelperModule` registrabile e una serie di servizi iniettabili per:
We found that @tc-libs/helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.