OverviewFilesCommitsIssuesDocsReleasesPeers

autobase-doctor / node_modules / encryption-encoding / index.d.ts

31 lines · typescript ref:
declare module 'encryption-encoding' {
  interface EncryptionData {
    value: Buffer | string
    version: number
  }

  interface State {
    start: number
    end: number
    buffer: Buffer | null
  }

  interface EncryptionEncoding {
    preencode(state: State, data: EncryptionData): void
    encode(state: State, data: EncryptionData): void
    decode(state: State): EncryptionData
  }

  export const encryptionEncoding: EncryptionEncoding

  export function encrypt(
    value: Buffer | string,
    cb: (value: Buffer | string) => Promise<EncryptionData>
  ): Promise<Buffer>

  export function decrypt<T = any>(
    value: Buffer,
    cb: (decoded: EncryptionData) => Promise<T>
  ): Promise<T>
}