Lighthouse
  • 👋Introduction
  • Quick Start
  • How To
    • 🔑Create an API Key
    • 🔼Upload Data
      • 📁File
      • 🔤Text/JSON
      • 🔀Buffer
    • 🔒Upload Encrypted Data
      • 📁File
      • 🔤Text/JSON
      • 🔐Encryption Authentication
        • 📝Method 1: Signed Message
        • ⚕️Method 2: JWT
        • 📲Method 3: Passkey
    • Encryption Features
      • 👯Share File
      • ❌Revoke Access
      • 🔑Check Access Conditions
      • 🚪Token Gating
      • Chains Supported
      • 📃Access Control Conditions
      • 🔓Decrypt File
        • 🌐Browser Decrypt File
        • 💻NodeJS Decrypt File
      • 🚪Access control with zkTLS
      • 👬Account Delegation Tutorial
    • 📂List Files
    • 💁File Info
    • 💰Get Balance
    • 🔁Retrieve File
    • 💾Check for Filecoin Deals
    • 🔄IPNS - Handle Mutable Data
    • 📦Migrate Files
    • 📌Pin CID
    • 💸Pay per use
    • Resize Image
    • 💻Use CLI Tools
  • zkTLS
  • 🤝Account Delegation
  • 💾Filecoin First
    • Usage
    • 💰Pay Per Deal
  • Tutorials
    • 💸Pay to View Application
    • Use Python SDK
    • 📝Update Content with Lighthouse IPNS
    • 📹Add Video Player in UI
    • ✅Document Verification with PoDSI
    • 🎨Minting NFTs on EVM Chains
    • 🪙Minting NFTs on Solana
    • 👩‍💻Programmable Storage with Lighthouse SDK and Filecoin
    • 🔐Secure File Sharing
    • Upload Encrypted Files
    • 📄Token Gating and Custom Contract
    • 🔑Token Gating NFTs
    • 🏖️Pushing File Metadata Onchain
    • Use Radix Wallet on Lighthouse Filesdapp
  • Concepts
    • Glossary
    • IPFS CID Transition to v1
  • Support
    • 📞Contact
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. How To
  2. Encryption Features

Revoke Access

The owner of the file can revoke the access of an encrypted file that was shared by him previously, this code example demonstrates the same.

const revokeAccess = async () => {
  try {
    // CID of the encrypted file that you want to revoke access to
    // CID is generated by uploading a file with encryption
    // Only the owner of the file can revoke access to another wallet address
    const cid = 'YOUR_CID' // Example: "Qma7Na9sEdeM6aQeu6bUFW54HktNnW2k8g226VunXBhrn7";
    const publicKey = 'YOUR_PUBLIC_KEY' // Example: "0xa3c960b3ba29367ecbcaf1430452c6cd7516f588";
    const signedMessage = "SIGNATURE/JWT"
    const publicKeyUserB = ['RECEIVER_PUBLIC_KEY'] // Example: "0x487fc2fE07c593EAb555729c3DD6dF85020B5160";

    const revokeResponse = await lighthouse.revokeFileAccess(
      publicKey,
      publicKeyUserB,
      cid,
      signedMessage
    )
    console.log(revokeResponse)
    /* Sample Response
    {
      data: {
        cid: 'QmTsC1UxihvZYBcrA36DGpikiyR8ShosCcygKojHVdjpGd',
        revokeTo: [ '0x487fc2fE07c593EAb555729c3DD6dF85020B5160' ],
        status: 'Success'
      }
    }
    */
  } catch (error) {
    console.log(error)
  }
}
revokeAccess()
lighthouse-web3 revoke-access [cid] [address]
PreviousShare FileNextCheck Access Conditions

Last updated 1 year ago

Was this helpful?

❌