@eyeoverthink/wasm-deflate-vault 0.0.0-stage → 2.0.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 +174 -0
- package/README.md +43 -3
- package/package.json +48 -6
- package/src/wasm-deflate-vault.d.ts +28 -0
- package/src/wasm-deflate-vault.js +859 -0
- package/test/vault.test.js +284 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
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
|
|
41
|
+
Object 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.
|
|
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
|
|
53
|
+
of 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 into 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 a copy of this
|
|
95
|
+
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 NOTICE file within such Work,
|
|
109
|
+
excluding those notices that do not pertain to any part of
|
|
110
|
+
the Derivative Works, in at least one of the following places:
|
|
111
|
+
within a NOTICE text file distributed as part of the Work; within
|
|
112
|
+
the Source form or documentation, if provided along with the
|
|
113
|
+
Work; or, within a display generated by the Derivative Works,
|
|
114
|
+
if and wherever such third-party notices normally appear. The
|
|
115
|
+
contents of the NOTICE file are for informational purposes only
|
|
116
|
+
and do not modify the License. You may add Your own attribution
|
|
117
|
+
notices within Derivative Works that You distribute, alongside
|
|
118
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
119
|
+
that such additional notices cannot be construed as modifying
|
|
120
|
+
the License.
|
|
121
|
+
|
|
122
|
+
You may add Your own copyright notice to Your modifications and
|
|
123
|
+
may provide additional or different license terms and conditions
|
|
124
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
125
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
126
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
127
|
+
the conditions stated in this License.
|
|
128
|
+
|
|
129
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
130
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
131
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
132
|
+
this License, without any additional terms or conditions.
|
|
133
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
134
|
+
the terms of any separate license agreement you may have executed
|
|
135
|
+
with Licensor regarding such Contributions.
|
|
136
|
+
|
|
137
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
138
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
139
|
+
except as required for reasonable and customary use in describing the
|
|
140
|
+
origin of the Work and reproducing the copyright notice.
|
|
141
|
+
|
|
142
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
143
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
144
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
145
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
146
|
+
implied, including, without limitation, any warranties or conditions
|
|
147
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
148
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
149
|
+
appropriateness of using or redistributing the Work and assume any
|
|
150
|
+
risks associated with Your exercise of permissions under this License.
|
|
151
|
+
|
|
152
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
153
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
154
|
+
unless required by applicable law (including intentional or gross
|
|
155
|
+
negligence) damages, shall any Contributor be liable to You for
|
|
156
|
+
damages, including any direct, indirect, incidental, special,
|
|
157
|
+
incidental, or consequential damages of any kind arising out of this
|
|
158
|
+
License or out of the use or inability to use the Work (including
|
|
159
|
+
but not limited to loss of data, loss of profits, or business
|
|
160
|
+
interruption), even if such Contributor has been advised of the
|
|
161
|
+
possibility of such damages.
|
|
162
|
+
|
|
163
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
164
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
165
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
166
|
+
or other liability obligations and/or rights consistent with this
|
|
167
|
+
License. However, in accepting such obligations, You may act only
|
|
168
|
+
on Your own behalf and on Your own sole responsibility, not on behalf
|
|
169
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
170
|
+
defend, and hold each Contributor harmless for any liability
|
|
171
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
172
|
+
of your accepting any such warranty or additional liability.
|
|
173
|
+
|
|
174
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# WASM Deflate Vault (`v2.0.0`)
|
|
2
|
+
|
|
3
|
+
[](https://github.com/eyeoverthink/wasm-deflate-vault/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Zero-dependency, **100% offline** unification of `java__java-rosetta-stone-perfect-v2.html` + `transmutation__Transmutation-Bridge-Key-Encoded.html`:
|
|
7
|
+
|
|
8
|
+
- **Live Vault Studio:** https://eyeoverthink.github.io/wasm-deflate-vault/
|
|
9
|
+
- **Repository:** https://github.com/eyeoverthink/wasm-deflate-vault (`v2.0.0`, Apache-2.0)
|
|
10
|
+
|
|
11
|
+
## Primitives
|
|
12
|
+
|
|
13
|
+
1. **Deflate-in-WASM container (`packDeflateWasmContainer` / `unpackAndVerifyWasmContainer`):** Compresses multi-file bundles via `CompressionStream('deflate')` (`78 9c` zlib header) and embeds the payload in a `.wasm` linear-memory Data segment alongside `"wdv.manifest"` (manifest, Ed25519 signature, signer key). The module holds data and four constant-returning functions; inflating happens in JavaScript. File contents may be strings or `Uint8Array` (binary files come back as `Uint8Array`).
|
|
14
|
+
The verifier **never compiles or runs the module**: it parses the bytes, requires exactly the layout this package writes, then checks SHA-256, the Ed25519 signature, and the per-file Merkle root. Inflated size is capped (`maxInflatedBytes`, default 64 MiB).
|
|
15
|
+
2. **Per-File RFC 6962 Merkle Inclusion Proofs:** Proves any single file (`getFileMerkleProof` / `verifyFileMerkleProof`) against the signed root.
|
|
16
|
+
3. **Standard PKZIP (`0x04034b50` + CRC-32) Builder & Inspector** + **Variation-Selector Signed Carrier Bridge**.
|
|
17
|
+
|
|
18
|
+
## Trust model (2.0.0)
|
|
19
|
+
|
|
20
|
+
A signature only means something if you know whose key made it. The verifier therefore **never trusts the key embedded in a vault**: pass the signer's raw Ed25519 public key (64 hex characters) as `expectedPublicKeys`. Without it, or with any other key, the result is `ok: false` and no files are returned. Small-order Ed25519 keys, which verify any message without a private key, are always refused.
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
const packed = await packDeflateWasmContainer(files, { keyPair }); // packed.publicKeyHex
|
|
24
|
+
const res = await unpackAndVerifyWasmContainer(wasmBytes, { expectedPublicKeys: [trustedSignerHex] });
|
|
25
|
+
if (res.ok) use(res.files);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`decodeBridgeCarrier(text, { expectedPublicKeys })` follows the same rule.
|
|
29
|
+
|
|
30
|
+
Breaking changes from 1.x: `unpackAndVerifyWasmContainer` and `decodeBridgeCarrier` return `ok: false` without pinned keys; `checks` gains `keyTrusted`.
|
|
31
|
+
|
|
32
|
+
Known limits: the per-file Merkle tree duplicates an odd node and joins name and content with `0x1f`, so it is **not** RFC 6962 and two different file maps can share a root; use it as a change detector only. The zip writer writes names as given (sanitise `..` and absolute paths yourself).
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @eyeoverthink/wasm-deflate-vault
|
|
38
|
+
npm test
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
Apache-2.0 — see [LICENSE](LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@eyeoverthink/wasm-deflate-vault",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@eyeoverthink/wasm-deflate-vault",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Zero-dependency Self-Extracting Deflate-in-WASM container, IEEE 802.3 CRC-32 PKZIP builder/inspector, RFC 6962 per-file Merkle inclusion prover, WebCrypto Ed25519 signing, and Unicode Variation-Selector bridge.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./src/wasm-deflate-vault.js",
|
|
8
|
+
"types": "./src/wasm-deflate-vault.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./src/wasm-deflate-vault.d.ts",
|
|
12
|
+
"import": "./src/wasm-deflate-vault.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src/",
|
|
17
|
+
"test/",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"wasm",
|
|
23
|
+
"deflate",
|
|
24
|
+
"pkzip",
|
|
25
|
+
"merkle-tree",
|
|
26
|
+
"rfc6962",
|
|
27
|
+
"ed25519",
|
|
28
|
+
"steganography",
|
|
29
|
+
"zero-dependency"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/eyeoverthink/wasm-deflate-vault.git"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://eyeoverthink.github.io/wasm-deflate-vault/",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/eyeoverthink/wasm-deflate-vault/issues"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"test": "node --test test/vault.test.js"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const VERSION: string;
|
|
2
|
+
export const VAULT_MAGIC: number;
|
|
3
|
+
|
|
4
|
+
export function crc32(bytes: Uint8Array): number;
|
|
5
|
+
export function buildZipArchive(filesMap: Record<string, string | Uint8Array>): Uint8Array;
|
|
6
|
+
export function inspectZipArchive(zipBytes: Uint8Array): { ok: boolean; magicHex?: string; entryCount?: number; totalBytes?: number; cdMatch?: boolean; entries?: unknown[]; error?: string };
|
|
7
|
+
|
|
8
|
+
export function buildFileMerkleTree(filesMap: Record<string, string | Uint8Array>): Promise<{ filenames: string[]; leafCount: number; layers: string[][]; rootHex: string }>;
|
|
9
|
+
export function getFileMerkleProof(tree: { filenames: string[]; layers: string[][]; rootHex: string }, filename: string): { filename: string; leafHash: string; proof: Array<{ position: "left" | "right"; hash: string }>; rootHex: string };
|
|
10
|
+
export function verifyFileMerkleProof(opts: { filename: string; content: string | Uint8Array; proof: Array<{ position: "left" | "right"; hash: string }>; rootHex: string }): Promise<{ ok: boolean; computedRoot: string; expectedRoot: string }>;
|
|
11
|
+
|
|
12
|
+
export const DEFAULT_MAX_INFLATED_BYTES: number;
|
|
13
|
+
|
|
14
|
+
/** Raw Ed25519 public keys as 64 hex characters; one or a list. */
|
|
15
|
+
export type ExpectedPublicKeys = string | string[];
|
|
16
|
+
|
|
17
|
+
/** True for a malformed key or one of the small-order Ed25519 points (which verify any message). */
|
|
18
|
+
export function isSmallOrderKey(publicKeyHex: string): boolean;
|
|
19
|
+
/** Raw Ed25519 public key of a CryptoKey as 64 hex characters. */
|
|
20
|
+
export function publicKeyToHex(publicKey: CryptoKey): Promise<string>;
|
|
21
|
+
|
|
22
|
+
export function packDeflateWasmContainer(filesMap: Record<string, string | Uint8Array>, options?: { issuedAt?: string; keyPair?: CryptoKeyPair }): Promise<{ wasmBytes: Uint8Array; wasmByteLength: number; manifest: Record<string, unknown>; envelope: Record<string, unknown>; publicKeyHex: string; merkleTree: Awaited<ReturnType<typeof buildFileMerkleTree>> }>;
|
|
23
|
+
/** Never compiles or runs the module. ok is true only when the signer is one of `expectedPublicKeys`. */
|
|
24
|
+
export function unpackAndVerifyWasmContainer(wasmBytes: Uint8Array, options?: { expectedPublicKeys?: ExpectedPublicKeys; maxInflatedBytes?: number }): Promise<{ ok: boolean; checks: { magicOk: boolean; sha256Ok: boolean; keyTrusted: boolean; signatureOk: boolean; merkleOk: boolean }; manifest?: Record<string, unknown>; signerPublicKeyHex?: string | null; edFxTag?: string; files?: Record<string, string | Uint8Array>; merkleTree?: Awaited<ReturnType<typeof buildFileMerkleTree>>; error?: string }>;
|
|
25
|
+
export function findWasmDataSegmentByteOffset(wasmBytes: Uint8Array): number;
|
|
26
|
+
|
|
27
|
+
export function encodeBridgeCarrier(envelope: Record<string, unknown>, carrierGlyph?: string): { carrier: string; encodedBytes: number };
|
|
28
|
+
export function decodeBridgeCarrier(carrierText: string, options?: { expectedPublicKeys?: ExpectedPublicKeys }): Promise<{ ok: boolean; signatureValid?: boolean; keyTrusted?: boolean; signerPublicKeyHex?: string | null; manifest?: Record<string, unknown>; edFxTag?: string; error?: string }>;
|