Replace `crypto-js` with `expo-crypto`

This commit is contained in:
Zhiyuan Zheng 2020-12-24 10:39:44 +01:00
parent b5f267e6bf
commit 97442b31db
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
3 changed files with 6 additions and 10 deletions

View File

@ -15,11 +15,11 @@
"@react-navigation/native": "^5.8.10",
"@reduxjs/toolkit": "^1.5.0",
"axios": "^0.21.0",
"crypto-js": "^3.3.0",
"expo": "^40.0.0",
"expo-auth-session": "~3.0.0",
"expo-av": "~8.7.0",
"expo-blur": "~8.2.2",
"expo-crypto": "~8.4.0",
"expo-image-picker": "~9.2.0",
"expo-linear-gradient": "~8.4.0",
"expo-linking": "~2.0.0",

View File

@ -20,7 +20,7 @@ import {
} from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import sha256 from 'crypto-js/sha256'
import * as Crypto from 'expo-crypto'
import { store } from '@root/store'
import ComposeRoot from '@screens/Shared/Compose/Root'
@ -464,7 +464,8 @@ const Compose: React.FC<Props> = ({ route: { params }, navigation }) => {
instance: 'local',
url: 'statuses',
headers: {
'Idempotency-Key': sha256(
'Idempotency-Key': await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256,
composeState.spoiler.raw +
composeState.text.raw +
composeState.poll.options['0'] +
@ -477,7 +478,7 @@ const Compose: React.FC<Props> = ({ route: { params }, navigation }) => {
composeState.attachments.uploads.map(upload => upload.id) +
composeState.visibility +
(params?.type === 'edit' ? Math.random() : '')
).toString()
)
},
body: formData
})

View File

@ -2390,11 +2390,6 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"
crypto-js@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b"
integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q==
css-select@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/css-select/-/css-select-2.1.0.tgz#6a34653356635934a81baca68d0255432105dbef"
@ -2832,7 +2827,7 @@ expo-constants@^9.3.3, expo-constants@~9.3.3:
fbjs "1.0.0"
uuid "^3.3.2"
expo-crypto@^8.4.0:
expo-crypto@^8.4.0, expo-crypto@~8.4.0:
version "8.4.0"
resolved "https://registry.yarnpkg.com/expo-crypto/-/expo-crypto-8.4.0.tgz#59a5b0640bb39db93e6857feafa2c9514b172cef"
integrity sha512-EHEFx5sHTDVIuQH8/juuecQWj1uQ7ClM98fKXPFcNYcBlYSCQvkik37hwfJC5WLcVnelFDpvZJmHxiTfB5GKCg==