diff --git a/Common/sources/commondefines.js b/Common/sources/commondefines.js index 97e286fc..588734e6 100644 --- a/Common/sources/commondefines.js +++ b/Common/sources/commondefines.js @@ -50,7 +50,6 @@ function InputCommand(data, copyExplicit) { this['username'] = data['username']; this['tokenSession'] = data['tokenSession']; this['tokenDownload'] = data['tokenDownload']; - this['tokenHistory'] = data['tokenHistory']; this['data'] = data['data']; this['editorid'] = data['editorid']; this['format'] = data['format']; @@ -84,7 +83,6 @@ function InputCommand(data, copyExplicit) { this['savekey'] = data['savekey']; this['userconnectionid'] = data['userconnectionid']; this['responsekey'] = data['responsekey']; - this['docconnectionid'] = data['docconnectionid']; this['jsonparams'] = data['jsonparams']; this['lcid'] = data['lcid']; this['useractionid'] = data['useractionid']; @@ -101,7 +99,6 @@ function InputCommand(data, copyExplicit) { this['savepassword'] = data['savepassword']; this['withoutPassword'] = data['withoutPassword']; this['outputurls'] = data['outputurls']; - this['closeonerror'] = data['closeonerror']; this['serverVersion'] = data['serverVersion']; this['rediskey'] = data['rediskey']; this['nobase64'] = data['nobase64']; @@ -127,7 +124,6 @@ function InputCommand(data, copyExplicit) { this['username'] = undefined; this['tokenSession'] = undefined;//string validate this['tokenDownload'] = undefined;//string validate - this['tokenHistory'] = undefined;//string validate this['data'] = undefined;//string //to open this['editorid'] = undefined;//int @@ -152,7 +148,6 @@ function InputCommand(data, copyExplicit) { this['savekey'] = undefined;//int document id to save this['userconnectionid'] = undefined;//string internal this['responsekey'] = undefined; - this['docconnectionid'] = undefined;//string internal this['jsonparams'] = undefined;//string this['lcid'] = undefined; this['useractionid'] = undefined; @@ -165,7 +160,6 @@ function InputCommand(data, copyExplicit) { this['savepassword'] = undefined; this['withoutPassword'] = undefined; this['outputurls'] = undefined; - this['closeonerror'] = undefined; this['serverVersion'] = undefined; this['rediskey'] = undefined; this['nobase64'] = true; @@ -218,9 +212,6 @@ InputCommand.prototype = { getTokenDownload: function() { return this['tokenDownload']; }, - getTokenHistory: function() { - return this['tokenHistory']; - }, getData: function() { return this['data']; }, @@ -359,12 +350,6 @@ InputCommand.prototype = { setResponseKey: function(data) { this['responsekey'] = data; }, - getDocConnectionId: function() { - return this['docconnectionid']; - }, - setDocConnectionId: function(data) { - this['docconnectionid'] = data; - }, getJsonParams: function() { return this['jsonparams']; }, @@ -447,12 +432,6 @@ InputCommand.prototype = { getOutputUrls: function() { return this['outputurls']; }, - getCloseOnError: function() { - return this['closeonerror']; - }, - setCloseOnError: function(data) { - this['closeonerror'] = data; - }, getServerVersion: function() { return this['serverVersion']; }, diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index d47b5ccc..68b02296 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -1734,11 +1734,6 @@ exports.install = function(server, callbackFunction) { case 'close': yield* closeDocument(ctx, conn); break; - case 'versionHistory' : { - let cmd = new commonDefines.InputCommand(data.cmd); - yield* versionHistory(ctx, conn, cmd); - break; - } case 'openDocument' : { var cmd = new commonDefines.InputCommand(data.message); cmd.fillFromConnection(conn); @@ -1949,42 +1944,6 @@ exports.install = function(server, callbackFunction) { } } - function* versionHistory(ctx, conn, cmd) { - const tenTokenEnableBrowser = ctx.getCfg('services.CoAuthoring.token.enable.browser', cfgTokenEnableBrowser); - - var docIdOld = conn.docId; - var docIdNew = cmd.getDocId(); - //check jwt - if (tenTokenEnableBrowser) { - var checkJwtRes = yield checkJwt(ctx, cmd.getTokenHistory(), commonDefines.c_oAscSecretType.Browser); - if (checkJwtRes.decoded) { - fillVersionHistoryFromJwt(ctx, checkJwtRes.decoded, cmd); - docIdNew = cmd.getDocId(); - cmd.setWithAuthorization(true); - } else { - sendData(ctx, conn, {type: "expiredToken", code: checkJwtRes.code, description: checkJwtRes.description}); - return; - } - } - if (docIdOld !== docIdNew) { - //remove presence(other data was removed before in closeDocument) - yield removePresence(ctx, conn); - var hvals = yield editorData.getPresence(ctx, docIdOld, connections); - if (hvals.length <= 0) { - yield editorData.removePresenceDocument(ctx, docIdOld); - } - - //apply new - conn.docId = docIdNew; - yield addPresence(ctx, conn, true); - if (tenTokenEnableBrowser) { - let sessionToken = yield fillJwtByConnection(ctx, conn); - sendDataRefreshToken(ctx, conn, sessionToken); - } - } - //open - yield canvasService.openDocument(ctx, conn, cmd, null); - } // Getting changes for the document (either from the cache or accessing the database, but only if there were saves) function* getDocumentChanges(ctx, docId, optStartIndex, optEndIndex) { // If during that moment, while we were waiting for a response from the database, everyone left, then nothing needs to be sent @@ -2492,22 +2451,23 @@ exports.install = function(server, callbackFunction) { } return res; } - function fillVersionHistoryFromJwt(ctx, decoded, cmd) { + function fillVersionHistoryFromJwt(ctx, decoded, data) { + let openCmd = data.openCmd; + data.mode = 'view'; + data.coEditingMode = 'strict'; + data.docid = decoded.key; + openCmd.url = decoded.url; if (decoded.changesUrl && decoded.previous) { - let versionMatch = cmd.getServerVersion() === commonDefines.buildVersion; - let openPreviousVersion = cmd.getDocId() === decoded.previous.key; + let versionMatch = openCmd.serverVersion === commonDefines.buildVersion; + let openPreviousVersion = openCmd.id === decoded.previous.key; if (versionMatch && openPreviousVersion) { - cmd.setUrl(decoded.previous.url); - cmd.setDocId(decoded.previous.key); + data.docid = decoded.previous.key; + openCmd.url = decoded.previous.url; } else { - ctx.logger.warn('fillVersionHistoryFromJwt serverVersion mismatch or mismatch between previous url and changes. serverVersion=%s docId=%s', cmd.getServerVersion(), cmd.getDocId()); - cmd.setUrl(decoded.url); - cmd.setDocId(decoded.key); + ctx.logger.warn('fillVersionHistoryFromJwt serverVersion mismatch or mismatch between previous url and changes. serverVersion=%s docId=%s', openCmd.serverVersion, openCmd.id); } - } else { - cmd.setUrl(decoded.url); - cmd.setDocId(decoded.key); } + return true; } function* auth(ctx, conn, data) { @@ -2536,6 +2496,9 @@ exports.install = function(server, callbackFunction) { } else if (decoded.editorConfig && undefined !== decoded.editorConfig.ds_sessionTimeConnect) { //reconnection fillDataFromJwtRes = fillDataFromJwt(ctx, decoded, data); + } else if (decoded.version) {//version required, but maybe add new type like jwtSession? + //version history + fillDataFromJwtRes = fillVersionHistoryFromJwt(ctx, decoded, data); } else { //opening let validationErr = validateAuthToken(data, decoded); @@ -3668,13 +3631,7 @@ exports.install = function(server, callbackFunction) { output.fromObject(data.output); var outputData = output.getData(); - var docConnectionId = cmd.getDocConnectionId(); - var docId; - if(docConnectionId){ - docId = docConnectionId; - } else { - docId = cmd.getDocId(); - } + var docId = cmd.getDocId(); if (cmd.getUserConnectionId()) { participants = getParticipantUser(docId, cmd.getUserConnectionId()); } else {