Skip to content

Commit

Permalink
feat(core): Export PasswordCipher helper
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Jun 18, 2021
1 parent 4aa6f56 commit 221051f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { UnauthorizedError } from '../../common/error/errors';
import { Injector } from '../../common/injector';
import { NativeAuthenticationMethod } from '../../entity/authentication-method/native-authentication-method.entity';
import { User } from '../../entity/user/user.entity';
import { PasswordCiper } from '../../service/helpers/password-cipher/password-ciper';
import { PasswordCipher } from '../../service/helpers/password-cipher/password-cipher';
import { TransactionalConnection } from '../../service/transaction/transactional-connection';

import { AuthenticationStrategy } from './authentication-strategy';
Expand All @@ -31,11 +31,11 @@ export class NativeAuthenticationStrategy implements AuthenticationStrategy<Nati
readonly name = NATIVE_AUTH_STRATEGY_NAME;

private connection: TransactionalConnection;
private passwordCipher: PasswordCiper;
private passwordCipher: PasswordCipher;

init(injector: Injector) {
this.connection = injector.get(TransactionalConnection);
this.passwordCipher = injector.get(PasswordCiper);
this.passwordCipher = injector.get(PasswordCipher);
}

defineInputType(): DocumentNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const SALT_ROUNDS = 12;
* A cipher which uses bcrypt (https://en.wikipedia.org/wiki/Bcrypt) to hash plaintext password strings.
*/
@Injectable()
export class PasswordCiper {
export class PasswordCipher {
hash(plaintext: string): Promise<string> {
return bcrypt.hash(plaintext, SALT_ROUNDS);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from './helpers/order-calculator/order-calculator';
export * from './helpers/order-merger/order-merger';
export * from './helpers/order-modifier/order-modifier';
export * from './helpers/order-state-machine/order-state';
export * from './helpers/password-cipher/password-cipher';
export * from './helpers/fulfillment-state-machine/fulfillment-state';
export * from './helpers/payment-state-machine/payment-state';
export * from './services/administrator.service';
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/service/service.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { OrderCalculator } from './helpers/order-calculator/order-calculator';
import { OrderMerger } from './helpers/order-merger/order-merger';
import { OrderModifier } from './helpers/order-modifier/order-modifier';
import { OrderStateMachine } from './helpers/order-state-machine/order-state-machine';
import { PasswordCiper } from './helpers/password-cipher/password-ciper';
import { PasswordCipher } from './helpers/password-cipher/password-cipher';
import { PaymentStateMachine } from './helpers/payment-state-machine/payment-state-machine';
import { RefundStateMachine } from './helpers/refund-state-machine/refund-state-machine';
import { ShippingCalculator } from './helpers/shipping-calculator/shipping-calculator';
Expand Down Expand Up @@ -99,7 +99,7 @@ const services = [

const helpers = [
TranslatableSaver,
PasswordCiper,
PasswordCipher,
OrderCalculator,
OrderStateMachine,
FulfillmentStateMachine,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/service/services/administrator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { NativeAuthenticationMethod } from '../../entity/authentication-method/n
import { User } from '../../entity/user/user.entity';
import { CustomFieldRelationService } from '../helpers/custom-field-relation/custom-field-relation.service';
import { ListQueryBuilder } from '../helpers/list-query-builder/list-query-builder';
import { PasswordCiper } from '../helpers/password-cipher/password-ciper';
import { PasswordCipher } from '../helpers/password-cipher/password-cipher';
import { patchEntity } from '../helpers/utils/patch-entity';
import { TransactionalConnection } from '../transaction/transactional-connection';

Expand All @@ -28,7 +28,7 @@ export class AdministratorService {
private connection: TransactionalConnection,
private configService: ConfigService,
private listQueryBuilder: ListQueryBuilder,
private passwordCipher: PasswordCiper,
private passwordCipher: PasswordCipher,
private userService: UserService,
private roleService: RoleService,
private customFieldRelationService: CustomFieldRelationService,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/service/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { ConfigService } from '../../config/config.service';
import { NativeAuthenticationMethod } from '../../entity/authentication-method/native-authentication-method.entity';
import { User } from '../../entity/user/user.entity';
import { PasswordCiper } from '../helpers/password-cipher/password-ciper';
import { PasswordCipher } from '../helpers/password-cipher/password-cipher';
import { VerificationTokenGenerator } from '../helpers/verification-token-generator/verification-token-generator';
import { TransactionalConnection } from '../transaction/transactional-connection';

Expand All @@ -31,7 +31,7 @@ export class UserService {
private connection: TransactionalConnection,
private configService: ConfigService,
private roleService: RoleService,
private passwordCipher: PasswordCiper,
private passwordCipher: PasswordCipher,
private verificationTokenGenerator: VerificationTokenGenerator,
) {}

Expand Down

0 comments on commit 221051f

Please sign in to comment.