feat(sdk): collect device metadata during verify handshake

Auto-collect navigator.userAgent, platform, and language in the SDK
verify RPC payload. Add DeviceMeta type. Hub receives this metadata
for display in the Desktop UI device list and confirmation dialog.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
yushen
2026-02-04 13:43:41 +08:00
parent ff827f05e4
commit dd701a2472
3 changed files with 15 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ export {
type DeleteAgentResult,
type UpdateGatewayParams,
type UpdateGatewayResult,
type DeviceMeta,
type VerifyParams,
type VerifyResult,
} from "./rpc";

View File

@@ -146,9 +146,17 @@ export interface UpdateGatewayResult {
connectionState: string;
}
/** Device metadata collected during verify handshake */
export interface DeviceMeta {
userAgent?: string;
platform?: string;
language?: string;
}
/** verify - request params */
export interface VerifyParams {
token?: string;
meta?: DeviceMeta;
}
/** verify - response payload */

View File

@@ -312,10 +312,15 @@ export class GatewayClient {
if (this.options.hubId) {
// Set internal state to allow send/request during verify
this._state = "registered";
const meta = typeof navigator !== "undefined" ? {
userAgent: navigator.userAgent,
platform: navigator.platform,
language: navigator.language,
} : undefined;
this.request<{ hubId: string; agentId: string }>(
this.options.hubId,
"verify",
{ token: this.options.token },
{ token: this.options.token, meta },
this.options.verifyTimeout,
)
.then((result) => {