#Encryption Policies

Walbucket supports multiple encryption policy types for fine-grained access control.

#Policy Types

#Wallet-Gated

Only specific wallet addresses can access the file:

policy: {
  type: 'wallet-gated',
  addresses: ['0x...', '0x...']
}
typescript

#Time-Limited

File access expires at a specific timestamp:

policy: {
  type: 'time-limited',
  expiration: Date.now() + 86400000 // 24 hours from now
}
typescript

#Password-Protected

File requires a password for access:

policy: {
  type: 'password-protected',
  password: 'my-secret-password'
}
typescript

#Public

No access restrictions:

policy: {
  type: 'public'
}
typescript

#Usage Examples

#Upload with Wallet-Gated Policy

const result = await walbucket.upload(file, {
  name: 'private-document.pdf',
  encryption: true,
  policy: {
    type: 'wallet-gated',
    addresses: ['0x123...', '0x456...']
  }
});
typescript

#Upload with Time-Limited Policy

const result = await walbucket.upload(file, {
  name: 'temporary-file.jpg',
  encryption: true,
  policy: {
    type: 'time-limited',
    expiration: Date.now() + (7 * 24 * 60 * 60 * 1000) // 7 days
  }
});
typescript

#Upload with Password Protection

const result = await walbucket.upload(file, {
  name: 'secure-file.pdf',
  encryption: true,
  policy: {
    type: 'password-protected',
    password: 'my-secret-password'
  }
});
typescript

#Retrieve with Decryption

import { SealClient } from '@mysten/seal';
import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';

const suiClient = new SuiClient({
  url: getFullnodeUrl('testnet'),
});

const sealClient = new SealClient({ suiClient });
const sessionKey = await sealClient.getSessionKey(policyId);

const result = await walbucket.retrieve(assetId, {
  sessionKey,
});
typescript