@mearl/client
Advanced tools
+3
-3
@@ -1,2 +0,2 @@ | ||
| import { UnifiedClient } from './unified.js'; | ||
| import { UnifiedClient, normalizeBrowserSelector, } from './unified.js'; | ||
| function formatError(error) { | ||
@@ -19,3 +19,3 @@ return error instanceof Error ? error.message : String(error); | ||
| function browserMatches(browser, selector) { | ||
| const normalized = selector.trim().toLowerCase(); | ||
| const normalized = normalizeBrowserSelector(selector); | ||
| return (browser.browserId.toLowerCase() === normalized || | ||
@@ -30,3 +30,3 @@ browser.originalBrowserId?.toLowerCase() === normalized || | ||
| return exact; | ||
| const normalized = selector.trim().toLowerCase(); | ||
| const normalized = normalizeBrowserSelector(selector); | ||
| return browsers.filter(browser => browser.browserId.toLowerCase().includes(normalized) || | ||
@@ -33,0 +33,0 @@ browser.originalBrowserId?.toLowerCase().includes(normalized) || |
+15
-7
@@ -339,11 +339,11 @@ import { type BrowserCommandAction } from './generated-browser-action-protocol.js'; | ||
| readonly name: "tdbank_account"; | ||
| readonly description: "TDBank 账号操作:获取当前账号、账号列表、切换账号、快速借用并切换账号"; | ||
| readonly description: "TDBank 账号操作:获取扫码登录二维码、当前账号、账号列表、切换账号、快速借用并切换账号"; | ||
| readonly params: [{ | ||
| readonly name: "tabId"; | ||
| readonly type: "number"; | ||
| readonly description: "CDP 模式下可指定用于读取 Cookie 的标签页 ID"; | ||
| readonly description: "login 后续查询或选身份时复用首次返回的标签页 ID;其他操作在 CDP 模式下用于读取 Cookie"; | ||
| }, { | ||
| readonly name: "operation"; | ||
| readonly type: "\"current\" | \"list\" | \"switch\" | \"borrow\""; | ||
| readonly description: "操作类型,默认 list"; | ||
| readonly type: "\"current\" | \"list\" | \"login\" | \"switch\" | \"borrow\""; | ||
| readonly description: "操作类型,默认 current"; | ||
| }, { | ||
@@ -364,13 +364,21 @@ readonly name: "refresh"; | ||
| readonly type: "string | number"; | ||
| readonly description: "switch 时也可直接指定 havanaId"; | ||
| readonly description: "switch 时直接指定 havanaId;TDBank 方式需配合 site,免密方式需配合 ssoKey"; | ||
| }, { | ||
| readonly name: "site"; | ||
| readonly type: "string | number"; | ||
| readonly description: "直接指定 havanaId 时必填"; | ||
| readonly description: "TDBank 方式直接指定 havanaId 时必填"; | ||
| }, { | ||
| readonly name: "ssoKey"; | ||
| readonly type: "string"; | ||
| readonly description: "switch 免密方式的秘钥;必须同时传 havanaId,site 固定为 taobao"; | ||
| }, { | ||
| readonly name: "query"; | ||
| readonly type: "string"; | ||
| readonly description: "borrow 时输入要借用的账号 loginId/关键词"; | ||
| }, { | ||
| readonly name: "identityId"; | ||
| readonly type: "string | number"; | ||
| readonly description: "login 返回 identity_required 后,传用户明确选择的 identityId"; | ||
| }]; | ||
| readonly examples: ["tdbank_account --payload '{\"operation\":\"current\"}'", "tdbank_account --payload '{\"operation\":\"list\",\"refresh\":true}'", "tdbank_account --payload '{\"operation\":\"switch\",\"accountId\":12345}'", "tdbank_account --payload '{\"operation\":\"borrow\",\"query\":\"test_account\"}'"]; | ||
| readonly examples: ["tdbank_account --payload '{\"operation\":\"login\"}'", "tdbank_account --payload '{\"operation\":\"login\",\"tabId\":12345}'", "tdbank_account --payload '{\"operation\":\"login\",\"tabId\":12345,\"identityId\":\"10001\"}'", "tdbank_account --payload '{\"operation\":\"current\"}'", "tdbank_account --payload '{\"operation\":\"list\",\"refresh\":true}'", "tdbank_account --payload '{\"operation\":\"switch\",\"accountId\":12345}'", "tdbank_account --payload '{\"operation\":\"switch\",\"havanaId\":\"1234567890\",\"ssoKey\":\"<secret>\"}'", "tdbank_account --payload '{\"operation\":\"borrow\",\"query\":\"test_account\"}'"]; | ||
| }, { | ||
@@ -377,0 +385,0 @@ readonly name: "browser_list"; |
+24
-6
@@ -239,3 +239,3 @@ import { APP_PROFILE_NAMES, } from './generated-browser-action-protocol.js'; | ||
| name: 'tdbank_account', | ||
| description: 'TDBank 账号操作:获取当前账号、账号列表、切换账号、快速借用并切换账号', | ||
| description: 'TDBank 账号操作:获取扫码登录二维码、当前账号、账号列表、切换账号、快速借用并切换账号', | ||
| params: [ | ||
@@ -245,8 +245,8 @@ { | ||
| type: 'number', | ||
| description: 'CDP 模式下可指定用于读取 Cookie 的标签页 ID', | ||
| description: 'login 后续查询或选身份时复用首次返回的标签页 ID;其他操作在 CDP 模式下用于读取 Cookie', | ||
| }, | ||
| { | ||
| name: 'operation', | ||
| type: '"current" | "list" | "switch" | "borrow"', | ||
| description: '操作类型,默认 list', | ||
| type: '"current" | "list" | "login" | "switch" | "borrow"', | ||
| description: '操作类型,默认 current', | ||
| }, | ||
@@ -256,10 +256,28 @@ { name: 'refresh', type: 'boolean', description: 'list 时是否强制刷新账号列表' }, | ||
| { name: 'accountId', type: 'string | number', description: 'switch 时使用账号列表中的 id' }, | ||
| { name: 'havanaId', type: 'string | number', description: 'switch 时也可直接指定 havanaId' }, | ||
| { name: 'site', type: 'string | number', description: '直接指定 havanaId 时必填' }, | ||
| { | ||
| name: 'havanaId', | ||
| type: 'string | number', | ||
| description: 'switch 时直接指定 havanaId;TDBank 方式需配合 site,免密方式需配合 ssoKey', | ||
| }, | ||
| { name: 'site', type: 'string | number', description: 'TDBank 方式直接指定 havanaId 时必填' }, | ||
| { | ||
| name: 'ssoKey', | ||
| type: 'string', | ||
| description: 'switch 免密方式的秘钥;必须同时传 havanaId,site 固定为 taobao', | ||
| }, | ||
| { name: 'query', type: 'string', description: 'borrow 时输入要借用的账号 loginId/关键词' }, | ||
| { | ||
| name: 'identityId', | ||
| type: 'string | number', | ||
| description: 'login 返回 identity_required 后,传用户明确选择的 identityId', | ||
| }, | ||
| ], | ||
| examples: [ | ||
| `tdbank_account --payload '{"operation":"login"}'`, | ||
| `tdbank_account --payload '{"operation":"login","tabId":12345}'`, | ||
| `tdbank_account --payload '{"operation":"login","tabId":12345,"identityId":"10001"}'`, | ||
| `tdbank_account --payload '{"operation":"current"}'`, | ||
| `tdbank_account --payload '{"operation":"list","refresh":true}'`, | ||
| `tdbank_account --payload '{"operation":"switch","accountId":12345}'`, | ||
| `tdbank_account --payload '{"operation":"switch","havanaId":"1234567890","ssoKey":"<secret>"}'`, | ||
| `tdbank_account --payload '{"operation":"borrow","query":"test_account"}'`, | ||
@@ -266,0 +284,0 @@ ], |
@@ -115,3 +115,3 @@ export interface GetRequestsParams { | ||
| export interface TdbankAccountParams { | ||
| operation?: 'current' | 'list' | 'switch' | 'borrow'; | ||
| operation?: 'current' | 'list' | 'login' | 'switch' | 'borrow'; | ||
| pageIndex?: number; | ||
@@ -123,3 +123,5 @@ refresh?: boolean; | ||
| site?: string | number; | ||
| ssoKey?: string; | ||
| tabId?: number; | ||
| identityId?: string | number; | ||
| } | ||
@@ -126,0 +128,0 @@ export type BrowserStatus = 'connected' | 'running_disconnected' | 'stopped'; |
@@ -26,2 +26,3 @@ import { type CloudConnectorListResult } from '@mearl/cloud-types'; | ||
| export declare function decodeBrowserTarget(selector: string | undefined): BrowserTarget | undefined; | ||
| export declare function normalizeBrowserSelector(selector: string): string; | ||
| export declare class UnifiedClient { | ||
@@ -28,0 +29,0 @@ private readonly options; |
+17
-9
@@ -9,3 +9,3 @@ import WebSocket from 'ws'; | ||
| function encodeBrowserTarget(target) { | ||
| const browser = encodeURIComponent(target.browser); | ||
| const browser = encodeURIComponent(target.browser).replace(/%3A/g, ':'); | ||
| return target.connector | ||
@@ -25,10 +25,14 @@ ? `${GLOBAL_BROWSER_PREFIX}remote:${encodeURIComponent(target.connector)}:${browser}` | ||
| try { | ||
| const parts = selector.slice(GLOBAL_BROWSER_PREFIX.length).split(':'); | ||
| if (parts[0] === 'local' && parts.length === 2) { | ||
| const browser = decodeURIComponent(parts[1]); | ||
| const target = selector.slice(GLOBAL_BROWSER_PREFIX.length); | ||
| if (target.startsWith('local:')) { | ||
| const browser = decodeURIComponent(target.slice('local:'.length)); | ||
| return browser ? { browser } : undefined; | ||
| } | ||
| if (parts[0] === 'remote' && parts.length === 3) { | ||
| const connector = decodeURIComponent(parts[1]); | ||
| const browser = decodeURIComponent(parts[2]); | ||
| if (target.startsWith('remote:')) { | ||
| const remoteTarget = target.slice('remote:'.length); | ||
| const separator = remoteTarget.indexOf(':'); | ||
| if (separator < 0) | ||
| return undefined; | ||
| const connector = decodeURIComponent(remoteTarget.slice(0, separator)); | ||
| const browser = decodeURIComponent(remoteTarget.slice(separator + 1)); | ||
| return connector && browser ? { connector, browser } : undefined; | ||
@@ -42,2 +46,6 @@ } | ||
| } | ||
| export function normalizeBrowserSelector(selector) { | ||
| const decodedTarget = decodeBrowserTarget(selector); | ||
| return (decodedTarget ? encodeBrowserTarget(decodedTarget) : selector.trim()).toLowerCase(); | ||
| } | ||
| function decorateBrowser(browser, source) { | ||
@@ -63,3 +71,3 @@ const safeBrowser = omitTransientBrowserSecrets(browser); | ||
| function browserMatches(browser, selector) { | ||
| const normalized = selector.trim().toLowerCase(); | ||
| const normalized = normalizeBrowserSelector(selector); | ||
| return (browser.browserId.toLowerCase() === normalized || | ||
@@ -77,3 +85,3 @@ browser.originalBrowserId?.toLowerCase() === normalized || | ||
| return exact; | ||
| const normalized = selector.trim().toLowerCase(); | ||
| const normalized = normalizeBrowserSelector(selector); | ||
| return candidates.filter(browser => browser.browserId.toLowerCase().includes(normalized) || | ||
@@ -80,0 +88,0 @@ browser.originalBrowserId?.toLowerCase().includes(normalized) || |
+2
-2
| { | ||
| "name": "@mearl/client", | ||
| "version": "2.9.3", | ||
| "version": "2.9.4", | ||
| "description": "Unified Mearl SDK & CLI for local and remote browsers", | ||
@@ -58,3 +58,3 @@ "type": "module", | ||
| "ws": "^8.18.0", | ||
| "@mearl/cloud-types": "2.9.3" | ||
| "@mearl/cloud-types": "2.9.4" | ||
| }, | ||
@@ -61,0 +61,0 @@ "devDependencies": { |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
264088
0.96%5727
0.67%17
6.25%+ Added
- Removed
Updated