ooxml-core 0.5.0 → 0.6.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 +1 -0
- package/dist/digest/algorithm-names.d.ts +20 -0
- package/dist/digest/algorithm-names.d.ts.map +1 -0
- package/dist/digest/base64.d.ts +8 -0
- package/dist/digest/base64.d.ts.map +1 -0
- package/dist/digest/digest.d.ts +13 -0
- package/dist/digest/digest.d.ts.map +1 -0
- package/dist/digest/index.cjs +594 -0
- package/dist/digest/index.d.ts +8 -0
- package/dist/digest/index.d.ts.map +1 -0
- package/dist/digest/index.mjs +581 -0
- package/dist/digest/password-hash.d.ts +30 -0
- package/dist/digest/password-hash.d.ts.map +1 -0
- package/dist/digest/sha1.d.ts +3 -0
- package/dist/digest/sha1.d.ts.map +1 -0
- package/dist/digest/sha256.d.ts +10 -0
- package/dist/digest/sha256.d.ts.map +1 -0
- package/dist/digest/sha512.d.ts +5 -0
- package/dist/digest/sha512.d.ts.map +1 -0
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +131 -54
- package/dist/docx/embedded.mjs +131 -54
- package/dist/docx/equation.d.ts +8 -0
- package/dist/docx/equation.d.ts.map +1 -0
- package/dist/docx/index.cjs +131 -54
- package/dist/docx/index.mjs +131 -54
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +3 -1
- package/dist/docx/layout/index.mjs +3 -1
- package/dist/docx/load/index.cjs +133 -56
- package/dist/docx/load/index.mjs +133 -56
- package/dist/docx/model-run.d.ts +5 -0
- package/dist/docx/model-run.d.ts.map +1 -1
- package/dist/docx/parse-revisions.d.ts.map +1 -1
- package/dist/docx/parse-table.d.ts.map +1 -1
- package/dist/docx/write-inline.d.ts.map +1 -1
- package/dist/docx/write-table-margins.d.ts +5 -0
- package/dist/docx/write-table-margins.d.ts.map +1 -0
- package/dist/docx/write-table-properties.d.ts +3 -1
- package/dist/docx/write-table-properties.d.ts.map +1 -1
- package/dist/docx/write-table.d.ts.map +1 -1
- package/dist/index.cjs +598 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +598 -1
- package/dist/xlsx/edit/history.d.ts +1 -1
- package/dist/xlsx/edit/history.d.ts.map +1 -1
- package/dist/xlsx/edit/index.d.ts +1 -1
- package/dist/xlsx/edit/index.d.ts.map +1 -1
- package/dist/xlsx/edit/protection.d.ts +18 -6
- package/dist/xlsx/edit/protection.d.ts.map +1 -1
- package/dist/xlsx/edit/types.d.ts +2 -2
- package/dist/xlsx/index.cjs +671 -28
- package/dist/xlsx/index.mjs +670 -29
- package/dist/xlsx/load/index.cjs +56 -19
- package/dist/xlsx/load/index.mjs +56 -19
- package/dist/xlsx/model.d.ts +21 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/read/password-hash.d.ts +15 -0
- package/dist/xlsx/read/password-hash.d.ts.map +1 -0
- package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/read/workbook-part.d.ts +3 -1
- package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/write/password-hash.d.ts +8 -0
- package/dist/xlsx/write/password-hash.d.ts.map +1 -0
- package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/package.json +6 -1
package/dist/xlsx/index.mjs
CHANGED
|
@@ -8214,10 +8214,10 @@ var DISTRIBUTION_MORE = [
|
|
|
8214
8214
|
"The hypergeometric distribution.",
|
|
8215
8215
|
5,
|
|
8216
8216
|
5,
|
|
8217
|
-
(k, n2,
|
|
8217
|
+
(k, n2, K3, N, c2) => {
|
|
8218
8218
|
const kk = Math.trunc(k);
|
|
8219
8219
|
const nn = Math.trunc(n2 ?? 0);
|
|
8220
|
-
const KK = Math.trunc(
|
|
8220
|
+
const KK = Math.trunc(K3 ?? 0);
|
|
8221
8221
|
const NN = Math.trunc(N ?? 0);
|
|
8222
8222
|
if (kk < 0 || nn > NN || KK > NN || kk > Math.min(nn, KK)) fail(ERR.NUM);
|
|
8223
8223
|
const pmf = (i) => combin(KK, i) * combin(NN - KK, nn - i) / combin(NN, nn);
|
|
@@ -11533,6 +11533,29 @@ function translateReferences(formula, dRow, dCol) {
|
|
|
11533
11533
|
return translateFormula(formula, dRow, dCol);
|
|
11534
11534
|
}
|
|
11535
11535
|
|
|
11536
|
+
// src/xlsx/read/password-hash.ts
|
|
11537
|
+
function modernHashAttributeNames(prefix = "") {
|
|
11538
|
+
const name = (base) => prefix ? `${prefix}${base[0].toUpperCase()}${base.slice(1)}` : base;
|
|
11539
|
+
return {
|
|
11540
|
+
algorithmName: name("algorithmName"),
|
|
11541
|
+
hashValue: name("hashValue"),
|
|
11542
|
+
saltValue: name("saltValue"),
|
|
11543
|
+
spinCount: name("spinCount")
|
|
11544
|
+
};
|
|
11545
|
+
}
|
|
11546
|
+
function readModernHash(node, prefix = "") {
|
|
11547
|
+
const names = modernHashAttributeNames(prefix);
|
|
11548
|
+
const algorithmName = att(node, names.algorithmName);
|
|
11549
|
+
const hashValue = att(node, names.hashValue);
|
|
11550
|
+
const saltValue = att(node, names.saltValue);
|
|
11551
|
+
if (!algorithmName || !hashValue || !saltValue) return void 0;
|
|
11552
|
+
const hash = { algorithmName, hashValue, saltValue };
|
|
11553
|
+
const spin2 = att(node, names.spinCount);
|
|
11554
|
+
const spinCount = spin2 === void 0 || spin2.trim() === "" ? Number.NaN : Number(spin2);
|
|
11555
|
+
if (Number.isFinite(spinCount)) hash.spinCount = spinCount;
|
|
11556
|
+
return hash;
|
|
11557
|
+
}
|
|
11558
|
+
|
|
11536
11559
|
// src/xlsx/read/workbook-part.ts
|
|
11537
11560
|
function parseWorkbookPart(xml) {
|
|
11538
11561
|
const root = parseXml(xml, { label: "XLSX workbook" }).documentElement;
|
|
@@ -11560,16 +11583,19 @@ function parseWorkbookPart(xml) {
|
|
|
11560
11583
|
if (name.name) definedNames.push(name);
|
|
11561
11584
|
}
|
|
11562
11585
|
const view = xFirst(xFirst(root, "bookViews"), "workbookView");
|
|
11563
|
-
const
|
|
11586
|
+
const protection = xFirst(root, "workbookProtection");
|
|
11587
|
+
const password = att(protection, "workbookPassword");
|
|
11588
|
+
const modernHash = readModernHash(protection, "workbook");
|
|
11564
11589
|
const calcMode = att(xFirst(root, "calcPr"), "calcMode");
|
|
11565
11590
|
return {
|
|
11566
11591
|
...password ? { workbookPasswordHash: password } : {},
|
|
11592
|
+
...modernHash ? { workbookModernHash: modernHash } : {},
|
|
11567
11593
|
...calcMode === "manual" ? { calcMode: "manual" } : {},
|
|
11568
11594
|
sheets,
|
|
11569
11595
|
definedNames,
|
|
11570
11596
|
date1904: boolAttr(xFirst(root, "workbookPr"), "date1904", false),
|
|
11571
11597
|
activeTab: numAttr(view, "activeTab") ?? 0,
|
|
11572
|
-
structureLocked: boolAttr(
|
|
11598
|
+
structureLocked: boolAttr(protection, "lockStructure", false),
|
|
11573
11599
|
fullCalcOnLoad: boolAttr(xFirst(root, "calcPr"), "fullCalcOnLoad", false)
|
|
11574
11600
|
};
|
|
11575
11601
|
}
|
|
@@ -11744,6 +11770,8 @@ function readProtection(node) {
|
|
|
11744
11770
|
const protection = { sheet: boolAttr(node, "sheet", false) };
|
|
11745
11771
|
const password = att(node, "password");
|
|
11746
11772
|
if (password) protection.passwordHash = password;
|
|
11773
|
+
const modernHash = readModernHash(node);
|
|
11774
|
+
if (modernHash) protection.modernHash = modernHash;
|
|
11747
11775
|
const allow = [];
|
|
11748
11776
|
for (const attribute of Array.from(node.attributes)) {
|
|
11749
11777
|
if (PROTECTION_META.has(attribute.name)) continue;
|
|
@@ -12651,6 +12679,7 @@ async function loadXlsx(input) {
|
|
|
12651
12679
|
if (book.fullCalcOnLoad) workbook.fullCalcOnLoad = true;
|
|
12652
12680
|
if (book.structureLocked) workbook.structureLocked = true;
|
|
12653
12681
|
if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
|
|
12682
|
+
if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
|
|
12654
12683
|
if (book.calcMode) workbook.calcMode = book.calcMode;
|
|
12655
12684
|
if (!sheets.length) throw new Error("XLSX workbook has no sheets");
|
|
12656
12685
|
liftPrintAreas(workbook);
|
|
@@ -13555,6 +13584,18 @@ function themePart(theme2, sourceXml) {
|
|
|
13555
13584
|
return `${XML_HEADER}${buildXml(doc).replace(/^<\?xml[^>]*\?>\s*/, "")}`;
|
|
13556
13585
|
}
|
|
13557
13586
|
|
|
13587
|
+
// src/xlsx/write/password-hash.ts
|
|
13588
|
+
function modernHashValues(hash, prefix = "") {
|
|
13589
|
+
if (!hash) return {};
|
|
13590
|
+
const names = modernHashAttributeNames(prefix);
|
|
13591
|
+
return {
|
|
13592
|
+
[names.algorithmName]: hash.algorithmName,
|
|
13593
|
+
[names.hashValue]: hash.hashValue,
|
|
13594
|
+
[names.saltValue]: hash.saltValue,
|
|
13595
|
+
[names.spinCount]: hash.spinCount === void 0 ? void 0 : String(hash.spinCount)
|
|
13596
|
+
};
|
|
13597
|
+
}
|
|
13598
|
+
|
|
13558
13599
|
// src/xlsx/write/workbook-part.ts
|
|
13559
13600
|
var KEPT_BEFORE_SHEETS = ["fileVersion", "fileSharing"];
|
|
13560
13601
|
var KEPT_AFTER_SHEETS = ["functionGroups", "externalReferences"];
|
|
@@ -13605,18 +13646,17 @@ function workbookXml(workbook, sheets, activeTab, sourceXml) {
|
|
|
13605
13646
|
out += raw(KEPT_BEFORE_SHEETS) || '<fileVersion appName="xl" lastEdited="7" lowestEdited="7" rupBuild="27328"/>';
|
|
13606
13647
|
out += `<workbookPr${copyAttrs(kept.get("workbookPr"), ["date1904"])}${workbook.date1904 ? ' date1904="1"' : ""}/>`;
|
|
13607
13648
|
if (workbook.structureLocked) {
|
|
13608
|
-
const
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
);
|
|
13649
|
+
const skip = [
|
|
13650
|
+
"lockStructure",
|
|
13651
|
+
"workbookPassword",
|
|
13652
|
+
"workbookAlgorithmName",
|
|
13653
|
+
"workbookHashValue",
|
|
13654
|
+
"workbookSaltValue",
|
|
13655
|
+
"workbookSpinCount"
|
|
13656
|
+
];
|
|
13657
|
+
const modern = Object.entries(modernHashValues(workbook.workbookModernHash, "workbook")).filter((entry) => entry[1] !== void 0).map(([name, value]) => ` ${name}="${escapeAttr3(value)}"`).join("");
|
|
13618
13658
|
const password = workbook.workbookPasswordHash ? ` workbookPassword="${escapeAttr3(workbook.workbookPasswordHash)}"` : "";
|
|
13619
|
-
out += `<workbookProtection${copyAttrs(
|
|
13659
|
+
out += `<workbookProtection${copyAttrs(kept.get("workbookProtection"), skip)}${modern}${password} lockStructure="1"/>`;
|
|
13620
13660
|
}
|
|
13621
13661
|
const view = kept.get("bookViews") ? elements(kept.get("bookViews"))[0] : void 0;
|
|
13622
13662
|
out += `<bookViews><workbookView${copyAttrs(view, ["activeTab", "firstSheet", "xr2:uid"])}${activeTab ? ` activeTab="${activeTab}"` : ""}/></bookViews>`;
|
|
@@ -14223,18 +14263,15 @@ function colsXml(sheet, styleCount) {
|
|
|
14223
14263
|
}
|
|
14224
14264
|
return out.length ? `<cols>${out.join("")}</cols>` : "";
|
|
14225
14265
|
}
|
|
14226
|
-
var HASH_ATTRS = ["algorithmName", "hashValue", "saltValue", "spinCount"];
|
|
14227
14266
|
function protectionXml2(sheet) {
|
|
14228
14267
|
const protection = sheet.protection;
|
|
14229
14268
|
if (!protection) return "";
|
|
14230
14269
|
const source2 = snapshotElement(sheet, "sheetProtection");
|
|
14231
14270
|
if (source2 && sameModel(readProtection(source2), protection))
|
|
14232
14271
|
return snapshotXml(sheet, "sheetProtection") ?? "";
|
|
14233
|
-
const values =
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
else if (protection.passwordHash === void 0 && att(source2, "password") === void 0)
|
|
14237
|
-
for (const name of HASH_ATTRS) values[name] = att(source2, name);
|
|
14272
|
+
const values = modernHashValues(
|
|
14273
|
+
protection.modernHash
|
|
14274
|
+
);
|
|
14238
14275
|
values["password"] = protection.passwordHash;
|
|
14239
14276
|
values["sheet"] = protection.sheet || void 0;
|
|
14240
14277
|
const allow = new Set(protection.allow ?? []);
|
|
@@ -16685,7 +16722,12 @@ function replaceOne(ctx, query, replacement, at) {
|
|
|
16685
16722
|
}
|
|
16686
16723
|
|
|
16687
16724
|
// src/xlsx/edit/history.ts
|
|
16688
|
-
var SETTING_KEYS = [
|
|
16725
|
+
var SETTING_KEYS = [
|
|
16726
|
+
"structureLocked",
|
|
16727
|
+
"workbookPasswordHash",
|
|
16728
|
+
"workbookModernHash",
|
|
16729
|
+
"calcMode"
|
|
16730
|
+
];
|
|
16689
16731
|
function captureSettings(workbook) {
|
|
16690
16732
|
const out = {};
|
|
16691
16733
|
for (const key of SETTING_KEYS) if (workbook[key] !== void 0) out[key] = workbook[key];
|
|
@@ -17664,6 +17706,583 @@ function setPrintOptions(ctx, s, patch) {
|
|
|
17664
17706
|
);
|
|
17665
17707
|
}
|
|
17666
17708
|
|
|
17709
|
+
// src/digest/algorithm-names.ts
|
|
17710
|
+
var CANONICAL_BY_LOOKUP_KEY = {
|
|
17711
|
+
SHA1: "SHA-1",
|
|
17712
|
+
SHA256: "SHA-256",
|
|
17713
|
+
SHA384: "SHA-384",
|
|
17714
|
+
SHA512: "SHA-512",
|
|
17715
|
+
MD2: "MD2",
|
|
17716
|
+
MD4: "MD4",
|
|
17717
|
+
MD5: "MD5",
|
|
17718
|
+
RIPEMD128: "RIPEMD-128",
|
|
17719
|
+
RIPEMD160: "RIPEMD-160",
|
|
17720
|
+
WHIRLPOOL: "WHIRLPOOL"
|
|
17721
|
+
};
|
|
17722
|
+
function normalizeDigestAlgorithmName(name) {
|
|
17723
|
+
const key = name.toUpperCase().replace(/[-_\s]/g, "");
|
|
17724
|
+
return Object.hasOwn(CANONICAL_BY_LOOKUP_KEY, key) ? CANONICAL_BY_LOOKUP_KEY[key] : void 0;
|
|
17725
|
+
}
|
|
17726
|
+
|
|
17727
|
+
// src/digest/base64.ts
|
|
17728
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
17729
|
+
var VALUES = new Map([...ALPHABET].map((char, index2) => [char, index2]));
|
|
17730
|
+
function encodeBase64(bytes) {
|
|
17731
|
+
let out = "";
|
|
17732
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
17733
|
+
const a = bytes[i];
|
|
17734
|
+
const b = bytes[i + 1];
|
|
17735
|
+
const c2 = bytes[i + 2];
|
|
17736
|
+
const n2 = a << 16 | (b ?? 0) << 8 | (c2 ?? 0);
|
|
17737
|
+
out += ALPHABET[n2 >> 18] + ALPHABET[n2 >> 12 & 63];
|
|
17738
|
+
out += b === void 0 ? "=" : ALPHABET[n2 >> 6 & 63];
|
|
17739
|
+
out += c2 === void 0 ? "=" : ALPHABET[n2 & 63];
|
|
17740
|
+
}
|
|
17741
|
+
return out;
|
|
17742
|
+
}
|
|
17743
|
+
function decodeBase64(text2) {
|
|
17744
|
+
const compact3 = text2.replace(/\s+/g, "");
|
|
17745
|
+
const body = compact3.replace(/={1,2}$/, "");
|
|
17746
|
+
if (body.length % 4 === 1) return void 0;
|
|
17747
|
+
if (compact3.length !== body.length && compact3.length % 4 !== 0) return void 0;
|
|
17748
|
+
const out = new Uint8Array(Math.floor(body.length * 3 / 4));
|
|
17749
|
+
let bits = 0;
|
|
17750
|
+
let buffer = 0;
|
|
17751
|
+
let index2 = 0;
|
|
17752
|
+
for (const char of body) {
|
|
17753
|
+
const value = VALUES.get(char);
|
|
17754
|
+
if (value === void 0) return void 0;
|
|
17755
|
+
buffer = (buffer << 6 | value) & 16777215;
|
|
17756
|
+
bits += 6;
|
|
17757
|
+
if (bits >= 8) {
|
|
17758
|
+
bits -= 8;
|
|
17759
|
+
out[index2++] = buffer >> bits & 255;
|
|
17760
|
+
}
|
|
17761
|
+
}
|
|
17762
|
+
return out;
|
|
17763
|
+
}
|
|
17764
|
+
|
|
17765
|
+
// src/digest/sha256.ts
|
|
17766
|
+
var K = new Uint32Array([
|
|
17767
|
+
1116352408,
|
|
17768
|
+
1899447441,
|
|
17769
|
+
3049323471,
|
|
17770
|
+
3921009573,
|
|
17771
|
+
961987163,
|
|
17772
|
+
1508970993,
|
|
17773
|
+
2453635748,
|
|
17774
|
+
2870763221,
|
|
17775
|
+
3624381080,
|
|
17776
|
+
310598401,
|
|
17777
|
+
607225278,
|
|
17778
|
+
1426881987,
|
|
17779
|
+
1925078388,
|
|
17780
|
+
2162078206,
|
|
17781
|
+
2614888103,
|
|
17782
|
+
3248222580,
|
|
17783
|
+
3835390401,
|
|
17784
|
+
4022224774,
|
|
17785
|
+
264347078,
|
|
17786
|
+
604807628,
|
|
17787
|
+
770255983,
|
|
17788
|
+
1249150122,
|
|
17789
|
+
1555081692,
|
|
17790
|
+
1996064986,
|
|
17791
|
+
2554220882,
|
|
17792
|
+
2821834349,
|
|
17793
|
+
2952996808,
|
|
17794
|
+
3210313671,
|
|
17795
|
+
3336571891,
|
|
17796
|
+
3584528711,
|
|
17797
|
+
113926993,
|
|
17798
|
+
338241895,
|
|
17799
|
+
666307205,
|
|
17800
|
+
773529912,
|
|
17801
|
+
1294757372,
|
|
17802
|
+
1396182291,
|
|
17803
|
+
1695183700,
|
|
17804
|
+
1986661051,
|
|
17805
|
+
2177026350,
|
|
17806
|
+
2456956037,
|
|
17807
|
+
2730485921,
|
|
17808
|
+
2820302411,
|
|
17809
|
+
3259730800,
|
|
17810
|
+
3345764771,
|
|
17811
|
+
3516065817,
|
|
17812
|
+
3600352804,
|
|
17813
|
+
4094571909,
|
|
17814
|
+
275423344,
|
|
17815
|
+
430227734,
|
|
17816
|
+
506948616,
|
|
17817
|
+
659060556,
|
|
17818
|
+
883997877,
|
|
17819
|
+
958139571,
|
|
17820
|
+
1322822218,
|
|
17821
|
+
1537002063,
|
|
17822
|
+
1747873779,
|
|
17823
|
+
1955562222,
|
|
17824
|
+
2024104815,
|
|
17825
|
+
2227730452,
|
|
17826
|
+
2361852424,
|
|
17827
|
+
2428436474,
|
|
17828
|
+
2756734187,
|
|
17829
|
+
3204031479,
|
|
17830
|
+
3329325298
|
|
17831
|
+
]);
|
|
17832
|
+
var IV = [
|
|
17833
|
+
1779033703,
|
|
17834
|
+
3144134277,
|
|
17835
|
+
1013904242,
|
|
17836
|
+
2773480762,
|
|
17837
|
+
1359893119,
|
|
17838
|
+
2600822924,
|
|
17839
|
+
528734635,
|
|
17840
|
+
1541459225
|
|
17841
|
+
];
|
|
17842
|
+
var W = new Uint32Array(64);
|
|
17843
|
+
var rotr = (x, n2) => x >>> n2 | x << 32 - n2;
|
|
17844
|
+
function compress(h, view, offset2) {
|
|
17845
|
+
for (let i = 0; i < 16; i++) W[i] = view.getUint32(offset2 + i * 4);
|
|
17846
|
+
for (let i = 16; i < 64; i++) {
|
|
17847
|
+
const a2 = W[i - 15];
|
|
17848
|
+
const b2 = W[i - 2];
|
|
17849
|
+
const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
|
|
17850
|
+
const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
|
|
17851
|
+
W[i] = W[i - 16] + s0 + W[i - 7] + s1 >>> 0;
|
|
17852
|
+
}
|
|
17853
|
+
let a = h[0], b = h[1], c2 = h[2], d = h[3], e = h[4], f = h[5], g = h[6], k = h[7];
|
|
17854
|
+
for (let i = 0; i < 64; i++) {
|
|
17855
|
+
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
17856
|
+
const ch = e & f ^ ~e & g;
|
|
17857
|
+
const t1 = k + S1 + ch + K[i] + W[i] >>> 0;
|
|
17858
|
+
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
17859
|
+
const maj = a & b ^ a & c2 ^ b & c2;
|
|
17860
|
+
const t2 = S0 + maj >>> 0;
|
|
17861
|
+
k = g;
|
|
17862
|
+
g = f;
|
|
17863
|
+
f = e;
|
|
17864
|
+
e = d + t1 >>> 0;
|
|
17865
|
+
d = c2;
|
|
17866
|
+
c2 = b;
|
|
17867
|
+
b = a;
|
|
17868
|
+
a = t1 + t2 >>> 0;
|
|
17869
|
+
}
|
|
17870
|
+
h[0] = h[0] + a >>> 0;
|
|
17871
|
+
h[1] = h[1] + b >>> 0;
|
|
17872
|
+
h[2] = h[2] + c2 >>> 0;
|
|
17873
|
+
h[3] = h[3] + d >>> 0;
|
|
17874
|
+
h[4] = h[4] + e >>> 0;
|
|
17875
|
+
h[5] = h[5] + f >>> 0;
|
|
17876
|
+
h[6] = h[6] + g >>> 0;
|
|
17877
|
+
h[7] = h[7] + k >>> 0;
|
|
17878
|
+
}
|
|
17879
|
+
function pad64(data) {
|
|
17880
|
+
const padded = new Uint8Array(Math.ceil((data.length + 9) / 64) * 64);
|
|
17881
|
+
padded.set(data);
|
|
17882
|
+
padded[data.length] = 128;
|
|
17883
|
+
const bits = data.length * 8;
|
|
17884
|
+
const view = new DataView(padded.buffer);
|
|
17885
|
+
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
17886
|
+
view.setUint32(padded.length - 4, bits >>> 0);
|
|
17887
|
+
return view;
|
|
17888
|
+
}
|
|
17889
|
+
function wordsOut(h) {
|
|
17890
|
+
const out = new Uint8Array(h.length * 4);
|
|
17891
|
+
const view = new DataView(out.buffer);
|
|
17892
|
+
for (let i = 0; i < h.length; i++) view.setUint32(i * 4, h[i]);
|
|
17893
|
+
return out;
|
|
17894
|
+
}
|
|
17895
|
+
function sha256(data) {
|
|
17896
|
+
const h = new Uint32Array(IV);
|
|
17897
|
+
const view = pad64(data);
|
|
17898
|
+
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress(h, view, offset2);
|
|
17899
|
+
return wordsOut(h);
|
|
17900
|
+
}
|
|
17901
|
+
|
|
17902
|
+
// src/digest/sha1.ts
|
|
17903
|
+
var W2 = new Uint32Array(80);
|
|
17904
|
+
var rotl = (x, n2) => x << n2 | x >>> 32 - n2;
|
|
17905
|
+
function compress2(h, view, offset2) {
|
|
17906
|
+
for (let i = 0; i < 16; i++) W2[i] = view.getUint32(offset2 + i * 4);
|
|
17907
|
+
for (let i = 16; i < 80; i++) W2[i] = rotl(W2[i - 3] ^ W2[i - 8] ^ W2[i - 14] ^ W2[i - 16], 1);
|
|
17908
|
+
let a = h[0], b = h[1], c2 = h[2], d = h[3], e = h[4];
|
|
17909
|
+
for (let i = 0; i < 80; i++) {
|
|
17910
|
+
let f;
|
|
17911
|
+
let k;
|
|
17912
|
+
if (i < 20) {
|
|
17913
|
+
f = b & c2 | ~b & d;
|
|
17914
|
+
k = 1518500249;
|
|
17915
|
+
} else if (i < 40) {
|
|
17916
|
+
f = b ^ c2 ^ d;
|
|
17917
|
+
k = 1859775393;
|
|
17918
|
+
} else if (i < 60) {
|
|
17919
|
+
f = b & c2 | b & d | c2 & d;
|
|
17920
|
+
k = 2400959708;
|
|
17921
|
+
} else {
|
|
17922
|
+
f = b ^ c2 ^ d;
|
|
17923
|
+
k = 3395469782;
|
|
17924
|
+
}
|
|
17925
|
+
const t = rotl(a, 5) + f + e + k + W2[i] >>> 0;
|
|
17926
|
+
e = d;
|
|
17927
|
+
d = c2;
|
|
17928
|
+
c2 = rotl(b, 30) >>> 0;
|
|
17929
|
+
b = a;
|
|
17930
|
+
a = t;
|
|
17931
|
+
}
|
|
17932
|
+
h[0] = h[0] + a >>> 0;
|
|
17933
|
+
h[1] = h[1] + b >>> 0;
|
|
17934
|
+
h[2] = h[2] + c2 >>> 0;
|
|
17935
|
+
h[3] = h[3] + d >>> 0;
|
|
17936
|
+
h[4] = h[4] + e >>> 0;
|
|
17937
|
+
}
|
|
17938
|
+
function sha1(data) {
|
|
17939
|
+
const h = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
|
|
17940
|
+
const view = pad64(data);
|
|
17941
|
+
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress2(h, view, offset2);
|
|
17942
|
+
return wordsOut(h);
|
|
17943
|
+
}
|
|
17944
|
+
|
|
17945
|
+
// src/digest/sha512.ts
|
|
17946
|
+
var K2 = new Uint32Array([
|
|
17947
|
+
1116352408,
|
|
17948
|
+
3609767458,
|
|
17949
|
+
1899447441,
|
|
17950
|
+
602891725,
|
|
17951
|
+
3049323471,
|
|
17952
|
+
3964484399,
|
|
17953
|
+
3921009573,
|
|
17954
|
+
2173295548,
|
|
17955
|
+
961987163,
|
|
17956
|
+
4081628472,
|
|
17957
|
+
1508970993,
|
|
17958
|
+
3053834265,
|
|
17959
|
+
2453635748,
|
|
17960
|
+
2937671579,
|
|
17961
|
+
2870763221,
|
|
17962
|
+
3664609560,
|
|
17963
|
+
3624381080,
|
|
17964
|
+
2734883394,
|
|
17965
|
+
310598401,
|
|
17966
|
+
1164996542,
|
|
17967
|
+
607225278,
|
|
17968
|
+
1323610764,
|
|
17969
|
+
1426881987,
|
|
17970
|
+
3590304994,
|
|
17971
|
+
1925078388,
|
|
17972
|
+
4068182383,
|
|
17973
|
+
2162078206,
|
|
17974
|
+
991336113,
|
|
17975
|
+
2614888103,
|
|
17976
|
+
633803317,
|
|
17977
|
+
3248222580,
|
|
17978
|
+
3479774868,
|
|
17979
|
+
3835390401,
|
|
17980
|
+
2666613458,
|
|
17981
|
+
4022224774,
|
|
17982
|
+
944711139,
|
|
17983
|
+
264347078,
|
|
17984
|
+
2341262773,
|
|
17985
|
+
604807628,
|
|
17986
|
+
2007800933,
|
|
17987
|
+
770255983,
|
|
17988
|
+
1495990901,
|
|
17989
|
+
1249150122,
|
|
17990
|
+
1856431235,
|
|
17991
|
+
1555081692,
|
|
17992
|
+
3175218132,
|
|
17993
|
+
1996064986,
|
|
17994
|
+
2198950837,
|
|
17995
|
+
2554220882,
|
|
17996
|
+
3999719339,
|
|
17997
|
+
2821834349,
|
|
17998
|
+
766784016,
|
|
17999
|
+
2952996808,
|
|
18000
|
+
2566594879,
|
|
18001
|
+
3210313671,
|
|
18002
|
+
3203337956,
|
|
18003
|
+
3336571891,
|
|
18004
|
+
1034457026,
|
|
18005
|
+
3584528711,
|
|
18006
|
+
2466948901,
|
|
18007
|
+
113926993,
|
|
18008
|
+
3758326383,
|
|
18009
|
+
338241895,
|
|
18010
|
+
168717936,
|
|
18011
|
+
666307205,
|
|
18012
|
+
1188179964,
|
|
18013
|
+
773529912,
|
|
18014
|
+
1546045734,
|
|
18015
|
+
1294757372,
|
|
18016
|
+
1522805485,
|
|
18017
|
+
1396182291,
|
|
18018
|
+
2643833823,
|
|
18019
|
+
1695183700,
|
|
18020
|
+
2343527390,
|
|
18021
|
+
1986661051,
|
|
18022
|
+
1014477480,
|
|
18023
|
+
2177026350,
|
|
18024
|
+
1206759142,
|
|
18025
|
+
2456956037,
|
|
18026
|
+
344077627,
|
|
18027
|
+
2730485921,
|
|
18028
|
+
1290863460,
|
|
18029
|
+
2820302411,
|
|
18030
|
+
3158454273,
|
|
18031
|
+
3259730800,
|
|
18032
|
+
3505952657,
|
|
18033
|
+
3345764771,
|
|
18034
|
+
106217008,
|
|
18035
|
+
3516065817,
|
|
18036
|
+
3606008344,
|
|
18037
|
+
3600352804,
|
|
18038
|
+
1432725776,
|
|
18039
|
+
4094571909,
|
|
18040
|
+
1467031594,
|
|
18041
|
+
275423344,
|
|
18042
|
+
851169720,
|
|
18043
|
+
430227734,
|
|
18044
|
+
3100823752,
|
|
18045
|
+
506948616,
|
|
18046
|
+
1363258195,
|
|
18047
|
+
659060556,
|
|
18048
|
+
3750685593,
|
|
18049
|
+
883997877,
|
|
18050
|
+
3785050280,
|
|
18051
|
+
958139571,
|
|
18052
|
+
3318307427,
|
|
18053
|
+
1322822218,
|
|
18054
|
+
3812723403,
|
|
18055
|
+
1537002063,
|
|
18056
|
+
2003034995,
|
|
18057
|
+
1747873779,
|
|
18058
|
+
3602036899,
|
|
18059
|
+
1955562222,
|
|
18060
|
+
1575990012,
|
|
18061
|
+
2024104815,
|
|
18062
|
+
1125592928,
|
|
18063
|
+
2227730452,
|
|
18064
|
+
2716904306,
|
|
18065
|
+
2361852424,
|
|
18066
|
+
442776044,
|
|
18067
|
+
2428436474,
|
|
18068
|
+
593698344,
|
|
18069
|
+
2756734187,
|
|
18070
|
+
3733110249,
|
|
18071
|
+
3204031479,
|
|
18072
|
+
2999351573,
|
|
18073
|
+
3329325298,
|
|
18074
|
+
3815920427,
|
|
18075
|
+
3391569614,
|
|
18076
|
+
3928383900,
|
|
18077
|
+
3515267271,
|
|
18078
|
+
566280711,
|
|
18079
|
+
3940187606,
|
|
18080
|
+
3454069534,
|
|
18081
|
+
4118630271,
|
|
18082
|
+
4000239992,
|
|
18083
|
+
116418474,
|
|
18084
|
+
1914138554,
|
|
18085
|
+
174292421,
|
|
18086
|
+
2731055270,
|
|
18087
|
+
289380356,
|
|
18088
|
+
3203993006,
|
|
18089
|
+
460393269,
|
|
18090
|
+
320620315,
|
|
18091
|
+
685471733,
|
|
18092
|
+
587496836,
|
|
18093
|
+
852142971,
|
|
18094
|
+
1086792851,
|
|
18095
|
+
1017036298,
|
|
18096
|
+
365543100,
|
|
18097
|
+
1126000580,
|
|
18098
|
+
2618297676,
|
|
18099
|
+
1288033470,
|
|
18100
|
+
3409855158,
|
|
18101
|
+
1501505948,
|
|
18102
|
+
4234509866,
|
|
18103
|
+
1607167915,
|
|
18104
|
+
987167468,
|
|
18105
|
+
1816402316,
|
|
18106
|
+
1246189591
|
|
18107
|
+
]);
|
|
18108
|
+
var IV_512 = [
|
|
18109
|
+
1779033703,
|
|
18110
|
+
4089235720,
|
|
18111
|
+
3144134277,
|
|
18112
|
+
2227873595,
|
|
18113
|
+
1013904242,
|
|
18114
|
+
4271175723,
|
|
18115
|
+
2773480762,
|
|
18116
|
+
1595750129,
|
|
18117
|
+
1359893119,
|
|
18118
|
+
2917565137,
|
|
18119
|
+
2600822924,
|
|
18120
|
+
725511199,
|
|
18121
|
+
528734635,
|
|
18122
|
+
4215389547,
|
|
18123
|
+
1541459225,
|
|
18124
|
+
327033209
|
|
18125
|
+
];
|
|
18126
|
+
var IV_384 = [
|
|
18127
|
+
3418070365,
|
|
18128
|
+
3238371032,
|
|
18129
|
+
1654270250,
|
|
18130
|
+
914150663,
|
|
18131
|
+
2438529370,
|
|
18132
|
+
812702999,
|
|
18133
|
+
355462360,
|
|
18134
|
+
4144912697,
|
|
18135
|
+
1731405415,
|
|
18136
|
+
4290775857,
|
|
18137
|
+
2394180231,
|
|
18138
|
+
1750603025,
|
|
18139
|
+
3675008525,
|
|
18140
|
+
1694076839,
|
|
18141
|
+
1203062813,
|
|
18142
|
+
3204075428
|
|
18143
|
+
];
|
|
18144
|
+
var W3 = new Uint32Array(160);
|
|
18145
|
+
function compress3(h, data, offset2) {
|
|
18146
|
+
for (let i = 0; i < 32; i++) {
|
|
18147
|
+
const o = offset2 + i * 4;
|
|
18148
|
+
W3[i] = (data[o] << 24 | data[o + 1] << 16 | data[o + 2] << 8 | data[o + 3]) >>> 0;
|
|
18149
|
+
}
|
|
18150
|
+
for (let i = 16; i < 80; i++) {
|
|
18151
|
+
const xh = W3[(i - 15) * 2];
|
|
18152
|
+
const xl = W3[(i - 15) * 2 + 1];
|
|
18153
|
+
const s0h = (xh >>> 1 | xl << 31) ^ (xh >>> 8 | xl << 24) ^ xh >>> 7;
|
|
18154
|
+
const s0l = (xl >>> 1 | xh << 31) ^ (xl >>> 8 | xh << 24) ^ (xl >>> 7 | xh << 25);
|
|
18155
|
+
const yh = W3[(i - 2) * 2];
|
|
18156
|
+
const yl = W3[(i - 2) * 2 + 1];
|
|
18157
|
+
const s1h = (yh >>> 19 | yl << 13) ^ (yl >>> 29 | yh << 3) ^ yh >>> 6;
|
|
18158
|
+
const s1l = (yl >>> 19 | yh << 13) ^ (yh >>> 29 | yl << 3) ^ (yl >>> 6 | yh << 26);
|
|
18159
|
+
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(i - 7) * 2 + 1] + W3[(i - 16) * 2 + 1];
|
|
18160
|
+
const hi = s0h + s1h + W3[(i - 7) * 2] + W3[(i - 16) * 2] + Math.floor(lo / 4294967296);
|
|
18161
|
+
lo >>>= 0;
|
|
18162
|
+
W3[i * 2] = hi >>> 0;
|
|
18163
|
+
W3[i * 2 + 1] = lo;
|
|
18164
|
+
}
|
|
18165
|
+
let ah = h[0], al = h[1], bh = h[2], bl = h[3], ch = h[4], cl = h[5], dh = h[6], dl = h[7];
|
|
18166
|
+
let eh = h[8], el2 = h[9], fh = h[10], fl = h[11], gh = h[12], gl = h[13], hh = h[14], hl = h[15];
|
|
18167
|
+
for (let i = 0; i < 80; i++) {
|
|
18168
|
+
const S1h = (eh >>> 14 | el2 << 18) ^ (eh >>> 18 | el2 << 14) ^ (el2 >>> 9 | eh << 23);
|
|
18169
|
+
const S1l = (el2 >>> 14 | eh << 18) ^ (el2 >>> 18 | eh << 14) ^ (eh >>> 9 | el2 << 23);
|
|
18170
|
+
const chh = eh & fh ^ ~eh & gh;
|
|
18171
|
+
const chl = el2 & fl ^ ~el2 & gl;
|
|
18172
|
+
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) + K2[i * 2 + 1] + W3[i * 2 + 1];
|
|
18173
|
+
const t1h = hh + S1h + chh + K2[i * 2] + W3[i * 2] + Math.floor(t1l / 4294967296);
|
|
18174
|
+
t1l >>>= 0;
|
|
18175
|
+
const S0h = (ah >>> 28 | al << 4) ^ (al >>> 2 | ah << 30) ^ (al >>> 7 | ah << 25);
|
|
18176
|
+
const S0l = (al >>> 28 | ah << 4) ^ (ah >>> 2 | al << 30) ^ (ah >>> 7 | al << 25);
|
|
18177
|
+
const majh = ah & bh ^ ah & ch ^ bh & ch;
|
|
18178
|
+
const majl = al & bl ^ al & cl ^ bl & cl;
|
|
18179
|
+
let t2l = (S0l >>> 0) + (majl >>> 0);
|
|
18180
|
+
const t2h = S0h + majh + Math.floor(t2l / 4294967296);
|
|
18181
|
+
t2l >>>= 0;
|
|
18182
|
+
hh = gh;
|
|
18183
|
+
hl = gl;
|
|
18184
|
+
gh = fh;
|
|
18185
|
+
gl = fl;
|
|
18186
|
+
fh = eh;
|
|
18187
|
+
fl = el2;
|
|
18188
|
+
let nl = (dl >>> 0) + t1l;
|
|
18189
|
+
eh = dh + t1h + Math.floor(nl / 4294967296) >>> 0;
|
|
18190
|
+
el2 = nl >>> 0;
|
|
18191
|
+
dh = ch;
|
|
18192
|
+
dl = cl;
|
|
18193
|
+
ch = bh;
|
|
18194
|
+
cl = bl;
|
|
18195
|
+
bh = ah;
|
|
18196
|
+
bl = al;
|
|
18197
|
+
nl = t1l + t2l;
|
|
18198
|
+
ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
|
|
18199
|
+
al = nl >>> 0;
|
|
18200
|
+
}
|
|
18201
|
+
const add = (i, xh, xl) => {
|
|
18202
|
+
const lo = (h[i + 1] >>> 0) + (xl >>> 0);
|
|
18203
|
+
h[i] = h[i] + xh + Math.floor(lo / 4294967296) >>> 0;
|
|
18204
|
+
h[i + 1] = lo >>> 0;
|
|
18205
|
+
};
|
|
18206
|
+
add(0, ah, al);
|
|
18207
|
+
add(2, bh, bl);
|
|
18208
|
+
add(4, ch, cl);
|
|
18209
|
+
add(6, dh, dl);
|
|
18210
|
+
add(8, eh, el2);
|
|
18211
|
+
add(10, fh, fl);
|
|
18212
|
+
add(12, gh, gl);
|
|
18213
|
+
add(14, hh, hl);
|
|
18214
|
+
}
|
|
18215
|
+
function digest64(data, iv, bytes) {
|
|
18216
|
+
const h = new Uint32Array(iv);
|
|
18217
|
+
const padded = new Uint8Array(Math.ceil((data.length + 17) / 128) * 128);
|
|
18218
|
+
padded.set(data);
|
|
18219
|
+
padded[data.length] = 128;
|
|
18220
|
+
const bits = data.length * 8;
|
|
18221
|
+
const view = new DataView(padded.buffer);
|
|
18222
|
+
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
18223
|
+
view.setUint32(padded.length - 4, bits >>> 0);
|
|
18224
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += 128) compress3(h, padded, offset2);
|
|
18225
|
+
const out = new Uint8Array(bytes);
|
|
18226
|
+
const outView = new DataView(out.buffer);
|
|
18227
|
+
for (let i = 0; i < bytes / 4; i++) outView.setUint32(i * 4, h[i]);
|
|
18228
|
+
return out;
|
|
18229
|
+
}
|
|
18230
|
+
var sha512 = (data) => digest64(data, IV_512, 64);
|
|
18231
|
+
var sha384 = (data) => digest64(data, IV_384, 48);
|
|
18232
|
+
|
|
18233
|
+
// src/digest/digest.ts
|
|
18234
|
+
var DIGESTS = {
|
|
18235
|
+
"SHA-1": sha1,
|
|
18236
|
+
"SHA-256": sha256,
|
|
18237
|
+
"SHA-384": sha384,
|
|
18238
|
+
"SHA-512": sha512
|
|
18239
|
+
};
|
|
18240
|
+
function digestFunction(name) {
|
|
18241
|
+
const canonical = normalizeDigestAlgorithmName(name);
|
|
18242
|
+
return canonical && canonical in DIGESTS ? DIGESTS[canonical] : void 0;
|
|
18243
|
+
}
|
|
18244
|
+
|
|
18245
|
+
// src/digest/password-hash.ts
|
|
18246
|
+
var MAX_SPIN_COUNT = 1e7;
|
|
18247
|
+
var validSpinCount = (spinCount) => spinCount === void 0 || Number.isInteger(spinCount) && spinCount >= 0 && spinCount <= MAX_SPIN_COUNT;
|
|
18248
|
+
function spin(password, salt, spinCount, digest) {
|
|
18249
|
+
const input = new Uint8Array(salt.length + password.length * 2);
|
|
18250
|
+
input.set(salt);
|
|
18251
|
+
for (let i = 0; i < password.length; i++) {
|
|
18252
|
+
const code = password.charCodeAt(i);
|
|
18253
|
+
input[salt.length + i * 2] = code & 255;
|
|
18254
|
+
input[salt.length + i * 2 + 1] = code >> 8;
|
|
18255
|
+
}
|
|
18256
|
+
let value = digest(input);
|
|
18257
|
+
const buffer = new Uint8Array(value.length + 4);
|
|
18258
|
+
const view = new DataView(buffer.buffer);
|
|
18259
|
+
for (let i = 0; i < spinCount; i++) {
|
|
18260
|
+
buffer.set(value);
|
|
18261
|
+
view.setUint32(value.length, i, true);
|
|
18262
|
+
value = digest(buffer);
|
|
18263
|
+
}
|
|
18264
|
+
return value;
|
|
18265
|
+
}
|
|
18266
|
+
function hashBytes(password, { algorithmName, saltValue, spinCount }) {
|
|
18267
|
+
const digest = digestFunction(algorithmName);
|
|
18268
|
+
const salt = decodeBase64(saltValue);
|
|
18269
|
+
if (!digest || !salt || !validSpinCount(spinCount)) return void 0;
|
|
18270
|
+
return spin(password, salt, spinCount ?? 0, digest);
|
|
18271
|
+
}
|
|
18272
|
+
function hashPassword(password, options) {
|
|
18273
|
+
const bytes = hashBytes(password, options);
|
|
18274
|
+
return bytes && encodeBase64(bytes);
|
|
18275
|
+
}
|
|
18276
|
+
function verifyPasswordHash(password, hash) {
|
|
18277
|
+
if (!digestFunction(hash.algorithmName)) return void 0;
|
|
18278
|
+
const expected = decodeBase64(hash.hashValue);
|
|
18279
|
+
const actual = expected && hashBytes(password, hash);
|
|
18280
|
+
if (!expected || !actual || actual.length !== expected.length) return false;
|
|
18281
|
+
let difference = 0;
|
|
18282
|
+
for (let i = 0; i < actual.length; i++) difference |= actual[i] ^ expected[i];
|
|
18283
|
+
return difference === 0;
|
|
18284
|
+
}
|
|
18285
|
+
|
|
17667
18286
|
// src/xlsx/edit/protection.ts
|
|
17668
18287
|
function legacyPasswordHash(password) {
|
|
17669
18288
|
let hash = 0;
|
|
@@ -17675,15 +18294,30 @@ function legacyPasswordHash(password) {
|
|
|
17675
18294
|
hash ^= 52811;
|
|
17676
18295
|
return hash.toString(16).toUpperCase();
|
|
17677
18296
|
}
|
|
17678
|
-
var
|
|
18297
|
+
var sameLegacyHash = (hash, password) => hash.toUpperCase() === legacyPasswordHash(password);
|
|
18298
|
+
function matchesHashes(modern, legacy, password) {
|
|
18299
|
+
const verdict = modern ? verifyPasswordHash(password, modern) : void 0;
|
|
18300
|
+
if (verdict !== void 0) return verdict;
|
|
18301
|
+
if (legacy !== void 0) return sameLegacyHash(legacy, password);
|
|
18302
|
+
return !modern;
|
|
18303
|
+
}
|
|
18304
|
+
var protectionOf = (sheet) => sheet && "rows" in sheet ? sheet.protection : sheet;
|
|
17679
18305
|
function verifySheetPassword(sheet, password) {
|
|
17680
|
-
const protection = sheet
|
|
18306
|
+
const protection = protectionOf(sheet);
|
|
17681
18307
|
if (!protection?.sheet) return true;
|
|
17682
|
-
return
|
|
18308
|
+
return matchesHashes(protection.modernHash, protection.passwordHash, password);
|
|
18309
|
+
}
|
|
18310
|
+
async function verifySheetPasswordAsync(sheet, password) {
|
|
18311
|
+
return verifySheetPassword(sheet, password);
|
|
18312
|
+
}
|
|
18313
|
+
async function modernPasswordHash(password, hash, digest = "SHA-512") {
|
|
18314
|
+
const value = hashPassword(password, { ...hash, algorithmName: digest });
|
|
18315
|
+
if (value === void 0) throw new Error(`Cannot compute a ${digest} password hash`);
|
|
18316
|
+
return value;
|
|
17683
18317
|
}
|
|
17684
18318
|
function verifyWorkbookPassword(workbook, password) {
|
|
17685
18319
|
if (!workbook.structureLocked) return true;
|
|
17686
|
-
return
|
|
18320
|
+
return matchesHashes(workbook.workbookModernHash, workbook.workbookPasswordHash, password);
|
|
17687
18321
|
}
|
|
17688
18322
|
var WRONG_PASSWORD = "The password you supplied is not correct.";
|
|
17689
18323
|
function setSheetProtection(ctx, s, protection, password) {
|
|
@@ -17700,8 +18334,13 @@ function setSheetProtection(ctx, s, protection, password) {
|
|
|
17700
18334
|
return;
|
|
17701
18335
|
}
|
|
17702
18336
|
const next = structuredClone(protection);
|
|
17703
|
-
if (password)
|
|
17704
|
-
|
|
18337
|
+
if (password) {
|
|
18338
|
+
next.passwordHash = legacyPasswordHash(password);
|
|
18339
|
+
delete next.modernHash;
|
|
18340
|
+
} else if (password === "") {
|
|
18341
|
+
delete next.passwordHash;
|
|
18342
|
+
delete next.modernHash;
|
|
18343
|
+
}
|
|
17705
18344
|
sheet.protection = next;
|
|
17706
18345
|
},
|
|
17707
18346
|
{ sheet: s }
|
|
@@ -17716,9 +18355,11 @@ function setWorkbookProtection(ctx, locked, password) {
|
|
|
17716
18355
|
workbook.structureLocked = true;
|
|
17717
18356
|
if (password) workbook.workbookPasswordHash = legacyPasswordHash(password);
|
|
17718
18357
|
else if (password === "") delete workbook.workbookPasswordHash;
|
|
18358
|
+
if (password !== void 0) delete workbook.workbookModernHash;
|
|
17719
18359
|
} else {
|
|
17720
18360
|
delete workbook.structureLocked;
|
|
17721
18361
|
delete workbook.workbookPasswordHash;
|
|
18362
|
+
delete workbook.workbookModernHash;
|
|
17722
18363
|
}
|
|
17723
18364
|
});
|
|
17724
18365
|
}
|
|
@@ -20393,4 +21034,4 @@ function createRefEvaluator(workbook, calc, options = {}) {
|
|
|
20393
21034
|
};
|
|
20394
21035
|
}
|
|
20395
21036
|
|
|
20396
|
-
export { AxisMetrics, BORDER_STYLES, BUILTIN_CELL_STYLES, BUILTIN_NUMBER_FORMATS, CIRCULAR_REFERENCE_WARNING, COLUMN_PADDING_PX, DEFAULT_BASE_COL_WIDTH, DEFAULT_COL_WIDTH, DEFAULT_MAX_DIGIT_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE, ERROR_CODES, FORMAT_PRESETS, FUNCTION_CATALOG, FormulaError, IMAGE_EXTENSIONS, INDENT_PX_PER_LEVEL, INDEXED_COLORS, MAX_COL, MAX_DATE_SERIAL, MAX_OUTLINE_LEVEL, MAX_ROW, OVERFLOW_TEXT, PERCENT_SCALE, THEME_SLOTS, TIME_PERIODS, addFuturePrefixes, applyBuiltinStyle, applyStylePatch, applyTint, approximateMeasure, autoFitColumnWidth, autoFitRowHeight, autoGrowRows, autoSeriesColor, bordersView, builtinCellStyle, builtinFormatId, calcModeOf, categoryTotals, cellError, cellKey, cellView, cellsFromText, charactersToColumnWidth, charactersToPixels, chartView, columnIndex, columnLabel, columnWidthToPixels, compareCellValues, compareValues, createCalcEngine, createConditionalFormatEvaluator, createEditSession, createGridMetrics, createRefEvaluator, createWorkbook, createWorksheet, currentRegion, dateToSerial, defaultCellStyle, defaultColumnPixels, deleteCell, deleteSheetInFormula, detectSeries, edgeView, effectiveStyleId, fillView, fontView, forEachCell, forEachCellInRange, formatAddress, formatAxisValue, formatGeneral, formatRange, formatRefSpec, formatValue, generalAlignment, getCell, getCellAt, getValue, hls240ToRgb, inTimePeriod, internStyle, isCellError, isDateFormat, isEmptyCell, isErrorCode, isOverflowTarget, isSpilledCell, keyToAddress, legacyPasswordHash, lineHeightPoints, listValidationOptions, loadXlsx, mergeAt, mergeFont, mergeView, mixColors, modulateLuminance, moveReferencesInFormula, navigate, needsArrayEvaluation, newMediaPart, nextSheetId, nextSheetName, niceScale, normalizeRange, numberToText, overflowExtent, parseAddress, parseCellInput, parseFormula, parseHex, parseHtmlTable, parseNumberText, parseRange, parseTsv, patchStyle, percentile, pixelsToCharacters, pixelsToColumnWidth, pixelsToPoints, pointsToPixels, presetEdges, putCell, queryPattern, quoteSheetName, rangeContains, rangeSize, rangesIntersect, referenceSpans, referencedRanges, renameSheetInFormula, renameTableInFormula, renderChartSvg, replaceText, resolveColor, rgbToHls240, rotationDegrees, rowsToRefit, saveXlsx, scaleColor, selectionStats, serialToDate, sheetByName, shiftFormula, shiftRange, shiftSpan, spillAnchorOf, stepDecimals, stripFuturePrefixes, structuredToA1, styleAt, styleKey, subtractRange, themeColor, timePeriodFormula, toHexColor, toHtml, toTsv, tokenize, translateFormula, translateReferences, uniqueHeaders, usedRange, validateCellInput, validateDefinedName, validateSheetName, validateTableName, validationAt, verifySheetPassword, verifyWorkbookPassword, visibleCells, wrappedLineCount, zoomPercent };
|
|
21037
|
+
export { AxisMetrics, BORDER_STYLES, BUILTIN_CELL_STYLES, BUILTIN_NUMBER_FORMATS, CIRCULAR_REFERENCE_WARNING, COLUMN_PADDING_PX, DEFAULT_BASE_COL_WIDTH, DEFAULT_COL_WIDTH, DEFAULT_MAX_DIGIT_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE, ERROR_CODES, FORMAT_PRESETS, FUNCTION_CATALOG, FormulaError, IMAGE_EXTENSIONS, INDENT_PX_PER_LEVEL, INDEXED_COLORS, MAX_COL, MAX_DATE_SERIAL, MAX_OUTLINE_LEVEL, MAX_ROW, OVERFLOW_TEXT, PERCENT_SCALE, THEME_SLOTS, TIME_PERIODS, addFuturePrefixes, applyBuiltinStyle, applyStylePatch, applyTint, approximateMeasure, autoFitColumnWidth, autoFitRowHeight, autoGrowRows, autoSeriesColor, bordersView, builtinCellStyle, builtinFormatId, calcModeOf, categoryTotals, cellError, cellKey, cellView, cellsFromText, charactersToColumnWidth, charactersToPixels, chartView, columnIndex, columnLabel, columnWidthToPixels, compareCellValues, compareValues, createCalcEngine, createConditionalFormatEvaluator, createEditSession, createGridMetrics, createRefEvaluator, createWorkbook, createWorksheet, currentRegion, dateToSerial, defaultCellStyle, defaultColumnPixels, deleteCell, deleteSheetInFormula, detectSeries, edgeView, effectiveStyleId, fillView, fontView, forEachCell, forEachCellInRange, formatAddress, formatAxisValue, formatGeneral, formatRange, formatRefSpec, formatValue, generalAlignment, getCell, getCellAt, getValue, hls240ToRgb, inTimePeriod, internStyle, isCellError, isDateFormat, isEmptyCell, isErrorCode, isOverflowTarget, isSpilledCell, keyToAddress, legacyPasswordHash, lineHeightPoints, listValidationOptions, loadXlsx, mergeAt, mergeFont, mergeView, mixColors, modernPasswordHash, modulateLuminance, moveReferencesInFormula, navigate, needsArrayEvaluation, newMediaPart, nextSheetId, nextSheetName, niceScale, normalizeRange, numberToText, overflowExtent, parseAddress, parseCellInput, parseFormula, parseHex, parseHtmlTable, parseNumberText, parseRange, parseTsv, patchStyle, percentile, pixelsToCharacters, pixelsToColumnWidth, pixelsToPoints, pointsToPixels, presetEdges, putCell, queryPattern, quoteSheetName, rangeContains, rangeSize, rangesIntersect, referenceSpans, referencedRanges, renameSheetInFormula, renameTableInFormula, renderChartSvg, replaceText, resolveColor, rgbToHls240, rotationDegrees, rowsToRefit, saveXlsx, scaleColor, selectionStats, serialToDate, sheetByName, shiftFormula, shiftRange, shiftSpan, spillAnchorOf, stepDecimals, stripFuturePrefixes, structuredToA1, styleAt, styleKey, subtractRange, themeColor, timePeriodFormula, toHexColor, toHtml, toTsv, tokenize, translateFormula, translateReferences, uniqueHeaders, usedRange, validateCellInput, validateDefinedName, validateSheetName, validateTableName, validationAt, verifySheetPassword, verifySheetPasswordAsync, verifyWorkbookPassword, visibleCells, wrappedLineCount, zoomPercent };
|