-
-
Notifications
You must be signed in to change notification settings - Fork 145
/
test.sh
executable file
·58 lines (46 loc) · 1.22 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Variables
EXE_NAME="$1"
JS_SOURCE_FILE="$2"
OUTPUT_FOLDER="$3"
# Ensure nvm is installed
if ! command -v nvm &> /dev/null
then
echo "nvm not found. Installing..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# shellcheck source=/dev/null
source ~/.nvm/nvm.sh
fi
# Use Node 22
nvm install 22
nvm use 22
# Create sea-config.json
cat <<EOF > sea-config.json
{
"main": "${JS_SOURCE_FILE}",
"output": "sea-prep.blob",
"assets": {
"index.html": "public/index.html",
"top.html": "public/top.html",
"style.css": "public/style.css",
"injection.js": "public/injection.js",
"redirector.html": "public/redirector.html"
}
}
EOF
# Generate the blob
node --experimental-sea-config sea-config.json
# Copy node binary
cp "$(command -v node)" "$EXE_NAME"
# Remove the signature of the binary
codesign --remove-signature "$EXE_NAME"
# Inject the blob
npx postject "$EXE_NAME" NODE_SEA_BLOB sea-prep.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
--macho-segment-name NODE_SEA
# Sign the binary
codesign --sign - "$EXE_NAME"
# Move the executable to the output folder
mv "$EXE_NAME" "$OUTPUT_FOLDER"
# Clean up
rm sea-config.json sea-prep.blob