mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
Hub: - add encrypted Live Activity token registry, registration API, and update/end pushes over direct APNs - enable only for HAPI_IOS_PUSH=apns; relay reports remote:false - keep content-state encrypted with the per-install push key and a domain-separated AAD iOS: - add ActivityKit coordinator, HapiWidgets extension, lock-screen and Dynamic Island UI, encrypted content-state, deep links, and settings toggle - cap concurrent activities and reconcile across hub switches Docs/tests: - native contract, privacy, READMEs, localization catalogs - cross-language cipher fixture and hub/iOS unit tests via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
31 lines
1.1 KiB
Swift
31 lines
1.1 KiB
Swift
import Foundation
|
|
import Security
|
|
|
|
/// Read-only Keychain access to the per-install push key shared with the app
|
|
/// and the Notification Service Extension.
|
|
///
|
|
/// The widget target carries the same `run.hapi.companion.push` Keychain
|
|
/// access group. No `kSecAttrAccessGroup` is passed: Foundation reads the
|
|
/// first accessible group, matching the app/NSE lookup. Items are stored
|
|
/// `kSecAttrAccessibleAfterFirstUnlock`, so this works while the phone is
|
|
/// locked after its first unlock since boot.
|
|
enum WidgetKeychain {
|
|
static let service = "run.hapi.companion.push"
|
|
static let pushKeyAccount = "pushKey"
|
|
|
|
static func pushKey() -> Data? {
|
|
let query: [String: Any] = [
|
|
kSecClass as String: kSecClassGenericPassword,
|
|
kSecAttrService as String: service,
|
|
kSecAttrAccount as String: pushKeyAccount,
|
|
kSecReturnData as String: true,
|
|
kSecMatchLimit as String: kSecMatchLimitOne
|
|
]
|
|
var item: CFTypeRef?
|
|
guard SecItemCopyMatching(query as CFDictionary, &item) == errSecSuccess else {
|
|
return nil
|
|
}
|
|
return item as? Data
|
|
}
|
|
}
|