opentrace-community / opentrace-android

OpenTrace Android app. Reference implementation of the BlueTrace protocol.
https://bluetrace.io
GNU General Public License v3.0
577 stars 225 forks source link

After that an user upload the data , how to retrieve the uid or phone number of the user who upload and uid or phone number of other users who is in upload data of this user . #23

Closed russellmoya closed 4 years ago

esQmo commented 4 years ago

Can you please use a valid title and explain your issue in the "description" section?

russellmoya commented 4 years ago

ok

russellmoya commented 4 years ago

how to know the phone number or the uid of the users in this data uploaded

esQmo commented 4 years ago

How did you manage to get the upload PIN? @russellmoya

rinekri commented 4 years ago

@russellmoya you can download uploaded file by ObjectMetadata and decode msg (where contains encoded contacted user id) from the records list and token (where contains encoded user id who uploaded data). But your token is empty and it seems you are avoided getToken process.

russellmoya commented 4 years ago

Thanks a lot @rinekri for answer me. i remove the token , but in the original code , i have the token . @rinekri . i have Encryption secret key , that i store in google cloud secret manager . but i want know how to decode msg and token

@russellmoya you can download uploaded file by ObjectMetadata and decode msg (where contains encoded contacted user id) from the records list and token (where contains encoded user id who uploaded data). But your token is empty and it seems you are avoided getToken process.

rinekri commented 4 years ago

@russellmoya you can use decryptTempID and validateToken functions to do this. You can find them in the existing files: first / second. For encryptionKey parameter use await getEncryptionKey()

russellmoya commented 4 years ago

How did you manage to get the upload PIN? @russellmoya

i modify getUploadToken.ts file . in the getUploadToken.ts , i change if (data) code . the new code :

if (data) { //const uploadCodes = await retrieveUploadCodes(); const uploadCodes = uid.substring(0, 6).toUpperCase(); console.log('getUploadToken:', obtained ${uploadCodes.length} upload codes); console.log("voici le code de retrive",uploadCodes);

if(uploadCodes.length >0){
    if(uploadCodes === data.toUpperCase()){
      valid = true ;
    } else {
        valid = false ;
    }
}

// valid = uploadCodes.find(x => x === data) !== undefined; console.log('getUploadToken:', data is ${valid ? 'valid' : 'not valid'} code); }

russellmoya commented 4 years ago

@russellmoya you can use decryptTempID and validateToken functions to do this. You can find them in the existing files: first / second. For encryptionKey parameter use await getEncryptionKey()

for msg i use descyptTempID and for token i use validateToken ? ... @rinekri

rinekri commented 4 years ago

@rinekri yeah. This is an example how you can download uploaded data to decrypt it:

async function getCurrentUploadedData(event: ObjectMetadata): Promise<UploadedData> {
  return admin.storage().bucket(event.bucket).file(event.name!).download().then(file => {
    const uploadedData = JSON.parse(file[0].toString())
    console.log('getUploadedData:', `Uploaded data token: ${uploadedData.token}`);
    return uploadedData
  }).catch(function (error) {
    console.log("getUploadedData", error);
    return null
  })
}

interface UploadedData {
  records: Record[];
  token: string
}

interface Record {
  id: string,
  msg: string,
  timestamp: string
}
russellmoya commented 4 years ago

thanks