Skip to content

Commit 846d0d6

Browse files
authored
feat: SDK update for version 26.2.0 (#158)
1 parent 99ee7a1 commit 846d0d6

56 files changed

Lines changed: 1145 additions & 372 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

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

3+
## 26.2.0
4+
5+
* Added: Device Authorization Grant params (`verificationUrl`, `userCodeLength`, `userCodeFormat`, `deviceCodeDuration`) to `updateOAuth2Server`
6+
* Added: `authorizationDetailsTypes` (RFC 9396) param to `updateOAuth2Server` in `project`
7+
* Added: `userAccessedAt` param to `updateMembershipPrivacyPolicy` in `project`
8+
* Added: email classification attributes (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`) to `User`
9+
* Added: `userAccessedAt` attribute to `Membership`
10+
* Added: `dedicatedDatabases.execute` to `ProjectKeyScopes`
11+
* Updated: Replaced HTTP transport with `undici` for requests and self-signed certs
12+
13+
314
## 26.1.0
415

516
* Added: `createSesProvider` and `updateSesProvider` to `messaging`

docs/examples/project/update-membership-privacy-policy.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const result = await project.updateMembershipPrivacyPolicy({
1313
userEmail: false, // optional
1414
userPhone: false, // optional
1515
userName: false, // optional
16-
userMFA: false // optional
16+
userMFA: false, // optional
17+
userAccessedAt: false // optional
1718
});
1819
```

docs/examples/project/update-o-auth-2-server.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ const result = await project.updateOAuth2Server({
1212
enabled: false,
1313
authorizationUrl: 'https://example.com',
1414
scopes: [], // optional
15+
authorizationDetailsTypes: [], // optional
1516
accessTokenDuration: 60, // optional
1617
refreshTokenDuration: 60, // optional
1718
publicAccessTokenDuration: 60, // optional
1819
publicRefreshTokenDuration: 60, // optional
19-
confidentialPkce: false // optional
20+
confidentialPkce: false, // optional
21+
verificationUrl: 'https://example.com', // optional
22+
userCodeLength: 6, // optional
23+
userCodeFormat: 'numeric', // optional
24+
deviceCodeDuration: 60 // optional
2025
});
2126
```

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "node-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.1.0",
5+
"version": "26.2.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/index.js",
88
"type": "commonjs",
@@ -52,6 +52,6 @@
5252
},
5353
"dependencies": {
5454
"json-bigint": "1.0.0",
55-
"node-fetch-native-with-agent": "1.7.2"
55+
"undici": "^6.26.0"
5656
}
5757
}

src/client.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { fetch, FormData, File } from 'node-fetch-native-with-agent';
2-
import { createAgent } from 'node-fetch-native-with-agent/agent';
1+
import { fetch, FormData, File, Agent, type RequestInit } from 'undici';
32
import { Models } from './models';
43
import { InputFile } from './inputFile';
54
import JSONbigModule from 'json-bigint';
@@ -74,7 +73,7 @@ class AppwriteException extends Error {
7473
}
7574

7675
function getUserAgent() {
77-
let ua = 'AppwriteNodeJSSDK/26.1.0';
76+
let ua = 'AppwriteNodeJSSDK/26.2.0';
7877

7978
// `process` is a global in Node.js, but not fully available in all runtimes.
8079
const platform: string[] = [];
@@ -108,6 +107,7 @@ function getUserAgent() {
108107

109108
class Client {
110109
static CHUNK_SIZE = 1024 * 1024 * 5;
110+
private selfSignedAgent?: Agent;
111111

112112
config = {
113113
endpoint: 'https://cloud.appwrite.io/v1',
@@ -128,7 +128,7 @@ class Client {
128128
'x-sdk-name': 'Node.js',
129129
'x-sdk-platform': 'server',
130130
'x-sdk-language': 'nodejs',
131-
'x-sdk-version': '26.1.0',
131+
'x-sdk-version': '26.2.0',
132132
'user-agent' : getUserAgent(),
133133
'X-Appwrite-Response-Format': '1.9.5',
134134
};
@@ -170,6 +170,11 @@ class Client {
170170

171171
this.config.selfSigned = selfSigned;
172172

173+
if (!selfSigned && this.selfSignedAgent) {
174+
this.selfSignedAgent.destroy();
175+
this.selfSignedAgent = undefined;
176+
}
177+
173178
return this;
174179
}
175180

@@ -359,9 +364,19 @@ class Client {
359364
let options: RequestInit = {
360365
method,
361366
headers,
362-
...createAgent(this.config.endpoint, { rejectUnauthorized: !this.config.selfSigned }),
363367
};
364368

369+
if (this.config.selfSigned) {
370+
if (!this.selfSignedAgent) {
371+
this.selfSignedAgent = new Agent({
372+
connect: {
373+
rejectUnauthorized: false,
374+
},
375+
});
376+
}
377+
options.dispatcher = this.selfSignedAgent;
378+
}
379+
365380
if (method === 'GET') {
366381
for (const [key, value] of Object.entries(Client.flatten(params))) {
367382
url.searchParams.append(key, value);

src/enums/project-key-scopes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export enum ProjectKeyScopes {
8989
ArchivesWrite = 'archives.write',
9090
RestorationsRead = 'restorations.read',
9191
RestorationsWrite = 'restorations.write',
92+
DedicatedDatabasesExecute = 'dedicatedDatabases.execute',
9293
DomainsRead = 'domains.read',
9394
DomainsWrite = 'domains.write',
9495
EventsRead = 'events.read',

src/inputFile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { File } from "node-fetch-native-with-agent";
1+
import { File } from "undici";
22

33
type FsPromises = {
44
stat: (path: string) => Promise<{ size: number }>;

src/models.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,6 +2925,26 @@ export namespace Models {
29252925
* Email verification status.
29262926
*/
29272927
emailVerification: boolean;
2928+
/**
2929+
* Canonical form of the user email address.
2930+
*/
2931+
emailCanonical?: string;
2932+
/**
2933+
* Whether the user email is from a free email provider.
2934+
*/
2935+
emailIsFree?: boolean;
2936+
/**
2937+
* Whether the user email is from a disposable email provider.
2938+
*/
2939+
emailIsDisposable?: boolean;
2940+
/**
2941+
* Whether the user email is from a corporate domain.
2942+
*/
2943+
emailIsCorporate?: boolean;
2944+
/**
2945+
* Whether the user email is in its canonical form.
2946+
*/
2947+
emailIsCanonical?: boolean;
29282948
/**
29292949
* Phone verification status.
29302950
*/
@@ -3576,6 +3596,10 @@ export namespace Models {
35763596
* Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console.
35773597
*/
35783598
mfa: boolean;
3599+
/**
3600+
* Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console.
3601+
*/
3602+
userAccessedAt: string;
35793603
/**
35803604
* User list of roles
35813605
*/
@@ -4264,6 +4288,10 @@ export namespace Models {
42644288
* OAuth2 server allowed scopes
42654289
*/
42664290
oAuth2ServerScopes: string[];
4291+
/**
4292+
* OAuth2 server accepted RFC 9396 authorization_details types
4293+
*/
4294+
oAuth2ServerAuthorizationDetailsTypes: string[];
42674295
/**
42684296
* OAuth2 server access token duration in seconds for confidential clients
42694297
*/
@@ -4284,6 +4312,22 @@ export namespace Models {
42844312
* When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting.
42854313
*/
42864314
oAuth2ServerConfidentialPkce: boolean;
4315+
/**
4316+
* URL to your application page where users enter the device flow user code. Empty when the Device Authorization Grant is not configured.
4317+
*/
4318+
oAuth2ServerVerificationUrl: string;
4319+
/**
4320+
* Number of characters in the device flow user code, excluding the formatting separator.
4321+
*/
4322+
oAuth2ServerUserCodeLength: number;
4323+
/**
4324+
* Character set for device flow user codes: `numeric`, `alphabetic`, or `alphanumeric`.
4325+
*/
4326+
oAuth2ServerUserCodeFormat: string;
4327+
/**
4328+
* Lifetime in seconds of device flow device codes and user codes.
4329+
*/
4330+
oAuth2ServerDeviceCodeDuration: number;
42874331
/**
42884332
* OAuth2 server discovery URL
42894333
*/
@@ -5662,6 +5706,10 @@ export namespace Models {
56625706
* Whether user MFA status is visible in memberships.
56635707
*/
56645708
userMFA: boolean;
5709+
/**
5710+
* Whether user last access time is visible in memberships.
5711+
*/
5712+
userAccessedAt: boolean;
56655713
}
56665714

56675715
/**

0 commit comments

Comments
 (0)