feat: add cookie import method
This commit is contained in:
@@ -1241,6 +1241,20 @@
|
||||
'modal.localDesc': '通过 Kiro IDE 本地缓存文件添加账号',
|
||||
'modal.credentialsTitle': '凭证 JSON',
|
||||
'modal.credentialsDesc': '通过 Kiro Account Manager 导出的凭证添加账号',
|
||||
'modal.cookieTitle': 'Kiro 网页 Cookie',
|
||||
'modal.cookieDesc': '通过从 Kiro 网页 Cookie 中获取的 RefreshToken 添加账号',
|
||||
'cookie.howToGet': '如何获取 RefreshToken?',
|
||||
'cookie.step1': '打开浏览器,访问并登录',
|
||||
'cookie.step2': '在页面空白处右键 → 检查 → Application → Cookies → https://app.kiro.dev',
|
||||
'cookie.step3': '在列表中找到 <b>RefreshToken</b>,双击其 Value 列并复制',
|
||||
'cookie.refreshToken': 'RefreshToken',
|
||||
'cookie.provider': '登录方式',
|
||||
'cookie.github': 'GitHub',
|
||||
'cookie.google': 'Google',
|
||||
'cookie.refreshTokenPlaceholder': '粘贴 RefreshToken Cookie 的值',
|
||||
'cookie.refreshTokenMissing': '请填写 RefreshToken',
|
||||
'cookie.importSuccess': '账号添加成功',
|
||||
'cookie.link': 'https://app.kiro.dev/account/usage',
|
||||
'builderid.startLogin': '开始登录',
|
||||
'builderid.verifyCode': '请在浏览器中输入上方验证码',
|
||||
'builderid.verifyUrl': '验证链接',
|
||||
@@ -1455,6 +1469,20 @@
|
||||
'modal.localDesc': 'Add account via Kiro IDE local cache files',
|
||||
'modal.credentialsTitle': 'Credentials JSON',
|
||||
'modal.credentialsDesc': 'Add account via Kiro Account Manager exported credentials',
|
||||
'modal.cookieTitle': 'Kiro Web Cookie',
|
||||
'modal.cookieDesc': 'Add account via RefreshToken obtained from Kiro Web Cookie',
|
||||
'cookie.howToGet': 'How to get the RefreshToken?',
|
||||
'cookie.step1': 'Open your browser and sign in at',
|
||||
'cookie.step2': 'Right-click on blank area → Inspect → Application → Cookies → https://app.kiro.dev',
|
||||
'cookie.step3': 'Find <b>RefreshToken</b> in the list, double-click its Value and copy it',
|
||||
'cookie.refreshToken': 'RefreshToken',
|
||||
'cookie.provider': 'Login Provider',
|
||||
'cookie.github': 'GitHub',
|
||||
'cookie.google': 'Google',
|
||||
'cookie.refreshTokenPlaceholder': 'Paste the RefreshToken cookie value here',
|
||||
'cookie.refreshTokenMissing': 'RefreshToken is required',
|
||||
'cookie.importSuccess': 'Account added successfully',
|
||||
'cookie.link': 'https://app.kiro.dev/account/usage',
|
||||
'builderid.startLogin': 'Start Login',
|
||||
'builderid.verifyCode': 'Enter the code above in your browser',
|
||||
'builderid.verifyUrl': 'Verification URL',
|
||||
@@ -2256,6 +2284,7 @@
|
||||
'<div class="card" style="margin:0;cursor:pointer;border:2px solid transparent;transition:border-color 0.2s" onclick="showModal(\'sso\')" onmouseover="this.style.borderColor=\'#7c3aed\'" onmouseout="this.style.borderColor=\'transparent\'"><div style="font-weight:600;margin-bottom:6px">' + t('modal.ssoTitle') + '</div><div style="font-size:13px;color:#64748b">' + t('modal.ssoDesc') + '</div></div>' +
|
||||
'<div class="card" style="margin:0;cursor:pointer;border:2px solid transparent;transition:border-color 0.2s" onclick="showModal(\'local\')" onmouseover="this.style.borderColor=\'#7c3aed\'" onmouseout="this.style.borderColor=\'transparent\'"><div style="font-weight:600;margin-bottom:6px">' + t('modal.localTitle') + '</div><div style="font-size:13px;color:#64748b">' + t('modal.localDesc') + '</div></div>' +
|
||||
'<div class="card" style="margin:0;cursor:pointer;border:2px solid transparent;transition:border-color 0.2s" onclick="showModal(\'credentials\')" onmouseover="this.style.borderColor=\'#7c3aed\'" onmouseout="this.style.borderColor=\'transparent\'"><div style="font-weight:600;margin-bottom:6px">' + t('modal.credentialsTitle') + '</div><div style="font-size:13px;color:#64748b">' + t('modal.credentialsDesc') + '</div></div>' +
|
||||
'<div class="card" style="margin:0;cursor:pointer;border:2px solid transparent;transition:border-color 0.2s" onclick="showModal(\'cookie\')" onmouseover="this.style.borderColor=\'#7c3aed\'" onmouseout="this.style.borderColor=\'transparent\'"><div style="font-weight:600;margin-bottom:6px">' + t('modal.cookieTitle') + '</div><div style="font-size:13px;color:#64748b">' + t('modal.cookieDesc') + '</div></div>' +
|
||||
'</div>' +
|
||||
'<div class="modal-footer"><button class="btn btn-secondary" onclick="closeModal()">' + t('common.cancel') + '</button></div>';
|
||||
} else if (type === 'builderid') {
|
||||
@@ -2287,6 +2316,13 @@
|
||||
'<div style="font-size:12px;color:#64748b;margin-bottom:12px;line-height:1.5">' + t('credentials.batchHint') + '</div>' +
|
||||
'<div class="form-group"><label>' + t('credentials.label') + '</label><textarea id="credJson" placeholder=\'[{"refreshToken":"xxx","provider":"BuilderId"},{"refreshToken":"yyy","clientId":"...","clientSecret":"...","provider":"Enterprise"}]\' style="min-height:120px"></textarea></div>' +
|
||||
'<div class="modal-footer"><button class="btn btn-secondary" onclick="showModal(\'add\')">' + t('common.back') + '</button><button class="btn btn-primary" onclick="importCredentials()">' + t('common.add') + '</button></div>';
|
||||
} else if (type === 'cookie') {
|
||||
title.textContent = t('modal.cookieTitle');
|
||||
body.innerHTML =
|
||||
'<div style="font-size:13px;color:#64748b;margin-bottom:16px;line-height:1.8"><p style="margin-bottom:8px;font-weight:600;color:#374151">' + t('cookie.howToGet') + '</p><ol style="margin:0;padding-left:20px;display:flex;flex-direction:column;gap:6px"><li>' + t('cookie.step1') + ' <a href="' + t('cookie.link') + '" target="_blank" style="color:#7c3aed;word-break:break-all">' + t('cookie.link') + '</a></li><li>' + t('cookie.step2') + '</li><li>' + t('cookie.step3') + '</li></ol></div>' +
|
||||
'<div class="form-group"><label>' + t('cookie.provider') + '</label><select id="cookieProvider"><option value="Google">' + t('cookie.google') + '</option><option value="Github">' + t('cookie.github') + '</option></select></div>' +
|
||||
'<div class="form-group"><label>' + t('cookie.refreshToken') + '</label><textarea id="cookieRefreshToken" placeholder="' + t('cookie.refreshTokenPlaceholder') + '" style="min-height:80px;font-family:monospace;font-size:12px"></textarea></div>' +
|
||||
'<div class="modal-footer"><button class="btn btn-secondary" onclick="showModal(\'add\')">' + t('common.back') + '</button><button class="btn btn-primary" onclick="importFromCookie()">' + t('common.add') + '</button></div>';
|
||||
} else if (type === 'sso') {
|
||||
title.textContent = t('modal.ssoTitle');
|
||||
body.innerHTML =
|
||||
@@ -2397,6 +2433,16 @@
|
||||
newIds.forEach(id => autoRefreshNewAccount(id));
|
||||
} catch (e) { alert(t('credentials.jsonError')); }
|
||||
}
|
||||
async function importFromCookie() {
|
||||
const refreshToken = document.getElementById('cookieRefreshToken').value.trim();
|
||||
if (!refreshToken) { alert(t('cookie.refreshTokenMissing')); return; }
|
||||
const provider = document.getElementById('cookieProvider').value;
|
||||
const payload = { refreshToken, accessToken: '', clientId: '', clientSecret: '', authMethod: 'social', provider };
|
||||
const res = await fetch('/admin/api/auth/credentials', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, body: JSON.stringify(payload) });
|
||||
const d = await res.json();
|
||||
if (d.success) { closeModal(); loadAccounts(); loadStats(); alert(t('cookie.importSuccess') + ': ' + (d.account?.email || d.account?.id)); autoRefreshNewAccount(d.account?.id); }
|
||||
else alert(t('common.failed') + ': ' + d.error);
|
||||
}
|
||||
async function importSsoToken() {
|
||||
const res = await fetch('/admin/api/auth/sso-token', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, body: JSON.stringify({ bearerToken: document.getElementById('ssoToken').value, region: document.getElementById('ssoRegion').value }) });
|
||||
const d = await res.json();
|
||||
|
||||
Reference in New Issue
Block a user