@maildrop/api
Advanced tools
Comparing version 1.0.7 to 1.0.9
const axios = require("axios"); | ||
const moment = require("moment"); | ||
const url = require("url"); | ||
@@ -13,4 +12,4 @@ | ||
// api key expiry | ||
apiKeyExpiry: "1970-01-01", | ||
// api key expiry timestamp | ||
apiKeyExpiry: 0, | ||
@@ -76,3 +75,3 @@ /** | ||
async getApiKey() { | ||
if (!this.apiKey || moment().isAfter(this.apiKeyExpiry)) { | ||
if (!this.apiKey || this.apiKeyExpiry < new Date().getTime()) { | ||
const { data: html } = await axios.get(this.webHost); | ||
@@ -83,3 +82,3 @@ const { data: js } = await axios.get( | ||
this.apiKey = js.match(/x-api-key":"([^"]+)/)[1]; | ||
this.apiKeyExpiry = moment().add(60, "minutes").toDate(); // every 1 hour renew apiKey logic | ||
this.apiKeyExpiry = new Date().getTime() + 2 * 60 * 60 * 1000; // expired in 2 hour | ||
} | ||
@@ -86,0 +85,0 @@ return this.apiKey; |
{ | ||
"dependencies": { | ||
"axios": "^0.19.2", | ||
"moment": "^2.24.0", | ||
"url": "^0.11.0" | ||
@@ -10,5 +9,7 @@ }, | ||
"anonymous", | ||
"disposable-email", | ||
"email", | ||
"fetch", | ||
"maildrop" | ||
"maildrop", | ||
"temporary-email" | ||
], | ||
@@ -21,3 +22,3 @@ "main": "main.js", | ||
}, | ||
"version": "1.0.7" | ||
"version": "1.0.9" | ||
} |
2
4712
81
- Removedmoment@^2.24.0
- Removedmoment@2.30.1(transitive)