From da6381d71f08e2d506a0b6b2adb9db11476f6e93 Mon Sep 17 00:00:00 2001 From: wood Date: Fri, 15 Dec 2023 00:38:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E9=97=AE=E9=80=9A=E8=BF=87access=20to?= =?UTF-8?q?ken=E8=8E=B7=E5=8F=96sess]=E5=A4=B1=E6=95=88=E4=BA=86=E4=B9=88?= =?UTF-8?q?=20Fixes=20#32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get_sess.html | 106 +++++++++++++++++++++++ get_sess1.html | 69 --------------- index.html | 69 +++++++-------- static/getsess.js | 212 ++++++++++++++++++++++++++++++++++++++++++++++ static/js.js | 5 +- static/sess1.js | 170 ------------------------------------- 6 files changed, 357 insertions(+), 274 deletions(-) create mode 100644 get_sess.html delete mode 100644 get_sess1.html create mode 100644 static/getsess.js delete mode 100644 static/sess1.js diff --git a/get_sess.html b/get_sess.html new file mode 100644 index 0000000..4411858 --- /dev/null +++ b/get_sess.html @@ -0,0 +1,106 @@ + + + + + + + 通过access_token来获取sess + + + + + + + + + + + +
+

查询结果

+
+ + + + + + + + + + + + + + + + + + + +
序号Access_Tokenuser idemailnamephone number注册时间sess idsess id生成时间org idIP Country
+
+
+
+ + + + 通过access_token来获取sess + + + +
+

输入 API KEY

+

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

+ + + + [官网线路]api.openai.com + [CZLoapi线路]oapi.czl.net + [群友CF反代]openai.996.lat + [已前置https]自定义 + + + + +
+ + + + 查询 + + + + +

页面列表

+ + 查API信息 + 通过access token获取sess + 手动获取sess的方法 + pandora无痛获取access + + +
+ 本网页由woodchen开源于Github + +
+
+
+ + + +
+ + + + + \ No newline at end of file diff --git a/get_sess1.html b/get_sess1.html deleted file mode 100644 index 25dd3cb..0000000 --- a/get_sess1.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - 通过access_token来获取sess - - - - - -
-

通过access token来获取sess

-

页面列表:查API信息     通过access token获取sess

-
- -
-
-

输入 Access Token

-

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

-
-

- -
- -
-

选择查询线路

-

支持自定义线路,官网线路需要魔法

-
- - - - -
- - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/index.html b/index.html index 90fe3fc..c86546e 100644 --- a/index.html +++ b/index.html @@ -14,55 +14,54 @@ - +
-

查询结果

-
- - - - - - - - - - - - - - - - - - - - - -
序号API KEY总额度已使用剩余量已用比例到期时间模型[最高]绑卡绑卡信息组织信息速率[RPM,TPM]有效
+

查询结果

+
+ + + + + + + + + + + + + + + + + + + + + +
序号API KEY总额度已使用剩余量已用比例到期时间模型[最高]绑卡绑卡信息组织信息速率[RPM,TPM-RPD]有效
+
-
- + OpenAI API 信息查询 - +

输入 API KEY

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

- + [官网线路]api.openai.com [CZLoapi线路]oapi.czl.net [群友CF反代]openai.996.lat - [本地] [已前置https]自定义 @@ -84,15 +83,17 @@ 查询 - +

页面列表

