@appwrite.io/console 0.6.4 → 0.7.0-rc.2

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 (408) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/sdk.js +2513 -2350
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +2513 -2350
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +2513 -2350
  7. package/docs/examples/account/create-anonymous-session.md +1 -1
  8. package/docs/examples/account/create-email-password-session.md +1 -1
  9. package/docs/examples/account/create-email-token.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-token.md +1 -1
  12. package/docs/examples/account/create-mfa-authenticator.md +1 -1
  13. package/docs/examples/account/create-mfa-challenge.md +1 -1
  14. package/docs/examples/account/create-mfa-recovery-codes.md +1 -1
  15. package/docs/examples/account/create-phone-token.md +1 -1
  16. package/docs/examples/account/create-phone-verification.md +1 -1
  17. package/docs/examples/account/create-push-target.md +1 -1
  18. package/docs/examples/account/create-recovery.md +1 -1
  19. package/docs/examples/account/create-session.md +1 -1
  20. package/docs/examples/account/create-verification.md +1 -1
  21. package/docs/examples/account/create.md +1 -1
  22. package/docs/examples/account/delete-identity.md +1 -1
  23. package/docs/examples/account/delete-mfa-authenticator.md +2 -3
  24. package/docs/examples/account/delete-push-target.md +1 -1
  25. package/docs/examples/account/delete-session.md +1 -1
  26. package/docs/examples/account/delete-sessions.md +1 -1
  27. package/docs/examples/account/delete.md +1 -1
  28. package/docs/examples/account/get-mfa-recovery-codes.md +1 -1
  29. package/docs/examples/account/get-prefs.md +1 -1
  30. package/docs/examples/account/get-session.md +1 -1
  31. package/docs/examples/account/get.md +1 -1
  32. package/docs/examples/account/list-identities.md +1 -1
  33. package/docs/examples/account/list-logs.md +1 -1
  34. package/docs/examples/account/list-mfa-factors.md +1 -1
  35. package/docs/examples/account/list-sessions.md +1 -1
  36. package/docs/examples/account/update-email.md +1 -1
  37. package/docs/examples/account/update-m-f-a.md +1 -1
  38. package/docs/examples/account/update-magic-u-r-l-session.md +1 -1
  39. package/docs/examples/account/update-mfa-authenticator.md +1 -1
  40. package/docs/examples/account/update-mfa-challenge.md +1 -1
  41. package/docs/examples/account/update-mfa-recovery-codes.md +1 -1
  42. package/docs/examples/account/update-name.md +1 -1
  43. package/docs/examples/account/update-password.md +1 -1
  44. package/docs/examples/account/update-phone-session.md +1 -1
  45. package/docs/examples/account/update-phone-verification.md +1 -1
  46. package/docs/examples/account/update-phone.md +1 -1
  47. package/docs/examples/account/update-prefs.md +1 -1
  48. package/docs/examples/account/update-push-target.md +1 -1
  49. package/docs/examples/account/update-recovery.md +1 -1
  50. package/docs/examples/account/update-session.md +1 -1
  51. package/docs/examples/account/update-status.md +1 -1
  52. package/docs/examples/account/update-verification.md +1 -1
  53. package/docs/examples/assistant/chat.md +1 -1
  54. package/docs/examples/console/variables.md +1 -1
  55. package/docs/examples/databases/create-boolean-attribute.md +1 -1
  56. package/docs/examples/databases/create-collection.md +1 -1
  57. package/docs/examples/databases/create-datetime-attribute.md +1 -1
  58. package/docs/examples/databases/create-document.md +1 -1
  59. package/docs/examples/databases/create-email-attribute.md +1 -1
  60. package/docs/examples/databases/create-enum-attribute.md +1 -1
  61. package/docs/examples/databases/create-float-attribute.md +1 -1
  62. package/docs/examples/databases/create-index.md +1 -1
  63. package/docs/examples/databases/create-integer-attribute.md +1 -1
  64. package/docs/examples/databases/create-ip-attribute.md +1 -1
  65. package/docs/examples/databases/create-relationship-attribute.md +1 -1
  66. package/docs/examples/databases/create-string-attribute.md +1 -1
  67. package/docs/examples/databases/create-url-attribute.md +1 -1
  68. package/docs/examples/databases/create.md +1 -1
  69. package/docs/examples/databases/delete-attribute.md +1 -1
  70. package/docs/examples/databases/delete-collection.md +1 -1
  71. package/docs/examples/databases/delete-document.md +1 -1
  72. package/docs/examples/databases/delete-index.md +1 -1
  73. package/docs/examples/databases/delete.md +1 -1
  74. package/docs/examples/databases/get-attribute.md +1 -1
  75. package/docs/examples/databases/get-collection-usage.md +1 -1
  76. package/docs/examples/databases/get-collection.md +1 -1
  77. package/docs/examples/databases/get-database-usage.md +1 -1
  78. package/docs/examples/databases/get-document.md +1 -1
  79. package/docs/examples/databases/get-index.md +1 -1
  80. package/docs/examples/databases/get-usage.md +1 -1
  81. package/docs/examples/databases/get.md +1 -1
  82. package/docs/examples/databases/list-attributes.md +1 -1
  83. package/docs/examples/databases/list-collection-logs.md +1 -1
  84. package/docs/examples/databases/list-collections.md +1 -1
  85. package/docs/examples/databases/list-document-logs.md +1 -1
  86. package/docs/examples/databases/list-documents.md +1 -1
  87. package/docs/examples/databases/list-indexes.md +1 -1
  88. package/docs/examples/databases/list-logs.md +1 -1
  89. package/docs/examples/databases/list.md +1 -1
  90. package/docs/examples/databases/update-boolean-attribute.md +1 -1
  91. package/docs/examples/databases/update-collection.md +1 -1
  92. package/docs/examples/databases/update-datetime-attribute.md +1 -1
  93. package/docs/examples/databases/update-document.md +1 -1
  94. package/docs/examples/databases/update-email-attribute.md +1 -1
  95. package/docs/examples/databases/update-enum-attribute.md +1 -1
  96. package/docs/examples/databases/update-float-attribute.md +1 -1
  97. package/docs/examples/databases/update-integer-attribute.md +1 -1
  98. package/docs/examples/databases/update-ip-attribute.md +1 -1
  99. package/docs/examples/databases/update-relationship-attribute.md +1 -1
  100. package/docs/examples/databases/update-string-attribute.md +1 -1
  101. package/docs/examples/databases/update-url-attribute.md +1 -1
  102. package/docs/examples/databases/update.md +1 -1
  103. package/docs/examples/functions/create-build.md +2 -2
  104. package/docs/examples/functions/create-deployment.md +1 -1
  105. package/docs/examples/functions/create-execution.md +3 -2
  106. package/docs/examples/functions/create-variable.md +1 -1
  107. package/docs/examples/functions/create.md +3 -3
  108. package/docs/examples/functions/delete-deployment.md +1 -1
  109. package/docs/examples/functions/delete-execution.md +14 -0
  110. package/docs/examples/functions/delete-variable.md +1 -1
  111. package/docs/examples/functions/delete.md +1 -1
  112. package/docs/examples/functions/{download-deployment.md → get-deployment-download.md} +1 -1
  113. package/docs/examples/functions/get-deployment.md +1 -1
  114. package/docs/examples/functions/get-execution.md +1 -1
  115. package/docs/examples/functions/get-function-usage.md +1 -1
  116. package/docs/examples/functions/{get-specifications.md → get-template.md} +4 -2
  117. package/docs/examples/functions/get-usage.md +1 -1
  118. package/docs/examples/functions/get-variable.md +1 -1
  119. package/docs/examples/functions/get.md +1 -1
  120. package/docs/examples/functions/list-deployments.md +1 -1
  121. package/docs/examples/functions/list-executions.md +1 -1
  122. package/docs/examples/functions/list-runtimes.md +1 -1
  123. package/docs/examples/functions/list-templates.md +16 -0
  124. package/docs/examples/functions/list-variables.md +1 -1
  125. package/docs/examples/functions/list.md +1 -1
  126. package/docs/examples/functions/update-deployment-build.md +14 -0
  127. package/docs/examples/functions/update-deployment.md +1 -1
  128. package/docs/examples/functions/update-variable.md +1 -1
  129. package/docs/examples/functions/update.md +3 -3
  130. package/docs/examples/graphql/mutation.md +1 -1
  131. package/docs/examples/graphql/query.md +1 -1
  132. package/docs/examples/health/get-antivirus.md +1 -1
  133. package/docs/examples/health/get-cache.md +1 -1
  134. package/docs/examples/health/get-certificate.md +1 -1
  135. package/docs/examples/health/get-d-b.md +1 -1
  136. package/docs/examples/health/get-failed-jobs.md +1 -1
  137. package/docs/examples/health/get-pub-sub.md +1 -1
  138. package/docs/examples/health/get-queue-builds.md +1 -1
  139. package/docs/examples/health/get-queue-certificates.md +1 -1
  140. package/docs/examples/health/get-queue-databases.md +1 -1
  141. package/docs/examples/health/get-queue-deletes.md +1 -1
  142. package/docs/examples/health/get-queue-functions.md +1 -1
  143. package/docs/examples/health/get-queue-logs.md +1 -1
  144. package/docs/examples/health/get-queue-mails.md +1 -1
  145. package/docs/examples/health/get-queue-messaging.md +1 -1
  146. package/docs/examples/health/get-queue-migrations.md +1 -1
  147. package/docs/examples/health/get-queue-usage-dump.md +1 -1
  148. package/docs/examples/health/get-queue-usage.md +1 -1
  149. package/docs/examples/health/get-queue-webhooks.md +1 -1
  150. package/docs/examples/health/get-queue.md +1 -1
  151. package/docs/examples/health/get-storage-local.md +1 -1
  152. package/docs/examples/health/get-storage.md +1 -1
  153. package/docs/examples/health/get-time.md +1 -1
  154. package/docs/examples/health/get.md +1 -1
  155. package/docs/examples/locale/get.md +1 -1
  156. package/docs/examples/locale/list-codes.md +1 -1
  157. package/docs/examples/locale/list-continents.md +1 -1
  158. package/docs/examples/locale/list-countries-e-u.md +1 -1
  159. package/docs/examples/locale/list-countries-phones.md +1 -1
  160. package/docs/examples/locale/list-countries.md +1 -1
  161. package/docs/examples/locale/list-currencies.md +1 -1
  162. package/docs/examples/locale/list-languages.md +1 -1
  163. package/docs/examples/messaging/create-apns-provider.md +1 -1
  164. package/docs/examples/messaging/create-email.md +1 -1
  165. package/docs/examples/messaging/create-fcm-provider.md +1 -1
  166. package/docs/examples/messaging/create-mailgun-provider.md +1 -1
  167. package/docs/examples/messaging/create-msg91provider.md +1 -1
  168. package/docs/examples/messaging/create-push.md +1 -1
  169. package/docs/examples/messaging/create-sendgrid-provider.md +1 -1
  170. package/docs/examples/messaging/create-sms.md +1 -1
  171. package/docs/examples/messaging/create-smtp-provider.md +1 -1
  172. package/docs/examples/messaging/create-subscriber.md +1 -1
  173. package/docs/examples/messaging/create-telesign-provider.md +1 -1
  174. package/docs/examples/messaging/create-textmagic-provider.md +1 -1
  175. package/docs/examples/messaging/create-topic.md +1 -1
  176. package/docs/examples/messaging/create-twilio-provider.md +1 -1
  177. package/docs/examples/messaging/create-vonage-provider.md +1 -1
  178. package/docs/examples/messaging/delete-provider.md +1 -1
  179. package/docs/examples/messaging/delete-subscriber.md +1 -1
  180. package/docs/examples/messaging/delete-topic.md +1 -1
  181. package/docs/examples/messaging/delete.md +1 -1
  182. package/docs/examples/messaging/get-message.md +1 -1
  183. package/docs/examples/messaging/get-provider.md +1 -1
  184. package/docs/examples/messaging/get-subscriber.md +1 -1
  185. package/docs/examples/messaging/get-topic.md +1 -1
  186. package/docs/examples/messaging/list-message-logs.md +1 -1
  187. package/docs/examples/messaging/list-messages.md +1 -1
  188. package/docs/examples/messaging/list-provider-logs.md +1 -1
  189. package/docs/examples/messaging/list-providers.md +1 -1
  190. package/docs/examples/messaging/list-subscriber-logs.md +1 -1
  191. package/docs/examples/messaging/list-subscribers.md +1 -1
  192. package/docs/examples/messaging/list-targets.md +1 -1
  193. package/docs/examples/messaging/list-topic-logs.md +1 -1
  194. package/docs/examples/messaging/list-topics.md +1 -1
  195. package/docs/examples/messaging/update-apns-provider.md +1 -1
  196. package/docs/examples/messaging/update-email.md +1 -1
  197. package/docs/examples/messaging/update-fcm-provider.md +1 -1
  198. package/docs/examples/messaging/update-mailgun-provider.md +1 -1
  199. package/docs/examples/messaging/update-msg91provider.md +1 -1
  200. package/docs/examples/messaging/update-push.md +1 -1
  201. package/docs/examples/messaging/update-sendgrid-provider.md +1 -1
  202. package/docs/examples/messaging/update-sms.md +1 -1
  203. package/docs/examples/messaging/update-smtp-provider.md +1 -1
  204. package/docs/examples/messaging/update-telesign-provider.md +1 -1
  205. package/docs/examples/messaging/update-textmagic-provider.md +1 -1
  206. package/docs/examples/messaging/update-topic.md +1 -1
  207. package/docs/examples/messaging/update-twilio-provider.md +1 -1
  208. package/docs/examples/messaging/update-vonage-provider.md +1 -1
  209. package/docs/examples/migrations/create-appwrite-migration.md +1 -1
  210. package/docs/examples/migrations/create-firebase-migration.md +1 -1
  211. package/docs/examples/migrations/create-firebase-o-auth-migration.md +1 -1
  212. package/docs/examples/migrations/create-n-host-migration.md +1 -1
  213. package/docs/examples/migrations/create-supabase-migration.md +1 -1
  214. package/docs/examples/migrations/delete-firebase-auth.md +1 -1
  215. package/docs/examples/migrations/delete.md +1 -1
  216. package/docs/examples/migrations/get-appwrite-report.md +1 -1
  217. package/docs/examples/migrations/get-firebase-report-o-auth.md +1 -1
  218. package/docs/examples/migrations/get-firebase-report.md +1 -1
  219. package/docs/examples/migrations/get-n-host-report.md +1 -1
  220. package/docs/examples/migrations/get-supabase-report.md +1 -1
  221. package/docs/examples/migrations/get.md +1 -1
  222. package/docs/examples/migrations/list-firebase-projects.md +1 -1
  223. package/docs/examples/migrations/list.md +1 -1
  224. package/docs/examples/migrations/retry.md +1 -1
  225. package/docs/examples/project/create-variable.md +1 -1
  226. package/docs/examples/project/delete-variable.md +1 -1
  227. package/docs/examples/project/get-usage.md +1 -1
  228. package/docs/examples/project/get-variable.md +1 -1
  229. package/docs/examples/project/list-variables.md +1 -1
  230. package/docs/examples/project/update-variable.md +1 -1
  231. package/docs/examples/projects/create-j-w-t.md +15 -0
  232. package/docs/examples/projects/create-key.md +1 -1
  233. package/docs/examples/projects/create-platform.md +1 -1
  234. package/docs/examples/projects/create-smtp-test.md +1 -1
  235. package/docs/examples/projects/create-webhook.md +1 -1
  236. package/docs/examples/projects/create.md +1 -1
  237. package/docs/examples/projects/delete-email-template.md +1 -1
  238. package/docs/examples/projects/delete-key.md +1 -1
  239. package/docs/examples/projects/delete-platform.md +1 -1
  240. package/docs/examples/projects/delete-sms-template.md +1 -1
  241. package/docs/examples/projects/delete-webhook.md +1 -1
  242. package/docs/examples/projects/delete.md +1 -1
  243. package/docs/examples/projects/get-email-template.md +1 -1
  244. package/docs/examples/projects/get-key.md +1 -1
  245. package/docs/examples/projects/get-platform.md +1 -1
  246. package/docs/examples/projects/get-sms-template.md +1 -1
  247. package/docs/examples/projects/get-webhook.md +1 -1
  248. package/docs/examples/projects/get.md +1 -1
  249. package/docs/examples/projects/list-keys.md +1 -1
  250. package/docs/examples/projects/list-platforms.md +1 -1
  251. package/docs/examples/projects/list-webhooks.md +1 -1
  252. package/docs/examples/projects/list.md +1 -1
  253. package/docs/examples/projects/update-api-status-all.md +1 -1
  254. package/docs/examples/projects/update-api-status.md +1 -1
  255. package/docs/examples/projects/update-auth-duration.md +1 -1
  256. package/docs/examples/projects/update-auth-limit.md +1 -1
  257. package/docs/examples/projects/update-auth-password-dictionary.md +1 -1
  258. package/docs/examples/projects/update-auth-password-history.md +1 -1
  259. package/docs/examples/projects/update-auth-sessions-limit.md +1 -1
  260. package/docs/examples/projects/update-auth-status.md +1 -1
  261. package/docs/examples/projects/update-email-template.md +1 -1
  262. package/docs/examples/projects/update-key.md +1 -1
  263. package/docs/examples/projects/update-mock-numbers.md +14 -0
  264. package/docs/examples/projects/update-o-auth2.md +1 -1
  265. package/docs/examples/projects/update-personal-data-check.md +1 -1
  266. package/docs/examples/projects/update-platform.md +1 -1
  267. package/docs/examples/projects/update-service-status-all.md +1 -1
  268. package/docs/examples/projects/update-service-status.md +1 -1
  269. package/docs/examples/projects/update-session-alerts.md +14 -0
  270. package/docs/examples/projects/update-sms-template.md +1 -1
  271. package/docs/examples/projects/update-smtp.md +1 -1
  272. package/docs/examples/projects/update-team.md +1 -1
  273. package/docs/examples/projects/update-webhook-signature.md +1 -1
  274. package/docs/examples/projects/update-webhook.md +1 -1
  275. package/docs/examples/projects/update.md +1 -1
  276. package/docs/examples/proxy/create-rule.md +1 -1
  277. package/docs/examples/proxy/delete-rule.md +1 -1
  278. package/docs/examples/proxy/get-rule.md +1 -1
  279. package/docs/examples/proxy/list-rules.md +1 -1
  280. package/docs/examples/proxy/update-rule-verification.md +1 -1
  281. package/docs/examples/storage/create-bucket.md +1 -1
  282. package/docs/examples/storage/create-file.md +1 -1
  283. package/docs/examples/storage/delete-bucket.md +1 -1
  284. package/docs/examples/storage/delete-file.md +1 -1
  285. package/docs/examples/storage/get-bucket-usage.md +1 -1
  286. package/docs/examples/storage/get-bucket.md +1 -1
  287. package/docs/examples/storage/get-file.md +1 -1
  288. package/docs/examples/storage/get-usage.md +1 -1
  289. package/docs/examples/storage/list-buckets.md +1 -1
  290. package/docs/examples/storage/list-files.md +1 -1
  291. package/docs/examples/storage/update-bucket.md +1 -1
  292. package/docs/examples/storage/update-file.md +1 -1
  293. package/docs/examples/teams/create-membership.md +1 -1
  294. package/docs/examples/teams/create.md +1 -1
  295. package/docs/examples/teams/delete-membership.md +1 -1
  296. package/docs/examples/teams/delete.md +1 -1
  297. package/docs/examples/teams/get-membership.md +1 -1
  298. package/docs/examples/teams/get-prefs.md +1 -1
  299. package/docs/examples/teams/get.md +1 -1
  300. package/docs/examples/teams/list-logs.md +1 -1
  301. package/docs/examples/teams/list-memberships.md +1 -1
  302. package/docs/examples/teams/list.md +1 -1
  303. package/docs/examples/teams/update-membership-status.md +1 -1
  304. package/docs/examples/teams/update-membership.md +1 -1
  305. package/docs/examples/teams/update-name.md +1 -1
  306. package/docs/examples/teams/update-prefs.md +1 -1
  307. package/docs/examples/users/create-argon2user.md +1 -1
  308. package/docs/examples/users/create-bcrypt-user.md +1 -1
  309. package/docs/examples/users/create-j-w-t.md +15 -0
  310. package/docs/examples/users/create-m-d5user.md +1 -1
  311. package/docs/examples/users/create-mfa-recovery-codes.md +1 -1
  312. package/docs/examples/users/create-p-h-pass-user.md +1 -1
  313. package/docs/examples/users/create-s-h-a-user.md +1 -1
  314. package/docs/examples/users/create-scrypt-modified-user.md +1 -1
  315. package/docs/examples/users/create-scrypt-user.md +1 -1
  316. package/docs/examples/users/create-session.md +1 -1
  317. package/docs/examples/users/create-target.md +1 -1
  318. package/docs/examples/users/create-token.md +1 -1
  319. package/docs/examples/users/create.md +1 -1
  320. package/docs/examples/users/delete-identity.md +1 -1
  321. package/docs/examples/users/delete-mfa-authenticator.md +1 -1
  322. package/docs/examples/users/delete-session.md +1 -1
  323. package/docs/examples/users/delete-sessions.md +1 -1
  324. package/docs/examples/users/delete-target.md +1 -1
  325. package/docs/examples/users/delete.md +1 -1
  326. package/docs/examples/users/get-mfa-recovery-codes.md +1 -1
  327. package/docs/examples/users/get-prefs.md +1 -1
  328. package/docs/examples/users/get-target.md +1 -1
  329. package/docs/examples/users/get-usage.md +1 -1
  330. package/docs/examples/users/get.md +1 -1
  331. package/docs/examples/users/list-identities.md +1 -1
  332. package/docs/examples/users/list-logs.md +1 -1
  333. package/docs/examples/users/list-memberships.md +1 -1
  334. package/docs/examples/users/list-mfa-factors.md +1 -1
  335. package/docs/examples/users/list-sessions.md +1 -1
  336. package/docs/examples/users/list-targets.md +1 -1
  337. package/docs/examples/users/list.md +1 -1
  338. package/docs/examples/users/update-email-verification.md +1 -1
  339. package/docs/examples/users/update-email.md +1 -1
  340. package/docs/examples/users/update-labels.md +1 -1
  341. package/docs/examples/users/update-mfa-recovery-codes.md +1 -1
  342. package/docs/examples/users/update-mfa.md +1 -1
  343. package/docs/examples/users/update-name.md +1 -1
  344. package/docs/examples/users/update-password.md +1 -1
  345. package/docs/examples/users/update-phone-verification.md +1 -1
  346. package/docs/examples/users/update-phone.md +1 -1
  347. package/docs/examples/users/update-prefs.md +1 -1
  348. package/docs/examples/users/update-status.md +1 -1
  349. package/docs/examples/users/update-target.md +1 -1
  350. package/docs/examples/vcs/create-repository-detection.md +1 -1
  351. package/docs/examples/vcs/create-repository.md +1 -1
  352. package/docs/examples/vcs/delete-installation.md +1 -1
  353. package/docs/examples/vcs/get-installation.md +1 -1
  354. package/docs/examples/vcs/get-repository-contents.md +15 -0
  355. package/docs/examples/vcs/get-repository.md +1 -1
  356. package/docs/examples/vcs/list-installations.md +1 -1
  357. package/docs/examples/vcs/list-repositories.md +1 -1
  358. package/docs/examples/vcs/list-repository-branches.md +1 -1
  359. package/docs/examples/vcs/update-external-deployments.md +1 -1
  360. package/package.json +1 -1
  361. package/src/client.ts +124 -66
  362. package/src/enums/email-template-type.ts +2 -0
  363. package/src/enums/platform-type.ts +2 -0
  364. package/src/enums/runtime.ts +1 -0
  365. package/src/index.ts +1 -1
  366. package/src/models.ts +230 -28
  367. package/src/services/account.ts +651 -644
  368. package/src/services/assistant.ts +19 -16
  369. package/src/services/avatars.ts +111 -152
  370. package/src/services/console.ts +19 -14
  371. package/src/services/databases.ts +628 -638
  372. package/src/services/functions.ts +435 -339
  373. package/src/services/graphql.ts +31 -24
  374. package/src/services/health.ts +299 -199
  375. package/src/services/locale.ts +113 -77
  376. package/src/services/messaging.ts +568 -583
  377. package/src/services/migrations.ts +199 -197
  378. package/src/services/project.ts +82 -65
  379. package/src/services/projects.ts +615 -459
  380. package/src/services/proxy.ts +68 -50
  381. package/src/services/storage.ts +198 -253
  382. package/src/services/teams.ts +198 -188
  383. package/src/services/users.ts +568 -478
  384. package/src/services/vcs.ts +149 -83
  385. package/types/client.d.ts +13 -17
  386. package/types/enums/email-template-type.d.ts +3 -1
  387. package/types/enums/platform-type.d.ts +3 -1
  388. package/types/enums/runtime.d.ts +2 -1
  389. package/types/index.d.ts +1 -1
  390. package/types/models.d.ts +230 -28
  391. package/types/services/account.d.ts +162 -317
  392. package/types/services/assistant.d.ts +4 -4
  393. package/types/services/avatars.d.ts +50 -84
  394. package/types/services/console.d.ts +4 -4
  395. package/types/services/databases.d.ts +143 -173
  396. package/types/services/functions.d.ts +112 -97
  397. package/types/services/graphql.d.ts +6 -6
  398. package/types/services/health.d.ts +64 -85
  399. package/types/services/locale.d.ts +28 -39
  400. package/types/services/messaging.d.ts +103 -104
  401. package/types/services/migrations.d.ts +34 -34
  402. package/types/services/project.d.ts +17 -20
  403. package/types/services/projects.d.ts +118 -87
  404. package/types/services/proxy.d.ts +13 -14
  405. package/types/services/storage.d.ts +53 -78
  406. package/types/services/teams.d.ts +53 -83
  407. package/types/services/users.d.ts +120 -157
  408. package/types/services/vcs.d.ts +31 -20
