solid-logic 3.1.1-f0ed025 → 3.1.1-f7eee1f
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 +108 -2
- package/dist/789.solid-logic.js +11 -0
- package/dist/789.solid-logic.js.map +1 -0
- package/dist/789.solid-logic.min.js +1 -0
- package/dist/841.solid-logic.js +12133 -0
- package/dist/841.solid-logic.js.map +1 -0
- package/dist/841.solid-logic.min.js +73 -0
- package/dist/841.solid-logic.min.js.map +1 -0
- package/dist/acl/aclLogic.d.ts +5 -0
- package/{lib → dist}/acl/aclLogic.d.ts.map +1 -1
- package/dist/acl/aclLogic.js +122 -0
- package/dist/acl/aclLogic.js.map +1 -0
- package/{lib → dist}/authSession/authSession.js +1 -1
- package/{lib → dist}/authSession/authSession.js.map +1 -1
- package/{lib → dist}/authn/SolidAuthnLogic.d.ts +3 -3
- package/{lib → dist}/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/dist/authn/SolidAuthnLogic.js +147 -0
- package/dist/authn/SolidAuthnLogic.js.map +1 -0
- package/{lib → dist}/authn/authUtil.d.ts +1 -1
- package/{lib → dist}/authn/authUtil.js +12 -12
- package/dist/authn/authUtil.js.map +1 -0
- package/{lib → dist}/chat/chatLogic.d.ts +1 -1
- package/dist/chat/chatLogic.js +160 -0
- package/dist/chat/chatLogic.js.map +1 -0
- package/{lib → dist}/inbox/inboxLogic.d.ts +1 -1
- package/{lib → dist}/inbox/inboxLogic.d.ts.map +1 -1
- package/dist/inbox/inboxLogic.js +55 -0
- package/dist/inbox/inboxLogic.js.map +1 -0
- package/{lib → dist}/index.d.ts +1 -1
- package/{lib → dist}/index.d.ts.map +1 -1
- package/{lib → dist}/index.js +4 -4
- package/{lib → dist}/index.js.map +1 -1
- package/dist/issuer/issuerLogic.js +40 -0
- package/dist/issuer/issuerLogic.js.map +1 -0
- package/{lib → dist}/logic/CustomError.d.ts.map +1 -1
- package/dist/logic/CustomError.js +38 -0
- package/dist/logic/CustomError.js.map +1 -0
- package/dist/logic/solidLogic.d.ts +6 -0
- package/{lib → dist}/logic/solidLogic.d.ts.map +1 -1
- package/{lib → dist}/logic/solidLogic.js +32 -33
- package/dist/logic/solidLogic.js.map +1 -0
- package/dist/logic/solidLogicSingleton.js +54 -0
- package/dist/logic/solidLogicSingleton.js.map +1 -0
- package/{lib → dist}/profile/profileLogic.d.ts +1 -1
- package/dist/profile/profileLogic.js +165 -0
- package/dist/profile/profileLogic.js.map +1 -0
- package/dist/solid-logic.esm.external.js +12725 -0
- package/dist/solid-logic.esm.external.js.map +1 -0
- package/dist/solid-logic.esm.external.min.js +32 -0
- package/dist/solid-logic.esm.external.min.js.map +1 -0
- package/dist/solid-logic.external.js +12802 -0
- package/dist/solid-logic.external.js.map +1 -0
- package/dist/solid-logic.external.min.js +32 -0
- package/dist/solid-logic.external.min.js.map +1 -0
- package/dist/solid-logic.js +40921 -0
- package/dist/solid-logic.js.map +1 -0
- package/dist/solid-logic.min.js +41 -0
- package/dist/solid-logic.min.js.map +1 -0
- package/dist/typeIndex/typeIndexLogic.js +222 -0
- package/dist/typeIndex/typeIndexLogic.js.map +1 -0
- package/{lib → dist}/types.d.ts +2 -2
- package/{lib → dist}/util/containerLogic.d.ts +1 -1
- package/{lib → dist}/util/containerLogic.d.ts.map +1 -1
- package/{src/util/containerLogic.ts → dist/util/containerLogic.js} +20 -25
- package/dist/util/containerLogic.js.map +1 -0
- package/dist/util/debug.d.ts.map +1 -0
- package/dist/util/debug.js +20 -0
- package/dist/util/debug.js.map +1 -0
- package/{lib → dist}/util/ns.js +2 -2
- package/{lib → dist}/util/ns.js.map +1 -1
- package/{lib → dist}/util/utilityLogic.d.ts +1 -1
- package/{lib → dist}/util/utilityLogic.d.ts.map +1 -1
- package/dist/util/utilityLogic.js +180 -0
- package/dist/util/utilityLogic.js.map +1 -0
- package/{lib → dist}/util/utils.d.ts +1 -1
- package/{lib → dist}/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +47 -0
- package/dist/util/utils.js.map +1 -0
- package/dist/versionInfo.js +33 -0
- package/dist/versionInfo.js.map +1 -0
- package/package.json +58 -20
- package/eslint.config.js +0 -29
- package/jest.config.js +0 -10
- package/lib/acl/aclLogic.d.ts +0 -5
- package/lib/acl/aclLogic.js +0 -168
- package/lib/acl/aclLogic.js.map +0 -1
- package/lib/authn/SolidAuthnLogic.js +0 -193
- package/lib/authn/SolidAuthnLogic.js.map +0 -1
- package/lib/authn/authUtil.js.map +0 -1
- package/lib/chat/chatLogic.js +0 -272
- package/lib/chat/chatLogic.js.map +0 -1
- package/lib/inbox/inboxLogic.js +0 -139
- package/lib/inbox/inboxLogic.js.map +0 -1
- package/lib/issuer/issuerLogic.js +0 -52
- package/lib/issuer/issuerLogic.js.map +0 -1
- package/lib/logic/CustomError.js +0 -89
- package/lib/logic/CustomError.js.map +0 -1
- package/lib/logic/solidLogic.d.ts +0 -6
- package/lib/logic/solidLogic.js.map +0 -1
- package/lib/logic/solidLogicSingleton.js +0 -94
- package/lib/logic/solidLogicSingleton.js.map +0 -1
- package/lib/profile/profileLogic.js +0 -259
- package/lib/profile/profileLogic.js.map +0 -1
- package/lib/typeIndex/typeIndexLogic.js +0 -399
- package/lib/typeIndex/typeIndexLogic.js.map +0 -1
- package/lib/util/containerLogic.js +0 -102
- package/lib/util/containerLogic.js.map +0 -1
- package/lib/util/debug.d.ts.map +0 -1
- package/lib/util/debug.js +0 -40
- package/lib/util/debug.js.map +0 -1
- package/lib/util/utilityLogic.js +0 -284
- package/lib/util/utilityLogic.js.map +0 -1
- package/lib/util/utils.js +0 -47
- package/lib/util/utils.js.map +0 -1
- package/src/acl/aclLogic.ts +0 -156
- package/src/authSession/authSession.ts +0 -7
- package/src/authn/SolidAuthnLogic.ts +0 -127
- package/src/authn/authUtil.ts +0 -70
- package/src/chat/chatLogic.ts +0 -226
- package/src/inbox/inboxLogic.ts +0 -59
- package/src/index.ts +0 -22
- package/src/issuer/issuerLogic.ts +0 -40
- package/src/logic/CustomError.ts +0 -29
- package/src/logic/solidLogic.ts +0 -76
- package/src/logic/solidLogicSingleton.ts +0 -20
- package/src/profile/profileLogic.ts +0 -125
- package/src/typeIndex/typeIndexLogic.ts +0 -198
- package/src/types.ts +0 -122
- package/src/util/debug.ts +0 -20
- package/src/util/ns.ts +0 -5
- package/src/util/utilityLogic.ts +0 -156
- package/src/util/utils.ts +0 -52
- package/test/aclLogic.test.ts +0 -24
- package/test/authUtil.test.ts +0 -23
- package/test/chatLogic.test.ts +0 -316
- package/test/container.test.ts +0 -58
- package/test/helpers/dataSetup.ts +0 -134
- package/test/helpers/setup.ts +0 -17
- package/test/inboxLogic.test.ts +0 -218
- package/test/logic.test.ts +0 -29
- package/test/profileLogic.test.ts +0 -246
- package/test/solidAuthLogic.test.ts +0 -49
- package/test/typeIndexLogic.test.ts +0 -255
- package/test/utilityLogic.test.ts +0 -179
- package/test/utils.test.ts +0 -32
- package/tsconfig.json +0 -75
- /package/{lib → dist}/authSession/authSession.d.ts +0 -0
- /package/{lib → dist}/authSession/authSession.d.ts.map +0 -0
- /package/{lib → dist}/authn/authUtil.d.ts.map +0 -0
- /package/{lib → dist}/chat/chatLogic.d.ts.map +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts.map +0 -0
- /package/{lib → dist}/logic/CustomError.d.ts +0 -0
- /package/{lib → dist}/logic/solidLogicSingleton.d.ts +0 -0
- /package/{lib → dist}/logic/solidLogicSingleton.d.ts.map +0 -0
- /package/{lib → dist}/profile/profileLogic.d.ts.map +0 -0
- /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts +0 -0
- /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts.map +0 -0
- /package/{lib → dist}/types.d.ts.map +0 -0
- /package/{lib → dist}/types.js +0 -0
- /package/{lib → dist}/types.js.map +0 -0
- /package/{lib → dist}/util/debug.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts.map +0 -0
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
-
function step(op) {
|
|
49
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
-
switch (op[0]) {
|
|
54
|
-
case 0: case 1: t = op; break;
|
|
55
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
-
default:
|
|
59
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
-
if (t[2]) _.ops.pop();
|
|
64
|
-
_.trys.pop(); continue;
|
|
65
|
-
}
|
|
66
|
-
op = body.call(thisArg, _);
|
|
67
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
-
exports.solidLogicSingleton = void 0;
|
|
73
|
-
var debug = __importStar(require("../util/debug"));
|
|
74
|
-
var authSession_1 = require("../authSession/authSession");
|
|
75
|
-
var solidLogic_1 = require("./solidLogic");
|
|
76
|
-
var _fetch = function (url, requestInit) { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
-
var omitCreds;
|
|
78
|
-
return __generator(this, function (_a) {
|
|
79
|
-
omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit';
|
|
80
|
-
if (authSession_1.authSession.info.webId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114
|
|
81
|
-
// In fact fetch should respect credentials omit itself
|
|
82
|
-
return [2 /*return*/, authSession_1.authSession.fetch(url, requestInit)];
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return [2 /*return*/, window.fetch(url, requestInit)];
|
|
86
|
-
}
|
|
87
|
-
return [2 /*return*/];
|
|
88
|
-
});
|
|
89
|
-
}); };
|
|
90
|
-
//this const makes solidLogicSingleton global accessible in mashlib
|
|
91
|
-
var solidLogicSingleton = (0, solidLogic_1.createSolidLogic)({ fetch: _fetch }, authSession_1.authSession);
|
|
92
|
-
exports.solidLogicSingleton = solidLogicSingleton;
|
|
93
|
-
debug.log('Unique quadstore initialized.');
|
|
94
|
-
//# sourceMappingURL=solidLogicSingleton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidLogicSingleton.js","sourceRoot":"","sources":["../../src/logic/solidLogicSingleton.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAsC;AACtC,0DAAwD;AACxD,2CAA+C;AAE/C,IAAM,MAAM,GAAG,UAAO,GAAG,EAAE,WAAW;;;QAC5B,SAAS,GAAG,WAAW,IAAI,WAAW,CAAC,WAAW,IAAI,WAAW,CAAC,WAAW,IAAI,MAAM,CAAA;QAC7F,IAAI,yBAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,oDAAoD;YAC5F,uDAAuD;YACvD,sBAAO,yBAAW,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,EAAA;QAC9C,CAAC;aAAM,CAAC;YACJ,sBAAO,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,EAAA;QACzC,CAAC;;;KACJ,CAAA;AAED,mEAAmE;AACnE,IAAM,mBAAmB,GAAG,IAAA,6BAAgB,EAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,yBAAW,CAAC,CAAA;AAInE,kDAAmB;AAF5B,KAAK,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA"}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
-
function step(op) {
|
|
49
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
-
switch (op[0]) {
|
|
54
|
-
case 0: case 1: t = op; break;
|
|
55
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
-
default:
|
|
59
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
-
if (t[2]) _.ops.pop();
|
|
64
|
-
_.trys.pop(); continue;
|
|
65
|
-
}
|
|
66
|
-
op = body.call(thisArg, _);
|
|
67
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
-
exports.createProfileLogic = createProfileLogic;
|
|
73
|
-
var CustomError_1 = require("../logic/CustomError");
|
|
74
|
-
var debug = __importStar(require("../util/debug"));
|
|
75
|
-
var ns_1 = require("../util/ns");
|
|
76
|
-
var utils_1 = require("../util/utils");
|
|
77
|
-
function createProfileLogic(store, authn, utilityLogic) {
|
|
78
|
-
var ns = ns_1.ns;
|
|
79
|
-
/**
|
|
80
|
-
* loads the preference without throwing errors - if it can create it it does so.
|
|
81
|
-
* remark: it still throws error if it cannot load profile.
|
|
82
|
-
* @param user
|
|
83
|
-
* @returns undefined if preferenceFile cannot be returned or NamedNode if it can find it or create it
|
|
84
|
-
*/
|
|
85
|
-
function silencedLoadPreferences(user) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
var err_1;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
_a.trys.push([0, 2, , 3]);
|
|
92
|
-
return [4 /*yield*/, loadPreferences(user)
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
94
|
-
];
|
|
95
|
-
case 1: return [2 /*return*/, _a.sent()
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
97
|
-
];
|
|
98
|
-
case 2:
|
|
99
|
-
err_1 = _a.sent();
|
|
100
|
-
return [2 /*return*/, undefined];
|
|
101
|
-
case 3: return [2 /*return*/];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* loads the preference without returning different errors if it cannot create or load it.
|
|
108
|
-
* remark: it also throws error if it cannot load profile.
|
|
109
|
-
* @param user
|
|
110
|
-
* @returns undefined if preferenceFile cannot be an Error or NamedNode if it can find it or create it
|
|
111
|
-
*/
|
|
112
|
-
function loadPreferences(user) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var possiblePreferencesFile, preferencesFile, err_2, message, err_3, msg;
|
|
115
|
-
return __generator(this, function (_a) {
|
|
116
|
-
switch (_a.label) {
|
|
117
|
-
case 0: return [4 /*yield*/, loadProfile(user)];
|
|
118
|
-
case 1:
|
|
119
|
-
_a.sent();
|
|
120
|
-
possiblePreferencesFile = (0, utils_1.suggestPreferencesFile)(user);
|
|
121
|
-
_a.label = 2;
|
|
122
|
-
case 2:
|
|
123
|
-
_a.trys.push([2, 4, , 5]);
|
|
124
|
-
return [4 /*yield*/, utilityLogic.followOrCreateLink(user, ns.space('preferencesFile'), possiblePreferencesFile, user.doc())];
|
|
125
|
-
case 3:
|
|
126
|
-
preferencesFile = _a.sent();
|
|
127
|
-
return [3 /*break*/, 5];
|
|
128
|
-
case 4:
|
|
129
|
-
err_2 = _a.sent();
|
|
130
|
-
message = "User ".concat(user, " has no pointer in profile to preferences file.");
|
|
131
|
-
debug.warn(message);
|
|
132
|
-
// we are listing the possible errors
|
|
133
|
-
if (err_2 instanceof CustomError_1.NotEditableError) {
|
|
134
|
-
throw err_2;
|
|
135
|
-
}
|
|
136
|
-
if (err_2 instanceof CustomError_1.WebOperationError) {
|
|
137
|
-
throw err_2;
|
|
138
|
-
}
|
|
139
|
-
if (err_2 instanceof CustomError_1.UnauthorizedError) {
|
|
140
|
-
throw err_2;
|
|
141
|
-
}
|
|
142
|
-
if (err_2 instanceof CustomError_1.CrossOriginForbiddenError) {
|
|
143
|
-
throw err_2;
|
|
144
|
-
}
|
|
145
|
-
if (err_2 instanceof CustomError_1.SameOriginForbiddenError) {
|
|
146
|
-
throw err_2;
|
|
147
|
-
}
|
|
148
|
-
if (err_2 instanceof CustomError_1.FetchError) {
|
|
149
|
-
throw err_2;
|
|
150
|
-
}
|
|
151
|
-
throw err_2;
|
|
152
|
-
case 5:
|
|
153
|
-
_a.trys.push([5, 7, , 8]);
|
|
154
|
-
return [4 /*yield*/, store.fetcher.load(preferencesFile)];
|
|
155
|
-
case 6:
|
|
156
|
-
_a.sent();
|
|
157
|
-
return [3 /*break*/, 8];
|
|
158
|
-
case 7:
|
|
159
|
-
err_3 = _a.sent();
|
|
160
|
-
msg = "Unable to load preference of user ".concat(user, ": ").concat(err_3);
|
|
161
|
-
debug.warn(msg);
|
|
162
|
-
if (err_3.response.status === 401) {
|
|
163
|
-
throw new CustomError_1.UnauthorizedError();
|
|
164
|
-
}
|
|
165
|
-
if (err_3.response.status === 403) {
|
|
166
|
-
if ((0, utils_1.differentOrigin)(preferencesFile)) {
|
|
167
|
-
throw new CustomError_1.CrossOriginForbiddenError();
|
|
168
|
-
}
|
|
169
|
-
throw new CustomError_1.SameOriginForbiddenError();
|
|
170
|
-
}
|
|
171
|
-
/*if (err.response.status === 404) {
|
|
172
|
-
throw new NotFoundError();
|
|
173
|
-
}*/
|
|
174
|
-
throw new Error(msg);
|
|
175
|
-
case 8: return [2 /*return*/, preferencesFile];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function loadProfile(user) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
var err_4;
|
|
183
|
-
return __generator(this, function (_a) {
|
|
184
|
-
switch (_a.label) {
|
|
185
|
-
case 0:
|
|
186
|
-
if (!user) {
|
|
187
|
-
throw new Error("loadProfile: no user given.");
|
|
188
|
-
}
|
|
189
|
-
_a.label = 1;
|
|
190
|
-
case 1:
|
|
191
|
-
_a.trys.push([1, 3, , 4]);
|
|
192
|
-
return [4 /*yield*/, store.fetcher.load(user.doc())];
|
|
193
|
-
case 2:
|
|
194
|
-
_a.sent();
|
|
195
|
-
return [3 /*break*/, 4];
|
|
196
|
-
case 3:
|
|
197
|
-
err_4 = _a.sent();
|
|
198
|
-
throw new Error("Unable to load profile of user ".concat(user, ": ").concat(err_4));
|
|
199
|
-
case 4: return [2 /*return*/, user.doc()];
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
function loadMe() {
|
|
205
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
-
var me;
|
|
207
|
-
return __generator(this, function (_a) {
|
|
208
|
-
switch (_a.label) {
|
|
209
|
-
case 0:
|
|
210
|
-
me = authn.currentUser();
|
|
211
|
-
if (me === null) {
|
|
212
|
-
throw new Error("Current user not found! Not logged in?");
|
|
213
|
-
}
|
|
214
|
-
return [4 /*yield*/, store.fetcher.load(me.doc())];
|
|
215
|
-
case 1:
|
|
216
|
-
_a.sent();
|
|
217
|
-
return [2 /*return*/, me];
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function getPodRoot(user) {
|
|
223
|
-
var podRoot = findStorage(user);
|
|
224
|
-
if (!podRoot) {
|
|
225
|
-
throw new Error("User pod root not found!");
|
|
226
|
-
}
|
|
227
|
-
return podRoot;
|
|
228
|
-
}
|
|
229
|
-
function getMainInbox(user) {
|
|
230
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
-
var mainInbox;
|
|
232
|
-
return __generator(this, function (_a) {
|
|
233
|
-
switch (_a.label) {
|
|
234
|
-
case 0: return [4 /*yield*/, store.fetcher.load(user)];
|
|
235
|
-
case 1:
|
|
236
|
-
_a.sent();
|
|
237
|
-
mainInbox = store.any(user, ns.ldp("inbox"), undefined, user.doc());
|
|
238
|
-
if (!mainInbox) {
|
|
239
|
-
throw new Error("User main inbox not found!");
|
|
240
|
-
}
|
|
241
|
-
return [2 /*return*/, mainInbox];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
function findStorage(me) {
|
|
247
|
-
return store.any(me, ns.space("storage"), undefined, me.doc());
|
|
248
|
-
}
|
|
249
|
-
return {
|
|
250
|
-
loadMe: loadMe,
|
|
251
|
-
getPodRoot: getPodRoot,
|
|
252
|
-
getMainInbox: getMainInbox,
|
|
253
|
-
findStorage: findStorage,
|
|
254
|
-
loadPreferences: loadPreferences,
|
|
255
|
-
loadProfile: loadProfile,
|
|
256
|
-
silencedLoadPreferences: silencedLoadPreferences
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
//# sourceMappingURL=profileLogic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profileLogic.js","sourceRoot":"","sources":["../../src/profile/profileLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,gDAqHC;AA3HD,oDAA+J;AAC/J,mDAAuC;AACvC,iCAA6C;AAC7C,uCAAuE;AAGvE,SAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY;IACzD,IAAM,EAAE,GAAG,OAAS,CAAA;IAEpB;;;;;OAKG;IACH,SAAe,uBAAuB,CAAC,IAAe;;;;;;;wBAEvC,qBAAM,eAAe,CAAC,IAAI,CAAC;4BACtC,6DAA6D;0BADvB;4BAAlC,sBAAO,SAA2B;wBACtC,6DAA6D;sBADvB;;;wBAGlC,sBAAO,SAAS,EAAA;;;;;KAEvB;IAED;;;;;OAKG;IACH,SAAe,eAAe,CAAE,IAAe;;;;;4BAC3C,qBAAM,WAAW,CAAC,IAAI,CAAC,EAAA;;wBAAvB,SAAuB,CAAA;wBAEjB,uBAAuB,GAAG,IAAA,8BAAsB,EAAC,IAAI,CAAC,CAAA;;;;wBAGtC,qBAAM,YAAY,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAc,EAAE,uBAAuB,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,EAAA;;wBAA5I,eAAe,GAAG,SAA0H,CAAA;;;;wBAEtI,OAAO,GAAG,eAAQ,IAAI,oDAAiD,CAAA;wBAC7E,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;wBACnB,qCAAqC;wBACrC,IAAI,KAAG,YAAY,8BAAgB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