UNPKG

@meeco/cryppo

Version:

In-browser encryption and decryption. Clone of Ruby Cryppo

52 lines 2.96 kB
import { Buffer as _buffer } from 'buffer'; import forge from 'node-forge'; import { IEncryptionArtifacts } from './encryption/encryption.js'; import { ICryppoSerializationArtifacts, IDerivedKey } from './key-derivation/derived-key.js'; import { SerializationFormat } from './serialization-versions.js'; /** * Wrapping some node-forge utils in case we ever need to replace it */ export declare const encode64: typeof forge.util.encode64; export declare const decode64: typeof forge.util.decode64; export declare const encodeUtf8: typeof forge.util.encodeUtf8; export declare const utf8ToBytes: typeof forge.util.text.utf8.encode; export declare const utf16ToBytes: typeof forge.util.text.utf16.encode; export declare const binaryStringToBytes: typeof forge.util.binary.raw.decode; export declare const bytesToBinaryString: (bytes: Uint8Array) => string; export declare const bytesToUtf16: (bytes: Uint8Array) => string; export declare const bytesToUtf8: (bytes: Uint8Array) => string; export declare const binaryStringToBytesBuffer: (value: string) => _buffer<ArrayBuffer>; export declare const bytesBufferToBinaryString: (val: Buffer | Uint8Array | ArrayBuffer) => string; export declare const generateRandomBytesString: (length?: number) => string; export declare function serializeDerivedKeyOptions(strategy: string, artifacts: IDerivedKey | IEncryptionArtifacts | ICryppoSerializationArtifacts, serializationFormat?: SerializationFormat): string; export declare function deSerializeDerivedKeyOptions(serialized: string): { derivationStrategy: string; serializationArtifacts: IEncryptionArtifacts; }; export declare function serialize(strategy: string, data: string, artifacts: IDerivedKey | IEncryptionArtifacts, serializationFormat?: SerializationFormat): string; export interface IDecoded { encryptionStrategy: string; decodedPairs: any[]; } export declare function deSerialize(serialized: string): IDecoded; /** * The Ruby version uses url safe base64 encoding. * RFC 4648 specifies + is encoded as - and / is _ * with the trailing = removed. */ export declare function encodeSafe64(data: string): string; export declare function decodeSafe64(base64: string): string; export declare function encodeSafe64Bson(versionByte: string, artifacts: IDerivedKey | IEncryptionArtifacts | ICryppoSerializationArtifacts): string; export declare function decodeSafe64Bson(base64: string): string; export declare function encodeDerivationArtifacts(artifacts: IDerivedKey): string; export declare function decodeDerivationArtifacts(encoded: string): any; /** * Returns some base64 encoded random bytes that can be used for encryption verification. */ export declare function generateEncryptionVerificationArtifacts(): { token: string; salt: string; }; export declare function keyLengthFromPublicKeyPem(publicKeyPem: string): any; export declare function keyLengthFromPrivateKeyPem(privateKey: string): any; //# sourceMappingURL=util.d.ts.map