Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-J 16
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
22_23-J 16
22_23-J 16
Commits
80eafe8c
Commit
80eafe8c
authored
May 10, 2023
by
Ishini Kiridena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
key on alerts
parent
e103d164
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
178 additions
and
27 deletions
+178
-27
ExpressBackend/route/patient-routes/register-route.js
ExpressBackend/route/patient-routes/register-route.js
+20
-18
emma-frontend/components/patientscreens/registration/regEight.js
...ontend/components/patientscreens/registration/regEight.js
+69
-9
emma-frontend/package-lock.json
emma-frontend/package-lock.json
+68
-0
emma-frontend/package.json
emma-frontend/package.json
+2
-0
emma-frontend/services/decryptByServerKey.js
emma-frontend/services/decryptByServerKey.js
+19
-0
No files found.
ExpressBackend/route/patient-routes/register-route.js
View file @
80eafe8c
...
...
@@ -12,25 +12,27 @@ const GenerateKeyPairAndCreateAccount = require("./../../services/accountCreator
let
timestamp
;
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
);
//decrypt user request details
//! @todo do not decrypt the password
const
decryptedEmail
=
req
.
body
.
email
;
const
decryptedBirthday
=
DecryptWithServerKey
(
req
.
body
.
birthday
);
const
decryptedChildCount
=
DecryptWithServerKey
(
req
.
body
.
childcount
);
const
decryptedEducationLevel
=
DecryptWithServerKey
(
req
.
body
.
educationlevel
);
const
decryptedEmail
=
DecryptWithServerKey
(
req
.
body
.
email
);
const
decryptedEmployed
=
DecryptWithServerKey
(
req
.
body
.
employed
);
const
decryptedEthnicity
=
DecryptWithServerKey
(
req
.
body
.
ethnicity
);
const
decryptedGender
=
DecryptWithServerKey
(
req
.
body
.
gender
);
const
decryptedName
=
DecryptWithServerKey
(
req
.
body
.
name
);
const
decryptedNationality
=
DecryptWithServerKey
(
req
.
body
.
nationality
);
const
decryptedOrphan
=
DecryptWithServerKey
(
req
.
body
.
orphan
);
const
decryptedPassword
=
req
.
body
.
password
;
const
decryptedUserName
=
req
.
body
.
username
;
const
decryptedName
=
req
.
body
.
name
;
const
decryptedPronoun
=
req
.
body
.
pronoun
;
const
decryptedBirthday
=
req
.
body
.
birthday
;
const
decryptedGender
=
req
.
body
.
gender
;
const
decryptedOrphan
=
req
.
body
.
orphan
;
const
decryptedSiblingCount
=
req
.
body
.
siblingcount
;
const
decryptedRelationship
=
req
.
body
.
relationship
;
const
decryptedChildCount
=
req
.
body
.
childcount
;
const
decryptedSexualPreference
=
req
.
body
.
sexualpreference
;
const
decryptedReligion
=
req
.
body
.
religion
;
const
decryptedEthnicity
=
req
.
body
.
ethnicity
;
const
decryptedNationality
=
req
.
body
.
nationality
;
const
decryptedEducationLevel
=
req
.
body
.
educationlevel
;
const
decryptedEmployed
=
req
.
body
.
employed
;
const
decryptedPronoun
=
DecryptWithServerKey
(
req
.
body
.
pronoun
);
const
decryptedRelationship
=
DecryptWithServerKey
(
req
.
body
.
relationship
);
const
decryptedReligion
=
DecryptWithServerKey
(
req
.
body
.
religion
);
const
decryptedSexualPreference
=
DecryptWithServerKey
(
req
.
body
.
sexualpreference
);
const
decryptedSiblingCount
=
DecryptWithServerKey
(
req
.
body
.
siblingcount
);
const
decryptedUserName
=
DecryptWithServerKey
(
req
.
body
.
username
);
//get the server key pair
const
serverSourceKeyPair
=
StellarSDK
.
Keypair
.
fromSecret
(
...
...
@@ -298,7 +300,7 @@ router.post("/", async (req, res) => {
//create the user collection object to be added to the DB
const
userCollectionObject
=
new
UserSchema
({
username
:
decryptedUserName
,
password
:
req
.
body
.
p
assword
,
password
:
decryptedP
assword
,
email
:
decryptedEmail
,
publickey
:
userKeyPair
.
publicKey
(),
rsa
:
b64RSApk
,
...
...
emma-frontend/components/patientscreens/registration/regEight.js
View file @
80eafe8c
import
React
,
{
useState
}
from
"
react
"
;
import
{
View
,
Text
,
Button
,
StyleSheet
}
from
"
react-native
"
;
import
{
View
,
Text
,
Button
,
StyleSheet
,
Alert
,
Clipboard
}
from
"
react-native
"
;
import
RadioForm
,
{
RadioButton
,
RadioButtonInput
,
...
...
@@ -7,6 +7,9 @@ import RadioForm, {
}
from
"
react-native-simple-radio-button
"
;
import
EncryptWithServerKey
from
"
../../../services/encryptByServerKey
"
;
import
{
LOCALBACKEND
}
from
"
../../../env
"
;
import
DecryptWithServerKey
from
"
../../../services/decryptByServerKey
"
;
import
AsyncStorage
from
"
@react-native-async-storage/async-storage
"
;
import
Clipboard
from
"
@react-native-clipboard/clipboard
"
;
export
default
function
PatientRegEight
({
navigation
,
route
})
{
const
[
educationLevel
,
setEducationLevel
]
=
useState
(
""
);
...
...
@@ -50,12 +53,8 @@ export default function PatientRegEight({ navigation, route }) {
const
encryptedEthnicity
=
EncryptWithServerKey
(
route
.
params
.
ethnicity
);
const
encryptedReligion
=
EncryptWithServerKey
(
route
.
params
.
religion
);
const
encryptedNationality
=
EncryptWithServerKey
(
route
.
params
.
nationality
);
const
encryptedEducationLevel
=
EncryptWithServerKey
(
route
.
params
.
educationLevel
);
const
encryptedEmployedStatus
=
EncryptWithServerKey
(
route
.
params
.
employedStatus
);
const
encryptedEducationLevel
=
EncryptWithServerKey
(
educationLevel
);
const
encryptedEmployedStatus
=
EncryptWithServerKey
(
employedStatus
);
//create JSON object
const
regObject
=
{
email
:
encryptedEmail
,
...
...
@@ -77,21 +76,82 @@ export default function PatientRegEight({ navigation, route }) {
employed
:
encryptedEmployedStatus
,
};
console
.
log
(
"
999999999999999999999
"
,
regObject
);
const
registerUrl
=
LOCALBACKEND
+
`/patient/register`
;
//call the backend endpoint
try
{
const
regResponse
=
await
fetch
(
registerUrl
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
(
regObject
),
});
console
.
log
(
regResponse
);
console
.
log
(
"
9--------------------------------
"
,
regObject
);
const
responseData
=
await
regResponse
.
json
();
if
(
regResponse
.
ok
)
{
console
.
log
(
"
Success
"
,
responseData
);
console
.
log
(
"
Registration success in backend...
"
);
const
{
message
,
hash
,
pubkey
,
seed
,
rsapk
,
rsask
}
=
responseData
;
//decrypt the data
const
decryptedStellarPublicKey
=
DecryptWithServerKey
(
pubkey
);
const
decryptedStellarSecretKey
=
DecryptWithServerKey
(
seed
);
const
decryptedRsaPublicKey
=
DecryptWithServerKey
(
rsapk
);
const
decryptedRsaSecretKey
=
DecryptWithServerKey
(
rsask
);
try
{
//save in async storage
await
AsyncStorage
.
setItem
(
"
patientStellarPublicKey
"
,
decryptedStellarPublicKey
);
await
AsyncStorage
.
setItem
(
"
patientStellarSecretKey
"
,
decryptedStellarSecretKey
);
await
AsyncStorage
.
setItem
(
"
patientRsaPublicKey
"
,
decryptedRsaPublicKey
);
await
AsyncStorage
.
setItem
(
"
patientRsaSecretKey
"
,
decryptedRsaSecretKey
);
const
copyMessage
=
`Public key : `
+
decryptedStellarPublicKey
+
`,Secret key : `
+
decryptedStellarSecretKey
;
const
alertMessage
=
`Public key : `
+
decryptedStellarPublicKey
+
`\nSecret key : `
+
decryptedStellarSecretKey
+
`\n Save the keys in a safe place`
;
//Show keys on the alert
Alert
.
alert
(
"
Account keys
"
,
alertMessage
,
[
{
text
:
"
Copy
"
,
onPress
:
()
=>
{
console
.
log
(
copyMessage
);
Clipboard
.
setStrings
(
[
"
Public key :
"
+
decryptedStellarPublicKey
],
[
"
Secret key :
"
+
decryptedStellarSecretKey
]
);
},
},
{
text
:
"
Close
"
,
style
:
"
cancel
"
},
]);
//on close send to main UI
}
catch
(
errorWhenStoringInAsyncStorage
)
{
console
.
log
(
errorWhenStoringInAsyncStorage
);
}
}
else
{
console
.
log
(
responseData
);
}
...
...
emma-frontend/package-lock.json
View file @
80eafe8c
...
...
@@ -8,6 +8,8 @@
"name"
:
"emma-frontend"
,
"version"
:
"1.0.0"
,
"dependencies"
:
{
"@react-native-async-storage/async-storage"
:
"1.17.11"
,
"@react-native-clipboard/clipboard"
:
"^1.11.2"
,
"@react-native-community/datetimepicker"
:
"6.7.3"
,
"@react-navigation/native"
:
"^6.1.6"
,
"@react-navigation/stack"
:
"^6.3.16"
,
...
...
@@ -3471,6 +3473,26 @@
"url"
:
"https://github.com/sponsors/isaacs"
}
},
"node_modules/@react-native-async-storage/async-storage"
:
{
"version"
:
"1.17.11"
,
"resolved"
:
"https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.17.11.tgz"
,
"integrity"
:
"sha512-bzs45n5HNcDq6mxXnSsOHysZWn1SbbebNxldBXCQs8dSvF8Aor9KCdpm+TpnnGweK3R6diqsT8lFhX77VX0NFw=="
,
"dependencies"
:
{
"merge-options"
:
"^3.0.4"
},
"peerDependencies"
:
{
"react-native"
:
"^0.0.0-0 || 0.60 - 0.71 || 1000.0.0"
}
},
"node_modules/@react-native-clipboard/clipboard"
:
{
"version"
:
"1.11.2"
,
"resolved"
:
"https://registry.npmjs.org/@react-native-clipboard/clipboard/-/clipboard-1.11.2.tgz"
,
"integrity"
:
"sha512-bHyZVW62TuleiZsXNHS1Pv16fWc0fh8O9WvBzl4h2fykqZRW9a+Pv/RGTH56E3X2PqzHP38K5go8zmCZUoIsoQ=="
,
"peerDependencies"
:
{
"react"
:
">=16.0"
,
"react-native"
:
">=0.57.0"
}
},
"node_modules/@react-native-community/cli"
:
{
"version"
:
"10.2.2"
,
"resolved"
:
"https://registry.npmjs.org/@react-native-community/cli/-/cli-10.2.2.tgz"
,
...
...
@@ -7969,6 +7991,14 @@
"node"
:
">=8"
}
},
"node_modules/is-plain-obj"
:
{
"version"
:
"2.1.0"
,
"resolved"
:
"https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz"
,
"integrity"
:
"sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA=="
,
"engines"
:
{
"node"
:
">=8"
}
},
"node_modules/is-plain-object"
:
{
"version"
:
"2.0.4"
,
"resolved"
:
"https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz"
,
...
...
@@ -9184,6 +9214,17 @@
"resolved"
:
"https://registry.npmjs.org/memory-cache/-/memory-cache-0.2.0.tgz"
,
"integrity"
:
"sha512-OcjA+jzjOYzKmKS6IQVALHLVz+rNTMPoJvCztFaZxwG14wtAW7VRZjwTQu06vKCYOxh4jVnik7ya0SXTB0W+xA=="
},
"node_modules/merge-options"
:
{
"version"
:
"3.0.4"
,
"resolved"
:
"https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz"
,
"integrity"
:
"sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ=="
,
"dependencies"
:
{
"is-plain-obj"
:
"^2.1.0"
},
"engines"
:
{
"node"
:
">=10"
}
},
"node_modules/merge-stream"
:
{
"version"
:
"2.0.0"
,
"resolved"
:
"https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz"
,
...
...
@@ -15985,6 +16026,20 @@
}
}
},
"@react-native-async-storage/async-storage"
:
{
"version"
:
"1.17.11"
,
"resolved"
:
"https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.17.11.tgz"
,
"integrity"
:
"sha512-bzs45n5HNcDq6mxXnSsOHysZWn1SbbebNxldBXCQs8dSvF8Aor9KCdpm+TpnnGweK3R6diqsT8lFhX77VX0NFw=="
,
"requires"
:
{
"merge-options"
:
"^3.0.4"
}
},
"@react-native-clipboard/clipboard"
:
{
"version"
:
"1.11.2"
,
"resolved"
:
"https://registry.npmjs.org/@react-native-clipboard/clipboard/-/clipboard-1.11.2.tgz"
,
"integrity"
:
"sha512-bHyZVW62TuleiZsXNHS1Pv16fWc0fh8O9WvBzl4h2fykqZRW9a+Pv/RGTH56E3X2PqzHP38K5go8zmCZUoIsoQ=="
,
"requires"
:
{}
},
"@react-native-community/cli"
:
{
"version"
:
"10.2.2"
,
"resolved"
:
"https://registry.npmjs.org/@react-native-community/cli/-/cli-10.2.2.tgz"
,
...
...
@@ -19392,6 +19447,11 @@
"resolved"
:
"https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz"
,
"integrity"
:
"sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ=="
},
"is-plain-obj"
:
{
"version"
:
"2.1.0"
,
"resolved"
:
"https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz"
,
"integrity"
:
"sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA=="
},
"is-plain-object"
:
{
"version"
:
"2.0.4"
,
"resolved"
:
"https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz"
,
...
...
@@ -20321,6 +20381,14 @@
"resolved"
:
"https://registry.npmjs.org/memory-cache/-/memory-cache-0.2.0.tgz"
,
"integrity"
:
"sha512-OcjA+jzjOYzKmKS6IQVALHLVz+rNTMPoJvCztFaZxwG14wtAW7VRZjwTQu06vKCYOxh4jVnik7ya0SXTB0W+xA=="
},
"merge-options"
:
{
"version"
:
"3.0.4"
,
"resolved"
:
"https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz"
,
"integrity"
:
"sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ=="
,
"requires"
:
{
"is-plain-obj"
:
"^2.1.0"
}
},
"merge-stream"
:
{
"version"
:
"2.0.0"
,
"resolved"
:
"https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz"
,
...
...
emma-frontend/package.json
View file @
80eafe8c
...
...
@@ -9,6 +9,8 @@
"web"
:
"expo start --web"
},
"dependencies"
:
{
"@react-native-async-storage/async-storage"
:
"1.17.11"
,
"@react-native-clipboard/clipboard"
:
"^1.11.2"
,
"@react-native-community/datetimepicker"
:
"6.7.3"
,
"@react-navigation/native"
:
"^6.1.6"
,
"@react-navigation/stack"
:
"^6.3.16"
,
...
...
emma-frontend/services/decryptByServerKey.js
0 → 100644
View file @
80eafe8c
import
CryptoJS
from
"
react-native-crypto-js
"
;
import
{
useEffect
}
from
"
react
"
;
import
{
AES_KEY
}
from
"
../env
"
;
function
DecryptWithServerKey
(
encryptedTxt
)
{
const
key
=
CryptoJS
.
enc
.
Utf8
.
parse
(
AES_KEY
);
const
options
=
{
mode
:
CryptoJS
.
mode
.
CBC
,
padding
:
CryptoJS
.
pad
.
Pkcs7
,
iv
:
CryptoJS
.
enc
.
Utf8
.
parse
(
AES_KEY
),
};
const
decryptedBytes
=
CryptoJS
.
AES
.
decrypt
(
encryptedTxt
,
key
,
options
);
const
decryptedTxt
=
decryptedBytes
.
toString
(
CryptoJS
.
enc
.
Utf8
);
return
decryptedTxt
;
}
export
default
DecryptWithServerKey
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment