feat: reject token if it's not valid

This commit is contained in:
2024-06-15 06:26:13 -04:00
parent dfd709ad1c
commit 5d528fba52
12 changed files with 368 additions and 16 deletions

View File

@@ -2,6 +2,8 @@ import type { TokenOptions } from "gtoken";
import { mock } from "bun:test";
import type { AdminSdkCredentials } from "~/libs/fcm/getGoogleAuthToken";
const emailRegex =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
@@ -27,4 +29,12 @@ class MockGoogleToken {
}
}
mock.module("gtoken", () => ({ GoogleToken: MockGoogleToken }));
mock.module("src/libs/fcm/getGoogleAuthToken", () => {
return {
getGoogleAuthToken: (adminSdkJson: AdminSdkCredentials) => {
return new MockGoogleToken({
email: adminSdkJson.clientEmail,
}).getToken();
},
};
});