@appwrite.io/console 0.6.0-rc.14 → 0.6.0-rc.16
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.
- package/README.md +1 -1
- package/dist/cjs/sdk.js +222 -69
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +223 -70
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +222 -69
- package/docs/examples/account/{add-authenticator.md → create-mfa-authenticator.md} +1 -1
- package/docs/examples/account/{create-challenge.md → create-mfa-challenge.md} +2 -2
- package/docs/examples/account/create-mfa-recovery-codes.md +11 -0
- package/docs/examples/account/{verify-authenticator.md → delete-mfa-authenticator.md} +1 -1
- package/docs/examples/account/get-mfa-recovery-codes.md +11 -0
- package/docs/examples/account/{list-factors.md → list-mfa-factors.md} +1 -1
- package/docs/examples/account/{delete-authenticator.md → update-mfa-authenticator.md} +1 -1
- package/docs/examples/account/{update-challenge.md → update-mfa-challenge.md} +1 -1
- package/docs/examples/account/update-mfa-recovery-codes.md +11 -0
- package/docs/examples/users/create-mfa-recovery-codes.md +13 -0
- package/docs/examples/users/{delete-authenticator.md → delete-mfa-authenticator.md} +3 -3
- package/docs/examples/users/get-mfa-recovery-codes.md +13 -0
- package/docs/examples/users/{list-factors.md → list-mfa-factors.md} +1 -1
- package/docs/examples/users/update-mfa-recovery-codes.md +13 -0
- package/package.json +1 -1
- package/src/client.ts +1 -1
- package/src/enums/authentication-factor.ts +3 -2
- package/src/enums/type.ts +3 -0
- package/src/index.ts +2 -1
- package/src/models.ts +13 -8
- package/src/services/account.ts +132 -60
- package/src/services/users.ts +88 -10
- package/types/enums/authentication-factor.d.ts +3 -2
- package/types/enums/type.d.ts +3 -0
- package/types/index.d.ts +2 -1
- package/types/models.d.ts +13 -8
- package/types/services/account.d.ts +71 -26
- package/types/services/users.d.ts +45 -6
package/src/models.ts
CHANGED
|
@@ -1186,10 +1186,6 @@ export namespace Models {
|
|
|
1186
1186
|
* Multi factor authentication status.
|
|
1187
1187
|
*/
|
|
1188
1188
|
mfa: boolean;
|
|
1189
|
-
/**
|
|
1190
|
-
* TOTP status.
|
|
1191
|
-
*/
|
|
1192
|
-
totp: boolean;
|
|
1193
1189
|
/**
|
|
1194
1190
|
* User preferences as a key-value object
|
|
1195
1191
|
*/
|
|
@@ -1424,6 +1420,10 @@ export namespace Models {
|
|
|
1424
1420
|
* Secret used to authenticate the user. Only included if the request was made with an API key
|
|
1425
1421
|
*/
|
|
1426
1422
|
secret: string;
|
|
1423
|
+
/**
|
|
1424
|
+
* Most recent date in ISO 8601 format when the session successfully passed MFA challenge.
|
|
1425
|
+
*/
|
|
1426
|
+
mfaUpdatedAt: string;
|
|
1427
1427
|
}
|
|
1428
1428
|
/**
|
|
1429
1429
|
* Identity
|
|
@@ -3240,13 +3240,18 @@ export namespace Models {
|
|
|
3240
3240
|
expire: string;
|
|
3241
3241
|
}
|
|
3242
3242
|
/**
|
|
3243
|
-
*
|
|
3243
|
+
* MFA Recovery Codes
|
|
3244
3244
|
*/
|
|
3245
|
-
export type
|
|
3245
|
+
export type MfaRecoveryCodes = {
|
|
3246
3246
|
/**
|
|
3247
|
-
*
|
|
3247
|
+
* Recovery codes.
|
|
3248
3248
|
*/
|
|
3249
|
-
|
|
3249
|
+
recoveryCodes: string[];
|
|
3250
|
+
}
|
|
3251
|
+
/**
|
|
3252
|
+
* MFAType
|
|
3253
|
+
*/
|
|
3254
|
+
export type MfaType = {
|
|
3250
3255
|
/**
|
|
3251
3256
|
* Secret token used for TOTP factor.
|
|
3252
3257
|
*/
|
package/src/services/account.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { Service } from '../service';
|
|
|
2
2
|
import { AppwriteException, Client } from '../client';
|
|
3
3
|
import type { Models } from '../models';
|
|
4
4
|
import type { UploadProgress, Payload } from '../client';
|
|
5
|
-
import { AuthenticationFactor } from '../enums/authentication-factor';
|
|
6
5
|
import { AuthenticatorType } from '../enums/authenticator-type';
|
|
6
|
+
import { AuthenticationFactor } from '../enums/authentication-factor';
|
|
7
7
|
import { OAuthProvider } from '../enums/o-auth-provider';
|
|
8
8
|
|
|
9
9
|
export class Account extends Service {
|
|
@@ -267,15 +267,110 @@ export class Account extends Service {
|
|
|
267
267
|
}, payload);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Add Authenticator
|
|
272
|
+
*
|
|
273
|
+
* Add an authenticator app to be used as an MFA factor. Verify the
|
|
274
|
+
* authenticator using the [verify
|
|
275
|
+
* authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
|
|
276
|
+
* method.
|
|
277
|
+
*
|
|
278
|
+
* @param {AuthenticatorType} type
|
|
279
|
+
* @throws {AppwriteException}
|
|
280
|
+
* @returns {Promise}
|
|
281
|
+
*/
|
|
282
|
+
async createMfaAuthenticator(type: AuthenticatorType): Promise<Models.MfaType> {
|
|
283
|
+
if (typeof type === 'undefined') {
|
|
284
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
|
|
288
|
+
const payload: Payload = {};
|
|
289
|
+
|
|
290
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
291
|
+
return await this.client.call('post', uri, {
|
|
292
|
+
'content-type': 'application/json',
|
|
293
|
+
}, payload);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Verify Authenticator
|
|
298
|
+
*
|
|
299
|
+
* Verify an authenticator app after adding it using the [add
|
|
300
|
+
* authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
|
|
301
|
+
* method.
|
|
302
|
+
*
|
|
303
|
+
* @param {AuthenticatorType} type
|
|
304
|
+
* @param {string} otp
|
|
305
|
+
* @throws {AppwriteException}
|
|
306
|
+
* @returns {Promise}
|
|
307
|
+
*/
|
|
308
|
+
async updateMfaAuthenticator<Preferences extends Models.Preferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>> {
|
|
309
|
+
if (typeof type === 'undefined') {
|
|
310
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (typeof otp === 'undefined') {
|
|
314
|
+
throw new AppwriteException('Missing required parameter: "otp"');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
|
|
318
|
+
const payload: Payload = {};
|
|
319
|
+
|
|
320
|
+
if (typeof otp !== 'undefined') {
|
|
321
|
+
payload['otp'] = otp;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
325
|
+
return await this.client.call('put', uri, {
|
|
326
|
+
'content-type': 'application/json',
|
|
327
|
+
}, payload);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Delete Authenticator
|
|
332
|
+
*
|
|
333
|
+
* Delete an authenticator for a user by ID.
|
|
334
|
+
*
|
|
335
|
+
* @param {AuthenticatorType} type
|
|
336
|
+
* @param {string} otp
|
|
337
|
+
* @throws {AppwriteException}
|
|
338
|
+
* @returns {Promise}
|
|
339
|
+
*/
|
|
340
|
+
async deleteMfaAuthenticator<Preferences extends Models.Preferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>> {
|
|
341
|
+
if (typeof type === 'undefined') {
|
|
342
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (typeof otp === 'undefined') {
|
|
346
|
+
throw new AppwriteException('Missing required parameter: "otp"');
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
|
|
350
|
+
const payload: Payload = {};
|
|
351
|
+
|
|
352
|
+
if (typeof otp !== 'undefined') {
|
|
353
|
+
payload['otp'] = otp;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
357
|
+
return await this.client.call('delete', uri, {
|
|
358
|
+
'content-type': 'application/json',
|
|
359
|
+
}, payload);
|
|
360
|
+
}
|
|
361
|
+
|
|
270
362
|
/**
|
|
271
363
|
* Create 2FA Challenge
|
|
272
364
|
*
|
|
365
|
+
* Begin the process of MFA verification after sign-in. Finish the flow with
|
|
366
|
+
* [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
|
|
367
|
+
* method.
|
|
273
368
|
*
|
|
274
369
|
* @param {AuthenticationFactor} factor
|
|
275
370
|
* @throws {AppwriteException}
|
|
276
371
|
* @returns {Promise}
|
|
277
372
|
*/
|
|
278
|
-
async
|
|
373
|
+
async createMfaChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge> {
|
|
279
374
|
if (typeof factor === 'undefined') {
|
|
280
375
|
throw new AppwriteException('Missing required parameter: "factor"');
|
|
281
376
|
}
|
|
@@ -296,14 +391,18 @@ export class Account extends Service {
|
|
|
296
391
|
/**
|
|
297
392
|
* Create MFA Challenge (confirmation)
|
|
298
393
|
*
|
|
299
|
-
* Complete the MFA challenge by providing the one-time password.
|
|
394
|
+
* Complete the MFA challenge by providing the one-time password. Finish the
|
|
395
|
+
* process of MFA verification by providing the one-time password. To begin
|
|
396
|
+
* the flow, use
|
|
397
|
+
* [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
|
|
398
|
+
* method.
|
|
300
399
|
*
|
|
301
400
|
* @param {string} challengeId
|
|
302
401
|
* @param {string} otp
|
|
303
402
|
* @throws {AppwriteException}
|
|
304
403
|
* @returns {Promise}
|
|
305
404
|
*/
|
|
306
|
-
async
|
|
405
|
+
async updateMfaChallenge(challengeId: string, otp: string): Promise<{}> {
|
|
307
406
|
if (typeof challengeId === 'undefined') {
|
|
308
407
|
throw new AppwriteException('Missing required parameter: "challengeId"');
|
|
309
408
|
}
|
|
@@ -337,7 +436,7 @@ export class Account extends Service {
|
|
|
337
436
|
* @throws {AppwriteException}
|
|
338
437
|
* @returns {Promise}
|
|
339
438
|
*/
|
|
340
|
-
async
|
|
439
|
+
async listMfaFactors(): Promise<Models.MfaFactors> {
|
|
341
440
|
const apiPath = '/account/mfa/factors';
|
|
342
441
|
const payload: Payload = {};
|
|
343
442
|
|
|
@@ -348,93 +447,65 @@ export class Account extends Service {
|
|
|
348
447
|
}
|
|
349
448
|
|
|
350
449
|
/**
|
|
351
|
-
*
|
|
450
|
+
* Get MFA Recovery Codes
|
|
352
451
|
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* method.
|
|
452
|
+
* Get recovery codes that can be used as backup for MFA flow. Before getting
|
|
453
|
+
* codes, they must be generated using
|
|
454
|
+
* [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
|
|
455
|
+
* method. An OTP challenge is required to read recovery codes.
|
|
357
456
|
*
|
|
358
|
-
* @param {AuthenticatorType} type
|
|
359
457
|
* @throws {AppwriteException}
|
|
360
458
|
* @returns {Promise}
|
|
361
459
|
*/
|
|
362
|
-
async
|
|
363
|
-
|
|
364
|
-
throw new AppwriteException('Missing required parameter: "type"');
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
const apiPath = '/account/mfa/{type}'.replace('{type}', type);
|
|
460
|
+
async getMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> {
|
|
461
|
+
const apiPath = '/account/mfa/recovery-codes';
|
|
368
462
|
const payload: Payload = {};
|
|
369
463
|
|
|
370
464
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
371
|
-
return await this.client.call('
|
|
465
|
+
return await this.client.call('get', uri, {
|
|
372
466
|
'content-type': 'application/json',
|
|
373
467
|
}, payload);
|
|
374
468
|
}
|
|
375
469
|
|
|
376
470
|
/**
|
|
377
|
-
*
|
|
471
|
+
* Create MFA Recovery Codes
|
|
378
472
|
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
473
|
+
* Generate recovery codes as backup for MFA flow. It's recommended to
|
|
474
|
+
* generate and show then immediately after user successfully adds their
|
|
475
|
+
* authehticator. Recovery codes can be used as a MFA verification type in
|
|
476
|
+
* [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
|
|
381
477
|
* method.
|
|
382
478
|
*
|
|
383
|
-
* @param {AuthenticatorType} type
|
|
384
|
-
* @param {string} otp
|
|
385
479
|
* @throws {AppwriteException}
|
|
386
480
|
* @returns {Promise}
|
|
387
481
|
*/
|
|
388
|
-
async
|
|
389
|
-
|
|
390
|
-
throw new AppwriteException('Missing required parameter: "type"');
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (typeof otp === 'undefined') {
|
|
394
|
-
throw new AppwriteException('Missing required parameter: "otp"');
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
const apiPath = '/account/mfa/{type}'.replace('{type}', type);
|
|
482
|
+
async createMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> {
|
|
483
|
+
const apiPath = '/account/mfa/recovery-codes';
|
|
398
484
|
const payload: Payload = {};
|
|
399
485
|
|
|
400
|
-
if (typeof otp !== 'undefined') {
|
|
401
|
-
payload['otp'] = otp;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
486
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
405
|
-
return await this.client.call('
|
|
487
|
+
return await this.client.call('post', uri, {
|
|
406
488
|
'content-type': 'application/json',
|
|
407
489
|
}, payload);
|
|
408
490
|
}
|
|
409
491
|
|
|
410
492
|
/**
|
|
411
|
-
*
|
|
493
|
+
* Regenerate MFA Recovery Codes
|
|
412
494
|
*
|
|
413
|
-
*
|
|
495
|
+
* Regenerate recovery codes that can be used as backup for MFA flow. Before
|
|
496
|
+
* regenerating codes, they must be first generated using
|
|
497
|
+
* [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
|
|
498
|
+
* method. An OTP challenge is required to regenreate recovery codes.
|
|
414
499
|
*
|
|
415
|
-
* @param {AuthenticatorType} type
|
|
416
|
-
* @param {string} otp
|
|
417
500
|
* @throws {AppwriteException}
|
|
418
501
|
* @returns {Promise}
|
|
419
502
|
*/
|
|
420
|
-
async
|
|
421
|
-
|
|
422
|
-
throw new AppwriteException('Missing required parameter: "type"');
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
if (typeof otp === 'undefined') {
|
|
426
|
-
throw new AppwriteException('Missing required parameter: "otp"');
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
const apiPath = '/account/mfa/{type}'.replace('{type}', type);
|
|
503
|
+
async updateMfaRecoveryCodes(): Promise<Models.MfaRecoveryCodes> {
|
|
504
|
+
const apiPath = '/account/mfa/recovery-codes';
|
|
430
505
|
const payload: Payload = {};
|
|
431
506
|
|
|
432
|
-
if (typeof otp !== 'undefined') {
|
|
433
|
-
payload['otp'] = otp;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
507
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
437
|
-
return await this.client.call('
|
|
508
|
+
return await this.client.call('patch', uri, {
|
|
438
509
|
'content-type': 'application/json',
|
|
439
510
|
}, payload);
|
|
440
511
|
}
|
|
@@ -987,10 +1058,11 @@ export class Account extends Service {
|
|
|
987
1058
|
}
|
|
988
1059
|
|
|
989
1060
|
/**
|
|
990
|
-
* Update
|
|
1061
|
+
* Update session
|
|
991
1062
|
*
|
|
992
|
-
*
|
|
993
|
-
* useful when session
|
|
1063
|
+
* Use this endpoint to extend a session's length. Extending a session is
|
|
1064
|
+
* useful when session expiry is short. If the session was created using an
|
|
1065
|
+
* OAuth provider, this endpoint refreshes the access token from the provider.
|
|
994
1066
|
*
|
|
995
1067
|
* @param {string} sessionId
|
|
996
1068
|
* @throws {AppwriteException}
|
package/src/services/users.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Models } from '../models';
|
|
|
4
4
|
import type { UploadProgress, Payload } from '../client';
|
|
5
5
|
import { PasswordHash } from '../enums/password-hash';
|
|
6
6
|
import { UserUsageRange } from '../enums/user-usage-range';
|
|
7
|
-
import {
|
|
7
|
+
import { Type } from '../enums/type';
|
|
8
8
|
import { MessagingProviderType } from '../enums/messaging-provider-type';
|
|
9
9
|
|
|
10
10
|
export class Users extends Service {
|
|
@@ -815,6 +815,34 @@ export class Users extends Service {
|
|
|
815
815
|
}, payload);
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
+
/**
|
|
819
|
+
* Delete Authenticator
|
|
820
|
+
*
|
|
821
|
+
* Delete an authenticator app.
|
|
822
|
+
*
|
|
823
|
+
* @param {string} userId
|
|
824
|
+
* @param {Type} type
|
|
825
|
+
* @throws {AppwriteException}
|
|
826
|
+
* @returns {Promise}
|
|
827
|
+
*/
|
|
828
|
+
async deleteMfaAuthenticator<Preferences extends Models.Preferences>(userId: string, type: Type): Promise<Models.User<Preferences>> {
|
|
829
|
+
if (typeof userId === 'undefined') {
|
|
830
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
if (typeof type === 'undefined') {
|
|
834
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type);
|
|
838
|
+
const payload: Payload = {};
|
|
839
|
+
|
|
840
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
841
|
+
return await this.client.call('delete', uri, {
|
|
842
|
+
'content-type': 'application/json',
|
|
843
|
+
}, payload);
|
|
844
|
+
}
|
|
845
|
+
|
|
818
846
|
/**
|
|
819
847
|
* List Factors
|
|
820
848
|
*
|
|
@@ -824,7 +852,7 @@ export class Users extends Service {
|
|
|
824
852
|
* @throws {AppwriteException}
|
|
825
853
|
* @returns {Promise}
|
|
826
854
|
*/
|
|
827
|
-
async
|
|
855
|
+
async listMfaFactors(userId: string): Promise<Models.MfaFactors> {
|
|
828
856
|
if (typeof userId === 'undefined') {
|
|
829
857
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
830
858
|
}
|
|
@@ -839,29 +867,79 @@ export class Users extends Service {
|
|
|
839
867
|
}
|
|
840
868
|
|
|
841
869
|
/**
|
|
842
|
-
*
|
|
870
|
+
* Get MFA Recovery Codes
|
|
843
871
|
*
|
|
844
|
-
*
|
|
872
|
+
* Get recovery codes that can be used as backup for MFA flow by User ID.
|
|
873
|
+
* Before getting codes, they must be generated using
|
|
874
|
+
* [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
|
|
875
|
+
* method.
|
|
845
876
|
*
|
|
846
877
|
* @param {string} userId
|
|
847
|
-
* @param {AuthenticatorType} type
|
|
848
878
|
* @throws {AppwriteException}
|
|
849
879
|
* @returns {Promise}
|
|
850
880
|
*/
|
|
851
|
-
async
|
|
881
|
+
async getMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> {
|
|
852
882
|
if (typeof userId === 'undefined') {
|
|
853
883
|
throw new AppwriteException('Missing required parameter: "userId"');
|
|
854
884
|
}
|
|
855
885
|
|
|
856
|
-
|
|
857
|
-
|
|
886
|
+
const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId);
|
|
887
|
+
const payload: Payload = {};
|
|
888
|
+
|
|
889
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
890
|
+
return await this.client.call('get', uri, {
|
|
891
|
+
'content-type': 'application/json',
|
|
892
|
+
}, payload);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Regenerate MFA Recovery Codes
|
|
897
|
+
*
|
|
898
|
+
* Regenerate recovery codes that can be used as backup for MFA flow by User
|
|
899
|
+
* ID. Before regenerating codes, they must be first generated using
|
|
900
|
+
* [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
|
|
901
|
+
* method.
|
|
902
|
+
*
|
|
903
|
+
* @param {string} userId
|
|
904
|
+
* @throws {AppwriteException}
|
|
905
|
+
* @returns {Promise}
|
|
906
|
+
*/
|
|
907
|
+
async updateMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> {
|
|
908
|
+
if (typeof userId === 'undefined') {
|
|
909
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
858
910
|
}
|
|
859
911
|
|
|
860
|
-
const apiPath = '/users/{userId}/mfa/
|
|
912
|
+
const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId);
|
|
861
913
|
const payload: Payload = {};
|
|
862
914
|
|
|
863
915
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
864
|
-
return await this.client.call('
|
|
916
|
+
return await this.client.call('put', uri, {
|
|
917
|
+
'content-type': 'application/json',
|
|
918
|
+
}, payload);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Create MFA Recovery Codes
|
|
923
|
+
*
|
|
924
|
+
* Generate recovery codes used as backup for MFA flow for User ID. Recovery
|
|
925
|
+
* codes can be used as a MFA verification type in
|
|
926
|
+
* [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
|
|
927
|
+
* method by client SDK.
|
|
928
|
+
*
|
|
929
|
+
* @param {string} userId
|
|
930
|
+
* @throws {AppwriteException}
|
|
931
|
+
* @returns {Promise}
|
|
932
|
+
*/
|
|
933
|
+
async createMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes> {
|
|
934
|
+
if (typeof userId === 'undefined') {
|
|
935
|
+
throw new AppwriteException('Missing required parameter: "userId"');
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId);
|
|
939
|
+
const payload: Payload = {};
|
|
940
|
+
|
|
941
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
942
|
+
return await this.client.call('patch', uri, {
|
|
865
943
|
'content-type': 'application/json',
|
|
866
944
|
}, payload);
|
|
867
945
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ export type { QueryTypes, QueryTypesList } from './query';
|
|
|
22
22
|
export { Permission } from './permission';
|
|
23
23
|
export { Role } from './role';
|
|
24
24
|
export { ID } from './id';
|
|
25
|
-
export { AuthenticationFactor } from './enums/authentication-factor';
|
|
26
25
|
export { AuthenticatorType } from './enums/authenticator-type';
|
|
26
|
+
export { AuthenticationFactor } from './enums/authentication-factor';
|
|
27
27
|
export { OAuthProvider } from './enums/o-auth-provider';
|
|
28
28
|
export { Browser } from './enums/browser';
|
|
29
29
|
export { CreditCard } from './enums/credit-card';
|
|
@@ -54,4 +54,5 @@ export { ImageFormat } from './enums/image-format';
|
|
|
54
54
|
export { StorageUsageRange } from './enums/storage-usage-range';
|
|
55
55
|
export { PasswordHash } from './enums/password-hash';
|
|
56
56
|
export { UserUsageRange } from './enums/user-usage-range';
|
|
57
|
+
export { Type } from './enums/type';
|
|
57
58
|
export { MessagingProviderType } from './enums/messaging-provider-type';
|
package/types/models.d.ts
CHANGED
|
@@ -1186,10 +1186,6 @@ export declare namespace Models {
|
|
|
1186
1186
|
* Multi factor authentication status.
|
|
1187
1187
|
*/
|
|
1188
1188
|
mfa: boolean;
|
|
1189
|
-
/**
|
|
1190
|
-
* TOTP status.
|
|
1191
|
-
*/
|
|
1192
|
-
totp: boolean;
|
|
1193
1189
|
/**
|
|
1194
1190
|
* User preferences as a key-value object
|
|
1195
1191
|
*/
|
|
@@ -1424,6 +1420,10 @@ export declare namespace Models {
|
|
|
1424
1420
|
* Secret used to authenticate the user. Only included if the request was made with an API key
|
|
1425
1421
|
*/
|
|
1426
1422
|
secret: string;
|
|
1423
|
+
/**
|
|
1424
|
+
* Most recent date in ISO 8601 format when the session successfully passed MFA challenge.
|
|
1425
|
+
*/
|
|
1426
|
+
mfaUpdatedAt: string;
|
|
1427
1427
|
};
|
|
1428
1428
|
/**
|
|
1429
1429
|
* Identity
|
|
@@ -3240,13 +3240,18 @@ export declare namespace Models {
|
|
|
3240
3240
|
expire: string;
|
|
3241
3241
|
};
|
|
3242
3242
|
/**
|
|
3243
|
-
*
|
|
3243
|
+
* MFA Recovery Codes
|
|
3244
3244
|
*/
|
|
3245
|
-
type
|
|
3245
|
+
type MfaRecoveryCodes = {
|
|
3246
3246
|
/**
|
|
3247
|
-
*
|
|
3247
|
+
* Recovery codes.
|
|
3248
3248
|
*/
|
|
3249
|
-
|
|
3249
|
+
recoveryCodes: string[];
|
|
3250
|
+
};
|
|
3251
|
+
/**
|
|
3252
|
+
* MFAType
|
|
3253
|
+
*/
|
|
3254
|
+
type MfaType = {
|
|
3250
3255
|
/**
|
|
3251
3256
|
* Secret token used for TOTP factor.
|
|
3252
3257
|
*/
|