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.
Files changed (69) hide show
  1. package/README.md +1 -0
  2. package/dist/digest/algorithm-names.d.ts +20 -0
  3. package/dist/digest/algorithm-names.d.ts.map +1 -0
  4. package/dist/digest/base64.d.ts +8 -0
  5. package/dist/digest/base64.d.ts.map +1 -0
  6. package/dist/digest/digest.d.ts +13 -0
  7. package/dist/digest/digest.d.ts.map +1 -0
  8. package/dist/digest/index.cjs +594 -0
  9. package/dist/digest/index.d.ts +8 -0
  10. package/dist/digest/index.d.ts.map +1 -0
  11. package/dist/digest/index.mjs +581 -0
  12. package/dist/digest/password-hash.d.ts +30 -0
  13. package/dist/digest/password-hash.d.ts.map +1 -0
  14. package/dist/digest/sha1.d.ts +3 -0
  15. package/dist/digest/sha1.d.ts.map +1 -0
  16. package/dist/digest/sha256.d.ts +10 -0
  17. package/dist/digest/sha256.d.ts.map +1 -0
  18. package/dist/digest/sha512.d.ts +5 -0
  19. package/dist/digest/sha512.d.ts.map +1 -0
  20. package/dist/docx/block-parser.d.ts.map +1 -1
  21. package/dist/docx/embedded.cjs +131 -54
  22. package/dist/docx/embedded.mjs +131 -54
  23. package/dist/docx/equation.d.ts +8 -0
  24. package/dist/docx/equation.d.ts.map +1 -0
  25. package/dist/docx/index.cjs +131 -54
  26. package/dist/docx/index.mjs +131 -54
  27. package/dist/docx/layout/adapter.d.ts.map +1 -1
  28. package/dist/docx/layout/index.cjs +3 -1
  29. package/dist/docx/layout/index.mjs +3 -1
  30. package/dist/docx/load/index.cjs +133 -56
  31. package/dist/docx/load/index.mjs +133 -56
  32. package/dist/docx/model-run.d.ts +5 -0
  33. package/dist/docx/model-run.d.ts.map +1 -1
  34. package/dist/docx/parse-revisions.d.ts.map +1 -1
  35. package/dist/docx/parse-table.d.ts.map +1 -1
  36. package/dist/docx/write-inline.d.ts.map +1 -1
  37. package/dist/docx/write-table-margins.d.ts +5 -0
  38. package/dist/docx/write-table-margins.d.ts.map +1 -0
  39. package/dist/docx/write-table-properties.d.ts +3 -1
  40. package/dist/docx/write-table-properties.d.ts.map +1 -1
  41. package/dist/docx/write-table.d.ts.map +1 -1
  42. package/dist/index.cjs +598 -0
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.mjs +598 -1
  46. package/dist/xlsx/edit/history.d.ts +1 -1
  47. package/dist/xlsx/edit/history.d.ts.map +1 -1
  48. package/dist/xlsx/edit/index.d.ts +1 -1
  49. package/dist/xlsx/edit/index.d.ts.map +1 -1
  50. package/dist/xlsx/edit/protection.d.ts +18 -6
  51. package/dist/xlsx/edit/protection.d.ts.map +1 -1
  52. package/dist/xlsx/edit/types.d.ts +2 -2
  53. package/dist/xlsx/index.cjs +671 -28
  54. package/dist/xlsx/index.mjs +670 -29
  55. package/dist/xlsx/load/index.cjs +56 -19
  56. package/dist/xlsx/load/index.mjs +56 -19
  57. package/dist/xlsx/model.d.ts +21 -0
  58. package/dist/xlsx/model.d.ts.map +1 -1
  59. package/dist/xlsx/read/load.d.ts.map +1 -1
  60. package/dist/xlsx/read/password-hash.d.ts +15 -0
  61. package/dist/xlsx/read/password-hash.d.ts.map +1 -0
  62. package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
  63. package/dist/xlsx/read/workbook-part.d.ts +3 -1
  64. package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
  65. package/dist/xlsx/write/password-hash.d.ts +8 -0
  66. package/dist/xlsx/write/password-hash.d.ts.map +1 -0
  67. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  68. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  69. package/package.json +6 -1
package/dist/index.mjs CHANGED
@@ -1528,6 +1528,603 @@ async function loadDiagram(hostPart, relationshipIds, host) {
1528
1528
  };
1529
1529
  }
1530
1530
 
