Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
93120ee
feat(dashpay): sign in to an app with one DashConnect QR from protoco…
jeanpierreroma Oct 8, 2026
9552f6a
feat(dashpay): disable the app's key when a one-QR connection is turn…
jeanpierreroma Oct 10, 2026
18d0a04
fix(dashpay): keep every one-QR session key revocable
jeanpierreroma Oct 10, 2026
c80f5a0
fix(dashpay): match grant records by key and fail closed on a stale i…
jeanpierreroma Oct 10, 2026
cc1a970
fix(dashpay): decide one-QR key and response state from Platform
jeanpierreroma Oct 12, 2026
09a28c5
fix(dashpay): disconnect also disables one-QR keys the wallet has no …
jeanpierreroma Oct 12, 2026
7ec86f2
fix(dashpay): keep a stored App Connect value that is not a row list
jeanpierreroma Oct 13, 2026
d24e54a
fix(dashpay): show what a one-QR sign-in gives the app and bind the a…
jeanpierreroma Oct 13, 2026
430b3c0
fix(dashpay): model an unresolved sign-in as its own state and keep t…
jeanpierreroma Oct 13, 2026
fdc5d4c
fix(dashpay): turning off a one-QR connection also disables the app's…
jeanpierreroma Oct 13, 2026
d61a1df
fix(dashpay): a one-QR disconnect reaches the two-QR keys with no ses…
jeanpierreroma Oct 13, 2026
aa8488d
fix(dashpay): a one-QR disconnect looks for the app's keys on the wal…
jeanpierreroma Oct 13, 2026
957ea94
fix(dashpay): say when an app's key on another identity keeps the con…
jeanpierreroma Oct 13, 2026
c5fdbd3
fix(dashpay): keep DashConnect rows and grant records with the wallet…
jeanpierreroma Oct 13, 2026
1633ae0
fix(dashpay): a DashConnect disconnect acts only on the wallet its ro…
jeanpierreroma Oct 13, 2026
8bfc35b
fix(dashpay): one DashConnect approval, key registration or disconnec…
jeanpierreroma Oct 13, 2026
57b3346
fix(dashpay): bind DashConnect operations to the network scope too, a…
jeanpierreroma Oct 13, 2026
c1d6001
fix(dashpay): approve a DashConnect sign-in only for the wallet and n…
jeanpierreroma Oct 13, 2026
c89def3
fix(dashpay): a devnet pointed at other nodes is another scope for a …
jeanpierreroma Oct 13, 2026
41187c9
fix(dashpay): record a one-QR session key before its registration is …
jeanpierreroma Oct 14, 2026
5868ac1
fix(dashpay): confirm a recovered one-QR key only with its bound and …
jeanpierreroma Oct 14, 2026
b41bc1c
fix(dashpay): free a native result string through a typed C pointer
jeanpierreroma Oct 14, 2026
4a05418
Merge branch 'develop' into feat/dashconnect-v2
jeanpierreroma Oct 15, 2026
06e0d2c
fix(dashpay): activate an app's existing row when its one-QR key is c…
jeanpierreroma Oct 15, 2026
5c2f19d
fix(dashpay): give a confirmed one-QR key its row back if the row was…
jeanpierreroma Oct 15, 2026
d126261
Merge remote-tracking branch 'origin/develop' into feat/dashconnect-v2
jeanpierreroma Oct 16, 2026
3b75374
build: pin the platform SDK to v5.1-dev with platform#4844
jeanpierreroma Oct 16, 2026
b9e5089
fix(dashpay): settle a pending one-QR registration before a disconnec…
jeanpierreroma Oct 16, 2026
96bee7c
fix(dashpay): choose the disconnect from a fresh view, and settle a o…
jeanpierreroma Oct 16, 2026
bf4e32c
fix(dashpay): settle a registration that lands during a disconnect, a…
jeanpierreroma Oct 18, 2026
0f37b44
Merge remote-tracking branch 'origin/develop' into feat/dashconnect-v2
romchornyi Oct 30, 2026
79996be
docs(dashpay): note the revision race a one-QR registration record st…
romchornyi Oct 30, 2026
ff13301
docs(dashpay): describe the registration revision gap as it stands
romchornyi Oct 30, 2026
55b0490
fix(dashpay): read the App Connect response through the SDK's off-mai…
romchornyi Nov 6, 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,7 @@ DWUpholdMainnetConstants__Release.m
# Claude Code local settings
.claude/settings.local.json
DashWallet/Uphold-Info.plist

