@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/react/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { CusfrontClient } from '../index.cjs';
|
|
4
4
|
import { User } from '../resources/auth.cjs';
|
|
5
|
-
import { C as CardProduct, a as Card, D as Deposit } from '../cards-
|
|
5
|
+
import { C as CardProduct, a as Card, D as Deposit } from '../cards-DwxkVJUB.cjs';
|
|
6
6
|
import { Balance } from '../resources/balance.cjs';
|
|
7
7
|
import { NotificationPage, InboxItem, NotificationCategory } from '../resources/notifications.cjs';
|
|
8
8
|
import '../http-CL97TjMO.cjs';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { CusfrontClient } from '../index.js';
|
|
4
4
|
import { User } from '../resources/auth.js';
|
|
5
|
-
import { C as CardProduct, a as Card, D as Deposit } from '../cards-
|
|
5
|
+
import { C as CardProduct, a as Card, D as Deposit } from '../cards-VkS_2lPe.js';
|
|
6
6
|
import { Balance } from '../resources/balance.js';
|
|
7
7
|
import { NotificationPage, InboxItem, NotificationCategory } from '../resources/notifications.js';
|
|
8
8
|
import '../http-CL97TjMO.js';
|
package/dist/resources/auth.cjs
CHANGED
|
@@ -155,12 +155,17 @@ var AuthResource = class {
|
|
|
155
155
|
return resp;
|
|
156
156
|
}
|
|
157
157
|
/** Verify a TOTP code (or XXXX-XXXX backup code) against a
|
|
158
|
-
* `totp_required` challenge. On success the JWT is stored.
|
|
158
|
+
* `totp_required` challenge. On success the JWT is stored. A backup code
|
|
159
|
+
* signs nobody in: it is used up and the answer is
|
|
160
|
+
* `totp_setup_email_required`, the start of connecting a new
|
|
161
|
+
* authenticator ({@link confirmTotpSetupEmail}). Nothing is stored then.
|
|
162
|
+
* Errors after a backup code: see {@link TotpSetupEmailErrorCode}. */
|
|
159
163
|
async verifyTotp(input) {
|
|
160
164
|
const resp = await this.http.post("/auth/login/totp", {
|
|
161
165
|
body: withRemember(input),
|
|
162
166
|
skipAuth: true
|
|
163
167
|
});
|
|
168
|
+
if (resp.stage === "totp_setup_email_required") return resp;
|
|
164
169
|
await this.keep(resp);
|
|
165
170
|
return resp;
|
|
166
171
|
}
|
|
@@ -233,6 +238,28 @@ var AuthResource = class {
|
|
|
233
238
|
await this.keep(resp);
|
|
234
239
|
return resp;
|
|
235
240
|
}
|
|
241
|
+
/** Send the code from the e-mail of a `totp_setup_email_required`
|
|
242
|
+
* answer. A right code answers `totp_setup_required`: show its
|
|
243
|
+
* `otpauth_url` as a QR, then finish with {@link completeTotpSetup}.
|
|
244
|
+
* Each code works for 5 minutes and takes five tries; only the newest
|
|
245
|
+
* one works. Nothing is stored. Errors: {@link TotpSetupEmailErrorCode}. */
|
|
246
|
+
async confirmTotpSetupEmail(input) {
|
|
247
|
+
return this.http.post("/auth/login/totp-setup/email", {
|
|
248
|
+
body: { challenge_token: input.challenge_token, code: input.code },
|
|
249
|
+
skipAuth: true
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/** A new e-mail code for the same `totp_setup_email_required` sign-in;
|
|
253
|
+
* the one before it stops working. Use the `challenge_token` of the
|
|
254
|
+
* answer from now on. Five codes an hour at most.
|
|
255
|
+
* Errors: {@link TotpSetupEmailErrorCode}; 401 means the sign-in is over,
|
|
256
|
+
* so start again with {@link login}. */
|
|
257
|
+
async resendTotpSetupEmail(input) {
|
|
258
|
+
return this.http.post("/auth/login/totp-setup/email/resend", {
|
|
259
|
+
body: { challenge_token: input.challenge_token },
|
|
260
|
+
skipAuth: true
|
|
261
|
+
});
|
|
262
|
+
}
|
|
236
263
|
/** Finish a `totp_setup_required` login: send the first code from the
|
|
237
264
|
* authenticator app. The JWT is stored. The response carries ten
|
|
238
265
|
* one-time `backup_codes` that are never returned again, so show them to
|
|
@@ -247,13 +274,41 @@ var AuthResource = class {
|
|
|
247
274
|
}
|
|
248
275
|
/** Change the signed-in user's password. Every other session of the
|
|
249
276
|
* account is signed out; this one stays valid.
|
|
250
|
-
* Errors: 400 when the new password fails the policy,
|
|
251
|
-
*
|
|
277
|
+
* Errors: 400 `weak_password` when the new password fails the policy,
|
|
278
|
+
* 400 `no_password` when the account has none yet (use
|
|
279
|
+
* {@link requestPasswordSetup}), 401 when the current one is wrong. */
|
|
252
280
|
async changePassword(input) {
|
|
253
281
|
return this.http.post("/auth/password", {
|
|
254
282
|
body: input
|
|
255
283
|
});
|
|
256
284
|
}
|
|
285
|
+
/** Step one of setting the first password of an account that has none
|
|
286
|
+
* (`user.has_password === false`, e.g. made by signing in with an e-mail
|
|
287
|
+
* code): a six-digit code goes to the account's address and works for 5
|
|
288
|
+
* minutes. Nothing changes yet.
|
|
289
|
+
* Errors: 409 `password_exists` (use {@link changePassword}),
|
|
290
|
+
* `email_required` (a Telegram account with no address yet: attach one
|
|
291
|
+
* with {@link requestEmailChange} first), `email_not_proven` (sign in
|
|
292
|
+
* with an e-mail code first); 429 `too_many_requests` (five codes an
|
|
293
|
+
* hour); 503 `delivery_failed`. Platform 0.8.2 and newer. */
|
|
294
|
+
async requestPasswordSetup() {
|
|
295
|
+
return this.http.post("/auth/password/setup", {});
|
|
296
|
+
}
|
|
297
|
+
/** Step two: the code from the e-mail and the new password set the
|
|
298
|
+
* account's first password. Every other session of the account is signed
|
|
299
|
+
* out; this one stays valid, and signing in with a code keeps working.
|
|
300
|
+
* Errors: 400 `weak_password` (the code is not used up, fix the password
|
|
301
|
+
* and send again), 401 `invalid_code` (after five wrong codes ask for a
|
|
302
|
+
* new one), 409 `password_exists`. */
|
|
303
|
+
async confirmPasswordSetup(input) {
|
|
304
|
+
return this.http.post("/auth/password/setup/confirm", {
|
|
305
|
+
body: {
|
|
306
|
+
challenge_id: input.challengeId,
|
|
307
|
+
code: input.code,
|
|
308
|
+
new_password: input.newPassword
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
257
312
|
/** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
|
|
258
313
|
* telegram/email; for TOTP it short-circuits back to the challenge. */
|
|
259
314
|
async switchMethod(input) {
|