@investorid/identity-sdk
Version:
Interact with BlockChain Identities.
39 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("ethers/utils");
const Config_1 = require("../Config");
const Errors_1 = require("../errors/Errors");
function toHex(message) {
return utils_1.hexlify(utils_1.toUtf8Bytes(message));
}
exports.toHex = toHex;
exports.default = { arrayify: utils_1.arrayify, toHex };
function isHexString(value) {
return typeof value === 'string' && utils_1.isHexString(value);
}
exports.isHexString = isHexString;
/**
* Check if an URI is secured or not according to SDK configuration.
* @param value
* @return True if the uri is secured.
*/
function isValidURI(value) {
return typeof value === 'string' && (Config_1.allowUnsecuredProviders ? value.match(/^https?:\/\/.*\..*/) : value.match(/^https:\/\/.*\..*/)) !== null;
}
exports.isValidURI = isValidURI;
/**
* Check if an URI is secured or not according to SDK configuration.
* @param value
* @return true if the URI is secure or unsecured endpoints are allowed.
* @throws UnsecuredURIError if the URI is not secure.
*/
function guardSecuredURI(value) {
if (!isValidURI(value)) {
throw new Errors_1.UnsecuredURIError({
value,
});
}
return true;
}
exports.guardSecuredURI = guardSecuredURI;
//# sourceMappingURL=Utils.js.map