Replace createPromise() with standarized API and syntax#102
Replace createPromise() with standarized API and syntax#102jonkoops merged 1 commit intokeycloak:mainfrom
createPromise() with standarized API and syntax#102Conversation
Closes keycloak#88 Signed-off-by: Jon Koops <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the custom createPromise() implementation with standardized Promise API and simplifies asynchronous flow by using async/await.
- Corrected error message text in tests to improve clarity and consistency.
- Added test cases to assert correct behavior for token refresh including the scenario with login iframe disabled.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/tests/user-profile.spec.ts | Updated error message text for loadUserProfile rejection |
| test/tests/token.spec.ts | Updated error message expectation for updateToken and added extra test for iframe disabled scenario |
| test/tests/account-url.spec.ts | Updated error message text for createAccountUrl rejection |
Comments suppressed due to low confidence (3)
test/tests/user-profile.spec.ts:34
- The error message text has been updated for clarity; please verify that it matches the standardized API expectations.
await expect(executor.loadUserProfile()).rejects.toThrow('Unable to load user profile, make sure the adapter is not configured using a generic OIDC provider.')
test/tests/token.spec.ts:10
- The test now expects a specific error message for updateToken; ensure that the new error string aligns with the updated implementation.
await expect(executor.updateToken(9999)).rejects.toThrow('Unable to update token, no refresh token available.')
test/tests/account-url.spec.ts:34
- The error message correction improves clarity; confirm this change is consistent with similar adjustments in other parts of the test suite.
await expect(executor.createAccountUrl()).rejects.toThrow('Unable to create account URL, make sure the adapter is not configured using a generic OIDC provider.')
mposolda
left a comment
There was a problem hiding this comment.
Approving. Nice stuff! IMO keycloak.js looks much better now without custom promises.
I assume that this does not need any changes in the documentation and any changes in the application consuming keycloak.js. Is it correct?
|
Correct, this is just a refactor of the internals to get away from the custom promise implementation we have internally to an implementation that uses as much standard JavaScript syntax and APIs. |
Removes the custom internal
createPromise()implementation, which is a remnant of the old custom promises that Keycloak JS used to use. This replaces all the internals with the standard Promise API, and untangles a bunch of spaghetti code caused by callbacks by replacing them withasyncfunctions andawaiting them.Closes #88