@univerjs-pro/collaboration-endpoint 1.0.0-insiders.20260727-46ed76c
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/comb-protocol.d.ts +47 -0
- package/dist/comb-protocol.js +1 -0
- package/dist/endpoint.d.ts +62 -0
- package/dist/endpoint.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/middleware-registry.d.ts +8 -0
- package/dist/middleware-registry.js +1 -0
- package/dist/protocol-http.d.ts +10 -0
- package/dist/protocol-http.js +1 -0
- package/dist/ticket-store.d.ts +9 -0
- package/dist/ticket-store.js +1 -0
- package/dist/univer-collab-endpoint.d.ts +82 -0
- package/dist/univer-collab-endpoint.js +1 -0
- package/package.json +25 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { IChangeset, ICombJoinResponse, IMember, IUpdateCursor } from "@univerjs/protocol";
|
|
2
|
+
import { CmdRspCode, CombCmd } from "@univerjs/protocol";
|
|
3
|
+
export declare const CollabEvent: {
|
|
4
|
+
readonly CHANGESET_ACK: "changeset_ack";
|
|
5
|
+
readonly CHANGESET_REJ: "changeset_rej";
|
|
6
|
+
readonly CHANGESET_SHOULD_RETRY: "changeset_should_retry";
|
|
7
|
+
readonly NEW_CHANGESETS: "new_changesets";
|
|
8
|
+
readonly PERMISSION_REJ: "permission_rej";
|
|
9
|
+
readonly UPDATE_CURSOR: "update_cursor";
|
|
10
|
+
readonly USERS_ENTER: "users_enter";
|
|
11
|
+
readonly USERS_LEAVE: "users_leave";
|
|
12
|
+
};
|
|
13
|
+
export interface CombInboundMessage {
|
|
14
|
+
readonly cmd?: unknown;
|
|
15
|
+
readonly routeKey?: unknown;
|
|
16
|
+
readonly joinReq?: {
|
|
17
|
+
readonly rooms?: readonly {
|
|
18
|
+
readonly roomID?: unknown;
|
|
19
|
+
readonly args?: unknown;
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
readonly leaveReq?: {
|
|
23
|
+
readonly roomID?: unknown;
|
|
24
|
+
readonly args?: unknown;
|
|
25
|
+
};
|
|
26
|
+
readonly collaMsg?: {
|
|
27
|
+
readonly eventID?: unknown;
|
|
28
|
+
readonly updateCursorEvent?: {
|
|
29
|
+
readonly unitID?: unknown;
|
|
30
|
+
readonly memberID?: unknown;
|
|
31
|
+
readonly selection?: unknown;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare function infoResponse(cmd: CombCmd.HELLO | CombCmd.HEARTBEAT, memberID: string, routeKey?: string): object;
|
|
36
|
+
export declare function joinResponse(routeKey: string, code: CmdRspCode, roomInfos: ICombJoinResponse["roomInfos"], reason: string): object;
|
|
37
|
+
export declare function memberToProtocol(member: {
|
|
38
|
+
readonly memberID: string;
|
|
39
|
+
readonly userID: string;
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly avatar?: string;
|
|
42
|
+
}): IMember;
|
|
43
|
+
export declare function userEnterMessage(unitID: string, member: IMember): object;
|
|
44
|
+
export declare function userLeaveMessage(unitID: string, member: Pick<IMember, "memberID" | "name">): object;
|
|
45
|
+
export declare function presenceMessage(unitID: string, payload: IUpdateCursor): object;
|
|
46
|
+
export declare function changesetMessage(unitID: string, event: typeof CollabEvent.CHANGESET_ACK | typeof CollabEvent.CHANGESET_REJ | typeof CollabEvent.CHANGESET_SHOULD_RETRY | typeof CollabEvent.NEW_CHANGESETS | typeof CollabEvent.PERMISSION_REJ, changeset: IChangeset): object;
|
|
47
|
+
export declare function trustedEventMessage(unitID: string, eventID: string, data: Readonly<Record<string, unknown>>): object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';const _0x1189ea=_0x1efc;(function(_0x5ba8ba,_0x26ffa3){const _0xaec20b=_0x1efc,_0x5234d5=_0x5ba8ba();while(!![]){try{const _0x4052b9=-parseInt(_0xaec20b(0xed))/0x1+parseInt(_0xaec20b(0xf0))/0x2*(-parseInt(_0xaec20b(0xfd))/0x3)+parseInt(_0xaec20b(0xdc))/0x4+-parseInt(_0xaec20b(0xe9))/0x5*(parseInt(_0xaec20b(0xf9))/0x6)+parseInt(_0xaec20b(0xf3))/0x7+-parseInt(_0xaec20b(0xd8))/0x8*(parseInt(_0xaec20b(0x100))/0x9)+parseInt(_0xaec20b(0xd9))/0xa;if(_0x4052b9===_0x26ffa3)break;else _0x5234d5['push'](_0x5234d5['shift']());}catch(_0x118456){_0x5234d5['push'](_0x5234d5['shift']());}}}(_0x52ca,0x7dcf1));function _0x1efc(_0x139b97,_0x53123e){_0x139b97=_0x139b97-0xd7;const _0x52ca2f=_0x52ca();let _0x1efc19=_0x52ca2f[_0x139b97];return _0x1efc19;}Object['defineProperty'](exports,_0x1189ea(0xf6),{'value':!![]}),exports[_0x1189ea(0xe2)]=void 0x0,exports[_0x1189ea(0xf7)]=infoResponse,exports[_0x1189ea(0xdb)]=joinResponse,exports[_0x1189ea(0xfe)]=memberToProtocol,exports[_0x1189ea(0xeb)]=userEnterMessage,exports[_0x1189ea(0xef)]=userLeaveMessage,exports[_0x1189ea(0xfa)]=presenceMessage,exports[_0x1189ea(0xfb)]=changesetMessage,exports[_0x1189ea(0xda)]=trustedEventMessage;function _0x52ca(){const _0x4d1e4e=['trustedEventMessage','joinResponse','3567572vskTFl','JOIN','changeset_ack','userID','csRejEvent','changeset_rej','CollabEvent','permission_rej','users_enter','newCsEvent','CombCmd','avatar','USERS_ENTER','10uhzQGZ','CmdRspCode','userEnterMessage','csShouldRetryEvent','400486LiGSBC','update_cursor','userLeaveMessage','2rkzPXc','new_changesets','users_leave','292621kxlIYT','NEW_CHANGESETS','memberID','__esModule','infoResponse','changeset_should_retry','991602VjJZTs','presenceMessage','changesetMessage','CHANGESET_SHOULD_RETRY','966213bOUvKA','memberToProtocol','PERMISSION_REJ','39483FaLiXn','UPDATE_CURSOR','csAckEvent','1280XCfdjy','13366280yKjPhe'];_0x52ca=function(){return _0x4d1e4e;};return _0x52ca();}const protocol_1=require('@univerjs/protocol');exports[_0x1189ea(0xe2)]={'CHANGESET_ACK':_0x1189ea(0xde),'CHANGESET_REJ':_0x1189ea(0xe1),'CHANGESET_SHOULD_RETRY':_0x1189ea(0xf8),'NEW_CHANGESETS':_0x1189ea(0xf1),'PERMISSION_REJ':_0x1189ea(0xe3),'UPDATE_CURSOR':_0x1189ea(0xee),'USERS_ENTER':_0x1189ea(0xe4),'USERS_LEAVE':_0x1189ea(0xf2)};function infoResponse(_0x22abdb,_0xffbdda,_0x299403=''){const _0x240673=_0x1189ea;return{'cmd':_0x22abdb,'code':protocol_1[_0x240673(0xea)]['OK'],'reason':'success','routeKey':_0x299403,'infoRsp':{'memberID':_0xffbdda}};}function joinResponse(_0x1a6693,_0x53c369,_0x2a7714,_0x24fa1c){const _0x111092=_0x1189ea;return{'cmd':protocol_1['CombCmd'][_0x111092(0xdd)],'code':_0x53c369,'reason':_0x24fa1c,'routeKey':_0x1a6693,'joinRsp':{'roomInfos':_0x2a7714}};}function memberToProtocol(_0x273e47){const _0x92636f=_0x1189ea;return{'memberID':_0x273e47[_0x92636f(0xf5)],'userID':_0x273e47[_0x92636f(0xdf)],'name':_0x273e47['name'],..._0x273e47['avatar']===undefined?{}:{'avatar':_0x273e47[_0x92636f(0xe7)]}};}function recv(_0x482d49,_0x3daa45){const _0x4386bc=_0x1189ea;return{'cmd':protocol_1[_0x4386bc(0xe6)]['RECV'],'code':protocol_1[_0x4386bc(0xea)]['OK'],'reason':'success','routeKey':_0x482d49,'collaMsg':_0x3daa45};}function userEnterMessage(_0x5b0a55,_0x39889b){const _0x2a9f03=_0x1189ea;return recv(_0x5b0a55,{'eventID':exports[_0x2a9f03(0xe2)][_0x2a9f03(0xe8)],'joinEvent':{..._0x39889b,'avatar':_0x39889b[_0x2a9f03(0xe7)]??''}});}function userLeaveMessage(_0x46e722,_0x1c96da){const _0x36492b=_0x1189ea;return recv(_0x46e722,{'eventID':exports[_0x36492b(0xe2)]['USERS_LEAVE'],'leaveEvent':_0x1c96da});}function presenceMessage(_0x464474,_0x85ef9){const _0x535eab=_0x1189ea;return recv(_0x464474,{'eventID':exports[_0x535eab(0xe2)][_0x535eab(0x101)],'updateCursorEvent':_0x85ef9});}function changesetMessage(_0x1a4b76,_0x45e3e,_0x36eec0){const _0x3f62e0=_0x1189ea,_0x42cd14={[exports[_0x3f62e0(0xe2)]['CHANGESET_ACK']]:_0x3f62e0(0xd7),[exports[_0x3f62e0(0xe2)]['CHANGESET_REJ']]:_0x3f62e0(0xe0),[exports['CollabEvent'][_0x3f62e0(0xfc)]]:_0x3f62e0(0xec),[exports[_0x3f62e0(0xe2)][_0x3f62e0(0xf4)]]:_0x3f62e0(0xe5),[exports[_0x3f62e0(0xe2)][_0x3f62e0(0xff)]]:'permissionRejEvent'}[_0x45e3e];return recv(_0x1a4b76,{'eventID':_0x45e3e,[_0x42cd14]:{'cs':_0x36eec0}});}function trustedEventMessage(_0x1578db,_0x1d84b6,_0x2d46c6){return recv(_0x1578db,{..._0x2d46c6,'eventID':_0x1d84b6});}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type CollabSession, type Disposable, type IUniverCollabService } from "@univerjs-pro/collaboration-service";
|
|
2
|
+
import type { NodeTransportContext, NodeTransportMiddlewareObject, NodeTransportNext } from "@univerjs-pro/collaboration-transport-node";
|
|
3
|
+
import type { EndpointEventMap, EndpointMiddlewareAction, EndpointMiddlewareMap, ITrustedUnitRoomHost, UniverCollabEndpointOptions } from "./univer-collab-endpoint.js";
|
|
4
|
+
type EndpointListener<K extends keyof EndpointEventMap> = (event: EndpointEventMap[K]) => void | Promise<void>;
|
|
5
|
+
export declare class UniverCollabEndpoint implements NodeTransportMiddlewareObject, ITrustedUnitRoomHost {
|
|
6
|
+
private readonly _service;
|
|
7
|
+
private readonly _middleware;
|
|
8
|
+
private readonly _listeners;
|
|
9
|
+
private readonly _bindingsByConnection;
|
|
10
|
+
private readonly _claimedConnectionIDs;
|
|
11
|
+
private readonly _bindingsByMember;
|
|
12
|
+
private readonly _rooms;
|
|
13
|
+
private readonly _outboundQueues;
|
|
14
|
+
private readonly _ticketStore;
|
|
15
|
+
private readonly _ownsTicketStore;
|
|
16
|
+
private readonly _ticketTtlMs;
|
|
17
|
+
private readonly _protocolBasePath;
|
|
18
|
+
private readonly _combPath;
|
|
19
|
+
private readonly _serviceSubscriptions;
|
|
20
|
+
private readonly _deletedUnitIDs;
|
|
21
|
+
private _disposed;
|
|
22
|
+
constructor(_service: IUniverCollabService, options?: UniverCollabEndpointOptions);
|
|
23
|
+
use<K extends EndpointMiddlewareAction>(action: K, middleware: EndpointMiddlewareMap[K]): Disposable;
|
|
24
|
+
on<K extends keyof EndpointEventMap>(event: K, listener: EndpointListener<K>): Disposable;
|
|
25
|
+
findJoinedSession(input: {
|
|
26
|
+
readonly unitID: string;
|
|
27
|
+
readonly memberID: string;
|
|
28
|
+
readonly authenticatedUserID: string;
|
|
29
|
+
}): CollabSession | null;
|
|
30
|
+
findJoinedSessionByUser(input: {
|
|
31
|
+
readonly unitID: string;
|
|
32
|
+
readonly authenticatedUserID: string;
|
|
33
|
+
}): CollabSession | null;
|
|
34
|
+
publishTrustedUnitEvent(input: {
|
|
35
|
+
readonly unitID: string;
|
|
36
|
+
readonly origin: CollabSession;
|
|
37
|
+
readonly eventID: string;
|
|
38
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
handle(ctx: NodeTransportContext, next: NodeTransportNext): Promise<void>;
|
|
41
|
+
dispose(): Promise<void>;
|
|
42
|
+
private _handleHttp;
|
|
43
|
+
private _handleOpen;
|
|
44
|
+
private _handleMessage;
|
|
45
|
+
private _handleJoin;
|
|
46
|
+
private _handleLeave;
|
|
47
|
+
private _handlePresence;
|
|
48
|
+
private _handleNewChanges;
|
|
49
|
+
private _trustedClientChangeset;
|
|
50
|
+
private _enqueueCommittedChangeset;
|
|
51
|
+
private _evictUnitRoom;
|
|
52
|
+
private _enqueueUnitOutbound;
|
|
53
|
+
private _disconnectConnection;
|
|
54
|
+
private _disconnectBinding;
|
|
55
|
+
private _leaveUnit;
|
|
56
|
+
private _broadcastToRoom;
|
|
57
|
+
private _safeSend;
|
|
58
|
+
private _emit;
|
|
59
|
+
private _assertRunning;
|
|
60
|
+
private _assertJoinable;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
package/dist/endpoint.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';const _0x44c8b6=_0x3a08;(function(_0x34a696,_0x2f3bef){const _0x40fded=_0x3a08,_0x15e1f5=_0x34a696();while(!![]){try{const _0x47bc11=parseInt(_0x40fded(0x2ac))/0x1*(parseInt(_0x40fded(0x23a))/0x2)+parseInt(_0x40fded(0x2bd))/0x3+parseInt(_0x40fded(0x21a))/0x4+-parseInt(_0x40fded(0x2c0))/0x5+parseInt(_0x40fded(0x29c))/0x6+-parseInt(_0x40fded(0x259))/0x7+-parseInt(_0x40fded(0x2b2))/0x8*(-parseInt(_0x40fded(0x2a9))/0x9);if(_0x47bc11===_0x2f3bef)break;else _0x15e1f5['push'](_0x15e1f5['shift']());}catch(_0x3ccaa0){_0x15e1f5['push'](_0x15e1f5['shift']());}}}(_0x2be7,0x50241));Object['defineProperty'](exports,_0x44c8b6(0x225),{'value':!![]}),exports[_0x44c8b6(0x23c)]=void 0x0;function _0x2be7(){const _0x30a58e=['JOIN','params','CmdRspCode','Stored\x20sheet\x20block\x20is\x20not\x20valid\x20JSON','presenceMessage','rejected','1891456VczqNm','HELLO','CollabEvent','unitIds\x20must\x20be\x20a\x20non-empty\x20string\x20array','kind','send','trustedEventMessage','_deletedUnitIDs','run','changeset','websocket-open','incomingMessage','_handleOpen','findJoinedSession','comb','_disconnectBinding','http','resources','FAIL','add','_assertJoinable','sessionTicketTtlMs','isArray','response','keys','resourceId','getSheetBlock','ticketStore','getResources','type','_disconnectConnection','status','collaMsg','_combPath','GET','pathname','INTERNAL_ERROR','_handleMessage','POST','deserialized-block','/snapshot/-/units/recover','endsWith','selection','_disposed','userLeaveMessage','snapshot','slice','stringify','websocket-message','UNIT_NOT_FOUND','userId','protocolFailure','cmd','rev','searchParams','publishTrustedUnitEvent','infoResponse','Request\x20body\x20must\x20be\x20an\x20object','Sheet\x20block\x20was\x20not\x20found','origin','_ticketStore','Invalid\x20Comb\x20JSON\x20message','getAll','size','receivePresence','writeProtocolJson','request','705960xJJnAm','websocket-close','trim','parseInteger','memberToProtocol','_handleHttp','joinReq','url','_listeners','recoverUnits','code','_handleNewChanges','map','60741BpLlEa','session','eventID','4ZJAtel','_rooms','HEARTBEAT','isSafeInteger','new_changes','ticket','280vCQyZK','_bindingsByConnection','submitChangeset','authenticatedUserID','protocolBasePath\x20must\x20be\x20an\x20absolute\x20path\x20without\x20a\x20trailing\x20slash','_ticketTtlMs','routeKey','endpoint-dispose','getChangesets','get','Unit\x20has\x20been\x20deleted','229020cZrbRZ','all','HTTP\x20user\x20is\x20not\x20authenticated','884175exXKCO','recover-units','JOIN_ROOM_PERMISSION_DENIED','revision','/universer-api','updateCursorEvent','startsWith','LEAVE','explicit','unit','consume','error','disconnect','CHANGESET_SHOULD_RETRY','_assertRunning','has','leaveReq','_enqueueCommittedChangeset','_protocolBasePath','values','unitIDs','fetch-missing','memberId','INVALID_REQUEST','split','CollabError','filter','_handleLeave','includes','_middleware','hardDelete\x20must\x20be\x20true\x20or\x20false','Invalid\x20JOIN\x20request','message','joinResponse','then','UPDATE_CURSOR','blockID','_serviceSubscriptions','parse','randomUUID','changesetCommitted','Invalid\x20new\x20changes\x20request','resourceId\x20must\x20be\x20a\x20JSON\x20string\x20array','Comb\x20messages\x20must\x20be\x20JSON\x20text','unitID','delete-units','CombCmd','Route\x20contains\x20invalid\x20encoding','UNAUTHENTICATED','OK_ERROR','new-changes','string','http://localhost','readJson','http-','deleteUnits','memberID','_leaveUnit','unitIds','_trustedClientChangeset','_enqueueUnitOutbound','928452fuwSxW','true','_broadcastToRoom','decode','handle','use','WebSocket\x20Session\x20is\x20not\x20established','dispose','sendPresence','clear','customData','__esModule','Endpoint\x20failure','_bindingsByMember','_emit','protocolBasePath','JOIN\x20failed','PERMISSION_DENIED','changesets','set','_ownsTicketStore','_safeSend','_evictUnitRoom','changesetMessage','Route,\x20request\x20and\x20changeset\x20identity\x20must\x20match','Invalid\x20or\x20expired\x20session\x20ticket','joinedUnitIDs','delete','CHANGESET_ACK','close','latestRevision','member','56486lYKsIr','already-committed','UniverCollabEndpoint','connection','_claimedConnectionIDs','length','block','Endpoint\x20disposed','from','object','retry','finally','some','_outboundQueues','/user/session-ticket','UniverCollabEndpoint\x20requires\x20a\x20service','_service','data','allSettled','resolve','name','roomID','_handlePresence','hardDelete','unitsRecovered'];_0x2be7=function(){return _0x30a58e;};return _0x2be7();}const node_crypto_1=require('node:crypto'),collaboration_service_1=require('@univerjs-pro/collaboration-service'),protocol_1=require('@univerjs/protocol'),comb_protocol_js_1=require('./comb-protocol.js'),middleware_registry_js_1=require('./middleware-registry.js'),protocol_http_js_1=require('./protocol-http.js'),ticket_store_js_1=require('./ticket-store.js'),DEFAULT_TICKET_TTL_MS=0x5*0xea60;function decodeSegment(_0x2b35b8){const _0x46b691=_0x44c8b6;try{return decodeURIComponent(_0x2b35b8);}catch{throw new collaboration_service_1[(_0x46b691(0x1f6))](_0x46b691(0x1f4),_0x46b691(0x20c));}}function matchHttpRoute(_0x5a7f54,_0xf21fb9,_0xee7c8){const _0x29c573=_0x44c8b6,_0x1187db=relativeProtocolPath(_0xf21fb9,_0xee7c8);if(_0x1187db===null)return null;if(_0x5a7f54===_0x29c573(0x27b)&&_0x1187db===_0x29c573(0x248))return{'name':'ticket','params':{}};if(_0x5a7f54==='DELETE'&&_0x1187db==='/snapshot/-/units')return{'name':_0x29c573(0x20a),'params':{}};if(_0x5a7f54===_0x29c573(0x27f)&&_0x1187db===_0x29c573(0x281))return{'name':'recover-units','params':{}};const _0x1b4fae=_0x1187db[_0x29c573(0x1f5)]('/')['filter'](Boolean);if(_0x5a7f54===_0x29c573(0x27f)&&_0x1b4fae[_0x29c573(0x23f)]===0x5&&_0x1b4fae[0x0]===_0x29c573(0x267)&&_0x1b4fae[0x2]===_0x29c573(0x1e6)&&_0x1b4fae[0x4]===_0x29c573(0x2b0))return{'name':_0x29c573(0x20f),'params':{'type':decodeSegment(_0x1b4fae[0x1]),'unitID':decodeSegment(_0x1b4fae[0x3])}};if(_0x5a7f54!=='GET')return null;if(_0x1b4fae[0x0]!==_0x29c573(0x286))return null;if(_0x1b4fae[_0x29c573(0x23f)]===0x7&&_0x1b4fae[0x1]==='block'&&_0x1b4fae[0x3]===_0x29c573(0x1e6)&&_0x1b4fae[0x5]===_0x29c573(0x240))return{'name':'deserialized-block','params':{'type':decodeSegment(_0x1b4fae[0x2]),'unitID':decodeSegment(_0x1b4fae[0x4]),'blockID':decodeSegment(_0x1b4fae[0x6])}};if(_0x1b4fae[_0x29c573(0x23f)]<0x5||_0x1b4fae[0x2]!==_0x29c573(0x1e6))return null;const _0x4e6f99={'type':decodeSegment(_0x1b4fae[0x1]),'unitID':decodeSegment(_0x1b4fae[0x3])};if(_0x1b4fae[_0x29c573(0x23f)]===0x6&&_0x1b4fae[0x4]===_0x29c573(0x28e))return{'name':_0x29c573(0x1e6),'params':{..._0x4e6f99,'revision':decodeSegment(_0x1b4fae[0x5])}};if(_0x1b4fae['length']===0x6&&_0x1b4fae[0x4]===_0x29c573(0x240))return{'name':_0x29c573(0x240),'params':{..._0x4e6f99,'blockID':decodeSegment(_0x1b4fae[0x5])}};if(_0x1b4fae[_0x29c573(0x23f)]===0x5&&_0x1b4fae[0x4]==='fetchmissing')return{'name':_0x29c573(0x1f2),'params':_0x4e6f99};if(_0x1b4fae[_0x29c573(0x23f)]===0x5&&_0x1b4fae[0x4]===_0x29c573(0x26a))return{'name':_0x29c573(0x26a),'params':_0x4e6f99};return null;}function relativeProtocolPath(_0x296528,_0x2ae90d){const _0xd6085=_0x44c8b6;if(_0x296528===_0x2ae90d)return'/';const _0x555776=_0x2ae90d+'/';return _0x296528[_0xd6085(0x1e3)](_0x555776)?_0x296528[_0xd6085(0x287)](_0x2ae90d['length']):null;}function normalizeProtocolBasePath(_0x4b002d){const _0xa2e626=_0x44c8b6;if(!_0x4b002d[_0xa2e626(0x1e3)]('/')||_0x4b002d==='/'||_0x4b002d[_0xa2e626(0x282)]('/')||_0x4b002d[_0xa2e626(0x1f9)]('?')||_0x4b002d['includes']('#'))throw new TypeError(_0xa2e626(0x2b6));return _0x4b002d;}function callerSession(_0x5153e5){const _0x1c7024=_0x44c8b6;return{'memberId':_0x1c7024(0x213)+(0x0,node_crypto_1[_0x1c7024(0x204)])(),'userId':_0x5153e5,'customData':{}};}function assertNewChangesRequest(_0x119152){const _0x611f4c=_0x44c8b6;if(!_0x119152||typeof _0x119152!==_0x611f4c(0x243))throw new collaboration_service_1[(_0x611f4c(0x1f6))](_0x611f4c(0x1f4),_0x611f4c(0x292));const _0x4bc85a=_0x119152;if(typeof _0x4bc85a['unitID']!==_0x611f4c(0x210)||typeof _0x4bc85a[_0x611f4c(0x215)]!=='string'||!Number[_0x611f4c(0x2af)](_0x4bc85a[_0x611f4c(0x276)])||!_0x4bc85a[_0x611f4c(0x262)]||typeof _0x4bc85a[_0x611f4c(0x262)]!==_0x611f4c(0x243))throw new collaboration_service_1['CollabError']('INVALID_REQUEST',_0x611f4c(0x206));}function _0x3a08(_0x1c201f,_0x3de9c7){_0x1c201f=_0x1c201f-0x1de;const _0x2be72e=_0x2be7();let _0x3a0830=_0x2be72e[_0x1c201f];return _0x3a0830;}function assertUnitIDs(_0x62297e){const _0x594794=_0x44c8b6;if(!Array[_0x594794(0x26f)](_0x62297e)||_0x62297e[_0x594794(0x23f)]===0x0||_0x62297e['some'](_0x3a8ab5=>typeof _0x3a8ab5!==_0x594794(0x210)||_0x3a8ab5[_0x594794(0x29e)]()['length']===0x0))throw new collaboration_service_1['CollabError'](_0x594794(0x1f4),_0x594794(0x25c));}function parseDeleteUnitsRequest(_0x3fa99e){const _0x3b9f7f=_0x44c8b6,_0x177937=_0x3fa99e[_0x3b9f7f(0x297)](_0x3b9f7f(0x217));assertUnitIDs(_0x177937);const _0xa40ef6=_0x3fa99e[_0x3b9f7f(0x297)](_0x3b9f7f(0x251));if(_0xa40ef6[_0x3b9f7f(0x23f)]>0x1||_0xa40ef6[_0x3b9f7f(0x23f)]===0x1&&_0xa40ef6[0x0]!==_0x3b9f7f(0x21b)&&_0xa40ef6[0x0]!=='false')throw new collaboration_service_1[(_0x3b9f7f(0x1f6))](_0x3b9f7f(0x1f4),_0x3b9f7f(0x1fb));return{'unitIds':_0x177937,'hardDelete':_0xa40ef6[0x0]===_0x3b9f7f(0x21b)};}function assertRecoverUnitsRequest(_0x518c18){const _0x11f856=_0x44c8b6;if(!_0x518c18||typeof _0x518c18!==_0x11f856(0x243))throw new collaboration_service_1[(_0x11f856(0x1f6))](_0x11f856(0x1f4),_0x11f856(0x292));assertUnitIDs(_0x518c18['unitIds']);}class UniverCollabEndpoint{[_0x44c8b6(0x24a)];[_0x44c8b6(0x1fa)]=new middleware_registry_js_1['EndpointMiddlewareRegistry']();[_0x44c8b6(0x2a4)]=new Map();['_bindingsByConnection']=new Map();[_0x44c8b6(0x23e)]=new Set();[_0x44c8b6(0x227)]=new Map();[_0x44c8b6(0x2ad)]=new Map();[_0x44c8b6(0x247)]=new Map();['_ticketStore'];['_ownsTicketStore'];[_0x44c8b6(0x2b7)];[_0x44c8b6(0x1ef)];[_0x44c8b6(0x27a)];[_0x44c8b6(0x202)];[_0x44c8b6(0x260)]=new Set();[_0x44c8b6(0x284)]=![];constructor(_0x35ad72,_0x4c08cb={}){const _0x3b5e9c=_0x44c8b6;this[_0x3b5e9c(0x24a)]=_0x35ad72;if(!_0x35ad72)throw new TypeError(_0x3b5e9c(0x249));this['_ticketStore']=_0x4c08cb['ticketStore']??new ticket_store_js_1['MemorySessionTicketStore'](),this[_0x3b5e9c(0x22e)]=_0x4c08cb[_0x3b5e9c(0x274)]===undefined,this['_ticketTtlMs']=_0x4c08cb[_0x3b5e9c(0x26e)]??DEFAULT_TICKET_TTL_MS;if(!Number[_0x3b5e9c(0x2af)](this[_0x3b5e9c(0x2b7)])||this[_0x3b5e9c(0x2b7)]<=0x0)throw new TypeError('sessionTicketTtlMs\x20must\x20be\x20a\x20positive\x20safe\x20integer');this[_0x3b5e9c(0x1ef)]=normalizeProtocolBasePath(_0x4c08cb[_0x3b5e9c(0x229)]??_0x3b5e9c(0x1e1)),this[_0x3b5e9c(0x27a)]=this[_0x3b5e9c(0x1ef)]+'/comb/connect',this['_serviceSubscriptions']=[this['_service']['on'](_0x3b5e9c(0x205),_0x5e3da2=>{const _0x4f61a6=_0x3b5e9c;this[_0x4f61a6(0x1ee)](_0x5e3da2[_0x4f61a6(0x262)],_0x5e3da2[_0x4f61a6(0x2aa)]['memberId']);}),this[_0x3b5e9c(0x24a)]['on']('unitsDeleted',_0x5a01ba=>{const _0x540c75=_0x3b5e9c;for(const _0x1b891f of _0x5a01ba[_0x540c75(0x29b)][_0x540c75(0x1f1)]){this['_deletedUnitIDs']['add'](_0x1b891f);}for(const _0x47dcce of _0x5a01ba[_0x540c75(0x29b)][_0x540c75(0x1f1)]){this['_enqueueUnitOutbound'](_0x47dcce,async()=>{const _0x22b4b3=_0x540c75;this[_0x22b4b3(0x230)](_0x47dcce);});}}),this[_0x3b5e9c(0x24a)]['on'](_0x3b5e9c(0x252),async _0x407c45=>{const _0x3d928f=_0x3b5e9c;await Promise[_0x3d928f(0x2be)](_0x407c45[_0x3d928f(0x29b)][_0x3d928f(0x1f1)][_0x3d928f(0x2a8)](_0x319f2a=>this[_0x3d928f(0x219)](_0x319f2a,async()=>{const _0x870dfe=_0x3d928f;this[_0x870dfe(0x260)][_0x870dfe(0x235)](_0x319f2a);})));})];}[_0x44c8b6(0x21f)](_0x44e651,_0x4ac430){const _0x1ccdc4=_0x44c8b6;return this[_0x1ccdc4(0x1eb)](),this['_middleware'][_0x1ccdc4(0x21f)](_0x44e651,_0x4ac430);}['on'](_0x258011,_0x10a349){const _0x3bd706=_0x44c8b6;this[_0x3bd706(0x1eb)]();const _0xbc6ac7=this[_0x3bd706(0x2a4)]['get'](_0x258011)??new Set(),_0x206cea=_0x10a349;_0xbc6ac7['add'](_0x206cea),this[_0x3bd706(0x2a4)][_0x3bd706(0x22d)](_0x258011,_0xbc6ac7);let _0x5002f6=![];return{'dispose':()=>{const _0x435eac=_0x3bd706;if(_0x5002f6)return;_0x5002f6=!![],_0xbc6ac7[_0x435eac(0x235)](_0x206cea);}};}[_0x44c8b6(0x266)](_0x1bad23){const _0x478895=_0x44c8b6;if(this['_disposed'])return null;const _0x1f13c2=this[_0x478895(0x227)][_0x478895(0x2bb)](_0x1bad23['memberID']);if(!_0x1f13c2||_0x1f13c2[_0x478895(0x2aa)][_0x478895(0x28b)]!==_0x1bad23[_0x478895(0x2b5)]||!_0x1f13c2[_0x478895(0x234)]['has'](_0x1bad23[_0x478895(0x209)]))return null;return _0x1f13c2['session'];}['findJoinedSessionByUser'](_0xf4967e){const _0x9760a5=_0x44c8b6;if(this[_0x9760a5(0x284)])return null;for(const _0x41b76f of this[_0x9760a5(0x2ad)]['get'](_0xf4967e['unitID'])?.[_0x9760a5(0x1f0)]()??[]){if(_0x41b76f[_0x9760a5(0x2aa)][_0x9760a5(0x28b)]===_0xf4967e['authenticatedUserID'])return _0x41b76f[_0x9760a5(0x2aa)];}return null;}async[_0x44c8b6(0x290)](_0xdd85f6){const _0x3d9f84=_0x44c8b6;this[_0x3d9f84(0x1eb)]();const _0xe55e1e=[...this[_0x3d9f84(0x2ad)][_0x3d9f84(0x2bb)](_0xdd85f6['unitID'])?.[_0x3d9f84(0x271)]()??[]],_0x57e7de=this[_0x3d9f84(0x227)][_0x3d9f84(0x2bb)](_0xdd85f6[_0x3d9f84(0x294)][_0x3d9f84(0x1f3)]),_0x4a9c44=_0x57e7de?.[_0x3d9f84(0x234)][_0x3d9f84(0x1ec)](_0xdd85f6[_0x3d9f84(0x209)])?_0xdd85f6[_0x3d9f84(0x294)][_0x3d9f84(0x1f3)]:undefined,_0x3b5ea1=(0x0,comb_protocol_js_1[_0x3d9f84(0x25f)])(_0xdd85f6[_0x3d9f84(0x209)],_0xdd85f6[_0x3d9f84(0x2ab)],_0xdd85f6[_0x3d9f84(0x24b)]);this[_0x3d9f84(0x219)](_0xdd85f6['unitID'],async()=>{const _0x32d414=_0x3d9f84;for(const _0x19a755 of _0xe55e1e){if(_0x19a755===_0x4a9c44)continue;const _0x15e6f5=this[_0x32d414(0x227)][_0x32d414(0x2bb)](_0x19a755);if(!_0x15e6f5?.[_0x32d414(0x234)][_0x32d414(0x1ec)](_0xdd85f6[_0x32d414(0x209)]))continue;await this[_0x32d414(0x22f)](_0x15e6f5[_0x32d414(0x23d)],_0x3b5ea1);}});}async[_0x44c8b6(0x21e)](_0x5531f3,_0x407eed){const _0x2595e2=_0x44c8b6;if(this[_0x2595e2(0x284)]){await _0x407eed();return;}switch(_0x5531f3[_0x2595e2(0x25d)]){case _0x2595e2(0x269):await this[_0x2595e2(0x2a1)](_0x5531f3,_0x407eed);return;case _0x2595e2(0x263):await this[_0x2595e2(0x265)](_0x5531f3[_0x2595e2(0x264)]['url'],_0x5531f3['connection'],_0x407eed);return;case _0x2595e2(0x29d):!await this[_0x2595e2(0x277)](_0x5531f3[_0x2595e2(0x23d)],_0x2595e2(0x1e9))&&await _0x407eed();return;case _0x2595e2(0x289):await this['_handleMessage'](_0x5531f3,_0x407eed);return;}}async[_0x44c8b6(0x221)](){const _0x5778c1=_0x44c8b6;if(this[_0x5778c1(0x284)])return;this[_0x5778c1(0x284)]=!![];for(const _0x4caa61 of this[_0x5778c1(0x202)]){_0x4caa61[_0x5778c1(0x221)]();}await Promise['allSettled']([...this[_0x5778c1(0x247)]['values']()]);const _0x54aab3=[...this[_0x5778c1(0x2b3)]['values']()];for(const _0x5483e9 of _0x54aab3){await this[_0x5778c1(0x268)](_0x5483e9,_0x5778c1(0x2b9)),_0x5483e9[_0x5778c1(0x23d)]['close'](0x3e9,_0x5778c1(0x241));}this[_0x5778c1(0x2b3)][_0x5778c1(0x223)](),this[_0x5778c1(0x23e)]['clear'](),this['_bindingsByMember'][_0x5778c1(0x223)](),this['_rooms']['clear'](),this[_0x5778c1(0x247)][_0x5778c1(0x223)](),this[_0x5778c1(0x1fa)][_0x5778c1(0x223)](),this['_listeners'][_0x5778c1(0x223)]();if(this['_ownsTicketStore'])await this['_ticketStore'][_0x5778c1(0x221)]?.();}async[_0x44c8b6(0x2a1)](_0xc6d363,_0xe4d3cf){const _0x200ef4=_0x44c8b6;let _0x52511f,_0x21e8f1;try{_0x52511f=new URL(_0xc6d363['incomingMessage'][_0x200ef4(0x2a3)]??'/',_0x200ef4(0x211)),_0x21e8f1=matchHttpRoute(_0xc6d363[_0x200ef4(0x264)]['method'],_0x52511f[_0x200ef4(0x27c)],this[_0x200ef4(0x1ef)]);}catch(_0x49da2a){const _0xd5f2f8=(0x0,protocol_http_js_1['protocolFailure'])(_0x49da2a);(0x0,protocol_http_js_1[_0x200ef4(0x29a)])(_0xc6d363[_0x200ef4(0x270)],_0xd5f2f8[_0x200ef4(0x278)],{'error':_0xd5f2f8[_0x200ef4(0x1e8)]});return;}if(!_0x21e8f1){await _0xe4d3cf();return;}try{if(!_0xc6d363['userId'])throw new collaboration_service_1['CollabError'](_0x200ef4(0x20d),_0x200ef4(0x2bf));if(_0x21e8f1[_0x200ef4(0x24e)]===_0x200ef4(0x2b1)){const _0x198145=await this[_0x200ef4(0x295)]['issue']({'userId':_0xc6d363[_0x200ef4(0x28b)],'customData':_0xc6d363['customData']},this[_0x200ef4(0x2b7)]);(0x0,protocol_http_js_1[_0x200ef4(0x29a)])(_0xc6d363['response'],0xc8,{'error':protocol_http_js_1[_0x200ef4(0x20e)],'ticket':_0x198145});return;}const _0x534c5f=callerSession(_0xc6d363[_0x200ef4(0x28b)]),_0x5c069c={'session':_0x534c5f,'customData':_0xc6d363[_0x200ef4(0x224)]};if(_0x21e8f1[_0x200ef4(0x24e)]==='delete-units'){const _0x536963=parseDeleteUnitsRequest(_0x52511f[_0x200ef4(0x28f)]);await this[_0x200ef4(0x24a)][_0x200ef4(0x214)]({'unitIDs':_0x536963[_0x200ef4(0x217)],'hardDelete':_0x536963[_0x200ef4(0x251)]},_0x5c069c),(0x0,protocol_http_js_1['writeProtocolJson'])(_0xc6d363['response'],0xc8,{'error':protocol_http_js_1[_0x200ef4(0x20e)]});return;}if(_0x21e8f1[_0x200ef4(0x24e)]===_0x200ef4(0x1de)){const _0x2c5a50=await _0xc6d363[_0x200ef4(0x212)]();assertRecoverUnitsRequest(_0x2c5a50),await this[_0x200ef4(0x24a)][_0x200ef4(0x2a5)]({'unitIDs':_0x2c5a50[_0x200ef4(0x217)]},_0x5c069c),(0x0,protocol_http_js_1['writeProtocolJson'])(_0xc6d363[_0x200ef4(0x270)],0xc8,{'error':protocol_http_js_1[_0x200ef4(0x20e)]});return;}const _0x2e43a8=(0x0,protocol_http_js_1[_0x200ef4(0x29f)])(_0x21e8f1[_0x200ef4(0x254)]['type'],_0x200ef4(0x276)),_0x16aba8=_0x21e8f1[_0x200ef4(0x254)][_0x200ef4(0x209)];if(_0x21e8f1['name']===_0x200ef4(0x20f)){await this['_handleNewChanges'](_0xc6d363,_0x16aba8,_0x2e43a8);return;}switch(_0x21e8f1[_0x200ef4(0x24e)]){case _0x200ef4(0x1e6):{const _0x535400=(0x0,protocol_http_js_1['parseInteger'])(_0x21e8f1[_0x200ef4(0x254)][_0x200ef4(0x1e0)],_0x200ef4(0x1e0)),_0x7d540c=await this[_0x200ef4(0x24a)]['getUnit']({'unitID':_0x16aba8,'type':_0x2e43a8,'revision':_0x535400},_0x5c069c);(0x0,protocol_http_js_1[_0x200ef4(0x29a)])(_0xc6d363[_0x200ef4(0x270)],0xc8,{'error':protocol_http_js_1['OK_ERROR'],'snapshot':_0x7d540c[_0x200ef4(0x286)],'changesets':_0x7d540c[_0x200ef4(0x22c)]});return;}case _0x200ef4(0x240):case _0x200ef4(0x280):{const _0x20ec81=await this['_service'][_0x200ef4(0x273)]({'unitID':_0x16aba8,'type':_0x2e43a8,'blockID':_0x21e8f1[_0x200ef4(0x254)][_0x200ef4(0x201)]},_0x5c069c);if(!_0x20ec81[_0x200ef4(0x240)])throw new collaboration_service_1[(_0x200ef4(0x1f6))](_0x200ef4(0x28a),_0x200ef4(0x293));const _0x5cecc7=_0x21e8f1[_0x200ef4(0x24e)]==='deserialized-block'?{..._0x20ec81[_0x200ef4(0x240)],'data':JSON['parse'](new TextDecoder()[_0x200ef4(0x21d)](_0x20ec81[_0x200ef4(0x240)][_0x200ef4(0x24b)]))}:_0x20ec81[_0x200ef4(0x240)];(0x0,protocol_http_js_1[_0x200ef4(0x29a)])(_0xc6d363[_0x200ef4(0x270)],0xc8,{'error':protocol_http_js_1[_0x200ef4(0x20e)],'block':_0x5cecc7});return;}case _0x200ef4(0x1f2):{const _0x13cb81=(0x0,protocol_http_js_1['parseInteger'])(_0x52511f[_0x200ef4(0x28f)][_0x200ef4(0x2bb)](_0x200ef4(0x242))??'',_0x200ef4(0x242)),_0x15bf23=(0x0,protocol_http_js_1[_0x200ef4(0x29f)])(_0x52511f[_0x200ef4(0x28f)][_0x200ef4(0x2bb)]('to')??'','to'),_0x3a2a63=await this[_0x200ef4(0x24a)][_0x200ef4(0x2ba)]({'unitID':_0x16aba8,'type':_0x2e43a8,'from':_0x13cb81,'to':_0x15bf23},_0x5c069c);(0x0,protocol_http_js_1[_0x200ef4(0x29a)])(_0xc6d363[_0x200ef4(0x270)],0xc8,{'error':protocol_http_js_1[_0x200ef4(0x20e)],'changesets':_0x3a2a63[_0x200ef4(0x22c)],'latestRevision':_0x3a2a63[_0x200ef4(0x238)]});return;}case _0x200ef4(0x26a):{const _0x19a3d9=_0x52511f[_0x200ef4(0x28f)]['get'](_0x200ef4(0x272));let _0x58fdf5;try{_0x58fdf5=JSON['parse'](_0x19a3d9??'');}catch{throw new collaboration_service_1[(_0x200ef4(0x1f6))](_0x200ef4(0x1f4),_0x200ef4(0x207));}if(!Array[_0x200ef4(0x26f)](_0x58fdf5)||_0x58fdf5['some'](_0x5409be=>typeof _0x5409be!==_0x200ef4(0x210)))throw new collaboration_service_1['CollabError'](_0x200ef4(0x1f4),_0x200ef4(0x207));const _0x2d5197=await this[_0x200ef4(0x24a)][_0x200ef4(0x275)]({'unitID':_0x16aba8,'type':_0x2e43a8,'resourceIDs':_0x58fdf5},_0x5c069c);(0x0,protocol_http_js_1[_0x200ef4(0x29a)])(_0xc6d363[_0x200ef4(0x270)],0xc8,{'error':protocol_http_js_1['OK_ERROR'],'resources':_0x2d5197['resources']});return;}}}catch(_0x565063){const _0x46cdf9=_0x565063 instanceof SyntaxError?new collaboration_service_1[(_0x200ef4(0x1f6))](_0x200ef4(0x27d),_0x200ef4(0x256),{'cause':_0x565063}):_0x565063,_0xc13326=(0x0,protocol_http_js_1[_0x200ef4(0x28c)])(_0x46cdf9);(0x0,protocol_http_js_1[_0x200ef4(0x29a)])(_0xc6d363[_0x200ef4(0x270)],_0xc13326[_0x200ef4(0x278)],{'error':_0xc13326[_0x200ef4(0x1e8)]});}}async[_0x44c8b6(0x265)](_0x5bb0f2,_0x488bbb,_0x564f66){const _0x454ec9=_0x44c8b6;let _0x36db6c;try{_0x36db6c=new URL(_0x5bb0f2??'/',_0x454ec9(0x211));}catch{_0x488bbb['close'](0x3f0,'Invalid\x20WebSocket\x20URL');return;}if(_0x36db6c[_0x454ec9(0x27c)]!==this[_0x454ec9(0x27a)]){await _0x564f66();return;}this[_0x454ec9(0x23e)][_0x454ec9(0x26c)](_0x488bbb['id']);try{const _0x141f1d=_0x36db6c[_0x454ec9(0x28f)]['get']('sessionTicket')??'',_0x21d72e=await this[_0x454ec9(0x295)][_0x454ec9(0x1e7)](_0x141f1d);if(!_0x21d72e){_0x488bbb['close'](0x3f0,_0x454ec9(0x233));return;}const _0x11d2c7=(0x0,node_crypto_1[_0x454ec9(0x204)])(),_0x43bdec={'memberId':_0x11d2c7,'userId':_0x21d72e['userId'],'customData':_0x21d72e['customData']},_0x524c6e={'memberID':_0x11d2c7,'userID':_0x21d72e['userId'],'name':_0x21d72e[_0x454ec9(0x28b)]},_0x21fb1d={'connection':_0x488bbb,'session':_0x43bdec,'member':_0x524c6e};await this[_0x454ec9(0x1fa)][_0x454ec9(0x261)]('connect',_0x21fb1d,()=>undefined);const _0x328893={'connection':_0x488bbb,'session':_0x43bdec,'member':_0x524c6e,'joinedUnitIDs':new Set()};this[_0x454ec9(0x2b3)][_0x454ec9(0x22d)](_0x488bbb['id'],_0x328893),this[_0x454ec9(0x227)][_0x454ec9(0x22d)](_0x11d2c7,_0x328893);}catch(_0x5a9b8b){_0x488bbb['close'](_0x5a9b8b instanceof collaboration_service_1[_0x454ec9(0x1f6)]?0x3f0:0x3f3,_0x5a9b8b instanceof collaboration_service_1[_0x454ec9(0x1f6)]?'Connection\x20rejected':_0x454ec9(0x226));}}async[_0x44c8b6(0x27e)](_0x40ada6,_0x3d1a30){const _0x23fd32=_0x44c8b6,_0xa35cb7=this['_bindingsByConnection'][_0x23fd32(0x2bb)](_0x40ada6[_0x23fd32(0x23d)]['id']);if(!_0xa35cb7){if(!this[_0x23fd32(0x23e)][_0x23fd32(0x1ec)](_0x40ada6[_0x23fd32(0x23d)]['id'])){await _0x3d1a30();return;}_0x40ada6[_0x23fd32(0x23d)][_0x23fd32(0x237)](0x3f0,_0x23fd32(0x220));return;}if(typeof _0x40ada6[_0x23fd32(0x24b)]!==_0x23fd32(0x210)){_0x40ada6['connection']['close'](0x3eb,_0x23fd32(0x208));return;}let _0x5aaceb;try{const _0xa85000=JSON[_0x23fd32(0x203)](_0x40ada6[_0x23fd32(0x24b)]);if(!_0xa85000||typeof _0xa85000!==_0x23fd32(0x243))throw new Error('invalid');_0x5aaceb=_0xa85000;}catch{_0x40ada6['connection']['close'](0x3eb,_0x23fd32(0x296));return;}const _0x2cc749=typeof _0x5aaceb[_0x23fd32(0x2b8)]==='string'?_0x5aaceb['routeKey']:'';switch(_0x5aaceb[_0x23fd32(0x28d)]){case protocol_1[_0x23fd32(0x20b)][_0x23fd32(0x25a)]:case protocol_1[_0x23fd32(0x20b)][_0x23fd32(0x2ae)]:await _0x40ada6[_0x23fd32(0x23d)][_0x23fd32(0x25e)](JSON['stringify']((0x0,comb_protocol_js_1[_0x23fd32(0x291)])(_0x5aaceb[_0x23fd32(0x28d)],_0xa35cb7[_0x23fd32(0x239)]['memberID'],_0x2cc749)));return;case protocol_1[_0x23fd32(0x20b)][_0x23fd32(0x253)]:await this['_handleJoin'](_0xa35cb7,_0x5aaceb,_0x2cc749);return;case protocol_1[_0x23fd32(0x20b)][_0x23fd32(0x1e4)]:await this[_0x23fd32(0x1f8)](_0xa35cb7,_0x5aaceb,_0x2cc749);return;case protocol_1['CombCmd']['INGEST']:if(_0x5aaceb[_0x23fd32(0x279)]?.[_0x23fd32(0x2ab)]!==comb_protocol_js_1['CollabEvent'][_0x23fd32(0x200)]){await _0x3d1a30();return;}await this[_0x23fd32(0x250)](_0xa35cb7,_0x5aaceb,_0x40ada6['customData']);return;default:await _0x3d1a30();}}async['_handleJoin'](_0x2d0074,_0x1771f4,_0x58d956){const _0x292fe9=_0x44c8b6,_0xd6cf6=_0x1771f4[_0x292fe9(0x2a2)]?.['rooms'],_0x4c61af=_0xd6cf6?.[_0x292fe9(0x23f)]?_0xd6cf6[_0x292fe9(0x2a8)](_0x27d7c6=>_0x27d7c6[_0x292fe9(0x24f)]):_0x58d956?[_0x58d956]:[];if(_0x4c61af[_0x292fe9(0x23f)]===0x0||_0x4c61af[_0x292fe9(0x246)](_0x3814c1=>typeof _0x3814c1!==_0x292fe9(0x210)||!_0x3814c1)){await _0x2d0074[_0x292fe9(0x23d)][_0x292fe9(0x25e)](JSON[_0x292fe9(0x288)]((0x0,comb_protocol_js_1[_0x292fe9(0x1fe)])(_0x58d956,protocol_1['CmdRspCode'][_0x292fe9(0x26b)],{},_0x292fe9(0x1fc))));return;}const _0x25041a=[...new Set(_0x4c61af)],_0x30321e=_0x25041a[_0x292fe9(0x1f7)](_0x1e95d6=>!_0x2d0074[_0x292fe9(0x234)]['has'](_0x1e95d6));try{for(const _0x30d80d of _0x25041a){this[_0x292fe9(0x26d)](_0x30d80d);}for(const _0x5048ab of _0x30321e){await this['_middleware'][_0x292fe9(0x261)]('joinUnit',{'session':_0x2d0074[_0x292fe9(0x2aa)],'unitID':_0x5048ab},()=>undefined);}for(const _0x33b105 of _0x25041a){this[_0x292fe9(0x26d)](_0x33b105);}}catch(_0x568050){const _0x1f8d53=_0x568050 instanceof collaboration_service_1['CollabError']&&_0x568050[_0x292fe9(0x2a6)]===_0x292fe9(0x28a)?protocol_1[_0x292fe9(0x255)]['JOIN_ROOM_NOT_EXISTS']:_0x568050 instanceof collaboration_service_1['CollabError']&&(_0x568050[_0x292fe9(0x2a6)]===_0x292fe9(0x22b)||_0x568050[_0x292fe9(0x2a6)]===_0x292fe9(0x20d))?protocol_1[_0x292fe9(0x255)][_0x292fe9(0x1df)]:protocol_1[_0x292fe9(0x255)]['FAIL'];await _0x2d0074[_0x292fe9(0x23d)][_0x292fe9(0x25e)](JSON[_0x292fe9(0x288)]((0x0,comb_protocol_js_1[_0x292fe9(0x1fe)])(_0x58d956||_0x25041a[0x0],_0x1f8d53,{},_0x568050 instanceof collaboration_service_1[_0x292fe9(0x1f6)]?_0x568050[_0x292fe9(0x1fd)]:_0x292fe9(0x22a))));return;}for(const _0x2d6203 of _0x30321e){const _0x5293ec=this[_0x292fe9(0x2ad)][_0x292fe9(0x2bb)](_0x2d6203)??new Map();_0x5293ec[_0x292fe9(0x22d)](_0x2d0074[_0x292fe9(0x239)][_0x292fe9(0x215)],_0x2d0074),this[_0x292fe9(0x2ad)][_0x292fe9(0x22d)](_0x2d6203,_0x5293ec),_0x2d0074[_0x292fe9(0x234)]['add'](_0x2d6203);}const _0xe48e7f={};for(const _0x4cc87a of _0x25041a){_0xe48e7f[_0x4cc87a]={'roomID':_0x4cc87a,'members':[...this[_0x292fe9(0x2ad)][_0x292fe9(0x2bb)](_0x4cc87a)?.[_0x292fe9(0x1f0)]()??[]]['map'](_0x57bc1c=>(0x0,comb_protocol_js_1[_0x292fe9(0x2a0)])(_0x57bc1c[_0x292fe9(0x239)]))};}await _0x2d0074[_0x292fe9(0x23d)][_0x292fe9(0x25e)](JSON['stringify']((0x0,comb_protocol_js_1[_0x292fe9(0x1fe)])(_0x58d956||_0x25041a[0x0],protocol_1['CmdRspCode']['OK'],_0xe48e7f,'success')));for(const _0x318c08 of _0x30321e){await this[_0x292fe9(0x21c)](_0x318c08,(0x0,comb_protocol_js_1['userEnterMessage'])(_0x318c08,(0x0,comb_protocol_js_1[_0x292fe9(0x2a0)])(_0x2d0074[_0x292fe9(0x239)])),_0x2d0074[_0x292fe9(0x239)][_0x292fe9(0x215)]);}}async[_0x44c8b6(0x1f8)](_0x574ef8,_0x2ebfe9,_0x36d9e7){const _0x5e1089=_0x44c8b6,_0xc653f5=typeof _0x2ebfe9['leaveReq']?.['roomID']===_0x5e1089(0x210)?_0x2ebfe9[_0x5e1089(0x1ed)][_0x5e1089(0x24f)]:_0x36d9e7;if(!_0xc653f5)return;await this[_0x5e1089(0x216)](_0x574ef8,_0xc653f5,_0x5e1089(0x1e5));}async[_0x44c8b6(0x250)](_0x5ef1aa,_0x245244,_0x180afd){const _0xcb143e=_0x44c8b6,_0x547578=typeof _0x245244['routeKey']===_0xcb143e(0x210)?_0x245244[_0xcb143e(0x2b8)]:'',_0x1d1384=_0x245244['collaMsg']?.[_0xcb143e(0x1e2)]?.[_0xcb143e(0x283)];if(!_0x547578||!_0x5ef1aa['joinedUnitIDs']['has'](_0x547578)||typeof _0x1d1384!==_0xcb143e(0x210))return;const _0x1270e9={'unitID':_0x547578,'memberID':_0x5ef1aa[_0xcb143e(0x239)][_0xcb143e(0x215)],'selection':_0x1d1384};try{await this[_0xcb143e(0x1fa)][_0xcb143e(0x261)](_0xcb143e(0x299),{'session':_0x5ef1aa[_0xcb143e(0x2aa)],'unitID':_0x547578,'payload':_0x1270e9,'customData':_0x180afd},()=>undefined);}catch(_0xab93df){if(_0xab93df instanceof collaboration_service_1[_0xcb143e(0x1f6)])return;throw _0xab93df;}if(typeof _0x1270e9[_0xcb143e(0x283)]!==_0xcb143e(0x210))return;const _0x1784e6=[...this[_0xcb143e(0x2ad)][_0xcb143e(0x2bb)](_0x547578)?.[_0xcb143e(0x1f0)]()??[]]['filter'](_0x30926f=>_0x30926f!==_0x5ef1aa);for(const _0x199ca5 of _0x1784e6){const _0x283143={'unitID':_0x547578,'memberID':_0x5ef1aa[_0xcb143e(0x239)][_0xcb143e(0x215)],'selection':_0x1270e9[_0xcb143e(0x283)]};try{await this[_0xcb143e(0x1fa)][_0xcb143e(0x261)](_0xcb143e(0x222),{'session':_0x5ef1aa[_0xcb143e(0x2aa)],'unitID':_0x547578,'payload':_0x283143,'customData':_0x180afd,'targetMemberId':_0x199ca5[_0xcb143e(0x239)][_0xcb143e(0x215)]},()=>undefined);}catch{continue;}if(typeof _0x283143[_0xcb143e(0x283)]!==_0xcb143e(0x210))continue;await this[_0xcb143e(0x22f)](_0x199ca5[_0xcb143e(0x23d)],(0x0,comb_protocol_js_1[_0xcb143e(0x257)])(_0x547578,{'unitID':_0x547578,'memberID':_0x5ef1aa[_0xcb143e(0x239)][_0xcb143e(0x215)],'selection':_0x283143['selection']}));}}async[_0x44c8b6(0x2a7)](_0x58814a,_0x541a1f,_0x4c234c){const _0x13f261=_0x44c8b6,_0x24b640=await _0x58814a['readJson']();assertNewChangesRequest(_0x24b640);if(_0x24b640[_0x13f261(0x209)]!==_0x541a1f||_0x24b640[_0x13f261(0x276)]!==_0x4c234c||_0x24b640[_0x13f261(0x262)]?.[_0x13f261(0x209)]!==_0x541a1f||_0x24b640[_0x13f261(0x262)]['type']!==_0x4c234c)throw new collaboration_service_1[(_0x13f261(0x1f6))](_0x13f261(0x1f4),_0x13f261(0x232));const _0x272f94=this['_bindingsByMember'][_0x13f261(0x2bb)](_0x24b640[_0x13f261(0x215)]);if(!_0x272f94||_0x272f94[_0x13f261(0x2aa)]['userId']!==_0x58814a[_0x13f261(0x28b)])throw new collaboration_service_1[(_0x13f261(0x1f6))](_0x13f261(0x22b),'memberID\x20does\x20not\x20belong\x20to\x20the\x20authenticated\x20user');if(!_0x272f94[_0x13f261(0x234)][_0x13f261(0x1ec)](_0x541a1f))throw new collaboration_service_1['CollabError'](_0x13f261(0x22b),'Session\x20has\x20not\x20joined\x20this\x20unit');const _0x4cf386=await this[_0x13f261(0x24a)][_0x13f261(0x2b4)]({'changeset':_0x24b640['changeset']},{'session':_0x272f94['session'],'customData':_0x58814a[_0x13f261(0x224)]});if(_0x4cf386['status']===_0x13f261(0x23b))await this[_0x13f261(0x22f)](_0x272f94[_0x13f261(0x23d)],(0x0,comb_protocol_js_1['changesetMessage'])(_0x541a1f,comb_protocol_js_1[_0x13f261(0x25b)][_0x13f261(0x236)],_0x4cf386['changeset']));else{if(_0x4cf386['status']===_0x13f261(0x258)){const _0x443fe3=_0x4cf386[_0x13f261(0x1e8)][_0x13f261(0x2a6)]==='PERMISSION_DENIED'||_0x4cf386[_0x13f261(0x1e8)][_0x13f261(0x2a6)]===_0x13f261(0x20d)?comb_protocol_js_1[_0x13f261(0x25b)]['PERMISSION_REJ']:comb_protocol_js_1[_0x13f261(0x25b)]['CHANGESET_REJ'];await this[_0x13f261(0x22f)](_0x272f94[_0x13f261(0x23d)],(0x0,comb_protocol_js_1['changesetMessage'])(_0x541a1f,_0x443fe3,this[_0x13f261(0x218)](_0x24b640[_0x13f261(0x262)],_0x272f94)));}else _0x4cf386['status']===_0x13f261(0x244)&&await this[_0x13f261(0x22f)](_0x272f94[_0x13f261(0x23d)],(0x0,comb_protocol_js_1['changesetMessage'])(_0x541a1f,comb_protocol_js_1[_0x13f261(0x25b)][_0x13f261(0x1ea)],this[_0x13f261(0x218)](_0x24b640[_0x13f261(0x262)],_0x272f94)));}(0x0,protocol_http_js_1[_0x13f261(0x29a)])(_0x58814a[_0x13f261(0x270)],0xc8,{'error':protocol_http_js_1[_0x13f261(0x20e)]});}[_0x44c8b6(0x218)](_0x4cfab9,_0x49a1b3){const _0x36d0ae=_0x44c8b6;return{..._0x4cfab9,'userID':_0x49a1b3[_0x36d0ae(0x2aa)]['userId'],'memberID':_0x49a1b3[_0x36d0ae(0x2aa)][_0x36d0ae(0x1f3)]};}[_0x44c8b6(0x1ee)](_0x286314,_0x1a6fcf){const _0x407e15=_0x44c8b6;if(this[_0x407e15(0x284)])return;const _0xef78bd=_0x286314[_0x407e15(0x209)],_0x230542=[...this['_rooms'][_0x407e15(0x2bb)](_0xef78bd)?.['keys']()??[]];this[_0x407e15(0x219)](_0xef78bd,async()=>{const _0x4fd197=_0x407e15;for(const _0x216034 of _0x230542){const _0x5ea7b0=this[_0x4fd197(0x227)][_0x4fd197(0x2bb)](_0x216034);if(!_0x5ea7b0?.['joinedUnitIDs'][_0x4fd197(0x1ec)](_0xef78bd))continue;const _0x1ae285=_0x216034===_0x1a6fcf?comb_protocol_js_1[_0x4fd197(0x25b)]['CHANGESET_ACK']:comb_protocol_js_1[_0x4fd197(0x25b)]['NEW_CHANGESETS'];await this[_0x4fd197(0x22f)](_0x5ea7b0[_0x4fd197(0x23d)],(0x0,comb_protocol_js_1[_0x4fd197(0x231)])(_0xef78bd,_0x1ae285,_0x286314));}});}[_0x44c8b6(0x230)](_0x285369){const _0x3bb101=_0x44c8b6,_0x28a065=this[_0x3bb101(0x2ad)]['get'](_0x285369);if(!_0x28a065)return;this['_rooms'][_0x3bb101(0x235)](_0x285369);for(const _0x49582c of _0x28a065[_0x3bb101(0x1f0)]()){_0x49582c['joinedUnitIDs'][_0x3bb101(0x235)](_0x285369);}}['_enqueueUnitOutbound'](_0x1f7f79,_0x3b1127){const _0x5de981=_0x44c8b6,_0x3c4c35=this[_0x5de981(0x247)]['get'](_0x1f7f79)??Promise[_0x5de981(0x24d)](),_0x51e93c=_0x3c4c35['catch'](()=>undefined)[_0x5de981(0x1ff)](_0x3b1127);return this[_0x5de981(0x247)][_0x5de981(0x22d)](_0x1f7f79,_0x51e93c),void _0x51e93c[_0x5de981(0x245)](()=>{const _0x29a2b3=_0x5de981;this[_0x29a2b3(0x247)][_0x29a2b3(0x2bb)](_0x1f7f79)===_0x51e93c&&this['_outboundQueues'][_0x29a2b3(0x235)](_0x1f7f79);}),_0x51e93c;}async[_0x44c8b6(0x277)](_0x43ed81,_0x5b4407){const _0x79aa41=_0x44c8b6,_0x21b225=this[_0x79aa41(0x2b3)][_0x79aa41(0x2bb)](_0x43ed81['id']),_0x576d19=this[_0x79aa41(0x23e)]['delete'](_0x43ed81['id']);if(!_0x21b225)return _0x576d19;return await this[_0x79aa41(0x268)](_0x21b225,_0x5b4407),!![];}async['_disconnectBinding'](_0x9f20,_0x35fa99){const _0x312ee8=_0x44c8b6;this['_bindingsByConnection']['delete'](_0x9f20[_0x312ee8(0x23d)]['id']),this[_0x312ee8(0x227)][_0x312ee8(0x235)](_0x9f20[_0x312ee8(0x239)]['memberID']);const _0x2a2e2a=[..._0x9f20[_0x312ee8(0x234)]];for(const _0x280b6a of _0x2a2e2a){await this[_0x312ee8(0x216)](_0x9f20,_0x280b6a,_0x35fa99);}}async[_0x44c8b6(0x216)](_0x191d16,_0x648c90,_0x455544){const _0x20b619=_0x44c8b6;if(!_0x191d16[_0x20b619(0x234)][_0x20b619(0x235)](_0x648c90))return![];const _0x1365a4=this[_0x20b619(0x2ad)][_0x20b619(0x2bb)](_0x648c90);_0x1365a4?.[_0x20b619(0x235)](_0x191d16[_0x20b619(0x239)]['memberID']);if(_0x1365a4?.[_0x20b619(0x298)]===0x0)this[_0x20b619(0x2ad)][_0x20b619(0x235)](_0x648c90);return await this[_0x20b619(0x21c)](_0x648c90,(0x0,comb_protocol_js_1[_0x20b619(0x285)])(_0x648c90,{'memberID':_0x191d16[_0x20b619(0x239)][_0x20b619(0x215)],'name':_0x191d16[_0x20b619(0x239)][_0x20b619(0x24e)]}),_0x191d16['member'][_0x20b619(0x215)]),await this[_0x20b619(0x228)]('memberLeftUnit',{'session':_0x191d16[_0x20b619(0x2aa)],'unitID':_0x648c90,'reason':_0x455544}),!![];}async[_0x44c8b6(0x21c)](_0x62f0be,_0x348b35,_0x27437c){const _0x4e519c=_0x44c8b6,_0x54cf74=[...this[_0x4e519c(0x2ad)][_0x4e519c(0x2bb)](_0x62f0be)?.[_0x4e519c(0x1f0)]()??[]];await Promise[_0x4e519c(0x24c)](_0x54cf74[_0x4e519c(0x1f7)](_0x3c3ccd=>_0x3c3ccd[_0x4e519c(0x239)]['memberID']!==_0x27437c)[_0x4e519c(0x2a8)](_0x37516f=>this[_0x4e519c(0x22f)](_0x37516f[_0x4e519c(0x23d)],_0x348b35)));}async[_0x44c8b6(0x22f)](_0x35c9e0,_0x5bb8fd){const _0x4b78ef=_0x44c8b6;try{await _0x35c9e0[_0x4b78ef(0x25e)](JSON[_0x4b78ef(0x288)](_0x5bb8fd));}catch{}}async[_0x44c8b6(0x228)](_0x4f65ed,_0x588a61){const _0x5f3221=_0x44c8b6,_0x53c466=[...this[_0x5f3221(0x2a4)]['get'](_0x4f65ed)??[]];for(const _0x2858bb of _0x53c466){try{await _0x2858bb(_0x588a61);}catch{}}}['_assertRunning'](){const _0x37f856=_0x44c8b6;if(this[_0x37f856(0x284)])throw new Error('UniverCollabEndpoint\x20is\x20disposed');}['_assertJoinable'](_0x5ad0dd){const _0xd4e1e0=_0x44c8b6;if(this['_deletedUnitIDs'][_0xd4e1e0(0x1ec)](_0x5ad0dd))throw new collaboration_service_1[(_0xd4e1e0(0x1f6))](_0xd4e1e0(0x28a),_0xd4e1e0(0x2bc));}}exports[_0x44c8b6(0x23c)]=UniverCollabEndpoint;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { MemorySessionTicketStore, UniverCollabEndpoint, } from "./univer-collab-endpoint.js";
|
|
2
|
+
export type { BaseEndpointMiddlewareContext, ConnectEndpointMiddlewareContext, EndpointEventMap, EndpointMember, EndpointMiddleware, EndpointMiddlewareAction, EndpointMiddlewareMap, EndpointMiddlewareNext, EndpointSessionBinding, ISessionTicketStore, ITrustedUnitRoomHost, JoinUnitEndpointMiddlewareContext, MemberLeftUnitEvent, ReceivePresenceEndpointMiddlewareContext, SendPresenceEndpointMiddlewareContext, SessionTicketRecord, UniverCollabEndpointOptions, } from "./univer-collab-endpoint.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['UniverCollabEndpoint']=exports['MemorySessionTicketStore']=void 0x0;var univer_collab_endpoint_js_1=require('./univer-collab-endpoint.js');Object['defineProperty'](exports,'MemorySessionTicketStore',{'enumerable':!![],'get':function(){return univer_collab_endpoint_js_1['MemorySessionTicketStore'];}}),Object['defineProperty'](exports,'UniverCollabEndpoint',{'enumerable':!![],'get':function(){return univer_collab_endpoint_js_1['UniverCollabEndpoint'];}});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Disposable } from "@univerjs-pro/collaboration-service";
|
|
2
|
+
import type { EndpointMiddleware } from "./univer-collab-endpoint.js";
|
|
3
|
+
export declare class EndpointMiddlewareRegistry<TAction extends PropertyKey> {
|
|
4
|
+
private readonly _middlewares;
|
|
5
|
+
use<TContext>(action: TAction, middleware: EndpointMiddleware<TContext>): Disposable;
|
|
6
|
+
run<TContext>(action: TAction, context: TContext, terminal: () => void | Promise<void>): Promise<void>;
|
|
7
|
+
clear(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';const _0x4cb3e3=_0x4911;(function(_0x52f839,_0xcf8bf8){const _0x41ba9a=_0x4911,_0x2e36e0=_0x52f839();while(!![]){try{const _0x54a60e=parseInt(_0x41ba9a(0x82))/0x1*(parseInt(_0x41ba9a(0x80))/0x2)+parseInt(_0x41ba9a(0x7d))/0x3+-parseInt(_0x41ba9a(0x7a))/0x4*(parseInt(_0x41ba9a(0x7e))/0x5)+parseInt(_0x41ba9a(0x88))/0x6+-parseInt(_0x41ba9a(0x79))/0x7*(-parseInt(_0x41ba9a(0x8a))/0x8)+parseInt(_0x41ba9a(0x85))/0x9+parseInt(_0x41ba9a(0x84))/0xa*(-parseInt(_0x41ba9a(0x81))/0xb);if(_0x54a60e===_0xcf8bf8)break;else _0x2e36e0['push'](_0x2e36e0['shift']());}catch(_0x2a8fe4){_0x2e36e0['push'](_0x2e36e0['shift']());}}}(_0x2193,0xaa089));Object[_0x4cb3e3(0x76)](exports,_0x4cb3e3(0x83),{'value':!![]}),exports[_0x4cb3e3(0x78)]=void 0x0;function _0x4911(_0xbc056e,_0x5c06e7){_0xbc056e=_0xbc056e-0x76;const _0x2193b7=_0x2193();let _0x491142=_0x2193b7[_0xbc056e];return _0x491142;}class EndpointMiddlewareRegistry{[_0x4cb3e3(0x7f)]=new Map();[_0x4cb3e3(0x89)](_0x12dcfb,_0x2fd772){const _0x506641=_0x4cb3e3,_0x190316=this[_0x506641(0x7f)][_0x506641(0x8b)](_0x12dcfb)??[],_0x329894=_0x2fd772;_0x190316[_0x506641(0x86)](_0x329894),this[_0x506641(0x7f)]['set'](_0x12dcfb,_0x190316);let _0x3b1839=![];return{'dispose':()=>{const _0x565104=_0x506641;if(_0x3b1839)return;_0x3b1839=!![];const _0x160333=_0x190316[_0x565104(0x8c)](_0x329894);if(_0x160333>=0x0)_0x190316['splice'](_0x160333,0x1);}};}async[_0x4cb3e3(0x87)](_0x24d6a4,_0xee449f,_0xdf3d31){const _0x22facc=_0x4cb3e3,_0x944e81=[...this[_0x22facc(0x7f)][_0x22facc(0x8b)](_0x24d6a4)??[]],_0x540483=async _0x34879c=>{const _0x328e97=_0x22facc,_0x47dfcb=_0x944e81[_0x34879c];if(!_0x47dfcb){await _0xdf3d31();return;}let _0x3fb038=![],_0xaa1613;const _0x1f4d83=()=>{const _0x3e4989=_0x4911;if(_0x3fb038)throw new Error(_0x3e4989(0x7b)+String(_0x24d6a4)+_0x3e4989(0x7c));return _0x3fb038=!![],_0xaa1613=_0x540483(_0x34879c+0x1),_0xaa1613;};try{await _0x47dfcb(_0xee449f,_0x1f4d83);}catch(_0x487ae2){if(_0xaa1613)try{await _0xaa1613;}catch{}throw _0x487ae2;}if(!_0x3fb038)throw new Error(_0x328e97(0x7b)+String(_0x24d6a4)+'\x20completed\x20without\x20calling\x20next()');await _0xaa1613;};await _0x540483(0x0);}[_0x4cb3e3(0x77)](){const _0x3af01c=_0x4cb3e3;this[_0x3af01c(0x7f)][_0x3af01c(0x77)]();}}exports['EndpointMiddlewareRegistry']=EndpointMiddlewareRegistry;function _0x2193(){const _0x50d589=['_middlewares','950HmClNp','5405939dbYvRA','2251KojuIg','__esModule','50VkCsmD','3402603mhRBXX','push','run','2831520Kvngqg','use','16cXCcXV','get','indexOf','defineProperty','clear','EndpointMiddlewareRegistry','3533432NUucry','3484976UFXpYL','Endpoint\x20middleware\x20for\x20','\x20called\x20next()\x20more\x20than\x20once','3288546CllpVR','5CIbYte'];_0x2193=function(){return _0x50d589;};return _0x2193();}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IError } from "@univerjs/protocol";
|
|
2
|
+
import type { ServerResponse } from "node:http";
|
|
3
|
+
export interface ProtocolFailure {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly error: IError;
|
|
6
|
+
}
|
|
7
|
+
export declare const OK_ERROR: IError;
|
|
8
|
+
export declare function parseInteger(value: string, name: string): number;
|
|
9
|
+
export declare function protocolFailure(error: unknown): ProtocolFailure;
|
|
10
|
+
export declare function writeProtocolJson(response: ServerResponse, status: number, body: unknown): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';const _0x2fe6f9=_0x27e3;(function(_0x485b30,_0x4ad833){const _0x59cdc6=_0x27e3,_0x1bc2b0=_0x485b30();while(!![]){try{const _0xa8592d=-parseInt(_0x59cdc6(0x179))/0x1+-parseInt(_0x59cdc6(0x193))/0x2*(parseInt(_0x59cdc6(0x172))/0x3)+parseInt(_0x59cdc6(0x177))/0x4+-parseInt(_0x59cdc6(0x18f))/0x5*(-parseInt(_0x59cdc6(0x187))/0x6)+parseInt(_0x59cdc6(0x181))/0x7*(-parseInt(_0x59cdc6(0x183))/0x8)+-parseInt(_0x59cdc6(0x188))/0x9*(-parseInt(_0x59cdc6(0x17c))/0xa)+-parseInt(_0x59cdc6(0x178))/0xb*(parseInt(_0x59cdc6(0x190))/0xc);if(_0xa8592d===_0x4ad833)break;else _0x1bc2b0['push'](_0x1bc2b0['shift']());}catch(_0x24e890){_0x1bc2b0['push'](_0x1bc2b0['shift']());}}}(_0x3749,0x38872));function _0x3749(){const _0xd6a705=['REQUEST_ABORTED','Transport\x20unavailable','2187930nspYqa','443367oJRBbP','NOT_FOUND','\x20must\x20be\x20an\x20integer','base64','isSafeInteger','writeProtocolJson','toString','5HtAYEn','159492rDWaov','message','end','2FjCHsH','code','ErrorCode','NodeTransportError','Internal\x20server\x20error','from','defineProperty','INTERNAL_ERROR','PERMISSION_DENIED','writableEnded','1253199rpXgsB','APPLY_REJECT','INVALID_ARGUMENT','REQUEST_BODY_TOO_LARGE','INVALID_JSON','1705756KdKUlQ','22nmUqIb','173005WrMvCe','CollabError','OK_ERROR','70ypTEKR','content-type','test','status','application/json;\x20charset=utf-8','287077UWbNHP','protocolFailure','56NEQkEO','parseInteger'];_0x3749=function(){return _0xd6a705;};return _0x3749();}Object[_0x2fe6f9(0x16e)](exports,'__esModule',{'value':!![]}),exports[_0x2fe6f9(0x17b)]=void 0x0,exports[_0x2fe6f9(0x184)]=parseInteger,exports[_0x2fe6f9(0x182)]=protocolFailure,exports[_0x2fe6f9(0x18d)]=writeProtocolJson;const protocol_1=require('@univerjs/protocol'),collaboration_service_1=require('@univerjs-pro/collaboration-service'),collaboration_transport_node_1=require('@univerjs-pro/collaboration-transport-node');exports[_0x2fe6f9(0x17b)]={'code':protocol_1[_0x2fe6f9(0x16a)]['OK'],'message':''};function _0x27e3(_0x41d319,_0x537c22){_0x41d319=_0x41d319-0x169;const _0x374916=_0x3749();let _0x27e3f4=_0x374916[_0x41d319];return _0x27e3f4;}function parseInteger(_0x217102,_0x3b79a6){const _0x15bc3=_0x2fe6f9;if(!/^-?\d+$/[_0x15bc3(0x17e)](_0x217102))throw new collaboration_service_1[(_0x15bc3(0x17a))]('INVALID_REQUEST',_0x3b79a6+_0x15bc3(0x18a));const _0x52dad0=Number(_0x217102);if(!Number[_0x15bc3(0x18c)](_0x52dad0))throw new collaboration_service_1['CollabError']('INVALID_REQUEST',_0x3b79a6+'\x20is\x20outside\x20the\x20safe\x20integer\x20range');return _0x52dad0;}function protocolFailure(_0x43b2fa){const _0x3b7df3=_0x2fe6f9;if(_0x43b2fa instanceof collaboration_transport_node_1[_0x3b7df3(0x16b)]){if(_0x43b2fa[_0x3b7df3(0x169)]===_0x3b7df3(0x175))return{'status':0x19d,'error':{'code':protocol_1['ErrorCode']['INVALID_ARGUMENT'],'message':_0x43b2fa[_0x3b7df3(0x191)]}};if(_0x43b2fa['code']===_0x3b7df3(0x176)||_0x43b2fa['code']===_0x3b7df3(0x185))return{'status':0x190,'error':{'code':protocol_1[_0x3b7df3(0x16a)]['INVALID_ARGUMENT'],'message':_0x43b2fa[_0x3b7df3(0x191)]}};return{'status':0x1f7,'error':{'code':protocol_1[_0x3b7df3(0x16a)][_0x3b7df3(0x16f)],'message':_0x3b7df3(0x186)}};}if(!(_0x43b2fa instanceof collaboration_service_1['CollabError']))return{'status':0x1f4,'error':{'code':protocol_1['ErrorCode']['INTERNAL_ERROR'],'message':_0x3b7df3(0x16c)}};const _0x1af025={'UNAUTHENTICATED':{'status':0x191,'code':protocol_1[_0x3b7df3(0x16a)]['UNAUTHENTICATED']},'INVALID_REQUEST':{'status':0x190,'code':protocol_1[_0x3b7df3(0x16a)][_0x3b7df3(0x174)]},'UNIT_NOT_FOUND':{'status':0x194,'code':protocol_1['ErrorCode'][_0x3b7df3(0x189)]},'PERMISSION_DENIED':{'status':0x193,'code':protocol_1[_0x3b7df3(0x16a)][_0x3b7df3(0x170)]},'OT_CONFLICT':{'status':0x199,'code':protocol_1[_0x3b7df3(0x16a)][_0x3b7df3(0x173)]},'REVISION_MISMATCH':{'status':0x199,'code':protocol_1['ErrorCode']['CHANGESET_REVISION_CONFILICT']},'ADAPTER_FAILURE':{'status':0x1f7,'code':protocol_1['ErrorCode'][_0x3b7df3(0x16f)]},'INTERNAL_ERROR':{'status':0x1f4,'code':protocol_1['ErrorCode'][_0x3b7df3(0x16f)]}},_0x9d84d9=_0x1af025[_0x43b2fa['code']];return{'status':_0x9d84d9[_0x3b7df3(0x17f)],'error':{'code':_0x9d84d9[_0x3b7df3(0x169)],'message':_0x43b2fa['message']}};}function writeProtocolJson(_0xae3622,_0x216aca,_0x12a94a){const _0x57947f=_0x2fe6f9;if(_0xae3622[_0x57947f(0x171)]||_0xae3622['destroyed'])return;_0xae3622['statusCode']=_0x216aca,_0xae3622['setHeader'](_0x57947f(0x17d),_0x57947f(0x180)),_0xae3622[_0x57947f(0x192)](JSON['stringify'](_0x12a94a,(_0x3a5ade,_0x26350f)=>_0x26350f instanceof Uint8Array?Buffer[_0x57947f(0x16d)](_0x26350f)[_0x57947f(0x18e)](_0x57947f(0x18b)):_0x26350f));}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ISessionTicketStore, SessionTicketRecord } from "./univer-collab-endpoint.js";
|
|
2
|
+
export declare class MemorySessionTicketStore implements ISessionTicketStore {
|
|
3
|
+
private readonly _tickets;
|
|
4
|
+
private _disposed;
|
|
5
|
+
issue(record: SessionTicketRecord, ttlMs: number): Promise<string>;
|
|
6
|
+
consume(ticket: string): Promise<SessionTicketRecord | null>;
|
|
7
|
+
dispose(): Promise<void>;
|
|
8
|
+
private _purgeExpired;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function _0x528c(){const _0x1be8d1=['6gmOlPm','record','Session\x20ticket\x20store\x20is\x20disposed','expiresAt','_disposed','defineProperty','21742TLBcKs','730570arQfQS','552olnYHG','663112FZahcx','775MZkLpm','toString','clear','368997NaqAtw','randomBytes','_tickets','delete','dispose','139900dIpKRr','__esModule','Session\x20ticket\x20TTL\x20must\x20be\x20a\x20positive\x20safe\x20integer','consume','get','1270305jhhjcL','now','MemorySessionTicketStore','_purgeExpired','issue','isSafeInteger','set','has','base64url','122VluykX'];_0x528c=function(){return _0x1be8d1;};return _0x528c();}function _0x522b(_0x205326,_0x50bd64){_0x205326=_0x205326-0x153;const _0x528ce3=_0x528c();let _0x522b3e=_0x528ce3[_0x205326];return _0x522b3e;}const _0x25bc60=_0x522b;(function(_0x1236f0,_0x397dcf){const _0xd3ee36=_0x522b,_0x50e61c=_0x1236f0();while(!![]){try{const _0x17bf2f=parseInt(_0xd3ee36(0x166))/0x1*(parseInt(_0xd3ee36(0x15b))/0x2)+-parseInt(_0xd3ee36(0x169))/0x3+-parseInt(_0xd3ee36(0x165))/0x4+-parseInt(_0xd3ee36(0x16e))/0x5*(parseInt(_0xd3ee36(0x15c))/0x6)+-parseInt(_0xd3ee36(0x162))/0x7*(-parseInt(_0xd3ee36(0x164))/0x8)+parseInt(_0xd3ee36(0x173))/0x9+parseInt(_0xd3ee36(0x163))/0xa;if(_0x17bf2f===_0x397dcf)break;else _0x50e61c['push'](_0x50e61c['shift']());}catch(_0x50daa8){_0x50e61c['push'](_0x50e61c['shift']());}}}(_0x528c,0x26d3a));Object[_0x25bc60(0x161)](exports,_0x25bc60(0x16f),{'value':!![]}),exports[_0x25bc60(0x154)]=void 0x0;const node_crypto_1=require('node:crypto');class MemorySessionTicketStore{['_tickets']=new Map();[_0x25bc60(0x160)]=![];async[_0x25bc60(0x156)](_0x45e866,_0x11600b){const _0x2b9d54=_0x25bc60;if(this[_0x2b9d54(0x160)])throw new Error(_0x2b9d54(0x15e));if(!Number[_0x2b9d54(0x157)](_0x11600b)||_0x11600b<=0x0)throw new TypeError(_0x2b9d54(0x170));this['_purgeExpired']();let _0x21e32d;do{_0x21e32d=(0x0,node_crypto_1[_0x2b9d54(0x16a)])(0x20)[_0x2b9d54(0x167)](_0x2b9d54(0x15a));}while(this[_0x2b9d54(0x16b)][_0x2b9d54(0x159)](_0x21e32d));return this[_0x2b9d54(0x16b)][_0x2b9d54(0x158)](_0x21e32d,{'record':_0x45e866,'expiresAt':Date[_0x2b9d54(0x153)]()+_0x11600b}),_0x21e32d;}async[_0x25bc60(0x171)](_0x477e95){const _0x3b2dd9=_0x25bc60;if(this[_0x3b2dd9(0x160)]||!_0x477e95)return null;const _0x4fc692=this['_tickets'][_0x3b2dd9(0x172)](_0x477e95);if(!_0x4fc692)return null;this[_0x3b2dd9(0x16b)][_0x3b2dd9(0x16c)](_0x477e95);if(_0x4fc692[_0x3b2dd9(0x15f)]<=Date[_0x3b2dd9(0x153)]())return null;return _0x4fc692[_0x3b2dd9(0x15d)];}async[_0x25bc60(0x16d)](){const _0x57bd59=_0x25bc60;if(this[_0x57bd59(0x160)])return;this[_0x57bd59(0x160)]=!![],this['_tickets'][_0x57bd59(0x168)]();}[_0x25bc60(0x155)](){const _0x359e27=_0x25bc60,_0x4dc3ca=Date[_0x359e27(0x153)]();for(const [_0x2d0a3d,_0x153724]of this[_0x359e27(0x16b)]){if(_0x153724['expiresAt']<=_0x4dc3ca)this[_0x359e27(0x16b)][_0x359e27(0x16c)](_0x2d0a3d);}}}exports['MemorySessionTicketStore']=MemorySessionTicketStore;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { CollabSession, CustomData } from "@univerjs-pro/collaboration-service";
|
|
2
|
+
import type { NodeTransportConnection } from "@univerjs-pro/collaboration-transport-node";
|
|
3
|
+
export interface SessionTicketRecord {
|
|
4
|
+
readonly userId: string;
|
|
5
|
+
readonly customData: CustomData;
|
|
6
|
+
}
|
|
7
|
+
export interface ISessionTicketStore {
|
|
8
|
+
issue(record: SessionTicketRecord, ttlMs: number): Promise<string>;
|
|
9
|
+
consume(ticket: string): Promise<SessionTicketRecord | null>;
|
|
10
|
+
dispose?(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export interface EndpointSessionBinding {
|
|
13
|
+
readonly connection: NodeTransportConnection;
|
|
14
|
+
readonly session: CollabSession;
|
|
15
|
+
readonly member: EndpointMember;
|
|
16
|
+
readonly joinedUnitIDs: ReadonlySet<string>;
|
|
17
|
+
}
|
|
18
|
+
export interface ITrustedUnitRoomHost {
|
|
19
|
+
findJoinedSession(input: {
|
|
20
|
+
readonly unitID: string;
|
|
21
|
+
readonly memberID: string;
|
|
22
|
+
readonly authenticatedUserID: string;
|
|
23
|
+
}): CollabSession | null;
|
|
24
|
+
findJoinedSessionByUser(input: {
|
|
25
|
+
readonly unitID: string;
|
|
26
|
+
readonly authenticatedUserID: string;
|
|
27
|
+
}): CollabSession | null;
|
|
28
|
+
publishTrustedUnitEvent(input: {
|
|
29
|
+
readonly unitID: string;
|
|
30
|
+
readonly origin: CollabSession;
|
|
31
|
+
readonly eventID: string;
|
|
32
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export interface EndpointMember {
|
|
36
|
+
readonly memberID: string;
|
|
37
|
+
readonly userID: string;
|
|
38
|
+
name: string;
|
|
39
|
+
avatar?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface BaseEndpointMiddlewareContext {
|
|
42
|
+
readonly session: CollabSession;
|
|
43
|
+
}
|
|
44
|
+
export interface ConnectEndpointMiddlewareContext extends BaseEndpointMiddlewareContext {
|
|
45
|
+
readonly connection: NodeTransportConnection;
|
|
46
|
+
readonly member: EndpointMember;
|
|
47
|
+
}
|
|
48
|
+
export interface JoinUnitEndpointMiddlewareContext extends BaseEndpointMiddlewareContext {
|
|
49
|
+
readonly unitID: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ReceivePresenceEndpointMiddlewareContext extends BaseEndpointMiddlewareContext {
|
|
52
|
+
readonly unitID: string;
|
|
53
|
+
readonly payload: unknown;
|
|
54
|
+
readonly customData: CustomData;
|
|
55
|
+
}
|
|
56
|
+
export interface SendPresenceEndpointMiddlewareContext extends ReceivePresenceEndpointMiddlewareContext {
|
|
57
|
+
readonly targetMemberId: string;
|
|
58
|
+
}
|
|
59
|
+
export type EndpointMiddlewareAction = "connect" | "joinUnit" | "receivePresence" | "sendPresence";
|
|
60
|
+
export type EndpointMiddlewareNext = () => Promise<void>;
|
|
61
|
+
export type EndpointMiddleware<TContext> = (ctx: TContext, next: EndpointMiddlewareNext) => void | Promise<void>;
|
|
62
|
+
export interface EndpointMiddlewareMap {
|
|
63
|
+
readonly connect: EndpointMiddleware<ConnectEndpointMiddlewareContext>;
|
|
64
|
+
readonly joinUnit: EndpointMiddleware<JoinUnitEndpointMiddlewareContext>;
|
|
65
|
+
readonly receivePresence: EndpointMiddleware<ReceivePresenceEndpointMiddlewareContext>;
|
|
66
|
+
readonly sendPresence: EndpointMiddleware<SendPresenceEndpointMiddlewareContext>;
|
|
67
|
+
}
|
|
68
|
+
export interface MemberLeftUnitEvent {
|
|
69
|
+
readonly session: CollabSession;
|
|
70
|
+
readonly unitID: string;
|
|
71
|
+
readonly reason: "explicit" | "disconnect" | "endpoint-dispose";
|
|
72
|
+
}
|
|
73
|
+
export interface EndpointEventMap {
|
|
74
|
+
readonly memberLeftUnit: MemberLeftUnitEvent;
|
|
75
|
+
}
|
|
76
|
+
export interface UniverCollabEndpointOptions {
|
|
77
|
+
readonly ticketStore?: ISessionTicketStore;
|
|
78
|
+
readonly sessionTicketTtlMs?: number;
|
|
79
|
+
readonly protocolBasePath?: string;
|
|
80
|
+
}
|
|
81
|
+
export { UniverCollabEndpoint } from "./endpoint.js";
|
|
82
|
+
export { MemorySessionTicketStore } from "./ticket-store.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function _0x4c22(_0x5b0d50,_0x13adbd){_0x5b0d50=_0x5b0d50-0x191;var _0x3b0e82=_0x3b0e();var _0x4c2229=_0x3b0e82[_0x5b0d50];return _0x4c2229;}var _0x2717b0=_0x4c22;(function(_0x26db76,_0x368899){var _0x1a9fa2=_0x4c22,_0x5785ae=_0x26db76();while(!![]){try{var _0x10e23d=parseInt(_0x1a9fa2(0x199))/0x1+-parseInt(_0x1a9fa2(0x197))/0x2+parseInt(_0x1a9fa2(0x196))/0x3*(-parseInt(_0x1a9fa2(0x192))/0x4)+parseInt(_0x1a9fa2(0x198))/0x5+-parseInt(_0x1a9fa2(0x19e))/0x6*(parseInt(_0x1a9fa2(0x19c))/0x7)+-parseInt(_0x1a9fa2(0x193))/0x8*(parseInt(_0x1a9fa2(0x191))/0x9)+parseInt(_0x1a9fa2(0x19b))/0xa;if(_0x10e23d===_0x368899)break;else _0x5785ae['push'](_0x5785ae['shift']());}catch(_0x135790){_0x5785ae['push'](_0x5785ae['shift']());}}}(_0x3b0e,0x72976));Object['defineProperty'](exports,_0x2717b0(0x19d),{'value':!![]}),exports['MemorySessionTicketStore']=exports[_0x2717b0(0x195)]=void 0x0;var endpoint_js_1=require('./endpoint.js');Object[_0x2717b0(0x19a)](exports,_0x2717b0(0x195),{'enumerable':!![],'get':function(){var _0x1b0e04=_0x2717b0;return endpoint_js_1[_0x1b0e04(0x195)];}});function _0x3b0e(){var _0x53d6f8=['435724UyNKFS','360ArzxjC','MemorySessionTicketStore','UniverCollabEndpoint','21RuFhUn','234244JAoDso','4285905zRfqLS','194260oZcUkO','defineProperty','14665540WRHcjX','35pGXPVs','__esModule','1065774LCfZUt','56169fodYcL'];_0x3b0e=function(){return _0x53d6f8;};return _0x3b0e();}var ticket_store_js_1=require('./ticket-store.js');Object[_0x2717b0(0x19a)](exports,_0x2717b0(0x194),{'enumerable':!![],'get':function(){var _0x431afa=_0x2717b0;return ticket_store_js_1[_0x431afa(0x194)];}});
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@univerjs-pro/collaboration-endpoint",
|
|
3
|
+
"type": "commonjs",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"version": "1.0.0-insiders.20260727-46ed76c",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@univerjs-pro/collaboration-service": "1.0.0-insiders.20260727-46ed76c",
|
|
19
|
+
"@univerjs-pro/collaboration-transport-node": "1.0.0-insiders.20260727-46ed76c",
|
|
20
|
+
"@univerjs/protocol": "1.0.0-insiders.20260727-46ed76c"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
}
|
|
25
|
+
}
|