Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
matrix-react-sdk
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Matrix.org
matrix-react-sdk
Commits
30325564
Commit
30325564
authored
1 year ago
by
Hugh Nimmo-Smith
Browse files
Options
Downloads
Patches
Plain Diff
Update failure reasons to match MSC
parent
737f2075
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/views/auth/LoginWithQR.tsx
+10
-10
10 additions, 10 deletions
src/components/views/auth/LoginWithQR.tsx
src/components/views/auth/LoginWithQRFlow.tsx
+14
-15
14 additions, 15 deletions
src/components/views/auth/LoginWithQRFlow.tsx
with
24 additions
and
25 deletions
src/components/views/auth/LoginWithQR.tsx
+
10
−
10
View file @
30325564
...
...
@@ -16,14 +16,14 @@ limitations under the License.
import
React
,
{
lazy
,
Suspense
}
from
"
react
"
;
// We import "matrix-js-sdk/src/rendezvous" asynchronously to avoid importing the entire Rust Crypto WASM into the main bundle.
import
{
RendezvousFailureReason
}
from
"
matrix-js-sdk/src/rendezvous/RendezvousFailureReason
"
;
import
{
ClientRendezvousFailureReason
,
MSC4108FailureReason
,
RendezvousFailureReason
}
from
"
matrix-js-sdk/src/rendezvous/RendezvousFailureReason
"
;
import
{
RendezvousIntent
}
from
"
matrix-js-sdk/src/rendezvous/RendezvousIntent
"
;
import
{
logger
}
from
"
matrix-js-sdk/src/logger
"
;
import
{
MatrixClient
,
discoverAndValidateOIDCIssuerWellKnown
,
generateScope
}
from
"
matrix-js-sdk/src/matrix
"
;
import
{
OnResultFunction
}
from
"
react-qr-reader
"
;
import
{
OidcClient
}
from
"
oidc-client-ts
"
;
import
{
RendezvousError
,
type
MSC4108SignInWithQR
}
from
"
matrix-js-sdk/src/rendezvous
"
;
import
{
getOidcClientId
}
from
"
../../../utils/oidc/registerClient
"
;
import
SdkConfig
from
"
../../../SdkConfig
"
;
import
{
completeDeviceAuthorizationGrant
}
from
"
../../../Lifecycle
"
;
...
...
@@ -144,7 +144,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
// eslint-disable-next-line react/no-direct-mutation-state
this
.
state
.
rendezvous
.
onFailure
=
undefined
;
// calling cancel will call close() as well to clean up the resources
this
.
state
.
rendezvous
.
cancel
(
Rendezvous
FailureReason
.
UserCancelled
).
then
(()
=>
{});
this
.
state
.
rendezvous
.
cancel
(
MSC4108
FailureReason
.
UserCancelled
).
then
(()
=>
{});
}
}
...
...
@@ -197,7 +197,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
});
}
catch
(
e
)
{
logger
.
error
(
"
Error whilst generating QR code
"
,
e
);
this
.
setState
({
phase
:
Phase
.
Error
,
failureReason
:
RendezvousFailureReason
.
HomeserverLacksSupport
});
this
.
setState
({
phase
:
Phase
.
Error
,
failureReason
:
Client
RendezvousFailureReason
.
HomeserverLacksSupport
});
return
;
}
...
...
@@ -228,7 +228,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
// we ask the user to confirm that the channel is secure
}
catch
(
e
:
RendezvousError
|
unknown
)
{
logger
.
error
(
"
Error whilst generating QR
"
,
e
);
await
this
.
state
.
rendezvous
?.
cancel
(
e
instanceof
RendezvousError
?
e
.
code
:
RendezvousFailureReason
.
Unknown
);
await
this
.
state
.
rendezvous
?.
cancel
(
e
instanceof
RendezvousError
?
e
.
code
:
Client
RendezvousFailureReason
.
Unknown
);
}
};
...
...
@@ -239,7 +239,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
return
;
// suppress duplicate scans
}
if
(
this
.
state
.
rendezvous
)
{
await
this
.
state
.
rendezvous
.
cancel
(
Rendezvous
FailureReason
.
UserCancelled
);
await
this
.
state
.
rendezvous
.
cancel
(
MSC4108
FailureReason
.
UserCancelled
);
this
.
reset
();
}
...
...
@@ -314,7 +314,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
}
}
catch
(
e
:
RendezvousError
|
unknown
)
{
logger
.
error
(
"
Error whilst scanning QR
"
,
e
);
await
this
.
state
.
rendezvous
?.
cancel
(
e
instanceof
RendezvousError
?
e
.
code
:
RendezvousFailureReason
.
Unknown
);
await
this
.
state
.
rendezvous
?.
cancel
(
e
instanceof
RendezvousError
?
e
.
code
:
Client
RendezvousFailureReason
.
Unknown
);
}
};
...
...
@@ -388,7 +388,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
}
}
catch
(
e
:
RendezvousError
|
unknown
)
{
logger
.
error
(
"
Error whilst approving login
"
,
e
);
await
this
.
state
.
rendezvous
?.
cancel
(
e
instanceof
RendezvousError
?
e
.
code
:
RendezvousFailureReason
.
Unknown
);
await
this
.
state
.
rendezvous
?.
cancel
(
e
instanceof
RendezvousError
?
e
.
code
:
Client
RendezvousFailureReason
.
Unknown
);
}
};
...
...
@@ -413,7 +413,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
private
onClick
=
async
(
type
:
Click
,
checkCode
?:
string
):
Promise
<
void
>
=>
{
switch
(
type
)
{
case
Click
.
Cancel
:
await
this
.
state
.
rendezvous
?.
cancel
(
Rendezvous
FailureReason
.
UserCancelled
);
await
this
.
state
.
rendezvous
?.
cancel
(
MSC4108
FailureReason
.
UserCancelled
);
this
.
reset
();
this
.
props
.
onFinished
(
false
);
break
;
...
...
@@ -430,7 +430,7 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
await
this
.
updateMode
(
this
.
props
.
mode
);
break
;
case
Click
.
Back
:
await
this
.
state
.
rendezvous
?.
cancel
(
Rendezvous
FailureReason
.
UserCancelled
);
await
this
.
state
.
rendezvous
?.
cancel
(
MSC4108
FailureReason
.
UserCancelled
);
this
.
props
.
onFinished
(
false
);
break
;
case
Click
.
ScanQr
:
...
...
This diff is collapsed.
Click to expand it.
src/components/views/auth/LoginWithQRFlow.tsx
+
14
−
15
View file @
30325564
...
...
@@ -15,7 +15,7 @@ limitations under the License.
*/
import
React
,
{
RefObject
,
createRef
}
from
"
react
"
;
import
{
RendezvousFailureReason
}
from
"
matrix-js-sdk/src/rendezvous
"
;
import
{
MSC4108FailureReason
,
Client
RendezvousFailureReason
}
from
"
matrix-js-sdk/src/rendezvous
"
;
import
{
Icon
as
ChevronLeftIcon
}
from
"
@vector-im/compound-design-tokens/icons/chevron-left.svg
"
;
import
{
QrReader
,
OnResultFunction
}
from
"
react-qr-reader
"
;
import
{
logger
}
from
"
matrix-js-sdk/src/logger
"
;
...
...
@@ -95,44 +95,43 @@ export default class LoginWithQRFlow extends React.Component<IProps> {
switch
(
this
.
props
.
phase
)
{
case
Phase
.
Error
:
switch
(
this
.
props
.
failureReason
)
{
case
RendezvousFailureReason
.
Expired
:
case
Client
RendezvousFailureReason
.
Expired
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_linking_incomplete
"
);
break
;
case
RendezvousFailureReason
.
InvalidCode
:
case
Client
RendezvousFailureReason
.
InvalidCode
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_invalid_scanned_code
"
);
break
;
case
RendezvousFailureReason
.
UnsupportedTransport
:
case
RendezvousFailureReason
.
UnsupportedAlgorithm
:
case
MSC4108FailureReason
.
UnsupportedProtocol
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_device_unsupported
"
);
break
;
case
RendezvousFailureReason
.
UserDeclined
:
case
Client
RendezvousFailureReason
.
UserDeclined
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_request_declined
"
);
break
;
case
RendezvousFailureReason
.
OtherDeviceAlreadySignedIn
:
case
Client
RendezvousFailureReason
.
OtherDeviceAlreadySignedIn
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_device_already_signed_in
"
);
break
;
case
RendezvousFailureReason
.
OtherDeviceNotSignedIn
:
case
Client
RendezvousFailureReason
.
OtherDeviceNotSignedIn
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_device_not_signed_in
"
);
break
;
case
Rendezvous
FailureReason
.
UserCancelled
:
case
MSC4108
FailureReason
.
UserCancelled
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_request_cancelled
"
);
break
;
case
RendezvousFailureReason
.
Unknown
:
case
Client
RendezvousFailureReason
.
Unknown
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_unexpected
"
);
break
;
case
RendezvousFailureReason
.
HomeserverLacksSupport
:
case
Client
RendezvousFailureReason
.
HomeserverLacksSupport
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_homeserver_lacks_support
"
);
break
;
case
RendezvousFailureReason
.
InsecureChannelDetected
:
case
Client
RendezvousFailureReason
.
InsecureChannelDetected
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_insecure_connection
"
);
break
;
case
Rendezvous
FailureReason
.
UnexpectedMessage
:
case
MSC4108
FailureReason
.
UnexpectedMessage
Received
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_unexpected_message
"
);
break
;
case
Rendezvous
FailureReason
.
DeviceAlreadyExists
:
case
MSC4108
FailureReason
.
DeviceAlreadyExists
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_device_already_exists
"
);
break
;
case
Rendezvous
FailureReason
.
DeviceNotFound
:
case
MSC4108
FailureReason
.
DeviceNotFound
:
cancellationMessage
=
_t
(
"
auth|qr_code_login|error_device_not_found
"
);
break
;
default
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment