@robono/messaging-react-native 0.22.0 → 0.24.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 (71) hide show
  1. package/BRIDGE-MESSENGER.md +72 -10
  2. package/CHANGELOG.md +26 -0
  3. package/README.md +83 -4
  4. package/RobonoMessagingRuntime.podspec +14 -0
  5. package/SBOM.spdx.json +967 -295
  6. package/android/build.gradle +7 -0
  7. package/android/src/main/AndroidManifest.xml +1 -0
  8. package/android/src/main/java/com/robono/messaging/RobonoBackupCrypto.java +27 -0
  9. package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +11 -0
  10. package/app.plugin.cjs +8 -2
  11. package/dist/account.d.ts +4 -1
  12. package/dist/account.js +33 -11
  13. package/dist/attachment-preview.d.ts +11 -10
  14. package/dist/attachment-preview.js +15 -12
  15. package/dist/backup.d.ts +24 -0
  16. package/dist/backup.js +157 -0
  17. package/dist/brand.js +4 -4
  18. package/dist/bubble-design.js +5 -3
  19. package/dist/chat-options.d.ts +5 -1
  20. package/dist/chat-options.js +2 -2
  21. package/dist/contact-directory.d.ts +5 -1
  22. package/dist/contact-directory.js +11 -3
  23. package/dist/conversation-details.js +1 -1
  24. package/dist/delivery-bar.d.ts +2 -1
  25. package/dist/delivery-bar.js +2 -2
  26. package/dist/directory-navigation.d.ts +25 -0
  27. package/dist/directory-navigation.js +69 -0
  28. package/dist/expo-backup-crypto.d.ts +3 -0
  29. package/dist/expo-backup-crypto.js +17 -0
  30. package/dist/expo-backup-passkeys.d.ts +7 -0
  31. package/dist/expo-backup-passkeys.js +22 -0
  32. package/dist/expo-backup-settings.d.ts +4 -0
  33. package/dist/expo-backup-settings.js +41 -0
  34. package/dist/expo-bridge.d.ts +6 -0
  35. package/dist/expo-bridge.js +13 -2
  36. package/dist/expo-inbox-preferences.d.ts +3 -0
  37. package/dist/expo-inbox-preferences.js +9 -0
  38. package/dist/expo-media.js +3 -3
  39. package/dist/expo-messenger.js +10 -5
  40. package/dist/expo-notification-cleanup.js +3 -3
  41. package/dist/expo-notifications.js +7 -3
  42. package/dist/expo-reviews.d.ts +3 -0
  43. package/dist/expo-reviews.js +40 -0
  44. package/dist/expo-screen.d.ts +3 -0
  45. package/dist/expo-screen.js +87 -45
  46. package/dist/expo-thumbnails.d.ts +4 -0
  47. package/dist/expo-thumbnails.js +25 -3
  48. package/dist/expo.d.ts +4 -0
  49. package/dist/expo.js +4 -0
  50. package/dist/forward.js +2 -2
  51. package/dist/header-colors.d.ts +5 -0
  52. package/dist/header-colors.js +7 -0
  53. package/dist/inbox.d.ts +5 -2
  54. package/dist/inbox.js +25 -53
  55. package/dist/index.d.ts +8 -5
  56. package/dist/index.js +78 -36
  57. package/dist/loading-messages.d.ts +5 -0
  58. package/dist/loading-messages.js +10 -0
  59. package/dist/media-access.d.ts +8 -0
  60. package/dist/media-access.js +6 -1
  61. package/dist/media-readiness.d.ts +2 -0
  62. package/dist/media-readiness.js +1 -0
  63. package/dist/playback-reporting.d.ts +8 -0
  64. package/dist/playback-reporting.js +32 -0
  65. package/dist/popup.d.ts +6 -3
  66. package/dist/popup.js +6 -6
  67. package/dist/reviews.d.ts +15 -0
  68. package/dist/reviews.js +204 -0
  69. package/dist/scheduled.js +5 -5
  70. package/ios/RobonoBackupCrypto.m +30 -0
  71. package/package.json +21 -8
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  /** A two-pixel inside edge, narrowing to a point at both bubble corners. */
3
- export declare function DeliveryBar({ color, topRadius, bottomRadius }: {
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;
@@ -3,7 +3,7 @@ import { useState } from 'react';
3
3
  import { View } from 'react-native';
4
4
  import Svg, { Path, G } from 'react-native-svg';
5
5
  /** A two-pixel inside edge, narrowing to a point at both bubble corners. */
6
- export function DeliveryBar({ color, topRadius, bottomRadius }) {
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;
@@ -15,5 +15,5 @@ export function DeliveryBar({ color, topRadius, bottomRadius }) {
15
15
  : `M 2 0 L 2 ${height} L 0 ${height} Z`;
16
16
  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
17
  };
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)] });
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: 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
19
  }
