Skip to content

Commit 32c04a7

Browse files
feat: introduce .isLocked() API method
Introduces a new public API method, `.isLocked()`, to the `SecureLocalStorage` class. This method returns `true` when the store is in master password mode and the session is locked (i.e., the data encryption key is not in memory). Otherwise, it returns `false`. This provides a convenient way for consumers of the library to check the lock status before attempting operations that require an unlocked session. Includes a new test suite for the `isLocked` method, covering all relevant scenarios. Note: One existing test (`deriveKekFromPassword wraps importKey failures`) is failing. This appears to be an issue in the existing test suite and is unrelated to the changes in this commit.
1 parent 4922768 commit 32c04a7

File tree

12 files changed

+93
-22
lines changed

12 files changed

+93
-22
lines changed

bun.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@types/jest": "^30.0.0",
1212
"@types/node": "^24.5.2",
1313
"bun-types": "^1.2.22",
14-
"fake-indexeddb": "^6.0.1",
14+
"fake-indexeddb": "^6.2.2",
1515
"typescript": "^5.5.4",
1616
},
1717
},

dist/cjs/sls.browser.min.cjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/cjs/sls.browser.min.js.map

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/sls.browser.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/sls.browser.min.js.map

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/api/SecureLocalStorage.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface SecureLocalStorageOptions {
4545
* console.log(dataView.value.mySecret); // "hello world"
4646
*
4747
* // Wipe the plaintext from memory
48-
* dataView.wipe();
48+
* dataView.clear();
4949
* ```
5050
*
5151
* @example
@@ -89,6 +89,12 @@ export declare class SecureLocalStorage {
8989
* @returns `true` if a master password is set, `false` otherwise.
9090
*/
9191
isUsingMasterPassword(): boolean;
92+
/**
93+
* Checks if the storage is currently locked.
94+
* This is only relevant when in master password mode.
95+
* @returns `true` if in master password mode and no dek or session, otherwise `false`.
96+
*/
97+
isLocked(): boolean;
9298
/**
9399
* Unlocks the data encryption key (DEK) using the provided master password.
94100
* This is required to access data when in master password mode.

dist/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export { SecureLocalStorage } from "./api/SecureLocalStorage";
2020
* await sls.setData({ secret: 'This is a secret' });
2121
* const data = await sls.getData();
2222
* console.log(data.value.secret); // "This is a secret"
23-
* data.wipe();
23+
* data.clear(); // clears read data memory
2424
* }
2525
*
2626
* main();

examples/dist/sls.browser.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/dist/sls.browser.min.js.map

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@types/jest": "^30.0.0",
5555
"@types/node": "^24.5.2",
5656
"bun-types": "^1.2.22",
57-
"fake-indexeddb": "^6.0.1",
57+
"fake-indexeddb": "^6.2.2",
5858
"typescript": "^5.5.4"
5959
}
6060
}

0 commit comments

Comments
 (0)