appwrite-utils-cli 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -149,9 +149,26 @@ export class ConfigManager {
|
|
149
149
|
logger.debug(`Config discovered at: ${configPath}`, { prefix: "ConfigManager" });
|
150
150
|
// 3. Load config from file
|
151
151
|
let config = await this.loaderService.loadFromPath(configPath);
|
152
|
-
// 4. Load session authentication
|
153
|
-
|
154
|
-
|
152
|
+
// 4. Load session authentication (only if appropriate based on config)
|
153
|
+
// Determine if we should load session:
|
154
|
+
// - Load if authMethod is explicitly "session"
|
155
|
+
// - Load if authMethod is "auto" or undefined AND no API key exists
|
156
|
+
// - Skip if authMethod is "apikey" or if API key is present with "auto" mode
|
157
|
+
const hasApiKey = !!(config.appwriteKey && config.appwriteKey.trim().length > 0);
|
158
|
+
const authMethod = config.authMethod || "auto";
|
159
|
+
const shouldLoadSession = options.sessionOverride !== undefined ||
|
160
|
+
authMethod === "session" ||
|
161
|
+
(authMethod === "auto" && !hasApiKey);
|
162
|
+
logger.debug("Session loading decision", {
|
163
|
+
prefix: "ConfigManager",
|
164
|
+
hasApiKey,
|
165
|
+
authMethod,
|
166
|
+
shouldLoadSession,
|
167
|
+
});
|
168
|
+
const session = shouldLoadSession
|
169
|
+
? options.sessionOverride ||
|
170
|
+
(await this.sessionService.findSession(config.appwriteEndpoint, config.appwriteProject))
|
171
|
+
: null;
|
155
172
|
// 5. Merge session into config
|
156
173
|
if (session) {
|
157
174
|
logger.debug("Merging session authentication into config", { prefix: "ConfigManager" });
|
@@ -57,7 +57,11 @@ export class ConfigMergeService {
|
|
57
57
|
const merged = cloneDeep(config);
|
58
58
|
// Add session authentication (map 'cookie' to 'sessionCookie')
|
59
59
|
merged.sessionCookie = session.cookie;
|
60
|
-
|
60
|
+
// Only set authMethod to "session" if not explicitly set to "apikey"
|
61
|
+
// This allows API key authentication to take priority when both are available
|
62
|
+
if (merged.authMethod !== "apikey") {
|
63
|
+
merged.authMethod = "session";
|
64
|
+
}
|
61
65
|
// Add session metadata if available
|
62
66
|
if (session.email || session.expiresAt) {
|
63
67
|
merged.sessionMetadata = {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "appwrite-utils-cli",
|
3
3
|
"description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
|
4
|
-
"version": "1.7.
|
4
|
+
"version": "1.7.2",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
@@ -249,10 +249,30 @@ export class ConfigManager {
|
|
249
249
|
// 3. Load config from file
|
250
250
|
let config = await this.loaderService.loadFromPath(configPath);
|
251
251
|
|
252
|
-
// 4. Load session authentication
|
253
|
-
|
254
|
-
|
255
|
-
|
252
|
+
// 4. Load session authentication (only if appropriate based on config)
|
253
|
+
// Determine if we should load session:
|
254
|
+
// - Load if authMethod is explicitly "session"
|
255
|
+
// - Load if authMethod is "auto" or undefined AND no API key exists
|
256
|
+
// - Skip if authMethod is "apikey" or if API key is present with "auto" mode
|
257
|
+
const hasApiKey = !!(config.appwriteKey && config.appwriteKey.trim().length > 0);
|
258
|
+
const authMethod = config.authMethod || "auto";
|
259
|
+
|
260
|
+
const shouldLoadSession =
|
261
|
+
options.sessionOverride !== undefined ||
|
262
|
+
authMethod === "session" ||
|
263
|
+
(authMethod === "auto" && !hasApiKey);
|
264
|
+
|
265
|
+
logger.debug("Session loading decision", {
|
266
|
+
prefix: "ConfigManager",
|
267
|
+
hasApiKey,
|
268
|
+
authMethod,
|
269
|
+
shouldLoadSession,
|
270
|
+
});
|
271
|
+
|
272
|
+
const session = shouldLoadSession
|
273
|
+
? options.sessionOverride ||
|
274
|
+
(await this.sessionService.findSession(config.appwriteEndpoint, config.appwriteProject))
|
275
|
+
: null;
|
256
276
|
|
257
277
|
// 5. Merge session into config
|
258
278
|
if (session) {
|
@@ -80,7 +80,12 @@ export class ConfigMergeService {
|
|
80
80
|
|
81
81
|
// Add session authentication (map 'cookie' to 'sessionCookie')
|
82
82
|
merged.sessionCookie = session.cookie;
|
83
|
-
|
83
|
+
|
84
|
+
// Only set authMethod to "session" if not explicitly set to "apikey"
|
85
|
+
// This allows API key authentication to take priority when both are available
|
86
|
+
if (merged.authMethod !== "apikey") {
|
87
|
+
merged.authMethod = "session";
|
88
|
+
}
|
84
89
|
|
85
90
|
// Add session metadata if available
|
86
91
|
if (session.email || session.expiresAt) {
|