Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1db3f8cca2 |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-6",
|
"version": "13.0.0-5",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"acorn": {
|
"acorn": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-6",
|
"version": "13.0.0-5",
|
||||||
"description": "A framework for real-time p2p shared editing on any data",
|
"description": "A framework for real-time p2p shared editing on any data",
|
||||||
"main": "./y.node.js",
|
"main": "./y.node.js",
|
||||||
"browser": "./y.js",
|
"browser": "./y.js",
|
||||||
|
|||||||
@@ -141,9 +141,7 @@ export default function extendConnector (Y/* :any */) {
|
|||||||
this.log('User joined: %s', user)
|
this.log('User joined: %s', user)
|
||||||
this.connections[user] = {
|
this.connections[user] = {
|
||||||
isSynced: false,
|
isSynced: false,
|
||||||
role: role,
|
role: role
|
||||||
waitingMessages: [],
|
|
||||||
auth: null
|
|
||||||
}
|
}
|
||||||
let defer = {}
|
let defer = {}
|
||||||
defer.promise = new Promise(function (resolve) { defer.resolve = resolve })
|
defer.promise = new Promise(function (resolve) { defer.resolve = resolve })
|
||||||
@@ -269,17 +267,11 @@ export default function extendConnector (Y/* :any */) {
|
|||||||
})
|
})
|
||||||
return Promise.reject(new Error('Incompatible protocol version'))
|
return Promise.reject(new Error('Incompatible protocol version'))
|
||||||
}
|
}
|
||||||
if (message.type === 'sync step 1' && this.connections[sender] != null && this.connections[sender].auth == null) {
|
if (message.auth != null && this.connections[sender] != null) {
|
||||||
// authenticate using auth in message
|
// authenticate using auth in message
|
||||||
var auth = this.checkAuth(message.auth, this.y)
|
var auth = this.checkAuth(message.auth, this.y)
|
||||||
this.connections[sender].auth = auth
|
this.connections[sender].auth = auth
|
||||||
auth.then(auth => {
|
auth.then(auth => {
|
||||||
// in case operations were received before sender was received
|
|
||||||
// we apply the messages after authentication
|
|
||||||
this.connections[sender].waitingMessages.forEach(msg => {
|
|
||||||
this.receiveMessage(sender, msg)
|
|
||||||
})
|
|
||||||
this.connections[sender].waitingMessages = null
|
|
||||||
for (var f of this.userEventListeners) {
|
for (var f of this.userEventListeners) {
|
||||||
f({
|
f({
|
||||||
action: 'userAuthenticated',
|
action: 'userAuthenticated',
|
||||||
@@ -288,6 +280,9 @@ export default function extendConnector (Y/* :any */) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else if (this.connections[sender] != null && this.connections[sender].auth == null) {
|
||||||
|
// authenticate without otherwise
|
||||||
|
this.connections[sender].auth = this.checkAuth(null, this.y)
|
||||||
}
|
}
|
||||||
if (this.connections[sender] != null && this.connections[sender].auth != null) {
|
if (this.connections[sender] != null && this.connections[sender].auth != null) {
|
||||||
return this.connections[sender].auth.then((auth) => {
|
return this.connections[sender].auth.then((auth) => {
|
||||||
@@ -387,13 +382,8 @@ export default function extendConnector (Y/* :any */) {
|
|||||||
this.y.db.apply(message.ops)
|
this.y.db.apply(message.ops)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (this.connections[sender] != null) {
|
|
||||||
// wait for authentication
|
|
||||||
let senderConn = this.connection[sender]
|
|
||||||
senderConn.waitingMessages = senderConn.waitingMessages || []
|
|
||||||
senderConn.waitingMessages.push(message)
|
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(new Error('Unknown user - Unable to deliver message'))
|
return Promise.reject(new Error('Unable to deliver message'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_setSyncedWith (user) {
|
_setSyncedWith (user) {
|
||||||
|
|||||||
24
y.node.js
24
y.node.js
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* yjs - A framework for real-time p2p shared editing on any data
|
* yjs - A framework for real-time p2p shared editing on any data
|
||||||
* @version v13.0.0-6
|
* @version v13.0.0-5
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -702,9 +702,7 @@ function extendConnector (Y/* :any */) {
|
|||||||
this.log('User joined: %s', user);
|
this.log('User joined: %s', user);
|
||||||
this.connections[user] = {
|
this.connections[user] = {
|
||||||
isSynced: false,
|
isSynced: false,
|
||||||
role: role,
|
role: role
|
||||||
waitingMessages: [],
|
|
||||||
auth: null
|
|
||||||
};
|
};
|
||||||
let defer = {};
|
let defer = {};
|
||||||
defer.promise = new Promise(function (resolve) { defer.resolve = resolve; });
|
defer.promise = new Promise(function (resolve) { defer.resolve = resolve; });
|
||||||
@@ -830,17 +828,11 @@ function extendConnector (Y/* :any */) {
|
|||||||
});
|
});
|
||||||
return Promise.reject(new Error('Incompatible protocol version'))
|
return Promise.reject(new Error('Incompatible protocol version'))
|
||||||
}
|
}
|
||||||
if (message.type === 'sync step 1' && this.connections[sender] != null && this.connections[sender].auth == null) {
|
if (message.auth != null && this.connections[sender] != null) {
|
||||||
// authenticate using auth in message
|
// authenticate using auth in message
|
||||||
var auth = this.checkAuth(message.auth, this.y);
|
var auth = this.checkAuth(message.auth, this.y);
|
||||||
this.connections[sender].auth = auth;
|
this.connections[sender].auth = auth;
|
||||||
auth.then(auth => {
|
auth.then(auth => {
|
||||||
// in case operations were received before sender was received
|
|
||||||
// we apply the messages after authentication
|
|
||||||
this.connections[sender].waitingMessages.forEach(msg => {
|
|
||||||
this.receiveMessage(sender, msg);
|
|
||||||
});
|
|
||||||
this.connections[sender].waitingMessages = null;
|
|
||||||
for (var f of this.userEventListeners) {
|
for (var f of this.userEventListeners) {
|
||||||
f({
|
f({
|
||||||
action: 'userAuthenticated',
|
action: 'userAuthenticated',
|
||||||
@@ -849,6 +841,9 @@ function extendConnector (Y/* :any */) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (this.connections[sender] != null && this.connections[sender].auth == null) {
|
||||||
|
// authenticate without otherwise
|
||||||
|
this.connections[sender].auth = this.checkAuth(null, this.y);
|
||||||
}
|
}
|
||||||
if (this.connections[sender] != null && this.connections[sender].auth != null) {
|
if (this.connections[sender] != null && this.connections[sender].auth != null) {
|
||||||
return this.connections[sender].auth.then((auth) => {
|
return this.connections[sender].auth.then((auth) => {
|
||||||
@@ -948,13 +943,8 @@ function extendConnector (Y/* :any */) {
|
|||||||
this.y.db.apply(message.ops);
|
this.y.db.apply(message.ops);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (this.connections[sender] != null) {
|
|
||||||
// wait for authentication
|
|
||||||
let senderConn = this.connection[sender];
|
|
||||||
senderConn.waitingMessages = senderConn.waitingMessages || [];
|
|
||||||
senderConn.waitingMessages.push(message);
|
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(new Error('Unknown user - Unable to deliver message'))
|
return Promise.reject(new Error('Unable to deliver message'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_setSyncedWith (user) {
|
_setSyncedWith (user) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user