video-saas-admin 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 +42 -0
- package/dist/index.js +20 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# video-saas-admin
|
|
2
|
+
|
|
3
|
+
Admin SDK for Video SaaS. Use this **server-side only** to generate short-lived room tokens for your frontend.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install video-saas-admin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { VideoSaasAdmin } from "video-saas-admin";
|
|
15
|
+
|
|
16
|
+
const admin = new VideoSaasAdmin({ apiKey: process.env.VIDEO_SAAS_API_KEY });
|
|
17
|
+
|
|
18
|
+
// In your API route / backend handler:
|
|
19
|
+
const token = await admin.createRoomToken("room-123");
|
|
20
|
+
res.json({ token }); // send to your frontend
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then on the frontend, pass the token to `video-saas-client`:
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
import { useVideoCall } from "video-saas-client";
|
|
27
|
+
|
|
28
|
+
const { localStream, remoteStreams, leaveRoom } = useVideoCall(roomId, { token });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
### `new VideoSaasAdmin({ apiKey, serverUrl? })`
|
|
34
|
+
|
|
35
|
+
| Option | Type | Required | Description |
|
|
36
|
+
|--------|------|----------|-------------|
|
|
37
|
+
| `apiKey` | string | Yes | Your secret API key (keep server-side only) |
|
|
38
|
+
| `serverUrl` | string | No | Defaults to `https://video-saas.breakbyte.com` |
|
|
39
|
+
|
|
40
|
+
### `admin.createRoomToken(roomId)`
|
|
41
|
+
|
|
42
|
+
Returns a `Promise<string>` — a signed JWT valid for 1 hour, scoped to the given `roomId`.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/index.js
|
|
2
|
+
var VideoSaasAdmin = class {
|
|
3
|
+
constructor({ apiKey, serverUrl = "https://video-saas.breakbyte.com" }) {
|
|
4
|
+
if (!apiKey) throw new Error("apiKey is required");
|
|
5
|
+
this.apiKey = apiKey;
|
|
6
|
+
this.serverUrl = serverUrl.replace(/\/$/, "");
|
|
7
|
+
}
|
|
8
|
+
async createRoomToken(roomId) {
|
|
9
|
+
if (!roomId) throw new Error("roomId is required");
|
|
10
|
+
const res = await fetch(`${this.serverUrl}/api/create-token`, {
|
|
11
|
+
method: "POST",
|
|
12
|
+
headers: { "Content-Type": "application/json" },
|
|
13
|
+
body: JSON.stringify({ apiKey: this.apiKey, roomId })
|
|
14
|
+
});
|
|
15
|
+
const data = await res.json();
|
|
16
|
+
if (!res.ok) throw new Error(data.error || "Failed to create token");
|
|
17
|
+
return data.token;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
module.exports = { VideoSaasAdmin };
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "video-saas-admin",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Admin SDK for Video SaaS — generate room tokens server-side",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.0.0"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "node build.js",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"esbuild": "^0.27.4"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/nafiztalukder/video-saas.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"video",
|
|
26
|
+
"saas",
|
|
27
|
+
"admin",
|
|
28
|
+
"sdk"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT"
|
|
31
|
+
}
|