Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
5694f166
Commit
5694f166
authored
Apr 05, 2024
by
Danny Liu
Browse files
style: run npm run format
parent
a68b95c9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
16 deletions
+27
-16
src/lib/components/chat/Settings/Account.svelte
src/lib/components/chat/Settings/Account.svelte
+6
-3
src/lib/utils/index.ts
src/lib/utils/index.ts
+19
-11
src/routes/auth/+page.svelte
src/routes/auth/+page.svelte
+2
-2
No files found.
src/lib/components/chat/Settings/Account.svelte
View file @
5694f166
...
...
@@ -151,9 +151,12 @@
if (canvasPixelTest()) {
profileImageUrl = generateInitialsImage(name);
} else {
toast.error("Canvas pixel test failed, fingerprint evasion likely. Disable fingerprint evasion and try again!", {
autoClose: 1000 * 10,
});
toast.error(
'Canvas pixel test failed, fingerprint evasion likely. Disable fingerprint evasion and try again!',
{
autoClose: 1000 * 10
}
);
}
}}>{$i18n.t('Use Gravatar')}</button
>
...
...
src/lib/utils/index.ts
View file @
5694f166
...
...
@@ -99,7 +99,7 @@ export const getGravatarURL = (email) => {
export
const
canvasPixelTest
=
()
=>
{
// Test a 1x1 pixel to potentially identify browser/plugin fingerprint blocking or spoofing
// Inspiration: https://github.com/kkapsner/CanvasBlocker/blob/master/test/detectionTest.js
const
canvas
=
document
.
createElement
(
"
canvas
"
);
const
canvas
=
document
.
createElement
(
'
canvas
'
);
const
ctx
=
canvas
.
getContext
(
'
2d
'
);
canvas
.
height
=
1
;
canvas
.
width
=
1
;
...
...
@@ -107,11 +107,10 @@ export const canvasPixelTest = () => {
const
pixelValues
=
imageData
.
data
;
// Generate RGB test data
for
(
let
i
=
0
;
i
<
imageData
.
data
.
length
;
i
+=
1
){
if
(
i
%
4
!==
3
){
for
(
let
i
=
0
;
i
<
imageData
.
data
.
length
;
i
+=
1
)
{
if
(
i
%
4
!==
3
)
{
pixelValues
[
i
]
=
Math
.
floor
(
256
*
Math
.
random
());
}
else
{
}
else
{
pixelValues
[
i
]
=
255
;
}
}
...
...
@@ -120,16 +119,23 @@ export const canvasPixelTest = () => {
const
p
=
ctx
.
getImageData
(
0
,
0
,
canvas
.
width
,
canvas
.
height
).
data
;
// Read RGB data and fail if unmatched
for
(
let
i
=
0
;
i
<
p
.
length
;
i
+=
1
){
if
(
p
[
i
]
!==
pixelValues
[
i
]){
console
.
log
(
"
canvasPixelTest: Wrong canvas pixel RGB value detected:
"
,
p
[
i
],
"
at:
"
,
i
,
"
expected:
"
,
pixelValues
[
i
]);
console
.
log
(
"
canvasPixelTest: Canvas blocking or spoofing is likely
"
);
for
(
let
i
=
0
;
i
<
p
.
length
;
i
+=
1
)
{
if
(
p
[
i
]
!==
pixelValues
[
i
])
{
console
.
log
(
'
canvasPixelTest: Wrong canvas pixel RGB value detected:
'
,
p
[
i
],
'
at:
'
,
i
,
'
expected:
'
,
pixelValues
[
i
]
);
console
.
log
(
'
canvasPixelTest: Canvas blocking or spoofing is likely
'
);
return
false
;
}
}
return
true
;
}
}
;
export
const
generateInitialsImage
=
(
name
)
=>
{
const
canvas
=
document
.
createElement
(
'
canvas
'
);
...
...
@@ -138,7 +144,9 @@ export const generateInitialsImage = (name) => {
canvas
.
height
=
100
;
if
(
!
canvasPixelTest
())
{
console
.
log
(
"
generateInitialsImage: failed pixel test, fingerprint evasion is likely. Using default image.
"
);
console
.
log
(
'
generateInitialsImage: failed pixel test, fingerprint evasion is likely. Using default image.
'
);
return
'
/user.png
'
;
}
...
...
src/routes/auth/+page.svelte
View file @
5694f166
...
...
@@ -44,8 +44,8 @@
);
if (!canvasPixelTest()) {
toast.error(
"
Canvas pixel test failed, fingerprint evasion likely. Default image used.
"
, {
autoClose: 1000 * 10
,
toast.error(
'
Canvas pixel test failed, fingerprint evasion likely. Default image used.
'
, {
autoClose: 1000 * 10
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment