@hot-updater/react-native 0.23.0 → 0.23.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/react-native",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "description": "React Native OTA solution for self-hosted",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -111,6 +111,7 @@
111
111
  },
112
112
  "devDependencies": {
113
113
  "@react-native-community/cli": "18.0.0",
114
+ "@types/node": "^22.10.5",
114
115
  "@types/react": "19.1.3",
115
116
  "@types/use-sync-external-store": "^0.0.6",
116
117
  "del-cli": "^6.0.0",
@@ -119,14 +120,14 @@
119
120
  "react-native": "0.79.1",
120
121
  "react-native-builder-bob": "^0.40.10",
121
122
  "typescript": "^5.8.3",
122
- "hot-updater": "0.23.0"
123
+ "hot-updater": "0.23.1"
123
124
  },
124
125
  "dependencies": {
125
126
  "use-sync-external-store": "1.5.0",
126
- "@hot-updater/cli-tools": "0.23.0",
127
- "@hot-updater/plugin-core": "0.23.0",
128
- "@hot-updater/js": "0.23.0",
129
- "@hot-updater/core": "0.23.0"
127
+ "@hot-updater/cli-tools": "0.23.1",
128
+ "@hot-updater/core": "0.23.1",
129
+ "@hot-updater/js": "0.23.1",
130
+ "@hot-updater/plugin-core": "0.23.1"
130
131
  },
131
132
  "scripts": {
132
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 node_path_1 = __importDefault(require("node:path"));
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");
@@ -62,6 +63,36 @@ var getFingerprint = function () { return __awaiter(void 0, void 0, void 0, func
62
63
  }
63
64
  });
64
65
  }); };
66
+ /**
67
+ * Extract public key from private key in signing config
68
+ */
69
+ var getPublicKeyFromConfig = function (signingConfig) { return __awaiter(void 0, void 0, void 0, function () {
70
+ var privateKeyPath, privateKeyPEM, publicKeyPEM, error_1;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ if (!(signingConfig === null || signingConfig === void 0 ? void 0 : signingConfig.enabled) || !(signingConfig === null || signingConfig === void 0 ? void 0 : signingConfig.privateKeyPath)) {
75
+ return [2 /*return*/, null];
76
+ }
77
+ _a.label = 1;
78
+ case 1:
79
+ _a.trys.push([1, 3, , 4]);
80
+ privateKeyPath = node_path_1.default.isAbsolute(signingConfig.privateKeyPath)
81
+ ? signingConfig.privateKeyPath
82
+ : node_path_1.default.resolve(process.cwd(), signingConfig.privateKeyPath);
83
+ return [4 /*yield*/, (0, hot_updater_1.loadPrivateKey)(privateKeyPath)];
84
+ case 2:
85
+ privateKeyPEM = _a.sent();
86
+ publicKeyPEM = (0, hot_updater_1.getPublicKeyFromPrivate)(privateKeyPEM);
87
+ return [2 /*return*/, publicKeyPEM.trim()];
88
+ case 3:
89
+ error_1 = _a.sent();
90
+ throw new Error("[hot-updater] Failed to extract public key: ".concat(error_1 instanceof Error ? error_1.message : String(error_1), "\n") +
91
+ "Run 'npx hot-updater keys generate' to create signing keys");
92
+ case 4: return [2 /*return*/];
93
+ }
94
+ });
95
+ }); };
65
96
  /**
66
97
  * Native code modifications - should only run once
67
98
  */
@@ -91,7 +122,7 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
91
122
  var modifiedConfig = config;
92
123
  // === iOS: Add channel and fingerprint to Info.plist ===
93
124
  modifiedConfig = (0, config_plugins_1.withInfoPlist)(modifiedConfig, function (cfg) { return __awaiter(void 0, void 0, void 0, function () {
94
- var fingerprintHash, config, fingerprint;
125
+ var fingerprintHash, config, fingerprint, publicKey;
95
126
  return __generator(this, function (_a) {
96
127
  switch (_a.label) {
97
128
  case 0:
@@ -105,18 +136,23 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
105
136
  fingerprint = _a.sent();
106
137
  fingerprintHash = fingerprint.ios.hash;
107
138
  _a.label = 3;
108
- case 3:
139
+ case 3: return [4 /*yield*/, getPublicKeyFromConfig(config.signing)];
140
+ case 4:
141
+ publicKey = _a.sent();
109
142
  cfg.modResults.HOT_UPDATER_CHANNEL = channel;
110
143
  if (fingerprintHash) {
111
144
  cfg.modResults.HOT_UPDATER_FINGERPRINT_HASH = fingerprintHash;
112
145
  }
146
+ if (publicKey) {
147
+ cfg.modResults.HOT_UPDATER_PUBLIC_KEY = publicKey;
148
+ }
113
149
  return [2 /*return*/, cfg];
114
150
  }
115
151
  });
116
152
  }); });
117
153
  // === Android: Add channel and fingerprint to strings.xml ===
118
154
  modifiedConfig = (0, config_plugins_1.withStringsXml)(modifiedConfig, function (cfg) { return __awaiter(void 0, void 0, void 0, function () {
119
- var fingerprintHash, config, fingerprint;
155
+ var fingerprintHash, config, fingerprint, publicKey;
120
156
  return __generator(this, function (_a) {
121
157
  switch (_a.label) {
122
158
  case 0:
@@ -130,7 +166,9 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
130
166
  fingerprint = _a.sent();
131
167
  fingerprintHash = fingerprint.android.hash;
132
168
  _a.label = 3;
133
- case 3:
169
+ case 3: return [4 /*yield*/, getPublicKeyFromConfig(config.signing)];
170
+ case 4:
171
+ publicKey = _a.sent();
134
172
  // Ensure resources object exists
135
173
  if (!cfg.modResults.resources) {
136
174
  cfg.modResults.resources = {};
@@ -163,6 +201,19 @@ var withHotUpdaterConfigAsync = function (props) { return function (config) {
163
201
  _: fingerprintHash,
164
202
  });
165
203
  }
204
+ if (publicKey) {
205
+ // Remove existing hot_updater_public_key entry if it exists
206
+ cfg.modResults.resources.string =
207
+ cfg.modResults.resources.string.filter(function (item) { return !(item.$ && item.$.name === "hot_updater_public_key"); });
208
+ // Add the new hot_updater_public_key entry
209
+ cfg.modResults.resources.string.push({
210
+ $: {
211
+ name: "hot_updater_public_key",
212
+ moduleConfig: "true",
213
+ },
214
+ _: publicKey,
215
+ });
216
+ }
166
217
  return [2 /*return*/, cfg];
167
218
  }
168
219
  });