Skip to content

Commit 4f50a61

Browse files
authored
Initial OAuth work
1 parent 46e0a85 commit 4f50a61

15 files changed

Lines changed: 958 additions & 0 deletions

File tree

src/lib/api/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Configuration as ConfigurationV1,
88
HubManagementApi as HubManagementV1Api,
99
MetaApi,
10+
OAuthApi,
1011
PublicShockerSharesApi,
1112
SessionsApi,
1213
ShockerSharesApi as ShockerSharesV1Api,
@@ -59,3 +60,4 @@ export const publicShockerSharesApi = new PublicShockerSharesApi(DefaultApiV1Con
5960
export const shockerSharesV1Api = new ShockerSharesV1Api(DefaultApiV1Configuration);
6061
export const shockerSharesV2Api = new ShockerSharesV2Api(DefaultApiV2Configuration);
6162
export const usersApi = new UsersApi(DefaultApiV1Configuration);
63+
export const oauthApi = new OAuthApi(DefaultApiV1Configuration);

src/lib/api/internal/v1/.openapi-generator/FILES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ apis/AdminApi.ts
44
apis/HubEndpointsApi.ts
55
apis/HubManagementApi.ts
66
apis/MetaApi.ts
7+
apis/OAuthApi.ts
78
apis/PublicShockerSharesApi.ts
89
apis/SessionsApi.ts
910
apis/ShockerSharesApi.ts
@@ -48,9 +49,13 @@ models/LogEntry.ts
4849
models/LogEntryIAsyncEnumerableLegacyDataResponse.ts
4950
models/Login.ts
5051
models/LoginSessionResponse.ts
52+
models/LoginV2OkResponse.ts
5153
models/MatchTypeEnum.ts
5254
models/MinimalShocker.ts
5355
models/NewShocker.ts
56+
models/OAuthConnectionResponse.ts
57+
models/OAuthFinalizeRequest.ts
58+
models/OAuthSignupDataResponse.ts
5459
models/OpenShockProblem.ts
5560
models/OtaItem.ts
5661
models/OtaItemIReadOnlyCollectionLegacyDataResponse.ts

src/lib/api/internal/v1/apis/AccountApi.ts

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ import type {
2020
ChangeUsernameRequest,
2121
LegacyEmptyResponse,
2222
Login,
23+
OAuthConnectionResponse,
2324
OpenShockProblem,
2425
PasswordResetProcessData,
26+
ProblemDetails,
2527
ResetRequest,
2628
SignUp,
2729
UsernameCheckResponse,
@@ -37,10 +39,14 @@ import {
3739
LegacyEmptyResponseToJSON,
3840
LoginFromJSON,
3941
LoginToJSON,
42+
OAuthConnectionResponseFromJSON,
43+
OAuthConnectionResponseToJSON,
4044
OpenShockProblemFromJSON,
4145
OpenShockProblemToJSON,
4246
PasswordResetProcessDataFromJSON,
4347
PasswordResetProcessDataToJSON,
48+
ProblemDetailsFromJSON,
49+
ProblemDetailsToJSON,
4450
ResetRequestFromJSON,
4551
ResetRequestToJSON,
4652
SignUpFromJSON,
@@ -76,6 +82,10 @@ export interface AccountSignUpRequest {
7682
signUp?: SignUp;
7783
}
7884

85+
export interface AuthenticatedAccountAddOAuthConnectionRequest {
86+
provider: string;
87+
}
88+
7989
export interface AuthenticatedAccountChangeEmailRequest {
8090
changeEmailRequest?: ChangeEmailRequest;
8191
}
@@ -88,6 +98,10 @@ export interface AuthenticatedAccountChangeUsernameRequest {
8898
changeUsernameRequest?: ChangeUsernameRequest;
8999
}
90100

101+
export interface AuthenticatedAccountRemoveOAuthConnectionRequest {
102+
provider: string;
103+
}
104+
91105
/**
92106
* AccountApi - interface
93107
*
@@ -200,6 +214,22 @@ export interface AccountApiInterface {
200214
*/
201215
accountSignUp(signUp?: SignUp, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LegacyEmptyResponse>;
202216

217+
/**
218+
* Initiates the OAuth flow (link mode) for a given provider. On success this returns a `302 Found` to the provider\'s authorization page. After consent, the OAuth middleware will call the internal callback and finally redirect to `/1/oauth/{provider}/handoff`.
219+
* @summary Start linking an OAuth provider to the current account.
220+
* @param {string} provider Provider key (e.g. &#x60;discord&#x60;).
221+
* @param {*} [options] Override http request option.
222+
* @throws {RequiredError}
223+
* @memberof AccountApiInterface
224+
*/
225+
authenticatedAccountAddOAuthConnectionRaw(requestParameters: AuthenticatedAccountAddOAuthConnectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;
226+
227+
/**
228+
* Initiates the OAuth flow (link mode) for a given provider. On success this returns a `302 Found` to the provider\'s authorization page. After consent, the OAuth middleware will call the internal callback and finally redirect to `/1/oauth/{provider}/handoff`.
229+
* Start linking an OAuth provider to the current account.
230+
*/
231+
authenticatedAccountAddOAuthConnection(provider: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;
232+
203233
/**
204234
*
205235
* @summary Change the password of the current user
@@ -259,6 +289,35 @@ export interface AccountApiInterface {
259289
*/
260290
authenticatedAccountDeactivate(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<string>;
261291

292+
/**
293+
*
294+
* @summary List OAuth connections linked to the current user.
295+
* @param {*} [options] Override http request option.
296+
* @throws {RequiredError}
297+
* @memberof AccountApiInterface
298+
*/
299+
authenticatedAccountListOAuthConnectionsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<OAuthConnectionResponse>>>;
300+
301+
/**
302+
* List OAuth connections linked to the current user.
303+
*/
304+
authenticatedAccountListOAuthConnections(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<OAuthConnectionResponse>>;
305+
306+
/**
307+
*
308+
* @summary Remove an existing OAuth connection for the current user.
309+
* @param {string} provider Provider key (e.g. &#x60;discord&#x60;).
310+
* @param {*} [options] Override http request option.
311+
* @throws {RequiredError}
312+
* @memberof AccountApiInterface
313+
*/
314+
authenticatedAccountRemoveOAuthConnectionRaw(requestParameters: AuthenticatedAccountRemoveOAuthConnectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;
315+
316+
/**
317+
* Remove an existing OAuth connection for the current user.
318+
*/
319+
authenticatedAccountRemoveOAuthConnection(provider: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;
320+
262321
}
263322

264323
/**
@@ -513,6 +572,44 @@ export class AccountApi extends runtime.BaseAPI implements AccountApiInterface {
513572
return await response.value();
514573
}
515574

575+
/**
576+
* Initiates the OAuth flow (link mode) for a given provider. On success this returns a `302 Found` to the provider\'s authorization page. After consent, the OAuth middleware will call the internal callback and finally redirect to `/1/oauth/{provider}/handoff`.
577+
* Start linking an OAuth provider to the current account.
578+
*/
579+
async authenticatedAccountAddOAuthConnectionRaw(requestParameters: AuthenticatedAccountAddOAuthConnectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
580+
if (requestParameters['provider'] == null) {
581+
throw new runtime.RequiredError(
582+
'provider',
583+
'Required parameter "provider" was null or undefined when calling authenticatedAccountAddOAuthConnection().'
584+
);
585+
}
586+
587+
const queryParameters: any = {};
588+
589+
const headerParameters: runtime.HTTPHeaders = {};
590+
591+
592+
let urlPath = `/1/account/connections/{provider}/link`;
593+
urlPath = urlPath.replace(`{${"provider"}}`, encodeURIComponent(String(requestParameters['provider'])));
594+
595+
const response = await this.request({
596+
path: urlPath,
597+
method: 'GET',
598+
headers: headerParameters,
599+
query: queryParameters,
600+
}, initOverrides);
601+
602+
return new runtime.VoidApiResponse(response);
603+
}
604+
605+
/**
606+
* Initiates the OAuth flow (link mode) for a given provider. On success this returns a `302 Found` to the provider\'s authorization page. After consent, the OAuth middleware will call the internal callback and finally redirect to `/1/oauth/{provider}/handoff`.
607+
* Start linking an OAuth provider to the current account.
608+
*/
609+
async authenticatedAccountAddOAuthConnection(provider: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
610+
await this.authenticatedAccountAddOAuthConnectionRaw({ provider: provider }, initOverrides);
611+
}
612+
516613
/**
517614
* Change the password of the current user
518615
*/
@@ -640,4 +737,69 @@ export class AccountApi extends runtime.BaseAPI implements AccountApiInterface {
640737
return await response.value();
641738
}
642739

740+
/**
741+
* List OAuth connections linked to the current user.
742+
*/
743+
async authenticatedAccountListOAuthConnectionsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<OAuthConnectionResponse>>> {
744+
const queryParameters: any = {};
745+
746+
const headerParameters: runtime.HTTPHeaders = {};
747+
748+
749+
let urlPath = `/1/account/connections`;
750+
751+
const response = await this.request({
752+
path: urlPath,
753+
method: 'GET',
754+
headers: headerParameters,
755+
query: queryParameters,
756+
}, initOverrides);
757+
758+
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OAuthConnectionResponseFromJSON));
759+
}
760+
761+
/**
762+
* List OAuth connections linked to the current user.
763+
*/
764+
async authenticatedAccountListOAuthConnections(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<OAuthConnectionResponse>> {
765+
const response = await this.authenticatedAccountListOAuthConnectionsRaw(initOverrides);
766+
return await response.value();
767+
}
768+
769+
/**
770+
* Remove an existing OAuth connection for the current user.
771+
*/
772+
async authenticatedAccountRemoveOAuthConnectionRaw(requestParameters: AuthenticatedAccountRemoveOAuthConnectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
773+
if (requestParameters['provider'] == null) {
774+
throw new runtime.RequiredError(
775+
'provider',
776+
'Required parameter "provider" was null or undefined when calling authenticatedAccountRemoveOAuthConnection().'
777+
);
778+
}
779+
780+
const queryParameters: any = {};
781+
782+
const headerParameters: runtime.HTTPHeaders = {};
783+
784+
785+
let urlPath = `/1/account/connections/{provider}`;
786+
urlPath = urlPath.replace(`{${"provider"}}`, encodeURIComponent(String(requestParameters['provider'])));
787+
788+
const response = await this.request({
789+
path: urlPath,
790+
method: 'DELETE',
791+
headers: headerParameters,
792+
query: queryParameters,
793+
}, initOverrides);
794+
795+
return new runtime.VoidApiResponse(response);
796+
}
797+
798+
/**
799+
* Remove an existing OAuth connection for the current user.
800+
*/
801+
async authenticatedAccountRemoveOAuthConnection(provider: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
802+
await this.authenticatedAccountRemoveOAuthConnectionRaw({ provider: provider }, initOverrides);
803+
}
804+
643805
}

0 commit comments

Comments
 (0)