@lvce-editor/extension-management-worker 4.42.0 → 4.43.0

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.
@@ -1760,6 +1760,45 @@ const getNodeRpcInfo = async (extensionId, rpcId) => {
1760
1760
  };
1761
1761
  };
1762
1762
 
1763
+ const cacheName$1 = 'ExtensionSecrets';
1764
+ const getRequestUrl = (extensionId, key) => {
1765
+ return `https://secret-storage.invalid/${encodeURIComponent(extensionId)}/${encodeURIComponent(key)}`;
1766
+ };
1767
+ const isElectron = () => {
1768
+ return get$5().platform === Electron;
1769
+ };
1770
+ const deleteSecret = async (extensionId, key) => {
1771
+ string(extensionId);
1772
+ string(key);
1773
+ if (isElectron()) {
1774
+ await invoke$1('SecretStorage.delete', extensionId, key);
1775
+ return;
1776
+ }
1777
+ const cache = await caches.open(cacheName$1);
1778
+ await cache.delete(getRequestUrl(extensionId, key));
1779
+ };
1780
+ const getSecret = async (extensionId, key) => {
1781
+ string(extensionId);
1782
+ string(key);
1783
+ if (isElectron()) {
1784
+ return invoke$1('SecretStorage.get', extensionId, key);
1785
+ }
1786
+ const cache = await caches.open(cacheName$1);
1787
+ const response = await cache.match(getRequestUrl(extensionId, key));
1788
+ return response?.text();
1789
+ };
1790
+ const storeSecret = async (extensionId, key, value) => {
1791
+ string(extensionId);
1792
+ string(key);
1793
+ string(value);
1794
+ if (isElectron()) {
1795
+ await invoke$1('SecretStorage.store', extensionId, key, value);
1796
+ return;
1797
+ }
1798
+ const cache = await caches.open(cacheName$1);
1799
+ await cache.put(getRequestUrl(extensionId, key), new Response(value));
1800
+ };
1801
+
1763
1802
  class CommandNotFoundError extends Error {
1764
1803
  constructor(command) {
1765
1804
  super(`Command not found ${command}`);
@@ -1771,8 +1810,17 @@ class CommandNotFoundError extends Error {
1771
1810
  const createExtensionCommandMap = extensionId => {
1772
1811
  return {
1773
1812
  ...commandMapRef,
1813
+ 'Extensions.deleteSecret'(key) {
1814
+ return deleteSecret(extensionId, key);
1815
+ },
1774
1816
  'Extensions.getNodeRpcInfo'(rpcId) {
1775
1817
  return getNodeRpcInfo(extensionId, rpcId);
1818
+ },
1819
+ 'Extensions.getSecret'(key) {
1820
+ return getSecret(extensionId, key);
1821
+ },
1822
+ 'Extensions.storeSecret'(key, value) {
1823
+ return storeSecret(extensionId, key, value);
1776
1824
  }
1777
1825
  };
1778
1826
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-management-worker",
3
- "version": "4.42.0",
3
+ "version": "4.43.0",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"