Commit Graph

1879 Commits

Author SHA1 Message Date
Alexis Sellier ca1b1f4453
Make some improvements to `rad-checkout`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-09 09:33:01 +01:00
Fintan Halpenny cb2d83daae
radicle: wire up radicle-cob
To wire up radicle-cob, it is necessary to implement the traits for
the following types:
* `Repository`: `change::Storage`, `object::Storage`, and `Store`
* `project::Identity`: `identity::Identity`

For `Repository`, the `change::Storage` implementation is trivial, as
it uses the underlying `git2::Repository` implementation. Then
`object::Storage` simply defines the required references names and
does lookups or updates.

The aforementioned reference naming scheme is:

  refs/namespaces/<ns>/refs/cobs/<typename>/<object_id>

For `project::Identity`, the `identity::Identity` implementation is
straight-forward.

To finalise the work, a simplified API is exposed as `radicle::cob`
where the `create`, `update`, `get`, and `list` functions are
redefined in terms of `radicle` specific types.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-08 18:13:54 +00:00
Fintan Halpenny 0bd213d15a
radicle-cob: simplify Objects and remove identifier
Objects does not need to be separated by `local` and `remotes`, it
uses `iter` internally, so all references are used regardless.

Simplify Objects by having it be a simple vector of references.

This also means that the `identifier` is not needed. This was only
required to identify the local reference, so it can now be removed.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-08 18:13:54 +00:00
Fintan Halpenny d6416c9be1
radicle-cob: remove Resource on Store
The `Store` trait had a paramter for a `Resource`. This is too
restrictive for implementations, particularly `heartwood`.

Instead, where a unique identifier is needed for the
`object::Storage`, i.e. in `create` and `update`, the identifier
becomes a parameter.

This allows the removal of passing the resource in `list`, `get` and
`changegraph`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-08 18:13:53 +00:00
Fintan Halpenny 4112b0fdc5
radicle-cob: Reference conversion from git2::Reference
It will be common for Reference to be converted from a
`git2::Reference` when one is implementing `object::Storage`.

Provide a `TryFrom` implementation between `git2::Reference` and
`Reference`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-08 14:46:52 +00:00
Fintan Halpenny 6b303bdc97
radicle-cob: Component conversions
`TypeName` and `ObjectId` are expected to be used in reference
names.

Add `From` conversions to `Component` for both of these types to make
it easier for using them with `git-ref-format`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-08 14:46:51 +00:00
xphoniex c829045b8d
Add `rad-self` command
Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
2022-11-08 11:16:32 +01:00
xphoniex c7ba5a7b3f
Add `rad-auth`, `rad-help`
Enable `rad-init`, `rad-checkout` commands as well.

Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
2022-11-08 11:16:32 +01:00
Alexis Sellier a8dc065dce
Use database transactions where appropriate
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-08 09:39:23 +01:00
Alexis Sellier 609d05fff2
Update `sqlite` dependency
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-08 09:39:23 +01:00
Alexis Sellier 8fe949b2a0
Implement `rad-checkout` command
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-07 22:04:47 +01:00
Alexis Sellier 32cd94dd23
Add `rad-init` command
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-07 22:01:49 +01:00
Alexis Sellier 223d36086e
Add `radicle-cli` crate's `terminal` module
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
Co-authored-by: xphoniex <dj.2dixx@gmail.com>
2022-11-07 14:48:01 +01:00
xphoniex 357fc79b41
Implement `paths` for `Profile`
Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
2022-11-06 12:42:47 +01:00
xphoniex 5847ad2ff1
Add `Clone` instance to `Profile`
Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
2022-11-06 12:42:30 +01:00
Fintan Halpenny 3aa7a5635b
nix: update sources for rust-1.65
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-05 12:48:02 +01:00
Alexis Sellier 45c7f3049b
Update to Rust 1.65
* Use new let-else syntax
* Fix new clippy lints

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-05 12:47:26 +01:00
Fintan Halpenny f3c4a53e1e
radicle-cob: port collaborative objects
This is a minimal port of the collaborative objects code from
radicle-link[0].

