mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-26 22:31:12 +00:00
Adding new TOTP generate and update methods. Fixes #191
This commit is contained in:
parent
e270d67086
commit
a0dba1f108
4 changed files with 36 additions and 2 deletions
0
copy_generated_types_from_lemmy.sh
Normal file → Executable file
0
copy_generated_types_from_lemmy.sh
Normal file → Executable file
35
src/http.ts
35
src/http.ts
|
@ -129,6 +129,9 @@ import { UploadImage, UploadImageResponse, VERSION } from "./types/others";
|
||||||
import { HideCommunity } from "./types/HideCommunity";
|
import { HideCommunity } from "./types/HideCommunity";
|
||||||
import { BlockInstance } from "./types/BlockInstance";
|
import { BlockInstance } from "./types/BlockInstance";
|
||||||
import { BlockInstanceResponse } from "./types/BlockInstanceResponse";
|
import { BlockInstanceResponse } from "./types/BlockInstanceResponse";
|
||||||
|
import { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse";
|
||||||
|
import { UpdateTotp } from "./types/UpdateTotp";
|
||||||
|
import { UpdateTotpResponse } from "./types/UpdateTotpResponse";
|
||||||
|
|
||||||
enum HttpType {
|
enum HttpType {
|
||||||
Get = "GET",
|
Get = "GET",
|
||||||
|
@ -212,6 +215,38 @@ export class LemmyHttp {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a TOTP / two-factor secret.
|
||||||
|
*
|
||||||
|
* Afterwards you need to call `/user/totp/update` with a valid token to enable it.
|
||||||
|
*
|
||||||
|
* `HTTP.POST /user/totp/generate`
|
||||||
|
*/
|
||||||
|
generateTotpSecret() {
|
||||||
|
return this.#wrapper<object, GenerateTotpSecretResponse>(
|
||||||
|
HttpType.Post,
|
||||||
|
"/user/totp/generate",
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable / Disable TOTP / two-factor authentication.
|
||||||
|
*
|
||||||
|
* To enable, you need to first call `/user/totp/generate` and then pass a valid token to this.
|
||||||
|
*
|
||||||
|
* Disabling is only possible if 2FA was previously enabled. Again it is necessary to pass a valid token.
|
||||||
|
*
|
||||||
|
* `HTTP.POST /user/totp/update`
|
||||||
|
*/
|
||||||
|
updateTotp(form: UpdateTotp) {
|
||||||
|
return this.#wrapper<object, UpdateTotpResponse>(
|
||||||
|
HttpType.Post,
|
||||||
|
"/user/totp/update",
|
||||||
|
form,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the modlog.
|
* Get the modlog.
|
||||||
*
|
*
|
||||||
|
|
|
@ -241,4 +241,4 @@ export { UpdateTotp } from "./types/UpdateTotp";
|
||||||
export { UpdateTotpResponse } from "./types/UpdateTotpResponse";
|
export { UpdateTotpResponse } from "./types/UpdateTotpResponse";
|
||||||
export { VerifyEmail } from "./types/VerifyEmail";
|
export { VerifyEmail } from "./types/VerifyEmail";
|
||||||
export { VerifyEmailResponse } from "./types/VerifyEmailResponse";
|
export { VerifyEmailResponse } from "./types/VerifyEmailResponse";
|
||||||
export { ImageFile, UploadImage, UploadImageResponse } from "./types/others";
|
export { UploadImage, UploadImageResponse, ImageFile } from "./types/others";
|
||||||
|
|
|
@ -25,7 +25,6 @@ export interface SaveUserSettings {
|
||||||
show_read_posts?: boolean;
|
show_read_posts?: boolean;
|
||||||
show_new_post_notifs?: boolean;
|
show_new_post_notifs?: boolean;
|
||||||
discussion_languages?: Array<LanguageId>;
|
discussion_languages?: Array<LanguageId>;
|
||||||
generate_totp_2fa?: boolean;
|
|
||||||
open_links_in_new_tab?: boolean;
|
open_links_in_new_tab?: boolean;
|
||||||
infinite_scroll_enabled?: boolean;
|
infinite_scroll_enabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue