correio/passwordless/store

Trusted adapter protocol. Applications normally use passwordless.Service. Implementations must serialize each command, sample milliseconds since Unix epoch after acquiring serialization, and return Unknown for ambiguous writes.

Types

pub type Fault {
  Unavailable
  Unknown
  Capacity
  IncompatibleData
  IssueExpired
  IdentityCollision
}

Constructors

  • Unavailable
  • Unknown
  • Capacity
  • IncompatibleData
  • IssueExpired
  • IdentityCollision
pub type Issue(a) {
  Issue(
    id: String,
    subject: a,
    scope: String,
    purpose: String,
    destination: String,
    verifier: String,
    expires_at: Int,
    retain_until: Int,
    attempts: Int,
  )
}

Constructors

  • Issue(
      id: String,
      subject: a,
      scope: String,
      purpose: String,
      destination: String,
      verifier: String,
      expires_at: Int,
      retain_until: Int,
      attempts: Int,
    )
pub type Receipt(a) {
  Receipt(row: Row(a), authenticated_at: Int)
}

Constructors

  • Receipt(row: Row(a), authenticated_at: Int)
pub type Refusal {
  Missing
  Expired
  Revoked
  Exhausted
  Consumed
  WrongAnswer
  BindingMismatch
  Malformed
}

Constructors

  • Missing
  • Expired
  • Revoked
  • Exhausted
  • Consumed
  • WrongAnswer
  • BindingMismatch
  • Malformed
pub type Revoke {
  Revoke(id: String, scope: String, purpose: String)
}

Constructors

  • Revoke(id: String, scope: String, purpose: String)
pub type Row(a) {
  Row(
    id: String,
    subject: a,
    scope: String,
    purpose: String,
    destination: String,
    verifier: String,
    expires_at: Int,
    retain_until: Int,
    attempts: Int,
    status: Status,
    failed_commands: List(String),
  )
}

Constructors

  • Row(
      id: String,
      subject: a,
      scope: String,
      purpose: String,
      destination: String,
      verifier: String,
      expires_at: Int,
      retain_until: Int,
      attempts: Int,
      status: Status,
      failed_commands: List(String),
    )
pub type Status {
  Active
  Spent(command: String, authenticated_at: Int)
  Withdrawn
  TimedOut
}

Constructors

  • Active
  • Spent(command: String, authenticated_at: Int)
  • Withdrawn
  • TimedOut
pub type Store(a) {
  Store(
    now: fn() -> Result(Int, Fault),
    issue: fn(Issue(a)) -> Result(Row(a), Fault),
    verify: fn(Verify) -> Result(
      Result(Receipt(a), Refusal),
      Fault,
    ),
    revoke: fn(Revoke) -> Result(Result(Nil, Refusal), Fault),
    cleanup: fn(Int) -> Result(Int, Fault),
  )
}

Constructors

pub type Verify {
  Verify(
    id: String,
    command: String,
    scope: String,
    purpose: String,
    destination: String,
    verifier: String,
  )
}

Constructors

  • Verify(
      id: String,
      command: String,
      scope: String,
      purpose: String,
      destination: String,
      verifier: String,
    )

Values

pub fn issued(command: Issue(a)) -> Row(a)
pub fn revoke_row(
  row: Row(a),
  command: Revoke,
  now: Int,
) -> #(Row(a), Result(Nil, Refusal))
pub fn same_issue(row: Row(a), command: Issue(a)) -> Bool

Issue replay must match its immutable command, including native subject.

pub fn verify_row(
  row: Row(a),
  command: Verify,
  now: Int,
) -> #(Row(a), Result(Receipt(a), Refusal))

Apply only while holding row authority. Time must be read after the lock.

✨ Search Document