├── .mvn └── wrapper │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── build ├── buildDocker.sh ├── docker-compose.yml └── docker │ ├── Dockerfile │ └── src │ ├── logback-spring.xml │ └── runCodeFront.sh ├── checkstyle-conf.xml ├── checkstyle-suppressions.xml ├── checkstyle.header ├── client ├── .editorconfig ├── .env ├── .gitignore ├── .nvmrc ├── README.md ├── eslint.config.mjs ├── index.html ├── license.js ├── package-lock.json ├── package.json ├── pom.xml ├── public │ ├── apple-touch-icon.png │ ├── favicon.ico │ ├── favicon.svg │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.jsx │ ├── Body.jsx │ ├── api.js │ ├── components │ │ ├── Button │ │ │ └── Button.jsx │ │ ├── CircleIcon │ │ │ └── CircleIcon.jsx │ │ ├── FlowUserActionSafeguard │ │ │ └── FlowUserActionSafeguard.jsx │ │ ├── FoldableContent │ │ │ └── FoldableContent.jsx │ │ ├── Footer │ │ │ └── Footer.jsx │ │ ├── Guide │ │ │ └── Guide.jsx │ │ ├── Header │ │ │ └── Header.jsx │ │ ├── HelpText │ │ │ └── HelpText.jsx │ │ ├── LanguageDropdown │ │ │ └── LanguageDropdown.jsx │ │ ├── MainContent │ │ │ └── MainContent.jsx │ │ ├── QRCode │ │ │ └── QRCode.jsx │ │ ├── Settings │ │ │ └── Settings.jsx │ │ ├── Sidebar │ │ │ └── Sidebar.jsx │ │ └── StartButton │ │ │ └── StartButton.jsx │ ├── constants.js │ ├── contexts │ │ ├── Contexts.jsx │ │ ├── localization │ │ │ ├── Localization.jsx │ │ │ ├── eng.json │ │ │ └── swe.json │ │ └── sidebar │ │ │ └── Sidebar.jsx │ ├── flow-utils.js │ ├── hooks │ │ ├── useDevice.js │ │ └── useHash.js │ ├── logo.svg │ ├── main.jsx │ ├── pages │ │ ├── About │ │ │ └── About.jsx │ │ ├── Error │ │ │ └── Error.jsx │ │ ├── OpenDesktopApp │ │ │ └── OpenDesktopApp.jsx │ │ ├── OpenMobileApp │ │ │ └── OpenMobileApp.jsx │ │ ├── ResultFailed │ │ │ └── ResultFailed.jsx │ │ ├── ResultSuccess │ │ │ └── ResultSuccess.jsx │ │ ├── ScanQR │ │ │ └── ScanQR.jsx │ │ └── Start │ │ │ └── Start.jsx │ ├── router.jsx │ ├── styling │ │ ├── fonts │ │ │ ├── Caveat-Regular.woff │ │ │ ├── Caveat-Regular.woff2 │ │ │ ├── Inter-Bold.woff │ │ │ ├── Inter-Bold.woff2 │ │ │ ├── Inter-Regular.woff │ │ │ └── Inter-Regular.woff2 │ │ ├── images │ │ │ ├── MarkerArrow.svg │ │ │ ├── angle-down-solid-darkblue.svg │ │ │ ├── angle-down-solid-white.svg │ │ │ ├── arrow-left-solid-darkblue.svg │ │ │ ├── arrow-right-from-bracket-solid.svg │ │ │ ├── check-solid.svg │ │ │ ├── eid-still.png │ │ │ ├── en.svg │ │ │ ├── exclamation-solid.svg │ │ │ ├── gear-solid.svg │ │ │ ├── github.svg │ │ │ ├── logo-bank-id.svg │ │ │ ├── open-mobile.svg │ │ │ ├── sv.svg │ │ │ └── system-external-link.svg │ │ └── index.css │ └── utils.js └── vite.config.js ├── mvnw ├── mvnw.cmd ├── pom.xml └── server ├── README.md ├── certificates ├── localhost-cert.pem ├── localhost-key.pem ├── production │ ├── truststore.p12 │ └── truststore.pem └── test │ ├── FPTestcert5_20240610.p12 │ ├── truststore.p12 │ └── truststore.pem ├── checkstyle.header ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── bankid │ │ └── codefront │ │ ├── CodeFrontApplication.java │ │ ├── ServletInitializer.java │ │ ├── bankid │ │ └── relyingparty │ │ │ ├── RpApi.java │ │ │ ├── metrics │ │ │ └── RpApiMetrics.java │ │ │ └── signature │ │ │ ├── BidSignatureNamespaceContext.java │ │ │ ├── DigitalSignature.java │ │ │ ├── SignatureParseException.java │ │ │ └── XmlParseErrorHandler.java │ │ ├── config │ │ ├── AppConfig.java │ │ ├── BankIDRelyingPartyConfig.java │ │ ├── ClockConfig.java │ │ ├── HeadersConfig.java │ │ ├── Metrics.java │ │ ├── SecurityConfig.java │ │ ├── SessionConfig.java │ │ └── SessionConfigDev.java │ │ ├── models │ │ ├── Base64String.java │ │ ├── ValidatedValue.java │ │ ├── bankid │ │ │ └── relyingparty │ │ │ │ ├── AdditionalWebData.java │ │ │ │ ├── BankIDRequirements.java │ │ │ │ ├── CancelRequest.java │ │ │ │ ├── CollectRequest.java │ │ │ │ ├── CollectResponse.java │ │ │ │ ├── CompletionData.java │ │ │ │ ├── DeviceData.java │ │ │ │ ├── RiskLevel.java │ │ │ │ ├── RiskRequirement.java │ │ │ │ ├── SetUpData.java │ │ │ │ ├── StartAuthenticationRequest.java │ │ │ │ ├── StartSignatureRequest.java │ │ │ │ ├── StartTransactionResponse.java │ │ │ │ └── UserData.java │ │ └── service │ │ │ ├── BankIDTransaction.java │ │ │ ├── CollectResult.java │ │ │ ├── CompletionResult.java │ │ │ └── Status.java │ │ ├── rest │ │ ├── controller │ │ │ ├── GlobalControllerExceptionHandler.java │ │ │ ├── SpaController.java │ │ │ ├── StartController.java │ │ │ ├── TransactionController.java │ │ │ └── metrics │ │ │ │ └── TransactionControllerMetrics.java │ │ └── model │ │ │ ├── AuthenticationRequest.java │ │ │ ├── CheckResponse.java │ │ │ ├── CompletionResponse.java │ │ │ ├── ErrorCode.java │ │ │ ├── SessionValue.java │ │ │ ├── SignRequest.java │ │ │ ├── StartResponse.java │ │ │ ├── TransactionResponse.java │ │ │ └── UserVisibleDataFormat.java │ │ ├── service │ │ ├── AuditService.java │ │ └── BankIDService.java │ │ └── utils │ │ └── CodeFrontWebApplicationException.java └── resources │ ├── application-dev.yaml │ ├── application-prod.yaml │ ├── application-redis.yaml │ ├── application-tlsdisabled.yaml │ ├── application.yaml │ ├── findbugs-exclude.xml │ └── logback-spring.xml └── test └── java └── com └── bankid └── codefront ├── TestUtils.java ├── actuator └── K8sProbesTest.java ├── bankid └── relyingparty │ ├── RpApiTest.java │ └── signature │ └── DigitalSignatureTest.java ├── models ├── Base64StringTest.java └── bankid │ └── relyingparty │ ├── BankIDRequirementsTest.java │ ├── CancelRequestTest.java │ ├── CollectRequestTest.java │ ├── CollectResponseTest.java │ ├── CompletionDataTest.java │ ├── StartAuthenticationRequestTest.java │ ├── StartSignatureRequestTest.java │ └── StartTransactionResponseTest.java ├── rest ├── contoller │ ├── AuthenticationResponse.java │ ├── CheckResponse.java │ ├── GlobalControllerExceptionHandlerTest.java │ ├── RestBaseControllerTest.java │ ├── RestControllerTest.java │ ├── SpaControllerTest.java │ └── TransactionControllerTest.java └── model │ ├── AuthenticationRequestTest.java │ ├── CompletionResponseTest.java │ └── SignRequestTest.java └── service └── BankIDServiceTest.java /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About BankID 2 | BankID is the largest eID in Sweden, with more than 8,4 million users and over 6000 connected businesses and authorities. Our solution has revolutionized everyday life in Sweden and lays the foundation for a modern and accessible society. 3 | ## All information moved to developer’s site 4 | We no longer update our repositories on Github as all our information for developers is now found on our website developers.bankid.com. 5 | 6 | [Visit the website for developers ](https://developers.bankid.com) 7 | 8 | ## Live example of flows 9 | To see how the identification and signature flows work you can visit our test site for end-users. If you hold a production BankID you can try the full flows. If you don’t have a production BankID you can’t complete the full tests, but can still benefit from viewing the UI. 10 | 11 | [Visit the test site for end-users ](https://test.bankid.com) -------------------------------------------------------------------------------- /build/buildDocker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | dockerTempTag=codefront-server 3 | echo ${dockerTempTag} 4 | 5 | mkdir -p docker/target/bin/ 6 | cp ../server/target/codefront-develop-SNAPSHOT.war docker/target/bin/codefront-server.war 7 | 8 | docker buildx build docker/. \ 9 | --no-cache \ 10 | -t ${dockerTempTag} \ 11 | --progress=plain 12 | -------------------------------------------------------------------------------- /build/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | codefront: 5 | image: codefront-server 6 | restart: always 7 | user: "2000" 8 | read_only: true 9 | cap_drop: 10 | - ALL 11 | environment: 12 | - SPRING_PROFILES_ACTIVE=dev 13 | tmpfs: 14 | # These directories need to be writable at runtime. 15 | - /tmp:uid=2000,gid=2000 16 | volumes: 17 | - ../server/certificates/:/opt/codefront/certificates/:r 18 | - ./docker/src/logback-spring.xml:/opt/codefront/src/main/resources/logback-spring.xml:r 19 | ports: 20 | - "8443:8443" 21 | -------------------------------------------------------------------------------- /build/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG BASE_IMAGE=${BASE_IMAGE:-registry.access.redhat.com/ubi8/openjdk-17-runtime:1.19-4} 2 | FROM ${BASE_IMAGE} 3 | 4 | LABEL base-image=${BASE_IMAGE} 5 | LABEL name="codefront-server" 6 | LABEL description="CodeFront-server is the java-based server, currently the main GUI server" 7 | LABEL distribution-scope="opensource" 8 | LABEL summary="codefront-server" 9 | 10 | # Expose ports and volumes. 11 | EXPOSE 8443 12 | VOLUME ["/opt/codefront/config/", "/opt/codefront/logs"] 13 | 14 | # Copy files. 15 | COPY src/runCodeFront.sh target/bin/codefront-server.war /opt/codefront/ 16 | COPY src/logback-spring.xml /opt/codefront/default-config/ 17 | 18 | USER root 19 | 20 | # Run required commands. 21 | RUN chmod 755 /opt && \ 22 | chmod 755 /opt/codefront/runCodeFront.sh && \ 23 | chmod 644 /opt/codefront/codefront-server.war 24 | 25 | # Set working directory and user. 26 | WORKDIR /opt/codefront/ 27 | USER 2000 28 | 29 | # Set entry point. 30 | ENTRYPOINT ["/opt/codefront/runCodeFront.sh"] 31 | -------------------------------------------------------------------------------- /build/docker/src/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {"HOSTNAME":"${HOSTNAME}"} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | %d [%thread] %level{8} %logger{50} [%X{userIp}] [%X{userId}] %msg%n 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /build/docker/src/runCodeFront.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec java \ 3 | $JAVA_OPTS \ 4 | -XX:-ParallelRefProcEnabled \ 5 | -XX:MaxGCPauseMillis=500 \ 6 | -XX:+ExitOnOutOfMemoryError \ 7 | \ 8 | -Djava.net.preferIPv4Stack=true \ 9 | -Djava.awt.headless=true \ 10 | \ 11 | -jar \ 12 | /opt/codefront/codefront-server.war \ 13 | "$@" 14 | -------------------------------------------------------------------------------- /checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /checkstyle.header: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | -------------------------------------------------------------------------------- /client/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 2 9 | -------------------------------------------------------------------------------- /client/.env: -------------------------------------------------------------------------------- 1 | VITE_PUBLIC_URL= 2 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /client/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.12.0 2 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | # BankID Demo Client 2 | 3 | This is the frontend part of the BankID Demo. Here we provide an example of how to handle all the things necessary in a frontend of a site with a BankID integration. 4 | 5 | 6 | 7 | ## Secure start 8 | 9 | > To protect users and businesses, Secure start will be mandatory from 1st of May 2024. 10 | > 11 | > Secure start means using animated QR code and autostart. 12 | 13 | ### Animated QR code 14 | QR code is used when the user visits a site on one device and uses the BankID app on another device. The user simply scans the QR code with their BankID app and verify the authentication. 15 | 16 | In the frontend we handle the animation by polling the API every second to get the latest code and update the QR code shown on the site. 17 | 18 | See [src/pages/ScanQR](src/pages/ScanQR/ScanQR.js) for more info. 19 | 20 | ### Autostart 21 | 22 | Autostart is used when the user visits a site on the same device as the BankID is located, either on a mobile device where the BankID app is installed or on a desktop device where the BankID Security Program is installed. The user simply clicks a button on the site which opens their BankID application where they can verify the authentication. 23 | 24 | In the frontend we handle this by checking what type of device the user has and show different buttons depending on the scenario. 25 | 26 | ### Autostart Desktop 27 | 28 | If the user is on a desktop device we just redirect to a URL with the `bankid://`-scheme and the BankID Security Program opens. 29 | 30 | See [src/pages/OpenDesktopApp](src/pages/OpenDesktopApp/OpenDesktopApp.js) for more info. 31 | 32 | ### Autostart Mobile 33 | 34 | On a mobile device we redirect to `app.bankid.com` which handles opening of the BankID app correctly on iOS and Android. For the BankID app to redirect back to the site correctly we need to pass a `returnUrl`. On iOS this is a bit tricky due to all links opening in Safari regardless of what default browser the user has. 35 | 36 | See [src/pages/OpenMobileApp](src/pages/OpenMobileApp/OpenMobileApp.js) for more info. 37 | 38 | 39 | --- 40 | 41 | ## Available scripts 42 | 43 | In the project directory, you can run: 44 | 45 | ### `npm run dev` 46 | 47 | Runs the app in the development mode.\ 48 | Open [http://localhost:5173](http://localhost:5173) to view it in your browser. 49 | 50 | ### `npm run lint` 51 | 52 | Runs ESLint to statically analyze the code and look for problems. 53 | 54 | ### `npm run build` 55 | 56 | Builds the app for production to the `build` folder. 57 | -------------------------------------------------------------------------------- /client/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import react from "eslint-plugin-react"; 2 | import reactHooks from "eslint-plugin-react-hooks"; 3 | import _import from "eslint-plugin-import"; 4 | import jsxA11Y from "eslint-plugin-jsx-a11y"; 5 | import licenseHeader from "eslint-plugin-license-header"; 6 | import { fixupPluginRules } from "@eslint/compat"; 7 | import globals from "globals"; 8 | import path from "node:path"; 9 | import { fileURLToPath } from "node:url"; 10 | import js from "@eslint/js"; 11 | import { FlatCompat } from "@eslint/eslintrc"; 12 | 13 | const __filename = fileURLToPath(import.meta.url); 14 | const __dirname = path.dirname(__filename); 15 | const compat = new FlatCompat({ 16 | baseDirectory: __dirname, 17 | recommendedConfig: js.configs.recommended, 18 | allConfig: js.configs.all 19 | }); 20 | 21 | export default [{ 22 | ignores: ["**/eslint.config.mjs", "**/license.js", "target/*", "build/*"], 23 | }, ...compat.extends("plugin:react/recommended"), { 24 | plugins: { 25 | react, 26 | "react-hooks": fixupPluginRules(reactHooks), 27 | import: fixupPluginRules(_import), 28 | "jsx-a11y": jsxA11Y, 29 | "license-header": licenseHeader, 30 | }, 31 | 32 | settings: { 33 | react: { 34 | version: "detect", 35 | }, 36 | }, 37 | 38 | languageOptions: { 39 | globals: { 40 | ...globals.browser, 41 | }, 42 | 43 | ecmaVersion: "latest", 44 | sourceType: "module", 45 | }, 46 | 47 | rules: { 48 | "react/react-in-jsx-scope": 0, 49 | "jsx-quotes": ["error", "prefer-single"], 50 | 51 | "react/function-component-definition": [2, { 52 | namedComponents: "arrow-function", 53 | }], 54 | "no-console": 1, 55 | "react-hooks/exhaustive-deps": 1, 56 | "react/require-default-props": 0, 57 | "react/jsx-props-no-spreading": 0, 58 | "react/jsx-filename-extension": 0, 59 | "import/prefer-default-export": 0, 60 | "react/prop-types": 0, 61 | "license-header/header": ["error", "./license.js"], 62 | }, 63 | }]; 64 | -------------------------------------------------------------------------------- /client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | BankID Demo 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /client/license.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bankid-demo", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "lint": "eslint . --report-unused-disable-directives --max-warnings 0", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "axios": "^1.7.7", 14 | "classnames": "^2.5.1", 15 | "is-mobile": "^5.0.0", 16 | "qrcode": "^1.5.4", 17 | "react": "^18.3.1", 18 | "react-dom": "^18.3.1", 19 | "react-markdown": "^9.0.1", 20 | "react-router-dom": "^6.26.2", 21 | "remark-gfm": "^4.0.0" 22 | }, 23 | "devDependencies": { 24 | "@eslint/compat": "^1.2.4", 25 | "@eslint/eslintrc": "^3.2.0", 26 | "@eslint/js": "^9.16.0", 27 | "@types/react": "^18.3.1", 28 | "@types/react-dom": "^18.3.0", 29 | "@vitejs/plugin-basic-ssl": "^1.0.2", 30 | "@vitejs/plugin-react": "^4.3.1", 31 | "eslint": "^9.16.0", 32 | "eslint-plugin-import": "^2.31.0", 33 | "eslint-plugin-jsx-a11y": "^6.10.2", 34 | "eslint-plugin-license-header": "^0.6.1", 35 | "eslint-plugin-react": "^7.36.1", 36 | "eslint-plugin-react-hooks": "^5.1.0", 37 | "eslint-plugin-react-refresh": "^0.4.12", 38 | "globals": "^15.13.0", 39 | "vite": "^6.0.3" 40 | }, 41 | "overrides": { 42 | "qrcode": { 43 | "yargs": "~17.7.2" 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /client/public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BankID/SampleCode/b6cc93d955ac1012fa9adc9bf265c4b8787a40b0/client/public/apple-touch-icon.png -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BankID/SampleCode/b6cc93d955ac1012fa9adc9bf265c4b8787a40b0/client/public/favicon.ico -------------------------------------------------------------------------------- /client/public/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BankID/SampleCode/b6cc93d955ac1012fa9adc9bf265c4b8787a40b0/client/public/logo192.png -------------------------------------------------------------------------------- /client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BankID/SampleCode/b6cc93d955ac1012fa9adc9bf265c4b8787a40b0/client/public/logo512.png -------------------------------------------------------------------------------- /client/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "BankID", 3 | "name": "BankID Demo", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "display": "standalone" 22 | } 23 | -------------------------------------------------------------------------------- /client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /client/src/App.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import { useEffect, useState } from 'react'; 36 | import { BrowserRouter } from 'react-router-dom'; 37 | import Axios from 'axios'; 38 | 39 | import Contexts from './contexts/Contexts'; 40 | import Header from './components/Header/Header'; 41 | import api from './api'; 42 | import Body from './Body'; 43 | 44 | const App = () => { 45 | const [loaded, setLoaded] = useState(false); 46 | 47 | // On launch we call the API to get a CSRF-token. 48 | useEffect(() => { 49 | api.start().then((response) => { 50 | Axios.defaults.headers.common['X-CSRF-TOKEN'] = response.data.csrfToken; 51 | setLoaded(true); 52 | }); 53 | }, []); 54 | 55 | if (!loaded) { 56 | return null; 57 | } 58 | 59 | return ( 60 | 61 | 62 |
63 | 64 | 65 | 66 | ); 67 | }; 68 | 69 | export default App; 70 | -------------------------------------------------------------------------------- /client/src/Body.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import classNames from 'classnames'; 36 | 37 | import MainContent from './components/MainContent/MainContent'; 38 | import Footer from './components/Footer/Footer'; 39 | import Sidebar from './components/Sidebar/Sidebar'; 40 | import Router from './router'; 41 | import { useSidebar } from './contexts/sidebar/Sidebar'; 42 | 43 | const Body = () => { 44 | const { isOpen: sidebarOpen } = useSidebar(); 45 | 46 | return ( 47 | 48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 |
56 | 57 |
58 | 59 | 60 |
61 | ); 62 | }; 63 | 64 | export default Body; 65 | -------------------------------------------------------------------------------- /client/src/api.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import Axios from 'axios'; 36 | 37 | const BASE_URL = `${window.location.origin}${import.meta.env.VITE_PUBLIC_URL}/api`; 38 | 39 | const start = () => Axios.get( 40 | `${BASE_URL}/start`, 41 | { withCredentials: true }, 42 | ); 43 | 44 | const authentication = ({ text, textIsFormatted }) => { 45 | const userVisibleData = text; 46 | const userVisibleDataFormat = textIsFormatted ? 'SIMPLE_MARKDOWN_V1' : 'NONE'; 47 | 48 | return Axios.post( 49 | `${BASE_URL}/authentication`, 50 | { 51 | userVisibleData, 52 | userVisibleDataFormat, 53 | }, 54 | { withCredentials: true }, 55 | ); 56 | }; 57 | 58 | const sign = ({ text, textIsFormatted }) => { 59 | const userVisibleData = text; 60 | const userVisibleDataFormat = textIsFormatted ? 'SIMPLE_MARKDOWN_V1' : 'NONE'; 61 | 62 | return Axios.post( 63 | `${BASE_URL}/sign`, 64 | { 65 | userVisibleData, 66 | userVisibleDataFormat, 67 | }, 68 | { withCredentials: true }, 69 | ); 70 | }; 71 | 72 | const check = () => Axios.post( 73 | `${BASE_URL}/check`, 74 | {}, 75 | { withCredentials: true }, 76 | ); 77 | 78 | const cancel = () => Axios.delete( 79 | `${BASE_URL}/cancel`, 80 | { withCredentials: true }, 81 | ); 82 | 83 | const api = { 84 | start, 85 | authentication, 86 | sign, 87 | check, 88 | cancel, 89 | }; 90 | 91 | export default api; 92 | -------------------------------------------------------------------------------- /client/src/components/Button/Button.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import { Link } from 'react-router-dom'; 36 | import classNames from 'classnames'; 37 | 38 | const Button = ({ 39 | to, 40 | state, 41 | text, 42 | buttonType = 'primary', 43 | disabled, 44 | title, 45 | onClick, 46 | }) => { 47 | const handleClick = (e) => { 48 | if (disabled) { 49 | e.preventDefault(); 50 | return; 51 | } 52 | 53 | if (typeof onClick === 'function') { 54 | onClick(e); 55 | } 56 | }; 57 | 58 | return ( 59 | 67 | {text} 68 | 69 | ); 70 | }; 71 | 72 | export default Button; 73 | -------------------------------------------------------------------------------- /client/src/components/CircleIcon/CircleIcon.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import classNames from 'classnames'; 36 | 37 | import exclamationIcon from '../../styling/images/exclamation-solid.svg'; 38 | import checkIcon from '../../styling/images/check-solid.svg'; 39 | 40 | const icons = { 41 | error: exclamationIcon, 42 | success: checkIcon, 43 | }; 44 | 45 | const CircleIcon = ({ 46 | type, 47 | className, 48 | }) => ( 49 |
50 | 55 |
56 | ); 57 | 58 | export default CircleIcon; 59 | -------------------------------------------------------------------------------- /client/src/components/FlowUserActionSafeguard/FlowUserActionSafeguard.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import { useEffect } from 'react'; 36 | import { useLocation, useNavigate } from 'react-router-dom'; 37 | import useHash from '../../hooks/useHash'; 38 | 39 | export const pageOpenedByUserAction = (location = {}, hashParams = {}) => (location.state || {}).triggeredByUser || hashParams.initiated === 'true'; 40 | 41 | // To avoid initiating a flow without the users intent we should navigate away 42 | // if we somehow ended up on a flow page without the correct state 43 | const FlowUserActionSafeguard = () => { 44 | const location = useLocation(); 45 | const navigate = useNavigate(); 46 | const { hashParams } = useHash(); 47 | 48 | useEffect(() => { 49 | const shouldNavigateAway = !pageOpenedByUserAction(location, hashParams); 50 | 51 | if (shouldNavigateAway) { 52 | navigate('/'); 53 | } 54 | }, []); 55 | 56 | return null; 57 | }; 58 | 59 | export default FlowUserActionSafeguard; 60 | -------------------------------------------------------------------------------- /client/src/components/FoldableContent/FoldableContent.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import { useState } from 'react'; 36 | import classNames from 'classnames'; 37 | 38 | import { useLocalization } from '../../contexts/localization/Localization'; 39 | import downIcon from '../../styling/images/angle-down-solid-white.svg'; 40 | 41 | const FoldableContent = ({ title, children }) => { 42 | const { translate } = useLocalization(); 43 | const [open, setOpen] = useState(false); 44 | 45 | const toggleOpen = () => { 46 | setOpen(!open); 47 | }; 48 | 49 | return ( 50 |
51 | 63 |
64 |
65 | { children } 66 |
67 |
68 |
69 | ); 70 | }; 71 | 72 | export default FoldableContent; 73 | -------------------------------------------------------------------------------- /client/src/components/Guide/Guide.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import { useNavigate } from 'react-router-dom'; 36 | import classNames from 'classnames'; 37 | 38 | import { useLocalization } from '../../contexts/localization/Localization'; 39 | import arrowLeftIcon from '../../styling/images/arrow-left-solid-darkblue.svg'; 40 | 41 | const Guide = ({ 42 | children, 43 | status, 44 | className, 45 | onBackClick, 46 | }) => { 47 | const { translate } = useLocalization(); 48 | const navigate = useNavigate(); 49 | 50 | const handleBackClick = () => { 51 | if (typeof onBackClick === 'function') onBackClick(); 52 | navigate(-1); 53 | }; 54 | 55 | return ( 56 |
57 | 68 | 69 | {children} 70 |
71 | ); 72 | }; 73 | 74 | export default Guide; 75 | -------------------------------------------------------------------------------- /client/src/components/HelpText/HelpText.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import { useLocalization } from '../../contexts/localization/Localization'; 36 | import arrowImage from '../../styling/images/MarkerArrow.svg'; 37 | 38 | const HelpText = () => { 39 | const { translate } = useLocalization(); 40 | 41 | return ( 42 |
43 | 48 |

{translate('help-text')}

49 |
50 | ); 51 | }; 52 | 53 | export default HelpText; 54 | -------------------------------------------------------------------------------- /client/src/components/MainContent/MainContent.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | const MainContent = ({ children }) => ( 36 |
37 | { children } 38 |
39 | ); 40 | 41 | export default MainContent; 42 | -------------------------------------------------------------------------------- /client/src/components/QRCode/QRCode.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import { useEffect, useState } from 'react'; 36 | /** 37 | * Here we've decided to use a library for creating the QR images. At the time of 38 | * writing this library is safe to use. But you should always do your research 39 | * and not use libraries you do not trust. 40 | */ 41 | import QRLib from 'qrcode'; 42 | import { useLocalization } from '../../contexts/localization/Localization'; 43 | 44 | const qrCodeOptions = { 45 | width: 200, 46 | margin: 3, 47 | errorCorrectionLevel: 'L', 48 | }; 49 | 50 | const QrCode = ({ qrCode }) => { 51 | const { translate } = useLocalization(); 52 | const [qrImage, setQrImage] = useState(); 53 | 54 | useEffect(() => { 55 | QRLib.toDataURL(qrCode, qrCodeOptions) 56 | .then((url) => { 57 | setQrImage(url); 58 | }) 59 | .catch(() => { 60 | setQrImage(undefined); 61 | }); 62 | }, [qrCode]); 63 | 64 | if (!qrImage) { 65 | return null; 66 | } 67 | 68 | return ( 69 | {translate('qr-code')} 70 | ); 71 | }; 72 | 73 | export default QrCode; 74 | -------------------------------------------------------------------------------- /client/src/components/StartButton/StartButton.jsx: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | BSD 3-Clause License 4 | 5 | Copyright (c) 2022, Finansiell ID-Teknik BID AB 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Neither the name of the copyright holder nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | import { URLS } from '../../constants'; 36 | import { useSidebar } from '../../contexts/sidebar/Sidebar'; 37 | import useDevice from '../../hooks/useDevice'; 38 | import Button from '../Button/Button'; 39 | 40 | const StartButton = ({ 41 | testingType, 42 | text, 43 | buttonType = 'primary', 44 | disabled, 45 | title, 46 | }) => { 47 | const { 48 | isMobileOrTablet, 49 | } = useDevice(); 50 | const { close: closeSidebar } = useSidebar(); 51 | 52 | const url = isMobileOrTablet ? URLS.openMobileApp : URLS.scanQr; 53 | 54 | const handleClick = (e) => { 55 | if (disabled) { 56 | e.preventDefault(); 57 | return; 58 | } 59 | 60 | closeSidebar(); 61 | }; 62 | 63 | return ( 64 |