[ENG-8498](https://linear.app/comm/issue/ENG-8498/[july]-handle-invalid-device-token).
[ENG-8824](https://linear.app/comm/issue/ENG-8824/biggest-risk-detecting-invalid-device-token-error-from-fcm).
Keyserver code is [here](https://github.com/CommE2E/comm/blob/261f770b836e566e979302042b49b3398746d1f5/keyserver/src/push/utils.js#L33) and [here](https://github.com/CommE2E/comm/blob/261f770b836e566e979302042b49b3398746d1f5/keyserver/src/push/utils.js#L150C21-L150C22).
This is implemented according to the [Detect invalid token responses from the FCM backend](https://firebase.google.com/docs/cloud-messaging/manage-tokens) section in the Firebase docs.
Unfortunately, for `INVALID_ARGUMENT` there are no detailed docs of how the error might look like, the only information is a description of each [ErrorCode](https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode). This is a common issue with Firebase, see e.g. [here](https://github.com/firebase/firebase-js-sdk/issues/8030).
We had two options:
1. Invalidate token for all `INVALID_ARGUMENT` error - don't think this is safe option, this error could be caused by multiple things.
2. Check if the error has a message about an invalid registration token.
The returned error looks like this:
```
{
"error": {
"code": 400,
"message": "The registration token is not a valid FCM registration token",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "INVALID_ARGUMENT"
}
]
}
}
```
Based on what node SDK is doing on a keyserver this approach is basically the same, so I think should be okay.
Depends on D12946