@camstack/system 1.2.381 → 1.2.383
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/addon-runner.js +4 -2
- package/dist/addon-runner.mjs +4 -2
- package/dist/addon-utils.js +1 -1
- package/dist/addon-utils.mjs +1 -1
- package/dist/auth/admin-token-manager.d.ts +75 -0
- package/dist/auth/api-key-manager.d.ts +1 -14
- package/dist/auth/auth-audit-log.d.ts +59 -0
- package/dist/auth/auth-manager.d.ts +28 -16
- package/dist/auth/cidr.d.ts +22 -0
- package/dist/auth/login-session-manager.d.ts +158 -0
- package/dist/auth/user-management-internal.d.ts +69 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +14 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +291 -3631
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +284 -3617
- package/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +36 -0
- package/dist/builtins/backup-orchestrator/manifest-store.d.ts +19 -1
- package/dist/builtins/backup-orchestrator/restore-archive.d.ts +24 -0
- package/dist/builtins/calendars/calendars.addon.js +1 -1
- package/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
- package/dist/builtins/device-manager/device-manager.addon.js +2 -2
- package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +1110 -735
- package/dist/builtins/keychain/index.mjs +1109 -734
- package/dist/builtins/keychain/keychain-reset-trigger.d.ts +25 -0
- package/dist/builtins/keychain/keychain-service.d.ts +36 -3
- package/dist/builtins/keychain/keychain-store.d.ts +24 -1
- package/dist/builtins/keychain/system-held-secrets.d.ts +2 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.d.ts +16 -0
- package/dist/builtins/local-auth/local-auth.addon.js +1028 -294
- package/dist/builtins/local-auth/local-auth.addon.mjs +1035 -299
- package/dist/builtins/local-network/local-network.addon.js +3 -3
- package/dist/builtins/local-network/local-network.addon.mjs +3 -3
- package/dist/builtins/loki-logging/index.js +97 -29
- package/dist/builtins/loki-logging/index.mjs +97 -29
- package/dist/builtins/loki-logging/loki-logging.addon.d.ts +7 -23
- package/dist/builtins/loki-logging/retire-enabled-flag.d.ts +23 -0
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +2 -2
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +2 -2
- package/dist/builtins/system-backup/backup-encryption.d.ts +57 -0
- package/dist/builtins/system-backup/system-backup.service.d.ts +16 -1
- package/dist/builtins/system-config/cluster-secret-keeper.d.ts +7 -0
- package/dist/builtins/system-config/index.d.ts +1 -0
- package/dist/builtins/system-config/index.js +2 -0
- package/dist/builtins/system-config/index.mjs +2 -2
- package/dist/builtins/system-config/mesh-actions.d.ts +19 -0
- package/dist/builtins/system-config/system-config.addon.d.ts +47 -4
- package/dist/builtins/system-config/system-config.addon.js +87858 -43
- package/dist/builtins/system-config/system-config.addon.mjs +87813 -39
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{child-cap-dispatch-hf-Gce_4.js → child-cap-dispatch-BD8fhJ1b.js} +7 -4
- package/dist/{child-cap-dispatch-BTe4eKep.mjs → child-cap-dispatch-C68N2a6Y.mjs} +11 -8
- package/dist/{composition-sources-4SmsP0O4.js → composition-sources-ChpT_Yw4.js} +1 -1
- package/dist/{composition-sources-CgOQVIwa.mjs → composition-sources-DM7Ft_tp.mjs} +1 -1
- package/dist/{cluster-secret-BUiG8DCo.js → constants-CDpry1_T.js} +82 -1
- package/dist/{cluster-secret-DgJTZ4qY.mjs → constants-e3mCa1jG.mjs} +23 -2
- package/dist/{dist-BugrtARh.js → dist-CUNGH0fs.js} +1755 -157
- package/dist/{dist-BC0GnGeg.mjs → dist-osl3bkF0.mjs} +1732 -158
- package/dist/{event-loop-stall-monitor-GgpnfAC0.mjs → event-loop-stall-monitor-BeeWMnyT.mjs} +15 -15
- package/dist/{event-loop-stall-monitor-CnQ-K6Gn.js → event-loop-stall-monitor-Dk28EF8B.js} +15 -15
- package/dist/{hub-cap-forward-CH6_VWVO.mjs → hub-cap-forward-CDiN1p98.mjs} +18 -2
- package/dist/{hub-cap-forward-COCmYaup.js → hub-cap-forward-W8oEm4ME.js} +23 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +1023 -83525
- package/dist/index.mjs +1218 -83794
- package/dist/{jwt-signing-key-CsuVKA1W.mjs → jwt-signing-key-MQLxLfgF.mjs} +1 -1
- package/dist/{jwt-signing-key-CjoZcol8.js → jwt-signing-key-WI6z7JBo.js} +1 -1
- package/dist/kernel/index.d.ts +17 -1
- package/dist/kernel/moleculer/agent-mesh-authenticator.d.ts +41 -0
- package/dist/kernel/moleculer/broker-factory.d.ts +25 -2
- package/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +1 -0
- package/dist/kernel/moleculer/hub-service.d.ts +9 -0
- package/dist/kernel/moleculer/mesh-access-middleware.d.ts +33 -0
- package/dist/kernel/moleculer/mesh-auth-mode.d.ts +64 -0
- package/dist/kernel/moleculer/mesh-authenticator.d.ts +71 -0
- package/dist/kernel/moleculer/mesh-auto-enforce.d.ts +26 -0
- package/dist/kernel/moleculer/mesh-join-client.d.ts +51 -0
- package/dist/kernel/moleculer/mesh-join-proof.d.ts +39 -0
- package/dist/kernel/moleculer/mesh-mtls/constants.d.ts +20 -0
- package/dist/kernel/moleculer/mesh-mtls/index.d.ts +9 -0
- package/dist/kernel/moleculer/mesh-mtls/mesh-ca-keeper.d.ts +55 -0
- package/dist/kernel/moleculer/mesh-mtls/mesh-ca.d.ts +45 -0
- package/dist/kernel/moleculer/mesh-mtls/mesh-crl.d.ts +16 -0
- package/dist/kernel/moleculer/mesh-mtls/mesh-enroll.d.ts +27 -0
- package/dist/kernel/moleculer/mesh-mtls/mesh-join-token.d.ts +55 -0
- package/dist/kernel/moleculer/mesh-mtls/mesh-tls-enabler.d.ts +5 -0
- package/dist/kernel/moleculer/mesh-mtls/tls-tcp-transporter.d.ts +92 -0
- package/dist/kernel/system-settings-policy.d.ts +4 -3
- package/dist/kernel/transport/hub-cap-forward.d.ts +14 -3
- package/dist/kernel/transport/index.d.ts +1 -1
- package/dist/ms-DlIWNkkk.mjs +160 -0
- package/dist/ms-t68_FaqE.js +171 -0
- package/dist/restore-archive-C5f9yX90.js +4139 -0
- package/dist/restore-archive-CZRtI1k9.mjs +4045 -0
- package/dist/{retired-settings-keys-MCVhxPkJ.mjs → retired-settings-keys-LuDd4y3M.mjs} +1 -1
- package/dist/{retired-settings-keys-DCuetwOt.js → retired-settings-keys-WLrbzdPR.js} +1 -1
- package/dist/tls-BWpwU-d5.js +1160 -0
- package/dist/tls-C2NT-Orr.mjs +949 -0
- package/dist/{tls-CCMX7MjX.js → x509.es-BhTzcFhZ.js} +65 -1108
- package/dist/{tls-CJHogwTl.mjs → x509.es-Xf3K_brW.mjs} +40 -950
- package/package.json +3 -2
|
@@ -3,3627 +3,15 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CUNGH0fs.js");
|
|
7
|
+
const require_restore_archive = require("../../restore-archive-C5f9yX90.js");
|
|
7
8
|
let node_crypto = require("node:crypto");
|
|
8
|
-
let buffer = require("buffer");
|
|
9
9
|
let node_fs_promises = require("node:fs/promises");
|
|
10
|
-
let node_fs_promises$1 = require_chunk.__toESM(node_fs_promises, 1);
|
|
11
10
|
node_fs_promises = require_chunk.__toESM(node_fs_promises);
|
|
12
11
|
let node_path = require("node:path");
|
|
13
|
-
let node_path$1 = require_chunk.__toESM(node_path, 1);
|
|
14
12
|
node_path = require_chunk.__toESM(node_path);
|
|
15
13
|
let node_fs = require("node:fs");
|
|
16
|
-
let node_fs$1 = require_chunk.__toESM(node_fs, 1);
|
|
17
14
|
node_fs = require_chunk.__toESM(node_fs);
|
|
18
|
-
let node_zlib = require("node:zlib");
|
|
19
|
-
node_zlib = require_chunk.__toESM(node_zlib);
|
|
20
|
-
let node_events = require("node:events");
|
|
21
|
-
let node_stream = require("node:stream");
|
|
22
|
-
node_stream = require_chunk.__toESM(node_stream, 1);
|
|
23
|
-
let node_string_decoder = require("node:string_decoder");
|
|
24
|
-
let fs = require("fs");
|
|
25
|
-
fs = require_chunk.__toESM(fs, 1);
|
|
26
|
-
let path = require("path");
|
|
27
|
-
path = require_chunk.__toESM(path, 1);
|
|
28
|
-
let zlib = require("zlib");
|
|
29
|
-
zlib = require_chunk.__toESM(zlib, 1);
|
|
30
|
-
let assert = require("assert");
|
|
31
|
-
assert = require_chunk.__toESM(assert, 1);
|
|
32
|
-
let events = require("events");
|
|
33
|
-
events = require_chunk.__toESM(events, 1);
|
|
34
|
-
let node_stream_promises = require("node:stream/promises");
|
|
35
|
-
let node_assert = require("node:assert");
|
|
36
|
-
node_assert = require_chunk.__toESM(node_assert, 1);
|
|
37
|
-
//#region node_modules/tar/dist/esm/index.min.js
|
|
38
|
-
var Mr = Object.defineProperty;
|
|
39
|
-
var Br = (s, t) => {
|
|
40
|
-
for (var e in t) Mr(s, e, {
|
|
41
|
-
get: t[e],
|
|
42
|
-
enumerable: !0
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var xs = typeof process == "object" && process ? process : {
|
|
46
|
-
stdout: null,
|
|
47
|
-
stderr: null
|
|
48
|
-
}, zr = (s) => !!s && typeof s == "object" && (s instanceof A$1 || s instanceof node_stream.default || Ur(s) || Hr(s)), Ur = (s) => !!s && typeof s == "object" && s instanceof node_events.EventEmitter && typeof s.pipe == "function" && s.pipe !== node_stream.default.Writable.prototype.pipe, Hr = (s) => !!s && typeof s == "object" && s instanceof node_events.EventEmitter && typeof s.write == "function" && typeof s.end == "function", q = Symbol("EOF"), Q = Symbol("maybeEmitEnd"), rt = Symbol("emittedEnd"), Le = Symbol("emittingEnd"), qt = Symbol("emittedError"), Ne = Symbol("closed"), Ls = Symbol("read"), De = Symbol("flush"), Ns = Symbol("flushChunk"), z = Symbol("encoding"), Mt = Symbol("decoder"), g$1 = Symbol("flowing"), Qt = Symbol("paused"), Bt = Symbol("resume"), b$1 = Symbol("buffer"), D$1 = Symbol("pipes"), _$1 = Symbol("bufferLength"), gi = Symbol("bufferPush"), Ae = Symbol("bufferShift"), L = Symbol("objectMode"), w$1 = Symbol("destroyed"), bi = Symbol("error"), _i = Symbol("emitData"), Ds = Symbol("emitEnd"), Oi = Symbol("emitEnd2"), Z = Symbol("async"), Ti = Symbol("abort"), Ie = Symbol("aborted"), Jt = Symbol("signal"), Rt = Symbol("dataListeners"), F = Symbol("discarded"), jt = (s) => Promise.resolve().then(s), Wr = (s) => s(), Gr = (s) => s === "end" || s === "finish" || s === "prefinish", Zr = (s) => s instanceof ArrayBuffer || !!s && typeof s == "object" && s.constructor && s.constructor.name === "ArrayBuffer" && s.byteLength >= 0, Yr = (s) => !Buffer.isBuffer(s) && ArrayBuffer.isView(s), Fe = class {
|
|
49
|
-
src;
|
|
50
|
-
dest;
|
|
51
|
-
opts;
|
|
52
|
-
ondrain;
|
|
53
|
-
constructor(t, e, i) {
|
|
54
|
-
this.src = t, this.dest = e, this.opts = i, this.ondrain = () => t[Bt](), this.dest.on("drain", this.ondrain);
|
|
55
|
-
}
|
|
56
|
-
unpipe() {
|
|
57
|
-
this.dest.removeListener("drain", this.ondrain);
|
|
58
|
-
}
|
|
59
|
-
proxyErrors(t) {}
|
|
60
|
-
end() {
|
|
61
|
-
this.unpipe(), this.opts.end && this.dest.end();
|
|
62
|
-
}
|
|
63
|
-
}, xi = class extends Fe {
|
|
64
|
-
unpipe() {
|
|
65
|
-
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
66
|
-
}
|
|
67
|
-
constructor(t, e, i) {
|
|
68
|
-
super(t, e, i), this.proxyErrors = (r) => this.dest.emit("error", r), t.on("error", this.proxyErrors);
|
|
69
|
-
}
|
|
70
|
-
}, Kr = (s) => !!s.objectMode, Vr = (s) => !s.objectMode && !!s.encoding && s.encoding !== "buffer", A$1 = class extends node_events.EventEmitter {
|
|
71
|
-
[g$1] = !1;
|
|
72
|
-
[Qt] = !1;
|
|
73
|
-
[D$1] = [];
|
|
74
|
-
[b$1] = [];
|
|
75
|
-
[L];
|
|
76
|
-
[z];
|
|
77
|
-
[Z];
|
|
78
|
-
[Mt];
|
|
79
|
-
[q] = !1;
|
|
80
|
-
[rt] = !1;
|
|
81
|
-
[Le] = !1;
|
|
82
|
-
[Ne] = !1;
|
|
83
|
-
[qt] = null;
|
|
84
|
-
[_$1] = 0;
|
|
85
|
-
[w$1] = !1;
|
|
86
|
-
[Jt];
|
|
87
|
-
[Ie] = !1;
|
|
88
|
-
[Rt] = 0;
|
|
89
|
-
[F] = !1;
|
|
90
|
-
writable = !0;
|
|
91
|
-
readable = !0;
|
|
92
|
-
constructor(...t) {
|
|
93
|
-
let e = t[0] || {};
|
|
94
|
-
if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
|
|
95
|
-
Kr(e) ? (this[L] = !0, this[z] = null) : Vr(e) ? (this[z] = e.encoding, this[L] = !1) : (this[L] = !1, this[z] = null), this[Z] = !!e.async, this[Mt] = this[z] ? new node_string_decoder.StringDecoder(this[z]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[b$1] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[D$1] });
|
|
96
|
-
let { signal: i } = e;
|
|
97
|
-
i && (this[Jt] = i, i.aborted ? this[Ti]() : i.addEventListener("abort", () => this[Ti]()));
|
|
98
|
-
}
|
|
99
|
-
get bufferLength() {
|
|
100
|
-
return this[_$1];
|
|
101
|
-
}
|
|
102
|
-
get encoding() {
|
|
103
|
-
return this[z];
|
|
104
|
-
}
|
|
105
|
-
set encoding(t) {
|
|
106
|
-
throw new Error("Encoding must be set at instantiation time");
|
|
107
|
-
}
|
|
108
|
-
setEncoding(t) {
|
|
109
|
-
throw new Error("Encoding must be set at instantiation time");
|
|
110
|
-
}
|
|
111
|
-
get objectMode() {
|
|
112
|
-
return this[L];
|
|
113
|
-
}
|
|
114
|
-
set objectMode(t) {
|
|
115
|
-
throw new Error("objectMode must be set at instantiation time");
|
|
116
|
-
}
|
|
117
|
-
get async() {
|
|
118
|
-
return this[Z];
|
|
119
|
-
}
|
|
120
|
-
set async(t) {
|
|
121
|
-
this[Z] = this[Z] || !!t;
|
|
122
|
-
}
|
|
123
|
-
[Ti]() {
|
|
124
|
-
this[Ie] = !0, this.emit("abort", this[Jt]?.reason), this.destroy(this[Jt]?.reason);
|
|
125
|
-
}
|
|
126
|
-
get aborted() {
|
|
127
|
-
return this[Ie];
|
|
128
|
-
}
|
|
129
|
-
set aborted(t) {}
|
|
130
|
-
write(t, e, i) {
|
|
131
|
-
if (this[Ie]) return !1;
|
|
132
|
-
if (this[q]) throw new Error("write after end");
|
|
133
|
-
if (this[w$1]) return this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
|
|
134
|
-
typeof e == "function" && (i = e, e = "utf8"), e || (e = "utf8");
|
|
135
|
-
let r = this[Z] ? jt : Wr;
|
|
136
|
-
if (!this[L] && !Buffer.isBuffer(t)) {
|
|
137
|
-
if (Yr(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
|
|
138
|
-
else if (Zr(t)) t = Buffer.from(t);
|
|
139
|
-
else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
140
|
-
}
|
|
141
|
-
return this[L] ? (this[g$1] && this[_$1] !== 0 && this[De](!0), this[g$1] ? this.emit("data", t) : this[gi](t), this[_$1] !== 0 && this.emit("readable"), i && r(i), this[g$1]) : t.length ? (typeof t == "string" && !(e === this[z] && !this[Mt]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[Mt].write(t)), this[g$1] && this[_$1] !== 0 && this[De](!0), this[g$1] ? this.emit("data", t) : this[gi](t), this[_$1] !== 0 && this.emit("readable"), i && r(i), this[g$1]) : (this[_$1] !== 0 && this.emit("readable"), i && r(i), this[g$1]);
|
|
142
|
-
}
|
|
143
|
-
read(t) {
|
|
144
|
-
if (this[w$1]) return null;
|
|
145
|
-
if (this[F] = !1, this[_$1] === 0 || t === 0 || t && t > this[_$1]) return this[Q](), null;
|
|
146
|
-
this[L] && (t = null), this[b$1].length > 1 && !this[L] && (this[b$1] = [this[z] ? this[b$1].join("") : Buffer.concat(this[b$1], this[_$1])]);
|
|
147
|
-
let e = this[Ls](t || null, this[b$1][0]);
|
|
148
|
-
return this[Q](), e;
|
|
149
|
-
}
|
|
150
|
-
[Ls](t, e) {
|
|
151
|
-
if (this[L]) this[Ae]();
|
|
152
|
-
else {
|
|
153
|
-
let i = e;
|
|
154
|
-
t === i.length || t === null ? this[Ae]() : typeof i == "string" ? (this[b$1][0] = i.slice(t), e = i.slice(0, t), this[_$1] -= t) : (this[b$1][0] = i.subarray(t), e = i.subarray(0, t), this[_$1] -= t);
|
|
155
|
-
}
|
|
156
|
-
return this.emit("data", e), !this[b$1].length && !this[q] && this.emit("drain"), e;
|
|
157
|
-
}
|
|
158
|
-
end(t, e, i) {
|
|
159
|
-
return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = "utf8"), t !== void 0 && this.write(t, e), i && this.once("end", i), this[q] = !0, this.writable = !1, (this[g$1] || !this[Qt]) && this[Q](), this;
|
|
160
|
-
}
|
|
161
|
-
[Bt]() {
|
|
162
|
-
this[w$1] || (!this[Rt] && !this[D$1].length && (this[F] = !0), this[Qt] = !1, this[g$1] = !0, this.emit("resume"), this[b$1].length ? this[De]() : this[q] ? this[Q]() : this.emit("drain"));
|
|
163
|
-
}
|
|
164
|
-
resume() {
|
|
165
|
-
return this[Bt]();
|
|
166
|
-
}
|
|
167
|
-
pause() {
|
|
168
|
-
this[g$1] = !1, this[Qt] = !0, this[F] = !1;
|
|
169
|
-
}
|
|
170
|
-
get destroyed() {
|
|
171
|
-
return this[w$1];
|
|
172
|
-
}
|
|
173
|
-
get flowing() {
|
|
174
|
-
return this[g$1];
|
|
175
|
-
}
|
|
176
|
-
get paused() {
|
|
177
|
-
return this[Qt];
|
|
178
|
-
}
|
|
179
|
-
[gi](t) {
|
|
180
|
-
this[L] ? this[_$1] += 1 : this[_$1] += t.length, this[b$1].push(t);
|
|
181
|
-
}
|
|
182
|
-
[Ae]() {
|
|
183
|
-
return this[L] ? this[_$1] -= 1 : this[_$1] -= this[b$1][0].length, this[b$1].shift();
|
|
184
|
-
}
|
|
185
|
-
[De](t = !1) {
|
|
186
|
-
do ;
|
|
187
|
-
while (this[Ns](this[Ae]()) && this[b$1].length);
|
|
188
|
-
!t && !this[b$1].length && !this[q] && this.emit("drain");
|
|
189
|
-
}
|
|
190
|
-
[Ns](t) {
|
|
191
|
-
return this.emit("data", t), this[g$1];
|
|
192
|
-
}
|
|
193
|
-
pipe(t, e) {
|
|
194
|
-
if (this[w$1]) return t;
|
|
195
|
-
this[F] = !1;
|
|
196
|
-
let i = this[rt];
|
|
197
|
-
return e = e || {}, t === xs.stdout || t === xs.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, i ? e.end && t.end() : (this[D$1].push(e.proxyErrors ? new xi(this, t, e) : new Fe(this, t, e)), this[Z] ? jt(() => this[Bt]()) : this[Bt]()), t;
|
|
198
|
-
}
|
|
199
|
-
unpipe(t) {
|
|
200
|
-
let e = this[D$1].find((i) => i.dest === t);
|
|
201
|
-
e && (this[D$1].length === 1 ? (this[g$1] && this[Rt] === 0 && (this[g$1] = !1), this[D$1] = []) : this[D$1].splice(this[D$1].indexOf(e), 1), e.unpipe());
|
|
202
|
-
}
|
|
203
|
-
addListener(t, e) {
|
|
204
|
-
return this.on(t, e);
|
|
205
|
-
}
|
|
206
|
-
on(t, e) {
|
|
207
|
-
let i = super.on(t, e);
|
|
208
|
-
if (t === "data") this[F] = !1, this[Rt]++, !this[D$1].length && !this[g$1] && this[Bt]();
|
|
209
|
-
else if (t === "readable" && this[_$1] !== 0) super.emit("readable");
|
|
210
|
-
else if (Gr(t) && this[rt]) super.emit(t), this.removeAllListeners(t);
|
|
211
|
-
else if (t === "error" && this[qt]) {
|
|
212
|
-
let r = e;
|
|
213
|
-
this[Z] ? jt(() => r.call(this, this[qt])) : r.call(this, this[qt]);
|
|
214
|
-
}
|
|
215
|
-
return i;
|
|
216
|
-
}
|
|
217
|
-
removeListener(t, e) {
|
|
218
|
-
return this.off(t, e);
|
|
219
|
-
}
|
|
220
|
-
off(t, e) {
|
|
221
|
-
let i = super.off(t, e);
|
|
222
|
-
return t === "data" && (this[Rt] = this.listeners("data").length, this[Rt] === 0 && !this[F] && !this[D$1].length && (this[g$1] = !1)), i;
|
|
223
|
-
}
|
|
224
|
-
removeAllListeners(t) {
|
|
225
|
-
let e = super.removeAllListeners(t);
|
|
226
|
-
return (t === "data" || t === void 0) && (this[Rt] = 0, !this[F] && !this[D$1].length && (this[g$1] = !1)), e;
|
|
227
|
-
}
|
|
228
|
-
get emittedEnd() {
|
|
229
|
-
return this[rt];
|
|
230
|
-
}
|
|
231
|
-
[Q]() {
|
|
232
|
-
!this[Le] && !this[rt] && !this[w$1] && this[b$1].length === 0 && this[q] && (this[Le] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Ne] && this.emit("close"), this[Le] = !1);
|
|
233
|
-
}
|
|
234
|
-
emit(t, ...e) {
|
|
235
|
-
let i = e[0];
|
|
236
|
-
if (t !== "error" && t !== "close" && t !== w$1 && this[w$1]) return !1;
|
|
237
|
-
if (t === "data") return !this[L] && !i ? !1 : this[Z] ? (jt(() => this[_i](i)), !0) : this[_i](i);
|
|
238
|
-
if (t === "end") return this[Ds]();
|
|
239
|
-
if (t === "close") {
|
|
240
|
-
if (this[Ne] = !0, !this[rt] && !this[w$1]) return !1;
|
|
241
|
-
let n = super.emit("close");
|
|
242
|
-
return this.removeAllListeners("close"), n;
|
|
243
|
-
} else if (t === "error") {
|
|
244
|
-
this[qt] = i, super.emit(bi, i);
|
|
245
|
-
let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : !1;
|
|
246
|
-
return this[Q](), n;
|
|
247
|
-
} else if (t === "resume") {
|
|
248
|
-
let n = super.emit("resume");
|
|
249
|
-
return this[Q](), n;
|
|
250
|
-
} else if (t === "finish" || t === "prefinish") {
|
|
251
|
-
let n = super.emit(t);
|
|
252
|
-
return this.removeAllListeners(t), n;
|
|
253
|
-
}
|
|
254
|
-
let r = super.emit(t, ...e);
|
|
255
|
-
return this[Q](), r;
|
|
256
|
-
}
|
|
257
|
-
[_i](t) {
|
|
258
|
-
for (let i of this[D$1]) i.dest.write(t) === !1 && this.pause();
|
|
259
|
-
let e = this[F] ? !1 : super.emit("data", t);
|
|
260
|
-
return this[Q](), e;
|
|
261
|
-
}
|
|
262
|
-
[Ds]() {
|
|
263
|
-
return this[rt] ? !1 : (this[rt] = !0, this.readable = !1, this[Z] ? (jt(() => this[Oi]()), !0) : this[Oi]());
|
|
264
|
-
}
|
|
265
|
-
[Oi]() {
|
|
266
|
-
if (this[Mt]) {
|
|
267
|
-
let e = this[Mt].end();
|
|
268
|
-
if (e) {
|
|
269
|
-
for (let i of this[D$1]) i.dest.write(e);
|
|
270
|
-
this[F] || super.emit("data", e);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
for (let e of this[D$1]) e.end();
|
|
274
|
-
let t = super.emit("end");
|
|
275
|
-
return this.removeAllListeners("end"), t;
|
|
276
|
-
}
|
|
277
|
-
async collect() {
|
|
278
|
-
let t = Object.assign([], { dataLength: 0 });
|
|
279
|
-
this[L] || (t.dataLength = 0);
|
|
280
|
-
let e = this.promise();
|
|
281
|
-
return this.on("data", (i) => {
|
|
282
|
-
t.push(i), this[L] || (t.dataLength += i.length);
|
|
283
|
-
}), await e, t;
|
|
284
|
-
}
|
|
285
|
-
async concat() {
|
|
286
|
-
if (this[L]) throw new Error("cannot concat in objectMode");
|
|
287
|
-
let t = await this.collect();
|
|
288
|
-
return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
|
|
289
|
-
}
|
|
290
|
-
async promise() {
|
|
291
|
-
return new Promise((t, e) => {
|
|
292
|
-
this.on(w$1, () => e(/* @__PURE__ */ new Error("stream destroyed"))), this.on("error", (i) => e(i)), this.on("end", () => t());
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
[Symbol.asyncIterator]() {
|
|
296
|
-
this[F] = !1;
|
|
297
|
-
let t = !1, e = async () => (this.pause(), t = !0, {
|
|
298
|
-
value: void 0,
|
|
299
|
-
done: !0
|
|
300
|
-
});
|
|
301
|
-
return {
|
|
302
|
-
next: () => {
|
|
303
|
-
if (t) return e();
|
|
304
|
-
let r = this.read();
|
|
305
|
-
if (r !== null) return Promise.resolve({
|
|
306
|
-
done: !1,
|
|
307
|
-
value: r
|
|
308
|
-
});
|
|
309
|
-
if (this[q]) return e();
|
|
310
|
-
let n, o, a = (d) => {
|
|
311
|
-
this.off("data", h), this.off("end", l), this.off(w$1, c), e(), o(d);
|
|
312
|
-
}, h = (d) => {
|
|
313
|
-
this.off("error", a), this.off("end", l), this.off(w$1, c), this.pause(), n({
|
|
314
|
-
value: d,
|
|
315
|
-
done: !!this[q]
|
|
316
|
-
});
|
|
317
|
-
}, l = () => {
|
|
318
|
-
this.off("error", a), this.off("data", h), this.off(w$1, c), e(), n({
|
|
319
|
-
done: !0,
|
|
320
|
-
value: void 0
|
|
321
|
-
});
|
|
322
|
-
}, c = () => a(/* @__PURE__ */ new Error("stream destroyed"));
|
|
323
|
-
return new Promise((d, S) => {
|
|
324
|
-
o = S, n = d, this.once(w$1, c), this.once("error", a), this.once("end", l), this.once("data", h);
|
|
325
|
-
});
|
|
326
|
-
},
|
|
327
|
-
throw: e,
|
|
328
|
-
return: e,
|
|
329
|
-
[Symbol.asyncIterator]() {
|
|
330
|
-
return this;
|
|
331
|
-
},
|
|
332
|
-
[Symbol.asyncDispose]: async () => {}
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
[Symbol.iterator]() {
|
|
336
|
-
this[F] = !1;
|
|
337
|
-
let t = !1, e = () => (this.pause(), this.off(bi, e), this.off(w$1, e), this.off("end", e), t = !0, {
|
|
338
|
-
done: !0,
|
|
339
|
-
value: void 0
|
|
340
|
-
}), i = () => {
|
|
341
|
-
if (t) return e();
|
|
342
|
-
let r = this.read();
|
|
343
|
-
return r === null ? e() : {
|
|
344
|
-
done: !1,
|
|
345
|
-
value: r
|
|
346
|
-
};
|
|
347
|
-
};
|
|
348
|
-
return this.once("end", e), this.once(bi, e), this.once(w$1, e), {
|
|
349
|
-
next: i,
|
|
350
|
-
throw: e,
|
|
351
|
-
return: e,
|
|
352
|
-
[Symbol.iterator]() {
|
|
353
|
-
return this;
|
|
354
|
-
},
|
|
355
|
-
[Symbol.dispose]: () => {}
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
destroy(t) {
|
|
359
|
-
if (this[w$1]) return t ? this.emit("error", t) : this.emit(w$1), this;
|
|
360
|
-
this[w$1] = !0, this[F] = !0, this[b$1].length = 0, this[_$1] = 0;
|
|
361
|
-
let e = this;
|
|
362
|
-
return typeof e.close == "function" && !this[Ne] && e.close(), t ? this.emit("error", t) : this.emit(w$1), this;
|
|
363
|
-
}
|
|
364
|
-
static get isStream() {
|
|
365
|
-
return zr;
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
var Xr = fs.default.writev, ot = Symbol("_autoClose"), H = Symbol("_close"), te = Symbol("_ended"), m$1 = Symbol("_fd"), Ni = Symbol("_finished"), j = Symbol("_flags"), Di = Symbol("_flush"), Ci = Symbol("_handleChunk"), ki = Symbol("_makeBuf"), ie = Symbol("_mode"), Ce = Symbol("_needDrain"), Ut = Symbol("_onerror"), Ht = Symbol("_onopen"), Ai = Symbol("_onread"), Pt = Symbol("_onwrite"), ht = Symbol("_open"), U = Symbol("_path"), nt = Symbol("_pos"), Y = Symbol("_queue"), zt = Symbol("_read"), Ii = Symbol("_readSize"), J = Symbol("_reading"), ee = Symbol("_remain"), Fi = Symbol("_size"), ke = Symbol("_write"), gt = Symbol("_writing"), ve = Symbol("_defaultFlag"), bt = Symbol("_errored"), _t = class extends A$1 {
|
|
369
|
-
[bt] = !1;
|
|
370
|
-
[m$1];
|
|
371
|
-
[U];
|
|
372
|
-
[Ii];
|
|
373
|
-
[J] = !1;
|
|
374
|
-
[Fi];
|
|
375
|
-
[ee];
|
|
376
|
-
[ot];
|
|
377
|
-
constructor(t, e) {
|
|
378
|
-
if (e = e || {}, super(e), this.readable = !0, this.writable = !1, typeof t != "string") throw new TypeError("path must be a string");
|
|
379
|
-
this[bt] = !1, this[m$1] = typeof e.fd == "number" ? e.fd : void 0, this[U] = t, this[Ii] = e.readSize || 16 * 1024 * 1024, this[J] = !1, this[Fi] = typeof e.size == "number" ? e.size : Infinity, this[ee] = this[Fi], this[ot] = typeof e.autoClose == "boolean" ? e.autoClose : !0, typeof this[m$1] == "number" ? this[zt]() : this[ht]();
|
|
380
|
-
}
|
|
381
|
-
get fd() {
|
|
382
|
-
return this[m$1];
|
|
383
|
-
}
|
|
384
|
-
get path() {
|
|
385
|
-
return this[U];
|
|
386
|
-
}
|
|
387
|
-
write() {
|
|
388
|
-
throw new TypeError("this is a readable stream");
|
|
389
|
-
}
|
|
390
|
-
end() {
|
|
391
|
-
throw new TypeError("this is a readable stream");
|
|
392
|
-
}
|
|
393
|
-
[ht]() {
|
|
394
|
-
fs.default.open(this[U], "r", (t, e) => this[Ht](t, e));
|
|
395
|
-
}
|
|
396
|
-
[Ht](t, e) {
|
|
397
|
-
t ? this[Ut](t) : (this[m$1] = e, this.emit("open", e), this[zt]());
|
|
398
|
-
}
|
|
399
|
-
[ki]() {
|
|
400
|
-
return Buffer.allocUnsafe(Math.min(this[Ii], this[ee]));
|
|
401
|
-
}
|
|
402
|
-
[zt]() {
|
|
403
|
-
if (!this[J]) {
|
|
404
|
-
this[J] = !0;
|
|
405
|
-
let t = this[ki]();
|
|
406
|
-
if (t.length === 0) return process.nextTick(() => this[Ai](null, 0, t));
|
|
407
|
-
fs.default.read(this[m$1], t, 0, t.length, null, (e, i, r) => this[Ai](e, i, r));
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
[Ai](t, e, i) {
|
|
411
|
-
this[J] = !1, t ? this[Ut](t) : this[Ci](e, i) && this[zt]();
|
|
412
|
-
}
|
|
413
|
-
[H]() {
|
|
414
|
-
if (this[ot] && typeof this[m$1] == "number") {
|
|
415
|
-
let t = this[m$1];
|
|
416
|
-
this[m$1] = void 0, fs.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
[Ut](t) {
|
|
420
|
-
this[J] = !0, this[H](), this.emit("error", t);
|
|
421
|
-
}
|
|
422
|
-
[Ci](t, e) {
|
|
423
|
-
let i = !1;
|
|
424
|
-
return this[ee] -= t, t > 0 && (i = super.write(t < e.length ? e.subarray(0, t) : e)), (t === 0 || this[ee] <= 0) && (i = !1, this[H](), super.end()), i;
|
|
425
|
-
}
|
|
426
|
-
emit(t, ...e) {
|
|
427
|
-
switch (t) {
|
|
428
|
-
case "prefinish":
|
|
429
|
-
case "finish": return !1;
|
|
430
|
-
case "drain": return typeof this[m$1] == "number" && this[zt](), !1;
|
|
431
|
-
case "error": return this[bt] ? !1 : (this[bt] = !0, super.emit(t, ...e));
|
|
432
|
-
default: return super.emit(t, ...e);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}, Me = class extends _t {
|
|
436
|
-
[ht]() {
|
|
437
|
-
let t = !0;
|
|
438
|
-
try {
|
|
439
|
-
this[Ht](null, fs.default.openSync(this[U], "r")), t = !1;
|
|
440
|
-
} finally {
|
|
441
|
-
t && this[H]();
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
[zt]() {
|
|
445
|
-
let t = !0;
|
|
446
|
-
try {
|
|
447
|
-
if (!this[J]) {
|
|
448
|
-
this[J] = !0;
|
|
449
|
-
do {
|
|
450
|
-
let e = this[ki](), i = e.length === 0 ? 0 : fs.default.readSync(this[m$1], e, 0, e.length, null);
|
|
451
|
-
if (!this[Ci](i, e)) break;
|
|
452
|
-
} while (!0);
|
|
453
|
-
this[J] = !1;
|
|
454
|
-
}
|
|
455
|
-
t = !1;
|
|
456
|
-
} finally {
|
|
457
|
-
t && this[H]();
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
[H]() {
|
|
461
|
-
if (this[ot] && typeof this[m$1] == "number") {
|
|
462
|
-
let t = this[m$1];
|
|
463
|
-
this[m$1] = void 0, fs.default.closeSync(t), this.emit("close");
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}, tt = class extends events.default {
|
|
467
|
-
readable = !1;
|
|
468
|
-
writable = !0;
|
|
469
|
-
[bt] = !1;
|
|
470
|
-
[gt] = !1;
|
|
471
|
-
[te] = !1;
|
|
472
|
-
[Y] = [];
|
|
473
|
-
[Ce] = !1;
|
|
474
|
-
[U];
|
|
475
|
-
[ie];
|
|
476
|
-
[ot];
|
|
477
|
-
[m$1];
|
|
478
|
-
[ve];
|
|
479
|
-
[j];
|
|
480
|
-
[Ni] = !1;
|
|
481
|
-
[nt];
|
|
482
|
-
constructor(t, e) {
|
|
483
|
-
e = e || {}, super(e), this[U] = t, this[m$1] = typeof e.fd == "number" ? e.fd : void 0, this[ie] = e.mode === void 0 ? 438 : e.mode, this[nt] = typeof e.start == "number" ? e.start : void 0, this[ot] = typeof e.autoClose == "boolean" ? e.autoClose : !0;
|
|
484
|
-
let i = this[nt] !== void 0 ? "r+" : "w";
|
|
485
|
-
this[ve] = e.flags === void 0, this[j] = e.flags === void 0 ? i : e.flags, this[m$1] === void 0 && this[ht]();
|
|
486
|
-
}
|
|
487
|
-
emit(t, ...e) {
|
|
488
|
-
if (t === "error") {
|
|
489
|
-
if (this[bt]) return !1;
|
|
490
|
-
this[bt] = !0;
|
|
491
|
-
}
|
|
492
|
-
return super.emit(t, ...e);
|
|
493
|
-
}
|
|
494
|
-
get fd() {
|
|
495
|
-
return this[m$1];
|
|
496
|
-
}
|
|
497
|
-
get path() {
|
|
498
|
-
return this[U];
|
|
499
|
-
}
|
|
500
|
-
[Ut](t) {
|
|
501
|
-
this[H](), this[gt] = !0, this.emit("error", t);
|
|
502
|
-
}
|
|
503
|
-
[ht]() {
|
|
504
|
-
fs.default.open(this[U], this[j], this[ie], (t, e) => this[Ht](t, e));
|
|
505
|
-
}
|
|
506
|
-
[Ht](t, e) {
|
|
507
|
-
this[ve] && this[j] === "r+" && t && t.code === "ENOENT" ? (this[j] = "w", this[ht]()) : t ? this[Ut](t) : (this[m$1] = e, this.emit("open", e), this[gt] || this[Di]());
|
|
508
|
-
}
|
|
509
|
-
end(t, e) {
|
|
510
|
-
return t && this.write(t, e), this[te] = !0, !this[gt] && !this[Y].length && typeof this[m$1] == "number" && this[Pt](null, 0), this;
|
|
511
|
-
}
|
|
512
|
-
write(t, e) {
|
|
513
|
-
return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", /* @__PURE__ */ new Error("write() after end()")), !1) : this[m$1] === void 0 || this[gt] || this[Y].length ? (this[Y].push(t), this[Ce] = !0, !1) : (this[gt] = !0, this[ke](t), !0);
|
|
514
|
-
}
|
|
515
|
-
[ke](t) {
|
|
516
|
-
fs.default.write(this[m$1], t, 0, t.length, this[nt], (e, i) => this[Pt](e, i));
|
|
517
|
-
}
|
|
518
|
-
[Pt](t, e) {
|
|
519
|
-
t ? this[Ut](t) : (this[nt] !== void 0 && typeof e == "number" && (this[nt] += e), this[Y].length ? this[Di]() : (this[gt] = !1, this[te] && !this[Ni] ? (this[Ni] = !0, this[H](), this.emit("finish")) : this[Ce] && (this[Ce] = !1, this.emit("drain"))));
|
|
520
|
-
}
|
|
521
|
-
[Di]() {
|
|
522
|
-
if (this[Y].length === 0) this[te] && this[Pt](null, 0);
|
|
523
|
-
else if (this[Y].length === 1) this[ke](this[Y].pop());
|
|
524
|
-
else {
|
|
525
|
-
let t = this[Y];
|
|
526
|
-
this[Y] = [], Xr(this[m$1], t, this[nt], (e, i) => this[Pt](e, i));
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
[H]() {
|
|
530
|
-
if (this[ot] && typeof this[m$1] == "number") {
|
|
531
|
-
let t = this[m$1];
|
|
532
|
-
this[m$1] = void 0, fs.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}, Wt = class extends tt {
|
|
536
|
-
[ht]() {
|
|
537
|
-
let t;
|
|
538
|
-
if (this[ve] && this[j] === "r+") try {
|
|
539
|
-
t = fs.default.openSync(this[U], this[j], this[ie]);
|
|
540
|
-
} catch (e) {
|
|
541
|
-
if (e?.code === "ENOENT") return this[j] = "w", this[ht]();
|
|
542
|
-
throw e;
|
|
543
|
-
}
|
|
544
|
-
else t = fs.default.openSync(this[U], this[j], this[ie]);
|
|
545
|
-
this[Ht](null, t);
|
|
546
|
-
}
|
|
547
|
-
[H]() {
|
|
548
|
-
if (this[ot] && typeof this[m$1] == "number") {
|
|
549
|
-
let t = this[m$1];
|
|
550
|
-
this[m$1] = void 0, fs.default.closeSync(t), this.emit("close");
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
[ke](t) {
|
|
554
|
-
let e = !0;
|
|
555
|
-
try {
|
|
556
|
-
this[Pt](null, fs.default.writeSync(this[m$1], t, 0, t.length, this[nt])), e = !1;
|
|
557
|
-
} finally {
|
|
558
|
-
if (e) try {
|
|
559
|
-
this[H]();
|
|
560
|
-
} catch {}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
var qr = new Map([
|
|
565
|
-
["C", "cwd"],
|
|
566
|
-
["f", "file"],
|
|
567
|
-
["z", "gzip"],
|
|
568
|
-
["P", "preservePaths"],
|
|
569
|
-
["U", "unlink"],
|
|
570
|
-
["strip-components", "strip"],
|
|
571
|
-
["stripComponents", "strip"],
|
|
572
|
-
["keep-newer", "newer"],
|
|
573
|
-
["keepNewer", "newer"],
|
|
574
|
-
["keep-newer-files", "newer"],
|
|
575
|
-
["keepNewerFiles", "newer"],
|
|
576
|
-
["k", "keep"],
|
|
577
|
-
["keep-existing", "keep"],
|
|
578
|
-
["keepExisting", "keep"],
|
|
579
|
-
["m", "noMtime"],
|
|
580
|
-
["no-mtime", "noMtime"],
|
|
581
|
-
["p", "preserveOwner"],
|
|
582
|
-
["L", "follow"],
|
|
583
|
-
["h", "follow"],
|
|
584
|
-
["onentry", "onReadEntry"]
|
|
585
|
-
]), Is = (s) => !!s.sync && !!s.file, Fs = (s) => !s.sync && !!s.file, Cs = (s) => !!s.sync && !s.file, ks = (s) => !s.sync && !s.file;
|
|
586
|
-
var vs = (s) => !!s.file;
|
|
587
|
-
var Qr = (s) => {
|
|
588
|
-
return qr.get(s) || s;
|
|
589
|
-
}, se = (s = {}) => {
|
|
590
|
-
if (!s) return {};
|
|
591
|
-
let t = {};
|
|
592
|
-
for (let [e, i] of Object.entries(s)) {
|
|
593
|
-
let r = Qr(e);
|
|
594
|
-
t[r] = i;
|
|
595
|
-
}
|
|
596
|
-
return t.chmod === void 0 && t.noChmod === !1 && (t.chmod = !0), delete t.noChmod, t;
|
|
597
|
-
};
|
|
598
|
-
var K = (s, t, e, i, r) => Object.assign((n = [], o, a) => {
|
|
599
|
-
Array.isArray(n) && (o = n, n = {}), typeof o == "function" && (a = o, o = void 0), o = o ? Array.from(o) : [];
|
|
600
|
-
let h = se(n);
|
|
601
|
-
if (r?.(h, o), Is(h)) {
|
|
602
|
-
if (typeof a == "function") throw new TypeError("callback not supported for sync tar functions");
|
|
603
|
-
return s(h, o);
|
|
604
|
-
} else if (Fs(h)) {
|
|
605
|
-
let l = t(h, o);
|
|
606
|
-
return a ? l.then(() => a(), a) : l;
|
|
607
|
-
} else if (Cs(h)) {
|
|
608
|
-
if (typeof a == "function") throw new TypeError("callback not supported for sync tar functions");
|
|
609
|
-
return e(h, o);
|
|
610
|
-
} else if (ks(h)) {
|
|
611
|
-
if (typeof a == "function") throw new TypeError("callback only supported with file option");
|
|
612
|
-
return i(h, o);
|
|
613
|
-
}
|
|
614
|
-
throw new Error("impossible options??");
|
|
615
|
-
}, {
|
|
616
|
-
syncFile: s,
|
|
617
|
-
asyncFile: t,
|
|
618
|
-
syncNoFile: e,
|
|
619
|
-
asyncNoFile: i,
|
|
620
|
-
validate: r
|
|
621
|
-
});
|
|
622
|
-
var jr = zlib.default.constants || { ZLIB_VERNUM: 4736 }, M = Object.freeze(Object.assign(Object.create(null), {
|
|
623
|
-
Z_NO_FLUSH: 0,
|
|
624
|
-
Z_PARTIAL_FLUSH: 1,
|
|
625
|
-
Z_SYNC_FLUSH: 2,
|
|
626
|
-
Z_FULL_FLUSH: 3,
|
|
627
|
-
Z_FINISH: 4,
|
|
628
|
-
Z_BLOCK: 5,
|
|
629
|
-
Z_OK: 0,
|
|
630
|
-
Z_STREAM_END: 1,
|
|
631
|
-
Z_NEED_DICT: 2,
|
|
632
|
-
Z_ERRNO: -1,
|
|
633
|
-
Z_STREAM_ERROR: -2,
|
|
634
|
-
Z_DATA_ERROR: -3,
|
|
635
|
-
Z_MEM_ERROR: -4,
|
|
636
|
-
Z_BUF_ERROR: -5,
|
|
637
|
-
Z_VERSION_ERROR: -6,
|
|
638
|
-
Z_NO_COMPRESSION: 0,
|
|
639
|
-
Z_BEST_SPEED: 1,
|
|
640
|
-
Z_BEST_COMPRESSION: 9,
|
|
641
|
-
Z_DEFAULT_COMPRESSION: -1,
|
|
642
|
-
Z_FILTERED: 1,
|
|
643
|
-
Z_HUFFMAN_ONLY: 2,
|
|
644
|
-
Z_RLE: 3,
|
|
645
|
-
Z_FIXED: 4,
|
|
646
|
-
Z_DEFAULT_STRATEGY: 0,
|
|
647
|
-
DEFLATE: 1,
|
|
648
|
-
INFLATE: 2,
|
|
649
|
-
GZIP: 3,
|
|
650
|
-
GUNZIP: 4,
|
|
651
|
-
DEFLATERAW: 5,
|
|
652
|
-
INFLATERAW: 6,
|
|
653
|
-
UNZIP: 7,
|
|
654
|
-
BROTLI_DECODE: 8,
|
|
655
|
-
BROTLI_ENCODE: 9,
|
|
656
|
-
Z_MIN_WINDOWBITS: 8,
|
|
657
|
-
Z_MAX_WINDOWBITS: 15,
|
|
658
|
-
Z_DEFAULT_WINDOWBITS: 15,
|
|
659
|
-
Z_MIN_CHUNK: 64,
|
|
660
|
-
Z_MAX_CHUNK: Infinity,
|
|
661
|
-
Z_DEFAULT_CHUNK: 16384,
|
|
662
|
-
Z_MIN_MEMLEVEL: 1,
|
|
663
|
-
Z_MAX_MEMLEVEL: 9,
|
|
664
|
-
Z_DEFAULT_MEMLEVEL: 8,
|
|
665
|
-
Z_MIN_LEVEL: -1,
|
|
666
|
-
Z_MAX_LEVEL: 9,
|
|
667
|
-
Z_DEFAULT_LEVEL: -1,
|
|
668
|
-
BROTLI_OPERATION_PROCESS: 0,
|
|
669
|
-
BROTLI_OPERATION_FLUSH: 1,
|
|
670
|
-
BROTLI_OPERATION_FINISH: 2,
|
|
671
|
-
BROTLI_OPERATION_EMIT_METADATA: 3,
|
|
672
|
-
BROTLI_MODE_GENERIC: 0,
|
|
673
|
-
BROTLI_MODE_TEXT: 1,
|
|
674
|
-
BROTLI_MODE_FONT: 2,
|
|
675
|
-
BROTLI_DEFAULT_MODE: 0,
|
|
676
|
-
BROTLI_MIN_QUALITY: 0,
|
|
677
|
-
BROTLI_MAX_QUALITY: 11,
|
|
678
|
-
BROTLI_DEFAULT_QUALITY: 11,
|
|
679
|
-
BROTLI_MIN_WINDOW_BITS: 10,
|
|
680
|
-
BROTLI_MAX_WINDOW_BITS: 24,
|
|
681
|
-
BROTLI_LARGE_MAX_WINDOW_BITS: 30,
|
|
682
|
-
BROTLI_DEFAULT_WINDOW: 22,
|
|
683
|
-
BROTLI_MIN_INPUT_BLOCK_BITS: 16,
|
|
684
|
-
BROTLI_MAX_INPUT_BLOCK_BITS: 24,
|
|
685
|
-
BROTLI_PARAM_MODE: 0,
|
|
686
|
-
BROTLI_PARAM_QUALITY: 1,
|
|
687
|
-
BROTLI_PARAM_LGWIN: 2,
|
|
688
|
-
BROTLI_PARAM_LGBLOCK: 3,
|
|
689
|
-
BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
|
|
690
|
-
BROTLI_PARAM_SIZE_HINT: 5,
|
|
691
|
-
BROTLI_PARAM_LARGE_WINDOW: 6,
|
|
692
|
-
BROTLI_PARAM_NPOSTFIX: 7,
|
|
693
|
-
BROTLI_PARAM_NDIRECT: 8,
|
|
694
|
-
BROTLI_DECODER_RESULT_ERROR: 0,
|
|
695
|
-
BROTLI_DECODER_RESULT_SUCCESS: 1,
|
|
696
|
-
BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
|
|
697
|
-
BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
|
|
698
|
-
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
|
|
699
|
-
BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
|
|
700
|
-
BROTLI_DECODER_NO_ERROR: 0,
|
|
701
|
-
BROTLI_DECODER_SUCCESS: 1,
|
|
702
|
-
BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
|
|
703
|
-
BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
|
|
704
|
-
BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
|
|
705
|
-
BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
|
|
706
|
-
BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
|
|
707
|
-
BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
|
|
708
|
-
BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
|
|
709
|
-
BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
|
|
710
|
-
BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
|
|
711
|
-
BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
|
|
712
|
-
BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
|
|
713
|
-
BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
|
|
714
|
-
BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
|
|
715
|
-
BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
|
|
716
|
-
BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
|
|
717
|
-
BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
|
|
718
|
-
BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
|
|
719
|
-
BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
|
|
720
|
-
BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
|
|
721
|
-
BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
|
|
722
|
-
BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
|
|
723
|
-
BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
|
|
724
|
-
BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
|
|
725
|
-
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
|
|
726
|
-
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
|
|
727
|
-
BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
|
|
728
|
-
BROTLI_DECODER_ERROR_UNREACHABLE: -31
|
|
729
|
-
}, jr));
|
|
730
|
-
var tn = buffer.Buffer.concat, Bs = Object.getOwnPropertyDescriptor(buffer.Buffer, "concat"), en = (s) => s, Mi = Bs?.writable === !0 || Bs?.set !== void 0 ? (s) => {
|
|
731
|
-
buffer.Buffer.concat = s ? en : tn;
|
|
732
|
-
} : (s) => {}, Tt = Symbol("_superWrite"), Gt = class extends Error {
|
|
733
|
-
code;
|
|
734
|
-
errno;
|
|
735
|
-
constructor(t, e) {
|
|
736
|
-
super("zlib: " + t.message, { cause: t }), this.code = t.code, this.errno = t.errno, this.code || (this.code = "ZLIB_ERROR"), this.message = "zlib: " + t.message, Error.captureStackTrace(this, e ?? this.constructor);
|
|
737
|
-
}
|
|
738
|
-
get name() {
|
|
739
|
-
return "ZlibError";
|
|
740
|
-
}
|
|
741
|
-
}, Bi = Symbol("flushFlag"), re = class extends A$1 {
|
|
742
|
-
#t = !1;
|
|
743
|
-
#i = !1;
|
|
744
|
-
#s;
|
|
745
|
-
#n;
|
|
746
|
-
#r;
|
|
747
|
-
#e;
|
|
748
|
-
#o;
|
|
749
|
-
get sawError() {
|
|
750
|
-
return this.#t;
|
|
751
|
-
}
|
|
752
|
-
get handle() {
|
|
753
|
-
return this.#e;
|
|
754
|
-
}
|
|
755
|
-
get flushFlag() {
|
|
756
|
-
return this.#s;
|
|
757
|
-
}
|
|
758
|
-
constructor(t, e) {
|
|
759
|
-
if (!t || typeof t != "object") throw new TypeError("invalid options for ZlibBase constructor");
|
|
760
|
-
if (super(t), this.#s = t.flush ?? 0, this.#n = t.finishFlush ?? 0, this.#r = t.fullFlushFlag ?? 0, typeof zlib[e] != "function") throw new TypeError("Compression method not supported: " + e);
|
|
761
|
-
try {
|
|
762
|
-
this.#e = new zlib[e](t);
|
|
763
|
-
} catch (i) {
|
|
764
|
-
throw new Gt(i, this.constructor);
|
|
765
|
-
}
|
|
766
|
-
this.#o = (i) => {
|
|
767
|
-
this.#t || (this.#t = !0, this.close(), this.emit("error", i));
|
|
768
|
-
}, this.#e?.on("error", (i) => this.#o(new Gt(i))), this.once("end", () => this.close);
|
|
769
|
-
}
|
|
770
|
-
close() {
|
|
771
|
-
this.#e && (this.#e.close(), this.#e = void 0, this.emit("close"));
|
|
772
|
-
}
|
|
773
|
-
reset() {
|
|
774
|
-
if (!this.#t) return (0, assert.default)(this.#e, "zlib binding closed"), this.#e.reset?.();
|
|
775
|
-
}
|
|
776
|
-
flush(t) {
|
|
777
|
-
this.ended || (typeof t != "number" && (t = this.#r), this.write(Object.assign(buffer.Buffer.alloc(0), { [Bi]: t })));
|
|
778
|
-
}
|
|
779
|
-
end(t, e, i) {
|
|
780
|
-
return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), t && (e ? this.write(t, e) : this.write(t)), this.flush(this.#n), this.#i = !0, super.end(i);
|
|
781
|
-
}
|
|
782
|
-
get ended() {
|
|
783
|
-
return this.#i;
|
|
784
|
-
}
|
|
785
|
-
[Tt](t) {
|
|
786
|
-
return super.write(t);
|
|
787
|
-
}
|
|
788
|
-
write(t, e, i) {
|
|
789
|
-
if (typeof e == "function" && (i = e, e = "utf8"), typeof t == "string" && (t = buffer.Buffer.from(t, e)), this.#t) return;
|
|
790
|
-
(0, assert.default)(this.#e, "zlib binding closed");
|
|
791
|
-
let r = this.#e._handle, n = r.close;
|
|
792
|
-
r.close = () => {};
|
|
793
|
-
let o = this.#e.close;
|
|
794
|
-
this.#e.close = () => {}, Mi(!0);
|
|
795
|
-
let a;
|
|
796
|
-
try {
|
|
797
|
-
let l = typeof t[Bi] == "number" ? t[Bi] : this.#s;
|
|
798
|
-
a = this.#e._processChunk(t, l), Mi(!1);
|
|
799
|
-
} catch (l) {
|
|
800
|
-
Mi(!1), this.#o(new Gt(l, this.write));
|
|
801
|
-
} finally {
|
|
802
|
-
this.#e && (this.#e._handle = r, r.close = n, this.#e.close = o, this.#e.removeAllListeners("error"));
|
|
803
|
-
}
|
|
804
|
-
this.#e && this.#e.on("error", (l) => this.#o(new Gt(l, this.write)));
|
|
805
|
-
let h;
|
|
806
|
-
if (a) if (Array.isArray(a) && a.length > 0) {
|
|
807
|
-
let l = a[0];
|
|
808
|
-
h = this[Tt](buffer.Buffer.from(l));
|
|
809
|
-
for (let c = 1; c < a.length; c++) h = this[Tt](a[c]);
|
|
810
|
-
} else h = this[Tt](buffer.Buffer.from(a));
|
|
811
|
-
return i && i(), h;
|
|
812
|
-
}
|
|
813
|
-
}, Be = class extends re {
|
|
814
|
-
#t;
|
|
815
|
-
#i;
|
|
816
|
-
constructor(t, e) {
|
|
817
|
-
t = t || {}, t.flush = t.flush || M.Z_NO_FLUSH, t.finishFlush = t.finishFlush || M.Z_FINISH, t.fullFlushFlag = M.Z_FULL_FLUSH, super(t, e), this.#t = t.level, this.#i = t.strategy;
|
|
818
|
-
}
|
|
819
|
-
params(t, e) {
|
|
820
|
-
if (!this.sawError) {
|
|
821
|
-
if (!this.handle) throw new Error("cannot switch params when binding is closed");
|
|
822
|
-
if (!this.handle.params) throw new Error("not supported in this implementation");
|
|
823
|
-
if (this.#t !== t || this.#i !== e) {
|
|
824
|
-
this.flush(M.Z_SYNC_FLUSH), (0, assert.default)(this.handle, "zlib binding closed");
|
|
825
|
-
let i = this.handle.flush;
|
|
826
|
-
this.handle.flush = (r, n) => {
|
|
827
|
-
typeof r == "function" && (n = r, r = this.flushFlag), this.flush(r), n?.();
|
|
828
|
-
};
|
|
829
|
-
try {
|
|
830
|
-
this.handle.params(t, e);
|
|
831
|
-
} finally {
|
|
832
|
-
this.handle.flush = i;
|
|
833
|
-
}
|
|
834
|
-
this.handle && (this.#t = t, this.#i = e);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
var Pe = class extends Be {
|
|
840
|
-
#t;
|
|
841
|
-
constructor(t) {
|
|
842
|
-
super(t, "Gzip"), this.#t = t && !!t.portable;
|
|
843
|
-
}
|
|
844
|
-
[Tt](t) {
|
|
845
|
-
return this.#t ? (this.#t = !1, t[9] = 255, super[Tt](t)) : super[Tt](t);
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
var ze = class extends Be {
|
|
849
|
-
constructor(t) {
|
|
850
|
-
super(t, "Unzip");
|
|
851
|
-
}
|
|
852
|
-
}, Ue = class extends re {
|
|
853
|
-
constructor(t, e) {
|
|
854
|
-
t = t || {}, t.flush = t.flush || M.BROTLI_OPERATION_PROCESS, t.finishFlush = t.finishFlush || M.BROTLI_OPERATION_FINISH, t.fullFlushFlag = M.BROTLI_OPERATION_FLUSH, super(t, e);
|
|
855
|
-
}
|
|
856
|
-
}, He = class extends Ue {
|
|
857
|
-
constructor(t) {
|
|
858
|
-
super(t, "BrotliCompress");
|
|
859
|
-
}
|
|
860
|
-
}, We = class extends Ue {
|
|
861
|
-
constructor(t) {
|
|
862
|
-
super(t, "BrotliDecompress");
|
|
863
|
-
}
|
|
864
|
-
}, Ge = class extends re {
|
|
865
|
-
constructor(t, e) {
|
|
866
|
-
t = t || {}, t.flush = t.flush || M.ZSTD_e_continue, t.finishFlush = t.finishFlush || M.ZSTD_e_end, t.fullFlushFlag = M.ZSTD_e_flush, super(t, e);
|
|
867
|
-
}
|
|
868
|
-
}, Ze = class extends Ge {
|
|
869
|
-
constructor(t) {
|
|
870
|
-
super(t, "ZstdCompress");
|
|
871
|
-
}
|
|
872
|
-
}, Ye = class extends Ge {
|
|
873
|
-
constructor(t) {
|
|
874
|
-
super(t, "ZstdDecompress");
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
var Ps = (s, t) => {
|
|
878
|
-
if (Number.isSafeInteger(s)) s < 0 ? nn(s, t) : rn(s, t);
|
|
879
|
-
else throw Error("cannot encode number outside of javascript safe integer range");
|
|
880
|
-
return t;
|
|
881
|
-
}, rn = (s, t) => {
|
|
882
|
-
t[0] = 128;
|
|
883
|
-
for (var e = t.length; e > 1; e--) t[e - 1] = s & 255, s = Math.floor(s / 256);
|
|
884
|
-
}, nn = (s, t) => {
|
|
885
|
-
t[0] = 255;
|
|
886
|
-
var e = !1;
|
|
887
|
-
s = s * -1;
|
|
888
|
-
for (var i = t.length; i > 1; i--) {
|
|
889
|
-
var r = s & 255;
|
|
890
|
-
s = Math.floor(s / 256), e ? t[i - 1] = Us(r) : r === 0 ? t[i - 1] = 0 : (e = !0, t[i - 1] = Hs(r));
|
|
891
|
-
}
|
|
892
|
-
}, zs = (s) => {
|
|
893
|
-
let t = s[0], e = t === 128 ? hn(s.subarray(1, s.length)) : t === 255 ? on(s) : null;
|
|
894
|
-
if (e === null) throw Error("invalid base256 encoding");
|
|
895
|
-
if (!Number.isSafeInteger(e)) throw Error("parsed number outside of javascript safe integer range");
|
|
896
|
-
return e;
|
|
897
|
-
}, on = (s) => {
|
|
898
|
-
for (var t = s.length, e = 0, i = !1, r = t - 1; r > -1; r--) {
|
|
899
|
-
var n = Number(s[r]), o;
|
|
900
|
-
i ? o = Us(n) : n === 0 ? o = n : (i = !0, o = Hs(n)), o !== 0 && (e -= o * Math.pow(256, t - r - 1));
|
|
901
|
-
}
|
|
902
|
-
return e;
|
|
903
|
-
}, hn = (s) => {
|
|
904
|
-
for (var t = s.length, e = 0, i = t - 1; i > -1; i--) {
|
|
905
|
-
var r = Number(s[i]);
|
|
906
|
-
r !== 0 && (e += r * Math.pow(256, t - i - 1));
|
|
907
|
-
}
|
|
908
|
-
return e;
|
|
909
|
-
}, Us = (s) => (255 ^ s) & 255, Hs = (s) => (255 ^ s) + 1 & 255;
|
|
910
|
-
Br({}, {
|
|
911
|
-
code: () => Ke,
|
|
912
|
-
isCode: () => ne,
|
|
913
|
-
isName: () => ln,
|
|
914
|
-
name: () => oe,
|
|
915
|
-
normalFsTypes: () => zi
|
|
916
|
-
});
|
|
917
|
-
var ne = (s) => oe.has(s), ln = (s) => Ke.has(s), zi = new Set([
|
|
918
|
-
"0",
|
|
919
|
-
"",
|
|
920
|
-
"1",
|
|
921
|
-
"2",
|
|
922
|
-
"3",
|
|
923
|
-
"4",
|
|
924
|
-
"5",
|
|
925
|
-
"6",
|
|
926
|
-
"7",
|
|
927
|
-
"D"
|
|
928
|
-
]), oe = new Map([
|
|
929
|
-
["0", "File"],
|
|
930
|
-
["", "OldFile"],
|
|
931
|
-
["1", "Link"],
|
|
932
|
-
["2", "SymbolicLink"],
|
|
933
|
-
["3", "CharacterDevice"],
|
|
934
|
-
["4", "BlockDevice"],
|
|
935
|
-
["5", "Directory"],
|
|
936
|
-
["6", "FIFO"],
|
|
937
|
-
["7", "ContiguousFile"],
|
|
938
|
-
["g", "GlobalExtendedHeader"],
|
|
939
|
-
["x", "ExtendedHeader"],
|
|
940
|
-
["A", "SolarisACL"],
|
|
941
|
-
["D", "GNUDumpDir"],
|
|
942
|
-
["I", "Inode"],
|
|
943
|
-
["K", "NextFileHasLongLinkpath"],
|
|
944
|
-
["L", "NextFileHasLongPath"],
|
|
945
|
-
["M", "ContinuationFile"],
|
|
946
|
-
["N", "OldGnuLongPath"],
|
|
947
|
-
["S", "SparseFile"],
|
|
948
|
-
["V", "TapeVolumeHeader"],
|
|
949
|
-
["X", "OldExtendedHeader"]
|
|
950
|
-
]), Ke = new Map(Array.from(oe).map((s) => [s[1], s[0]]));
|
|
951
|
-
var C$1 = class {
|
|
952
|
-
cksumValid = !1;
|
|
953
|
-
needPax = !1;
|
|
954
|
-
nullBlock = !1;
|
|
955
|
-
block;
|
|
956
|
-
path;
|
|
957
|
-
mode;
|
|
958
|
-
uid;
|
|
959
|
-
gid;
|
|
960
|
-
size;
|
|
961
|
-
cksum;
|
|
962
|
-
#t = "Unsupported";
|
|
963
|
-
linkpath;
|
|
964
|
-
uname;
|
|
965
|
-
gname;
|
|
966
|
-
devmaj = 0;
|
|
967
|
-
devmin = 0;
|
|
968
|
-
atime;
|
|
969
|
-
ctime;
|
|
970
|
-
mtime;
|
|
971
|
-
charset;
|
|
972
|
-
comment;
|
|
973
|
-
constructor(t, e = 0, i, r) {
|
|
974
|
-
Buffer.isBuffer(t) ? this.decode(t, e || 0, i, r) : t && this.#i(t);
|
|
975
|
-
}
|
|
976
|
-
decode(t, e, i, r) {
|
|
977
|
-
if (e || (e = 0), !t || !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
|
|
978
|
-
let n = xt(t, e + 156, 1), o = zi.has(n), a = o ? i : void 0, h = o ? r : void 0;
|
|
979
|
-
if (this.path = a?.path ?? xt(t, e, 100), this.mode = a?.mode ?? h?.mode ?? at(t, e + 100, 8), this.uid = a?.uid ?? h?.uid ?? at(t, e + 108, 8), this.gid = a?.gid ?? h?.gid ?? at(t, e + 116, 8), this.size = a?.size ?? h?.size ?? at(t, e + 124, 12), this.mtime = a?.mtime ?? h?.mtime ?? Hi(t, e + 136, 12), this.cksum = at(t, e + 148, 12), h && this.#i(h, !0), a && this.#i(a), ne(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = xt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000") if (this.uname = a?.uname ?? h?.uname ?? xt(t, e + 265, 32), this.gname = a?.gname ?? h?.gname ?? xt(t, e + 297, 32), this.devmaj = a?.devmaj ?? h?.devmaj ?? at(t, e + 329, 8) ?? 0, this.devmin = a?.devmin ?? h?.devmin ?? at(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
|
|
980
|
-
let c = xt(t, e + 345, 155);
|
|
981
|
-
this.path = c + "/" + this.path;
|
|
982
|
-
} else {
|
|
983
|
-
let c = xt(t, e + 345, 130);
|
|
984
|
-
c && (this.path = c + "/" + this.path), this.atime = i?.atime ?? r?.atime ?? Hi(t, e + 476, 12), this.ctime = i?.ctime ?? r?.ctime ?? Hi(t, e + 488, 12);
|
|
985
|
-
}
|
|
986
|
-
let l = 256;
|
|
987
|
-
for (let c = e; c < e + 148; c++) l += t[c];
|
|
988
|
-
for (let c = e + 156; c < e + 512; c++) l += t[c];
|
|
989
|
-
this.cksumValid = l === this.cksum, this.cksum === void 0 && l === 256 && (this.nullBlock = !0);
|
|
990
|
-
}
|
|
991
|
-
#i(t, e = !1) {
|
|
992
|
-
Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e || i === "linkpath" && e || i === "global"))));
|
|
993
|
-
}
|
|
994
|
-
encode(t, e = 0) {
|
|
995
|
-
if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
|
|
996
|
-
let i = this.ctime || this.atime ? 130 : 155, r = cn(this.path || "", i), n = r[0], o = r[1];
|
|
997
|
-
this.needPax = !!r[2], this.needPax = Lt(t, e, 100, n) || this.needPax, this.needPax = lt(t, e + 100, 8, this.mode) || this.needPax, this.needPax = lt(t, e + 108, 8, this.uid) || this.needPax, this.needPax = lt(t, e + 116, 8, this.gid) || this.needPax, this.needPax = lt(t, e + 124, 12, this.size) || this.needPax, this.needPax = Wi(t, e + 136, 12, this.mtime) || this.needPax, t[e + 156] = Number(this.#t.codePointAt(0)), this.needPax = Lt(t, e + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e + 257, 8), this.needPax = Lt(t, e + 265, 32, this.uname) || this.needPax, this.needPax = Lt(t, e + 297, 32, this.gname) || this.needPax, this.needPax = lt(t, e + 329, 8, this.devmaj) || this.needPax, this.needPax = lt(t, e + 337, 8, this.devmin) || this.needPax, this.needPax = Lt(t, e + 345, i, o) || this.needPax, t[e + 475] !== 0 ? this.needPax = Lt(t, e + 345, 155, o) || this.needPax : (this.needPax = Lt(t, e + 345, 130, o) || this.needPax, this.needPax = Wi(t, e + 476, 12, this.atime) || this.needPax, this.needPax = Wi(t, e + 488, 12, this.ctime) || this.needPax);
|
|
998
|
-
let a = 256;
|
|
999
|
-
for (let h = e; h < e + 148; h++) a += t[h];
|
|
1000
|
-
for (let h = e + 156; h < e + 512; h++) a += t[h];
|
|
1001
|
-
return this.cksum = a, lt(t, e + 148, 8, this.cksum), this.cksumValid = !0, this.needPax;
|
|
1002
|
-
}
|
|
1003
|
-
get type() {
|
|
1004
|
-
return this.#t === "Unsupported" ? this.#t : oe.get(this.#t);
|
|
1005
|
-
}
|
|
1006
|
-
get typeKey() {
|
|
1007
|
-
return this.#t;
|
|
1008
|
-
}
|
|
1009
|
-
set type(t) {
|
|
1010
|
-
let e = String(Ke.get(t));
|
|
1011
|
-
if (ne(e) || e === "Unsupported") this.#t = e;
|
|
1012
|
-
else if (ne(t)) this.#t = t;
|
|
1013
|
-
else throw new TypeError("invalid entry type: " + t);
|
|
1014
|
-
}
|
|
1015
|
-
}, cn = (s, t) => {
|
|
1016
|
-
let i = s, r = "", n, o = node_path$1.posix.parse(s).root || ".";
|
|
1017
|
-
if (Buffer.byteLength(i) < 100) n = [
|
|
1018
|
-
i,
|
|
1019
|
-
r,
|
|
1020
|
-
!1
|
|
1021
|
-
];
|
|
1022
|
-
else {
|
|
1023
|
-
r = node_path$1.posix.dirname(i), i = node_path$1.posix.basename(i);
|
|
1024
|
-
do
|
|
1025
|
-
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [
|
|
1026
|
-
i,
|
|
1027
|
-
r,
|
|
1028
|
-
!1
|
|
1029
|
-
] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [
|
|
1030
|
-
i.slice(0, 99),
|
|
1031
|
-
r,
|
|
1032
|
-
!0
|
|
1033
|
-
] : (i = node_path$1.posix.join(node_path$1.posix.basename(r), i), r = node_path$1.posix.dirname(r));
|
|
1034
|
-
while (r !== o && n === void 0);
|
|
1035
|
-
n || (n = [
|
|
1036
|
-
s.slice(0, 99),
|
|
1037
|
-
"",
|
|
1038
|
-
!0
|
|
1039
|
-
]);
|
|
1040
|
-
}
|
|
1041
|
-
return n;
|
|
1042
|
-
}, xt = (s, t, e) => s.subarray(t, t + e).toString("utf8").replace(/\0.*/, ""), Hi = (s, t, e) => fn(at(s, t, e)), fn = (s) => s === void 0 ? void 0 : /* @__PURE__ */ new Date(s * 1e3), at = (s, t, e) => Number(s[t]) & 128 ? zs(s.subarray(t, t + e)) : un(s, t, e), dn = (s) => isNaN(s) ? void 0 : s, un = (s, t, e) => dn(parseInt(s.subarray(t, t + e).toString("utf8").replace(/\0.*$/, "").trim(), 8)), mn = {
|
|
1043
|
-
12: 8589934591,
|
|
1044
|
-
8: 2097151
|
|
1045
|
-
}, lt = (s, t, e, i) => i === void 0 ? !1 : i > mn[e] || i < 0 ? (Ps(i, s.subarray(t, t + e)), !0) : (pn(s, t, e, i), !1), pn = (s, t, e, i) => s.write(En(i, e), t, e, "ascii"), En = (s, t) => wn(Math.floor(s).toString(8), t), wn = (s, t) => (s.length === t - 1 ? s : new Array(t - s.length - 1).join("0") + s + " ") + "\0", Wi = (s, t, e, i) => i === void 0 ? !1 : lt(s, t, e, i.getTime() / 1e3), Sn = new Array(156).join("\0"), Lt = (s, t, e, i) => i === void 0 ? !1 : (s.write(i + Sn, t, e, "utf8"), i.length !== Buffer.byteLength(i) || i.length > e);
|
|
1046
|
-
var ct = class s {
|
|
1047
|
-
atime;
|
|
1048
|
-
mtime;
|
|
1049
|
-
ctime;
|
|
1050
|
-
charset;
|
|
1051
|
-
comment;
|
|
1052
|
-
gid;
|
|
1053
|
-
uid;
|
|
1054
|
-
gname;
|
|
1055
|
-
uname;
|
|
1056
|
-
linkpath;
|
|
1057
|
-
dev;
|
|
1058
|
-
ino;
|
|
1059
|
-
nlink;
|
|
1060
|
-
path;
|
|
1061
|
-
size;
|
|
1062
|
-
mode;
|
|
1063
|
-
global;
|
|
1064
|
-
constructor(t, e = !1) {
|
|
1065
|
-
this.atime = t.atime, this.charset = t.charset, this.comment = t.comment, this.ctime = t.ctime, this.dev = t.dev, this.gid = t.gid, this.global = e, this.gname = t.gname, this.ino = t.ino, this.linkpath = t.linkpath, this.mtime = t.mtime, this.nlink = t.nlink, this.path = t.path, this.size = t.size, this.uid = t.uid, this.uname = t.uname;
|
|
1066
|
-
}
|
|
1067
|
-
encode() {
|
|
1068
|
-
let t = this.encodeBody();
|
|
1069
|
-
if (t === "") return Buffer.allocUnsafe(0);
|
|
1070
|
-
let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
|
|
1071
|
-
for (let n = 0; n < 512; n++) r[n] = 0;
|
|
1072
|
-
new C$1({
|
|
1073
|
-
path: ("PaxHeader/" + (0, node_path$1.basename)(this.path ?? "")).slice(0, 99),
|
|
1074
|
-
mode: this.mode || 420,
|
|
1075
|
-
uid: this.uid,
|
|
1076
|
-
gid: this.gid,
|
|
1077
|
-
size: e,
|
|
1078
|
-
mtime: this.mtime,
|
|
1079
|
-
type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
|
|
1080
|
-
linkpath: "",
|
|
1081
|
-
uname: this.uname || "",
|
|
1082
|
-
gname: this.gname || "",
|
|
1083
|
-
devmaj: 0,
|
|
1084
|
-
devmin: 0,
|
|
1085
|
-
atime: this.atime,
|
|
1086
|
-
ctime: this.ctime
|
|
1087
|
-
}).encode(r), r.write(t, 512, e, "utf8");
|
|
1088
|
-
for (let n = e + 512; n < r.length; n++) r[n] = 0;
|
|
1089
|
-
return r;
|
|
1090
|
-
}
|
|
1091
|
-
encodeBody() {
|
|
1092
|
-
return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
|
|
1093
|
-
}
|
|
1094
|
-
encodeField(t) {
|
|
1095
|
-
if (this[t] === void 0) return "";
|
|
1096
|
-
let e = this[t], i = e instanceof Date ? e.getTime() / 1e3 : e, r = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
|
|
1097
|
-
`, n = Buffer.byteLength(r), o = Math.floor(Math.log(n) / Math.log(10)) + 1;
|
|
1098
|
-
return n + o >= Math.pow(10, o) && (o += 1), o + n + r;
|
|
1099
|
-
}
|
|
1100
|
-
static parse(t, e, i = !1) {
|
|
1101
|
-
return new s(Rn(gn(t), e), i);
|
|
1102
|
-
}
|
|
1103
|
-
}, Rn = (s, t) => t ? Object.assign({}, t, s) : s, gn = (s) => s.replace(/\n$/, "").split(`
|
|
1104
|
-
`).reduce(bn, Object.create(null)), bn = (s, t) => {
|
|
1105
|
-
let e = parseInt(t, 10);
|
|
1106
|
-
if (e !== Buffer.byteLength(t) + 1) return s;
|
|
1107
|
-
t = t.slice((e + " ").length);
|
|
1108
|
-
let i = t.split("="), r = i.shift();
|
|
1109
|
-
if (!r) return s;
|
|
1110
|
-
let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=");
|
|
1111
|
-
return s[n] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n) ? /* @__PURE__ */ new Date(Number(o) * 1e3) : /^[0-9]+$/.test(o) ? +o : o, s;
|
|
1112
|
-
};
|
|
1113
|
-
var f$1 = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) !== "win32" ? (s) => s : (s) => s && s.replaceAll(/\\/g, "/");
|
|
1114
|
-
var Ve = class extends A$1 {
|
|
1115
|
-
extended;
|
|
1116
|
-
globalExtended;
|
|
1117
|
-
header;
|
|
1118
|
-
startBlockSize;
|
|
1119
|
-
blockRemain;
|
|
1120
|
-
remain;
|
|
1121
|
-
type;
|
|
1122
|
-
meta = !1;
|
|
1123
|
-
ignore = !1;
|
|
1124
|
-
path;
|
|
1125
|
-
mode;
|
|
1126
|
-
uid;
|
|
1127
|
-
gid;
|
|
1128
|
-
uname;
|
|
1129
|
-
gname;
|
|
1130
|
-
size = 0;
|
|
1131
|
-
mtime;
|
|
1132
|
-
atime;
|
|
1133
|
-
ctime;
|
|
1134
|
-
linkpath;
|
|
1135
|
-
dev;
|
|
1136
|
-
ino;
|
|
1137
|
-
nlink;
|
|
1138
|
-
invalid = !1;
|
|
1139
|
-
absolute;
|
|
1140
|
-
unsupported = !1;
|
|
1141
|
-
constructor(t, e, i) {
|
|
1142
|
-
switch (super({}), this.pause(), this.extended = e, this.globalExtended = i, this.header = t, this.remain = t.size ?? 0, this.startBlockSize = 512 * Math.ceil(this.remain / 512), this.blockRemain = this.startBlockSize, this.type = t.type, this.type) {
|
|
1143
|
-
case "File":
|
|
1144
|
-
case "OldFile":
|
|
1145
|
-
case "Link":
|
|
1146
|
-
case "SymbolicLink":
|
|
1147
|
-
case "CharacterDevice":
|
|
1148
|
-
case "BlockDevice":
|
|
1149
|
-
case "Directory":
|
|
1150
|
-
case "FIFO":
|
|
1151
|
-
case "ContiguousFile":
|
|
1152
|
-
case "GNUDumpDir": break;
|
|
1153
|
-
case "NextFileHasLongLinkpath":
|
|
1154
|
-
case "NextFileHasLongPath":
|
|
1155
|
-
case "OldGnuLongPath":
|
|
1156
|
-
case "GlobalExtendedHeader":
|
|
1157
|
-
case "ExtendedHeader":
|
|
1158
|
-
case "OldExtendedHeader":
|
|
1159
|
-
this.meta = !0;
|
|
1160
|
-
break;
|
|
1161
|
-
default: this.ignore = !0;
|
|
1162
|
-
}
|
|
1163
|
-
if (!t.path) throw new Error("no path provided for tar.ReadEntry");
|
|
1164
|
-
this.path = f$1(t.path), this.mode = t.mode, this.mode && (this.mode = this.mode & 4095), this.uid = t.uid, this.gid = t.gid, this.uname = t.uname, this.gname = t.gname, this.size = this.remain, this.mtime = t.mtime, this.atime = t.atime, this.ctime = t.ctime, this.linkpath = t.linkpath ? f$1(t.linkpath) : void 0, this.uname = t.uname, this.gname = t.gname, e && this.#t(e), i && this.#t(i, !0);
|
|
1165
|
-
}
|
|
1166
|
-
write(t) {
|
|
1167
|
-
let e = t.length;
|
|
1168
|
-
if (e > this.blockRemain) throw new Error("writing more to entry than is appropriate");
|
|
1169
|
-
let i = this.remain, r = this.blockRemain;
|
|
1170
|
-
return this.remain = Math.max(0, i - e), this.blockRemain = Math.max(0, r - e), this.ignore ? !0 : i >= e ? super.write(t) : super.write(t.subarray(0, i));
|
|
1171
|
-
}
|
|
1172
|
-
#t(t, e = !1) {
|
|
1173
|
-
t.path && (t.path = f$1(t.path)), t.linkpath && (t.linkpath = f$1(t.linkpath)), Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e))));
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
var Nt = (s, t, e, i = {}) => {
|
|
1177
|
-
s.file && (i.file = s.file), s.cwd && (i.cwd = s.cwd), i.code = e instanceof Error && e.code || t, i.tarCode = t, !s.strict && i.recoverable !== !1 ? (e instanceof Error && (i = Object.assign(e, i), e = e.message), s.emit("warn", t, e, i)) : e instanceof Error ? s.emit("error", Object.assign(e, i)) : s.emit("error", Object.assign(/* @__PURE__ */ new Error(`${t}: ${e}`), i));
|
|
1178
|
-
};
|
|
1179
|
-
var Tn = 1024 * 1024, Vi = Buffer.from([31, 139]), $i = Buffer.from([
|
|
1180
|
-
40,
|
|
1181
|
-
181,
|
|
1182
|
-
47,
|
|
1183
|
-
253
|
|
1184
|
-
]), xn = Math.max(Vi.length, $i.length), B = Symbol("state"), Dt = Symbol("writeEntry"), et = Symbol("readEntry"), Gi = Symbol("nextEntry"), Ws = Symbol("processEntry"), V = Symbol("extendedHeader"), he = Symbol("globalExtendedHeader"), ft = Symbol("meta"), Gs = Symbol("emitMeta"), p$1 = Symbol("buffer"), it = Symbol("queue"), dt = Symbol("ended"), Zi = Symbol("emittedEnd"), At = Symbol("emit"), y = Symbol("unzip"), $e = Symbol("consumeChunk"), Xe = Symbol("consumeChunkSub"), Yi = Symbol("consumeBody"), Zs = Symbol("consumeMeta"), Ys = Symbol("consumeHeader"), ae = Symbol("consuming"), Ki = Symbol("bufferConcat"), qe = Symbol("maybeEnd"), Yt = Symbol("writing"), ut = Symbol("aborted"), Qe = Symbol("onDone"), It = Symbol("sawValidEntry"), Je = Symbol("sawNullBlock"), je = Symbol("sawEOF"), Ks = Symbol("closeStream"), Ln = () => !0, st = class extends events.EventEmitter {
|
|
1185
|
-
file;
|
|
1186
|
-
strict;
|
|
1187
|
-
maxMetaEntrySize;
|
|
1188
|
-
filter;
|
|
1189
|
-
brotli;
|
|
1190
|
-
zstd;
|
|
1191
|
-
writable = !0;
|
|
1192
|
-
readable = !1;
|
|
1193
|
-
[it] = [];
|
|
1194
|
-
[p$1];
|
|
1195
|
-
[et];
|
|
1196
|
-
[Dt];
|
|
1197
|
-
[B] = "begin";
|
|
1198
|
-
[ft] = "";
|
|
1199
|
-
[V];
|
|
1200
|
-
[he];
|
|
1201
|
-
[dt] = !1;
|
|
1202
|
-
[y];
|
|
1203
|
-
[ut] = !1;
|
|
1204
|
-
[It];
|
|
1205
|
-
[Je] = !1;
|
|
1206
|
-
[je] = !1;
|
|
1207
|
-
[Yt] = !1;
|
|
1208
|
-
[ae] = !1;
|
|
1209
|
-
[Zi] = !1;
|
|
1210
|
-
constructor(t = {}) {
|
|
1211
|
-
super(), this.file = t.file || "", this.on(Qe, () => {
|
|
1212
|
-
(this[B] === "begin" || this[It] === !1) && this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
|
|
1213
|
-
}), t.ondone ? this.on(Qe, t.ondone) : this.on(Qe, () => {
|
|
1214
|
-
this.emit("prefinish"), this.emit("finish"), this.emit("end");
|
|
1215
|
-
}), this.strict = !!t.strict, this.maxMetaEntrySize = t.maxMetaEntrySize || Tn, this.filter = typeof t.filter == "function" ? t.filter : Ln;
|
|
1216
|
-
let e = t.file && (t.file.endsWith(".tar.br") || t.file.endsWith(".tbr"));
|
|
1217
|
-
this.brotli = !(t.gzip || t.zstd) && t.brotli !== void 0 ? t.brotli : e ? void 0 : !1;
|
|
1218
|
-
let i = t.file && (t.file.endsWith(".tar.zst") || t.file.endsWith(".tzst"));
|
|
1219
|
-
this.zstd = !(t.gzip || t.brotli) && t.zstd !== void 0 ? t.zstd : i ? !0 : void 0, this.on("end", () => this[Ks]()), typeof t.onwarn == "function" && this.on("warn", t.onwarn), typeof t.onReadEntry == "function" && this.on("entry", t.onReadEntry);
|
|
1220
|
-
}
|
|
1221
|
-
warn(t, e, i = {}) {
|
|
1222
|
-
Nt(this, t, e, i);
|
|
1223
|
-
}
|
|
1224
|
-
[Ys](t, e) {
|
|
1225
|
-
this[It] === void 0 && (this[It] = !1);
|
|
1226
|
-
let i;
|
|
1227
|
-
try {
|
|
1228
|
-
i = new C$1(t, e, this[V], this[he]);
|
|
1229
|
-
} catch (r) {
|
|
1230
|
-
return this.warn("TAR_ENTRY_INVALID", r);
|
|
1231
|
-
}
|
|
1232
|
-
if (i.nullBlock) this[Je] ? (this[je] = !0, this[B] === "begin" && (this[B] = "header"), this[At]("eof")) : (this[Je] = !0, this[At]("nullBlock"));
|
|
1233
|
-
else if (this[Je] = !1, !i.cksumValid) this.warn("TAR_ENTRY_INVALID", "checksum failure", { header: i });
|
|
1234
|
-
else if (!i.path) this.warn("TAR_ENTRY_INVALID", "path is required", { header: i });
|
|
1235
|
-
else {
|
|
1236
|
-
let r = i.type;
|
|
1237
|
-
if (/^(Symbolic)?Link$/.test(r) && !i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath required", { header: i });
|
|
1238
|
-
else if (!/^(Symbolic)?Link$/.test(r) && !/^(Global)?ExtendedHeader$/.test(r) && i.linkpath) this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
|
|
1239
|
-
else {
|
|
1240
|
-
let n = this[Dt] = new Ve(i, this[V], this[he]);
|
|
1241
|
-
if (!this[It]) if (n.remain) {
|
|
1242
|
-
let o = () => {
|
|
1243
|
-
n.invalid || (this[It] = !0);
|
|
1244
|
-
};
|
|
1245
|
-
n.on("end", o);
|
|
1246
|
-
} else this[It] = !0;
|
|
1247
|
-
n.meta ? n.size > this.maxMetaEntrySize ? (n.ignore = !0, this[At]("ignoredEntry", n), this[B] = "ignore", n.resume()) : n.size > 0 && (this[ft] = "", n.on("data", (o) => this[ft] += o), this[B] = "meta") : (this[V] = void 0, n.ignore = n.ignore || !this.filter(n.path, n), n.ignore ? (this[At]("ignoredEntry", n), this[B] = n.remain ? "ignore" : "header", n.resume()) : (n.remain ? this[B] = "body" : (this[B] = "header", n.end()), this[et] ? this[it].push(n) : (this[it].push(n), this[Gi]())));
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
[Ks]() {
|
|
1252
|
-
queueMicrotask(() => this.emit("close"));
|
|
1253
|
-
}
|
|
1254
|
-
[Ws](t) {
|
|
1255
|
-
let e = !0;
|
|
1256
|
-
if (!t) this[et] = void 0, e = !1;
|
|
1257
|
-
else if (Array.isArray(t)) {
|
|
1258
|
-
let [i, ...r] = t;
|
|
1259
|
-
this.emit(i, ...r);
|
|
1260
|
-
} else this[et] = t, this.emit("entry", t), t.emittedEnd || (t.on("end", () => this[Gi]()), e = !1);
|
|
1261
|
-
return e;
|
|
1262
|
-
}
|
|
1263
|
-
[Gi]() {
|
|
1264
|
-
do ;
|
|
1265
|
-
while (this[Ws](this[it].shift()));
|
|
1266
|
-
if (this[it].length === 0) {
|
|
1267
|
-
let t = this[et];
|
|
1268
|
-
!t || t.flowing || t.size === t.remain ? this[Yt] || this.emit("drain") : t.once("drain", () => this.emit("drain"));
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
[Yi](t, e) {
|
|
1272
|
-
let i = this[Dt];
|
|
1273
|
-
if (!i) throw new Error("attempt to consume body without entry??");
|
|
1274
|
-
let r = i.blockRemain ?? 0, n = r >= t.length && e === 0 ? t : t.subarray(e, e + r);
|
|
1275
|
-
return i.write(n), i.blockRemain || (this[B] = "header", this[Dt] = void 0, i.end()), n.length;
|
|
1276
|
-
}
|
|
1277
|
-
[Zs](t, e) {
|
|
1278
|
-
let i = this[Dt], r = this[Yi](t, e);
|
|
1279
|
-
return !this[Dt] && i && this[Gs](i), r;
|
|
1280
|
-
}
|
|
1281
|
-
[At](t, e, i) {
|
|
1282
|
-
this[it].length === 0 && !this[et] ? this.emit(t, e, i) : this[it].push([
|
|
1283
|
-
t,
|
|
1284
|
-
e,
|
|
1285
|
-
i
|
|
1286
|
-
]);
|
|
1287
|
-
}
|
|
1288
|
-
[Gs](t) {
|
|
1289
|
-
switch (this[At]("meta", this[ft]), t.type) {
|
|
1290
|
-
case "ExtendedHeader":
|
|
1291
|
-
case "OldExtendedHeader":
|
|
1292
|
-
this[V] = ct.parse(this[ft], this[V], !1);
|
|
1293
|
-
break;
|
|
1294
|
-
case "GlobalExtendedHeader":
|
|
1295
|
-
this[he] = ct.parse(this[ft], this[he], !0);
|
|
1296
|
-
break;
|
|
1297
|
-
case "NextFileHasLongPath":
|
|
1298
|
-
case "OldGnuLongPath": {
|
|
1299
|
-
let e = this[V] ?? Object.create(null);
|
|
1300
|
-
this[V] = e, e.path = this[ft].replace(/\0.*/, "");
|
|
1301
|
-
break;
|
|
1302
|
-
}
|
|
1303
|
-
case "NextFileHasLongLinkpath": {
|
|
1304
|
-
let e = this[V] || Object.create(null);
|
|
1305
|
-
this[V] = e, e.linkpath = this[ft].replace(/\0.*/, "");
|
|
1306
|
-
break;
|
|
1307
|
-
}
|
|
1308
|
-
default: throw new Error("unknown meta: " + t.type);
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
abort(t) {
|
|
1312
|
-
this[ut] = !0, this.emit("abort", t), this.warn("TAR_ABORT", t, { recoverable: !1 });
|
|
1313
|
-
}
|
|
1314
|
-
write(t, e, i) {
|
|
1315
|
-
if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this[ut]) return i?.(), !1;
|
|
1316
|
-
if ((this[y] === void 0 || this.brotli === void 0 && this[y] === !1) && t) {
|
|
1317
|
-
if (this[p$1] && (t = Buffer.concat([this[p$1], t]), this[p$1] = void 0), t.length < xn) return this[p$1] = t, i?.(), !0;
|
|
1318
|
-
for (let h = 0; this[y] === void 0 && h < Vi.length; h++) t[h] !== Vi[h] && (this[y] = !1);
|
|
1319
|
-
let o = !1;
|
|
1320
|
-
if (this[y] === !1 && this.zstd !== !1) {
|
|
1321
|
-
o = !0;
|
|
1322
|
-
for (let h = 0; h < $i.length; h++) if (t[h] !== $i[h]) {
|
|
1323
|
-
o = !1;
|
|
1324
|
-
break;
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
let a = this.brotli === void 0 && !o;
|
|
1328
|
-
if (this[y] === !1 && a) if (t.length < 512) if (this[dt]) this.brotli = !0;
|
|
1329
|
-
else return this[p$1] = t, i?.(), !0;
|
|
1330
|
-
else try {
|
|
1331
|
-
new C$1(t.subarray(0, 512)), this.brotli = !1;
|
|
1332
|
-
} catch {
|
|
1333
|
-
this.brotli = !0;
|
|
1334
|
-
}
|
|
1335
|
-
if (this[y] === void 0 || this[y] === !1 && (this.brotli || o)) {
|
|
1336
|
-
let h = this[dt];
|
|
1337
|
-
this[dt] = !1, this[y] = this[y] === void 0 ? new ze({}) : o ? new Ye({}) : new We({}), this[y].on("data", (c) => this[$e](c)), this[y].on("error", (c) => this.abort(c)), this[y].on("end", () => {
|
|
1338
|
-
this[dt] = !0, this[$e]();
|
|
1339
|
-
}), this[Yt] = !0;
|
|
1340
|
-
let l = !!this[y][h ? "end" : "write"](t);
|
|
1341
|
-
return this[Yt] = !1, i?.(), l;
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
this[Yt] = !0, this[y] ? this[y].write(t) : this[$e](t), this[Yt] = !1;
|
|
1345
|
-
let n = this[it].length > 0 ? !1 : this[et] ? this[et].flowing : !0;
|
|
1346
|
-
return !n && this[it].length === 0 && this[et]?.once("drain", () => this.emit("drain")), i?.(), n;
|
|
1347
|
-
}
|
|
1348
|
-
[Ki](t) {
|
|
1349
|
-
t && !this[ut] && (this[p$1] = this[p$1] ? Buffer.concat([this[p$1], t]) : t);
|
|
1350
|
-
}
|
|
1351
|
-
[qe]() {
|
|
1352
|
-
if (this[dt] && !this[Zi] && !this[ut] && !this[ae]) {
|
|
1353
|
-
this[Zi] = !0;
|
|
1354
|
-
let t = this[Dt];
|
|
1355
|
-
if (t && t.blockRemain) {
|
|
1356
|
-
let e = this[p$1] ? this[p$1].length : 0;
|
|
1357
|
-
this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`, { entry: t }), this[p$1] && t.write(this[p$1]), t.end();
|
|
1358
|
-
}
|
|
1359
|
-
this[At](Qe);
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
[$e](t) {
|
|
1363
|
-
if (this[ae] && t) this[Ki](t);
|
|
1364
|
-
else if (!t && !this[p$1]) this[qe]();
|
|
1365
|
-
else if (t) {
|
|
1366
|
-
if (this[ae] = !0, this[p$1]) {
|
|
1367
|
-
this[Ki](t);
|
|
1368
|
-
let e = this[p$1];
|
|
1369
|
-
this[p$1] = void 0, this[Xe](e);
|
|
1370
|
-
} else this[Xe](t);
|
|
1371
|
-
for (; this[p$1] && this[p$1]?.length >= 512 && !this[ut] && !this[je];) {
|
|
1372
|
-
let e = this[p$1];
|
|
1373
|
-
this[p$1] = void 0, this[Xe](e);
|
|
1374
|
-
}
|
|
1375
|
-
this[ae] = !1;
|
|
1376
|
-
}
|
|
1377
|
-
(!this[p$1] || this[dt]) && this[qe]();
|
|
1378
|
-
}
|
|
1379
|
-
[Xe](t) {
|
|
1380
|
-
let e = 0, i = t.length;
|
|
1381
|
-
for (; e + 512 <= i && !this[ut] && !this[je];) switch (this[B]) {
|
|
1382
|
-
case "begin":
|
|
1383
|
-
case "header":
|
|
1384
|
-
this[Ys](t, e), e += 512;
|
|
1385
|
-
break;
|
|
1386
|
-
case "ignore":
|
|
1387
|
-
case "body":
|
|
1388
|
-
e += this[Yi](t, e);
|
|
1389
|
-
break;
|
|
1390
|
-
case "meta":
|
|
1391
|
-
e += this[Zs](t, e);
|
|
1392
|
-
break;
|
|
1393
|
-
default: throw new Error("invalid state: " + this[B]);
|
|
1394
|
-
}
|
|
1395
|
-
e < i && (this[p$1] = this[p$1] ? Buffer.concat([t.subarray(e), this[p$1]]) : t.subarray(e));
|
|
1396
|
-
}
|
|
1397
|
-
end(t, e, i) {
|
|
1398
|
-
return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[ut] || (this[y] ? (t && this[y].write(t), this[y].end()) : (this[dt] = !0, (this.brotli === void 0 || this.zstd === void 0) && (t = t || Buffer.alloc(0)), t && this.write(t), this[qe]())), this;
|
|
1399
|
-
}
|
|
1400
|
-
};
|
|
1401
|
-
var mt = (s) => {
|
|
1402
|
-
let t = s.length - 1, e = -1;
|
|
1403
|
-
for (; t > -1 && s.charAt(t) === "/";) e = t, t--;
|
|
1404
|
-
return e === -1 ? s : s.slice(0, e);
|
|
1405
|
-
};
|
|
1406
|
-
var An = (s) => {
|
|
1407
|
-
let t = s.onReadEntry;
|
|
1408
|
-
s.onReadEntry = t ? (e) => {
|
|
1409
|
-
t(e), e.resume();
|
|
1410
|
-
} : (e) => e.resume();
|
|
1411
|
-
}, Xi = (s, t) => {
|
|
1412
|
-
let e = new Map(t.map((n) => [mt(n), !0])), i = s.filter, r = (n, o = "") => {
|
|
1413
|
-
let a = o || (0, path.parse)(n).root || ".", h;
|
|
1414
|
-
if (n === a) h = !1;
|
|
1415
|
-
else {
|
|
1416
|
-
let l = e.get(n);
|
|
1417
|
-
h = l !== void 0 ? l : r((0, path.dirname)(n), a);
|
|
1418
|
-
}
|
|
1419
|
-
return e.set(n, h), h;
|
|
1420
|
-
};
|
|
1421
|
-
s.filter = i ? (n, o) => i(n, o) && r(mt(n)) : (n) => r(mt(n));
|
|
1422
|
-
}, In = (s) => {
|
|
1423
|
-
let t = new st(s), e = s.file, i;
|
|
1424
|
-
try {
|
|
1425
|
-
i = node_fs$1.default.openSync(e, "r");
|
|
1426
|
-
let r = node_fs$1.default.fstatSync(i), n = s.maxReadSize || 16 * 1024 * 1024;
|
|
1427
|
-
if (r.size < n) {
|
|
1428
|
-
let o = Buffer.allocUnsafe(r.size), a = node_fs$1.default.readSync(i, o, 0, r.size, 0);
|
|
1429
|
-
t.end(a === o.byteLength ? o : o.subarray(0, a));
|
|
1430
|
-
} else {
|
|
1431
|
-
let o = 0, a = Buffer.allocUnsafe(n);
|
|
1432
|
-
for (; o < r.size;) {
|
|
1433
|
-
let h = node_fs$1.default.readSync(i, a, 0, n, o);
|
|
1434
|
-
if (h === 0) break;
|
|
1435
|
-
o += h, t.write(a.subarray(0, h));
|
|
1436
|
-
}
|
|
1437
|
-
t.end();
|
|
1438
|
-
}
|
|
1439
|
-
} finally {
|
|
1440
|
-
if (typeof i == "number") try {
|
|
1441
|
-
node_fs$1.default.closeSync(i);
|
|
1442
|
-
} catch {}
|
|
1443
|
-
}
|
|
1444
|
-
}, Fn = (s, t) => {
|
|
1445
|
-
let e = new st(s), i = s.maxReadSize || 16 * 1024 * 1024, r = s.file;
|
|
1446
|
-
return new Promise((o, a) => {
|
|
1447
|
-
e.on("error", a), e.on("end", o), node_fs$1.default.stat(r, (h, l) => {
|
|
1448
|
-
if (h) a(h);
|
|
1449
|
-
else {
|
|
1450
|
-
let c = new _t(r, {
|
|
1451
|
-
readSize: i,
|
|
1452
|
-
size: l.size
|
|
1453
|
-
});
|
|
1454
|
-
c.on("error", a), c.pipe(e);
|
|
1455
|
-
}
|
|
1456
|
-
});
|
|
1457
|
-
});
|
|
1458
|
-
}, Ft = K(In, Fn, (s) => new st(s), (s) => new st(s), (s, t) => {
|
|
1459
|
-
t?.length && Xi(s, t), s.noResume || An(s);
|
|
1460
|
-
});
|
|
1461
|
-
var qi = (s, t, e) => (s &= 4095, e && (s = (s | 384) & -19), t && (s & 256 && (s |= 64), s & 32 && (s |= 8), s & 4 && (s |= 1)), s);
|
|
1462
|
-
var { isAbsolute: kn, parse: Vs } = node_path$1.win32, le = (s) => {
|
|
1463
|
-
let t = "", e = Vs(s);
|
|
1464
|
-
for (; kn(s) || e.root;) {
|
|
1465
|
-
let i = s.charAt(0) === "/" && s.slice(0, 4) !== "//?/" ? "/" : e.root;
|
|
1466
|
-
s = s.slice(i.length), t += i, e = Vs(s);
|
|
1467
|
-
}
|
|
1468
|
-
return [t, s];
|
|
1469
|
-
};
|
|
1470
|
-
var ti = [
|
|
1471
|
-
"|",
|
|
1472
|
-
"<",
|
|
1473
|
-
">",
|
|
1474
|
-
"?",
|
|
1475
|
-
":"
|
|
1476
|
-
], Qi = ti.map((s) => String.fromCodePoint(61440 + Number(s.codePointAt(0)))), vn = new Map(ti.map((s, t) => [s, Qi[t]])), Mn = new Map(Qi.map((s, t) => [s, ti[t]])), Ji = (s) => ti.reduce((t, e) => t.split(e).join(vn.get(e)), s), $s = (s) => Qi.reduce((t, e) => t.split(e).join(Mn.get(e)), s);
|
|
1477
|
-
var er = (s, t) => t ? (s = f$1(s).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s) : f$1(s), Bn = 16 * 1024 * 1024, Qs = Symbol("process"), Js = Symbol("file"), js = Symbol("directory"), ts = Symbol("symlink"), tr = Symbol("hardlink"), ce = Symbol("header"), ei = Symbol("read"), es = Symbol("lstat"), ii = Symbol("onlstat"), is = Symbol("onread"), ss = Symbol("onreadlink"), rs = Symbol("openfile"), ns = Symbol("onopenfile"), pt = Symbol("close"), si = Symbol("mode"), os = Symbol("awaitDrain"), ji = Symbol("ondrain"), X = Symbol("prefix"), fe = class extends A$1 {
|
|
1478
|
-
path;
|
|
1479
|
-
portable;
|
|
1480
|
-
myuid = process.getuid && process.getuid() || 0;
|
|
1481
|
-
myuser = process.env.USER || "";
|
|
1482
|
-
maxReadSize;
|
|
1483
|
-
linkCache;
|
|
1484
|
-
statCache;
|
|
1485
|
-
preservePaths;
|
|
1486
|
-
cwd;
|
|
1487
|
-
strict;
|
|
1488
|
-
mtime;
|
|
1489
|
-
noPax;
|
|
1490
|
-
noMtime;
|
|
1491
|
-
prefix;
|
|
1492
|
-
fd;
|
|
1493
|
-
blockLen = 0;
|
|
1494
|
-
blockRemain = 0;
|
|
1495
|
-
buf;
|
|
1496
|
-
pos = 0;
|
|
1497
|
-
remain = 0;
|
|
1498
|
-
length = 0;
|
|
1499
|
-
offset = 0;
|
|
1500
|
-
win32;
|
|
1501
|
-
absolute;
|
|
1502
|
-
header;
|
|
1503
|
-
type;
|
|
1504
|
-
linkpath;
|
|
1505
|
-
stat;
|
|
1506
|
-
onWriteEntry;
|
|
1507
|
-
#t = !1;
|
|
1508
|
-
constructor(t, e = {}) {
|
|
1509
|
-
let i = se(e);
|
|
1510
|
-
super(), this.path = f$1(t), this.portable = !!i.portable, this.maxReadSize = i.maxReadSize || Bn, this.linkCache = i.linkCache || /* @__PURE__ */ new Map(), this.statCache = i.statCache || /* @__PURE__ */ new Map(), this.preservePaths = !!i.preservePaths, this.cwd = f$1(i.cwd || process.cwd()), this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.mtime = i.mtime, this.prefix = i.prefix ? f$1(i.prefix) : void 0, this.onWriteEntry = i.onWriteEntry, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
1511
|
-
let r = !1;
|
|
1512
|
-
if (!this.preservePaths) {
|
|
1513
|
-
let [o, a] = le(this.path);
|
|
1514
|
-
o && typeof a == "string" && (this.path = a, r = o);
|
|
1515
|
-
}
|
|
1516
|
-
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = $s(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f$1(i.absolute || path.default.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, {
|
|
1517
|
-
entry: this,
|
|
1518
|
-
path: r + this.path
|
|
1519
|
-
});
|
|
1520
|
-
let n = this.statCache.get(this.absolute);
|
|
1521
|
-
n ? this[ii](n) : this[es]();
|
|
1522
|
-
}
|
|
1523
|
-
warn(t, e, i = {}) {
|
|
1524
|
-
return Nt(this, t, e, i);
|
|
1525
|
-
}
|
|
1526
|
-
emit(t, ...e) {
|
|
1527
|
-
return t === "error" && (this.#t = !0), super.emit(t, ...e);
|
|
1528
|
-
}
|
|
1529
|
-
[es]() {
|
|
1530
|
-
fs.default.lstat(this.absolute, (t, e) => {
|
|
1531
|
-
if (t) return this.emit("error", t);
|
|
1532
|
-
this[ii](e);
|
|
1533
|
-
});
|
|
1534
|
-
}
|
|
1535
|
-
[ii](t) {
|
|
1536
|
-
this.statCache.set(this.absolute, t), this.stat = t, t.isFile() || (t.size = 0), this.type = Pn(t), this.emit("stat", t), this[Qs]();
|
|
1537
|
-
}
|
|
1538
|
-
[Qs]() {
|
|
1539
|
-
switch (this.type) {
|
|
1540
|
-
case "File": return this[Js]();
|
|
1541
|
-
case "Directory": return this[js]();
|
|
1542
|
-
case "SymbolicLink": return this[ts]();
|
|
1543
|
-
default: return this.end();
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
[si](t) {
|
|
1547
|
-
return qi(t, this.type === "Directory", this.portable);
|
|
1548
|
-
}
|
|
1549
|
-
[X](t) {
|
|
1550
|
-
return er(t, this.prefix);
|
|
1551
|
-
}
|
|
1552
|
-
[ce]() {
|
|
1553
|
-
if (!this.stat) throw new Error("cannot write header before stat");
|
|
1554
|
-
this.type === "Directory" && this.portable && (this.noMtime = !0), this.onWriteEntry?.(this), this.header = new C$1({
|
|
1555
|
-
path: this[X](this.path),
|
|
1556
|
-
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath,
|
|
1557
|
-
mode: this[si](this.stat.mode),
|
|
1558
|
-
uid: this.portable ? void 0 : this.stat.uid,
|
|
1559
|
-
gid: this.portable ? void 0 : this.stat.gid,
|
|
1560
|
-
size: this.stat.size,
|
|
1561
|
-
mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
|
|
1562
|
-
type: this.type === "Unsupported" ? void 0 : this.type,
|
|
1563
|
-
uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
|
|
1564
|
-
atime: this.portable ? void 0 : this.stat.atime,
|
|
1565
|
-
ctime: this.portable ? void 0 : this.stat.ctime
|
|
1566
|
-
}), this.header.encode() && !this.noPax && super.write(new ct({
|
|
1567
|
-
atime: this.portable ? void 0 : this.header.atime,
|
|
1568
|
-
ctime: this.portable ? void 0 : this.header.ctime,
|
|
1569
|
-
gid: this.portable ? void 0 : this.header.gid,
|
|
1570
|
-
mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
|
|
1571
|
-
path: this[X](this.path),
|
|
1572
|
-
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath,
|
|
1573
|
-
size: this.header.size,
|
|
1574
|
-
uid: this.portable ? void 0 : this.header.uid,
|
|
1575
|
-
uname: this.portable ? void 0 : this.header.uname,
|
|
1576
|
-
dev: this.portable ? void 0 : this.stat.dev,
|
|
1577
|
-
ino: this.portable ? void 0 : this.stat.ino,
|
|
1578
|
-
nlink: this.portable ? void 0 : this.stat.nlink
|
|
1579
|
-
}).encode());
|
|
1580
|
-
let t = this.header?.block;
|
|
1581
|
-
if (!t) throw new Error("failed to encode header");
|
|
1582
|
-
super.write(t);
|
|
1583
|
-
}
|
|
1584
|
-
[js]() {
|
|
1585
|
-
if (!this.stat) throw new Error("cannot create directory entry without stat");
|
|
1586
|
-
this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[ce](), this.end();
|
|
1587
|
-
}
|
|
1588
|
-
[ts]() {
|
|
1589
|
-
fs.default.readlink(this.absolute, (t, e) => {
|
|
1590
|
-
if (t) return this.emit("error", t);
|
|
1591
|
-
this[ss](e);
|
|
1592
|
-
});
|
|
1593
|
-
}
|
|
1594
|
-
[ss](t) {
|
|
1595
|
-
this.linkpath = f$1(t), this[ce](), this.end();
|
|
1596
|
-
}
|
|
1597
|
-
[tr](t) {
|
|
1598
|
-
if (!this.stat) throw new Error("cannot create link entry without stat");
|
|
1599
|
-
this.type = "Link", this.linkpath = f$1(path.default.relative(this.cwd, t)), this.stat.size = 0, this[ce](), this.end();
|
|
1600
|
-
}
|
|
1601
|
-
[Js]() {
|
|
1602
|
-
if (!this.stat) throw new Error("cannot create file entry without stat");
|
|
1603
|
-
if (this.stat.nlink > 1) {
|
|
1604
|
-
let t = `${this.stat.dev}:${this.stat.ino}`, e = this.linkCache.get(t);
|
|
1605
|
-
if (e?.indexOf(this.cwd) === 0) return this[tr](e);
|
|
1606
|
-
this.linkCache.set(t, this.absolute);
|
|
1607
|
-
}
|
|
1608
|
-
if (this[ce](), this.stat.size === 0) return this.end();
|
|
1609
|
-
this[rs]();
|
|
1610
|
-
}
|
|
1611
|
-
[rs]() {
|
|
1612
|
-
fs.default.open(this.absolute, "r", (t, e) => {
|
|
1613
|
-
if (t) return this.emit("error", t);
|
|
1614
|
-
this[ns](e);
|
|
1615
|
-
});
|
|
1616
|
-
}
|
|
1617
|
-
[ns](t) {
|
|
1618
|
-
if (this.fd = t, this.#t) return this[pt]();
|
|
1619
|
-
if (!this.stat) throw new Error("should stat before calling onopenfile");
|
|
1620
|
-
this.blockLen = 512 * Math.ceil(this.stat.size / 512), this.blockRemain = this.blockLen;
|
|
1621
|
-
let e = Math.min(this.blockLen, this.maxReadSize);
|
|
1622
|
-
this.buf = Buffer.allocUnsafe(e), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ei]();
|
|
1623
|
-
}
|
|
1624
|
-
[ei]() {
|
|
1625
|
-
let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
|
|
1626
|
-
if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
|
|
1627
|
-
fs.default.read(t, e, i, r, n, (o, a) => {
|
|
1628
|
-
if (o) return this[pt](() => this.emit("error", o));
|
|
1629
|
-
this[is](a);
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
[pt](t = () => {}) {
|
|
1633
|
-
this.fd !== void 0 && fs.default.close(this.fd, t);
|
|
1634
|
-
}
|
|
1635
|
-
[is](t) {
|
|
1636
|
-
if (t <= 0 && this.remain > 0) {
|
|
1637
|
-
let r = Object.assign(/* @__PURE__ */ new Error("encountered unexpected EOF"), {
|
|
1638
|
-
path: this.absolute,
|
|
1639
|
-
syscall: "read",
|
|
1640
|
-
code: "EOF"
|
|
1641
|
-
});
|
|
1642
|
-
return this[pt](() => this.emit("error", r));
|
|
1643
|
-
}
|
|
1644
|
-
if (t > this.remain) {
|
|
1645
|
-
let r = Object.assign(/* @__PURE__ */ new Error("did not encounter expected EOF"), {
|
|
1646
|
-
path: this.absolute,
|
|
1647
|
-
syscall: "read",
|
|
1648
|
-
code: "EOF"
|
|
1649
|
-
});
|
|
1650
|
-
return this[pt](() => this.emit("error", r));
|
|
1651
|
-
}
|
|
1652
|
-
if (!this.buf) throw new Error("should have created buffer prior to reading");
|
|
1653
|
-
if (t === this.remain) for (let r = t; r < this.length && t < this.blockRemain; r++) this.buf[r + this.offset] = 0, t++, this.remain++;
|
|
1654
|
-
let e = this.offset === 0 && t === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + t);
|
|
1655
|
-
this.write(e) ? this[ji]() : this[os](() => this[ji]());
|
|
1656
|
-
}
|
|
1657
|
-
[os](t) {
|
|
1658
|
-
this.once("drain", t);
|
|
1659
|
-
}
|
|
1660
|
-
write(t, e, i) {
|
|
1661
|
-
if (typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this.blockRemain < t.length) {
|
|
1662
|
-
let r = Object.assign(/* @__PURE__ */ new Error("writing more data than expected"), { path: this.absolute });
|
|
1663
|
-
return this.emit("error", r);
|
|
1664
|
-
}
|
|
1665
|
-
return this.remain -= t.length, this.blockRemain -= t.length, this.pos += t.length, this.offset += t.length, super.write(t, null, i);
|
|
1666
|
-
}
|
|
1667
|
-
[ji]() {
|
|
1668
|
-
if (!this.remain) return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), this[pt]((t) => t ? this.emit("error", t) : this.end());
|
|
1669
|
-
if (!this.buf) throw new Error("buffer lost somehow in ONDRAIN");
|
|
1670
|
-
this.offset >= this.length && (this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length)), this.offset = 0), this.length = this.buf.length - this.offset, this[ei]();
|
|
1671
|
-
}
|
|
1672
|
-
}, ri = class extends fe {
|
|
1673
|
-
sync = !0;
|
|
1674
|
-
[es]() {
|
|
1675
|
-
this[ii](fs.default.lstatSync(this.absolute));
|
|
1676
|
-
}
|
|
1677
|
-
[ts]() {
|
|
1678
|
-
this[ss](fs.default.readlinkSync(this.absolute));
|
|
1679
|
-
}
|
|
1680
|
-
[rs]() {
|
|
1681
|
-
this[ns](fs.default.openSync(this.absolute, "r"));
|
|
1682
|
-
}
|
|
1683
|
-
[ei]() {
|
|
1684
|
-
let t = !0;
|
|
1685
|
-
try {
|
|
1686
|
-
let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
|
|
1687
|
-
if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
|
|
1688
|
-
let a = fs.default.readSync(e, i, r, n, o);
|
|
1689
|
-
this[is](a), t = !1;
|
|
1690
|
-
} finally {
|
|
1691
|
-
if (t) try {
|
|
1692
|
-
this[pt](() => {});
|
|
1693
|
-
} catch {}
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
[os](t) {
|
|
1697
|
-
t();
|
|
1698
|
-
}
|
|
1699
|
-
[pt](t = () => {}) {
|
|
1700
|
-
this.fd !== void 0 && fs.default.closeSync(this.fd), t();
|
|
1701
|
-
}
|
|
1702
|
-
}, ni = class extends A$1 {
|
|
1703
|
-
blockLen = 0;
|
|
1704
|
-
blockRemain = 0;
|
|
1705
|
-
buf = 0;
|
|
1706
|
-
pos = 0;
|
|
1707
|
-
remain = 0;
|
|
1708
|
-
length = 0;
|
|
1709
|
-
preservePaths;
|
|
1710
|
-
portable;
|
|
1711
|
-
strict;
|
|
1712
|
-
noPax;
|
|
1713
|
-
noMtime;
|
|
1714
|
-
readEntry;
|
|
1715
|
-
type;
|
|
1716
|
-
prefix;
|
|
1717
|
-
path;
|
|
1718
|
-
mode;
|
|
1719
|
-
uid;
|
|
1720
|
-
gid;
|
|
1721
|
-
uname;
|
|
1722
|
-
gname;
|
|
1723
|
-
header;
|
|
1724
|
-
mtime;
|
|
1725
|
-
atime;
|
|
1726
|
-
ctime;
|
|
1727
|
-
linkpath;
|
|
1728
|
-
size;
|
|
1729
|
-
onWriteEntry;
|
|
1730
|
-
warn(t, e, i = {}) {
|
|
1731
|
-
return Nt(this, t, e, i);
|
|
1732
|
-
}
|
|
1733
|
-
constructor(t, e = {}) {
|
|
1734
|
-
let i = se(e);
|
|
1735
|
-
super(), this.preservePaths = !!i.preservePaths, this.portable = !!i.portable, this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.onWriteEntry = i.onWriteEntry, this.readEntry = t;
|
|
1736
|
-
let { type: r } = t;
|
|
1737
|
-
if (r === "Unsupported") throw new Error("writing entry that should be ignored");
|
|
1738
|
-
this.type = r, this.type === "Directory" && this.portable && (this.noMtime = !0), this.prefix = i.prefix, this.path = f$1(t.path), this.mode = t.mode !== void 0 ? this[si](t.mode) : void 0, this.uid = this.portable ? void 0 : t.uid, this.gid = this.portable ? void 0 : t.gid, this.uname = this.portable ? void 0 : t.uname, this.gname = this.portable ? void 0 : t.gname, this.size = t.size, this.mtime = this.noMtime ? void 0 : i.mtime || t.mtime, this.atime = this.portable ? void 0 : t.atime, this.ctime = this.portable ? void 0 : t.ctime, this.linkpath = t.linkpath !== void 0 ? f$1(t.linkpath) : void 0, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
1739
|
-
let n = !1;
|
|
1740
|
-
if (!this.preservePaths) {
|
|
1741
|
-
let [a, h] = le(this.path);
|
|
1742
|
-
a && typeof h == "string" && (this.path = h, n = a);
|
|
1743
|
-
}
|
|
1744
|
-
this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new C$1({
|
|
1745
|
-
path: this[X](this.path),
|
|
1746
|
-
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath,
|
|
1747
|
-
mode: this.mode,
|
|
1748
|
-
uid: this.portable ? void 0 : this.uid,
|
|
1749
|
-
gid: this.portable ? void 0 : this.gid,
|
|
1750
|
-
size: this.size,
|
|
1751
|
-
mtime: this.noMtime ? void 0 : this.mtime,
|
|
1752
|
-
type: this.type,
|
|
1753
|
-
uname: this.portable ? void 0 : this.uname,
|
|
1754
|
-
atime: this.portable ? void 0 : this.atime,
|
|
1755
|
-
ctime: this.portable ? void 0 : this.ctime
|
|
1756
|
-
}), n && this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute path`, {
|
|
1757
|
-
entry: this,
|
|
1758
|
-
path: n + this.path
|
|
1759
|
-
}), this.header.encode() && !this.noPax && super.write(new ct({
|
|
1760
|
-
atime: this.portable ? void 0 : this.atime,
|
|
1761
|
-
ctime: this.portable ? void 0 : this.ctime,
|
|
1762
|
-
gid: this.portable ? void 0 : this.gid,
|
|
1763
|
-
mtime: this.noMtime ? void 0 : this.mtime,
|
|
1764
|
-
path: this[X](this.path),
|
|
1765
|
-
linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[X](this.linkpath) : this.linkpath,
|
|
1766
|
-
size: this.size,
|
|
1767
|
-
uid: this.portable ? void 0 : this.uid,
|
|
1768
|
-
uname: this.portable ? void 0 : this.uname,
|
|
1769
|
-
dev: this.portable ? void 0 : this.readEntry.dev,
|
|
1770
|
-
ino: this.portable ? void 0 : this.readEntry.ino,
|
|
1771
|
-
nlink: this.portable ? void 0 : this.readEntry.nlink
|
|
1772
|
-
}).encode());
|
|
1773
|
-
let o = this.header?.block;
|
|
1774
|
-
if (!o) throw new Error("failed to encode header");
|
|
1775
|
-
super.write(o), t.pipe(this);
|
|
1776
|
-
}
|
|
1777
|
-
[X](t) {
|
|
1778
|
-
return er(t, this.prefix);
|
|
1779
|
-
}
|
|
1780
|
-
[si](t) {
|
|
1781
|
-
return qi(t, this.type === "Directory", this.portable);
|
|
1782
|
-
}
|
|
1783
|
-
write(t, e, i) {
|
|
1784
|
-
typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8"));
|
|
1785
|
-
let r = t.length;
|
|
1786
|
-
if (r > this.blockRemain) throw new Error("writing more to entry than is appropriate");
|
|
1787
|
-
return this.blockRemain -= r, super.write(t, i);
|
|
1788
|
-
}
|
|
1789
|
-
end(t, e, i) {
|
|
1790
|
-
return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e ?? "utf8")), i && this.once("finish", i), t ? super.end(t, i) : super.end(i), this;
|
|
1791
|
-
}
|
|
1792
|
-
}, Pn = (s) => s.isFile() ? "File" : s.isDirectory() ? "Directory" : s.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
|
|
1793
|
-
var oi = class s {
|
|
1794
|
-
tail;
|
|
1795
|
-
head;
|
|
1796
|
-
length = 0;
|
|
1797
|
-
static create(t = []) {
|
|
1798
|
-
return new s(t);
|
|
1799
|
-
}
|
|
1800
|
-
constructor(t = []) {
|
|
1801
|
-
for (let e of t) this.push(e);
|
|
1802
|
-
}
|
|
1803
|
-
*[Symbol.iterator]() {
|
|
1804
|
-
for (let t = this.head; t; t = t.next) yield t.value;
|
|
1805
|
-
}
|
|
1806
|
-
removeNode(t) {
|
|
1807
|
-
if (t.list !== this) throw new Error("removing node which does not belong to this list");
|
|
1808
|
-
let e = t.next, i = t.prev;
|
|
1809
|
-
return e && (e.prev = i), i && (i.next = e), t === this.head && (this.head = e), t === this.tail && (this.tail = i), this.length--, t.next = void 0, t.prev = void 0, t.list = void 0, e;
|
|
1810
|
-
}
|
|
1811
|
-
unshiftNode(t) {
|
|
1812
|
-
if (t === this.head) return;
|
|
1813
|
-
t.list && t.list.removeNode(t);
|
|
1814
|
-
let e = this.head;
|
|
1815
|
-
t.list = this, t.next = e, e && (e.prev = t), this.head = t, this.tail || (this.tail = t), this.length++;
|
|
1816
|
-
}
|
|
1817
|
-
pushNode(t) {
|
|
1818
|
-
if (t === this.tail) return;
|
|
1819
|
-
t.list && t.list.removeNode(t);
|
|
1820
|
-
let e = this.tail;
|
|
1821
|
-
t.list = this, t.prev = e, e && (e.next = t), this.tail = t, this.head || (this.head = t), this.length++;
|
|
1822
|
-
}
|
|
1823
|
-
push(...t) {
|
|
1824
|
-
for (let e = 0, i = t.length; e < i; e++) Un(this, t[e]);
|
|
1825
|
-
return this.length;
|
|
1826
|
-
}
|
|
1827
|
-
unshift(...t) {
|
|
1828
|
-
for (var e = 0, i = t.length; e < i; e++) Hn(this, t[e]);
|
|
1829
|
-
return this.length;
|
|
1830
|
-
}
|
|
1831
|
-
pop() {
|
|
1832
|
-
if (!this.tail) return;
|
|
1833
|
-
let t = this.tail.value, e = this.tail;
|
|
1834
|
-
return this.tail = this.tail.prev, this.tail ? this.tail.next = void 0 : this.head = void 0, e.list = void 0, this.length--, t;
|
|
1835
|
-
}
|
|
1836
|
-
shift() {
|
|
1837
|
-
if (!this.head) return;
|
|
1838
|
-
let t = this.head.value, e = this.head;
|
|
1839
|
-
return this.head = this.head.next, this.head ? this.head.prev = void 0 : this.tail = void 0, e.list = void 0, this.length--, t;
|
|
1840
|
-
}
|
|
1841
|
-
forEach(t, e) {
|
|
1842
|
-
e = e || this;
|
|
1843
|
-
for (let i = this.head, r = 0; i; r++) t.call(e, i.value, r, this), i = i.next;
|
|
1844
|
-
}
|
|
1845
|
-
forEachReverse(t, e) {
|
|
1846
|
-
e = e || this;
|
|
1847
|
-
for (let i = this.tail, r = this.length - 1; i; r--) t.call(e, i.value, r, this), i = i.prev;
|
|
1848
|
-
}
|
|
1849
|
-
get(t) {
|
|
1850
|
-
let e = 0, i = this.head;
|
|
1851
|
-
for (; i && e < t; e++) i = i.next;
|
|
1852
|
-
if (e === t && i) return i.value;
|
|
1853
|
-
}
|
|
1854
|
-
getReverse(t) {
|
|
1855
|
-
let e = 0, i = this.tail;
|
|
1856
|
-
for (; i && e < t; e++) i = i.prev;
|
|
1857
|
-
if (e === t && i) return i.value;
|
|
1858
|
-
}
|
|
1859
|
-
map(t, e) {
|
|
1860
|
-
e = e || this;
|
|
1861
|
-
let i = new s();
|
|
1862
|
-
for (let r = this.head; r;) i.push(t.call(e, r.value, this)), r = r.next;
|
|
1863
|
-
return i;
|
|
1864
|
-
}
|
|
1865
|
-
mapReverse(t, e) {
|
|
1866
|
-
e = e || this;
|
|
1867
|
-
var i = new s();
|
|
1868
|
-
for (let r = this.tail; r;) i.push(t.call(e, r.value, this)), r = r.prev;
|
|
1869
|
-
return i;
|
|
1870
|
-
}
|
|
1871
|
-
reduce(t, e) {
|
|
1872
|
-
let i, r = this.head;
|
|
1873
|
-
if (arguments.length > 1) i = e;
|
|
1874
|
-
else if (this.head) r = this.head.next, i = this.head.value;
|
|
1875
|
-
else throw new TypeError("Reduce of empty list with no initial value");
|
|
1876
|
-
for (var n = 0; r; n++) i = t(i, r.value, n), r = r.next;
|
|
1877
|
-
return i;
|
|
1878
|
-
}
|
|
1879
|
-
reduceReverse(t, e) {
|
|
1880
|
-
let i, r = this.tail;
|
|
1881
|
-
if (arguments.length > 1) i = e;
|
|
1882
|
-
else if (this.tail) r = this.tail.prev, i = this.tail.value;
|
|
1883
|
-
else throw new TypeError("Reduce of empty list with no initial value");
|
|
1884
|
-
for (let n = this.length - 1; r; n--) i = t(i, r.value, n), r = r.prev;
|
|
1885
|
-
return i;
|
|
1886
|
-
}
|
|
1887
|
-
toArray() {
|
|
1888
|
-
let t = new Array(this.length);
|
|
1889
|
-
for (let e = 0, i = this.head; i; e++) t[e] = i.value, i = i.next;
|
|
1890
|
-
return t;
|
|
1891
|
-
}
|
|
1892
|
-
toArrayReverse() {
|
|
1893
|
-
let t = new Array(this.length);
|
|
1894
|
-
for (let e = 0, i = this.tail; i; e++) t[e] = i.value, i = i.prev;
|
|
1895
|
-
return t;
|
|
1896
|
-
}
|
|
1897
|
-
slice(t = 0, e = this.length) {
|
|
1898
|
-
e < 0 && (e += this.length), t < 0 && (t += this.length);
|
|
1899
|
-
let i = new s();
|
|
1900
|
-
if (e < t || e < 0) return i;
|
|
1901
|
-
t < 0 && (t = 0), e > this.length && (e = this.length);
|
|
1902
|
-
let r = this.head, n = 0;
|
|
1903
|
-
for (n = 0; r && n < t; n++) r = r.next;
|
|
1904
|
-
for (; r && n < e; n++, r = r.next) i.push(r.value);
|
|
1905
|
-
return i;
|
|
1906
|
-
}
|
|
1907
|
-
sliceReverse(t = 0, e = this.length) {
|
|
1908
|
-
e < 0 && (e += this.length), t < 0 && (t += this.length);
|
|
1909
|
-
let i = new s();
|
|
1910
|
-
if (e < t || e < 0) return i;
|
|
1911
|
-
t < 0 && (t = 0), e > this.length && (e = this.length);
|
|
1912
|
-
let r = this.length, n = this.tail;
|
|
1913
|
-
for (; n && r > e; r--) n = n.prev;
|
|
1914
|
-
for (; n && r > t; r--, n = n.prev) i.push(n.value);
|
|
1915
|
-
return i;
|
|
1916
|
-
}
|
|
1917
|
-
splice(t, e = 0, ...i) {
|
|
1918
|
-
t > this.length && (t = this.length - 1), t < 0 && (t = this.length + t);
|
|
1919
|
-
let r = this.head;
|
|
1920
|
-
for (let o = 0; r && o < t; o++) r = r.next;
|
|
1921
|
-
let n = [];
|
|
1922
|
-
for (let o = 0; r && o < e; o++) n.push(r.value), r = this.removeNode(r);
|
|
1923
|
-
r ? r !== this.tail && (r = r.prev) : r = this.tail;
|
|
1924
|
-
for (let o of i) r = zn(this, r, o);
|
|
1925
|
-
return n;
|
|
1926
|
-
}
|
|
1927
|
-
reverse() {
|
|
1928
|
-
let t = this.head, e = this.tail;
|
|
1929
|
-
for (let i = t; i; i = i.prev) {
|
|
1930
|
-
let r = i.prev;
|
|
1931
|
-
i.prev = i.next, i.next = r;
|
|
1932
|
-
}
|
|
1933
|
-
return this.head = e, this.tail = t, this;
|
|
1934
|
-
}
|
|
1935
|
-
};
|
|
1936
|
-
function zn(s, t, e) {
|
|
1937
|
-
let n = new de(e, t, t ? t.next : s.head, s);
|
|
1938
|
-
return n.next === void 0 && (s.tail = n), n.prev === void 0 && (s.head = n), s.length++, n;
|
|
1939
|
-
}
|
|
1940
|
-
function Un(s, t) {
|
|
1941
|
-
s.tail = new de(t, s.tail, void 0, s), s.head || (s.head = s.tail), s.length++;
|
|
1942
|
-
}
|
|
1943
|
-
function Hn(s, t) {
|
|
1944
|
-
s.head = new de(t, void 0, s.head, s), s.tail || (s.tail = s.head), s.length++;
|
|
1945
|
-
}
|
|
1946
|
-
var de = class {
|
|
1947
|
-
list;
|
|
1948
|
-
next;
|
|
1949
|
-
prev;
|
|
1950
|
-
value;
|
|
1951
|
-
constructor(t, e, i, r) {
|
|
1952
|
-
this.list = r, this.value = t, e ? (e.next = this, this.prev = e) : this.prev = void 0, i ? (i.prev = this, this.next = i) : this.next = void 0;
|
|
1953
|
-
}
|
|
1954
|
-
};
|
|
1955
|
-
var mi = class {
|
|
1956
|
-
path;
|
|
1957
|
-
absolute;
|
|
1958
|
-
entry;
|
|
1959
|
-
stat;
|
|
1960
|
-
readdir;
|
|
1961
|
-
pending = !1;
|
|
1962
|
-
pendingLink = !1;
|
|
1963
|
-
ignore = !1;
|
|
1964
|
-
piped = !1;
|
|
1965
|
-
constructor(t, e) {
|
|
1966
|
-
this.path = t || "./", this.absolute = e;
|
|
1967
|
-
}
|
|
1968
|
-
}, ir = Buffer.alloc(1024), ai = Symbol("onStat"), ue = Symbol("ended"), W$1 = Symbol("queue"), me = Symbol("pendingLinks"), Et = Symbol("current"), Ct = Symbol("process"), pe = Symbol("processing"), hi = Symbol("processJob"), G = Symbol("jobs"), hs = Symbol("jobDone"), li = Symbol("addFSEntry"), sr = Symbol("addTarEntry"), cs = Symbol("stat"), fs$1 = Symbol("readdir"), ci = Symbol("onreaddir"), fi = Symbol("pipe"), rr = Symbol("entry"), as = Symbol("entryOpt"), di = Symbol("writeEntryClass"), or = Symbol("write"), ls = Symbol("ondrain"), wt = class extends A$1 {
|
|
1969
|
-
sync = !1;
|
|
1970
|
-
opt;
|
|
1971
|
-
cwd;
|
|
1972
|
-
maxReadSize;
|
|
1973
|
-
preservePaths;
|
|
1974
|
-
strict;
|
|
1975
|
-
noPax;
|
|
1976
|
-
prefix;
|
|
1977
|
-
linkCache;
|
|
1978
|
-
statCache;
|
|
1979
|
-
file;
|
|
1980
|
-
portable;
|
|
1981
|
-
zip;
|
|
1982
|
-
readdirCache;
|
|
1983
|
-
noDirRecurse;
|
|
1984
|
-
follow;
|
|
1985
|
-
noMtime;
|
|
1986
|
-
mtime;
|
|
1987
|
-
filter;
|
|
1988
|
-
jobs;
|
|
1989
|
-
[di];
|
|
1990
|
-
onWriteEntry;
|
|
1991
|
-
[W$1];
|
|
1992
|
-
[me] = /* @__PURE__ */ new Map();
|
|
1993
|
-
[G] = 0;
|
|
1994
|
-
[pe] = !1;
|
|
1995
|
-
[ue] = !1;
|
|
1996
|
-
constructor(t = {}) {
|
|
1997
|
-
if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f$1(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[di] = fe, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
|
|
1998
|
-
if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
|
|
1999
|
-
if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = !0), this.zip = new Pe(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new He(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ze(t.zstd)), !this.zip) throw new Error("impossible");
|
|
2000
|
-
let e = this.zip;
|
|
2001
|
-
e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[ls]()), this.on("resume", () => e.resume());
|
|
2002
|
-
} else this.on("drain", this[ls]);
|
|
2003
|
-
this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => !0, this[W$1] = new oi(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[pe] = !1, this[ue] = !1;
|
|
2004
|
-
}
|
|
2005
|
-
[or](t) {
|
|
2006
|
-
return super.write(t);
|
|
2007
|
-
}
|
|
2008
|
-
add(t) {
|
|
2009
|
-
return this.write(t), this;
|
|
2010
|
-
}
|
|
2011
|
-
end(t, e, i) {
|
|
2012
|
-
return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = void 0), t && this.add(t), this[ue] = !0, this[Ct](), i && i(), this;
|
|
2013
|
-
}
|
|
2014
|
-
write(t) {
|
|
2015
|
-
if (this[ue]) throw new Error("write after end");
|
|
2016
|
-
return typeof t == "string" ? this[li](t) : this[sr](t), this.flowing;
|
|
2017
|
-
}
|
|
2018
|
-
[sr](t) {
|
|
2019
|
-
let e = f$1(path.default.resolve(this.cwd, t.path));
|
|
2020
|
-
if (!this.filter(t.path, t)) t.resume();
|
|
2021
|
-
else {
|
|
2022
|
-
let i = new mi(t.path, e);
|
|
2023
|
-
i.entry = new ni(t, this[as](i)), i.entry.on("end", () => this[hs](i)), this[G] += 1, this[W$1].push(i);
|
|
2024
|
-
}
|
|
2025
|
-
this[Ct]();
|
|
2026
|
-
}
|
|
2027
|
-
[li](t) {
|
|
2028
|
-
let e = f$1(path.default.resolve(this.cwd, t));
|
|
2029
|
-
this[W$1].push(new mi(t, e)), this[Ct]();
|
|
2030
|
-
}
|
|
2031
|
-
[cs](t) {
|
|
2032
|
-
t.pending = !0, this[G] += 1;
|
|
2033
|
-
fs.default[this.follow ? "stat" : "lstat"](t.absolute, (i, r) => {
|
|
2034
|
-
t.pending = !1, this[G] -= 1, i ? this.emit("error", i) : this[ai](t, r);
|
|
2035
|
-
});
|
|
2036
|
-
}
|
|
2037
|
-
[ai](t, e) {
|
|
2038
|
-
if (this.statCache.set(t.absolute, e), t.stat = e, !this.filter(t.path, e)) t.ignore = !0;
|
|
2039
|
-
else if (e.isFile() && e.nlink > 1 && !this.linkCache.get(`${e.dev}:${e.ino}`) && !this.sync) if (t === this[Et]) this[hi](t);
|
|
2040
|
-
else {
|
|
2041
|
-
let i = `${e.dev}:${e.ino}`, r = this[me].get(i);
|
|
2042
|
-
r ? r.push(t) : this[me].set(i, [t]), t.pendingLink = !0, t.pending = !0;
|
|
2043
|
-
}
|
|
2044
|
-
this[Ct]();
|
|
2045
|
-
}
|
|
2046
|
-
[fs$1](t) {
|
|
2047
|
-
t.pending = !0, this[G] += 1, fs.default.readdir(t.absolute, (e, i) => {
|
|
2048
|
-
if (t.pending = !1, this[G] -= 1, e) return this.emit("error", e);
|
|
2049
|
-
this[ci](t, i);
|
|
2050
|
-
});
|
|
2051
|
-
}
|
|
2052
|
-
[ci](t, e) {
|
|
2053
|
-
this.readdirCache.set(t.absolute, e), t.readdir = e, this[Ct]();
|
|
2054
|
-
}
|
|
2055
|
-
[Ct]() {
|
|
2056
|
-
if (!this[pe]) {
|
|
2057
|
-
this[pe] = !0;
|
|
2058
|
-
for (let t = this[W$1].head; t && this[G] < this.jobs; t = t.next) if (this[hi](t.value), t.value.ignore) {
|
|
2059
|
-
let e = t.next;
|
|
2060
|
-
this[W$1].removeNode(t), t.next = e;
|
|
2061
|
-
}
|
|
2062
|
-
this[pe] = !1, this[ue] && this[W$1].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(ir) : (super.write(ir), super.end()));
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
get [Et]() {
|
|
2066
|
-
return this[W$1] && this[W$1].head && this[W$1].head.value;
|
|
2067
|
-
}
|
|
2068
|
-
[hs](t) {
|
|
2069
|
-
this[W$1].shift(), this[G] -= 1;
|
|
2070
|
-
let { stat: e } = t;
|
|
2071
|
-
if (e && e.isFile() && e.nlink > 1) {
|
|
2072
|
-
let i = `${e.dev}:${e.ino}`, r = this[me].get(i);
|
|
2073
|
-
if (r) {
|
|
2074
|
-
this[me].delete(i);
|
|
2075
|
-
for (let n of r) n.pending = !1, this[hi](n);
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
this[Ct]();
|
|
2079
|
-
}
|
|
2080
|
-
[hi](t) {
|
|
2081
|
-
if (t.pending && t.pendingLink && t === this[Et] && (t.pending = !1, t.pendingLink = !1), !t.pending) {
|
|
2082
|
-
if (t.entry) {
|
|
2083
|
-
t === this[Et] && !t.piped && this[fi](t);
|
|
2084
|
-
return;
|
|
2085
|
-
}
|
|
2086
|
-
if (!t.stat) {
|
|
2087
|
-
let e = this.statCache.get(t.absolute);
|
|
2088
|
-
e ? this[ai](t, e) : this[cs](t);
|
|
2089
|
-
}
|
|
2090
|
-
if (t.stat && !t.ignore) {
|
|
2091
|
-
if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
|
|
2092
|
-
let e = this.readdirCache.get(t.absolute);
|
|
2093
|
-
if (e ? this[ci](t, e) : this[fs$1](t), !t.readdir) return;
|
|
2094
|
-
}
|
|
2095
|
-
if (t.entry = this[rr](t), !t.entry) {
|
|
2096
|
-
t.ignore = !0;
|
|
2097
|
-
return;
|
|
2098
|
-
}
|
|
2099
|
-
t === this[Et] && !t.piped && this[fi](t);
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
[as](t) {
|
|
2104
|
-
return {
|
|
2105
|
-
onwarn: (e, i, r) => this.warn(e, i, r),
|
|
2106
|
-
noPax: this.noPax,
|
|
2107
|
-
cwd: this.cwd,
|
|
2108
|
-
absolute: t.absolute,
|
|
2109
|
-
preservePaths: this.preservePaths,
|
|
2110
|
-
maxReadSize: this.maxReadSize,
|
|
2111
|
-
strict: this.strict,
|
|
2112
|
-
portable: this.portable,
|
|
2113
|
-
linkCache: this.linkCache,
|
|
2114
|
-
statCache: this.statCache,
|
|
2115
|
-
noMtime: this.noMtime,
|
|
2116
|
-
mtime: this.mtime,
|
|
2117
|
-
prefix: this.prefix,
|
|
2118
|
-
onWriteEntry: this.onWriteEntry
|
|
2119
|
-
};
|
|
2120
|
-
}
|
|
2121
|
-
[rr](t) {
|
|
2122
|
-
this[G] += 1;
|
|
2123
|
-
try {
|
|
2124
|
-
return new this[di](t.path, this[as](t)).on("end", () => this[hs](t)).on("error", (i) => this.emit("error", i));
|
|
2125
|
-
} catch (e) {
|
|
2126
|
-
this.emit("error", e);
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
[ls]() {
|
|
2130
|
-
this[Et] && this[Et].entry && this[Et].entry.resume();
|
|
2131
|
-
}
|
|
2132
|
-
[fi](t) {
|
|
2133
|
-
t.piped = !0, t.readdir && t.readdir.forEach((r) => {
|
|
2134
|
-
let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
|
|
2135
|
-
this[li](o + r);
|
|
2136
|
-
});
|
|
2137
|
-
let e = t.entry, i = this.zip;
|
|
2138
|
-
if (!e) throw new Error("cannot pipe without source");
|
|
2139
|
-
i ? e.on("data", (r) => {
|
|
2140
|
-
i.write(r) || e.pause();
|
|
2141
|
-
}) : e.on("data", (r) => {
|
|
2142
|
-
super.write(r) || e.pause();
|
|
2143
|
-
});
|
|
2144
|
-
}
|
|
2145
|
-
pause() {
|
|
2146
|
-
return this.zip && this.zip.pause(), super.pause();
|
|
2147
|
-
}
|
|
2148
|
-
warn(t, e, i = {}) {
|
|
2149
|
-
Nt(this, t, e, i);
|
|
2150
|
-
}
|
|
2151
|
-
}, kt = class extends wt {
|
|
2152
|
-
sync = !0;
|
|
2153
|
-
constructor(t) {
|
|
2154
|
-
super(t), this[di] = ri;
|
|
2155
|
-
}
|
|
2156
|
-
pause() {}
|
|
2157
|
-
resume() {}
|
|
2158
|
-
[cs](t) {
|
|
2159
|
-
let e = this.follow ? "statSync" : "lstatSync";
|
|
2160
|
-
this[ai](t, fs.default[e](t.absolute));
|
|
2161
|
-
}
|
|
2162
|
-
[fs$1](t) {
|
|
2163
|
-
this[ci](t, fs.default.readdirSync(t.absolute));
|
|
2164
|
-
}
|
|
2165
|
-
[fi](t) {
|
|
2166
|
-
let e = t.entry, i = this.zip;
|
|
2167
|
-
if (t.readdir && t.readdir.forEach((r) => {
|
|
2168
|
-
let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
|
|
2169
|
-
this[li](o + r);
|
|
2170
|
-
}), !e) throw new Error("Cannot pipe without source");
|
|
2171
|
-
i ? e.on("data", (r) => {
|
|
2172
|
-
i.write(r);
|
|
2173
|
-
}) : e.on("data", (r) => {
|
|
2174
|
-
super[or](r);
|
|
2175
|
-
});
|
|
2176
|
-
}
|
|
2177
|
-
};
|
|
2178
|
-
var Wn = (s, t) => {
|
|
2179
|
-
let e = new kt(s), i = new Wt(s.file, { mode: s.mode || 438 });
|
|
2180
|
-
e.pipe(i), ar(e, t);
|
|
2181
|
-
}, Gn = (s, t) => {
|
|
2182
|
-
let e = new wt(s), i = new tt(s.file, { mode: s.mode || 438 });
|
|
2183
|
-
e.pipe(i);
|
|
2184
|
-
let r = new Promise((n, o) => {
|
|
2185
|
-
i.on("error", o), i.on("close", n), e.on("error", o);
|
|
2186
|
-
});
|
|
2187
|
-
return lr(e, t).catch((n) => e.emit("error", n)), r;
|
|
2188
|
-
}, ar = (s, t) => {
|
|
2189
|
-
t.forEach((e) => {
|
|
2190
|
-
e.charAt(0) === "@" ? Ft({
|
|
2191
|
-
file: node_path$1.default.resolve(s.cwd, e.slice(1)),
|
|
2192
|
-
sync: !0,
|
|
2193
|
-
noResume: !0,
|
|
2194
|
-
onReadEntry: (i) => s.add(i)
|
|
2195
|
-
}) : s.add(e);
|
|
2196
|
-
}), s.end();
|
|
2197
|
-
}, lr = async (s, t) => {
|
|
2198
|
-
for (let e of t) e.charAt(0) === "@" ? await Ft({
|
|
2199
|
-
file: node_path$1.default.resolve(String(s.cwd), e.slice(1)),
|
|
2200
|
-
noResume: !0,
|
|
2201
|
-
onReadEntry: (i) => {
|
|
2202
|
-
s.add(i);
|
|
2203
|
-
}
|
|
2204
|
-
}) : s.add(e);
|
|
2205
|
-
s.end();
|
|
2206
|
-
}, Zn = (s, t) => {
|
|
2207
|
-
let e = new kt(s);
|
|
2208
|
-
return ar(e, t), e;
|
|
2209
|
-
}, Yn = (s, t) => {
|
|
2210
|
-
let e = new wt(s);
|
|
2211
|
-
return lr(e, t).catch((i) => e.emit("error", i)), e;
|
|
2212
|
-
}, Kn = K(Wn, Gn, Zn, Yn, (s, t) => {
|
|
2213
|
-
if (!t?.length) throw new TypeError("no paths specified to add to archive");
|
|
2214
|
-
});
|
|
2215
|
-
var ur = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: mr, O_NOFOLLOW: cr, O_TRUNC: pr, O_WRONLY: Er } = fs.default.constants, wr = Number(process.env.__FAKE_FS_O_FILENAME__) || fs.default.constants.UV_FS_O_FILEMAP || 0, $n = ur && !!wr, Xn = 512 * 1024, qn = wr | pr | mr | Er, fr = !ur && typeof cr == "number" ? cr | pr | mr | Er : null, ds = fr !== null ? () => fr : $n ? (s) => s < Xn ? qn : "w" : () => "w";
|
|
2216
|
-
var us = (s, t, e) => {
|
|
2217
|
-
try {
|
|
2218
|
-
return node_fs$1.default.lchownSync(s, t, e);
|
|
2219
|
-
} catch (i) {
|
|
2220
|
-
if (i?.code !== "ENOENT") throw i;
|
|
2221
|
-
}
|
|
2222
|
-
}, pi = (s, t, e, i) => {
|
|
2223
|
-
node_fs$1.default.lchown(s, t, e, (r) => {
|
|
2224
|
-
i(r && r?.code !== "ENOENT" ? r : null);
|
|
2225
|
-
});
|
|
2226
|
-
}, Qn = (s, t, e, i, r) => {
|
|
2227
|
-
if (t.isDirectory()) ms(node_path$1.default.resolve(s, t.name), e, i, (n) => {
|
|
2228
|
-
if (n) return r(n);
|
|
2229
|
-
pi(node_path$1.default.resolve(s, t.name), e, i, r);
|
|
2230
|
-
});
|
|
2231
|
-
else pi(node_path$1.default.resolve(s, t.name), e, i, r);
|
|
2232
|
-
}, ms = (s, t, e, i) => {
|
|
2233
|
-
node_fs$1.default.readdir(s, { withFileTypes: !0 }, (r, n) => {
|
|
2234
|
-
if (r) {
|
|
2235
|
-
if (r.code === "ENOENT") return i();
|
|
2236
|
-
if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
|
|
2237
|
-
}
|
|
2238
|
-
if (r || !n.length) return pi(s, t, e, i);
|
|
2239
|
-
let o = n.length, a = null, h = (l) => {
|
|
2240
|
-
if (!a) {
|
|
2241
|
-
if (l) return i(a = l);
|
|
2242
|
-
if (--o === 0) return pi(s, t, e, i);
|
|
2243
|
-
}
|
|
2244
|
-
};
|
|
2245
|
-
for (let l of n) Qn(s, l, t, e, h);
|
|
2246
|
-
});
|
|
2247
|
-
}, Jn = (s, t, e, i) => {
|
|
2248
|
-
t.isDirectory() && ps(node_path$1.default.resolve(s, t.name), e, i), us(node_path$1.default.resolve(s, t.name), e, i);
|
|
2249
|
-
}, ps = (s, t, e) => {
|
|
2250
|
-
let i;
|
|
2251
|
-
try {
|
|
2252
|
-
i = node_fs$1.default.readdirSync(s, { withFileTypes: !0 });
|
|
2253
|
-
} catch (r) {
|
|
2254
|
-
let n = r;
|
|
2255
|
-
if (n?.code === "ENOENT") return;
|
|
2256
|
-
if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return us(s, t, e);
|
|
2257
|
-
throw n;
|
|
2258
|
-
}
|
|
2259
|
-
for (let r of i) Jn(s, r, t, e);
|
|
2260
|
-
return us(s, t, e);
|
|
2261
|
-
};
|
|
2262
|
-
var we = class extends Error {
|
|
2263
|
-
path;
|
|
2264
|
-
code;
|
|
2265
|
-
syscall = "chdir";
|
|
2266
|
-
constructor(t, e) {
|
|
2267
|
-
super(`${e}: Cannot cd into '${t}'`), this.path = t, this.code = e;
|
|
2268
|
-
}
|
|
2269
|
-
get name() {
|
|
2270
|
-
return "CwdError";
|
|
2271
|
-
}
|
|
2272
|
-
};
|
|
2273
|
-
var St = class extends Error {
|
|
2274
|
-
path;
|
|
2275
|
-
symlink;
|
|
2276
|
-
syscall = "symlink";
|
|
2277
|
-
code = "TAR_SYMLINK_ERROR";
|
|
2278
|
-
constructor(t, e) {
|
|
2279
|
-
super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"), this.symlink = t, this.path = e;
|
|
2280
|
-
}
|
|
2281
|
-
get name() {
|
|
2282
|
-
return "SymlinkError";
|
|
2283
|
-
}
|
|
2284
|
-
};
|
|
2285
|
-
var to = (s, t) => {
|
|
2286
|
-
node_fs$1.default.stat(s, (e, i) => {
|
|
2287
|
-
(e || !i.isDirectory()) && (e = new we(s, e?.code || "ENOTDIR")), t(e);
|
|
2288
|
-
});
|
|
2289
|
-
}, Sr = (s, t, e) => {
|
|
2290
|
-
s = f$1(s);
|
|
2291
|
-
let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, a = t.gid, h = typeof o == "number" && typeof a == "number" && (o !== t.processUid || a !== t.processGid), l = t.preserve, c = t.unlink, d = f$1(t.cwd), S = (E, x) => {
|
|
2292
|
-
E ? e(E) : x && h ? ms(x, o, a, (xe) => S(xe)) : n ? node_fs$1.default.chmod(s, r, e) : e();
|
|
2293
|
-
};
|
|
2294
|
-
if (s === d) return to(s, S);
|
|
2295
|
-
if (l) return node_fs_promises$1.default.mkdir(s, {
|
|
2296
|
-
mode: r,
|
|
2297
|
-
recursive: !0
|
|
2298
|
-
}).then((E) => S(null, E ?? void 0), S);
|
|
2299
|
-
Es(d, f$1(node_path$1.default.relative(d, s)).split("/"), r, c, d, void 0, S);
|
|
2300
|
-
}, Es = (s, t, e, i, r, n, o) => {
|
|
2301
|
-
if (t.length === 0) return o(null, n);
|
|
2302
|
-
let a = t.shift(), h = f$1(node_path$1.default.resolve(s + "/" + a));
|
|
2303
|
-
node_fs$1.default.mkdir(h, e, yr(h, t, e, i, r, n, o));
|
|
2304
|
-
}, yr = (s, t, e, i, r, n, o) => (a) => {
|
|
2305
|
-
a ? node_fs$1.default.lstat(s, (h, l) => {
|
|
2306
|
-
if (h) h.path = h.path && f$1(h.path), o(h);
|
|
2307
|
-
else if (l.isDirectory()) Es(s, t, e, i, r, n, o);
|
|
2308
|
-
else if (i) node_fs$1.default.unlink(s, (c) => {
|
|
2309
|
-
if (c) return o(c);
|
|
2310
|
-
node_fs$1.default.mkdir(s, e, yr(s, t, e, i, r, n, o));
|
|
2311
|
-
});
|
|
2312
|
-
else {
|
|
2313
|
-
if (l.isSymbolicLink()) return o(new St(s, s + "/" + t.join("/")));
|
|
2314
|
-
o(a);
|
|
2315
|
-
}
|
|
2316
|
-
}) : (n = n || s, Es(s, t, e, i, r, n, o));
|
|
2317
|
-
}, eo = (s) => {
|
|
2318
|
-
let t = !1, e;
|
|
2319
|
-
try {
|
|
2320
|
-
t = node_fs$1.default.statSync(s).isDirectory();
|
|
2321
|
-
} catch (i) {
|
|
2322
|
-
e = i?.code;
|
|
2323
|
-
} finally {
|
|
2324
|
-
if (!t) throw new we(s, e ?? "ENOTDIR");
|
|
2325
|
-
}
|
|
2326
|
-
}, Rr = (s, t) => {
|
|
2327
|
-
s = f$1(s);
|
|
2328
|
-
let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, a = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), h = t.preserve, l = t.unlink, c = f$1(t.cwd), d = (E) => {
|
|
2329
|
-
E && a && ps(E, n, o), r && node_fs$1.default.chmodSync(s, i);
|
|
2330
|
-
};
|
|
2331
|
-
if (s === c) return eo(c), d();
|
|
2332
|
-
if (h) return d(node_fs$1.default.mkdirSync(s, {
|
|
2333
|
-
mode: i,
|
|
2334
|
-
recursive: !0
|
|
2335
|
-
}) ?? void 0);
|
|
2336
|
-
let T = f$1(node_path$1.default.relative(c, s)).split("/"), N;
|
|
2337
|
-
for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
|
|
2338
|
-
x = f$1(node_path$1.default.resolve(x));
|
|
2339
|
-
try {
|
|
2340
|
-
node_fs$1.default.mkdirSync(x, i), N = N || x;
|
|
2341
|
-
} catch {
|
|
2342
|
-
let xe = node_fs$1.default.lstatSync(x);
|
|
2343
|
-
if (xe.isDirectory()) continue;
|
|
2344
|
-
if (l) {
|
|
2345
|
-
node_fs$1.default.unlinkSync(x), node_fs$1.default.mkdirSync(x, i), N = N || x;
|
|
2346
|
-
continue;
|
|
2347
|
-
} else if (xe.isSymbolicLink()) return new St(x, x + "/" + T.join("/"));
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
return d(N);
|
|
2351
|
-
};
|
|
2352
|
-
var ws = Object.create(null), gr = 1e4, Vt = /* @__PURE__ */ new Set(), br = (s) => {
|
|
2353
|
-
Vt.has(s) ? Vt.delete(s) : ws[s] = s.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"), Vt.add(s);
|
|
2354
|
-
let t = ws[s], e = Vt.size - gr;
|
|
2355
|
-
if (e > gr / 10) {
|
|
2356
|
-
for (let i of Vt) if (Vt.delete(i), delete ws[i], --e <= 0) break;
|
|
2357
|
-
}
|
|
2358
|
-
return t;
|
|
2359
|
-
};
|
|
2360
|
-
var so = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32", ro = (s) => s.split("/").slice(0, -1).reduce((e, i) => {
|
|
2361
|
-
let r = e.at(-1);
|
|
2362
|
-
return r !== void 0 && (i = (0, node_path$1.join)(r, i)), e.push(i || "/"), e;
|
|
2363
|
-
}, []), Si = class {
|
|
2364
|
-
#t = /* @__PURE__ */ new Map();
|
|
2365
|
-
#i = /* @__PURE__ */ new Map();
|
|
2366
|
-
#s = /* @__PURE__ */ new Set();
|
|
2367
|
-
reserve(t, e) {
|
|
2368
|
-
t = so ? ["win32 parallelization disabled"] : t.map((r) => mt((0, node_path$1.join)(br(r))));
|
|
2369
|
-
let i = new Set(t.map((r) => ro(r)).reduce((r, n) => r.concat(n)));
|
|
2370
|
-
this.#i.set(e, {
|
|
2371
|
-
dirs: i,
|
|
2372
|
-
paths: t
|
|
2373
|
-
});
|
|
2374
|
-
for (let r of t) {
|
|
2375
|
-
let n = this.#t.get(r);
|
|
2376
|
-
n ? n.push(e) : this.#t.set(r, [e]);
|
|
2377
|
-
}
|
|
2378
|
-
for (let r of i) {
|
|
2379
|
-
let n = this.#t.get(r);
|
|
2380
|
-
if (!n) this.#t.set(r, [new Set([e])]);
|
|
2381
|
-
else {
|
|
2382
|
-
let o = n.at(-1);
|
|
2383
|
-
o instanceof Set ? o.add(e) : n.push(new Set([e]));
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
return this.#r(e);
|
|
2387
|
-
}
|
|
2388
|
-
#n(t) {
|
|
2389
|
-
let e = this.#i.get(t);
|
|
2390
|
-
if (!e) throw new Error("function does not have any path reservations");
|
|
2391
|
-
return {
|
|
2392
|
-
paths: e.paths.map((i) => this.#t.get(i)),
|
|
2393
|
-
dirs: [...e.dirs].map((i) => this.#t.get(i))
|
|
2394
|
-
};
|
|
2395
|
-
}
|
|
2396
|
-
check(t) {
|
|
2397
|
-
let { paths: e, dirs: i } = this.#n(t);
|
|
2398
|
-
return e.every((r) => r && r[0] === t) && i.every((r) => r && r[0] instanceof Set && r[0].has(t));
|
|
2399
|
-
}
|
|
2400
|
-
#r(t) {
|
|
2401
|
-
return this.#s.has(t) || !this.check(t) ? !1 : (this.#s.add(t), t(() => this.#e(t)), !0);
|
|
2402
|
-
}
|
|
2403
|
-
#e(t) {
|
|
2404
|
-
if (!this.#s.has(t)) return !1;
|
|
2405
|
-
let e = this.#i.get(t);
|
|
2406
|
-
if (!e) throw new Error("invalid reservation");
|
|
2407
|
-
let { paths: i, dirs: r } = e, n = /* @__PURE__ */ new Set();
|
|
2408
|
-
for (let o of i) {
|
|
2409
|
-
let a = this.#t.get(o);
|
|
2410
|
-
if (!a || a?.[0] !== t) continue;
|
|
2411
|
-
let h = a[1];
|
|
2412
|
-
if (!h) {
|
|
2413
|
-
this.#t.delete(o);
|
|
2414
|
-
continue;
|
|
2415
|
-
}
|
|
2416
|
-
if (a.shift(), typeof h == "function") n.add(h);
|
|
2417
|
-
else for (let l of h) n.add(l);
|
|
2418
|
-
}
|
|
2419
|
-
for (let o of r) {
|
|
2420
|
-
let a = this.#t.get(o), h = a?.[0];
|
|
2421
|
-
if (!(!a || !(h instanceof Set))) if (h.size === 1 && a.length === 1) {
|
|
2422
|
-
this.#t.delete(o);
|
|
2423
|
-
continue;
|
|
2424
|
-
} else if (h.size === 1) {
|
|
2425
|
-
a.shift();
|
|
2426
|
-
let l = a[0];
|
|
2427
|
-
typeof l == "function" && n.add(l);
|
|
2428
|
-
} else h.delete(t);
|
|
2429
|
-
}
|
|
2430
|
-
return this.#s.delete(t), n.forEach((o) => this.#r(o)), !0;
|
|
2431
|
-
}
|
|
2432
|
-
};
|
|
2433
|
-
var Or = () => process.umask();
|
|
2434
|
-
var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs = Symbol("isReusable"), P$1 = Symbol("makeFs"), _s = Symbol("file"), Os = Symbol("directory"), Ri = Symbol("link"), Lr = Symbol("symlink"), Nr = Symbol("hardlink"), ye = Symbol("ensureNoSymlink"), Dr = Symbol("unsupported"), Ar = Symbol("checkPath"), Ss = Symbol("stripAbsolutePath"), yt = Symbol("mkdir"), O$1 = Symbol("onError"), yi = Symbol("pending"), Ir = Symbol("pend"), $t = Symbol("unpend"), ys = Symbol("ended"), Rs = Symbol("maybeClose"), Ts = Symbol("skip"), Re = Symbol("doChown"), ge = Symbol("uid"), be = Symbol("gid"), _e = Symbol("checkedCwd"), Oe = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32", ho = 1024, ao = (s, t) => {
|
|
2435
|
-
if (!Oe) return node_fs$1.default.unlink(s, t);
|
|
2436
|
-
let e = s + ".DELETE." + (0, node_crypto.randomBytes)(16).toString("hex");
|
|
2437
|
-
node_fs$1.default.rename(s, e, (i) => {
|
|
2438
|
-
if (i) return t(i);
|
|
2439
|
-
node_fs$1.default.unlink(e, t);
|
|
2440
|
-
});
|
|
2441
|
-
}, lo = (s) => {
|
|
2442
|
-
if (!Oe) return node_fs$1.default.unlinkSync(s);
|
|
2443
|
-
let t = s + ".DELETE." + (0, node_crypto.randomBytes)(16).toString("hex");
|
|
2444
|
-
node_fs$1.default.renameSync(s, t), node_fs$1.default.unlinkSync(t);
|
|
2445
|
-
}, Fr = (s, t, e) => s !== void 0 && s === s >>> 0 ? s : t !== void 0 && t === t >>> 0 ? t : e, Xt = class extends st {
|
|
2446
|
-
[ys] = !1;
|
|
2447
|
-
[_e] = !1;
|
|
2448
|
-
[yi] = 0;
|
|
2449
|
-
reservations = new Si();
|
|
2450
|
-
transform;
|
|
2451
|
-
writable = !0;
|
|
2452
|
-
readable = !1;
|
|
2453
|
-
uid;
|
|
2454
|
-
gid;
|
|
2455
|
-
setOwner;
|
|
2456
|
-
preserveOwner;
|
|
2457
|
-
processGid;
|
|
2458
|
-
processUid;
|
|
2459
|
-
maxDepth;
|
|
2460
|
-
forceChown;
|
|
2461
|
-
win32;
|
|
2462
|
-
newer;
|
|
2463
|
-
keep;
|
|
2464
|
-
noMtime;
|
|
2465
|
-
preservePaths;
|
|
2466
|
-
unlink;
|
|
2467
|
-
cwd;
|
|
2468
|
-
strip;
|
|
2469
|
-
processUmask;
|
|
2470
|
-
umask;
|
|
2471
|
-
dmode;
|
|
2472
|
-
fmode;
|
|
2473
|
-
chmod;
|
|
2474
|
-
constructor(t = {}) {
|
|
2475
|
-
if (t.ondone = () => {
|
|
2476
|
-
this[ys] = !0, this[Rs]();
|
|
2477
|
-
}, super(t), this.transform = t.transform, this.chmod = !!t.chmod, typeof t.uid == "number" || typeof t.gid == "number") {
|
|
2478
|
-
if (typeof t.uid != "number" || typeof t.gid != "number") throw new TypeError("cannot set owner without number uid and gid");
|
|
2479
|
-
if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
|
|
2480
|
-
this.uid = t.uid, this.gid = t.gid, this.setOwner = !0;
|
|
2481
|
-
} else this.uid = void 0, this.gid = void 0, this.setOwner = !1;
|
|
2482
|
-
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? !!(process.getuid && process.getuid() === 0) : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : ho, this.forceChown = t.forceChown === !0, this.win32 = !!t.win32 || Oe, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f$1(node_path$1.default.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Or() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Tr](e));
|
|
2483
|
-
}
|
|
2484
|
-
warn(t, e, i = {}) {
|
|
2485
|
-
return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = !1), super.warn(t, e, i);
|
|
2486
|
-
}
|
|
2487
|
-
[Rs]() {
|
|
2488
|
-
this[ys] && this[yi] === 0 && (this.emit("prefinish"), this.emit("finish"), this.emit("end"));
|
|
2489
|
-
}
|
|
2490
|
-
[Ss](t, e) {
|
|
2491
|
-
let i = t[e], { type: r } = t;
|
|
2492
|
-
if (!i || this.preservePaths) return !0;
|
|
2493
|
-
let [n, o] = le(i), a = o.replaceAll(/\\/g, "/").split("/");
|
|
2494
|
-
if (a.includes("..") || Oe && /^[a-z]:\.\.$/i.test(a[0] ?? "")) {
|
|
2495
|
-
if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, {
|
|
2496
|
-
entry: t,
|
|
2497
|
-
[e]: i
|
|
2498
|
-
}), !1;
|
|
2499
|
-
let h = node_path$1.default.posix.dirname(t.path), l = node_path$1.default.posix.normalize(node_path$1.default.posix.join(h, a.join("/")));
|
|
2500
|
-
if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, {
|
|
2501
|
-
entry: t,
|
|
2502
|
-
[e]: i
|
|
2503
|
-
}), !1;
|
|
2504
|
-
}
|
|
2505
|
-
return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, {
|
|
2506
|
-
entry: t,
|
|
2507
|
-
[e]: i
|
|
2508
|
-
})), !0;
|
|
2509
|
-
}
|
|
2510
|
-
[Ar](t) {
|
|
2511
|
-
let e = f$1(t.path), i = e.split("/");
|
|
2512
|
-
if (this.strip) {
|
|
2513
|
-
if (i.length < this.strip) return !1;
|
|
2514
|
-
if (t.type === "Link") {
|
|
2515
|
-
let r = f$1(String(t.linkpath)).split("/");
|
|
2516
|
-
if (r.length >= this.strip) t.linkpath = r.slice(this.strip).join("/");
|
|
2517
|
-
else return !1;
|
|
2518
|
-
}
|
|
2519
|
-
i.splice(0, this.strip), t.path = i.join("/");
|
|
2520
|
-
}
|
|
2521
|
-
if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", {
|
|
2522
|
-
entry: t,
|
|
2523
|
-
path: e,
|
|
2524
|
-
depth: i.length,
|
|
2525
|
-
maxDepth: this.maxDepth
|
|
2526
|
-
}), !1;
|
|
2527
|
-
if (!this[Ss](t, "path") || !this[Ss](t, "linkpath")) return !1;
|
|
2528
|
-
if (t.absolute = node_path$1.default.isAbsolute(t.path) ? f$1(node_path$1.default.resolve(t.path)) : f$1(node_path$1.default.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
|
|
2529
|
-
entry: t,
|
|
2530
|
-
path: f$1(t.path),
|
|
2531
|
-
resolvedPath: t.absolute,
|
|
2532
|
-
cwd: this.cwd
|
|
2533
|
-
}), !1;
|
|
2534
|
-
if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return !1;
|
|
2535
|
-
if (this.win32) {
|
|
2536
|
-
let { root: r } = node_path$1.default.win32.parse(String(t.absolute));
|
|
2537
|
-
t.absolute = r + Ji(String(t.absolute).slice(r.length));
|
|
2538
|
-
let { root: n } = node_path$1.default.win32.parse(t.path);
|
|
2539
|
-
t.path = n + Ji(t.path.slice(n.length));
|
|
2540
|
-
}
|
|
2541
|
-
return !0;
|
|
2542
|
-
}
|
|
2543
|
-
[Tr](t) {
|
|
2544
|
-
if (!this[Ar](t)) return t.resume();
|
|
2545
|
-
switch (node_assert.default.equal(typeof t.absolute, "string"), t.type) {
|
|
2546
|
-
case "Directory":
|
|
2547
|
-
case "GNUDumpDir": t.mode && (t.mode = t.mode | 448);
|
|
2548
|
-
case "File":
|
|
2549
|
-
case "OldFile":
|
|
2550
|
-
case "ContiguousFile":
|
|
2551
|
-
case "Link":
|
|
2552
|
-
case "SymbolicLink": return this[gs](t);
|
|
2553
|
-
default: return this[Dr](t);
|
|
2554
|
-
}
|
|
2555
|
-
}
|
|
2556
|
-
[O$1](t, e) {
|
|
2557
|
-
t.name === "CwdError" ? this.emit("error", t) : (this.warn("TAR_ENTRY_ERROR", t, { entry: e }), this[$t](), e.resume());
|
|
2558
|
-
}
|
|
2559
|
-
[yt](t, e, i) {
|
|
2560
|
-
Sr(f$1(t), {
|
|
2561
|
-
uid: this.uid,
|
|
2562
|
-
gid: this.gid,
|
|
2563
|
-
processUid: this.processUid,
|
|
2564
|
-
processGid: this.processGid,
|
|
2565
|
-
umask: this.processUmask,
|
|
2566
|
-
preserve: this.preservePaths,
|
|
2567
|
-
unlink: this.unlink,
|
|
2568
|
-
cwd: this.cwd,
|
|
2569
|
-
mode: e
|
|
2570
|
-
}, i);
|
|
2571
|
-
}
|
|
2572
|
-
[Re](t) {
|
|
2573
|
-
return this.forceChown || this.preserveOwner && (typeof t.uid == "number" && t.uid !== this.processUid || typeof t.gid == "number" && t.gid !== this.processGid) || typeof this.uid == "number" && this.uid !== this.processUid || typeof this.gid == "number" && this.gid !== this.processGid;
|
|
2574
|
-
}
|
|
2575
|
-
[ge](t) {
|
|
2576
|
-
return Fr(this.uid, t.uid, this.processUid);
|
|
2577
|
-
}
|
|
2578
|
-
[be](t) {
|
|
2579
|
-
return Fr(this.gid, t.gid, this.processGid);
|
|
2580
|
-
}
|
|
2581
|
-
[_s](t, e) {
|
|
2582
|
-
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new tt(String(t.absolute), {
|
|
2583
|
-
flags: ds(t.size),
|
|
2584
|
-
mode: i,
|
|
2585
|
-
autoClose: !1
|
|
2586
|
-
});
|
|
2587
|
-
r.on("error", (h) => {
|
|
2588
|
-
r.fd && node_fs$1.default.close(r.fd, () => {}), r.write = () => !0, this[O$1](h, t), e();
|
|
2589
|
-
});
|
|
2590
|
-
let n = 1, o = (h) => {
|
|
2591
|
-
if (h) {
|
|
2592
|
-
r.fd && node_fs$1.default.close(r.fd, () => {}), this[O$1](h, t), e();
|
|
2593
|
-
return;
|
|
2594
|
-
}
|
|
2595
|
-
--n === 0 && r.fd !== void 0 && node_fs$1.default.close(r.fd, (l) => {
|
|
2596
|
-
l ? this[O$1](l, t) : this[$t](), e();
|
|
2597
|
-
});
|
|
2598
|
-
};
|
|
2599
|
-
r.on("finish", () => {
|
|
2600
|
-
let h = String(t.absolute), l = r.fd;
|
|
2601
|
-
if (typeof l == "number" && t.mtime && !this.noMtime) {
|
|
2602
|
-
n++;
|
|
2603
|
-
let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
|
|
2604
|
-
node_fs$1.default.futimes(l, c, d, (S) => S ? node_fs$1.default.utimes(h, c, d, (T) => o(T && S)) : o());
|
|
2605
|
-
}
|
|
2606
|
-
if (typeof l == "number" && this[Re](t)) {
|
|
2607
|
-
n++;
|
|
2608
|
-
let c = this[ge](t), d = this[be](t);
|
|
2609
|
-
typeof c == "number" && typeof d == "number" && node_fs$1.default.fchown(l, c, d, (S) => S ? node_fs$1.default.chown(h, c, d, (T) => o(T && S)) : o());
|
|
2610
|
-
}
|
|
2611
|
-
o();
|
|
2612
|
-
});
|
|
2613
|
-
let a = this.transform && this.transform(t) || t;
|
|
2614
|
-
a !== t && (a.on("error", (h) => {
|
|
2615
|
-
this[O$1](h, t), e();
|
|
2616
|
-
}), t.pipe(a)), a.pipe(r);
|
|
2617
|
-
}
|
|
2618
|
-
[Os](t, e) {
|
|
2619
|
-
let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode;
|
|
2620
|
-
this[yt](String(t.absolute), i, (r) => {
|
|
2621
|
-
if (r) {
|
|
2622
|
-
this[O$1](r, t), e();
|
|
2623
|
-
return;
|
|
2624
|
-
}
|
|
2625
|
-
let n = 1, o = () => {
|
|
2626
|
-
--n === 0 && (e(), this[$t](), t.resume());
|
|
2627
|
-
};
|
|
2628
|
-
t.mtime && !this.noMtime && (n++, node_fs$1.default.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[Re](t) && (n++, node_fs$1.default.chown(String(t.absolute), Number(this[ge](t)), Number(this[be](t)), o)), o();
|
|
2629
|
-
});
|
|
2630
|
-
}
|
|
2631
|
-
[Dr](t) {
|
|
2632
|
-
t.unsupported = !0, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
|
|
2633
|
-
}
|
|
2634
|
-
[Lr](t, e) {
|
|
2635
|
-
let i = f$1(node_path$1.default.relative(this.cwd, node_path$1.default.resolve(node_path$1.default.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
|
|
2636
|
-
this[ye](t, this.cwd, i, () => this[Ri](t, String(t.linkpath), "symlink", e), (r) => {
|
|
2637
|
-
this[O$1](r, t), e();
|
|
2638
|
-
});
|
|
2639
|
-
}
|
|
2640
|
-
[Nr](t, e) {
|
|
2641
|
-
let i = f$1(node_path$1.default.resolve(this.cwd, String(t.linkpath))), r = f$1(String(t.linkpath)).split("/");
|
|
2642
|
-
this[ye](t, this.cwd, r, () => this[Ri](t, i, "link", e), (n) => {
|
|
2643
|
-
this[O$1](n, t), e();
|
|
2644
|
-
});
|
|
2645
|
-
}
|
|
2646
|
-
[ye](t, e, i, r, n) {
|
|
2647
|
-
let o = i.shift();
|
|
2648
|
-
if (this.preservePaths || o === void 0) return r();
|
|
2649
|
-
let a = node_path$1.default.resolve(e, o);
|
|
2650
|
-
node_fs$1.default.lstat(a, (h, l) => {
|
|
2651
|
-
if (h) return r();
|
|
2652
|
-
if (l?.isSymbolicLink()) return n(new St(a, node_path$1.default.resolve(a, i.join("/"))));
|
|
2653
|
-
this[ye](t, a, i, r, n);
|
|
2654
|
-
});
|
|
2655
|
-
}
|
|
2656
|
-
[Ir]() {
|
|
2657
|
-
this[yi]++;
|
|
2658
|
-
}
|
|
2659
|
-
[$t]() {
|
|
2660
|
-
this[yi]--, this[Rs]();
|
|
2661
|
-
}
|
|
2662
|
-
[Ts](t) {
|
|
2663
|
-
this[$t](), t.resume();
|
|
2664
|
-
}
|
|
2665
|
-
[bs](t, e) {
|
|
2666
|
-
return t.type === "File" && !this.unlink && e.isFile() && e.nlink <= 1 && !Oe;
|
|
2667
|
-
}
|
|
2668
|
-
[gs](t) {
|
|
2669
|
-
this[Ir]();
|
|
2670
|
-
let e = [t.path];
|
|
2671
|
-
t.linkpath && e.push(t.linkpath), this.reservations.reserve(e, (i) => this[xr](t, i));
|
|
2672
|
-
}
|
|
2673
|
-
[xr](t, e) {
|
|
2674
|
-
let i = (a) => {
|
|
2675
|
-
e(a);
|
|
2676
|
-
}, r = () => {
|
|
2677
|
-
this[yt](this.cwd, this.dmode, (a) => {
|
|
2678
|
-
if (a) {
|
|
2679
|
-
this[O$1](a, t), i();
|
|
2680
|
-
return;
|
|
2681
|
-
}
|
|
2682
|
-
this[_e] = !0, n();
|
|
2683
|
-
});
|
|
2684
|
-
}, n = () => {
|
|
2685
|
-
if (t.absolute !== this.cwd) {
|
|
2686
|
-
let a = f$1(node_path$1.default.dirname(String(t.absolute)));
|
|
2687
|
-
if (a !== this.cwd) return this[yt](a, this.dmode, (h) => {
|
|
2688
|
-
if (h) {
|
|
2689
|
-
this[O$1](h, t), i();
|
|
2690
|
-
return;
|
|
2691
|
-
}
|
|
2692
|
-
o();
|
|
2693
|
-
});
|
|
2694
|
-
}
|
|
2695
|
-
o();
|
|
2696
|
-
}, o = () => {
|
|
2697
|
-
node_fs$1.default.lstat(String(t.absolute), (a, h) => {
|
|
2698
|
-
if (h && (this.keep || this.newer && h.mtime > (t.mtime ?? h.mtime))) {
|
|
2699
|
-
this[Ts](t), i();
|
|
2700
|
-
return;
|
|
2701
|
-
}
|
|
2702
|
-
if (a || this[bs](t, h)) return this[P$1](null, t, i);
|
|
2703
|
-
if (h.isDirectory()) {
|
|
2704
|
-
if (t.type === "Directory") {
|
|
2705
|
-
let l = this.chmod && t.mode && (h.mode & 4095) !== t.mode, c = (d) => this[P$1](d ?? null, t, i);
|
|
2706
|
-
return l ? node_fs$1.default.chmod(String(t.absolute), Number(t.mode), c) : c();
|
|
2707
|
-
}
|
|
2708
|
-
if (t.absolute !== this.cwd) return node_fs$1.default.rmdir(String(t.absolute), (l) => this[P$1](l ?? null, t, i));
|
|
2709
|
-
}
|
|
2710
|
-
if (t.absolute === this.cwd) return this[P$1](null, t, i);
|
|
2711
|
-
ao(String(t.absolute), (l) => this[P$1](l ?? null, t, i));
|
|
2712
|
-
});
|
|
2713
|
-
};
|
|
2714
|
-
this[_e] ? n() : r();
|
|
2715
|
-
}
|
|
2716
|
-
[P$1](t, e, i) {
|
|
2717
|
-
if (t) {
|
|
2718
|
-
this[O$1](t, e), i();
|
|
2719
|
-
return;
|
|
2720
|
-
}
|
|
2721
|
-
switch (e.type) {
|
|
2722
|
-
case "File":
|
|
2723
|
-
case "OldFile":
|
|
2724
|
-
case "ContiguousFile": return this[_s](e, i);
|
|
2725
|
-
case "Link": return this[Nr](e, i);
|
|
2726
|
-
case "SymbolicLink": return this[Lr](e, i);
|
|
2727
|
-
case "Directory":
|
|
2728
|
-
case "GNUDumpDir": return this[Os](e, i);
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
[Ri](t, e, i, r) {
|
|
2732
|
-
node_fs$1.default[i](e, String(t.absolute), (n) => {
|
|
2733
|
-
n ? this[O$1](n, t) : (this[$t](), t.resume()), r();
|
|
2734
|
-
});
|
|
2735
|
-
}
|
|
2736
|
-
}, Se = (s) => {
|
|
2737
|
-
try {
|
|
2738
|
-
return [null, s()];
|
|
2739
|
-
} catch (t) {
|
|
2740
|
-
return [t, null];
|
|
2741
|
-
}
|
|
2742
|
-
}, Te = class extends Xt {
|
|
2743
|
-
sync = !0;
|
|
2744
|
-
[P$1](t, e) {
|
|
2745
|
-
return super[P$1](t, e, () => {});
|
|
2746
|
-
}
|
|
2747
|
-
[gs](t) {
|
|
2748
|
-
if (!this[_e]) {
|
|
2749
|
-
let n = this[yt](this.cwd, this.dmode);
|
|
2750
|
-
if (n) return this[O$1](n, t);
|
|
2751
|
-
this[_e] = !0;
|
|
2752
|
-
}
|
|
2753
|
-
if (t.absolute !== this.cwd) {
|
|
2754
|
-
let n = f$1(node_path$1.default.dirname(String(t.absolute)));
|
|
2755
|
-
if (n !== this.cwd) {
|
|
2756
|
-
let o = this[yt](n, this.dmode);
|
|
2757
|
-
if (o) return this[O$1](o, t);
|
|
2758
|
-
}
|
|
2759
|
-
}
|
|
2760
|
-
let [e, i] = Se(() => node_fs$1.default.lstatSync(String(t.absolute)));
|
|
2761
|
-
if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ts](t);
|
|
2762
|
-
if (e || this[bs](t, i)) return this[P$1](null, t);
|
|
2763
|
-
if (i.isDirectory()) {
|
|
2764
|
-
if (t.type === "Directory") {
|
|
2765
|
-
let [a] = this.chmod && t.mode && (i.mode & 4095) !== t.mode ? Se(() => {
|
|
2766
|
-
node_fs$1.default.chmodSync(String(t.absolute), Number(t.mode));
|
|
2767
|
-
}) : [];
|
|
2768
|
-
return this[P$1](a, t);
|
|
2769
|
-
}
|
|
2770
|
-
let [n] = Se(() => node_fs$1.default.rmdirSync(String(t.absolute)));
|
|
2771
|
-
this[P$1](n, t);
|
|
2772
|
-
}
|
|
2773
|
-
let [r] = t.absolute === this.cwd ? [] : Se(() => lo(String(t.absolute)));
|
|
2774
|
-
this[P$1](r, t);
|
|
2775
|
-
}
|
|
2776
|
-
[_s](t, e) {
|
|
2777
|
-
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (a) => {
|
|
2778
|
-
let h;
|
|
2779
|
-
try {
|
|
2780
|
-
node_fs$1.default.closeSync(n);
|
|
2781
|
-
} catch (l) {
|
|
2782
|
-
h = l;
|
|
2783
|
-
}
|
|
2784
|
-
(a || h) && this[O$1](a || h, t), e();
|
|
2785
|
-
}, n;
|
|
2786
|
-
try {
|
|
2787
|
-
n = node_fs$1.default.openSync(String(t.absolute), ds(t.size), i);
|
|
2788
|
-
} catch (a) {
|
|
2789
|
-
return r(a);
|
|
2790
|
-
}
|
|
2791
|
-
let o = this.transform && this.transform(t) || t;
|
|
2792
|
-
o !== t && (o.on("error", (a) => this[O$1](a, t)), t.pipe(o)), o.on("data", (a) => {
|
|
2793
|
-
try {
|
|
2794
|
-
node_fs$1.default.writeSync(n, a, 0, a.length);
|
|
2795
|
-
} catch (h) {
|
|
2796
|
-
r(h);
|
|
2797
|
-
}
|
|
2798
|
-
}), o.on("end", () => {
|
|
2799
|
-
let a = null;
|
|
2800
|
-
if (t.mtime && !this.noMtime) {
|
|
2801
|
-
let h = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
|
|
2802
|
-
try {
|
|
2803
|
-
node_fs$1.default.futimesSync(n, h, l);
|
|
2804
|
-
} catch (c) {
|
|
2805
|
-
try {
|
|
2806
|
-
node_fs$1.default.utimesSync(String(t.absolute), h, l);
|
|
2807
|
-
} catch {
|
|
2808
|
-
a = c;
|
|
2809
|
-
}
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
if (this[Re](t)) {
|
|
2813
|
-
let h = this[ge](t), l = this[be](t);
|
|
2814
|
-
try {
|
|
2815
|
-
node_fs$1.default.fchownSync(n, Number(h), Number(l));
|
|
2816
|
-
} catch (c) {
|
|
2817
|
-
try {
|
|
2818
|
-
node_fs$1.default.chownSync(String(t.absolute), Number(h), Number(l));
|
|
2819
|
-
} catch {
|
|
2820
|
-
a = a || c;
|
|
2821
|
-
}
|
|
2822
|
-
}
|
|
2823
|
-
}
|
|
2824
|
-
r(a);
|
|
2825
|
-
});
|
|
2826
|
-
}
|
|
2827
|
-
[Os](t, e) {
|
|
2828
|
-
let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode, r = this[yt](String(t.absolute), i);
|
|
2829
|
-
if (r) {
|
|
2830
|
-
this[O$1](r, t), e();
|
|
2831
|
-
return;
|
|
2832
|
-
}
|
|
2833
|
-
if (t.mtime && !this.noMtime) try {
|
|
2834
|
-
node_fs$1.default.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
|
|
2835
|
-
} catch {}
|
|
2836
|
-
if (this[Re](t)) try {
|
|
2837
|
-
node_fs$1.default.chownSync(String(t.absolute), Number(this[ge](t)), Number(this[be](t)));
|
|
2838
|
-
} catch {}
|
|
2839
|
-
e(), t.resume();
|
|
2840
|
-
}
|
|
2841
|
-
[yt](t, e) {
|
|
2842
|
-
try {
|
|
2843
|
-
return Rr(f$1(t), {
|
|
2844
|
-
uid: this.uid,
|
|
2845
|
-
gid: this.gid,
|
|
2846
|
-
processUid: this.processUid,
|
|
2847
|
-
processGid: this.processGid,
|
|
2848
|
-
umask: this.processUmask,
|
|
2849
|
-
preserve: this.preservePaths,
|
|
2850
|
-
unlink: this.unlink,
|
|
2851
|
-
cwd: this.cwd,
|
|
2852
|
-
mode: e
|
|
2853
|
-
});
|
|
2854
|
-
} catch (i) {
|
|
2855
|
-
return i;
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2858
|
-
[ye](t, e, i, r, n) {
|
|
2859
|
-
if (this.preservePaths || i.length === 0) return r();
|
|
2860
|
-
let o = e;
|
|
2861
|
-
for (let a of i) {
|
|
2862
|
-
o = node_path$1.default.resolve(o, a);
|
|
2863
|
-
let [h, l] = Se(() => node_fs$1.default.lstatSync(o));
|
|
2864
|
-
if (h) return r();
|
|
2865
|
-
if (l.isSymbolicLink()) return n(new St(o, node_path$1.default.resolve(e, i.join("/"))));
|
|
2866
|
-
}
|
|
2867
|
-
r();
|
|
2868
|
-
}
|
|
2869
|
-
[Ri](t, e, i, r) {
|
|
2870
|
-
let n = `${i}Sync`;
|
|
2871
|
-
try {
|
|
2872
|
-
node_fs$1.default[n](e, String(t.absolute)), r(), t.resume();
|
|
2873
|
-
} catch (o) {
|
|
2874
|
-
return this[O$1](o, t);
|
|
2875
|
-
}
|
|
2876
|
-
}
|
|
2877
|
-
}, co = (s) => {
|
|
2878
|
-
let t = new Te(s), e = s.file, i = node_fs$1.default.statSync(e);
|
|
2879
|
-
new Me(e, {
|
|
2880
|
-
readSize: s.maxReadSize || 16 * 1024 * 1024,
|
|
2881
|
-
size: i.size
|
|
2882
|
-
}).pipe(t);
|
|
2883
|
-
}, fo = (s, t) => {
|
|
2884
|
-
let e = new Xt(s), i = s.maxReadSize || 16 * 1024 * 1024, r = s.file;
|
|
2885
|
-
return new Promise((o, a) => {
|
|
2886
|
-
e.on("error", a), e.on("close", o), node_fs$1.default.stat(r, (h, l) => {
|
|
2887
|
-
if (h) a(h);
|
|
2888
|
-
else {
|
|
2889
|
-
let c = new _t(r, {
|
|
2890
|
-
readSize: i,
|
|
2891
|
-
size: l.size
|
|
2892
|
-
});
|
|
2893
|
-
c.on("error", a), c.pipe(e);
|
|
2894
|
-
}
|
|
2895
|
-
});
|
|
2896
|
-
});
|
|
2897
|
-
};
|
|
2898
|
-
K(co, fo, (s) => new Te(s), (s) => new Xt(s), (s, t) => {
|
|
2899
|
-
t?.length && Xi(s, t);
|
|
2900
|
-
});
|
|
2901
|
-
var mo = (s, t) => {
|
|
2902
|
-
let e = new kt(s), i = !0, r, n;
|
|
2903
|
-
try {
|
|
2904
|
-
try {
|
|
2905
|
-
r = node_fs$1.default.openSync(s.file, "r+");
|
|
2906
|
-
} catch (h) {
|
|
2907
|
-
if (h?.code === "ENOENT") r = node_fs$1.default.openSync(s.file, "w+");
|
|
2908
|
-
else throw h;
|
|
2909
|
-
}
|
|
2910
|
-
let o = node_fs$1.default.fstatSync(r), a = Buffer.alloc(512);
|
|
2911
|
-
t: for (n = 0; n < o.size; n += 512) {
|
|
2912
|
-
for (let c = 0, d = 0; c < 512; c += d) {
|
|
2913
|
-
if (d = node_fs$1.default.readSync(r, a, c, a.length - c, n + c), n === 0 && a[0] === 31 && a[1] === 139) throw new Error("cannot append to compressed archives");
|
|
2914
|
-
if (!d) break t;
|
|
2915
|
-
}
|
|
2916
|
-
let h = new C$1(a);
|
|
2917
|
-
if (!h.cksumValid) break;
|
|
2918
|
-
let l = 512 * Math.ceil((h.size || 0) / 512);
|
|
2919
|
-
if (n + l + 512 > o.size) break;
|
|
2920
|
-
n += l, s.mtimeCache && h.mtime && s.mtimeCache.set(String(h.path), h.mtime);
|
|
2921
|
-
}
|
|
2922
|
-
i = !1, po(s, e, n, r, t);
|
|
2923
|
-
} finally {
|
|
2924
|
-
if (i) try {
|
|
2925
|
-
node_fs$1.default.closeSync(r);
|
|
2926
|
-
} catch {}
|
|
2927
|
-
}
|
|
2928
|
-
}, po = (s, t, e, i, r) => {
|
|
2929
|
-
let n = new Wt(s.file, {
|
|
2930
|
-
fd: i,
|
|
2931
|
-
start: e
|
|
2932
|
-
});
|
|
2933
|
-
t.pipe(n), wo(t, r);
|
|
2934
|
-
}, Eo = (s, t) => {
|
|
2935
|
-
t = Array.from(t);
|
|
2936
|
-
let e = new wt(s), i = (n, o, a) => {
|
|
2937
|
-
let h = (T, N) => {
|
|
2938
|
-
T ? node_fs$1.default.close(n, (E) => a(T)) : a(null, N);
|
|
2939
|
-
}, l = 0;
|
|
2940
|
-
if (o === 0) return h(null, 0);
|
|
2941
|
-
let c = 0, d = Buffer.alloc(512), S = (T, N) => {
|
|
2942
|
-
if (T || N === void 0) return h(T);
|
|
2943
|
-
if (c += N, c < 512 && N) return node_fs$1.default.read(n, d, c, d.length - c, l + c, S);
|
|
2944
|
-
if (l === 0 && d[0] === 31 && d[1] === 139) return h(/* @__PURE__ */ new Error("cannot append to compressed archives"));
|
|
2945
|
-
if (c < 512) return h(null, l);
|
|
2946
|
-
let E = new C$1(d);
|
|
2947
|
-
if (!E.cksumValid) return h(null, l);
|
|
2948
|
-
let x = 512 * Math.ceil((E.size ?? 0) / 512);
|
|
2949
|
-
if (l + x + 512 > o || (l += x + 512, l >= o)) return h(null, l);
|
|
2950
|
-
s.mtimeCache && E.mtime && s.mtimeCache.set(String(E.path), E.mtime), c = 0, node_fs$1.default.read(n, d, 0, 512, l, S);
|
|
2951
|
-
};
|
|
2952
|
-
node_fs$1.default.read(n, d, 0, 512, l, S);
|
|
2953
|
-
};
|
|
2954
|
-
return new Promise((n, o) => {
|
|
2955
|
-
e.on("error", o);
|
|
2956
|
-
let a = "r+", h = (l, c) => {
|
|
2957
|
-
if (l && l.code === "ENOENT" && a === "r+") return a = "w+", node_fs$1.default.open(s.file, a, h);
|
|
2958
|
-
if (l || !c) return o(l);
|
|
2959
|
-
node_fs$1.default.fstat(c, (d, S) => {
|
|
2960
|
-
if (d) return node_fs$1.default.close(c, () => o(d));
|
|
2961
|
-
i(c, S.size, (T, N) => {
|
|
2962
|
-
if (T) return o(T);
|
|
2963
|
-
let E = new tt(s.file, {
|
|
2964
|
-
fd: c,
|
|
2965
|
-
start: N
|
|
2966
|
-
});
|
|
2967
|
-
e.pipe(E), E.on("error", o), E.on("close", n), So(e, t);
|
|
2968
|
-
});
|
|
2969
|
-
});
|
|
2970
|
-
};
|
|
2971
|
-
node_fs$1.default.open(s.file, a, h);
|
|
2972
|
-
});
|
|
2973
|
-
}, wo = (s, t) => {
|
|
2974
|
-
t.forEach((e) => {
|
|
2975
|
-
e.charAt(0) === "@" ? Ft({
|
|
2976
|
-
file: node_path$1.default.resolve(s.cwd, e.slice(1)),
|
|
2977
|
-
sync: !0,
|
|
2978
|
-
noResume: !0,
|
|
2979
|
-
onReadEntry: (i) => s.add(i)
|
|
2980
|
-
}) : s.add(e);
|
|
2981
|
-
}), s.end();
|
|
2982
|
-
}, So = async (s, t) => {
|
|
2983
|
-
for (let e of t) e.charAt(0) === "@" ? await Ft({
|
|
2984
|
-
file: node_path$1.default.resolve(String(s.cwd), e.slice(1)),
|
|
2985
|
-
noResume: !0,
|
|
2986
|
-
onReadEntry: (i) => s.add(i)
|
|
2987
|
-
}) : s.add(e);
|
|
2988
|
-
s.end();
|
|
2989
|
-
}, vt = K(mo, Eo, () => {
|
|
2990
|
-
throw new TypeError("file is required");
|
|
2991
|
-
}, () => {
|
|
2992
|
-
throw new TypeError("file is required");
|
|
2993
|
-
}, (s, t) => {
|
|
2994
|
-
if (!vs(s)) throw new TypeError("file is required");
|
|
2995
|
-
if (s.gzip || s.brotli || s.zstd || s.file.endsWith(".br") || s.file.endsWith(".tbr")) throw new TypeError("cannot append to compressed archives");
|
|
2996
|
-
if (!t?.length) throw new TypeError("no paths specified to add/replace");
|
|
2997
|
-
});
|
|
2998
|
-
K(vt.syncFile, vt.asyncFile, vt.syncNoFile, vt.asyncNoFile, (s, t = []) => {
|
|
2999
|
-
vt.validate?.(s, t), Ro(s);
|
|
3000
|
-
});
|
|
3001
|
-
var Ro = (s) => {
|
|
3002
|
-
let t = s.filter;
|
|
3003
|
-
s.mtimeCache || (s.mtimeCache = /* @__PURE__ */ new Map()), s.filter = t ? (e, i) => t(e, i) && !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e, i) => !((s.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0));
|
|
3004
|
-
};
|
|
3005
|
-
//#endregion
|
|
3006
|
-
//#region src/builtins/system-backup/system-backup.service.ts
|
|
3007
|
-
/**
|
|
3008
|
-
* Thrown when an archive build (or a backup run driving one) is
|
|
3009
|
-
* stopped via its `AbortSignal`. Callers use `instanceof` to tell a
|
|
3010
|
-
* deliberate operator cancel from a real failure — a cancelled run is
|
|
3011
|
-
* an outcome, not an error to alert on. (D342)
|
|
3012
|
-
*/
|
|
3013
|
-
var BackupCancelledError = class extends Error {
|
|
3014
|
-
constructor(message = "backup run cancelled") {
|
|
3015
|
-
super(message);
|
|
3016
|
-
this.name = "BackupCancelledError";
|
|
3017
|
-
}
|
|
3018
|
-
};
|
|
3019
|
-
/**
|
|
3020
|
-
* Thrown when an archive would carry a live database and its owner could not
|
|
3021
|
-
* produce a verified snapshot of it (D693). Nothing was built: a run that
|
|
3022
|
-
* "succeeded" without the database — or with a torn copy of it — would push
|
|
3023
|
-
* the oldest good archive out of every destination's retention.
|
|
3024
|
-
*/
|
|
3025
|
-
var BackupSnapshotRefusedError = class extends Error {
|
|
3026
|
-
constructor(reason) {
|
|
3027
|
-
super(`settings database snapshot failed — no archive built, nothing uploaded, retention untouched: ${reason}`);
|
|
3028
|
-
this.name = "BackupSnapshotRefusedError";
|
|
3029
|
-
}
|
|
3030
|
-
};
|
|
3031
|
-
/**
|
|
3032
|
-
* Settle with `pending`, or reject with {@link BackupCancelledError} as soon as
|
|
3033
|
-
* `signal` fires. A pending call abandoned by the cancel still settles later:
|
|
3034
|
-
* `onAbandoned` runs then, to clean up what it produced.
|
|
3035
|
-
*/
|
|
3036
|
-
function raceAbort(pending, signal, onAbandoned) {
|
|
3037
|
-
if (signal === void 0) return pending;
|
|
3038
|
-
return new Promise((resolve, reject) => {
|
|
3039
|
-
let abandoned = false;
|
|
3040
|
-
const onAbort = () => {
|
|
3041
|
-
abandoned = true;
|
|
3042
|
-
reject(new BackupCancelledError());
|
|
3043
|
-
};
|
|
3044
|
-
if (signal.aborted) onAbort();
|
|
3045
|
-
else signal.addEventListener("abort", onAbort, { once: true });
|
|
3046
|
-
pending.then((value) => {
|
|
3047
|
-
signal.removeEventListener("abort", onAbort);
|
|
3048
|
-
if (abandoned) onAbandoned();
|
|
3049
|
-
else resolve(value);
|
|
3050
|
-
}, (err) => {
|
|
3051
|
-
signal.removeEventListener("abort", onAbort);
|
|
3052
|
-
if (abandoned) onAbandoned();
|
|
3053
|
-
else reject(err);
|
|
3054
|
-
});
|
|
3055
|
-
});
|
|
3056
|
-
}
|
|
3057
|
-
/** Throw `BackupCancelledError` when the signal has fired. */
|
|
3058
|
-
function throwIfCancelled(signal) {
|
|
3059
|
-
if (signal?.aborted) throw new BackupCancelledError();
|
|
3060
|
-
}
|
|
3061
|
-
/**
|
|
3062
|
-
* Default set of paths considered part of a "system backup". Includes
|
|
3063
|
-
* everything that isn't pure backend code — config, sqlite, addons
|
|
3064
|
-
* (runtime overlay), addons-data (per-addon private dir), TLS certs,
|
|
3065
|
-
* auto-update marker.
|
|
3066
|
-
*
|
|
3067
|
-
* Anything not listed is excluded by omission — recordings/, media/,
|
|
3068
|
-
* models/, logs/, cache/ (too large or fully recreatable). Note this
|
|
3069
|
-
* covers only TOP-LEVEL trees: bulk nested INSIDE a listed location
|
|
3070
|
-
* is excluded via `DEFAULT_BACKUP_EXCLUDES` + the node_modules rule
|
|
3071
|
-
* below, enforced in the walk and the tar filter alike.
|
|
3072
|
-
*/
|
|
3073
|
-
var DEFAULT_BACKUP_LOCATIONS = [
|
|
3074
|
-
"config.yaml",
|
|
3075
|
-
"addons",
|
|
3076
|
-
"addons-data",
|
|
3077
|
-
"tls",
|
|
3078
|
-
"auto-update.json"
|
|
3079
|
-
];
|
|
3080
|
-
/**
|
|
3081
|
-
* Subtrees never captured by a system backup even though they live
|
|
3082
|
-
* under a `DEFAULT_BACKUP_LOCATIONS` entry. Paths are dataDir-relative
|
|
3083
|
-
* prefixes. Two lessons from the live hub (2026-09-04, D-record
|
|
3084
|
-
* "backup excludes"):
|
|
3085
|
-
*
|
|
3086
|
-
* - `addons-data/backup-orchestrator/staging` — the orchestrator's
|
|
3087
|
-
* LEGACY staging dir (now `<dataDir>/backup-staging`, outside every
|
|
3088
|
-
* location). Before Jul 28 every archive nested all previous
|
|
3089
|
-
* archives (175M → 503M → 4.5G); leaked files from that era must
|
|
3090
|
-
* never be re-swept into new backups.
|
|
3091
|
-
* - `addons-data/recorder/exports` — operator-exported clips (8.4 GB
|
|
3092
|
-
* on the hub). Media, not system state; a restore has no use for it.
|
|
3093
|
-
*/
|
|
3094
|
-
var DEFAULT_BACKUP_EXCLUDES = ["addons-data/backup-orchestrator/staging", "addons-data/recorder/exports"];
|
|
3095
|
-
/**
|
|
3096
|
-
* Directory name excluded wherever it appears in the tree.
|
|
3097
|
-
* `AddonInstaller` materialises runtime deps under
|
|
3098
|
-
* `addons/@camstack/<addon>/node_modules` (~196 MB on the hub); only
|
|
3099
|
-
* built `dist` + package.json + assets are restore-worthy — deps are
|
|
3100
|
-
* reinstalled from npm on demand. node_modules is NEVER archived.
|
|
3101
|
-
*/
|
|
3102
|
-
var EXCLUDED_DIR_NAME = "node_modules";
|
|
3103
|
-
/**
|
|
3104
|
-
* True when a dataDir-relative path must be omitted from archives,
|
|
3105
|
-
* manifests and location stats. Accepts tar-style paths (`./` prefix,
|
|
3106
|
-
* trailing `/`) and backslash separators.
|
|
3107
|
-
*/
|
|
3108
|
-
function isExcludedFromBackup(relPath) {
|
|
3109
|
-
const norm = normalizeArchivePath(relPath);
|
|
3110
|
-
if (norm.length === 0) return false;
|
|
3111
|
-
const segments = norm.split("/");
|
|
3112
|
-
if (segments.includes(EXCLUDED_DIR_NAME)) return true;
|
|
3113
|
-
if (segments.some((seg) => seg.endsWith(".backup-snapshot-partial"))) return true;
|
|
3114
|
-
if (norm.endsWith(".backup-snapshot")) return true;
|
|
3115
|
-
return DEFAULT_BACKUP_EXCLUDES.some((prefix) => norm === prefix || norm.startsWith(`${prefix}/`));
|
|
3116
|
-
}
|
|
3117
|
-
/** `./a/b/` and `a\\b` → `a/b`: the one spelling every archive-path comparison uses. */
|
|
3118
|
-
function normalizeArchivePath(relPath) {
|
|
3119
|
-
return relPath.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
|
|
3120
|
-
}
|
|
3121
|
-
/** The files SQLite keeps beside a database. A live one is never archived. */
|
|
3122
|
-
var SQLITE_SIDECAR_SUFFIXES = [
|
|
3123
|
-
"-wal",
|
|
3124
|
-
"-shm",
|
|
3125
|
-
"-journal"
|
|
3126
|
-
];
|
|
3127
|
-
var SQLITE_DATABASE_SUFFIXES = [
|
|
3128
|
-
".db",
|
|
3129
|
-
".sqlite",
|
|
3130
|
-
".sqlite3"
|
|
3131
|
-
];
|
|
3132
|
-
/**
|
|
3133
|
-
* The database a `-wal` / `-shm` / `-journal` belongs to, or null for any other
|
|
3134
|
-
* path. The base must name a database (`.db` / `.sqlite` / `.sqlite3`): a
|
|
3135
|
-
* `build-journal` is not a sidecar, and must not stop every backup as a "live
|
|
3136
|
-
* database" that does not exist.
|
|
3137
|
-
*/
|
|
3138
|
-
function databaseOfSidecar(relPath) {
|
|
3139
|
-
for (const suffix of SQLITE_SIDECAR_SUFFIXES) {
|
|
3140
|
-
if (!relPath.endsWith(suffix)) continue;
|
|
3141
|
-
const db = relPath.slice(0, -suffix.length);
|
|
3142
|
-
return SQLITE_DATABASE_SUFFIXES.some((dbSuffix) => db.endsWith(dbSuffix)) ? db : null;
|
|
3143
|
-
}
|
|
3144
|
-
return null;
|
|
3145
|
-
}
|
|
3146
|
-
/** A SQLite database file, or a sidecar of one. */
|
|
3147
|
-
function isSqlitePath(relPath) {
|
|
3148
|
-
const db = databaseOfSidecar(relPath) ?? relPath;
|
|
3149
|
-
return SQLITE_DATABASE_SUFFIXES.some((suffix) => db.endsWith(suffix));
|
|
3150
|
-
}
|
|
3151
|
-
/** Path of the manifest file embedded inside every archive. */
|
|
3152
|
-
var ARCHIVE_MANIFEST_NAME = ".camstack-backup-manifest.json";
|
|
3153
|
-
var DEFAULT_STAT_CACHE_TTL_MS = 6e4;
|
|
3154
|
-
/**
|
|
3155
|
-
* System-level archive primitives. Construct one per server boot;
|
|
3156
|
-
* methods are pure I/O.
|
|
3157
|
-
*/
|
|
3158
|
-
var SystemBackupService = class {
|
|
3159
|
-
dataDir;
|
|
3160
|
-
logger;
|
|
3161
|
-
statCacheTtlMs;
|
|
3162
|
-
statCache = /* @__PURE__ */ new Map();
|
|
3163
|
-
constructor(dataDir, logger, opts) {
|
|
3164
|
-
this.dataDir = dataDir;
|
|
3165
|
-
this.logger = logger;
|
|
3166
|
-
this.statCacheTtlMs = opts?.statCacheTtlMs ?? DEFAULT_STAT_CACHE_TTL_MS;
|
|
3167
|
-
}
|
|
3168
|
-
/**
|
|
3169
|
-
* Snapshot the current size + file count of each well-known
|
|
3170
|
-
* location. Used by the admin UI to render an opt-in checklist
|
|
3171
|
-
* before triggering a backup, and by `createArchive` to derive the
|
|
3172
|
-
* embedded manifest.
|
|
3173
|
-
*
|
|
3174
|
-
* The walk is async (yields to the event loop per directory) and
|
|
3175
|
-
* per-location results are cached + single-flighted: the service
|
|
3176
|
-
* runs in-process in the hub, and a synchronous walk of the 70k+
|
|
3177
|
-
* file `addons` location blocked the event loop long enough to kill
|
|
3178
|
-
* WS keepalives cluster-wide.
|
|
3179
|
-
*/
|
|
3180
|
-
statLocations(locations = DEFAULT_BACKUP_LOCATIONS) {
|
|
3181
|
-
return Promise.all(locations.map((loc) => this.statLocationCached(loc)));
|
|
3182
|
-
}
|
|
3183
|
-
statLocationCached(loc) {
|
|
3184
|
-
const now = Date.now();
|
|
3185
|
-
const hit = this.statCache.get(loc);
|
|
3186
|
-
if (hit && now - hit.at < this.statCacheTtlMs) return hit.value;
|
|
3187
|
-
const value = this.statLocation(loc);
|
|
3188
|
-
this.statCache.set(loc, {
|
|
3189
|
-
at: now,
|
|
3190
|
-
value
|
|
3191
|
-
});
|
|
3192
|
-
value.catch(() => this.statCache.delete(loc));
|
|
3193
|
-
return value;
|
|
3194
|
-
}
|
|
3195
|
-
async statLocation(loc) {
|
|
3196
|
-
const abs = node_path.isAbsolute(loc) ? loc : node_path.join(this.dataDir, loc);
|
|
3197
|
-
if (!node_fs.existsSync(abs)) return {
|
|
3198
|
-
name: loc,
|
|
3199
|
-
sizeBytes: 0,
|
|
3200
|
-
fileCount: 0,
|
|
3201
|
-
present: false
|
|
3202
|
-
};
|
|
3203
|
-
const walked = await walkAbs(abs, abs, this.exclusionPredicate());
|
|
3204
|
-
return {
|
|
3205
|
-
name: loc,
|
|
3206
|
-
sizeBytes: walked.reduce((acc, e) => acc + e.sizeBytes, 0),
|
|
3207
|
-
fileCount: walked.filter((e) => e.kind === "file").length,
|
|
3208
|
-
present: true
|
|
3209
|
-
};
|
|
3210
|
-
}
|
|
3211
|
-
/**
|
|
3212
|
-
* Create a tar.gz of the given locations. Uses the `tar` npm package
|
|
3213
|
-
* (used by npm itself) instead of shelling out — gives us:
|
|
3214
|
-
*
|
|
3215
|
-
* - Symlink dereference (`follow: true`) so dev mode's
|
|
3216
|
-
* `addons/<name> → packages/<name>` overlay archives content,
|
|
3217
|
-
* not just link stubs.
|
|
3218
|
-
* - Programmatic walk → we build a manifest of every entry while
|
|
3219
|
-
* copying so the archive can self-describe.
|
|
3220
|
-
*
|
|
3221
|
-
* Locations that don't exist are silently skipped. Throws if zero
|
|
3222
|
-
* locations would be included.
|
|
3223
|
-
*
|
|
3224
|
-
* Cancellation: `signal` aborts the build IN FLIGHT — the manifest
|
|
3225
|
-
* walk checks it per filesystem node and the tar phase runs through
|
|
3226
|
-
* `stream.pipeline(..., { signal })`, which destroys the pack and
|
|
3227
|
-
* the file sink immediately. On abort the half-written archive is
|
|
3228
|
-
* deleted here (never left for the caller to remember) and the call
|
|
3229
|
-
* rejects with {@link BackupCancelledError}. (D342)
|
|
3230
|
-
*
|
|
3231
|
-
* Progress: `onArchiveBytes` receives the cumulative compressed
|
|
3232
|
-
* bytes written to `archivePath` — the live "how large has staging
|
|
3233
|
-
* grown" counter `backup.listRuns` exposes.
|
|
3234
|
-
*/
|
|
3235
|
-
async createArchive(opts) {
|
|
3236
|
-
throwIfCancelled(opts.signal);
|
|
3237
|
-
const requested = opts.locations ?? DEFAULT_BACKUP_LOCATIONS;
|
|
3238
|
-
const present = [];
|
|
3239
|
-
for (const loc of requested) {
|
|
3240
|
-
const abs = node_path.isAbsolute(loc) ? loc : node_path.join(this.dataDir, loc);
|
|
3241
|
-
if (node_fs.existsSync(abs)) present.push(loc);
|
|
3242
|
-
else this.logger.debug("createArchive: skipping missing location", { meta: { location: loc } });
|
|
3243
|
-
}
|
|
3244
|
-
if (present.length === 0) throw new Error(`createArchive: no locations from {${requested.join(", ")}} exist under ${this.dataDir}`);
|
|
3245
|
-
node_fs.mkdirSync(node_path.dirname(opts.archivePath), { recursive: true });
|
|
3246
|
-
const walked = [];
|
|
3247
|
-
for (const loc of present) {
|
|
3248
|
-
throwIfCancelled(opts.signal);
|
|
3249
|
-
const abs = node_path.join(this.dataDir, loc);
|
|
3250
|
-
const stat = await node_fs_promises.stat(abs);
|
|
3251
|
-
if (stat.isDirectory()) for (const e of await walkAbs(abs, this.dataDir, this.exclusionPredicate(), opts.signal)) walked.push(e);
|
|
3252
|
-
else if (!isExcludedFromBackup(node_path.relative(this.dataDir, abs))) walked.push(toArchiveEntry(abs, this.dataDir, stat));
|
|
3253
|
-
}
|
|
3254
|
-
const walkedPaths = new Set(walked.map((e) => e.path));
|
|
3255
|
-
const owned = walked.some((e) => isSqlitePath(e.path)) ? await this.ownedDatabasesInScope(opts.owner, walkedPaths) : /* @__PURE__ */ new Set();
|
|
3256
|
-
const unowned = /* @__PURE__ */ new Set();
|
|
3257
|
-
for (const e of walked) {
|
|
3258
|
-
const db = databaseOfSidecar(e.path);
|
|
3259
|
-
if (db !== null && !owned.has(db)) unowned.add(db);
|
|
3260
|
-
}
|
|
3261
|
-
if (unowned.size > 0) {
|
|
3262
|
-
const databases = [...unowned].sort();
|
|
3263
|
-
this.logger.error("createArchive: a live SQLite database has no owner snapshot — no archive built", { meta: {
|
|
3264
|
-
databases,
|
|
3265
|
-
archivePath: opts.archivePath
|
|
3266
|
-
} });
|
|
3267
|
-
throw new BackupSnapshotRefusedError(`live SQLite database ${databases.join(", ")} has no owner that can snapshot it — a copy of its files would be torn; remove its stale -wal/-shm/-journal if nothing has it open, or leave its location out of the backup`);
|
|
3268
|
-
}
|
|
3269
|
-
const snapshot = owned.size > 0 && opts.owner ? await this.takeOwnerSnapshot(opts.owner, owned, opts.signal) : null;
|
|
3270
|
-
try {
|
|
3271
|
-
const liveFiles = /* @__PURE__ */ new Set();
|
|
3272
|
-
for (const db of owned) {
|
|
3273
|
-
liveFiles.add(db);
|
|
3274
|
-
for (const suffix of SQLITE_SIDECAR_SUFFIXES) liveFiles.add(db + suffix);
|
|
3275
|
-
}
|
|
3276
|
-
const entries = walked.filter((e) => !liveFiles.has(e.path));
|
|
3277
|
-
if (snapshot !== null) entries.push(snapshot.entry);
|
|
3278
|
-
const manifest = {
|
|
3279
|
-
archiveVersion: 1,
|
|
3280
|
-
createdAt: Date.now(),
|
|
3281
|
-
dataDir: this.dataDir,
|
|
3282
|
-
locations: present,
|
|
3283
|
-
entries,
|
|
3284
|
-
totalBytes: entries.reduce((acc, e) => acc + e.sizeBytes, 0),
|
|
3285
|
-
totalFiles: entries.filter((e) => e.kind === "file").length,
|
|
3286
|
-
...snapshot !== null ? { sqliteSnapshots: [snapshot.archived] } : {}
|
|
3287
|
-
};
|
|
3288
|
-
const carriedSnapshot = snapshot?.archived.snapshotPath ?? null;
|
|
3289
|
-
return await this.writeArchive({
|
|
3290
|
-
archivePath: opts.archivePath,
|
|
3291
|
-
present,
|
|
3292
|
-
manifest,
|
|
3293
|
-
excluded: (rel) => {
|
|
3294
|
-
if (rel === carriedSnapshot) return false;
|
|
3295
|
-
return liveFiles.has(rel) || isExcludedFromBackup(rel);
|
|
3296
|
-
},
|
|
3297
|
-
...opts.signal ? { signal: opts.signal } : {},
|
|
3298
|
-
...opts.onArchiveBytes ? { onArchiveBytes: opts.onArchiveBytes } : {}
|
|
3299
|
-
});
|
|
3300
|
-
} finally {
|
|
3301
|
-
if (snapshot !== null) await this.removeSnapshot(snapshot.absPath);
|
|
3302
|
-
}
|
|
3303
|
-
}
|
|
3304
|
-
/**
|
|
3305
|
-
* Tar `present` (filtered by `excluded`) plus the staged manifest into
|
|
3306
|
-
* `archivePath`.
|
|
3307
|
-
*/
|
|
3308
|
-
async writeArchive(opts) {
|
|
3309
|
-
const { present, manifest } = opts;
|
|
3310
|
-
const manifestStagePath = `${opts.archivePath}.${process.pid}.manifest.json`;
|
|
3311
|
-
node_fs.writeFileSync(manifestStagePath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
3312
|
-
this.logger.info("createArchive: tarring", { meta: {
|
|
3313
|
-
archivePath: opts.archivePath,
|
|
3314
|
-
locations: [...present],
|
|
3315
|
-
totalFiles: manifest.totalFiles,
|
|
3316
|
-
totalBytes: manifest.totalBytes
|
|
3317
|
-
} });
|
|
3318
|
-
try {
|
|
3319
|
-
const stagedInDataDir = node_path.join(this.dataDir, ARCHIVE_MANIFEST_NAME);
|
|
3320
|
-
node_fs.copyFileSync(manifestStagePath, stagedInDataDir);
|
|
3321
|
-
const stagingRel = node_path.relative(this.dataDir, node_path.dirname(opts.archivePath));
|
|
3322
|
-
const excludePrefix = stagingRel && !stagingRel.startsWith("..") && !node_path.isAbsolute(stagingRel) ? stagingRel : null;
|
|
3323
|
-
try {
|
|
3324
|
-
const pack = Kn({
|
|
3325
|
-
gzip: true,
|
|
3326
|
-
cwd: this.dataDir,
|
|
3327
|
-
follow: true,
|
|
3328
|
-
portable: true,
|
|
3329
|
-
filter: (entryPath) => {
|
|
3330
|
-
const norm = normalizeArchivePath(entryPath);
|
|
3331
|
-
if (opts.excluded(norm)) return false;
|
|
3332
|
-
if (!excludePrefix) return true;
|
|
3333
|
-
return norm !== excludePrefix && !norm.startsWith(`${excludePrefix}/`);
|
|
3334
|
-
}
|
|
3335
|
-
}, [ARCHIVE_MANIFEST_NAME, ...present]);
|
|
3336
|
-
const sink = node_fs.createWriteStream(opts.archivePath);
|
|
3337
|
-
try {
|
|
3338
|
-
await (0, node_stream_promises.pipeline)(pack, byteCountingPassthrough(opts.onArchiveBytes), sink, opts.signal ? { signal: opts.signal } : {});
|
|
3339
|
-
} catch (err) {
|
|
3340
|
-
try {
|
|
3341
|
-
node_fs.rmSync(opts.archivePath, { force: true });
|
|
3342
|
-
} catch {}
|
|
3343
|
-
if (opts.signal?.aborted) throw new BackupCancelledError();
|
|
3344
|
-
throw err;
|
|
3345
|
-
}
|
|
3346
|
-
} finally {
|
|
3347
|
-
try {
|
|
3348
|
-
node_fs.rmSync(stagedInDataDir, { force: true });
|
|
3349
|
-
} catch {}
|
|
3350
|
-
}
|
|
3351
|
-
} finally {
|
|
3352
|
-
try {
|
|
3353
|
-
node_fs.rmSync(manifestStagePath, { force: true });
|
|
3354
|
-
} catch {}
|
|
3355
|
-
}
|
|
3356
|
-
const sizeBytes = node_fs.statSync(opts.archivePath).size;
|
|
3357
|
-
return {
|
|
3358
|
-
archivePath: opts.archivePath,
|
|
3359
|
-
includedLocations: [...present],
|
|
3360
|
-
sizeBytes,
|
|
3361
|
-
manifest
|
|
3362
|
-
};
|
|
3363
|
-
}
|
|
3364
|
-
/**
|
|
3365
|
-
* without extracting payload files. Streams the tar.gz, parses the
|
|
3366
|
-
* one entry we care about, then aborts.
|
|
3367
|
-
*/
|
|
3368
|
-
async readArchiveManifest(archivePath) {
|
|
3369
|
-
if (!node_fs.existsSync(archivePath)) throw new Error(`readArchiveManifest: ${archivePath} does not exist`);
|
|
3370
|
-
return new Promise((resolve, reject) => {
|
|
3371
|
-
const chunks = [];
|
|
3372
|
-
let found = false;
|
|
3373
|
-
let resolved = false;
|
|
3374
|
-
const parser = new st({ onentry: (entry) => {
|
|
3375
|
-
if (entry.path === ".camstack-backup-manifest.json" && !found) {
|
|
3376
|
-
found = true;
|
|
3377
|
-
entry.on("data", (chunk) => chunks.push(chunk));
|
|
3378
|
-
entry.on("end", () => {
|
|
3379
|
-
try {
|
|
3380
|
-
const json = Buffer.concat(chunks).toString("utf-8");
|
|
3381
|
-
const parsed = JSON.parse(json);
|
|
3382
|
-
resolved = true;
|
|
3383
|
-
resolve(parsed);
|
|
3384
|
-
} catch (err) {
|
|
3385
|
-
resolved = true;
|
|
3386
|
-
reject(err instanceof Error ? err : new Error(String(err)));
|
|
3387
|
-
}
|
|
3388
|
-
});
|
|
3389
|
-
} else entry.resume();
|
|
3390
|
-
} });
|
|
3391
|
-
parser.on("end", () => {
|
|
3392
|
-
if (!resolved) resolve(found ? null : null);
|
|
3393
|
-
});
|
|
3394
|
-
const gunzip = node_zlib.createGunzip();
|
|
3395
|
-
gunzip.on("error", (err) => {
|
|
3396
|
-
if (!resolved) {
|
|
3397
|
-
resolved = true;
|
|
3398
|
-
reject(err);
|
|
3399
|
-
}
|
|
3400
|
-
});
|
|
3401
|
-
const reader = node_fs.createReadStream(archivePath);
|
|
3402
|
-
reader.on("error", (err) => {
|
|
3403
|
-
if (!resolved) {
|
|
3404
|
-
resolved = true;
|
|
3405
|
-
reject(err);
|
|
3406
|
-
}
|
|
3407
|
-
});
|
|
3408
|
-
reader.pipe(gunzip).pipe(parser);
|
|
3409
|
-
});
|
|
3410
|
-
}
|
|
3411
|
-
/**
|
|
3412
|
-
* Schedule a restore for the next boot by writing a marker file.
|
|
3413
|
-
* `locations` (optional) carries through to the launcher's boot-time
|
|
3414
|
-
* restore (`server/backend/src/launcher.ts`, the only restore there is)
|
|
3415
|
-
* so the operator's "restore only X and Y" choice survives the process
|
|
3416
|
-
* restart.
|
|
3417
|
-
*/
|
|
3418
|
-
scheduleRestoreMarker(opts) {
|
|
3419
|
-
if (!node_fs.existsSync(opts.archivePath)) throw new Error(`scheduleRestoreMarker: ${opts.archivePath} missing`);
|
|
3420
|
-
const markerPath = this.getRestoreMarkerPath();
|
|
3421
|
-
const marker = {
|
|
3422
|
-
archivePath: opts.archivePath,
|
|
3423
|
-
requestedAt: Date.now(),
|
|
3424
|
-
source: opts.source,
|
|
3425
|
-
...opts.locations ? { locations: [...opts.locations] } : {}
|
|
3426
|
-
};
|
|
3427
|
-
node_fs.mkdirSync(node_path.dirname(markerPath), { recursive: true });
|
|
3428
|
-
node_fs.writeFileSync(markerPath, JSON.stringify(marker, null, 2), { mode: 384 });
|
|
3429
|
-
return markerPath;
|
|
3430
|
-
}
|
|
3431
|
-
/** Read the pending-restore marker if one is present. */
|
|
3432
|
-
readPendingMarker() {
|
|
3433
|
-
const markerPath = this.getRestoreMarkerPath();
|
|
3434
|
-
if (!node_fs.existsSync(markerPath)) return null;
|
|
3435
|
-
try {
|
|
3436
|
-
const raw = node_fs.readFileSync(markerPath, "utf-8");
|
|
3437
|
-
const parsed = JSON.parse(raw);
|
|
3438
|
-
if (typeof parsed === "object" && parsed != null && typeof parsed.archivePath === "string") return parsed;
|
|
3439
|
-
} catch (err) {
|
|
3440
|
-
this.logger.warn("readPendingMarker: malformed marker — ignoring", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
3441
|
-
}
|
|
3442
|
-
return null;
|
|
3443
|
-
}
|
|
3444
|
-
/** Drop the marker after a successful boot-time restore. */
|
|
3445
|
-
clearPendingMarker() {
|
|
3446
|
-
const markerPath = this.getRestoreMarkerPath();
|
|
3447
|
-
if (node_fs.existsSync(markerPath)) node_fs.rmSync(markerPath, { force: true });
|
|
3448
|
-
}
|
|
3449
|
-
/**
|
|
3450
|
-
* The databases the owner declares, archive-relative, that this walk found.
|
|
3451
|
-
* One outside this data root is not in scope. An owner that cannot answer
|
|
3452
|
-
* stops the archive: without the answer, nothing says which file is live.
|
|
3453
|
-
*/
|
|
3454
|
-
async ownedDatabasesInScope(owner, walked) {
|
|
3455
|
-
if (owner === void 0) return /* @__PURE__ */ new Set();
|
|
3456
|
-
let declared;
|
|
3457
|
-
try {
|
|
3458
|
-
declared = await owner.listDatabases();
|
|
3459
|
-
} catch (err) {
|
|
3460
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
3461
|
-
this.logger.error("createArchive: the database owner did not say what it owns — no archive built", { meta: { error: reason } });
|
|
3462
|
-
throw new BackupSnapshotRefusedError(`the database owner could not be asked: ${reason}`);
|
|
3463
|
-
}
|
|
3464
|
-
const inScope = /* @__PURE__ */ new Set();
|
|
3465
|
-
for (const abs of declared) {
|
|
3466
|
-
const rel = this.archiveRelative(abs);
|
|
3467
|
-
if (rel !== null && walked.has(rel)) inScope.add(rel);
|
|
3468
|
-
}
|
|
3469
|
-
return inScope;
|
|
3470
|
-
}
|
|
3471
|
-
/**
|
|
3472
|
-
* Ask the owner for its snapshot, and place it in this archive. The snapshot
|
|
3473
|
-
* must sit on THIS data root — the call is pinned to this node, so a path
|
|
3474
|
-
* elsewhere means it reached another host, and that file is not ours to
|
|
3475
|
-
* read — beside an owned database in scope, and it must cover EVERY owned
|
|
3476
|
-
* database in scope. Anything else is refused.
|
|
3477
|
-
*
|
|
3478
|
-
* Only ever DELETED here: `<owned db>.backup-snapshot` under this data root,
|
|
3479
|
-
* a name this process derives itself. A path the owner ANSWERS is never
|
|
3480
|
-
* deleted on its word — answering the live database as the snapshot would
|
|
3481
|
-
* otherwise delete the live database. A file at any other path is left to
|
|
3482
|
-
* the owner's own sweep.
|
|
3483
|
-
*
|
|
3484
|
-
* A cancel is honoured while the owner is still copying; the copy it may
|
|
3485
|
-
* finish afterwards is removed when that call settles.
|
|
3486
|
-
*/
|
|
3487
|
-
async takeOwnerSnapshot(owner, owned, signal) {
|
|
3488
|
-
const removeOwnedSnapshots = async () => {
|
|
3489
|
-
for (const db of owned) await this.removeSnapshot(node_path.join(this.dataDir, db + require_dist.DATABASE_SNAPSHOT_SUFFIX));
|
|
3490
|
-
};
|
|
3491
|
-
let result;
|
|
3492
|
-
try {
|
|
3493
|
-
result = await raceAbort(owner.writeSnapshot(), signal, () => {
|
|
3494
|
-
this.logger.info("createArchive: run cancelled while the owner copied — its copy is removed when it lands", { meta: { databases: [...owned] } });
|
|
3495
|
-
return removeOwnedSnapshots();
|
|
3496
|
-
});
|
|
3497
|
-
} catch (err) {
|
|
3498
|
-
if (err instanceof BackupCancelledError) throw err;
|
|
3499
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
3500
|
-
this.logger.error("createArchive: the owner could not snapshot its live database — no archive built", { meta: {
|
|
3501
|
-
databases: [...owned],
|
|
3502
|
-
error: reason
|
|
3503
|
-
} });
|
|
3504
|
-
await removeOwnedSnapshots();
|
|
3505
|
-
throw new BackupSnapshotRefusedError(reason);
|
|
3506
|
-
}
|
|
3507
|
-
try {
|
|
3508
|
-
const livePath = this.archiveRelative(result.livePath);
|
|
3509
|
-
const snapshotPath = this.archiveRelative(result.snapshotPath);
|
|
3510
|
-
if (livePath === null || snapshotPath === null) {
|
|
3511
|
-
this.logger.warn("createArchive: the owner answered a snapshot outside this data root — not touched, left to its sweep", { meta: {
|
|
3512
|
-
snapshot: result.snapshotPath,
|
|
3513
|
-
dataDir: this.dataDir
|
|
3514
|
-
} });
|
|
3515
|
-
throw new BackupSnapshotRefusedError(`snapshot ${result.snapshotPath} is not under this archive's data root ${this.dataDir}`);
|
|
3516
|
-
}
|
|
3517
|
-
if (snapshotPath !== livePath + ".backup-snapshot") throw new BackupSnapshotRefusedError(`snapshot ${snapshotPath} does not sit beside the database ${livePath} it copies`);
|
|
3518
|
-
const uncovered = [...owned].filter((db) => db !== livePath);
|
|
3519
|
-
if (!owned.has(livePath) || uncovered.length > 0) throw new BackupSnapshotRefusedError(`snapshot copies ${livePath}, but the owned database(s) in this archive are ${[...owned].join(", ")}`);
|
|
3520
|
-
const absPath = node_path.join(this.dataDir, snapshotPath);
|
|
3521
|
-
const stat = await node_fs_promises.stat(absPath);
|
|
3522
|
-
this.logger.info("createArchive: carrying the owner snapshot in place of the live database", { meta: {
|
|
3523
|
-
database: livePath,
|
|
3524
|
-
snapshot: snapshotPath,
|
|
3525
|
-
sizeBytes: stat.size,
|
|
3526
|
-
tables: result.tables.length,
|
|
3527
|
-
copyMs: result.copyMs,
|
|
3528
|
-
verifyMs: result.verifyMs
|
|
3529
|
-
} });
|
|
3530
|
-
return {
|
|
3531
|
-
absPath,
|
|
3532
|
-
archived: {
|
|
3533
|
-
...result,
|
|
3534
|
-
livePath,
|
|
3535
|
-
snapshotPath
|
|
3536
|
-
},
|
|
3537
|
-
entry: toArchiveEntry(absPath, this.dataDir, stat)
|
|
3538
|
-
};
|
|
3539
|
-
} catch (err) {
|
|
3540
|
-
await removeOwnedSnapshots();
|
|
3541
|
-
throw err;
|
|
3542
|
-
}
|
|
3543
|
-
}
|
|
3544
|
-
async removeSnapshot(absPath) {
|
|
3545
|
-
try {
|
|
3546
|
-
await node_fs_promises.rm(absPath, { force: true });
|
|
3547
|
-
} catch (err) {
|
|
3548
|
-
this.logger.warn("createArchive: owner snapshot could not be removed", { meta: {
|
|
3549
|
-
snapshot: absPath,
|
|
3550
|
-
error: err instanceof Error ? err.message : String(err)
|
|
3551
|
-
} });
|
|
3552
|
-
}
|
|
3553
|
-
}
|
|
3554
|
-
/** `abs` relative to the data root, or null when it lies outside it. */
|
|
3555
|
-
archiveRelative(abs) {
|
|
3556
|
-
const rel = node_path.relative(node_path.resolve(this.dataDir), node_path.resolve(abs));
|
|
3557
|
-
if (rel.length === 0 || rel.startsWith("..") || node_path.isAbsolute(rel)) return null;
|
|
3558
|
-
return normalizeArchivePath(rel);
|
|
3559
|
-
}
|
|
3560
|
-
getRestoreMarkerPath() {
|
|
3561
|
-
return node_path.join(this.dataDir, ".pending-restore.json");
|
|
3562
|
-
}
|
|
3563
|
-
/**
|
|
3564
|
-
* Absolute-path form of {@link isExcludedFromBackup}, anchored on
|
|
3565
|
-
* this service's dataDir. Shared by the manifest walk and the location
|
|
3566
|
-
* stats so both agree with the tar filter about what a backup contains.
|
|
3567
|
-
*/
|
|
3568
|
-
exclusionPredicate() {
|
|
3569
|
-
return (abs) => isExcludedFromBackup(node_path.relative(this.dataDir, abs));
|
|
3570
|
-
}
|
|
3571
|
-
};
|
|
3572
|
-
/**
|
|
3573
|
-
* Recursively walk a directory and produce one `ArchiveEntry` per
|
|
3574
|
-
* filesystem node. `dataDir` is used to compute the archive-relative
|
|
3575
|
-
* path. Symlinks are dereferenced (matches the `follow: true` flag we
|
|
3576
|
-
* pass to tar.create).
|
|
3577
|
-
*/
|
|
3578
|
-
async function walkAbs(absRoot, dataDir, shouldSkip, signal) {
|
|
3579
|
-
const out = [];
|
|
3580
|
-
await walkRec(absRoot, dataDir, out, shouldSkip, signal);
|
|
3581
|
-
return out;
|
|
3582
|
-
}
|
|
3583
|
-
async function walkRec(abs, dataDir, out, shouldSkip, signal) {
|
|
3584
|
-
throwIfCancelled(signal);
|
|
3585
|
-
if (shouldSkip?.(abs)) return;
|
|
3586
|
-
let stat;
|
|
3587
|
-
try {
|
|
3588
|
-
stat = await node_fs_promises.stat(abs);
|
|
3589
|
-
} catch {
|
|
3590
|
-
return;
|
|
3591
|
-
}
|
|
3592
|
-
out.push(toArchiveEntry(abs, dataDir, stat));
|
|
3593
|
-
if (stat.isDirectory()) {
|
|
3594
|
-
let children;
|
|
3595
|
-
try {
|
|
3596
|
-
children = await node_fs_promises.readdir(abs);
|
|
3597
|
-
} catch {
|
|
3598
|
-
return;
|
|
3599
|
-
}
|
|
3600
|
-
for (const child of children) await walkRec(node_path.join(abs, child), dataDir, out, shouldSkip, signal);
|
|
3601
|
-
}
|
|
3602
|
-
}
|
|
3603
|
-
/**
|
|
3604
|
-
* Pass-through transform that reports the CUMULATIVE bytes flowed so
|
|
3605
|
-
* far. Sits between the tar pack and the file sink so the caller's
|
|
3606
|
-
* progress counter tracks the compressed archive as it grows on disk.
|
|
3607
|
-
*/
|
|
3608
|
-
function byteCountingPassthrough(onBytes) {
|
|
3609
|
-
let total = 0;
|
|
3610
|
-
return new node_stream.Transform({ transform(chunk, _encoding, callback) {
|
|
3611
|
-
if (Buffer.isBuffer(chunk)) total += chunk.byteLength;
|
|
3612
|
-
onBytes?.(total);
|
|
3613
|
-
callback(null, chunk);
|
|
3614
|
-
} });
|
|
3615
|
-
}
|
|
3616
|
-
function toArchiveEntry(abs, dataDir, stat) {
|
|
3617
|
-
const rel = node_path.relative(dataDir, abs).replace(/\\/g, "/");
|
|
3618
|
-
const kind = stat.isDirectory() ? "dir" : stat.isSymbolicLink() ? "symlink" : "file";
|
|
3619
|
-
return {
|
|
3620
|
-
path: rel || node_path.basename(abs),
|
|
3621
|
-
kind,
|
|
3622
|
-
sizeBytes: kind === "file" ? stat.size : 0,
|
|
3623
|
-
mtime: stat.mtimeMs
|
|
3624
|
-
};
|
|
3625
|
-
}
|
|
3626
|
-
//#endregion
|
|
3627
15
|
//#region ../../node_modules/croner/dist/croner.js
|
|
3628
16
|
function T(s) {
|
|
3629
17
|
return Date.UTC(s.y, s.m - 1, s.d, s.h, s.i, s.s);
|
|
@@ -4693,6 +1081,131 @@ async function downloadArchiveToCache(input) {
|
|
|
4693
1081
|
}
|
|
4694
1082
|
}
|
|
4695
1083
|
//#endregion
|
|
1084
|
+
//#region src/builtins/backup-orchestrator/encryption-key-store.ts
|
|
1085
|
+
/**
|
|
1086
|
+
* @durable class=config owner=backup-orchestrator
|
|
1087
|
+
* write="`setupEncryption` inserts one row per generated key and retires the
|
|
1088
|
+
* previous active row; `disableEncryption` retires the active row"
|
|
1089
|
+
* retention="none — one small row per key ever generated; a retired row
|
|
1090
|
+
* names the key older archives need"
|
|
1091
|
+
*/
|
|
1092
|
+
var BACKUP_ENCRYPTION_KEYS_COLLECTION = "backup_encryption_keys";
|
|
1093
|
+
var COLUMNS = [
|
|
1094
|
+
{
|
|
1095
|
+
name: "key_id",
|
|
1096
|
+
type: "TEXT",
|
|
1097
|
+
primaryKey: true
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
name: "public_key",
|
|
1101
|
+
type: "TEXT",
|
|
1102
|
+
notNull: true
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
name: "created_at",
|
|
1106
|
+
type: "INTEGER",
|
|
1107
|
+
notNull: true
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
name: "retired_at",
|
|
1111
|
+
type: "INTEGER"
|
|
1112
|
+
}
|
|
1113
|
+
];
|
|
1114
|
+
var BackupEncryptionKeyStore = class {
|
|
1115
|
+
store;
|
|
1116
|
+
now;
|
|
1117
|
+
declared = false;
|
|
1118
|
+
constructor(store, now = Date.now) {
|
|
1119
|
+
this.store = store;
|
|
1120
|
+
this.now = now;
|
|
1121
|
+
}
|
|
1122
|
+
async ensureDeclared() {
|
|
1123
|
+
if (this.declared) return;
|
|
1124
|
+
await this.store.declareCollection({
|
|
1125
|
+
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
1126
|
+
columns: COLUMNS
|
|
1127
|
+
});
|
|
1128
|
+
this.declared = true;
|
|
1129
|
+
}
|
|
1130
|
+
/** Every key, newest first. */
|
|
1131
|
+
async list() {
|
|
1132
|
+
await this.ensureDeclared();
|
|
1133
|
+
const rows = await this.store.query({
|
|
1134
|
+
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
1135
|
+
filter: { orderBy: {
|
|
1136
|
+
field: "created_at",
|
|
1137
|
+
direction: "desc"
|
|
1138
|
+
} }
|
|
1139
|
+
});
|
|
1140
|
+
const out = [];
|
|
1141
|
+
for (const row of rows) {
|
|
1142
|
+
const record = toRecord(row.data);
|
|
1143
|
+
if (record !== null) out.push(record);
|
|
1144
|
+
}
|
|
1145
|
+
return out;
|
|
1146
|
+
}
|
|
1147
|
+
/** The key new archives are encrypted to; `null` = encryption off. */
|
|
1148
|
+
async active() {
|
|
1149
|
+
return (await this.list()).find((k) => k.retiredAt === null) ?? null;
|
|
1150
|
+
}
|
|
1151
|
+
/** Make `publicKey` the active key; the previous one is retired, kept listed. */
|
|
1152
|
+
async activate(input) {
|
|
1153
|
+
const parsed = require_restore_archive.parseBackupPublicKey(input.publicKey);
|
|
1154
|
+
const t = this.now();
|
|
1155
|
+
await this.retireActive(t);
|
|
1156
|
+
const record = {
|
|
1157
|
+
keyId: parsed.keyId,
|
|
1158
|
+
publicKey: input.publicKey.trim(),
|
|
1159
|
+
createdAt: t,
|
|
1160
|
+
retiredAt: null
|
|
1161
|
+
};
|
|
1162
|
+
await this.write(record);
|
|
1163
|
+
return record;
|
|
1164
|
+
}
|
|
1165
|
+
/** Encryption off: the active key is retired. Archives already made keep needing it. */
|
|
1166
|
+
async disable() {
|
|
1167
|
+
await this.retireActive(this.now());
|
|
1168
|
+
}
|
|
1169
|
+
async retireActive(at) {
|
|
1170
|
+
for (const key of await this.list()) if (key.retiredAt === null) await this.write({
|
|
1171
|
+
...key,
|
|
1172
|
+
retiredAt: at
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
async write(record) {
|
|
1176
|
+
await this.ensureDeclared();
|
|
1177
|
+
await this.store.deleteWhere({
|
|
1178
|
+
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
1179
|
+
filter: { where: { key_id: record.keyId } }
|
|
1180
|
+
});
|
|
1181
|
+
await this.store.insert({
|
|
1182
|
+
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
1183
|
+
record: {
|
|
1184
|
+
id: record.keyId,
|
|
1185
|
+
data: {
|
|
1186
|
+
key_id: record.keyId,
|
|
1187
|
+
public_key: record.publicKey,
|
|
1188
|
+
created_at: record.createdAt,
|
|
1189
|
+
retired_at: record.retiredAt
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
function toRecord(row) {
|
|
1196
|
+
const keyId = row["key_id"];
|
|
1197
|
+
const publicKey = row["public_key"];
|
|
1198
|
+
const createdAt = row["created_at"];
|
|
1199
|
+
if (typeof keyId !== "string" || typeof publicKey !== "string") return null;
|
|
1200
|
+
const retired = row["retired_at"];
|
|
1201
|
+
return {
|
|
1202
|
+
keyId,
|
|
1203
|
+
publicKey,
|
|
1204
|
+
createdAt: typeof createdAt === "number" ? createdAt : Number(createdAt ?? 0),
|
|
1205
|
+
retiredAt: typeof retired === "number" ? retired : null
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
//#endregion
|
|
4696
1209
|
//#region src/builtins/backup-orchestrator/manifest-store.ts
|
|
4697
1210
|
/** File path (relative to the location root) where the index lives. */
|
|
4698
1211
|
var MANIFESTS_FILENAME = "manifests.json";
|
|
@@ -4763,7 +1276,8 @@ function normalizeManifest(raw) {
|
|
|
4763
1276
|
createdAt: Number(cand["createdAt"]),
|
|
4764
1277
|
sizeBytes: Number(cand["sizeBytes"]),
|
|
4765
1278
|
...typeof cand["label"] === "string" ? { label: cand["label"] } : {},
|
|
4766
|
-
manifest
|
|
1279
|
+
manifest,
|
|
1280
|
+
...encryptionOf(cand["encryption"])
|
|
4767
1281
|
};
|
|
4768
1282
|
archives.push(entry);
|
|
4769
1283
|
}
|
|
@@ -4776,6 +1290,32 @@ var EMPTY_MANIFEST = {
|
|
|
4776
1290
|
version: 1,
|
|
4777
1291
|
archives: []
|
|
4778
1292
|
};
|
|
1293
|
+
function encryptionOf(raw) {
|
|
1294
|
+
if (typeof raw !== "object" || raw === null) return {};
|
|
1295
|
+
const scheme = Reflect.get(raw, "scheme");
|
|
1296
|
+
const keyId = Reflect.get(raw, "keyId");
|
|
1297
|
+
if (typeof scheme !== "string" || typeof keyId !== "string") return {};
|
|
1298
|
+
return { encryption: {
|
|
1299
|
+
scheme,
|
|
1300
|
+
keyId
|
|
1301
|
+
} };
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* What the destination's clear-text index may say about an encrypted archive:
|
|
1305
|
+
* the outline a restore needs (locations, sizes, the snapshot promise) — not
|
|
1306
|
+
* the list of files, which stays inside the ciphertext.
|
|
1307
|
+
*/
|
|
1308
|
+
function outlineOfManifest(manifest) {
|
|
1309
|
+
return {
|
|
1310
|
+
archiveVersion: manifest.archiveVersion,
|
|
1311
|
+
createdAt: manifest.createdAt,
|
|
1312
|
+
dataDir: manifest.dataDir,
|
|
1313
|
+
locations: [...manifest.locations],
|
|
1314
|
+
entries: [],
|
|
1315
|
+
totalBytes: manifest.totalBytes,
|
|
1316
|
+
totalFiles: manifest.totalFiles
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
4779
1319
|
/**
|
|
4780
1320
|
* Build a `ManifestArchiveEntry` from the raw inputs collected during
|
|
4781
1321
|
* a successful upload. Pure transform — no I/O — kept here so the
|
|
@@ -4788,7 +1328,8 @@ function buildArchiveEntry(input) {
|
|
|
4788
1328
|
createdAt: input.createdAt,
|
|
4789
1329
|
sizeBytes: input.sizeBytes,
|
|
4790
1330
|
...input.label !== void 0 ? { label: input.label } : {},
|
|
4791
|
-
manifest: input.manifest
|
|
1331
|
+
manifest: input.encryption !== void 0 ? outlineOfManifest(input.manifest) : input.manifest,
|
|
1332
|
+
...input.encryption !== void 0 ? { encryption: input.encryption } : {}
|
|
4792
1333
|
};
|
|
4793
1334
|
}
|
|
4794
1335
|
/**
|
|
@@ -4929,7 +1470,7 @@ var BackupRunQueue = class {
|
|
|
4929
1470
|
const idx = this.pending.indexOf(runId);
|
|
4930
1471
|
if (idx >= 0) this.pending.splice(idx, 1);
|
|
4931
1472
|
this.finish(record, "cancelled");
|
|
4932
|
-
record.rejectResult(new BackupCancelledError(`backup run ${runId} cancelled while queued`));
|
|
1473
|
+
record.rejectResult(new require_restore_archive.BackupCancelledError(`backup run ${runId} cancelled while queued`));
|
|
4933
1474
|
return true;
|
|
4934
1475
|
}
|
|
4935
1476
|
if (record.snapshot.state === "running") {
|
|
@@ -5037,9 +1578,9 @@ var BackupRunQueue = class {
|
|
|
5037
1578
|
}
|
|
5038
1579
|
record.resolveResult(value);
|
|
5039
1580
|
} catch (err) {
|
|
5040
|
-
if (err instanceof BackupCancelledError || record.controller.signal.aborted) {
|
|
1581
|
+
if (err instanceof require_restore_archive.BackupCancelledError || record.controller.signal.aborted) {
|
|
5041
1582
|
this.finish(record, "cancelled");
|
|
5042
|
-
record.rejectResult(err instanceof BackupCancelledError ? err : new BackupCancelledError());
|
|
1583
|
+
record.rejectResult(err instanceof require_restore_archive.BackupCancelledError ? err : new require_restore_archive.BackupCancelledError());
|
|
5043
1584
|
} else {
|
|
5044
1585
|
this.finish(record, "failed", err instanceof Error ? err.message : String(err));
|
|
5045
1586
|
record.rejectResult(err);
|
|
@@ -5481,6 +2022,9 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5481
2022
|
systemBackup = null;
|
|
5482
2023
|
policies = null;
|
|
5483
2024
|
schedules = null;
|
|
2025
|
+
/** Backup encryption keys — PUBLIC keys only (see encryption-key-store.ts). */
|
|
2026
|
+
encryptionKeys = null;
|
|
2027
|
+
warnedNoEncryptionStore = false;
|
|
5484
2028
|
dataDir = "";
|
|
5485
2029
|
/**
|
|
5486
2030
|
* Transient build buffer for archive fan-out. The tar is built here
|
|
@@ -5519,7 +2063,7 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5519
2063
|
async onInitialize() {
|
|
5520
2064
|
this.dataDir = this.ctx.nodeDataDir;
|
|
5521
2065
|
this.stagingDir = resolveStagingDir(this.ctx.nodeDataDir);
|
|
5522
|
-
this.systemBackup = new SystemBackupService(this.dataDir, this.ctx.logger);
|
|
2066
|
+
this.systemBackup = new require_restore_archive.SystemBackupService(this.dataDir, this.ctx.logger);
|
|
5523
2067
|
this.runQueue = new BackupRunQueue((request, signal, progress) => this.runBackupBuild(request, signal, progress));
|
|
5524
2068
|
await this.cleanStagingArea();
|
|
5525
2069
|
this.policies = this.resolvePolicyService();
|
|
@@ -5536,6 +2080,8 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5536
2080
|
this.ctx.logger.error("backup-orchestrator: schedule table init failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
5537
2081
|
this.schedules = null;
|
|
5538
2082
|
}
|
|
2083
|
+
const settingsStore = this.ctx.kernel.capabilityRegistry?.getSingleton("settings-store");
|
|
2084
|
+
this.encryptionKeys = settingsStore ? new BackupEncryptionKeyStore(settingsStore) : null;
|
|
5539
2085
|
const provider = {
|
|
5540
2086
|
listDestinations: () => this.listDestinations(),
|
|
5541
2087
|
list: () => this.aggregatedList(),
|
|
@@ -5545,6 +2091,10 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5545
2091
|
cancel: (input) => this.cancelRun(input),
|
|
5546
2092
|
getEntries: (input) => this.getEntries(input),
|
|
5547
2093
|
restore: (input) => this.scheduleRestore(input),
|
|
2094
|
+
getEncryption: () => this.getEncryption(),
|
|
2095
|
+
setupEncryption: () => this.setupEncryption(),
|
|
2096
|
+
disableEncryption: () => this.disableEncryption(),
|
|
2097
|
+
checkBackupKey: (input) => this.checkBackupKey(input),
|
|
5548
2098
|
delete: (input) => this.deleteArchive(input),
|
|
5549
2099
|
listArchives: (input) => this.listArchives(input),
|
|
5550
2100
|
upsertDestinationPolicy: (input) => this.upsertDestinationPolicy(input),
|
|
@@ -5768,7 +2318,8 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5768
2318
|
createdAt: a.createdAt,
|
|
5769
2319
|
sizeBytes: a.sizeBytes,
|
|
5770
2320
|
...a.label !== void 0 ? { label: a.label } : {},
|
|
5771
|
-
locations: [...a.manifest.locations]
|
|
2321
|
+
locations: [...a.manifest.locations],
|
|
2322
|
+
...a.encryption !== void 0 ? { encryption: a.encryption } : {}
|
|
5772
2323
|
};
|
|
5773
2324
|
out.push(entry);
|
|
5774
2325
|
}
|
|
@@ -5842,7 +2393,7 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5842
2393
|
try {
|
|
5843
2394
|
entries = await submitted.result;
|
|
5844
2395
|
} catch (err) {
|
|
5845
|
-
if (!(err instanceof BackupCancelledError)) throw err;
|
|
2396
|
+
if (!(err instanceof require_restore_archive.BackupCancelledError)) throw err;
|
|
5846
2397
|
entries = [];
|
|
5847
2398
|
}
|
|
5848
2399
|
const finalState = this.runQueue?.getRun(submitted.runId)?.state;
|
|
@@ -5896,8 +2447,9 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5896
2447
|
}
|
|
5897
2448
|
progress.setDestinations(targets.map((t) => t.id));
|
|
5898
2449
|
const policies = await this.loadPoliciesIndexed(targets.map((t) => t.id));
|
|
2450
|
+
const encryptTo = await this.activeEncryptionKey();
|
|
5899
2451
|
const archiveId = (0, node_crypto.randomUUID)();
|
|
5900
|
-
const archiveFilename = `${archiveId}.tar.gz`;
|
|
2452
|
+
const archiveFilename = encryptTo === null ? `${archiveId}.tar.gz` : `${archiveId}.tar.gz${require_restore_archive.ENCRYPTED_BACKUP_SUFFIX}`;
|
|
5901
2453
|
const cachePath = await this.stagingPath(archiveFilename);
|
|
5902
2454
|
let result;
|
|
5903
2455
|
try {
|
|
@@ -5906,10 +2458,11 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5906
2458
|
...input.locations ? { locations: [...input.locations] } : {},
|
|
5907
2459
|
signal,
|
|
5908
2460
|
onArchiveBytes: (bytes) => progress.setStagedBytes(bytes),
|
|
5909
|
-
owner: this.databaseOwner()
|
|
2461
|
+
owner: this.databaseOwner(),
|
|
2462
|
+
...encryptTo !== null ? { encryptTo: encryptTo.publicKey } : {}
|
|
5910
2463
|
});
|
|
5911
2464
|
} catch (err) {
|
|
5912
|
-
if (err instanceof BackupSnapshotRefusedError) for (const dest of targets) {
|
|
2465
|
+
if (err instanceof require_restore_archive.BackupSnapshotRefusedError) for (const dest of targets) {
|
|
5913
2466
|
progress.destinationFailed(dest.id);
|
|
5914
2467
|
await this.recordDestinationOutcome(dest.id, Date.now(), err.message);
|
|
5915
2468
|
}
|
|
@@ -5940,6 +2493,7 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5940
2493
|
retentionCount: input.retentionCount ?? policy.retentionCount,
|
|
5941
2494
|
createdAt,
|
|
5942
2495
|
label: formatArchiveLabel(dest.id, createdAt, input.label),
|
|
2496
|
+
...result.encryption !== void 0 ? { encryption: result.encryption } : {},
|
|
5943
2497
|
signal,
|
|
5944
2498
|
onUploadedBytes: (bytes) => progress.setUploadedBytes(bytes)
|
|
5945
2499
|
});
|
|
@@ -5961,7 +2515,7 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5961
2515
|
}
|
|
5962
2516
|
});
|
|
5963
2517
|
} catch (err) {
|
|
5964
|
-
if (err instanceof BackupCancelledError) continue;
|
|
2518
|
+
if (err instanceof require_restore_archive.BackupCancelledError) continue;
|
|
5965
2519
|
progress.destinationFailed(dest.id);
|
|
5966
2520
|
const message = err instanceof Error ? err.message : String(err);
|
|
5967
2521
|
this.ctx.logger.error("backup trigger: destination failed", { meta: {
|
|
@@ -6035,7 +2589,7 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
6035
2589
|
for await (const rawChunk of stream) {
|
|
6036
2590
|
if (input.signal?.aborted) {
|
|
6037
2591
|
stream.destroy();
|
|
6038
|
-
throw new BackupCancelledError(`backup upload to ${input.locationId} cancelled mid-stream`);
|
|
2592
|
+
throw new require_restore_archive.BackupCancelledError(`backup upload to ${input.locationId} cancelled mid-stream`);
|
|
6039
2593
|
}
|
|
6040
2594
|
const chunk = toBufferChunk(rawChunk);
|
|
6041
2595
|
const data = new Uint8Array(chunk.byteLength);
|
|
@@ -6061,7 +2615,8 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
6061
2615
|
createdAt: input.createdAt,
|
|
6062
2616
|
sizeBytes: input.sizeBytes,
|
|
6063
2617
|
label: input.label,
|
|
6064
|
-
manifest: input.archiveManifest
|
|
2618
|
+
manifest: input.archiveManifest,
|
|
2619
|
+
...input.encryption !== void 0 ? { encryption: input.encryption } : {}
|
|
6065
2620
|
});
|
|
6066
2621
|
await this.manifestLock.run(input.locationId, async () => {
|
|
6067
2622
|
const { keep, drop } = applyRetention([...(await readLocationManifest(this.storageApi(), input.locationId)).archives, entry], input.retentionCount);
|
|
@@ -6090,7 +2645,8 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
6090
2645
|
createdAt: input.createdAt,
|
|
6091
2646
|
sizeBytes: input.sizeBytes,
|
|
6092
2647
|
label: input.label,
|
|
6093
|
-
locations: [...input.archiveManifest.locations]
|
|
2648
|
+
locations: [...input.archiveManifest.locations],
|
|
2649
|
+
...input.encryption !== void 0 ? { encryption: input.encryption } : {}
|
|
6094
2650
|
};
|
|
6095
2651
|
}
|
|
6096
2652
|
/**
|
|
@@ -6116,7 +2672,8 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
6116
2672
|
createdAt: a.createdAt,
|
|
6117
2673
|
sizeBytes: a.sizeBytes,
|
|
6118
2674
|
...a.label !== void 0 ? { label: a.label } : {},
|
|
6119
|
-
locations: [...a.manifest.locations]
|
|
2675
|
+
locations: [...a.manifest.locations],
|
|
2676
|
+
...a.encryption !== void 0 ? { encryption: a.encryption } : {}
|
|
6120
2677
|
}));
|
|
6121
2678
|
}
|
|
6122
2679
|
/**
|
|
@@ -6224,15 +2781,26 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
6224
2781
|
if (!this.systemBackup) throw new Error("orchestrator not initialized");
|
|
6225
2782
|
const entry = (await readLocationManifest(this.storageApi(), input.destinationId)).archives.find((a) => a.id === input.backupId);
|
|
6226
2783
|
if (!entry) throw new Error(`backup restore: backup "${input.backupId}" not found at location "${input.destinationId}"`);
|
|
2784
|
+
require_restore_archive.precheckRestoreKey(entry.encryption?.keyId, input.backupSecretKey);
|
|
2785
|
+
const downloaded = await this.stagingPath(`restore-${input.backupId}.download`);
|
|
6227
2786
|
const cachePath = await this.stagingPath(`restore-${input.backupId}.tar.gz`);
|
|
6228
2787
|
await downloadArchiveToCache({
|
|
6229
2788
|
api: this.ctx.api.storage,
|
|
6230
2789
|
locationId: input.destinationId,
|
|
6231
2790
|
filename: entry.filename,
|
|
6232
|
-
cachePath,
|
|
2791
|
+
cachePath: downloaded,
|
|
6233
2792
|
chunkBytes: UPLOAD_CHUNK_BYTES,
|
|
6234
2793
|
logger: this.ctx.logger
|
|
6235
2794
|
});
|
|
2795
|
+
const prepared = await require_restore_archive.prepareRestoreArchive({
|
|
2796
|
+
downloaded,
|
|
2797
|
+
target: cachePath,
|
|
2798
|
+
...input.backupSecretKey !== void 0 ? { secretKey: input.backupSecretKey } : {}
|
|
2799
|
+
});
|
|
2800
|
+
if (prepared.encrypted) this.ctx.logger.info("backup restore: encrypted archive decrypted into staging", { meta: {
|
|
2801
|
+
backupId: input.backupId,
|
|
2802
|
+
keyId: prepared.keyId
|
|
2803
|
+
} });
|
|
6236
2804
|
this.systemBackup.scheduleRestoreMarker({
|
|
6237
2805
|
archivePath: cachePath,
|
|
6238
2806
|
source: input.backupId,
|
|
@@ -6252,6 +2820,98 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
6252
2820
|
}
|
|
6253
2821
|
});
|
|
6254
2822
|
}
|
|
2823
|
+
requireEncryptionKeys() {
|
|
2824
|
+
if (this.encryptionKeys === null) throw new Error("backup encryption: no settings-store — the setting cannot be read or saved");
|
|
2825
|
+
return this.encryptionKeys;
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* The key a run encrypts to; `null` = encryption off. THROWS when the
|
|
2829
|
+
* setting cannot be read — a run must fail rather than ship a plain archive
|
|
2830
|
+
* an operator asked to be encrypted.
|
|
2831
|
+
*/
|
|
2832
|
+
async activeEncryptionKey() {
|
|
2833
|
+
const store = this.encryptionKeys;
|
|
2834
|
+
if (store === null) {
|
|
2835
|
+
if (!this.warnedNoEncryptionStore) {
|
|
2836
|
+
this.warnedNoEncryptionStore = true;
|
|
2837
|
+
this.ctx.logger.warn("backup encryption unavailable on this node (no settings-store) — archives are plain");
|
|
2838
|
+
}
|
|
2839
|
+
return null;
|
|
2840
|
+
}
|
|
2841
|
+
try {
|
|
2842
|
+
const active = await store.active();
|
|
2843
|
+
return active === null ? null : {
|
|
2844
|
+
keyId: active.keyId,
|
|
2845
|
+
publicKey: active.publicKey
|
|
2846
|
+
};
|
|
2847
|
+
} catch (err) {
|
|
2848
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2849
|
+
throw new Error(`backup encryption setting unreadable — no archive built, so none leaves unencrypted: ${message}`, { cause: err });
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
async getEncryption() {
|
|
2853
|
+
const keys = await this.requireEncryptionKeys().list();
|
|
2854
|
+
const active = keys.find((k) => k.retiredAt === null) ?? null;
|
|
2855
|
+
return {
|
|
2856
|
+
enabled: active !== null,
|
|
2857
|
+
active: active === null ? null : {
|
|
2858
|
+
keyId: active.keyId,
|
|
2859
|
+
publicKey: active.publicKey,
|
|
2860
|
+
createdAt: active.createdAt
|
|
2861
|
+
},
|
|
2862
|
+
keys: keys.map((k) => ({
|
|
2863
|
+
keyId: k.keyId,
|
|
2864
|
+
createdAt: k.createdAt,
|
|
2865
|
+
retiredAt: k.retiredAt
|
|
2866
|
+
}))
|
|
2867
|
+
};
|
|
2868
|
+
}
|
|
2869
|
+
async setupEncryption() {
|
|
2870
|
+
const store = this.requireEncryptionKeys();
|
|
2871
|
+
const previous = await store.active();
|
|
2872
|
+
const pair = require_restore_archive.generateBackupKeyPair();
|
|
2873
|
+
const record = await store.activate({ publicKey: pair.publicKey });
|
|
2874
|
+
this.ctx.logger.warn("backup encryption key generated — new archives are encrypted to it", { meta: {
|
|
2875
|
+
keyId: record.keyId,
|
|
2876
|
+
replacedKeyId: previous?.keyId ?? null
|
|
2877
|
+
} });
|
|
2878
|
+
return {
|
|
2879
|
+
keyId: record.keyId,
|
|
2880
|
+
secretKey: pair.secretKey,
|
|
2881
|
+
publicKey: record.publicKey,
|
|
2882
|
+
createdAt: record.createdAt,
|
|
2883
|
+
replacedKeyId: previous?.keyId ?? null
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2886
|
+
async disableEncryption() {
|
|
2887
|
+
const store = this.requireEncryptionKeys();
|
|
2888
|
+
const previous = await store.active();
|
|
2889
|
+
await store.disable();
|
|
2890
|
+
if (previous !== null) this.ctx.logger.warn("backup encryption turned OFF — new archives are plain", { meta: { disabledKeyId: previous.keyId } });
|
|
2891
|
+
return { disabledKeyId: previous?.keyId ?? null };
|
|
2892
|
+
}
|
|
2893
|
+
async checkBackupKey(input) {
|
|
2894
|
+
let keyId;
|
|
2895
|
+
try {
|
|
2896
|
+
keyId = require_restore_archive.parseBackupSecretKey(input.backupSecretKey).keyId;
|
|
2897
|
+
} catch (err) {
|
|
2898
|
+
if (!(err instanceof require_restore_archive.BackupKeyFormatError)) throw err;
|
|
2899
|
+
return {
|
|
2900
|
+
valid: false,
|
|
2901
|
+
keyId: null,
|
|
2902
|
+
known: false,
|
|
2903
|
+
active: false,
|
|
2904
|
+
error: err.message
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
const match = (await this.requireEncryptionKeys().list()).find((k) => k.keyId === keyId);
|
|
2908
|
+
return {
|
|
2909
|
+
valid: true,
|
|
2910
|
+
keyId,
|
|
2911
|
+
known: match !== void 0,
|
|
2912
|
+
active: match !== void 0 && match.retiredAt === null
|
|
2913
|
+
};
|
|
2914
|
+
}
|
|
6255
2915
|
/**
|
|
6256
2916
|
* Resolve a target destination set — see {@link selectBackupTargets} for the
|
|
6257
2917
|
* rule. Caller-provided list wins over the per-destination policy flag;
|