- + 查API信息 - 通过access token获取sess + 通过access token获取sess 手动获取sess的方法 + pandora无痛获取access
diff --git a/static/getsess.js b/static/getsess.js new file mode 100644 index 0000000..8947ed1 --- /dev/null +++ b/static/getsess.js @@ -0,0 +1,212 @@ +let queriedApiKeys = []; +let serialNumber = 1; + +function toggleCustomUrlInput() { + // 获取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"); + } else { + // 给customUrlInput的classList添加"hidden" + customUrlInput.classList.add("hidden"); + } +} + +async function checkBilling(apiKey, apiUrl) { + const headers = { + "Authorization": "Bearer " + apiKey, + "Content-Type": "application/json" + }; + const urlGetsess = `${apiUrl}/dashboard/onboarding/login`; + + try { + const response = await fetch(urlGetsess, { + method: "POST", // 设置请求方法为 POST + headers: headers, + body: JSON.stringify({}) // 此处放置要发送的数据 + }); + + const getsessdata = await response.json(); + console.log(getsessdata); + if (getsessdata && getsessdata.user && getsessdata.user.session) { + return getsessdata; // 直接返回整个getsessdata对象 + } else { + console.error("Unexpected data structure: user or session property not found in the response.", getsessdata); + return null; + } + } catch (error) { + console.error(error); + return null; + } +} + +//查询函数 +async function sendRequest() { + let button = document.querySelector("button"); + button.textContent = "加载中..."; + button.disabled = true; + button.classList.add("loading") + + let apiKeyInput = document.getElementById("api-key-input"); + let apiUrlSelect = document.getElementById("api-url-select"); + let customUrlInput = document.getElementById("custom-url-input"); + let table = document.getElementById("result-table"); + let h2 = document.getElementById("result-head"); + + if (apiKeyInput.value.trim() === "") { + alert("请填写API KEY"); + return; + } + + document.getElementById("result-table").getElementsByTagName('tbody')[0].innerHTML = ""; + + let apiUrl = ""; + if (apiUrlSelect.value === "custom") { + if (customUrlInput.value.trim() === "") { + mdui.alert({ + headline: "无查询线路", + description: "请选择或自定义", + confirmText: "OK", + }) + return; + } else { + apiUrl = customUrlInput.value.trim(); + if (!apiUrl.startsWith("http://") && !apiUrl.startsWith("https://")) { + apiUrl = "https://" + apiUrl; + } + } + } else { + apiUrl = apiUrlSelect.value; + } + + let apiKeys = apiKeyInput.value.split(/[,\s,\n]+/); + + if (apiKeys.length === 0) { + mdui.alert({ + headline: "未匹配到 access_token", + description: "请检查输入内容", + confirmText: "OK", + }) + return; + } + + mdui.alert({ + headline: "成功匹配到 access_token", + description: apiKeys, + confirmText: "OK", + }); + + showLoadingAnimation(); + + let tableBody = document.querySelector("#result-table tbody"); + for (let i = 0; i < apiKeys.length; i++) { + let apiKey = apiKeys[i].trim(); + + let data = await checkBilling(apiKey, apiUrl); // 获取 checkBilling 的结果 + + let row = document.createElement("tr"); + + let serialNumberCell = document.createElement("td"); + serialNumberCell.textContent = serialNumber; + row.appendChild(serialNumberCell); + + let apiKeyCell = document.createElement("td"); + apiKeyCell.textContent = apiKey.replace(/^(.{10}).*(.{8})$/, "$1***$2"); + row.appendChild(apiKeyCell); + + if (data.user && data.user.session) { + let user = data.user; + let session = user.session; + let ip_country = data.ip_country; + + let orgId = user.orgs.data[0].id; + + let properties = ['id', 'email', 'name', 'phone_number', 'created', 'sensitive_id', 'session_created', orgId, 'ip_country']; + properties.forEach(prop => { + let cell = document.createElement("td"); + if (prop === 'created' || prop === 'session_created') { + let timestamp = prop === 'created' ? user[prop] : session['created']; + cell.textContent = new Date(timestamp * 1000).toLocaleString(); + } else if (prop === 'sensitive_id') { + cell.textContent = session[prop]; // 获取 session 对象中的 sensitive_id + } else if (prop === orgId) { + cell.textContent = orgId; // 直接使用 orgId 变量 + } else if (prop === 'ip_country') { + cell.textContent = ip_country ? ip_country : 'N/A'; // 改为使用 ip_country 变量 + } else { + cell.textContent = user[prop]; + } + row.appendChild(cell); + }); + + } else { + // 接口返回的数据结构不符合预期 + console.error("Unexpected data structure: data[0] or data.user is undefined."); + let errorMessageCell = document.createElement("td"); + errorMessageCell.colSpan = "8"; + errorMessageCell.classList.add("status-error"); + errorMessageCell.textContent = "不正确或已失效的API-KEY"; + row.appendChild(errorMessageCell); + } + + tableBody.appendChild(row); + + if (i === apiKeys.length - 1) { + queriedApiKeys = []; + } + serialNumber++; + + + + button.textContent = "查询"; + button.disabled = false; + button.classList.remove("loading"); + } + hideLoadingAnimation(); +} + + +let apiUrlSelect = document.getElementById("api-url-select"); +let customUrlInput = document.getElementById("custom-url-input"); + +apiUrlSelect.addEventListener("change", function () { + if (apiUrlSelect.value === "custom") { + customUrlInput.style.display = "inline-block"; + customUrlInput.style.marginTop = "5px"; + } else { + customUrlInput.style.display = "none"; + } +}); + + +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); + } +} \ No newline at end of file diff --git a/static/js.js b/static/js.js index d8cd1c0..80fbc05 100644 --- a/static/js.js +++ b/static/js.js @@ -397,6 +397,9 @@ function sendRequest() { } else if (sessKeyMatch !== null) { result.push(sessKeyMatch[0]); + }else { + // 如果没有匹配到任何内容,保留原始行 + result.push(line); } } return result; @@ -565,7 +568,7 @@ function sendRequest() { } else if (model === 'gpt-4-32k') { modelName = 'gpt4-32K'; } - rateLimitsText += `${modelName}: ${rateLimitsData[model].max_requests_per_1_minute}, ${rateLimitsData[model].max_tokens_per_1_minute}\n`; + rateLimitsText += `${modelName}: ${rateLimitsData[model].max_requests_per_1_minute}, ${rateLimitsData[model].max_tokens_per_1_minute}-${rateLimitsData[model].max_requests_per_1_day}\n`; } else { rateLimitsText += model + ": ❌\n"; } diff --git a/static/sess1.js b/static/sess1.js deleted file mode 100644 index 2cc7336..0000000 --- a/static/sess1.js +++ /dev/null @@ -1,170 +0,0 @@ -let queriedApiKeys = []; -let serialNumber = 1; - - -async function checkBilling(apiKey, apiUrl) { - const headers = { - "Authorization": "Bearer " + apiKey, - "Content-Type": "application/json" - }; - const urlGetsess = `${apiUrl}/dashboard/onboarding/login`; - - try { - let getSess; - try { - const response = await fetch(urlGetsess, { - method: "POST", // 设置请求方法为 POST - headers: headers, - body: JSON.stringify({}) // 此处放置要发送的数据 - }); - - const getsessdata = await response.json(); - console.log(getsessdata); - - // 获取"sensitive_id" - const sensitiveId = getsessdata.user.session.sensitive_id; - - // 现在,sensitiveId 包含了"sensitive_id"的值 - console.log(sensitiveId); - return [sensitiveId]; - } catch (error) { - console.error(error); - } - - } catch (error) { - console.error(error); - return [null]; - } -} - -//查询函数 -async function sendRequest() { - let button = document.querySelector("button"); - button.textContent = "加载中..."; - button.disabled = true; - button.classList.add("loading") - - let apiKeyInput = document.getElementById("api-key-input"); - let apiUrlSelect = document.getElementById("api-url-select"); - let customUrlInput = document.getElementById("custom-url-input"); - let table = document.getElementById("result-table"); - let h2 = document.getElementById("result-head"); - h2.style.visibility = "visible"; - table.style.visibility = "visible"; - - if (apiKeyInput.value.trim() === "") { - alert("请填写API KEY"); - return; - } - - document.getElementById("result-table").getElementsByTagName('tbody')[0].innerHTML = ""; - - let apiUrl = ""; - if (apiUrlSelect.value === "custom") { - if (customUrlInput.value.trim() === "") { - alert("请设置API链接"); - return; - } else { - apiUrl = customUrlInput.value.trim(); - if (!apiUrl.startsWith("http://") && !apiUrl.startsWith("https://")) { - apiUrl = "https://" + apiUrl; - } - } - } else { - apiUrl = apiUrlSelect.value; - } - - let apiKeys = apiKeyInput.value.split(/[,\s,\n]+/); - - if (apiKeys.length === 0) { - alert("未匹配到 API-KEY,请检查输入内容"); - return; - } - - alert("成功匹配到 API Key,确认后开始查询:" + apiKeys); - - let tableBody = document.querySelector("#result-table tbody"); - for (let i = 0; i < apiKeys.length; i++) { - let apiKey = apiKeys[i].trim(); - - if (queriedApiKeys.includes(apiKey)) { - console.log(`API KEY ${apiKey} 已查询过,跳过此次查询`); - continue; - } - queriedApiKeys.push(apiKey); - - // 使用 await 关键字等待 checkBilling 的结果 - let data = await checkBilling(apiKey, apiUrl); - - data = data.map(item => { - if (item === undefined || item === null) { - return 'Not Found.' - } else { - return item; - } - }) - - - let row = document.createElement("tr"); - - checkBilling(apiKey, apiUrl).then((data) => { - data = data.map(item => { - if (item === undefined) { - return 'Not Found.' - } else { - return item - } - } - ) - - let row = document.createElement("tr"); - - let serialNumberCell = document.createElement("td"); // 创建序列号单元格 - serialNumberCell.textContent = serialNumber; // 设置序列号文本 - row.appendChild(serialNumberCell); // 将序列号单元格添加到行中 - - let apiKeyCell = document.createElement("td"); - apiKeyCell.textContent = apiKey.replace(/^(.{10}).*(.{8})$/, "$1***$2"); - row.appendChild(apiKeyCell); - - console.log('查看查询结果', data); // 添加 console.log 以查看 data 的值 - - if (data[0] === undefined) { - let errorMessageCell = document.createElement("td"); - errorMessageCell.colSpan = "8"; - errorMessageCell.classList.add("status-error"); - errorMessageCell.textContent = "不正确或已失效的API-KEY"; - row.appendChild(errorMessageCell); - } else { - let sensitiveIdResult = document.createElement("td"); - sensitiveIdResult.textContent = data[0]; - row.appendChild(sensitiveIdResult); - } - tableBody.appendChild(row); - - if (i === apiKeys.length - 1) { - queriedApiKeys = []; - } - serialNumber++; // 增加序列号 - h2.style.display = 'block'; - table.style.display = 'table'; - - button.textContent = "查询"; - button.disabled = false; - button.classList.remove("loading") - }) - - } -} - -let apiUrlSelect = document.getElementById("api-url-select"); -let customUrlInput = document.getElementById("custom-url-input"); - -apiUrlSelect.addEventListener("change", function () { - if (apiUrlSelect.value === "custom") { - customUrlInput.style.display = "inline-block"; - customUrlInput.style.marginTop = "5px"; - } else { - customUrlInput.style.display = "none"; - } -}); \ No newline at end of file