Skip to content

Commit

Permalink
Feat(authentication.ts): Add isValid Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
WillKirkmanM committed Dec 15, 2024
1 parent 2c591bb commit 7a48c72
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/music-sdk/src/lib/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@ export async function register(data: AuthData): Promise<ResponseAuthData> {
return response.data;
}

interface TokenValidationResponse {
status: boolean;
token_type?: string;
claims?: {
sub: string;
exp: number;
username: string;
bitrate: number;
token_type: string;
role: string;
};
message?: string;
}

/**
* Check if the current token is valid.
* @returns {Promise<TokenValidationResponse>} - A promise that resolves to the validation response.
*/
export async function isValid(): Promise<TokenValidationResponse> {
const response = await axios.get('/auth/is-valid');
return response.data;
}

/**
* Login a user.
* @param {AuthData} data - The login data.
Expand Down

0 comments on commit 7a48c72

Please sign in to comment.