@openge/forge-archive-zip 0.1.0-rc.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ Foundation Forge: @openge/forge-archive-zip
2
+ Copyright 2026 OpenGE contributors
3
+
4
+ This product includes software developed by OpenGE contributors.
5
+
6
+ This package uses fflate, distributed under the MIT License.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # `@openge/forge-archive-zip`
2
+
3
+ Runtime-neutral ZIP32 archive Provider with bounded safety validation.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pnpm add @openge/forge-archive-zip
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { decodeZipArchive, encodeZipArchive } from '@openge/forge-archive-zip';
15
+
16
+ const archive = encodeZipArchive([
17
+ { bytes: new TextEncoder().encode('hello'), kind: 'file', path: 'hello.txt' },
18
+ ], { compression: 'deflate' });
19
+
20
+ const decoded = decodeZipArchive(archive, {
21
+ limits: { maxArchiveBytes: 8 * 1024 * 1024, maxExpandedBytes: 32 * 1024 * 1024 },
22
+ });
23
+ ```
24
+
25
+ The provider creates deterministic ZIP32 archives and validates the central
26
+ directory before decompression. It rejects encryption, ZIP64, unsupported
27
+ methods, unsafe paths and entry kinds, duplicate names, inconsistent headers,
28
+ CRC mismatches, and configured resource-limit violations.
29
+
30
+ Only in-memory bytes are handled. Downloading, filesystem extraction, cache
31
+ policy, credentials, and product artifact semantics belong to the consumer.
32
+
33
+ ## License
34
+
35
+ Licensed under the Apache License 2.0.
@@ -0,0 +1,7 @@
1
+ import { type ZipArchiveEntryMetadata } from './contracts.js';
2
+ export interface ParsedZipArchiveEntry extends Omit<ZipArchiveEntryMetadata, 'kind'> {
3
+ readonly dataOffset: number;
4
+ readonly kind: ZipArchiveEntryMetadata['kind'] | 'other' | 'symbolic-link';
5
+ }
6
+ export declare function parseZipCentralDirectory(archive: Uint8Array): readonly ParsedZipArchiveEntry[];
7
+ //# sourceMappingURL=central-directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"central-directory.d.ts","sourceRoot":"","sources":["../src/central-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAUpF,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAC;IAClF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,GAAG,eAAe,CAAC;CAC5E;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,qBAAqB,EAAE,CA+F9F"}
@@ -0,0 +1,170 @@
1
+ import { zipArchiveErrorCodes } from './contracts.js';
2
+ import { ZipArchiveError } from './errors.js';
3
+ const centralDirectoryHeaderSignature = 0x02014b50;
4
+ const endOfCentralDirectorySignature = 0x06054b50;
5
+ const localFileHeaderSignature = 0x04034b50;
6
+ const maximumCommentBytes = 0xffff;
7
+ const minimumEndRecordBytes = 22;
8
+ const utf8Flag = 0x0800;
9
+ export function parseZipCentralDirectory(archive) {
10
+ const view = new DataView(archive.buffer, archive.byteOffset, archive.byteLength);
11
+ const endOffset = findEndRecord(view);
12
+ const diskNumber = readUint16(view, endOffset + 4);
13
+ const centralDisk = readUint16(view, endOffset + 6);
14
+ const diskEntries = readUint16(view, endOffset + 8);
15
+ const entryCount = readUint16(view, endOffset + 10);
16
+ const centralSize = readUint32(view, endOffset + 12);
17
+ const centralOffset = readUint32(view, endOffset + 16);
18
+ const commentLength = readUint16(view, endOffset + 20);
19
+ if (endOffset + minimumEndRecordBytes + commentLength !== archive.length) {
20
+ throw invalidZip();
21
+ }
22
+ if (diskNumber !== 0 || centralDisk !== 0 || diskEntries !== entryCount) {
23
+ throw unsupportedFeature();
24
+ }
25
+ if (entryCount === 0xffff || centralSize === 0xffffffff || centralOffset === 0xffffffff) {
26
+ throw unsupportedFeature();
27
+ }
28
+ if (centralOffset + centralSize !== endOffset) {
29
+ throw invalidZip();
30
+ }
31
+ const entries = [];
32
+ const paths = new Set();
33
+ let offset = centralOffset;
34
+ for (let index = 0; index < entryCount; index += 1) {
35
+ if (readUint32(view, offset) !== centralDirectoryHeaderSignature) {
36
+ throw invalidZip();
37
+ }
38
+ const versionMadeBy = readUint16(view, offset + 4);
39
+ const flags = readUint16(view, offset + 8);
40
+ const method = readUint16(view, offset + 10);
41
+ const crc32 = readUint32(view, offset + 16);
42
+ const compressedBytes = readUint32(view, offset + 20);
43
+ const uncompressedBytes = readUint32(view, offset + 24);
44
+ const nameLength = readUint16(view, offset + 28);
45
+ const extraLength = readUint16(view, offset + 30);
46
+ const entryCommentLength = readUint16(view, offset + 32);
47
+ const startDisk = readUint16(view, offset + 34);
48
+ const externalAttributes = readUint32(view, offset + 38);
49
+ const localOffset = readUint32(view, offset + 42);
50
+ if (compressedBytes === 0xffffffff
51
+ || uncompressedBytes === 0xffffffff
52
+ || localOffset === 0xffffffff
53
+ || startDisk !== 0) {
54
+ throw unsupportedFeature();
55
+ }
56
+ if ((flags & 0x0001) !== 0 || (method !== 0 && method !== 8)) {
57
+ throw unsupportedFeature();
58
+ }
59
+ const entryEnd = offset + 46 + nameLength + extraLength + entryCommentLength;
60
+ if (entryEnd > endOffset) {
61
+ throw invalidZip();
62
+ }
63
+ const nameBytes = archive.subarray(offset + 46, offset + 46 + nameLength);
64
+ if ((flags & utf8Flag) === 0 && nameBytes.some((byte) => byte > 0x7f)) {
65
+ throw unsupportedFeature();
66
+ }
67
+ const path = decodeName(nameBytes);
68
+ if (path.length === 0) {
69
+ throw invalidZip();
70
+ }
71
+ if (paths.has(path)) {
72
+ throw new ZipArchiveError(zipArchiveErrorCodes.duplicateEntry, { path });
73
+ }
74
+ paths.add(path);
75
+ const kind = readEntryKind(versionMadeBy, externalAttributes, path);
76
+ const dataOffset = readLocalDataOffset(archive, view, localOffset, flags, method, nameBytes, compressedBytes, centralOffset);
77
+ entries.push({
78
+ compressedBytes,
79
+ compression: method === 0 ? 'store' : 'deflate',
80
+ crc32,
81
+ dataOffset,
82
+ kind,
83
+ path,
84
+ uncompressedBytes,
85
+ });
86
+ offset = entryEnd;
87
+ }
88
+ if (offset !== endOffset) {
89
+ throw invalidZip();
90
+ }
91
+ return entries.toSorted((left, right) => comparePaths(left.path, right.path));
92
+ }
93
+ function findEndRecord(view) {
94
+ if (view.byteLength < minimumEndRecordBytes) {
95
+ throw invalidZip();
96
+ }
97
+ const minimumOffset = Math.max(0, view.byteLength - minimumEndRecordBytes - maximumCommentBytes);
98
+ for (let offset = view.byteLength - minimumEndRecordBytes; offset >= minimumOffset; offset -= 1) {
99
+ if (readUint32(view, offset) === endOfCentralDirectorySignature) {
100
+ return offset;
101
+ }
102
+ }
103
+ throw invalidZip();
104
+ }
105
+ function readLocalDataOffset(archive, view, localOffset, flags, method, centralNameBytes, compressedBytes, centralOffset) {
106
+ if (readUint32(view, localOffset) !== localFileHeaderSignature) {
107
+ throw invalidZip();
108
+ }
109
+ if (readUint16(view, localOffset + 6) !== flags || readUint16(view, localOffset + 8) !== method) {
110
+ throw invalidZip();
111
+ }
112
+ const nameLength = readUint16(view, localOffset + 26);
113
+ const extraLength = readUint16(view, localOffset + 28);
114
+ const localNameBytes = archive.subarray(localOffset + 30, localOffset + 30 + nameLength);
115
+ if (localNameBytes.length !== centralNameBytes.length
116
+ || localNameBytes.some((byte, index) => byte !== centralNameBytes[index])) {
117
+ throw invalidZip();
118
+ }
119
+ const dataOffset = localOffset + 30 + nameLength + extraLength;
120
+ if (dataOffset + compressedBytes > centralOffset || dataOffset > archive.length) {
121
+ throw invalidZip();
122
+ }
123
+ return dataOffset;
124
+ }
125
+ function readEntryKind(versionMadeBy, externalAttributes, path) {
126
+ const platform = versionMadeBy >>> 8;
127
+ if (platform === 3) {
128
+ const fileType = (externalAttributes >>> 16) & 0o170000;
129
+ if (fileType === 0o120000) {
130
+ return 'symbolic-link';
131
+ }
132
+ if (fileType !== 0 && fileType !== 0o040000 && fileType !== 0o100000) {
133
+ return 'other';
134
+ }
135
+ if (fileType === 0o040000) {
136
+ return 'directory';
137
+ }
138
+ }
139
+ return path.endsWith('/') || (externalAttributes & 0x10) !== 0 ? 'directory' : 'file';
140
+ }
141
+ function decodeName(bytes) {
142
+ try {
143
+ return new TextDecoder('utf-8', { fatal: true }).decode(bytes);
144
+ }
145
+ catch (error) {
146
+ throw new ZipArchiveError(zipArchiveErrorCodes.invalidZip, {}, error);
147
+ }
148
+ }
149
+ function readUint16(view, offset) {
150
+ if (offset < 0 || offset + 2 > view.byteLength) {
151
+ throw invalidZip();
152
+ }
153
+ return view.getUint16(offset, true);
154
+ }
155
+ function readUint32(view, offset) {
156
+ if (offset < 0 || offset + 4 > view.byteLength) {
157
+ throw invalidZip();
158
+ }
159
+ return view.getUint32(offset, true);
160
+ }
161
+ function comparePaths(left, right) {
162
+ return left < right ? -1 : left > right ? 1 : 0;
163
+ }
164
+ function invalidZip() {
165
+ return new ZipArchiveError(zipArchiveErrorCodes.invalidZip);
166
+ }
167
+ function unsupportedFeature() {
168
+ return new ZipArchiveError(zipArchiveErrorCodes.unsupportedZipFeature);
169
+ }
170
+ //# sourceMappingURL=central-directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"central-directory.js","sourceRoot":"","sources":["../src/central-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgC,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,+BAA+B,GAAG,UAAU,CAAC;AACnD,MAAM,8BAA8B,GAAG,UAAU,CAAC;AAClD,MAAM,wBAAwB,GAAG,UAAU,CAAC;AAC5C,MA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IACrB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,UAAU,CAAC,IAAc,EAAE,MAAc;IAChD,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/C,MAAM,UAAU,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,KAAa;IAC/C,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,UAAU;IACjB,OAAO,IAAI,eAAe,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,IAAI,eAAe,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC;AACzE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type DecodedZipArchive, type EncodeZipArchiveOptions, type ZipArchiveInspection, type ZipArchiveReadOptions, type ZipArchiveSourceEntry } from './contracts.js';
2
+ export declare function encodeZipArchive(entries: readonly ZipArchiveSourceEntry[], options: EncodeZipArchiveOptions): Uint8Array;
3
+ export declare function inspectZipArchive(archive: Uint8Array, options?: ZipArchiveReadOptions): ZipArchiveInspection;
4
+ export declare function decodeZipArchive(archive: Uint8Array, options?: ZipArchiveReadOptions): DecodedZipArchive;
5
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAE5B,KAAK,oBAAoB,EAEzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAC;AAGxB,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,qBAAqB,EAAE,EACzC,OAAO,EAAE,uBAAuB,GAC/B,UAAU,CA8BZ;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAGtB;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,qBAA0B,GAClC,iBAAiB,CAuBnB"}
package/dist/codec.js ADDED
@@ -0,0 +1,142 @@
1
+ import { ArchiveSafetyError, inspectArchiveEntries, } from '@openge/forge-archive-safety';
2
+ import { unzipSync, zipSync } from 'fflate';
3
+ import { parseZipCentralDirectory } from './central-directory.js';
4
+ import { zipArchiveDefaultLimits, zipArchiveErrorCodes, } from './contracts.js';
5
+ import { ZipArchiveError } from './errors.js';
6
+ export function encodeZipArchive(entries, options) {
7
+ const limits = resolveLimits(options.limits);
8
+ inspectSafety(entries.map((entry) => ({
9
+ kind: entry.kind,
10
+ path: entry.path,
11
+ uncompressedBytes: entry.kind === 'file' ? entry.bytes.length : 0,
12
+ })), limits);
13
+ const seen = new Set();
14
+ const zippable = Object.create(null);
15
+ for (const entry of [...entries].toSorted((left, right) => comparePaths(left.path, right.path))) {
16
+ if (seen.has(entry.path)) {
17
+ throw new ZipArchiveError(zipArchiveErrorCodes.duplicateEntry, { path: entry.path });
18
+ }
19
+ seen.add(entry.path);
20
+ if ((entry.kind === 'directory') !== entry.path.endsWith('/')) {
21
+ throw new ZipArchiveError(zipArchiveErrorCodes.invalidEntry, { path: entry.path });
22
+ }
23
+ zippable[entry.path] = entry.kind === 'file' ? entry.bytes : new Uint8Array();
24
+ }
25
+ let archive;
26
+ try {
27
+ archive = zipSync(zippable, {
28
+ level: options.compression === 'store' ? 0 : 6,
29
+ mtime: new Date(1980, 0, 1),
30
+ });
31
+ }
32
+ catch (error) {
33
+ throw new ZipArchiveError(zipArchiveErrorCodes.invalidEntry, {}, error);
34
+ }
35
+ assertArchiveSize(archive, limits);
36
+ return archive;
37
+ }
38
+ export function inspectZipArchive(archive, options = {}) {
39
+ const inspection = inspectInternal(archive, options);
40
+ return { entries: inspection.entries, summary: inspection.summary };
41
+ }
42
+ export function decodeZipArchive(archive, options = {}) {
43
+ const inspection = inspectInternal(archive, options);
44
+ let decoded;
45
+ try {
46
+ decoded = unzipSync(archive);
47
+ }
48
+ catch (error) {
49
+ throw new ZipArchiveError(zipArchiveErrorCodes.decompressionFailed, {}, error);
50
+ }
51
+ const entries = inspection.parsedEntries.map((entry) => {
52
+ const bytes = Object.prototype.hasOwnProperty.call(decoded, entry.path)
53
+ ? decoded[entry.path]
54
+ : undefined;
55
+ if (bytes === undefined || bytes.length !== entry.uncompressedBytes) {
56
+ throw new ZipArchiveError(zipArchiveErrorCodes.decompressionFailed, { path: entry.path });
57
+ }
58
+ if (calculateCrc32(bytes) !== entry.crc32) {
59
+ throw new ZipArchiveError(zipArchiveErrorCodes.crcMismatch, { path: entry.path });
60
+ }
61
+ return entry.kind === 'directory'
62
+ ? { kind: 'directory', path: entry.path }
63
+ : { bytes, kind: 'file', path: entry.path };
64
+ });
65
+ return { entries };
66
+ }
67
+ function inspectInternal(archive, options) {
68
+ const limits = resolveLimits(options.limits);
69
+ assertArchiveSize(archive, limits);
70
+ const parsedEntries = parseZipCentralDirectory(archive);
71
+ const summary = inspectSafety(parsedEntries.map((entry) => ({
72
+ kind: entry.kind,
73
+ path: entry.path,
74
+ uncompressedBytes: entry.uncompressedBytes,
75
+ })), limits);
76
+ const entries = parsedEntries.map((entry) => {
77
+ if (entry.kind !== 'directory' && entry.kind !== 'file') {
78
+ throw new ZipArchiveError(zipArchiveErrorCodes.unsafeArchive, { path: entry.path });
79
+ }
80
+ return {
81
+ compressedBytes: entry.compressedBytes,
82
+ compression: entry.compression,
83
+ crc32: entry.crc32,
84
+ kind: entry.kind,
85
+ path: entry.path,
86
+ uncompressedBytes: entry.uncompressedBytes,
87
+ };
88
+ });
89
+ return { entries, parsedEntries, summary };
90
+ }
91
+ function inspectSafety(entries, limits) {
92
+ try {
93
+ return inspectArchiveEntries(entries, {
94
+ maxEntries: limits.maxEntries,
95
+ maxExpandedBytes: limits.maxExpandedBytes,
96
+ });
97
+ }
98
+ catch (error) {
99
+ if (error instanceof ArchiveSafetyError) {
100
+ throw new ZipArchiveError(zipArchiveErrorCodes.unsafeArchive, { safetyCode: error.code }, error);
101
+ }
102
+ throw error;
103
+ }
104
+ }
105
+ function resolveLimits(overrides) {
106
+ const limits = { ...zipArchiveDefaultLimits, ...overrides };
107
+ if (!Number.isSafeInteger(limits.maxArchiveBytes)
108
+ || limits.maxArchiveBytes <= 0
109
+ || !Number.isSafeInteger(limits.maxEntries)
110
+ || limits.maxEntries <= 0
111
+ || !Number.isSafeInteger(limits.maxExpandedBytes)
112
+ || limits.maxExpandedBytes <= 0) {
113
+ throw new ZipArchiveError(zipArchiveErrorCodes.invalidLimits);
114
+ }
115
+ return limits;
116
+ }
117
+ function assertArchiveSize(archive, limits) {
118
+ if (archive.length > limits.maxArchiveBytes) {
119
+ throw new ZipArchiveError(zipArchiveErrorCodes.archiveTooLarge, {
120
+ actualBytes: archive.length,
121
+ maxArchiveBytes: limits.maxArchiveBytes,
122
+ });
123
+ }
124
+ }
125
+ function comparePaths(left, right) {
126
+ return left < right ? -1 : left > right ? 1 : 0;
127
+ }
128
+ const crcTable = Uint32Array.from({ length: 256 }, (_, index) => {
129
+ let value = index;
130
+ for (let bit = 0; bit < 8; bit += 1) {
131
+ value = (value & 1) === 1 ? 0xedb88320 ^ (value >>> 1) : value >>> 1;
132
+ }
133
+ return value >>> 0;
134
+ });
135
+ function calculateCrc32(bytes) {
136
+ let crc = 0xffffffff;
137
+ for (const byte of bytes) {
138
+ crc = (crcTable[(crc ^ byte) & 0xff] ?? 0) ^ (crc >>> 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1
+ import type { ArchiveInspectionSummary, ArchiveSafetyLimits } from '@openge/forge-archive-safety';
2
+ export type ZipArchiveCompression = 'deflate' | 'store';
3
+ export type ZipArchiveSourceEntry = {
4
+ readonly bytes: Uint8Array;
5
+ readonly kind: 'file';
6
+ readonly path: string;
7
+ } | {
8
+ readonly kind: 'directory';
9
+ readonly path: string;
10
+ };
11
+ export interface EncodeZipArchiveOptions {
12
+ readonly compression: ZipArchiveCompression;
13
+ readonly limits?: Partial<ZipArchiveLimits>;
14
+ }
15
+ export interface DecodedZipArchive {
16
+ readonly entries: readonly ZipArchiveSourceEntry[];
17
+ }
18
+ export interface ZipArchiveLimits extends ArchiveSafetyLimits {
19
+ readonly maxArchiveBytes: number;
20
+ }
21
+ export interface ZipArchiveReadOptions {
22
+ readonly limits?: Partial<ZipArchiveLimits>;
23
+ }
24
+ export interface ZipArchiveEntryMetadata {
25
+ readonly compressedBytes: number;
26
+ readonly compression: ZipArchiveCompression;
27
+ readonly crc32: number;
28
+ readonly kind: 'directory' | 'file';
29
+ readonly path: string;
30
+ readonly uncompressedBytes: number;
31
+ }
32
+ export interface ZipArchiveInspection {
33
+ readonly entries: readonly ZipArchiveEntryMetadata[];
34
+ readonly summary: ArchiveInspectionSummary;
35
+ }
36
+ export declare const zipArchiveDefaultLimits: ZipArchiveLimits;
37
+ export declare const zipArchiveErrorCodes: {
38
+ readonly archiveTooLarge: "ARCHIVE_TOO_LARGE";
39
+ readonly crcMismatch: "CRC_MISMATCH";
40
+ readonly decompressionFailed: "DECOMPRESSION_FAILED";
41
+ readonly duplicateEntry: "DUPLICATE_ENTRY";
42
+ readonly invalidEntry: "INVALID_ENTRY";
43
+ readonly invalidLimits: "INVALID_LIMITS";
44
+ readonly invalidZip: "INVALID_ZIP";
45
+ readonly unsafeArchive: "UNSAFE_ARCHIVE";
46
+ readonly unsupportedZipFeature: "UNSUPPORTED_ZIP_FEATURE";
47
+ };
48
+ export type ZipArchiveErrorCode = typeof zipArchiveErrorCodes[keyof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AC;IACtB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACrD,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;CAC5C;AAED,eAAO,MAAM,uBAAuB,EAAE,gBAIpC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;CAUvB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,OAAO,oBAAoB,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export const zipArchiveDefaultLimits = Object.freeze({
2
+ maxArchiveBytes: 268_435_456,
3
+ maxEntries: 10_000,
4
+ maxExpandedBytes: 1_073_741_824,
5
+ });
6
+ export const zipArchiveErrorCodes = {
7
+ archiveTooLarge: 'ARCHIVE_TOO_LARGE',
8
+ crcMismatch: 'CRC_MISMATCH',
9
+ decompressionFailed: 'DECOMPRESSION_FAILED',
10
+ duplicateEntry: 'DUPLICATE_ENTRY',
11
+ invalidEntry: 'INVALID_ENTRY',
12
+ invalidLimits: 'INVALID_LIMITS',
13
+ invalidZip: 'INVALID_ZIP',
14
+ unsafeArchive: 'UNSAFE_ARCHIVE',
15
+ unsupportedZipFeature: 'UNSUPPORTED_ZIP_FEATURE',
16
+ };
17
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAuCA,MAAM,CAAC,MAAM,uBAAuB,GAAqB,MAAM,CAAC,MAAM,CAAC;IACrE,eAAe,EAAE,WAAW;IAC5B,UAAU,EAAE,MAAM;IAClB,gBAAgB,EAAE,aAAa;CAChC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,eAAe,EAAE,mBAAmB;IACpC,WAAW,EAAE,cAAc;IAC3B,mBAAmB,EAAE,sBAAsB;IAC3C,cAAc,EAAE,iBAAiB;IACjC,YAAY,EAAE,eAAe;IAC7B,aAAa,EAAE,gBAAgB;IAC/B,UAAU,EAAE,aAAa;IACzB,aAAa,EAAE,gBAAgB;IAC/B,qBAAqB,EAAE,yBAAyB;CACxC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ZipArchiveErrorCode } from './contracts.js';
2
+ export declare class ZipArchiveError extends Error {
3
+ readonly code: ZipArchiveErrorCode;
4
+ readonly details: Readonly<Record<string, unknown>>;
5
+ constructor(code: ZipArchiveErrorCode, details?: Readonly<Record<string, unknown>>, cause?: unknown);
6
+ }
7
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;gBAGlD,IAAI,EAAE,mBAAmB,EACzB,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,EAC/C,KAAK,CAAC,EAAE,OAAO;CAOlB"}
package/dist/errors.js ADDED
@@ -0,0 +1,11 @@
1
+ export class ZipArchiveError extends Error {
2
+ code;
3
+ details;
4
+ constructor(code, details = {}, cause) {
5
+ super(code, cause === undefined ? undefined : { cause });
6
+ this.name = 'ZipArchiveError';
7
+ this.code = code;
8
+ this.details = details;
9
+ }
10
+ }
11
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAsB;IAC1B,OAAO,CAAoC;IAEpD,YACE,IAAyB,EACzB,UAA6C,EAAE,EAC/C,KAAe;QAEf,KAAK,CAAC,IAAI,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export type { DecodedZipArchive, EncodeZipArchiveOptions, ZipArchiveEntryMetadata, ZipArchiveErrorCode, ZipArchiveInspection, ZipArchiveLimits, ZipArchiveReadOptions, ZipArchiveCompression, ZipArchiveSourceEntry, } from './contracts.js';
2
+ export { zipArchiveDefaultLimits, zipArchiveErrorCodes } from './contracts.js';
3
+ export { decodeZipArchive, encodeZipArchive, inspectZipArchive } from './codec.js';
4
+ export { ZipArchiveError } from './errors.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { zipArchiveDefaultLimits, zipArchiveErrorCodes } from './contracts.js';
2
+ export { decodeZipArchive, encodeZipArchive, inspectZipArchive } from './codec.js';
3
+ export { ZipArchiveError } from './errors.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@openge/forge-archive-zip",
3
+ "version": "0.1.0-rc.0",
4
+ "description": "Runtime-neutral ZIP32 archive Provider with bounded safety validation",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE",
18
+ "NOTICE"
19
+ ],
20
+ "sideEffects": false,
21
+ "engines": {
22
+ "node": ">=22.14.0"
23
+ },
24
+ "license": "Apache-2.0",
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/zopenge/foundation-forge.git",
31
+ "directory": "packages/archive-zip"
32
+ },
33
+ "homepage": "https://github.com/zopenge/foundation-forge#readme",
34
+ "bugs": {
35
+ "url": "https://github.com/zopenge/foundation-forge/issues"
36
+ },
37
+ "dependencies": {
38
+ "fflate": "0.8.3",
39
+ "@openge/forge-archive-safety": "^0.1.0"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc -p tsconfig.build.json",
43
+ "lint": "eslint . --max-warnings 0",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit --pretty false",
45
+ "test": "vitest run",
46
+ "test:coverage": "vitest run --coverage"
47
+ }
48
+ }