@@ -1,17 +1,15 @@
1
- import { Service } from '../service';
2
- import { AppwriteException, Client } from '../client';
1
+ import { AppwriteException, Client, type Payload, UploadProgress } from '../client';
3
2
  import type { Models } from '../models';
4
- import type { UploadProgress, Payload } from '../client';
5
3
  import { AuthenticatorType } from '../enums/authenticator-type';
6
4
  import { AuthenticationFactor } from '../enums/authentication-factor';
7
5
  import { OAuthProvider } from '../enums/o-auth-provider';
8
6
 
9
- export class Account extends Service {
7
+ export class Account {
8
+ client: Client;
10
9
 
11
- constructor(client: Client)
12
- {
13
- super(client);
14
- }
10
+ constructor(client: Client) {
11
+ this.client = client;
12
+ }
15
13
 
16
14
  /**
17
15
  * Get account
@@ -19,135 +17,137 @@ export class Account extends Service {
19
17
  * Get the currently logged in user.
20
18
  *
21
19
  * @throws {AppwriteException}
22
- * @returns {Promise}
23
- */
20
+ * @returns {Promise<Models.User<Preferences>>}
21
+ */
24
22
  async get<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> {
25
23
  const apiPath = '/account';
26
24
  const payload: Payload = {};
27
-
28
25
  const uri = new URL(this.client.config.endpoint + apiPath);
29
- return await this.client.call('get', uri, {
26
+
27
+ const apiHeaders: { [header: string]: string } = {
30
28
  'content-type': 'application/json',
31
- }, payload);
32
- }
29
+ }
33
30
 
31
+ return await this.client.call(
32
+ 'get',
33
+ uri,
34
+ apiHeaders,
35
+ payload
36
+ );
37
+ }
34
38
  /**
35
39
  * Create account
36
40
  *
37
- * Use this endpoint to allow a new user to register a new account in your
38
- * project. After the user registration completes successfully, you can use
39
- * the
40
- * [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification)
41
- * route to start verifying the user email address. To allow the new user to
42
- * login to their new account, you need to create a new [account
43
- * session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
41
+ * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
44
42
  *
45
43
  * @param {string} userId
46
44
  * @param {string} email
47
45
  * @param {string} password
48
46
  * @param {string} name
49
47
  * @throws {AppwriteException}
50
- * @returns {Promise}
51
- */
48
+ * @returns {Promise<Models.User<Preferences>>}
49
+ */
52
50
  async create<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
53
51
  if (typeof userId === 'undefined') {
54
52
  throw new AppwriteException('Missing required parameter: "userId"');
55
53
  }
56
-
57
54
  if (typeof email === 'undefined') {
58
55
  throw new AppwriteException('Missing required parameter: "email"');
59
56
  }
60
-
61
57
  if (typeof password === 'undefined') {
62
58
  throw new AppwriteException('Missing required parameter: "password"');
63
59
  }
64
-
65
60
  const apiPath = '/account';
66
61
  const payload: Payload = {};
67
-
68
62
  if (typeof userId !== 'undefined') {
69
63
  payload['userId'] = userId;
70
64
  }
71
-
72
65
  if (typeof email !== 'undefined') {
73
66
  payload['email'] = email;
74
67
  }
75
-
76
68
  if (typeof password !== 'undefined') {
77
69
  payload['password'] = password;
78
70
  }
79
-
80
71
  if (typeof name !== 'undefined') {
81
72
  payload['name'] = name;
82
73
  }
83
-
84
74
  const uri = new URL(this.client.config.endpoint + apiPath);
85
- return await this.client.call('post', uri, {
75
+
76
+ const apiHeaders: { [header: string]: string } = {
86
77
  'content-type': 'application/json',
87
- }, payload);
88
- }
78
+ }
89
79
 
