SDK Reference

    @proveanything/smartlinks

    npm install @proveanything/smartlinks
    View on npm →

    Namespaces

    Other

    attestations

    Functions for attestations operations

    18 functions24 types

    create

    Create a single attestation (admin). attestationType are required typescript const a = await attestations.create('coll_123', { subjectType: 'container', subjectId: 'uuid-of-cask', attestationType: 'temperature', recordedAt: '2025-04-15T14:30:00Z', value: { celsius: 12.4 }, ownerData: { sensorId: 'TEMP-7' }, unit: '°C', visibility: 'public', })

    public
    create(collectionId: string,
        data: ) → Promise<>

    createBatch

    Batch-create attestations (admin). Sends an array of CreateAttestationInput objects in a single request. The server processes them atomically and returns the created records. typescript const records = await attestations.createBatch('coll_123', [ { subjectType: 'container', subjectId: 'uuid1', attestationType: 'temperature', value: { celsius: 12.4 } }, { subjectType: 'container', subjectId: 'uuid1', attestationType: 'humidity', value: { rh: 68 } }, ])

    public
    createBatch(collectionId: string,
        items: []) → Promise<[]>

    list

    List attestations for a subject (admin). Returns all three data zones. Supports filtering by type and date range. typescript const { attestations: records } = await attestations.list('coll_123', { subjectType: 'container', subjectId: 'uuid-of-cask', attestationType: 'temperature', recordedAfter: '2025-01-01T00:00:00Z', limit: 50, })

    public
    list(collectionId: string,
        params: ) → Promise<>

    summary

    Time-series summary of attestations (admin). Aggregates attestation counts (and optionally a numeric value field) into time buckets. Useful for charting trends. attestationType are required typescript const { summary } = await attestations.summary('coll_123', { subjectType: 'container', subjectId: 'uuid-of-cask', attestationType: 'temperature', valueField: 'celsius', groupBy: 'day', recordedAfter: '2025-01-01T00:00:00Z', })

    public
    summary(collectionId: string,
        params: ) → Promise<>

    latest

    Latest snapshot — one record per attestationType (admin). Returns the most-recent attestation for each type recorded against this subject. Ideal for dashboards that show the current state of a container. typescript const { latest } = await attestations.latest('coll_123', { subjectType: 'container', subjectId: 'uuid-of-fridge', }) // latest[0].attestationType === 'temperature' // latest[0].latest.value === { celsius: 4.1 }

    public
    latest(collectionId: string,
        params: ) → Promise<>

    verify

    Verify the hash chain for a (subjectType, subjectId, attestationType) tuple (admin). Re-computes each contentHash and confirms it matches the stored value and correctly references the previous record's hash. A valid: false result with failedAt indicates the first broken link. typescript const result = await attestations.verify('coll_123', { subjectType: 'container', subjectId: 'uuid-of-cask', attestationType: 'temperature', }) if (!result.valid) { console.warn('Chain broken at', result.failedAt) }

    public
    verify(collectionId: string,
        params: ) → Promise<>

    treeSummary

    Tree time-series summary — aggregates across an entire container subtree (admin). Performs a BFS traversal of the container hierarchy rooted at subjectId, collects all descendant container IDs (and optionally their items), then aggregates attestations across all of them. subjectType is implicitly 'container' typescript const { summary, subjectCount } = await attestations.treeSummary('coll_123', { subjectId: 'root-warehouse-uuid', attestationType: 'temperature', valueField: 'celsius', groupBy: 'hour', includeItems: true, }) console.log(`Aggregated over ${subjectCount} subjects`)

    public
    treeSummary(collectionId: string,
        params: ) → Promise<>

    treeLatest

    Tree latest snapshot — most-recent record per type across a container subtree (admin). Same BFS traversal as treeSummary, but returns the most-recent record per attestationType aggregated across the entire subtree.

    public
    treeLatest(collectionId: string,
        params: ) → Promise<>

    publicList

    List attestations for a subject (public). Records with visibility='admin' are always excluded. Records with visibility='owner' are included only when the caller provides a valid Firebase ID token that resolves to the subject owner. The audience field in the response indicates the tier that was served. typescript const { attestations: records, audience } = await attestations.publicList('coll_123', { subjectType: 'proof', subjectId: 'proof-uuid', })

    public
    publicList(collectionId: string,
        params: ) → Promise<>

    publicSummary

    Time-series summary (public). Always served at audience='public'. Same parameters as the admin version. attestationType are required

    public
    publicSummary(collectionId: string,
        params: ) → Promise<>

    publicLatest

    Latest snapshot per attestationType (public). Owner elevation applies — provide a Firebase ID token for owner-tier data.

    public
    publicLatest(collectionId: string,
        params: ) → Promise<>

    publicTreeSummary

    Tree time-series summary (public). Always served at audience='public'. Performs the same BFS traversal as the admin version but only includes publicly visible attestations.

    public
    publicTreeSummary(collectionId: string,
        params: ) → Promise<>

    publicTreeLatest

    Tree latest snapshot (public).

    public
    publicTreeLatest(collectionId: string,
        params: ) → Promise<>

    publicContainerList

    List attestations for a specific container (public shortcut). Equivalent to publicList with subjectType='container' and subjectId=containerId pre-filled.

    public
    publicContainerList(collectionId: string,
        containerId: string,
        params?: Omit<, 'subjectType' | 'subjectId'>) → Promise<>

    publicContainerSummary

    Time-series summary for a specific container (public shortcut).

    public
    publicContainerSummary(collectionId: string,
        containerId: string,
        params: Omit<, 'subjectType' | 'subjectId'>) → Promise<>

    publicContainerLatest

    Latest snapshot for a specific container (public shortcut).

    public
    publicContainerLatest(collectionId: string,
        containerId: string) → Promise<>

    publicContainerTreeSummary

    Tree time-series summary rooted at a specific container (public shortcut).

    public
    publicContainerTreeSummary(collectionId: string,
        containerId: string,
        params: Omit<, 'subjectId'>) → Promise<>

    publicContainerTreeLatest

    Tree latest snapshot rooted at a specific container (public shortcut).

    public
    publicContainerTreeLatest(collectionId: string,
        containerId: string,
        params?: Pick<, 'includeItems'>) → Promise<>