@robono/messaging-react-native 0.23.0 → 0.25.0

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 (132) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +157 -4
  3. package/RobonoMessagingRuntime.podspec +16 -0
  4. package/SBOM.spdx.json +2709 -813
  5. package/android/build.gradle +10 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/java/com/robono/messaging/RobonoBackupCrypto.java +27 -0
  8. package/android/src/main/java/com/robono/messaging/RobonoBackupGoogle.java +76 -0
  9. package/android/src/main/java/com/robono/messaging/RobonoHistoryStore.java +173 -0
  10. package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +11 -0
  11. package/app.plugin.cjs +22 -3
  12. package/cloudkit/backup-schema.ckdb +13 -0
  13. package/dist/account-pages.d.ts +51 -0
  14. package/dist/account-pages.js +65 -0
  15. package/dist/account.d.ts +6 -2
  16. package/dist/account.js +37 -11
  17. package/dist/attachment-preview.d.ts +11 -10
  18. package/dist/attachment-preview.js +15 -12
  19. package/dist/backup-background.d.ts +25 -0
  20. package/dist/backup-background.js +71 -0
  21. package/dist/backup-base64.d.ts +3 -0
  22. package/dist/backup-base64.js +41 -0
  23. package/dist/backup-google-authorization.d.ts +23 -0
  24. package/dist/backup-google-authorization.js +95 -0
  25. package/dist/backup.d.ts +24 -0
  26. package/dist/backup.js +202 -0
  27. package/dist/brand.js +4 -4
  28. package/dist/bubble-design.d.ts +1 -1
  29. package/dist/bubble-design.js +5 -3
  30. package/dist/cloudkit-backup.d.ts +14 -0
  31. package/dist/cloudkit-backup.js +193 -0
  32. package/dist/contact-directory.d.ts +3 -1
  33. package/dist/contact-directory.js +3 -3
  34. package/dist/conversation-details.js +2 -2
  35. package/dist/customization.d.ts +1 -0
  36. package/dist/delivery-bar.d.ts +3 -2
  37. package/dist/delivery-bar.js +7 -4
  38. package/dist/delivery-notice.d.ts +9 -0
  39. package/dist/delivery-notice.js +15 -0
  40. package/dist/directory-navigation.d.ts +25 -0
  41. package/dist/directory-navigation.js +69 -0
  42. package/dist/expo-backup-background.d.ts +17 -0
  43. package/dist/expo-backup-background.js +57 -0
  44. package/dist/expo-backup-cloudkit.d.ts +6 -0
  45. package/dist/expo-backup-cloudkit.js +11 -0
  46. package/dist/expo-backup-crypto.d.ts +3 -0
  47. package/dist/expo-backup-crypto.js +17 -0
  48. package/dist/expo-backup-google.d.ts +7 -0
  49. package/dist/expo-backup-google.js +16 -0
  50. package/dist/expo-backup-network.d.ts +8 -0
  51. package/dist/expo-backup-network.js +18 -0
  52. package/dist/expo-backup-passkeys.d.ts +14 -0
  53. package/dist/expo-backup-passkeys.js +46 -0
  54. package/dist/expo-backup-settings.d.ts +4 -0
  55. package/dist/expo-backup-settings.js +59 -0
  56. package/dist/expo-backup.d.ts +14 -0
  57. package/dist/expo-backup.js +22 -0
  58. package/dist/expo-bridge.d.ts +2 -0
  59. package/dist/expo-bridge.js +3 -1
  60. package/dist/expo-cache.js +20 -1
  61. package/dist/expo-device-history.d.ts +24 -0
  62. package/dist/expo-device-history.js +88 -0
  63. package/dist/expo-durable-history.d.ts +26 -0
  64. package/dist/expo-durable-history.js +56 -0
  65. package/dist/expo-history-backup.d.ts +3 -0
  66. package/dist/expo-history-backup.js +79 -0
  67. package/dist/expo-history-maintenance.d.ts +4 -0
  68. package/dist/expo-history-maintenance.js +23 -0
  69. package/dist/expo-history-previews.d.ts +5 -0
  70. package/dist/expo-history-previews.js +57 -0
  71. package/dist/expo-history.d.ts +1 -1
  72. package/dist/expo-history.js +2 -2
  73. package/dist/expo-inbox-preferences.d.ts +3 -0
  74. package/dist/expo-inbox-preferences.js +9 -0
  75. package/dist/expo-media.d.ts +2 -0
  76. package/dist/expo-media.js +18 -24
  77. package/dist/expo-messenger.d.ts +8 -0
  78. package/dist/expo-messenger.js +27 -11
  79. package/dist/expo-notifications.d.ts +17 -1
  80. package/dist/expo-notifications.js +36 -16
  81. package/dist/expo-outbox.d.ts +2 -0
  82. package/dist/expo-outbox.js +1 -1
  83. package/dist/expo-oversight.d.ts +15 -0
  84. package/dist/expo-oversight.js +15 -0
  85. package/dist/expo-reviews.d.ts +6 -0
  86. package/dist/expo-reviews.js +145 -0
  87. package/dist/expo-screen.js +62 -28
  88. package/dist/expo-thumbnails.d.ts +6 -2
  89. package/dist/expo-thumbnails.js +73 -8
  90. package/dist/expo.d.ts +14 -0
  91. package/dist/expo.js +12 -0
  92. package/dist/forward.js +2 -2
  93. package/dist/header-calls.js +1 -1
  94. package/dist/header-colors.d.ts +5 -0
  95. package/dist/header-colors.js +7 -0
  96. package/dist/inbox-search.d.ts +1 -1
  97. package/dist/inbox-search.js +7 -3
  98. package/dist/inbox.d.ts +6 -2
  99. package/dist/inbox.js +27 -55
  100. package/dist/index.d.ts +14 -6
  101. package/dist/index.js +195 -78
  102. package/dist/linked-apps.d.ts +45 -0
  103. package/dist/linked-apps.js +40 -0
  104. package/dist/loading-messages.d.ts +5 -0
  105. package/dist/loading-messages.js +10 -0
  106. package/dist/media-access.d.ts +8 -0
  107. package/dist/media-access.js +6 -1
  108. package/dist/media-controller.d.ts +2 -0
  109. package/dist/native-history-authorization.d.ts +4 -0
  110. package/dist/native-history-authorization.js +69 -0
  111. package/dist/native-history-backup.d.ts +16 -0
  112. package/dist/native-history-backup.js +144 -0
  113. package/dist/native-history.d.ts +14 -0
  114. package/dist/native-history.js +186 -0
  115. package/dist/native-outbox.d.ts +2 -0
  116. package/dist/oversight-session.d.ts +4 -0
  117. package/dist/oversight-session.js +14 -0
  118. package/dist/popup.d.ts +6 -3
  119. package/dist/popup.js +6 -6
  120. package/dist/preview-layout.d.ts +12 -0
  121. package/dist/preview-layout.js +102 -0
  122. package/dist/recent-media.js +2 -1
  123. package/dist/reviews.d.ts +19 -0
  124. package/dist/reviews.js +231 -0
  125. package/dist/scheduled.js +6 -6
  126. package/dist/search.js +18 -8
  127. package/ios/RobonoBackupCloudKit.m +96 -0
  128. package/ios/RobonoBackupCrypto.m +30 -0
  129. package/ios/RobonoHistoryStore.m +170 -0
  130. package/package.json +34 -7
  131. package/plugin/backup-expiration.cjs +23 -0
  132. package/plugin/prepare-native.cjs +12 -0
