@renbostudios/edge-ota 0.2.6 → 0.2.7
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/dist/core/manifest.js +25 -3
- package/dist/index.js +3 -6
- package/package.json +1 -1
package/dist/core/manifest.js
CHANGED
|
@@ -12,18 +12,39 @@
|
|
|
12
12
|
* The client SDK deserialises this from the `manifest` part of the
|
|
13
13
|
* multipart response (or directly from the response body in non-multipart mode).
|
|
14
14
|
*/
|
|
15
|
+
function hexToBase64Url(hex) {
|
|
16
|
+
if (hex.length !== 64 || !/^[0-9a-fA-F]+$/.test(hex)) {
|
|
17
|
+
return hex;
|
|
18
|
+
}
|
|
19
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
20
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
21
|
+
bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
22
|
+
}
|
|
23
|
+
let binString = "";
|
|
24
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
25
|
+
binString += String.fromCharCode(bytes[i]);
|
|
26
|
+
}
|
|
27
|
+
const base64 = btoa(binString);
|
|
28
|
+
return base64
|
|
29
|
+
.replace(/\+/g, '-')
|
|
30
|
+
.replace(/\//g, '_')
|
|
31
|
+
.replace(/=+$/, '');
|
|
32
|
+
}
|
|
15
33
|
export function generateExpoManifest(params) {
|
|
16
34
|
return {
|
|
17
35
|
id: params.updateId,
|
|
18
36
|
createdAt: params.createdAt,
|
|
19
37
|
runtimeVersion: params.runtimeVersion,
|
|
20
38
|
launchAsset: {
|
|
21
|
-
hash: params.bundleHash,
|
|
39
|
+
hash: hexToBase64Url(params.bundleHash),
|
|
22
40
|
key: "bundle",
|
|
23
41
|
contentType: "application/javascript",
|
|
24
42
|
url: params.bundleUrl
|
|
25
43
|
},
|
|
26
|
-
assets: params.assets
|
|
44
|
+
assets: params.assets.map(asset => ({
|
|
45
|
+
...asset,
|
|
46
|
+
hash: hexToBase64Url(asset.hash)
|
|
47
|
+
})),
|
|
27
48
|
metadata: params.metadata ?? {},
|
|
28
49
|
extra: params.extra ?? {}
|
|
29
50
|
};
|
|
@@ -66,7 +87,8 @@ export function createExpoHeaders(signature) {
|
|
|
66
87
|
export function buildMultipartManifestBody(manifest, signature) {
|
|
67
88
|
const boundary = "expo-update-boundary-" + Math.random().toString(36).slice(2, 10);
|
|
68
89
|
const manifestJson = JSON.stringify(manifest);
|
|
69
|
-
let partHeaders = "Content-
|
|
90
|
+
let partHeaders = "Content-Disposition: inline; name=\"manifest\"\r\n";
|
|
91
|
+
partHeaders += "Content-Type: application/json\r\n";
|
|
70
92
|
if (signature) {
|
|
71
93
|
partHeaders += `expo-signature: sig="${signature}", keyid="root", alg="ecdsa-p256-sha256"\r\n`;
|
|
72
94
|
}
|
package/dist/index.js
CHANGED
|
@@ -353,12 +353,10 @@ program
|
|
|
353
353
|
console.log(" payload ", payloadObj);
|
|
354
354
|
continue;
|
|
355
355
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
await zipDirectory(distDir, zipPath);
|
|
359
|
-
const zipBuffer = fs.readFileSync(zipPath);
|
|
356
|
+
console.log(` packing bundle`);
|
|
357
|
+
const bundleBuffer = fs.readFileSync(bundlePath);
|
|
360
358
|
const form = new FormData();
|
|
361
|
-
form.append("bundle", new Blob([
|
|
359
|
+
form.append("bundle", new Blob([bundleBuffer], { type: "application/javascript" }), `bundle-${platform}.hbc`);
|
|
362
360
|
form.append("payload", payloadStr);
|
|
363
361
|
form.append("signature", signature);
|
|
364
362
|
form.append("platform", platform);
|
|
@@ -371,7 +369,6 @@ program
|
|
|
371
369
|
},
|
|
372
370
|
body: form
|
|
373
371
|
});
|
|
374
|
-
fs.unlinkSync(zipPath);
|
|
375
372
|
if (response.ok) {
|
|
376
373
|
const body = await response.json().catch(() => ({}));
|
|
377
374
|
const updateId = body.updateId || "unknown";
|
package/package.json
CHANGED