@takeal/cusfront-sdk 0.8.1 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -1
- package/README.md +49 -7
- package/dist/{cards-BPu8Ill7.d.cts → cards-DwxkVJUB.d.cts} +36 -3
- package/dist/{cards-DP1fJc_c.d.ts → cards-VkS_2lPe.d.ts} +36 -3
- package/dist/index.cjs +59 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +59 -4
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/resources/auth.cjs +58 -3
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +102 -7
- package/dist/resources/auth.d.ts +102 -7
- package/dist/resources/auth.js +58 -3
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.d.cts +1 -1
- package/dist/resources/cards.d.ts +1 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +1 -1
- package/dist/resources/deposits.d.ts +1 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +1 -1
- package/dist/resources/funding-options.d.ts +1 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/resources/subscription.cjs.map +1 -1
- package/dist/resources/subscription.d.cts +4 -0
- package/dist/resources/subscription.d.ts +4 -0
- package/dist/resources/subscription.js.map +1 -1
- package/dist/telegram.cjs +59 -4
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +1 -1
- package/dist/telegram.d.ts +1 -1
- package/dist/telegram.js +59 -4
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
package/dist/telegram.cjs
CHANGED
|
@@ -684,12 +684,17 @@ var AuthResource = class {
|
|
|
684
684
|
return resp;
|
|
685
685
|
}
|
|
686
686
|
/** Verify a TOTP code (or XXXX-XXXX backup code) against a
|
|
687
|
-
* `totp_required` challenge. On success the JWT is stored.
|
|
687
|
+
* `totp_required` challenge. On success the JWT is stored. A backup code
|
|
688
|
+
* signs nobody in: it is used up and the answer is
|
|
689
|
+
* `totp_setup_email_required`, the start of connecting a new
|
|
690
|
+
* authenticator ({@link confirmTotpSetupEmail}). Nothing is stored then.
|
|
691
|
+
* Errors after a backup code: see {@link TotpSetupEmailErrorCode}. */
|
|
688
692
|
async verifyTotp(input) {
|
|
689
693
|
const resp = await this.http.post("/auth/login/totp", {
|
|
690
694
|
body: withRemember(input),
|
|
691
695
|
skipAuth: true
|
|
692
696
|
});
|
|
697
|
+
if (resp.stage === "totp_setup_email_required") return resp;
|
|
693
698
|
await this.keep(resp);
|
|
694
699
|
return resp;
|
|
695
700
|
}
|
|
@@ -762,6 +767,28 @@ var AuthResource = class {
|
|
|
762
767
|
await this.keep(resp);
|
|
763
768
|
return resp;
|
|
764
769
|
}
|
|
770
|
+
/** Send the code from the e-mail of a `totp_setup_email_required`
|
|
771
|
+
* answer. A right code answers `totp_setup_required`: show its
|
|
772
|
+
* `otpauth_url` as a QR, then finish with {@link completeTotpSetup}.
|
|
773
|
+
* Each code works for 5 minutes and takes five tries; only the newest
|
|
774
|
+
* one works. Nothing is stored. Errors: {@link TotpSetupEmailErrorCode}. */
|
|
775
|
+
async confirmTotpSetupEmail(input) {
|
|
776
|
+
return this.http.post("/auth/login/totp-setup/email", {
|
|
777
|
+
body: { challenge_token: input.challenge_token, code: input.code },
|
|
778
|
+
skipAuth: true
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
/** A new e-mail code for the same `totp_setup_email_required` sign-in;
|
|
782
|
+
* the one before it stops working. Use the `challenge_token` of the
|
|
783
|
+
* answer from now on. Five codes an hour at most.
|
|
784
|
+
* Errors: {@link TotpSetupEmailErrorCode}; 401 means the sign-in is over,
|
|
785
|
+
* so start again with {@link login}. */
|
|
786
|
+
async resendTotpSetupEmail(input) {
|
|
787
|
+
return this.http.post("/auth/login/totp-setup/email/resend", {
|
|
788
|
+
body: { challenge_token: input.challenge_token },
|
|
789
|
+
skipAuth: true
|
|
790
|
+
});
|
|
791
|
+
}
|
|
765
792
|
/** Finish a `totp_setup_required` login: send the first code from the
|
|
766
793
|
* authenticator app. The JWT is stored. The response carries ten
|
|
767
794
|
* one-time `backup_codes` that are never returned again, so show them to
|
|
@@ -776,13 +803,41 @@ var AuthResource = class {
|
|
|
776
803
|
}
|
|
777
804
|
/** Change the signed-in user's password. Every other session of the
|
|
778
805
|
* account is signed out; this one stays valid.
|
|
779
|
-
* Errors: 400 when the new password fails the policy,
|
|
780
|
-
*
|
|
806
|
+
* Errors: 400 `weak_password` when the new password fails the policy,
|
|
807
|
+
* 400 `no_password` when the account has none yet (use
|
|
808
|
+
* {@link requestPasswordSetup}), 401 when the current one is wrong. */
|
|
781
809
|
async changePassword(input) {
|
|
782
810
|
return this.http.post("/auth/password", {
|
|
783
811
|
body: input
|
|
784
812
|
});
|
|
785
813
|
}
|
|
814
|
+
/** Step one of setting the first password of an account that has none
|
|
815
|
+
* (`user.has_password === false`, e.g. made by signing in with an e-mail
|
|
816
|
+
* code): a six-digit code goes to the account's address and works for 5
|
|
817
|
+
* minutes. Nothing changes yet.
|
|
818
|
+
* Errors: 409 `password_exists` (use {@link changePassword}),
|
|
819
|
+
* `email_required` (a Telegram account with no address yet: attach one
|
|
820
|
+
* with {@link requestEmailChange} first), `email_not_proven` (sign in
|
|
821
|
+
* with an e-mail code first); 429 `too_many_requests` (five codes an
|
|
822
|
+
* hour); 503 `delivery_failed`. Platform 0.8.2 and newer. */
|
|
823
|
+
async requestPasswordSetup() {
|
|
824
|
+
return this.http.post("/auth/password/setup", {});
|
|
825
|
+
}
|
|
826
|
+
/** Step two: the code from the e-mail and the new password set the
|
|
827
|
+
* account's first password. Every other session of the account is signed
|
|
828
|
+
* out; this one stays valid, and signing in with a code keeps working.
|
|
829
|
+
* Errors: 400 `weak_password` (the code is not used up, fix the password
|
|
830
|
+
* and send again), 401 `invalid_code` (after five wrong codes ask for a
|
|
831
|
+
* new one), 409 `password_exists`. */
|
|
832
|
+
async confirmPasswordSetup(input) {
|
|
833
|
+
return this.http.post("/auth/password/setup/confirm", {
|
|
834
|
+
body: {
|
|
835
|
+
challenge_id: input.challengeId,
|
|
836
|
+
code: input.code,
|
|
837
|
+
new_password: input.newPassword
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
}
|
|
786
841
|
/** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
|
|
787
842
|
* telegram/email; for TOTP it short-circuits back to the challenge. */
|
|
788
843
|
async switchMethod(input) {
|
|
@@ -1718,7 +1773,7 @@ var FundingOptionsResource = class {
|
|
|
1718
1773
|
};
|
|
1719
1774
|
|
|
1720
1775
|
// src/version.ts
|
|
1721
|
-
var SDK_VERSION = "0.8.
|
|
1776
|
+
var SDK_VERSION = "0.8.4";
|
|
1722
1777
|
|
|
1723
1778
|
// src/client-platform.ts
|
|
1724
1779
|
var CLIENT_HEADER = "X-Takeal-Client";
|