@@ -1,7 +1,9 @@
1
1
  export function bubbleCorners(appearance, mine, caption = false) {
2
- const radius = appearance.presentation?.bubbleShape === 'square' ? 0 : appearance.presentation?.bubbleShape === 'rounded' ? 16 : 8;
3
- const emphasized = appearance.presentation?.bubbleStyle === 'rounded-corner' ? Math.max(28, radius) : radius;
4
- return { borderTopLeftRadius: radius, borderTopRightRadius: radius, borderBottomLeftRadius: caption ? 0 : mine ? radius : emphasized, borderBottomRightRadius: caption ? 0 : mine ? emphasized : radius };
2
+ // Match the original Messenger: 14px body, 3px sender-side bottom corner.
3
+ const senderCorner = appearance.presentation?.bubbleStyle === 'rounded-corner';
4
+ const radius = appearance.presentation?.bubbleShape === 'square' ? 0 : appearance.presentation?.bubbleShape === 'rounded' ? 16 : senderCorner ? 14 : 8;
5
+ const tail = senderCorner ? Math.min(3, radius) : radius;
6
+ return { borderTopLeftRadius: radius, borderTopRightRadius: radius, borderBottomLeftRadius: caption ? 0 : mine ? radius : tail, borderBottomRightRadius: caption ? 0 : mine ? tail : radius };
5
7
  }
