utils package

Contains helper methods for Veramo plugins.

Functions

FunctionDescription
asArray(arg)(BETA) Ensures that a given input is an array. If the input is a single item, it is converted to an array with a single entry.
base58ToBytes(s)Converts a base58 string to the Uint8Array it represents.
base64ToBytes(s)Converts a base64url string to the Uint8Array it represents.
bytesToBase64(b)Encodes a Uint8Array to a base64 string representation with padding.
bytesToBase64url(b)Converts a Uint8Array to a base64url string
bytesToHex(byteArray, prefix)(BETA) Converts a Uint8Array input to a hex string
compressIdentifierSecp256k1Keys(identifier)(BETA) Converts any Secp256k1 public keys of an IIdentifier to their compressed form.
computeEntryHash(input)(BETA) Computes a hash for a given credential or presentation. This hash is usable as an internal ID for database indexing
convertIdentifierEncryptionKeys(identifier)(BETA) Converts any Ed25519 keys of an IIdentifier to X25519 to be usable for encryption.
decodeBase64url(s)(BETA) Decodes a base64url string to a utf8 string represented by the same bytes.
decodeCredentialToObject(input)(BETA) Parses a W3CVerifiableCredential and converts it to a VerifiableCredential so it is easier to use programmatically.
decodeJoseBlob(blob)(BETA) Decodes a base64url string representing stringified JSON to a JSON object.
decodePresentationToObject(input)(BETA) Parses a W3CVerifiablePresentation and converts it to a VerifiablePresentation so it is easier to use programmatically.
dereferenceDidKeys(didDocument, section, context)(BETA) Dereferences keys from DID document and normalizes them for easy comparison.When dereferencing keyAgreement keys, only Ed25519 and X25519 curves are supported. Other key types are omitted from the result and Ed25519 keys are converted to X25519
encodeBase64url(s)(BETA) Encodes the bytes of an input string to base64url
encodeJoseBlob(payload)(BETA) Stringifies a JSON object and encodes the bytes of the resulting string to a base64url representation.
extractIssuer(input)(BETA) Decodes a credential or presentation and returns the issuer ID iss from a JWT or issuer/issuer.id from a VC or holder from a VP
extractPublicKeyHex(pk, convert)(BETA) Converts the publicKey of a VerificationMethod to hex encoding (publicKeyHex)
getChainIdForDidEthr(verificationMethod)(BETA) Extracts the chain ID from a supporting legacy representations as well.
getEthereumAddress(verificationMethod)(BETA) Extracts an ethereum address from a supporting legacy representations.
hexToBytes(hexString)(BETA) Converts a hex string (with or without prefix) to a byte array (Uint8Array)
isDefined(arg)(BETA) Checks if a variable is defined and not null. After this check, typescript sees the variable as defined.
isIterable(obj)(BETA) Checks if an object is iterable (can be used for for..of)
mapIdentifierKeysToDoc(identifier, section, context)(BETA) Maps the keys of a locally managed IIdentifier to the corresponding entries from the DID document.
processEntryToArray(inputEntryOrArray, startWithEntry)(BETA) Processes an entry or an array of entries into an array of entries. If a startWithEntry param is provided, it is set as the first item in the result array.
resolveDidOrThrow(didUrl, context)(BETA) Resolve a DID document or throw an error if the resolution fails.

Variables

VariableDescription
MANDATORY_CREDENTIAL_CONTEXTEvery Verifiable Credential @context property must contain this.

Type Aliases

Type AliasDescription
RecordLike(BETA) A mapping of string to another type. Both Map and Record are accepted.This API may change without a BREAKING CHANGE notice.