zotero-plugin 5.0.26 → 5.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/fetch-zotero-log.py +54 -17
- package/bin/release.js +1 -1
- package/debug-log.js +6 -3
- package/package.json +1 -1
package/bin/fetch-zotero-log.py
CHANGED
|
@@ -3,21 +3,58 @@
|
|
|
3
3
|
import sys, os
|
|
4
4
|
import urllib.request
|
|
5
5
|
from zipfile import ZipFile
|
|
6
|
+
from types import SimpleNamespace
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
from cryptography.hazmat.primitives.asymmetric import padding
|
|
9
|
+
from cryptography.hazmat.primitives import hashes
|
|
10
|
+
from cryptography.hazmat.primitives.serialization import load_pem_private_key
|
|
11
|
+
|
|
12
|
+
def debuglog():
|
|
13
|
+
local, host, remote = sys.argv[1].split('-')
|
|
14
|
+
if host != '0x0':
|
|
15
|
+
print('unexpected debug log host', host)
|
|
16
|
+
sys.exit(1)
|
|
17
|
+
|
|
18
|
+
encrypted = ('.') in remote
|
|
19
|
+
remote = remote.split('.')[0]
|
|
20
|
+
ext = '.enc' if encrypted else '.zip'
|
|
21
|
+
url = f'https://0x0.com/{remote}{ext}'
|
|
22
|
+
return SimpleNamespace(local=local, host=host, remote=remote, encrypted=encrypted, ext=ext, url=url)
|
|
23
|
+
|
|
24
|
+
def download():
|
|
25
|
+
debuglog.downloaded = f'logs/{debuglog.local}{debuglog.ext}'
|
|
26
|
+
print(debuglog.url, '=>', debuglog.downloaded)
|
|
27
|
+
logs = os.path.dirname(log)
|
|
28
|
+
if not os.path.exists(logs):
|
|
29
|
+
os.makedirs(logs)
|
|
30
|
+
urllib.request.urlretrieve(debuglog.url, debuglog.downloaded)
|
|
31
|
+
|
|
32
|
+
def decrypt():
|
|
33
|
+
if not debuglog.encrypted:
|
|
34
|
+
return
|
|
35
|
+
|
|
36
|
+
encrypted = debuglog.downloaded
|
|
37
|
+
debuglog.downloaded = f'logs/{debuglog.local}.zip'
|
|
38
|
+
|
|
39
|
+
with open(sys.argv[2], 'rb') as f:
|
|
40
|
+
private_key = load_pem_private_key(f.read(), password=None)
|
|
41
|
+
with open(encrypted, 'rb') as f:
|
|
42
|
+
encrypted_data = f.read()
|
|
43
|
+
with open(debuglog.downloaded, 'wb') as f:
|
|
44
|
+
f.write(private_key.decrypt(encrypted_data, padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None)))
|
|
45
|
+
|
|
46
|
+
def show():
|
|
47
|
+
with ZipFile(debuglod.downloaded) as f:
|
|
48
|
+
for name in f.namelist():
|
|
49
|
+
if not '/' in name:
|
|
50
|
+
print('Unexpected', name, 'in', sys.argv[1])
|
|
51
|
+
sys.exit(1)
|
|
52
|
+
print(name)
|
|
53
|
+
f.extractall(path='logs')
|
|
54
|
+
os.remove(debuglog.downloaded)
|
|
55
|
+
print(debuglog.local)
|
|
56
|
+
|
|
57
|
+
debuglog = debuglog()
|
|
58
|
+
download()
|
|
59
|
+
decrypt()
|
|
60
|
+
show()
|
package/bin/release.js
CHANGED
|
@@ -8448,7 +8448,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
8448
8448
|
"package.json"(exports, module) {
|
|
8449
8449
|
module.exports = {
|
|
8450
8450
|
name: "zotero-plugin",
|
|
8451
|
-
version: "5.0.
|
|
8451
|
+
version: "5.0.28",
|
|
8452
8452
|
description: "Zotero plugin builder",
|
|
8453
8453
|
homepage: "https://github.com/retorquere/zotero-plugin/wiki",
|
|
8454
8454
|
bin: {
|
package/debug-log.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.DebugLog = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
+
const pkg = require('./package.json');
|
|
6
7
|
const UZip = tslib_1.__importStar(require("uzip"));
|
|
7
8
|
class DebugLogSender {
|
|
8
9
|
constructor() {
|
|
@@ -88,6 +89,7 @@ class DebugLogSender {
|
|
|
88
89
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
89
90
|
const zip = new Uint8Array(UZip.encode(files));
|
|
90
91
|
let blob;
|
|
92
|
+
let ext = '';
|
|
91
93
|
if (pubkey) {
|
|
92
94
|
try {
|
|
93
95
|
const subtle = Zotero.getMainWindow().crypto.subtle;
|
|
@@ -99,6 +101,7 @@ class DebugLogSender {
|
|
|
99
101
|
const publicKey = await subtle.importKey('spki', keyBuffer, { name: 'RSA-OAEP', hash: 'SHA-256' }, true, ['encrypt']);
|
|
100
102
|
const encrypted = await subtle.encrypt({ name: 'RSA-OAEP' }, publicKey, zip);
|
|
101
103
|
blob = new Blob([encrypted], { type: 'application/octet-stream' });
|
|
104
|
+
ext = '.enc';
|
|
102
105
|
}
|
|
103
106
|
catch (err) {
|
|
104
107
|
Services.prompt.alert(null, `Log encryption for ${plugin} failed`, err.message);
|
|
@@ -107,21 +110,21 @@ class DebugLogSender {
|
|
|
107
110
|
if (!blob)
|
|
108
111
|
blob = new Blob([zip], { type: 'application/zip' });
|
|
109
112
|
const formData = new FormData();
|
|
110
|
-
formData.append('file', blob, `${key}.zip`);
|
|
113
|
+
formData.append('file', blob, `${key}${ext || '.zip'}`);
|
|
111
114
|
formData.append('expire', `${7 * 24}`);
|
|
112
115
|
try {
|
|
113
116
|
const response = await fetch('https://0x0.st', {
|
|
114
117
|
method: 'POST',
|
|
115
118
|
body: formData,
|
|
116
119
|
headers: {
|
|
117
|
-
'User-Agent':
|
|
120
|
+
'User-Agent': `Zotero-plugin/${pkg.version}`,
|
|
118
121
|
},
|
|
119
122
|
});
|
|
120
123
|
const body = await response.text();
|
|
121
124
|
const id = body.match(/https:\/\/0x0.st\/([A-Z0-9]+)\.zip/i);
|
|
122
125
|
if (!id)
|
|
123
126
|
throw new Error(body);
|
|
124
|
-
Services.prompt.alert(null, `Debug log ID for ${plugin}`, `${key}-0x0-${id[1]}`);
|
|
127
|
+
Services.prompt.alert(null, `Debug log ID for ${plugin}`, `${key}-0x0-${id[1]}{ext}`);
|
|
125
128
|
}
|
|
126
129
|
catch (err) {
|
|
127
130
|
Services.prompt.alert(null, `Could not post debug log for ${plugin}`, err.message);
|