This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Basic implementation of NIP 01 filters in typescript. */ | |
interface Event { | |
id : string | |
kind : number | |
created_at : number | |
pubkey : string | |
subject ?: string | |
content : string | |
sig : string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Useful for type-checking your pipe middleware. | |
export type PipeMethod<T> = (input : T) => Promise<T> | |
// Return type for the pipe method. | |
type PipeReturn<T> = (input: T, catcher: Function) => Promise<PipeOutput<T>> | |
// Object returned by the pipe method. | |
interface PipeOutput<T> { | |
errors: unknown[]; | |
output: T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Cloudflare Worker Script */ | |
import NostrEmitter from './emitter.js' | |
const delay = (ms = 1000) => new Promise((r, _) => setTimeout(r, ms)) | |
export default { | |
async fetch(request) { | |
let cache | |
const emitter = new NostrEmitter() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2021 Pieter Wuille | |
// Distributed under the MIT software license, see the accompanying | |
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
// Revised and converted to Javascript by Christopher Scott. | |
function bytesToBigInt(bytes) { | |
let num = 0n | |
for (let i = bytes.length - 1; i >= 0; i--) { | |
num = (num * 256n) + BigInt(bytes[i]) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 443 ssl; | |
listen [::]:443 ssl ipv6only=on; | |
listen example.com:9735 ssl; | |
listen example.com:9737 ssl; | |
server_name example.com; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { webcrypto as crypto } from 'crypto'; | |
const IV_LENGTH = 16, // Length of init vector. | |
SECRET_KEY = process.env.SECRET_KEY; | |
let cryptoKey; // Cached CryptoKey object. | |
export async function encrypt(plaintext) { | |
/* Encrypt a string using the server's encryption key. */ | |
const ec = new TextEncoder(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## Takes an input pipe of JSON, and outputs the value for a given key. | |
set -e | |
usage() { | |
printf " | |
Takes an input pipe of JSON, and outputs the value for a given key. \n | |
Usage: some_JSON_output | jgrep key \n | |
" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## Bind a local port and forward its traffic to an onion address. | |
## Requires socat to be installed, and a tor proxy to be running. | |
############################################################################### | |
# Environment | |
############################################################################### | |
SOCKS_HOST="127.0.0.1" | |
SOCKS_PORT="9050" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## Format credentials as lndconnect URL and generate QR code. | |
## Requires qrencode package. | |
HOST_ADDR="ADDRESS:PORT" | |
HOST_CERT=`cat /path/to/certificate.pem | sed '1d;$d' | tr -d '=' | tr '/+' '_-' | tr -d '\n'` | |
MACAROON=`base64 /path/to/access.macaroon | tr -d '=' | tr '/+' '_-' | tr -d '\n'` | |
echo "lndconnect://$HOST_ADDR?cert=$HOST_CERT&macaroon=$MACAROON" | qrencode -o /path/to/save/qrcode.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## POSIX compliant script for generating Bitcoin RPC credentials. | |
## Requires xxd and openssl packages to be installed. | |
## Distributed under the MIT software license. | |
############################################################################### | |
# Environment | |
############################################################################### | |
RPCAUTH_USER="bitcoin" |