@plattar/plattar-api
Advanced tools
Comparing version 1.90.1 to 1.90.2-dev
101
index.js
@@ -1,5 +0,100 @@ | ||
function plattar() { | ||
console.log('init plattar'); | ||
const got = require('got'); | ||
'use strict'; | ||
class Plattar { | ||
constructor() { | ||
this._authToken = undefined; | ||
this._serverLocation = undefined; | ||
} | ||
get server() { | ||
return { | ||
prod: 'https://app.plattar.com/api/v2/', | ||
staging: 'https://staging.plattar.space/api/v2/', | ||
dev: 'https://localhost/api/v2/' | ||
}; | ||
} | ||
get authToken() { | ||
return this._authToken; | ||
} | ||
get originLocation() { | ||
return this._serverLocation; | ||
} | ||
auth(token, opt) { | ||
const copt = opt || { validate: false }; | ||
return new Promise((resolve, reject) => { | ||
const server = this.originLocation; | ||
if (!server) { | ||
reject(new Error('Plattar.auth(token) - cannot authenticate as server not set via Plattar.origin(server)')); | ||
return; | ||
} | ||
if (!token) { | ||
reject(new Error('Plattar.auth(token) - token variable is undefined')); | ||
return; | ||
} | ||
if (!copt.validate) { | ||
this._authToken = { | ||
'plattar-auth-token': token | ||
}; | ||
resolve(this); | ||
return; | ||
} | ||
const validate = server + 'plattaruser/xauth/validate'; | ||
const options = { | ||
headers: { | ||
'plattar-auth-token': token | ||
} | ||
}; | ||
got.get(validate, options).then((response) => { | ||
this._authToken = { | ||
'plattar-auth-token': token | ||
}; | ||
resolve(this); | ||
}).catch((error) => { | ||
reject(new Error('Plattar.auth(token) - failed to validate authentication token at ' + validate)); | ||
}); | ||
}); | ||
} | ||
origin(server, opt) { | ||
const copt = opt || { validate: false }; | ||
return new Promise((resolve, reject) => { | ||
if (!server) { | ||
reject(new Error('Plattar.origin(server) - server variable is undefined')); | ||
return; | ||
} | ||
if (!copt.validate) { | ||
this._serverLocation = server; | ||
resolve(this); | ||
return; | ||
} | ||
const ping = server + 'ping'; | ||
got.get(ping).then((response) => { | ||
this._serverLocation = server; | ||
resolve(this); | ||
}).catch((error) => { | ||
reject(new Error('Plattar.origin(server) - failed to ping server at ' + ping)); | ||
}); | ||
}); | ||
} | ||
} | ||
module.exports = plattar; | ||
module.exports = new Plattar(); |
{ | ||
"name": "@plattar/plattar-api", | ||
"version": "1.90.1", | ||
"version": "1.90.2-dev", | ||
"description": "Module for interfacing with the Plattar API (https://www.plattar.com)", | ||
@@ -30,3 +30,6 @@ "main": "index.js", | ||
}, | ||
"homepage": "https://github.com/Plattar/plattar-api#readme" | ||
"homepage": "https://github.com/Plattar/plattar-api#readme", | ||
"dependencies": { | ||
"got": "^11.5.2" | ||
} | ||
} |
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
9546
3
77
1
2
+ Addedgot@^11.5.2
+ Added@sindresorhus/is@4.6.0(transitive)
+ Added@szmarczak/http-timer@4.0.6(transitive)
+ Added@types/cacheable-request@6.0.3(transitive)
+ Added@types/http-cache-semantics@4.0.4(transitive)
+ Added@types/keyv@3.1.4(transitive)
+ Added@types/node@22.10.7(transitive)
+ Added@types/responselike@1.0.3(transitive)
+ Addedcacheable-lookup@5.0.4(transitive)
+ Addedcacheable-request@7.0.4(transitive)
+ Addedclone-response@1.0.3(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddefer-to-connect@2.0.1(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedgot@11.8.6(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedhttp2-wrapper@1.0.3(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlowercase-keys@2.0.0(transitive)
+ Addedmimic-response@1.0.13.1.0(transitive)
+ Addednormalize-url@6.1.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-cancelable@2.1.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedquick-lru@5.1.1(transitive)
+ Addedresolve-alpn@1.2.1(transitive)
+ Addedresponselike@2.0.1(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedwrappy@1.0.2(transitive)