@@ -9,6 +9,10 @@ import { store, authn } from 'solid-logic'
99import * as ns from '../ns'
1010import * as $rdf from 'rdflib' // pull in first avoid cross-refs
1111import * as utils from '../utils'
12+ import { signMsg } from '../signature'
13+
14+ const SEC = 'https://w3id.org/security#' // Proof, VerificationMethod
15+ const CERT = 'http://www.w3.org/ns/auth/cert#' // PrivatKey, PublicKey
1216
1317/* The Solid logic for a 'LongChat'
1418*/
@@ -51,22 +55,31 @@ export class ChatChannel {
5155
5256 const me = authn . currentUser ( ) // If already logged on
5357
58+ const msg = { }
5459 if ( oldMsg ) { // edit message replaces old one
5560 sts . push ( $rdf . st ( mostRecentVersion ( oldMsg ) , ns . dct ( 'isReplacedBy' ) , message , chatDocument ) )
61+ // do we need to rebuild oldMsg signaturen ?
5662 if ( deleteIt ) {
5763 sts . push ( $rdf . st ( message , ns . schema ( 'dateDeleted' ) , dateStamp , chatDocument ) )
64+ msg [ 'dateDeleted' ] = dateStamp
5865 }
5966 } else { // link new message to channel
6067 sts . push ( $rdf . st ( this . channel , ns . wf ( 'message' ) , message , chatDocument ) )
6168 }
6269 sts . push (
6370 $rdf . st ( message , ns . sioc ( 'content' ) , store . literal ( text ) , chatDocument )
6471 )
72+ msg [ 'content' ] = text
73+
6574 sts . push (
6675 $rdf . st ( message , ns . dct ( 'created' ) , dateStamp , chatDocument )
6776 )
77+ msg [ 'created' ] = dateStamp
6878 if ( me ) {
6979 sts . push ( $rdf . st ( message , ns . foaf ( 'maker' ) , me , chatDocument ) )
80+ msg [ 'maker' ] = me
81+ // privateKey the cached private key of me, cache should be deleted after a certain time
82+ sts . push ( $rdf . st ( message , $rdf . sym ( `${ SEC } Proof` ) , $rdf . sym ( signMsg ( msg , privateKey [ me ] ) , chatDocument ) ) )
7083 }
7184 try {
7285 await store . updater . update ( [ ] , sts )
0 commit comments