@paramms/chat-widget 1.0.31 → 1.0.32

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/dist/react.d.ts CHANGED
@@ -9,6 +9,13 @@ interface BaseProps {
9
9
  apiUrl?: string;
10
10
  /** Your Relay profile ID — set as NEXT_PUBLIC_RELAY_PROFILE_ID in .env — required */
11
11
  profileId: string;
12
+ /** A signed identity token — an ES256 JWT `{sub,iat,exp}` minted by YOUR
13
+ * backend for chatrooms with signed identity (guestPublicKey) enabled.
14
+ * This is the production identity tier; wins over `userId`. */
15
+ token?: string;
16
+ /** Called when a signed token expires: return a fresh token from your
17
+ * backend to renew the session without a reload. */
18
+ refreshToken?: () => Promise<string | null>;
12
19
  /** Your logged-in user's stable ID. When omitted the widget automatically
13
20
  * assigns a persistent anonymous ID from localStorage — no login required. */
14
21
  userId?: string;
@@ -49,7 +56,7 @@ export interface ChatWidgetProps extends BaseProps {
49
56
  * @example Basic support chat
50
57
  * ```tsx
51
58
  * <ChatWidget
52
- * url={process.env.NEXT_PUBLIC_RELAY_WS_URL}
59
+ * url={process.env.NEXT_PUBLIC_RELAY_URL}
53
60
  * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}
54
61
  * userId={session?.user.id}
55
62
  * userName={session?.user.name}
@@ -57,19 +64,22 @@ export interface ChatWidgetProps extends BaseProps {
57
64
  * />
58
65
  * ```
59
66
  *
60
- * @example Multi-thread (tickets, bookings, orders)
67
+ * @example Multi-thread (tickets, bookings, orders) — one thread per subjectId
61
68
  * ```tsx
62
69
  * <ChatWidget
63
70
  * url={...} profileId={...}
64
- * showChatList
65
71
  * subjectId={`ticket_${ticket.id}`}
66
72
  * contextTitle={ticket.title}
67
73
  * contextStatus={ticket.status}
68
74
  * userId={session?.user.id}
69
75
  * />
70
76
  * ```
77
+ *
78
+ * Need a list of the user's threads with tap-to-open? That's `<ChatApp />`
79
+ * (inline) or `<ChatAppLauncher />` (floating bubble) — this component renders
80
+ * a single conversation.
71
81
  */
72
- export declare function ChatWidget({ url, apiUrl, profileId, userId, userName, userEmail, userAvatar, contextTitle, contextSubtitle, contextStatus, subjectId, accent, launcher, position, quickReplies, height, i18n, translateLang, }: ChatWidgetProps): JSX.Element;
82
+ export declare function ChatWidget({ url, apiUrl, profileId, token, refreshToken, userId, userName, userEmail, userAvatar, contextTitle, contextSubtitle, contextStatus, subjectId, accent, launcher, position, quickReplies, height, i18n, translateLang, }: ChatWidgetProps): JSX.Element;
73
83
  export interface MarketplaceChatProps extends BaseProps {
74
84
  /** Unique ID for this listing — each listing gets its own thread.
75
85
  * Omit for a general (non-item-specific) conversation. */
@@ -91,7 +101,7 @@ export interface MarketplaceChatProps extends BaseProps {
91
101
  * ```tsx
92
102
  * // On your listing detail page:
93
103
  * <MarketplaceChat
94
- * url={process.env.NEXT_PUBLIC_RELAY_WS_URL}
104
+ * url={process.env.NEXT_PUBLIC_RELAY_URL}
95
105
  * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}
96
106
  * listingId={car.id}
97
107
  * listingTitle={car.title}
@@ -104,35 +114,53 @@ export interface MarketplaceChatProps extends BaseProps {
104
114
  * />
105
115
  * ```
106
116
  *
107
- * **Without `listingId` (My Messages / inbox page)** shows the WhatsApp-style
108
- * thread list as the home screen. No conversation is opened until the user taps one.
109
- * Use this on a dedicated `/messages` or `/inbox` page.
117
+ * **Without `listingId`** opens the buyer's single general (non-listing)
118
+ * thread with this chatroom. For a "My Messages" / inbox page with the
119
+ * WhatsApp-style thread list and tap-to-open, use `<ChatApp />` (or
120
+ * `<ChatAppLauncher />` for a floating bubble):
110
121
  * ```tsx
111
122
  * // On your /messages page:
112
- * <MarketplaceChat
113
- * url={process.env.NEXT_PUBLIC_RELAY_WS_URL}
123
+ * <ChatApp
124
+ * url={process.env.NEXT_PUBLIC_RELAY_URL}
114
125
  * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}
115
126
  * userId={session?.user.id}
116
- * userName={session?.user.name}
117
127
  * />
118
128
  * ```
119
129
  *
120
130
  * Only `url` and `profileId` are required. All other props are optional.
121
131
  */
122
- export declare function MarketplaceChat({ url, apiUrl, profileId, listingId, listingTitle, listingMeta, listingPrice, listingStatus, userId, userName, userEmail, userAvatar, accent, launcher, position, quickReplies, height, i18n, translateLang, }: MarketplaceChatProps): JSX.Element;
132
+ export declare function MarketplaceChat({ url, apiUrl, profileId, token, refreshToken, listingId, listingTitle, listingMeta, listingPrice, listingStatus, userId, userName, userEmail, userAvatar, accent, launcher, position, quickReplies, height, i18n, translateLang, }: MarketplaceChatProps): JSX.Element;
123
133
  export interface ChatAppProps {
124
- /** Relay WebSocket URL — required */
134
+ /** Relay URL — ONE url, any scheme; `https://api.relay.paramms.com` is the
135
+ * recommended form. The WebSocket URL and REST base are derived from it —
136
+ * you do NOT need to pass `wss://` or `/ws`. */
125
137
  url: string;
126
- /** HTTP(S) base for REST calls. Defaults to the WS origin. */
138
+ /** HTTP(S) base for REST calls only when the REST API is on a different
139
+ * origin than the socket. Normally omit.
140
+ * @deprecated pass a single `url`; kept for back-compat. */
127
141
  apiUrl?: string;
128
142
  /** Your Relay profile ID — required */
129
143
  profileId: string;
144
+ /** A signed identity token (ES256 JWT) for chatrooms with signed identity
145
+ * enabled — the production tier. Wins over `userId`. */
146
+ token?: string;
147
+ /** Return a fresh token when a signed token expires. */
148
+ refreshToken?: () => Promise<string | null>;
130
149
  /** Your logged-in user's stable ID. Omit for anonymous (uses localStorage UID) */
131
150
  userId?: string;
132
151
  /** Optional: shown to agents in the dashboard */
133
152
  userName?: string;
134
153
  /** Optional: shown to agents in the dashboard */
135
154
  userEmail?: string;
155
+ /** Which conversations the list shows (default 'tenant'):
156
+ * 'tenant' — every conversation this user has with the business that
157
+ * owns `profileId`, across ALL of its chatrooms — like a real
158
+ * messaging app. Each row opens against its own chatroom.
159
+ * 'profile' — only this chatroom's threads (the pre-1.0.30 behaviour).
160
+ * Tenancy note: guests never see or send tenant ids — the server resolves
161
+ * the tenant FROM the profileId, so `profileId` stays the only id you
162
+ * configure. */
163
+ scope?: 'profile' | 'tenant';
136
164
  /** Brand colour hex — default '#4F63F5' */
137
165
  accent?: string;
138
166
  /** Container height. Default: '100%' */
@@ -142,21 +170,25 @@ export interface ChatAppProps {
142
170
  }
143
171
  /**
144
172
  * Full chat-app component: conversation list on the left (or full screen on
145
- * mobile), chat room on the right when a thread is selected.
173
+ * mobile), chat room on the right when a thread is selected — like a
174
+ * standalone messaging app. Tapping a thread opens the chat inline; the ✎
175
+ * button starts a new conversation with the business.
146
176
  *
147
- * Works like a standalone messaging app tapping a thread opens the chat
148
- * inline without navigating away from the page.
177
+ * By default (`scope="tenant"`) the list shows EVERY conversation this user
178
+ * has with the business that owns `profileId` — across all of its chatrooms —
179
+ * and each row opens against its own chatroom. Pass `scope="profile"` to
180
+ * limit it to one chatroom's threads.
149
181
  *
150
182
  * @example
151
183
  * ```tsx
152
184
  * 'use client'
153
- * import { ChatList } from '@paramms/chat-widget/react'
185
+ * import { ChatApp } from '@paramms/chat-widget/react'
154
186
  *
155
187
  * export default function MessagesPage({ session }) {
156
188
  * return (
157
189
  * <div style={{ height: '100vh' }}>
158
- * <ChatList
159
- * url={process.env.NEXT_PUBLIC_RELAY_WS_URL}
190
+ * <ChatApp
191
+ * url={process.env.NEXT_PUBLIC_RELAY_URL}
160
192
  * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}
161
193
  * userId={session?.user.id}
162
194
  * userName={session?.user.name}
@@ -167,18 +199,28 @@ export interface ChatAppProps {
167
199
  * }
168
200
  * ```
169
201
  */
170
- export declare function ChatApp({ url, apiUrl, profileId, userId, userName, userEmail, accent, height, i18n, }: ChatAppProps): JSX.Element;
202
+ export declare function ChatApp({ url, apiUrl, profileId, token, refreshToken, userId, userName, userEmail, accent, height, i18n, scope, }: ChatAppProps): JSX.Element;
171
203
  export interface ChatAppLauncherProps {
172
- /** Relay WebSocket URL — required */
204
+ /** Relay URL — ONE url, any scheme; `https://api.relay.paramms.com` is the
205
+ * recommended form. The WebSocket URL and REST base are derived from it. */
173
206
  url: string;
174
- /** HTTP(S) base for REST calls. Defaults to the WS origin. */
207
+ /** HTTP(S) base for REST calls only when REST is on a different origin.
208
+ * @deprecated pass a single `url`; kept for back-compat. */
175
209
  apiUrl?: string;
176
210
  /** Your Relay profile ID — required */
177
211
  profileId: string;
212
+ /** A signed identity token (ES256 JWT) for chatrooms with signed identity
213
+ * enabled — the production tier. Wins over `userId`. */
214
+ token?: string;
215
+ /** Return a fresh token when a signed token expires. */
216
+ refreshToken?: () => Promise<string | null>;
178
217
  /** Your logged-in user's stable ID */
179
218
  userId?: string;
180
219
  userName?: string;
181
220
  userEmail?: string;
221
+ /** Which conversations the panel's list shows — see ChatAppProps.scope.
222
+ * Default 'tenant': every conversation this user has with the business. */
223
+ scope?: 'profile' | 'tenant';
182
224
  /** Brand colour hex — default '#4F63F5' */
183
225
  accent?: string;
184
226
  /** true → floating bubble fixed to the corner of the screen (like Intercom)
@@ -205,7 +247,7 @@ export interface ChatAppLauncherProps {
205
247
  * @example Floating bubble (bottom-right)
206
248
  * ```tsx
207
249
  * <ChatAppLauncher
208
- * url={process.env.NEXT_PUBLIC_RELAY_WS_URL}
250
+ * url={process.env.NEXT_PUBLIC_RELAY_URL}
209
251
  * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}
210
252
  * userId={session?.user.id}
211
253
  * floating
@@ -216,7 +258,7 @@ export interface ChatAppLauncherProps {
216
258
  * @example Inline nav button
217
259
  * ```tsx
218
260
  * <ChatAppLauncher
219
- * url={process.env.NEXT_PUBLIC_RELAY_WS_URL}
261
+ * url={process.env.NEXT_PUBLIC_RELAY_URL}
220
262
  * profileId={process.env.NEXT_PUBLIC_RELAY_PROFILE_ID}
221
263
  * userId={session?.user.id}
222
264
  * floating={false}
@@ -224,5 +266,5 @@ export interface ChatAppLauncherProps {
224
266
  * />
225
267
  * ```
226
268
  */
227
- export declare function ChatAppLauncher({ url, apiUrl, profileId, userId, userName, userEmail, accent, floating, position, label, panelWidth, panelHeight, }: ChatAppLauncherProps): JSX.Element;
269
+ export declare function ChatAppLauncher({ url, apiUrl, profileId, token, refreshToken, userId, userName, userEmail, scope, accent, floating, position, label, panelWidth, panelHeight, }: ChatAppLauncherProps): JSX.Element;
228
270
  export {};