node-appwrite 17.2.0 → 19.0.0

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.
Files changed (126) hide show
  1. package/README.md +67 -2
  2. package/dist/client.js +3 -3
  3. package/dist/client.js.map +1 -1
  4. package/dist/client.mjs +3 -3
  5. package/dist/client.mjs.map +1 -1
  6. package/dist/enums/credit-card.d.mts +1 -1
  7. package/dist/enums/credit-card.d.ts +1 -1
  8. package/dist/enums/credit-card.js +1 -1
  9. package/dist/enums/credit-card.js.map +1 -1
  10. package/dist/enums/credit-card.mjs +1 -1
  11. package/dist/enums/credit-card.mjs.map +1 -1
  12. package/dist/enums/execution-method.d.mts +2 -1
  13. package/dist/enums/execution-method.d.ts +2 -1
  14. package/dist/enums/execution-method.js +1 -0
  15. package/dist/enums/execution-method.js.map +1 -1
  16. package/dist/enums/execution-method.mjs +1 -0
  17. package/dist/enums/execution-method.mjs.map +1 -1
  18. package/dist/enums/index-type.d.mts +2 -1
  19. package/dist/enums/index-type.d.ts +2 -1
  20. package/dist/enums/index-type.js +1 -0
  21. package/dist/enums/index-type.js.map +1 -1
  22. package/dist/enums/index-type.mjs +1 -0
  23. package/dist/enums/index-type.mjs.map +1 -1
  24. package/dist/enums/{v-c-s-deployment-type.js → vcs-deployment-type.js} +1 -1
  25. package/dist/enums/vcs-deployment-type.js.map +1 -0
  26. package/dist/enums/{v-c-s-deployment-type.mjs → vcs-deployment-type.mjs} +2 -2
  27. package/dist/enums/vcs-deployment-type.mjs.map +1 -0
  28. package/dist/index.d.mts +2 -1
  29. package/dist/index.d.ts +2 -1
  30. package/dist/index.js +7 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +2 -1
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/models.d.mts +1058 -153
  35. package/dist/models.d.ts +1058 -153
  36. package/dist/query.d.mts +196 -6
  37. package/dist/query.d.ts +196 -6
  38. package/dist/query.js +192 -2
  39. package/dist/query.js.map +1 -1
  40. package/dist/query.mjs +192 -2
  41. package/dist/query.mjs.map +1 -1
  42. package/dist/services/account.d.mts +625 -70
  43. package/dist/services/account.d.ts +625 -70
  44. package/dist/services/account.js +592 -292
  45. package/dist/services/account.js.map +1 -1
  46. package/dist/services/account.mjs +592 -292
  47. package/dist/services/account.mjs.map +1 -1
  48. package/dist/services/avatars.d.mts +157 -26
  49. package/dist/services/avatars.d.ts +157 -26
  50. package/dist/services/avatars.js +104 -93
  51. package/dist/services/avatars.js.map +1 -1
  52. package/dist/services/avatars.mjs +104 -93
  53. package/dist/services/avatars.mjs.map +1 -1
  54. package/dist/services/databases.d.mts +1425 -248
  55. package/dist/services/databases.d.ts +1425 -248
  56. package/dist/services/databases.js +1186 -611
  57. package/dist/services/databases.js.map +1 -1
  58. package/dist/services/databases.mjs +1186 -611
  59. package/dist/services/databases.mjs.map +1 -1
  60. package/dist/services/functions.d.mts +530 -107
  61. package/dist/services/functions.d.ts +530 -107
  62. package/dist/services/functions.js +393 -276
  63. package/dist/services/functions.js.map +1 -1
  64. package/dist/services/functions.mjs +393 -276
  65. package/dist/services/functions.mjs.map +1 -1
  66. package/dist/services/graphql.d.mts +24 -2
  67. package/dist/services/graphql.d.ts +24 -2
  68. package/dist/services/graphql.js +20 -16
  69. package/dist/services/graphql.js.map +1 -1
  70. package/dist/services/graphql.mjs +20 -16
  71. package/dist/services/graphql.mjs.map +1 -1
  72. package/dist/services/health.d.mts +175 -16
  73. package/dist/services/health.d.ts +175 -16
  74. package/dist/services/health.js +144 -115
  75. package/dist/services/health.js.map +1 -1
  76. package/dist/services/health.mjs +144 -115
  77. package/dist/services/health.mjs.map +1 -1
  78. package/dist/services/locale.js.map +1 -1
  79. package/dist/services/locale.mjs.map +1 -1
  80. package/dist/services/messaging.d.mts +1544 -262
  81. package/dist/services/messaging.d.ts +1544 -262
  82. package/dist/services/messaging.js +1417 -592
  83. package/dist/services/messaging.js.map +1 -1
  84. package/dist/services/messaging.mjs +1417 -592
  85. package/dist/services/messaging.mjs.map +1 -1
  86. package/dist/services/sites.d.mts +495 -99
  87. package/dist/services/sites.d.ts +495 -99
  88. package/dist/services/sites.js +371 -258
  89. package/dist/services/sites.js.map +1 -1
  90. package/dist/services/sites.mjs +371 -258
  91. package/dist/services/sites.mjs.map +1 -1
  92. package/dist/services/storage.d.mts +306 -63
  93. package/dist/services/storage.d.ts +306 -63
  94. package/dist/services/storage.js +225 -158
  95. package/dist/services/storage.js.map +1 -1
  96. package/dist/services/storage.mjs +225 -158
  97. package/dist/services/storage.mjs.map +1 -1
  98. package/dist/services/tables-db.d.mts +1744 -0
  99. package/dist/services/tables-db.d.ts +1744 -0
  100. package/dist/services/tables-db.js +2692 -0
  101. package/dist/services/tables-db.js.map +1 -0
  102. package/dist/services/tables-db.mjs +2691 -0
  103. package/dist/services/tables-db.mjs.map +1 -0
  104. package/dist/services/teams.d.mts +233 -39
  105. package/dist/services/teams.d.ts +233 -39
  106. package/dist/services/teams.js +170 -135
  107. package/dist/services/teams.js.map +1 -1
  108. package/dist/services/teams.mjs +170 -135
  109. package/dist/services/teams.mjs.map +1 -1
  110. package/dist/services/tokens.d.mts +76 -11
  111. package/dist/services/tokens.d.ts +76 -11
  112. package/dist/services/tokens.js +60 -45
  113. package/dist/services/tokens.js.map +1 -1
  114. package/dist/services/tokens.mjs +60 -45
  115. package/dist/services/tokens.mjs.map +1 -1
  116. package/dist/services/users.d.mts +842 -115
  117. package/dist/services/users.d.ts +842 -115
  118. package/dist/services/users.js +719 -408
  119. package/dist/services/users.js.map +1 -1
  120. package/dist/services/users.mjs +719 -408
  121. package/dist/services/users.mjs.map +1 -1
  122. package/package.json +1 -1
  123. package/dist/enums/v-c-s-deployment-type.js.map +0 -1
  124. package/dist/enums/v-c-s-deployment-type.mjs.map +0 -1
  125. /package/dist/enums/{v-c-s-deployment-type.d.mts → vcs-deployment-type.d.mts} +0 -0
  126. /package/dist/enums/{v-c-s-deployment-type.d.ts → vcs-deployment-type.d.ts} +0 -0
