@@ -54889,7 +54889,7 @@ class RemoteStorage {
54889
54889
case 'pod-not-selected':
54890
54890
if ((this.remote instanceof solid_1.default)
54891
54891
&& this.remote.getPodURLs().length > 0
54892
- && this.remote.getPodURL() == null) {
54892
+ && this.remote.getPodURL() === null) {
54893
54893
setTimeout(handler, 0);
54894
54894
}
54895
54895
break;
@@ -55185,16 +55185,6 @@ class RemoteStorage {
55185
55185
log(...args) {
55186
55186
log_1.default.apply(RemoteStorage, args);
55187
55187
}
55188
- setSolidAuthURL(authURL) {
55189
- if (!authURL) {
55190
- return;
55191
- }
55192
- solid_1.default._rs_init(this);
55193
- this.solid.setAuthURL(authURL);
55194
- if (hasLocalStorage) {
55195
- localStorage.setItem('remotestorage:solid-auth-url', authURL); // TODO
55196
- }
55197
- }
55198
55188
/**
55199
55189
* Set the OAuth key/ID for either GoogleDrive, Dropbox or Solid backend support.
55200
55190
*
@@ -56024,16 +56014,13 @@ const baseclient_1 = __importDefault(__webpack_require__(/*! ./baseclient */ "./
56024
56014
const eventhandling_1 = __importDefault(__webpack_require__(/*! ./eventhandling */ "./src/eventhandling.ts"));
56025
56015
const util_1 = __webpack_require__(/*! ./util */ "./src/util.ts");
56026
56016
const remote_1 = __webpack_require__(/*! ./remote */ "./src/remote.ts");
56027
- const solidStorage_1 = __importDefault(__webpack_require__(/*! ./solid/ solidStorage */ "./src/solid /solidStorage.ts"));
56017
+ const solidStorage_1 = __importDefault(__webpack_require__(/*! ./solidStorage */ "./src/solidStorage.ts"));
56028
56018
const blob_1 = __importDefault(__webpack_require__(/*! blob */ "./node_modules/blob/main.js"));
56029
56019
const SETTINGS_KEY = 'remotestorage:solid';
56030
56020
let hasLocalStorage;
56031
56021
/**
56032
56022
* Overwrite BaseClient's getItemURL with our own implementation
56033
56023
*
56034
- * TODO: Still needs to be implemented. At the moment it just throws
56035
- * and error saying that it's not implemented yet.
56036
- *
56037
56024
* @param {object} rs - RemoteStorage instance
56038
56025
*
56039
56026
* @private
@@ -56043,8 +56030,19 @@ function hookGetItemURL(rs) {
56043
56030
return;
56044
56031
}
56045
56032
rs._origBaseClientGetItemURL = baseclient_1.default.prototype.getItemURL;
56046
- baseclient_1.default.prototype.getItemURL = function ( /* path */) {
56047
- throw new Error('getItemURL is not implemented for Solid yet'); // TODO It actually is. No?
56033
+ baseclient_1.default.prototype.getItemURL = function (path) {
56034
+ if (typeof path !== 'string') {
56035
+ throw 'Argument \'path\' of baseClient.getItemURL must be a string';
56036
+ }
56037
+ if (this.storage.connected) {
56038
+ if (path.startsWith('/')) {
56039
+ path = path.substring(1);
56040
+ }
56041
+ return this.selectedPodURL + (0, util_1.cleanPath)(path);
56042
+ }
56043
+ else {
56044
+ return undefined;
56045
+ }
56048
56046
};
56049
56047
}
56050
56048
/**
@@ -56072,14 +56070,18 @@ function unHookGetItemURL(rs) {
56072
56070
*/
56073
56071
function requestBodyToBlob(body) {
56074
56072
if (typeof (body) === 'object') {
56075
- if (body instanceof blob_1.default)
56073
+ if (body instanceof blob_1.default) {
56076
56074
return body;
56077
- if (body instanceof DataView)
56075
+ }
56076
+ if (body instanceof DataView) {
56078
56077
return new blob_1.default([body], { type: "application/octet-stream" });
56079
- if (body instanceof ArrayBuffer)
56078
+ }
56079
+ if (body instanceof ArrayBuffer) {
56080
56080
return new blob_1.default([new DataView(body)]);
56081
- if (ArrayBuffer.isView(body))
56081
+ }
56082
+ if (ArrayBuffer.isView(body)) {
56082
56083
return new blob_1.default([body], { type: "application/octet-stream" });
56084
+ }
56083
56085
if (body instanceof FormData) {
56084
56086
return new blob_1.default([new URLSearchParams([JSON.parse(JSON.stringify(body.entries()))]).toString()], { type: 'application/x-www-form-urlencoded' });
56085
56087
}
@@ -56166,16 +56168,15 @@ class Solid extends remote_1.RemoteBase {
56166
56168
* @protected
56167
56169
*/
56168
56170
configure(settings) {
56169
- // TODO fix comments
56170
56171
// We only update this.userAddress if settings.userAddress is set to a string or to null
56171
56172
if (typeof settings.userAddress !== 'undefined') {
56172
56173
this.userAddress = settings.userAddress;
56173
56174
}
56174
- // We only update this.userAddress if settings.userAddress is set to a string or to null
56175
+ // We only update this.authURL if settings.href is set to a string or to null
56175
56176
if (typeof settings.href !== 'undefined') {
56176
56177
this.authURL = settings.href;
56177
56178
}
56178
- // Same for this.token. If only one of these two is set, we leave the other one at its existing value
56179
+ // Read session properties and pod URL from the properties if it exists
56179
56180
if (typeof settings.properties !== 'undefined') {
56180
56181
const properties = settings.properties;
56181
56182
if (properties) {
@@ -56218,8 +56219,7 @@ class Solid extends remote_1.RemoteBase {
56218
56219
};
56219
56220
if (this.sessionProperties) {
56220
56221
this.configStorage.setConfig(JSON.stringify(this.sessionProperties));
56221
- this.connected = false;
56222
- // TODO this.connect();
56222
+ this.connected = this.session.info && this.session.info.isLoggedIn;
56223
56223
writeSettingsToCache.apply(this);
56224
56224
}
56225
56225
else {
@@ -56241,21 +56241,31 @@ class Solid extends remote_1.RemoteBase {
56241
56241
return this.podURLs;
56242
56242
}
56243
56243
setPodURL(podURL) {
56244
+ if (this.selectedPodURL === podURL) {
56245
+ return;
56246
+ }
56244
56247
this.selectedPodURL = podURL;
56245
56248
if (this.session.info && this.session.info.isLoggedIn) {
56246
- let settings = (0, util_1.getJSONFromLocalStorage)(SETTINGS_KEY);
56247
- if (!settings) {
56248
- settings = {};
56249
- }
56250
- settings.userAddress = this.session.info.webId;
56251
- settings.href = this.authURL;
56252
- settings.properties = {
56253
- sessionProperties: this.sessionProperties,
56254
- podURL: this.selectedPodURL
56255
- };
56256
- localStorage.setItem(SETTINGS_KEY, JSON.stringify(settings));
56249
+ if (this.selectedPodURL) {
56250
+ let settings = (0, util_1.getJSONFromLocalStorage)(SETTINGS_KEY);
56251
+ if (!settings) {
56252
+ settings = {};
56253
+ }
56254
+ settings.userAddress = this.session.info.webId;
56255
+ settings.href = this.authURL;
56256
+ settings.properties = {
56257
+ sessionProperties: this.sessionProperties,
56258
+ podURL: this.selectedPodURL
56259
+ };
56260
+ localStorage.setItem(SETTINGS_KEY, JSON.stringify(settings));
56261
+ this.connected = true;
56262
+ this._emit('connected');
56263
+ }
56264
+ else {
56265
+ this.connected = false;
56266
+ this.rs._emit('pod-not-selected');
56267
+ }
56257
56268
}
56258
- this._emit('connected');
56259
56269
}
56260
56270
getPodURL() {
56261
56271
return this.selectedPodURL;
@@ -56265,12 +56275,24 @@ class Solid extends remote_1.RemoteBase {
56265
56275
*/
56266
56276
connect() {
56267
56277
this.rs.setBackend('solid');
56278
+ if (!this.authURL) {
56279
+ this.rs._emit('error', new Error(`No authURL is configured.`));
56280
+ return;
56281
+ }
56268
56282
this.session.login({
56269
56283
oidcIssuer: this.authURL,
56270
56284
redirectUrl: new URL("/", window.location.href).toString(),
56271
56285
clientName: "Remote Storage"
56272
56286
});
56273
56287
}
56288
+ /**
56289
+ * Get the connected Solid session
56290
+ *
56291
+ * @returns {Session} that is being used by this instance
56292
+ */
56293
+ getSession() {
56294
+ return (this.session.info && this.session.info.isLoggedIn) ? this.session : undefined;
56295
+ }
56274
56296
/**
56275
56297
* Convert path to file URL
56276
56298
*
@@ -56284,6 +56306,9 @@ class Solid extends remote_1.RemoteBase {
56284
56306
if (path.startsWith('/')) {
56285
56307
path = path.substring(1);
56286
56308
}
56309
+ if (path.length === 0) {
56310
+ path = '/';
56311
+ }
56287
56312
return this.selectedPodURL + path;
56288
56313
}
56289
56314
/**
@@ -56308,9 +56333,10 @@ class Solid extends remote_1.RemoteBase {
56308
56333
map[itemName] = {}; // We are skipping ETag
56309
56334
}
56310
56335
else {
56336
+ const fileDataset = (0, solid_client_1.getThing)(containerDataset, item);
56311
56337
map[itemName] = {
56312
- 'Content-Length': 1 ,
56313
- 'Last-Modified': 1 , // date.toUTCString()
56338
+ 'Content-Length': (0, solid_client_1.getInteger)(fileDataset, 'http://www.w3.org/ns/posix/stat#size') ,
56339
+ 'Last-Modified': (0, solid_client_1.getDatetime)(fileDataset, 'http://purl.org/dc/terms/modified').toUTCString() , // date.toUTCString()
56314
56340
};
56315
56341
}
56316
56342
return map;
@@ -56477,16 +56503,16 @@ class Solid extends remote_1.RemoteBase {
56477
56503
unHookGetItemURL(remoteStorage);
56478
56504
}
56479
56505
}
56480
- (0, util_1.applyMixins)(Solid, [eventhandling_1.default]); // TODO what is this?
56506
+ (0, util_1.applyMixins)(Solid, [eventhandling_1.default]);
56481
56507
module.exports = Solid;
56482
56508
56483
56509
56484
56510
/***/ }),
56485
56511
56486
- /***/ "./src/solid/ solidStorage.ts":
56487
- /*!*********************************** !*\
56488
- !*** ./src/solid/ solidStorage.ts ***!
56489
- \*********************************** /
56512
+ /***/ "./src/solidStorage.ts":
56513
+ /*!*****************************!*\
56514
+ !*** ./src/solidStorage.ts ***!
56515
+ \*****************************/
56490
56516
/***/ (function(__unused_webpack_module, exports) {
56491
56517
56492
56518
"use strict";
0 commit comments