Enrollment
SealdHealthcare.enroll(request) returns an Enrollment. A new device shows it to the person while it waits for an approver. It resolves to a Client once the SDK holds the device certificate (card) and has verified it offline.
wait
wait resolves with the Client once the SDK holds the card and has verified it offline. It rejects with enrollment-rejected or enrollment-lapsed. An enrolled device may still wait for access to some objects. The Client shows what the device still waits for (waiting()).
wait(): Promise<Client>func wait() async throws -> Clientsuspend fun wait(): ClientReturns: The Client for the newly enrolled device.
Records: Nothing. Not a decision.
Errors: enrollment-rejected if the approver rejected the request, enrollment-lapsed if it lapsed before an approver acted.
cancel
cancel withdraws the request and discards the key.
cancel(): Promise<void>func cancel() async throwssuspend fun cancel()Returns: Nothing.
Records: Nothing. Not a decision.
on
on subscribes to changes in the enrollment’s state, such as the code becoming available once the approver opens the request.
on(event: 'change', handler: (state: EnrollmentState) => void): Unsubscribefunc on(_ event: EnrollmentEvent) -> AsyncStream<EnrollmentState>fun on(event: EnrollmentEvent): Flow<EnrollmentState>Parameters
| Name | Type | Description |
|---|---|---|
event | 'change' (TypeScript), EnrollmentEvent (Swift and Kotlin) | The only event this object raises. |
handler | (state: EnrollmentState) => void | Called with the new state on every change. |
In Swift: for await state in enrollment.on(.change) { ... }. In Kotlin: enrollment.on(EnrollmentEvent.CHANGE).collect { state -> ... }.
Returns: Unsubscribe.
Records: Nothing. Not a decision.
Types
EnrollRequest
What SealdHealthcare.enroll takes.
interface EnrollRequest { hostname: string; tenantId: TenantId; replaces?: RecipientId; foundingToken?: string;}struct EnrollRequest { let hostname: String let tenantId: TenantId let replaces: RecipientId? let foundingToken: String?}data class EnrollRequest( val hostname: String, val tenantId: TenantId, val replaces: RecipientId? = null, val foundingToken: String? = null,)| Field | Type | Description |
|---|---|---|
hostname | string | The Seald Healthcare Cloud hostname as the person entered it, such as records.example-health.com. The SDK keeps it beside the device key. The browser extension answers only this hostname’s page. |
tenantId | TenantId | The tenant this device is enrolling into. |
replaces | RecipientId, optional | A replacement: the card it replaces, which the approver signs too. Revoke a lost device. Never replace it. |
foundingToken | string, optional | The tenant’s first device, or a re-founding: the one-use token that stands in for an approver. |
EnrollmentState
type EnrollmentState = 'pending' | 'opened' | 'revealed' | 'approved' | 'enrolled' | 'rejected' | 'lapsed';enum EnrollmentState: String { case pending, opened, revealed, approved, enrolled, rejected, lapsed}enum class EnrollmentState { PENDING, OPENED, REVEALED, APPROVED, ENROLLED, REJECTED, LAPSED }| Value | Meaning |
|---|---|
pending | The request was submitted and waits for an approver to open it. |
opened | An approver opened the request. |
revealed | This device revealed its secret. The code is now available. |
approved | The approver compared the code and approved. |
enrolled | The SDK holds the card and verified it offline. wait() resolves. |
rejected | The approver rejected the request. |
lapsed | The request lapsed before an approver acted. |
EnrollmentEvent
The event Enrollment.on raises, named in Swift and Kotlin where TypeScript uses the string literal 'change'.
type EnrollmentEvent = 'change';enum EnrollmentEvent { case change }enum class EnrollmentEvent { CHANGE }| Value | Meaning |
|---|---|
change | The enrollment’s state changed. |
Enrollment
interface Enrollment { readonly requestId: string; readonly tenantId: TenantId; readonly state: EnrollmentState; readonly code?: string; readonly lapsesAt: Date; wait(): Promise<Client>; cancel(): Promise<void>; on(event: 'change', handler: (state: EnrollmentState) => void): Unsubscribe;}class Enrollment { let requestId: String let tenantId: TenantId let state: EnrollmentState let code: String? let lapsesAt: Date
func wait() async throws -> Client func cancel() async throws func on(_ event: EnrollmentEvent) -> AsyncStream<EnrollmentState>}class Enrollment { val requestId: String val tenantId: TenantId val state: EnrollmentState val code: String? val lapsesAt: Instant
suspend fun wait(): Client suspend fun cancel() fun on(event: EnrollmentEvent): Flow<EnrollmentState>}| Field | Type | Description |
|---|---|---|
requestId | string | The enrollment request’s id, passed to resumeEnrollment after a restart. |
tenantId | TenantId | The tenant this device is enrolling into. |
state | EnrollmentState | The request’s current state. |
code | string, optional | The six-digit code, available once the approver has opened the request and this device has revealed its secret. The person reads it out. |
lapsesAt | Date | When the request lapses if no approver acts. |
wait | () => Promise<Client> | See above. |
cancel | () => Promise<void> | See above. |
on | (event, handler) => Unsubscribe | See above. |