@lynkoria/client 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/CHANGELOG.md +9 -0
- package/README.md +53 -14
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,41 +1,80 @@
|
|
|
1
1
|
# @lynkoria/client
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@lynkoria/client)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
|
|
6
|
+
Client SDK for **browsers and Electron**: realtime messaging, presence, typing, attachments and calls.
|
|
7
|
+
Your app never holds a service key. It gets short-lived tokens from **your** backend, which authorizes the
|
|
8
|
+
user and asks Lynkoria for them with [`@lynkoria/server`](https://www.npmjs.com/package/@lynkoria/server).
|
|
9
|
+
|
|
10
|
+
**[Documentation](https://lynkoria.com/docs/)** · [Client SDK guide](https://lynkoria.com/docs/client-sdk/) ·
|
|
11
|
+
[Quickstart](https://lynkoria.com/docs/quickstart/) · [Messaging](https://lynkoria.com/docs/messaging/) ·
|
|
12
|
+
[Calls](https://lynkoria.com/docs/calls/)
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @lynkoria/client
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
ES module with TypeScript types. `livekit-client` is only loaded when a user joins a call, so messaging-only
|
|
21
|
+
apps do not download the media engine.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
6
24
|
|
|
7
25
|
```ts
|
|
8
26
|
import { createLynkoria } from '@lynkoria/client';
|
|
9
27
|
|
|
10
28
|
const rtc = createLynkoria({
|
|
11
29
|
baseUrl: 'https://api.lynkoria.com',
|
|
12
|
-
getMessagingToken: () =>
|
|
30
|
+
getMessagingToken: () => myBackend.fetchLynkoriaMessagingToken(),
|
|
13
31
|
});
|
|
14
32
|
|
|
15
33
|
rtc.connect();
|
|
16
|
-
const history = await rtc.messages.history('conv_123'); // also starts seq tracking
|
|
17
|
-
const off = rtc.onMessage((event) => render(event)); // ordered, deduplicated, gap-resynced
|
|
18
34
|
|
|
35
|
+
// Messaging: history, live events and sending.
|
|
36
|
+
const history = await rtc.messages.history('conv_123');
|
|
37
|
+
const off = rtc.onMessage((event) => render(event)); // ordered, deduplicated, resynced after gaps
|
|
19
38
|
await rtc.messages.send({
|
|
20
39
|
conversationId: 'conv_123',
|
|
21
|
-
clientMessageId: rtc.ids.create(),
|
|
40
|
+
clientMessageId: rtc.ids.create(), // retry with the same ID: never duplicates
|
|
22
41
|
text: 'Hello',
|
|
23
42
|
});
|
|
24
43
|
|
|
44
|
+
// Presence.
|
|
25
45
|
const unsubscribe = rtc.presence.subscribe('user_456', (p) => render(p.status));
|
|
26
46
|
|
|
27
|
-
|
|
47
|
+
// Calls: your backend returns a join token from @lynkoria/server.
|
|
48
|
+
const session = await rtc.calls.join({ getJoinToken: () => myBackend.fetchJoinToken('call_789') });
|
|
28
49
|
await session.setMicrophoneEnabled(false);
|
|
29
50
|
await session.startScreenShare();
|
|
30
51
|
```
|
|
31
52
|
|
|
53
|
+
## What it covers
|
|
54
|
+
|
|
55
|
+
| Area | API | Guide |
|
|
56
|
+
| ------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
57
|
+
| Connection | `connect`, `disconnect`, `onConnectionState`, `onError` | [Client SDK](https://lynkoria.com/docs/client-sdk/) |
|
|
58
|
+
| Messages | `messages.history`, `send`, `edit`, `delete`, `react`, `markRead`, `onMessage`, `onRead` | [Messaging](https://lynkoria.com/docs/messaging/) |
|
|
59
|
+
| Conversations | `conversations.list`, `track`, `untrack`, `resync`, `onConversationUpdated` | [Messaging](https://lynkoria.com/docs/messaging/) |
|
|
60
|
+
| Presence | `presence.subscribe`, `get`, `setStatus`, `typing.start`, `stop`, `onTyping` | [Presence](https://lynkoria.com/docs/presence/) |
|
|
61
|
+
| Attachments | `attachments.upload`, `downloadUrl` | [File security](https://lynkoria.com/docs/file-security-and-scanning/) |
|
|
62
|
+
| Calls | `calls.join`, mute, camera, screen share, devices, participants | [Calls](https://lynkoria.com/docs/calls/) |
|
|
63
|
+
|
|
32
64
|
## Delivery guarantees
|
|
33
65
|
|
|
34
|
-
PostgreSQL is the source of truth. Realtime events carry a per-conversation `seq
|
|
35
|
-
|
|
36
|
-
|
|
66
|
+
PostgreSQL is the source of truth. Realtime events carry a per-conversation `seq`: the client applies them
|
|
67
|
+
in order, drops duplicates, and after a gap or a reconnect fetches the missed events. Retrying `send` with
|
|
68
|
+
the same `clientMessageId` never creates a duplicate.
|
|
69
|
+
|
|
70
|
+
## Frameworks
|
|
71
|
+
|
|
72
|
+
- React: [`@lynkoria/react`](https://www.npmjs.com/package/@lynkoria/react) hooks.
|
|
73
|
+
- Next.js and TanStack Start: [Next.js guide](https://lynkoria.com/docs/nextjs/), [TanStack guide](https://lynkoria.com/docs/tanstack/).
|
|
74
|
+
- React Native: messaging works with platform `fetch` and an ID generator
|
|
75
|
+
(`ids: { create: () => yourUuid() }` when `crypto.randomUUID` is missing). For native calls, use
|
|
76
|
+
[`@lynkoria/react-native`](https://www.npmjs.com/package/@lynkoria/react-native).
|
|
37
77
|
|
|
38
|
-
##
|
|
78
|
+
## License
|
|
39
79
|
|
|
40
|
-
|
|
41
|
-
supported). If `crypto.randomUUID` is missing, pass `ids: { create: () => yourUuid() }`.
|
|
80
|
+
[Apache-2.0](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynkoria/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Lynkoria communications client SDK (browser, Electron, React Native)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lynkoria/contracts": "^0.1.
|
|
26
|
+
"@lynkoria/contracts": "^0.1.1",
|
|
27
27
|
"livekit-client": "^2.24.0",
|
|
28
28
|
"socket.io-client": "^4.8.4"
|
|
29
29
|
},
|