@synopackageland/sdk 0.10.2 → 0.10.3
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 +77 -5
- package/dist/i18n/background/zh-CN.json +6 -6
- package/dist/i18n/delegate/de.json +5 -3
- package/dist/i18n/delegate/en.json +5 -3
- package/dist/i18n/delegate/es.json +5 -3
- package/dist/i18n/delegate/fr.json +5 -3
- package/dist/i18n/delegate/it.json +5 -3
- package/dist/i18n/delegate/ja.json +5 -3
- package/dist/i18n/delegate/ko.json +5 -3
- package/dist/i18n/delegate/zh-CN.json +5 -3
- package/dist/i18n/delegate/zh-TW.json +5 -3
- package/dist/i18n/identity/zh-CN.json +5 -5
- package/dist/i18n/save/de.json +15 -17
- package/dist/i18n/save/en.json +15 -17
- package/dist/i18n/save/es.json +15 -17
- package/dist/i18n/save/fr.json +15 -17
- package/dist/i18n/save/it.json +15 -17
- package/dist/i18n/save/ja.json +15 -17
- package/dist/i18n/save/ko.json +15 -17
- package/dist/i18n/save/zh-CN.json +15 -17
- package/dist/i18n/save/zh-TW.json +15 -17
- package/dist/index.js +2355 -2348
- package/dist/native.js +350 -0
- package/dist/src/delegate/BackgroundSavePanel.vue.d.ts +3 -0
- package/dist/src/delegate/BackgroundSaveSettings.vue.d.ts +29 -0
- package/dist/src/delegate/ExecutorSettings.vue.d.ts +1 -2
- package/dist/src/delegate/copy.d.ts +10 -6
- package/dist/src/delegate/executor-setup.d.ts +2 -0
- package/dist/src/delegate/save-copy.d.ts +30 -36
- package/dist/src/delegate/use-executor-setup.d.ts +5 -1
- package/dist/src/delegate/use-scope-approval.d.ts +50 -0
- package/dist/src/dsm/file-station.d.ts +1 -1
- package/dist/src/native/authorization-runtime.d.ts +2 -0
- package/dist/src/native/dsm-version.d.ts +6 -0
- package/dist/src/native/root-runtime.d.ts +34 -0
- package/dist/src/native.d.ts +2 -0
- package/dist/src/protocol/v1.d.ts +7 -1
- package/dist/src/shell/PageActions.vue.d.ts +13 -0
- package/dist/src/shell/app-pages.d.ts +2 -0
- package/dist/src/shell/page-actions.d.ts +3 -0
- package/dist/src/vue.d.ts +2 -0
- package/dist/style.css +1 -1
- package/dist/vue.js +1998 -1735
- package/package.json +7 -3
- package/spec/protocol/v1/README.md +86 -5
- package/spec/protocol/v1/errors.json +8 -0
- package/spec/protocol/v1/timeouts.json +21 -0
package/dist/native.js
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
function t(e) {
|
|
2
|
+
return ["103", "104", "dsm_103", "dsm_104"].indexOf(String(e)) >= 0;
|
|
3
|
+
}
|
|
4
|
+
const r = `function createRootAccess(options) {
|
|
5
|
+
var API = "SYNO.Core.TaskScheduler";
|
|
6
|
+
var POLL_MS = 500, MAX_POLL_MS = 1000, RUN_LIMIT_MS = 10 * 60 * 1000;
|
|
7
|
+
// The task an authorize just read back as exactly ours, for the run that follows.
|
|
8
|
+
var byOp = {}, running = {}, verified = {};
|
|
9
|
+
// spec/scheduler/v1: the id each task name was last listed with.
|
|
10
|
+
var listed = {};
|
|
11
|
+
var legacy = null, probe = null;
|
|
12
|
+
var versionUnsupported = ${t.toString()};
|
|
13
|
+
options.tasks.forEach(function (task) { byOp[task.op] = task; });
|
|
14
|
+
|
|
15
|
+
function now() { return options.now ? options.now() : Date.now(); }
|
|
16
|
+
function report(task, state, started) {
|
|
17
|
+
if (typeof options.progress !== "function") return;
|
|
18
|
+
try { options.progress({ op: task.op, state: state, elapsedMs: now() - started }); } catch (error) {}
|
|
19
|
+
}
|
|
20
|
+
function pause(interval, deadline) {
|
|
21
|
+
return options.wait(Math.max(0, Math.min(interval, deadline - now())));
|
|
22
|
+
}
|
|
23
|
+
function fail(code) {
|
|
24
|
+
var error = new Error(code);
|
|
25
|
+
error.code = code;
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
function begin(op) {
|
|
29
|
+
if (!Object.prototype.hasOwnProperty.call(byOp, op)) return Promise.reject(fail("root_unknown_op"));
|
|
30
|
+
if (options.user().admin !== true) return Promise.reject(fail("admin_required"));
|
|
31
|
+
return Promise.resolve(byOp[op]);
|
|
32
|
+
}
|
|
33
|
+
function readOutput(task) {
|
|
34
|
+
return task.output ? options.call("root.output", { op: task.op }) : Promise.resolve(null);
|
|
35
|
+
}
|
|
36
|
+
function listTasks() {
|
|
37
|
+
if (legacy === false) return options.send(API, "list", 3, { start: 0, limit: 500 });
|
|
38
|
+
if (legacy === true) return legacyList();
|
|
39
|
+
if (!probe) {
|
|
40
|
+
probe = options.send(API, "list", 3, { start: 0, limit: 500 }).then(function (data) {
|
|
41
|
+
legacy = false;
|
|
42
|
+
return data;
|
|
43
|
+
}, function (error) {
|
|
44
|
+
if (!error || !versionUnsupported(error.code)) {
|
|
45
|
+
probe = null;
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
legacy = true;
|
|
49
|
+
return legacyList();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return probe;
|
|
53
|
+
}
|
|
54
|
+
function legacyList() {
|
|
55
|
+
return options.send(API, "list", 2, { offset: 0, limit: 500 }).then(function (data) {
|
|
56
|
+
// Refuse a truncated snapshot: a same-named task could lie outside it.
|
|
57
|
+
if (!data || !Array.isArray(data.tasks) || data.tasks.length > 500
|
|
58
|
+
|| !(typeof data.total === "number" && isFinite(data.total) && Math.floor(data.total) === data.total) || data.total !== data.tasks.length) throw fail("root_bad_response");
|
|
59
|
+
return data;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function readTask(ref) {
|
|
63
|
+
return options.send(API, "get", legacy ? 3 : 4, ref);
|
|
64
|
+
}
|
|
65
|
+
function createTask(params) {
|
|
66
|
+
return options.send(legacy ? API : API + ".Root", "create", legacy ? 3 : 4, params);
|
|
67
|
+
}
|
|
68
|
+
function deleteTask(ref) {
|
|
69
|
+
return options.send(API, "delete", 2, { tasks: [ref] });
|
|
70
|
+
}
|
|
71
|
+
function runTask(ref) {
|
|
72
|
+
return options.send(API, "run", 2, { tasks: [ref] });
|
|
73
|
+
}
|
|
74
|
+
// spec/scheduler/v1: Task Scheduler names repeat, so a list finds the id and
|
|
75
|
+
// refuses a duplicate; get judges the task. cached: a step that deletes
|
|
76
|
+
// nothing may get the id an earlier list showed, and lists again when that
|
|
77
|
+
// get answers 4801 or another task.
|
|
78
|
+
function locate(task, cached) {
|
|
79
|
+
if (cached && listed[task.name] !== undefined) return Promise.resolve({ id: listed[task.name], real_owner: "root", cached: true });
|
|
80
|
+
return listTasks().then(function (data) {
|
|
81
|
+
if (!data || !Array.isArray(data.tasks)) throw fail("root_bad_response");
|
|
82
|
+
var named = data.tasks.filter(function (summary) { return summary && summary.name === task.name; });
|
|
83
|
+
delete listed[task.name];
|
|
84
|
+
if (named.length === 0) return null;
|
|
85
|
+
if (named.length > 1) return { duplicate: true };
|
|
86
|
+
listed[task.name] = named[0].id;
|
|
87
|
+
return { id: named[0].id, real_owner: named[0].real_owner };
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function find(task, cached) {
|
|
91
|
+
return locate(task, cached).then(function (located) {
|
|
92
|
+
if (!located) return { state: "missing" };
|
|
93
|
+
if (located.duplicate) return { state: "conflict" };
|
|
94
|
+
var ref = { id: located.id, real_owner: located.real_owner };
|
|
95
|
+
return readTask(ref).then(function (detail) {
|
|
96
|
+
if (located.cached && (!detail || String(detail.id) !== String(ref.id) || detail.name !== task.name)) return { relist: true };
|
|
97
|
+
var script = detail && detail.extra && detail.extra.script;
|
|
98
|
+
if (!detail || String(detail.id) !== String(ref.id) || detail.name !== task.name
|
|
99
|
+
|| detail.owner !== "root" || detail.real_owner !== "root" || detail.enable !== false || detail.type !== "script" || typeof script !== "string") {
|
|
100
|
+
return { state: "conflict" };
|
|
101
|
+
}
|
|
102
|
+
if (script === task.script) return { state: "ready", ref: ref };
|
|
103
|
+
if (script.indexOf(task.header) === 0) return { state: "outdated", ref: ref };
|
|
104
|
+
return { state: "conflict" };
|
|
105
|
+
}, function (error) {
|
|
106
|
+
if (!located.cached || ["4801", "dsm_4801"].indexOf(String(error && error.code)) < 0) throw error;
|
|
107
|
+
return { relist: true };
|
|
108
|
+
}).then(function (found) {
|
|
109
|
+
if (!found.relist) return found;
|
|
110
|
+
delete listed[task.name];
|
|
111
|
+
return find(task, false);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function definition(task, user) {
|
|
116
|
+
var hours = [];
|
|
117
|
+
for (var h = 1; h <= 23; h++) hours.push(h);
|
|
118
|
+
return {
|
|
119
|
+
name: task.name,
|
|
120
|
+
real_owner: user,
|
|
121
|
+
owner: "root",
|
|
122
|
+
enable: false,
|
|
123
|
+
type: "script",
|
|
124
|
+
schedule: {
|
|
125
|
+
date_type: 0, week_day: "0,1,2,3,4,5,6", repeat_date: 1001, monthly_week: [], hour: 0, minute: 0,
|
|
126
|
+
repeat_hour: 0, repeat_min: 0, last_work_hour: 0,
|
|
127
|
+
repeat_min_store_config: [1, 5, 10, 15, 20, 30], repeat_hour_store_config: hours
|
|
128
|
+
},
|
|
129
|
+
extra: { notify_enable: false, script: task.script, notify_mail: "", notify_if_error: false }
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function newest(history) {
|
|
133
|
+
if (!Array.isArray(history)) throw fail("root_bad_response");
|
|
134
|
+
return history.reduce(function (latest, entry) {
|
|
135
|
+
return entry && (!latest || Number(entry.timestamp) > Number(latest.timestamp)) ? entry : latest;
|
|
136
|
+
}, null);
|
|
137
|
+
}
|
|
138
|
+
function history(ref) {
|
|
139
|
+
return options.send(API, "get_history_status_list", 1, { id: ref.id }).then(newest);
|
|
140
|
+
}
|
|
141
|
+
function waitForRun(task, ref, before, started, deadline, interval) {
|
|
142
|
+
return history(ref).then(function (latest) {
|
|
143
|
+
var fresh = latest && (!before || latest.timestamp !== before.timestamp);
|
|
144
|
+
if (fresh && latest.exit_type !== "running" && latest.stop_time) {
|
|
145
|
+
if (latest.exit_code !== 0) throw fail("root_task_failed");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
report(task, fresh ? "running" : "queued", started);
|
|
149
|
+
if (now() >= deadline) throw fail("root_timeout");
|
|
150
|
+
return pause(interval, deadline).then(function () {
|
|
151
|
+
return waitForRun(task, ref, before, started, deadline, Math.min(interval * 2, MAX_POLL_MS));
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function validTime(value) {
|
|
157
|
+
if (typeof value !== "string" || !/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/.test(value)) return false;
|
|
158
|
+
var normalized = value.replace(" ", "T") + "Z";
|
|
159
|
+
var date = new Date(normalized);
|
|
160
|
+
return !isNaN(date.getTime()) && date.toISOString().slice(0, 19) === normalized.slice(0, 19);
|
|
161
|
+
}
|
|
162
|
+
function bounded(call, deadline) {
|
|
163
|
+
// A poll count alone cannot bound a stalled DSM callback. Discard late replies.
|
|
164
|
+
return new Promise(function (resolve, reject) {
|
|
165
|
+
var remaining = deadline - now();
|
|
166
|
+
if (remaining <= 0) { reject(fail("root_timeout")); return; }
|
|
167
|
+
var timer = setTimeout(function () { reject(fail("root_timeout")); }, remaining);
|
|
168
|
+
Promise.resolve().then(call).then(function (value) {
|
|
169
|
+
clearTimeout(timer);
|
|
170
|
+
if (now() >= deadline) reject(fail("root_timeout"));
|
|
171
|
+
else resolve(value);
|
|
172
|
+
}, function (error) { clearTimeout(timer); reject(error); });
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function legacyHistory(ref, deadline) {
|
|
176
|
+
return bounded(function () { return options.send(API, "view", 1, { id: ref.id }); }, deadline).then(function (records) {
|
|
177
|
+
// DSM 7.1 omits data entirely when a task has never run.
|
|
178
|
+
if (records === undefined) records = [];
|
|
179
|
+
if (!Array.isArray(records) || records.length > 500) throw fail("root_bad_response");
|
|
180
|
+
var seen = {};
|
|
181
|
+
records.forEach(function (record) {
|
|
182
|
+
if (!record || !validTime(record.start_time) || typeof record.stop_time !== "string"
|
|
183
|
+
|| (record.stop_time && (!validTime(record.stop_time) || record.stop_time < record.start_time))
|
|
184
|
+
|| typeof record.exit_type !== "string" || !(typeof record.exit_code === "number" && isFinite(record.exit_code) && Math.floor(record.exit_code) === record.exit_code)
|
|
185
|
+
|| seen[record.start_time]) throw fail("root_bad_response");
|
|
186
|
+
seen[record.start_time] = true;
|
|
187
|
+
});
|
|
188
|
+
return records;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function waitForLegacyRun(task, ref, before, started, deadline, interval) {
|
|
192
|
+
return legacyHistory(ref, deadline).then(function (records) {
|
|
193
|
+
var previous = before.map(function (record) { return record.start_time; });
|
|
194
|
+
var newestBefore = previous.slice().sort().pop();
|
|
195
|
+
var fresh = records.filter(function (record) { return previous.indexOf(record.start_time) === -1; });
|
|
196
|
+
if (fresh.length > 1) throw fail("root_bad_response");
|
|
197
|
+
var latest = fresh[0];
|
|
198
|
+
if (latest && (!newestBefore || latest.start_time > newestBefore) && latest.stop_time) {
|
|
199
|
+
if (latest.exit_code !== 0 || latest.exit_type !== "normal") throw fail("root_task_failed");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
report(task, latest ? "running" : "queued", started);
|
|
203
|
+
if (now() >= deadline) throw fail("root_timeout");
|
|
204
|
+
return pause(interval, deadline).then(function () {
|
|
205
|
+
return waitForLegacyRun(task, ref, before, started, deadline, Math.min(interval * 2, MAX_POLL_MS));
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function execute(task, verified) {
|
|
210
|
+
var started = now(), deadline = started + RUN_LIMIT_MS;
|
|
211
|
+
if (!legacy) {
|
|
212
|
+
return history(verified.ref).then(function (before) {
|
|
213
|
+
return runTask(verified.ref).then(function () { return waitForRun(task, verified.ref, before, started, deadline, POLL_MS); });
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return legacyHistory(verified.ref, deadline).then(function (before) {
|
|
217
|
+
if (before.some(function (record) { return !record.stop_time || record.exit_type === "running"; })) throw fail("root_not_ready");
|
|
218
|
+
// Mutating calls are sent exactly once, never retried with another profile.
|
|
219
|
+
return bounded(function () { return runTask(verified.ref); }, deadline).then(function () {
|
|
220
|
+
return waitForLegacyRun(task, verified.ref, before, started, deadline, POLL_MS);
|
|
221
|
+
});
|
|
222
|
+
}).then(function () {
|
|
223
|
+
return bounded(function () { return find(task, true); }, deadline).then(function (after) {
|
|
224
|
+
if (after.state !== "ready" || String(after.ref.id) !== String(verified.ref.id)) throw fail("root_verify_failed");
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
function verify(op) {
|
|
229
|
+
var ref = verified[op];
|
|
230
|
+
delete verified[op];
|
|
231
|
+
return ref && op !== "helper_repair" ? Promise.resolve({ state: "ready", ref: ref }) : find(byOp[op], true);
|
|
232
|
+
}
|
|
233
|
+
function performRun(op) {
|
|
234
|
+
return begin(op).then(function (task) {
|
|
235
|
+
return verify(op).then(function (found) {
|
|
236
|
+
if (found.state !== "ready") throw fail("root_not_ready");
|
|
237
|
+
var consent = op === "helper_repair" ? options.confirmPassword() : Promise.resolve({ confirmed: true });
|
|
238
|
+
return consent.then(function (confirmation) {
|
|
239
|
+
if (!confirmation || confirmation.confirmed !== true) throw fail("root_cancelled");
|
|
240
|
+
return op === "helper_repair" ? begin(op).then(function (task) { return find(task, true); }) : found;
|
|
241
|
+
}).then(function (verified) {
|
|
242
|
+
if (verified.state !== "ready") throw fail("root_not_ready");
|
|
243
|
+
return execute(task, verified);
|
|
244
|
+
});
|
|
245
|
+
}).then(function () { return readOutput(task); });
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
state: function (op) {
|
|
251
|
+
return begin(op).then(function (task) { return find(task, true); }).then(function (found) { return found.state; });
|
|
252
|
+
},
|
|
253
|
+
authorize: function (op) {
|
|
254
|
+
delete verified[op];
|
|
255
|
+
return begin(op).then(function (task) {
|
|
256
|
+
return find(task).then(function (found) {
|
|
257
|
+
if (found.state === "ready") { verified[op] = found.ref; return "ready"; }
|
|
258
|
+
if (found.state === "conflict") throw fail("root_conflict");
|
|
259
|
+
return options.confirmPassword().then(function (confirmation) {
|
|
260
|
+
if (!confirmation || confirmation.confirmed !== true) return "cancelled";
|
|
261
|
+
if (!legacy && (typeof confirmation.token !== "string" || !confirmation.token)) throw fail("root_verify_failed");
|
|
262
|
+
var params = definition(task, options.user().name);
|
|
263
|
+
if (!legacy) params.SynoConfirmPWToken = confirmation.token;
|
|
264
|
+
// Re-read after the legacy client-side dialog before replacing a task.
|
|
265
|
+
var checked = legacy ? begin(op).then(find) : Promise.resolve(found);
|
|
266
|
+
return checked.then(function (current) {
|
|
267
|
+
if (current.state === "conflict") throw fail("root_conflict");
|
|
268
|
+
if (current.state === "ready") return;
|
|
269
|
+
var replaced = current.state === "outdated" ? deleteTask(current.ref) : Promise.resolve();
|
|
270
|
+
return replaced.then(function () { return createTask(params); });
|
|
271
|
+
}).then(function () {
|
|
272
|
+
return find(task);
|
|
273
|
+
}).then(function (after) {
|
|
274
|
+
if (after.state !== "ready") throw fail("root_verify_failed");
|
|
275
|
+
verified[op] = after.ref;
|
|
276
|
+
return "ready";
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
run: function (op) {
|
|
283
|
+
if (!Object.prototype.hasOwnProperty.call(byOp, op)) return Promise.reject(fail("root_unknown_op"));
|
|
284
|
+
if (options.user().admin !== true) return Promise.reject(fail("admin_required"));
|
|
285
|
+
if (running[op]) return running[op];
|
|
286
|
+
var pending = performRun(op).then(function (value) {
|
|
287
|
+
delete running[op];
|
|
288
|
+
return value;
|
|
289
|
+
}, function (error) { delete running[op]; throw error; });
|
|
290
|
+
running[op] = pending;
|
|
291
|
+
return pending;
|
|
292
|
+
},
|
|
293
|
+
remove: function (op) {
|
|
294
|
+
delete verified[op];
|
|
295
|
+
return begin(op).then(function (task) {
|
|
296
|
+
return find(task).then(function (found) {
|
|
297
|
+
if (found.state === "missing") return "missing";
|
|
298
|
+
if (found.state === "conflict") throw fail("root_conflict");
|
|
299
|
+
return deleteTask(found.ref).then(function () {
|
|
300
|
+
return find(task);
|
|
301
|
+
}).then(function (after) {
|
|
302
|
+
if (after.state !== "missing") throw fail("root_verify_failed");
|
|
303
|
+
return "missing";
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
output: function (op) {
|
|
309
|
+
return begin(op).then(readOutput);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}`, n = `function createAuthorizationAccess(options) {
|
|
313
|
+
var busy = null;
|
|
314
|
+
function fail(code) { var error = new Error(code); error.code = code; return error; }
|
|
315
|
+
function status() { return options.call("authorization.status").then(function (d) {
|
|
316
|
+
if (!d || d.command !== "authorization" || d.schema_version !== 1 || ["ready","authorization_required","not_admin","session_expired","unavailable"].indexOf(d.state) < 0) throw fail("authorization_bad_response");
|
|
317
|
+
// upgrade_reapproval is a reason-only tombstone: it can only explain a pending request.
|
|
318
|
+
if (d.reason === "upgrade_reapproval" && d.state !== "authorization_required") throw fail("authorization_bad_response");
|
|
319
|
+
return d;
|
|
320
|
+
}); }
|
|
321
|
+
function plan(method) { return options.call(method).then(function (p) {
|
|
322
|
+
if (!p || p.command !== "authorization" || p.schema_version !== 1 || p.phase !== "plan" || !Array.isArray(p.operations) || p.operations.length === 0 || p.operations.length > options.tasks.length) throw fail("authorization_bad_response");
|
|
323
|
+
var seen = {};
|
|
324
|
+
p.operations.forEach(function (op) { if (seen[op] || !options.tasks.some(function (t) { return t.op === op; })) throw fail("authorization_bad_response"); seen[op] = true; });
|
|
325
|
+
return p;
|
|
326
|
+
}); }
|
|
327
|
+
// The backend's grant decides: a task still waiting at the window's limit, or
|
|
328
|
+
// one signalled after it wrote the grant, has still authorized the package.
|
|
329
|
+
function settled(e) {
|
|
330
|
+
if (!e || (e.code !== "root_timeout" && e.code !== "root_task_failed")) throw e;
|
|
331
|
+
return status().then(function (d) { if (d.state !== "ready") throw e; });
|
|
332
|
+
}
|
|
333
|
+
function exclusive(fn) { if (busy) return busy; busy = Promise.resolve().then(fn).then(function (s) { busy = null; return s; },function (e) { busy = null; throw e; });return busy; }
|
|
334
|
+
function authorize(ops,run) { return ops.reduce(function (previous,op) { return previous.then(function () {
|
|
335
|
+
return options.root.authorize(op).then(function (state) { if (state !== "ready") throw fail("root_cancelled"); return run ? options.root.run(op).catch(settled) : null; });
|
|
336
|
+
}); },Promise.resolve()); }
|
|
337
|
+
return {canManage:function () {return !!options.user && options.user().admin === true;},status:status,request:function () { return exclusive(function () {
|
|
338
|
+
return plan("authorization.request").then(function (p) { return authorize(p.operations,p.run === true); }).then(status,function (e) { if (e.code === "root_cancelled") return status();throw e; });
|
|
339
|
+
}); },revoke:function () { return exclusive(function () {
|
|
340
|
+
return plan("authorization.revoke").then(function (p) {
|
|
341
|
+
if (p.withdraw === true && typeof options.withdraw !== "function") throw fail("authorization_bad_response");
|
|
342
|
+
var disabled = p.withdraw === true ? options.withdraw() : p.disable === true ? authorize(["helper_disable"],true) : Promise.resolve();
|
|
343
|
+
return disabled.then(function () { return p.purge === true ? authorize(["helper_purge"],true) : null; }).then(function () { return p.operations.reduce(function (previous,op) {return previous.then(function () {return options.root.remove(op);});},Promise.resolve()); });
|
|
344
|
+
}).then(status,function (e) { if (e.code === "root_cancelled") return status();throw e; });
|
|
345
|
+
}); }};
|
|
346
|
+
}`;
|
|
347
|
+
export {
|
|
348
|
+
n as AUTHORIZATION_RUNTIME,
|
|
349
|
+
r as ROOT_RUNTIME
|
|
350
|
+
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import type { Context } from '../context';
|
|
1
2
|
import type { BackgroundSaveFacade, DestinationGrant } from './long-running';
|
|
2
3
|
import type { NasProvider } from '../nas/contract';
|
|
3
4
|
type __VLS_Props = {
|
|
4
5
|
sdk: BackgroundSaveFacade;
|
|
5
6
|
admin: boolean;
|
|
6
7
|
locale: string;
|
|
8
|
+
title?: string;
|
|
7
9
|
picker?: {
|
|
8
10
|
provider: NasProvider;
|
|
9
11
|
keys: string[];
|
|
10
12
|
labels?: Record<string, string>;
|
|
11
13
|
};
|
|
14
|
+
ctx?: Pick<Context, 'call'>;
|
|
12
15
|
pickerErrorText?: (error: unknown) => string | undefined;
|
|
13
16
|
sampleSave?: boolean;
|
|
14
17
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Context } from '../context';
|
|
2
|
+
import type { BackgroundSaveFacade, DestinationGrant, DestinationState } from './long-running';
|
|
3
|
+
import type { NasProvider } from '../nas/contract';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
sdk: BackgroundSaveFacade;
|
|
6
|
+
admin: boolean;
|
|
7
|
+
locale: string;
|
|
8
|
+
picker?: {
|
|
9
|
+
provider: NasProvider;
|
|
10
|
+
keys: string[];
|
|
11
|
+
labels?: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
ctx?: Pick<Context, 'call'>;
|
|
14
|
+
title?: string;
|
|
15
|
+
pickerErrorText?: (error: unknown) => string | undefined;
|
|
16
|
+
};
|
|
17
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
18
|
+
refresh: () => Promise<void>;
|
|
19
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
+
confirmed: () => any;
|
|
21
|
+
authorized: (grant: DestinationGrant) => any;
|
|
22
|
+
destinations: (states: DestinationState[]) => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
24
|
+
onConfirmed?: (() => any) | undefined;
|
|
25
|
+
onAuthorized?: ((grant: DestinationGrant) => any) | undefined;
|
|
26
|
+
onDestinations?: ((states: DestinationState[]) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
@@ -4,9 +4,8 @@ type __VLS_Props = {
|
|
|
4
4
|
locale?: string;
|
|
5
5
|
ctx?: Pick<Context, 'call'>;
|
|
6
6
|
};
|
|
7
|
-
declare function refresh(): Promise<void>;
|
|
8
7
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
9
|
-
refresh:
|
|
8
|
+
refresh: () => Promise<void>;
|
|
10
9
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
10
|
confirmed: () => any;
|
|
12
11
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
@@ -36,6 +36,9 @@ export declare const delegateCatalogs: Record<import("..").UiLocale, {
|
|
|
36
36
|
pending: string;
|
|
37
37
|
error: string;
|
|
38
38
|
setupError: string;
|
|
39
|
+
passwordRejected: string;
|
|
40
|
+
passwordRequired: string;
|
|
41
|
+
passwordConfirmFailed: string;
|
|
39
42
|
confirmingHelp: string;
|
|
40
43
|
denied: string;
|
|
41
44
|
session: string;
|
|
@@ -52,8 +55,6 @@ export declare const delegateCatalogs: Record<import("..").UiLocale, {
|
|
|
52
55
|
preselection: string;
|
|
53
56
|
preselectionHelp: string;
|
|
54
57
|
scopeMismatch: string;
|
|
55
|
-
scopeChangeHelp: string;
|
|
56
|
-
confirmScope: string;
|
|
57
58
|
waiting_executor: string;
|
|
58
59
|
status: string;
|
|
59
60
|
statusReady: string;
|
|
@@ -61,8 +62,9 @@ export declare const delegateCatalogs: Record<import("..").UiLocale, {
|
|
|
61
62
|
statusScope: string;
|
|
62
63
|
statusBlocked: string;
|
|
63
64
|
statusConfirming: string;
|
|
65
|
+
statusUnreachable: string;
|
|
66
|
+
statusStarting: string;
|
|
64
67
|
hintPassword: string;
|
|
65
|
-
hintUnchanged: string;
|
|
66
68
|
retry: string;
|
|
67
69
|
}>;
|
|
68
70
|
export declare function delegateCopy(locale?: string): {
|
|
@@ -101,6 +103,9 @@ export declare function delegateCopy(locale?: string): {
|
|
|
101
103
|
pending: string;
|
|
102
104
|
error: string;
|
|
103
105
|
setupError: string;
|
|
106
|
+
passwordRejected: string;
|
|
107
|
+
passwordRequired: string;
|
|
108
|
+
passwordConfirmFailed: string;
|
|
104
109
|
confirmingHelp: string;
|
|
105
110
|
denied: string;
|
|
106
111
|
session: string;
|
|
@@ -117,8 +122,6 @@ export declare function delegateCopy(locale?: string): {
|
|
|
117
122
|
preselection: string;
|
|
118
123
|
preselectionHelp: string;
|
|
119
124
|
scopeMismatch: string;
|
|
120
|
-
scopeChangeHelp: string;
|
|
121
|
-
confirmScope: string;
|
|
122
125
|
waiting_executor: string;
|
|
123
126
|
status: string;
|
|
124
127
|
statusReady: string;
|
|
@@ -126,8 +129,9 @@ export declare function delegateCopy(locale?: string): {
|
|
|
126
129
|
statusScope: string;
|
|
127
130
|
statusBlocked: string;
|
|
128
131
|
statusConfirming: string;
|
|
132
|
+
statusUnreachable: string;
|
|
133
|
+
statusStarting: string;
|
|
129
134
|
hintPassword: string;
|
|
130
|
-
hintUnchanged: string;
|
|
131
135
|
retry: string;
|
|
132
136
|
};
|
|
133
137
|
export declare function errorCopy(error: unknown, copy: DelegateCopy): string;
|
|
@@ -2,9 +2,7 @@ export declare const saveCatalogs: Record<import("..").UiLocale, {
|
|
|
2
2
|
title: string;
|
|
3
3
|
help: string;
|
|
4
4
|
selection: string;
|
|
5
|
-
delegations: string;
|
|
6
5
|
operations: string;
|
|
7
|
-
empty: string;
|
|
8
6
|
noOperations: string;
|
|
9
7
|
revoke: string;
|
|
10
8
|
choose: string;
|
|
@@ -14,9 +12,6 @@ export declare const saveCatalogs: Record<import("..").UiLocale, {
|
|
|
14
12
|
enable: string;
|
|
15
13
|
disableHelp: string;
|
|
16
14
|
disabled: string;
|
|
17
|
-
enabled: string;
|
|
18
|
-
revoked: string;
|
|
19
|
-
untilRevoked: string;
|
|
20
15
|
queued: string;
|
|
21
16
|
copying: string;
|
|
22
17
|
committed: string;
|
|
@@ -26,7 +21,6 @@ export declare const saveCatalogs: Record<import("..").UiLocale, {
|
|
|
26
21
|
uncertain: string;
|
|
27
22
|
uncertainHelp: string;
|
|
28
23
|
interruptedHelp: string;
|
|
29
|
-
loading: string;
|
|
30
24
|
denied: string;
|
|
31
25
|
permission: string;
|
|
32
26
|
permissionSelect: string;
|
|
@@ -37,29 +31,31 @@ export declare const saveCatalogs: Record<import("..").UiLocale, {
|
|
|
37
31
|
conflict: string;
|
|
38
32
|
space: string;
|
|
39
33
|
error: string;
|
|
40
|
-
scope: string;
|
|
41
|
-
scopeNeeds: string;
|
|
42
|
-
scopeMismatch: string;
|
|
43
34
|
reselect: string;
|
|
44
35
|
example: string;
|
|
45
36
|
exampleHelp: string;
|
|
46
|
-
statusEnabled: string;
|
|
47
|
-
statusDisabled: string;
|
|
48
|
-
statusNeedsScope: string;
|
|
49
37
|
status: string;
|
|
50
38
|
file: string;
|
|
51
39
|
size: string;
|
|
52
40
|
location: string;
|
|
53
41
|
openFolder: string;
|
|
54
42
|
retry: string;
|
|
43
|
+
folder: string;
|
|
44
|
+
folderNone: string;
|
|
45
|
+
scopeRow: string;
|
|
46
|
+
change: string;
|
|
47
|
+
cancelChange: string;
|
|
48
|
+
changeHelp: string;
|
|
49
|
+
approveHelp: string;
|
|
50
|
+
approve: string;
|
|
51
|
+
confirmChange: string;
|
|
52
|
+
password: string;
|
|
55
53
|
}>;
|
|
56
54
|
export declare function saveCopy(locale?: string): {
|
|
57
55
|
title: string;
|
|
58
56
|
help: string;
|
|
59
57
|
selection: string;
|
|
60
|
-
delegations: string;
|
|
61
58
|
operations: string;
|
|
62
|
-
empty: string;
|
|
63
59
|
noOperations: string;
|
|
64
60
|
revoke: string;
|
|
65
61
|
choose: string;
|
|
@@ -69,9 +65,6 @@ export declare function saveCopy(locale?: string): {
|
|
|
69
65
|
enable: string;
|
|
70
66
|
disableHelp: string;
|
|
71
67
|
disabled: string;
|
|
72
|
-
enabled: string;
|
|
73
|
-
revoked: string;
|
|
74
|
-
untilRevoked: string;
|
|
75
68
|
queued: string;
|
|
76
69
|
copying: string;
|
|
77
70
|
committed: string;
|
|
@@ -81,7 +74,6 @@ export declare function saveCopy(locale?: string): {
|
|
|
81
74
|
uncertain: string;
|
|
82
75
|
uncertainHelp: string;
|
|
83
76
|
interruptedHelp: string;
|
|
84
|
-
loading: string;
|
|
85
77
|
denied: string;
|
|
86
78
|
permission: string;
|
|
87
79
|
permissionSelect: string;
|
|
@@ -92,29 +84,31 @@ export declare function saveCopy(locale?: string): {
|
|
|
92
84
|
conflict: string;
|
|
93
85
|
space: string;
|
|
94
86
|
error: string;
|
|
95
|
-
scope: string;
|
|
96
|
-
scopeNeeds: string;
|
|
97
|
-
scopeMismatch: string;
|
|
98
87
|
reselect: string;
|
|
99
88
|
example: string;
|
|
100
89
|
exampleHelp: string;
|
|
101
|
-
statusEnabled: string;
|
|
102
|
-
statusDisabled: string;
|
|
103
|
-
statusNeedsScope: string;
|
|
104
90
|
status: string;
|
|
105
91
|
file: string;
|
|
106
92
|
size: string;
|
|
107
93
|
location: string;
|
|
108
94
|
openFolder: string;
|
|
109
95
|
retry: string;
|
|
96
|
+
folder: string;
|
|
97
|
+
folderNone: string;
|
|
98
|
+
scopeRow: string;
|
|
99
|
+
change: string;
|
|
100
|
+
cancelChange: string;
|
|
101
|
+
changeHelp: string;
|
|
102
|
+
approveHelp: string;
|
|
103
|
+
approve: string;
|
|
104
|
+
confirmChange: string;
|
|
105
|
+
password: string;
|
|
110
106
|
};
|
|
111
107
|
export declare function saveError(error: unknown, copy?: {
|
|
112
108
|
title: string;
|
|
113
109
|
help: string;
|
|
114
110
|
selection: string;
|
|
115
|
-
delegations: string;
|
|
116
111
|
operations: string;
|
|
117
|
-
empty: string;
|
|
118
112
|
noOperations: string;
|
|
119
113
|
revoke: string;
|
|
120
114
|
choose: string;
|
|
@@ -124,9 +118,6 @@ export declare function saveError(error: unknown, copy?: {
|
|
|
124
118
|
enable: string;
|
|
125
119
|
disableHelp: string;
|
|
126
120
|
disabled: string;
|
|
127
|
-
enabled: string;
|
|
128
|
-
revoked: string;
|
|
129
|
-
untilRevoked: string;
|
|
130
121
|
queued: string;
|
|
131
122
|
copying: string;
|
|
132
123
|
committed: string;
|
|
@@ -136,7 +127,6 @@ export declare function saveError(error: unknown, copy?: {
|
|
|
136
127
|
uncertain: string;
|
|
137
128
|
uncertainHelp: string;
|
|
138
129
|
interruptedHelp: string;
|
|
139
|
-
loading: string;
|
|
140
130
|
denied: string;
|
|
141
131
|
permission: string;
|
|
142
132
|
permissionSelect: string;
|
|
@@ -147,19 +137,23 @@ export declare function saveError(error: unknown, copy?: {
|
|
|
147
137
|
conflict: string;
|
|
148
138
|
space: string;
|
|
149
139
|
error: string;
|
|
150
|
-
scope: string;
|
|
151
|
-
scopeNeeds: string;
|
|
152
|
-
scopeMismatch: string;
|
|
153
140
|
reselect: string;
|
|
154
141
|
example: string;
|
|
155
142
|
exampleHelp: string;
|
|
156
|
-
statusEnabled: string;
|
|
157
|
-
statusDisabled: string;
|
|
158
|
-
statusNeedsScope: string;
|
|
159
143
|
status: string;
|
|
160
144
|
file: string;
|
|
161
145
|
size: string;
|
|
162
146
|
location: string;
|
|
163
147
|
openFolder: string;
|
|
164
148
|
retry: string;
|
|
149
|
+
folder: string;
|
|
150
|
+
folderNone: string;
|
|
151
|
+
scopeRow: string;
|
|
152
|
+
change: string;
|
|
153
|
+
cancelChange: string;
|
|
154
|
+
changeHelp: string;
|
|
155
|
+
approveHelp: string;
|
|
156
|
+
approve: string;
|
|
157
|
+
confirmChange: string;
|
|
158
|
+
password: string;
|
|
165
159
|
}, situation?: 'save' | 'select'): string;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type InjectionKey } from 'vue';
|
|
2
|
-
import type { ExecutorSetup } from './executor-setup';
|
|
2
|
+
import type { CapabilityStatus, ExecutorSetup } from './executor-setup';
|
|
3
3
|
export declare const ExecutorSetupKey: InjectionKey<ExecutorSetup>;
|
|
4
4
|
export declare function useExecutorSetup(): ExecutorSetup;
|
|
5
|
+
export type ConfirmFailure = 'password_rejected' | 'password_required' | 'password_confirm_failed';
|
|
6
|
+
export declare function confirmFailure(status: CapabilityStatus): ConfirmFailure | undefined;
|
|
7
|
+
export declare function passwordRejected(status: CapabilityStatus): boolean;
|
|
8
|
+
export declare function statusUnreachable(reason?: string): boolean;
|