Three ways in
A people lock opens with the keys of the people on its list. A password lock opens with its password. A link lock opens with a key after #. The same Locker envelope works across OpenVibe.
Drive and Sends
Drive uses people locks. Sends use link locks, expire in 1 hour to 30 days, and can have a download limit. Names, types, true sizes and contents are inside the envelope. Recipients can keep what they open.
Lock a file for an @name
Use the existing Locker SDK and the Network key directory. Include your own key before uploading to Drive, then use the Share API to add the recipient.
const locker = require('openvibe-sdk/locker');
const { share } = require('openvibe-sdk/share');
// token and subject come from your signed-in OpenVibe session.
const headers = { Authorization: `Bearer ${token}` };
const mine = await fetch(`https://openvibe.network/api/v1/people/${subject}/keys`, { headers }).then(r => r.json());
const recipient = await fetch('https://openvibe.network/api/v1/people/@name/keys', { headers }).then(r => r.json());
// payload contains the private file description, then the file bytes (see API docs).
const sealed = await locker.seal(payload, {
lock: 'people', keys: [{ subject: { type: 'user', id: subject }, publicKey: mine.ecdh_public }]
});
const item = await fetch('https://openvibe.locker/api/v1/files', {
method: 'POST', headers: { ...headers, 'Content-Type': 'application/octet-stream' }, body: sealed.bytes
}).then(r => r.json());
const withRecipient = await locker.rewrap(sealed.bytes, {
credentials: { person }, add: [{ subject: { type: 'user', id: recipient.subject }, publicKey: recipient.ecdh_public }]
});
await share({ base: 'https://openvibe.locker', token }).for('files', item.id).update({
members: [{ subject: { type: 'user', id: recipient.subject }, role: 'viewer', key_slot: withRecipient.header.slots.people.find(s => s.subject.id === recipient.subject) }],
envelope: Buffer.from(withRecipient.bytes).toString('base64')
});For large files use sealStream and openStream. Discard a download if final verification fails. See the OpenAPI reference, source and payload format, and agent guide.
If you lose the password (or your locker passphrase and recovery kit), nobody can open this, including OpenVibe.