UNPKG

@arcblock/did

Version:

Javascript lib to work with ArcBlock DID

58 lines (57 loc) 1.98 kB
import { LiteralUnion } from "type-fest"; //#region src/type.d.ts type DIDTypeKey = LiteralUnion<'role' | 'pk' | 'hash' | 'address', string>; type DIDTypeShortcut = LiteralUnion<'default' | 'arcblock' | 'eth' | 'ethereum' | 'passkey', string>; type DIDType = { [key in DIDTypeKey]?: number }; type RequiredDIDType = { role: number; pk: number; hash: number; address: number; }; type DIDTypeStr = { [key in DIDTypeKey]?: string }; type DIDTypeArg = DIDTypeShortcut | DIDType; declare const DID_TYPE_ARCBLOCK: DIDType; declare const DID_TYPE_PASSKEY: DIDType; declare const DID_TYPE_ETHEREUM: DIDType; declare const isEthereumType: (type: DIDType) => boolean; /** * Checks if the given string is an address * * @method isEthereumDid * @param {String} address the given HEX address * @return {Boolean} */ declare const isEthereumDid: (did: string) => boolean; /** * Converts to a checksum address * * @method toChecksumAddress * @param {String} address the given HEX address * @return {String} */ declare const toChecksumAddress: (address: string) => string; /** * Create an wallet type object that be used as param to create a new wallet */ declare function DidType(type?: DIDTypeArg): RequiredDIDType; declare namespace DidType { var toJSON: (type: RequiredDIDType) => DIDTypeStr; var fromJSON: (json: DIDTypeStr) => DIDType; } /** * Convert type info object to hex string * * @public * @static * @param {object} type - wallet type, {@see @arcblock/did#DidType} * @returns string */ declare const fromTypeInfo: (type: DIDTypeArg) => string; /** * Get type info from did */ declare const toTypeInfo: (did: string) => DIDType; declare const toTypeInfoStr: (did: string) => DIDTypeStr; //#endregion export { DIDType, DIDTypeArg, DIDTypeKey, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, RequiredDIDType, fromTypeInfo, isEthereumDid, isEthereumType, toChecksumAddress, toTypeInfo, toTypeInfoStr };