Skip to content

Commit

Permalink
Merge pull request #30 from appwrite/dev
Browse files Browse the repository at this point in the history
feat: membership privacy
  • Loading branch information
christyjacob4 authored Nov 7, 2024
2 parents 3222d4e + 67cabaa commit b29eeef
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 74 deletions.
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.io/console";
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.io/[email protected].2"></script>
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/[email protected].3"></script>
```


Expand Down
14 changes: 0 additions & 14 deletions docs/examples/account/list-credits.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/examples/console/get-copon.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ const client = new Client()

const projects = new Projects(client);

const result = await projects.updateTeamsSensitiveAttributes(
const result = await projects.updateMembershipsPrivacy(
'<PROJECT_ID>', // projectId
false // enabled
false, // userName
false, // userEmail
false // mfa
);

console.log(result);
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.io/console",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
"version": "1.4.2",
"version": "1.4.3",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class Client {
'x-sdk-name': 'Console',
'x-sdk-platform': 'console',
'x-sdk-language': 'web',
'x-sdk-version': '1.4.2',
'x-sdk-version': '1.4.3',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down
18 changes: 13 additions & 5 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1848,11 +1848,11 @@ export namespace Models {
*/
userId: string;
/**
* User name. Hide this attribute by disabling teams sensitive data in the Console.
* User name. Hide this attribute by toggling membership privacy in the Console.
*/
userName: string;
/**
* User email address. Hide this attribute by disabling teams sensitive data in the Console.
* User email address. Hide this attribute by toggling membership privacy in the Console.
*/
userEmail: string;
/**
Expand All @@ -1876,7 +1876,7 @@ export namespace Models {
*/
confirm: boolean;
/**
* Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by disabling teams sensitive data in the Console.
* 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;
/**
Expand Down Expand Up @@ -2550,9 +2550,17 @@ export namespace Models {
*/
authSessionAlerts: boolean;
/**
* Whether or not to show sensitive attributes in the teams API.
* Whether or not to show user names in the teams membership response.
*/
teamsSensitiveAttributes: boolean;
membershipsUserName: boolean;
/**
* Whether or not to show user emails in the teams membership response.
*/
membershipsUserEmail: boolean;
/**
* Whether or not to show user MFA status in the teams membership response.
*/
membershipsMfa: boolean;
/**
* List of Auth Providers.
*/
Expand Down
84 changes: 49 additions & 35 deletions src/services/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,55 @@ export class Projects {
}


return await this.client.call(
'patch',
uri,
apiHeaders,
payload
);
}
/**
* Update project team memberships privacy attributes
*
*
* @param {string} projectId
* @param {boolean} userName
* @param {boolean} userEmail
* @param {boolean} mfa
* @throws {AppwriteException}
* @returns {Promise<Models.Project>}
*/
async updateMembershipsPrivacy(projectId: string, userName: boolean, userEmail: boolean, mfa: boolean): Promise<Models.Project> {
if (typeof projectId === 'undefined') {
throw new AppwriteException('Missing required parameter: "projectId"');
}
if (typeof userName === 'undefined') {
throw new AppwriteException('Missing required parameter: "userName"');
}
if (typeof userEmail === 'undefined') {
throw new AppwriteException('Missing required parameter: "userEmail"');
}
if (typeof mfa === 'undefined') {
throw new AppwriteException('Missing required parameter: "mfa"');
}
const apiPath = '/projects/{projectId}/auth/memberships-privacy'.replace('{projectId}', projectId);
const payload: Payload = {};
if (typeof userName !== 'undefined') {
payload['userName'] = userName;
}
if (typeof userEmail !== 'undefined') {
payload['userEmail'] = userEmail;
}
if (typeof mfa !== 'undefined') {
payload['mfa'] = mfa;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
'content-type': 'application/json',
}


return await this.client.call(
'patch',
uri,
Expand Down Expand Up @@ -614,41 +663,6 @@ export class Projects {
}


return await this.client.call(
'patch',
uri,
apiHeaders,
payload
);
}
/**
* Update project team sensitive attributes
*
*
* @param {string} projectId
* @param {boolean} enabled
* @throws {AppwriteException}
* @returns {Promise<Models.Project>}
*/
async updateTeamsSensitiveAttributes(projectId: string, enabled: boolean): Promise<Models.Project> {
if (typeof projectId === 'undefined') {
throw new AppwriteException('Missing required parameter: "projectId"');
}
if (typeof enabled === 'undefined') {
throw new AppwriteException('Missing required parameter: "enabled"');
}
const apiPath = '/projects/{projectId}/auth/teams-sensitive-attributes'.replace('{projectId}', projectId);
const payload: Payload = {};
if (typeof enabled !== 'undefined') {
payload['enabled'] = enabled;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
'content-type': 'application/json',
}


return await this.client.call(
'patch',
uri,
Expand Down
4 changes: 2 additions & 2 deletions src/services/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export class Teams {
/**
* List team memberships
*
* Use this endpoint to list a team&#039;s members using the team&#039;s ID. All team members have read access to this endpoint. Hide sensitive attributes (userName, userEmail and mfa) from the response by disabling teams sensitive data in the Console.
* Use this endpoint to list a team&#039;s members using the team&#039;s ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console.
*
* @param {string} teamId
* @param {string[]} queries
Expand Down Expand Up @@ -315,7 +315,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee
/**
* Get team membership
*
* Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes (userName, userEmail and mfa) from the response by disabling teams sensitive data in the Console.
* Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console.
*
* @param {string} teamId
* @param {string} membershipId
Expand Down

0 comments on commit b29eeef

Please sign in to comment.