@haex-space/vault-sdk 2.3.15 → 2.3.16

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/index.mjs CHANGED
@@ -1978,6 +1978,42 @@ async function encryptCrdtData(data, vaultKey) {
1978
1978
  nonce: arrayBufferToBase64(nonce)
1979
1979
  };
1980
1980
  }
1981
+ async function wrapKey(keyToWrap, wrappingKey) {
1982
+ const cryptoKey = await crypto.subtle.importKey(
1983
+ "raw",
1984
+ new Uint8Array(wrappingKey),
1985
+ { name: ALGORITHM },
1986
+ false,
1987
+ ["encrypt"]
1988
+ );
1989
+ const nonce = crypto.getRandomValues(new Uint8Array(12));
1990
+ const ciphertext = await crypto.subtle.encrypt(
1991
+ { name: ALGORITHM, iv: nonce },
1992
+ cryptoKey,
1993
+ new Uint8Array(keyToWrap)
1994
+ );
1995
+ const result = new Uint8Array(12 + ciphertext.byteLength);
1996
+ result.set(nonce, 0);
1997
+ result.set(new Uint8Array(ciphertext), 12);
1998
+ return result;
1999
+ }
2000
+ async function unwrapKey(wrappedKey, wrappingKey) {
2001
+ const cryptoKey = await crypto.subtle.importKey(
2002
+ "raw",
2003
+ new Uint8Array(wrappingKey),
2004
+ { name: ALGORITHM },
2005
+ false,
2006
+ ["decrypt"]
2007
+ );
2008
+ const nonce = wrappedKey.slice(0, 12);
2009
+ const ciphertext = wrappedKey.slice(12);
2010
+ const plaintext = await crypto.subtle.decrypt(
2011
+ { name: ALGORITHM, iv: nonce },
2012
+ cryptoKey,
2013
+ ciphertext
2014
+ );
2015
+ return new Uint8Array(plaintext);
2016
+ }
1981
2017
  async function decryptCrdtData(encryptedData, nonce, vaultKey) {
1982
2018
  const vaultKeyBuffer = new Uint8Array(vaultKey);
1983
2019
  const cryptoKey = await crypto.subtle.importKey(
@@ -2034,6 +2070,6 @@ function createHaexVaultClient(config = {}) {
2034
2070
  return new HaexVaultClient(config);
2035
2071
  }
2036
2072
 
2037
- export { DEFAULT_TIMEOUT, DatabaseAPI, ErrorCode, FileSyncAPI, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HAEXTENSION_METHODS, HaexHubError, HaexVaultClient, PermissionStatus, PermissionsAPI, TABLE_SEPARATOR, WebAPI, arrayBufferToBase64, base64ToArrayBuffer, createHaexVaultClient, decryptCrdtData, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptString, encryptVaultKey, generateVaultKey, getTableName, hexToBytes, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, sortObjectKeysRecursively, verifyExtensionSignature };
2073
+ export { DEFAULT_TIMEOUT, DatabaseAPI, ErrorCode, FileSyncAPI, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HAEXTENSION_METHODS, HaexHubError, HaexVaultClient, PermissionStatus, PermissionsAPI, TABLE_SEPARATOR, WebAPI, arrayBufferToBase64, base64ToArrayBuffer, createHaexVaultClient, decryptCrdtData, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptString, encryptVaultKey, generateVaultKey, getTableName, hexToBytes, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, wrapKey };
2038
2074
  //# sourceMappingURL=index.mjs.map
2039
2075
  //# sourceMappingURL=index.mjs.map