@@ -23,17 +23,22 @@ var Account = class {
23
23
  payload
24
24
  );
25
25
  }
26
- /**
27
- * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
28
- *
29
- * @param {string} userId
30
- * @param {string} email
31
- * @param {string} password
32
- * @param {string} name
33
- * @throws {AppwriteException}
34
- * @returns {Promise<Models.User<Preferences>>}
35
- */
36
- create(userId, email, password, name) {
26
+ create(paramsOrFirst, ...rest) {
27
+ let params;
28
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
29
+ params = paramsOrFirst || {};
30
+ } else {
31
+ params = {
32
+ userId: paramsOrFirst,
33
+ email: rest[0],
34
+ password: rest[1],
35
+ name: rest[2]
36
+ };
37
+ }
38
+ const userId = params.userId;
39
+ const email = params.email;
40
+ const password = params.password;
41
+ const name = params.name;
37
42
  if (typeof userId === "undefined") {
38
43
  throw new AppwriteException('Missing required parameter: "userId"');
39
44
  }
@@ -68,17 +73,18 @@ var Account = class {
68
73
  payload
69
74
  );
70
75
  }
71
- /**
72
- * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request.
73
- * This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.
74
- *
75
- *
76
- * @param {string} email
77
- * @param {string} password
78
- * @throws {AppwriteException}
79
- * @returns {Promise<Models.User<Preferences>>}
80
- */
81
- updateEmail(email, password) {
76
+ updateEmail(paramsOrFirst, ...rest) {
77
+ let params;
78
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
79
+ params = paramsOrFirst || {};
80
+ } else {
81
+ params = {
82
+ email: paramsOrFirst,
83
+ password: rest[0]
84
+ };
85
+ }
86
+ const email = params.email;
87
+ const password = params.password;
82
88
  if (typeof email === "undefined") {
83
89
  throw new AppwriteException('Missing required parameter: "email"');
84
90
  }
@@ -104,14 +110,16 @@ var Account = class {
104
110
  payload
105
111
  );
106
112
  }
