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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## 26.2.0

* Added: Device Authorization Grant params (`verificationUrl`, `userCodeLength`, `userCodeFormat`, `deviceCodeDuration`) to `updateOAuth2Server`
* Added: `authorizationDetailsTypes` (RFC 9396) param to `updateOAuth2Server` in `project`
* Added: `userAccessedAt` param to `updateMembershipPrivacyPolicy` in `project`
* Added: email classification attributes (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`) to `User`
* Added: `userAccessedAt` attribute to `Membership`
* Added: `dedicatedDatabases.execute` to `ProjectKeyScopes`
* Updated: Replaced HTTP transport with `undici` for requests and self-signed certs


## 26.1.0

* Added: `createSesProvider` and `updateSesProvider` to `messaging`
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/project/update-membership-privacy-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const result = await project.updateMembershipPrivacyPolicy({
userEmail: false, // optional
userPhone: false, // optional
userName: false, // optional
userMFA: false // optional
userMFA: false, // optional
userAccessedAt: false // optional
});
```
7 changes: 6 additions & 1 deletion docs/examples/project/update-o-auth-2-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ const result = await project.updateOAuth2Server({
enabled: false,
authorizationUrl: 'https://example.com',
scopes: [], // optional
authorizationDetailsTypes: [], // optional
accessTokenDuration: 60, // optional
refreshTokenDuration: 60, // optional
publicAccessTokenDuration: 60, // optional
publicRefreshTokenDuration: 60, // optional
confidentialPkce: false // optional
confidentialPkce: false, // optional
verificationUrl: 'https://example.com', // optional
userCodeLength: 6, // optional
userCodeFormat: 'numeric', // optional
deviceCodeDuration: 60 // optional
});
```
574 changes: 276 additions & 298 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "node-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.1.0",
"version": "26.2.0",
"license": "BSD-3-Clause",
"main": "dist/index.js",
"type": "commonjs",
Expand Down Expand Up @@ -52,6 +52,6 @@
},
"dependencies": {
"json-bigint": "1.0.0",
"node-fetch-native-with-agent": "1.7.2"
"undici": "^6.26.0"
}
}
25 changes: 20 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fetch, FormData, File } from 'node-fetch-native-with-agent';
import { createAgent } from 'node-fetch-native-with-agent/agent';
import { fetch, FormData, File, Agent, type RequestInit } from 'undici';
import { Models } from './models';
import { InputFile } from './inputFile';
import JSONbigModule from 'json-bigint';
Expand Down Expand Up @@ -74,7 +73,7 @@ class AppwriteException extends Error {
}

function getUserAgent() {
let ua = 'AppwriteNodeJSSDK/26.1.0';
let ua = 'AppwriteNodeJSSDK/26.2.0';

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

class Client {
static CHUNK_SIZE = 1024 * 1024 * 5;
private selfSignedAgent?: Agent;

config = {
endpoint: 'https://cloud.appwrite.io/v1',
Expand All @@ -128,7 +128,7 @@ class Client {
'x-sdk-name': 'Node.js',
'x-sdk-platform': 'server',
'x-sdk-language': 'nodejs',
'x-sdk-version': '26.1.0',
'x-sdk-version': '26.2.0',
'user-agent' : getUserAgent(),
'X-Appwrite-Response-Format': '1.9.5',
};
Expand Down Expand Up @@ -170,6 +170,11 @@ class Client {

this.config.selfSigned = selfSigned;

if (!selfSigned && this.selfSignedAgent) {
this.selfSignedAgent.destroy();
this.selfSignedAgent = undefined;
}
Comment thread
ChiragAgg5k marked this conversation as resolved.

return this;
}

Expand Down Expand Up @@ -359,9 +364,19 @@ class Client {
let options: RequestInit = {
method,
headers,
...createAgent(this.config.endpoint, { rejectUnauthorized: !this.config.selfSigned }),
};

if (this.config.selfSigned) {
if (!this.selfSignedAgent) {
this.selfSignedAgent = new Agent({
connect: {
rejectUnauthorized: false,
},
});
}
options.dispatcher = this.selfSignedAgent;
}

if (method === 'GET') {
for (const [key, value] of Object.entries(Client.flatten(params))) {
url.searchParams.append(key, value);
Expand Down
1 change: 1 addition & 0 deletions src/enums/project-key-scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export enum ProjectKeyScopes {
ArchivesWrite = 'archives.write',
RestorationsRead = 'restorations.read',
RestorationsWrite = 'restorations.write',
DedicatedDatabasesExecute = 'dedicatedDatabases.execute',
DomainsRead = 'domains.read',
DomainsWrite = 'domains.write',
EventsRead = 'events.read',
Expand Down
2 changes: 1 addition & 1 deletion src/inputFile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { File } from "node-fetch-native-with-agent";
import { File } from "undici";

type FsPromises = {
stat: (path: string) => Promise<{ size: number }>;
Expand Down
48 changes: 48 additions & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2925,6 +2925,26 @@ export namespace Models {
* Email verification status.
*/
emailVerification: boolean;
/**
* Canonical form of the user email address.
*/
emailCanonical?: string;
/**
* Whether the user email is from a free email provider.
*/
emailIsFree?: boolean;
/**
* Whether the user email is from a disposable email provider.
*/
emailIsDisposable?: boolean;
/**
* Whether the user email is from a corporate domain.
*/
emailIsCorporate?: boolean;
/**
* Whether the user email is in its canonical form.
*/
emailIsCanonical?: boolean;
/**
* Phone verification status.
*/
Expand Down Expand Up @@ -3576,6 +3596,10 @@ export namespace Models {
* Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console.
*/
mfa: boolean;
/**
* Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console.
*/
userAccessedAt: string;
/**
* User list of roles
*/
Expand Down Expand Up @@ -4264,6 +4288,10 @@ export namespace Models {
* OAuth2 server allowed scopes
*/
oAuth2ServerScopes: string[];
/**
* OAuth2 server accepted RFC 9396 authorization_details types
*/
oAuth2ServerAuthorizationDetailsTypes: string[];
/**
* OAuth2 server access token duration in seconds for confidential clients
*/
Expand All @@ -4284,6 +4312,22 @@ export namespace Models {
* 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.
*/
oAuth2ServerConfidentialPkce: boolean;
/**
* URL to your application page where users enter the device flow user code. Empty when the Device Authorization Grant is not configured.
*/
oAuth2ServerVerificationUrl: string;
/**
* Number of characters in the device flow user code, excluding the formatting separator.
*/
oAuth2ServerUserCodeLength: number;
/**
* Character set for device flow user codes: `numeric`, `alphabetic`, or `alphanumeric`.
*/
oAuth2ServerUserCodeFormat: string;
/**
* Lifetime in seconds of device flow device codes and user codes.
*/
oAuth2ServerDeviceCodeDuration: number;
/**
* OAuth2 server discovery URL
*/
Expand Down Expand Up @@ -5662,6 +5706,10 @@ export namespace Models {
* Whether user MFA status is visible in memberships.
*/
userMFA: boolean;
/**
* Whether user last access time is visible in memberships.
*/
userAccessedAt: boolean;
}

/**
Expand Down
Loading
Loading