修改KBAuthSession主程序添加token extension没有拿到的情况

This commit is contained in:
2025-10-31 16:50:15 +08:00
parent 90c1e7ff6c
commit ffea9d2022
9 changed files with 642 additions and 1 deletions

View File

@@ -62,6 +62,15 @@ static const NSTimeInterval kKBExpiryGrace = 5.0; // 秒
return m;
}
#if DEBUG
static inline void KBLog(NSString *fmt, ...) {
va_list args; va_start(args, fmt);
NSString *msg = [[NSString alloc] initWithFormat:fmt arguments:args];
va_end(args);
NSLog(@"[KBAuth] %@", msg);
}
#endif
- (instancetype)init {
if (self = [super init]) {
[self reloadFromKeychain];
@@ -166,6 +175,13 @@ static void KBAuthDarwinCallback(CFNotificationCenterRef center, void *observer,
query[(__bridge id)kSecAttrAccessible] = (__bridge id)kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly;
OSStatus status = SecItemAdd((__bridge CFDictionaryRef)query, NULL);
#if DEBUG
if (status != errSecSuccess) {
KBLog(@"SecItemAdd failed status=%ld group=%@", (long)status, KB_KEYCHAIN_ACCESS_GROUP);
} else {
KBLog(@"SecItemAdd ok group=%@", KB_KEYCHAIN_ACCESS_GROUP);
}
#endif
return (status == errSecSuccess);
}
@@ -176,6 +192,13 @@ static void KBAuthDarwinCallback(CFNotificationCenterRef center, void *observer,
CFTypeRef dataRef = NULL;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &dataRef);
#if DEBUG
if (status != errSecSuccess) {
KBLog(@"SecItemCopyMatching status=%ld group=%@ (item not found or no entitlement)", (long)status, KB_KEYCHAIN_ACCESS_GROUP);
} else {
KBLog(@"SecItemCopyMatching ok group=%@", KB_KEYCHAIN_ACCESS_GROUP);
}
#endif
if (status != errSecSuccess || !dataRef) return nil;
return (__bridge_transfer NSData *)dataRef;
}