op-vscode
op-vscode copied to clipboard
HIghlight key and value for "1Password: Save to 1Password"
Summary
let say I have an .env variable like
PUBLIC_APP_URL=127.0.0.1:5000
I highlight the 127.0.0.1:5000
part and invoke 1Password: Save in 1Password
. What do you want to call it?
defaults to save in url
, and I think thats sounds good. This process creates a standard 1Password item and does not replace the hardcoded selection. I see that not available through 1Password: Get from 1Password
. Thereafter, I figure when asked for the What do you want to call it?
I put in PUBLIC_APP_URL.
Proposed solution
When 1Password: Save to 1Password
is invoked, regex the selection to include the key if highlighted and load that for the default in What do you want to call it?
Also if the key is not highlighted change the default from url
to something like UNDEFINED_KEY
in order to prevent user confusion as I had as above. This change (if key highlighted) would also require the selection be changed before replacing the hardcoded secret with the 1Password replacement.
Is there a workaround to accomplish this today?
Already know url
won't work (not in docs?) and manually type a new name.
Hi @cycle4passion, thanks for filing this ticket. Apologies it's taken a while to review it. I am trying to reproduce this issue and am having a different result:
- With the line
PUBLIC_APP_URL=127.0.0.1:5000
and the selection127.0.0.1:5000
- Running the
1Password: Save in 1Password
command results in no suggestion for "What do you want to call this item?" and "value" for "What do you want this field to be called?" - Upon completing these fields the selection is replaced with a secret reference
If you're able to, can you try to reproduce your issue and outline the steps you took? Thank you!
I agree, its been awhile. As I read what I wrote previously, I can't even understand it. I will try again. First off the the steps you propose do work.
Lets start with a different example first
// .env
AAA_API_KEY=1234
I highlight 1234
and invoke 'Save in 1Password'.
I am asked What do you want to call this item?
This is ambiguous, at that point (having not created one before), I am unsure if you mean the name of the 1Password entry, or the name of the key within that item. Maybe the text would be clearer as 'What do you want to call this
1Password
item?'. It does become clearer when posed the second question 'What do you want this field to be called?'. Nevertheless the remainder of the steps work correctly.
Feature request: The name for 1Password field is available on the same line as the highlighted text to be stored in 1Password. The extension could read the entire line which has selected text within it and regex the 1PW field name (everything before =). This could then be the default that in the
What do you want this field to be called?
prompt. There may be use cases I am not considering beyond .env files??
Now second example. Assume this is the first time I have used this extension.
// .env
POCKETBASE_URL=http://127.0.0.1:8090
I highlight http://127.0.0.1:8090
and invoke 'Save in 1Password'.
What do you want to call this item?
- I enter "POCKETBASE"
What do you want this field to be called?
- the default says url
.
I think, well I just named it in the last step and, yes, its a URL so I guess that's good enough and hit enter. I receive an error: Command '1Password: Save in 1Password' resulted in an error - Cannot read propertied of undefined (reading 'reference'). I click OK, and popup at bottom says
Item titled "POCKETBASE" save successfully to your vault
. I check and it did save it.
Unlike in my first example where you can accept
value
as the default for the field name, you cannot accepturl
as default. I looks like trying to store in url is handled differently than 1PW custom fields. I would pose the the default should not be url to prevent this error. I understand without thehttp://
this is a non-issue, but how am I to know that? It definitely seems weird to highlight only part of the valuehttp://127.0.0.1:8090
to store in 1Password.