@arcblock/did
Version:
Javascript lib to work with ArcBlock DID
54 lines (53 loc) • 1.8 kB
TypeScript
import type { LiteralUnion } from 'type-fest';
export type DIDTypeKey = LiteralUnion<'role' | 'pk' | 'hash' | 'address', string>;
export type DIDTypeShortcut = LiteralUnion<'default' | 'arcblock' | 'eth' | 'ethereum' | 'passkey', string>;
export type DIDType = {
[key in DIDTypeKey]?: number;
};
export type DIDTypeStr = {
[key in DIDTypeKey]?: string;
};
export 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) => any;
/**
* 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): DIDType;
declare namespace DidType {
var toJSON: (type: DIDType) => 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;
export { DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, fromTypeInfo, toTypeInfo, toTypeInfoStr, isEthereumType, isEthereumDid, toChecksumAddress, DidType, };