@xyo-network/xns-payload-plugins 3.4.4 → 3.4.6
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/package.json +5 -5
- package/plugins/record/dist/browser/index.d.ts +629 -0
- package/plugins/record/dist/browser/index.mjs +575 -0
- package/plugins/record/dist/browser/index.mjs.map +1 -0
- package/plugins/record/dist/neutral/index.d.ts +629 -0
- package/plugins/record/dist/neutral/index.mjs +575 -0
- package/plugins/record/dist/neutral/index.mjs.map +1 -0
- package/plugins/record/dist/node/index.d.ts +629 -0
- package/plugins/record/dist/node/index.mjs +575 -0
- package/plugins/record/dist/node/index.mjs.map +1 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
// src/Address/Payload.ts
|
|
2
|
+
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
3
|
+
var AddressRecordSchema = "network.xyo.ns.record.address";
|
|
4
|
+
var isAddressRecord = isPayloadOfSchemaType(AddressRecordSchema);
|
|
5
|
+
|
|
6
|
+
// src/diviner/DomainLeaseEstimateDiviner/Schema.ts
|
|
7
|
+
var DomainLeaseEstimateDivinerValidationErrorDetailsSchema = "network.xyo.diviner.ns.domain.registration.lease.estimate.validation.error.details";
|
|
8
|
+
|
|
9
|
+
// src/diviner/DomainLeaseEstimateDiviner/ErrorDetails/ErrorCodes.ts
|
|
10
|
+
var DomainLeaseEstimateDivinerErrorDetailsDictionary = {
|
|
11
|
+
0: {
|
|
12
|
+
code: "0",
|
|
13
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
14
|
+
title: "Success"
|
|
15
|
+
},
|
|
16
|
+
1: {
|
|
17
|
+
code: "1",
|
|
18
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
19
|
+
title: "Invalid casing"
|
|
20
|
+
},
|
|
21
|
+
2: {
|
|
22
|
+
code: "2",
|
|
23
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
24
|
+
title: "Invalid coin signature"
|
|
25
|
+
},
|
|
26
|
+
3: {
|
|
27
|
+
code: "3",
|
|
28
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
29
|
+
title: "Invalid length"
|
|
30
|
+
},
|
|
31
|
+
4: {
|
|
32
|
+
code: "4",
|
|
33
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
34
|
+
title: "Invalid name"
|
|
35
|
+
},
|
|
36
|
+
5: {
|
|
37
|
+
code: "5",
|
|
38
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
39
|
+
title: "Reserved fragment"
|
|
40
|
+
},
|
|
41
|
+
6: {
|
|
42
|
+
code: "6",
|
|
43
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
44
|
+
title: "Reserved name"
|
|
45
|
+
},
|
|
46
|
+
7: {
|
|
47
|
+
code: "7",
|
|
48
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
49
|
+
title: "Reserved string"
|
|
50
|
+
},
|
|
51
|
+
8: {
|
|
52
|
+
code: "8",
|
|
53
|
+
schema: DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
54
|
+
title: "Invalid TLD"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// src/diviner/DomainLeaseEstimateDiviner/ErrorDetails/Payload.ts
|
|
59
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType2, isPayloadOfSchemaTypeWithSources } from "@xyo-network/payload-model";
|
|
60
|
+
var isDomainLeaseEstimateDivinerValidationErrorDetails = isPayloadOfSchemaType2(
|
|
61
|
+
DomainLeaseEstimateDivinerValidationErrorDetailsSchema
|
|
62
|
+
);
|
|
63
|
+
var isDomainLeaseEstimateDivinerValidationErrorDetailsWithSources = isPayloadOfSchemaTypeWithSources(DomainLeaseEstimateDivinerValidationErrorDetailsSchema);
|
|
64
|
+
|
|
65
|
+
// src/diviner/lib/parseEstimatesFromArray.ts
|
|
66
|
+
import { findAs } from "@xylabs/array";
|
|
67
|
+
import { exists } from "@xylabs/exists";
|
|
68
|
+
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
69
|
+
import {
|
|
70
|
+
asHashLeaseEstimate,
|
|
71
|
+
HashLeaseEstimateSchema
|
|
72
|
+
} from "@xyo-network/diviner-hash-lease";
|
|
73
|
+
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
74
|
+
|
|
75
|
+
// src/DomainRegistration/DomainRegistration.ts
|
|
76
|
+
import { AsObjectFactory as AsObjectFactory3 } from "@xylabs/object";
|
|
77
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType5, isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources4 } from "@xyo-network/payload-model";
|
|
78
|
+
|
|
79
|
+
// src/Domain/Domain.ts
|
|
80
|
+
import { AsObjectFactory } from "@xylabs/object";
|
|
81
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType3, isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources2 } from "@xyo-network/payload-model";
|
|
82
|
+
var DomainSchema = "network.xyo.ns.domain";
|
|
83
|
+
var isDomain = isPayloadOfSchemaType3(DomainSchema);
|
|
84
|
+
var asDomain = AsObjectFactory.create(isDomain);
|
|
85
|
+
var asOptionalDomain = AsObjectFactory.createOptional(isDomain);
|
|
86
|
+
var isDomainWithSources = isPayloadOfSchemaTypeWithSources2(DomainSchema);
|
|
87
|
+
var asDomainWithSources = AsObjectFactory.create(isDomainWithSources);
|
|
88
|
+
var asOptionalDomainWithSources = AsObjectFactory.createOptional(isDomainWithSources);
|
|
89
|
+
|
|
90
|
+
// src/Domain/DomainLease.ts
|
|
91
|
+
import { AsObjectFactory as AsObjectFactory2 } from "@xylabs/object";
|
|
92
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType4, isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources3 } from "@xyo-network/payload-model";
|
|
93
|
+
var DomainLeaseSchema = "network.xyo.ns.domain.lease";
|
|
94
|
+
var isDomainLease = isPayloadOfSchemaType4(DomainLeaseSchema);
|
|
95
|
+
var asDomainLease = AsObjectFactory2.create(isDomainLease);
|
|
96
|
+
var asOptionalDomainLease = AsObjectFactory2.createOptional(isDomainLease);
|
|
97
|
+
var isDomainLeaseWithSources = isPayloadOfSchemaTypeWithSources3(DomainLeaseSchema);
|
|
98
|
+
var asDomainLeaseWithSources = AsObjectFactory2.create(isDomainLeaseWithSources);
|
|
99
|
+
var asOptionalDomainLeaseWithSources = AsObjectFactory2.createOptional(isDomainLeaseWithSources);
|
|
100
|
+
|
|
101
|
+
// src/DomainRegistration/DomainRegistration.ts
|
|
102
|
+
var DomainRegistrationSchema = `${DomainSchema}.registration`;
|
|
103
|
+
var isDomainRegistration = isPayloadOfSchemaType5(DomainRegistrationSchema);
|
|
104
|
+
var asDomainRegistration = AsObjectFactory3.create(isDomainRegistration);
|
|
105
|
+
var asOptionalDomainRegistration = AsObjectFactory3.createOptional(isDomainRegistration);
|
|
106
|
+
var isDomainRegistrationWithSources = isPayloadOfSchemaTypeWithSources4(DomainRegistrationSchema);
|
|
107
|
+
var asDomainRegistrationWithSources = AsObjectFactory3.create(isDomainRegistrationWithSources);
|
|
108
|
+
var asOptionalDomainRegistrationWithSources = AsObjectFactory3.createOptional(isDomainRegistrationWithSources);
|
|
109
|
+
|
|
110
|
+
// src/DomainRegistration/DomainRegistrationLease.ts
|
|
111
|
+
import { AsObjectFactory as AsObjectFactory4 } from "@xylabs/object";
|
|
112
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType6, isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources5 } from "@xyo-network/payload-model";
|
|
113
|
+
var DomainRegistrationLeaseSchema = `${DomainRegistrationSchema}.lease`;
|
|
114
|
+
var isDomainRegistrationLease = isPayloadOfSchemaType6(DomainRegistrationLeaseSchema);
|
|
115
|
+
var asDomainRegistrationLease = AsObjectFactory4.create(isDomainRegistrationLease);
|
|
116
|
+
var asOptionalDomainRegistrationLease = AsObjectFactory4.createOptional(isDomainRegistrationLease);
|
|
117
|
+
var isDomainRegistrationLeaseWithSources = isPayloadOfSchemaTypeWithSources5(DomainRegistrationLeaseSchema);
|
|
118
|
+
var asDomainRegistrationLeaseWithSources = AsObjectFactory4.create(isDomainRegistrationLeaseWithSources);
|
|
119
|
+
var asOptionalDomainRegistrationLeaseWithSources = AsObjectFactory4.createOptional(isDomainRegistrationLeaseWithSources);
|
|
120
|
+
var isDomainRegistrationLeaseSources = isDomainRegistrationLeaseWithSources;
|
|
121
|
+
|
|
122
|
+
// src/diviner/lib/parseEstimatesFromArray.ts
|
|
123
|
+
var parseEstimatesFromArray = async (payloads) => {
|
|
124
|
+
if (!payloads) return [];
|
|
125
|
+
const bws = payloads.filter(isBoundWitness).filter(hasEstimatePayloads) ?? [];
|
|
126
|
+
if (bws.length === 0) return [];
|
|
127
|
+
const hashMap = await PayloadBuilder.toAllHashMap(payloads);
|
|
128
|
+
return bws.map((bw) => {
|
|
129
|
+
const hashLeaseEstimate = getPayloadBySchemaFromBoundWitness(
|
|
130
|
+
bw,
|
|
131
|
+
HashLeaseEstimateSchema,
|
|
132
|
+
hashMap,
|
|
133
|
+
asHashLeaseEstimate
|
|
134
|
+
);
|
|
135
|
+
if (!hashLeaseEstimate) return;
|
|
136
|
+
const domainLease = getPayloadBySchemaFromBoundWitness(
|
|
137
|
+
bw,
|
|
138
|
+
DomainRegistrationLeaseSchema,
|
|
139
|
+
hashMap,
|
|
140
|
+
asDomainRegistrationLeaseWithSources
|
|
141
|
+
);
|
|
142
|
+
if (!domainLease) return;
|
|
143
|
+
return [bw, hashLeaseEstimate, domainLease];
|
|
144
|
+
}).filter(exists);
|
|
145
|
+
};
|
|
146
|
+
var hasEstimatePayloads = (bw) => {
|
|
147
|
+
return bw.payload_schemas.includes(DomainRegistrationLeaseSchema) && bw.payload_schemas.includes(HashLeaseEstimateSchema);
|
|
148
|
+
};
|
|
149
|
+
var getPayloadBySchemaFromBoundWitness = (bw, schema, hashMap, identity) => {
|
|
150
|
+
const schemaIndex = bw.payload_schemas.indexOf(schema);
|
|
151
|
+
if (schemaIndex === -1) return;
|
|
152
|
+
const hash = bw.payload_hashes[schemaIndex];
|
|
153
|
+
return findAs([hashMap[hash]], identity);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// src/DNS/types/OperationCodes.ts
|
|
157
|
+
var DNSQueryOpcodes = {
|
|
158
|
+
QUERY: 0,
|
|
159
|
+
IQUERY: 1,
|
|
160
|
+
STATUS: 2,
|
|
161
|
+
NOTIFY: 4,
|
|
162
|
+
UPDATE: 5,
|
|
163
|
+
DSO: 6
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/DNS/types/ResponseCodes.ts
|
|
167
|
+
var DNSRcodes = {
|
|
168
|
+
NOERROR: 0,
|
|
169
|
+
FORMERR: 1,
|
|
170
|
+
SERVFAIL: 2,
|
|
171
|
+
NXDOMAIN: 3,
|
|
172
|
+
NOTIMP: 4,
|
|
173
|
+
REFUSED: 5,
|
|
174
|
+
YXDOMAIN: 6,
|
|
175
|
+
YXRRSET: 7,
|
|
176
|
+
NXRRSET: 8,
|
|
177
|
+
NOTAUTH: 9,
|
|
178
|
+
NOTZONE: 10,
|
|
179
|
+
BADSIG: 16,
|
|
180
|
+
BADKEY: 17,
|
|
181
|
+
BADTIME: 18
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// src/DNS/types/Header.ts
|
|
185
|
+
var StandardRequestHeader = {
|
|
186
|
+
ID: 0,
|
|
187
|
+
QR: 0,
|
|
188
|
+
// Query/Response Flag (0 = Query)
|
|
189
|
+
Opcode: DNSQueryOpcodes.QUERY,
|
|
190
|
+
// Operation Code (0 for standard query)
|
|
191
|
+
AA: 0,
|
|
192
|
+
// Authoritative Answer (0 in query)
|
|
193
|
+
TC: 0,
|
|
194
|
+
// Truncation (0 for non-truncated)
|
|
195
|
+
RD: 1,
|
|
196
|
+
// Recursion Desired (1 if recursion is requested)
|
|
197
|
+
RCODE: DNSRcodes.NOERROR,
|
|
198
|
+
// Response Code (always 0 in query)
|
|
199
|
+
QDCOUNT: 1,
|
|
200
|
+
ANCOUNT: 0,
|
|
201
|
+
NSCOUNT: 0,
|
|
202
|
+
ARCOUNT: 0
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// src/DNS/types/ResourceRecord.ts
|
|
206
|
+
var DNSResourceRecordTypes = {
|
|
207
|
+
"A": 1,
|
|
208
|
+
// a host address
|
|
209
|
+
"NS": 2,
|
|
210
|
+
// an authoritative name server
|
|
211
|
+
"MD": 3,
|
|
212
|
+
// a mail destination (OBSOLETE - use MX)
|
|
213
|
+
"MF": 4,
|
|
214
|
+
// a mail forwarder (OBSOLETE - use MX)
|
|
215
|
+
"CNAME": 5,
|
|
216
|
+
// the canonical name for an alias
|
|
217
|
+
"SOA": 6,
|
|
218
|
+
// marks the start of a zone of authority
|
|
219
|
+
"MB": 7,
|
|
220
|
+
// a mailbox domain name (EXPERIMENTAL)
|
|
221
|
+
"MG": 8,
|
|
222
|
+
// a mail group member (EXPERIMENTAL)
|
|
223
|
+
"MR": 9,
|
|
224
|
+
// a mail rename domain name (EXPERIMENTAL)
|
|
225
|
+
"NULL": 10,
|
|
226
|
+
// a null RR (EXPERIMENTAL)
|
|
227
|
+
"WKS": 11,
|
|
228
|
+
// a well known service description
|
|
229
|
+
"PTR": 12,
|
|
230
|
+
// a domain name pointer
|
|
231
|
+
"HINFO": 13,
|
|
232
|
+
// host information
|
|
233
|
+
"MINFO": 14,
|
|
234
|
+
// mailbox or mail list information
|
|
235
|
+
"MX": 15,
|
|
236
|
+
// mail exchange
|
|
237
|
+
"TXT": 16,
|
|
238
|
+
// text strings
|
|
239
|
+
"RP": 17,
|
|
240
|
+
// for Responsible Person
|
|
241
|
+
"AFSDB": 18,
|
|
242
|
+
// for AFS Data Base location
|
|
243
|
+
"X25": 19,
|
|
244
|
+
// for X.25 PSDN address
|
|
245
|
+
"ISDN": 20,
|
|
246
|
+
// for ISDN address
|
|
247
|
+
"RT": 21,
|
|
248
|
+
// for Route Through
|
|
249
|
+
"NSAP": 22,
|
|
250
|
+
// for NSAP address, NSAP style A record (DEPRECATED)
|
|
251
|
+
"NSAP-PTR": 23,
|
|
252
|
+
// for domain name pointer, NSAP style (DEPRECATED)
|
|
253
|
+
"SIG": 24,
|
|
254
|
+
// for security signature
|
|
255
|
+
"KEY": 25,
|
|
256
|
+
// for security key
|
|
257
|
+
"PX": 26,
|
|
258
|
+
// X.400 mail mapping information
|
|
259
|
+
"GPOS": 27,
|
|
260
|
+
// Geographical Position
|
|
261
|
+
"AAAA": 28,
|
|
262
|
+
// IP6 Address
|
|
263
|
+
"LOC": 29,
|
|
264
|
+
// Location Information
|
|
265
|
+
"NXT": 30,
|
|
266
|
+
// Next Domain (OBSOLETE)
|
|
267
|
+
"EID": 31,
|
|
268
|
+
// Endpoint Identifier
|
|
269
|
+
"NIMLOC": 32,
|
|
270
|
+
// Nimrod Locator
|
|
271
|
+
"SRV": 33,
|
|
272
|
+
// Server Selection
|
|
273
|
+
"ATMA": 34,
|
|
274
|
+
// ATM Address
|
|
275
|
+
"NAPTR": 35,
|
|
276
|
+
// Naming Authority Pointer
|
|
277
|
+
"KX": 36,
|
|
278
|
+
// Key Exchanger
|
|
279
|
+
"CERT": 37,
|
|
280
|
+
// CERT
|
|
281
|
+
"A6": 38,
|
|
282
|
+
// A6 (OBSOLETE - use AAAA)
|
|
283
|
+
"DNAME": 39,
|
|
284
|
+
// DNAME
|
|
285
|
+
"SINK": 40,
|
|
286
|
+
// SINK
|
|
287
|
+
"OPT": 41,
|
|
288
|
+
// OPT
|
|
289
|
+
"APL": 42,
|
|
290
|
+
// APL
|
|
291
|
+
"DS": 43,
|
|
292
|
+
// Delegation Signer
|
|
293
|
+
"SSHFP": 44,
|
|
294
|
+
// SSH Key Fingerprint
|
|
295
|
+
"IPSECKEY": 45,
|
|
296
|
+
// IPSECKEY
|
|
297
|
+
"RRSIG": 46,
|
|
298
|
+
// RRSIG
|
|
299
|
+
"NSEC": 47,
|
|
300
|
+
// NSEC
|
|
301
|
+
"DNSKEY": 48,
|
|
302
|
+
// DNSKEY
|
|
303
|
+
"DHCID": 49,
|
|
304
|
+
// DHCID
|
|
305
|
+
"NSEC3": 50,
|
|
306
|
+
// NSEC3
|
|
307
|
+
"NSEC3PARAM": 51,
|
|
308
|
+
// NSEC3PARAM
|
|
309
|
+
"TLSA": 52,
|
|
310
|
+
// TLSA
|
|
311
|
+
"SMIMEA": 53,
|
|
312
|
+
// S/MIME cert association
|
|
313
|
+
"HIP": 55,
|
|
314
|
+
// Host Identity Protocol
|
|
315
|
+
"NINFO": 56,
|
|
316
|
+
// NINFO
|
|
317
|
+
"RKEY": 57,
|
|
318
|
+
// RKEY
|
|
319
|
+
"TALINK": 58,
|
|
320
|
+
// Trust Anchor LINK
|
|
321
|
+
"CDS": 59,
|
|
322
|
+
// Child DS
|
|
323
|
+
"CDNSKEY": 60,
|
|
324
|
+
// DNSKEY(s) the Child wants reflected in DS
|
|
325
|
+
"OPENPGPKEY": 61,
|
|
326
|
+
// OpenPGP Key
|
|
327
|
+
"CSYNC": 62,
|
|
328
|
+
// Child-To-Parent Synchronization
|
|
329
|
+
"ZONEMD": 63,
|
|
330
|
+
// Message Digest Over Zone Data
|
|
331
|
+
"SVCB": 64,
|
|
332
|
+
// General-purpose service binding
|
|
333
|
+
"HTTPS": 65,
|
|
334
|
+
// SVCB-compatible type for use with HTTP
|
|
335
|
+
"SPF": 99,
|
|
336
|
+
"UINFO": 100,
|
|
337
|
+
"UID": 101,
|
|
338
|
+
"GID": 102,
|
|
339
|
+
"UNSPEC": 103,
|
|
340
|
+
"NID": 104,
|
|
341
|
+
"L32": 105,
|
|
342
|
+
"L64": 106,
|
|
343
|
+
"LP": 107,
|
|
344
|
+
"EUI48": 108,
|
|
345
|
+
// an EUI-48 address
|
|
346
|
+
"EUI64": 109,
|
|
347
|
+
// an EUI-64 address
|
|
348
|
+
"NXNAME": 128,
|
|
349
|
+
// NXDOMAIN indicator for Compact Denial of Existence
|
|
350
|
+
"TKEY": 249,
|
|
351
|
+
// Transaction Key
|
|
352
|
+
"TSIG": 250,
|
|
353
|
+
// Transaction Signature
|
|
354
|
+
"IXFR": 251,
|
|
355
|
+
// incremental transfer
|
|
356
|
+
"AXFR": 252,
|
|
357
|
+
// transfer of an entire zone
|
|
358
|
+
"MAILB": 253,
|
|
359
|
+
// mailbox-related RRs (MB, MG or MR)
|
|
360
|
+
"MAILA": 254,
|
|
361
|
+
// mail agent RRs (OBSOLETE - see MX)
|
|
362
|
+
"*": 255,
|
|
363
|
+
// A request for some or all records the server has available
|
|
364
|
+
"URI": 256,
|
|
365
|
+
// URI
|
|
366
|
+
"CAA": 257,
|
|
367
|
+
// Certification Authority Restriction
|
|
368
|
+
"AVC": 258,
|
|
369
|
+
// Application Visibility and Control
|
|
370
|
+
"DOA": 259,
|
|
371
|
+
// Digital Object Architecture
|
|
372
|
+
"AMTRELAY": 260,
|
|
373
|
+
// Automatic Multicast Tunneling Relay
|
|
374
|
+
"RESINFO": 261,
|
|
375
|
+
// Resolver Information as Key/Value Pairs
|
|
376
|
+
"WALLET": 262,
|
|
377
|
+
// Public wallet address
|
|
378
|
+
"CLA": 263,
|
|
379
|
+
// BP Convergence Layer Adapter
|
|
380
|
+
"IPN": 264,
|
|
381
|
+
// BP Node Number
|
|
382
|
+
"TA": 32768,
|
|
383
|
+
// DNSSEC Trust Authorities
|
|
384
|
+
"DLV": 32769,
|
|
385
|
+
// DNSSEC Lookaside Validation (OBSOLETE)
|
|
386
|
+
// NOTE: Custom types here chosen within the Private Use Range
|
|
387
|
+
// https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4
|
|
388
|
+
// https://www.rfc-editor.org/rfc/rfc5226
|
|
389
|
+
// as, per the RFC, the Private Use Range is reserved
|
|
390
|
+
// "For private or local use only, with the type and
|
|
391
|
+
// purpose defined by the local site. No attempt is made to
|
|
392
|
+
// prevent multiple sites from using the same value in
|
|
393
|
+
// different (and incompatible) ways. There is no need for
|
|
394
|
+
// IANA to review such assignments (since IANA does not record
|
|
395
|
+
// them) and assignments are not generally useful for broad
|
|
396
|
+
// interoperability. It is the responsibility of the sites
|
|
397
|
+
// making use of the Private Use range to ensure that no
|
|
398
|
+
// conflicts occur (within the intended scope of use)."
|
|
399
|
+
// If we want to apply for a custom reserved code later
|
|
400
|
+
// on, once the usage is proven enough we can absolutely
|
|
401
|
+
// do that.
|
|
402
|
+
"XYOA": 65432,
|
|
403
|
+
// XYO Address
|
|
404
|
+
"XYOH": 65433
|
|
405
|
+
// XYO Hash
|
|
406
|
+
};
|
|
407
|
+
var findDNSResourceRecordTypesByValue = (value) => {
|
|
408
|
+
for (const key in DNSResourceRecordTypes) {
|
|
409
|
+
const resourceRecordType = key;
|
|
410
|
+
if (DNSResourceRecordTypes[resourceRecordType] === value) {
|
|
411
|
+
return resourceRecordType;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return void 0;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
// src/DNS/types/Request.ts
|
|
418
|
+
var getRequestFor = (domain, type = DNSResourceRecordTypes.A) => {
|
|
419
|
+
return {
|
|
420
|
+
...StandardRequestHeader,
|
|
421
|
+
ID: getRandomId(),
|
|
422
|
+
Question: [{
|
|
423
|
+
name: domain,
|
|
424
|
+
type,
|
|
425
|
+
class: 1
|
|
426
|
+
}]
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
var getRandomId = () => {
|
|
430
|
+
return Math.floor(Math.random() * 65536);
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
// src/DNS/Witness/Schema.ts
|
|
434
|
+
var DNSSchema = "network.xyo.dns";
|
|
435
|
+
|
|
436
|
+
// src/DNS/Witness/Config.ts
|
|
437
|
+
var DNSWitnessConfigSchema = `${DNSSchema}.witness.config`;
|
|
438
|
+
|
|
439
|
+
// src/DNS/Witness/Payload/Request.ts
|
|
440
|
+
import { AsObjectFactory as AsObjectFactory5 } from "@xylabs/object";
|
|
441
|
+
import {
|
|
442
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType7,
|
|
443
|
+
isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources6
|
|
444
|
+
} from "@xyo-network/payload-model";
|
|
445
|
+
var isDNSRequest = isPayloadOfSchemaType7(DNSSchema);
|
|
446
|
+
var asDNSRequest = AsObjectFactory5.create(isDNSRequest);
|
|
447
|
+
var asOptionalDNSRequest = AsObjectFactory5.createOptional(isDNSRequest);
|
|
448
|
+
var isDNSRequestWithSources = isPayloadOfSchemaTypeWithSources6(DNSSchema);
|
|
449
|
+
var asDNSRequestWithSources = AsObjectFactory5.create(isDNSRequestWithSources);
|
|
450
|
+
var asOptionalDNSRequestWithSources = AsObjectFactory5.createOptional(isDNSRequestWithSources);
|
|
451
|
+
var getDnsRequestFor = (domain, type = DNSResourceRecordTypes.A) => {
|
|
452
|
+
return { ...getRequestFor(domain, type), schema: DNSSchema };
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// src/DNS/Witness/Payload/Response.ts
|
|
456
|
+
import { AsObjectFactory as AsObjectFactory6 } from "@xylabs/object";
|
|
457
|
+
import {
|
|
458
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType8,
|
|
459
|
+
isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources7
|
|
460
|
+
} from "@xyo-network/payload-model";
|
|
461
|
+
var isDNSResponse = isPayloadOfSchemaType8(DNSSchema);
|
|
462
|
+
var asDNSResponse = AsObjectFactory6.create(isDNSResponse);
|
|
463
|
+
var asOptionalDNSResponse = AsObjectFactory6.createOptional(isDNSResponse);
|
|
464
|
+
var isDNSResponseWithSources = isPayloadOfSchemaTypeWithSources7(DNSSchema);
|
|
465
|
+
var asDNSResponseWithSources = AsObjectFactory6.create(isDNSResponseWithSources);
|
|
466
|
+
var asOptionalDNSResponseWithSources = AsObjectFactory6.createOptional(isDNSResponseWithSources);
|
|
467
|
+
|
|
468
|
+
// src/Duration/validation/validateBoundWitness.ts
|
|
469
|
+
import { BoundWitnessValidator } from "@xyo-network/boundwitness-validator";
|
|
470
|
+
var validateBoundWitness = async (recordBw, requiredSchemas = []) => {
|
|
471
|
+
if (!requiredSchemas.every((requiredSchema) => recordBw.payload_schemas.includes(requiredSchema))) return false;
|
|
472
|
+
const validator = new BoundWitnessValidator(recordBw);
|
|
473
|
+
const errors = await validator.validate();
|
|
474
|
+
return errors.length === 0;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// src/Duration/validation/validateBoundWitnessAndDuration.ts
|
|
478
|
+
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
479
|
+
var validateBoundWitnessAndDuration = async (recordBw, recordPayload) => {
|
|
480
|
+
if (!await recordIsInBoundWitness(recordBw, recordPayload)) return false;
|
|
481
|
+
return recordIsTemporallyValidToBoundWitness(recordBw, recordPayload);
|
|
482
|
+
};
|
|
483
|
+
var recordIsInBoundWitness = async (recordBw, recordPayload) => {
|
|
484
|
+
const hash = await PayloadBuilder2.dataHash(recordPayload);
|
|
485
|
+
return recordBw.payload_hashes.includes(hash);
|
|
486
|
+
};
|
|
487
|
+
var recordIsTemporallyValidToBoundWitness = (_recordBw, _recordPayload) => {
|
|
488
|
+
return true;
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// src/Duration/validation/validateDuration.ts
|
|
492
|
+
var validateDuration = (recordPayload) => {
|
|
493
|
+
return isWithinDelegatedTimeframe(recordPayload);
|
|
494
|
+
};
|
|
495
|
+
var isWithinDelegatedTimeframe = (recordPayload, now = Date.now()) => {
|
|
496
|
+
return recordPayload.nbf < now && now < recordPayload.exp;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
// src/Duration/validation/validateBoundWitnessWithDuration.ts
|
|
500
|
+
var validateBoundWitnessWithDuration = async (recordBw, recordPayload) => {
|
|
501
|
+
if (!await validateBoundWitness(recordBw, [recordPayload.schema])) return false;
|
|
502
|
+
if (!validateDuration(recordPayload)) return false;
|
|
503
|
+
return await validateBoundWitnessAndDuration(recordBw, recordPayload);
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
// src/Hash/Payload.ts
|
|
507
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType9 } from "@xyo-network/payload-model";
|
|
508
|
+
var HashRecordSchema = "network.xyo.ns.record.hash";
|
|
509
|
+
var isHashRecord = isPayloadOfSchemaType9(HashRecordSchema);
|
|
510
|
+
export {
|
|
511
|
+
AddressRecordSchema,
|
|
512
|
+
DNSQueryOpcodes,
|
|
513
|
+
DNSRcodes,
|
|
514
|
+
DNSResourceRecordTypes,
|
|
515
|
+
DNSSchema,
|
|
516
|
+
DNSWitnessConfigSchema,
|
|
517
|
+
DomainLeaseEstimateDivinerErrorDetailsDictionary,
|
|
518
|
+
DomainLeaseEstimateDivinerValidationErrorDetailsSchema,
|
|
519
|
+
DomainLeaseSchema,
|
|
520
|
+
DomainRegistrationLeaseSchema,
|
|
521
|
+
DomainRegistrationSchema,
|
|
522
|
+
DomainSchema,
|
|
523
|
+
HashRecordSchema,
|
|
524
|
+
StandardRequestHeader,
|
|
525
|
+
asDNSRequest,
|
|
526
|
+
asDNSRequestWithSources,
|
|
527
|
+
asDNSResponse,
|
|
528
|
+
asDNSResponseWithSources,
|
|
529
|
+
asDomain,
|
|
530
|
+
asDomainLease,
|
|
531
|
+
asDomainLeaseWithSources,
|
|
532
|
+
asDomainRegistration,
|
|
533
|
+
asDomainRegistrationLease,
|
|
534
|
+
asDomainRegistrationLeaseWithSources,
|
|
535
|
+
asDomainRegistrationWithSources,
|
|
536
|
+
asDomainWithSources,
|
|
537
|
+
asOptionalDNSRequest,
|
|
538
|
+
asOptionalDNSRequestWithSources,
|
|
539
|
+
asOptionalDNSResponse,
|
|
540
|
+
asOptionalDNSResponseWithSources,
|
|
541
|
+
asOptionalDomain,
|
|
542
|
+
asOptionalDomainLease,
|
|
543
|
+
asOptionalDomainLeaseWithSources,
|
|
544
|
+
asOptionalDomainRegistration,
|
|
545
|
+
asOptionalDomainRegistrationLease,
|
|
546
|
+
asOptionalDomainRegistrationLeaseWithSources,
|
|
547
|
+
asOptionalDomainRegistrationWithSources,
|
|
548
|
+
asOptionalDomainWithSources,
|
|
549
|
+
findDNSResourceRecordTypesByValue,
|
|
550
|
+
getDnsRequestFor,
|
|
551
|
+
getRandomId,
|
|
552
|
+
getRequestFor,
|
|
553
|
+
isAddressRecord,
|
|
554
|
+
isDNSRequest,
|
|
555
|
+
isDNSRequestWithSources,
|
|
556
|
+
isDNSResponse,
|
|
557
|
+
isDNSResponseWithSources,
|
|
558
|
+
isDomain,
|
|
559
|
+
isDomainLease,
|
|
560
|
+
isDomainLeaseEstimateDivinerValidationErrorDetails,
|
|
561
|
+
isDomainLeaseEstimateDivinerValidationErrorDetailsWithSources,
|
|
562
|
+
isDomainLeaseWithSources,
|
|
563
|
+
isDomainRegistration,
|
|
564
|
+
isDomainRegistrationLease,
|
|
565
|
+
isDomainRegistrationLeaseSources,
|
|
566
|
+
isDomainRegistrationLeaseWithSources,
|
|
567
|
+
isDomainRegistrationWithSources,
|
|
568
|
+
isDomainWithSources,
|
|
569
|
+
isHashRecord,
|
|
570
|
+
isWithinDelegatedTimeframe,
|
|
571
|
+
parseEstimatesFromArray,
|
|
572
|
+
validateBoundWitnessWithDuration,
|
|
573
|
+
validateDuration
|
|
574
|
+
};
|
|
575
|
+
//# sourceMappingURL=index.mjs.map
|