directus-sdk-javascript
Advanced tools
Comparing version 3.0.0-13 to 3.0.0-14
{ | ||
"name": "directus-sdk-javascript", | ||
"version": "3.0.0-13", | ||
"version": "3.0.0-14", | ||
"description": "WIP - Directus SDK for JavaScript (Node and Browser)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -36,12 +36,8 @@ const axios = require('axios'); | ||
if (accessToken && accessToken.length > 0) { | ||
const payloadBase64 = accessToken.split('.')[1].replace('-', '+').replace('_', '/'); | ||
const pd = JSON.parse(base64.decode(payloadBase64)); | ||
const payloadBase64 = accessToken.split('.')[1].replace('-', '+').replace('_', '/'); | ||
const pd = JSON.parse(base64.decode(payloadBase64)); | ||
const exp = new Date(pd.exp * 1000); | ||
const exp = new Date(pd.exp * 1000); | ||
return Object.assign({}, pd, { exp }); | ||
} | ||
return null; | ||
return Object.assign({}, pd, { exp }); | ||
} | ||
@@ -92,12 +88,13 @@ | ||
login({ email, password, url, database }) { | ||
this.emit('login'); | ||
return new Promise((resolve, reject) => { | ||
this.emit('login'); | ||
if (this.loggedIn) { | ||
this.emit('login:success'); | ||
} | ||
if (this.loggedIn) { | ||
return this.emit('login:success'); | ||
} | ||
if (url) this.url = url; | ||
if (database) this.database = database; | ||
if (url) this.url = url; | ||
if (database) this.database = database; | ||
this.getToken({ email, password }) | ||
this.getToken({ email, password }) | ||
.then(res => res.data) | ||
@@ -110,3 +107,3 @@ .then(data => { | ||
if (timeDiff < 30000 && state.loading === false) { | ||
if (timeDiff < 30000) { | ||
this.refresh(this.accessToken); | ||
@@ -117,4 +114,9 @@ } | ||
this.emit('login:success'); | ||
resolve(); | ||
}) | ||
.catch(error => this.emit('login:failed', error)); | ||
.catch((error) => { | ||
this.emit('login:failed', error); | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
@@ -121,0 +123,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
41599
160
0