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

@plattar/plattar-api

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plattar/plattar-api - npm Package Compare versions

Comparing version 1.90.1 to 1.90.2-dev

.DS_Store

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();

7

package.json
{
"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"
}
}
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