@realtimexsco/live-chat 1.4.17 → 1.4.19
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/PERMISSIONS.md +209 -0
- package/README.md +3 -3
- package/dist/firebase-messaging-sw.js +5 -2
- package/dist/index.cjs +4614 -3632
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +161 -3
- package/dist/index.d.ts +161 -3
- package/dist/index.mjs +2915 -1937
- package/dist/index.mjs.map +1 -1
- package/package.json +34 -2
package/PERMISSIONS.md
CHANGED
|
@@ -56,6 +56,215 @@ Same rules apply in **DM and group** chats.
|
|
|
56
56
|
|
|
57
57
|
---
|
|
58
58
|
|
|
59
|
+
## Permission reference (with live examples)
|
|
60
|
+
|
|
61
|
+
Everything below comes from one response:
|
|
62
|
+
|
|
63
|
+
```http
|
|
64
|
+
GET /settings/effective
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"pushNotificationEnabled": true,
|
|
70
|
+
"audioCallEnabled": true,
|
|
71
|
+
"videoCallEnabled": true,
|
|
72
|
+
"blockUsersEnabled": true,
|
|
73
|
+
"groupCreationEnabled": true,
|
|
74
|
+
"calls": {
|
|
75
|
+
"allowedByPlatform": true,
|
|
76
|
+
"configured": true,
|
|
77
|
+
"enabled": true
|
|
78
|
+
},
|
|
79
|
+
"attachments": {
|
|
80
|
+
"enabled": true,
|
|
81
|
+
"maxFileSizeMB": 10,
|
|
82
|
+
"allowedMimeTypes": ["image/*", "video/*", "audio/*", "application/pdf"],
|
|
83
|
+
"maxAttachmentsPerMessage": 10
|
|
84
|
+
},
|
|
85
|
+
"groupPolicy": {
|
|
86
|
+
"defaults": {
|
|
87
|
+
"onlyAdminCanSendMessage": false,
|
|
88
|
+
"onlyAdminCanEditInfo": false,
|
|
89
|
+
"senderCanEditMessage": true,
|
|
90
|
+
"allowMemberAdd": true,
|
|
91
|
+
"allowMemberRemove": false,
|
|
92
|
+
"moderationEnabled": false
|
|
93
|
+
},
|
|
94
|
+
"locked": []
|
|
95
|
+
},
|
|
96
|
+
"messageTimers": {
|
|
97
|
+
"dmEditMinutes": 5,
|
|
98
|
+
"dmDeleteMinutes": 5,
|
|
99
|
+
"groupEditMinutes": 10,
|
|
100
|
+
"groupDeleteMinutes": 10
|
|
101
|
+
},
|
|
102
|
+
"maxAdminsPerGroup": 5,
|
|
103
|
+
"maxParticipantsPerGroup": 100,
|
|
104
|
+
"maxPinnedMessagesPerConversation": 10
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
These are the same values shipped as `DEFAULT_EFFECTIVE_SETTINGS` (used before the fetch resolves, and as a fallback if the fetch fails), so the examples below double as "what you get out of the box."
|
|
109
|
+
|
|
110
|
+
### `pushNotificationEnabled`
|
|
111
|
+
|
|
112
|
+
Single on/off switch for the push-notification row in Settings.
|
|
113
|
+
|
|
114
|
+
- Admin sets it `false` → the toggle row stays visible, the switch is disabled, hovering shows *"This feature is disabled by your administrator."*
|
|
115
|
+
- Check it yourself: `useAdminFeatureGate("pushNotification").enabled`
|
|
116
|
+
|
|
117
|
+
### `audioCallEnabled` / `videoCallEnabled`
|
|
118
|
+
|
|
119
|
+
Per-call-type switches for the header phone / video buttons. They are evaluated **after** the three `calls.*` gates below — see [Calls check order](#calls-check-order).
|
|
120
|
+
|
|
121
|
+
- `videoCallEnabled: false`, everything else `true` → video button greyed out, tooltip *"This feature is disabled by your administrator."*; phone button unaffected.
|
|
122
|
+
- Check it yourself: `useAdminFeatureGate("videoCall")` / `useAdminFeatureGate("audioCall")`
|
|
123
|
+
|
|
124
|
+
### `calls.allowedByPlatform` / `calls.configured` / `calls.enabled`
|
|
125
|
+
|
|
126
|
+
Three gates checked **in order** before `audioCallEnabled`/`videoCallEnabled` are even looked at — first failing one wins:
|
|
127
|
+
|
|
128
|
+
| Field is `false` | Tooltip shown |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `calls.allowedByPlatform` | *"Calls are not allowed on this platform. Please contact your administrator."* |
|
|
131
|
+
| `calls.configured` | *"Calls are not configured. Please contact your administrator."* |
|
|
132
|
+
| `calls.enabled` | *"This feature is disabled by your administrator."* |
|
|
133
|
+
|
|
134
|
+
Example: a workspace on a plan without calling has `"calls": { "allowedByPlatform": false, "configured": true, "enabled": true }`. Both call buttons stay visible but disabled with the "not allowed on this platform" message — `videoCallEnabled: true` doesn't matter, the platform check runs first.
|
|
135
|
+
|
|
136
|
+
### `blockUsersEnabled`
|
|
137
|
+
|
|
138
|
+
Gates the "Block user" item in the conversation's overflow menu.
|
|
139
|
+
|
|
140
|
+
- `false` → menu item stays visible, disabled, tooltip *"This feature is disabled by your administrator."*
|
|
141
|
+
- Check it yourself: `useAdminFeatureGate("blockUsers").enabled`
|
|
142
|
+
|
|
143
|
+
### `attachments.enabled`
|
|
144
|
+
|
|
145
|
+
Master switch for the paperclip / attach button.
|
|
146
|
+
|
|
147
|
+
- `false` → attach button visible but disabled, same tooltip pattern.
|
|
148
|
+
- Check it yourself: `useAdminFeatureGate("attachments").enabled`
|
|
149
|
+
|
|
150
|
+
### `attachments.maxFileSizeMB`
|
|
151
|
+
|
|
152
|
+
Per-file size ceiling, enforced client-side before upload.
|
|
153
|
+
|
|
154
|
+
- `maxFileSizeMB: 10` and the user picks a 15 MB video → the picker rejects it before it's added to the message.
|
|
155
|
+
- Read the raw value (there's no gate for this, it's a limit not a boolean): `useEffectiveSettingsOptional().settings.attachments.maxFileSizeMB`
|
|
156
|
+
|
|
157
|
+
### `attachments.allowedMimeTypes`
|
|
158
|
+
|
|
159
|
+
Whitelist of MIME patterns the file picker accepts. `"*"` or `"*/*"` in the list means "allow everything."
|
|
160
|
+
|
|
161
|
+
- `["image/*", "application/pdf"]` → the file picker's `accept` attribute (and any manual filtering) only allows images and PDFs; a `.zip` is rejected.
|
|
162
|
+
- Read it: `settings.attachments.allowedMimeTypes`
|
|
163
|
+
|
|
164
|
+
### `attachments.maxAttachmentsPerMessage`
|
|
165
|
+
|
|
166
|
+
Caps how many files can ride on one message.
|
|
167
|
+
|
|
168
|
+
- `maxAttachmentsPerMessage: 10` and the user has already attached 10 images → the attach button (or drop zone) stops accepting more until one is removed.
|
|
169
|
+
|
|
170
|
+
### `groupCreationEnabled`
|
|
171
|
+
|
|
172
|
+
Gates the "New group" tab in the create-chat dialog.
|
|
173
|
+
|
|
174
|
+
- `false` → tab stays visible, disabled, tooltip explains why.
|
|
175
|
+
- Check it yourself: `useAdminFeatureGate("groupCreation").enabled`
|
|
176
|
+
|
|
177
|
+
### `groupPolicy.defaults` — starting permissions for a *new* group
|
|
178
|
+
|
|
179
|
+
Each key seeds the permission drawer when a group is created; group admins can still change them afterward **unless locked** (see next section).
|
|
180
|
+
|
|
181
|
+
| Key | Meaning | Example |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| `onlyAdminCanSendMessage` | If `true`, only admins can post — everyone else is read-only | Announcement-only groups set this `true` |
|
|
184
|
+
| `onlyAdminCanEditInfo` | If `true`, only admins can change group name/avatar/description | Prevents members from renaming the group |
|
|
185
|
+
| `senderCanEditMessage` | If `true`, a member can edit their own sent messages | `false` disables the "Edit" option on your own messages |
|
|
186
|
+
| `allowMemberAdd` | If `true`, non-admin members can add other people | `false` restricts inviting to admins only |
|
|
187
|
+
| `allowMemberRemove` | If `true`, non-admin members can remove other members | Usually left `false`; only admins remove people |
|
|
188
|
+
| `moderationEnabled` | If `true`, messages go through the moderation pipeline before appearing | Turned on for public/large groups |
|
|
189
|
+
|
|
190
|
+
### `groupPolicy.locked` — permissions the workspace admin has frozen
|
|
191
|
+
|
|
192
|
+
An array of the `GroupPermissions` keys above (or arbitrary policy keys) that a **group admin cannot toggle** in the permission drawer, no matter what they pick.
|
|
193
|
+
|
|
194
|
+
- `"locked": ["onlyAdminCanSendMessage", "moderationEnabled"]` → in the group's permission drawer, those two rows render disabled at whatever value `defaults` set them to; every other row stays editable.
|
|
195
|
+
- Check it yourself: `useEffectiveSettingsOptional().isGroupPermissionLocked("onlyAdminCanSendMessage")` → `true`/`false`
|
|
196
|
+
|
|
197
|
+
### `messageTimers.*`
|
|
198
|
+
|
|
199
|
+
Editable/deletable time windows, split by conversation type. Each is "minutes since send."
|
|
200
|
+
|
|
201
|
+
- `dmEditMinutes: 5` → in a 1:1 chat, the "Edit" option disappears from a message 5 minutes after it was sent.
|
|
202
|
+
- `groupDeleteMinutes: 10` → in a group, "Delete for everyone" disappears 10 minutes after send (still allows "Delete for me").
|
|
203
|
+
- `dmDeleteMinutes` / `groupEditMinutes` follow the same pattern for their combination.
|
|
204
|
+
|
|
205
|
+
### `maxAdminsPerGroup`
|
|
206
|
+
|
|
207
|
+
Ceiling on how many members can hold admin rights in one group.
|
|
208
|
+
|
|
209
|
+
- `maxAdminsPerGroup: 5` and a group already has 5 admins → the "Make admin" action is disabled for remaining members until an existing admin is demoted.
|
|
210
|
+
|
|
211
|
+
### `maxParticipantsPerGroup`
|
|
212
|
+
|
|
213
|
+
Ceiling on total members in a group.
|
|
214
|
+
|
|
215
|
+
- `maxParticipantsPerGroup: 100` and the group has 100 members → "Add members" stops accepting new invites, whether the group was created here or is at the platform-wide cap.
|
|
216
|
+
|
|
217
|
+
### `maxPinnedMessagesPerConversation`
|
|
218
|
+
|
|
219
|
+
Ceiling on pinned messages, per conversation (DM or group).
|
|
220
|
+
|
|
221
|
+
- `maxPinnedMessagesPerConversation: 10` and 10 messages are already pinned → the "Pin" action on an 11th message is disabled until something is unpinned.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Setting these values (important: read this before asking "how do I set X")
|
|
226
|
+
|
|
227
|
+
The package calls **`GET /settings/effective`** ([settings.api.ts](src/services/api/settings.api.ts)) — it only *reads* this JSON, there is no `PUT`/`POST` in this SDK for most of it. Where a value comes from splits into two groups:
|
|
228
|
+
|
|
229
|
+
### Group A — workspace-wide settings (backend/admin-panel only)
|
|
230
|
+
|
|
231
|
+
`calls.allowedByPlatform`, `calls.configured`, `calls.enabled`, `audioCallEnabled`, `videoCallEnabled`, `pushNotificationEnabled`, `blockUsersEnabled`, `groupCreationEnabled`, `attachments.*`, `messageTimers.*`, `maxAdminsPerGroup`, `maxParticipantsPerGroup`, `maxPinnedMessagesPerConversation`, and `groupPolicy.locked`.
|
|
232
|
+
|
|
233
|
+
**This npm package cannot set these.** They're whatever your backend returns from `/settings/effective` — that response is produced by your server/admin dashboard, which lives outside this SDK. To change `calls.allowedByPlatform` or `maxAdminsPerGroup`, go to wherever your team configures that endpoint (admin panel, database row, backend config) and change it there. Once changed, the package picks it up automatically on the next `refresh()` (or next mount) — no package-side action needed.
|
|
234
|
+
|
|
235
|
+
If you don't have that admin panel yet, this SDK doesn't provide one — you'd build/expose it server-side and have it write into the same store `/settings/effective` reads from.
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
// You CANNOT do this — there is no setter for workspace settings:
|
|
239
|
+
// settings.calls.allowedByPlatform = false ❌ read-only, and mutating it wouldn't call the server anyway
|
|
240
|
+
// settings.maxAdminsPerGroup = 10 ❌ same
|
|
241
|
+
|
|
242
|
+
// What you CAN do: re-fetch after the backend/admin side changes it
|
|
243
|
+
const { refresh } = useEffectiveSettingsOptional();
|
|
244
|
+
await refresh(); // re-pulls GET /settings/effective
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Group B — per-conversation group permissions (settable from this package)
|
|
248
|
+
|
|
249
|
+
Only the 6 `groupPolicy.defaults` keys (`onlyAdminCanSendMessage`, `onlyAdminCanEditInfo`, `senderCanEditMessage`, `allowMemberAdd`, `allowMemberRemove`, `moderationEnabled`) can be changed through this SDK, and only **per group**, and only for keys **not** in `groupPolicy.locked` — a locked key always wins regardless of what a group admin submits.
|
|
250
|
+
|
|
251
|
+
This ships as `PermissionDrawer` in the default UI, backed by the store action `updateGroupPermissions`, which calls `POST /conversation/group/permission/update`:
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
import { useStore } from "@realtimexsco/live-chat";
|
|
255
|
+
|
|
256
|
+
const updateGroupPermissions = useStore((s) => s.updateGroupPermissions);
|
|
257
|
+
|
|
258
|
+
// Toggle "only admins can send messages" on for this one group
|
|
259
|
+
await updateGroupPermissions(conversationId, {
|
|
260
|
+
onlyAdminCanSendMessage: true,
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Server-side, locked keys should be rejected/ignored even if a client sends them — the drawer already keeps locked rows disabled, but don't rely on the client alone to enforce that.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
59
268
|
## Exports you need
|
|
60
269
|
|
|
61
270
|
```ts
|
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
> Drop-in real-time chat UI for React and Next.js — direct messages, group chats, reactions, replies, forwarding, pinned/starred messages, and more. Built on Socket.IO, Zustand, Tailwind CSS v4, and Radix UI.
|
|
4
4
|
|
|
5
|
-
[npm version](https://www.npmjs.com/package/@realtimexsco/live-chat)
|
|
6
|
-
[npm downloads](https://www.npmjs.com/package/@realtimexsco/live-chat)
|
|
7
|
-
[
|
|
5
|
+
[](https://www.npmjs.com/package/@realtimexsco/live-chat)
|
|
6
|
+
[](https://www.npmjs.com/package/@realtimexsco/live-chat)
|
|
7
|
+
[](#license)
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
| | |
|
|
@@ -314,14 +314,17 @@ if (rawConfig) {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
var data = payload.data || {};
|
|
317
|
+
var isCall = data.kind === "call";
|
|
317
318
|
var title =
|
|
318
319
|
(payload.notification && payload.notification.title) ||
|
|
319
320
|
data.title ||
|
|
320
|
-
|
|
321
|
+
(isCall
|
|
322
|
+
? "Incoming " + (data.mode === "video" ? "video" : "voice") + " call"
|
|
323
|
+
: "New message");
|
|
321
324
|
var body =
|
|
322
325
|
(payload.notification && payload.notification.body) ||
|
|
323
326
|
data.body ||
|
|
324
|
-
"";
|
|
327
|
+
(isCall ? "Tap to open the chat" : "");
|
|
325
328
|
|
|
326
329
|
console.log(
|
|
327
330
|
"[realtimex-push] single background notification:",
|