
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@requestnetwork/lit-protocol-cipher
Advanced tools
Lit Protocol Provider for Request Network.
@requestnetwork/lit-protocol-cipher
is a typescript library part of the Request Network protocol that provides encryption and decryption capabilities using the Lit Protocol.
npm install @requestnetwork/lit-protocol-cipher
The LitProtocolCipherProvider
class provides encryption and decryption capabilities using the Lit Protocol. Here's how to implement and use it:
import { ethers } from 'ethers';
import { LitProtocolCipherProvider } from '@requestnetwork/lit-protocol-cipher';
import { LIT_NETWORKS } from '@lit-protocol/types';
import { LitNodeClient } from '@lit-protocol/lit-node-client';
// Initialize the provider
const litProvider = new LitProtocolCipherProvider(
new LitNodeClient({
litNetwork: LIT_NETWORKS.datil,
}),
{
baseURL: 'https://gnosis.gateway.request.network',
headers: {
'Content-Type': 'application/json',
},
}, // nodeConnectionConfig
);
// Initialize the client
await litProvider.initializeClient();
// Enable decryption
await litProvider.enableDecryption(true);
// Example usage with wallet connection
async function example() {
try {
// Connect wallet and get signer (example using ethers.js)
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const address = await signer.getAddress();
// Get session signatures (required for decryption)
await litProvider.getSessionSignatures(signer, address);
// Example data to encrypt
const sensitiveData = {
message: 'Secret message',
timestamp: Date.now(),
};
// Encryption parameters (defining who can access the data)
const encryptionParams = [
{
key: '0x1234....', // Ethereum address that can decrypt
type: 'address',
},
];
// Encrypt data
const encryptedData = await litProvider.encrypt(sensitiveData, { encryptionParams });
if (!encryptedData) {
throw new Error('Encryption failed');
}
// Store the encrypted data somewhere...
// Later, decrypt the data
const decryptedData = await litProvider.decrypt(encryptedData, { encryptionParams });
if (decryptedData) {
// Parse the decrypted data if it was originally an object
const parsedData = JSON.parse(decryptedData);
console.log('Decrypted data:', parsedData);
}
} catch (error) {
console.error('Error:', error);
} finally {
// Disconnect wallet when done
await litProvider.disconnectWallet();
}
}
// Multiple recipients example
async function multipleRecipientsExample() {
const encryptionParams = [
{ key: '0x1234....', type: 'address' }, // First recipient
{ key: '0x5678....', type: 'address' }, // Second recipient
{ key: '0x90AB....', type: 'address' }, // Third recipient
];
const encryptedData = await litProvider.encrypt('Secret message for multiple recipients', {
encryptionParams,
});
}
Wallet Connection Management
Flexible Encryption
Secure Decryption
The provider includes built-in error handling for common scenarios:
It's recommended to wrap your encryption/decryption operations in try-catch blocks to handle any potential errors gracefully.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Read the contributing guide
FAQs
Lit Protocol Cipher Provider.
We found that @requestnetwork/lit-protocol-cipher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.