Skip to content

Commit 55fd8b8

Browse files
Merge pull request #176 from appwrite/dev
feat: SDK update for version 26.1.0
2 parents 2b2c6a3 + fd8faab commit 55fd8b8

18 files changed

Lines changed: 117 additions & 83 deletions

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## 26.1.0
4+
5+
* Added: Realtime connections now send the configured JWT for authentication.
6+
* Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests.
7+
* Fixed: URL-encode path parameters across all services.
8+
* Fixed: `ping` now sends an `Accept: application/json` header.
9+
310
## 26.0.0
411

512
* Breaking: Renamed `Theme` enum to `BrowserTheme`, changing `avatars.getScreenshot()` `theme` param type.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Client, Account } from "appwrite";
3333
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:
3434

3535
```html
36-
<script src="https://cdn.jsdelivr.net/npm/appwrite@26.0.0"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/appwrite@26.1.0"></script>
3737
```
3838

3939

docs/examples/account/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const account = new Account(client);
1010
const result = await account.create({
1111
userId: '<USER_ID>',
1212
email: 'email@example.com',
13-
password: '',
13+
password: 'password',
1414
name: '<NAME>' // optional
1515
});
1616

docs/examples/account/update-password.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const client = new Client()
88
const account = new Account(client);
99

1010
const result = await account.updatePassword({
11-
password: '',
12-
oldPassword: '<OLD_PASSWORD>' // optional
11+
password: 'password',
12+
oldPassword: 'password' // optional
1313
});
1414

1515
console.log(result);

docs/examples/account/update-recovery.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const account = new Account(client);
1010
const result = await account.updateRecovery({
1111
userId: '<USER_ID>',
1212
secret: '<SECRET>',
13-
password: ''
13+
password: 'password'
1414
});
1515

1616
console.log(result);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "appwrite",
33
"homepage": "https://appwrite.io/support",
44
"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",
5-
"version": "26.0.0",
5+
"version": "26.1.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/client.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class Client {
382382
'x-sdk-name': 'Web',
383383
'x-sdk-platform': 'client',
384384
'x-sdk-language': 'web',
385-
'x-sdk-version': '26.0.0',
385+
'x-sdk-version': '26.1.0',
386386
'X-Appwrite-Response-Format': '1.9.5',
387387
};
388388

@@ -526,7 +526,7 @@ class Client {
526526
/**
527527
* Set ImpersonateUserId
528528
*
529-
* 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.
529+
* Impersonate a user by ID
530530
*
531531
* @param value string
532532
*
@@ -540,7 +540,7 @@ class Client {
540540
/**
541541
* Set ImpersonateUserEmail
542542
*
543-
* 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.
543+
* Impersonate a user by email
544544
*
545545
* @param value string
546546
*
@@ -554,7 +554,7 @@ class Client {
554554
/**
555555
* Set ImpersonateUserPhone
556556
*
557-
* 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.
557+
* Impersonate a user by phone
558558
*
559559
* @param value string
560560
*
@@ -615,7 +615,11 @@ class Client {
615615

616616
const encodedProject = encodeURIComponent((this.config.project as string) ?? '');
617617
// URL carries only the project; channels/queries are sent via subscribe message.
618-
const queryParams = 'project=' + encodedProject;
618+
let queryParams = 'project=' + encodedProject;
619+
620+
if (this.config.jwt) {
621+
queryParams += '&jwt=' + encodeURIComponent(this.config.jwt as string);
622+
}
619623

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

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

src/services/account.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class Account {
292292
throw new AppwriteException('Missing required parameter: "identityId"');
293293
}
294294

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2763-
const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', provider);
2763+
const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', encodeURIComponent(String(provider)));
27642764
const payload: Payload = {};
27652765
if (typeof success !== 'undefined') {
27662766
payload['success'] = success;

src/services/avatars.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class Avatars {
7070
throw new AppwriteException('Missing required parameter: "code"');
7171
}
7272

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

9191
payload['project'] = this.client.config.project;
92+
payload['impersonateuserid'] = this.client.config.impersonateuserid;
9293

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

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

173174
payload['project'] = this.client.config.project;
175+
payload['impersonateuserid'] = this.client.config.impersonateuserid;
174176

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

234236
payload['project'] = this.client.config.project;
237+
payload['impersonateuserid'] = this.client.config.impersonateuserid;
235238

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

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

316319
payload['project'] = this.client.config.project;
320+
payload['impersonateuserid'] = this.client.config.impersonateuserid;
317321

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

396400
payload['project'] = this.client.config.project;
401+
payload['impersonateuserid'] = this.client.config.impersonateuserid;
397402

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

482487
payload['project'] = this.client.config.project;
488+
payload['impersonateuserid'] = this.client.config.impersonateuserid;
483489

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

563569
payload['project'] = this.client.config.project;
570+
payload['impersonateuserid'] = this.client.config.impersonateuserid;
564571

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

762769
payload['project'] = this.client.config.project;
770+
payload['impersonateuserid'] = this.client.config.impersonateuserid;
763771

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

0 commit comments

Comments
 (0)