@internxt/cli 0.1.4
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/.env +11 -0
- package/README.md +297 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +7 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +7 -0
- package/dist/commands/config.d.ts +18 -0
- package/dist/commands/config.js +50 -0
- package/dist/commands/download.d.ts +19 -0
- package/dist/commands/download.js +119 -0
- package/dist/commands/list.d.ts +22 -0
- package/dist/commands/list.js +125 -0
- package/dist/commands/login.d.ts +21 -0
- package/dist/commands/login.js +124 -0
- package/dist/commands/logout.d.ts +9 -0
- package/dist/commands/logout.js +28 -0
- package/dist/commands/logs.d.ts +6 -0
- package/dist/commands/logs.js +12 -0
- package/dist/commands/move.d.ts +18 -0
- package/dist/commands/move.js +109 -0
- package/dist/commands/trash.d.ts +15 -0
- package/dist/commands/trash.js +85 -0
- package/dist/commands/upload.d.ts +15 -0
- package/dist/commands/upload.js +93 -0
- package/dist/commands/webdav.d.ts +12 -0
- package/dist/commands/webdav.js +64 -0
- package/dist/commands/whoami.d.ts +9 -0
- package/dist/commands/whoami.js +27 -0
- package/dist/database/migrations/20240402164914-create-files.d.ts +1 -0
- package/dist/database/migrations/20240402164914-create-files.js +55 -0
- package/dist/database/migrations/20240402165418-create-folders.d.ts +1 -0
- package/dist/database/migrations/20240402165418-create-folders.js +37 -0
- package/dist/hooks/prerun/auth_check.d.ts +3 -0
- package/dist/hooks/prerun/auth_check.js +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/services/auth.service.d.ts +14 -0
- package/dist/services/auth.service.js +79 -0
- package/dist/services/config.service.d.ts +19 -0
- package/dist/services/config.service.js +79 -0
- package/dist/services/crypto.service.d.ts +22 -0
- package/dist/services/crypto.service.js +126 -0
- package/dist/services/database/drive-database-manager.service.d.ts +18 -0
- package/dist/services/database/drive-database-manager.service.js +76 -0
- package/dist/services/database/drive-file/drive-file.attributes.d.ts +14 -0
- package/dist/services/database/drive-file/drive-file.attributes.js +2 -0
- package/dist/services/database/drive-file/drive-file.domain.d.ts +18 -0
- package/dist/services/database/drive-file/drive-file.domain.js +51 -0
- package/dist/services/database/drive-file/drive-file.model.d.ts +17 -0
- package/dist/services/database/drive-file/drive-file.model.js +82 -0
- package/dist/services/database/drive-file/drive-file.repository.d.ts +11 -0
- package/dist/services/database/drive-file/drive-file.repository.js +40 -0
- package/dist/services/database/drive-folder/drive-folder.attributes.d.ts +9 -0
- package/dist/services/database/drive-folder/drive-folder.attributes.js +2 -0
- package/dist/services/database/drive-folder/drive-folder.domain.d.ts +13 -0
- package/dist/services/database/drive-folder/drive-folder.domain.js +36 -0
- package/dist/services/database/drive-folder/drive-folder.model.d.ts +12 -0
- package/dist/services/database/drive-folder/drive-folder.model.js +56 -0
- package/dist/services/database/drive-folder/drive-folder.repository.d.ts +11 -0
- package/dist/services/database/drive-folder/drive-folder.repository.js +40 -0
- package/dist/services/drive/drive-file.service.d.ts +15 -0
- package/dist/services/drive/drive-file.service.js +51 -0
- package/dist/services/drive/drive-folder.service.d.ts +15 -0
- package/dist/services/drive/drive-folder.service.js +49 -0
- package/dist/services/drive/trash.service.d.ts +5 -0
- package/dist/services/drive/trash.service.js +12 -0
- package/dist/services/keys.service.d.ts +14 -0
- package/dist/services/keys.service.js +110 -0
- package/dist/services/network/download.service.d.ts +7 -0
- package/dist/services/network/download.service.js +33 -0
- package/dist/services/network/network-facade.service.d.ts +21 -0
- package/dist/services/network/network-facade.service.js +128 -0
- package/dist/services/network/upload.service.d.ts +9 -0
- package/dist/services/network/upload.service.js +20 -0
- package/dist/services/realms/drive-files.realm.d.ts +23 -0
- package/dist/services/realms/drive-files.realm.js +76 -0
- package/dist/services/realms/drive-folders.realm.d.ts +20 -0
- package/dist/services/realms/drive-folders.realm.js +68 -0
- package/dist/services/realms/drive-realm-manager.service.d.ts +15 -0
- package/dist/services/realms/drive-realm-manager.service.js +63 -0
- package/dist/services/sdk-manager.service.d.ts +28 -0
- package/dist/services/sdk-manager.service.js +107 -0
- package/dist/services/usage.service.d.ts +6 -0
- package/dist/services/usage.service.js +23 -0
- package/dist/services/validation.service.d.ts +7 -0
- package/dist/services/validation.service.js +21 -0
- package/dist/types/command.types.d.ts +42 -0
- package/dist/types/command.types.js +59 -0
- package/dist/types/config.types.d.ts +13 -0
- package/dist/types/config.types.js +2 -0
- package/dist/types/drive.types.d.ts +14 -0
- package/dist/types/drive.types.js +2 -0
- package/dist/types/keys.types.d.ts +16 -0
- package/dist/types/keys.types.js +31 -0
- package/dist/types/network.types.d.ts +11 -0
- package/dist/types/network.types.js +2 -0
- package/dist/types/webdav.types.d.ts +15 -0
- package/dist/types/webdav.types.js +6 -0
- package/dist/utils/cli.utils.d.ts +32 -0
- package/dist/utils/cli.utils.js +105 -0
- package/dist/utils/crypto.utils.d.ts +6 -0
- package/dist/utils/crypto.utils.js +10 -0
- package/dist/utils/drive.utils.d.ts +6 -0
- package/dist/utils/drive.utils.js +34 -0
- package/dist/utils/errors.utils.d.ts +19 -0
- package/dist/utils/errors.utils.js +50 -0
- package/dist/utils/format.utils.d.ts +6 -0
- package/dist/utils/format.utils.js +30 -0
- package/dist/utils/hash.utils.d.ts +15 -0
- package/dist/utils/hash.utils.js +37 -0
- package/dist/utils/logger.utils.d.ts +3 -0
- package/dist/utils/logger.utils.js +50 -0
- package/dist/utils/network.utils.d.ts +22 -0
- package/dist/utils/network.utils.js +49 -0
- package/dist/utils/pm2.utils.d.ts +10 -0
- package/dist/utils/pm2.utils.js +65 -0
- package/dist/utils/stream.utils.d.ts +7 -0
- package/dist/utils/stream.utils.js +56 -0
- package/dist/utils/webdav.utils.d.ts +7 -0
- package/dist/utils/webdav.utils.js +47 -0
- package/dist/utils/xml.utils.d.ts +8 -0
- package/dist/utils/xml.utils.js +23 -0
- package/dist/webdav/handlers/GET.handler.d.ts +23 -0
- package/dist/webdav/handlers/GET.handler.js +52 -0
- package/dist/webdav/handlers/HEAD.handler.d.ts +5 -0
- package/dist/webdav/handlers/HEAD.handler.js +9 -0
- package/dist/webdav/handlers/OPTIONS.handler.d.ts +5 -0
- package/dist/webdav/handlers/OPTIONS.handler.js +11 -0
- package/dist/webdav/handlers/PROPFIND.handler.d.ts +21 -0
- package/dist/webdav/handlers/PROPFIND.handler.js +234 -0
- package/dist/webdav/handlers/PUT.handler.d.ts +23 -0
- package/dist/webdav/handlers/PUT.handler.js +51 -0
- package/dist/webdav/index.d.ts +1 -0
- package/dist/webdav/index.js +30 -0
- package/dist/webdav/middewares/auth.middleware.d.ts +3 -0
- package/dist/webdav/middewares/auth.middleware.js +27 -0
- package/dist/webdav/middewares/errors.middleware.d.ts +2 -0
- package/dist/webdav/middewares/errors.middleware.js +20 -0
- package/dist/webdav/middewares/request-logger.middleware.d.ts +7 -0
- package/dist/webdav/middewares/request-logger.middleware.js +15 -0
- package/dist/webdav/webdav-server.d.ts +25 -0
- package/dist/webdav/webdav-server.js +98 -0
- package/oclif.manifest.json +593 -0
- package/package.json +122 -0
package/.env
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
DRIVE_URL=https://drive.internxt.com
|
|
2
|
+
DRIVE_API_URL=https://drive.internxt.com/api
|
|
3
|
+
DRIVE_NEW_API_URL=https://api.internxt.com/drive
|
|
4
|
+
PAYMENTS_API_URL=https://api.internxt.com/payments
|
|
5
|
+
PHOTOS_API_URL=https://photos.internxt.com/api
|
|
6
|
+
APP_CRYPTO_SECRET=6KYQBP847D4ATSFA
|
|
7
|
+
APP_CRYPTO_SECRET2=8Q8VMUE3BJZV87GT
|
|
8
|
+
APP_MAGIC_IV=d139cb9a2cd17092e79e1861cf9d7023
|
|
9
|
+
APP_MAGIC_SALT=38dce0391b49efba88dbc8c39ebf868f0267eb110bb0012ab27dc52a528d61b1d1ed9d76f400ff58e3240028442b1eab9bb84e111d9dadd997982dbde9dbd25e
|
|
10
|
+
NETWORK_URL=https://api.internxt.com
|
|
11
|
+
WEBDAV_SERVER_PORT=3005
|
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Internxt CLI
|
|
2
|
+
|
|
3
|
+
[](https://github.com/internxt/cli/actions/workflows/commands-unit-tests.yml)
|
|
4
|
+
[](https://github.com/internxt/cli/actions/workflows/github-code-scanning/codeql)
|
|
5
|
+
|
|
6
|
+
A CLI tool to interact with yout Internxt encrypted files
|
|
7
|
+
|
|
8
|
+
<!-- toc -->
|
|
9
|
+
* [Internxt CLI](#internxt-cli)
|
|
10
|
+
* [Usage](#usage)
|
|
11
|
+
* [Commands](#commands)
|
|
12
|
+
<!-- tocstop -->
|
|
13
|
+
|
|
14
|
+
# Usage
|
|
15
|
+
|
|
16
|
+
<!-- usage -->
|
|
17
|
+
```sh-session
|
|
18
|
+
$ npm install -g @internxt/cli
|
|
19
|
+
$ internxt COMMAND
|
|
20
|
+
running command...
|
|
21
|
+
$ internxt (--version)
|
|
22
|
+
@internxt/cli/0.1.4 darwin-arm64 node-v18.16.1
|
|
23
|
+
$ internxt --help [COMMAND]
|
|
24
|
+
USAGE
|
|
25
|
+
$ internxt COMMAND
|
|
26
|
+
...
|
|
27
|
+
```
|
|
28
|
+
<!-- usagestop -->
|
|
29
|
+
|
|
30
|
+
# Commands
|
|
31
|
+
|
|
32
|
+
<!-- commands -->
|
|
33
|
+
* [`internxt config`](#internxt-config)
|
|
34
|
+
* [`internxt download`](#internxt-download)
|
|
35
|
+
* [`internxt list`](#internxt-list)
|
|
36
|
+
* [`internxt login`](#internxt-login)
|
|
37
|
+
* [`internxt logout`](#internxt-logout)
|
|
38
|
+
* [`internxt logs`](#internxt-logs)
|
|
39
|
+
* [`internxt move`](#internxt-move)
|
|
40
|
+
* [`internxt trash`](#internxt-trash)
|
|
41
|
+
* [`internxt upload`](#internxt-upload)
|
|
42
|
+
* [`internxt webdav ACTION`](#internxt-webdav-action)
|
|
43
|
+
* [`internxt whoami`](#internxt-whoami)
|
|
44
|
+
|
|
45
|
+
## `internxt config`
|
|
46
|
+
|
|
47
|
+
Display useful information from the user logged into the Internxt CLI.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
USAGE
|
|
51
|
+
$ internxt config [--columns <value> | -x] [--filter <value>] [--no-header | [--csv | --no-truncate]]
|
|
52
|
+
[--output csv|json|yaml | | ] [--sort <value>]
|
|
53
|
+
|
|
54
|
+
FLAGS
|
|
55
|
+
-x, --extended show extra columns
|
|
56
|
+
--columns=<value> only show provided columns (comma-separated)
|
|
57
|
+
--csv output is csv format [alias: --output=csv]
|
|
58
|
+
--filter=<value> filter property by partial string matching, ex: name=foo
|
|
59
|
+
--no-header hide table header from output
|
|
60
|
+
--no-truncate do not truncate output to fit screen
|
|
61
|
+
--output=<option> output in a more machine friendly format
|
|
62
|
+
<options: csv|json|yaml>
|
|
63
|
+
--sort=<value> property to sort by (prepend '-' for descending)
|
|
64
|
+
|
|
65
|
+
DESCRIPTION
|
|
66
|
+
Display useful information from the user logged into the Internxt CLI.
|
|
67
|
+
|
|
68
|
+
EXAMPLES
|
|
69
|
+
$ internxt config
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
_See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/config.ts)_
|
|
73
|
+
|
|
74
|
+
## `internxt download`
|
|
75
|
+
|
|
76
|
+
Download and decrypts a file from Internxt Drive to a directory. The file name will be the same as the file name in your Drive
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
USAGE
|
|
80
|
+
$ internxt download --id <value> --directory <value> [--overwrite]
|
|
81
|
+
|
|
82
|
+
FLAGS
|
|
83
|
+
--directory=<value> (required) The directory to download the file to.
|
|
84
|
+
--id=<value> (required) The id of the file to download. Use internxt list to view your files ids
|
|
85
|
+
--overwrite Overwrite the file if it already exists
|
|
86
|
+
|
|
87
|
+
DESCRIPTION
|
|
88
|
+
Download and decrypts a file from Internxt Drive to a directory. The file name will be the same as the file name in
|
|
89
|
+
your Drive
|
|
90
|
+
|
|
91
|
+
EXAMPLES
|
|
92
|
+
$ internxt download
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
_See code: [src/commands/download.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/download.ts)_
|
|
96
|
+
|
|
97
|
+
## `internxt list`
|
|
98
|
+
|
|
99
|
+
Lists the content of a folder id.
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
USAGE
|
|
103
|
+
$ internxt list [-n] [-f <value>] [--columns <value> | -x] [--filter <value>] [--no-header | [--csv |
|
|
104
|
+
--no-truncate]] [--output csv|json|yaml | | ] [--sort <value>]
|
|
105
|
+
|
|
106
|
+
FLAGS
|
|
107
|
+
-f, --id=<value> The folder id to list. Leave empty for the root folder.
|
|
108
|
+
-x, --extended show extra columns
|
|
109
|
+
--columns=<value> only show provided columns (comma-separated)
|
|
110
|
+
--csv output is csv format [alias: --output=csv]
|
|
111
|
+
--filter=<value> filter property by partial string matching, ex: name=foo
|
|
112
|
+
--no-header hide table header from output
|
|
113
|
+
--no-truncate do not truncate output to fit screen
|
|
114
|
+
--output=<option> output in a more machine friendly format
|
|
115
|
+
<options: csv|json|yaml>
|
|
116
|
+
--sort=<value> property to sort by (prepend '-' for descending)
|
|
117
|
+
|
|
118
|
+
HELPER FLAGS
|
|
119
|
+
-n, --non-interactive Blocks the cli from being interactive. If passed, the cli will not request data through the
|
|
120
|
+
console and will throw errors directly
|
|
121
|
+
|
|
122
|
+
DESCRIPTION
|
|
123
|
+
Lists the content of a folder id.
|
|
124
|
+
|
|
125
|
+
EXAMPLES
|
|
126
|
+
$ internxt list
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
_See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/list.ts)_
|
|
130
|
+
|
|
131
|
+
## `internxt login`
|
|
132
|
+
|
|
133
|
+
Logs into an Internxt account. If the account is two-factor protected, then an extra code will be required.
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
USAGE
|
|
137
|
+
$ internxt login [-n] [-e <value>] [-p <value>] [-w <value>]
|
|
138
|
+
|
|
139
|
+
FLAGS
|
|
140
|
+
-e, --email=<value> The email to log in
|
|
141
|
+
-p, --password=<value> The plain password to log in
|
|
142
|
+
-w, --twofactor=123456 The two factor auth code (only needed if the account is two-factor protected)
|
|
143
|
+
|
|
144
|
+
HELPER FLAGS
|
|
145
|
+
-n, --non-interactive Blocks the cli from being interactive. If passed, the cli will not request data through the
|
|
146
|
+
console and will throw errors directly
|
|
147
|
+
|
|
148
|
+
DESCRIPTION
|
|
149
|
+
Logs into an Internxt account. If the account is two-factor protected, then an extra code will be required.
|
|
150
|
+
|
|
151
|
+
EXAMPLES
|
|
152
|
+
$ internxt login
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
_See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/login.ts)_
|
|
156
|
+
|
|
157
|
+
## `internxt logout`
|
|
158
|
+
|
|
159
|
+
Logs out the current internxt user that is logged into the Internxt CLI.
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
USAGE
|
|
163
|
+
$ internxt logout
|
|
164
|
+
|
|
165
|
+
DESCRIPTION
|
|
166
|
+
Logs out the current internxt user that is logged into the Internxt CLI.
|
|
167
|
+
|
|
168
|
+
EXAMPLES
|
|
169
|
+
$ internxt logout
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
_See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/logout.ts)_
|
|
173
|
+
|
|
174
|
+
## `internxt logs`
|
|
175
|
+
|
|
176
|
+
Displays the Internxt CLI logs directory path
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
USAGE
|
|
180
|
+
$ internxt logs
|
|
181
|
+
|
|
182
|
+
DESCRIPTION
|
|
183
|
+
Displays the Internxt CLI logs directory path
|
|
184
|
+
|
|
185
|
+
EXAMPLES
|
|
186
|
+
$ internxt logs
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
_See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/logs.ts)_
|
|
190
|
+
|
|
191
|
+
## `internxt move`
|
|
192
|
+
|
|
193
|
+
Move a folder/file into a destination folder.
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
USAGE
|
|
197
|
+
$ internxt move [-n] [-i <value>] [-d <value>]
|
|
198
|
+
|
|
199
|
+
FLAGS
|
|
200
|
+
-d, --destination=<value> The destination folder id where the item is going to be moved.
|
|
201
|
+
-i, --id=<value> The item id to be moved (it can be a file id or a folder id).
|
|
202
|
+
|
|
203
|
+
HELPER FLAGS
|
|
204
|
+
-n, --non-interactive Blocks the cli from being interactive. If passed, the cli will not request data through the
|
|
205
|
+
console and will throw errors directly
|
|
206
|
+
|
|
207
|
+
DESCRIPTION
|
|
208
|
+
Move a folder/file into a destination folder.
|
|
209
|
+
|
|
210
|
+
EXAMPLES
|
|
211
|
+
$ internxt move
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
_See code: [src/commands/move.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/move.ts)_
|
|
215
|
+
|
|
216
|
+
## `internxt trash`
|
|
217
|
+
|
|
218
|
+
Moves a given folder/file to the trash.
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
USAGE
|
|
222
|
+
$ internxt trash [-n] [-i <value>]
|
|
223
|
+
|
|
224
|
+
FLAGS
|
|
225
|
+
-i, --id=<value> The item id to be trashed (it can be a file id or a folder id).
|
|
226
|
+
|
|
227
|
+
HELPER FLAGS
|
|
228
|
+
-n, --non-interactive Blocks the cli from being interactive. If passed, the cli will not request data through the
|
|
229
|
+
console and will throw errors directly
|
|
230
|
+
|
|
231
|
+
DESCRIPTION
|
|
232
|
+
Moves a given folder/file to the trash.
|
|
233
|
+
|
|
234
|
+
EXAMPLES
|
|
235
|
+
$ internxt trash
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
_See code: [src/commands/trash.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/trash.ts)_
|
|
239
|
+
|
|
240
|
+
## `internxt upload`
|
|
241
|
+
|
|
242
|
+
Upload a file to Internxt Drive
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
USAGE
|
|
246
|
+
$ internxt upload --file <value> [--json] [--id <value>]
|
|
247
|
+
|
|
248
|
+
FLAGS
|
|
249
|
+
--file=<value> (required) The path to read the file in your system
|
|
250
|
+
--id=<value> The folder id to upload the file to
|
|
251
|
+
|
|
252
|
+
GLOBAL FLAGS
|
|
253
|
+
--json Format output as json.
|
|
254
|
+
|
|
255
|
+
DESCRIPTION
|
|
256
|
+
Upload a file to Internxt Drive
|
|
257
|
+
|
|
258
|
+
EXAMPLES
|
|
259
|
+
$ internxt upload
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
_See code: [src/commands/upload.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/upload.ts)_
|
|
263
|
+
|
|
264
|
+
## `internxt webdav ACTION`
|
|
265
|
+
|
|
266
|
+
Enable or disable the Internxt CLI WebDav server
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
USAGE
|
|
270
|
+
$ internxt webdav ACTION
|
|
271
|
+
|
|
272
|
+
DESCRIPTION
|
|
273
|
+
Enable or disable the Internxt CLI WebDav server
|
|
274
|
+
|
|
275
|
+
EXAMPLES
|
|
276
|
+
$ internxt webdav
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
_See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/webdav.ts)_
|
|
280
|
+
|
|
281
|
+
## `internxt whoami`
|
|
282
|
+
|
|
283
|
+
Display the current user logged into the Internxt CLI.
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
USAGE
|
|
287
|
+
$ internxt whoami
|
|
288
|
+
|
|
289
|
+
DESCRIPTION
|
|
290
|
+
Display the current user logged into the Internxt CLI.
|
|
291
|
+
|
|
292
|
+
EXAMPLES
|
|
293
|
+
$ internxt whoami
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
_See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v0.1.4/src/commands/whoami.ts)_
|
|
297
|
+
<!-- commandsstop -->
|
package/bin/dev.cmd
ADDED
package/bin/dev.js
ADDED
package/bin/run.cmd
ADDED
package/bin/run.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Config extends Command {
|
|
3
|
+
static readonly args: {};
|
|
4
|
+
static readonly description = "Display useful information from the user logged into the Internxt CLI.";
|
|
5
|
+
static readonly examples: string[];
|
|
6
|
+
static readonly flags: {
|
|
7
|
+
columns: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
8
|
+
csv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
filter: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
11
|
+
'no-header': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
'no-truncate': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
14
|
+
sort: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
15
|
+
};
|
|
16
|
+
catch(error: Error): Promise<void>;
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const config_service_1 = require("../services/config.service");
|
|
5
|
+
const cli_utils_1 = require("../utils/cli.utils");
|
|
6
|
+
const errors_utils_1 = require("../utils/errors.utils");
|
|
7
|
+
const usage_service_1 = require("../services/usage.service");
|
|
8
|
+
const format_utils_1 = require("../utils/format.utils");
|
|
9
|
+
class Config extends core_1.Command {
|
|
10
|
+
static args = {};
|
|
11
|
+
static description = 'Display useful information from the user logged into the Internxt CLI.';
|
|
12
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
13
|
+
static flags = {
|
|
14
|
+
...core_1.ux.table.flags(),
|
|
15
|
+
};
|
|
16
|
+
async catch(error) {
|
|
17
|
+
errors_utils_1.ErrorUtils.report(error, { command: this.id });
|
|
18
|
+
cli_utils_1.CLIUtils.error(error.message);
|
|
19
|
+
this.exit(1);
|
|
20
|
+
}
|
|
21
|
+
async run() {
|
|
22
|
+
const { flags } = await this.parse(Config);
|
|
23
|
+
const userCredentials = await config_service_1.ConfigService.instance.readUser();
|
|
24
|
+
if (userCredentials?.user) {
|
|
25
|
+
const configList = [
|
|
26
|
+
{ key: 'Email', value: userCredentials.user.email },
|
|
27
|
+
{ key: 'Root folder ID', value: userCredentials.root_folder_uuid },
|
|
28
|
+
{ key: 'Used space', value: format_utils_1.FormatUtils.humanFileSize(await usage_service_1.UsageService.instance.fetchTotalUsage()) },
|
|
29
|
+
{ key: 'Available space', value: format_utils_1.FormatUtils.formatLimit(await usage_service_1.UsageService.instance.fetchSpaceLimit()) },
|
|
30
|
+
];
|
|
31
|
+
core_1.ux.table(configList, {
|
|
32
|
+
key: {
|
|
33
|
+
header: 'Key',
|
|
34
|
+
get: (row) => row.key,
|
|
35
|
+
},
|
|
36
|
+
value: {
|
|
37
|
+
header: 'Value',
|
|
38
|
+
get: (row) => row.value,
|
|
39
|
+
},
|
|
40
|
+
}, {
|
|
41
|
+
printLine: this.log.bind(this),
|
|
42
|
+
...flags,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
cli_utils_1.CLIUtils.error('You are not logged in');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = Config;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { NetworkFacade } from '../services/network/network-facade.service';
|
|
3
|
+
import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings';
|
|
4
|
+
import { DriveFileItem } from '../types/drive.types';
|
|
5
|
+
export default class Download extends Command {
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
id: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
directory: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
catch(error: Error): Promise<void>;
|
|
14
|
+
getFileMetadata: (uuid: string) => Promise<DriveFileItem>;
|
|
15
|
+
getUser: () => Promise<UserSettings>;
|
|
16
|
+
getDownloadPath: (downloadDirectory: string, driveFile: DriveFileItem, overwrite: boolean) => Promise<string>;
|
|
17
|
+
prepareNetwork: (user: UserSettings) => Promise<NetworkFacade>;
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = require("@oclif/core");
|
|
7
|
+
const drive_file_service_1 = require("../services/drive/drive-file.service");
|
|
8
|
+
const cli_utils_1 = require("../utils/cli.utils");
|
|
9
|
+
const network_facade_service_1 = require("../services/network/network-facade.service");
|
|
10
|
+
const auth_service_1 = require("../services/auth.service");
|
|
11
|
+
const crypto_service_1 = require("../services/crypto.service");
|
|
12
|
+
const download_service_1 = require("../services/network/download.service");
|
|
13
|
+
const upload_service_1 = require("../services/network/upload.service");
|
|
14
|
+
const sdk_manager_service_1 = require("../services/sdk-manager.service");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const stream_utils_1 = require("../utils/stream.utils");
|
|
19
|
+
const errors_utils_1 = require("../utils/errors.utils");
|
|
20
|
+
class Download extends core_1.Command {
|
|
21
|
+
static description = 'Download and decrypts a file from Internxt Drive to a directory. The file name will be the same as the file name in your Drive';
|
|
22
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
23
|
+
static flags = {
|
|
24
|
+
overwrite: core_1.Flags.boolean({ description: 'Overwrite the file if it already exists', default: false }),
|
|
25
|
+
id: core_1.Flags.string({
|
|
26
|
+
description: 'The id of the file to download. Use <%= config.bin %> list to view your files ids',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
directory: core_1.Flags.string({
|
|
30
|
+
description: 'The directory to download the file to.',
|
|
31
|
+
required: true,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
async catch(error) {
|
|
35
|
+
errors_utils_1.ErrorUtils.report(error, { command: this.id });
|
|
36
|
+
cli_utils_1.CLIUtils.error(error.message);
|
|
37
|
+
this.exit(1);
|
|
38
|
+
}
|
|
39
|
+
getFileMetadata = async (uuid) => {
|
|
40
|
+
cli_utils_1.CLIUtils.doing('Getting file metadata');
|
|
41
|
+
const driveFile = await drive_file_service_1.DriveFileService.instance.getFileMetadata(uuid);
|
|
42
|
+
cli_utils_1.CLIUtils.done();
|
|
43
|
+
if (!driveFile) {
|
|
44
|
+
throw new Error('File not found');
|
|
45
|
+
}
|
|
46
|
+
return driveFile;
|
|
47
|
+
};
|
|
48
|
+
getUser = async () => {
|
|
49
|
+
const { mnemonic } = await auth_service_1.AuthService.instance.getAuthDetails();
|
|
50
|
+
const user = await auth_service_1.AuthService.instance.getUser();
|
|
51
|
+
return {
|
|
52
|
+
...user,
|
|
53
|
+
mnemonic,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
getDownloadPath = async (downloadDirectory, driveFile, overwrite) => {
|
|
57
|
+
const filename = path_1.default.format({
|
|
58
|
+
name: driveFile.name,
|
|
59
|
+
ext: `.${driveFile.type}`,
|
|
60
|
+
});
|
|
61
|
+
const downloadPath = path_1.default.join(downloadDirectory, filename);
|
|
62
|
+
await promises_1.default.access(downloadDirectory, promises_1.default.constants.W_OK);
|
|
63
|
+
try {
|
|
64
|
+
const stat = await promises_1.default.stat(downloadPath);
|
|
65
|
+
if (stat.isFile() && !overwrite) {
|
|
66
|
+
throw new Error('File already exists, use --overwrite flag to overwrite it');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
if (err.code !== 'ENOENT') {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return downloadPath;
|
|
75
|
+
};
|
|
76
|
+
prepareNetwork = async (user) => {
|
|
77
|
+
cli_utils_1.CLIUtils.doing('Preparing Network');
|
|
78
|
+
const networkModule = sdk_manager_service_1.SdkManager.instance.getNetwork({
|
|
79
|
+
user: user.bridgeUser,
|
|
80
|
+
pass: user.userId,
|
|
81
|
+
});
|
|
82
|
+
const networkFacade = new network_facade_service_1.NetworkFacade(networkModule, upload_service_1.UploadService.instance, download_service_1.DownloadService.instance, crypto_service_1.CryptoService.instance);
|
|
83
|
+
cli_utils_1.CLIUtils.done();
|
|
84
|
+
return networkFacade;
|
|
85
|
+
};
|
|
86
|
+
async run() {
|
|
87
|
+
const { flags } = await this.parse(Download);
|
|
88
|
+
const { directory: downloadDirectory, id: fileUuid, overwrite } = flags;
|
|
89
|
+
const directoryStat = await promises_1.default.stat(downloadDirectory);
|
|
90
|
+
if (!directoryStat.isDirectory()) {
|
|
91
|
+
throw new Error('The directory provided is not a directory');
|
|
92
|
+
}
|
|
93
|
+
const driveFile = await this.getFileMetadata(fileUuid);
|
|
94
|
+
const downloadPath = await this.getDownloadPath(downloadDirectory, driveFile, overwrite);
|
|
95
|
+
const user = await this.getUser();
|
|
96
|
+
const networkFacade = await this.prepareNetwork(user);
|
|
97
|
+
const fileWriteStream = (0, fs_1.createWriteStream)(downloadPath);
|
|
98
|
+
const progressBar = core_1.ux.progress({
|
|
99
|
+
format: 'Downloading file [{bar}] {percentage}%',
|
|
100
|
+
linewrap: true,
|
|
101
|
+
});
|
|
102
|
+
progressBar.start(100, 0);
|
|
103
|
+
const [executeDownload, abortable] = await networkFacade.downloadToStream(user.bucket, user.mnemonic, driveFile.fileId, stream_utils_1.StreamUtils.writeStreamToWritableStream(fileWriteStream), {
|
|
104
|
+
abortController: new AbortController(),
|
|
105
|
+
progressCallback: (progress) => {
|
|
106
|
+
progressBar.update(progress);
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
process.on('SIGINT', () => {
|
|
110
|
+
abortable.abort('SIGINT received');
|
|
111
|
+
process.exit(1);
|
|
112
|
+
});
|
|
113
|
+
await executeDownload;
|
|
114
|
+
progressBar.update(100);
|
|
115
|
+
progressBar.stop();
|
|
116
|
+
cli_utils_1.CLIUtils.success(`File downloaded successfully to ${downloadPath}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.default = Download;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class List extends Command {
|
|
3
|
+
static readonly args: {};
|
|
4
|
+
static readonly description = "Lists the content of a folder id.";
|
|
5
|
+
static readonly examples: string[];
|
|
6
|
+
static readonly flags: {
|
|
7
|
+
columns: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
8
|
+
csv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
filter: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
11
|
+
'no-header': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
'no-truncate': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
14
|
+
sort: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
15
|
+
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
catch(error: Error): Promise<void>;
|
|
20
|
+
getFolderUuid: (folderUuidFlag: string | undefined, nonInteractive: boolean) => Promise<string>;
|
|
21
|
+
getFolderUuidInteractively: () => Promise<string>;
|
|
22
|
+
}
|