node-appwrite 7.0.2 → 8.0.0-RC1
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/LICENSE +1 -1
- package/README.md +2 -2
- package/docs/examples/databases/create-boolean-attribute.md +2 -2
- package/docs/examples/databases/create-collection.md +2 -2
- package/docs/examples/databases/create-datetime-attribute.md +20 -0
- package/docs/examples/databases/create-document.md +2 -2
- package/docs/examples/databases/create-email-attribute.md +2 -2
- package/docs/examples/databases/create-enum-attribute.md +2 -2
- package/docs/examples/databases/create-float-attribute.md +2 -2
- package/docs/examples/databases/create-index.md +2 -2
- package/docs/examples/databases/create-integer-attribute.md +2 -2
- package/docs/examples/databases/create-ip-attribute.md +2 -2
- package/docs/examples/databases/create-string-attribute.md +2 -2
- package/docs/examples/databases/create-url-attribute.md +2 -2
- package/docs/examples/databases/create.md +2 -2
- package/docs/examples/databases/delete-attribute.md +2 -2
- package/docs/examples/databases/delete-collection.md +2 -2
- package/docs/examples/databases/delete-document.md +2 -2
- package/docs/examples/databases/delete-index.md +2 -2
- package/docs/examples/databases/delete.md +2 -2
- package/docs/examples/databases/get-attribute.md +2 -2
- package/docs/examples/databases/get-collection.md +2 -2
- package/docs/examples/databases/get-document.md +2 -2
- package/docs/examples/databases/get-index.md +2 -2
- package/docs/examples/databases/get.md +2 -2
- package/docs/examples/databases/list-attributes.md +2 -2
- package/docs/examples/databases/list-collections.md +2 -2
- package/docs/examples/databases/list-documents.md +2 -2
- package/docs/examples/databases/list-indexes.md +2 -2
- package/docs/examples/databases/list.md +1 -1
- package/docs/examples/databases/update-collection.md +2 -2
- package/docs/examples/databases/update-document.md +2 -2
- package/docs/examples/databases/update.md +2 -2
- package/docs/examples/functions/create-deployment.md +1 -1
- package/docs/examples/functions/create-variable.md +20 -0
- package/docs/examples/functions/create.md +1 -1
- package/docs/examples/functions/delete-variable.md +20 -0
- package/docs/examples/functions/get-variable.md +20 -0
- package/docs/examples/functions/list-variables.md +20 -0
- package/docs/examples/functions/update-variable.md +20 -0
- package/docs/examples/functions/update.md +1 -1
- package/docs/examples/storage/create-bucket.md +1 -1
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/storage/update-bucket.md +1 -1
- package/docs/examples/users/create-argon2user.md +20 -0
- package/docs/examples/users/create-bcrypt-user.md +20 -0
- package/docs/examples/users/create-m-d5user.md +20 -0
- package/docs/examples/users/create-p-h-pass-user.md +20 -0
- package/docs/examples/users/create-s-h-a-user.md +20 -0
- package/docs/examples/users/create-scrypt-modified-user.md +20 -0
- package/docs/examples/users/create-scrypt-user.md +20 -0
- package/docs/examples/users/create.md +1 -1
- package/index.d.ts +714 -262
- package/index.js +6 -0
- package/lib/client.js +5 -2
- package/lib/id.js +12 -0
- package/lib/permission.js +24 -0
- package/lib/query.js +30 -12
- package/lib/role.js +25 -0
- package/lib/services/account.js +43 -42
- package/lib/services/avatars.js +22 -20
- package/lib/services/databases.js +385 -243
- package/lib/services/functions.js +219 -109
- package/lib/services/health.js +7 -1
- package/lib/services/locale.js +7 -1
- package/lib/services/storage.js +78 -129
- package/lib/services/teams.js +39 -73
- package/lib/services/users.js +482 -63
- package/package.json +1 -1
package/lib/services/users.js
CHANGED
|
@@ -8,58 +8,93 @@ const fs = require('fs');
|
|
|
8
8
|
|
|
9
9
|
class Users extends Service {
|
|
10
10
|
|
|
11
|
+
constructor(client)
|
|
12
|
+
{
|
|
13
|
+
super(client);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
11
17
|
/**
|
|
12
18
|
* List Users
|
|
13
19
|
*
|
|
14
20
|
* Get a list of all the project's users. You can use the query params to
|
|
15
21
|
* filter your results.
|
|
16
22
|
*
|
|
23
|
+
* @param {string[]} queries
|
|
17
24
|
* @param {string} search
|
|
18
|
-
* @param {number} limit
|
|
19
|
-
* @param {number} offset
|
|
20
|
-
* @param {string} cursor
|
|
21
|
-
* @param {string} cursorDirection
|
|
22
|
-
* @param {string} orderType
|
|
23
25
|
* @throws {AppwriteException}
|
|
24
26
|
* @returns {Promise}
|
|
25
27
|
*/
|
|
26
|
-
async list(
|
|
28
|
+
async list(queries, search) {
|
|
27
29
|
let path = '/users';
|
|
28
30
|
let payload = {};
|
|
29
31
|
|
|
32
|
+
if (typeof queries !== 'undefined') {
|
|
33
|
+
payload['queries'] = queries;
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
if (typeof search !== 'undefined') {
|
|
31
37
|
payload['search'] = search;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
return await this.client.call('get', path, {
|
|
41
|
+
'content-type': 'application/json',
|
|
42
|
+
}, payload);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create User
|
|
47
|
+
*
|
|
48
|
+
* Create a new user.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} userId
|
|
51
|
+
* @param {string} email
|
|
52
|
+
* @param {string} phone
|
|
53
|
+
* @param {string} password
|
|
54
|
+
* @param {string} name
|
|
55
|
+
* @throws {AppwriteException}
|
|
56
|
+
* @returns {Promise}
|
|
57
|
+
*/
|
|
58
|
+
async create(userId, email, phone, password, name) {
|
|
59
|
+
let path = '/users';
|
|
60
|
+
let payload = {};
|
|
61
|
+
if (typeof userId === 'undefined') {
|
|
62
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if (typeof userId !== 'undefined') {
|
|
67
|
+
payload['userId'] = userId;
|
|
36
68
|
}
|
|
37
69
|
|
|
38
|
-
if (typeof
|
|
39
|
-
payload['
|
|
70
|
+
if (typeof email !== 'undefined') {
|
|
71
|
+
payload['email'] = email;
|
|
40
72
|
}
|
|
41
73
|
|
|
42
|
-
if (typeof
|
|
43
|
-
payload['
|
|
74
|
+
if (typeof phone !== 'undefined') {
|
|
75
|
+
payload['phone'] = phone;
|
|
44
76
|
}
|
|
45
77
|
|
|
46
|
-
if (typeof
|
|
47
|
-
payload['
|
|
78
|
+
if (typeof password !== 'undefined') {
|
|
79
|
+
payload['password'] = password;
|
|
48
80
|
}
|
|
49
81
|
|
|
50
|
-
if (typeof
|
|
51
|
-
payload['
|
|
82
|
+
if (typeof name !== 'undefined') {
|
|
83
|
+
payload['name'] = name;
|
|
52
84
|
}
|
|
53
85
|
|
|
54
|
-
return await this.client.call('
|
|
86
|
+
return await this.client.call('post', path, {
|
|
55
87
|
'content-type': 'application/json',
|
|
56
88
|
}, payload);
|
|
57
89
|
}
|
|
58
90
|
|
|
59
91
|
/**
|
|
60
|
-
* Create User
|
|
92
|
+
* Create User with Argon2 Password
|
|
61
93
|
*
|
|
62
|
-
* Create a new user.
|
|
94
|
+
* Create a new user. Password provided must be hashed with the
|
|
95
|
+
* [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST
|
|
96
|
+
* /users](/docs/server/users#usersCreate) endpoint to create users with a
|
|
97
|
+
* plain text password.
|
|
63
98
|
*
|
|
64
99
|
* @param {string} userId
|
|
65
100
|
* @param {string} email
|
|
@@ -68,7 +103,9 @@ class Users extends Service {
|
|
|
68
103
|
* @throws {AppwriteException}
|
|
69
104
|
* @returns {Promise}
|
|
70
105
|
*/
|
|
71
|
-
async
|
|
106
|
+
async createArgon2User(userId, email, password, name) {
|
|
107
|
+
let path = '/users/argon2';
|
|
108
|
+
let payload = {};
|
|
72
109
|
if (typeof userId === 'undefined') {
|
|
73
110
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
74
111
|
}
|
|
@@ -81,8 +118,110 @@ class Users extends Service {
|
|
|
81
118
|
throw new AppwriteException('Missing required parameter: "password"');
|
|
82
119
|
}
|
|
83
120
|
|
|
84
|
-
|
|
121
|
+
|
|
122
|
+
if (typeof userId !== 'undefined') {
|
|
123
|
+
payload['userId'] = userId;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (typeof email !== 'undefined') {
|
|
127
|
+
payload['email'] = email;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (typeof password !== 'undefined') {
|
|
131
|
+
payload['password'] = password;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (typeof name !== 'undefined') {
|
|
135
|
+
payload['name'] = name;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return await this.client.call('post', path, {
|
|
139
|
+
'content-type': 'application/json',
|
|
140
|
+
}, payload);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Create User with Bcrypt Password
|
|
145
|
+
*
|
|
146
|
+
* Create a new user. Password provided must be hashed with the
|
|
147
|
+
* [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST
|
|
148
|
+
* /users](/docs/server/users#usersCreate) endpoint to create users with a
|
|
149
|
+
* plain text password.
|
|
150
|
+
*
|
|
151
|
+
* @param {string} userId
|
|
152
|
+
* @param {string} email
|
|
153
|
+
* @param {string} password
|
|
154
|
+
* @param {string} name
|
|
155
|
+
* @throws {AppwriteException}
|
|
156
|
+
* @returns {Promise}
|
|
157
|
+
*/
|
|
158
|
+
async createBcryptUser(userId, email, password, name) {
|
|
159
|
+
let path = '/users/bcrypt';
|
|
160
|
+
let payload = {};
|
|
161
|
+
if (typeof userId === 'undefined') {
|
|
162
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (typeof email === 'undefined') {
|
|
166
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (typeof password === 'undefined') {
|
|
170
|
+
throw new AppwriteException('Missing required parameter: "password"');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
if (typeof userId !== 'undefined') {
|
|
175
|
+
payload['userId'] = userId;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (typeof email !== 'undefined') {
|
|
179
|
+
payload['email'] = email;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (typeof password !== 'undefined') {
|
|
183
|
+
payload['password'] = password;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (typeof name !== 'undefined') {
|
|
187
|
+
payload['name'] = name;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return await this.client.call('post', path, {
|
|
191
|
+
'content-type': 'application/json',
|
|
192
|
+
}, payload);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Create User with MD5 Password
|
|
197
|
+
*
|
|
198
|
+
* Create a new user. Password provided must be hashed with the
|
|
199
|
+
* [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST
|
|
200
|
+
* /users](/docs/server/users#usersCreate) endpoint to create users with a
|
|
201
|
+
* plain text password.
|
|
202
|
+
*
|
|
203
|
+
* @param {string} userId
|
|
204
|
+
* @param {string} email
|
|
205
|
+
* @param {string} password
|
|
206
|
+
* @param {string} name
|
|
207
|
+
* @throws {AppwriteException}
|
|
208
|
+
* @returns {Promise}
|
|
209
|
+
*/
|
|
210
|
+
async createMD5User(userId, email, password, name) {
|
|
211
|
+
let path = '/users/md5';
|
|
85
212
|
let payload = {};
|
|
213
|
+
if (typeof userId === 'undefined') {
|
|
214
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (typeof email === 'undefined') {
|
|
218
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (typeof password === 'undefined') {
|
|
222
|
+
throw new AppwriteException('Missing required parameter: "password"');
|
|
223
|
+
}
|
|
224
|
+
|
|
86
225
|
|
|
87
226
|
if (typeof userId !== 'undefined') {
|
|
88
227
|
payload['userId'] = userId;
|
|
@@ -105,6 +244,291 @@ class Users extends Service {
|
|
|
105
244
|
}, payload);
|
|
106
245
|
}
|
|
107
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Create User with PHPass Password
|
|
249
|
+
*
|
|
250
|
+
* Create a new user. Password provided must be hashed with the
|
|
251
|
+
* [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST
|
|
252
|
+
* /users](/docs/server/users#usersCreate) endpoint to create users with a
|
|
253
|
+
* plain text password.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} userId
|
|
256
|
+
* @param {string} email
|
|
257
|
+
* @param {string} password
|
|
258
|
+
* @param {string} name
|
|
259
|
+
* @throws {AppwriteException}
|
|
260
|
+
* @returns {Promise}
|
|
261
|
+
*/
|
|
262
|
+
async createPHPassUser(userId, email, password, name) {
|
|
263
|
+
let path = '/users/phpass';
|
|
264
|
+
let payload = {};
|
|
265
|
+
if (typeof userId === 'undefined') {
|
|
266
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (typeof email === 'undefined') {
|
|
270
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (typeof password === 'undefined') {
|
|
274
|
+
throw new AppwriteException('Missing required parameter: "password"');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
if (typeof userId !== 'undefined') {
|
|
279
|
+
payload['userId'] = userId;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (typeof email !== 'undefined') {
|
|
283
|
+
payload['email'] = email;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (typeof password !== 'undefined') {
|
|
287
|
+
payload['password'] = password;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (typeof name !== 'undefined') {
|
|
291
|
+
payload['name'] = name;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return await this.client.call('post', path, {
|
|
295
|
+
'content-type': 'application/json',
|
|
296
|
+
}, payload);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Create User with Scrypt Password
|
|
301
|
+
*
|
|
302
|
+
* Create a new user. Password provided must be hashed with the
|
|
303
|
+
* [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST
|
|
304
|
+
* /users](/docs/server/users#usersCreate) endpoint to create users with a
|
|
305
|
+
* plain text password.
|
|
306
|
+
*
|
|
307
|
+
* @param {string} userId
|
|
308
|
+
* @param {string} email
|
|
309
|
+
* @param {string} password
|
|
310
|
+
* @param {string} passwordSalt
|
|
311
|
+
* @param {number} passwordCpu
|
|
312
|
+
* @param {number} passwordMemory
|
|
313
|
+
* @param {number} passwordParallel
|
|
314
|
+
* @param {number} passwordLength
|
|
315
|
+
* @param {string} name
|
|
316
|
+
* @throws {AppwriteException}
|
|
317
|
+
* @returns {Promise}
|
|
318
|
+
*/
|
|
319
|
+
async createScryptUser(userId, email, password, passwordSalt, passwordCpu, passwordMemory, passwordParallel, passwordLength, name) {
|
|
320
|
+
let path = '/users/scrypt';
|
|
321
|
+
let payload = {};
|
|
322
|
+
if (typeof userId === 'undefined') {
|
|
323
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (typeof email === 'undefined') {
|
|
327
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (typeof password === 'undefined') {
|
|
331
|
+
throw new AppwriteException('Missing required parameter: "password"');
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (typeof passwordSalt === 'undefined') {
|
|
335
|
+
throw new AppwriteException('Missing required parameter: "passwordSalt"');
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (typeof passwordCpu === 'undefined') {
|
|
339
|
+
throw new AppwriteException('Missing required parameter: "passwordCpu"');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (typeof passwordMemory === 'undefined') {
|
|
343
|
+
throw new AppwriteException('Missing required parameter: "passwordMemory"');
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (typeof passwordParallel === 'undefined') {
|
|
347
|
+
throw new AppwriteException('Missing required parameter: "passwordParallel"');
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (typeof passwordLength === 'undefined') {
|
|
351
|
+
throw new AppwriteException('Missing required parameter: "passwordLength"');
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
if (typeof userId !== 'undefined') {
|
|
356
|
+
payload['userId'] = userId;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (typeof email !== 'undefined') {
|
|
360
|
+
payload['email'] = email;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (typeof password !== 'undefined') {
|
|
364
|
+
payload['password'] = password;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (typeof passwordSalt !== 'undefined') {
|
|
368
|
+
payload['passwordSalt'] = passwordSalt;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (typeof passwordCpu !== 'undefined') {
|
|
372
|
+
payload['passwordCpu'] = passwordCpu;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (typeof passwordMemory !== 'undefined') {
|
|
376
|
+
payload['passwordMemory'] = passwordMemory;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (typeof passwordParallel !== 'undefined') {
|
|
380
|
+
payload['passwordParallel'] = passwordParallel;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (typeof passwordLength !== 'undefined') {
|
|
384
|
+
payload['passwordLength'] = passwordLength;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (typeof name !== 'undefined') {
|
|
388
|
+
payload['name'] = name;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return await this.client.call('post', path, {
|
|
392
|
+
'content-type': 'application/json',
|
|
393
|
+
}, payload);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Create User with Scrypt Modified Password
|
|
398
|
+
*
|
|
399
|
+
* Create a new user. Password provided must be hashed with the [Scrypt
|
|
400
|
+
* Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc)
|
|
401
|
+
* algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint
|
|
402
|
+
* to create users with a plain text password.
|
|
403
|
+
*
|
|
404
|
+
* @param {string} userId
|
|
405
|
+
* @param {string} email
|
|
406
|
+
* @param {string} password
|
|
407
|
+
* @param {string} passwordSalt
|
|
408
|
+
* @param {string} passwordSaltSeparator
|
|
409
|
+
* @param {string} passwordSignerKey
|
|
410
|
+
* @param {string} name
|
|
411
|
+
* @throws {AppwriteException}
|
|
412
|
+
* @returns {Promise}
|
|
413
|
+
*/
|
|
414
|
+
async createScryptModifiedUser(userId, email, password, passwordSalt, passwordSaltSeparator, passwordSignerKey, name) {
|
|
415
|
+
let path = '/users/scrypt-modified';
|
|
416
|
+
let payload = {};
|
|
417
|
+
if (typeof userId === 'undefined') {
|
|
418
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (typeof email === 'undefined') {
|
|
422
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (typeof password === 'undefined') {
|
|
426
|
+
throw new AppwriteException('Missing required parameter: "password"');
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (typeof passwordSalt === 'undefined') {
|
|
430
|
+
throw new AppwriteException('Missing required parameter: "passwordSalt"');
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (typeof passwordSaltSeparator === 'undefined') {
|
|
434
|
+
throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"');
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (typeof passwordSignerKey === 'undefined') {
|
|
438
|
+
throw new AppwriteException('Missing required parameter: "passwordSignerKey"');
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
if (typeof userId !== 'undefined') {
|
|
443
|
+
payload['userId'] = userId;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (typeof email !== 'undefined') {
|
|
447
|
+
payload['email'] = email;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (typeof password !== 'undefined') {
|
|
451
|
+
payload['password'] = password;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (typeof passwordSalt !== 'undefined') {
|
|
455
|
+
payload['passwordSalt'] = passwordSalt;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (typeof passwordSaltSeparator !== 'undefined') {
|
|
459
|
+
payload['passwordSaltSeparator'] = passwordSaltSeparator;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (typeof passwordSignerKey !== 'undefined') {
|
|
463
|
+
payload['passwordSignerKey'] = passwordSignerKey;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (typeof name !== 'undefined') {
|
|
467
|
+
payload['name'] = name;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return await this.client.call('post', path, {
|
|
471
|
+
'content-type': 'application/json',
|
|
472
|
+
}, payload);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Create User with SHA Password
|
|
477
|
+
*
|
|
478
|
+
* Create a new user. Password provided must be hashed with the
|
|
479
|
+
* [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use
|
|
480
|
+
* the [POST /users](/docs/server/users#usersCreate) endpoint to create users
|
|
481
|
+
* with a plain text password.
|
|
482
|
+
*
|
|
483
|
+
* @param {string} userId
|
|
484
|
+
* @param {string} email
|
|
485
|
+
* @param {string} password
|
|
486
|
+
* @param {string} passwordVersion
|
|
487
|
+
* @param {string} name
|
|
488
|
+
* @throws {AppwriteException}
|
|
489
|
+
* @returns {Promise}
|
|
490
|
+
*/
|
|
491
|
+
async createSHAUser(userId, email, password, passwordVersion, name) {
|
|
492
|
+
let path = '/users/sha';
|
|
493
|
+
let payload = {};
|
|
494
|
+
if (typeof userId === 'undefined') {
|
|
495
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (typeof email === 'undefined') {
|
|
499
|
+
throw new AppwriteException('Missing required parameter: "email"');
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (typeof password === 'undefined') {
|
|
503
|
+
throw new AppwriteException('Missing required parameter: "password"');
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
if (typeof userId !== 'undefined') {
|
|
508
|
+
payload['userId'] = userId;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (typeof email !== 'undefined') {
|
|
512
|
+
payload['email'] = email;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (typeof password !== 'undefined') {
|
|
516
|
+
payload['password'] = password;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (typeof passwordVersion !== 'undefined') {
|
|
520
|
+
payload['passwordVersion'] = passwordVersion;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (typeof name !== 'undefined') {
|
|
524
|
+
payload['name'] = name;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return await this.client.call('post', path, {
|
|
528
|
+
'content-type': 'application/json',
|
|
529
|
+
}, payload);
|
|
530
|
+
}
|
|
531
|
+
|
|
108
532
|
/**
|
|
109
533
|
* Get User
|
|
110
534
|
*
|
|
@@ -115,12 +539,12 @@ class Users extends Service {
|
|
|
115
539
|
* @returns {Promise}
|
|
116
540
|
*/
|
|
117
541
|
async get(userId) {
|
|
542
|
+
let path = '/users/{userId}'.replace('{userId}', userId);
|
|
543
|
+
let payload = {};
|
|
118
544
|
if (typeof userId === 'undefined') {
|
|
119
545
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
120
546
|
}
|
|
121
547
|
|
|
122
|
-
let path = '/users/{userId}'.replace('{userId}', userId);
|
|
123
|
-
let payload = {};
|
|
124
548
|
|
|
125
549
|
return await this.client.call('get', path, {
|
|
126
550
|
'content-type': 'application/json',
|
|
@@ -141,12 +565,12 @@ class Users extends Service {
|
|
|
141
565
|
* @returns {Promise}
|
|
142
566
|
*/
|
|
143
567
|
async delete(userId) {
|
|
568
|
+
let path = '/users/{userId}'.replace('{userId}', userId);
|
|
569
|
+
let payload = {};
|
|
144
570
|
if (typeof userId === 'undefined') {
|
|
145
571
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
146
572
|
}
|
|
147
573
|
|
|
148
|
-
let path = '/users/{userId}'.replace('{userId}', userId);
|
|
149
|
-
let payload = {};
|
|
150
574
|
|
|
151
575
|
return await this.client.call('delete', path, {
|
|
152
576
|
'content-type': 'application/json',
|
|
@@ -164,6 +588,8 @@ class Users extends Service {
|
|
|
164
588
|
* @returns {Promise}
|
|
165
589
|
*/
|
|
166
590
|
async updateEmail(userId, email) {
|
|
591
|
+
let path = '/users/{userId}/email'.replace('{userId}', userId);
|
|
592
|
+
let payload = {};
|
|
167
593
|
if (typeof userId === 'undefined') {
|
|
168
594
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
169
595
|
}
|
|
@@ -172,8 +598,6 @@ class Users extends Service {
|
|
|
172
598
|
throw new AppwriteException('Missing required parameter: "email"');
|
|
173
599
|
}
|
|
174
600
|
|
|
175
|
-
let path = '/users/{userId}/email'.replace('{userId}', userId);
|
|
176
|
-
let payload = {};
|
|
177
601
|
|
|
178
602
|
if (typeof email !== 'undefined') {
|
|
179
603
|
payload['email'] = email;
|
|
@@ -190,25 +614,20 @@ class Users extends Service {
|
|
|
190
614
|
* Get the user activity logs list by its unique ID.
|
|
191
615
|
*
|
|
192
616
|
* @param {string} userId
|
|
193
|
-
* @param {
|
|
194
|
-
* @param {number} offset
|
|
617
|
+
* @param {string[]} queries
|
|
195
618
|
* @throws {AppwriteException}
|
|
196
619
|
* @returns {Promise}
|
|
197
620
|
*/
|
|
198
|
-
async getLogs(userId,
|
|
621
|
+
async getLogs(userId, queries) {
|
|
622
|
+
let path = '/users/{userId}/logs'.replace('{userId}', userId);
|
|
623
|
+
let payload = {};
|
|
199
624
|
if (typeof userId === 'undefined') {
|
|
200
625
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
201
626
|
}
|
|
202
627
|
|
|
203
|
-
let path = '/users/{userId}/logs'.replace('{userId}', userId);
|
|
204
|
-
let payload = {};
|
|
205
|
-
|
|
206
|
-
if (typeof limit !== 'undefined') {
|
|
207
|
-
payload['limit'] = limit;
|
|
208
|
-
}
|
|
209
628
|
|
|
210
|
-
if (typeof
|
|
211
|
-
payload['
|
|
629
|
+
if (typeof queries !== 'undefined') {
|
|
630
|
+
payload['queries'] = queries;
|
|
212
631
|
}
|
|
213
632
|
|
|
214
633
|
return await this.client.call('get', path, {
|
|
@@ -226,12 +645,12 @@ class Users extends Service {
|
|
|
226
645
|
* @returns {Promise}
|
|
227
646
|
*/
|
|
228
647
|
async getMemberships(userId) {
|
|
648
|
+
let path = '/users/{userId}/memberships'.replace('{userId}', userId);
|
|
649
|
+
let payload = {};
|
|
229
650
|
if (typeof userId === 'undefined') {
|
|
230
651
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
231
652
|
}
|
|
232
653
|
|
|
233
|
-
let path = '/users/{userId}/memberships'.replace('{userId}', userId);
|
|
234
|
-
let payload = {};
|
|
235
654
|
|
|
236
655
|
return await this.client.call('get', path, {
|
|
237
656
|
'content-type': 'application/json',
|
|
@@ -249,6 +668,8 @@ class Users extends Service {
|
|
|
249
668
|
* @returns {Promise}
|
|
250
669
|
*/
|
|
251
670
|
async updateName(userId, name) {
|
|
671
|
+
let path = '/users/{userId}/name'.replace('{userId}', userId);
|
|
672
|
+
let payload = {};
|
|
252
673
|
if (typeof userId === 'undefined') {
|
|
253
674
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
254
675
|
}
|
|
@@ -257,8 +678,6 @@ class Users extends Service {
|
|
|
257
678
|
throw new AppwriteException('Missing required parameter: "name"');
|
|
258
679
|
}
|
|
259
680
|
|
|
260
|
-
let path = '/users/{userId}/name'.replace('{userId}', userId);
|
|
261
|
-
let payload = {};
|
|
262
681
|
|
|
263
682
|
if (typeof name !== 'undefined') {
|
|
264
683
|
payload['name'] = name;
|
|
@@ -280,6 +699,8 @@ class Users extends Service {
|
|
|
280
699
|
* @returns {Promise}
|
|
281
700
|
*/
|
|
282
701
|
async updatePassword(userId, password) {
|
|
702
|
+
let path = '/users/{userId}/password'.replace('{userId}', userId);
|
|
703
|
+
let payload = {};
|
|
283
704
|
if (typeof userId === 'undefined') {
|
|
284
705
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
285
706
|
}
|
|
@@ -288,8 +709,6 @@ class Users extends Service {
|
|
|
288
709
|
throw new AppwriteException('Missing required parameter: "password"');
|
|
289
710
|
}
|
|
290
711
|
|
|
291
|
-
let path = '/users/{userId}/password'.replace('{userId}', userId);
|
|
292
|
-
let payload = {};
|
|
293
712
|
|
|
294
713
|
if (typeof password !== 'undefined') {
|
|
295
714
|
payload['password'] = password;
|
|
@@ -311,6 +730,8 @@ class Users extends Service {
|
|
|
311
730
|
* @returns {Promise}
|
|
312
731
|
*/
|
|
313
732
|
async updatePhone(userId, number) {
|
|
733
|
+
let path = '/users/{userId}/phone'.replace('{userId}', userId);
|
|
734
|
+
let payload = {};
|
|
314
735
|
if (typeof userId === 'undefined') {
|
|
315
736
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
316
737
|
}
|
|
@@ -319,8 +740,6 @@ class Users extends Service {
|
|
|
319
740
|
throw new AppwriteException('Missing required parameter: "number"');
|
|
320
741
|
}
|
|
321
742
|
|
|
322
|
-
let path = '/users/{userId}/phone'.replace('{userId}', userId);
|
|
323
|
-
let payload = {};
|
|
324
743
|
|
|
325
744
|
if (typeof number !== 'undefined') {
|
|
326
745
|
payload['number'] = number;
|
|
@@ -341,12 +760,12 @@ class Users extends Service {
|
|
|
341
760
|
* @returns {Promise}
|
|
342
761
|
*/
|
|
343
762
|
async getPrefs(userId) {
|
|
763
|
+
let path = '/users/{userId}/prefs'.replace('{userId}', userId);
|
|
764
|
+
let payload = {};
|
|
344
765
|
if (typeof userId === 'undefined') {
|
|
345
766
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
346
767
|
}
|
|
347
768
|
|
|
348
|
-
let path = '/users/{userId}/prefs'.replace('{userId}', userId);
|
|
349
|
-
let payload = {};
|
|
350
769
|
|
|
351
770
|
return await this.client.call('get', path, {
|
|
352
771
|
'content-type': 'application/json',
|
|
@@ -366,6 +785,8 @@ class Users extends Service {
|
|
|
366
785
|
* @returns {Promise}
|
|
367
786
|
*/
|
|
368
787
|
async updatePrefs(userId, prefs) {
|
|
788
|
+
let path = '/users/{userId}/prefs'.replace('{userId}', userId);
|
|
789
|
+
let payload = {};
|
|
369
790
|
if (typeof userId === 'undefined') {
|
|
370
791
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
371
792
|
}
|
|
@@ -374,8 +795,6 @@ class Users extends Service {
|
|
|
374
795
|
throw new AppwriteException('Missing required parameter: "prefs"');
|
|
375
796
|
}
|
|
376
797
|
|
|
377
|
-
let path = '/users/{userId}/prefs'.replace('{userId}', userId);
|
|
378
|
-
let payload = {};
|
|
379
798
|
|
|
380
799
|
if (typeof prefs !== 'undefined') {
|
|
381
800
|
payload['prefs'] = prefs;
|
|
@@ -396,12 +815,12 @@ class Users extends Service {
|
|
|
396
815
|
* @returns {Promise}
|
|
397
816
|
*/
|
|
398
817
|
async getSessions(userId) {
|
|
818
|
+
let path = '/users/{userId}/sessions'.replace('{userId}', userId);
|
|
819
|
+
let payload = {};
|
|
399
820
|
if (typeof userId === 'undefined') {
|
|
400
821
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
401
822
|
}
|
|
402
823
|
|
|
403
|
-
let path = '/users/{userId}/sessions'.replace('{userId}', userId);
|
|
404
|
-
let payload = {};
|
|
405
824
|
|
|
406
825
|
return await this.client.call('get', path, {
|
|
407
826
|
'content-type': 'application/json',
|
|
@@ -418,12 +837,12 @@ class Users extends Service {
|
|
|
418
837
|
* @returns {Promise}
|
|
419
838
|
*/
|
|
420
839
|
async deleteSessions(userId) {
|
|
840
|
+
let path = '/users/{userId}/sessions'.replace('{userId}', userId);
|
|
841
|
+
let payload = {};
|
|
421
842
|
if (typeof userId === 'undefined') {
|
|
422
843
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
423
844
|
}
|
|
424
845
|
|
|
425
|
-
let path = '/users/{userId}/sessions'.replace('{userId}', userId);
|
|
426
|
-
let payload = {};
|
|
427
846
|
|
|
428
847
|
return await this.client.call('delete', path, {
|
|
429
848
|
'content-type': 'application/json',
|
|
@@ -441,6 +860,8 @@ class Users extends Service {
|
|
|
441
860
|
* @returns {Promise}
|
|
442
861
|
*/
|
|
443
862
|
async deleteSession(userId, sessionId) {
|
|
863
|
+
let path = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId);
|
|
864
|
+
let payload = {};
|
|
444
865
|
if (typeof userId === 'undefined') {
|
|
445
866
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
446
867
|
}
|
|
@@ -449,8 +870,6 @@ class Users extends Service {
|
|
|
449
870
|
throw new AppwriteException('Missing required parameter: "sessionId"');
|
|
450
871
|
}
|
|
451
872
|
|
|
452
|
-
let path = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId);
|
|
453
|
-
let payload = {};
|
|
454
873
|
|
|
455
874
|
return await this.client.call('delete', path, {
|
|
456
875
|
'content-type': 'application/json',
|
|
@@ -469,6 +888,8 @@ class Users extends Service {
|
|
|
469
888
|
* @returns {Promise}
|
|
470
889
|
*/
|
|
471
890
|
async updateStatus(userId, status) {
|
|
891
|
+
let path = '/users/{userId}/status'.replace('{userId}', userId);
|
|
892
|
+
let payload = {};
|
|
472
893
|
if (typeof userId === 'undefined') {
|
|
473
894
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
474
895
|
}
|
|
@@ -477,8 +898,6 @@ class Users extends Service {
|
|
|
477
898
|
throw new AppwriteException('Missing required parameter: "status"');
|
|
478
899
|
}
|
|
479
900
|
|
|
480
|
-
let path = '/users/{userId}/status'.replace('{userId}', userId);
|
|
481
|
-
let payload = {};
|
|
482
901
|
|
|
483
902
|
if (typeof status !== 'undefined') {
|
|
484
903
|
payload['status'] = status;
|
|
@@ -500,6 +919,8 @@ class Users extends Service {
|
|
|
500
919
|
* @returns {Promise}
|
|
501
920
|
*/
|
|
502
921
|
async updateEmailVerification(userId, emailVerification) {
|
|
922
|
+
let path = '/users/{userId}/verification'.replace('{userId}', userId);
|
|
923
|
+
let payload = {};
|
|
503
924
|
if (typeof userId === 'undefined') {
|
|
504
925
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
505
926
|
}
|
|
@@ -508,8 +929,6 @@ class Users extends Service {
|
|
|
508
929
|
throw new AppwriteException('Missing required parameter: "emailVerification"');
|
|
509
930
|
}
|
|
510
931
|
|
|
511
|
-
let path = '/users/{userId}/verification'.replace('{userId}', userId);
|
|
512
|
-
let payload = {};
|
|
513
932
|
|
|
514
933
|
if (typeof emailVerification !== 'undefined') {
|
|
515
934
|
payload['emailVerification'] = emailVerification;
|
|
@@ -531,6 +950,8 @@ class Users extends Service {
|
|
|
531
950
|
* @returns {Promise}
|
|
532
951
|
*/
|
|
533
952
|
async updatePhoneVerification(userId, phoneVerification) {
|
|
953
|
+
let path = '/users/{userId}/verification/phone'.replace('{userId}', userId);
|
|
954
|
+
let payload = {};
|
|
534
955
|
if (typeof userId === 'undefined') {
|
|
535
956
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
536
957
|
}
|
|
@@ -539,8 +960,6 @@ class Users extends Service {
|
|
|
539
960
|
throw new AppwriteException('Missing required parameter: "phoneVerification"');
|
|
540
961
|
}
|
|
541
962
|
|
|
542
|
-
let path = '/users/{userId}/verification/phone'.replace('{userId}', userId);
|
|
543
|
-
let payload = {};
|
|
544
963
|
|
|
545
964
|
if (typeof phoneVerification !== 'undefined') {
|
|
546
965
|
payload['phoneVerification'] = phoneVerification;
|
|
@@ -552,4 +971,4 @@ class Users extends Service {
|
|
|
552
971
|
}
|
|
553
972
|
}
|
|
554
973
|
|
|
555
|
-
module.exports = Users;
|
|
974
|
+
module.exports = Users;
|