Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 26.1.0

* Added: Realtime connections now send the configured JWT for authentication.
* Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests.
* Fixed: URL-encode path parameters across all services.
* Fixed: `ping` now sends an `Accept: application/json` header.

## 26.0.0

* Breaking: Renamed `Theme` enum to `BrowserTheme`, changing `avatars.getScreenshot()` `theme` param type.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { Client, Account } from "appwrite";
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:

```html
<script src="https://cdn.jsdelivr.net/npm/appwrite@26.0.0"></script>
<script src="https://cdn.jsdelivr.net/npm/appwrite@26.1.0"></script>
```


Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const account = new Account(client);
const result = await account.create({
userId: '<USER_ID>',
email: 'email@example.com',
password: '',
password: 'password',
name: '<NAME>' // optional
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/account/update-password.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const client = new Client()
const account = new Account(client);

const result = await account.updatePassword({
password: '',
oldPassword: '<OLD_PASSWORD>' // optional
password: 'password',
oldPassword: 'password' // optional
Comment on lines +11 to +12

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Misleading password placeholder in documentation examples

The previous placeholders ('' / '<OLD_PASSWORD>') were either clearly empty or explicitly tagged as placeholders. The new value 'password' reads like a literal password string that developers might copy verbatim into their code. A conventional placeholder such as '<NEW_PASSWORD>' and '<OLD_PASSWORD>' would make it unambiguous that these are template values to be replaced. The same pattern appears in docs/examples/account/create.md and docs/examples/account/update-recovery.md.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

});

console.log(result);
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/update-recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const account = new Account(client);
const result = await account.updateRecovery({
userId: '<USER_ID>',
secret: '<SECRET>',
password: ''
password: 'password'
});

console.log(result);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
"version": "26.0.0",
"version": "26.1.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
15 changes: 10 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class Client {
'x-sdk-name': 'Web',
'x-sdk-platform': 'client',
'x-sdk-language': 'web',
'x-sdk-version': '26.0.0',
'x-sdk-version': '26.1.0',
'X-Appwrite-Response-Format': '1.9.5',
};

Expand Down Expand Up @@ -526,7 +526,7 @@ class Client {
/**
* Set ImpersonateUserId
*
* Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
* Impersonate a user by ID
*
* @param value string
*
Expand All @@ -540,7 +540,7 @@ class Client {
/**
* Set ImpersonateUserEmail
*
* Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
* Impersonate a user by email
*
* @param value string
*
Expand All @@ -554,7 +554,7 @@ class Client {
/**
* Set ImpersonateUserPhone
*
* Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
* Impersonate a user by phone
*
* @param value string
*
Expand Down Expand Up @@ -615,7 +615,11 @@ class Client {

const encodedProject = encodeURIComponent((this.config.project as string) ?? '');
// URL carries only the project; channels/queries are sent via subscribe message.
const queryParams = 'project=' + encodedProject;
let queryParams = 'project=' + encodedProject;

if (this.config.jwt) {
queryParams += '&jwt=' + encodeURIComponent(this.config.jwt as string);
}

const url = this.config.endpointRealtime + '/realtime?' + queryParams;

Expand Down Expand Up @@ -1044,6 +1048,7 @@ class Client {
async ping(): Promise<unknown> {
return this.call('GET', new URL(this.config.endpoint + '/ping'), {
'X-Appwrite-Project': this.config.project,
'accept': 'application/json',
});
}

Expand Down
28 changes: 14 additions & 14 deletions src/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "identityId"');
}

const apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId);
const apiPath = '/account/identities/{identityId}'.replace('{identityId}', encodeURIComponent(String(identityId)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -518,7 +518,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "type"');
}

const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -572,7 +572,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "type"');
}

const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -635,7 +635,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "otp"');
}

const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type)));
const payload: Payload = {};
if (typeof otp !== 'undefined') {
payload['otp'] = otp;
Expand Down Expand Up @@ -700,7 +700,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "otp"');
}

const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type)));
const payload: Payload = {};
if (typeof otp !== 'undefined') {
payload['otp'] = otp;
Expand Down Expand Up @@ -758,7 +758,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "type"');
}

const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -811,7 +811,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "type"');
}

const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', encodeURIComponent(String(type)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -1986,7 +1986,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "provider"');
}

const apiPath = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider);
const apiPath = '/account/sessions/oauth2/{provider}'.replace('{provider}', encodeURIComponent(String(provider)));
const payload: Payload = {};
if (typeof success !== 'undefined') {
payload['success'] = success;
Expand Down Expand Up @@ -2191,7 +2191,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "sessionId"');
}

const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -2244,7 +2244,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "sessionId"');
}

const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -2298,7 +2298,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "sessionId"');
}

const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', encodeURIComponent(String(sessionId)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -2460,7 +2460,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "identifier"');
}

const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', encodeURIComponent(String(targetId)));
const payload: Payload = {};
if (typeof identifier !== 'undefined') {
payload['identifier'] = identifier;
Expand Down Expand Up @@ -2517,7 +2517,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "targetId"');
}

const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', encodeURIComponent(String(targetId)));
const payload: Payload = {};
const uri = new URL(this.client.config.endpoint + apiPath);

Expand Down Expand Up @@ -2760,7 +2760,7 @@ export class Account {
throw new AppwriteException('Missing required parameter: "provider"');
}

const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', provider);
const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', encodeURIComponent(String(provider)));
const payload: Payload = {};
if (typeof success !== 'undefined') {
payload['success'] = success;
Expand Down
14 changes: 11 additions & 3 deletions src/services/avatars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class Avatars {
throw new AppwriteException('Missing required parameter: "code"');
}

const apiPath = '/avatars/browsers/{code}'.replace('{code}', code);
const apiPath = '/avatars/browsers/{code}'.replace('{code}', encodeURIComponent(String(code)));
const payload: Payload = {};
if (typeof width !== 'undefined') {
payload['width'] = width;
Expand All @@ -89,6 +89,7 @@ export class Avatars {
}

payload['project'] = this.client.config.project;
payload['impersonateuserid'] = this.client.config.impersonateuserid;

for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
Expand Down Expand Up @@ -152,7 +153,7 @@ export class Avatars {
throw new AppwriteException('Missing required parameter: "code"');
}

const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code);
const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', encodeURIComponent(String(code)));
const payload: Payload = {};
if (typeof width !== 'undefined') {
payload['width'] = width;
Expand All @@ -171,6 +172,7 @@ export class Avatars {
}

payload['project'] = this.client.config.project;
payload['impersonateuserid'] = this.client.config.impersonateuserid;

for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
Expand Down Expand Up @@ -232,6 +234,7 @@ export class Avatars {
}

payload['project'] = this.client.config.project;
payload['impersonateuserid'] = this.client.config.impersonateuserid;

for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
Expand Down Expand Up @@ -295,7 +298,7 @@ export class Avatars {
throw new AppwriteException('Missing required parameter: "code"');
}

const apiPath = '/avatars/flags/{code}'.replace('{code}', code);
const apiPath = '/avatars/flags/{code}'.replace('{code}', encodeURIComponent(String(code)));
const payload: Payload = {};
if (typeof width !== 'undefined') {
payload['width'] = width;
Expand All @@ -314,6 +317,7 @@ export class Avatars {
}

payload['project'] = this.client.config.project;
payload['impersonateuserid'] = this.client.config.impersonateuserid;

for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
Expand Down Expand Up @@ -394,6 +398,7 @@ export class Avatars {
}

payload['project'] = this.client.config.project;
payload['impersonateuserid'] = this.client.config.impersonateuserid;

for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
Expand Down Expand Up @@ -480,6 +485,7 @@ export class Avatars {
}

payload['project'] = this.client.config.project;
payload['impersonateuserid'] = this.client.config.impersonateuserid;

for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
Expand Down Expand Up @@ -561,6 +567,7 @@ export class Avatars {
}

payload['project'] = this.client.config.project;
payload['impersonateuserid'] = this.client.config.impersonateuserid;

for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
Expand Down Expand Up @@ -760,6 +767,7 @@ export class Avatars {
}

payload['project'] = this.client.config.project;
payload['impersonateuserid'] = this.client.config.impersonateuserid;

for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
Expand Down
Loading