typescript-virtual-container 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,13 +48,13 @@ function bootstrapEtc(vfs, hostname, props) {
48
48
  `NAME="Fortune GNU/Linux"`,
49
49
  `PRETTY_NAME="${props.os}"`,
50
50
  `ID=fortune`,
51
- `ID_LIKE=debian`,
51
+ `ID_LIKE=fortune`,
52
52
  `HOME_URL="https://github.com/itsrealfortune/typescript-virtual-container"`,
53
53
  `VERSION_CODENAME=nyx`,
54
- `VERSION_ID="24.04"`,
54
+ `VERSION_ID="1.0"`,
55
55
  `FORTUNE_CODENAME=nyx`,
56
56
  ].join("\n")}\n`);
57
- ensureFile(vfs, "/etc/debian_version", "nyx/stable\n");
57
+ ensureFile(vfs, "/etc/fortune_version", "nyx/stable\n");
58
58
  ensureFile(vfs, "/etc/hostname", `${hostname}\n`);
59
59
  ensureFile(vfs, "/etc/shells", "/bin/sh\n/bin/bash\n/usr/bin/bash\n/bin/dash\n/usr/bin/dash\n");
60
60
  ensureFile(vfs, "/etc/profile", `${[
@@ -65,12 +65,12 @@ function bootstrapEtc(vfs, hostname, props) {
65
65
  " export PS1='\\[\\e[37;1m\\][\\[\\e[35;1m\\]\\u\\[\\e[37;1m\\]@\\[\\e[34;1m\\]\\h\\[\\e[0m\\] \\w]\\[\\e[0m\\]\\$ '",
66
66
  "fi",
67
67
  ].join("\n")}\n`);
68
- ensureFile(vfs, "/etc/issue", "Fortune GNU/Linux 24.04 LTS \\n \\l\n");
69
- ensureFile(vfs, "/etc/issue.net", "Fortune GNU/Linux 24.04 LTS\n");
68
+ ensureFile(vfs, "/etc/issue", "Fortune GNU/Linux 1.0 Nyx \\n \\l\n");
69
+ ensureFile(vfs, "/etc/issue.net", "Fortune GNU/Linux 1.0 Nyx\n");
70
70
  ensureFile(vfs, "/etc/motd", ["", `Welcome to ${props.os}`, `Kernel: ${props.kernel}`, ""].join("\n"));
71
71
  ensureFile(vfs, "/etc/lsb-release", `${[
72
72
  "DISTRIB_ID=Fortune",
73
- "DISTRIB_RELEASE=24.04",
73
+ "DISTRIB_RELEASE=1.0",
74
74
  "DISTRIB_CODENAME=nyx",
75
75
  `DISTRIB_DESCRIPTION="${props.os}"`,
76
76
  ].join("\n")}\n`);
@@ -642,8 +642,8 @@ export function refreshProc(vfs, props, hostname, shellStartTime, sessions = [],
642
642
  "dm_mod 155648 10 - Live 0x0000000000000000",
643
643
  "crc32c_intel 24576 10 - Live 0x0000000000000000",
644
644
  ].join("\n")}\n`);
645
- // /proc/cmdline — Firecracker boot args
646
- write(vfs, "/proc/cmdline", `console=ttyS0 reboot=k panic=1 nomodule random.trust_cpu=1 ipv6.disable=1 swiotlb=noforce rdinit=/process_api init_on_free=1 -- --firecracker-init --addr 0.0.0.0:2024 --max-ws-buffer-size 32768 --block-local-connections\n`);
645
+ // /proc/cmdline — boot args
646
+ write(vfs, "/proc/cmdline", `console=ttyS0 reboot=k panic=1 nomodule random.trust_cpu=1 ipv6.disable=1 swiotlb=noforce rdinit=/process_api init_on_free=1\n`);
647
647
  // /proc/filesystems — matching real container
