-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sebankid/qr: fallback to button element if QR cannot be rendered (#34)
* sebankid/qr: fallback to button element if QR cannot be rendered * sebankid:same-device: proper fallback
- Loading branch information
1 parent
a338771
commit 4a5c2ed
Showing
3 changed files
with
24 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import CriiptoVerifyContext from "../context"; | |
|
||
import logo from './SEBankIDQRCode/[email protected]'; | ||
import './SEBankIDQRCode/SEBankIDQRCode.css'; | ||
import AuthMethodButton from "./AuthMethodButton"; | ||
|
||
interface Props { | ||
redirectUri?: string, | ||
|
@@ -28,7 +29,10 @@ interface Props { | |
isCompleting: boolean | ||
error: OAuth2Error | Error | null | ||
retry: () => void | ||
}) => React.ReactElement | ||
}) => React.ReactElement | ||
|
||
/** Render fallback element while loading */ | ||
fallback?: React.ReactElement | ||
} | ||
|
||
interface QrResponse { | ||
|
@@ -47,11 +51,6 @@ function searchParamsToPOJO(input: URLSearchParams) { | |
}, {}); | ||
} | ||
|
||
// const logo = new Image(); | ||
// logo.src = logoSrc; | ||
|
||
// const LOGO_RATIO = 0.15; | ||
|
||
export default function SEBankIDQrCode(props: Props) { | ||
const canvasRef = useRef<HTMLCanvasElement>(null); | ||
const wrapperRef = useRef<HTMLDivElement>(null); | ||
|
@@ -180,6 +179,10 @@ export default function SEBankIDQrCode(props: Props) { | |
</div> | ||
); | ||
|
||
if (!qrCode && props.fallback) { | ||
return props.fallback; | ||
} | ||
|
||
if (props.children) { | ||
return props.children({ | ||
qrElement, | ||
|
@@ -193,6 +196,8 @@ export default function SEBankIDQrCode(props: Props) { | |
return qrElement; | ||
} | ||
|
||
SEBankIDQrCode.acr_values = 'urn:grn:authn:se:bankid:another-device:qr'; | ||
|
||
type UseDrawOptions = { | ||
width?: number, | ||
canvas: HTMLCanvasElement | null, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters