refactor(api): partager nomme le document, détenir répond par oui ou non
`shareCap(cap, toUser)` faisait tenir une clé à l'appelant. En amont il n'en
tient aucune : c'est le verifier qui remplit `ContactDetails.read_cap`, et une
inbox se résout depuis un profil. Cette signature a déjà changé deux fois
aujourd'hui — `(cap, toInbox)` puis `(cap, toUser)` — et les deux laissaient à
l'app quelque chose qu'elle ne tiendra pas plus tard.
- `inbox.share(doc, toUser)` : les deux choses qu'une application a, un document
et une personne. Ni la clé ni l'adresse n'apparaissent.
- `hasCap(doc)` remplace `capFor(doc)` et rend un BOOLÉEN. C'est la seule
question que le modèle admette, et l'unique appelant qui utilisait la valeur
s'en servait pour la passer à `shareCap`.
Les tests ont fait apparaître un besoin que ces retraits allaient casser :
obtenir le lien PARTAGEABLE d'un document publié, pour le faire circuler. C'est
distinct du partage dirigé et ça existe en amont — un `RepoLinkV0 { read_cap }`
est ce qu'on passe, `ContactDetails.read_cap` est la remise à quelqu'un. D'où
`linkTo(doc)`, seul endroit où une app tient légitimement une clé : on ne peut
pas faire circuler ce qu'on n'a pas le droit de toucher. La clé d'un document
protégé, elle, ne sort jamais par là — elle passe par `share`.
171 tests unitaires, e2e 42/42 en 3,5 min (synchro à froid 29s, stable contre
30s au run précédent — le wallet par batterie tient).
This commit is contained in:
@@ -37,7 +37,7 @@ import {
|
||||
type Nuri,
|
||||
type Scope,
|
||||
} from "@ng-eventually/client";
|
||||
import { capFor, configure, configureStoreRegistry, setCurrentUser } from "@ng-eventually/client/polyfill";
|
||||
import { configure, configureStoreRegistry, setCurrentUser } from "@ng-eventually/client/polyfill";
|
||||
import { ng as realNg, init as realInit } from "@ng-org/web";
|
||||
|
||||
// --- the domain, such as it is ---------------------------------------------
|
||||
@@ -135,16 +135,15 @@ async function readSharedNote(link: string): Promise<Note | null> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hand a reader the key to one of my notes.
|
||||
* Hand a reader access to one of my notes.
|
||||
*
|
||||
* Names the PERSON. Where their inbox is, and whether they have one yet, is the
|
||||
* library's business — an application will never handle an inbox address once this is
|
||||
* native, so it does not handle one now.
|
||||
* Names the NOTE and the PERSON — the two things this app has. Neither the key nor the
|
||||
* recipient's inbox appears: an application will handle neither once this is native
|
||||
* (upstream the verifier fills `ContactDetails.read_cap` itself), so it handles neither
|
||||
* now. Refuses if the note is not mine to share.
|
||||
*/
|
||||
async function shareNote(doc: Nuri, withUser: string): Promise<void> {
|
||||
const cap = capFor(doc);
|
||||
if (!cap) throw new Error("this note is not mine to share");
|
||||
await inbox.shareCap(cap, withUser);
|
||||
await inbox.share(doc, withUser);
|
||||
}
|
||||
|
||||
/** Open a note for messages — only its owner can, and only they will read them. */
|
||||
|
||||
Reference in New Issue
Block a user