As extension.CheckWrite of the Go reference on the branch v0.12:
- extension.ts holds NOTE_ID and CAPSULE_ID, and checkWrite: datekeys.note
goes only in the noncritical array of PUBLIC_HEADER and datekeys.capsule
only in that of a .dkk, version 1, with data that is checked; any other
extension is the application's own.
- The writer of capsules applies it in newSealer, after the public note
and before the profile, to the arrays of PUBLIC_HEADER, CONTROL_CBOR and
the head, with the rules of the note; the writer of a .dkk applies it
after checkDisjoint. The texts are those of Go, taken from a probe.
- note.ts: checkNoteData checks the bytes of a note in the order of Go's
CheckNote, length, then UTF-8, then the rules of text; unusableNote is
Go's Header.UnusableNote. lengths.ts no longer keeps its own NOTE_ID.
Green on the test data of spec-v0.11: it changes no output of a valid
writer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
'capsule: extension: datekeys.note version 1: a public note that breaks the rules of text: text: control U+0009 in the declared author: ERR_EXTENSION_DATA_INVALID',
],
['a note without data',{noncritical:[{...note,data: undefined}]},'capsule: extension: datekeys.note version 1: a public note without data: ERR_EXTENSION_DATA_INVALID'],
['a note in critical',{critical:[note]},misplaced('datekeys.note','critical_extensions','PUBLIC_HEADER')],
['a note in the control',{controlNoncritical:[note]},misplaced('datekeys.note','noncritical_extensions','CONTROL_CBOR')],
['a note in the control, critical',{controlCritical:[note]},misplaced('datekeys.note','critical_extensions','CONTROL_CBOR')],
['a note in the head',{headNoncritical:[note]},misplaced('datekeys.note','noncritical_extensions','head')],
['a note in the head, critical',{headCritical:[note]},misplaced('datekeys.note','critical_extensions','head')],
]as[string,Partial<EncryptOptions>,string][])('refuses %s, as §72 asks of an encoder, with the text of Go and nothing written',async(_name,set,text)=>{
newError('accesskey: extension: datekeys.note version 1 is not registered for noncritical_extensions of .dkk: an encoder must not write it there (spec §72)'),
newError('capsule: extension: datekeys.capsule version 1 is not registered for critical_extensions of head: an encoder must not write it there (spec §72)'),
);
});
it('checks the data with validate, after its place, and wraps its errors',()=>{
thrownewError(`${context}: extension: ${e.id} version ${e.version} is not registered for ${arr} of ${obj}: an encoder must not write it there (spec §72)`);
}
try{
if(e.data===undefined){
thrownewDateKeysError('ERR_EXTENSION_DATA_INVALID',e.id===NOTE_ID?'a public note without data':`${CAPSULE_ID} without data`);
}
validate?.(e);
}catch(err){
if(errinstanceofDateKeysError)throwerr.wrap(`extension: ${e.id} version ${e.version}`).wrap(context);