80
+ return await this.client.call(
81
+ 'post',
82
+ uri,
83
+ apiHeaders,
84
+ payload
85
+ );
86
+ }
90
87
  /**
91
88
  * Delete account
92
89
  *
93
90
  * Delete the currently logged in user.
94
91
  *
95
92
  * @throws {AppwriteException}
96
- * @returns {Promise}
97
- */
93
+ * @returns {Promise<{}>}
94
+ */
98
95
  async delete(): Promise<{}> {
99
96
  const apiPath = '/account';
100
97
  const payload: Payload = {};
101
-
102
98
  const uri = new URL(this.client.config.endpoint + apiPath);
103
- return await this.client.call('delete', uri, {
99
+
100
+ const apiHeaders: { [header: string]: string } = {
104
101
  'content-type': 'application/json',
105
- }, payload);
106
- }
102
+ }
107
103
 
104
+ return await this.client.call(
105
+ 'delete',
106
+ uri,
107
+ apiHeaders,
108
+ payload
109
+ );
110
+ }
108
111
  /**
109
112
  * Update email
110
113
  *
111
- * Update currently logged in user account email address. After changing user
112
- * address, the user confirmation status will get reset. A new confirmation
113
- * email is not sent automatically however you can use the send confirmation
114
- * email endpoint again to send the confirmation email. For security measures,
115
- * user password is required to complete this request.
116
- * This endpoint can also be used to convert an anonymous account to a normal
117
- * one, by passing an email address and a new password.
118
- *
114
+ * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request.
115
+ This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.
116
+
119
117
  *
120
118
  * @param {string} email
121
119
  * @param {string} password
122
120
  * @throws {AppwriteException}
123
- * @returns {Promise}
124
- */
121
+ * @returns {Promise<Models.User<Preferences>>}
122
+ */
125
123
  async updateEmail<Preferences extends Models.Preferences>(email: string, password: string): Promise<Models.User<Preferences>> {
126
124
  if (typeof email === 'undefined') {
127
125
  throw new AppwriteException('Missing required parameter: "email"');
128
126
  }
129
-
130
127
  if (typeof password === 'undefined') {
131
128
  throw new AppwriteException('Missing required parameter: "password"');
132
129
  }
133
-
134
130
  const apiPath = '/account/email';
135
131
  const payload: Payload = {};
136
-
137
132
  if (typeof email !== 'undefined') {
138
133
  payload['email'] = email;
139
134
  }
140
-
141
135
  if (typeof password !== 'undefined') {
142
136
  payload['password'] = password;
143
137
  }
144
-
145
138
  const uri = new URL(this.client.config.endpoint + apiPath);
146
- return await this.client.call('patch', uri, {
139
+
140
+ const apiHeaders: { [header: string]: string } = {
147
141
  'content-type': 'application/json',
148
- }, payload);
149
- }
142
+ }
150
143
 
144
+ return await this.client.call(
145
+ 'patch',
146
+ uri,
147
+ apiHeaders,
148
+ payload
149
+ );
150
+ }
151
151
  /**
152
152
  * List Identities
153
153
  *
@@ -155,22 +155,27 @@ export class Account extends Service {
155
155
  *
156
156
  * @param {string[]} queries
157
157
  * @throws {AppwriteException}
158
- * @returns {Promise}
159
- */
158
+ * @returns {Promise<Models.IdentityList>}
159
+ */
160
160
  async listIdentities(queries?: string[]): Promise<Models.IdentityList> {
161
161
  const apiPath = '/account/identities';
162
162
  const payload: Payload = {};
163
-
164
163
  if (typeof queries !== 'undefined') {
165
164
  payload['queries'] = queries;
166
165
  }
167
-
168
166
  const uri = new URL(this.client.config.endpoint + apiPath);
169
- return await this.client.call('get', uri, {
167
+
168
+ const apiHeaders: { [header: string]: string } = {
170
169
  'content-type': 'application/json',
171
- }, payload);
172
- }
170
+ }
173
171
 
172
+ return await this.client.call(
173
+ 'get',
174
+ uri,
175
+ apiHeaders,
176
+ payload
177
+ );
178
+ }
174
179
  /**
175
180
  * Delete identity
176
181
  *
@@ -178,68 +183,79 @@ export class Account extends Service {
178
183
  *
179
184
  * @param {string} identityId
180
185
  * @throws {AppwriteException}
181
- * @returns {Promise}
182
- */
186
+ * @returns {Promise<{}>}
187
+ */
183
188
  async deleteIdentity(identityId: string): Promise<{}> {
184
189
  if (typeof identityId === 'undefined') {
185
190
  throw new AppwriteException('Missing required parameter: "identityId"');
186
191
  }
187
-
188
192
  const apiPath = '/account/identities/{identityId}'.replace('{identityId}', identityId);
189
193
  const payload: Payload = {};
190
-
191
194
  const uri = new URL(this.client.config.endpoint + apiPath);
192
- return await this.client.call('delete', uri, {
195
+
196
+ const apiHeaders: { [header: string]: string } = {
193
197
  'content-type': 'application/json',
194
- }, payload);
195
- }
198
+ }
196
199
 
200
+ return await this.client.call(
201
+ 'delete',
202
+ uri,
203
+ apiHeaders,
204
+ payload
205
+ );
206
+ }
197
207
  /**
198
208
  * Create JWT
199
209
  *
200
- * Use this endpoint to create a JSON Web Token. You can use the resulting JWT
201
- * to authenticate on behalf of the current user when working with the
202
- * Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
203
- * from its creation and will be invalid if the user will logout in that time
204
- * frame.
210
+ * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame.
205
211
  *
206
212
  * @throws {AppwriteException}
207
- * @returns {Promise}
208
- */
213
+ * @returns {Promise<Models.Jwt>}
214
+ */
209
215
  async createJWT(): Promise<Models.Jwt> {
210
- const apiPath = '/account/jwt';
216
+ const apiPath = '/account/jwts';
211
217
  const payload: Payload = {};
212
-
213
218
  const uri = new URL(this.client.config.endpoint + apiPath);
214
- return await this.client.call('post', uri, {
219
+
220
+ const apiHeaders: { [header: string]: string } = {
215
221
  'content-type': 'application/json',
216
- }, payload);
217
- }
222
+ }
218
223
 
224
+ return await this.client.call(
225
+ 'post',
226
+ uri,
227
+ apiHeaders,
228
+ payload
229
+ );
230
+ }
219
231
  /**
220
232
  * List logs
221
233
  *
222
- * Get the list of latest security activity logs for the currently logged in
223
- * user. Each log returns user IP address, location and date and time of log.
234
+ * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log.
224
235
  *
225
236
  * @param {string[]} queries
226
237
  * @throws {AppwriteException}
227
- * @returns {Promise}
228
- */
238
+ * @returns {Promise<Models.LogList>}
239
+ */
229
240
  async listLogs(queries?: string[]): Promise<Models.LogList> {
230
241
  const apiPath = '/account/logs';
231
242
  const payload: Payload = {};
232
-
233
243
  if (typeof queries !== 'undefined') {
234
244
  payload['queries'] = queries;
235
245
  }
236
-
237
246
  const uri = new URL(this.client.config.endpoint + apiPath);
238
- return await this.client.call('get', uri, {
247
+
248
+ const apiHeaders: { [header: string]: string } = {
239
249
  'content-type': 'application/json',
240
- }, payload);
241
- }
250
+ }
242
251
 
252
+ return await this.client.call(
253
+ 'get',
254
+ uri,
255
+ apiHeaders,
256
+ payload
257
+ );
258
+ }
243
259
  /**
244
260
  * Update MFA
245
261
  *
@@ -247,269 +263,286 @@ export class Account extends Service {
247
263
  *
248
264
  * @param {boolean} mfa
249
265
  * @throws {AppwriteException}
250
- * @returns {Promise}
251
- */
266
+ * @returns {Promise<Models.User<Preferences>>}
267
+ */
252
268
  async updateMFA<Preferences extends Models.Preferences>(mfa: boolean): Promise<Models.User<Preferences>> {
253
269
  if (typeof mfa === 'undefined') {
254
270
  throw new AppwriteException('Missing required parameter: "mfa"');
255
271
  }
256
-
257
272
  const apiPath = '/account/mfa';
258
273
  const payload: Payload = {};
259
-
260
274
  if (typeof mfa !== 'undefined') {
261
275
  payload['mfa'] = mfa;
262
276
  }
263
-
264
277
  const uri = new URL(this.client.config.endpoint + apiPath);
265
- return await this.client.call('patch', uri, {
278
+
279
+ const apiHeaders: { [header: string]: string } = {
266
280
  'content-type': 'application/json',
267
- }, payload);
268
- }
281
+ }
269
282
 
