-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scaffolding for window.ipfs.enable
This simply changes the flow and API for getting IPFS proxy instance, does not implement UX nor decrease the size of injected content script.
- Loading branch information
Showing
2 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
'use strict' | ||
|
||
const { createProxyClient } = require('ipfs-postmsg-proxy') | ||
const _Buffer = Buffer | ||
|
||
// TODO: this should not be injected by default into every page, | ||
// instead should be lazy-loaded when .enable() method is called for the first time | ||
const { createProxyClient } = require('ipfs-postmsg-proxy') | ||
|
||
function windowIpfs2 () { | ||
return Object.freeze({ | ||
enable: async (args) => { | ||
// TODO: pass args to ipfs-postmsg-proxy constructor | ||
// to trigger user prompt if list of requested capabilities is not empty | ||
const proxyClient = createProxyClient() | ||
console.log('Called window.ipfs.enable', args) | ||
return proxyClient | ||
} | ||
}) | ||
} | ||
|
||
// TODO: we should remove Buffer and add support for Uint8Array/ArrayBuffer natively | ||
window.Buffer = window.Buffer || _Buffer | ||
window.ipfs = window.ipfs || createProxyClient() | ||
window.ipfs = window.ipfs || windowIpfs2() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters