@rstreamlabs/tunnels 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.d.mts +89 -79
- package/dist/index.d.ts +89 -79
- package/dist/index.js +30 -9
- package/dist/index.mjs +30 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1876,34 +1876,50 @@ var Watch = class {
|
|
|
1876
1876
|
|
|
1877
1877
|
// src/webtty.ts
|
|
1878
1878
|
var z7 = __toESM(require("zod"));
|
|
1879
|
-
var
|
|
1879
|
+
var osFamilySchema = z7.enum([
|
|
1880
1880
|
"linux",
|
|
1881
1881
|
"macos",
|
|
1882
1882
|
"windows",
|
|
1883
1883
|
"netbsd",
|
|
1884
1884
|
"openbsd",
|
|
1885
1885
|
"freebsd"
|
|
1886
|
-
];
|
|
1886
|
+
]);
|
|
1887
|
+
var webttyCapabilitySchema = z7.enum(["exec", "fs"]);
|
|
1888
|
+
var webttyFSModeSchema = z7.enum(["read-write", "read-only"]);
|
|
1887
1889
|
var webttyServerSchema = z7.object({
|
|
1888
1890
|
tunnel_id: z7.string(),
|
|
1889
1891
|
host: z7.string(),
|
|
1890
1892
|
token_auth: z7.boolean(),
|
|
1891
|
-
|
|
1893
|
+
capabilities: z7.array(webttyCapabilitySchema).optional(),
|
|
1894
|
+
exec_path: z7.string().optional(),
|
|
1895
|
+
fs_path: z7.string().optional(),
|
|
1896
|
+
fs_mode: webttyFSModeSchema.optional(),
|
|
1897
|
+
os_family: osFamilySchema.optional(),
|
|
1892
1898
|
arch: z7.string().optional(),
|
|
1893
1899
|
os_id: z7.string().optional(),
|
|
1894
|
-
// /etc/os-release::ID (ubuntu, debian, rocky, etc.)
|
|
1895
1900
|
os_version_id: z7.string().optional(),
|
|
1896
|
-
// /etc/os-release::VERSION_ID (24.04, 22.04, 11, 10.0.19045, ...)
|
|
1897
1901
|
os_version_codename: z7.string().optional(),
|
|
1898
|
-
// /etc/os-release::VERSION_CODENAME (jammy, noble...)
|
|
1899
1902
|
os_pretty_name: z7.string().optional(),
|
|
1900
|
-
// /etc/os-release::PRETTY_NAME
|
|
1901
1903
|
kernel_release: z7.string().optional(),
|
|
1902
|
-
// uname -r
|
|
1903
1904
|
hostname: z7.string().optional(),
|
|
1904
|
-
// uname -n
|
|
1905
1905
|
labels: z7.record(z7.string(), z7.string().optional()).optional()
|
|
1906
1906
|
});
|
|
1907
|
+
function isWebTTYCapability(value) {
|
|
1908
|
+
return webttyCapabilitySchema.safeParse(value).success;
|
|
1909
|
+
}
|
|
1910
|
+
function parseWebTTYCapabilities(value) {
|
|
1911
|
+
const values = (value ?? "").split(",").map((capability) => capability.trim()).filter(isWebTTYCapability);
|
|
1912
|
+
return webttyCapabilitySchema.options.filter(
|
|
1913
|
+
(capability) => values.includes(capability)
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1916
|
+
function webTTYCapabilitiesForLabels(labels) {
|
|
1917
|
+
const parsed = parseWebTTYCapabilities(labels["rstream.webtty.capabilities"]);
|
|
1918
|
+
return parsed.length > 0 ? parsed : ["exec"];
|
|
1919
|
+
}
|
|
1920
|
+
function webTTYHasCapability(capabilities, capability) {
|
|
1921
|
+
return capabilities.includes(capability);
|
|
1922
|
+
}
|
|
1907
1923
|
function parser(tunnel) {
|
|
1908
1924
|
if (tunnel.status !== "online") return null;
|
|
1909
1925
|
if (tunnel.publish !== true) return null;
|
|
@@ -1912,6 +1928,7 @@ function parser(tunnel) {
|
|
|
1912
1928
|
if (tunnelLabels["application-protocol"] !== "rstream.webtty") {
|
|
1913
1929
|
return null;
|
|
1914
1930
|
}
|
|
1931
|
+
const capabilities = webTTYCapabilitiesForLabels(tunnelLabels);
|
|
1915
1932
|
const labels = {};
|
|
1916
1933
|
for (const [key, value] of Object.entries(tunnelLabels)) {
|
|
1917
1934
|
if (!key.startsWith("rstream.webtty.label.")) continue;
|
|
@@ -1923,6 +1940,10 @@ function parser(tunnel) {
|
|
|
1923
1940
|
tunnel_id: tunnel.id,
|
|
1924
1941
|
host: formatTunnelHost(tunnel),
|
|
1925
1942
|
token_auth: tunnel.token_auth === true,
|
|
1943
|
+
capabilities,
|
|
1944
|
+
exec_path: webTTYHasCapability(capabilities, "exec") ? tunnelLabels["rstream.webtty.exec.path"] ?? "/" : void 0,
|
|
1945
|
+
fs_path: webTTYHasCapability(capabilities, "fs") ? tunnelLabels["rstream.webtty.fs.path"] ?? "/fs" : void 0,
|
|
1946
|
+
fs_mode: webTTYHasCapability(capabilities, "fs") ? tunnelLabels["rstream.webtty.fs.mode"] ?? "read-write" : void 0,
|
|
1926
1947
|
os_family: tunnelLabels["rstream.webtty.os_family"],
|
|
1927
1948
|
arch: tunnelLabels["rstream.webtty.arch"],
|
|
1928
1949
|
os_id: tunnelLabels["rstream.webtty.os_id"],
|
package/dist/index.mjs
CHANGED
|
@@ -1137,34 +1137,50 @@ var Watch = class {
|
|
|
1137
1137
|
|
|
1138
1138
|
// src/webtty.ts
|
|
1139
1139
|
import * as z2 from "zod";
|
|
1140
|
-
var
|
|
1140
|
+
var osFamilySchema = z2.enum([
|
|
1141
1141
|
"linux",
|
|
1142
1142
|
"macos",
|
|
1143
1143
|
"windows",
|
|
1144
1144
|
"netbsd",
|
|
1145
1145
|
"openbsd",
|
|
1146
1146
|
"freebsd"
|
|
1147
|
-
];
|
|
1147
|
+
]);
|
|
1148
|
+
var webttyCapabilitySchema = z2.enum(["exec", "fs"]);
|
|
1149
|
+
var webttyFSModeSchema = z2.enum(["read-write", "read-only"]);
|
|
1148
1150
|
var webttyServerSchema = z2.object({
|
|
1149
1151
|
tunnel_id: z2.string(),
|
|
1150
1152
|
host: z2.string(),
|
|
1151
1153
|
token_auth: z2.boolean(),
|
|
1152
|
-
|
|
1154
|
+
capabilities: z2.array(webttyCapabilitySchema).optional(),
|
|
1155
|
+
exec_path: z2.string().optional(),
|
|
1156
|
+
fs_path: z2.string().optional(),
|
|
1157
|
+
fs_mode: webttyFSModeSchema.optional(),
|
|
1158
|
+
os_family: osFamilySchema.optional(),
|
|
1153
1159
|
arch: z2.string().optional(),
|
|
1154
1160
|
os_id: z2.string().optional(),
|
|
1155
|
-
// /etc/os-release::ID (ubuntu, debian, rocky, etc.)
|
|
1156
1161
|
os_version_id: z2.string().optional(),
|
|
1157
|
-
// /etc/os-release::VERSION_ID (24.04, 22.04, 11, 10.0.19045, ...)
|
|
1158
1162
|
os_version_codename: z2.string().optional(),
|
|
1159
|
-
// /etc/os-release::VERSION_CODENAME (jammy, noble...)
|
|
1160
1163
|
os_pretty_name: z2.string().optional(),
|
|
1161
|
-
// /etc/os-release::PRETTY_NAME
|
|
1162
1164
|
kernel_release: z2.string().optional(),
|
|
1163
|
-
// uname -r
|
|
1164
1165
|
hostname: z2.string().optional(),
|
|
1165
|
-
// uname -n
|
|
1166
1166
|
labels: z2.record(z2.string(), z2.string().optional()).optional()
|
|
1167
1167
|
});
|
|
1168
|
+
function isWebTTYCapability(value) {
|
|
1169
|
+
return webttyCapabilitySchema.safeParse(value).success;
|
|
1170
|
+
}
|
|
1171
|
+
function parseWebTTYCapabilities(value) {
|
|
1172
|
+
const values = (value ?? "").split(",").map((capability) => capability.trim()).filter(isWebTTYCapability);
|
|
1173
|
+
return webttyCapabilitySchema.options.filter(
|
|
1174
|
+
(capability) => values.includes(capability)
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1177
|
+
function webTTYCapabilitiesForLabels(labels) {
|
|
1178
|
+
const parsed = parseWebTTYCapabilities(labels["rstream.webtty.capabilities"]);
|
|
1179
|
+
return parsed.length > 0 ? parsed : ["exec"];
|
|
1180
|
+
}
|
|
1181
|
+
function webTTYHasCapability(capabilities, capability) {
|
|
1182
|
+
return capabilities.includes(capability);
|
|
1183
|
+
}
|
|
1168
1184
|
function parser(tunnel) {
|
|
1169
1185
|
if (tunnel.status !== "online") return null;
|
|
1170
1186
|
if (tunnel.publish !== true) return null;
|
|
@@ -1173,6 +1189,7 @@ function parser(tunnel) {
|
|
|
1173
1189
|
if (tunnelLabels["application-protocol"] !== "rstream.webtty") {
|
|
1174
1190
|
return null;
|
|
1175
1191
|
}
|
|
1192
|
+
const capabilities = webTTYCapabilitiesForLabels(tunnelLabels);
|
|
1176
1193
|
const labels = {};
|
|
1177
1194
|
for (const [key, value] of Object.entries(tunnelLabels)) {
|
|
1178
1195
|
if (!key.startsWith("rstream.webtty.label.")) continue;
|
|
@@ -1184,6 +1201,10 @@ function parser(tunnel) {
|
|
|
1184
1201
|
tunnel_id: tunnel.id,
|
|
1185
1202
|
host: formatTunnelHost(tunnel),
|
|
1186
1203
|
token_auth: tunnel.token_auth === true,
|
|
1204
|
+
capabilities,
|
|
1205
|
+
exec_path: webTTYHasCapability(capabilities, "exec") ? tunnelLabels["rstream.webtty.exec.path"] ?? "/" : void 0,
|
|
1206
|
+
fs_path: webTTYHasCapability(capabilities, "fs") ? tunnelLabels["rstream.webtty.fs.path"] ?? "/fs" : void 0,
|
|
1207
|
+
fs_mode: webTTYHasCapability(capabilities, "fs") ? tunnelLabels["rstream.webtty.fs.mode"] ?? "read-write" : void 0,
|
|
1187
1208
|
os_family: tunnelLabels["rstream.webtty.os_family"],
|
|
1188
1209
|
arch: tunnelLabels["rstream.webtty.arch"],
|
|
1189
1210
|
os_id: tunnelLabels["rstream.webtty.os_id"],
|