-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
if (err instanceof ResponseError) { | ||
throw await PassageError.fromResponseError(err, 'Could not fetch app'); | ||
} | ||
private configureApi(config?: ConfigurationParameters): Configuration { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
const responseError = new ResponseError( | ||
{ | ||
status: 502, | ||
json: async () => ({ code: 'error_code', error: 'Bad gateway' }), | ||
} as Response, | ||
'Error', | ||
); | ||
const passageError = await PassageError.fromResponseError(responseError); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
f532693
to
deba066
Compare
25f3bcd
to
175827e
Compare
src/classes/Auth/Auth.ts
Outdated
/** | ||
* Auth class constructor. | ||
* @param {PassageInstanceConfig} config config properties for Passage instance | ||
*/ | ||
public constructor(protected config: PassageInstanceConfig) { | ||
public constructor(protected readonly config: PassageInstanceConfig) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed in fd686ac
…Errors to std Error
…i object initialization to constructor
feat: changes jwt validation to only check app id in audience using the jwt libs validation options
2bf3e5a
to
fd686ac
Compare
Quality Gate passedIssues Measures |
BEGIN_COMMIT_OVERRIDE
feat!: removes deprecated code from Passage class
feat:
validate_jwt
only compares the aud claim against the Passage app idfeat: removes redundant error message prefixes
feat!: return void instead of boolean for
Passage.user.delete
,Passage.user.revokeRefreshTokens
, andPassage.user.revokeDevice
END_COMMIT_OVERRIDE
What's New?
Error
instead ofPassageError
for non-network errorsScreenshots (if appropriate):
Type of change
Checklist:
Additional context