@secure-exec/browser 0.1.1-rc.1 → 0.1.1-rc.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/dist/worker.js +9 -5
- package/package.json +2 -2
package/dist/worker.js
CHANGED
|
@@ -23,6 +23,9 @@ const encoder = new TextEncoder();
|
|
|
23
23
|
function getUtf8ByteLength(text) {
|
|
24
24
|
return encoder.encode(text).byteLength;
|
|
25
25
|
}
|
|
26
|
+
function getBase64EncodedByteLength(rawByteLength) {
|
|
27
|
+
return Math.ceil(rawByteLength / 3) * 4;
|
|
28
|
+
}
|
|
26
29
|
function assertPayloadByteLength(payloadLabel, actualBytes, maxBytes) {
|
|
27
30
|
if (actualBytes <= maxBytes)
|
|
28
31
|
return;
|
|
@@ -212,12 +215,13 @@ async function initRuntime(payload) {
|
|
|
212
215
|
});
|
|
213
216
|
const readFileBinaryRef = makeApplySyncPromise(async (path) => {
|
|
214
217
|
const data = await fsOps.readFile(path);
|
|
215
|
-
assertPayloadByteLength(`fs.readFileBinary ${path}`, data.byteLength, base64TransferLimitBytes);
|
|
216
|
-
return
|
|
218
|
+
assertPayloadByteLength(`fs.readFileBinary ${path}`, getBase64EncodedByteLength(data.byteLength), base64TransferLimitBytes);
|
|
219
|
+
return btoa(String.fromCharCode(...data));
|
|
217
220
|
});
|
|
218
|
-
const writeFileBinaryRef = makeApplySyncPromise(async (path,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
+
const writeFileBinaryRef = makeApplySyncPromise(async (path, base64) => {
|
|
222
|
+
assertTextPayloadSize(`fs.writeFileBinary ${path}`, base64, base64TransferLimitBytes);
|
|
223
|
+
const bytes = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
|
224
|
+
return fsOps.writeFile(path, bytes);
|
|
221
225
|
});
|
|
222
226
|
const readDirRef = makeApplySyncPromise(async (path) => {
|
|
223
227
|
const entries = await fsOps.readDirWithTypes(path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secure-exec/browser",
|
|
3
|
-
"version": "0.1.1-rc.
|
|
3
|
+
"version": "0.1.1-rc.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"sucrase": "^3.35.0",
|
|
46
|
-
"@secure-exec/core": "0.1.1-rc.
|
|
46
|
+
"@secure-exec/core": "0.1.1-rc.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^22.10.2",
|