Creates a new instance of the EncryptedMaps client.
The client used to talk to the EncryptedMaps canister.
Optionaloptions: { cache?: DerivedKeyMaterialCache }Optional configuration.
Optionalcache?: DerivedKeyMaterialCacheStrategy for caching derived key material. Defaults to InMemoryDerivedKeyMaterialCache (in-memory only, never persisted). Pass IndexedDbDerivedKeyMaterialCache to persist across page reloads — see the security note in the class description.
import { EncryptedMaps } from "@icp-sdk/vetkeys/encrypted_maps";
const encryptedMaps = new EncryptedMaps(encryptedMapsClientInstance);
import {
EncryptedMaps,
IndexedDbDerivedKeyMaterialCache,
} from "@icp-sdk/vetkeys/encrypted_maps";
const encryptedMaps = new EncryptedMaps(encryptedMapsClientInstance, {
// Namespace the store per identity so one identity's cached keys are
// never served to another on the same origin.
cache: new IndexedDbDerivedKeyMaterialCache(`vetkeys-${myPrincipal}`),
});
// Remember to call encryptedMaps.clearCache() on logout / identity change.
The client instance for interacting with the EncryptedMaps canister.
The cached verification key for validating encrypted VetKeys.
Clears all cached derived key material.
Strongly recommended on logout or whenever the authenticated identity
changes: the cache belongs to a single identity, so clearing it (or
discarding the EncryptedMaps instance) prevents one identity's key
material from being served to another, and drops the still-usable
decryption capability that otherwise lingers. This matters most with
IndexedDbDerivedKeyMaterialCache, where cached key handles persist
across sessions until cleared.
Decrypts a value for a specific map and key.
The principal of the map owner
The name/identifier of the map
The key to decrypt for
The value to decrypt
Promise resolving to the decrypted value
Encrypts a value for a specific map and key.
The principal of the map owner
The name/identifier of the map
The key to encrypt for
The value to encrypt
Promise resolving to the encrypted value
Retrieves a list of maps that were shared with the user and the user still has access to.
Promise resolving to an array of [Principal, Uint8Array] pairs representing accessible map identifiers.
Retrieves all accessible maps with their decrypted values.
Promise resolving to an array of map data
Retrieves all accessible values across all maps the user has access to.
Promise resolving to an array of map data with decrypted values
Derives a key material for a specific map.
The principal of the map owner
The name/identifier of the map
Promise resolving to the derived key material
Gets or fetches the derived key material for a map.
The principal of the map owner
The name/identifier of the map
Promise resolving to the derived key material
Retrieves a list of non-empty maps owned by the caller.
Promise resolving to an array of map names
Gets all users that have access to a map and their access rights.
The principal of the map owner
The name/identifier of the map
Promise resolving to an array of user-access rights pairs
Checks a user's access rights.
The principal of the map owner
The name/identifier of the map
The principal of the user to check rights for
Promise resolving to the user's access rights if they exist
Retrieves and decrypts a stored value from a map.
The principal of the map owner
The name/identifier of the map
The key to retrieve
Promise resolving to the decrypted value
Retrieves all values from a specific map.
The principal of the map owner
The name/identifier of the map
Promise resolving to an array of key-value pairs
Retrieves the public verification key for validating encrypted VetKeys.
The vetkeys obtained via getVetkey are verified using this key,
and, therefore, this method is not needed for using getVetkey.
Promise resolving to the verification key bytes
Removes a value from a map.
The principal of the map owner
The name/identifier of the map
The key to remove
Promise resolving to the removed value if it existed
Revokes a user's access.
The principal of the map owner
The name/identifier of the map
The principal of the user to remove
Promise resolving to the previous access rights if they existed
Grants or modifies access rights for a user.
The principal of the map owner
The name/identifier of the map
The principal of the user to grant/modify rights for
The access rights to grant
Promise resolving to the previous access rights if they existed
Stores an encrypted value in a map.
The principal of the map owner
The name/identifier of the map
The key to store
The value to store
Promise resolving to the previous value if it existed
The EncryptedMaps frontend library facilitates interaction with an EncryptedMaps-enabled canister on the Internet Computer (ICP). It allows web applications to securely store, retrieve, and manage encrypted key-value pairs within named maps while handling user access control and key sharing.
Core Features
Security Considerations
EncryptedMapsinstance per identity (or call EncryptedMaps.clearCache on logout / identity change);