indraq_cli 2.8.1 → 2.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +185 -2
  2. package/cloud-api/.env.example +9 -0
  3. package/cloud-api/README.md +34 -1
  4. package/cloud-api/dist/index.js +1396 -68
  5. package/cloud-api/dist/index.js.map +1 -1
  6. package/cloud-api/dist/ota-device-enrollment.js +41 -0
  7. package/cloud-api/dist/ota-device-enrollment.js.map +1 -0
  8. package/cloud-api/dist/ota-enrollment-pages.js +67 -0
  9. package/cloud-api/dist/ota-enrollment-pages.js.map +1 -0
  10. package/cloud-api/dist/ota-recovery-content.js +36 -0
  11. package/cloud-api/dist/ota-recovery-content.js.map +1 -0
  12. package/cloud-api/dist/ota-recovery-protocol.js +16 -0
  13. package/cloud-api/dist/ota-release-policy.js +25 -0
  14. package/cloud-api/dist/ota-release-policy.js.map +1 -0
  15. package/cloud-api/package.json +1 -1
  16. package/cloud-api/public/indraq-logo.png +0 -0
  17. package/cloud-api/sql/015_ota_device_registry_and_withdrawal.sql +23 -0
  18. package/cloud-api/sql/016_ota_verified_tester_devices.sql +19 -0
  19. package/cloud-api/sql/017_ota_device_app_access_grants.sql +18 -0
  20. package/cloud-api/sql/018_ota_android_tester_agent.sql +24 -0
  21. package/cloud-api/sql/019_ota_android_scoped_testers.sql +9 -0
  22. package/cloud-api/sql/020_ota_recovery_and_retention.sql +21 -0
  23. package/cloud-api/sql/021_ota_device_profile_consolidation.sql +14 -0
  24. package/cloud-api/src/index.ts +1078 -82
  25. package/cloud-api/src/index.ts.backup-before-extra-params-2026-11-20T19-41-35-684Z +3189 -0
  26. package/cloud-api/src/ota-device-enrollment.ts +30 -0
  27. package/cloud-api/src/ota-enrollment-pages.ts +71 -0
  28. package/cloud-api/src/ota-recovery-content.ts +45 -0
  29. package/cloud-api/src/ota-recovery-protocol.ts +16 -0
  30. package/cloud-api/src/ota-release-policy.ts +28 -0
  31. package/dist/cli/help-content.d.ts.map +1 -1
  32. package/dist/cli/help-content.js +34 -10
  33. package/dist/cli/help-content.js.map +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/modules/mobile/commands/build-mobile.command.d.ts +3 -1
  37. package/dist/modules/mobile/commands/build-mobile.command.d.ts.map +1 -1
  38. package/dist/modules/mobile/commands/build-mobile.command.js +214 -57
  39. package/dist/modules/mobile/commands/build-mobile.command.js.map +1 -1
  40. package/dist/modules/mobile/commands/mobile-build-wizard.command.d.ts +3 -1
  41. package/dist/modules/mobile/commands/mobile-build-wizard.command.d.ts.map +1 -1
  42. package/dist/modules/mobile/commands/mobile-build-wizard.command.js +23 -16
  43. package/dist/modules/mobile/commands/mobile-build-wizard.command.js.map +1 -1
  44. package/dist/modules/mobile/commands/mobile-prebuild.command.d.ts +2 -0
  45. package/dist/modules/mobile/commands/mobile-prebuild.command.d.ts.map +1 -1
  46. package/dist/modules/mobile/commands/mobile-prebuild.command.js +58 -2
  47. package/dist/modules/mobile/commands/mobile-prebuild.command.js.map +1 -1
  48. package/dist/modules/mobile/commands/ota.command.d.ts +9 -0
  49. package/dist/modules/mobile/commands/ota.command.d.ts.map +1 -1
  50. package/dist/modules/mobile/commands/ota.command.js +271 -103
  51. package/dist/modules/mobile/commands/ota.command.js.map +1 -1
  52. package/dist/modules/mobile/commands/testers.command.d.ts +11 -0
  53. package/dist/modules/mobile/commands/testers.command.d.ts.map +1 -1
  54. package/dist/modules/mobile/commands/testers.command.js +236 -5
  55. package/dist/modules/mobile/commands/testers.command.js.map +1 -1
  56. package/dist/modules/mobile/config/mobile-config.d.ts +3 -0
  57. package/dist/modules/mobile/config/mobile-config.d.ts.map +1 -1
  58. package/dist/modules/mobile/config/mobile-config.js.map +1 -1
  59. package/dist/modules/mobile/index.d.ts.map +1 -1
  60. package/dist/modules/mobile/index.js +41 -6
  61. package/dist/modules/mobile/index.js.map +1 -1
  62. package/dist/modules/mobile/services/mobile-cloud.service.d.ts +85 -1
  63. package/dist/modules/mobile/services/mobile-cloud.service.d.ts.map +1 -1
  64. package/dist/modules/mobile/services/mobile-cloud.service.js +27 -1
  65. package/dist/modules/mobile/services/mobile-cloud.service.js.map +1 -1
  66. package/dist/modules/mobile/services/mobile-native-integration.service.d.ts +12 -0
  67. package/dist/modules/mobile/services/mobile-native-integration.service.d.ts.map +1 -0
  68. package/dist/modules/mobile/services/mobile-native-integration.service.js +394 -0
  69. package/dist/modules/mobile/services/mobile-native-integration.service.js.map +1 -0
  70. package/dist/modules/mobile/services/ota-apk-validator.service.d.ts +4 -0
  71. package/dist/modules/mobile/services/ota-apk-validator.service.d.ts.map +1 -1
  72. package/dist/modules/mobile/services/ota-apk-validator.service.js +25 -3
  73. package/dist/modules/mobile/services/ota-apk-validator.service.js.map +1 -1
  74. package/dist/modules/mobile/services/ota-native-compatibility.service.d.ts +18 -0
  75. package/dist/modules/mobile/services/ota-native-compatibility.service.d.ts.map +1 -0
  76. package/dist/modules/mobile/services/ota-native-compatibility.service.js +21 -0
  77. package/dist/modules/mobile/services/ota-native-compatibility.service.js.map +1 -0
  78. package/dist/modules/mobile/services/ota-setup.service.d.ts +4 -0
  79. package/dist/modules/mobile/services/ota-setup.service.d.ts.map +1 -1
  80. package/dist/modules/mobile/services/ota-setup.service.js +231 -42
  81. package/dist/modules/mobile/services/ota-setup.service.js.map +1 -1
  82. package/dist/modules/mobile/services/tester-reconnect-policy.d.ts +9 -0
  83. package/dist/modules/mobile/services/tester-reconnect-policy.d.ts.map +1 -0
  84. package/dist/modules/mobile/services/tester-reconnect-policy.js +12 -0
  85. package/dist/modules/mobile/services/tester-reconnect-policy.js.map +1 -0
  86. package/dist/modules/mobile/services/tester-reconnect-probe.service.d.ts +5 -0
  87. package/dist/modules/mobile/services/tester-reconnect-probe.service.d.ts.map +1 -0
  88. package/dist/modules/mobile/services/tester-reconnect-probe.service.js +41 -0
  89. package/dist/modules/mobile/services/tester-reconnect-probe.service.js.map +1 -0
  90. package/dist/modules/scaffold/commands/init.command.d.ts.map +1 -1
  91. package/dist/modules/scaffold/commands/init.command.js +8 -2
  92. package/dist/modules/scaffold/commands/init.command.js.map +1 -1
  93. package/package.json +58 -4
  94. package/src/modules/mobile/services/android-agent-bridge/IIndraQTesterAgent.aidl +2 -0
  95. package/src/modules/mobile/services/android-agent-bridge/IndraQTesterModule.java +67 -0
  96. package/src/modules/mobile/services/android-agent-bridge/IndraQTesterPackage.java +15 -0
  97. package/src/modules/mobile/services/android-identity-bridge/IndraQDeviceIdentityModule.java +31 -0
  98. package/src/modules/mobile/services/android-identity-bridge/IndraQDeviceIdentityPackage.java +16 -0
  99. package/src/modules/mobile/services/expo-android-identity-plugin.cjs +44 -0
