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
@@ -0,0 +1,11 @@
|
||||
export function parseInvite(raw, now = Date.now()) {
|
||||
if (typeof raw !== 'string' || raw.length > 800) throw new Error('Bu bir AITURK eşleştirme QR kodu değil.')
|
||||
let data
|
||||
try { data = JSON.parse(raw) } catch { throw new Error('Bu bir AITURK eşleştirme QR kodu değil.') }
|
||||
if (!data || data.kind !== 'aiturk-mobile-invite' || data.version !== 1 ||
|
||||
!/^[0-9a-f-]{36}$/.test(data.inviteId) || !/^[0-9a-f-]{36}$/.test(data.desktopId) ||
|
||||
!/^[A-Za-z0-9_-]{43}$/.test(data.secret) || !Number.isFinite(Date.parse(data.expiresAt)) ||
|
||||
Date.parse(data.expiresAt) <= now || Date.parse(data.expiresAt) > now + 11 * 60000)
|
||||
throw new Error('QR geçersiz veya süresi dolmuş. Bilgisayarda yeni kod oluşturun.')
|
||||
return { inviteId: data.inviteId, desktopId: data.desktopId, secret: data.secret }
|
||||
}
|
||||
Reference in new issue
Block a user