A `CollaborativeObject` is made up of a `History` of `Change`s that
are expected to be stored in a `git` backend.

The library exposes a CRU series of functions `create`, `get`, `list`,
and `update`.

This implementation differs, to previous one, in that it does not
assume any kind of identity system -- its only assumption is that
identities have an identifier and can be addressed in the `git`
database. This means that it does not require an `author` to be passed
in and it only uses the `resource` (previously `authorizing_identity`)
to store its content-address in the `Change`.

It also foregoes any caching to simplify the port and not make any
early optimisation assumptions.

[0]: https://github.com/radicle-dev/radicle-link/tree/master/cob

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-04 16:11:18 +00:00
Fintan Halpenny 58c26e1c9d
radicle-crypto: ExtendedSignature constructor and destructor
Add `ExtendedSignature::new` to construct an `ExtendedSignature`
provided a public key and signature. The `namespace` chosen was
"radicle" and `reserved` is set to be empty -- these choices were
slightly arbitrary.

Also add a desctructor in the form of:
`From<ExtendedSignature> for (PublicKey, Signature)`

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-04 16:11:17 +00:00
Fintan Halpenny 3af5a7084d
radicle-crypto: add Serialize and Deserialize for Signature
Add Serialize and Deserialize for Signature using the the `into` and
`try_from` serde attributes. To achieve this `From` and `TryFrom`
implementations were added between `Signature` and `String`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-04 16:11:17 +00:00
Alexis Sellier dc79130988
Zeroize passphrases
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 16:52:29 +01:00
Alexis Sellier 6e8e1e0972
Zeroize secret key in signer
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 16:49:29 +01:00
Alexis Sellier 25a541ee0a
Scope down default-members
We don't need to build everything by default, just the
core set of libraries.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 16:24:38 +01:00
Slack Coder c7706156c6
node: fix test dependency error
Enable Radicle Crypto's test feature.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-11-03 16:02:50 +01:00
Alexis Sellier 41f53f3fae
Small improvements to signer/agent
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 13:29:20 +01:00
Alexis Sellier 092ccfdcbc
Add `profile::env` module
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 13:06:08 +01:00
Alexis Sellier 577b632056
Use `Signer::try_sign` in interactive contexts
In interactive (user) contexts, use `try_sign` instead of `sign`.

We also revisit the `Profile` by adding a `signer` method that can
fail, eg. if we couldn't connect to ssh-agent.

Finally, we replace `UnsafeSigner` with `MemorySigner`, which makes
use of `ssh::Keystore`.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 13:06:00 +01:00
Alexis Sellier a79ef67b2a
Add `Signer::try_sign` method and cleanup usage
To support ssh-agent, add a signing method that can fail.
Also cleanup usage so that we always accept signer references.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 10:12:22 +01:00
Alexis Sellier 5494490c40
crypto: implement an OpenSSH keystore
This will become the primary keystore.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-02 14:11:07 +01:00
Alexis Sellier f5212405c5
ssh: simplify `radicle-ssh` crate implementation
Remove the internal buffer and simplify code around that.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-01 22:12:19 +01:00
Alexis Sellier 16b22d9178
Move `radicle/id` and `radicle/signature`
We move the identity branch out of `heads/` and to the old location:

  refs/rad/id

We move the signed refs branch to:

  refs/rad/sigrefs

Keeping both "special" branches under the same hierarchy makes things a
bit easier to work with, and tells the user that they should be updated
with special tooling.

We also revert to `rad/` because we no longer have the issue of having
`rad/rad/id` when doing a checkout of the remote branch in a working
copy.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-01 15:56:06 +01:00
Slack Coder 25c982cd8c
node: use method to access session's Node ID
Make accessing an important session value, the Node ID, as a method to
Session.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-31 18:17:27 +01:00
Alexis Sellier 6f3a598cc1
Remove `git-url` dependency
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-31 18:14:54 +01:00
Alexis Sellier 7b7e83fbc7
node: implement node announcement sybil resistance
We implement a small proof-of-work on the node announcement message
to prevent the routing table from being filled by fake entries.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-31 18:13:14 +01:00
Slack Coder 3c900f106f radicle-node: distinguish announcment nodes
Its easy to confuse what/who 'node' or 'session' is.

