Skip to content

Commit

Permalink
refactor: update genCredentials to use random salt
Browse files Browse the repository at this point in the history
  • Loading branch information
caru-ini committed Jun 18, 2024
1 parent 85a47a5 commit 7d4a2e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions server/domain/user/service/genCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ export const genCredentials = (params: {
poolId: EntityId['userPool'];
username: string;
password: string;
salt?: string;
}): { salt: string; verifier: string } => {
const salt = params.salt || crypto.randomBytes(16).toString('hex');
const salt = crypto.randomBytes(16).toString('hex');
const verifier = genVerifier({ ...params, salt });
return { salt, verifier };
};
7 changes: 4 additions & 3 deletions server/tests/api/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import api from 'api/$api';
import type { UserEntity } from 'api/@types/user';
import axios from 'axios';
import { genConfirmationCode } from 'domain/user/service/genConfirmationCode';
import { genCredentials } from 'domain/user/service/genCredentials';
import { genVerifier } from 'domain/user/service/genCredentials';
import { genTokens } from 'domain/user/service/genTokens';
import { brandedId } from 'service/brandedId';
import { COOKIE_NAME } from 'service/constants';
Expand All @@ -19,11 +19,12 @@ export const noCookieClient = api(
);

export const createUserClient = async (): Promise<typeof noCookieClient> => {
const { verifier, salt } = genCredentials({
const salt = 'test-client-salt';
const verifier = genVerifier({
poolId: DEFAULT_USER_POOL_ID,
username: 'test-client',
password: 'test-client-password',
salt: 'test-client-salt',
salt,
});
const user: UserEntity = {
id: brandedId.user.entity.parse(ulid()),
Expand Down

0 comments on commit 7d4a2e4

Please sign in to comment.