fix self signed certs

This commit is contained in:
alexweininger 2021-04-30 05:02:31 -07:00
parent 4886416bae
commit 0e533b5d26
7 changed files with 44 additions and 24 deletions

View file

@ -6,6 +6,10 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## [Unreleased]
## [0.0.6] - 2021-4-30
### Fixed
- Fixed a bug where the extension could not connect to Appwrite instances over localhost beacuse of self-signed certificates.
## [0.0.5] - 2021-4-30
### Fixed
- Sometimes views would not refresh after adding/removing a project [PR](https://github.com/streamlux/vscode-appwrite/pull/7)

View file

@ -58,6 +58,7 @@ After connecting to an Appwrite project, your `appwrite.projects` setting will c
"endpoint": "https://[Domain]/v1",
"projectId": "[Project ID]",
"secret": "API key with all scopes",
"selfSigned": "boolean", // set to true if you're connecting to Appwrite over localhost
"nickname": "My project"
}
```

View file

@ -2,7 +2,7 @@
"name": "vscode-appwrite",
"displayName": "Appwrite",
"description": "Manage your Appwrite resources right from VS Code!",
"version": "0.0.5",
"version": "0.0.6",
"engines": {
"vscode": "^1.55.0"
},

11
src/appwrite.d.ts vendored
View file

@ -248,8 +248,8 @@ export type FilesList = {
};
export type File = {
'$id': string;
'$permissions': Permissions;
$id: string;
$permissions: Permissions;
name: string;
dateCreated: number;
signature: string;
@ -266,14 +266,14 @@ export type Collection = {
rules: Rule[];
};
export type CreatedCollection = Partial<Collection> & Pick<Collection, 'name'>;
export type CreatedCollection = Partial<Collection> & Pick<Collection, "name">;
export type CollectionsList = {
sum: number;
collections: Collection[];
};
export type CreatedRule = Omit<Rule, '$id' | '$collection' | 'default' | 'list'>;
export type CreatedRule = Omit<Rule, "$id" | "$collection" | "default" | "list">;
export type Rule = {
$id: string;
@ -299,6 +299,7 @@ export type Client = {
setProject: (projectId: string) => Client;
// Your secret API key
setKey: (key: string) => Client;
setSelfSigned: (value: boolean) => void;
};
export type UsersClient = {
deleteUser: (id: string) => Promise<any>;
@ -358,7 +359,7 @@ export type StorageClient = {
createFile: (file: any, read: string[], write: string[]) => Promise<any>;
listFiles: () => Promise<any>;
getFile: (fileId: string) => Promise<any>;
}
};
export type SDK = {
Client: new () => Client;

View file

@ -13,10 +13,10 @@ export let healthClient: Health | undefined;
export let databaseClient: Database | undefined;
export let storageClient: Storage | undefined;
function initAppwriteClient({ endpoint, projectId, secret }: AppwriteProjectConfiguration) {
function initAppwriteClient({ endpoint, projectId, secret, selfSigned }: AppwriteProjectConfiguration) {
client = new AppwriteSDK.Client();
clientConfig = { endpoint, projectId, secret };
client.setEndpoint(endpoint).setProject(projectId).setKey(secret);
client.setEndpoint(endpoint).setProject(projectId).setKey(secret).setSelfSigned(selfSigned);
usersClient = new Users(client);
healthClient = new Health(client);

View file

@ -6,6 +6,7 @@ export type AppwriteProjectConfiguration = {
endpoint: string;
console?: string;
projectId: string;
selfSigned: boolean;
secret: string;
};

View file

@ -1,38 +1,51 @@
import { window } from "vscode";
import { AppwriteProjectConfiguration } from "../settings";
import { AppwriteProjectConfiguration, getActiveProjectConfiguration } from "../settings";
export async function addProjectWizard(): Promise<AppwriteProjectConfiguration | undefined> {
const config = await getActiveProjectConfiguration();
const endpoint = await window.showInputBox({
placeHolder: "Endpoint",
prompt: "Enter your Appwrite API endping",
ignoreFocusOut: true
value: config?.endpoint ?? "https://localhost/v1",
valueSelection: undefined,
prompt: "Enter your Appwrite API endpoint (ex: https://localhost/v1)",
ignoreFocusOut: true,
});
if (endpoint === undefined) {
return;
}
const projectId = await window.showInputBox({
placeHolder: "Project Id",
prompt: "Enter your Appwrite project id",
ignoreFocusOut: true
prompt: "Enter your Appwrite project id (ex: 5df5acd0d48c2)",
ignoreFocusOut: true,
});
if (projectId === undefined) {
return;
}
const secret = await window.showInputBox({
placeHolder: "API key secret",
prompt: "Enter your Appwrite API key secret",
ignoreFocusOut: true
prompt: "Enter your Appwrite API key secret (with all scopes)",
ignoreFocusOut: true,
});
if (secret === undefined) {
return;
}
const selfSigned = await window.showQuickPick(
[
{ label: "Yes", description: "If running Appwrite on localhost, or local IP" },
{ label: "No", description: "If connecting to a remote Appwrite instance" },
],
{ placeHolder: "Allow communication with self-signed SSL certificates? (Select 'Yes' for connecting to Appwrite on localhost)" }
);
if (selfSigned === undefined) {
return;
}
const nickname = await window.showInputBox({
prompt: "(Optional) Project name",
ignoreFocusOut: true
ignoreFocusOut: true,
});
if (endpoint && projectId && secret) {
return { endpoint, projectId, secret, nickname };
return { endpoint, projectId, secret, nickname, selfSigned: selfSigned.label === "Yes" };
}
return undefined;
}