@pipeup/share 0.7.0 → 0.8.0-beta.1
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/dist/cli.js +109 -125
- package/dist/pipeup+share.min.js +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -166,82 +166,80 @@ function n(e3) {
|
|
|
166
166
|
}
|
|
167
167
|
var a = /^[A-Za-z0-9_-]{43}$/;
|
|
168
168
|
var s = /* @__PURE__ */ new Map();
|
|
169
|
-
async function
|
|
169
|
+
async function d() {
|
|
170
170
|
let t2 = await crypto.subtle.generateKey({ name: "Ed25519" }, false, ["sign", "verify"]);
|
|
171
171
|
return { publicKey: e(new Uint8Array(await crypto.subtle.exportKey("raw", t2.publicKey))), privateKey: t2.privateKey };
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
173
|
+
async function l(t2, r2) {
|
|
174
174
|
let n2 = await crypto.subtle.sign({ name: "Ed25519" }, t2.privateKey, r2);
|
|
175
175
|
return e(new Uint8Array(n2));
|
|
176
176
|
}
|
|
177
|
-
var u = "
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var h = ["Red", "Orange", "Yellow", "Green", "Teal", "Blue", "Purple", "Pink", "Brown", "Grey"];
|
|
181
|
-
function p(e3) {
|
|
177
|
+
var u = ["Otter", "Fox", "Owl", "Bear", "Rabbit"];
|
|
178
|
+
var c = ["Red", "Orange", "Yellow", "Green", "Teal", "Blue", "Purple", "Pink", "Brown", "Grey"];
|
|
179
|
+
function h(e3) {
|
|
182
180
|
let t2 = 2166136261;
|
|
183
181
|
for (let r2 = 0; r2 < e3.length; r2++) t2 = Math.imul(t2 ^ e3.charCodeAt(r2), 16777619);
|
|
184
182
|
return t2 = Math.imul(t2 ^ t2 >>> 16, 2246822507), t2 = Math.imul(t2 ^ t2 >>> 13, 3266489909), (t2 ^ t2 >>> 16) >>> 0;
|
|
185
183
|
}
|
|
186
|
-
var
|
|
187
|
-
var
|
|
188
|
-
let t2 = e3.name.replace(/^AI assistant
|
|
184
|
+
var p = (e3) => `${c[((e4) => Math.floor(h(e4) / u.length) % c.length)(e3)]} ${u[((e4) => h(e4) % u.length)(e3)]}`;
|
|
185
|
+
var f = (e3) => {
|
|
186
|
+
let t2 = e3.name.replace(/^AI assistant \xb7 /, "") || p(e3.author);
|
|
189
187
|
return e3.alike ? `${t2} \xB7 ${(function(e4) {
|
|
190
|
-
let t3 =
|
|
188
|
+
let t3 = h(`id:${e4}`), r2 = "";
|
|
191
189
|
for (let e5 = 0; e5 < 4; e5++, t3 >>>= 5) r2 += "0123456789ABCDEFGHJKMNPQRSTVWXYZ"[31 & t3];
|
|
192
190
|
return r2;
|
|
193
191
|
})(e3.author)}` : t2;
|
|
194
192
|
};
|
|
195
|
-
var
|
|
196
|
-
var
|
|
197
|
-
var
|
|
198
|
-
var
|
|
199
|
-
var
|
|
200
|
-
var
|
|
201
|
-
var
|
|
202
|
-
var
|
|
203
|
-
var
|
|
204
|
-
var
|
|
205
|
-
var
|
|
193
|
+
var m = "AI assistant";
|
|
194
|
+
var g = (e3) => e3 === m || e3.startsWith(`${m} `);
|
|
195
|
+
var y = 1e4;
|
|
196
|
+
var w = 2 ** 40;
|
|
197
|
+
var b = 2 ** 47;
|
|
198
|
+
var x = 1e4;
|
|
199
|
+
var v = /^[0-9a-f]{8}$/;
|
|
200
|
+
var k = /^[A-Za-z0-9_-]{43}$/;
|
|
201
|
+
var A = /^(?:[^\s@<>"]{1,64}@[^\s@<>"]{1,190}\.[^\s@<>"]{2,24}|gh:[A-Za-z0-9-]{1,39})$/;
|
|
202
|
+
var E = /^(?:[A-Za-z0-9_-]{43}|(?:host|gh):[A-Za-z0-9._@-]{1,64})$/;
|
|
203
|
+
var $ = /^[A-Za-z0-9_-]{43}$/;
|
|
206
204
|
var S = /* @__PURE__ */ new Set(["create", "reply", "edit", "delete", "resolve", "reopen", "addressed", "react", "unreact", "seen", "contact", "uncontact"]);
|
|
207
|
-
var
|
|
208
|
-
var
|
|
209
|
-
async function
|
|
205
|
+
var M = /^(?:\p{Regional_Indicator}{2}|[#*0-9]\uFE0F?\u20E3|\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?)*)$/u;
|
|
206
|
+
var C = (e3) => "string" == typeof e3 && M.test(e3) && [...e3].length <= 16;
|
|
207
|
+
async function N(e3, t2) {
|
|
210
208
|
if (e3.author !== t2.publicKey) throw new Error("pipeup: an op must be signed by its author");
|
|
211
|
-
return { body: e3, sig: await
|
|
209
|
+
return { body: e3, sig: await l(t2, r(n(e3))) };
|
|
212
210
|
}
|
|
213
|
-
var
|
|
214
|
-
var
|
|
211
|
+
var q = (e3, t2) => "string" == typeof e3 && e3.length <= t2;
|
|
212
|
+
var O = (e3) => !!e3 && "object" == typeof e3;
|
|
215
213
|
var j = (e3) => "number" == typeof e3 && Number.isFinite(e3) && e3 >= 0 && e3 <= 1;
|
|
216
|
-
function
|
|
217
|
-
if (!
|
|
214
|
+
function P2(e3) {
|
|
215
|
+
if (!O(e3)) return false;
|
|
218
216
|
let { id: t2, path: r2, fingerprint: n2, snapshot: i, quote: o, point: a2, view: s2 } = e3;
|
|
219
|
-
if (!(
|
|
217
|
+
if (!(q(r2, 2e3) && q(i, 500) && "string" == typeof n2 && v.test(n2) && (void 0 === t2 || q(t2, 200) && "" !== t2) && (void 0 === o || O(o) && q(o.exact, x) && "" !== o.exact && q(o.prefix, 64) && q(o.suffix, 64)) && (void 0 === a2 || O(a2) && j(a2.x) && j(a2.y)))) return false;
|
|
220
218
|
if (void 0 !== s2) {
|
|
221
|
-
if (!
|
|
219
|
+
if (!O(s2) || Array.isArray(s2)) return false;
|
|
222
220
|
let e4 = Object.entries(s2);
|
|
223
|
-
if (e4.length > 16 || !e4.every(([e5, t3]) => e5.length <= 64 &&
|
|
221
|
+
if (e4.length > 16 || !e4.every(([e5, t3]) => e5.length <= 64 && q(t3, 200))) return false;
|
|
224
222
|
}
|
|
225
223
|
return true;
|
|
226
224
|
}
|
|
227
|
-
function
|
|
228
|
-
if (!
|
|
225
|
+
function T(e3) {
|
|
226
|
+
if (!O(e3)) return false;
|
|
229
227
|
let { body: t2, sig: r2 } = e3;
|
|
230
|
-
if ("string" != typeof r2 || !
|
|
228
|
+
if ("string" != typeof r2 || !O(t2) || JSON.stringify({ body: t2, sig: r2 }).length > 262144) return false;
|
|
231
229
|
let n2 = t2;
|
|
232
|
-
if (1 !== n2.v || "string" != typeof n2.id || !
|
|
230
|
+
if (1 !== n2.v || "string" != typeof n2.id || !k.test(n2.id) || !S.has(n2.kind) || !q(n2.doc, 64) || "" === n2.doc || "string" != typeof n2.thread || !k.test(n2.thread) || "string" != typeof n2.author || !$.test(n2.author) || "string" != typeof n2.name || n2.name.length > 80 || n2.name !== n2.name.trim() || "number" != typeof n2.clock || !Number.isSafeInteger(n2.clock) || n2.clock < 1 || n2.clock > w || "number" != typeof n2.at || !Number.isSafeInteger(n2.at) || n2.at < 0 || n2.at > b || void 0 !== n2.text && (!q(n2.text, y) || n2.text !== n2.text.trim()) || void 0 !== n2.target && ("string" != typeof n2.target || !k.test(n2.target)) || ("create" === n2.kind || "reply" === n2.kind || "edit" === n2.kind || "addressed" === n2.kind) && !n2.text || ("reply" === n2.kind || "edit" === n2.kind || "delete" === n2.kind) && !n2.target) return false;
|
|
233
231
|
if (void 0 !== n2.mentions) {
|
|
234
232
|
if ("create" !== n2.kind && "reply" !== n2.kind && "edit" !== n2.kind || !Array.isArray(n2.mentions) || n2.mentions.length > 20) return false;
|
|
235
233
|
let e4 = n2.text?.length ?? 0;
|
|
236
234
|
for (let t3 of n2.mentions) {
|
|
237
|
-
if (!
|
|
235
|
+
if (!O(t3) || !Number.isSafeInteger(t3.start) || !Number.isSafeInteger(t3.end)) return false;
|
|
238
236
|
let { start: r3, end: n3, ref: i } = t3;
|
|
239
|
-
if (r3 < 0 || n3 <= r3 || n3 > e4 || "string" != typeof i ||
|
|
237
|
+
if (r3 < 0 || n3 <= r3 || n3 > e4 || "string" != typeof i || !E.test(i)) return false;
|
|
240
238
|
}
|
|
241
239
|
}
|
|
242
|
-
return !(!("contact" !== n2.kind || "string" == typeof n2.text &&
|
|
240
|
+
return !(!("contact" !== n2.kind || "string" == typeof n2.text && A.test(n2.text)) || "seen" === n2.kind && !n2.target || !("react" !== n2.kind && "unreact" !== n2.kind || n2.target && C(n2.text)) || !("create" !== n2.kind || n2.id === n2.thread && P2(n2.anchor)));
|
|
243
241
|
}
|
|
244
|
-
function
|
|
242
|
+
function I(i) {
|
|
245
243
|
return (async function(r2, n2, i2) {
|
|
246
244
|
if (!a.test(r2)) return false;
|
|
247
245
|
try {
|
|
@@ -260,18 +258,18 @@ function F(i) {
|
|
|
260
258
|
}
|
|
261
259
|
})(i.body.author, r(n(i.body)), i.sig);
|
|
262
260
|
}
|
|
263
|
-
function
|
|
261
|
+
function F(e3, t2) {
|
|
264
262
|
return e3.body.clock !== t2.body.clock ? e3.body.clock - t2.body.clock : e3.body.at !== t2.body.at ? e3.body.at - t2.body.at : e3.body.author !== t2.body.author ? e3.body.author < t2.body.author ? -1 : 1 : e3.body.id !== t2.body.id ? e3.body.id < t2.body.id ? -1 : 1 : 0;
|
|
265
263
|
}
|
|
266
|
-
function
|
|
264
|
+
function D(e3, t2, r2, n2, i, o) {
|
|
267
265
|
let a2 = { id: e3, author: t2, name: r2, text: n2, at: i, edited: false, deleted: false, replies: [], reactions: [] };
|
|
268
266
|
return o?.length && (a2.mentions = o), a2;
|
|
269
267
|
}
|
|
270
|
-
async function
|
|
268
|
+
async function R(t2) {
|
|
271
269
|
let i = { ...t2, id: void 0, thread: "create" === t2.kind ? void 0 : t2.thread }, o = await crypto.subtle.digest("SHA-256", r(n(i)));
|
|
272
270
|
return e(new Uint8Array(o));
|
|
273
271
|
}
|
|
274
|
-
var
|
|
272
|
+
var L = class {
|
|
275
273
|
constructor(e3) {
|
|
276
274
|
this.doc = e3;
|
|
277
275
|
}
|
|
@@ -288,10 +286,10 @@ var K = class {
|
|
|
288
286
|
threads() {
|
|
289
287
|
return (function(e3) {
|
|
290
288
|
let t2 = /* @__PURE__ */ new Map(), r2 = /* @__PURE__ */ new Map(), n2 = /* @__PURE__ */ new Map();
|
|
291
|
-
for (let { body: i2 } of [...e3].sort(
|
|
289
|
+
for (let { body: i2 } of [...e3].sort(F)) {
|
|
292
290
|
if (i2.name && n2.set(i2.author, i2.name), "create" === i2.kind) {
|
|
293
291
|
if (t2.has(i2.id) || !i2.anchor || void 0 === i2.text) continue;
|
|
294
|
-
let e5 =
|
|
292
|
+
let e5 = D(i2.id, i2.author, i2.name, i2.text, i2.at, i2.mentions);
|
|
295
293
|
t2.set(i2.id, { id: i2.id, anchor: i2.anchor, root: e5, resolved: false }), r2.set(i2.id, { comment: e5, thread: i2.id });
|
|
296
294
|
continue;
|
|
297
295
|
}
|
|
@@ -309,7 +307,7 @@ var K = class {
|
|
|
309
307
|
if (o2 && o2.thread === i2.thread) {
|
|
310
308
|
if ("reply" === i2.kind) {
|
|
311
309
|
if (r2.has(i2.id) || void 0 === i2.text) continue;
|
|
312
|
-
let t3 =
|
|
310
|
+
let t3 = D(i2.id, i2.author, i2.name, i2.text, i2.at, i2.mentions);
|
|
313
311
|
e4.root.replies.push(t3), r2.set(i2.id, { comment: t3, thread: i2.thread });
|
|
314
312
|
continue;
|
|
315
313
|
}
|
|
@@ -335,14 +333,14 @@ var K = class {
|
|
|
335
333
|
for (let t3 of e4.reactions) for (let e5 of t3.by) e5.name ||= n2.get(e5.author) ?? "";
|
|
336
334
|
}
|
|
337
335
|
let i = /* @__PURE__ */ new Map(), o = (e4, t3) => {
|
|
338
|
-
let r3 =
|
|
336
|
+
let r3 = f({ author: e4, name: t3 }).toLowerCase();
|
|
339
337
|
(i.get(r3) ?? i.set(r3, /* @__PURE__ */ new Set()).get(r3)).add(e4);
|
|
340
338
|
};
|
|
341
339
|
for (let { comment: e4 } of r2.values()) {
|
|
342
340
|
o(e4.author, e4.name);
|
|
343
341
|
for (let t3 of e4.reactions) for (let e5 of t3.by) o(e5.author, e5.name);
|
|
344
342
|
}
|
|
345
|
-
let a2 = (e4, t3) => (i.get(
|
|
343
|
+
let a2 = (e4, t3) => (i.get(f({ author: e4, name: t3 }).toLowerCase())?.size ?? 0) > 1;
|
|
346
344
|
for (let { comment: e4 } of r2.values()) {
|
|
347
345
|
a2(e4.author, e4.name) && (e4.alike = true);
|
|
348
346
|
for (let t3 of e4.reactions) for (let e5 of t3.by) a2(e5.author, e5.name) && (e5.alike = true);
|
|
@@ -353,39 +351,71 @@ var K = class {
|
|
|
353
351
|
async add(e3) {
|
|
354
352
|
let t2 = [];
|
|
355
353
|
for (let r2 of e3) {
|
|
356
|
-
if (!
|
|
354
|
+
if (!T(r2) || r2.body.doc !== this.doc || this.ops.has(r2.body.id) || r2.body.id !== await R(r2.body) || !await I(r2)) continue;
|
|
357
355
|
let e4 = { body: r2.body, sig: r2.sig };
|
|
358
356
|
this.ops.set(e4.body.id, e4), this.clock = Math.max(this.clock, e4.body.clock), "create" === e4.body.kind && this.createAt.set(e4.body.author, Math.max(this.createAt.get(e4.body.author) ?? 0, e4.body.at)), this.threadAt.set(e4.body.thread, Math.max(this.threadAt.get(e4.body.thread) ?? 0, e4.body.at)), t2.push(e4);
|
|
359
357
|
}
|
|
360
358
|
return t2;
|
|
361
359
|
}
|
|
362
360
|
async append(e3, t2, r2) {
|
|
363
|
-
let n2 = { v: 1, ...r2, id: "", thread: "create" === r2.kind ? "" : r2.thread, doc: this.doc, author: e3.publicKey, name: t2, clock: Math.min(this.clock + 1,
|
|
364
|
-
n2.id = await
|
|
361
|
+
let n2 = { v: 1, ...r2, id: "", thread: "create" === r2.kind ? "" : r2.thread, doc: this.doc, author: e3.publicKey, name: t2, clock: Math.min(this.clock + 1, w), at: Math.min(Math.max(Date.now(), "create" === r2.kind ? (this.createAt.get(e3.publicKey) ?? 0) + 1 : (this.threadAt.get(r2.thread) ?? 0) + 1), b) };
|
|
362
|
+
n2.id = await R(n2);
|
|
365
363
|
let i = this.ops.get(n2.id);
|
|
366
364
|
if (i) return i;
|
|
367
365
|
"create" === n2.kind && (n2.thread = n2.id);
|
|
368
|
-
let [o] = await this.add([await
|
|
366
|
+
let [o] = await this.add([await N(n2, e3)]);
|
|
369
367
|
if (!o) throw new Error("pipeup: could not record this change");
|
|
370
368
|
return o;
|
|
371
369
|
}
|
|
372
370
|
};
|
|
373
|
-
var
|
|
374
|
-
function
|
|
371
|
+
var U = /^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;
|
|
372
|
+
function _() {
|
|
375
373
|
return `${(function(t2 = 16) {
|
|
376
374
|
return e(crypto.getRandomValues(new Uint8Array(t2)));
|
|
377
375
|
})(12)}:${e(crypto.getRandomValues(new Uint8Array(32)))}`;
|
|
378
376
|
}
|
|
379
|
-
async function
|
|
380
|
-
let r2 =
|
|
377
|
+
async function z(e3) {
|
|
378
|
+
let r2 = U.exec(e3.trim()), n2 = r2?.[1], i = r2?.[2];
|
|
381
379
|
if (!n2 || !i) throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');
|
|
382
380
|
return { id: n2, key: await crypto.subtle.importKey("raw", t(i), { name: "AES-GCM" }, false, ["encrypt", "decrypt"]) };
|
|
383
381
|
}
|
|
384
|
-
async function
|
|
382
|
+
async function H(t2, n2, i) {
|
|
385
383
|
let o = crypto.getRandomValues(new Uint8Array(12)), a2 = await crypto.subtle.encrypt({ name: "AES-GCM", iv: o, additionalData: r(i) }, t2, r(n2));
|
|
386
384
|
return { iv: e(o), data: e(new Uint8Array(a2)) };
|
|
387
385
|
}
|
|
388
|
-
var
|
|
386
|
+
var K = (e3) => `pipeup-file:${e3}`;
|
|
387
|
+
async function B(e3, n2, i) {
|
|
388
|
+
if (e3.length > 5e6) throw new Error("pipeup: this feedback file is too large");
|
|
389
|
+
let o, a2, s2;
|
|
390
|
+
try {
|
|
391
|
+
o = JSON.parse(e3);
|
|
392
|
+
} catch {
|
|
393
|
+
throw new Error("pipeup: this is not an Pipeup feedback file");
|
|
394
|
+
}
|
|
395
|
+
if (!o || "object" != typeof o || 1 !== o.pipeup || "string" != typeof o.doc) throw new Error("pipeup: this is not an Pipeup feedback file");
|
|
396
|
+
if (o.doc !== n2) throw new Error("pipeup: this feedback is for a different document");
|
|
397
|
+
if (!o.sealed) return Array.isArray(o.ops) ? o.ops : [];
|
|
398
|
+
if (!i) throw new Error("pipeup: this feedback is sealed, and this page has no document key");
|
|
399
|
+
if ("string" != typeof o.iv || "string" != typeof o.data) throw new Error("pipeup: this is not an Pipeup feedback file");
|
|
400
|
+
try {
|
|
401
|
+
a2 = await (async function(e4, n3, i2) {
|
|
402
|
+
try {
|
|
403
|
+
let o2 = await crypto.subtle.decrypt({ name: "AES-GCM", iv: t(n3.iv), additionalData: r(i2) }, e4, t(n3.data));
|
|
404
|
+
return new TextDecoder().decode(o2);
|
|
405
|
+
} catch {
|
|
406
|
+
throw new Error("pipeup: this feedback could not be opened with this document");
|
|
407
|
+
}
|
|
408
|
+
})(i, { iv: o.iv, data: o.data }, K(n2));
|
|
409
|
+
} catch {
|
|
410
|
+
throw new Error("pipeup: this feedback could not be opened with this document's key");
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
s2 = JSON.parse(a2);
|
|
414
|
+
} catch {
|
|
415
|
+
throw new Error("pipeup: this is not an Pipeup feedback file");
|
|
416
|
+
}
|
|
417
|
+
return Array.isArray(s2) ? s2 : [];
|
|
418
|
+
}
|
|
389
419
|
var G = /^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/;
|
|
390
420
|
var Z = class extends Error {
|
|
391
421
|
constructor(e3, t2, r2 = 1) {
|
|
@@ -404,7 +434,7 @@ var J = class e2 {
|
|
|
404
434
|
unsaved = [];
|
|
405
435
|
static async open(t2) {
|
|
406
436
|
if ("string" != typeof t2.doc || "" === t2.doc || t2.doc.length > 64) throw new Error("pipeup: the document id must be 1 to 64 characters");
|
|
407
|
-
let r2 = new
|
|
437
|
+
let r2 = new L(t2.doc), n2 = await t2.store.load(t2.doc), i = n2.length - (await r2.add(n2)).length;
|
|
408
438
|
i && console.warn(`pipeup: ${i} saved change${1 === i ? "" : "s"} on this page couldn't be read; kept as saved`);
|
|
409
439
|
let o = new e2(r2, t2);
|
|
410
440
|
return o.refresh(false), o;
|
|
@@ -450,7 +480,7 @@ var J = class e2 {
|
|
|
450
480
|
}
|
|
451
481
|
contact(e3) {
|
|
452
482
|
let t2 = e3.trim();
|
|
453
|
-
return
|
|
483
|
+
return A.test(t2) ? this.enqueue(async () => {
|
|
454
484
|
await this.write({ kind: "contact", thread: this.me, text: t2 });
|
|
455
485
|
}) : Promise.reject(new Error("pipeup: that isn't an email address or a GitHub name"));
|
|
456
486
|
}
|
|
@@ -461,32 +491,17 @@ var J = class e2 {
|
|
|
461
491
|
}
|
|
462
492
|
contacts() {
|
|
463
493
|
let e3 = /* @__PURE__ */ new Map();
|
|
464
|
-
for (let { body: t2 } of [...this.log.all()].sort(
|
|
494
|
+
for (let { body: t2 } of [...this.log.all()].sort(F)) "contact" === t2.kind && t2.text ? e3.set(t2.author, t2.text) : "uncontact" === t2.kind && e3.delete(t2.author);
|
|
465
495
|
return e3;
|
|
466
496
|
}
|
|
467
497
|
get portable() {
|
|
468
498
|
return this.options.identity.privateKey.extractable;
|
|
469
499
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
let t2 = ((function(e5) {
|
|
476
|
-
let t3 = 0, r3 = 0, n2 = "";
|
|
477
|
-
for (let i of e5) for (r3 = r3 << 8 | i, t3 += 8; t3 >= 5; ) n2 += u[r3 >>> t3 - 5 & 31], t3 -= 5;
|
|
478
|
-
return t3 && (n2 += u[r3 << 5 - t3 & 31]), n2;
|
|
479
|
-
})(e4) + (function(e5) {
|
|
480
|
-
let t3 = 2166136261;
|
|
481
|
-
for (let r4 of e5) t3 = Math.imul(t3 ^ r4, 16777619);
|
|
482
|
-
t3 = Math.imul(t3 ^ t3 >>> 15, 739982445);
|
|
483
|
-
let r3 = "";
|
|
484
|
-
for (let e6 = 0; e6 < 4; e6++, t3 >>>= 5) r3 += u[31 & t3];
|
|
485
|
-
return r3;
|
|
486
|
-
})(e4)).match(/.{1,4}/g).join("-");
|
|
487
|
-
return `PU1-${t2}`;
|
|
488
|
-
})(t(r2.d)) : null;
|
|
489
|
-
})(this.options.identity);
|
|
500
|
+
async seed() {
|
|
501
|
+
let e3 = this.options.identity.privateKey;
|
|
502
|
+
if (!e3.extractable) return null;
|
|
503
|
+
let { d: r2 } = await crypto.subtle.exportKey("jwk", e3);
|
|
504
|
+
return r2 ? t(r2) : null;
|
|
490
505
|
}
|
|
491
506
|
seen(e3) {
|
|
492
507
|
return this.enqueue(async () => {
|
|
@@ -518,7 +533,7 @@ var J = class e2 {
|
|
|
518
533
|
}
|
|
519
534
|
sign(e3, t2) {
|
|
520
535
|
if (!G.test(e3)) throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');
|
|
521
|
-
return
|
|
536
|
+
return l(this.options.identity, r(`pipeup:${e3}
|
|
522
537
|
${t2}`));
|
|
523
538
|
}
|
|
524
539
|
flush() {
|
|
@@ -526,43 +541,12 @@ ${t2}`));
|
|
|
526
541
|
}
|
|
527
542
|
exportFile() {
|
|
528
543
|
return (async function(e3, t2, r2) {
|
|
529
|
-
let n2 = r2 ? { pipeup: 1, doc: e3, sealed: true, ...await
|
|
544
|
+
let n2 = r2 ? { pipeup: 1, doc: e3, sealed: true, ...await H(r2, JSON.stringify(t2), K(e3)) } : { pipeup: 1, doc: e3, sealed: false, ops: t2 };
|
|
530
545
|
return JSON.stringify(n2, null, 2);
|
|
531
546
|
})(this.options.doc, this.log.all(), this.options.key);
|
|
532
547
|
}
|
|
533
548
|
async importFile(e3) {
|
|
534
|
-
return this.merge(await (
|
|
535
|
-
if (e4.length > 5e6) throw new Error("pipeup: this feedback file is too large");
|
|
536
|
-
let o, a2, s2;
|
|
537
|
-
try {
|
|
538
|
-
o = JSON.parse(e4);
|
|
539
|
-
} catch {
|
|
540
|
-
throw new Error("pipeup: this is not an Pipeup feedback file");
|
|
541
|
-
}
|
|
542
|
-
if (!o || "object" != typeof o || 1 !== o.pipeup || "string" != typeof o.doc) throw new Error("pipeup: this is not an Pipeup feedback file");
|
|
543
|
-
if (o.doc !== n2) throw new Error("pipeup: this feedback is for a different document");
|
|
544
|
-
if (!o.sealed) return Array.isArray(o.ops) ? o.ops : [];
|
|
545
|
-
if (!i) throw new Error("pipeup: this feedback is sealed, and this page has no document key");
|
|
546
|
-
if ("string" != typeof o.iv || "string" != typeof o.data) throw new Error("pipeup: this is not an Pipeup feedback file");
|
|
547
|
-
try {
|
|
548
|
-
a2 = await (async function(e5, n3, i2) {
|
|
549
|
-
try {
|
|
550
|
-
let o2 = await crypto.subtle.decrypt({ name: "AES-GCM", iv: t(n3.iv), additionalData: r(i2) }, e5, t(n3.data));
|
|
551
|
-
return new TextDecoder().decode(o2);
|
|
552
|
-
} catch {
|
|
553
|
-
throw new Error("pipeup: this feedback could not be opened with this document");
|
|
554
|
-
}
|
|
555
|
-
})(i, { iv: o.iv, data: o.data }, B(n2));
|
|
556
|
-
} catch {
|
|
557
|
-
throw new Error("pipeup: this feedback could not be opened with this document's key");
|
|
558
|
-
}
|
|
559
|
-
try {
|
|
560
|
-
s2 = JSON.parse(a2);
|
|
561
|
-
} catch {
|
|
562
|
-
throw new Error("pipeup: this is not an Pipeup feedback file");
|
|
563
|
-
}
|
|
564
|
-
return Array.isArray(s2) ? s2 : [];
|
|
565
|
-
})(e3, this.options.doc, this.options.key), "file");
|
|
549
|
+
return this.merge(await B(e3, this.options.doc, this.options.key), "file");
|
|
566
550
|
}
|
|
567
551
|
merge(e3, t2) {
|
|
568
552
|
return e3.length > 5e3 ? Promise.reject(new RangeError("pipeup: too many changes to merge at once")) : this.enqueue(async () => {
|
|
@@ -627,17 +611,17 @@ ${t2}`));
|
|
|
627
611
|
function V(e3) {
|
|
628
612
|
let t2 = e3.trim();
|
|
629
613
|
if (!t2) throw new Error("pipeup: a comment needs some words");
|
|
630
|
-
if (t2.length >
|
|
614
|
+
if (t2.length > y) throw new Error(`pipeup: comments are limited to ${y} characters`);
|
|
631
615
|
return t2;
|
|
632
616
|
}
|
|
633
617
|
function W(e3) {
|
|
634
|
-
if (!
|
|
618
|
+
if (!C(e3)) throw new Error("pipeup: a reaction is one emoji");
|
|
635
619
|
return e3;
|
|
636
620
|
}
|
|
637
621
|
function Q(e3) {
|
|
638
622
|
let t2 = e3.replace(/\s+/g, " ").trim();
|
|
639
623
|
if (!t2 || t2.length > 80) throw new Error("pipeup: choose a name of 1 to 80 characters");
|
|
640
|
-
if (
|
|
624
|
+
if (g(t2)) throw new Error("pipeup: that name is kept for AI replies; choose another");
|
|
641
625
|
return t2;
|
|
642
626
|
}
|
|
643
627
|
var X = class {
|
|
@@ -1109,12 +1093,12 @@ function server(value, mailbox) {
|
|
|
1109
1093
|
return mailbox ? value.replace(/\/+$/, "") : u2.origin + u2.pathname;
|
|
1110
1094
|
}
|
|
1111
1095
|
async function feedbackOps(file, docAttr, io) {
|
|
1112
|
-
const { id, key } = await
|
|
1096
|
+
const { id, key } = await z(docAttr);
|
|
1113
1097
|
const doc = await J.open({
|
|
1114
1098
|
doc: id,
|
|
1115
1099
|
key,
|
|
1116
1100
|
store: new X(),
|
|
1117
|
-
identity: await
|
|
1101
|
+
identity: await d(),
|
|
1118
1102
|
name: ""
|
|
1119
1103
|
});
|
|
1120
1104
|
try {
|
|
@@ -1140,11 +1124,11 @@ Run the same command with --new-doc and I will write a fresh one into the page.
|
|
|
1140
1124
|
);
|
|
1141
1125
|
throw new UsageError("the page needs a document identity");
|
|
1142
1126
|
}
|
|
1143
|
-
docAttr =
|
|
1127
|
+
docAttr = _();
|
|
1144
1128
|
html = setAttribute(html, "data-pipeup-doc", docAttr);
|
|
1145
1129
|
io.out("Gave the page a new document identity (data-pipeup-doc).");
|
|
1146
1130
|
}
|
|
1147
|
-
const { id } = await
|
|
1131
|
+
const { id } = await z(docAttr).catch(() => {
|
|
1148
1132
|
throw new UsageError("data-pipeup-doc in the page isn't a valid document identity");
|
|
1149
1133
|
});
|
|
1150
1134
|
const from = typeof flags.get("from") === "string" ? flags.get("from") : null;
|
|
@@ -1214,7 +1198,7 @@ async function addressOf(file, io) {
|
|
|
1214
1198
|
const a2 = parseShare(readAttribute(html, "data-pipeup-share"), true);
|
|
1215
1199
|
if (a2.kind === "off") throw new UsageError(`${file}: ${a2.reason}`);
|
|
1216
1200
|
const docAttr = readAttribute(html, "data-pipeup-doc");
|
|
1217
|
-
const doc = docAttr ? (await
|
|
1201
|
+
const doc = docAttr ? (await z(docAttr).catch(() => null))?.id : null;
|
|
1218
1202
|
if (!doc) throw new UsageError(`${file} has no valid data-pipeup-doc`);
|
|
1219
1203
|
return { html, a: a2, l: ladder(doc, a2.key) };
|
|
1220
1204
|
}
|