2

我正在开发一个 Angular6+实体应用程序代码库)。应用程序本身取决于:

"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"

我正在尝试使用以下方法删除 RDF 资源rdflib.UpdateManager.update()

$rdf.UpdateManager(this.store).update(toBeDeleted, [], (uri, ok, message, response) => {
  if (ok) {
    console.log('DELETED')
  } else {
    console.warn(message)
  }
})

UpdateManager 你可以在这里找到更多关于 JSDoc和 rdflib.js 的介绍

现在,使用 Firefox 63.0b12 (64-bit),我不断收到以下错误,我认为这可能与访问WebCrypto API 应限制在安全来源(即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 依赖项?这个问题的根本原因是什么?

4

2 回答 2

1

调用此代码时出现相同的错误:

import auth from 'solid-auth-client';

// for example in a button click handling, this gives me the error:
auth.logout();

使用 yarn、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

听起来有点相关...

于 2018-10-14T19:34:44.287 回答
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模块,这也是一个浏览器可用的模块。

于 2018-10-18T18:53:42.703 回答