@fgv/ts-web-extras 5.1.0-19 → 5.1.0-20

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 (393) hide show
  1. package/package.json +10 -10
  2. package/.rush/temp/42a7a953924ae898114e7b6231a2408228d92433.tar.log +0 -243
  3. package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +0 -57
  4. package/.rush/temp/operation/build/all.log +0 -57
  5. package/.rush/temp/operation/build/log-chunks.jsonl +0 -57
  6. package/.rush/temp/operation/build/state.json +0 -3
  7. package/.rush/temp/shrinkwrap-deps.json +0 -692
  8. package/CHANGELOG.md +0 -23
  9. package/config/api-extractor.json +0 -343
  10. package/config/jest.config.json +0 -19
  11. package/config/rig.json +0 -16
  12. package/config/typedoc.json +0 -7
  13. package/dist/test/mocks/idb-keyval.js +0 -6
  14. package/dist/test/mocks/idb-keyval.js.map +0 -1
  15. package/dist/test/setupTests.js +0 -74
  16. package/dist/test/setupTests.js.map +0 -1
  17. package/dist/test/unit/browserCryptoProvider.wrapBytes.test.js +0 -221
  18. package/dist/test/unit/browserCryptoProvider.wrapBytes.test.js.map +0 -1
  19. package/dist/test/unit/browserHashProvider.test.js +0 -140
  20. package/dist/test/unit/browserHashProvider.test.js.map +0 -1
  21. package/dist/test/unit/directoryHandleStore.test.js +0 -190
  22. package/dist/test/unit/directoryHandleStore.test.js.map +0 -1
  23. package/dist/test/unit/fileApiTreeAccessors.test.js +0 -1188
  24. package/dist/test/unit/fileApiTreeAccessors.test.js.map +0 -1
  25. package/dist/test/unit/fileApiTypes.test.js +0 -472
  26. package/dist/test/unit/fileApiTypes.test.js.map +0 -1
  27. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +0 -622
  28. package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
  29. package/dist/test/unit/fileTreeHelpers.test.js +0 -590
  30. package/dist/test/unit/fileTreeHelpers.test.js.map +0 -1
  31. package/dist/test/unit/httpTreeAccessors.test.js +0 -1364
  32. package/dist/test/unit/httpTreeAccessors.test.js.map +0 -1
  33. package/dist/test/unit/localStorageTreeAccessors.test.js +0 -812
  34. package/dist/test/unit/localStorageTreeAccessors.test.js.map +0 -1
  35. package/dist/test/unit/urlParams.test.js +0 -393
  36. package/dist/test/unit/urlParams.test.js.map +0 -1
  37. package/dist/test/utils/fileSystemAccessMocks.js +0 -271
  38. package/dist/test/utils/fileSystemAccessMocks.js.map +0 -1
  39. package/dist/test/utils/testHelpers.js +0 -124
  40. package/dist/test/utils/testHelpers.js.map +0 -1
  41. package/docs/CryptoUtils/README.md +0 -60
  42. package/docs/CryptoUtils/classes/BrowserCryptoProvider.decrypt.md +0 -27
  43. package/docs/CryptoUtils/classes/BrowserCryptoProvider.deriveKey.md +0 -26
  44. package/docs/CryptoUtils/classes/BrowserCryptoProvider.encrypt.md +0 -25
  45. package/docs/CryptoUtils/classes/BrowserCryptoProvider.exportPublicKeyJwk.md +0 -24
  46. package/docs/CryptoUtils/classes/BrowserCryptoProvider.fromBase64.md +0 -24
  47. package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateKey.md +0 -17
  48. package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateKeyPair.md +0 -25
  49. package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateRandomBytes.md +0 -24
  50. package/docs/CryptoUtils/classes/BrowserCryptoProvider.importPublicKeyJwk.md +0 -25
  51. package/docs/CryptoUtils/classes/BrowserCryptoProvider.md +0 -231
  52. package/docs/CryptoUtils/classes/BrowserCryptoProvider.sha256.md +0 -24
  53. package/docs/CryptoUtils/classes/BrowserCryptoProvider.toBase64.md +0 -24
  54. package/docs/CryptoUtils/classes/BrowserCryptoProvider.unwrapBytes.md +0 -27
  55. package/docs/CryptoUtils/classes/BrowserCryptoProvider.wrapBytes.md +0 -28
  56. package/docs/CryptoUtils/classes/BrowserHashProvider.hashParts.md +0 -26
  57. package/docs/CryptoUtils/classes/BrowserHashProvider.hashString.md +0 -25
  58. package/docs/CryptoUtils/classes/BrowserHashProvider.md +0 -81
  59. package/docs/CryptoUtils/functions/createBrowserCryptoProvider.md +0 -12
  60. package/docs/FileTreeHelpers/README.md +0 -85
  61. package/docs/FileTreeHelpers/functions/extractFileListMetadata.md +0 -11
  62. package/docs/FileTreeHelpers/functions/extractFileMetadata.md +0 -11
  63. package/docs/FileTreeHelpers/functions/fromDirectoryUpload.md +0 -12
  64. package/docs/FileTreeHelpers/functions/fromFileList.md +0 -12
  65. package/docs/FileTreeHelpers/functions/getOriginalFile.md +0 -11
  66. package/docs/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +0 -9
  67. package/docs/README.md +0 -524
  68. package/docs/classes/BrowserCryptoProvider.decrypt.md +0 -27
  69. package/docs/classes/BrowserCryptoProvider.deriveKey.md +0 -26
  70. package/docs/classes/BrowserCryptoProvider.encrypt.md +0 -25
  71. package/docs/classes/BrowserCryptoProvider.exportPublicKeyJwk.md +0 -24
  72. package/docs/classes/BrowserCryptoProvider.fromBase64.md +0 -24
  73. package/docs/classes/BrowserCryptoProvider.generateKey.md +0 -17
  74. package/docs/classes/BrowserCryptoProvider.generateKeyPair.md +0 -25
  75. package/docs/classes/BrowserCryptoProvider.generateRandomBytes.md +0 -24
  76. package/docs/classes/BrowserCryptoProvider.importPublicKeyJwk.md +0 -25
  77. package/docs/classes/BrowserCryptoProvider.md +0 -231
  78. package/docs/classes/BrowserCryptoProvider.sha256.md +0 -24
  79. package/docs/classes/BrowserCryptoProvider.toBase64.md +0 -24
  80. package/docs/classes/BrowserCryptoProvider.unwrapBytes.md +0 -27
  81. package/docs/classes/BrowserCryptoProvider.wrapBytes.md +0 -28
  82. package/docs/classes/BrowserHashProvider.hashParts.md +0 -26
  83. package/docs/classes/BrowserHashProvider.hashString.md +0 -25
  84. package/docs/classes/BrowserHashProvider.md +0 -81
  85. package/docs/classes/DirectoryHandleStore.getAll.md +0 -17
  86. package/docs/classes/DirectoryHandleStore.getAllLabels.md +0 -17
  87. package/docs/classes/DirectoryHandleStore.load.md +0 -24
  88. package/docs/classes/DirectoryHandleStore.md +0 -120
  89. package/docs/classes/DirectoryHandleStore.remove.md +0 -24
  90. package/docs/classes/DirectoryHandleStore.save.md +0 -25
  91. package/docs/classes/FileApiTreeAccessors.create.md +0 -25
  92. package/docs/classes/FileApiTreeAccessors.createFromHttp.md +0 -24
  93. package/docs/classes/FileApiTreeAccessors.createFromLocalStorage.md +0 -25
  94. package/docs/classes/FileApiTreeAccessors.createPersistent.md +0 -26
  95. package/docs/classes/FileApiTreeAccessors.createPersistentFromFile.md +0 -27
  96. package/docs/classes/FileApiTreeAccessors.extractFileMetadata.md +0 -24
  97. package/docs/classes/FileApiTreeAccessors.fromDirectoryUpload.md +0 -25
  98. package/docs/classes/FileApiTreeAccessors.fromFileList.md +0 -25
  99. package/docs/classes/FileApiTreeAccessors.getOriginalFile.md +0 -27
  100. package/docs/classes/FileApiTreeAccessors.md +0 -172
  101. package/docs/classes/FileSystemAccessTreeAccessors.deleteFile.md +0 -22
  102. package/docs/classes/FileSystemAccessTreeAccessors.fileIsMutable.md +0 -22
  103. package/docs/classes/FileSystemAccessTreeAccessors.fromDirectoryHandle.md +0 -25
  104. package/docs/classes/FileSystemAccessTreeAccessors.fromFileHandle.md +0 -29
  105. package/docs/classes/FileSystemAccessTreeAccessors.getDirtyPaths.md +0 -15
  106. package/docs/classes/FileSystemAccessTreeAccessors.isDirty.md +0 -15
  107. package/docs/classes/FileSystemAccessTreeAccessors.md +0 -275
  108. package/docs/classes/FileSystemAccessTreeAccessors.saveFileContents.md +0 -23
  109. package/docs/classes/FileSystemAccessTreeAccessors.syncToDisk.md +0 -15
  110. package/docs/classes/HttpTreeAccessors.deleteFile.md +0 -24
  111. package/docs/classes/HttpTreeAccessors.fileIsMutable.md +0 -24
  112. package/docs/classes/HttpTreeAccessors.fromHttp.md +0 -24
  113. package/docs/classes/HttpTreeAccessors.getDirtyPaths.md +0 -17
  114. package/docs/classes/HttpTreeAccessors.isDirty.md +0 -17
  115. package/docs/classes/HttpTreeAccessors.md +0 -261
  116. package/docs/classes/HttpTreeAccessors.saveFileContents.md +0 -25
  117. package/docs/classes/HttpTreeAccessors.syncToDisk.md +0 -22
  118. package/docs/classes/LocalStorageTreeAccessors.deleteFile.md +0 -24
  119. package/docs/classes/LocalStorageTreeAccessors.fileIsMutable.md +0 -24
  120. package/docs/classes/LocalStorageTreeAccessors.fromStorage.md +0 -25
  121. package/docs/classes/LocalStorageTreeAccessors.getDirtyPaths.md +0 -17
  122. package/docs/classes/LocalStorageTreeAccessors.isDirty.md +0 -17
  123. package/docs/classes/LocalStorageTreeAccessors.md +0 -270
  124. package/docs/classes/LocalStorageTreeAccessors.saveFileContents.md +0 -25
  125. package/docs/classes/LocalStorageTreeAccessors.syncToDisk.md +0 -17
  126. package/docs/functions/createBrowserCryptoProvider.md +0 -12
  127. package/docs/functions/exportAsJson.md +0 -12
  128. package/docs/functions/exportUsingFileSystemAPI.md +0 -11
  129. package/docs/functions/extractDirectoryPath.md +0 -13
  130. package/docs/functions/extractFileListMetadata.md +0 -11
  131. package/docs/functions/extractFileMetadata.md +0 -11
  132. package/docs/functions/fromDirectoryUpload.md +0 -12
  133. package/docs/functions/fromFileList.md +0 -12
  134. package/docs/functions/getOriginalFile.md +0 -11
  135. package/docs/functions/isDirectoryHandle.md +0 -11
  136. package/docs/functions/isFileHandle.md +0 -11
  137. package/docs/functions/isFilePath.md +0 -11
  138. package/docs/functions/parseContextFilter.md +0 -12
  139. package/docs/functions/parseQualifierDefaults.md +0 -12
  140. package/docs/functions/parseResourceTypes.md +0 -12
  141. package/docs/functions/parseUrlParameters.md +0 -11
  142. package/docs/functions/safeShowDirectoryPicker.md +0 -11
  143. package/docs/functions/safeShowOpenFilePicker.md +0 -11
  144. package/docs/functions/safeShowSaveFilePicker.md +0 -11
  145. package/docs/functions/supportsFileSystemAccess.md +0 -11
  146. package/docs/interfaces/FilePickerAcceptType.accept.md +0 -9
  147. package/docs/interfaces/FilePickerAcceptType.description.md +0 -9
  148. package/docs/interfaces/FilePickerAcceptType.md +0 -61
  149. package/docs/interfaces/FileSystemCreateWritableOptions.keepExistingData.md +0 -9
  150. package/docs/interfaces/FileSystemCreateWritableOptions.md +0 -44
  151. package/docs/interfaces/FileSystemDirectoryHandle._asyncIterator_.md +0 -13
  152. package/docs/interfaces/FileSystemDirectoryHandle.entries.md +0 -13
  153. package/docs/interfaces/FileSystemDirectoryHandle.getDirectoryHandle.md +0 -21
  154. package/docs/interfaces/FileSystemDirectoryHandle.getFileHandle.md +0 -21
  155. package/docs/interfaces/FileSystemDirectoryHandle.keys.md +0 -13
  156. package/docs/interfaces/FileSystemDirectoryHandle.kind.md +0 -9
  157. package/docs/interfaces/FileSystemDirectoryHandle.md +0 -224
  158. package/docs/interfaces/FileSystemDirectoryHandle.removeEntry.md +0 -21
  159. package/docs/interfaces/FileSystemDirectoryHandle.resolve.md +0 -20
  160. package/docs/interfaces/FileSystemDirectoryHandle.values.md +0 -13
  161. package/docs/interfaces/FileSystemFileHandle.createWritable.md +0 -20
  162. package/docs/interfaces/FileSystemFileHandle.getFile.md +0 -13
  163. package/docs/interfaces/FileSystemFileHandle.kind.md +0 -9
  164. package/docs/interfaces/FileSystemFileHandle.md +0 -146
  165. package/docs/interfaces/FileSystemGetDirectoryOptions.create.md +0 -9
  166. package/docs/interfaces/FileSystemGetDirectoryOptions.md +0 -44
  167. package/docs/interfaces/FileSystemGetFileOptions.create.md +0 -9
  168. package/docs/interfaces/FileSystemGetFileOptions.md +0 -44
  169. package/docs/interfaces/FileSystemHandle.isSameEntry.md +0 -20
  170. package/docs/interfaces/FileSystemHandle.kind.md +0 -9
  171. package/docs/interfaces/FileSystemHandle.md +0 -118
  172. package/docs/interfaces/FileSystemHandle.name.md +0 -9
  173. package/docs/interfaces/FileSystemHandle.queryPermission.md +0 -20
  174. package/docs/interfaces/FileSystemHandle.requestPermission.md +0 -20
  175. package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +0 -44
  176. package/docs/interfaces/FileSystemHandlePermissionDescriptor.mode.md +0 -9
  177. package/docs/interfaces/FileSystemRemoveOptions.md +0 -44
  178. package/docs/interfaces/FileSystemRemoveOptions.recursive.md +0 -9
  179. package/docs/interfaces/FileSystemWritableFileStream.md +0 -142
  180. package/docs/interfaces/FileSystemWritableFileStream.seek.md +0 -20
  181. package/docs/interfaces/FileSystemWritableFileStream.truncate.md +0 -20
  182. package/docs/interfaces/FileSystemWritableFileStream.write.md +0 -20
  183. package/docs/interfaces/IDirectoryHandleTreeInitializer.dirHandles.md +0 -9
  184. package/docs/interfaces/IDirectoryHandleTreeInitializer.md +0 -78
  185. package/docs/interfaces/IDirectoryHandleTreeInitializer.nonRecursive.md +0 -9
  186. package/docs/interfaces/IDirectoryHandleTreeInitializer.prefix.md +0 -9
  187. package/docs/interfaces/IFileHandleTreeInitializer.fileHandles.md +0 -9
  188. package/docs/interfaces/IFileHandleTreeInitializer.md +0 -61
  189. package/docs/interfaces/IFileHandleTreeInitializer.prefix.md +0 -9
  190. package/docs/interfaces/IFileListTreeInitializer.fileList.md +0 -9
  191. package/docs/interfaces/IFileListTreeInitializer.md +0 -44
  192. package/docs/interfaces/IFileMetadata.lastModified.md +0 -9
  193. package/docs/interfaces/IFileMetadata.md +0 -112
  194. package/docs/interfaces/IFileMetadata.name.md +0 -9
  195. package/docs/interfaces/IFileMetadata.path.md +0 -9
  196. package/docs/interfaces/IFileMetadata.size.md +0 -9
  197. package/docs/interfaces/IFileMetadata.type.md +0 -9
  198. package/docs/interfaces/IFileSystemAccessTreeParams.autoSync.md +0 -12
  199. package/docs/interfaces/IFileSystemAccessTreeParams.filePath.md +0 -13
  200. package/docs/interfaces/IFileSystemAccessTreeParams.logger.md +0 -11
  201. package/docs/interfaces/IFileSystemAccessTreeParams.md +0 -148
  202. package/docs/interfaces/IFileSystemAccessTreeParams.requireWritePermission.md +0 -13
  203. package/docs/interfaces/IFsAccessApis.md +0 -62
  204. package/docs/interfaces/IFsAccessApis.showDirectoryPicker.md +0 -20
  205. package/docs/interfaces/IFsAccessApis.showOpenFilePicker.md +0 -20
  206. package/docs/interfaces/IFsAccessApis.showSaveFilePicker.md +0 -20
  207. package/docs/interfaces/IHttpTreeParams.autoSync.md +0 -9
  208. package/docs/interfaces/IHttpTreeParams.baseUrl.md +0 -9
  209. package/docs/interfaces/IHttpTreeParams.fetchImpl.md +0 -9
  210. package/docs/interfaces/IHttpTreeParams.logger.md +0 -9
  211. package/docs/interfaces/IHttpTreeParams.md +0 -182
  212. package/docs/interfaces/IHttpTreeParams.namespace.md +0 -9
  213. package/docs/interfaces/IHttpTreeParams.userId.md +0 -9
  214. package/docs/interfaces/ILocalStorageTreeParams.autoSync.md +0 -12
  215. package/docs/interfaces/ILocalStorageTreeParams.md +0 -131
  216. package/docs/interfaces/ILocalStorageTreeParams.pathToKeyMap.md +0 -13
  217. package/docs/interfaces/ILocalStorageTreeParams.storage.md +0 -12
  218. package/docs/interfaces/IUrlConfigOptions.config.md +0 -11
  219. package/docs/interfaces/IUrlConfigOptions.configStartDir.md +0 -11
  220. package/docs/interfaces/IUrlConfigOptions.contextFilter.md +0 -11
  221. package/docs/interfaces/IUrlConfigOptions.input.md +0 -11
  222. package/docs/interfaces/IUrlConfigOptions.inputStartDir.md +0 -11
  223. package/docs/interfaces/IUrlConfigOptions.interactive.md +0 -11
  224. package/docs/interfaces/IUrlConfigOptions.loadZip.md +0 -11
  225. package/docs/interfaces/IUrlConfigOptions.maxDistance.md +0 -11
  226. package/docs/interfaces/IUrlConfigOptions.md +0 -248
  227. package/docs/interfaces/IUrlConfigOptions.qualifierDefaults.md +0 -11
  228. package/docs/interfaces/IUrlConfigOptions.reduceQualifiers.md +0 -11
  229. package/docs/interfaces/IUrlConfigOptions.resourceTypes.md +0 -11
  230. package/docs/interfaces/IUrlConfigOptions.zipFile.md +0 -11
  231. package/docs/interfaces/IUrlConfigOptions.zipPath.md +0 -11
  232. package/docs/interfaces/ShowDirectoryPickerOptions.id.md +0 -9
  233. package/docs/interfaces/ShowDirectoryPickerOptions.md +0 -78
  234. package/docs/interfaces/ShowDirectoryPickerOptions.mode.md +0 -9
  235. package/docs/interfaces/ShowDirectoryPickerOptions.startIn.md +0 -9
  236. package/docs/interfaces/ShowOpenFilePickerOptions.excludeAcceptAllOption.md +0 -9
  237. package/docs/interfaces/ShowOpenFilePickerOptions.id.md +0 -9
  238. package/docs/interfaces/ShowOpenFilePickerOptions.md +0 -112
  239. package/docs/interfaces/ShowOpenFilePickerOptions.multiple.md +0 -9
  240. package/docs/interfaces/ShowOpenFilePickerOptions.startIn.md +0 -9
  241. package/docs/interfaces/ShowOpenFilePickerOptions.types.md +0 -9
  242. package/docs/interfaces/ShowSaveFilePickerOptions.excludeAcceptAllOption.md +0 -9
  243. package/docs/interfaces/ShowSaveFilePickerOptions.id.md +0 -9
  244. package/docs/interfaces/ShowSaveFilePickerOptions.md +0 -112
  245. package/docs/interfaces/ShowSaveFilePickerOptions.startIn.md +0 -9
  246. package/docs/interfaces/ShowSaveFilePickerOptions.suggestedName.md +0 -9
  247. package/docs/interfaces/ShowSaveFilePickerOptions.types.md +0 -9
  248. package/docs/type-aliases/TreeInitializer.md +0 -11
  249. package/docs/type-aliases/WellKnownDirectory.md +0 -11
  250. package/docs/type-aliases/WindowWithFsAccess.md +0 -11
  251. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +0 -9
  252. package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +0 -9
  253. package/docs/variables/defaultFileApiTreeInitParams.md +0 -9
  254. package/etc/ts-web-extras.api.md +0 -439
  255. package/lib/test/mocks/idb-keyval.d.ts +0 -6
  256. package/lib/test/mocks/idb-keyval.d.ts.map +0 -1
  257. package/lib/test/mocks/idb-keyval.js +0 -9
  258. package/lib/test/mocks/idb-keyval.js.map +0 -1
  259. package/lib/test/setupTests.d.ts +0 -2
  260. package/lib/test/setupTests.d.ts.map +0 -1
  261. package/lib/test/setupTests.js +0 -76
  262. package/lib/test/setupTests.js.map +0 -1
  263. package/lib/test/unit/browserCryptoProvider.wrapBytes.test.d.ts +0 -2
  264. package/lib/test/unit/browserCryptoProvider.wrapBytes.test.d.ts.map +0 -1
  265. package/lib/test/unit/browserCryptoProvider.wrapBytes.test.js +0 -223
  266. package/lib/test/unit/browserCryptoProvider.wrapBytes.test.js.map +0 -1
  267. package/lib/test/unit/browserHashProvider.test.d.ts +0 -2
  268. package/lib/test/unit/browserHashProvider.test.d.ts.map +0 -1
  269. package/lib/test/unit/browserHashProvider.test.js +0 -142
  270. package/lib/test/unit/browserHashProvider.test.js.map +0 -1
  271. package/lib/test/unit/directoryHandleStore.test.d.ts +0 -2
  272. package/lib/test/unit/directoryHandleStore.test.d.ts.map +0 -1
  273. package/lib/test/unit/directoryHandleStore.test.js +0 -192
  274. package/lib/test/unit/directoryHandleStore.test.js.map +0 -1
  275. package/lib/test/unit/fileApiTreeAccessors.test.d.ts +0 -2
  276. package/lib/test/unit/fileApiTreeAccessors.test.d.ts.map +0 -1
  277. package/lib/test/unit/fileApiTreeAccessors.test.js +0 -1190
  278. package/lib/test/unit/fileApiTreeAccessors.test.js.map +0 -1
  279. package/lib/test/unit/fileApiTypes.test.d.ts +0 -2
  280. package/lib/test/unit/fileApiTypes.test.d.ts.map +0 -1
  281. package/lib/test/unit/fileApiTypes.test.js +0 -474
  282. package/lib/test/unit/fileApiTypes.test.js.map +0 -1
  283. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +0 -2
  284. package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +0 -1
  285. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +0 -624
  286. package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
  287. package/lib/test/unit/fileTreeHelpers.test.d.ts +0 -2
  288. package/lib/test/unit/fileTreeHelpers.test.d.ts.map +0 -1
  289. package/lib/test/unit/fileTreeHelpers.test.js +0 -592
  290. package/lib/test/unit/fileTreeHelpers.test.js.map +0 -1
  291. package/lib/test/unit/httpTreeAccessors.test.d.ts +0 -2
  292. package/lib/test/unit/httpTreeAccessors.test.d.ts.map +0 -1
  293. package/lib/test/unit/httpTreeAccessors.test.js +0 -1366
  294. package/lib/test/unit/httpTreeAccessors.test.js.map +0 -1
  295. package/lib/test/unit/localStorageTreeAccessors.test.d.ts +0 -2
  296. package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +0 -1
  297. package/lib/test/unit/localStorageTreeAccessors.test.js +0 -814
  298. package/lib/test/unit/localStorageTreeAccessors.test.js.map +0 -1
  299. package/lib/test/unit/urlParams.test.d.ts +0 -2
  300. package/lib/test/unit/urlParams.test.d.ts.map +0 -1
  301. package/lib/test/unit/urlParams.test.js +0 -395
  302. package/lib/test/unit/urlParams.test.js.map +0 -1
  303. package/lib/test/utils/fileSystemAccessMocks.d.ts +0 -53
  304. package/lib/test/utils/fileSystemAccessMocks.d.ts.map +0 -1
  305. package/lib/test/utils/fileSystemAccessMocks.js +0 -277
  306. package/lib/test/utils/fileSystemAccessMocks.js.map +0 -1
  307. package/lib/test/utils/testHelpers.d.ts +0 -51
  308. package/lib/test/utils/testHelpers.d.ts.map +0 -1
  309. package/lib/test/utils/testHelpers.js +0 -133
  310. package/lib/test/utils/testHelpers.js.map +0 -1
  311. package/rush-logs/ts-web-extras.build.cache.log +0 -3
  312. package/rush-logs/ts-web-extras.build.log +0 -57
  313. package/src/index.browser.ts +0 -24
  314. package/src/index.ts +0 -47
  315. package/src/packlets/crypto-utils/browserCryptoProvider.ts +0 -553
  316. package/src/packlets/crypto-utils/browserHashProvider.ts +0 -73
  317. package/src/packlets/crypto-utils/index.ts +0 -29
  318. package/src/packlets/file-api-types/index.ts +0 -366
  319. package/src/packlets/file-tree/directoryHandleStore.ts +0 -136
  320. package/src/packlets/file-tree/fileApiTreeAccessors.ts +0 -528
  321. package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +0 -519
  322. package/src/packlets/file-tree/httpTreeAccessors.ts +0 -478
  323. package/src/packlets/file-tree/index.ts +0 -32
  324. package/src/packlets/file-tree/localStorageTreeAccessors.ts +0 -430
  325. package/src/packlets/helpers/fileTreeHelpers.ts +0 -107
  326. package/src/packlets/helpers/index.ts +0 -28
  327. package/src/packlets/url-utils/index.ts +0 -28
  328. package/src/packlets/url-utils/urlParams.ts +0 -245
  329. package/src/test/mocks/idb-keyval.ts +0 -5
  330. package/src/test/setupTests.ts +0 -87
  331. package/src/test/unit/browserCryptoProvider.wrapBytes.test.ts +0 -325
  332. package/src/test/unit/browserHashProvider.test.ts +0 -155
  333. package/src/test/unit/browserHashProvider.test.ts.bak +0 -376
  334. package/src/test/unit/directoryHandleStore.test.ts +0 -251
  335. package/src/test/unit/fileApiTreeAccessors.test.ts +0 -1387
  336. package/src/test/unit/fileApiTypes.test.ts +0 -587
  337. package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +0 -885
  338. package/src/test/unit/fileTreeHelpers.test.ts +0 -694
  339. package/src/test/unit/httpTreeAccessors.test.ts +0 -1750
  340. package/src/test/unit/localStorageTreeAccessors.test.ts +0 -1014
  341. package/src/test/unit/urlParams.test.ts +0 -464
  342. package/src/test/utils/fileSystemAccessMocks.ts +0 -353
  343. package/src/test/utils/testHelpers.ts +0 -155
  344. package/temp/build/typescript/ts_8nwakTlr.json +0 -1
  345. package/temp/coverage/base.css +0 -224
  346. package/temp/coverage/block-navigation.js +0 -87
  347. package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +0 -1744
  348. package/temp/coverage/crypto-utils/browserHashProvider.ts.html +0 -304
  349. package/temp/coverage/crypto-utils/index.html +0 -131
  350. package/temp/coverage/favicon.png +0 -0
  351. package/temp/coverage/file-tree/directoryHandleStore.ts.html +0 -493
  352. package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +0 -1669
  353. package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
  354. package/temp/coverage/file-tree/httpTreeAccessors.ts.html +0 -1519
  355. package/temp/coverage/file-tree/index.html +0 -176
  356. package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +0 -1375
  357. package/temp/coverage/helpers/fileTreeHelpers.ts.html +0 -406
  358. package/temp/coverage/helpers/index.html +0 -116
  359. package/temp/coverage/index.html +0 -161
  360. package/temp/coverage/lcov-report/base.css +0 -224
  361. package/temp/coverage/lcov-report/block-navigation.js +0 -87
  362. package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +0 -1744
  363. package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +0 -304
  364. package/temp/coverage/lcov-report/crypto-utils/index.html +0 -131
  365. package/temp/coverage/lcov-report/favicon.png +0 -0
  366. package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +0 -493
  367. package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +0 -1669
  368. package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
  369. package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +0 -1519
  370. package/temp/coverage/lcov-report/file-tree/index.html +0 -176
  371. package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +0 -1375
  372. package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +0 -406
  373. package/temp/coverage/lcov-report/helpers/index.html +0 -116
  374. package/temp/coverage/lcov-report/index.html +0 -161
  375. package/temp/coverage/lcov-report/prettify.css +0 -1
  376. package/temp/coverage/lcov-report/prettify.js +0 -2
  377. package/temp/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  378. package/temp/coverage/lcov-report/sorter.js +0 -210
  379. package/temp/coverage/lcov-report/url-utils/index.html +0 -116
  380. package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +0 -820
  381. package/temp/coverage/lcov.info +0 -3924
  382. package/temp/coverage/prettify.css +0 -1
  383. package/temp/coverage/prettify.js +0 -2
  384. package/temp/coverage/sort-arrow-sprite.png +0 -0
  385. package/temp/coverage/sorter.js +0 -210
  386. package/temp/coverage/url-utils/index.html +0 -116
  387. package/temp/coverage/url-utils/urlParams.ts.html +0 -820
  388. package/temp/test/jest/haste-map-7492f1b44480e0cdd1f220078fb3afd8-c8dd6c3430605adeb2f1cadf4f75e791-8c9336785555d572065b28c111982ba4 +0 -0
  389. package/temp/test/jest/jest-transform-cache-7492f1b44480e0cdd1f220078fb3afd8-79ef2876fae7ca75eedb2aa53dc48338/8a/package_8a7abbb163935a14e582220d11872de3 +0 -53
  390. package/temp/test/jest/perf-cache-7492f1b44480e0cdd1f220078fb3afd8-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
  391. package/temp/ts-web-extras.api.json +0 -9373
  392. package/temp/ts-web-extras.api.md +0 -439
  393. package/tsconfig.json +0 -7
