Files
OSGKeyboard/OSGKeyboardHostSupport/Features/Account/OOBEGrantProvisioningCoordinator.swift
T
rockyandClaude Opus 5 5d51c5bf77 chore: snapshot uncommitted local work before rebasing onto cloud-agent
Safety commit so the 94 uncommitted files in the working tree (in-flight
Account/Mac/Tip work plus the feature-preview recording tooling) survive the
move onto cursor/cloud-agent-1787824905651-vxuwc.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-01 11:28:07 -07:00

45 lines
1.4 KiB
Swift

// OOBEGrantProvisioningCoordinator.swift
// OSGKeyboard · HostSupport
//
// Provisions anonymous, App-Attest-bound OOBE credentials without creating or
// mutating an AccountTokenSession.
import Foundation
#if canImport(OSGKeyboardShared)
import OSGKeyboardShared
#endif
public actor OOBEGrantProvisioningCoordinator {
private let apiClient: AccountAPIClient
private let integrity: DeviceIntegrityCoordinator
private let installationIDs: any OOBEInstallationIDStoring
private let grants: OOBEGatewayGrantCoordinator
public init(
apiClient: AccountAPIClient,
integrity: DeviceIntegrityCoordinator,
installationIDs: any OOBEInstallationIDStoring,
grants: OOBEGatewayGrantCoordinator = OOBEGatewayGrantCoordinator()
) {
self.apiClient = apiClient
self.integrity = integrity
self.installationIDs = installationIDs
self.grants = grants
}
@discardableResult
public func provision() async throws -> ManagedGatewayGrantCredentials {
let installationID = try await installationIDs.oobeInstallationID()
let request = try await integrity.makeOOBEGrantRequest(
installationID: installationID
)
let credentials = try await apiClient.requestOOBEGrant(request)
try await grants.install(credentials)
return credentials
}
public func clear() async {
try? await grants.clearGrant()
}
}