Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Increase integrity error logs #254

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rude-bags-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"io-wallet-user-func": patch
---

Add integrity error logs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const verifyAssertion = async (params: VerifyAssertionParams) => {
integrityAssertion,
} = params;

const errors: string[] = [];

// First check whether the clientData has been signed correctly with the hardware key
const signatureValidated = validateAssertionSignature(
hardwareKey,
Expand Down Expand Up @@ -100,23 +102,26 @@ export const verifyAssertion = async (params: VerifyAssertionParams) => {
androidPlayStoreCertificateHash,
);
break;
} catch (e) {
} catch (error) {
/* If it fails I continue the for loop anyway to try other bundleIdentifiers.
* The check is still done at the end on the value of responseValidated
*/
errors.push(`${error}`);
}
} else {
errors.push(`${result}`);
}
}

if (!tokenPayloadExternal || !bundleIdentifier) {
throw new Error(
"[Android Assertion] Invalid token payload from Play Integrity API response",
`[Android Assertion] Invalid token payload from Play Integrity API response: ${errors.join(",")}`,
);
}

if (!responseValidated) {
throw new Error(
"[Android Assertion] Integrity Response did not pass validation",
`[Android Assertion] Integrity Response did not pass validation: ${errors.join(",")}`,
);
}
};
Expand Down
Loading