@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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/sdk.js +222 -69
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +223 -70
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +222 -69
  7. package/docs/examples/account/{add-authenticator.md → create-mfa-authenticator.md} +1 -1
  8. package/docs/examples/account/{create-challenge.md → create-mfa-challenge.md} +2 -2
  9. package/docs/examples/account/create-mfa-recovery-codes.md +11 -0
  10. package/docs/examples/account/{verify-authenticator.md → delete-mfa-authenticator.md} +1 -1
  11. package/docs/examples/account/get-mfa-recovery-codes.md +11 -0
  12. package/docs/examples/account/{list-factors.md → list-mfa-factors.md} +1 -1
  13. package/docs/examples/account/{delete-authenticator.md → update-mfa-authenticator.md} +1 -1
  14. package/docs/examples/account/{update-challenge.md → update-mfa-challenge.md} +1 -1
  15. package/docs/examples/account/update-mfa-recovery-codes.md +11 -0
  16. package/docs/examples/users/create-mfa-recovery-codes.md +13 -0
  17. package/docs/examples/users/{delete-authenticator.md → delete-mfa-authenticator.md} +3 -3
  18. package/docs/examples/users/get-mfa-recovery-codes.md +13 -0
  19. package/docs/examples/users/{list-factors.md → list-mfa-factors.md} +1 -1
  20. package/docs/examples/users/update-mfa-recovery-codes.md +13 -0
  21. package/package.json +1 -1
  22. package/src/client.ts +1 -1
  23. package/src/enums/authentication-factor.ts +3 -2
  24. package/src/enums/type.ts +3 -0
  25. package/src/index.ts +2 -1
  26. package/src/models.ts +13 -8
  27. package/src/services/account.ts +132 -60
  28. package/src/services/users.ts +88 -10
  29. package/types/enums/authentication-factor.d.ts +3 -2
  30. package/types/enums/type.d.ts +3 -0
  31. package/types/index.d.ts +2 -1
  32. package/types/models.d.ts +13 -8
  33. package/types/services/account.d.ts +71 -26
  34. package/types/services/users.d.ts +45 -6
package/README.md CHANGED
@@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console";
33
33
  To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:
34
34
 
35
35
  ```html
36
- <script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@0.6.0-rc.14"></script>
36
+ <script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@0.6.0-rc.16"></script>
37
37
  ```
38
38
 
39
39
 
package/dist/cjs/sdk.js CHANGED
@@ -117,7 +117,7 @@ class Client {
117
117
  'x-sdk-name': 'Console',
118
118
  'x-sdk-platform': 'console',
119
119
  'x-sdk-language': 'web',
120
- 'x-sdk-version': '0.6.0-rc.14',
120
+ 'x-sdk-version': '0.6.0-rc.16',
121
121
  'X-Appwrite-Response-Format': '1.5.0',
122
122
  };
123
123
  this.realtime = {
@@ -692,15 +692,103 @@ class Account extends Service {
692
692
  }, payload);
693
693
  });
694
694
  }
