zotero-plugin 5.0.25 → 5.0.26

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/keypair CHANGED
@@ -2,24 +2,53 @@
2
2
 
3
3
  from cryptography.hazmat.primitives.asymmetric import rsa
4
4
  from cryptography.hazmat.primitives import serialization
5
- import sys, os
5
+ import sys, os, subprocess
6
6
 
7
7
  script_name = os.path.basename(sys.argv[0])
8
- if len(sys.argv) != 2:
9
- print(f'Usage: {script_name} <directory>')
8
+ if len(sys.argv) != 3:
9
+ print(f'Usage: {script_name} <private key> <public key>')
10
10
  sys.exit(1)
11
11
 
12
- target = sys.argv[1]
13
- if not os.path.isdir(target):
14
- print(f'Error: {target} is not a directory.')
12
+ script_name, private_key_file, public_key_file = sys.argv
13
+
14
+ def controlled(file_path):
15
+ created_file = False
16
+
17
+ try:
18
+ if not os.path.exists(file_path):
19
+ os.makedirs(os.path.dirname(os.path.abspath(file_path)), exist_ok=True)
20
+ open(file_path, 'a').close()
21
+ created_file = True
22
+
23
+ result = subprocess.run(
24
+ ['git', 'check-ignore', '--quiet', file_path],
25
+ cwd=os.path.dirname(os.path.abspath(file_path)),
26
+ check=False
27
+ )
28
+
29
+ return result.returncode != 0
30
+
31
+ except FileNotFoundError:
32
+ print("Git is not installed or not in the system's PATH.")
15
33
  sys.exit(1)
16
34
 
17
- valid_files = {'public.pem', 'private.pem'}
18
- all_files = set(os.listdir(target))
35
+ except subprocess.CalledProcessError as e:
36
+ print(f'Error checking ignore status: {e}')
37
+ sys.exit(1)
19
38
 
20
- if not all_files.issubset(valid_files):
21
- print(f'Error: Directory contains invalid files: {all_files - valid_files}')
22
- sys.exit(1)
39
+ finally:
40
+ if created_file and os.path.exists(file_path):
41
+ os.remove(file_path)
42
+ def check_name(kind, file_path):
43
+ if os.path.basename(file_path) != f'{kind}.pem':
44
+ print(f'The {kind} key file must be named {kind}.pem')
45
+ sys.exit(1)
46
+
47
+ if (kind == 'private') == controlled(file_path):
48
+ print(f'The {kind} key file must {"not " if kind == "private" else ""}be under source control')
49
+ sys.exit(1)
50
+ check_name('private', private_key_file)
51
+ check_name('public', public_key_file)
23
52
 
24
53
  private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
25
54
  private_pem = private_key.private_bytes(
@@ -27,7 +56,8 @@ private_pem = private_key.private_bytes(
27
56
  format=serialization.PrivateFormat.PKCS8,
28
57
  encryption_algorithm=serialization.NoEncryption()
29
58
  )
30
- with open(os.path.join(target, 'private.pem'), 'w') as f:
59
+ with open(os.path.join(private_key_file), 'w') as f:
60
+ print('creating private key', private_key_file)
31
61
  f.write(private_pem.decode('utf-8'))
32
62
 
33
63
  public_key = private_key.public_key()
@@ -35,5 +65,6 @@ public_pem = public_key.public_bytes(
35
65
  encoding=serialization.Encoding.PEM,
36
66
  format=serialization.PublicFormat.SubjectPublicKeyInfo
37
67
  )
38
- with open(os.path.join(target, 'public.pem'), 'w') as f:
68
+ with open(os.path.join(public_key_file), 'w') as f:
69
+ print('creating public key', public_key_file)
39
70
  f.write(public_pem.decode('utf-8'))
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.25",
8451
+ version: "5.0.26",
8452
8452
  description: "Zotero plugin builder",
8453
8453
  homepage: "https://github.com/retorquere/zotero-plugin/wiki",
8454
8454
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin",
3
- "version": "5.0.25",
3
+ "version": "5.0.26",
4
4
  "description": "Zotero plugin builder",
5
5
  "homepage": "https://github.com/retorquere/zotero-plugin/wiki",
6
6
  "bin": {