Nsite tools

Make and publish static Nostr websites. These functions check your site files, prepare a signed manifest and help other people find the website.

Try it in context: Read the guide.

import { Nsite } from '@chaoticka/nsite-loopy-sdk';

What you can call (10)

NSITE_NAMED_KIND

Nostr event kind used to announce a named nsite.

Call it as: Nsite.NSITE_NAMED_KIND

For developers: TypeScript signature

const NSITE_NAMED_KIND:35128;

Code location: src/nsite/manifest.js

NSITE_ROOT_KIND

Nostr event kind used to announce the website at an account’s root.

Call it as: Nsite.NSITE_ROOT_KIND

For developers: TypeScript signature

const NSITE_ROOT_KIND:15128;

Code location: src/nsite/manifest.js

compareFiles

Show which site files were added, removed or changed between two versions.

Call it as: Nsite.compareFiles

For developers: TypeScript signature

function compareFiles(before:FileMap,after:FileMap):Promise<object[]>;

Code location: src/nsite/files.js

manifestTemplate

Prepare the site listing that an approved signer will publish to Nostr.

Call it as: Nsite.manifestTemplate

For developers: TypeScript signature

function manifestTemplate(prepared:PreparedFiles,options?:{identifier?:string;server?:string;title?:string;description?:string;created_at?:number}):UnsignedEvent;

Code location: src/nsite/manifest.js

mediaType

Guess the content type a site file should use when served.

Call it as: Nsite.mediaType

For developers: TypeScript signature

function mediaType(path:string):string;

Code location: src/nsite/files.js

normalizeFileMap

Check and normalize a map of website file paths and their contents.

Call it as: Nsite.normalizeFileMap

For developers: TypeScript signature

function normalizeFileMap(input:FileMap):Record<string,Uint8Array>;

Code location: src/nsite/files.js

nsiteAddress

Calculate a gateway address for a root or named nsite.

Call it as: Nsite.nsiteAddress

For developers: TypeScript signature

function nsiteAddress(pubkey:Hex,options?:{identifier?:string;gateway?:string}):string;

Code location: src/nsite/manifest.js

parseManifest

Read and validate a signed nsite manifest, including its file listing and hashes.

Call it as: Nsite.parseManifest

For developers: TypeScript signature

function parseManifest(event:SignedEvent,options?:{verify?:boolean;now?:number}):Promise<ManifestRecord>;

Code location: src/nsite/manifest.js

prepareManifestFiles

Fingerprint every file and produce the complete list needed to publish an nsite.

Call it as: Nsite.prepareManifestFiles

For developers: TypeScript signature

function prepareManifestFiles(files:FileMap,options?:{maxFiles?:number;maxBytes?:number}):Promise<PreparedFiles>;

Code location: src/nsite/manifest.js

publishNsite

Upload site files, sign the manifest, publish it to relays and save the results.

Call it as: Nsite.publishNsite

For developers: TypeScript signature

function publishNsite(files:FileMap,options:{signer:Signer;pubkey:Hex;server:string;relays:string[];identifier?:string;title?:string;description?:string;uploader?:(data:Uint8Array,options:object)=>Promise<{hash:Hex;verified:boolean}>;publisher?:(event:SignedEvent,relays:string[])=>Promise<PublishReceipts>;checkpoint?:(job:object)=>Promise<void>|void;signal?:AbortSignal}):Promise<{job:object;event:SignedEvent;manifest:ManifestRecord;receipts:PublishReceipts}>;

Code location: src/nsite/publisher.js