@vacantthinker/firefox-addon-framework-easy 2026.615.1133 → 2026.615.1148

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.
@@ -9,15 +9,19 @@ export declare function stoOpCheck(key: string): Promise<boolean>;
9
9
  * @param key The key to retrieve.
10
10
  * @returns Promise resolving to the stored value or null if not found.
11
11
  */
12
- export declare function stoOpGet<T = any>(key: string): Promise<T | null>;
12
+ export declare function stoOpGet<T>(key: string): Promise<T | null>;
13
13
  /**
14
14
  * Retrieves all items from local storage.
15
15
  * @returns Promise resolving to an object containing all storage items.
16
16
  */
17
- export declare function stoOpGetAll<T = Record<string, any>>(): Promise<T>;
17
+ export declare function stoOpGetAll<T extends Record<string, unknown>>(): Promise<T>;
18
+ /**
19
+ * Clears all data from local storage.
20
+ */
18
21
  export declare function stoOpClear(): Promise<void>;
19
22
  /**
20
23
  * Queries keys that start with a specific prefix.
24
+ * WARNING: This loads all storage into memory. Use sparingly on large datasets.
21
25
  * @param prefix The prefix to filter keys.
22
26
  * @returns Promise resolving to an array of matching keys.
23
27
  */
@@ -25,9 +29,9 @@ export declare function stoOpQueryStartWith(prefix: string): Promise<string[]>;
25
29
  /**
26
30
  * Sets a value in local storage.
27
31
  * @param key The key to set.
28
- * @param value The value to store.
32
+ * @param value The value to store. Must be JSON-serializable.
29
33
  */
30
- export declare function stoOpSet(key: string, value: any): Promise<void>;
34
+ export declare function stoOpSet<T = unknown>(key: string, value: T): Promise<void>;
31
35
  /**
32
36
  * Removes a key from local storage.
33
37
  * @param key The key to remove.
@@ -1 +1 @@
1
- {"version":3,"file":"opStorage.d.ts","sourceRoot":"","sources":["../src/opStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG9D;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,GAA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AAGH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EACxC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,GACP,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D"}
package/dist/opStorage.js CHANGED
@@ -5,16 +5,18 @@
5
5
  */
6
6
  export async function stoOpCheck(key) {
7
7
  const result = await browser.storage.local.get(key);
8
- return key in result;
8
+ // FIX: Protects against prototype pollution (e.g., key = "constructor")
9
+ return Object.prototype.hasOwnProperty.call(result, key);
9
10
  }
10
11
  /**
11
12
  * Retrieves a value from local storage by key.
12
13
  * @param key The key to retrieve.
13
14
  * @returns Promise resolving to the stored value or null if not found.
14
15
  */
16
+ // FIX: Removed default `any`. Forces the caller to specify the expected type.
15
17
  export async function stoOpGet(key) {
16
18
  const result = await browser.storage.local.get(key);
17
- return result[key] !== undefined ?
19
+ return Object.prototype.hasOwnProperty.call(result, key) ?
18
20
  result[key] :
19
21
  null;
20
22
  }
@@ -22,30 +24,50 @@ export async function stoOpGet(key) {
22
24
  * Retrieves all items from local storage.
23
25
  * @returns Promise resolving to an object containing all storage items.
24
26
  */
27
+ // FIX: Narrowed generic constraint to ensure it returns an object structure.
25
28
  export async function stoOpGetAll() {
26
- const result = await browser.storage.local.get();
29
+ const result = await browser.storage.local.get(null); // Explicitly passing
30
+ // null is safer in
31
+ // some MV3 contexts
27
32
  return result;
28
33
  }
34
+ /**
35
+ * Clears all data from local storage.
36
+ */
29
37
  export async function stoOpClear() {
30
38
  await browser.storage.local.clear();
31
39
  }
32
40
  /**
33
41
  * Queries keys that start with a specific prefix.
42
+ * WARNING: This loads all storage into memory. Use sparingly on large datasets.
34
43
  * @param prefix The prefix to filter keys.
35
44
  * @returns Promise resolving to an array of matching keys.
36
45
  */
37
46
  export async function stoOpQueryStartWith(prefix) {
38
- const allItems = await browser.storage.local.get();
39
- return Object.keys(allItems)
40
- .filter((key) => key.startsWith(prefix));
47
+ try {
48
+ const allItems = await browser.storage.local.get(null);
49
+ return Object.keys(allItems).filter((key) => key.startsWith(prefix));
50
+ }
51
+ catch (error) {
52
+ console.error(`stoOpQueryStartWith failed. Storage might be too large:`, error);
53
+ return [];
54
+ }
41
55
  }
42
56
  /**
43
57
  * Sets a value in local storage.
44
58
  * @param key The key to set.
45
- * @param value The value to store.
59
+ * @param value The value to store. Must be JSON-serializable.
46
60
  */
61
+ // FIX: Replaced `any` with `unknown` to prevent reckless assignments without
62
+ // type checking.
47
63
  export async function stoOpSet(key, value) {
48
- await browser.storage.local.set({ [key]: value });
64
+ try {
65
+ await browser.storage.local.set({ [key]: value });
66
+ }
67
+ catch (error) {
68
+ console.error(`stoOpSet failed to write key "${key}". Quota exceeded?`, error);
69
+ throw error;
70
+ }
49
71
  }
50
72
  /**
51
73
  * Removes a key from local storage.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vacantthinker/firefox-addon-framework-easy",
3
- "version": "2026.0615.1133",
3
+ "version": "2026.0615.1148",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",