Skip to content

Commit

Permalink
chore: bump @ory/client v1.1.39
Browse files Browse the repository at this point in the history
  • Loading branch information
Benehiko committed Jun 28, 2023
1 parent eb0af2a commit 73df1cb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
"@ory/client": "1.1.23",
"@ory/client": "1.1.39",
"@ory/elements-markup": "0.0.1-beta.6",
"@ory/integrations": "1.1.0",
"axios": "1.2.6",
Expand Down
51 changes: 25 additions & 26 deletions src/pkg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export const getUrlForFlow = (
flow: string,
query?: URLSearchParams,
) =>
`${removeTrailingSlash(base)}/self-service/${flow}/browser${
query ? `?${query.toString()}` : ""
`${removeTrailingSlash(base)}/self-service/${flow}/browser${query ? `?${query.toString()}` : ""
}`

export const defaultConfig: RouteOptionsCreator = () => {
Expand All @@ -44,40 +43,40 @@ const isErrorAuthenticatorAssuranceLevel = (
err: unknown,
): err is ErrorAuthenticatorAssuranceLevelNotSatisfied => {
const e = err as ErrorAuthenticatorAssuranceLevelNotSatisfied
return e.id !== undefined && e.id === "session_aal2_required"
return e.error?.id !== undefined && e.error?.id === "session_aal2_required"
}

// Redirects to the specified URL if the error is an AxiosError with a 404, 410,
// or 403 error code.
export const redirectOnSoftError =
(res: Response, next: NextFunction, redirectTo: string) =>
(err: AxiosError) => {
if (!err.response) {
next(err)
return
}
(err: AxiosError) => {
if (!err.response) {
next(err)
return
}

if (
err.response.status === 404 ||
err.response.status === 410 ||
err.response.status === 403
) {
const error = err.response.data as { error: unknown }
if (error.error !== undefined) {
// in some cases Kratos will require us to redirect to a different page when the session_aal2_required
// for example, when recovery redirects us to settings
// but settings requires us to redirect to login?aal=aal2
if (isErrorAuthenticatorAssuranceLevel(error.error)) {
res.redirect(error.error.details?.redirect_browser_to || redirectTo)
return
if (
err.response.status === 404 ||
err.response.status === 410 ||
err.response.status === 403
) {
const error = err.response.data as { error: unknown }
if (error.error !== undefined) {
// in some cases Kratos will require us to redirect to a different page when the session_aal2_required
// for example, when recovery redirects us to settings
// but settings requires us to redirect to login?aal=aal2
if (isErrorAuthenticatorAssuranceLevel(error.error)) {
res.redirect(error.error.redirect_browser_to || redirectTo)
return
}
}
res.redirect(`${redirectTo}`)
return
}
res.redirect(`${redirectTo}`)
return
}

next(err)
}
next(err)
}

export const handlebarsHelpers = {
jsonPretty: (context: any) => JSON.stringify(context, null, 2),
Expand Down

0 comments on commit 73df1cb

Please sign in to comment.