@tradetrust-tt/dnsprove 2.14.2 → 2.16.0
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/index.js +13 -19
- package/dist/records/dnsTxt.js +6 -26
- package/dist/ts/records/dnsTxt.d.ts +5 -20
- package/dist/ts/util/logger.d.ts +7 -6
- package/package.json +1 -1
- package/src/index.test.ts +6 -54
- package/src/index.ts +4 -7
- package/src/records/dnsTxt.ts +7 -31
package/dist/index.js
CHANGED
|
@@ -16,12 +16,10 @@ Object.defineProperty(exports, "OpenAttestationDnsDidRecord", {
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
exports.queryDns = exports.parseOpenAttestationRecord = exports.parseDocumentStoreResults = exports.parseDnsDidResults = exports.getDocumentStoreRecords = exports.getDnsDidRecords = exports.defaultDnsResolvers = void 0;
|
|
19
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
20
19
|
var _dnsTxt = require("./records/dnsTxt");
|
|
21
20
|
var _dnsDid = require("./records/dnsDid");
|
|
22
21
|
var _logger = require("./util/logger");
|
|
23
22
|
var _error = require("./common/error");
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
23
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
24
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
25
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -39,29 +37,25 @@ const _getLogger = (0, _logger.getLogger)("index"),
|
|
|
39
37
|
trace = _getLogger.trace;
|
|
40
38
|
const defaultDnsResolvers = exports.defaultDnsResolvers = [( /*#__PURE__*/function () {
|
|
41
39
|
var _ref = _asyncToGenerator(function* (domain) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
data = _yield$axios.data;
|
|
47
|
-
return data;
|
|
40
|
+
const data = yield fetch(`https://dns.google/resolve?name=${domain}&type=TXT`, {
|
|
41
|
+
method: "GET"
|
|
42
|
+
});
|
|
43
|
+
return data.json();
|
|
48
44
|
});
|
|
49
45
|
return function (_x) {
|
|
50
46
|
return _ref.apply(this, arguments);
|
|
51
47
|
};
|
|
52
48
|
}()), ( /*#__PURE__*/function () {
|
|
53
49
|
var _ref2 = _asyncToGenerator(function* (domain) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
data = _yield$axios2.data;
|
|
64
|
-
return data;
|
|
50
|
+
const data = yield fetch(`https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`, {
|
|
51
|
+
method: "GET",
|
|
52
|
+
headers: {
|
|
53
|
+
accept: "application/dns-json",
|
|
54
|
+
contentType: "application/json",
|
|
55
|
+
connection: "keep-alive"
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return data.json();
|
|
65
59
|
});
|
|
66
60
|
return function (_x2) {
|
|
67
61
|
return _ref2.apply(this, arguments);
|
package/dist/records/dnsTxt.js
CHANGED
|
@@ -3,18 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RecordTypesT = exports.OpenAttestationDNSTextRecordT = exports.
|
|
6
|
+
exports.RecordTypesT = exports.OpenAttestationDNSTextRecordT = exports.EthereumNetworks = exports.EthereumNetworkIdT = exports.EthereumAddressT = exports.BlockchainNetworkT = void 0;
|
|
7
7
|
var _runtypes = require("runtypes");
|
|
8
8
|
const RecordTypesT = exports.RecordTypesT = (0, _runtypes.Literal)("openatts");
|
|
9
|
-
|
|
10
|
-
// export const BlockchainNetworkT = Literal("ethereum");
|
|
11
|
-
const BlockchainNetworkT = exports.BlockchainNetworkT = (0, _runtypes.Union)((0, _runtypes.Literal)("ethereum"), (0, _runtypes.Literal)("hedera"));
|
|
9
|
+
const BlockchainNetworkT = exports.BlockchainNetworkT = (0, _runtypes.Literal)("ethereum");
|
|
12
10
|
const EthereumAddressT = exports.EthereumAddressT = _runtypes.String.withConstraint(maybeAddress => {
|
|
13
11
|
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid ethereum address`;
|
|
14
12
|
});
|
|
15
|
-
const HederaAccountIDT = exports.HederaAccountIDT = _runtypes.String.withConstraint(maybeAddress => {
|
|
16
|
-
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid hedera address`;
|
|
17
|
-
});
|
|
18
13
|
let EthereumNetworks = exports.EthereumNetworks = void 0;
|
|
19
14
|
(function (EthereumNetworks) {
|
|
20
15
|
EthereumNetworks["homestead"] = "1";
|
|
@@ -29,29 +24,14 @@ let EthereumNetworks = exports.EthereumNetworks = void 0;
|
|
|
29
24
|
EthereumNetworks["xdcapothem"] = "51";
|
|
30
25
|
EthereumNetworks["stabilityTestnet"] = "20180427";
|
|
31
26
|
EthereumNetworks["stability"] = "101010";
|
|
32
|
-
EthereumNetworks["hedera"] = "295";
|
|
33
|
-
EthereumNetworks["hederatestnet"] = "296";
|
|
34
27
|
EthereumNetworks["astron"] = "1338";
|
|
35
28
|
})(EthereumNetworks || (exports.EthereumNetworks = EthereumNetworks = {}));
|
|
36
|
-
|
|
37
|
-
(
|
|
38
|
-
HederaNetworks["mainnet"] = "295";
|
|
39
|
-
HederaNetworks["testnet"] = "296";
|
|
40
|
-
})(HederaNetworks || (exports.HederaNetworks = HederaNetworks = {}));
|
|
41
|
-
const HederaNetworkIdT = exports.HederaNetworkIdT = (0, _runtypes.Union)((0, _runtypes.Literal)(HederaNetworks.mainnet), (0, _runtypes.Literal)(HederaNetworks.testnet));
|
|
42
|
-
const EthereumNetworkIdT = exports.EthereumNetworkIdT = (0, _runtypes.Union)((0, _runtypes.Literal)(EthereumNetworks.homestead), (0, _runtypes.Literal)(EthereumNetworks.ropsten), (0, _runtypes.Literal)(EthereumNetworks.rinkeby), (0, _runtypes.Literal)(EthereumNetworks.goerli), (0, _runtypes.Literal)(EthereumNetworks.sepolia), (0, _runtypes.Literal)(EthereumNetworks.polygon), (0, _runtypes.Literal)(EthereumNetworks.polygonAmoy), (0, _runtypes.Literal)(EthereumNetworks.xdc), (0, _runtypes.Literal)(EthereumNetworks.xdcapothem), (0, _runtypes.Literal)(EthereumNetworks.stabilityTestnet), (0, _runtypes.Literal)(EthereumNetworks.stability), (0, _runtypes.Literal)(EthereumNetworks.local), (0, _runtypes.Literal)(EthereumNetworks.hedera), (0, _runtypes.Literal)(EthereumNetworks.hederatestnet), (0, _runtypes.Literal)(EthereumNetworks.astron));
|
|
43
|
-
const OpenAttestationDNSTextRecordT = exports.OpenAttestationDNSTextRecordT = (0, _runtypes.Union)((0, _runtypes.Record)({
|
|
29
|
+
const EthereumNetworkIdT = exports.EthereumNetworkIdT = (0, _runtypes.Union)((0, _runtypes.Literal)(EthereumNetworks.homestead), (0, _runtypes.Literal)(EthereumNetworks.ropsten), (0, _runtypes.Literal)(EthereumNetworks.rinkeby), (0, _runtypes.Literal)(EthereumNetworks.goerli), (0, _runtypes.Literal)(EthereumNetworks.sepolia), (0, _runtypes.Literal)(EthereumNetworks.polygon), (0, _runtypes.Literal)(EthereumNetworks.polygonAmoy), (0, _runtypes.Literal)(EthereumNetworks.xdc), (0, _runtypes.Literal)(EthereumNetworks.xdcapothem), (0, _runtypes.Literal)(EthereumNetworks.stabilityTestnet), (0, _runtypes.Literal)(EthereumNetworks.stability), (0, _runtypes.Literal)(EthereumNetworks.local), (0, _runtypes.Literal)(EthereumNetworks.astron));
|
|
30
|
+
const OpenAttestationDNSTextRecordT = exports.OpenAttestationDNSTextRecordT = (0, _runtypes.Record)({
|
|
44
31
|
type: RecordTypesT,
|
|
45
|
-
net:
|
|
32
|
+
net: BlockchainNetworkT,
|
|
46
33
|
netId: EthereumNetworkIdT,
|
|
47
34
|
addr: EthereumAddressT
|
|
48
35
|
}).And((0, _runtypes.Partial)({
|
|
49
36
|
dnssec: _runtypes.Boolean
|
|
50
|
-
}))
|
|
51
|
-
type: RecordTypesT,
|
|
52
|
-
net: (0, _runtypes.Literal)("hedera"),
|
|
53
|
-
netId: HederaNetworkIdT,
|
|
54
|
-
addr: HederaAccountIDT
|
|
55
|
-
}).And((0, _runtypes.Partial)({
|
|
56
|
-
dnssec: _runtypes.Boolean
|
|
57
|
-
})));
|
|
37
|
+
}));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Static, Boolean, String, Literal, Record, Union, Partial } from "runtypes";
|
|
2
2
|
export declare const RecordTypesT: Literal<"openatts">;
|
|
3
|
-
export declare const BlockchainNetworkT:
|
|
3
|
+
export declare const BlockchainNetworkT: Literal<"ethereum">;
|
|
4
4
|
export declare const EthereumAddressT: import("runtypes").Constraint<String, string, unknown>;
|
|
5
|
-
export declare const HederaAccountIDT: import("runtypes").Constraint<String, string, unknown>;
|
|
6
5
|
export declare enum EthereumNetworks {
|
|
7
6
|
homestead = "1",
|
|
8
7
|
ropsten = "3",
|
|
@@ -16,31 +15,17 @@ export declare enum EthereumNetworks {
|
|
|
16
15
|
xdcapothem = "51",
|
|
17
16
|
stabilityTestnet = "20180427",
|
|
18
17
|
stability = "101010",
|
|
19
|
-
hedera = "295",
|
|
20
|
-
hederatestnet = "296",
|
|
21
18
|
astron = "1338"
|
|
22
19
|
}
|
|
23
|
-
export declare
|
|
24
|
-
|
|
25
|
-
testnet = "296"
|
|
26
|
-
}
|
|
27
|
-
export declare const HederaNetworkIdT: Union<[Literal<HederaNetworks.mainnet>, Literal<HederaNetworks.testnet>]>;
|
|
28
|
-
export declare const EthereumNetworkIdT: Union<[Literal<EthereumNetworks.homestead>, Literal<EthereumNetworks.ropsten>, Literal<EthereumNetworks.rinkeby>, Literal<EthereumNetworks.goerli>, Literal<EthereumNetworks.sepolia>, Literal<EthereumNetworks.polygon>, Literal<EthereumNetworks.polygonAmoy>, Literal<EthereumNetworks.xdc>, Literal<EthereumNetworks.xdcapothem>, Literal<EthereumNetworks.stabilityTestnet>, Literal<EthereumNetworks.stability>, Literal<EthereumNetworks.local>, Literal<EthereumNetworks.hedera>, Literal<EthereumNetworks.hederatestnet>, Literal<EthereumNetworks.astron>]>;
|
|
29
|
-
export declare const OpenAttestationDNSTextRecordT: Union<[import("runtypes").Intersect<[Record<{
|
|
20
|
+
export declare const EthereumNetworkIdT: Union<[Literal<EthereumNetworks.homestead>, Literal<EthereumNetworks.ropsten>, Literal<EthereumNetworks.rinkeby>, Literal<EthereumNetworks.goerli>, Literal<EthereumNetworks.sepolia>, Literal<EthereumNetworks.polygon>, Literal<EthereumNetworks.polygonAmoy>, Literal<EthereumNetworks.xdc>, Literal<EthereumNetworks.xdcapothem>, Literal<EthereumNetworks.stabilityTestnet>, Literal<EthereumNetworks.stability>, Literal<EthereumNetworks.local>, Literal<EthereumNetworks.astron>]>;
|
|
21
|
+
export declare const OpenAttestationDNSTextRecordT: import("runtypes").Intersect<[Record<{
|
|
30
22
|
type: Literal<"openatts">;
|
|
31
23
|
net: Literal<"ethereum">;
|
|
32
|
-
netId: Union<[Literal<EthereumNetworks.homestead>, Literal<EthereumNetworks.ropsten>, Literal<EthereumNetworks.rinkeby>, Literal<EthereumNetworks.goerli>, Literal<EthereumNetworks.sepolia>, Literal<EthereumNetworks.polygon>, Literal<EthereumNetworks.polygonAmoy>, Literal<EthereumNetworks.xdc>, Literal<EthereumNetworks.xdcapothem>, Literal<EthereumNetworks.stabilityTestnet>, Literal<EthereumNetworks.stability>, Literal<EthereumNetworks.local>, Literal<EthereumNetworks.
|
|
33
|
-
addr: import("runtypes").Constraint<String, string, unknown>;
|
|
34
|
-
}, false>, Partial<{
|
|
35
|
-
dnssec: Boolean;
|
|
36
|
-
}, false>]>, import("runtypes").Intersect<[Record<{
|
|
37
|
-
type: Literal<"openatts">;
|
|
38
|
-
net: Literal<"hedera">;
|
|
39
|
-
netId: Union<[Literal<HederaNetworks.mainnet>, Literal<HederaNetworks.testnet>]>;
|
|
24
|
+
netId: Union<[Literal<EthereumNetworks.homestead>, Literal<EthereumNetworks.ropsten>, Literal<EthereumNetworks.rinkeby>, Literal<EthereumNetworks.goerli>, Literal<EthereumNetworks.sepolia>, Literal<EthereumNetworks.polygon>, Literal<EthereumNetworks.polygonAmoy>, Literal<EthereumNetworks.xdc>, Literal<EthereumNetworks.xdcapothem>, Literal<EthereumNetworks.stabilityTestnet>, Literal<EthereumNetworks.stability>, Literal<EthereumNetworks.local>, Literal<EthereumNetworks.astron>]>;
|
|
40
25
|
addr: import("runtypes").Constraint<String, string, unknown>;
|
|
41
26
|
}, false>, Partial<{
|
|
42
27
|
dnssec: Boolean;
|
|
43
|
-
}, false>]
|
|
28
|
+
}, false>]>;
|
|
44
29
|
export type BlockchainNetwork = Static<typeof BlockchainNetworkT>;
|
|
45
30
|
export type EthereumAddress = Static<typeof EthereumAddressT>;
|
|
46
31
|
export type OpenAttestationDNSTextRecord = Static<typeof OpenAttestationDNSTextRecordT>;
|
package/dist/ts/util/logger.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
import debug from "debug";
|
|
2
|
+
export declare const trace: (namespace: string) => debug.Debugger;
|
|
3
|
+
export declare const info: (namespace: string) => debug.Debugger;
|
|
4
|
+
export declare const error: (namespace: string) => debug.Debugger;
|
|
4
5
|
export declare const getLogger: (namespace: string) => {
|
|
5
|
-
trace:
|
|
6
|
-
info:
|
|
7
|
-
error:
|
|
6
|
+
trace: debug.Debugger;
|
|
7
|
+
info: debug.Debugger;
|
|
8
|
+
error: debug.Debugger;
|
|
8
9
|
};
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
1
|
import { setupServer, SetupServerApi } from "msw/node";
|
|
3
2
|
import { http, HttpResponse } from "msw";
|
|
4
3
|
import { CustomDnsResolver, getDocumentStoreRecords, queryDns, parseDocumentStoreResults, getDnsDidRecords } from ".";
|
|
@@ -211,20 +210,18 @@ describe("queryDns", () => {
|
|
|
211
210
|
|
|
212
211
|
const testDnsResolvers: CustomDnsResolver[] = [
|
|
213
212
|
async (domain) => {
|
|
214
|
-
const
|
|
213
|
+
const data = await fetch(`https://dns.google/resolve?name=${domain}&type=TXT`, {
|
|
215
214
|
method: "GET",
|
|
216
|
-
url: `https://dns.google/resolve?name=${domain}&type=TXT`,
|
|
217
215
|
});
|
|
218
216
|
|
|
219
|
-
return data;
|
|
217
|
+
return data.json();
|
|
220
218
|
},
|
|
221
219
|
async (domain) => {
|
|
222
|
-
const
|
|
220
|
+
const data = await fetch(`https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`, {
|
|
223
221
|
method: "GET",
|
|
224
|
-
url: `https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`,
|
|
225
222
|
headers: { accept: "application/dns-json", contentType: "application/json", connection: "keep-alive" },
|
|
226
223
|
});
|
|
227
|
-
return data;
|
|
224
|
+
return data.json();
|
|
228
225
|
},
|
|
229
226
|
];
|
|
230
227
|
|
|
@@ -244,7 +241,7 @@ describe("queryDns", () => {
|
|
|
244
241
|
|
|
245
242
|
const records = await queryDns("https://donotuse.openattestation.com", testDnsResolvers);
|
|
246
243
|
const sortedAnswer = records?.Answer.sort((a, b) => a.data.localeCompare(b.data));
|
|
247
|
-
expect(sortedAnswer).
|
|
244
|
+
expect(sortedAnswer).toMatchObject(sampleResponse.Answer);
|
|
248
245
|
});
|
|
249
246
|
|
|
250
247
|
test("Should fallback to second dns when first dns is down", async () => {
|
|
@@ -262,7 +259,7 @@ describe("queryDns", () => {
|
|
|
262
259
|
const records = await queryDns("https://donotuse.openattestation.com", testDnsResolvers);
|
|
263
260
|
|
|
264
261
|
const sortedAnswer = records?.Answer.sort((a, b) => a.data.localeCompare(b.data));
|
|
265
|
-
expect(sortedAnswer).
|
|
262
|
+
expect(sortedAnswer).toMatchObject(sampleResponse.Answer);
|
|
266
263
|
});
|
|
267
264
|
|
|
268
265
|
test("Should throw error when all dns provided are down", async () => {
|
|
@@ -284,51 +281,6 @@ describe("queryDns", () => {
|
|
|
284
281
|
});
|
|
285
282
|
});
|
|
286
283
|
|
|
287
|
-
describe("getDocumentStoreRecords for Hedera", () => {
|
|
288
|
-
const sampleDnsTextRecord = [
|
|
289
|
-
{
|
|
290
|
-
type: "openatts",
|
|
291
|
-
net: "hedera",
|
|
292
|
-
netId: "295",
|
|
293
|
-
addr: "0x222B69788e2e9B7FB93a3a0fE258D4604Dc7df21",
|
|
294
|
-
dnssec: false,
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
type: "openatts",
|
|
298
|
-
net: "hedera",
|
|
299
|
-
netId: "296",
|
|
300
|
-
addr: "0x222B69788e2e9B7FB93a3a0fE258D4604Dc7df21",
|
|
301
|
-
dnssec: false,
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
type: "openatts",
|
|
305
|
-
net: "hedera",
|
|
306
|
-
netId: "296",
|
|
307
|
-
addr: "0x3DE43bfd3D771931E46CbBd4EDE0D3d95C85f81A",
|
|
308
|
-
dnssec: false,
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
type: "openatts",
|
|
312
|
-
net: "hedera",
|
|
313
|
-
netId: "296",
|
|
314
|
-
addr: "0xB9cf2eFcBeCdF96E6A7E46AECd79A784B41Bcf6B",
|
|
315
|
-
dnssec: false,
|
|
316
|
-
},
|
|
317
|
-
];
|
|
318
|
-
|
|
319
|
-
test("it should work with trustlv.org", async () => {
|
|
320
|
-
const records = (await getDocumentStoreRecords("trustlv.org")).sort((a, b) => {
|
|
321
|
-
if (a.netId < b.netId) return -1;
|
|
322
|
-
if (a.netId > b.netId) return 1;
|
|
323
|
-
if (a.addr < b.addr) return -1;
|
|
324
|
-
if (a.addr > b.addr) return 1;
|
|
325
|
-
return 0;
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
expect(records).toStrictEqual(sampleDnsTextRecord);
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
|
|
332
284
|
describe("getDocumentStoreRecords for Astron", () => {
|
|
333
285
|
const sampleDnsTextRecord = [
|
|
334
286
|
{
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
1
|
import { OpenAttestationDNSTextRecord, OpenAttestationDNSTextRecordT } from "./records/dnsTxt";
|
|
3
2
|
import { OpenAttestationDnsDidRecord, OpenAttestationDnsDidRecordT } from "./records/dnsDid";
|
|
4
3
|
import { getLogger } from "./util/logger";
|
|
@@ -26,20 +25,18 @@ export type CustomDnsResolver = (domain: string) => Promise<IDNSQueryResponse>;
|
|
|
26
25
|
|
|
27
26
|
export const defaultDnsResolvers: CustomDnsResolver[] = [
|
|
28
27
|
async (domain) => {
|
|
29
|
-
const
|
|
28
|
+
const data = await fetch(`https://dns.google/resolve?name=${domain}&type=TXT`, {
|
|
30
29
|
method: "GET",
|
|
31
|
-
url: `https://dns.google/resolve?name=${domain}&type=TXT`,
|
|
32
30
|
});
|
|
33
31
|
|
|
34
|
-
return data;
|
|
32
|
+
return data.json();
|
|
35
33
|
},
|
|
36
34
|
async (domain) => {
|
|
37
|
-
const
|
|
35
|
+
const data = await fetch(`https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`, {
|
|
38
36
|
method: "GET",
|
|
39
|
-
url: `https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`,
|
|
40
37
|
headers: { accept: "application/dns-json", contentType: "application/json", connection: "keep-alive" },
|
|
41
38
|
});
|
|
42
|
-
return data;
|
|
39
|
+
return data.json();
|
|
43
40
|
},
|
|
44
41
|
];
|
|
45
42
|
|
package/src/records/dnsTxt.ts
CHANGED
|
@@ -2,17 +2,12 @@ import { Static, Boolean, String, Literal, Record, Union, Partial } from "runtyp
|
|
|
2
2
|
|
|
3
3
|
export const RecordTypesT = Literal("openatts");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export const BlockchainNetworkT = Union(Literal("ethereum"), Literal("hedera"));
|
|
5
|
+
export const BlockchainNetworkT = Literal("ethereum");
|
|
7
6
|
|
|
8
7
|
export const EthereumAddressT = String.withConstraint((maybeAddress: string) => {
|
|
9
8
|
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid ethereum address`;
|
|
10
9
|
});
|
|
11
10
|
|
|
12
|
-
export const HederaAccountIDT = String.withConstraint((maybeAddress: string) => {
|
|
13
|
-
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid hedera address`;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
11
|
export enum EthereumNetworks {
|
|
17
12
|
homestead = "1",
|
|
18
13
|
ropsten = "3",
|
|
@@ -26,18 +21,9 @@ export enum EthereumNetworks {
|
|
|
26
21
|
xdcapothem = "51",
|
|
27
22
|
stabilityTestnet = "20180427",
|
|
28
23
|
stability = "101010",
|
|
29
|
-
hedera = "295",
|
|
30
|
-
hederatestnet = "296",
|
|
31
24
|
astron = "1338",
|
|
32
25
|
}
|
|
33
26
|
|
|
34
|
-
export enum HederaNetworks {
|
|
35
|
-
mainnet = "295",
|
|
36
|
-
testnet = "296",
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const HederaNetworkIdT = Union(Literal(HederaNetworks.mainnet), Literal(HederaNetworks.testnet));
|
|
40
|
-
|
|
41
27
|
export const EthereumNetworkIdT = Union(
|
|
42
28
|
Literal(EthereumNetworks.homestead),
|
|
43
29
|
Literal(EthereumNetworks.ropsten),
|
|
@@ -51,25 +37,15 @@ export const EthereumNetworkIdT = Union(
|
|
|
51
37
|
Literal(EthereumNetworks.stabilityTestnet),
|
|
52
38
|
Literal(EthereumNetworks.stability),
|
|
53
39
|
Literal(EthereumNetworks.local),
|
|
54
|
-
Literal(EthereumNetworks.hedera),
|
|
55
|
-
Literal(EthereumNetworks.hederatestnet),
|
|
56
40
|
Literal(EthereumNetworks.astron)
|
|
57
41
|
);
|
|
58
42
|
|
|
59
|
-
export const OpenAttestationDNSTextRecordT =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}).And(Partial({ dnssec: Boolean })),
|
|
66
|
-
Record({
|
|
67
|
-
type: RecordTypesT,
|
|
68
|
-
net: Literal("hedera"),
|
|
69
|
-
netId: HederaNetworkIdT,
|
|
70
|
-
addr: HederaAccountIDT,
|
|
71
|
-
}).And(Partial({ dnssec: Boolean }))
|
|
72
|
-
);
|
|
43
|
+
export const OpenAttestationDNSTextRecordT = Record({
|
|
44
|
+
type: RecordTypesT,
|
|
45
|
+
net: BlockchainNetworkT,
|
|
46
|
+
netId: EthereumNetworkIdT,
|
|
47
|
+
addr: EthereumAddressT,
|
|
48
|
+
}).And(Partial({ dnssec: Boolean }));
|
|
73
49
|
|
|
74
50
|
export type BlockchainNetwork = Static<typeof BlockchainNetworkT>;
|
|
75
51
|
export type EthereumAddress = Static<typeof EthereumAddressT>;
|