pure-md5 0.2.0 → 0.2.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.
Files changed (158) hide show
  1. package/dist/adapters/ie11.cjs +1 -2
  2. package/dist/adapters/ie11.js +1 -2
  3. package/dist/adapters/node.cjs +1 -2
  4. package/dist/adapters/node.js +1 -2
  5. package/dist/adapters/webcrypto.cjs +1 -2
  6. package/dist/adapters/webcrypto.js +1 -2
  7. package/dist/core/index.cjs +1 -2
  8. package/dist/core/index.js +1 -2
  9. package/dist/index.cjs +1 -2
  10. package/dist/index.js +1 -2
  11. package/dist/stream/adapter.cjs +1 -2
  12. package/dist/stream/adapter.js +1 -2
  13. package/dist/stream/fs-utils.cjs +1 -2
  14. package/dist/stream/fs-utils.js +1 -2
  15. package/dist/stream/index.cjs +1 -2
  16. package/dist/stream/index.js +1 -2
  17. package/dist/stream/light/index.cjs +1 -2
  18. package/dist/stream/light/index.js +1 -2
  19. package/dist/stream/md5-stream.cjs +1 -2
  20. package/dist/stream/md5-stream.js +1 -2
  21. package/dist/stream/whatwg-stream.cjs +1 -2
  22. package/dist/stream/whatwg-stream.js +1 -2
  23. package/dist/utils/detect.cjs +1 -2
  24. package/dist/utils/detect.js +1 -2
  25. package/package.json +1 -1
  26. package/pure-md5-0.2.0.tgz +0 -0
  27. package/.aliases +0 -19
  28. package/.bash_profile +0 -12
  29. package/.bash_prompt +0 -56
  30. package/.changeset/README.md +0 -32
  31. package/.changeset/config.json +0 -16
  32. package/.continue/mcpServers/new-mcp-server.yaml +0 -10
  33. package/.continue/rules +0 -29
  34. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  35. package/.github/ISSUE_TEMPLATE/documentation.md +0 -20
  36. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  37. package/.github/PULL_REQUEST_TEMPLATE.md +0 -35
  38. package/.github/workflows/npm-publish.yml +0 -33
  39. package/.github/workflows/release.yml +0 -42
  40. package/CHANGELOG.md +0 -9
  41. package/CONTRIBUTING.md +0 -203
  42. package/MIGRATION_GUIDE_STREAMS.md +0 -374
  43. package/STREAM_API.md +0 -582
  44. package/STREAM_BENCHMARKS.md +0 -232
  45. package/STREAM_EXAMPLES.md +0 -669
  46. package/STREAM_OPTIMIZATION_REPORT.md +0 -136
  47. package/STREAM_TROUBLESHOOTING.md +0 -537
  48. package/WEB_CRYPTO_TESTS_SUMMARY.md +0 -140
  49. package/WHATWG_STREAMS.md +0 -191
  50. package/__tests__/adapters/node-crypto.test.ts +0 -167
  51. package/__tests__/adapters/web-crypto-node.test.ts +0 -73
  52. package/__tests__/adapters/web-crypto.test.ts +0 -195
  53. package/__tests__/add32.test.ts +0 -33
  54. package/__tests__/fallback.test.ts +0 -345
  55. package/__tests__/hex.test.ts +0 -38
  56. package/__tests__/hex_chr.test.ts +0 -20
  57. package/__tests__/index.test.ts +0 -87
  58. package/__tests__/integration/fixtures/test-file.txt +0 -1
  59. package/__tests__/integration/md5-stream-file.test.ts +0 -293
  60. package/__tests__/integration/node-crypto-file.test.ts +0 -86
  61. package/__tests__/integration/web-crypto.test.ts +0 -38
  62. package/__tests__/md51.test.ts +0 -73
  63. package/__tests__/md5block.test.ts +0 -61
  64. package/__tests__/md5cycle.test.ts +0 -48
  65. package/__tests__/round-functions.test.ts +0 -87
  66. package/__tests__/stream/fs-utils.test.ts +0 -209
  67. package/__tests__/stream/md5-stream-edge-cases.test.ts +0 -461
  68. package/__tests__/stream/md5-stream.test.ts +0 -418
  69. package/__tests__/stream/whatwg-stream.test.ts +0 -355
  70. package/__tests__/stream/whatwg-stream.test.ts.bak2 +0 -335
  71. package/benchmarks/md5-stream.bench.ts +0 -212
  72. package/benchmarks/whatwg-stream.bench.ts +0 -180
  73. package/dist/adapters/ie11.cjs.map +0 -1
  74. package/dist/adapters/ie11.js.map +0 -1
  75. package/dist/adapters/node.cjs.map +0 -1
  76. package/dist/adapters/node.js.map +0 -1
  77. package/dist/adapters/webcrypto.cjs.map +0 -1
  78. package/dist/adapters/webcrypto.js.map +0 -1
  79. package/dist/chunk-2YXXFGBV.js +0 -2
  80. package/dist/chunk-2YXXFGBV.js.map +0 -1
  81. package/dist/chunk-4KSCMS4Q.js +0 -2
  82. package/dist/chunk-4KSCMS4Q.js.map +0 -1
  83. package/dist/chunk-6P2QV5SR.js +0 -4
  84. package/dist/chunk-6P2QV5SR.js.map +0 -1
  85. package/dist/chunk-G5WHEAIQ.js +0 -2
  86. package/dist/chunk-G5WHEAIQ.js.map +0 -1
  87. package/dist/chunk-H2K353LR.js +0 -2
  88. package/dist/chunk-H2K353LR.js.map +0 -1
  89. package/dist/chunk-JKVD5LHZ.js +0 -2
  90. package/dist/chunk-JKVD5LHZ.js.map +0 -1
  91. package/dist/chunk-NWQ4N5RX.js +0 -2
  92. package/dist/chunk-NWQ4N5RX.js.map +0 -1
  93. package/dist/chunk-PHZ7FTYF.js +0 -2
  94. package/dist/chunk-PHZ7FTYF.js.map +0 -1
  95. package/dist/chunk-PNZTVQA7.js +0 -2
  96. package/dist/chunk-PNZTVQA7.js.map +0 -1
  97. package/dist/chunk-R4JB5MBR.js +0 -2
  98. package/dist/chunk-R4JB5MBR.js.map +0 -1
  99. package/dist/chunk-VFOAY6XI.js +0 -2
  100. package/dist/chunk-VFOAY6XI.js.map +0 -1
  101. package/dist/chunk-XB5BQIEX.js +0 -2
  102. package/dist/chunk-XB5BQIEX.js.map +0 -1
  103. package/dist/core/index.cjs.map +0 -1
  104. package/dist/core/index.js.map +0 -1
  105. package/dist/index.cjs.map +0 -1
  106. package/dist/index.js.map +0 -1
  107. package/dist/stream/adapter.cjs.map +0 -1
  108. package/dist/stream/adapter.js.map +0 -1
  109. package/dist/stream/fs-utils.cjs.map +0 -1
  110. package/dist/stream/fs-utils.js.map +0 -1
  111. package/dist/stream/index.cjs.map +0 -1
  112. package/dist/stream/index.js.map +0 -1
  113. package/dist/stream/light/index.cjs.map +0 -1
  114. package/dist/stream/light/index.js.map +0 -1
  115. package/dist/stream/md5-stream.cjs.map +0 -1
  116. package/dist/stream/md5-stream.js.map +0 -1
  117. package/dist/stream/whatwg-stream.cjs.map +0 -1
  118. package/dist/stream/whatwg-stream.js.map +0 -1
  119. package/dist/utils/detect.cjs.map +0 -1
  120. package/dist/utils/detect.js.map +0 -1
  121. package/planning/03-optimization-size-tree-shaking/01-es-modules-tree-shaking.md +0 -152
  122. package/planning/03-optimization-size-tree-shaking/02-consolidate-modules.md +0 -65
  123. package/planning/03-optimization-size-tree-shaking/03-remove-duplicate-add32.md +0 -93
  124. package/planning/03-optimization-size-tree-shaking/04-remove-runtime-check.md +0 -102
  125. package/planning/03-optimization-size-tree-shaking/05-optimize-loops-performance.md +0 -107
  126. package/planning/03-optimization-size-tree-shaking/06-tsup-formats-configuration.md +0 -227
  127. package/planning/03-optimization-size-tree-shaking/07-multiple-build-formats.md +0 -228
  128. package/planning/03-optimization-size-tree-shaking/08-benchmarks-metrics.md +0 -34
  129. package/planning/03-optimization-size-tree-shaking/MIGRATION_GUIDE.md +0 -260
  130. package/planning/03-optimization-size-tree-shaking/README.md +0 -173
  131. package/planning/03-optimization-size-tree-shaking/SUMMARY.md +0 -168
  132. package/planning/04-adapter-backend/03-backend-web-crypto.md +0 -149
  133. package/planning/04-adapter-backend/04-backend-node-crypto.md +0 -181
  134. package/planning/04-adapter-backend/05-backend-pure-js.md +0 -174
  135. package/planning/04-adapter-backend/06-backend-ie11.md +0 -158
  136. package/planning/04-adapter-backend/07-detection-environment.md +0 -232
  137. package/planning/04-adapter-backend/08-detection-backend.md +0 -210
  138. package/planning/04-adapter-backend/09-adapter-unified.md +0 -255
  139. package/planning/04-adapter-backend/10-fallback-mechanism.md +0 -333
  140. package/planning/04-adapter-backend/11-tests-backend-web-crypto.md +0 -191
  141. package/planning/04-adapter-backend/12-tests-backend-node-crypto.md +0 -222
  142. package/planning/04-adapter-backend/README.md +0 -45
  143. package/planning/05-documentation-publishing/01-README-optimization.md +0 -105
  144. package/planning/05-documentation-publishing/02-VitePress-site-evaluation.md +0 -136
  145. package/planning/05-documentation-publishing/03-Changeset-setup.md +0 -192
  146. package/planning/05-documentation-publishing/04-GitHub-templates.md +0 -252
  147. package/planning/05-documentation-publishing/README.md +0 -22
  148. package/planning/05-documentation-publishing/STATUS.md +0 -222
  149. package/planning/prd.md +0 -405
  150. package/planning/streams/01-create-md5stream-class.md +0 -69
  151. package/planning/streams/02-create-factory-api.md +0 -65
  152. package/planning/streams/03-fs-integration.md +0 -37
  153. package/planning/streams/04-whatwg-streams-support.md +0 -37
  154. package/planning/streams/05-audit-optimization.md +0 -121
  155. package/planning/streams/06-comprehensive-tests-docs.md +0 -137
  156. package/planning/streams/07-architecture-integration.md +0 -38
  157. package/planning/streams/README.md +0 -98
  158. package/tsup.config.ts +0 -24
