我正在开发Angular6 + solid-app(codebase)。该应用程序本身取决于:
"crypto-js": "^3.1.9-1",
"rdflib": "^0.19.0",
"solid-auth-client": "^2.2.6",
"stream": "0.0.2",
"webcrypto": "^0.1.1",
"zone.js": "^0.8.26"
我想要做的是使用rdflib.UpdateManager.update()
删除RDF资源:
$rdf.UpdateManager(this.store).update(toBeDeleted, [], (uri, ok, message, response) => {
if (ok) {
console.log('DELETED')
} else {
console.warn(message)
}
})
您可以找到更多有关UpdateManager
here的JSDoc以及rdflib.js here的介绍。
现在,使用Firefox 63.0b12 (64-bit)
,我不断收到以下错误,我认为这可能与访问 WebCrypto API should be restricted to secure origins(说https://
页)。使用Opera时会引发相同的错误。
Unhandled Promise rejection: Cannot find module "../algorithms/RSASSA-PKCS1-v1_5". ; Zone: <root> ; Task: Promise.then ; Value: Error: Cannot find module "../algorithms/RSASSA-PKCS1-v1_5".
at webpackEmptyContext (algorithms sync:2)
at SupportedAlgorithms.normalize (SupportedAlgorithms.js:84)
at SubtleCrypto.importKey (SubtleCrypto.js:279)
at RSASSA_PKCS1_v1_5.importKey (RSASSA-PKCS1-v1_5.js:124)
at Function.importKey (JWA.js:113)
at Function.importKey (JWK.js:46)
at Function.issueFor (PoPToken.js:57)
at webid-oidc.js:183
at fetchWithCredentials (authn-fetch.js:63)
at authn-fetch.js:41 Error: Cannot find module "../algorithms/RSASSA-PKCS1-v1_5".
at webpackEmptyContext (http://localhost:4200/main.js:11:10)
at SupportedAlgorithms.normalize (http://localhost:4200/vendor.js:132732:107)
at SubtleCrypto.importKey (http://localhost:4200/vendor.js:132336:51)
at RSASSA_PKCS1_v1_5.importKey (http://localhost:4200/vendor.js:124747:28)
at Function.importKey (http://localhost:4200/vendor.js:125342:34)
at Function.importKey (http://localhost:4200/vendor.js:125411:18)
at Function.issueFor (http://localhost:4200/vendor.js:127189:18)
at http://localhost:4200/vendor.js:185374:44
at fetchWithCredentials (http://localhost:4200/vendor.js:184423:49)
at http://localhost:4200/vendor.js:184401:16
我是否缺少npm依赖项?此问题的根本原因是什么?
答案 0 :(得分:1)
调用此代码时出现相同的错误:
import auth from 'solid-auth-client';
// for example in a button click handling, this gives me the error:
auth.logout();
使用纱线,webpack 4和babel 7
依赖项:
"@material-ui/core": "^3.2.0",
"rdflib": "^0.19.0",
"react": "^16.5.2",
"react-dom": "^16.5.2"
“ @ trust / webcrypto”模块(版本0.9.2)处理其他模块的动态加载的方式会在我的构建中触发警告:
WARNING in ./node_modules/@trust/webcrypto/src/algorithms/SupportedAlgorithms.js 84:22-60
Critical dependency: the request of a dependency is an expression
@ ./node_modules/@trust/webcrypto/src/algorithms/index.js
@ ./node_modules/@trust/webcrypto/src/SubtleCrypto.js
@ ./node_modules/@trust/webcrypto/src/Crypto.js
@ ./node_modules/@trust/webcrypto/src/index.js
@ ./node_modules/@solid/oidc-rp/src/AuthenticationRequest.js
@ ./node_modules/@solid/oidc-rp/src/RelyingParty.js
@ ./node_modules/@solid/oidc-rp/src/index.js
@ ./node_modules/solid-auth-client/lib/webid-oidc.js
@ ./node_modules/solid-auth-client/lib/solid-auth-client.js
@ ./node_modules/solid-auth-client/lib/index.js
@ ./src/main/index.js
@ multi (webpack)-dev-server/client?http://localhost:3000 @babel/polyfill ./src/main/index.js
声音有些相关...
答案 1 :(得分:1)
Dmitri Zagidulin在这里回答了我的问题(以及我认为是解决方法的请求):https://github.com/anvilresearch/webcrypto/pull/80#issuecomment-431115569
@trust/webcrypto
模块仅用作后端上的NodeJS模块。要将其从webpack捆绑中排除,请使用以下外部模块(由浏览器提供)替换它:
externals: {
'@trust/webcrypto': 'crypto',
'text-encoding': 'TextEncoder',
}
PS:他还建议外部化 text-encoding 模块,该模块也是浏览器可用的模块。