Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spotify-local-control

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spotify-local-control - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

37

index.js

@@ -6,2 +6,3 @@ const https = require('https')

const randomString = require('random-string')
const portscanner = require('portscanner')

@@ -52,6 +53,4 @@ module.exports = connect

function localApi () {
const endpoint = `https://${randomString({length: 10})}.spotilocal.com:4370`
var csrfAndOuathAndEndpoints
var csrfAndOuath
return {

@@ -61,8 +60,18 @@ // send request to local spotify client

get (path, query = {}) {
csrfAndOuath = csrfAndOuath || Promise.all([
getCsrfToken(),
getOauthToken()
])
csrfAndOuathAndEndpoints = csrfAndOuathAndEndpoints || Promise.all([
getOauthToken(),
findPort()
])
.then(function ([oauth, port]) {
const endpoint = `https://${randomString({length: 10})}.spotilocal.com:${port}`
return csrfAndOuath.then(([csrf, oauth]) => get(endpoint + path, {
return Promise.all([
oauth,
getCsrfToken({endpoint: endpoint}),
endpoint
])
})
return csrfAndOuathAndEndpoints.then(([oauth, csrf, endpoint]) => get(endpoint + path, {
headers: {

@@ -76,5 +85,15 @@ 'Origin': 'https://open.spotify.com'

// find port sportify webhelper is running on
// null -> int
function findPort () {
return new Promise(function (resolve, reject) {
portscanner.findAPortInUse(4370, 4380, '127.0.0.1', function(error, port) {
error ? reject(error) : resolve(port)
})
})
}
// fetch csrf token
// null -> promise
function getCsrfToken () {
function getCsrfToken ({endpoint: endpoint}) {
return get(endpoint + '/simplecsrf/token.json', {

@@ -81,0 +100,0 @@ headers: {

{
"name": "spotify-local-control",
"version": "1.0.0",
"version": "1.0.1",
"description": "Control a local spotify client via spotify-webhelper",

@@ -20,4 +20,5 @@ "main": "index.js",

"random-string": "^0.1.2",
"url-parse-lax": "^1.0.0"
"url-parse-lax": "^1.0.0",
"portscanner": "^2.1.1"
}
}

@@ -38,2 +38,5 @@ # spotify-local-control [![stability][0]][1]

## See Also
- [spotify-find](https://github.com/f-mer/spotify-find) - get spotify catalog information
## License

@@ -40,0 +43,0 @@ [MIT](https://tldrlegal.com/license/mit-license)

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