283
+ return await this.client.call(
284
+ 'patch',
285
+ uri,
286
+ apiHeaders,
287
+ payload
288
+ );
289
+ }
270
290
  /**
271
291
  * Create Authenticator
272
292
  *
273
- * Add an authenticator app to be used as an MFA factor. Verify the
274
- * authenticator using the [verify
275
- * authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
276
- * method.
293
+ * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.
277
294
  *
278
295
  * @param {AuthenticatorType} type
279
296
  * @throws {AppwriteException}
280
- * @returns {Promise}
281
- */
297
+ * @returns {Promise<Models.MfaType>}
298
+ */
282
299
  async createMfaAuthenticator(type: AuthenticatorType): Promise<Models.MfaType> {
283
300
  if (typeof type === 'undefined') {
284
301
  throw new AppwriteException('Missing required parameter: "type"');
285
302
  }
286
-
287
303
  const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
288
304
  const payload: Payload = {};
289
-
290
305
  const uri = new URL(this.client.config.endpoint + apiPath);
291
- return await this.client.call('post', uri, {
306
+
307
+ const apiHeaders: { [header: string]: string } = {
292
308
  'content-type': 'application/json',
293
- }, payload);
294
- }
309
+ }
295
310
 
311
+ return await this.client.call(
312
+ 'post',
313
+ uri,
314
+ apiHeaders,
315
+ payload
316
+ );
317
+ }
296
318
  /**
297
319
  * Verify Authenticator
298
320
  *
299
- * Verify an authenticator app after adding it using the [add
300
- * authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
301
- * method.
321
+ * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method.
302
322
  *
303
323
  * @param {AuthenticatorType} type
304
324
  * @param {string} otp
305
325
  * @throws {AppwriteException}
306
- * @returns {Promise}
307
- */
326
+ * @returns {Promise<Models.User<Preferences>>}
327
+ */
308
328
  async updateMfaAuthenticator<Preferences extends Models.Preferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>> {
309
329
  if (typeof type === 'undefined') {
310
330
  throw new AppwriteException('Missing required parameter: "type"');
311
331
  }
312
-
313
332
  if (typeof otp === 'undefined') {
314
333
  throw new AppwriteException('Missing required parameter: "otp"');
315
334
  }
316
-
317
335
  const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
318
336
  const payload: Payload = {};
319
-
320
337
  if (typeof otp !== 'undefined') {
321
338
  payload['otp'] = otp;
322
339
  }
323
-
324
340
  const uri = new URL(this.client.config.endpoint + apiPath);
325
- return await this.client.call('put', uri, {
341
+
342
+ const apiHeaders: { [header: string]: string } = {
326
343
  'content-type': 'application/json',
327
- }, payload);
328
- }
344
+ }
329
345
 
346
+ return await this.client.call(
347
+ 'put',
348
+ uri,
349
+ apiHeaders,
350
+ payload
351
+ );
352
+ }
330
353
  /**
331
354
  * Delete Authenticator
332
355
  *
333
356
  * Delete an authenticator for a user by ID.
334
357
  *
335
358
  * @param {AuthenticatorType} type
336
- * @param {string} otp
337
359
  * @throws {AppwriteException}
338
- * @returns {Promise}
339
- */
340
- async deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise<{}> {
360
+ * @returns {Promise<{}>}
361
+ */
362
+ async deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}> {
341
363
  if (typeof type === 'undefined') {
342
364
  throw new AppwriteException('Missing required parameter: "type"');
343
365
  }
344
-
345
- if (typeof otp === 'undefined') {
346
- throw new AppwriteException('Missing required parameter: "otp"');
347
- }
348
-
349
366
  const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
350
367
  const payload: Payload = {};
368
+ const uri = new URL(this.client.config.endpoint + apiPath);
351
369
 
352
- if (typeof otp !== 'undefined') {
353
- payload['otp'] = otp;
370
+ const apiHeaders: { [header: string]: string } = {
371
+ 'content-type': 'application/json',
354
372
  }
355
373
 
356
- const uri = new URL(this.client.config.endpoint + apiPath);
357
- return await this.client.call('delete', uri, {
358
- 'content-type': 'application/json',
359
- }, payload);
374
+ return await this.client.call(
375
+ 'delete',
376
+ uri,
377
+ apiHeaders,
378
+ payload
379
+ );
360
380
  }
361
-
362
381
  /**
363
382
  * Create MFA Challenge
364
383
  *
365
- * Begin the process of MFA verification after sign-in. Finish the flow with
366
- * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
367
- * method.
384
+ * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method.
368
385
  *
369
386
  * @param {AuthenticationFactor} factor
370
387
  * @throws {AppwriteException}
371
- * @returns {Promise}
372
- */
388
+ * @returns {Promise<Models.MfaChallenge>}
389
+ */
373
390
  async createMfaChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge> {
374
391
  if (typeof factor === 'undefined') {
375
392
  throw new AppwriteException('Missing required parameter: "factor"');
376
393
  }
377
-
378
394
  const apiPath = '/account/mfa/challenge';
379
395
  const payload: Payload = {};
380
-
381
396
  if (typeof factor !== 'undefined') {
382
397
  payload['factor'] = factor;
383
398
  }
384
-
385
399
  const uri = new URL(this.client.config.endpoint + apiPath);
386
- return await this.client.call('post', uri, {
400
+
401
+ const apiHeaders: { [header: string]: string } = {
387
402
  'content-type': 'application/json',
388
- }, payload);
389
- }
403
+ }
390
404
 
405
+ return await this.client.call(
406
+ 'post',
407
+ uri,
408
+ apiHeaders,
409
+ payload
410
+ );
411
+ }
391
412
  /**
392
413
  * Create MFA Challenge (confirmation)
393
414
  *
394
- * Complete the MFA challenge by providing the one-time password. Finish the
395
- * process of MFA verification by providing the one-time password. To begin
396
- * the flow, use
397
- * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
398
- * method.
415
+ * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
399
416
  *
400
417
  * @param {string} challengeId
401
418
  * @param {string} otp
402
419
  * @throws {AppwriteException}
403
- * @returns {Promise}
404
- */
420
+ * @returns {Promise<{}>}
421
+ */
405
422
  async updateMfaChallenge(challengeId: string, otp: string): Promise<{}> {
406
423
  if (typeof challengeId === 'undefined') {
407
424
  throw new AppwriteException('Missing required parameter: "challengeId"');
408
425
  }
409
-
410
426
  if (typeof otp === 'undefined') {
411
427
  throw new AppwriteException('Missing required parameter: "otp"');
412
428
  }
413
-
414
429
  const apiPath = '/account/mfa/challenge';
415
430
  const payload: Payload = {};
416
-
417
431
  if (typeof challengeId !== 'undefined') {
418
432
  payload['challengeId'] = challengeId;
419
433
  }
420
-
421
434
  if (typeof otp !== 'undefined') {
422
435
  payload['otp'] = otp;
423
436
  }
424
-
425
437
  const uri = new URL(this.client.config.endpoint + apiPath);
426
- return await this.client.call('put', uri, {
438
+
439
+ const apiHeaders: { [header: string]: string } = {
427
440
  'content-type': 'application/json',
428
- }, payload);
429
- }
441
+ }
430
442
 
443
+ return await this.client.call(
444
+ 'put',
445
+ uri,
446
+ apiHeaders,
447
+ payload
448
+ );
449
+ }
431
450
  /**
432
451
  * List Factors
433
452
  *
434
453
  * List the factors available on the account to be used as a MFA challange.
435
454
  *
436
455
  * @throws {AppwriteException}
437
- * @returns {Promise}
438
- */
456
+ * @returns {Promise<Models.MfaFactors>}
457
+ */
439
458
  async listMfaFactors(): Promise<Models.MfaFactors> {
440
459
  const apiPath = '/account/mfa/factors';
441
460
  const payload: Payload = {};
442
-
443
461
  const uri = new URL(this.client.config.endpoint + apiPath);
444
- return await this.client.call('get', uri, {
462
+
463
+ const apiHeaders: { [header: string]: string } = {
445
464
  'content-type': 'application/json',
446
- }, payload);
447
- }
465
+ }
448
466
 
467
+ return await this.client.call(
468
+ 'get',
469
+ uri,
470
+ apiHeaders,
471
+ payload
472
+ );
473
+ }
449
474
  /**
450
475
  * Get MFA Recovery Codes
451
476
  *
452
- * Get recovery codes that can be used as backup for MFA flow. Before getting
453
- * codes, they must be generated using
454
- * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
455
- * method. An OTP challenge is required to read recovery codes.
477
+ * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes.
456
478
  *
457
479
  * @throws {AppwriteException}
458
- * @returns {Promise}
459
- */
480
+ * @returns {Promise<Models.MfaRecoveryCodes>}
481
+ */
460
482
  async getMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> {
461
483
  const apiPath = '/account/mfa/recovery-codes';
462
484
  const payload: Payload = {};
463
-
464
485
  const uri = new URL(this.client.config.endpoint + apiPath);
465
- return await this.client.call('get', uri, {
486
+
487
+ const apiHeaders: { [header: string]: string } = {
466
488
  'content-type': 'application/json',
467
- }, payload);
468
- }
489
+ }
469
490
 
491
+ return await this.client.call(
492
+ 'get',
493
+ uri,
494
+ apiHeaders,
495
+ payload
496
+ );
497
+ }
470
498
  /**
471
499
  * Create MFA Recovery Codes
472
500
  *
473
- * Generate recovery codes as backup for MFA flow. It's recommended to
474
- * generate and show then immediately after user successfully adds their
475
- * authehticator. Recovery codes can be used as a MFA verification type in
476
- * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
477
- * method.
501
+ * Generate recovery codes as backup for MFA flow. It&#039;s recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
478
502
  *
479
503
  * @throws {AppwriteException}
480
- * @returns {Promise}
481
- */
504
+ * @returns {Promise<Models.MfaRecoveryCodes>}
505
+ */
482
506
  async createMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> {
483
507
  const apiPath = '/account/mfa/recovery-codes';
484
508
  const payload: Payload = {};
485
-
486
509
  const uri = new URL(this.client.config.endpoint + apiPath);
487
- return await this.client.call('post', uri, {
510
+
511
+ const apiHeaders: { [header: string]: string } = {
488
512
  'content-type': 'application/json',
489
- }, payload);
490
- }
513
+ }
491
514
 
515
+ return await this.client.call(
516
+ 'post',
517
+ uri,
518
+ apiHeaders,
519
+ payload
520
+ );
521
+ }
492
522
  /**
493
523
  * Regenerate MFA Recovery Codes
494
524
  *
495
- * Regenerate recovery codes that can be used as backup for MFA flow. Before
496
- * regenerating codes, they must be first generated using
497
- * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
498
- * method. An OTP challenge is required to regenreate recovery codes.
525
+ * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes.
499
526
  *
500
527
  * @throws {AppwriteException}
501
- * @returns {Promise}
502
- */
528
+ * @returns {Promise<Models.MfaRecoveryCodes>}
529
+ */
503
530
  async updateMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> {
504
531
  const apiPath = '/account/mfa/recovery-codes';
505
532
  const payload: Payload = {};
506
-
507
533
  const uri = new URL(this.client.config.endpoint + apiPath);
508
- return await this.client.call('patch', uri, {
534
+
535
+ const apiHeaders: { [header: string]: string } = {
509
536
  'content-type': 'application/json',
510
- }, payload);
511
- }
537
+ }
512
538
 
539
+ return await this.client.call(
540
+ 'patch',
541
+ uri,
542
+ apiHeaders,
543
+ payload
544
+ );
545
+ }
513
546
  /**
514
547
  * Update name
515
548
  *
@@ -517,618 +550,626 @@ export class Account extends Service {
517
550
  *
518
551
  * @param {string} name
519
552
  * @throws {AppwriteException}
520
- * @returns {Promise}
521
- */
553
+ * @returns {Promise<Models.User<Preferences>>}
554
+ */
522
555
  async updateName<Preferences extends Models.Preferences>(name: string): Promise<Models.User<Preferences>> {
523
556
  if (typeof name === 'undefined') {
524
557
  throw new AppwriteException('Missing required parameter: "name"');
525
558
  }
526
-
527
559
  const apiPath = '/account/name';
528
560
  const payload: Payload = {};
529
-
530
561
  if (typeof name !== 'undefined') {
531
562
  payload['name'] = name;
532
563
  }
533
-
534
564
  const uri = new URL(this.client.config.endpoint + apiPath);
535
- return await this.client.call('patch', uri, {
565
+
566
+ const apiHeaders: { [header: string]: string } = {
536
567
  'content-type': 'application/json',
537
- }, payload);
538
- }
568
+ }
539
569
 
