How do you create UUIDs to store values in Forge App?


I have tried to use uuid npm package but it failed with following error:

There was an error invoking the function - crypto.getRandomValues() not supported. See

Error: crypto.getRandomValues() not supported.

I think sandboxed environment for Forge does not support crypto package.
I want to do something like that:

    const uuid = uuidv4();
    await storage.set(`TABLE_NAME-${issueId}-${uuid}`, formData);

My understanding is Forge provides an eventually consistent distributed Storage API and UUIDs are used as keys in these kind of environments. If it is not supported, how am I supposed to store a value? Am I missing something here?



Hello @denizoguz, I ran into a similar problem when I tried to get UUID. Is this “crypto” from Node package?

If you are trying to get some unique value you can use some one-way cryptographic hash function like SHA1 … etc.

Try importing this package “import crypto from 'crypto';” - which is in Node already. I recently used it to encrypt my data (AES).



Hi @OnucheIdoko1 ,
Thanks for the answer. crypto is a build in package for NodeJS. Forge is using a sandboxed environment and not all NodeJS packages are guaranteed to work. I have used “uuid-random” npm package instead of “uuid” package to generate UUIDs.