@blockcore/dns 0.0.1 → 0.0.2
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/dist/BlockcoreDns.d.ts +8 -0
- package/dist/BlockcoreDns.js +39 -0
- package/dist/{src/index.d.ts → index.d.ts} +0 -0
- package/dist/{src/index.js → index.js} +0 -0
- package/dist/options.d.ts +3 -0
- package/dist/{test/dns.d.ts → options.js} +0 -0
- package/package.json +5 -1
- package/dist/test/dns.js +0 -8
@@ -0,0 +1,8 @@
|
|
1
|
+
import { BlockcoreDnsOptions } from './options.js';
|
2
|
+
export declare class BlockcoreDns {
|
3
|
+
private options;
|
4
|
+
static defaultOptions: BlockcoreDnsOptions;
|
5
|
+
static create(): BlockcoreDns;
|
6
|
+
constructor(options?: BlockcoreDnsOptions);
|
7
|
+
getDnsServers(): Promise<unknown>;
|
8
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import fetch from 'node-fetch';
|
2
|
+
export class BlockcoreDns {
|
3
|
+
constructor(options = BlockcoreDns.defaultOptions) {
|
4
|
+
Object.defineProperty(this, "options", {
|
5
|
+
enumerable: true,
|
6
|
+
configurable: true,
|
7
|
+
writable: true,
|
8
|
+
value: options
|
9
|
+
});
|
10
|
+
}
|
11
|
+
static create() {
|
12
|
+
const dns = new BlockcoreDns();
|
13
|
+
return dns;
|
14
|
+
}
|
15
|
+
async getDnsServers() {
|
16
|
+
const url = `${this.options.baseUrl}/services/BLOCKCORE-DNS.json`;
|
17
|
+
const response = await fetch(url, {
|
18
|
+
method: 'GET',
|
19
|
+
// mode: 'cors',
|
20
|
+
// cache: 'no-cache',
|
21
|
+
// credentials: 'same-origin',
|
22
|
+
headers: {
|
23
|
+
'Content-Type': 'application/json',
|
24
|
+
},
|
25
|
+
redirect: 'follow',
|
26
|
+
referrerPolicy: 'no-referrer',
|
27
|
+
});
|
28
|
+
const servers = await response.json();
|
29
|
+
return servers;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
Object.defineProperty(BlockcoreDns, "defaultOptions", {
|
33
|
+
enumerable: true,
|
34
|
+
configurable: true,
|
35
|
+
writable: true,
|
36
|
+
value: {
|
37
|
+
baseUrl: 'https://chains.blockcore.net',
|
38
|
+
}
|
39
|
+
});
|
File without changes
|
File without changes
|
File without changes
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@blockcore/dns",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.2",
|
4
4
|
"type": "module",
|
5
5
|
"exports": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -50,5 +50,9 @@
|
|
50
50
|
"nodeArguments": [
|
51
51
|
"--loader=ts-node/esm"
|
52
52
|
]
|
53
|
+
},
|
54
|
+
"dependencies": {
|
55
|
+
"axios": "^0.27.2",
|
56
|
+
"node-fetch": "^3.2.9"
|
53
57
|
}
|
54
58
|
}
|