fms-api-client
Advanced tools
Comparing version
{ | ||
"name": "fms-api-client", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "A FileMaker Data API client designed to allow easier interaction with a FileMaker database from a web environment.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -403,2 +403,3 @@ 'use strict'; | ||
function watch() { | ||
this.connection.clear(); | ||
if (this.queue.length > 0) { | ||
@@ -405,0 +406,0 @@ this.shift(); |
@@ -137,4 +137,7 @@ 'use strict'; | ||
login() { | ||
return this.agent.connection.start( | ||
!_.isEmpty(this.agent.agent) ? this.agent.localize() : false | ||
return new Promise((resolve, reject) => | ||
this.agent.connection | ||
.start(!_.isEmpty(this.agent.agent) ? this.agent.localize() : false) | ||
.then(response => resolve(response)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
@@ -153,6 +156,9 @@ } | ||
logout(id) { | ||
return this.agent.connection | ||
.end(!_.isEmpty(this.agent.agent) ? this.agent.localize() : false, id) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)); | ||
return new Promise((resolve, reject) => | ||
this.agent.connection | ||
.end(!_.isEmpty(this.agent.agent) ? this.agent.localize() : false, id) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(resolve(body))) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -167,5 +173,6 @@ /** | ||
productInfo() { | ||
return productInfo( | ||
this.agent.connection.server, | ||
this.agent.connection.version | ||
return new Promise((resolve, reject) => | ||
productInfo(this.agent.connection.server, this.agent.connection.version) | ||
.then(response => resolve(response)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
@@ -188,7 +195,6 @@ } | ||
sessions: this.agent.connection.sessions.map( | ||
({ issued, expires, id, active }) => ({ | ||
({ issued, expires, id }) => ({ | ||
issued, | ||
expires, | ||
id, | ||
active | ||
id | ||
}) | ||
@@ -241,6 +247,10 @@ ) | ||
databases(credentials, version) { | ||
return databases( | ||
this.agent.connection.server, | ||
credentials || this.agent.connection.credentials, | ||
this.agent.connection.version | ||
return new Promise((resolve, reject) => | ||
databases( | ||
this.agent.connection.server, | ||
credentials || this.agent.connection.credentials, | ||
this.agent.connection.version | ||
) | ||
.then(response => resolve(response)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
@@ -258,18 +268,21 @@ } | ||
layouts(parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.layouts( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
this.agent.connection.version | ||
), | ||
method: 'get' | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => body.response); | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.layouts( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
this.agent.connection.version | ||
), | ||
method: 'get' | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => resolve(body.response)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -286,19 +299,22 @@ | ||
scripts(parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.scripts( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
this.agent.connection.version | ||
), | ||
method: 'get' | ||
}, | ||
parameters | ||
) | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.scripts( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
this.agent.connection.version | ||
), | ||
method: 'get' | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => body.response); | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => resolve(body.response)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -316,20 +332,23 @@ | ||
layout(layout, parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.layout( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
params: toStrings(sanitizeParameters(parameters, ['recordId'])) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => body.response); | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.layout( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
params: toStrings(sanitizeParameters(parameters, ['recordId'])) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => resolve(body.response)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -348,33 +367,36 @@ | ||
duplicate(layout, recordId, parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.duplicate( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
recordId, | ||
this.agent.connection.version | ||
), | ||
method: 'post', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.duplicate( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
recordId, | ||
this.agent.connection.version | ||
), | ||
method: 'post', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
data: sanitizeParameters(parameters, [ | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'request' | ||
]) | ||
}, | ||
data: sanitizeParameters(parameters, [ | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'request' | ||
]) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)); | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)) | ||
.then(result => resolve(result)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -406,39 +428,41 @@ | ||
create(layout, data = {}, parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.create( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
this.agent.connection.version | ||
), | ||
method: 'post', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.create( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
this.agent.connection.version | ||
), | ||
method: 'post', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
data: Object.assign( | ||
sanitizeParameters(parameters, [ | ||
'portalData', | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'request' | ||
]), | ||
this.data.incoming(setData(data)) | ||
) | ||
}, | ||
data: Object.assign( | ||
sanitizeParameters(parameters, [ | ||
'portalData', | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'request' | ||
]), | ||
this.data.incoming(setData(data)) | ||
) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)) | ||
.then(response => | ||
parameters.merge ? Object.assign(data, response) : response | ||
); | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)) | ||
.then(response => | ||
resolve(parameters.merge ? Object.assign(data, response) : response) | ||
) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -458,43 +482,47 @@ | ||
edit(layout, recordId, data, parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.update( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
recordId, | ||
this.agent.connection.version | ||
), | ||
method: 'patch', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.update( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
recordId, | ||
this.agent.connection.version | ||
), | ||
method: 'patch', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
data: Object.assign( | ||
sanitizeParameters(parameters, [ | ||
'portalData', | ||
'modId', | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'request' | ||
]), | ||
this.data.incoming(setData(data)) | ||
) | ||
}, | ||
data: Object.assign( | ||
sanitizeParameters(parameters, [ | ||
'portalData', | ||
'modId', | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'request' | ||
]), | ||
this.data.incoming(setData(data)) | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)) | ||
.then(body => | ||
resolve( | ||
parameters.merge | ||
? Object.assign(data, { recordId: recordId }, body) | ||
: body | ||
) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)) | ||
.then(body => | ||
parameters.merge | ||
? Object.assign(data, { recordId: recordId }, body) | ||
: body | ||
); | ||
) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -513,29 +541,33 @@ | ||
delete(layout, recordId, parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.delete( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
recordId, | ||
this.agent.connection.version | ||
), | ||
method: 'delete', | ||
data: sanitizeParameters(parameters, [ | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'request' | ||
]) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)); | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.delete( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
recordId, | ||
this.agent.connection.version | ||
), | ||
method: 'delete', | ||
data: sanitizeParameters(parameters, [ | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'request' | ||
]) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)) | ||
.then(result => resolve(result)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -554,35 +586,39 @@ | ||
get(layout, recordId, parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.get( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
recordId, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
params: toStrings( | ||
sanitizeParameters(namespace(parameters), [ | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'layout.response', | ||
'portal', | ||
'_offset.*', | ||
'_limit.*', | ||
'request' | ||
]) | ||
) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)); | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.get( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
recordId, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
params: toStrings( | ||
sanitizeParameters(namespace(parameters), [ | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'layout.response', | ||
'portal', | ||
'_offset.*', | ||
'_limit.*', | ||
'request' | ||
]) | ||
) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)) | ||
.then(result => resolve(result)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -600,40 +636,44 @@ | ||
list(layout, parameters = {}) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.list( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.list( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
params: toStrings( | ||
sanitizeParameters(namespace(parameters), [ | ||
'_limit', | ||
'_offset', | ||
'_sort', | ||
'portal', | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'layout.response', | ||
'_offset.*', | ||
'_limit.*', | ||
'request' | ||
]) | ||
) | ||
}, | ||
params: toStrings( | ||
sanitizeParameters(namespace(parameters), [ | ||
'_limit', | ||
'_offset', | ||
'_sort', | ||
'portal', | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'layout.response', | ||
'_offset.*', | ||
'_limit.*', | ||
'request' | ||
]) | ||
) | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)); | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => parseScriptResult(body)) | ||
.then(result => resolve(result)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -693,4 +733,5 @@ | ||
.then(body => parseScriptResult(body)) | ||
.then(response => resolve(response)) | ||
.then(result => resolve(result)) | ||
.catch(error => { | ||
this._save(); | ||
return error.code === '401' | ||
@@ -716,22 +757,25 @@ ? resolve({ | ||
globals(data, parameters) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.globals( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
this.agent.connection.version | ||
), | ||
method: 'patch', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.globals( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
this.agent.connection.version | ||
), | ||
method: 'patch', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
data: { globalFields: toStrings(data) } | ||
}, | ||
data: { globalFields: toStrings(data) } | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => body.response); | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(result => resolve(result)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -807,3 +851,3 @@ | ||
.then(response => resolve(response)) | ||
.catch(error => reject(error)); | ||
.catch(error => this._save(reject(error))); | ||
}); | ||
@@ -826,46 +870,50 @@ } | ||
run(layout, scripts, parameters, request) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.list( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.list( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
params: sanitizeParameters( | ||
Object.assign( | ||
Array.isArray(scripts) | ||
? { scripts } | ||
: isJSON(scripts) | ||
? { scripts: [scripts] } | ||
: { script: scripts }, | ||
typeof scripts === 'string' && typeof parameters !== 'undefined' | ||
? { 'script.param': parameters } | ||
: {}, | ||
namespace({ limit: 1 }) | ||
), | ||
[ | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'_limit' | ||
] | ||
) | ||
}, | ||
params: sanitizeParameters( | ||
Object.assign( | ||
Array.isArray(scripts) | ||
? { scripts } | ||
: isJSON(scripts) | ||
? { scripts: [scripts] } | ||
: { script: scripts }, | ||
typeof scripts === 'string' && typeof parameters !== 'undefined' | ||
? { 'script.param': parameters } | ||
: {}, | ||
namespace({ limit: 1 }) | ||
), | ||
[ | ||
'script', | ||
'script.param', | ||
'script.prerequest', | ||
'script.prerequest.param', | ||
'script.presort', | ||
'script.presort.param', | ||
'_limit' | ||
] | ||
) | ||
}, | ||
typeof scripts === 'string' && typeof parameters !== 'undefined' | ||
? request | ||
: parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => pick(parseScriptResult(body), 'scriptResult')); | ||
typeof scripts === 'string' && typeof parameters !== 'undefined' | ||
? request | ||
: parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => pick(parseScriptResult(body), 'scriptResult')) | ||
.then(result => resolve(result)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -885,35 +933,39 @@ | ||
script(layout, script, param = {}, parameters) { | ||
return this.agent | ||
.request( | ||
{ | ||
url: urls.script( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
script, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
return new Promise((resolve, reject) => | ||
this.agent | ||
.request( | ||
{ | ||
url: urls.script( | ||
this.agent.connection.server, | ||
this.agent.connection.database, | ||
layout, | ||
script, | ||
this.agent.connection.version | ||
), | ||
method: 'get', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
params: !isEmpty(param) | ||
? { | ||
'script.param': isJSON(param) | ||
? JSON.stringify(param) | ||
: param.toString() | ||
} | ||
: param | ||
}, | ||
params: !isEmpty(param) | ||
? { | ||
'script.param': isJSON(param) | ||
? JSON.stringify(param) | ||
: param.toString() | ||
} | ||
: param | ||
}, | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => ({ | ||
...body.response, | ||
scriptResult: isJSON(body.response.scriptResult) | ||
? JSON.parse(body.response.scriptResult) | ||
: body.response.scriptResult | ||
})); | ||
parameters | ||
) | ||
.then(response => response.data) | ||
.then(body => this.data.outgoing(body)) | ||
.then(body => this._save(body)) | ||
.then(body => ({ | ||
...body.response, | ||
scriptResult: isJSON(body.response.scriptResult) | ||
? JSON.parse(body.response.scriptResult) | ||
: body.response.scriptResult | ||
})) | ||
.then(result => resolve(result)) | ||
.catch(error => this._save(reject(error))) | ||
); | ||
} | ||
@@ -920,0 +972,0 @@ } |
@@ -109,3 +109,7 @@ 'use strict'; | ||
return new Promise((resolve, reject) => { | ||
const sessions = _.sortBy(this.sessions, ['active', 'used'], ['desc']); | ||
const sessions = _.sortBy( | ||
this.sessions.filter(session => !session.expired()), | ||
['active', 'used'], | ||
['desc'] | ||
); | ||
const session = sessions[0]; | ||
@@ -134,3 +138,3 @@ session.active = true; | ||
ready() { | ||
return this.sessions.length > 0; | ||
return this.sessions.filter(session => !session.expired()).length > 0; | ||
} | ||
@@ -271,3 +275,3 @@ | ||
typeof header === 'string' | ||
? header.replace('Bearer ', '') !== session.token && !session.expired() | ||
? header.replace('Bearer ', '') !== session.token | ||
: !session.expired() | ||
@@ -274,0 +278,0 @@ ); |
Sorry, the diff of this file is too big to display
2955
2.07%202457
-3.44%2604
-3.3%