570
+ return await this.client.call(
571
+ 'patch',
572
+ uri,
573
+ apiHeaders,
574
+ payload
575
+ );
576
+ }
540
577
  /**
541
578
  * Update password
542
579
  *
543
- * Update currently logged in user password. For validation, user is required
544
- * to pass in the new password, and the old password. For users created with
545
- * OAuth, Team Invites and Magic URL, oldPassword is optional.
580
+ * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.
546
581
  *
547
582
  * @param {string} password
548
583
  * @param {string} oldPassword
549
584
  * @throws {AppwriteException}
550
- * @returns {Promise}
551
- */
585
+ * @returns {Promise<Models.User<Preferences>>}
586
+ */
552
587
  async updatePassword<Preferences extends Models.Preferences>(password: string, oldPassword?: string): Promise<Models.User<Preferences>> {
553
588
  if (typeof password === 'undefined') {
554
589
  throw new AppwriteException('Missing required parameter: "password"');
555
590
  }
556
-
557
591
  const apiPath = '/account/password';
558
592
  const payload: Payload = {};
559
-
560
593
  if (typeof password !== 'undefined') {
561
594
  payload['password'] = password;
562
595
  }
563
-
564
596
  if (typeof oldPassword !== 'undefined') {
565
597
  payload['oldPassword'] = oldPassword;
566
598
  }
567
-
568
599
  const uri = new URL(this.client.config.endpoint + apiPath);
569
- return await this.client.call('patch', uri, {
600
+
601
+ const apiHeaders: { [header: string]: string } = {
570
602
  'content-type': 'application/json',
571
- }, payload);
572
- }
603
+ }
573
604
 
605
+ return await this.client.call(
606
+ 'patch',
607
+ uri,
608
+ apiHeaders,
609
+ payload
610
+ );
611
+ }
574
612
  /**
575
613
  * Update phone
576
614
  *
577
- * Update the currently logged in user's phone number. After updating the
578
- * phone number, the phone verification status will be reset. A confirmation
579
- * SMS is not sent automatically, however you can use the [POST
580
- * /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification)
581
- * endpoint to send a confirmation SMS.
615
+ * Update the currently logged in user&#039;s phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS.
582
616
  *
583
617
  * @param {string} phone
584
618
  * @param {string} password
585
619
  * @throws {AppwriteException}
586
- * @returns {Promise}
587
- */
620
+ * @returns {Promise<Models.User<Preferences>>}
621
+ */
588
622
  async updatePhone<Preferences extends Models.Preferences>(phone: string, password: string): Promise<Models.User<Preferences>> {
589
623
  if (typeof phone === 'undefined') {
590
624
  throw new AppwriteException('Missing required parameter: "phone"');
591
625
  }
592
-
593
626
  if (typeof password === 'undefined') {
594
627
  throw new AppwriteException('Missing required parameter: "password"');
595
628
  }
596
-
597
629
  const apiPath = '/account/phone';
598
630
  const payload: Payload = {};
599
-
600
631
  if (typeof phone !== 'undefined') {
601
632
  payload['phone'] = phone;
602
633
  }
603
-
604
634
  if (typeof password !== 'undefined') {
605
635
  payload['password'] = password;
606
636
  }
607
-
608
637
  const uri = new URL(this.client.config.endpoint + apiPath);
609
- return await this.client.call('patch', uri, {
638
+
639
+ const apiHeaders: { [header: string]: string } = {
610
640
  'content-type': 'application/json',
611
- }, payload);
612
- }
641
+ }
613
642
 
643
+ return await this.client.call(
644
+ 'patch',
645
+ uri,
646
+ apiHeaders,
647
+ payload
648
+ );
649
+ }
614
650
  /**
615
651
  * Get account preferences
616
652
  *
617
653
  * Get the preferences as a key-value object for the currently logged in user.
618
654
  *
619
655
  * @throws {AppwriteException}
620
- * @returns {Promise}
621
- */
656
+ * @returns {Promise<Preferences>}
657
+ */
622
658
  async getPrefs<Preferences extends Models.Preferences>(): Promise<Preferences> {
623
659
  const apiPath = '/account/prefs';
624
660
  const payload: Payload = {};
625
-
626
661
  const uri = new URL(this.client.config.endpoint + apiPath);
627
- return await this.client.call('get', uri, {
662
+
663
+ const apiHeaders: { [header: string]: string } = {
628
664
  'content-type': 'application/json',
629
- }, payload);
630
- }
665
+ }
631
666
 
667
+ return await this.client.call(
668
+ 'get',
669
+ uri,
670
+ apiHeaders,
671
+ payload
672
+ );
673
+ }
632
674
  /**
633
675
  * Update preferences
634
676
  *
635
- * Update currently logged in user account preferences. The object you pass is
636
- * stored as is, and replaces any previous value. The maximum allowed prefs
637
- * size is 64kB and throws error if exceeded.
677
+ * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.
638
678
  *
639
679
  * @param {Partial<Preferences>} prefs
640
680
  * @throws {AppwriteException}
641
- * @returns {Promise}
642
- */
681
+ * @returns {Promise<Models.User<Preferences>>}
682
+ */
643
683
  async updatePrefs<Preferences extends Models.Preferences>(prefs: Partial<Preferences>): Promise<Models.User<Preferences>> {
644
684
  if (typeof prefs === 'undefined') {
645
685
  throw new AppwriteException('Missing required parameter: "prefs"');
646
686
  }
647
-
648
687
  const apiPath = '/account/prefs';
649
688
  const payload: Payload = {};
650
-
651
689
  if (typeof prefs !== 'undefined') {
652
690
  payload['prefs'] = prefs;
653
691
  }
654
-
655
692
  const uri = new URL(this.client.config.endpoint + apiPath);
656
- return await this.client.call('patch', uri, {
693
+
694
+ const apiHeaders: { [header: string]: string } = {
657
695
  'content-type': 'application/json',
658
- }, payload);
659
- }
696
+ }
660
697
 
698
+ return await this.client.call(
699
+ 'patch',
700
+ uri,
701
+ apiHeaders,
702
+ payload
703
+ );
704
+ }
661
705
  /**
662
706
  * Create password recovery
663
707
  *
664
- * Sends the user an email with a temporary secret key for password reset.
665
- * When the user clicks the confirmation link he is redirected back to your
666
- * app password reset URL with the secret key and email address values
667
- * attached to the URL query string. Use the query string params to submit a
668
- * request to the [PUT
669
- * /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery)
670
- * endpoint to complete the process. The verification link sent to the user's
671
- * email address is valid for 1 hour.
708
+ * Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user&#039;s email address is valid for 1 hour.
672
709
  *
673
710
  * @param {string} email
674
711
  * @param {string} url
675
712
  * @throws {AppwriteException}
676
- * @returns {Promise}
677
- */
713
+ * @returns {Promise<Models.Token>}
714
+ */
678
715
  async createRecovery(email: string, url: string): Promise<Models.Token> {
679
716
  if (typeof email === 'undefined') {
680
717
  throw new AppwriteException('Missing required parameter: "email"');
681
718
  }
682
-
683
719
  if (typeof url === 'undefined') {
684
720
  throw new AppwriteException('Missing required parameter: "url"');
685
721
  }
686
-
687
722
  const apiPath = '/account/recovery';
688
723
  const payload: Payload = {};
689
-
690
724
  if (typeof email !== 'undefined') {
691
725
  payload['email'] = email;
692
726
  }
693
-
694
727
  if (typeof url !== 'undefined') {
695
728
  payload['url'] = url;
696
729
  }
697
-
698
730
  const uri = new URL(this.client.config.endpoint + apiPath);
699
- return await this.client.call('post', uri, {
731
+
732
+ const apiHeaders: { [header: string]: string } = {
700
733
  'content-type': 'application/json',
701
- }, payload);
702
- }
734
+ }
703
735
 
736
+ return await this.client.call(
737
+ 'post',
738
+ uri,
739
+ apiHeaders,
740
+ payload
741
+ );
742
+ }
704
743
  /**
705
744
  * Create password recovery (confirmation)
706
745
  *
707
- * Use this endpoint to complete the user account password reset. Both the
708
- * **userId** and **secret** arguments will be passed as query parameters to
709
- * the redirect URL you have provided when sending your request to the [POST
710
- * /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery)
711
- * endpoint.
712
- *
713
- * Please note that in order to avoid a [Redirect
714
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
715
- * the only valid redirect URLs are the ones from domains you have set when
716
- * adding your platforms in the console interface.
746
+ * Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint.
747
+
748
+ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
717
749
  *
718
750
  * @param {string} userId
719
751
  * @param {string} secret
720
752
  * @param {string} password
721
753
  * @throws {AppwriteException}
722
- * @returns {Promise}
723
- */
754
+ * @returns {Promise<Models.Token>}
755
+ */
724
756
  async updateRecovery(userId: string, secret: string, password: string): Promise<Models.Token> {
725
757
  if (typeof userId === 'undefined') {
726
758
  throw new AppwriteException('Missing required parameter: "userId"');
727
759
  }
728
-
729
760
  if (typeof secret === 'undefined') {
730
761
  throw new AppwriteException('Missing required parameter: "secret"');
731
762
  }
732
-
733
763
  if (typeof password === 'undefined') {
734
764
  throw new AppwriteException('Missing required parameter: "password"');
735
765
  }
736
-
737
766
  const apiPath = '/account/recovery';
738
767
  const payload: Payload = {};
739
-
740
768
  if (typeof userId !== 'undefined') {
741
769
  payload['userId'] = userId;
742
770
  }
743
-
744
771
  if (typeof secret !== 'undefined') {
745
772
  payload['secret'] = secret;
746
773
  }
747
-
748
774
  if (typeof password !== 'undefined') {
749
775
  payload['password'] = password;
750
776
  }
751
-
752
777
  const uri = new URL(this.client.config.endpoint + apiPath);
753
- return await this.client.call('put', uri, {
778
+
779
+ const apiHeaders: { [header: string]: string } = {
754
780
  'content-type': 'application/json',
755
- }, payload);
756
- }
781
+ }
757
782
 
783
+ return await this.client.call(
784
+ 'put',
785
+ uri,
786
+ apiHeaders,
787
+ payload
788
+ );
789
+ }
758
790
  /**
759
791
  * List sessions
760
792
  *
761
- * Get the list of active sessions across different devices for the currently
762
- * logged in user.
793
+ * Get the list of active sessions across different devices for the currently logged in user.
763
794
  *
764
795
  * @throws {AppwriteException}
765
- * @returns {Promise}
766
- */
796
+ * @returns {Promise<Models.SessionList>}
797
+ */
767
798
  async listSessions(): Promise<Models.SessionList> {
768
799
  const apiPath = '/account/sessions';
769
800
  const payload: Payload = {};
770
-
771
801
  const uri = new URL(this.client.config.endpoint + apiPath);
772
- return await this.client.call('get', uri, {
802
+
803
+ const apiHeaders: { [header: string]: string } = {
773
804
  'content-type': 'application/json',
774
- }, payload);
775
- }
805
+ }
776
806
 
807
+ return await this.client.call(
808
+ 'get',
809
+ uri,
810
+ apiHeaders,
811
+ payload
812
+ );
813
+ }
777
814
  /**
778
815
  * Delete sessions
779
816
  *
780
- * Delete all sessions from the user account and remove any sessions cookies
781
- * from the end client.
817
+ * Delete all sessions from the user account and remove any sessions cookies from the end client.
782
818
  *
783
819
  * @throws {AppwriteException}
784
- * @returns {Promise}
785
- */
820
+ * @returns {Promise<{}>}
821
+ */
786
822
  async deleteSessions(): Promise<{}> {
787
823
  const apiPath = '/account/sessions';
788
824
  const payload: Payload = {};
789
-
790
825
  const uri = new URL(this.client.config.endpoint + apiPath);
791
- return await this.client.call('delete', uri, {
826
+
827
+ const apiHeaders: { [header: string]: string } = {
792
828
  'content-type': 'application/json',
793
- }, payload);
794
- }
829
+ }
795
830
 
831
+ return await this.client.call(
832
+ 'delete',
833
+ uri,
834
+ apiHeaders,
835
+ payload
836
+ );
837
+ }
796
838
  /**
797
839
  * Create anonymous session
798
840
  *
799
- * Use this endpoint to allow a new user to register an anonymous account in
800
- * your project. This route will also create a new session for the user. To
801
- * allow the new user to convert an anonymous account to a normal account, you
802
- * need to update its [email and
803
- * password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail)
804
- * or create an [OAuth2
805
- * session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).
841
+ * Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).
806
842
  *
807
843
  * @throws {AppwriteException}
808
- * @returns {Promise}
809
- */
844
+ * @returns {Promise<Models.Session>}
845
+ */
810
846
  async createAnonymousSession(): Promise<Models.Session> {
811
847
  const apiPath = '/account/sessions/anonymous';
812
848
  const payload: Payload = {};
813
-
814
849
  const uri = new URL(this.client.config.endpoint + apiPath);
815
- return await this.client.call('post', uri, {
850
+
851
+ const apiHeaders: { [header: string]: string } = {
816
852
  'content-type': 'application/json',
817
- }, payload);
818
- }
853
+ }
819
854
 
