我正在尝试使用公钥加密(tweetnacl)验证文档。 我知道you can add commonjs modules用于验证功能但无法实现。
{
"_id": "_design/validate_update",
"language": "javascript",
"validate_doc_update":
"function(newDoc, oldDoc, userCtx){
verify=require('lib/validation').sign.detached.verify;
if(verify(newDoc.message, new.Doc.signature, oldDoc.publicKey)){
return true;
}
}",
"lib": {
"validation": "exports.nacl=(function(nacl){..... })"
}
}
当我这样做时,我收到错误:
Module require('lib/validation') raised error (new TypeError("func.apply is not a function", "/usr/local/share/couchdb/server/main.js", 1181))
我想我必须以某种方式更改tweetnacl代码以解释为commonjs模块?