@liveblocks/core 3.13.3-slate1 → 3.13.4
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/index.cjs +46 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +46 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -483,7 +483,7 @@ type DeleteCrdtOp = {
|
|
|
483
483
|
readonly id: string;
|
|
484
484
|
readonly type: OpCode.DELETE_CRDT;
|
|
485
485
|
};
|
|
486
|
-
type
|
|
486
|
+
type IgnoredOp = {
|
|
487
487
|
readonly type: OpCode.DELETE_CRDT;
|
|
488
488
|
readonly id: "ACK";
|
|
489
489
|
readonly opId: string;
|
|
@@ -514,7 +514,7 @@ type ClientWireOp = Op & HasOpId;
|
|
|
514
514
|
* 2. AckOp — Our op was seen but intentionally ignored (still counts as ack)
|
|
515
515
|
* 3. Op without opId — Another client's op being forwarded to us
|
|
516
516
|
*/
|
|
517
|
-
type ServerWireOp = ClientWireOp |
|
|
517
|
+
type ServerWireOp = ClientWireOp | IgnoredOp | TheirOp;
|
|
518
518
|
type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
519
519
|
opId?: undefined;
|
|
520
520
|
};
|
|
@@ -5243,4 +5243,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5243
5243
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5244
5244
|
};
|
|
5245
5245
|
|
|
5246
|
-
export { type
|
|
5246
|
+
export { type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStateServerMsg, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -483,7 +483,7 @@ type DeleteCrdtOp = {
|
|
|
483
483
|
readonly id: string;
|
|
484
484
|
readonly type: OpCode.DELETE_CRDT;
|
|
485
485
|
};
|
|
486
|
-
type
|
|
486
|
+
type IgnoredOp = {
|
|
487
487
|
readonly type: OpCode.DELETE_CRDT;
|
|
488
488
|
readonly id: "ACK";
|
|
489
489
|
readonly opId: string;
|
|
@@ -514,7 +514,7 @@ type ClientWireOp = Op & HasOpId;
|
|
|
514
514
|
* 2. AckOp — Our op was seen but intentionally ignored (still counts as ack)
|
|
515
515
|
* 3. Op without opId — Another client's op being forwarded to us
|
|
516
516
|
*/
|
|
517
|
-
type ServerWireOp = ClientWireOp |
|
|
517
|
+
type ServerWireOp = ClientWireOp | IgnoredOp | TheirOp;
|
|
518
518
|
type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
519
519
|
opId?: undefined;
|
|
520
520
|
};
|
|
@@ -5243,4 +5243,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5243
5243
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5244
5244
|
};
|
|
5245
5245
|
|
|
5246
|
-
export { type
|
|
5246
|
+
export { type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStateServerMsg, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.13.
|
|
9
|
+
var PKG_VERSION = "3.13.4";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3222,7 +3222,7 @@ var BACKOFF_DELAYS_SLOW = [2e3, 3e4, 6e4, 3e5];
|
|
|
3222
3222
|
var HEARTBEAT_INTERVAL = 3e4;
|
|
3223
3223
|
var PONG_TIMEOUT = 2e3;
|
|
3224
3224
|
var AUTH_TIMEOUT = 1e4;
|
|
3225
|
-
var SOCKET_CONNECT_TIMEOUT =
|
|
3225
|
+
var SOCKET_CONNECT_TIMEOUT = 2e4;
|
|
3226
3226
|
var StopRetrying = class extends Error {
|
|
3227
3227
|
constructor(reason) {
|
|
3228
3228
|
super(reason);
|
|
@@ -4167,41 +4167,6 @@ var TreePool = class {
|
|
|
4167
4167
|
}
|
|
4168
4168
|
};
|
|
4169
4169
|
|
|
4170
|
-
// src/protocol/AuthToken.ts
|
|
4171
|
-
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
4172
|
-
Permission2["Read"] = "room:read";
|
|
4173
|
-
Permission2["Write"] = "room:write";
|
|
4174
|
-
Permission2["PresenceWrite"] = "room:presence:write";
|
|
4175
|
-
Permission2["CommentsWrite"] = "comments:write";
|
|
4176
|
-
Permission2["CommentsRead"] = "comments:read";
|
|
4177
|
-
return Permission2;
|
|
4178
|
-
})(Permission || {});
|
|
4179
|
-
function canWriteStorage(scopes) {
|
|
4180
|
-
return scopes.includes("room:write" /* Write */);
|
|
4181
|
-
}
|
|
4182
|
-
function canComment(scopes) {
|
|
4183
|
-
return scopes.includes("comments:write" /* CommentsWrite */) || scopes.includes("room:write" /* Write */);
|
|
4184
|
-
}
|
|
4185
|
-
function isValidAuthTokenPayload(data) {
|
|
4186
|
-
return isPlainObject(data) && (data.k === "acc" /* ACCESS_TOKEN */ || data.k === "id" /* ID_TOKEN */ || data.k === "sec-legacy" /* SECRET_LEGACY */);
|
|
4187
|
-
}
|
|
4188
|
-
function parseAuthToken(rawTokenString) {
|
|
4189
|
-
const tokenParts = rawTokenString.split(".");
|
|
4190
|
-
if (tokenParts.length !== 3) {
|
|
4191
|
-
throw new Error("Authentication error: invalid JWT token");
|
|
4192
|
-
}
|
|
4193
|
-
const payload = tryParseJson(b64decode(tokenParts[1]));
|
|
4194
|
-
if (!(payload && isValidAuthTokenPayload(payload))) {
|
|
4195
|
-
throw new Error(
|
|
4196
|
-
"Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback"
|
|
4197
|
-
);
|
|
4198
|
-
}
|
|
4199
|
-
return {
|
|
4200
|
-
raw: rawTokenString,
|
|
4201
|
-
parsed: payload
|
|
4202
|
-
};
|
|
4203
|
-
}
|
|
4204
|
-
|
|
4205
4170
|
// src/ai.ts
|
|
4206
4171
|
var DEFAULT_REQUEST_TIMEOUT = 4e3;
|
|
4207
4172
|
function defineAiTool() {
|
|
@@ -4730,8 +4695,8 @@ function createAi(config) {
|
|
|
4730
4695
|
if (authValue.type === "secret") {
|
|
4731
4696
|
const token = authValue.token.parsed;
|
|
4732
4697
|
context.staticSessionInfoSig.set({
|
|
4733
|
-
userId: token.
|
|
4734
|
-
userInfo: token.
|
|
4698
|
+
userId: token.uid,
|
|
4699
|
+
userInfo: token.ui
|
|
4735
4700
|
});
|
|
4736
4701
|
} else {
|
|
4737
4702
|
context.staticSessionInfoSig.set({
|
|
@@ -5153,6 +5118,41 @@ function createReceivingToolInvocation(invocationId, name, partialArgsText = "")
|
|
|
5153
5118
|
};
|
|
5154
5119
|
}
|
|
5155
5120
|
|
|
5121
|
+
// src/protocol/AuthToken.ts
|
|
5122
|
+
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
5123
|
+
Permission2["Read"] = "room:read";
|
|
5124
|
+
Permission2["Write"] = "room:write";
|
|
5125
|
+
Permission2["PresenceWrite"] = "room:presence:write";
|
|
5126
|
+
Permission2["CommentsWrite"] = "comments:write";
|
|
5127
|
+
Permission2["CommentsRead"] = "comments:read";
|
|
5128
|
+
return Permission2;
|
|
5129
|
+
})(Permission || {});
|
|
5130
|
+
function canWriteStorage(scopes) {
|
|
5131
|
+
return scopes.includes("room:write" /* Write */);
|
|
5132
|
+
}
|
|
5133
|
+
function canComment(scopes) {
|
|
5134
|
+
return scopes.includes("comments:write" /* CommentsWrite */) || scopes.includes("room:write" /* Write */);
|
|
5135
|
+
}
|
|
5136
|
+
function isValidAuthTokenPayload(data) {
|
|
5137
|
+
return isPlainObject(data) && (data.k === "acc" /* ACCESS_TOKEN */ || data.k === "id" /* ID_TOKEN */);
|
|
5138
|
+
}
|
|
5139
|
+
function parseAuthToken(rawTokenString) {
|
|
5140
|
+
const tokenParts = rawTokenString.split(".");
|
|
5141
|
+
if (tokenParts.length !== 3) {
|
|
5142
|
+
throw new Error("Authentication error: invalid JWT token");
|
|
5143
|
+
}
|
|
5144
|
+
const payload = tryParseJson(b64decode(tokenParts[1]));
|
|
5145
|
+
if (!(payload && isValidAuthTokenPayload(payload))) {
|
|
5146
|
+
throw new Error(
|
|
5147
|
+
"Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback"
|
|
5148
|
+
);
|
|
5149
|
+
}
|
|
5150
|
+
return {
|
|
5151
|
+
raw: rawTokenString,
|
|
5152
|
+
parsed: payload
|
|
5153
|
+
};
|
|
5154
|
+
}
|
|
5155
|
+
|
|
5156
5156
|
// src/auth-manager.ts
|
|
5157
5157
|
var NON_RETRY_STATUS_CODES = [
|
|
5158
5158
|
400,
|
|
@@ -5287,10 +5287,8 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5287
5287
|
const BUFFER = 30;
|
|
5288
5288
|
const expiresAt = Math.floor(Date.now() / 1e3) + (token.parsed.exp - token.parsed.iat) - BUFFER;
|
|
5289
5289
|
seenTokens.add(token.raw);
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
expiryTimes.push(expiresAt);
|
|
5293
|
-
}
|
|
5290
|
+
tokens.push(token);
|
|
5291
|
+
expiryTimes.push(expiresAt);
|
|
5294
5292
|
return { type: "secret", token };
|
|
5295
5293
|
} finally {
|
|
5296
5294
|
if (requestOptions.roomId) {
|
|
@@ -5990,7 +5988,7 @@ var OpCode = Object.freeze({
|
|
|
5990
5988
|
CREATE_MAP: 7,
|
|
5991
5989
|
CREATE_REGISTER: 8
|
|
5992
5990
|
});
|
|
5993
|
-
function
|
|
5991
|
+
function isIgnoredOp(op) {
|
|
5994
5992
|
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5995
5993
|
}
|
|
5996
5994
|
|
|
@@ -8894,8 +8892,8 @@ function createRoom(options, config) {
|
|
|
8894
8892
|
if (authValue.type === "secret") {
|
|
8895
8893
|
const token = authValue.token.parsed;
|
|
8896
8894
|
context.staticSessionInfoSig.set({
|
|
8897
|
-
userId: token.
|
|
8898
|
-
userInfo: token.
|
|
8895
|
+
userId: token.uid,
|
|
8896
|
+
userInfo: token.ui
|
|
8899
8897
|
});
|
|
8900
8898
|
} else {
|
|
8901
8899
|
context.staticSessionInfoSig.set({
|
|
@@ -9330,7 +9328,7 @@ function createRoom(options, config) {
|
|
|
9330
9328
|
};
|
|
9331
9329
|
}
|
|
9332
9330
|
function applyOp(op, source) {
|
|
9333
|
-
if (
|
|
9331
|
+
if (isIgnoredOp(op)) {
|
|
9334
9332
|
return { modified: false };
|
|
9335
9333
|
}
|
|
9336
9334
|
switch (op.type) {
|
|
@@ -10376,8 +10374,7 @@ function createClient(options) {
|
|
|
10376
10374
|
const baseUrl = getBaseUrl(clientOptions.baseUrl);
|
|
10377
10375
|
const currentUserId = new Signal(void 0);
|
|
10378
10376
|
const authManager = createAuthManager(options, (token) => {
|
|
10379
|
-
|
|
10380
|
-
currentUserId.set(() => userId);
|
|
10377
|
+
currentUserId.set(() => token.uid);
|
|
10381
10378
|
});
|
|
10382
10379
|
const fetchPolyfill = clientOptions.polyfills?.fetch || /* istanbul ignore next */
|
|
10383
10380
|
globalThis.fetch?.bind(globalThis);
|
|
@@ -10408,8 +10405,6 @@ function createClient(options) {
|
|
|
10408
10405
|
throw new StopRetrying(
|
|
10409
10406
|
"Cannot use AI Copilots with a public API key"
|
|
10410
10407
|
);
|
|
10411
|
-
} else if (resp.token.parsed.k === "sec-legacy" /* SECRET_LEGACY */) {
|
|
10412
|
-
throw new StopRetrying("AI Copilots requires an ID or Access token");
|
|
10413
10408
|
}
|
|
10414
10409
|
return resp;
|
|
10415
10410
|
},
|