Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Latest commit

 

History

History
535 lines (305 loc) · 12.2 KB

codec.md

File metadata and controls

535 lines (305 loc) · 12.2 KB

MATTR Wallet SDK React Native / Exports / codec

Namespace: codec

Table of contents

Type Aliases

Variables

Functions

Type Aliases

DeflateError

Ƭ DeflateError: DeflateError


InflateError

Ƭ InflateError: InflateError


InvalidBase32DecodeError

Ƭ InvalidBase32DecodeError: InvalidBase32DecodeError


InvalidBase64DecodeError

Ƭ InvalidBase64DecodeError: InvalidBase64DecodeError


InvalidBase64URLDecodeError

Ƭ InvalidBase64URLDecodeError: InvalidBase64URLDecodeError


InvalidCborldDecodeError

Ƭ InvalidCborldDecodeError: InvalidCborldDecodeError


InvalidCborldEncodeError

Ƭ InvalidCborldEncodeError: InvalidCborldEncodeError


InvalidJSONError

Ƭ InvalidJSONError: InvalidJSONError


MultiHash

Ƭ MultiHash: MultiHash


MultiHashError

Ƭ MultiHashError: MultiHashError

Variables

MultiHash

MultiHash: typeof MultiHash

Functions

base32Decode

base32Decode(base32String): Result<Uint8Array, InvalidBase32DecodeError>

Base32 decode to Uint8Array

Parameters

Name Type
base32String string

Returns

Result<Uint8Array, InvalidBase32DecodeError>

A Result containing the decoded Uint8Array on ok or a InvalidBase32DecodeError on error


base32DecodeToString

base32DecodeToString(base32String): Result<string, InvalidBase32DecodeError>

Base32 decode to a string

Parameters

Name Type Description
base32String string The base32 encoded string

Returns

Result<string, InvalidBase32DecodeError>

A Result containing the decoded string on ok or a InvalidBase32DecodeError on error


base32Encode

base32Encode(byteArray): string

Base32 encode an Uint8Array

Parameters

Name Type Description
byteArray Uint8Array The bytes to encode

Returns

string

The string of the encoded bytes


base32EncodeFromString

base32EncodeFromString(str): string

Base32 encode a string

Parameters

Name Type Description
str string The string to encode

Returns

string

The base32 encoded string


base64Decode

base64Decode(base64String): Result<Uint8Array, InvalidBase64DecodeError>

Base64 decode to Uint8Array

Parameters

Name Type Description
base64String string The base64 encoded string

Returns

Result<Uint8Array, InvalidBase64DecodeError>

A Result containing the decoded Uint8Array on ok or a InvalidBase64DecodeError on error


base64DecodeToString

base64DecodeToString(base64String): Result<string, InvalidBase64DecodeError>

Base64 decode to a string

Parameters

Name Type Description
base64String string The base64 encoded string

Returns

Result<string, InvalidBase64DecodeError>

A Result containing the decoded string on ok or a InvalidBase64DecodeError on error


base64Encode

base64Encode(byteArray): string

Base64 encode an Uint8Array

Parameters

Name Type Description
byteArray Uint8Array The bytes to encode

Returns

string

The string of the encoded bytes


base64EncodeFromString

base64EncodeFromString(str): string

Base64 encode a string

Parameters

Name Type Description
str string The string to encode

Returns

string

The base64 encoded string


base64UrlDecode

base64UrlDecode(base64urlString): Result<Uint8Array, InvalidBase64URLDecodeError>

Base64URL decode to Uint8Array

Parameters

Name Type Description
base64urlString string The base64url encoded string

Returns

Result<Uint8Array, InvalidBase64URLDecodeError>

A Result containing the decoded Uint8Array on ok or a InvalidBase64URLDecodeError on error


base64UrlDecodeToObject

base64UrlDecodeToObject(base64urlString): Result<object, InvalidBase64URLDecodeError | InvalidJSONError>

Base64URL decode to an object

Parameters

Name Type Description
base64urlString string The base64url encoded string

Returns

Result<object, InvalidBase64URLDecodeError | InvalidJSONError>

A Result containing the decoded object on ok or a InvalidBase64URLDecodeError or InvalidJSONError on error


base64UrlEncode

base64UrlEncode(byteArray): string

Base64URL encode an Uint8Array

Parameters

Name Type Description
byteArray Uint8Array The bytes to encode

Returns

string

The string of the encoded bytes


base64UrlEncodeFromObject

base64UrlEncodeFromObject(obj): string

Base64URL encode an object

Parameters

Name Type Description
obj Record<string, unknown> The object to create the encoded string from

Returns

string

The string of the encoded object


base64UrlEncodeFromString

base64UrlEncodeFromString(str): string

Base64URL encode a string

Parameters

Name Type Description
str string The string to encode

Returns

string

The base64url encoded string


base64UrlEncodeNoPadding

base64UrlEncodeNoPadding(bytes): string

Base64URL encode with no padding from an Uint8Array to a string

Parameters

Name Type Description
bytes Uint8Array The bytes to encode

Returns

string

The base64url encoded string


bytesToString

bytesToString(bytes): string

Convert a Uint8Array to a string

Parameters

Name Type Description
bytes Uint8Array The bytes to convert to a string

Returns

string

The string result from the converted bytes


canonicalMultiHash

canonicalMultiHash(input, hashAlgorithm): Result<Uint8Array, MultiHashError>

Creates a canonical multihash of the input object by canonicalizing the object.

Parameters

Name Type Description
input Record<string, unknown> The object to canonicalize and then hash
hashAlgorithm Sha256 The algorithm to hash and encode the data with

Returns

Result<Uint8Array, MultiHashError>

A Result containing the encoded Uint8Array on ok or a MultiHashError on error


decodeCborld

decodeCborld(byteArray, documentLoader): ResultAsync<unknown, InvalidCborldDecodeError>

Decode CBOR-LD bytes intoto JSON-LD document

Parameters

Name Type Description
byteArray Uint8Array The cborld bytes
documentLoader DocumentLoader The document loader to resolve contexts

Returns

ResultAsync<unknown, InvalidCborldDecodeError>

A ResultAsync containing the decoded object on ok or a InvalidCborldDecodeError on error


deflate

deflate(data): Result<Uint8Array, DeflateError>

Deflate compression

Parameters

Name Type Description
data Uint8Array The data to be compressed

Returns

Result<Uint8Array, DeflateError>

A Result containing the compressed Uint8Array on ok or a DeflateError on error


encodeCborld

encodeCborld(jsonldDocument, documentLoader): ResultAsync<Uint8Array, InvalidCborldEncodeError>

Encode a JSON-LD document into CBOR-LD bytes

Parameters

Name Type Description
jsonldDocument Record<string, unknown> The json document to encode
documentLoader DocumentLoader The document loader to resolve contexts

Returns

ResultAsync<Uint8Array, InvalidCborldEncodeError>

A ResultAsync containing the decoded cborld bytes on ok or a InvalidCborldEncodeError on error


inflate

inflate(data): Result<Uint8Array, InflateError>

Inflate decompression

Parameters

Name Type Description
data Uint8Array The data to be decompressed

Returns

Result<Uint8Array, InflateError>

A Result containing the decompressed Uint8Array on ok or a InflateError on error


stringToBytes

stringToBytes(str): Uint8Array

Convert a string to an Uint8Array

Parameters

Name Type Description
str string The string to convert to bytes

Returns

Uint8Array

The bytes result from the converted string