@lynkoria/server 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 +58 -10
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
# @lynkoria/server
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@lynkoria/server)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
|
|
6
|
+
Server SDK for your **product backend**. Your backend authorizes the user, then asks Lynkoria for short-lived
|
|
7
|
+
tokens with its **service key**: join tokens for calls and livestreams, and messaging tokens for chat and
|
|
8
|
+
presence. It also creates calls and conversations, moderates users and verifies webhooks.
|
|
9
|
+
|
|
10
|
+
> Keep the service key on the server. Never ship it to a browser or mobile app.
|
|
11
|
+
|
|
12
|
+
**[Documentation](https://lynkoria.com/docs/)** · [Server SDK guide](https://lynkoria.com/docs/server-sdk/) ·
|
|
13
|
+
[Quickstart](https://lynkoria.com/docs/quickstart/) · [Webhooks](https://lynkoria.com/docs/webhooks/)
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @lynkoria/server
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires Node.js 22.12 or later. ES module with TypeScript types.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
6
24
|
|
|
7
25
|
```ts
|
|
8
26
|
import { createLynkoriaServer } from '@lynkoria/server';
|
|
@@ -13,8 +31,10 @@ const lynkoria = createLynkoriaServer({
|
|
|
13
31
|
webhookSecret: process.env.LYNKORIA_WEBHOOK_SECRET,
|
|
14
32
|
});
|
|
15
33
|
|
|
34
|
+
// 1. Create (or reuse) a call for something in your product.
|
|
16
35
|
const call = await lynkoria.calls.create({ productCallId: 'call_789', type: 'group' });
|
|
17
|
-
|
|
36
|
+
|
|
37
|
+
// 2. After your own authorization checks, give this user a join token.
|
|
18
38
|
const { url, token } = await lynkoria.calls.joinToken({
|
|
19
39
|
callId: call.id,
|
|
20
40
|
userId: session.userId,
|
|
@@ -23,15 +43,43 @@ const { url, token } = await lynkoria.calls.joinToken({
|
|
|
23
43
|
role: 'participant',
|
|
24
44
|
});
|
|
25
45
|
|
|
46
|
+
// 3. Messaging: a short-lived token for @lynkoria/client.
|
|
26
47
|
const { token: messagingToken } = await lynkoria.sessions.messagingToken({
|
|
27
|
-
userId,
|
|
28
|
-
deviceId,
|
|
29
|
-
tenantId,
|
|
48
|
+
userId: session.userId,
|
|
49
|
+
deviceId: session.deviceId,
|
|
30
50
|
});
|
|
31
51
|
|
|
32
|
-
//
|
|
52
|
+
// 4. Webhooks: verify the signature on the raw request body.
|
|
33
53
|
const event = lynkoria.webhooks.verify(rawBody, req.headers['lynkoria-signature']);
|
|
34
54
|
```
|
|
35
55
|
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
Return `url` and `token` (or `messagingToken`) to your app, which passes them to
|
|
57
|
+
[`@lynkoria/client`](https://www.npmjs.com/package/@lynkoria/client) or a native SDK.
|
|
58
|
+
|
|
59
|
+
## What it covers
|
|
60
|
+
|
|
61
|
+
| Area | Methods | Guide |
|
|
62
|
+
| ------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
63
|
+
| Calls | `calls.create`, `get`, `joinToken`, `end`, `removeParticipant`, `setRole`, `signal` | [Calls](https://lynkoria.com/docs/calls/) |
|
|
64
|
+
| Messaging | `sessions.messagingToken`, `conversations.create`, `addMembers`, `removeMember` | [Messaging](https://lynkoria.com/docs/messaging/) |
|
|
65
|
+
| Users | `users.suspend`, `unsuspend` | [Server SDK](https://lynkoria.com/docs/server-sdk/) |
|
|
66
|
+
| Notifications | `notifications.send` | [Push](https://lynkoria.com/docs/push-notifications/) |
|
|
67
|
+
| Recordings | `recordings.start`, `list`, `get`, `stop`, `download`, `delete` | [Recording](https://lynkoria.com/docs/recording-and-egress/) |
|
|
68
|
+
| Webhooks | `webhooks.verify`, or the standalone `verifyWebhook` | [Webhooks](https://lynkoria.com/docs/webhooks/) |
|
|
69
|
+
|
|
70
|
+
The full method list is in the [server SDK reference](https://lynkoria.com/docs/server-sdk/).
|
|
71
|
+
|
|
72
|
+
## Errors and delivery
|
|
73
|
+
|
|
74
|
+
Failed calls throw `LynkoriaError` with `code`, `status` and `requestId`; see [errors](https://lynkoria.com/docs/errors/).
|
|
75
|
+
Webhooks are delivered at least once, so deduplicate by `event.id`.
|
|
76
|
+
|
|
77
|
+
## Related packages
|
|
78
|
+
|
|
79
|
+
- [`@lynkoria/client`](https://www.npmjs.com/package/@lynkoria/client): browser and Electron client.
|
|
80
|
+
- [`@lynkoria/react`](https://www.npmjs.com/package/@lynkoria/react): React hooks.
|
|
81
|
+
- [`@lynkoria/contracts`](https://www.npmjs.com/package/@lynkoria/contracts): shared schemas, events and error codes.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
[Apache-2.0](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynkoria/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Lynkoria server SDK for product backends: calls, tokens, conversations, webhook verification",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@lynkoria/contracts": "^0.1.
|
|
29
|
+
"@lynkoria/contracts": "^0.1.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@lynkoria/config": "0.0.0",
|