@orbitconnect/react 0.1.0 → 0.1.1

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  React SDK for OrbitConnect — drop in real-time chat, voice/video calls, and meetings into any React app.
4
4
 
5
- > The SDK connects exclusively to `https://orbitxyz.muvle.org/api/v1`. This base URL is fixed and cannot be overridden.
5
+ > Get your API keys at [orbitconnect.cloud](https://orbitconnect.cloud). All requests go to `https://api.orbitconnect.cloud/api/v1` this base URL is fixed and cannot be overridden.
6
6
 
7
7
  ## Install
8
8
 
@@ -16,9 +16,17 @@ Also import the stylesheet once in your entry file:
16
16
  import '@orbitconnect/react/index.css'
17
17
  ```
18
18
 
19
- ## Quick start
19
+ ---
20
+
21
+ ## Get started
22
+
23
+ ### 1. Create an account
24
+
25
+ Sign up at [orbitconnect.cloud](https://orbitconnect.cloud) to get your:
26
+ - `ORBIT_SECRET_KEY` — server-side secret key (`sk_live_…`)
27
+ - `ORBIT_CLIENT_ID` — publishable client ID (`pk_live_…`)
20
28
 
21
- ### 1. Backend — issue a user token
29
+ ### 2. Backend — issue a user token
22
30
 
23
31
  ```ts
24
32
  // Express / Next.js API route
@@ -36,7 +44,7 @@ app.post('/auth/token', async (req, res) => {
36
44
  })
37
45
  ```
38
46
 
39
- ### 2. Frontend — wrap with OrbitProvider
47
+ ### 3. Frontend — wrap with OrbitProvider
40
48
 
41
49
  ```tsx
42
50
  import { OrbitProvider, Chat } from '@orbitconnect/react'
@@ -215,6 +223,23 @@ const {
215
223
  } = useCall()
216
224
  ```
217
225
 
226
+ ### useMeeting()
227
+
228
+ ```ts
229
+ const {
230
+ meeting, // ActiveMeeting | null
231
+ joinMeeting, // (meetingId, title) => Promise<void>
232
+ leaveMeeting,
233
+ muteSelf,
234
+ unmuteSelf,
235
+ startScreenShare,
236
+ stopScreenShare,
237
+ raiseHand,
238
+ lowerHand,
239
+ sendReaction, // (emoji: string) => void
240
+ } = useMeeting()
241
+ ```
242
+
218
243
  ### useNotifications()
219
244
 
220
245
  ```ts
@@ -254,6 +279,12 @@ const {
254
279
  } = useRealtime()
255
280
  ```
256
281
 
282
+ ### useCallHistory()
283
+
284
+ ```ts
285
+ const { records } = useCallHistory() // CallRecord[]
286
+ ```
287
+
257
288
  ### useOrbitEvent(eventType, handler)
258
289
 
259
290
  Subscribe to any raw WebSocket event.
@@ -270,12 +301,6 @@ useOrbitEvent('notification:received', ({ payload }) => {
270
301
  })
271
302
  ```
272
303
 
273
- ### useCallHistory()
274
-
275
- ```ts
276
- const { records } = useCallHistory() // CallRecord[]
277
- ```
278
-
279
304
  ### useOrbit()
280
305
 
281
306
  Access the raw context from any child component.
@@ -361,14 +386,6 @@ When the server closes the WebSocket with code `4001` (token expired), the SDK c
361
386
 
362
387
  ---
363
388
 
364
- ## Build
365
-
366
- ```bash
367
- npm run build # tsc + vite build + tailwind CSS
368
- npm run dev # vite dev server (for SDK development)
369
- npm run lint # eslint
370
- ```
371
-
372
389
  ## License
373
390
 
374
- MIT
391
+ MIT — [orbitconnect.cloud](https://orbitconnect.cloud)
@@ -49,6 +49,13 @@ export interface AppConfig {
49
49
  enableMeetingUi?: boolean;
50
50
  /** Show "Powered by OrbitConnect" footer in Chat and Meeting widgets (default: true) */
51
51
  showPoweredBy?: boolean;
52
+ /**
53
+ * Enable end-to-end encryption for messages.
54
+ * When true, message content is encrypted client-side before sending
55
+ * and decrypted on receipt using the PSALMS + RSA dual-layer cipher.
56
+ * The conversation must also have is_e2e_enabled=true on the backend.
57
+ */
58
+ enableE2E?: boolean;
52
59
  /** Custom attachment button icon */
53
60
  attachmentIcon?: ReactNode;
54
61
  /** Custom voice-record button icon */
@@ -80,8 +87,12 @@ export interface OrbitContextValue {
80
87
  baseUrl: string;
81
88
  /** Optional branding config */
82
89
  appConfig?: AppConfig;
90
+ /** E2E key pair — present only when appConfig.enableE2E is true */
91
+ e2eKeys?: import('./e2e').E2EKeys;
92
+ /** Per-session key used by the PSALMS cipher layer */
93
+ e2eSessionKey?: string;
83
94
  }
84
95
  export declare const OrbitContext: import("react").Context<OrbitContextValue | null>;
85
96
  export declare function useOrbit(): OrbitContextValue;
86
97
  /** Convenience hook — returns appConfig with safe defaults applied */
87
- export declare function useAppConfig(): Required<Pick<AppConfig, 'showChatHeader' | 'showQuickMessageButton' | 'useRichTextEditor' | 'showAttachMentButton' | 'showSearchIcon' | 'showAudioIcon' | 'showVideoIcon' | 'enableMeetingUi' | 'showPoweredBy'>> & Pick<AppConfig, 'attachmentIcon' | 'recordIcon' | 'QuickmessageIcon' | 'emojIcon' | 'stickerIcon' | 'sendIcon' | 'deliveredIcon' | 'sentIcon' | 'readIcon' | 'callIcon' | 'VideoCallIcon'>;
98
+ export declare function useAppConfig(): Required<Pick<AppConfig, 'showChatHeader' | 'showQuickMessageButton' | 'useRichTextEditor' | 'showAttachMentButton' | 'showSearchIcon' | 'showAudioIcon' | 'showVideoIcon' | 'enableMeetingUi' | 'showPoweredBy' | 'enableE2E'>> & Pick<AppConfig, 'attachmentIcon' | 'recordIcon' | 'QuickmessageIcon' | 'emojIcon' | 'stickerIcon' | 'sendIcon' | 'deliveredIcon' | 'sentIcon' | 'readIcon' | 'callIcon' | 'VideoCallIcon'>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * E2E encryption for the React SDK.
3
+ * Layer 1: PSALMS arithmetic cipher
4
+ * Layer 2: RSA-OAEP via Web Crypto API
5
+ *
6
+ * Key pair is generated once per session and stored in memory.
7
+ * The public key is shared with the backend/other participants via the
8
+ * X-E2E-Public-Key header on the first message send.
9
+ */
10
+ export interface E2EKeys {
11
+ publicKey: CryptoKey;
12
+ privateKey: CryptoKey;
13
+ /** Exported SPKI public key as base64 — safe to share */
14
+ publicKeyB64: string;
15
+ }
16
+ /** Generate a fresh RSA-OAEP 2048-bit key pair */
17
+ export declare function generateE2EKeyPair(): Promise<E2EKeys>;
18
+ /** Import a base64 SPKI public key for encrypting to a recipient */
19
+ export declare function importPublicKey(b64: string): Promise<CryptoKey>;
20
+ /**
21
+ * Encrypt plaintext: PSALMS → RSA-OAEP
22
+ * Returns a compact JSON string safe to send as message content.
23
+ */
24
+ export declare function e2eEncrypt(plaintext: string, sessionKey: string, recipientPublicKey: CryptoKey): Promise<string>;
25
+ /**
26
+ * Decrypt: RSA-OAEP → PSALMS
27
+ */
28
+ export declare function e2eDecrypt(encryptedB64: string, sessionKey: string, privateKey: CryptoKey): Promise<string>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * PSALMS CIPHER — browser-compatible port
3
+ * Arithmetic cipher: add → subtract → divide (encrypt), reversed on decrypt.
4
+ * Uses Web Crypto API for IV generation.
5
+ */
6
+ export declare function psalmsEncrypt(plaintext: string, key: string): {
7
+ cipher: string;
8
+ iv: string;
9
+ };
10
+ export declare function psalmsDecrypt(cipher: string, iv: string, key: string): string;