Socket
Socket
Sign inDemoInstall

mx-puppet-bridge

Package Overview
Dependencies
282
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.38 to 0.0.39

lib/src/db/schema/v14.d.ts

1

lib/src/botprovisioner.js

@@ -348,2 +348,3 @@ "use strict";

hsUrl,
mxid: sender,
});

@@ -350,0 +351,0 @@ if (!client) {

8

lib/src/db/eventstore.d.ts

@@ -5,6 +5,6 @@ import { IDatabaseConnector } from "./connector";

constructor(db: IDatabaseConnector);
insert(puppetId: number, matrixId: string, remoteId: string): Promise<void>;
remove(puppetId: number, remoteId: string): Promise<void>;
getMatrix(puppetId: number, remoteId: string): Promise<string[]>;
getRemote(puppetId: number, matrixId: string): Promise<string[]>;
insert(puppetId: number, roomId: string, matrixId: string, remoteId: string): Promise<void>;
remove(puppetId: number, roomId: string, remoteId: string): Promise<void>;
getMatrix(puppetId: number, roomId: string, remoteId: string): Promise<string[]>;
getRemote(puppetId: number, roomId: string, matrixId: string): Promise<string[]>;
}

@@ -30,6 +30,7 @@ "use strict";

}
insert(puppetId, matrixId, remoteId) {
insert(puppetId, roomId, matrixId, remoteId) {
return __awaiter(this, void 0, void 0, function* () {
yield this.db.Run("INSERT INTO event_store (puppet_id, matrix_id, remote_id) VALUES ($p, $m, $r)", {
yield this.db.Run("INSERT INTO event_store (puppet_id, room_id, matrix_id, remote_id) VALUES ($p, $room, $m, $r)", {
p: puppetId,
room: roomId,
m: matrixId,

@@ -40,6 +41,7 @@ r: remoteId,

}
remove(puppetId, remoteId) {
remove(puppetId, roomId, remoteId) {
return __awaiter(this, void 0, void 0, function* () {
yield this.db.Run("DELETE FROM event_store WHERE puppet_id = $p AND remote_id = $r", {
yield this.db.Run("DELETE FROM event_store WHERE puppet_id = $p AND room_id = $room AND remote_id = $r", {
p: puppetId,
room: roomId,
r: remoteId,

@@ -49,7 +51,8 @@ });

}
getMatrix(puppetId, remoteId) {
getMatrix(puppetId, roomId, remoteId) {
return __awaiter(this, void 0, void 0, function* () {
const result = [];
const rows = yield this.db.All("SELECT * FROM event_store WHERE puppet_id=$p AND remote_id=$r", {
const rows = yield this.db.All("SELECT * FROM event_store WHERE puppet_id=$p AND room_id = $room AND remote_id=$r", {
p: puppetId,
room: roomId,
r: remoteId,

@@ -63,7 +66,8 @@ });

}
getRemote(puppetId, matrixId) {
getRemote(puppetId, roomId, matrixId) {
return __awaiter(this, void 0, void 0, function* () {
const result = [];
const rows = yield this.db.All("SELECT * FROM event_store WHERE puppet_id=$p AND matrix_id=$m", {
const rows = yield this.db.All("SELECT * FROM event_store WHERE puppet_id = $p AND room_id = $room AND matrix_id = $m", {
p: puppetId,
room: roomId,
m: matrixId,

@@ -70,0 +74,0 @@ });

import { PuppetBridge } from "./puppetbridge";
import { IRemoteRoom } from "./interfaces";
export declare class EventSyncroniser {

@@ -6,6 +7,6 @@ private bridge;

constructor(bridge: PuppetBridge);
insert(puppetId: number, matrixId: string, remoteId?: string): Promise<void>;
remove(puppetId: number, remoteId: string): Promise<void>;
getMatrix(puppetId: number, remoteId: string): Promise<string[]>;
getRemote(puppetId: number, matrixId: string): Promise<string[]>;
insert(room: IRemoteRoom, matrixId: string, remoteId?: string): Promise<void>;
remove(room: IRemoteRoom, remoteId: string): Promise<void>;
getMatrix(room: IRemoteRoom, remoteId: string): Promise<string[]>;
getRemote(room: IRemoteRoom, matrixId: string): Promise<string[]>;
}

@@ -31,12 +31,14 @@ "use strict";

}
insert(puppetId, matrixId, remoteId) {
insert(room, matrixId, remoteId) {
return __awaiter(this, void 0, void 0, function* () {
if (remoteId) {
const dbPuppetId = yield this.bridge.namespaceHandler.getDbPuppetId(puppetId);
yield this.eventStore.insert(dbPuppetId, matrixId, remoteId);
const dbPuppetId = yield this.bridge.namespaceHandler.getDbPuppetId(room.puppetId);
yield this.eventStore.insert(dbPuppetId, room.roomId, matrixId, remoteId);
}
// we have registered this event, so we might as well mark it as read
try {
const [eventId, roomId] = matrixId.split(";");
yield this.bridge.botIntent.underlyingClient.sendReadReceipt(roomId, eventId);
const roomId = yield this.bridge.roomSync.maybeGetMxid(room);
if (roomId) {
yield this.bridge.botIntent.underlyingClient.sendReadReceipt(roomId, matrixId);
}
}

@@ -48,18 +50,18 @@ catch (err) {

}
remove(puppetId, remoteId) {
remove(room, remoteId) {
return __awaiter(this, void 0, void 0, function* () {
const dbPuppetId = yield this.bridge.namespaceHandler.getDbPuppetId(puppetId);
yield this.eventStore.remove(dbPuppetId, remoteId);
const dbPuppetId = yield this.bridge.namespaceHandler.getDbPuppetId(room.puppetId);
yield this.eventStore.remove(dbPuppetId, room.roomId, remoteId);
});
}
getMatrix(puppetId, remoteId) {
getMatrix(room, remoteId) {
return __awaiter(this, void 0, void 0, function* () {
const dbPuppetId = yield this.bridge.namespaceHandler.getDbPuppetId(puppetId);
return yield this.eventStore.getMatrix(dbPuppetId, remoteId);
const dbPuppetId = yield this.bridge.namespaceHandler.getDbPuppetId(room.puppetId);
return yield this.eventStore.getMatrix(dbPuppetId, room.roomId, remoteId);
});
}
getRemote(puppetId, matrixId) {
getRemote(room, matrixId) {
return __awaiter(this, void 0, void 0, function* () {
const dbPuppetId = yield this.bridge.namespaceHandler.getDbPuppetId(puppetId);
return yield this.eventStore.getRemote(dbPuppetId, matrixId);
const dbPuppetId = yield this.bridge.namespaceHandler.getDbPuppetId(room.puppetId);
return yield this.eventStore.getRemote(dbPuppetId, room.roomId, matrixId);
});

@@ -66,0 +68,0 @@ }

@@ -229,3 +229,3 @@ "use strict";

for (const redacts of event.redactsEventIds) {
const eventIds = yield this.bridge.eventSync.getRemote(room.puppetId, `${redacts};${roomId}`);
const eventIds = yield this.bridge.eventSync.getRemote(room, redacts);
for (const eventId of eventIds) {

@@ -314,3 +314,3 @@ log.verbose("Emitting redact event...");

url,
eventId: `${event.eventId};${roomId}`,
eventId: event.eventId,
};

@@ -353,3 +353,3 @@ if (content.info) {

emote: false,
eventId: `${event.eventId};${roomId}`,
eventId: event.eventId,
};

@@ -368,3 +368,3 @@ this.bridge.emit("message", room, textData, asUser, event);

notice: msgtype === "m.notice",
eventId: `${event.eventId};${roomId}`,
eventId: event.eventId,
};

@@ -379,3 +379,3 @@ if (content.format) {

const eventId = relate.event_id || relate["m.in_reply_to"].event_id;
const relEvent = (yield this.bridge.eventSync.getRemote(room.puppetId, `${eventId};${roomId}`))[0];
const relEvent = (yield this.bridge.eventSync.getRemote(room, eventId))[0];
if (relEvent) {

@@ -388,3 +388,3 @@ if (this.bridge.protocol.features.edit && relate.rel_type === "m.replace") {

notice: newContent.msgtype === "m.notice",
eventId: `${event.eventId};${roomId}`,
eventId: event.eventId,
};

@@ -391,0 +391,0 @@ if (newContent.format) {

@@ -572,3 +572,5 @@ "use strict";

}
info.invites.add(puppetData.puppetMxid);
if (puppetData.autoinvite) {
info.invites.add(puppetData.puppetMxid);
}
}

@@ -575,0 +577,0 @@ }

@@ -13,2 +13,3 @@ import { PuppetBridge } from "./puppetbridge";

hsUrl: string;
mxid: string;
}

@@ -15,0 +16,0 @@ export declare class Provisioner {

@@ -122,2 +122,3 @@ "use strict";

token: info.token,
mxid,
};

@@ -124,0 +125,0 @@ });

@@ -34,3 +34,3 @@ "use strict";

log.info(`Received reaction from ${params.user.userId} to send to ${params.room.roomId}, message ${eventId}`);
const origEvent = (yield this.bridge.eventSync.getMatrix(params.room.puppetId, eventId))[0];
const origEvent = (yield this.bridge.eventSync.getMatrix(params.room, eventId))[0];
if (!origEvent) {

@@ -67,3 +67,3 @@ log.warn("No original event found, ignoring...");

if (matrixEventId && params.eventId) {
yield this.bridge.eventSync.insert(params.room.puppetId, matrixEventId, params.eventId);
yield this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -78,3 +78,3 @@ // and finally save the reaction to our reaction store

log.info(`Removing reaction from ${params.user.userId} in ${params.room.roomId}, message ${eventId}`);
const origEvent = (yield this.bridge.eventSync.getMatrix(params.room.puppetId, eventId))[0];
const origEvent = (yield this.bridge.eventSync.getMatrix(params.room, eventId))[0];
if (!origEvent) {

@@ -107,3 +107,3 @@ log.warn("No original event found, ignoring...");

log.info(`Removing all reactions from message ${eventId} in ${params.room.roomId}`);
const origEvent = (yield this.bridge.eventSync.getMatrix(params.room.puppetId, eventId))[0];
const origEvent = (yield this.bridge.eventSync.getMatrix(params.room, eventId))[0];
if (!origEvent) {

@@ -110,0 +110,0 @@ log.warn("No original event found, ignoring...");

@@ -87,3 +87,3 @@ "use strict";

}
const origEvents = yield this.bridge.eventSync.getMatrix(params.room.puppetId, params.eventId);
const origEvents = yield this.bridge.eventSync.getMatrix(params.room, params.eventId);
for (const origEvent of origEvents) {

@@ -154,3 +154,3 @@ yield ret.client.sendReadReceipt(ret.mxid, origEvent.split(";")[0]);

if (matrixEventId && params.eventId) {
yield this.bridge.eventSync.insert(params.room.puppetId, `${matrixEventId};${mxid}`, params.eventId);
yield this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -175,3 +175,3 @@ // aaand stop typing

}
const origEvents = yield this.bridge.eventSync.getMatrix(params.room.puppetId, eventId);
const origEvents = yield this.bridge.eventSync.getMatrix(params.room, eventId);
if (ix < 0) {

@@ -217,3 +217,3 @@ // negative indexes are from the back

if (matrixEventId && params.eventId) {
yield this.bridge.eventSync.insert(params.room.puppetId, `${matrixEventId};${mxid}`, params.eventId);
yield this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -231,3 +231,3 @@ // aaand stop typing

const { client, mxid } = yield this.prepareSend(params);
const origEvents = yield this.bridge.eventSync.getMatrix(params.room.puppetId, eventId);
const origEvents = yield this.bridge.eventSync.getMatrix(params.room, eventId);
for (const origEvent of origEvents) {

@@ -252,3 +252,3 @@ yield this.bridge.redactEvent(client, mxid, origEvent.split(";")[0]);

}
const origEvents = yield this.bridge.eventSync.getMatrix(params.room.puppetId, eventId);
const origEvents = yield this.bridge.eventSync.getMatrix(params.room, eventId);
const origEvent = origEvents[0];

@@ -280,3 +280,3 @@ // this send object needs to be any-type, as the interfaces don't do replies yet

if (matrixEventId && params.eventId) {
yield this.bridge.eventSync.insert(params.room.puppetId, `${matrixEventId};${mxid}`, params.eventId);
yield this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -425,3 +425,3 @@ // aaand stop typing

if (matrixEventId && params.eventId) {
yield this.bridge.eventSync.insert(params.room.puppetId, `${matrixEventId};${mxid}`, params.eventId);
yield this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -428,0 +428,0 @@ // aaand stop typing

@@ -12,3 +12,3 @@ /// <reference types="node" />

import { PuppetBridge } from "./puppetbridge";
export declare const CURRENT_SCHEMA = 13;
export declare const CURRENT_SCHEMA = 14;
declare type GetSchemaClass = (version: number) => IDbSchema;

@@ -15,0 +15,0 @@ export declare class Store {

@@ -35,3 +35,3 @@ "use strict";

const log = new log_1.Log("Store");
exports.CURRENT_SCHEMA = 13;
exports.CURRENT_SCHEMA = 14;
class Store {

@@ -38,0 +38,0 @@ constructor(config, bridge) {

@@ -49,4 +49,26 @@ "use strict";

catch (err) {
log.verbose("Invalid client config");
if (err.body.errcode === "M_UNKNOWN_TOKEN") {
log.verbose("Client got revoked, retrying to connect...");
const newToken = yield this.bridge.provisioner.loginWithSharedSecret(token.mxid);
if (newToken) {
const newClient = new matrix_bot_sdk_1.MatrixClient(token.hsUrl, newToken);
try {
yield newClient.getUserId();
yield this.bridge.provisioner.setToken(token.mxid, newToken);
return newClient;
}
catch (_a) {
log.verbose("Invalid newly configured client");
}
}
else {
log.verbose("Invalid client config and no shared secret configured");
}
}
else {
log.verbose("Invalid client config");
}
}
// might as well dispose of the token to not re-try too often
yield this.bridge.provisioner.setToken(token.mxid, null);
return null;

@@ -53,0 +75,0 @@ });

@@ -40,3 +40,2 @@ "use strict";

options.url = url;
options.encoding = undefined;
return yield got_1.default(options).buffer();

@@ -43,0 +42,0 @@ });

{
"name": "mx-puppet-bridge",
"version": "0.0.38",
"version": "0.0.39",
"description": "Matrix Puppeting Bridge library",

@@ -23,3 +23,3 @@ "repository": {

"dependencies": {
"@sorunome/matrix-bot-sdk": "^0.5.3-1",
"@sorunome/matrix-bot-sdk": "^0.5.3-2",
"got": "^10.7.0",

@@ -26,0 +26,0 @@ "better-sqlite3": "^6.0.1",

@@ -361,2 +361,3 @@ /*

hsUrl,
mxid: sender,
});

@@ -363,0 +364,0 @@ if (!client) {

@@ -24,5 +24,6 @@ /*

public async insert(puppetId: number, matrixId: string, remoteId: string) {
await this.db.Run("INSERT INTO event_store (puppet_id, matrix_id, remote_id) VALUES ($p, $m, $r)", {
public async insert(puppetId: number, roomId: string, matrixId: string, remoteId: string) {
await this.db.Run("INSERT INTO event_store (puppet_id, room_id, matrix_id, remote_id) VALUES ($p, $room, $m, $r)", {
p: puppetId,
room: roomId,
m: matrixId,

@@ -33,5 +34,6 @@ r: remoteId,

public async remove(puppetId: number, remoteId: string) {
await this.db.Run("DELETE FROM event_store WHERE puppet_id = $p AND remote_id = $r", {
public async remove(puppetId: number, roomId: string, remoteId: string) {
await this.db.Run("DELETE FROM event_store WHERE puppet_id = $p AND room_id = $room AND remote_id = $r", {
p: puppetId,
room: roomId,
r: remoteId,

@@ -41,6 +43,7 @@ });

public async getMatrix(puppetId: number, remoteId: string): Promise<string[]> {
public async getMatrix(puppetId: number, roomId: string, remoteId: string): Promise<string[]> {
const result: string[] = [];
const rows = await this.db.All("SELECT * FROM event_store WHERE puppet_id=$p AND remote_id=$r", {
const rows = await this.db.All("SELECT * FROM event_store WHERE puppet_id=$p AND room_id = $room AND remote_id=$r", {
p: puppetId,
room: roomId,
r: remoteId,

@@ -54,6 +57,7 @@ });

public async getRemote(puppetId: number, matrixId: string): Promise<string[]> {
public async getRemote(puppetId: number, roomId: string, matrixId: string): Promise<string[]> {
const result: string[] = [];
const rows = await this.db.All("SELECT * FROM event_store WHERE puppet_id=$p AND matrix_id=$m", {
const rows = await this.db.All("SELECT * FROM event_store WHERE puppet_id = $p AND room_id = $room AND matrix_id = $m", {
p: puppetId,
room: roomId,
m: matrixId,

@@ -60,0 +64,0 @@ });

@@ -17,2 +17,3 @@ /*

import { DbEventStore } from "./db/eventstore";
import { IRemoteRoom } from "./interfaces";

@@ -29,11 +30,13 @@ const log = new Log("EventSyncroniser");

public async insert(puppetId: number, matrixId: string, remoteId?: string) {
public async insert(room: IRemoteRoom, matrixId: string, remoteId?: string) {
if (remoteId) {
const dbPuppetId = await this.bridge.namespaceHandler.getDbPuppetId(puppetId);
await this.eventStore.insert(dbPuppetId, matrixId, remoteId);
const dbPuppetId = await this.bridge.namespaceHandler.getDbPuppetId(room.puppetId);
await this.eventStore.insert(dbPuppetId, room.roomId, matrixId, remoteId);
}
// we have registered this event, so we might as well mark it as read
try {
const [eventId, roomId] = matrixId.split(";");
await this.bridge.botIntent.underlyingClient.sendReadReceipt(roomId, eventId);
const roomId = await this.bridge.roomSync.maybeGetMxid(room);
if (roomId) {
await this.bridge.botIntent.underlyingClient.sendReadReceipt(roomId, matrixId);
}
} catch (err) {

@@ -44,16 +47,16 @@ log.silly("Failed to send read reciept", err);

public async remove(puppetId: number, remoteId: string) {
const dbPuppetId = await this.bridge.namespaceHandler.getDbPuppetId(puppetId);
await this.eventStore.remove(dbPuppetId, remoteId);
public async remove(room: IRemoteRoom, remoteId: string) {
const dbPuppetId = await this.bridge.namespaceHandler.getDbPuppetId(room.puppetId);
await this.eventStore.remove(dbPuppetId, room.roomId, remoteId);
}
public async getMatrix(puppetId: number, remoteId: string): Promise<string[]> {
const dbPuppetId = await this.bridge.namespaceHandler.getDbPuppetId(puppetId);
return await this.eventStore.getMatrix(dbPuppetId, remoteId);
public async getMatrix(room: IRemoteRoom, remoteId: string): Promise<string[]> {
const dbPuppetId = await this.bridge.namespaceHandler.getDbPuppetId(room.puppetId);
return await this.eventStore.getMatrix(dbPuppetId, room.roomId, remoteId);
}
public async getRemote(puppetId: number, matrixId: string): Promise<string[]> {
const dbPuppetId = await this.bridge.namespaceHandler.getDbPuppetId(puppetId);
return await this.eventStore.getRemote(dbPuppetId, matrixId);
public async getRemote(room: IRemoteRoom, matrixId: string): Promise<string[]> {
const dbPuppetId = await this.bridge.namespaceHandler.getDbPuppetId(room.puppetId);
return await this.eventStore.getRemote(dbPuppetId, room.roomId, matrixId);
}
}

@@ -225,3 +225,3 @@ /*

for (const redacts of event.redactsEventIds) {
const eventIds = await this.bridge.eventSync.getRemote(room.puppetId, `${redacts};${roomId}`);
const eventIds = await this.bridge.eventSync.getRemote(room, redacts);
for (const eventId of eventIds) {

@@ -317,3 +317,3 @@ log.verbose("Emitting redact event...");

url,
eventId: `${event.eventId};${roomId}`,
eventId: event.eventId,
};

@@ -356,3 +356,3 @@ if (content.info) {

emote: false,
eventId: `${event.eventId};${roomId}`,
eventId: event.eventId,
};

@@ -375,3 +375,3 @@ this.bridge.emit("message", room, textData, asUser, event);

notice: msgtype === "m.notice",
eventId: `${event.eventId};${roomId}`,
eventId: event.eventId,
};

@@ -386,4 +386,4 @@ if (content.format) {

const eventId = relate.event_id || relate["m.in_reply_to"].event_id;
const relEvent = (await this.bridge.eventSync.getRemote(room.puppetId,
`${eventId};${roomId}`))[0];
const relEvent = (await this.bridge.eventSync.getRemote(room,
eventId))[0];
if (relEvent) {

@@ -396,3 +396,3 @@ if (this.bridge.protocol.features.edit && relate.rel_type === "m.replace") {

notice: newContent.msgtype === "m.notice",
eventId: `${event.eventId};${roomId}`,
eventId: event.eventId,
};

@@ -399,0 +399,0 @@ if (newContent.format) {

@@ -560,3 +560,5 @@ /*

}
info.invites.add(puppetData.puppetMxid);
if (puppetData.autoinvite) {
info.invites.add(puppetData.puppetMxid);
}
}

@@ -563,0 +565,0 @@ }

@@ -34,2 +34,3 @@ /*

hsUrl: string;
mxid: string;
}

@@ -124,2 +125,3 @@

token: info.token,
mxid,
};

@@ -126,0 +128,0 @@ }

@@ -32,3 +32,3 @@ /*

log.info(`Received reaction from ${params.user.userId} to send to ${params.room.roomId}, message ${eventId}`);
const origEvent = (await this.bridge.eventSync.getMatrix(params.room.puppetId, eventId))[0];
const origEvent = (await this.bridge.eventSync.getMatrix(params.room, eventId))[0];
if (!origEvent) {

@@ -65,3 +65,3 @@ log.warn("No original event found, ignoring...");

if (matrixEventId && params.eventId) {
await this.bridge.eventSync.insert(params.room.puppetId, matrixEventId, params.eventId);
await this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -75,3 +75,3 @@ // and finally save the reaction to our reaction store

log.info(`Removing reaction from ${params.user.userId} in ${params.room.roomId}, message ${eventId}`);
const origEvent = (await this.bridge.eventSync.getMatrix(params.room.puppetId, eventId))[0];
const origEvent = (await this.bridge.eventSync.getMatrix(params.room, eventId))[0];
if (!origEvent) {

@@ -103,3 +103,3 @@ log.warn("No original event found, ignoring...");

log.info(`Removing all reactions from message ${eventId} in ${params.room.roomId}`);
const origEvent = (await this.bridge.eventSync.getMatrix(params.room.puppetId, eventId))[0];
const origEvent = (await this.bridge.eventSync.getMatrix(params.room, eventId))[0];
if (!origEvent) {

@@ -106,0 +106,0 @@ log.warn("No original event found, ignoring...");

@@ -93,3 +93,3 @@ /*

}
const origEvents = await this.bridge.eventSync.getMatrix(params.room.puppetId, params.eventId);
const origEvents = await this.bridge.eventSync.getMatrix(params.room, params.eventId);
for (const origEvent of origEvents) {

@@ -156,3 +156,3 @@ await ret.client.sendReadReceipt(ret.mxid, origEvent.split(";")[0]);

if (matrixEventId && params.eventId) {
await this.bridge.eventSync.insert(params.room.puppetId, `${matrixEventId};${mxid}`, params.eventId);
await this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -175,3 +175,3 @@ // aaand stop typing

}
const origEvents = await this.bridge.eventSync.getMatrix(params.room.puppetId, eventId);
const origEvents = await this.bridge.eventSync.getMatrix(params.room, eventId);
if (ix < 0) {

@@ -216,3 +216,3 @@ // negative indexes are from the back

if (matrixEventId && params.eventId) {
await this.bridge.eventSync.insert(params.room.puppetId, `${matrixEventId};${mxid}`, params.eventId);
await this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -229,3 +229,3 @@ // aaand stop typing

const { client, mxid } = await this.prepareSend(params);
const origEvents = await this.bridge.eventSync.getMatrix(params.room.puppetId, eventId);
const origEvents = await this.bridge.eventSync.getMatrix(params.room, eventId);
for (const origEvent of origEvents) {

@@ -248,3 +248,3 @@ await this.bridge.redactEvent(client, mxid, origEvent.split(";")[0]);

}
const origEvents = await this.bridge.eventSync.getMatrix(params.room.puppetId, eventId);
const origEvents = await this.bridge.eventSync.getMatrix(params.room, eventId);
const origEvent = origEvents[0];

@@ -275,3 +275,3 @@ // this send object needs to be any-type, as the interfaces don't do replies yet

if (matrixEventId && params.eventId) {
await this.bridge.eventSync.insert(params.room.puppetId, `${matrixEventId};${mxid}`, params.eventId);
await this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -415,3 +415,3 @@ // aaand stop typing

if (matrixEventId && params.eventId) {
await this.bridge.eventSync.insert(params.room.puppetId, `${matrixEventId};${mxid}`, params.eventId);
await this.bridge.eventSync.insert(params.room, matrixEventId, params.eventId);
}

@@ -418,0 +418,0 @@ // aaand stop typing

@@ -30,3 +30,3 @@ /*

export const CURRENT_SCHEMA = 13;
export const CURRENT_SCHEMA = 14;

@@ -33,0 +33,0 @@ type GetSchemaClass = (version: number) => IDbSchema;

@@ -50,4 +50,23 @@ /*

} catch (err) {
log.verbose("Invalid client config");
if (err.body.errcode === "M_UNKNOWN_TOKEN") {
log.verbose("Client got revoked, retrying to connect...");
const newToken = await this.bridge.provisioner.loginWithSharedSecret(token.mxid);
if (newToken) {
const newClient = new MatrixClient(token.hsUrl, newToken);
try {
await newClient.getUserId();
await this.bridge.provisioner.setToken(token.mxid, newToken);
return newClient;
} catch {
log.verbose("Invalid newly configured client");
}
} else {
log.verbose("Invalid client config and no shared secret configured");
}
} else {
log.verbose("Invalid client config");
}
}
// might as well dispose of the token to not re-try too often
await this.bridge.provisioner.setToken(token.mxid, null);
return null;

@@ -54,0 +73,0 @@ }

@@ -44,3 +44,2 @@ /*

options.url = url;
options.encoding = undefined;
return await got(options).buffer();

@@ -47,0 +46,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc