forked from itxve/aliyundriver-refresh-token
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
313 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.history | ||
node_modules | ||
node_modules | ||
.vercel | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.history | ||
node_modules | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 itxve | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<script type="module" src="./index.ts"></script> | ||
<script> | ||
function copyIt() { | ||
const u = document.querySelector("#user-Info") | ||
u.select() | ||
document.execCommand("copy") | ||
alert("已复制") | ||
} | ||
</script> | ||
|
||
<body> | ||
<div id="app" class="main"> | ||
<img id="qrcode" class="qrcode-img" /> | ||
<div id="expire"> | ||
<p>二维码已失效</p> | ||
<button class="refresh">刷新二维码</button> | ||
</div> | ||
</div> | ||
<div class="main"> | ||
<textarea rows="5" cols="33" id="user-Info"></textarea> | ||
<button class="copy" onclick="copyIt()">copy</button> | ||
</div> | ||
</body> | ||
|
||
<style> | ||
.main { | ||
display: flex; | ||
position: relative; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin-top: 60px; | ||
} | ||
|
||
.qrcode-img { | ||
box-shadow: 0px 0px 1px 1px rgb(28 28 32 / 5%), 0px 8px 24px rgb(28 28 32 / 12%); | ||
border-radius: 10px; | ||
width: 128px; | ||
height: 128px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
button.refresh { | ||
cursor: pointer; | ||
font-size: 12px; | ||
color: #f0f0f0; | ||
background: #637dff; | ||
line-height: 24px; | ||
height: 24px; | ||
width: auto; | ||
padding: 0px 10px; | ||
border-radius: 30px; | ||
border: 0; | ||
} | ||
|
||
#expire { | ||
background: hsla(0, 0%, 100%, .9); | ||
display: none; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
position: absolute; | ||
height: 100%; | ||
top: 0; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
#expire p { | ||
font-size: 14px; | ||
} | ||
|
||
#token { | ||
z-index: 100; | ||
} | ||
|
||
.show { | ||
display: flex !important; | ||
} | ||
|
||
button.copy { | ||
cursor: pointer; | ||
font-size: 12px; | ||
color: #f0f0f0; | ||
background: #2f91dc; | ||
line-height: 24px; | ||
height: 24px; | ||
width: auto; | ||
padding: 0px 10px; | ||
border-radius: 30px; | ||
border: 0; | ||
} | ||
</style> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
let qr: any = ""; | ||
let checkInterval: NodeJS.Timer; | ||
|
||
document.querySelector(".refresh").addEventListener("click", getQrCode); | ||
const userInfoDom = document.querySelector("#user-Info"); | ||
const expireDom = document.querySelector("#expire"); | ||
|
||
export function getQrCode() { | ||
fetch("/api/qrcode-generate?img=true") | ||
.then((res) => res.json()) | ||
.then((res) => { | ||
qr = res; | ||
const qrcode = document.getElementById("qrcode"); | ||
qrcode.setAttribute("src", res.codeContent); | ||
checkInterval = setInterval(checkQrCode, 1000); | ||
}); | ||
} | ||
|
||
export function checkQrCode() { | ||
fetch("/api/qrcode-state-query?ck=" + qr.ck + "&t=" + qr.t) | ||
.then((res) => res.json()) | ||
.then((res) => { | ||
if (["EXPIRED", "CANCELED"].includes(res.data.qrCodeStatus)) { | ||
if (checkInterval) { | ||
clearInterval(checkInterval); | ||
} | ||
expireDom.classList.add("show"); | ||
} else if (["CONFIRMED"].includes(res.data.qrCodeStatus)) { | ||
console.log(res, "CONFIRMED"); | ||
userInfoDom.innerHTML = res.data.bizExt; | ||
} | ||
}); | ||
} | ||
|
||
setTimeout(getQrCode, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## QR Code扫码获取阿里云盘refresh token | ||
|
||
## Vercel 部署 | ||
<a href="https://vercel.com/new/import?s=https://github.com/itxve/aliyundriver-refresh-token"><img src="https://vercel.com/button" height="24"></a> | ||
|
||
|
||
## License | ||
|
||
[The MIT License (MIT)](https://github.com/itxve/aliyundriver-refresh-token/blob/master/LICENSE) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { VercelRequest, VercelResponse } from "@vercel/node"; | ||
import QRCode from "qrcode"; | ||
import https from "https"; | ||
|
||
export default function (req: VercelRequest, res: VercelResponse) { | ||
res.setHeader("Access-Control-Allow-Origin", "*"); | ||
const { img } = req.query; | ||
https | ||
.get( | ||
{ | ||
host: "passport.aliyundrive.com", | ||
path: | ||
"/newlogin/qrcode/generate.do?" + | ||
"appName=aliyun_drive" + | ||
"&fromSite=52" + | ||
"&appName=aliyun_drive" + | ||
"&appEntrance=web" + | ||
"&isMobile=false" + | ||
"&lang=zh_CN" + | ||
"&returnUrl=" + | ||
"&bizParams=" + | ||
"&_bx-v=2.0.31", | ||
timeout: 3000, | ||
}, | ||
(response) => { | ||
let data: any = ""; | ||
response.on("data", (d) => { | ||
data += d; | ||
}); | ||
response.on("end", async () => { | ||
const json = JSON.parse(data); | ||
const result = { | ||
codeContent: json.content.data.codeContent, | ||
ck: json.content.data.ck, | ||
t: json.content.data.t, | ||
}; | ||
if (img) { | ||
const image = await QRCode.toDataURL(result.codeContent); | ||
result.codeContent = image; | ||
res.send(result); | ||
} else { | ||
res.send(result); | ||
} | ||
}); | ||
} | ||
) | ||
.on("error", (e) => { | ||
res.status(500).send(e); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import type { VercelRequest, VercelResponse } from "@vercel/node"; | ||
import https from "https"; | ||
|
||
export default function (req: VercelRequest, res: VercelResponse) { | ||
res.setHeader("Access-Control-Allow-Origin", "*"); | ||
const { ck, t } = req.query; | ||
const params: any = { | ||
t, | ||
ck, | ||
appName: "aliyun_drive", | ||
appEntrance: "web", | ||
isMobile: "false", | ||
lang: "zh_CN", | ||
returnUrl: "", | ||
fromSite: "52", | ||
bizParams: "", | ||
navlanguage: "zh-CN", | ||
navPlatform: "MacIntel", | ||
}; | ||
|
||
let body = ""; | ||
Object.keys(params).forEach((key) => { | ||
body += "&" + key + "=" + params[key]; | ||
}); | ||
|
||
const status: any = { | ||
NEW: "请用阿里云盘 App 扫码", | ||
SCANED: "请在手机上确认", | ||
EXPIRED: "二维码已过期", | ||
CANCELED: "已取消", | ||
CONFIRMED: "已确认", | ||
}; | ||
https | ||
.request( | ||
{ | ||
method: "POST", | ||
host: "passport.aliyundrive.com", | ||
path: | ||
"/newlogin/qrcode/query.do?appName=aliyun_drive&fromSite=52&_bx-v=2.0.31", | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | ||
}, | ||
timeout: 3000, | ||
}, | ||
(response) => { | ||
let data: any = ""; | ||
response.on("data", (d) => { | ||
data += d; | ||
}); | ||
response.on("end", () => { | ||
const rt = JSON.parse(data).content; | ||
if (rt.data.qrCodeStatus === "CONFIRMED") { | ||
rt.data.bizExt = JSON.parse(atob(rt.data.bizExt)); | ||
} else { | ||
//添加 一个tip | ||
rt.data.tip = status[rt.data.qrCodeStatus]; | ||
} | ||
res.send(rt); | ||
}); | ||
} | ||
) | ||
.on("error", (e) => { | ||
res.status(500).send(e); | ||
}) | ||
.end(body); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters