From 335dfd350433be80c9a5482997c72067af6427a9 Mon Sep 17 00:00:00 2001 From: Juan P Lopez Date: Thu, 14 Nov 2024 14:59:06 -0500 Subject: [PATCH] fix(core): update notifications device token validation length --- core/api/src/domain/users/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/api/src/domain/users/index.ts b/core/api/src/domain/users/index.ts index d352278930..c90ea6c0db 100644 --- a/core/api/src/domain/users/index.ts +++ b/core/api/src/domain/users/index.ts @@ -56,11 +56,15 @@ export const checkedToNonEmptyLanguage = ( } export const checkedToDeviceToken = (token: string): DeviceToken | ValidationError => { - // token from firebase have a length of 163 - const correctLength = 163 - if (token.length !== correctLength) { + // iOS tokens: 64 chars (min) + // Android tokens: up to 200 chars (max) + // Firebase: 142 chars but it is variable + const minLength = 64 + const maxLength = 200 + + if (token.length < minLength || token.length > maxLength) { return new InvalidDeviceTokenError( - `wrong length, expected ${correctLength}, got ${token.length}`, + `Invalid token length. Expected between ${minLength}-${maxLength}, got ${token.length}`, ) }