solid-ui 2.4.27-7184a38a → 2.4.27-7e137543

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/lib/chat/keys.js DELETED
@@ -1,247 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.generatePrivateKey = generatePrivateKey;
9
- exports.generatePublicKey = generatePublicKey;
10
- exports.getPrivateKey = getPrivateKey;
11
- exports.getPublicKey = getPublicKey;
12
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
- var debug = _interopRequireWildcard(require("../debug"));
15
- var _secp256k = require("@noble/curves/secp256k1");
16
- var _utils = require("@noble/hashes/utils");
17
- var _signature = require("./signature");
18
- var _solidLogic = require("solid-logic");
19
- var $rdf = _interopRequireWildcard(require("rdflib"));
20
- var _cryptoKeyHelpers = require("../utils/cryptoKeyHelpers");
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); }
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; }
23
- function generatePrivateKey() {
24
- return (0, _utils.bytesToHex)(_secp256k.schnorr.utils.randomPrivateKey());
25
- }
26
- function generatePublicKey(privateKey) {
27
- return (0, _utils.bytesToHex)(_secp256k.schnorr.getPublicKey(privateKey));
28
- }
29
- function getPublicKey(_x) {
30
- return _getPublicKey.apply(this, arguments);
31
- }
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);
60
- }
61
- function getPrivateKey(_x2) {
62
- return _getPrivateKey.apply(this, arguments);
63
- }
64
- function _getPrivateKey() {
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) {
69
- case 0:
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;
109
- break;
110
- }
111
- del = [];
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:
129
- case "end":
130
- return _context2.stop();
131
- }
132
- }, _callee2);
133
- }));
134
- return _getPrivateKey.apply(this, arguments);
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
- }
247
- //# sourceMappingURL=keys.js.map
@@ -1 +0,0 @@
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,EA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,KAAK,GAAG,GAAG,GAAG2D,SAAA,CAAA1D,EAAA,CAAIwD,QAAQ,CAACK,MAAM,CAAC,EAAC;UAAA;YAGrE;YACM9B,OAAO,GAAGE,UAAU,CAACC,MAAM,EAAEJ,EAAE,CAAC;YAAA4B,SAAA,CAAApE,IAAA;YAAA,OAChCsC,MAAM,CAACM,MAAM,EAAEH,OAAO,CAAC;UAAA;YAAA2B,SAAA,CAAApE,IAAA;YAAA;UAAA;YAAAoE,SAAA,CAAArE,IAAA;YAAAqE,SAAA,CAAAI,EAAA,GAAAJ,SAAA;YAAA,MACT,IAAIX,KAAK,CAAAW,SAAA,CAAAI,EAAA,CAAK;UAAA;UAAA;YAAA,OAAAJ,SAAA,CAAAxD,IAAA;QAAA;MAAA,GAAAqD,QAAA;IAAA;EAAA,CACrC;EAAA,OAAAD,QAAA,CAAA5E,KAAA,OAAAC,SAAA;AAAA"}
@@ -1,27 +0,0 @@
1
- export declare const utf8Decoder: TextDecoder;
2
- export declare const utf8Encoder: TextEncoder;
3
- export declare const SEC = "https://w3id.org/security#";
4
- export declare const CERT = "http://www.w3.org/ns/auth/cert#";
5
- export type MsgTemplate = {
6
- id: string;
7
- created: string;
8
- dateDeleted: string;
9
- content: string;
10
- maker: string;
11
- sig: string;
12
- };
13
- export type UnsignedMsg = MsgTemplate & {
14
- pubkey: string;
15
- };
16
- export type Message = UnsignedMsg & {
17
- id: string;
18
- sig: string;
19
- };
20
- export declare function getBlankMsg(): MsgTemplate;
21
- export declare function finishMsg(t: MsgTemplate, privateKey: string): Message;
22
- export declare function serializeMsg(msg: UnsignedMsg): string;
23
- export declare function getMsgHash(message: UnsignedMsg): string;
24
- export declare function validateMsg<T>(message: T): message is T & UnsignedMsg;
25
- export declare function verifySignature(sig: string, message: Message, pubKey: string): boolean;
26
- export declare function signMsg(message: UnsignedMsg, key: string): string;
27
- //# sourceMappingURL=signature.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/chat/signature.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,aAA2B,CAAA;AACnD,eAAO,MAAM,WAAW,aAAoB,CAAA;AAE5C,eAAO,MAAM,GAAG,+BAA+B,CAAA;AAC/C,eAAO,MAAM,IAAI,oCAAoC,CAAA;AA2BrD,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,wBAAgB,WAAW,IAAK,WAAW,CAS1C;AAED,wBAAgB,SAAS,CAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAOtE;AAED,wBAAgB,YAAY,CAAE,GAAG,EAAE,WAAW,GAAG,MAAM,CAMtD;AAED,wBAAgB,UAAU,CAAE,OAAO,EAAE,WAAW,UAG/C;AAID,wBAAgB,WAAW,CAAC,CAAC,EAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,WAAW,CAkBtE;AAED,wBAAgB,eAAe,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAMvF;AAED,wBAAgB,OAAO,CAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIlE"}
@@ -1,110 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SEC = exports.CERT = void 0;
7
- exports.finishMsg = finishMsg;
8
- exports.getBlankMsg = getBlankMsg;
9
- exports.getMsgHash = getMsgHash;
10
- exports.serializeMsg = serializeMsg;
11
- exports.signMsg = signMsg;
12
- exports.utf8Encoder = exports.utf8Decoder = void 0;
13
- exports.validateMsg = validateMsg;
14
- exports.verifySignature = verifySignature;
15
- var _secp256k = require("@noble/curves/secp256k1");
16
- var _utils = require("@noble/hashes/utils");
17
- var _sha = require("@noble/hashes/sha256");
18
- // import {utf8Encoder} from './utils'
19
- // import { getPublicKey } from './keys'
20
-
21
- var utf8Decoder = new TextDecoder('utf-8');
22
- exports.utf8Decoder = utf8Decoder;
23
- var utf8Encoder = new TextEncoder();
24
- exports.utf8Encoder = utf8Encoder;
25
- var SEC = 'https://w3id.org/security#'; // Proof, VerificationMethod
26
- exports.SEC = SEC;
27
- var CERT = 'http://www.w3.org/ns/auth/cert#'; // PrivateKey, PublicKey
28
-
29
- /* eslint-disable no-unused-vars */
30
- /* export enum Kind {
31
- Metadata = 0,
32
- Text = 1,
33
- RecommendRelay = 2,
34
- Contacts = 3,
35
- EncryptedDirectMessage = 4,
36
- EventDeletion = 5,
37
- Reaction = 7,
38
- BadgeAward = 8,
39
- ChannelCreation = 40,
40
- ChannelMetadata = 41,
41
- ChannelMessage = 42,
42
- ChannelHideMessage = 43,
43
- ChannelMuteUser = 44,
44
- Report = 1984,
45
- ZapRequest = 9734,
46
- Zap = 9735,
47
- RelayList = 10002,
48
- ClientAuth = 22242,
49
- BadgeDefinition = 30008,
50
- ProfileBadge = 30009,
51
- Article = 30023
52
- } */
53
- exports.CERT = CERT;
54
- function getBlankMsg() {
55
- return {
56
- id: '',
57
- created: '',
58
- dateDeleted: '',
59
- content: '',
60
- maker: '',
61
- sig: ''
62
- };
63
- }
64
- function finishMsg(t, privateKey) {
65
- // to update to chat message triples
66
- var message = t;
67
- // message.pubkey = getPublicKey(privateKey)
68
- message.id = getMsgHash(message);
69
- message.sig = signMsg(message, privateKey);
70
- return message;
71
- }
72
- function serializeMsg(msg) {
73
- // to update to chat messages triples
74
- /* if (!validateMsg(msg))
75
- throw new Error("can't serialize message with wrong or missing properties") */
76
-
77
- return JSON.stringify(msg);
78
- }
79
- function getMsgHash(message) {
80
- var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
81
- return (0, _utils.bytesToHex)(msgHash);
82
- }
83
- var isRecord = function isRecord(obj) {
84
- return obj instanceof Object;
85
- };
86
- function validateMsg(message) {
87
- /* if (!isRecord(message)) return false
88
- if (typeof message.kind !== 'number') return false
89
- if (typeof message.content !== 'string') return false
90
- if (typeof message.created_at !== 'number') return false
91
- if (typeof message.pubkey !== 'string') return false
92
- if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
93
- if (!Array.isArray(message.tags)) return false
94
- for (let i = 0; i < message.tags.length; i++) {
95
- let tag = message.tags[i]
96
- if (!Array.isArray(tag)) return false
97
- for (let j = 0; j < tag.length; j++) {
98
- if (typeof tag[j] === 'object') return false
99
- }
100
- } */
101
-
102
- return true;
103
- }
104
- function verifySignature(sig, message, pubKey) {
105
- return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
106
- }
107
- function signMsg(message, key) {
108
- return (0, _utils.bytesToHex)(_secp256k.schnorr.sign(getMsgHash(message), key));
109
- }
110
- //# sourceMappingURL=signature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signature.js","names":["_secp256k","require","_utils","_sha","utf8Decoder","TextDecoder","exports","utf8Encoder","TextEncoder","SEC","CERT","getBlankMsg","id","created","dateDeleted","content","maker","sig","finishMsg","t","privateKey","message","getMsgHash","signMsg","serializeMsg","msg","JSON","stringify","msgHash","sha256","encode","bytesToHex","isRecord","obj","Object","validateMsg","verifySignature","pubKey","schnorr","verify","key","sign"],"sources":["../../src/chat/signature.ts"],"sourcesContent":["import { schnorr } from '@noble/curves/secp256k1'\r\nimport { bytesToHex } from '@noble/hashes/utils'\r\nimport { sha256 } from '@noble/hashes/sha256'\r\n\r\n// import {utf8Encoder} from './utils'\r\n// import { getPublicKey } from './keys'\r\n\r\nexport const utf8Decoder = new TextDecoder('utf-8')\r\nexport const utf8Encoder = new TextEncoder()\r\n\r\nexport const SEC = 'https://w3id.org/security#' // Proof, VerificationMethod\r\nexport const CERT = 'http://www.w3.org/ns/auth/cert#' // PrivateKey, PublicKey\r\n\r\n/* eslint-disable no-unused-vars */\r\n/* export enum Kind {\r\n Metadata = 0,\r\n Text = 1,\r\n RecommendRelay = 2,\r\n Contacts = 3,\r\n EncryptedDirectMessage = 4,\r\n EventDeletion = 5,\r\n Reaction = 7,\r\n BadgeAward = 8,\r\n ChannelCreation = 40,\r\n ChannelMetadata = 41,\r\n ChannelMessage = 42,\r\n ChannelHideMessage = 43,\r\n ChannelMuteUser = 44,\r\n Report = 1984,\r\n ZapRequest = 9734,\r\n Zap = 9735,\r\n RelayList = 10002,\r\n ClientAuth = 22242,\r\n BadgeDefinition = 30008,\r\n ProfileBadge = 30009,\r\n Article = 30023\r\n} */\r\n\r\nexport type MsgTemplate = {\r\n id: string\r\n created: string\r\n dateDeleted: string\r\n content: string\r\n maker: string\r\n sig: string\r\n}\r\n\r\nexport type UnsignedMsg = MsgTemplate & {\r\n pubkey: string\r\n}\r\n\r\nexport type Message = UnsignedMsg & {\r\n id: string\r\n sig: string\r\n}\r\n\r\nexport function getBlankMsg (): MsgTemplate {\r\n return {\r\n id: '',\r\n created: '',\r\n dateDeleted: '',\r\n content: '',\r\n maker: '',\r\n sig: ''\r\n }\r\n}\r\n\r\nexport function finishMsg (t: MsgTemplate, privateKey: string): Message {\r\n // to update to chat message triples\r\n const message = t as Message\r\n // message.pubkey = getPublicKey(privateKey)\r\n message.id = getMsgHash(message)\r\n message.sig = signMsg(message, privateKey)\r\n return message\r\n}\r\n\r\nexport function serializeMsg (msg: UnsignedMsg): string {\r\n // to update to chat messages triples\r\n /* if (!validateMsg(msg))\r\n throw new Error(\"can't serialize message with wrong or missing properties\") */\r\n\r\n return JSON.stringify(msg)\r\n}\r\n\r\nexport function getMsgHash (message: UnsignedMsg) {\r\n const msgHash = sha256(utf8Encoder.encode(serializeMsg(message)))\r\n return bytesToHex(msgHash)\r\n}\r\n\r\nconst isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object\r\n\r\nexport function validateMsg<T> (message: T): message is T & UnsignedMsg {\r\n /* if (!isRecord(message)) return false\r\n if (typeof message.kind !== 'number') return false\r\n if (typeof message.content !== 'string') return false\r\n if (typeof message.created_at !== 'number') return false\r\n if (typeof message.pubkey !== 'string') return false\r\n if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false\r\n\r\n if (!Array.isArray(message.tags)) return false\r\n for (let i = 0; i < message.tags.length; i++) {\r\n let tag = message.tags[i]\r\n if (!Array.isArray(tag)) return false\r\n for (let j = 0; j < tag.length; j++) {\r\n if (typeof tag[j] === 'object') return false\r\n }\r\n } */\r\n\r\n return true\r\n}\r\n\r\nexport function verifySignature (sig: string, message: Message, pubKey: string): boolean {\r\n return schnorr.verify(\r\n sig,\r\n getMsgHash(message),\r\n pubKey\r\n )\r\n}\r\n\r\nexport function signMsg (message: UnsignedMsg, key: string): string {\r\n return bytesToHex(\r\n schnorr.sign(getMsgHash(message), key)\r\n )\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAEA;AACA;;AAEO,IAAMG,WAAW,GAAG,IAAIC,WAAW,CAAC,OAAO,CAAC;AAAAC,OAAA,CAAAF,WAAA,GAAAA,WAAA;AAC5C,IAAMG,WAAW,GAAG,IAAIC,WAAW,EAAE;AAAAF,OAAA,CAAAC,WAAA,GAAAA,WAAA;AAErC,IAAME,GAAG,GAAG,4BAA4B,EAAC;AAAAH,OAAA,CAAAG,GAAA,GAAAA,GAAA;AACzC,IAAMC,IAAI,GAAG,iCAAiC,EAAC;;AAEtD;AACA;AACA;AACA;AACA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AAG,EACHK,UAAU,CAACD,OAAO,CAAC,EACnBgB,MAAM,CACP;AACH;AAEO,SAASd,OAAOA,CAAEF,OAAoB,EAAEmB,GAAW,EAAU;EAClE,OAAO,IAAAT,iBAAU,EACfO,iBAAO,CAACG,IAAI,CAACnB,UAAU,CAACD,OAAO,CAAC,EAAEmB,GAAG,CAAC,CACvC;AACH"}
@@ -1,5 +0,0 @@
1
- export declare const pubKeyUrl: (webId: string) => string;
2
- export declare function publicKeyExists(webId: string): Promise<string | undefined>;
3
- export declare const privKeyUrl: (webId: string) => string;
4
- export declare function privateKeyExists(webId: string): Promise<string | undefined>;
5
- //# sourceMappingURL=cryptoKeyHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cryptoKeyHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/cryptoKeyHelpers.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,SAAS,UAAW,MAAM,WAStC,CAAA;AAED,wBAAsB,eAAe,CAAE,KAAK,EAAE,MAAM,+BAInD;AAED,eAAO,MAAM,UAAU,UAAW,MAAM,WASvC,CAAA;AAED,wBAAsB,gBAAgB,CAAE,KAAK,EAAE,MAAM,+BAIpD"}
@@ -1,157 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.privKeyUrl = void 0;
9
- exports.privateKeyExists = privateKeyExists;
10
- exports.pubKeyUrl = void 0;
11
- exports.publicKeyExists = publicKeyExists;
12
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
- var debug = _interopRequireWildcard(require("../debug"));
15
- var _signature = require("../chat/signature");
16
- var _solidLogic = require("solid-logic");
17
- 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); }
18
- 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; }
19
- // find podRoot from space:storage for subdomain/suffix podServers
20
- /* export const podRoot = (webId: string) => {
21
- await store.fetcher.load(webId)
22
- const url = new URL(webId)
23
- // find storage in webId
24
- const storage = store.each(store.sym(webId), store.sym('http://www.w3.org/ns/pim/space#storage'))
25
- const pod = storage.length === 1 ? storage : storage.find(node => url.origin === new URL(node.value).origin)
26
- const podRoot = Array.isArray(pod) ? pod[0] : pod
27
- if (!podRoot?.value) throw Error('No space:storage in ' + webId)
28
- return podRoot.value
29
- } */
30
-
31
- var pubKeyUrl = function pubKeyUrl(webId) {
32
- var url = new URL(webId);
33
- // find storage in webId
34
- var storage = _solidLogic.store.each(_solidLogic.store.sym(webId), _solidLogic.store.sym('http://www.w3.org/ns/pim/space#storage'));
35
- var pod = storage.length === 1 ? storage : storage.find(function (node) {
36
- return url.origin === new URL(node.value).origin;
37
- });
38
- var podUrl = Array.isArray(pod) ? pod[0] : pod;
39
- if (!(podUrl !== null && podUrl !== void 0 && podUrl.value)) throw Error('No space:storage in ' + webId);
40
- var publicKeyUrl = (podUrl === null || podUrl === void 0 ? void 0 : podUrl.value) + 'profile/keys/publicKey.ttl';
41
- return publicKeyUrl;
42
- };
43
- exports.pubKeyUrl = pubKeyUrl;
44
- function publicKeyExists(_x) {
45
- return _publicKeyExists.apply(this, arguments);
46
- }
47
- function _publicKeyExists() {
48
- _publicKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
49
- var publicKeyUrl;
50
- return _regenerator["default"].wrap(function _callee$(_context) {
51
- while (1) switch (_context.prev = _context.next) {
52
- case 0:
53
- // find publickey
54
- publicKeyUrl = pubKeyUrl(webId);
55
- _context.next = 3;
56
- return keyExists(webId, publicKeyUrl, 'PublicKey');
57
- case 3:
58
- return _context.abrupt("return", _context.sent);
59
- case 4:
60
- case "end":
61
- return _context.stop();
62
- }
63
- }, _callee);
64
- }));
65
- return _publicKeyExists.apply(this, arguments);
66
- }
67
- var privKeyUrl = function privKeyUrl(webId) {
68
- var url = new URL(webId);
69
- // find storage in webId
70
- var storage = _solidLogic.store.each(_solidLogic.store.sym(webId), _solidLogic.store.sym('http://www.w3.org/ns/pim/space#storage'));
71
- var pod = storage.length === 1 ? storage : storage.find(function (node) {
72
- return url.origin === new URL(node.value).origin;
73
- });
74
- var podUrl = Array.isArray(pod) ? pod[0] : pod;
75
- if (!(podUrl !== null && podUrl !== void 0 && podUrl.value)) throw Error('Expected space:storage in ' + webId);
76
- var privateKeyUrl = (podUrl === null || podUrl === void 0 ? void 0 : podUrl.value) + 'profile/keys/privateKey.ttl';
77
- return privateKeyUrl;
78
- };
79
- exports.privKeyUrl = privKeyUrl;
80
- function privateKeyExists(_x2) {
81
- return _privateKeyExists.apply(this, arguments);
82
- }
83
- function _privateKeyExists() {
84
- _privateKeyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
85
- var privateKeyUrl;
86
- return _regenerator["default"].wrap(function _callee2$(_context2) {
87
- while (1) switch (_context2.prev = _context2.next) {
88
- case 0:
89
- // find privateKey
90
- privateKeyUrl = privKeyUrl(webId);
91
- _context2.next = 3;
92
- return keyExists(webId, privateKeyUrl, 'PrivateKey');
93
- case 3:
94
- return _context2.abrupt("return", _context2.sent);
95
- case 4:
96
- case "end":
97
- return _context2.stop();
98
- }
99
- }, _callee2);
100
- }));
101
- return _privateKeyExists.apply(this, arguments);
102
- }
103
- function keyExists(_x3, _x4, _x5) {
104
- return _keyExists.apply(this, arguments);
105
- }
106
- function _keyExists() {
107
- _keyExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
108
- var key, _err$response, data, contentType, response;
109
- return _regenerator["default"].wrap(function _callee3$(_context3) {
110
- while (1) switch (_context3.prev = _context3.next) {
111
- case 0:
112
- _context3.prev = 0;
113
- _context3.next = 3;
114
- return _solidLogic.store.fetcher.load(keyUrl);
115
- case 3:
116
- key = _solidLogic.store.any(_solidLogic.store.sym(webId), _solidLogic.store.sym(_signature.CERT + keyType));
117
- return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
118
- case 7:
119
- _context3.prev = 7;
120
- _context3.t0 = _context3["catch"](0);
121
- if (!((_context3.t0 === null || _context3.t0 === void 0 ? void 0 : (_err$response = _context3.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status) === 404)) {
122
- _context3.next = 24;
123
- break;
124
- }
125
- _context3.prev = 10;
126
- // create privateKey resource
127
- data = '';
128
- contentType = 'text/turtle';
129
- _context3.next = 15;
130
- return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
131
- data: data,
132
- contentType: contentType
133
- });
134
- case 15:
135
- response = _context3.sent;
136
- _context3.next = 22;
137
- break;
138
- case 18:
139
- _context3.prev = 18;
140
- _context3.t1 = _context3["catch"](10);
141
- debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t1);
142
- throw _context3.t1;
143
- case 22:
144
- delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
145
- return _context3.abrupt("return", undefined);
146
- case 24:
147
- debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t0);
148
- throw _context3.t0;
149
- case 26:
150
- case "end":
151
- return _context3.stop();
152
- }
153
- }, _callee3, null, [[0, 7], [10, 18]]);
154
- }));
155
- return _keyExists.apply(this, arguments);
156
- }
157
- //# sourceMappingURL=cryptoKeyHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cryptoKeyHelpers.js","names":["debug","_interopRequireWildcard","require","_signature","_solidLogic","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","pubKeyUrl","webId","url","URL","storage","store","each","sym","pod","length","find","node","origin","value","podUrl","Array","isArray","Error","publicKeyUrl","exports","publicKeyExists","_x","_publicKeyExists","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_callee$","_context","prev","next","keyExists","abrupt","sent","stop","privKeyUrl","privateKeyUrl","privateKeyExists","_x2","_privateKeyExists","_callee2","_callee2$","_context2","_x3","_x4","_x5","_keyExists","_callee3","keyUrl","keyType","_err$response","data","contentType","response","_callee3$","_context3","fetcher","load","any","CERT","t0","status","webOperation","t1","log","requested","undefined"],"sources":["../../src/utils/cryptoKeyHelpers.ts"],"sourcesContent":["import * as debug from '../debug'\nimport { CERT } from '../chat/signature'\nimport { store } from 'solid-logic'\n\n// find podRoot from space:storage for subdomain/suffix podServers\n/* export const podRoot = (webId: string) => {\n await store.fetcher.load(webId)\n const url = new URL(webId)\n // find storage in webId\n const storage = store.each(store.sym(webId), store.sym('http://www.w3.org/ns/pim/space#storage'))\n const pod = storage.length === 1 ? storage : storage.find(node => url.origin === new URL(node.value).origin)\n const podRoot = Array.isArray(pod) ? pod[0] : pod\n if (!podRoot?.value) throw Error('No space:storage in ' + webId)\n return podRoot.value\n} */\n\nexport const pubKeyUrl = (webId: string) => {\n const url = new URL(webId)\n // find storage in webId\n const storage = store.each(store.sym(webId), store.sym('http://www.w3.org/ns/pim/space#storage'))\n const pod = storage.length === 1 ? storage : storage.find(node => url.origin === new URL(node.value).origin)\n const podUrl = Array.isArray(pod) ? pod[0] : pod\n if (!podUrl?.value) throw Error('No space:storage in ' + webId)\n const publicKeyUrl = podUrl?.value + 'profile/keys/publicKey.ttl'\n return publicKeyUrl\n}\n\nexport async function publicKeyExists (webId: string) {\n // find publickey\n const publicKeyUrl = pubKeyUrl(webId)\n return await keyExists(webId, publicKeyUrl, 'PublicKey')\n}\n\nexport const privKeyUrl = (webId: string) => {\n const url = new URL(webId)\n // find storage in webId\n const storage = store.each(store.sym(webId), store.sym('http://www.w3.org/ns/pim/space#storage'))\n const pod = storage.length === 1 ? storage : storage.find(node => url.origin === new URL(node.value).origin)\n const podUrl = Array.isArray(pod) ? pod[0] : pod\n if (!podUrl?.value) throw Error('Expected space:storage in ' + webId)\n const privateKeyUrl = podUrl?.value + 'profile/keys/privateKey.ttl'\n return privateKeyUrl\n}\n\nexport async function privateKeyExists (webId: string) {\n // find privateKey\n const privateKeyUrl = privKeyUrl(webId)\n return await keyExists(webId, privateKeyUrl, 'PrivateKey')\n}\n\ntype KeyType = 'PublicKey' | 'PrivateKey'\n\nasync function keyExists (webId, keyUrl, keyType: KeyType) {\n try {\n await store.fetcher.load(keyUrl)\n const key = store.any(store.sym(webId), store.sym(CERT + keyType))\n return key?.value // as NamedNode\n } catch (err) {\n if (err?.response?.status === 404) { // If PATCH on some server do not all create intermediate containers\n try {\n // create privateKey resource\n const data = ''\n const contentType = 'text/turtle'\n const response = await store.fetcher.webOperation('PUT', keyUrl, {\n data,\n contentType\n })\n } catch (err) {\n debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + err)\n throw err\n }\n delete store.fetcher.requested[keyUrl] // delete cached 404 error\n return undefined\n }\n debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + err)\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