feat(mobile): connect Android and IDE to browser account login
This commit is contained in:
1 parent
b66daed07a
commit
c1929957a2
8 files changed
+109
-8
No files matched your search
+33
-1
@@ -30,8 +30,40 @@ function event(frame) {
|
||||
}
|
||||
}
|
||||
}
|
||||
action('login-start', async () => {
|
||||
if (credentials.accountToken || connection) throw new Error('Kayıtlı hesabınız var; önce mevcut cihaz erişimini iptal edin.')
|
||||
const result = await new AccountClient({}).call('/v1/aiturk/mobile-auth/start', {})
|
||||
if (!/^https:\/\/turkservis\.online\/account\/aiturk\/mobile-login\/[0-9a-f-]{36}$/.test(result.verificationUri)) throw new Error('Geçersiz giriş sayfası.')
|
||||
credentials.pendingLogin = result; await saveCredentials()
|
||||
$('login-code').textContent = `Yalnız kendi hesabınızda bu kodu onaylayın: ${result.userCode}`
|
||||
$('login-link').href = result.verificationUri; $('login-link').hidden = false
|
||||
if (native()) await native().openLogin({ url: result.verificationUri })
|
||||
status('Tarayıcıda giriş yaptıktan sonra buraya dönüp girişi kontrol edin.')
|
||||
})
|
||||
action('login-check', async () => {
|
||||
if (!credentials.pendingLogin) throw new Error('Önce giriş başlatın.')
|
||||
const result = await new AccountClient({ accountToken: credentials.pendingLogin.deviceCode }).call('/v1/aiturk/mobile-auth/poll', {})
|
||||
if (result.state !== 'approved') { status('Tarayıcıdaki kod onayı bekleniyor.'); return }
|
||||
credentials.accountToken = result.accountToken; delete credentials.pendingLogin; await saveCredentials()
|
||||
account = new AccountClient(credentials); $('login-code').textContent = 'Hesaba giriş yapıldı.'; $('login-link').hidden = true
|
||||
status('Hesap bağlı. Şimdi telefonun eşleştirme kodunu oluşturun.')
|
||||
})
|
||||
action('logout', async () => {
|
||||
const token = credentials.accountToken || credentials.pendingLogin?.deviceCode
|
||||
// Revoke the app-specific credential before dropping the local copy. A
|
||||
// network failure leaves it available for an explicit retry.
|
||||
if (token?.startsWith('tsml_')) await new AccountClient({ accountToken: token }).call('/v1/aiturk/mobile-auth/logout', {})
|
||||
connectionEpoch++; stopVoice(); connection?.close(); connection = null; selected = null; account = null
|
||||
credentials = {}; pendingTask = null; await saveCredentials()
|
||||
$('work').hidden = true; $('login-link').hidden = true; $('login-code').textContent = ''; $('pair-code').textContent = ''
|
||||
status('Bu uygulamanın oturumu kapatıldı. IDE’de başlamış iş kendi çalışma kurallarıyla devam edebilir.')
|
||||
})
|
||||
action('pair', async () => {
|
||||
credentials = { accountToken: $('account-token').value.trim() }; $('account-token').value = ''
|
||||
if (credentials.deviceId) throw new Error('Bu telefon zaten eşleşme başlatmış. Bilgisayarları bulun veya mevcut erişimi iptal edin.')
|
||||
const manual = $('account-token').value.trim(); $('account-token').value = ''
|
||||
if (manual && credentials.accountToken && manual !== credentials.accountToken) throw new Error('Kayıtlı hesap sessizce değiştirilemez.')
|
||||
if (manual) credentials.accountToken = manual
|
||||
if (!credentials.accountToken) throw new Error('Önce AITURK hesabınıza giriş yapın.')
|
||||
account = new AccountClient(credentials)
|
||||
const result = await account.call('/v1/aiturk/pairings', { display_name: $('device-name').value.trim(), platform: 'android' })
|
||||
Object.assign(credentials, { deviceId: result.device_id, deviceToken: result.device_token, pairingId: result.pairing_id })
|
||||
|
||||
@@ -4,8 +4,14 @@
|
||||
<p class="eyebrow">AITURK · ANDROID GELİŞTİRME SÜRÜMÜ</p><h1>Fikrini konuş.<br>Birlikte geliştir.</h1>
|
||||
<p id="status" class="status" role="status" aria-live="polite">Bilgisayarına bağlanarak başla.</p>
|
||||
<section id="setup"><h2>1. Aynı AITURK hesabı</h2>
|
||||
<p>Bu ilk geliştirme sürümünde hesabınızın API anahtarıyla giriş yapılır. <a href="https://turkservis.online/account" target="_blank" rel="noreferrer">AITURK hesabınızı açın</a>. Bu anahtar Google ses anahtarından ayrıdır.</p>
|
||||
<p>Tarayıcıda AITURK hesabınıza giriş yapın ve burada gösterilen kısa kodu onaylayın. Google ses anahtarı ayrı kalır.</p>
|
||||
<button id="login-start">AITURK hesabımla giriş yap</button><pre id="login-code" aria-live="polite"></pre>
|
||||
<a id="login-link" hidden target="_blank" rel="noreferrer">Giriş sayfasını aç</a>
|
||||
<button id="login-check" class="secondary">Girişi kontrol et</button>
|
||||
<button id="logout" class="secondary">Bu uygulamadaki hesaptan çık</button>
|
||||
<details><summary>Gelişmiş: mevcut hesap API anahtarını kullan</summary>
|
||||
<label>AITURK hesap API anahtarı<input id="account-token" type="password" autocomplete="off" autocapitalize="none" spellcheck="false"></label>
|
||||
</details>
|
||||
<label>Telefon adı<input id="device-name" maxlength="80" value="Android telefonum"></label><button id="pair">Eşleştirme kodu oluştur</button>
|
||||
<pre id="pair-code" aria-live="polite"></pre><p>Kodu bilgisayardaki AITURK Mobil bağlantı penceresinde onaylayın. Eşleştirme kimliğini kopyalayabilirsiniz.</p>
|
||||
<button id="devices" class="secondary">Onaydan sonra bilgisayarları bul</button>
|
||||
|
||||
Reference in new issue
Block a user