107
- /**
108
- * Get the list of identities for the currently logged in user.
109
- *
110
- * @param {string[]} queries
111
- * @throws {AppwriteException}
112
- * @returns {Promise<Models.IdentityList>}
113
- */
114
- listIdentities(queries) {
113
+ listIdentities(paramsOrFirst) {
114
+ let params;
115
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
116
+ params = paramsOrFirst || {};
117
+ } else {
118
+ params = {
119
+ queries: paramsOrFirst
120
+ };
121
+ }
122
+ const queries = params.queries;
115
123
  const apiPath = "/account/identities";
116
124
  const payload = {};
117
125
  if (typeof queries !== "undefined") {
@@ -126,14 +134,16 @@ var Account = class {
126
134
  payload
127
135
  );
128
136
  }
129
- /**
130
- * Delete an identity by its unique ID.
131
- *
132
- * @param {string} identityId
133
- * @throws {AppwriteException}
134
- * @returns {Promise<{}>}
135
- */
136
- deleteIdentity(identityId) {
137
+ deleteIdentity(paramsOrFirst) {
138
+ let params;
139
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
140
+ params = paramsOrFirst || {};
141
+ } else {
142
+ params = {
143
+ identityId: paramsOrFirst
144
+ };
145
+ }
146
+ const identityId = params.identityId;
137
147
  if (typeof identityId === "undefined") {
138
148
  throw new AppwriteException('Missing required parameter: "identityId"');
139
149
  }
@@ -170,14 +180,16 @@ var Account = class {
170
180
  payload
171
181
  );
172
182
  }
173
- /**
174
- * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log.
175
- *
176
- * @param {string[]} queries
177
- * @throws {AppwriteException}
178
- * @returns {Promise<Models.LogList>}
179
- */
180
- listLogs(queries) {
183
+ listLogs(paramsOrFirst) {
184
+ let params;
185
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
186
+ params = paramsOrFirst || {};
187
+ } else {
188
+ params = {
189
+ queries: paramsOrFirst
190
+ };
191
+ }
192
+ const queries = params.queries;
181
193
  const apiPath = "/account/logs";
182
194
  const payload = {};
183
195
  if (typeof queries !== "undefined") {
@@ -192,14 +204,16 @@ var Account = class {
192
204
  payload
193
205
  );
194
206
  }
195
- /**
196
- * Enable or disable MFA on an account.
197
- *
198
- * @param {boolean} mfa
199
- * @throws {AppwriteException}
200
- * @returns {Promise<Models.User<Preferences>>}
201
- */
202
- updateMFA(mfa) {
207
+ updateMFA(paramsOrFirst) {
208
+ let params;
209
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
210
+ params = paramsOrFirst || {};
211
+ } else {
212
+ params = {
213
+ mfa: paramsOrFirst
214
+ };
215
+ }
216
+ const mfa = params.mfa;
203
217
  if (typeof mfa === "undefined") {
204
218
  throw new AppwriteException('Missing required parameter: "mfa"');
205
219
  }
@@ -219,14 +233,16 @@ var Account = class {
219
233
  payload
220
234
  );
221
235
  }
222
- /**
223
- * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.
224
- *
225
- * @param {AuthenticatorType} type
226
- * @throws {AppwriteException}
227
- * @returns {Promise<Models.MfaType>}
228
- */
229
- createMfaAuthenticator(type) {
236
+ createMfaAuthenticator(paramsOrFirst) {
237
+ let params;
238
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "type" in paramsOrFirst) {
239
+ params = paramsOrFirst || {};
240
+ } else {
241
+ params = {
242
+ type: paramsOrFirst
243
+ };
244
+ }
245
+ const type = params.type;
230
246
  if (typeof type === "undefined") {
231
247
  throw new AppwriteException('Missing required parameter: "type"');
232
248
  }
@@ -243,15 +259,44 @@ var Account = class {
243
259
  payload
244
260
  );
245
261
  }
246
- /**
247
- * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method.
248
- *
249
- * @param {AuthenticatorType} type
250
- * @param {string} otp
251
- * @throws {AppwriteException}
252
- * @returns {Promise<Models.User<Preferences>>}
253
- */
254
- updateMfaAuthenticator(type, otp) {
262
+ createMFAAuthenticator(paramsOrFirst) {
263
+ let params;
264
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "type" in paramsOrFirst) {
265
+ params = paramsOrFirst || {};
266
+ } else {
267
+ params = {
268
+ type: paramsOrFirst
269
+ };
270
+ }
271
+ const type = params.type;
272
+ if (typeof type === "undefined") {
273
+ throw new AppwriteException('Missing required parameter: "type"');
274
+ }
275
+ const apiPath = "/account/mfa/authenticators/{type}".replace("{type}", type);
276
+ const payload = {};
277
+ const uri = new URL(this.client.config.endpoint + apiPath);
278
+ const apiHeaders = {
279
+ "content-type": "application/json"
280
+ };
281
+ return this.client.call(
282
+ "post",
283
+ uri,
284
+ apiHeaders,
285
+ payload
286
+ );
287
+ }
288
+ updateMfaAuthenticator(paramsOrFirst, ...rest) {
289
+ let params;
290
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "type" in paramsOrFirst) {
291
+ params = paramsOrFirst || {};
292
+ } else {
293
+ params = {
294
+ type: paramsOrFirst,
295
+ otp: rest[0]
296
+ };
297
+ }
298
+ const type = params.type;
299
+ const otp = params.otp;
255
300
  if (typeof type === "undefined") {
256
301
  throw new AppwriteException('Missing required parameter: "type"');
257
302
  }
@@ -274,14 +319,50 @@ var Account = class {
274
319
  payload
275
320
  );
276
321
  }
277
- /**
278
- * Delete an authenticator for a user by ID.
279
- *
280
- * @param {AuthenticatorType} type
281
- * @throws {AppwriteException}
282
- * @returns {Promise<{}>}
283
- */
284
- deleteMfaAuthenticator(type) {
322
+ updateMFAAuthenticator(paramsOrFirst, ...rest) {
323
+ let params;
324
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "type" in paramsOrFirst) {
325
+ params = paramsOrFirst || {};
326
+ } else {
327
+ params = {
328
+ type: paramsOrFirst,
329
+ otp: rest[0]
330
+ };
331
+ }
332
+ const type = params.type;
333
+ const otp = params.otp;
334
+ if (typeof type === "undefined") {
335
+ throw new AppwriteException('Missing required parameter: "type"');
336
+ }
337
+ if (typeof otp === "undefined") {
338
+ throw new AppwriteException('Missing required parameter: "otp"');
339
+ }
340
+ const apiPath = "/account/mfa/authenticators/{type}".replace("{type}", type);
341
+ const payload = {};
342
+ if (typeof otp !== "undefined") {
343
+ payload["otp"] = otp;
344
+ }
345
+ const uri = new URL(this.client.config.endpoint + apiPath);
346
+ const apiHeaders = {
347
+ "content-type": "application/json"
348
+ };
349
+ return this.client.call(
350
+ "put",
351
+ uri,
352
+ apiHeaders,
353
+ payload
354
+ );
355
+ }
356
+ deleteMfaAuthenticator(paramsOrFirst) {
357
+ let params;
358
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "type" in paramsOrFirst) {
359
+ params = paramsOrFirst || {};
360
+ } else {
361
+ params = {
362
+ type: paramsOrFirst
363
+ };
364
+ }
365
+ const type = params.type;
285
366
  if (typeof type === "undefined") {
286
367
  throw new AppwriteException('Missing required parameter: "type"');
287
368
  }
@@ -298,14 +379,42 @@ var Account = class {
298
379
  payload
299
380
  );
300
381
  }
