@fgv/ts-web-extras 5.1.0-2 → 5.1.0-21

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 (263) hide show
  1. package/dist/packlets/crypto-utils/browserCryptoProvider.js +208 -18
  2. package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
  3. package/dist/packlets/file-tree/fileApiTreeAccessors.js +1 -1
  4. package/dist/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
  5. package/dist/packlets/file-tree/httpTreeAccessors.js +72 -42
  6. package/dist/packlets/file-tree/httpTreeAccessors.js.map +1 -1
  7. package/dist/ts-web-extras.d.ts +59 -7
  8. package/dist/tsdoc-metadata.json +1 -1
  9. package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +52 -5
  10. package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -1
  11. package/lib/packlets/crypto-utils/browserCryptoProvider.js +207 -17
  12. package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
  13. package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +1 -1
  14. package/lib/packlets/file-tree/fileApiTreeAccessors.js +1 -1
  15. package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
  16. package/lib/packlets/file-tree/httpTreeAccessors.d.ts +6 -0
  17. package/lib/packlets/file-tree/httpTreeAccessors.d.ts.map +1 -1
  18. package/lib/packlets/file-tree/httpTreeAccessors.js +72 -42
  19. package/lib/packlets/file-tree/httpTreeAccessors.js.map +1 -1
  20. package/package.json +27 -26
  21. package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +0 -75
  22. package/.rush/temp/chunked-rush-logs/ts-web-extras.test.chunks.jsonl +0 -75
  23. package/.rush/temp/operation/build/all.log +0 -75
  24. package/.rush/temp/operation/build/error.log +0 -18
  25. package/.rush/temp/operation/build/log-chunks.jsonl +0 -75
  26. package/.rush/temp/operation/build/state.json +0 -3
  27. package/.rush/temp/operation/test/all.log +0 -75
  28. package/.rush/temp/operation/test/error.log +0 -18
  29. package/.rush/temp/operation/test/log-chunks.jsonl +0 -75
  30. package/.rush/temp/operation/test/state.json +0 -3
  31. package/.rush/temp/shrinkwrap-deps.json +0 -635
  32. package/CHANGELOG.md +0 -23
  33. package/config/api-extractor.json +0 -343
  34. package/config/jest.config.json +0 -19
  35. package/config/rig.json +0 -16
  36. package/config/typedoc.json +0 -6
  37. package/dist/test/mocks/idb-keyval.js +0 -6
  38. package/dist/test/mocks/idb-keyval.js.map +0 -1
  39. package/dist/test/setupTests.js +0 -74
  40. package/dist/test/setupTests.js.map +0 -1
  41. package/dist/test/unit/browserHashProvider.test.js +0 -140
  42. package/dist/test/unit/browserHashProvider.test.js.map +0 -1
  43. package/dist/test/unit/directoryHandleStore.test.js +0 -190
  44. package/dist/test/unit/directoryHandleStore.test.js.map +0 -1
  45. package/dist/test/unit/fileApiTreeAccessors.test.js +0 -1188
  46. package/dist/test/unit/fileApiTreeAccessors.test.js.map +0 -1
  47. package/dist/test/unit/fileApiTypes.test.js +0 -472
  48. package/dist/test/unit/fileApiTypes.test.js.map +0 -1
  49. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +0 -622
  50. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
  51. package/dist/test/unit/fileTreeHelpers.test.js +0 -590
  52. package/dist/test/unit/fileTreeHelpers.test.js.map +0 -1
  53. package/dist/test/unit/httpTreeAccessors.test.js +0 -1229
  54. package/dist/test/unit/httpTreeAccessors.test.js.map +0 -1
  55. package/dist/test/unit/localStorageTreeAccessors.test.js +0 -812
  56. package/dist/test/unit/localStorageTreeAccessors.test.js.map +0 -1
  57. package/dist/test/unit/urlParams.test.js +0 -393
  58. package/dist/test/unit/urlParams.test.js.map +0 -1
  59. package/dist/test/utils/fileSystemAccessMocks.js +0 -271
  60. package/dist/test/utils/fileSystemAccessMocks.js.map +0 -1
  61. package/dist/test/utils/testHelpers.js +0 -124
  62. package/dist/test/utils/testHelpers.js.map +0 -1
  63. package/docs/@fgv/namespaces/CryptoUtils/README.md +0 -18
  64. package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserCryptoProvider.md +0 -203
  65. package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserHashProvider.md +0 -63
  66. package/docs/@fgv/namespaces/CryptoUtils/functions/createBrowserCryptoProvider.md +0 -18
  67. package/docs/@fgv/namespaces/FileTreeHelpers/README.md +0 -19
  68. package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileListMetadata.md +0 -23
  69. package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileMetadata.md +0 -23
  70. package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromDirectoryUpload.md +0 -33
  71. package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromFileList.md +0 -33
  72. package/docs/@fgv/namespaces/FileTreeHelpers/functions/getOriginalFile.md +0 -25
  73. package/docs/@fgv/namespaces/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +0 -11
  74. package/docs/README.md +0 -78
  75. package/docs/classes/DirectoryHandleStore.md +0 -116
  76. package/docs/classes/FileApiTreeAccessors.md +0 -286
  77. package/docs/classes/FileSystemAccessTreeAccessors.md +0 -557
  78. package/docs/classes/HttpTreeAccessors.md +0 -508
  79. package/docs/classes/LocalStorageTreeAccessors.md +0 -520
  80. package/docs/functions/exportAsJson.md +0 -23
  81. package/docs/functions/exportUsingFileSystemAPI.md +0 -26
  82. package/docs/functions/extractDirectoryPath.md +0 -23
  83. package/docs/functions/isDirectoryHandle.md +0 -23
  84. package/docs/functions/isFileHandle.md +0 -23
  85. package/docs/functions/isFilePath.md +0 -21
  86. package/docs/functions/parseContextFilter.md +0 -22
  87. package/docs/functions/parseQualifierDefaults.md +0 -22
  88. package/docs/functions/parseResourceTypes.md +0 -22
  89. package/docs/functions/parseUrlParameters.md +0 -15
  90. package/docs/functions/safeShowDirectoryPicker.md +0 -24
  91. package/docs/functions/safeShowOpenFilePicker.md +0 -24
  92. package/docs/functions/safeShowSaveFilePicker.md +0 -24
  93. package/docs/functions/supportsFileSystemAccess.md +0 -23
  94. package/docs/interfaces/FilePickerAcceptType.md +0 -16
  95. package/docs/interfaces/FileSystemCreateWritableOptions.md +0 -15
  96. package/docs/interfaces/FileSystemDirectoryHandle.md +0 -187
  97. package/docs/interfaces/FileSystemFileHandle.md +0 -106
  98. package/docs/interfaces/FileSystemGetDirectoryOptions.md +0 -15
  99. package/docs/interfaces/FileSystemGetFileOptions.md +0 -15
  100. package/docs/interfaces/FileSystemHandle.md +0 -69
  101. package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +0 -15
  102. package/docs/interfaces/FileSystemRemoveOptions.md +0 -15
  103. package/docs/interfaces/FileSystemWritableFileStream.md +0 -127
  104. package/docs/interfaces/IDirectoryHandleTreeInitializer.md +0 -17
  105. package/docs/interfaces/IFileHandleTreeInitializer.md +0 -16
  106. package/docs/interfaces/IFileListTreeInitializer.md +0 -15
  107. package/docs/interfaces/IFileMetadata.md +0 -19
  108. package/docs/interfaces/IFileSystemAccessTreeParams.md +0 -30
  109. package/docs/interfaces/IFsAccessApis.md +0 -57
  110. package/docs/interfaces/IHttpTreeParams.md +0 -32
  111. package/docs/interfaces/ILocalStorageTreeParams.md +0 -30
  112. package/docs/interfaces/IUrlConfigOptions.md +0 -27
  113. package/docs/interfaces/ShowDirectoryPickerOptions.md +0 -17
  114. package/docs/interfaces/ShowOpenFilePickerOptions.md +0 -19
  115. package/docs/interfaces/ShowSaveFilePickerOptions.md +0 -19
  116. package/docs/type-aliases/TreeInitializer.md +0 -11
  117. package/docs/type-aliases/WellKnownDirectory.md +0 -11
  118. package/docs/type-aliases/WindowWithFsAccess.md +0 -11
  119. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +0 -11
  120. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +0 -11
  121. package/etc/ts-web-extras.api.md +0 -433
  122. package/lib/test/mocks/idb-keyval.d.ts +0 -6
  123. package/lib/test/mocks/idb-keyval.d.ts.map +0 -1
  124. package/lib/test/mocks/idb-keyval.js +0 -9
  125. package/lib/test/mocks/idb-keyval.js.map +0 -1
  126. package/lib/test/setupTests.d.ts +0 -2
  127. package/lib/test/setupTests.d.ts.map +0 -1
  128. package/lib/test/setupTests.js +0 -76
  129. package/lib/test/setupTests.js.map +0 -1
  130. package/lib/test/unit/browserHashProvider.test.d.ts +0 -2
  131. package/lib/test/unit/browserHashProvider.test.d.ts.map +0 -1
  132. package/lib/test/unit/browserHashProvider.test.js +0 -142
  133. package/lib/test/unit/browserHashProvider.test.js.map +0 -1
  134. package/lib/test/unit/directoryHandleStore.test.d.ts +0 -2
  135. package/lib/test/unit/directoryHandleStore.test.d.ts.map +0 -1
  136. package/lib/test/unit/directoryHandleStore.test.js +0 -192
  137. package/lib/test/unit/directoryHandleStore.test.js.map +0 -1
  138. package/lib/test/unit/fileApiTreeAccessors.test.d.ts +0 -2
  139. package/lib/test/unit/fileApiTreeAccessors.test.d.ts.map +0 -1
  140. package/lib/test/unit/fileApiTreeAccessors.test.js +0 -1190
  141. package/lib/test/unit/fileApiTreeAccessors.test.js.map +0 -1
  142. package/lib/test/unit/fileApiTypes.test.d.ts +0 -2
  143. package/lib/test/unit/fileApiTypes.test.d.ts.map +0 -1
  144. package/lib/test/unit/fileApiTypes.test.js +0 -474
  145. package/lib/test/unit/fileApiTypes.test.js.map +0 -1
  146. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +0 -2
  147. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +0 -1
  148. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +0 -624
  149. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
  150. package/lib/test/unit/fileTreeHelpers.test.d.ts +0 -2
  151. package/lib/test/unit/fileTreeHelpers.test.d.ts.map +0 -1
  152. package/lib/test/unit/fileTreeHelpers.test.js +0 -592
  153. package/lib/test/unit/fileTreeHelpers.test.js.map +0 -1
  154. package/lib/test/unit/httpTreeAccessors.test.d.ts +0 -2
  155. package/lib/test/unit/httpTreeAccessors.test.d.ts.map +0 -1
  156. package/lib/test/unit/httpTreeAccessors.test.js +0 -1231
  157. package/lib/test/unit/httpTreeAccessors.test.js.map +0 -1
  158. package/lib/test/unit/localStorageTreeAccessors.test.d.ts +0 -2
  159. package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +0 -1
  160. package/lib/test/unit/localStorageTreeAccessors.test.js +0 -814
  161. package/lib/test/unit/localStorageTreeAccessors.test.js.map +0 -1
  162. package/lib/test/unit/urlParams.test.d.ts +0 -2
  163. package/lib/test/unit/urlParams.test.d.ts.map +0 -1
  164. package/lib/test/unit/urlParams.test.js +0 -395
  165. package/lib/test/unit/urlParams.test.js.map +0 -1
  166. package/lib/test/utils/fileSystemAccessMocks.d.ts +0 -53
  167. package/lib/test/utils/fileSystemAccessMocks.d.ts.map +0 -1
  168. package/lib/test/utils/fileSystemAccessMocks.js +0 -277
  169. package/lib/test/utils/fileSystemAccessMocks.js.map +0 -1
  170. package/lib/test/utils/testHelpers.d.ts +0 -51
  171. package/lib/test/utils/testHelpers.d.ts.map +0 -1
  172. package/lib/test/utils/testHelpers.js +0 -133
  173. package/lib/test/utils/testHelpers.js.map +0 -1
  174. package/rush-logs/ts-web-extras.build.cache.log +0 -0
  175. package/rush-logs/ts-web-extras.build.error.log +0 -18
  176. package/rush-logs/ts-web-extras.build.log +0 -75
  177. package/rush-logs/ts-web-extras.test.cache.log +0 -1
  178. package/rush-logs/ts-web-extras.test.error.log +0 -18
  179. package/rush-logs/ts-web-extras.test.log +0 -75
  180. package/src/index.browser.ts +0 -24
  181. package/src/index.ts +0 -47
  182. package/src/packlets/crypto-utils/browserCryptoProvider.ts +0 -311
  183. package/src/packlets/crypto-utils/browserHashProvider.ts +0 -73
  184. package/src/packlets/crypto-utils/index.ts +0 -29
  185. package/src/packlets/file-api-types/index.ts +0 -366
  186. package/src/packlets/file-tree/directoryHandleStore.ts +0 -136
  187. package/src/packlets/file-tree/fileApiTreeAccessors.ts +0 -528
  188. package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +0 -519
  189. package/src/packlets/file-tree/httpTreeAccessors.ts +0 -448
  190. package/src/packlets/file-tree/index.ts +0 -32
  191. package/src/packlets/file-tree/localStorageTreeAccessors.ts +0 -430
  192. package/src/packlets/helpers/fileTreeHelpers.ts +0 -107
  193. package/src/packlets/helpers/index.ts +0 -28
  194. package/src/packlets/url-utils/index.ts +0 -28
  195. package/src/packlets/url-utils/urlParams.ts +0 -245
  196. package/src/test/mocks/idb-keyval.ts +0 -5
  197. package/src/test/setupTests.ts +0 -87
  198. package/src/test/unit/browserHashProvider.test.ts +0 -155
  199. package/src/test/unit/browserHashProvider.test.ts.bak +0 -376
  200. package/src/test/unit/directoryHandleStore.test.ts +0 -251
  201. package/src/test/unit/fileApiTreeAccessors.test.ts +0 -1387
  202. package/src/test/unit/fileApiTypes.test.ts +0 -587
  203. package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +0 -885
  204. package/src/test/unit/fileTreeHelpers.test.ts +0 -694
  205. package/src/test/unit/httpTreeAccessors.test.ts +0 -1571
  206. package/src/test/unit/localStorageTreeAccessors.test.ts +0 -1014
  207. package/src/test/unit/urlParams.test.ts +0 -464
  208. package/src/test/utils/fileSystemAccessMocks.ts +0 -353
  209. package/src/test/utils/testHelpers.ts +0 -155
  210. package/temp/build/typescript/ts_8nwakTlr.json +0 -1
  211. package/temp/coverage/base.css +0 -224
  212. package/temp/coverage/block-navigation.js +0 -87
  213. package/temp/coverage/crypto/browserHashProvider.ts.html +0 -304
  214. package/temp/coverage/crypto/index.html +0 -116
  215. package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +0 -1018
  216. package/temp/coverage/crypto-utils/browserHashProvider.ts.html +0 -304
  217. package/temp/coverage/crypto-utils/index.html +0 -131
  218. package/temp/coverage/favicon.png +0 -0
  219. package/temp/coverage/file-tree/directoryHandleStore.ts.html +0 -493
  220. package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +0 -1669
  221. package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
  222. package/temp/coverage/file-tree/httpTreeAccessors.ts.html +0 -1429
  223. package/temp/coverage/file-tree/index.html +0 -176
  224. package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +0 -1375
  225. package/temp/coverage/helpers/fileTreeHelpers.ts.html +0 -406
  226. package/temp/coverage/helpers/index.html +0 -116
  227. package/temp/coverage/index.html +0 -161
  228. package/temp/coverage/lcov-report/base.css +0 -224
  229. package/temp/coverage/lcov-report/block-navigation.js +0 -87
  230. package/temp/coverage/lcov-report/crypto/browserHashProvider.ts.html +0 -304
  231. package/temp/coverage/lcov-report/crypto/index.html +0 -116
  232. package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +0 -1018
  233. package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +0 -304
  234. package/temp/coverage/lcov-report/crypto-utils/index.html +0 -131
  235. package/temp/coverage/lcov-report/favicon.png +0 -0
  236. package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +0 -493
  237. package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +0 -1669
  238. package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
  239. package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +0 -1429
  240. package/temp/coverage/lcov-report/file-tree/index.html +0 -176
  241. package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +0 -1375
  242. package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +0 -406
  243. package/temp/coverage/lcov-report/helpers/index.html +0 -116
  244. package/temp/coverage/lcov-report/index.html +0 -161
  245. package/temp/coverage/lcov-report/prettify.css +0 -1
  246. package/temp/coverage/lcov-report/prettify.js +0 -2
  247. package/temp/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  248. package/temp/coverage/lcov-report/sorter.js +0 -210
  249. package/temp/coverage/lcov-report/url-utils/index.html +0 -116
  250. package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +0 -820
  251. package/temp/coverage/lcov.info +0 -3597
  252. package/temp/coverage/prettify.css +0 -1
  253. package/temp/coverage/prettify.js +0 -2
  254. package/temp/coverage/sort-arrow-sprite.png +0 -0
  255. package/temp/coverage/sorter.js +0 -210
  256. package/temp/coverage/url-utils/index.html +0 -116
  257. package/temp/coverage/url-utils/urlParams.ts.html +0 -820
  258. package/temp/test/jest/haste-map-b931e4e63102f86c5bd4949f7dced44f-9d713eb41149188b4e5c0ae3d86d0a57-2ad8e16b24e391b8cdbe50b55c137169 +0 -0
  259. package/temp/test/jest/jest-transform-cache-b931e4e63102f86c5bd4949f7dced44f-79ef2876fae7ca75eedb2aa53dc48338/b5/package_b5f57afc9ec2c011239b1608ee5bdfa5 +0 -53
  260. package/temp/test/jest/perf-cache-b931e4e63102f86c5bd4949f7dced44f-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
  261. package/temp/ts-web-extras.api.json +0 -8850
  262. package/temp/ts-web-extras.api.md +0 -433
  263. package/tsconfig.json +0 -7
