feat: a key that can't be used is explained in the picker
The key picker stays open until the link is made, saying "encrypting
with …" meanwhile. A key that can't be read, or doesn't keep to
share.keyRules, is shown in it in red with which rule it misses
("its value has 28 characters; share.keyRules needs 32
(minLength)"), to pick another.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
6 files changed
+73
-16
No files matched your search
@@ -91,13 +91,13 @@ type file struct {
|
||||
}
|
||||
|
||||
// Seal encrypts files with key, the value of h.Key, into a share link,
|
||||
// if key keeps to rules.
|
||||
// if key keeps to rules (*KeyError if not).
|
||||
func Seal(h Header, key []byte, files []File, rules Rules) (ref.Ref, error) {
|
||||
if _, err := ParseKey(h.Key.String()); err != nil {
|
||||
return ref.Ref{}, fmt.Errorf("the key: %w", err)
|
||||
}
|
||||
if err := rules.Check(key); err != nil {
|
||||
return ref.Ref{}, err
|
||||
return ref.Ref{}, &KeyError{Name: h.Key.Name, Err: err}
|
||||
}
|
||||
if len(files) == 0 {
|
||||
return ref.Ref{}, errors.New("no files to share")
|
||||
|
||||
Reference in new issue
Block a user