@hot-updater/react-native 0.25.1 → 0.25.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.
- package/package.json +6 -6
- package/plugin/build/withHotUpdater.js +60 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/react-native",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.3",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -120,14 +120,14 @@
|
|
|
120
120
|
"react-native": "0.79.1",
|
|
121
121
|
"react-native-builder-bob": "^0.40.10",
|
|
122
122
|
"typescript": "^5.8.3",
|
|
123
|
-
"hot-updater": "0.25.
|
|
123
|
+
"hot-updater": "0.25.3"
|
|
124
124
|
},
|
|
125
125
|
"dependencies": {
|
|
126
126
|
"use-sync-external-store": "1.5.0",
|
|
127
|
-
"@hot-updater/cli-tools": "0.25.
|
|
128
|
-
"@hot-updater/
|
|
129
|
-
"@hot-updater/
|
|
130
|
-
"@hot-updater/plugin-core": "0.25.
|
|
127
|
+
"@hot-updater/cli-tools": "0.25.3",
|
|
128
|
+
"@hot-updater/core": "0.25.3",
|
|
129
|
+
"@hot-updater/js": "0.25.3",
|
|
130
|
+
"@hot-updater/plugin-core": "0.25.3"
|
|
131
131
|
},
|
|
132
132
|
"scripts": {
|
|
133
133
|
"build": "bob build && tsc -p plugin/tsconfig.build.json",
|
|
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var promises_1 = require("node:fs/promises");
|
|
42
43
|
var cli_tools_1 = require("@hot-updater/cli-tools");
|
|
43
44
|
var config_plugins_1 = require("expo/config-plugins");
|
|
44
45
|
var hot_updater_1 = require("hot-updater");
|
|
@@ -64,32 +65,81 @@ var getFingerprint = function () { return __awaiter(void 0, void 0, void 0, func
|
|
|
64
65
|
});
|
|
65
66
|
}); };
|
|
66
67
|
/**
|
|
67
|
-
* Extract public key
|
|
68
|
+
* Extract public key for embedding in native configs.
|
|
69
|
+
* Supports multiple sources with priority order:
|
|
70
|
+
* 1. HOT_UPDATER_PRIVATE_KEY environment variable
|
|
71
|
+
* 2. Private key file (extract public key)
|
|
72
|
+
* 3. Public key file (derived from privateKeyPath)
|
|
73
|
+
* 4. Skip with warning (graceful fallback)
|
|
68
74
|
*/
|
|
69
75
|
var getPublicKeyFromConfig = function (signingConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
-
var privateKeyPath, privateKeyPEM, publicKeyPEM,
|
|
76
|
+
var envPrivateKey, publicKeyPEM, privateKeyPath, publicKeyPath, privateKeyPEM, publicKeyPEM, _privateKeyError_1, publicKeyPEM, _publicKeyError_1;
|
|
71
77
|
return __generator(this, function (_a) {
|
|
72
78
|
switch (_a.label) {
|
|
73
79
|
case 0:
|
|
74
|
-
|
|
80
|
+
// If signing not enabled, no public key needed
|
|
81
|
+
if (!(signingConfig === null || signingConfig === void 0 ? void 0 : signingConfig.enabled)) {
|
|
82
|
+
return [2 /*return*/, null];
|
|
83
|
+
}
|
|
84
|
+
envPrivateKey = process.env.HOT_UPDATER_PRIVATE_KEY;
|
|
85
|
+
if (envPrivateKey) {
|
|
86
|
+
try {
|
|
87
|
+
publicKeyPEM = (0, hot_updater_1.getPublicKeyFromPrivate)(envPrivateKey);
|
|
88
|
+
console.log("[hot-updater] Using public key extracted from HOT_UPDATER_PRIVATE_KEY environment variable");
|
|
89
|
+
return [2 /*return*/, publicKeyPEM.trim()];
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.warn("[hot-updater] WARNING: Failed to extract public key from HOT_UPDATER_PRIVATE_KEY:\n" +
|
|
93
|
+
"".concat(error instanceof Error ? error.message : String(error), "\n"));
|
|
94
|
+
// Continue to try other methods
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// If no privateKeyPath configured, can't proceed with file-based methods
|
|
98
|
+
if (!signingConfig.privateKeyPath) {
|
|
99
|
+
console.warn("[hot-updater] WARNING: signing.enabled is true but no privateKeyPath configured.\n" +
|
|
100
|
+
"Public key will not be embedded. Set HOT_UPDATER_PRIVATE_KEY environment variable or configure privateKeyPath.");
|
|
75
101
|
return [2 /*return*/, null];
|
|
76
102
|
}
|
|
77
|
-
_a.label = 1;
|
|
78
|
-
case 1:
|
|
79
|
-
_a.trys.push([1, 3, , 4]);
|
|
80
103
|
privateKeyPath = path_1.default.isAbsolute(signingConfig.privateKeyPath)
|
|
81
104
|
? signingConfig.privateKeyPath
|
|
82
105
|
: path_1.default.resolve(process.cwd(), signingConfig.privateKeyPath);
|
|
106
|
+
publicKeyPath = privateKeyPath.replace(/private-key\.pem$/, "public-key.pem");
|
|
107
|
+
_a.label = 1;
|
|
108
|
+
case 1:
|
|
109
|
+
_a.trys.push([1, 3, , 8]);
|
|
83
110
|
return [4 /*yield*/, (0, hot_updater_1.loadPrivateKey)(privateKeyPath)];
|
|
84
111
|
case 2:
|
|
85
112
|
privateKeyPEM = _a.sent();
|
|
86
113
|
publicKeyPEM = (0, hot_updater_1.getPublicKeyFromPrivate)(privateKeyPEM);
|
|
114
|
+
console.log("[hot-updater] Extracted public key from ".concat(privateKeyPath));
|
|
87
115
|
return [2 /*return*/, publicKeyPEM.trim()];
|
|
88
116
|
case 3:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
117
|
+
_privateKeyError_1 = _a.sent();
|
|
118
|
+
_a.label = 4;
|
|
119
|
+
case 4:
|
|
120
|
+
_a.trys.push([4, 6, , 7]);
|
|
121
|
+
return [4 /*yield*/, (0, promises_1.readFile)(publicKeyPath, "utf-8")];
|
|
122
|
+
case 5:
|
|
123
|
+
publicKeyPEM = _a.sent();
|
|
124
|
+
console.log("[hot-updater] Using public key from ".concat(publicKeyPath));
|
|
125
|
+
return [2 /*return*/, publicKeyPEM.trim()];
|
|
126
|
+
case 6:
|
|
127
|
+
_publicKeyError_1 = _a.sent();
|
|
128
|
+
// Priority 4: All sources failed - throw error
|
|
129
|
+
throw new Error("[hot-updater] Failed to load public key for bundle signing.\n\n" +
|
|
130
|
+
"Signing is enabled (signing.enabled: true) but no public key sources found.\n\n" +
|
|
131
|
+
"For EAS builds, use EAS Secrets:\n" +
|
|
132
|
+
' eas env:create --name HOT_UPDATER_PRIVATE_KEY --value "$(cat keys/private-key.pem)"\n\n' +
|
|
133
|
+
"Or add to eas.json:\n" +
|
|
134
|
+
' "env": { "HOT_UPDATER_PRIVATE_KEY": "-----BEGIN PRIVATE KEY-----\\n..." }\n\n' +
|
|
135
|
+
"For local development:\n" +
|
|
136
|
+
" npx hot-updater keys generate\n\n" +
|
|
137
|
+
"Searched locations:\n" +
|
|
138
|
+
" - HOT_UPDATER_PRIVATE_KEY environment variable\n" +
|
|
139
|
+
" - Private key file: ".concat(privateKeyPath, "\n") +
|
|
140
|
+
" - Public key file: ".concat(publicKeyPath, "\n"));
|
|
141
|
+
case 7: return [3 /*break*/, 8];
|
|
142
|
+
case 8: return [2 /*return*/];
|
|
93
143
|
}
|
|
94
144
|
});
|
|
95
145
|
}); };
|