zotero-plugin 5.0.31 → 5.0.32

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.
@@ -6,9 +6,6 @@ from zipfile import ZipFile
6
6
  from types import SimpleNamespace
7
7
  from pathlib import Path
8
8
 
9
- from Cryptodome.PublicKey import RSA
10
- from Cryptodome.Cipher import PKCS1_OAEP
11
-
12
9
  def oops(*args):
13
10
  print(*args)
14
11
  sys.exit(1)
@@ -33,24 +30,31 @@ def debuglog():
33
30
  references = ('.refs' in tags)
34
31
  cypher_rsa = None
35
32
  if encrypted:
36
- if len(len(sys.argv) != 3):
33
+ if len(sys.argv) != 3:
37
34
  oops('no private key provided')
38
35
  if Path(sys.argv[2]).suffix != '.pem':
39
36
  oops('private key must be a .pem')
40
37
 
41
- url = f'https://0x0.com/{remote}.zip'
42
- SimpleNamespace(key=key, host=host, remote=remote, encrypted=encrypted, references=references, url=url),
38
+ url = f'https://0x0.st/{remote}.zip'
39
+ return SimpleNamespace(key=key, host=host, remote=remote, encrypted=encrypted, references=references, url=url)
43
40
  debuglog = debuglog()
44
41
 
42
+ if debuglog.encrypted:
43
+ from cryptography.hazmat.primitives.asymmetric import padding
44
+ from cryptography.hazmat.primitives import hashes
45
+ from cryptography.hazmat.primitives.serialization import load_pem_private_key
46
+ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
47
+ from cryptography.hazmat.backends import default_backend
48
+
45
49
  def download():
46
50
  debuglog.zip = f'logs/{debuglog.key}.zip'
47
- print(debuglog.url, '=>', debuglog.zip)
48
- logs = os.path.dirname(log)
51
+ logs = os.path.dirname(debuglog.zip)
49
52
  if not os.path.exists(logs):
50
53
  os.makedirs(logs)
54
+ print(debuglog.url, '=>', debuglog.zip)
51
55
  urllib.request.urlretrieve(debuglog.url, debuglog.zip)
52
56
 
53
- def decrypt(encrypted, iv, target):
57
+ def decrypt(symmetric_key, encrypted, iv, target):
54
58
  encrypted = encrypted.read()
55
59
  iv = iv.read()
56
60
 
@@ -58,10 +62,11 @@ def decrypt(encrypted, iv, target):
58
62
  tag = encrypted[-16:]
59
63
  ciphertext = encrypted[:-16]
60
64
 
61
- cipher_aes = AES.new(symmetric_key, AES.MODE_GCM, nonce=iv)
62
- decrypted = cipher_aes.decrypt_and_verify(ciphertext, tag)
65
+ cipher = Cipher(algorithms.AES(symmetric_key), modes.GCM(iv, tag), backend=default_backend())
66
+ decryptor = cipher.decryptor()
67
+
63
68
  with open(target, 'wb') as f:
64
- f.write(decrypted)
69
+ f.write(decryptor.update(ciphertext) + decryptor.finalize())
65
70
 
66
71
  def unpack():
67
72
  symmetric_key = None
@@ -70,35 +75,39 @@ def unpack():
70
75
  files = zip.namelist()
71
76
 
72
77
  symmetric_key = [f for f in files if Path(f).suffix == '.key']
73
- match len(private_key):
78
+ match len(symmetric_key):
74
79
  case 0:
75
80
  if debuglog.encrypted:
76
81
  oops('No key found in', debuglog.key)
77
82
 
78
83
  case 1:
79
84
  with open(sys.argv[2], 'rb') as f:
80
- private_key = RSA.import_key(f.read())
81
- cipher_rsa = PKCS1_OAEP.new(private_key)
85
+ private_key = load_pem_private_key(f.read(), password=None, backend=default_backend())
82
86
  with zip.open(symmetric_key[0]) as f:
83
- symmetric_key = cipher_rsa.decrypt(f.read())
87
+ symmetric_key = private_key.decrypt(f.read(), padding.OAEP(
88
+ mgf=padding.MGF1(algorithm=hashes.SHA256()),
89
+ algorithm=hashes.SHA256(),
90
+ label=None
91
+ ))
84
92
 
85
93
  case _:
86
94
  oops('Multiple keys found in', debuglog.key)
87
95
 
88
96
  for name in files:
89
97
  match Path(name).suffix:
90
- case '.key' | '.iv'
98
+ case '.key' | '.iv':
91
99
  pass
92
- case '.enc'
93
- print(Path('logs') / name.with_suffix('.zip'), '(encrypted)')
94
- iv = next((f for f in filename_list if f == Path(name).with_suffix('.iv')), None)
100
+ case '.enc':
101
+ print(Path('logs') / Path(name).with_suffix('.zip'), '(encrypted)')
102
+ iv = next((f for f in files if f == Path(name).with_suffix('.iv')), None)
103
+ print(name, iv, files)
95
104
 
96
- with zip.open(name) as f_data, open(iv) as f_iv:
97
- decrypt(f_data, f_iv, str(Path('logs') / name))
105
+ with zip.open(name) as f_data, zip.open(iv) as f_iv:
106
+ decrypt(symmetric_key, f_data, f_iv, str(Path('logs') / name))
98
107
 
99
108
  case _:
100
109
  print(Path('logs') / name)
101
110
  f.extract(name, path='logs')
102
111
 
103
112
  download()
104
- decrypt()
113
+ unpack()
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.31",
8451
+ version: "5.0.32",
8452
8452
  description: "Zotero plugin builder",
8453
8453
  homepage: "https://github.com/retorquere/zotero-plugin/wiki",
8454
8454
  bin: {
package/bin/start.py CHANGED
@@ -74,7 +74,7 @@ class Config:
74
74
  self.preference['extensions.lastAppVersion'] = None
75
75
 
76
76
  def find_source(self):
77
- for rdf in glob.glob(os.path.join('*', 'install.rdf')):
77
+ for rdf in glob.glob(os.path.join('*', 'manifest.json')):
78
78
  return os.path.dirname(rdf)
79
79
  if os.path.isdir('build'):
80
80
  return 'build'
@@ -143,8 +143,8 @@ if config.plugin.build:
143
143
  if config.zotero.db:
144
144
  shutil.copyfile(config.zotero.db, os.path.join(config.profile.path, 'zotero', 'zotero.sqlite'))
145
145
 
146
- for plugin_id in ET.parse(os.path.join(config.plugin.source, 'install.rdf')).getroot().findall('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description/{http://www.mozilla.org/2004/em-rdf#}id'):
147
- plugin_path = os.path.join(config.profile.path, 'extensions', plugin_id.text)
146
+ with open(os.path.join(config.plugin.source, 'manifest.json')) as f:
147
+ plugin_path = os.path.join(config.profile.path, 'extensions', json.load(f)['applications']['zotero']['id'])
148
148
  with open(plugin_path, 'w') as f:
149
149
  sources = config.plugin.source
150
150
  if sources[-1] not in '/\\': sources += os.sep
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin",
3
- "version": "5.0.31",
3
+ "version": "5.0.32",
4
4
  "description": "Zotero plugin builder",
5
5
  "homepage": "https://github.com/retorquere/zotero-plugin/wiki",
6
6
  "bin": {