@takeal/cusfront-sdk 0.8.0 → 0.8.3

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/dist/telegram.js CHANGED
@@ -774,13 +774,41 @@ var AuthResource = class {
774
774
  }
775
775
  /** Change the signed-in user's password. Every other session of the
776
776
  * account is signed out; this one stays valid.
777
- * Errors: 400 when the new password fails the policy, 401 when the
778
- * current one is wrong. */
777
+ * Errors: 400 `weak_password` when the new password fails the policy,
778
+ * 400 `no_password` when the account has none yet (use
779
+ * {@link requestPasswordSetup}), 401 when the current one is wrong. */
779
780
  async changePassword(input) {
780
781
  return this.http.post("/auth/password", {
781
782
  body: input
782
783
  });
783
784
  }
785
+ /** Step one of setting the first password of an account that has none
786
+ * (`user.has_password === false`, e.g. made by signing in with an e-mail
787
+ * code): a six-digit code goes to the account's address and works for 5
788
+ * minutes. Nothing changes yet.
789
+ * Errors: 409 `password_exists` (use {@link changePassword}),
790
+ * `email_required` (a Telegram account with no address yet: attach one
791
+ * with {@link requestEmailChange} first), `email_not_proven` (sign in
792
+ * with an e-mail code first); 429 `too_many_requests` (five codes an
793
+ * hour); 503 `delivery_failed`. Platform 0.8.2 and newer. */
794
+ async requestPasswordSetup() {
795
+ return this.http.post("/auth/password/setup", {});
796
+ }
797
+ /** Step two: the code from the e-mail and the new password set the
798
+ * account's first password. Every other session of the account is signed
799
+ * out; this one stays valid, and signing in with a code keeps working.
800
+ * Errors: 400 `weak_password` (the code is not used up, fix the password
801
+ * and send again), 401 `invalid_code` (after five wrong codes ask for a
802
+ * new one), 409 `password_exists`. */
803
+ async confirmPasswordSetup(input) {
804
+ return this.http.post("/auth/password/setup/confirm", {
805
+ body: {
806
+ challenge_id: input.challengeId,
807
+ code: input.code,
808
+ new_password: input.newPassword
809
+ }
810
+ });
811
+ }
784
812
  /** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
785
813
  * telegram/email; for TOTP it short-circuits back to the challenge. */
786
814
  async switchMethod(input) {
@@ -833,10 +861,12 @@ var AuthResource = class {
833
861
  await Promise.resolve(this.tokens.set(resp.access_token));
834
862
  return resp;
835
863
  }
836
- /** Attach the first real email to a Telegram-made account (and clear
837
- * `email_pending`). 409 if taken. An account that already has a real
838
- * address gets 409 `email_change_needs_code`: change it with
839
- * {@link requestEmailChange} and {@link confirmEmailChange}. */
864
+ /** Always answers 409 `email_change_needs_code` on platform 0.8.1 and
865
+ * newer: an address is attached only after a code sent to it comes back.
866
+ * For the first real email of a Telegram-made account use
867
+ * {@link requestEmailChange} and {@link confirmEmailChange}; they clear
868
+ * `email_pending` too.
869
+ * @deprecated Use {@link requestEmailChange} and {@link confirmEmailChange}. */
840
870
  async linkEmail(input) {
841
871
  return this.http.post("/me/email", { body: { email: input.email } });
842
872
  }
@@ -1714,7 +1744,7 @@ var FundingOptionsResource = class {
1714
1744
  };
1715
1745
 
1716
1746
  // src/version.ts
1717
- var SDK_VERSION = "0.8.0";
1747
+ var SDK_VERSION = "0.8.3";
1718
1748
 
1719
1749
  // src/client-platform.ts
1720
1750
  var CLIENT_HEADER = "X-Takeal-Client";