@talkjs/core 1.5.8 → 1.6.0

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.
@@ -118,7 +118,7 @@ export declare interface AudioFileMetadata {
118
118
  * {
119
119
  * type: "autoLink",
120
120
  * text: "talkjs.com"
121
- * url: "https://talkjs.com/docs/SDKs/JavaScript_Data_API/Message_Content/#AutoLinkNode"
121
+ * url: "https://talkjs.com/docs/JavaScript_Data_API/Message_Content/#AutoLinkNode"
122
122
  * }
123
123
  * ```
124
124
  *
@@ -354,7 +354,7 @@ export declare interface ConversationRef {
354
354
  * The user "Alice" will still exist after you do this. This deletes the participant, not the user.
355
355
  *
356
356
  * @param user - Specifies which participant in the conversation you want to reference. Either the user's ID, or a reference to that user.
357
- * @returns A {@linkcode ParticipantRef} for that user's participation in this conversation
357
+ * @returns A {@link ParticipantRef} for that user's participation in this conversation
358
358
  * @throws If the user is not a UserRef or a non-empty string
359
359
  * @public
360
360
  */
@@ -368,7 +368,7 @@ export declare interface ConversationRef {
368
368
  * To send a message, use {@link ConversationRef.send}.
369
369
  *
370
370
  * @param id - The ID of the message that you want to reference
371
- * @returns A {@linkcode MessageRef} for the message with that ID in this conversation
371
+ * @returns A {@link MessageRef} for the message with that ID in this conversation
372
372
  * @throws If the id is not a string or is an empty string
373
373
  * @public
374
374
  */
@@ -1081,9 +1081,7 @@ export declare interface GenericFileMetadata {
1081
1081
  *
1082
1082
  * @remarks
1083
1083
  * Backed by a registry, so calling this function twice with the same app and user returns the same session object both times.
1084
- * A new session will be created if the old one encountered an error or got garbage collected.
1085
- *
1086
- * The `token` and `tokenFetcher` properties are ignored if there is already a session for that user in the registry.
1084
+ * A new session will be created if the old one encountered an error.
1087
1085
  */
1088
1086
  export declare function getTalkSession(options: TalkSessionOptions): TalkSession;
1089
1087
 
@@ -1308,7 +1306,7 @@ export declare interface MessageRef {
1308
1306
  * ```
1309
1307
  *
1310
1308
  * @param emoji - The emoji for the reaction you want to reference. a single Unicode emoji like "🚀" or a custom emoji like ":cat_roomba:". Custom emoji can be up to 50 characters long.
1311
- * @returns A {@linkcode ReactionRef} for the reaction with that emoji on this message
1309
+ * @returns A {@link ReactionRef} for the reaction with that emoji on this message
1312
1310
  * @throws If the emoji is not a string or is an empty string
1313
1311
  * @public
1314
1312
  */
@@ -2153,6 +2151,37 @@ export declare interface TalkSession {
2153
2151
  * @see {@link Session.user} which lets you get a reference to any user.
2154
2152
  */
2155
2153
  readonly currentUser: UserRef;
2154
+ /**
2155
+ * Set the auth token to be used on this session.
2156
+ *
2157
+ * @remarks
2158
+ * This will immediately reauthenticate the websocket connection to TalkJS,
2159
+ * overwriting any previous tokens on the session.
2160
+ *
2161
+ * This does not affect any in-progress requests. As long as the new auth token is valid,
2162
+ * your subscriptions will stay active with no gaps or missing data during reauthentication.
2163
+ *
2164
+ * Note: When you call `getTalkSession` multiple times with the same arguments, the same TalkSession object is reused.
2165
+ * This means that when you call setToken in one place, it will set the auth token on
2166
+ * all sessions with the same appId and userId as this one.
2167
+ */
2168
+ setToken(token: string): void;
2169
+ /**
2170
+ * This property stores the function that is called when a new authentication token is needed.
2171
+ *
2172
+ * @remarks
2173
+ * The `onNeedToken` callback will run any time this session needs a new token.
2174
+ * This includes the first time you request data (if you have not called `setToken`), and whenever the auth token is about to expire.
2175
+ *
2176
+ * If you call `setToken` and leave this callback undefined, token expiry will trigger a critical error and the session will terminate.
2177
+ *
2178
+ * The callback should fetch a new JWT from your backend and then call {@link setToken} with it.
2179
+ * Ensure that the callback retries automatically when experiencing temporary issues such as network problems.
2180
+ *
2181
+ * If you called `getTalkSession` multiple times with the same arguments,
2182
+ * this will affect all sessions using the same appId + userId as this one.
2183
+ */
2184
+ onNeedToken?: () => void;
2156
2185
  /**
2157
2186
  * Subscribe to unrecoverable errors on the session.
2158
2187
  *
@@ -2191,7 +2220,7 @@ export declare interface TalkSession {
2191
2220
  * await userRef.set({ name: "Bob" });
2192
2221
  *
2193
2222
  * @param id - The ID of the user that you want to reference
2194
- * @returns A {@linkcode UserRef} for the user with that ID
2223
+ * @returns A {@link UserRef} for the user with that ID
2195
2224
  * @throws If the id is not a string or is an empty string
2196
2225
  * @public
2197
2226
  */
@@ -2224,7 +2253,7 @@ export declare interface TalkSession {
2224
2253
  * ```
2225
2254
  *
2226
2255
  * @param id - The ID of the conversation that you want to reference
2227
- * @returns A {@linkcode ConversationRef} for the conversation with that ID
2256
+ * @returns A {@link ConversationRef} for the conversation with that ID
2228
2257
  * @throws If the id is not a string or is an empty string
2229
2258
  * @public
2230
2259
  */
@@ -2261,13 +2290,13 @@ export declare interface TalkSession {
2261
2290
  *
2262
2291
  * @remarks
2263
2292
  * This function does not send any message, it only uploads the file and returns a file token.
2264
- * To send the file in a message, pass the file token in a {@linkcode SendFileBlock} when calling {@linkcode ConversationRef.send}.
2293
+ * To send the file in a message, pass the file token in a {@link SendFileBlock} when calling {@link ConversationRef.send}.
2265
2294
  *
2266
2295
  * {@link https://talkjs.com/docs/Concepts/Message_Content/#sending-message-content | See the documentation} for more information about sending files in messages.
2267
2296
  *
2268
- * If the file is a video, image, audio file, or voice recording, use one of the other functions like {@linkcode uploadImage} instead.
2297
+ * If the file is a video, image, audio file, or voice recording, use one of the other functions like {@link uploadImage} instead.
2269
2298
  *
2270
- * @param data The binary file data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2299
+ * @param data The binary file data. Usually a {@link https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2271
2300
  * @param metadata Information about the file
2272
2301
  * @returns A file token that can be used to send the file in a message.
2273
2302
  */
@@ -2276,9 +2305,9 @@ export declare interface TalkSession {
2276
2305
  * Upload an image with image-specific metadata.
2277
2306
  *
2278
2307
  * @remarks
2279
- * This is a variant of {@linkcode uploadFile} used for images.
2308
+ * This is a variant of {@link uploadFile} used for images.
2280
2309
  *
2281
- * @param data The binary image data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2310
+ * @param data The binary image data. Usually a {@link https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2282
2311
  * @param metadata Information about the image.
2283
2312
  * @returns A file token that can be used to send the image in a message.
2284
2313
  */
@@ -2287,9 +2316,9 @@ export declare interface TalkSession {
2287
2316
  * Upload a video with video-specific metadata.
2288
2317
  *
2289
2318
  * @remarks
2290
- * This is a variant of {@linkcode uploadFile} used for videos.
2319
+ * This is a variant of {@link uploadFile} used for videos.
2291
2320
  *
2292
- * @param data The binary video data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2321
+ * @param data The binary video data. Usually a {@link https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2293
2322
  * @param metadata Information about the video.
2294
2323
  * @returns A file token that can be used to send the video in a message.
2295
2324
  */
@@ -2298,9 +2327,9 @@ export declare interface TalkSession {
2298
2327
  * Upload an audio file with audio-specific metadata.
2299
2328
  *
2300
2329
  * @remarks
2301
- * This is a variant of {@linkcode uploadFile} used for audio files.
2330
+ * This is a variant of {@link uploadFile} used for audio files.
2302
2331
  *
2303
- * @param data The binary audio data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2332
+ * @param data The binary audio data. Usually a {@link https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2304
2333
  * @param metadata Information about the audio file.
2305
2334
  * @returns A file token that can be used to send the audio file in a message.
2306
2335
  */
@@ -2309,9 +2338,9 @@ export declare interface TalkSession {
2309
2338
  * Upload a voice recording with voice-specific metadata.
2310
2339
  *
2311
2340
  * @remarks
2312
- * This is a variant of {@linkcode uploadFile} used for voice recordings.
2341
+ * This is a variant of {@link uploadFile} used for voice recordings.
2313
2342
  *
2314
- * @param data The binary audio data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2343
+ * @param data The binary audio data. Usually a {@link https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
2315
2344
  * @param metadata Information about the voice recording.
2316
2345
  * @returns A file token that can be used to send the audio file in a message.
2317
2346
  */
@@ -2321,7 +2350,13 @@ export declare interface TalkSession {
2321
2350
  export declare interface TalkSessionOptions {
2322
2351
  appId: string;
2323
2352
  userId: string;
2353
+ /**
2354
+ * @deprecated Use {@link TalkSession.setToken} instead. This parameter is ignored if you have previously called getTalkSession with the same userId and appId.
2355
+ */
2324
2356
  token?: string;
2357
+ /**
2358
+ * @deprecated Use {@link TalkSession.onNeedToken} and {@link TalkSession.setToken} instead. This parameter is ignored if you have previously called getTalkSession with the same userId and appId.
2359
+ */
2325
2360
  tokenFetcher?: () => string | Promise<string>;
2326
2361
  }
2327
2362
 
@@ -2564,12 +2599,12 @@ export declare interface UserOnlineSnapshot {
2564
2599
  * Users are considered connected whenever they have an active websocket connection to the TalkJS servers.
2565
2600
  * In practice, this means:
2566
2601
  *
2567
- * People using the {@link https://talkjs.com/docs/SDKs/JavaScript_Data_API/ | JS Data API} are considered connected if they are subscribed to something, or if they sent a request in the last few seconds.
2602
+ * People using the {@link https://talkjs.com/docs/JavaScript_Data_API/ | JS Data API} are considered connected if they are subscribed to something, or if they sent a request in the last few seconds.
2568
2603
  * Creating a `TalkSession` is not enough to appear connected.
2569
2604
  *
2570
- * People using {@link https://talkjs.com/docs/SDKs/ | Components}, are considered connected if they have a UI open.
2605
+ * People using {@link https://talkjs.com/docs/UI_Components/ | Components}, are considered connected if they have a UI open.
2571
2606
  *
2572
- * People using the {@link https://talkjs.com/docs/SDKs/JavaScript/Classic/ | JavaScript SDK}, {@link https://talkjs.com/docs/SDKs/React/Classic/ | React SDK}, {@link https://talkjs.com/docs/SDKs/React_Native/ | React Native SDK}, or {@link https://talkjs.com/docs/SDKs/Flutter/ | Flutter SDK} are considered connected whenever they have an active `Session` object.
2607
+ * People using the {@link https://talkjs.com/docs/UI_Components/JavaScript/Classic/ | JavaScript SDK}, {@link https://talkjs.com/docs/UI_Components/React/Classic/ | React SDK}, {@link https://talkjs.com/docs/UI_Components/React_Native/ | React Native SDK}, or {@link https://talkjs.com/docs/UI_Components/Flutter/ | Flutter SDK} are considered connected whenever they have an active `Session` object.
2573
2608
  */
2574
2609
  readonly isConnected: boolean;
2575
2610
  }