@xyo-network/payload 2.43.3 → 2.43.4
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/cjs/index.d.ts +0 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/docs.json +704 -1397
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +7 -8
- package/src/index.ts +0 -1
- package/dist/cjs/SchemaNameValidator.d.ts +0 -68
- package/dist/cjs/SchemaNameValidator.d.ts.map +0 -1
- package/dist/cjs/SchemaNameValidator.js +0 -127
- package/dist/cjs/SchemaNameValidator.js.map +0 -1
- package/dist/esm/SchemaNameValidator.d.ts +0 -68
- package/dist/esm/SchemaNameValidator.d.ts.map +0 -1
- package/dist/esm/SchemaNameValidator.js +0 -114
- package/dist/esm/SchemaNameValidator.js.map +0 -1
- package/src/SchemaNameValidator.ts +0 -120
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,8BAA8B,CAAA"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,8BAA8B,CAAA"}
|
package/package.json
CHANGED
|
@@ -10,15 +10,14 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xyo-network/
|
|
14
|
-
"@xyo-network/
|
|
15
|
-
"@xyo-network/payload-
|
|
16
|
-
"@xyo-network/payload-
|
|
17
|
-
"@xyo-network/payload-
|
|
18
|
-
"@xyo-network/payload-wrapper": "^2.43.3"
|
|
13
|
+
"@xyo-network/huri": "^2.43.4",
|
|
14
|
+
"@xyo-network/payload-builder": "^2.43.4",
|
|
15
|
+
"@xyo-network/payload-model": "^2.43.4",
|
|
16
|
+
"@xyo-network/payload-validator": "^2.43.4",
|
|
17
|
+
"@xyo-network/payload-wrapper": "^2.43.4"
|
|
19
18
|
},
|
|
20
19
|
"devDependencies": {
|
|
21
|
-
"@xylabs/ts-scripts-yarn3": "^2.
|
|
20
|
+
"@xylabs/ts-scripts-yarn3": "^2.12.0"
|
|
22
21
|
},
|
|
23
22
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
24
23
|
"browser": "dist/esm/index.js",
|
|
@@ -53,5 +52,5 @@
|
|
|
53
52
|
},
|
|
54
53
|
"sideEffects": false,
|
|
55
54
|
"types": "dist/esm/index.d.ts",
|
|
56
|
-
"version": "2.43.
|
|
55
|
+
"version": "2.43.4"
|
|
57
56
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates a XYO schema structure and existence
|
|
3
|
-
*/
|
|
4
|
-
export declare class XyoSchemaNameValidator {
|
|
5
|
-
schema?: string;
|
|
6
|
-
private _parts?;
|
|
7
|
-
private _rootDomain?;
|
|
8
|
-
constructor(schema?: string);
|
|
9
|
-
/**
|
|
10
|
-
* Checks whether the schema is all lowercase
|
|
11
|
-
*
|
|
12
|
-
* @returns boolean
|
|
13
|
-
*/
|
|
14
|
-
get isLowercase(): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Levels in the schema
|
|
17
|
-
*
|
|
18
|
-
* @returns number
|
|
19
|
-
*/
|
|
20
|
-
get levels(): number | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* The schema converted into a string array split on '.'
|
|
23
|
-
*
|
|
24
|
-
* @returns string[]
|
|
25
|
-
*/
|
|
26
|
-
get parts(): string[] | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
29
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
30
|
-
* registration
|
|
31
|
-
*
|
|
32
|
-
* @returns string
|
|
33
|
-
*/
|
|
34
|
-
get rootDomain(): string | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Run all static validations
|
|
37
|
-
* @returns Error[]
|
|
38
|
-
*/
|
|
39
|
-
all(): Error[];
|
|
40
|
-
/**
|
|
41
|
-
* Run all the validations
|
|
42
|
-
* @param checkExistence - boolean
|
|
43
|
-
* @returns Error[]
|
|
44
|
-
*/
|
|
45
|
-
allDynamic(): Promise<Error[]>;
|
|
46
|
-
/**
|
|
47
|
-
* Determines how many levels of the schema's reverse domain
|
|
48
|
-
* pass DNS resolution
|
|
49
|
-
*
|
|
50
|
-
* @returns number (0 if none exist)
|
|
51
|
-
*/
|
|
52
|
-
domainExistenceDepth(): Promise<number>;
|
|
53
|
-
/**
|
|
54
|
-
* Checks if the root domain validates via DNS resolution
|
|
55
|
-
*
|
|
56
|
-
* @returns boolean
|
|
57
|
-
*/
|
|
58
|
-
rootDomainExists(): Promise<boolean>;
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* Get a domain for the schema at a certain level
|
|
62
|
-
*
|
|
63
|
-
* @param level - Zero based level to check
|
|
64
|
-
* @returns string
|
|
65
|
-
*/
|
|
66
|
-
private domainLevel;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=SchemaNameValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaNameValidator.d.ts","sourceRoot":"","sources":["../../src/SchemaNameValidator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,sBAAsB;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,WAAW,CAAC,CAAQ;gBAChB,MAAM,CAAC,EAAE,MAAM;IAI3B;;;;OAIG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;;;OAIG;IACH,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED;;;;OAIG;IACH,IAAI,KAAK,yBAGR;IAED;;;;;;OAMG;IACH,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAGnC;IAED;;;OAGG;IAEI,GAAG;IAQV;;;;OAIG;IAEU,UAAU;IAOvB;;;;;OAKG;IACU,oBAAoB;IAYjC;;;;OAIG;IACU,gBAAgB;IAI7B;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;CAMpB"}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XyoSchemaNameValidator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const dns_1 = require("@xyo-network/dns");
|
|
6
|
-
/**
|
|
7
|
-
* Validates a XYO schema structure and existence
|
|
8
|
-
*/
|
|
9
|
-
class XyoSchemaNameValidator {
|
|
10
|
-
constructor(schema) {
|
|
11
|
-
this.schema = schema;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Checks whether the schema is all lowercase
|
|
15
|
-
*
|
|
16
|
-
* @returns boolean
|
|
17
|
-
*/
|
|
18
|
-
get isLowercase() {
|
|
19
|
-
var _a;
|
|
20
|
-
return this.schema === ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Levels in the schema
|
|
24
|
-
*
|
|
25
|
-
* @returns number
|
|
26
|
-
*/
|
|
27
|
-
get levels() {
|
|
28
|
-
var _a;
|
|
29
|
-
return (_a = this.parts) === null || _a === void 0 ? void 0 : _a.length;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The schema converted into a string array split on '.'
|
|
33
|
-
*
|
|
34
|
-
* @returns string[]
|
|
35
|
-
*/
|
|
36
|
-
get parts() {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
this._parts = (_a = this._parts) !== null && _a !== void 0 ? _a : (_b = this.schema) === null || _b === void 0 ? void 0 : _b.split('.');
|
|
39
|
-
return this._parts;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
43
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
44
|
-
* registration
|
|
45
|
-
*
|
|
46
|
-
* @returns string
|
|
47
|
-
*/
|
|
48
|
-
get rootDomain() {
|
|
49
|
-
var _a;
|
|
50
|
-
this._rootDomain = (_a = this._rootDomain) !== null && _a !== void 0 ? _a : this.domainLevel(1);
|
|
51
|
-
return this._rootDomain;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Run all static validations
|
|
55
|
-
* @returns Error[]
|
|
56
|
-
*/
|
|
57
|
-
all() {
|
|
58
|
-
var _a, _b, _c;
|
|
59
|
-
const errors = [];
|
|
60
|
-
if (((_b = (_a = this.schema) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0)
|
|
61
|
-
errors.push(Error('schema missing'));
|
|
62
|
-
else if (((_c = this.levels) !== null && _c !== void 0 ? _c : 0) < 3)
|
|
63
|
-
errors.push(Error(`schema levels < 3 [${this.levels}, ${this.schema}]`));
|
|
64
|
-
else if (!this.isLowercase)
|
|
65
|
-
errors.push(Error(`schema not lowercase [${this.schema}]`));
|
|
66
|
-
return errors;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Run all the validations
|
|
70
|
-
* @param checkExistence - boolean
|
|
71
|
-
* @returns Error[]
|
|
72
|
-
*/
|
|
73
|
-
allDynamic() {
|
|
74
|
-
var _a, _b;
|
|
75
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const errors = [];
|
|
77
|
-
if (((_b = (_a = this.schema) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0)
|
|
78
|
-
errors.push(Error('schema missing'));
|
|
79
|
-
else if (!(yield this.rootDomainExists()))
|
|
80
|
-
errors.push(Error(`schema root domain must exist [${this.rootDomain}]`));
|
|
81
|
-
return errors;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Determines how many levels of the schema's reverse domain
|
|
86
|
-
* pass DNS resolution
|
|
87
|
-
*
|
|
88
|
-
* @returns number (0 if none exist)
|
|
89
|
-
*/
|
|
90
|
-
domainExistenceDepth() {
|
|
91
|
-
var _a;
|
|
92
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const levels = (_a = this.levels) !== null && _a !== void 0 ? _a : 0;
|
|
94
|
-
let level = 0;
|
|
95
|
-
while (level < levels) {
|
|
96
|
-
if (!(yield (0, dns_1.domainExists)(this.domainLevel(level)))) {
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
level += 1;
|
|
100
|
-
}
|
|
101
|
-
return level;
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Checks if the root domain validates via DNS resolution
|
|
106
|
-
*
|
|
107
|
-
* @returns boolean
|
|
108
|
-
*/
|
|
109
|
-
rootDomainExists() {
|
|
110
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
return yield (0, dns_1.domainExists)(this.rootDomain);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
* Get a domain for the schema at a certain level
|
|
117
|
-
*
|
|
118
|
-
* @param level - Zero based level to check
|
|
119
|
-
* @returns string
|
|
120
|
-
*/
|
|
121
|
-
domainLevel(level) {
|
|
122
|
-
var _a;
|
|
123
|
-
return (_a = this.parts) === null || _a === void 0 ? void 0 : _a.slice(0, level + 1).reverse().join('.');
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
exports.XyoSchemaNameValidator = XyoSchemaNameValidator;
|
|
127
|
-
//# sourceMappingURL=SchemaNameValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaNameValidator.js","sourceRoot":"","sources":["../../src/SchemaNameValidator.ts"],"names":[],"mappings":";;;;AAAA,0CAA+C;AAE/C;;GAEG;AACH,MAAa,sBAAsB;IAIjC,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAI,WAAW;;QACb,OAAO,IAAI,CAAC,MAAM,MAAK,MAAA,IAAI,CAAC,MAAM,0CAAE,WAAW,EAAE,CAAA,CAAA;IACnD,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;;QACR,OAAO,MAAA,IAAI,CAAC,KAAK,0CAAE,MAAM,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACH,IAAI,KAAK;;QACP,IAAI,CAAC,MAAM,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,CAAC,GAAG,CAAC,CAAA;QACpD,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED;;;;;;OAMG;IACH,IAAI,UAAU;;QACZ,IAAI,CAAC,WAAW,GAAG,MAAA,IAAI,CAAC,WAAW,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b,OAAO,KAAK,GAAG,MAAM,EAAE;gBACrB,IAAI,CAAC,CAAC,MAAM,IAAA,kBAAY,EAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;oBAClD,MAAK;iBACN;gBACD,KAAK,IAAI,CAAC,CAAA;aACX;YACD,OAAO,KAAK,CAAA;;KACb;IAED;;;;OAIG;IACU,gBAAgB;;YAC3B,OAAO,MAAM,IAAA,kBAAY,EAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC5C,CAAC;KAAA;IAED;;;;;;OAMG;IACK,WAAW,CAAC,KAAa;;QAC/B,OAAO,MAAA,IAAI,CAAC,KAAK,0CACb,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EACnB,OAAO,GACP,IAAI,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;CACF;AAlHD,wDAkHC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates a XYO schema structure and existence
|
|
3
|
-
*/
|
|
4
|
-
export declare class XyoSchemaNameValidator {
|
|
5
|
-
schema?: string;
|
|
6
|
-
private _parts?;
|
|
7
|
-
private _rootDomain?;
|
|
8
|
-
constructor(schema?: string);
|
|
9
|
-
/**
|
|
10
|
-
* Checks whether the schema is all lowercase
|
|
11
|
-
*
|
|
12
|
-
* @returns boolean
|
|
13
|
-
*/
|
|
14
|
-
get isLowercase(): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Levels in the schema
|
|
17
|
-
*
|
|
18
|
-
* @returns number
|
|
19
|
-
*/
|
|
20
|
-
get levels(): number | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* The schema converted into a string array split on '.'
|
|
23
|
-
*
|
|
24
|
-
* @returns string[]
|
|
25
|
-
*/
|
|
26
|
-
get parts(): string[] | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
29
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
30
|
-
* registration
|
|
31
|
-
*
|
|
32
|
-
* @returns string
|
|
33
|
-
*/
|
|
34
|
-
get rootDomain(): string | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Run all static validations
|
|
37
|
-
* @returns Error[]
|
|
38
|
-
*/
|
|
39
|
-
all(): Error[];
|
|
40
|
-
/**
|
|
41
|
-
* Run all the validations
|
|
42
|
-
* @param checkExistence - boolean
|
|
43
|
-
* @returns Error[]
|
|
44
|
-
*/
|
|
45
|
-
allDynamic(): Promise<Error[]>;
|
|
46
|
-
/**
|
|
47
|
-
* Determines how many levels of the schema's reverse domain
|
|
48
|
-
* pass DNS resolution
|
|
49
|
-
*
|
|
50
|
-
* @returns number (0 if none exist)
|
|
51
|
-
*/
|
|
52
|
-
domainExistenceDepth(): Promise<number>;
|
|
53
|
-
/**
|
|
54
|
-
* Checks if the root domain validates via DNS resolution
|
|
55
|
-
*
|
|
56
|
-
* @returns boolean
|
|
57
|
-
*/
|
|
58
|
-
rootDomainExists(): Promise<boolean>;
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* Get a domain for the schema at a certain level
|
|
62
|
-
*
|
|
63
|
-
* @param level - Zero based level to check
|
|
64
|
-
* @returns string
|
|
65
|
-
*/
|
|
66
|
-
private domainLevel;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=SchemaNameValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaNameValidator.d.ts","sourceRoot":"","sources":["../../src/SchemaNameValidator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,sBAAsB;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,WAAW,CAAC,CAAQ;gBAChB,MAAM,CAAC,EAAE,MAAM;IAI3B;;;;OAIG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;;;OAIG;IACH,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED;;;;OAIG;IACH,IAAI,KAAK,yBAGR;IAED;;;;;;OAMG;IACH,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAGnC;IAED;;;OAGG;IAEI,GAAG;IAQV;;;;OAIG;IAEU,UAAU;IAOvB;;;;;OAKG;IACU,oBAAoB;IAYjC;;;;OAIG;IACU,gBAAgB;IAI7B;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;CAMpB"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { domainExists } from '@xyo-network/dns';
|
|
2
|
-
/**
|
|
3
|
-
* Validates a XYO schema structure and existence
|
|
4
|
-
*/
|
|
5
|
-
export class XyoSchemaNameValidator {
|
|
6
|
-
schema;
|
|
7
|
-
_parts;
|
|
8
|
-
_rootDomain;
|
|
9
|
-
constructor(schema) {
|
|
10
|
-
this.schema = schema;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Checks whether the schema is all lowercase
|
|
14
|
-
*
|
|
15
|
-
* @returns boolean
|
|
16
|
-
*/
|
|
17
|
-
get isLowercase() {
|
|
18
|
-
return this.schema === this.schema?.toLowerCase();
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Levels in the schema
|
|
22
|
-
*
|
|
23
|
-
* @returns number
|
|
24
|
-
*/
|
|
25
|
-
get levels() {
|
|
26
|
-
return this.parts?.length;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The schema converted into a string array split on '.'
|
|
30
|
-
*
|
|
31
|
-
* @returns string[]
|
|
32
|
-
*/
|
|
33
|
-
get parts() {
|
|
34
|
-
this._parts = this._parts ?? this.schema?.split('.');
|
|
35
|
-
return this._parts;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
39
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
40
|
-
* registration
|
|
41
|
-
*
|
|
42
|
-
* @returns string
|
|
43
|
-
*/
|
|
44
|
-
get rootDomain() {
|
|
45
|
-
this._rootDomain = this._rootDomain ?? this.domainLevel(1);
|
|
46
|
-
return this._rootDomain;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Run all static validations
|
|
50
|
-
* @returns Error[]
|
|
51
|
-
*/
|
|
52
|
-
all() {
|
|
53
|
-
const errors = [];
|
|
54
|
-
if ((this.schema?.length ?? 0) === 0)
|
|
55
|
-
errors.push(Error('schema missing'));
|
|
56
|
-
else if ((this.levels ?? 0) < 3)
|
|
57
|
-
errors.push(Error(`schema levels < 3 [${this.levels}, ${this.schema}]`));
|
|
58
|
-
else if (!this.isLowercase)
|
|
59
|
-
errors.push(Error(`schema not lowercase [${this.schema}]`));
|
|
60
|
-
return errors;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Run all the validations
|
|
64
|
-
* @param checkExistence - boolean
|
|
65
|
-
* @returns Error[]
|
|
66
|
-
*/
|
|
67
|
-
async allDynamic() {
|
|
68
|
-
const errors = [];
|
|
69
|
-
if ((this.schema?.length ?? 0) === 0)
|
|
70
|
-
errors.push(Error('schema missing'));
|
|
71
|
-
else if (!(await this.rootDomainExists()))
|
|
72
|
-
errors.push(Error(`schema root domain must exist [${this.rootDomain}]`));
|
|
73
|
-
return errors;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Determines how many levels of the schema's reverse domain
|
|
77
|
-
* pass DNS resolution
|
|
78
|
-
*
|
|
79
|
-
* @returns number (0 if none exist)
|
|
80
|
-
*/
|
|
81
|
-
async domainExistenceDepth() {
|
|
82
|
-
const levels = this.levels ?? 0;
|
|
83
|
-
let level = 0;
|
|
84
|
-
while (level < levels) {
|
|
85
|
-
if (!(await domainExists(this.domainLevel(level)))) {
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
level += 1;
|
|
89
|
-
}
|
|
90
|
-
return level;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Checks if the root domain validates via DNS resolution
|
|
94
|
-
*
|
|
95
|
-
* @returns boolean
|
|
96
|
-
*/
|
|
97
|
-
async rootDomainExists() {
|
|
98
|
-
return await domainExists(this.rootDomain);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
* Get a domain for the schema at a certain level
|
|
103
|
-
*
|
|
104
|
-
* @param level - Zero based level to check
|
|
105
|
-
* @returns string
|
|
106
|
-
*/
|
|
107
|
-
domainLevel(level) {
|
|
108
|
-
return this.parts
|
|
109
|
-
?.slice(0, level + 1)
|
|
110
|
-
.reverse()
|
|
111
|
-
.join('.');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=SchemaNameValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaNameValidator.js","sourceRoot":"","sources":["../../src/SchemaNameValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAC1B,MAAM,CAAS;IACd,MAAM,CAAW;IACjB,WAAW,CAAS;IAC5B,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;IACnD,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,EAAE,MAAM,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACH,IAAI,KAAK;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;QACpD,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED;;;;;;OAMG;IACH,IAAI,UAAU;QACZ,IAAI,CAAC,WA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QACb,OAAO,KAAK,GAAG,MAAM,EAAE;YACrB,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;gBAClD,MAAK;aACN;YACD,KAAK,IAAI,CAAC,CAAA;SACX;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,gBAAgB;QAC3B,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC5C,CAAC;IAED;;;;;;OAMG;IACK,WAAW,CAAC,KAAa;QAC/B,OAAO,IAAI,CAAC,KAAK;YACf,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;aACpB,OAAO,EAAE;aACT,IAAI,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;CACF"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { domainExists } from '@xyo-network/dns'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Validates a XYO schema structure and existence
|
|
5
|
-
*/
|
|
6
|
-
export class XyoSchemaNameValidator {
|
|
7
|
-
public schema?: string
|
|
8
|
-
private _parts?: string[]
|
|
9
|
-
private _rootDomain?: string
|
|
10
|
-
constructor(schema?: string) {
|
|
11
|
-
this.schema = schema
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Checks whether the schema is all lowercase
|
|
16
|
-
*
|
|
17
|
-
* @returns boolean
|
|
18
|
-
*/
|
|
19
|
-
get isLowercase(): boolean {
|
|
20
|
-
return this.schema === this.schema?.toLowerCase()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Levels in the schema
|
|
25
|
-
*
|
|
26
|
-
* @returns number
|
|
27
|
-
*/
|
|
28
|
-
get levels(): number | undefined {
|
|
29
|
-
return this.parts?.length
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The schema converted into a string array split on '.'
|
|
34
|
-
*
|
|
35
|
-
* @returns string[]
|
|
36
|
-
*/
|
|
37
|
-
get parts() {
|
|
38
|
-
this._parts = this._parts ?? this.schema?.split('.')
|
|
39
|
-
return this._parts
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
44
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
45
|
-
* registration
|
|
46
|
-
*
|
|
47
|
-
* @returns string
|
|
48
|
-
*/
|
|
49
|
-
get rootDomain(): string | undefined {
|
|
50
|
-
this._rootDomain = this._rootDomain ?? this.domainLevel(1)
|
|
51
|
-
return this._rootDomain
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Run all static validations
|
|
56
|
-
* @returns Error[]
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
public all() {
|
|
60
|
-
const errors: Error[] = []
|
|
61
|
-
if ((this.schema?.length ?? 0) === 0) errors.push(Error('schema missing'))
|
|
62
|
-
else if ((this.levels ?? 0) < 3) errors.push(Error(`schema levels < 3 [${this.levels}, ${this.schema}]`))
|
|
63
|
-
else if (!this.isLowercase) errors.push(Error(`schema not lowercase [${this.schema}]`))
|
|
64
|
-
return errors
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Run all the validations
|
|
69
|
-
* @param checkExistence - boolean
|
|
70
|
-
* @returns Error[]
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
public async allDynamic() {
|
|
74
|
-
const errors: Error[] = []
|
|
75
|
-
if ((this.schema?.length ?? 0) === 0) errors.push(Error('schema missing'))
|
|
76
|
-
else if (!(await this.rootDomainExists())) errors.push(Error(`schema root domain must exist [${this.rootDomain}]`))
|
|
77
|
-
return errors
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Determines how many levels of the schema's reverse domain
|
|
82
|
-
* pass DNS resolution
|
|
83
|
-
*
|
|
84
|
-
* @returns number (0 if none exist)
|
|
85
|
-
*/
|
|
86
|
-
public async domainExistenceDepth() {
|
|
87
|
-
const levels = this.levels ?? 0
|
|
88
|
-
let level = 0
|
|
89
|
-
while (level < levels) {
|
|
90
|
-
if (!(await domainExists(this.domainLevel(level)))) {
|
|
91
|
-
break
|
|
92
|
-
}
|
|
93
|
-
level += 1
|
|
94
|
-
}
|
|
95
|
-
return level
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Checks if the root domain validates via DNS resolution
|
|
100
|
-
*
|
|
101
|
-
* @returns boolean
|
|
102
|
-
*/
|
|
103
|
-
public async rootDomainExists() {
|
|
104
|
-
return await domainExists(this.rootDomain)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
* Get a domain for the schema at a certain level
|
|
110
|
-
*
|
|
111
|
-
* @param level - Zero based level to check
|
|
112
|
-
* @returns string
|
|
113
|
-
*/
|
|
114
|
-
private domainLevel(level: number): string | undefined {
|
|
115
|
-
return this.parts
|
|
116
|
-
?.slice(0, level + 1)
|
|
117
|
-
.reverse()
|
|
118
|
-
.join('.')
|
|
119
|
-
}
|
|
120
|
-
}
|