fix(deps): migrate zxcvbn

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-05-07 19:31:27 +02:00
parent 4ed6f5fed1
commit 0263c09ce1

View file

@ -5,9 +5,20 @@
*/ */
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm'; import { InjectRepository } from '@nestjs/typeorm';
import { zxcvbnAsync, zxcvbnOptions } from '@zxcvbn-ts/core'; import {
import zxcvbnCommonPackage from '@zxcvbn-ts/language-common'; OptionsGraph,
import zxcvbnEnPackage from '@zxcvbn-ts/language-en'; OptionsType,
zxcvbnAsync,
zxcvbnOptions,
} from '@zxcvbn-ts/core';
import {
adjacencyGraphs,
dictionary as zxcvbnCommonDictionary,
} from '@zxcvbn-ts/language-common';
import {
dictionary as zxcvbnEnDictionary,
translations as zxcvbnEnTranslations,
} from '@zxcvbn-ts/language-en';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import authConfiguration, { AuthConfig } from '../config/auth.config'; import authConfiguration, { AuthConfig } from '../config/auth.config';
@ -34,13 +45,13 @@ export class IdentityService {
private authConfig: AuthConfig, private authConfig: AuthConfig,
) { ) {
this.logger.setContext(IdentityService.name); this.logger.setContext(IdentityService.name);
const options = { const options: OptionsType = {
dictionary: { dictionary: {
...zxcvbnCommonPackage.dictionary, ...zxcvbnCommonDictionary,
...zxcvbnEnPackage.dictionary, ...zxcvbnEnDictionary,
}, },
graphs: zxcvbnCommonPackage.adjacencyGraphs, graphs: adjacencyGraphs as OptionsGraph,
translations: zxcvbnEnPackage.translations, translations: zxcvbnEnTranslations,
}; };
zxcvbnOptions.setOptions(options); zxcvbnOptions.setOptions(options);
} }