INNER CODE UNIT · TypeScript
hasWriteToken
jonasstrehle/supercookie · server/main.ts:274
const hasWriteToken = (token: string): boolean => midSet.has(token);
/**
* @description
* When navigating to path /read the mode of an (known) visitor is set to "write".
* Assuming that the data has already been written to the browser, the webserver
* is redirecting the user to the first route.
*/
webserver_2.get("/read", (_req: express.Request, res: express.Response) => {
const uid = generateUUID();
console.info(`supercookie | Visitor uid='${uid}' is known • Read`);
const profile: Profile = Profile.from(uid);
profile._setStorageSize(Math.floor(Math.log2(STORAGE.index ?? 1)) + 1);
if (profile === null)
return res.redirect("/read");
Webserver.setCookie(res, "uid", uid);
res.redirect(`/t/${Webserver.getRouteByIndex(0)}?f=${generateUUID()}`)
});