- Add GETTING_STARTED.md with quick start guide and development modes - Add INSTALL.sh automated installation script - Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md - Add QUICK_REFERENCE.md for common commands - Add SETUP_GUIDE.md with detailed setup instructions - Update README.md with improved project overview - Add did-wallet app dependencies and node_modules
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.output = exports.exists = exports.hash = exports.bytes = exports.bool = exports.number = void 0;
|
|
function number(n) {
|
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
throw new Error(`wrong positive integer: ${n}`);
|
|
}
|
|
exports.number = number;
|
|
function bool(b) {
|
|
if (typeof b !== 'boolean')
|
|
throw new Error(`boolean expected, not ${b}`);
|
|
}
|
|
exports.bool = bool;
|
|
// TODO: merge with utils
|
|
function isBytes(a) {
|
|
return (a != null &&
|
|
typeof a === 'object' &&
|
|
(a instanceof Uint8Array || a.constructor.name === 'Uint8Array'));
|
|
}
|
|
function bytes(b, ...lengths) {
|
|
if (!isBytes(b))
|
|
throw new Error('Uint8Array expected');
|
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
}
|
|
exports.bytes = bytes;
|
|
function hash(hash) {
|
|
if (typeof hash !== 'function' || typeof hash.create !== 'function')
|
|
throw new Error('hash must be wrapped by utils.wrapConstructor');
|
|
number(hash.outputLen);
|
|
number(hash.blockLen);
|
|
}
|
|
exports.hash = hash;
|
|
function exists(instance, checkFinished = true) {
|
|
if (instance.destroyed)
|
|
throw new Error('Hash instance has been destroyed');
|
|
if (checkFinished && instance.finished)
|
|
throw new Error('Hash#digest() has already been called');
|
|
}
|
|
exports.exists = exists;
|
|
function output(out, instance) {
|
|
bytes(out);
|
|
const min = instance.outputLen;
|
|
if (out.length < min) {
|
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
}
|
|
}
|
|
exports.output = output;
|
|
const assert = { number, bool, bytes, hash, exists, output };
|
|
exports.default = assert;
|
|
//# sourceMappingURL=_assert.js.map
|