648
648
  write(vfs, "/proc/filesystems", `${[
649
649
  "nodev\tsysfs",
@@ -1512,8 +1512,7 @@ function bootstrapMisc(vfs, props) {
1512
1512
  ensureDir(vfs, "/srv");
1513
1513
  ensureDir(vfs, "/mnt");
1514
1514
  ensureDir(vfs, "/media");
1515
- // /boot — no kernel images in Firecracker containers (kernel is external),
1516
- // but maintain the directory structure for tool compatibility
1515
+ // /boot — kernel images, initrd, and bootloader config
1517
1516
  ensureDir(vfs, "/boot");
1518
1517
  ensureDir(vfs, "/boot/grub");
1519
1518
  ensureFile(vfs, "/boot/grub/grub.cfg", `${[
@@ -1521,26 +1520,133 @@ function bootstrapMisc(vfs, props) {
1521
1520
  "set default=0",
1522
1521
  "set timeout=0",
1523
1522
  "",
1524
- `menuentry "Fortune GNU/Linux" {`,
1523
+ `menuentry "Fortune GNU/Linux 1.0 Nyx" {`,
1525
1524
  ` linux /vmlinuz-${props.kernel} root=/dev/vda rw console=ttyS0`,
1526
1525
  ` initrd /initrd.img-${props.kernel}`,
1527
1526
  `}`,
1528
1527
  ].join("\n")}\n`);
1529
1528
  const kver = props.kernel;
1530
- ensureFile(vfs, `/boot/vmlinuz-${kver}`, "", 0o644);
1531
- ensureFile(vfs, `/boot/initrd.img-${kver}`, "", 0o644);
1532
- ensureFile(vfs, `/boot/System.map-${kver}`, `${kver} virtual\n`, 0o644);
1533
- ensureFile(vfs, `/boot/config-${kver}`, `# Linux kernel config ${kver}\nCONFIG_VIRTIO=y\nCONFIG_VIRTIO_BLK=y\nCONFIG_VIRTIO_NET=y\nCONFIG_KVM_GUEST=y\n`, 0o644);
1529
+ // kernel image — padded to a realistic size so ls -l /boot/ looks credible
1530
+ const vmlinuzContent = `# Fortune GNU/Linux kernel ${kver}
1531
+ # Compressed Linux/x86_64 kernel image
1532
+ # Build: fortune@nyx-build, gcc (Fortune 13.3.0-nyx1)
1533
+ # SMP PREEMPT_DYNAMIC, virtio, kvm_guest
1534
+ `.padEnd(10240, "x");
1535
+ ensureFile(vfs, `/boot/vmlinuz-${kver}`, vmlinuzContent, 0o644);
1536
+ ensureFile(vfs, `/boot/initrd.img-${kver}`, `${[
1537
+ "#!/bin/sh",
1538
+ "# Fortune GNU/Linux initramfs",
1539
+ `# Kernel: ${kver}`,
1540
+ "mount -t proc none /proc",
1541
+ "mount -t sysfs none /sys",
1542
+ "mount -t devtmpfs none /dev",
1543
+ "echo 'Loading Fortune GNU/Linux 1.0 Nyx...'",
1544
+ "exec /sbin/init",
1545
+ ].join("\n")}\n`, 0o644);
1546
+ ensureFile(vfs, `/boot/System.map-${kver}`, `${[
1547
+ "ffffffff81000000 T _stext",
1548
+ "ffffffff81000000 T _text",
1549
+ "ffffffff81000000 A startup_64",
1550
+ "ffffffff81000100 T secondary_startup_64",
1551
+ "ffffffff81000200 T __startup_64",
1552
+ "ffffffff81001000 T x86_64_start_kernel",
1553
+ "ffffffff81001100 T x86_64_start_reservations",
1554
+ "ffffffff81001200 T start_kernel",
1555
+ "ffffffff81002000 T init_task",
1556
+ "ffffffff81003000 T rest_init",
1557
+ "ffffffff81004000 T kernel_init",
1558
+ "ffffffff81005000 T kernel_init_freeable",
1559
+ "ffffffff81006000 T do_basic_setup",
1560
+ "ffffffffa0000000 T virtio_init",
1561
+ "ffffffffa0001000 T virtio_devices_init",
1562
+ "ffffffffa0010000 T virtio_blk_init",
1563
+ "ffffffffa0020000 T virtio_net_init",
1564
+ "ffffffffa00f0000 T fortitude_init",
1565
+ ].join("\n")}\n`, 0o644);
1566
+ ensureFile(vfs, `/boot/config-${kver}`, `${[
1567
+ "#",
1568
+ "# Linux/x86_64 6.1.0-fortune Kernel Configuration",
1569
+ "# Fortune GNU/Linux 1.0 Nyx",
1570
+ "#",
1571
+ "CONFIG_64BIT=y",
1572
+ "CONFIG_X86_64=y",
1573
+ "CONFIG_SMP=y",
1574
+ "CONFIG_PREEMPT=y",
1575
+ "CONFIG_PREEMPT_DYNAMIC=y",
1576
+ "",
1577
+ "#",
1578
+ "# Virtualization",
1579
+ "#",
1580
+ "CONFIG_HYPERVISOR_GUEST=y",
1581
+ "CONFIG_KVM_GUEST=y",
1582
+ "CONFIG_PARAVIRT=y",
1583
+ "CONFIG_PARAVIRT_SPINLOCKS=y",
1584
+ "",
1585
+ "#",
1586
+ "# Virtio",
1587
+ "#",
1588
+ "CONFIG_VIRTIO=y",
1589
+ "CONFIG_VIRTIO_MENU=y",
1590
+ "CONFIG_VIRTIO_BLK=y",
1591
+ "CONFIG_VIRTIO_NET=y",
1592
+ "CONFIG_VIRTIO_CONSOLE=y",
1593
+ "CONFIG_VIRTIO_BALLOON=y",
1594
+ "CONFIG_VIRTIO_MMIO=y",
1595
+ "CONFIG_VIRTIO_INPUT=y",
1596
+ "",
1597
+ "#",
1598
+ "# Block devices",
1599
+ "#",
1600
+ "CONFIG_BLK_DEV=y",
1601
+ "CONFIG_EXT4_FS=y",
1602
+ "CONFIG_TMPFS=y",
1603
+ "CONFIG_TMPFS_XATTR=y",
1604
+ "",
1605
+ "#",
1606
+ "# Networking",
1607
+ "#",
1608
+ "CONFIG_NET=y",
1609
+ "CONFIG_INET=y",
1610
+ "CONFIG_IPV6=n",
1611
+ "CONFIG_BRIDGE=m",
1612
+ "CONFIG_NETFILTER=y",
1613
+ "CONFIG_NETFILTER_XTABLES=y",
1614
+ "",
1615
+ "#",
1616
+ "# Console",
1617
+ "#",
1618
+ "CONFIG_SERIAL_8250=y",
1619
+ "CONFIG_SERIAL_8250_CONSOLE=y",
1620
+ "CONFIG_VT=y",
1621
+ "CONFIG_VT_CONSOLE=y",
1622
+ "CONFIG_HW_CONSOLE=y",
1623
+ "",
1624
+ "#",
1625
+ "# Security",
1626
+ "#",
1627
+ "CONFIG_SECURITY=y",
1628
+ "CONFIG_SECURITY_NETWORK=y",
1629
+ "CONFIG_LSM=\"lockdown,yama,loadpin,safesetid,integrity\"",
1630
+ "",
1631
+ "#",
1632
+ "# Virtual file system",
1633
+ "#",
1634
+ "CONFIG_PROC_FS=y",
1635
+ "CONFIG_SYSFS=y",
1636
+ "CONFIG_DEVTMPFS=y",
1637
+ "CONFIG_DEVTMPFS_MOUNT=y",
1638
+ "CONFIG_CONFIGFS_FS=y",
1639
+ "CONFIG_DEBUG_FS=y",
1640
+ ].join("\n")}\n`, 0o644);
1641
+ const prevKver = "1.0.0+itsrealfortune+0-amd64";
1534
1642
  if (!vfs.exists("/vmlinuz"))
1535
1643
  vfs.symlink(`/boot/vmlinuz-${kver}`, "/vmlinuz");
1536
1644
  if (!vfs.exists("/vmlinuz.old"))
1537
- vfs.symlink(`/boot/vmlinuz-${kver}`, "/vmlinuz.old");
1645
+ vfs.symlink(`/boot/vmlinuz-${prevKver}`, "/vmlinuz.old");
1538
1646
  if (!vfs.exists("/initrd.img"))
1539
1647
  vfs.symlink(`/boot/initrd.img-${kver}`, "/initrd.img");
1540
1648
  if (!vfs.exists("/initrd.img.old"))
1541
- vfs.symlink(`/boot/initrd.img-${kver}`, "/initrd.img.old");
1542
- // No /snap — not present in Firecracker container
1543
- // /proc/cmdline confirms: no snapd boot args
1649
+ vfs.symlink(`/boot/initrd.img-${prevKver}`, "/initrd.img.old");
1544
1650
  // /lost+found — ext4 recovery
1545
1651
  ensureDir(vfs, "/lost+found", 0o700);
1546
1652
  // /home — users managed by bootstrapRoot + syncEtcPasswd
@@ -0,0 +1 @@
1
+ export declare function keyToBytes(e: KeyboardEvent): Uint8Array | null;
@@ -0,0 +1,46 @@
1
+ export function keyToBytes(e) {
2
+ const enc = new TextEncoder();
3
+ if (e.ctrlKey && !e.altKey) {
4
+ const k = e.key.toLowerCase();
5
+ if (k.length === 1 && k >= "a" && k <= "z")
6
+ return new Uint8Array([k.charCodeAt(0) - 96]);
7
+ if (e.key === "[")
8
+ return new Uint8Array([27]);
9
+ if (e.key === "\\")
10
+ return new Uint8Array([28]);
11
+ if (e.key === "]")
12
+ return new Uint8Array([29]);
13
+ if (e.key === "_" || e.key === "/")
14
+ return new Uint8Array([31]);
15
+ if (e.key === "Backspace")
16
+ return new Uint8Array([8]);
17
+ }
18
+ if (e.altKey && !e.ctrlKey && e.key.length === 1) {
19
+ return new Uint8Array([27, e.key.charCodeAt(0)]);
20
+ }
21
+ switch (e.key) {
22
+ case "ArrowUp": return new Uint8Array([27, 91, 65]);
23
+ case "ArrowDown": return new Uint8Array([27, 91, 66]);
24
+ case "ArrowRight": return new Uint8Array([27, 91, 67]);
25
+ case "ArrowLeft": return new Uint8Array([27, 91, 68]);
26
+ case "Home": return new Uint8Array([27, 91, 72]);
27
+ case "End": return new Uint8Array([27, 91, 70]);
28
+ case "PageUp": return new Uint8Array([27, 91, 53, 126]);
29
+ case "PageDown": return new Uint8Array([27, 91, 54, 126]);
30
+ case "Delete": return new Uint8Array([27, 91, 51, 126]);
31
+ case "Insert": return new Uint8Array([27, 91, 50, 126]);
32
+ case "F1": return new Uint8Array([27, 79, 80]);
33
+ case "F2": return new Uint8Array([27, 79, 81]);
34
+ case "F3": return new Uint8Array([27, 79, 82]);
35
+ case "F4": return new Uint8Array([27, 79, 83]);
36
+ case "Backspace": return new Uint8Array([127]);
37
+ case "Enter": return new Uint8Array([13]);
38
+ case "Tab": return new Uint8Array([9]);
39
+ case "Escape": return new Uint8Array([27]);
40
+ default:
41
+ if (e.key.length === 1 && !e.ctrlKey && !e.metaKey) {
42
+ return enc.encode(e.key);
43
+ }
44
+ return null;
45
+ }
46
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
7
- "version": "1.6.1",
7
+ "version": "1.6.3",
8
8
  "files": [
9
9
  "dist/",
10
10
  "README.md",