Initial commit
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
a78c2ce1c7
@ -0,0 +1,10 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
type: docker
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: node:20-alpine
|
||||
commands:
|
||||
- yarn install
|
||||
- yarn build
|
@ -0,0 +1,29 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
# Locks
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
pnpm-lock.yaml
|
@ -0,0 +1,19 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Digicode</title>
|
||||
<meta name="description" content="Spot the security flaw in a naive pin lock" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div id="output">
|
||||
<div id="display"></div>
|
||||
<div id="light"></div>
|
||||
</div>
|
||||
<div id="keypad"></div>
|
||||
</div>
|
||||
<script type="module" src="/src/digicode.ts"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "digicode",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.4.5"
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import './style.css'
|
||||
|
||||
const code = '1234';
|
||||
|
||||
const display = document.getElementById('display') as HTMLDivElement;
|
||||
const light = document.getElementById('light') as HTMLDivElement;
|
||||
const keypad = document.getElementById('keypad') as HTMLDivElement;
|
||||
|
||||
function resetCode() {
|
||||
display.innerText = '';
|
||||
light.classList.remove('is-success', 'is-error');
|
||||
}
|
||||
|
||||
function composeDigit(digit: number) {
|
||||
const output = display.innerText + digit.toString();
|
||||
display.innerText = output;
|
||||
if (!code.startsWith(output)) {
|
||||
light.classList.add('is-error');
|
||||
setTimeout(resetCode, 1000)
|
||||
return;
|
||||
}
|
||||
if (code === output) {
|
||||
light.classList.add('is-success');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 1; i < 11; i++) {
|
||||
const digit = i % 10;
|
||||
const button = document.createElement('button');
|
||||
button.innerText = digit.toString();
|
||||
button.onclick = () => composeDigit(digit);
|
||||
keypad.appendChild(button);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
:root {
|
||||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3.2em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
#app {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
background-color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s;
|
||||
}
|
||||
button:hover {
|
||||
border-color: #646cff;
|
||||
}
|
||||
button:focus,
|
||||
button:focus-visible {
|
||||
outline: 4px auto -webkit-focus-ring-color;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
a:hover {
|
||||
color: #747bff;
|
||||
}
|
||||
button, #light {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
||||
|
||||
#output {
|
||||
display: flex;
|
||||
}
|
||||
#display {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
#light {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
background-color: #1a1a1a;
|
||||
}
|
||||
#light.is-error {
|
||||
background-color: #fd3838;
|
||||
}
|
||||
#light.is-success {
|
||||
background-color: #46fd46;
|
||||
}
|
||||
|
||||
#keypad {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
#keypad > button:last-child {
|
||||
grid-column: 2;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
Loading…
Reference in new issue