User approvals
Approvals happen only on the node’s consent page, never in the app: a session opened on an
app is refused (403) if it tries approveRelease itself.
// What waits for a decision: unapproved node releases, newer package releases, a stalled deadline.val pending = client.pendingApprovals(org)
// Ask: POST /consent/requests, then open the page in a Custom Tab.val started = ConsentLauncher.request( activity, client, ConsentRequest.Release(ConsentScope(org), pending.releases.first().version, returnTo = "myapp://consent"),)started.code is the request’s confirmation code (ABC-123); the consent page shows the same
one, so show it in the app before the page opens.
The page sends the person back to returnTo?request_id=…&result=approved|declined. That is a
hint (anyone can type a URL): confirm it with the node.
// In the activity that receives the App Link (null when the intent is not a consent return):val result = ConsentLauncher.resume(client, intent, started.requestId) // or client.resumeConsent(url, id)// or poll, when the link does not come back:val polled = client.waitForConsent(started.requestId, timeout = 10.minutes)resume reads the decision on the request this app started from the node, never from the
link (whose result anyone can type), and throws CalimeroError when the return is not that
decision:
| Code | Means |
|---|---|
CONSENT_NOT_STARTED |
the link names a request, and the app passed none (requestId = null) |
CONSENT_REQUEST_MISMATCH |
the link, or the node’s answer, names another request than the app’s |
CONSENT_NOT_DECIDED |
the page sent the person back, but the app’s request is still pending: another request may have been approved on a page that was not the node’s. Do not act on it |
CONSENT_REPLACED |
the node no longer knows the app’s request (404): an account has one undecided request per node, and a newer one replaced it, possibly on a forged page. Do not act on it either |
Keep started.requestId across the trip to the browser (onSaveInstanceState, or your view
model’s saved state), since the process may be gone when the link comes back. MeroAppSession
does this itself, as mero-js does with sessionStorage: it keeps only the request id in its
SessionStore (under CONSENT_STORAGE_KEY), once the page opens, and forgets it on the node’s
decision or CONSENT_REPLACED; any other refusal keeps it for the real return.
withoutConsentReturn(href) strips request_id and result from a link.
The four steps are the same in mero-js and swift-sdk (request / begin / resume / wait):
| Step | mero-core | mero-compose |
|---|---|---|
| request | client.requestConsent(request): { requestId, url, code, expiresAt } |
|
| begin | client.openConsentPage(request, OpenConsentOptions(navigate, confirm)) (checks code) |
ConsentLauncher.request(context, client, request, confirm) (a Custom Tab) |
| resume | client.resumeConsent(href, requestId) |
ConsentLauncher.resume(client, uri or intent, requestId), MeroAppSession.handle(url) (consentResult / consentError) |
| wait | client.waitForConsent(requestId, timeout), client.consentResult(requestId) |
Organizations and invitations
Section titled “Organizations and invitations”A package-bound session may not create an organization or mint or accept an invitation itself; it asks on the consent page like any other approval:
ConsentRequest.CreateOrg(name = "Acme", returnTo = returnTo)ConsentRequest.CreateInvite(org, OrgRole.MEMBER, returnTo, teams = listOf(team), ttlSecs = 86_400, uses = 1)ConsentRequest.AcceptInvite(token, returnTo)Managing an organization goes through the page the same way (core#5018):
ConsentRequest.LeaveOrg(org, returnTo)ConsentRequest.RemoveMember(org, account, returnTo)ConsentRequest.SetMemberRole(org, account, OrgRole.ADMIN, returnTo) // OWNER hands ownership overConsentRequest.SetMemberTeams(org, account, listOf(ConsentTeamMembership(team, TeamRole.LEAD)), returnTo)ConsentRequest.RemoveMemberTeams(org, account, listOf(team), returnTo)ConsentRequest.RevokeInvite(org, inviteKey, returnTo)ConsentRequest.RenameOrg(org, "Acme Labs", returnTo) // outcome: OrgRenamed(orgId, name)ConsentRequest.DeleteOrg(org, returnTo) // outcome: OrgDeleted(apps)ConsentRequest.SetCapabilities(org, OrgCapabilities.CREATE_APP.toLong(), returnTo, account = account, team = team)ConsentRequest.SetAllApps(org, account, allApps = true, returnTo)SetCapabilities without account sets a default: the team’s, or the organization’s without team.
returnTo must be the package’s own frontend origin or one its signed manifest names, never an
app scheme. On Calimero Cloud, a native app uses the package’s served page, which passes the
answer on to the app’s callback (callback?request_id=…&result=…), as in swift-sdk:
val returnTo = consentReturnTo(origin = "https://x.apps.calimero.network", version = "3.1.72")// https://x.apps.calimero.network/3.1.72/?native-consent=1A verified App Link on such an https origin (an intent filter with android:autoVerify="true"
and the origin’s assetlinks.json) works too. On a development node, use the app’s callback as it is.
Once approved, ConsentResult.outcome says what the approval did, typed by kind:
when (val outcome = result.outcome) { is ConsentOutcome.OrgCreated -> openOrg(outcome.orgId) is ConsentOutcome.InviteCreated -> share(inviteLink(outcome.token)) // a bearer secret is ConsentOutcome.InviteAccepted -> openOrg(outcome.org) is ConsentOutcome.OrgRenamed -> showName(outcome.name) is ConsentOutcome.OrgDeleted -> forgetApps(outcome.apps) ConsentOutcome.LeftOrg, ConsentOutcome.MemberRemoved, ConsentOutcome.MemberRoleSet, ConsentOutcome.MemberTeamsSet, ConsentOutcome.MemberTeamsRemoved, ConsentOutcome.InviteRevoked, ConsentOutcome.CapabilitiesSet, ConsentOutcome.AllAppsSet -> refresh() ConsentOutcome.Release, ConsentOutcome.Upgrade, ConsentOutcome.Outbound -> refresh() is ConsentOutcome.Other -> Unit // a kind this SDK version does not know null -> Unit // pending or declined (result.isDeclined)}An invitation’s token is a secret: ConsentRequest.AcceptInvite and ConsentOutcome.InviteCreated
leave it out of toString, so a logged request or result does not carry it. Do not log
outcome.token yourself.
MeroAppSession.requestConsent(context, request) and MeroAppSession.handle(url) do both, and
put the confirmed result in session.consentResult.
409 CONSENT_STALE means what the page showed changed: ask again. 409 RELEASE_DEADLINE
(ReleaseDeadlineError) means new work is stopped until the scope approves release.