remove js-ipfs in electron app, eslint to dev deps (#123)

- add ipfs:// protocol handlers, not enabled for now
- use browser-side auto-js-ipfs for loading from ipfs even in electron app
- deps: bump wabac.js to 2.13.0
- update CHANGES

Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
This commit is contained in:
RangerMauve
2022-10-04 15:54:43 -07:00
committed by GitHub
co-authored by Ilya Kreymer
parent 43122425e5
commit f1df02ea3c
10 changed files with 562 additions and 2801 deletions
+44
View File
@@ -0,0 +1,44 @@
import { protocol, session } from "electron";
import fetchToHandler from "fetch-to-electron-protocol-handler";
import makeIPFSFetch from "js-ipfs-fetch";
import * as IPFS from "ipfs-core";
export const PROTOCOL_PERMISSIONS = {
standard: true,
secure: true,
allowServiceWorkers: true,
supportFetchAPI: true,
bypassCSP: false,
corsEnabled: true,
stream: true
};
export function registerPrivileges(privileges = PROTOCOL_PERMISSIONS) {
protocol.registerSchemesAsPrivileged([
{scheme: "ipfs", privileges},
{scheme: "ipns", privileges},
{scheme: "ipld", privileges}
]);
}
export function registerHandler(ipfsRepoPath) {
const handler = createHandler(ipfsRepoPath);
protocol.registerStreamProtocol("ipfs", handler);
protocol.registerStreamProtocol("ipns", handler);
protocol.registerStreamProtocol("ipld", handler);
}
export function createHandler (ipfsRepoPath) {
const {handler} = fetchToHandler(async () => {
const ipfs = await IPFS.create({
repo: ipfsRepoPath
});
const fetch = await makeIPFSFetch({ ipfs });
return fetch;
}, session.defaultSession);
return handler;
}