6
8
  export function bubbleDelivery(message, pending, receipts, appearance) {
7
9
  const phase = pending === 'failed' || message.delivery?.state === 'failed' ? 'failed' : pending || message.delivery?.state === 'pending' ? 'sent' : receipts && !!message.readAt ? 'consumed' : 'delivered';
@@ -0,0 +1,14 @@
1
+ import { type MessagingBackupCloud } from '@robono/messaging';
2
+ export interface MessagingCloudKitTransport {
3
+ request(id: string, input: Record<string, unknown>): Promise<any>;
4
+ cancel(id: string): void | Promise<void>;
5
+ }
6
+ /** Private CloudKit adapter. The native transport resolves writes/deletes only
7
+ * after Apple's server completion, not when a CKAsset file is staged locally. */
8
+ export declare function createCloudKitMessagingBackupCloud(options: {
9
+ container: string;
10
+ transport: MessagingCloudKitTransport;
11
+ randomId: () => string;
12
+ openSettings: () => Promise<void>;
13
+ retainedSnapshots?: number;
14
+ }): MessagingBackupCloud;
@@ -0,0 +1,193 @@
1
+ import { MessagingBackupError, withMessagingDeadline } from '@robono/messaging';
2
+ import { encodeBackupBase64, decodeBackupBase64 } from './backup-base64.js';
3
+ const valid = (scope, snapshot, part) => {
4
+ if (!/^[a-f0-9]{64}$/.test(scope) || snapshot !== undefined && !/^[a-f0-9]{32}$/.test(snapshot) || part !== undefined && !/^(manifest|protection|commit|\d{1,6})$/.test(part))
5
+ throw new MessagingBackupError('invalid_backup');
6
+ };
7
+ const limit = (part) => part === 'manifest' ? 16 * 1024 * 1024 + 28 : ['commit', 'protection'].includes(part) ? 8192 : 4 * 1024 * 1024 + 28;
8
+ /** Private CloudKit adapter. The native transport resolves writes/deletes only
9
+ * after Apple's server completion, not when a CKAsset file is staged locally. */
10
+ export function createCloudKitMessagingBackupCloud(options) {
11
+ if (!/^iCloud\.[A-Za-z0-9.-]{1,180}$/.test(options.container))
12
+ throw new MessagingBackupError('unavailable');
13
+ const retained = options.retainedSnapshots ?? 2;
14
+ if (!Number.isInteger(retained) || retained < 2 || retained > 10)
15
+ throw new MessagingBackupError('invalid_backup');
16
+ const identities = new WeakMap(), snapshots = new Map(), uploads = new Map();
17
+ const invoke = async (input, signal) => {
18
+ const id = options.randomId();
19
+ if (signal.aborted)
20
+ throw new MessagingBackupError('cancelled');
21
+ const abort = () => { void Promise.resolve().then(() => options.transport.cancel(id)).catch(() => { }); };
22
+ signal.addEventListener('abort', abort, { once: true });
23
+ try {
24
+ const result = await options.transport.request(id, { ...input, container: options.container });
25
+ if (signal.aborted)
26
+ throw new MessagingBackupError('cancelled');
27
+ return result;
28
+ }
29
+ catch (e) {
30
+ if (signal.aborted)
31
+ throw new MessagingBackupError('cancelled');
32
+ if (e instanceof MessagingBackupError)
33
+ throw e;
34
+ throw new MessagingBackupError(['cancelled', 'invalid_backup', 'storage_full', 'unavailable'].includes(e?.code) ? e.code : 'connection');
35
+ }
36
+ finally {
37
+ signal.removeEventListener('abort', abort);
38
+ }
39
+ };
40
+ const run = async (parent, task, timeout = 120000) => {
41
+ try {
42
+ return await withMessagingDeadline(task, { signal: parent, timeoutMs: timeout });
43
+ }
44
+ catch (e) {
45
+ if (parent.aborted)
46
+ throw new MessagingBackupError('cancelled');
47
+ if (e instanceof MessagingBackupError)
48
+ throw e;
49
+ throw new MessagingBackupError('connection');
50
+ }
51
+ };
52
+ const account = async (signal) => {
53
+ const value = await invoke({ action: 'account' }, signal);
54
+ if (value === null)
55
+ return null;
56
+ if (!value || !/^[a-f0-9]{64}$/.test(value.id) || value.provider !== 'icloud')
57
+ throw new MessagingBackupError('connection');
58
+ const previous = identities.get(signal);
59
+ if (previous && previous !== value.id)
60
+ throw new MessagingBackupError('connection');
61
+ identities.set(signal, value.id);
62
+ return { id: value.id, label: 'iCloud', provider: 'icloud' };
63
+ };
64
+ const request = async (action, scope, signal, extra = {}) => {
65
+ valid(scope, extra.snapshot, extra.part);
66
+ const owner = await account(signal);
67
+ if (!owner)
68
+ throw new MessagingBackupError('connection');
69
+ if (extra.snapshot) {
70
+ const key = scope + ':' + extra.snapshot, previous = snapshots.get(key);
71
+ if (previous && previous !== owner.id)
72
+ throw new MessagingBackupError('connection');
73
+ snapshots.set(key, owner.id);
74
+ }
75
+ return invoke({ ...extra, action, scope, account: owner.id }, signal);
76
+ };
77
+ const list = async (scope, signal) => {
78
+ const parts = [], seen = new Set(), cursors = new Set();
79
+ let cursor;
80
+ do {
81
+ const result = await request('list', scope, signal, cursor ? { cursor } : {});
82
+ if (!Array.isArray(result?.files) || result.files.length > 200)
83
+ throw new MessagingBackupError('invalid_backup');
84
+ for (const p of result.files) {
85
+ if (typeof p?.snapshot !== 'string' || typeof p?.part !== 'string')
86
+ throw new MessagingBackupError('invalid_backup');
87
+ valid(scope, p.snapshot, p.part);
88
+ if (!Number.isSafeInteger(p.byteSize) || p.byteSize < 0 || p.byteSize > limit(p.part) || !Number.isFinite(p.createdAt) || p.createdAt <= 0)
89
+ throw new MessagingBackupError('invalid_backup');
90
+ const key = p.snapshot + ':' + p.part;
91
+ if (seen.has(key))
92
+ throw new MessagingBackupError('invalid_backup');
93
+ seen.add(key);
94
+ parts.push(p);
95
+ }
96
+ if (parts.length > 100003)
97
+ throw new MessagingBackupError('invalid_backup');
98
+ cursor = result.cursor ?? undefined;
99
+ if (cursor !== undefined) {
100
+ if (typeof cursor !== 'string' || !cursor || cursor.length > 32768 || cursors.has(cursor))
101
+ throw new MessagingBackupError('invalid_backup');
102
+ cursors.add(cursor);
103
+ }
104
+ } while (cursor);
105
+ return parts;
106
+ };
107
+ const read = async (scope, snapshot, part, signal) => {
108
+ const result = await request('read', scope, signal, { snapshot, part });
109
+ if (typeof result?.base64 !== 'string' || result.base64.length > Math.ceil(limit(part) / 3) * 4 || /[^A-Za-z0-9+/=]/.test(result.base64))
110
+ throw new MessagingBackupError('invalid_backup');
111
+ let bytes;
112
+ try {
113
+ bytes = decodeBackupBase64(result.base64, limit(part));
114
+ }
115
+ catch {
116
+ throw new MessagingBackupError('invalid_backup');
117
+ }
118
+ if (bytes.length > limit(part))
119
+ throw new MessagingBackupError('invalid_backup');
120
+ return bytes;
121
+ };
122
+ const write = async (scope, snapshot, part, bytes, signal) => {
123
+ valid(scope, snapshot, part);
124
+ if (bytes.length > limit(part))
125
+ throw new MessagingBackupError('invalid_backup');
126
+ const key = scope + ':' + snapshot, parts = uploads.get(key) ?? new Map();
127
+ uploads.set(key, parts);
128
+ if (parts.size > 100003 || parts.has(part))
129
+ throw new MessagingBackupError('invalid_backup');
130
+ parts.set(part, { bytes: bytes.length, confirmed: false });
131
+ const result = await request('write', scope, signal, { snapshot, part, base64: encodeBackupBase64(bytes) });
132
+ if (result?.confirmed !== true)
133
+ throw new MessagingBackupError('connection');
134
+ parts.set(part, { bytes: bytes.length, confirmed: true });
135
+ };
136
+ const summary = async (scope, id, signal) => {
137
+ let value;
138
+ try {
139
+ value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(await read(scope, id, 'commit', signal)));
140
+ }
141
+ catch (e) {
142
+ if (e instanceof MessagingBackupError)
143
+ throw e;
144
+ throw new MessagingBackupError('invalid_backup');
145
+ }
146
+ if (value?.id !== id || value.encrypted !== true || !Number.isSafeInteger(value.byteSize) || value.byteSize < 28 || !Number.isFinite(value.createdAt) || value.createdAt <= 0 || typeof value.includeVideos !== 'boolean' || value.protection !== undefined && !['password', 'passkey', 'recovery-key'].includes(value.protection))
147
+ throw new MessagingBackupError('invalid_backup');
148
+ return value;
149
+ };
150
+ const remove = async (scope, p, signal) => { if ((await request('delete', scope, signal, { snapshot: p.snapshot, part: p.part }))?.confirmed !== true)
151
+ throw new MessagingBackupError('connection'); };
152
+ const cleanupOrder = (a, b) => order(a) - order(b), order = (p) => p.part === 'commit' ? -1 : ['0', 'manifest'].includes(p.part) ? 1 : 0;
153
+ return {
154
+ account: s => run(s, account), async connect(s) { if (!await run(s, account))
155
+ await options.openSettings(); }, manageStorage: options.openSettings,
156
+ latest: (scope, parent) => run(parent, async (signal) => { const commits = (await list(scope, signal)).filter(p => p.part === 'commit').sort((a, b) => b.createdAt - a.createdAt || b.snapshot.localeCompare(a.snapshot)); return commits.length ? summary(scope, commits[0].snapshot, signal) : null; }),
157
+ read: (scope, id, part, parent) => run(parent, signal => read(scope, id, part, signal)),
158
+ write: (scope, id, part, bytes, parent) => run(parent, signal => write(scope, id, part, bytes, signal)),
159
+ commit: (scope, value, parent) => run(parent, async (signal) => {
160
+ // CloudKit query indexes may lag. Use individual server acknowledgements,
161
+ // never a local file or a query that may omit a just-uploaded part.
162
+ const parts = uploads.get(scope + ':' + value.id);
163
+ if (!parts?.has('manifest') || parts.has('commit') || [...parts.values()].some(p => !p.confirmed) || [...parts.values()].reduce((n, p) => n + p.bytes, 0) !== value.byteSize || (['password', 'passkey'].includes(value.protection ?? '')) !== parts.has('protection'))
164
+ throw new MessagingBackupError('invalid_backup');
165
+ const data = new TextEncoder().encode(JSON.stringify(value));
166
+ await write(scope, value.id, 'commit', data, signal);
167
+ if (JSON.stringify(await summary(scope, value.id, signal)) !== JSON.stringify(value))
168
+ throw new MessagingBackupError('invalid_backup');
169
+ snapshots.delete(scope + ':' + value.id);
170
+ uploads.delete(scope + ':' + value.id);
171
+ }),
172
+ async discard(scope, id) { const key = scope + ':' + id; if (!snapshots.has(key))
173
+ return; await run(new AbortController().signal, async (signal) => { const known = uploads.get(key); const parts = known ? [...known].map(([part, p]) => ({ snapshot: id, part, byteSize: p.bytes, createdAt: Date.now() })) : (await list(scope, signal)).filter(p => p.snapshot === id); for (const p of parts.sort(cleanupOrder))
174
+ await remove(scope, p, signal); snapshots.delete(key); uploads.delete(key); }); },
175
+ maintain: (scope, parent) => run(parent, async (signal) => {
176
+ const all = await list(scope, signal), commits = all.filter(p => p.part === 'commit').sort((a, b) => b.createdAt - a.createdAt), keep = new Set(commits.slice(0, retained).map(p => p.snapshot));
177
+ for (const id of keep)
178
+ await summary(scope, id, signal);
179
+ let remaining = 200;
180
+ for (const id of [...new Set(all.map(p => p.snapshot))].filter(id => !keep.has(id)).slice(0, 20)) {
181
+ const parts = all.filter(p => p.snapshot === id);
182
+ if (uploads.has(scope + ':' + id) || parts.some(p => p.createdAt > Date.now() - 7 * 86400000))
183
+ continue;
184
+ for (const p of parts.sort(cleanupOrder)) {
185
+ if (!remaining--)
186
+ return;
187
+ await remove(scope, p, signal);
188
+ }
189
+ snapshots.delete(scope + ':' + id);
190
+ }
191
+ }, 5000),
192
+ };
193
+ }
@@ -16,7 +16,9 @@ export interface MessagingDirectoryContact {
16
16
  }
