@tradetrust-tt/dnsprove 2.19.0 → 2.20.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/records/dnsTxt.js +2 -19
- package/dist/ts/records/dnsTxt.d.ts +3 -19
- package/package.json +1 -1
- package/src/index.test.ts +70 -0
- package/src/records/dnsTxt.ts +3 -33
package/dist/records/dnsTxt.js
CHANGED
|
@@ -3,31 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RecordTypesT = exports.OpenAttestationDNSTextRecordT = exports.
|
|
6
|
+
exports.RecordTypesT = exports.OpenAttestationDNSTextRecordT = 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
9
|
const BlockchainNetworkT = exports.BlockchainNetworkT = (0, _runtypes.Literal)("ethereum");
|
|
10
10
|
const EthereumAddressT = exports.EthereumAddressT = _runtypes.String.withConstraint(maybeAddress => {
|
|
11
11
|
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid ethereum address`;
|
|
12
12
|
});
|
|
13
|
-
|
|
14
|
-
(function (EthereumNetworks) {
|
|
15
|
-
EthereumNetworks["homestead"] = "1";
|
|
16
|
-
EthereumNetworks["ropsten"] = "3";
|
|
17
|
-
EthereumNetworks["rinkeby"] = "4";
|
|
18
|
-
EthereumNetworks["goerli"] = "5";
|
|
19
|
-
EthereumNetworks["sepolia"] = "11155111";
|
|
20
|
-
EthereumNetworks["polygon"] = "137";
|
|
21
|
-
EthereumNetworks["polygonAmoy"] = "80002";
|
|
22
|
-
EthereumNetworks["local"] = "1337";
|
|
23
|
-
EthereumNetworks["xdc"] = "50";
|
|
24
|
-
EthereumNetworks["xdcapothem"] = "51";
|
|
25
|
-
EthereumNetworks["stabilityTestnet"] = "20180427";
|
|
26
|
-
EthereumNetworks["stability"] = "101010";
|
|
27
|
-
EthereumNetworks["astronTestnet"] = "21002";
|
|
28
|
-
EthereumNetworks["astron"] = "1338";
|
|
29
|
-
})(EthereumNetworks || (exports.EthereumNetworks = EthereumNetworks = {}));
|
|
30
|
-
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.astronTestnet), (0, _runtypes.Literal)(EthereumNetworks.astron));
|
|
13
|
+
const EthereumNetworkIdT = exports.EthereumNetworkIdT = _runtypes.String.withConstraint(maybeNetId => /^\d+$/.test(maybeNetId) || `${maybeNetId} is not a valid numeric network id`);
|
|
31
14
|
const OpenAttestationDNSTextRecordT = exports.OpenAttestationDNSTextRecordT = (0, _runtypes.Record)({
|
|
32
15
|
type: RecordTypesT,
|
|
33
16
|
net: BlockchainNetworkT,
|
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
import { Static, Boolean, String, Literal, Record,
|
|
1
|
+
import { Static, Boolean, String, Literal, Record, Partial } from "runtypes";
|
|
2
2
|
export declare const RecordTypesT: Literal<"openatts">;
|
|
3
3
|
export declare const BlockchainNetworkT: Literal<"ethereum">;
|
|
4
4
|
export declare const EthereumAddressT: import("runtypes").Constraint<String, string, unknown>;
|
|
5
|
-
export declare
|
|
6
|
-
homestead = "1",
|
|
7
|
-
ropsten = "3",
|
|
8
|
-
rinkeby = "4",
|
|
9
|
-
goerli = "5",
|
|
10
|
-
sepolia = "11155111",
|
|
11
|
-
polygon = "137",
|
|
12
|
-
polygonAmoy = "80002",
|
|
13
|
-
local = "1337",
|
|
14
|
-
xdc = "50",
|
|
15
|
-
xdcapothem = "51",
|
|
16
|
-
stabilityTestnet = "20180427",
|
|
17
|
-
stability = "101010",
|
|
18
|
-
astronTestnet = "21002",
|
|
19
|
-
astron = "1338"
|
|
20
|
-
}
|
|
21
|
-
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.astronTestnet>, Literal<EthereumNetworks.astron>]>;
|
|
5
|
+
export declare const EthereumNetworkIdT: import("runtypes").Constraint<String, string, unknown>;
|
|
22
6
|
export declare const OpenAttestationDNSTextRecordT: import("runtypes").Intersect<[Record<{
|
|
23
7
|
type: Literal<"openatts">;
|
|
24
8
|
net: Literal<"ethereum">;
|
|
25
|
-
netId:
|
|
9
|
+
netId: import("runtypes").Constraint<String, string, unknown>;
|
|
26
10
|
addr: import("runtypes").Constraint<String, string, unknown>;
|
|
27
11
|
}, false>, Partial<{
|
|
28
12
|
dnssec: Boolean;
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -173,6 +173,76 @@ describe("parseDocumentStoreResults", () => {
|
|
|
173
173
|
];
|
|
174
174
|
expect(parseDocumentStoreResults(sampleRecord, true)).toStrictEqual([]);
|
|
175
175
|
});
|
|
176
|
+
|
|
177
|
+
test("it should accept any numeric netId (e.g. Mantle mainnet 5000)", () => {
|
|
178
|
+
const addr = "0x2f60375e8144e16Adf1979936301D8341D58C36C";
|
|
179
|
+
const sampleRecord = [
|
|
180
|
+
{
|
|
181
|
+
name: "example.example.com.",
|
|
182
|
+
type: 16,
|
|
183
|
+
TTL: 110,
|
|
184
|
+
data: `"openatts net=ethereum netId=5000 addr=${addr}"`,
|
|
185
|
+
dnssec: false,
|
|
186
|
+
},
|
|
187
|
+
];
|
|
188
|
+
expect(parseDocumentStoreResults(sampleRecord, false)).toStrictEqual([
|
|
189
|
+
{
|
|
190
|
+
type: "openatts",
|
|
191
|
+
net: "ethereum",
|
|
192
|
+
netId: "5000",
|
|
193
|
+
addr,
|
|
194
|
+
dnssec: false,
|
|
195
|
+
},
|
|
196
|
+
]);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("it should accept an arbitrary previously-unknown numeric netId", () => {
|
|
200
|
+
const addr = "0x2f60375e8144e16Adf1979936301D8341D58C36C";
|
|
201
|
+
const sampleRecord = [
|
|
202
|
+
{
|
|
203
|
+
name: "example.example.com.",
|
|
204
|
+
type: 16,
|
|
205
|
+
TTL: 110,
|
|
206
|
+
data: `"openatts net=ethereum netId=99999 addr=${addr}"`,
|
|
207
|
+
dnssec: false,
|
|
208
|
+
},
|
|
209
|
+
];
|
|
210
|
+
expect(parseDocumentStoreResults(sampleRecord, false)).toStrictEqual([
|
|
211
|
+
{
|
|
212
|
+
type: "openatts",
|
|
213
|
+
net: "ethereum",
|
|
214
|
+
netId: "99999",
|
|
215
|
+
addr,
|
|
216
|
+
dnssec: false,
|
|
217
|
+
},
|
|
218
|
+
]);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("it should reject a non-numeric netId", () => {
|
|
222
|
+
const sampleRecord = [
|
|
223
|
+
{
|
|
224
|
+
name: "example.example.com.",
|
|
225
|
+
type: 16,
|
|
226
|
+
TTL: 110,
|
|
227
|
+
data: '"openatts net=ethereum netId=abc addr=0x2f60375e8144e16Adf1979936301D8341D58C36C"',
|
|
228
|
+
dnssec: false,
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
expect(parseDocumentStoreResults(sampleRecord, false)).toStrictEqual([]);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test("it should reject an alphanumeric netId", () => {
|
|
235
|
+
const sampleRecord = [
|
|
236
|
+
{
|
|
237
|
+
name: "example.example.com.",
|
|
238
|
+
type: 16,
|
|
239
|
+
TTL: 110,
|
|
240
|
+
data: '"openatts net=ethereum netId=1abc addr=0x2f60375e8144e16Adf1979936301D8341D58C36C"',
|
|
241
|
+
dnssec: false,
|
|
242
|
+
},
|
|
243
|
+
];
|
|
244
|
+
expect(parseDocumentStoreResults(sampleRecord, false)).toStrictEqual([]);
|
|
245
|
+
});
|
|
176
246
|
});
|
|
177
247
|
|
|
178
248
|
describe("queryDns", () => {
|
package/src/records/dnsTxt.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Static, Boolean, String, Literal, Record,
|
|
1
|
+
import { Static, Boolean, String, Literal, Record, Partial } from "runtypes";
|
|
2
2
|
|
|
3
3
|
export const RecordTypesT = Literal("openatts");
|
|
4
4
|
|
|
@@ -8,38 +8,8 @@ export const EthereumAddressT = String.withConstraint((maybeAddress: string) =>
|
|
|
8
8
|
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid ethereum address`;
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
ropsten = "3",
|
|
14
|
-
rinkeby = "4",
|
|
15
|
-
goerli = "5",
|
|
16
|
-
sepolia = "11155111",
|
|
17
|
-
polygon = "137",
|
|
18
|
-
polygonAmoy = "80002",
|
|
19
|
-
local = "1337",
|
|
20
|
-
xdc = "50",
|
|
21
|
-
xdcapothem = "51",
|
|
22
|
-
stabilityTestnet = "20180427",
|
|
23
|
-
stability = "101010",
|
|
24
|
-
astronTestnet = "21002",
|
|
25
|
-
astron = "1338",
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const EthereumNetworkIdT = Union(
|
|
29
|
-
Literal(EthereumNetworks.homestead),
|
|
30
|
-
Literal(EthereumNetworks.ropsten),
|
|
31
|
-
Literal(EthereumNetworks.rinkeby),
|
|
32
|
-
Literal(EthereumNetworks.goerli),
|
|
33
|
-
Literal(EthereumNetworks.sepolia),
|
|
34
|
-
Literal(EthereumNetworks.polygon),
|
|
35
|
-
Literal(EthereumNetworks.polygonAmoy),
|
|
36
|
-
Literal(EthereumNetworks.xdc),
|
|
37
|
-
Literal(EthereumNetworks.xdcapothem),
|
|
38
|
-
Literal(EthereumNetworks.stabilityTestnet),
|
|
39
|
-
Literal(EthereumNetworks.stability),
|
|
40
|
-
Literal(EthereumNetworks.local),
|
|
41
|
-
Literal(EthereumNetworks.astronTestnet),
|
|
42
|
-
Literal(EthereumNetworks.astron)
|
|
11
|
+
export const EthereumNetworkIdT = String.withConstraint(
|
|
12
|
+
(maybeNetId: string) => /^\d+$/.test(maybeNetId) || `${maybeNetId} is not a valid numeric network id`
|
|
43
13
|
);
|
|
44
14
|
|
|
45
15
|
export const OpenAttestationDNSTextRecordT = Record({
|