@@ -1,87 +0,0 @@
1
- import { ff, gg, hh, ii } from '../src/round-functions';
2
- import add32 from '../src/add32';
3
-
4
- describe('Round Functions', () => {
5
- const fn = add32;
6
- const a = 0x12345678;
7
- const b = 0x9abcdef0;
8
- const c = 0xfedcba98;
9
- const d = 0x76543210;
10
- const x = 0x13579bdf;
11
- const s = 7;
12
- const t = 0x5a827999;
13
-
14
- describe('ff', () => {
15
- test('should compute F function correctly', () => {
16
- const result = ff(fn, a, b, c, d, x, s, t);
17
-
18
- // Manually compute expected value
19
- const f = (b & c) | (~b & d);
20
- const add = fn;
21
- let expected = add(a, f);
22
- expected = add(expected, x);
23
- expected = add(expected, t);
24
- expected = add((expected << s) | (expected >>> (32 - s)), b);
25
-
26
- expect(result).toBe(expected);
27
- });
28
-
29
- test('should handle different inputs', () => {
30
- const result1 = ff(fn, 0, 0, 0, 0, 0, 0, 0);
31
- expect(result1).toBe(0);
32
-
33
- const result2 = ff(fn, -1, -1, -1, -1, -1, 1, -1);
34
- // Result should be a 32-bit integer (can be negative in two's complement)
35
- expect(result2).toBeGreaterThanOrEqual(-0x80000000);
36
- expect(result2).toBeLessThanOrEqual(0xffffffff);
37
- });
38
- });
39
-
40
- describe('gg', () => {
41
- test('should compute G function correctly', () => {
42
- const result = gg(fn, a, b, c, d, x, s, t);
43
-
44
- // Manually compute expected value
45
- const g = (b & d) | (c & ~d);
46
- const add = fn;
47
- let expected = add(a, g);
48
- expected = add(expected, x);
49
- expected = add(expected, t);
50
- expected = add((expected << s) | (expected >>> (32 - s)), b);
51
-
52
- expect(result).toBe(expected);
53
- });
54
- });
55
-
56
- describe('hh', () => {
57
- test('should compute H function correctly', () => {
58
- const result = hh(fn, a, b, c, d, x, s, t);
59
-
60
- // Manually compute expected value
61
- const h = b ^ c ^ d;
62
- const add = fn;
63
- let expected = add(a, h);
64
- expected = add(expected, x);
65
- expected = add(expected, t);
66
- expected = add((expected << s) | (expected >>> (32 - s)), b);
67
-
68
- expect(result).toBe(expected);
69
- });
70
- });
71
-
72
- describe('ii', () => {
73
- test('should compute I function correctly', () => {
74
- const result = ii(fn, a, b, c, d, x, s, t);
75
-
76
- // Manually compute expected value
77
- const i = c ^ (b | ~d);
78
- const add = fn;
79
- let expected = add(a, i);
80
- expected = add(expected, x);
81
- expected = add(expected, t);
82
- expected = add((expected << s) | (expected >>> (32 - s)), b);
83
-
84
- expect(result).toBe(expected);
85
- });
86
- });
87
- });
@@ -1,209 +0,0 @@
1
- /**
2
- * Tests for file system utilities (fs-utils)
3
- */
4
-
5
- import fs from 'fs';
6
- import path from 'path';
7
- import { Readable } from 'stream';
8
- import {
9
- hashFile,
10
- hashFileStream,
11
- hashFileSync,
12
- verifyFile,
13
- createProgressTracker
14
- } from '../../src/stream/fs-utils.js';
15
- import { md5Core } from '../../src/core/index.js';
16
-
17
- describe('File System Utilities', () => {
18
- const fixturesDir = path.join(__dirname, '..', 'integration', 'fixtures');
19
- const testFile = path.join(fixturesDir, 'test-file.txt');
20
- const nonExistentFile = path.join(fixturesDir, 'non-existent.txt');
21
-
22
- describe('hashFile', () => {
23
- test('should hash a text file correctly', async () => {
24
- const result = await hashFile(testFile);
25
-
26
- expect(result.digest).toBe(md5Core('Hello, World!\n'));
27
- expect(result.bytesProcessed).toBe(14);
28
- expect(typeof result.digest).toBe('string');
29
- expect(result.digest.length).toBe(32);
30
- });
31
-
32
- test('should hash a binary file correctly', async () => {
33
- const tempFile = path.join(fixturesDir, 'temp-binary.bin');
34
- const buffer = Buffer.from([0x00, 0x01, 0x02, 0xff, 0xfe, 0xfd]);
35
-
36
- try {
37
- fs.writeFileSync(tempFile, buffer);
38
- const result = await hashFile(tempFile);
39
-
40
- expect(/^[0-9a-f]{32}$/.test(result.digest)).toBe(true);
41
- expect(result.bytesProcessed).toBe(6);
42
- } finally {
43
- if (fs.existsSync(tempFile)) {
44
- fs.unlinkSync(tempFile);
45
- }
46
- }
47
- });
48
-
49
- test('should handle large files', async () => {
50
- const tempFile = path.join(fixturesDir, 'temp-large.bin');
51
- const bufferSize = 1024 * 1024;
52
- const buffer = Buffer.alloc(bufferSize, 'a');
53
-
54
- try {
55
- fs.writeFileSync(tempFile, buffer);
56
- const result = await hashFile(tempFile);
57
-
58
- expect(result.bytesProcessed).toBe(bufferSize);
59
- expect(result.digest.length).toBe(32);
60
- } finally {
61
- if (fs.existsSync(tempFile)) {
62
- fs.unlinkSync(tempFile);
63
- }
64
- }
65
- });
66
-
67
- test('should throw error for non-existent file', async () => {
68
- await expect(hashFile(nonExistentFile)).rejects.toThrow('File not found');
69
- });
70
-
71
- test('should throw error for directory instead of file', async () => {
72
- await expect(hashFile(fixturesDir)).rejects.toThrow('Path is not a file');
73
- });
74
-
75
- test('should support chunkSize option', async () => {
76
- const result = await hashFile(testFile, { chunkSize: 1024 });
77
- expect(result.digest).toBe(md5Core('Hello, World!\n'));
78
- });
79
-
80
- test('should support onProgress option', async () => {
81
- const progressValues: number[] = [];
82
- const result = await hashFile(testFile, {
83
- onProgress: (current) => {
84
- progressValues.push(current);
85
- }
86
- });
87
-
88
- expect(result.digest).toBe(md5Core('Hello, World!\n'));
89
- expect(progressValues.length).toBeGreaterThan(0);
90
- expect(progressValues[progressValues.length - 1]).toBe(14);
91
- });
92
- });
93
-
94
- describe('hashFileStream', () => {
95
- test('should hash a readable stream correctly', async () => {
96
- const stream = fs.createReadStream(testFile);
97
- const result = await hashFileStream(stream);
98
-
99
- expect(result.digest).toBe(md5Core('Hello, World!\n'));
100
- expect(result.bytesProcessed).toBe(14);
101
- });
102
-
103
- test('should handle buffer input through stream', async () => {
104
- const buffer = Buffer.from('stream test data');
105
- const stream = Readable.from([buffer]);
106
- const result = await hashFileStream(stream);
107
-
108
- expect(result.digest).toBe(md5Core('stream test data'));
109
- expect(result.bytesProcessed).toBe(16);
110
- });
111
-
112
- test('should handle empty stream', async () => {
113
- const stream = Readable.from([]);
114
- const result = await hashFileStream(stream);
115
-
116
- expect(result.digest).toBe(md5Core(''));
117
- expect(result.bytesProcessed).toBe(0);
118
- });
119
-
120
- test('should throw error for invalid stream', async () => {
121
- await expect(hashFileStream(null as any)).rejects.toThrow('Invalid readable stream');
122
- });
123
- });
124
-
125
- describe('hashFileSync', () => {
126
- test('should hash a text file synchronously', () => {
127
- const digest = hashFileSync(testFile);
128
-
129
- expect(typeof digest).toBe('string');
130
- expect(digest.length).toBe(32);
131
- expect(digest).toBe(md5Core('Hello, World!\n'));
132
- });
133
-
134
- test('should hash a binary file synchronously', () => {
135
- const tempFile = path.join(fixturesDir, 'temp-sync.bin');
136
- const buffer = Buffer.from([0x10, 0x20, 0x30]);
137
-
138
- try {
139
- fs.writeFileSync(tempFile, buffer);
140
- const digest = hashFileSync(tempFile);
141
-
142
- expect(/^[0-9a-f]{32}$/.test(digest)).toBe(true);
143
- } finally {
144
- if (fs.existsSync(tempFile)) {
145
- fs.unlinkSync(tempFile);
146
- }
147
- }
148
- });
149
-
150
- test('should throw error for non-existent file', () => {
151
- expect(() => hashFileSync(nonExistentFile)).toThrow('File not found');
152
- });
153
-
154
- test('should throw error for directory', () => {
155
- expect(() => hashFileSync(fixturesDir)).toThrow('Path is not a file');
156
- });
157
- });
158
-
159
- describe('verifyFile', () => {
160
- test('should verify correct digest', async () => {
161
- const digest = md5Core('Hello, World!\n');
162
- const result = await verifyFile(testFile, digest);
163
-
164
- expect(result).toBe(true);
165
- });
166
-
167
- test('should reject incorrect digest', async () => {
168
- const result = await verifyFile(testFile, 'invalid digest');
169
-
170
- expect(result).toBe(false);
171
- });
172
-
173
- test('should be case-insensitive for digest', async () => {
174
- const digest = md5Core('Hello, World!\n').toUpperCase();
175
- const result = await verifyFile(testFile, digest);
176
-
177
- expect(result).toBe(true);
178
- });
179
- });
180
-
181
- describe('createProgressTracker', () => {
182
- test('should create a progress callback', () => {
183
- const progressValues: number[] = [];
184
- const tracker = createProgressTracker(100, (percent) => {
185
- progressValues.push(percent);
186
- });
187
-
188
- tracker(25);
189
- tracker(50);
190
- tracker(75);
191
- tracker(100);
192
-
193
- expect(progressValues.length).toBeGreaterThan(0);
194
- expect(progressValues[progressValues.length - 1]).toBe(100);
195
- });
196
- });
197
-
198
- describe('integration with MD5Stream', () => {
199
- test('should produce same hash as MD5Stream', async () => {
200
- const stream = fs.createReadStream(testFile);
201
- const { MD5Stream, pipeThroughMD5 } = require('../../src/stream/md5-stream.js');
202
- const md5Stream = new MD5Stream();
203
- const streamResult = await pipeThroughMD5.call(md5Stream, stream);
204
- const fileResult = await hashFile(testFile);
205
-
206
- expect(streamResult.digest).toBe(fileResult.digest);
207
- });
208
- });
209
- });