301
- /**
302
- * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method.
303
- *
304
- * @param {AuthenticationFactor} factor
305
- * @throws {AppwriteException}
306
- * @returns {Promise<Models.MfaChallenge>}
307
- */
308
- createMfaChallenge(factor) {
382
+ deleteMFAAuthenticator(paramsOrFirst) {
383
+ let params;
384
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "type" in paramsOrFirst) {
385
+ params = paramsOrFirst || {};
386
+ } else {
387
+ params = {
388
+ type: paramsOrFirst
389
+ };
390
+ }
391
+ const type = params.type;
392
+ if (typeof type === "undefined") {
393
+ throw new AppwriteException('Missing required parameter: "type"');
394
+ }
395
+ const apiPath = "/account/mfa/authenticators/{type}".replace("{type}", type);
396
+ const payload = {};
397
+ const uri = new URL(this.client.config.endpoint + apiPath);
398
+ const apiHeaders = {
399
+ "content-type": "application/json"
400
+ };
401
+ return this.client.call(
402
+ "delete",
403
+ uri,
404
+ apiHeaders,
405
+ payload
406
+ );
407
+ }
408
+ createMfaChallenge(paramsOrFirst) {
409
+ let params;
410
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "factor" in paramsOrFirst) {
411
+ params = paramsOrFirst || {};
412
+ } else {
413
+ params = {
414
+ factor: paramsOrFirst
415
+ };
416
+ }
417
+ const factor = params.factor;
309
418
  if (typeof factor === "undefined") {
310
419
  throw new AppwriteException('Missing required parameter: "factor"');
311
420
  }
@@ -325,15 +434,84 @@ var Account = class {
325
434
  payload
326
435
  );
327
436
  }
328
- /**
329
- * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
330
- *
331
- * @param {string} challengeId
332
- * @param {string} otp
333
- * @throws {AppwriteException}
334
- * @returns {Promise<Models.Session>}
335
- */
336
- updateMfaChallenge(challengeId, otp) {
437
+ createMFAChallenge(paramsOrFirst) {
438
+ let params;
439
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "factor" in paramsOrFirst) {
440
+ params = paramsOrFirst || {};
441
+ } else {
442
+ params = {
443
+ factor: paramsOrFirst
444
+ };
445
+ }
446
+ const factor = params.factor;
447
+ if (typeof factor === "undefined") {
448
+ throw new AppwriteException('Missing required parameter: "factor"');
449
+ }
450
+ const apiPath = "/account/mfa/challenge";
451
+ const payload = {};
452
+ if (typeof factor !== "undefined") {
453
+ payload["factor"] = factor;
454
+ }
455
+ const uri = new URL(this.client.config.endpoint + apiPath);
456
+ const apiHeaders = {
457
+ "content-type": "application/json"
458
+ };
459
+ return this.client.call(
460
+ "post",
461
+ uri,
462
+ apiHeaders,
463
+ payload
464
+ );
465
+ }
466
+ updateMfaChallenge(paramsOrFirst, ...rest) {
467
+ let params;
468
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
469
+ params = paramsOrFirst || {};
470
+ } else {
471
+ params = {
472
+ challengeId: paramsOrFirst,
473
+ otp: rest[0]
474
+ };
475
+ }
476
+ const challengeId = params.challengeId;
477
+ const otp = params.otp;
478
+ if (typeof challengeId === "undefined") {
479
+ throw new AppwriteException('Missing required parameter: "challengeId"');
480
+ }
481
+ if (typeof otp === "undefined") {
482
+ throw new AppwriteException('Missing required parameter: "otp"');
483
+ }
484
+ const apiPath = "/account/mfa/challenge";
485
+ const payload = {};
486
+ if (typeof challengeId !== "undefined") {
487
+ payload["challengeId"] = challengeId;
488
+ }
489
+ if (typeof otp !== "undefined") {
490
+ payload["otp"] = otp;
491
+ }
492
+ const uri = new URL(this.client.config.endpoint + apiPath);
493
+ const apiHeaders = {
494
+ "content-type": "application/json"
495
+ };
496
+ return this.client.call(
497
+ "put",
498
+ uri,
499
+ apiHeaders,
500
+ payload
501
+ );
502
+ }
503
+ updateMFAChallenge(paramsOrFirst, ...rest) {
504
+ let params;
505
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
506
+ params = paramsOrFirst || {};
507
+ } else {
508
+ params = {
509
+ challengeId: paramsOrFirst,
510
+ otp: rest[0]
511
+ };
512
+ }
513
+ const challengeId = params.challengeId;
514
+ const otp = params.otp;
337
515
  if (typeof challengeId === "undefined") {
338
516
  throw new AppwriteException('Missing required parameter: "challengeId"');
339
517
  }
