无法使用 web-ext 签署 Firefox WebExtensions

Failed to sign Firefox WebExtensions with web-ext

我正在将 Chrome 扩展移植到 Firefox WebExtensions。 Chrome.

一切正常

我在 Firefox 上试过这些:

1. 修改我的扩展使其与 Firefox WebExtensions 兼容,然后通过 Load Temporary Add-on 将其加载到 Firefox 中,一切正常

2. 通过 npm install -g web-ext 安装 web-ext 模块。然后我 运行 web-ext run, Firefox 成功启动并安装了我的扩展

3. 运行 web-ext build,然后在 Firefox 上安装打包的扩展,一切正常

D:\temp>web-ext build
Building web extension from D:\temp
Your web extension is ready: D:\temp\web-ext-artifacts\my_extension-1.0.zip

4. 然后我 运行 web-ext sign --api-key=MyApiKey --api-secret=MyApiSecret, 它失败了错误:

D:\temp>web-ext sign --api-key=MyApiKey --api-secret=MyApiSecret
Building web extension from D:\temp

sign: Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\abc\AppData\Local\Temp\tmp-web-ext-628J9dJMBi0bWRX'
    at Error (native)
    at Object.fs.rmdirSync (fs.js:806:18)
    at _rmdirRecursiveSync (C:\Users\abc\AppData\Roaming\npm\node_modules\web-ext\node_modules\tmp\lib\tmp.js:284:10)
    at TempDir._cleanupCallback [as _removeTempDir] (C:\Users\abc\AppData\Roaming\npm\node_modules\web-ext\node_modules\tmp\lib\tmp.js:408:5)
    at TempDir.remove (C:\Users\abc\AppData\Roaming\npm\node_modules\web-ext\dist\webpack:\src\util\temp-dir.js:9:4939)
    at C:\Users\abc\AppData\Roaming\npm\node_modules\web-ext\dist\webpack:\src\util\temp-dir.js:9:3976
    at process._tickCallback (node.js:401:9)

sign: Error code: ENOTEMPTY

我进入了C:\Users\abc\AppData\Local\Temp\tmp-web-ext-628J9dJMBi0bWRX,实际上它是空的。有人知道为什么会这样吗?

我的 api 密钥和 api 密钥用于旧的 Firefox JSCTypes 附加组件。这就是我不断收到此错误的原因吗?

这里是document of web-ext.

这个问题的解决方法

经过进一步挖掘,我发现导致此错误的原因是我在我的网络上使用了代理。我尝试通过 运行ning 命令 set HTTP_PROXY=MyProxyServerAddress 设置代理,然后错误消失。

其他问题解决

然后又尝试运行web-ext sign,又发现错误:

Server response: You do not own this addon. (status: 403)
sign: WebExtError: The WebExtension could not be signed

我将我的add-on(由web-ext build生成的打包文件)上传到Mozilla Add-on Site,然后再次运行 web-ext sign。这次add-on签名成功

Note: You need to change your add-on's version each time running web-ext sign. Otherwise it will fail with error: Server response: Version already exists. (status: 409)

干杯!