17
17
  export interface MessagingDirectoryOptions {
18
18
  directory?: readonly MessagingDirectoryContact[];
19
- /** Recheck permission on your server and return the authorized conversation.
19
+ /** The shared Messenger opens the conversation destination immediately.
20
+ * Recheck permission on your server and return its authorized conversation summary
21
+ * directly; do not wait for directory/inbox refreshes before returning.
20
22
  * Honor cancellation when the account, directory entry or screen changes. */
21
23
  onOpenDirectoryContact?: (contact: MessagingDirectoryContact, signal: AbortSignal) => Promise<ConversationSummary>;
22
24
  }
@@ -10,7 +10,7 @@ export function directoryWithoutChats(directory, chats, query = '') {
10
10
  if (!c.id || seen.has(c.id) || c.conversationId && ids.has(c.conversationId) || c.contactId && people.has(c.contactId))
11
11
  return false;
12
12
  seen.add(c.id);
13
- return !term || `${c.name} ${c.status}`.toLocaleLowerCase().includes(term);
13
+ return !term || `${c.name} ${c.available ? '' : c.status}`.toLocaleLowerCase().includes(term);
14
14
  });
15
15
  }
16
16
  export function MessagingDirectoryRow({ contact, appearance, onPress }) {
@@ -20,6 +20,6 @@ export function MessagingDirectoryRow({ contact, appearance, onPress }) {
20
20
  useEffect(() => { setNow(Date.now()); const remaining = Math.min(45000, Math.max(0, deadline - Date.now())); if (!remaining)
21
21
  return; const timer = setTimeout(() => setNow(Date.now()), remaining + 1); return () => clearTimeout(timer); }, [deadline]);
22
22
  const online = contact.available && Number.isFinite(contact.onlineUntil) && deadline > now;
23
- const c = messagingFriendsColors(appearance), f = appearance.screens?.friends, avatar = messagingAvatarStyle(f?.avatarSize ?? 40, f?.avatarShape), padding = f?.rowSpacing === 'compact' ? 6 : f?.rowSpacing === 'relaxed' ? 16 : 10;
24
- return _jsxs(Pressable, { testID: 'messaging-directory-' + contact.id, accessibilityRole: "button", accessibilityLabel: contact.name + ', ' + contact.status, onPress: onPress, style: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 12, paddingVertical: padding, minHeight: Math.max(44, avatar.height + padding * 2) }, children: [appearance.screens?.friends?.showAvatars !== false && (contact.avatarUrl ? _jsx(Image, { source: { uri: contact.avatarUrl }, style: { ...avatar } }) : _jsx(View, { style: { ...avatar, backgroundColor: c.accent + '20', alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 18, fontWeight: '700' }, children: contact.name.slice(0, 1).toUpperCase() }) })), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: c.foreground, fontSize: f?.nameSize ?? 16, fontWeight: '700' }, children: contact.name }), online && _jsx(View, { testID: "directory-online", accessibilityLabel: uiText("Online now"), style: { width: 8, height: 8, borderRadius: 4, backgroundColor: '#2e9d63' } }), _jsx(Text, { numberOfLines: f?.previewLines ?? 1, style: { color: c.secondary, marginTop: 3, fontSize: f?.previewSize ?? 14 }, children: contact.status })] })] });
23
+ const c = messagingFriendsColors(appearance), f = appearance.screens?.friends, avatar = messagingAvatarStyle(f?.avatarSize ?? 48, f?.avatarShape), padding = f?.rowSpacing === 'compact' ? 6 : f?.rowSpacing === 'relaxed' ? 16 : 12;
24
+ return _jsxs(Pressable, { testID: 'messaging-directory-' + contact.id, accessibilityRole: "button", accessibilityLabel: contact.available ? contact.name : contact.name + ', ' + contact.status, onPress: onPress, style: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 16, paddingVertical: padding, minHeight: Math.max(44, avatar.height + padding * 2) }, children: [appearance.screens?.friends?.showAvatars !== false && (contact.avatarUrl ? _jsx(Image, { source: { uri: contact.avatarUrl }, style: { ...avatar } }) : _jsx(View, { style: { ...avatar, backgroundColor: c.accent + '20', alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 18, fontWeight: '700' }, children: contact.name.slice(0, 1).toUpperCase() }) })), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: c.foreground, fontSize: f?.nameSize ?? 16, fontWeight: '700' }, children: contact.name }), online && _jsx(View, { testID: "directory-online", accessibilityLabel: uiText("Online now"), style: { width: 8, height: 8, borderRadius: 4, backgroundColor: '#2e9d63' } }), !contact.available && _jsx(Text, { numberOfLines: f?.previewLines ?? 1, style: { color: c.secondary, marginTop: 3, fontSize: f?.previewSize ?? 14 }, children: contact.status })] })] });
25
25
  }
