New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stltio/stealth

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stltio/stealth - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

52

index.js

@@ -1,2 +0,2 @@

// import axios from 'axios'
import axios from 'axios'
import jsSHA from 'jssha'

@@ -15,3 +15,3 @@

export default async function stealth() {
export default async function stealth({ apiKey }) {
let start = window.performance.now()

@@ -53,11 +53,45 @@ return Promise.all([

return {
id: new jsSHA('SHA-256', 'TEXT', { encoding: 'UTF8' })
.update(JSON.stringify(local))
.getHash('HEX'),
local,
ms: parseInt(window.performance.now() - start),
remote: {}
const payload = {
local: {
...local,
hash: new jsSHA('SHA-256', 'TEXT', { encoding: 'UTF8' })
.update(JSON.stringify(local))
.getHash('HEX')
}
}
// If apiKey is provided, send the payload to the server (more accurate results)
// Want an API_KEY? Contact us at hello@stlt.io
if (apiKey) {
const axiosInstance = axios.create()
axiosInstance.defaults.withCredentials = true
axiosInstance.defaults.headers.common['x-api-key'] = apiKey
return axiosInstance
.get(`https://api.stlt.io/${payload.local.hash}`)
.then((response) => {
return {
visitorId: response.data.visitorId,
local: payload.local,
ms: parseInt(window.performance.now() - start),
remote: response.data
}
})
.catch((error) => {
console.log(error.message)
return {
visitorId: payload.local.hash,
local: payload.local,
ms: parseInt(window.performance.now() - start),
remote: {}
}
})
} else {
return {
visitorId: payload.local.hash,
local: payload.local,
ms: parseInt(window.performance.now() - start),
remote: {}
}
}
})
}

4

package.json
{
"name": "@stltio/stealth",
"version": "0.1.4",
"version": "0.2.0",
"description": "",

@@ -34,3 +34,3 @@ "main": "index",

"author": "Stlt.io",
"license": "ISC",
"license": "MIT",
"dependencies": {

@@ -37,0 +37,0 @@ "axios": "^1.6.8",

@@ -15,3 +15,3 @@ # Stlt - Stealth

remote: {},
id: 'abc...xyz',
visitorId: 'abc...xyz',
ms: 491

@@ -26,3 +26,3 @@ } = result

const [data, setData] = useState({ local: {}, remote: {}, id: '', ms: 0 })
const [data, setData] = useState({ local: {}, remote: {}, visitorId: '', ms: 0 })

@@ -29,0 +29,0 @@ useEffect(() => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc