Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
6cdb499
feat(duckdb): connect to MotherDuck and update DuckDB to 2.0.1 (#4461)
datlechin Nov 24, 2026
3eb0d7b
docs(core): ADR 0046, a monthly self-hosted license has 7 days' grace…
datlechin Nov 24, 2026
78ec49e
fix(mcp): bind approvals to the scope they showed and harden scope ru…
datlechin Nov 24, 2026
75d2bb4
docs(core): ADR 0048, a self-hosted install signs in through OIDC or …
datlechin Nov 24, 2026
9cf15f0
perf(editor): restyle a long line without typesetting it again (#4475)
datlechin Nov 24, 2026
ddf5288
perf(dashboard): publish one board per Server Dashboard refresh (#4476)
datlechin Nov 24, 2026
32dc16b
fix(focus): keep the sidebar selection accent and the keyboard when a…
datlechin Nov 25, 2026
a1238a1
feat(ai): read models from each provider and a shared catalog (#4477)
datlechin Nov 25, 2026
8955f77
feat(core): sign in to a company server and verify its license (#4470)
datlechin Nov 25, 2026
dfaf912
docs(core): ADR 0050, a self-hosted license renewal is requested by t…
datlechin Nov 25, 2026
fe6a624
docs(core): ADR 0055, managed policies for the sync provider and tabl…
datlechin Nov 25, 2026
e2b0999
feat(filter): list the filter column picker alphabetically on request…
datlechin Nov 25, 2026
2f1d007
feat(core): require RFC 9207 iss where the server promises it, compar…
datlechin Nov 25, 2026
5f4a17f
docs(core): ADR 0051, the sync protocol and its record rules (#4488)
datlechin Nov 25, 2026
3a14cbf
test(core-sqlite): measure the linked SQLite's stored tail check inst…
datlechin Nov 25, 2026
274dcd4
docs(core): 0055's personalSync keeps the key kinds, as amended by 00…
datlechin Nov 25, 2026
54efc4f
docs(core): ADR 0051, G0 round 1 fixes (#4491)
datlechin Nov 25, 2026
cd9b322
docs(core): ADR 0052, synced records have canonical ids and saved que…
datlechin Nov 25, 2026
3b3516e
docs(core): ADR 0051, G0 round 3 security fixes (#4496)
datlechin Nov 25, 2026
43753ff
docs(core): ADR 0054, one sync engine in the core for TablePro Sync a…
datlechin Nov 25, 2026
3c7724f
docs(core): ADR 0053, end-to-end sync keys under the recovery key, an…
datlechin Nov 25, 2026
f1bd5ca
docs(core): 0044 names what 0053 amends (#4499)
datlechin Nov 25, 2026
5f9ac36
docs(core): ADR 0051, G0 round 5 fixes (#4500)
datlechin Nov 25, 2026
c9ded5a
docs(core): 0054's key versions count from the chain, reset generatio…
datlechin Nov 25, 2026
836625e
docs(core): 0054 drop rule, generations without S, head times, fork b…
datlechin Nov 25, 2026
e0c55c6
docs(core): ADR 0053 G0 round 5, equivocation-only forks, new generat…
datlechin Nov 25, 2026
6a202f5
docs(core): ADR 0051, new generations and identity-key team statement…
datlechin Nov 25, 2026
9bdaa24
docs(core): ADR 0052, identity, device and member ids carry the gener…
datlechin Nov 25, 2026
8d79637
fix(transfer): show progress and results inside the import, export an…
datlechin Nov 25, 2026
e2c9a12
docs(core): ADR 0056, end-to-end keys on the 1Password and Bitwarden …
datlechin Nov 25, 2026
0aa3828
docs(core): align 0051, 0052, 0054, 0044 and 0055 with ADR 0056 (#4507)
datlechin Nov 25, 2026
4af6f5d
docs(core): ADR 0056 r2 and 0051, 0052, 0054 amendments for G0 round …
datlechin Nov 25, 2026
c2d418a
feat(policy): apply the ADR 0055 managed policy keys on the Mac and i…
datlechin Nov 25, 2026
26f3157
docs(core): ADR 0056 r3 and 0051, 0054 amendments for G0 round 2 (#4509)
datlechin Nov 25, 2026
c8f9b84
docs(core): ADR 0056 r4 and 0051, 0054 amendments for G0 round 3 (#4511)
datlechin Nov 25, 2026
d95bf4e
chore(skills): verify.sh takes a jobs cap (#4510)
datlechin Nov 25, 2026
1f95b43
docs(core): ADR 0056 r5 and 0051, 0054 amendments for G0 round 4 (#4512)
datlechin Nov 25, 2026
d881b57
docs(core): ADR 0056 r6 and 0051, 0054 amendments for G0 round 5 (#4513)
datlechin Nov 25, 2026
9072f9e
docs(core): ADR 0056 r7 and 0051, 0054 amendments for G0 round 6 (#4514)
datlechin Nov 25, 2026
e56ddf6
docs(core): ADR 0056 r8 and 0051, 0054 amendments for G0 round 7 (#4515)
datlechin Nov 25, 2026
f8e4ec2
fix(ios): keep plugin enum labels and always identities, and name an …
mvanhorn Nov 25, 2026
5402042
docs(core): accept ADRs 0051, 0052, 0054 and 0056 after G0 (#4517)
datlechin Nov 25, 2026
f5e5ea6
refactor(core): move the generated /v2 client into tablepro-cloud-api…
datlechin Nov 25, 2026
e0f17c7
feat(onboarding): setup guide, import hand-off and shortcut presets o…
datlechin Nov 25, 2026
20eab6b
feat(ios): sign in to a TablePro account through the shared core (#4492)
datlechin Nov 25, 2026
fdc66a8
feat(core): tablepro-records crate for synced kinds (#4518)
datlechin Nov 25, 2026
79e19fc
feat(core): tablepro-keys crate for the end-to-end design (#4519)
datlechin Nov 25, 2026
3dfce83
feat(core): store models, change journal and store generation (#4560)
datlechin Nov 25, 2026
fcb8da7
docs(core): ADR 0059, key errors name the expected signer and two lib…
datlechin Nov 25, 2026
01be1a3
docs(core): ADR 0060, the change journal names the records each write…
datlechin Nov 25, 2026
052faa7
docs(core): ADR 0061, the records crate settles six record rules (#4569)
datlechin Nov 25, 2026
743a2e0
docs(core): ADR 0062, a stopped scope records why it stopped (#4574)
datlechin Nov 25, 2026
5edaa79
test(ci): iOS runs on the shortcut presets now that it links the core…
datlechin Nov 26, 2026
018f999
docs(core): ADR 0064, a team restart waits for a word comparison, and…
datlechin Nov 26, 2026
e0cbe8e
docs(core): ADR 0063, the macOS app holds its results in the core bef…
datlechin Nov 26, 2026
295f67b
perf(editor): redraw only the lines a caret move or edit changes (#4570)
datlechin Nov 26, 2026
f8cacd7
perf(editor): parse edits off the main thread without copying the doc…
datlechin Nov 26, 2026
9221796
perf(autocomplete): size the completion popup before showing it and u…
datlechin Nov 26, 2026
594d9f7
docs(core): ADR 0065 and 0066, the WAL timeline check, refused change…
datlechin Nov 26, 2026
08bdd75
fix(core-storage): copy history.db into a name that does not exist ye…
datlechin Nov 26, 2026
3968cbd
fix(core): G1 round 1 fixes for tablepro-keys vectors and hardening (…
datlechin Nov 26, 2026
b055e28
feat(core): UUID record ids for synced kinds (#4587)
datlechin Nov 26, 2026
ba7b463
feat(core): sync crate contracts, FFI sync surface and fakes (#4572)
datlechin Nov 26, 2026
25b1d50
feat(core): store parity for the Mac library (ids, icons, SSH/TLS fie…
datlechin Nov 26, 2026
68b47a8
perf(import): read transaction state only when it can move, and trans…
datlechin Nov 26, 2026
4e39c02
feat(ios): connection library on the core store models (#4608)
datlechin Nov 26, 2026
b40e760
perf(export): start an export from the catalog's row estimate, not an…
datlechin Nov 26, 2026
0ddc1f4
perf(export): read a dump's table DDL once per schema (#4592)
datlechin Nov 26, 2026
baf645f
perf(connections): read the catalog side kinds in one round trip per …
datlechin Nov 26, 2026
4643c81
perf(editor): bound the memory each document's undo history holds (#4…
datlechin Nov 26, 2026
b2791c6
perf(editor): answer attributedString() with the text storage (#4562)
datlechin Nov 26, 2026
c2524df
perf(connections): reconnect when the network returns and ping less w…
datlechin Nov 26, 2026
d1e2db4
feat(macos): saved queries and history on the core stores (#4611)
datlechin Nov 26, 2026
9c5bfa3
perf(autocomplete): run completion requests off the main thread with …
datlechin Nov 26, 2026
77cff41
perf(redis): page keys from a saved scan cursor and send cluster pipe…
datlechin Nov 26, 2026
9df1cb2
fix(core): replace_library refuses a file that changed since it was r…
datlechin Nov 26, 2026
7b91fec
perf(ssh): share one session per route, use the probe channel, keep l…
datlechin Nov 26, 2026
3552158
test(editor): queue each TreeSitter edit burst before any of it can p…
datlechin Nov 26, 2026
10857f3
chore(windows): add changelog.d and towncrier notes (#4612)
datlechin Nov 26, 2026
2e551d4
perf(export): stream gzip while writing a dump and while reading one …
datlechin Nov 26, 2026
62b1297
perf(drivers): decode ClickHouse and SQL Server cells without per-fie…
datlechin Nov 26, 2026
971456a
feat(core): re-vendor /v2 with sync and key operations, and RFC 9470 …
datlechin Nov 26, 2026
917c297
perf(editor): scan a large script's run controls off the main thread …
datlechin Nov 26, 2026
1f3363e
perf(sidebar): match ASCII names by bytes and filter each container o…
datlechin Nov 26, 2026
6400623
perf(connections): use the idle session for the first listing and rea…
datlechin Nov 26, 2026
32b4099
perf(idle): save tabs only after a change and let the app nap with a …
datlechin Nov 27, 2026
0a2120f
perf(connections): send session setup with the connect instead of in …
datlechin Nov 27, 2026
cc50546
perf(editor): keep each query tab's document when switching tabs (#4588)
datlechin Nov 27, 2026
8c47b6c
test(memory): pin that a closed tab lets go of its rows and its resul…
datlechin Nov 27, 2026
ee20f01
ci(ios): install the simulator runtime when the runner image lacks it…
datlechin Nov 27, 2026
2dc1d14
ci(linux): pull Docker Hub images through mirror.gcr.io instead of an…
datlechin Nov 27, 2026
fec5b18
test(core): let each step-up test permit release one sign-in page (#4…
datlechin Nov 27, 2026
422d6ac
test(ios): fail the sync merge save with a read-only folder, not a de…
datlechin Nov 27, 2026
22f3ad1
fix(core-postgres): read the catalogs of PostgreSQL 10 to 13 (#4613)
datlechin Nov 27, 2026
98f6883
test(windows): live-server tests for PostgreSQL (#4614)
datlechin Nov 27, 2026
4079a88
fix(plugin-oracle): follow TNS listener redirects (#4610)
datlechin Nov 27, 2026
20770d4
ci(deps): bump the actions group across 1 directory with 2 updates (#…
dependabot[bot] Nov 27, 2026
873fc11
perf(memory): build each result row at its exact size in every driver…
datlechin Nov 27, 2026
d465598
perf(results): run the adapter's side of every driver call off the ma…
datlechin Nov 27, 2026
f51edc1
perf(autocomplete): rank table names from a prebuilt index instead of…
datlechin Nov 27, 2026
e60d667
fix(ios): a library write after the core's file went missing writes i…
datlechin Nov 27, 2026
3fd812b
perf(data-grid): read large text, JSON and binary cells as a head and…
datlechin Nov 27, 2026
d42bb33
fix(results): check for Stop just before a user statement reaches the…
datlechin Nov 27, 2026
c5d735a
feat(connections): projects that keep one product's connections, quer…
datlechin Nov 27, 2026
bb6d4a3
perf(sqlite): run SQLite statements on their own thread, not Swift's …
datlechin Nov 27, 2026
7407caf
perf(postgresql): read rows in libpq chunks instead of one result per…
datlechin Nov 27, 2026
5b45237
perf(mongodb): read each document's BSON once with libbson's iterator…
datlechin Nov 27, 2026
f1dffe0
feat(core-ai): tool calling for both provider protocols (#4630)
datlechin Nov 27, 2026
0404813
feat(windows): per-shortcut rebinding with a recorder (#4627)
datlechin Nov 27, 2026
cb48f3e
feat(windows): command palette / quick switcher (#4628)
datlechin Nov 27, 2026
f0fc0b5
feat(core): query-plan model, parsers and FFI (#4622)
datlechin Nov 27, 2026
e753de7
feat(core): SSH and credential profiles go through the checked librar…
datlechin Nov 27, 2026
67d604f
fix(linux): read the assistant message text through ChatMessage::text…
datlechin Nov 27, 2026
065acfd
perf(paging): seek on the primary key for next, previous and last pag…
datlechin Nov 27, 2026
90fe85f
fix(plugin-oracle): load the sidebar, long values and CLOBs on Oracle…
datlechin Nov 27, 2026
8af8705
fix(theme): stop a themed window covering the sidebar in full screen …
datlechin Nov 27, 2026
03d311e
fix(theme): make selections visible in every built-in theme (#4636)
datlechin Nov 27, 2026
98bb0b7
feat(core): end-to-end sync engine, accounts and keys (ADR 0044, 0056…
datlechin Nov 27, 2026
dc15243
fix(windows): make the command palette's commit event args a class (#…
datlechin Nov 27, 2026
ddafb12
test(core-storage): the report test builds its profile without serde_…
datlechin Nov 27, 2026
806d4c9
fix(windows): mark ShortcutRecorderButton partial for the AOT publish…
datlechin Nov 27, 2026
8271f51
fix(core-sync): a reopened service waits for its state file, and key …
datlechin Nov 27, 2026
e50a954
docs(core): ADR 0068 moves the pending-edit tracker and undo to the c…
datlechin Nov 27, 2026
051bb76
feat(core): sync connection projects (#4642)
datlechin Nov 27, 2026
2cce543
feat(core): the host peeks and acknowledges the library writes the co…
datlechin Nov 27, 2026
f28a8b6
feat(core): Team Library connections cross as library records, and ev…
datlechin Nov 27, 2026
ec95fcc
docs(core): ADRs 0069 to 0075 settle the full-sync milestone's ruling…
datlechin Nov 28, 2026
6bedf84
fix(macos): stop typing in the connection form's Tags field from cras…
datlechin Nov 28, 2026
ea66de3
fix(macos): open row context menus from VoiceOver and the keyboard (#…
datlechin Nov 28, 2026
4d4925a
feat(core-sync): sync passwords end to end as personal envelopes (#4665)
datlechin Nov 28, 2026
bed162f
fix(windows): run the shortcuts UI test serially and scroll to its ca…
datlechin Nov 28, 2026
c89f096
feat(core): grid copy and display text into the core (C-11) (#4653)
datlechin Nov 28, 2026
eeff06a
feat(windows): agent mode for the AI assistant (1b, 1c, 2) (#4657)
datlechin Nov 28, 2026
0a7066e
fix(core): no state transaction held across a nested begin or a netwo…
datlechin Nov 28, 2026
a262573
feat(core): table structure/DDL and SQL dump/import through the FFI (…
datlechin Nov 28, 2026
d8e4772
fix(core): list and decide sync approvals per record, show them in th…
datlechin Nov 28, 2026
d970079
fix(macos): build the menu anchor test's selection without the reduce…
datlechin Nov 28, 2026
6afee86
feat(core): script runner with a batch error policy into the core (C-…
datlechin Nov 28, 2026
bb41eb8
fix(linux): drop the icu deps the app no longer uses (#4670)
datlechin Nov 28, 2026
4a57f48
feat(core): move the pending-edit tracker and undo to the core, keyed…
datlechin Nov 28, 2026
1b5d480
fix(core): route a personal approval to the engine that listed it (#4…
datlechin Nov 28, 2026
38ea5cc
fix(core-sync): a refused envelope waits for its record, never as a r…
datlechin Nov 28, 2026
bfc26fc
fix(core-sync): the app's synced secrets host takes every kind it nam…
datlechin Nov 28, 2026
5a8deb8
fix(windows): compare stored shortcut values in the shortcuts UI test…
datlechin Nov 28, 2026
3c7e87a
fix(core-sync): the engine opens with the server out of reach and kee…
datlechin Nov 28, 2026
8583a18
fix(core): settle SSH profile names by lowest id, as credential profi…
datlechin Nov 28, 2026
4b0e421
fix(core): a log sink set from any thread never turns tracing off for…
datlechin Nov 28, 2026
97e2b02
test(windows): expect the integer rendering for a toggled boolean cel…
datlechin Nov 28, 2026
ca28319
fix(core): name signed-out key devices and log a public code with eve…
datlechin Nov 28, 2026
7cb317c
test(core): name the captured log line type in the log code tests (#4…
datlechin Nov 28, 2026
dc43cf4
test(core): the project import fakes return the credential write resu…
datlechin Nov 28, 2026
f9adcff
feat(core-sync): team connection secrets as team envelopes (#4682)
datlechin Nov 28, 2026
9ebc4f0
test(ios): lock the folder a failing sync merge save writes to, since…
datlechin Nov 28, 2026
10a30d0
fix(core): a Team Library copy carries no device credential path, and…
datlechin Nov 28, 2026
b85cf95
fix(macos): a Team Library or linked-folder row asks before it uses t…
datlechin Nov 28, 2026
07a3028
feat(windows): TablePro Sync settings, status and end-to-end encrypti…
datlechin Nov 28, 2026
99b8ec6
fix(core): a run's times cross in microseconds, so a run under a mill…
datlechin Nov 28, 2026
6d09ec8
fix(core-sync): a server that never answers is out of reach in second…
datlechin Nov 28, 2026
61457a0
fix(windows): passwords sync under TablePro Sync by default (#4689)
datlechin Nov 28, 2026
ce1706f
fix(macos): start a new folder's rename and keep a rename across a re…
datlechin Nov 28, 2026
1d3292c
fix(macos): keep a rename's caret and selection across a Favorites re…
datlechin Nov 28, 2026
018bb66
test(macos): the history downgrade probe checks the stores 0.88.0 rea…
datlechin Nov 28, 2026
d02dfdb
fix(windows): settings cards set Content only when there is one (#4693)
datlechin Nov 28, 2026
c8beb2d
fix(macos): explain a feature a company license leaves out instead of…
datlechin Nov 28, 2026
6876e08
ci(ios): boot an iPhone on the selected Xcode's simulator runtime and…
datlechin Nov 28, 2026
bebe73c
fix(macos): a file row's sign-in question names the file it opens on …
datlechin Nov 28, 2026
3bb881e
build(linux): drop indexmap from the app, unused since pending edits …
datlechin Nov 28, 2026
39682c2
feat(macos): TablePro Sync on the core, with keys, approvals, passwor…
datlechin Nov 28, 2026
b25a198
fix(sync): show the Passwords switch off while the server does not sy…
datlechin Nov 28, 2026
7b99547
docs(sync): changelog fragments for the Passwords switch fix (#4700)
datlechin Nov 28, 2026
05f8078
ci(macos): give macOS Tests 150 minutes, since a cold Rust cache push…
datlechin Nov 28, 2026
e2514e4
fix(core-sync): a key rotation never keeps a key device no device row…
datlechin Nov 28, 2026
600f6c8
fix(core-sync): split the replace keep list out of complete_replace t…
datlechin Nov 28, 2026
4e98fe6
fix(sync): Keep Theirs keeps a team connection's password, and an edi…
datlechin Nov 28, 2026
9363c67
chore(release): move release/0.89 to main 4e98fe6c75 for v0.89.0-beta.2
datlechin Nov 28, 2026
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
16 changes: 7 additions & 9 deletions apple/TablePro/Core/Services/TeamLibrary/TeamLibrary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,26 @@ internal final class TeamLibrary: ObservableObject {

// MARK: - Publishing

// An edit of the team's copy by an owner, admin or editor, under the team's id for it. Nil secrets keep the team's
// envelopes as they are; otherwise they are the whole set, sealed again for the edited destination.
// An edit of the team's copy by an owner, admin or editor, under the team's id for it. `secretChanges` names only
// the secrets the person set, or cleared with an empty value; the team keeps every other.
func publishConnectionEdit(
_ edited: DatabaseConnection,
of original: TeamLibraryConnection,
secrets: [ConnectionSecretItem: String]?,
secretChanges: [ConnectionSecretItem: String],
to destination: TeamLibraryDestination
) async throws(TeamLibraryPublishError) -> TeamLibraryPublishResult {
var record = LibraryRecordMapping.record(edited, keeping: nil)
record.connection.id = original.id
let arguments = secrets.map { secrets in
ConnectionSecretItem.teamEnvelopeItems.compactMap { item -> TeamSecretArg? in
guard let kind = item.teamEnvelopeKind, let value = secrets[item], !value.isEmpty else { return nil }
return TeamSecretArg(kind: kind, value: value)
}
let changes = ConnectionSecretItem.teamEnvelopeItems.compactMap { item -> TeamSecretChangeArg? in
guard let kind = item.teamEnvelopeKind, let value = secretChanges[item] else { return nil }
return TeamSecretChangeArg(kind: kind, value: value.isEmpty ? nil : value)
}
return try await publish(to: destination) { engine, owner in
try await engine.publishTeamConnectionEdit(
expectedOwner: owner,
teamId: original.teamID,
connection: record,
secrets: arguments
changes: changes
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nonisolated protocol TeamLibraryEngine: TeamConflictEngine {
expectedOwner: TeamLibraryOwnerArg,
teamId: String,
connection: LibraryConnectionRecord,
secrets: [TeamSecretArg]?
changes: [TeamSecretChangeArg]
) async throws -> TeamPublishInfo
func teamConnectionSecrets(
expectedOwner: TeamLibraryOwnerArg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,23 @@ extension ConnectionEditorStore {
let current = library.content.connection(rowID: target.original.connection.id) ?? target.original
let record = enforcingInvariants(edits.applied(to: current.connection, since: since)).record
let outcome: TeamLibraryPublishOutcome
switch await teamSecrets(for: record, current: current, changed: changed, library: library) {
case .unreadable:
outcome = .failed(.failed(.unavailable))
case .secrets(let secrets):
do throws(TeamLibraryPublishError) {
outcome = .finished(try await library.publishConnectionEdit(
record, of: target.original, secrets: secrets, to: target.destination
))
} catch {
outcome = .failed(error)
}
do throws(TeamLibraryPublishError) {
outcome = .finished(try await library.publishConnectionEdit(
record,
of: target.original,
secretChanges: teamSecretChanges(for: record, current: current, changed: changed),
to: target.destination
))
} catch {
outcome = .failed(error)
}
finishTeamPublish(outcome, published: saving)
}
return .failure(.teamPublishInFlight)
}

// What the person changed of the secrets a team envelope carries; an emptied field removes that secret.
// What the person changed of the secrets a team envelope carries; an emptied field clears that secret. A field left
// alone is not here, whether the form could fill it or not.
func changedTeamSecrets(of saving: ConnectionDraft) -> [ConnectionSecretItem: String] {
var changed: [ConnectionSecretItem: String] = [:]
if saving.credentials.password != baseline.credentials.password {
Expand All @@ -113,42 +112,32 @@ extension ConnectionEditorStore {
return changed
}

enum TeamCopySecrets {
// Nil keeps the team's envelopes as they are.
case secrets([ConnectionSecretItem: String]?)
// A secret changed or the connection moved, and the team's secrets could not be read to carry the rest.
case unreadable
}

// Nil while nothing secret changed and the connection still goes where the team's secrets were sealed for. Else
// the whole set: the team's secrets as they are now with the person's changes, and a linked profile's in place of
// the form's, since the copy goes out with that profile's values. A key file's passphrase stays on this Mac.
func teamSecrets(
// The secrets the edit names, an empty value clearing one. The core keeps the team's envelope of every other secret
// and seals it again for a moved copy when it opens on this Mac, so a field the form could not fill never removes
// the team's secret. A linked profile's secrets stand in for the form's, since the copy goes out with that
// profile's values; one the profile does not hold is left as the team has it. A key file's passphrase stays on this
// Mac.
func teamSecretChanges(
for record: DatabaseConnection,
current: TeamLibraryConnection,
changed: [ConnectionSecretItem: String],
library: TeamLibrary
) async -> TeamCopySecrets {
changed: [ConnectionSecretItem: String]
) -> [ConnectionSecretItem: String] {
let was = current.connection
let moved = record.destination != was.destination
|| record.username != was.username
|| record.sshProfileId != was.sshProfileId
|| record.credentialMode != was.credentialMode
guard moved || !changed.isEmpty else { return .secrets(nil) }
guard var secrets = await library.secrets(for: current) else {
return changed.isEmpty ? .secrets(nil) : .unreadable
}
for (item, value) in changed {
secrets[item] = value.isEmpty ? nil : value
}
guard moved || !changed.isEmpty else { return [:] }
var changes = changed
let stored = { (value: String?) in value.flatMap { $0.isEmpty ? nil : $0 } }
if case .profile(let profileId, _) = record.sshTunnelMode {
secrets[.sshPassword] = services.sshProfileStorage.loadSSHPassword(for: profileId)
secrets[.totpSecret] = services.sshProfileStorage.loadTOTPSecret(for: profileId)
changes[.sshPassword] = stored(services.sshProfileStorage.loadSSHPassword(for: profileId))
changes[.totpSecret] = stored(services.sshProfileStorage.loadTOTPSecret(for: profileId))
}
if let profileId = record.credentialMode.profileId {
secrets[.password] = services.credentialProfileStorage.loadPassword(for: profileId)
changes[.password] = stored(services.credentialProfileStorage.loadPassword(for: profileId))
}
return .secrets(secrets.filter { !$0.value.isEmpty })
return changes
}

// Edits typed while the publish ran were not in it, so the window stays with them unsaved.
Expand Down
6 changes: 3 additions & 3 deletions apple/TableProTests/TeamLibrary/TeamLibraryFixture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class FakeTeamLibraryEngine: FakeTeamConflictEngine, TeamLibraryEngine, @u
private var teamReadGate: AsyncGate?
private var passGate: AsyncGate?
private(set) var connectionPublishes: [(team: String, connections: [LibraryConnectionRecord])] = []
private(set) var connectionEdits: [(team: String, connection: LibraryConnectionRecord, secrets: [TeamSecretArg]?)] = []
private(set) var connectionEdits: [(team: String, connection: LibraryConnectionRecord, changes: [TeamSecretChangeArg])] = []
private var heldSecrets: [String: [TeamSecretArg]] = [:]
private var secretsFailure: CoreError?
private(set) var queryPublishes: [(team: String, folders: [TeamFolderArg], queries: [TeamQueryArg])] = []
Expand Down Expand Up @@ -139,12 +139,12 @@ final class FakeTeamLibraryEngine: FakeTeamConflictEngine, TeamLibraryEngine, @u
expectedOwner: TeamLibraryOwnerArg,
teamId: String,
connection: LibraryConnectionRecord,
secrets: [TeamSecretArg]?
changes: [TeamSecretChangeArg]
) async throws -> TeamPublishInfo {
try check(expectedOwner)
try signedIn()
return try state.withLock {
connectionEdits.append((teamId, connection, secrets))
connectionEdits.append((teamId, connection, changes))
return try publishAnswer.get()
}
}
Expand Down
12 changes: 6 additions & 6 deletions apple/TableProTests/TeamLibrary/TeamLibrarySecretsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct TeamLibrarySecretsTests {
#expect(try TeamLibrary.result(of: info) == .publishedWithoutPasswords(0, .off))
}

@Test("An edit goes to its team under the team's id with the whole set of secrets, or none to keep the team's")
@Test("An edit goes to its team under the team's id naming only the secrets set or cleared, and never a key passphrase")
func editPublishesUnderTheTeamsId() async throws {
let engine = FakeTeamLibraryEngine(teams: [TeamLibraryFixture.acme(role: .editor, items: [
TeamLibraryFixture.connection("c1", name: "Prod")
Expand All @@ -104,18 +104,18 @@ struct TeamLibrarySecretsTests {
let result = try await fixture.library.publishConnectionEdit(
edited,
of: original,
secrets: [.password: "rotated", .sshPassword: "", .sshKeyPassphrase: "key file"],
secretChanges: [.password: "rotated", .sshPassword: "", .sshKeyPassphrase: "key file"],
to: destination
)
_ = try await fixture.library.publishConnectionEdit(edited, of: original, secrets: nil, to: destination)
_ = try await fixture.library.publishConnectionEdit(edited, of: original, secretChanges: [:], to: destination)

#expect(result == .published(1))
let first = try #require(engine.connectionEdits.first)
#expect(first.team == TeamLibraryFixture.team)
#expect(first.connection.connection.id == "c1")
#expect(first.connection.connection.port == 5_433)
#expect(first.secrets?.map { "\($0.kind)=\($0.value)" } == ["password=rotated"])
#expect(engine.connectionEdits.last.map { $0.secrets == nil } == true)
#expect(first.changes.map { "\($0.kind)=\($0.value ?? "cleared")" } == ["password=rotated", "ssh_password=cleared"])
#expect(engine.connectionEdits.last.map { $0.changes.isEmpty } == true)
}

@Test("A member's edit is refused before it reaches the engine")
Expand All @@ -132,7 +132,7 @@ struct TeamLibrarySecretsTests {
try await fixture.library.publishConnectionEdit(
original.connection,
of: original,
secrets: nil,
secretChanges: [:],
to: fixture.library.destination(TeamLibraryFixture.team)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ struct ConnectionEditorStoreTeamCopyTests {
try await waitUntil { dismissed }
}

private func secrets(_ edit: (team: String, connection: LibraryConnectionRecord, secrets: [TeamSecretArg]?)?) -> [String]? {
edit?.secrets?.map { "\($0.kind)=\($0.value)" }.sorted()
private func changes(_ edit: (team: String, connection: LibraryConnectionRecord, changes: [TeamSecretChangeArg])?) -> [String]? {
edit?.changes.map { "\($0.kind)=\($0.value ?? "cleared")" }.sorted()
}

@Test("A team's copy opens with the password its envelopes hold, and is never one the library can delete")
Expand All @@ -61,8 +61,8 @@ struct ConnectionEditorStoreTeamCopyTests {
#expect(editor.storage.loadConnections().isEmpty)
}

@Test("A port change publishes under the team's id with the team's secrets sealed again, and writes nothing here")
func movedEditCarriesTheTeamsSecrets() async throws {
@Test("A port change publishes under the team's id naming no secret, so the team seals its own again, and writes nothing here")
func movedEditNamesNoSecret() async throws {
let (team, original) = try await teamCopy()
let editor = try ConnectionEditorStoreFixture()
let store = editor.makeStore(.editTeamCopy(target(original, secrets: [.password: "s3cret"], in: team)), teamLibrary: team.library)
Expand All @@ -72,13 +72,13 @@ struct ConnectionEditorStoreTeamCopyTests {
let edit = try #require(team.engine.connectionEdits.first)
#expect(edit.connection.connection.id == "c1")
#expect(edit.connection.connection.port == 5_433)
#expect(secrets(edit) == ["password=s3cret"])
#expect(changes(edit) == [])
#expect(editor.storage.loadConnections().isEmpty)
#expect(editor.secretKeys(for: original.connection.id).isEmpty)
#expect(!store.isPublishingTeamCopy)
}

@Test("A password a teammate rotated after the form opened is the one sealed again, never the one the form read")
@Test("A password a teammate rotated after the form opened is never overwritten with the one the form read")
func rotatedPasswordIsKept() async throws {
let (team, original) = try await teamCopy()
let editor = try ConnectionEditorStoreFixture()
Expand All @@ -87,7 +87,24 @@ struct ConnectionEditorStoreTeamCopyTests {

try await save(store) { $0.portText = "5433" }

#expect(secrets(team.engine.connectionEdits.first) == ["password=rotated"])
#expect(changes(team.engine.connectionEdits.first) == [])
}

@Test(
"A password field the form could not fill and the person left alone keeps the team's password",
arguments: [[:], nil] as [[ConnectionSecretItem: String]?]
)
func unfilledPasswordIsKept(opened: [ConnectionSecretItem: String]?) async throws {
let (team, original) = try await teamCopy(secrets: [])
let editor = try ConnectionEditorStoreFixture()
let store = editor.makeStore(.editTeamCopy(target(original, secrets: opened, in: team)), teamLibrary: team.library)
#expect(store.draft.credentials.password.isEmpty)

try await save(store) { $0.portText = "56432" }

let edit = try #require(team.engine.connectionEdits.first)
#expect(edit.connection.connection.port == 56_432)
#expect(changes(edit) == [])
}

@Test("A typed password replaces the team's, and a cleared one removes it")
Expand All @@ -107,7 +124,7 @@ struct ConnectionEditorStoreTeamCopyTests {
$0.ssh.password = ""
}

#expect(secrets(team.engine.connectionEdits.first) == ["password=typed"])
#expect(changes(team.engine.connectionEdits.first) == ["password=typed", "ssh_password=cleared"])
}

@Test("A name-only change leaves the team's envelopes as they are")
Expand All @@ -120,7 +137,7 @@ struct ConnectionEditorStoreTeamCopyTests {

let edit = try #require(team.engine.connectionEdits.first)
#expect(edit.connection.connection.name == "Production")
#expect(edit.secrets == nil)
#expect(changes(edit) == [])
}

@Test("A team edit with key passphrases set sends no passphrase: they belong to this Mac's key files")
Expand All @@ -135,26 +152,25 @@ struct ConnectionEditorStoreTeamCopyTests {

try await save(store) {
$0.portText = "5433"
$0.credentials.password = "typed"
$0.ssh.keyPassphrase = "key file"
$0.ssl.clientKeyPassphrase = "client key"
}

#expect(team.engine.connectionEdits.first?.secrets?.map { $0.kind } == ["password"])
#expect(team.engine.connectionEdits.first?.changes.map { $0.kind } == ["password"])
}

@Test("A password typed while the team's secrets cannot be read is refused, and nothing is sent")
func unreadableSecretsRefuseATypedOne() async throws {
@Test("A password typed while the team's secrets cannot be read goes up alone")
func typedPasswordGoesUpWhenTheTeamsCannotBeRead() async throws {
let (team, original) = try await teamCopy()
team.engine.failSecretReads(with: TeamConflictFixture.failure("sync.server"))
let editor = try ConnectionEditorStoreFixture()
let store = editor.makeStore(.editTeamCopy(target(original, secrets: nil, in: team)), teamLibrary: team.library)

store.update { $0.credentials.password = "typed" }
_ = store.save()
try await save(store) { $0.credentials.password = "typed" }

try await waitUntil { store.saveError != nil }
#expect(team.engine.connectionEdits.isEmpty)
#expect(!store.isPublishingTeamCopy)
#expect(changes(team.engine.connectionEdits.first) == ["password=typed"])
#expect(store.saveError == nil)
}

@Test("An edit the team refuses keeps the window open and says why")
Expand Down
1 change: 1 addition & 0 deletions apple/changelog.d/4706.fixed.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Saving a Team Library connection whose password field was empty could delete the team's password.
1 change: 1 addition & 0 deletions apple/changelog.d/4706.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keep Theirs on a Team Library connection conflict could leave the team's password unreadable for everyone.
Loading
Loading