@tradetrust-tt/dnsprove 2.13.1 → 2.14.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.
@@ -31,6 +31,7 @@ let EthereumNetworks = exports.EthereumNetworks = void 0;
31
31
  EthereumNetworks["stability"] = "101010";
32
32
  EthereumNetworks["hedera"] = "295";
33
33
  EthereumNetworks["hederatestnet"] = "296";
34
+ EthereumNetworks["astron"] = "1338";
34
35
  })(EthereumNetworks || (exports.EthereumNetworks = EthereumNetworks = {}));
35
36
  let HederaNetworks = exports.HederaNetworks = void 0;
36
37
  (function (HederaNetworks) {
@@ -38,7 +39,7 @@ let HederaNetworks = exports.HederaNetworks = void 0;
38
39
  HederaNetworks["testnet"] = "296";
39
40
  })(HederaNetworks || (exports.HederaNetworks = HederaNetworks = {}));
40
41
  const HederaNetworkIdT = exports.HederaNetworkIdT = (0, _runtypes.Union)((0, _runtypes.Literal)(HederaNetworks.mainnet), (0, _runtypes.Literal)(HederaNetworks.testnet));
41
- 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));
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));
42
43
  const OpenAttestationDNSTextRecordT = exports.OpenAttestationDNSTextRecordT = (0, _runtypes.Union)((0, _runtypes.Record)({
43
44
  type: RecordTypesT,
44
45
  net: (0, _runtypes.Literal)("ethereum"),
@@ -13,7 +13,7 @@ export interface IDNSQueryResponse {
13
13
  interface GenericObject {
14
14
  [key: string]: string;
15
15
  }
16
- export declare type CustomDnsResolver = (domain: string) => Promise<IDNSQueryResponse>;
16
+ export type CustomDnsResolver = (domain: string) => Promise<IDNSQueryResponse>;
17
17
  export declare const defaultDnsResolvers: CustomDnsResolver[];
18
18
  export declare const queryDns: (domain: string, customDnsResolvers: CustomDnsResolver[]) => Promise<IDNSQueryResponse>;
19
19
  /**
@@ -38,6 +38,6 @@ export declare const parseDnsDidResults: (recordSet: IDNSRecord[] | undefined, d
38
38
  addr: '0x2f60375e8144e16Adf1979936301D8341D58C36C',
39
39
  dnssec: true } ]
40
40
  */
41
- export declare const getDocumentStoreRecords: (domain: string, customDnsResolvers?: CustomDnsResolver[] | undefined) => Promise<OpenAttestationDNSTextRecord[]>;
42
- export declare const getDnsDidRecords: (domain: string, customDnsResolvers?: CustomDnsResolver[] | undefined) => Promise<OpenAttestationDnsDidRecord[]>;
41
+ export declare const getDocumentStoreRecords: (domain: string, customDnsResolvers?: CustomDnsResolver[]) => Promise<OpenAttestationDNSTextRecord[]>;
42
+ export declare const getDnsDidRecords: (domain: string, customDnsResolvers?: CustomDnsResolver[]) => Promise<OpenAttestationDnsDidRecord[]>;
43
43
  export { OpenAttestationDNSTextRecord, OpenAttestationDnsDidRecord };
@@ -12,4 +12,4 @@ export declare const OpenAttestationDnsDidRecordT: import("runtypes").Intersect<
12
12
  }, false>, Partial<{
13
13
  dnssec: Boolean;
14
14
  }, false>]>;
15
- export declare type OpenAttestationDnsDidRecord = Static<typeof OpenAttestationDnsDidRecordT>;
15
+ export type OpenAttestationDnsDidRecord = Static<typeof OpenAttestationDnsDidRecordT>;
@@ -17,18 +17,19 @@ export declare enum EthereumNetworks {
17
17
  stabilityTestnet = "20180427",
18
18
  stability = "101010",
19
19
  hedera = "295",
20
- hederatestnet = "296"
20
+ hederatestnet = "296",
21
+ astron = "1338"
21
22
  }
22
23
  export declare enum HederaNetworks {
23
24
  mainnet = "295",
24
25
  testnet = "296"
25
26
  }
26
27
  export declare const HederaNetworkIdT: Union<[Literal<HederaNetworks.mainnet>, Literal<HederaNetworks.testnet>]>;
27
- 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>]>;
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>]>;
28
29
  export declare const OpenAttestationDNSTextRecordT: Union<[import("runtypes").Intersect<[Record<{
29
30
  type: Literal<"openatts">;
30
31
  net: Literal<"ethereum">;
31
- 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.hedera>, Literal<EthereumNetworks.hederatestnet>]>;
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.hedera>, Literal<EthereumNetworks.hederatestnet>, Literal<EthereumNetworks.astron>]>;
32
33
  addr: import("runtypes").Constraint<String, string, unknown>;
33
34
  }, false>, Partial<{
34
35
  dnssec: Boolean;
@@ -40,7 +41,7 @@ export declare const OpenAttestationDNSTextRecordT: Union<[import("runtypes").In
40
41
  }, false>, Partial<{
41
42
  dnssec: Boolean;
42
43
  }, false>]>]>;