@@ -364,6 +542,7 @@ var Account = class {
364
542
  *
365
543
  * @throws {AppwriteException}
366
544
  * @returns {Promise<Models.MfaFactors>}
545
+ * @deprecated This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.
367
546
  */
368
547
  listMfaFactors() {
369
548
  const apiPath = "/account/mfa/factors";
@@ -377,11 +556,30 @@ var Account = class {
377
556
  payload
378
557
  );
379
558
  }
559
+ /**
560
+ * List the factors available on the account to be used as a MFA challange.
561
+ *
562
+ * @throws {AppwriteException}
563
+ * @returns {Promise<Models.MfaFactors>}
564
+ */
565
+ listMFAFactors() {
566
+ const apiPath = "/account/mfa/factors";
567
+ const payload = {};
568
+ const uri = new URL(this.client.config.endpoint + apiPath);
569
+ const apiHeaders = {};
570
+ return this.client.call(
571
+ "get",
572
+ uri,
573
+ apiHeaders,
574
+ payload
575
+ );
576
+ }
380
577
  /**
381
578
  * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes.
382
579
  *
383
580
  * @throws {AppwriteException}
384
581
  * @returns {Promise<Models.MfaRecoveryCodes>}
582
+ * @deprecated This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.
385
583
  */
386
584
  getMfaRecoveryCodes() {
387
585
  const apiPath = "/account/mfa/recovery-codes";
@@ -396,11 +594,30 @@ var Account = class {
396
594
  );
397
595
  }
398
596
  /**
399
- * Generate recovery codes as backup for MFA flow. It&#039;s recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
597
+ * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes.
400
598
  *
401
599
  * @throws {AppwriteException}
402
600
  * @returns {Promise<Models.MfaRecoveryCodes>}
403
601
  */
602
+ getMFARecoveryCodes() {
603
+ const apiPath = "/account/mfa/recovery-codes";
604
+ const payload = {};
605
+ const uri = new URL(this.client.config.endpoint + apiPath);
606
+ const apiHeaders = {};
607
+ return this.client.call(
608
+ "get",
609
+ uri,
610
+ apiHeaders,
611
+ payload
612
+ );
613
+ }
614
+ /**
615
+ * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
616
+ *
617
+ * @throws {AppwriteException}
618
+ * @returns {Promise<Models.MfaRecoveryCodes>}
619
+ * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.
620
+ */
404
621
  createMfaRecoveryCodes() {
405
622
  const apiPath = "/account/mfa/recovery-codes";
406
623
  const payload = {};
@@ -415,11 +632,32 @@ var Account = class {
415
632
  payload
416
633
  );
417
634
  }
635
+ /**
636
+ * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
637
+ *
638
+ * @throws {AppwriteException}
639
+ * @returns {Promise<Models.MfaRecoveryCodes>}
640
+ */
641
+ createMFARecoveryCodes() {
642
+ const apiPath = "/account/mfa/recovery-codes";
643
+ const payload = {};
644
+ const uri = new URL(this.client.config.endpoint + apiPath);
645
+ const apiHeaders = {
646
+ "content-type": "application/json"
647
+ };
648
+ return this.client.call(
649
+ "post",
650
+ uri,
651
+ apiHeaders,
652
+ payload
653
+ );
654
+ }
418
655
  /**
419
656
  * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes.
420
657
  *
421
658
  * @throws {AppwriteException}
422
659
  * @returns {Promise<Models.MfaRecoveryCodes>}
660
+ * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.
423
661
  */
424
662
  updateMfaRecoveryCodes() {
425
663
  const apiPath = "/account/mfa/recovery-codes";
@@ -436,13 +674,35 @@ var Account = class {
436
674
  );
437
675
  }
438
676
  /**
439
- * Update currently logged in user account name.
677
+ * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes.
440
678
  *
441
- * @param {string} name
442
679
  * @throws {AppwriteException}
443
- * @returns {Promise<Models.User<Preferences>>}
680
+ * @returns {Promise<Models.MfaRecoveryCodes>}
444
681
  */
445
- updateName(name) {
682
+ updateMFARecoveryCodes() {
683
+ const apiPath = "/account/mfa/recovery-codes";
684
+ const payload = {};
685
+ const uri = new URL(this.client.config.endpoint + apiPath);
686
+ const apiHeaders = {
687
+ "content-type": "application/json"
688
+ };
689
+ return this.client.call(
690
+ "patch",
691
+ uri,
692
+ apiHeaders,
693
+ payload
694
+ );
695
+ }
696
+ updateName(paramsOrFirst) {
697
+ let params;
698
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
699
+ params = paramsOrFirst || {};
700
+ } else {
701
+ params = {
702
+ name: paramsOrFirst
703
+ };
704
+ }
705
+ const name = params.name;
446
706
  if (typeof name === "undefined") {
447
707
  throw new AppwriteException('Missing required parameter: "name"');
448
708
  }
@@ -462,15 +722,18 @@ var Account = class {
462
722
  payload
463
723
  );
464
724
  }
465
- /**
466
- * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.
467
- *
468
- * @param {string} password
469
- * @param {string} oldPassword
470
- * @throws {AppwriteException}
471
- * @returns {Promise<Models.User<Preferences>>}
472
- */
473
- updatePassword(password, oldPassword) {
725
+ updatePassword(paramsOrFirst, ...rest) {
726
+ let params;
727
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
728
+ params = paramsOrFirst || {};
729
+ } else {
730
+ params = {
731
+ password: paramsOrFirst,
732
+ oldPassword: rest[0]
733
+ };
734
+ }
735
+ const password = params.password;
736
+ const oldPassword = params.oldPassword;
474
737
  if (typeof password === "undefined") {
475
738
  throw new AppwriteException('Missing required parameter: "password"');
476
739
  }
@@ -493,15 +756,18 @@ var Account = class {
493
756
  payload
494
757
  );
495
758
  }
496
- /**
497
- * Update the currently logged in user&#039;s phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS.
498
- *
499
- * @param {string} phone
500
- * @param {string} password
501
- * @throws {AppwriteException}
502
- * @returns {Promise<Models.User<Preferences>>}
503
- */
504
- updatePhone(phone, password) {
759
+ updatePhone(paramsOrFirst, ...rest) {
760
+ let params;
761
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
762
+ params = paramsOrFirst || {};
763
+ } else {
764
+ params = {
765
+ phone: paramsOrFirst,
766
+ password: rest[0]
767
+ };
768
+ }
769
+ const phone = params.phone;
770
+ const password = params.password;
505
771
  if (typeof phone === "undefined") {
506
772
  throw new AppwriteException('Missing required parameter: "phone"');
507
773
  }
@@ -545,14 +811,16 @@ var Account = class {
545
811
  payload
546
812
  );
547
813
  }
548
- /**
549
- * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.
550
- *
551
- * @param {Partial<Preferences>} prefs
552
- * @throws {AppwriteException}
553
- * @returns {Promise<Models.User<Preferences>>}
554
- */
555
- updatePrefs(prefs) {
814
+ updatePrefs(paramsOrFirst) {
815
+ let params;
816
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "prefs" in paramsOrFirst) {
817
+ params = paramsOrFirst || {};
818
+ } else {
819
+ params = {
820
+ prefs: paramsOrFirst
821
+ };
822
+ }
823
+ const prefs = params.prefs;
556
824
  if (typeof prefs === "undefined") {
557
825
  throw new AppwriteException('Missing required parameter: "prefs"');
558
826
  }
@@ -572,15 +840,18 @@ var Account = class {
572
840
  payload
573
841
  );
574
842
  }
575
- /**
576
- * Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user&#039;s email address is valid for 1 hour.
577
- *
578
- * @param {string} email
579
- * @param {string} url
580
- * @throws {AppwriteException}
581
- * @returns {Promise<Models.Token>}
582
- */
583
- createRecovery(email, url) {
843
+ createRecovery(paramsOrFirst, ...rest) {
844
+ let params;
845
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
846
+ params = paramsOrFirst || {};
847
+ } else {
848
+ params = {
849
+ email: paramsOrFirst,
850
+ url: rest[0]
851
+ };
852
+ }
853
+ const email = params.email;
854
+ const url = params.url;
584
855
  if (typeof email === "undefined") {
585
856
  throw new AppwriteException('Missing required parameter: "email"');
586
857
  }
@@ -606,18 +877,20 @@ var Account = class {
606
877
  payload
607
878
  );
608
879
  }
609
- /**
610
- * Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint.
611
- *
612
- * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
613
- *
614
- * @param {string} userId
615
- * @param {string} secret
616
- * @param {string} password
617
- * @throws {AppwriteException}
618
- * @returns {Promise<Models.Token>}
619
- */
620
- updateRecovery(userId, secret, password) {
880
+ updateRecovery(paramsOrFirst, ...rest) {
881
+ let params;
882
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
883
+ params = paramsOrFirst || {};
884
+ } else {
885
+ params = {
886
+ userId: paramsOrFirst,
887
+ secret: rest[0],
888
+ password: rest[1]
889
+ };
890
+ }
891
+ const userId = params.userId;
892
+ const secret = params.secret;
893
+ const password = params.password;
621
894
  if (typeof userId === "undefined") {
622
895
  throw new AppwriteException('Missing required parameter: "userId"');
623
896
  }
@@ -707,17 +980,18 @@ var Account = class {
707
980
  payload
708
981
  );
709
982
  }
710
- /**
711
- * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.
712
- *
713
- * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
714
- *
715
- * @param {string} email
716
- * @param {string} password
717
- * @throws {AppwriteException}
718
- * @returns {Promise<Models.Session>}
719
- */
720
- createEmailPasswordSession(email, password) {
983
+ createEmailPasswordSession(paramsOrFirst, ...rest) {
984
+ let params;
985
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
986
+ params = paramsOrFirst || {};
987
+ } else {
988
+ params = {
989
+ email: paramsOrFirst,
990
+ password: rest[0]
991
+ };
992
+ }
993
+ const email = params.email;
994
+ const password = params.password;
721
995
  if (typeof email === "undefined") {
722
996
  throw new AppwriteException('Missing required parameter: "email"');
723
997
  }
@@ -743,15 +1017,18 @@ var Account = class {
743
1017
  payload
744
1018
  );
745
1019
  }
746
- /**
747
- * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.
748
- *
749
- * @param {string} userId
750
- * @param {string} secret
751
- * @throws {AppwriteException}
752
- * @returns {Promise<Models.Session>}
753
- */
754
- updateMagicURLSession(userId, secret) {
1020
+ updateMagicURLSession(paramsOrFirst, ...rest) {
1021
+ let params;
1022
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1023
+ params = paramsOrFirst || {};
1024
+ } else {
1025
+ params = {
1026
+ userId: paramsOrFirst,
1027
+ secret: rest[0]
1028
+ };
1029
+ }
1030
+ const userId = params.userId;
1031
+ const secret = params.secret;
755
1032
  if (typeof userId === "undefined") {
756
1033
  throw new AppwriteException('Missing required parameter: "userId"');
757
1034
  }
@@ -777,15 +1054,18 @@ var Account = class {
777
1054
  payload
778
1055
  );
779
1056
  }
780
- /**
781
- * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.
782
- *
783
- * @param {string} userId
784
- * @param {string} secret
785
- * @throws {AppwriteException}
786
- * @returns {Promise<Models.Session>}
787
- */
788
- updatePhoneSession(userId, secret) {
1057
+ updatePhoneSession(paramsOrFirst, ...rest) {
1058
+ let params;
1059
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1060
+ params = paramsOrFirst || {};
1061
+ } else {
1062
+ params = {
1063
+ userId: paramsOrFirst,
1064
+ secret: rest[0]
1065
+ };
1066
+ }
1067
+ const userId = params.userId;
1068
+ const secret = params.secret;
789
1069
  if (typeof userId === "undefined") {
790
1070
  throw new AppwriteException('Missing required parameter: "userId"');
791
1071
  }
@@ -811,15 +1091,18 @@ var Account = class {
811
1091
  payload
812
1092
  );
813
1093
  }
814
- /**
815
- * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.
816
- *
817
- * @param {string} userId
818
- * @param {string} secret
819
- * @throws {AppwriteException}
820
- * @returns {Promise<Models.Session>}
821
- */
822
- createSession(userId, secret) {
1094
+ createSession(paramsOrFirst, ...rest) {
1095
+ let params;
1096
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1097
+ params = paramsOrFirst || {};
1098
+ } else {
1099
+ params = {
1100
+ userId: paramsOrFirst,
1101
+ secret: rest[0]
1102
+ };
1103
+ }
1104
+ const userId = params.userId;
1105
+ const secret = params.secret;
823
1106
  if (typeof userId === "undefined") {
824
1107
  throw new AppwriteException('Missing required parameter: "userId"');
825
1108
  }
@@ -845,14 +1128,16 @@ var Account = class {
845
1128
  payload
846
1129
  );
847
1130
  }
848
- /**
849
- * Use this endpoint to get a logged in user&#039;s session using a Session ID. Inputting &#039;current&#039; will return the current session being used.
850
- *
851
- * @param {string} sessionId
852
- * @throws {AppwriteException}
853
- * @returns {Promise<Models.Session>}
854
- */
855
- getSession(sessionId) {
1131
+ getSession(paramsOrFirst) {
1132
+ let params;
1133
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1134
+ params = paramsOrFirst || {};
1135
+ } else {
1136
+ params = {
1137
+ sessionId: paramsOrFirst
1138
+ };
1139
+ }
1140
+ const sessionId = params.sessionId;
856
1141
  if (typeof sessionId === "undefined") {
857
1142
  throw new AppwriteException('Missing required parameter: "sessionId"');
858
1143
  }
@@ -867,14 +1152,16 @@ var Account = class {
867
1152
  payload
868
1153
  );
869
1154
  }
870
- /**
871
- * Use this endpoint to extend a session&#039;s length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider.
872
- *
873
- * @param {string} sessionId
874
- * @throws {AppwriteException}
875
- * @returns {Promise<Models.Session>}
876
- */
877
- updateSession(sessionId) {
1155
+ updateSession(paramsOrFirst) {
1156
+ let params;
1157
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1158
+ params = paramsOrFirst || {};
1159
+ } else {
1160
+ params = {
1161
+ sessionId: paramsOrFirst
1162
+ };
1163
+ }
1164
+ const sessionId = params.sessionId;
878
1165
  if (typeof sessionId === "undefined") {
879
1166
  throw new AppwriteException('Missing required parameter: "sessionId"');
880
1167
  }
@@ -891,14 +1178,16 @@ var Account = class {
891
1178
  payload
892
1179
  );
893
1180
  }
894
- /**
895
- * Logout the user. Use &#039;current&#039; as the session ID to logout on this device, use a session ID to logout on another device. If you&#039;re looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead.
896
- *
897
- * @param {string} sessionId
898
- * @throws {AppwriteException}
899
- * @returns {Promise<{}>}
900
- */
901
- deleteSession(sessionId) {
1181
+ deleteSession(paramsOrFirst) {
1182
+ let params;
1183
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1184
+ params = paramsOrFirst || {};
1185
+ } else {
1186
+ params = {
1187
+ sessionId: paramsOrFirst
1188
+ };
1189
+ }
1190
+ const sessionId = params.sessionId;
902
1191
  if (typeof sessionId === "undefined") {
903
1192
  throw new AppwriteException('Missing required parameter: "sessionId"');
904
1193
  }
@@ -935,18 +1224,20 @@ var Account = class {
935
1224
  payload
936
1225
  );
937
1226
  }
938
- /**
939
- * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user&#039;s email is valid for 15 minutes.
940
- *
941
- * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
942
- *
943
- * @param {string} userId
944
- * @param {string} email
945
- * @param {boolean} phrase
946
- * @throws {AppwriteException}
947
- * @returns {Promise<Models.Token>}
948
- */
949
- createEmailToken(userId, email, phrase) {
1227
+ createEmailToken(paramsOrFirst, ...rest) {
1228
+ let params;
1229
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1230
+ params = paramsOrFirst || {};
1231
+ } else {
1232
+ params = {
1233
+ userId: paramsOrFirst,
1234
+ email: rest[0],
1235
+ phrase: rest[1]
1236
+ };
1237
+ }
1238
+ const userId = params.userId;
1239
+ const email = params.email;
1240
+ const phrase = params.phrase;
950
1241
  if (typeof userId === "undefined") {
951
1242
  throw new AppwriteException('Missing required parameter: "userId"');
952
1243
  }
@@ -975,20 +1266,22 @@ var Account = class {
975
1266
  payload
976
1267
  );
977
1268
  }
978
- /**
979
- * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user&#039;s email address is valid for 1 hour.
980
- *
981
- * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
982
- *
983
- *
984
- * @param {string} userId
985
- * @param {string} email
986
- * @param {string} url
987
- * @param {boolean} phrase
988
- * @throws {AppwriteException}
989
- * @returns {Promise<Models.Token>}
990
- */
991
- createMagicURLToken(userId, email, url, phrase) {
1269
+ createMagicURLToken(paramsOrFirst, ...rest) {
1270
+ let params;
1271
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1272
+ params = paramsOrFirst || {};
1273
+ } else {
1274
+ params = {
1275
+ userId: paramsOrFirst,
1276
+ email: rest[0],
1277
+ url: rest[1],
1278
+ phrase: rest[2]
1279
+ };
1280
+ }
1281
+ const userId = params.userId;
1282
+ const email = params.email;
1283
+ const url = params.url;
1284
+ const phrase = params.phrase;
992
1285
  if (typeof userId === "undefined") {
993
1286
  throw new AppwriteException('Missing required parameter: "userId"');
994
1287
  }
@@ -1020,21 +1313,22 @@ var Account = class {
1020
1313
  payload
1021
1314
  );
1022
1315
  }
1023
- /**
1024
- * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL&#039;s back to your app when login is completed.
1025
- *
1026
- * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint.
1027
- *
1028
- * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1029
- *
1030
- * @param {OAuthProvider} provider
1031
- * @param {string} success
1032
- * @param {string} failure
1033
- * @param {string[]} scopes
1034
- * @throws {AppwriteException}
1035
- * @returns {Promise<string>}
1036
- */
1037
- createOAuth2Token(provider, success, failure, scopes) {
1316
+ createOAuth2Token(paramsOrFirst, ...rest) {
1317
+ let params;
1318
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst) && "provider" in paramsOrFirst) {
1319
+ params = paramsOrFirst || {};
1320
+ } else {
1321
+ params = {
1322
+ provider: paramsOrFirst,
1323
+ success: rest[0],
1324
+ failure: rest[1],
1325
+ scopes: rest[2]
1326
+ };
1327
+ }
1328
+ const provider = params.provider;
1329
+ const success = params.success;
1330
+ const failure = params.failure;
1331
+ const scopes = params.scopes;
1038
1332
  if (typeof provider === "undefined") {
1039
1333
  throw new AppwriteException('Missing required parameter: "provider"');
1040
1334
  }
@@ -1058,17 +1352,18 @@ var Account = class {
1058
1352
  payload
1059
1353
  );
1060
1354
  }
