Skip to content

Commit f01af8f

Browse files
committed
chore(ts): refactoring
1 parent b3ea501 commit f01af8f

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@
4444
"publishConfig": {
4545
"registry": "https://registry.npmjs.org/"
4646
},
47-
"dependencies": {
48-
"base-64": "^1.0.0"
49-
},
5047
"devDependencies": {
5148
"@react-native-community/eslint-config": "^3.0.2",
5249
"@release-it/conventional-changelog": "^5.0.0",
5350
"@tsconfig/node-lts": "^20.1.1",
5451
"@types/react": "17.0.21",
5552
"@types/react-native": "0.70.0",
56-
"@types/base-64": "^1.0.2",
5753
"del-cli": "^5.0.0",
5854
"eslint": "^8.4.1",
5955
"eslint-config-prettier": "^8.5.0",

src/index.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
type TalsecConfig,
1414
} from './definitions';
1515
import { getThreatCount, itemsHaveType } from './utils';
16-
import { decode } from 'base-64';
16+
import { Buffer } from 'buffer';
1717

1818
const { FreeraspReactNative } = NativeModules;
1919

@@ -55,15 +55,11 @@ const prepareMapping = async (): Promise<void> => {
5555

5656
// parses base64-encoded malware data to SuspiciousAppInfo[]
5757
const parseMalwareData = (data: string[]): SuspiciousAppInfo[] => {
58-
const result: SuspiciousAppInfo[] = [];
59-
data.forEach((entry) => {
60-
result.push(toSuspiciousAppInfo(entry));
61-
});
62-
return result;
58+
return data.map((entry) => toSuspiciousAppInfo(entry));
6359
};
6460

6561
const toSuspiciousAppInfo = (base64Value: string): SuspiciousAppInfo => {
66-
const data = JSON.parse(decode(base64Value));
62+
const data = JSON.parse(Buffer.from(base64Value, 'base64').toString('utf8'));
6763
const packageInfo = data.packageInfo as PackageInfo;
6864
return { packageInfo, reason: data.reason } as SuspiciousAppInfo;
6965
};

yarn.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,11 +2606,6 @@
26062606
dependencies:
26072607
"@babel/types" "^7.20.7"
26082608

2609-
"@types/base-64@^1.0.2":
2610-
version "1.0.2"
2611-
resolved "https://registry.yarnpkg.com/@types/base-64/-/base-64-1.0.2.tgz#f7bc80d242306f20c57f076d79d1efe2d31032ca"
2612-
integrity sha512-uPgKMmM9fmn7I+Zi6YBqctOye4SlJsHKcisjHIMWpb2YKZRc36GpKyNuQ03JcT+oNXg1m7Uv4wU94EVltn8/cw==
2613-
26142609
"@types/graceful-fs@^4.1.3":
26152610
version "4.1.9"
26162611
resolved "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz"
@@ -3518,11 +3513,6 @@ balanced-match@^1.0.0:
35183513
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz"
35193514
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
35203515

3521-
base-64@^1.0.0:
3522-
version "1.0.0"
3523-
resolved "https://registry.yarnpkg.com/base-64/-/base-64-1.0.0.tgz#09d0f2084e32a3fd08c2475b973788eee6ae8f4a"
3524-
integrity sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==
3525-
35263516
base64-js@^1.1.2, base64-js@^1.2.3, base64-js@^1.3.1, base64-js@^1.5.1:
35273517
version "1.5.1"
35283518
resolved "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz"

0 commit comments

Comments
 (0)