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

feat!: removes deprecated code from Passage class #209

Merged
merged 11 commits into from
Dec 31, 2024

Conversation

ctran88
Copy link
Contributor

@ctran88 ctran88 commented Dec 20, 2024

BEGIN_COMMIT_OVERRIDE
feat!: removes deprecated code from Passage class

feat: validate_jwt only compares the aud claim against the Passage app id
feat: removes redundant error message prefixes
feat!: return void instead of boolean for Passage.user.delete, Passage.user.revokeRefreshTokens, and Passage.user.revokeDevice
END_COMMIT_OVERRIDE

What's New?

  • Removes deprecated methods, types, models, and utilities
  • Throws Error instead of PassageError for non-network errors
  • Adds some more access constraints to fields that do not need to be modified outside of constructor

Screenshots (if appropriate):

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have manually tested my code thoroughly
  • I have added/updated inline documentation for public facing interfaces if relevant
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing integration and unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional context

if (err instanceof ResponseError) {
throw await PassageError.fromResponseError(err, 'Could not fetch app');
}
private configureApi(config?: ConfigurationParameters): Configuration {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this from the root utils directory since it's only used in this class's constructor


user = new User(mockConfig);
// @ts-ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignores the ts compilation error that usersApi is readonly

Comment on lines +43 to +50
const responseError = new ResponseError(
{
status: 502,
json: async () => ({ code: 'error_code', error: 'Bad gateway' }),
} as Response,
'Error',
);
const passageError = await PassageError.fromResponseError(responseError);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting this up just to keep the assert on line 53 that the thrown error is an instance of PassageError

using rejects.toThrow(PassageError) doesn't work because PassageError is no longer "constructable" due to the private constructor

@@ -63,12 +64,14 @@ export class User extends PassageBase {

const users = response.users;
if (!users.length) {
throw new PassageError('User not found.');
throw new ResponseError(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still want to throw a PassageError to emulate a network error here since this method should essentially have the same behavior as the get

@ctran88 ctran88 marked this pull request as ready for review December 20, 2024 18:55
@ctran88 ctran88 requested a review from a team December 20, 2024 18:55
@ctran88 ctran88 force-pushed the PSG-5585-camelcase-codegen branch from f532693 to deba066 Compare December 20, 2024 23:12
@ctran88 ctran88 force-pushed the PSG-5213-remove-deprecated-code branch 2 times, most recently from 25f3bcd to 175827e Compare December 23, 2024 20:14
Base automatically changed from PSG-5585-camelcase-codegen to main December 26, 2024 21:44
/**
* Auth class constructor.
* @param {PassageInstanceConfig} config config properties for Passage instance
*/
public constructor(protected config: PassageInstanceConfig) {
public constructor(protected readonly config: PassageInstanceConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also mark the constructor in PassageBase as protected readonly which should enforce that for inherited classes

Copy link
Contributor Author

@ctran88 ctran88 Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in 3a73261

src/index.ts Outdated
export * from './types/JWKS';
export * from './types/MagicLink';
export * from './types/PassageConfig';
export * from './types/User';
export * from './generated/models';
Copy link
Contributor

@flanagankp flanagankp Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to remove export * from './generated/models';. The idea is that any generated types that are returned by our classes have re-exported them from the types.ts file in each of the classes/<ClassName> directories.

Copy link
Contributor Author

@ctran88 ctran88 Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in fd686ac

@ctran88 ctran88 force-pushed the PSG-5213-remove-deprecated-code branch from 2bf3e5a to fd686ac Compare December 30, 2024 20:28
@ctran88 ctran88 merged commit ba42c26 into main Dec 31, 2024
6 checks passed
@ctran88 ctran88 deleted the PSG-5213-remove-deprecated-code branch December 31, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants