UNPKG

@arcblock/did

Version:

Javascript lib to work with ArcBlock DID

69 lines (67 loc) 3.56 kB
import { getEntityId, isSameEntity } from "./entity.cjs"; import { DIDType, DIDTypeArg, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, RequiredDIDType, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from "./type.cjs"; import { DID_PREFIX, toStrictHex } from "./util.cjs"; import { ALIAS_METHODS, ALL_METHODS, AliasMethod, CRYPTO_METHODS, CryptoMethod, DEFAULT_METHOD, DIDMethod, isAliasMethod, isCryptoMethod, isKnownMethod } from "./method.cjs"; import { ParsedDID, extractIdentifier, extractMethod, formatDid, parse } from "./parse.cjs"; import { isKnownDid } from "./validate.cjs"; import { expandShortForm, toShortForm } from "./short-form.cjs"; import { NameHierarchy, ResolveRoute, getResolveRoute, isGlobalName, isLocalName, parseNameHierarchy } from "./name.cjs"; import { InMemoryNameRegistry, NameRegistry } from "./name-registry.cjs"; import { DIDNameResolver, DIDNameResolverOptions, ResolveTraceResult } from "./name-resolver.cjs"; import { types } from "@ocap/mcrypto"; import { BytesType, toAddress, toDid } from "@ocap/util"; //#region src/index.d.ts /** * Gen DID from private key and type config * * Spec: https://github.com/ArcBlock/ABT-DID-Protocol#create-did * * @public * @static * @param {string} sk - hex encoded secret key string * @param {object} type - wallet type, {@see @ocap/wallet#WalletType} * @returns {string} DID string */ declare const fromSecretKey: (sk: BytesType, type?: DIDTypeArg) => string; /** * Gen DID from public key and type config * * @public * @static * @param {string} pk - hex encoded public key * @param {object} type - wallet type, {@see @ocap/wallet#WalletType} * @returns {string} DID string */ declare const fromPublicKey: (pk: BytesType, type?: DIDTypeArg) => string; declare const fromPublicKeyHash: (buffer: string, type: DIDTypeArg) => string; /** * Gen DID from an hex encoded hash and role type * * @public * @static * @param {string} hash - hex encoded hash * @param {enum} role - role type, {@see @ocap/mcrypto#types} * @returns {string} DID string */ declare const fromHash: (hash: string, role?: number) => string; /** * Check if an DID is generated from a publicKey * * @public * @static * @param {string} did - string of the did, usually base58btc format * @param {string} pk - hex encoded publicKey string * @returns {boolean} */ declare const isFromPublicKey: (did: string, pk: BytesType) => boolean; /** * Check if a DID string is valid * * @public * @static * @param {string} did - address string * @returns {boolean} */ declare const isValid: (did: string) => boolean; //#endregion export { ALIAS_METHODS, ALL_METHODS, type AliasMethod, CRYPTO_METHODS, type CryptoMethod, DEFAULT_METHOD, type DIDMethod, DIDNameResolver, type DIDNameResolverOptions, type DIDType, type DIDTypeArg, type DIDTypeShortcut, type DIDTypeStr, DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, InMemoryNameRegistry, type NameHierarchy, type NameRegistry, type ParsedDID, type RequiredDIDType, type ResolveRoute, type ResolveTraceResult, expandShortForm, extractIdentifier, extractMethod, formatDid, fromHash, fromPublicKey, fromPublicKeyHash, fromSecretKey, fromTypeInfo, getEntityId, getResolveRoute, isAliasMethod, isCryptoMethod, isEthereumDid, isEthereumType, isFromPublicKey, isGlobalName, isKnownDid, isKnownMethod, isLocalName, isSameEntity, isValid, parse, parseNameHierarchy, toAddress, toDid, toShortForm, toStrictHex, toTypeInfo, toTypeInfoStr, types };