Commit Graph

61 Commits

Author SHA1 Message Date
niamtokik
93387f29f3 fix release configuration. 2023-10-26 13:08:57 +00:00
ErlangPunch
0ac7ad53c3 quick fix on documentation error 2023-10-01 16:15:42 +02:00
ErlangPunch
f3154ec57e use latest erlang version. 2023-10-01 16:11:05 +02:00
niamkik
1769ec5998 use gen_statem with nostr_client_connection now 2023-10-01 16:09:01 +02:00
niamkik
87714be5db update 2023-10-01 13:07:14 +02:00
niamkik
ee805f910b forgot to modify test suites... 2023-10-01 12:53:00 +02:00
niamkik
afeb0e9bfb create nostrlib application 2023-10-01 12:40:00 +02:00
niamkik
87f5796a6b removed useless files. 2023-10-01 12:24:44 +02:00
niamkik
b3a39fe3d9 convert nostr application to erlang release 2023-10-01 12:20:23 +02:00
niamkik
e3032e7bf1 lot of things to do there: removing half of this infrastructure. 2023-09-26 21:41:20 +02:00
niamkik
8413a45047 cleanup and update 2023-09-19 21:48:46 +02:00
niamkik
7d905ab40b update 2023-09-12 21:05:16 +02:00
niamkik
64daf20d26 == 2023-09-05: Shortcut_24/01
Hey everyone! First shortcut of this new season. Sorry for the delay,
I was playing with another project but now is the time to code for
Erlang Punch and nostr I did only few small modification during the
past three months. I merged bech32 module (we'll see that in another
shortcut) and did some cleanup  but the project did not change a
lot. At least, we are still stuck on the same issues. Okay, let's
do that!

We were working on nip/05, I think had something that work, but we
will need to check that. Another project could be cool, something we
were talking on for many months: creating the message router. Oh!
I remember now! The link between nip/05 and the database was not
done. Do I want to work on that right now? Not sure. I don't even
remember how this part is working. Let start our pomodoro session.
No more talk ;)

Okay! We need a way to list active clients but it leads to...
database, in particular mnesia. Well, I feel hot to do some
mnesia! :)

So; first pomodoro done. I only updated some documentation and
started to play with mnesia. I don't really know how to deal
with the connection at this time. In fact, if we are starting
to use mnesia... Perhaps we should use it everywhere. I should
dissociate clients and users.

A client is an active connection to a server, and we should only have
one perhaps more if more users need to connect on it.

An user is using a client (so the connection) to receive and share
their information. In this case, we should have something like that:

 1. a new client is started, a client abstracts the connection
    between an user and the server.

 2. a new user want to use the connection/client, then it will share
    the same connection if it already exists or create it if not
    present.

 3. It become an active user.

Let works on the second part.

== 2023-09-05: Shortcut_24/02

Okay! That's the last one for tonight. It's hot out there, and it's
hard to think with this kind of weather. Adding mnesia is not a small
task and it will impact a lot of the implementation but based on the
big modification in many NIP, in particular NIP/01 and NIP/25, I will
need to use mnesia one day or another. What we did during these
shortcuts? Well... Documentation and a first step in the interface to
store clients state. That's a good thing for the first one.

 + created nostr@clients module
 + created interface to create, list and delete clients
 ~ added documentation
 ~ did some test to remember how this application was
   working...

See you next time friends; I need to drink some water. :')
2023-09-05 21:23:28 +02:00
niamtokik
627df36145 just do some cleanup and add new NIPs in README. 2023-09-01 18:24:36 +00:00
niamtokik
bcef306591 Merge branch 'main' into issue/11-nip-implement-nip02-httpsgithubcomnostr-protocolnipsblobmaster02md 2023-08-12 07:54:02 +00:00
Niamtokik
2410017c6b Merge pull request #15 from erlang-punch/issue/6-implement-bech32-format-in-pure-erlang
Issue/6 implement bech32 format in pure erlang
2023-08-12 07:52:10 +00:00
niamtokik
d6d38eb0c5 Erlang Bech32 and Segwit Address Implementation
This commit implements bech32 format and segwit addressing like
defined in Bitcoin implementation. A module called bech32 and another
one called segwit have been created. These two modules offers the
support for encoding and decoding of bech32 string in different formats.
In final, 99% coverage for bech32 and 97% coverage for segwit. The
document is enough for now.

