-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(core): add custom key encoder and deprecate insecureHash #8379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
8ca6a35
bbef53f
1b208fe
76fe3a2
4d174fb
3b33656
57fdc65
4836258
13e46b6
938dfe7
d9b7b2a
9bfc828
178996f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,6 +412,19 @@ Sha1.prototype.arrayBuffer = function () { | |
return buffer; | ||
}; | ||
|
||
/** | ||
* @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder. | ||
* This function will be removed in a future version. | ||
*/ | ||
export const insecureHash = (message) => { | ||
console.warn( | ||
|
||
"Using default key encoder: SHA-1 is *not* collision-resistant. " + | ||
"While acceptable for most cache scenarios, a motivated attacker " + | ||
"can craft two different payloads that map to the same cache key. " + | ||
"If that risk matters in your environment, supply a stronger " + | ||
"encoder (e.g. SHA-3) by calling the `makeDefaultKeyEncoder()` method. " + | ||
"If you change the key encoder, consider also creating a new cache, " + | ||
"to avoid (the potential for) collisions with existing keys." | ||
); | ||
return new Sha1(true).update(message)["hex"](); | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.