node-red-contrib-nostr
Version:
Node-RED nodes for seamless Nostr protocol integration. Features robust WebSocket handling, event filtering, and NPUB-based routing. Built with TypeScript for type safety and extensive testing. Perfect for Nostr automation flows.
32 lines (31 loc) • 958 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Validation = void 0;
class Validation {
static isValidHexString(str) {
return /^[0-9a-f]+$/i.test(str);
}
static isValidPubkey(pubkey) {
return this.isValidHexString(pubkey) && pubkey.length === 64;
}
static isValidEventId(id) {
return this.isValidHexString(id) && id.length === 64;
}
static isValidSignature(signature) {
return this.isValidHexString(signature) && signature.length === 128;
}
static isValidRelayUrl(url) {
try {
const parsed = new URL(url);
return parsed.protocol === 'wss:' || parsed.protocol === 'ws:';
}
catch {
return false;
}
}
static isValidTimestamp(timestamp) {
const now = Math.floor(Date.now() / 1000);
return timestamp > 0 && timestamp <= now;
}
}
exports.Validation = Validation;