-
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.
Merge pull request #100 from SmoFlaDru/dev-benno
Add passkey creation and login, select activity chart time range, nav bar improvements, dark theme switching, fixes.
- Loading branch information
Showing
36 changed files
with
1,368 additions
and
566 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import * as ApexCharts from 'apexcharts/dist/apexcharts.min.js' | ||
import * as tabler from '@tabler/core/dist/js/tabler.min.js' | ||
import * as htmx from 'htmx.org/dist/htmx.min.js' | ||
import * as passkeys from './passkeys'; | ||
|
||
import "@tabler/core/dist/css/tabler.min.css" | ||
import "@tabler/core/dist/css/tabler-vendors.min.css" | ||
|
||
export { ApexCharts, tabler, htmx } | ||
|
||
window.passkeys = passkeys; | ||
|
||
export { ApexCharts, tabler, htmx, passkeys } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import {startAuthentication, startRegistration} from '@simplewebauthn/browser' | ||
|
||
const sendToServerForVerificationAndLogin = async (response) => { | ||
try { | ||
console.log("sendToServerForVerificationAndLogin:", response); | ||
const verificationResp = await fetch('/passkeys/verify-authentication', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(response), | ||
}); | ||
const verificationJSON = await verificationResp.json(); | ||
|
||
// Show UI appropriate for the `verified` status | ||
if (verificationJSON && verificationJSON.verified) { | ||
console.log("success") | ||
window.location.href = '/profile'; | ||
} else { | ||
console.log("error", verificationJSON); | ||
} | ||
} catch (e) { | ||
handleError(e); | ||
} | ||
} | ||
|
||
const handleError = (error) => { | ||
console.log("An error occurred:", error); | ||
} | ||
|
||
export const autocomplete = async () => { | ||
try { | ||
console.log("Setting up autocomplete"); | ||
const options = await fetch('/passkeys/generate-authentication-options') | ||
const optionsPayload = (await options.json())["publicKey"] | ||
// delete options["allowedCredentials"] | ||
const response = await startAuthentication(optionsPayload, true) | ||
await sendToServerForVerificationAndLogin(response) | ||
} catch (e) { | ||
handleError(e); | ||
} | ||
}; | ||
|
||
export const create = async () => { | ||
const resp = await fetch('/passkeys/generate-registration-options'); | ||
|
||
let attResp; | ||
try { | ||
// Pass the options to the authenticator and wait for a response | ||
attResp = await startRegistration((await resp.json()).publicKey); | ||
} catch (error) { | ||
// Some basic error handling | ||
if (error.name === 'InvalidStateError') { | ||
throw Error('Error: Authenticator was probably already registered by user'); | ||
} else { | ||
throw Error(error); | ||
} | ||
} | ||
|
||
// POST the response to the endpoint that calls | ||
// @simplewebauthn/server -> verifyRegistrationResponse() | ||
const verificationResp = await fetch('/passkeys/verify-registration', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(attResp), | ||
}); | ||
|
||
// Wait for the results of verification | ||
const verificationJSON = await verificationResp.json(); | ||
|
||
// Show UI appropriate for the `verified` status | ||
if (verificationJSON && verificationJSON.verified) { | ||
return 'Success!'; | ||
} else { | ||
throw Error(`Oh no, something went wrong! Response: <pre>${JSON.stringify(verificationJSON)}</pre>`); | ||
} | ||
} |
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
Oops, something went wrong.