@xyo-network/core 2.58.0 → 2.60.0-rc.1
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/Hasher/Hasher.js +53 -6
- package/dist/cjs/Hasher/Hasher.js.map +1 -1
- package/dist/cjs/Wasm/WasmSupport.js +153 -0
- package/dist/cjs/Wasm/WasmSupport.js.map +1 -0
- package/dist/cjs/Wasm/index.js +5 -0
- package/dist/cjs/Wasm/index.js.map +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/Validator.js.map +1 -1
- package/dist/docs.json +6227 -2584
- package/dist/esm/Hasher/Hasher.js +37 -7
- package/dist/esm/Hasher/Hasher.js.map +1 -1
- package/dist/esm/Wasm/WasmSupport.js +141 -0
- package/dist/esm/Wasm/WasmSupport.js.map +1 -0
- package/dist/esm/Wasm/index.js +2 -0
- package/dist/esm/Wasm/index.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/Validator.js.map +1 -1
- package/dist/types/Hasher/Hasher.d.ts +11 -2
- package/dist/types/Hasher/Hasher.d.ts.map +1 -1
- package/dist/types/Wasm/WasmSupport.d.ts +92 -0
- package/dist/types/Wasm/WasmSupport.d.ts.map +1 -0
- package/dist/types/Wasm/index.d.ts +2 -0
- package/dist/types/Wasm/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/Validator.d.ts +3 -2
- package/dist/types/lib/Validator.d.ts.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Base.html +9 -6
- package/docs/classes/Hasher.html +161 -26
- package/docs/classes/ObjectWrapper.html +8 -5
- package/docs/classes/WasmSupport.html +336 -0
- package/docs/classes/XyoAbstractData.html +13 -10
- package/docs/classes/XyoData.html +18 -15
- package/docs/classes/XyoObjectWrapper.html +8 -5
- package/docs/classes/XyoValidatorBase.html +11 -8
- package/docs/functions/deepBy.html +5 -2
- package/docs/functions/deepOmitUnderscoreFields.html +5 -2
- package/docs/functions/deepPickUnderscoreFields.html +5 -2
- package/docs/functions/dumpErrors.html +5 -2
- package/docs/functions/isBrowser.html +5 -2
- package/docs/functions/normalizeAddress.html +5 -2
- package/docs/functions/removeEmptyFields.html +5 -2
- package/docs/functions/sortFields.html +5 -2
- package/docs/functions/toUint8Array.html +5 -2
- package/docs/functions/toUint8ArrayOptional.html +5 -2
- package/docs/functions/trimAddressPrefix.html +5 -2
- package/docs/functions/uuid.html +5 -2
- package/docs/index.html +4 -1
- package/docs/interfaces/Logger.html +10 -7
- package/docs/interfaces/Validator.html +8 -5
- package/docs/modules.html +7 -1
- package/docs/types/AnyObject.html +5 -2
- package/docs/types/BaseParams.html +5 -2
- package/docs/types/BaseParamsFields.html +5 -2
- package/docs/types/DataLike.html +5 -2
- package/docs/types/EmptyObject.html +5 -2
- package/docs/types/LogFunction.html +5 -2
- package/docs/types/StringKeyObject.html +5 -2
- package/docs/types/WasmFeature.html +73 -0
- package/docs/types/WithAdditional.html +5 -2
- package/docs/variables/WasmFeatureDetectors.html +204 -0
- package/docs/variables/addressPrefix.html +5 -2
- package/package.json +6 -4
- package/src/Hasher/Hasher.ts +44 -7
- package/src/Wasm/WasmSupport.ts +168 -0
- package/src/Wasm/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/lib/Validator.ts +4 -2
|
@@ -5,11 +5,15 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const hash_wasm_1 = require("hash-wasm");
|
|
6
6
|
const sha_js_1 = tslib_1.__importDefault(require("sha.js"));
|
|
7
7
|
const lib_1 = require("../lib");
|
|
8
|
+
const Wasm_1 = require("../Wasm");
|
|
8
9
|
const removeEmptyFields_1 = require("./removeEmptyFields");
|
|
9
10
|
const removeFields_1 = require("./removeFields");
|
|
10
11
|
const sortFields_1 = require("./sortFields");
|
|
12
|
+
const wasmSupportStatic = new Wasm_1.WasmSupport(['bigInt']);
|
|
11
13
|
class Hasher extends lib_1.ObjectWrapper {
|
|
14
|
+
/** @deprecated use hashAsync instead */
|
|
12
15
|
get hash() {
|
|
16
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
13
17
|
return Hasher.hash(this.obj);
|
|
14
18
|
}
|
|
15
19
|
get hashFields() {
|
|
@@ -18,33 +22,76 @@ class Hasher extends lib_1.ObjectWrapper {
|
|
|
18
22
|
get stringified() {
|
|
19
23
|
return Hasher.stringify(this.obj);
|
|
20
24
|
}
|
|
25
|
+
static filterExclude(objs = [], hash) {
|
|
26
|
+
var _a;
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const hashes = Array.isArray(hash) ? hash : [hash];
|
|
29
|
+
return (_a = (yield this.hashPairs(objs)).filter(([_, objHash]) => !hashes.includes(objHash))) === null || _a === void 0 ? void 0 : _a.map((pair) => pair[0]);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
static filterInclude(objs = [], hash) {
|
|
33
|
+
var _a;
|
|
34
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const hashes = Array.isArray(hash) ? hash : [hash];
|
|
36
|
+
return (_a = (yield this.hashPairs(objs)).filter(([_, objHash]) => hashes.includes(objHash))) === null || _a === void 0 ? void 0 : _a.map((pair) => pair[0]);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
static find(objs = [], hash) {
|
|
40
|
+
var _a;
|
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
return (_a = (yield this.hashPairs(objs)).find(([_, objHash]) => objHash === hash)) === null || _a === void 0 ? void 0 : _a[0];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** @deprecated use hashAsync instead */
|
|
21
46
|
static hash(obj) {
|
|
22
47
|
return (0, sha_js_1.default)('sha256').update(this.stringify(obj)).digest().toString('hex');
|
|
23
48
|
}
|
|
24
49
|
static hashAsync(obj) {
|
|
25
50
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
|
|
51
|
+
yield Hasher.wasmInitialized;
|
|
52
|
+
if (Hasher.wasmSupport.canUseWasm) {
|
|
53
|
+
const stringToHash = this.stringify(obj);
|
|
27
54
|
try {
|
|
28
|
-
return yield (0, hash_wasm_1.sha256)(
|
|
55
|
+
return yield (0, hash_wasm_1.sha256)(stringToHash);
|
|
29
56
|
}
|
|
30
57
|
catch (ex) {
|
|
31
|
-
|
|
58
|
+
Hasher.wasmSupport.allowWasm = false;
|
|
32
59
|
}
|
|
33
60
|
}
|
|
61
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
34
62
|
return this.hash(obj);
|
|
35
63
|
});
|
|
36
64
|
}
|
|
37
65
|
static hashFields(obj) {
|
|
38
66
|
return (0, removeEmptyFields_1.removeEmptyFields)((0, removeFields_1.deepOmitUnderscoreFields)(obj));
|
|
39
67
|
}
|
|
68
|
+
static hashPairs(objs) {
|
|
69
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
return yield Promise.all(objs.map((obj) => tslib_1.__awaiter(this, void 0, void 0, function* () { return [obj, yield Hasher.hashAsync(obj)]; })));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
static hashes(objs) {
|
|
74
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
return yield Promise.all(objs.map((obj) => this.hashAsync(obj)));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
40
78
|
static stringify(obj) {
|
|
41
79
|
return JSON.stringify((0, sortFields_1.sortFields)(this.hashFields(obj)));
|
|
42
80
|
}
|
|
81
|
+
static toMap(objs) {
|
|
82
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const result = {};
|
|
84
|
+
yield Promise.all(objs.map((obj) => tslib_1.__awaiter(this, void 0, void 0, function* () { return (result[yield Hasher.hashAsync(obj)] = obj); })));
|
|
85
|
+
return result;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
43
88
|
hashAsync() {
|
|
44
|
-
return
|
|
89
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
return yield Hasher.hashAsync(this.obj);
|
|
91
|
+
});
|
|
45
92
|
}
|
|
46
93
|
}
|
|
47
94
|
exports.Hasher = Hasher;
|
|
48
|
-
Hasher.
|
|
49
|
-
Hasher.
|
|
95
|
+
Hasher.wasmInitialized = wasmSupportStatic.initialize();
|
|
96
|
+
Hasher.wasmSupport = wasmSupportStatic;
|
|
50
97
|
//# sourceMappingURL=Hasher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hasher.js","sourceRoot":"","sources":["../../../src/Hasher/Hasher.ts"],"names":[],"mappings":";;;;AAAA,yCAAkC;AAClC,4DAA0B;AAE1B,gCAAiD;AACjD,2DAAuD;AACvD,iDAAyD;AACzD,6CAAyC;AAEzC,MAAa,MAAwC,SAAQ,mBAAgB;IAI3E,IAAI,IAAI;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpC,CAAC;IAED,IAAI,WAAW;QACb,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACnC,CAAC;IAED,MAAM,CAAC,IAAI,CAAsB,GAAM;QACrC,OAAO,IAAA,gBAAK,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC7E,CAAC;IAED,MAAM,CAAO,SAAS,CAAsB,GAAM;;YAChD,
|
|
1
|
+
{"version":3,"file":"Hasher.js","sourceRoot":"","sources":["../../../src/Hasher/Hasher.ts"],"names":[],"mappings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 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WasmSupport = exports.WasmFeatureDetectors = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const wasm_feature_detect_1 = require("wasm-feature-detect");
|
|
6
|
+
exports.WasmFeatureDetectors = {
|
|
7
|
+
bigInt: wasm_feature_detect_1.bigInt,
|
|
8
|
+
bulkMemory: wasm_feature_detect_1.bulkMemory,
|
|
9
|
+
exceptions: wasm_feature_detect_1.exceptions,
|
|
10
|
+
extendedConst: wasm_feature_detect_1.extendedConst,
|
|
11
|
+
gc: wasm_feature_detect_1.gc,
|
|
12
|
+
memory64: wasm_feature_detect_1.memory64,
|
|
13
|
+
multiValue: wasm_feature_detect_1.multiValue,
|
|
14
|
+
mutableGlobals: wasm_feature_detect_1.mutableGlobals,
|
|
15
|
+
referenceTypes: wasm_feature_detect_1.referenceTypes,
|
|
16
|
+
relaxedSimd: wasm_feature_detect_1.relaxedSimd,
|
|
17
|
+
saturatedFloatToInt: wasm_feature_detect_1.saturatedFloatToInt,
|
|
18
|
+
signExtensions: wasm_feature_detect_1.signExtensions,
|
|
19
|
+
simd: wasm_feature_detect_1.simd,
|
|
20
|
+
streamingCompilation: wasm_feature_detect_1.streamingCompilation,
|
|
21
|
+
tailCall: wasm_feature_detect_1.tailCall,
|
|
22
|
+
threads: wasm_feature_detect_1.threads,
|
|
23
|
+
};
|
|
24
|
+
class WasmSupport {
|
|
25
|
+
/**
|
|
26
|
+
* Instance constructor for use where async instantiation
|
|
27
|
+
* is not possible. Where possible, prefer the static
|
|
28
|
+
* create method over use of this constructor directly
|
|
29
|
+
* as no initialization (feature detection) is able to
|
|
30
|
+
* be done here
|
|
31
|
+
* @param desiredFeatures The desired feature set
|
|
32
|
+
*/
|
|
33
|
+
constructor(desiredFeatures) {
|
|
34
|
+
this.desiredFeatures = desiredFeatures;
|
|
35
|
+
this._allowWasm = true;
|
|
36
|
+
this._featureSupport = {};
|
|
37
|
+
this._forceWasm = false;
|
|
38
|
+
this._isInitialized = false;
|
|
39
|
+
this._isWasmFeatureSetSupported = false;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Is Wasm allowed
|
|
43
|
+
*/
|
|
44
|
+
get allowWasm() {
|
|
45
|
+
return this._allowWasm;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether or not to allow WASM usage
|
|
49
|
+
*/
|
|
50
|
+
set allowWasm(v) {
|
|
51
|
+
this._allowWasm = v;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Whether or not Wasm should be used based on the desired
|
|
55
|
+
* feature set, initialization state, or force-use settings
|
|
56
|
+
*/
|
|
57
|
+
get canUseWasm() {
|
|
58
|
+
return (
|
|
59
|
+
// Just force WASM
|
|
60
|
+
this._forceWasm ||
|
|
61
|
+
// Or if we haven't checked be optimistic
|
|
62
|
+
(this._allowWasm && !this._isInitialized) ||
|
|
63
|
+
// Or if we have checked and WASM is not supported, be realistic
|
|
64
|
+
(this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns a object containing a property for each desired wasm feature
|
|
68
|
+
* with a boolean value indicating whether or not the feature is supported
|
|
69
|
+
*/
|
|
70
|
+
get featureSupport() {
|
|
71
|
+
return Object.assign({}, this._featureSupport);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Force use of Wasm
|
|
75
|
+
*/
|
|
76
|
+
get forceWasm() {
|
|
77
|
+
return this._forceWasm;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Whether or not to force Wasm usage
|
|
81
|
+
*/
|
|
82
|
+
set forceWasm(v) {
|
|
83
|
+
this._forceWasm = v;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Whether or not Wasm is supported based
|
|
87
|
+
* on the desired feature set
|
|
88
|
+
*/
|
|
89
|
+
get isDesiredFeatureSetSupported() {
|
|
90
|
+
return this._isWasmFeatureSetSupported;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether or not Wasm detection has been run
|
|
94
|
+
* for the desired feature set
|
|
95
|
+
*/
|
|
96
|
+
get isInitialized() {
|
|
97
|
+
return this._isInitialized;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Static creation & async initialization for use where
|
|
101
|
+
* async instantiation is possible
|
|
102
|
+
* @param desiredFeatures The desired feature set
|
|
103
|
+
* @returns An initialized instance of the class with detection
|
|
104
|
+
* for the desired feature set
|
|
105
|
+
*/
|
|
106
|
+
static create(desiredFeatures) {
|
|
107
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const instance = new WasmSupport(desiredFeatures);
|
|
109
|
+
yield instance.initialize();
|
|
110
|
+
return Promise.resolve(instance);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Checks for specific wasm features
|
|
115
|
+
* @param features The list of features to check for
|
|
116
|
+
* @returns True if all the features are supported, false otherwise
|
|
117
|
+
*/
|
|
118
|
+
featureCheck(features) {
|
|
119
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const results = yield Promise.all(features.map((feature) => exports.WasmFeatureDetectors[feature]).map((detector) => tslib_1.__awaiter(this, void 0, void 0, function* () { return yield detector(); })));
|
|
121
|
+
return results.every((result) => result);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Does feature detection for the desired feature set
|
|
126
|
+
*/
|
|
127
|
+
initialize() {
|
|
128
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
if (this._isInitialized)
|
|
130
|
+
return;
|
|
131
|
+
yield this.detectDesiredFeatures();
|
|
132
|
+
this._isInitialized = true;
|
|
133
|
+
return;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
detectDesiredFeatures() {
|
|
137
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
|
|
139
|
+
const desiredFeature = this.desiredFeatures[feature];
|
|
140
|
+
const detector = exports.WasmFeatureDetectors[desiredFeature];
|
|
141
|
+
if (!(yield detector())) {
|
|
142
|
+
this._featureSupport[desiredFeature] = false;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this._featureSupport[desiredFeature] = true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every((v) => v);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.WasmSupport = WasmSupport;
|
|
153
|
+
//# sourceMappingURL=WasmSupport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WasmSupport.js","sourceRoot":"","sources":["../../../src/Wasm/WasmSupport.ts"],"names":[],"mappings":";;;;AAAA,6DAiB4B;AAEf,QAAA,oBAAoB,GAAG;IAClC,MAAM,EAAE,4BAAM;IACd,UAAU,EAAE,gCAAU;IACtB,UAAU,EAAE,gCAAU;IACtB,aAAa,EAAE,mCAAa;IAC5B,EAAE,EAAE,wBAAE;IACN,QAAQ,EAAE,8BAAQ;IAClB,UAAU,EAAE,gCAAU;IACtB,cAAc,EAAE,oCAAc;IAC9B,cAAc,EAAE,oCAAc;IAC9B,WAAW,EAAE,iCAAW;IACxB,mBAAmB,EAAE,yCAAmB;IACxC,cAAc,EAAE,oCAAc;IAC9B,IAAI,EAAE,0BAAI;IACV,oBAAoB,EAAE,0CAAoB;IAC1C,QAAQ,EAAE,8BAAQ;IAClB,OAAO,EAAE,6BAAO;CACR,CAAA;AAIV,MAAa,WAAW;IAOtB;;;;;;;OAOG;IACH,YAAsB,eAA8B;QAA9B,oBAAe,GAAf,eAAe,CAAe;QAd5C,eAAU,GAAG,IAAI,CAAA;QACjB,oBAAe,GA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@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Wasm/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,4 +4,5 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./Data"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./Hasher"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./lib"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./Wasm"), exports);
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,mDAAwB;AACxB,gDAAqB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,mDAAwB;AACxB,gDAAqB;AACrB,iDAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validator.js","sourceRoot":"","sources":["../../../src/lib/Validator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Validator.js","sourceRoot":"","sources":["../../../src/lib/Validator.ts"],"names":[],"mappings":";;;AAGA,mDAA+C;AAM/C,MAAsB,gBAAkD,SAAQ,6BAAgB;CAE/F;AAFD,4CAEC"}
|