# SDD per-developer files
.claude/*.local.md
.worktrees/
798 changes: 798 additions & 0 deletions DashWallet/Sources/Models/DashConnect/AppConnectLogin.swift

Large diffs are not rendered by default.

37 changes: 29 additions & 8 deletions DashWallet/Sources/Models/DashConnect/DashConnectDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ protocol DashConnectDataSource {

func parseQR(_ content: String) async throws -> DashConnectQr
func makeConnectionRequest(from loginRequest: DashKeyRequest) async -> ConnectionRequest
func approveLogin(_ request: DashKeyRequest) async throws -> DAppConnection
/// `consent` is the request as the approval sheet showed it. A login
/// that would give the app something else, or act for another identity,
/// wallet or network than it was resolved for, is refused.
func approveLogin(_ request: DashKeyRequest, consent: ConnectionRequest) async throws -> DAppConnection
/// Parses a scanned `dash-st:` payload and either completes key
/// registration immediately or returns a token purchase that awaits
/// explicit user approval via `approveTokenPurchase(_:)`.
Expand All @@ -36,8 +39,21 @@ protocol DashConnectDataSource {
/// transition could already have reached Platform — the caller must not
/// offer a retry when it could have.
func approveTokenPurchase(_ request: DashConnectTokenPurchaseRequest) async throws
func disconnect(id: String) async
func remove(id: String) async
/// Turns a connection off. For a one-QR connection this disables the key
/// the app was given on the identity and deletes the published response,
/// and throws when the key could not be disabled — the connection then
/// stays as it was. The connection also stays, and that is thrown, while
/// the app holds a key on another identity of the wallet. For a two-QR
/// connection it only changes the local status: that login derives the
/// same key every time and Platform never re-adds a disabled key, so
/// disabling it would lock the app out for good. Turning off a one-QR
/// connection that replaced a two-QR one does disable those keys too.
///
/// `scope` is the `DAppConnection.scope` of the row that was picked:
/// both calls act only while it still names the wallet they would act
/// on.
func disconnect(id: String, scope: String?) async throws
func remove(id: String, scope: String?) async
}

/// Why a token purchase failed, and — the part that decides what the UI may
Expand Down Expand Up @@ -118,7 +134,11 @@ final class MockDashConnectDataSource: DashConnectDataSource {
network: .testnet
)
static let sampleLoginQRCode = DashConnectSampleQR.keyUri(for: sampleLoginRequest)
static let sampleRequest = ConnectionRequest(loginRequest: sampleLoginRequest)
static let sampleRequest: ConnectionRequest = {
var request = ConnectionRequest(loginRequest: sampleLoginRequest)
request.login = .twoQR
return request
}()

static func sample(_ status: ConnectionStatus) -> DAppConnection {
DAppConnection(
Expand Down Expand Up @@ -194,7 +214,7 @@ final class MockDashConnectDataSource: DashConnectDataSource {
throw DashConnectMockError.notDashConnectQrCode
}

func approveLogin(_ request: DashKeyRequest) async throws -> DAppConnection {
func approveLogin(_ request: DashKeyRequest, consent: ConnectionRequest) async throws -> DAppConnection {
try await Task.sleep(nanoseconds: 400_000_000)

if shouldFailNextApprove {
Expand Down Expand Up @@ -225,7 +245,8 @@ final class MockDashConnectDataSource: DashConnectDataSource {
appUrl: fallback.appUrl,
walletUsername: nil,
walletIdentityId: nil,
existingConnection: existingConnection(for: fallback.appContractId)
existingConnection: existingConnection(for: fallback.appContractId),
login: .twoQR
)
}

Expand All @@ -239,7 +260,7 @@ final class MockDashConnectDataSource: DashConnectDataSource {
DashConnectMockError.stateTransitionNotSupported)
}

func disconnect(id: String) async {
func disconnect(id: String, scope: String?) async throws {
let disconnectedAt = Date()
persistAndSend(subject.value.map { connection in
guard connection.id == id else { return connection }
Expand All @@ -253,7 +274,7 @@ final class MockDashConnectDataSource: DashConnectDataSource {
})
}

func remove(id: String) async {
func remove(id: String, scope: String?) async {
persistAndSend(subject.value.filter { $0.id != id })
}

Expand Down
56 changes: 53 additions & 3 deletions DashWallet/Sources/Models/DashConnect/DashConnectModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ extension DashConnectTokenPurchaseRequest {
/// the user locally turned the connection off from the wallet UI.
///
/// `active` means the app's login keys are registered on the identity and the
/// wallet has already published the matching `loginKeyResponse`.
/// wallet has already published the matching `loginKeyResponse`. For a one-QR
/// connection it means the app holds a session key on an identity of this
/// wallet that this wallet has not disabled: the row is made once the key is
/// seen on the identity, before its response is published, and stays
/// whether or not the publish is confirmed.
enum ConnectionStatus: String, Codable, CaseIterable {
case approved
case active
Expand All @@ -173,13 +177,27 @@ enum ConnectionStatus: String, Codable, CaseIterable {
}
}

/// Which login made a connection. It decides what turning it off means:
/// a one-QR connection has a session key on the identity to disable, a
/// two-QR connection does not (see `DashConnectDataSource.disconnect`).
enum DashConnectLoginKind: String, Codable {
case twoQR
case oneQR
}

/// A connected app identified by its stable contract id.
struct DAppConnection: Identifiable, Equatable, Hashable {
let id: String
let name: String
let url: String
let status: ConnectionStatus
let updatedAt: Date
var loginKind: DashConnectLoginKind = .twoQR
/// Names the wallet and network a data source published this row for;
/// `nil` on a row that was built or read from a store. Not stored. It
/// goes back with a disconnect or a remove, so a row picked from a list
/// that has since changed wallets is not acted on in the new one.
var scope: String? = nil
}

/// A pending request derived from a scanned login QR code.
Expand All @@ -190,6 +208,14 @@ struct ConnectionRequest: Equatable {
let walletUsername: String?
let walletIdentityId: String?
let existingConnection: DAppConnection?
/// The login approving this request would run.
var login: AppConnect.Login = .unresolved
/// Why the login is unresolved, when the wallet knows.
var unresolvedLoginReason: String? = nil
/// Names the wallet and network this request was resolved for; `nil`
/// when it was not resolved against one. An approval runs only while it
/// is still the active one.
var scope: String? = nil
}

extension ConnectionRequest {
Expand Down Expand Up @@ -217,15 +243,39 @@ extension ConnectionRequest {
appUrl: String,
walletUsername: String?,
walletIdentityId: String?,
existingConnection: DAppConnection?
existingConnection: DAppConnection?,
login: AppConnect.Login = .unresolved,
unresolvedLoginReason: String? = nil,
scope: String? = nil
) {
self.init(
appLabel: appLabel.trimmingCharacters(in: .whitespacesAndNewlines),
appUrl: appUrl.trimmingCharacters(in: .whitespacesAndNewlines),
appContractId: loginRequest.contractId.toBase58String(),
walletUsername: walletUsername,
walletIdentityId: walletIdentityId,
existingConnection: existingConnection
existingConnection: existingConnection,
login: login,
unresolvedLoginReason: unresolvedLoginReason,
scope: scope
)
}

/// Whether this request, as a sheet showed it, was resolved for the
/// identity, wallet and network an approval is about to run for.
func wasResolved(forIdentityId identityId: String, scope: String) -> Bool {
walletIdentityId == identityId && self.scope == scope
}
}

extension AppConnect.SessionKeyTerms {
/// The budget as DASH at full credit precision, e.g. "0.05 DASH".
var budgetText: String {
PlatformCreditsFormatter.dashString(budgetCredits)
}

/// The lifetime in whole days.
var lifetimeDays: Int {
Int(lifetime / (24 * 60 * 60))
}
}
32 changes: 30 additions & 2 deletions DashWallet/Sources/Models/DashConnect/DashConnectStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ import os
protocol DashConnectStore {
func load() -> [DAppConnection]
func save(_ connections: [DAppConnection])
/// Names the wallet and network whose rows this store reads and writes
/// right now; `nil` when it has no scope.
var scopeKey: String? { get }
/// This store fixed to one wallet, and to the network scope it has now.
/// An operation that outlasts a wallet switch reads and writes through
/// it, so its rows stay with the wallet it ran for.
func pinned(toWalletIdHex walletIdHex: String) -> any DashConnectStore
}

final class UserDefaultsDashConnectStore: DashConnectStore {
Expand Down Expand Up @@ -76,6 +83,22 @@ final class UserDefaultsDashConnectStore: DashConnectStore {
return "dashconnect.connections.v1.\(networkScope).\(walletScope)"
Comment thread
romchornyi marked this conversation as resolved.
Resolved
}

var scopeKey: String? { storageKey }

func pinned(toWalletIdHex walletIdHex: String) -> any DashConnectStore {
pinnedStore(toWalletIdHex: walletIdHex)
}

func pinnedStore(toWalletIdHex walletIdHex: String) -> UserDefaultsDashConnectStore {
let devnetName = devnetNameProvider()
return UserDefaultsDashConnectStore(
defaults: defaults,
network: network,
walletIdHexProvider: { walletIdHex },
devnetNameProvider: { devnetName }
)
}

private var networkScope: String? {
guard network == .devnet else { return network.rawValue }
guard let name = devnetNameProvider()?
Expand Down Expand Up @@ -115,7 +138,8 @@ final class UserDefaultsDashConnectStore: DashConnectStore {
name: row.label,
url: row.url,
status: row.status,
updatedAt: row.updatedAt
updatedAt: row.updatedAt,
loginKind: row.loginKind ?? .twoQR
)
)
}
Expand All @@ -140,7 +164,8 @@ final class UserDefaultsDashConnectStore: DashConnectStore {
label: $0.name,
url: $0.url,
status: $0.status,
updatedAt: $0.updatedAt
updatedAt: $0.updatedAt,
loginKind: $0.loginKind == .twoQR ? nil : $0.loginKind
)
}

Expand All @@ -166,6 +191,9 @@ final class UserDefaultsDashConnectStore: DashConnectStore {
let url: String
let status: ConnectionStatus
let updatedAt: Date
/// Absent for a two-QR connection, which is every row written before
/// the one-QR login existed.
let loginKind: DashConnectLoginKind?
}

private static func base58Decode(_ string: String) -> Data? {
Expand Down
Loading
Loading