@synopackageland/sdk 0.48.0 → 0.49.1
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 +6 -0
- package/dist/index.js +245 -239
- package/dist/src/files/FileBrowser.vue.d.ts +2 -0
- package/dist/src/nas/listing-cache.d.ts +7 -0
- package/dist/style.css +1 -1
- package/dist/vue.js +1841 -1780
- package/executor-manifest.json +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -83,12 +83,12 @@ function ke(e) {
|
|
|
83
83
|
function i() {
|
|
84
84
|
var s = o();
|
|
85
85
|
return s ? Promise.resolve(s) : a || (a = new Promise(function(r) {
|
|
86
|
-
var
|
|
87
|
-
function
|
|
88
|
-
|
|
86
|
+
var l = new AbortController(), c = !1;
|
|
87
|
+
function p(d) {
|
|
88
|
+
c || (c = !0, clearTimeout(u), r(d));
|
|
89
89
|
}
|
|
90
90
|
var u = setTimeout(function() {
|
|
91
|
-
|
|
91
|
+
l.abort(), p(void 0);
|
|
92
92
|
}, 15e3);
|
|
93
93
|
try {
|
|
94
94
|
e.fetch("webman/login.cgi?enable_syno_token=yes", {
|
|
@@ -97,24 +97,24 @@ function ke(e) {
|
|
|
97
97
|
mode: "same-origin",
|
|
98
98
|
redirect: "error",
|
|
99
99
|
cache: "no-store",
|
|
100
|
-
signal:
|
|
101
|
-
}).then(function(
|
|
102
|
-
return
|
|
103
|
-
}).then(function(
|
|
104
|
-
if (!
|
|
105
|
-
var
|
|
106
|
-
if (
|
|
107
|
-
|
|
100
|
+
signal: l.signal
|
|
101
|
+
}).then(function(d) {
|
|
102
|
+
return d.ok ? d.json() : void 0;
|
|
103
|
+
}).then(function(d) {
|
|
104
|
+
if (!c) {
|
|
105
|
+
var h = n(e.read());
|
|
106
|
+
if (h) {
|
|
107
|
+
p(h);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
var
|
|
111
|
-
|
|
110
|
+
var m = d && d.success === !0 ? n(d.SynoToken) : void 0;
|
|
111
|
+
m && (e.write && e.write(m), t = m), p(m);
|
|
112
112
|
}
|
|
113
113
|
}).catch(function() {
|
|
114
|
-
|
|
114
|
+
p(void 0);
|
|
115
115
|
});
|
|
116
116
|
} catch {
|
|
117
|
-
|
|
117
|
+
p(void 0);
|
|
118
118
|
}
|
|
119
119
|
}), a);
|
|
120
120
|
}
|
|
@@ -152,7 +152,7 @@ async function De(e) {
|
|
|
152
152
|
function U(e) {
|
|
153
153
|
throw { code: { 106: "session_required", 107: "session_required", 119: "session_required", 105: "denied", 403: "denied", 407: "denied", 408: "denied", 414: "conflict", 1805: "conflict", 400: "invalid-request" }[String(e)] ?? "unavailable" };
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function D(e) {
|
|
156
156
|
if (typeof e != "string" || e.length < 2 || e.length > 4096 || !e.startsWith("/") || /[\u0000-\u001f\u007f\\,"]/.test(e) || e.split("/").slice(1).some((t) => !t || t === "." || t === "..")) throw { code: "invalid-request" };
|
|
157
157
|
}
|
|
158
158
|
function Y(e) {
|
|
@@ -170,129 +170,129 @@ function le(e = {}) {
|
|
|
170
170
|
if (!s) throw { code: "dsm_session_required" };
|
|
171
171
|
return s;
|
|
172
172
|
}
|
|
173
|
-
async function n(i, s, r,
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
176
|
-
let
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
173
|
+
async function n(i, s, r, l, c, p = !1, u) {
|
|
174
|
+
if (c.aborted) throw { code: "canceled" };
|
|
175
|
+
const d = new AbortController();
|
|
176
|
+
let h = !1, m = !1;
|
|
177
|
+
const g = () => d.abort();
|
|
178
|
+
c.addEventListener("abort", g, { once: !0 }), c.aborted && d.abort();
|
|
179
|
+
const f = setTimeout(() => {
|
|
180
|
+
m = !0, d.abort();
|
|
181
181
|
}, e.timeout ?? (u ? 1200 * 1e3 : L()));
|
|
182
|
-
let
|
|
182
|
+
let b = () => {
|
|
183
183
|
};
|
|
184
184
|
try {
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
185
|
+
const $ = async () => {
|
|
186
|
+
if (d.signal.aborted) throw { code: "canceled" };
|
|
187
187
|
if (e.webApi && !u) {
|
|
188
|
-
|
|
188
|
+
h = !0;
|
|
189
189
|
try {
|
|
190
|
-
return await e.webApi(i, s, r,
|
|
190
|
+
return await e.webApi(i, s, r, l);
|
|
191
191
|
} catch (q) {
|
|
192
192
|
const T = /^dsm_(\d+)$/.exec(String(q?.code));
|
|
193
193
|
throw T && U(T[1]), q;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
const N = await a(
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
199
|
-
for (const [q, T] of Object.entries({ api: i, method: s, version: String(r), ...
|
|
200
|
-
u &&
|
|
201
|
-
const K = await fetch(ce, { method: "POST", body:
|
|
196
|
+
const N = await a(d.signal);
|
|
197
|
+
if (d.signal.aborted) throw { code: "canceled" };
|
|
198
|
+
const C = u ? new FormData() : new URLSearchParams();
|
|
199
|
+
for (const [q, T] of Object.entries({ api: i, method: s, version: String(r), ...l, SynoToken: N })) C.append(q, T);
|
|
200
|
+
u && C.append("file", u), h = !0;
|
|
201
|
+
const K = await fetch(ce, { method: "POST", body: C, credentials: "same-origin", mode: "same-origin", redirect: "error", cache: "no-store", signal: d.signal, headers: { "X-SYNO-TOKEN": N } });
|
|
202
202
|
if (!K.ok) throw Error();
|
|
203
203
|
const M = await De(K);
|
|
204
204
|
if (M?.success === !1 && U(M.error?.code), M?.success !== !0) throw Error();
|
|
205
205
|
return M.data;
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
}),
|
|
209
|
-
if (
|
|
210
|
-
return
|
|
211
|
-
} catch (
|
|
212
|
-
const
|
|
213
|
-
throw typeof
|
|
206
|
+
}, v = new Promise((N, C) => {
|
|
207
|
+
b = () => C({ code: m ? "timeout" : "canceled" }), d.signal.addEventListener("abort", b, { once: !0 }), d.signal.aborted && b();
|
|
208
|
+
}), w = await Promise.race([$(), v]);
|
|
209
|
+
if (w?.error || Array.isArray(w?.errors) && w.errors.length) throw { code: "denied" };
|
|
210
|
+
return w;
|
|
211
|
+
} catch ($) {
|
|
212
|
+
const v = $?.code;
|
|
213
|
+
throw typeof v == "number" && [106, 107, 119, 105, 403, 407, 408, 414, 1805, 400].includes(v) && U(v), typeof v == "string" && ["canceled", "timeout"].includes(v) ? { code: p && h ? "commit-uncertain" : v } : typeof v == "string" && ["session_required", "dsm_session_required", "denied", "not_found", "conflict", "invalid-request", "unavailable", "commit-uncertain"].includes(v) ? { code: v } : { code: p && h ? "commit-uncertain" : m ? "timeout" : c.aborted ? "canceled" : "unavailable" };
|
|
214
214
|
} finally {
|
|
215
|
-
clearTimeout(
|
|
215
|
+
clearTimeout(f), c.removeEventListener("abort", g), d.signal.removeEventListener("abort", b);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
async function o(i, s, r,
|
|
219
|
-
i !== void 0 &&
|
|
220
|
-
const
|
|
221
|
-
if (!Number.isSafeInteger(s) || s < 0 || s > 1e6 || !Number.isSafeInteger(
|
|
222
|
-
const
|
|
223
|
-
if (!Array.isArray(
|
|
224
|
-
return
|
|
218
|
+
async function o(i, s, r, l) {
|
|
219
|
+
i !== void 0 && D(i);
|
|
220
|
+
const c = r.limit ?? 100, p = r.sortBy ?? "name", u = r.sortDirection ?? "ASC";
|
|
221
|
+
if (!Number.isSafeInteger(s) || s < 0 || s > 1e6 || !Number.isSafeInteger(c) || c < 1 || c > 100 || !["name", "size", "type", "mtime"].includes(p) || !["ASC", "DESC"].includes(u)) throw { code: "invalid-request" };
|
|
222
|
+
const d = await n("SYNO.FileStation.List", i === void 0 ? "list_share" : "list", 2, { offset: String(s), limit: String(c), sort_by: p, sort_direction: u, additional: '["size"]', ...i === void 0 ? {} : { folder_path: i } }, l), h = i === void 0 ? d?.shares ?? d?.files : d?.files;
|
|
223
|
+
if (!Array.isArray(h) || h.length > c || !Number.isSafeInteger(d.total) || d.total < 0 || d.offset !== s || s + h.length > d.total || !h.length && s < d.total) throw { code: "unavailable" };
|
|
224
|
+
return h.forEach(Z), d;
|
|
225
225
|
}
|
|
226
226
|
return {
|
|
227
227
|
token: a,
|
|
228
228
|
shares: (i, s) => o(void 0, i, {}, s),
|
|
229
229
|
list: (i, s, r) => o(i, s.offset ?? 0, s, r),
|
|
230
230
|
async info(i, s) {
|
|
231
|
-
|
|
231
|
+
D(i);
|
|
232
232
|
const r = await n("SYNO.FileStation.List", "getinfo", 2, { path: JSON.stringify([i]), additional: '["size"]' }, s);
|
|
233
233
|
if (!Array.isArray(r?.files) || r.files.length !== 1 || r.files[0]?.path !== i) throw { code: "not_found" };
|
|
234
234
|
return Z(r.files[0]);
|
|
235
235
|
},
|
|
236
236
|
async createFolder(i, s, r) {
|
|
237
|
-
return
|
|
237
|
+
return D(i), Y(s), await n("SYNO.FileStation.CreateFolder", "create", 2, { folder_path: JSON.stringify([i]), name: JSON.stringify([s]), force_parent: "false" }, r, !0), { created: !0 };
|
|
238
238
|
},
|
|
239
239
|
// Display/preview only. A successful browser result never authorizes a
|
|
240
240
|
// backend write or grant; the executor independently checks its subject.
|
|
241
241
|
async checkPermission(i, s) {
|
|
242
|
-
|
|
243
|
-
const r = Array.from(crypto.getRandomValues(new Uint8Array(16)), (
|
|
242
|
+
D(i);
|
|
243
|
+
const r = Array.from(crypto.getRandomValues(new Uint8Array(16)), (c) => c.toString(16).padStart(2, "0")).join("");
|
|
244
244
|
if ((await n("SYNO.FileStation.CheckPermission", "write", 3, { path: i, filename: `.synopkgland-permission-probe-${r}`, overwrite: "false", size: "0" }, s))?.blSkip !== !1) throw { code: "denied" };
|
|
245
245
|
},
|
|
246
246
|
async upload(i, s, r) {
|
|
247
|
-
if (
|
|
247
|
+
if (D(i), Y(s.name), !Number.isSafeInteger(s.size) || s.size < 0 || s.size > we) throw { code: "upload_size_required" };
|
|
248
248
|
await n("SYNO.FileStation.Upload", "upload", 2, { path: i, create_parents: "false", overwrite: "false", size: String(s.size) }, r, !0, s);
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
252
|
const Pe = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/, k = (e) => typeof e == "string" && Pe.test(e), O = (e) => e && k(e.delegation_id) && k(e.job_id), I = (e) => typeof e == "string" && e.startsWith("/") && e !== "/" && !e.includes("\0") && !e.slice(1).split("/").some((t) => !t || t === "." || t === "..");
|
|
253
|
-
function
|
|
253
|
+
function S() {
|
|
254
254
|
throw { code: "EXECUTOR_PROTOCOL" };
|
|
255
255
|
}
|
|
256
256
|
function Q(e) {
|
|
257
257
|
return e && Number.isSafeInteger(e.generation) && e.generation >= 0 && I(e.root) && (e.scope === "home" ? e.root === "/home" : e.scope.startsWith("shared:") && e.root === "/" + e.scope.slice(7));
|
|
258
258
|
}
|
|
259
259
|
function Me(e, t) {
|
|
260
|
-
return (!e || e.job_id !== t.job_id || !["queued", "copying", "committed", "canceled", "interrupted", "uncertain"].includes(e.state)) &&
|
|
260
|
+
return (!e || e.job_id !== t.job_id || !["queued", "copying", "committed", "canceled", "interrupted", "uncertain"].includes(e.state)) && S(), e.state === "committed" ? (!e.receipt || !I(e.receipt.path) || !Number.isSafeInteger(e.receipt.size) || e.receipt.size < 0 || e.receipt.size > 16 * 1024 ** 3) && S() : e.receipt !== void 0 && S(), e.reason !== void 0 && (typeof e.reason != "string" || !/^[A-Za-z][A-Za-z0-9_-]{0,127}$/.test(e.reason)) && S(), { job_id: e.job_id, state: e.state, ...e.receipt ? { receipt: { ...e.receipt } } : {}, ...e.code ? { code: e.code } : {}, ...e.reason ? { reason: e.reason } : {} };
|
|
261
261
|
}
|
|
262
262
|
function b6(e, t = async () => {
|
|
263
263
|
const a = await e.call("delegate.operations.list");
|
|
264
|
-
return Array.isArray(a?.operations) ||
|
|
264
|
+
return Array.isArray(a?.operations) || S(), a.operations;
|
|
265
265
|
}) {
|
|
266
|
-
const a = async (n, o) => (O(o) ||
|
|
266
|
+
const a = async (n, o) => (O(o) || S(), Me(await e.call(n, { delegation_id: o.delegation_id, job_id: o.job_id }), o));
|
|
267
267
|
return {
|
|
268
268
|
async destination(n) {
|
|
269
|
-
k(n) ||
|
|
269
|
+
k(n) || S();
|
|
270
270
|
const o = await e.call("delegate.destination", { key: n });
|
|
271
|
-
if ((!o || o.key !== n || !["active", "missing", "revoked", "reselection-required", "needs-scope-confirmation", "disabled"].includes(o.status) || o.selection !== null && !Q(o.selection)) &&
|
|
271
|
+
if ((!o || o.key !== n || !["active", "missing", "revoked", "reselection-required", "needs-scope-confirmation", "disabled"].includes(o.status) || o.selection !== null && !Q(o.selection)) && S(), o.status === "active") {
|
|
272
272
|
const i = o.destination, s = o.selection;
|
|
273
|
-
(!i || !s || !k(i.id) || i.key !== n || i.lifetime !== "until-revoked" || !i.username || !I(i.path) || !(i.path === s.root || i.path.startsWith(s.root + "/"))) &&
|
|
274
|
-
} else o.destination !== null &&
|
|
273
|
+
(!i || !s || !k(i.id) || i.key !== n || i.lifetime !== "until-revoked" || !i.username || !I(i.path) || !(i.path === s.root || i.path.startsWith(s.root + "/"))) && S();
|
|
274
|
+
} else o.destination !== null && S();
|
|
275
275
|
return o;
|
|
276
276
|
},
|
|
277
277
|
async exportExample(n) {
|
|
278
|
-
(!k(n.key) || !k(n.job_id)) &&
|
|
278
|
+
(!k(n.key) || !k(n.job_id)) && S();
|
|
279
279
|
const o = await e.call("delegate.example.export", { key: n.key, job_id: n.job_id });
|
|
280
|
-
return (!O(o) || o.job_id !== n.job_id) &&
|
|
280
|
+
return (!O(o) || o.job_id !== n.job_id) && S(), o;
|
|
281
281
|
},
|
|
282
282
|
selectDestination: (n) => e.call("delegate.select_destination", { key: n.key, path: n.path }),
|
|
283
283
|
async status() {
|
|
284
284
|
const n = await e.call("delegate.status");
|
|
285
285
|
if (!["ready", "disabled", "needs-scope-confirmation"].includes(n?.state)) throw { code: "EXECUTOR_UNAVAILABLE" };
|
|
286
|
-
return typeof n?.disabled != "boolean" &&
|
|
286
|
+
return typeof n?.disabled != "boolean" && S(), n.selection && !Q(n.selection) && S(), { disabled: n.disabled, ...n.scope_mode ? { scopeMode: n.scope_mode, selection: n.selection ?? null, preselection: n.preselection, mismatch: n.mismatch } : {} };
|
|
287
287
|
},
|
|
288
288
|
async list() {
|
|
289
289
|
const n = await e.call("delegate.list");
|
|
290
|
-
return Array.isArray(n?.delegations) ||
|
|
290
|
+
return Array.isArray(n?.delegations) || S(), n.delegations.filter((o) => o.lifetime === "until-revoked" && !o.revoked).map((o) => ((!k(o.delegation_id) || typeof o.destination != "string" || !o.destination || !I(o.path) || typeof o.subject?.username != "string" || !o.subject.username) && S(), { id: o.delegation_id, key: o.destination, path: o.path, username: o.subject.username, lifetime: "until-revoked" }));
|
|
291
291
|
},
|
|
292
292
|
async operations() {
|
|
293
293
|
const n = await t();
|
|
294
294
|
return Promise.all(n.map(async (o) => {
|
|
295
|
-
(typeof o?.name != "string" || !o.name || !O(o)) &&
|
|
295
|
+
(typeof o?.name != "string" || !o.name || !O(o)) && S();
|
|
296
296
|
const i = { delegation_id: o.delegation_id, job_id: o.job_id };
|
|
297
297
|
try {
|
|
298
298
|
return { ...i, name: o.name, ...await a("delegate.operations.get", i) };
|
|
@@ -303,14 +303,14 @@ function b6(e, t = async () => {
|
|
|
303
303
|
}));
|
|
304
304
|
},
|
|
305
305
|
async revoke(n) {
|
|
306
|
-
return (await e.call("delegate.revoke", { delegation_id: n.delegation_id }))?.revoked !== !0 &&
|
|
306
|
+
return (await e.call("delegate.revoke", { delegation_id: n.delegation_id }))?.revoked !== !0 && S(), { revoked: !0 };
|
|
307
307
|
},
|
|
308
308
|
cancel: (n) => a("delegate.operations.cancel", n),
|
|
309
309
|
async disable() {
|
|
310
|
-
return (await e.call("delegate.disable"))?.disabled !== !0 &&
|
|
310
|
+
return (await e.call("delegate.disable"))?.disabled !== !0 && S(), { disabled: !0 };
|
|
311
311
|
},
|
|
312
312
|
async enable() {
|
|
313
|
-
return (await e.call("delegate.enable"))?.disabled !== !1 &&
|
|
313
|
+
return (await e.call("delegate.enable"))?.disabled !== !1 && S(), { disabled: !1 };
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
316
|
}
|
|
@@ -807,11 +807,11 @@ function z(e) {
|
|
|
807
807
|
}
|
|
808
808
|
function A(e, t) {
|
|
809
809
|
const a = pe(e);
|
|
810
|
-
return Object.fromEntries(B.map((n) => [n,
|
|
810
|
+
return Object.fromEntries(B.map((n) => [n, P(a.en, a[n])]));
|
|
811
811
|
}
|
|
812
812
|
function S6(e, t) {
|
|
813
|
-
const a = pe(t), n =
|
|
814
|
-
return Object.fromEntries(B.map((o) => [o,
|
|
813
|
+
const a = pe(t), n = P(e.en, a.en);
|
|
814
|
+
return Object.fromEntries(B.map((o) => [o, P(P(n, e[o]), a[o])]));
|
|
815
815
|
}
|
|
816
816
|
function Ne(e, t, a = "en") {
|
|
817
817
|
return (typeof e == "string" ? e : e[Ue(t.count, a)] ?? e.other).replace(/\{(\w+)\}/g, (o, i) => i in t ? String(t[i]) : o);
|
|
@@ -823,10 +823,10 @@ function pe(e) {
|
|
|
823
823
|
return Object.fromEntries(Object.entries(e).map(([t, a]) => [t.slice(t.lastIndexOf("/") + 1, -5), a]));
|
|
824
824
|
}
|
|
825
825
|
const X = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Oe = (e) => typeof e.other == "string";
|
|
826
|
-
function
|
|
826
|
+
function P(e, t) {
|
|
827
827
|
if (!X(e) || !X(t) || Oe(t)) return t ?? e;
|
|
828
828
|
const a = { ...e };
|
|
829
|
-
for (const [n, o] of Object.entries(t)) a[n] =
|
|
829
|
+
for (const [n, o] of Object.entries(t)) a[n] = P(e[n], o);
|
|
830
830
|
return a;
|
|
831
831
|
}
|
|
832
832
|
function _6(e) {
|
|
@@ -857,28 +857,28 @@ function Ve(e = {}) {
|
|
|
857
857
|
let o = !1;
|
|
858
858
|
return {
|
|
859
859
|
async download(i) {
|
|
860
|
-
if (
|
|
860
|
+
if (D(i), o) throw { code: "canceled" };
|
|
861
861
|
const s = await t.token();
|
|
862
862
|
if (o) throw { code: "canceled" };
|
|
863
863
|
const r = document.createElement("iframe");
|
|
864
864
|
r.hidden = !0, r.setAttribute("sandbox", "allow-forms allow-same-origin allow-downloads"), a.add(r), document.body.append(r);
|
|
865
|
-
const
|
|
866
|
-
if (!
|
|
865
|
+
const l = r.contentDocument;
|
|
866
|
+
if (!l)
|
|
867
867
|
throw r.remove(), a.delete(r), { code: "unavailable" };
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
for (const [u,
|
|
873
|
-
const
|
|
874
|
-
|
|
868
|
+
const c = l.createElement("meta");
|
|
869
|
+
c.httpEquiv = "Content-Security-Policy", c.content = "default-src 'none'; form-action 'self'; base-uri 'none'", l.head.append(c);
|
|
870
|
+
const p = l.createElement("form");
|
|
871
|
+
p.method = "POST", p.action = ce;
|
|
872
|
+
for (const [u, d] of Object.entries({ api: "SYNO.FileStation.Download", method: "download", version: "2", path: JSON.stringify([i]), mode: "download", SynoToken: s })) {
|
|
873
|
+
const h = l.createElement("input");
|
|
874
|
+
h.type = "hidden", h.name = u, h.value = d, p.append(h);
|
|
875
875
|
}
|
|
876
|
-
|
|
876
|
+
l.body.append(p);
|
|
877
877
|
try {
|
|
878
|
-
|
|
878
|
+
p.submit();
|
|
879
879
|
} finally {
|
|
880
|
-
for (const u of Array.from(
|
|
881
|
-
|
|
880
|
+
for (const u of Array.from(p.querySelectorAll("input"))) u.value = "";
|
|
881
|
+
p.remove();
|
|
882
882
|
}
|
|
883
883
|
},
|
|
884
884
|
dispose() {
|
|
@@ -890,89 +890,95 @@ function Ve(e = {}) {
|
|
|
890
890
|
},
|
|
891
891
|
async upload(i, s, r) {
|
|
892
892
|
if (o) throw { code: "canceled" };
|
|
893
|
-
const
|
|
894
|
-
n.add(
|
|
893
|
+
const l = new AbortController(), c = () => l.abort();
|
|
894
|
+
n.add(l), r.addEventListener("abort", c, { once: !0 }), r.aborted && l.abort();
|
|
895
895
|
try {
|
|
896
|
-
await t.upload(i, s,
|
|
896
|
+
await t.upload(i, s, l.signal);
|
|
897
897
|
} finally {
|
|
898
|
-
n.delete(
|
|
898
|
+
n.delete(l), r.removeEventListener("abort", c);
|
|
899
899
|
}
|
|
900
900
|
}
|
|
901
901
|
};
|
|
902
902
|
}
|
|
903
|
-
function
|
|
903
|
+
function _(e = "unavailable") {
|
|
904
904
|
throw { code: e };
|
|
905
905
|
}
|
|
906
906
|
function j(e) {
|
|
907
|
-
return (!e || typeof e != "object" || Array.isArray(e)) &&
|
|
907
|
+
return (!e || typeof e != "object" || Array.isArray(e)) && _(), e;
|
|
908
908
|
}
|
|
909
909
|
const he = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0;
|
|
910
910
|
function ge(e) {
|
|
911
911
|
const t = j(e), a = j(t.additional ?? {});
|
|
912
|
-
return (typeof t.name != "string" || typeof t.path != "string" || typeof t.isdir != "boolean" || a.size !== void 0 && !he(a.size)) &&
|
|
912
|
+
return (typeof t.name != "string" || typeof t.path != "string" || typeof t.isdir != "boolean" || a.size !== void 0 && !he(a.size)) && _(), { name: t.name, path: t.path, isDir: t.isdir, ...a.size === void 0 ? {} : { bytes: a.size } };
|
|
913
913
|
}
|
|
914
914
|
const We = /* @__PURE__ */ new Set(["#recycle", "#snapshot", "@eaDir", "@tmp", "@sharebin"]);
|
|
915
915
|
function ee(e, t, a) {
|
|
916
916
|
const n = j(e), o = n.shares ?? n.files;
|
|
917
|
-
(!Array.isArray(o) || o.length > a || !he(n.total) || n.offset !== t || t + o.length > n.total) &&
|
|
917
|
+
(!Array.isArray(o) || o.length > a || !he(n.total) || n.offset !== t || t + o.length > n.total) && _();
|
|
918
918
|
const i = o.map(ge), s = t + i.length;
|
|
919
|
-
return s < n.total && !i.length &&
|
|
919
|
+
return s < n.total && !i.length && _(), { entries: i.filter((r) => !We.has(r.name)), total: n.total, offset: t, ...s < n.total ? { nextOffset: s } : {} };
|
|
920
920
|
}
|
|
921
921
|
function Je(e) {
|
|
922
922
|
let t = !1;
|
|
923
923
|
const a = new AbortController(), n = Ve(e.files), o = le({ webApi: e.webApi, token: e.files?.token, timeout: L(e.requestTimeout) });
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
924
|
+
let i;
|
|
925
|
+
function s() {
|
|
926
|
+
return i ??= e.call("nas.session.status", {}, { signal: a.signal }).finally(() => {
|
|
927
|
+
i = void 0;
|
|
928
|
+
}), i;
|
|
929
|
+
}
|
|
930
|
+
async function r(l, c, p, u = !1) {
|
|
931
|
+
(t || p.aborted) && _("canceled");
|
|
932
|
+
let d = () => {
|
|
927
933
|
};
|
|
928
|
-
const
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
clearTimeout(
|
|
934
|
+
const h = new Promise((b, $) => {
|
|
935
|
+
const v = () => $({ code: u ? "commit-uncertain" : "canceled" }), w = setTimeout(() => $({ code: u ? "commit-uncertain" : "timeout" }), L(e.requestTimeout));
|
|
936
|
+
p.addEventListener("abort", v, { once: !0 }), a.signal.addEventListener("abort", v, { once: !0 }), d = () => {
|
|
937
|
+
clearTimeout(w), p.removeEventListener("abort", v), a.signal.removeEventListener("abort", v);
|
|
932
938
|
};
|
|
933
|
-
}),
|
|
934
|
-
|
|
939
|
+
}), m = new AbortController(), g = () => m.abort();
|
|
940
|
+
p.addEventListener("abort", g, { once: !0 }), a.signal.addEventListener("abort", g, { once: !0 });
|
|
935
941
|
async function f() {
|
|
936
|
-
switch (await
|
|
942
|
+
switch (await s(), m.signal.aborted && _("canceled"), l) {
|
|
937
943
|
case "nas.files.shares":
|
|
938
|
-
return o.shares(
|
|
944
|
+
return o.shares(c.offset, m.signal);
|
|
939
945
|
case "nas.files.list":
|
|
940
|
-
return o.list(
|
|
946
|
+
return o.list(c.path, c, m.signal);
|
|
941
947
|
case "nas.files.info":
|
|
942
|
-
return o.info(
|
|
948
|
+
return o.info(c.path, m.signal);
|
|
943
949
|
case "nas.files.create_folder":
|
|
944
|
-
return o.createFolder(
|
|
950
|
+
return o.createFolder(c.parent, c.name, m.signal);
|
|
945
951
|
}
|
|
946
|
-
|
|
952
|
+
_("unsupported");
|
|
947
953
|
}
|
|
948
954
|
try {
|
|
949
|
-
return await Promise.race([f(),
|
|
950
|
-
} catch (
|
|
951
|
-
const
|
|
952
|
-
H(
|
|
955
|
+
return await Promise.race([f(), h]);
|
|
956
|
+
} catch (b) {
|
|
957
|
+
const $ = b?.code;
|
|
958
|
+
H(b) && _(H(b)), [407, 408, "407", "408", "denied"].includes($) && _("denied"), ($ === "cross_origin" || $ === "origin_required") && _("origin-refused"), ($ === "request_timeout" || $ === "request_canceled") && _(u ? "commit-uncertain" : $ === "request_timeout" ? "timeout" : "canceled"), _(typeof $ == "string" && ["session_required", "dsm_session_required", "auth_unavailable", "denied", "not_found", "conflict", "invalid-request", "unavailable", "unknown_method", "unsupported", "commit-uncertain", "canceled", "timeout"].includes($) ? $ : u ? "commit-uncertain" : "unavailable");
|
|
953
959
|
} finally {
|
|
954
|
-
|
|
960
|
+
d(), m.abort(), p.removeEventListener("abort", g), a.signal.removeEventListener("abort", g);
|
|
955
961
|
}
|
|
956
962
|
}
|
|
957
963
|
return {
|
|
958
|
-
async upload(
|
|
959
|
-
(t ||
|
|
964
|
+
async upload(l, c, p) {
|
|
965
|
+
(t || p.aborted) && _("canceled"), await e.call("nas.session.status", {}, { signal: p }), (t || p.aborted) && _("canceled"), await n.upload(l, c, p);
|
|
960
966
|
},
|
|
961
|
-
async download(
|
|
962
|
-
t &&
|
|
967
|
+
async download(l) {
|
|
968
|
+
t && _("canceled"), await e.call("nas.session.status"), t && _("canceled"), await n.download(l);
|
|
963
969
|
},
|
|
964
|
-
async shares(
|
|
965
|
-
return ee(await
|
|
970
|
+
async shares(l, c) {
|
|
971
|
+
return ee(await r("nas.files.shares", { offset: l }, c), l, 100);
|
|
966
972
|
},
|
|
967
|
-
async list(
|
|
968
|
-
const
|
|
969
|
-
return ee(await
|
|
973
|
+
async list(l, c, p) {
|
|
974
|
+
const u = c.offset ?? 0, d = c.limit ?? 100;
|
|
975
|
+
return ee(await r("nas.files.list", { path: l, ...c, offset: u, limit: d }, p), u, d);
|
|
970
976
|
},
|
|
971
|
-
async info(
|
|
972
|
-
return ge(await
|
|
977
|
+
async info(l, c) {
|
|
978
|
+
return ge(await r("nas.files.info", { path: l }, c));
|
|
973
979
|
},
|
|
974
|
-
async createFolder(
|
|
975
|
-
j(await
|
|
980
|
+
async createFolder(l, c, p) {
|
|
981
|
+
j(await r("nas.files.create_folder", { parent: l, name: c }, p, !0)).created !== !0 && _("commit-uncertain");
|
|
976
982
|
},
|
|
977
983
|
dispose() {
|
|
978
984
|
t = !0, a.abort(), n?.dispose();
|
|
@@ -2277,7 +2283,7 @@ function T6(e) {
|
|
|
2277
2283
|
return ve[z(e)];
|
|
2278
2284
|
}
|
|
2279
2285
|
function E6(e, t, a, n) {
|
|
2280
|
-
const o = x(e, a ?? Object.entries(ve).find(([,
|
|
2286
|
+
const o = x(e, a ?? Object.entries(ve).find(([, l]) => l === t)?.[0], n);
|
|
2281
2287
|
if (o) return o.message;
|
|
2282
2288
|
const i = V(e, a);
|
|
2283
2289
|
if (i) return i;
|
|
@@ -3434,10 +3440,10 @@ function s4(e = "en") {
|
|
|
3434
3440
|
return Se[z(e)];
|
|
3435
3441
|
}
|
|
3436
3442
|
function x6(e, t = s4(), a = "save", n, o) {
|
|
3437
|
-
const i = x(e, n ?? Object.entries(Se).find(([,
|
|
3443
|
+
const i = x(e, n ?? Object.entries(Se).find(([, c]) => c === t)?.[0], o);
|
|
3438
3444
|
if (i) return i.message;
|
|
3439
|
-
const s = a === "select", r = e?.code,
|
|
3440
|
-
return
|
|
3445
|
+
const s = a === "select", r = e?.code, l = V(e, n);
|
|
3446
|
+
return l || (r === "disabled" ? t.disabled : ["EXECUTOR_UNAVAILABLE", "needs-admin-approval", "needs-scope-confirmation"].includes(r ?? "") ? t.needs : ["session_required", "dsm_session_required", "AUTH_DENIED"].includes(r ?? "") ? t.session : ["DENIED", "DELEGATION_DENIED", "IDENTITY_CHANGED", "SCOPE_DENIED", "INELIGIBLE", "DESTINATION_CHANGED", "denied", "grant-revoked", "identity-changed", "permission-changed"].includes(r ?? "") ? t.denied : r === "PERMISSION_DENIED" ? s ? t.permissionSelect : t.permission : r === "not-found" ? t.missing : r === "APP_DENIED" ? s ? t.appPrivilegeSelect : t.appPrivilege : ["CONFLICT", "conflict", "file-exists", "destination-exists"].includes(r ?? "") ? t.conflict : ["NO_SPACE", "ENOSPC", "no-space"].includes(r ?? "") ? t.space : ["uncertain", "commit-uncertain"].includes(r ?? "") ? t.uncertainHelp : t.error);
|
|
3441
3447
|
}
|
|
3442
3448
|
const r4 = {
|
|
3443
3449
|
"portal.title": "Anwendungsportal",
|
|
@@ -3776,12 +3782,12 @@ const ne = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/, WO = [
|
|
|
3776
3782
|
"synologymeet"
|
|
3777
3783
|
], oe = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/, JO = ["registered", "unregistered", "cleanup-required"], KO = { dsm_4100: "portal_alias_invalid", dsm_4102: "portal_alias_reserved", dsm_4103: "portal_alias_in_use", dsm_105: "admin_required" }, ae = (e) => e?.code;
|
|
3778
3784
|
function U6(e) {
|
|
3779
|
-
function t(
|
|
3780
|
-
const
|
|
3781
|
-
return
|
|
3785
|
+
function t(g, f, b) {
|
|
3786
|
+
const $ = { state: g, canManage: b === !0, controlPanel: b !== void 0, defaultAlias: e.defaultAlias };
|
|
3787
|
+
return g === "active" && f && ($.alias = f, $.url = `${e.location.protocol}//${e.location.host}/${encodeURIComponent(f)}/`), $;
|
|
3782
3788
|
}
|
|
3783
|
-
function a(
|
|
3784
|
-
return
|
|
3789
|
+
function a(g) {
|
|
3790
|
+
return g?.state === "active" && typeof g.alias == "string" && oe.test(g.alias) ? t("active", g.alias) : t(g?.state === "inactive" ? "inactive" : "unavailable");
|
|
3785
3791
|
}
|
|
3786
3792
|
async function n() {
|
|
3787
3793
|
try {
|
|
@@ -3793,76 +3799,76 @@ function U6(e) {
|
|
|
3793
3799
|
async function o() {
|
|
3794
3800
|
try {
|
|
3795
3801
|
if (!(((await e.send("SYNO.API.Info", "query", 1, { query: "SYNO.Core.AppPortal" }))?.["SYNO.Core.AppPortal"]?.maxVersion ?? 0) >= 2)) return t("unavailable", void 0, !1);
|
|
3796
|
-
const
|
|
3797
|
-
if (
|
|
3798
|
-
const
|
|
3799
|
-
return typeof
|
|
3802
|
+
const f = await e.send("SYNO.Core.AppPortal", "get", 2, { id: e.appId, additional: ["default_setting"] });
|
|
3803
|
+
if (f?.id !== e.appId) return t("unavailable", void 0, !1);
|
|
3804
|
+
const b = typeof f.alias == "string" && oe.test(f.alias) ? f.alias : "", $ = t(b ? "active" : "inactive", b, !0), v = f.additional?.default_setting?.alias;
|
|
3805
|
+
return typeof v == "string" && ne.test(v) && ($.defaultAlias = v), $;
|
|
3800
3806
|
} catch {
|
|
3801
3807
|
return t("unavailable", void 0, !1);
|
|
3802
3808
|
}
|
|
3803
3809
|
}
|
|
3804
3810
|
async function i() {
|
|
3805
|
-
let
|
|
3811
|
+
let g;
|
|
3806
3812
|
try {
|
|
3807
|
-
|
|
3813
|
+
g = await e.call("portal.status", {});
|
|
3808
3814
|
} catch {
|
|
3809
3815
|
return e.isAdmin() ? t("unavailable", void 0, !1) : t("unavailable");
|
|
3810
3816
|
}
|
|
3811
|
-
if (!e.isAdmin()) return a(
|
|
3812
|
-
const
|
|
3813
|
-
if (!
|
|
3814
|
-
if (
|
|
3815
|
-
const
|
|
3816
|
-
return { ...t(
|
|
3817
|
+
if (!e.isAdmin()) return a(g);
|
|
3818
|
+
const f = JO.find(($) => $ === g?.entry);
|
|
3819
|
+
if (!f) return t("unavailable", void 0, !1);
|
|
3820
|
+
if (f === "registered") return { ...await o(), entry: f };
|
|
3821
|
+
const b = a(g);
|
|
3822
|
+
return { ...t(f === "unregistered" ? "inactive" : b.state, b.alias, !0), entry: f };
|
|
3817
3823
|
}
|
|
3818
|
-
let s = Promise.resolve(), r,
|
|
3819
|
-
async function
|
|
3820
|
-
const
|
|
3824
|
+
let s = Promise.resolve(), r, l, c = 0;
|
|
3825
|
+
async function p() {
|
|
3826
|
+
const g = ++c;
|
|
3821
3827
|
await s;
|
|
3822
|
-
const
|
|
3823
|
-
return
|
|
3828
|
+
const f = e.entry ? await i() : e.isAdmin() ? await o() : await n();
|
|
3829
|
+
return g === c && (r = f), f;
|
|
3824
3830
|
}
|
|
3825
3831
|
function u() {
|
|
3826
|
-
return
|
|
3827
|
-
|
|
3832
|
+
return l ??= p().finally(() => {
|
|
3833
|
+
l = void 0;
|
|
3828
3834
|
});
|
|
3829
3835
|
}
|
|
3830
|
-
async function
|
|
3836
|
+
async function d(g) {
|
|
3831
3837
|
if (!e.isAdmin()) throw { code: "admin_required" };
|
|
3832
|
-
const
|
|
3833
|
-
s =
|
|
3834
|
-
}),
|
|
3838
|
+
const f = e.call(g, {});
|
|
3839
|
+
s = f.catch(() => {
|
|
3840
|
+
}), l = void 0;
|
|
3835
3841
|
try {
|
|
3836
|
-
await
|
|
3837
|
-
} catch (
|
|
3838
|
-
throw { code: ae(
|
|
3842
|
+
await f;
|
|
3843
|
+
} catch (b) {
|
|
3844
|
+
throw { code: ae(b) === "ADMIN_REQUIRED" ? "admin_required" : "PORTAL_FAILED" };
|
|
3839
3845
|
}
|
|
3840
|
-
return
|
|
3846
|
+
return p();
|
|
3841
3847
|
}
|
|
3842
|
-
async function
|
|
3848
|
+
async function h(g) {
|
|
3843
3849
|
if (!e.isAdmin()) throw { code: "admin_required" };
|
|
3844
3850
|
try {
|
|
3845
|
-
await e.send("SYNO.Core.AppPortal", "set", 2, { id: e.appId, alias:
|
|
3846
|
-
} catch (
|
|
3847
|
-
throw { code: KO[ae(
|
|
3851
|
+
await e.send("SYNO.Core.AppPortal", "set", 2, { id: e.appId, alias: g });
|
|
3852
|
+
} catch (f) {
|
|
3853
|
+
throw { code: KO[ae(f) ?? ""] ?? "portal_unavailable" };
|
|
3848
3854
|
}
|
|
3849
|
-
return
|
|
3855
|
+
return p();
|
|
3850
3856
|
}
|
|
3851
|
-
const
|
|
3857
|
+
const m = {
|
|
3852
3858
|
messages: $4(e.locale),
|
|
3853
3859
|
status: u,
|
|
3854
3860
|
lastStatus: () => r,
|
|
3855
|
-
async apply(
|
|
3856
|
-
if (typeof
|
|
3857
|
-
if (WO.includes(
|
|
3858
|
-
return
|
|
3861
|
+
async apply(g) {
|
|
3862
|
+
if (typeof g != "string" || !ne.test(g)) throw { code: "portal_alias_invalid" };
|
|
3863
|
+
if (WO.includes(g)) throw { code: "portal_alias_reserved" };
|
|
3864
|
+
return h(g);
|
|
3859
3865
|
},
|
|
3860
|
-
disable: () =>
|
|
3866
|
+
disable: () => h(null),
|
|
3861
3867
|
openControlPanel() {
|
|
3862
3868
|
e.launch("SYNO.SDS.AdminCenter.Application", { fn: "SYNO.SDS.AdminCenter.Login.Main", tab: "applications" });
|
|
3863
3869
|
}
|
|
3864
3870
|
};
|
|
3865
|
-
return e.entry && (
|
|
3871
|
+
return e.entry && (m.register = () => d("portal.register"), m.unregister = () => d("portal.unregister")), u(), m;
|
|
3866
3872
|
}
|
|
3867
3873
|
const GO = {
|
|
3868
3874
|
"sharedfolder.title": "Freigegebene Ordner",
|
|
@@ -4155,25 +4161,25 @@ function _e(e) {
|
|
|
4155
4161
|
canGrant: () => e.isAdmin() && e.send !== void 0,
|
|
4156
4162
|
async grant(o) {
|
|
4157
4163
|
if (!e.isAdmin() || !e.send) throw { code: "admin_required" };
|
|
4158
|
-
const i = await a(), s = i.folders.find((
|
|
4164
|
+
const i = await a(), s = i.folders.find((c) => c.key === o);
|
|
4159
4165
|
if (!s || s.state === "missing" || s.state === "ambiguous") throw { code: "shared_folder_unavailable" };
|
|
4160
4166
|
if (s.state === "ready") return i;
|
|
4161
4167
|
if (s.required === "none") throw { code: "shared_folder_unavailable" };
|
|
4162
4168
|
const r = s.required === "write";
|
|
4163
4169
|
try {
|
|
4164
|
-
const
|
|
4165
|
-
if ((Array.isArray(
|
|
4166
|
-
} catch (
|
|
4167
|
-
if (se(
|
|
4170
|
+
const c = J(await e.send("SYNO.Core.Share.Permission", "list", 1, { name: s.name, user_group_type: "system", offset: 0, limit: 1e3, with_inherit: !1, is_unite_permission: !1 }));
|
|
4171
|
+
if ((Array.isArray(c?.items) ? c.items : []).some((u) => u?.name === i.account && u.is_custom === !0)) throw { code: "shared_folder_custom_acl" };
|
|
4172
|
+
} catch (c) {
|
|
4173
|
+
if (se(c) === "shared_folder_custom_acl") throw c;
|
|
4168
4174
|
}
|
|
4169
4175
|
try {
|
|
4170
4176
|
await e.send("SYNO.Core.Share.Permission", "set", 1, { name: s.name, user_group_type: "system", permissions: [{ name: i.account, is_readonly: !r, is_writable: r, is_deny: !1, is_custom: !1 }] });
|
|
4171
|
-
} catch (
|
|
4172
|
-
throw { code: se(
|
|
4177
|
+
} catch (c) {
|
|
4178
|
+
throw { code: se(c) === "dsm_105" ? "admin_required" : "shared_folder_grant_failed" };
|
|
4173
4179
|
}
|
|
4174
|
-
const
|
|
4175
|
-
if (
|
|
4176
|
-
return
|
|
4180
|
+
const l = await a();
|
|
4181
|
+
if (l.folders.find((c) => c.key === o)?.state !== "ready") throw { code: "shared_folder_grant_unverified" };
|
|
4182
|
+
return l;
|
|
4177
4183
|
},
|
|
4178
4184
|
openControlPanel() {
|
|
4179
4185
|
e.launch?.("SYNO.SDS.AdminCenter.Application", { fn: "SYNO.SDS.AdminCenter.Share.Main" });
|
|
@@ -4204,40 +4210,40 @@ function l6(e, t = "en") {
|
|
|
4204
4210
|
function F6(e) {
|
|
4205
4211
|
const t = e.locale ?? "en", a = _e({ call: e.call, locale: t, isAdmin: () => !1 }), n = /* @__PURE__ */ new Set();
|
|
4206
4212
|
let o = [], i, s, r = 0;
|
|
4207
|
-
function
|
|
4208
|
-
const
|
|
4209
|
-
for (const
|
|
4210
|
-
o = [...
|
|
4211
|
-
for (const
|
|
4213
|
+
function l(u) {
|
|
4214
|
+
const d = /* @__PURE__ */ new Map();
|
|
4215
|
+
for (const h of u) d.set(JSON.stringify([h.account, h.share, h.required]), h);
|
|
4216
|
+
o = [...d.values()];
|
|
4217
|
+
for (const h of n) h(o);
|
|
4212
4218
|
}
|
|
4213
|
-
function
|
|
4219
|
+
function c(u) {
|
|
4214
4220
|
if (s) return s;
|
|
4215
|
-
const
|
|
4216
|
-
return s = a.status().then((
|
|
4217
|
-
const
|
|
4218
|
-
u &&
|
|
4221
|
+
const d = r;
|
|
4222
|
+
return s = a.status().then((h) => {
|
|
4223
|
+
const m = h.folders.filter((g) => g.state === "pending" && g.required !== "none").map((g) => ({ account: h.account, share: g.name, required: g.required }));
|
|
4224
|
+
u && d === r ? l(m) : m.length && l([...m, ...o]);
|
|
4219
4225
|
}).finally(() => {
|
|
4220
4226
|
s = void 0;
|
|
4221
4227
|
}), s;
|
|
4222
4228
|
}
|
|
4223
|
-
const
|
|
4229
|
+
const p = {
|
|
4224
4230
|
messages: W(t),
|
|
4225
4231
|
message: (u) => l6(u, t),
|
|
4226
4232
|
check() {
|
|
4227
|
-
return i ??=
|
|
4233
|
+
return i ??= c(!1);
|
|
4228
4234
|
},
|
|
4229
4235
|
retry() {
|
|
4230
|
-
return
|
|
4236
|
+
return c(!0);
|
|
4231
4237
|
},
|
|
4232
4238
|
handle(u) {
|
|
4233
|
-
const
|
|
4234
|
-
return
|
|
4239
|
+
const d = c6(u);
|
|
4240
|
+
return d ? (r++, l([...o, d]), !0) : !1;
|
|
4235
4241
|
},
|
|
4236
|
-
async call(u,
|
|
4242
|
+
async call(u, d, h) {
|
|
4237
4243
|
try {
|
|
4238
|
-
return await e.call(u,
|
|
4239
|
-
} catch (
|
|
4240
|
-
throw
|
|
4244
|
+
return await e.call(u, d, h);
|
|
4245
|
+
} catch (m) {
|
|
4246
|
+
throw p.handle(m), m;
|
|
4241
4247
|
}
|
|
4242
4248
|
},
|
|
4243
4249
|
subscribe(u) {
|
|
@@ -4247,7 +4253,7 @@ function F6(e) {
|
|
|
4247
4253
|
},
|
|
4248
4254
|
openControlPanel: () => e.openControlPanel?.()
|
|
4249
4255
|
};
|
|
4250
|
-
return
|
|
4256
|
+
return p;
|
|
4251
4257
|
}
|
|
4252
4258
|
const d6 = {
|
|
4253
4259
|
/** The DSM session in auth is missing, invalid or expired. */
|
|
@@ -4442,8 +4448,8 @@ function W6(e, t, a) {
|
|
|
4442
4448
|
const r = await e.call("app.status", {}, { signal: n.signal });
|
|
4443
4449
|
!r || typeof r.user != "string" || !r.user || typeof r.admin != "boolean" ? s = { code: "auth_unavailable" } : t === "admin-only" && !r.admin && (s = { code: "admin_required" });
|
|
4444
4450
|
} catch (r) {
|
|
4445
|
-
const
|
|
4446
|
-
s = { code:
|
|
4451
|
+
const l = r?.code;
|
|
4452
|
+
s = { code: l === "session_required" || l === "admin_required" || l === "app_privilege_denied" ? l : "auth_unavailable" };
|
|
4447
4453
|
}
|
|
4448
4454
|
n.signal.aborted || a(s);
|
|
4449
4455
|
}
|
|
@@ -4481,25 +4487,25 @@ function J6(e) {
|
|
|
4481
4487
|
async function a(n, o) {
|
|
4482
4488
|
const i = new AbortController(), s = { code: "request_canceled", message: "request canceled" };
|
|
4483
4489
|
let r;
|
|
4484
|
-
const
|
|
4490
|
+
const l = () => {
|
|
4485
4491
|
r = s, i.abort();
|
|
4486
|
-
},
|
|
4492
|
+
}, c = setTimeout(() => {
|
|
4487
4493
|
r = { code: "request_timeout", message: "request timeout" }, i.abort();
|
|
4488
|
-
}, L(e.requestTimeout)),
|
|
4489
|
-
if (
|
|
4490
|
-
throw clearTimeout(
|
|
4491
|
-
|
|
4494
|
+
}, L(e.requestTimeout)), p = o?.signal;
|
|
4495
|
+
if (p?.aborted)
|
|
4496
|
+
throw clearTimeout(c), s;
|
|
4497
|
+
p?.addEventListener("abort", l);
|
|
4492
4498
|
try {
|
|
4493
|
-
if (e.ready && !e.token?.() && await Promise.race([e.ready(), new Promise((
|
|
4494
|
-
const u = e.token?.(),
|
|
4495
|
-
if (!
|
|
4496
|
-
const
|
|
4497
|
-
if (!
|
|
4498
|
-
return
|
|
4499
|
+
if (e.ready && !e.token?.() && await Promise.race([e.ready(), new Promise((g) => i.signal.addEventListener("abort", () => g(), { once: !0 }))]), r) throw r;
|
|
4500
|
+
const u = e.token?.(), h = await (await t(e.endpoint, { method: "POST", mode: "same-origin", credentials: "same-origin", redirect: "error", cache: "no-store", headers: { "Content-Type": "application/json", ...u ? { "X-SYNO-TOKEN": u } : {} }, body: JSON.stringify(n), signal: i.signal })).json();
|
|
4501
|
+
if (!h || typeof h != "object" || !("success" in h)) throw { code: "bad_response", message: "unexpected response" };
|
|
4502
|
+
const m = h;
|
|
4503
|
+
if (!m.success) throw m.error ?? { code: "bad_response", message: "unexpected response" };
|
|
4504
|
+
return m.data;
|
|
4499
4505
|
} catch (u) {
|
|
4500
4506
|
throw r ?? u;
|
|
4501
4507
|
} finally {
|
|
4502
|
-
clearTimeout(
|
|
4508
|
+
clearTimeout(c), p?.removeEventListener("abort", l);
|
|
4503
4509
|
}
|
|
4504
4510
|
}
|
|
4505
4511
|
return { call: (n, o, i) => a({ method: n, params: o ?? {} }, i), batch: h6(a) };
|
|
@@ -4521,8 +4527,8 @@ async function K6(e) {
|
|
|
4521
4527
|
signal: a.signal,
|
|
4522
4528
|
headers: { "Content-Type": "application/x-www-form-urlencoded", "X-SYNO-TOKEN": s },
|
|
4523
4529
|
body: new URLSearchParams({ api: "SYNO.Core.Service.PortInfo", version: "1", method: "load", SynoToken: s })
|
|
4524
|
-
}),
|
|
4525
|
-
return
|
|
4530
|
+
}), l = r.ok ? await r.json() : void 0;
|
|
4531
|
+
return l?.success === !0 ? l.data : void 0;
|
|
4526
4532
|
}, o = await Promise.race([n(), new Promise((s) => {
|
|
4527
4533
|
t = setTimeout(() => {
|
|
4528
4534
|
a.abort(), s(void 0);
|
|
@@ -4532,21 +4538,21 @@ async function K6(e) {
|
|
|
4532
4538
|
const i = (s) => typeof s == "string" ? s.trim() : "";
|
|
4533
4539
|
return o.port_info.flatMap((s) => {
|
|
4534
4540
|
if (!s || typeof s != "object") return [];
|
|
4535
|
-
const r = s,
|
|
4536
|
-
if (!
|
|
4537
|
-
const
|
|
4538
|
-
const
|
|
4539
|
-
if (!
|
|
4540
|
-
const
|
|
4541
|
-
return
|
|
4541
|
+
const r = s, l = i(r.port_id), c = i(r.protocol);
|
|
4542
|
+
if (!l || !Array.isArray(r.dst_port)) return [];
|
|
4543
|
+
const p = r.dst_port.flatMap((u) => {
|
|
4544
|
+
const d = /^(\d{1,5})(?:[-:](\d{1,5}))?$/.exec(i(u));
|
|
4545
|
+
if (!d) return [];
|
|
4546
|
+
const h = Number(d[1]), m = Number(d[2] ?? d[1]);
|
|
4547
|
+
return h >= 1 && m <= 65535 && m >= h ? [{ first: h, last: m }] : [];
|
|
4542
4548
|
});
|
|
4543
4549
|
return [{
|
|
4544
|
-
id:
|
|
4550
|
+
id: l,
|
|
4545
4551
|
name: i(r.name),
|
|
4546
4552
|
desc: i(r.desc),
|
|
4547
|
-
protocol:
|
|
4553
|
+
protocol: c,
|
|
4548
4554
|
ports: r.dst_port.map(i).filter((u) => /^\d{1,5}$/.test(u)).map(Number).filter((u) => u >= 1 && u <= 65535),
|
|
4549
|
-
ranges:
|
|
4555
|
+
ranges: p
|
|
4550
4556
|
}];
|
|
4551
4557
|
});
|
|
4552
4558
|
} catch {
|