1061
- /**
1062
- * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user&#039;s phone is valid for 15 minutes.
1063
- *
1064
- * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1065
- *
1066
- * @param {string} userId
1067
- * @param {string} phone
1068
- * @throws {AppwriteException}
1069
- * @returns {Promise<Models.Token>}
1070
- */
1071
- createPhoneToken(userId, phone) {
1355
+ createPhoneToken(paramsOrFirst, ...rest) {
1356
+ let params;
1357
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1358
+ params = paramsOrFirst || {};
1359
+ } else {
1360
+ params = {
1361
+ userId: paramsOrFirst,
1362
+ phone: rest[0]
1363
+ };
1364
+ }
1365
+ const userId = params.userId;
1366
+ const phone = params.phone;
1072
1367
  if (typeof userId === "undefined") {
1073
1368
  throw new AppwriteException('Missing required parameter: "userId"');
1074
1369
  }
@@ -1094,17 +1389,16 @@ var Account = class {
1094
1389
  payload
1095
1390
  );
1096
1391
  }
1097
- /**
1098
- * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user&#039;s email address is valid for 7 days.
1099
- *
1100
- * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
1101
- *
1102
- *
1103
- * @param {string} url
1104
- * @throws {AppwriteException}
1105
- * @returns {Promise<Models.Token>}
1106
- */
1107
- createVerification(url) {
1392
+ createVerification(paramsOrFirst) {
1393
+ let params;
1394
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1395
+ params = paramsOrFirst || {};
1396
+ } else {
1397
+ params = {
1398
+ url: paramsOrFirst
1399
+ };
1400
+ }
1401
+ const url = params.url;
1108
1402
  if (typeof url === "undefined") {
1109
1403
  throw new AppwriteException('Missing required parameter: "url"');
1110
1404
  }
@@ -1124,15 +1418,18 @@ var Account = class {
1124
1418
  payload
1125
1419
  );
1126
1420
  }