Rename session to 'relayer' to convey its role as message propagator.
Rename the announcement's node to 'announcer', clarifying its as the
source.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-31 11:40:50 -05:00
Slack Coder a8895aee80 node: follow up on session renaming
Rename the module to session from peer to be consistent with recent
renaming of the type from Peer to Session.  Remove stutter by renaming
session::SessionState to session::State, and session::SessionError to
session::Error.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-28 09:57:56 -05:00
Slack Coder c11f5b13bf rad-auth: create profile when not found
Be careful about when to attempt creating a profile.  Errors could
trigger creating a profile even when unrelated to it not existing.

Profile::load(..) is altered to distinguish between these cases.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-28 09:38:12 -05:00
Fintan Halpenny c0b0d29e19
radicle-crypto: split out from radicle
The crypto types are useful to use in other components that are
separate from the radicle crate, e.g. the incoming radicle-cobs
crate.

Separate out the types into a radicle-crypto crate. This crate defines
the usual PublicKey, SecretKey, and Signature types. It also provides
the ssh functionality, under the `ssh` feature. It is also necessary
to provide the `From` impl for `Component` here, which again is
guarded by the `git-ref-format` feature.

The `Arbitrary` implementation are moved. The arbitrary decision of
redefining `ByteArray` in both radicle-crypto and radicle was made.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-10-27 20:40:39 +01:00
Alexis Sellier 2a1154ef87
Re-work git transports
The changes in this commit are all intertwined and it was hard to
split them into smaller commits:

* Use custom transports everywhere

Instead of `file://` and instead of using a child process for fetching
and pushing; we go through our custom transports, which use the `rad://`
and `heartwood://` schemes.

* Introduce a 'mock' remote transport

To test the remote transport without needing to spawn TCP streams,
we add a mock transport that works between storages on the file
system.

* Get rid of node's `git-url`

Instead of git urls, nodes simply use their node-ids to replicate.
2022-10-26 21:40:19 +02:00
Alexis Sellier 3407c6c017
Add `ToString` support for transport URLs
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-24 21:57:53 +02:00
Alexis Sellier 66493422c2
Add 'local' and 'remote' URL formats
To distinguish between working-copy-to-storage (local) and
storage-to-storage (remote) replication, we create two new
URL types: a `remote::Url` (`heartwood://`) and a `local::Url`
(`rad://`).

These schemes are to be used for the remote and local transports,
respectively.

The difference between the two schemes is that remote replication
requires a node id.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-24 20:19:45 +02:00
Slack Coder 7c65f08cd1
radicle: fix typo
Correct radicle::node::Error::Connect's string.
2022-10-21 22:13:40 +02:00
Alexis Sellier 5f4fc8236e
A couple of docs and naming improvements
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-20 18:06:31 +02:00
Alexis Sellier 8b834a7b6e
Protect ourselves against naked refs
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-20 12:59:55 +02:00
Alexis Sellier 1906124497
Re-use `HEAD` reference if it exists
Since the `HEAD` reference is trusted (we set it locally), use that
when possible, instead of re-computing it.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-20 12:44:51 +02:00
Alexis Sellier 2ec320acec
Use 'primary key' constraint instead of index
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 22:39:31 +02:00
Alexis Sellier 706fbc6550
Get the node running
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 22:39:24 +02:00
Alexis Sellier 961c18319f
Test canonical refs are set
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 15:35:35 +02:00
Alexis Sellier e6fd85f249
Implement `public_references` helper function
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 15:20:44 +02:00
Alexis Sellier 111480cd6e
Make use of `git2::Repository::refname_to_id`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 14:47:12 +02:00