Skip to content

Commit 00383ca

Browse files
committed
continue with fixes
1 parent 3ef1f83 commit 00383ca

File tree

4 files changed

+84
-107
lines changed

4 files changed

+84
-107
lines changed

appwrite.config.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"projectId": "6839a26e003262977966",
3+
"endpoint": "https://fra.cloud.appwrite.io/v1",
4+
"projectName": "Testing Project",
5+
"settings": {
6+
"services": {
7+
"account": true,
8+
"avatars": true,
9+
"databases": true,
10+
"locale": true,
11+
"health": true,
12+
"storage": true,
13+
"teams": true,
14+
"users": true,
15+
"sites": true,
16+
"functions": true,
17+
"graphql": true,
18+
"messaging": true
19+
},
20+
"auth": {
21+
"methods": {
22+
"jwt": true,
23+
"phone": true,
24+
"invites": true,
25+
"anonymous": true,
26+
"email-otp": true,
27+
"magic-url": true,
28+
"email-password": true
29+
},
30+
"security": {
31+
"duration": 31536000,
32+
"limit": 0,
33+
"sessionsLimit": 10,
34+
"passwordHistory": 0,
35+
"passwordDictionary": false,
36+
"personalDataCheck": false,
37+
"sessionAlerts": false,
38+
"mockNumbers": [
39+
{
40+
"phone": "+13605559587",
41+
"otp": "414882"
42+
}
43+
]
44+
}
45+
}
46+
},
47+
"functions": [
48+
{
49+
"$id": "686501df001d5eb9417f",
50+
"execute": [
51+
"any"
52+
],
53+
"name": "Starter function",
54+
"enabled": true,
55+
"logging": true,
56+
"runtime": "node-22",
57+
"scopes": [
58+
"users.read"
59+
],
60+
"events": [],
61+
"schedule": "",
62+
"timeout": 15,
63+
"entrypoint": "src/main.js",
64+
"commands": "npm install",
65+
"specification": "s-0.5vcpu-512mb",
66+
"path": "functions/Starter function"
67+
}
68+
]
69+
}

