@fgv/ts-web-extras 5.0.2 → 5.1.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +58 -25
- package/.rush/temp/chunked-rush-logs/ts-web-extras.test.chunks.jsonl +70 -0
- package/.rush/temp/operation/build/all.log +58 -25
- package/.rush/temp/operation/build/error.log +18 -0
- package/.rush/temp/operation/build/log-chunks.jsonl +58 -25
- package/.rush/temp/operation/build/state.json +1 -1
- package/.rush/temp/operation/test/all.log +70 -0
- package/.rush/temp/operation/test/error.log +16 -0
- package/.rush/temp/operation/test/log-chunks.jsonl +70 -0
- package/.rush/temp/operation/test/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +175 -163
- package/config/jest.config.json +4 -1
- package/config/typedoc.json +6 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/packlets/crypto-utils/browserCryptoProvider.js +254 -0
- package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -0
- package/dist/packlets/crypto-utils/browserHashProvider.js.map +1 -0
- package/dist/packlets/{crypto → crypto-utils}/index.js +1 -0
- package/dist/packlets/crypto-utils/index.js.map +1 -0
- package/dist/packlets/file-api-types/index.js +27 -3
- package/dist/packlets/file-api-types/index.js.map +1 -1
- package/dist/packlets/file-tree/directoryHandleStore.js +124 -0
- package/dist/packlets/file-tree/directoryHandleStore.js.map +1 -0
- package/dist/packlets/file-tree/fileApiTreeAccessors.js +91 -0
- package/dist/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
- package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js +414 -0
- package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -0
- package/dist/packlets/file-tree/httpTreeAccessors.js +279 -0
- package/dist/packlets/file-tree/httpTreeAccessors.js.map +1 -0
- package/dist/packlets/file-tree/index.js +4 -0
- package/dist/packlets/file-tree/index.js.map +1 -1
- package/dist/packlets/file-tree/localStorageTreeAccessors.js +359 -0
- package/dist/packlets/file-tree/localStorageTreeAccessors.js.map +1 -0
- package/dist/test/mocks/idb-keyval.js +6 -0
- package/dist/test/mocks/idb-keyval.js.map +1 -0
- package/dist/test/unit/browserHashProvider.test.js +1 -1
- package/dist/test/unit/browserHashProvider.test.js.map +1 -1
- package/dist/test/unit/directoryHandleStore.test.js +190 -0
- package/dist/test/unit/directoryHandleStore.test.js.map +1 -0
- package/dist/test/unit/fileApiTreeAccessors.test.js +51 -0
- package/dist/test/unit/fileApiTreeAccessors.test.js.map +1 -1
- package/dist/test/unit/fileApiTypes.test.js +30 -0
- package/dist/test/unit/fileApiTypes.test.js.map +1 -1
- package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +622 -0
- package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +1 -0
- package/dist/test/unit/httpTreeAccessors.test.js +1000 -0
- package/dist/test/unit/httpTreeAccessors.test.js.map +1 -0
- package/dist/test/unit/localStorageTreeAccessors.test.js +812 -0
- package/dist/test/unit/localStorageTreeAccessors.test.js.map +1 -0
- package/dist/test/utils/fileSystemAccessMocks.js +271 -0
- package/dist/test/utils/fileSystemAccessMocks.js.map +1 -0
- package/dist/ts-web-extras.d.ts +584 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/docs/@fgv/namespaces/CryptoUtils/README.md +18 -0
- package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserCryptoProvider.md +203 -0
- package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserHashProvider.md +63 -0
- package/docs/@fgv/namespaces/CryptoUtils/functions/createBrowserCryptoProvider.md +18 -0
- package/docs/@fgv/namespaces/FileTreeHelpers/README.md +19 -0
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileListMetadata.md +23 -0
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileMetadata.md +23 -0
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromDirectoryUpload.md +33 -0
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromFileList.md +33 -0
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/getOriginalFile.md +25 -0
- package/docs/@fgv/namespaces/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +11 -0
- package/docs/README.md +78 -0
- package/docs/classes/DirectoryHandleStore.md +116 -0
- package/docs/classes/FileApiTreeAccessors.md +286 -0
- package/docs/classes/FileSystemAccessTreeAccessors.md +557 -0
- package/docs/classes/HttpTreeAccessors.md +508 -0
- package/docs/classes/LocalStorageTreeAccessors.md +520 -0
- package/docs/functions/exportAsJson.md +23 -0
- package/docs/functions/exportUsingFileSystemAPI.md +26 -0
- package/docs/functions/extractDirectoryPath.md +23 -0
- package/docs/functions/isDirectoryHandle.md +23 -0
- package/docs/functions/isFileHandle.md +23 -0
- package/docs/functions/isFilePath.md +21 -0
- package/docs/functions/parseContextFilter.md +22 -0
- package/docs/functions/parseQualifierDefaults.md +22 -0
- package/docs/functions/parseResourceTypes.md +22 -0
- package/docs/functions/parseUrlParameters.md +15 -0
- package/docs/functions/safeShowDirectoryPicker.md +24 -0
- package/docs/functions/safeShowOpenFilePicker.md +24 -0
- package/docs/functions/safeShowSaveFilePicker.md +24 -0
- package/docs/functions/supportsFileSystemAccess.md +23 -0
- package/docs/interfaces/FilePickerAcceptType.md +16 -0
- package/docs/interfaces/FileSystemCreateWritableOptions.md +15 -0
- package/docs/interfaces/FileSystemDirectoryHandle.md +187 -0
- package/docs/interfaces/FileSystemFileHandle.md +106 -0
- package/docs/interfaces/FileSystemGetDirectoryOptions.md +15 -0
- package/docs/interfaces/FileSystemGetFileOptions.md +15 -0
- package/docs/interfaces/FileSystemHandle.md +69 -0
- package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +15 -0
- package/docs/interfaces/FileSystemRemoveOptions.md +15 -0
- package/docs/interfaces/FileSystemWritableFileStream.md +127 -0
- package/docs/interfaces/IDirectoryHandleTreeInitializer.md +17 -0
- package/docs/interfaces/IFileHandleTreeInitializer.md +16 -0
- package/docs/interfaces/IFileListTreeInitializer.md +15 -0
- package/docs/interfaces/IFileMetadata.md +19 -0
- package/docs/interfaces/IFileSystemAccessTreeParams.md +30 -0
- package/docs/interfaces/IFsAccessApis.md +57 -0
- package/docs/interfaces/IHttpTreeParams.md +32 -0
- package/docs/interfaces/ILocalStorageTreeParams.md +30 -0
- package/docs/interfaces/IUrlConfigOptions.md +27 -0
- package/docs/interfaces/ShowDirectoryPickerOptions.md +17 -0
- package/docs/interfaces/ShowOpenFilePickerOptions.md +19 -0
- package/docs/interfaces/ShowSaveFilePickerOptions.md +19 -0
- package/docs/type-aliases/TreeInitializer.md +11 -0
- package/docs/type-aliases/WellKnownDirectory.md +11 -0
- package/docs/type-aliases/WindowWithFsAccess.md +11 -0
- package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +11 -0
- package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +11 -0
- package/etc/ts-web-extras.api.md +124 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +25 -2
- package/lib/index.js.map +1 -1
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +77 -0
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/browserCryptoProvider.js +259 -0
- package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -0
- package/lib/packlets/crypto-utils/browserHashProvider.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/browserHashProvider.js.map +1 -0
- package/lib/packlets/{crypto → crypto-utils}/index.d.ts +1 -0
- package/lib/packlets/crypto-utils/index.d.ts.map +1 -0
- package/lib/packlets/{crypto → crypto-utils}/index.js +1 -0
- package/lib/packlets/crypto-utils/index.js.map +1 -0
- package/lib/packlets/file-api-types/index.d.ts.map +1 -1
- package/lib/packlets/file-api-types/index.js +27 -3
- package/lib/packlets/file-api-types/index.js.map +1 -1
- package/lib/packlets/file-tree/directoryHandleStore.d.ts +59 -0
- package/lib/packlets/file-tree/directoryHandleStore.d.ts.map +1 -0
- package/lib/packlets/file-tree/directoryHandleStore.js +128 -0
- package/lib/packlets/file-tree/directoryHandleStore.js.map +1 -0
- package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +66 -0
- package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.js +91 -0
- package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.d.ts +152 -0
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.d.ts.map +1 -0
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js +418 -0
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -0
- package/lib/packlets/file-tree/httpTreeAccessors.d.ts +88 -0
- package/lib/packlets/file-tree/httpTreeAccessors.d.ts.map +1 -0
- package/lib/packlets/file-tree/httpTreeAccessors.js +283 -0
- package/lib/packlets/file-tree/httpTreeAccessors.js.map +1 -0
- package/lib/packlets/file-tree/index.d.ts +4 -0
- package/lib/packlets/file-tree/index.d.ts.map +1 -1
- package/lib/packlets/file-tree/index.js +4 -0
- package/lib/packlets/file-tree/index.js.map +1 -1
- package/lib/packlets/file-tree/localStorageTreeAccessors.d.ts +141 -0
- package/lib/packlets/file-tree/localStorageTreeAccessors.d.ts.map +1 -0
- package/lib/packlets/file-tree/localStorageTreeAccessors.js +363 -0
- package/lib/packlets/file-tree/localStorageTreeAccessors.js.map +1 -0
- package/lib/test/mocks/idb-keyval.d.ts +6 -0
- package/lib/test/mocks/idb-keyval.d.ts.map +1 -0
- package/lib/test/mocks/idb-keyval.js +9 -0
- package/lib/test/mocks/idb-keyval.js.map +1 -0
- package/lib/test/unit/browserHashProvider.test.js +21 -21
- package/lib/test/unit/browserHashProvider.test.js.map +1 -1
- package/lib/test/unit/directoryHandleStore.test.d.ts +2 -0
- package/lib/test/unit/directoryHandleStore.test.d.ts.map +1 -0
- package/lib/test/unit/directoryHandleStore.test.js +192 -0
- package/lib/test/unit/directoryHandleStore.test.js.map +1 -0
- package/lib/test/unit/fileApiTreeAccessors.test.js +51 -0
- package/lib/test/unit/fileApiTreeAccessors.test.js.map +1 -1
- package/lib/test/unit/fileApiTypes.test.js +30 -0
- package/lib/test/unit/fileApiTypes.test.js.map +1 -1
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +2 -0
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +1 -0
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +624 -0
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +1 -0
- package/lib/test/unit/httpTreeAccessors.test.d.ts +2 -0
- package/lib/test/unit/httpTreeAccessors.test.d.ts.map +1 -0
- package/lib/test/unit/httpTreeAccessors.test.js +1002 -0
- package/lib/test/unit/httpTreeAccessors.test.js.map +1 -0
- package/lib/test/unit/localStorageTreeAccessors.test.d.ts +2 -0
- package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +1 -0
- package/lib/test/unit/localStorageTreeAccessors.test.js +814 -0
- package/lib/test/unit/localStorageTreeAccessors.test.js.map +1 -0
- package/lib/test/utils/fileSystemAccessMocks.d.ts +53 -0
- package/lib/test/utils/fileSystemAccessMocks.d.ts.map +1 -0
- package/lib/test/utils/fileSystemAccessMocks.js +277 -0
- package/lib/test/utils/fileSystemAccessMocks.js.map +1 -0
- package/package.json +41 -34
- package/rush-logs/ts-web-extras.build.cache.log +0 -1
- package/rush-logs/ts-web-extras.build.error.log +18 -0
- package/rush-logs/ts-web-extras.build.log +58 -25
- package/rush-logs/ts-web-extras.test.cache.log +1 -0
- package/rush-logs/ts-web-extras.test.error.log +16 -0
- package/rush-logs/ts-web-extras.test.log +70 -0
- package/src/index.ts +2 -2
- package/src/packlets/crypto-utils/browserCryptoProvider.ts +311 -0
- package/src/packlets/{crypto → crypto-utils}/index.ts +1 -0
- package/src/packlets/file-api-types/index.ts +24 -3
- package/src/packlets/file-tree/directoryHandleStore.ts +136 -0
- package/src/packlets/file-tree/fileApiTreeAccessors.ts +108 -0
- package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +519 -0
- package/src/packlets/file-tree/httpTreeAccessors.ts +381 -0
- package/src/packlets/file-tree/index.ts +4 -0
- package/src/packlets/file-tree/localStorageTreeAccessors.ts +430 -0
- package/src/test/mocks/idb-keyval.ts +5 -0
- package/src/test/unit/browserHashProvider.test.ts +1 -1
- package/src/test/unit/directoryHandleStore.test.ts +251 -0
- package/src/test/unit/fileApiTreeAccessors.test.ts +69 -0
- package/src/test/unit/fileApiTypes.test.ts +36 -0
- package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +885 -0
- package/src/test/unit/httpTreeAccessors.test.ts +1278 -0
- package/src/test/unit/localStorageTreeAccessors.test.ts +1014 -0
- package/src/test/utils/fileSystemAccessMocks.ts +353 -0
- package/temp/build/typescript/ts_8nwakTlr.json +1 -0
- package/temp/coverage/crypto/browserHashProvider.ts.html +1 -1
- package/temp/coverage/crypto/index.html +1 -1
- package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +1018 -0
- package/temp/coverage/crypto-utils/browserHashProvider.ts.html +304 -0
- package/temp/coverage/crypto-utils/index.html +131 -0
- package/temp/coverage/file-tree/directoryHandleStore.ts.html +493 -0
- package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +330 -6
- package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +1642 -0
- package/temp/coverage/file-tree/httpTreeAccessors.ts.html +1228 -0
- package/temp/coverage/file-tree/index.html +69 -9
- package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +1375 -0
- package/temp/coverage/helpers/fileTreeHelpers.ts.html +1 -1
- package/temp/coverage/helpers/index.html +1 -1
- package/temp/coverage/index.html +13 -13
- package/temp/coverage/lcov-report/crypto/browserHashProvider.ts.html +1 -1
- package/temp/coverage/lcov-report/crypto/index.html +1 -1
- package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +1018 -0
- package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +304 -0
- package/temp/coverage/lcov-report/crypto-utils/index.html +131 -0
- package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +493 -0
- package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +330 -6
- package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +1642 -0
- package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +1228 -0
- package/temp/coverage/lcov-report/file-tree/index.html +69 -9
- package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +1375 -0
- package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +1 -1
- package/temp/coverage/lcov-report/helpers/index.html +1 -1
- package/temp/coverage/lcov-report/index.html +13 -13
- package/temp/coverage/lcov-report/url-utils/index.html +1 -1
- package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +1 -1
- package/temp/coverage/lcov.info +2829 -428
- package/temp/coverage/url-utils/index.html +1 -1
- package/temp/coverage/url-utils/urlParams.ts.html +1 -1
- package/temp/test/jest/haste-map-b931e4e63102f86c5bd4949f7dced44f-9d713eb41149188b4e5c0ae3d86d0a57-2ad8e16b24e391b8cdbe50b55c137169 +0 -0
- package/temp/test/jest/perf-cache-b931e4e63102f86c5bd4949f7dced44f-da39a3ee5e6b4b0d3255bfef95601890 +1 -0
- package/temp/ts-web-extras.api.json +5282 -1472
- package/temp/ts-web-extras.api.md +124 -1
- package/dist/packlets/crypto/browserHashProvider.js.map +0 -1
- package/dist/packlets/crypto/index.js.map +0 -1
- package/docs/index.md +0 -34
- package/docs/ts-web-extras.browserhashprovider.hashparts.md +0 -88
- package/docs/ts-web-extras.browserhashprovider.hashstring.md +0 -72
- package/docs/ts-web-extras.browserhashprovider.md +0 -66
- package/docs/ts-web-extras.exportasjson.md +0 -70
- package/docs/ts-web-extras.exportusingfilesystemapi.md +0 -104
- package/docs/ts-web-extras.extractdirectorypath.md +0 -52
- package/docs/ts-web-extras.fileapitreeaccessors.create.md +0 -72
- package/docs/ts-web-extras.fileapitreeaccessors.extractfilemetadata.md +0 -54
- package/docs/ts-web-extras.fileapitreeaccessors.fromdirectoryupload.md +0 -72
- package/docs/ts-web-extras.fileapitreeaccessors.fromfilelist.md +0 -72
- package/docs/ts-web-extras.fileapitreeaccessors.getoriginalfile.md +0 -72
- package/docs/ts-web-extras.fileapitreeaccessors.md +0 -114
- package/docs/ts-web-extras.filepickeraccepttype.accept.md +0 -11
- package/docs/ts-web-extras.filepickeraccepttype.description.md +0 -11
- package/docs/ts-web-extras.filepickeraccepttype.md +0 -75
- package/docs/ts-web-extras.filesystemcreatewritableoptions_2.keepexistingdata.md +0 -11
- package/docs/ts-web-extras.filesystemcreatewritableoptions_2.md +0 -58
- package/docs/ts-web-extras.filesystemdirectoryhandle_2._symbol.asynciterator_.md +0 -15
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.entries.md +0 -15
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.getdirectoryhandle.md +0 -66
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.getfilehandle.md +0 -66
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.keys.md +0 -15
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.kind.md +0 -11
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.md +0 -146
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.removeentry.md +0 -66
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.resolve.md +0 -50
- package/docs/ts-web-extras.filesystemdirectoryhandle_2.values.md +0 -15
- package/docs/ts-web-extras.filesystemfilehandle_2.createwritable.md +0 -52
- package/docs/ts-web-extras.filesystemfilehandle_2.getfile.md +0 -15
- package/docs/ts-web-extras.filesystemfilehandle_2.kind.md +0 -11
- package/docs/ts-web-extras.filesystemfilehandle_2.md +0 -92
- package/docs/ts-web-extras.filesystemgetdirectoryoptions_2.create.md +0 -11
- package/docs/ts-web-extras.filesystemgetdirectoryoptions_2.md +0 -58
- package/docs/ts-web-extras.filesystemgetfileoptions_2.create.md +0 -11
- package/docs/ts-web-extras.filesystemgetfileoptions_2.md +0 -58
- package/docs/ts-web-extras.filesystemhandle_2.issameentry.md +0 -50
- package/docs/ts-web-extras.filesystemhandle_2.kind.md +0 -11
- package/docs/ts-web-extras.filesystemhandle_2.md +0 -119
- package/docs/ts-web-extras.filesystemhandle_2.name.md +0 -11
- package/docs/ts-web-extras.filesystemhandle_2.querypermission.md +0 -52
- package/docs/ts-web-extras.filesystemhandle_2.requestpermission.md +0 -52
- package/docs/ts-web-extras.filesystemhandlepermissiondescriptor.md +0 -58
- package/docs/ts-web-extras.filesystemhandlepermissiondescriptor.mode.md +0 -11
- package/docs/ts-web-extras.filesystemremoveoptions_2.md +0 -58
- package/docs/ts-web-extras.filesystemremoveoptions_2.recursive.md +0 -11
- package/docs/ts-web-extras.filesystemwritablefilestream_2.md +0 -57
- package/docs/ts-web-extras.filesystemwritablefilestream_2.seek.md +0 -50
- package/docs/ts-web-extras.filesystemwritablefilestream_2.truncate.md +0 -50
- package/docs/ts-web-extras.filesystemwritablefilestream_2.write.md +0 -50
- package/docs/ts-web-extras.filetreehelpers.defaultfileapitreeinitparams.md +0 -13
- package/docs/ts-web-extras.filetreehelpers.extractfilelistmetadata.md +0 -56
- package/docs/ts-web-extras.filetreehelpers.extractfilemetadata.md +0 -56
- package/docs/ts-web-extras.filetreehelpers.fromdirectoryupload.md +0 -76
- package/docs/ts-web-extras.filetreehelpers.fromfilelist.md +0 -76
- package/docs/ts-web-extras.filetreehelpers.getoriginalfile.md +0 -72
- package/docs/ts-web-extras.filetreehelpers.md +0 -102
- package/docs/ts-web-extras.idirectoryhandletreeinitializer.dirhandles.md +0 -11
- package/docs/ts-web-extras.idirectoryhandletreeinitializer.md +0 -100
- package/docs/ts-web-extras.idirectoryhandletreeinitializer.nonrecursive.md +0 -11
- package/docs/ts-web-extras.idirectoryhandletreeinitializer.prefix.md +0 -11
- package/docs/ts-web-extras.ifilehandletreeinitializer.filehandles.md +0 -11
- package/docs/ts-web-extras.ifilehandletreeinitializer.md +0 -79
- package/docs/ts-web-extras.ifilehandletreeinitializer.prefix.md +0 -11
- package/docs/ts-web-extras.ifilelisttreeinitializer.filelist.md +0 -11
- package/docs/ts-web-extras.ifilelisttreeinitializer.md +0 -58
- package/docs/ts-web-extras.ifilemetadata.lastmodified.md +0 -11
- package/docs/ts-web-extras.ifilemetadata.md +0 -124
- package/docs/ts-web-extras.ifilemetadata.name.md +0 -11
- package/docs/ts-web-extras.ifilemetadata.path.md +0 -11
- package/docs/ts-web-extras.ifilemetadata.size.md +0 -11
- package/docs/ts-web-extras.ifilemetadata.type.md +0 -11
- package/docs/ts-web-extras.ifsaccessapis.md +0 -56
- package/docs/ts-web-extras.ifsaccessapis.showdirectorypicker.md +0 -52
- package/docs/ts-web-extras.ifsaccessapis.showopenfilepicker.md +0 -52
- package/docs/ts-web-extras.ifsaccessapis.showsavefilepicker.md +0 -52
- package/docs/ts-web-extras.isdirectoryhandle.md +0 -56
- package/docs/ts-web-extras.isfilehandle.md +0 -56
- package/docs/ts-web-extras.isfilepath.md +0 -52
- package/docs/ts-web-extras.iurlconfigoptions.config.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.configstartdir.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.contextfilter.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.input.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.inputstartdir.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.interactive.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.loadzip.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.maxdistance.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.md +0 -286
- package/docs/ts-web-extras.iurlconfigoptions.qualifierdefaults.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.reducequalifiers.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.resourcetypes.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.zipfile.md +0 -13
- package/docs/ts-web-extras.iurlconfigoptions.zippath.md +0 -13
- package/docs/ts-web-extras.md +0 -512
- package/docs/ts-web-extras.parsecontextfilter.md +0 -52
- package/docs/ts-web-extras.parsequalifierdefaults.md +0 -52
- package/docs/ts-web-extras.parseresourcetypes.md +0 -52
- package/docs/ts-web-extras.parseurlparameters.md +0 -17
- package/docs/ts-web-extras.safeshowdirectorypicker.md +0 -72
- package/docs/ts-web-extras.safeshowopenfilepicker.md +0 -72
- package/docs/ts-web-extras.safeshowsavefilepicker.md +0 -72
- package/docs/ts-web-extras.showdirectorypickeroptions.id.md +0 -11
- package/docs/ts-web-extras.showdirectorypickeroptions.md +0 -96
- package/docs/ts-web-extras.showdirectorypickeroptions.mode.md +0 -11
- package/docs/ts-web-extras.showdirectorypickeroptions.startin.md +0 -11
- package/docs/ts-web-extras.showopenfilepickeroptions.excludeacceptalloption.md +0 -11
- package/docs/ts-web-extras.showopenfilepickeroptions.id.md +0 -11
- package/docs/ts-web-extras.showopenfilepickeroptions.md +0 -134
- package/docs/ts-web-extras.showopenfilepickeroptions.multiple.md +0 -11
- package/docs/ts-web-extras.showopenfilepickeroptions.startin.md +0 -11
- package/docs/ts-web-extras.showopenfilepickeroptions.types.md +0 -11
- package/docs/ts-web-extras.showsavefilepickeroptions.excludeacceptalloption.md +0 -11
- package/docs/ts-web-extras.showsavefilepickeroptions.id.md +0 -11
- package/docs/ts-web-extras.showsavefilepickeroptions.md +0 -134
- package/docs/ts-web-extras.showsavefilepickeroptions.startin.md +0 -11
- package/docs/ts-web-extras.showsavefilepickeroptions.suggestedname.md +0 -11
- package/docs/ts-web-extras.showsavefilepickeroptions.types.md +0 -11
- package/docs/ts-web-extras.supportsfilesystemaccess.md +0 -56
- package/docs/ts-web-extras.treeinitializer.md +0 -15
- package/docs/ts-web-extras.wellknowndirectory.md +0 -13
- package/docs/ts-web-extras.windowwithfsaccess.md +0 -15
- package/lib/packlets/crypto/browserHashProvider.d.ts.map +0 -1
- package/lib/packlets/crypto/browserHashProvider.js.map +0 -1
- package/lib/packlets/crypto/index.d.ts.map +0 -1
- package/lib/packlets/crypto/index.js.map +0 -1
- package/temp/build/typescript/ts_vnCx6LlY.json +0 -1
- package/temp/test/jest/haste-map-7492f1b44480e0cdd1f220078fb3afd8-c8dd6c3430605adeb2f1cadf4f75e791-8c9336785555d572065b28c111982ba4 +0 -0
- package/temp/test/jest/perf-cache-7492f1b44480e0cdd1f220078fb3afd8-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
- /package/dist/packlets/{crypto → crypto-utils}/browserHashProvider.js +0 -0
- /package/lib/packlets/{crypto → crypto-utils}/browserHashProvider.d.ts +0 -0
- /package/lib/packlets/{crypto → crypto-utils}/browserHashProvider.js +0 -0
- /package/src/packlets/{crypto → crypto-utils}/browserHashProvider.ts +0 -0
- /package/temp/test/jest/{jest-transform-cache-7492f1b44480e0cdd1f220078fb3afd8-79ef2876fae7ca75eedb2aa53dc48338/0e/package_0eb6535f5987849d93ea51ef33a14cf6 → jest-transform-cache-b931e4e63102f86c5bd4949f7dced44f-79ef2876fae7ca75eedb2aa53dc48338/b5/package_b5f57afc9ec2c011239b1608ee5bdfa5} +0 -0
package/package.json
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-web-extras",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0-1",
|
|
4
4
|
"description": "Browser-compatible utilities and FileTree implementations",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-web-extras.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "heft test --clean",
|
|
9
|
+
"clean": "heft clean",
|
|
10
|
+
"test": "heft test --clean",
|
|
11
|
+
"build-docs": "typedoc --options ./config/typedoc.json",
|
|
12
|
+
"build-all": "rushx build; rushx build-docs",
|
|
13
|
+
"test-handles": "jest --runInBand --detectOpenHandles",
|
|
14
|
+
"clean-jest": "jest --clear-cache",
|
|
15
|
+
"coverage": "jest --coverage",
|
|
16
|
+
"lint": "eslint src --ext .ts",
|
|
17
|
+
"fixlint": "eslint src --ext .ts --fix"
|
|
18
|
+
},
|
|
7
19
|
"sideEffects": false,
|
|
8
20
|
"keywords": [
|
|
9
21
|
"browser",
|
|
@@ -19,41 +31,45 @@
|
|
|
19
31
|
},
|
|
20
32
|
"homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-web-extras#readme",
|
|
21
33
|
"devDependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
34
|
+
"@fgv/heft-dual-rig": "workspace:*",
|
|
35
|
+
"@fgv/ts-extras": "workspace:*",
|
|
36
|
+
"@fgv/ts-utils": "workspace:*",
|
|
37
|
+
"@fgv/ts-json-base": "workspace:*",
|
|
38
|
+
"@fgv/ts-utils-jest": "workspace:*",
|
|
39
|
+
"@microsoft/api-documenter": "^7.28.2",
|
|
40
|
+
"@microsoft/api-extractor": "^7.55.2",
|
|
24
41
|
"@types/jest": "^29.5.14",
|
|
25
42
|
"@types/node": "^20.14.9",
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
27
|
-
"@typescript-eslint/parser": "^8.
|
|
28
|
-
"eslint": "^9.39.
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^8.52.0",
|
|
44
|
+
"@typescript-eslint/parser": "^8.52.0",
|
|
45
|
+
"eslint": "^9.39.2",
|
|
29
46
|
"eslint-plugin-import": "^2.32.0",
|
|
30
47
|
"eslint-plugin-node": "^11.1.0",
|
|
31
48
|
"eslint-plugin-promise": "^7.2.1",
|
|
32
49
|
"jest": "^29.7.0",
|
|
33
50
|
"jest-extended": "^4.0.2",
|
|
34
|
-
"rimraf": "^6.1.
|
|
35
|
-
"ts-jest": "^29.4.
|
|
51
|
+
"rimraf": "^6.1.2",
|
|
52
|
+
"ts-jest": "^29.4.6",
|
|
36
53
|
"ts-node": "^10.9.2",
|
|
37
54
|
"typescript": "5.9.3",
|
|
38
55
|
"eslint-plugin-n": "^17.23.1",
|
|
39
|
-
"@rushstack/eslint-config": "4.
|
|
40
|
-
"@rushstack/heft": "1.
|
|
41
|
-
"@rushstack/heft-jest-plugin": "1.
|
|
42
|
-
"@rushstack/heft-node-rig": "2.11.
|
|
56
|
+
"@rushstack/eslint-config": "4.6.4",
|
|
57
|
+
"@rushstack/heft": "1.2.6",
|
|
58
|
+
"@rushstack/heft-jest-plugin": "1.2.6",
|
|
59
|
+
"@rushstack/heft-node-rig": "2.11.26",
|
|
43
60
|
"@types/heft-jest": "1.0.6",
|
|
44
|
-
"eslint-plugin-tsdoc": "~0.
|
|
61
|
+
"eslint-plugin-tsdoc": "~0.5.2",
|
|
45
62
|
"@rushstack/eslint-patch": "1.14.1",
|
|
46
|
-
"@types/react": "~19.2.
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"@fgv/ts-json-base": "5.0.2",
|
|
50
|
-
"@fgv/ts-utils-jest": "5.0.2"
|
|
63
|
+
"@types/react": "~19.2.8",
|
|
64
|
+
"typedoc": "~0.28.16",
|
|
65
|
+
"typedoc-plugin-markdown": "~4.9.0"
|
|
51
66
|
},
|
|
52
67
|
"peerDependencies": {
|
|
68
|
+
"@fgv/ts-extras": "workspace:*",
|
|
69
|
+
"@fgv/ts-utils": "workspace:*",
|
|
70
|
+
"@fgv/ts-json-base": "workspace:*",
|
|
53
71
|
"react": ">=18 <20",
|
|
54
|
-
"react-dom": ">=18 <20"
|
|
55
|
-
"@fgv/ts-json-base": "5.0.2",
|
|
56
|
-
"@fgv/ts-utils": "5.0.2"
|
|
72
|
+
"react-dom": ">=18 <20"
|
|
57
73
|
},
|
|
58
74
|
"exports": {
|
|
59
75
|
".": {
|
|
@@ -70,18 +86,9 @@
|
|
|
70
86
|
},
|
|
71
87
|
"repository": {
|
|
72
88
|
"type": "git",
|
|
73
|
-
"url": "https://github.com/ErikFortune/fgv.git"
|
|
89
|
+
"url": "git+https://github.com/ErikFortune/fgv.git"
|
|
74
90
|
},
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"clean": "heft clean",
|
|
78
|
-
"test": "heft test --clean",
|
|
79
|
-
"build-docs": "api-documenter markdown --input-folder ./temp --output-folder docs",
|
|
80
|
-
"build-all": "rushx build; rushx build-docs",
|
|
81
|
-
"test-handles": "jest --runInBand --detectOpenHandles",
|
|
82
|
-
"clean-jest": "jest --clear-cache",
|
|
83
|
-
"coverage": "jest --coverage",
|
|
84
|
-
"lint": "eslint src --ext .ts",
|
|
85
|
-
"fixlint": "eslint src --ext .ts --fix"
|
|
91
|
+
"dependencies": {
|
|
92
|
+
"idb-keyval": "^6.2.2"
|
|
86
93
|
}
|
|
87
|
-
}
|
|
94
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Project does not have a rush-project.json configuration file, or one provided by a rig, so it does not support caching.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
(node:72593) [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:72591) [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:72598) [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:72594) [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:72597) [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:72590) [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:72596) [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:72592) [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:72595) [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,42 +1,75 @@
|
|
|
1
1
|
Invoking: heft test --clean
|
|
2
2
|
---- build started ----
|
|
3
|
+
[build:clean] Deleted 0 files and 3 folders
|
|
3
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.
|
|
4
5
|
[build:typescript] Using TypeScript version 5.9.3
|
|
5
|
-
[build:api-extractor] Using API Extractor version 7.
|
|
6
|
+
[build:api-extractor] Using API Extractor version 7.57.6
|
|
6
7
|
[build:api-extractor] Analysis will use the bundled TypeScript version 5.8.2
|
|
7
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.
|
|
8
|
-
---- build finished (
|
|
9
|
+
---- build finished (3.991s) ----
|
|
9
10
|
---- test started ----
|
|
11
|
+
[test:clean] Deleted 0 files and 1 folder
|
|
10
12
|
[test:jest] Using Jest version 29.5.0
|
|
11
13
|
[test:jest]
|
|
12
|
-
[test:jest] Run start.
|
|
14
|
+
[test:jest] Run start. 9 test suites
|
|
13
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
|
|
14
19
|
[test:jest] START lib/test/unit/fileTreeHelpers.test.js
|
|
15
20
|
[test:jest] START lib/test/unit/fileApiTypes.test.js
|
|
16
21
|
[test:jest] START lib/test/unit/urlParams.test.js
|
|
17
|
-
[test:jest]
|
|
22
|
+
[test:jest] START lib/test/unit/directoryHandleStore.test.js
|
|
18
23
|
[test:jest] START lib/test/unit/browserHashProvider.test.js
|
|
19
|
-
[
|
|
20
|
-
|
|
21
|
-
[
|
|
22
|
-
|
|
24
|
+
(node:72593) [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:72591) [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
|
+
(node:72598) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
|
|
29
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
30
|
+
[test:jest] PASS lib/test/unit/httpTreeAccessors.test.js (duration: 0.858s, 52 passed, 0 failed)
|
|
31
|
+
[test:jest] PASS lib/test/unit/fileSystemAccessTreeAccessors.test.js (duration: 0.900s, 44 passed, 0 failed)
|
|
32
|
+
[test:jest] PASS lib/test/unit/browserHashProvider.test.js (duration: 0.969s, 15 passed, 0 failed)
|
|
33
|
+
(node:72594) [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/fileTreeHelpers.test.js (duration: 0.968s, 35 passed, 0 failed)
|
|
36
|
+
[test:jest] PASS lib/test/unit/directoryHandleStore.test.js (duration: 0.948s, 19 passed, 0 failed)
|
|
37
|
+
(node:72597) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
|
|
38
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
39
|
+
(node:72590) [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
|
+
(node:72596) [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:72592) [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/urlParams.test.js (duration: 0.916s, 60 passed, 0 failed)
|
|
46
|
+
[test:jest] PASS lib/test/unit/fileApiTreeAccessors.test.js (duration: 0.987s, 65 passed, 0 failed)
|
|
47
|
+
[test:jest] PASS lib/test/unit/localStorageTreeAccessors.test.js (duration: 0.974s, 44 passed, 0 failed)
|
|
48
|
+
(node:72595) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
|
|
49
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
50
|
+
[test:jest] PASS lib/test/unit/fileApiTypes.test.js (duration: 0.933s, 36 passed, 0 failed)
|
|
23
51
|
[test:jest]
|
|
24
52
|
[test:jest] Tests finished:
|
|
25
|
-
[test:jest] Successes:
|
|
53
|
+
[test:jest] Successes: 370
|
|
26
54
|
[test:jest] Failures: 0
|
|
27
|
-
[test:jest] Total:
|
|
28
|
-
|
|
29
|
-
File
|
|
30
|
-
|
|
31
|
-
All files
|
|
32
|
-
crypto
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
[test:jest] Total: 371
|
|
56
|
+
-----------------------------------|---------|----------|---------|---------|-------------------
|
|
57
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
58
|
+
-----------------------------------|---------|----------|---------|---------|-------------------
|
|
59
|
+
All files | 100 | 100 | 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 | 100 | 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 | 100 | 100 | 100 |
|
|
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.336s) ----
|
|
75
|
+
-------------------- Finished (6.331s) --------------------
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This project does not define the caching behavior of the "test" command, so caching has been disabled.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
(node:35708) [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:35707) [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:35710) [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:35711) [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:35705) [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:35709) [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:35712) [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:35706) [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)
|
|
@@ -0,0 +1,70 @@
|
|
|
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.55.2
|
|
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 (2.899s) ----
|
|
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. 8 test suites
|
|
15
|
+
[test:jest] START lib/test/unit/fileApiTreeAccessors.test.js
|
|
16
|
+
[test:jest] START lib/test/unit/fileTreeHelpers.test.js
|
|
17
|
+
[test:jest] START lib/test/unit/fileSystemAccessTreeAccessors.test.js
|
|
18
|
+
[test:jest] START lib/test/unit/localStorageTreeAccessors.test.js
|
|
19
|
+
[test:jest] START lib/test/unit/fileApiTypes.test.js
|
|
20
|
+
[test:jest] START lib/test/unit/urlParams.test.js
|
|
21
|
+
[test:jest] START lib/test/unit/directoryHandleStore.test.js
|
|
22
|
+
[test:jest] START lib/test/unit/browserHashProvider.test.js
|
|
23
|
+
(node:35708) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
|
|
24
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
25
|
+
[test:jest] PASS lib/test/unit/localStorageTreeAccessors.test.js (duration: 0.633s, 33 passed, 0 failed)
|
|
26
|
+
(node:35707) [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
|
+
(node:35710) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
|
|
29
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
30
|
+
(node:35711) [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.656s, 19 passed, 0 failed)
|
|
33
|
+
[test:jest] PASS lib/test/unit/urlParams.test.js (duration: 0.661s, 60 passed, 0 failed)
|
|
34
|
+
(node:35705) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
|
|
35
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
36
|
+
[test:jest] PASS lib/test/unit/fileApiTreeAccessors.test.js (duration: 0.660s, 63 passed, 0 failed)
|
|
37
|
+
(node:35709) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
|
|
38
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
39
|
+
[test:jest] PASS lib/test/unit/fileApiTypes.test.js (duration: 0.676s, 36 passed, 0 failed)
|
|
40
|
+
(node:35712) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
|
|
41
|
+
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
42
|
+
(node:35706) [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/fileTreeHelpers.test.js (duration: 0.713s, 35 passed, 0 failed)
|
|
45
|
+
[test:jest] PASS lib/test/unit/fileSystemAccessTreeAccessors.test.js (duration: 0.719s, 38 passed, 0 failed)
|
|
46
|
+
[test:jest] PASS lib/test/unit/browserHashProvider.test.js (duration: 0.723s, 15 passed, 0 failed)
|
|
47
|
+
[test:jest]
|
|
48
|
+
[test:jest] Tests finished:
|
|
49
|
+
[test:jest] Successes: 299
|
|
50
|
+
[test:jest] Failures: 0
|
|
51
|
+
[test:jest] Total: 300
|
|
52
|
+
-----------------------------------|---------|----------|---------|---------|------------------------------------
|
|
53
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
54
|
+
-----------------------------------|---------|----------|---------|---------|------------------------------------
|
|
55
|
+
All files | 100 | 95.68 | 100 | 100 |
|
|
56
|
+
crypto-utils | 100 | 100 | 100 | 100 |
|
|
57
|
+
browserCryptoProvider.ts | 100 | 100 | 100 | 100 |
|
|
58
|
+
browserHashProvider.ts | 100 | 100 | 100 | 100 |
|
|
59
|
+
file-tree | 100 | 94.9 | 100 | 100 |
|
|
60
|
+
directoryHandleStore.ts | 100 | 100 | 100 | 100 |
|
|
61
|
+
fileApiTreeAccessors.ts | 100 | 100 | 100 | 100 |
|
|
62
|
+
fileSystemAccessTreeAccessors.ts | 100 | 93.06 | 100 | 100 | 90,152,160,169,176
|
|
63
|
+
localStorageTreeAccessors.ts | 100 | 88.6 | 100 | 100 | 92,107,163-164,196-197,210,245-249
|
|
64
|
+
helpers | 100 | 100 | 100 | 100 |
|
|
65
|
+
fileTreeHelpers.ts | 100 | 100 | 100 | 100 |
|
|
66
|
+
url-utils | 100 | 100 | 100 | 100 |
|
|
67
|
+
urlParams.ts | 100 | 100 | 100 | 100 |
|
|
68
|
+
-----------------------------------|---------|----------|---------|---------|------------------------------------
|
|
69
|
+
---- test finished (1.675s) ----
|
|
70
|
+
-------------------- Finished (4.577s) --------------------
|
package/src/index.ts
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
* @packageDocumentation
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
export
|
|
34
|
+
import * as CryptoUtils from './packlets/crypto-utils';
|
|
35
|
+
export { CryptoUtils };
|
|
36
36
|
|
|
37
37
|
// Export file tree functionality
|
|
38
38
|
export * from './packlets/file-tree';
|
|
@@ -0,0 +1,311 @@
|
|
|
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 */
|