import VaultFormatA from "./VaultFormatA" ; import VaultFormatB from "./VaultFormatB" ; import { hasValidSignature as isFormatBSigned } from "./formatB/signing" ; import { VaultFormatID } from "../types" ; const DEFAULT_FORMAT = VaultFormatA ; let __defaultFormat = DEFAULT_FORMAT ; export function detectFormat ( encryptedContent ) { if ( isFormatBSigned ( encryptedContent ) ) { return VaultFormatB ; } return VaultFormatA ; } export function getDefaultFormat ( ) { return __defaultFormat ; } export function getFormatForID ( id ) { if ( id === VaultFormatID . B ) { return VaultFormatB ; } return VaultFormatA ; } export function setDefaultFormat ( Format = null ) { __defaultFormat = Format || DEFAULT_FORMAT ; }