@appwrite.io/console 0.2.0 → 0.4.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 (322) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/sdk.js +3353 -1497
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +3350 -1498
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +3353 -1497
  7. package/docs/examples/account/create-anonymous-session.md +1 -1
  8. package/docs/examples/account/create-email-session.md +1 -1
  9. package/docs/examples/account/create-j-w-t.md +1 -1
  10. package/docs/examples/account/create-magic-u-r-l-session.md +1 -1
  11. package/docs/examples/account/create-o-auth2session.md +1 -1
  12. package/docs/examples/account/create-phone-session.md +1 -1
  13. package/docs/examples/account/create-phone-verification.md +1 -1
  14. package/docs/examples/account/create-recovery.md +1 -1
  15. package/docs/examples/account/create-verification.md +1 -1
  16. package/docs/examples/account/create.md +1 -1
  17. package/docs/examples/account/{create-with-invite-code.md → delete-identity.md} +2 -2
  18. package/docs/examples/account/delete-session.md +1 -1
  19. package/docs/examples/account/delete-sessions.md +1 -1
  20. package/docs/examples/account/get-prefs.md +1 -1
  21. package/docs/examples/account/get-session.md +1 -1
  22. package/docs/examples/account/get.md +1 -1
  23. package/docs/examples/account/list-identities.md +18 -0
  24. package/docs/examples/account/list-logs.md +1 -1
  25. package/docs/examples/account/list-sessions.md +1 -1
  26. package/docs/examples/account/update-email.md +1 -1
  27. package/docs/examples/account/update-magic-u-r-l-session.md +1 -1
  28. package/docs/examples/account/update-name.md +1 -1
  29. package/docs/examples/account/update-password.md +1 -1
  30. package/docs/examples/account/update-phone-session.md +1 -1
  31. package/docs/examples/account/update-phone-verification.md +1 -1
  32. package/docs/examples/account/update-phone.md +1 -1
  33. package/docs/examples/account/update-prefs.md +1 -1
  34. package/docs/examples/account/update-recovery.md +1 -1
  35. package/docs/examples/account/update-session.md +1 -1
  36. package/docs/examples/account/update-status.md +1 -1
  37. package/docs/examples/account/update-verification.md +1 -1
  38. package/docs/examples/assistant/chat.md +18 -0
  39. package/docs/examples/avatars/get-browser.md +1 -1
  40. package/docs/examples/avatars/get-credit-card.md +1 -1
  41. package/docs/examples/avatars/get-favicon.md +1 -1
  42. package/docs/examples/avatars/get-flag.md +1 -1
  43. package/docs/examples/avatars/get-image.md +1 -1
  44. package/docs/examples/avatars/get-initials.md +1 -1
  45. package/docs/examples/avatars/get-q-r.md +1 -1
  46. package/docs/examples/console/variables.md +1 -1
  47. package/docs/examples/databases/create-boolean-attribute.md +1 -1
  48. package/docs/examples/databases/create-collection.md +1 -1
  49. package/docs/examples/databases/create-datetime-attribute.md +1 -1
  50. package/docs/examples/databases/create-document.md +1 -1
  51. package/docs/examples/databases/create-email-attribute.md +1 -1
  52. package/docs/examples/databases/create-enum-attribute.md +1 -1
  53. package/docs/examples/databases/create-float-attribute.md +1 -1
  54. package/docs/examples/databases/create-index.md +1 -1
  55. package/docs/examples/databases/create-integer-attribute.md +1 -1
  56. package/docs/examples/databases/create-ip-attribute.md +1 -1
  57. package/docs/examples/databases/create-relationship-attribute.md +1 -1
  58. package/docs/examples/databases/create-string-attribute.md +1 -1
  59. package/docs/examples/databases/create-url-attribute.md +1 -1
  60. package/docs/examples/databases/create.md +1 -1
  61. package/docs/examples/databases/delete-attribute.md +1 -1
  62. package/docs/examples/databases/delete-collection.md +1 -1
  63. package/docs/examples/databases/delete-document.md +1 -1
  64. package/docs/examples/databases/delete-index.md +1 -1
  65. package/docs/examples/databases/delete.md +1 -1
  66. package/docs/examples/databases/get-attribute.md +1 -1
  67. package/docs/examples/databases/get-collection-usage.md +1 -1
  68. package/docs/examples/databases/get-collection.md +1 -1
  69. package/docs/examples/databases/get-database-usage.md +1 -1
  70. package/docs/examples/databases/get-document.md +1 -1
  71. package/docs/examples/databases/get-index.md +1 -1
  72. package/docs/examples/databases/get-usage.md +1 -1
  73. package/docs/examples/databases/get.md +1 -1
  74. package/docs/examples/databases/list-attributes.md +1 -1
  75. package/docs/examples/databases/list-collection-logs.md +1 -1
  76. package/docs/examples/databases/list-collections.md +1 -1
  77. package/docs/examples/databases/list-document-logs.md +1 -1
  78. package/docs/examples/databases/list-documents.md +1 -1
  79. package/docs/examples/databases/list-indexes.md +1 -1
  80. package/docs/examples/databases/list-logs.md +1 -1
  81. package/docs/examples/databases/list.md +1 -1
  82. package/docs/examples/databases/update-boolean-attribute.md +1 -1
  83. package/docs/examples/databases/update-collection.md +1 -1
  84. package/docs/examples/databases/update-datetime-attribute.md +1 -1
  85. package/docs/examples/databases/update-document.md +1 -1
  86. package/docs/examples/databases/update-email-attribute.md +1 -1
  87. package/docs/examples/databases/update-enum-attribute.md +1 -1
  88. package/docs/examples/databases/update-float-attribute.md +1 -1
  89. package/docs/examples/databases/update-integer-attribute.md +1 -1
  90. package/docs/examples/databases/update-ip-attribute.md +1 -1
  91. package/docs/examples/databases/update-relationship-attribute.md +1 -1
  92. package/docs/examples/databases/update-string-attribute.md +1 -1
  93. package/docs/examples/databases/update-url-attribute.md +1 -1
  94. package/docs/examples/databases/update.md +1 -1
  95. package/docs/examples/functions/create-build.md +1 -1
  96. package/docs/examples/functions/create-deployment.md +2 -2
  97. package/docs/examples/functions/create-execution.md +1 -1
  98. package/docs/examples/functions/create-variable.md +1 -1
  99. package/docs/examples/functions/create.md +2 -2
  100. package/docs/examples/functions/delete-deployment.md +1 -1
  101. package/docs/examples/functions/delete-variable.md +1 -1
  102. package/docs/examples/functions/delete.md +1 -1
  103. package/docs/examples/functions/download-deployment.md +14 -0
  104. package/docs/examples/functions/get-deployment.md +1 -1
  105. package/docs/examples/functions/get-execution.md +1 -1
  106. package/docs/examples/functions/get-function-usage.md +1 -1
  107. package/docs/examples/functions/get-usage.md +1 -1
  108. package/docs/examples/functions/get-variable.md +1 -1
  109. package/docs/examples/functions/get.md +1 -1
  110. package/docs/examples/functions/list-deployments.md +1 -1
  111. package/docs/examples/functions/list-executions.md +1 -1
  112. package/docs/examples/functions/list-runtimes.md +1 -1
  113. package/docs/examples/functions/list-variables.md +1 -1
  114. package/docs/examples/functions/list.md +1 -1
  115. package/docs/examples/functions/update-deployment.md +1 -1
  116. package/docs/examples/functions/update-variable.md +1 -1
  117. package/docs/examples/functions/update.md +1 -1
  118. package/docs/examples/graphql/mutation.md +1 -1
  119. package/docs/examples/graphql/query.md +1 -1
  120. package/docs/examples/health/get-antivirus.md +1 -1
  121. package/docs/examples/health/get-cache.md +1 -1
  122. package/docs/examples/health/get-d-b.md +1 -1
  123. package/docs/examples/health/get-pub-sub.md +1 -1
  124. package/docs/examples/health/get-queue-builds.md +18 -0
  125. package/docs/examples/health/get-queue-certificates.md +1 -1
  126. package/docs/examples/health/get-queue-databases.md +18 -0
  127. package/docs/examples/health/get-queue-deletes.md +18 -0
  128. package/docs/examples/health/get-queue-functions.md +1 -1
  129. package/docs/examples/health/get-queue-logs.md +1 -1
  130. package/docs/examples/health/get-queue-mails.md +18 -0
  131. package/docs/examples/health/get-queue-messaging.md +18 -0
  132. package/docs/examples/health/get-queue-migrations.md +18 -0
  133. package/docs/examples/health/get-queue-webhooks.md +1 -1
  134. package/docs/examples/health/get-queue.md +1 -1
  135. package/docs/examples/health/get-storage-local.md +1 -1
  136. package/docs/examples/health/get-time.md +1 -1
  137. package/docs/examples/health/get.md +1 -1
  138. package/docs/examples/locale/get.md +1 -1
  139. package/docs/examples/locale/list-codes.md +18 -0
  140. package/docs/examples/locale/list-continents.md +1 -1
  141. package/docs/examples/locale/list-countries-e-u.md +1 -1
  142. package/docs/examples/locale/list-countries-phones.md +1 -1
  143. package/docs/examples/locale/list-countries.md +1 -1
  144. package/docs/examples/locale/list-currencies.md +1 -1
  145. package/docs/examples/locale/list-languages.md +1 -1
  146. package/docs/examples/migrations/create-appwrite-migration.md +18 -0
  147. package/docs/examples/migrations/create-firebase-migration.md +18 -0
  148. package/docs/examples/migrations/create-firebase-o-auth-migration.md +18 -0
  149. package/docs/examples/migrations/create-n-host-migration.md +18 -0
  150. package/docs/examples/migrations/create-supabase-migration.md +18 -0
  151. package/docs/examples/migrations/delete-firebase-auth.md +18 -0
  152. package/docs/examples/migrations/delete.md +18 -0
  153. package/docs/examples/migrations/get-appwrite-report.md +18 -0
  154. package/docs/examples/migrations/get-firebase-report-o-auth.md +18 -0
  155. package/docs/examples/migrations/get-firebase-report.md +18 -0
  156. package/docs/examples/migrations/get-n-host-report.md +18 -0
  157. package/docs/examples/migrations/get-supabase-report.md +18 -0
  158. package/docs/examples/migrations/get.md +18 -0
  159. package/docs/examples/migrations/list-firebase-projects.md +18 -0
  160. package/docs/examples/migrations/list.md +18 -0
  161. package/docs/examples/migrations/retry.md +18 -0
  162. package/docs/examples/project/create-variable.md +18 -0
  163. package/docs/examples/project/delete-variable.md +18 -0
  164. package/docs/examples/project/get-usage.md +2 -2
  165. package/docs/examples/project/get-variable.md +18 -0
  166. package/docs/examples/project/list-variables.md +18 -0
  167. package/docs/examples/project/update-variable.md +18 -0
  168. package/docs/examples/projects/create-key.md +1 -1
  169. package/docs/examples/projects/create-platform.md +1 -1
  170. package/docs/examples/projects/create-webhook.md +1 -1
  171. package/docs/examples/projects/create.md +2 -2
  172. package/docs/examples/projects/delete-email-template.md +18 -0
  173. package/docs/examples/projects/delete-key.md +1 -1
  174. package/docs/examples/projects/delete-platform.md +1 -1
  175. package/docs/examples/projects/delete-sms-template.md +18 -0
  176. package/docs/examples/projects/delete-webhook.md +1 -1
  177. package/docs/examples/projects/delete.md +2 -2
  178. package/docs/examples/projects/get-email-template.md +18 -0
  179. package/docs/examples/projects/get-key.md +1 -1
  180. package/docs/examples/projects/get-platform.md +1 -1
  181. package/docs/examples/projects/get-sms-template.md +18 -0
  182. package/docs/examples/projects/get-webhook.md +1 -1
  183. package/docs/examples/projects/get.md +1 -1
  184. package/docs/examples/projects/list-keys.md +1 -1
  185. package/docs/examples/projects/list-platforms.md +1 -1
  186. package/docs/examples/projects/list-webhooks.md +1 -1
  187. package/docs/examples/projects/list.md +1 -1
  188. package/docs/examples/projects/update-auth-duration.md +1 -1
  189. package/docs/examples/projects/update-auth-limit.md +1 -1
  190. package/docs/examples/projects/update-auth-password-dictionary.md +1 -1
  191. package/docs/examples/projects/update-auth-password-history.md +1 -1
  192. package/docs/examples/projects/update-auth-sessions-limit.md +1 -1
  193. package/docs/examples/projects/update-auth-status.md +1 -1
  194. package/docs/examples/projects/update-email-template.md +18 -0
  195. package/docs/examples/projects/update-key.md +1 -1
  196. package/docs/examples/projects/update-o-auth2.md +1 -1
  197. package/docs/examples/projects/{delete-domain.md → update-personal-data-check.md} +2 -2
  198. package/docs/examples/projects/update-platform.md +1 -1
  199. package/docs/examples/projects/{create-domain.md → update-service-status-all.md} +2 -2
  200. package/docs/examples/projects/update-service-status.md +1 -1
  201. package/docs/examples/projects/update-sms-template.md +18 -0
  202. package/docs/examples/projects/{get-domain.md → update-smtp-configuration.md} +2 -2
  203. package/docs/examples/projects/{list-domains.md → update-team.md} +2 -2
  204. package/docs/examples/projects/update-webhook-signature.md +1 -1
  205. package/docs/examples/projects/update-webhook.md +1 -1
  206. package/docs/examples/projects/update.md +1 -1
  207. package/docs/examples/proxy/create-rule.md +18 -0
  208. package/docs/examples/proxy/delete-rule.md +18 -0
  209. package/docs/examples/proxy/get-rule.md +18 -0
  210. package/docs/examples/proxy/list-rules.md +18 -0
  211. package/docs/examples/proxy/update-rule-verification.md +18 -0
  212. package/docs/examples/storage/create-bucket.md +1 -1
  213. package/docs/examples/storage/create-file.md +1 -1
  214. package/docs/examples/storage/delete-bucket.md +1 -1
  215. package/docs/examples/storage/delete-file.md +1 -1
  216. package/docs/examples/storage/get-bucket-usage.md +1 -1
  217. package/docs/examples/storage/get-bucket.md +1 -1
  218. package/docs/examples/storage/get-file-download.md +1 -1
  219. package/docs/examples/storage/get-file-preview.md +1 -1
  220. package/docs/examples/storage/get-file-view.md +1 -1
  221. package/docs/examples/storage/get-file.md +1 -1
  222. package/docs/examples/storage/get-usage.md +1 -1
  223. package/docs/examples/storage/list-buckets.md +1 -1
  224. package/docs/examples/storage/list-files.md +1 -1
  225. package/docs/examples/storage/update-bucket.md +1 -1
  226. package/docs/examples/storage/update-file.md +1 -1
  227. package/docs/examples/teams/create-membership.md +2 -2
  228. package/docs/examples/teams/create.md +1 -1
  229. package/docs/examples/teams/delete-membership.md +1 -1
  230. package/docs/examples/teams/delete.md +1 -1
  231. package/docs/examples/teams/get-membership.md +1 -1
  232. package/docs/examples/teams/get-prefs.md +1 -1
  233. package/docs/examples/teams/get.md +1 -1
  234. package/docs/examples/teams/list-logs.md +1 -1
  235. package/docs/examples/teams/list-memberships.md +1 -1
  236. package/docs/examples/teams/list.md +1 -1
  237. package/docs/examples/teams/update-membership-status.md +1 -1
  238. package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
  239. package/docs/examples/teams/update-name.md +1 -1
  240. package/docs/examples/teams/update-prefs.md +1 -1
  241. package/docs/examples/users/create-argon2user.md +1 -1
  242. package/docs/examples/users/create-bcrypt-user.md +1 -1
  243. package/docs/examples/users/create-m-d5user.md +1 -1
  244. package/docs/examples/users/create-p-h-pass-user.md +1 -1
  245. package/docs/examples/users/create-s-h-a-user.md +1 -1
  246. package/docs/examples/users/create-scrypt-modified-user.md +1 -1
  247. package/docs/examples/users/create-scrypt-user.md +1 -1
  248. package/docs/examples/users/create.md +1 -1
  249. package/docs/examples/users/delete-identity.md +18 -0
  250. package/docs/examples/users/delete-session.md +1 -1
  251. package/docs/examples/users/delete-sessions.md +1 -1
  252. package/docs/examples/users/delete.md +1 -1
  253. package/docs/examples/users/get-prefs.md +1 -1
  254. package/docs/examples/users/get-usage.md +1 -1
  255. package/docs/examples/users/get.md +1 -1
  256. package/docs/examples/users/list-identities.md +18 -0
  257. package/docs/examples/users/list-logs.md +1 -1
  258. package/docs/examples/users/list-memberships.md +1 -1
  259. package/docs/examples/users/list-sessions.md +1 -1
  260. package/docs/examples/users/list.md +1 -1
  261. package/docs/examples/users/update-email-verification.md +1 -1
  262. package/docs/examples/users/update-email.md +1 -1
  263. package/docs/examples/users/update-labels.md +18 -0
  264. package/docs/examples/users/update-name.md +1 -1
  265. package/docs/examples/users/update-password.md +1 -1
  266. package/docs/examples/users/update-phone-verification.md +1 -1
  267. package/docs/examples/users/update-phone.md +1 -1
  268. package/docs/examples/users/update-prefs.md +1 -1
  269. package/docs/examples/users/update-status.md +1 -1
  270. package/docs/examples/vcs/create-repository-detection.md +18 -0
  271. package/docs/examples/vcs/create-repository.md +18 -0
  272. package/docs/examples/vcs/delete-installation.md +18 -0
  273. package/docs/examples/vcs/get-installation.md +18 -0
  274. package/docs/examples/vcs/get-repository.md +18 -0
  275. package/docs/examples/vcs/list-installations.md +18 -0
  276. package/docs/examples/vcs/list-repositories.md +18 -0
  277. package/docs/examples/vcs/list-repository-branches.md +18 -0
  278. package/docs/examples/vcs/update-external-deployments.md +18 -0
  279. package/package.json +3 -2
  280. package/src/client.ts +2 -2
  281. package/src/index.ts +4 -0
  282. package/src/models.ts +863 -233
  283. package/src/query.ts +1 -1
  284. package/src/role.ts +72 -6
  285. package/src/services/account.ts +1052 -1055
  286. package/src/services/assistant.ts +38 -0
  287. package/src/services/avatars.ts +338 -337
  288. package/src/services/console.ts +16 -16
  289. package/src/services/databases.ts +2170 -2140
  290. package/src/services/functions.ts +804 -657
  291. package/src/services/graphql.ts +47 -47
  292. package/src/services/health.ts +373 -204
  293. package/src/services/locale.ts +156 -137
  294. package/src/services/migrations.ts +707 -0
  295. package/src/services/project.ts +178 -20
  296. package/src/services/projects.ts +1511 -1256
  297. package/src/services/proxy.ts +150 -0
  298. package/src/services/storage.ts +572 -577
  299. package/src/services/teams.ts +498 -501
  300. package/src/services/users.ts +1091 -1001
  301. package/src/services/vcs.ts +272 -0
  302. package/types/index.d.ts +4 -0
  303. package/types/models.d.ts +863 -233
  304. package/types/role.d.ts +62 -0
  305. package/types/services/account.d.ts +116 -104
  306. package/types/services/assistant.d.ts +14 -0
  307. package/types/services/avatars.d.ts +18 -17
  308. package/types/services/console.d.ts +2 -2
  309. package/types/services/databases.d.ts +111 -105
  310. package/types/services/functions.d.ts +95 -55
  311. package/types/services/graphql.d.ts +4 -4
  312. package/types/services/health.d.ts +97 -26
  313. package/types/services/locale.d.ts +24 -14
  314. package/types/services/migrations.d.ts +185 -0
  315. package/types/services/project.d.ts +60 -3
  316. package/types/services/projects.d.ts +174 -104
  317. package/types/services/proxy.d.ts +59 -0
  318. package/types/services/storage.d.ts +29 -28
  319. package/types/services/teams.d.ts +36 -35
  320. package/types/services/users.d.ts +105 -66
  321. package/types/services/vcs.d.ts +97 -0
  322. package/docs/examples/projects/update-domain-verification.md +0 -18