Added an article explaining how and why Bech32/Segwit were implemented
in pure Erlang.
2023-08-12 07:31:25 +00:00
niamkik
9f24446cf6 == 2023-05-23: Shortcut_23/25
Hey everyone! Ready for a new shortcut session? Well, we should
probably start by reading what we have done last week... So, we have a
working nip/05 implementation, it can be used by the client and the
server. We will need to plug that in our client and/or our routers. If
you take a look on the specification, when an event is coming to the
client with the field `nip05` it should check its content and validate
it. The relay is not correctly supported if I remember correctly, so,
we will probably need to work on that as well. We will also need to
check the content (if it's an hex key or not). Let's do that?

If I want to check this implementation, I will need to configure a
domain name pointing somewhere and returning the correct information,
something like toriko@test.erlangpunch.com (test domain). What if we
configure the server side first? When we have a valid user on our
side, we can enable a local server forwarding to the correct value. It
should be easy to do.

 + created nostr_relay_nip05_handler module (nip05 support on server
    side)
     + started just a quick session to test if everything was working. The
        documentation is not accurate, need to update it
         + created an isolated nostr_relay_listener:routes/1 function
          ! need to create a sub-domain to test the application and do a small
             reverse proxy (say test.erlangpunch.com).

== 2023-05-23: Shortcut_23/26

Let's start the second round. We will create a local relay handling
.well-known/nostr.json path (without https for the moment).

 ~ modified router in nostr_relay_listener
  + created nostr_relay_nip05_handler module
   + created nostr_relay_nip05_handler:lookup/3 to search in the
      active user (it's only a test for the moment).
       ! add a way to print the relay where the user can be found
        ! improve nostr_relay_nip05_handler:lookup_public_key/1.
         ! improve documentation and add notes, it could be a bit confusing.
          ? I think I already talked about that, but the current design is not
             really correct and needs to be fixed. The goal is to create many
                users and they can be connected to one or more relay. In this case,
                   the internal relay will find them directly from the database of
                      active user and create automatically the names/public keys
                         available.

== 2023-05-23: Shortcut_23/27

So, last shortcut tonight, the third one. I will continue to create
nostr_relay_nip05_handler module and will go to bed! This module is
working, at least, locally, with hardcoded values and without
https... But the idea is there. The current relay was implemented to
be only used in test suite, the database is not even correctly
working.

 + added nip05 CORS support
  + added more documentation and notes
   + created a function to list all users on the server
    + created a functio nto list one user on the server
     ! those functions are using hardcoded values and should not be
        used in production ;)
         ! need to modify the whole structure, like I said previously,
            an user should be isolated and select the relay he wants.

So, it's done for tonight! I know, it was not really... fun but we
will improve that very soon. The current application is already
working a little bit, and nip05 was a requirement to use it into the
wild. A will create a custom domain name containing my testing data
and will try to publish some events next week :)

Have a good day, good night, and as usual, thanks for watching! ;)
2023-05-23 21:38:49 +02:00
niamkik
f0bfe7421e == 2023-05-16: Shortcut_23/22
Hi everyone! So, another shortcut session... We start with lot of
typos to fix. Last week we did the first nip/05 implementation in a
dedicated process using gen_statem. We had some issues with the
connection to the remote server, I found the problem just after the
session, it was due to the TLS timeout I had configured. It was fixed
and it worked. Today, I also updated Erlang version to the latest one
available (R26), cowboy and gun were also updated as well. Those
session will be dedicated to test and finish nip05
implementation. Let's do it!

 + checked if the process was working, and it is the case
 + added few documentation to explain how it's working
 ! need to modify the way we store the value
 ! need to create simple interfaces (and document them)
 ! cleanup the mess... This module is hard to understand at first glance.
 ? modify the data-structure used?

== 2023-05-16: Shortcut_23/23

