Configure cypto
This commit is contained in:
parent
09d8951fc3
commit
915482a915
|
@ -5,6 +5,7 @@ import { context } from "@budibase/backend-core"
|
|||
import tracer from "dd-trace"
|
||||
import fs from "fs"
|
||||
import url from "url"
|
||||
import crypto from "crypto"
|
||||
|
||||
export function init() {
|
||||
const helpersSource = fs.readFileSync(
|
||||
|
@ -45,7 +46,25 @@ export function init() {
|
|||
const helpersModule = jsIsolate.compileModuleSync(
|
||||
`${injectedRequire};${helpersSource}`
|
||||
)
|
||||
|
||||
const cryptoModule = jsIsolate.compileModuleSync(`export default {
|
||||
randomUUID: cryptoRandomUUIDCb,
|
||||
}`)
|
||||
cryptoModule.instantiateSync(jsContext, specifier => {
|
||||
throw new Error(`No imports allowed. Required: ${specifier}`)
|
||||
})
|
||||
|
||||
global.setSync(
|
||||
"cryptoRandomUUIDCb",
|
||||
new ivm.Callback((...params: Parameters<typeof crypto.randomUUID>) => {
|
||||
return crypto.randomUUID(...params)
|
||||
})
|
||||
)
|
||||
|
||||
helpersModule.instantiateSync(jsContext, specifier => {
|
||||
if (specifier === "crypto") {
|
||||
return cryptoModule
|
||||
}
|
||||
throw new Error(`No imports allowed. Required: ${specifier}`)
|
||||
})
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const externalCollections = {
|
|||
comparison: require("@budibase/handlebars-helpers/lib/comparison"),
|
||||
object: require("@budibase/handlebars-helpers/lib/object"),
|
||||
regex: require("@budibase/handlebars-helpers/lib/regex"),
|
||||
// uuid: require("@budibase/handlebars-helpers/lib/uuid"),
|
||||
uuid: require("@budibase/handlebars-helpers/lib/uuid"),
|
||||
}
|
||||
|
||||
const addedHelpers = {
|
||||
|
|
Loading…
Reference in New Issue