SDK Reference
@proveanything/smartlinks
Namespaces
attestations
Functions for attestations operations
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', })
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 } }, ])
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, })
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', })
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 }
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) }
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`)
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.
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', })
publicList(collectionId: string,
params: ) → Promise<>publicSummary
Time-series summary (public). Always served at audience='public'. Same parameters as the admin version. attestationType are required
publicSummary(collectionId: string,
params: ) → Promise<>publicLatest
Latest snapshot per attestationType (public). Owner elevation applies — provide a Firebase ID token for owner-tier data.
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.
publicTreeSummary(collectionId: string,
params: ) → Promise<>publicTreeLatest
Tree latest snapshot (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.
publicContainerList(collectionId: string,
containerId: string,
params?: Omit<, 'subjectType' | 'subjectId'>) → Promise<>publicContainerSummary
Time-series summary for a specific container (public shortcut).
publicContainerSummary(collectionId: string,
containerId: string,
params: Omit<, 'subjectType' | 'subjectId'>) → Promise<>publicContainerLatest
Latest snapshot for a specific container (public shortcut).
publicContainerLatest(collectionId: string,
containerId: string) → Promise<>publicContainerTreeSummary
Tree time-series summary rooted at a specific container (public shortcut).
publicContainerTreeSummary(collectionId: string,
containerId: string,
params: Omit<, 'subjectId'>) → Promise<>publicContainerTreeLatest
Tree latest snapshot rooted at a specific container (public shortcut).
publicContainerTreeLatest(collectionId: string,
containerId: string,
params?: Pick<, 'includeItems'>) → Promise<>