@maildrop/api
Advanced tools
Comparing version 1.0.21 to 1.0.23
62
main.js
@@ -1,3 +0,2 @@ | ||
const axios = require("axios"); | ||
const bigInteger = require("big-integer"); | ||
const fetch = require("cross-fetch"); | ||
const url = require("url"); | ||
@@ -27,10 +26,13 @@ | ||
const alias = email.replace(/@maildrop.cc$/, ""); | ||
const options = { headers: { "x-api-key": await this.getApiKey() } }; | ||
const options = { | ||
headers: { "x-api-key": await this.getApiKey() }, | ||
method: "DELETE", | ||
}; | ||
const { data } = await axios.delete( | ||
url.resolve(this.apiHost, `${this.apiRelativePath}/${alias}/${id}`), | ||
options | ||
); | ||
return data; | ||
return await ( | ||
await fetch( | ||
url.resolve(this.apiHost, `${this.apiRelativePath}/${alias}/${id}`), | ||
options | ||
) | ||
).json(); | ||
}, | ||
@@ -51,15 +53,19 @@ | ||
const { data: inbox } = await axios.get( | ||
url.resolve(this.apiHost, `${this.apiRelativePath}/${alias}`), | ||
options | ||
); | ||
const inbox = await ( | ||
await fetch( | ||
url.resolve(this.apiHost, `${this.apiRelativePath}/${alias}`), | ||
options | ||
) | ||
).json(); | ||
for (const message of inbox.messages) { | ||
const { data } = await axios.get( | ||
url.resolve( | ||
this.apiHost, | ||
`${this.apiRelativePath}/${alias}/${message.id}` | ||
), | ||
options | ||
); | ||
const data = await ( | ||
await fetch( | ||
url.resolve( | ||
this.apiHost, | ||
`${this.apiRelativePath}/${alias}/${message.id}` | ||
), | ||
options | ||
) | ||
).json(); | ||
@@ -82,9 +88,17 @@ // contains raw body & html | ||
if (force || !this.apiKey || this.apiKeyExpiry < new Date().getTime()) { | ||
const { data: html } = await axios.get(this.webHost); | ||
const { data: js } = await axios.get( | ||
url.resolve(this.webHost, html.match(/([^"]+static\/js\/main[^"]+)/)[1]) | ||
); | ||
const html = await (await fetch(this.webHost)).text(); | ||
const js = await ( | ||
await fetch( | ||
url.resolve( | ||
this.webHost, | ||
html.match(/([^"]+static\/js\/main[^"]+)/)[1] | ||
) | ||
) | ||
).text(); | ||
this.apiKey = js.match(/x-api-key":"([^"]+)/)[1]; | ||
this.apiKeyExpiry = new Date().getTime() + 6 * 60 * 60 * 1000; // 6 hour expiration | ||
} | ||
return this.apiKey; | ||
@@ -91,0 +105,0 @@ }, |
{ | ||
"dependencies": { | ||
"axios": "^0.19.2", | ||
"cross-fetch": "^3.0.4", | ||
"url": "^0.11.0" | ||
@@ -21,3 +21,3 @@ }, | ||
}, | ||
"version": "1.0.21" | ||
"version": "1.0.23" | ||
} |
@@ -5,3 +5,3 @@ const maildrop = require("./main.js"); | ||
const email = "linto@maildrop.cc"; | ||
console.log(email); | ||
console.log({ email, xApiKey: await maildrop.getApiKey() }); | ||
@@ -8,0 +8,0 @@ // test fetchMails |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
5385
103
5
+ Addedcross-fetch@^3.0.4
+ Addedcross-fetch@3.1.8(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedaxios@^0.19.2
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)