@liveblocks/core 3.20.0-perm6 → 3.20.0-perm7
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 +52 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -28
- package/dist/index.d.ts +21 -28
- package/dist/index.js +54 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -110,28 +110,21 @@ type PermissionMatrix = {
|
|
|
110
110
|
personal: AccessLevel;
|
|
111
111
|
};
|
|
112
112
|
type PermissionResources = keyof PermissionMatrix;
|
|
113
|
-
type
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
type RoomPermission = Permission[];
|
|
118
|
-
type RoomPermissionInput = readonly Permission[];
|
|
119
|
-
type RoomAccesses = Record<string, RoomPermission>;
|
|
120
|
-
type RoomAccessesInput = Record<string, RoomPermissionInput>;
|
|
121
|
-
type RoomAccessesUpdateInput = Record<string, RoomPermissionInput | null>;
|
|
122
|
-
type RoomPermissionSources = {
|
|
123
|
-
defaultAccesses: readonly Permission[];
|
|
124
|
-
groupsAccesses: readonly (readonly Permission[])[];
|
|
125
|
-
userAccesses?: readonly Permission[] | undefined;
|
|
126
|
-
};
|
|
127
|
-
declare function permissionMatrixFromScopes(scopes: readonly string[]): PermissionMatrix;
|
|
113
|
+
type RoomPermissions = Permission[];
|
|
114
|
+
type RoomAccesses = Record<string, RoomPermissions>;
|
|
115
|
+
type UpdateRoomAccesses = Record<string, RoomPermissions | null>;
|
|
116
|
+
declare function permissionMatrixFromScopes(scopes: RoomPermissions): PermissionMatrix;
|
|
128
117
|
declare function hasPermissionAccess(matrix: Partial<PermissionMatrix>, resource: PermissionResources, requiredAccess: RequiredAccessLevel): boolean;
|
|
129
|
-
declare function
|
|
130
|
-
declare function
|
|
131
|
-
declare function
|
|
132
|
-
declare function mergePermissionMatrices(
|
|
133
|
-
declare function permissionMatrixToScopes(matrix: PermissionMatrix):
|
|
134
|
-
declare function mergeRoomPermissionScopes({ defaultAccesses, groupsAccesses, userAccesses, }:
|
|
118
|
+
declare function normalizeRoomPermissions(permissions: string[] | readonly string[]): RoomPermissions;
|
|
119
|
+
declare function normalizeRoomAccesses(accesses: RoomAccesses | undefined): RoomAccesses | undefined;
|
|
120
|
+
declare function normalizeUpdateRoomAccesses(accesses: UpdateRoomAccesses | undefined): UpdateRoomAccesses | undefined;
|
|
121
|
+
declare function mergePermissionMatrices(matrices: PermissionMatrix[]): PermissionMatrix;
|
|
122
|
+
declare function permissionMatrixToScopes(matrix: PermissionMatrix): RoomPermissions;
|
|
123
|
+
declare function mergeRoomPermissionScopes({ defaultAccesses, groupsAccesses, userAccesses, }: {
|
|
124
|
+
defaultAccesses: RoomPermissions;
|
|
125
|
+
groupsAccesses: RoomPermissions[];
|
|
126
|
+
userAccesses: RoomPermissions;
|
|
127
|
+
}): RoomPermissions;
|
|
135
128
|
|
|
136
129
|
type CustomAuthenticationResult = Relax<{
|
|
137
130
|
token: string;
|
|
@@ -1754,7 +1747,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1754
1747
|
subscriptions: SubscriptionData[];
|
|
1755
1748
|
requestedAt: Date;
|
|
1756
1749
|
nextCursor: string | null;
|
|
1757
|
-
permissionHints: Record<string,
|
|
1750
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
1758
1751
|
}>;
|
|
1759
1752
|
getThreadsSince(options: {
|
|
1760
1753
|
roomId: string;
|
|
@@ -1774,7 +1767,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1774
1767
|
deleted: SubscriptionDeleteInfo[];
|
|
1775
1768
|
};
|
|
1776
1769
|
requestedAt: Date;
|
|
1777
|
-
permissionHints: Record<string,
|
|
1770
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
1778
1771
|
}>;
|
|
1779
1772
|
searchComments(options: {
|
|
1780
1773
|
roomId: string;
|
|
@@ -2024,7 +2017,7 @@ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> ex
|
|
|
2024
2017
|
subscriptions: SubscriptionData[];
|
|
2025
2018
|
nextCursor: string | null;
|
|
2026
2019
|
requestedAt: Date;
|
|
2027
|
-
permissionHints: Record<string,
|
|
2020
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
2028
2021
|
}>;
|
|
2029
2022
|
getUserThreadsSince_experimental(options: {
|
|
2030
2023
|
since: Date;
|
|
@@ -2043,7 +2036,7 @@ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> ex
|
|
|
2043
2036
|
deleted: SubscriptionDeleteInfo[];
|
|
2044
2037
|
};
|
|
2045
2038
|
requestedAt: Date;
|
|
2046
|
-
permissionHints: Record<string,
|
|
2039
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
2047
2040
|
}>;
|
|
2048
2041
|
groupsStore: BatchStore<GroupData | undefined, string>;
|
|
2049
2042
|
getGroup(groupId: string): Promise<GroupData | undefined>;
|
|
@@ -3852,7 +3845,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3852
3845
|
subscriptions: SubscriptionData[];
|
|
3853
3846
|
requestedAt: Date;
|
|
3854
3847
|
nextCursor: string | null;
|
|
3855
|
-
permissionHints: Record<string,
|
|
3848
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
3856
3849
|
}>;
|
|
3857
3850
|
/**
|
|
3858
3851
|
* Returns the updated and deleted threads and their associated inbox notifications and subscriptions since the requested date.
|
|
@@ -3876,7 +3869,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3876
3869
|
deleted: SubscriptionDeleteInfo[];
|
|
3877
3870
|
};
|
|
3878
3871
|
requestedAt: Date;
|
|
3879
|
-
permissionHints: Record<string,
|
|
3872
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
3880
3873
|
}>;
|
|
3881
3874
|
/**
|
|
3882
3875
|
* Returns a thread and the associated inbox notification and subscription if it exists.
|
|
@@ -5769,4 +5762,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5769
5762
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5770
5763
|
};
|
|
5771
5764
|
|
|
5772
|
-
export { type AccessLevel, 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 ChildStorageNode, 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 CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, 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 DFM, type DFMD, 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 Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, 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 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 LayerKey, type ListStorageNode, 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 MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type
|
|
5765
|
+
export { type AccessLevel, 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 ChildStorageNode, 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 CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, 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 DFM, type DFMD, 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 Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, 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 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 LayerKey, type ListStorageNode, 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 MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, 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 StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, 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, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergePermissionMatrices, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, permissionMatrixToScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -110,28 +110,21 @@ type PermissionMatrix = {
|
|
|
110
110
|
personal: AccessLevel;
|
|
111
111
|
};
|
|
112
112
|
type PermissionResources = keyof PermissionMatrix;
|
|
113
|
-
type
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
type RoomPermission = Permission[];
|
|
118
|
-
type RoomPermissionInput = readonly Permission[];
|
|
119
|
-
type RoomAccesses = Record<string, RoomPermission>;
|
|
120
|
-
type RoomAccessesInput = Record<string, RoomPermissionInput>;
|
|
121
|
-
type RoomAccessesUpdateInput = Record<string, RoomPermissionInput | null>;
|
|
122
|
-
type RoomPermissionSources = {
|
|
123
|
-
defaultAccesses: readonly Permission[];
|
|
124
|
-
groupsAccesses: readonly (readonly Permission[])[];
|
|
125
|
-
userAccesses?: readonly Permission[] | undefined;
|
|
126
|
-
};
|
|
127
|
-
declare function permissionMatrixFromScopes(scopes: readonly string[]): PermissionMatrix;
|
|
113
|
+
type RoomPermissions = Permission[];
|
|
114
|
+
type RoomAccesses = Record<string, RoomPermissions>;
|
|
115
|
+
type UpdateRoomAccesses = Record<string, RoomPermissions | null>;
|
|
116
|
+
declare function permissionMatrixFromScopes(scopes: RoomPermissions): PermissionMatrix;
|
|
128
117
|
declare function hasPermissionAccess(matrix: Partial<PermissionMatrix>, resource: PermissionResources, requiredAccess: RequiredAccessLevel): boolean;
|
|
129
|
-
declare function
|
|
130
|
-
declare function
|
|
131
|
-
declare function
|
|
132
|
-
declare function mergePermissionMatrices(
|
|
133
|
-
declare function permissionMatrixToScopes(matrix: PermissionMatrix):
|
|
134
|
-
declare function mergeRoomPermissionScopes({ defaultAccesses, groupsAccesses, userAccesses, }:
|
|
118
|
+
declare function normalizeRoomPermissions(permissions: string[] | readonly string[]): RoomPermissions;
|
|
119
|
+
declare function normalizeRoomAccesses(accesses: RoomAccesses | undefined): RoomAccesses | undefined;
|
|
120
|
+
declare function normalizeUpdateRoomAccesses(accesses: UpdateRoomAccesses | undefined): UpdateRoomAccesses | undefined;
|
|
121
|
+
declare function mergePermissionMatrices(matrices: PermissionMatrix[]): PermissionMatrix;
|
|
122
|
+
declare function permissionMatrixToScopes(matrix: PermissionMatrix): RoomPermissions;
|
|
123
|
+
declare function mergeRoomPermissionScopes({ defaultAccesses, groupsAccesses, userAccesses, }: {
|
|
124
|
+
defaultAccesses: RoomPermissions;
|
|
125
|
+
groupsAccesses: RoomPermissions[];
|
|
126
|
+
userAccesses: RoomPermissions;
|
|
127
|
+
}): RoomPermissions;
|
|
135
128
|
|
|
136
129
|
type CustomAuthenticationResult = Relax<{
|
|
137
130
|
token: string;
|
|
@@ -1754,7 +1747,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1754
1747
|
subscriptions: SubscriptionData[];
|
|
1755
1748
|
requestedAt: Date;
|
|
1756
1749
|
nextCursor: string | null;
|
|
1757
|
-
permissionHints: Record<string,
|
|
1750
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
1758
1751
|
}>;
|
|
1759
1752
|
getThreadsSince(options: {
|
|
1760
1753
|
roomId: string;
|
|
@@ -1774,7 +1767,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1774
1767
|
deleted: SubscriptionDeleteInfo[];
|
|
1775
1768
|
};
|
|
1776
1769
|
requestedAt: Date;
|
|
1777
|
-
permissionHints: Record<string,
|
|
1770
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
1778
1771
|
}>;
|
|
1779
1772
|
searchComments(options: {
|
|
1780
1773
|
roomId: string;
|
|
@@ -2024,7 +2017,7 @@ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> ex
|
|
|
2024
2017
|
subscriptions: SubscriptionData[];
|
|
2025
2018
|
nextCursor: string | null;
|
|
2026
2019
|
requestedAt: Date;
|
|
2027
|
-
permissionHints: Record<string,
|
|
2020
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
2028
2021
|
}>;
|
|
2029
2022
|
getUserThreadsSince_experimental(options: {
|
|
2030
2023
|
since: Date;
|
|
@@ -2043,7 +2036,7 @@ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> ex
|
|
|
2043
2036
|
deleted: SubscriptionDeleteInfo[];
|
|
2044
2037
|
};
|
|
2045
2038
|
requestedAt: Date;
|
|
2046
|
-
permissionHints: Record<string,
|
|
2039
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
2047
2040
|
}>;
|
|
2048
2041
|
groupsStore: BatchStore<GroupData | undefined, string>;
|
|
2049
2042
|
getGroup(groupId: string): Promise<GroupData | undefined>;
|
|
@@ -3852,7 +3845,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3852
3845
|
subscriptions: SubscriptionData[];
|
|
3853
3846
|
requestedAt: Date;
|
|
3854
3847
|
nextCursor: string | null;
|
|
3855
|
-
permissionHints: Record<string,
|
|
3848
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
3856
3849
|
}>;
|
|
3857
3850
|
/**
|
|
3858
3851
|
* Returns the updated and deleted threads and their associated inbox notifications and subscriptions since the requested date.
|
|
@@ -3876,7 +3869,7 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
3876
3869
|
deleted: SubscriptionDeleteInfo[];
|
|
3877
3870
|
};
|
|
3878
3871
|
requestedAt: Date;
|
|
3879
|
-
permissionHints: Record<string,
|
|
3872
|
+
permissionHints: Record<string, RoomPermissions>;
|
|
3880
3873
|
}>;
|
|
3881
3874
|
/**
|
|
3882
3875
|
* Returns a thread and the associated inbox notification and subscription if it exists.
|
|
@@ -5769,4 +5762,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5769
5762
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5770
5763
|
};
|
|
5771
5764
|
|
|
5772
|
-
export { type AccessLevel, 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 ChildStorageNode, 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 CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, 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 DFM, type DFMD, 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 Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, 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 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 LayerKey, type ListStorageNode, 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 MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type
|
|
5765
|
+
export { type AccessLevel, 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 ChildStorageNode, 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 CompactChildNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, 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 DFM, type DFMD, 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 Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, 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 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 LayerKey, type ListStorageNode, 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 MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, 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 StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, 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, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergePermissionMatrices, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, permissionMatrixToScopes, 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.20.0-
|
|
9
|
+
var PKG_VERSION = "3.20.0-perm7";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -5246,6 +5246,9 @@ var ROOM_PERMISSION_RESOURCES = [
|
|
|
5246
5246
|
"feeds"
|
|
5247
5247
|
];
|
|
5248
5248
|
var VALID_PERMISSIONS = new Set(Object.values(Permission));
|
|
5249
|
+
function isPermission(permission) {
|
|
5250
|
+
return VALID_PERMISSIONS.has(permission);
|
|
5251
|
+
}
|
|
5249
5252
|
function resolveResourceAccess(scopes, resource) {
|
|
5250
5253
|
const permissions = PERMISSIONS_BY_RESOURCE[resource];
|
|
5251
5254
|
let resourceAccess;
|
|
@@ -5330,46 +5333,46 @@ function resolveRoomPermissionMatrix(permissions, roomId) {
|
|
|
5330
5333
|
matrix: explicitMatrix
|
|
5331
5334
|
});
|
|
5332
5335
|
}
|
|
5333
|
-
function
|
|
5334
|
-
if (!Array.isArray(
|
|
5336
|
+
function normalizeRoomPermissions(permissions) {
|
|
5337
|
+
if (!Array.isArray(permissions)) {
|
|
5335
5338
|
throw new Error("Permission list must be an array");
|
|
5336
5339
|
}
|
|
5337
|
-
return
|
|
5338
|
-
if (!
|
|
5340
|
+
return permissions.map((permission) => {
|
|
5341
|
+
if (!isPermission(permission)) {
|
|
5339
5342
|
throw new Error(`Not a valid permission: ${permission}`);
|
|
5340
5343
|
}
|
|
5341
5344
|
return permission;
|
|
5342
5345
|
});
|
|
5343
5346
|
}
|
|
5344
|
-
function
|
|
5345
|
-
if (
|
|
5347
|
+
function normalizeRoomAccesses(accesses) {
|
|
5348
|
+
if (accesses === void 0) {
|
|
5346
5349
|
return void 0;
|
|
5347
5350
|
}
|
|
5348
5351
|
return Object.fromEntries(
|
|
5349
|
-
Object.entries(
|
|
5352
|
+
Object.entries(accesses).map(([id, permissions]) => [
|
|
5350
5353
|
id,
|
|
5351
|
-
|
|
5354
|
+
normalizeRoomPermissions(permissions)
|
|
5352
5355
|
])
|
|
5353
5356
|
);
|
|
5354
5357
|
}
|
|
5355
|
-
function
|
|
5356
|
-
if (
|
|
5358
|
+
function normalizeUpdateRoomAccesses(accesses) {
|
|
5359
|
+
if (accesses === void 0) {
|
|
5357
5360
|
return void 0;
|
|
5358
5361
|
}
|
|
5359
5362
|
return Object.fromEntries(
|
|
5360
|
-
Object.entries(
|
|
5363
|
+
Object.entries(accesses).map(([id, permissions]) => [
|
|
5361
5364
|
id,
|
|
5362
|
-
permissions === null ? null :
|
|
5365
|
+
permissions === null ? null : normalizeRoomPermissions(permissions)
|
|
5363
5366
|
])
|
|
5364
5367
|
);
|
|
5365
5368
|
}
|
|
5366
|
-
function mergePermissionMatrices(
|
|
5369
|
+
function mergePermissionMatrices(matrices) {
|
|
5367
5370
|
return {
|
|
5368
|
-
room: strongestMatrixAccess(
|
|
5369
|
-
storage: strongestMatrixAccess(
|
|
5370
|
-
comments: strongestMatrixAccess(
|
|
5371
|
-
feeds: strongestMatrixAccess(
|
|
5372
|
-
personal: strongestMatrixAccess(
|
|
5371
|
+
room: strongestMatrixAccess(matrices, "room"),
|
|
5372
|
+
storage: strongestMatrixAccess(matrices, "storage"),
|
|
5373
|
+
comments: strongestMatrixAccess(matrices, "comments"),
|
|
5374
|
+
feeds: strongestMatrixAccess(matrices, "feeds"),
|
|
5375
|
+
personal: strongestMatrixAccess(matrices, "personal")
|
|
5373
5376
|
};
|
|
5374
5377
|
}
|
|
5375
5378
|
function permissionMatrixToScopes(matrix) {
|
|
@@ -5391,12 +5394,13 @@ function mergeRoomPermissionScopes({
|
|
|
5391
5394
|
groupsAccesses,
|
|
5392
5395
|
userAccesses
|
|
5393
5396
|
}) {
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5397
|
+
return permissionMatrixToScopes(
|
|
5398
|
+
mergePermissionMatrices([
|
|
5399
|
+
permissionMatrixFromScopes(defaultAccesses),
|
|
5400
|
+
...groupsAccesses.map(permissionMatrixFromScopes),
|
|
5401
|
+
permissionMatrixFromScopes(userAccesses)
|
|
5402
|
+
])
|
|
5403
|
+
);
|
|
5400
5404
|
}
|
|
5401
5405
|
function permissionForAccessLevel(resource, access, field = resource) {
|
|
5402
5406
|
const levels = PERMISSIONS_BY_RESOURCE[resource];
|
|
@@ -5408,9 +5412,9 @@ function permissionForAccessLevel(resource, access, field = resource) {
|
|
|
5408
5412
|
}
|
|
5409
5413
|
return permissions[0];
|
|
5410
5414
|
}
|
|
5411
|
-
function strongestMatrixAccess(
|
|
5412
|
-
return
|
|
5413
|
-
(strongest,
|
|
5415
|
+
function strongestMatrixAccess(matrices, resource) {
|
|
5416
|
+
return matrices.reduce(
|
|
5417
|
+
(strongest, matrix) => strongestAccess(strongest, matrix[resource]),
|
|
5414
5418
|
"none"
|
|
5415
5419
|
);
|
|
5416
5420
|
}
|
|
@@ -5593,7 +5597,7 @@ function makeCachedToken(token, expiresAt) {
|
|
|
5593
5597
|
function getAuthTokenPermissionScopes(permissions) {
|
|
5594
5598
|
return Object.entries(permissions).map(([resource, scopes]) => ({
|
|
5595
5599
|
resource,
|
|
5596
|
-
scopes
|
|
5600
|
+
scopes: normalizeRoomPermissions(scopes)
|
|
5597
5601
|
}));
|
|
5598
5602
|
}
|
|
5599
5603
|
function cachedTokenSatisfiesRequest(cachedToken, request) {
|
|
@@ -9501,23 +9505,15 @@ var ClientMsgCode = Object.freeze({
|
|
|
9501
9505
|
|
|
9502
9506
|
// src/refs/ManagedOthers.ts
|
|
9503
9507
|
function makeUser(conn, presence) {
|
|
9504
|
-
const { connectionId, id, info } = conn;
|
|
9505
|
-
const canWrite =
|
|
9506
|
-
conn.permissionMatrix,
|
|
9507
|
-
"storage",
|
|
9508
|
-
"write"
|
|
9509
|
-
);
|
|
9508
|
+
const { connectionId, id, info, access } = conn;
|
|
9509
|
+
const { canWrite, canComment } = access;
|
|
9510
9510
|
return freeze(
|
|
9511
9511
|
compactObject({
|
|
9512
9512
|
connectionId,
|
|
9513
9513
|
id,
|
|
9514
9514
|
info,
|
|
9515
9515
|
canWrite,
|
|
9516
|
-
canComment
|
|
9517
|
-
conn.permissionMatrix,
|
|
9518
|
-
"comments",
|
|
9519
|
-
"write"
|
|
9520
|
-
),
|
|
9516
|
+
canComment,
|
|
9521
9517
|
isReadOnly: !canWrite,
|
|
9522
9518
|
// Deprecated, kept for backward-compatibility
|
|
9523
9519
|
presence
|
|
@@ -9588,7 +9584,7 @@ var ManagedOthers = class {
|
|
|
9588
9584
|
* Records a known connection. This records the connection ID and the
|
|
9589
9585
|
* associated metadata.
|
|
9590
9586
|
*/
|
|
9591
|
-
setConnection(connectionId, metaUserId, metaUserInfo,
|
|
9587
|
+
setConnection(connectionId, metaUserId, metaUserInfo, access) {
|
|
9592
9588
|
this.#internal.mutate((state) => {
|
|
9593
9589
|
state.connections.set(
|
|
9594
9590
|
connectionId,
|
|
@@ -9596,7 +9592,7 @@ var ManagedOthers = class {
|
|
|
9596
9592
|
connectionId,
|
|
9597
9593
|
id: metaUserId,
|
|
9598
9594
|
info: metaUserInfo,
|
|
9599
|
-
|
|
9595
|
+
access
|
|
9600
9596
|
})
|
|
9601
9597
|
);
|
|
9602
9598
|
if (!state.presences.has(connectionId)) {
|
|
@@ -9749,6 +9745,14 @@ function defaultMessageFromContext(context) {
|
|
|
9749
9745
|
|
|
9750
9746
|
// src/room.ts
|
|
9751
9747
|
var FEEDS_TIMEOUT = 5e3;
|
|
9748
|
+
function connectionAccessFromScopes(scopes) {
|
|
9749
|
+
const roomPermissions = normalizeRoomPermissions(scopes);
|
|
9750
|
+
const matrix = permissionMatrixFromScopes(roomPermissions);
|
|
9751
|
+
return {
|
|
9752
|
+
canWrite: hasPermissionAccess(matrix, "storage", "write"),
|
|
9753
|
+
canComment: hasPermissionAccess(matrix, "comments", "write")
|
|
9754
|
+
};
|
|
9755
|
+
}
|
|
9752
9756
|
function makeIdFactory(connectionId) {
|
|
9753
9757
|
let count = 0;
|
|
9754
9758
|
return () => `${connectionId}:${count++}`;
|
|
@@ -10339,7 +10343,9 @@ function createRoom(options, config) {
|
|
|
10339
10343
|
context.dynamicSessionInfoSig.set({
|
|
10340
10344
|
actor: message.actor,
|
|
10341
10345
|
nonce: message.nonce,
|
|
10342
|
-
permissionMatrix: permissionMatrixFromScopes(
|
|
10346
|
+
permissionMatrix: permissionMatrixFromScopes(
|
|
10347
|
+
normalizeRoomPermissions(message.scopes)
|
|
10348
|
+
),
|
|
10343
10349
|
meta: message.meta
|
|
10344
10350
|
});
|
|
10345
10351
|
context.idFactory = makeIdFactory(message.actor);
|
|
@@ -10360,7 +10366,7 @@ function createRoom(options, config) {
|
|
|
10360
10366
|
connectionId,
|
|
10361
10367
|
user.id,
|
|
10362
10368
|
user.info,
|
|
10363
|
-
user.scopes
|
|
10369
|
+
connectionAccessFromScopes(user.scopes)
|
|
10364
10370
|
);
|
|
10365
10371
|
}
|
|
10366
10372
|
return { type: "reset" };
|
|
@@ -10380,7 +10386,7 @@ function createRoom(options, config) {
|
|
|
10380
10386
|
message.actor,
|
|
10381
10387
|
message.id,
|
|
10382
10388
|
message.info,
|
|
10383
|
-
message.scopes
|
|
10389
|
+
connectionAccessFromScopes(message.scopes)
|
|
10384
10390
|
);
|
|
10385
10391
|
context.buffer.messages.push({
|
|
10386
10392
|
type: ClientMsgCode.UPDATE_PRESENCE,
|
|
@@ -11746,7 +11752,6 @@ function createClient(options) {
|
|
|
11746
11752
|
),
|
|
11747
11753
|
authenticate: async () => {
|
|
11748
11754
|
const resp = await authManager.getAuthValue({
|
|
11749
|
-
// TODO: Should we have permissions for AI Copilots?
|
|
11750
11755
|
resource: "personal",
|
|
11751
11756
|
access: "write"
|
|
11752
11757
|
});
|
|
@@ -12690,9 +12695,9 @@ export {
|
|
|
12690
12695
|
nanoid,
|
|
12691
12696
|
nn,
|
|
12692
12697
|
nodeStreamToCompactNodes,
|
|
12693
|
-
|
|
12694
|
-
|
|
12695
|
-
|
|
12698
|
+
normalizeRoomAccesses,
|
|
12699
|
+
normalizeRoomPermissions,
|
|
12700
|
+
normalizeUpdateRoomAccesses,
|
|
12696
12701
|
objectToQuery,
|
|
12697
12702
|
patchNotificationSettings,
|
|
12698
12703
|
permissionMatrixFromScopes,
|