Skip to content

Commit

Permalink
Merge pull request #496 from curveball/upgrade-time
Browse files Browse the repository at this point in the history
Bringing all dependencies up to date
  • Loading branch information
evert authored Jul 10, 2024
2 parents f86b739 + 3e5f4ee commit d86415b
Show file tree
Hide file tree
Showing 123 changed files with 1,624 additions and 3,303 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"env": {
"browser": true,
"node": true,
"es6": true,
"mocha": true
"es6": true
},
"extends": [
"eslint:recommended",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
node-version: 22
- run: npm ci
- run: npm test

Expand All @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
node-version: 22
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
Expand All @@ -39,7 +39,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
node-version: 22
- run: npm ci
- uses: actions/setup-node@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
name: Test
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x, 22.x]
runs-on: ubuntu-latest
needs: build
steps:
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SOURCE_FILES:=$(shell find src/ -type f -name '*.ts')
TEST_FILES:=$(shell find test/ -type f -name '*.ts')
DOCKER_IMAGE_NAME:=a12n-server

.PHONY:start run build test lint fix lint-fix start-dev watch inspect deploy
Expand All @@ -16,7 +17,7 @@ docker-run:
docker run -it --rm --name $(DOCKER_IMAGE_NAME)-01 $(DOCKER_IMAGE_NAME)

test:
npx nyc mocha
npx tsx --test ${TEST_FILES}

lint:
npx tsc --noemit
Expand Down
37 changes: 26 additions & 11 deletions assets/webauthn.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
// @ts-check

/** @import * as SimpleWebAuthn from '@simplewebauthn/browser' */

/**
* @type {SimpleWebAuthn}
*/
var SimpleWebAuthnBrowser;

document.addEventListener('DOMContentLoaded', function(){
const elemBeginRegister = document.getElementById('btnBeginRegister');
const elemBeginLogin = document.getElementById('btnBeginLogin');
const elemError = document.getElementById('error');
const elemBeginRegister = /** @type {HTMLButtonElement} */ (document.getElementById('btnBeginRegister'));
const elemBeginLogin = /** @type {HTMLButtonElement} */(document.getElementById('btnBeginLogin'));
const elemError = /** @type {HTMLDivElement} */(document.getElementById('error'));

const { startAttestation, startAssertion } = SimpleWebAuthnBrowser;
const { startRegistration, startAuthentication } = SimpleWebAuthnBrowser;

elemBeginRegister?.addEventListener('click', async (ev) => {

Expand All @@ -13,11 +21,13 @@ document.addEventListener('DOMContentLoaded', function(){
elemError.classList.add('hidden');
elemBeginRegister.disabled = true;



const jsonResponse = await makeRequest('/register/mfa/webauthn/registration', {}, elemBeginRegister);

let attResp;
try {
attResp = await startAttestation(jsonResponse);
attResp = await startRegistration(jsonResponse);
} catch (error) {
let errorText;
if (error.name === 'InvalidStateError') {
Expand Down Expand Up @@ -48,7 +58,7 @@ document.addEventListener('DOMContentLoaded', function(){

let asseResp;
try {
asseResp = await startAssertion(jsonResponse);
asseResp = await startAuthentication(jsonResponse);
} catch (error) {
handleError(error, elemBeginLogin);
}
Expand All @@ -62,13 +72,14 @@ document.addEventListener('DOMContentLoaded', function(){
}, elemBeginLogin);

const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('continue')) {
window.location.href = urlParams.get('continue');
} else {
window.location.href = '/';
}
window.location.href = urlParams.get('continue') ?? '/';
});

/**
* @param {string} url
* @param {RequestInit} options
* @param {HTMLButtonElement} button
*/
async function makeRequest(url, options, button) {
let resp;
try {
Expand Down Expand Up @@ -102,6 +113,10 @@ document.addEventListener('DOMContentLoaded', function(){
return jsonResponse;
}

/**
* @param {string} error
* @param {HTMLButtonElement} btn
*/
function handleError(error, btn) {
elemError.innerText = error;
elemError.classList.remove('hidden');
Expand Down
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

0.26.0 (????-??-??)
-------------------

* Upgraded to Curveball 1.
* Moved from CommonJS to ESM.
* Upgraded to Typescript 5.5.
* Dropped mocha for the built-in Node tester.


0.25.4 (2024-02-26)
-------------------

Expand Down
Loading

0 comments on commit d86415b

Please sign in to comment.