diff options
author | Michael Muré <batolettre@gmail.com> | 2023-08-14 16:58:06 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2023-08-14 16:58:06 +0200 |
commit | 297e1931a7b5913275e8e9b0a46494d95e7e5e7c (patch) | |
tree | 5c5ef10f66bff4f9e6e3bbe87c70c02940bdbce3 /entity/boostrap | |
parent | f0167a1d6068d22af5ffff260e2848f7c14a71b3 (diff) | |
download | git-bug-bootstrap-rework-2.tar.gz git-bug-bootstrap-rework-2.zip |
WIP 2bootstrap-rework-2
Diffstat (limited to 'entity/boostrap')
-rw-r--r-- | entity/boostrap/identity.go | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/entity/boostrap/identity.go b/entity/boostrap/identity.go new file mode 100644 index 00000000..92fb03bf --- /dev/null +++ b/entity/boostrap/identity.go @@ -0,0 +1,80 @@ +package bootstrap + +import ( + "fmt" + + "github.com/ProtonMail/go-crypto/openpgp" + "github.com/ProtonMail/go-crypto/openpgp/packet" + + "github.com/MichaelMure/git-bug/repository" + "github.com/MichaelMure/git-bug/util/lamport" + "github.com/MichaelMure/git-bug/util/timestamp" +) + +var ErrNoPrivateKey = fmt.Errorf("no private key") + +type Key interface { + Public() *packet.PublicKey + Private() *packet.PrivateKey + Validate() error + Clone() Key + PGPEntity() *openpgp.Entity + + // EnsurePrivateKey attempt to load the corresponding private key if it is not loaded already. + // If no private key is found, returns ErrNoPrivateKey + EnsurePrivateKey(repo repository.RepoKeyring) error +} + +type Identity interface { + Entity + + // Name return the last version of the name + // Can be empty. + Name() string + + // DisplayName return a non-empty string to display, representing the + // identity, based on the non-empty values. + DisplayName() string + + // Email return the last version of the email + // Can be empty. + Email() string + + // Login return the last version of the login + // Can be empty. + // Warning: this login can be defined when importing from a bridge but should *not* be + // used to identify an identity as multiple bridge with different login can map to the same + // identity. Use the metadata system for that usage instead. + Login() string + + // AvatarUrl return the last version of the Avatar URL + // Can be empty. + AvatarUrl() string + + // Keys return the last version of the valid keys + // Can be empty. + Keys() []Key + + // SigningKey return the key that should be used to sign new messages. If no key is available, return nil. + SigningKey(repo repository.RepoKeyring) (Key, error) + + // ValidKeysAtTime return the set of keys valid at a given lamport time for a given clock of another entity + // Can be empty. + ValidKeysAtTime(clockName string, time lamport.Time) []Key + + // LastModification return the timestamp at which the last version of the identity became valid. + LastModification() timestamp.Timestamp + + // LastModificationLamports return the lamport times at which the last version of the identity became valid. + LastModificationLamports() map[string]lamport.Time + + // IsProtected return true if the chain of git commits started to be signed. + // If that's the case, only signed commit with a valid key for this identity can be added. + IsProtected() bool + + // Validate check if the Identity data is valid + Validate() error + + // NeedCommit indicate that the in-memory state changed and need to be committed in the repository + NeedCommit() bool +} |