zotero-plugin 6.3.2 → 6.4.0

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/README.md CHANGED
@@ -124,3 +124,52 @@ then when you execute `npm start`, zotero will start up with the latest build of
124
124
  **DO CREATE A BACKUP OF YOUR ZOTERO DATA *AND* YOUR ZOTERO PROFILE BEFORE USING THIS THE FIRST TIME**
125
125
 
126
126
  `zotero-start` will **blindly** trust you've set it up right and will **alter data** in the profile
127
+
128
+ # Getting logging from your users
129
+
130
+ In your startup, you can call
131
+
132
+ ```
133
+ import { DebugLog } from 'zotero-plugin/debug-log'
134
+ DebugLog.register('<your plugin name>', ['your-plugin.', 'fileHandler.pdf'])
135
+ ```
136
+
137
+ and you will get an entry in the Help menu that will allow your users to upload their debug log for diagnosis. You can fetch the log by
138
+ running
139
+
140
+ ```
141
+ zp-fetch-log <the ID that the user was presented with>
142
+ ```
143
+
144
+ If you want to be extra secure, you can encrypt the logs before they are sent; first, run
145
+
146
+ ```
147
+ zp-keypair
148
+ ```
149
+
150
+ which will generate a keypair. Remember the passphrase, it cannot be recovered, but if you do forget, you can generate a new keypair. Logs
151
+ sent with the old keypair cannot be decrypted, so if you forget your passphrase, you will have to put out a new release of your plugin.
152
+
153
+ add this to your esbuild script:
154
+
155
+ ```
156
+ const { pem } = require('zotero-plugin/esbuild')
157
+ ```
158
+
159
+ and add `pem` to your plugins in the esbuild config:
160
+
161
+ ```
162
+ ...
163
+ plugins: [pem],
164
+ ...
165
+ ```
166
+
167
+ and in your code, register using
168
+
169
+ ```
170
+ DebugLog.register('<your plugin name>', ['your-plugin.', 'fileHandler.pdf'], require('./public.pem'))
171
+ ```
172
+
173
+ Logs are sent to/retrieved from 0x0.st
174
+
175
+ The preferences you list will be included in the log; if a preference ends with a period (`.`), all preferences under it will be included
package/bin/fetch-log.mjs CHANGED
@@ -11,7 +11,7 @@ import { Entry as KeyRingEntry } from "@napi-rs/keyring";
11
11
  import prompts from "prompts";
12
12
 
13
13
  // package.json
14
- var version = "6.3.2";
14
+ var version = "6.4.0";
15
15
 
16
16
  // bin/crypto.ts
17
17
  import crypto from "crypto";
@@ -92,7 +92,7 @@ async function main() {
92
92
  if (entry.isDirectory) continue;
93
93
  const m2 = entry.name.match(/(?<filename>.+)\.(?<type>key|enc|iv)$/i);
94
94
  let filename = m2?.groups.filename || entry.name;
95
- const type = (m2?.groups.ext || "").toLowerCase();
95
+ const type = (m2?.groups.type || "").toLowerCase();
96
96
  if (type && !options.encrypted) oops("unexpected", type, "file in non-encrypted log");
97
97
  if (type === "key") {
98
98
  decryptionKey = crypto2.privateDecrypt({
package/bin/link.mjs CHANGED
@@ -15,7 +15,7 @@ var root_default = process.cwd();
15
15
 
16
16
  // bin/link.ts
17
17
  var pkg = { ...__require(path.join(root_default, "package.json")) };
18
- if (!pkg.id) pkg.id = `${pkg.name.replace(/^zotero-/, "")}@${pkg.author.email.replace(/.*@/, "")}`.toLowerCase();
18
+ if (!pkg.id) pkg.id = `${pkg.name}@${pkg.author.email.replace(/.*@/, "")}`.toLowerCase();
19
19
  if (pkg.xpi) Object.assign(pkg, pkg.xpi);
20
20
  var build = path.join(root_default, "build");
21
21
  var zotero = process.argv[2];
package/debug-log.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare class Bundler {
7
7
  get zip(): ArrayBuffer;
8
8
  get name(): string;
9
9
  id(remote: string): string;
10
+ formData(expire?: number): FormData;
10
11
  }
11
12
  declare class DebugLogSender {
12
13
  id: {
package/debug-log.js CHANGED
@@ -55,8 +55,16 @@ class Bundler {
55
55
  id(remote) {
56
56
  return `${this.key}-${remote}${this.#refs ? '.refs' : ''}${this.#pubkey ? '.enc' : ''}`;
57
57
  }
58
+ formData(expire = 7) {
59
+ const blob = new Blob([this.zip], { type: 'application/zip' });
60
+ const formData = new FormData();
61
+ formData.append('file', blob, this.name);
62
+ formData.append('expire', `${expire * 24}`);
63
+ return formData;
64
+ }
58
65
  }
59
66
  exports.Bundler = Bundler;
67
+ const zotero_prefs_root = 'extensions.zotero.';
60
68
  class DebugLogSender {
61
69
  id = {
62
70
  menu: 'debug-log-sender-menu',
@@ -128,14 +136,10 @@ class DebugLogSender {
128
136
  let rdf = await this.rdf();
129
137
  if (rdf)
130
138
  await bundler.add('items.rdf', rdf, true);
131
- const blob = new Blob([bundler.zip], { type: 'application/zip' });
132
- const formData = new FormData();
133
- formData.append('file', blob, bundler.name);
134
- formData.append('expire', `${7 * 24}`);
135
139
  try {
136
140
  const response = await fetch('https://0x0.st', {
137
141
  method: 'POST',
138
- body: formData,
142
+ body: bundler.formData(),
139
143
  headers: {
140
144
  'User-Agent': `Zotero-plugin/${pkg.version}`,
141
145
  },
@@ -154,7 +158,12 @@ class DebugLogSender {
154
158
  const prefs = {};
155
159
  const names = [];
156
160
  for (let pref of preferences) {
157
- pref = pref.replace(/^:/, 'extensions.zotero.');
161
+ if (pref[0] === ':') {
162
+ pref = pref.substring(1);
163
+ }
164
+ else if (!pref.startsWith(zotero_prefs_root)) {
165
+ pref = zotero_prefs_root + pref;
166
+ }
158
167
  if (pref.endsWith('.')) {
159
168
  const childkeys = Services.prefs.getBranch(pref).getChildList('', {});
160
169
  for (const key of childkeys) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin",
3
- "version": "6.3.2",
3
+ "version": "6.4.0",
4
4
  "description": "Zotero plugin builder",
5
5
  "homepage": "https://github.com/retorquere/zotero-plugin/wiki",
6
6
  "bin": {