publishport-opencli 1.0.49 → 1.0.50
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/douyin/auth.js +1 -1
- package/clis/github/auth.js +2 -2
- package/package.json +1 -1
package/clis/douyin/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AuthRequiredError as s,CommandExecutionError as
|
|
1
|
+
import{AuthRequiredError as s,CommandExecutionError as u}from"@jackwener/opencli/errors";import{registerSiteAuthCommands as a}from"../_shared/site-auth.js";import{browserFetch as c}from"./_shared/browser-fetch.js";async function n(i){const e=await i.getCookies({url:"https://creator.douyin.com"}),r=new Set(e.filter((o)=>o.value).map((o)=>o.name));return r.has("sessionid")||r.has("uid_tt")}async function t(i){await i.goto("https://creator.douyin.com");const r=await c(i,"GET","https://creator.douyin.com/web/api/media/user/info/?aid=1128"),o=r.user_info??r.user;if(!o)throw new u("Douyin user info response is missing user_info");return{id:o.uid??"",username:o.nickname??"",followers:o.follower_count??0}}a({site:"douyin",domain:"creator.douyin.com",loginUrl:"https://creator.douyin.com/",columns:["id","username","followers"],quickCheck:n,verify:t,poll:async(i)=>{if(!await n(i))throw new s("creator.douyin.com","Waiting for Douyin creator session cookies");return t(i)}});
|
package/clis/github/auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{AuthRequiredError as
|
|
1
|
+
import{AuthRequiredError as i}from"@jackwener/opencli/errors";import{registerSiteAuthCommands as u}from"../_shared/site-auth.js";async function a(e){const t=await e.getCookies({url:"https://github.com"}),n=new Set(t.filter((o)=>o.value).map((o)=>o.name)),s=t.find((o)=>o.name==="logged_in")?.value;return n.has("user_session")||n.has("dotcom_user")||s==="yes"}async function r(e){await e.goto("https://github.com/settings/profile");await e.wait(1);const t=await e.evaluate(`() => {
|
|
2
2
|
const meta = (name) => document.querySelector('meta[name="' + name + '"]')?.getAttribute('content') || '';
|
|
3
3
|
const username = meta('octolytics-actor-login');
|
|
4
4
|
const id = meta('octolytics-actor-id');
|
|
5
5
|
const name = document.querySelector('input#user_profile_name')?.value || '';
|
|
6
6
|
return { username, id, name, url: location.href };
|
|
7
|
-
}`);if(!
|
|
7
|
+
}`);if(!t?.username||/\/login(?:\?|$)/.test(String(t?.url??"")))throw new i("github.com","Could not detect a logged-in GitHub account");return{id:t.id||"",username:t.username,name:t.name||"",url:`https://github.com/${t.username}`}}u({site:"github",domain:"github.com",loginUrl:"https://github.com/login",columns:["id","username","name","url"],quickCheck:a,verify:r,poll:async(e)=>{if(!await a(e))throw new i("github.com","Waiting for GitHub session cookies");return r(e)}});
|