-
Notifications
You must be signed in to change notification settings - Fork 465
Expose default onCallback #2488
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,7 +118,11 @@ export type OnCallbackContext = { | |
| export type OnCallbackHook = ( | ||
| error: SdkError | null, | ||
| ctx: OnCallbackContext, | ||
| session: SessionData | null | ||
| session: SessionData | null, | ||
| defaultOnCallback: ( | ||
| error: SdkError | null, | ||
| ctx: OnCallbackContext | ||
| ) => Promise<NextResponse> | ||
| ) => Promise<NextResponse>; | ||
|
|
||
| // params passed to the /authorize endpoint that cannot be overwritten | ||
|
|
@@ -676,7 +680,12 @@ export class AuthClient { | |
| state | ||
| ); | ||
| if (!transactionStateCookie) { | ||
| return this.onCallback(new InvalidStateError(), {}, null); | ||
| return this.onCallback( | ||
| new InvalidStateError(), | ||
| {}, | ||
| null, | ||
| this.defaultOnCallback | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ); | ||
| } | ||
|
|
||
| const transactionState = transactionStateCookie.payload; | ||
|
|
@@ -745,7 +754,8 @@ export class AuthClient { | |
| ...onCallbackCtx, | ||
| connectedAccount | ||
| }, | ||
| session | ||
| session, | ||
| this.defaultOnCallback | ||
| ); | ||
|
|
||
| await this.transactionStore.delete(res.cookies, state); | ||
|
|
@@ -888,7 +898,12 @@ export class AuthClient { | |
| } | ||
| }; | ||
|
|
||
| const res = await this.onCallback(null, onCallbackCtx, session); | ||
| const res = await this.onCallback( | ||
| null, | ||
| onCallbackCtx, | ||
| session, | ||
| this.defaultOnCallback | ||
| ); | ||
|
|
||
| // call beforeSessionSaved callback if present | ||
| // if not then filter id_token claims with default rules | ||
|
|
@@ -1413,7 +1428,12 @@ export class AuthClient { | |
| req: NextRequest, | ||
| state?: string | ||
| ): Promise<NextResponse> { | ||
| const response = await this.onCallback(error, ctx, null); | ||
| const response = await this.onCallback( | ||
| error, | ||
| ctx, | ||
| null, | ||
| this.defaultOnCallback | ||
| ); | ||
|
|
||
| // Clean up the transaction cookie on error to prevent accumulation | ||
| if (state) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Could we add JSDoc on type parameters, IDEs (VS Code, WebStorm) surface these on hover. Something like below should be good.