node-appwrite 12.0.1 → 12.1.0-rc.4

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 (298) hide show
  1. package/.travis.yml +18 -8
  2. package/README.md +1 -1
  3. package/dist/client.d.mts +131 -0
  4. package/dist/client.d.ts +131 -0
  5. package/dist/client.js +302 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/client.mjs +295 -0
  8. package/dist/client.mjs.map +1 -0
  9. package/dist/enums/authentication-factor.d.mts +8 -0
  10. package/dist/enums/authentication-factor.d.ts +8 -0
  11. package/dist/enums/authentication-factor.js +13 -0
  12. package/dist/enums/authentication-factor.js.map +1 -0
  13. package/dist/enums/authentication-factor.mjs +11 -0
  14. package/dist/enums/authentication-factor.mjs.map +1 -0
  15. package/dist/enums/authenticator-type.d.mts +5 -0
  16. package/dist/enums/authenticator-type.d.ts +5 -0
  17. package/dist/enums/authenticator-type.js +10 -0
  18. package/dist/enums/authenticator-type.js.map +1 -0
  19. package/dist/enums/authenticator-type.mjs +8 -0
  20. package/dist/enums/authenticator-type.mjs.map +1 -0
  21. package/dist/enums/browser.d.mts +18 -0
  22. package/dist/enums/browser.d.ts +18 -0
  23. package/dist/enums/browser.js +23 -0
  24. package/dist/enums/browser.js.map +1 -0
  25. package/dist/enums/browser.mjs +21 -0
  26. package/dist/enums/browser.mjs.map +1 -0
  27. package/dist/enums/compression.d.mts +7 -0
  28. package/dist/enums/compression.d.ts +7 -0
  29. package/dist/enums/compression.js +12 -0
  30. package/dist/enums/compression.js.map +1 -0
  31. package/dist/enums/compression.mjs +10 -0
  32. package/dist/enums/compression.mjs.map +1 -0
  33. package/dist/enums/credit-card.d.mts +20 -0
  34. package/dist/enums/credit-card.d.ts +20 -0
  35. package/dist/enums/credit-card.js +25 -0
  36. package/dist/enums/credit-card.js.map +1 -0
  37. package/dist/enums/credit-card.mjs +23 -0
  38. package/dist/enums/credit-card.mjs.map +1 -0
  39. package/dist/enums/execution-method.d.mts +10 -0
  40. package/dist/enums/execution-method.d.ts +10 -0
  41. package/dist/enums/execution-method.js +15 -0
  42. package/dist/enums/execution-method.js.map +1 -0
  43. package/dist/enums/execution-method.mjs +13 -0
  44. package/dist/enums/execution-method.mjs.map +1 -0
  45. package/dist/enums/flag.d.mts +198 -0
  46. package/dist/enums/flag.d.ts +198 -0
  47. package/dist/enums/flag.js +203 -0
  48. package/dist/enums/flag.js.map +1 -0
  49. package/dist/enums/flag.mjs +201 -0
  50. package/dist/enums/flag.mjs.map +1 -0
  51. package/dist/enums/image-format.d.mts +9 -0
  52. package/dist/enums/image-format.d.ts +9 -0
  53. package/dist/enums/image-format.js +14 -0
  54. package/dist/enums/image-format.js.map +1 -0
  55. package/dist/enums/image-format.mjs +12 -0
  56. package/dist/enums/image-format.mjs.map +1 -0
  57. package/dist/enums/image-gravity.d.mts +13 -0
  58. package/dist/enums/image-gravity.d.ts +13 -0
  59. package/dist/enums/image-gravity.js +18 -0
  60. package/dist/enums/image-gravity.js.map +1 -0
  61. package/dist/enums/image-gravity.mjs +16 -0
  62. package/dist/enums/image-gravity.mjs.map +1 -0
  63. package/dist/enums/index-type.d.mts +7 -0
  64. package/dist/enums/index-type.d.ts +7 -0
  65. package/dist/enums/index-type.js +12 -0
  66. package/dist/enums/index-type.js.map +1 -0
  67. package/dist/enums/index-type.mjs +10 -0
  68. package/dist/enums/index-type.mjs.map +1 -0
  69. package/dist/enums/messaging-provider-type.d.mts +7 -0
  70. package/dist/enums/messaging-provider-type.d.ts +7 -0
  71. package/dist/enums/messaging-provider-type.js +12 -0
  72. package/dist/enums/messaging-provider-type.js.map +1 -0
  73. package/dist/enums/messaging-provider-type.mjs +10 -0
  74. package/dist/enums/messaging-provider-type.mjs.map +1 -0
  75. package/dist/enums/name.d.mts +17 -0
  76. package/dist/enums/name.d.ts +17 -0
  77. package/dist/enums/name.js +22 -0
  78. package/dist/enums/name.js.map +1 -0
  79. package/dist/enums/name.mjs +20 -0
  80. package/dist/enums/name.mjs.map +1 -0
  81. package/dist/enums/o-auth-provider.d.mts +43 -0
  82. package/dist/enums/o-auth-provider.d.ts +43 -0
  83. package/dist/enums/o-auth-provider.js +48 -0
  84. package/dist/enums/o-auth-provider.js.map +1 -0
  85. package/dist/enums/o-auth-provider.mjs +46 -0
  86. package/dist/enums/o-auth-provider.mjs.map +1 -0
  87. package/dist/enums/password-hash.d.mts +15 -0
  88. package/dist/enums/password-hash.d.ts +15 -0
  89. package/dist/enums/password-hash.js +20 -0
  90. package/dist/enums/password-hash.js.map +1 -0
  91. package/dist/enums/password-hash.mjs +18 -0
  92. package/dist/enums/password-hash.mjs.map +1 -0
  93. package/dist/enums/relation-mutate.d.mts +7 -0
  94. package/dist/enums/relation-mutate.d.ts +7 -0
  95. package/dist/enums/relation-mutate.js +12 -0
  96. package/dist/enums/relation-mutate.js.map +1 -0
  97. package/dist/enums/relation-mutate.mjs +10 -0
  98. package/dist/enums/relation-mutate.mjs.map +1 -0
  99. package/dist/enums/relationship-type.d.mts +8 -0
  100. package/dist/enums/relationship-type.d.ts +8 -0
  101. package/dist/enums/relationship-type.js +13 -0
  102. package/dist/enums/relationship-type.js.map +1 -0
  103. package/dist/enums/relationship-type.mjs +11 -0
  104. package/dist/enums/relationship-type.mjs.map +1 -0
  105. package/dist/enums/runtime.d.mts +48 -0
  106. package/dist/enums/runtime.d.ts +48 -0
  107. package/dist/enums/runtime.js +53 -0
  108. package/dist/enums/runtime.js.map +1 -0
  109. package/dist/enums/runtime.mjs +51 -0
  110. package/dist/enums/runtime.mjs.map +1 -0
  111. package/dist/enums/smtp-encryption.d.mts +7 -0
  112. package/dist/enums/smtp-encryption.d.ts +7 -0
  113. package/dist/enums/smtp-encryption.js +12 -0
  114. package/dist/enums/smtp-encryption.js.map +1 -0
  115. package/dist/enums/smtp-encryption.mjs +10 -0
  116. package/dist/enums/smtp-encryption.mjs.map +1 -0
  117. package/dist/id.d.mts +7 -0
  118. package/dist/id.d.ts +7 -0
  119. package/dist/id.js +29 -0
  120. package/dist/id.js.map +1 -0
  121. package/dist/id.mjs +27 -0
  122. package/dist/id.mjs.map +1 -0
  123. package/dist/index.d.mts +35 -0
  124. package/dist/index.d.ts +35 -0
  125. package/dist/index.js +180 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/index.mjs +35 -0
  128. package/dist/index.mjs.map +1 -0
  129. package/dist/inputFile.d.mts +9 -0
  130. package/dist/inputFile.d.ts +9 -0
  131. package/dist/inputFile.js +23 -0
  132. package/dist/inputFile.js.map +1 -0
  133. package/dist/inputFile.mjs +21 -0
  134. package/dist/inputFile.mjs.map +1 -0
  135. package/dist/models.d.mts +2406 -0
  136. package/dist/models.d.ts +2406 -0
  137. package/dist/models.js +4 -0
  138. package/dist/models.js.map +1 -0
  139. package/dist/models.mjs +3 -0
  140. package/dist/models.mjs.map +1 -0
  141. package/dist/permission.d.mts +9 -0
  142. package/dist/permission.d.ts +9 -0
  143. package/dist/permission.js +23 -0
  144. package/dist/permission.js.map +1 -0
  145. package/dist/permission.mjs +21 -0
  146. package/dist/permission.mjs.map +1 -0
  147. package/dist/query.d.mts +35 -0
  148. package/dist/query.d.ts +35 -0
  149. package/dist/query.js +49 -0
  150. package/dist/query.js.map +1 -0
  151. package/dist/query.mjs +47 -0
  152. package/dist/query.mjs.map +1 -0
  153. package/dist/role.d.mts +72 -0
  154. package/dist/role.d.ts +72 -0
  155. package/dist/role.js +96 -0
  156. package/dist/role.js.map +1 -0
  157. package/dist/role.mjs +94 -0
  158. package/dist/role.mjs.map +1 -0
  159. package/dist/services/account.d.mts +478 -0
  160. package/dist/services/account.d.ts +478 -0
  161. package/dist/services/account.js +1331 -0
  162. package/dist/services/account.js.map +1 -0
  163. package/dist/services/account.mjs +1329 -0
  164. package/dist/services/account.mjs.map +1 -0
  165. package/dist/services/avatars.d.mts +118 -0
  166. package/dist/services/avatars.d.ts +118 -0
  167. package/dist/services/avatars.js +297 -0
  168. package/dist/services/avatars.js.map +1 -0
  169. package/dist/services/avatars.mjs +295 -0
  170. package/dist/services/avatars.mjs.map +1 -0
  171. package/dist/services/databases.d.mts +606 -0
  172. package/dist/services/databases.d.ts +606 -0
  173. package/dist/services/databases.js +1908 -0
  174. package/dist/services/databases.js.map +1 -0
  175. package/dist/services/databases.mjs +1906 -0
  176. package/dist/services/databases.mjs.map +1 -0
  177. package/dist/services/functions.d.mts +287 -0
  178. package/dist/services/functions.d.ts +287 -0
  179. package/dist/services/functions.js +837 -0
  180. package/dist/services/functions.js.map +1 -0
  181. package/dist/services/functions.mjs +835 -0
  182. package/dist/services/functions.mjs.map +1 -0
  183. package/dist/services/graphql.d.mts +30 -0
  184. package/dist/services/graphql.d.ts +30 -0
  185. package/dist/services/graphql.js +73 -0
  186. package/dist/services/graphql.js.map +1 -0
  187. package/dist/services/graphql.mjs +71 -0
  188. package/dist/services/graphql.mjs.map +1 -0
  189. package/dist/services/health.d.mts +235 -0
  190. package/dist/services/health.d.ts +235 -0
  191. package/dist/services/health.js +584 -0
  192. package/dist/services/health.js.map +1 -0
  193. package/dist/services/health.mjs +582 -0
  194. package/dist/services/health.mjs.map +1 -0
  195. package/dist/services/locale.d.mts +84 -0
  196. package/dist/services/locale.d.ts +84 -0
  197. package/dist/services/locale.js +189 -0
  198. package/dist/services/locale.js.map +1 -0
  199. package/dist/services/locale.mjs +187 -0
  200. package/dist/services/locale.mjs.map +1 -0
  201. package/dist/services/messaging.d.mts +688 -0
  202. package/dist/services/messaging.d.ts +688 -0
  203. package/dist/services/messaging.js +2152 -0
  204. package/dist/services/messaging.js.map +1 -0
  205. package/dist/services/messaging.mjs +2150 -0
  206. package/dist/services/messaging.mjs.map +1 -0
  207. package/dist/services/storage.d.mts +193 -0
  208. package/dist/services/storage.d.ts +193 -0
  209. package/dist/services/storage.js +550 -0
  210. package/dist/services/storage.js.map +1 -0
  211. package/dist/services/storage.mjs +548 -0
  212. package/dist/services/storage.mjs.map +1 -0
  213. package/dist/services/teams.d.mts +171 -0
  214. package/dist/services/teams.d.ts +171 -0
  215. package/dist/services/teams.js +466 -0
  216. package/dist/services/teams.js.map +1 -0
  217. package/dist/services/teams.mjs +464 -0
  218. package/dist/services/teams.mjs.map +1 -0
  219. package/dist/services/users.d.mts +490 -0
  220. package/dist/services/users.d.ts +490 -0
  221. package/dist/services/users.js +1464 -0
  222. package/dist/services/users.js.map +1 -0
  223. package/dist/services/users.mjs +1462 -0
  224. package/dist/services/users.mjs.map +1 -0
  225. package/docs/examples/functions/create-deployment.md +1 -1
  226. package/docs/examples/messaging/create-msg91provider.md +1 -1
  227. package/docs/examples/messaging/update-msg91provider.md +2 -2
  228. package/docs/examples/storage/create-file.md +1 -1
  229. package/package.json +35 -5
  230. package/src/client.ts +366 -0
  231. package/src/enums/authentication-factor.ts +6 -0
  232. package/src/enums/authenticator-type.ts +3 -0
  233. package/src/enums/browser.ts +16 -0
  234. package/src/enums/compression.ts +5 -0
  235. package/src/enums/credit-card.ts +18 -0
  236. package/src/enums/execution-method.ts +8 -0
  237. package/src/enums/flag.ts +196 -0
  238. package/src/enums/image-format.ts +7 -0
  239. package/src/enums/image-gravity.ts +11 -0
  240. package/src/enums/index-type.ts +5 -0
  241. package/src/enums/messaging-provider-type.ts +5 -0
  242. package/src/enums/name.ts +15 -0
  243. package/src/enums/o-auth-provider.ts +41 -0
  244. package/src/enums/password-hash.ts +13 -0
  245. package/src/enums/relation-mutate.ts +5 -0
  246. package/src/enums/relationship-type.ts +6 -0
  247. package/src/enums/runtime.ts +46 -0
  248. package/src/enums/smtp-encryption.ts +5 -0
  249. package/{lib/id.js → src/id.ts} +8 -12
  250. package/src/index.ts +35 -0
  251. package/src/inputFile.ts +23 -0
  252. package/src/models.ts +2404 -0
  253. package/src/permission.ts +22 -0
  254. package/src/query.ts +101 -0
  255. package/{lib/role.js → src/role.ts} +23 -25
  256. package/src/services/account.ts +1418 -0
  257. package/src/services/avatars.ts +312 -0
  258. package/{lib/services/databases.js → src/services/databases.ts} +644 -638
  259. package/{lib/services/functions.js → src/services/functions.ts} +317 -369
  260. package/{lib/services/graphql.js → src/services/graphql.ts} +35 -34
  261. package/src/services/health.ts +629 -0
  262. package/src/services/locale.ts +205 -0
  263. package/{lib/services/messaging.js → src/services/messaging.ts} +666 -641
  264. package/{lib/services/storage.js → src/services/storage.ts} +211 -298
  265. package/{lib/services/teams.js → src/services/teams.ts} +211 -200
  266. package/{lib/services/users.js → src/services/users.ts} +603 -519
  267. package/tsconfig.json +18 -0
  268. package/tsup.config.js +19 -0
  269. package/index.d.ts +0 -6656
  270. package/index.js +0 -75
  271. package/lib/client.js +0 -245
  272. package/lib/enums/authentication-factor.js +0 -8
  273. package/lib/enums/authenticator-type.js +0 -5
  274. package/lib/enums/browser.js +0 -18
  275. package/lib/enums/compression.js +0 -7
  276. package/lib/enums/credit-card.js +0 -20
  277. package/lib/enums/execution-method.js +0 -10
  278. package/lib/enums/flag.js +0 -198
  279. package/lib/enums/image-format.js +0 -9
  280. package/lib/enums/image-gravity.js +0 -13
  281. package/lib/enums/index-type.js +0 -7
  282. package/lib/enums/messaging-provider-type.js +0 -7
  283. package/lib/enums/name.js +0 -17
  284. package/lib/enums/o-auth-provider.js +0 -43
  285. package/lib/enums/password-hash.js +0 -15
  286. package/lib/enums/relation-mutate.js +0 -7
  287. package/lib/enums/relationship-type.js +0 -8
  288. package/lib/enums/runtime.js +0 -48
  289. package/lib/enums/smtp-encryption.js +0 -7
  290. package/lib/exception.js +0 -10
  291. package/lib/inputFile.js +0 -117
  292. package/lib/permission.js +0 -24
  293. package/lib/query.js +0 -90
  294. package/lib/service.js +0 -10
  295. package/lib/services/account.js +0 -1365
  296. package/lib/services/avatars.js +0 -325
  297. package/lib/services/health.js +0 -513
  298. package/lib/services/locale.js +0 -169
