Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion appleApp/FTWKit/Sources/FTWKit/Protocol/Contract.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ public enum Contract {

public static let roleOwner = "owner"
public static let roleViewer = "viewer"
public static let roleWatch = "watch"

/// What each role carries, with the registry's `*` expanded. Used only
/// for a box from before roles, which sends no scope list.
public static let roleScopes: [String: [String]] = [
roleOwner: scopes,
roleViewer: ["ftw.live.read"],
roleWatch: ["ftw.live.read", "ftw.plan.read", "ftw.events.read", "ftw.dispatch.write"],
]

public static let roleLabels: [String: String] = [
roleOwner: "Owner",
roleViewer: "Viewer",
roleWatch: "Watch",
]

public static let scopeModeWrite = "ftw.mode.write"
Expand All @@ -44,7 +47,7 @@ public enum Contract {
"cmd.lease", "cmd.precondition", "cmd.readback",
"der.battery", "der.ev", "der.v2x",
"plan.dispatch", "net.webrtc", "price.spot", "api.passthrough",
"cloud.link",
"cloud.link", "cmd.exchange",
]

public static let capHistory5m = "history.5m"
Expand All @@ -55,6 +58,8 @@ public enum Contract {
/// The box can run the FTW Cloud uplink. Absent, the app offers no FTW
/// Cloud and reads through the relay alone.
public static let capCloudLink = "cloud.link"
/// The box can take a watch. Absent, the phone offers no Add watch.
public static let capCmdExchange = "cmd.exchange"

/// The scopes an FTW Cloud grant may name, and what its data may be
/// used for: the registry's `cloud_scopes` and `cloud_purposes`.
Expand Down
11 changes: 11 additions & 0 deletions protocol/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ capabilities:
# only and offers no FTW Cloud. It says nothing about whether the owner
# turned FTW Cloud on; the box's grant decides that.
- cloud.link
# The box can take a watch: it opens the relay's exchange socket and mints
# watch codes. Absent means the phone offers no Add watch. The wire is
# docs/watch-exchange.md in srcfl/ftw-webapp.
- cmd.exchange

# ---------------------------------------------------------------------------
# Scopes. One object axis, two verb axes: <object>.<read|write>.
Expand All @@ -104,6 +108,13 @@ roles:
viewer:
label: Viewer
scopes: [ftw.live.read]
# A watch that an owner phone added. That phone is its parent, and each check
# keeps only the scopes below that the parent holds at that moment, so a
# watch never does more than its phone can do now. Read and charge: no site
# mode, no members, no history and no passthrough.
watch:
label: Watch
scopes: [ftw.live.read, ftw.plan.read, ftw.events.read, ftw.dispatch.write]

# ---------------------------------------------------------------------------
# FTW Cloud. What an owner can let the box share with FTW Cloud, and why.
Expand Down
Loading