Introduce canvasPixelTest() intended to validate canvas functionality

Browsers and plugins that spoof canvas data produce corrupt images. In attempt to mitigate:

* Add canvasPixelTest() to test a single pixel and test the RGB values
* Test canvasPixelTest() inside generateInitialsImage() and use default `/user.png` if failure detected
* Call canvasPixelTest() directly within settings to avoid setting an invalid image
* Use toast.error() with 10 second autoClose
This commit is contained in:
Self Denial 2024-04-05 16:04:00 -06:00
parent c8f7bb990c
commit ac9308dbed
3 changed files with 55 additions and 3 deletions

View file

@ -5,7 +5,7 @@
import { WEBUI_NAME, config, user } from '$lib/stores';
import { onMount, getContext } from 'svelte';
import { toast } from 'svelte-sonner';
import { generateInitialsImage } from '$lib/utils';
import { generateInitialsImage, canvasPixelTest } from '$lib/utils';
const i18n = getContext('i18n');
@ -43,6 +43,12 @@
}
);
if (!canvasPixelTest()) {
toast.error("Canvas pixel test failed, fingerprint evasion likely. Default image used.", {
autoClose: 1000 * 10,
});
}
await setSessionUser(sessionUser);
};