1531
+ // src/digest/index.ts
1532
+ var digest_exports = {};
1533
+ __export(digest_exports, {
1534
+ MAX_SPIN_COUNT: () => MAX_SPIN_COUNT,
1535
+ decodeBase64: () => decodeBase64,
1536
+ digestFunction: () => digestFunction,
1537
+ digestSync: () => digestSync,
1538
+ encodeBase64: () => encodeBase64,
1539
+ hashPassword: () => hashPassword,
1540
+ normalizeDigestAlgorithmName: () => normalizeDigestAlgorithmName,
1541
+ sha1: () => sha1,
1542
+ sha256: () => sha256,
1543
+ sha384: () => sha384,
1544
+ sha512: () => sha512,
1545
+ verifyPasswordHash: () => verifyPasswordHash
1546
+ });
1547
+
1548
+ // src/digest/algorithm-names.ts
1549
+ var CANONICAL_BY_LOOKUP_KEY = {
1550
+ SHA1: "SHA-1",
1551
+ SHA256: "SHA-256",
1552
+ SHA384: "SHA-384",
1553
+ SHA512: "SHA-512",
1554
+ MD2: "MD2",
1555
+ MD4: "MD4",
1556
+ MD5: "MD5",
1557
+ RIPEMD128: "RIPEMD-128",
1558
+ RIPEMD160: "RIPEMD-160",
1559
+ WHIRLPOOL: "WHIRLPOOL"
1560
+ };
1561
+ function normalizeDigestAlgorithmName(name) {
1562
+ const key = name.toUpperCase().replace(/[-_\s]/g, "");
1563
+ return Object.hasOwn(CANONICAL_BY_LOOKUP_KEY, key) ? CANONICAL_BY_LOOKUP_KEY[key] : void 0;
1564
+ }
1565
+
1566
+ // src/digest/base64.ts
1567
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1568
+ var VALUES = new Map([...ALPHABET].map((char, index) => [char, index]));
1569
+ function encodeBase64(bytes) {
1570
+ let out = "";
1571
+ for (let i = 0; i < bytes.length; i += 3) {
1572
+ const a = bytes[i];
1573
+ const b = bytes[i + 1];
1574
+ const c = bytes[i + 2];
1575
+ const n = a << 16 | (b ?? 0) << 8 | (c ?? 0);
1576
+ out += ALPHABET[n >> 18] + ALPHABET[n >> 12 & 63];
1577
+ out += b === void 0 ? "=" : ALPHABET[n >> 6 & 63];
1578
+ out += c === void 0 ? "=" : ALPHABET[n & 63];
1579
+ }
1580
+ return out;
1581
+ }
1582
+ function decodeBase64(text) {
1583
+ const compact = text.replace(/\s+/g, "");
1584
+ const body = compact.replace(/={1,2}$/, "");
1585
+ if (body.length % 4 === 1) return void 0;
1586
+ if (compact.length !== body.length && compact.length % 4 !== 0) return void 0;
1587
+ const out = new Uint8Array(Math.floor(body.length * 3 / 4));
1588
+ let bits = 0;
1589
+ let buffer = 0;
1590
+ let index = 0;
1591
+ for (const char of body) {
1592
+ const value = VALUES.get(char);
1593
+ if (value === void 0) return void 0;
1594
+ buffer = (buffer << 6 | value) & 16777215;
1595
+ bits += 6;
1596
+ if (bits >= 8) {
1597
+ bits -= 8;
1598
+ out[index++] = buffer >> bits & 255;
1599
+ }
1600
+ }
1601
+ return out;
1602
+ }
1603
+
1604
+ // src/digest/sha256.ts
1605
+ var K = new Uint32Array([
1606
+ 1116352408,
1607
+ 1899447441,
1608
+ 3049323471,
1609
+ 3921009573,
1610
+ 961987163,
1611
+ 1508970993,
1612
+ 2453635748,
1613
+ 2870763221,
1614
+ 3624381080,
1615
+ 310598401,
1616
+ 607225278,
1617
+ 1426881987,
1618
+ 1925078388,
1619
+ 2162078206,
1620
+ 2614888103,
1621
+ 3248222580,
1622
+ 3835390401,
1623
+ 4022224774,
1624
+ 264347078,
1625
+ 604807628,
1626
+ 770255983,
1627
+ 1249150122,
1628
+ 1555081692,
1629
+ 1996064986,
1630
+ 2554220882,
1631
+ 2821834349,
1632
+ 2952996808,
1633
+ 3210313671,
1634
+ 3336571891,
1635
+ 3584528711,
1636
+ 113926993,
1637
+ 338241895,
1638
+ 666307205,
1639
+ 773529912,
1640
+ 1294757372,
1641
+ 1396182291,
1642
+ 1695183700,
1643
+ 1986661051,
1644
+ 2177026350,
1645
+ 2456956037,
1646
+ 2730485921,
1647
+ 2820302411,
1648
+ 3259730800,
1649
+ 3345764771,
1650
+ 3516065817,
1651
+ 3600352804,
1652
+ 4094571909,
1653
+ 275423344,
1654
+ 430227734,
1655
+ 506948616,
1656
+ 659060556,
1657
+ 883997877,
1658
+ 958139571,
1659
+ 1322822218,
1660
+ 1537002063,
1661
+ 1747873779,
1662
+ 1955562222,
1663
+ 2024104815,
1664
+ 2227730452,
1665
+ 2361852424,
1666
+ 2428436474,
1667
+ 2756734187,
1668
+ 3204031479,
1669
+ 3329325298
1670
+ ]);
1671
+ var IV = [
1672
+ 1779033703,
1673
+ 3144134277,
1674
+ 1013904242,
1675
+ 2773480762,
1676
+ 1359893119,
1677
+ 2600822924,
1678
+ 528734635,
1679
+ 1541459225
1680
+ ];
1681
+ var W = new Uint32Array(64);
1682
+ var rotr = (x, n) => x >>> n | x << 32 - n;
1683
+ function compress(h, view, offset) {
1684
+ for (let i = 0; i < 16; i++) W[i] = view.getUint32(offset + i * 4);
1685
+ for (let i = 16; i < 64; i++) {
1686
+ const a2 = W[i - 15];
1687
+ const b2 = W[i - 2];
1688
+ const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
1689
+ const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
1690
+ W[i] = W[i - 16] + s0 + W[i - 7] + s1 >>> 0;
1691
+ }
1692
+ let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], k = h[7];
1693
+ for (let i = 0; i < 64; i++) {
1694
+ const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
1695
+ const ch = e & f ^ ~e & g;
1696
+ const t1 = k + S1 + ch + K[i] + W[i] >>> 0;
1697
+ const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
1698
+ const maj = a & b ^ a & c ^ b & c;
1699
+ const t2 = S0 + maj >>> 0;
1700
+ k = g;
1701
+ g = f;
1702
+ f = e;
1703
+ e = d + t1 >>> 0;
1704
+ d = c;
1705
+ c = b;
1706
+ b = a;
1707
+ a = t1 + t2 >>> 0;
1708
+ }
1709
+ h[0] = h[0] + a >>> 0;
1710
+ h[1] = h[1] + b >>> 0;
1711
+ h[2] = h[2] + c >>> 0;
1712
+ h[3] = h[3] + d >>> 0;
1713
+ h[4] = h[4] + e >>> 0;
1714
+ h[5] = h[5] + f >>> 0;
1715
+ h[6] = h[6] + g >>> 0;
1716
+ h[7] = h[7] + k >>> 0;
1717
+ }
1718
+ function pad64(data) {
1719
+ const padded = new Uint8Array(Math.ceil((data.length + 9) / 64) * 64);
1720
+ padded.set(data);
1721
+ padded[data.length] = 128;
1722
+ const bits = data.length * 8;
1723
+ const view = new DataView(padded.buffer);
1724
+ view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
1725
+ view.setUint32(padded.length - 4, bits >>> 0);
1726
+ return view;
1727
+ }
1728
+ function wordsOut(h) {
1729
+ const out = new Uint8Array(h.length * 4);
1730
+ const view = new DataView(out.buffer);
1731
+ for (let i = 0; i < h.length; i++) view.setUint32(i * 4, h[i]);
1732
+ return out;
1733
+ }
1734
+ function sha256(data) {
1735
+ const h = new Uint32Array(IV);
1736
+ const view = pad64(data);
1737
+ for (let offset = 0; offset < view.byteLength; offset += 64) compress(h, view, offset);
1738
+ return wordsOut(h);
1739
+ }
1740
+
1741
+ // src/digest/sha1.ts
1742
+ var W2 = new Uint32Array(80);
1743
+ var rotl = (x, n) => x << n | x >>> 32 - n;
1744
+ function compress2(h, view, offset) {
1745
+ for (let i = 0; i < 16; i++) W2[i] = view.getUint32(offset + i * 4);
1746
+ for (let i = 16; i < 80; i++) W2[i] = rotl(W2[i - 3] ^ W2[i - 8] ^ W2[i - 14] ^ W2[i - 16], 1);
1747
+ let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4];
1748
+ for (let i = 0; i < 80; i++) {
1749
+ let f;
1750
+ let k;
1751
+ if (i < 20) {
1752
+ f = b & c | ~b & d;
1753
+ k = 1518500249;
1754
+ } else if (i < 40) {
1755
+ f = b ^ c ^ d;
1756
+ k = 1859775393;
1757
+ } else if (i < 60) {
1758
+ f = b & c | b & d | c & d;
1759
+ k = 2400959708;
1760
+ } else {
1761
+ f = b ^ c ^ d;
1762
+ k = 3395469782;
1763
+ }
1764
+ const t = rotl(a, 5) + f + e + k + W2[i] >>> 0;
1765
+ e = d;
1766
+ d = c;
1767
+ c = rotl(b, 30) >>> 0;
1768
+ b = a;
1769
+ a = t;
1770
+ }
1771
+ h[0] = h[0] + a >>> 0;
1772
+ h[1] = h[1] + b >>> 0;
1773
+ h[2] = h[2] + c >>> 0;
1774
+ h[3] = h[3] + d >>> 0;
1775
+ h[4] = h[4] + e >>> 0;
1776
+ }
1777
+ function sha1(data) {
1778
+ const h = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
1779
+ const view = pad64(data);
1780
+ for (let offset = 0; offset < view.byteLength; offset += 64) compress2(h, view, offset);
1781
+ return wordsOut(h);
1782
+ }
1783
+
1784
+ // src/digest/sha512.ts
1785
+ var K2 = new Uint32Array([
1786
+ 1116352408,
1787
+ 3609767458,
1788
+ 1899447441,
1789
+ 602891725,
1790
+ 3049323471,
1791
+ 3964484399,
1792
+ 3921009573,
1793
+ 2173295548,
1794
+ 961987163,
1795
+ 4081628472,
1796
+ 1508970993,
1797
+ 3053834265,
1798
+ 2453635748,
1799
+ 2937671579,
1800
+ 2870763221,
1801
+ 3664609560,
1802
+ 3624381080,
1803
+ 2734883394,
1804
+ 310598401,
1805
+ 1164996542,
1806
+ 607225278,
1807
+ 1323610764,
1808
+ 1426881987,
1809
+ 3590304994,
1810
+ 1925078388,
1811
+ 4068182383,
1812
+ 2162078206,
1813
+ 991336113,
1814
+ 2614888103,
1815
+ 633803317,
1816
+ 3248222580,
1817
+ 3479774868,
1818
+ 3835390401,
1819
+ 2666613458,
1820
+ 4022224774,
1821
+ 944711139,
1822
+ 264347078,
1823
+ 2341262773,
1824
+ 604807628,
1825
+ 2007800933,
1826
+ 770255983,
1827
+ 1495990901,
1828
+ 1249150122,
1829
+ 1856431235,
1830
+ 1555081692,
1831
+ 3175218132,
1832
+ 1996064986,
1833
+ 2198950837,
1834
+ 2554220882,
1835
+ 3999719339,
1836
+ 2821834349,
1837
+ 766784016,
1838
+ 2952996808,
1839
+ 2566594879,
1840
+ 3210313671,
1841
+ 3203337956,
1842
+ 3336571891,
1843
+ 1034457026,
1844
+ 3584528711,
1845
+ 2466948901,
1846
+ 113926993,
1847
+ 3758326383,
1848
+ 338241895,
1849
+ 168717936,
1850
+ 666307205,
1851
+ 1188179964,
1852
+ 773529912,
1853
+ 1546045734,
1854
+ 1294757372,
1855
+ 1522805485,
1856
+ 1396182291,
1857
+ 2643833823,
1858
+ 1695183700,
1859
+ 2343527390,
1860
+ 1986661051,
1861
+ 1014477480,
1862
+ 2177026350,
1863
+ 1206759142,
1864
+ 2456956037,
1865
+ 344077627,
1866
+ 2730485921,
1867
+ 1290863460,
1868
+ 2820302411,
1869
+ 3158454273,
1870
+ 3259730800,
1871
+ 3505952657,
1872
+ 3345764771,
1873
+ 106217008,
1874
+ 3516065817,
1875
+ 3606008344,
1876
+ 3600352804,
1877
+ 1432725776,
1878
+ 4094571909,
1879
+ 1467031594,
1880
+ 275423344,
1881
+ 851169720,
1882
+ 430227734,
1883
+ 3100823752,
1884
+ 506948616,
1885
+ 1363258195,
1886
+ 659060556,
1887
+ 3750685593,
1888
+ 883997877,
1889
+ 3785050280,
1890
+ 958139571,
1891
+ 3318307427,
1892
+ 1322822218,
1893
+ 3812723403,
1894
+ 1537002063,
1895
+ 2003034995,
1896
+ 1747873779,
1897
+ 3602036899,
1898
+ 1955562222,
1899
+ 1575990012,
1900
+ 2024104815,
1901
+ 1125592928,
1902
+ 2227730452,
1903
+ 2716904306,
1904
+ 2361852424,
1905
+ 442776044,
1906
+ 2428436474,
1907
+ 593698344,
1908
+ 2756734187,
1909
+ 3733110249,
1910
+ 3204031479,
1911
+ 2999351573,
1912
+ 3329325298,
1913
+ 3815920427,
1914
+ 3391569614,
1915
+ 3928383900,
1916
+ 3515267271,
1917
+ 566280711,
1918
+ 3940187606,
1919
+ 3454069534,
1920
+ 4118630271,
1921
+ 4000239992,
1922
+ 116418474,
1923
+ 1914138554,
1924
+ 174292421,
1925
+ 2731055270,
1926
+ 289380356,
1927
+ 3203993006,
1928
+ 460393269,
1929
+ 320620315,
1930
+ 685471733,
1931
+ 587496836,
1932
+ 852142971,
1933
+ 1086792851,
1934
+ 1017036298,
1935
+ 365543100,
1936
+ 1126000580,
1937
+ 2618297676,
1938
+ 1288033470,
1939
+ 3409855158,
1940
+ 1501505948,
1941
+ 4234509866,
1942
+ 1607167915,
1943
+ 987167468,
1944
+ 1816402316,
1945
+ 1246189591
1946
+ ]);
1947
+ var IV_512 = [
1948
+ 1779033703,
1949
+ 4089235720,
1950
+ 3144134277,
1951
+ 2227873595,
1952
+ 1013904242,
1953
+ 4271175723,
1954
+ 2773480762,
1955
+ 1595750129,
1956
+ 1359893119,
1957
+ 2917565137,
1958
+ 2600822924,
1959
+ 725511199,
1960
+ 528734635,
1961
+ 4215389547,
1962
+ 1541459225,
1963
+ 327033209
1964
+ ];
1965
+ var IV_384 = [
1966
+ 3418070365,
1967
+ 3238371032,
1968
+ 1654270250,
1969
+ 914150663,
1970
+ 2438529370,
1971
+ 812702999,
1972
+ 355462360,
1973
+ 4144912697,
1974
+ 1731405415,
1975
+ 4290775857,
1976
+ 2394180231,
1977
+ 1750603025,
1978
+ 3675008525,
1979
+ 1694076839,
1980
+ 1203062813,
1981
+ 3204075428
1982
+ ];
1983
+ var W3 = new Uint32Array(160);
1984
+ function compress3(h, data, offset) {
1985
+ for (let i = 0; i < 32; i++) {
1986
+ const o = offset + i * 4;
1987
+ W3[i] = (data[o] << 24 | data[o + 1] << 16 | data[o + 2] << 8 | data[o + 3]) >>> 0;
1988
+ }
1989
+ for (let i = 16; i < 80; i++) {
1990
+ const xh = W3[(i - 15) * 2];
1991
+ const xl = W3[(i - 15) * 2 + 1];
1992
+ const s0h = (xh >>> 1 | xl << 31) ^ (xh >>> 8 | xl << 24) ^ xh >>> 7;
1993
+ const s0l = (xl >>> 1 | xh << 31) ^ (xl >>> 8 | xh << 24) ^ (xl >>> 7 | xh << 25);
1994
+ const yh = W3[(i - 2) * 2];
1995
+ const yl = W3[(i - 2) * 2 + 1];
1996
+ const s1h = (yh >>> 19 | yl << 13) ^ (yl >>> 29 | yh << 3) ^ yh >>> 6;
1997
+ const s1l = (yl >>> 19 | yh << 13) ^ (yh >>> 29 | yl << 3) ^ (yl >>> 6 | yh << 26);
1998
+ let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(i - 7) * 2 + 1] + W3[(i - 16) * 2 + 1];
1999
+ const hi = s0h + s1h + W3[(i - 7) * 2] + W3[(i - 16) * 2] + Math.floor(lo / 4294967296);
2000
+ lo >>>= 0;
2001
+ W3[i * 2] = hi >>> 0;
2002
+ W3[i * 2 + 1] = lo;
2003
+ }
2004
+ 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];
2005
+ let eh = h[8], el = h[9], fh = h[10], fl = h[11], gh = h[12], gl = h[13], hh = h[14], hl = h[15];
2006
+ for (let i = 0; i < 80; i++) {
2007
+ const S1h = (eh >>> 14 | el << 18) ^ (eh >>> 18 | el << 14) ^ (el >>> 9 | eh << 23);
2008
+ const S1l = (el >>> 14 | eh << 18) ^ (el >>> 18 | eh << 14) ^ (eh >>> 9 | el << 23);
2009
+ const chh = eh & fh ^ ~eh & gh;
2010
+ const chl = el & fl ^ ~el & gl;
2011
+ let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) + K2[i * 2 + 1] + W3[i * 2 + 1];
2012
+ const t1h = hh + S1h + chh + K2[i * 2] + W3[i * 2] + Math.floor(t1l / 4294967296);
2013
+ t1l >>>= 0;
2014
+ const S0h = (ah >>> 28 | al << 4) ^ (al >>> 2 | ah << 30) ^ (al >>> 7 | ah << 25);
2015
+ const S0l = (al >>> 28 | ah << 4) ^ (ah >>> 2 | al << 30) ^ (ah >>> 7 | al << 25);
2016
+ const majh = ah & bh ^ ah & ch ^ bh & ch;
2017
+ const majl = al & bl ^ al & cl ^ bl & cl;
2018
+ let t2l = (S0l >>> 0) + (majl >>> 0);
2019
+ const t2h = S0h + majh + Math.floor(t2l / 4294967296);
2020
+ t2l >>>= 0;
2021
+ hh = gh;
2022
+ hl = gl;
2023
+ gh = fh;
2024
+ gl = fl;
2025
+ fh = eh;
2026
+ fl = el;
2027
+ let nl = (dl >>> 0) + t1l;
2028
+ eh = dh + t1h + Math.floor(nl / 4294967296) >>> 0;
2029
+ el = nl >>> 0;
2030
+ dh = ch;
2031
+ dl = cl;
2032
+ ch = bh;
2033
+ cl = bl;
2034
+ bh = ah;
2035
+ bl = al;
2036
+ nl = t1l + t2l;
2037
+ ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
2038
+ al = nl >>> 0;
2039
+ }
2040
+ const add = (i, xh, xl) => {
2041
+ const lo = (h[i + 1] >>> 0) + (xl >>> 0);
2042
+ h[i] = h[i] + xh + Math.floor(lo / 4294967296) >>> 0;
2043
+ h[i + 1] = lo >>> 0;
2044
+ };
2045
+ add(0, ah, al);
2046
+ add(2, bh, bl);
2047
+ add(4, ch, cl);
2048
+ add(6, dh, dl);
2049
+ add(8, eh, el);
2050
+ add(10, fh, fl);
2051
+ add(12, gh, gl);
2052
+ add(14, hh, hl);
2053
+ }
2054
+ function digest64(data, iv, bytes) {
2055
+ const h = new Uint32Array(iv);
2056
+ const padded = new Uint8Array(Math.ceil((data.length + 17) / 128) * 128);
2057
+ padded.set(data);
2058
+ padded[data.length] = 128;
2059
+ const bits = data.length * 8;
2060
+ const view = new DataView(padded.buffer);
2061
+ view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
2062
+ view.setUint32(padded.length - 4, bits >>> 0);
2063
+ for (let offset = 0; offset < padded.length; offset += 128) compress3(h, padded, offset);
2064
+ const out = new Uint8Array(bytes);
2065
+ const outView = new DataView(out.buffer);
2066
+ for (let i = 0; i < bytes / 4; i++) outView.setUint32(i * 4, h[i]);
2067
+ return out;
2068
+ }
2069
+ var sha512 = (data) => digest64(data, IV_512, 64);
2070
+ var sha384 = (data) => digest64(data, IV_384, 48);
2071
+
2072
+ // src/digest/digest.ts
2073
+ var DIGESTS = {
2074
+ "SHA-1": sha1,
2075
+ "SHA-256": sha256,
2076
+ "SHA-384": sha384,
2077
+ "SHA-512": sha512
2078
+ };
2079
+ function digestFunction(name) {
2080
+ const canonical = normalizeDigestAlgorithmName(name);
2081
+ return canonical && canonical in DIGESTS ? DIGESTS[canonical] : void 0;
2082
+ }
2083
+ function digestSync(name, data) {
2084
+ return digestFunction(name)?.(data);
2085
+ }
2086
+
2087
+ // src/digest/password-hash.ts
2088
+ var MAX_SPIN_COUNT = 1e7;
2089
+ var validSpinCount = (spinCount) => spinCount === void 0 || Number.isInteger(spinCount) && spinCount >= 0 && spinCount <= MAX_SPIN_COUNT;
2090
+ function spin(password, salt, spinCount, digest) {
2091
+ const input = new Uint8Array(salt.length + password.length * 2);
2092
+ input.set(salt);
2093
+ for (let i = 0; i < password.length; i++) {
2094
+ const code = password.charCodeAt(i);
2095
+ input[salt.length + i * 2] = code & 255;
2096
+ input[salt.length + i * 2 + 1] = code >> 8;
2097
+ }
2098
+ let value = digest(input);
2099
+ const buffer = new Uint8Array(value.length + 4);
2100
+ const view = new DataView(buffer.buffer);
2101
+ for (let i = 0; i < spinCount; i++) {
2102
+ buffer.set(value);
2103
+ view.setUint32(value.length, i, true);
2104
+ value = digest(buffer);
2105
+ }
2106
+ return value;
2107
+ }
2108
+ function hashBytes(password, { algorithmName, saltValue, spinCount }) {
2109
+ const digest = digestFunction(algorithmName);
2110
+ const salt = decodeBase64(saltValue);
2111
+ if (!digest || !salt || !validSpinCount(spinCount)) return void 0;
2112
+ return spin(password, salt, spinCount ?? 0, digest);
2113
+ }
2114
+ function hashPassword(password, options) {
2115
+ const bytes = hashBytes(password, options);
2116
+ return bytes && encodeBase64(bytes);
2117
+ }
2118
+ function verifyPasswordHash(password, hash) {
2119
+ if (!digestFunction(hash.algorithmName)) return void 0;
2120
+ const expected = decodeBase64(hash.hashValue);
2121
+ const actual = expected && hashBytes(password, hash);
2122
+ if (!expected || !actual || actual.length !== expected.length) return false;
2123
+ let difference = 0;
2124
+ for (let i = 0; i < actual.length; i++) difference |= actual[i] ^ expected[i];
2125
+ return difference === 0;
2126
+ }
2127
+
1531
2128
  // src/geometry/index.ts
1532
2129
  var geometry_exports = {};
1533
2130
  __export(geometry_exports, {
@@ -18669,4 +19266,4 @@ function parseOmml(xml) {
18669
19266
  return ommlFromElement(parseXml(xml, { label: "OMML" }).documentElement);
18670
19267
  }
18671
19268
 
18672
- export { color_exports as color, diagram_exports as diagram, geometry_exports as geometry, math_exports as math, opc_exports as opc, units_exports as units, xml_exports as xml };
19269
+ export { color_exports as color, diagram_exports as diagram, digest_exports as digest, geometry_exports as geometry, math_exports as math, opc_exports as opc, units_exports as units, xml_exports as xml };
@@ -38,7 +38,7 @@ type Snapshot = {
38
38
  settings?: BookSettings;
39
39
  };
40
40
  /** Workbook-level settings `meta` and `workbook` snapshots also record. */
41
- type BookSettings = Pick<Workbook, 'structureLocked' | 'workbookPasswordHash' | 'calcMode'>;
41
+ type BookSettings = Pick<Workbook, 'structureLocked' | 'workbookPasswordHash' | 'workbookModernHash' | 'calcMode'>;
42
42
  export interface HistoryEntry {
43
43
  before: Snapshot;
44
44
  after: Snapshot;
@@ -1 +1 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/xlsx/edit/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,SAAS,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,EAAE,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE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,GAAG,IAAI,CA+B5E;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAc7F;AAED,8CAA8C;AAC9C,qBAAa,OAAO;IAIP,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;gBAEf,KAAK,EAAE,MAAM;IAE1C,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAM7B,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS;IAWjD,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS;IAQjD,OAAO,QAAO,OAAO,CAAyB;IAC9C,OAAO,QAAO,OAAO,CAA2B;IAChD,SAAS,QAAO,MAAM,GAAG,SAAS,CAA4B;IAC9D,SAAS,QAAO,MAAM,GAAG,SAAS,CAA8B;CAChE"}
@@ -14,7 +14,7 @@ export { uniqueHeaders } from './tables.js';
14
14
  export { IMAGE_EXTENSIONS, newMediaPart, type ChartPatch } from './charts.js';
15
15
  export { validateTableName, type TablePatch, type TableRef } from './table-edits.js';
16
16
  export { autoGrowRows, rowsToRefit } from './row-autofit.js';
17
- export { legacyPasswordHash, verifySheetPassword, verifyWorkbookPassword } from './protection.js';
17
+ export { legacyPasswordHash, modernPasswordHash, verifySheetPassword, verifySheetPasswordAsync, verifyWorkbookPassword, } from './protection.js';
18
18
  export { MAX_OUTLINE_LEVEL } from './outline.js';
19
19
  export type { RemoveDuplicatesResult } from './duplicates.js';
20
20
  export { calcModeOf, type CalcMode } from './calc-mode.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/xlsx/edit/index.ts"],"names":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CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAClG,YAAY,EACX,YAAY,EACZ,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GAClB,MAAM,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { SheetProtection, Workbook, Worksheet } from '../model.js';
1
+ import type { ModernPasswordHash, SheetProtection, Workbook, Worksheet } from '../model.js';
2
2
  import { type EditContext } from './context.js';
3
3
  /**
4
4
  * Excel's legacy 16-bit password verifier (ECMA-376 Part 4, 14.7.1), upper-case hex as the
@@ -7,20 +7,32 @@ import { type EditContext } from './context.js';
7
7
  export declare function legacyPasswordHash(password: string): string;
8
8
  /**
9
9
  * Whether `password` unlocks a sheet's protection (true when it is not protected or has no
10
- * legacy password). Only the legacy hash is checked: a sheet protected with just Excel's modern
11
- * SHA-512 hash reports false for every non-empty password.
10
+ * password). Excel's modern hash is checked synchronously for SHA-1, SHA-256, SHA-384 and SHA-512;
11
+ * a modern hash with any other digest falls back to the legacy hash and, without one, never
12
+ * unlocks, so a sheet is never unprotected by mistake. Malformed hashes fail rather than throw.
12
13
  */
13
14
  export declare function verifySheetPassword(sheet: Worksheet | SheetProtection | undefined, password: string): boolean;
14
- /** Whether `password` unlocks the workbook structure protection. */
15
+ /** {@link verifySheetPassword} as a promise, kept for callers written against the async API. */
16
+ export declare function verifySheetPasswordAsync(sheet: Worksheet | SheetProtection | undefined, password: string): Promise<boolean>;
17
+ /**
18
+ * The base64 ECMA-376 agile hash of `password` for the salt and iteration count in `hash`, as a
19
+ * promise for callers written against the async API; `hashPassword` in `ooxml-core/digest` is the
20
+ * synchronous form. Rejects for a digest other than SHA-1/256/384/512 or unusable parameters.
21
+ */
22
+ export declare function modernPasswordHash(password: string, hash: Pick<ModernPasswordHash, 'saltValue' | 'spinCount'>, digest?: string): Promise<string>;
23
+ /** Whether `password` unlocks the workbook structure protection (modern or legacy hash). */
15
24
  export declare function verifyWorkbookPassword(workbook: Workbook, password: string): boolean;
16
25
  /**
17
26
  * Protects (or with `undefined`, unprotects) a sheet. A non-empty `password` sets the legacy
18
- * hash; `''` removes it. Unprotecting with a password checks it first and throws when wrong.
27
+ * hash and drops the modern one (it would no longer match); `''` removes both hashes, and
28
+ * `undefined` keeps whatever `protection` carries. Unprotecting with a password checks it first
29
+ * (against the modern or legacy hash) and throws when it is wrong.
19
30
  */
20
31
  export declare function setSheetProtection(ctx: EditContext, s: number, protection: SheetProtection | undefined, password?: string): void;
21
32
  /**
22
33
  * Locks or unlocks the workbook structure. Locking with a non-empty password stores its legacy
23
- * hash; unlocking with a password checks it first and throws when wrong.
34
+ * hash and drops the modern one; `''` removes both, `undefined` keeps them. Unlocking with a
35
+ * password checks it first (against the modern or legacy hash) and throws when it is wrong.
24
36
  */
25
37
  export declare function setWorkbookProtection(ctx: EditContext, locked: boolean, password?: string): void;
26
38
  //# sourceMappingURL=protection.d.ts.map