接入既有macOS硬件UUID登录恢复并校验产品会话,准备131

这个提交包含在:
mac 于 2026-11-11 19:39:21 +08:00 提交
1 父节点 4830f913c2
当前提交 d979f8958c
10 个文件已更改
+122 -21

没有与搜索条件相匹配的文件

+11
查看文件
@@ -9,6 +9,9 @@ class Request implements ArrayAccess {
function get_param($k){return $this->params[$k]??null;} function get_header($k){return $this->headers[$k]??'';} function get_body(){return json_encode($this->params);}
function offsetExists($k):bool{return isset($this->params[$k]);} function offsetGet($k):mixed{return $this->get_param($k);} function offsetSet($k,$v):void{$this->params[$k]=$v;} function offsetUnset($k):void{unset($this->params[$k]);}
}
class WP_REST_Request extends Request {function __construct($method){parent::__construct();} function set_param($key,$value){$this[$key]=$value;}}
class AuthBridge {function rest_check_access($request){if($request->get_param('token')!=='stub-valid-device-token')return new WP_Error('invalid','invalid',array('status'=>401));return array('success'=>true,'data'=>array('user_id'=>7));}}
$GLOBALS['dayu_macos_app_auth']=new AuthBridge;
$transients=array();$options=array();$meta=array();$purchase=array();$admin=false;$member=false;$bound=7;$rows=array();$checks=array();
function add_action(...$a){} function add_filter(...$a){} function register_rest_route(...$a){} function wp_schedule_single_event(...$a){}
function add_option($k,$v,...$a){global $options;if(isset($options[$k]))return false;$options[$k]=$v;return true;}
@@ -41,6 +44,14 @@ $meta=array('cao_user_type'=>'vip','cao_vip_end_time'=>time()-1);check(!Dayu_Col
$meta=array('cao_vip_type'=>'year','cao_vip_expire'=>time()+100);check(Dayu_Color_Online_LUTs::access(7),'legacy active membership supported');$meta=array();
check(!Dayu_Color_Online_LUTs::access(8),'deleted user denied');
$device='00000000-0000-0000-0000-000000000001';$key=str_repeat('a',40);$login='dayu_app_login_'.hash('sha256',$key);
check(denied(Dayu_Color_Online_LUTs::device_login(new Request(array('device_uuid'=>$device))),400),'UUID alone cannot mint an online session');
check(denied(Dayu_Color_Online_LUTs::device_login(new Request(array('device_uuid'=>$device,'login_token'=>str_repeat('x',30)))),401),'forged shared login token rejected');
check(denied(Dayu_Color_Online_LUTs::device_login(new Request(array('device_uuid'=>'random-client-id','login_token'=>'stub-valid-device-token'))),400),'non-hardware UUID format rejected');
$restored=body(Dayu_Color_Online_LUTs::device_login(new Request(array('device_uuid'=>$device,'login_token'=>'stub-valid-device-token'))));
check(strlen($restored['token']??'')===64&&$restored['allowed']===false,'existing bound account restored without granting unpaid access');
$bound=8;check(denied(Dayu_Color_Online_LUTs::device_login(new Request(array('device_uuid'=>$device,'login_token'=>'stub-valid-device-token'))),401),'shared login user must match current hardware binding');$bound=0;
check(denied(Dayu_Color_Online_LUTs::device_login(new Request(array('device_uuid'=>$device,'login_token'=>'stub-valid-device-token'))),401),'unbound hardware cannot resume another account');$bound=7;
check(body(Dayu_Color_Online_LUTs::logout(new Request(array(),$restored['token'])))['success']===true,'restored session can be revoked normally');
$session=array('app_name'=>'DayuColor','device_uuid'=>$device,'expires_at'=>time()+120,'status'=>'pending','user_id'=>7);
$transients[$login]=$session;
check(body(Dayu_Color_Online_LUTs::exchange(new Request(array('session_key'=>$key,'device_uuid'=>$device))))['status']==='pending','pending login cannot mint a credential');