Consent

fun Consent(modifier: Modifier = Modifier, requester: Requester, trustedRequesterIdentity: TrustedRequesterIdentity?, presentmentData: PresentmentData, preselectedDocuments: List<Document>, imageLoader: ImageLoader?, transactionDataRendererRepository: TransactionDataRendererRepository? = null, requesterHistory: RequesterHistory? = null, classifyPurposesFn: ClassifyPurposesFn = ::defaultClassifyPurposes, classifyRiskFn: ClassifyRiskFn = ::defaultClassifyRisk, onDocumentsInFocus: (documents: List<Document>) -> Unit, onConfirm: (selection: PresentmentSelection) -> Unit, onCancel: () -> Unit = {})

A composable used for obtaining consent when presenting one or more credentials.

Purpose Classification (classifyPurposesFn)

Consent evaluates the active credential selection using classifyPurposesFn, which returns a set of PresentmentPurposes:

  • Subtitle text: The classified purposes are localized and formatted into the purpose subtitle displayed under the relying party header (e.g., "is requesting your age", "is requesting your driving privileges and identity"). When multiple purposes are returned, they are joined into a localized list in enum declaration order. If an empty set is returned, a fallback unknown purpose phrase is shown.

  • Forwarded to risk assessment: The returned purposes set is forwarded directly as the purposes argument to classifyRiskFn.

Defaults to defaultClassifyPurposes.

Risk Assessment (classifyRiskFn)

Consent evaluates the active credential selection and classified purposes using classifyRiskFn, which returns a ConsentRiskAssessment containing a ConsentRiskLevel and a set of ConsentRiskReasons.

Risk Levels

The evaluated ConsentRiskLevel governs the placement, visual styling, and confirmation safeguards of the RP-info box:

  • ConsentRiskLevel.NORMAL:

  • Placement & styling: Placed at the bottom of the scrollable content using a neutral surface container (no colored fill or border) with an info (ⓘ) icon. When there is only a single use-case, the RP-info box is attached as the bottom segment of that use-case's segmented container group; when there are multiple use-cases, it appears as a standalone segmented container below all use-cases.

  • Confirmation: The "Continue" button is immediately enabled without any cool-off delay.

  • ConsentRiskLevel.WARNING:

  • Placement & styling: Placed at the top of the scrollable content (directly below the relying party header and above the credentials) in a yellow/amber warning box with a warning (⚠) icon.

  • Confirmation: The "Continue" button is immediately enabled without any cool-off delay.

  • ConsentRiskLevel.HIGH_RISK:

  • Placement & styling: Placed at the top of the scrollable content (directly below the relying party header and above the credentials) in a red danger box with a warning (⚠) icon.

  • Confirmation: Enforces a 5-second cool-off timer on the primary button ("Wait..." transitioning to "Continue"). The user must scroll to the bottom of the prompt before the timer begins.

Risk Reasons

Any ConsentRiskReasons in ConsentRiskAssessment.reasons generate corresponding explanatory copy inside the RP-info box (or warning/danger box):

In addition to reason-specific alerts, the RP-info box displays share history (first-time vs. returning share, if requesterHistory is provided), a link to the relying party's privacy policy (if available), and any TrustMetadata.disclaimer.

Defaults to defaultClassifyRisk.

Parameters

modifier
requester

the relying party which is requesting the data.

trustedRequesterIdentity

conveys the level of trust in the requester, if any.

presentmentData

the combinations of credentials and claims that the user can select.

preselectedDocuments

the list of documents the user may have preselected earlier (for example an OS-provided credential picker like Android's Credential Manager) or the empty list if the user didn't preselect.

imageLoader

a ImageLoader.

transactionDataRendererRepository

the TransactionDataRendererRepository to find renderers for transaction data in, or null to use only the built-in rendering.

requesterHistory

an optional RequesterHistory used to query whether the user has shared credentials with requester before.

classifyPurposesFn

function used to classify the PresentmentPurposes of the request.

classifyRiskFn

function used to evaluate the ConsentRiskAssessment of the request.

onDocumentsInFocus

called with the documents currently selected for the user, including when first shown. If the user selects a different set of documents in the prompt, this will be called again.

onConfirm

called when the user presses the "Continue" button, returns the user's selection.

onCancel

called when the sheet is dismissed.