@orbitconnect/react 0.1.0 → 0.1.3
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 +36 -19
- package/dist/OrbitContext.d.ts +14 -1
- package/dist/e2e/index.d.ts +28 -0
- package/dist/e2e/psalms.d.ts +10 -0
- package/dist/index.js +867 -760
- package/package.json +6 -2
- package/CHANGELOG.md +0 -56
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
|
-
>
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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)
|
package/dist/OrbitContext.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface AppConfig {
|
|
|
33
33
|
sounds?: SoundConfig;
|
|
34
34
|
/** Show the chat header bar (default: true) */
|
|
35
35
|
showChatHeader?: boolean;
|
|
36
|
+
/** Show the conversation list header — brand/title + new-chat button (default: true) */
|
|
37
|
+
showConversationHeader?: boolean;
|
|
36
38
|
/** Show the quick-message button in the composer (default: true) */
|
|
37
39
|
showQuickMessageButton?: boolean;
|
|
38
40
|
/** Use the rich-text (contentEditable) editor; false = plain textarea (default: true) */
|
|
@@ -49,6 +51,13 @@ export interface AppConfig {
|
|
|
49
51
|
enableMeetingUi?: boolean;
|
|
50
52
|
/** Show "Powered by OrbitConnect" footer in Chat and Meeting widgets (default: true) */
|
|
51
53
|
showPoweredBy?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Enable end-to-end encryption for messages.
|
|
56
|
+
* When true, message content is encrypted client-side before sending
|
|
57
|
+
* and decrypted on receipt using the PSALMS + RSA dual-layer cipher.
|
|
58
|
+
* The conversation must also have is_e2e_enabled=true on the backend.
|
|
59
|
+
*/
|
|
60
|
+
enableE2E?: boolean;
|
|
52
61
|
/** Custom attachment button icon */
|
|
53
62
|
attachmentIcon?: ReactNode;
|
|
54
63
|
/** Custom voice-record button icon */
|
|
@@ -80,8 +89,12 @@ export interface OrbitContextValue {
|
|
|
80
89
|
baseUrl: string;
|
|
81
90
|
/** Optional branding config */
|
|
82
91
|
appConfig?: AppConfig;
|
|
92
|
+
/** E2E key pair — present only when appConfig.enableE2E is true */
|
|
93
|
+
e2eKeys?: import('./e2e').E2EKeys;
|
|
94
|
+
/** Per-session key used by the PSALMS cipher layer */
|
|
95
|
+
e2eSessionKey?: string;
|
|
83
96
|
}
|
|
84
97
|
export declare const OrbitContext: import("react").Context<OrbitContextValue | null>;
|
|
85
98
|
export declare function useOrbit(): OrbitContextValue;
|
|
86
99
|
/** 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'>;
|
|
100
|
+
export declare function useAppConfig(): Required<Pick<AppConfig, 'showChatHeader' | 'showConversationHeader' | '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;
|