solid-ui 2.4.27-6c8461c9 → 2.4.27-7184a38a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/solid-ui.js +1527 -1175
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +1 -1
- package/dist/solid-ui.min.js.map +1 -1
- package/lib/chat/chatLogic.js +63 -37
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/keys.d.ts +2 -2
- package/lib/chat/keys.d.ts.map +1 -1
- package/lib/chat/keys.js +206 -49
- package/lib/chat/keys.js.map +1 -1
- package/lib/chat/message.js +30 -12
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/signature.d.ts.map +1 -1
- package/lib/chat/signature.js +2 -2
- package/lib/chat/signature.js.map +1 -1
- package/lib/utils/cryptoKeyHelpers.d.ts +5 -0
- package/lib/utils/cryptoKeyHelpers.d.ts.map +1 -0
- package/lib/utils/cryptoKeyHelpers.js +157 -0
- package/lib/utils/cryptoKeyHelpers.js.map +1 -0
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/package.json +1 -1
- package/lib/chat/crypto.d.ts +0 -1
- package/lib/chat/crypto.d.ts.map +0 -1
- package/lib/chat/crypto.js +0 -257
- package/lib/chat/crypto.js.map +0 -1
package/lib/chat/chatLogic.js
CHANGED
|
@@ -85,7 +85,7 @@ var ChatChannel = /*#__PURE__*/function () {
|
|
|
85
85
|
var oldMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
86
86
|
var deleteIt = arguments.length > 2 ? arguments[2] : undefined;
|
|
87
87
|
return /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
88
|
-
var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, privateKey,
|
|
88
|
+
var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, oldMsgMaker, errMsg, privateKey, pubKey, sig, _errMsg;
|
|
89
89
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
90
90
|
while (1) switch (_context2.prev = _context2.next) {
|
|
91
91
|
case 0:
|
|
@@ -96,57 +96,83 @@ var ChatChannel = /*#__PURE__*/function () {
|
|
|
96
96
|
chatDocument = oldMsg ? oldMsg.doc() : _this.dateFolder.leafDocumentFromDate(now);
|
|
97
97
|
message = _solidLogic.store.sym(chatDocument.uri + '#' + 'Msg' + timestamp); // const content = store.literal(text)
|
|
98
98
|
me = _solidLogic.authn.currentUser(); // If already logged on
|
|
99
|
-
msg = _signature.getBlankMsg;
|
|
100
|
-
msg.id = message;
|
|
101
|
-
if (oldMsg) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
99
|
+
msg = (0, _signature.getBlankMsg)();
|
|
100
|
+
msg.id = message.uri;
|
|
101
|
+
if (!oldMsg) {
|
|
102
|
+
_context2.next = 22;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
// edit message replaces old one
|
|
106
|
+
oldMsgMaker = _solidLogic.store.any(oldMsg, ns.foaf('maker')); // may not be needed here, but needed on READ
|
|
107
|
+
if (!(oldMsgMaker.uri === me.uri)) {
|
|
108
|
+
_context2.next = 16;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument));
|
|
112
|
+
if (deleteIt) {
|
|
113
|
+
// we need to add a specific signature, else anyone can delete a msg ?
|
|
114
|
+
sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument));
|
|
115
|
+
// msg.dateDeleted = dateStamp
|
|
112
116
|
}
|
|
117
|
+
_context2.next = 20;
|
|
118
|
+
break;
|
|
119
|
+
case 16:
|
|
120
|
+
errMsg = 'Error you cannot delete/edit a message from someone else : \n' + oldMsgMaker.uri;
|
|
121
|
+
debug.warn(errMsg);
|
|
122
|
+
alert(errMsg);
|
|
123
|
+
throw new Error(errMsg);
|
|
124
|
+
case 20:
|
|
125
|
+
_context2.next = 23;
|
|
126
|
+
break;
|
|
127
|
+
case 22:
|
|
128
|
+
// link new message to channel
|
|
129
|
+
sts.push($rdf.st(_this.channel, ns.wf('message'), message, chatDocument));
|
|
130
|
+
case 23:
|
|
113
131
|
sts.push($rdf.st(message, ns.sioc('content'), _solidLogic.store.literal(text), chatDocument));
|
|
114
132
|
msg.content = text;
|
|
115
133
|
sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
|
|
116
|
-
msg.created = dateStamp;
|
|
134
|
+
msg.created = dateStamp.value;
|
|
117
135
|
if (!me) {
|
|
118
|
-
_context2.next =
|
|
136
|
+
_context2.next = 36;
|
|
119
137
|
break;
|
|
120
138
|
}
|
|
121
139
|
sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
|
|
122
|
-
msg.maker = me;
|
|
123
|
-
// privateKey the cached private key of me,
|
|
124
|
-
_context2.next =
|
|
125
|
-
return (0, _keys.getPrivateKey)(me);
|
|
126
|
-
case
|
|
140
|
+
msg.maker = me.uri;
|
|
141
|
+
// privateKey the cached private key of me, cached in store
|
|
142
|
+
_context2.next = 32;
|
|
143
|
+
return (0, _keys.getPrivateKey)(me.uri);
|
|
144
|
+
case 32:
|
|
127
145
|
privateKey = _context2.sent;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
146
|
+
// const privateKey0 = 'a11bc5d2eee6cdb3b37f5473a712cad905ccfb13fb2ccdbf1be0a1ac4fdc7d2a'
|
|
147
|
+
// const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'
|
|
148
|
+
pubKey = (0, _keys.getPublicKey)(me.uri);
|
|
149
|
+
sig = (0, _signature.signMsg)(msg, privateKey);
|
|
150
|
+
/* const verify = verifySignature(sig, msg, pubKey) // alain to remove
|
|
151
|
+
debug.warn('sig ' + sig)
|
|
152
|
+
debug.warn('verifySign ' + verify)
|
|
153
|
+
debug.warn(msg) */
|
|
154
|
+
sts.push($rdf.st(message, $rdf.sym("".concat(_signature.SEC, "Proof")), $rdf.lit(sig), chatDocument));
|
|
155
|
+
case 36:
|
|
156
|
+
_context2.prev = 36;
|
|
157
|
+
_context2.next = 39;
|
|
132
158
|
return _solidLogic.store.updater.update([], sts);
|
|
133
|
-
case
|
|
134
|
-
_context2.next =
|
|
159
|
+
case 39:
|
|
160
|
+
_context2.next = 47;
|
|
135
161
|
break;
|
|
136
|
-
case
|
|
137
|
-
_context2.prev =
|
|
138
|
-
_context2.t0 = _context2["catch"](
|
|
139
|
-
|
|
140
|
-
debug.warn(
|
|
141
|
-
alert(
|
|
142
|
-
throw new Error(
|
|
143
|
-
case
|
|
162
|
+
case 41:
|
|
163
|
+
_context2.prev = 41;
|
|
164
|
+
_context2.t0 = _context2["catch"](36);
|
|
165
|
+
_errMsg = 'Error saving chat message: ' + _context2.t0;
|
|
166
|
+
debug.warn(_errMsg);
|
|
167
|
+
alert(_errMsg);
|
|
168
|
+
throw new Error(_errMsg);
|
|
169
|
+
case 47:
|
|
144
170
|
return _context2.abrupt("return", message);
|
|
145
|
-
case
|
|
171
|
+
case 48:
|
|
146
172
|
case "end":
|
|
147
173
|
return _context2.stop();
|
|
148
174
|
}
|
|
149
|
-
}, _callee2, null, [[
|
|
175
|
+
}, _callee2, null, [[36, 41]]);
|
|
150
176
|
})();
|
|
151
177
|
});
|
|
152
178
|
function updateMessage(_x2) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatLogic.js","names":["debug","_interopRequireWildcard","require","_dateFolder","_solidLogic","ns","$rdf","utils","_signature","_keys","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ChatChannel","channel","options","_classCallCheck2","channelRoot","doc","dateFolder","DateFolder","div","_createClass2","value","_createMessage","_asyncToGenerator2","_regenerator","mark","_callee","text","wrap","_callee$","_context","prev","next","abrupt","updateMessage","stop","createMessage","_x","apply","arguments","_updateMessage","_this","oldMsg","length","undefined","deleteIt","_callee2","sts","now","timestamp","dateStamp","chatDocument","message","me","msg","privateKey","errMsg","_callee2$","_context2","Date","getTime","term","leafDocumentFromDate","store","sym","uri","authn","currentUser","getBlankMsg","id","push","st","mostRecentVersion","dct","schema","dateDeleted","wf","sioc","literal","content","created","foaf","maker","getPrivateKey","sent","concat","SEC","signMsg","updater","update","t0","warn","alert","Error","_x2","_deleteMessage","_callee3","_callee3$","_context3","deleteMessage","_x3","exports","originalVersion","any","isDeleted","holds","isReplaced","isHidden","nick","person","s","label","_createIfNotExists","_x4","_createIfNotExists2","contentType","data","_callee4","response","_callee4$","_context4","fetcher","load","status","log","webOperation","t1","requested"],"sources":["../../src/chat/chatLogic.js"],"sourcesContent":["/**\n * Contains the [[ChatChannel]] class and logic for Solid Chat\n * @packageDocumentation\n */\n\nimport * as debug from '../debug'\nimport { DateFolder } from './dateFolder'\nimport { store, authn } from 'solid-logic'\nimport * as ns from '../ns'\nimport * as $rdf from 'rdflib' // pull in first avoid cross-refs\nimport * as utils from '../utils'\nimport { getBlankMsg, signMsg, SEC } from './signature'\nimport { getPrivateKey } from './keys'\n\n/* The Solid logic for a 'LongChat'\n*/\n/**\n * Common code for a chat (discussion area of messages about something)\n * This version runs over a series of files for different time periods\n *\n * Parameters for the whole chat like its title are stored on\n * index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl\n *\n */\n\nexport class ChatChannel {\n constructor (channel, options) {\n this.channel = channel\n this.channelRoot = channel.doc()\n this.options = options\n this.dateFolder = new DateFolder(this.channelRoot, 'chat.ttl')\n this.div = null // : HTMLElement\n }\n\n /* Store a new message in the web,\n */\n async createMessage (text) {\n return this.updateMessage(text)\n }\n\n /* Store a new message in the web,\n as a replacement for an existing one.\n The old one iis left, and the two are linked\n */\n async updateMessage (text, oldMsg = null, deleteIt) {\n const sts = []\n const now = new Date()\n const timestamp = '' + now.getTime()\n const dateStamp = $rdf.term(now)\n const chatDocument = oldMsg ? oldMsg.doc() : this.dateFolder.leafDocumentFromDate(now)\n const message = store.sym(chatDocument.uri + '#' + 'Msg' + timestamp)\n // const content = store.literal(text)\n\n const me = authn.currentUser() // If already logged on\n\n const msg = getBlankMsg\n msg.id = message\n if (oldMsg) { // edit message replaces old one\n sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument))\n // do we need to rebuild oldMsg signaturen ?\n if (deleteIt) {\n sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument))\n msg.dateDeleted = dateStamp\n }\n } else { // link new message to channel\n sts.push($rdf.st(this.channel, ns.wf('message'), message, chatDocument))\n }\n sts.push(\n $rdf.st(message, ns.sioc('content'), store.literal(text), chatDocument)\n )\n msg.content = text\n\n sts.push(\n $rdf.st(message, ns.dct('created'), dateStamp, chatDocument)\n )\n msg.created = dateStamp\n if (me) {\n sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument))\n msg.maker = me\n // privateKey the cached private key of me, cache should be deleted after a certain time\n const privateKey = await getPrivateKey(me)\n sts.push($rdf.st(message, $rdf.sym(`${SEC}Proof`), $rdf.sym(signMsg(msg, privateKey), chatDocument)))\n }\n try {\n await store.updater.update([], sts)\n } catch (err) {\n const errMsg = 'Error saving chat message: ' + err\n debug.warn(errMsg)\n alert(errMsg)\n throw new Error(errMsg)\n }\n return message\n }\n\n /* Mark a message as deleted\n * Wee add a new version of the message,m witha deletion flag (deletion date)\n * so that the deletion can be revoked by adding another non-deleted update\n */\n async deleteMessage (message) {\n return this.updateMessage('(message deleted)', message, true)\n }\n} // class ChatChannel\n\nexport function originalVersion (message) {\n let msg = message\n while (msg) {\n message = msg\n msg = store.any(null, ns.dct('isReplacedBy'), message, message.doc())\n }\n return message\n}\n\nexport function mostRecentVersion (message) {\n let msg = message\n while (msg) {\n message = msg\n msg = store.any(message, ns.dct('isReplacedBy'), null, message.doc())\n }\n return message\n}\n\nexport function isDeleted (message) {\n return store.holds(message, ns.schema('dateDeleted'), null, message.doc())\n}\n\nexport function isReplaced (message) {\n return store.holds(message, ns.dct('isReplacedBy'), null, message.doc())\n}\n\nexport function isHidden (message) {\n return this.isDeleted(message) || this.isReplaced(message)\n}\n\n// A Nickname for a person\n\nexport function nick (person) {\n const s = store.any(person, ns.foaf('nick'))\n if (s) return '' + s.value\n return '' + utils.label(person)\n}\n\nexport async function _createIfNotExists (doc, contentType = 'text/turtle', data = '') {\n let response\n try {\n response = await store.fetcher.load(doc)\n } catch (err) {\n if (err.response.status === 404) {\n debug.log(\n 'createIfNotExists: doc does NOT exist, will create... ' + doc\n )\n try {\n response = await store.fetcher.webOperation('PUT', doc.uri, {\n data,\n contentType\n })\n } catch (err) {\n debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + err)\n throw err\n }\n delete store.fetcher.requested[doc.uri] // delete cached 404 error\n // debug.log('createIfNotExists doc created ok ' + doc)\n return response\n } else {\n debug.log(\n 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err\n )\n throw err\n }\n }\n // debug.log('createIfNotExists: doc exists, all good: ' + doc)\n return response\n}\n// ends\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,EAAA,GAAAJ,uBAAA,CAAAC,OAAA;AACA,IAAAI,IAAA,GAAAL,uBAAA,CAAAC,OAAA;AACA,IAAAK,KAAA,GAAAN,uBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAAsC,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA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;YAC7BrD,KAAK,CAACiJ,GAAG,CACP,wDAAwD,GAAG5G,GAAG,CAC/D;YAAAwG,SAAA,CAAAzF,IAAA;YAAAyF,SAAA,CAAAxF,IAAA;YAAA,OAEkB+B,iBAAK,CAAC0D,OAAO,CAACI,YAAY,CAAC,KAAK,EAAE7G,GAAG,CAACiD,GAAG,EAAE;cAC1DmD,IAAI,EAAJA,IAAI;cACJD,WAAW,EAAXA;YACF,CAAC,CAAC;UAAA;YAHFG,QAAQ,GAAAE,SAAA,CAAApC,IAAA;YAAAoC,SAAA,CAAAxF,IAAA;YAAA;UAAA;YAAAwF,SAAA,CAAAzF,IAAA;YAAAyF,SAAA,CAAAM,EAAA,GAAAN,SAAA;YAKR7I,KAAK,CAACiJ,GAAG,CAAC,gCAAgC,GAAG5G,GAAG,GAAG,IAAI,GAAAwG,SAAA,CAAAM,EAAM,CAAC;YAAA,MAAAN,SAAA,CAAAM,EAAA;UAAA;YAGhE,OAAO/D,iBAAK,CAAC0D,OAAO,CAACM,SAAS,CAAC/G,GAAG,CAACiD,GAAG,CAAC,EAAC;YACxC;YAAA,OAAAuD,SAAA,CAAAvF,MAAA,WACOqF,QAAQ;UAAA;YAEf3I,KAAK,CAACiJ,GAAG,CACP,6CAA6C,GAAG5G,GAAG,GAAG,IAAI,GAAAwG,SAAA,CAAA9B,EAAM,CACjE;YAAA,MAAA8B,SAAA,CAAA9B,EAAA;UAAA;YAAA,OAAA8B,SAAA,CAAAvF,MAAA,WAKEqF,QAAQ;UAAA;UAAA;YAAA,OAAAE,SAAA,CAAArF,IAAA;QAAA;MAAA,GAAAkF,QAAA;IAAA;EAAA,CAChB;EAAA,OAAAH,mBAAA,CAAA5E,KAAA,OAAAC,SAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"chatLogic.js","names":["debug","_interopRequireWildcard","require","_dateFolder","_solidLogic","ns","$rdf","utils","_signature","_keys","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ChatChannel","channel","options","_classCallCheck2","channelRoot","doc","dateFolder","DateFolder","div","_createClass2","value","_createMessage","_asyncToGenerator2","_regenerator","mark","_callee","text","wrap","_callee$","_context","prev","next","abrupt","updateMessage","stop","createMessage","_x","apply","arguments","_updateMessage","_this","oldMsg","length","undefined","deleteIt","_callee2","sts","now","timestamp","dateStamp","chatDocument","message","me","msg","oldMsgMaker","errMsg","privateKey","pubKey","sig","_errMsg","_callee2$","_context2","Date","getTime","term","leafDocumentFromDate","store","sym","uri","authn","currentUser","getBlankMsg","id","any","foaf","push","st","mostRecentVersion","dct","schema","warn","alert","Error","wf","sioc","literal","content","created","maker","getPrivateKey","sent","getPublicKey","signMsg","concat","SEC","lit","updater","update","t0","_x2","_deleteMessage","_callee3","_callee3$","_context3","deleteMessage","_x3","exports","originalVersion","isDeleted","holds","isReplaced","isHidden","nick","person","s","label","_createIfNotExists","_x4","_createIfNotExists2","contentType","data","_callee4","response","_callee4$","_context4","fetcher","load","status","log","webOperation","t1","requested"],"sources":["../../src/chat/chatLogic.js"],"sourcesContent":["/**\n * Contains the [[ChatChannel]] class and logic for Solid Chat\n * @packageDocumentation\n */\n\nimport * as debug from '../debug'\nimport { DateFolder } from './dateFolder'\nimport { store, authn } from 'solid-logic'\nimport * as ns from '../ns'\nimport * as $rdf from 'rdflib' // pull in first avoid cross-refs\nimport * as utils from '../utils'\nimport { getBlankMsg, signMsg, SEC, verifySignature } from './signature'\nimport { getPrivateKey, getPublicKey } from './keys'\n\n/* The Solid logic for a 'LongChat'\n*/\n/**\n * Common code for a chat (discussion area of messages about something)\n * This version runs over a series of files for different time periods\n *\n * Parameters for the whole chat like its title are stored on\n * index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl\n *\n */\n\nexport class ChatChannel {\n constructor (channel, options) {\n this.channel = channel\n this.channelRoot = channel.doc()\n this.options = options\n this.dateFolder = new DateFolder(this.channelRoot, 'chat.ttl')\n this.div = null // : HTMLElement\n }\n\n /* Store a new message in the web,\n */\n async createMessage (text) {\n return this.updateMessage(text)\n }\n\n /* Store a new message in the web,\n as a replacement for an existing one.\n The old one iis left, and the two are linked\n */\n async updateMessage (text, oldMsg = null, deleteIt) {\n const sts = []\n const now = new Date()\n const timestamp = '' + now.getTime()\n const dateStamp = $rdf.term(now)\n const chatDocument = oldMsg ? oldMsg.doc() : this.dateFolder.leafDocumentFromDate(now)\n const message = store.sym(chatDocument.uri + '#' + 'Msg' + timestamp)\n // const content = store.literal(text)\n\n const me = authn.currentUser() // If already logged on\n\n const msg = getBlankMsg()\n msg.id = message.uri\n if (oldMsg) { // edit message replaces old one\n const oldMsgMaker = store.any(oldMsg, ns.foaf('maker')) // may not be needed here, but needed on READ\n if (oldMsgMaker.uri === me.uri) {\n sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument))\n if (deleteIt) { // we need to add a specific signature, else anyone can delete a msg ?\n sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument))\n // msg.dateDeleted = dateStamp\n }\n } else {\n const errMsg = 'Error you cannot delete/edit a message from someone else : \\n' + oldMsgMaker.uri\n debug.warn(errMsg)\n alert(errMsg)\n throw new Error(errMsg)\n }\n } else { // link new message to channel\n sts.push($rdf.st(this.channel, ns.wf('message'), message, chatDocument))\n }\n sts.push(\n $rdf.st(message, ns.sioc('content'), store.literal(text), chatDocument)\n )\n msg.content = text\n\n sts.push(\n $rdf.st(message, ns.dct('created'), dateStamp, chatDocument)\n )\n msg.created = dateStamp.value\n if (me) {\n sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument))\n msg.maker = me.uri\n // privateKey the cached private key of me, cached in store\n const privateKey = await getPrivateKey(me.uri)\n // const privateKey0 = 'a11bc5d2eee6cdb3b37f5473a712cad905ccfb13fb2ccdbf1be0a1ac4fdc7d2a'\n // const pubKey0 = '023a9da707bee1302f66083c9d95673ff969b41607a66f52686fa774d64ceb87'\n const pubKey = getPublicKey(me.uri)\n\n const sig = signMsg(msg, privateKey)\n /* const verify = verifySignature(sig, msg, pubKey) // alain to remove\n debug.warn('sig ' + sig)\n debug.warn('verifySign ' + verify)\n debug.warn(msg) */\n sts.push($rdf.st(message, $rdf.sym(`${SEC}Proof`), $rdf.lit(sig), chatDocument))\n }\n try {\n await store.updater.update([], sts)\n } catch (err) {\n const errMsg = 'Error saving chat message: ' + err\n debug.warn(errMsg)\n alert(errMsg)\n throw new Error(errMsg)\n }\n return message\n }\n\n /* Mark a message as deleted\n * Wee add a new version of the message,m witha deletion flag (deletion date)\n * so that the deletion can be revoked by adding another non-deleted update\n */\n async deleteMessage (message) {\n return this.updateMessage('(message deleted)', message, true)\n }\n} // class ChatChannel\n\nexport function originalVersion (message) {\n let msg = message\n while (msg) {\n message = msg\n msg = store.any(null, ns.dct('isReplacedBy'), message, message.doc())\n }\n return message\n}\n\nexport function mostRecentVersion (message) {\n let msg = message\n while (msg) {\n message = msg\n msg = store.any(message, ns.dct('isReplacedBy'), null, message.doc())\n }\n return message\n}\n\nexport function isDeleted (message) {\n return store.holds(message, ns.schema('dateDeleted'), null, message.doc())\n}\n\nexport function isReplaced (message) {\n return store.holds(message, ns.dct('isReplacedBy'), null, message.doc())\n}\n\nexport function isHidden (message) {\n return this.isDeleted(message) || this.isReplaced(message)\n}\n\n// A Nickname for a person\n\nexport function nick (person) {\n const s = store.any(person, ns.foaf('nick'))\n if (s) return '' + s.value\n return '' + utils.label(person)\n}\n\nexport async function _createIfNotExists (doc, contentType = 'text/turtle', data = '') {\n let response\n try {\n response = await store.fetcher.load(doc)\n } catch (err) {\n if (err.response.status === 404) {\n debug.log(\n 'createIfNotExists: doc does NOT exist, will create... ' + doc\n )\n try {\n response = await store.fetcher.webOperation('PUT', doc.uri, {\n data,\n contentType\n })\n } catch (err) {\n debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + err)\n throw err\n }\n delete store.fetcher.requested[doc.uri] // delete cached 404 error\n // debug.log('createIfNotExists doc created ok ' + doc)\n return response\n } else {\n debug.log(\n 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err\n )\n throw err\n }\n }\n // debug.log('createIfNotExists: doc exists, all good: ' + doc)\n return response\n}\n// ends\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,EAAA,GAAAJ,uBAAA,CAAAC,OAAA;AACA,IAAAI,IAAA,GAAAL,uBAAA,CAAAC,OAAA;AACA,IAAAK,KAAA,GAAAN,uBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAAoD,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAV,wBAAAc,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,E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AAA;AAAA"}
|
package/lib/chat/keys.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function generatePrivateKey(): string;
|
|
2
2
|
export declare function generatePublicKey(privateKey: string): string;
|
|
3
|
-
export declare function getPublicKey(webId: any):
|
|
4
|
-
export declare function getPrivateKey(webId:
|
|
3
|
+
export declare function getPublicKey(webId: any): Promise<string | undefined>;
|
|
4
|
+
export declare function getPrivateKey(webId: string): Promise<string>;
|
|
5
5
|
//# sourceMappingURL=keys.d.ts.map
|
package/lib/chat/keys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/chat/keys.ts"],"names":[],"mappings":"AAQA,wBAAgB,kBAAkB,IAAK,MAAM,CAE5C;AAED,wBAAgB,iBAAiB,CAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/chat/keys.ts"],"names":[],"mappings":"AAQA,wBAAgB,kBAAkB,IAAK,MAAM,CAE5C;AAED,wBAAgB,iBAAiB,CAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAsB,YAAY,CAAE,KAAK,KAAA,+BAaxC;AAED,wBAAsB,aAAa,CAAE,KAAK,EAAE,MAAM,mBAuDjD"}
|
package/lib/chat/keys.js
CHANGED
|
@@ -11,80 +11,237 @@ exports.getPrivateKey = getPrivateKey;
|
|
|
11
11
|
exports.getPublicKey = getPublicKey;
|
|
12
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
+
var debug = _interopRequireWildcard(require("../debug"));
|
|
14
15
|
var _secp256k = require("@noble/curves/secp256k1");
|
|
15
16
|
var _utils = require("@noble/hashes/utils");
|
|
16
17
|
var _signature = require("./signature");
|
|
17
18
|
var _solidLogic = require("solid-logic");
|
|
18
19
|
var $rdf = _interopRequireWildcard(require("rdflib"));
|
|
20
|
+
var _cryptoKeyHelpers = require("../utils/cryptoKeyHelpers");
|
|
19
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
// should have webcrypto.getRandomValues defined
|
|
22
|
-
|
|
23
23
|
function generatePrivateKey() {
|
|
24
24
|
return (0, _utils.bytesToHex)(_secp256k.schnorr.utils.randomPrivateKey());
|
|
25
25
|
}
|
|
26
26
|
function generatePublicKey(privateKey) {
|
|
27
27
|
return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
|
|
28
28
|
}
|
|
29
|
-
function getPublicKey(
|
|
30
|
-
|
|
31
|
-
/* const url = new URL(webId)
|
|
32
|
-
url.hash = ''
|
|
33
|
-
store.fetcher.load(url.href)
|
|
34
|
-
let publicKey = store.any(store.sym(webId), store.sym(CERT +'publicKey')) */
|
|
35
|
-
var publicKey = publicKeyExists(webId);
|
|
36
|
-
return publicKey === null || publicKey === void 0 ? void 0 : publicKey.uri;
|
|
37
|
-
}
|
|
38
|
-
function publicKeyExists(webId) {
|
|
39
|
-
// find publickey
|
|
40
|
-
var url = new URL(webId);
|
|
41
|
-
url.hash = '';
|
|
42
|
-
_solidLogic.store.fetcher.load(url.href);
|
|
43
|
-
var publicKey = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'publicKey'));
|
|
44
|
-
return publicKey;
|
|
29
|
+
function getPublicKey(_x) {
|
|
30
|
+
return _getPublicKey.apply(this, arguments);
|
|
45
31
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
function _getPublicKey() {
|
|
33
|
+
_getPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
|
|
34
|
+
var publicKeyDoc, key;
|
|
35
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
36
|
+
while (1) switch (_context.prev = _context.next) {
|
|
37
|
+
case 0:
|
|
38
|
+
_context.next = 2;
|
|
39
|
+
return _solidLogic.store.fetcher.load(webId);
|
|
40
|
+
case 2:
|
|
41
|
+
publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
|
|
42
|
+
_context.prev = 3;
|
|
43
|
+
_context.next = 6;
|
|
44
|
+
return _solidLogic.store.fetcher.load(publicKeyDoc);
|
|
45
|
+
case 6:
|
|
46
|
+
// url.href)
|
|
47
|
+
key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + 'PublicKey'));
|
|
48
|
+
return _context.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
|
|
49
|
+
case 10:
|
|
50
|
+
_context.prev = 10;
|
|
51
|
+
_context.t0 = _context["catch"](3);
|
|
52
|
+
return _context.abrupt("return", undefined);
|
|
53
|
+
case 13:
|
|
54
|
+
case "end":
|
|
55
|
+
return _context.stop();
|
|
56
|
+
}
|
|
57
|
+
}, _callee, null, [[3, 10]]);
|
|
58
|
+
}));
|
|
59
|
+
return _getPublicKey.apply(this, arguments);
|
|
52
60
|
}
|
|
53
|
-
function getPrivateKey(
|
|
61
|
+
function getPrivateKey(_x2) {
|
|
54
62
|
return _getPrivateKey.apply(this, arguments);
|
|
55
63
|
}
|
|
56
64
|
function _getPrivateKey() {
|
|
57
|
-
_getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
58
|
-
var
|
|
59
|
-
return _regenerator["default"].wrap(function
|
|
60
|
-
while (1) switch (
|
|
65
|
+
_getPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
|
|
66
|
+
var publicKeyDoc, privateKeyDoc, publicKey, privateKey, validPublicKey, del, add, newPublicKey, keyContainer;
|
|
67
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
68
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
61
69
|
case 0:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
_context2.next = 2;
|
|
71
|
+
return _solidLogic.store.fetcher.load(webId);
|
|
72
|
+
case 2:
|
|
73
|
+
// find keys url's
|
|
74
|
+
publicKeyDoc = (0, _cryptoKeyHelpers.pubKeyUrl)(webId);
|
|
75
|
+
privateKeyDoc = (0, _cryptoKeyHelpers.privKeyUrl)(webId); // find key pair
|
|
76
|
+
_context2.next = 6;
|
|
77
|
+
return (0, _cryptoKeyHelpers.publicKeyExists)(webId);
|
|
78
|
+
case 6:
|
|
79
|
+
publicKey = _context2.sent;
|
|
80
|
+
_context2.next = 9;
|
|
81
|
+
return (0, _cryptoKeyHelpers.privateKeyExists)(webId);
|
|
82
|
+
case 9:
|
|
83
|
+
privateKey = _context2.sent;
|
|
84
|
+
// is publicKey valid ?
|
|
85
|
+
validPublicKey = true;
|
|
86
|
+
if (privateKey && publicKey !== generatePublicKey(privateKey)) {
|
|
87
|
+
if (confirm('This is strange the publicKey is not valid for\n' + webId + '\'shall we repair keeping the private key ?')) validPublicKey = false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// create key pair or repair publicKey
|
|
91
|
+
if (!(!privateKey || !publicKey || !validPublicKey)) {
|
|
92
|
+
_context2.next = 30;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
del = [];
|
|
96
|
+
add = []; // if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyDoc)))
|
|
97
|
+
if (privateKey) {
|
|
98
|
+
_context2.next = 20;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
// add = []
|
|
102
|
+
privateKey = generatePrivateKey();
|
|
103
|
+
add = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PrivateKey'), $rdf.literal(privateKey), $rdf.sym(privateKeyDoc))];
|
|
104
|
+
_context2.next = 20;
|
|
105
|
+
return saveKey(privateKeyDoc, [], add, webId);
|
|
106
|
+
case 20:
|
|
107
|
+
if (!(!publicKey || !validPublicKey)) {
|
|
108
|
+
_context2.next = 27;
|
|
68
109
|
break;
|
|
69
110
|
}
|
|
70
111
|
del = [];
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
112
|
+
// delete invalid public key
|
|
113
|
+
if (publicKey) {
|
|
114
|
+
del = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(publicKeyDoc))];
|
|
115
|
+
debug.log(del);
|
|
116
|
+
}
|
|
117
|
+
// update new valid key
|
|
118
|
+
newPublicKey = generatePublicKey(privateKey);
|
|
119
|
+
add = [$rdf.st($rdf.sym(webId), $rdf.sym(_signature.CERT + 'PublicKey'), $rdf.literal(newPublicKey), $rdf.sym(publicKeyDoc))];
|
|
120
|
+
_context2.next = 27;
|
|
121
|
+
return saveKey(publicKeyDoc, del, add);
|
|
122
|
+
case 27:
|
|
123
|
+
keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1);
|
|
124
|
+
_context2.next = 30;
|
|
125
|
+
return setAcl(keyContainer, keyContainerAclBody(webId));
|
|
126
|
+
case 30:
|
|
127
|
+
return _context2.abrupt("return", privateKey);
|
|
128
|
+
case 31:
|
|
83
129
|
case "end":
|
|
84
|
-
return
|
|
130
|
+
return _context2.stop();
|
|
85
131
|
}
|
|
86
|
-
},
|
|
132
|
+
}, _callee2);
|
|
87
133
|
}));
|
|
88
134
|
return _getPrivateKey.apply(this, arguments);
|
|
89
135
|
}
|
|
136
|
+
var keyContainerAclBody = function keyContainerAclBody(me) {
|
|
137
|
+
var aclBody = "\n@prefix : <#>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix key: <./>.\n\n:ReadWrite\n a acl:Authorization;\n acl:accessTo key:;\n acl:agent <".concat(me, ">;\n acl:mode acl:Read, acl:Write.\n:Read\n a acl:Authorization;\n acl:accessTo key:;\n acl:default key:;\n acl:agentClass foaf:Agent;\n acl:mode acl:Read.\n");
|
|
138
|
+
return aclBody;
|
|
139
|
+
};
|
|
140
|
+
var keyAclBody = function keyAclBody(keyDoc, me) {
|
|
141
|
+
var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
|
|
142
|
+
if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
|
|
143
|
+
var aclBody = "\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#Read>\n a acl:Authorization;\n ".concat(keyAgent, ";\n acl:accessTo <").concat(keyDoc.split('/').pop(), ">;\n acl:mode acl:Read, acl:Control. # NSS issue: missing acl link header with READ only\n");
|
|
144
|
+
return aclBody;
|
|
145
|
+
};
|
|
146
|
+
function setAcl(_x3, _x4) {
|
|
147
|
+
return _setAcl.apply(this, arguments);
|
|
148
|
+
}
|
|
149
|
+
function _setAcl() {
|
|
150
|
+
_setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(keyDoc, aclBody) {
|
|
151
|
+
var keyAclDoc, aclResponse;
|
|
152
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
153
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
154
|
+
case 0:
|
|
155
|
+
_context3.next = 2;
|
|
156
|
+
return _solidLogic.store.fetcher.load(keyDoc);
|
|
157
|
+
case 2:
|
|
158
|
+
// FIXME: check the Why value on this quad:
|
|
159
|
+
keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
160
|
+
if (keyAclDoc) {
|
|
161
|
+
_context3.next = 5;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
throw new Error('Key ACL doc not found!');
|
|
165
|
+
case 5:
|
|
166
|
+
_context3.next = 7;
|
|
167
|
+
return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
|
|
168
|
+
data: aclBody,
|
|
169
|
+
contentType: 'text/turtle'
|
|
170
|
+
});
|
|
171
|
+
case 7:
|
|
172
|
+
aclResponse = _context3.sent;
|
|
173
|
+
case 8:
|
|
174
|
+
case "end":
|
|
175
|
+
return _context3.stop();
|
|
176
|
+
}
|
|
177
|
+
}, _callee3);
|
|
178
|
+
}));
|
|
179
|
+
return _setAcl.apply(this, arguments);
|
|
180
|
+
}
|
|
181
|
+
function saveKey(_x5, _x6, _x7) {
|
|
182
|
+
return _saveKey.apply(this, arguments);
|
|
183
|
+
}
|
|
184
|
+
function _saveKey() {
|
|
185
|
+
_saveKey = (0, _asyncToGenerator2["default"])(function (keyDoc, del, add) {
|
|
186
|
+
var me = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
187
|
+
return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
188
|
+
var keyAclDoc, response, aclBody;
|
|
189
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
190
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
191
|
+
case 0:
|
|
192
|
+
_context4.next = 2;
|
|
193
|
+
return _solidLogic.store.updater.updateMany(del, add);
|
|
194
|
+
case 2:
|
|
195
|
+
_context4.next = 4;
|
|
196
|
+
return _solidLogic.store.fetcher.load(keyDoc);
|
|
197
|
+
case 4:
|
|
198
|
+
_context4.prev = 4;
|
|
199
|
+
// get keyAcldoc
|
|
200
|
+
keyAclDoc = _solidLogic.store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
201
|
+
if (keyAclDoc) {
|
|
202
|
+
_context4.next = 8;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
throw new Error("".concat(keyDoc, " ACL doc not found!"));
|
|
206
|
+
case 8:
|
|
207
|
+
_context4.prev = 8;
|
|
208
|
+
_context4.next = 11;
|
|
209
|
+
return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
|
|
210
|
+
case 11:
|
|
211
|
+
response = _context4.sent;
|
|
212
|
+
// this may fail if webId is not an owner
|
|
213
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
|
|
214
|
+
_context4.next = 20;
|
|
215
|
+
break;
|
|
216
|
+
case 15:
|
|
217
|
+
_context4.prev = 15;
|
|
218
|
+
_context4.t0 = _context4["catch"](8);
|
|
219
|
+
if (!(_context4.t0.response.status !== 404)) {
|
|
220
|
+
_context4.next = 19;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
throw new Error(_context4.t0);
|
|
224
|
+
case 19:
|
|
225
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + _context4.t0.response.status); // should test 404 and 2xx
|
|
226
|
+
case 20:
|
|
227
|
+
// create READ only ACL
|
|
228
|
+
aclBody = keyAclBody(keyDoc, me);
|
|
229
|
+
_context4.next = 23;
|
|
230
|
+
return setAcl(keyDoc, aclBody);
|
|
231
|
+
case 23:
|
|
232
|
+
_context4.next = 28;
|
|
233
|
+
break;
|
|
234
|
+
case 25:
|
|
235
|
+
_context4.prev = 25;
|
|
236
|
+
_context4.t1 = _context4["catch"](4);
|
|
237
|
+
throw new Error(_context4.t1);
|
|
238
|
+
case 28:
|
|
239
|
+
case "end":
|
|
240
|
+
return _context4.stop();
|
|
241
|
+
}
|
|
242
|
+
}, _callee4, null, [[4, 25], [8, 15]]);
|
|
243
|
+
})();
|
|
244
|
+
});
|
|
245
|
+
return _saveKey.apply(this, arguments);
|
|
246
|
+
}
|
|
90
247
|
//# sourceMappingURL=keys.js.map
|
package/lib/chat/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","names":["_secp256k","require","_utils","_signature","_solidLogic","$rdf","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","generatePrivateKey","bytesToHex","schnorr","utils","randomPrivateKey","generatePublicKey","privateKey","getPublicKey","webId","publicKey","publicKeyExists","uri","url","URL","hash","store","fetcher","load","href","any","sym","CERT","privateKeyExists","privateKeyUrl","hostname","getPrivateKey","_x","_getPrivateKey","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","del","add","wrap","_callee$","_context","prev","next","push","st","literal","updater","updateMany","abrupt","stop"],"sources":["../../src/chat/keys.ts"],"sourcesContent":["import { schnorr } from '@noble/curves/secp256k1'\r\nimport { bytesToHex } from '@noble/hashes/utils'\r\nimport { CERT } from './signature'\r\nimport { store } from 'solid-logic'\r\nimport * as $rdf from 'rdflib'\r\nimport { NamedNode, literal } from 'rdflib'\r\nimport crypto from 'crypto' // should have webcrypto.getRandomValues defined\r\n\r\nexport function generatePrivateKey (): string {\r\n return bytesToHex(schnorr.utils.randomPrivateKey())\r\n}\r\n\r\nexport function generatePublicKey (privateKey: string): string {\r\n return bytesToHex(schnorr.getPublicKey(privateKey))\r\n}\r\n\r\nexport function getPublicKey (webId) {\r\n // find publickey\r\n /* const url = new URL(webId)\r\n url.hash = ''\r\n store.fetcher.load(url.href)\r\n let publicKey = store.any(store.sym(webId), store.sym(CERT +'publicKey')) */\r\n const publicKey = publicKeyExists(webId)\r\n return publicKey?.uri as any\r\n}\r\n\r\nfunction publicKeyExists (webId: string): NamedNode {\r\n // find publickey\r\n const url = new URL(webId)\r\n url.hash = ''\r\n store.fetcher.load(url.href)\r\n const publicKey = store.any(store.sym(webId), store.sym(CERT + 'publicKey'))\r\n return publicKey as NamedNode\r\n}\r\n\r\nfunction privateKeyExists (webId: string): NamedNode {\r\n const url = new URL(webId)\r\n const privateKeyUrl = url.hostname + '/profile/privateKey.ttl'\r\n store.fetcher.load(privateKeyUrl)\r\n const privateKey = store.any(store.sym(webId), store.sym(CERT + 'privateKey'))\r\n return privateKey as NamedNode\r\n}\r\n\r\nexport async function getPrivateKey (webId) {\r\n const url = new URL(webId)\r\n const privateKeyUrl = url.hostname + '/profile/privateKey.ttl'\r\n // find publickey\r\n let publicKey = publicKeyExists(webId)\r\n // find privateKey\r\n let privateKey = privateKeyExists(webId)\r\n // create key pair\r\n if (!privateKey || !publicKey) {\r\n const del: any[] = []\r\n const add: any[] = []\r\n if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'privateKey'), privateKey, $rdf.sym(privateKeyUrl)))\r\n if (publicKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'publicKey'), publicKey, $rdf.sym(url.href)))\r\n\r\n privateKey = store.sym(generatePrivateKey())\r\n publicKey = store.sym(generatePublicKey(privateKey.uri))\r\n\r\n add.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'privateKey'), $rdf.literal(privateKey.uri), $rdf.sym(privateKeyUrl)))\r\n add.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'publicKey'), $rdf.literal(publicKey.uri), $rdf.sym(url.href)))\r\n await store.updater.updateMany(del, add)\r\n }\r\n return privateKey.uri as any\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAC,uBAAA,CAAAL,OAAA;AAA8B,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CA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ACK,GAAG;QAAA;QAAA;UAAA,OAAA2B,QAAA,CAAAS,IAAA;MAAA;IAAA,GAAAd,OAAA;EAAA,CACtB;EAAA,OAAAN,cAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"keys.js","names":["debug","_interopRequireWildcard","require","_secp256k","_utils","_signature","_solidLogic","$rdf","_cryptoKeyHelpers","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","generatePrivateKey","bytesToHex","schnorr","utils","randomPrivateKey","generatePublicKey","privateKey","getPublicKey","_x","_getPublicKey","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","webId","publicKeyDoc","wrap","_callee$","_context","prev","next","store","fetcher","load","pubKeyUrl","any","sym","CERT","abrupt","value","t0","undefined","stop","getPrivateKey","_x2","_getPrivateKey","_callee2","privateKeyDoc","publicKey","validPublicKey","del","add","newPublicKey","keyContainer","_callee2$","_context2","privKeyUrl","publicKeyExists","sent","privateKeyExists","confirm","st","literal","saveKey","lit","log","substring","lastIndexOf","setAcl","keyContainerAclBody","me","aclBody","concat","keyAclBody","keyDoc","keyAgent","length","split","pop","_x3","_x4","_setAcl","_callee3","keyAclDoc","aclResponse","_callee3$","_context3","Error","webOperation","data","contentType","_x5","_x6","_x7","_saveKey","_callee4","response","_callee4$","_context4","updater","updateMany","status","t1"],"sources":["../../src/chat/keys.ts"],"sourcesContent":["import * as debug from '../debug'\r\nimport { schnorr } from '@noble/curves/secp256k1'\r\nimport { bytesToHex } from '@noble/hashes/utils'\r\nimport { CERT } from './signature'\r\nimport { store } from 'solid-logic'\r\nimport * as $rdf from 'rdflib'\r\nimport { publicKeyExists, pubKeyUrl, privKeyUrl, privateKeyExists } from '../utils/cryptoKeyHelpers'\r\n\r\nexport function generatePrivateKey (): string {\r\n return bytesToHex(schnorr.utils.randomPrivateKey())\r\n}\r\n\r\nexport function generatePublicKey (privateKey: string): string {\r\n return bytesToHex(schnorr.getPublicKey(privateKey))\r\n}\r\n\r\nexport async function getPublicKey (webId) {\r\n await store.fetcher.load(webId)\r\n const publicKeyDoc = pubKeyUrl(webId)\r\n try {\r\n await store.fetcher.load(publicKeyDoc) // url.href)\r\n const key = store.any(store.sym(webId), store.sym(CERT + 'PublicKey'))\r\n return key?.value // as NamedNode\r\n } catch (err) {\r\n return undefined\r\n }\r\n // this is called in display message and should not try to create a publicKeyDoc\r\n // const publicKey = await publicKeyExists(webId)\r\n // return publicKey\r\n}\r\n\r\nexport async function getPrivateKey (webId: string) {\r\n await store.fetcher.load(webId)\r\n // find keys url's\r\n const publicKeyDoc = pubKeyUrl(webId)\r\n const privateKeyDoc = privKeyUrl(webId)\r\n\r\n // find key pair\r\n const publicKey = await publicKeyExists(webId)\r\n let privateKey = await privateKeyExists(webId)\r\n\r\n // is publicKey valid ?\r\n let validPublicKey = true\r\n if (privateKey && (publicKey !== generatePublicKey(privateKey as string))) {\r\n if (confirm('This is strange the publicKey is not valid for\\n' + webId +\r\n '\\'shall we repair keeping the private key ?')) validPublicKey = false\r\n }\r\n\r\n // create key pair or repair publicKey\r\n if (!privateKey || !publicKey || !validPublicKey) {\r\n let del: any[] = []\r\n let add: any[] = []\r\n // if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyDoc)))\r\n\r\n if (!privateKey) {\r\n // add = []\r\n privateKey = generatePrivateKey()\r\n add = [$rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.literal(privateKey), $rdf.sym(privateKeyDoc))]\r\n await saveKey(privateKeyDoc, [], add, webId)\r\n }\r\n if (!publicKey || !validPublicKey) {\r\n del = []\r\n // delete invalid public key\r\n if (publicKey) {\r\n del = [$rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(publicKeyDoc))]\r\n debug.log(del)\r\n }\r\n // update new valid key\r\n const newPublicKey = generatePublicKey(privateKey)\r\n add = [$rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PublicKey'), $rdf.literal(newPublicKey), $rdf.sym(publicKeyDoc))]\r\n await saveKey(publicKeyDoc, del, add)\r\n }\r\n const keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1)\r\n await setAcl(keyContainer, keyContainerAclBody(webId))\r\n /* debug.log('new key pair ' + webId)\r\n debug.log('newPrivateKey-1 ' + privateKey)\r\n debug.log('newPublicKey-1 ' + publicKey) */\r\n /* debug.log('del')\r\n debug.log(del)\r\n debug.log('add')\r\n debug.log(add) */\r\n // await store.updater.updateMany(del, add)\r\n // TODO create READ ACL's\r\n // await setAcl() // depends on which key has been updated\r\n }\r\n return privateKey as string\r\n}\r\n\r\nconst keyContainerAclBody = (me: string) => {\r\n const aclBody = `\r\n@prefix : <#>.\r\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\r\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\r\n@prefix key: <./>.\r\n\r\n:ReadWrite\r\n a acl:Authorization;\r\n acl:accessTo key:;\r\n acl:agent <${me}>;\r\n acl:mode acl:Read, acl:Write.\r\n:Read\r\n a acl:Authorization;\r\n acl:accessTo key:;\r\n acl:default key:;\r\n acl:agentClass foaf:Agent;\r\n acl:mode acl:Read.\r\n`\r\n return aclBody\r\n}\r\n\r\nconst keyAclBody = (keyDoc, me) => {\r\n let keyAgent = 'acl:agentClass foaf:Agent' // publicKey\r\n if (me?.length) keyAgent = `acl:agent <${me}>` // privateKey\r\n const aclBody = `\r\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\r\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\r\n<#Read>\r\n a acl:Authorization;\r\n ${keyAgent};\r\n acl:accessTo <${keyDoc.split('/').pop()}>;\r\n acl:mode acl:Read, acl:Control. # NSS issue: missing acl link header with READ only\r\n`\r\n return aclBody\r\n}\r\n\r\nasync function setAcl (keyDoc, aclBody) {\r\n // Some servers don't present a Link http response header\r\n // if the container doesn't exist yet, so refetch the container\r\n // now that it has been created:\r\n await store.fetcher.load(keyDoc)\r\n\r\n // FIXME: check the Why value on this quad:\r\n const keyAclDoc = store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'))\r\n if (!keyAclDoc) {\r\n throw new Error('Key ACL doc not found!')\r\n }\r\n\r\n /* let keyAgent = `acl:agent <${me}>;\\n` // privateKey\r\n if (!me?.length) keyAgent = `acl:agent <${me}>;\\n` + ' acl:agentClass foaf:Agent' // publicKey NSS issue\r\n const aclBody = `\r\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\r\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\r\n<#Read>\r\n a acl:Authorization;\r\n acl:agent <${me}>;\r\n ${keyAgent};\r\n acl:accessTo <${keyDoc.split('/').pop()}>;\r\n acl:mode acl:Read, acl:Control. # NSS issue: missing acl link header with READ only\r\n` */\r\n const aclResponse = await store.fetcher.webOperation('PUT', keyAclDoc.value, {\r\n data: aclBody,\r\n contentType: 'text/turtle'\r\n })\r\n}\r\n\r\nasync function saveKey (keyDoc, del, add, me = '') {\r\n // save key\r\n await store.updater.updateMany(del, add) // or a promise store.updater.update ?\r\n await store.fetcher.load(keyDoc)\r\n\r\n try {\r\n // get keyAcldoc\r\n const keyAclDoc = store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'))\r\n if (!keyAclDoc) {\r\n throw new Error(`${keyDoc} ACL doc not found!`)\r\n }\r\n // delete READ only keyAclDoc. This is possible if the webId is an owner\r\n try {\r\n const response = await store.fetcher.webOperation('DELETE', keyAclDoc.value) // this may fail if webId is not an owner\r\n debug.log('delete ' + keyAclDoc.value + ' ' + response.status) // should test 404 and 2xx\r\n } catch (err) {\r\n if (err.response.status !== 404) { throw new Error(err) }\r\n debug.log('delete ' + keyAclDoc.value + ' ' + err.response.status) // should test 404 and 2xx\r\n }\r\n\r\n // create READ only ACL\r\n const aclBody = keyAclBody(keyDoc, me)\r\n await setAcl(keyDoc, aclBody)\r\n } catch (err) { throw new Error(err) }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAN,uBAAA,CAAAC,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAAoG,SAAAO,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAT,wBAAAa,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA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