// StoreKit entitlement: pull the current entitlement's signed representation.
//
// EXAMPLE CODE. Placeholders only.

import Foundation
import StoreKit

extension ClaudeBFF {
    /// The user's current entitlement as a signed JWS, if one is active.
    /// A free trial and a paid subscription both surface here while active, so
    /// the app does not distinguish them. The BFF makes the final decision and
    /// re-verifies the signature server-side.
    static func currentEntitlementJWS() async throws -> String {
        for await result in Transaction.currentEntitlements {
            // Forward the signed representation as-is. The device's own
            // verification is not the gate; the server's is.
            return result.jwsRepresentation
        }
        throw BFFError.noActiveEntitlement
    }
}
