@arcblock/did
Version:
Javascript lib to work with ArcBlock DID
39 lines (37 loc) • 1.27 kB
JavaScript
//#region src/method.ts
/** Crypto methods: share unified identifier encoding (base58 checksum / ethereum / base16) */
const CRYPTO_METHODS = Object.freeze([
"abt",
"afs",
"aos",
"spaces"
]);
/** Alias methods: human-readable identifiers */
const ALIAS_METHODS = Object.freeze(["name"]);
/** All supported methods */
const ALL_METHODS = Object.freeze([...CRYPTO_METHODS, ...ALIAS_METHODS]);
/** Default method when none is specified */
const DEFAULT_METHOD = "abt";
/** Check if a value is a known crypto method */
function isCryptoMethod(method) {
if (typeof method !== "string") return false;
return CRYPTO_METHODS.includes(method);
}
/** Check if a value is a known alias method */
function isAliasMethod(method) {
if (typeof method !== "string") return false;
return ALIAS_METHODS.includes(method);
}
/** Check if a value is any known method */
function isKnownMethod(method) {
if (typeof method !== "string") return false;
return ALL_METHODS.includes(method);
}
//#endregion
exports.ALIAS_METHODS = ALIAS_METHODS;
exports.ALL_METHODS = ALL_METHODS;
exports.CRYPTO_METHODS = CRYPTO_METHODS;
exports.DEFAULT_METHOD = DEFAULT_METHOD;
exports.isAliasMethod = isAliasMethod;
exports.isCryptoMethod = isCryptoMethod;
exports.isKnownMethod = isKnownMethod;