diff options
Diffstat (limited to 'packages/meshbay-android/app/src/main/assets')
| -rw-r--r-- | packages/meshbay-android/app/src/main/assets/bridge/meshbay-bridge.js | 111 |
1 files changed, 107 insertions, 4 deletions
diff --git a/packages/meshbay-android/app/src/main/assets/bridge/meshbay-bridge.js b/packages/meshbay-android/app/src/main/assets/bridge/meshbay-bridge.js index 82e556d..a07399f 100644 --- a/packages/meshbay-android/app/src/main/assets/bridge/meshbay-bridge.js +++ b/packages/meshbay-android/app/src/main/assets/bridge/meshbay-bridge.js @@ -15,10 +15,12 @@ * that refuses: `platform.js` decides what to show from whether an object * exists (`platform.node.available`, `platform.folder.available`, …). * - * `HUB_BASE`, `BINARY` and `CAST` are prepended by the shell when it injects - * this file: the interface asks for the hub while its modules load, before - * anything can await; BINARY says whether the WebView carries ArrayBuffer - * messages; CAST whether this device can cast at all. + * `HUB_BASE`, `BINARY`, `CAST`, `BACKUP` and `MESSAGES` are prepended by the + * shell when it injects this file: the interface asks for the hub while its + * modules load, before anything can await; BINARY says whether the WebView carries ArrayBuffer + * messages; CAST whether this device can cast at all; BACKUP whether this is + * the personal profile, the only one backed up; MESSAGES whether this build + * backs text messages up (not the Play build). */ (function () { 'use strict'; @@ -197,6 +199,107 @@ call('push:remember', subscription, account, secret, since), }, + // Backups (§9.12, §9.13), of the personal profile only: a copy of the + // application inside a work profile has none of these (Profiles.kt). + ...(BACKUP ? { + // Photo backup (§9.12): the phone lists its photos, keeps what was sent, + // and hands each photo's bytes over at /photosync/<token> on this origin. + // The page decides when and does the sending. Phone-only, like `push`. + photoSync: { + status: () => call('photosync:status'), + permit: (withVideos) => call('photosync:permit', withVideos === true), + albums: (withVideos) => call('photosync:albums', withVideos === true), + configure: (settings) => call('photosync:configure', settings || null), + estimate: (settings) => call('photosync:estimate', settings), + plan: () => call('photosync:plan'), + sent: (token, dir, name) => call('photosync:sent', token, dir, name), + manifest: () => call('photosync:manifest'), + manifestSent: (token) => call('photosync:manifest-sent', token), + completed: () => call('photosync:completed'), + failed: (code, text) => call('photosync:failed', code, text), + keepAlive: (on, text) => call('photosync:keep-alive', on === true, text || ''), + }, + + // Where every backup goes (§9.12): one folder of one group the account + // owns and is alone in. Each kind goes into `<account>-<kind>` under it. + phoneSync: { + destination: () => call('phonesync:destination'), + setDestination: (d) => call('phonesync:set-destination', d || null), + }, + + // Contacts backup (§9.13): the phone writes the address book into one + // file, served at /phonesync/<token> on this origin, when it changed since + // the last one sent. The page decides when and does the sending. + contactSync: { + status: () => call('contactsync:status'), + permit: () => call('contactsync:permit'), + configure: (settings) => call('contactsync:configure', settings || null), + plan: () => call('contactsync:plan'), + sent: (token, dir, name) => call('contactsync:sent', token, dir, name), + completed: () => call('contactsync:completed'), + failed: (code, text) => call('contactsync:failed', code, text), + openSettings: () => call('contactsync:open-settings'), + }, + + // Calendar backup (§9.13), the same way: one iCalendar file of every + // calendar the person can write to, when it changed. + calendarSync: { + status: () => call('calendarsync:status'), + permit: () => call('calendarsync:permit'), + configure: (settings) => call('calendarsync:configure', settings || null), + plan: () => call('calendarsync:plan'), + sent: (token, dir, name) => call('calendarsync:sent', token, dir, name), + completed: () => call('calendarsync:completed'), + failed: (code, text) => call('calendarsync:failed', code, text), + openSettings: () => call('calendarsync:open-settings'), + }, + + // Files backup (§9.13): folders the person chose through the system's + // picker, sent like photos, a range at a time from /drivesync/<token>. + driveSync: { + status: () => call('drivesync:status'), + addFolder: () => call('drivesync:add-folder'), + removeFolder: (id) => call('drivesync:remove-folder', id), + configure: (settings) => call('drivesync:configure', settings || null), + plan: () => call('drivesync:plan'), + sent: (token, dir, name) => call('drivesync:sent', token, dir, name), + manifest: () => call('drivesync:manifest'), + manifestSent: (token) => call('drivesync:manifest-sent', token), + completed: () => call('drivesync:completed'), + failed: (code, text) => call('drivesync:failed', code, text), + keepAlive: (on, text) => call('drivesync:keep-alive', on === true, text || ''), + }, + + // WhatsApp's own folder (§9.13), the same way: its encrypted chat + // backups for a restore, and its media if the person ticks them. + whatsappSync: { + status: () => call('wasync:status'), + chooseFolder: () => call('wasync:add-folder'), + forgetFolder: (id) => call('wasync:remove-folder', id), + configure: (settings) => call('wasync:configure', settings || null), + plan: () => call('wasync:plan'), + sent: (token, dir, name) => call('wasync:sent', token, dir, name), + manifest: () => call('wasync:manifest'), + manifestSent: (token) => call('wasync:manifest-sent', token), + completed: () => call('wasync:completed'), + failed: (code, text) => call('wasync:failed', code, text), + keepAlive: (on, text) => call('wasync:keep-alive', on === true, text || ''), + }, + } : {}), + + // Messages backup (§9.13), the same way as contacts: the messages added + // since the last file the node took. Only in a build that may read them. + ...(MESSAGES ? { messageSync: { + status: () => call('messagesync:status'), + permit: () => call('messagesync:permit'), + configure: (settings) => call('messagesync:configure', settings || null), + plan: () => call('messagesync:plan'), + sent: (token, dir, name) => call('messagesync:sent', token, dir, name), + completed: () => call('messagesync:completed'), + failed: (code, text) => call('messagesync:failed', code, text), + openSettings: () => call('messagesync:open-settings'), + } } : {}), + // Where downloads go, chosen once. A display name comes back, never a URI. folder: { choose: () => call('folder:choose'), |