dcp-client 4.4.6 → 4.4.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/dcp-support.py +36 -0
- package/dist/dcp-client-bundle.js +1 -1
- package/dist/dcp-client-bundle.js.map +1 -1
- package/fs-basic.py +46 -0
- package/index.py +105 -0
- package/libexec/sandbox/access-lists.js +1 -1
- package/package.json +7 -4
package/dcp-support.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @file dcp-support.py
|
|
2
|
+
# Python polyfills for OS-level functionality needed by dcp-client
|
|
3
|
+
#
|
|
4
|
+
# @author Will Pringle, will@distributive.network
|
|
5
|
+
# @author Wes Garland, wes@distributive.network
|
|
6
|
+
# @author Hamada Gasmallah, hamada@distributive.network
|
|
7
|
+
# @date Feb 2024
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import pythonmonkey as pm
|
|
11
|
+
|
|
12
|
+
# Supply globalThis.crypto.getRandomValues
|
|
13
|
+
def getRandomValues(typedArr):
|
|
14
|
+
setRandomVal = pm.eval("""'use strict';
|
|
15
|
+
function setRandomVal(typedArr, bytes)
|
|
16
|
+
{
|
|
17
|
+
const arrBytes = typedArr.BYTES_PER_ELEMENT;
|
|
18
|
+
for (let i=0; i < typedArr.length; i++)
|
|
19
|
+
{
|
|
20
|
+
const index = i * arrBytes;
|
|
21
|
+
for (let byte=0; byte < arrBytes; byte++)
|
|
22
|
+
{
|
|
23
|
+
if (typedArr.constructor.name.includes('Big'))
|
|
24
|
+
typedArr[i] += BigInt(bytes[index + byte]) << BigInt(arrBytes - byte - 1) * 8n
|
|
25
|
+
else
|
|
26
|
+
typedArr[i] += bytes[index + byte] << (arrBytes - byte - 1) * 8
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
setRandomVal""")
|
|
31
|
+
randomBytes = memoryview(bytearray(os.urandom(typedArr.nbytes)))
|
|
32
|
+
setRandomVal(typedArr, randomBytes)
|
|
33
|
+
return typedArr
|
|
34
|
+
|
|
35
|
+
exports['getRandomValues'] = getRandomValues
|
|
36
|
+
|