Response Data Validation
You can validate the response data of all service APIs and its integrity through HMAC. With every successful Service API response, a header with key "hmac" contains the HMAC digest value. You can calculate the HMAC digest of the response body, and then compare it to the digest in the header.
Calculation
Steps:
Sort the fields inside the "result" object by key in ascending alphabetical order (Lexicographical order)
Concatenate the ordered values into a single string (No separators)
Sort the fields inside the response body in lexicographical order.
Concatenate the ordered values into a single string (No separators)
Calculate the HMAC digest of the using SHA512 and the bundleβs HMAC key. HMAC Key will be provided separate from the documentation.
Convert the digest into Hexadecimal Lowercase format.
Compare the resulting digest with the one in the response header.
Example:
Consider the following response for the Egyptian National ID OCR:
Code Snippets
Last updated