@fgv/ts-web-extras 5.1.0-4 → 5.1.0-40
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/dist/packlets/crypto-utils/browserCryptoProvider.js +330 -18
- package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
- package/dist/packlets/crypto-utils/idbPrivateKeyStorage.js +238 -0
- package/dist/packlets/crypto-utils/idbPrivateKeyStorage.js.map +1 -0
- package/dist/packlets/crypto-utils/index.js +13 -0
- package/dist/packlets/crypto-utils/index.js.map +1 -1
- package/dist/packlets/file-tree/directoryHandleStore.js.map +1 -1
- package/dist/packlets/file-tree/fileApiTreeAccessors.js +1 -1
- package/dist/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
- package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js +2 -2
- package/dist/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -1
- package/dist/packlets/file-tree/httpTreeAccessors.js +74 -44
- package/dist/packlets/file-tree/httpTreeAccessors.js.map +1 -1
- package/dist/packlets/file-tree/localStorageTreeAccessors.js.map +1 -1
- package/dist/packlets/helpers/fileTreeHelpers.js +1 -1
- package/dist/packlets/helpers/fileTreeHelpers.js.map +1 -1
- package/dist/ts-web-extras.d.ts +229 -10
- package/dist/tsdoc-metadata.json +1 -1
- package/eslint.config.js +32 -0
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +115 -6
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -1
- package/lib/packlets/crypto-utils/browserCryptoProvider.js +329 -17
- package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
- package/lib/packlets/crypto-utils/idbPrivateKeyStorage.d.ts +87 -0
- package/lib/packlets/crypto-utils/idbPrivateKeyStorage.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/idbPrivateKeyStorage.js +242 -0
- package/lib/packlets/crypto-utils/idbPrivateKeyStorage.js.map +1 -0
- package/lib/packlets/crypto-utils/index.d.ts +14 -0
- package/lib/packlets/crypto-utils/index.d.ts.map +1 -1
- package/lib/packlets/crypto-utils/index.js +14 -0
- package/lib/packlets/crypto-utils/index.js.map +1 -1
- package/lib/packlets/file-tree/directoryHandleStore.d.ts +2 -2
- package/lib/packlets/file-tree/directoryHandleStore.d.ts.map +1 -1
- package/lib/packlets/file-tree/directoryHandleStore.js.map +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +2 -2
- package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.js +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js +2 -2
- package/lib/packlets/file-tree/fileSystemAccessTreeAccessors.js.map +1 -1
- package/lib/packlets/file-tree/httpTreeAccessors.d.ts +6 -0
- package/lib/packlets/file-tree/httpTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/file-tree/httpTreeAccessors.js +74 -44
- package/lib/packlets/file-tree/httpTreeAccessors.js.map +1 -1
- package/lib/packlets/file-tree/localStorageTreeAccessors.js.map +1 -1
- package/lib/packlets/helpers/fileTreeHelpers.d.ts +1 -1
- package/lib/packlets/helpers/fileTreeHelpers.d.ts.map +1 -1
- package/lib/packlets/helpers/fileTreeHelpers.js +6 -6
- package/lib/packlets/helpers/fileTreeHelpers.js.map +1 -1
- package/package.json +15 -14
- package/.rush/temp/44b0369e8112f3c6f4248af466a3f35ad626d9d7.tar.log +0 -237
- package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +0 -55
- package/.rush/temp/operation/build/all.log +0 -55
- package/.rush/temp/operation/build/log-chunks.jsonl +0 -55
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/shrinkwrap-deps.json +0 -692
- package/CHANGELOG.md +0 -23
- package/config/api-extractor.json +0 -343
- package/config/jest.config.json +0 -19
- package/config/rig.json +0 -16
- package/config/typedoc.json +0 -7
- package/dist/test/mocks/idb-keyval.js +0 -6
- package/dist/test/mocks/idb-keyval.js.map +0 -1
- package/dist/test/setupTests.js +0 -74
- package/dist/test/setupTests.js.map +0 -1
- package/dist/test/unit/browserHashProvider.test.js +0 -140
- package/dist/test/unit/browserHashProvider.test.js.map +0 -1
- package/dist/test/unit/directoryHandleStore.test.js +0 -190
- package/dist/test/unit/directoryHandleStore.test.js.map +0 -1
- package/dist/test/unit/fileApiTreeAccessors.test.js +0 -1188
- package/dist/test/unit/fileApiTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/fileApiTypes.test.js +0 -472
- package/dist/test/unit/fileApiTypes.test.js.map +0 -1
- package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +0 -622
- package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/fileTreeHelpers.test.js +0 -590
- package/dist/test/unit/fileTreeHelpers.test.js.map +0 -1
- package/dist/test/unit/httpTreeAccessors.test.js +0 -1229
- package/dist/test/unit/httpTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/localStorageTreeAccessors.test.js +0 -812
- package/dist/test/unit/localStorageTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/urlParams.test.js +0 -393
- package/dist/test/unit/urlParams.test.js.map +0 -1
- package/dist/test/utils/fileSystemAccessMocks.js +0 -271
- package/dist/test/utils/fileSystemAccessMocks.js.map +0 -1
- package/dist/test/utils/testHelpers.js +0 -124
- package/dist/test/utils/testHelpers.js.map +0 -1
- package/docs/CryptoUtils/README.md +0 -60
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.decrypt.md +0 -27
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.deriveKey.md +0 -26
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.encrypt.md +0 -25
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.fromBase64.md +0 -24
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateKey.md +0 -17
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.generateRandomBytes.md +0 -24
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.md +0 -151
- package/docs/CryptoUtils/classes/BrowserCryptoProvider.toBase64.md +0 -24
- package/docs/CryptoUtils/classes/BrowserHashProvider.hashParts.md +0 -26
- package/docs/CryptoUtils/classes/BrowserHashProvider.hashString.md +0 -25
- package/docs/CryptoUtils/classes/BrowserHashProvider.md +0 -81
- package/docs/CryptoUtils/functions/createBrowserCryptoProvider.md +0 -12
- package/docs/FileTreeHelpers/README.md +0 -85
- package/docs/FileTreeHelpers/functions/extractFileListMetadata.md +0 -11
- package/docs/FileTreeHelpers/functions/extractFileMetadata.md +0 -11
- package/docs/FileTreeHelpers/functions/fromDirectoryUpload.md +0 -12
- package/docs/FileTreeHelpers/functions/fromFileList.md +0 -12
- package/docs/FileTreeHelpers/functions/getOriginalFile.md +0 -11
- package/docs/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +0 -9
- package/docs/README.md +0 -524
- package/docs/classes/BrowserCryptoProvider.decrypt.md +0 -27
- package/docs/classes/BrowserCryptoProvider.deriveKey.md +0 -26
- package/docs/classes/BrowserCryptoProvider.encrypt.md +0 -25
- package/docs/classes/BrowserCryptoProvider.fromBase64.md +0 -24
- package/docs/classes/BrowserCryptoProvider.generateKey.md +0 -17
- package/docs/classes/BrowserCryptoProvider.generateRandomBytes.md +0 -24
- package/docs/classes/BrowserCryptoProvider.md +0 -151
- package/docs/classes/BrowserCryptoProvider.toBase64.md +0 -24
- package/docs/classes/BrowserHashProvider.hashParts.md +0 -26
- package/docs/classes/BrowserHashProvider.hashString.md +0 -25
- package/docs/classes/BrowserHashProvider.md +0 -81
- package/docs/classes/DirectoryHandleStore.getAll.md +0 -17
- package/docs/classes/DirectoryHandleStore.getAllLabels.md +0 -17
- package/docs/classes/DirectoryHandleStore.load.md +0 -24
- package/docs/classes/DirectoryHandleStore.md +0 -120
- package/docs/classes/DirectoryHandleStore.remove.md +0 -24
- package/docs/classes/DirectoryHandleStore.save.md +0 -25
- package/docs/classes/FileApiTreeAccessors.create.md +0 -25
- package/docs/classes/FileApiTreeAccessors.createFromHttp.md +0 -24
- package/docs/classes/FileApiTreeAccessors.createFromLocalStorage.md +0 -25
- package/docs/classes/FileApiTreeAccessors.createPersistent.md +0 -26
- package/docs/classes/FileApiTreeAccessors.createPersistentFromFile.md +0 -27
- package/docs/classes/FileApiTreeAccessors.extractFileMetadata.md +0 -24
- package/docs/classes/FileApiTreeAccessors.fromDirectoryUpload.md +0 -25
- package/docs/classes/FileApiTreeAccessors.fromFileList.md +0 -25
- package/docs/classes/FileApiTreeAccessors.getOriginalFile.md +0 -27
- package/docs/classes/FileApiTreeAccessors.md +0 -172
- package/docs/classes/FileSystemAccessTreeAccessors.deleteFile.md +0 -22
- package/docs/classes/FileSystemAccessTreeAccessors.fileIsMutable.md +0 -22
- package/docs/classes/FileSystemAccessTreeAccessors.fromDirectoryHandle.md +0 -25
- package/docs/classes/FileSystemAccessTreeAccessors.fromFileHandle.md +0 -29
- package/docs/classes/FileSystemAccessTreeAccessors.getDirtyPaths.md +0 -15
- package/docs/classes/FileSystemAccessTreeAccessors.isDirty.md +0 -15
- package/docs/classes/FileSystemAccessTreeAccessors.md +0 -275
- package/docs/classes/FileSystemAccessTreeAccessors.saveFileContents.md +0 -23
- package/docs/classes/FileSystemAccessTreeAccessors.syncToDisk.md +0 -15
- package/docs/classes/HttpTreeAccessors.deleteFile.md +0 -22
- package/docs/classes/HttpTreeAccessors.fileIsMutable.md +0 -24
- package/docs/classes/HttpTreeAccessors.fromHttp.md +0 -24
- package/docs/classes/HttpTreeAccessors.getDirtyPaths.md +0 -17
- package/docs/classes/HttpTreeAccessors.isDirty.md +0 -17
- package/docs/classes/HttpTreeAccessors.md +0 -261
- package/docs/classes/HttpTreeAccessors.saveFileContents.md +0 -25
- package/docs/classes/HttpTreeAccessors.syncToDisk.md +0 -22
- package/docs/classes/LocalStorageTreeAccessors.deleteFile.md +0 -24
- package/docs/classes/LocalStorageTreeAccessors.fileIsMutable.md +0 -24
- package/docs/classes/LocalStorageTreeAccessors.fromStorage.md +0 -25
- package/docs/classes/LocalStorageTreeAccessors.getDirtyPaths.md +0 -17
- package/docs/classes/LocalStorageTreeAccessors.isDirty.md +0 -17
- package/docs/classes/LocalStorageTreeAccessors.md +0 -270
- package/docs/classes/LocalStorageTreeAccessors.saveFileContents.md +0 -25
- package/docs/classes/LocalStorageTreeAccessors.syncToDisk.md +0 -17
- package/docs/functions/createBrowserCryptoProvider.md +0 -12
- package/docs/functions/exportAsJson.md +0 -12
- package/docs/functions/exportUsingFileSystemAPI.md +0 -11
- package/docs/functions/extractDirectoryPath.md +0 -13
- package/docs/functions/extractFileListMetadata.md +0 -11
- package/docs/functions/extractFileMetadata.md +0 -11
- package/docs/functions/fromDirectoryUpload.md +0 -12
- package/docs/functions/fromFileList.md +0 -12
- package/docs/functions/getOriginalFile.md +0 -11
- package/docs/functions/isDirectoryHandle.md +0 -11
- package/docs/functions/isFileHandle.md +0 -11
- package/docs/functions/isFilePath.md +0 -11
- package/docs/functions/parseContextFilter.md +0 -12
- package/docs/functions/parseQualifierDefaults.md +0 -12
- package/docs/functions/parseResourceTypes.md +0 -12
- package/docs/functions/parseUrlParameters.md +0 -11
- package/docs/functions/safeShowDirectoryPicker.md +0 -11
- package/docs/functions/safeShowOpenFilePicker.md +0 -11
- package/docs/functions/safeShowSaveFilePicker.md +0 -11
- package/docs/functions/supportsFileSystemAccess.md +0 -11
- package/docs/interfaces/FilePickerAcceptType.accept.md +0 -9
- package/docs/interfaces/FilePickerAcceptType.description.md +0 -9
- package/docs/interfaces/FilePickerAcceptType.md +0 -61
- package/docs/interfaces/FileSystemCreateWritableOptions.keepExistingData.md +0 -9
- package/docs/interfaces/FileSystemCreateWritableOptions.md +0 -44
- package/docs/interfaces/FileSystemDirectoryHandle._asyncIterator_.md +0 -13
- package/docs/interfaces/FileSystemDirectoryHandle.entries.md +0 -13
- package/docs/interfaces/FileSystemDirectoryHandle.getDirectoryHandle.md +0 -21
- package/docs/interfaces/FileSystemDirectoryHandle.getFileHandle.md +0 -21
- package/docs/interfaces/FileSystemDirectoryHandle.keys.md +0 -13
- package/docs/interfaces/FileSystemDirectoryHandle.kind.md +0 -9
- package/docs/interfaces/FileSystemDirectoryHandle.md +0 -224
- package/docs/interfaces/FileSystemDirectoryHandle.removeEntry.md +0 -21
- package/docs/interfaces/FileSystemDirectoryHandle.resolve.md +0 -20
- package/docs/interfaces/FileSystemDirectoryHandle.values.md +0 -13
- package/docs/interfaces/FileSystemFileHandle.createWritable.md +0 -20
- package/docs/interfaces/FileSystemFileHandle.getFile.md +0 -13
- package/docs/interfaces/FileSystemFileHandle.kind.md +0 -9
- package/docs/interfaces/FileSystemFileHandle.md +0 -146
- package/docs/interfaces/FileSystemGetDirectoryOptions.create.md +0 -9
- package/docs/interfaces/FileSystemGetDirectoryOptions.md +0 -44
- package/docs/interfaces/FileSystemGetFileOptions.create.md +0 -9
- package/docs/interfaces/FileSystemGetFileOptions.md +0 -44
- package/docs/interfaces/FileSystemHandle.isSameEntry.md +0 -20
- package/docs/interfaces/FileSystemHandle.kind.md +0 -9
- package/docs/interfaces/FileSystemHandle.md +0 -118
- package/docs/interfaces/FileSystemHandle.name.md +0 -9
- package/docs/interfaces/FileSystemHandle.queryPermission.md +0 -20
- package/docs/interfaces/FileSystemHandle.requestPermission.md +0 -20
- package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +0 -44
- package/docs/interfaces/FileSystemHandlePermissionDescriptor.mode.md +0 -9
- package/docs/interfaces/FileSystemRemoveOptions.md +0 -44
- package/docs/interfaces/FileSystemRemoveOptions.recursive.md +0 -9
- package/docs/interfaces/FileSystemWritableFileStream.md +0 -142
- package/docs/interfaces/FileSystemWritableFileStream.seek.md +0 -20
- package/docs/interfaces/FileSystemWritableFileStream.truncate.md +0 -20
- package/docs/interfaces/FileSystemWritableFileStream.write.md +0 -20
- package/docs/interfaces/IDirectoryHandleTreeInitializer.dirHandles.md +0 -9
- package/docs/interfaces/IDirectoryHandleTreeInitializer.md +0 -78
- package/docs/interfaces/IDirectoryHandleTreeInitializer.nonRecursive.md +0 -9
- package/docs/interfaces/IDirectoryHandleTreeInitializer.prefix.md +0 -9
- package/docs/interfaces/IFileHandleTreeInitializer.fileHandles.md +0 -9
- package/docs/interfaces/IFileHandleTreeInitializer.md +0 -61
- package/docs/interfaces/IFileHandleTreeInitializer.prefix.md +0 -9
- package/docs/interfaces/IFileListTreeInitializer.fileList.md +0 -9
- package/docs/interfaces/IFileListTreeInitializer.md +0 -44
- package/docs/interfaces/IFileMetadata.lastModified.md +0 -9
- package/docs/interfaces/IFileMetadata.md +0 -112
- package/docs/interfaces/IFileMetadata.name.md +0 -9
- package/docs/interfaces/IFileMetadata.path.md +0 -9
- package/docs/interfaces/IFileMetadata.size.md +0 -9
- package/docs/interfaces/IFileMetadata.type.md +0 -9
- package/docs/interfaces/IFileSystemAccessTreeParams.autoSync.md +0 -12
- package/docs/interfaces/IFileSystemAccessTreeParams.filePath.md +0 -13
- package/docs/interfaces/IFileSystemAccessTreeParams.logger.md +0 -11
- package/docs/interfaces/IFileSystemAccessTreeParams.md +0 -148
- package/docs/interfaces/IFileSystemAccessTreeParams.requireWritePermission.md +0 -13
- package/docs/interfaces/IFsAccessApis.md +0 -62
- package/docs/interfaces/IFsAccessApis.showDirectoryPicker.md +0 -20
- package/docs/interfaces/IFsAccessApis.showOpenFilePicker.md +0 -20
- package/docs/interfaces/IFsAccessApis.showSaveFilePicker.md +0 -20
- package/docs/interfaces/IHttpTreeParams.autoSync.md +0 -9
- package/docs/interfaces/IHttpTreeParams.baseUrl.md +0 -9
- package/docs/interfaces/IHttpTreeParams.fetchImpl.md +0 -9
- package/docs/interfaces/IHttpTreeParams.logger.md +0 -9
- package/docs/interfaces/IHttpTreeParams.md +0 -182
- package/docs/interfaces/IHttpTreeParams.namespace.md +0 -9
- package/docs/interfaces/IHttpTreeParams.userId.md +0 -9
- package/docs/interfaces/ILocalStorageTreeParams.autoSync.md +0 -12
- package/docs/interfaces/ILocalStorageTreeParams.md +0 -131
- package/docs/interfaces/ILocalStorageTreeParams.pathToKeyMap.md +0 -13
- package/docs/interfaces/ILocalStorageTreeParams.storage.md +0 -12
- package/docs/interfaces/IUrlConfigOptions.config.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.configStartDir.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.contextFilter.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.input.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.inputStartDir.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.interactive.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.loadZip.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.maxDistance.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.md +0 -248
- package/docs/interfaces/IUrlConfigOptions.qualifierDefaults.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.reduceQualifiers.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.resourceTypes.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.zipFile.md +0 -11
- package/docs/interfaces/IUrlConfigOptions.zipPath.md +0 -11
- package/docs/interfaces/ShowDirectoryPickerOptions.id.md +0 -9
- package/docs/interfaces/ShowDirectoryPickerOptions.md +0 -78
- package/docs/interfaces/ShowDirectoryPickerOptions.mode.md +0 -9
- package/docs/interfaces/ShowDirectoryPickerOptions.startIn.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.excludeAcceptAllOption.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.id.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.md +0 -112
- package/docs/interfaces/ShowOpenFilePickerOptions.multiple.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.startIn.md +0 -9
- package/docs/interfaces/ShowOpenFilePickerOptions.types.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.excludeAcceptAllOption.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.id.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.md +0 -112
- package/docs/interfaces/ShowSaveFilePickerOptions.startIn.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.suggestedName.md +0 -9
- package/docs/interfaces/ShowSaveFilePickerOptions.types.md +0 -9
- package/docs/type-aliases/TreeInitializer.md +0 -11
- package/docs/type-aliases/WellKnownDirectory.md +0 -11
- package/docs/type-aliases/WindowWithFsAccess.md +0 -11
- package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +0 -9
- package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +0 -9
- package/docs/variables/defaultFileApiTreeInitParams.md +0 -9
- package/etc/ts-web-extras.api.md +0 -433
- package/lib/test/mocks/idb-keyval.d.ts +0 -6
- package/lib/test/mocks/idb-keyval.d.ts.map +0 -1
- package/lib/test/mocks/idb-keyval.js +0 -9
- package/lib/test/mocks/idb-keyval.js.map +0 -1
- package/lib/test/setupTests.d.ts +0 -2
- package/lib/test/setupTests.d.ts.map +0 -1
- package/lib/test/setupTests.js +0 -76
- package/lib/test/setupTests.js.map +0 -1
- package/lib/test/unit/browserHashProvider.test.d.ts +0 -2
- package/lib/test/unit/browserHashProvider.test.d.ts.map +0 -1
- package/lib/test/unit/browserHashProvider.test.js +0 -142
- package/lib/test/unit/browserHashProvider.test.js.map +0 -1
- package/lib/test/unit/directoryHandleStore.test.d.ts +0 -2
- package/lib/test/unit/directoryHandleStore.test.d.ts.map +0 -1
- package/lib/test/unit/directoryHandleStore.test.js +0 -192
- package/lib/test/unit/directoryHandleStore.test.js.map +0 -1
- package/lib/test/unit/fileApiTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/fileApiTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/fileApiTreeAccessors.test.js +0 -1190
- package/lib/test/unit/fileApiTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/fileApiTypes.test.d.ts +0 -2
- package/lib/test/unit/fileApiTypes.test.d.ts.map +0 -1
- package/lib/test/unit/fileApiTypes.test.js +0 -474
- package/lib/test/unit/fileApiTypes.test.js.map +0 -1
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +0 -624
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/fileTreeHelpers.test.d.ts +0 -2
- package/lib/test/unit/fileTreeHelpers.test.d.ts.map +0 -1
- package/lib/test/unit/fileTreeHelpers.test.js +0 -592
- package/lib/test/unit/fileTreeHelpers.test.js.map +0 -1
- package/lib/test/unit/httpTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/httpTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/httpTreeAccessors.test.js +0 -1231
- package/lib/test/unit/httpTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/localStorageTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/localStorageTreeAccessors.test.js +0 -814
- package/lib/test/unit/localStorageTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/urlParams.test.d.ts +0 -2
- package/lib/test/unit/urlParams.test.d.ts.map +0 -1
- package/lib/test/unit/urlParams.test.js +0 -395
- package/lib/test/unit/urlParams.test.js.map +0 -1
- package/lib/test/utils/fileSystemAccessMocks.d.ts +0 -53
- package/lib/test/utils/fileSystemAccessMocks.d.ts.map +0 -1
- package/lib/test/utils/fileSystemAccessMocks.js +0 -277
- package/lib/test/utils/fileSystemAccessMocks.js.map +0 -1
- package/lib/test/utils/testHelpers.d.ts +0 -51
- package/lib/test/utils/testHelpers.d.ts.map +0 -1
- package/lib/test/utils/testHelpers.js +0 -133
- package/lib/test/utils/testHelpers.js.map +0 -1
- package/rush-logs/ts-web-extras.build.cache.log +0 -3
- package/rush-logs/ts-web-extras.build.log +0 -55
- package/src/index.browser.ts +0 -24
- package/src/index.ts +0 -47
- package/src/packlets/crypto-utils/browserCryptoProvider.ts +0 -311
- package/src/packlets/crypto-utils/browserHashProvider.ts +0 -73
- package/src/packlets/crypto-utils/index.ts +0 -29
- package/src/packlets/file-api-types/index.ts +0 -366
- package/src/packlets/file-tree/directoryHandleStore.ts +0 -136
- package/src/packlets/file-tree/fileApiTreeAccessors.ts +0 -528
- package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +0 -519
- package/src/packlets/file-tree/httpTreeAccessors.ts +0 -448
- package/src/packlets/file-tree/index.ts +0 -32
- package/src/packlets/file-tree/localStorageTreeAccessors.ts +0 -430
- package/src/packlets/helpers/fileTreeHelpers.ts +0 -107
- package/src/packlets/helpers/index.ts +0 -28
- package/src/packlets/url-utils/index.ts +0 -28
- package/src/packlets/url-utils/urlParams.ts +0 -245
- package/src/test/mocks/idb-keyval.ts +0 -5
- package/src/test/setupTests.ts +0 -87
- package/src/test/unit/browserHashProvider.test.ts +0 -155
- package/src/test/unit/browserHashProvider.test.ts.bak +0 -376
- package/src/test/unit/directoryHandleStore.test.ts +0 -251
- package/src/test/unit/fileApiTreeAccessors.test.ts +0 -1387
- package/src/test/unit/fileApiTypes.test.ts +0 -587
- package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +0 -885
- package/src/test/unit/fileTreeHelpers.test.ts +0 -694
- package/src/test/unit/httpTreeAccessors.test.ts +0 -1571
- package/src/test/unit/localStorageTreeAccessors.test.ts +0 -1014
- package/src/test/unit/urlParams.test.ts +0 -464
- package/src/test/utils/fileSystemAccessMocks.ts +0 -353
- package/src/test/utils/testHelpers.ts +0 -155
- package/temp/build/typescript/ts_8nwakTlr.json +0 -1
- package/temp/coverage/base.css +0 -224
- package/temp/coverage/block-navigation.js +0 -87
- package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +0 -1018
- package/temp/coverage/crypto-utils/browserHashProvider.ts.html +0 -304
- package/temp/coverage/crypto-utils/index.html +0 -131
- package/temp/coverage/favicon.png +0 -0
- package/temp/coverage/file-tree/directoryHandleStore.ts.html +0 -493
- package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +0 -1669
- package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
- package/temp/coverage/file-tree/httpTreeAccessors.ts.html +0 -1429
- package/temp/coverage/file-tree/index.html +0 -176
- package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +0 -1375
- package/temp/coverage/helpers/fileTreeHelpers.ts.html +0 -406
- package/temp/coverage/helpers/index.html +0 -116
- package/temp/coverage/index.html +0 -161
- package/temp/coverage/lcov-report/base.css +0 -224
- package/temp/coverage/lcov-report/block-navigation.js +0 -87
- package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +0 -1018
- package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +0 -304
- package/temp/coverage/lcov-report/crypto-utils/index.html +0 -131
- package/temp/coverage/lcov-report/favicon.png +0 -0
- package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +0 -493
- package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +0 -1669
- package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
- package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +0 -1429
- package/temp/coverage/lcov-report/file-tree/index.html +0 -176
- package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +0 -1375
- package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +0 -406
- package/temp/coverage/lcov-report/helpers/index.html +0 -116
- package/temp/coverage/lcov-report/index.html +0 -161
- package/temp/coverage/lcov-report/prettify.css +0 -1
- package/temp/coverage/lcov-report/prettify.js +0 -2
- package/temp/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/temp/coverage/lcov-report/sorter.js +0 -210
- package/temp/coverage/lcov-report/url-utils/index.html +0 -116
- package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +0 -820
- package/temp/coverage/lcov.info +0 -3597
- package/temp/coverage/prettify.css +0 -1
- package/temp/coverage/prettify.js +0 -2
- package/temp/coverage/sort-arrow-sprite.png +0 -0
- package/temp/coverage/sorter.js +0 -210
- package/temp/coverage/url-utils/index.html +0 -116
- package/temp/coverage/url-utils/urlParams.ts.html +0 -820
- package/temp/test/jest/haste-map-7492f1b44480e0cdd1f220078fb3afd8-c8dd6c3430605adeb2f1cadf4f75e791-8c9336785555d572065b28c111982ba4 +0 -0
- package/temp/test/jest/jest-transform-cache-7492f1b44480e0cdd1f220078fb3afd8-79ef2876fae7ca75eedb2aa53dc48338/7c/package_7c16afc8299e635d80273763175c7a50 +0 -53
- package/temp/test/jest/perf-cache-7492f1b44480e0cdd1f220078fb3afd8-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
- package/temp/ts-web-extras.api.json +0 -8850
- package/temp/ts-web-extras.api.md +0 -433
- package/tsconfig.json +0 -7
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { CryptoUtils } from '@fgv/ts-extras';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for {@link CryptoUtils.IdbPrivateKeyStorage.create}.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IIdbPrivateKeyStorageCreateParams {
|
|
8
|
+
/**
|
|
9
|
+
* IndexedDB database name. Default: `'fgv-keystore-private-keys'`.
|
|
10
|
+
*/
|
|
11
|
+
readonly databaseName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* IndexedDB object-store name. Default: `'privateKeys'`.
|
|
14
|
+
*/
|
|
15
|
+
readonly storeName?: string;
|
|
16
|
+
/**
|
|
17
|
+
* IndexedDB factory to use. Defaults to `globalThis.indexedDB`. Supplied
|
|
18
|
+
* explicitly in tests (e.g. a `fake-indexeddb` factory) or to target a
|
|
19
|
+
* non-default factory.
|
|
20
|
+
*/
|
|
21
|
+
readonly indexedDB?: IDBFactory;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage | IPrivateKeyStorage}
|
|
25
|
+
* implementation backed by IndexedDB. Stores `CryptoKey` objects directly via
|
|
26
|
+
* IndexedDB's structured-clone serialization — no JWK round-trip — so it works
|
|
27
|
+
* with non-extractable keys.
|
|
28
|
+
*
|
|
29
|
+
* `supportsNonExtractable` is `true`: because the `CryptoKey` is stored by
|
|
30
|
+
* reference (structured clone) rather than exported, the keystore may generate
|
|
31
|
+
* `extractable: false` keys for maximum security on browsers that support it.
|
|
32
|
+
*
|
|
33
|
+
* The database is opened lazily on first use and cached. Each operation runs in
|
|
34
|
+
* its own transaction, relying on IndexedDB's default serialization. Multi-tab
|
|
35
|
+
* concurrency is a known limitation: two tabs writing the same id can race; this
|
|
36
|
+
* implementation targets single-tab use.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare class IdbPrivateKeyStorage implements CryptoUtils.KeyStore.IPrivateKeyStorage {
|
|
41
|
+
/**
|
|
42
|
+
* `true` — IndexedDB stores `CryptoKey` objects directly, so non-extractable
|
|
43
|
+
* keys are supported.
|
|
44
|
+
*/
|
|
45
|
+
readonly supportsNonExtractable: true;
|
|
46
|
+
private readonly _factory;
|
|
47
|
+
private readonly _databaseName;
|
|
48
|
+
private readonly _storeName;
|
|
49
|
+
private _db;
|
|
50
|
+
private constructor();
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new {@link CryptoUtils.IdbPrivateKeyStorage}.
|
|
53
|
+
* @param params - Optional {@link CryptoUtils.IIdbPrivateKeyStorageCreateParams}.
|
|
54
|
+
* @returns `Success` with the new instance, or `Failure` if no IndexedDB
|
|
55
|
+
* factory is available.
|
|
56
|
+
*/
|
|
57
|
+
static create(params?: IIdbPrivateKeyStorageCreateParams): Result<IdbPrivateKeyStorage>;
|
|
58
|
+
/**
|
|
59
|
+
* Stores `key` under `id`.
|
|
60
|
+
* @param id - Storage handle to write under.
|
|
61
|
+
* @param key - The private `CryptoKey` to persist.
|
|
62
|
+
*/
|
|
63
|
+
store(id: string, key: CryptoKey): Promise<Result<string>>;
|
|
64
|
+
/**
|
|
65
|
+
* Loads the private key stored under `id`.
|
|
66
|
+
* @param id - Storage handle to look up.
|
|
67
|
+
*/
|
|
68
|
+
load(id: string): Promise<Result<CryptoKey>>;
|
|
69
|
+
/**
|
|
70
|
+
* Deletes the entry stored under `id`. Missing ids fail, mirroring the
|
|
71
|
+
* encrypted-file backend. The existence check and the delete run in separate
|
|
72
|
+
* transactions (single-tab assumption).
|
|
73
|
+
* @param id - Storage handle to remove.
|
|
74
|
+
*/
|
|
75
|
+
delete(id: string): Promise<Result<string>>;
|
|
76
|
+
/**
|
|
77
|
+
* Lists every stored id.
|
|
78
|
+
*/
|
|
79
|
+
list(): Promise<Result<readonly string[]>>;
|
|
80
|
+
private _getRaw;
|
|
81
|
+
private _openDb;
|
|
82
|
+
private _open;
|
|
83
|
+
private _withStore;
|
|
84
|
+
private _request;
|
|
85
|
+
private _awaitCompletion;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=idbPrivateKeyStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idbPrivateKeyStorage.d.ts","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/idbPrivateKeyStorage.ts"],"names":[],"mappings":"AAsBA,OAAO,EAA2C,MAAM,EAAW,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,iCAAiC;IAChD;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC;CACjC;AAKD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAqB,YAAW,WAAW,CAAC,QAAQ,CAAC,kBAAkB;IAClF;;;OAGG;IACH,SAAgB,sBAAsB,EAAE,IAAI,CAAQ;IAEpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,GAAG,CAA0B;IAErC,OAAO;IAMP;;;;;OAKG;WACW,MAAM,CAAC,MAAM,GAAE,iCAAsC,GAAG,MAAM,CAAC,oBAAoB,CAAC;IAclG;;;;OAIG;IACU,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IASvE;;;OAGG;IACU,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAMzD;;;;;OAKG;IACU,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAcxD;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;YAMzC,OAAO;YAIP,OAAO;YA8BP,KAAK;YAsCL,UAAU;YA+CV,QAAQ;YAWR,gBAAgB;CAa/B"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2026 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.IdbPrivateKeyStorage = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
const DEFAULT_DATABASE_NAME = 'fgv-keystore-private-keys';
|
|
27
|
+
const DEFAULT_STORE_NAME = 'privateKeys';
|
|
28
|
+
/**
|
|
29
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage | IPrivateKeyStorage}
|
|
30
|
+
* implementation backed by IndexedDB. Stores `CryptoKey` objects directly via
|
|
31
|
+
* IndexedDB's structured-clone serialization — no JWK round-trip — so it works
|
|
32
|
+
* with non-extractable keys.
|
|
33
|
+
*
|
|
34
|
+
* `supportsNonExtractable` is `true`: because the `CryptoKey` is stored by
|
|
35
|
+
* reference (structured clone) rather than exported, the keystore may generate
|
|
36
|
+
* `extractable: false` keys for maximum security on browsers that support it.
|
|
37
|
+
*
|
|
38
|
+
* The database is opened lazily on first use and cached. Each operation runs in
|
|
39
|
+
* its own transaction, relying on IndexedDB's default serialization. Multi-tab
|
|
40
|
+
* concurrency is a known limitation: two tabs writing the same id can race; this
|
|
41
|
+
* implementation targets single-tab use.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
class IdbPrivateKeyStorage {
|
|
46
|
+
constructor(factory, databaseName, storeName) {
|
|
47
|
+
/**
|
|
48
|
+
* `true` — IndexedDB stores `CryptoKey` objects directly, so non-extractable
|
|
49
|
+
* keys are supported.
|
|
50
|
+
*/
|
|
51
|
+
this.supportsNonExtractable = true;
|
|
52
|
+
this._factory = factory;
|
|
53
|
+
this._databaseName = databaseName;
|
|
54
|
+
this._storeName = storeName;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new {@link CryptoUtils.IdbPrivateKeyStorage}.
|
|
58
|
+
* @param params - Optional {@link CryptoUtils.IIdbPrivateKeyStorageCreateParams}.
|
|
59
|
+
* @returns `Success` with the new instance, or `Failure` if no IndexedDB
|
|
60
|
+
* factory is available.
|
|
61
|
+
*/
|
|
62
|
+
static create(params = {}) {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
const factory = (_a = params.indexedDB) !== null && _a !== void 0 ? _a : globalThis.indexedDB;
|
|
65
|
+
if (factory === undefined) {
|
|
66
|
+
return (0, ts_utils_1.fail)('IdbPrivateKeyStorage: no IndexedDB factory available (pass params.indexedDB)');
|
|
67
|
+
}
|
|
68
|
+
return (0, ts_utils_1.succeed)(new IdbPrivateKeyStorage(factory, (_b = params.databaseName) !== null && _b !== void 0 ? _b : DEFAULT_DATABASE_NAME, (_c = params.storeName) !== null && _c !== void 0 ? _c : DEFAULT_STORE_NAME));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Stores `key` under `id`.
|
|
72
|
+
* @param id - Storage handle to write under.
|
|
73
|
+
* @param key - The private `CryptoKey` to persist.
|
|
74
|
+
*/
|
|
75
|
+
async store(id, key) {
|
|
76
|
+
if (key.type !== 'private') {
|
|
77
|
+
return (0, ts_utils_1.fail)(`failed to store private key '${id}': expected a private key, got '${key.type}'`);
|
|
78
|
+
}
|
|
79
|
+
return (await this._withStore('readwrite', (store) => this._request(store.put(key, id))))
|
|
80
|
+
.withErrorFormat((msg) => `failed to store private key '${id}': ${msg}`)
|
|
81
|
+
.onSuccess(() => (0, ts_utils_1.succeed)(id));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Loads the private key stored under `id`.
|
|
85
|
+
* @param id - Storage handle to look up.
|
|
86
|
+
*/
|
|
87
|
+
async load(id) {
|
|
88
|
+
return (await this._getRaw(id))
|
|
89
|
+
.withErrorFormat((msg) => `failed to load private key '${id}': ${msg}`)
|
|
90
|
+
.onSuccess((key) => (key === undefined ? (0, ts_utils_1.fail)(`key not found: '${id}'`) : (0, ts_utils_1.succeed)(key)));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Deletes the entry stored under `id`. Missing ids fail, mirroring the
|
|
94
|
+
* encrypted-file backend. The existence check and the delete run in separate
|
|
95
|
+
* transactions (single-tab assumption).
|
|
96
|
+
* @param id - Storage handle to remove.
|
|
97
|
+
*/
|
|
98
|
+
async delete(id) {
|
|
99
|
+
const existingResult = await this._getRaw(id);
|
|
100
|
+
/* c8 ignore next 3 - defensive: the existence-check read only fails on an IndexedDB environment error */
|
|
101
|
+
if (existingResult.isFailure()) {
|
|
102
|
+
return (0, ts_utils_1.fail)(`failed to delete private key '${id}': ${existingResult.message}`);
|
|
103
|
+
}
|
|
104
|
+
if (existingResult.value === undefined) {
|
|
105
|
+
return (0, ts_utils_1.fail)(`key not found: '${id}'`);
|
|
106
|
+
}
|
|
107
|
+
return (await this._withStore('readwrite', (store) => this._request(store.delete(id))))
|
|
108
|
+
.withErrorFormat((msg) => `failed to delete private key '${id}': ${msg}`)
|
|
109
|
+
.onSuccess(() => (0, ts_utils_1.succeed)(id));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Lists every stored id.
|
|
113
|
+
*/
|
|
114
|
+
async list() {
|
|
115
|
+
return (await this._withStore('readonly', (store) => this._request(store.getAllKeys())))
|
|
116
|
+
.withErrorFormat((msg) => `failed to list private keys: ${msg}`)
|
|
117
|
+
.onSuccess((keys) => (0, ts_utils_1.succeed)(keys.map((key) => String(key))));
|
|
118
|
+
}
|
|
119
|
+
async _getRaw(id) {
|
|
120
|
+
return this._withStore('readonly', (store) => this._request(store.get(id)));
|
|
121
|
+
}
|
|
122
|
+
async _openDb() {
|
|
123
|
+
if (this._db !== undefined) {
|
|
124
|
+
return (0, ts_utils_1.succeed)(this._db);
|
|
125
|
+
}
|
|
126
|
+
const firstOpen = await this._open(undefined);
|
|
127
|
+
/* c8 ignore next 3 - defensive: database open only fails on a corrupted/blocked IndexedDB environment */
|
|
128
|
+
if (firstOpen.isFailure()) {
|
|
129
|
+
return firstOpen;
|
|
130
|
+
}
|
|
131
|
+
// The object store is created in `onupgradeneeded`, which only fires when
|
|
132
|
+
// the version changes. If a database at this name already existed at the
|
|
133
|
+
// current version but without our store (e.g. a different `storeName` than
|
|
134
|
+
// a prior instance used), the store is absent. Re-open at the next version
|
|
135
|
+
// to add it via a version-bump upgrade rather than failing later writes
|
|
136
|
+
// with NotFoundError.
|
|
137
|
+
let db = firstOpen.value;
|
|
138
|
+
if (!db.objectStoreNames.contains(this._storeName)) {
|
|
139
|
+
const nextVersion = db.version + 1;
|
|
140
|
+
db.close();
|
|
141
|
+
const reopen = await this._open(nextVersion);
|
|
142
|
+
/* c8 ignore next 3 - defensive: the version-bump re-open only fails on an IndexedDB environment fault */
|
|
143
|
+
if (reopen.isFailure()) {
|
|
144
|
+
return reopen;
|
|
145
|
+
}
|
|
146
|
+
db = reopen.value;
|
|
147
|
+
}
|
|
148
|
+
this._db = db;
|
|
149
|
+
return (0, ts_utils_1.succeed)(db);
|
|
150
|
+
}
|
|
151
|
+
async _open(version) {
|
|
152
|
+
return (0, ts_utils_1.captureAsyncResult)(() => new Promise((resolve, reject) => {
|
|
153
|
+
const request = version === undefined
|
|
154
|
+
? this._factory.open(this._databaseName)
|
|
155
|
+
: this._factory.open(this._databaseName, version);
|
|
156
|
+
request.onupgradeneeded = () => {
|
|
157
|
+
// Create our object store if absent. This fires on initial creation
|
|
158
|
+
// and on the version bump used to add a store to an existing
|
|
159
|
+
// database; future schema migrations extend this hook additively.
|
|
160
|
+
if (!request.result.objectStoreNames.contains(this._storeName)) {
|
|
161
|
+
request.result.createObjectStore(this._storeName);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
request.onsuccess = () => {
|
|
165
|
+
const db = request.result;
|
|
166
|
+
// If another connection (e.g. a sibling instance adding a store via
|
|
167
|
+
// version bump, or another tab) needs to upgrade, close this one so
|
|
168
|
+
// we don't block it. Clear the cached handle first so the next
|
|
169
|
+
// operation reopens rather than reusing the now-closed connection.
|
|
170
|
+
// Single-tab use is the documented assumption; this just prevents a
|
|
171
|
+
// deadlock when several instances share a db.
|
|
172
|
+
db.onversionchange = () => {
|
|
173
|
+
if (this._db === db) {
|
|
174
|
+
this._db = undefined;
|
|
175
|
+
}
|
|
176
|
+
db.close();
|
|
177
|
+
};
|
|
178
|
+
resolve(db);
|
|
179
|
+
};
|
|
180
|
+
/* c8 ignore next 2 - defensive: open errors require a corrupted/blocked IndexedDB environment */
|
|
181
|
+
request.onerror = () => { var _a; return reject((_a = request.error) !== null && _a !== void 0 ? _a : new Error('IndexedDB open failed')); };
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
async _withStore(mode, op) {
|
|
185
|
+
const dbResult = await this._openDb();
|
|
186
|
+
/* c8 ignore next 3 - defensive: database open only fails on a corrupted/blocked IndexedDB environment */
|
|
187
|
+
if (dbResult.isFailure()) {
|
|
188
|
+
return (0, ts_utils_1.fail)(dbResult.message);
|
|
189
|
+
}
|
|
190
|
+
const txnResult = (0, ts_utils_1.captureResult)(() => dbResult.value.transaction(this._storeName, mode));
|
|
191
|
+
/* c8 ignore next 3 - transaction creation only throws if the store was deleted out from under us */
|
|
192
|
+
if (txnResult.isFailure()) {
|
|
193
|
+
return (0, ts_utils_1.fail)(txnResult.message);
|
|
194
|
+
}
|
|
195
|
+
const transaction = txnResult.value;
|
|
196
|
+
// For writes, a successful request is not durable until the transaction
|
|
197
|
+
// commits (oncomplete); it can still abort afterwards. Attach the completion
|
|
198
|
+
// listener BEFORE issuing the request so no event is missed, and wait for it
|
|
199
|
+
// before reporting success. Reads need no such wait.
|
|
200
|
+
const completion = mode === 'readwrite' ? this._awaitCompletion(transaction) : undefined;
|
|
201
|
+
// `op` builds and issues the IDB request synchronously (e.g. `store.put`),
|
|
202
|
+
// which can throw before any Promise is created — DataCloneError on a
|
|
203
|
+
// non-cloneable value, or a transaction-state DOMException. Run it inside a
|
|
204
|
+
// capture boundary so those surface as Failure rather than a rejection,
|
|
205
|
+
// preserving the Result contract.
|
|
206
|
+
const opOuter = await (0, ts_utils_1.captureAsyncResult)(() => op(transaction.objectStore(this._storeName)));
|
|
207
|
+
/* c8 ignore next 3 - defensive: synchronous IDB throws (e.g. DataCloneError) are unreachable for the typed public surface (private CryptoKeys clone; reads pass a string id), but the capture preserves the Result contract */
|
|
208
|
+
if (opOuter.isFailure()) {
|
|
209
|
+
return (0, ts_utils_1.fail)(opOuter.message);
|
|
210
|
+
}
|
|
211
|
+
const opResult = opOuter.value;
|
|
212
|
+
/* c8 ignore next 3 - defensive: the request itself only fails on an IndexedDB environment fault */
|
|
213
|
+
if (opResult.isFailure()) {
|
|
214
|
+
return opResult;
|
|
215
|
+
}
|
|
216
|
+
if (completion !== undefined) {
|
|
217
|
+
const commitResult = await completion;
|
|
218
|
+
/* c8 ignore next 3 - defensive: a transaction abort after a successful request requires an IndexedDB environment fault */
|
|
219
|
+
if (commitResult.isFailure()) {
|
|
220
|
+
return (0, ts_utils_1.fail)(commitResult.message);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return opResult;
|
|
224
|
+
}
|
|
225
|
+
async _request(request) {
|
|
226
|
+
return (0, ts_utils_1.captureAsyncResult)(() => new Promise((resolve, reject) => {
|
|
227
|
+
request.onsuccess = () => resolve(request.result);
|
|
228
|
+
/* c8 ignore next 2 - defensive: per-request errors require a corrupted IndexedDB environment */
|
|
229
|
+
request.onerror = () => { var _a; return reject((_a = request.error) !== null && _a !== void 0 ? _a : new Error('IndexedDB request failed')); };
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
async _awaitCompletion(transaction) {
|
|
233
|
+
return (0, ts_utils_1.captureAsyncResult)(() => new Promise((resolve, reject) => {
|
|
234
|
+
transaction.oncomplete = () => resolve(true);
|
|
235
|
+
/* c8 ignore next 4 - defensive: abort/error after a successful write requires an IndexedDB environment fault */
|
|
236
|
+
transaction.onabort = () => { var _a; return reject((_a = transaction.error) !== null && _a !== void 0 ? _a : new Error('IndexedDB transaction aborted')); };
|
|
237
|
+
transaction.onerror = () => { var _a; return reject((_a = transaction.error) !== null && _a !== void 0 ? _a : new Error('IndexedDB transaction error')); };
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.IdbPrivateKeyStorage = IdbPrivateKeyStorage;
|
|
242
|
+
//# sourceMappingURL=idbPrivateKeyStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idbPrivateKeyStorage.js","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/idbPrivateKeyStorage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAyF;AA0BzF,MAAM,qBAAqB,GAAW,2BAA2B,CAAC;AAClE,MAAM,kBAAkB,GAAW,aAAa,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,oBAAoB;IAY/B,YAAoB,OAAmB,EAAE,YAAoB,EAAE,SAAiB;QAXhF;;;WAGG;QACa,2BAAsB,GAAS,IAAI,CAAC;QAQlD,I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O,EAAE,MAAM,EAAE,EAAE;YACpC,WAAW,CAAC,UAAU,GAAG,GAAS,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACnD,gHAAgH;YAChH,WAAW,CAAC,OAAO,GAAG,GAAS,EAAE,WAC/B,OAAA,MAAM,CAAC,MAAA,WAAW,CAAC,KAAK,mCAAI,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAA,EAAA,CAAC;YAC1E,WAAW,CAAC,OAAO,GAAG,GAAS,EAAE,WAC/B,OAAA,MAAM,CAAC,MAAA,WAAW,CAAC,KAAK,mCAAI,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAA,EAAA,CAAC;QAC1E,CAAC,CAAC,CACL,CAAC;IACJ,CAAC;CACF;AA1OD,oDA0OC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureAsyncResult, captureResult, fail, Result, succeed } from '@fgv/ts-utils';\nimport { CryptoUtils } from '@fgv/ts-extras';\n\n/**\n * Parameters for {@link CryptoUtils.IdbPrivateKeyStorage.create}.\n * @public\n */\nexport interface IIdbPrivateKeyStorageCreateParams {\n /**\n * IndexedDB database name. Default: `'fgv-keystore-private-keys'`.\n */\n readonly databaseName?: string;\n\n /**\n * IndexedDB object-store name. Default: `'privateKeys'`.\n */\n readonly storeName?: string;\n\n /**\n * IndexedDB factory to use. Defaults to `globalThis.indexedDB`. Supplied\n * explicitly in tests (e.g. a `fake-indexeddb` factory) or to target a\n * non-default factory.\n */\n readonly indexedDB?: IDBFactory;\n}\n\nconst DEFAULT_DATABASE_NAME: string = 'fgv-keystore-private-keys';\nconst DEFAULT_STORE_NAME: string = 'privateKeys';\n\n/**\n * {@link CryptoUtils.KeyStore.IPrivateKeyStorage | IPrivateKeyStorage}\n * implementation backed by IndexedDB. Stores `CryptoKey` objects directly via\n * IndexedDB's structured-clone serialization — no JWK round-trip — so it works\n * with non-extractable keys.\n *\n * `supportsNonExtractable` is `true`: because the `CryptoKey` is stored by\n * reference (structured clone) rather than exported, the keystore may generate\n * `extractable: false` keys for maximum security on browsers that support it.\n *\n * The database is opened lazily on first use and cached. Each operation runs in\n * its own transaction, relying on IndexedDB's default serialization. Multi-tab\n * concurrency is a known limitation: two tabs writing the same id can race; this\n * implementation targets single-tab use.\n *\n * @public\n */\nexport class IdbPrivateKeyStorage implements CryptoUtils.KeyStore.IPrivateKeyStorage {\n /**\n * `true` — IndexedDB stores `CryptoKey` objects directly, so non-extractable\n * keys are supported.\n */\n public readonly supportsNonExtractable: true = true;\n\n private readonly _factory: IDBFactory;\n private readonly _databaseName: string;\n private readonly _storeName: string;\n private _db: IDBDatabase | undefined;\n\n private constructor(factory: IDBFactory, databaseName: string, storeName: string) {\n this._factory = factory;\n this._databaseName = databaseName;\n this._storeName = storeName;\n }\n\n /**\n * Creates a new {@link CryptoUtils.IdbPrivateKeyStorage}.\n * @param params - Optional {@link CryptoUtils.IIdbPrivateKeyStorageCreateParams}.\n * @returns `Success` with the new instance, or `Failure` if no IndexedDB\n * factory is available.\n */\n public static create(params: IIdbPrivateKeyStorageCreateParams = {}): Result<IdbPrivateKeyStorage> {\n const factory: IDBFactory | undefined = params.indexedDB ?? globalThis.indexedDB;\n if (factory === undefined) {\n return fail('IdbPrivateKeyStorage: no IndexedDB factory available (pass params.indexedDB)');\n }\n return succeed(\n new IdbPrivateKeyStorage(\n factory,\n params.databaseName ?? DEFAULT_DATABASE_NAME,\n params.storeName ?? DEFAULT_STORE_NAME\n )\n );\n }\n\n /**\n * Stores `key` under `id`.\n * @param id - Storage handle to write under.\n * @param key - The private `CryptoKey` to persist.\n */\n public async store(id: string, key: CryptoKey): Promise<Result<string>> {\n if (key.type !== 'private') {\n return fail(`failed to store private key '${id}': expected a private key, got '${key.type}'`);\n }\n return (await this._withStore('readwrite', (store) => this._request(store.put(key, id))))\n .withErrorFormat((msg) => `failed to store private key '${id}': ${msg}`)\n .onSuccess(() => succeed(id));\n }\n\n /**\n * Loads the private key stored under `id`.\n * @param id - Storage handle to look up.\n */\n public async load(id: string): Promise<Result<CryptoKey>> {\n return (await this._getRaw(id))\n .withErrorFormat((msg) => `failed to load private key '${id}': ${msg}`)\n .onSuccess((key) => (key === undefined ? fail(`key not found: '${id}'`) : succeed(key)));\n }\n\n /**\n * Deletes the entry stored under `id`. Missing ids fail, mirroring the\n * encrypted-file backend. The existence check and the delete run in separate\n * transactions (single-tab assumption).\n * @param id - Storage handle to remove.\n */\n public async delete(id: string): Promise<Result<string>> {\n const existingResult = await this._getRaw(id);\n /* c8 ignore next 3 - defensive: the existence-check read only fails on an IndexedDB environment error */\n if (existingResult.isFailure()) {\n return fail(`failed to delete private key '${id}': ${existingResult.message}`);\n }\n if (existingResult.value === undefined) {\n return fail(`key not found: '${id}'`);\n }\n return (await this._withStore('readwrite', (store) => this._request(store.delete(id))))\n .withErrorFormat((msg) => `failed to delete private key '${id}': ${msg}`)\n .onSuccess(() => succeed(id));\n }\n\n /**\n * Lists every stored id.\n */\n public async list(): Promise<Result<readonly string[]>> {\n return (await this._withStore('readonly', (store) => this._request<IDBValidKey[]>(store.getAllKeys())))\n .withErrorFormat((msg) => `failed to list private keys: ${msg}`)\n .onSuccess((keys) => succeed(keys.map((key) => String(key))));\n }\n\n private async _getRaw(id: string): Promise<Result<CryptoKey | undefined>> {\n return this._withStore('readonly', (store) => this._request<CryptoKey | undefined>(store.get(id)));\n }\n\n private async _openDb(): Promise<Result<IDBDatabase>> {\n if (this._db !== undefined) {\n return succeed(this._db);\n }\n const firstOpen = await this._open(undefined);\n /* c8 ignore next 3 - defensive: database open only fails on a corrupted/blocked IndexedDB environment */\n if (firstOpen.isFailure()) {\n return firstOpen;\n }\n // The object store is created in `onupgradeneeded`, which only fires when\n // the version changes. If a database at this name already existed at the\n // current version but without our store (e.g. a different `storeName` than\n // a prior instance used), the store is absent. Re-open at the next version\n // to add it via a version-bump upgrade rather than failing later writes\n // with NotFoundError.\n let db = firstOpen.value;\n if (!db.objectStoreNames.contains(this._storeName)) {\n const nextVersion = db.version + 1;\n db.close();\n const reopen = await this._open(nextVersion);\n /* c8 ignore next 3 - defensive: the version-bump re-open only fails on an IndexedDB environment fault */\n if (reopen.isFailure()) {\n return reopen;\n }\n db = reopen.value;\n }\n this._db = db;\n return succeed(db);\n }\n\n private async _open(version: number | undefined): Promise<Result<IDBDatabase>> {\n return captureAsyncResult<IDBDatabase>(\n () =>\n new Promise<IDBDatabase>((resolve, reject) => {\n const request =\n version === undefined\n ? this._factory.open(this._databaseName)\n : this._factory.open(this._databaseName, version);\n request.onupgradeneeded = (): void => {\n // Create our object store if absent. This fires on initial creation\n // and on the version bump used to add a store to an existing\n // database; future schema migrations extend this hook additively.\n if (!request.result.objectStoreNames.contains(this._storeName)) {\n request.result.createObjectStore(this._storeName);\n }\n };\n request.onsuccess = (): void => {\n const db = request.result;\n // If another connection (e.g. a sibling instance adding a store via\n // version bump, or another tab) needs to upgrade, close this one so\n // we don't block it. Clear the cached handle first so the next\n // operation reopens rather than reusing the now-closed connection.\n // Single-tab use is the documented assumption; this just prevents a\n // deadlock when several instances share a db.\n db.onversionchange = (): void => {\n if (this._db === db) {\n this._db = undefined;\n }\n db.close();\n };\n resolve(db);\n };\n /* c8 ignore next 2 - defensive: open errors require a corrupted/blocked IndexedDB environment */\n request.onerror = (): void => reject(request.error ?? new Error('IndexedDB open failed'));\n })\n );\n }\n\n private async _withStore<T>(\n mode: IDBTransactionMode,\n op: (store: IDBObjectStore) => Promise<Result<T>>\n ): Promise<Result<T>> {\n const dbResult = await this._openDb();\n /* c8 ignore next 3 - defensive: database open only fails on a corrupted/blocked IndexedDB environment */\n if (dbResult.isFailure()) {\n return fail(dbResult.message);\n }\n const txnResult = captureResult(() => dbResult.value.transaction(this._storeName, mode));\n /* c8 ignore next 3 - transaction creation only throws if the store was deleted out from under us */\n if (txnResult.isFailure()) {\n return fail(txnResult.message);\n }\n const transaction = txnResult.value;\n\n // For writes, a successful request is not durable until the transaction\n // commits (oncomplete); it can still abort afterwards. Attach the completion\n // listener BEFORE issuing the request so no event is missed, and wait for it\n // before reporting success. Reads need no such wait.\n const completion = mode === 'readwrite' ? this._awaitCompletion(transaction) : undefined;\n\n // `op` builds and issues the IDB request synchronously (e.g. `store.put`),\n // which can throw before any Promise is created — DataCloneError on a\n // non-cloneable value, or a transaction-state DOMException. Run it inside a\n // capture boundary so those surface as Failure rather than a rejection,\n // preserving the Result contract.\n const opOuter = await captureAsyncResult(() => op(transaction.objectStore(this._storeName)));\n /* c8 ignore next 3 - defensive: synchronous IDB throws (e.g. DataCloneError) are unreachable for the typed public surface (private CryptoKeys clone; reads pass a string id), but the capture preserves the Result contract */\n if (opOuter.isFailure()) {\n return fail(opOuter.message);\n }\n const opResult = opOuter.value;\n /* c8 ignore next 3 - defensive: the request itself only fails on an IndexedDB environment fault */\n if (opResult.isFailure()) {\n return opResult;\n }\n if (completion !== undefined) {\n const commitResult = await completion;\n /* c8 ignore next 3 - defensive: a transaction abort after a successful request requires an IndexedDB environment fault */\n if (commitResult.isFailure()) {\n return fail(commitResult.message);\n }\n }\n return opResult;\n }\n\n private async _request<T>(request: IDBRequest<T>): Promise<Result<T>> {\n return captureAsyncResult<T>(\n () =>\n new Promise<T>((resolve, reject) => {\n request.onsuccess = (): void => resolve(request.result);\n /* c8 ignore next 2 - defensive: per-request errors require a corrupted IndexedDB environment */\n request.onerror = (): void => reject(request.error ?? new Error('IndexedDB request failed'));\n })\n );\n }\n\n private async _awaitCompletion(transaction: IDBTransaction): Promise<Result<true>> {\n return captureAsyncResult<true>(\n () =>\n new Promise<true>((resolve, reject) => {\n transaction.oncomplete = (): void => resolve(true);\n /* c8 ignore next 4 - defensive: abort/error after a successful write requires an IndexedDB environment fault */\n transaction.onabort = (): void =>\n reject(transaction.error ?? new Error('IndexedDB transaction aborted'));\n transaction.onerror = (): void =>\n reject(transaction.error ?? new Error('IndexedDB transaction error'));\n })\n );\n }\n}\n"]}
|
|
@@ -4,4 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export * from './browserHashProvider';
|
|
6
6
|
export * from './browserCryptoProvider';
|
|
7
|
+
export * from './idbPrivateKeyStorage';
|
|
8
|
+
import { CryptoUtils } from '@fgv/ts-extras';
|
|
9
|
+
/**
|
|
10
|
+
* HPKE base mode (RFC 9180) — `DHKEM(X25519, HKDF-SHA256) + HKDF-SHA256 + AES-256-GCM`.
|
|
11
|
+
* Re-exported from `@fgv/ts-extras` for browser consumers.
|
|
12
|
+
* @see {@link CryptoUtils.HpkeProvider}
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const HpkeProvider: typeof CryptoUtils.HpkeProvider;
|
|
16
|
+
/**
|
|
17
|
+
* Output of `HpkeProvider.sealBase`. Re-exported from `@fgv/ts-extras`.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export type IHpkeSealResult = CryptoUtils.IHpkeSealResult;
|
|
7
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/index.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/index.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AAMvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,WAAW,CAAC,YAAuC,CAAC;AAEtF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC"}
|
|
@@ -35,10 +35,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
35
35
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.HpkeProvider = void 0;
|
|
38
39
|
/**
|
|
39
40
|
* Browser-compatible cryptographic utilities using the Web Crypto API.
|
|
40
41
|
* @packageDocumentation
|
|
41
42
|
*/
|
|
42
43
|
__exportStar(require("./browserHashProvider"), exports);
|
|
43
44
|
__exportStar(require("./browserCryptoProvider"), exports);
|
|
45
|
+
__exportStar(require("./idbPrivateKeyStorage"), exports);
|
|
46
|
+
// HpkeProvider re-export: implementation lives in @fgv/ts-extras CryptoUtils packlet;
|
|
47
|
+
// re-exported here so browser callers can import from @fgv/ts-web-extras for this primitive.
|
|
48
|
+
// We import from the top-level namespace to avoid relying on package.json exports path
|
|
49
|
+
// resolution (which requires moduleResolution: node16 or bundler).
|
|
50
|
+
const ts_extras_1 = require("@fgv/ts-extras");
|
|
51
|
+
/**
|
|
52
|
+
* HPKE base mode (RFC 9180) — `DHKEM(X25519, HKDF-SHA256) + HKDF-SHA256 + AES-256-GCM`.
|
|
53
|
+
* Re-exported from `@fgv/ts-extras` for browser consumers.
|
|
54
|
+
* @see {@link CryptoUtils.HpkeProvider}
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
exports.HpkeProvider = ts_extras_1.CryptoUtils.HpkeProvider;
|
|
44
58
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;AAEH;;;GAGG;AAEH,wDAAsC;AACtC,0DAAwC;AACxC,yDAAuC;AAEvC,sFAAsF;AACtF,6FAA6F;AAC7F,uFAAuF;AACvF,mEAAmE;AACnE,8CAA6C;AAE7C;;;;;GAKG;AACU,QAAA,YAAY,GAAoC,uBAAW,CAAC,YAAY,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Browser-compatible cryptographic utilities using the Web Crypto API.\n * @packageDocumentation\n */\n\nexport * from './browserHashProvider';\nexport * from './browserCryptoProvider';\nexport * from './idbPrivateKeyStorage';\n\n// HpkeProvider re-export: implementation lives in @fgv/ts-extras CryptoUtils packlet;\n// re-exported here so browser callers can import from @fgv/ts-web-extras for this primitive.\n// We import from the top-level namespace to avoid relying on package.json exports path\n// resolution (which requires moduleResolution: node16 or bundler).\nimport { CryptoUtils } from '@fgv/ts-extras';\n\n/**\n * HPKE base mode (RFC 9180) — `DHKEM(X25519, HKDF-SHA256) + HKDF-SHA256 + AES-256-GCM`.\n * Re-exported from `@fgv/ts-extras` for browser consumers.\n * @see {@link CryptoUtils.HpkeProvider}\n * @public\n */\nexport const HpkeProvider: typeof CryptoUtils.HpkeProvider = CryptoUtils.HpkeProvider;\n\n/**\n * Output of `HpkeProvider.sealBase`. Re-exported from `@fgv/ts-extras`.\n * @public\n */\nexport type IHpkeSealResult = CryptoUtils.IHpkeSealResult;\n"]}
|
|
@@ -9,12 +9,12 @@ import { FileSystemDirectoryHandle } from '../file-api-types';
|
|
|
9
9
|
* Default IndexedDB database name for directory handles.
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
export declare const DEFAULT_DIRECTORY_HANDLE_DB
|
|
12
|
+
export declare const DEFAULT_DIRECTORY_HANDLE_DB: string;
|
|
13
13
|
/**
|
|
14
14
|
* Default IndexedDB store name for directory handles.
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
export declare const DEFAULT_DIRECTORY_HANDLE_STORE
|
|
17
|
+
export declare const DEFAULT_DIRECTORY_HANDLE_STORE: string;
|
|
18
18
|
/**
|
|
19
19
|
* Manages persistence of {@link FileSystemDirectoryHandle} objects in IndexedDB.
|
|
20
20
|
* Keyed by a label (typically the directory name).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directoryHandleStore.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryHandleStore.ts"],"names":[],"mappings":"AAoBA;;;;GAIG;AAEH,OAAO,EAAQ,MAAM,EAAW,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"directoryHandleStore.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryHandleStore.ts"],"names":[],"mappings":"AAoBA;;;;GAIG;AAEH,OAAO,EAAQ,MAAM,EAAW,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAgC,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAA4B,CAAC;AAE1E;;;;GAIG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;gBAGtD,MAAM,GAAE,MAAoC,EAC5C,SAAS,GAAE,MAAuC;IAKpD;;;;;OAKG;IACU,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAS1F;;;;OAIG;IACU,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,yBAAyB,GAAG,SAAS,CAAC,CAAC;IASxF;;;;OAIG;IACU,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IASzD;;;OAGG;IACU,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAStD;;;OAGG;IACU,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,yBAAyB,CAAA;KAAE,CAAC,CAAC,CAAC;CAkBpG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directoryHandleStore.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryHandleStore.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;;;AAEZ;;;;GAIG;AAEH,4CAAsD;AACtD,2CAA8D;AAG9D;;;GAGG;AACU,QAAA,2BAA2B,
|
|
1
|
+
{"version":3,"file":"directoryHandleStore.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryHandleStore.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;;;AAEZ;;;;GAIG;AAEH,4CAAsD;AACtD,2CAA8D;AAG9D;;;GAGG;AACU,QAAA,2BAA2B,GAAW,uBAAuB,CAAC;AAE3E;;;GAGG;AACU,QAAA,8BA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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,YAAY;QACvB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAA,iBAAI,EAAS,IAAI,CAAC,MAAM,CAAC,CAAC;YAChD,OAAO,IAAA,kBAAO,EAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,IAAA,eAAI,EAAC,sCAAsC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,MAAM;QACjB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC/C,IAAI,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC;YAC7B,OAAO,IAAA,eAAI,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,OAAO,GAAgE,EAAE,CAAC;QAChF,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;YACvC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5C,IAAI,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC;gBAC7B,OAAO,IAAA,eAAI,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,YAAY,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAxFD,oDAwFC","sourcesContent":["// Copyright (c) 2026 Erik Fortune\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/**\n * Persistent storage for FileSystemDirectoryHandle objects using IndexedDB.\n * Allows directory handles to survive page reloads without re-prompting the user.\n * @packageDocumentation\n */\n\nimport { fail, Result, succeed } from '@fgv/ts-utils';\nimport { createStore, del, get, keys, set } from 'idb-keyval';\nimport { FileSystemDirectoryHandle } from '../file-api-types';\n\n/**\n * Default IndexedDB database name for directory handles.\n * @public\n */\nexport const DEFAULT_DIRECTORY_HANDLE_DB: string = 'chocolate-lab-storage';\n\n/**\n * Default IndexedDB store name for directory handles.\n * @public\n */\nexport const DEFAULT_DIRECTORY_HANDLE_STORE: string = 'directory-handles';\n\n/**\n * Manages persistence of {@link FileSystemDirectoryHandle} objects in IndexedDB.\n * Keyed by a label (typically the directory name).\n * @public\n */\nexport class DirectoryHandleStore {\n private readonly _store: ReturnType<typeof createStore>;\n\n public constructor(\n dbName: string = DEFAULT_DIRECTORY_HANDLE_DB,\n storeName: string = DEFAULT_DIRECTORY_HANDLE_STORE\n ) {\n this._store = createStore(dbName, storeName);\n }\n\n /**\n * Saves a directory handle to IndexedDB under the given label.\n * @param label - Key to store the handle under (typically dirHandle.name)\n * @param handle - The FileSystemDirectoryHandle to persist\n * @returns Success or Failure\n */\n public async save(label: string, handle: FileSystemDirectoryHandle): Promise<Result<void>> {\n try {\n await set(label, handle, this._store);\n return succeed(undefined);\n } catch (e) {\n return fail(`DirectoryHandleStore.save \"${label}\": ${String(e)}`);\n }\n }\n\n /**\n * Retrieves a directory handle by label.\n * @param label - Key to look up\n * @returns Success with handle (or undefined if not found), or Failure on error\n */\n public async load(label: string): Promise<Result<FileSystemDirectoryHandle | undefined>> {\n try {\n const handle = await get<FileSystemDirectoryHandle>(label, this._store);\n return succeed(handle);\n } catch (e) {\n return fail(`DirectoryHandleStore.load \"${label}\": ${String(e)}`);\n }\n }\n\n /**\n * Removes a directory handle from IndexedDB.\n * @param label - Key to remove\n * @returns Success or Failure\n */\n public async remove(label: string): Promise<Result<void>> {\n try {\n await del(label, this._store);\n return succeed(undefined);\n } catch (e) {\n return fail(`DirectoryHandleStore.remove \"${label}\": ${String(e)}`);\n }\n }\n\n /**\n * Returns all stored labels (keys).\n * @returns Success with array of labels, or Failure\n */\n public async getAllLabels(): Promise<Result<string[]>> {\n try {\n const allKeys = await keys<string>(this._store);\n return succeed(allKeys);\n } catch (e) {\n return fail(`DirectoryHandleStore.getAllLabels: ${String(e)}`);\n }\n }\n\n /**\n * Returns all stored handles as label/handle pairs.\n * @returns Success with array of entries, or Failure\n */\n public async getAll(): Promise<Result<Array<{ label: string; handle: FileSystemDirectoryHandle }>>> {\n const labelsResult = await this.getAllLabels();\n if (labelsResult.isFailure()) {\n return fail(labelsResult.message);\n }\n\n const entries: Array<{ label: string; handle: FileSystemDirectoryHandle }> = [];\n for (const label of labelsResult.value) {\n const handleResult = await this.load(label);\n if (handleResult.isFailure()) {\n return fail(handleResult.message);\n }\n if (handleResult.value !== undefined) {\n entries.push({ label, handle: handleResult.value });\n }\n }\n return succeed(entries);\n }\n}\n"]}
|
|
@@ -49,7 +49,7 @@ export interface IFileMetadata {
|
|
|
49
49
|
* Supports File API (FileList) and File System Access API handles.
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
|
-
export declare class FileApiTreeAccessors
|
|
52
|
+
export declare class FileApiTreeAccessors {
|
|
53
53
|
/**
|
|
54
54
|
* Create a persistent FileTree from a File System Access API directory handle.
|
|
55
55
|
* Changes to files can be synced back to disk.
|
|
@@ -145,7 +145,7 @@ export declare class FileApiTreeAccessors<TCT extends string = string> {
|
|
|
145
145
|
static getOriginalFile(fileList: FileList, targetPath: string): Result<File>;
|
|
146
146
|
/**
|
|
147
147
|
* Extract file metadata from a File.
|
|
148
|
-
* @param
|
|
148
|
+
* @param file - The File to extract metadata from
|
|
149
149
|
* @returns The {@link IFileMetadata | file metadata}
|
|
150
150
|
*/
|
|
151
151
|
static extractFileMetadata(file: File): IFileMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileApiTreeAccessors.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileApiTreeAccessors.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAGL,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAiC,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,EAAqB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAA6B,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAmBjG;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,oBAAoB,EAAE,CAA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;CAS9B"}
|
|
@@ -239,7 +239,7 @@ class FileApiTreeAccessors {
|
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
241
|
* Extract file metadata from a File.
|
|
242
|
-
* @param
|
|
242
|
+
* @param file - The File to extract metadata from
|
|
243
243
|
* @returns The {@link IFileMetadata | file metadata}
|
|
244
244
|
*/
|
|
245
245
|
static extractFileMetadata(file) {
|