695
+ /**
696
+ * Add Authenticator
697
+ *
698
+ * Add an authenticator app to be used as an MFA factor. Verify the
699
+ * authenticator using the [verify
700
+ * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
701
+ * method.
702
+ *
703
+ * @param {AuthenticatorType} type
704
+ * @throws {AppwriteException}
705
+ * @returns {Promise}
706
+ */
707
+ createMfaAuthenticator(type) {
708
+ return __awaiter(this, void 0, void 0, function* () {
709
+ if (typeof type === 'undefined') {
710
+ throw new AppwriteException('Missing required parameter: "type"');
711
+ }
712
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
713
+ const payload = {};
714
+ const uri = new URL(this.client.config.endpoint + apiPath);
715
+ return yield this.client.call('post', uri, {
716
+ 'content-type': 'application/json',
717
+ }, payload);
718
+ });
719
+ }
720
+ /**
721
+ * Verify Authenticator
722
+ *
723
+ * Verify an authenticator app after adding it using the [add
724
+ * authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
725
+ * method.
726
+ *
727
+ * @param {AuthenticatorType} type
728
+ * @param {string} otp
729
+ * @throws {AppwriteException}
730
+ * @returns {Promise}
731
+ */
732
+ updateMfaAuthenticator(type, otp) {
733
+ return __awaiter(this, void 0, void 0, function* () {
734
+ if (typeof type === 'undefined') {
735
+ throw new AppwriteException('Missing required parameter: "type"');
736
+ }
737
+ if (typeof otp === 'undefined') {
738
+ throw new AppwriteException('Missing required parameter: "otp"');
739
+ }
740
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
741
+ const payload = {};
742
+ if (typeof otp !== 'undefined') {
743
+ payload['otp'] = otp;
744
+ }
745
+ const uri = new URL(this.client.config.endpoint + apiPath);
746
+ return yield this.client.call('put', uri, {
747
+ 'content-type': 'application/json',
748
+ }, payload);
749
+ });
750
+ }
751
+ /**
752
+ * Delete Authenticator
753
+ *
754
+ * Delete an authenticator for a user by ID.
755
+ *
756
+ * @param {AuthenticatorType} type
757
+ * @param {string} otp
758
+ * @throws {AppwriteException}
759
+ * @returns {Promise}
760
+ */
761
+ deleteMfaAuthenticator(type, otp) {
762
+ return __awaiter(this, void 0, void 0, function* () {
763
+ if (typeof type === 'undefined') {
764
+ throw new AppwriteException('Missing required parameter: "type"');
765
+ }
766
+ if (typeof otp === 'undefined') {
767
+ throw new AppwriteException('Missing required parameter: "otp"');
768
+ }
769
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
770
+ const payload = {};
771
+ if (typeof otp !== 'undefined') {
772
+ payload['otp'] = otp;
773
+ }
774
+ const uri = new URL(this.client.config.endpoint + apiPath);
775
+ return yield this.client.call('delete', uri, {
776
+ 'content-type': 'application/json',
777
+ }, payload);
778
+ });
779
+ }
695
780
  /**
696
781
  * Create 2FA Challenge
697
782
  *
783
+ * Begin the process of MFA verification after sign-in. Finish the flow with
784
+ * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
785
+ * method.
698
786
  *
699
787
  * @param {AuthenticationFactor} factor
700
788
  * @throws {AppwriteException}
701
789
  * @returns {Promise}
702
790
  */
