Skip to content

Commit

Permalink
Fix adapter with the latest test suite changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaminduDilshan committed Nov 30, 2022
1 parent 07a3a05 commit e524c5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
26 changes: 2 additions & 24 deletions src/app/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ let auth: any;
let sessionNonceCookie: string;
let userVerification: any;

let optionsRequestCounter = 0;
let resultRequestCounter = 0;

const allowCredentials = [
{
id: "rnInB99skrSHLwQJpAio3W2S5RMHGYGudqdobiUImDI",
Expand All @@ -36,7 +33,6 @@ export default ({ app }: { app: express.Application }) => {
app.post("/assertion/options", async (req, res) => {
console.log("\nRequest @ /assertion/options");

optionsRequestCounter += 1;
sessionNonceCookie = "";

// Client Id of the sample app.
Expand Down Expand Up @@ -92,7 +88,7 @@ export default ({ app }: { app: express.Application }) => {
* Allow credentials are not required in the usernameless authentication.
* According to spec, credentials are used when the user has to be identified.
*/
if (optionsRequestCounter == 1 && resultRequestCounter == 0) {
if (req.body?.username && req.body?.userVerification && req.body?.extensions) {
responseToTool.allowCredentials = allowCredentials;
}

Expand Down Expand Up @@ -128,7 +124,7 @@ export default ({ app }: { app: express.Application }) => {
* Allow credentials are not required in the usernameless authentication.
* According to spec, credentials are used when the user has to be identified.
*/
if (optionsRequestCounter == 1 && resultRequestCounter == 0) {
if (req.body?.username && req.body?.userVerification && req.body?.extensions) {
responseToTool.allowCredentials = allowCredentials;
}

Expand All @@ -148,8 +144,6 @@ export default ({ app }: { app: express.Application }) => {
app.post("/assertion/result", async (req, res) => {
console.log("\nRequest @ /assertion/result");

resultRequestCounter += 1;

if (req.body.response?.authenticatorData) {
try {
const authenticatorData = parseAuthenticatorData(Buffer.from(
Expand Down Expand Up @@ -245,20 +239,4 @@ export default ({ app }: { app: express.Application }) => {
});
});
});

/**
* Reset counters.
*/
app.get("/adapter/counter/reset", async (req, res) => {
console.log("\nRequest @ /adapter/counter/reset");

optionsRequestCounter = 0;
resultRequestCounter = 0;

res.send({
message: "Options request counter = " + optionsRequestCounter + " | " + "Results request counter = "
+ resultRequestCounter,
status: "success"
});
});
};
2 changes: 1 addition & 1 deletion src/app/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default ({ app }: { app: express.Application }) => {
console.log("\nRequest @ /attestation/options");
console.log("user >> ", req.body.username, req.body.displayName);

const extensions = { "example.extension": true };
const extensions = req.body.extensions;
const attestationLogic = req.body.attestation == "direct" ? "direct" : "none";
let username = userOps.formatUsername(req.body.username);

Expand Down

0 comments on commit e524c5d

Please sign in to comment.