@tradetrust-tt/dnsprove 2.8.1 → 2.9.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 +30 -8
- package/dist/ts/records/dnsTxt.d.ts +16 -3
- package/package.json +1 -1
- package/src/index.test.ts +15 -0
- package/src/records/dnsTxt.ts +25 -10
package/dist/records/dnsTxt.js
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.OpenAttestationDNSTextRecordT = exports.EthereumNetworkIdT = exports.EthereumNetworks = exports.EthereumAddressT = exports.BlockchainNetworkT = exports.RecordTypesT = void 0;
|
|
6
|
+
exports.OpenAttestationDNSTextRecordT = exports.EthereumNetworkIdT = exports.HederaNetworkIdT = exports.HederaNetworks = exports.EthereumNetworks = exports.HederaAccountIDT = exports.EthereumAddressT = exports.BlockchainNetworkT = exports.RecordTypesT = void 0;
|
|
7
7
|
|
|
8
8
|
var _runtypes = require("runtypes");
|
|
9
9
|
|
|
10
|
-
const RecordTypesT = (0, _runtypes.Literal)("openatts");
|
|
10
|
+
const RecordTypesT = (0, _runtypes.Literal)("openatts"); // export const BlockchainNetworkT = Literal("ethereum");
|
|
11
|
+
|
|
11
12
|
exports.RecordTypesT = RecordTypesT;
|
|
12
|
-
const BlockchainNetworkT = (0, _runtypes.Literal)("ethereum");
|
|
13
|
+
const BlockchainNetworkT = (0, _runtypes.Union)((0, _runtypes.Literal)("ethereum"), (0, _runtypes.Literal)("hedera"));
|
|
13
14
|
exports.BlockchainNetworkT = BlockchainNetworkT;
|
|
14
15
|
|
|
15
16
|
const EthereumAddressT = _runtypes.String.withConstraint(maybeAddress => {
|
|
@@ -17,6 +18,12 @@ const EthereumAddressT = _runtypes.String.withConstraint(maybeAddress => {
|
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
exports.EthereumAddressT = EthereumAddressT;
|
|
21
|
+
|
|
22
|
+
const HederaAccountIDT = _runtypes.String.withConstraint(maybeAddress => {
|
|
23
|
+
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid hedera address`;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
exports.HederaAccountIDT = HederaAccountIDT;
|
|
20
27
|
let EthereumNetworks;
|
|
21
28
|
exports.EthereumNetworks = EthereumNetworks;
|
|
22
29
|
|
|
@@ -33,16 +40,31 @@ exports.EthereumNetworks = EthereumNetworks;
|
|
|
33
40
|
EthereumNetworks["xdcapothem"] = "51";
|
|
34
41
|
})(EthereumNetworks || (exports.EthereumNetworks = EthereumNetworks = {}));
|
|
35
42
|
|
|
43
|
+
let HederaNetworks;
|
|
44
|
+
exports.HederaNetworks = HederaNetworks;
|
|
45
|
+
|
|
46
|
+
(function (HederaNetworks) {
|
|
47
|
+
HederaNetworks["mainnet"] = "295";
|
|
48
|
+
HederaNetworks["testnet"] = "296";
|
|
49
|
+
})(HederaNetworks || (exports.HederaNetworks = HederaNetworks = {}));
|
|
50
|
+
|
|
51
|
+
const HederaNetworkIdT = (0, _runtypes.Union)((0, _runtypes.Literal)(HederaNetworks.mainnet), (0, _runtypes.Literal)(HederaNetworks.testnet));
|
|
52
|
+
exports.HederaNetworkIdT = HederaNetworkIdT;
|
|
36
53
|
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.local));
|
|
37
54
|
exports.EthereumNetworkIdT = EthereumNetworkIdT;
|
|
38
|
-
const OpenAttestationDNSTextRecordT = (0, _runtypes.Record)({
|
|
55
|
+
const OpenAttestationDNSTextRecordT = (0, _runtypes.Union)((0, _runtypes.Record)({
|
|
39
56
|
type: RecordTypesT,
|
|
40
|
-
net:
|
|
41
|
-
// key names are directly lifted from the dns-txt record format
|
|
57
|
+
net: (0, _runtypes.Literal)("ethereum"),
|
|
42
58
|
netId: EthereumNetworkIdT,
|
|
43
|
-
// they are abbreviated because of 255 char constraint on dns-txt records
|
|
44
59
|
addr: EthereumAddressT
|
|
45
60
|
}).And((0, _runtypes.Partial)({
|
|
46
61
|
dnssec: _runtypes.Boolean
|
|
47
|
-
}))
|
|
62
|
+
})), (0, _runtypes.Record)({
|
|
63
|
+
type: RecordTypesT,
|
|
64
|
+
net: (0, _runtypes.Literal)("hedera"),
|
|
65
|
+
netId: HederaNetworkIdT,
|
|
66
|
+
addr: HederaAccountIDT
|
|
67
|
+
}).And((0, _runtypes.Partial)({
|
|
68
|
+
dnssec: _runtypes.Boolean
|
|
69
|
+
})));
|
|
48
70
|
exports.OpenAttestationDNSTextRecordT = OpenAttestationDNSTextRecordT;
|
|
@@ -1,7 +1,8 @@
|
|
|
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: Literal<"ethereum">;
|
|
3
|
+
export declare const BlockchainNetworkT: Union<[Literal<"ethereum">, Literal<"hedera">]>;
|
|
4
4
|
export declare const EthereumAddressT: import("runtypes").Constraint<String, string, unknown>;
|
|
5
|
+
export declare const HederaAccountIDT: import("runtypes").Constraint<String, string, unknown>;
|
|
5
6
|
export declare enum EthereumNetworks {
|
|
6
7
|
homestead = "1",
|
|
7
8
|
ropsten = "3",
|
|
@@ -14,15 +15,27 @@ export declare enum EthereumNetworks {
|
|
|
14
15
|
xdc = "50",
|
|
15
16
|
xdcapothem = "51"
|
|
16
17
|
}
|
|
18
|
+
export declare enum HederaNetworks {
|
|
19
|
+
mainnet = "295",
|
|
20
|
+
testnet = "296"
|
|
21
|
+
}
|
|
22
|
+
export declare const HederaNetworkIdT: Union<[Literal<HederaNetworks.mainnet>, Literal<HederaNetworks.testnet>]>;
|
|
17
23
|
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.local>]>;
|
|
18
|
-
export declare const OpenAttestationDNSTextRecordT: import("runtypes").Intersect<[Record<{
|
|
24
|
+
export declare const OpenAttestationDNSTextRecordT: Union<[import("runtypes").Intersect<[Record<{
|
|
19
25
|
type: Literal<"openatts">;
|
|
20
26
|
net: Literal<"ethereum">;
|
|
21
27
|
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.local>]>;
|
|
22
28
|
addr: import("runtypes").Constraint<String, string, unknown>;
|
|
23
29
|
}, false>, Partial<{
|
|
24
30
|
dnssec: Boolean;
|
|
25
|
-
}, false>]
|
|
31
|
+
}, false>]>, import("runtypes").Intersect<[Record<{
|
|
32
|
+
type: Literal<"openatts">;
|
|
33
|
+
net: Literal<"hedera">;
|
|
34
|
+
netId: Union<[Literal<HederaNetworks.mainnet>, Literal<HederaNetworks.testnet>]>;
|
|
35
|
+
addr: import("runtypes").Constraint<String, string, unknown>;
|
|
36
|
+
}, false>, Partial<{
|
|
37
|
+
dnssec: Boolean;
|
|
38
|
+
}, false>]>]>;
|
|
26
39
|
export declare type BlockchainNetwork = Static<typeof BlockchainNetworkT>;
|
|
27
40
|
export declare type EthereumAddress = Static<typeof EthereumAddressT>;
|
|
28
41
|
export declare type OpenAttestationDNSTextRecord = Static<typeof OpenAttestationDNSTextRecordT>;
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -255,3 +255,18 @@ describe("queryDns", () => {
|
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
257
|
});
|
|
258
|
+
|
|
259
|
+
describe("getDocumentStoreRecords for Hedera", () => {
|
|
260
|
+
const sampleDnsTextRecord = {
|
|
261
|
+
type: "openatts",
|
|
262
|
+
net: "hedera",
|
|
263
|
+
netId: "296",
|
|
264
|
+
dnssec: false,
|
|
265
|
+
addr: "0x3498b8e0A00fC8c3a1f64647AC85EEE8E1baF953",
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
test("it should work with trustlv.org", async () => {
|
|
269
|
+
const records = await getDocumentStoreRecords("trustlv.org");
|
|
270
|
+
expect(records).toStrictEqual([sampleDnsTextRecord]);
|
|
271
|
+
});
|
|
272
|
+
});
|
package/src/records/dnsTxt.ts
CHANGED
|
@@ -2,12 +2,17 @@ import { Static, Boolean, String, Literal, Record, Union, Partial } from "runtyp
|
|
|
2
2
|
|
|
3
3
|
export const RecordTypesT = Literal("openatts");
|
|
4
4
|
|
|
5
|
-
export const BlockchainNetworkT = Literal("ethereum");
|
|
5
|
+
// export const BlockchainNetworkT = Literal("ethereum");
|
|
6
|
+
export const BlockchainNetworkT = Union(Literal("ethereum"), Literal("hedera"));
|
|
6
7
|
|
|
7
8
|
export const EthereumAddressT = String.withConstraint((maybeAddress: string) => {
|
|
8
9
|
return /0x[a-fA-F0-9]{40}/.test(maybeAddress) || `${maybeAddress} is not a valid ethereum address`;
|
|
9
10
|
});
|
|
10
11
|
|
|
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
|
+
|
|
11
16
|
export enum EthereumNetworks {
|
|
12
17
|
homestead = "1",
|
|
13
18
|
ropsten = "3",
|
|
@@ -21,6 +26,12 @@ export enum EthereumNetworks {
|
|
|
21
26
|
xdcapothem = "51",
|
|
22
27
|
}
|
|
23
28
|
|
|
29
|
+
export enum HederaNetworks {
|
|
30
|
+
mainnet = "295",
|
|
31
|
+
testnet = "296",
|
|
32
|
+
}
|
|
33
|
+
export const HederaNetworkIdT = Union(Literal(HederaNetworks.mainnet), Literal(HederaNetworks.testnet));
|
|
34
|
+
|
|
24
35
|
export const EthereumNetworkIdT = Union(
|
|
25
36
|
Literal(EthereumNetworks.homestead),
|
|
26
37
|
Literal(EthereumNetworks.ropsten),
|
|
@@ -34,15 +45,19 @@ export const EthereumNetworkIdT = Union(
|
|
|
34
45
|
Literal(EthereumNetworks.local)
|
|
35
46
|
);
|
|
36
47
|
|
|
37
|
-
export const OpenAttestationDNSTextRecordT =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Partial({
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
export const OpenAttestationDNSTextRecordT = Union(
|
|
49
|
+
Record({
|
|
50
|
+
type: RecordTypesT,
|
|
51
|
+
net: Literal("ethereum"),
|
|
52
|
+
netId: EthereumNetworkIdT,
|
|
53
|
+
addr: EthereumAddressT,
|
|
54
|
+
}).And(Partial({ dnssec: Boolean })),
|
|
55
|
+
Record({
|
|
56
|
+
type: RecordTypesT,
|
|
57
|
+
net: Literal("hedera"),
|
|
58
|
+
netId: HederaNetworkIdT,
|
|
59
|
+
addr: HederaAccountIDT,
|
|
60
|
+
}).And(Partial({ dnssec: Boolean }))
|
|
46
61
|
);
|
|
47
62
|
|
|
48
63
|
export type BlockchainNetwork = Static<typeof BlockchainNetworkT>;
|