-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Console SDK update for version 2.1.0 #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,15 +303,18 @@ class Client { | |
| config: { | ||
| endpoint: string; | ||
| endpointRealtime: string; | ||
| [key: string]: string | undefined; | ||
| selfSigned: boolean; | ||
| [key: string]: string | boolean | undefined; | ||
| } = { | ||
| endpoint: 'https://cloud.appwrite.io/v1', | ||
| endpointRealtime: '', | ||
| selfSigned: false, | ||
| project: '', | ||
| key: '', | ||
| jwt: '', | ||
| locale: '', | ||
| mode: '', | ||
| cookie: '', | ||
| platform: '', | ||
| }; | ||
| /** | ||
|
|
@@ -321,7 +324,7 @@ class Client { | |
| 'x-sdk-name': 'Console', | ||
| 'x-sdk-platform': 'console', | ||
| 'x-sdk-language': 'web', | ||
| 'x-sdk-version': '2.0.0', | ||
| 'x-sdk-version': '2.1.0', | ||
| 'X-Appwrite-Response-Format': '1.8.0', | ||
| }; | ||
|
|
||
|
|
@@ -369,6 +372,18 @@ class Client { | |
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Set self-signed | ||
| * | ||
| * @param {boolean} selfSigned | ||
| * | ||
| * @returns {this} | ||
| */ | ||
| setSelfSigned(selfSigned: boolean): this { | ||
| this.config.selfSigned = selfSigned; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Set Project | ||
| * | ||
|
|
@@ -435,6 +450,20 @@ class Client { | |
| this.config.mode = value; | ||
| return this; | ||
| } | ||
| /** | ||
| * Set Cookie | ||
| * | ||
| * The user cookie to authenticate with | ||
| * | ||
| * @param value string | ||
| * | ||
| * @return {this} | ||
| */ | ||
| setCookie(value: string): this { | ||
| this.headers['Cookie'] = value; | ||
| this.config.cookie = value; | ||
| return this; | ||
| } | ||
|
Comment on lines
+453
to
+466
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's look at the setCookie method and surrounding context in src/client.ts
cat -n src/client.ts | sed -n '440,480p'Repository: appwrite/sdk-for-console Length of output: 1198 🏁 Script executed: # Check file size to understand if we can read more context
wc -l src/client.tsRepository: appwrite/sdk-for-console Length of output: 85 🏁 Script executed: # Search for environment detection or browser-specific code
rg -n "typeof window|process\.env|NODE_ENV|isBrowser|isNode" src/client.ts | head -20Repository: appwrite/sdk-for-console Length of output: 229 🏁 Script executed: # Search for other cookie-related code or authentication patterns
rg -n -i "cookie|auth|credentials" src/client.ts | head -30Repository: appwrite/sdk-for-console Length of output: 1784 🏁 Script executed: # Look for any documentation or comments about intended environments
rg -n "browser|server|node\.js|environment" src/client.ts | head -20Repository: appwrite/sdk-for-console Length of output: 126 🌐 Web query:
💡 Result: Short answer: No — browsers forbid JavaScript from setting a request "Cookie" HTTP header in fetch. The Fetch spec and browser implementations treat "Cookie" (and "Set‑Cookie" on responses) as forbidden; the browser controls sending cookies. [1][2] What to use instead:
Sources:
🏁 Script executed: # Search for setCookie usage throughout the codebase
rg -n "setCookie" --type ts --type jsRepository: appwrite/sdk-for-console Length of output: 122 🏁 Script executed: # Check how config.cookie is used, especially in request execution
rg -n "config\.cookie|this\.config\.cookie" src/client.ts -A 2 -B 2Repository: appwrite/sdk-for-console Length of output: 227 🏁 Script executed: # Look at the request execution logic to see how headers are processed
cat -n src/client.ts | sed -n '700,750p'Repository: appwrite/sdk-for-console Length of output: 2286 🏁 Script executed: # Search for any comments or documentation about server vs browser usage
rg -n "server|node|browser|environment" src/ -B 2 -A 2 | head -40Repository: appwrite/sdk-for-console Length of output: 4317 🏁 Script executed: # Let's check if config.cookie is actually used anywhere in the request building or execution
rg -n "config\.cookie" src/ -B 2 -A 2Repository: appwrite/sdk-for-console Length of output: 297 🏁 Script executed: # Check the headers object usage in the actual request
cat -n src/client.ts | sed -n '670,710p'Repository: appwrite/sdk-for-console Length of output: 1737 🏁 Script executed: # Look for README or documentation that explains browser vs server usage
find . -maxdepth 2 -type f \( -name "README*" -o -name "*.md" \) | head -10Repository: appwrite/sdk-for-console Length of output: 94 🏁 Script executed: # Check if there's any initialization or documentation in index.ts or main entry point
find . -maxdepth 2 -type f -name "index.ts" -o -name "package.json" | xargs ls -laRepository: appwrite/sdk-for-console Length of output: 195 🏁 Script executed: # Check package.json for project purpose and target environments
cat package.jsonRepository: appwrite/sdk-for-console Length of output: 1203 🏁 Script executed: # Check README for documentation about usage
head -100 README.mdRepository: appwrite/sdk-for-console Length of output: 3890 🏁 Script executed: # Check how headers are passed to fetch, and if Cookie header is actually sent
cat -n src/client.ts | sed -n '755,800p'Repository: appwrite/sdk-for-console Length of output: 2007 🏁 Script executed: # Search for any Node.js specific imports or features
rg -n "require|import.*node|globalThis|Buffer" src/client.ts | head -20Repository: appwrite/sdk-for-console Length of output: 345 🏁 Script executed: # Let's confirm if config.cookie is ever used - search the entire codebase
rg -n "config\.cookie" --type ts --type jsRepository: appwrite/sdk-for-console Length of output: 121 🏁 Script executed: # Check the call method to see if headers are actually used in the fetch call
cat -n src/client.ts | sed -n '795,825p'Repository: appwrite/sdk-for-console Length of output: 1509 🏁 Script executed: # Let's verify what gets passed to fetch as headers
cat -n src/client.ts | sed -n '688,708p'Repository: appwrite/sdk-for-console Length of output: 924 Document that The Since this SDK supports both browser and server-side usage, clarify either in documentation or with an environment check that 🤖 Prompt for AI Agents |
||
| /** | ||
| * Set Platform | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: appwrite/sdk-for-console
Length of output: 1061
🏁 Script executed:
rg -n --type=ts 'config\.selfSigned|this\.config\.selfSigned' -C2Repository: appwrite/sdk-for-console
Length of output: 284
🏁 Script executed:
Repository: appwrite/sdk-for-console
Length of output: 651
🏁 Script executed:
Repository: appwrite/sdk-for-console
Length of output: 50
🏁 Script executed:
sed -n '688,750p' src/client.tsRepository: appwrite/sdk-for-console
Length of output: 2434
🏁 Script executed:
sed -n '795,850p' src/client.tsRepository: appwrite/sdk-for-console
Length of output: 2320
Remove unused
selfSignedconfiguration or implement its functionality.The
selfSignedconfig property is declared and has a setter method, but it is never actually read or used anywhere in the codebase. TheprepareRequestandcallmethods do not reference it, so callingsetSelfSigned()has no effect.If this is intended for Node.js environments using custom HTTPS agents, the implementation is incomplete. If not needed, remove the property, the setter, and the initialization to eliminate dead code.