Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add refresh peer token to FishjamClient API #69

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/fishjam-openapi/openapi.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ echo "Generating code for $1...\n"

cd $ROOTDIR \
&& npx @openapitools/openapi-generator-cli generate \
-i https://raw.githubusercontent.com/fishjam-cloud/fishjam/$1/openapi.yaml?token=$2 \
-i https://raw.githubusercontent.com/fishjam-cloud/fishjam/refs/heads/$1/openapi.yaml?token=$2 \
-g typescript-axios \
-o ./src/generated
108 changes: 107 additions & 1 deletion packages/fishjam-openapi/src/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Fishjam Media Server
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.8.0
* The version of the OpenAPI document: 0.9.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -743,6 +743,32 @@ export interface PeerOptionsWebRTC {
*/
'metadata'?: { [key: string]: any; };
}
/**
* Response containing new peer token
* @export
* @interface PeerRefreshTokenResponse
*/
export interface PeerRefreshTokenResponse {
/**
*
* @type {PeerRefreshTokenResponseData}
* @memberof PeerRefreshTokenResponse
*/
'data': PeerRefreshTokenResponseData;
}
/**
*
* @export
* @interface PeerRefreshTokenResponseData
*/
export interface PeerRefreshTokenResponseData {
/**
* Token for authorizing websocket connection
* @type {string}
* @memberof PeerRefreshTokenResponseData
*/
'token': string;
}
/**
* Informs about the peer status
* @export
Expand Down Expand Up @@ -2085,6 +2111,48 @@ export const RoomApiAxiosParamCreator = function (configuration?: Configuration)



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Refresh peer token
* @param {string} roomId Room ID
* @param {string} id Peer id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
refreshToken: async (roomId: string, id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'roomId' is not null or undefined
assertParamExists('refreshToken', 'roomId', roomId)
// verify required parameter 'id' is not null or undefined
assertParamExists('refreshToken', 'id', id)
const localVarPath = `/room/{room_id}/peer/{id}/refresh_token`
.replace(`{${"room_id"}}`, encodeURIComponent(String(roomId)))
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

// authentication authorization required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
Expand Down Expand Up @@ -2257,6 +2325,20 @@ export const RoomApiFp = function(configuration?: Configuration) {
const localVarOperationServerBasePath = operationServerMap['RoomApi.getRoom']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @summary Refresh peer token
* @param {string} roomId Room ID
* @param {string} id Peer id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async refreshToken(roomId: string, id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PeerRefreshTokenResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.refreshToken(roomId, id, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['RoomApi.refreshToken']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @summary Subscribe component to the tracks of peers or components
Expand Down Expand Up @@ -2365,6 +2447,17 @@ export const RoomApiFactory = function (configuration?: Configuration, basePath?
getRoom(roomId: string, options?: any): AxiosPromise<RoomDetailsResponse> {
return localVarFp.getRoom(roomId, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Refresh peer token
* @param {string} roomId Room ID
* @param {string} id Peer id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
refreshToken(roomId: string, id: string, options?: any): AxiosPromise<PeerRefreshTokenResponse> {
return localVarFp.refreshToken(roomId, id, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Subscribe component to the tracks of peers or components
Expand Down Expand Up @@ -2486,6 +2579,19 @@ export class RoomApi extends BaseAPI {
return RoomApiFp(this.configuration).getRoom(roomId, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Refresh peer token
* @param {string} roomId Room ID
* @param {string} id Peer id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof RoomApi
*/
public refreshToken(roomId: string, id: string, options?: RawAxiosRequestConfig) {
return RoomApiFp(this.configuration).refreshToken(roomId, id, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Subscribe component to the tracks of peers or components
Expand Down
2 changes: 1 addition & 1 deletion packages/fishjam-openapi/src/generated/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Fishjam Media Server
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.8.0
* The version of the OpenAPI document: 0.9.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion packages/fishjam-openapi/src/generated/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Fishjam Media Server
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.8.0
* The version of the OpenAPI document: 0.9.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion packages/fishjam-openapi/src/generated/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Fishjam Media Server
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.8.0
* The version of the OpenAPI document: 0.9.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion packages/fishjam-openapi/src/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Fishjam Media Server
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.8.0
* The version of the OpenAPI document: 0.9.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
7 changes: 7 additions & 0 deletions packages/js-server-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,11 @@ export class FishjamClient {
async deleteRoom(roomId: string): Promise<void> {
await this.roomApi.deleteRoom(roomId).catch((error) => raiseExceptions(error, 'room'));
}

async refreshPeerToken(roomId: string, peerId: string): Promise<string> {
const refreshTokenResponse = await this.roomApi
.refreshToken(roomId, peerId)
.catch((error) => raiseExceptions(error, 'peer'));
return refreshTokenResponse.data.data.token;
}
}