From c93807a2f71c0182c4e27991cc9959400f171a77 Mon Sep 17 00:00:00 2001 From: Johnathan Abts Date: Wed, 3 Jan 2024 17:07:53 +0800 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E5=88=B7=E6=96=B0?= =?UTF-8?q?sess=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get_sess.html | 1 + get_sess2.html | 16 ++- index.html | 1 + refresh_see.html | 201 +++++++++++++++++++++++++++ static/refresh_see.js | 313 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 527 insertions(+), 5 deletions(-) create mode 100644 refresh_see.html create mode 100644 static/refresh_see.js diff --git a/get_sess.html b/get_sess.html index d91d0e4..87c5ad9 100644 --- a/get_sess.html +++ b/get_sess.html @@ -83,6 +83,7 @@ 查API信息 通过access token获取sess 通过PandoraNext获取sess + 刷新Platform相关信息刷新sess 手动获取sess的方法 diff --git a/get_sess2.html b/get_sess2.html index 1aa5238..5dbe40b 100644 --- a/get_sess2.html +++ b/get_sess2.html @@ -11,7 +11,12 @@ - + + + + + + + + + + +
+
+

查询结果

+ + +
+
+ + + + + + + + + + + + + + + +
序号邮箱账户手机号Sensitive IDRefresh TokenAccess TokenSensitive ID创建时间
+
+
+
+ + + + 刷新Platform相关信息刷新sess + + + +
+

输入 API KEY

+

本站不保存 KEY 信息,查询后请自行保存

+ + + + [FakeOpen]ai.fakeopen.com + 自定义,使用PandoraNext的API + + + + [官网线路]api.openai.com + [CZLoapi线路]oapi.czl.net + [群友CF反代]openai.996.lat + CF Gateway + [已前置https]自定义 + + + + + + +
+ + + 查询 + + + +

页面列表

