This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
Allow options.init to at least overwrite the identity for an existing browser repo #2353
Labels
exp/expert
Having worked on the specific codebase is important
kind/feature
P3
Low: Not priority right now
status/ready
Ready to be worked
We should be able to switch the identity of a browser node.
If not with the existing
options.init.privateKey
option (and perhaps an additional flag), then by some other standard means.Type: Enhancement
Severity: non-critical but an important use-case
Description:
For my browser IPFS app I need users to be able to supply their own identities and log in as different identities when they need to.
It is already possible to provide an identity for the creation of a browser IPFS instance with the
options.init.privateKey
config. But it is only ever used once, before the creation of a repository, and then never again as long as a repository of the same name exists in the browser's IndexedDB. Subsequent initializations simply ignore all the configs underoptions.init
and read the identity stored.(Aside: And the identity is stored as plain text in the config it seems! Even if I use the
options.pass
option, thereby initializing the keychain, it merely copies the identity into the encrypted keychain asself
while leaving the plain text identity in config! The most important secret is always stored in plain text in the browser, even if the node was initialized from scratch with a passphrase, for reasons I cannot appreciate: #1138)This means I can never replace an IPFS instance within my application without either deleting the IndexedDB stores manually, which very opaque and hacky, OR by recreating a repository with a different name from scratch, probably identified with some sort of public aspect of the identity the user is providing, but also duplicating all of the blocks I know will be needed by the app even as this different user.
I believe this is a shortcoming of the API. It is bad enough that on the browser repositories are isolated by domain (purely from the storage space perspective, I am not arguing the privacy concerns are immaterial if we somehow managed to share a repository without needing extensions, as long as the keys are also stored in these repositories.) To then need to do so for every identity the user wants to create for my own app under my own domain seems especially undesirable.
There should be a way to force at least a new identity on an existing repository (under our control) without losing other configuration and blocks. It seems that there used to be an option to force the initialization process, but it was removed according to issue #515. Right now, I have to resort to manually deleting
<reponame>
and<reponame>/keys
. But even if that's to be the right solution, it should be part of the API.Steps to reproduce the shortcoming:
const node = await IPFS.create()
await node.id()
const node = await IPFS.create({ init: { privateKey: key64 } })
await node.id()
It should be different due to being provided a private key. But it remains the same as the first generated key.
The text was updated successfully, but these errors were encountered: