kordoc 2.0.0 → 2.0.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/index.js CHANGED
@@ -138,7 +138,7 @@ import { inflateRawSync } from "zlib";
138
138
  import { DOMParser } from "@xmldom/xmldom";
139
139
 
140
140
  // src/utils.ts
141
- var VERSION = true ? "2.0.0" : "0.0.0-dev";
141
+ var VERSION = true ? "2.0.1" : "0.0.0-dev";
142
142
  function toArrayBuffer(buf) {
143
143
  if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
144
144
  return buf.buffer;
@@ -1950,18 +1950,20 @@ function decryptDistributePayload(payload) {
1950
1950
  if (payload.length < 256) throw new Error("\uBC30\uD3EC\uC6A9 payload\uAC00 256\uBC14\uC774\uD2B8 \uBBF8\uB9CC\uC785\uB2C8\uB2E4");
1951
1951
  const seed = (payload[0] | payload[1] << 8 | payload[2] << 16 | payload[3] << 24) >>> 0;
1952
1952
  const lcg = new MsvcLcg(seed);
1953
- const result = new Uint8Array(256);
1954
- result[0] = payload[0];
1955
- result[1] = payload[1];
1956
- result[2] = payload[2];
1957
- result[3] = payload[3];
1958
- let i = 4;
1953
+ const result = new Uint8Array(payload.subarray(0, 256));
1954
+ let i = 0;
1955
+ let n = 0;
1956
+ let key = 0;
1959
1957
  while (i < 256) {
1960
- const keyByte = lcg.rand() & 255;
1961
- const n = (lcg.rand() & 15) + 1;
1962
- for (let j = 0; j < n && i < 256; j++, i++) {
1963
- result[i] = payload[i] ^ keyByte;
1958
+ if (n === 0) {
1959
+ key = lcg.rand() & 255;
1960
+ n = (lcg.rand() & 15) + 1;
1961
+ }
1962
+ if (i >= 4) {
1963
+ result[i] ^= key;
1964
1964
  }
1965
+ i++;
1966
+ n--;
1965
1967
  }
1966
1968
  return result;
1967
1969
  }
@@ -1985,7 +1987,7 @@ function parseRecordHeader(data, offset) {
1985
1987
  }
1986
1988
  return { tagId, size, headerSize };
1987
1989
  }
1988
- var TAG_DISTRIBUTE_DOC_DATA = 16 + 28;
1990
+ var TAG_DISTRIBUTE_DOC_DATA = 16 + 12;
1989
1991
  function decryptViewText(viewTextRaw, compressed) {
1990
1992
  const data = new Uint8Array(viewTextRaw);
1991
1993
  const rec = parseRecordHeader(data, 0);