@@ -10,1060 +10,1057 @@ export class Account extends Service {
10
10
  super(client);
11
11
  }
12
12
 
13
- /**
14
- * Get Account
15
- *
16
- * Get currently logged in user data as JSON object.
17
- *
18
- * @throws {AppwriteException}
19
- * @returns {Promise}
20
- */
21
- async get<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> {
22
- let path = '/account';
23
- let payload: Payload = {};
24
-
25
- const uri = new URL(this.client.config.endpoint + path);
26
- return await this.client.call('get', uri, {
27
- 'content-type': 'application/json',
28
- }, payload);
29
- }
30
-
31
- /**
32
- * Create Account
33
- *
34
- * Use this endpoint to allow a new user to register a new account in your
35
- * project. After the user registration completes successfully, you can use
36
- * the [/account/verfication](/docs/client/account#accountCreateVerification)
37
- * route to start verifying the user email address. To allow the new user to
38
- * login to their new account, you need to create a new [account
39
- * session](/docs/client/account#accountCreateSession).
40
- *
41
- * @param {string} userId
42
- * @param {string} email
43
- * @param {string} password
44
- * @param {string} name
45
- * @throws {AppwriteException}
46
- * @returns {Promise}
47
- */
48
- async create<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
49
- if (typeof userId === 'undefined') {
50
- throw new AppwriteException('Missing required parameter: "userId"');
51
- }
52
-
53
- if (typeof email === 'undefined') {
54
- throw new AppwriteException('Missing required parameter: "email"');
55
- }
56
-
57
- if (typeof password === 'undefined') {
58
- throw new AppwriteException('Missing required parameter: "password"');
59
- }
60
-
61
- let path = '/account';
62
- let payload: Payload = {};
63
-
64
- if (typeof userId !== 'undefined') {
65
- payload['userId'] = userId;
66
- }
67
-
68
- if (typeof email !== 'undefined') {
69
- payload['email'] = email;
70
- }
71
-
72
- if (typeof password !== 'undefined') {
73
- payload['password'] = password;
74
- }
75
-
76
- if (typeof name !== 'undefined') {
77
- payload['name'] = name;
78
- }
79
-
80
- const uri = new URL(this.client.config.endpoint + path);
81
- return await this.client.call('post', uri, {
82
- 'content-type': 'application/json',
83
- }, payload);
84
- }
85
-
86
- /**
87
- * Update Email
88
- *
89
- * Update currently logged in user account email address. After changing user
90
- * address, the user confirmation status will get reset. A new confirmation
91
- * email is not sent automatically however you can use the send confirmation
92
- * email endpoint again to send the confirmation email. For security measures,
93
- * user password is required to complete this request.
94
- * This endpoint can also be used to convert an anonymous account to a normal
95
- * one, by passing an email address and a new password.
96
- *
97
- *
98
- * @param {string} email
99
- * @param {string} password
100
- * @throws {AppwriteException}
101
- * @returns {Promise}
102
- */
103
- async updateEmail<Preferences extends Models.Preferences>(email: string, password: string): Promise<Models.User<Preferences>> {
104
- if (typeof email === 'undefined') {
105
- throw new AppwriteException('Missing required parameter: "email"');
106
- }
107
-
108
- if (typeof password === 'undefined') {
109
- throw new AppwriteException('Missing required parameter: "password"');
110
- }
111
-
112
- let path = '/account/email';
113
- let payload: Payload = {};
114
-
115
- if (typeof email !== 'undefined') {
116
- payload['email'] = email;
117
- }
118
-
119
- if (typeof password !== 'undefined') {
120
- payload['password'] = password;
121
- }
122
-
123
- const uri = new URL(this.client.config.endpoint + path);
124
- return await this.client.call('patch', uri, {
125
- 'content-type': 'application/json',
126
- }, payload);
127
- }
128
-
129
- /**
130
- * Create account using an invite code
131
- *
132
- * Use this endpoint to allow a new user to register a new account in your
133
- * project. After the user registration completes successfully, you can use
134
- * the [/account/verfication](/docs/client/account#accountCreateVerification)
135
- * route to start verifying the user email address. To allow the new user to
136
- * login to their new account, you need to create a new [account
137
- * session](/docs/client/account#accountCreateSession).
138
- *
139
- * @param {string} userId
140
- * @param {string} email
141
- * @param {string} password
142
- * @param {string} name
143
- * @param {string} code
144
- * @throws {AppwriteException}
145
- * @returns {Promise}
146
- */
147
- async createWithInviteCode<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string, code?: string): Promise<Models.Account<Preferences>> {
148
- if (typeof userId === 'undefined') {
149
- throw new AppwriteException('Missing required parameter: "userId"');
150
- }
151
-
152
- if (typeof email === 'undefined') {
153
- throw new AppwriteException('Missing required parameter: "email"');
154
- }
155
-
156
- if (typeof password === 'undefined') {
157
- throw new AppwriteException('Missing required parameter: "password"');
158
- }
159
-
160
- let path = '/account/invite';
161
- let payload: Payload = {};
162
-
163
- if (typeof userId !== 'undefined') {
164
- payload['userId'] = userId;
165
- }
166
-
167
- if (typeof email !== 'undefined') {
168
- payload['email'] = email;
169
- }
170
-
171
- if (typeof password !== 'undefined') {
172
- payload['password'] = password;
173
- }
174
-
175
- if (typeof name !== 'undefined') {
176
- payload['name'] = name;
177
- }
178
-
179
- if (typeof code !== 'undefined') {
180
- payload['code'] = code;
181
- }
182
-
183
- const uri = new URL(this.client.config.endpoint + path);
184
- return await this.client.call('post', uri, {
185
- 'content-type': 'application/json',
186
- }, payload);
187
- }
188
-
189
- /**
190
- * Create JWT
191
- *
192
- * Use this endpoint to create a JSON Web Token. You can use the resulting JWT
193
- * to authenticate on behalf of the current user when working with the
194
- * Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
195
- * from its creation and will be invalid if the user will logout in that time
196
- * frame.
197
- *
198
- * @throws {AppwriteException}
199
- * @returns {Promise}
200
- */
201
- async createJWT(): Promise<Models.Jwt> {
202
- let path = '/account/jwt';
203
- let payload: Payload = {};
204
-
205
- const uri = new URL(this.client.config.endpoint + path);
206
- return await this.client.call('post', uri, {
207
- 'content-type': 'application/json',
208
- }, payload);
209
- }
210
-
211
- /**
212
- * List Logs
213
- *
214
- * Get currently logged in user list of latest security activity logs. Each
215
- * log returns user IP address, location and date and time of log.
216
- *
217
- * @param {string[]} queries
218
- * @throws {AppwriteException}
219
- * @returns {Promise}
220
- */
221
- async listLogs(queries?: string[]): Promise<Models.LogList> {
222
- let path = '/account/logs';
223
- let payload: Payload = {};
224
-
225
- if (typeof queries !== 'undefined') {
226
- payload['queries'] = queries;
227
- }
228
-
229
- const uri = new URL(this.client.config.endpoint + path);
230
- return await this.client.call('get', uri, {
231
- 'content-type': 'application/json',
232
- }, payload);
233
- }
234
-
235
- /**
236
- * Update Name
237
- *
238
- * Update currently logged in user account name.
239
- *
240
- * @param {string} name
241
- * @throws {AppwriteException}
242
- * @returns {Promise}
243
- */
244
- async updateName<Preferences extends Models.Preferences>(name: string): Promise<Models.User<Preferences>> {
245
- if (typeof name === 'undefined') {
246
- throw new AppwriteException('Missing required parameter: "name"');
247
- }
248
-
249
- let path = '/account/name';
250
- let payload: Payload = {};
251
-
252
- if (typeof name !== 'undefined') {
253
- payload['name'] = name;
254
- }
255
-
256
- const uri = new URL(this.client.config.endpoint + path);
257
- return await this.client.call('patch', uri, {
258
- 'content-type': 'application/json',
259
- }, payload);
260
- }
261
-
262
- /**
263
- * Update Password
264
- *
265
- * Update currently logged in user password. For validation, user is required
266
- * to pass in the new password, and the old password. For users created with
267
- * OAuth, Team Invites and Magic URL, oldPassword is optional.
268
- *
269
- * @param {string} password
270
- * @param {string} oldPassword
271
- * @throws {AppwriteException}
272
- * @returns {Promise}
273
- */
274
- async updatePassword<Preferences extends Models.Preferences>(password: string, oldPassword?: string): Promise<Models.User<Preferences>> {
275
- if (typeof password === 'undefined') {
276
- throw new AppwriteException('Missing required parameter: "password"');
277
- }
278
-
279
- let path = '/account/password';
280
- let payload: Payload = {};
281
-
282
- if (typeof password !== 'undefined') {
283
- payload['password'] = password;
284
- }
285
-
286
- if (typeof oldPassword !== 'undefined') {
287
- payload['oldPassword'] = oldPassword;
288
- }
289
-
290
- const uri = new URL(this.client.config.endpoint + path);
291
- return await this.client.call('patch', uri, {
292
- 'content-type': 'application/json',
293
- }, payload);
294
- }
295
-
296
- /**
297
- * Update Phone
298
- *
299
- * Update the currently logged in user's phone number. After updating the
300
- * phone number, the phone verification status will be reset. A confirmation
301
- * SMS is not sent automatically, however you can use the [POST
302
- * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification)
303
- * endpoint to send a confirmation SMS.
304
- *
305
- * @param {string} phone
306
- * @param {string} password
307
- * @throws {AppwriteException}
308
- * @returns {Promise}
309
- */
310
- async updatePhone<Preferences extends Models.Preferences>(phone: string, password: string): Promise<Models.User<Preferences>> {
311
- if (typeof phone === 'undefined') {
312
- throw new AppwriteException('Missing required parameter: "phone"');
313
- }
314
-
315
- if (typeof password === 'undefined') {
316
- throw new AppwriteException('Missing required parameter: "password"');
317
- }
318
-
319
- let path = '/account/phone';
320
- let payload: Payload = {};
321
-
322
- if (typeof phone !== 'undefined') {
323
- payload['phone'] = phone;
324
- }
325
-
326
- if (typeof password !== 'undefined') {
327
- payload['password'] = password;
328
- }
329
-
330
- const uri = new URL(this.client.config.endpoint + path);
331
- return await this.client.call('patch', uri, {
332
- 'content-type': 'application/json',
333
- }, payload);
334
- }
335
-
336
- /**
337
- * Get Account Preferences
338
- *
339
- * Get currently logged in user preferences as a key-value object.
340
- *
341
- * @throws {AppwriteException}
342
- * @returns {Promise}
343
- */
344
- async getPrefs<Preferences extends Models.Preferences>(): Promise<Preferences> {
345
- let path = '/account/prefs';
346
- let payload: Payload = {};
347
-
348
- const uri = new URL(this.client.config.endpoint + path);
349
- return await this.client.call('get', uri, {
350
- 'content-type': 'application/json',
351
- }, payload);
352
- }
353
-
354
- /**
355
- * Update Preferences
356
- *
357
- * Update currently logged in user account preferences. The object you pass is
358
- * stored as is, and replaces any previous value. The maximum allowed prefs
359
- * size is 64kB and throws error if exceeded.
360
- *
361
- * @param {Partial<Preferences>} prefs
362
- * @throws {AppwriteException}
363
- * @returns {Promise}
364
- */
365
- async updatePrefs<Preferences extends Models.Preferences>(prefs: Partial<Preferences>): Promise<Models.User<Preferences>> {
366
- if (typeof prefs === 'undefined') {
367
- throw new AppwriteException('Missing required parameter: "prefs"');
368
- }
369
-
370
- let path = '/account/prefs';
371
- let payload: Payload = {};
372
-
373
- if (typeof prefs !== 'undefined') {
374
- payload['prefs'] = prefs;
375
- }
376
-
377
- const uri = new URL(this.client.config.endpoint + path);
378
- return await this.client.call('patch', uri, {
379
- 'content-type': 'application/json',
380
- }, payload);
381
- }
382
-
383
- /**
384
- * Create Password Recovery
385
- *
386
- * Sends the user an email with a temporary secret key for password reset.
387
- * When the user clicks the confirmation link he is redirected back to your
388
- * app password reset URL with the secret key and email address values
389
- * attached to the URL query string. Use the query string params to submit a
390
- * request to the [PUT
391
- * /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to
392
- * complete the process. The verification link sent to the user's email
393
- * address is valid for 1 hour.
394
- *
395
- * @param {string} email
396
- * @param {string} url
397
- * @throws {AppwriteException}
398
- * @returns {Promise}
399
- */
400
- async createRecovery(email: string, url: string): Promise<Models.Token> {
401
- if (typeof email === 'undefined') {
402
- throw new AppwriteException('Missing required parameter: "email"');
403
- }
404
-
405
- if (typeof url === 'undefined') {
406
- throw new AppwriteException('Missing required parameter: "url"');
407
- }
408
-
409
- let path = '/account/recovery';
410
- let payload: Payload = {};
411
-
412
- if (typeof email !== 'undefined') {
413
- payload['email'] = email;
414
- }
415
-
416
- if (typeof url !== 'undefined') {
417
- payload['url'] = url;
418
- }
419
-
420
- const uri = new URL(this.client.config.endpoint + path);
421
- return await this.client.call('post', uri, {
422
- 'content-type': 'application/json',
423
- }, payload);
424
- }
425
-
426
- /**
427
- * Create Password Recovery (confirmation)
428
- *
429
- * Use this endpoint to complete the user account password reset. Both the
430
- * **userId** and **secret** arguments will be passed as query parameters to
431
- * the redirect URL you have provided when sending your request to the [POST
432
- * /account/recovery](/docs/client/account#accountCreateRecovery) endpoint.
433
- *
434
- * Please note that in order to avoid a [Redirect
435
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
436
- * the only valid redirect URLs are the ones from domains you have set when
437
- * adding your platforms in the console interface.
438
- *
439
- * @param {string} userId
440
- * @param {string} secret
441
- * @param {string} password
442
- * @param {string} passwordAgain
443
- * @throws {AppwriteException}
444
- * @returns {Promise}
445
- */
446
- async updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise<Models.Token> {
447
- if (typeof userId === 'undefined') {
448
- throw new AppwriteException('Missing required parameter: "userId"');
449
- }
450
-
451
- if (typeof secret === 'undefined') {
452
- throw new AppwriteException('Missing required parameter: "secret"');
453
- }
454
-
455
- if (typeof password === 'undefined') {
456
- throw new AppwriteException('Missing required parameter: "password"');
457
- }
458
-
459
- if (typeof passwordAgain === 'undefined') {
460
- throw new AppwriteException('Missing required parameter: "passwordAgain"');
461
- }
462
-
463
- let path = '/account/recovery';
464
- let payload: Payload = {};
465
-
466
- if (typeof userId !== 'undefined') {
467
- payload['userId'] = userId;
468
- }
469
-
470
- if (typeof secret !== 'undefined') {
471
- payload['secret'] = secret;
472
- }
473
-
474
- if (typeof password !== 'undefined') {
475
- payload['password'] = password;
476
- }
477
-
478
- if (typeof passwordAgain !== 'undefined') {
479
- payload['passwordAgain'] = passwordAgain;
480
- }
481
-
482
- const uri = new URL(this.client.config.endpoint + path);
483
- return await this.client.call('put', uri, {
484
- 'content-type': 'application/json',
485
- }, payload);
486
- }
487
-
488
- /**
489
- * List Sessions
490
- *
491
- * Get currently logged in user list of active sessions across different
492
- * devices.
493
- *
494
- * @throws {AppwriteException}
495
- * @returns {Promise}
496
- */
497
- async listSessions(): Promise<Models.SessionList> {
498
- let path = '/account/sessions';
499
- let payload: Payload = {};
500
-
501
- const uri = new URL(this.client.config.endpoint + path);
502
- return await this.client.call('get', uri, {
503
- 'content-type': 'application/json',
504
- }, payload);
505
- }
506
-
507
- /**
508
- * Delete Sessions
509
- *
510
- * Delete all sessions from the user account and remove any sessions cookies
511
- * from the end client.
512
- *
513
- * @throws {AppwriteException}
514
- * @returns {Promise}
515
- */
516
- async deleteSessions(): Promise<{}> {
517
- let path = '/account/sessions';
518
- let payload: Payload = {};
519
-
520
- const uri = new URL(this.client.config.endpoint + path);
521
- return await this.client.call('delete', uri, {
522
- 'content-type': 'application/json',
523
- }, payload);
524
- }
525
-
526
- /**
527
- * Create Anonymous Session
528
- *
529
- * Use this endpoint to allow a new user to register an anonymous account in
530
- * your project. This route will also create a new session for the user. To
531
- * allow the new user to convert an anonymous account to a normal account, you
532
- * need to update its [email and
533
- * password](/docs/client/account#accountUpdateEmail) or create an [OAuth2
534
- * session](/docs/client/account#accountCreateOAuth2Session).
535
- *
536
- * @throws {AppwriteException}
537
- * @returns {Promise}
538
- */
539
- async createAnonymousSession(): Promise<Models.Session> {
540
- let path = '/account/sessions/anonymous';
541
- let payload: Payload = {};
542
-
543
- const uri = new URL(this.client.config.endpoint + path);
544
- return await this.client.call('post', uri, {
545
- 'content-type': 'application/json',
546
- }, payload);
547
- }
548
-
549
- /**
550
- * Create Email Session
551
- *
552
- * Allow the user to login into their account by providing a valid email and
553
- * password combination. This route will create a new session for the user.
554
- *
555
- * A user is limited to 10 active sessions at a time by default. [Learn more
556
- * about session limits](/docs/authentication-security#limits).
557
- *
558
- * @param {string} email
559
- * @param {string} password
560
- * @throws {AppwriteException}
561
- * @returns {Promise}
562
- */
563
- async createEmailSession(email: string, password: string): Promise<Models.Session> {
564
- if (typeof email === 'undefined') {
565
- throw new AppwriteException('Missing required parameter: "email"');
566
- }
567
-
568
- if (typeof password === 'undefined') {
569
- throw new AppwriteException('Missing required parameter: "password"');
570
- }
571
-
572
- let path = '/account/sessions/email';
573
- let payload: Payload = {};
574
-
575
- if (typeof email !== 'undefined') {
576
- payload['email'] = email;
577
- }
578
-
579
- if (typeof password !== 'undefined') {
580
- payload['password'] = password;
581
- }
582
-
583
- const uri = new URL(this.client.config.endpoint + path);
584
- return await this.client.call('post', uri, {
585
- 'content-type': 'application/json',
586
- }, payload);
587
- }
588
-
589
- /**
590
- * Create Magic URL session
591
- *
592
- * Sends the user an email with a secret key for creating a session. If the
593
- * provided user ID has not be registered, a new user will be created. When
594
- * the user clicks the link in the email, the user is redirected back to the
595
- * URL you provided with the secret key and userId values attached to the URL
596
- * query string. Use the query string parameters to submit a request to the
597
- * [PUT
598
- * /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession)
599
- * endpoint to complete the login process. The link sent to the user's email
600
- * address is valid for 1 hour. If you are on a mobile device you can leave
601
- * the URL parameter empty, so that the login completion will be handled by
602
- * your Appwrite instance by default.
603
- *
604
- * A user is limited to 10 active sessions at a time by default. [Learn more
605
- * about session limits](/docs/authentication-security#limits).
606
- *
607
- * @param {string} userId
608
- * @param {string} email
609
- * @param {string} url
610
- * @throws {AppwriteException}
611
- * @returns {Promise}
612
- */
613
- async createMagicURLSession(userId: string, email: string, url?: string): Promise<Models.Token> {
614
- if (typeof userId === 'undefined') {
615
- throw new AppwriteException('Missing required parameter: "userId"');
616
- }
617
-
618
- if (typeof email === 'undefined') {
619
- throw new AppwriteException('Missing required parameter: "email"');
620
- }
621
-
622
- let path = '/account/sessions/magic-url';
623
- let payload: Payload = {};
624
-
625
- if (typeof userId !== 'undefined') {
626
- payload['userId'] = userId;
627
- }
628
-
629
- if (typeof email !== 'undefined') {
630
- payload['email'] = email;
631
- }
632
-
633
- if (typeof url !== 'undefined') {
634
- payload['url'] = url;
635
- }
636
-
637
- const uri = new URL(this.client.config.endpoint + path);
638
- return await this.client.call('post', uri, {
639
- 'content-type': 'application/json',
640
- }, payload);
641
- }
642
-
643
- /**
644
- * Create Magic URL session (confirmation)
645
- *
646
- * Use this endpoint to complete creating the session with the Magic URL. Both
647
- * the **userId** and **secret** arguments will be passed as query parameters
648
- * to the redirect URL you have provided when sending your request to the
649
- * [POST
650
- * /account/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession)
651
- * endpoint.
652
- *
653
- * Please note that in order to avoid a [Redirect
654
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
655
- * the only valid redirect URLs are the ones from domains you have set when
656
- * adding your platforms in the console interface.
657
- *
658
- * @param {string} userId
659
- * @param {string} secret
660
- * @throws {AppwriteException}
661
- * @returns {Promise}
662
- */
663
- async updateMagicURLSession(userId: string, secret: string): Promise<Models.Session> {
664
- if (typeof userId === 'undefined') {
665
- throw new AppwriteException('Missing required parameter: "userId"');
666
- }
667
-
668
- if (typeof secret === 'undefined') {
669
- throw new AppwriteException('Missing required parameter: "secret"');
670
- }
671
-
672
- let path = '/account/sessions/magic-url';
673
- let payload: Payload = {};
674
-
675
- if (typeof userId !== 'undefined') {
676
- payload['userId'] = userId;
677
- }
678
-
679
- if (typeof secret !== 'undefined') {
680
- payload['secret'] = secret;
681
- }
682
-
683
- const uri = new URL(this.client.config.endpoint + path);
684
- return await this.client.call('put', uri, {
685
- 'content-type': 'application/json',
686
- }, payload);
687
- }
688
-
689
- /**
690
- * Create OAuth2 Session
691
- *
692
- * Allow the user to login to their account using the OAuth2 provider of their
693
- * choice. Each OAuth2 provider should be enabled from the Appwrite console
694
- * first. Use the success and failure arguments to provide a redirect URL's
695
- * back to your app when login is completed.
696
- *
697
- * If there is already an active session, the new session will be attached to
698
- * the logged-in account. If there are no active sessions, the server will
699
- * attempt to look for a user with the same email address as the email
700
- * received from the OAuth2 provider and attach the new session to the
701
- * existing user. If no matching user is found - the server will create a new
702
- * user.
703
- *
704
- * A user is limited to 10 active sessions at a time by default. [Learn more
705
- * about session limits](/docs/authentication-security#limits).
706
- *
707
- *
708
- * @param {string} provider
709
- * @param {string} success
710
- * @param {string} failure
711
- * @param {string[]} scopes
712
- * @throws {AppwriteException}
713
- * @returns {void|string}
714
- */
715
- createOAuth2Session(provider: string, success?: string, failure?: string, scopes?: string[]): void | URL {
716
- if (typeof provider === 'undefined') {
717
- throw new AppwriteException('Missing required parameter: "provider"');
718
- }
719
-
720
- let path = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider);
721
- let payload: Payload = {};
722
-
723
- if (typeof success !== 'undefined') {
724
- payload['success'] = success;
725
- }
726
-
727
- if (typeof failure !== 'undefined') {
728
- payload['failure'] = failure;
729
- }
730
-
731
- if (typeof scopes !== 'undefined') {
732
- payload['scopes'] = scopes;
733
- }
734
-
735
- const uri = new URL(this.client.config.endpoint + path);
736
- payload['project'] = this.client.config.project;
737
-
738
-
739
- for (const [key, value] of Object.entries(Service.flatten(payload))) {
740
- uri.searchParams.append(key, value);
741
- }
742
- if (typeof window !== 'undefined' && window?.location) {
743
- window.location.href = uri.toString();
744
- } else {
745
- return uri;
746
- }
747
- }
748
-
749
- /**
750
- * Create Phone session
751
- *
752
- * Sends the user an SMS with a secret key for creating a session. If the
753
- * provided user ID has not be registered, a new user will be created. Use the
754
- * returned user ID and secret and submit a request to the [PUT
755
- * /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession)
756
- * endpoint to complete the login process. The secret sent to the user's phone
757
- * is valid for 15 minutes.
758
- *
759
- * A user is limited to 10 active sessions at a time by default. [Learn more
760
- * about session limits](/docs/authentication-security#limits).
761
- *
762
- * @param {string} userId
763
- * @param {string} phone
764
- * @throws {AppwriteException}
765
- * @returns {Promise}
766
- */
767
- async createPhoneSession(userId: string, phone: string): Promise<Models.Token> {
768
- if (typeof userId === 'undefined') {
769
- throw new AppwriteException('Missing required parameter: "userId"');
770
- }
771
-
772
- if (typeof phone === 'undefined') {
773
- throw new AppwriteException('Missing required parameter: "phone"');
774
- }
775
-
776
- let path = '/account/sessions/phone';
777
- let payload: Payload = {};
778
-
779
- if (typeof userId !== 'undefined') {
780
- payload['userId'] = userId;
781
- }
782
-
783
- if (typeof phone !== 'undefined') {
784
- payload['phone'] = phone;
785
- }
786
-
787
- const uri = new URL(this.client.config.endpoint + path);
788
- return await this.client.call('post', uri, {
789
- 'content-type': 'application/json',
790
- }, payload);
791
- }
792
-
793
- /**
794
- * Create Phone Session (confirmation)
795
- *
796
- * Use this endpoint to complete creating a session with SMS. Use the
797
- * **userId** from the
798
- * [createPhoneSession](/docs/client/account#accountCreatePhoneSession)
799
- * endpoint and the **secret** received via SMS to successfully update and
800
- * confirm the phone session.
801
- *
802
- * @param {string} userId
803
- * @param {string} secret
804
- * @throws {AppwriteException}
805
- * @returns {Promise}
806
- */
807
- async updatePhoneSession(userId: string, secret: string): Promise<Models.Session> {
808
- if (typeof userId === 'undefined') {
809
- throw new AppwriteException('Missing required parameter: "userId"');
810
- }
811
-
812
- if (typeof secret === 'undefined') {
813
- throw new AppwriteException('Missing required parameter: "secret"');
814
- }
815
-
816
- let path = '/account/sessions/phone';
817
- let payload: Payload = {};
818
-
819
- if (typeof userId !== 'undefined') {
820
- payload['userId'] = userId;
821
- }
822
-
823
- if (typeof secret !== 'undefined') {
824
- payload['secret'] = secret;
825
- }
826
-
827
- const uri = new URL(this.client.config.endpoint + path);
828
- return await this.client.call('put', uri, {
829
- 'content-type': 'application/json',
830
- }, payload);
831
- }
832
-
833
- /**
834
- * Get Session
835
- *
836
- * Use this endpoint to get a logged in user's session using a Session ID.
837
- * Inputting 'current' will return the current session being used.
838
- *
839
- * @param {string} sessionId
840
- * @throws {AppwriteException}
841
- * @returns {Promise}
842
- */
843
- async getSession(sessionId: string): Promise<Models.Session> {
844
- if (typeof sessionId === 'undefined') {
845
- throw new AppwriteException('Missing required parameter: "sessionId"');
846
- }
847
-
848
- let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
849
- let payload: Payload = {};
850
-
851
- const uri = new URL(this.client.config.endpoint + path);
852
- return await this.client.call('get', uri, {
853
- 'content-type': 'application/json',
854
- }, payload);
855
- }
856
-
857
- /**
858
- * Update OAuth Session (Refresh Tokens)
859
- *
860
- * Access tokens have limited lifespan and expire to mitigate security risks.
861
- * If session was created using an OAuth provider, this route can be used to
862
- * "refresh" the access token.
863
- *
864
- * @param {string} sessionId
865
- * @throws {AppwriteException}
866
- * @returns {Promise}
867
- */
868
- async updateSession(sessionId: string): Promise<Models.Session> {
869
- if (typeof sessionId === 'undefined') {
870
- throw new AppwriteException('Missing required parameter: "sessionId"');
871
- }
872
-
873
- let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
874
- let payload: Payload = {};
875
-
876
- const uri = new URL(this.client.config.endpoint + path);
877
- return await this.client.call('patch', uri, {
878
- 'content-type': 'application/json',
879
- }, payload);
880
- }
881
-
882
- /**
883
- * Delete Session
884
- *
885
- * Use this endpoint to log out the currently logged in user from all their
886
- * account sessions across all of their different devices. When using the
887
- * Session ID argument, only the unique session ID provided is deleted.
888
- *
889
- *
890
- * @param {string} sessionId
891
- * @throws {AppwriteException}
892
- * @returns {Promise}
893
- */
894
- async deleteSession(sessionId: string): Promise<{}> {
895
- if (typeof sessionId === 'undefined') {
896
- throw new AppwriteException('Missing required parameter: "sessionId"');
897
- }
898
-
899
- let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
900
- let payload: Payload = {};
901
-
902
- const uri = new URL(this.client.config.endpoint + path);
903
- return await this.client.call('delete', uri, {
904
- 'content-type': 'application/json',
905
- }, payload);
906
- }
907
-
908
- /**
909
- * Update Status
910
- *
911
- * Block the currently logged in user account. Behind the scene, the user
912
- * record is not deleted but permanently blocked from any access. To
913
- * completely delete a user, use the Users API instead.
914
- *
915
- * @throws {AppwriteException}
916
- * @returns {Promise}
917
- */
918
- async updateStatus<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> {
919
- let path = '/account/status';
920
- let payload: Payload = {};
921
-
922
- const uri = new URL(this.client.config.endpoint + path);
923
- return await this.client.call('patch', uri, {
924
- 'content-type': 'application/json',
925
- }, payload);
926
- }
927
-
928
- /**
929
- * Create Email Verification
930
- *
931
- * Use this endpoint to send a verification message to your user email address
932
- * to confirm they are the valid owners of that address. Both the **userId**
933
- * and **secret** arguments will be passed as query parameters to the URL you
934
- * have provided to be attached to the verification email. The provided URL
935
- * should redirect the user back to your app and allow you to complete the
936
- * verification process by verifying both the **userId** and **secret**
937
- * parameters. Learn more about how to [complete the verification
938
- * process](/docs/client/account#accountUpdateEmailVerification). The
939
- * verification link sent to the user's email address is valid for 7 days.
940
- *
941
- * Please note that in order to avoid a [Redirect
942
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
943
- * the only valid redirect URLs are the ones from domains you have set when
944
- * adding your platforms in the console interface.
945
- *
946
- *
947
- * @param {string} url
948
- * @throws {AppwriteException}
949
- * @returns {Promise}
950
- */
951
- async createVerification(url: string): Promise<Models.Token> {
952
- if (typeof url === 'undefined') {
953
- throw new AppwriteException('Missing required parameter: "url"');
954
- }
955
-
956
- let path = '/account/verification';
957
- let payload: Payload = {};
958
-
959
- if (typeof url !== 'undefined') {
960
- payload['url'] = url;
961
- }
962
-
963
- const uri = new URL(this.client.config.endpoint + path);
964
- return await this.client.call('post', uri, {
965
- 'content-type': 'application/json',
966
- }, payload);
967
- }
968
-
969
- /**
970
- * Create Email Verification (confirmation)
971
- *
972
- * Use this endpoint to complete the user email verification process. Use both
973
- * the **userId** and **secret** parameters that were attached to your app URL
974
- * to verify the user email ownership. If confirmed this route will return a
975
- * 200 status code.
976
- *
977
- * @param {string} userId
978
- * @param {string} secret
979
- * @throws {AppwriteException}
980
- * @returns {Promise}
981
- */
982
- async updateVerification(userId: string, secret: string): Promise<Models.Token> {
983
- if (typeof userId === 'undefined') {
984
- throw new AppwriteException('Missing required parameter: "userId"');
985
- }
986
-
987
- if (typeof secret === 'undefined') {
988
- throw new AppwriteException('Missing required parameter: "secret"');
989
- }
990
-
991
- let path = '/account/verification';
992
- let payload: Payload = {};
993
-
994
- if (typeof userId !== 'undefined') {
995
- payload['userId'] = userId;
996
- }
997
-
998
- if (typeof secret !== 'undefined') {
999
- payload['secret'] = secret;
1000
- }
1001
-
1002
- const uri = new URL(this.client.config.endpoint + path);
1003
- return await this.client.call('put', uri, {
1004
- 'content-type': 'application/json',
1005
- }, payload);
1006
- }
1007
-
1008
- /**
1009
- * Create Phone Verification
1010
- *
1011
- * Use this endpoint to send a verification SMS to the currently logged in
1012
- * user. This endpoint is meant for use after updating a user's phone number
1013
- * using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone)
1014
- * endpoint. Learn more about how to [complete the verification
1015
- * process](/docs/client/account#accountUpdatePhoneVerification). The
1016
- * verification code sent to the user's phone number is valid for 15 minutes.
1017
- *
1018
- * @throws {AppwriteException}
1019
- * @returns {Promise}
1020
- */
1021
- async createPhoneVerification(): Promise<Models.Token> {
1022
- let path = '/account/verification/phone';
1023
- let payload: Payload = {};
1024
-
1025
- const uri = new URL(this.client.config.endpoint + path);
1026
- return await this.client.call('post', uri, {
1027
- 'content-type': 'application/json',
1028
- }, payload);
1029
- }
1030
-
1031
- /**
1032
- * Create Phone Verification (confirmation)
1033
- *
1034
- * Use this endpoint to complete the user phone verification process. Use the
1035
- * **userId** and **secret** that were sent to your user's phone number to
1036
- * verify the user email ownership. If confirmed this route will return a 200
1037
- * status code.
1038
- *
1039
- * @param {string} userId
1040
- * @param {string} secret
1041
- * @throws {AppwriteException}
1042
- * @returns {Promise}
1043
- */
1044
- async updatePhoneVerification(userId: string, secret: string): Promise<Models.Token> {
1045
- if (typeof userId === 'undefined') {
1046
- throw new AppwriteException('Missing required parameter: "userId"');
1047
- }
1048
-
1049
- if (typeof secret === 'undefined') {
1050
- throw new AppwriteException('Missing required parameter: "secret"');
1051
- }
1052
-
1053
- let path = '/account/verification/phone';
1054
- let payload: Payload = {};
1055
-
1056
- if (typeof userId !== 'undefined') {
1057
- payload['userId'] = userId;
1058
- }
1059
-
1060
- if (typeof secret !== 'undefined') {
1061
- payload['secret'] = secret;
1062
- }
1063
-
1064
- const uri = new URL(this.client.config.endpoint + path);
1065
- return await this.client.call('put', uri, {
1066
- 'content-type': 'application/json',
1067
- }, payload);
13
+ /**
14
+ * Get account
15
+ *
16
+ * Get the currently logged in user.
17
+ *
18
+ * @throws {AppwriteException}
19
+ * @returns {Promise}
20
+ */
21
+ async get<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> {
22
+ const apiPath = '/account';
23
+ const payload: Payload = {};
24
+
25
+ const uri = new URL(this.client.config.endpoint + apiPath);
26
+ return await this.client.call('get', uri, {
27
+ 'content-type': 'application/json',
28
+ }, payload);
29
+ }
30
+
31
+ /**
32
+ * Create account
33
+ *
34
+ * Use this endpoint to allow a new user to register a new account in your
35
+ * project. After the user registration completes successfully, you can use
36
+ * the
37
+ * [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification)
38
+ * route to start verifying the user email address. To allow the new user to
39
+ * login to their new account, you need to create a new [account
40
+ * session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
41
+ *
42
+ * @param {string} userId
43
+ * @param {string} email
44
+ * @param {string} password
45
+ * @param {string} name
46
+ * @throws {AppwriteException}
47
+ * @returns {Promise}
48
+ */
49
+ async create<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
50
+ if (typeof userId === 'undefined') {
51
+ throw new AppwriteException('Missing required parameter: "userId"');
1068
52
  }
53
+
54
+ if (typeof email === 'undefined') {
55
+ throw new AppwriteException('Missing required parameter: "email"');
56
+ }
57
+
58
+ if (typeof password === 'undefined') {
59
+ throw new AppwriteException('Missing required parameter: "password"');
60
+ }
61
+
62
+ const apiPath = '/account';
63
+ const payload: Payload = {};
64
+
65
+ if (typeof userId !== 'undefined') {
66
+ payload['userId'] = userId;
67
+ }
68
+
69
+ if (typeof email !== 'undefined') {
70
+ payload['email'] = email;
71
+ }
72
+
73
+ if (typeof password !== 'undefined') {
74
+ payload['password'] = password;
75
+ }
76
+
77
+ if (typeof name !== 'undefined') {
78
+ payload['name'] = name;
79
+ }
80
+
81
+ const uri = new URL(this.client.config.endpoint + apiPath);
82
+ return await this.client.call('post', uri, {
83
+ 'content-type': 'application/json',
84
+ }, payload);
85
+ }
86
+
87
+ /**
88
+ * Update email
89
+ *
90
+ * Update currently logged in user account email address. After changing user
91
+ * address, the user confirmation status will get reset. A new confirmation
92
+ * email is not sent automatically however you can use the send confirmation
93
+ * email endpoint again to send the confirmation email. For security measures,
94
+ * user password is required to complete this request.
95
+ * This endpoint can also be used to convert an anonymous account to a normal
96
+ * one, by passing an email address and a new password.
97
+ *
98
+ *
99
+ * @param {string} email
100
+ * @param {string} password
101
+ * @throws {AppwriteException}
102
+ * @returns {Promise}
103
+ */
104
+ async updateEmail<Preferences extends Models.Preferences>(email: string, password: string): Promise<Models.User<Preferences>> {
105
+ if (typeof email === 'undefined') {
106
+ throw new AppwriteException('Missing required parameter: "email"');
107
+ }
108
+
109
+ if (typeof password === 'undefined') {
110
+ throw new AppwriteException('Missing required parameter: "password"');
111
+ }
112
+
113
+ const apiPath = '/account/email';
114
+ const payload: Payload = {};
115
+
116
+ if (typeof email !== 'undefined') {
117
+ payload['email'] = email;
118
+ }
119
+
120
+ if (typeof password !== 'undefined') {
121
+ payload['password'] = password;
122
+ }
123
+
124
+ const uri = new URL(this.client.config.endpoint + apiPath);
125
+ return await this.client.call('patch', uri, {
126
+ 'content-type': 'application/json',
127
+ }, payload);
128
+ }
129
+
130
+ /**
131
+ * List Identities
132
+ *
133
+ * Get the list of identities for the currently logged in user.
134
+ *
135
+ * @param {string} queries
136
+ * @throws {AppwriteException}
137
+ * @returns {Promise}
138
+ */
139
+ async listIdentities(queries?: string): Promise<Models.IdentityList> {
140
+ const apiPath = '/account/identities';
141
+ const payload: Payload = {};
142
+
143
+ if (typeof queries !== 'undefined') {
144
+ payload['queries'] = queries;
145
+ }
146
+
147
+ const uri = new URL(this.client.config.endpoint + apiPath);
148
+ return await this.client.call('get', uri, {
149
+ 'content-type': 'application/json',
150
+ }, payload);
151
+ }
152
+
153
+ /**
154
+ * Delete Identity
155
+ *
156
+ * Delete an identity by its unique ID.
157
+ *
158
+ * @param {string} identityId
159
+ * @throws {AppwriteException}
160
+ * @returns {Promise}
161
+ */
162
+ async deleteIdentity(identityId: string): Promise<{}> {
163
+ if (typeof identityId === 'undefined') {
164
+ throw new AppwriteException('Missing required parameter: "identityId"');
165
+ }
166
+
167
+ const apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId);
168
+ const payload: Payload = {};
169
+
170
+ const uri = new URL(this.client.config.endpoint + apiPath);
171
+ return await this.client.call('delete', uri, {
172
+ 'content-type': 'application/json',
173
+ }, payload);
174
+ }
175
+
176
+ /**
177
+ * Create JWT
178
+ *
179
+ * Use this endpoint to create a JSON Web Token. You can use the resulting JWT
180
+ * to authenticate on behalf of the current user when working with the
181
+ * Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
182
+ * from its creation and will be invalid if the user will logout in that time
183
+ * frame.
184
+ *
185
+ * @throws {AppwriteException}
186
+ * @returns {Promise}
187
+ */
188
+ async createJWT(): Promise<Models.Jwt> {
189
+ const apiPath = '/account/jwt';
190
+ const payload: Payload = {};
191
+
192
+ const uri = new URL(this.client.config.endpoint + apiPath);
193
+ return await this.client.call('post', uri, {
194
+ 'content-type': 'application/json',
195
+ }, payload);
196
+ }
197
+
198
+ /**
199
+ * List logs
200
+ *
201
+ * Get the list of latest security activity logs for the currently logged in
202
+ * user. Each log returns user IP address, location and date and time of log.
203
+ *
204
+ * @param {string[]} queries
205
+ * @throws {AppwriteException}
206
+ * @returns {Promise}
207
+ */
208
+ async listLogs(queries?: string[]): Promise<Models.LogList> {
209
+ const apiPath = '/account/logs';
210
+ const payload: Payload = {};
211
+
212
+ if (typeof queries !== 'undefined') {
213
+ payload['queries'] = queries;
214
+ }
215
+
216
+ const uri = new URL(this.client.config.endpoint + apiPath);
217
+ return await this.client.call('get', uri, {
218
+ 'content-type': 'application/json',
219
+ }, payload);
220
+ }
221
+
222
+ /**
223
+ * Update name
224
+ *
225
+ * Update currently logged in user account name.
226
+ *
227
+ * @param {string} name
228
+ * @throws {AppwriteException}
229
+ * @returns {Promise}
230
+ */
231
+ async updateName<Preferences extends Models.Preferences>(name: string): Promise<Models.User<Preferences>> {
232
+ if (typeof name === 'undefined') {
233
+ throw new AppwriteException('Missing required parameter: "name"');
234
+ }
235
+
236
+ const apiPath = '/account/name';
237
+ const payload: Payload = {};
238
+
239
+ if (typeof name !== 'undefined') {
240
+ payload['name'] = name;
241
+ }
242
+
243
+ const uri = new URL(this.client.config.endpoint + apiPath);
244
+ return await this.client.call('patch', uri, {
245
+ 'content-type': 'application/json',
246
+ }, payload);
247
+ }
248
+
249
+ /**
250
+ * Update password
251
+ *
252
+ * Update currently logged in user password. For validation, user is required
253
+ * to pass in the new password, and the old password. For users created with
254
+ * OAuth, Team Invites and Magic URL, oldPassword is optional.
255
+ *
256
+ * @param {string} password
257
+ * @param {string} oldPassword
258
+ * @throws {AppwriteException}
259
+ * @returns {Promise}
260
+ */
261
+ async updatePassword<Preferences extends Models.Preferences>(password: string, oldPassword?: string): Promise<Models.User<Preferences>> {
262
+ if (typeof password === 'undefined') {
263
+ throw new AppwriteException('Missing required parameter: "password"');
264
+ }
265
+
266
+ const apiPath = '/account/password';
267
+ const payload: Payload = {};
268
+
269
+ if (typeof password !== 'undefined') {
270
+ payload['password'] = password;
271
+ }
272
+
273
+ if (typeof oldPassword !== 'undefined') {
274
+ payload['oldPassword'] = oldPassword;
275
+ }
276
+
277
+ const uri = new URL(this.client.config.endpoint + apiPath);
278
+ return await this.client.call('patch', uri, {
279
+ 'content-type': 'application/json',
280
+ }, payload);
281
+ }
282
+
283
+ /**
284
+ * Update phone
285
+ *
286
+ * Update the currently logged in user's phone number. After updating the
287
+ * phone number, the phone verification status will be reset. A confirmation
288
+ * SMS is not sent automatically, however you can use the [POST
289
+ * /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification)
290
+ * endpoint to send a confirmation SMS.
291
+ *
292
+ * @param {string} phone
293
+ * @param {string} password
294
+ * @throws {AppwriteException}
295
+ * @returns {Promise}
296
+ */
297
+ async updatePhone<Preferences extends Models.Preferences>(phone: string, password: string): Promise<Models.User<Preferences>> {
298
+ if (typeof phone === 'undefined') {
299
+ throw new AppwriteException('Missing required parameter: "phone"');
300
+ }
301
+
302
+ if (typeof password === 'undefined') {
303
+ throw new AppwriteException('Missing required parameter: "password"');
304
+ }
305
+
306
+ const apiPath = '/account/phone';
307
+ const payload: Payload = {};
308
+
309
+ if (typeof phone !== 'undefined') {
310
+ payload['phone'] = phone;
311
+ }
312
+
313
+ if (typeof password !== 'undefined') {
314
+ payload['password'] = password;
315
+ }
316
+
317
+ const uri = new URL(this.client.config.endpoint + apiPath);
318
+ return await this.client.call('patch', uri, {
319
+ 'content-type': 'application/json',
320
+ }, payload);
321
+ }
322
+
323
+ /**
324
+ * Get account preferences
325
+ *
326
+ * Get the preferences as a key-value object for the currently logged in user.
327
+ *
328
+ * @throws {AppwriteException}
329
+ * @returns {Promise}
330
+ */
331
+ async getPrefs<Preferences extends Models.Preferences>(): Promise<Preferences> {
332
+ const apiPath = '/account/prefs';
333
+ const payload: Payload = {};
334
+
335
+ const uri = new URL(this.client.config.endpoint + apiPath);
336
+ return await this.client.call('get', uri, {
337
+ 'content-type': 'application/json',
338
+ }, payload);
339
+ }
340
+
341
+ /**
342
+ * Update preferences
343
+ *
344
+ * Update currently logged in user account preferences. The object you pass is
345
+ * stored as is, and replaces any previous value. The maximum allowed prefs
346
+ * size is 64kB and throws error if exceeded.
347
+ *
348
+ * @param {Partial<Preferences>} prefs
349
+ * @throws {AppwriteException}
350
+ * @returns {Promise}
351
+ */
352
+ async updatePrefs<Preferences extends Models.Preferences>(prefs: Partial<Preferences>): Promise<Models.User<Preferences>> {
353
+ if (typeof prefs === 'undefined') {
354
+ throw new AppwriteException('Missing required parameter: "prefs"');
355
+ }
356
+
357
+ const apiPath = '/account/prefs';
358
+ const payload: Payload = {};
359
+
360
+ if (typeof prefs !== 'undefined') {
361
+ payload['prefs'] = prefs;
362
+ }
363
+
364
+ const uri = new URL(this.client.config.endpoint + apiPath);
365
+ return await this.client.call('patch', uri, {
366
+ 'content-type': 'application/json',
367
+ }, payload);
368
+ }
369
+
370
+ /**
371
+ * Create password recovery
372
+ *
373
+ * Sends the user an email with a temporary secret key for password reset.
374
+ * When the user clicks the confirmation link he is redirected back to your
375
+ * app password reset URL with the secret key and email address values
376
+ * attached to the URL query string. Use the query string params to submit a
377
+ * request to the [PUT
378
+ * /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery)
379
+ * endpoint to complete the process. The verification link sent to the user's
380
+ * email address is valid for 1 hour.
381
+ *
382
+ * @param {string} email
383
+ * @param {string} url
384
+ * @throws {AppwriteException}
385
+ * @returns {Promise}
386
+ */
387
+ async createRecovery(email: string, url: string): Promise<Models.Token> {
388
+ if (typeof email === 'undefined') {
389
+ throw new AppwriteException('Missing required parameter: "email"');
390
+ }
391
+
392
+ if (typeof url === 'undefined') {
393
+ throw new AppwriteException('Missing required parameter: "url"');
394
+ }
395
+
396
+ const apiPath = '/account/recovery';
397
+ const payload: Payload = {};
398
+
399
+ if (typeof email !== 'undefined') {
400
+ payload['email'] = email;
401
+ }
402
+
403
+ if (typeof url !== 'undefined') {
404
+ payload['url'] = url;
405
+ }
406
+
407
+ const uri = new URL(this.client.config.endpoint + apiPath);
408
+ return await this.client.call('post', uri, {
409
+ 'content-type': 'application/json',
410
+ }, payload);
411
+ }
412
+
413
+ /**
414
+ * Create password recovery (confirmation)
415
+ *
416
+ * Use this endpoint to complete the user account password reset. Both the
417
+ * **userId** and **secret** arguments will be passed as query parameters to
418
+ * the redirect URL you have provided when sending your request to the [POST
419
+ * /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery)
420
+ * endpoint.
421
+ *
422
+ * Please note that in order to avoid a [Redirect
423
+ * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
424
+ * the only valid redirect URLs are the ones from domains you have set when
425
+ * adding your platforms in the console interface.
426
+ *
427
+ * @param {string} userId
428
+ * @param {string} secret
429
+ * @param {string} password
430
+ * @param {string} passwordAgain
431
+ * @throws {AppwriteException}
432
+ * @returns {Promise}
433
+ */
434
+ async updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise<Models.Token> {
435
+ if (typeof userId === 'undefined') {
436
+ throw new AppwriteException('Missing required parameter: "userId"');
437
+ }
438
+
439
+ if (typeof secret === 'undefined') {
440
+ throw new AppwriteException('Missing required parameter: "secret"');
441
+ }
442
+
443
+ if (typeof password === 'undefined') {
444
+ throw new AppwriteException('Missing required parameter: "password"');
445
+ }
446
+
447
+ if (typeof passwordAgain === 'undefined') {
448
+ throw new AppwriteException('Missing required parameter: "passwordAgain"');
449
+ }
450
+
451
+ const apiPath = '/account/recovery';
452
+ const payload: Payload = {};
453
+
454
+ if (typeof userId !== 'undefined') {
455
+ payload['userId'] = userId;
456
+ }
457
+
458
+ if (typeof secret !== 'undefined') {
459
+ payload['secret'] = secret;
460
+ }
461
+
462
+ if (typeof password !== 'undefined') {
463
+ payload['password'] = password;
464
+ }
465
+
466
+ if (typeof passwordAgain !== 'undefined') {
467
+ payload['passwordAgain'] = passwordAgain;
468
+ }
469
+
470
+ const uri = new URL(this.client.config.endpoint + apiPath);
471
+ return await this.client.call('put', uri, {
472
+ 'content-type': 'application/json',
473
+ }, payload);
474
+ }
475
+
476
+ /**
477
+ * List sessions
478
+ *
479
+ * Get the list of active sessions across different devices for the currently
480
+ * logged in user.
481
+ *
482
+ * @throws {AppwriteException}
483
+ * @returns {Promise}
484
+ */
485
+ async listSessions(): Promise<Models.SessionList> {
486
+ const apiPath = '/account/sessions';
487
+ const payload: Payload = {};
488
+
489
+ const uri = new URL(this.client.config.endpoint + apiPath);
490
+ return await this.client.call('get', uri, {
491
+ 'content-type': 'application/json',
492
+ }, payload);
493
+ }
494
+
495
+ /**
496
+ * Delete sessions
497
+ *
498
+ * Delete all sessions from the user account and remove any sessions cookies
499
+ * from the end client.
500
+ *
501
+ * @throws {AppwriteException}
502
+ * @returns {Promise}
503
+ */
504
+ async deleteSessions(): Promise<{}> {
505
+ const apiPath = '/account/sessions';
506
+ const payload: Payload = {};
507
+
508
+ const uri = new URL(this.client.config.endpoint + apiPath);
509
+ return await this.client.call('delete', uri, {
510
+ 'content-type': 'application/json',
511
+ }, payload);
512
+ }
513
+
514
+ /**
515
+ * Create anonymous session
516
+ *
517
+ * Use this endpoint to allow a new user to register an anonymous account in
518
+ * your project. This route will also create a new session for the user. To
519
+ * allow the new user to convert an anonymous account to a normal account, you
520
+ * need to update its [email and
521
+ * password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail)
522
+ * or create an [OAuth2
523
+ * session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).
524
+ *
525
+ * @throws {AppwriteException}
526
+ * @returns {Promise}
527
+ */
528
+ async createAnonymousSession(): Promise<Models.Session> {
529
+ const apiPath = '/account/sessions/anonymous';
530
+ const payload: Payload = {};
531
+
532
+ const uri = new URL(this.client.config.endpoint + apiPath);
533
+ return await this.client.call('post', uri, {
534
+ 'content-type': 'application/json',
535
+ }, payload);
536
+ }
537
+
538
+ /**
539
+ * Create email session
540
+ *
541
+ * Allow the user to login into their account by providing a valid email and
542
+ * password combination. This route will create a new session for the user.
543
+ *
544
+ * A user is limited to 10 active sessions at a time by default. [Learn more
545
+ * about session
546
+ * limits](https://appwrite.io/docs/authentication-security#limits).
547
+ *
548
+ * @param {string} email
549
+ * @param {string} password
550
+ * @throws {AppwriteException}
551
+ * @returns {Promise}
552
+ */
553
+ async createEmailSession(email: string, password: string): Promise<Models.Session> {
554
+ if (typeof email === 'undefined') {
555
+ throw new AppwriteException('Missing required parameter: "email"');
556
+ }
557
+
558
+ if (typeof password === 'undefined') {
559
+ throw new AppwriteException('Missing required parameter: "password"');
560
+ }
561
+
562
+ const apiPath = '/account/sessions/email';
563
+ const payload: Payload = {};
564
+
565
+ if (typeof email !== 'undefined') {
566
+ payload['email'] = email;
567
+ }
568
+
569
+ if (typeof password !== 'undefined') {
570
+ payload['password'] = password;
571
+ }
572
+
573
+ const uri = new URL(this.client.config.endpoint + apiPath);
574
+ return await this.client.call('post', uri, {
575
+ 'content-type': 'application/json',
576
+ }, payload);
577
+ }
578
+
579
+ /**
580
+ * Create magic URL session
581
+ *
582
+ * Sends the user an email with a secret key for creating a session. If the
583
+ * provided user ID has not been registered, a new user will be created. When
584
+ * the user clicks the link in the email, the user is redirected back to the
585
+ * URL you provided with the secret key and userId values attached to the URL
586
+ * query string. Use the query string parameters to submit a request to the
587
+ * [PUT
588
+ * /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession)
589
+ * endpoint to complete the login process. The link sent to the user's email
590
+ * address is valid for 1 hour. If you are on a mobile device you can leave
591
+ * the URL parameter empty, so that the login completion will be handled by
592
+ * your Appwrite instance by default.
593
+ *
594
+ * A user is limited to 10 active sessions at a time by default. [Learn more
595
+ * about session
596
+ * limits](https://appwrite.io/docs/authentication-security#limits).
597
+ *
598
+ *
599
+ * @param {string} userId
600
+ * @param {string} email
601
+ * @param {string} url
602
+ * @throws {AppwriteException}
603
+ * @returns {Promise}
604
+ */
605
+ async createMagicURLSession(userId: string, email: string, url?: string): Promise<Models.Token> {
606
+ if (typeof userId === 'undefined') {
607
+ throw new AppwriteException('Missing required parameter: "userId"');
608
+ }
609
+
610
+ if (typeof email === 'undefined') {
611
+ throw new AppwriteException('Missing required parameter: "email"');
612
+ }
613
+
614
+ const apiPath = '/account/sessions/magic-url';
615
+ const payload: Payload = {};
616
+
617
+ if (typeof userId !== 'undefined') {
618
+ payload['userId'] = userId;
619
+ }
620
+
621
+ if (typeof email !== 'undefined') {
622
+ payload['email'] = email;
623
+ }
624
+
625
+ if (typeof url !== 'undefined') {
626
+ payload['url'] = url;
627
+ }
628
+
629
+ const uri = new URL(this.client.config.endpoint + apiPath);
630
+ return await this.client.call('post', uri, {
631
+ 'content-type': 'application/json',
632
+ }, payload);
633
+ }
634
+
635
+ /**
636
+ * Create magic URL session (confirmation)
637
+ *
638
+ * Use this endpoint to complete creating the session with the Magic URL. Both
639
+ * the **userId** and **secret** arguments will be passed as query parameters
640
+ * to the redirect URL you have provided when sending your request to the
641
+ * [POST
642
+ * /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession)
643
+ * endpoint.
644
+ *
645
+ * Please note that in order to avoid a [Redirect
646
+ * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
647
+ * the only valid redirect URLs are the ones from domains you have set when
648
+ * adding your platforms in the console interface.
649
+ *
650
+ * @param {string} userId
651
+ * @param {string} secret
652
+ * @throws {AppwriteException}
653
+ * @returns {Promise}
654
+ */
655
+ async updateMagicURLSession(userId: string, secret: string): Promise<Models.Session> {
656
+ if (typeof userId === 'undefined') {
657
+ throw new AppwriteException('Missing required parameter: "userId"');
658
+ }
659
+
660
+ if (typeof secret === 'undefined') {
661
+ throw new AppwriteException('Missing required parameter: "secret"');
662
+ }
663
+
664
+ const apiPath = '/account/sessions/magic-url';
665
+ const payload: Payload = {};
666
+
667
+ if (typeof userId !== 'undefined') {
668
+ payload['userId'] = userId;
669
+ }
670
+
671
+ if (typeof secret !== 'undefined') {
672
+ payload['secret'] = secret;
673
+ }
674
+
675
+ const uri = new URL(this.client.config.endpoint + apiPath);
676
+ return await this.client.call('put', uri, {
677
+ 'content-type': 'application/json',
678
+ }, payload);
679
+ }
680
+
681
+ /**
682
+ * Create OAuth2 session
683
+ *
684
+ * Allow the user to login to their account using the OAuth2 provider of their
685
+ * choice. Each OAuth2 provider should be enabled from the Appwrite console
686
+ * first. Use the success and failure arguments to provide a redirect URL's
687
+ * back to your app when login is completed.
688
+ *
689
+ * If there is already an active session, the new session will be attached to
690
+ * the logged-in account. If there are no active sessions, the server will
691
+ * attempt to look for a user with the same email address as the email
692
+ * received from the OAuth2 provider and attach the new session to the
693
+ * existing user. If no matching user is found - the server will create a new
694
+ * user.
695
+ *
696
+ * A user is limited to 10 active sessions at a time by default. [Learn more
697
+ * about session
698
+ * limits](https://appwrite.io/docs/authentication-security#limits).
699
+ *
700
+ *
701
+ * @param {string} provider
702
+ * @param {string} success
703
+ * @param {string} failure
704
+ * @param {string[]} scopes
705
+ * @throws {AppwriteException}
706
+ * @returns {void|string}
707
+ */
708
+ createOAuth2Session(provider: string, success?: string, failure?: string, scopes?: string[]): void | URL {
709
+ if (typeof provider === 'undefined') {
710
+ throw new AppwriteException('Missing required parameter: "provider"');
711
+ }
712
+
713
+ const apiPath = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider);
714
+ const payload: Payload = {};
715
+
716
+ if (typeof success !== 'undefined') {
717
+ payload['success'] = success;
718
+ }
719
+
720
+ if (typeof failure !== 'undefined') {
721
+ payload['failure'] = failure;
722
+ }
723
+
724
+ if (typeof scopes !== 'undefined') {
725
+ payload['scopes'] = scopes;
726
+ }
727
+
728
+ const uri = new URL(this.client.config.endpoint + apiPath);
729
+ payload['project'] = this.client.config.project;
730
+
731
+
732
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
733
+ uri.searchParams.append(key, value);
734
+ }
735
+ if (typeof window !== 'undefined' && window?.location) {
736
+ window.location.href = uri.toString();
737
+ } else {
738
+ return uri;
739
+ }
740
+ }
741
+
742
+ /**
743
+ * Create phone session
744
+ *
745
+ * Sends the user an SMS with a secret key for creating a session. If the
746
+ * provided user ID has not be registered, a new user will be created. Use the
747
+ * returned user ID and secret and submit a request to the [PUT
748
+ * /account/sessions/phone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession)
749
+ * endpoint to complete the login process. The secret sent to the user's phone
750
+ * is valid for 15 minutes.
751
+ *
752
+ * A user is limited to 10 active sessions at a time by default. [Learn more
753
+ * about session
754
+ * limits](https://appwrite.io/docs/authentication-security#limits).
755
+ *
756
+ * @param {string} userId
757
+ * @param {string} phone
758
+ * @throws {AppwriteException}
759
+ * @returns {Promise}
760
+ */
761
+ async createPhoneSession(userId: string, phone: string): Promise<Models.Token> {
762
+ if (typeof userId === 'undefined') {
763
+ throw new AppwriteException('Missing required parameter: "userId"');
764
+ }
765
+
766
+ if (typeof phone === 'undefined') {
767
+ throw new AppwriteException('Missing required parameter: "phone"');
768
+ }
769
+
770
+ const apiPath = '/account/sessions/phone';
771
+ const payload: Payload = {};
772
+
773
+ if (typeof userId !== 'undefined') {
774
+ payload['userId'] = userId;
775
+ }
776
+
777
+ if (typeof phone !== 'undefined') {
778
+ payload['phone'] = phone;
779
+ }
780
+
781
+ const uri = new URL(this.client.config.endpoint + apiPath);
782
+ return await this.client.call('post', uri, {
783
+ 'content-type': 'application/json',
784
+ }, payload);
785
+ }
786
+
787
+ /**
788
+ * Create phone session (confirmation)
789
+ *
790
+ * Use this endpoint to complete creating a session with SMS. Use the
791
+ * **userId** from the
792
+ * [createPhoneSession](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession)
793
+ * endpoint and the **secret** received via SMS to successfully update and
794
+ * confirm the phone session.
795
+ *
796
+ * @param {string} userId
797
+ * @param {string} secret
798
+ * @throws {AppwriteException}
799
+ * @returns {Promise}
800
+ */
801
+ async updatePhoneSession(userId: string, secret: string): Promise<Models.Session> {
802
+ if (typeof userId === 'undefined') {
803
+ throw new AppwriteException('Missing required parameter: "userId"');
804
+ }
805
+
806
+ if (typeof secret === 'undefined') {
807
+ throw new AppwriteException('Missing required parameter: "secret"');
808
+ }
809
+
810
+ const apiPath = '/account/sessions/phone';
811
+ const payload: Payload = {};
812
+
813
+ if (typeof userId !== 'undefined') {
814
+ payload['userId'] = userId;
815
+ }
816
+
817
+ if (typeof secret !== 'undefined') {
818
+ payload['secret'] = secret;
819
+ }
820
+
821
+ const uri = new URL(this.client.config.endpoint + apiPath);
822
+ return await this.client.call('put', uri, {
823
+ 'content-type': 'application/json',
824
+ }, payload);
825
+ }
826
+
827
+ /**
828
+ * Get session
829
+ *
830
+ * Use this endpoint to get a logged in user's session using a Session ID.
831
+ * Inputting 'current' will return the current session being used.
832
+ *
833
+ * @param {string} sessionId
834
+ * @throws {AppwriteException}
835
+ * @returns {Promise}
836
+ */
837
+ async getSession(sessionId: string): Promise<Models.Session> {
838
+ if (typeof sessionId === 'undefined') {
839
+ throw new AppwriteException('Missing required parameter: "sessionId"');
840
+ }
841
+
842
+ const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
843
+ const payload: Payload = {};
844
+
845
+ const uri = new URL(this.client.config.endpoint + apiPath);
846
+ return await this.client.call('get', uri, {
847
+ 'content-type': 'application/json',
848
+ }, payload);
849
+ }
850
+
851
+ /**
852
+ * Update OAuth session (refresh tokens)
853
+ *
854
+ * Access tokens have limited lifespan and expire to mitigate security risks.
855
+ * If session was created using an OAuth provider, this route can be used to
856
+ * "refresh" the access token.
857
+ *
858
+ * @param {string} sessionId
859
+ * @throws {AppwriteException}
860
+ * @returns {Promise}
861
+ */
862
+ async updateSession(sessionId: string): Promise<Models.Session> {
863
+ if (typeof sessionId === 'undefined') {
864
+ throw new AppwriteException('Missing required parameter: "sessionId"');
865
+ }
866
+
867
+ const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
868
+ const payload: Payload = {};
869
+
870
+ const uri = new URL(this.client.config.endpoint + apiPath);
871
+ return await this.client.call('patch', uri, {
872
+ 'content-type': 'application/json',
873
+ }, payload);
874
+ }
875
+
876
+ /**
877
+ * Delete session
878
+ *
879
+ * Logout the user. Use 'current' as the session ID to logout on this device,
880
+ * use a session ID to logout on another device. If you're looking to logout
881
+ * the user on all devices, use [Delete
882
+ * Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
883
+ * instead.
884
+ *
885
+ * @param {string} sessionId
886
+ * @throws {AppwriteException}
887
+ * @returns {Promise}
888
+ */
889
+ async deleteSession(sessionId: string): Promise<{}> {
890
+ if (typeof sessionId === 'undefined') {
891
+ throw new AppwriteException('Missing required parameter: "sessionId"');
892
+ }
893
+
894
+ const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
895
+ const payload: Payload = {};
896
+
897
+ const uri = new URL(this.client.config.endpoint + apiPath);
898
+ return await this.client.call('delete', uri, {
899
+ 'content-type': 'application/json',
900
+ }, payload);
901
+ }
902
+
903
+ /**
904
+ * Update status
905
+ *
906
+ * Block the currently logged in user account. Behind the scene, the user
907
+ * record is not deleted but permanently blocked from any access. To
908
+ * completely delete a user, use the Users API instead.
909
+ *
910
+ * @throws {AppwriteException}
911
+ * @returns {Promise}
912
+ */
913
+ async updateStatus<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> {
914
+ const apiPath = '/account/status';
915
+ const payload: Payload = {};
916
+
917
+ const uri = new URL(this.client.config.endpoint + apiPath);
918
+ return await this.client.call('patch', uri, {
919
+ 'content-type': 'application/json',
920
+ }, payload);
921
+ }
922
+
923
+ /**
924
+ * Create email verification
925
+ *
926
+ * Use this endpoint to send a verification message to your user email address
927
+ * to confirm they are the valid owners of that address. Both the **userId**
928
+ * and **secret** arguments will be passed as query parameters to the URL you
929
+ * have provided to be attached to the verification email. The provided URL
930
+ * should redirect the user back to your app and allow you to complete the
931
+ * verification process by verifying both the **userId** and **secret**
932
+ * parameters. Learn more about how to [complete the verification
933
+ * process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
934
+ * The verification link sent to the user's email address is valid for 7 days.
935
+ *
936
+ * Please note that in order to avoid a [Redirect
937
+ * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
938
+ * the only valid redirect URLs are the ones from domains you have set when
939
+ * adding your platforms in the console interface.
940
+ *
941
+ *
942
+ * @param {string} url
943
+ * @throws {AppwriteException}
944
+ * @returns {Promise}
945
+ */
946
+ async createVerification(url: string): Promise<Models.Token> {
947
+ if (typeof url === 'undefined') {
948
+ throw new AppwriteException('Missing required parameter: "url"');
949
+ }
950
+
951
+ const apiPath = '/account/verification';
952
+ const payload: Payload = {};
953
+
954
+ if (typeof url !== 'undefined') {
955
+ payload['url'] = url;
956
+ }
957
+
958
+ const uri = new URL(this.client.config.endpoint + apiPath);
959
+ return await this.client.call('post', uri, {
960
+ 'content-type': 'application/json',
961
+ }, payload);
962
+ }
963
+
964
+ /**
965
+ * Create email verification (confirmation)
966
+ *
967
+ * Use this endpoint to complete the user email verification process. Use both
968
+ * the **userId** and **secret** parameters that were attached to your app URL
969
+ * to verify the user email ownership. If confirmed this route will return a
970
+ * 200 status code.
971
+ *
972
+ * @param {string} userId
973
+ * @param {string} secret
974
+ * @throws {AppwriteException}
975
+ * @returns {Promise}
976
+ */
977
+ async updateVerification(userId: string, secret: string): Promise<Models.Token> {
978
+ if (typeof userId === 'undefined') {
979
+ throw new AppwriteException('Missing required parameter: "userId"');
980
+ }
981
+
982
+ if (typeof secret === 'undefined') {
983
+ throw new AppwriteException('Missing required parameter: "secret"');
984
+ }
985
+
986
+ const apiPath = '/account/verification';
987
+ const payload: Payload = {};
988
+
989
+ if (typeof userId !== 'undefined') {
990
+ payload['userId'] = userId;
991
+ }
992
+
993
+ if (typeof secret !== 'undefined') {
994
+ payload['secret'] = secret;
995
+ }
996
+
997
+ const uri = new URL(this.client.config.endpoint + apiPath);
998
+ return await this.client.call('put', uri, {
999
+ 'content-type': 'application/json',
1000
+ }, payload);
1001
+ }
1002
+
1003
+ /**
1004
+ * Create phone verification
1005
+ *
1006
+ * Use this endpoint to send a verification SMS to the currently logged in
1007
+ * user. This endpoint is meant for use after updating a user's phone number
1008
+ * using the
1009
+ * [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone)
1010
+ * endpoint. Learn more about how to [complete the verification
1011
+ * process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification).
1012
+ * The verification code sent to the user's phone number is valid for 15
1013
+ * minutes.
1014
+ *
1015
+ * @throws {AppwriteException}
1016
+ * @returns {Promise}
1017
+ */
1018
+ async createPhoneVerification(): Promise<Models.Token> {
1019
+ const apiPath = '/account/verification/phone';
1020
+ const payload: Payload = {};
1021
+
1022
+ const uri = new URL(this.client.config.endpoint + apiPath);
1023
+ return await this.client.call('post', uri, {
1024
+ 'content-type': 'application/json',
1025
+ }, payload);
1026
+ }
1027
+
1028
+ /**
1029
+ * Create phone verification (confirmation)
1030
+ *
1031
+ * Use this endpoint to complete the user phone verification process. Use the
1032
+ * **userId** and **secret** that were sent to your user's phone number to
1033
+ * verify the user email ownership. If confirmed this route will return a 200
1034
+ * status code.
1035
+ *
1036
+ * @param {string} userId
1037
+ * @param {string} secret
1038
+ * @throws {AppwriteException}
1039
+ * @returns {Promise}
1040
+ */
1041
+ async updatePhoneVerification(userId: string, secret: string): Promise<Models.Token> {
1042
+ if (typeof userId === 'undefined') {
1043
+ throw new AppwriteException('Missing required parameter: "userId"');
1044
+ }
1045
+
1046
+ if (typeof secret === 'undefined') {
1047
+ throw new AppwriteException('Missing required parameter: "secret"');
1048
+ }
1049
+
1050
+ const apiPath = '/account/verification/phone';
1051
+ const payload: Payload = {};
1052
+
1053
+ if (typeof userId !== 'undefined') {
1054
+ payload['userId'] = userId;
1055
+ }
1056
+
1057
+ if (typeof secret !== 'undefined') {
1058
+ payload['secret'] = secret;
1059
+ }
1060
+
1061
+ const uri = new URL(this.client.config.endpoint + apiPath);
1062
+ return await this.client.call('put', uri, {
1063
+ 'content-type': 'application/json',
1064
+ }, payload);
1065
+ }
1069
1066
  };