+ + 查API信息 + 通过access token获取sess + 通过PandoraNext获取sess + 刷新Platform相关信息刷新sess + 手动获取sess的方法 + + +
+ + 本网页由woodchen开源于Github + +
+
+
+
+ + + diff --git a/static/refresh_see.js b/static/refresh_see.js new file mode 100644 index 0000000..a6c26c2 --- /dev/null +++ b/static/refresh_see.js @@ -0,0 +1,313 @@ +let serialNumber = 1; + +function toggleCustomUrlInput() { + const refreshTokenApiElement = document.getElementById("refresh-token-api"); + const PandoraNextUrlInput = document.getElementById("PandoraNext-url-input"); + if (refreshTokenApiElement.value === "custom") { + PandoraNextUrlInput.classList.remove("hidden"); + PandoraNextUrlInput.style.display = "inline-block"; + PandoraNextUrlInput.style.marginTop = "5px"; + } else { + PandoraNextUrlInput.classList.add("hidden"); + PandoraNextUrlInput.style.display = "none"; + } + // 获取id为"api-url-select"的元素 + const selectElement = document.getElementById("api-url-select"); + // 获取id为"custom-url-input"的元素 + const customUrlInput = document.getElementById("custom-url-input"); + // 如果selectElement的值为"custom" + if (selectElement.value === "custom") { + // 从customUrlInput的classList中移除"hidden" + customUrlInput.classList.remove("hidden"); + customUrlInput.style.display = "inline-block"; + customUrlInput.style.marginTop = "5px"; + } else { + // 给customUrlInput的classList添加"hidden" + customUrlInput.classList.add("hidden"); + customUrlInput.style.display = "none"; + } +} + +const service = axios.create({ + withCredentials: true, // 跨域请求时发送Cookie + timeout: 60000, // 请求超时 +}); + +function checkBilling(refreshToken, refUrl, apiUrl) { + return new Promise(async (resolve, reject) => { + try { + var urlencoded = new URLSearchParams(); + urlencoded.append("refresh_token", refreshToken); + const response = await service.post(refUrl, urlencoded, { + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + }); + const rdata = response.data; + console.log(`rdata: ${rdata}`); + if (rdata && rdata.access_token && rdata.refresh_token) { + // 查询sess + const get_sess = await service.post( + `${apiUrl}/dashboard/onboarding/login`, + {}, + { + headers: { + Authorization: "Bearer " + rdata.access_token, + "Content-Type": "application/json", + }, + } + ); + const getsessdata = get_sess.data; + console.log(`getsessdata: ${getsessdata}`); + if (getsessdata && getsessdata.user && getsessdata.user.session) { + resolve({token_info: rdata, ...getsessdata}); + } else { + reject({token_info: rdata, ...getsessdata}); + } + } else { + reject(rdata); + } + } catch (error) { + reject(error); + } + }); +} + +//查询函数 +async function sendRequest() { + let apiKeyInput = document.getElementById("api-key-input"); + let refreshTokenApi = document.getElementById("refresh-token-api"); + let PandoraNextUrlInput = document.getElementById("PandoraNext-url-input"); + let apiUrlSelect = document.getElementById("api-url-select"); + let customUrlInput = document.getElementById("custom-url-input"); + + document + .getElementById("result-table") + .getElementsByTagName("tbody")[0].innerHTML = ""; + + let refUrl = refreshTokenApi.value; + let apiUrl = apiUrlSelect.value; + if (refUrl === "custom") { + refUrl = PandoraNextUrlInput.value.trim(); + if (refUrl) { + refUrl += "/api"; + } + } + if (!refUrl) { + mdui.alert({ + headline: "无查询线路", + description: "请选择或自定义配置刷新token线路", + confirmText: "OK", + }); + return; + } + if (!refUrl.startsWith("http://") && !refUrl.startsWith("https://")) { + refUrl = "https://" + refUrl; + } + if (apiUrlSelect.value === "custom") { + apiUrl = customUrlInput.value.trim(); + } + refUrl += "/auth/platform/refresh"; + if (!apiUrl) { + mdui.alert({ + headline: "无查询线路", + description: "请选择或自定义配置查询Sess线路", + confirmText: "OK", + }); + return; + } else { + if (!apiUrl.startsWith("http://") && !apiUrl.startsWith("https://")) { + apiUrl = "https://" + apiUrl; + } + if (!apiUrl.startsWith("https://gateway.ai.cloudflare.com")) { + apiUrl += "/v1"; // 如果不是,则添加路径‘/v1’ + } else { + apiUrl = apiUrl.replace("/v1", ""); // 如果用户选择的选项是https://gateway.ai.cloudflare.com开头,则删除/v1 + } + if (apiUrl && apiUrl.endsWith("/")) { + apiUrl = apiUrl.slice(0, -1); // 去掉末尾的"/" + } + } + + let tokenList = apiKeyInput.value.split(/[,\s,\n]+/); + if (!apiKeyInput.value || tokenList.length === 0) { + mdui.alert({ + headline: "请输入Token", + description: "请检查输入refresh_token", + confirmText: "OK", + }); + return; + } + + showLoadingAnimation(); + + let tableBody = document.querySelector("#result-table tbody"); + + let properties = [ + "email", + "phone_number", + "sensitive_id", + "refresh_token", + "access_token", + "created", + ]; + + for (let i = 0; i < tokenList.length; i++) { + let token = tokenList[i].trim(); + if (token) { + let row = document.createElement("tr"); + let serialNumberCell = document.createElement("td"); + serialNumberCell.textContent = serialNumber; + row.appendChild(serialNumberCell); + try { + let data = await checkBilling(token, refUrl, apiUrl); + let user = data.user; + let session = user.session; + let token_info = data.token_info; + properties.forEach((prop) => { + let cellValue = ""; + let cell = document.createElement("td"); + if (prop === "created") { + cellValue = new Date(session["created"] * 1000).toLocaleString(); + } else if (prop === "sensitive_id") { + cellValue = session[prop]; // 获取 session 对象中的 sensitive_id + cell.onclick = function () { + copyCell(cell, `Sensitive ID复制成功`); + }; + } else if (prop === "refresh_token" || prop === "access_token") { + cellValue = token_info[prop]; + cell.onclick = function () { + copyCell( + cell, + `${ + prop === "refresh_token" ? "Refresh Token" : "Access Token" + }复制成功` + ); + }; + } else { + cellValue = user[prop] ? user[prop] : ""; // 确保在user[prop]为空时,cellValue被赋予空字符串 + } + + cell.textContent = + cellValue && cellValue.length > 50 + ? cellValue.substring(0, 57) + "..." + : cellValue; // 如果长度超过60,显示"..." + cell.innerHTML = `${cell.textContent}`; // 在悬停时显示全部内容 + row.appendChild(cell); + }); + } catch (error) { + let username = document.createElement("td"); + username.textContent = token.replace(/^(.{10}).*(.{8})$/, "$1***$2"); + row.appendChild(username); + let errorMessageCell = document.createElement("td"); + errorMessageCell.colSpan = "8"; + errorMessageCell.classList.add("status-error"); + // 在这里检查错误信息是否为 "error request login url" + if (error === "error request login url") { + errorMessageCell.textContent = "请求错误,请稍后重试"; + } else { + errorMessageCell.textContent = + error && error.detail ? error.detail : error; + } + row.appendChild(errorMessageCell); + } + + tableBody.appendChild(row); + serialNumber++; + } + } + hideLoadingAnimation(); +} + +function copyCell(cell, message) { + // 创建一个新的textarea元素 + var textarea = document.createElement("textarea"); + // 设置textarea的值为单元格的文本内容 + textarea.value = cell.innerText; + // 将textarea元素添加到body中 + document.body.appendChild(textarea); + // 选择textarea的文本内容 + textarea.select(); + // 执行复制命令 + document.execCommand("copy"); + // 移除textarea元素 + document.body.removeChild(textarea); + mdui.alert({ + headline: "提示", + description: message, + confirmText: "OK", + }); +} + +function copyTable() { + // 这个函数可以保留,以便你仍然可以复制整个表格内容 + var tableBody = document.getElementById("result-tbody"); + var textarea = document.createElement("textarea"); + textarea.value = tableBody.innerText; + document.body.appendChild(textarea); + textarea.select(); + document.execCommand("copy"); + document.body.removeChild(textarea); + mdui.alert({ + headline: "提示", + description: "复制成功", + confirmText: "OK", + }); +} + +function copySess() { + var sensitiveCells = document.querySelectorAll("tbody td:nth-child(4) span"); // 选择所有的Sensitive ID单元格 + var sensitiveIds = Array.from(sensitiveCells).map((cell) => cell.title); // 从单元格中获取所有的Sensitive ID + var textarea = document.createElement("textarea"); + textarea.value = sensitiveIds.join("\n"); // 用换行符连接所有的Sensitive ID + document.body.appendChild(textarea); + textarea.select(); + document.execCommand("copy"); + document.body.removeChild(textarea); + mdui.alert({ + headline: "提示", + description: "Sensitive ID复制成功", + confirmText: "OK", + }); +} + +function showLoadingAnimation() { + const button = document.getElementById("query-button"); + + // 创建一个新的 元素 + const progressElement = document.createElement("mdui-linear-progress"); + progressElement.id = "query-progress"; + + // 将新元素替代原始按钮元素 + button.parentElement.replaceChild(progressElement, button); +} + +function hideLoadingAnimation() { + const progressElement = document.querySelector("mdui-linear-progress"); + + if (progressElement) { + const button = document.createElement("mdui-button"); + button.id = "query-button"; + button.innerHTML = "查询"; + button.setAttribute("full-width", ""); + button.setAttribute("icon", "search"); + button.setAttribute("onclick", "sendRequest()"); + + // 将原始按钮元素替代回来 + progressElement.parentElement.replaceChild(button, progressElement); + } +} + +const navigationDrawer = document.querySelector(".left-drawer"); +const toggleButton = document.getElementById("toggle-button"); + +let isOpen = true; + +toggleButton.addEventListener("click", () => { + isOpen = !isOpen; + if (isOpen) { + navigationDrawer.open = true; + } else { + navigationDrawer.open = false; + } +}); From 4c65ee7a71836d32bf5a344fc5d40e1887b389a7 Mon Sep 17 00:00:00 2001 From: wood chen <95951386+woodchen-ink@users.noreply.github.com> Date: Wed, 3 Jan 2024 22:56:14 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 063e12e55a970ff121ce7f9602bf1ac1a014fddb Mon Sep 17 00:00:00 2001 From: Johnathan Abts Date: Thu, 4 Jan 2024 11:09:24 +0800 Subject: [PATCH 3/9] =?UTF-8?q?fix:=20=E5=B0=86=E5=88=B7=E6=96=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=90=88=E5=B9=B6=E6=88=90=E4=B8=80=E4=B8=AA=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E8=AF=B7=E6=B1=82=EF=BC=8C=E6=BD=98=E5=A4=9A=E6=8B=89?= =?UTF-8?q?=E8=87=AA=E5=B8=A6platform=E7=9A=84api=EF=BC=8C=E6=97=A0?= =?UTF-8?q?=E9=9C=80=E5=8D=95=E7=8B=AC=E5=86=8D=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- refresh_see.html | 52 ++++------------------- static/refresh_see.js | 96 ++++++++++++++----------------------------- 2 files changed, 40 insertions(+), 108 deletions(-) diff --git a/refresh_see.html b/refresh_see.html index fc78d78..2a76584 100644 --- a/refresh_see.html +++ b/refresh_see.html @@ -11,7 +11,6 @@ -