43
- export declare type BlockchainNetwork = Static<typeof BlockchainNetworkT>;
44
- export declare type EthereumAddress = Static<typeof EthereumAddressT>;
45
- export declare type OpenAttestationDNSTextRecord = Static<typeof OpenAttestationDNSTextRecordT>;
46
- export declare type RecordTypes = Static<typeof RecordTypesT>;
44
+ export type BlockchainNetwork = Static<typeof BlockchainNetworkT>;
45
+ export type EthereumAddress = Static<typeof EthereumAddressT>;
46
+ export type OpenAttestationDNSTextRecord = Static<typeof OpenAttestationDNSTextRecordT>;
47
+ export type RecordTypes = Static<typeof RecordTypesT>;
@@ -1,4 +1,3 @@
1
- /// <reference types="debug" />
2
1
  export declare const trace: (namespace: string) => import("debug").Debugger;
3
2
  export declare const info: (namespace: string) => import("debug").Debugger;
4
3
  export declare const error: (namespace: string) => import("debug").Debugger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradetrust-tt/dnsprove",
3
- "version": "2.13.1",
3
+ "version": "2.14.0",
4
4
  "description": "Helper utility for retrieving OpenAttestations document store address records from DNS",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "generator-nod"
46
46
  ],
47
47
  "dependencies": {
48
- "axios": "0.21.1",
48
+ "axios": "1.7.2",
49
49
  "debug": "^4.3.1",
50
50
  "runtypes": "^6.3.0"
51
51
  },
@@ -53,7 +53,7 @@
53
53
  "@babel/cli": "^7.13.16",
54
54
  "@babel/core": "^7.13.16",
55
55
  "@babel/plugin-proposal-class-properties": "^7.13.0",
56
- "@babel/preset-env": "^7.13.15",
56
+ "@babel/preset-env": "^7.24.8",
57
57
  "@babel/preset-typescript": "^7.13.0",
58
58
  "@commitlint/cli": "^18.4.3",
59
59
  "@commitlint/config-conventional": "18.4.3",
@@ -63,25 +63,25 @@
63
63
  "@typescript-eslint/eslint-plugin": "^4.22.0",
64
64
  "@typescript-eslint/parser": "^4.22.0",
65
65
  "babel-eslint": "^10.1.0",
66
- "babel-jest": "^26.6.3",
66
+ "babel-jest": "^29.7.0",
67
67
  "commitizen": "^4.3.0",
68
68
  "documentation": "^14.0.2",
69
69
  "eslint": "^7.25.0",
70
70
  "eslint-config-airbnb-base": "^14.2.1",
71
71
  "eslint-config-prettier": "^8.3.0",
72
- "eslint-plugin-import": "^2.22.1",
72
+ "eslint-plugin-import": "^2.29.1",
73
73
  "eslint-plugin-prettier": "^3.4.0",
74
74
  "git-cz": "^4.9.0",
75
75
  "husky": "^8.0.3",
76
- "jest": "^26.6.3",
76
+ "jest": "^29.7.0",
77
77
  "lint-staged": "^10.5.4",
78
- "msw": "0.35.0",
78
+ "msw": "^2.3.1",
79
79
  "open-cli": "^7.2.0",
80
80
  "prettier": "^2.2.1",
81
81
  "rimraf": "^3.0.2",
82
82
  "semantic-release": "^22.0.8",
83
- "ts-jest": "^26.5.5",
84
- "typescript": "^4.2.4"
83
+ "ts-jest": "^29.2.2",
84
+ "typescript": "5.5.3"
85
85
  },
