publishport-opencli 1.0.51 → 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/clis/note/auth.js +2 -2
- package/clis/pinterest/auth.js +1 -1
- package/clis/qiita/auth.js +1 -1
- package/clis/rednote/auth.js +1 -1
- package/clis/xueqiu/auth.js +1 -1
- package/package.json +1 -1
package/clis/note/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{AuthRequiredError as
|
|
1
|
+
import{AuthRequiredError as n,CommandExecutionError as o}from"@jackwener/opencli/errors";import{registerSiteAuthCommands as a}from"../_shared/site-auth.js";async function r(e){return(await e.getCookies({url:"https://note.com"})).some((s)=>s.name==="_note_session_v5")}async function i(e){if(!await r(e))throw new n("note.com","note _note_session_v5 cookie missing");await e.goto("https://note.com/");const t=await e.evaluate(`(async () => {
|
|
2
2
|
try {
|
|
3
3
|
const res = await fetch('/api/v2/current_user', { credentials: 'include', headers: { 'Accept': 'application/json' } });
|
|
4
4
|
if (res.status === 401 || res.status === 403) return { kind: 'auth', detail: 'current_user HTTP ' + res.status };
|
|
@@ -9,4 +9,4 @@ import{AuthRequiredError as o,CommandExecutionError as r}from"@jackwener/opencli
|
|
|
9
9
|
if (!d || (d.urlname == null && d.id == null)) return { kind: 'auth', detail: 'current_user returned no user — anonymous' };
|
|
10
10
|
return { ok: true, urlname: String(d.urlname || ''), nickname: String(d.nickname || ''), user_id: String(d.id || '') };
|
|
11
11
|
} catch (e) { return { kind: 'exception', detail: String(e && e.message || e) }; }
|
|
12
|
-
})()`);if(t?.kind==="auth")throw new
|
|
12
|
+
})()`);if(t?.kind==="auth")throw new n("note.com",t.detail);if(t?.kind==="http")throw new o(`HTTP ${t.httpStatus} from current_user`);if(t?.kind==="exception")throw new o(`note whoami failed: ${t.detail}`);if(!t?.ok)throw new o(`Unexpected note probe: ${JSON.stringify(t)}`);return{urlname:t.urlname,nickname:t.nickname,url:t.urlname?`https://note.com/${t.urlname}`:""}}a({site:"note",domain:"note.com",loginUrl:"https://note.com/login",columns:["urlname","nickname","url"],quickCheckRequiresNavigation:!0,quickCheck:r,verify:i,poll:async(e)=>{if(!await r(e))throw new n("note.com","Waiting for note session cookie");return i(e)}});
|
package/clis/pinterest/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AuthRequiredError as
|
|
1
|
+
import{AuthRequiredError as s}from"@jackwener/opencli/errors";import{registerSiteAuthCommands as o}from"../_shared/site-auth.js";import{resolvePinterestUser as w}from"./client.js";async function i(e){return(await e.getCookies({url:"https://www.pinterest.com"})).some((n)=>n.name==="_pinterest_sess")}async function r(e){if(!await i(e))throw new s("www.pinterest.com","Pinterest _pinterest_sess cookie missing");const t=await w(e);return{username:t,url:`https://www.pinterest.com/${t}/`}}o({site:"pinterest",domain:"www.pinterest.com",loginUrl:"https://www.pinterest.com/login/",columns:["username","url"],quickCheckRequiresNavigation:!0,quickCheck:i,verify:r,poll:async(e)=>{if(!await i(e))throw new s("www.pinterest.com","Waiting for Pinterest session cookie");return r(e)}});
|
package/clis/qiita/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AuthRequiredError as
|
|
1
|
+
import{AuthRequiredError as n}from"@jackwener/opencli/errors";import{registerSiteAuthCommands as s}from"../_shared/site-auth.js";import{qiitaViewer as m}from"./gql.js";const e="https://qiita.com";async function a(i){return(await i.getCookies({url:e})).some((t)=>t.name==="_qiita_login_session"&&t.value)}async function r(i){await i.goto(`${e}/`);const o=await m(i);return{url_name:o.urlName,name:o.name||"",user_id:String(o.originalId??"")}}s({site:"qiita",domain:"qiita.com",loginUrl:"https://qiita.com/login",columns:["url_name","name","user_id"],loginDescription:"打开 Qiita 登录页并等待浏览器完成登录(供桌面客户端引导登录)。",quickCheckRequiresNavigation:!0,quickCheck:a,verify:r,poll:async(i)=>{if(!await a(i))throw new n("qiita.com","Waiting for Qiita session cookie");return r(i)}});
|
package/clis/rednote/auth.js
CHANGED
|
@@ -16,4 +16,4 @@ import{AuthRequiredError as o,CommandExecutionError as s}from"@jackwener/opencli
|
|
|
16
16
|
}
|
|
17
17
|
return { ok: true, user_id: userId, nickname };
|
|
18
18
|
})()
|
|
19
|
-
`);if(n?.kind==="auth")throw new o("rednote.com",n.detail);if(!n?.ok)throw new s(`Unexpected Rednote probe: ${JSON.stringify(n)}`);return{user_id:n.user_id,nickname:n.nickname}}u({site:"rednote",domain:"rednote.com",loginUrl:"https://www.rednote.com/explore",columns:["user_id","nickname"],quickCheck:t,verify:r,poll:async(e)=>{if(!await t(e))throw new o("rednote.com","Waiting for Rednote web_session cookie");return r(e)}});
|
|
19
|
+
`);if(n?.kind==="auth")throw new o("rednote.com",n.detail);if(!n?.ok)throw new s(`Unexpected Rednote probe: ${JSON.stringify(n)}`);return{user_id:n.user_id,nickname:n.nickname}}u({site:"rednote",domain:"rednote.com",loginUrl:"https://www.rednote.com/explore",columns:["user_id","nickname"],quickCheckRequiresNavigation:!0,quickCheck:t,verify:r,poll:async(e)=>{if(!await t(e))throw new o("rednote.com","Waiting for Rednote web_session cookie");return r(e)}});
|
package/clis/xueqiu/auth.js
CHANGED
|
@@ -24,4 +24,4 @@ import{AuthRequiredError as t,CommandExecutionError as o}from"@jackwener/opencli
|
|
|
24
24
|
} catch (e) {
|
|
25
25
|
return { kind: 'exception', detail: String(e && e.message || e) };
|
|
26
26
|
}
|
|
27
|
-
})()`);if(e?.kind==="auth")throw new t("xueqiu.com",e.detail);if(e?.kind==="http")throw new o(`HTTP ${e.httpStatus} from xueqiu stock API: ${e.detail||""}`);if(e?.kind==="xq-error")throw new o(`xueqiu API error_code ${e.errorCode}: ${e.detail}`);if(e?.kind==="exception")throw new o(`xueqiu whoami failed: ${e.detail}`);if(!e?.ok)throw new o(`Unexpected xueqiu probe: ${JSON.stringify(e)}`);return{user_id:String(e.user_id)}}s({site:"xueqiu",domain:"xueqiu.com",loginUrl:"https://xueqiu.com/",columns:["user_id"],quickCheck:r,verify:n,poll:async(i)=>{if(!await r(i))throw new t("xueqiu.com","Waiting for Xueqiu xq_a_token cookie");return n(i)}});
|
|
27
|
+
})()`);if(e?.kind==="auth")throw new t("xueqiu.com",e.detail);if(e?.kind==="http")throw new o(`HTTP ${e.httpStatus} from xueqiu stock API: ${e.detail||""}`);if(e?.kind==="xq-error")throw new o(`xueqiu API error_code ${e.errorCode}: ${e.detail}`);if(e?.kind==="exception")throw new o(`xueqiu whoami failed: ${e.detail}`);if(!e?.ok)throw new o(`Unexpected xueqiu probe: ${JSON.stringify(e)}`);return{user_id:String(e.user_id)}}s({site:"xueqiu",domain:"xueqiu.com",loginUrl:"https://xueqiu.com/",columns:["user_id"],quickCheckRequiresNavigation:!0,quickCheck:r,verify:n,poll:async(i)=>{if(!await r(i))throw new t("xueqiu.com","Waiting for Xueqiu xq_a_token cookie");return n(i)}});
|