@@ -12,7 +12,7 @@ function MediaThumbnail({ message, preview }) {
12
12
  useEffect(() => { let live = true; setUri(undefined); if (preview && ['image', 'video'].includes(message.kind))
13
13
  void preview(message).then(value => { if (live)
14
14
  setUri(value.uri); }).catch(() => { }); return () => { live = false; }; }, [message.id, message.media?.assetId, preview]);
15
- return _jsxs(View, { style: { width: 56, height: 56, borderRadius: 8, overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: c.incoming }, children: [uri ? _jsx(Image, { source: { uri }, accessibilityLabel: message.media?.fileName ?? uiText("Attachment"), onError: () => setUri(undefined), style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: message.kind === 'voice' ? 'mic' : message.kind === 'document' ? 'document' : message.kind === 'video' ? 'video' : 'image', color: c.foreground, size: 24 }), uri && message.kind === 'video' && _jsx(View, { style: { position: 'absolute', backgroundColor: '#0008', padding: 3, borderRadius: 20 }, children: _jsx(MessageIcon, { name: "play", color: "#fff", size: 18 }) })] });
15
+ return _jsxs(View, { style: { width: 56, height: 56, borderRadius: 8, overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: c.incoming }, children: [uri ? _jsx(Image, { source: { uri }, accessibilityLabel: message.media?.fileName ?? uiText("Attachment"), resizeMode: "contain", onError: () => setUri(undefined), style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: message.kind === 'voice' ? 'mic' : message.kind === 'document' ? 'document' : message.kind === 'video' ? 'video' : 'image', color: c.foreground, size: 24 }), uri && message.kind === 'video' && _jsx(View, { style: { position: 'absolute', backgroundColor: '#0008', padding: 3, borderRadius: 20 }, children: _jsx(MessageIcon, { name: "play", color: "#fff", size: 18 }) })] });
16
16
  }
17
17
  /** Contact/group identity and retained shared media, using Messenger's bounded popup. */
