Does Visual Studio Code support Environment Variables for the ChatGPT extension? - security

I would like to open the editor and be able to use the ChatGPT extension without needing to log in via browser or store the OpenAI api key in a workspace file. Ideally, I would be able to use the environment variable stored in .zshenv.
I know that Visual Studio Code allows for some environment variables to be set but not all via ${ENV_EXAMPLE} but this has not worked for me in the settings.json file:
{
"chatgpt.response.showNotification": true,
"chatgpt.gpt3.maxTokens": 2048,
"chatgpt.gpt3.apiKey": "${OPEN_AI_API_KEY}",
}

Yes you can store API keys for the ChatGPT extension.
Per the ChatGPT extension documentation here are the steps:
Click Login in your extension.
Once asked provide your API key to the extension.
Ref: marketplace.visualstudio.com/items?itemName=gencay.vscode-chatgpt

Related

how can parametrized URL values using a registry key in FireFox and edge like chrome

I want to install an extension via registry and also set install_parameter in it and read through manifest file as described in chrome documentation. Can anyone know how to do same thing in firefox and edge?
Based on your needs, you can distribute Edge extensions through the registry. But only for extensions that have been published in Edge Adds-on.
To distribute your extension using the Windows registry:
Find or create the following key in the registry:
32-bit Windows: HKEY_LOCAL_MACHINE\Software\Microsoft\Edge\Extensions.
64-bit Windows: HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Edge\Extensions.
Create a new key, or folder, under Extensions with the same name as the ID of your extension. Like this:
In the Extensions key, create the update_url property, and set the value to https://edge.microsoft.com/extensionwebstorebase/v1/crx.
For more details, please refer to this doc: Alternative ways to distribute extensions-Use the Windows registry.

VS Code : Differences between options under File menu

In Visual Studio Code, as you might know, there are many options under File:
Open file
Open folder
Open workspace
Add folder to workspace
etc.
Could anyone please tell me the differences and benefits to choosing any of these over others? VS Code clearly sits gently on top of the File system, and is not heavily configured (say like, VS 2017, NetBeans, Eclipse, etc.) - it is of course closer to its sibling, Atom.
But I'm not entirely sure the advantages or recommendations related to, for example, Add Folder to Workspace vs just Open Folder, saving the workspace (or not), etc.
Any help would be appreciated.
Thanks a ton!
-J
1. Firstly open file is just the option to edit or open a file.
2. Secondly opening a folder is the option to import your project directory in the editor.
3. Then comes the workspace option which is quite similar to the open folder option with the difference that every workspace has its custom working settings.
VS Code provides two different scopes for settings:
User Settings - Settings that apply globally to any instance of VS Code you open.
Workspace Settings - Settings stored inside your workspace and only apply when the workspace is opened.
Workspace settings override user settings.
For more details you can refer to VS code settings (docs)

Programmatically specify Private Extension Gallery in Visual Studio 2012

One of the newest features in VS 2012 is the ability to create Private Extension Galleries, which allow you to build your own extension repositories and not have to publish them to the world (internal company tools, etc.). I've successfully created one as described in the MSDN blog I referenced, but I'm wondering if anyone knows of a way to programmatically set the details of the gallery - the name and URL, and then "Apply" it - so that each person who wants to access it doesn't have to manually enter in the info.
I looked in the registry to see if I could install a key, and I think it's possible but not exactly trivial. Anyone have any insight?
The registry keys to set are documented under http://msdn.microsoft.com/en-us/library/hh266735.aspx. $RootPath$ would indicate a path like HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0 on the user's machine. Minimally, you could write a little tool that just sets those registry keys.
If you want to be really fancy, you could take that .pkgdef example and stick that inside a .vsix. Then, installing that extension would register the private extension gallery. A bit meta, but that could prove useful.
I'm going to mark Jason's answer as accepted, because he pointed me in the direction of how to properly do it which was my ultimate question. However, I do want to add another solution which does work if this is all you need:
If you manually add your private gallery details to Visual Studio, your registry key will be created for you. Go to:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\ExtensionManager\Repositories\[Dynamic Guid]
and export that key to a normal .reg file. You can then either create a simple batch script to install the key for you on other computers, or just have people use the .reg file to install it themselves.

Chrome external extension not shown in extension list

I'm trying to install a Chrome external extension using a visual studio setup project and following the instructions listed in http://code.google.com/chrome/extensions/external_extensions.html#registry, I did the following to add an external extension to Google chrome:
Packed the extension and moved the resulting .crx file to a folder C:\Hafez\Grid_Bootstrapper
I've added a registry sub key named fnfnbeppfinmnjnjhedifcfllpcfgeea under the following path: HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\Extensions\ with the next two values:
1.path with a value of "C:\Hafez\Grid_Bootstrapper\fnfnbeppfinmnjnjhedifcfllpcfgeea.crx" and
2.version with a value of "1.0.0.1"
which are, by the way, the exact values but unfortunately when I start Chrome the extension is not listed.
BTW, I'm doing this in a installer custom action and it writes the values exactly the way I want them.
I can't find what is wrong because I do the exact steps listed in the link.
May you discover what have I done wrong?

Making a Windows Installer communicate with a Chrome extension without NPAPI

I have a windows application which installs a Chrome extension via the windows registry. I wish for this application to generate some one-time information for Chrome to read based on information typed in by the user during the installation process.
Assuming I am not using NPAPI in the Chrome extension, is there anywhere the installer can place information such that the extension will see it?
Edit: I also wish to launching chrome at the end of the installation.
Another way you can pass information to an installed extension from outside of Chrome is to have a page with your extension that you then open Chrome too and pass the info in the hash...such as....
chrome.exe "chrome-extension://emcggffhhapbbkcodabdliakappfibcf/showHash.html#info"
Problem with this method is your installing the extension using the simple registry method (Im guessing) and not using the Policy method. With the Policy method you can force an install and it will happen even if Chrome is allready open (where as according to the docs the simple method happens the next time Chrome is opened). Downside to this is you will have to make an uninstaller yourself as you cant uninstall an extension from Chrome that is installed with this method. Im also not sure how quick/often it will be before the extension is installed (couldnt find it in the docs and too lazy to try it ;)) and youd need to make your installer wait a bit for it to be installed....
http://www.chromium.org/developers/how-tos/adding-new-policies
http://dev.chromium.org/administrators/policy-list-3#ExtensionInstallForcelist
http://dev.chromium.org/administrators/policy-templates (says where in the registry to add them)
Another possible method could be to pack the extension at install time and add a file with the info that the extension could read. Problem with this method is that the extensions ID would change (might not be a problem for you?) or youll have to include the PEM in your installer which you probably dont want to do....
chrome.exe --pack-extension="C:\simple-example" --no-message-box
Many people wish there were an event firing on extension installing.
There's a workaround, not elegant way to send info to the browser from outside: launch chrome asking to open an url.
I use it with a local html file. My application execute a command line like:
"pathToChrome\Chrome.exe" "file://pathToHtmlFile/myFile.html?param1=value1&param2=value2"
The info I pass are the page's parameters.
The catch is that this page is read by the extensions in one of many ways:
You can write a content script this page will fire
You can put some javascript on this page to write down the parameters as cookies, for the extension to read in the future (without calling the extension at this time)
It hasn't to be a local page. If your page is on a server, it can save the parameters in the server, ir it worthy.
It hasn't to be even your page. You can call any page on Internet, but beeing sure it will fire your content script extension, and it will read your "customized" parameters.
Instead of communicating through the windows registry, you can create a WebSQL from the installer and from the extension read the data from there.
You will need to a bit of research about how to this, but this is possible. the steps should be:
The installer will create the database and register to chrome (maybe with the Databases.db)
The extension will use openDatabase to create a connection to the database
The extension will do a transaction and read the needed file.
Another option is to add file to the crx for example "installer_info.json" and do an AJAX request from the extension to the "installer_info.json" file.
There is no formal way for doing this things, little research and you will have a way.

Resources