Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
contrast-color
Advanced tools
Determines the best contrast color to use. Give it a background color and it returns a foreground color (black or white by default but customizable).
Determines the best contrast color to use. Give it a background color and it returns a foreground color (black or white by default but customizable).
$ npm install contrast-color
// Use via class instance
const ContrastColor = require('contrast-color');
const cc = ContrastColor({
bgColor: 'navy',
fgDarkColor: 'water',
fgLightColor: 'navy',
fgDarkColor: '#0570E3',
customNamedColors: {
water: '#00D0FF'
}
});
const defaultFgColor = cc.contrastColor();
const inverseFgColor = cc.contrastColor({ bgColor: 'water' });
const hasAquaBgColor = cc.contrastColor({ bgColor: 'aqua' });
/* Results
{
defaultFgColor: '#000080',
inverseFgColor: '#0570E3',
hasAquaBgColor: '#0570E3'
}
*/
// OR ...
// Use via static method
const { contrastColor } = require('contrast-color');
const hasRedBg = contrastColor({ bgColor: '#f00' });
const hasRedBgWithBlackFg = contrastColor({ bgColor: '#f00', threshold: 76 });
const hasYellowBg = contrastColor({ bgColor: 'yellow' });
const hasWhiteBgWithGreenFg = contrastColor({ fgDarkColor: '#008000' });
const hasBlackBgWithLimeFg = contrastColor({ bgColor: '#000000', fgLightColor: 'lime' });
const hasKitchenSink = contrastColor({
bgColor: '#808080',
fgDarkColor: 'dirty',
fgLightColor: 'clean',
threshold: 129,
customNamedColors: {
dirty: '#f90',
clean: '#ff99ff'
}
});
/* Results:
{
hasRedBg: '#FFFFFF',
hasRedBgWithBlackFg: '#000000',
hasYellowBg: '#000000',
hasWhiteBgWithGreenFg: '#008000',
hasBlackBgWithLimeFg: '#00FF00',
hasKitchenSink: '#ff99ff'
}
*/
Optional
: Object
with parameters to use.
Optional
: String
hex or named (e.g.#ff0000
, red
)Default
: #FFFFFF
Is returned if bgColor
is determined to be light
Optional
: String
hex or named (e.g.#ff0000
, red
)Default
: #000000
Is returned if bgColor
is determined to be dark
Optional
: String
hex or named (e.g.#ff0000
, red
)Default
: #FFFFFF
Is returned if bgColor
is determined to be invalid
Optional
: String
hex or named (e.g.#ff0000
, red
)Default
: #000000
Optional
: Number
(0-255) used to adjust varianceDefault
: 128
Optional
: Object
used to override or add named colors (e.g. { blue: "#0074D9" }
)Requrired
: Object
with parameters to use.
Required
: String
hex or named (e.g.#ff0000
, red
)Is returned if bgColor
is determined to be light
Optional
: String
hex or named (e.g.#ff0000
, red
)Default
: #000000
Is returned if bgColor
is determined to be dark
Optional
: String
hex or named (e.g.#ff0000
, red
)Default
: #FFFFFF
Is returned if bgColor
is determined to be invalid
Optional
: String
hex or named (e.g.#ff0000
, red
)Default
: #000000
Optional
: Number
(0-255) used to adjust varianceDefault
: 128
Optional
: Object
used to override or add named colors (e.g. { blue: "#0074D9" }
)ISC © Buster Collings
FAQs
Determines the best contrast color to use. Give it a background color and it returns a foreground color (black or white by default but customizable).
The npm package contrast-color receives a total of 5,645 weekly downloads. As such, contrast-color popularity was classified as popular.
We found that contrast-color demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.