truecaller / backend-sdk-validation

5 stars 16 forks source link

decrypt payload for authenticated data #18

Open caseThree opened 2 years ago

caseThree commented 2 years ago

The truecaller profile received at the backend is of this format:

{ "avatarUrl":null, "city":null, "companyName":null, "countryCode":"IN", "email":null, "facebookId":null, "firstName":"Shobhit", "gender":"M", "isAmbassador":false, "isBusiness":false, "isVerified":false, "jobTitle":null, "lastName":"Tewari", "payload":null, "phoneNumber": null, "requestNonce": null, "signature": null, "street":null, "successful":true, "twitterId":null, "url":null, "zipcode":null }

Here null is the placeholdere for specific fields.

In this format of data, we verify the signature but there is a possibility that the developer may take data from the raw object mentioned above. After validation, the data must be taken from the payload and not the raw object received at the backend as shown above. This is also mentioned in the docs.

I created a function that will return the details in the payload which is the verified data in the format:

{ requestNonce: null, requestTime: null, phoneNumber: null, firstName: 'Shobhit', lastName: 'Tewari', gender: 'M', countryCode: 'IN', trueName: true, ambassador: false, isBusiness: false, verifier: null }

This is the data which is received after decoding the payload which is verified after verifying the signature.