w3c-ccg / security-vocab

The Linked Data Security Vocabulary

Home Page:https://w3id.org/security

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ENOENT: no such file or directory, open '/var/task/node_modules/security-context/contexts/security-v1.jsonld

OR13 opened this issue · comments

2021-10-31T17:37:11.535Z	5180479b-60c6-4715-9a89-4ae3d59f27ad	ERROR	/var/task/node_modules/security-context/js/index.js:1
Error: ENOENT: no such file or directory, open '/var/task/node_modules/security-context/contexts/security-v1.jsonld'
    at Object.openSync (fs.js:498:3)
    at Proxy.readFileSync (fs.js:394:35)
    at _read (/var/task/node_modules/security-context/js/index.js:12:8)
    at Object.<anonymous> (/var/task/node_modules/security-context/js/index.js:19:3)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/var/task/node_modules/security-context/contexts/security-v1.jsonld'
}
RequestId: 5180479b-60c6-4715-9a89-4ae3d59f27ad Error: Runtime exited with error: exit status 1
Runtime.ExitError

Probably caused by the use of fs and path here: https://github.com/w3c-ccg/security-vocab/blob/main/js/index.js

It would be wiser to use require, or import instead of fs.

This prevents these libraries from working in environments where the fs / modules may not be accessible, such as cloud functions on vercel / next.js or React Native....

In turn this error causes failures in any other dependencies that rely of security context.

My hope was to use digital bazaar libraries here: https://github.com/transmute-industries/api.did.actor/tree/main/vc-api/facade

So we could test did key and vc based interop with a toggle for selecting the vendor, but I cannot get the db libraries to run on vercel...

here is our solution to the same issue:

https://github.com/transmute-industries/verifiable-data/blob/main/packages/security-context/index.js#L4

we use require, and .json instead of .jsonld.

It would be wiser to use require, or import instead of fs.

+1, this is why I had to create a fork of this lib here: https://github.com/digitalbazaar/security-context