Continue to implement nip/05. Fix bugs and try to simplify the way
it's actually done.

 + created is_valid/1 interface
 + created check_identifier_validity/2 to check if the identifier
   and the key are the same on the remote server.
 ~ cleaned up the documentation and the exported functions
 ! it's still mess...
 ? is it really the good way to do? exporting a simple function
   to check if the identifier is valid could be easier. Another
   way is to create a kind of callback to set the value found
   and update another data-structure somewhere else.
 ? this feature will be used by the client and the relay, create
   a behavior instead of a full gen_statem could also be helpful.

== 2023-05-16: Shortcut_23/24

Okay, we have some functional, it's working but there are still some
bugs to fix. Let's go for a third round.

 + add notification support (created init_notify/2)
 + add more documentation
 + add identifier/1 and public_key/1 (could be helpful)
 ~ modified the record, it has now the raw identifier (if valid)
 ! Add tests...!
 ! Add a local server to mock this part of the code in the
   test suite.
 ? I think this code will be refactored, some parts are quite
   dirty and I don't really like the way it's done. We'll see in
   another session.

So, I think we have a working process/module. It's not perfect at all
but we will improve that when the whole stack will work. At least, we
can now check if an identifier is valid (or not). The next step is to
integrate this module/process directly on the client and server
sides... See you soon! :)
2023-05-16 21:39:28 +02:00
niamtokik
64f08a8e23 Merge branch 'main' into issue/11-nip-implement-nip02-httpsgithubcomnostr-protocolnipsblobmaster02md 2023-05-16 11:44:32 +00:00
Niamtokik
422d483d11 Merge pull request #14 from erlang-punch/dev/add-erlang-otp-26-support
Add Erlang R26 support
2023-05-16 11:43:46 +00:00
niamtokik
008815d16b Add Erlang R26 support
- upgrade cowboy version to 2.10.0
 - upgrade gun version to 2.0.1
2023-05-16 11:39:25 +00:00
niamtokik
22fa1794d4 just clean things up 2023-05-14 08:48:47 +00:00
niamkik
34af66f529 == 2023-05-09: Shorcut_23/19
Hi everyone! The week was a bit exausting on my side... So, I will try
to continue the previous implementation of nip/05. First, we will read
the change during the last session. Okay! Let's go!

 + created check_json/1 function to check json object returned by the
   server hosting the information about one user
 + added eunit test support
 + added more documentation
 + added some todos.
 ! require documentation on many functions
 ! need to check the data stored in names and relays attributes.

== 2023-05-09: Shorcut_23/20

Did some cleanup, in particular in the init function.

 + splitted the init function in small functions to check
   arguments present in a proplists
 + added module documentation
 + added more documentation
 ! need to rename this module to nostr_client_nip05

== 2023-05-09: Shorcut_23/21

This last part was dedicated to test the process... And it does not
work correctly. Anyway, it will be fixed next time. When creating a
connection to the remote server with a valid domain and path, nothing
is returned. It's possibly related to CA validation (to check).

Anyway, see you Friday... :)

 + add logging support
 + did some tests
 ~ fixed a bug in the path used to fetch the information
 ~ fixed few other bugs
2023-05-09 21:39:16 +02:00
niamkik
66976ee22a shortcut_23_16 -> shortcut 23_18 2023-05-02 21:37:50 +02:00
niamkik
72d4755229 shortcut 23/13 to 23/15 2023-04-25 21:50:27 +02:00
niamkik
14e31762ec shortcut_23/10, 23/11 and 23/12 2023-04-18 21:41:50 +02:00
niamkik
ea8b036b4d update the documentation 2023-04-16 17:30:59 +02:00
niamkik
1ccf4480db correct shurtcuts session index 2023-04-16 17:04:38 +02:00
niamkik
8e05a732ca shortcut 23/06, 23/07, 23/08 2023-04-16 16:21:08 +02:00
niamtokik
d0ef31a4d9 add tests 2023-04-14 17:20:51 +00:00
niamkik
2a95ef296d cleanup nostr_client_key, add more documentation and creates the interfaces/API to communicate with it 2023-04-14 17:41:46 +02:00
niamkik
e4a115557d --[ SHORTCUT_23/04 ]
We will probably work on another part of the code. We will finish
NIP/02 and merge it. At this time, the relay is doing to much things
and it was not planned at all. Let's work on NIP/02 and the client
tonight!

