Skip to content

Commit 51e72ab

Browse files
committed
chore: change imports of string operations
1 parent 61186ca commit 51e72ab

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@
9292
"react-toastify": "^9.1.2",
9393
"react-typed": "^1.2.0",
9494
"recharts": "^2.7.3",
95-
"sass": "^1.64.2",
9695
"sha256": "^0.2.0",
97-
"siwe": "^2.1.4",
9896
"slick-carousel": "^1.8.1",
9997
"striptags": "3.2.0",
10098
"survey-analytics": "^1.9.109",
@@ -140,6 +138,7 @@
140138
"lint-staged": "15.3.0",
141139
"postcss": "^8.4.18",
142140
"prettier": "^2.5.1",
141+
"sass": "^1.64.2",
143142
"semver": "^7.6.3",
144143
"tailwindcss": "3.4.16"
145144
}

src/domain/quiz/views/quiz-question-list/QuizCore.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
*/
1616

1717
import clsx from 'clsx';
18-
import { nanoid } from 'nanoid';
18+
19+
import { generateRandomId } from '@/utils';
1920

2021
import RadioIcon from './RadioIcon';
2122

@@ -72,7 +73,7 @@ export function QuizCore({
7273

7374
return (
7475
<button
75-
key={nanoid()}
76+
key={generateRandomId()}
7677
type="button"
7778
className={clsx('flex items-center gap-x-4 md:block min-h-[48px] py-3 border text-[15px] transition-all rounded mt-6 w-full text-left px-4 border-gray-600 hover:border-gray', {
7879
'!border-gray': checked,

src/services/auth/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@
1414
* limitations under the License.
1515
*/
1616

17-
import sha256 from 'sha256';
18-
17+
import { encryptWithSha256 } from '@/utils/encryption';
1918
import { post } from '@/utils/request';
2019

2120
export async function signin(email, password) {
2221
const res = await post(
2322
'ts/v1/auth/user/email/login/password',
24-
{ email, password: sha256(password) },
23+
{ email, password: encryptWithSha256(password) },
2524
{ isSetJwt: true }
2625
);
2726
return res;
2827
}
2928

3029
export async function reset(key, password) {
31-
const res = await post('ts/v1/auth/user/email/reset/password', { key, password: sha256(password) });
30+
const res = await post('ts/v1/auth/user/email/reset/password', { key, password: encryptWithSha256(password) });
3231
return res;
3332
}
3433

@@ -53,7 +52,7 @@ export async function bindEmail(email, verification_code) {
5352
export async function registerEmail(email, password, verification_code) {
5453
const res = await post('ts/v1/auth/user/email/register', {
5554
email,
56-
password: sha256(password),
55+
password: encryptWithSha256(password),
5756
verification_code,
5857
});
5958
return res;

src/shared/utils/encryption.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright 2024 OpenBuild
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export { default as encryptWithSha256 } from 'sha256';

src/shared/utils/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,4 @@ export function HTMLDecode(text) {
9595
}
9696

9797
export { isEmpty, isInteger, isString, isFunction, isPlainObject, get, cloneDeep, merge, capitalize, chunk, range } from 'lodash';
98+
export { nanoid as generateRandomId } from 'nanoid';

0 commit comments

Comments
 (0)