UNPKG

@arcblock/did

Version:

Javascript lib to work with ArcBlock DID

32 lines (31 loc) 1.11 kB
//#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 export { ALIAS_METHODS, ALL_METHODS, CRYPTO_METHODS, DEFAULT_METHOD, isAliasMethod, isCryptoMethod, isKnownMethod };