luminate/Sources/LuminateCore/Models/JellyfinQuickConnectState.swift

70 lines
2.8 KiB
Swift

//
// JellyfinQuickConnectState.swift
//
// Copyright 2026 Brendan Szymanski <hello@bscubed.dev>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
import Foundation
/// The state of a Quick Connect pairing attempt.
///
/// Quick Connect is a three-part exchange: Luminate initiates a request and shows the returned
/// ``code`` to the user, the user approves that code from an already signed-in client, and Luminate
/// polls with the ``secret`` until ``authenticated`` is `true` and then exchanges the secret for a
/// token. The secret must never be shown to the user; the code must never be sent as a secret.
package struct JellyfinQuickConnectState: Hashable, Sendable {
/// Whether the user has approved the request yet.
package var authenticated: Bool?
/// The private value Luminate polls and finally redeems with. Never display this.
package var secret: String?
/// The short human-readable code the user types into an already signed-in client.
package var code: String?
/// The identifier of the device that made the request.
package var deviceID: String?
/// The name of the device that made the request.
package var deviceName: String?
/// The name of the application that made the request.
package var appName: String?
/// The version of the application that made the request.
package var appVersion: String?
/// When the request was created; servers expire unapproved requests.
package var dateAdded: Date?
/// Creates a Quick Connect state, defaulting every unspecified field to `nil`.
///
/// Each parameter sets the property of the same name.
package init(
authenticated: Bool? = nil,
secret: String? = nil,
code: String? = nil,
deviceID: String? = nil,
deviceName: String? = nil,
appName: String? = nil,
appVersion: String? = nil,
dateAdded: Date? = nil
) {
self.authenticated = authenticated
self.secret = secret
self.code = code
self.deviceID = deviceID
self.deviceName = deviceName
self.appName = appName
self.appVersion = appVersion
self.dateAdded = dateAdded
}
}