import{d as o,b as e}from"../../nitro/nitro.mjs";import"node:http";import"node:https";import"node:events";import"node:buffer";import"node:fs";import"node:path";import"node:crypto";import"node:url";const t=o((async o=>{try{const t=e(o),r=t.uuid,n=t.verifier;let s=await checkAuth(r,n),i=0;const c=1e3*Number(t.interval);for(;!(s||(await new Promise((o=>setTimeout(o,c))),s=await checkAuth(r,n),i+=1,i*c>12e4)););if(s)return{token:s};throw new Error("获取超时")}catch(o){throw o}}));async function checkAuth(o,e){console.log(" fetch cursor access tokening");const t=`https://api2.cursor.sh/auth/poll?uuid=${o}&verifier=${e}`,r=await fetch(t,{headers:{origin:"vscode-file://vscode-app","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Cursor/0.4.2 Chrome/108.0.5359.215 Electron/22.3.10 Safari/537.36"}});if(!r.ok)return console.log(`Failed to fetch access token, url:${t}, status:${r.status}`),"";const n=await r.json();return"accessToken"in n?(console.log(n),n.accessToken):(console.log("access_token not in response"),"")}export{t as default}; | |