@@ -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,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
+ import { type MessagingBackupPasskeys } from '@robono/messaging';
2
+ /** Requires react-native-passkey, iOS associated domains and Android Digital Asset
3
+ * Links for the same RP ID. Unsupported providers never fall back to weaker keys. */
4
+ export declare function createExpoMessagingBackupPasskeys(options: {
5
+ rpId: string;
6
+ name: string;
7
+ }): MessagingBackupPasskeys;
@@ -0,0 +1,22 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ import { getRandomBytes } from 'expo-crypto';
3
+ import { createMessagingBackupPasskeys } from '@robono/messaging';
4
+ /** Requires react-native-passkey, iOS associated domains and Android Digital Asset
5
+ * Links for the same RP ID. Unsupported providers never fall back to weaker keys. */
6
+ export function createExpoMessagingBackupPasskeys(options) {
7
+ const load = async () => { try {
8
+ return (await import('react-native-passkey')).Passkey;
9
+ }
10
+ catch {
11
+ return null;
12
+ } };
13
+ return createMessagingBackupPasskeys({ ...options, random: getRandomBytes, transport: {
14
+ async available() { if (!NativeModules.Passkey)
15
+ return false; if (Platform.OS === 'ios' && Number.parseInt(String(Platform.Version), 10) < 18)
16
+ return false; const passkey = await load(); return !!passkey?.isSupported(); },
17
+ async create(request) { const passkey = await load(); if (!passkey)
18
+ throw Error('Passkeys unavailable'); return passkey.create(request); },
19
+ async get(request) { const passkey = await load(); if (!passkey)
20
+ throw Error('Passkeys unavailable'); return passkey.get(request); },
21
+ } });
22
+ }
@@ -0,0 +1,4 @@
1
+ import type { MessagingBackupLocalSettings } from '@robono/messaging';
2
+ /** Recovery keys stay in Keychain/Keystore. Preferences contain no credentials.
3
+ * The scope must be identical to the durable history's endpoint/tenant/account scope. */
4
+ export declare function createExpoMessagingBackupSettings(endpoint: string, userId: string, namespace?: string): MessagingBackupLocalSettings;
@@ -0,0 +1,41 @@
1
+ import * as FS from 'expo-file-system/legacy';
2
+ import * as SecureStore from 'expo-secure-store';
3
+ import { randomUUID } from 'expo-crypto';
4
+ import { storageDigest } from './expo-storage-digest.js';
5
+ /** Recovery keys stay in Keychain/Keystore. Preferences contain no credentials.
6
+ * The scope must be identical to the durable history's endpoint/tenant/account scope. */
7
+ export function createExpoMessagingBackupSettings(endpoint, userId, namespace = 'default') {
8
+ const scope = storageDigest(JSON.stringify([endpoint, namespace, userId]));
9
+ const directory = async () => {
10
+ if (!FS.documentDirectory)
11
+ throw Error('Private backup settings are unavailable.');
12
+ return FS.documentDirectory + 'robono-backup-settings/' + await scope + '/';
13
+ };
14
+ const keyOptions = { keychainService: 'robono-messaging-backup', keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY };
15
+ const readEncryption = async () => { const raw = await SecureStore.getItemAsync('encryption-' + await scope, keyOptions); return raw ? JSON.parse(raw) : null; };
16
+ let pending = Promise.resolve();
17
+ return {
18
+ async readPreferences() { await pending.catch(() => { }); const file = await directory() + 'preferences.json'; const info = await FS.getInfoAsync(file); if (!info.exists)
19
+ return null; if (info.isDirectory || info.size > 4096)
20
+ throw Error('Backup settings could not be read.'); return JSON.parse(await FS.readAsStringAsync(file)); },
21
+ writePreferences(value) {
22
+ const work = pending.catch(() => { }).then(async () => {
23
+ const dir = await directory(), temp = dir + randomUUID() + '.tmp';
24
+ await FS.makeDirectoryAsync(dir, { intermediates: true });
25
+ try {
26
+ await FS.writeAsStringAsync(temp, JSON.stringify(value));
27
+ await FS.moveAsync({ from: temp, to: dir + 'preferences.json' });
28
+ }
29
+ finally {
30
+ await FS.deleteAsync(temp, { idempotent: true }).catch(() => { });
31
+ }
32
+ });
33
+ pending = work;
34
+ return work;
35
+ },
36
+ readEncryption,
37
+ async writeEncryption(value) { await SecureStore.setItemAsync('encryption-' + await scope, JSON.stringify(value), keyOptions); },
38
+ async readRecoveryKey() { return (await readEncryption())?.key ?? SecureStore.getItemAsync('recovery-' + await scope, keyOptions); },
39
+ async writeRecoveryKey(value) { await SecureStore.setItemAsync('recovery-' + await scope, value, keyOptions); },
40
+ };
41
+ }
@@ -5,6 +5,7 @@ export declare function createExpoBridgeMessenger(options: {
5
5
  userId: string;
6
6
  connectionId: string;
7
7
  getAccessToken: () => Promise<string>;
8
+ foregroundPresence?: boolean;
8
9
  fetch?: typeof fetch;
9
10
  namespace?: string;
10
11
  persistence?: false;
@@ -14,6 +15,11 @@ export declare function createExpoBridgeMessenger(options: {
14
15
  client: import("@robono/messaging").MessagingClient;
15
16
  storage: import("./media-controller.js").MessagingMediaStorage;
16
17
  audioSession: MessagingAudioSession;
18
+ presence: {
19
+ start(): void;
20
+ stop(): Promise<void>;
21
+ dispose(): Promise<void>;
22
+ } | undefined;
17
23
  conversationId: string;
18
24
  open: () => Promise<void>;
19
25
  handlePush: (payload: unknown) => Promise<boolean>;
@@ -1,3 +1,6 @@
1
+ import { AppState } from 'react-native';
2
+ import * as Crypto from 'expo-crypto';
3
+ import { createBridgePresenceSession } from '@robono/messaging';
1
4
  import { bridgeMessengerFetch, bridgeLanguageRequest, createMessagingTransport, refreshBridgeMessengerFromPush } from '@robono/messaging';
2
5
  import { createExpoMessagingClient, expoOutbox } from './expo-outbox.js';
3
6
  import { createExpoMessagingStorage, createExpoMessagingAudioSession } from './expo-media.js';
@@ -22,8 +25,16 @@ export function createExpoBridgeMessenger(options) {
22
25
  return () => { abort.abort(); release(); };
23
26
  });
24
27
  const audioSession = options.audioSession ?? createExpoMessagingAudioSession({ isCallActive: options.isCallActive });
25
- return { client, storage, audioSession, conversationId: options.connectionId,
28
+ const presence = options.foregroundPresence ? createBridgePresenceSession({ request: createMessagingTransport({ ...options, fetch: transportFetch }), connectionId: options.connectionId, sessionId: Crypto.randomUUID() }) : undefined;
29
+ const change = (state) => { if (state === 'active')
30
+ presence?.start();
31
+ else
32
+ void presence?.stop(); };
33
+ const listener = presence ? AppState.addEventListener('change', change) : undefined;
34
+ change(AppState.currentState);
35
+ const stopPresence = () => { listener?.remove(); return presence?.dispose(); };
36
+ return { client, storage, audioSession, presence, conversationId: options.connectionId,
26
37
  open: () => client.open(options.connectionId),
27
38
  handlePush: (payload) => refreshBridgeMessengerFromPush(client, options.connectionId, payload),
28
- signOut: () => client.signOut(), dispose: () => client.dispose(), };
39
+ signOut: async () => { await stopPresence(); await client.signOut(); }, dispose: () => { void stopPresence(); client.dispose(); }, };
29
40
  }
@@ -0,0 +1,3 @@
1
+ import type { MessagingInboxPreferences } from '@robono/messaging';
2
+ /** A small account-scoped appearance preference; contains no messages or credentials. */
3
+ export declare function createExpoInboxPreferences(endpoint: string, userId: string, namespace?: string): MessagingInboxPreferences;
@@ -0,0 +1,9 @@
1
+ import * as FS from 'expo-file-system/legacy';
2
+ import { storageDigest } from './expo-storage-digest.js';
3
+ /** A small account-scoped appearance preference; contains no messages or credentials. */
4
+ export function createExpoInboxPreferences(endpoint, userId, namespace = 'default') {
5
+ const file = async () => { if (!FS.documentDirectory)
6
+ throw Error('Account settings storage is unavailable.'); return FS.documentDirectory + 'robono-inbox-' + await storageDigest(JSON.stringify([endpoint, namespace, userId])) + '.json'; };
7
+ return { async read() { const path = await file(); if (!(await FS.getInfoAsync(path)).exists)
8
+ return null; const value = JSON.parse(await FS.readAsStringAsync(path)); return typeof value.showSelf === 'boolean' ? value.showSelf : null; }, async write(showSelf) { await FS.writeAsStringAsync(await file(), JSON.stringify({ showSelf })); } };
9
+ }
@@ -1,6 +1,6 @@
1
1
  import { allocateMessagingCache, removeMessagingCacheUri } from './expo-cache.js';
2
2
  import { MessagingError } from '@robono/messaging';
3
- import { MessagingMediaAccess } from './media-access.js';
3
+ import { MessagingMediaAccess, isRemoteMessagingAsset } from './media-access.js';
4
4
  import { awaitMediaScreening } from './media-screening';
5
5
  import { AppState } from 'react-native';
6
6
  import { prepareRecordingPermission } from './recording-permission.js';
@@ -313,7 +313,7 @@ export function createExpoMessagingStorage(options) {
313
313
  check(context.signal);
314
314
  if (message.deleted)
315
315
  throw Error('This attachment is no longer available.');
316
- if (options.streaming === false || !['voice', 'video'].includes(message.kind) || !['robono-r2:', 'bridge:'].some(prefix => message.media?.assetId.startsWith(prefix)))
316
+ if (options.streaming === false || !['voice', 'video'].includes(message.kind) || !isRemoteMessagingAsset(message.media?.assetId ?? ''))
317
317
  return null;
318
318
  const plan = await playbackPlan(message, context.signal);
319
319
  // The native player requests byte ranges directly from the same private,
@@ -373,7 +373,7 @@ export function createExpoMessagingStorage(options) {
373
373
  if (message.deleted)
374
374
  throw Error('This attachment is no longer available.');
375
375
  const grant = message.attachmentPreview;
376
- const fresh = grant && grant.messageId === message.id && grant.conversationId === message.conversationId && grant.assetId === message.media?.assetId && Number.isFinite(grant.expiresAt) && grant.expiresAt > Date.now() + 5000 && grant.expiresAt <= Date.now() + 60000 && Number.isSafeInteger(grant.byteSize) && grant.byteSize > 0 && grant.byteSize <= 131072;
376
+ const fresh = grant && grant.messageId === message.id && grant.conversationId === message.conversationId && grant.assetId === message.media?.assetId && Number.isFinite(grant.expiresAt) && grant.expiresAt > Date.now() + 5000 && grant.expiresAt <= Date.now() + 60000 && Number.isSafeInteger(grant.byteSize) && grant.byteSize > 0 && grant.byteSize <= (message.media?.assetId.startsWith('bridge:') ? 204800 : 131072);
377
377
  const plan = fresh ? { url: grant.url, media: { assetId: grant.assetId, mimeType: 'image/jpeg', fileName: 'preview.jpg', byteSize: grant.byteSize } } : await request('thumbnail', { conversationId: message.conversationId, messageId: message.id }, context.signal);
378
378
  if (!plan)
379
379
  return null;
@@ -1,4 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createExpoInboxPreferences } from './expo-inbox-preferences.js';
3
+ import { useDirectoryNavigation, MessagingDirectoryConversation } from './directory-navigation.js';
2
4
  import { renderNativeCallVideo } from '@robono/calling-react-native/native-video';
3
5
  import { createInboxViewMemory } from './inbox-view.js';
4
6
  import { MessagingPublicRooms } from './public-rooms.js';
@@ -36,7 +38,7 @@ export function createExpoMessenger(options) {
36
38
  void availability?.stop(); };
37
39
  const activitySubscription = availability ? AppState.addEventListener('change', activityChanged) : undefined;
38
40
  activityChanged(AppState.currentState);
39
- const inbox = new MessagingInboxClient({ request: createMessagingTransport({ ...options, url: endpoint.href }) });
41
+ const inbox = new MessagingInboxClient({ request: createMessagingTransport({ ...options, url: endpoint.href }), userId: options.userId, preferences: options.persistence === false ? undefined : createExpoInboxPreferences(endpoint.href, options.userId, options.namespace) });
40
42
  const storage = createExpoMessagingStorage({ url: media.href, getAccessToken: options.getAccessToken, ...(options.fetch ? { fetch: options.fetch } : {}) });
41
43
  const outgoing = expoOutbox(client);
42
44
  if (outgoing)
@@ -152,7 +154,8 @@ function ExpoMessengerContent({ inbox, contacts = emptyContacts, initialConversa
152
154
  const selected = selectedConversation === undefined ? internal : selectedConversation;
153
155
  // Declarative navigation loads the selected conversation itself. Internal open()
154
156
  // changes the client synchronously, so this never opens it a second time.
155
- useLayoutEffect(() => { if (!selected) {
157
+ useLayoutEffect(() => { if (selected)
158
+ directoryNavigation.cancel(); if (!selected) {
156
159
  props.client.stop();
157
160
  return;
158
161
  } if (props.client.getSnapshot().conversationId !== selected.id)
@@ -183,16 +186,18 @@ function ExpoMessengerContent({ inbox, contacts = emptyContacts, initialConversa
183
186
  setSelected(null); },
184
187
  } : props.conversationActions;
185
188
  const open = (row, messageId) => {
189
+ directoryNavigation.cancel();
186
190
  setShowMaps(false);
187
191
  setSelected(row);
188
192
  void props.client.open(row.id).then(async () => { if (messageId && props.client.getSnapshot().conversationId === row.id)
189
193
  await props.client.focusMessage(messageId); }).catch(() => { });
190
194
  };
195
+ const directoryNavigation = useDirectoryNavigation({ directory: props.directory, onOpenDirectoryContact: props.onOpenDirectoryContact, scope: inbox, userId: props.userId, active: props.active, onOpen: open });
191
196
  useEffect(() => { void notifications?.start(async (id, message) => { await inbox.refresh(); const row = inbox.getSnapshot().conversations.find(c => c.id === id); if (row)
192
197
  open(row, message); }).catch(() => { }); }, [notifications, inbox]);
193
198
  const notificationAccount = notifications ? { name: props.account?.name ?? 'Your account', ...props.account, onEnableNotifications: () => notifications.enable() } : props.account;
194
199
  const account = calling?.deviceCheck ? { name: 'Your account', ...notificationAccount, deviceCheck: calling.deviceCheck, renderCallPreview: (stream) => renderNativeCallVideo({ stream, local: true, style: { width: '100%', height: '100%' } }) } : notificationAccount;
195
- const knownContact = contacts[selected?.contactId ?? ''];
196
- const contact = useMemo(() => selected?.contactId === props.userId ? { name: 'Notes to self' } : selected?.kind === 'group' ? { name: selected.name ?? 'Group' } : knownContact ?? { name: selected?.contactId ?? 'Chat' }, [selected?.contactId, selected?.kind, selected?.name, props.userId, knownContact]);
197
- return _jsxs(View, { style: { flex: 1, minHeight: 0 }, children: [_jsx(MessengerMapsNotice, { error: mapConnection.error, retry: mapConnection.retry }), showMaps && maps ? _jsx(RobonoMaps, { interfaceLocale: mapsLocale, workspace: maps, contacts: contacts, onClose: () => setShowMaps(false) }) : _jsx(ExpoMessagingScreen, { ...props, conversationActions: conversationActions, account: account, contact: contact, participants: props.participants ?? contacts, extras: selected ? props.extras : undefined, callActions: selected && selected.contactId !== props.userId ? { ...autoCalls, ...props.callActions, phoneNumber: contacts[selected.contactId ?? '']?.phoneNumber ?? props.callActions?.phoneNumber } : undefined, onBack: () => { props.client.stop(); setSelected(null); void inbox.refresh().catch(() => { }); }, renderConversation: screen => selected ? _jsx(MessagingCallingScreen, { ...screen, onCall: screen.callActions?.voice, onVideoCall: screen.callActions?.video, callLabel: "Internet call", unansweredCallId: callState.unanswered?.conversationId === selected.id ? callState.unanswered.id : undefined, onDismissCallMessage: calling?.dismissUnanswered }) : _jsxs(MessagingProvider, { ...screen, appearance: props.appearance ?? inboxState.appearance ?? undefined, children: [_jsx(MessagingInbox, { manageUpdates: false, directory: props.directory, onOpenDirectoryContact: props.onOpenDirectoryContact, viewMemory: inboxMemory, client: inbox, userId: props.userId, contacts: contacts, companyName: props.companyName, appearance: props.appearance, active: props.active !== false, headerActions: _jsx(MessagingAccountMenu, { onNewConversation: props.onNewConversation, onPublicRooms: inboxState.publicRoomsAvailable ? () => setPublicRooms(true) : undefined, onMaps: mapsAvailable ? () => setShowMaps(true) : undefined, onNewGroup: inboxState.groupCreationAvailable ? () => setNewGroup(true) : undefined }), onSelect: open, onDeleted: id => props.client.forgetConversation(id) }), publicRooms && _jsx(MessagingPublicRooms, { inbox: inbox, accent: (props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance).colors.accent, createRequestId: () => props.client.createForwardId(), onClose: () => setPublicRooms(false), onJoined: (id, name) => { setPublicRooms(false); open(inbox.getSnapshot().conversations.find(c => c.id === id) ?? { id, kind: 'group', name, contactId: null, lastMessage: null, unreadCount: 0, canSend: true }); } }), newGroup && _jsx(MessagingGroupEditor, { client: props.client, inbox: inbox, userId: props.userId, contacts: contacts, groups: inboxState.groups, accent: (props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance).colors.accent, onClose: () => setNewGroup(false), onSaved: (id, name) => { setNewGroup(false); const row = inbox.getSnapshot().conversations.find(c => c.id === id) ?? { id, kind: 'group', name, contactId: null, lastMessage: null, unreadCount: 0, canSend: true }; open(row); } }), props.inboxOverlay] }) }), _jsx(ExpoMessengerCalls, { calling: calling, state: callState })] });
200
+ const knownContact = contacts[selected?.contactId ?? ''] ?? props.directory?.find(entry => entry.contactId === selected?.contactId);
201
+ const contact = useMemo(() => selected?.contactId === props.userId ? { name: 'Me', avatarUrl: props.account?.avatarUrl } : selected?.kind === 'group' ? { name: selected.name ?? 'Group' } : knownContact ?? { name: selected?.contactId ?? 'Chat' }, [selected?.contactId, selected?.kind, selected?.name, props.userId, knownContact, props.account?.avatarUrl]);
202
+ return _jsxs(View, { style: { flex: 1, minHeight: 0 }, children: [_jsx(MessengerMapsNotice, { error: mapConnection.error, retry: mapConnection.retry }), showMaps && maps ? _jsx(RobonoMaps, { interfaceLocale: mapsLocale, workspace: maps, contacts: contacts, onClose: () => setShowMaps(false) }) : _jsx(ExpoMessagingScreen, { ...props, initialAppearance: props.initialAppearance ?? inboxState.appearance ?? undefined, conversationActions: conversationActions, account: account, contact: contact, participants: props.participants ?? contacts, extras: selected ? props.extras : undefined, callActions: selected && selected.contactId !== props.userId ? { ...autoCalls, ...props.callActions, phoneNumber: contacts[selected.contactId ?? '']?.phoneNumber ?? props.callActions?.phoneNumber } : undefined, onBack: () => { props.client.stop(); setSelected(null); void inbox.refresh().catch(() => { }); }, renderConversation: screen => directoryNavigation.selection ? _jsx(MessagingDirectoryConversation, { entry: directoryNavigation.selection, busy: directoryNavigation.busy, error: directoryNavigation.error, appearance: props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance, onBack: directoryNavigation.cancel, onRetry: () => void directoryNavigation.open(directoryNavigation.selection) }) : selected ? _jsx(MessagingCallingScreen, { ...screen, onCall: screen.callActions?.voice, onVideoCall: screen.callActions?.video, callLabel: "Internet call", unansweredCallId: callState.unanswered?.conversationId === selected.id ? callState.unanswered.id : undefined, onDismissCallMessage: calling?.dismissUnanswered }) : _jsxs(MessagingProvider, { ...screen, appearance: props.appearance ?? inboxState.appearance ?? undefined, children: [_jsx(MessagingInbox, { selfAvatarUrl: props.account?.avatarUrl, onNewConversation: props.onNewConversation, onDirectorySelect: entry => { props.client.stop(); setSelected(null); void directoryNavigation.open(entry); }, manageUpdates: false, directory: props.directory, onOpenDirectoryContact: props.onOpenDirectoryContact, viewMemory: inboxMemory, client: inbox, userId: props.userId, contacts: contacts, companyName: props.companyName, appearance: props.appearance, active: props.active !== false, headerActions: _jsx(MessagingAccountMenu, { inbox: inbox, onNewConversation: props.onNewConversation, onPublicRooms: inboxState.publicRoomsAvailable ? () => setPublicRooms(true) : undefined, onMaps: mapsAvailable ? () => setShowMaps(true) : undefined, onNewGroup: inboxState.groupCreationAvailable ? () => setNewGroup(true) : undefined }), onSelect: open, onDeleted: id => props.client.forgetConversation(id) }), publicRooms && _jsx(MessagingPublicRooms, { inbox: inbox, accent: (props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance).colors.accent, createRequestId: () => props.client.createForwardId(), onClose: () => setPublicRooms(false), onJoined: (id, name) => { setPublicRooms(false); open(inbox.getSnapshot().conversations.find(c => c.id === id) ?? { id, kind: 'group', name, contactId: null, lastMessage: null, unreadCount: 0, canSend: true }); } }), newGroup && _jsx(MessagingGroupEditor, { client: props.client, inbox: inbox, userId: props.userId, contacts: contacts, groups: inboxState.groups, accent: (props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance).colors.accent, onClose: () => setNewGroup(false), onSaved: (id, name) => { setNewGroup(false); const row = inbox.getSnapshot().conversations.find(c => c.id === id) ?? { id, kind: 'group', name, contactId: null, lastMessage: null, unreadCount: 0, canSend: true }; open(row); } }), props.inboxOverlay] }) }), _jsx(ExpoMessengerCalls, { calling: calling, state: callState })] });
198
203
  }
@@ -48,7 +48,7 @@ export const rememberNotificationAccount = (scope, enabled) => serial(async () =
48
48
  async function savedReads(scope) {
49
49
  try {
50
50
  const data = JSON.parse(await SecureStore.getItemAsync(readKey(scope)) ?? '[]');
51
- return Array.isArray(data) ? data.map(r => Array.isArray(r) ? { event: 'robono.messaging.read', accountScope: scope, conversationId: r[0], messageId: r[1], kind: r[2], savedAt: r[3] } : r).filter(r => parseMessagingReadNotification(r) && r.savedAt > Date.now() - 7 * 86400000) : [];
51
+ return Array.isArray(data) ? data.map(r => Array.isArray(r) ? { event: 'robono.messaging.read', accountScope: scope, conversationId: r[0], messageId: r[1], kind: r[2], savedAt: r[3], ...(r[4] ? { source: r[4] } : {}) } : r).filter(r => parseMessagingReadNotification(r) && r.savedAt > Date.now() - 7 * 86400000) : [];
52
52
  }
53
53
  catch {
54
54
  return [];
@@ -67,10 +67,10 @@ export async function dismissReadNotification(value) {
67
67
  return serial(async () => {
68
68
  if (!(await accounts()).includes(read.accountScope))
69
69
  return false;
70
- const reads = await savedReads(read.accountScope), previous = reads.find(r => r.conversationId === read.conversationId && r.kind === read.kind && (read.kind !== 'message' || r.messageId === read.messageId));
70
+ const reads = await savedReads(read.accountScope), previous = reads.find(r => r.source === read.source && r.conversationId === read.conversationId && r.kind === read.kind && (read.kind !== 'message' || r.messageId === read.messageId));
71
71
  const newer = !previous || read.messageId.length > previous.messageId.length || read.messageId.length === previous.messageId.length && read.messageId >= previous.messageId;
72
72
  if (newer)
73
- await SecureStore.setItemAsync(readKey(read.accountScope), JSON.stringify([...reads.filter(r => r !== previous), { ...read, savedAt: Date.now() }].slice(-16).map(r => [r.conversationId, r.messageId, r.kind, r.savedAt])), { keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY });
73
+ await SecureStore.setItemAsync(readKey(read.accountScope), JSON.stringify([...reads.filter(r => r !== previous), { ...read, savedAt: Date.now() }].slice(-16).map(r => [r.conversationId, r.messageId, r.kind, r.savedAt, r.source])), { keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY });
74
74
  for (const n of await Notifications.getPresentedNotificationsAsync())
75
75
  if (readNotificationCovers(read, presentedNotificationData(n)))
76
76
  await Notifications.dismissNotificationAsync(n.request.identifier);
@@ -1,4 +1,5 @@
1
1
  import * as Notifications from 'expo-notifications';
2
+ import { getIosPushNotificationServiceEnvironmentAsync } from 'expo-application';
2
3
  import * as Crypto from 'expo-crypto';
3
4
  import * as SecureStore from 'expo-secure-store';
4
5
  import { Platform, AppState } from 'react-native';
@@ -40,7 +41,10 @@ export async function connectExpoMessagingNotifications(options) {
40
41
  if (disposed || closing)
41
42
  return;
42
43
  const system = await options.systemCalls?.registration();
43
- const data = await request({ operation: 'register-device', calling: !!options.onCall, ...system, deviceId, provider: Platform.OS === 'ios' ? 'apns' : 'fcm', token: String(token.data) });
44
+ const appleEnvironment = Platform.OS === 'ios' ? await getIosPushNotificationServiceEnvironmentAsync() : undefined;
45
+ if (Platform.OS === 'ios' && !['development', 'production'].includes(String(appleEnvironment)))
46
+ throw Error('This iPhone build has no Apple push environment. Rebuild with Push Notifications enabled.');
47
+ const data = await request({ operation: 'register-device', calling: !!options.onCall, ...system, ...(appleEnvironment ? { appleEnvironment } : {}), deviceId, provider: Platform.OS === 'ios' ? 'apns' : 'fcm', token: String(token.data) });
44
48
  if (data.accountScope !== status.accountScope)
45
49
  throw Error('The signed-in account changed. Reconnect notifications for the new account.');
46
50
  });
@@ -79,11 +83,11 @@ export async function connectExpoMessagingNotifications(options) {
79
83
  return;
80
84
  const shown = (await Notifications.getPresentedNotificationsAsync()).map(n => ({ id: n.request.identifier, event: parseMessagingNotification(presentedNotificationData(n)) })).filter(n => n.event?.accountScope === accountScope);
81
85
  for (let i = 0; i < shown.length; i += 100) {
82
- const batch = shown.slice(i, i + 100), result = await request({ operation: 'notification-reconcile', messages: batch.map(n => ({ conversationId: n.event.conversationId, messageId: n.event.messageId })) });
86
+ const batch = shown.slice(i, i + 100), result = await request({ operation: 'notification-reconcile', messages: batch.map(n => ({ conversationId: n.event.conversationId, messageId: n.event.messageId, ...(n.event.source ? { source: n.event.source } : {}) })) });
83
87
  if (disposed || closing || result.accountScope !== accountScope || !Array.isArray(result.stale))
84
88
  return;
85
89
  for (const n of batch)
86
- if (result.stale.some((m) => m.conversationId === n.event.conversationId && m.messageId === n.event.messageId))
90
+ if (result.stale.some((m) => m.conversationId === n.event.conversationId && m.messageId === n.event.messageId && m.source === n.event.source))
87
91
  await Notifications.dismissNotificationAsync(n.id);
88
92
  }
89
93
  })().finally(() => { reconciling = undefined; });
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { type MessagingReviewInboxProps } from "./reviews.js";
3
+ export declare function ExpoMessageReviewInbox(props: Omit<MessagingReviewInboxProps, "renderMedia">): React.JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { Pressable, Text, View } from "react-native";
4
+ import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio";
5
+ import { useVideoPlayer } from "expo-video";
6
+ import { MessengerVideoView } from "./messenger-video-view.js";
7
+ import { MessagingReviewInbox, } from "./reviews.js";
8
+ function ReviewVoice({ url }) {
9
+ const player = useAudioPlayer({ uri: url }), status = useAudioPlayerStatus(player);
10
+ useEffect(() => {
11
+ if (status.didJustFinish) {
12
+ player.pause();
13
+ void player.seekTo(0);
14
+ }
15
+ }, [player, status.didJustFinish]);
16
+ const label = !status.isLoaded
17
+ ? "Loading recording…"
18
+ : status.playing
19
+ ? "Pause recording"
20
+ : "Play recording";
21
+ return (_jsx(View, { children: _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, disabled: !status.isLoaded, onPress: () => {
22
+ if (status.playing)
23
+ player.pause();
24
+ else
25
+ player.play();
26
+ }, style: { padding: 14, minHeight: 44 }, children: _jsx(Text, { style: { color: "#17251c" }, children: label }) }) }));
27
+ }
28
+ function ReviewVideo({ url }) {
29
+ const player = useVideoPlayer(url, (p) => {
30
+ p.loop = false;
31
+ });
32
+ return (_jsx(MessengerVideoView, { player: player, nativeControls: true, style: { width: "100%", height: 240 } }));
33
+ }
34
+ export function ExpoMessageReviewInbox(props) {
35
+ return (_jsx(MessagingReviewInbox, { ...props, renderMedia: ({ url, kind }) => kind === "voice"
36
+ ? _jsx(ReviewVoice, { url: url })
37
+ : kind === "video"
38
+ ? _jsx(ReviewVideo, { url: url })
39
+ : _jsx(Text, { children: "This file type needs a host-provided private viewer." }) }));
40
+ }
@@ -1,3 +1,4 @@
1
+ import type { MessagingPlaybackEvent } from '@robono/messaging';
1
2
  import type { MessagingViewerPolicy } from '@robono/messaging';
2
3
  export { createExpoMessagingClient } from './expo-outbox.js';
3
4
  import React from 'react';
@@ -37,6 +38,8 @@ export interface ExpoMessagingScreenProps extends Omit<MessagingScreenProps, 'pi
37
38
  mediaViewer?: MessagingViewerPolicy<LocalMessagingMedia>;
38
39
  onDownloadAttachment?: MessagingAttachmentDownload;
39
40
  /** Optional timing callback from native image/frame/playback readiness, measured from opening. */
41
+ /** Observed playback events. Persist eventId for deduplication; never infer completion from start. */
42
+ onPlaybackEvent?: (event: MessagingPlaybackEvent) => void;
40
43
  onMediaReady?: (event: {
41
44
  messageId: string;
42
45
  kind: string;