mirror of
https://github.com/plantroon/mx-puppet-xmpp.git
synced 2024-11-14 23:41:40 +00:00
fix content authentification
This commit is contained in:
parent
6feacecb5b
commit
0255283d5a
26
package-lock.json
generated
26
package-lock.json
generated
@ -33,9 +33,9 @@
|
||||
"integrity": "sha512-lXKXfypKo644k4Da4yXkPCrwcvn6SlUW2X2zFbuflKHNjf0w9htru01bo26uMhleMXsDmnZ12eJLdrAZa9MANg=="
|
||||
},
|
||||
"@sorunome/matrix-bot-sdk": {
|
||||
"version": "0.5.3-2",
|
||||
"resolved": "https://registry.npmjs.org/@sorunome/matrix-bot-sdk/-/matrix-bot-sdk-0.5.3-2.tgz",
|
||||
"integrity": "sha512-kGbz+EudtS8iISEyfNnJEa29lA3tqzE7jUwaXUdkYqo2QuiNS0xnXi5zJDJoCycQEf5v0bWbVdtM+dEIilpTew==",
|
||||
"version": "0.5.3-3",
|
||||
"resolved": "https://registry.npmjs.org/@sorunome/matrix-bot-sdk/-/matrix-bot-sdk-0.5.3-3.tgz",
|
||||
"integrity": "sha512-/n3Yq8OJ0Y3xtuAVwy7w8K8zyazfCQ0df/68ISOYjoFqGiJ8r1aOTDHn633cPictCdc6xWx5DatDG0Ef06jpMA==",
|
||||
"requires": {
|
||||
"@types/express": "^4.17.2",
|
||||
"chalk": "^3.0.0",
|
||||
@ -246,6 +246,12 @@
|
||||
"@types/mime": "*"
|
||||
}
|
||||
},
|
||||
"@types/tough-cookie": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.0.tgz",
|
||||
"integrity": "sha512-I99sngh224D0M7XgW1s120zxCt3VYQ3IQsuw3P3jbq5GG4yc79+ZjyKznyOGIQrflfylLgcfekeZW/vk0yng6A==",
|
||||
"dev": true
|
||||
},
|
||||
"accepts": {
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
|
||||
@ -1490,9 +1496,9 @@
|
||||
"integrity": "sha512-ejdnDQcR75gwknmMw/tx02AuRs8jCtqFoFqDZMjiNxsu85sRIJVXDKHuLYvUUPRBUtV2FpSZa9bL1BUa3BdR2g=="
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.24.0",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
|
||||
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
|
||||
"version": "2.25.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.25.1.tgz",
|
||||
"integrity": "sha512-nRKMf9wDS4Fkyd0C9LXh2FFXinD+iwbJ5p/lh3CHitW9kZbRbJ8hCruiadiIXZVbeAqKZzqcTvHnK3mRhFjb6w=="
|
||||
},
|
||||
"morgan": {
|
||||
"version": "1.10.0",
|
||||
@ -1519,11 +1525,11 @@
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"mx-puppet-bridge": {
|
||||
"version": "0.0.41-1",
|
||||
"resolved": "https://registry.npmjs.org/mx-puppet-bridge/-/mx-puppet-bridge-0.0.41-1.tgz",
|
||||
"integrity": "sha512-Xu5wnkzfJ/5u2S7hsVM09NZcBbXVH8HxpLs0dLjjsgRpu2vx4V50rpvspd6euMyIUs+DZZcyQ5suY3FFETmqzg==",
|
||||
"version": "0.0.42",
|
||||
"resolved": "https://registry.npmjs.org/mx-puppet-bridge/-/mx-puppet-bridge-0.0.42.tgz",
|
||||
"integrity": "sha512-1nh+P9z9+DWmT00mcCEOsWKLI9I7qvfmZS8+7+Rh5r9QiBk6kkVvjGG1l7cCO7HwkA3J9IA1b0VhxFfz3cONtg==",
|
||||
"requires": {
|
||||
"@sorunome/matrix-bot-sdk": "^0.5.3-2",
|
||||
"@sorunome/matrix-bot-sdk": "^0.5.3-3",
|
||||
"better-sqlite3": "^6.0.1",
|
||||
"escape-html": "^1.0.3",
|
||||
"events": "^3.1.0",
|
||||
|
@ -20,14 +20,16 @@
|
||||
"events": "^3.0.0",
|
||||
"expire-set": "^1.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"mx-puppet-bridge": "0.0.41-1",
|
||||
"mx-puppet-bridge": "0.0.42",
|
||||
"node-emoji": "^1.10.0",
|
||||
"node-html-parser": "^1.2.13",
|
||||
"tough-cookie": "^4.0.0",
|
||||
"tslint": "^5.17.0",
|
||||
"typescript": "^3.7.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/node": "^12.0.8"
|
||||
"@types/node": "^12.0.8",
|
||||
"@types/tough-cookie": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ Copyright 2020 mx-puppet-skype
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -18,6 +18,7 @@ import { Contact as SkypeContact } from "@sorunome/skype-http/dist/lib/types/con
|
||||
import { NewMediaMessage as SkypeNewMediaMessage } from "@sorunome/skype-http/dist/lib/interfaces/api/api";
|
||||
import { Context as SkypeContext } from "@sorunome/skype-http/dist/lib/interfaces/api/context";
|
||||
import ExpireSet from "expire-set";
|
||||
import * as toughCookie from "tough-cookie";
|
||||
|
||||
const log = new Log("SkypePuppet:client");
|
||||
|
||||
@ -231,15 +232,40 @@ export class Client extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
public async downloadFile(url: string): Promise<Buffer> {
|
||||
if (!url.includes("/views/")) {
|
||||
url = url + "/views/imgpsh_fullsize_anim";
|
||||
public async downloadFile(url: string, type: string = "imgpsh_fullsize_anim"): Promise<Buffer> {
|
||||
if (url.startsWith("https://api.asm.skype.com/") && !url.includes("/views/")) {
|
||||
url = `${url}/views/${type}`;
|
||||
}
|
||||
const cookieJar = new toughCookie.CookieJar(this.api.context.cookies);
|
||||
return await Util.DownloadFile(url, {
|
||||
headers: {
|
||||
Authorization: "skypetoken=" + this.api.context.skypeToken.value,
|
||||
RegistrationToken: this.api.context.registrationToken.raw,
|
||||
},
|
||||
cookieJar: {
|
||||
setCookie: async (rawCookie: string, cookieUrl: string) =>
|
||||
new Promise((resolve, reject) =>
|
||||
cookieJar.setCookie(rawCookie, cookieUrl, (err, value) =>
|
||||
err ? reject(err) : resolve(value),
|
||||
),
|
||||
),
|
||||
getCookieString: async (cookieUrl: string) =>
|
||||
new Promise((resolve, reject) =>
|
||||
cookieJar.getCookieString(cookieUrl, (err, value) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
if (url.startsWith("https://api.asm.skype.com/")) {
|
||||
if (value) {
|
||||
value += "; ";
|
||||
}
|
||||
value += "skypetoken_asm=" + encodeURIComponent(this.api.context.skypeToken.value);
|
||||
}
|
||||
resolve(value);
|
||||
}),
|
||||
),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -86,11 +86,15 @@ export class Skype {
|
||||
avatarUrl = picture.slice("URL@".length);
|
||||
}
|
||||
}
|
||||
const p = this.puppets[puppetId];
|
||||
return {
|
||||
puppetId,
|
||||
roomId: conversation.id,
|
||||
name,
|
||||
avatarUrl,
|
||||
downloadFile: async (url: string): Promise<Buffer> => {
|
||||
return await p.client.downloadFile(url, "swx_avatar");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -414,8 +418,6 @@ export class Skype {
|
||||
if (!p) {
|
||||
return;
|
||||
}
|
||||
console.log("===================");
|
||||
console.log(data);
|
||||
log.info("Received reply from matrix");
|
||||
const conversation = await p.client.getConversation(room);
|
||||
if (!conversation) {
|
||||
|
Loading…
Reference in New Issue
Block a user