1127
- /**
1128
- * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
1129
- *
1130
- * @param {string} userId
1131
- * @param {string} secret
1132
- * @throws {AppwriteException}
1133
- * @returns {Promise<Models.Token>}
1134
- */
1135
- updateVerification(userId, secret) {
1421
+ updateVerification(paramsOrFirst, ...rest) {
1422
+ let params;
1423
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1424
+ params = paramsOrFirst || {};
1425
+ } else {
1426
+ params = {
1427
+ userId: paramsOrFirst,
1428
+ secret: rest[0]
1429
+ };
1430
+ }
1431
+ const userId = params.userId;
1432
+ const secret = params.secret;
1136
1433
  if (typeof userId === "undefined") {
1137
1434
  throw new AppwriteException('Missing required parameter: "userId"');
1138
1435
  }
@@ -1159,7 +1456,7 @@ var Account = class {
1159
1456
  );
1160
1457
  }
1161
1458
  /**
1162
- * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user&#039;s phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user&#039;s phone number is valid for 15 minutes.
1459
+ * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes.
1163
1460
  *
1164
1461
  * @throws {AppwriteException}
1165
1462
  * @returns {Promise<Models.Token>}
@@ -1178,15 +1475,18 @@ var Account = class {
1178
1475
  payload
1179
1476
  );
1180
1477
  }
1181
- /**
1182
- * Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user&#039;s phone number to verify the user email ownership. If confirmed this route will return a 200 status code.
1183
- *
1184
- * @param {string} userId
1185
- * @param {string} secret
1186
- * @throws {AppwriteException}
1187
- * @returns {Promise<Models.Token>}
1188
- */
1189
- updatePhoneVerification(userId, secret) {
1478
+ updatePhoneVerification(paramsOrFirst, ...rest) {
1479
+ let params;
1480
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
1481
+ params = paramsOrFirst || {};
1482
+ } else {
1483
+ params = {
1484
+ userId: paramsOrFirst,
1485
+ secret: rest[0]
1486
+ };
1487
+ }
1488
+ const userId = params.userId;
1489
+ const secret = params.secret;
1190
1490
  if (typeof userId === "undefined") {
1191
1491
  throw new AppwriteException('Missing required parameter: "userId"');
1192
1492
  }