703
- createChallenge(factor) {
791
+ createMfaChallenge(factor) {
704
792
  return __awaiter(this, void 0, void 0, function* () {
705
793
  if (typeof factor === 'undefined') {
706
794
  throw new AppwriteException('Missing required parameter: "factor"');
@@ -719,14 +807,18 @@ class Account extends Service {
719
807
  /**
720
808
  * Create MFA Challenge (confirmation)
721
809
  *
722
- * Complete the MFA challenge by providing the one-time password.
810
+ * Complete the MFA challenge by providing the one-time password. Finish the
811
+ * process of MFA verification by providing the one-time password. To begin
812
+ * the flow, use
813
+ * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
814
+ * method.
723
815
  *
724
816
  * @param {string} challengeId
725
817
  * @param {string} otp
726
818
  * @throws {AppwriteException}
727
819
  * @returns {Promise}
728
820
  */
729
- updateChallenge(challengeId, otp) {
821
+ updateMfaChallenge(challengeId, otp) {
730
822
  return __awaiter(this, void 0, void 0, function* () {
731
823
  if (typeof challengeId === 'undefined') {
732
824
  throw new AppwriteException('Missing required parameter: "challengeId"');
@@ -756,7 +848,7 @@ class Account extends Service {
756
848
  * @throws {AppwriteException}
757
849
  * @returns {Promise}
758
850
  */
759
- listFactors() {
851
+ listMfaFactors() {
760
852
  return __awaiter(this, void 0, void 0, function* () {
761
853
  const apiPath = '/account/mfa/factors';
762
854
  const payload = {};
@@ -767,86 +859,65 @@ class Account extends Service {
767
859
  });
768
860
  }
769
861
  /**
770
- * Add Authenticator
862
+ * Get MFA Recovery Codes
771
863
  *
772
- * Add an authenticator app to be used as an MFA factor. Verify the
773
- * authenticator using the [verify
774
- * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
775
- * method.
864
+ * Get recovery codes that can be used as backup for MFA flow. Before getting
865
+ * codes, they must be generated using
866
+ * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
867
+ * method. An OTP challenge is required to read recovery codes.
776
868
  *
777
- * @param {AuthenticatorType} type
778
869
  * @throws {AppwriteException}
779
870
  * @returns {Promise}
780
871
  */
781
- addAuthenticator(type) {
872
+ getMfaRecoveryCodes() {
782
873
  return __awaiter(this, void 0, void 0, function* () {
783
- if (typeof type === 'undefined') {
784
- throw new AppwriteException('Missing required parameter: "type"');
785
- }
786
- const apiPath = '/account/mfa/{type}'.replace('{type}', type);
874
+ const apiPath = '/account/mfa/recovery-codes';
787
875
  const payload = {};
788
876
  const uri = new URL(this.client.config.endpoint + apiPath);
789
- return yield this.client.call('post', uri, {
877
+ return yield this.client.call('get', uri, {
790
878
  'content-type': 'application/json',
791
879
  }, payload);
792
880
  });
793
881
  }
794
882
  /**
795
- * Verify Authenticator
883
+ * Create MFA Recovery Codes
796
884
  *
797
- * Verify an authenticator app after adding it using the [add
798
- * authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
885
+ * Generate recovery codes as backup for MFA flow. It's recommended to
886
+ * generate and show then immediately after user successfully adds their
887
+ * authehticator. Recovery codes can be used as a MFA verification type in
888
+ * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
799
889
  * method.
800
890
  *
801
- * @param {AuthenticatorType} type
802
- * @param {string} otp
803
891
  * @throws {AppwriteException}
804
892
  * @returns {Promise}
805
893
  */
806
- verifyAuthenticator(type, otp) {
894
+ createMfaRecoveryCodes() {
807
895
  return __awaiter(this, void 0, void 0, function* () {
808
- if (typeof type === 'undefined') {
809
- throw new AppwriteException('Missing required parameter: "type"');
810
- }
811
- if (typeof otp === 'undefined') {
812
- throw new AppwriteException('Missing required parameter: "otp"');
813
- }
814
- const apiPath = '/account/mfa/{type}'.replace('{type}', type);
896
+ const apiPath = '/account/mfa/recovery-codes';
815
897
  const payload = {};
816
- if (typeof otp !== 'undefined') {
817
- payload['otp'] = otp;
818
- }
819
898
  const uri = new URL(this.client.config.endpoint + apiPath);
820
- return yield this.client.call('put', uri, {
899
+ return yield this.client.call('post', uri, {
821
900
  'content-type': 'application/json',
822
901
  }, payload);
823
902
  });
824
903
  }
825
904
  /**
826
- * Delete Authenticator
905
+ * Regenerate MFA Recovery Codes
827
906
  *
828
- * Delete an authenticator for a user by ID.
907
+ * Regenerate recovery codes that can be used as backup for MFA flow. Before
908
+ * regenerating codes, they must be first generated using
909
+ * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
910
+ * method. An OTP challenge is required to regenreate recovery codes.
829
911
  *
830
- * @param {AuthenticatorType} type
831
- * @param {string} otp
832
912
  * @throws {AppwriteException}
833
913
  * @returns {Promise}
834
914
  */
835
- deleteAuthenticator(type, otp) {
915
+ updateMfaRecoveryCodes() {
836
916
  return __awaiter(this, void 0, void 0, function* () {
837
- if (typeof type === 'undefined') {
838
- throw new AppwriteException('Missing required parameter: "type"');
839
- }
840
- if (typeof otp === 'undefined') {
841
- throw new AppwriteException('Missing required parameter: "otp"');
842
- }
843
- const apiPath = '/account/mfa/{type}'.replace('{type}', type);
917
+ const apiPath = '/account/mfa/recovery-codes';
844
918
  const payload = {};
845
- if (typeof otp !== 'undefined') {
846
- payload['otp'] = otp;
847
- }
848
919
  const uri = new URL(this.client.config.endpoint + apiPath);
849
- return yield this.client.call('delete', uri, {
920
+ return yield this.client.call('patch', uri, {
850
921
  'content-type': 'application/json',
851
922
  }, payload);
852
923
  });
@@ -1354,10 +1425,11 @@ class Account extends Service {
1354
1425
  });
1355
1426
  }
1356
1427
  /**
1357
- * Update (or renew) session
1428
+ * Update session
1358
1429
  *
1359
- * Extend session's expiry to increase it's lifespan. Extending a session is
1360
- * useful when session length is short such as 5 minutes.
1430
+ * Use this endpoint to extend a session's length. Extending a session is
1431
+ * useful when session expiry is short. If the session was created using an
1432
+ * OAuth provider, this endpoint refreshes the access token from the provider.
1361
1433
  *
1362
1434
  * @param {string} sessionId
1363
1435
  * @throws {AppwriteException}
@@ -11677,6 +11749,32 @@ class Users extends Service {
11677
11749
  }, payload);
11678
11750
  });
11679
11751
  }
11752
+ /**
11753
+ * Delete Authenticator
11754
+ *
11755
+ * Delete an authenticator app.
11756
+ *
11757
+ * @param {string} userId
11758
+ * @param {Type} type
11759
+ * @throws {AppwriteException}
11760
+ * @returns {Promise}
11761
+ */
11762
+ deleteMfaAuthenticator(userId, type) {
11763
+ return __awaiter(this, void 0, void 0, function* () {
11764
+ if (typeof userId === 'undefined') {
11765
+ throw new AppwriteException('Missing required parameter: "userId"');
11766
+ }
11767
+ if (typeof type === 'undefined') {
11768
+ throw new AppwriteException('Missing required parameter: "type"');
11769
+ }
11770
+ const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type);
11771
+ const payload = {};
11772
+ const uri = new URL(this.client.config.endpoint + apiPath);
11773
+ return yield this.client.call('delete', uri, {
11774
+ 'content-type': 'application/json',
11775
+ }, payload);
11776
+ });
11777
+ }
11680
11778
  /**
11681
11779
  * List Factors
11682
11780
  *
@@ -11686,7 +11784,7 @@ class Users extends Service {
11686
11784
  * @throws {AppwriteException}
11687
11785
  * @returns {Promise}
11688
11786
  */
11689
- listFactors(userId) {
11787
+ listMfaFactors(userId) {
11690
11788
  return __awaiter(this, void 0, void 0, function* () {
11691
11789
  if (typeof userId === 'undefined') {
11692
11790
  throw new AppwriteException('Missing required parameter: "userId"');
@@ -11700,27 +11798,76 @@ class Users extends Service {
11700
11798
  });
11701
11799
  }
11702
11800
  /**
11703
- * Delete Authenticator
11801
+ * Get MFA Recovery Codes
11704
11802
  *
11705
- * Delete an authenticator app.
11803
+ * Get recovery codes that can be used as backup for MFA flow by User ID.
11804
+ * Before getting codes, they must be generated using
11805
+ * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
11806
+ * method.
11706
11807
  *
11707
11808
  * @param {string} userId
11708
- * @param {AuthenticatorType} type
11709
11809
  * @throws {AppwriteException}
11710
11810
  * @returns {Promise}
11711
11811
  */
11712
- deleteAuthenticator(userId, type) {
11812
+ getMfaRecoveryCodes(userId) {
11713
11813
  return __awaiter(this, void 0, void 0, function* () {
11714
11814
  if (typeof userId === 'undefined') {
11715
11815
  throw new AppwriteException('Missing required parameter: "userId"');
11716
11816
  }
11717
- if (typeof type === 'undefined') {
11718
- throw new AppwriteException('Missing required parameter: "type"');
11817
+ const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId);
11818
+ const payload = {};
11819
+ const uri = new URL(this.client.config.endpoint + apiPath);
11820
+ return yield this.client.call('get', uri, {
11821
+ 'content-type': 'application/json',
11822
+ }, payload);
11823
+ });
11824
+ }
11825
+ /**
11826
+ * Regenerate MFA Recovery Codes
11827
+ *
11828
+ * Regenerate recovery codes that can be used as backup for MFA flow by User
11829
+ * ID. Before regenerating codes, they must be first generated using
11830
+ * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
11831
+ * method.
11832
+ *
11833
+ * @param {string} userId
11834
+ * @throws {AppwriteException}
11835
+ * @returns {Promise}
11836
+ */
11837
+ updateMfaRecoveryCodes(userId) {
11838
+ return __awaiter(this, void 0, void 0, function* () {
11839
+ if (typeof userId === 'undefined') {
11840
+ throw new AppwriteException('Missing required parameter: "userId"');
11719
11841
  }
11720
- const apiPath = '/users/{userId}/mfa/{type}'.replace('{userId}', userId).replace('{type}', type);
11842
+ const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId);
11721
11843
  const payload = {};
11722
11844
  const uri = new URL(this.client.config.endpoint + apiPath);
11723
- return yield this.client.call('delete', uri, {
11845
+ return yield this.client.call('put', uri, {
11846
+ 'content-type': 'application/json',
11847
+ }, payload);
11848
+ });
11849
+ }
11850
+ /**
11851
+ * Create MFA Recovery Codes
11852
+ *
11853
+ * Generate recovery codes used as backup for MFA flow for User ID. Recovery
11854
+ * codes can be used as a MFA verification type in
11855
+ * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
11856
+ * method by client SDK.
11857
+ *
11858
+ * @param {string} userId
11859
+ * @throws {AppwriteException}
11860
+ * @returns {Promise}
11861
+ */
11862
+ createMfaRecoveryCodes(userId) {
11863
+ return __awaiter(this, void 0, void 0, function* () {
11864
+ if (typeof userId === 'undefined') {
11865
+ throw new AppwriteException('Missing required parameter: "userId"');
11866
+ }
11867
+ const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId);
11868
+ const payload = {};
11869
+ const uri = new URL(this.client.config.endpoint + apiPath);
11870
+ return yield this.client.call('patch', uri, {
11724
11871
  'content-type': 'application/json',
11725
11872
  }, payload);
11726
11873
  });
@@ -12618,18 +12765,19 @@ class ID {
12618
12765
  }
12619
12766
  }
12620
12767
 
12621
- exports.AuthenticationFactor = void 0;
12622
- (function (AuthenticationFactor) {
12623
- AuthenticationFactor["Totp"] = "totp";
12624
- AuthenticationFactor["Phone"] = "phone";
12625
- AuthenticationFactor["Email"] = "email";
12626
- })(exports.AuthenticationFactor || (exports.AuthenticationFactor = {}));
12627
-
12628
12768
  exports.AuthenticatorType = void 0;
12629
12769
  (function (AuthenticatorType) {
12630
12770
  AuthenticatorType["Totp"] = "totp";
12631
12771
  })(exports.AuthenticatorType || (exports.AuthenticatorType = {}));
12632
12772
 
12773
+ exports.AuthenticationFactor = void 0;
12774
+ (function (AuthenticationFactor) {
12775
+ AuthenticationFactor["Email"] = "email";
12776
+ AuthenticationFactor["Phone"] = "phone";
12777
+ AuthenticationFactor["Totp"] = "totp";
12778
+ AuthenticationFactor["Recoverycode"] = "recoverycode";
12779
+ })(exports.AuthenticationFactor || (exports.AuthenticationFactor = {}));
12780
+
12633
12781
  exports.OAuthProvider = void 0;
12634
12782
  (function (OAuthProvider) {
12635
12783
  OAuthProvider["Amazon"] = "amazon";
@@ -13429,6 +13577,11 @@ exports.UserUsageRange = void 0;
13429
13577
  UserUsageRange["NinetyDays"] = "90d";
13430
13578
  })(exports.UserUsageRange || (exports.UserUsageRange = {}));
13431
13579
 
13580
+ exports.Type = void 0;
13581
+ (function (Type) {
13582
+ Type["Totp"] = "totp";
13583
+ })(exports.Type || (exports.Type = {}));
13584
+
13432
13585
  exports.MessagingProviderType = void 0;
13433
13586
  (function (MessagingProviderType) {
13434
13587
  MessagingProviderType["Email"] = "email";