Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/crisp-steaks-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"io-wallet-user-func": patch
---

Fixed HTTP status for Google Play Integrity API failures: external service errors now return 500 instead of 409
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export interface VerifyAssertionParams {

export const playintegrity = google.playintegrity("v1");

export class ExternalServiceError extends Error {
name = "ExternalServiceError";
}

export const verifyAssertion = async (
params: VerifyAssertionParams,
): Promise<ValidationResult> => {
Expand Down Expand Up @@ -85,12 +89,17 @@ export const verifyAssertion = async (
let responseValidated;

for (const packageName of bundleIdentifiers) {
const result = await playintegrity.v1.decodeIntegrityToken({
packageName,
requestBody: {
integrityToken: integrityAssertion,
},
});
let result;
try {
result = await playintegrity.v1.decodeIntegrityToken({
packageName,
requestBody: {
integrityToken: integrityAssertion,
},
});
} catch {
throw new ExternalServiceError();
}

const token = result.data.tokenPayloadExternal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
validateiOSAssertion,
validateiOSAttestation,
} from "./ios";
import { ExternalServiceError } from "./android/assertion";

Check failure on line 33 in apps/io-wallet-user-func/src/infra/mobile-attestation-service/index.ts

View workflow job for this annotation

GitHub Actions / Code Review / js_code_review

Expected "./android/assertion" to come before "./ios"

export class IntegrityCheckError extends Error {
name = "IntegrityCheckError";
Expand Down Expand Up @@ -123,9 +124,14 @@
),
),
TE.orElseW((androidErr) =>
TE.left(
new IntegrityCheckError([iosErr.message, androidErr.message]),
),
androidErr instanceof ExternalServiceError
? TE.left(androidErr)
: TE.left(
new IntegrityCheckError([
iosErr.message,
androidErr.message,
]),
),
),
),
),
Expand Down
Loading