- matrix-crypt-file documentation updated (it cannot encrypt, only decrypts)

- matrix-js-sdk update from 15.5.0 to 16.0.0
- Fixed matrix-js-sdk breaking changes
- @matrix-org_olm-3.2.8.tgz added to package since there is no npm release for this. It fixes some errors so we need it.
This commit is contained in:
Skylar Sadlier 2022-03-17 14:23:22 -06:00
parent d304cb95f6
commit ac68060825
6 changed files with 61 additions and 34 deletions

BIN
@matrix-org_olm-3.2.8.tgz Normal file

Binary file not shown.

52
package-lock.json generated
View File

@ -1,19 +1,20 @@
{
"name": "node-red-contrib-matrix-chat",
"version": "0.4.1",
"version": "0.4.6",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "0.4.1",
"name": "node-red-contrib-matrix-chat",
"version": "0.4.6",
"license": "SEE LICENSE FILE",
"dependencies": {
"fs-extra": "^10.0.0",
"got": "^12.0.1",
"isomorphic-webcrypto": "^2.3.8",
"matrix-js-sdk": "^15.5.0",
"matrix-js-sdk": "^16.0.0",
"node-localstorage": "^2.2.1",
"olm": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz",
"olm": "./@matrix-org_olm-3.2.8.tgz",
"utf8": "^3.0.0"
},
"engines": {
@ -7092,14 +7093,14 @@
}
},
"node_modules/matrix-events-sdk": {
"version": "0.0.1-beta.6",
"resolved": "https://registry.npmjs.org/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.6.tgz",
"integrity": "sha512-VMqPXe3Bg4R9yC9PNqGv6bDFwWlVYadYxp0Ke1ihhXUCpGcx7e28kOYcqK2T3RxLXK4KK7VH4JRbY53Do3r+Fw=="
"version": "0.0.1-beta.7",
"resolved": "https://registry.npmjs.org/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.7.tgz",
"integrity": "sha512-9jl4wtWanUFSy2sr2lCjErN/oC8KTAtaeaozJtrgot1JiQcEI4Rda9OLgQ7nLKaqb4Z/QUx/fR3XpDzm5Jy1JA=="
},
"node_modules/matrix-js-sdk": {
"version": "15.5.0",
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-15.5.0.tgz",
"integrity": "sha512-Y8BoJ5xEejTeO2vwGrE4hNrSSOKLP6/brqeTy+gjjgti/PUhf+foC+ww9lHv7MqiNYFl9a/8tBf3crhU8+3jVw==",
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-16.0.0.tgz",
"integrity": "sha512-ZlrRjqo493pY6OwtQto+oNG2tFALbJKHUtIHUbay0eX100jQjbgMzXtWHrrFEU01+/aAccx+UP4ap0/MRcsALQ==",
"dependencies": {
"@babel/runtime": "^7.12.5",
"another-json": "^0.2.0",
@ -7107,7 +7108,7 @@
"bs58": "^4.0.1",
"content-type": "^1.0.4",
"loglevel": "^1.7.1",
"matrix-events-sdk": "^0.0.1-beta.6",
"matrix-events-sdk": "^0.0.1-beta.7",
"p-retry": "^4.5.0",
"qs": "^6.9.6",
"request": "^2.88.2",
@ -8182,9 +8183,10 @@
}
},
"node_modules/olm": {
"version": "3.2.1",
"resolved": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz",
"integrity": "sha512-B87bTpGIGieuV2FNauChjjQtVltwTGagQFoHm+3Dcse4amKAAGJB/I54dnP/JtbHZ+RYVoApM2OQ46Z4VH6eNg==",
"name": "@matrix-org/olm",
"version": "3.2.8",
"resolved": "file:@matrix-org_olm-3.2.8.tgz",
"integrity": "sha512-yCJzEYY2aG1z+7nxKYZC4DFYwQO/5iG019qgotJhauYJRhEG9gLrKTvXO6lRHS8TjnZzsZFZyO/hQUlI4Dryig==",
"license": "Apache-2.0"
},
"node_modules/on-finished": {
@ -17088,14 +17090,14 @@
}
},
"matrix-events-sdk": {
"version": "0.0.1-beta.6",
"resolved": "https://registry.npmjs.org/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.6.tgz",
"integrity": "sha512-VMqPXe3Bg4R9yC9PNqGv6bDFwWlVYadYxp0Ke1ihhXUCpGcx7e28kOYcqK2T3RxLXK4KK7VH4JRbY53Do3r+Fw=="
"version": "0.0.1-beta.7",
"resolved": "https://registry.npmjs.org/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.7.tgz",
"integrity": "sha512-9jl4wtWanUFSy2sr2lCjErN/oC8KTAtaeaozJtrgot1JiQcEI4Rda9OLgQ7nLKaqb4Z/QUx/fR3XpDzm5Jy1JA=="
},
"matrix-js-sdk": {
"version": "15.5.0",
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-15.5.0.tgz",
"integrity": "sha512-Y8BoJ5xEejTeO2vwGrE4hNrSSOKLP6/brqeTy+gjjgti/PUhf+foC+ww9lHv7MqiNYFl9a/8tBf3crhU8+3jVw==",
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-16.0.0.tgz",
"integrity": "sha512-ZlrRjqo493pY6OwtQto+oNG2tFALbJKHUtIHUbay0eX100jQjbgMzXtWHrrFEU01+/aAccx+UP4ap0/MRcsALQ==",
"requires": {
"@babel/runtime": "^7.12.5",
"another-json": "^0.2.0",
@ -17103,7 +17105,7 @@
"bs58": "^4.0.1",
"content-type": "^1.0.4",
"loglevel": "^1.7.1",
"matrix-events-sdk": "^0.0.1-beta.6",
"matrix-events-sdk": "^0.0.1-beta.7",
"p-retry": "^4.5.0",
"qs": "^6.9.6",
"request": "^2.88.2",
@ -17233,6 +17235,7 @@
"optional": true,
"peer": true,
"requires": {
"@babel/core": "^7.14.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
@ -17457,6 +17460,7 @@
"optional": true,
"peer": true,
"requires": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
@ -17504,6 +17508,7 @@
"optional": true,
"peer": true,
"requires": {
"@babel/core": "^7.14.0",
"babel-preset-fbjs": "^3.4.0",
"hermes-parser": "0.4.7",
"metro-babel-transformer": "0.66.2",
@ -17519,6 +17524,7 @@
"optional": true,
"peer": true,
"requires": {
"@babel/core": "^7.14.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
@ -18030,8 +18036,8 @@
}
},
"olm": {
"version": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz",
"integrity": "sha512-B87bTpGIGieuV2FNauChjjQtVltwTGagQFoHm+3Dcse4amKAAGJB/I54dnP/JtbHZ+RYVoApM2OQ46Z4VH6eNg=="
"version": "file:@matrix-org_olm-3.2.8.tgz",
"integrity": "sha512-yCJzEYY2aG1z+7nxKYZC4DFYwQO/5iG019qgotJhauYJRhEG9gLrKTvXO6lRHS8TjnZzsZFZyO/hQUlI4Dryig=="
},
"on-finished": {
"version": "2.3.0",

View File

@ -6,9 +6,9 @@
"fs-extra": "^10.0.0",
"got": "^12.0.1",
"isomorphic-webcrypto": "^2.3.8",
"matrix-js-sdk": "^15.5.0",
"matrix-js-sdk": "^16.0.0",
"node-localstorage": "^2.2.1",
"olm": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz",
"olm": "./@matrix-org_olm-3.2.8.tgz",
"utf8": "^3.0.0"
},
"node-red": {

View File

@ -25,7 +25,7 @@
<script type="text/html" data-help-name="matrix-decrypt-file">
<h3>Details</h3>
<p>Files sent in an encrypted room are themselves encrypted. Use this node to encrypt/decrypt files. Note: This node will download the encrypted file so be cautious of large downloads.</p>
<p>Files sent in an encrypted room are themselves encrypted. Use this node to decrypt files. Note: This node will download the encrypted file so be cautious of large downloads.</p>
<h3>Inputs</h3>
<dl class="message-properties">

View File

@ -55,7 +55,7 @@ module.exports = function(RED) {
msg.reason = '';
}
node.server.matrixClient.redactEvent(msg.topic,msg.eventId,undefined ,{
node.server.matrixClient.redactEvent(msg.topic, msg.eventId, undefined,{
reason: msg.reason
})

View File

@ -4,6 +4,7 @@ const sdk = require("matrix-js-sdk");
const { resolve } = require('path');
const { LocalStorage } = require('node-localstorage');
const { LocalStorageCryptoStore } = require('matrix-js-sdk/lib/crypto/store/localStorage-crypto-store');
const {RoomEvent, RoomMemberEvent, HttpApiEvent, ClientEvent} = require("matrix-js-sdk");
module.exports = function(RED) {
function MatrixFolderNameFromUserId(name) {
@ -146,7 +147,7 @@ module.exports = function(RED) {
return node.connected;
};
node.matrixClient.on("Room.timeline", async function(event, room, toStartOfTimeline, removed, data) {
node.matrixClient.on(RoomEvent.Timeline, async function(event, room, toStartOfTimeline, removed, data) {
if (toStartOfTimeline) {
return; // ignore paginated results
}
@ -167,6 +168,23 @@ module.exports = function(RED) {
return;
}
const isDmRoom = (room) => {
// Find out if this is a direct message room.
let isDM = !!room.getDMInviter();
const allMembers = room.currentState.getMembers();
if (!isDM && allMembers.length <= 2) {
// if not a DM, but there are 2 users only
// double check DM (needed because getDMInviter works only if you were invited, not if you invite)
// hence why we check for each member
if (allMembers.some((m) => m.getDMInviter())) {
return true;
}
}
return allMembers.length <= 2 && isDM;
};
node.matrixClient.getRoom(event.getRoomId())
let msg = {
encrypted : event.isEncrypted(),
redacted : event.isRedacted(),
@ -177,6 +195,7 @@ module.exports = function(RED) {
topic : event.getRoomId(),
eventId : event.getId(),
event : event,
isDirectMessage: isDmRoom(event.getRoomId())
};
node.log("Received" + (msg.encrypted ? ' encrypted' : '') +" timeline event [" + msg.type + "]: (" + room.name + ") " + event.getSender() + " :: " + msg.content.body + (toStartOfTimeline ? ' [PAGINATED]' : ''));
@ -189,9 +208,9 @@ module.exports = function(RED) {
*
* @event module:client~MatrixClient#"crypto.suggestKeyRestore"
*/
node.matrixClient.on("crypto.suggestKeyRestore", function(){
});
// node.matrixClient.on("crypto.suggestKeyRestore", function(){
//
// });
// node.matrixClient.on("RoomMember.typing", async function(event, member) {
// let isTyping = member.typing;
@ -210,7 +229,8 @@ module.exports = function(RED) {
// });
// handle auto-joining rooms
node.matrixClient.on("RoomMember.membership", async function(event, member) {
node.matrixClient.on(RoomMemberEvent.Membership, async function(event, member) {
if (member.membership === "invite" && member.userId === node.userId) {
if(node.autoAcceptRoomInvites) {
node.matrixClient.joinRoom(member.roomId).then(function() {
@ -224,7 +244,7 @@ module.exports = function(RED) {
}
});
node.matrixClient.on("sync", async function(state, prevState, data) {
node.matrixClient.on(ClientEvent.Sync, async function(state, prevState, data) {
node.debug("SYNC [STATE=" + state + "] [PREVSTATE=" + prevState + "]");
if(prevState === null && state === "PREPARED" ) {
// Occurs when the initial sync is completed first time.
@ -292,7 +312,8 @@ module.exports = function(RED) {
}
});
node.matrixClient.on("Session.logged_out", async function(errorObj){
node.matrixClient.on(HttpApiEvent.SessionLoggedOut, async function(errorObj){
// Example if user auth token incorrect:
// {
// errcode: 'M_UNKNOWN_TOKEN',