@appconda/nextjs 1.0.158 → 1.0.160

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