lib/client.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,7 @@ class Client {
250250
if (cookies && cookies.length > 0) {
251251
for (const cookie of cookies) {
252252
if (cookie.startsWith("a_session_console=")) {
253-
// Extract only the name=value portion, removing Set-Cookie attributes
254-
// Set-Cookie format: "name=value; expires=...; domain=...; etc"
255-
// Cookie header should only contain: "name=value"
256-
const cookieValue = cookie.split(";")[0].trim();
257-
globalConfig.setCookie(cookieValue);
253+
globalConfig.setCookie(cookie);
258254
}
259255
}
260256
}

lib/commands/generic.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export const loginCommand = async ({
8888
const legacyClient = new ClientLegacy();
8989
legacyClient.setEndpoint(configEndpoint);
9090
legacyClient.setProject("console");
91-
9291
if (globalConfig.getSelfSigned()) {
9392
legacyClient.setSelfSigned(true);
9493
}
@@ -114,6 +113,7 @@ export const loginCommand = async ({
114113
const savedCookie = globalConfig.getCookie();
115114

116115
if (savedCookie) {
116+
legacyClient.setCookie(savedCookie);
117117
client.setCookie(savedCookie);
118118
}
119119

@@ -127,16 +127,14 @@ export const loginCommand = async ({
127127
const { factor } = mfa
128128
? { factor: mfa }
129129
: await inquirer.prompt(questionsListFactors);
130-
131130
const challenge = await accountClient.createMfaChallenge(factor);
132131

133132
const { otp } = code
134133
? { otp: code }
135134
: await inquirer.prompt(questionsMFAChallenge);
136-
137135
await legacyClient.call(
138136
"PUT",
139-
"/account/sessions/mfa/challenge",
137+
"/account/mfa/challenges",
140138
{
141139
"content-type": "application/json",
142140
},

lib/services.ts

Lines changed: 12 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,72 @@
1-
import { sdkForConsole } from "./sdks.js";
1+
import { sdkForConsole, sdkForProject } from "./sdks.js";
22
import {
33
Client,
4-
Account,
5-
Avatars,
6-
Backups,
7-
Assistant,
84
Console,
95
Databases,
10-
Domains,
116
Functions,
12-
Graphql,
13-
Health,
14-
Locale,
157
Messaging,
16-
Migrations,
178
Organizations,
18-
Project,
199
Projects,
2010
Proxy,
2111
Sites,
2212
Storage,
2313
TablesDB,
2414
Teams,
25-
Tokens,
26-
Users,
27-
Vcs,
28-
Realtime,
2915
} from "@appwrite.io/console";
3016

31-
export const getAccountService = async (sdk?: Client): Promise<Account> => {
32-
const client = !sdk ? await sdkForConsole(true) : sdk;
33-
return new Account(client);
34-
};
35-
36-
export const getAvatarsService = async (sdk?: Client): Promise<Avatars> => {
37-
const client = !sdk ? await sdkForConsole(true) : sdk;
38-
return new Avatars(client);
39-
};
40-
41-
export const getBackupsService = async (sdk?: Client): Promise<Backups> => {
42-
const client = !sdk ? await sdkForConsole(true) : sdk;
43-
return new Backups(client);
44-
};
45-
46-
export const getAssistantService = async (sdk?: Client): Promise<Assistant> => {
47-
const client = !sdk ? await sdkForConsole(true) : sdk;
48-
return new Assistant(client);
49-
};
50-
5117
export const getConsoleService = async (sdk?: Client): Promise<Console> => {
52-
const client = !sdk ? await sdkForConsole(true) : sdk;
18+
const client = !sdk ? await sdkForProject() : sdk;
5319
return new Console(client);
5420
};
5521

5622
export const getDatabasesService = async (sdk?: Client): Promise<Databases> => {
57-
const client = !sdk ? await sdkForConsole(true) : sdk;
23+
const client = !sdk ? await sdkForProject() : sdk;
5824
return new Databases(client);
5925
};
6026

61-
export const getDomainsService = async (sdk?: Client): Promise<Domains> => {
62-
const client = !sdk ? await sdkForConsole(true) : sdk;
63-
return new Domains(client);
64-
};
65-
6627
export const getFunctionsService = async (sdk?: Client): Promise<Functions> => {
67-
const client = !sdk ? await sdkForConsole(true) : sdk;
28+
const client = !sdk ? await sdkForProject() : sdk;
6829
return new Functions(client);
6930
};
7031

71-
export const getGraphqlService = async (sdk?: Client): Promise<Graphql> => {
72-
const client = !sdk ? await sdkForConsole(true) : sdk;
73-
return new Graphql(client);
74-
};
75-
76-
export const getHealthService = async (sdk?: Client): Promise<Health> => {
77-
const client = !sdk ? await sdkForConsole(true) : sdk;
78-
return new Health(client);
79-
};
80-
81-
export const getLocaleService = async (sdk?: Client): Promise<Locale> => {
82-
const client = !sdk ? await sdkForConsole(true) : sdk;
83-
return new Locale(client);
84-
};
85-
8632
export const getMessagingService = async (sdk?: Client): Promise<Messaging> => {
87-
const client = !sdk ? await sdkForConsole(true) : sdk;
33+
const client = !sdk ? await sdkForProject() : sdk;
8834
return new Messaging(client);
8935
};
9036

91-
export const getMigrationsService = async (
92-
sdk?: Client,
93-
): Promise<Migrations> => {
94-
const client = !sdk ? await sdkForConsole(true) : sdk;
95-
return new Migrations(client);
96-
};
97-
9837
export const getOrganizationsService = async (
9938
sdk?: Client,
10039
): Promise<Organizations> => {
101-
const client = !sdk ? await sdkForConsole(true) : sdk;
40+
const client = !sdk ? await sdkForProject() : sdk;
10241
return new Organizations(client);
10342
};
10443

105-
export const getProjectService = async (sdk?: Client): Promise<Project> => {
106-
const client = !sdk ? await sdkForConsole(true) : sdk;
107-
return new Project(client);
108-
};
109-
11044
export const getProjectsService = async (sdk?: Client): Promise<Projects> => {
111-
const client = !sdk ? await sdkForConsole(true) : sdk;
45+
const client = !sdk ? await sdkForConsole() : sdk;
11246
return new Projects(client);
11347
};
11448

11549
export const getProxyService = async (sdk?: Client): Promise<Proxy> => {
116-
const client = !sdk ? await sdkForConsole(true) : sdk;
50+
const client = !sdk ? await sdkForProject() : sdk;
11751
return new Proxy(client);
11852
};
11953

12054
export const getSitesService = async (sdk?: Client): Promise<Sites> => {
121-
const client = !sdk ? await sdkForConsole(true) : sdk;
55+
const client = !sdk ? await sdkForProject() : sdk;
12256
return new Sites(client);
12357
};
12458

12559
export const getStorageService = async (sdk?: Client): Promise<Storage> => {
126-
const client = !sdk ? await sdkForConsole(true) : sdk;
60+
const client = !sdk ? await sdkForProject() : sdk;
12761
return new Storage(client);
12862
};
12963

13064
export const getTablesDBService = async (sdk?: Client): Promise<TablesDB> => {
131-
const client = !sdk ? await sdkForConsole(true) : sdk;
65+
const client = !sdk ? await sdkForProject() : sdk;
13266
return new TablesDB(client);
13367
};
13468

13569
export const getTeamsService = async (sdk?: Client): Promise<Teams> => {
136-
const client = !sdk ? await sdkForConsole(true) : sdk;
70+
const client = !sdk ? await sdkForProject() : sdk;
13771
return new Teams(client);
13872
};
139-
140-
export const getTokensService = async (sdk?: Client): Promise<Tokens> => {
141-
const client = !sdk ? await sdkForConsole(true) : sdk;
142-
return new Tokens(client);
143-
};
144-
145-
export const getUsersService = async (sdk?: Client): Promise<Users> => {
146-
const client = !sdk ? await sdkForConsole(true) : sdk;
147-
return new Users(client);
148-
};
149-
150-
export const getVcsService = async (sdk?: Client): Promise<Vcs> => {
151-
const client = !sdk ? await sdkForConsole(true) : sdk;
152-
return new Vcs(client);
153-
};
154-
155-
export const getRealtimeService = async (sdk?: Client): Promise<Realtime> => {
156-
const client = !sdk ? await sdkForConsole(true) : sdk;
157-
return new Realtime(client);
158-
};

0 commit comments

Comments
 (0)