接入既有macOS硬件UUID登录恢复并校验产品会话,准备131
这个提交包含在:
1 父节点
4830f913c2
当前提交
d979f8958c
10 个文件已更改
+122
-21
没有与搜索条件相匹配的文件
+10
-2
@@ -99,6 +99,7 @@ static NSDictionary *DYOnlineKeyQuery(void) {
|
||||
[NSDistributedNotificationCenter.defaultCenter postNotificationName:DYOnlineLUTIdentityChanged object:nil userInfo:nil deliverImmediately:YES];return YES;
|
||||
}
|
||||
+ (NSString *)deviceUUID {
|
||||
// macOS hardware host UUID (verified equal to IOPlatformUUID), never uuid_generate/NSUUID.
|
||||
uuid_t uuid;struct timespec timeout={2,0};if(gethostuuid(uuid,&timeout)!=0)return nil;uuid_string_t text;uuid_unparse_upper(uuid,text);return [NSString stringWithUTF8String:text];
|
||||
}
|
||||
+ (NSDictionary *)JSON:(NSData *)data error:(NSError **)error {
|
||||
@@ -107,16 +108,23 @@ static NSDictionary *DYOnlineKeyQuery(void) {
|
||||
}
|
||||
+ (NSProgress *)request:(NSString *)path body:(NSDictionary *)body authenticated:(BOOL)authenticated completion:(DYOnlineLUTReply)completion {
|
||||
BOOL login=[path isEqual:@"/dayu-app/v1/login/session"];
|
||||
if(!login&&![path hasPrefix:@"/dayu-color/v1/lut/"]){if(completion)completion(nil,DYOnlineError(400,@"请求地址无效。"));return nil;}
|
||||
BOOL deviceLogin=[path isEqual:@"/device-login"];
|
||||
if(!login&&!deviceLogin&&![path hasPrefix:@"/dayu-color/v1/lut/"]){if(completion)completion(nil,DYOnlineError(400,@"请求地址无效。"));return nil;}
|
||||
NSDictionary *credential=authenticated?[self credential]:nil;
|
||||
if(authenticated&&!credential){if(completion)completion(nil,DYOnlineError(401,@"请先在大鱼调色主 APP 登录。"));return nil;}
|
||||
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:[@"https://dayu.media/wp-json" stringByAppendingString:path]]];
|
||||
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:deviceLogin?@"https://dayu.media/wp-admin/admin-ajax.php":[@"https://dayu.media/wp-json" stringByAppendingString:path]]];
|
||||
request.HTTPMethod=@"POST";request.cachePolicy=NSURLRequestReloadIgnoringLocalCacheData;
|
||||
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
||||
[request setValue:@"application/json, image/png, application/octet-stream" forHTTPHeaderField:@"Accept"];
|
||||
[request setValue:@"DayuColor-OnlineLUT/1.0" forHTTPHeaderField:@"User-Agent"];
|
||||
if(credential)[request setValue:[@"Bearer " stringByAppendingString:credential[@"token"]]forHTTPHeaderField:@"Authorization"];
|
||||
NSError *error=nil;request.HTTPBody=[NSJSONSerialization dataWithJSONObject:body?:@{} options:0 error:&error];
|
||||
if(deviceLogin){
|
||||
NSURLComponents *form=[[[NSURLComponents alloc]init]autorelease];
|
||||
form.queryItems=@[[NSURLQueryItem queryItemWithName:@"action" value:@"app_device_login"],[NSURLQueryItem queryItemWithName:@"device_uuid" value:body[@"device_uuid"]?:@""],[NSURLQueryItem queryItemWithName:@"app_name" value:@"DayuColor"],[NSURLQueryItem queryItemWithName:@"app_version" value:NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]?:@""]];
|
||||
request.HTTPBody=[form.percentEncodedQuery dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[request setValue:@"application/x-www-form-urlencoded;charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
|
||||
}
|
||||
if(!request.HTTPBody){if(completion)completion(nil,error);return nil;}
|
||||
NSUInteger limit=[path hasSuffix:@"/download"]?64*1024*1024:2*1024*1024;
|
||||
DYOnlineLUTTransfer *transfer=[[[DYOnlineLUTTransfer alloc]init]autorelease];return [transfer start:request limit:limit completion:completion];
|
||||
|
||||
在新工单中引用
屏蔽一个用户