18
18
  export function ConversationDetails(props) {
@@ -79,7 +79,7 @@ export function ConversationDetails(props) {
79
79
  }
80
80
  useEffect(() => { setMessages([]); setMembers([]); setNext(null); if (tab === 'members' || tab === 'media' && state.sharedMediaAvailable)
81
81
  void load(); return () => { ++generation.current; request.current?.abort(); }; }, [client, state.conversationId, tab]);
82
- const footer = _jsxs(View, { children: [busy && _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading conversation details"), color: accent, style: { padding: 16 } }), !!error && _jsxs(_Fragment, { children: [_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, padding: 12 }, children: error }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => void load(!!next), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent }, children: uiText("Try again") }) })] }), next && !busy && !error && _jsx(Pressable, { accessibilityRole: "button", onPress: () => void load(true), style: { minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent }, children: uiText("Load more") }) })] });
82
+ const footer = _jsxs(View, { style: { minHeight: 48 }, children: [_jsx(View, { pointerEvents: "none", style: { position: "absolute", top: 0, left: 0, right: 0, height: 48, alignItems: "center", justifyContent: "center" }, children: busy && _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading conversation details"), color: accent }) }), !!error && _jsxs(_Fragment, { children: [_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, padding: 12 }, children: error }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => void load(!!next), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent }, children: uiText("Try again") }) })] }), next && !error && _jsx(Pressable, { disabled: busy, accessibilityState: { busy }, accessibilityRole: "button", onPress: () => void load(true), style: { minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent, opacity: busy ? 0 : 1 }, children: uiText("Load more") }) })] });
83
83
  return _jsx(MessagingPopup, { screen: styleScreen, visible: visible, onDismiss: dismiss, title: leaving ? uiText("Leave group?") : group ? uiText("Group details") : uiText("Contact details"), compact: leaving, closeDisabled: leaving && busy, background: c.background, onClose: () => { if (!leaving || !busy) {
84
84
  if (leaving)
85
85
  setLeaving(false);
@@ -14,6 +14,7 @@ export interface HeaderRegionProps {
14
14
  name: string;
15
15
  avatarUrl?: string;
16
16
  language?: string;
17
+ networkName?: string;
17
18
  phoneNumber?: string;
18
19
  };
19
20
  appearance: MessagingAppearance;
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- /** A two-pixel inside edge, narrowing to a point at both bubble corners. */
3
- export declare function DeliveryBar({ color, topRadius, bottomRadius }: {
2
+ /** A two-pixel inside edge with short, tapered curves at both bubble corners. */
3
+ export declare function DeliveryBar({ color, topRadius, bottomRadius, roundedStart }: {
4
4
  color: string;
5
5
  topRadius: number;
6
6
  bottomRadius: number;
7
+ roundedStart?: boolean;
7
8
  }): React.JSX.Element;
@@ -2,18 +2,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { View } from 'react-native';
4
4
  import Svg, { Path, G } from 'react-native-svg';
5
- /** A two-pixel inside edge, narrowing to a point at both bubble corners. */
6
- export function DeliveryBar({ color, topRadius, bottomRadius }) {
5
+ /** A two-pixel inside edge with short, tapered curves at both bubble corners. */
6
+ export function DeliveryBar({ color, topRadius, bottomRadius, roundedStart = false }) {
7
7
  const [height, setHeight] = useState(0);
8
8
  const scale = height ? Math.min(1, height / Math.max(1, topRadius + bottomRadius)) : 1;
9
9
  const top = topRadius * scale, bottom = bottomRadius * scale;
10
10
  const capHeight = (radius) => radius > 0 ? radius : Math.min(8, height ? height / 2 : 8);
11
11
  const cap = (radius, bottom = false) => {
12
12
  const width = Math.max(2, radius), height = capHeight(radius);
13
+ // Keep the side-facing half of each corner. The curve still follows the
14
+ // bubble's radius, but ends before wrapping onto its top or bottom edge.
15
+ const tipX = radius * .7071125, tipY = radius * .2928875;
13
16
  const path = radius > 0
14
- ? `M 0 0 C ${radius * .5523} 0 ${radius} ${radius * .4477} ${radius} ${radius} L ${Math.max(0, radius - 2)} ${radius} C ${Math.max(0, radius - 2)} ${radius * .4477} ${radius * .5523} 1 0 0 Z`
17
+ ? `M ${tipX} ${tipY} C ${radius * .888075} ${radius * .473275} ${radius} ${radius * .72385} ${radius} ${radius} L ${Math.max(0, radius - 2)} ${radius} C ${Math.max(0, radius - 2)} ${radius * .72385} ${radius * .888075} ${radius * .473275 + 1} ${tipX} ${tipY} Z`
15
18
  : `M 2 0 L 2 ${height} L 0 ${height} Z`;
16
19
  return _jsx(Svg, { width: width, height: height, viewBox: `0 0 ${width} ${height}`, style: { position: 'absolute', right: 0, ...(bottom ? { bottom: 0 } : { top: 0 }) }, accessible: false, children: _jsx(G, { transform: bottom ? `translate(0 ${height}) scale(1 -1)` : undefined, children: _jsx(Path, { d: path, fill: color }) }) });
17
20
  };
18
- return _jsxs(View, { pointerEvents: "none", onLayout: e => setHeight(e.nativeEvent.layout.height), style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }, children: [_jsx(View, { style: { position: 'absolute', top: capHeight(top), bottom: capHeight(bottom), right: 0, width: 2, backgroundColor: color } }), cap(top), cap(bottom, true)] });
21
+ return _jsxs(View, { pointerEvents: "none", onLayout: e => setHeight(e.nativeEvent.layout.height), style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }, children: [_jsx(View, { style: { position: 'absolute', top: roundedStart ? 1 : capHeight(top), bottom: capHeight(bottom), right: 0, width: 2, backgroundColor: color } }), roundedStart ? _jsx(View, { testID: "delivery-bar-rounded-start", style: { position: 'absolute', top: 0, right: 0, width: 2, height: 2, borderTopLeftRadius: 1, borderTopRightRadius: 1, backgroundColor: color } }) : cap(top), cap(bottom, true)] });
19
22
  }
@@ -0,0 +1,9 @@
1
+ import type { MessagingMessage } from '@robono/messaging';
2
+ /** Used by the shared native and web bubble. Diagnostics stay out of the UI. */
3
+ export declare function deliveryNotice(message: MessagingMessage): {
4
+ text: string;
5
+ retry: boolean;
6
+ } | {
7
+ text: undefined;
8
+ retry: boolean;
9
+ };
@@ -0,0 +1,15 @@
1
+ /** Used by the shared native and web bubble. Diagnostics stay out of the UI. */
2
+ export function deliveryNotice(message) {
3
+ const delivery = message.delivery, code = delivery?.error;
4
+ if (delivery?.state === 'pending' && code === 'message_review_pending')
5
+ return { text: 'Waiting for safety check or review', retry: false };
6
+ if (delivery?.state !== 'failed')
7
+ return { text: undefined, retry: false };
8
+ if (code === 'message_screening_failed')
9
+ return { text: 'Safety check unavailable', retry: true };
10
+ if (['message_review_rejected', 'message_screening_blocked', 'message_rule_blocked'].includes(code ?? ''))
11
+ return { text: 'Not approved for delivery', retry: false };
12
+ if (['review_expired', 'review_source_unavailable', 'bridge_message_expired', 'history_content_expired'].includes(code ?? ''))
13
+ return { text: 'This unsent message has expired', retry: false };
14
+ return { text: undefined, retry: true };
15
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { type MessagingAppearance, type ConversationSummary } from '@robono/messaging';
3
+ import type { MessagingDirectoryContact, MessagingDirectoryOptions } from './contact-directory.js';
4
+ /** Navigation is immediate; permission resolution must finish before any chat data or composer is mounted. */
5
+ export declare function useDirectoryNavigation(options: MessagingDirectoryOptions & {
6
+ scope: object;
7
+ userId: string;
8
+ active?: boolean;
9
+ onOpen: (row: ConversationSummary) => void;
10
+ }): {
11
+ selection: MessagingDirectoryContact | null;
12
+ error: string;
13
+ busy: boolean;
14
+ open: (entry: MessagingDirectoryContact) => Promise<void>;
15
+ cancel: () => void;
16
+ };
17
+ /** A normal chat destination, never a blocking dialog or a pretend authorized chat. */
18
+ export declare function MessagingDirectoryConversation({ entry, error, busy, appearance, onBack, onRetry }: {
19
+ entry: MessagingDirectoryContact;
20
+ error: string;
21
+ busy: boolean;
22
+ appearance: MessagingAppearance;
23
+ onBack: () => void;
24
+ onRetry: () => void;
25
+ }): React.JSX.Element;
@@ -0,0 +1,69 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
3
+ import { AppState, BackHandler, Image, Pressable, View } from 'react-native';
4
+ import { MessagingLoadingMessages } from './loading-messages.js';
5
+ import { messagingAvatarStyle, messagingScreenAppearance } from '@robono/messaging';
6
+ import { messagingHeaderColors } from './header-colors.js';
7
+ import { MessageIcon } from './icons.js';
8
+ import { MessagingTypography, Text } from './typography.js';
9
+ import { useRobonoLocale } from './localization.js';
10
+ const emptyDirectory = [];
11
+ /** Navigation is immediate; permission resolution must finish before any chat data or composer is mounted. */
12
+ export function useDirectoryNavigation(options) {
13
+ const latest = useRef(options);
14
+ latest.current = options;
15
+ const request = useRef(null);
16
+ const [selection, setSelection] = useState(null), [error, setError] = useState(''), [busy, setBusy] = useState(false);
17
+ const cancel = () => { request.current?.control.abort(); request.current = null; setSelection(null); setError(''); setBusy(false); };
18
+ useLayoutEffect(() => { cancel(); return () => { request.current?.control.abort(); request.current = null; }; }, [options.scope, options.userId]);
19
+ useEffect(() => { if (options.active === false)
20
+ cancel(); }, [options.active]);
21
+ useEffect(() => { const sub = AppState.addEventListener('change', state => { if (state !== 'active')
22
+ cancel(); }); return () => sub.remove(); }, []);
23
+ useLayoutEffect(() => {
24
+ if (!selection)
25
+ return;
26
+ const current = (options.directory ?? emptyDirectory).find(entry => entry.id === selection.id);
27
+ if (!current || current.available !== selection.available || current.contactId !== selection.contactId || current.conversationId !== selection.conversationId)
28
+ cancel();
29
+ }, [options.directory, selection]);
30
+ async function open(entry) {
31
+ request.current?.control.abort();
32
+ request.current = null;
33
+ setSelection(entry);
34
+ setError('');
35
+ setBusy(false);
36
+ if (!entry.available || !latest.current.onOpenDirectoryContact)
37
+ return;
38
+ const pending = { control: new AbortController(), entry };
39
+ request.current = pending;
40
+ setBusy(true);
41
+ try {
42
+ const row = await latest.current.onOpenDirectoryContact(entry, pending.control.signal);
43
+ const current = latest.current.directory?.find(value => value.id === entry.id);
44
+ if (request.current !== pending || pending.control.signal.aborted || !current?.available || current.contactId !== entry.contactId || current.conversationId !== entry.conversationId)
45
+ return;
46
+ request.current = null;
47
+ setSelection(null);
48
+ setBusy(false);
49
+ latest.current.onOpen(row);
50
+ }
51
+ catch (e) {
52
+ if (request.current === pending && !pending.control.signal.aborted)
53
+ setError(e instanceof Error ? e.message : 'This conversation could not be opened. Try again.');
54
+ }
55
+ finally {
56
+ if (request.current === pending) {
57
+ request.current = null;
58
+ setBusy(false);
59
+ }
60
+ }
61
+ }
62
+ return { selection, error, busy, open, cancel };
63
+ }
64
+ /** A normal chat destination, never a blocking dialog or a pretend authorized chat. */
65
+ export function MessagingDirectoryConversation({ entry, error, busy, appearance, onBack, onRetry }) {
66
+ const { text } = useRobonoLocale(), design = messagingScreenAppearance(appearance), header = messagingHeaderColors(design, false), chat = design.screens?.chat, avatar = messagingAvatarStyle(chat?.avatarSize ?? 38, chat?.avatarShape);
67
+ useEffect(() => { const sub = BackHandler.addEventListener('hardwareBackPress', () => { onBack(); return true; }); return () => sub.remove(); }, [onBack]);
68
+ return _jsx(MessagingTypography, { appearance: design, children: _jsxs(View, { testID: "messaging-directory-conversation", style: { flex: 1, minHeight: 0, backgroundColor: design.colors.background }, children: [_jsxs(View, { testID: "messaging-chat-header", style: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 12, paddingVertical: 4, minHeight: chat?.headerSize === 'roomy' ? 72 : chat?.headerSize === 'compact' ? 44 : undefined, backgroundColor: header.background, gap: 4 }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: text('Back'), onPress: onBack, style: { width: 44, minHeight: 44, alignSelf: 'stretch', marginStart: -12, marginEnd: -4, marginVertical: -4, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "back", color: header.foreground, size: 32 }) }), _jsxs(View, { testID: "messaging-chat-identity", style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [design.showAvatars && (entry.avatarUrl ? _jsx(Image, { source: { uri: entry.avatarUrl }, style: { ...avatar, borderWidth: 1, borderColor: '#ffffff' } }) : _jsx(View, { style: { ...avatar, borderWidth: 1, borderColor: '#ffffff', backgroundColor: design.colors.incoming, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.incomingText }, children: entry.name.slice(0, 1) }) })), _jsx(Text, { numberOfLines: 1, style: { flex: 1, color: header.foreground, fontSize: chat?.titleSize ?? 18, textAlign: chat?.titleAlign ?? 'left', fontWeight: '800' }, children: entry.name })] })] }), _jsx(View, { style: { flex: 1, padding: 24, alignItems: 'center', justifyContent: 'center', gap: 16 }, children: busy ? _jsx(MessagingLoadingMessages, { color: design.colors.secondary }, entry.id) : _jsxs(_Fragment, { children: [_jsx(Text, { accessibilityRole: error ? 'alert' : undefined, style: { color: design.colors.secondary, textAlign: 'center', fontSize: 16, lineHeight: 24 }, children: error || entry.detail }), !!error && entry.available && _jsx(Pressable, { accessibilityRole: "button", onPress: onRetry, style: { minHeight: 44, justifyContent: 'center', paddingHorizontal: 16 }, children: _jsx(Text, { style: { color: design.colors.accent }, children: text('Try again') }) })] }) })] }) });
69
+ }
@@ -0,0 +1,17 @@
1
+ import { type MessagingBackupPreferences } from '@robono/messaging';
2
+ import { type MessagingBackgroundBackupOptions } from './backup-background.js';
3
+ export type { MessagingBackgroundBackupOptions, MessagingBackgroundBackupSession } from './backup-background.js';
4
+ /** Call once at module scope in the host entry point, before registering React.
5
+ * This optional entry point requires expo-background-task and expo-task-manager.
6
+ * One task restores whichever host account is current; no identity/token is saved
7
+ * in the scheduler. Actual backup cadence comes from that account's preferences. */
8
+ export declare function defineExpoMessagingBackupTask(options: MessagingBackgroundBackupOptions & {
9
+ taskName?: string;
10
+ }): {
11
+ schedule: (preferences: MessagingBackupPreferences) => Promise<void>;
12
+ /** Sign-out must cancel active work and remove future OS wakes. */
13
+ stop: () => Promise<void>;
14
+ /** Also call on foreground resume; does nothing until a backup is due. */
15
+ run: () => Promise<boolean>;
16
+ cancel: () => void | undefined;
17
+ };
@@ -0,0 +1,57 @@
1
+ import * as BackgroundTask from 'expo-background-task';
2
+ import * as TaskManager from 'expo-task-manager';
3
+ import { MessagingBackupError } from '@robono/messaging';
4
+ import { createMessagingBackgroundBackupRunner } from './backup-background.js';
5
+ /** Call once at module scope in the host entry point, before registering React.
6
+ * This optional entry point requires expo-background-task and expo-task-manager.
7
+ * One task restores whichever host account is current; no identity/token is saved
8
+ * in the scheduler. Actual backup cadence comes from that account's preferences. */
9
+ export function defineExpoMessagingBackupTask(options) {
10
+ const name = options.taskName ?? 'robono.messaging.backup.v1';
11
+ if (!/^[a-zA-Z0-9._-]{1,160}$/.test(name))
12
+ throw Error('Invalid backup task name.');
13
+ if (TaskManager.isTaskDefined(name))
14
+ throw Error('Define the backup task only once, at the application entry point.');
15
+ const runner = createMessagingBackgroundBackupRunner(options);
16
+ let pending = Promise.resolve();
17
+ TaskManager.defineTask(name, async ({ error }) => {
18
+ if (error)
19
+ return BackgroundTask.BackgroundTaskResult.Failed;
20
+ const expiration = BackgroundTask.addExpirationListener(runner.cancel);
21
+ try {
22
+ return await runner.run() ? BackgroundTask.BackgroundTaskResult.Success : BackgroundTask.BackgroundTaskResult.Failed;
23
+ }
24
+ finally {
25
+ expiration.remove();
26
+ }
27
+ });
28
+ const schedule = (preferences) => {
29
+ if (!['off', 'daily', 'weekly', 'monthly'].includes(preferences.frequency))
30
+ return Promise.reject(Error('Invalid backup frequency.'));
31
+ if (preferences.frequency === 'off')
32
+ runner.cancel();
33
+ const next = pending.catch(() => { }).then(async () => {
34
+ if (preferences.frequency === 'off') {
35
+ if (await TaskManager.isTaskRegisteredAsync(name))
36
+ await BackgroundTask.unregisterTaskAsync(name);
37
+ }
38
+ else {
39
+ if (await BackgroundTask.getStatusAsync() !== BackgroundTask.BackgroundTaskStatus.Available)
40
+ throw new MessagingBackupError('background_unavailable');
41
+ // Check daily even for monthly schedules, so OS delays cannot postpone a
42
+ // missed month by another full month. runScheduled checks the calendar due date.
43
+ await BackgroundTask.registerTaskAsync(name, { minimumInterval: 12 * 60 });
44
+ }
45
+ });
46
+ pending = next;
47
+ return next;
48
+ };
49
+ return {
50
+ schedule,
51
+ /** Sign-out must cancel active work and remove future OS wakes. */
52
+ stop: () => schedule({ frequency: 'off', cellular: false, includeVideos: false }),
53
+ /** Also call on foreground resume; does nothing until a backup is due. */
54
+ run: runner.run,
55
+ cancel: runner.cancel,
56
+ };
57
+ }
@@ -0,0 +1,6 @@
1
+ /** The host must provision this private iCloud container in its signed app. */
2
+ export declare function createExpoCloudKitMessagingBackup(options: {
3
+ container: string;
4
+ openSettings: () => Promise<void>;
5
+ retainedSnapshots?: number;
6
+ }): import("@robono/messaging").MessagingBackupCloud;
@@ -0,0 +1,11 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ import { randomUUID } from 'expo-crypto';
3
+ import { MessagingBackupError } from '@robono/messaging';
4
+ import { createCloudKitMessagingBackupCloud } from './cloudkit-backup.js';
5
+ /** The host must provision this private iCloud container in its signed app. */
6
+ export function createExpoCloudKitMessagingBackup(options) {
7
+ const native = NativeModules.RobonoBackupCloudKit;
8
+ if (Platform.OS !== 'ios' || !native)
9
+ throw new MessagingBackupError('unavailable');
10
+ return createCloudKitMessagingBackupCloud({ ...options, transport: native, randomId: randomUUID });
11
+ }
@@ -0,0 +1,3 @@
1
+ import type { MessagingBackupCrypto } from '@robono/messaging';
2
+ /** Interoperable with the web backup archive: AES-256-GCM, 96-bit IV, 128-bit tag. */
3
+ export declare function createExpoMessagingBackupCrypto(): MessagingBackupCrypto;
@@ -0,0 +1,17 @@
1
+ import { NativeModules } from 'react-native';
2
+ import { backupHex, backupUnhex } from '@robono/messaging';
3
+ import { AESEncryptionKey, AESSealedData, aesEncryptAsync, aesDecryptAsync, getRandomBytes } from 'expo-crypto';
4
+ /** Interoperable with the web backup archive: AES-256-GCM, 96-bit IV, 128-bit tag. */
5
+ export function createExpoMessagingBackupCrypto() {
6
+ return {
7
+ random: length => getRandomBytes(length),
8
+ ...(NativeModules.RobonoBackupCrypto ? { passwordKey: async (password, salt, iterations) => backupUnhex(await NativeModules.RobonoBackupCrypto.passwordKey(password, backupHex(salt), iterations)) } : {}),
9
+ async seal(key, plaintext, context) {
10
+ const sealed = await aesEncryptAsync(plaintext, await AESEncryptionKey.import(key), { nonce: { length: 12 }, tagLength: 16, additionalData: context });
11
+ return sealed.combined();
12
+ },
13
+ async open(key, bytes, context) {
14
+ return aesDecryptAsync(AESSealedData.fromCombined(bytes, { ivLength: 12, tagLength: 16 }), await AESEncryptionKey.import(key), { additionalData: context });
15
+ },
16
+ };
17
+ }
@@ -0,0 +1,7 @@
1
+ /** Requires a Google Android OAuth client for this package and signing SHA-1,
2
+ * Drive API enabled, and consent-screen configuration in the host's project.
3
+ * Only connect() may present consent; background account checks never do. */
4
+ export declare function createExpoGoogleMessagingBackup(options?: {
5
+ retainedSnapshots?: number;
6
+ openStorage?: () => Promise<void>;
7
+ }): import("@robono/messaging").MessagingBackupCloud;
@@ -0,0 +1,16 @@
1
+ import { NativeModules, Platform, Linking } from 'react-native';
2
+ import { randomUUID } from 'expo-crypto';
3
+ import { fetch as streamingFetch } from 'expo/fetch';
4
+ import { createGoogleMessagingBackupCloud, MessagingBackupError } from '@robono/messaging';
5
+ import { createMessagingGoogleBackupAuthorization } from './backup-google-authorization.js';
6
+ /** Requires a Google Android OAuth client for this package and signing SHA-1,
7
+ * Drive API enabled, and consent-screen configuration in the host's project.
8
+ * Only connect() may present consent; background account checks never do. */
9
+ export function createExpoGoogleMessagingBackup(options = {}) {
10
+ const transport = NativeModules.RobonoBackupGoogle;
11
+ if (Platform.OS !== 'android' || !transport)
12
+ throw new MessagingBackupError('unavailable');
13
+ const fetch = streamingFetch;
14
+ const authorization = createMessagingGoogleBackupAuthorization({ transport, fetch, randomId: randomUUID });
15
+ return createGoogleMessagingBackupCloud({ ...authorization, fetch, retainedSnapshots: options.retainedSnapshots, openStorage: options.openStorage ?? (async () => { await Linking.openURL('https://one.google.com/storage'); }) });
16
+ }
@@ -0,0 +1,8 @@
1
+ import type { MessagingBackupDriver } from '@robono/messaging';
2
+ type BackupNetwork = Awaited<ReturnType<MessagingBackupDriver['network']>>;
3
+ /** Network events cancel transfers when the user's current policy forbids them. */
4
+ export declare function createExpoMessagingBackupNetwork(): {
5
+ network: () => Promise<BackupNetwork>;
6
+ subscribeNetwork(listener: (network: BackupNetwork) => void): () => void;
7
+ };
8
+ export {};