use serverTime and check on setup.js
This commit is contained in:
parent
beaca3e61c
commit
fdd3dfb1d2
@ -38,10 +38,10 @@ export class OvhApi{
|
||||
path,
|
||||
body={},
|
||||
getMethod=rest=>rest.get,
|
||||
header={accept: 'json'}
|
||||
header={accept: 'json'},
|
||||
timestamp = (Date.now()/1000).toFixed()
|
||||
}){
|
||||
if (!this.credentials.consumerKey) await this.getConsumerKey();
|
||||
let timestamp = await this.getApiTime();
|
||||
header['X-Ovh-Timestamp'] = timestamp;
|
||||
header['X-Ovh-Signature'] = await this.getSignature({
|
||||
method: getMethod(this.methods),
|
||||
|
7
setup.js
7
setup.js
@ -14,6 +14,13 @@ if (!store.ovhCredentials.applicationKey || !store.ovhCredentials.applicationSec
|
||||
|
||||
let dns = new OvhApi({credentials: store.ovhCredentials, logs: false});
|
||||
|
||||
let apiTime = await dns.getApiTime();
|
||||
let serverTime = (Date.now()/1000).toFixed();
|
||||
if (apiTime > serverTime+1 || apiTime < serverTime-1){
|
||||
console.error(`serverTime (${serverTime}) and apiTIme (${apiTime}) are different`);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
if (!store.ovhCredentials.consumerKey) await dns.getConsumerKey();
|
||||
|
||||
console.log('list all available records for defined domains =>');
|
||||
|
Loading…
Reference in New Issue
Block a user