@positronic/cloudflare 0.0.72 → 0.0.74
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/dist/src/api/auth-middleware.js +2 -2
- package/dist/src/api/brains.js +28 -28
- package/dist/src/api/index.js +26 -1
- package/dist/src/api/store.js +30 -30
- package/dist/src/api/users.js +34 -34
- package/dist/src/auth-do.js +21 -53
- package/dist/src/brain-runner-do.js +7 -7
- package/dist/src/create-r2-store.js +2 -2
- package/dist/src/dev-server.js +6 -6
- package/dist/src/monitor-do.js +15 -15
- package/dist/src/schedule-do.js +24 -24
- package/dist/types/api/auth-middleware.d.ts +1 -1
- package/dist/types/api/auth-middleware.d.ts.map +1 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/auth-do.d.ts +6 -8
- package/dist/types/auth-do.d.ts.map +1 -1
- package/dist/types/brain-runner-do.d.ts +1 -1
- package/dist/types/brain-runner-do.d.ts.map +1 -1
- package/dist/types/create-r2-store.d.ts +1 -1
- package/dist/types/monitor-do.d.ts +7 -7
- package/dist/types/monitor-do.d.ts.map +1 -1
- package/dist/types/schedule-do.d.ts +7 -7
- package/dist/types/schedule-do.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -269,7 +269,7 @@ import { jwtVerify, decodeJwt, importJWK } from 'jose';
|
|
|
269
269
|
case 5:
|
|
270
270
|
_state.sent();
|
|
271
271
|
c.set('auth', {
|
|
272
|
-
|
|
272
|
+
userName: userKey.userName,
|
|
273
273
|
isRoot: false
|
|
274
274
|
});
|
|
275
275
|
return [
|
|
@@ -320,7 +320,7 @@ import { jwtVerify, decodeJwt, importJWK } from 'jose';
|
|
|
320
320
|
case 10:
|
|
321
321
|
_state.sent();
|
|
322
322
|
c.set('auth', {
|
|
323
|
-
|
|
323
|
+
userName: null,
|
|
324
324
|
isRoot: true
|
|
325
325
|
});
|
|
326
326
|
return [
|
package/dist/src/api/brains.js
CHANGED
|
@@ -161,13 +161,13 @@ import { isSignalValid, brainMachineDefinition } from '@positronic/core';
|
|
|
161
161
|
import { getManifest } from '../brain-runner-do.js';
|
|
162
162
|
var brains = new Hono();
|
|
163
163
|
/**
|
|
164
|
-
* Get the
|
|
164
|
+
* Get the userName for ownership filtering from the auth context.
|
|
165
165
|
* Root users get null (no filter — sees everything).
|
|
166
|
-
* Non-root users get their
|
|
167
|
-
*/ function
|
|
166
|
+
* Non-root users get their userName (sees only their own).
|
|
167
|
+
*/ function scopeUserName(context) {
|
|
168
168
|
var auth = context.get('auth');
|
|
169
|
-
var
|
|
170
|
-
return (auth === null || auth === void 0 ? void 0 : auth.isRoot) ? null : (
|
|
169
|
+
var _auth_userName;
|
|
170
|
+
return (auth === null || auth === void 0 ? void 0 : auth.isRoot) ? null : (_auth_userName = auth === null || auth === void 0 ? void 0 : auth.userName) !== null && _auth_userName !== void 0 ? _auth_userName : null;
|
|
171
171
|
}
|
|
172
172
|
brains.post('/runs', function(context) {
|
|
173
173
|
return _async_to_generator(function() {
|
|
@@ -229,7 +229,7 @@ brains.post('/runs', function(context) {
|
|
|
229
229
|
stub = namespace.get(doId);
|
|
230
230
|
// Read auth context for currentUser (every brain run must have an owner)
|
|
231
231
|
auth = context.get('auth');
|
|
232
|
-
if (!(auth === null || auth === void 0 ? void 0 : auth.
|
|
232
|
+
if (!(auth === null || auth === void 0 ? void 0 : auth.userName) && !(auth === null || auth === void 0 ? void 0 : auth.isRoot)) {
|
|
233
233
|
return [
|
|
234
234
|
2,
|
|
235
235
|
context.json({
|
|
@@ -238,7 +238,7 @@ brains.post('/runs', function(context) {
|
|
|
238
238
|
];
|
|
239
239
|
}
|
|
240
240
|
currentUser = {
|
|
241
|
-
|
|
241
|
+
name: auth.userName || 'root'
|
|
242
242
|
};
|
|
243
243
|
// Pass options to the brain runner if provided
|
|
244
244
|
initialData = options ? {
|
|
@@ -341,7 +341,7 @@ brains.post('/runs/rerun', function(context) {
|
|
|
341
341
|
case 3:
|
|
342
342
|
// Read auth context for currentUser (every brain run must have an owner)
|
|
343
343
|
auth = context.get('auth');
|
|
344
|
-
if (!(auth === null || auth === void 0 ? void 0 : auth.
|
|
344
|
+
if (!(auth === null || auth === void 0 ? void 0 : auth.userName) && !(auth === null || auth === void 0 ? void 0 : auth.isRoot)) {
|
|
345
345
|
return [
|
|
346
346
|
2,
|
|
347
347
|
context.json({
|
|
@@ -350,7 +350,7 @@ brains.post('/runs/rerun', function(context) {
|
|
|
350
350
|
];
|
|
351
351
|
}
|
|
352
352
|
currentUser = {
|
|
353
|
-
|
|
353
|
+
name: auth.userName || 'root'
|
|
354
354
|
};
|
|
355
355
|
// Create a new brain run with rerun parameters
|
|
356
356
|
newBrainRunId = uuidv4();
|
|
@@ -410,17 +410,17 @@ brains.get('/runs/:runId/watch', function(context) {
|
|
|
410
410
|
});
|
|
411
411
|
brains.get('/runs/:runId', function(context) {
|
|
412
412
|
return _async_to_generator(function() {
|
|
413
|
-
var runId,
|
|
413
|
+
var runId, userName, monitorId, monitorStub, run;
|
|
414
414
|
return _ts_generator(this, function(_state) {
|
|
415
415
|
switch(_state.label){
|
|
416
416
|
case 0:
|
|
417
417
|
runId = context.req.param('runId');
|
|
418
|
-
|
|
418
|
+
userName = scopeUserName(context);
|
|
419
419
|
monitorId = context.env.MONITOR_DO.idFromName('singleton');
|
|
420
420
|
monitorStub = context.env.MONITOR_DO.get(monitorId);
|
|
421
421
|
return [
|
|
422
422
|
4,
|
|
423
|
-
monitorStub.getRun(runId,
|
|
423
|
+
monitorStub.getRun(runId, userName)
|
|
424
424
|
];
|
|
425
425
|
case 1:
|
|
426
426
|
run = _state.sent();
|
|
@@ -676,7 +676,7 @@ brains.post('/runs/:runId/resume', function(context) {
|
|
|
676
676
|
});
|
|
677
677
|
brains.get('/:identifier/history', function(context) {
|
|
678
678
|
return _async_to_generator(function() {
|
|
679
|
-
var identifier, limit, manifest, resolution, brain, brainTitle, monitorId, monitorStub,
|
|
679
|
+
var identifier, limit, manifest, resolution, brain, brainTitle, monitorId, monitorStub, userName, runs;
|
|
680
680
|
return _ts_generator(this, function(_state) {
|
|
681
681
|
switch(_state.label){
|
|
682
682
|
case 0:
|
|
@@ -717,10 +717,10 @@ brains.get('/:identifier/history', function(context) {
|
|
|
717
717
|
// Get the monitor singleton instance
|
|
718
718
|
monitorId = context.env.MONITOR_DO.idFromName('singleton');
|
|
719
719
|
monitorStub = context.env.MONITOR_DO.get(monitorId);
|
|
720
|
-
|
|
720
|
+
userName = scopeUserName(context);
|
|
721
721
|
return [
|
|
722
722
|
4,
|
|
723
|
-
monitorStub.history(brainTitle, limit,
|
|
723
|
+
monitorStub.history(brainTitle, limit, userName)
|
|
724
724
|
];
|
|
725
725
|
case 1:
|
|
726
726
|
runs = _state.sent();
|
|
@@ -736,7 +736,7 @@ brains.get('/:identifier/history', function(context) {
|
|
|
736
736
|
});
|
|
737
737
|
brains.get('/:identifier/active-runs', function(context) {
|
|
738
738
|
return _async_to_generator(function() {
|
|
739
|
-
var identifier, manifest, resolution, brain, brainTitle, monitorId, monitorStub,
|
|
739
|
+
var identifier, manifest, resolution, brain, brainTitle, monitorId, monitorStub, userName, runs;
|
|
740
740
|
return _ts_generator(this, function(_state) {
|
|
741
741
|
switch(_state.label){
|
|
742
742
|
case 0:
|
|
@@ -776,10 +776,10 @@ brains.get('/:identifier/active-runs', function(context) {
|
|
|
776
776
|
// Get the monitor singleton instance
|
|
777
777
|
monitorId = context.env.MONITOR_DO.idFromName('singleton');
|
|
778
778
|
monitorStub = context.env.MONITOR_DO.get(monitorId);
|
|
779
|
-
|
|
779
|
+
userName = scopeUserName(context);
|
|
780
780
|
return [
|
|
781
781
|
4,
|
|
782
|
-
monitorStub.activeRuns(brainTitle,
|
|
782
|
+
monitorStub.activeRuns(brainTitle, userName)
|
|
783
783
|
];
|
|
784
784
|
case 1:
|
|
785
785
|
runs = _state.sent();
|
|
@@ -960,7 +960,7 @@ brains.get('/', function(context) {
|
|
|
960
960
|
// Create a new schedule
|
|
961
961
|
brains.post('/schedules', function(context) {
|
|
962
962
|
return _async_to_generator(function() {
|
|
963
|
-
var body, cronExpression, identifier, manifest, resolution, brain, brainTitle, scheduleDoId, scheduleStub, auth,
|
|
963
|
+
var body, cronExpression, identifier, manifest, resolution, brain, brainTitle, scheduleDoId, scheduleStub, auth, runAsUserName, timezone, schedule, error, errorMessage;
|
|
964
964
|
return _ts_generator(this, function(_state) {
|
|
965
965
|
switch(_state.label){
|
|
966
966
|
case 0:
|
|
@@ -1043,7 +1043,7 @@ brains.post('/schedules', function(context) {
|
|
|
1043
1043
|
scheduleStub = context.env.SCHEDULE_DO.get(scheduleDoId);
|
|
1044
1044
|
// Require authentication — scheduled runs will execute as this user
|
|
1045
1045
|
auth = context.get('auth');
|
|
1046
|
-
if (!(auth === null || auth === void 0 ? void 0 : auth.
|
|
1046
|
+
if (!(auth === null || auth === void 0 ? void 0 : auth.userName) && !(auth === null || auth === void 0 ? void 0 : auth.isRoot)) {
|
|
1047
1047
|
return [
|
|
1048
1048
|
2,
|
|
1049
1049
|
context.json({
|
|
@@ -1051,7 +1051,7 @@ brains.post('/schedules', function(context) {
|
|
|
1051
1051
|
}, 401)
|
|
1052
1052
|
];
|
|
1053
1053
|
}
|
|
1054
|
-
|
|
1054
|
+
runAsUserName = auth.userName || 'root';
|
|
1055
1055
|
// Determine timezone: use provided value, fall back to project timezone
|
|
1056
1056
|
timezone = body.timezone;
|
|
1057
1057
|
if (!!timezone) return [
|
|
@@ -1081,7 +1081,7 @@ brains.post('/schedules', function(context) {
|
|
|
1081
1081
|
}
|
|
1082
1082
|
return [
|
|
1083
1083
|
4,
|
|
1084
|
-
scheduleStub.createSchedule(brainTitle, cronExpression, timezone,
|
|
1084
|
+
scheduleStub.createSchedule(brainTitle, cronExpression, timezone, runAsUserName)
|
|
1085
1085
|
];
|
|
1086
1086
|
case 4:
|
|
1087
1087
|
schedule = _state.sent();
|
|
@@ -1109,16 +1109,16 @@ brains.post('/schedules', function(context) {
|
|
|
1109
1109
|
// List all schedules
|
|
1110
1110
|
brains.get('/schedules', function(context) {
|
|
1111
1111
|
return _async_to_generator(function() {
|
|
1112
|
-
var scheduleId, scheduleStub,
|
|
1112
|
+
var scheduleId, scheduleStub, userName, result;
|
|
1113
1113
|
return _ts_generator(this, function(_state) {
|
|
1114
1114
|
switch(_state.label){
|
|
1115
1115
|
case 0:
|
|
1116
1116
|
scheduleId = context.env.SCHEDULE_DO.idFromName('singleton');
|
|
1117
1117
|
scheduleStub = context.env.SCHEDULE_DO.get(scheduleId);
|
|
1118
|
-
|
|
1118
|
+
userName = scopeUserName(context);
|
|
1119
1119
|
return [
|
|
1120
1120
|
4,
|
|
1121
|
-
scheduleStub.listSchedules(
|
|
1121
|
+
scheduleStub.listSchedules(userName)
|
|
1122
1122
|
];
|
|
1123
1123
|
case 1:
|
|
1124
1124
|
result = _state.sent();
|
|
@@ -1133,7 +1133,7 @@ brains.get('/schedules', function(context) {
|
|
|
1133
1133
|
// Get scheduled run history - MUST be before :scheduleId route
|
|
1134
1134
|
brains.get('/schedules/runs', function(context) {
|
|
1135
1135
|
return _async_to_generator(function() {
|
|
1136
|
-
var scheduleIdParam, limit, scheduleDoId, scheduleStub,
|
|
1136
|
+
var scheduleIdParam, limit, scheduleDoId, scheduleStub, userName, result;
|
|
1137
1137
|
return _ts_generator(this, function(_state) {
|
|
1138
1138
|
switch(_state.label){
|
|
1139
1139
|
case 0:
|
|
@@ -1141,10 +1141,10 @@ brains.get('/schedules/runs', function(context) {
|
|
|
1141
1141
|
limit = Number(context.req.query('limit') || '100');
|
|
1142
1142
|
scheduleDoId = context.env.SCHEDULE_DO.idFromName('singleton');
|
|
1143
1143
|
scheduleStub = context.env.SCHEDULE_DO.get(scheduleDoId);
|
|
1144
|
-
|
|
1144
|
+
userName = scopeUserName(context);
|
|
1145
1145
|
return [
|
|
1146
1146
|
4,
|
|
1147
|
-
scheduleStub.getAllRuns(scheduleIdParam, limit,
|
|
1147
|
+
scheduleStub.getAllRuns(scheduleIdParam, limit, userName)
|
|
1148
1148
|
];
|
|
1149
1149
|
case 1:
|
|
1150
1150
|
result = _state.sent();
|
package/dist/src/api/index.js
CHANGED
|
@@ -153,7 +153,7 @@ app.get('/auth/setup', function(context) {
|
|
|
153
153
|
context.json({
|
|
154
154
|
backend: 'cloudflare',
|
|
155
155
|
rootKeyConfigured: rootKeyConfigured,
|
|
156
|
-
instructions: "To configure root authentication:\n1.
|
|
156
|
+
instructions: "To configure root authentication:\n1. Convert your SSH public key to JWK format\n2. In Cloudflare dashboard, go to Workers & Pages > Your project > Settings > Variables and Secrets\n3. Add a new secret named ROOT_PUBLIC_KEY with the JWK value"
|
|
157
157
|
})
|
|
158
158
|
];
|
|
159
159
|
});
|
|
@@ -205,6 +205,31 @@ app.use('*', function(c, next) {
|
|
|
205
205
|
});
|
|
206
206
|
})();
|
|
207
207
|
});
|
|
208
|
+
// Whoami endpoint (requires auth, handled by middleware above)
|
|
209
|
+
app.get('/auth/whoami', function(context) {
|
|
210
|
+
return _async_to_generator(function() {
|
|
211
|
+
var auth;
|
|
212
|
+
return _ts_generator(this, function(_state) {
|
|
213
|
+
auth = context.get('auth');
|
|
214
|
+
if (auth.isRoot) {
|
|
215
|
+
return [
|
|
216
|
+
2,
|
|
217
|
+
context.json({
|
|
218
|
+
name: 'root',
|
|
219
|
+
isRoot: true
|
|
220
|
+
})
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
return [
|
|
224
|
+
2,
|
|
225
|
+
context.json({
|
|
226
|
+
name: auth.userName,
|
|
227
|
+
isRoot: false
|
|
228
|
+
})
|
|
229
|
+
];
|
|
230
|
+
});
|
|
231
|
+
})();
|
|
232
|
+
});
|
|
208
233
|
// Mount route modules
|
|
209
234
|
app.route('/brains', brains);
|
|
210
235
|
app.route('/resources', resources);
|
package/dist/src/api/store.js
CHANGED
|
@@ -173,13 +173,13 @@ function _ts_generator(thisArg, body) {
|
|
|
173
173
|
import { Hono } from 'hono';
|
|
174
174
|
var store = new Hono();
|
|
175
175
|
/**
|
|
176
|
-
* Get the
|
|
176
|
+
* Get the userName for ownership filtering from the auth context.
|
|
177
177
|
* Root users get null (no filter — sees everything).
|
|
178
|
-
* Non-root users get their
|
|
179
|
-
*/ function
|
|
178
|
+
* Non-root users get their userName.
|
|
179
|
+
*/ function scopeUserName(context) {
|
|
180
180
|
var auth = context.get('auth');
|
|
181
|
-
var
|
|
182
|
-
return (auth === null || auth === void 0 ? void 0 : auth.isRoot) ? null : (
|
|
181
|
+
var _auth_userName;
|
|
182
|
+
return (auth === null || auth === void 0 ? void 0 : auth.isRoot) ? null : (_auth_userName = auth === null || auth === void 0 ? void 0 : auth.userName) !== null && _auth_userName !== void 0 ? _auth_userName : null;
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* Check if the authenticated user is root.
|
|
@@ -192,18 +192,18 @@ var store = new Hono();
|
|
|
192
192
|
*
|
|
193
193
|
* R2 key patterns:
|
|
194
194
|
* shared: store/{brainTitle}/{key}.json
|
|
195
|
-
* per-user: store/{brainTitle}/user/{
|
|
195
|
+
* per-user: store/{brainTitle}/user/{userName}/{key}.json
|
|
196
196
|
*/ function parseStoreKey(r2Key) {
|
|
197
197
|
// Remove "store/" prefix
|
|
198
198
|
var withoutPrefix = r2Key.slice('store/'.length);
|
|
199
|
-
// Check for per-user pattern: {brainTitle}/user/{
|
|
199
|
+
// Check for per-user pattern: {brainTitle}/user/{userName}/{key}.json
|
|
200
200
|
var userMatch = withoutPrefix.match(/^([^/]+)\/user\/([^/]+)\/(.+)\.json$/);
|
|
201
201
|
if (userMatch) {
|
|
202
202
|
return {
|
|
203
203
|
brainTitle: userMatch[1],
|
|
204
204
|
key: userMatch[3],
|
|
205
205
|
scope: 'user',
|
|
206
|
-
|
|
206
|
+
userName: userMatch[2]
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
// Check for shared pattern: {brainTitle}/{key}.json
|
|
@@ -278,12 +278,12 @@ store.get('/:brainTitle/shared/:key', function(context) {
|
|
|
278
278
|
// GET /store/:brainTitle/user/:key - Get per-user key value
|
|
279
279
|
store.get('/:brainTitle/user/:key', function(context) {
|
|
280
280
|
return _async_to_generator(function() {
|
|
281
|
-
var
|
|
281
|
+
var userName, bucket, brainTitle, key, targetUserName, r2Key, object, value, _;
|
|
282
282
|
return _ts_generator(this, function(_state) {
|
|
283
283
|
switch(_state.label){
|
|
284
284
|
case 0:
|
|
285
|
-
|
|
286
|
-
if (!
|
|
285
|
+
userName = scopeUserName(context);
|
|
286
|
+
if (!userName && !isRoot(context)) {
|
|
287
287
|
return [
|
|
288
288
|
2,
|
|
289
289
|
context.json({
|
|
@@ -296,8 +296,8 @@ store.get('/:brainTitle/user/:key', function(context) {
|
|
|
296
296
|
key = decodeURIComponent(context.req.param('key'));
|
|
297
297
|
// For root users, they could be looking at any user's key
|
|
298
298
|
// But for non-root, it's always their own
|
|
299
|
-
|
|
300
|
-
r2Key = "store/".concat(brainTitle, "/user/").concat(
|
|
299
|
+
targetUserName = userName;
|
|
300
|
+
r2Key = "store/".concat(brainTitle, "/user/").concat(targetUserName, "/").concat(key, ".json");
|
|
301
301
|
return [
|
|
302
302
|
4,
|
|
303
303
|
bucket.get(r2Key)
|
|
@@ -327,7 +327,7 @@ store.get('/:brainTitle/user/:key', function(context) {
|
|
|
327
327
|
key: key,
|
|
328
328
|
value: value,
|
|
329
329
|
scope: 'user',
|
|
330
|
-
|
|
330
|
+
userName: targetUserName
|
|
331
331
|
})
|
|
332
332
|
];
|
|
333
333
|
}
|
|
@@ -372,12 +372,12 @@ store.delete('/:brainTitle/shared/:key', function(context) {
|
|
|
372
372
|
// DELETE /store/:brainTitle/user/:key - Delete per-user key
|
|
373
373
|
store.delete('/:brainTitle/user/:key', function(context) {
|
|
374
374
|
return _async_to_generator(function() {
|
|
375
|
-
var
|
|
375
|
+
var userName, bucket, brainTitle, key, targetUserName, r2Key;
|
|
376
376
|
return _ts_generator(this, function(_state) {
|
|
377
377
|
switch(_state.label){
|
|
378
378
|
case 0:
|
|
379
|
-
|
|
380
|
-
if (!
|
|
379
|
+
userName = scopeUserName(context);
|
|
380
|
+
if (!userName && !isRoot(context)) {
|
|
381
381
|
return [
|
|
382
382
|
2,
|
|
383
383
|
context.json({
|
|
@@ -388,8 +388,8 @@ store.delete('/:brainTitle/user/:key', function(context) {
|
|
|
388
388
|
bucket = context.env.RESOURCES_BUCKET;
|
|
389
389
|
brainTitle = decodeURIComponent(context.req.param('brainTitle'));
|
|
390
390
|
key = decodeURIComponent(context.req.param('key'));
|
|
391
|
-
|
|
392
|
-
r2Key = "store/".concat(brainTitle, "/user/").concat(
|
|
391
|
+
targetUserName = userName;
|
|
392
|
+
r2Key = "store/".concat(brainTitle, "/user/").concat(targetUserName, "/").concat(key, ".json");
|
|
393
393
|
return [
|
|
394
394
|
4,
|
|
395
395
|
bucket.delete(r2Key)
|
|
@@ -409,13 +409,13 @@ store.delete('/:brainTitle/user/:key', function(context) {
|
|
|
409
409
|
// GET /store/:brainTitle - List keys for a brain
|
|
410
410
|
store.get('/:brainTitle', function(context) {
|
|
411
411
|
return _async_to_generator(function() {
|
|
412
|
-
var bucket, brainTitle,
|
|
412
|
+
var bucket, brainTitle, userName, rootUser, prefix, keys, cursor, listed, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, object, parsed;
|
|
413
413
|
return _ts_generator(this, function(_state) {
|
|
414
414
|
switch(_state.label){
|
|
415
415
|
case 0:
|
|
416
416
|
bucket = context.env.RESOURCES_BUCKET;
|
|
417
417
|
brainTitle = decodeURIComponent(context.req.param('brainTitle'));
|
|
418
|
-
|
|
418
|
+
userName = scopeUserName(context);
|
|
419
419
|
rootUser = isRoot(context);
|
|
420
420
|
prefix = "store/".concat(brainTitle, "/");
|
|
421
421
|
keys = [];
|
|
@@ -439,13 +439,13 @@ store.get('/:brainTitle', function(context) {
|
|
|
439
439
|
// Access control: non-root only sees their own per-user keys
|
|
440
440
|
if (!rootUser) {
|
|
441
441
|
if (parsed.scope === 'shared') continue;
|
|
442
|
-
if (parsed.scope === 'user' && parsed.
|
|
442
|
+
if (parsed.scope === 'user' && parsed.userName !== userName) continue;
|
|
443
443
|
}
|
|
444
444
|
keys.push(_object_spread_props(_object_spread({
|
|
445
445
|
key: parsed.key,
|
|
446
446
|
scope: parsed.scope
|
|
447
|
-
}, parsed.
|
|
448
|
-
|
|
447
|
+
}, parsed.userName && {
|
|
448
|
+
userName: parsed.userName
|
|
449
449
|
}), {
|
|
450
450
|
size: object.size,
|
|
451
451
|
lastModified: object.uploaded.toISOString()
|
|
@@ -488,13 +488,13 @@ store.get('/:brainTitle', function(context) {
|
|
|
488
488
|
// DELETE /store/:brainTitle - Clear all accessible keys for a brain
|
|
489
489
|
store.delete('/:brainTitle', function(context) {
|
|
490
490
|
return _async_to_generator(function() {
|
|
491
|
-
var bucket, brainTitle,
|
|
491
|
+
var bucket, brainTitle, userName, rootUser, prefix, deleted, cursor, listed, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, object, parsed, err;
|
|
492
492
|
return _ts_generator(this, function(_state) {
|
|
493
493
|
switch(_state.label){
|
|
494
494
|
case 0:
|
|
495
495
|
bucket = context.env.RESOURCES_BUCKET;
|
|
496
496
|
brainTitle = decodeURIComponent(context.req.param('brainTitle'));
|
|
497
|
-
|
|
497
|
+
userName = scopeUserName(context);
|
|
498
498
|
rootUser = isRoot(context);
|
|
499
499
|
prefix = "store/".concat(brainTitle, "/");
|
|
500
500
|
deleted = 0;
|
|
@@ -537,7 +537,7 @@ store.delete('/:brainTitle', function(context) {
|
|
|
537
537
|
3,
|
|
538
538
|
6
|
|
539
539
|
];
|
|
540
|
-
if (parsed.scope === 'user' && parsed.
|
|
540
|
+
if (parsed.scope === 'user' && parsed.userName !== userName) return [
|
|
541
541
|
3,
|
|
542
542
|
6
|
|
543
543
|
];
|
|
@@ -605,12 +605,12 @@ store.delete('/:brainTitle', function(context) {
|
|
|
605
605
|
// GET /store - List brains with store data
|
|
606
606
|
store.get('/', function(context) {
|
|
607
607
|
return _async_to_generator(function() {
|
|
608
|
-
var bucket,
|
|
608
|
+
var bucket, userName, rootUser, brainTitles, listed, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, prefix, title, cursor, listed1, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, object, parsed, brains;
|
|
609
609
|
return _ts_generator(this, function(_state) {
|
|
610
610
|
switch(_state.label){
|
|
611
611
|
case 0:
|
|
612
612
|
bucket = context.env.RESOURCES_BUCKET;
|
|
613
|
-
|
|
613
|
+
userName = scopeUserName(context);
|
|
614
614
|
rootUser = isRoot(context);
|
|
615
615
|
brainTitles = new Set();
|
|
616
616
|
if (!rootUser) return [
|
|
@@ -670,7 +670,7 @@ store.get('/', function(context) {
|
|
|
670
670
|
object = _step1.value;
|
|
671
671
|
parsed = parseStoreKey(object.key);
|
|
672
672
|
if (!parsed) continue;
|
|
673
|
-
if (parsed.scope === 'user' && parsed.
|
|
673
|
+
if (parsed.scope === 'user' && parsed.userName === userName) {
|
|
674
674
|
brainTitles.add(parsed.brainTitle);
|
|
675
675
|
}
|
|
676
676
|
}
|