Skip to content

Instantly share code, notes, and snippets.

View blakejakopovic's full-sized avatar

Blake Jakopovic blakejakopovic

View GitHub Profile
@blakejakopovic
blakejakopovic / rust_docker
Created February 3, 2024 10:36 — forked from gsquire/rust_docker
A small docker image for rust using alpine linux
FROM alpine:3.6
RUN apk add --no-cache rust cargo
COPY project /build
WORKDIR /build
RUN ["cargo", "build", "--release"]
ENTRYPOINT ["cargo", "run", "--release"]
@blakejakopovic
blakejakopovic / NIP-ZZ.md
Last active May 20, 2023 10:00
NIP-ZZ - 401/402 Unauthorised/Payment Required Nostr HTTP AUTH Flow

NIP-ZZ

401/402 Unauthorised/Payment Required Nostr HTTP AUTH Flow

draft optional author:wakoinc

This NIP is an extension to NIP-98 which allows HTTP authorization using a base64 encoded event header. This NIP documents a typical protocol flow for failure, retry and success - or hard fail.

@blakejakopovic
blakejakopovic / yy.md
Last active May 20, 2023 10:27
NIP-YY - Nostr Service Definition

NIP-YY

Nostr Service Definition

draft optional author:wakoinc

A standardised service definition event allowing services to broadcast services they provide, and client apps to impliment support for a service type that is inter-changable

@blakejakopovic
blakejakopovic / DummyNostrHttpAuthEndpoint.rb
Created May 17, 2023 18:16
Dummy Nostr HTTP AUTH endpoint for NIP-98
require 'sinatra'
get '/public/AUTHIMAGE.jpg' do
auth_header = request.env['HTTP_AUTHORIZATION']
puts auth_header
# Check if the header value starts with "Nostr "
unless auth_header && auth_header.start_with?("Nostr ")
headers['WWW-AUTHENTICATE'] = 'NOSTR-NIP-98'
headers['Access-Control-Expose-Headers'] = 'WWW-Authenticate'
@blakejakopovic
blakejakopovic / Nostr-MyServices.md
Created April 11, 2023 15:15
NIP-XX - My Services

Nostr 'My Services' Event Kind (Draft/Experiment)

A way to support in-app management of services with subscriptions and credits where a payment is due (I guess it can be free too?).

Client UX

A client app can query for these events and show a list of services that are active or have credit remaining. They can show a list of expired (or no credit left) services as well. Clicking a service can allow you to make a payment based on the payment options provided.

What to support

  • Current balance (optional if expiry exists, else mandatory)
  • Current expiry (optional for balance): Represents payment due by
@blakejakopovic
blakejakopovic / nostr_query_engine.md
Last active March 26, 2023 12:14
Nostr missing event query/request features and pain points

Pain Points / design limitations

  • Limit is useless for subscriptions with multiple filters (as how to prioritise which filter results are most important? Left to right?)
  • Hard to do pagination (using since/until, but what limit to use? What if older events shared after you fetch, you’ve now missed it)
  • Race condition between EOSE and CLOSE subscription when you don’t want to stream (option to only return existing data only, without newer broadcast results)
  • Events from new pubkeys are missing basic kind0 data (ideally embed name/display_name for first pubkey event)
  • Websocket congestion control and bottlenecks (single event streamed at a time, blocked by larger events FIFO)
  • Unable to query for ranges of kinds (e.g. {"kinds": [30000-39999]})
  • More?

Missing Features

@blakejakopovic
blakejakopovic / nip19.rs
Created March 21, 2023 17:53
Nostr NIP-19 Rust TLV decode
#[macro_use]
extern crate log;
use anyhow::Result;
use bech32::FromBase32;
use secp256k1::hashes::hex::ToHex;
use std::convert::TryFrom;
fn parse_tlv(data: &[u8]) -> Vec<(u8, &[u8])> {
let mut result = vec![];
@blakejakopovic
blakejakopovic / app.rb
Last active March 17, 2023 15:33
Nostr NIP-42 Website Login Example
require 'sinatra'
require 'json'
# class App < Sinatra::Application
configure do
enable :sessions
end
get '/' do
@blakejakopovic
blakejakopovic / NIP-XX.md
Last active March 9, 2023 11:02
NIP-XX - Nostr Proof of Work Service Provider

NIP-XX

Proof of Work Service Provider

draft optional author:wakoinc

This NIP defines a way for clients to request a target proof of work calculation for an event prior to publishing.

@blakejakopovic
blakejakopovic / nostr_zap_validator.rs
Last active March 2, 2023 15:58
Quick and dirty Rust Nostr ZAP Validation
// https://github.com/nostr-protocol/nips/blob/master/57.md
//
// Quick and dirty Rust Nostr ZAP Validation
//
// anyhow = "1.0.68"
// bech32 = "0.9"
// lightning-invoice = "0.21.0"
// nostr-rs-relay = "0.7.2"
// serde_json = "~1"