Core tools
Small building blocks for files and URLs: turn text into bytes, calculate hashes and reject unsafe addresses or paths. Other modules use these behind the scenes.
Try it in context: Read the guide.
import { Core } from '@chaoticka/nsite-loopy-sdk';
What you can call (11)
bytes
Turn text or binary input into the bytes that hashing and publishing need.
Call it as: Core.bytes
For developers: TypeScript signature
function bytes(value:string|Uint8Array|ArrayBuffer):Uint8Array;
Code location: src/core/bytes.js
encode
Convert ordinary text into UTF-8 bytes.
Call it as: Core.encode
For developers: TypeScript signature
function encode(value:string):Uint8Array;
Code location: src/core/bytes.js
endpoint
Check and clean one relay or Blossom server address before using it.
Call it as: Core.endpoint
For developers: TypeScript signature
function endpoint(input:string,type?:'relay'|'blossom'):string;
Code location: src/core/urls.js
endpoints
Check a list of server addresses and remove exact duplicates.
Call it as: Core.endpoints
For developers: TypeScript signature
function endpoints(values:string[],type?:'relay'|'blossom',max?:number):string[];
Code location: src/core/urls.js
hex
Display bytes as a hexadecimal string.
Call it as: Core.hex
For developers: TypeScript signature
function hex(value:Uint8Array):string;
Code location: src/core/bytes.js
normalizeOptions
Check a set of library configuration options and supply normalized values.
Call it as: Core.normalizeOptions
For developers: TypeScript signature
function normalizeOptions(options?:SDKOptions):SDKOptions;
Code location: src/core/options.js
nsitePath
Clean a site file path and reject unsafe paths like folder traversal.
Call it as: Core.nsitePath
For developers: TypeScript signature
function nsitePath(input:string):string;
Code location: src/core/urls.js
sha256
Calculate a SHA-256 fingerprint so a file can be checked for changes.
Call it as: Core.sha256
For developers: TypeScript signature
function sha256(value:string|Uint8Array|ArrayBuffer,options?:object):Promise<Hex>;
Code location: src/core/bytes.js
slug
Make a short, valid identifier for a named nsite.
Call it as: Core.slug
For developers: TypeScript signature
function slug(value:string):string;
Code location: src/core/urls.js
toBase64Url
Encode bytes into the URL-safe base64 format used in some Nostr requests.
Call it as: Core.toBase64Url
For developers: TypeScript signature
function toBase64Url(value:string|Uint8Array|ArrayBuffer):string;
Code location: src/core/bytes.js
unhex
Turn hexadecimal text back into bytes.
Call it as: Core.unhex
For developers: TypeScript signature
function unhex(value:string):Uint8Array;
Code location: src/core/bytes.js