855
+ return await this.client.call(
856
+ 'post',
857
+ uri,
858
+ apiHeaders,
859
+ payload
860
+ );
861
+ }
820
862
  /**
821
863
  * Create email password session
822
864
  *
823
- * Allow the user to login into their account by providing a valid email and
824
- * password combination. This route will create a new session for the user.
825
- *
826
- * A user is limited to 10 active sessions at a time by default. [Learn more
827
- * about session
828
- * limits](https://appwrite.io/docs/authentication-security#limits).
865
+ * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.
866
+
867
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
829
868
  *
830
869
  * @param {string} email
831
870
  * @param {string} password
832
871
  * @throws {AppwriteException}
833
- * @returns {Promise}
834
- */
872
+ * @returns {Promise<Models.Session>}
873
+ */
835
874
  async createEmailPasswordSession(email: string, password: string): Promise<Models.Session> {
836
875
  if (typeof email === 'undefined') {
837
876
  throw new AppwriteException('Missing required parameter: "email"');
838
877
  }
839
-
840
878
  if (typeof password === 'undefined') {
841
879
  throw new AppwriteException('Missing required parameter: "password"');
842
880
  }
843
-
844
881
  const apiPath = '/account/sessions/email';
845
882
  const payload: Payload = {};
846
-
847
883
  if (typeof email !== 'undefined') {
848
884
  payload['email'] = email;
849
885
  }
850
-
851
886
  if (typeof password !== 'undefined') {
852
887
  payload['password'] = password;
853
888
  }
854
-
855
889
  const uri = new URL(this.client.config.endpoint + apiPath);
856
- return await this.client.call('post', uri, {
890
+
891
+ const apiHeaders: { [header: string]: string } = {
857
892
  'content-type': 'application/json',
858
- }, payload);
859
- }
893
+ }
860
894
 
895
+ return await this.client.call(
896
+ 'post',
897
+ uri,
898
+ apiHeaders,
899
+ payload
900
+ );
901
+ }
861
902
  /**
862
903
  * Update magic URL session
863
904
  *
864
- * Use this endpoint to create a session from token. Provide the **userId**
865
- * and **secret** parameters from the successful response of authentication
866
- * flows initiated by token creation. For example, magic URL and phone login.
905
+ * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.
867
906
  *
868
907
  * @param {string} userId
869
908
  * @param {string} secret
870
909
  * @throws {AppwriteException}
871
- * @returns {Promise}
872
- */
910
+ * @returns {Promise<Models.Session>}
911
+ */
873
912
  async updateMagicURLSession(userId: string, secret: string): Promise<Models.Session> {
874
913
  if (typeof userId === 'undefined') {
875
914
  throw new AppwriteException('Missing required parameter: "userId"');
876
915
  }
877
-
878
916
  if (typeof secret === 'undefined') {
879
917
  throw new AppwriteException('Missing required parameter: "secret"');
880
918
  }
881
-
882
919
  const apiPath = '/account/sessions/magic-url';
883
920
  const payload: Payload = {};
884
-
885
921
  if (typeof userId !== 'undefined') {
886
922
  payload['userId'] = userId;
887
923
  }
888
-
889
924
  if (typeof secret !== 'undefined') {
890
925
  payload['secret'] = secret;
891
926
  }
892
-
893
927
  const uri = new URL(this.client.config.endpoint + apiPath);
894
- return await this.client.call('put', uri, {
928
+
929
+ const apiHeaders: { [header: string]: string } = {
895
930
  'content-type': 'application/json',
896
- }, payload);
897
- }
931
+ }
898
932
 
933
+ return await this.client.call(
934
+ 'put',
935
+ uri,
936
+ apiHeaders,
937
+ payload
938
+ );
939
+ }
899
940
  /**
900
941
  * Create OAuth2 session
901
942
  *
902
- * Allow the user to login to their account using the OAuth2 provider of their
903
- * choice. Each OAuth2 provider should be enabled from the Appwrite console
904
- * first. Use the success and failure arguments to provide a redirect URL's
905
- * back to your app when login is completed.
906
- *
907
- * If there is already an active session, the new session will be attached to
908
- * the logged-in account. If there are no active sessions, the server will
909
- * attempt to look for a user with the same email address as the email
910
- * received from the OAuth2 provider and attach the new session to the
911
- * existing user. If no matching user is found - the server will create a new
912
- * user.
913
- *
914
- * A user is limited to 10 active sessions at a time by default. [Learn more
915
- * about session
916
- * limits](https://appwrite.io/docs/authentication-security#limits).
917
- *
943
+ * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL&#039;s back to your app when login is completed.
944
+
945
+ If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.
946
+
947
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
948
+
918
949
  *
919
950
  * @param {OAuthProvider} provider
920
951
  * @param {string} success
921
952
  * @param {string} failure
922
953
  * @param {string[]} scopes
923
954
  * @throws {AppwriteException}
924
- * @returns {void|string}
925
- */
926
- createOAuth2Session(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): void | URL {
955
+ * @returns {Promise<void | string>}
956
+ */
957
+ async createOAuth2Session(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): Promise<void | string> {
927
958
  if (typeof provider === 'undefined') {
928
959
  throw new AppwriteException('Missing required parameter: "provider"');
929
960
  }
930
-
931
961
  const apiPath = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider);
932
962
  const payload: Payload = {};
933
-
934
963
  if (typeof success !== 'undefined') {
935
964
  payload['success'] = success;
936
965
  }
937
-
938
966
  if (typeof failure !== 'undefined') {
939
967
  payload['failure'] = failure;
940
968
  }
941
-
942
969
  if (typeof scopes !== 'undefined') {
943
970
  payload['scopes'] = scopes;
944
971
  }
945
-
946
972
  const uri = new URL(this.client.config.endpoint + apiPath);
947
- payload['project'] = this.client.config.project;
948
-
949
973
 
950
- for (const [key, value] of Object.entries(Service.flatten(payload))) {
951
- uri.searchParams.append(key, value);
974
+ const apiHeaders: { [header: string]: string } = {
975
+ 'content-type': 'application/json',
952
976
  }
953
- if (typeof window !== 'undefined' && window?.location) {
954
- window.location.href = uri.toString();
955
- } else {
956
- return uri;
977
+
978
+ const location = await this.client.redirect(
979
+ 'get',
980
+ uri,
981
+ apiHeaders,
982
+ payload
983
+ );
984
+ if (typeof window !== 'undefined') {
985
+ window.location.href = location;
957
986
  }
987
+ return location.toString();
958
988
  }
959
-
960
989
  /**
961
990
  * Update phone session
962
991
  *
963
- * Use this endpoint to create a session from token. Provide the **userId**
964
- * and **secret** parameters from the successful response of authentication
965
- * flows initiated by token creation. For example, magic URL and phone login.
992
+ * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.
966
993
  *
967
994
  * @param {string} userId
968
995
  * @param {string} secret
969
996
  * @throws {AppwriteException}
970
- * @returns {Promise}
971
- */
997
+ * @returns {Promise<Models.Session>}
998
+ */
972
999
  async updatePhoneSession(userId: string, secret: string): Promise<Models.Session> {
973
1000
  if (typeof userId === 'undefined') {
974
1001
  throw new AppwriteException('Missing required parameter: "userId"');
975
1002
  }
976
-
977
1003
  if (typeof secret === 'undefined') {
978
1004
  throw new AppwriteException('Missing required parameter: "secret"');
979
1005
  }
980
-
981
1006
  const apiPath = '/account/sessions/phone';
982
1007
  const payload: Payload = {};
983
-
984
1008
  if (typeof userId !== 'undefined') {
985
1009
  payload['userId'] = userId;
986
1010
  }
987
-
988
1011
  if (typeof secret !== 'undefined') {
989
1012
  payload['secret'] = secret;
990
1013
  }
991
-
992
1014
  const uri = new URL(this.client.config.endpoint + apiPath);
993
- return await this.client.call('put', uri, {
1015
+
1016
+ const apiHeaders: { [header: string]: string } = {
994
1017
  'content-type': 'application/json',
995
- }, payload);
996
- }
1018
+ }
997
1019
 
1020
+ return await this.client.call(
1021
+ 'put',
1022
+ uri,
1023
+ apiHeaders,
1024
+ payload
1025
+ );
1026
+ }
998
1027
  /**
999
1028
  * Create session
1000
1029
  *
1001
- * Use this endpoint to create a session from token. Provide the **userId**
1002
- * and **secret** parameters from the successful response of authentication
1003
- * flows initiated by token creation. For example, magic URL and phone login.
1030
+ * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.
1004
1031
  *
1005
1032
  * @param {string} userId
1006
1033
  * @param {string} secret
1007
1034
  * @throws {AppwriteException}
1008
- * @returns {Promise}
1009
- */
1035
+ * @returns {Promise<Models.Session>}
1036
+ */
1010
1037
  async createSession(userId: string, secret: string): Promise<Models.Session> {
1011
1038
  if (typeof userId === 'undefined') {
1012
1039
  throw new AppwriteException('Missing required parameter: "userId"');
1013
1040
  }
1014
-
1015
1041
  if (typeof secret === 'undefined') {
1016
1042
  throw new AppwriteException('Missing required parameter: "secret"');
1017
1043
  }
1018
-
1019
1044
  const apiPath = '/account/sessions/token';
1020
1045
  const payload: Payload = {};
1021
-
1022
1046
  if (typeof userId !== 'undefined') {
1023
1047
  payload['userId'] = userId;
1024
1048
  }
1025
-
1026
1049
  if (typeof secret !== 'undefined') {
1027
1050
  payload['secret'] = secret;
1028
1051
  }
1029
-
1030
1052
  const uri = new URL(this.client.config.endpoint + apiPath);
1031
- return await this.client.call('post', uri, {
1053
+
1054
+ const apiHeaders: { [header: string]: string } = {
1032
1055
  'content-type': 'application/json',
1033
- }, payload);
1034
- }
1056
+ }
1035
1057
 
1058
+ return await this.client.call(
1059
+ 'post',
1060
+ uri,
1061
+ apiHeaders,
1062
+ payload
1063
+ );
1064
+ }
1036
1065
  /**
1037
1066
  * Get session
1038
1067
  *
1039
- * Use this endpoint to get a logged in user's session using a Session ID.
1040
- * Inputting 'current' will return the current session being used.
1068
+ * Use this endpoint to get a logged in user&#039;s session using a Session ID. Inputting &#039;current&#039; will return the current session being used.
1041
1069
  *
1042
1070
  * @param {string} sessionId
1043
1071
  * @throws {AppwriteException}
1044
- * @returns {Promise}
1045
- */
1072
+ * @returns {Promise<Models.Session>}
1073
+ */
1046
1074
  async getSession(sessionId: string): Promise<Models.Session> {
1047
1075
  if (typeof sessionId === 'undefined') {
1048
1076
  throw new AppwriteException('Missing required parameter: "sessionId"');
1049
1077
  }
1050
-
1051
1078
  const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1052
1079
  const payload: Payload = {};
1053
-
1054
1080
  const uri = new URL(this.client.config.endpoint + apiPath);
1055
- return await this.client.call('get', uri, {
1081
+
1082
+ const apiHeaders: { [header: string]: string } = {
1056
1083
  'content-type': 'application/json',
1057
- }, payload);
1058
- }
1084
+ }
1059
1085
 
1086
+ return await this.client.call(
1087
+ 'get',
1088
+ uri,
1089
+ apiHeaders,
1090
+ payload
1091
+ );
1092
+ }
1060
1093
  /**
1061
1094
  * Update session
1062
1095
  *
1063
- * Use this endpoint to extend a session's length. Extending a session is
1064
- * useful when session expiry is short. If the session was created using an
1065
- * OAuth provider, this endpoint refreshes the access token from the provider.
1096
+ * Use this endpoint to extend a session&#039;s length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider.
1066
1097
  *
1067
1098
  * @param {string} sessionId
1068
1099
  * @throws {AppwriteException}
1069
- * @returns {Promise}
1070
- */
1100
+ * @returns {Promise<Models.Session>}
1101
+ */
1071
1102
  async updateSession(sessionId: string): Promise<Models.Session> {
1072
1103
  if (typeof sessionId === 'undefined') {
1073
1104
  throw new AppwriteException('Missing required parameter: "sessionId"');
1074
1105
  }
1075
-
1076
1106
  const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1077
1107
  const payload: Payload = {};
1078
-
1079
1108
  const uri = new URL(this.client.config.endpoint + apiPath);
1080
- return await this.client.call('patch', uri, {
1109
+
1110
+ const apiHeaders: { [header: string]: string } = {
1081
1111
  'content-type': 'application/json',
1082
- }, payload);
1083
- }
1112
+ }
1084
1113
 
