@snakechat/commskit-node 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 +8 -8
- package/package.json +148 -148
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# commskit-node
|
|
1
|
+
# @snakechat/commskit-node
|
|
2
2
|
|
|
3
3
|
Node.js / TypeScript server for the commskit wire protocol. It is a sibling of the Python backend
|
|
4
4
|
(`../backend-python`, package `commskit`) and speaks exactly the same protocol
|
|
5
|
-
([`../../docs/archive/PROTOCOL.md`](
|
|
5
|
+
([`../../docs/archive/PROTOCOL.md`](https://github.com/prateek0128/chat-call-module/blob/main/docs/archive/PROTOCOL.md)), so the existing clients (`mobile/`, `web/`,
|
|
6
6
|
`examples/backend/demo-server-python` page) work against it unchanged. A database created by either backend works with the other
|
|
7
7
|
(same table and column names).
|
|
8
8
|
|
|
9
9
|
**Status: feature-complete.** Core, chat, call signalling, moderation (block / report / admin review),
|
|
10
10
|
devices + push (Expo, Apple VoIP), the Redis bridge and S3 storage are implemented. 172 tests pass (1 more is
|
|
11
11
|
skipped: it needs a real `redis-server`). Redis, S3, Expo and APNs are tested with fakes, not real services.
|
|
12
|
-
Guides: [`../../docs/backend/backend-node/`](
|
|
12
|
+
Guides: [`../../docs/backend/backend-node/`](https://github.com/prateek0128/chat-call-module/tree/main/docs/backend/backend-node).
|
|
13
13
|
|
|
14
14
|
Stack: TypeScript (strict), Node >= 20, ESM, `ws`, `kysely` (better-sqlite3 for tests/demo, `pg` for production),
|
|
15
15
|
`jose` (HS256 JWT, claim `uid`), tsup, vitest.
|
|
@@ -17,7 +17,7 @@ Stack: TypeScript (strict), Node >= 20, ESM, `ws`, `kysely` (better-sqlite3 for
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install commskit-node kysely ws jose
|
|
20
|
+
npm install @snakechat/commskit-node kysely ws jose
|
|
21
21
|
npm install better-sqlite3 # or: pg
|
|
22
22
|
npm install fastify # or: express (optional peer dependencies)
|
|
23
23
|
```
|
|
@@ -28,8 +28,8 @@ npm install fastify # or: express (optional peer dependencies)
|
|
|
28
28
|
import Fastify from "fastify";
|
|
29
29
|
import Database from "better-sqlite3";
|
|
30
30
|
import { Kysely, SqliteDialect } from "kysely";
|
|
31
|
-
import { ChatFeature, CommsHub, JwtAuth, ensureSchema } from "commskit-node";
|
|
32
|
-
import { commskitPlugin } from "commskit-node/fastify";
|
|
31
|
+
import { ChatFeature, CommsHub, JwtAuth, ensureSchema } from "@snakechat/commskit-node";
|
|
32
|
+
import { commskitPlugin } from "@snakechat/commskit-node/fastify";
|
|
33
33
|
|
|
34
34
|
const db = new Kysely<any>({ dialect: new SqliteDialect({ database: new Database("comms.db") }) });
|
|
35
35
|
await ensureSchema(db); // creates chats, messages, calls, comms_* tables (idempotent)
|
|
@@ -47,7 +47,7 @@ await app.listen({ port: 8080 });
|
|
|
47
47
|
```ts
|
|
48
48
|
import { createServer } from "node:http";
|
|
49
49
|
import express from "express";
|
|
50
|
-
import { commskitRouter, attach } from "commskit-node/express";
|
|
50
|
+
import { commskitRouter, attach } from "@snakechat/commskit-node/express";
|
|
51
51
|
|
|
52
52
|
const app = express();
|
|
53
53
|
app.use(commskitRouter(hub)); // /chats/...
|
|
@@ -60,7 +60,7 @@ No framework: `createServer((req, res) => restListener(hub)(req, res))` plus `hu
|
|
|
60
60
|
|
|
61
61
|
## Python name mapping
|
|
62
62
|
|
|
63
|
-
| Python (`commskit`) | Node (
|
|
63
|
+
| Python (`commskit`) | Node (`@snakechat/commskit-node`) |
|
|
64
64
|
|---|---|
|
|
65
65
|
| `CommsHub(auth=, session_factory=, users=, push=, ...)` | `new CommsHub({ auth, db, users, push, connections, rateLimiter, roleResolver, onHandlerError, cameOnlineCooldown })` |
|
|
66
66
|
| `ChatFeature(...).install(hub)` | `hub.install(new ChatFeature({ policy, storage, devices, config }))` |
|
package/package.json
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@snakechat/commskit-node",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Node.js/TypeScript server for the commskit wire protocol: chat, calls, moderation, push. Sibling of the Python `commskit` backend.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"chat",
|
|
7
|
-
"voice-call",
|
|
8
|
-
"video-call",
|
|
9
|
-
"webrtc",
|
|
10
|
-
"websocket",
|
|
11
|
-
"realtime",
|
|
12
|
-
"signaling",
|
|
13
|
-
"fastify",
|
|
14
|
-
"express",
|
|
15
|
-
"commskit"
|
|
16
|
-
],
|
|
17
|
-
"type": "module",
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/prateek0128/chat-call-module.git",
|
|
22
|
-
"directory": "backend/backend-node"
|
|
23
|
-
},
|
|
24
|
-
"homepage": "https://github.com/prateek0128/chat-call-module/tree/main/backend/backend-node#readme",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/prateek0128/chat-call-module/issues"
|
|
27
|
-
},
|
|
28
|
-
"publishConfig": {
|
|
29
|
-
"access": "public"
|
|
30
|
-
},
|
|
31
|
-
"engines": {
|
|
32
|
-
"node": ">=20"
|
|
33
|
-
},
|
|
34
|
-
"main": "./dist/index.js",
|
|
35
|
-
"types": "./dist/index.d.ts",
|
|
36
|
-
"exports": {
|
|
37
|
-
".": {
|
|
38
|
-
"types": "./dist/index.d.ts",
|
|
39
|
-
"import": "./dist/index.js"
|
|
40
|
-
},
|
|
41
|
-
"./core": {
|
|
42
|
-
"types": "./dist/core.d.ts",
|
|
43
|
-
"import": "./dist/core.js"
|
|
44
|
-
},
|
|
45
|
-
"./chat": {
|
|
46
|
-
"types": "./dist/chat.d.ts",
|
|
47
|
-
"import": "./dist/chat.js"
|
|
48
|
-
},
|
|
49
|
-
"./call": {
|
|
50
|
-
"types": "./dist/call.d.ts",
|
|
51
|
-
"import": "./dist/call.js"
|
|
52
|
-
},
|
|
53
|
-
"./moderation": {
|
|
54
|
-
"types": "./dist/moderation.d.ts",
|
|
55
|
-
"import": "./dist/moderation.js"
|
|
56
|
-
},
|
|
57
|
-
"./integration": {
|
|
58
|
-
"types": "./dist/integration.d.ts",
|
|
59
|
-
"import": "./dist/integration.js"
|
|
60
|
-
},
|
|
61
|
-
"./push": {
|
|
62
|
-
"types": "./dist/push.d.ts",
|
|
63
|
-
"import": "./dist/push.js"
|
|
64
|
-
},
|
|
65
|
-
"./redis": {
|
|
66
|
-
"types": "./dist/redis.d.ts",
|
|
67
|
-
"import": "./dist/redis.js"
|
|
68
|
-
},
|
|
69
|
-
"./s3": {
|
|
70
|
-
"types": "./dist/s3.d.ts",
|
|
71
|
-
"import": "./dist/s3.js"
|
|
72
|
-
},
|
|
73
|
-
"./fastify": {
|
|
74
|
-
"types": "./dist/fastify.d.ts",
|
|
75
|
-
"import": "./dist/fastify.js"
|
|
76
|
-
},
|
|
77
|
-
"./express": {
|
|
78
|
-
"types": "./dist/express.d.ts",
|
|
79
|
-
"import": "./dist/express.js"
|
|
80
|
-
},
|
|
81
|
-
"./package.json": "./package.json"
|
|
82
|
-
},
|
|
83
|
-
"files": [
|
|
84
|
-
"dist",
|
|
85
|
-
"LICENSE"
|
|
86
|
-
],
|
|
87
|
-
"scripts": {
|
|
88
|
-
"build": "tsup",
|
|
89
|
-
"test": "vitest run",
|
|
90
|
-
"typecheck": "tsc --noEmit",
|
|
91
|
-
"smoke": "node scripts/dist-smoke.mjs"
|
|
92
|
-
},
|
|
93
|
-
"dependencies": {
|
|
94
|
-
"jose": "^5.9.6",
|
|
95
|
-
"kysely": "^0.27.4",
|
|
96
|
-
"ws": "^8.18.0"
|
|
97
|
-
},
|
|
98
|
-
"peerDependencies": {
|
|
99
|
-
"better-sqlite3": "^11.0.0",
|
|
100
|
-
"express": "^4.19.0 || ^5.0.0",
|
|
101
|
-
"fastify": "^4.28.0 || ^5.0.0",
|
|
102
|
-
"pg": "^8.11.0",
|
|
103
|
-
"@aws-sdk/client-s3": "^3.600.0",
|
|
104
|
-
"@aws-sdk/s3-request-presigner": "^3.600.0",
|
|
105
|
-
"ioredis": "^5.4.0",
|
|
106
|
-
"sharp": "^0.33.0"
|
|
107
|
-
},
|
|
108
|
-
"peerDependenciesMeta": {
|
|
109
|
-
"better-sqlite3": {
|
|
110
|
-
"optional": true
|
|
111
|
-
},
|
|
112
|
-
"express": {
|
|
113
|
-
"optional": true
|
|
114
|
-
},
|
|
115
|
-
"fastify": {
|
|
116
|
-
"optional": true
|
|
117
|
-
},
|
|
118
|
-
"pg": {
|
|
119
|
-
"optional": true
|
|
120
|
-
},
|
|
121
|
-
"@aws-sdk/client-s3": {
|
|
122
|
-
"optional": true
|
|
123
|
-
},
|
|
124
|
-
"@aws-sdk/s3-request-presigner": {
|
|
125
|
-
"optional": true
|
|
126
|
-
},
|
|
127
|
-
"ioredis": {
|
|
128
|
-
"optional": true
|
|
129
|
-
},
|
|
130
|
-
"sharp": {
|
|
131
|
-
"optional": true
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
"devDependencies": {
|
|
135
|
-
"@types/better-sqlite3": "^7.6.11",
|
|
136
|
-
"@types/express": "^4.17.21",
|
|
137
|
-
"@types/node": "^20.14.0",
|
|
138
|
-
"@types/pg": "^8.11.10",
|
|
139
|
-
"@types/ws": "^8.5.12",
|
|
140
|
-
"better-sqlite3": "^11.5.0",
|
|
141
|
-
"express": "^4.21.0",
|
|
142
|
-
"fastify": "^4.28.1",
|
|
143
|
-
"pg": "^8.13.0",
|
|
144
|
-
"tsup": "^8.3.0",
|
|
145
|
-
"typescript": "^5.6.0",
|
|
146
|
-
"vitest": "^2.1.0"
|
|
147
|
-
}
|
|
148
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@snakechat/commskit-node",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Node.js/TypeScript server for the commskit wire protocol: chat, calls, moderation, push. Sibling of the Python `commskit` backend.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"chat",
|
|
7
|
+
"voice-call",
|
|
8
|
+
"video-call",
|
|
9
|
+
"webrtc",
|
|
10
|
+
"websocket",
|
|
11
|
+
"realtime",
|
|
12
|
+
"signaling",
|
|
13
|
+
"fastify",
|
|
14
|
+
"express",
|
|
15
|
+
"commskit"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/prateek0128/chat-call-module.git",
|
|
22
|
+
"directory": "backend/backend-node"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/prateek0128/chat-call-module/tree/main/backend/backend-node#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/prateek0128/chat-call-module/issues"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20"
|
|
33
|
+
},
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./core": {
|
|
42
|
+
"types": "./dist/core.d.ts",
|
|
43
|
+
"import": "./dist/core.js"
|
|
44
|
+
},
|
|
45
|
+
"./chat": {
|
|
46
|
+
"types": "./dist/chat.d.ts",
|
|
47
|
+
"import": "./dist/chat.js"
|
|
48
|
+
},
|
|
49
|
+
"./call": {
|
|
50
|
+
"types": "./dist/call.d.ts",
|
|
51
|
+
"import": "./dist/call.js"
|
|
52
|
+
},
|
|
53
|
+
"./moderation": {
|
|
54
|
+
"types": "./dist/moderation.d.ts",
|
|
55
|
+
"import": "./dist/moderation.js"
|
|
56
|
+
},
|
|
57
|
+
"./integration": {
|
|
58
|
+
"types": "./dist/integration.d.ts",
|
|
59
|
+
"import": "./dist/integration.js"
|
|
60
|
+
},
|
|
61
|
+
"./push": {
|
|
62
|
+
"types": "./dist/push.d.ts",
|
|
63
|
+
"import": "./dist/push.js"
|
|
64
|
+
},
|
|
65
|
+
"./redis": {
|
|
66
|
+
"types": "./dist/redis.d.ts",
|
|
67
|
+
"import": "./dist/redis.js"
|
|
68
|
+
},
|
|
69
|
+
"./s3": {
|
|
70
|
+
"types": "./dist/s3.d.ts",
|
|
71
|
+
"import": "./dist/s3.js"
|
|
72
|
+
},
|
|
73
|
+
"./fastify": {
|
|
74
|
+
"types": "./dist/fastify.d.ts",
|
|
75
|
+
"import": "./dist/fastify.js"
|
|
76
|
+
},
|
|
77
|
+
"./express": {
|
|
78
|
+
"types": "./dist/express.d.ts",
|
|
79
|
+
"import": "./dist/express.js"
|
|
80
|
+
},
|
|
81
|
+
"./package.json": "./package.json"
|
|
82
|
+
},
|
|
83
|
+
"files": [
|
|
84
|
+
"dist",
|
|
85
|
+
"LICENSE"
|
|
86
|
+
],
|
|
87
|
+
"scripts": {
|
|
88
|
+
"build": "tsup",
|
|
89
|
+
"test": "vitest run",
|
|
90
|
+
"typecheck": "tsc --noEmit",
|
|
91
|
+
"smoke": "node scripts/dist-smoke.mjs"
|
|
92
|
+
},
|
|
93
|
+
"dependencies": {
|
|
94
|
+
"jose": "^5.9.6",
|
|
95
|
+
"kysely": "^0.27.4",
|
|
96
|
+
"ws": "^8.18.0"
|
|
97
|
+
},
|
|
98
|
+
"peerDependencies": {
|
|
99
|
+
"better-sqlite3": "^11.0.0",
|
|
100
|
+
"express": "^4.19.0 || ^5.0.0",
|
|
101
|
+
"fastify": "^4.28.0 || ^5.0.0",
|
|
102
|
+
"pg": "^8.11.0",
|
|
103
|
+
"@aws-sdk/client-s3": "^3.600.0",
|
|
104
|
+
"@aws-sdk/s3-request-presigner": "^3.600.0",
|
|
105
|
+
"ioredis": "^5.4.0",
|
|
106
|
+
"sharp": "^0.33.0"
|
|
107
|
+
},
|
|
108
|
+
"peerDependenciesMeta": {
|
|
109
|
+
"better-sqlite3": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"express": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
115
|
+
"fastify": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"pg": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
121
|
+
"@aws-sdk/client-s3": {
|
|
122
|
+
"optional": true
|
|
123
|
+
},
|
|
124
|
+
"@aws-sdk/s3-request-presigner": {
|
|
125
|
+
"optional": true
|
|
126
|
+
},
|
|
127
|
+
"ioredis": {
|
|
128
|
+
"optional": true
|
|
129
|
+
},
|
|
130
|
+
"sharp": {
|
|
131
|
+
"optional": true
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"devDependencies": {
|
|
135
|
+
"@types/better-sqlite3": "^7.6.11",
|
|
136
|
+
"@types/express": "^4.17.21",
|
|
137
|
+
"@types/node": "^20.14.0",
|
|
138
|
+
"@types/pg": "^8.11.10",
|
|
139
|
+
"@types/ws": "^8.5.12",
|
|
140
|
+
"better-sqlite3": "^11.5.0",
|
|
141
|
+
"express": "^4.21.0",
|
|
142
|
+
"fastify": "^4.28.1",
|
|
143
|
+
"pg": "^8.13.0",
|
|
144
|
+
"tsup": "^8.3.0",
|
|
145
|
+
"typescript": "^5.6.0",
|
|
146
|
+
"vitest": "^2.1.0"
|
|
147
|
+
}
|
|
148
|
+
}
|