import { Dict } from './data-structures.js'; type SerialKind = 'JSON' | 'CBOR' | 'MGPK'; /** * SAIDifies arbitrary data passed in as a map (Dict) object. * Defaults to using the customary letter `d` as the label. The 'd' stands for digest. * Defaults to using Blake3-256 as the derivation algorithm and JSON as the serialization kind. * * Returns a tuple of [said, saidified data] * - said: Self-addressing identifier; the fully qualified Base64 SAID * - sad: Self-addressing data; the data object with the SAID added to the field labeled by `label` * * @example * * ```ts * const myData = { * a: 1, * b: 2, * d: '' * } * const label = 'd'; * const said = deriveSAIDBytes(myData, label); * console.log(said); * expect(said).toEqual('ELLbizIr2FJLHexNkiLZpsTWfhwUmZUicuhmoZ9049Hz'); * ``` * * @param data - data to derive self-addressing data from and to add to as a prop labeled by `label` * @param label - name of the property in the "data" field that will have the SAID placed inside * @param code - algorithm to be used to derive the SAID * @param kind - type of serialization to use * @param prefix - producing a `urn:said:`-prefixed identifier when using `URN_SAID_PREFIX`. */ export declare function saidify(data: Dict, label?: string, code?: string, kind?: SerialKind, prefix?: string): [string, Dict]; /** * The `urn:said:` prefix is included in the placeholder prior to digest * calculation (pre-processing), so the serialized byte size is preserved when the placeholder is * replaced with the final SAID. * * Returns a tuple of [said, saidified data] where `said` is the full `urn:said:` string and the * field labeled by `label` in the returned data contains that same `urn:said:` string. * * @example * * ```ts * const data = { id: '', first: 'Sue', last: 'Smith', role: 'Founder' } * const [urn, sad] = saidifyUrn(data, 'id') * // urn === 'urn:said:ELDYOBfFDX7hCuC0aJk1ux-n4I2U4FHdsT5RdiEas_It' * // sad.id === urn * ``` * * @param data - data to derive self-addressing data from and to add to as a prop labeled by `label` * @param label - name of the property in the "data" field that will have the SAID placed inside * @param code - algorithm to be used to derive the SAID * @param kind - type of serialization to use */ export declare function saidifyUrn(data: Dict, label?: string, code?: string, kind?: SerialKind): [string, Dict]; /** * Verifies a self-addressing data structure against a SAID. If the SAID is not supplied then the indicated * labeled field is used to read the SAID to use to verify the data. * * IMPORTANT: This assumes insertion-order preserving data structures. Newer versions of JavaScript/TypeScript * guarantee this but older versions do not. * If you are using an older version of JavaScript/TypeScript then this is currently unsupported as the * order of fields will not be deterministic. * * @example * * ```ts * const myData = { * a: 1, * b: 2, * d: 'ELLbizIr2FJLHexNkiLZpsTWfhwUmZUicuhmoZ9049Hz' * } * const label = 'd'; * const said = 'ELLbizIr2FJLHexNkiLZpsTWfhwUmZUicuhmoZ9049Hz'; * const doesVerify = verify(myData, label, said); * // test assertion * expect(doesVerify).toEqual(true); * ``` * * @param sad - The self-addressing data to verify. Should contain the digest field labeled with the 'label' param. * @param label - The label of the self-addressing digest field, the SAID, in the self-addressing data 'sad' param. * @param said - The SAID to verify against. Defaults to the 'label' field of the 'sad' param. * @param code - The derivation code specifying which algorithm to use. Defaults to Blake3-256. * @param kind - The serialization kind to use. Defaults to JSON. * @param prefix - Prepends `urn:said:` to the placeholder before hashing. */ export declare function verify(sad: Dict, said?: string, label?: string, code?: string, kind?: SerialKind, prefix?: string): boolean; /** * Recomputes the digest using a `urn:said:`-prefixed placeholder (pre-processing) and * compares against the supplied (or embedded) `urn:said:` value. * * @param sad - The self-addressing data to verify. The field labeled `label` should contain a * `urn:said:` value. * @param said - The full `urn:said:` to verify against. Defaults to the `label` field of `sad`. * @param label - The label of the self-addressing digest field in `sad`. * @param code - The derivation code specifying which algorithm to use. Defaults to Blake3-256. * @param kind - The serialization kind to use. Defaults to JSON. */ export declare function verifyUrn(sad: Dict, said?: string, label?: string, code?: string, kind?: SerialKind): boolean; export {};