@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/CHANGELOG.md +70 -0
- package/README.md +27 -1
- package/dist/analytics.cjs +88 -7
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.d.cts +30 -2
- package/dist/analytics.d.ts +30 -2
- package/dist/analytics.js +86 -8
- package/dist/analytics.js.map +1 -1
- package/dist/index.cjs +122 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +122 -14
- package/dist/index.js.map +1 -1
- package/dist/resources/auth.cjs +36 -6
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +56 -7
- package/dist/resources/auth.d.ts +56 -7
- package/dist/resources/auth.js +36 -6
- package/dist/resources/auth.js.map +1 -1
- package/dist/telegram.cjs +37 -7
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.js +37 -7
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,13 @@ interface User {
|
|
|
38
38
|
/** The Telegram account linked to this user, or `null` when none is.
|
|
39
39
|
* Present on `GET /auth/me` and inside every `stage: "jwt"` envelope. */
|
|
40
40
|
telegram?: TelegramLink | null;
|
|
41
|
+
/** Whether the account has a password. `false` for an account that signs
|
|
42
|
+
* in with codes only: offer "set a password"
|
|
43
|
+
* ({@link AuthResource.requestPasswordSetup}) instead of "change password"
|
|
44
|
+
* ({@link AuthResource.changePassword}). Present on `GET /auth/me` and
|
|
45
|
+
* inside every `stage: "jwt"` envelope from platform 0.8.2; absent on
|
|
46
|
+
* older servers. */
|
|
47
|
+
has_password?: boolean;
|
|
41
48
|
}
|
|
42
49
|
/** A Telegram account attached to a user. One Telegram per account and one
|
|
43
50
|
* account per Telegram. */
|
|
@@ -230,6 +237,10 @@ interface VerifyEmailCodeInput {
|
|
|
230
237
|
type EmailCodeSession = JwtIssued & {
|
|
231
238
|
/** `true` when the address had no account and got one with this code. */
|
|
232
239
|
account_created: boolean;
|
|
240
|
+
/** `true` when this code proved the mailbox of an existing account for
|
|
241
|
+
* the first time and the password and linked sign-ins set before that
|
|
242
|
+
* were removed. */
|
|
243
|
+
credentials_reset?: boolean;
|
|
233
244
|
card_order?: CardOrder;
|
|
234
245
|
card_order_error?: CardOrderError;
|
|
235
246
|
};
|
|
@@ -251,6 +262,22 @@ interface TotpSetupComplete extends Session {
|
|
|
251
262
|
/** Ten one-time `XXXX-XXXX` codes, returned only this once. */
|
|
252
263
|
backup_codes: string[];
|
|
253
264
|
}
|
|
265
|
+
/** What `requestPasswordSetup` returns: send `challengeId` back with the
|
|
266
|
+
* code and the new password. */
|
|
267
|
+
interface PasswordSetupRequested {
|
|
268
|
+
challenge_id: string;
|
|
269
|
+
/** Where the code went, partly hidden: `al***@example.com`. */
|
|
270
|
+
destination_hint: string;
|
|
271
|
+
expires_at: string;
|
|
272
|
+
}
|
|
273
|
+
interface ConfirmPasswordSetupInput {
|
|
274
|
+
challengeId: string;
|
|
275
|
+
/** The six digits from the e-mail. */
|
|
276
|
+
code: string;
|
|
277
|
+
/** At least 12 characters with a lower-case letter, an upper-case letter
|
|
278
|
+
* and a digit. */
|
|
279
|
+
newPassword: string;
|
|
280
|
+
}
|
|
254
281
|
interface ChangePasswordInput {
|
|
255
282
|
current_password: string;
|
|
256
283
|
/** At least 12 characters with a lower-case letter, an upper-case letter
|
|
@@ -321,11 +348,31 @@ declare class AuthResource {
|
|
|
321
348
|
completeTotpSetup(input: TotpVerifyInput): Promise<TotpSetupComplete>;
|
|
322
349
|
/** Change the signed-in user's password. Every other session of the
|
|
323
350
|
* account is signed out; this one stays valid.
|
|
324
|
-
* Errors: 400 when the new password fails the policy,
|
|
325
|
-
*
|
|
351
|
+
* Errors: 400 `weak_password` when the new password fails the policy,
|
|
352
|
+
* 400 `no_password` when the account has none yet (use
|
|
353
|
+
* {@link requestPasswordSetup}), 401 when the current one is wrong. */
|
|
326
354
|
changePassword(input: ChangePasswordInput): Promise<{
|
|
327
355
|
revoked_sessions: number;
|
|
328
356
|
}>;
|
|
357
|
+
/** Step one of setting the first password of an account that has none
|
|
358
|
+
* (`user.has_password === false`, e.g. made by signing in with an e-mail
|
|
359
|
+
* code): a six-digit code goes to the account's address and works for 5
|
|
360
|
+
* minutes. Nothing changes yet.
|
|
361
|
+
* Errors: 409 `password_exists` (use {@link changePassword}),
|
|
362
|
+
* `email_required` (a Telegram account with no address yet: attach one
|
|
363
|
+
* with {@link requestEmailChange} first), `email_not_proven` (sign in
|
|
364
|
+
* with an e-mail code first); 429 `too_many_requests` (five codes an
|
|
365
|
+
* hour); 503 `delivery_failed`. Platform 0.8.2 and newer. */
|
|
366
|
+
requestPasswordSetup(): Promise<PasswordSetupRequested>;
|
|
367
|
+
/** Step two: the code from the e-mail and the new password set the
|
|
368
|
+
* account's first password. Every other session of the account is signed
|
|
369
|
+
* out; this one stays valid, and signing in with a code keeps working.
|
|
370
|
+
* Errors: 400 `weak_password` (the code is not used up, fix the password
|
|
371
|
+
* and send again), 401 `invalid_code` (after five wrong codes ask for a
|
|
372
|
+
* new one), 409 `password_exists`. */
|
|
373
|
+
confirmPasswordSetup(input: ConfirmPasswordSetupInput): Promise<{
|
|
374
|
+
revoked_sessions: number;
|
|
375
|
+
}>;
|
|
329
376
|
/** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
|
|
330
377
|
* telegram/email; for TOTP it short-circuits back to the challenge. */
|
|
331
378
|
switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse>;
|
|
@@ -362,10 +409,12 @@ declare class AuthResource {
|
|
|
362
409
|
* Telegram; unlink it first) / `telegram_in_use` (this Telegram belongs to
|
|
363
410
|
* another account); 503 `telegram_not_configured`. */
|
|
364
411
|
linkTelegram(input: LinkTelegramInput): Promise<JwtIssued>;
|
|
365
|
-
/**
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
* {@link requestEmailChange} and {@link confirmEmailChange}
|
|
412
|
+
/** Always answers 409 `email_change_needs_code` on platform 0.8.1 and
|
|
413
|
+
* newer: an address is attached only after a code sent to it comes back.
|
|
414
|
+
* For the first real email of a Telegram-made account use
|
|
415
|
+
* {@link requestEmailChange} and {@link confirmEmailChange}; they clear
|
|
416
|
+
* `email_pending` too.
|
|
417
|
+
* @deprecated Use {@link requestEmailChange} and {@link confirmEmailChange}. */
|
|
369
418
|
linkEmail(input: {
|
|
370
419
|
email: string;
|
|
371
420
|
}): Promise<User>;
|
|
@@ -392,4 +441,4 @@ declare class AuthResource {
|
|
|
392
441
|
signOut(): Promise<void>;
|
|
393
442
|
}
|
|
394
443
|
|
|
395
|
-
export { AuthResource, type AvailableMethod, type ChangePasswordInput, type EmailChangeRequested, type EmailCodeSent, type EmailCodeSession, type ExchangeTelegramInput, type JwtIssued, type LinkTelegramInput, type LoginInput, type LoginResponse, type OtpSentResponse, type OtpVerifyInput, type RegisterInput, type RequestEmailCodeInput, type Session, type SwitchMethodInput, type TelegramLink, type TelegramUnknown, type TotpRequired, type TotpSetupComplete, type TotpSetupRequired, type TotpVerifyInput, type User, type VerifyEmailCodeInput };
|
|
444
|
+
export { AuthResource, type AvailableMethod, type ChangePasswordInput, type ConfirmPasswordSetupInput, type EmailChangeRequested, type EmailCodeSent, type EmailCodeSession, type ExchangeTelegramInput, type JwtIssued, type LinkTelegramInput, type LoginInput, type LoginResponse, type OtpSentResponse, type OtpVerifyInput, type PasswordSetupRequested, type RegisterInput, type RequestEmailCodeInput, type Session, type SwitchMethodInput, type TelegramLink, type TelegramUnknown, type TotpRequired, type TotpSetupComplete, type TotpSetupRequired, type TotpVerifyInput, type User, type VerifyEmailCodeInput };
|
package/dist/resources/auth.d.ts
CHANGED
|
@@ -38,6 +38,13 @@ interface User {
|
|
|
38
38
|
/** The Telegram account linked to this user, or `null` when none is.
|
|
39
39
|
* Present on `GET /auth/me` and inside every `stage: "jwt"` envelope. */
|
|
40
40
|
telegram?: TelegramLink | null;
|
|
41
|
+
/** Whether the account has a password. `false` for an account that signs
|
|
42
|
+
* in with codes only: offer "set a password"
|
|
43
|
+
* ({@link AuthResource.requestPasswordSetup}) instead of "change password"
|
|
44
|
+
* ({@link AuthResource.changePassword}). Present on `GET /auth/me` and
|
|
45
|
+
* inside every `stage: "jwt"` envelope from platform 0.8.2; absent on
|
|
46
|
+
* older servers. */
|
|
47
|
+
has_password?: boolean;
|
|
41
48
|
}
|
|
42
49
|
/** A Telegram account attached to a user. One Telegram per account and one
|
|
43
50
|
* account per Telegram. */
|
|
@@ -230,6 +237,10 @@ interface VerifyEmailCodeInput {
|
|
|
230
237
|
type EmailCodeSession = JwtIssued & {
|
|
231
238
|
/** `true` when the address had no account and got one with this code. */
|
|
232
239
|
account_created: boolean;
|
|
240
|
+
/** `true` when this code proved the mailbox of an existing account for
|
|
241
|
+
* the first time and the password and linked sign-ins set before that
|
|
242
|
+
* were removed. */
|
|
243
|
+
credentials_reset?: boolean;
|
|
233
244
|
card_order?: CardOrder;
|
|
234
245
|
card_order_error?: CardOrderError;
|
|
235
246
|
};
|
|
@@ -251,6 +262,22 @@ interface TotpSetupComplete extends Session {
|
|
|
251
262
|
/** Ten one-time `XXXX-XXXX` codes, returned only this once. */
|
|
252
263
|
backup_codes: string[];
|
|
253
264
|
}
|
|
265
|
+
/** What `requestPasswordSetup` returns: send `challengeId` back with the
|
|
266
|
+
* code and the new password. */
|
|
267
|
+
interface PasswordSetupRequested {
|
|
268
|
+
challenge_id: string;
|
|
269
|
+
/** Where the code went, partly hidden: `al***@example.com`. */
|
|
270
|
+
destination_hint: string;
|
|
271
|
+
expires_at: string;
|
|
272
|
+
}
|
|
273
|
+
interface ConfirmPasswordSetupInput {
|
|
274
|
+
challengeId: string;
|
|
275
|
+
/** The six digits from the e-mail. */
|
|
276
|
+
code: string;
|
|
277
|
+
/** At least 12 characters with a lower-case letter, an upper-case letter
|
|
278
|
+
* and a digit. */
|
|
279
|
+
newPassword: string;
|
|
280
|
+
}
|
|
254
281
|
interface ChangePasswordInput {
|
|
255
282
|
current_password: string;
|
|
256
283
|
/** At least 12 characters with a lower-case letter, an upper-case letter
|
|
@@ -321,11 +348,31 @@ declare class AuthResource {
|
|
|
321
348
|
completeTotpSetup(input: TotpVerifyInput): Promise<TotpSetupComplete>;
|
|
322
349
|
/** Change the signed-in user's password. Every other session of the
|
|
323
350
|
* account is signed out; this one stays valid.
|
|
324
|
-
* Errors: 400 when the new password fails the policy,
|
|
325
|
-
*
|
|
351
|
+
* Errors: 400 `weak_password` when the new password fails the policy,
|
|
352
|
+
* 400 `no_password` when the account has none yet (use
|
|
353
|
+
* {@link requestPasswordSetup}), 401 when the current one is wrong. */
|
|
326
354
|
changePassword(input: ChangePasswordInput): Promise<{
|
|
327
355
|
revoked_sessions: number;
|
|
328
356
|
}>;
|
|
357
|
+
/** Step one of setting the first password of an account that has none
|
|
358
|
+
* (`user.has_password === false`, e.g. made by signing in with an e-mail
|
|
359
|
+
* code): a six-digit code goes to the account's address and works for 5
|
|
360
|
+
* minutes. Nothing changes yet.
|
|
361
|
+
* Errors: 409 `password_exists` (use {@link changePassword}),
|
|
362
|
+
* `email_required` (a Telegram account with no address yet: attach one
|
|
363
|
+
* with {@link requestEmailChange} first), `email_not_proven` (sign in
|
|
364
|
+
* with an e-mail code first); 429 `too_many_requests` (five codes an
|
|
365
|
+
* hour); 503 `delivery_failed`. Platform 0.8.2 and newer. */
|
|
366
|
+
requestPasswordSetup(): Promise<PasswordSetupRequested>;
|
|
367
|
+
/** Step two: the code from the e-mail and the new password set the
|
|
368
|
+
* account's first password. Every other session of the account is signed
|
|
369
|
+
* out; this one stays valid, and signing in with a code keeps working.
|
|
370
|
+
* Errors: 400 `weak_password` (the code is not used up, fix the password
|
|
371
|
+
* and send again), 401 `invalid_code` (after five wrong codes ask for a
|
|
372
|
+
* new one), 409 `password_exists`. */
|
|
373
|
+
confirmPasswordSetup(input: ConfirmPasswordSetupInput): Promise<{
|
|
374
|
+
revoked_sessions: number;
|
|
375
|
+
}>;
|
|
329
376
|
/** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
|
|
330
377
|
* telegram/email; for TOTP it short-circuits back to the challenge. */
|
|
331
378
|
switchMethod(input: SwitchMethodInput): Promise<OtpSentResponse>;
|
|
@@ -362,10 +409,12 @@ declare class AuthResource {
|
|
|
362
409
|
* Telegram; unlink it first) / `telegram_in_use` (this Telegram belongs to
|
|
363
410
|
* another account); 503 `telegram_not_configured`. */
|
|
364
411
|
linkTelegram(input: LinkTelegramInput): Promise<JwtIssued>;
|
|
365
|
-
/**
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
* {@link requestEmailChange} and {@link confirmEmailChange}
|
|
412
|
+
/** Always answers 409 `email_change_needs_code` on platform 0.8.1 and
|
|
413
|
+
* newer: an address is attached only after a code sent to it comes back.
|
|
414
|
+
* For the first real email of a Telegram-made account use
|
|
415
|
+
* {@link requestEmailChange} and {@link confirmEmailChange}; they clear
|
|
416
|
+
* `email_pending` too.
|
|
417
|
+
* @deprecated Use {@link requestEmailChange} and {@link confirmEmailChange}. */
|
|
369
418
|
linkEmail(input: {
|
|
370
419
|
email: string;
|
|
371
420
|
}): Promise<User>;
|
|
@@ -392,4 +441,4 @@ declare class AuthResource {
|
|
|
392
441
|
signOut(): Promise<void>;
|
|
393
442
|
}
|
|
394
443
|
|
|
395
|
-
export { AuthResource, type AvailableMethod, type ChangePasswordInput, type EmailChangeRequested, type EmailCodeSent, type EmailCodeSession, type ExchangeTelegramInput, type JwtIssued, type LinkTelegramInput, type LoginInput, type LoginResponse, type OtpSentResponse, type OtpVerifyInput, type RegisterInput, type RequestEmailCodeInput, type Session, type SwitchMethodInput, type TelegramLink, type TelegramUnknown, type TotpRequired, type TotpSetupComplete, type TotpSetupRequired, type TotpVerifyInput, type User, type VerifyEmailCodeInput };
|
|
444
|
+
export { AuthResource, type AvailableMethod, type ChangePasswordInput, type ConfirmPasswordSetupInput, type EmailChangeRequested, type EmailCodeSent, type EmailCodeSession, type ExchangeTelegramInput, type JwtIssued, type LinkTelegramInput, type LoginInput, type LoginResponse, type OtpSentResponse, type OtpVerifyInput, type PasswordSetupRequested, type RegisterInput, type RequestEmailCodeInput, type Session, type SwitchMethodInput, type TelegramLink, type TelegramUnknown, type TotpRequired, type TotpSetupComplete, type TotpSetupRequired, type TotpVerifyInput, type User, type VerifyEmailCodeInput };
|
package/dist/resources/auth.js
CHANGED
|
@@ -245,13 +245,41 @@ var AuthResource = class {
|
|
|
245
245
|
}
|
|
246
246
|
/** Change the signed-in user's password. Every other session of the
|
|
247
247
|
* account is signed out; this one stays valid.
|
|
248
|
-
* Errors: 400 when the new password fails the policy,
|
|
249
|
-
*
|
|
248
|
+
* Errors: 400 `weak_password` when the new password fails the policy,
|
|
249
|
+
* 400 `no_password` when the account has none yet (use
|
|
250
|
+
* {@link requestPasswordSetup}), 401 when the current one is wrong. */
|
|
250
251
|
async changePassword(input) {
|
|
251
252
|
return this.http.post("/auth/password", {
|
|
252
253
|
body: input
|
|
253
254
|
});
|
|
254
255
|
}
|
|
256
|
+
/** Step one of setting the first password of an account that has none
|
|
257
|
+
* (`user.has_password === false`, e.g. made by signing in with an e-mail
|
|
258
|
+
* code): a six-digit code goes to the account's address and works for 5
|
|
259
|
+
* minutes. Nothing changes yet.
|
|
260
|
+
* Errors: 409 `password_exists` (use {@link changePassword}),
|
|
261
|
+
* `email_required` (a Telegram account with no address yet: attach one
|
|
262
|
+
* with {@link requestEmailChange} first), `email_not_proven` (sign in
|
|
263
|
+
* with an e-mail code first); 429 `too_many_requests` (five codes an
|
|
264
|
+
* hour); 503 `delivery_failed`. Platform 0.8.2 and newer. */
|
|
265
|
+
async requestPasswordSetup() {
|
|
266
|
+
return this.http.post("/auth/password/setup", {});
|
|
267
|
+
}
|
|
268
|
+
/** Step two: the code from the e-mail and the new password set the
|
|
269
|
+
* account's first password. Every other session of the account is signed
|
|
270
|
+
* out; this one stays valid, and signing in with a code keeps working.
|
|
271
|
+
* Errors: 400 `weak_password` (the code is not used up, fix the password
|
|
272
|
+
* and send again), 401 `invalid_code` (after five wrong codes ask for a
|
|
273
|
+
* new one), 409 `password_exists`. */
|
|
274
|
+
async confirmPasswordSetup(input) {
|
|
275
|
+
return this.http.post("/auth/password/setup/confirm", {
|
|
276
|
+
body: {
|
|
277
|
+
challenge_id: input.challengeId,
|
|
278
|
+
code: input.code,
|
|
279
|
+
new_password: input.newPassword
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
255
283
|
/** Swap the 2FA method mid-flow. Resolves to `otp_sent` for
|
|
256
284
|
* telegram/email; for TOTP it short-circuits back to the challenge. */
|
|
257
285
|
async switchMethod(input) {
|
|
@@ -304,10 +332,12 @@ var AuthResource = class {
|
|
|
304
332
|
await Promise.resolve(this.tokens.set(resp.access_token));
|
|
305
333
|
return resp;
|
|
306
334
|
}
|
|
307
|
-
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
* {@link requestEmailChange} and {@link confirmEmailChange}
|
|
335
|
+
/** Always answers 409 `email_change_needs_code` on platform 0.8.1 and
|
|
336
|
+
* newer: an address is attached only after a code sent to it comes back.
|
|
337
|
+
* For the first real email of a Telegram-made account use
|
|
338
|
+
* {@link requestEmailChange} and {@link confirmEmailChange}; they clear
|
|
339
|
+
* `email_pending` too.
|
|
340
|
+
* @deprecated Use {@link requestEmailChange} and {@link confirmEmailChange}. */
|
|
311
341
|
async linkEmail(input) {
|
|
312
342
|
return this.http.post("/me/email", { body: { email: input.email } });
|
|
313
343
|
}
|