appwrite-cli 5.0.1 → 5.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Appwrite Command Line SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-1.5.0-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
29
29
 
30
30
  ```sh
31
31
  $ appwrite -v
32
- 5.0.1
32
+ 5.0.3
33
33
  ```
34
34
 
35
35
  ### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
60
60
  Once the installation completes, you can verify your install using
61
61
  ```
62
62
  $ appwrite -v
63
- 5.0.1
63
+ 5.0.3
64
64
  ```
65
65
 
66
66
  ## Getting Started
package/install.ps1 CHANGED
@@ -13,8 +13,8 @@
13
13
  # You can use "View source" of this page to see the full script.
14
14
 
15
15
  # REPO
16
- $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.1/appwrite-cli-win-x64.exe"
17
- $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.1/appwrite-cli-win-arm64.exe"
16
+ $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.3/appwrite-cli-win-x64.exe"
17
+ $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.3/appwrite-cli-win-arm64.exe"
18
18
 
19
19
  $APPWRITE_BINARY_NAME = "appwrite.exe"
20
20
 
package/install.sh CHANGED
@@ -97,7 +97,7 @@ printSuccess() {
97
97
  downloadBinary() {
98
98
  echo "[2/4] Downloading executable for $OS ($ARCH) ..."
99
99
 
100
- GITHUB_LATEST_VERSION="5.0.1"
100
+ GITHUB_LATEST_VERSION="5.0.3"
101
101
  GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102
102
  GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103
103
 
package/lib/client.js CHANGED
@@ -15,8 +15,8 @@ class Client {
15
15
  'x-sdk-name': 'Command Line',
16
16
  'x-sdk-platform': 'console',
17
17
  'x-sdk-language': 'cli',
18
- 'x-sdk-version': '5.0.1',
19
- 'user-agent' : `AppwriteCLI/5.0.1 (${os.type()} ${os.version()}; ${os.arch()})`,
18
+ 'x-sdk-version': '5.0.3',
19
+ 'user-agent' : `AppwriteCLI/5.0.3 (${os.type()} ${os.version()}; ${os.arch()})`,
20
20
  'X-Appwrite-Response-Format' : '1.5.0',
21
21
  };
22
22
  }
@@ -4,8 +4,8 @@ const Client = require("../client");
4
4
  const { sdkForConsole } = require("../sdks");
5
5
  const { globalConfig, localConfig } = require("../config");
6
6
  const { actionRunner, success, parseBool, commandDescriptions, log, parse } = require("../parser");
7
- const { questionsLogin } = require("../questions");
8
- const { accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
7
+ const { questionsLogin, questionsListFactors, questionsMfaChallenge } = require("../questions");
8
+ const { accountUpdateMfaChallenge, accountCreateMfaChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
9
9
 
10
10
  const login = new Command("login")
11
11
  .description(commandDescriptions['login'])
@@ -24,7 +24,44 @@ const login = new Command("login")
24
24
  sdk: client
25
25
  })
26
26
 
27
- success()
27
+ client.setCookie(globalConfig.getCookie());
28
+
29
+ let account;
30
+
31
+ try {
32
+ account = await accountGet({
33
+ sdk: client,
34
+ parseOutput: false
35
+ });
36
+ } catch(error) {
37
+ if (error.response === 'user_more_factors_required') {
38
+ const { factor } = await inquirer.prompt(questionsListFactors);
39
+
40
+ const challenge = await accountCreateMfaChallenge({
41
+ factor,
42
+ parseOutput: false,
43
+ sdk: client
44
+ });
45
+
46
+ const { otp } = await inquirer.prompt(questionsMfaChallenge);
47
+
48
+ await accountUpdateMfaChallenge({
49
+ challengeId: challenge.$id,
50
+ otp,
51
+ parseOutput: false,
52
+ sdk: client
53
+ });
54
+
55
+ account = await accountGet({
56
+ sdk: client,
57
+ parseOutput: false
58
+ });
59
+ } else {
60
+ throw error;
61
+ }
62
+ }
63
+
64
+ success("Signed in as user with ID: " + account.$id);
28
65
  }));
29
66
 
30
67
  const logout = new Command("logout")
package/lib/questions.js CHANGED
@@ -1,6 +1,9 @@
1
1
  const { localConfig } = require('./config');
2
2
  const { projectsList } = require('./commands/projects');
3
3
  const { functionsListRuntimes } = require('./commands/functions');
4
+ const { accountListMfaFactors } = require("./commands/account");
5
+ const { sdkForConsole } = require("./sdks");
6
+
4
7
  const { databasesList } = require('./commands/databases');
5
8
  const JSONbig = require("json-bigint")({ storeAsString: false });
6
9
 
@@ -387,7 +390,57 @@ const questionsDeployTeams = [
387
390
  name: "override",
388
391
  message: 'Are you sure you want to override this team? This can lead to loss of data! Type "YES" to confirm.'
389
392
  },
390
- ]
393
+ ];
394
+
395
+ const questionsListFactors = [
396
+ {
397
+ type: "list",
398
+ name: "factor",
399
+ message: "Your account is protected by multiple factors. Which factor would you like to use to authenticate?",
400
+ choices: async () => {
401
+ let client = await sdkForConsole(false);
402
+ const factors = await accountListMfaFactors({
403
+ sdk: client,
404
+ parseOutput: false
405
+ });
406
+
407
+ const choices = [
408
+ {
409
+ name: `TOTP (Time-based One-time Password)`,
410
+ value: 'totp'
411
+ },
412
+ {
413
+ name: `E-mail`,
414
+ value: 'email'
415
+ },
416
+ {
417
+ name: `Phone (SMS)`,
418
+ value: 'phone'
419
+ },
420
+ {
421
+ name: `Recovery code`,
422
+ value: 'recoveryCode'
423
+ }
424
+ ].filter((ch) => factors[ch.value] === true);
425
+
426
+ return choices;
427
+ }
428
+ }
429
+ ];
430
+
431
+ const questionsMfaChallenge = [
432
+ {
433
+ type: "input",
434
+ name: "otp",
435
+ message: "Enter OTP",
436
+ validate(value) {
437
+ if (!value) {
438
+ return "Please enter OTP";
439
+ }
440
+ return true;
441
+ },
442
+ }
443
+ ];
391
444
 
392
445
  module.exports = {
393
446
  questionsInitProject,
@@ -398,5 +451,7 @@ module.exports = {
398
451
  questionsDeployCollections,
399
452
  questionsDeployBuckets,
400
453
  questionsDeployTeams,
401
- questionsGetEntrypoint
454
+ questionsGetEntrypoint,
455
+ questionsListFactors,
456
+ questionsMfaChallenge
402
457
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "appwrite-cli",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "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",
5
- "version": "5.0.1",
5
+ "version": "5.0.3",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
5
5
  "homepage": "https://github.com/appwrite/sdk-for-cli",
6
6
  "license": "BSD-3-Clause",
7
7
  "architecture": {
8
8
  "64bit": {
9
- "url": "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.1/appwrite-cli-win-x64.exe",
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.3/appwrite-cli-win-x64.exe",
10
10
  "bin": [
11
11
  [
12
12
  "appwrite-cli-win-x64.exe",
@@ -15,7 +15,7 @@
15
15
  ]
16
16
  },
17
17
  "arm64": {
18
- "url": "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.1/appwrite-cli-win-arm64.exe",
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.3/appwrite-cli-win-arm64.exe",
19
19
  "bin": [
20
20
  [
21
21
  "appwrite-cli-win-arm64.exe",