FCE-2044 validate credentials at client creation#271
Open
czerwiukk wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds fail-fast configuration/credential validation paths for FishjamClient, introducing an async factory to verify credentials against the backend and a reusable config-validation helper, with accompanying test coverage.
Changes:
- Added
validateFishjamConfigandMissingManagementTokenExceptionto validate required config fields at construction time. - Introduced
FishjamClient.create()(async factory) andcheckCredentials()to validate credentials via a backend call. - Added new Vitest coverage for sync config validation and mocked credential-check behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/js-server-sdk/tests/config-validation.test.ts | Adds tests for constructor config validation and mocked backend credential checks via getAllRooms. |
| packages/js-server-sdk/src/utils.ts | Introduces validateFishjamConfig to enforce presence of fishjamId and managementToken. |
| packages/js-server-sdk/src/exceptions/index.ts | Adds MissingManagementTokenException for missing/empty management token config. |
| packages/js-server-sdk/src/client.ts | Validates config in constructor; adds create() async factory and checkCredentials() method with updated JSDoc. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Async factory. Constructs a client and verifies that the provided | ||
| * `fishjamId` and `managementToken` are accepted by the Fishjam backend. | ||
| * | ||
| * Throws {@link InvalidFishjamConfigException} for malformed config, |
Comment on lines
+36
to
+37
| * Fishjam backend. Use {@link FishjamClient.create} or | ||
| * {@link FishjamClient.checkCredentials} to verify them at construction time. |
Comment on lines
+93
to
+101
| * Verifies the configured credentials by making a single lightweight | ||
| * call to the Fishjam backend. Resolves on success, otherwise throws the | ||
| * same exception types thrown by other client methods (notably | ||
| * {@link UnauthorizedException} and {@link FishjamNotFoundException}). | ||
| */ | ||
| async checkCredentials(): Promise<void> { | ||
| try { | ||
| await this.roomApi.getAllRooms(); | ||
| } catch (error) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds credentials validation to the preferred way of creating the client.
There is also a separate checkCredentials method if someone needs to create the client synchronously.
Motivation and Context
The SDK client should fail fast when misconfigured.
Documentation impact
Types of changes
not work as expected)