quickspeadsheet 1.0.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.
@@ -0,0 +1,76 @@
1
+ import { hO as o, hP as K } from "./dragMerge-DHUQYNgo.js";
2
+ const S = 3759263696, v = 3776623009;
3
+ function x(e) {
4
+ const t = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
5
+ if (!t || t.length < 8) return !1;
6
+ const a = new DataView(t.buffer, t.byteOffset, 8), r = a.getUint32(0, !0), c = a.getUint32(4, !0);
7
+ if (r !== S || c !== v) return !1;
8
+ try {
9
+ const i = o.parse(t), s = o.find(i, "EncryptionInfo") || o.find(i, "/EncryptionInfo"), f = o.find(i, "EncryptedPackage") || o.find(i, "/EncryptedPackage");
10
+ return !!(s?.content && f?.content);
11
+ } catch {
12
+ return !1;
13
+ }
14
+ }
15
+ async function b(e) {
16
+ const t = atob(e), a = new Uint8Array(t.length);
17
+ for (let r = 0; r < t.length; r++) a[r] = t.charCodeAt(r);
18
+ return a;
19
+ }
20
+ const P = () => new Promise((e) => typeof queueMicrotask == "function" ? queueMicrotask(e) : setTimeout(e, 0));
21
+ async function T(e, t, a, r, c) {
22
+ const s = new TextEncoder().encode(e), f = c === "SHA512" ? "SHA-512" : c === "SHA1" ? "SHA-1" : "SHA-256";
23
+ let n = new Uint8Array(t.length + s.length);
24
+ n.set(t), n.set(s, t.length), n = new Uint8Array(await crypto.subtle.digest(f, n));
25
+ const g = 1e4;
26
+ for (let y = 1; y <= a; y++) {
27
+ y % g === 0 && await P();
28
+ const u = new Uint8Array(4);
29
+ new DataView(u.buffer).setUint32(0, y, !0);
30
+ const l = new Uint8Array(4 + n.length);
31
+ l.set(u), l.set(n, 4), n = new Uint8Array(await crypto.subtle.digest(f, l));
32
+ }
33
+ return crypto.subtle.importKey("raw", n.slice(0, r / 8), { name: "AES-CBC" }, !1, ["decrypt"]);
34
+ }
35
+ function O(e) {
36
+ const t = K(e);
37
+ if (!t) return null;
38
+ const a = (u, l) => u?.getAttribute?.(l), r = t.getElementsByTagName("keyData")[0] || t.getElementsByTagName("encryption:keyData")[0], c = t.getElementsByTagName("keyEncryptor")[0] || t.getElementsByTagName("encryption:keyEncryptor")[0];
39
+ if (!r || !c) return null;
40
+ const i = c.getElementsByTagName("p:encryptedKey")[0] || c.getElementsByTagName("encryptedKey")[0] || c.querySelector?.("*[encryptedKeyValue]") || Array.from(c.querySelectorAll?.("*") || []).find((u) => u.getAttribute?.("encryptedKeyValue")), s = i?.getAttribute?.("encryptedKeyValue") || i?.getAttribute?.("encryptedKey"), f = parseInt(i?.getAttribute?.("spinCount") || a(c, "spinCount") || "100000", 10), n = i?.getAttribute?.("saltValue") || i?.getAttribute?.("salt"), g = parseInt(i?.getAttribute?.("keyBits") || a(r, "keyBits") || "128", 10), y = i?.getAttribute?.("hashAlgorithm") || a(r, "hashAlgorithm") || "SHA1";
41
+ return !n || !s ? null : { saltB64: n, encKey: s, spinCount: f, keyBits: g, hashAlg: y };
42
+ }
43
+ function h(e) {
44
+ return e ? e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : typeof Buffer < "u" && Buffer.isBuffer(e) ? new Uint8Array(e) : Array.isArray(e) ? new Uint8Array(e) : new Uint8Array(e) : new Uint8Array(0);
45
+ }
46
+ async function H(e, t) {
47
+ const a = e instanceof ArrayBuffer ? new Uint8Array(e) : e, r = o.parse(a), c = o.find(r, "EncryptionInfo") || o.find(r, "/EncryptionInfo"), i = o.find(r, "EncryptedPackage") || o.find(r, "/EncryptedPackage");
48
+ if (!c || !i || !c.content || !i.content)
49
+ throw new Error("Invalid OLE encrypted package structure");
50
+ let s = h(c.content);
51
+ if (s.length >= 8) {
52
+ const d = new DataView(s.buffer, s.byteOffset, 8);
53
+ d.getUint16(0, !0) === 4 && d.getUint16(2, !0) === 4 && d.getUint32(4, !0) === 64 && (s = s.slice(8));
54
+ }
55
+ const f = new TextDecoder("utf-8").decode(s), n = O(f);
56
+ if (!n) throw new Error("Invalid EncryptionInfo - only Agile encryption is supported");
57
+ const g = await b(n.saltB64), y = await b(n.encKey), u = await T(t, g, n.spinCount, n.keyBits, n.hashAlg), l = y.slice(0, 16), m = y.slice(16);
58
+ let w;
59
+ try {
60
+ w = await crypto.subtle.decrypt({ name: "AES-CBC", iv: l }, u, m);
61
+ } catch {
62
+ throw new Error("Invalid password");
63
+ }
64
+ const k = Math.min(n.keyBits / 8, 32), B = new Uint8Array(w).slice(0, k), U = await crypto.subtle.importKey("raw", B, { name: "AES-CBC" }, !1, ["decrypt"]), p = h(i.content), A = (p.length >= 8 ? Number(new DataView(p.buffer, p.byteOffset, 8).getBigUint64(0, !0)) : 0) > 0 && p.length > 8 ? p.slice(8) : p, I = A.slice(0, 16), C = A.slice(16);
65
+ let E;
66
+ try {
67
+ E = await crypto.subtle.decrypt({ name: "AES-CBC", iv: I }, U, C);
68
+ } catch {
69
+ throw new Error("Invalid password");
70
+ }
71
+ return new Uint8Array(E);
72
+ }
73
+ export {
74
+ H as decryptOle,
75
+ x as isOleEncrypted
76
+ };
@@ -0,0 +1,60 @@
1
+ import { hQ as B, hP as K } from "./dragMerge-DHUQYNgo.js";
2
+ async function A(r) {
3
+ const t = atob(r), c = new Uint8Array(t.length);
4
+ for (let n = 0; n < t.length; n++) c[n] = t.charCodeAt(n);
5
+ return c;
6
+ }
7
+ const S = () => new Promise((r) => typeof queueMicrotask == "function" ? queueMicrotask(r) : setTimeout(r, 0));
8
+ async function I(r, t, c, n, e) {
9
+ const s = new TextEncoder().encode(r), i = e === "SHA512" ? "SHA-512" : e === "SHA1" ? "SHA-1" : "SHA-256";
10
+ let a = new Uint8Array(t.length + s.length);
11
+ a.set(t), a.set(s, t.length), a = new Uint8Array(await crypto.subtle.digest(i, a));
12
+ const u = 1e4;
13
+ for (let l = 1; l <= c; l++) {
14
+ l % u === 0 && await S();
15
+ const g = new Uint8Array(4);
16
+ new DataView(g.buffer).setUint32(0, l, !0);
17
+ const y = new Uint8Array(4 + a.length);
18
+ y.set(g), y.set(a, 4), a = new Uint8Array(await crypto.subtle.digest(i, y));
19
+ }
20
+ return crypto.subtle.importKey("raw", a.slice(0, n / 8), { name: "AES-CBC" }, !1, ["decrypt"]);
21
+ }
22
+ function C(r) {
23
+ const t = K(r);
24
+ if (!t) return null;
25
+ const c = (y, f) => y?.getAttribute?.(f), n = t.getElementsByTagName("keyData")[0] || t.getElementsByTagName("encryption:keyData")[0], e = t.getElementsByTagName("keyEncryptor")[0] || t.getElementsByTagName("encryption:keyEncryptor")[0];
26
+ if (!n || !e) return null;
27
+ e.getElementsByTagName("p:encryptedKey")[0] || e.getElementsByTagName("encryptedKey")[0] || e.querySelector?.("[encryptedKey]");
28
+ const o = e.getElementsByTagName("p:encryptedKey")[0] || e.getElementsByTagName("encryptedKey")[0] || e.querySelector?.("*[encryptedKeyValue]") || Array.from(e.querySelectorAll?.("*") || []).find((y) => y.getAttribute?.("encryptedKeyValue")), s = o?.getAttribute?.("encryptedKeyValue") || o?.getAttribute?.("encryptedKey"), i = parseInt(o?.getAttribute?.("spinCount") || c(e, "spinCount") || "100000", 10), a = o?.getAttribute?.("saltValue") || o?.getAttribute?.("salt"), u = parseInt(o?.getAttribute?.("blockSize") || c(n, "blockSize") || "16", 10), l = parseInt(o?.getAttribute?.("keyBits") || c(n, "keyBits") || "128", 10), g = o?.getAttribute?.("hashAlgorithm") || c(n, "hashAlgorithm") || "SHA1";
29
+ return !a || !s ? null : { saltB64: a, encKey: s, spinCount: i, blockSize: u, keyBits: l, hashAlg: g };
30
+ }
31
+ async function v(r, t) {
32
+ const c = r.file("EncryptionInfo") || r.file("encryptionInfo"), n = r.file("EncryptedPackage") || r.file("encryptedPackage");
33
+ if (!c || !n)
34
+ throw new Error("Invalid encrypted package structure");
35
+ let e = await c.async("arraybuffer");
36
+ if (e.byteLength >= 8) {
37
+ const p = new DataView(e);
38
+ p.getUint16(0, !0) === 4 && p.getUint16(2, !0) === 4 && p.getUint32(4, !0) === 64 && (e = e.slice(8));
39
+ }
40
+ const o = new TextDecoder("utf-8").decode(new Uint8Array(e)), s = new Uint8Array(await n.async("arraybuffer")), i = C(o);
41
+ if (!i) throw new Error("Invalid EncryptionInfo");
42
+ const a = await A(i.saltB64), u = await A(i.encKey), l = await I(t, a, i.spinCount, i.keyBits, i.hashAlg), g = u.slice(0, 16), y = u.slice(16);
43
+ let f;
44
+ try {
45
+ f = await crypto.subtle.decrypt({ name: "AES-CBC", iv: g }, l, y);
46
+ } catch {
47
+ throw new Error("Invalid password");
48
+ }
49
+ const m = Math.min(i.keyBits / 8, 32), b = new Uint8Array(f).slice(0, m), h = await crypto.subtle.importKey("raw", b, { name: "AES-CBC" }, !1, ["decrypt"]), w = (s.length >= 8 ? Number(new DataView(s.buffer, s.byteOffset, 8).getBigUint64(0, !0)) : 0) > 0 && s.length > 8 ? s.slice(8) : s, k = w.slice(0, 16), E = w.slice(16);
50
+ let d;
51
+ try {
52
+ d = await crypto.subtle.decrypt({ name: "AES-CBC", iv: k }, h, E);
53
+ } catch {
54
+ throw new Error("Invalid password");
55
+ }
56
+ return B.loadAsync(d, { optimizedBinaryString: !0 });
57
+ }
58
+ export {
59
+ v as decryptOoxml
60
+ };