86
86
  "publishConfig": {
87
87
  "access": "public"
package/src/index.test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
2
  import { setupServer, SetupServerApi } from "msw/node";
3
- import { rest } from "msw";
3
+ import { http, HttpResponse } from "msw";
4
4
  import { CustomDnsResolver, getDocumentStoreRecords, queryDns, parseDocumentStoreResults, getDnsDidRecords } from ".";
5
5
  import { DnsproveStatusCode } from "./common/error";
6
6
 
@@ -234,8 +234,8 @@ describe("queryDns", () => {
234
234
 
235
235
  test("Should work for first dns if first dns is not down", async () => {
236
236
  const handlers = [
237
- rest.get("https://dns.google/resolve", (_, res, ctx) => {
238
- return res(ctx.json(sampleResponse));
237
+ http.get("https://dns.google/resolve", (_) => {
238
+ return HttpResponse.json(sampleResponse);
239
239
  }),
240
240
  ];
241
241
 
@@ -249,11 +249,11 @@ describe("queryDns", () => {
249
249
 
250
250
  test("Should fallback to second dns when first dns is down", async () => {
251
251
  const handlers = [
252
- rest.get("https://dns.google/resolve", (_, res, ctx) => {
253
- return res(ctx.status(500));
252
+ http.get("https://dns.google/resolve", (_) => {
253
+ return new HttpResponse(null, { status: 500 });
254
254
  }),
255
- rest.get("https://cloudflare-dns.com/dns-query", (_, res, ctx) => {
256
- return res(ctx.json(sampleResponse));
255
+ http.get("https://cloudflare-dns.com/dns-query", (_) => {
256
+ return HttpResponse.json(sampleResponse);
257
257
  }),
258
258
  ];
259
259
  server = setupServer(...handlers);
@@ -267,11 +267,11 @@ describe("queryDns", () => {
267
267
 
268
268
  test("Should throw error when all dns provided are down", async () => {
269
269
  const handlers = [
270
- rest.get("https://dns.google/resolve", (_, res, ctx) => {
271
- return res(ctx.status(500));
270
+ http.get("https://dns.google/resolve", (_) => {
271
+ return new HttpResponse(null, { status: 500 });
272
272
  }),
273
- rest.get("https://cloudflare-dns.com/dns-query", (_, res, ctx) => {
274
- return res(ctx.status(500));
273
+ http.get("https://cloudflare-dns.com/dns-query", (_) => {
274
+ return new HttpResponse(null, { status: 500 });
275
275
  }),
276
276
  ];
277
277
  server = setupServer(...handlers);
@@ -328,3 +328,20 @@ describe("getDocumentStoreRecords for Hedera", () => {
328
328
  expect(records).toStrictEqual(sampleDnsTextRecord);
329
329
  });
330
330
  });
331
+
332
+ describe("getDocumentStoreRecords for Astron", () => {
333
+ const sampleDnsTextRecord = [
334
+ {
335
+ type: "openatts",
336
+ net: "ethereum",
337
+ netId: "1338",
338
+ addr: "0x0D5da59B93e8AC9b1781CE5694fbcE626586F4c9",
339
+ dnssec: false,
340
+ },
341
+ ];
342
+
343
+ test("it should work with astronlayer2.bitfactory.cn", async () => {
344
+ const records = await getDocumentStoreRecords("astronlayer2.bitfactory.cn");
345
+ expect(records).toStrictEqual(sampleDnsTextRecord);
346
+ });
347
+ });
@@ -28,12 +28,14 @@ export enum EthereumNetworks {
28
28
  stability = "101010",
29
29
  hedera = "295",
30
30
  hederatestnet = "296",
31
+ astron = "1338",
31
32
  }
32
33
 
33
34
  export enum HederaNetworks {
34
35
  mainnet = "295",
35
36
  testnet = "296",
36
37
  }
38
+
37
39
  export const HederaNetworkIdT = Union(Literal(HederaNetworks.mainnet), Literal(HederaNetworks.testnet));
38
40
 
39
41
  export const EthereumNetworkIdT = Union(
@@ -50,7 +52,8 @@ export const EthereumNetworkIdT = Union(
50
52
  Literal(EthereumNetworks.stability),
51
53
  Literal(EthereumNetworks.local),
52
54
  Literal(EthereumNetworks.hedera),
53
- Literal(EthereumNetworks.hederatestnet)
55
+ Literal(EthereumNetworks.hederatestnet),
56
+ Literal(EthereumNetworks.astron)
54
57
  );
55
58
 
56
59
  export const OpenAttestationDNSTextRecordT = Union(