/** * Various utility functions; not meant to be exported to the external world... * * @module */ import type { KeyOptions, OutputOptions, JWKeyPair } from "./types.js"; import type { Multibase, Multikey } from "@iherman/multikey-webcrypto"; /** * Type guard for a Multibase value. * * Beware! Mathematically, this function is not fool-proof. After all, a random string * may start with a 'z' or a 'u', and contain only characters that are part of the * required base vocabulary. To increase the probability of success, an attempt is made to decode the multibase value. * If successful, the value can indeed be accepted as a multibase with a reasonable probability. */ export declare function isMultibase(obj: any): obj is Multibase; /** * Type guard for a Multikey object. * * @param obj */ export declare function isMultikey(obj: object): obj is Multikey; /** * Type guard for a CryptoKey object. * * @param obj */ export declare function isCryptoKey(obj: object): obj is CryptoKey; /** * Type guard for a CryptoKeyPair object. * * @param obj */ export declare function isCryptoKeyPair(obj: object): obj is CryptoKeyPair; /** * Type guard for a JWK Key Pair * * @param obj */ export declare function isJWKKeyPair(obj: object): obj is JWKeyPair; /** * Text to array buffer, needed for crypto operations. * The text is encoded in UTF-8, which is the default for the WebCrypto API. * * @param text */ export declare function textToBytes(text: string): Uint8Array; /** * Array buffer to text, needed for crypto operations. * The text is decoded from UTF-8, which is the default for the WebCrypto API. * * @param byteBuffer */ export declare function bytesToText(byteBuffer: Uint8Array): string; /** * Additional structure needed for operations such as sign or verify in the WebCrypto API. Can * be extracted from the WebCrypto representation of the crypto keys, * see {@link algorithmDataCR}. */ export interface WebCryptoAPIData extends KeyOptions { name: string; publicExponent?: Uint8Array; } /** * Mapping of the CryptoKey instance and the corresponding terms for the WebCrypto API like * sign or verify. * * @param key * @returns */ export declare function algorithmDataCR(key: CryptoKey): WebCryptoAPIData; /** * Encode the result in base58 or base64, possibly in Multibase. The `options` argument dictates. * Default is base64 encoding and plain output. * * @param options * @param rawMessage * @param multi - whether this is for a multikey/multibase environment or not */ export declare function encodeResult(options: OutputOptions | undefined, rawMessage: ArrayBuffer, multi: boolean): string; /** * Decode a string from encoded form. If the text is recognized as Multibase, the encoding format is there, otherwise * the `options` argument rules. * * @param options * @param encodedMessage * @param multi - whether this is for a multikey/multibase environment or not */ export declare function decodeResult(options: OutputOptions | undefined, encodedMessage: string, multi: boolean): ArrayBuffer; //# sourceMappingURL=utils.d.ts.map