gruruya / nmostr Goto Github PK
View Code? Open in Web Editor NEWNim library for Nostr
Home Page: https://gruruya.github.io/nmostr/
License: GNU Affero General Public License v3.0
Nim library for Nostr
Home Page: https://gruruya.github.io/nmostr/
License: GNU Affero General Public License v3.0
Hi,
I want to help, but I want to know if this project is active. Is this project active?
Lately I've been using nmostr as a backup tool(local-first app, offline-first, self-host, minimal, serverless, export data) for nullboard(webapp, local-first app, no data, no server, offline-first, import/export data). I mentioned this here as an interesting use case that you could mention in the readme. But I did not modify the source code, in which case should I make the code publicly available?
use case: #12
Hello everyone!
I would like to know if it would be possible to have media type in nmostr. Would it be possible to have media type in mnostr?
media/plaintext
, media/html
, media/yaml
etc in nostr. In that case, we can support the rfc that specifies this."RFC2046" specifies that Media Types (formerly known as MIME types) and Media Subtypes will be assigned and listed by the IANA. Procedures for registering Media Types can be found in RFC6838, RFC4289, RFC6657. Additional procedures for registering media types for transfer via Real-time Transport Protocol (RTP) can be found in RFC4855. See this: https://www.iana.org/assignments/media-types/media-types.xhtml
We might have a syntax for media/type as:
import pkg/[nmostr, whisky]
# The example below is a conceptual sketch for this.
socket.send CMEvent(event: note(keypair, "media/type", "string")).toJson
In the theory:
example 1: media/urn
urn: urn:<NAMESPACE-IDENTIFIER>:<NAMESPACE-SPECIFIC-STRING>
: The placeholder stands for a string representing the resource category you want to identify. The is the resource's specific identifier, and its format depends on the namespace identifier. The following are examples of URNs: urn:isbn:1234567890
, urn:ISSN:0167-6423
, urn:ietf:rfc:2648
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/urn", "urn:ietf:rfc:2648")).toJson
example 2: media/uri
uri: https://the-great-chef.com/languages/recipe
: The URI acronym stands for Uniform Resource Identifier. Shortly, it is a string that identifies a resource. From a syntactical point of view, a URI string mostly follows the same format as... the URL!
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/uri", "https://the-great-chef.com/languages/recipe")).toJson
example 3: media/plaintext
In cryptography, plaintext usually means unencrypted information pending input into cryptographic algorithms, usually encryption algorithms.
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/plaintext", "Hello world from nmostr!")).toJson
example 4: media/url
URL identifies the web address or location of a unique resource.
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/url", "https://jwt.io")).toJson
example 5: media/text-fragments
Text fragments allow you linking directly to a specific portion of text in a web document, without requiring the author to annotate it with an ID, using particular syntax in the URL fragment.
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/text-fragments", "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#:~:text=human")).toJson
example 6: media/bibtext
'BibTeX' stands for a tool and a file format which are used to describe and process lists of references, mostly in conjunction with LaTeX documents.
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/bibtext", "http://sample-opensource-orgs.org/demo/sample.bib")).toJson
example 7: media/ipfs
Relays can't be expected to host media, the infrastructure requirements would be immense. URLs break and many image/video hosts do annoying things that prevent simple unobtrusive viewing of media. Use of decentralized URN to embed media in messages should be normalized.
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/urn", "urn:ipfs:bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi")).toJson
example 8: media/bittorrent
Let's assume in this theoretical example that you want to share a link to an iso file of a linux distribution to your friends on nostr. You could do something like this:
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/bittorrent", "https://linuxfreetest.com/linux_2023-05-13_k61.iso.torrent")).toJson
example 9: media/file
file
: URI Scheme is a URI scheme defined in RFC 8089, typically used to retrieve files from within one's own computer. This is very useful indoors where you want to share common data paths.
import pkg/[nmostr, whisky]
socket.send CMEvent(event: note(keypair, "media/file", "file://listlinux.com/free/public_html/chaps")).toJson
import pkg/[nmostr, whisky]
import std/uri
let host = parseUri("https://nim-lang.org")
assert $host == "https://nim-lang.org"
let keypair = newKeypair()
echo "New secret key: " & keypair.seckey.toBech32
echo "The public key: " & keypair.pubkey.toBech32
# Post a note
let socket = newWebSocket("wss://nostr.oxtr.dev") # Remember to build with -d:ssl
socket.send CMEvent(event: note(keypair, "media/url", host)).toJson
let response = socket.receiveMessage().get.data
echo response
# Read the note back
unpack fromMessage(response), msg:
when msg is SMOk:
socket.send CMRequest(id: randomID(), filter: Filter(ids: @[msg.id])).toJson
echo socket.receiveMessage().get.data
socket.close()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.