@@ -1 +0,0 @@
1
- {"version":3,"file":"testHelpers.js","sourceRoot":"","sources":["../../../src/test/utils/testHelpers.ts"],"names":[],"mappings":"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","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Test utilities for mocking browser APIs\n */\n\n/**\n * Mock file data structure\n */\nexport interface MockFileData {\n name: string;\n content: string;\n type?: string;\n lastModified?: number;\n webkitRelativePath?: string;\n}\n\n/**\n * Create a mock File object with all necessary properties and methods\n */\nexport function createMockFile(data: MockFileData): File {\n const blob = new Blob([data.content], { type: data.type || 'text/plain' });\n const file = new File([blob], data.name, {\n type: data.type || 'text/plain',\n lastModified: data.lastModified || Date.now()\n });\n\n // Add webkitRelativePath if provided (for directory uploads)\n if (data.webkitRelativePath) {\n Object.defineProperty(file, 'webkitRelativePath', {\n value: data.webkitRelativePath,\n writable: false,\n configurable: true\n });\n }\n\n // Ensure text() method works properly\n if (!file.text || typeof file.text !== 'function') {\n Object.defineProperty(file, 'text', {\n value: () => Promise.resolve(data.content),\n writable: false,\n configurable: true\n });\n }\n\n return file;\n}\n\n/**\n * Create a mock FileList using DataTransfer API\n * This is the most reliable method for creating FileList objects in tests\n */\nexport function createMockFileList(files: MockFileData[]): FileList {\n // Use DataTransfer to create a proper FileList\n const dt = new DataTransfer();\n\n files.forEach((fileData) => {\n const file = createMockFile(fileData);\n dt.items.add(file);\n });\n\n return dt.files;\n}\n\n/**\n * Create a mock FileList for directory upload simulation\n * Includes webkitRelativePath for each file\n */\nexport function createMockDirectoryFileList(\n directoryStructure: Array<{ path: string; content: string; type?: string }>\n): FileList {\n const files = directoryStructure.map((item) => ({\n name: item.path.split('/').pop() || '',\n content: item.content,\n type: item.type,\n webkitRelativePath: item.path\n }));\n\n return createMockFileList(files);\n}\n\n/**\n * Helper to create a promise that resolves after a delay\n * Useful for testing async operations\n */\nexport function delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Helper to verify File API text() method works correctly\n * Since we're using Blob/File polyfills, this ensures they have the right methods\n */\nexport async function verifyFileAPI(file: File): Promise<boolean> {\n try {\n // Check if text() method exists and works\n if (typeof file.text !== 'function') {\n throw new Error('File.text() method not available');\n }\n\n const text = await file.text();\n return typeof text === 'string';\n } catch {\n return false;\n }\n}\n\n/**\n * Mock Web Crypto digest result for testing\n * Creates a deterministic hash-like ArrayBuffer\n */\nexport function createMockDigest(input: string, algorithm: string = 'SHA-256'): ArrayBuffer {\n // Create a deterministic \"hash\" based on input for testing\n // This is not a real hash but good enough for testing\n const hashLength = algorithm.includes('256') ? 32 : algorithm.includes('512') ? 64 : 20;\n const buffer = new ArrayBuffer(hashLength);\n const view = new Uint8Array(buffer);\n\n // Fill with deterministic values based on input\n for (let i = 0; i < hashLength; i++) {\n view[i] = (input.charCodeAt(i % input.length) + i) % 256;\n }\n\n return buffer;\n}\n\n/**\n * Convert ArrayBuffer to hex string for comparison in tests\n */\nexport function arrayBufferToHex(buffer: ArrayBuffer): string {\n const view = new Uint8Array(buffer);\n return Array.from(view)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n"]}
File without changes
@@ -1,18 +0,0 @@
1
- (node:7773) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
2
- (Use `node --trace-deprecation ...` to show where the warning was created)
3
- (node:7771) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
4
- (Use `node --trace-deprecation ...` to show where the warning was created)
5
- (node:7776) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
6
- (Use `node --trace-deprecation ...` to show where the warning was created)
7
- (node:7769) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
8
- (Use `node --trace-deprecation ...` to show where the warning was created)
9
- (node:7775) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
10
- (Use `node --trace-deprecation ...` to show where the warning was created)
11
- (node:7774) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
12
- (Use `node --trace-deprecation ...` to show where the warning was created)
13
- (node:7770) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
14
- (Use `node --trace-deprecation ...` to show where the warning was created)
15
- (node:7768) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
16
- (Use `node --trace-deprecation ...` to show where the warning was created)
17
- (node:7772) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
18
- (Use `node --trace-deprecation ...` to show where the warning was created)
@@ -1,75 +0,0 @@
1
- Invoking: heft test --clean
2
- ---- build started ----
3
- [build:clean] Deleted 0 files and 3 folders
4
- [build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.
5
- [build:typescript] Using TypeScript version 5.9.3
6
- [build:api-extractor] Using API Extractor version 7.57.6
7
- [build:api-extractor] Analysis will use the bundled TypeScript version 5.8.2
8
- [build:api-extractor] *** The target project appears to use TypeScript 5.9.3 which is newer than the bundled compiler engine; consider upgrading API Extractor.
9
- ---- build finished (3.999s) ----
10
- ---- test started ----
11
- [test:clean] Deleted 0 files and 1 folder
12
- [test:jest] Using Jest version 29.5.0
13
- [test:jest]
14
- [test:jest] Run start. 9 test suites
15
- [test:jest] START lib/test/unit/fileApiTreeAccessors.test.js
16
- [test:jest] START lib/test/unit/httpTreeAccessors.test.js
17
- [test:jest] START lib/test/unit/localStorageTreeAccessors.test.js
18
- [test:jest] START lib/test/unit/fileSystemAccessTreeAccessors.test.js
19
- [test:jest] START lib/test/unit/fileTreeHelpers.test.js
20
- [test:jest] START lib/test/unit/fileApiTypes.test.js
21
- [test:jest] START lib/test/unit/urlParams.test.js
22
- [test:jest] START lib/test/unit/directoryHandleStore.test.js
23
- [test:jest] START lib/test/unit/browserHashProvider.test.js
24
- (node:7773) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
25
- (Use `node --trace-deprecation ...` to show where the warning was created)
26
- [test:jest] PASS lib/test/unit/fileApiTypes.test.js (duration: 0.930s, 36 passed, 0 failed)
27
- (node:7771) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
28
- (Use `node --trace-deprecation ...` to show where the warning was created)
29
- (node:7776) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
30
- (Use `node --trace-deprecation ...` to show where the warning was created)
31
- (node:7769) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
32
- (Use `node --trace-deprecation ...` to show where the warning was created)
33
- (node:7775) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
34
- (Use `node --trace-deprecation ...` to show where the warning was created)
35
- [test:jest] PASS lib/test/unit/directoryHandleStore.test.js (duration: 0.969s, 19 passed, 0 failed)
36
- (node:7774) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
37
- (Use `node --trace-deprecation ...` to show where the warning was created)
38
- [test:jest] PASS lib/test/unit/urlParams.test.js (duration: 0.927s, 60 passed, 0 failed)
39
- (node:7770) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
40
- (Use `node --trace-deprecation ...` to show where the warning was created)
41
- [test:jest] PASS lib/test/unit/localStorageTreeAccessors.test.js (duration: 0.999s, 44 passed, 0 failed)
42
- (node:7768) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
43
- (Use `node --trace-deprecation ...` to show where the warning was created)
44
- [test:jest] PASS lib/test/unit/fileApiTreeAccessors.test.js (duration: 0.993s, 65 passed, 0 failed)
45
- [test:jest] PASS lib/test/unit/fileSystemAccessTreeAccessors.test.js (duration: 0.997s, 44 passed, 0 failed)
46
- [test:jest] PASS lib/test/unit/browserHashProvider.test.js (duration: 1.035s, 15 passed, 0 failed)
47
- (node:7772) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
48
- (Use `node --trace-deprecation ...` to show where the warning was created)
49
- [test:jest] PASS lib/test/unit/fileTreeHelpers.test.js (duration: 1.036s, 35 passed, 0 failed)
50
- [test:jest] PASS lib/test/unit/httpTreeAccessors.test.js (duration: 1.031s, 57 passed, 0 failed)
51
- [test:jest]
52
- [test:jest] Tests finished:
53
- [test:jest] Successes: 375
54
- [test:jest] Failures: 0
55
- [test:jest] Total: 376
56
- -----------------------------------|---------|----------|---------|---------|-------------------
57
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
58
- -----------------------------------|---------|----------|---------|---------|-------------------
59
- All files | 100 | 99.62 | 100 | 100 |
60
- crypto-utils | 100 | 100 | 100 | 100 |
61
- browserCryptoProvider.ts | 100 | 100 | 100 | 100 |
62
- browserHashProvider.ts | 100 | 100 | 100 | 100 |
63
- file-tree | 100 | 99.57 | 100 | 100 |
64
- directoryHandleStore.ts | 100 | 100 | 100 | 100 |
65
- fileApiTreeAccessors.ts | 100 | 100 | 100 | 100 |
66
- fileSystemAccessTreeAccessors.ts | 100 | 100 | 100 | 100 |
67
- httpTreeAccessors.ts | 100 | 98.41 | 100 | 100 | 339
68
- localStorageTreeAccessors.ts | 100 | 100 | 100 | 100 |
69
- helpers | 100 | 100 | 100 | 100 |
70
- fileTreeHelpers.ts | 100 | 100 | 100 | 100 |
71
- url-utils | 100 | 100 | 100 | 100 |
72
- urlParams.ts | 100 | 100 | 100 | 100 |
73
- -----------------------------------|---------|----------|---------|---------|-------------------
74
- ---- test finished (2.409s) ----
75
- -------------------- Finished (6.412s) --------------------
@@ -1 +0,0 @@
1
- This project does not define the caching behavior of the "test" command, so caching has been disabled.
@@ -1,18 +0,0 @@
1
- (node:99490) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
2
- (Use `node --trace-deprecation ...` to show where the warning was created)
3
- (node:99493) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
4
- (Use `node --trace-deprecation ...` to show where the warning was created)
5
- (node:99494) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
6
- (Use `node --trace-deprecation ...` to show where the warning was created)
7
- (node:99488) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
8
- (Use `node --trace-deprecation ...` to show where the warning was created)
9
- (node:99489) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
10
- (Use `node --trace-deprecation ...` to show where the warning was created)
11
- (node:99492) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
12
- (Use `node --trace-deprecation ...` to show where the warning was created)
13
- (node:99495) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
14
- (Use `node --trace-deprecation ...` to show where the warning was created)
15
- (node:99487) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
16
- (Use `node --trace-deprecation ...` to show where the warning was created)
17
- (node:99491) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
18
- (Use `node --trace-deprecation ...` to show where the warning was created)
@@ -1,75 +0,0 @@
1
- Invoking: heft test --clean
2
- ---- build started ----
3
- [build:clean] Deleted 0 files and 3 folders
4
- [build:typescript] The TypeScript compiler version 5.9.3 is newer than the latest version that was tested with Heft (5.8); it may not work correctly.
5
- [build:typescript] Using TypeScript version 5.9.3
6
- [build:api-extractor] Using API Extractor version 7.57.6
7
- [build:api-extractor] Analysis will use the bundled TypeScript version 5.8.2
8
- [build:api-extractor] *** The target project appears to use TypeScript 5.9.3 which is newer than the bundled compiler engine; consider upgrading API Extractor.
9
- ---- build finished (3.976s) ----
10
- ---- test started ----
11
- [test:clean] Deleted 0 files and 1 folder
12
- [test:jest] Using Jest version 29.5.0
13
- [test:jest]
14
- [test:jest] Run start. 9 test suites
15
- [test:jest] START lib/test/unit/fileApiTreeAccessors.test.js
16
- [test:jest] START lib/test/unit/httpTreeAccessors.test.js
17
- [test:jest] START lib/test/unit/localStorageTreeAccessors.test.js
18
- [test:jest] START lib/test/unit/fileSystemAccessTreeAccessors.test.js
19
- [test:jest] START lib/test/unit/fileTreeHelpers.test.js
20
- [test:jest] START lib/test/unit/fileApiTypes.test.js
21
- [test:jest] START lib/test/unit/urlParams.test.js
22
- [test:jest] START lib/test/unit/directoryHandleStore.test.js
23
- [test:jest] START lib/test/unit/browserHashProvider.test.js
24
- (node:99490) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
25
- (Use `node --trace-deprecation ...` to show where the warning was created)
26
- (node:99493) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
27
- (Use `node --trace-deprecation ...` to show where the warning was created)
28
- [test:jest] PASS lib/test/unit/urlParams.test.js (duration: 0.793s, 60 passed, 0 failed)
29
- [test:jest] PASS lib/test/unit/fileSystemAccessTreeAccessors.test.js (duration: 0.886s, 44 passed, 0 failed)
30
- (node:99494) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
31
- (Use `node --trace-deprecation ...` to show where the warning was created)
32
- [test:jest] PASS lib/test/unit/directoryHandleStore.test.js (duration: 0.868s, 19 passed, 0 failed)
33
- (node:99488) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
34
- (Use `node --trace-deprecation ...` to show where the warning was created)
35
- (node:99489) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
36
- (Use `node --trace-deprecation ...` to show where the warning was created)
37
- [test:jest] PASS lib/test/unit/localStorageTreeAccessors.test.js (duration: 0.949s, 44 passed, 0 failed)
38
- (node:99492) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
39
- (Use `node --trace-deprecation ...` to show where the warning was created)
40
- [test:jest] PASS lib/test/unit/fileApiTypes.test.js (duration: 0.931s, 36 passed, 0 failed)
41
- (node:99495) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
42
- (Use `node --trace-deprecation ...` to show where the warning was created)
43
- (node:99487) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
44
- (Use `node --trace-deprecation ...` to show where the warning was created)
45
- [test:jest] PASS lib/test/unit/fileApiTreeAccessors.test.js (duration: 1.013s, 65 passed, 0 failed)
46
- (node:99491) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
47
- (Use `node --trace-deprecation ...` to show where the warning was created)
48
- [test:jest] PASS lib/test/unit/fileTreeHelpers.test.js (duration: 0.996s, 35 passed, 0 failed)
49
- [test:jest] PASS lib/test/unit/httpTreeAccessors.test.js (duration: 1.015s, 57 passed, 0 failed)
50
- [test:jest] PASS lib/test/unit/browserHashProvider.test.js (duration: 1.021s, 15 passed, 0 failed)
51
- [test:jest]
52
- [test:jest] Tests finished:
53
- [test:jest] Successes: 375
54
- [test:jest] Failures: 0
55
- [test:jest] Total: 376
56
- -----------------------------------|---------|----------|---------|---------|-------------------
57
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
58
- -----------------------------------|---------|----------|---------|---------|-------------------
59
- All files | 100 | 99.62 | 100 | 100 |
60
- crypto-utils | 100 | 100 | 100 | 100 |
61
- browserCryptoProvider.ts | 100 | 100 | 100 | 100 |
62
- browserHashProvider.ts | 100 | 100 | 100 | 100 |
63
- file-tree | 100 | 99.57 | 100 | 100 |
64
- directoryHandleStore.ts | 100 | 100 | 100 | 100 |
65
- fileApiTreeAccessors.ts | 100 | 100 | 100 | 100 |
66
- fileSystemAccessTreeAccessors.ts | 100 | 100 | 100 | 100 |
67
- httpTreeAccessors.ts | 100 | 98.41 | 100 | 100 | 339
68
- localStorageTreeAccessors.ts | 100 | 100 | 100 | 100 |
69
- helpers | 100 | 100 | 100 | 100 |
70
- fileTreeHelpers.ts | 100 | 100 | 100 | 100 |
71
- url-utils | 100 | 100 | 100 | 100 |
72
- urlParams.ts | 100 | 100 | 100 | 100 |
73
- -----------------------------------|---------|----------|---------|---------|-------------------
74
- ---- test finished (2.232s) ----
75
- -------------------- Finished (6.215s) --------------------
@@ -1,24 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Erik Fortune
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in all
12
- * copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
- // Browser entry point - re-exports everything from main index
24
- export * from './index';
package/src/index.ts DELETED
@@ -1,47 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Erik Fortune
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in all
12
- * copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
- /**
24
- * Browser-compatible utilities and FileTree implementations.
25
- *
26
- * This library provides browser-compatible alternatives to Node.js-specific functionality,
27
- * including Web Crypto API-based hashing, File API-based file tree implementations,
28
- * and URL parameter parsing utilities.
29
- * All exports are designed to be tree-shakeable for optimal bundle size.
30
- *
31
- * @packageDocumentation
32
- */
33
-
34
- import * as CryptoUtils from './packlets/crypto-utils';
35
- export { CryptoUtils };
36
-
37
- // Export file tree functionality
38
- export * from './packlets/file-tree';
39
-
40
- // Export helper functions
41
- export * from './packlets/helpers';
42
-
43
- // Export File System Access API types
44
- export * from './packlets/file-api-types';
45
-
46
- // Export URL utilities
47
- export * from './packlets/url-utils';
@@ -1,311 +0,0 @@
1
- // Copyright (c) 2024 Erik Fortune
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in all
11
- // copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- // SOFTWARE.
20
-
21
- /* c8 ignore start - Browser-only implementation cannot be tested in Node.js environment */
22
- import { captureResult, Failure, Result, Success } from '@fgv/ts-utils';
23
- import { CryptoUtils } from '@fgv/ts-extras';
24
-
25
- type ICryptoProvider = CryptoUtils.ICryptoProvider;
26
- type IEncryptionResult = CryptoUtils.IEncryptionResult;
27
- const CryptoConstants = CryptoUtils.Constants;
28
-
29
- /**
30
- * Extracts an `ArrayBuffer` from a Uint8Array, handling the potential SharedArrayBuffer case.
31
- * @param arr - The Uint8Array to extract from
32
- * @returns An `ArrayBuffer` containing a copy of the data.
33
- */
34
- function toArrayBuffer(arr: Uint8Array): ArrayBuffer {
35
- // Create a new ArrayBuffer and copy the data - this handles both ArrayBuffer and SharedArrayBuffer
36
- const buffer = new ArrayBuffer(arr.byteLength);
37
- new Uint8Array(buffer).set(arr);
38
- return buffer;
39
- }
40
-
41
- /**
42
- * Browser implementation of `ICryptoProvider` using the Web Crypto API.
43
- * Uses AES-256-GCM for authenticated encryption.
44
- *
45
- * Note: This provider requires a browser environment with Web Crypto API support.
46
- * In Node.js 15+, Web Crypto is available via globalThis.crypto or require('crypto').webcrypto.
47
- *
48
- * @public
49
- */
50
- export class BrowserCryptoProvider implements ICryptoProvider {
51
- private readonly _crypto: Crypto;
52
-
53
- /**
54
- * Creates a new {@link CryptoUtils.BrowserCryptoProvider | BrowserCryptoProvider}.
55
- * @param cryptoApi - Optional Crypto instance (defaults to globalThis.crypto)
56
- */
57
- public constructor(cryptoApi?: Crypto) {
58
- if (cryptoApi) {
59
- this._crypto = cryptoApi;
60
- } else if (typeof globalThis !== 'undefined' && globalThis.crypto) {
61
- this._crypto = globalThis.crypto;
62
- } else if (typeof window !== 'undefined' && window.crypto) {
63
- this._crypto = window.crypto;
64
- } else {
65
- throw new Error('Web Crypto API not available');
66
- }
67
- }
68
-
69
- /**
70
- * Encrypts plaintext using AES-256-GCM.
71
- * @param plaintext - UTF-8 string to encrypt
72
- * @param key - 32-byte encryption key
73
- * @returns `Success` with encryption result, or `Failure` with an error.
74
- */
75
- public async encrypt(plaintext: string, key: Uint8Array): Promise<Result<IEncryptionResult>> {
76
- if (key.length !== CryptoConstants.AES_256_KEY_SIZE) {
77
- return Failure.with(`Key must be ${CryptoConstants.AES_256_KEY_SIZE} bytes, got ${key.length}`);
78
- }
79
-
80
- try {
81
- // Generate random IV
82
- const iv = this._crypto.getRandomValues(new Uint8Array(CryptoConstants.GCM_IV_SIZE));
83
-
84
- // Import the key
85
- const cryptoKey = await this._crypto.subtle.importKey(
86
- 'raw',
87
- toArrayBuffer(key),
88
- { name: 'AES-GCM' },
89
- false,
90
- ['encrypt']
91
- );
92
-
93
- // Encode plaintext to bytes
94
- const encoder = new TextEncoder();
95
- const plaintextBytes = encoder.encode(plaintext);
96
-
97
- // Encrypt (Web Crypto appends auth tag to ciphertext)
98
- const encryptedWithTag = await this._crypto.subtle.encrypt(
99
- {
100
- name: 'AES-GCM',
101
- iv: iv,
102
- tagLength: CryptoConstants.GCM_AUTH_TAG_SIZE * 8 // bits
103
- },
104
- cryptoKey,
105
- plaintextBytes
106
- );
107
-
108
- // Split ciphertext and auth tag (auth tag is last 16 bytes)
109
- const encryptedArray = new Uint8Array(encryptedWithTag);
110
- const encryptedData = encryptedArray.slice(
111
- 0,
112
- encryptedArray.length - CryptoConstants.GCM_AUTH_TAG_SIZE
113
- );
114
- const authTag = encryptedArray.slice(encryptedArray.length - CryptoConstants.GCM_AUTH_TAG_SIZE);
115
- return Success.with({
116
- iv,
117
- authTag,
118
- encryptedData
119
- });
120
- } catch (e) {
121
- const message = e instanceof Error ? e.message : String(e);
122
- return Failure.with(`Encryption failed: ${message}`);
123
- }
124
- }
125
-
126
- /**
127
- * Decrypts ciphertext using AES-256-GCM.
128
- * @param encryptedData - Encrypted bytes
129
- * @param key - 32-byte decryption key
130
- * @param iv - Initialization vector (12 bytes)
131
- * @param authTag - GCM authentication tag (16 bytes)
132
- * @returns `Success` with decrypted UTF-8 string, or `Failure` with an error.
133
- */
134
- public async decrypt(
135
- encryptedData: Uint8Array,
136
- key: Uint8Array,
137
- iv: Uint8Array,
138
- authTag: Uint8Array
139
- ): Promise<Result<string>> {
140
- if (key.length !== CryptoConstants.AES_256_KEY_SIZE) {
141
- return Failure.with(`Key must be ${CryptoConstants.AES_256_KEY_SIZE} bytes, got ${key.length}`);
142
- }
143
- if (iv.length !== CryptoConstants.GCM_IV_SIZE) {
144
- return Failure.with(`IV must be ${CryptoConstants.GCM_IV_SIZE} bytes, got ${iv.length}`);
145
- }
146
- if (authTag.length !== CryptoConstants.GCM_AUTH_TAG_SIZE) {
147
- return Failure.with(
148
- `Auth tag must be ${CryptoConstants.GCM_AUTH_TAG_SIZE} bytes, got ${authTag.length}`
149
- );
150
- }
151
-
152
- try {
153
- // Import the key
154
- const cryptoKey = await this._crypto.subtle.importKey(
155
- 'raw',
156
- toArrayBuffer(key),
157
- { name: 'AES-GCM' },
158
- false,
159
- ['decrypt']
160
- );
161
-
162
- // Web Crypto expects ciphertext + auth tag concatenated
163
- const encryptedWithTag = new Uint8Array(encryptedData.length + authTag.length);
164
- encryptedWithTag.set(encryptedData);
165
- encryptedWithTag.set(authTag, encryptedData.length);
166
-
167
- // Decrypt
168
- const decrypted = await this._crypto.subtle.decrypt(
169
- {
170
- name: 'AES-GCM',
171
- iv: toArrayBuffer(iv),
172
- tagLength: CryptoConstants.GCM_AUTH_TAG_SIZE * 8 // bits
173
- },
174
- cryptoKey,
175
- encryptedWithTag
176
- );
177
-
178
- // Decode to string
179
- const decoder = new TextDecoder();
180
- return Success.with(decoder.decode(decrypted));
181
- } catch (e) {
182
- const message = e instanceof Error ? e.message : String(e);
183
- return Failure.with(`Decryption failed: ${message}`);
184
- }
185
- }
186
-
187
- /**
188
- * Generates a random 32-byte key suitable for AES-256.
189
- * @returns Success with generated key, or Failure with error
190
- */
191
- public async generateKey(): Promise<Result<Uint8Array>> {
192
- try {
193
- return Success.with(this._crypto.getRandomValues(new Uint8Array(CryptoConstants.AES_256_KEY_SIZE)));
194
- } catch (e) {
195
- const message = e instanceof Error ? e.message : String(e);
196
- return Failure.with(`Key generation failed: ${message}`);
197
- }
198
- }
199
-
200
- /**
201
- * Derives a key from a password using PBKDF2.
202
- * @param password - Password string
203
- * @param salt - Salt bytes (should be at least 16 bytes)
204
- * @param iterations - Number of iterations (recommend 100000+)
205
- * @returns Success with derived 32-byte key, or Failure with error
206
- */
207
- public async deriveKey(
208
- password: string,
209
- salt: Uint8Array,
210
- iterations: number
211
- ): Promise<Result<Uint8Array>> {
212
- if (iterations < 1) {
213
- return Failure.with('Iterations must be at least 1');
214
- }
215
- if (salt.length < 8) {
216
- return Failure.with('Salt should be at least 8 bytes');
217
- }
218
-
219
- try {
220
- // Encode password
221
- const encoder = new TextEncoder();
222
- const passwordBytes = encoder.encode(password);
223
-
224
- // Import password as key material
225
- const keyMaterial = await this._crypto.subtle.importKey('raw', passwordBytes, 'PBKDF2', false, [
226
- 'deriveBits'
227
- ]);
228
-
229
- // Derive key bits
230
- const derivedBits = await this._crypto.subtle.deriveBits(
231
- {
232
- name: 'PBKDF2',
233
- salt: toArrayBuffer(salt),
234
- iterations: iterations,
235
- hash: 'SHA-256'
236
- },
237
- keyMaterial,
238
- CryptoConstants.AES_256_KEY_SIZE * 8 // bits
239
- );
240
-
241
- return Success.with(new Uint8Array(derivedBits));
242
- } catch (e) {
243
- const message = e instanceof Error ? e.message : String(e);
244
- return Failure.with(`Key derivation failed: ${message}`);
245
- }
246
- }
247
-
248
- // ============================================================================
249
- // Platform Utility Methods
250
- // ============================================================================
251
-
252
- /**
253
- * Generates cryptographically secure random bytes.
254
- * @param length - Number of bytes to generate
255
- * @returns Success with random bytes, or Failure with error
256
- */
257
- public generateRandomBytes(length: number): Result<Uint8Array> {
258
- if (length < 1) {
259
- return Failure.with('Length must be at least 1');
260
- }
261
- try {
262
- return Success.with(this._crypto.getRandomValues(new Uint8Array(length)));
263
- } catch (e) {
264
- const message = e instanceof Error ? e.message : String(e);
265
- return Failure.with(`Random bytes generation failed: ${message}`);
266
- }
267
- }
268
-
269
- /**
270
- * Encodes binary data to base64 string.
271
- * @param data - Binary data to encode
272
- * @returns Base64-encoded string
273
- */
274
- public toBase64(data: Uint8Array): string {
275
- // Convert Uint8Array to binary string, then to base64
276
- let binary = '';
277
- for (let i = 0; i < data.length; i++) {
278
- binary += String.fromCharCode(data[i]);
279
- }
280
- return btoa(binary);
281
- }
282
-
283
- /**
284
- * Decodes base64 string to binary data.
285
- * @param base64 - Base64-encoded string
286
- * @returns Success with decoded bytes, or Failure if invalid base64
287
- */
288
- public fromBase64(base64: string): Result<Uint8Array> {
289
- try {
290
- const binary = atob(base64);
291
- const bytes = new Uint8Array(binary.length);
292
- for (let i = 0; i < binary.length; i++) {
293
- bytes[i] = binary.charCodeAt(i);
294
- }
295
- return Success.with(bytes);
296
- } catch (e) {
297
- return Failure.with('Invalid base64 string');
298
- }
299
- }
300
- }
301
-
302
- /**
303
- * Creates a {@link CryptoUtils.BrowserCryptoProvider | BrowserCryptoProvider} if Web
304
- * Crypto API is available.
305
- * @returns `Success` with provider, or `Failure` if not available
306
- * @public
307
- */
308
- export function createBrowserCryptoProvider(): Result<BrowserCryptoProvider> {
309
- return captureResult(() => new BrowserCryptoProvider());
310
- }
311
- /* c8 ignore stop */