@@ -1,245 +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
- * Configuration options that can be passed via URL parameters
25
- * @public
26
- */
27
- export interface IUrlConfigOptions {
28
- /**
29
- * Input file path
30
- */
31
- input?: string;
32
-
33
- /**
34
- * Configuration name or path
35
- */
36
- config?: string;
37
-
38
- /**
39
- * Context filter token (pipe-separated)
40
- */
41
- contextFilter?: string;
42
-
43
- /**
44
- * Qualifier defaults token (pipe-separated)
45
- */
46
- qualifierDefaults?: string;
47
-
48
- /**
49
- * Resource types filter (comma-separated)
50
- */
51
- resourceTypes?: string;
52
-
53
- /**
54
- * Maximum distance for language matching
55
- */
56
- maxDistance?: number;
57
-
58
- /**
59
- * Whether to reduce qualifiers
60
- */
61
- reduceQualifiers?: boolean;
62
-
63
- /**
64
- * Whether to launch in interactive mode
65
- */
66
- interactive?: boolean;
67
-
68
- /**
69
- * Starting directory for input file picker (derived from input path)
70
- */
71
- inputStartDir?: string;
72
-
73
- /**
74
- * Starting directory for config file picker (derived from config path)
75
- */
76
- configStartDir?: string;
77
-
78
- /**
79
- * Whether to use ZIP loading mode
80
- */
81
- loadZip?: boolean;
82
-
83
- /**
84
- * Path to ZIP file to load (for CLI-generated ZIPs)
85
- */
86
- zipPath?: string;
87
-
88
- /**
89
- * Name of ZIP file to load from Downloads (filename only)
90
- */
91
- zipFile?: string;
92
- }
93
-
94
- /**
95
- * Parses URL parameters and extracts configuration options
96
- * @public
97
- */
98
- export function parseUrlParameters(): IUrlConfigOptions {
99
- const params = new URLSearchParams(window.location.search);
100
-
101
- const options: IUrlConfigOptions = {};
102
-
103
- // Parse string parameters
104
- const input = params.get('input');
105
- if (input) {
106
- options.input = input;
107
- // Set starting directory for input file picker
108
- if (isFilePath(input)) {
109
- options.inputStartDir = extractDirectoryPath(input);
110
- }
111
- }
112
-
113
- const config = params.get('config');
114
- if (config) {
115
- options.config = config;
116
- // Set starting directory for config file picker
117
- if (isFilePath(config)) {
118
- options.configStartDir = extractDirectoryPath(config);
119
- }
120
- }
121
-
122
- const contextFilter = params.get('contextFilter');
123
- if (contextFilter) options.contextFilter = contextFilter;
124
-
125
- const qualifierDefaults = params.get('qualifierDefaults');
126
- if (qualifierDefaults) options.qualifierDefaults = qualifierDefaults;
127
-
128
- const resourceTypes = params.get('resourceTypes');
129
- if (resourceTypes) options.resourceTypes = resourceTypes;
130
-
131
- // Parse numeric parameters
132
- const maxDistance = params.get('maxDistance');
133
- if (maxDistance) {
134
- const parsed = parseInt(maxDistance, 10);
135
- if (!isNaN(parsed)) options.maxDistance = parsed;
136
- }
137
-
138
- // Parse boolean parameters
139
- const reduceQualifiers = params.get('reduceQualifiers');
140
- if (reduceQualifiers === 'true') options.reduceQualifiers = true;
141
-
142
- const interactive = params.get('interactive');
143
- if (interactive === 'true') options.interactive = true;
144
-
145
- // Parse ZIP loading parameters
146
- const loadZip = params.get('loadZip');
147
- if (loadZip === 'true') options.loadZip = true;
148
-
149
- const zipPath = params.get('zipPath');
150
- if (zipPath) options.zipPath = zipPath;
151
-
152
- const zipFile = params.get('zipFile');
153
- if (zipFile) options.zipFile = zipFile;
154
-
155
- return options;
156
- }
157
-
158
- /**
159
- * Converts context filter token to context object
160
- * Example: "language=en-US|territory=US" -\> \{ language: "en-US", territory: "US" \}
161
- * @public
162
- */
163
- export function parseContextFilter(contextFilter: string): Record<string, string> {
164
- const context: Record<string, string> = {};
165
-
166
- const tokens = contextFilter.split('|');
167
- for (const token of tokens) {
168
- const [key, value] = token.split('=');
169
- if (key && value) {
170
- context[key.trim()] = value.trim();
171
- }
172
- }
173
-
174
- return context;
175
- }
176
-
177
- /**
178
- * Converts qualifier defaults token to structured format
179
- * Example: "language=en-US,en-CA|territory=US" -\> \{ language: ["en-US", "en-CA"], territory: ["US"] \}
180
- * @public
181
- */
182
- export function parseQualifierDefaults(qualifierDefaults: string): Record<string, string[]> {
183
- const defaults: Record<string, string[]> = {};
184
-
185
- const tokens = qualifierDefaults.split('|');
186
- for (const token of tokens) {
187
- const [key, values] = token.split('=');
188
- if (key && values) {
189
- defaults[key.trim()] = values.split(',').map((v) => v.trim());
190
- }
191
- }
192
-
193
- return defaults;
194
- }
195
-
196
- /**
197
- * Converts resource types string to array
198
- * Example: "json,string" -\> ["json", "string"]
199
- * @public
200
- */
201
- export function parseResourceTypes(resourceTypes: string): string[] {
202
- return resourceTypes
203
- .split(',')
204
- .map((t) => t.trim())
205
- .filter((t) => t.length > 0);
206
- }
207
-
208
- /**
209
- * Extracts the directory path from a file or directory path
210
- * If the path appears to be a directory (no extension), returns it as-is
211
- * If the path appears to be a file, returns the parent directory
212
- * @public
213
- */
214
- export function extractDirectoryPath(path: string): string {
215
- if (!path) return '';
216
-
217
- // Normalize path separators
218
- const normalizedPath = path.replace(/\\/g, '/');
219
-
220
- // Check if it looks like a file (has an extension)
221
- const parts = normalizedPath.split('/');
222
- const lastPart = parts[parts.length - 1];
223
-
224
- // If the last part has an extension, treat as file and return directory
225
- if (lastPart.includes('.') && !lastPart.startsWith('.')) {
226
- return parts.slice(0, -1).join('/') || '/';
227
- }
228
-
229
- // Otherwise, treat as directory
230
- return normalizedPath;
231
- }
232
-
233
- /**
234
- * Determines if a path appears to be a file (has extension) or directory
235
- * @public
236
- */
237
- export function isFilePath(path: string): boolean {
238
- if (!path) return false;
239
-
240
- const parts = path.split('/');
241
- const lastPart = parts[parts.length - 1];
242
-
243
- // Has extension and doesn't start with dot (hidden files)
244
- return lastPart.includes('.') && !lastPart.startsWith('.');
245
- }
@@ -1,5 +0,0 @@
1
- export const createStore = jest.fn(() => ({}));
2
- export const get = jest.fn();
3
- export const set = jest.fn();
4
- export const del = jest.fn();
5
- export const keys = jest.fn();
@@ -1,87 +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
- import { webcrypto } from 'crypto';
24
- import { TextEncoder, TextDecoder } from 'util';
25
-
26
- // Setup Web Crypto API using Node.js webcrypto
27
- Object.defineProperty(global, 'crypto', {
28
- value: webcrypto,
29
- writable: true,
30
- configurable: true
31
- });
32
-
33
- // Setup TextEncoder/TextDecoder for Node environment
34
- Object.defineProperty(global, 'TextEncoder', {
35
- value: TextEncoder,
36
- writable: true,
37
- configurable: true
38
- });
39
-
40
- Object.defineProperty(global, 'TextDecoder', {
41
- value: TextDecoder,
42
- writable: true,
43
- configurable: true
44
- });
45
-
46
- // Mock DataTransfer for File API testing
47
- class MockDataTransfer {
48
- items: { add: (file: File) => void };
49
- files: FileList;
50
-
51
- constructor() {
52
- const fileArray: File[] = [];
53
-
54
- this.items = {
55
- add: (file: File) => {
56
- fileArray.push(file);
57
- this.files = createFileList(fileArray);
58
- }
59
- };
60
-
61
- this.files = createFileList([]);
62
- }
63
- }
64
-
65
- function createFileList(files: File[]): FileList {
66
- const fileList = {
67
- length: files.length,
68
- item: (index: number) => files[index] || null,
69
- [Symbol.iterator]: function* () {
70
- for (const file of files) {
71
- yield file;
72
- }
73
- }
74
- };
75
-
76
- for (let i = 0; i < files.length; i++) {
77
- (fileList as unknown as Record<number, File>)[i] = files[i];
78
- }
79
-
80
- return fileList as unknown as FileList;
81
- }
82
-
83
- Object.defineProperty(global, 'DataTransfer', {
84
- value: MockDataTransfer,
85
- writable: true,
86
- configurable: true
87
- });
@@ -1,325 +0,0 @@
1
- /*
2
- * Copyright (c) 2026 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
- import '@fgv/ts-utils-jest';
24
-
25
- import { CryptoUtils } from '@fgv/ts-extras';
26
- import { BrowserCryptoProvider } from '../../packlets/crypto-utils';
27
-
28
- const provider = new BrowserCryptoProvider();
29
- const subtle = globalThis.crypto.subtle;
30
-
31
- async function generateEcdhPair(curve: 'P-256' | 'P-384' = 'P-256'): Promise<CryptoKeyPair> {
32
- return (await subtle.generateKey({ name: 'ECDH', namedCurve: curve }, true, [
33
- 'deriveKey',
34
- 'deriveBits'
35
- ])) as CryptoKeyPair;
36
- }
37
-
38
- async function generateEcdsaPair(): Promise<CryptoKeyPair> {
39
- return (await subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, [
40
- 'sign',
41
- 'verify'
42
- ])) as CryptoKeyPair;
43
- }
44
-
45
- describe('BrowserCryptoProvider — wrapBytes/unwrapBytes', () => {
46
- const defaultOptions: CryptoUtils.IWrapBytesOptions = {
47
- salt: new TextEncoder().encode('test-salt'),
48
- info: new TextEncoder().encode('test-info')
49
- };
50
-
51
- describe('round-trip', () => {
52
- test.each<[string, Uint8Array]>([
53
- ['32-byte plaintext (AES-256 key shape)', globalThis.crypto.getRandomValues(new Uint8Array(32))],
54
- ['1-byte plaintext', new Uint8Array([0x42])],
55
- ['1KB plaintext', globalThis.crypto.getRandomValues(new Uint8Array(1024))],
56
- ['empty plaintext', new Uint8Array(0)],
57
- ['high-bit-set bytes', new Uint8Array(64).fill(0xff)]
58
- ])('round-trips %s', async (__label, plaintext) => {
59
- const pair = await generateEcdhPair();
60
- const wrapped = (await provider.wrapBytes(plaintext, pair.publicKey, defaultOptions)).orThrow();
61
- expect(wrapped.ephemeralPublicKey.kty).toBe('EC');
62
- expect(wrapped.ephemeralPublicKey.crv).toBe('P-256');
63
- const recovered = (await provider.unwrapBytes(wrapped, pair.privateKey, defaultOptions)).orThrow();
64
- expect(new Uint8Array(recovered)).toEqual(plaintext);
65
- });
66
- });
67
-
68
- describe('determinism / freshness', () => {
69
- test('two wraps of identical inputs produce different ephemeral keys and ciphertexts', async () => {
70
- const pair = await generateEcdhPair();
71
- const plaintext = new TextEncoder().encode('same payload');
72
- const w1 = (await provider.wrapBytes(plaintext, pair.publicKey, defaultOptions)).orThrow();
73
- const w2 = (await provider.wrapBytes(plaintext, pair.publicKey, defaultOptions)).orThrow();
74
- expect(w1.ephemeralPublicKey).not.toEqual(w2.ephemeralPublicKey);
75
- expect(w1.ciphertext).not.toEqual(w2.ciphertext);
76
- expect(w1.nonce).not.toEqual(w2.nonce);
77
- });
78
- });
79
-
80
- describe('tampering', () => {
81
- test('flipping a bit in the nonce fails GCM authentication', async () => {
82
- const pair = await generateEcdhPair();
83
- const wrapped = (
84
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
85
- ).orThrow();
86
- const nonce = provider.fromBase64(wrapped.nonce).orThrow();
87
- nonce[0] ^= 0xff;
88
- const tampered: CryptoUtils.IWrappedBytes = { ...wrapped, nonce: provider.toBase64(nonce) };
89
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
90
- /unwrapBytes failed/i
91
- );
92
- });
93
-
94
- test('flipping a bit in the ciphertext fails GCM authentication', async () => {
95
- const pair = await generateEcdhPair();
96
- const wrapped = (
97
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
98
- ).orThrow();
99
- const ct = provider.fromBase64(wrapped.ciphertext).orThrow();
100
- ct[0] ^= 0x01;
101
- const tampered: CryptoUtils.IWrappedBytes = { ...wrapped, ciphertext: provider.toBase64(ct) };
102
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
103
- /unwrapBytes failed/i
104
- );
105
- });
106
-
107
- test('truncating ciphertext by one byte fails GCM authentication (still ≥ 16 bytes)', async () => {
108
- const pair = await generateEcdhPair();
109
- // 16-byte plaintext → 32-byte ciphertext (16 ct + 16 tag); truncate by 1 → 31 bytes ≥ 16
110
- const wrapped = (
111
- await provider.wrapBytes(new Uint8Array(16).fill(0xab), pair.publicKey, defaultOptions)
112
- ).orThrow();
113
- const ct = provider.fromBase64(wrapped.ciphertext).orThrow();
114
- const truncated = ct.slice(0, ct.length - 1);
115
- const tampered: CryptoUtils.IWrappedBytes = { ...wrapped, ciphertext: provider.toBase64(truncated) };
116
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
117
- /unwrapBytes failed/i
118
- );
119
- });
120
-
121
- test('substituting a different ephemeral public key fails authentication', async () => {
122
- const pair = await generateEcdhPair();
123
- const wrapped = (
124
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
125
- ).orThrow();
126
- const other = (
127
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
128
- ).orThrow();
129
- const tampered: CryptoUtils.IWrappedBytes = {
130
- ...wrapped,
131
- ephemeralPublicKey: other.ephemeralPublicKey
132
- };
133
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
134
- /unwrapBytes failed/i
135
- );
136
- });
137
- });
138
-
139
- describe('wrong-key / wrong-options', () => {
140
- test('unwrap with a different recipient private key fails', async () => {
141
- const pair = await generateEcdhPair();
142
- const other = await generateEcdhPair();
143
- const wrapped = (
144
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
145
- ).orThrow();
146
- expect(await provider.unwrapBytes(wrapped, other.privateKey, defaultOptions)).toFailWith(
147
- /unwrapBytes failed/i
148
- );
149
- });
150
-
151
- test('unwrap with a different HKDF salt fails authentication', async () => {
152
- const pair = await generateEcdhPair();
153
- const wrapped = (
154
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
155
- ).orThrow();
156
- const wrongSalt: CryptoUtils.IWrapBytesOptions = {
157
- salt: new TextEncoder().encode('different-salt'),
158
- info: defaultOptions.info
159
- };
160
- expect(await provider.unwrapBytes(wrapped, pair.privateKey, wrongSalt)).toFailWith(
161
- /unwrapBytes failed/i
162
- );
163
- });
164
-
165
- test('unwrap with a different HKDF info fails authentication', async () => {
166
- const pair = await generateEcdhPair();
167
- const wrapped = (
168
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
169
- ).orThrow();
170
- const wrongInfo: CryptoUtils.IWrapBytesOptions = {
171
- salt: defaultOptions.salt,
172
- info: new TextEncoder().encode('different-info')
173
- };
174
- expect(await provider.unwrapBytes(wrapped, pair.privateKey, wrongInfo)).toFailWith(
175
- /unwrapBytes failed/i
176
- );
177
- });
178
-
179
- test('empty salt and info round-trip when both sides agree', async () => {
180
- const pair = await generateEcdhPair();
181
- const empty: CryptoUtils.IWrapBytesOptions = { salt: new Uint8Array(0), info: new Uint8Array(0) };
182
- const plaintext = globalThis.crypto.getRandomValues(new Uint8Array(16));
183
- const wrapped = (await provider.wrapBytes(plaintext, pair.publicKey, empty)).orThrow();
184
- const recovered = (await provider.unwrapBytes(wrapped, pair.privateKey, empty)).orThrow();
185
- expect(new Uint8Array(recovered)).toEqual(plaintext);
186
- });
187
- });
188
-
189
- describe('malformed input', () => {
190
- test('malformed ephemeralPublicKey JWK fails', async () => {
191
- const pair = await generateEcdhPair();
192
- const wrapped = (
193
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
194
- ).orThrow();
195
- const bogus: CryptoUtils.IWrappedBytes = {
196
- ...wrapped,
197
- ephemeralPublicKey: { kty: 'EC', crv: 'P-256' } as JsonWebKey
198
- };
199
- expect(await provider.unwrapBytes(bogus, pair.privateKey, defaultOptions)).toFailWith(
200
- /unwrapBytes failed/i
201
- );
202
- });
203
-
204
- test('ephemeralPublicKey on the wrong curve (P-384) fails', async () => {
205
- const pair = await generateEcdhPair();
206
- const wrongCurve = await generateEcdhPair('P-384');
207
- const wrongJwk = await subtle.exportKey('jwk', wrongCurve.publicKey);
208
- const wrapped = (
209
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
210
- ).orThrow();
211
- const tampered: CryptoUtils.IWrappedBytes = { ...wrapped, ephemeralPublicKey: wrongJwk };
212
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
213
- /unwrapBytes failed/i
214
- );
215
- });
216
-
217
- test('non-base64 nonce fails with a clean error', async () => {
218
- const pair = await generateEcdhPair();
219
- const wrapped = (
220
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
221
- ).orThrow();
222
- const tampered: CryptoUtils.IWrappedBytes = { ...wrapped, nonce: 'not!base64!' };
223
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
224
- /unwrapBytes failed: nonce/i
225
- );
226
- });
227
-
228
- test('non-base64 ciphertext fails with a clean error', async () => {
229
- const pair = await generateEcdhPair();
230
- const wrapped = (
231
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
232
- ).orThrow();
233
- const tampered: CryptoUtils.IWrappedBytes = { ...wrapped, ciphertext: 'not!base64!' };
234
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
235
- /unwrapBytes failed: ciphertext/i
236
- );
237
- });
238
-
239
- test('wrong-length nonce (after base64 decode) fails before reaching AES-GCM', async () => {
240
- const pair = await generateEcdhPair();
241
- const wrapped = (
242
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
243
- ).orThrow();
244
- const shortNonce = new Uint8Array(8);
245
- const tampered: CryptoUtils.IWrappedBytes = { ...wrapped, nonce: provider.toBase64(shortNonce) };
246
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
247
- /unwrapBytes failed: nonce must be 12 bytes \(got 8\)/i
248
- );
249
- });
250
-
251
- test('ciphertext shorter than the GCM auth tag fails before reaching AES-GCM', async () => {
252
- const pair = await generateEcdhPair();
253
- const wrapped = (
254
- await provider.wrapBytes(new TextEncoder().encode('payload'), pair.publicKey, defaultOptions)
255
- ).orThrow();
256
- const shortCt = new Uint8Array(8);
257
- const tampered: CryptoUtils.IWrappedBytes = { ...wrapped, ciphertext: provider.toBase64(shortCt) };
258
- expect(await provider.unwrapBytes(tampered, pair.privateKey, defaultOptions)).toFailWith(
259
- /unwrapBytes failed: ciphertext must be at least 16 bytes \(got 8\)/i
260
- );
261
- });
262
- });
263
-
264
- describe('algorithm / type mismatch on recipient key', () => {
265
- test('wrap fails when recipient public key is RSA-OAEP, not ECDH', async () => {
266
- const rsa = (await subtle.generateKey(
267
- {
268
- name: 'RSA-OAEP',
269
- modulusLength: 2048,
270
- publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
271
- hash: 'SHA-256'
272
- },
273
- true,
274
- ['encrypt', 'decrypt']
275
- )) as CryptoKeyPair;
276
- const result = await provider.wrapBytes(new Uint8Array([1, 2, 3]), rsa.publicKey, defaultOptions);
277
- expect(result).toFailWith(/wrapBytes failed: recipient public key must be ECDH P-256.*RSA-OAEP/i);
278
- });
279
-
280
- test('wrap fails when recipient public key is ECDSA P-256, not ECDH', async () => {
281
- const ecdsa = await generateEcdsaPair();
282
- const result = await provider.wrapBytes(new Uint8Array([1, 2, 3]), ecdsa.publicKey, defaultOptions);
283
- expect(result).toFailWith(/wrapBytes failed: recipient public key must be ECDH P-256.*ECDSA/i);
284
- });
285
-
286
- test('wrap fails when recipient public key is ECDH P-384, not P-256', async () => {
287
- const wrongCurve = await generateEcdhPair('P-384');
288
- const result = await provider.wrapBytes(
289
- new Uint8Array([1, 2, 3]),
290
- wrongCurve.publicKey,
291
- defaultOptions
292
- );
293
- expect(result).toFailWith(/wrapBytes failed: recipient public key must be ECDH P-256.*P-384/i);
294
- });
295
-
296
- test('unwrap fails when recipient private key is ECDH P-384, not P-256', async () => {
297
- const pair = await generateEcdhPair();
298
- const wrapped = (
299
- await provider.wrapBytes(new Uint8Array([1, 2, 3]), pair.publicKey, defaultOptions)
300
- ).orThrow();
301
- const wrongCurve = await generateEcdhPair('P-384');
302
- const result = await provider.unwrapBytes(wrapped, wrongCurve.privateKey, defaultOptions);
303
- expect(result).toFailWith(/unwrapBytes failed: recipient private key must be ECDH P-256.*P-384/i);
304
- });
305
-
306
- test('wrap fails when recipient is an ECDH private key (not public)', async () => {
307
- const pair = await generateEcdhPair();
308
- const result = await provider.wrapBytes(new Uint8Array([1, 2, 3]), pair.privateKey, defaultOptions);
309
- expect(result).toFailWith(
310
- /wrapBytes failed: recipient public key must be a public CryptoKey \(got 'private'\)/i
311
- );
312
- });
313
-
314
- test('unwrap fails when recipient is an ECDH public key (not private)', async () => {
315
- const pair = await generateEcdhPair();
316
- const wrapped = (
317
- await provider.wrapBytes(new Uint8Array([1, 2, 3]), pair.publicKey, defaultOptions)
318
- ).orThrow();
319
- const result = await provider.unwrapBytes(wrapped, pair.publicKey, defaultOptions);
320
- expect(result).toFailWith(
321
- /unwrapBytes failed: recipient private key must be a private CryptoKey \(got 'public'\)/i
322
- );
323
- });
324
- });
325
- });