1114
+ return await this.client.call(
1115
+ 'patch',
1116
+ uri,
1117
+ apiHeaders,
1118
+ payload
1119
+ );
1120
+ }
1085
1121
  /**
1086
1122
  * Delete session
1087
1123
  *
1088
- * Logout the user. Use 'current' as the session ID to logout on this device,
1089
- * use a session ID to logout on another device. If you're looking to logout
1090
- * the user on all devices, use [Delete
1091
- * Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions)
1092
- * instead.
1124
+ * Logout the user. Use &#039;current&#039; as the session ID to logout on this device, use a session ID to logout on another device. If you&#039;re looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead.
1093
1125
  *
1094
1126
  * @param {string} sessionId
1095
1127
  * @throws {AppwriteException}
1096
- * @returns {Promise}
1097
- */
1128
+ * @returns {Promise<{}>}
1129
+ */
1098
1130
  async deleteSession(sessionId: string): Promise<{}> {
1099
1131
  if (typeof sessionId === 'undefined') {
1100
1132
  throw new AppwriteException('Missing required parameter: "sessionId"');
1101
1133
  }
1102
-
1103
1134
  const apiPath = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
1104
1135
  const payload: Payload = {};
1105
-
1106
1136
  const uri = new URL(this.client.config.endpoint + apiPath);
1107
- return await this.client.call('delete', uri, {
1137
+
1138
+ const apiHeaders: { [header: string]: string } = {
1108
1139
  'content-type': 'application/json',
1109
- }, payload);
1110
- }
1140
+ }
1111
1141
 
1142
+ return await this.client.call(
1143
+ 'delete',
1144
+ uri,
1145
+ apiHeaders,
1146
+ payload
1147
+ );
1148
+ }
1112
1149
  /**
1113
1150
  * Update status
1114
1151
  *
1115
- * Block the currently logged in user account. Behind the scene, the user
1116
- * record is not deleted but permanently blocked from any access. To
1117
- * completely delete a user, use the Users API instead.
1152
+ * Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead.
1118
1153
  *
1119
1154
  * @throws {AppwriteException}
1120
- * @returns {Promise}
1121
- */
1155
+ * @returns {Promise<Models.User<Preferences>>}
1156
+ */
1122
1157
  async updateStatus<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> {
1123
1158
  const apiPath = '/account/status';
1124
1159
  const payload: Payload = {};
1125
-
1126
1160
  const uri = new URL(this.client.config.endpoint + apiPath);
1127
- return await this.client.call('patch', uri, {
1161
+
1162
+ const apiHeaders: { [header: string]: string } = {
1128
1163
  'content-type': 'application/json',
1129
- }, payload);
1130
- }
1164
+ }
1131
1165
 
1166
+ return await this.client.call(
1167
+ 'patch',
1168
+ uri,
1169
+ apiHeaders,
1170
+ payload
1171
+ );
1172
+ }
1132
1173
  /**
1133
1174
  * Create push target
1134
1175
  *
@@ -1137,38 +1178,39 @@ export class Account extends Service {
1137
1178
  * @param {string} identifier
1138
1179
  * @param {string} providerId
1139
1180
  * @throws {AppwriteException}
1140
- * @returns {Promise}
1141
- */
1181
+ * @returns {Promise<Models.Target>}
1182
+ */
1142
1183
  async createPushTarget(targetId: string, identifier: string, providerId?: string): Promise<Models.Target> {
1143
1184
  if (typeof targetId === 'undefined') {
1144
1185
  throw new AppwriteException('Missing required parameter: "targetId"');
1145
1186
  }
1146
-
1147
1187
  if (typeof identifier === 'undefined') {
1148
1188
  throw new AppwriteException('Missing required parameter: "identifier"');
1149
1189
  }
1150
-
1151
1190
  const apiPath = '/account/targets/push';
1152
1191
  const payload: Payload = {};
1153
-
1154
1192
  if (typeof targetId !== 'undefined') {
1155
1193
  payload['targetId'] = targetId;
1156
1194
  }
1157
-
1158
1195
  if (typeof identifier !== 'undefined') {
1159
1196
  payload['identifier'] = identifier;
1160
1197
  }
1161
-
1162
1198
  if (typeof providerId !== 'undefined') {
1163
1199
  payload['providerId'] = providerId;
1164
1200
  }
1165
-
1166
1201
  const uri = new URL(this.client.config.endpoint + apiPath);
1167
- return await this.client.call('post', uri, {
1202
+
1203
+ const apiHeaders: { [header: string]: string } = {
1168
1204
  'content-type': 'application/json',
1169
- }, payload);
1170
- }
1205
+ }
1171
1206
 
1207
+ return await this.client.call(
1208
+ 'post',
1209
+ uri,
1210
+ apiHeaders,
1211
+ payload
1212
+ );
1213
+ }
1172
1214
  /**
1173
1215
  * Update push target
1174
1216
  *
@@ -1176,408 +1218,373 @@ export class Account extends Service {
1176
1218
  * @param {string} targetId
1177
1219
  * @param {string} identifier
1178
1220
  * @throws {AppwriteException}
1179
- * @returns {Promise}
1180
- */
1221
+ * @returns {Promise<Models.Target>}
1222
+ */
1181
1223
  async updatePushTarget(targetId: string, identifier: string): Promise<Models.Target> {
1182
1224
  if (typeof targetId === 'undefined') {
1183
1225
  throw new AppwriteException('Missing required parameter: "targetId"');
1184
1226
  }
1185
-
1186
1227
  if (typeof identifier === 'undefined') {
1187
1228
  throw new AppwriteException('Missing required parameter: "identifier"');
1188
1229
  }
1189
-
1190
1230
  const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
1191
1231
  const payload: Payload = {};
1192
-
1193
1232
  if (typeof identifier !== 'undefined') {
1194
1233
  payload['identifier'] = identifier;
1195
1234
  }
1196
-
1197
1235
  const uri = new URL(this.client.config.endpoint + apiPath);
1198
- return await this.client.call('put', uri, {
1236
+
1237
+ const apiHeaders: { [header: string]: string } = {
1199
1238
  'content-type': 'application/json',
1200
- }, payload);
1201
- }
1239
+ }
1202
1240
 
1241
+ return await this.client.call(
1242
+ 'put',
1243
+ uri,
1244
+ apiHeaders,
1245
+ payload
1246
+ );
1247
+ }
1203
1248
  /**
1204
1249
  * Delete push target
1205
1250
  *
1206
1251
  *
1207
1252
  * @param {string} targetId
1208
1253
  * @throws {AppwriteException}
1209
- * @returns {Promise}
1210
- */
1254
+ * @returns {Promise<{}>}
1255
+ */
1211
1256
  async deletePushTarget(targetId: string): Promise<{}> {
1212
1257
  if (typeof targetId === 'undefined') {
1213
1258
  throw new AppwriteException('Missing required parameter: "targetId"');
1214
1259
  }
1215
-
1216
1260
  const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
1217
1261
  const payload: Payload = {};
1218
-
1219
1262
  const uri = new URL(this.client.config.endpoint + apiPath);
1220
- return await this.client.call('delete', uri, {
1263
+
1264
+ const apiHeaders: { [header: string]: string } = {
1221
1265
  'content-type': 'application/json',
1222
- }, payload);
1223
- }
1266
+ }
1224
1267
 
1268
+ return await this.client.call(
1269
+ 'delete',
1270
+ uri,
1271
+ apiHeaders,
1272
+ payload
1273
+ );
1274
+ }
1225
1275
  /**
1226
1276
  * Create email token (OTP)
1227
1277
  *
1228
- * Sends the user an email with a secret key for creating a session. If the
1229
- * provided user ID has not be registered, a new user will be created. Use the
1230
- * returned user ID and secret and submit a request to the [POST
1231
- * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1232
- * endpoint to complete the login process. The secret sent to the user's email
1233
- * is valid for 15 minutes.
1234
- *
1235
- * A user is limited to 10 active sessions at a time by default. [Learn more
1236
- * about session
1237
- * limits](https://appwrite.io/docs/authentication-security#limits).
1278
+ * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user&#039;s email is valid for 15 minutes.
1279
+
1280
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1238
1281
  *
1239
1282
  * @param {string} userId
1240
1283
  * @param {string} email
1241
1284
  * @param {boolean} phrase
1242
1285
  * @throws {AppwriteException}
1243
- * @returns {Promise}
1244
- */
1286
+ * @returns {Promise<Models.Token>}
1287
+ */
1245
1288
  async createEmailToken(userId: string, email: string, phrase?: boolean): Promise<Models.Token> {
1246
1289
  if (typeof userId === 'undefined') {
1247
1290
  throw new AppwriteException('Missing required parameter: "userId"');
1248
1291
  }
1249
-
1250
1292
  if (typeof email === 'undefined') {
1251
1293
  throw new AppwriteException('Missing required parameter: "email"');
1252
1294
  }
1253
-
1254
1295
  const apiPath = '/account/tokens/email';
1255
1296
  const payload: Payload = {};
1256
-
1257
1297
  if (typeof userId !== 'undefined') {
1258
1298
  payload['userId'] = userId;
1259
1299
  }
1260
-
1261
1300
  if (typeof email !== 'undefined') {
1262
1301
  payload['email'] = email;
1263
1302
  }
1264
-
1265
1303
  if (typeof phrase !== 'undefined') {
1266
1304
  payload['phrase'] = phrase;
1267
1305
  }
1268
-
1269
1306
  const uri = new URL(this.client.config.endpoint + apiPath);
1270
- return await this.client.call('post', uri, {
1307
+
1308
+ const apiHeaders: { [header: string]: string } = {
1271
1309
  'content-type': 'application/json',
1272
- }, payload);
1273
- }
1310
+ }
1274
1311
 
1312
+ return await this.client.call(
1313
+ 'post',
1314
+ uri,
1315
+ apiHeaders,
1316
+ payload
1317
+ );
1318
+ }
1275
1319
  /**
1276
1320
  * Create magic URL token
1277
1321
  *
1278
- * Sends the user an email with a secret key for creating a session. If the
1279
- * provided user ID has not been registered, a new user will be created. When
1280
- * the user clicks the link in the email, the user is redirected back to the
1281
- * URL you provided with the secret key and userId values attached to the URL
1282
- * query string. Use the query string parameters to submit a request to the
1283
- * [POST
1284
- * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1285
- * endpoint to complete the login process. The link sent to the user's email
1286
- * address is valid for 1 hour. If you are on a mobile device you can leave
1287
- * the URL parameter empty, so that the login completion will be handled by
1288
- * your Appwrite instance by default.
1289
- *
1290
- * A user is limited to 10 active sessions at a time by default. [Learn more
1291
- * about session
1292
- * limits](https://appwrite.io/docs/authentication-security#limits).
1293
- *
1322
+ * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user&#039;s email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.
1323
+
1324
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1325
+
1294
1326
  *
1295
1327
  * @param {string} userId
1296
1328
  * @param {string} email
1297
1329
  * @param {string} url
1298
1330
  * @param {boolean} phrase
1299
1331
  * @throws {AppwriteException}
1300
- * @returns {Promise}
1301
- */
1332
+ * @returns {Promise<Models.Token>}
1333
+ */
1302
1334
  async createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise<Models.Token> {
1303
1335
  if (typeof userId === 'undefined') {
1304
1336
  throw new AppwriteException('Missing required parameter: "userId"');
1305
1337
  }
1306
-
1307
1338
  if (typeof email === 'undefined') {
1308
1339
  throw new AppwriteException('Missing required parameter: "email"');
1309
1340
  }
1310
-
1311
1341
  const apiPath = '/account/tokens/magic-url';
1312
1342
  const payload: Payload = {};
1313
-
1314
1343
  if (typeof userId !== 'undefined') {
1315
1344
  payload['userId'] = userId;
1316
1345
  }
1317
-
1318
1346
  if (typeof email !== 'undefined') {
1319
1347
  payload['email'] = email;
1320
1348
  }
1321
-
1322
1349
  if (typeof url !== 'undefined') {
1323
1350
  payload['url'] = url;
1324
1351
  }
1325
-
1326
1352
  if (typeof phrase !== 'undefined') {
1327
1353
  payload['phrase'] = phrase;
1328
1354
  }
1329
-
1330
1355
  const uri = new URL(this.client.config.endpoint + apiPath);
1331
- return await this.client.call('post', uri, {
1356
+
1357
+ const apiHeaders: { [header: string]: string } = {
1332
1358
  'content-type': 'application/json',
1333
- }, payload);
1334
- }
1359
+ }
1335
1360
 