@@ -0,0 +1,41 @@
1
+ /** Browser-backed proof of possession for IndraQ tester device profiles.
2
+ * A securely stored browser cookie, not an OS-level hardware identifier.
3
+ * Cloud must never imply biometric or Apple/Android UDID attestation.
4
+ */
5
+ import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
6
+ export const DEVICE_COOKIE = '__Secure-indraq_ota_device';
7
+ export const deviceToken = () => randomBytes(32).toString('base64url');
8
+ export const deviceTokenHash = (v) => createHash('sha256').update(v).digest('hex');
9
+ const encoded = (v) => encodeURIComponent(v);
10
+ export const deviceCookieHeader = (deviceId, secret) => `${DEVICE_COOKIE}=${encoded(deviceId + '.' + secret)}; Path=/ota/; Max-Age=31536000; Secure; HttpOnly; SameSite=Lax`;
11
+ export const readDeviceCookie = (header) => {
12
+ const item = String(header || '').split(';').map(v => v.trim()).find(v => v.startsWith(`${DEVICE_COOKIE}=`));
13
+ if (!item)
14
+ return null;
15
+ let raw = '';
16
+ try {
17
+ raw = decodeURIComponent(item.slice(DEVICE_COOKIE.length + 1));
18
+ }
19
+ catch {
20
+ return null;
21
+ }
22
+ const sep = raw.indexOf('.');
23
+ if (sep < 0)
24
+ return null;
25
+ const id = raw.slice(0, sep), secret = raw.slice(sep + 1);
26
+ if (!/^[0-9a-f-]{36}$/i.test(id) || !/^[A-Za-z0-9_-]{43}$/.test(secret))
27
+ return null;
28
+ return { id, secret };
29
+ };
30
+ export const verifiedBrowserMatches = (cookieHeader, device) => {
31
+ if (!device.verified_at || device.revoked_at || !device.browser_credential_hash)
32
+ return false;
33
+ const cookie = readDeviceCookie(cookieHeader);
34
+ if (!cookie || cookie.id !== device.id)
35
+ return false;
36
+ const digest = deviceTokenHash(cookie.secret);
37
+ const actual = Buffer.from(digest, 'hex');
38
+ const expected = Buffer.from(device.browser_credential_hash, 'hex');
39
+ return actual.length === expected.length && timingSafeEqual(actual, expected);
40
+ };
41
+ export const registeredInviteCanRedeem = (invite) => !invite.registered_device_id || Boolean(invite.browser_approved_at);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ota-device-enrollment.js","sourceRoot":"","sources":["ota-device-enrollment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,MAAM,CAAC,MAAM,aAAa,GAAG,4BAA4B,CAAC;AAC1D,MAAM,CAAC,MAAM,WAAW,GAAG,GAAW,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAQ,EAAS,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjG,MAAM,OAAO,GAAG,CAAC,CAAQ,EAAS,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAe,EAAC,MAAa,EAAS,EAAE,CACzE,GAAG,aAAa,IAAI,OAAO,CAAC,QAAQ,GAAC,GAAG,GAAC,MAAM,CAAC,gEAAgE,CAAC;AACnH,MAAM,CAAC,MAAM,gBAAgB,GAAG,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MAAM,GAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC5C,IAAG,CAAC,MAAM,IAAE,MAAM,CAAC,EAAE,KAAG,MAAM,CAAC,EAAE;QAAC,OAAO,KAAK,CAAC;IAC/C,MAAM,MAAM,GAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAC,KAAK,CAAC,CAAC;IAAA,MAAM,QAAQ,GAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAC,KAAK,CAAC,CAAC;IACxG,OAAO,MAAM,CAAC,MAAM,KAAG,QAAQ,CAAC,MAAM,IAAE,eAAe,CAAC,MAAM,EAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAA2E,EAAU,EAAE,CAC/H,CAAC,MAAM,CAAC,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,67 @@
1
+ /** IndraQ branded, dependency-free enrollment pages. No analytics or third-party assets.
2
+ * All user/device labels must be escaped before entering the DOM.
3
+ */
4
+ export const escapeEnrollmentHtml = (value) => String(value ?? '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c] || c));
5
+ const css = `:root{color-scheme:light;font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;--navy:#152f41;--ink:#16283c;--muted:#637588;--line:#e6eaf0;--grad:linear-gradient(110deg,#fc638a,#ffa950)}*{box-sizing:border-box}body{margin:0;min-height:100svh;color:var(--ink);background:radial-gradient(ellipse 380px 240px at 0 0,#fff0f2 0%,transparent 80%),radial-gradient(ellipse 420px 260px at 100% 100%,#fff0dc 0%,transparent 78%),#fafbfc;display:flex;flex-direction:column;-webkit-font-smoothing:antialiased}header{width:min(1060px,100%);padding:26px 28px;margin:0 auto;display:flex;align-items:center;justify-content:space-between}.brand{display:inline-flex;align-items:center;gap:9px;font-weight:850;letter-spacing:-.8px;text-decoration:none;color:var(--navy)}.brand img{display:block;width:148px;height:auto;max-height:46px;object-fit:contain}.head-tag{font-size:11px;font-weight:750;color:#8b5363;background:#fff1f2;padding:9px 12px;border-radius:30px;border:1px solid #ffdde3;text-transform:uppercase;letter-spacing:.65px}main{width:min(560px,calc(100% - 36px));margin:auto;padding:20px 0 26px}.card{background:rgba(255,255,255,.98);border:1px solid var(--line);border-radius:26px;box-shadow:0 20px 60px #132f4114;padding:36px}.state-icon{height:56px;width:56px;border-radius:18px;background:#fff0e7;display:grid;place-items:center;color:#e96958;font-size:26px;font-weight:850;margin-bottom:20px}.state-icon.approved{background:#e2f8ec;color:#14784f}.state-icon.warn{background:#fff1e6;color:#c16928}.eyebrow{font-size:11px;color:#e96b74;font-weight:850;text-transform:uppercase;letter-spacing:1.5px;margin:0 0 11px}h1{font-size:clamp(26px,4vw,36px);letter-spacing:-1.25px;line-height:1.15;margin:0 0 14px;color:#142c40}p{font-size:15px;line-height:1.65;color:var(--muted);margin:0 0 22px}.device{background:#f8fafb;border:1px solid var(--line);border-radius:14px;padding:15px;display:flex;justify-content:space-between;align-items:center;margin:4px 0 20px;gap:10px}.device span{color:#758598;font-size:13px}.device strong{font-size:14px;word-break:break-word;text-align:right}.button{appearance:none;border:0;display:flex;align-items:center;justify-content:center;gap:10px;width:100%;text-align:center;padding:16px 20px;background:var(--grad);border-radius:13px;color:#fff;font-weight:800;font-size:15px;text-decoration:none;cursor:pointer;box-shadow:0 9px 22px #f6758044;transition:transform .18s,filter .18s}.button:hover{filter:saturate(1.13);transform:translateY(-1px)}.button:focus-visible,.secondary:focus-visible{outline:3px solid #e97083;outline-offset:4px}.secondary{display:block;margin-top:12px;border:1px solid #dce2e8;border-radius:13px;background:white;color:var(--navy);text-align:center;padding:13px;text-decoration:none;font-size:14px;font-weight:750}.note{display:flex;gap:10px;padding:14px 16px;background:#f7f9fa;border:1px solid #eef0f4;border-radius:12px;color:#64788a;font-size:13px;line-height:1.5;margin-top:20px}.note b{color:var(--navy)}.foot{margin:0 auto;padding:20px;color:#7a8a98;font-size:12px;text-align:center}.fine{color:#8795a8;font-size:12px;line-height:1.5;margin:16px 0 0;text-align:center}form{margin:0}.checks{display:grid;gap:10px;margin:18px 0 23px;padding:16px;border-radius:15px;border:1px solid #e9eef2;background:#fbfcfd}.check{display:flex;align-items:center;gap:11px;color:var(--navy);font-size:13px;font-weight:680}.check span:first-child{background:#e2f8ec;color:#19804a;width:28px;height:28px;display:grid;place-items:center;border-radius:9px;font-weight:900}.check .muted{color:#9a6d37;background:#fff1dc}.hero-dots{height:6px;width:62px;border-radius:20px;background:var(--grad);margin:0 0 22px}.small-print{margin-top:15px;font-size:12px;text-align:center;color:#8291a0}.helper{margin-top:14px;text-align:center;font-size:13px;color:#718295}.helper a{color:var(--navy);text-underline-offset:3px}.app-icon{height:44px;width:44px;border-radius:12px;background:linear-gradient(135deg,#203a50,#3f6175);color:white;display:grid;place-items:center;font-weight:900;font-size:21px}.app-heading{display:flex;gap:12px;align-items:center;margin-bottom:22px}.app-heading strong{font-size:15px;color:var(--ink)}.app-heading span{display:block;color:var(--muted);font-size:12px;margin-top:3px}@media(min-width:700px){.card{padding:42px 44px}}@media(max-width:520px){header{padding:18px 22px}.brand img{width:128px}.head-tag{display:none}main{width:calc(100% - 28px);padding:4px 0 20px}.card{padding:28px 23px;border-radius:23px}.state-icon{margin-bottom:16px}h1{letter-spacing:-.8px}p{font-size:14px}.button{min-height:53px}.foot{font-size:11px}}@media(prefers-reduced-motion:reduce){.button{transition:none}}`;
6
+ const head = (title) => `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta name="referrer" content="no-referrer"><meta name="theme-color" content="#fbfbfc"><title>${escapeEnrollmentHtml(title)} · IndraQ</title><style>${css}</style></head><body><header><a class="brand" href="/ota/device/apps" aria-label="IndraQ testing"><img src="/ota/brand/indraq-logo.png" alt="IndraQ"></a><span class="head-tag">Private tester access</span></header>`;
7
+ const foot = '</body></html>';
8
+ export function enrollmentPage(input) {
9
+ const name = escapeEnrollmentHtml(input.name || 'Your phone');
10
+ const app = escapeEnrollmentHtml(input.app || '');
11
+ const action = escapeEnrollmentHtml(input.action || '');
12
+ const link = escapeEnrollmentHtml(input.link || '');
13
+ const types = {
14
+ register: { icon: '✓', iconClass: '', label: 'Device verification', title: 'Approve this device', description: 'Verify this phone to reuse it for testing authorized IndraQ applications. Only approve on a phone you control.', button: 'Approve this phone' },
15
+ approved: { icon: '✓', iconClass: 'approved', label: 'Verification successful', title: 'Device registered!', description: 'Your phone browser is now verified. Return to your computer; IndraQ CLI will automatically detect this approval.', button: 'View my testing apps' },
16
+ duplicate: { icon: '✓', iconClass: 'approved', label: 'Already registered', title: 'This browser is already approved', description: 'This browser is linked to an active IndraQ tester registration under the same owner. Reuse that registration rather than creating a second profile. The new registration QR remains unused.', button: 'View existing tester apps' },
17
+ expired: { icon: '!', iconClass: 'warn', label: 'Link unavailable', title: 'This link is no longer valid', description: 'This QR code may have expired, already been used, or been revoked. Generate another registration QR in the CLI.', button: '' },
18
+ denied: { icon: '!', iconClass: 'warn', label: 'Permission required', title: 'Use your verified phone', description: 'Open this link in the same phone browser that approved your IndraQ device. The device owner may need to renew its verification.', button: '' },
19
+ pair: { icon: '→', iconClass: '', label: 'App authorization', title: 'Allow app testing?', description: `Confirm this phone can test ${app}. Only grant access to an app you recognize.`, button: 'Approve app pairing' },
20
+ open: { icon: '↗', iconClass: 'approved', label: 'Pairing approved', title: 'Open your app', description: `Your phone has approved testing access for ${app}. Return to the installed app to complete pairing.`, button: 'Open app' }
21
+ };
22
+ const s = types[input.state];
23
+ const title = escapeEnrollmentHtml(s.title);
24
+ const button = (input.state === 'open' || input.state === 'approved' || input.state === 'duplicate') && link ? `<a class="button" href="${link}">${s.button}</a>` :
25
+ (input.state === 'register' || input.state === 'pair') && action ? `<form method="post" action="${action}"><button class="button" type="submit">${s.button}</button></form>` : '';
26
+ const details = name && input.state === 'register' ? `<div class="device"><span>Device</span><strong>${name}</strong></div>` : app && (input.state === 'pair' || input.state === 'open') ? `<div class="device"><span>Application</span><strong>${app}</strong></div>` : '';
27
+ const grantedApps = input.state === 'register' && input.apps?.length ? `<div class="device" style="display:block"><span>Testing access being approved</span><div style="margin-top:8px;font-weight:700;font-size:14px;line-height:1.6">${input.apps.map(escapeEnrollmentHtml).join(', ')}</div></div>` : '';
28
+ const safeNote = input.state === 'register' ? 'We verify this browser session, not a hardware ID. No access to your files, photos or contacts is requested.' : input.state === 'approved' ? 'Your CLI will display confirmation automatically. Keep this browser profile to authorize future apps.' : input.state === 'pair' ? 'Only apps you approve can receive tester-only releases on this installation.' : 'IndraQ registration links expire and are single-use for your security.';
29
+ return `${head(title)}<main><section class="card" aria-labelledby="heading"><div class="state-icon ${s.iconClass}">${s.icon}</div><div class="eyebrow">${s.label}</div><h1 id="heading">${title}</h1><p>${s.description}</p>${details}${grantedApps}${button}<div class="note"><span aria-hidden="true">◇</span><span>${safeNote}</span></div></section></main><footer class="foot">IndraQ Innovations · Trusted tester access</footer>${foot}`;
30
+ }
31
+ export function devicePortalPage(data) {
32
+ const apps = data.apps.map(a => {
33
+ const name = escapeEnrollmentHtml(a.name), id = escapeEnrollmentHtml(a.id), csrf = escapeEnrollmentHtml(a.csrf);
34
+ return `<div class="device" style="display:flex;align-items:center;gap:14px"><span style="font-size:15px;font-weight:750;color:#162338;flex:1">${name}</span>` +
35
+ (a.scheme ? `<form method="post" action="/ota/device/apps/${id}/link"><input type="hidden" name="csrf" value="${csrf}"><button class="button" style="padding:11px 15px;width:auto;font-size:13px" type="submit">Connect</button></form>` :
36
+ `<span style="font-size:12px">Needs IndraQ prebuild</span>`) + `</div>`;
37
+ }).join('');
38
+ const empty = `<p>No mobile apps have been authorized for this phone yet. Choose the phone during an IndraQ build, or run indraq mobile devices allow.</p>`;
39
+ return `${head('My testing apps')}<main style="width:min(540px,calc(100% - 32px))"><section class="card"><div class="state-icon approved">✓</div><div class="eyebrow">Reusable device</div><h1>Ready to test your apps.</h1><p><strong>${escapeEnrollmentHtml(data.deviceLabel)}</strong> is verified. Tap Connect next to an app you have installed. No new QR code is required. Apps remain separate and must be authorized.</p>${apps || empty}<div class="note">◇ &nbsp; This page is accessible only in the phone browser used to register. Each Connect link is one-use and expires automatically.</div></section></main><footer class="foot">IndraQ Innovations · Trusted tester access</footer>${foot}`;
40
+ }
41
+ // The browser will attempt to return to the already installed app automatically.
42
+ // Some iOS/Android browsers block automatic custom-scheme launches: the button
43
+ // remains as an explicit fallback, with no additional QR or approval step.
44
+ /** Recovery page is a *real user-consent screen*, not an automatic redirect.
45
+ * Browser consent is a fallback only if the app could not restore in-app.
46
+ * The token is one-use and must still be redeemed by the calling installation.
47
+ */
48
+ export function reconnectPage(input) {
49
+ const approved = input.state === 'open' && !!input.link;
50
+ const title = approved ? 'Continue testing on this device' : input.state === 'denied' ? 'Device verification required' : 'Testing access unavailable';
51
+ const app = escapeEnrollmentHtml(input.app || 'your app');
52
+ const link = approved ? escapeEnrollmentHtml(input.link) : '';
53
+ const intro = approved ? `Your phone is approved to test <strong>${app}</strong>. Please allow this app to reconnect securely. No new QR registration is needed.` :
54
+ input.state === 'denied' ? 'We could not verify this browser. Open this page in the same phone browser used for the original device registration. If its data was cleared, the device owner can renew registration.' :
55
+ 'This phone is not authorized for this app, or too many attempts were made. Ask your project administrator to check its testing permissions.';
56
+ const checks = approved ? `<div class="checks" aria-label="Verification details"><div class="check"><span>✓</span>Previously approved tester device</div><div class="check"><span>✓</span>Project access granted</div><div class="check"><span class="muted">→</span>Ready to return to the app</div></div>` : '';
57
+ const button = approved ? `<a class="button" href="${link}" aria-label="Allow testing and open app">Allow &amp; Continue&nbsp; →</a><p class="small-print">Your browser may ask permission to open the installed app.</p>` :
58
+ `<a class="secondary" href="/ota/device/apps">View my testing apps</a>`;
59
+ return `${head(title)}<main><section class="card" aria-labelledby="main-title">
60
+ <div class="hero-dots" aria-hidden="true"></div><div class="eyebrow">IndraQ · Android testing</div>
61
+ <h1 id="main-title">${escapeEnrollmentHtml(title)}</h1><p>${intro}</p>
62
+ ${approved ? `<div class="app-heading"><span class="app-icon" aria-hidden="true">✓</span><div><strong>${app}</strong><span>Private tester release</span></div></div>` : ''}
63
+ ${checks}${button}
64
+ <div class="note"><span aria-hidden="true">◇</span><span>${approved ? 'Only testers approved by the project owner can continue. For trusted internal testing, IndraQ may store a protected fingerprint of an Android signing-key-scoped identifier to recognize future builds. No files, photos or contacts are accessed.' : 'Your testing access is never granted automatically when device verification is unavailable.'}</span></div>
65
+ <p class="helper">Need help? Contact your project administrator.</p>
66
+ </section></main><footer class="foot">IndraQ Innovations · Tester access</footer>${foot}`;
67
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ota-enrollment-pages.js","sourceRoot":"","sources":["ota-enrollment-pages.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAS,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAC,CAAC,CAAA,EAAE,CAAA,CAAC,EAAC,GAAG,EAAC,OAAO,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG,EAAC,QAAQ,EAAC,GAAG,EAAC,OAAO,EAAC,CAAC,CAAC,CAAC,IAAE,CAAC,CAAC,CAAC,CAAC;AAE9K,MAAM,GAAG,GAAC,ukJAAukJ,CAAC;AACllJ,MAAM,IAAI,GAAC,CAAC,KAAY,EAAQ,EAAE,CAAA,kPAAkP,oBAAoB,CAAC,KAAK,CAAC,2BAA2B,GAAG,uNAAuN,CAAC;AACriB,MAAM,IAAI,GAAC,gBAAgB,CAAC;AAC5B,MAAM,UAAU,cAAc,CAAC,KAA2F;IACzH,M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,IAAI,EAAE,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,36 @@
1
+ const json = (value) => JSON.stringify(value ?? null);
2
+ export const identicalRecoveryPayloads = (left, right) => {
3
+ if (!left.length || left.length !== right.length)
4
+ return false;
5
+ const a = [...left].sort((x, y) => x.platform.localeCompare(y.platform));
6
+ const b = [...right].sort((x, y) => x.platform.localeCompare(y.platform));
7
+ return a.every((entry, i) => {
8
+ const other = b[i];
9
+ if (!other || entry.platform !== other.platform)
10
+ return false;
11
+ if (json(entry.metadata) !== json(other.metadata) || json(entry.extra) !== json(other.extra))
12
+ return false;
13
+ // Require positive evidence. Empty/unfinished OTA payloads are NOT equal.
14
+ const x = Array.isArray(entry.assets) ? entry.assets : [];
15
+ const y = Array.isArray(other.assets) ? other.assets : [];
16
+ if (x.length > 0 && y.length > 0)
17
+ return json(x) === json(y);
18
+ return x.length === 0 && y.length === 0 && Boolean(entry.source_hash) && entry.source_hash === other.source_hash;
19
+ });
20
+ };
21
+ const releasePayload = async (client, releaseId) => {
22
+ const result = await client.query(`SELECT u.platform,u.source_hash,
23
+ COALESCE(jsonb_agg(jsonb_build_object('assetKey',ua.asset_key,'sha256',a.sha256,
24
+ 'role',ua.role,'sortOrder',ua.sort_order) ORDER BY ua.asset_key,ua.role,ua.sort_order,a.sha256)
25
+ FILTER (WHERE ua.asset_id IS NOT NULL),'[]'::jsonb) assets,
26
+ COALESCE((u.manifest->'metadata')-'indraqReleaseId','{}'::jsonb) metadata,
27
+ COALESCE((u.manifest->'extra')-'indraq','{}'::jsonb) extra
28
+ FROM ota_updates u
29
+ LEFT JOIN ota_update_assets ua ON ua.update_id=u.id
30
+ LEFT JOIN ota_assets a ON a.id=ua.asset_id
31
+ WHERE u.release_id=$1 AND (u.manifest ? 'launchAsset')
32
+ GROUP BY u.id,u.platform,u.source_hash,u.manifest ORDER BY u.platform`, [releaseId]);
33
+ return result.rows;
34
+ };
35
+ export const recoveryPayloadsMatch = async (client, sourceId, targetId) => identicalRecoveryPayloads(await releasePayload(client, sourceId), await releasePayload(client, targetId));
36
+ //# sourceMappingURL=ota-recovery-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ota-recovery-content.js","sourceRoot":"","sources":["ota-recovery-content.ts"],"names":[],"mappings":"AAYA,MAAM,IAAI,GAAC,CAAC,KAAa,EAAC,EAAE,CAAA,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAC,CAAC,IAAyB,EAAC,KAA0B,EAAS,EAAE;IACrG,IAAG,CAAC,IAAI,CAAC,MAAM,IAAE,IAAI,CAAC,MAAM,KAAG,KAAK,CAAC,MAAM;QAAC,OAAO,KAAK,CAAC;IACzD,MAAM,CAAC,GAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAA,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpE,MAAM,CAAC,GAAC,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAA,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACxB,MAAM,KAAK,GAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjB,IAAG,CAAC,KAAK,IAAE,KAAK,CAAC,QAAQ,KAAG,KAAK,CAAC,QAAQ;YAAC,OAAO,KAAK,CAAC;QACxD,IAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;YAAC,OAAO,KAAK,CAAC;QACnG,0EAA0E;QAC1E,MAAM,CAAC,GAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA,CAAC,CAAA,KAAK,CAAC,MAAM,CAAA,CAAC,CAAA,EAAE,CAAC;QACpD,MAAM,CAAC,GAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA,CAAC,CAAA,KAAK,CAAC,MAAM,CAAA,CAAC,CAAA,EAAE,CAAC;QACpD,IAAG,CAAC,CAAC,MAAM,GAAC,CAAC,IAAI,CAAC,CAAC,MAAM,GAAC,CAAC;YAAC,OAAO,IAAI,CAAC,CAAC,CAAC,KAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,CAAC,CAAC,MAAM,KAAG,CAAC,IAAE,CAAC,CAAC,MAAM,KAAG,CAAC,IAAE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAE,KAAK,CAAC,WAAW,KAAG,KAAK,CAAC,WAAW,CAAC;IACvG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,cAAc,GAAC,KAAK,EAAC,MAA4E,EAAC,SAAgB,EAAC,EAAE;IACzH,MAAM,MAAM,GAAC,MAAM,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;0EAUwC,EAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACtF,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAC,KAAK,EAAC,MAA4E,EAAC,QAAe,EAAC,QAAe,EAAkB,EAAE,CACvK,yBAAyB,CAAC,MAAM,cAAc,CAAC,MAAM,EAAC,QAAQ,CAAC,EAAC,MAAM,cAAc,CAAC,MAAM,EAAC,QAAQ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** Expo Updates v1 directives require a multipart response. application/expo+json
2
+ * cannot represent a rollBackToEmbedded directive. The part must be signed
3
+ * using the same key as normal manifest payloads. */
4
+ export const embeddedDirective = (createdAt) => ({
5
+ type: 'rollBackToEmbedded',
6
+ parameters: { commitTime: createdAt }
7
+ });
8
+ export const multipartDirective = (directive, signature, seed = 'indraq-ota') => {
9
+ const boundary = `${seed.replace(/[^A-Za-z0-9_-]/g, '').slice(0, 60)}`;
10
+ const json = JSON.stringify(directive);
11
+ const signatureHeader = signature ? `expo-signature: ${signature}\r\n` : '';
12
+ return {
13
+ contentType: `multipart/mixed; boundary=${boundary}`,
14
+ body: `--${boundary}\r\ncontent-disposition: form-data; name="directive"\r\ncontent-type: application/json; charset=utf-8\r\n${signatureHeader}\r\n${json}\r\n--${boundary}--\r\n`
15
+ };
16
+ };
@@ -0,0 +1,25 @@
1
+ export const mayFinalize = (s) => s === 'draft';
2
+ export const mayPromote = (s, promotedAt) => s === 'test' || (s === 'paused' && !promotedAt);
3
+ export const mayPause = (s) => s === 'test' || s === 'released';
4
+ export const mayRollback = (s) => s === 'released';
5
+ export const mayWithdraw = (s, promotedAt) => s === 'test' || (s === 'paused' && !promotedAt);
6
+ /** Retain published assets indefinitely under Expo's immutable URL contract.
7
+ * GC is limited to unreferenced uploads (e.g. abandoned draft retries). */
8
+ export const canCollectAsset = (createdAt, referenced, now = new Date(), graceDays = 7) => !referenced && Number.isFinite(createdAt.getTime()) && createdAt.getTime() <= now.getTime() - graceDays * 86400000;
9
+ export const recoveryTargetsAreCompatible = (source, target) => source.app_id === target.app_id && source.mobile_environment_id === target.mobile_environment_id && source.runtime_version === target.runtime_version;
10
+ /** Conservative OTA audience intersection. Only a proven-disjoint pair of
11
+ * stable, server-verified device lists, group IDs or installation IDs can avoid
12
+ * blocking a concurrent recovery. Mixed/unknown selectors always overlap. */
13
+ export const otaAudiencesMayOverlap = (a, b) => {
14
+ if (a.audience_type !== 'test' || b.audience_type !== 'test')
15
+ return true;
16
+ const keys = ['deviceIds', 'groupIds', 'identities'];
17
+ const inspect = (r) => keys.filter(k => Array.isArray(r.audience?.[k]) && r.audience[k].length > 0);
18
+ const ak = inspect(a), bk = inspect(b);
19
+ if (ak.length !== 1 || bk.length !== 1 || ak[0] !== bk[0])
20
+ return true;
21
+ const k = ak[0];
22
+ const normalize = (v) => k === 'identities' ? `${v.type}:${String(v.value || '').toLowerCase()}` : String(v).toLowerCase();
23
+ const left = new Set(a.audience[k].map(normalize));
24
+ return b.audience[k].some((v) => left.has(normalize(v)));
25
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ota-release-policy.js","sourceRoot":"","sources":["ota-release-policy.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAC,CAAC,CAAe,EAAS,EAAE,CAAA,CAAC,KAAG,OAAO,CAAC;AAChE,MAAM,CAAC,MAAM,UAAU,GAAC,CAAC,CAAe,EAAC,UAAsB,EAAS,EAAE,CAAA,CAAC,KAAG,MAAM,IAAE,CAAC,CAAC,KAAG,QAAQ,IAAE,CAAC,UAAU,CAAC,CAAC;AAClH,MAAM,CAAC,MAAM,QAAQ,GAAC,CAAC,CAAe,EAAS,EAAE,CAAA,CAAC,KAAG,MAAM,IAAE,CAAC,KAAG,UAAU,CAAC;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAC,CAAC,CAAe,EAAS,EAAE,CAAA,CAAC,KAAG,UAAU,CAAC;AACnE,MAAM,CAAC,MAAM,WAAW,GAAC,CAAC,CAAe,EAAC,UAAsB,EAAS,EAAE,CAAA,CAAC,KAAG,MAAM,IAAE,CAAC,CAAC,KAAG,QAAQ,IAAE,CAAC,UAAU,CAAC,CAAC;AACnH;2EAC2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAC,CAAC,SAAc,EAAC,UAAkB,EAAC,GAAG,GAAC,IAAI,IAAI,EAAE,EAAC,SAAS,GAAC,CAAC,EAAS,EAAE,CACnG,CAAC,UAAU,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,IAAE,GA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C,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAE,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAA,CAAC,CAAA,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACnH,MAAM,IAAI,GAAC,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAK,EAAC,EAAE,CAAA,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC","sourcesContent":["/** Server-side OTA lifecycle guards. The public CLI must not be the only policy gate. */\nexport type ReleaseStatus = 'draft'|'test'|'released'|'paused'|'rolled_back'|'withdrawn';\nexport const mayFinalize=(s:ReleaseStatus):boolean=>s==='draft';\nexport const mayPromote=(s:ReleaseStatus,promotedAt:string|null):boolean=>s==='test'||(s==='paused'&&!promotedAt);\nexport const mayPause=(s:ReleaseStatus):boolean=>s==='test'||s==='released';\nexport const mayRollback=(s:ReleaseStatus):boolean=>s==='released';\nexport const mayWithdraw=(s:ReleaseStatus,promotedAt:string|null):boolean=>s==='test'||(s==='paused'&&!promotedAt);\n/** Retain published assets indefinitely under Expo's immutable URL contract.\n * GC is limited to unreferenced uploads (e.g. abandoned draft retries). */\nexport const canCollectAsset=(createdAt:Date,referenced:boolean,now=new Date(),graceDays=7):boolean=>\n !referenced && Number.isFinite(createdAt.getTime()) && createdAt.getTime()<=now.getTime()-graceDays*86400000;\nexport const recoveryTargetsAreCompatible=(source:{app_id:string;mobile_environment_id:string;runtime_version:string},target:{app_id:string;mobile_environment_id:string;runtime_version:string}):boolean=>\n source.app_id===target.app_id && source.mobile_environment_id===target.mobile_environment_id && source.runtime_version===target.runtime_version;\n\n/** Conservative OTA audience intersection. Only a proven-disjoint pair of\n * stable, server-verified device lists, group IDs or installation IDs can avoid\n * blocking a concurrent recovery. Mixed/unknown selectors always overlap. */\nexport const otaAudiencesMayOverlap=(a:{audience_type:string;audience?:any},b:{audience_type:string;audience?:any}):boolean=>{\n if(a.audience_type!=='test'||b.audience_type!=='test')return true;\n const keys=['deviceIds','groupIds','identities'] as const;\n const inspect=(r:typeof a)=>keys.filter(k=>Array.isArray(r.audience?.[k])&&r.audience[k].length>0);\n const ak=inspect(a),bk=inspect(b);\n if(ak.length!==1||bk.length!==1||ak[0]!==bk[0])return true;\n const k=ak[0]!;\n const normalize=(v:any)=>k==='identities'?`${v.type}:${String(v.value||'').toLowerCase()}`:String(v).toLowerCase();\n const left=new Set(a.audience[k].map(normalize));\n return b.audience[k].some((v:any)=>left.has(normalize(v)));\n};\n"]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@indraq/cloud-api",
3
3
  "private": true,
4
- "version": "1.3.7",
4
+ "version": "1.7.3",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "tsx watch src/index.ts",
Binary file
@@ -0,0 +1,23 @@
1
+ -- v2.9: Persistent tester profiles across builds and explicit testing withdrawal.
2
+ -- A registered tester is an ACCOUNT identity, not an Android hardware identifier.
3
+ -- Each app sandbox must still securely associate its own installation via a one-use invite.
4
+ CREATE TABLE IF NOT EXISTS ota_registered_tester_devices (
5
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
6
+ owner_user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
7
+ label text NOT NULL CHECK (length(trim(label)) BETWEEN 1 AND 80),
8
+ created_at timestamptz NOT NULL DEFAULT now(),
9
+ revoked_at timestamptz,
10
+ UNIQUE (id, owner_user_id)
11
+ );
12
+ CREATE INDEX IF NOT EXISTS ota_registered_tester_devices_owner_idx ON ota_registered_tester_devices(owner_user_id,created_at DESC);
13
+ CREATE TABLE IF NOT EXISTS ota_registered_device_installations (
14
+ device_id uuid NOT NULL REFERENCES ota_registered_tester_devices(id) ON DELETE CASCADE,
15
+ app_id uuid NOT NULL,
16
+ installation_id text NOT NULL,
17
+ linked_at timestamptz NOT NULL DEFAULT now(),
18
+ PRIMARY KEY (app_id,installation_id),
19
+ FOREIGN KEY (app_id,installation_id) REFERENCES ota_tester_installations(app_id,installation_id) ON DELETE CASCADE
20
+ );
21
+ ALTER TABLE ota_enrollment_invitations ADD COLUMN IF NOT EXISTS registered_device_id uuid REFERENCES ota_registered_tester_devices(id);
22
+ ALTER TABLE ota_releases DROP CONSTRAINT IF EXISTS ota_releases_status_check;
23
+ ALTER TABLE ota_releases ADD CONSTRAINT ota_releases_status_check CHECK (status IN ('draft','test','released','paused','rolled_back','withdrawn'));
@@ -0,0 +1,19 @@
1
+ -- Verified browser-backed tester authorization. This is not a hardware/UDID attestation.
2
+ -- Existing v2.9 profile-only entries stay unverified until the owner initiates and completes a challenge.
3
+ ALTER TABLE ota_registered_tester_devices
4
+ ADD COLUMN IF NOT EXISTS verified_at timestamptz,
5
+ ADD COLUMN IF NOT EXISTS browser_credential_hash text;
6
+
7
+ CREATE TABLE IF NOT EXISTS ota_device_registration_challenges (
8
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
9
+ device_id uuid NOT NULL REFERENCES ota_registered_tester_devices(id) ON DELETE CASCADE,
10
+ token_hash text NOT NULL UNIQUE,
11
+ created_at timestamptz NOT NULL DEFAULT now(),
12
+ expires_at timestamptz NOT NULL,
13
+ completed_at timestamptz
14
+ );
15
+ CREATE INDEX IF NOT EXISTS ota_device_registration_challenges_device_idx
16
+ ON ota_device_registration_challenges(device_id, created_at DESC);
17
+
18
+ ALTER TABLE ota_enrollment_invitations
19
+ ADD COLUMN IF NOT EXISTS browser_approved_at timestamptz;
@@ -0,0 +1,18 @@
1
+ -- IndraQ v2.9.3 — Pre-authorize verified device profiles for apps independently of APK/runtime.
2
+ -- A grant is an entitlement, never proof that a particular installation belongs to that device.
3
+ -- OTA delivery still requires an installation bound by a verified one-time enrollment.
4
+ CREATE TABLE IF NOT EXISTS ota_device_app_grants (
5
+ device_id uuid NOT NULL REFERENCES ota_registered_tester_devices(id) ON DELETE CASCADE,
6
+ app_id uuid NOT NULL REFERENCES mobile_apps(id) ON DELETE CASCADE,
7
+ granted_by uuid NOT NULL REFERENCES users(id),
8
+ granted_at timestamptz NOT NULL DEFAULT now(),
9
+ revoked_at timestamptz,
10
+ PRIMARY KEY (device_id,app_id)
11
+ );
12
+ CREATE INDEX IF NOT EXISTS ota_device_app_grants_app_idx ON ota_device_app_grants(app_id,revoked_at);
13
+ -- Preserve prior verified pairings when migrating from earlier versions.
14
+ INSERT INTO ota_device_app_grants(device_id,app_id,granted_by)
15
+ SELECT DISTINCT l.device_id,l.app_id,d.owner_user_id
16
+ FROM ota_registered_device_installations l
17
+ JOIN ota_registered_tester_devices d ON d.id=l.device_id
18
+ ON CONFLICT(device_id,app_id) DO NOTHING;
@@ -0,0 +1,24 @@
1
+ -- Cryptographic, installation-independent Android tester identity.
2
+ -- Agent remains installed while individual test APKs are uninstalled.
3
+ ALTER TABLE ota_registered_tester_devices ADD COLUMN IF NOT EXISTS agent_public_key text;
4
+ ALTER TABLE ota_registered_tester_devices ADD COLUMN IF NOT EXISTS agent_activated_at timestamptz;
5
+ CREATE TABLE IF NOT EXISTS ota_device_agent_activations (
6
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
7
+ device_id uuid NOT NULL REFERENCES ota_registered_tester_devices(id) ON DELETE CASCADE,
8
+ token_hash text NOT NULL UNIQUE,
9
+ created_at timestamptz NOT NULL DEFAULT now(),
10
+ expires_at timestamptz NOT NULL,
11
+ redeemed_at timestamptz
12
+ );
13
+ CREATE INDEX IF NOT EXISTS ota_device_agent_activations_device_idx ON ota_device_agent_activations(device_id,created_at DESC);
14
+ CREATE TABLE IF NOT EXISTS ota_device_agent_challenges (
15
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
16
+ app_id uuid NOT NULL REFERENCES mobile_apps(id) ON DELETE CASCADE,
17
+ installation_id text NOT NULL,
18
+ nonce text NOT NULL,
19
+ created_at timestamptz NOT NULL DEFAULT now(),
20
+ expires_at timestamptz NOT NULL,
21
+ redeemed_at timestamptz,
22
+ FOREIGN KEY (app_id,installation_id) REFERENCES ota_installations(app_id,installation_id) ON DELETE CASCADE
23
+ );
24
+ CREATE INDEX IF NOT EXISTS ota_device_agent_challenges_install_idx ON ota_device_agent_challenges(app_id,installation_id,created_at DESC);
@@ -0,0 +1,9 @@
1
+ -- Lower-assurance internal Android tester matching. NOT cryptographic device authentication.
2
+ -- Only a verified browser pairing can bind an ID; API never exposes the value.
3
+ CREATE TABLE IF NOT EXISTS ota_android_scoped_tester_identities (
4
+ device_id uuid NOT NULL REFERENCES ota_registered_tester_devices(id) ON DELETE CASCADE,
5
+ identity_digest char(64) NOT NULL UNIQUE,
6
+ bound_at timestamptz NOT NULL DEFAULT now(),
7
+ PRIMARY KEY (device_id, identity_digest)
8
+ );
9
+ CREATE INDEX IF NOT EXISTS ota_android_scoped_tester_identities_device_idx ON ota_android_scoped_tester_identities(device_id);
@@ -0,0 +1,21 @@
1
+ -- v1.6.0: Recovery is a new scoped release, never a mutation of a published manifest.
2
+ -- The native embedded JS is already inside each installed binary; we retain build
3
+ -- metadata and emit a signed Expo Updates directive rather than uploading a copy.
4
+ ALTER TABLE ota_releases ADD COLUMN IF NOT EXISTS recovery_kind text NOT NULL DEFAULT 'assets';
5
+ ALTER TABLE ota_releases ADD COLUMN IF NOT EXISTS recovery_of uuid REFERENCES ota_releases(id) ON DELETE SET NULL;
6
+ ALTER TABLE ota_releases ADD COLUMN IF NOT EXISTS recovery_target_id uuid REFERENCES ota_releases(id) ON DELETE SET NULL;
7
+ ALTER TABLE ota_releases ADD COLUMN IF NOT EXISTS deployment_group_id uuid;
8
+ ALTER TABLE ota_releases ADD COLUMN IF NOT EXISTS is_pinned boolean NOT NULL DEFAULT false;
9
+ ALTER TABLE ota_releases ADD COLUMN IF NOT EXISTS verified_at timestamptz;
10
+ ALTER TABLE ota_releases DROP CONSTRAINT IF EXISTS ota_releases_recovery_kind_check;
11
+ ALTER TABLE ota_releases ADD CONSTRAINT ota_releases_recovery_kind_check CHECK (recovery_kind IN ('assets','embedded'));
12
+ CREATE INDEX IF NOT EXISTS ota_releases_deployment_group_idx ON ota_releases(app_id,deployment_group_id) WHERE deployment_group_id IS NOT NULL;
13
+ CREATE INDEX IF NOT EXISTS ota_assets_created_idx ON ota_assets(created_at);
14
+ -- Published asset URLs are immutable; do NOT cascade-delete referenced OTA assets.
15
+ -- Unreferenced objects can be deleted after a grace period, if no published
16
+ -- manifest ever referenced them. See the storage cleanup endpoint.
17
+ -- Existing Jenkins native history is Android-only. An iOS release must have an
18
+ -- independently verified iOS build record before Cloud accepts iOS manifests.
19
+ ALTER TABLE mobile_native_builds ADD COLUMN IF NOT EXISTS platform text NOT NULL DEFAULT 'android';
20
+ ALTER TABLE mobile_native_builds DROP CONSTRAINT IF EXISTS mobile_native_builds_platform_check;
21
+ ALTER TABLE mobile_native_builds ADD CONSTRAINT mobile_native_builds_platform_check CHECK (platform IN ('android','ios'));
@@ -0,0 +1,14 @@
1
+ -- Explicit, audited owner-confirmed consolidation of duplicate registered tester profiles.
2
+ -- Never infer physical sameness from label, IP, Android ID, or user agent.
3
+ -- Historical OTA release audiences may contain the retired ID. The manifest
4
+ -- resolver maps it to the surviving profile without editing published releases.
5
+ CREATE TABLE IF NOT EXISTS ota_tester_device_profile_aliases (
6
+ duplicate_device_id uuid PRIMARY KEY REFERENCES ota_registered_tester_devices(id),
7
+ canonical_device_id uuid NOT NULL REFERENCES ota_registered_tester_devices(id),
8
+ merged_by uuid NOT NULL REFERENCES users(id),
9
+ merged_at timestamptz NOT NULL DEFAULT now(),
10
+ reason text NOT NULL,
11
+ CHECK (duplicate_device_id <> canonical_device_id)
12
+ );
13
+ CREATE INDEX IF NOT EXISTS ota_tester_device_profile_aliases_primary_idx
14
+ ON ota_tester_device_profile_aliases(canonical_device_id);