add server app
This commit is contained in:
parent
74ae00cc4e
commit
e69a1a49ad
21
.idea/workspace.xml
generated
21
.idea/workspace.xml
generated
@ -6,7 +6,14 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="987ac7e2-ceaa-49a2-b5c9-aed65a7c598d" name="更改" comment="add server app">
|
<list default="true" id="987ac7e2-ceaa-49a2-b5c9-aed65a7c598d" name="更改" comment="add server app">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/public/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/public/index.html" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/115ui.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/115ui.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/123ui.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/123ui.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/aliui.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/aliui.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/baidu.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/baidu.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/goapi.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/goapi.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/oneui.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/oneui.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/wrangler.jsonc.example" beforeDir="false" afterPath="$PROJECT_DIR$/wrangler.jsonc.example" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -77,7 +84,7 @@
|
|||||||
<updated>1749696640494</updated>
|
<updated>1749696640494</updated>
|
||||||
<workItem from="1749696641557" duration="119000" />
|
<workItem from="1749696641557" duration="119000" />
|
||||||
<workItem from="1749696773818" duration="18000" />
|
<workItem from="1749696773818" duration="18000" />
|
||||||
<workItem from="1749696801474" duration="54365000" />
|
<workItem from="1749696801474" duration="56160000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="fin onedrive official token">
|
<task id="LOCAL-00001" summary="fin onedrive official token">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@ -151,7 +158,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1749817021359</updated>
|
<updated>1749817021359</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="10" />
|
<task id="LOCAL-00010" summary="add server app">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1749817071777</created>
|
||||||
|
<option name="number" value="00010" />
|
||||||
|
<option name="presentableId" value="LOCAL-00010" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1749817071777</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="11" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
@ -172,13 +172,13 @@
|
|||||||
|
|
||||||
// 获取登录秘钥 #######################################################
|
// 获取登录秘钥 #######################################################
|
||||||
async function getLogin() {
|
async function getLogin() {
|
||||||
let server_use = document.getElementById("server_use").value;
|
let server_use = document.getElementById("server_use").checked;
|
||||||
let apps_uuid = document.getElementById("client-id").value;
|
let apps_uuid = document.getElementById("client-id").value;
|
||||||
let apps_keys = document.getElementById("app-secret").value;
|
let apps_keys = document.getElementById("app-secret").value;
|
||||||
let apps_type = document.getElementById("site-select").value;
|
let apps_type = document.getElementById("site-select").value;
|
||||||
let secret_key = document.getElementById("secret-key").value;
|
let secret_key = document.getElementById("secret-key").value;
|
||||||
console.log(server_use);
|
console.log( server_use);
|
||||||
if (server_use === "off" && (apps_uuid === "" || apps_keys === "")) {
|
if (!server_use && (apps_uuid === "" || apps_keys === "")) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
position: 'top',
|
position: 'top',
|
||||||
icon: 'info',
|
icon: 'info',
|
||||||
|
26
src/115ui.ts
26
src/115ui.ts
@ -14,12 +14,13 @@ export async function oneLogin(c: Context) {
|
|||||||
const client_key: string = <string>c.req.query('client_key');
|
const client_key: string = <string>c.req.query('client_key');
|
||||||
const driver_txt: string = <string>c.req.query('apps_types');
|
const driver_txt: string = <string>c.req.query('apps_types');
|
||||||
const server_use: string = <string>c.req.query('server_use');
|
const server_use: string = <string>c.req.query('server_use');
|
||||||
if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
|
if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
|
||||||
return c.json({text: "参数缺少"}, 500);
|
return c.json({text: "参数缺少"}, 500);
|
||||||
const random_key = getRandomString(64);
|
const random_key = getRandomString(64);
|
||||||
|
console.log(server_use);
|
||||||
// 请求参数 ==========================================================================
|
// 请求参数 ==========================================================================
|
||||||
const params_all: Record<string, any> = {
|
const params_all: Record<string, any> = {
|
||||||
client_id: server_use == "on" ? c.env.cloud115_uid : client_uid,
|
client_id: server_use == "true" ? c.env.cloud115_uid : client_uid,
|
||||||
state: random_key,
|
state: random_key,
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/115cloud/callback'
|
redirect_uri: 'https://' + c.env.MAIN_URLS + '/115cloud/callback'
|
||||||
@ -31,7 +32,7 @@ export async function oneLogin(c: Context) {
|
|||||||
// 执行请求 ===========================================================================
|
// 执行请求 ===========================================================================
|
||||||
try {
|
try {
|
||||||
const response = await fetch(urlWithParams.href, {method: 'GET',});
|
const response = await fetch(urlWithParams.href, {method: 'GET',});
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
local.setCookie(c, 'client_uid', client_uid);
|
local.setCookie(c, 'client_uid', client_uid);
|
||||||
local.setCookie(c, 'client_key', client_key);
|
local.setCookie(c, 'client_key', client_key);
|
||||||
}
|
}
|
||||||
@ -55,19 +56,18 @@ export async function oneToken(c: Context) {
|
|||||||
server_use = local.getCookie(c, 'server_use')
|
server_use = local.getCookie(c, 'server_use')
|
||||||
random_key = local.getCookie(c, 'random_key')
|
random_key = local.getCookie(c, 'random_key')
|
||||||
driver_txt = local.getCookie(c, 'driver_txt')
|
driver_txt = local.getCookie(c, 'driver_txt')
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
client_uid = local.getCookie(c, 'client_uid')
|
client_uid = local.getCookie(c, 'client_uid')
|
||||||
client_key = local.getCookie(c, 'client_key')
|
client_key = local.getCookie(c, 'client_key')
|
||||||
|
if (!random_uid || !random_key || random_uid !== random_key
|
||||||
|
|| !driver_txt || !login_data || !client_uid || !client_key)
|
||||||
|
return c.redirect(showErr("Cookie无效", "", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!random_uid || !random_key || random_uid !== random_key
|
|
||||||
|| !driver_txt || !login_data || !client_uid || !client_key)
|
|
||||||
return c.redirect(showErr("Cookie无效", "", ""));
|
|
||||||
client_url = driver_map[1];
|
client_url = driver_map[1];
|
||||||
params_all = {
|
params_all = {
|
||||||
client_id: server_use == "on" ? c.env.cloud115_uid : client_uid,
|
client_id: server_use == "true" ? c.env.cloud115_uid : client_uid,
|
||||||
client_secret: server_use == "on" ? c.env.cloud115_uid : client_key,
|
client_secret: server_use == "true" ? c.env.cloud115_key : client_key,
|
||||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/115cloud/callback',
|
redirect_uri: 'https://' + c.env.MAIN_URLS + '/115cloud/callback',
|
||||||
code: login_data,
|
code: login_data,
|
||||||
grant_type: 'authorization_code'
|
grant_type: 'authorization_code'
|
||||||
@ -86,7 +86,7 @@ export async function oneToken(c: Context) {
|
|||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
local.deleteCookie(c, 'client_uid');
|
local.deleteCookie(c, 'client_uid');
|
||||||
local.deleteCookie(c, 'client_key');
|
local.deleteCookie(c, 'client_key');
|
||||||
}
|
}
|
||||||
@ -98,8 +98,8 @@ export async function oneToken(c: Context) {
|
|||||||
return c.redirect(
|
return c.redirect(
|
||||||
`/?access_token=${json.data.access_token}`
|
`/?access_token=${json.data.access_token}`
|
||||||
+ `&refresh_token=${json.data.refresh_token}`
|
+ `&refresh_token=${json.data.refresh_token}`
|
||||||
+ `&client_uid=${server_use == "on" ? "" : client_uid}`
|
+ `&client_uid=${server_use == "true" ? "" : client_uid}`
|
||||||
+ `&client_key=${server_use == "on" ? "" : client_key}`
|
+ `&client_key=${server_use == "true" ? "" : client_key}`
|
||||||
+ `&driver_txt=${driver_txt}`
|
+ `&driver_txt=${driver_txt}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export async function oneLogin(c: Context) {
|
|||||||
const driver_txt: string = <string>c.req.query('apps_types');
|
const driver_txt: string = <string>c.req.query('apps_types');
|
||||||
const server_use: string = <string>c.req.query('server_use');
|
const server_use: string = <string>c.req.query('server_use');
|
||||||
console.log(server_use);
|
console.log(server_use);
|
||||||
if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
|
if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
|
||||||
return c.json({text: "参数缺少"}, 500);
|
return c.json({text: "参数缺少"}, 500);
|
||||||
// 请求参数 ==========================================================================
|
// 请求参数 ==========================================================================
|
||||||
const params_all: Record<string, any> = {
|
const params_all: Record<string, any> = {
|
||||||
|
10
src/aliui.ts
10
src/aliui.ts
@ -34,11 +34,11 @@ export async function alyLogin(c: Context) {
|
|||||||
const client_key: string = <string>c.req.query('client_key');
|
const client_key: string = <string>c.req.query('client_key');
|
||||||
const driver_txt: string = <string>c.req.query('apps_types');
|
const driver_txt: string = <string>c.req.query('apps_types');
|
||||||
const server_use: string = <string>c.req.query('server_use');
|
const server_use: string = <string>c.req.query('server_use');
|
||||||
if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
|
if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
|
||||||
return c.json({text: "参数缺少"}, 500);
|
return c.json({text: "参数缺少"}, 500);
|
||||||
const req: AliQrcodeReq = {
|
const req: AliQrcodeReq = {
|
||||||
client_id: server_use == "on" ? c.env.alicloud_uid : client_uid,
|
client_id: server_use == "true" ? c.env.alicloud_uid : client_uid,
|
||||||
client_secret: server_use == "on" ? c.env.alicloud_key : client_key,
|
client_secret: server_use == "true" ? c.env.alicloud_key : client_key,
|
||||||
scopes: ['user:base', 'file:all:read', 'file:all:write']
|
scopes: ['user:base', 'file:all:read', 'file:all:write']
|
||||||
}
|
}
|
||||||
const response = await fetch(driver_map[0], {
|
const response = await fetch(driver_map[0], {
|
||||||
@ -68,8 +68,8 @@ export async function alyLogin(c: Context) {
|
|||||||
export async function alyToken(c: Context) {
|
export async function alyToken(c: Context) {
|
||||||
let server_use: string = <string>local.getCookie(c, 'server_use')
|
let server_use: string = <string>local.getCookie(c, 'server_use')
|
||||||
const req: AliAccessTokenReq = {
|
const req: AliAccessTokenReq = {
|
||||||
client_id: server_use == "on" ? c.env.alicloud_uid : <string>c.req.query('client_id'),
|
client_id: server_use == "true" ? c.env.alicloud_uid : <string>c.req.query('client_id'),
|
||||||
client_secret: server_use == "on" ? c.env.alicloud_key : <string>c.req.query('client_secret'),
|
client_secret: server_use == "true" ? c.env.alicloud_key : <string>c.req.query('client_secret'),
|
||||||
grant_type: <string>c.req.query('grant_type'),
|
grant_type: <string>c.req.query('grant_type'),
|
||||||
code: <string>c.req.query('code'),
|
code: <string>c.req.query('code'),
|
||||||
refresh_token: <string>c.req.query('refresh_token')
|
refresh_token: <string>c.req.query('refresh_token')
|
||||||
|
27
src/baidu.ts
27
src/baidu.ts
@ -15,12 +15,12 @@ export async function oneLogin(c: Context) {
|
|||||||
const secret_key: string = <string>c.req.query('secret_key');
|
const secret_key: string = <string>c.req.query('secret_key');
|
||||||
const driver_txt: string = <string>c.req.query('apps_types');
|
const driver_txt: string = <string>c.req.query('apps_types');
|
||||||
const server_use: string = <string>c.req.query('server_use');
|
const server_use: string = <string>c.req.query('server_use');
|
||||||
if (server_use == "off" && (!driver_txt || !client_uid || !client_key || !secret_key))
|
if (server_use == "false" && (!driver_txt || !client_uid || !client_key || !secret_key))
|
||||||
return c.json({text: "参数缺少"}, 500);
|
return c.json({text: "参数缺少"}, 500);
|
||||||
// 请求参数 ==========================================================================
|
// 请求参数 ==========================================================================
|
||||||
const params_all: Record<string, any> = {
|
const params_all: Record<string, any> = {
|
||||||
client_id: server_use == "on" ? c.env.baiduyun_key : client_key,
|
client_id: server_use == "true" ? c.env.baiduyun_key : client_key,
|
||||||
device_id: server_use == "on" ? c.env.baiduyun_uid : client_uid,
|
device_id: server_use == "true" ? c.env.baiduyun_uid : client_uid,
|
||||||
scope: "basic,netdisk",
|
scope: "basic,netdisk",
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/baiduyun/callback'
|
redirect_uri: 'https://' + c.env.MAIN_URLS + '/baiduyun/callback'
|
||||||
@ -34,7 +34,7 @@ export async function oneLogin(c: Context) {
|
|||||||
const response = await fetch(urlWithParams.href, {
|
const response = await fetch(urlWithParams.href, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
local.setCookie(c, 'client_uid', client_uid);
|
local.setCookie(c, 'client_uid', client_uid);
|
||||||
local.setCookie(c, 'client_key', client_key);
|
local.setCookie(c, 'client_key', client_key);
|
||||||
local.setCookie(c, 'secret_key', secret_key);
|
local.setCookie(c, 'secret_key', secret_key);
|
||||||
@ -57,17 +57,18 @@ export async function oneToken(c: Context) {
|
|||||||
server_use = local.getCookie(c, 'server_use')
|
server_use = local.getCookie(c, 'server_use')
|
||||||
driver_txt = local.getCookie(c, 'driver_txt')
|
driver_txt = local.getCookie(c, 'driver_txt')
|
||||||
client_uid = client_key = secret_key = ""
|
client_uid = client_key = secret_key = ""
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
client_uid = local.getCookie(c, 'client_uid')
|
client_uid = local.getCookie(c, 'client_uid')
|
||||||
client_key = local.getCookie(c, 'client_key')
|
client_key = local.getCookie(c, 'client_key')
|
||||||
secret_key = local.getCookie(c, 'secret_key')
|
secret_key = local.getCookie(c, 'secret_key')
|
||||||
|
if (!login_data || !client_uid || !client_key || !secret_key)
|
||||||
|
return c.redirect(showErr("Cookie缺少", "", ""));
|
||||||
}
|
}
|
||||||
if (!login_data || !client_uid || !client_key || !secret_key)
|
|
||||||
return c.redirect(showErr("Cookie缺少", "", ""));
|
|
||||||
client_url = driver_map[1];
|
client_url = driver_map[1];
|
||||||
params_all = {
|
params_all = {
|
||||||
client_id: server_use == "on" ? c.env.baiduyun_key : client_key,
|
client_id: server_use == "true" ? c.env.baiduyun_key : client_key,
|
||||||
client_secret: server_use == "on" ? c.env.baiduyun_ext : secret_key,
|
client_secret: server_use == "true" ? c.env.baiduyun_ext : secret_key,
|
||||||
code: login_data,
|
code: login_data,
|
||||||
grant_type: 'authorization_code',
|
grant_type: 'authorization_code',
|
||||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/baiduyun/callback'
|
redirect_uri: 'https://' + c.env.MAIN_URLS + '/baiduyun/callback'
|
||||||
@ -85,7 +86,7 @@ export async function oneToken(c: Context) {
|
|||||||
urlWithParams.searchParams.append(key, params_all[key]);
|
urlWithParams.searchParams.append(key, params_all[key]);
|
||||||
});
|
});
|
||||||
const response: Response = await fetch(urlWithParams, {method: 'GET'});
|
const response: Response = await fetch(urlWithParams, {method: 'GET'});
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
local.deleteCookie(c, 'client_uid');
|
local.deleteCookie(c, 'client_uid');
|
||||||
local.deleteCookie(c, 'client_key');
|
local.deleteCookie(c, 'client_key');
|
||||||
local.deleteCookie(c, 'secret_key');
|
local.deleteCookie(c, 'secret_key');
|
||||||
@ -93,14 +94,14 @@ export async function oneToken(c: Context) {
|
|||||||
local.deleteCookie(c, 'driver_txt');
|
local.deleteCookie(c, 'driver_txt');
|
||||||
local.deleteCookie(c, 'server_use');
|
local.deleteCookie(c, 'server_use');
|
||||||
const json: Record<string, any> = await response.json();
|
const json: Record<string, any> = await response.json();
|
||||||
// console.log(response, json);
|
console.log(response, json);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return c.redirect(
|
return c.redirect(
|
||||||
`/?access_token=${json.access_token}`
|
`/?access_token=${json.access_token}`
|
||||||
+ `&refresh_token=${json.refresh_token}`
|
+ `&refresh_token=${json.refresh_token}`
|
||||||
+ `&client_uid=${client_uid}`
|
+ `&client_uid=${client_uid}`
|
||||||
+ `&client_key=${server_use == "on" ? "" : client_key}`
|
+ `&client_key=${server_use == "true" ? "" : client_key}`
|
||||||
+ `&secret_key=${server_use == "on" ? "" : secret_key}`
|
+ `&secret_key=${server_use == "true" ? "" : secret_key}`
|
||||||
+ `&driver_txt=${driver_txt}`
|
+ `&driver_txt=${driver_txt}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
23
src/goapi.ts
23
src/goapi.ts
@ -14,12 +14,12 @@ export async function oneLogin(c: Context) {
|
|||||||
const client_key: string = <string>c.req.query('client_key');
|
const client_key: string = <string>c.req.query('client_key');
|
||||||
const driver_txt: string = <string>c.req.query('apps_types');
|
const driver_txt: string = <string>c.req.query('apps_types');
|
||||||
const server_use: string = <string>c.req.query('server_use');
|
const server_use: string = <string>c.req.query('server_use');
|
||||||
if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
|
if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
|
||||||
return c.json({text: "参数缺少"}, 500);
|
return c.json({text: "参数缺少"}, 500);
|
||||||
const random_key = getRandomString(32);
|
const random_key = getRandomString(32);
|
||||||
// 请求参数 ==========================================================================
|
// 请求参数 ==========================================================================
|
||||||
const params_all: Record<string, any> = {
|
const params_all: Record<string, any> = {
|
||||||
'client_id': server_use == "on" ? c.env.onedrive_uid : client_uid,
|
'client_id': server_use == "true" ? c.env.googleui_uid : client_uid,
|
||||||
'redirect_uri': 'https://' + c.env.MAIN_URLS + '/googleui/callback',
|
'redirect_uri': 'https://' + c.env.MAIN_URLS + '/googleui/callback',
|
||||||
'scope': "https://www.googleapis.com/auth/drive",
|
'scope': "https://www.googleapis.com/auth/drive",
|
||||||
'response_type': 'code',
|
'response_type': 'code',
|
||||||
@ -27,7 +27,7 @@ export async function oneLogin(c: Context) {
|
|||||||
'access_type': 'offline',
|
'access_type': 'offline',
|
||||||
'prompt': 'consent'
|
'prompt': 'consent'
|
||||||
};
|
};
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
local.setCookie(c, 'client_uid', client_uid);
|
local.setCookie(c, 'client_uid', client_uid);
|
||||||
local.setCookie(c, 'client_key', client_key);
|
local.setCookie(c, 'client_key', client_key);
|
||||||
}
|
}
|
||||||
@ -56,18 +56,19 @@ export async function oneToken(c: Context) {
|
|||||||
server_use = local.getCookie(c, 'server_use')
|
server_use = local.getCookie(c, 'server_use')
|
||||||
driver_txt = <string>local.getCookie(c, 'driver_txt')
|
driver_txt = <string>local.getCookie(c, 'driver_txt')
|
||||||
client_uid = client_key = ""
|
client_uid = client_key = ""
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
client_uid = <string>local.getCookie(c, 'client_uid')
|
client_uid = <string>local.getCookie(c, 'client_uid')
|
||||||
client_key = <string>local.getCookie(c, 'client_key')
|
client_key = <string>local.getCookie(c, 'client_key')
|
||||||
|
if (!client_uid || !client_key || random_uid !== random_key || !client_uid || !client_key)
|
||||||
|
return c.redirect(showErr("Cookie无效", "", ""));
|
||||||
}
|
}
|
||||||
random_key = <string>local.getCookie(c, 'random_key')
|
random_key = <string>local.getCookie(c, 'random_key')
|
||||||
driver_txt = local.getCookie(c, 'driver_txt')
|
driver_txt = local.getCookie(c, 'driver_txt')
|
||||||
// console.log(login_data, random_uid, client_uid, client_key, random_key, driver_txt)
|
// console.log(login_data, random_uid, client_uid, client_key, random_key, driver_txt)
|
||||||
if (!client_uid || !client_key || random_uid !== random_key || !client_uid || !client_key)
|
|
||||||
return c.redirect(showErr("Cookie无效", "", ""));
|
|
||||||
params_all = {
|
params_all = {
|
||||||
'client_id': server_use == "on" ? c.env.googleui_uid : client_uid,
|
'client_id': server_use == "true" ? c.env.googleui_uid : client_uid,
|
||||||
'client_secret': server_use == "on" ? c.env.googleui_key : client_key,
|
'client_secret': server_use == "true" ? c.env.googleui_key : client_key,
|
||||||
'code': login_data,
|
'code': login_data,
|
||||||
'grant_type': 'authorization_code',
|
'grant_type': 'authorization_code',
|
||||||
'redirect_uri': 'https://' + c.env.MAIN_URLS + '/googleui/callback',
|
'redirect_uri': 'https://' + c.env.MAIN_URLS + '/googleui/callback',
|
||||||
@ -83,7 +84,7 @@ export async function oneToken(c: Context) {
|
|||||||
method: 'POST', body: paramsString,
|
method: 'POST', body: paramsString,
|
||||||
headers: {'Content-Type': 'application/x-www-form-urlencoded',},
|
headers: {'Content-Type': 'application/x-www-form-urlencoded',},
|
||||||
});
|
});
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
local.deleteCookie(c, 'client_uid');
|
local.deleteCookie(c, 'client_uid');
|
||||||
local.deleteCookie(c, 'client_key');
|
local.deleteCookie(c, 'client_key');
|
||||||
}
|
}
|
||||||
@ -96,8 +97,8 @@ export async function oneToken(c: Context) {
|
|||||||
return c.redirect(
|
return c.redirect(
|
||||||
`/?access_token=${json.access_token}`
|
`/?access_token=${json.access_token}`
|
||||||
+ `&refresh_token=${json.refresh_token}`
|
+ `&refresh_token=${json.refresh_token}`
|
||||||
+ `&client_uid=${server_use == "on" ? "" : client_uid}`
|
+ `&client_uid=${server_use == "true" ? "" : client_uid}`
|
||||||
+ `&client_key=${server_use == "on" ? "" : client_key}`
|
+ `&client_key=${server_use == "true" ? "" : client_key}`
|
||||||
+ `&driver_txt=${driver_txt}`
|
+ `&driver_txt=${driver_txt}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
18
src/oneui.ts
18
src/oneui.ts
@ -28,13 +28,13 @@ export async function oneLogin(c: Context) {
|
|||||||
const client_key: string = <string>c.req.query('client_key');
|
const client_key: string = <string>c.req.query('client_key');
|
||||||
const driver_txt: string = <string>c.req.query('apps_types');
|
const driver_txt: string = <string>c.req.query('apps_types');
|
||||||
const server_use: string = <string>c.req.query('server_use');
|
const server_use: string = <string>c.req.query('server_use');
|
||||||
if (server_use == "off" && (!driver_txt || !client_uid || !client_key))
|
if (server_use == "false" && (!driver_txt || !client_uid || !client_key))
|
||||||
return c.json({text: "参数缺少"}, 500);
|
return c.json({text: "参数缺少"}, 500);
|
||||||
const scopes_all = 'offline_access Files.ReadWrite.All';
|
const scopes_all = 'offline_access Files.ReadWrite.All';
|
||||||
const client_url: string = driver_map[driver_txt][0];
|
const client_url: string = driver_map[driver_txt][0];
|
||||||
// 请求参数 ==========================================================================
|
// 请求参数 ==========================================================================
|
||||||
const params_all: Record<string, any> = {
|
const params_all: Record<string, any> = {
|
||||||
client_id: server_use == "on" ? c.env.onedrive_uid : client_uid,
|
client_id: server_use == "true" ? c.env.onedrive_uid : client_uid,
|
||||||
scope: scopes_all,
|
scope: scopes_all,
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback'
|
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback'
|
||||||
@ -48,7 +48,7 @@ export async function oneLogin(c: Context) {
|
|||||||
const response = await fetch(urlWithParams.href, {
|
const response = await fetch(urlWithParams.href, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
local.setCookie(c, 'client_uid', client_uid);
|
local.setCookie(c, 'client_uid', client_uid);
|
||||||
local.setCookie(c, 'client_key', client_key);
|
local.setCookie(c, 'client_key', client_key);
|
||||||
}
|
}
|
||||||
@ -68,14 +68,14 @@ export async function oneToken(c: Context) {
|
|||||||
server_use = local.getCookie(c, 'server_use')
|
server_use = local.getCookie(c, 'server_use')
|
||||||
driver_txt = <string>local.getCookie(c, 'driver_txt')
|
driver_txt = <string>local.getCookie(c, 'driver_txt')
|
||||||
client_uid = client_key = ""
|
client_uid = client_key = ""
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
client_uid = <string>local.getCookie(c, 'client_uid')
|
client_uid = <string>local.getCookie(c, 'client_uid')
|
||||||
client_key = <string>local.getCookie(c, 'client_key')
|
client_key = <string>local.getCookie(c, 'client_key')
|
||||||
}
|
}
|
||||||
client_url = driver_map[driver_txt][1];
|
client_url = driver_map[driver_txt][1];
|
||||||
params_all = {
|
params_all = {
|
||||||
client_id: server_use == "on" ? c.env.onedrive_uid : client_uid,
|
client_id: server_use == "true" ? c.env.onedrive_uid : client_uid,
|
||||||
client_secret: server_use == "on" ? c.env.onedrive_key : client_key,
|
client_secret: server_use == "true" ? c.env.onedrive_key : client_key,
|
||||||
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback',
|
redirect_uri: 'https://' + c.env.MAIN_URLS + '/onedrive/callback',
|
||||||
code: login_data,
|
code: login_data,
|
||||||
grant_type: 'authorization_code'
|
grant_type: 'authorization_code'
|
||||||
@ -96,7 +96,7 @@ export async function oneToken(c: Context) {
|
|||||||
body: paramsString,
|
body: paramsString,
|
||||||
});
|
});
|
||||||
// console.log(response);
|
// console.log(response);
|
||||||
if (server_use !== "on") {
|
if (server_use == "false") {
|
||||||
local.deleteCookie(c, 'client_uid');
|
local.deleteCookie(c, 'client_uid');
|
||||||
local.deleteCookie(c, 'client_key');
|
local.deleteCookie(c, 'client_key');
|
||||||
}
|
}
|
||||||
@ -110,8 +110,8 @@ export async function oneToken(c: Context) {
|
|||||||
return c.redirect(
|
return c.redirect(
|
||||||
`/?access_token=${json.access_token}`
|
`/?access_token=${json.access_token}`
|
||||||
+ `&refresh_token=${json.refresh_token}`
|
+ `&refresh_token=${json.refresh_token}`
|
||||||
+ `&client_uid=${server_use == "on" ? "" : client_uid}`
|
+ `&client_uid=${server_use == "true" ? "" : client_uid}`
|
||||||
+ `&client_key=${server_use == "on" ? "" : client_key}`
|
+ `&client_key=${server_use == "true" ? "" : client_key}`
|
||||||
+ `&driver_txt=${driver_txt}`
|
+ `&driver_txt=${driver_txt}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
"baiduyun_key": "",
|
"baiduyun_key": "",
|
||||||
"115cloud_uid": "",
|
"115cloud_uid": "",
|
||||||
"115cloud_key": "",
|
"115cloud_key": "",
|
||||||
"123cloud_uid": "",
|
|
||||||
"123cloud_key": "",
|
|
||||||
"googleui_uid": "",
|
"googleui_uid": "",
|
||||||
"googleui_key": ""
|
"googleui_key": ""
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user