1361
+ return await this.client.call(
1362
+ 'post',
1363
+ uri,
1364
+ apiHeaders,
1365
+ payload
1366
+ );
1367
+ }
1336
1368
  /**
1337
1369
  * Create OAuth2 token
1338
1370
  *
1339
- * Allow the user to login to their account using the OAuth2 provider of their
1340
- * choice. Each OAuth2 provider should be enabled from the Appwrite console
1341
- * first. Use the success and failure arguments to provide a redirect URL's
1342
- * back to your app when login is completed.
1343
- *
1344
- * If authentication succeeds, `userId` and `secret` of a token will be
1345
- * appended to the success URL as query parameters. These can be used to
1346
- * create a new session using the [Create
1347
- * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1348
- * endpoint.
1349
- *
1350
- * A user is limited to 10 active sessions at a time by default. [Learn more
1351
- * about session
1352
- * limits](https://appwrite.io/docs/authentication-security#limits).
1371
+ * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL&#039;s back to your app when login is completed.
1372
+
1373
+ If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint.
1374
+
1375
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1353
1376
  *
1354
1377
  * @param {OAuthProvider} provider
1355
1378
  * @param {string} success
1356
1379
  * @param {string} failure
1357
1380
  * @param {string[]} scopes
1358
1381
  * @throws {AppwriteException}
1359
- * @returns {void|string}
1360
- */
1361
- createOAuth2Token(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): void | URL {
1382
+ * @returns {Promise<void | string>}
1383
+ */
1384
+ async createOAuth2Token(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): Promise<void | string> {
1362
1385
  if (typeof provider === 'undefined') {
1363
1386
  throw new AppwriteException('Missing required parameter: "provider"');
1364
1387
  }
1365
-
1366
1388
  const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', provider);
1367
1389
  const payload: Payload = {};
1368
-
1369
1390
  if (typeof success !== 'undefined') {
1370
1391
  payload['success'] = success;
1371
1392
  }
1372
-
1373
1393
  if (typeof failure !== 'undefined') {
1374
1394
  payload['failure'] = failure;
1375
1395
  }
1376
-
1377
1396
  if (typeof scopes !== 'undefined') {
1378
1397
  payload['scopes'] = scopes;
1379
1398
  }
1380
-
1381
1399
  const uri = new URL(this.client.config.endpoint + apiPath);
1382
- payload['project'] = this.client.config.project;
1383
-
1384
1400
 
1385
- for (const [key, value] of Object.entries(Service.flatten(payload))) {
1386
- uri.searchParams.append(key, value);
1401
+ const apiHeaders: { [header: string]: string } = {
1402
+ 'content-type': 'application/json',
1387
1403
  }
1388
- if (typeof window !== 'undefined' && window?.location) {
1389
- window.location.href = uri.toString();
1390
- } else {
1391
- return uri;
1404
+
1405
+ const location = await this.client.redirect(
1406
+ 'get',
1407
+ uri,
1408
+ apiHeaders,
1409
+ payload
1410
+ );
1411
+ if (typeof window !== 'undefined') {
1412
+ window.location.href = location;
1392
1413
  }
1414
+ return location.toString();
1393
1415
  }
1394
-
1395
1416
  /**
1396
1417
  * Create phone token
1397
1418
  *
1398
- * Sends the user an SMS with a secret key for creating a session. If the
1399
- * provided user ID has not be registered, a new user will be created. Use the
1400
- * returned user ID and secret and submit a request to the [POST
1401
- * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
1402
- * endpoint to complete the login process. The secret sent to the user's phone
1403
- * is valid for 15 minutes.
1404
- *
1405
- * A user is limited to 10 active sessions at a time by default. [Learn more
1406
- * about session
1407
- * limits](https://appwrite.io/docs/authentication-security#limits).
1419
+ * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user&#039;s phone is valid for 15 minutes.
1420
+
1421
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1408
1422
  *
1409
1423
  * @param {string} userId
1410
1424
  * @param {string} phone
1411
1425
  * @throws {AppwriteException}
1412
- * @returns {Promise}
1413
- */
1426
+ * @returns {Promise<Models.Token>}
1427
+ */
1414
1428
  async createPhoneToken(userId: string, phone: string): Promise<Models.Token> {
1415
1429
  if (typeof userId === 'undefined') {
1416
1430
  throw new AppwriteException('Missing required parameter: "userId"');
1417
1431
  }
1418
-
1419
1432
  if (typeof phone === 'undefined') {
1420
1433
  throw new AppwriteException('Missing required parameter: "phone"');
1421
1434
  }
1422
-
1423
1435
  const apiPath = '/account/tokens/phone';
1424
1436
  const payload: Payload = {};
1425
-
1426
1437
  if (typeof userId !== 'undefined') {
1427
1438
  payload['userId'] = userId;
1428
1439
  }
1429
-
1430
1440
  if (typeof phone !== 'undefined') {
1431
1441
  payload['phone'] = phone;
1432
1442
  }
1433
-
1434
1443
  const uri = new URL(this.client.config.endpoint + apiPath);
1435
- return await this.client.call('post', uri, {
1444
+
1445
+ const apiHeaders: { [header: string]: string } = {
1436
1446
  'content-type': 'application/json',
1437
- }, payload);
1438
- }
1447
+ }
1439
1448
 
1449
+ return await this.client.call(
1450
+ 'post',
1451
+ uri,
1452
+ apiHeaders,
1453
+ payload
1454
+ );
1455
+ }
1440
1456
  /**
1441
1457
  * Create email verification
1442
1458
  *
1443
- * Use this endpoint to send a verification message to your user email address
1444
- * to confirm they are the valid owners of that address. Both the **userId**
1445
- * and **secret** arguments will be passed as query parameters to the URL you
1446
- * have provided to be attached to the verification email. The provided URL
1447
- * should redirect the user back to your app and allow you to complete the
1448
- * verification process by verifying both the **userId** and **secret**
1449
- * parameters. Learn more about how to [complete the verification
1450
- * process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
1451
- * The verification link sent to the user's email address is valid for 7 days.
1452
- *
1453
- * Please note that in order to avoid a [Redirect
1454
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
1455
- * the only valid redirect URLs are the ones from domains you have set when
1456
- * adding your platforms in the console interface.
1457
- *
1459
+ * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user&#039;s email address is valid for 7 days.
1460
+
1461
+ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
1462
+
1458
1463
  *
1459
1464
  * @param {string} url
1460
1465
  * @throws {AppwriteException}
1461
- * @returns {Promise}
1462
- */
1466
+ * @returns {Promise<Models.Token>}
1467
+ */
1463
1468
  async createVerification(url: string): Promise<Models.Token> {
1464
1469
  if (typeof url === 'undefined') {
1465
1470
  throw new AppwriteException('Missing required parameter: "url"');
1466
1471
  }
1467
-
1468
1472
  const apiPath = '/account/verification';
1469
1473
  const payload: Payload = {};
1470
-
1471
1474
  if (typeof url !== 'undefined') {
1472
1475
  payload['url'] = url;
1473
1476
  }
1474
-
1475
1477
  const uri = new URL(this.client.config.endpoint + apiPath);
1476
- return await this.client.call('post', uri, {
1478
+
1479
+ const apiHeaders: { [header: string]: string } = {
1477
1480
  'content-type': 'application/json',
1478
- }, payload);
1479
- }
1481
+ }
1480
1482
 
1483
+ return await this.client.call(
1484
+ 'post',
1485
+ uri,
1486
+ apiHeaders,
1487
+ payload
1488
+ );
1489
+ }
1481
1490
  /**
1482
1491
  * Create email verification (confirmation)
1483
1492
  *
1484
- * Use this endpoint to complete the user email verification process. Use both
1485
- * the **userId** and **secret** parameters that were attached to your app URL
1486
- * to verify the user email ownership. If confirmed this route will return a
1487
- * 200 status code.
1493
+ * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
1488
1494
  *
1489
1495
  * @param {string} userId
1490
1496
  * @param {string} secret
1491
1497
  * @throws {AppwriteException}
1492
- * @returns {Promise}
1493
- */
1498
+ * @returns {Promise<Models.Token>}
1499
+ */
1494
1500
  async updateVerification(userId: string, secret: string): Promise<Models.Token> {
1495
1501
  if (typeof userId === 'undefined') {
1496
1502
  throw new AppwriteException('Missing required parameter: "userId"');
1497
1503
  }
1498
-
1499
1504
  if (typeof secret === 'undefined') {
1500
1505
  throw new AppwriteException('Missing required parameter: "secret"');
1501
1506
  }
1502
-
1503
1507
  const apiPath = '/account/verification';
1504
1508
  const payload: Payload = {};
1505
-
1506
1509
  if (typeof userId !== 'undefined') {
1507
1510
  payload['userId'] = userId;
1508
1511
  }
1509
-
1510
1512
  if (typeof secret !== 'undefined') {
1511
1513
  payload['secret'] = secret;
1512
1514
  }
1513
-
1514
1515
  const uri = new URL(this.client.config.endpoint + apiPath);
1515
- return await this.client.call('put', uri, {
1516
+
1517
+ const apiHeaders: { [header: string]: string } = {
1516
1518
  'content-type': 'application/json',
1517
- }, payload);
1518
- }
1519
+ }
1519
1520
 
1521
+ return await this.client.call(
1522
+ 'put',
1523
+ uri,
1524
+ apiHeaders,
1525
+ payload
1526
+ );
1527
+ }
1520
1528
  /**
1521
1529
  * Create phone verification
1522
1530
  *
1523
- * Use this endpoint to send a verification SMS to the currently logged in
1524
- * user. This endpoint is meant for use after updating a user's phone number
1525
- * using the
1526
- * [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone)
1527
- * endpoint. Learn more about how to [complete the verification
1528
- * process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification).
1529
- * The verification code sent to the user's phone number is valid for 15
1530
- * minutes.
1531
+ * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user&#039;s phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user&#039;s phone number is valid for 15 minutes.
1531
1532
  *
1532
1533
  * @throws {AppwriteException}
1533
- * @returns {Promise}
1534
- */
1534
+ * @returns {Promise<Models.Token>}
1535
+ */
1535
1536
  async createPhoneVerification(): Promise<Models.Token> {
1536
1537
  const apiPath = '/account/verification/phone';
1537
1538
  const payload: Payload = {};
1538
-
1539
1539
  const uri = new URL(this.client.config.endpoint + apiPath);
1540
- return await this.client.call('post', uri, {
1540
+
1541
+ const apiHeaders: { [header: string]: string } = {
1541
1542
  'content-type': 'application/json',
1542
- }, payload);
1543
- }
1543
+ }
1544
1544
 
1545
+ return await this.client.call(
1546
+ 'post',
1547
+ uri,
1548
+ apiHeaders,
1549
+ payload
1550
+ );
1551
+ }
1545
1552
  /**
1546
1553
  * Update phone verification (confirmation)
1547
1554
  *
1548
- * Use this endpoint to complete the user phone verification process. Use the
1549
- * **userId** and **secret** that were sent to your user's phone number to
1550
- * verify the user email ownership. If confirmed this route will return a 200
1551
- * status code.
1555
+ * Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user&#039;s phone number to verify the user email ownership. If confirmed this route will return a 200 status code.
1552
1556
  *
1553
1557
  * @param {string} userId
1554
1558
  * @param {string} secret
1555
1559
  * @throws {AppwriteException}
1556
- * @returns {Promise}
1557
- */
1560
+ * @returns {Promise<Models.Token>}
1561
+ */
1558
1562
  async updatePhoneVerification(userId: string, secret: string): Promise<Models.Token> {
1559
1563
  if (typeof userId === 'undefined') {
1560
1564
  throw new AppwriteException('Missing required parameter: "userId"');
1561
1565
  }
1562
-
1563
1566
  if (typeof secret === 'undefined') {
1564
1567
  throw new AppwriteException('Missing required parameter: "secret"');
1565
1568
  }
1566
-
1567
1569
  const apiPath = '/account/verification/phone';
1568
1570
  const payload: Payload = {};
1569
-
1570
1571
  if (typeof userId !== 'undefined') {
1571
1572
  payload['userId'] = userId;
1572
1573
  }
1573
-
1574
1574
  if (typeof secret !== 'undefined') {
1575
1575
  payload['secret'] = secret;
1576
1576
  }
1577
-
1578
1577
  const uri = new URL(this.client.config.endpoint + apiPath);
1579
- return await this.client.call('put', uri, {
1578
+
1579
+ const apiHeaders: { [header: string]: string } = {
1580
1580
  'content-type': 'application/json',
1581
- }, payload);
1581
+ }
1582
+
1583
+ return await this.client.call(
1584
+ 'put',
1585
+ uri,
1586
+ apiHeaders,
1587
+ payload
1588
+ );
1582
1589
  }
1583
- };
1590
+ }