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