@annadata/capacitor-mqtt-quic 0.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 +399 -0
- package/android/NGTCP2_BUILD_INSTRUCTIONS.md +319 -0
- package/android/build-nghttp3.sh +182 -0
- package/android/build-ngtcp2.sh +289 -0
- package/android/build-openssl.sh +302 -0
- package/android/build.gradle +75 -0
- package/android/gradle.properties +3 -0
- package/android/proguard-rules.pro +2 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/assets/mqttquic_ca.pem +5 -0
- package/android/src/main/cpp/CMakeLists.txt +157 -0
- package/android/src/main/cpp/ngtcp2_jni.cpp +928 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/MqttQuicPlugin.kt +232 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/client/MQTTClient.kt +339 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/mqtt/MQTT5Properties.kt +250 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/mqtt/MQTT5Protocol.kt +281 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/mqtt/MQTT5ReasonCodes.kt +109 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/mqtt/MQTTProtocol.kt +249 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/mqtt/MQTTTypes.kt +47 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/quic/NGTCP2Client.kt +184 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/quic/QuicClientStub.kt +54 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/quic/QuicTypes.kt +21 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/transport/QUICStreamAdapter.kt +37 -0
- package/android/src/main/kotlin/ai/annadata/mqttquic/transport/StreamTransport.kt +91 -0
- package/android/src/test/kotlin/ai/annadata/mqttquic/mqtt/MQTTProtocolTest.kt +92 -0
- package/dist/esm/definitions.d.ts +66 -0
- package/dist/esm/definitions.d.ts.map +1 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +28 -0
- package/dist/esm/web.d.ts.map +1 -0
- package/dist/esm/web.js +183 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +217 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +215 -0
- package/dist/plugin.js.map +1 -0
- package/ios/MqttQuicPlugin.podspec +34 -0
- package/ios/NGTCP2_BUILD_INSTRUCTIONS.md +302 -0
- package/ios/Sources/MqttQuicPlugin/Client/MQTTClient.swift +343 -0
- package/ios/Sources/MqttQuicPlugin/MQTT/MQTT5Properties.swift +280 -0
- package/ios/Sources/MqttQuicPlugin/MQTT/MQTT5Protocol.swift +333 -0
- package/ios/Sources/MqttQuicPlugin/MQTT/MQTT5ReasonCodes.swift +113 -0
- package/ios/Sources/MqttQuicPlugin/MQTT/MQTTProtocol.swift +322 -0
- package/ios/Sources/MqttQuicPlugin/MQTT/MQTTTypes.swift +54 -0
- package/ios/Sources/MqttQuicPlugin/MqttQuicPlugin.swift +229 -0
- package/ios/Sources/MqttQuicPlugin/QUIC/NGTCP2Bridge.h +29 -0
- package/ios/Sources/MqttQuicPlugin/QUIC/NGTCP2Bridge.mm +865 -0
- package/ios/Sources/MqttQuicPlugin/QUIC/NGTCP2Client.swift +262 -0
- package/ios/Sources/MqttQuicPlugin/QUIC/QuicClientStub.swift +66 -0
- package/ios/Sources/MqttQuicPlugin/QUIC/QuicTypes.swift +23 -0
- package/ios/Sources/MqttQuicPlugin/Resources/mqttquic_ca.pem +5 -0
- package/ios/Sources/MqttQuicPlugin/Transport/QUICStreamAdapter.swift +50 -0
- package/ios/Sources/MqttQuicPlugin/Transport/StreamTransport.swift +105 -0
- package/ios/Tests/MQTTProtocolTests.swift +82 -0
- package/ios/build-nghttp3.sh +173 -0
- package/ios/build-ngtcp2.sh +278 -0
- package/ios/build-openssl.sh +405 -0
- package/package.json +63 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Build script for OpenSSL on iOS
|
|
4
|
+
#
|
|
5
|
+
# This script builds OpenSSL 3.0+ as a static library for iOS.
|
|
6
|
+
# It requires:
|
|
7
|
+
# - Xcode 14+ (for iOS 15+)
|
|
8
|
+
# - iOS SDK 15.0+
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# ./build-openssl.sh [--arch ARCH] [--sdk SDK] [--version VERSION] [--quictls] [--quictls-branch BRANCH]
|
|
12
|
+
#
|
|
13
|
+
# Example:
|
|
14
|
+
# ./build-openssl.sh --arch arm64 --sdk iphoneos --version 3.2.0 --quictls
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
set -e
|
|
18
|
+
|
|
19
|
+
# Default values
|
|
20
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
21
|
+
if [ -z "$PROJECT_DIR" ] && [ -f "$SCRIPT_DIR/../package.json" ]; then
|
|
22
|
+
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
23
|
+
fi
|
|
24
|
+
if [ -n "$PROJECT_DIR" ]; then
|
|
25
|
+
REF_CODE_DIR="$(cd "$PROJECT_DIR/ref-code" && pwd)"
|
|
26
|
+
else
|
|
27
|
+
if [ -d "$SCRIPT_DIR/../ref-code" ]; then
|
|
28
|
+
REF_CODE_DIR="$(cd "$SCRIPT_DIR/../ref-code" && pwd)"
|
|
29
|
+
else
|
|
30
|
+
REF_CODE_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
31
|
+
fi
|
|
32
|
+
fi
|
|
33
|
+
DEFAULT_OPENSSL_SOURCE_DIR=""
|
|
34
|
+
if [ -n "$PROJECT_DIR" ] && [ -d "$PROJECT_DIR/ref-code/openssl" ]; then
|
|
35
|
+
DEFAULT_OPENSSL_SOURCE_DIR="$(cd "$PROJECT_DIR/ref-code/openssl" && pwd)"
|
|
36
|
+
elif [ -n "$PROJECT_DIR" ] && [ -d "$PROJECT_DIR/ref-code.openssl" ]; then
|
|
37
|
+
DEFAULT_OPENSSL_SOURCE_DIR="$(cd "$PROJECT_DIR/ref-code.openssl" && pwd)"
|
|
38
|
+
elif [ -d "$SCRIPT_DIR/../ref-code/openssl" ]; then
|
|
39
|
+
DEFAULT_OPENSSL_SOURCE_DIR="$(cd "$SCRIPT_DIR/../ref-code/openssl" && pwd)"
|
|
40
|
+
elif [ -d "$SCRIPT_DIR/../ref-code.openssl" ]; then
|
|
41
|
+
DEFAULT_OPENSSL_SOURCE_DIR="$(cd "$SCRIPT_DIR/../ref-code.openssl" && pwd)"
|
|
42
|
+
else
|
|
43
|
+
DEFAULT_OPENSSL_SOURCE_DIR="$REF_CODE_DIR/openssl"
|
|
44
|
+
fi
|
|
45
|
+
OPENSSL_VERSION="${OPENSSL_VERSION:-3.2.0}"
|
|
46
|
+
USE_QUICTLS="${USE_QUICTLS:-0}"
|
|
47
|
+
QUICTLS_BRANCH="${QUICTLS_BRANCH:-openssl-3.1.7+quic}"
|
|
48
|
+
ARCH="${ARCH:-arm64}"
|
|
49
|
+
SDK="${SDK:-iphoneos}"
|
|
50
|
+
IOS_DEPLOYMENT_TARGET="${IOS_DEPLOYMENT_TARGET:-15.0}"
|
|
51
|
+
INSTALL_PREFIX="${INSTALL_PREFIX:-$(pwd)/install/openssl-ios}"
|
|
52
|
+
|
|
53
|
+
# Parse arguments
|
|
54
|
+
while [[ $# -gt 0 ]]; do
|
|
55
|
+
case $1 in
|
|
56
|
+
--arch)
|
|
57
|
+
ARCH="$2"
|
|
58
|
+
shift 2
|
|
59
|
+
;;
|
|
60
|
+
--sdk)
|
|
61
|
+
SDK="$2"
|
|
62
|
+
shift 2
|
|
63
|
+
;;
|
|
64
|
+
--version)
|
|
65
|
+
OPENSSL_VERSION="$2"
|
|
66
|
+
shift 2
|
|
67
|
+
;;
|
|
68
|
+
--quictls)
|
|
69
|
+
USE_QUICTLS=1
|
|
70
|
+
shift
|
|
71
|
+
;;
|
|
72
|
+
--quictls-branch)
|
|
73
|
+
QUICTLS_BRANCH="$2"
|
|
74
|
+
USE_QUICTLS=1
|
|
75
|
+
shift 2
|
|
76
|
+
;;
|
|
77
|
+
--ios-deployment-target)
|
|
78
|
+
IOS_DEPLOYMENT_TARGET="$2"
|
|
79
|
+
shift 2
|
|
80
|
+
;;
|
|
81
|
+
--prefix)
|
|
82
|
+
INSTALL_PREFIX="$2"
|
|
83
|
+
shift 2
|
|
84
|
+
;;
|
|
85
|
+
*)
|
|
86
|
+
echo "Unknown option: $1"
|
|
87
|
+
echo "Usage: $0 [--arch ARCH] [--sdk SDK] [--version VERSION] [--quictls] [--quictls-branch BRANCH]"
|
|
88
|
+
exit 1
|
|
89
|
+
;;
|
|
90
|
+
esac
|
|
91
|
+
done
|
|
92
|
+
|
|
93
|
+
# Check prerequisites
|
|
94
|
+
if ! command -v xcrun &> /dev/null; then
|
|
95
|
+
echo "Error: Xcode command line tools are not installed"
|
|
96
|
+
exit 1
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# Get iOS SDK path
|
|
100
|
+
IOS_SDK_PATH=$(xcrun --sdk "$SDK" --show-sdk-path)
|
|
101
|
+
if [ -z "$IOS_SDK_PATH" ]; then
|
|
102
|
+
echo "Error: Could not find iOS SDK for $SDK"
|
|
103
|
+
exit 1
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
if [ "$USE_QUICTLS" = "1" ]; then
|
|
107
|
+
echo "Building quictls ($QUICTLS_BRANCH) for iOS"
|
|
108
|
+
else
|
|
109
|
+
echo "Building OpenSSL $OPENSSL_VERSION for iOS"
|
|
110
|
+
fi
|
|
111
|
+
echo " Architecture: $ARCH"
|
|
112
|
+
echo " SDK: $SDK"
|
|
113
|
+
echo " SDK Path: $IOS_SDK_PATH"
|
|
114
|
+
echo " Deployment Target: iOS $IOS_DEPLOYMENT_TARGET"
|
|
115
|
+
echo " Install Prefix: $INSTALL_PREFIX"
|
|
116
|
+
|
|
117
|
+
# Check if OpenSSL/quictls source exists
|
|
118
|
+
if [ "$USE_QUICTLS" = "1" ]; then
|
|
119
|
+
OPENSSL_SOURCE_DIR="${OPENSSL_SOURCE_DIR:-$DEFAULT_OPENSSL_SOURCE_DIR}"
|
|
120
|
+
OPENSSL_REPO_URL="https://github.com/quictls/openssl.git"
|
|
121
|
+
OPENSSL_REPO_BRANCH="$QUICTLS_BRANCH"
|
|
122
|
+
else
|
|
123
|
+
OPENSSL_SOURCE_DIR="${OPENSSL_SOURCE_DIR:-$DEFAULT_OPENSSL_SOURCE_DIR}"
|
|
124
|
+
OPENSSL_REPO_URL="https://github.com/openssl/openssl.git"
|
|
125
|
+
OPENSSL_REPO_BRANCH="openssl-$OPENSSL_VERSION"
|
|
126
|
+
fi
|
|
127
|
+
if [ ! -d "$OPENSSL_SOURCE_DIR" ]; then
|
|
128
|
+
echo "OpenSSL source not found. Cloning..."
|
|
129
|
+
git clone --depth 1 --branch "$OPENSSL_REPO_BRANCH" \
|
|
130
|
+
"$OPENSSL_REPO_URL" "$OPENSSL_SOURCE_DIR" || \
|
|
131
|
+
git clone --depth 1 "$OPENSSL_REPO_URL" "$OPENSSL_SOURCE_DIR"
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
# Validate quictls source when requested
|
|
135
|
+
if [ "$USE_QUICTLS" = "1" ]; then
|
|
136
|
+
if ! grep -q "SSL_provide_quic_data" "$OPENSSL_SOURCE_DIR/include/openssl/ssl.h.in" 2>/dev/null; then
|
|
137
|
+
echo "Error: OPENSSL_SOURCE_DIR does not appear to be quictls."
|
|
138
|
+
echo "Please clone quictls into $OPENSSL_SOURCE_DIR or set OPENSSL_SOURCE_DIR to a quictls checkout."
|
|
139
|
+
echo "Example:"
|
|
140
|
+
echo " git clone --depth 1 --branch $QUICTLS_BRANCH $OPENSSL_REPO_URL $OPENSSL_SOURCE_DIR"
|
|
141
|
+
exit 1
|
|
142
|
+
fi
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
cd "$OPENSSL_SOURCE_DIR"
|
|
146
|
+
|
|
147
|
+
# Set up environment for iOS cross-compilation
|
|
148
|
+
IOS_CC=$(xcrun --sdk "$SDK" --find clang)
|
|
149
|
+
IOS_AR=$(xcrun --sdk "$SDK" --find ar)
|
|
150
|
+
IOS_RANLIB=$(xcrun --sdk "$SDK" --find ranlib)
|
|
151
|
+
|
|
152
|
+
# Set compiler flags with correct sysroot
|
|
153
|
+
IOS_CFLAGS="-arch $ARCH -isysroot $IOS_SDK_PATH -mios-version-min=$IOS_DEPLOYMENT_TARGET -fno-common"
|
|
154
|
+
|
|
155
|
+
# Determine platform name based on architecture and SDK
|
|
156
|
+
if [ "$SDK" = "iphonesimulator" ]; then
|
|
157
|
+
case "$ARCH" in
|
|
158
|
+
arm64)
|
|
159
|
+
PLATFORM="iossimulator-arm64-xcrun"
|
|
160
|
+
;;
|
|
161
|
+
x86_64)
|
|
162
|
+
PLATFORM="iossimulator-xcrun"
|
|
163
|
+
;;
|
|
164
|
+
*)
|
|
165
|
+
echo "Error: Unsupported simulator architecture: $ARCH"
|
|
166
|
+
exit 1
|
|
167
|
+
;;
|
|
168
|
+
esac
|
|
169
|
+
else
|
|
170
|
+
case "$ARCH" in
|
|
171
|
+
arm64)
|
|
172
|
+
PLATFORM="ios64-xcrun"
|
|
173
|
+
;;
|
|
174
|
+
armv7)
|
|
175
|
+
PLATFORM="ios-xcrun"
|
|
176
|
+
;;
|
|
177
|
+
*)
|
|
178
|
+
echo "Error: Unsupported device architecture: $ARCH"
|
|
179
|
+
exit 1
|
|
180
|
+
;;
|
|
181
|
+
esac
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
# Check if platform is available, fallback to ios64-cross if not
|
|
185
|
+
if ! ./Configure list | grep -q "^$PLATFORM\$"; then
|
|
186
|
+
echo "Warning: Platform $PLATFORM not found, trying ios64-cross..."
|
|
187
|
+
if [ "$ARCH" = "arm64" ] && [ "$SDK" != "iphonesimulator" ]; then
|
|
188
|
+
PLATFORM="ios64-cross"
|
|
189
|
+
# For ios64-cross, we need to set environment variables properly
|
|
190
|
+
export CROSS_TOP="$IOS_SDK_PATH/.."
|
|
191
|
+
export CROSS_SDK=$(basename "$IOS_SDK_PATH")
|
|
192
|
+
export CC="$IOS_CC $IOS_CFLAGS"
|
|
193
|
+
else
|
|
194
|
+
echo "Error: Cannot determine appropriate platform for $ARCH on $SDK"
|
|
195
|
+
exit 1
|
|
196
|
+
fi
|
|
197
|
+
else
|
|
198
|
+
# Use xcrun targets which handle sysroot automatically
|
|
199
|
+
export CC="$IOS_CC"
|
|
200
|
+
export CFLAGS="$IOS_CFLAGS"
|
|
201
|
+
fi
|
|
202
|
+
|
|
203
|
+
export AR="$IOS_AR"
|
|
204
|
+
export RANLIB="$IOS_RANLIB"
|
|
205
|
+
|
|
206
|
+
# Clean previous build if it exists (important for QUIC support)
|
|
207
|
+
echo ""
|
|
208
|
+
echo "Cleaning previous OpenSSL build (if any)..."
|
|
209
|
+
if [ -f "Makefile" ] || [ -f "configdata.pm" ]; then
|
|
210
|
+
make distclean 2>/dev/null || true
|
|
211
|
+
# Also remove any generated config files
|
|
212
|
+
rm -f configdata.pm Makefile 2>/dev/null || true
|
|
213
|
+
fi
|
|
214
|
+
|
|
215
|
+
# Configure OpenSSL
|
|
216
|
+
echo ""
|
|
217
|
+
echo "Configuring OpenSSL for $PLATFORM with QUIC support..."
|
|
218
|
+
# OpenSSL uses "enable-quic" (not "quic") for QUIC support.
|
|
219
|
+
QUIC_OPTION="enable-quic"
|
|
220
|
+
if [ "$PLATFORM" = "ios64-cross" ]; then
|
|
221
|
+
# For ios64-cross, set environment variables that OpenSSL expects
|
|
222
|
+
export CROSS_TOP="$(dirname "$(dirname "$IOS_SDK_PATH")")"
|
|
223
|
+
export CROSS_SDK="$(basename "$IOS_SDK_PATH")"
|
|
224
|
+
export BUILD_TOOL="${IOS_CC%/*}"
|
|
225
|
+
|
|
226
|
+
./Configure "$PLATFORM" \
|
|
227
|
+
--prefix="$INSTALL_PREFIX" \
|
|
228
|
+
--openssldir="$INSTALL_PREFIX/ssl" \
|
|
229
|
+
no-shared \
|
|
230
|
+
no-tests \
|
|
231
|
+
no-asm \
|
|
232
|
+
"$QUIC_OPTION" \
|
|
233
|
+
-mios-version-min="$IOS_DEPLOYMENT_TARGET"
|
|
234
|
+
|
|
235
|
+
# Fix the Makefile to ensure correct sysroot is used
|
|
236
|
+
if [ -f "Makefile" ]; then
|
|
237
|
+
echo "Fixing Makefile to use correct sysroot..."
|
|
238
|
+
|
|
239
|
+
# Use Python for more reliable text processing
|
|
240
|
+
python3 << EOF
|
|
241
|
+
import re
|
|
242
|
+
import sys
|
|
243
|
+
|
|
244
|
+
sdk_path = "$IOS_SDK_PATH"
|
|
245
|
+
makefile_path = "Makefile"
|
|
246
|
+
|
|
247
|
+
# Read the Makefile
|
|
248
|
+
with open(makefile_path, 'r') as f:
|
|
249
|
+
content = f.read()
|
|
250
|
+
|
|
251
|
+
# Fix 1: Replace incorrect sysroot paths
|
|
252
|
+
content = re.sub(r'-isysroot\s+/SDKs/', f'-isysroot {sdk_path}', content)
|
|
253
|
+
content = re.sub(r'-isysroot\s+\$\(CROSS_TOP\)/SDKs/\$\(CROSS_SDK\)', f'-isysroot {sdk_path}', content)
|
|
254
|
+
|
|
255
|
+
# Fix 2: Fix cases where -isysroot is missing its path argument
|
|
256
|
+
# Pattern: -isysroot followed by whitespace and then a flag starting with -
|
|
257
|
+
# This is the critical fix
|
|
258
|
+
def fix_missing_sysroot(match):
|
|
259
|
+
flag = match.group(1)
|
|
260
|
+
return f'-isysroot {sdk_path} {flag}'
|
|
261
|
+
|
|
262
|
+
# Apply fix multiple times to catch all instances
|
|
263
|
+
for _ in range(10):
|
|
264
|
+
old_content = content
|
|
265
|
+
# Match: -isysroot followed by whitespace, then a flag starting with -
|
|
266
|
+
content = re.sub(r'-isysroot\s+(-[^\s]+)', fix_missing_sysroot, content)
|
|
267
|
+
if old_content == content:
|
|
268
|
+
break # No more changes
|
|
269
|
+
|
|
270
|
+
# Fix 3: Remove duplicate -isysroot arguments (keep only the first)
|
|
271
|
+
content = re.sub(r'-isysroot\s+([^\s]+)\s+-isysroot\s+([^\s]+)', r'-isysroot \1', content)
|
|
272
|
+
|
|
273
|
+
# Fix 4: Remove standalone SDK paths (not part of -isysroot)
|
|
274
|
+
# But be careful not to remove the path when it's part of -isysroot
|
|
275
|
+
def remove_standalone_sdk(match):
|
|
276
|
+
before = match.group(1)
|
|
277
|
+
after = match.group(2) if match.group(2) else ''
|
|
278
|
+
# Only remove if it's not preceded by -isysroot
|
|
279
|
+
if not before.rstrip().endswith('-isysroot'):
|
|
280
|
+
return before + after
|
|
281
|
+
return match.group(0)
|
|
282
|
+
|
|
283
|
+
content = re.sub(r'([^-])\s+' + re.escape(sdk_path) + r'(\s|$)', remove_standalone_sdk, content)
|
|
284
|
+
|
|
285
|
+
# Fix 5: Fix variable assignments that might have issues
|
|
286
|
+
# Fix CFLAGS, LDFLAGS, LDCMD variables
|
|
287
|
+
for var in ['CFLAGS', 'LDFLAGS', 'LDCMD', 'CC', 'CXX']:
|
|
288
|
+
# Remove duplicate -isysroot in variable assignments
|
|
289
|
+
pattern = rf'({var}=[^=]*?)-isysroot\s+[^\s]+\s+-isysroot\s+[^\s]+'
|
|
290
|
+
replacement = rf'\1-isysroot {sdk_path}'
|
|
291
|
+
content = re.sub(pattern, replacement, content)
|
|
292
|
+
|
|
293
|
+
# Ensure -isysroot has path in variable assignments
|
|
294
|
+
pattern = rf'({var}=[^=]*?)-isysroot\s+(-[^\s]+)'
|
|
295
|
+
replacement = rf'\1-isysroot {sdk_path} \2'
|
|
296
|
+
content = re.sub(pattern, replacement, content)
|
|
297
|
+
|
|
298
|
+
# Write the fixed Makefile
|
|
299
|
+
with open(makefile_path, 'w') as f:
|
|
300
|
+
f.write(content)
|
|
301
|
+
|
|
302
|
+
# Verify fix
|
|
303
|
+
if re.search(r'-isysroot\s+-[a-zA-Z]', content):
|
|
304
|
+
print("Warning: Some -isysroot flags may still be missing paths", file=sys.stderr)
|
|
305
|
+
sys.exit(1)
|
|
306
|
+
|
|
307
|
+
print("Makefile fixed successfully")
|
|
308
|
+
EOF
|
|
309
|
+
|
|
310
|
+
if [ $? -ne 0 ]; then
|
|
311
|
+
echo "Error: Failed to fix Makefile"
|
|
312
|
+
exit 1
|
|
313
|
+
fi
|
|
314
|
+
fi
|
|
315
|
+
else
|
|
316
|
+
./Configure "$PLATFORM" \
|
|
317
|
+
--prefix="$INSTALL_PREFIX" \
|
|
318
|
+
--openssldir="$INSTALL_PREFIX/ssl" \
|
|
319
|
+
no-shared \
|
|
320
|
+
no-tests \
|
|
321
|
+
no-asm \
|
|
322
|
+
"$QUIC_OPTION"
|
|
323
|
+
fi
|
|
324
|
+
|
|
325
|
+
# Verify QUIC support was enabled
|
|
326
|
+
echo ""
|
|
327
|
+
echo "Verifying QUIC support in OpenSSL configuration..."
|
|
328
|
+
if [ -f "configdata.pm" ]; then
|
|
329
|
+
if grep -q "quic" configdata.pm 2>/dev/null; then
|
|
330
|
+
echo "✓ QUIC support is enabled in OpenSSL configuration"
|
|
331
|
+
# Show the QUIC-related configuration
|
|
332
|
+
grep -i quic configdata.pm 2>/dev/null | head -3
|
|
333
|
+
else
|
|
334
|
+
echo "Warning: QUIC support may not be enabled. Checking configdata.pm..."
|
|
335
|
+
grep -i quic configdata.pm 2>/dev/null || echo "QUIC not found in configdata.pm"
|
|
336
|
+
fi
|
|
337
|
+
else
|
|
338
|
+
echo "Warning: configdata.pm not found, cannot verify QUIC support"
|
|
339
|
+
fi
|
|
340
|
+
|
|
341
|
+
# Build
|
|
342
|
+
echo ""
|
|
343
|
+
echo "Building OpenSSL..."
|
|
344
|
+
# Build only the static libraries we need (libssl.a and libcrypto.a)
|
|
345
|
+
# We'll build everything but use -k (keep going) to continue even if some targets fail
|
|
346
|
+
# This allows us to get the libraries even if providers/apps have linking issues
|
|
347
|
+
echo "Building libraries (this may show errors for providers/apps, which is OK)..."
|
|
348
|
+
make -k -j$(sysctl -n hw.ncpu) || true
|
|
349
|
+
|
|
350
|
+
# Verify that the required libraries were built
|
|
351
|
+
if [ ! -f "libcrypto.a" ] || [ ! -f "libssl.a" ]; then
|
|
352
|
+
echo "Error: Required libraries were not built"
|
|
353
|
+
echo "Attempting to build libraries directly..."
|
|
354
|
+
# Try building just the libraries
|
|
355
|
+
make libcrypto.a libssl.a -j$(sysctl -n hw.ncpu) || {
|
|
356
|
+
echo "Error: Failed to build libcrypto.a and libssl.a"
|
|
357
|
+
exit 1
|
|
358
|
+
}
|
|
359
|
+
fi
|
|
360
|
+
|
|
361
|
+
echo "Successfully built libcrypto.a and libssl.a"
|
|
362
|
+
|
|
363
|
+
# Install
|
|
364
|
+
echo ""
|
|
365
|
+
echo "Installing OpenSSL..."
|
|
366
|
+
# install_sw installs software (libraries and headers) without building
|
|
367
|
+
# Use -k to continue even if some parts fail
|
|
368
|
+
make -k install_sw || {
|
|
369
|
+
echo "Warning: install_sw had some errors, but checking if libraries were installed..."
|
|
370
|
+
# Manually copy libraries if install failed
|
|
371
|
+
if [ -f "libcrypto.a" ] && [ -f "libssl.a" ]; then
|
|
372
|
+
echo "Copying libraries manually..."
|
|
373
|
+
mkdir -p "$INSTALL_PREFIX/lib"
|
|
374
|
+
cp libcrypto.a libssl.a "$INSTALL_PREFIX/lib/" 2>/dev/null || true
|
|
375
|
+
echo "Copying headers manually..."
|
|
376
|
+
mkdir -p "$INSTALL_PREFIX/include"
|
|
377
|
+
cp -r include/openssl "$INSTALL_PREFIX/include/" 2>/dev/null || true
|
|
378
|
+
fi
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if [ "$USE_QUICTLS" = "1" ]; then
|
|
382
|
+
if ! grep -q "SSL_provide_quic_data" "$INSTALL_PREFIX/include/openssl/ssl.h" 2>/dev/null; then
|
|
383
|
+
echo "Error: Installed OpenSSL headers do not include QUIC APIs."
|
|
384
|
+
echo "Ensure OPENSSL_SOURCE_DIR points to a quictls checkout."
|
|
385
|
+
exit 1
|
|
386
|
+
fi
|
|
387
|
+
fi
|
|
388
|
+
|
|
389
|
+
echo ""
|
|
390
|
+
echo "Syncing artifacts to ios/libs and ios/include..."
|
|
391
|
+
LIBS_DIR="$SCRIPT_DIR/libs"
|
|
392
|
+
INCLUDE_DIR="$SCRIPT_DIR/include"
|
|
393
|
+
mkdir -p "$LIBS_DIR" "$INCLUDE_DIR"
|
|
394
|
+
if [ -f "$INSTALL_PREFIX/lib/libssl.a" ] && [ -f "$INSTALL_PREFIX/lib/libcrypto.a" ]; then
|
|
395
|
+
cp "$INSTALL_PREFIX/lib/libssl.a" "$INSTALL_PREFIX/lib/libcrypto.a" "$LIBS_DIR/"
|
|
396
|
+
fi
|
|
397
|
+
if [ -d "$INSTALL_PREFIX/include/openssl" ]; then
|
|
398
|
+
cp -R "$INSTALL_PREFIX/include/openssl" "$INCLUDE_DIR/"
|
|
399
|
+
fi
|
|
400
|
+
|
|
401
|
+
echo ""
|
|
402
|
+
echo "OpenSSL build complete!"
|
|
403
|
+
echo "Installation directory: $INSTALL_PREFIX"
|
|
404
|
+
echo "Libraries: $INSTALL_PREFIX/lib"
|
|
405
|
+
echo "Headers: $INSTALL_PREFIX/include"
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@annadata/capacitor-mqtt-quic",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "MQTT-over-QUIC client for Capacitor (iOS/Android). Uses ngtcp2 for QUIC; MQTT over WebSocket fallback on web.",
|
|
6
|
+
"main": "dist/plugin.cjs.js",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"types": "dist/esm/index.d.ts",
|
|
9
|
+
"unpkg": "dist/plugin.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"ios",
|
|
13
|
+
"android",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "npm run build:tsc && npm run build:rollup",
|
|
18
|
+
"build:tsc": "tsc",
|
|
19
|
+
"build:rollup": "rollup -c rollup.config.js",
|
|
20
|
+
"watch": "rollup -c rollup.config.js -w",
|
|
21
|
+
"lint": "eslint src --ext ts",
|
|
22
|
+
"prepack": "npm run clean:build-artifacts",
|
|
23
|
+
"prepublishOnly": "npm run build && npm run clean:build-artifacts",
|
|
24
|
+
"clean:build-artifacts": "node -e \"const fs=require('fs'),path=require('path');['android/build','android/install','android/.gradle','ios/build','ios/install','ios/libs','ios/include'].forEach(d=>{const p=path.join(__dirname,d);if(fs.existsSync(p)){console.log('Removing:',p);require('child_process').execSync('rm -rf '+p,{stdio:'inherit'})}})\""
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"capacitor",
|
|
28
|
+
"plugin",
|
|
29
|
+
"native",
|
|
30
|
+
"mqtt",
|
|
31
|
+
"quic",
|
|
32
|
+
"ngtcp2"
|
|
33
|
+
],
|
|
34
|
+
"capacitor": {
|
|
35
|
+
"ios": {
|
|
36
|
+
"src": "ios"
|
|
37
|
+
},
|
|
38
|
+
"android": {
|
|
39
|
+
"src": "android"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@capacitor/android": "^7.4.4",
|
|
44
|
+
"@capacitor/cli": "^7.4.3",
|
|
45
|
+
"@capacitor/core": "^7.4.3",
|
|
46
|
+
"@capacitor/ios": "^7.4.4",
|
|
47
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
48
|
+
"@types/node": "^22.10.0",
|
|
49
|
+
"eslint": "^9.20.1",
|
|
50
|
+
"rollup": "^4.28.1",
|
|
51
|
+
"typescript": "~5.6.0"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"mqtt": "^5.3.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@capacitor/core": "^7.0.0"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=18"
|
|
61
|
+
},
|
|
62
|
+
"license": "MIT"
|
|
63
|
+
}
|