From d77c84a5e6a08f88934e0fa9dfb4c3fe8cb09151 Mon Sep 17 00:00:00 2001 From: Anthony Lawn Date: Mon, 4 Dec 2023 05:56:51 -0600 Subject: [PATCH 1/7] WIP Implemented OAuth --- src/http.ts | 43 +++++++++++++++++++++++++++++++++ src/index.ts | 3 +++ src/types/CreateExternalAuth.ts | 14 +++++++++++ src/types/CreateSite.ts | 1 + src/types/DeleteExternalAuth.ts | 6 +++++ src/types/EditExternalAuth.ts | 16 ++++++++++++ src/types/EditSite.ts | 1 + src/types/ExternalAuth.ts | 19 +++++++++++++++ src/types/ExternalAuthId.ts | 3 +++ src/types/GetSiteResponse.ts | 2 ++ src/types/LocalSite.ts | 1 + 11 files changed, 109 insertions(+) create mode 100644 src/types/CreateExternalAuth.ts create mode 100644 src/types/DeleteExternalAuth.ts create mode 100644 src/types/EditExternalAuth.ts create mode 100644 src/types/ExternalAuth.ts create mode 100644 src/types/ExternalAuthId.ts diff --git a/src/http.ts b/src/http.ts index e51e2a29..8b931da1 100644 --- a/src/http.ts +++ b/src/http.ts @@ -22,6 +22,7 @@ import { CreateCommentLike } from "./types/CreateCommentLike"; import { CreateCommentReport } from "./types/CreateCommentReport"; import { CreateCommunity } from "./types/CreateCommunity"; import { CreateCustomEmoji } from "./types/CreateCustomEmoji"; +import { CreateExternalAuth } from "./types/CreateExternalAuth"; import { CreatePost } from "./types/CreatePost"; import { CreatePostLike } from "./types/CreatePostLike"; import { CreatePostReport } from "./types/CreatePostReport"; @@ -33,15 +34,18 @@ import { DeleteAccount } from "./types/DeleteAccount"; import { DeleteComment } from "./types/DeleteComment"; import { DeleteCommunity } from "./types/DeleteCommunity"; import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji"; +import { DeleteExternalAuth } from "./types/DeleteExternalAuth"; import { DeletePost } from "./types/DeletePost"; import { DeletePrivateMessage } from "./types/DeletePrivateMessage"; import { DistinguishComment } from "./types/DistinguishComment"; import { EditComment } from "./types/EditComment"; import { EditCommunity } from "./types/EditCommunity"; import { EditCustomEmoji } from "./types/EditCustomEmoji"; +import { EditExternalAuth } from "./types/EditExternalAuth"; import { EditPost } from "./types/EditPost"; import { EditPrivateMessage } from "./types/EditPrivateMessage"; import { EditSite } from "./types/EditSite"; +import { ExternalAuth } from "./types/ExternalAuth"; import { FeaturePost } from "./types/FeaturePost"; import { FollowCommunity } from "./types/FollowCommunity"; import { GetCaptchaResponse } from "./types/GetCaptchaResponse"; @@ -1421,6 +1425,45 @@ export class LemmyHttp { ); } + /** + * Create a new external auth method + * + * `HTTP.POST /external_auth` + */ + createExternalAuth(form: CreateExternalAuth) { + return this.#wrapper( + HttpType.Post, + "/external_auth", + form, + ); + } + + /** + * Edit an existing external auth method + * + * `HTTP.PUT /external_auth` + */ + editExternalAuth(form: EditExternalAuth) { + return this.#wrapper( + HttpType.Put, + "/external_auth", + form, + ); + } + + /** + * Delete an external auth method + * + * `HTTP.Post /external_auth/delete` + */ + deleteExternalAuth(form: DeleteExternalAuth) { + return this.#wrapper( + HttpType.Post, + "/external_auth/delete", + form, + ); + } + /** * Fetch federated instances. * diff --git a/src/index.ts b/src/index.ts index 92562096..b81b19d7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,6 +54,7 @@ export { CreateCommentLike } from "./types/CreateCommentLike"; export { CreateCommentReport } from "./types/CreateCommentReport"; export { CreateCommunity } from "./types/CreateCommunity"; export { CreateCustomEmoji } from "./types/CreateCustomEmoji"; +export { CreateExternalAuth } from "./types/CreateExternalAuth"; export { CreatePost } from "./types/CreatePost"; export { CreatePostLike } from "./types/CreatePostLike"; export { CreatePostReport } from "./types/CreatePostReport"; @@ -69,12 +70,14 @@ export { DeleteAccount } from "./types/DeleteAccount"; export { DeleteComment } from "./types/DeleteComment"; export { DeleteCommunity } from "./types/DeleteCommunity"; export { DeleteCustomEmoji } from "./types/DeleteCustomEmoji"; +export { DeleteExternalAuth } from "./types/DeleteExternalAuth"; export { DeletePost } from "./types/DeletePost"; export { DeletePrivateMessage } from "./types/DeletePrivateMessage"; export { DistinguishComment } from "./types/DistinguishComment"; export { EditComment } from "./types/EditComment"; export { EditCommunity } from "./types/EditCommunity"; export { EditCustomEmoji } from "./types/EditCustomEmoji"; +export { EditExternalAuth } from "./types/EditExternalAuth"; export { EditPost } from "./types/EditPost"; export { EditPrivateMessage } from "./types/EditPrivateMessage"; export { EditSite } from "./types/EditSite"; diff --git a/src/types/CreateExternalAuth.ts b/src/types/CreateExternalAuth.ts new file mode 100644 index 00000000..a7351d5b --- /dev/null +++ b/src/types/CreateExternalAuth.ts @@ -0,0 +1,14 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface CreateExternalAuth { + display_name: string; + auth_type: string; + auth_endpoint: string; + token_endpoint: string; + user_endpoint: string; + id_attribute: string; + issuer: string; + client_id: string; + client_secret: string; + scopes: string; +} diff --git a/src/types/CreateSite.ts b/src/types/CreateSite.ts index 3cb74312..12749ae2 100644 --- a/src/types/CreateSite.ts +++ b/src/types/CreateSite.ts @@ -48,4 +48,5 @@ export interface CreateSite { registration_mode?: RegistrationMode; content_warning?: string; default_post_listing_mode?: PostListingMode; + oauth_registration?: boolean; } diff --git a/src/types/DeleteExternalAuth.ts b/src/types/DeleteExternalAuth.ts new file mode 100644 index 00000000..ea17689e --- /dev/null +++ b/src/types/DeleteExternalAuth.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ExternalAuthId } from "./ExternalAuthId"; + +export interface DeleteExternalAuth { + id: ExternalAuthId; +} diff --git a/src/types/EditExternalAuth.ts b/src/types/EditExternalAuth.ts new file mode 100644 index 00000000..44037284 --- /dev/null +++ b/src/types/EditExternalAuth.ts @@ -0,0 +1,16 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ExternalAuthId } from "./ExternalAuthId"; + +export interface EditExternalAuth { + id: ExternalAuthId; + display_name: string; + auth_type: string; + auth_endpoint: string; + token_endpoint: string; + user_endpoint: string; + id_attribute: string; + issuer: string; + client_id: string; + client_secret: string; + scopes: string; +} diff --git a/src/types/EditSite.ts b/src/types/EditSite.ts index ef98f5e1..f5152213 100644 --- a/src/types/EditSite.ts +++ b/src/types/EditSite.ts @@ -47,6 +47,7 @@ export interface EditSite { blocked_urls?: Array; taglines?: Array; registration_mode?: RegistrationMode; + oauth_registration?: boolean; reports_email_admins?: boolean; content_warning?: string; default_post_listing_mode?: PostListingMode; diff --git a/src/types/ExternalAuth.ts b/src/types/ExternalAuth.ts new file mode 100644 index 00000000..343bc429 --- /dev/null +++ b/src/types/ExternalAuth.ts @@ -0,0 +1,19 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ExternalAuthId } from "./ExternalAuthId"; +import type { LocalSiteId } from "./LocalSiteId"; + +export interface ExternalAuth { + id: ExternalAuthId; + display_name: string; + auth_type: string; + auth_endpoint: string; + token_endpoint: string; + user_endpoint: string; + id_attribute: string; + issuer: string; + client_id: string; + client_secret: string; + scopes: string; + published: string; + updated: string; +} diff --git a/src/types/ExternalAuthId.ts b/src/types/ExternalAuthId.ts new file mode 100644 index 00000000..b23a1278 --- /dev/null +++ b/src/types/ExternalAuthId.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ExternalAuthId = number; diff --git a/src/types/GetSiteResponse.ts b/src/types/GetSiteResponse.ts index 04199011..65bf087e 100644 --- a/src/types/GetSiteResponse.ts +++ b/src/types/GetSiteResponse.ts @@ -1,5 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { CustomEmojiView } from "./CustomEmojiView"; +import type { ExternalAuth } from "./ExternalAuth"; import type { Language } from "./Language"; import type { LanguageId } from "./LanguageId"; import type { LocalSiteUrlBlocklist } from "./LocalSiteUrlBlocklist"; @@ -18,4 +19,5 @@ export interface GetSiteResponse { taglines: Array; custom_emojis: Array; blocked_urls: Array; + external_auths: Array; } diff --git a/src/types/LocalSite.ts b/src/types/LocalSite.ts index 0d2e24be..dda77929 100644 --- a/src/types/LocalSite.ts +++ b/src/types/LocalSite.ts @@ -29,6 +29,7 @@ export interface LocalSite { published: string; updated?: string; registration_mode: RegistrationMode; + oauth_registration: boolean; reports_email_admins: boolean; federation_signed_fetch: boolean; default_post_listing_mode: PostListingMode; From 205468b253ac85fa4a9d1ca6f4040df1def73bc0 Mon Sep 17 00:00:00 2001 From: privacyguard Date: Mon, 1 Jul 2024 01:35:09 +0300 Subject: [PATCH 2/7] Added OAUTH2 OIDC support --- copy_generated_types_from_lemmy.sh | 3 ++ src/http.ts | 52 ++++++++++++------- src/index.ts | 15 ++++-- src/types/CreateExternalAuth.ts | 14 ----- src/types/CreateOAuthProvider.ts | 18 +++++++ src/types/CreateSite.ts | 2 +- src/types/DeleteExternalAuth.ts | 6 --- src/types/DeleteOAuthProvider.ts | 5 ++ src/types/EditExternalAuth.ts | 16 ------ src/types/EditOAuthProvider.ts | 17 ++++++ src/types/ExternalAuth.ts | 19 ------- src/types/GetPosts.ts | 1 + src/types/GetSiteResponse.ts | 4 +- src/types/ImageDetails.ts | 8 +++ src/types/LemmyErrorType.ts | 3 ++ src/types/LocalSite.ts | 2 +- src/types/OAuth.ts | 7 +++ src/types/OAuthAccount.ts | 13 +++++ .../{ExternalAuthId.ts => OAuthAccountId.ts} | 2 +- src/types/OAuthProvider.ts | 20 +++++++ src/types/OAuthProviderId.ts | 3 ++ src/types/OAuthProviderInsertForm.ts | 20 +++++++ src/types/OAuthProviderUpdateForm.ts | 17 ++++++ src/types/PostView.ts | 2 + src/types/TokenResponse.ts | 9 ++++ 25 files changed, 196 insertions(+), 82 deletions(-) delete mode 100644 src/types/CreateExternalAuth.ts create mode 100644 src/types/CreateOAuthProvider.ts delete mode 100644 src/types/DeleteExternalAuth.ts create mode 100644 src/types/DeleteOAuthProvider.ts delete mode 100644 src/types/EditExternalAuth.ts create mode 100644 src/types/EditOAuthProvider.ts delete mode 100644 src/types/ExternalAuth.ts create mode 100644 src/types/ImageDetails.ts create mode 100644 src/types/OAuth.ts create mode 100644 src/types/OAuthAccount.ts rename src/types/{ExternalAuthId.ts => OAuthAccountId.ts} (74%) create mode 100644 src/types/OAuthProvider.ts create mode 100644 src/types/OAuthProviderId.ts create mode 100644 src/types/OAuthProviderInsertForm.ts create mode 100644 src/types/OAuthProviderUpdateForm.ts create mode 100644 src/types/TokenResponse.ts diff --git a/copy_generated_types_from_lemmy.sh b/copy_generated_types_from_lemmy.sh index a2e1ee57..dc407424 100755 --- a/copy_generated_types_from_lemmy.sh +++ b/copy_generated_types_from_lemmy.sh @@ -30,6 +30,9 @@ rm src/types/Sensitive.ts # Change all the bigints to numbers find src/types -type f -name '*.ts' -exec sed -i 's/bigint/number/g' {} + +# on MacOS: +# find src/types -type f -name '*.ts' -exec sed -i '' -e 's/bigint/number/g' {} \; + node putTypesInIndex.js prettier -w src diff --git a/src/http.ts b/src/http.ts index 8b931da1..a82a8b6a 100644 --- a/src/http.ts +++ b/src/http.ts @@ -22,7 +22,7 @@ import { CreateCommentLike } from "./types/CreateCommentLike"; import { CreateCommentReport } from "./types/CreateCommentReport"; import { CreateCommunity } from "./types/CreateCommunity"; import { CreateCustomEmoji } from "./types/CreateCustomEmoji"; -import { CreateExternalAuth } from "./types/CreateExternalAuth"; +import { CreateOAuthProvider } from "./types/CreateOAuthProvider"; import { CreatePost } from "./types/CreatePost"; import { CreatePostLike } from "./types/CreatePostLike"; import { CreatePostReport } from "./types/CreatePostReport"; @@ -34,18 +34,18 @@ import { DeleteAccount } from "./types/DeleteAccount"; import { DeleteComment } from "./types/DeleteComment"; import { DeleteCommunity } from "./types/DeleteCommunity"; import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji"; -import { DeleteExternalAuth } from "./types/DeleteExternalAuth"; +import { DeleteOAuthProvider } from "./types/DeleteOAuthProvider"; import { DeletePost } from "./types/DeletePost"; import { DeletePrivateMessage } from "./types/DeletePrivateMessage"; import { DistinguishComment } from "./types/DistinguishComment"; import { EditComment } from "./types/EditComment"; import { EditCommunity } from "./types/EditCommunity"; import { EditCustomEmoji } from "./types/EditCustomEmoji"; -import { EditExternalAuth } from "./types/EditExternalAuth"; +import { EditOAuthProvider } from "./types/EditOAuthProvider"; import { EditPost } from "./types/EditPost"; import { EditPrivateMessage } from "./types/EditPrivateMessage"; import { EditSite } from "./types/EditSite"; -import { ExternalAuth } from "./types/ExternalAuth"; +import { OAuthProvider } from "./types/OAuthProvider"; import { FeaturePost } from "./types/FeaturePost"; import { FollowCommunity } from "./types/FollowCommunity"; import { GetCaptchaResponse } from "./types/GetCaptchaResponse"; @@ -143,6 +143,7 @@ import { ListCommentLikesResponse } from "./types/ListCommentLikesResponse"; import { HidePost } from "./types/HidePost"; import { ListMedia } from "./types/ListMedia"; import { ListMediaResponse } from "./types/ListMediaResponse"; +import { OAuth } from "./types/OAuth"; enum HttpType { Get = "GET", @@ -1426,40 +1427,53 @@ export class LemmyHttp { } /** - * Create a new external auth method + * Create a new oauth provider method * - * `HTTP.POST /external_auth` + * `HTTP.POST /oauth_provider` */ - createExternalAuth(form: CreateExternalAuth) { - return this.#wrapper( + createOAuthProvider(form: CreateOAuthProvider) { + return this.#wrapper( HttpType.Post, - "/external_auth", + "/oauth_provider", form, ); } /** - * Edit an existing external auth method + * Edit an existing oauth provider method * - * `HTTP.PUT /external_auth` + * `HTTP.PUT /oauth_provider` */ - editExternalAuth(form: EditExternalAuth) { - return this.#wrapper( + editOAuthProvider(form: EditOAuthProvider) { + return this.#wrapper( HttpType.Put, - "/external_auth", + "/oauth_provider", form, ); } /** - * Delete an external auth method + * Delete an oauth provider method * - * `HTTP.Post /external_auth/delete` + * `HTTP.Post /oauth_provider/delete` */ - deleteExternalAuth(form: DeleteExternalAuth) { - return this.#wrapper( + deleteOAuthProvider(form: DeleteOAuthProvider) { + return this.#wrapper( HttpType.Post, - "/external_auth/delete", + "/oauth_provider/delete", + form, + ); + } + + /** + * Register user with OAuth + * + * `HTTP.Post /oauth/register` + */ + registerWithOAuth(form: OAuth) { + return this.#wrapper( + HttpType.Post, + "/oauth/register", form, ); } diff --git a/src/index.ts b/src/index.ts index b81b19d7..7d7123dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,7 +54,7 @@ export { CreateCommentLike } from "./types/CreateCommentLike"; export { CreateCommentReport } from "./types/CreateCommentReport"; export { CreateCommunity } from "./types/CreateCommunity"; export { CreateCustomEmoji } from "./types/CreateCustomEmoji"; -export { CreateExternalAuth } from "./types/CreateExternalAuth"; +export { CreateOAuthProvider } from "./types/CreateOAuthProvider"; export { CreatePost } from "./types/CreatePost"; export { CreatePostLike } from "./types/CreatePostLike"; export { CreatePostReport } from "./types/CreatePostReport"; @@ -70,14 +70,14 @@ export { DeleteAccount } from "./types/DeleteAccount"; export { DeleteComment } from "./types/DeleteComment"; export { DeleteCommunity } from "./types/DeleteCommunity"; export { DeleteCustomEmoji } from "./types/DeleteCustomEmoji"; -export { DeleteExternalAuth } from "./types/DeleteExternalAuth"; +export { DeleteOAuthProvider } from "./types/DeleteOAuthProvider"; export { DeletePost } from "./types/DeletePost"; export { DeletePrivateMessage } from "./types/DeletePrivateMessage"; export { DistinguishComment } from "./types/DistinguishComment"; export { EditComment } from "./types/EditComment"; export { EditCommunity } from "./types/EditCommunity"; export { EditCustomEmoji } from "./types/EditCustomEmoji"; -export { EditExternalAuth } from "./types/EditExternalAuth"; +export { EditOAuthProvider } from "./types/EditOAuthProvider"; export { EditPost } from "./types/EditPost"; export { EditPrivateMessage } from "./types/EditPrivateMessage"; export { EditSite } from "./types/EditSite"; @@ -114,6 +114,7 @@ export { GetUnreadCountResponse } from "./types/GetUnreadCountResponse"; export { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse"; export { HideCommunity } from "./types/HideCommunity"; export { HidePost } from "./types/HidePost"; +export { ImageDetails } from "./types/ImageDetails"; export { Instance } from "./types/Instance"; export { InstanceBlockView } from "./types/InstanceBlockView"; export { InstanceId } from "./types/InstanceId"; @@ -182,6 +183,13 @@ export { ModTransferCommunityView } from "./types/ModTransferCommunityView"; export { ModlogActionType } from "./types/ModlogActionType"; export { ModlogListParams } from "./types/ModlogListParams"; export { MyUserInfo } from "./types/MyUserInfo"; +export { OAuth } from "./types/OAuth"; +export { OAuthAccount } from "./types/OAuthAccount"; +export { OAuthAccountId } from "./types/OAuthAccountId"; +export { OAuthProvider } from "./types/OAuthProvider"; +export { OAuthProviderId } from "./types/OAuthProviderId"; +export { OAuthProviderInsertForm } from "./types/OAuthProviderInsertForm"; +export { OAuthProviderUpdateForm } from "./types/OAuthProviderUpdateForm"; export { OpenGraphData } from "./types/OpenGraphData"; export { PaginationCursor } from "./types/PaginationCursor"; export { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset"; @@ -249,6 +257,7 @@ export { SortType } from "./types/SortType"; export { SubscribedType } from "./types/SubscribedType"; export { SuccessResponse } from "./types/SuccessResponse"; export { Tagline } from "./types/Tagline"; +export { TokenResponse } from "./types/TokenResponse"; export { TransferCommunity } from "./types/TransferCommunity"; export { UpdateTotp } from "./types/UpdateTotp"; export { UpdateTotpResponse } from "./types/UpdateTotpResponse"; diff --git a/src/types/CreateExternalAuth.ts b/src/types/CreateExternalAuth.ts deleted file mode 100644 index a7351d5b..00000000 --- a/src/types/CreateExternalAuth.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface CreateExternalAuth { - display_name: string; - auth_type: string; - auth_endpoint: string; - token_endpoint: string; - user_endpoint: string; - id_attribute: string; - issuer: string; - client_id: string; - client_secret: string; - scopes: string; -} diff --git a/src/types/CreateOAuthProvider.ts b/src/types/CreateOAuthProvider.ts new file mode 100644 index 00000000..bc201c94 --- /dev/null +++ b/src/types/CreateOAuthProvider.ts @@ -0,0 +1,18 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface CreateOAuthProvider { + display_name: string; + issuer: string; + authorization_endpoint: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string; + name_claim: string; + client_id: string; + client_secret: string; + scopes: string; + auto_verify_email: boolean; + auto_approve_application: boolean; + account_linking_enabled: boolean; + enabled: boolean; +} diff --git a/src/types/CreateSite.ts b/src/types/CreateSite.ts index 12749ae2..7be2e778 100644 --- a/src/types/CreateSite.ts +++ b/src/types/CreateSite.ts @@ -46,7 +46,7 @@ export interface CreateSite { blocked_instances?: Array; taglines?: Array; registration_mode?: RegistrationMode; + oauth_registration?: boolean; content_warning?: string; default_post_listing_mode?: PostListingMode; - oauth_registration?: boolean; } diff --git a/src/types/DeleteExternalAuth.ts b/src/types/DeleteExternalAuth.ts deleted file mode 100644 index ea17689e..00000000 --- a/src/types/DeleteExternalAuth.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { ExternalAuthId } from "./ExternalAuthId"; - -export interface DeleteExternalAuth { - id: ExternalAuthId; -} diff --git a/src/types/DeleteOAuthProvider.ts b/src/types/DeleteOAuthProvider.ts new file mode 100644 index 00000000..79e3ce8a --- /dev/null +++ b/src/types/DeleteOAuthProvider.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface DeleteOAuthProvider { + id: string; +} diff --git a/src/types/EditExternalAuth.ts b/src/types/EditExternalAuth.ts deleted file mode 100644 index 44037284..00000000 --- a/src/types/EditExternalAuth.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { ExternalAuthId } from "./ExternalAuthId"; - -export interface EditExternalAuth { - id: ExternalAuthId; - display_name: string; - auth_type: string; - auth_endpoint: string; - token_endpoint: string; - user_endpoint: string; - id_attribute: string; - issuer: string; - client_id: string; - client_secret: string; - scopes: string; -} diff --git a/src/types/EditOAuthProvider.ts b/src/types/EditOAuthProvider.ts new file mode 100644 index 00000000..7a4ed2c9 --- /dev/null +++ b/src/types/EditOAuthProvider.ts @@ -0,0 +1,17 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface EditOAuthProvider { + id: string; + display_name: string; + authorization_endpoint: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string; + name_claim: string; + client_secret: string; + scopes: string; + auto_verify_email: boolean; + auto_approve_application: boolean; + account_linking_enabled: boolean; + enabled: boolean; +} diff --git a/src/types/ExternalAuth.ts b/src/types/ExternalAuth.ts deleted file mode 100644 index 343bc429..00000000 --- a/src/types/ExternalAuth.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { ExternalAuthId } from "./ExternalAuthId"; -import type { LocalSiteId } from "./LocalSiteId"; - -export interface ExternalAuth { - id: ExternalAuthId; - display_name: string; - auth_type: string; - auth_endpoint: string; - token_endpoint: string; - user_endpoint: string; - id_attribute: string; - issuer: string; - client_id: string; - client_secret: string; - scopes: string; - published: string; - updated: string; -} diff --git a/src/types/GetPosts.ts b/src/types/GetPosts.ts index 9da31496..295632bb 100644 --- a/src/types/GetPosts.ts +++ b/src/types/GetPosts.ts @@ -15,5 +15,6 @@ export interface GetPosts { liked_only?: boolean; disliked_only?: boolean; show_hidden?: boolean; + show_read?: boolean; page_cursor?: PaginationCursor; } diff --git a/src/types/GetSiteResponse.ts b/src/types/GetSiteResponse.ts index 65bf087e..415eb7a3 100644 --- a/src/types/GetSiteResponse.ts +++ b/src/types/GetSiteResponse.ts @@ -1,10 +1,10 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { CustomEmojiView } from "./CustomEmojiView"; -import type { ExternalAuth } from "./ExternalAuth"; import type { Language } from "./Language"; import type { LanguageId } from "./LanguageId"; import type { LocalSiteUrlBlocklist } from "./LocalSiteUrlBlocklist"; import type { MyUserInfo } from "./MyUserInfo"; +import type { OAuthProvider } from "./OAuthProvider"; import type { PersonView } from "./PersonView"; import type { SiteView } from "./SiteView"; import type { Tagline } from "./Tagline"; @@ -18,6 +18,6 @@ export interface GetSiteResponse { discussion_languages: Array; taglines: Array; custom_emojis: Array; + oauth_providers: Array; blocked_urls: Array; - external_auths: Array; } diff --git a/src/types/ImageDetails.ts b/src/types/ImageDetails.ts new file mode 100644 index 00000000..8d350abe --- /dev/null +++ b/src/types/ImageDetails.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface ImageDetails { + link: string; + width: number; + height: number; + content_type: string; +} diff --git a/src/types/LemmyErrorType.ts b/src/types/LemmyErrorType.ts index 16cc6653..a744789a 100644 --- a/src/types/LemmyErrorType.ts +++ b/src/types/LemmyErrorType.ts @@ -164,4 +164,7 @@ export type LemmyErrorType = | { error: "cant_block_local_instance" } | { error: "url_without_domain" } | { error: "inbox_timeout" } + | { error: "oauth_authorization_invalid" } + | { error: "oauth_login_failed" } + | { error: "oauth_registration_closed" } | { error: "unknown"; message: string }; diff --git a/src/types/LocalSite.ts b/src/types/LocalSite.ts index dda77929..77bf8c90 100644 --- a/src/types/LocalSite.ts +++ b/src/types/LocalSite.ts @@ -29,9 +29,9 @@ export interface LocalSite { published: string; updated?: string; registration_mode: RegistrationMode; - oauth_registration: boolean; reports_email_admins: boolean; federation_signed_fetch: boolean; default_post_listing_mode: PostListingMode; default_sort_type: SortType; + oauth_registration: boolean; } diff --git a/src/types/OAuth.ts b/src/types/OAuth.ts new file mode 100644 index 00000000..b979548e --- /dev/null +++ b/src/types/OAuth.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface OAuth { + code: string; + oauth_provider_id: string; + redirect_uri?: string; +} diff --git a/src/types/OAuthAccount.ts b/src/types/OAuthAccount.ts new file mode 100644 index 00000000..c7c4a16c --- /dev/null +++ b/src/types/OAuthAccount.ts @@ -0,0 +1,13 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LocalUserId } from "./LocalUserId"; +import type { OAuthAccountId } from "./OAuthAccountId"; +import type { OAuthProviderId } from "./OAuthProviderId"; + +export interface OAuthAccount { + id: OAuthAccountId; + local_user_id: LocalUserId; + oauth_provider_id: OAuthProviderId; + oauth_user_id: string; + published: string; + updated?: string; +} diff --git a/src/types/ExternalAuthId.ts b/src/types/OAuthAccountId.ts similarity index 74% rename from src/types/ExternalAuthId.ts rename to src/types/OAuthAccountId.ts index b23a1278..3ce24582 100644 --- a/src/types/ExternalAuthId.ts +++ b/src/types/OAuthAccountId.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type ExternalAuthId = number; +export type OAuthAccountId = number; diff --git a/src/types/OAuthProvider.ts b/src/types/OAuthProvider.ts new file mode 100644 index 00000000..cf4a7245 --- /dev/null +++ b/src/types/OAuthProvider.ts @@ -0,0 +1,20 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface OAuthProvider { + id: string; + display_name: string; + issuer?: string; + authorization_endpoint: string; + token_endpoint?: string; + userinfo_endpoint?: string; + id_claim?: string; + name_claim?: string; + client_id: string; + scopes: string; + auto_verify_email?: boolean; + auto_approve_application?: boolean; + account_linking_enabled?: boolean; + enabled?: boolean; + published?: string; + updated?: string; +} diff --git a/src/types/OAuthProviderId.ts b/src/types/OAuthProviderId.ts new file mode 100644 index 00000000..a688d400 --- /dev/null +++ b/src/types/OAuthProviderId.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type OAuthProviderId = number; diff --git a/src/types/OAuthProviderInsertForm.ts b/src/types/OAuthProviderInsertForm.ts new file mode 100644 index 00000000..f1ee2aa3 --- /dev/null +++ b/src/types/OAuthProviderInsertForm.ts @@ -0,0 +1,20 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProviderId } from "./OAuthProviderId"; + +export interface OAuthProviderInsertForm { + id: OAuthProviderId; + display_name: string; + issuer: string; + authorization_endpoint: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string; + name_claim: string; + client_id: string; + client_secret: string; + scopes: string; + auto_verify_email: boolean; + auto_approve_application: boolean; + account_linking_enabled: boolean; + enabled: boolean; +} diff --git a/src/types/OAuthProviderUpdateForm.ts b/src/types/OAuthProviderUpdateForm.ts new file mode 100644 index 00000000..3b40d554 --- /dev/null +++ b/src/types/OAuthProviderUpdateForm.ts @@ -0,0 +1,17 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface OAuthProviderUpdateForm { + display_name: string; + authorization_endpoint: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string; + name_claim: string; + client_secret: string | null; + scopes: string; + auto_verify_email: boolean; + auto_approve_application: boolean; + account_linking_enabled: boolean; + enabled: boolean; + updated: string; +} diff --git a/src/types/PostView.ts b/src/types/PostView.ts index a17cd51f..c66de232 100644 --- a/src/types/PostView.ts +++ b/src/types/PostView.ts @@ -1,5 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { Community } from "./Community"; +import type { ImageDetails } from "./ImageDetails"; import type { Person } from "./Person"; import type { Post } from "./Post"; import type { PostAggregates } from "./PostAggregates"; @@ -9,6 +10,7 @@ export interface PostView { post: Post; creator: Person; community: Community; + image_details?: ImageDetails; creator_banned_from_community: boolean; banned_from_community: boolean; creator_is_moderator: boolean; diff --git a/src/types/TokenResponse.ts b/src/types/TokenResponse.ts new file mode 100644 index 00000000..fd61d2cd --- /dev/null +++ b/src/types/TokenResponse.ts @@ -0,0 +1,9 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface TokenResponse { + access_token: string; + token_type: string; + expires_in?: number; + refresh_token?: string; + scope?: string; +} From 599d1a46c19f54800ce935c29d0d66c20951f6fa Mon Sep 17 00:00:00 2001 From: privacyguard Date: Sun, 7 Jul 2024 02:01:39 +0300 Subject: [PATCH 3/7] update based on the latest changes in the lemmy repo PR --- src/http.ts | 12 ++++++------ src/index.ts | 3 +-- src/types/{OAuth.ts => AuthenticateWithOauth.ts} | 4 ++-- src/types/GetSiteResponse.ts | 2 +- src/types/LemmyErrorType.ts | 1 + src/types/PersonBlockId.ts | 3 --- 6 files changed, 11 insertions(+), 14 deletions(-) rename src/types/{OAuth.ts => AuthenticateWithOauth.ts} (70%) delete mode 100644 src/types/PersonBlockId.ts diff --git a/src/http.ts b/src/http.ts index a82a8b6a..d0393548 100644 --- a/src/http.ts +++ b/src/http.ts @@ -143,7 +143,7 @@ import { ListCommentLikesResponse } from "./types/ListCommentLikesResponse"; import { HidePost } from "./types/HidePost"; import { ListMedia } from "./types/ListMedia"; import { ListMediaResponse } from "./types/ListMediaResponse"; -import { OAuth } from "./types/OAuth"; +import { AuthenticateWithOauth } from "./types/AuthenticateWithOauth"; enum HttpType { Get = "GET", @@ -1466,14 +1466,14 @@ export class LemmyHttp { } /** - * Register user with OAuth + * Authenticate with OAuth * - * `HTTP.Post /oauth/register` + * `HTTP.Post /oauth/authenticate` */ - registerWithOAuth(form: OAuth) { - return this.#wrapper( + authenticateWithOAuth(form: AuthenticateWithOauth) { + return this.#wrapper( HttpType.Post, - "/oauth/register", + "/oauth/authenticate", form, ); } diff --git a/src/index.ts b/src/index.ts index 7d7123dd..4489d472 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +13,7 @@ export { AdminPurgePersonView } from "./types/AdminPurgePersonView"; export { AdminPurgePost } from "./types/AdminPurgePost"; export { AdminPurgePostView } from "./types/AdminPurgePostView"; export { ApproveRegistrationApplication } from "./types/ApproveRegistrationApplication"; +export { AuthenticateWithOauth } from "./types/AuthenticateWithOauth"; export { BanFromCommunity } from "./types/BanFromCommunity"; export { BanFromCommunityResponse } from "./types/BanFromCommunityResponse"; export { BanPerson } from "./types/BanPerson"; @@ -183,7 +184,6 @@ export { ModTransferCommunityView } from "./types/ModTransferCommunityView"; export { ModlogActionType } from "./types/ModlogActionType"; export { ModlogListParams } from "./types/ModlogListParams"; export { MyUserInfo } from "./types/MyUserInfo"; -export { OAuth } from "./types/OAuth"; export { OAuthAccount } from "./types/OAuthAccount"; export { OAuthAccountId } from "./types/OAuthAccountId"; export { OAuthProvider } from "./types/OAuthProvider"; @@ -196,7 +196,6 @@ export { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset"; export { PasswordReset } from "./types/PasswordReset"; export { Person } from "./types/Person"; export { PersonAggregates } from "./types/PersonAggregates"; -export { PersonBlockId } from "./types/PersonBlockId"; export { PersonBlockView } from "./types/PersonBlockView"; export { PersonId } from "./types/PersonId"; export { PersonMention } from "./types/PersonMention"; diff --git a/src/types/OAuth.ts b/src/types/AuthenticateWithOauth.ts similarity index 70% rename from src/types/OAuth.ts rename to src/types/AuthenticateWithOauth.ts index b979548e..ca151e43 100644 --- a/src/types/OAuth.ts +++ b/src/types/AuthenticateWithOauth.ts @@ -1,7 +1,7 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface OAuth { +export interface AuthenticateWithOauth { code: string; oauth_provider_id: string; - redirect_uri?: string; + redirect_uri: string; } diff --git a/src/types/GetSiteResponse.ts b/src/types/GetSiteResponse.ts index 415eb7a3..b042180d 100644 --- a/src/types/GetSiteResponse.ts +++ b/src/types/GetSiteResponse.ts @@ -18,6 +18,6 @@ export interface GetSiteResponse { discussion_languages: Array; taglines: Array; custom_emojis: Array; - oauth_providers: Array; + oauth_providers: Array; blocked_urls: Array; } diff --git a/src/types/LemmyErrorType.ts b/src/types/LemmyErrorType.ts index a744789a..beae140f 100644 --- a/src/types/LemmyErrorType.ts +++ b/src/types/LemmyErrorType.ts @@ -44,6 +44,7 @@ export type LemmyErrorType = | { error: "couldnt_find_comment_reply" } | { error: "couldnt_find_private_message" } | { error: "couldnt_find_activity" } + | { error: "couldnt_find_oauth_provider" } | { error: "person_is_blocked" } | { error: "community_is_blocked" } | { error: "instance_is_blocked" } diff --git a/src/types/PersonBlockId.ts b/src/types/PersonBlockId.ts deleted file mode 100644 index 7e41573b..00000000 --- a/src/types/PersonBlockId.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export type PersonBlockId = number; From 5b6f6db7229ae158dc06024d96327e7b302cf164 Mon Sep 17 00:00:00 2001 From: privacyguard Date: Thu, 11 Jul 2024 03:27:04 +0300 Subject: [PATCH 4/7] updating types based on the latest changes in the Lemmy PR --- src/index.ts | 1 - src/types/DeleteOAuthProvider.ts | 3 ++- src/types/EditOAuthProvider.ts | 27 ++++++++++++++------------- src/types/GetPosts.ts | 1 + src/types/LemmyErrorType.ts | 1 + src/types/OAuthAccount.ts | 2 -- src/types/OAuthAccountId.ts | 3 --- src/types/OAuthProvider.ts | 3 ++- src/types/OAuthProviderInsertForm.ts | 2 -- src/types/OAuthProviderUpdateForm.ts | 16 ++++++++-------- 10 files changed, 28 insertions(+), 31 deletions(-) delete mode 100644 src/types/OAuthAccountId.ts diff --git a/src/index.ts b/src/index.ts index 4489d472..d5fa02f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -185,7 +185,6 @@ export { ModlogActionType } from "./types/ModlogActionType"; export { ModlogListParams } from "./types/ModlogListParams"; export { MyUserInfo } from "./types/MyUserInfo"; export { OAuthAccount } from "./types/OAuthAccount"; -export { OAuthAccountId } from "./types/OAuthAccountId"; export { OAuthProvider } from "./types/OAuthProvider"; export { OAuthProviderId } from "./types/OAuthProviderId"; export { OAuthProviderInsertForm } from "./types/OAuthProviderInsertForm"; diff --git a/src/types/DeleteOAuthProvider.ts b/src/types/DeleteOAuthProvider.ts index 79e3ce8a..c7c56752 100644 --- a/src/types/DeleteOAuthProvider.ts +++ b/src/types/DeleteOAuthProvider.ts @@ -1,5 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProviderId } from "./OAuthProviderId"; export interface DeleteOAuthProvider { - id: string; + id: OAuthProviderId; } diff --git a/src/types/EditOAuthProvider.ts b/src/types/EditOAuthProvider.ts index 7a4ed2c9..d345d8b2 100644 --- a/src/types/EditOAuthProvider.ts +++ b/src/types/EditOAuthProvider.ts @@ -1,17 +1,18 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProviderId } from "./OAuthProviderId"; export interface EditOAuthProvider { - id: string; - display_name: string; - authorization_endpoint: string; - token_endpoint: string; - userinfo_endpoint: string; - id_claim: string; - name_claim: string; - client_secret: string; - scopes: string; - auto_verify_email: boolean; - auto_approve_application: boolean; - account_linking_enabled: boolean; - enabled: boolean; + id: OAuthProviderId; + display_name: string | null; + authorization_endpoint: string | null; + token_endpoint: string | null; + userinfo_endpoint: string | null; + id_claim: string | null; + name_claim: string | null; + client_secret: string | null; + scopes: string | null; + auto_verify_email: boolean | null; + auto_approve_application: boolean | null; + account_linking_enabled: boolean | null; + enabled: boolean | null; } diff --git a/src/types/GetPosts.ts b/src/types/GetPosts.ts index 295632bb..f77f0607 100644 --- a/src/types/GetPosts.ts +++ b/src/types/GetPosts.ts @@ -16,5 +16,6 @@ export interface GetPosts { disliked_only?: boolean; show_hidden?: boolean; show_read?: boolean; + show_nsfw?: boolean; page_cursor?: PaginationCursor; } diff --git a/src/types/LemmyErrorType.ts b/src/types/LemmyErrorType.ts index beae140f..7ef8d277 100644 --- a/src/types/LemmyErrorType.ts +++ b/src/types/LemmyErrorType.ts @@ -168,4 +168,5 @@ export type LemmyErrorType = | { error: "oauth_authorization_invalid" } | { error: "oauth_login_failed" } | { error: "oauth_registration_closed" } + | { error: "couldnt_delete_oauth_provider" } | { error: "unknown"; message: string }; diff --git a/src/types/OAuthAccount.ts b/src/types/OAuthAccount.ts index c7c4a16c..7d0c4186 100644 --- a/src/types/OAuthAccount.ts +++ b/src/types/OAuthAccount.ts @@ -1,10 +1,8 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { LocalUserId } from "./LocalUserId"; -import type { OAuthAccountId } from "./OAuthAccountId"; import type { OAuthProviderId } from "./OAuthProviderId"; export interface OAuthAccount { - id: OAuthAccountId; local_user_id: LocalUserId; oauth_provider_id: OAuthProviderId; oauth_user_id: string; diff --git a/src/types/OAuthAccountId.ts b/src/types/OAuthAccountId.ts deleted file mode 100644 index 3ce24582..00000000 --- a/src/types/OAuthAccountId.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export type OAuthAccountId = number; diff --git a/src/types/OAuthProvider.ts b/src/types/OAuthProvider.ts index cf4a7245..85efc410 100644 --- a/src/types/OAuthProvider.ts +++ b/src/types/OAuthProvider.ts @@ -1,7 +1,8 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProviderId } from "./OAuthProviderId"; export interface OAuthProvider { - id: string; + id: OAuthProviderId; display_name: string; issuer?: string; authorization_endpoint: string; diff --git a/src/types/OAuthProviderInsertForm.ts b/src/types/OAuthProviderInsertForm.ts index f1ee2aa3..390fd676 100644 --- a/src/types/OAuthProviderInsertForm.ts +++ b/src/types/OAuthProviderInsertForm.ts @@ -1,8 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { OAuthProviderId } from "./OAuthProviderId"; export interface OAuthProviderInsertForm { - id: OAuthProviderId; display_name: string; issuer: string; authorization_endpoint: string; diff --git a/src/types/OAuthProviderUpdateForm.ts b/src/types/OAuthProviderUpdateForm.ts index 3b40d554..40c4ad27 100644 --- a/src/types/OAuthProviderUpdateForm.ts +++ b/src/types/OAuthProviderUpdateForm.ts @@ -1,17 +1,17 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. export interface OAuthProviderUpdateForm { - display_name: string; + display_name: string | null; authorization_endpoint: string; token_endpoint: string; userinfo_endpoint: string; - id_claim: string; - name_claim: string; + id_claim: string | null; + name_claim: string | null; client_secret: string | null; - scopes: string; - auto_verify_email: boolean; - auto_approve_application: boolean; - account_linking_enabled: boolean; - enabled: boolean; + scopes: string | null; + auto_verify_email: boolean | null; + auto_approve_application: boolean | null; + account_linking_enabled: boolean | null; + enabled: boolean | null; updated: string; } From 450d1b016c40b7dddf54bf182b8fae0f99273791 Mon Sep 17 00:00:00 2001 From: privacyguard Date: Mon, 15 Jul 2024 22:26:10 +0300 Subject: [PATCH 5/7] removed the auto_approve_application --- src/types/CreateOAuthProvider.ts | 1 - src/types/EditOAuthProvider.ts | 1 - src/types/OAuthProvider.ts | 1 - src/types/OAuthProviderInsertForm.ts | 1 - src/types/OAuthProviderUpdateForm.ts | 1 - 5 files changed, 5 deletions(-) diff --git a/src/types/CreateOAuthProvider.ts b/src/types/CreateOAuthProvider.ts index bc201c94..3bfd83ed 100644 --- a/src/types/CreateOAuthProvider.ts +++ b/src/types/CreateOAuthProvider.ts @@ -12,7 +12,6 @@ export interface CreateOAuthProvider { client_secret: string; scopes: string; auto_verify_email: boolean; - auto_approve_application: boolean; account_linking_enabled: boolean; enabled: boolean; } diff --git a/src/types/EditOAuthProvider.ts b/src/types/EditOAuthProvider.ts index d345d8b2..89ba74db 100644 --- a/src/types/EditOAuthProvider.ts +++ b/src/types/EditOAuthProvider.ts @@ -12,7 +12,6 @@ export interface EditOAuthProvider { client_secret: string | null; scopes: string | null; auto_verify_email: boolean | null; - auto_approve_application: boolean | null; account_linking_enabled: boolean | null; enabled: boolean | null; } diff --git a/src/types/OAuthProvider.ts b/src/types/OAuthProvider.ts index 85efc410..23817c31 100644 --- a/src/types/OAuthProvider.ts +++ b/src/types/OAuthProvider.ts @@ -13,7 +13,6 @@ export interface OAuthProvider { client_id: string; scopes: string; auto_verify_email?: boolean; - auto_approve_application?: boolean; account_linking_enabled?: boolean; enabled?: boolean; published?: string; diff --git a/src/types/OAuthProviderInsertForm.ts b/src/types/OAuthProviderInsertForm.ts index 390fd676..757b9075 100644 --- a/src/types/OAuthProviderInsertForm.ts +++ b/src/types/OAuthProviderInsertForm.ts @@ -12,7 +12,6 @@ export interface OAuthProviderInsertForm { client_secret: string; scopes: string; auto_verify_email: boolean; - auto_approve_application: boolean; account_linking_enabled: boolean; enabled: boolean; } diff --git a/src/types/OAuthProviderUpdateForm.ts b/src/types/OAuthProviderUpdateForm.ts index 40c4ad27..e6e5be0b 100644 --- a/src/types/OAuthProviderUpdateForm.ts +++ b/src/types/OAuthProviderUpdateForm.ts @@ -10,7 +10,6 @@ export interface OAuthProviderUpdateForm { client_secret: string | null; scopes: string | null; auto_verify_email: boolean | null; - auto_approve_application: boolean | null; account_linking_enabled: boolean | null; enabled: boolean | null; updated: string; From 1cbc010348a25b3a03ad2f64d32c9ab59a6c12b6 Mon Sep 17 00:00:00 2001 From: privacyguard Date: Wed, 17 Jul 2024 00:51:23 +0300 Subject: [PATCH 6/7] support registration application with sso --- src/types/AuthenticateWithOauth.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/AuthenticateWithOauth.ts b/src/types/AuthenticateWithOauth.ts index ca151e43..e0034f9c 100644 --- a/src/types/AuthenticateWithOauth.ts +++ b/src/types/AuthenticateWithOauth.ts @@ -4,4 +4,6 @@ export interface AuthenticateWithOauth { code: string; oauth_provider_id: string; redirect_uri: string; + show_nsfw?: boolean; + answer?: string; } From 4f10ac0780b7315e99b364956dac2929d92650a4 Mon Sep 17 00:00:00 2001 From: privacyguard Date: Wed, 24 Jul 2024 20:28:46 +0300 Subject: [PATCH 7/7] update to reflect the changes in lemmy --- src/index.ts | 2 +- src/types/AuthenticateWithOauth.ts | 1 + src/types/CreateOAuthProvider.ts | 1 - src/types/EditOAuthProvider.ts | 1 - src/types/GetSiteResponse.ts | 4 +++- src/types/LemmyErrorType.ts | 2 ++ src/types/OAuthProvider.ts | 17 ++++++++--------- src/types/OAuthProviderInsertForm.ts | 1 - src/types/OAuthProviderUpdateForm.ts | 1 - src/types/PublicOAuthProvider.ts | 4 ++++ src/types/TokenResponse.ts | 9 --------- 11 files changed, 19 insertions(+), 24 deletions(-) create mode 100644 src/types/PublicOAuthProvider.ts delete mode 100644 src/types/TokenResponse.ts diff --git a/src/index.ts b/src/index.ts index d5fa02f4..30e2d4c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -222,6 +222,7 @@ export { PrivateMessageReportView } from "./types/PrivateMessageReportView"; export { PrivateMessageResponse } from "./types/PrivateMessageResponse"; export { PrivateMessageView } from "./types/PrivateMessageView"; export { PrivateMessagesResponse } from "./types/PrivateMessagesResponse"; +export { PublicOAuthProvider } from "./types/PublicOAuthProvider"; export { PurgeComment } from "./types/PurgeComment"; export { PurgeCommunity } from "./types/PurgeCommunity"; export { PurgePerson } from "./types/PurgePerson"; @@ -255,7 +256,6 @@ export { SortType } from "./types/SortType"; export { SubscribedType } from "./types/SubscribedType"; export { SuccessResponse } from "./types/SuccessResponse"; export { Tagline } from "./types/Tagline"; -export { TokenResponse } from "./types/TokenResponse"; export { TransferCommunity } from "./types/TransferCommunity"; export { UpdateTotp } from "./types/UpdateTotp"; export { UpdateTotpResponse } from "./types/UpdateTotpResponse"; diff --git a/src/types/AuthenticateWithOauth.ts b/src/types/AuthenticateWithOauth.ts index e0034f9c..157a5ce7 100644 --- a/src/types/AuthenticateWithOauth.ts +++ b/src/types/AuthenticateWithOauth.ts @@ -5,5 +5,6 @@ export interface AuthenticateWithOauth { oauth_provider_id: string; redirect_uri: string; show_nsfw?: boolean; + username?: string; answer?: string; } diff --git a/src/types/CreateOAuthProvider.ts b/src/types/CreateOAuthProvider.ts index 3bfd83ed..5ad31d35 100644 --- a/src/types/CreateOAuthProvider.ts +++ b/src/types/CreateOAuthProvider.ts @@ -7,7 +7,6 @@ export interface CreateOAuthProvider { token_endpoint: string; userinfo_endpoint: string; id_claim: string; - name_claim: string; client_id: string; client_secret: string; scopes: string; diff --git a/src/types/EditOAuthProvider.ts b/src/types/EditOAuthProvider.ts index 89ba74db..c90c2fcc 100644 --- a/src/types/EditOAuthProvider.ts +++ b/src/types/EditOAuthProvider.ts @@ -8,7 +8,6 @@ export interface EditOAuthProvider { token_endpoint: string | null; userinfo_endpoint: string | null; id_claim: string | null; - name_claim: string | null; client_secret: string | null; scopes: string | null; auto_verify_email: boolean | null; diff --git a/src/types/GetSiteResponse.ts b/src/types/GetSiteResponse.ts index b042180d..8408b9f3 100644 --- a/src/types/GetSiteResponse.ts +++ b/src/types/GetSiteResponse.ts @@ -6,6 +6,7 @@ import type { LocalSiteUrlBlocklist } from "./LocalSiteUrlBlocklist"; import type { MyUserInfo } from "./MyUserInfo"; import type { OAuthProvider } from "./OAuthProvider"; import type { PersonView } from "./PersonView"; +import type { PublicOAuthProvider } from "./PublicOAuthProvider"; import type { SiteView } from "./SiteView"; import type { Tagline } from "./Tagline"; @@ -18,6 +19,7 @@ export interface GetSiteResponse { discussion_languages: Array; taglines: Array; custom_emojis: Array; - oauth_providers: Array; + oauth_providers?: Array; + admin_oauth_providers?: Array; blocked_urls: Array; } diff --git a/src/types/LemmyErrorType.ts b/src/types/LemmyErrorType.ts index 7ef8d277..4683539f 100644 --- a/src/types/LemmyErrorType.ts +++ b/src/types/LemmyErrorType.ts @@ -72,7 +72,9 @@ export type LemmyErrorType = | { error: "invalid_default_post_listing_type" } | { error: "registration_closed" } | { error: "registration_application_answer_required" } + | { error: "registration_username_required" } | { error: "email_already_exists" } + | { error: "username_already_exists" } | { error: "federation_forbidden_by_strict_allow_list" } | { error: "person_is_banned_from_community" } | { error: "object_is_not_public" } diff --git a/src/types/OAuthProvider.ts b/src/types/OAuthProvider.ts index 23817c31..ffcfa031 100644 --- a/src/types/OAuthProvider.ts +++ b/src/types/OAuthProvider.ts @@ -4,17 +4,16 @@ import type { OAuthProviderId } from "./OAuthProviderId"; export interface OAuthProvider { id: OAuthProviderId; display_name: string; - issuer?: string; + issuer: string; authorization_endpoint: string; - token_endpoint?: string; - userinfo_endpoint?: string; - id_claim?: string; - name_claim?: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string; client_id: string; scopes: string; - auto_verify_email?: boolean; - account_linking_enabled?: boolean; - enabled?: boolean; - published?: string; + auto_verify_email: boolean; + account_linking_enabled: boolean; + enabled: boolean; + published: string; updated?: string; } diff --git a/src/types/OAuthProviderInsertForm.ts b/src/types/OAuthProviderInsertForm.ts index 757b9075..0a8d182d 100644 --- a/src/types/OAuthProviderInsertForm.ts +++ b/src/types/OAuthProviderInsertForm.ts @@ -7,7 +7,6 @@ export interface OAuthProviderInsertForm { token_endpoint: string; userinfo_endpoint: string; id_claim: string; - name_claim: string; client_id: string; client_secret: string; scopes: string; diff --git a/src/types/OAuthProviderUpdateForm.ts b/src/types/OAuthProviderUpdateForm.ts index e6e5be0b..0a975d9a 100644 --- a/src/types/OAuthProviderUpdateForm.ts +++ b/src/types/OAuthProviderUpdateForm.ts @@ -6,7 +6,6 @@ export interface OAuthProviderUpdateForm { token_endpoint: string; userinfo_endpoint: string; id_claim: string | null; - name_claim: string | null; client_secret: string | null; scopes: string | null; auto_verify_email: boolean | null; diff --git a/src/types/PublicOAuthProvider.ts b/src/types/PublicOAuthProvider.ts new file mode 100644 index 00000000..9d5d0a02 --- /dev/null +++ b/src/types/PublicOAuthProvider.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProvider } from "./OAuthProvider"; + +export type PublicOAuthProvider = OAuthProvider; diff --git a/src/types/TokenResponse.ts b/src/types/TokenResponse.ts deleted file mode 100644 index fd61d2cd..00000000 --- a/src/types/TokenResponse.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface TokenResponse { - access_token: string; - token_type: string; - expires_in?: number; - refresh_token?: string; - scope?: string; -}