Skip to content

Commit 4316183

Browse files
refactor(sign): extract non-retriable error helper
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 201c74d commit 4316183

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
export const NON_RETRIABLE_SIGN_ERROR_CODE = 422
7+
8+
type SignMethodLike = {
9+
method?: string
10+
modalCode?: string
11+
}
12+
13+
type SignErrorLike = {
14+
code?: number | string
15+
}
16+
17+
type SubmissionErrorLike = {
18+
errors?: SignErrorLike[]
19+
}
20+
21+
export function shouldCloseCurrentModalOnSignError(
22+
methodConfig: SignMethodLike,
23+
signError: SubmissionErrorLike,
24+
): boolean {
25+
const modalCode = methodConfig.modalCode || methodConfig.method || 'token'
26+
if (modalCode !== 'password') {
27+
return false
28+
}
29+
30+
const errors = Array.isArray(signError.errors) ? signError.errors : []
31+
return errors.some((error) => Number(error?.code) === NON_RETRIABLE_SIGN_ERROR_CODE)
32+
}

0 commit comments

Comments
 (0)