Apps
Create an instance
Section titled “Create an instance”val appId = client.apps.create( name = "general", `package` = "com.calimero.chat", // installed from the registry if missing org = orgId, grants = listOf(AppGrant.Team(teamId)), // or Org, Account(…), Anyone; none: the owner initArgs = buildJsonObject { put("name", "general") },).appIdA raw bundle (client.packages.bundlePut, then apps.create(bundle = hash)) and .mpk uploads
(client.packages.upload) work only on a --dev cluster; production installs only from the registry
(client.packages.install).
Updates
Section titled “Updates”apps.update says whether a newer release is available and what it changes, judged over the app
and every app its release created with it
(Where an update may send data):
val u = client.apps.update(app = appId)u.available?.let { a -> a.propertyClass // the JSON `class`: PropertyClass.GREEN or RED a.reasons // why it is red: [{ code: "egressAdded", … }, …] a.egress // before, after, added, removed; null when unknown a.signerChanged // null when unknown a.summary // the update in one plain line, for a banner}u.mayApprove // whether this caller may approve itAn update the node cannot classify (a release the app runs is no longer installed) is red with an
unclassified reason, and what it would compare is null: show it as unknown, never as unchanged.
The organization’s owner and admins decide how updates apply (Update policies) and may undo one for a week (Restore points and undo); each change is a passkey step-up:
client.orgs.policySet(org = orgId, policy = Explicit(UpgradePolicyBodyPolicy( secondApprover = true, autoApply = UpgradePolicyBodyPolicy.AutoApply.NEVER, holdHours = 24)))// or apps.policySet(app = appId, policy = Explicit(UpgradePolicyBodyPolicy(…))) for one app;// Explicit(null) drops itclient.apps.approveUpgrade(app = appId, version = "1.1.0") // the first of twootherAdmin.apps.upgrade(app = appId, version = "1.1.0") // another owner or admin's clientclient.apps.undoView(app = appId) // what an undo would lose (lostWrites)client.apps.undo(app = appId)client.orgs.updates(org = orgId) // every app with an update or an approval waitingPublic links
Section titled “Public links”A public link lets anyone with its token call the app’s #[app::public] methods without an account
(Public links). Whoever may change the app’s access makes
one, with a passkey step-up; the visitor’s client signs each request with its own key:
val created = client.apps.publicLinkCreate(app = appId, label = "Feedback", ratePerMinute = 60)created.token // shown once: hand it to visitorsclient.apps.publicLinkList(app = appId).links // terms and creator, never a tokenclient.apps.publicLinkRevoke(app = appId, link = created.link)
// The visitor: no sign-in. Keep the seed (newVisitorSeed()) in encrypted preferences to stay the same visitor.val visitorClient = CalimeroClient(CalimeroClientOptions(baseUrl = clusterUrl, policy = CloudPolicy.production))val visitor = visitorClient.useVisitor(link = created.token, seed = newVisitorSeed())visitor.publicKey // how the app names the visitorvisitorClient.apps.intents(app = appId, method = "submit", args = args)useVisitor signs every request afresh (Bearer vis1.…, valid within 5 minutes of the node’s
clock), and only the app’s #[app::public] methods answer it; useApiKey or useSession replaces it.
forget() drops it without a request; signOut() does too, but first tries the revoke, which the node
refuses with 403 VISITOR_ONLY (a visitor has no session), and throws that after the credential is gone.
Calls and views
Section titled “Calls and views”val call = client.apps.intents(app = appId, method = "send_message", args = args) // index, result, events, receiptval view = client.apps.views(app = appId, method = "get_messages", args = args) // index, result; consistency = STALE reads any replicaintents mints an idempotency key (node:c-…) unless you give one, and retries a 503 or a dropped
connection with the same key (6 times, 200 ms doubling to 2 s). When it gives up it throws
UnavailableError, whose committed is Committed.No (the node said it did not run) or
Committed.Unknown. An app’s own refusal is AppError(appCode, fields).
Events
Section titled “Events”client.events(appId, from = 0).collect { event -> /* event.kind, event.data */ }A sealed server-sent event stream; cancel the collecting coroutine to close it.
Blobs and presence
Section titled “Blobs and presence”val blob = client.uploadBlob(appId, bytes, "image/png") // BlobInfo(blobId base58, id hex, size)val back = client.downloadBlob(appId, blob.blobId)val content = client.blobContent(appId, blob.blobId) // bytes + the content type servedval shared = client.downloadBlobGranted(appId, blobId, grant) // a run's grant: no session neededval outbox = client.apps.xcalls(app = appId) // a component app's pending xcalls, dead lettersclient.publishPresence(appId, seq = 1, state = "typing".encodeToByteArray())client.presence(appId)Sealed files
Section titled “Sealed files”A component app’s sealed files are encrypted on the node; only the app’s owner and its organization’s members may read them, and the node hands out only ciphertext:
val file = client.uploadFile(appId, bytes) // FileInfo(id, blobId, size, sha256, index)val large = client.uploadFile(appId, java.io.File(path)) // past 16 MiB: an upload session, read part by partval plain = client.exportFile(appId, file.id) // in memoryclient.exportFileTo(appId, file.id, FileSink.of(output)) // streamed, one 64 KiB chunk at a timeAn export asks the node to wrap the file’s data key to a key made for that call, checks every
segment against the file’s id before opening it, and the size and plaintext SHA-256 at the end
(core’s Client::export_file_to). A check that fails is an ExportError (BAD_ANSWER,
NOT_THE_FILE, TAMPERED, TOO_LARGE); discard what the sink got then, since it may be a prefix.
Cancel the coroutine to stop a download.
Pipeline receipts
Section titled “Pipeline receipts”val cluster = client.verifyAppCluster(appId) // each replica's attested receipt key, the governanceval answer = client.pipelineReceipt(appId, runId) // { receipt, node, signature }, version 2val receipt = client.verifyPipelineReceipt(appId, runId, answer)verifyPipelineReceipt checks, under the client’s own CloudPolicy, that an attested replica’s
receipt key signed the receipt, that it is for that app and run, and that every job’s report is
signed by a job key a job node’s quote binds to the cluster; a failure is a
ReceiptVerificationException naming what failed (core’s calimero-client, mero-js receipts.ts).