feat(mobile): add local QR scanning and desktop pairing invitations
This commit is contained in:
1 parent
c1929957a2
commit
4115f1b4c0
17 files changed
+178
-17
No files matched your search
@@ -37,6 +37,22 @@ try {
|
||||
await page.getByText('Yalnız kendi hesabınızda bu kodu onaylayın: ABCDEFGH').waitFor()
|
||||
await page.getByRole('button', { name: 'Girişi kontrol et' }).click()
|
||||
await page.getByText('Hesaba giriş yapıldı.', { exact: true }).waitFor()
|
||||
let claimed = false
|
||||
await page.route('https://turkservis.online/v1/aiturk/mobile/invites/**/claim', async route => {
|
||||
claimed = true
|
||||
const body = route.request().postDataJSON(); assert.equal(body.secret, 'a'.repeat(43))
|
||||
await route.fulfill({ status: 201, contentType: 'application/json', headers: { 'Access-Control-Allow-Origin': '*' },
|
||||
body: JSON.stringify({ device_id: 'fixture-phone', device_token: 'fixture-device-secret', pairing_id: 'fixture-pair', user_code: 'QRSTUVWX' }) })
|
||||
})
|
||||
const qrImage = await page.evaluate(async () => {
|
||||
const { drawQr } = await import('./qr.mjs'), canvas = document.createElement('canvas')
|
||||
drawQr(canvas, JSON.stringify({ kind: 'aiturk-mobile-invite', version: 1, inviteId: '11111111-1111-4111-8111-111111111111',
|
||||
desktopId: '22222222-2222-4222-8222-222222222222', secret: 'a'.repeat(43), expiresAt: new Date(Date.now() + 600000).toISOString() }))
|
||||
return canvas.toDataURL('image/png').split(',')[1]
|
||||
})
|
||||
await page.locator('#qr-file').setInputFiles({ name: 'invite.png', mimeType: 'image/png', buffer: Buffer.from(qrImage, 'base64') })
|
||||
await page.getByText('Bilgisayarda bekleyen telefonu getirip şu kodu onaylayın: QRSTUVWX').waitFor()
|
||||
assert.equal(claimed, true)
|
||||
await page.getByRole('button', { name: 'Bu uygulamadaki hesaptan çık' }).click()
|
||||
await page.getByText('Bu uygulamanın oturumu kapatıldı.', { exact: false }).waitFor()
|
||||
assert.deepEqual(loginCalls, ['start', 'poll', 'logout'])
|
||||
@@ -67,5 +83,5 @@ try {
|
||||
})
|
||||
assert.equal(result.length, result.expected); assert.equal(result.dtls, 'connected'); assert.equal(result.action, 'session.history')
|
||||
assert.deepEqual(errors, [])
|
||||
console.log(JSON.stringify({ onboarding: 'passed', mockedLoginUi: 'passed', realWebRTC: result, errors }))
|
||||
console.log(JSON.stringify({ onboarding: 'passed', mockedLoginUi: 'passed', realQrImageWithMockedClaim: 'passed', realWebRTC: result, errors }))
|
||||
} finally { await browser.close(); server.close() }
|
||||
@@ -5,4 +5,8 @@ await mkdir(new URL('../dist', import.meta.url), { recursive: true })
|
||||
await cp(new URL('../src', import.meta.url), new URL('../dist', import.meta.url), { recursive: true })
|
||||
const core = dirname(createRequire(import.meta.url).resolve('@capacitor/core/package.json'))
|
||||
await cp(join(core, 'dist', 'capacitor.js'), new URL('../dist/capacitor.js', import.meta.url))
|
||||
await mkdir(new URL('../dist/vendor', import.meta.url), { recursive: true })
|
||||
await cp(new URL('../node_modules/qrcode-generator/dist/qrcode.mjs', import.meta.url), new URL('../dist/vendor/qrcode.mjs', import.meta.url))
|
||||
await cp(new URL('../node_modules/jsqr/dist/jsQR.js', import.meta.url), new URL('../dist/vendor/jsQR.js', import.meta.url))
|
||||
await cp(new URL('../node_modules/jsqr/LICENSE', import.meta.url), new URL('../dist/vendor/jsQR-LICENSE.txt', import.meta.url))
|
||||
console.log('AITURK Android web assets built.')
|
||||
Reference in new issue
Block a user