Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Jan 18, 2024
1 parent 2368f85 commit 2f289d7
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 3 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].5"></script>
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/[email protected].6"></script>
```


Expand Down
18 changes: 18 additions & 0 deletions docs/examples/users/delete-authenticator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Client, Users } from "@appwrite.io/console";

const client = new Client();

const users = new Users(client);

client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = users.deleteAuthenticator('[USER_ID]', 'totp', '[OTP]');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
18 changes: 18 additions & 0 deletions docs/examples/users/list-providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Client, Users } from "@appwrite.io/console";

const client = new Client();

const users = new Users(client);

client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = users.listProviders('[USER_ID]');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
18 changes: 18 additions & 0 deletions docs/examples/users/update-mfa.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Client, Users } from "@appwrite.io/console";

const client = new Client();

const users = new Users(client);

client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

const promise = users.updateMfa('[USER_ID]', false);

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
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": "0.6.0-rc.5",
"version": "0.6.0-rc.6",
"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 @@ -104,7 +104,7 @@ class Client {
'x-sdk-name': 'Console',
'x-sdk-platform': 'console',
'x-sdk-language': 'web',
'x-sdk-version': '0.6.0-rc.5',
'x-sdk-version': '0.6.0-rc.6',
'X-Appwrite-Response-Format': '1.4.0',
};

Expand Down
89 changes: 89 additions & 0 deletions src/services/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,73 @@ export class Users extends Service {
}, payload);
}

/**
* Update MFA
*
*
* @param {string} userId
* @param {boolean} mfa
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateMfa<Preferences extends Models.Preferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>> {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}

if (typeof mfa === 'undefined') {
throw new AppwriteException('Missing required parameter: "mfa"');
}

const apiPath = '/users/{userId}/mfa'.replace('{userId}', userId);
const payload: Payload = {};

if (typeof mfa !== 'undefined') {
payload['mfa'] = mfa;
}

const uri = new URL(this.client.config.endpoint + apiPath);
return await this.client.call('patch', uri, {
'content-type': 'application/json',
}, payload);
}

/**
* Delete Authenticator
*
*
* @param {string} userId
* @param {string} provider
* @param {string} otp
* @throws {AppwriteException}
* @returns {Promise}
*/
async deleteAuthenticator<Preferences extends Models.Preferences>(userId: string, provider: string, otp: string): Promise<Models.User<Preferences>> {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}

if (typeof provider === 'undefined') {
throw new AppwriteException('Missing required parameter: "provider"');
}

if (typeof otp === 'undefined') {
throw new AppwriteException('Missing required parameter: "otp"');
}

const apiPath = '/users/{userId}/mfa/{provider}'.replace('{userId}', userId).replace('{provider}', provider);
const payload: Payload = {};

if (typeof otp !== 'undefined') {
payload['otp'] = otp;
}

const uri = new URL(this.client.config.endpoint + apiPath);
return await this.client.call('delete', uri, {
'content-type': 'application/json',
}, payload);
}

/**
* Update name
*
Expand Down Expand Up @@ -937,6 +1004,28 @@ export class Users extends Service {
}, payload);
}

/**
* List Providers
*
*
* @param {string} userId
* @throws {AppwriteException}
* @returns {Promise}
*/
async listProviders(userId: string): Promise<Models.MfaProviders> {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}

const apiPath = '/users/{userId}/providers'.replace('{userId}', userId);
const payload: Payload = {};

const uri = new URL(this.client.config.endpoint + apiPath);
return await this.client.call('get', uri, {
'content-type': 'application/json',
}, payload);
}

/**
* List user sessions
*
Expand Down

0 comments on commit 2f289d7

Please sign in to comment.