@tradetrust-tt/dnsprove 2.10.0 → 2.11.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/README.md +13 -13
- package/dist/common/error.js +5 -13
- package/dist/index.js +42 -96
- package/dist/records/dnsDid.js +11 -28
- package/dist/records/dnsTxt.js +13 -30
- package/dist/ts/records/dnsTxt.d.ts +3 -2
- package/dist/util/logger.js +1 -11
- package/package.json +14 -18
- package/src/index.test.ts +24 -8
- package/src/records/dnsTxt.ts +2 -0
- package/CHANGELOG.md +0 -1
package/README.md
CHANGED
|
@@ -89,10 +89,10 @@ Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global
|
|
|
89
89
|
|
|
90
90
|
#### Parameters
|
|
91
91
|
|
|
92
|
-
* `domain` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
93
|
-
* `customDnsResolvers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[CustomDnsResolver](#customdnsresolver)
|
|
92
|
+
* `domain` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
93
|
+
* `customDnsResolvers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[CustomDnsResolver](#customdnsresolver)>** 
|
|
94
94
|
|
|
95
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[IDNSQueryResponse](#idnsqueryresponse)
|
|
95
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[IDNSQueryResponse](#idnsqueryresponse)>** 
|
|
96
96
|
|
|
97
97
|
### parseOpenAttestationRecord
|
|
98
98
|
|
|
@@ -102,7 +102,7 @@ Parses one openattestation DNS-TXT record and turns it into an OpenAttestationsD
|
|
|
102
102
|
|
|
103
103
|
* `record` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** e.g: '"openatts net=ethereum netId=3 addr=0x0c9d5E6C766030cc6f0f49951D275Ad0701F81EC"'
|
|
104
104
|
|
|
105
|
-
Returns **GenericObject
|
|
105
|
+
Returns **GenericObject** 
|
|
106
106
|
|
|
107
107
|
### parseDocumentStoreResults
|
|
108
108
|
|
|
@@ -111,18 +111,18 @@ Takes a DNS-TXT Record set and returns openattestation document store records if
|
|
|
111
111
|
#### Parameters
|
|
112
112
|
|
|
113
113
|
* `recordSet` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[IDNSRecord](#idnsrecord)>** Refer to tests for examples (optional, default `[]`)
|
|
114
|
-
* `dnssec` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
|
|
114
|
+
* `dnssec` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
115
115
|
|
|
116
|
-
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[OpenAttestationDNSTextRecord](#openattestationdnstextrecord)
|
|
116
|
+
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[OpenAttestationDNSTextRecord](#openattestationdnstextrecord)>** 
|
|
117
117
|
|
|
118
118
|
### parseDnsDidResults
|
|
119
119
|
|
|
120
120
|
#### Parameters
|
|
121
121
|
|
|
122
122
|
* `recordSet` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[IDNSRecord](#idnsrecord)>** (optional, default `[]`)
|
|
123
|
-
* `dnssec` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
|
|
123
|
+
* `dnssec` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
124
124
|
|
|
125
|
-
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[OpenAttestationDnsDidRecord](#openattestationdnsdidrecord)
|
|
125
|
+
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[OpenAttestationDnsDidRecord](#openattestationdnsdidrecord)>** 
|
|
126
126
|
|
|
127
127
|
### getDocumentStoreRecords
|
|
128
128
|
|
|
@@ -131,7 +131,7 @@ Queries a given domain and parses the results to retrieve openattestation docume
|
|
|
131
131
|
#### Parameters
|
|
132
132
|
|
|
133
133
|
* `domain` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** e.g: "example.openattestation.com"
|
|
134
|
-
* `customDnsResolvers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[CustomDnsResolver](#customdnsresolver)
|
|
134
|
+
* `customDnsResolvers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[CustomDnsResolver](#customdnsresolver)>?** 
|
|
135
135
|
|
|
136
136
|
#### Examples
|
|
137
137
|
|
|
@@ -144,16 +144,16 @@ addr: '0x2f60375e8144e16Adf1979936301D8341D58C36C',
|
|
|
144
144
|
dnssec: true } ]
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[OpenAttestationDNSTextRecord](#openattestationdnstextrecord)
|
|
147
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[OpenAttestationDNSTextRecord](#openattestationdnstextrecord)>>** 
|
|
148
148
|
|
|
149
149
|
### getDnsDidRecords
|
|
150
150
|
|
|
151
151
|
#### Parameters
|
|
152
152
|
|
|
153
|
-
* `domain` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
154
|
-
* `customDnsResolvers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[CustomDnsResolver](#customdnsresolver)
|
|
153
|
+
* `domain` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
154
|
+
* `customDnsResolvers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[CustomDnsResolver](#customdnsresolver)>?** 
|
|
155
155
|
|
|
156
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[OpenAttestationDnsDidRecord](#openattestationdnsdidrecord)
|
|
156
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[OpenAttestationDnsDidRecord](#openattestationdnsdidrecord)>>** 
|
|
157
157
|
|
|
158
158
|
## License
|
|
159
159
|
|
package/dist/common/error.js
CHANGED
|
@@ -3,29 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
let DnsproveStatusCode;
|
|
11
|
-
exports.DnsproveStatusCode = DnsproveStatusCode;
|
|
12
|
-
|
|
6
|
+
exports.DnsproveStatusCode = exports.CodedError = void 0;
|
|
7
|
+
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; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
let DnsproveStatusCode = exports.DnsproveStatusCode = void 0;
|
|
13
11
|
(function (DnsproveStatusCode) {
|
|
14
12
|
DnsproveStatusCode[DnsproveStatusCode["IDNS_QUERY_ERROR_GENERAL"] = 0] = "IDNS_QUERY_ERROR_GENERAL";
|
|
15
13
|
})(DnsproveStatusCode || (exports.DnsproveStatusCode = DnsproveStatusCode = {}));
|
|
16
|
-
|
|
17
14
|
class CodedError extends Error {
|
|
18
15
|
constructor(message, code, codeString) {
|
|
19
16
|
super(message);
|
|
20
|
-
|
|
21
17
|
_defineProperty(this, "code", void 0);
|
|
22
|
-
|
|
23
18
|
_defineProperty(this, "codeString", void 0);
|
|
24
|
-
|
|
25
19
|
this.code = code;
|
|
26
20
|
this.codeString = codeString;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
exports.CodedError = CodedError;
|
package/dist/index.js
CHANGED
|
@@ -15,116 +15,87 @@ Object.defineProperty(exports, "OpenAttestationDnsDidRecord", {
|
|
|
15
15
|
return _dnsDid.OpenAttestationDnsDidRecord;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
exports.
|
|
19
|
-
|
|
18
|
+
exports.queryDns = exports.parseOpenAttestationRecord = exports.parseDocumentStoreResults = exports.parseDnsDidResults = exports.getDocumentStoreRecords = exports.getDnsDidRecords = exports.defaultDnsResolvers = void 0;
|
|
20
19
|
var _axios = _interopRequireDefault(require("axios"));
|
|
21
|
-
|
|
22
20
|
var _dnsTxt = require("./records/dnsTxt");
|
|
23
|
-
|
|
24
21
|
var _dnsDid = require("./records/dnsDid");
|
|
25
|
-
|
|
26
22
|
var _logger = require("./util/logger");
|
|
27
|
-
|
|
28
23
|
var _error = require("./common/error");
|
|
29
|
-
|
|
30
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
37
|
-
|
|
25
|
+
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
|
+
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
|
+
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; }
|
|
28
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
29
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
38
30
|
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
39
|
-
|
|
40
31
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
41
|
-
|
|
42
32
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
43
|
-
|
|
44
33
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
45
|
-
|
|
46
34
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
47
|
-
|
|
48
35
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
|
-
|
|
50
36
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
51
|
-
|
|
52
37
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
53
|
-
|
|
54
38
|
const _getLogger = (0, _logger.getLogger)("index"),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const defaultDnsResolvers = [/*#__PURE__*/function () {
|
|
39
|
+
trace = _getLogger.trace;
|
|
40
|
+
const defaultDnsResolvers = exports.defaultDnsResolvers = [( /*#__PURE__*/function () {
|
|
58
41
|
var _ref = _asyncToGenerator(function* (domain) {
|
|
59
42
|
const _yield$axios = yield (0, _axios.default)({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
method: "GET",
|
|
44
|
+
url: `https://dns.google/resolve?name=${domain}&type=TXT`
|
|
45
|
+
}),
|
|
46
|
+
data = _yield$axios.data;
|
|
65
47
|
return data;
|
|
66
48
|
});
|
|
67
|
-
|
|
68
49
|
return function (_x) {
|
|
69
50
|
return _ref.apply(this, arguments);
|
|
70
51
|
};
|
|
71
|
-
}(), /*#__PURE__*/function () {
|
|
52
|
+
}()), ( /*#__PURE__*/function () {
|
|
72
53
|
var _ref2 = _asyncToGenerator(function* (domain) {
|
|
73
54
|
const _yield$axios2 = yield (0, _axios.default)({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
55
|
+
method: "GET",
|
|
56
|
+
url: `https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`,
|
|
57
|
+
headers: {
|
|
58
|
+
accept: "application/dns-json",
|
|
59
|
+
contentType: "application/json",
|
|
60
|
+
connection: "keep-alive"
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
data = _yield$axios2.data;
|
|
84
64
|
return data;
|
|
85
65
|
});
|
|
86
|
-
|
|
87
66
|
return function (_x2) {
|
|
88
67
|
return _ref2.apply(this, arguments);
|
|
89
68
|
};
|
|
90
|
-
}()];
|
|
69
|
+
}())];
|
|
70
|
+
|
|
91
71
|
/**
|
|
92
72
|
* Returns true for strings that are openattestation records
|
|
93
73
|
* @param txtDataString e.g: '"openatts net=ethereum netId=3 addr=0x0c9d5E6C766030cc6f0f49951D275Ad0701F81EC"'
|
|
94
74
|
*/
|
|
95
|
-
|
|
96
|
-
exports.defaultDnsResolvers = defaultDnsResolvers;
|
|
97
|
-
|
|
98
75
|
const isOpenAttestationRecord = txtDataString => {
|
|
99
76
|
return txtDataString.startsWith("openatts");
|
|
100
77
|
};
|
|
101
|
-
|
|
102
78
|
const trimValue = str => {
|
|
103
79
|
return str.endsWith(";") ? str.substring(0, str.length - 1).trim() : str.trim();
|
|
104
80
|
};
|
|
81
|
+
|
|
105
82
|
/**
|
|
106
83
|
* Takes a string in the format of "key=value" and adds it to a JS object as key: value
|
|
107
84
|
* @param obj Object that will be modified
|
|
108
85
|
* @param keyValuePair A key value pair to add to the given object
|
|
109
86
|
* @example addKeyValuePairToObject(objectToModify, "foo=bar")
|
|
110
87
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
88
|
const addKeyValuePairToObject = (obj, keyValuePair) => {
|
|
114
89
|
const _keyValuePair$split = keyValuePair.split("="),
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
90
|
+
_keyValuePair$split2 = _toArray(_keyValuePair$split),
|
|
91
|
+
key = _keyValuePair$split2[0],
|
|
92
|
+
values = _keyValuePair$split2.slice(1);
|
|
119
93
|
const value = values.join("="); // in case there were values with = in them
|
|
120
|
-
|
|
121
94
|
/* eslint-disable no-param-reassign */
|
|
122
95
|
// this is necessary because we modify the accumulator in .reduce
|
|
123
|
-
|
|
124
96
|
obj[key.trim()] = trimValue(value);
|
|
125
97
|
return obj;
|
|
126
98
|
};
|
|
127
|
-
|
|
128
99
|
const formatDnsDidRecord = ({
|
|
129
100
|
a,
|
|
130
101
|
v,
|
|
@@ -138,103 +109,88 @@ const formatDnsDidRecord = ({
|
|
|
138
109
|
version: v
|
|
139
110
|
};
|
|
140
111
|
};
|
|
141
|
-
|
|
142
|
-
const queryDns = /*#__PURE__*/function () {
|
|
112
|
+
const queryDns = exports.queryDns = /*#__PURE__*/function () {
|
|
143
113
|
var _ref3 = _asyncToGenerator(function* (domain, customDnsResolvers) {
|
|
144
114
|
let data;
|
|
145
115
|
let i = 0;
|
|
146
|
-
|
|
147
116
|
while (!data && i < customDnsResolvers.length) {
|
|
148
117
|
try {
|
|
149
|
-
const customDnsResolver = customDnsResolvers[i];
|
|
150
|
-
|
|
118
|
+
const customDnsResolver = customDnsResolvers[i];
|
|
119
|
+
// eslint-disable-next-line no-await-in-loop
|
|
151
120
|
data = yield customDnsResolver(domain);
|
|
152
121
|
} catch (e) {
|
|
153
122
|
i += 1;
|
|
154
123
|
}
|
|
155
124
|
}
|
|
156
|
-
|
|
157
125
|
if (!data) {
|
|
158
126
|
throw new _error.CodedError("Unable to query DNS", _error.DnsproveStatusCode.IDNS_QUERY_ERROR_GENERAL, "IDNS_QUERY_ERROR_GENERAL");
|
|
159
127
|
}
|
|
160
|
-
|
|
161
128
|
return data;
|
|
162
129
|
});
|
|
163
|
-
|
|
164
130
|
return function queryDns(_x3, _x4) {
|
|
165
131
|
return _ref3.apply(this, arguments);
|
|
166
132
|
};
|
|
167
133
|
}();
|
|
134
|
+
|
|
168
135
|
/**
|
|
169
136
|
* Parses one openattestation DNS-TXT record and turns it into an OpenAttestationsDNSTextRecord object
|
|
170
137
|
* @param record e.g: '"openatts net=ethereum netId=3 addr=0x0c9d5E6C766030cc6f0f49951D275Ad0701F81EC"'
|
|
171
138
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
exports.queryDns = queryDns;
|
|
175
|
-
|
|
176
139
|
const parseOpenAttestationRecord = record => {
|
|
177
140
|
trace(`Parsing record: ${record}`);
|
|
178
141
|
const keyValuePairs = record.trim().split(" "); // tokenize into key=value elements
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
142
|
+
const recordObject = {};
|
|
143
|
+
// @ts-ignore: we already checked for this token
|
|
182
144
|
recordObject.type = keyValuePairs.shift();
|
|
183
145
|
keyValuePairs.reduce(addKeyValuePairToObject, recordObject);
|
|
184
146
|
return recordObject;
|
|
185
147
|
};
|
|
148
|
+
|
|
186
149
|
/**
|
|
187
150
|
* Currying function that applies a given dnssec result
|
|
188
151
|
*/
|
|
189
|
-
|
|
190
|
-
|
|
191
152
|
exports.parseOpenAttestationRecord = parseOpenAttestationRecord;
|
|
192
|
-
|
|
193
153
|
const applyDnssecResults = dnssecStatus => record => {
|
|
194
154
|
return _objectSpread(_objectSpread({}, record), {}, {
|
|
195
155
|
dnssec: dnssecStatus
|
|
196
156
|
});
|
|
197
157
|
};
|
|
158
|
+
|
|
198
159
|
/**
|
|
199
160
|
* Some DNS servers return TXT records with quoted strings, others don't :D
|
|
200
161
|
* @param record
|
|
201
162
|
* @returns unquoted DNS record
|
|
202
163
|
*/
|
|
203
|
-
|
|
204
|
-
|
|
205
164
|
const trimDoubleQuotes = record => {
|
|
206
165
|
return record.startsWith('"') ? record.slice(1, -1) : record;
|
|
207
166
|
};
|
|
167
|
+
|
|
208
168
|
/**
|
|
209
169
|
* Takes a record set and breaks that info array of key value pairs
|
|
210
170
|
* @param recordSet e.g: [{name: "google.com", type: 16, TTL: 3599, data: '"openatts net=ethereum netId=3 addr=0x2f60375e8144e16Adf1979936301D8341D58C36C"}]
|
|
211
171
|
*/
|
|
212
|
-
|
|
213
|
-
|
|
214
172
|
const parseOpenAttestationRecords = (recordSet = []) => {
|
|
215
173
|
trace(`Parsing DNS results: ${JSON.stringify(recordSet)}`);
|
|
216
174
|
return recordSet.map(record => record.data).map(trimDoubleQuotes) // removing leading and trailing quotes if they exist
|
|
217
175
|
.filter(isOpenAttestationRecord).map(parseOpenAttestationRecord);
|
|
218
176
|
};
|
|
177
|
+
|
|
219
178
|
/**
|
|
220
179
|
* Takes a DNS-TXT Record set and returns openattestation document store records if any
|
|
221
180
|
* @param recordSet Refer to tests for examples
|
|
222
181
|
*/
|
|
223
|
-
|
|
224
|
-
|
|
225
182
|
const parseDocumentStoreResults = (recordSet = [], dnssec) => {
|
|
226
183
|
return parseOpenAttestationRecords(recordSet).reduce((prev, curr) => {
|
|
227
184
|
return _dnsTxt.OpenAttestationDNSTextRecordT.guard(curr) ? [...prev, curr] : prev;
|
|
228
185
|
}, []).map(applyDnssecResults(dnssec));
|
|
229
186
|
};
|
|
230
|
-
|
|
231
187
|
exports.parseDocumentStoreResults = parseDocumentStoreResults;
|
|
232
|
-
|
|
233
188
|
const parseDnsDidResults = (recordSet = [], dnssec) => {
|
|
234
189
|
return parseOpenAttestationRecords(recordSet).map(formatDnsDidRecord).reduce((prev, curr) => {
|
|
235
190
|
return _dnsDid.OpenAttestationDnsDidRecordT.guard(curr) ? [...prev, curr] : prev;
|
|
236
191
|
}, []).map(applyDnssecResults(dnssec));
|
|
237
192
|
};
|
|
193
|
+
|
|
238
194
|
/**
|
|
239
195
|
* Queries a given domain and parses the results to retrieve openattestation document store records if any
|
|
240
196
|
* @param domain e.g: "example.openattestation.com"
|
|
@@ -246,11 +202,8 @@ const parseDnsDidResults = (recordSet = [], dnssec) => {
|
|
|
246
202
|
addr: '0x2f60375e8144e16Adf1979936301D8341D58C36C',
|
|
247
203
|
dnssec: true } ]
|
|
248
204
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
205
|
exports.parseDnsDidResults = parseDnsDidResults;
|
|
252
|
-
|
|
253
|
-
const getDocumentStoreRecords = /*#__PURE__*/function () {
|
|
206
|
+
const getDocumentStoreRecords = exports.getDocumentStoreRecords = /*#__PURE__*/function () {
|
|
254
207
|
var _ref4 = _asyncToGenerator(function* (domain, customDnsResolvers) {
|
|
255
208
|
trace(`Received request to resolve ${domain}`);
|
|
256
209
|
const dnsResolvers = customDnsResolvers || defaultDnsResolvers;
|
|
@@ -259,15 +212,11 @@ const getDocumentStoreRecords = /*#__PURE__*/function () {
|
|
|
259
212
|
trace(`Lookup results: ${JSON.stringify(answers)}`);
|
|
260
213
|
return parseDocumentStoreResults(answers, results.AD);
|
|
261
214
|
});
|
|
262
|
-
|
|
263
215
|
return function getDocumentStoreRecords(_x5, _x6) {
|
|
264
216
|
return _ref4.apply(this, arguments);
|
|
265
217
|
};
|
|
266
218
|
}();
|
|
267
|
-
|
|
268
|
-
exports.getDocumentStoreRecords = getDocumentStoreRecords;
|
|
269
|
-
|
|
270
|
-
const getDnsDidRecords = /*#__PURE__*/function () {
|
|
219
|
+
const getDnsDidRecords = exports.getDnsDidRecords = /*#__PURE__*/function () {
|
|
271
220
|
var _ref5 = _asyncToGenerator(function* (domain, customDnsResolvers) {
|
|
272
221
|
trace(`Received request to resolve ${domain}`);
|
|
273
222
|
const dnsResolvers = customDnsResolvers || defaultDnsResolvers;
|
|
@@ -276,10 +225,7 @@ const getDnsDidRecords = /*#__PURE__*/function () {
|
|
|
276
225
|
trace(`Lookup results: ${JSON.stringify(answers)}`);
|
|
277
226
|
return parseDnsDidResults(answers, results.AD);
|
|
278
227
|
});
|
|
279
|
-
|
|
280
228
|
return function getDnsDidRecords(_x7, _x8) {
|
|
281
229
|
return _ref5.apply(this, arguments);
|
|
282
230
|
};
|
|
283
|
-
}();
|
|
284
|
-
|
|
285
|
-
exports.getDnsDidRecords = getDnsDidRecords;
|
|
231
|
+
}();
|
package/dist/records/dnsDid.js
CHANGED
|
@@ -3,54 +3,37 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.validateDid = exports.VersionT = exports.RecordTypesT = exports.PublicKeyT = exports.OpenAttestationDnsDidRecordT = exports.AlgorithmT = void 0;
|
|
8
7
|
var _runtypes = require("runtypes");
|
|
9
|
-
|
|
10
8
|
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
11
|
-
|
|
12
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
|
|
14
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
|
|
16
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
-
|
|
18
12
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
19
|
-
|
|
20
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
-
|
|
22
14
|
// References https://www.w3.org/TR/did-core/#did-syntax
|
|
23
15
|
const validateDid = maybeDid => {
|
|
24
16
|
const _maybeDid$split = maybeDid.split(":"),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
_maybeDid$split2 = _toArray(_maybeDid$split),
|
|
18
|
+
did = _maybeDid$split2[0],
|
|
19
|
+
methodName = _maybeDid$split2[1],
|
|
20
|
+
methodSpecificIdParts = _maybeDid$split2.slice(2);
|
|
30
21
|
const methodSpecificId = methodSpecificIdParts.join(":");
|
|
31
22
|
if (did !== "did" || !methodName || !methodSpecificId || !/[a-z]+/.test(methodName)) return false;
|
|
32
23
|
return true;
|
|
33
24
|
};
|
|
34
|
-
|
|
35
25
|
exports.validateDid = validateDid;
|
|
36
|
-
const RecordTypesT = (0, _runtypes.Literal)("openatts");
|
|
37
|
-
exports.
|
|
38
|
-
const
|
|
39
|
-
exports.
|
|
40
|
-
const VersionT = _runtypes.String;
|
|
41
|
-
exports.VersionT = VersionT;
|
|
42
|
-
|
|
43
|
-
const PublicKeyT = _runtypes.String.withConstraint(maybeDid => {
|
|
26
|
+
const RecordTypesT = exports.RecordTypesT = (0, _runtypes.Literal)("openatts");
|
|
27
|
+
const AlgorithmT = exports.AlgorithmT = (0, _runtypes.Union)((0, _runtypes.Literal)("dns-did"));
|
|
28
|
+
const VersionT = exports.VersionT = _runtypes.String;
|
|
29
|
+
const PublicKeyT = exports.PublicKeyT = _runtypes.String.withConstraint(maybeDid => {
|
|
44
30
|
return validateDid(maybeDid) || `${maybeDid} is not a valid did`;
|
|
45
31
|
});
|
|
46
|
-
|
|
47
|
-
exports.PublicKeyT = PublicKeyT;
|
|
48
|
-
const OpenAttestationDnsDidRecordT = (0, _runtypes.Record)({
|
|
32
|
+
const OpenAttestationDnsDidRecordT = exports.OpenAttestationDnsDidRecordT = (0, _runtypes.Record)({
|
|
49
33
|
type: RecordTypesT,
|
|
50
34
|
algorithm: AlgorithmT,
|
|
51
35
|
publicKey: PublicKeyT,
|
|
52
36
|
version: VersionT
|
|
53
37
|
}).And((0, _runtypes.Partial)({
|
|
54
38
|
dnssec: _runtypes.Boolean
|
|
55
|
-
}));
|
|
56
|
-
exports.OpenAttestationDnsDidRecordT = OpenAttestationDnsDidRecordT;
|
|
39
|
+
}));
|
package/dist/records/dnsTxt.js
CHANGED
|
@@ -3,30 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.OpenAttestationDNSTextRecordT = exports.
|
|
7
|
-
|
|
6
|
+
exports.RecordTypesT = exports.OpenAttestationDNSTextRecordT = exports.HederaNetworks = exports.HederaNetworkIdT = exports.HederaAccountIDT = exports.EthereumNetworks = exports.EthereumNetworkIdT = exports.EthereumAddressT = exports.BlockchainNetworkT = void 0;
|
|
8
7
|
var _runtypes = require("runtypes");
|
|
8
|
+
const RecordTypesT = exports.RecordTypesT = (0, _runtypes.Literal)("openatts");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.
|
|
13
|
-
const BlockchainNetworkT = (0, _runtypes.Union)((0, _runtypes.Literal)("ethereum"), (0, _runtypes.Literal)("hedera"));
|
|
14
|
-
exports.BlockchainNetworkT = BlockchainNetworkT;
|
|
15
|
-
|
|
16
|
-
const EthereumAddressT = _runtypes.String.withConstraint(maybeAddress => {
|
|
10
|
+
// export const BlockchainNetworkT = Literal("ethereum");
|
|
11
|
+
const BlockchainNetworkT = exports.BlockchainNetworkT = (0, _runtypes.Union)((0, _runtypes.Literal)("ethereum"), (0, _runtypes.Literal)("hedera"));
|
|
12
|
+
const EthereumAddressT = exports.EthereumAddressT = _runtypes.String.withConstraint(maybeAddress => {
|
|
17
13
|
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid ethereum address`;
|
|
18
14
|
});
|
|
19
|
-
|
|
20
|
-
exports.EthereumAddressT = EthereumAddressT;
|
|
21
|
-
|
|
22
|
-
const HederaAccountIDT = _runtypes.String.withConstraint(maybeAddress => {
|
|
15
|
+
const HederaAccountIDT = exports.HederaAccountIDT = _runtypes.String.withConstraint(maybeAddress => {
|
|
23
16
|
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid hedera address`;
|
|
24
17
|
});
|
|
25
|
-
|
|
26
|
-
exports.HederaAccountIDT = HederaAccountIDT;
|
|
27
|
-
let EthereumNetworks;
|
|
28
|
-
exports.EthereumNetworks = EthereumNetworks;
|
|
29
|
-
|
|
18
|
+
let EthereumNetworks = exports.EthereumNetworks = void 0;
|
|
30
19
|
(function (EthereumNetworks) {
|
|
31
20
|
EthereumNetworks["homestead"] = "1";
|
|
32
21
|
EthereumNetworks["ropsten"] = "3";
|
|
@@ -35,25 +24,20 @@ exports.EthereumNetworks = EthereumNetworks;
|
|
|
35
24
|
EthereumNetworks["sepolia"] = "11155111";
|
|
36
25
|
EthereumNetworks["polygon"] = "137";
|
|
37
26
|
EthereumNetworks["polygonMumbai"] = "80001";
|
|
27
|
+
EthereumNetworks["polygonAmoy"] = "80002";
|
|
38
28
|
EthereumNetworks["local"] = "1337";
|
|
39
29
|
EthereumNetworks["xdc"] = "50";
|
|
40
30
|
EthereumNetworks["xdcapothem"] = "51";
|
|
41
31
|
EthereumNetworks["stabilityTestnet"] = "20180427";
|
|
42
32
|
})(EthereumNetworks || (exports.EthereumNetworks = EthereumNetworks = {}));
|
|
43
|
-
|
|
44
|
-
let HederaNetworks;
|
|
45
|
-
exports.HederaNetworks = HederaNetworks;
|
|
46
|
-
|
|
33
|
+
let HederaNetworks = exports.HederaNetworks = void 0;
|
|
47
34
|
(function (HederaNetworks) {
|
|
48
35
|
HederaNetworks["mainnet"] = "295";
|
|
49
36
|
HederaNetworks["testnet"] = "296";
|
|
50
37
|
})(HederaNetworks || (exports.HederaNetworks = HederaNetworks = {}));
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
exports.
|
|
54
|
-
const 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.polygonMumbai), (0, _runtypes.Literal)(EthereumNetworks.xdc), (0, _runtypes.Literal)(EthereumNetworks.xdcapothem), (0, _runtypes.Literal)(EthereumNetworks.stabilityTestnet), (0, _runtypes.Literal)(EthereumNetworks.local));
|
|
55
|
-
exports.EthereumNetworkIdT = EthereumNetworkIdT;
|
|
56
|
-
const OpenAttestationDNSTextRecordT = (0, _runtypes.Union)((0, _runtypes.Record)({
|
|
38
|
+
const HederaNetworkIdT = exports.HederaNetworkIdT = (0, _runtypes.Union)((0, _runtypes.Literal)(HederaNetworks.mainnet), (0, _runtypes.Literal)(HederaNetworks.testnet));
|
|
39
|
+
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.polygonMumbai), (0, _runtypes.Literal)(EthereumNetworks.polygonAmoy), (0, _runtypes.Literal)(EthereumNetworks.xdc), (0, _runtypes.Literal)(EthereumNetworks.xdcapothem), (0, _runtypes.Literal)(EthereumNetworks.stabilityTestnet), (0, _runtypes.Literal)(EthereumNetworks.local));
|
|
40
|
+
const OpenAttestationDNSTextRecordT = exports.OpenAttestationDNSTextRecordT = (0, _runtypes.Union)((0, _runtypes.Record)({
|
|
57
41
|
type: RecordTypesT,
|
|
58
42
|
net: (0, _runtypes.Literal)("ethereum"),
|
|
59
43
|
netId: EthereumNetworkIdT,
|
|
@@ -67,5 +51,4 @@ const OpenAttestationDNSTextRecordT = (0, _runtypes.Union)((0, _runtypes.Record)
|
|
|
67
51
|
addr: HederaAccountIDT
|
|
68
52
|
}).And((0, _runtypes.Partial)({
|
|
69
53
|
dnssec: _runtypes.Boolean
|
|
70
|
-
})));
|
|
71
|
-
exports.OpenAttestationDNSTextRecordT = OpenAttestationDNSTextRecordT;
|
|
54
|
+
})));
|
|
@@ -11,6 +11,7 @@ export declare enum EthereumNetworks {
|
|
|
11
11
|
sepolia = "11155111",
|
|
12
12
|
polygon = "137",
|
|
13
13
|
polygonMumbai = "80001",
|
|
14
|
+
polygonAmoy = "80002",
|
|
14
15
|
local = "1337",
|
|
15
16
|
xdc = "50",
|
|
16
17
|
xdcapothem = "51",
|
|
@@ -21,11 +22,11 @@ export declare enum HederaNetworks {
|
|
|
21
22
|
testnet = "296"
|
|
22
23
|
}
|
|
23
24
|
export declare const HederaNetworkIdT: Union<[Literal<HederaNetworks.mainnet>, Literal<HederaNetworks.testnet>]>;
|
|
24
|
-
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.polygonMumbai>, Literal<EthereumNetworks.xdc>, Literal<EthereumNetworks.xdcapothem>, Literal<EthereumNetworks.stabilityTestnet>, Literal<EthereumNetworks.local>]>;
|
|
25
|
+
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.polygonMumbai>, Literal<EthereumNetworks.polygonAmoy>, Literal<EthereumNetworks.xdc>, Literal<EthereumNetworks.xdcapothem>, Literal<EthereumNetworks.stabilityTestnet>, Literal<EthereumNetworks.local>]>;
|
|
25
26
|
export declare const OpenAttestationDNSTextRecordT: Union<[import("runtypes").Intersect<[Record<{
|
|
26
27
|
type: Literal<"openatts">;
|
|
27
28
|
net: Literal<"ethereum">;
|
|
28
|
-
netId: Union<[Literal<EthereumNetworks.homestead>, Literal<EthereumNetworks.ropsten>, Literal<EthereumNetworks.rinkeby>, Literal<EthereumNetworks.goerli>, Literal<EthereumNetworks.sepolia>, Literal<EthereumNetworks.polygon>, Literal<EthereumNetworks.polygonMumbai>, Literal<EthereumNetworks.xdc>, Literal<EthereumNetworks.xdcapothem>, Literal<EthereumNetworks.stabilityTestnet>, Literal<EthereumNetworks.local>]>;
|
|
29
|
+
netId: Union<[Literal<EthereumNetworks.homestead>, Literal<EthereumNetworks.ropsten>, Literal<EthereumNetworks.rinkeby>, Literal<EthereumNetworks.goerli>, Literal<EthereumNetworks.sepolia>, Literal<EthereumNetworks.polygon>, Literal<EthereumNetworks.polygonMumbai>, Literal<EthereumNetworks.polygonAmoy>, Literal<EthereumNetworks.xdc>, Literal<EthereumNetworks.xdcapothem>, Literal<EthereumNetworks.stabilityTestnet>, Literal<EthereumNetworks.local>]>;
|
|
29
30
|
addr: import("runtypes").Constraint<String, string, unknown>;
|
|
30
31
|
}, false>, Partial<{
|
|
31
32
|
dnssec: Boolean;
|
package/dist/util/logger.js
CHANGED
|
@@ -3,29 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.trace = exports.info = exports.getLogger = exports.error = void 0;
|
|
8
7
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
// not using .extends because of next.js resolve modules bug where its picking up old version of debug
|
|
13
10
|
const trace = namespace => (0, _debug.default)(`dnsprove:trace:${namespace}`);
|
|
14
|
-
|
|
15
11
|
exports.trace = trace;
|
|
16
|
-
|
|
17
12
|
const info = namespace => (0, _debug.default)(`dnsprove:info:${namespace}`);
|
|
18
|
-
|
|
19
13
|
exports.info = info;
|
|
20
|
-
|
|
21
14
|
const error = namespace => (0, _debug.default)(`dnsprove:error:${namespace}`);
|
|
22
|
-
|
|
23
15
|
exports.error = error;
|
|
24
|
-
|
|
25
16
|
const getLogger = namespace => ({
|
|
26
17
|
trace: trace(namespace),
|
|
27
18
|
info: info(namespace),
|
|
28
19
|
error: error(namespace)
|
|
29
20
|
});
|
|
30
|
-
|
|
31
21
|
exports.getLogger = getLogger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradetrust-tt/dnsprove",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Helper utility for retrieving OpenAttestations document store address records from DNS",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,11 +35,6 @@
|
|
|
35
35
|
"semantic-release": "semantic-release"
|
|
36
36
|
},
|
|
37
37
|
"types": "dist/ts",
|
|
38
|
-
"husky": {
|
|
39
|
-
"hooks": {
|
|
40
|
-
"pre-commit": "lint-staged"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
38
|
"lint-staged": {
|
|
44
39
|
"*.{js,ts,tsx}": [
|
|
45
40
|
"eslint --fix --ext js,ts,tsx",
|
|
@@ -50,7 +45,7 @@
|
|
|
50
45
|
"generator-nod"
|
|
51
46
|
],
|
|
52
47
|
"dependencies": {
|
|
53
|
-
"axios": "^
|
|
48
|
+
"axios": "^1.6.3",
|
|
54
49
|
"debug": "^4.3.1",
|
|
55
50
|
"runtypes": "^6.3.0"
|
|
56
51
|
},
|
|
@@ -60,33 +55,31 @@
|
|
|
60
55
|
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
61
56
|
"@babel/preset-env": "^7.13.15",
|
|
62
57
|
"@babel/preset-typescript": "^7.13.0",
|
|
63
|
-
"@commitlint/cli": "^
|
|
64
|
-
"@commitlint/config-conventional": "
|
|
65
|
-
"@commitlint/prompt": "^
|
|
66
|
-
"@ls-age/commitlint-circle": "^1.0.0",
|
|
67
|
-
"@types/axios": "^0.14.0",
|
|
58
|
+
"@commitlint/cli": "^18.4.3",
|
|
59
|
+
"@commitlint/config-conventional": "18.4.3",
|
|
60
|
+
"@commitlint/prompt": "^18.4.3",
|
|
68
61
|
"@types/debug": "^4.1.5",
|
|
69
62
|
"@types/jest": "^26.0.23",
|
|
70
63
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
|
71
64
|
"@typescript-eslint/parser": "^4.22.0",
|
|
72
65
|
"babel-eslint": "^10.1.0",
|
|
73
66
|
"babel-jest": "^26.6.3",
|
|
74
|
-
"commitizen": "^4.
|
|
75
|
-
"documentation": "^
|
|
67
|
+
"commitizen": "^4.3.0",
|
|
68
|
+
"documentation": "^14.0.2",
|
|
76
69
|
"eslint": "^7.25.0",
|
|
77
70
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
78
71
|
"eslint-config-prettier": "^8.3.0",
|
|
79
72
|
"eslint-plugin-import": "^2.22.1",
|
|
80
73
|
"eslint-plugin-prettier": "^3.4.0",
|
|
81
|
-
"git-cz": "^4.
|
|
82
|
-
"husky": "^
|
|
74
|
+
"git-cz": "^4.9.0",
|
|
75
|
+
"husky": "^8.0.3",
|
|
83
76
|
"jest": "^26.6.3",
|
|
84
77
|
"lint-staged": "^10.5.4",
|
|
85
78
|
"msw": "0.35.0",
|
|
86
|
-
"open-cli": "^
|
|
79
|
+
"open-cli": "^7.2.0",
|
|
87
80
|
"prettier": "^2.2.1",
|
|
88
81
|
"rimraf": "^3.0.2",
|
|
89
|
-
"semantic-release": "^
|
|
82
|
+
"semantic-release": "^22.0.8",
|
|
90
83
|
"ts-jest": "^26.5.5",
|
|
91
84
|
"typescript": "^4.2.4"
|
|
92
85
|
},
|
|
@@ -97,5 +90,8 @@
|
|
|
97
90
|
"commitizen": {
|
|
98
91
|
"path": "node_modules/@commitlint/prompt"
|
|
99
92
|
}
|
|
93
|
+
},
|
|
94
|
+
"engines": {
|
|
95
|
+
"node": "18.x"
|
|
100
96
|
}
|
|
101
97
|
}
|
package/src/index.test.ts
CHANGED
|
@@ -257,16 +257,32 @@ describe("queryDns", () => {
|
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
describe("getDocumentStoreRecords for Hedera", () => {
|
|
260
|
-
const sampleDnsTextRecord =
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
260
|
+
const sampleDnsTextRecord = [
|
|
261
|
+
{
|
|
262
|
+
type: "openatts",
|
|
263
|
+
net: "hedera",
|
|
264
|
+
netId: "296",
|
|
265
|
+
dnssec: false,
|
|
266
|
+
addr: "0x3DE43bfd3D771931E46CbBd4EDE0D3d95C85f81A",
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
addr: "0x222B69788e2e9B7FB93a3a0fE258D4604Dc7df21",
|
|
270
|
+
dnssec: false,
|
|
271
|
+
net: "hedera",
|
|
272
|
+
netId: "295",
|
|
273
|
+
type: "openatts",
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
addr: "0x222B69788e2e9B7FB93a3a0fE258D4604Dc7df21",
|
|
277
|
+
dnssec: false,
|
|
278
|
+
net: "hedera",
|
|
279
|
+
netId: "296",
|
|
280
|
+
type: "openatts",
|
|
281
|
+
},
|
|
282
|
+
];
|
|
267
283
|
|
|
268
284
|
test("it should work with trustlv.org", async () => {
|
|
269
285
|
const records = await getDocumentStoreRecords("trustlv.org");
|
|
270
|
-
expect(records).toStrictEqual(
|
|
286
|
+
expect(records).toStrictEqual(sampleDnsTextRecord);
|
|
271
287
|
});
|
|
272
288
|
});
|
package/src/records/dnsTxt.ts
CHANGED
|
@@ -21,6 +21,7 @@ export enum EthereumNetworks {
|
|
|
21
21
|
sepolia = "11155111",
|
|
22
22
|
polygon = "137",
|
|
23
23
|
polygonMumbai = "80001",
|
|
24
|
+
polygonAmoy = "80002",
|
|
24
25
|
local = "1337",
|
|
25
26
|
xdc = "50",
|
|
26
27
|
xdcapothem = "51",
|
|
@@ -41,6 +42,7 @@ export const EthereumNetworkIdT = Union(
|
|
|
41
42
|
Literal(EthereumNetworks.sepolia),
|
|
42
43
|
Literal(EthereumNetworks.polygon),
|
|
43
44
|
Literal(EthereumNetworks.polygonMumbai),
|
|
45
|
+
Literal(EthereumNetworks.polygonAmoy),
|
|
44
46
|
Literal(EthereumNetworks.xdc),
|
|
45
47
|
Literal(EthereumNetworks.xdcapothem),
|
|
46
48
|
Literal(EthereumNetworks.stabilityTestnet),
|
package/CHANGELOG.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|