clear-excel 0.1.0 → 1.0.2
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/CHANGELOG.md +25 -0
- package/README.md +120 -72
- package/dist/api/sanitize-excel-file.d.ts +5 -0
- package/dist/api/sanitize-excel-file.d.ts.map +1 -0
- package/dist/api/sanitize-excel.d.ts +3 -0
- package/dist/api/sanitize-excel.d.ts.map +1 -0
- package/dist/biff/workbook.d.ts +4 -0
- package/dist/biff/workbook.d.ts.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/formats.d.ts +5 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2777 -0
- package/dist/index.js.map +1 -0
- package/dist/ooxml/cleanup.d.ts +3 -0
- package/dist/ooxml/cleanup.d.ts.map +1 -0
- package/dist/ooxml/constants.d.ts +4 -0
- package/dist/ooxml/constants.d.ts.map +1 -0
- package/dist/ooxml/parts.d.ts +5 -0
- package/dist/ooxml/parts.d.ts.map +1 -0
- package/dist/ooxml/relationships.d.ts +21 -0
- package/dist/ooxml/relationships.d.ts.map +1 -0
- package/dist/ooxml/styles.d.ts +7 -0
- package/dist/ooxml/styles.d.ts.map +1 -0
- package/dist/ooxml/workbook.d.ts +3 -0
- package/dist/ooxml/workbook.d.ts.map +1 -0
- package/dist/ooxml/xml.d.ts +12 -0
- package/dist/ooxml/xml.d.ts.map +1 -0
- package/dist/options.d.ts +5 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/zip/central-directory.d.ts +7 -0
- package/dist/zip/central-directory.d.ts.map +1 -0
- package/package.json +64 -44
- package/index.cjs +0 -3
- package/index.d.ts +0 -62
- package/index.js +0 -7
- package/src/index.cjs +0 -894
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ExcelSanitizationLimits {
|
|
2
|
+
maxEntryCount: number;
|
|
3
|
+
maxUncompressedBytes: number;
|
|
4
|
+
maxXmlBytes: number;
|
|
5
|
+
maxWorksheetXmlBytes: number;
|
|
6
|
+
maxStylesXmlBytes: number;
|
|
7
|
+
maxMetadataXmlBytes: number;
|
|
8
|
+
maxRelationshipsXmlBytes: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SanitizeExcelOptions {
|
|
11
|
+
requireSingleWorksheet?: boolean;
|
|
12
|
+
limits?: Partial<ExcelSanitizationLimits>;
|
|
13
|
+
}
|
|
14
|
+
export interface SanitizeExcelFileOptions extends SanitizeExcelOptions {
|
|
15
|
+
overwrite?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface NormalizedSanitizeOptions {
|
|
18
|
+
requireSingleWorksheet: boolean;
|
|
19
|
+
limits: Readonly<ExcelSanitizationLimits>;
|
|
20
|
+
}
|
|
21
|
+
export interface NormalizedFileOptions extends NormalizedSanitizeOptions {
|
|
22
|
+
overwrite: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ReadBudget {
|
|
25
|
+
consumedBytes: number;
|
|
26
|
+
limitBytes: number;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACnC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,wBAAyB,SAAQ,oBAAoB;IACpE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,yBAAyB;IACxC,sBAAsB,EAAE,OAAO,CAAC;IAChC,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,qBAAsB,SAAQ,yBAAyB;IACtE,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExcelSanitizationLimits } from "../types.js";
|
|
2
|
+
export declare function hasZipSignature(buffer: Buffer): boolean;
|
|
3
|
+
export declare function validateZipCentralDirectory(buffer: Buffer, limits: Readonly<ExcelSanitizationLimits>): void;
|
|
4
|
+
export declare function validatePackageEntryName(name: string): void;
|
|
5
|
+
export declare function findEndOfCentralDirectory(buffer: Buffer): number | undefined;
|
|
6
|
+
export declare function rejectZip64ExtraFields(buffer: Buffer, extraOffset: number, extraLength: number): void;
|
|
7
|
+
//# sourceMappingURL=central-directory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"central-directory.d.ts","sourceRoot":"","sources":["../../src/zip/central-directory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAqB3D,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,GACxC,IAAI,CAmCN;AAmFD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAU3D;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW5E;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,IAAI,CAkBN"}
|
package/package.json
CHANGED
|
@@ -1,68 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clear-excel",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Safely remove drawings, comments, embedded objects
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Safely remove drawings, comments, and embedded objects from XLS, XLSX, and XLSM workbooks.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"comments",
|
|
7
|
+
"excel",
|
|
8
|
+
"excel-sanitizer",
|
|
9
|
+
"images",
|
|
10
|
+
"ole",
|
|
11
|
+
"ooxml",
|
|
12
|
+
"remove-comments",
|
|
13
|
+
"remove-images",
|
|
14
|
+
"sanitize",
|
|
15
|
+
"styles",
|
|
16
|
+
"xls",
|
|
17
|
+
"xlsm",
|
|
18
|
+
"xlsx"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/Vlad1slav1vanov/clear-excel#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/Vlad1slav1vanov/clear-excel/issues"
|
|
23
|
+
},
|
|
6
24
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"types": "./index.d.ts",
|
|
14
|
-
"import": "./index.js",
|
|
15
|
-
"require": "./index.cjs"
|
|
16
|
-
}
|
|
25
|
+
"author": "Vladislav Ivanov",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/Vlad1slav1vanov/clear-excel.git"
|
|
17
29
|
},
|
|
18
30
|
"files": [
|
|
19
|
-
"
|
|
20
|
-
"index.cjs",
|
|
21
|
-
"index.d.ts",
|
|
22
|
-
"src/index.cjs",
|
|
31
|
+
"dist",
|
|
23
32
|
"README.md",
|
|
33
|
+
"CHANGELOG.md",
|
|
24
34
|
"LICENSE"
|
|
25
35
|
],
|
|
26
|
-
"
|
|
27
|
-
"node": ">=22"
|
|
28
|
-
},
|
|
36
|
+
"type": "module",
|
|
29
37
|
"sideEffects": false,
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
"main": "./dist/index.js",
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"import": "./dist/index.js",
|
|
44
|
+
"default": "./dist/index.js"
|
|
45
|
+
}
|
|
36
46
|
},
|
|
37
|
-
"homepage": "https://github.com/Vlad1slav1vanov/clear-excel#readme",
|
|
38
47
|
"publishConfig": {
|
|
39
48
|
"access": "public"
|
|
40
49
|
},
|
|
41
|
-
"keywords": [
|
|
42
|
-
"excel",
|
|
43
|
-
"xlsx",
|
|
44
|
-
"ooxml",
|
|
45
|
-
"sanitize",
|
|
46
|
-
"comments",
|
|
47
|
-
"images",
|
|
48
|
-
"styles"
|
|
49
|
-
],
|
|
50
50
|
"scripts": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
51
|
+
"build:js": "vite build",
|
|
52
|
+
"build:types": "tsc --project tsconfig.build.json",
|
|
53
|
+
"build": "pnpm run build:js && pnpm run build:types",
|
|
54
|
+
"check:types": "tsc --project tsconfig.json",
|
|
55
|
+
"lint": "oxlint --deny-warnings .",
|
|
56
|
+
"lint:fix": "oxlint --fix .",
|
|
57
|
+
"format": "oxfmt --write .",
|
|
58
|
+
"format:check": "oxfmt --check .",
|
|
59
|
+
"test": "tsx --test test/*.test.ts",
|
|
60
|
+
"pack:dry-run": "pnpm --config.ignore-scripts=true pack --dry-run",
|
|
61
|
+
"test:package": "tsx scripts/verify-package.ts",
|
|
62
|
+
"check": "pnpm run format:check && pnpm run lint && pnpm run check:types && pnpm test && pnpm run build && pnpm run pack:dry-run && pnpm run test:package",
|
|
63
|
+
"prepack": "pnpm run build",
|
|
64
|
+
"prepublishOnly": "pnpm run check"
|
|
57
65
|
},
|
|
58
66
|
"dependencies": {
|
|
67
|
+
"cfb": "1.2.2",
|
|
59
68
|
"jszip": "^3.10.1"
|
|
60
69
|
},
|
|
61
70
|
"devDependencies": {
|
|
71
|
+
"@e965/xlsx": "0.20.3",
|
|
62
72
|
"@types/node": "^22.0.0",
|
|
63
|
-
"exceljs": "^4.4.0"
|
|
73
|
+
"exceljs": "^4.4.0",
|
|
74
|
+
"oxfmt": "^0.64.0",
|
|
75
|
+
"oxlint": "^1.79.0",
|
|
76
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
77
|
+
"tsx": "^4.23.12",
|
|
78
|
+
"typescript": "^7.0.2",
|
|
79
|
+
"vite": "^8.2.1"
|
|
64
80
|
},
|
|
65
81
|
"overrides": {
|
|
66
82
|
"uuid": "^11.1.1"
|
|
67
|
-
}
|
|
83
|
+
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=22"
|
|
86
|
+
},
|
|
87
|
+
"packageManager": "pnpm@11.22.0"
|
|
68
88
|
}
|
package/index.cjs
DELETED
package/index.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
export interface ExcelSanitizationLimits {
|
|
4
|
-
maxEntryCount: number;
|
|
5
|
-
maxUncompressedBytes: number;
|
|
6
|
-
maxXmlBytes: number;
|
|
7
|
-
maxWorksheetXmlBytes: number;
|
|
8
|
-
maxStylesXmlBytes: number;
|
|
9
|
-
maxMetadataXmlBytes: number;
|
|
10
|
-
maxRelationshipsXmlBytes: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface SanitizeExcelOptions {
|
|
14
|
-
requireSingleWorksheet?: boolean;
|
|
15
|
-
limits?: Partial<ExcelSanitizationLimits>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface SanitizeExcelFileOptions extends SanitizeExcelOptions {
|
|
19
|
-
overwrite?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type ExcelSanitizationErrorCode =
|
|
23
|
-
| "ERR_INVALID_ARGUMENT"
|
|
24
|
-
| "ERR_UNSUPPORTED_EXTENSION"
|
|
25
|
-
| "ERR_INVALID_XLSX"
|
|
26
|
-
| "ERR_LIMIT_EXCEEDED"
|
|
27
|
-
| "ERR_WORKSHEET_COUNT"
|
|
28
|
-
| "ERR_SAME_PATH"
|
|
29
|
-
| "ERR_OUTPUT_EXISTS"
|
|
30
|
-
| "ERR_FILE_READ"
|
|
31
|
-
| "ERR_FILE_WRITE";
|
|
32
|
-
|
|
33
|
-
export interface ExcelSanitizationErrorOptions {
|
|
34
|
-
cause?: unknown;
|
|
35
|
-
details?: Readonly<Record<string, unknown>>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class ExcelSanitizationError extends Error {
|
|
39
|
-
constructor(
|
|
40
|
-
code: ExcelSanitizationErrorCode,
|
|
41
|
-
message: string,
|
|
42
|
-
options?: ExcelSanitizationErrorOptions,
|
|
43
|
-
);
|
|
44
|
-
readonly name: "ExcelSanitizationError";
|
|
45
|
-
readonly code: ExcelSanitizationErrorCode;
|
|
46
|
-
readonly details?: Readonly<Record<string, unknown>>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const DEFAULT_LIMITS: Readonly<ExcelSanitizationLimits>;
|
|
50
|
-
|
|
51
|
-
export function isXlsxFilename(name: unknown): name is string;
|
|
52
|
-
|
|
53
|
-
export function sanitizeExcel(
|
|
54
|
-
buffer: Buffer,
|
|
55
|
-
options?: SanitizeExcelOptions,
|
|
56
|
-
): Promise<Buffer>;
|
|
57
|
-
|
|
58
|
-
export function sanitizeExcelFile(
|
|
59
|
-
inputPath: string,
|
|
60
|
-
outputPath: string,
|
|
61
|
-
options?: SanitizeExcelFileOptions,
|
|
62
|
-
): Promise<void>;
|
package/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import api from "./src/index.cjs";
|
|
2
|
-
|
|
3
|
-
export const DEFAULT_LIMITS = api.DEFAULT_LIMITS;
|
|
4
|
-
export const ExcelSanitizationError = api.ExcelSanitizationError;
|
|
5
|
-
export const isXlsxFilename = api.isXlsxFilename;
|
|
6
|
-
export const sanitizeExcel = api.sanitizeExcel;
|
|
7
|
-
export const sanitizeExcelFile = api.sanitizeExcelFile;
|