The problem we had was related related to the way we should receive
the answers from the relay... We will try to deal with that or switch
to another issue.

We already have a great implementation on the client, but we lack it
on the server side. I think it will be done another day. We will switch
to another issue.

----

Let's add the support for the key store. The idea is to store it somewhere
on the disk. To do that we can use many different methods. Which one is the
best? Well... At first, we will just export the key on a file present in the
filesystem. We will improve it later.

Okay, a nostr_client_key module has been created, it is currently not started
but the idea is to have one process per key. This process will be in charge
to save/update/export the private information stored for one user identified
by a name. At first, the private keys (and other informations) will not
be encrypted. It seems a bit crazy, but we need to start with something simple.

This information should be stored outside of the database because it should
be easy to extract and easy to export.

--[ SHORTCUT_23/05 ]

What kind of messages we need to support there? Well. We need to:

 1. (cast) generate a new key
 2. (cast) store the key on the disk
 3. (cast) load the key from the disk (if present)
 4. (call) export it in different formats

The main function created there was the initialization part of
nostr_client_key.

--[ SHORTCUT_23/05 ]

finalizing the initialization part of the nostr_client_key module
using gen_server. This shortcut implemented a way to generate,
initialize, and store a key. More tests are required though.

So, it's over for tonight! 3 shortcuts, one module implemented. It
looks good :)

See you for the next ones ;)
2023-04-11 21:47:23 +02:00
niamkik
f42ff2efd2 - 2023-04-04 21:08:02 +02:00
niamkik
7f6d231e2f So yesterday, we were working on relay store and a mnesia backend. let's continue.
Found a bug in the encoder. Will fix it right now. Better!

Okay, we corrected a bug in the encoder and started to define a new table called
subscriptions. This table will contain a list of subscription identifier (generated
by the clients), the client connected and a reference to a filter (probably another
table). The identifier should be a tuble {ClientIdentifier, Connection}.
2023-04-04 20:36:15 +02:00
niamkik
5f6daabf26 So a short break. I created the first relay_store handler, to store data in
mnesia backend. The idea is to create a behavior with the commands to insert,
delete, update and select information from the database. Not ACID... CRUD! :')

Anyway, the goal is to offer some facilities to create those handlers and
extend easily the relay. Inserting an event or a subscription should be
easy on mnesia but also on any kind of database like postgresql.

I think this module will be updated soon with more specification. At least,
it works to insert data in the database (events). The subscription will also
be inserted into the database but the procedure will be a bit different...
2023-04-03 21:24:46 +02:00
niamkik
c4ac0829dc add store documentation and some test with/for mnesia 2023-03-31 17:25:53 +02:00
niamkik
76df76a73f So, why pomodoro? why shortcut? Well... I used pomodoro method many time in the past
and was always happy when developing using that. why shortcut? I wanted "short circuit"
but it was a bit too long... Shortcut looks better!

A quick summary: we coded the supervisor for the nostr_relay subscription, deployed it
started it and created a simple interface to forward the events. More is needed... But
we will see that in another shortcut episode! :)
2023-03-31 15:42:25 +02:00
niamkik
0aa7ad912e update nostr_relay_subscription and _store 2023-03-28 21:58:23 +02:00
niamkik
6ed5d456dc update 2023-03-28 19:06:54 +02:00
ErlangPunch
65fc2e9285 update 2023-03-24 21:59:58 +01:00
ErlangPunch
04cd9618fc update 2023-03-24 19:18:15 +01:00
ErlangPunch
e3b6518cc4 update 2023-03-24 18:37:11 +01:00
niamtokik
01f353c6f8 add notes for the relay 2023-03-18 18:01:39 +00:00
niamtokik
ec5a933d01 update 2023-03-18 17:55:06 +00:00
niamkik
67816f3ec4 create a first primitive relay 2023-03-17 17:48:45 +01:00
niamtokik
560832eec0 create a new router model 2023-03-15 20:34:34 +00:00
niamkik
7a877e4aae update 2023-03-14 21:09:00 +01:00
niamkik
e37fa5baff update documentation 2023-03-14 18:58:23 +01:00
niamtokik
571f59b26a update 2023-03-14 17:29:11 +00:00