Skip to content

Commit 34debe1

Browse files
committed
final 2.x changes
2 parents 18366de + d1551d9 commit 34debe1

21 files changed

+4239
-497
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
test-folder
66
log.txt
77
test.ttl
8+
src/*.js

README.md

Lines changed: 134 additions & 72 deletions
Large diffs are not rendered by default.

dist/cjs/EssAuthSession.js

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
"use strict";
2+
3+
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
4+
function adopt(value) {
5+
return value instanceof P ? value : new P(function (resolve) {
6+
resolve(value);
7+
});
8+
}
9+
10+
return new (P || (P = Promise))(function (resolve, reject) {
11+
function fulfilled(value) {
12+
try {
13+
step(generator.next(value));
14+
} catch (e) {
15+
reject(e);
16+
}
17+
}
18+
19+
function rejected(value) {
20+
try {
21+
step(generator["throw"](value));
22+
} catch (e) {
23+
reject(e);
24+
}
25+
}
26+
27+
function step(result) {
28+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29+
}
30+
31+
step((generator = generator.apply(thisArg, _arguments || [])).next());
32+
});
33+
};
34+
35+
var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
36+
var _ = {
37+
label: 0,
38+
sent: function () {
39+
if (t[0] & 1) throw t[1];
40+
return t[1];
41+
},
42+
trys: [],
43+
ops: []
44+
},
45+
f,
46+
y,
47+
t,
48+
g;
49+
return g = {
50+
next: verb(0),
51+
"throw": verb(1),
52+
"return": verb(2)
53+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
54+
return this;
55+
}), g;
56+
57+
function verb(n) {
58+
return function (v) {
59+
return step([n, v]);
60+
};
61+
}
62+
63+
function step(op) {
64+
if (f) throw new TypeError("Generator is already executing.");
65+
66+
while (_) try {
67+
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;
68+
if (y = 0, t) op = [op[0] & 2, t.value];
69+
70+
switch (op[0]) {
71+
case 0:
72+
case 1:
73+
t = op;
74+
break;
75+
76+
case 4:
77+
_.label++;
78+
return {
79+
value: op[1],
80+
done: false
81+
};
82+
83+
case 5:
84+
_.label++;
85+
y = op[1];
86+
op = [0];
87+
continue;
88+
89+
case 7:
90+
op = _.ops.pop();
91+
92+
_.trys.pop();
93+
94+
continue;
95+
96+
default:
97+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
98+
_ = 0;
99+
continue;
100+
}
101+
102+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
103+
_.label = op[1];
104+
break;
105+
}
106+
107+
if (op[0] === 6 && _.label < t[1]) {
108+
_.label = t[1];
109+
t = op;
110+
break;
111+
}
112+
113+
if (t && _.label < t[2]) {
114+
_.label = t[2];
115+
116+
_.ops.push(op);
117+
118+
break;
119+
}
120+
121+
if (t[2]) _.ops.pop();
122+
123+
_.trys.pop();
124+
125+
continue;
126+
}
127+
128+
op = body.call(thisArg, _);
129+
} catch (e) {
130+
op = [6, e];
131+
y = 0;
132+
} finally {
133+
f = t = 0;
134+
}
135+
136+
if (op[0] & 5) throw op[1];
137+
return {
138+
value: op[0] ? op[1] : void 0,
139+
done: true
140+
};
141+
}
142+
};
143+
144+
exports.__esModule = true;
145+
exports.EssAuthSession = void 0;
146+
147+
var solid_client_authn_node_1 = require("@inrupt/solid-client-authn-node");
148+
149+
var EssAuthSession =
150+
/** @class */
151+
function () {
152+
function EssAuthSession() {}
153+
154+
EssAuthSession.prototype.login = function (options) {
155+
return __awaiter(this, void 0, void 0, function () {
156+
var sess;
157+
return __generator(this, function (_a) {
158+
switch (_a.label) {
159+
case 0:
160+
sess = new solid_client_authn_node_1.Session();
161+
return [4
162+
/*yield*/
163+
, sess.login({
164+
clientId: options.clientId,
165+
clientSecret: options.clientSecret,
166+
refreshToken: options.refreshToken,
167+
oidcIssuer: options.oidcIssuer
168+
})];
169+
170+
case 1:
171+
_a.sent();
172+
173+
this.session = sess;
174+
this.session.isLoggedIn = sess.info.isLoggedIn;
175+
this.session.webId = sess.info.webId;
176+
return [2
177+
/*return*/
178+
, this.session];
179+
}
180+
});
181+
});
182+
};
183+
184+
return EssAuthSession;
185+
}();
186+
187+
exports.EssAuthSession = EssAuthSession; // ENDS

dist/cjs/NoAuthSession.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"use strict";
2+
/** UNAUTHENTICATED SESSION
3+
*/
4+
5+
exports.__esModule = true;
6+
exports.NoAuthSession = void 0;
7+
8+
var NoAuthSession =
9+
/** @class */
10+
function () {
11+
function NoAuthSession(options) {
12+
if (options === void 0) {
13+
options = {};
14+
}
15+
16+
this.session = {
17+
isLoggedIn: false,
18+
info: {
19+
isLoggedIn: false
20+
},
21+
fetch: this._fetch.bind(this),
22+
logout: function () {}
23+
};
24+
this.fileHandler = options.fileHandler;
25+
this.httpFetch = options.httpFetch;
26+
}
27+
28+
NoAuthSession.prototype._fetch = function (url, options) {
29+
if (url.startsWith('file')) return this.fileHandler.fetch(url, options);else return this.httpFetch(url, options);
30+
};
31+
32+
return NoAuthSession;
33+
}();
34+
35+
exports.NoAuthSession = NoAuthSession;

0 commit comments

Comments
 (0)