solid-ui 2.4.27-6c8461c9 → 2.4.27-70090f20
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/README.md +6 -1
- package/dist/solid-ui.js +1707 -1196
- 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 +62 -36
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/keys.d.ts +10 -2
- package/lib/chat/keys.d.ts.map +1 -1
- package/lib/chat/keys.js +182 -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 +0 -2
- package/lib/chat/signature.d.ts.map +1 -1
- package/lib/chat/signature.js +25 -22
- package/lib/chat/signature.js.map +1 -1
- package/lib/utils/keyHelpers/accessData.d.ts +10 -0
- package/lib/utils/keyHelpers/accessData.d.ts.map +1 -0
- package/lib/utils/keyHelpers/accessData.js +226 -0
- package/lib/utils/keyHelpers/accessData.js.map +1 -0
- package/lib/utils/keyHelpers/acl.d.ts +20 -0
- package/lib/utils/keyHelpers/acl.d.ts.map +1 -0
- package/lib/utils/keyHelpers/acl.js +101 -0
- package/lib/utils/keyHelpers/acl.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessData.js","names":["debug","_interopRequireWildcard","require","_signature","_solidLogic","ns","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","getPodRoot","_ref","_asyncToGenerator2","_regenerator","mark","_callee","webId","_podRoot","webIdURL","storages","podRoot","path","_res$headers$get","res","wrap","_callee$","_context","prev","next","URL","uri","store","fetcher","load","each","space","doc","length","pathname","substring","lastIndexOf","sym","origin","webOperation","sent","headers","includes","value","abrupt","warn","concat","find","storage","stop","_x","apply","arguments","exports","pubKeyUrl","_ref2","_callee2","_callee2$","_context2","t0","t1","Error","_x2","getExistingPublicKey","_x3","_x4","_getExistingPublicKey","_callee4","publicKeyUrl","_callee4$","_context4","getKeyIfExists","privKeyUrl","_ref3","_callee3","_callee3$","_context3","_x5","getExistingPrivateKey","_x6","_x7","_getExistingPrivateKey","_callee5","privateKeyUrl","_callee5$","_context5","_x8","_x9","_x10","_getKeyIfExists","_callee6","keyUrl","keyType","_err$response","data","contentType","response","_callee6$","_context6","any","CERT","status","log","requested","undefined"],"sources":["../../../src/utils/keyHelpers/accessData.ts"],"sourcesContent":["import * as debug from '../../debug'\nimport { CERT } from '../../chat/signature'\nimport { store } from 'solid-logic'\nimport * as ns from '../../ns'\nimport { NamedNode } from 'rdflib'\n\nexport const getPodRoot = async (webId: NamedNode) => {\n const webIdURL = new URL(webId.uri)\n // find storages in webId document\n await store.fetcher.load(webId.uri)\n const storages = store.each(webId, ns.space('storage'), null, webId.doc())\n var podRoot: NamedNode | undefined\n if (!storages?.length) {\n // find storage recursively in webId URL\n let path = webIdURL.pathname\n while (path.length) {\n path = path.substring(0, path.lastIndexOf('/'))\n podRoot = store.sym(webIdURL.origin + path + '/')\n const res = await store.fetcher.webOperation('HEAD', podRoot.uri)\n if (res.headers.get('link')?.includes(ns.space('Storage').value)) break\n if (!path) debug.warn(`Current user storage not found for\\n${webId}`)\n }\n } else {\n // give preference to storage in webId root\n podRoot = storages.find((storage) => webIdURL.origin === new URL(storage.value).origin) as NamedNode\n if (!podRoot) podRoot = storages[0] as NamedNode\n }\n return podRoot?.value\n}\n\nexport const pubKeyUrl = async (webId: NamedNode) => {\n try {\n return await getPodRoot(webId) + 'profile/keys/publicKey.ttl'\n } catch (err) { throw new Error(err) }\n}\n\nexport async function getExistingPublicKey (webId: NamedNode, publicKeyUrl: string) {\n // find publickey\n return await getKeyIfExists(webId, publicKeyUrl, 'PublicKey')\n}\n\nexport const privKeyUrl = async (webId: NamedNode) => {\n try {\n return await getPodRoot(webId) + 'profile/keys/privateKey.ttl'\n } catch (err) { throw new Error(err) }\n}\n\nexport async function getExistingPrivateKey (webId: NamedNode, privateKeyUrl: string) {\n // find privateKey\n return await getKeyIfExists(webId, privateKeyUrl, 'PrivateKey')\n}\n\ntype KeyType = 'PublicKey' | 'PrivateKey'\n\nexport async function getKeyIfExists (webId: NamedNode, keyUrl: string, keyType: KeyType) {\n try {\n await store.fetcher.load(keyUrl)\n const key = store.any(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 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)\n throw err\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,EAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAA8B,SAAAI,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,SAAAN,wBAA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KAAK,EAAEoD,MAAM,EAAE;YAC/DG,IAAI,EAAJA,IAAI;YACJC,WAAW,EAAXA;UACF,CAAC,CAAC;QAAA;UAHIC,QAAQ,GAAAE,SAAA,CAAA1D,IAAA;UAAA0D,SAAA,CAAA1E,IAAA;UAAA;QAAA;UAAA0E,SAAA,CAAA3E,IAAA;UAAA2E,SAAA,CAAAtC,EAAA,GAAAsC,SAAA;UAKdxH,KAAK,CAAC4H,GAAG,CAAC,gCAAgC,GAAGX,MAAM,GAAG,IAAI,GAAAO,SAAA,CAAAtC,EAAM,CAAC;UAAA,MAAAsC,SAAA,CAAAtC,EAAA;QAAA;UAGnE,OAAOjC,iBAAK,CAACC,OAAO,CAAC2E,SAAS,CAACZ,MAAM,CAAC,EAAC;UAAA,OAAAO,SAAA,CAAAtD,MAAA,WAChC4D,SAAS;QAAA;UAElB9H,KAAK,CAAC4H,GAAG,CAAC,gCAAgC,GAAGX,MAAM,GAAG,IAAI,GAAAO,SAAA,CAAAvC,EAAM,CAAC;UAAA,MAAAuC,SAAA,CAAAvC,EAAA;QAAA;QAAA;UAAA,OAAAuC,SAAA,CAAAjD,IAAA;MAAA;IAAA,GAAAyC,QAAA;EAAA,CAGpE;EAAA,OAAAD,eAAA,CAAAtC,KAAA,OAAAC,SAAA;AAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* set ACL
|
|
3
|
+
* @param keyDoc
|
|
4
|
+
* @param aclBody
|
|
5
|
+
*/
|
|
6
|
+
export declare function setAcl(keyDoc: string, aclBody: string): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* key container ACL
|
|
9
|
+
* @param me
|
|
10
|
+
* @returns aclBody
|
|
11
|
+
*/
|
|
12
|
+
export declare const keyContainerAclBody: (me: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Read only ACL
|
|
15
|
+
* @param keyDoc
|
|
16
|
+
* @param me
|
|
17
|
+
* @returns aclBody
|
|
18
|
+
*/
|
|
19
|
+
export declare const keyAclBody: (keyDoc: any, me: any) => string;
|
|
20
|
+
//# sourceMappingURL=acl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl.d.ts","sourceRoot":"","sources":["../../../src/utils/keyHelpers/acl.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,MAAM,CAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBA0B5D;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,OAAQ,MAAM,WAe7C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,kCAatB,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
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.keyContainerAclBody = exports.keyAclBody = void 0;
|
|
9
|
+
exports.setAcl = setAcl;
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
|
+
var debug = _interopRequireWildcard(require("../../debug"));
|
|
13
|
+
var _solidLogic = require("solid-logic");
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
/**
|
|
17
|
+
* set ACL
|
|
18
|
+
* @param keyDoc
|
|
19
|
+
* @param aclBody
|
|
20
|
+
*/
|
|
21
|
+
function setAcl(_x, _x2) {
|
|
22
|
+
return _setAcl.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* key container ACL
|
|
26
|
+
* @param me
|
|
27
|
+
* @returns aclBody
|
|
28
|
+
*/
|
|
29
|
+
function _setAcl() {
|
|
30
|
+
_setAcl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(keyDoc, aclBody) {
|
|
31
|
+
var keyAclDoc, response, aclResponse;
|
|
32
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
33
|
+
while (1) switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
_context.next = 2;
|
|
36
|
+
return _solidLogic.store.fetcher.load(keyDoc);
|
|
37
|
+
case 2:
|
|
38
|
+
// FIXME: check the Why value on this quad:
|
|
39
|
+
debug.log(_solidLogic.store.statementsMatching(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl')));
|
|
40
|
+
keyAclDoc = _solidLogic.store.any(_solidLogic.store.sym(keyDoc), _solidLogic.store.sym('http://www.iana.org/assignments/link-relations/acl'));
|
|
41
|
+
if (keyAclDoc) {
|
|
42
|
+
_context.next = 6;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
throw new Error('Key ACL doc not found!');
|
|
46
|
+
case 6:
|
|
47
|
+
_context.prev = 6;
|
|
48
|
+
_context.next = 9;
|
|
49
|
+
return _solidLogic.store.fetcher.webOperation('DELETE', keyAclDoc.value);
|
|
50
|
+
case 9:
|
|
51
|
+
response = _context.sent;
|
|
52
|
+
// this may fail if webId is not an owner
|
|
53
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + response.status); // should test 404 and 2xx
|
|
54
|
+
_context.next = 18;
|
|
55
|
+
break;
|
|
56
|
+
case 13:
|
|
57
|
+
_context.prev = 13;
|
|
58
|
+
_context.t0 = _context["catch"](6);
|
|
59
|
+
if (!(_context.t0.response.status !== 404)) {
|
|
60
|
+
_context.next = 17;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(_context.t0);
|
|
64
|
+
case 17:
|
|
65
|
+
debug.log('delete ' + keyAclDoc.value + ' ' + _context.t0.response.status); // should test 404 and 2xx
|
|
66
|
+
case 18:
|
|
67
|
+
_context.next = 20;
|
|
68
|
+
return _solidLogic.store.fetcher.webOperation('PUT', keyAclDoc.value, {
|
|
69
|
+
data: aclBody,
|
|
70
|
+
contentType: 'text/turtle'
|
|
71
|
+
});
|
|
72
|
+
case 20:
|
|
73
|
+
aclResponse = _context.sent;
|
|
74
|
+
case 21:
|
|
75
|
+
case "end":
|
|
76
|
+
return _context.stop();
|
|
77
|
+
}
|
|
78
|
+
}, _callee, null, [[6, 13]]);
|
|
79
|
+
}));
|
|
80
|
+
return _setAcl.apply(this, arguments);
|
|
81
|
+
}
|
|
82
|
+
var keyContainerAclBody = function keyContainerAclBody(me) {
|
|
83
|
+
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:default key:;\n acl:agent <".concat(me, ">;\n acl:mode acl:Read, acl:Write.\n");
|
|
84
|
+
return aclBody;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Read only ACL
|
|
89
|
+
* @param keyDoc
|
|
90
|
+
* @param me
|
|
91
|
+
* @returns aclBody
|
|
92
|
+
*/
|
|
93
|
+
exports.keyContainerAclBody = keyContainerAclBody;
|
|
94
|
+
var keyAclBody = function keyAclBody(keyDoc, me) {
|
|
95
|
+
var keyAgent = 'acl:agentClass foaf:Agent'; // publicKey
|
|
96
|
+
if (me !== null && me !== void 0 && me.length) keyAgent = "acl:agent <".concat(me, ">"); // privateKey
|
|
97
|
+
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.\n");
|
|
98
|
+
return aclBody;
|
|
99
|
+
};
|
|
100
|
+
exports.keyAclBody = keyAclBody;
|
|
101
|
+
//# sourceMappingURL=acl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl.js","names":["debug","_interopRequireWildcard","require","_solidLogic","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","setAcl","_x","_x2","_setAcl","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","keyDoc","aclBody","keyAclDoc","response","aclResponse","wrap","_callee$","_context","prev","next","store","fetcher","load","log","statementsMatching","sym","any","Error","webOperation","value","sent","status","t0","data","contentType","stop","keyContainerAclBody","me","concat","exports","keyAclBody","keyAgent","length","split","pop"],"sources":["../../../src/utils/keyHelpers/acl.ts"],"sourcesContent":["import * as debug from '../../debug'\nimport { store } from 'solid-logic'\n\n/**\n * set ACL\n * @param keyDoc\n * @param aclBody\n */\nexport async function setAcl (keyDoc: string, aclBody: string) {\n // Some servers don't present a Link http response header\n // if the container doesn't exist yet, refetch the resource\n\n await store.fetcher.load(keyDoc)\n\n // FIXME: check the Why value on this quad:\n debug.log(store.statementsMatching(store.sym(keyDoc), store.sym('http://www.iana.org/assignments/link-relations/acl')))\n const keyAclDoc = store.any(store.sym(keyDoc), store.sym('http://www.iana.org/assignments/link-relations/acl'))\n if (!keyAclDoc) {\n throw new Error('Key ACL doc not found!')\n }\n\n // delete READ only keyAclDoc. This is possible if the webId is an owner\n try {\n const response = await store.fetcher.webOperation('DELETE', keyAclDoc.value) // this may fail if webId is not an owner\n debug.log('delete ' + keyAclDoc.value + ' ' + response.status) // should test 404 and 2xx\n } catch (err) {\n if (err.response.status !== 404) { throw new Error(err) }\n debug.log('delete ' + keyAclDoc.value + ' ' + err.response.status) // should test 404 and 2xx\n }\n\n const aclResponse = await store.fetcher.webOperation('PUT', keyAclDoc.value, {\n data: aclBody,\n contentType: 'text/turtle'\n })\n}\n\n/**\n * key container ACL\n * @param me\n * @returns aclBody\n */\nexport const keyContainerAclBody = (me: string) => {\n const 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:default key:;\n acl:agent <${me}>;\n acl:mode acl:Read, acl:Write.\n`\n return aclBody\n}\n\n/**\n * Read only ACL\n * @param keyDoc\n * @param me\n * @returns aclBody\n */\nexport const keyAclBody = (keyDoc, me) => {\n let keyAgent = 'acl:agentClass foaf:Agent' // publicKey\n if (me?.length) keyAgent = `acl:agent <${me}>` // privateKey\n const 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 ${keyAgent};\n acl:accessTo <${keyDoc.split('/').pop()}>;\n acl:mode acl:Read.\n`\n return aclBody\n}\n"],"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AAC;EAC/C,IAAM1B,OAAO,4IAAA2B,MAAA,CAKTG,QAAQ,2BAAAH,MAAA,CACM5B,MAAM,CAACiC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,EAAE,iCAE1C;EACC,OAAOjC,OAAO;AAChB,CAAC;AAAA4B,OAAA,CAAAC,UAAA,GAAAA,UAAA"}
|
package/lib/versionInfo.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.versionInfo = void 0;
|
|
7
7
|
var versionInfo = {
|
|
8
|
-
buildTime: '2023-
|
|
9
|
-
commit: '
|
|
8
|
+
buildTime: '2023-05-17T09:06:38Z',
|
|
9
|
+
commit: '70090f2023b45d5656d749a1af527ae2dccf0d00',
|
|
10
10
|
npmInfo: {
|
|
11
11
|
'solid-ui': '2.4.27',
|
|
12
12
|
npm: '8.19.4',
|
package/lib/versionInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versionInfo.js","names":["versionInfo","buildTime","commit","npmInfo","npm","node","v8","uv","zlib","brotli","ares","modules","nghttp2","napi","llhttp","openssl","cldr","icu","tz","unicode","ngtcp2","nghttp3","exports"],"sources":["../src/versionInfo.ts"],"sourcesContent":["export const versionInfo = {\n buildTime: '2023-
|
|
1
|
+
{"version":3,"file":"versionInfo.js","names":["versionInfo","buildTime","commit","npmInfo","npm","node","v8","uv","zlib","brotli","ares","modules","nghttp2","napi","llhttp","openssl","cldr","icu","tz","unicode","ngtcp2","nghttp3","exports"],"sources":["../src/versionInfo.ts"],"sourcesContent":["export const versionInfo = {\n buildTime: '2023-05-17T09:06:38Z',\n commit: '70090f2023b45d5656d749a1af527ae2dccf0d00',\n npmInfo:\n{\n 'solid-ui': '2.4.27',\n npm: '8.19.4',\n node: '16.20.0',\n v8: '9.4.146.26-node.26',\n uv: '1.43.0',\n zlib: '1.2.11',\n brotli: '1.0.9',\n ares: '1.19.0',\n modules: '93',\n nghttp2: '1.47.0',\n napi: '8',\n llhttp: '6.0.10',\n openssl: '1.1.1t+quic',\n cldr: '41.0',\n icu: '71.1',\n tz: '2022f',\n unicode: '14.0',\n ngtcp2: '0.8.1',\n nghttp3: '0.7.0'\n}\n}\n"],"mappings":";;;;;;AAAO,IAAMA,WAAW,GAAG;EACzBC,SAAS,EAAE,sBAAsB;EACjCC,MAAM,EAAE,0CAA0C;EAClDC,OAAO,EACT;IACE,UAAU,EAAE,QAAQ;IACpBC,GAAG,EAAE,QAAQ;IACbC,IAAI,EAAE,SAAS;IACfC,EAAE,EAAE,oBAAoB;IACxBC,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE,OAAO;IACfC,IAAI,EAAE,QAAQ;IACdC,OAAO,EAAE,IAAI;IACbC,OAAO,EAAE,QAAQ;IACjBC,IAAI,EAAE,GAAG;IACTC,MAAM,EAAE,QAAQ;IAChBC,OAAO,EAAE,aAAa;IACtBC,IAAI,EAAE,MAAM;IACZC,GAAG,EAAE,MAAM;IACXC,EAAE,EAAE,OAAO;IACXC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,OAAO;IACfC,OAAO,EAAE;EACX;AACA,CAAC;AAAAC,OAAA,CAAAtB,WAAA,GAAAA,WAAA"}
|
package/package.json
CHANGED
package/lib/chat/crypto.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=crypto.d.ts.map
|
package/lib/chat/crypto.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/chat/crypto.ts"],"names":[],"mappings":""}
|
package/lib/chat/crypto.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
/* import { literal, quad, Statement } from 'rdflib';
|
|
2
|
-
// import { PODCHAT, removeHashFromUrl } from './Constants';
|
|
3
|
-
import { authn } from 'solid-logic'
|
|
4
|
-
import * as UI from 'solid-ui'
|
|
5
|
-
import * as $rdf from 'rdflib'
|
|
6
|
-
|
|
7
|
-
const ns = UI.ns
|
|
8
|
-
|
|
9
|
-
const removeHashFromUrl = (url: string) => {
|
|
10
|
-
const newUrl = new URL(url)
|
|
11
|
-
newUrl.hash = ''
|
|
12
|
-
return newUrl.href
|
|
13
|
-
}
|
|
14
|
-
const PODCHAT_NS = 'https://www.pod-chat.com/';
|
|
15
|
-
const PODCHAT = {
|
|
16
|
-
LongChatMessage: PODCHAT_NS + 'LongChatMessage',
|
|
17
|
-
LongChatMessageReply: PODCHAT_NS + 'LongChatMessageReply',
|
|
18
|
-
RSAPublicKey: PODCHAT_NS + 'RSAPublicKey',
|
|
19
|
-
RSAPrivateKey: PODCHAT_NS + 'RSAPrivateKey',
|
|
20
|
-
signature: PODCHAT_NS + 'signature'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// import rdfStore, { extractObjectLastValue } from './RdfStore';
|
|
24
|
-
|
|
25
|
-
export type RdfStore = {
|
|
26
|
-
cache: Store,
|
|
27
|
-
fetcher: Fetcher,
|
|
28
|
-
updateManager: UpdateManager
|
|
29
|
-
}
|
|
30
|
-
function extractObject({ cache }: RdfStore, webid: string, resourceUrl: string, predicate: PredicateType): Array<Node> {
|
|
31
|
-
return cache.each(cache.sym(webid), predicate, undefined, cache.sym(resourceUrl));
|
|
32
|
-
}
|
|
33
|
-
function extractObjectLastValue(rdfStore: RdfStore, webid: string, resourceUrl: string, predicate: PredicateType): string | undefined {
|
|
34
|
-
return extractObject(rdfStore, webid, resourceUrl, predicate).map(q => q.value).pop();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const prepareRsaKeyPair = async (profileId: string, rsaPrivateKeyResourceUrl: string): Promise<void> => {
|
|
38
|
-
|
|
39
|
-
const privKey = await getPrivateKey(rsaPrivateKeyResourceUrl);
|
|
40
|
-
const pubKey = await getPublicKey(profileId);
|
|
41
|
-
|
|
42
|
-
if (!privKey || !pubKey) {
|
|
43
|
-
await createKeyPair(profileId, rsaPrivateKeyResourceUrl);
|
|
44
|
-
const privKeyNew = await getPrivateKey(rsaPrivateKeyResourceUrl);
|
|
45
|
-
const pubKeyNew = await getPublicKey(profileId);
|
|
46
|
-
if (!privKeyNew || !pubKeyNew) {
|
|
47
|
-
throw new Error('Unable to create RSA keypair.');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const signMessage = async (rsaPrivateKeyResourceUrl: string, messageContent: string): Promise<string | undefined> => {
|
|
53
|
-
const privateKey = await getPrivateKey(rsaPrivateKeyResourceUrl);
|
|
54
|
-
if (privateKey) {
|
|
55
|
-
const messageContentEnc = new TextEncoder().encode(messageContent);
|
|
56
|
-
const signature = await window.crypto.subtle.sign(
|
|
57
|
-
{
|
|
58
|
-
name: "RSA-PSS",
|
|
59
|
-
saltLength: 32,
|
|
60
|
-
},
|
|
61
|
-
privateKey,
|
|
62
|
-
messageContentEnc
|
|
63
|
-
);
|
|
64
|
-
const exportedAsString = ab2str(signature);
|
|
65
|
-
const exportedAsBase64 = window.btoa(exportedAsString);
|
|
66
|
-
return exportedAsBase64;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const verifyMessage = async (profileId: string, messageId: string, messageContent: string, signatureEncoded: string): Promise<{ messageId: string, trusted: boolean }> => {
|
|
73
|
-
let encoded = new TextEncoder().encode(messageContent);
|
|
74
|
-
const publicKey = await getPublicKey(profileId);
|
|
75
|
-
// base64 decode the string to get the binary data
|
|
76
|
-
const binaryDerString = window.atob(signatureEncoded);
|
|
77
|
-
// convert from a binary string to an ArrayBuffer
|
|
78
|
-
const signature = str2ab(binaryDerString);
|
|
79
|
-
|
|
80
|
-
if (publicKey) {
|
|
81
|
-
const trusted = await window.crypto.subtle.verify(
|
|
82
|
-
{
|
|
83
|
-
name: "RSA-PSS",
|
|
84
|
-
saltLength: 32,
|
|
85
|
-
},
|
|
86
|
-
publicKey,
|
|
87
|
-
signature,
|
|
88
|
-
encoded
|
|
89
|
-
);
|
|
90
|
-
return { messageId, trusted };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return { messageId, trusted: false };
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const getPublicKey = async (profileId: string): Promise<CryptoKey | undefined> => {
|
|
97
|
-
const profileResourceUrl = removeHashFromUrl(profileId);
|
|
98
|
-
await rdfStore.fetcher.load(profileResourceUrl);
|
|
99
|
-
const pubKeyEncoded = extractObjectLastValue(rdfStore, PODCHAT.RSAPublicKey, profileResourceUrl, rdfStore.cache.sym(SIOC.content_encoded));
|
|
100
|
-
if (pubKeyEncoded) {
|
|
101
|
-
return importPublicKey(pubKeyEncoded);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const getPrivateKey = async (rsaPrivateKeyResourceUrl: string): Promise<CryptoKey | undefined> => {
|
|
108
|
-
await rdfStore.fetcher.load(rsaPrivateKeyResourceUrl);
|
|
109
|
-
const privKeyEncoded = extractObjectLastValue(rdfStore, PODCHAT.RSAPrivateKey, rsaPrivateKeyResourceUrl, rdfStore.cache.sym(SIOC.content_encoded));
|
|
110
|
-
if (privKeyEncoded) {
|
|
111
|
-
return importPrivateKey(privKeyEncoded);
|
|
112
|
-
}
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/*
|
|
117
|
-
Import a PEM encoded RSA private key, to use for RSA-PSS signing.
|
|
118
|
-
Takes a string containing the PEM encoded key, and returns a Promise
|
|
119
|
-
that will resolve to a CryptoKey representing the private key.
|
|
120
|
-
*/
|
|
121
|
-
/* function importPrivateKey(pem: string) {
|
|
122
|
-
// base64 decode the string to get the binary data
|
|
123
|
-
const binaryDerString = window.atob(pem);
|
|
124
|
-
// convert from a binary string to an ArrayBuffer
|
|
125
|
-
const binaryDer = str2ab(binaryDerString);
|
|
126
|
-
|
|
127
|
-
return window.crypto.subtle.importKey(
|
|
128
|
-
"pkcs8",
|
|
129
|
-
binaryDer,
|
|
130
|
-
{
|
|
131
|
-
name: "RSA-PSS",
|
|
132
|
-
// Consider using a 4096-bit key for systems that require long-term security
|
|
133
|
-
//modulusLength: 4096,
|
|
134
|
-
//publicExponent: new Uint8Array([1, 0, 1]),
|
|
135
|
-
hash: "SHA-256",
|
|
136
|
-
},
|
|
137
|
-
true,
|
|
138
|
-
["sign"]
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/*
|
|
143
|
-
Import a PEM encoded RSA public key, to use for RSA-OAEP encryption.
|
|
144
|
-
Takes a string containing the PEM encoded key, and returns a Promise
|
|
145
|
-
that will resolve to a CryptoKey representing the public key.
|
|
146
|
-
*/
|
|
147
|
-
/* function importPublicKey(pem: string) {
|
|
148
|
-
// base64 decode the string to get the binary data
|
|
149
|
-
const binaryDerString = window.atob(pem);
|
|
150
|
-
// convert from a binary string to an ArrayBuffer
|
|
151
|
-
const binaryDer = str2ab(binaryDerString);
|
|
152
|
-
|
|
153
|
-
return window.crypto.subtle.importKey(
|
|
154
|
-
"spki",
|
|
155
|
-
binaryDer,
|
|
156
|
-
{
|
|
157
|
-
name: "RSA-PSS",
|
|
158
|
-
hash: "SHA-256"
|
|
159
|
-
},
|
|
160
|
-
true,
|
|
161
|
-
["verify"]
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* const createKeyPair = async (profileId: string, rsaPrivateKeyResourceUrl: string) => {
|
|
166
|
-
const key = await window.crypto.subtle
|
|
167
|
-
.generateKey(
|
|
168
|
-
{
|
|
169
|
-
name: "RSA-PSS",
|
|
170
|
-
// Consider using a 4096-bit key for systems that require long-term security
|
|
171
|
-
modulusLength: 4096,
|
|
172
|
-
publicExponent: new Uint8Array([1, 0, 1]),
|
|
173
|
-
hash: "SHA-256",
|
|
174
|
-
},
|
|
175
|
-
true,
|
|
176
|
-
["sign", "verify"]
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
await privKeyPkcs8Pem(key.privateKey, profileId, rsaPrivateKeyResourceUrl);
|
|
180
|
-
await pubKeySpkiPem(key.publicKey, profileId);
|
|
181
|
-
} */
|
|
182
|
-
|
|
183
|
-
/* async function privKeyPkcs8Pem(privKey: CryptoKey, profileId: string, rsaPrivateKeyResourceUrl: string) {
|
|
184
|
-
const exported = await window.crypto.subtle.exportKey("pkcs8", privKey);
|
|
185
|
-
const exportedAsString = ab2str(exported);
|
|
186
|
-
const exportedAsBase64 = window.btoa(exportedAsString);
|
|
187
|
-
const del: Statement[] = [];
|
|
188
|
-
const ins: Statement[] = [];
|
|
189
|
-
del.push(...rdfStore.cache.statementsMatching(
|
|
190
|
-
rdfStore.cache.sym(PODCHAT.RSAPrivateKey),
|
|
191
|
-
rdfStore.cache.sym(SIOC.content_encoded),
|
|
192
|
-
undefined,
|
|
193
|
-
rdfStore.cache.sym(rsaPrivateKeyResourceUrl)
|
|
194
|
-
));
|
|
195
|
-
ins.push(quad(
|
|
196
|
-
rdfStore.cache.sym(PODCHAT.RSAPrivateKey),
|
|
197
|
-
rdfStore.cache.sym(SIOC.content_encoded),
|
|
198
|
-
literal(exportedAsBase64), // alain
|
|
199
|
-
rdfStore.cache.sym(rsaPrivateKeyResourceUrl)
|
|
200
|
-
));
|
|
201
|
-
await rdfStore.updateManager.update(del, ins);
|
|
202
|
-
await aclForResource(rsaPrivateKeyResourceUrl, profileId);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
async function aclForResource(resourceUrl: string, ownerId: string) {
|
|
206
|
-
const ins: Statement[] = [];
|
|
207
|
-
const aclResourceUrl = resourceUrl + '.acl';
|
|
208
|
-
const graph = rdfStore.cache.sym(aclResourceUrl);
|
|
209
|
-
const aclId = rdfStore.cache.sym(aclResourceUrl + '#ControlReadWrite');
|
|
210
|
-
ins.push(quad(aclId, rdfStore.cache.sym(RDF.type), rdfStore.cache.sym(ACL.Authorization), graph));
|
|
211
|
-
ins.push(quad(aclId, rdfStore.cache.sym(ACL.accessTo), rdfStore.cache.sym(resourceUrl), graph));
|
|
212
|
-
[ACL.Control, ACL.Write, ACL.Read].forEach(mode => {
|
|
213
|
-
ins.push(quad(aclId, rdfStore.cache.sym(ACL.mode), rdfStore.cache.sym(mode), graph));
|
|
214
|
-
});
|
|
215
|
-
ins.push(quad(aclId, rdfStore.cache.sym(ACL.agent), rdfStore.cache.sym(ownerId), graph));
|
|
216
|
-
await rdfStore.updateManager.update([], ins);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
async function pubKeySpkiPem(pubKey: CryptoKey, profileId: string) {
|
|
220
|
-
const exported = await window.crypto.subtle.exportKey("spki", pubKey);
|
|
221
|
-
const exportedAsString = ab2str(exported);
|
|
222
|
-
const exportedAsBase64 = window.btoa(exportedAsString);
|
|
223
|
-
const profileResourceUrl = removeHashFromUrl(profileId);
|
|
224
|
-
const del: Statement[] = [];
|
|
225
|
-
const ins: Statement[] = [];
|
|
226
|
-
del.push(...rdfStore.cache.statementsMatching(
|
|
227
|
-
rdfStore.cache.sym(PODCHAT.RSAPublicKey),
|
|
228
|
-
rdfStore.cache.sym(SIOC.content_encoded),
|
|
229
|
-
undefined,
|
|
230
|
-
rdfStore.cache.sym(profileResourceUrl)
|
|
231
|
-
));
|
|
232
|
-
ins.push(quad(
|
|
233
|
-
rdfStore.cache.sym(PODCHAT.RSAPublicKey),
|
|
234
|
-
rdfStore.cache.sym(SIOC.content_encoded),
|
|
235
|
-
literal(exportedAsBase64), // alain
|
|
236
|
-
rdfStore.cache.sym(profileResourceUrl)
|
|
237
|
-
));
|
|
238
|
-
await rdfStore.updateManager.update(del, ins);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/*
|
|
242
|
-
Convert an ArrayBuffer into a string
|
|
243
|
-
*/
|
|
244
|
-
/* function ab2str(buf: ArrayBuffer) {
|
|
245
|
-
return String.fromCharCode.apply(null, new Uint8Array(buf) as unknown as number[]);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function str2ab(str: string) {
|
|
249
|
-
const buf = new ArrayBuffer(str.length);
|
|
250
|
-
const bufView = new Uint8Array(buf);
|
|
251
|
-
for (let i = 0, strLen = str.length; i < strLen; i++) {
|
|
252
|
-
bufView[i] = str.charCodeAt(i);
|
|
253
|
-
}
|
|
254
|
-
return buf;
|
|
255
|
-
} */
|
|
256
|
-
"use strict";
|
|
257
|
-
//# sourceMappingURL=crypto.js.map
|
package/lib/chat/crypto.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","names":[],"sources":["../../src/chat/crypto.ts"],"sourcesContent":["/* import { literal, quad, Statement } from 'rdflib';\r\n// import { PODCHAT, removeHashFromUrl } from './Constants';\r\nimport { authn } from 'solid-logic'\r\nimport * as UI from 'solid-ui'\r\nimport * as $rdf from 'rdflib'\r\n\r\nconst ns = UI.ns\r\n\r\nconst removeHashFromUrl = (url: string) => {\r\n const newUrl = new URL(url)\r\n newUrl.hash = ''\r\n return newUrl.href\r\n}\r\nconst PODCHAT_NS = 'https://www.pod-chat.com/';\r\nconst PODCHAT = {\r\n LongChatMessage: PODCHAT_NS + 'LongChatMessage',\r\n LongChatMessageReply: PODCHAT_NS + 'LongChatMessageReply',\r\n RSAPublicKey: PODCHAT_NS + 'RSAPublicKey',\r\n RSAPrivateKey: PODCHAT_NS + 'RSAPrivateKey',\r\n signature: PODCHAT_NS + 'signature'\r\n}\r\n\r\n// import rdfStore, { extractObjectLastValue } from './RdfStore';\r\n\r\nexport type RdfStore = {\r\n cache: Store,\r\n fetcher: Fetcher,\r\n updateManager: UpdateManager\r\n}\r\nfunction extractObject({ cache }: RdfStore, webid: string, resourceUrl: string, predicate: PredicateType): Array<Node> {\r\n return cache.each(cache.sym(webid), predicate, undefined, cache.sym(resourceUrl));\r\n}\r\nfunction extractObjectLastValue(rdfStore: RdfStore, webid: string, resourceUrl: string, predicate: PredicateType): string | undefined {\r\n return extractObject(rdfStore, webid, resourceUrl, predicate).map(q => q.value).pop();\r\n}\r\n\r\nexport const prepareRsaKeyPair = async (profileId: string, rsaPrivateKeyResourceUrl: string): Promise<void> => {\r\n\r\n const privKey = await getPrivateKey(rsaPrivateKeyResourceUrl);\r\n const pubKey = await getPublicKey(profileId);\r\n\r\n if (!privKey || !pubKey) {\r\n await createKeyPair(profileId, rsaPrivateKeyResourceUrl);\r\n const privKeyNew = await getPrivateKey(rsaPrivateKeyResourceUrl);\r\n const pubKeyNew = await getPublicKey(profileId);\r\n if (!privKeyNew || !pubKeyNew) {\r\n throw new Error('Unable to create RSA keypair.');\r\n }\r\n }\r\n}\r\n\r\nexport const signMessage = async (rsaPrivateKeyResourceUrl: string, messageContent: string): Promise<string | undefined> => {\r\n const privateKey = await getPrivateKey(rsaPrivateKeyResourceUrl);\r\n if (privateKey) {\r\n const messageContentEnc = new TextEncoder().encode(messageContent);\r\n const signature = await window.crypto.subtle.sign(\r\n {\r\n name: \"RSA-PSS\",\r\n saltLength: 32,\r\n },\r\n privateKey,\r\n messageContentEnc\r\n );\r\n const exportedAsString = ab2str(signature);\r\n const exportedAsBase64 = window.btoa(exportedAsString);\r\n return exportedAsBase64;\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nexport const verifyMessage = async (profileId: string, messageId: string, messageContent: string, signatureEncoded: string): Promise<{ messageId: string, trusted: boolean }> => {\r\n let encoded = new TextEncoder().encode(messageContent);\r\n const publicKey = await getPublicKey(profileId);\r\n // base64 decode the string to get the binary data\r\n const binaryDerString = window.atob(signatureEncoded);\r\n // convert from a binary string to an ArrayBuffer\r\n const signature = str2ab(binaryDerString);\r\n\r\n if (publicKey) {\r\n const trusted = await window.crypto.subtle.verify(\r\n {\r\n name: \"RSA-PSS\",\r\n saltLength: 32,\r\n },\r\n publicKey,\r\n signature,\r\n encoded\r\n );\r\n return { messageId, trusted };\r\n }\r\n\r\n return { messageId, trusted: false };\r\n}\r\n\r\nconst getPublicKey = async (profileId: string): Promise<CryptoKey | undefined> => {\r\n const profileResourceUrl = removeHashFromUrl(profileId);\r\n await rdfStore.fetcher.load(profileResourceUrl);\r\n const pubKeyEncoded = extractObjectLastValue(rdfStore, PODCHAT.RSAPublicKey, profileResourceUrl, rdfStore.cache.sym(SIOC.content_encoded));\r\n if (pubKeyEncoded) {\r\n return importPublicKey(pubKeyEncoded);\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nconst getPrivateKey = async (rsaPrivateKeyResourceUrl: string): Promise<CryptoKey | undefined> => {\r\n await rdfStore.fetcher.load(rsaPrivateKeyResourceUrl);\r\n const privKeyEncoded = extractObjectLastValue(rdfStore, PODCHAT.RSAPrivateKey, rsaPrivateKeyResourceUrl, rdfStore.cache.sym(SIOC.content_encoded));\r\n if (privKeyEncoded) {\r\n return importPrivateKey(privKeyEncoded);\r\n }\r\n return undefined;\r\n}\r\n\r\n/*\r\n Import a PEM encoded RSA private key, to use for RSA-PSS signing.\r\n Takes a string containing the PEM encoded key, and returns a Promise\r\n that will resolve to a CryptoKey representing the private key.\r\n */\r\n/* function importPrivateKey(pem: string) {\r\n // base64 decode the string to get the binary data\r\n const binaryDerString = window.atob(pem);\r\n // convert from a binary string to an ArrayBuffer\r\n const binaryDer = str2ab(binaryDerString);\r\n\r\n return window.crypto.subtle.importKey(\r\n \"pkcs8\",\r\n binaryDer,\r\n {\r\n name: \"RSA-PSS\",\r\n // Consider using a 4096-bit key for systems that require long-term security\r\n //modulusLength: 4096,\r\n //publicExponent: new Uint8Array([1, 0, 1]),\r\n hash: \"SHA-256\",\r\n },\r\n true,\r\n [\"sign\"]\r\n );\r\n}\r\n\r\n/*\r\n Import a PEM encoded RSA public key, to use for RSA-OAEP encryption.\r\n Takes a string containing the PEM encoded key, and returns a Promise\r\n that will resolve to a CryptoKey representing the public key.\r\n */\r\n/* function importPublicKey(pem: string) {\r\n // base64 decode the string to get the binary data\r\n const binaryDerString = window.atob(pem);\r\n // convert from a binary string to an ArrayBuffer\r\n const binaryDer = str2ab(binaryDerString);\r\n\r\n return window.crypto.subtle.importKey(\r\n \"spki\",\r\n binaryDer,\r\n {\r\n name: \"RSA-PSS\",\r\n hash: \"SHA-256\"\r\n },\r\n true,\r\n [\"verify\"]\r\n );\r\n}\r\n\r\n/* const createKeyPair = async (profileId: string, rsaPrivateKeyResourceUrl: string) => {\r\n const key = await window.crypto.subtle\r\n .generateKey(\r\n {\r\n name: \"RSA-PSS\",\r\n // Consider using a 4096-bit key for systems that require long-term security\r\n modulusLength: 4096,\r\n publicExponent: new Uint8Array([1, 0, 1]),\r\n hash: \"SHA-256\",\r\n },\r\n true,\r\n [\"sign\", \"verify\"]\r\n );\r\n\r\n await privKeyPkcs8Pem(key.privateKey, profileId, rsaPrivateKeyResourceUrl);\r\n await pubKeySpkiPem(key.publicKey, profileId);\r\n} */\r\n\r\n/* async function privKeyPkcs8Pem(privKey: CryptoKey, profileId: string, rsaPrivateKeyResourceUrl: string) {\r\n const exported = await window.crypto.subtle.exportKey(\"pkcs8\", privKey);\r\n const exportedAsString = ab2str(exported);\r\n const exportedAsBase64 = window.btoa(exportedAsString);\r\n const del: Statement[] = [];\r\n const ins: Statement[] = [];\r\n del.push(...rdfStore.cache.statementsMatching(\r\n rdfStore.cache.sym(PODCHAT.RSAPrivateKey),\r\n rdfStore.cache.sym(SIOC.content_encoded),\r\n undefined,\r\n rdfStore.cache.sym(rsaPrivateKeyResourceUrl)\r\n ));\r\n ins.push(quad(\r\n rdfStore.cache.sym(PODCHAT.RSAPrivateKey),\r\n rdfStore.cache.sym(SIOC.content_encoded),\r\n literal(exportedAsBase64), // alain\r\n rdfStore.cache.sym(rsaPrivateKeyResourceUrl)\r\n ));\r\n await rdfStore.updateManager.update(del, ins);\r\n await aclForResource(rsaPrivateKeyResourceUrl, profileId);\r\n}\r\n\r\nasync function aclForResource(resourceUrl: string, ownerId: string) {\r\n const ins: Statement[] = [];\r\n const aclResourceUrl = resourceUrl + '.acl';\r\n const graph = rdfStore.cache.sym(aclResourceUrl);\r\n const aclId = rdfStore.cache.sym(aclResourceUrl + '#ControlReadWrite');\r\n ins.push(quad(aclId, rdfStore.cache.sym(RDF.type), rdfStore.cache.sym(ACL.Authorization), graph));\r\n ins.push(quad(aclId, rdfStore.cache.sym(ACL.accessTo), rdfStore.cache.sym(resourceUrl), graph));\r\n [ACL.Control, ACL.Write, ACL.Read].forEach(mode => {\r\n ins.push(quad(aclId, rdfStore.cache.sym(ACL.mode), rdfStore.cache.sym(mode), graph));\r\n });\r\n ins.push(quad(aclId, rdfStore.cache.sym(ACL.agent), rdfStore.cache.sym(ownerId), graph));\r\n await rdfStore.updateManager.update([], ins);\r\n}\r\n\r\nasync function pubKeySpkiPem(pubKey: CryptoKey, profileId: string) {\r\n const exported = await window.crypto.subtle.exportKey(\"spki\", pubKey);\r\n const exportedAsString = ab2str(exported);\r\n const exportedAsBase64 = window.btoa(exportedAsString);\r\n const profileResourceUrl = removeHashFromUrl(profileId);\r\n const del: Statement[] = [];\r\n const ins: Statement[] = [];\r\n del.push(...rdfStore.cache.statementsMatching(\r\n rdfStore.cache.sym(PODCHAT.RSAPublicKey),\r\n rdfStore.cache.sym(SIOC.content_encoded),\r\n undefined,\r\n rdfStore.cache.sym(profileResourceUrl)\r\n ));\r\n ins.push(quad(\r\n rdfStore.cache.sym(PODCHAT.RSAPublicKey),\r\n rdfStore.cache.sym(SIOC.content_encoded),\r\n literal(exportedAsBase64), // alain\r\n rdfStore.cache.sym(profileResourceUrl)\r\n ));\r\n await rdfStore.updateManager.update(del, ins);\r\n}\r\n\r\n/*\r\n Convert an ArrayBuffer into a string\r\n */\r\n/* function ab2str(buf: ArrayBuffer) {\r\n return String.fromCharCode.apply(null, new Uint8Array(buf) as unknown as number[]);\r\n}\r\n\r\nfunction str2ab(str: string) {\r\n const buf = new ArrayBuffer(str.length);\r\n const bufView = new Uint8Array(buf);\r\n for (let i = 0, strLen = str.length; i < strLen; i++) {\r\n bufView[i] = str.charCodeAt(i);\r\n }\r\n return buf;\r\n} */\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXA"}
|