@@ -0,0 +1,1329 @@
1
+ import { AppwriteException } from '../client';
2
+
3
+ class Account {
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ /**
8
+ * Get account
9
+ *
10
+ * Get the currently logged in user.
11
+ *
12
+ * @throws {AppwriteException}
13
+ * @returns {Promise<Models.User<Preferences>>}
14
+ */
15
+ async get() {
16
+ const apiPath = "/account";
17
+ const payload = {};
18
+ const uri = new URL(this.client.config.endpoint + apiPath);
19
+ const apiHeaders = {
20
+ "content-type": "application/json"
21
+ };
22
+ return await this.client.call(
23
+ "get",
24
+ uri,
25
+ apiHeaders,
26
+ payload
27
+ );
28
+ }
29
+ /**
30
+ * Create account
31
+ *
32
+ * 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).
33
+ *
34
+ * @param {string} userId
35
+ * @param {string} email
36
+ * @param {string} password
37
+ * @param {string} name
38
+ * @throws {AppwriteException}
39
+ * @returns {Promise<Models.User<Preferences>>}
40
+ */
41
+ async create(userId, email, password, name) {
42
+ if (typeof userId === "undefined") {
43
+ throw new AppwriteException('Missing required parameter: "userId"');
44
+ }
45
+ if (typeof email === "undefined") {
46
+ throw new AppwriteException('Missing required parameter: "email"');
47
+ }
48
+ if (typeof password === "undefined") {
49
+ throw new AppwriteException('Missing required parameter: "password"');
50
+ }
51
+ const apiPath = "/account";
52
+ const payload = {};
53
+ if (typeof userId !== "undefined") {
54
+ payload["userId"] = userId;
55
+ }
56
+ if (typeof email !== "undefined") {
57
+ payload["email"] = email;
58
+ }
59
+ if (typeof password !== "undefined") {
60
+ payload["password"] = password;
61
+ }
62
+ if (typeof name !== "undefined") {
63
+ payload["name"] = name;
64
+ }
65
+ const uri = new URL(this.client.config.endpoint + apiPath);
66
+ const apiHeaders = {
67
+ "content-type": "application/json"
68
+ };
69
+ return await this.client.call(
70
+ "post",
71
+ uri,
72
+ apiHeaders,
73
+ payload
74
+ );
75
+ }
76
+ /**
77
+ * Update email
78
+ *
79
+ * 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.
80
+ This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.
81
+
82
+ *
83
+ * @param {string} email
84
+ * @param {string} password
85
+ * @throws {AppwriteException}
86
+ * @returns {Promise<Models.User<Preferences>>}
87
+ */
88
+ async updateEmail(email, password) {
89
+ if (typeof email === "undefined") {
90
+ throw new AppwriteException('Missing required parameter: "email"');
91
+ }
92
+ if (typeof password === "undefined") {
93
+ throw new AppwriteException('Missing required parameter: "password"');
94
+ }
95
+ const apiPath = "/account/email";
96
+ const payload = {};
97
+ if (typeof email !== "undefined") {
98
+ payload["email"] = email;
99
+ }
100
+ if (typeof password !== "undefined") {
101
+ payload["password"] = password;
102
+ }
103
+ const uri = new URL(this.client.config.endpoint + apiPath);
104
+ const apiHeaders = {
105
+ "content-type": "application/json"
106
+ };
107
+ return await this.client.call(
108
+ "patch",
109
+ uri,
110
+ apiHeaders,
111
+ payload
112
+ );
113
+ }
114
+ /**
115
+ * List Identities
116
+ *
117
+ * Get the list of identities for the currently logged in user.
118
+ *
119
+ * @param {string[]} queries
120
+ * @throws {AppwriteException}
121
+ * @returns {Promise<Models.IdentityList>}
122
+ */
123
+ async listIdentities(queries) {
124
+ const apiPath = "/account/identities";
125
+ const payload = {};
126
+ if (typeof queries !== "undefined") {
127
+ payload["queries"] = queries;
128
+ }
129
+ const uri = new URL(this.client.config.endpoint + apiPath);
130
+ const apiHeaders = {
131
+ "content-type": "application/json"
132
+ };
133
+ return await this.client.call(
134
+ "get",
135
+ uri,
136
+ apiHeaders,
137
+ payload
138
+ );
139
+ }
140
+ /**
141
+ * Delete identity
142
+ *
143
+ * Delete an identity by its unique ID.
144
+ *
145
+ * @param {string} identityId
146
+ * @throws {AppwriteException}
147
+ * @returns {Promise<{}>}
148
+ */
149
+ async deleteIdentity(identityId) {
150
+ if (typeof identityId === "undefined") {
151
+ throw new AppwriteException('Missing required parameter: "identityId"');
152
+ }
153
+ const apiPath = "/account/identities/{identityId}".replace("{identityId}", identityId);
154
+ const payload = {};
155
+ const uri = new URL(this.client.config.endpoint + apiPath);
156
+ const apiHeaders = {
157
+ "content-type": "application/json"
158
+ };
159
+ return await this.client.call(
160
+ "delete",
161
+ uri,
162
+ apiHeaders,
163
+ payload
164
+ );
165
+ }
166
+ /**
167
+ * Create JWT
168
+ *
169
+ * 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.
170
+ *
171
+ * @throws {AppwriteException}
172
+ * @returns {Promise<Models.Jwt>}
173
+ */
174
+ async createJWT() {
175
+ const apiPath = "/account/jwt";
176
+ const payload = {};
177
+ const uri = new URL(this.client.config.endpoint + apiPath);
178
+ const apiHeaders = {
179
+ "content-type": "application/json"
180
+ };
181
+ return await this.client.call(
182
+ "post",
183
+ uri,
184
+ apiHeaders,
185
+ payload
186
+ );
187
+ }
188
+ /**
189
+ * List logs
190
+ *
191
+ * 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.
192
+ *
193
+ * @param {string[]} queries
194
+ * @throws {AppwriteException}
195
+ * @returns {Promise<Models.LogList>}
196
+ */
197
+ async listLogs(queries) {
198
+ const apiPath = "/account/logs";
199
+ const payload = {};
200
+ if (typeof queries !== "undefined") {
201
+ payload["queries"] = queries;
202
+ }
203
+ const uri = new URL(this.client.config.endpoint + apiPath);
204
+ const apiHeaders = {
205
+ "content-type": "application/json"
206
+ };
207
+ return await this.client.call(
208
+ "get",
209
+ uri,
210
+ apiHeaders,
211
+ payload
212
+ );
213
+ }
214
+ /**
215
+ * Update MFA
216
+ *
217
+ * Enable or disable MFA on an account.
218
+ *
219
+ * @param {boolean} mfa
220
+ * @throws {AppwriteException}
221
+ * @returns {Promise<Models.User<Preferences>>}
222
+ */
223
+ async updateMFA(mfa) {
224
+ if (typeof mfa === "undefined") {
225
+ throw new AppwriteException('Missing required parameter: "mfa"');
226
+ }
227
+ const apiPath = "/account/mfa";
228
+ const payload = {};
229
+ if (typeof mfa !== "undefined") {
230
+ payload["mfa"] = mfa;
231
+ }
232
+ const uri = new URL(this.client.config.endpoint + apiPath);
233
+ const apiHeaders = {
234
+ "content-type": "application/json"
235
+ };
236
+ return await this.client.call(
237
+ "patch",
238
+ uri,
239
+ apiHeaders,
240
+ payload
241
+ );
242
+ }
243
+ /**
244
+ * Add Authenticator
245
+ *
246
+ * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method.
247
+ *
248
+ * @param {AuthenticatorType} type
249
+ * @throws {AppwriteException}
250
+ * @returns {Promise<Models.MfaType>}
251
+ */
252
+ async createMfaAuthenticator(type) {
253
+ if (typeof type === "undefined") {
254
+ throw new AppwriteException('Missing required parameter: "type"');
255
+ }
256
+ const apiPath = "/account/mfa/authenticators/{type}".replace("{type}", type);
257
+ const payload = {};
258
+ const uri = new URL(this.client.config.endpoint + apiPath);
259
+ const apiHeaders = {
260
+ "content-type": "application/json"
261
+ };
262
+ return await this.client.call(
263
+ "post",
264
+ uri,
265
+ apiHeaders,
266
+ payload
267
+ );
268
+ }
269
+ /**
270
+ * Verify Authenticator
271
+ *
272
+ * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method.
273
+ *
274
+ * @param {AuthenticatorType} type
275
+ * @param {string} otp
276
+ * @throws {AppwriteException}
277
+ * @returns {Promise<Models.User<Preferences>>}
278
+ */
279
+ async updateMfaAuthenticator(type, otp) {
280
+ if (typeof type === "undefined") {
281
+ throw new AppwriteException('Missing required parameter: "type"');
282
+ }
283
+ if (typeof otp === "undefined") {
284
+ throw new AppwriteException('Missing required parameter: "otp"');
285
+ }
286
+ const apiPath = "/account/mfa/authenticators/{type}".replace("{type}", type);
287
+ const payload = {};
288
+ if (typeof otp !== "undefined") {
289
+ payload["otp"] = otp;
290
+ }
291
+ const uri = new URL(this.client.config.endpoint + apiPath);
292
+ const apiHeaders = {
293
+ "content-type": "application/json"
294
+ };
295
+ return await this.client.call(
296
+ "put",
297
+ uri,
298
+ apiHeaders,
299
+ payload
300
+ );
301
+ }
302
+ /**
303
+ * Delete Authenticator
304
+ *
305
+ * Delete an authenticator for a user by ID.
306
+ *
307
+ * @param {AuthenticatorType} type
308
+ * @param {string} otp
309
+ * @throws {AppwriteException}
310
+ * @returns {Promise<Models.User<Preferences>>}
311
+ */
312
+ async deleteMfaAuthenticator(type, otp) {
313
+ if (typeof type === "undefined") {
314
+ throw new AppwriteException('Missing required parameter: "type"');
315
+ }
316
+ if (typeof otp === "undefined") {
317
+ throw new AppwriteException('Missing required parameter: "otp"');
318
+ }
319
+ const apiPath = "/account/mfa/authenticators/{type}".replace("{type}", type);
320
+ const payload = {};
321
+ if (typeof otp !== "undefined") {
322
+ payload["otp"] = otp;
323
+ }
324
+ const uri = new URL(this.client.config.endpoint + apiPath);
325
+ const apiHeaders = {
326
+ "content-type": "application/json"
327
+ };
328
+ return await this.client.call(
329
+ "delete",
330
+ uri,
331
+ apiHeaders,
332
+ payload
333
+ );
334
+ }
335
+ /**
336
+ * Create 2FA Challenge
337
+ *
338
+ * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method.
339
+ *
340
+ * @param {AuthenticationFactor} factor
341
+ * @throws {AppwriteException}
342
+ * @returns {Promise<Models.MfaChallenge>}
343
+ */
344
+ async createMfaChallenge(factor) {
345
+ if (typeof factor === "undefined") {
346
+ throw new AppwriteException('Missing required parameter: "factor"');
347
+ }
348
+ const apiPath = "/account/mfa/challenge";
349
+ const payload = {};
350
+ if (typeof factor !== "undefined") {
351
+ payload["factor"] = factor;
352
+ }
353
+ const uri = new URL(this.client.config.endpoint + apiPath);
354
+ const apiHeaders = {
355
+ "content-type": "application/json"
356
+ };
357
+ return await this.client.call(
358
+ "post",
359
+ uri,
360
+ apiHeaders,
361
+ payload
362
+ );
363
+ }
364
+ /**
365
+ * Create MFA Challenge (confirmation)
366
+ *
367
+ * 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.
368
+ *
369
+ * @param {string} challengeId
370
+ * @param {string} otp
371
+ * @throws {AppwriteException}
372
+ * @returns {Promise<{}>}
373
+ */
374
+ async updateMfaChallenge(challengeId, otp) {
375
+ if (typeof challengeId === "undefined") {
376
+ throw new AppwriteException('Missing required parameter: "challengeId"');
377
+ }
378
+ if (typeof otp === "undefined") {
379
+ throw new AppwriteException('Missing required parameter: "otp"');
380
+ }
381
+ const apiPath = "/account/mfa/challenge";
382
+ const payload = {};
383
+ if (typeof challengeId !== "undefined") {
384
+ payload["challengeId"] = challengeId;
385
+ }
386
+ if (typeof otp !== "undefined") {
387
+ payload["otp"] = otp;
388
+ }
389
+ const uri = new URL(this.client.config.endpoint + apiPath);
390
+ const apiHeaders = {
391
+ "content-type": "application/json"
392
+ };
393
+ return await this.client.call(
394
+ "put",
395
+ uri,
396
+ apiHeaders,
397
+ payload
398
+ );
399
+ }
400
+ /**
401
+ * List Factors
402
+ *
403
+ * List the factors available on the account to be used as a MFA challange.
404
+ *
405
+ * @throws {AppwriteException}
406
+ * @returns {Promise<Models.MfaFactors>}
407
+ */
408
+ async listMfaFactors() {
409
+ const apiPath = "/account/mfa/factors";
410
+ const payload = {};
411
+ const uri = new URL(this.client.config.endpoint + apiPath);
412
+ const apiHeaders = {
413
+ "content-type": "application/json"
414
+ };
415
+ return await this.client.call(
416
+ "get",
417
+ uri,
418
+ apiHeaders,
419
+ payload
420
+ );
421
+ }
422
+ /**
423
+ * Get MFA Recovery Codes
424
+ *
425
+ * 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.
426
+ *
427
+ * @throws {AppwriteException}
428
+ * @returns {Promise<Models.MfaRecoveryCodes>}
429
+ */
430
+ async getMfaRecoveryCodes() {
431
+ const apiPath = "/account/mfa/recovery-codes";
432
+ const payload = {};
433
+ const uri = new URL(this.client.config.endpoint + apiPath);
434
+ const apiHeaders = {
435
+ "content-type": "application/json"
436
+ };
437
+ return await this.client.call(
438
+ "get",
439
+ uri,
440
+ apiHeaders,
441
+ payload
442
+ );
443
+ }
444
+ /**
445
+ * Create MFA Recovery Codes
446
+ *
447
+ * 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.
448
+ *
449
+ * @throws {AppwriteException}
450
+ * @returns {Promise<Models.MfaRecoveryCodes>}
451
+ */
452
+ async createMfaRecoveryCodes() {
453
+ const apiPath = "/account/mfa/recovery-codes";
454
+ const payload = {};
455
+ const uri = new URL(this.client.config.endpoint + apiPath);
456
+ const apiHeaders = {
457
+ "content-type": "application/json"
458
+ };
459
+ return await this.client.call(
460
+ "post",
461
+ uri,
462
+ apiHeaders,
463
+ payload
464
+ );
465
+ }
466
+ /**
467
+ * Regenerate MFA Recovery Codes
468
+ *
469
+ * 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.
470
+ *
471
+ * @throws {AppwriteException}
472
+ * @returns {Promise<Models.MfaRecoveryCodes>}
473
+ */
474
+ async updateMfaRecoveryCodes() {
475
+ const apiPath = "/account/mfa/recovery-codes";
476
+ const payload = {};
477
+ const uri = new URL(this.client.config.endpoint + apiPath);
478
+ const apiHeaders = {
479
+ "content-type": "application/json"
480
+ };
481
+ return await this.client.call(
482
+ "patch",
483
+ uri,
484
+ apiHeaders,
485
+ payload
486
+ );
487
+ }
488
+ /**
489
+ * Update name
490
+ *
491
+ * Update currently logged in user account name.
492
+ *
493
+ * @param {string} name
494
+ * @throws {AppwriteException}
495
+ * @returns {Promise<Models.User<Preferences>>}
496
+ */
497
+ async updateName(name) {
498
+ if (typeof name === "undefined") {
499
+ throw new AppwriteException('Missing required parameter: "name"');
500
+ }
501
+ const apiPath = "/account/name";
502
+ const payload = {};
503
+ if (typeof name !== "undefined") {
504
+ payload["name"] = name;
505
+ }
506
+ const uri = new URL(this.client.config.endpoint + apiPath);
507
+ const apiHeaders = {
508
+ "content-type": "application/json"
509
+ };
510
+ return await this.client.call(
511
+ "patch",
512
+ uri,
513
+ apiHeaders,
514
+ payload
515
+ );
516
+ }
517
+ /**
518
+ * Update password
519
+ *
520
+ * 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.
521
+ *
522
+ * @param {string} password
523
+ * @param {string} oldPassword
524
+ * @throws {AppwriteException}
525
+ * @returns {Promise<Models.User<Preferences>>}
526
+ */
527
+ async updatePassword(password, oldPassword) {
528
+ if (typeof password === "undefined") {
529
+ throw new AppwriteException('Missing required parameter: "password"');
530
+ }
531
+ const apiPath = "/account/password";
532
+ const payload = {};
533
+ if (typeof password !== "undefined") {
534
+ payload["password"] = password;
535
+ }
536
+ if (typeof oldPassword !== "undefined") {
537
+ payload["oldPassword"] = oldPassword;
538
+ }
539
+ const uri = new URL(this.client.config.endpoint + apiPath);
540
+ const apiHeaders = {
541
+ "content-type": "application/json"
542
+ };
543
+ return await this.client.call(
544
+ "patch",
545
+ uri,
546
+ apiHeaders,
547
+ payload
548
+ );
549
+ }
550
+ /**
551
+ * Update phone
552
+ *
553
+ * 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.
554
+ *
555
+ * @param {string} phone
556
+ * @param {string} password
557
+ * @throws {AppwriteException}
558
+ * @returns {Promise<Models.User<Preferences>>}
559
+ */
560
+ async updatePhone(phone, password) {
561
+ if (typeof phone === "undefined") {
562
+ throw new AppwriteException('Missing required parameter: "phone"');
563
+ }
564
+ if (typeof password === "undefined") {
565
+ throw new AppwriteException('Missing required parameter: "password"');
566
+ }
567
+ const apiPath = "/account/phone";
568
+ const payload = {};
569
+ if (typeof phone !== "undefined") {
570
+ payload["phone"] = phone;
571
+ }
572
+ if (typeof password !== "undefined") {
573
+ payload["password"] = password;
574
+ }
575
+ const uri = new URL(this.client.config.endpoint + apiPath);
576
+ const apiHeaders = {
577
+ "content-type": "application/json"
578
+ };
579
+ return await this.client.call(
580
+ "patch",
581
+ uri,
582
+ apiHeaders,
583
+ payload
584
+ );
585
+ }
586
+ /**
587
+ * Get account preferences
588
+ *
589
+ * Get the preferences as a key-value object for the currently logged in user.
590
+ *
591
+ * @throws {AppwriteException}
592
+ * @returns {Promise<Preferences>}
593
+ */
594
+ async getPrefs() {
595
+ const apiPath = "/account/prefs";
596
+ const payload = {};
597
+ const uri = new URL(this.client.config.endpoint + apiPath);
598
+ const apiHeaders = {
599
+ "content-type": "application/json"
600
+ };
601
+ return await this.client.call(
602
+ "get",
603
+ uri,
604
+ apiHeaders,
605
+ payload
606
+ );
607
+ }
608
+ /**
609
+ * Update preferences
610
+ *
611
+ * 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.
612
+ *
613
+ * @param {Partial<Preferences>} prefs
614
+ * @throws {AppwriteException}
615
+ * @returns {Promise<Models.User<Preferences>>}
616
+ */
617
+ async updatePrefs(prefs) {
618
+ if (typeof prefs === "undefined") {
619
+ throw new AppwriteException('Missing required parameter: "prefs"');
620
+ }
621
+ const apiPath = "/account/prefs";
622
+ const payload = {};
623
+ if (typeof prefs !== "undefined") {
624
+ payload["prefs"] = prefs;
625
+ }
626
+ const uri = new URL(this.client.config.endpoint + apiPath);
627
+ const apiHeaders = {
628
+ "content-type": "application/json"
629
+ };
630
+ return await this.client.call(
631
+ "patch",
632
+ uri,
633
+ apiHeaders,
634
+ payload
635
+ );
636
+ }
637
+ /**
638
+ * Create password recovery
639
+ *
640
+ * 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.
641
+ *
642
+ * @param {string} email
643
+ * @param {string} url
644
+ * @throws {AppwriteException}
645
+ * @returns {Promise<Models.Token>}
646
+ */
647
+ async createRecovery(email, url) {
648
+ if (typeof email === "undefined") {
649
+ throw new AppwriteException('Missing required parameter: "email"');
650
+ }
651
+ if (typeof url === "undefined") {
652
+ throw new AppwriteException('Missing required parameter: "url"');
653
+ }
654
+ const apiPath = "/account/recovery";
655
+ const payload = {};
656
+ if (typeof email !== "undefined") {
657
+ payload["email"] = email;
658
+ }
659
+ if (typeof url !== "undefined") {
660
+ payload["url"] = url;
661
+ }
662
+ const uri = new URL(this.client.config.endpoint + apiPath);
663
+ const apiHeaders = {
664
+ "content-type": "application/json"
665
+ };
666
+ return await this.client.call(
667
+ "post",
668
+ uri,
669
+ apiHeaders,
670
+ payload
671
+ );
672
+ }
673
+ /**
674
+ * Create password recovery (confirmation)
675
+ *
676
+ * 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.
677
+
678
+ 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.
679
+ *
680
+ * @param {string} userId
681
+ * @param {string} secret
682
+ * @param {string} password
683
+ * @throws {AppwriteException}
684
+ * @returns {Promise<Models.Token>}
685
+ */
686
+ async updateRecovery(userId, secret, password) {
687
+ if (typeof userId === "undefined") {
688
+ throw new AppwriteException('Missing required parameter: "userId"');
689
+ }
690
+ if (typeof secret === "undefined") {
691
+ throw new AppwriteException('Missing required parameter: "secret"');
692
+ }
693
+ if (typeof password === "undefined") {
694
+ throw new AppwriteException('Missing required parameter: "password"');
695
+ }
696
+ const apiPath = "/account/recovery";
697
+ const payload = {};
698
+ if (typeof userId !== "undefined") {
699
+ payload["userId"] = userId;
700
+ }
701
+ if (typeof secret !== "undefined") {
702
+ payload["secret"] = secret;
703
+ }
704
+ if (typeof password !== "undefined") {
705
+ payload["password"] = password;
706
+ }
707
+ const uri = new URL(this.client.config.endpoint + apiPath);
708
+ const apiHeaders = {
709
+ "content-type": "application/json"
710
+ };
711
+ return await this.client.call(
712
+ "put",
713
+ uri,
714
+ apiHeaders,
715
+ payload
716
+ );
717
+ }
718
+ /**
719
+ * List sessions
720
+ *
721
+ * Get the list of active sessions across different devices for the currently logged in user.
722
+ *
723
+ * @throws {AppwriteException}
724
+ * @returns {Promise<Models.SessionList>}
725
+ */
726
+ async listSessions() {
727
+ const apiPath = "/account/sessions";
728
+ const payload = {};
729
+ const uri = new URL(this.client.config.endpoint + apiPath);
730
+ const apiHeaders = {
731
+ "content-type": "application/json"
732
+ };
733
+ return await this.client.call(
734
+ "get",
735
+ uri,
736
+ apiHeaders,
737
+ payload
738
+ );
739
+ }
740
+ /**
741
+ * Delete sessions
742
+ *
743
+ * Delete all sessions from the user account and remove any sessions cookies from the end client.
744
+ *
745
+ * @throws {AppwriteException}
746
+ * @returns {Promise<{}>}
747
+ */
748
+ async deleteSessions() {
749
+ const apiPath = "/account/sessions";
750
+ const payload = {};
751
+ const uri = new URL(this.client.config.endpoint + apiPath);
752
+ const apiHeaders = {
753
+ "content-type": "application/json"
754
+ };
755
+ return await this.client.call(
756
+ "delete",
757
+ uri,
758
+ apiHeaders,
759
+ payload
760
+ );
761
+ }
762
+ /**
763
+ * Create anonymous session
764
+ *
765
+ * 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).
766
+ *
767
+ * @throws {AppwriteException}
768
+ * @returns {Promise<Models.Session>}
769
+ */
770
+ async createAnonymousSession() {
771
+ const apiPath = "/account/sessions/anonymous";
772
+ const payload = {};
773
+ const uri = new URL(this.client.config.endpoint + apiPath);
774
+ const apiHeaders = {
775
+ "content-type": "application/json"
776
+ };
777
+ return await this.client.call(
778
+ "post",
779
+ uri,
780
+ apiHeaders,
781
+ payload
782
+ );
783
+ }
784
+ /**
785
+ * Create email password session
786
+ *
787
+ * 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.
788
+
789
+ 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).
790
+ *
791
+ * @param {string} email
792
+ * @param {string} password
793
+ * @throws {AppwriteException}
794
+ * @returns {Promise<Models.Session>}
795
+ */
796
+ async createEmailPasswordSession(email, password) {
797
+ if (typeof email === "undefined") {
798
+ throw new AppwriteException('Missing required parameter: "email"');
799
+ }
800
+ if (typeof password === "undefined") {
801
+ throw new AppwriteException('Missing required parameter: "password"');
802
+ }
803
+ const apiPath = "/account/sessions/email";
804
+ const payload = {};
805
+ if (typeof email !== "undefined") {
806
+ payload["email"] = email;
807
+ }
808
+ if (typeof password !== "undefined") {
809
+ payload["password"] = password;
810
+ }
811
+ const uri = new URL(this.client.config.endpoint + apiPath);
812
+ const apiHeaders = {
813
+ "content-type": "application/json"
814
+ };
815
+ return await this.client.call(
816
+ "post",
817
+ uri,
818
+ apiHeaders,
819
+ payload
820
+ );
821
+ }
822
+ /**
823
+ * Update magic URL session
824
+ *
825
+ * 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.
826
+ *
827
+ * @param {string} userId
828
+ * @param {string} secret
829
+ * @throws {AppwriteException}
830
+ * @returns {Promise<Models.Session>}
831
+ */
832
+ async updateMagicURLSession(userId, secret) {
833
+ if (typeof userId === "undefined") {
834
+ throw new AppwriteException('Missing required parameter: "userId"');
835
+ }
836
+ if (typeof secret === "undefined") {
837
+ throw new AppwriteException('Missing required parameter: "secret"');
838
+ }
839
+ const apiPath = "/account/sessions/magic-url";
840
+ const payload = {};
841
+ if (typeof userId !== "undefined") {
842
+ payload["userId"] = userId;
843
+ }
844
+ if (typeof secret !== "undefined") {
845
+ payload["secret"] = secret;
846
+ }
847
+ const uri = new URL(this.client.config.endpoint + apiPath);
848
+ const apiHeaders = {
849
+ "content-type": "application/json"
850
+ };
851
+ return await this.client.call(
852
+ "put",
853
+ uri,
854
+ apiHeaders,
855
+ payload
856
+ );
857
+ }
858
+ /**
859
+ * Update phone session
860
+ *
861
+ * 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.
862
+ *
863
+ * @param {string} userId
864
+ * @param {string} secret
865
+ * @throws {AppwriteException}
866
+ * @returns {Promise<Models.Session>}
867
+ */
868
+ async updatePhoneSession(userId, secret) {
869
+ if (typeof userId === "undefined") {
870
+ throw new AppwriteException('Missing required parameter: "userId"');
871
+ }
872
+ if (typeof secret === "undefined") {
873
+ throw new AppwriteException('Missing required parameter: "secret"');
874
+ }
875
+ const apiPath = "/account/sessions/phone";
876
+ const payload = {};
877
+ if (typeof userId !== "undefined") {
878
+ payload["userId"] = userId;
879
+ }
880
+ if (typeof secret !== "undefined") {
881
+ payload["secret"] = secret;
882
+ }
883
+ const uri = new URL(this.client.config.endpoint + apiPath);
884
+ const apiHeaders = {
885
+ "content-type": "application/json"
886
+ };
887
+ return await this.client.call(
888
+ "put",
889
+ uri,
890
+ apiHeaders,
891
+ payload
892
+ );
893
+ }
894
+ /**
895
+ * Create session
896
+ *
897
+ * 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.
898
+ *
899
+ * @param {string} userId
900
+ * @param {string} secret
901
+ * @throws {AppwriteException}
902
+ * @returns {Promise<Models.Session>}
903
+ */
904
+ async createSession(userId, secret) {
905
+ if (typeof userId === "undefined") {
906
+ throw new AppwriteException('Missing required parameter: "userId"');
907
+ }
908
+ if (typeof secret === "undefined") {
909
+ throw new AppwriteException('Missing required parameter: "secret"');
910
+ }
911
+ const apiPath = "/account/sessions/token";
912
+ const payload = {};
913
+ if (typeof userId !== "undefined") {
914
+ payload["userId"] = userId;
915
+ }
916
+ if (typeof secret !== "undefined") {
917
+ payload["secret"] = secret;
918
+ }
919
+ const uri = new URL(this.client.config.endpoint + apiPath);
920
+ const apiHeaders = {
921
+ "content-type": "application/json"
922
+ };
923
+ return await this.client.call(
924
+ "post",
925
+ uri,
926
+ apiHeaders,
927
+ payload
928
+ );
929
+ }
930
+ /**
931
+ * Get session
932
+ *
933
+ * 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.
934
+ *
935
+ * @param {string} sessionId
936
+ * @throws {AppwriteException}
937
+ * @returns {Promise<Models.Session>}
938
+ */
939
+ async getSession(sessionId) {
940
+ if (typeof sessionId === "undefined") {
941
+ throw new AppwriteException('Missing required parameter: "sessionId"');
942
+ }
943
+ const apiPath = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId);
944
+ const payload = {};
945
+ const uri = new URL(this.client.config.endpoint + apiPath);
946
+ const apiHeaders = {
947
+ "content-type": "application/json"
948
+ };
949
+ return await this.client.call(
950
+ "get",
951
+ uri,
952
+ apiHeaders,
953
+ payload
954
+ );
955
+ }
956
+ /**
957
+ * Update session
958
+ *
959
+ * 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.
960
+ *
961
+ * @param {string} sessionId
962
+ * @throws {AppwriteException}
963
+ * @returns {Promise<Models.Session>}
964
+ */
965
+ async updateSession(sessionId) {
966
+ if (typeof sessionId === "undefined") {
967
+ throw new AppwriteException('Missing required parameter: "sessionId"');
968
+ }
969
+ const apiPath = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId);
970
+ const payload = {};
971
+ const uri = new URL(this.client.config.endpoint + apiPath);
972
+ const apiHeaders = {
973
+ "content-type": "application/json"
974
+ };
975
+ return await this.client.call(
976
+ "patch",
977
+ uri,
978
+ apiHeaders,
979
+ payload
980
+ );
981
+ }
982
+ /**
983
+ * Delete session
984
+ *
985
+ * 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.
986
+ *
987
+ * @param {string} sessionId
988
+ * @throws {AppwriteException}
989
+ * @returns {Promise<{}>}
990
+ */
991
+ async deleteSession(sessionId) {
992
+ if (typeof sessionId === "undefined") {
993
+ throw new AppwriteException('Missing required parameter: "sessionId"');
994
+ }
995
+ const apiPath = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId);
996
+ const payload = {};
997
+ const uri = new URL(this.client.config.endpoint + apiPath);
998
+ const apiHeaders = {
999
+ "content-type": "application/json"
1000
+ };
1001
+ return await this.client.call(
1002
+ "delete",
1003
+ uri,
1004
+ apiHeaders,
1005
+ payload
1006
+ );
1007
+ }
1008
+ /**
1009
+ * Update status
1010
+ *
1011
+ * 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.
1012
+ *
1013
+ * @throws {AppwriteException}
1014
+ * @returns {Promise<Models.User<Preferences>>}
1015
+ */
1016
+ async updateStatus() {
1017
+ const apiPath = "/account/status";
1018
+ const payload = {};
1019
+ const uri = new URL(this.client.config.endpoint + apiPath);
1020
+ const apiHeaders = {
1021
+ "content-type": "application/json"
1022
+ };
1023
+ return await this.client.call(
1024
+ "patch",
1025
+ uri,
1026
+ apiHeaders,
1027
+ payload
1028
+ );
1029
+ }
1030
+ /**
1031
+ * Create email token (OTP)
1032
+ *
1033
+ * 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.
1034
+
1035
+ 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).
1036
+ *
1037
+ * @param {string} userId
1038
+ * @param {string} email
1039
+ * @param {boolean} phrase
1040
+ * @throws {AppwriteException}
1041
+ * @returns {Promise<Models.Token>}
1042
+ */
1043
+ async createEmailToken(userId, email, phrase) {
1044
+ if (typeof userId === "undefined") {
1045
+ throw new AppwriteException('Missing required parameter: "userId"');
1046
+ }
1047
+ if (typeof email === "undefined") {
1048
+ throw new AppwriteException('Missing required parameter: "email"');
1049
+ }
1050
+ const apiPath = "/account/tokens/email";
1051
+ const payload = {};
1052
+ if (typeof userId !== "undefined") {
1053
+ payload["userId"] = userId;
1054
+ }
1055
+ if (typeof email !== "undefined") {
1056
+ payload["email"] = email;
1057
+ }
1058
+ if (typeof phrase !== "undefined") {
1059
+ payload["phrase"] = phrase;
1060
+ }
1061
+ const uri = new URL(this.client.config.endpoint + apiPath);
1062
+ const apiHeaders = {
1063
+ "content-type": "application/json"
1064
+ };
1065
+ return await this.client.call(
1066
+ "post",
1067
+ uri,
1068
+ apiHeaders,
1069
+ payload
1070
+ );
1071
+ }
1072
+ /**
1073
+ * Create magic URL token
1074
+ *
1075
+ * 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.
1076
+
1077
+ 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).
1078
+
1079
+ *
1080
+ * @param {string} userId
1081
+ * @param {string} email
1082
+ * @param {string} url
1083
+ * @param {boolean} phrase
1084
+ * @throws {AppwriteException}
1085
+ * @returns {Promise<Models.Token>}
1086
+ */
1087
+ async createMagicURLToken(userId, email, url, phrase) {
1088
+ if (typeof userId === "undefined") {
1089
+ throw new AppwriteException('Missing required parameter: "userId"');
1090
+ }
1091
+ if (typeof email === "undefined") {
1092
+ throw new AppwriteException('Missing required parameter: "email"');
1093
+ }
1094
+ const apiPath = "/account/tokens/magic-url";
1095
+ const payload = {};
1096
+ if (typeof userId !== "undefined") {
1097
+ payload["userId"] = userId;
1098
+ }
1099
+ if (typeof email !== "undefined") {
1100
+ payload["email"] = email;
1101
+ }
1102
+ if (typeof url !== "undefined") {
1103
+ payload["url"] = url;
1104
+ }
1105
+ if (typeof phrase !== "undefined") {
1106
+ payload["phrase"] = phrase;
1107
+ }
1108
+ const uri = new URL(this.client.config.endpoint + apiPath);
1109
+ const apiHeaders = {
1110
+ "content-type": "application/json"
1111
+ };
1112
+ return await this.client.call(
1113
+ "post",
1114
+ uri,
1115
+ apiHeaders,
1116
+ payload
1117
+ );
1118
+ }
1119
+ /**
1120
+ * Create OAuth2 token
1121
+ *
1122
+ * 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.
1123
+
1124
+ 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.
1125
+
1126
+ 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).
1127
+ *
1128
+ * @param {OAuthProvider} provider
1129
+ * @param {string} success
1130
+ * @param {string} failure
1131
+ * @param {string[]} scopes
1132
+ * @throws {AppwriteException}
1133
+ * @returns {Promise<string>}
1134
+ */
1135
+ async createOAuth2Token(provider, success, failure, scopes) {
1136
+ if (typeof provider === "undefined") {
1137
+ throw new AppwriteException('Missing required parameter: "provider"');
1138
+ }
1139
+ const apiPath = "/account/tokens/oauth2/{provider}".replace("{provider}", provider);
1140
+ const payload = {};
1141
+ if (typeof success !== "undefined") {
1142
+ payload["success"] = success;
1143
+ }
1144
+ if (typeof failure !== "undefined") {
1145
+ payload["failure"] = failure;
1146
+ }
1147
+ if (typeof scopes !== "undefined") {
1148
+ payload["scopes"] = scopes;
1149
+ }
1150
+ const uri = new URL(this.client.config.endpoint + apiPath);
1151
+ const apiHeaders = {
1152
+ "content-type": "application/json"
1153
+ };
1154
+ return await this.client.redirect(
1155
+ "get",
1156
+ uri,
1157
+ apiHeaders,
1158
+ payload
1159
+ );
1160
+ }
1161
+ /**
1162
+ * Create phone token
1163
+ *
1164
+ * 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.
1165
+
1166
+ 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).
1167
+ *
1168
+ * @param {string} userId
1169
+ * @param {string} phone
1170
+ * @throws {AppwriteException}
1171
+ * @returns {Promise<Models.Token>}
1172
+ */
1173
+ async createPhoneToken(userId, phone) {
1174
+ if (typeof userId === "undefined") {
1175
+ throw new AppwriteException('Missing required parameter: "userId"');
1176
+ }
1177
+ if (typeof phone === "undefined") {
1178
+ throw new AppwriteException('Missing required parameter: "phone"');
1179
+ }
1180
+ const apiPath = "/account/tokens/phone";
1181
+ const payload = {};
1182
+ if (typeof userId !== "undefined") {
1183
+ payload["userId"] = userId;
1184
+ }
1185
+ if (typeof phone !== "undefined") {
1186
+ payload["phone"] = phone;
1187
+ }
1188
+ const uri = new URL(this.client.config.endpoint + apiPath);
1189
+ const apiHeaders = {
1190
+ "content-type": "application/json"
1191
+ };
1192
+ return await this.client.call(
1193
+ "post",
1194
+ uri,
1195
+ apiHeaders,
1196
+ payload
1197
+ );
1198
+ }
1199
+ /**
1200
+ * Create email verification
1201
+ *
1202
+ * 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.
1203
+
1204
+ 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.
1205
+
1206
+ *
1207
+ * @param {string} url
1208
+ * @throws {AppwriteException}
1209
+ * @returns {Promise<Models.Token>}
1210
+ */
1211
+ async createVerification(url) {
1212
+ if (typeof url === "undefined") {
1213
+ throw new AppwriteException('Missing required parameter: "url"');
1214
+ }
1215
+ const apiPath = "/account/verification";
1216
+ const payload = {};
1217
+ if (typeof url !== "undefined") {
1218
+ payload["url"] = url;
1219
+ }
1220
+ const uri = new URL(this.client.config.endpoint + apiPath);
1221
+ const apiHeaders = {
1222
+ "content-type": "application/json"
1223
+ };
1224
+ return await this.client.call(
1225
+ "post",
1226
+ uri,
1227
+ apiHeaders,
1228
+ payload
1229
+ );
1230
+ }
1231
+ /**
1232
+ * Create email verification (confirmation)
1233
+ *
1234
+ * 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.
1235
+ *
1236
+ * @param {string} userId
1237
+ * @param {string} secret
1238
+ * @throws {AppwriteException}
1239
+ * @returns {Promise<Models.Token>}
1240
+ */
1241
+ async updateVerification(userId, secret) {
1242
+ if (typeof userId === "undefined") {
1243
+ throw new AppwriteException('Missing required parameter: "userId"');
1244
+ }
1245
+ if (typeof secret === "undefined") {
1246
+ throw new AppwriteException('Missing required parameter: "secret"');
1247
+ }
1248
+ const apiPath = "/account/verification";
1249
+ const payload = {};
1250
+ if (typeof userId !== "undefined") {
1251
+ payload["userId"] = userId;
1252
+ }
1253
+ if (typeof secret !== "undefined") {
1254
+ payload["secret"] = secret;
1255
+ }
1256
+ const uri = new URL(this.client.config.endpoint + apiPath);
1257
+ const apiHeaders = {
1258
+ "content-type": "application/json"
1259
+ };
1260
+ return await this.client.call(
1261
+ "put",
1262
+ uri,
1263
+ apiHeaders,
1264
+ payload
1265
+ );
1266
+ }
1267
+ /**
1268
+ * Create phone verification
1269
+ *
1270
+ * 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.
1271
+ *
1272
+ * @throws {AppwriteException}
1273
+ * @returns {Promise<Models.Token>}
1274
+ */
1275
+ async createPhoneVerification() {
1276
+ const apiPath = "/account/verification/phone";
1277
+ const payload = {};
1278
+ const uri = new URL(this.client.config.endpoint + apiPath);
1279
+ const apiHeaders = {
1280
+ "content-type": "application/json"
1281
+ };
1282
+ return await this.client.call(
1283
+ "post",
1284
+ uri,
1285
+ apiHeaders,
1286
+ payload
1287
+ );
1288
+ }
1289
+ /**
1290
+ * Create phone verification (confirmation)
1291
+ *
1292
+ * 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.
1293
+ *
1294
+ * @param {string} userId
1295
+ * @param {string} secret
1296
+ * @throws {AppwriteException}
1297
+ * @returns {Promise<Models.Token>}
1298
+ */
1299
+ async updatePhoneVerification(userId, secret) {
1300
+ if (typeof userId === "undefined") {
1301
+ throw new AppwriteException('Missing required parameter: "userId"');
1302
+ }
1303
+ if (typeof secret === "undefined") {
1304
+ throw new AppwriteException('Missing required parameter: "secret"');
1305
+ }
1306
+ const apiPath = "/account/verification/phone";
1307
+ const payload = {};
1308
+ if (typeof userId !== "undefined") {
1309
+ payload["userId"] = userId;
1310
+ }
1311
+ if (typeof secret !== "undefined") {
1312
+ payload["secret"] = secret;
1313
+ }
1314
+ const uri = new URL(this.client.config.endpoint + apiPath);
1315
+ const apiHeaders = {
1316
+ "content-type": "application/json"
1317
+ };
1318
+ return await this.client.call(
1319
+ "put",
1320
+ uri,
1321
+ apiHeaders,
1322
+ payload
1323
+ );
1324
+ }
1325
+ }
1326
+
1327
+ export { Account };
1328
+ //# sourceMappingURL=out.js.map
1329
+ //# sourceMappingURL=account.mjs.map