UNPKG

@oddjs/odd

Version:
32 lines 1.36 kB
import * as DID from "../did/index.js"; import * as Path from "../path/index.js"; import * as Sharing from "./share.js"; /** * Adds some sample to the file system. */ export async function addSampleData(fs) { await fs.mkdir(Path.directory("private", "Apps")); await fs.mkdir(Path.directory("private", "Audio")); await fs.mkdir(Path.directory("private", "Documents")); await fs.mkdir(Path.directory("private", "Photos")); await fs.mkdir(Path.directory("private", "Video")); // Files await fs.write(Path.file("private", "Welcome.txt"), new TextEncoder().encode("Welcome to your personal transportable encrypted file system 👋")); } /** * Stores the public part of the exchange key in the DID format, * in the `/public/.well-known/exchange/DID_GOES_HERE/` directory. */ export async function addPublicExchangeKey(crypto, fs) { const publicDid = await DID.exchange(crypto); await fs.mkdir(Path.combine(Sharing.EXCHANGE_PATH, Path.directory(publicDid))); } /** * Checks if the public exchange key was added in the well-known location. * See `addPublicExchangeKey()` for the exact details. */ export async function hasPublicExchangeKey(crypto, fs) { const publicDid = await DID.exchange(crypto); return fs.exists(Path.combine(Sharing.EXCHANGE_PATH, Path.directory(publicDid))); } //# sourceMappingURL=data.js.map