
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@nostr-dev-kit/ndk-blossom
Advanced tools
NDK-Blossom is an extension for NDK (Nostr Development Kit) that adds support for the Blossom protocol, making it easy to upload, manage, and interact with binary data (images, videos, documents, etc.) stored on Blossom servers.
# Using npm
npm install @nostr-dev-kit/ndk-blossom
# Using yarn
yarn add @nostr-dev-kit/ndk-blossom
# Using bun
bun add @nostr-dev-kit/ndk-blossom
import { NDK } from '@nostr-dev-kit/ndk';
import { NDKBlossom } from '@nostr-dev-kit/ndk-blossom';
import { imetaTagToTag } from '@nostr-dev-kit/ndk/lib/utils/imeta';
// Create NDK instance
const ndk = new NDK({
explicitRelayUrls: ['wss://relay.example.com']
});
// Create NDKBlossom instance
const blossom = new NDKBlossom(ndk);
// Connect to NDK
await ndk.connect();
// Upload a file
const fileInput = document.getElementById('fileInput') as HTMLInputElement;
const file = fileInput.files?.[0];
if (file) {
// Handle upload failures
blossom.onUploadFailed = (error) => console.error(error);
// Track upload progress (especially useful for large files)
blossom.onUploadProgress = (progress, file, serverUrl) => {
const percentage = Math.round((progress.loaded / progress.total) * 100);
console.log(`Upload progress: ${percentage}%`);
return 'continue';
};
// Upload the file
const imeta = await blossom.upload(file);
console.log('File uploaded:', imeta);
// Convert the imeta object to a proper tag for nostr events
const imetaTag = imetaTagToTag(imeta);
// Use the URL in a nostr note
const note = await ndk.publish({
kind: 1,
content: `Check out this file: ${imeta.url}`,
tags: [imetaTag] // Use the properly formatted imeta tag
});
}
// Fix a broken URL
const user = ndk.getUser({ npub: 'npub...' });
const fixedUrl = await blossom.fixUrl(user, 'https://broken-server.example/abcdef123...');
For full documentation, see the documentation directory:
NDK-Blossom implements the Blossom protocol, which includes several Blossom Upgrade Documents (BUDs):
NDK-Blossom allows you to provide your own SHA256 calculation implementation:
import { NDK } from '@nostr-dev-kit/ndk';
import { NDKBlossom, SHA256Calculator } from '@nostr-dev-kit/ndk-blossom';
// Create NDK instance
const ndk = new NDK();
// Create NDKBlossom instance
const blossom = new NDKBlossom(ndk);
// Create a custom SHA256 calculator
class CustomSHA256Calculator implements SHA256Calculator {
async calculateSha256(file: File): Promise<string> {
// Your custom implementation here
// For example, using a different hashing library
// or modifying how hashing is performed
// Example using a hypothetical external library:
// return await externalHashLibrary.hashFile(file);
// Must return a hex string representation of the hash
return "...custom implementation...";
}
}
// Set the custom calculator
blossom.setSHA256Calculator(new CustomSHA256Calculator());
// Or provide it directly during upload
const imeta = await blossom.upload(file, {
sha256Calculator: new CustomSHA256Calculator()
});
This feature is useful for:
MIT
FAQs
Blossom protocol support for NDK (Nostr Development Kit)
We found that @nostr-dev-kit/ndk-blossom demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.