Skip to content

Commit

Permalink
Merge pull request #3 from passkeydeveloper/mm/add-queryparam-validation
Browse files Browse the repository at this point in the history
Begin scaffolding functionality
  • Loading branch information
MasterKale authored Aug 9, 2024
2 parents fed437a + 2dd60c3 commit f11c30a
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 32 deletions.
218 changes: 207 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"@cloudflare/workers-types": "^4.20240729.0",
"typescript": "^5.5.2",
"vitest": "1.5.0",
"wrangler": "^3.60.3"
"wrangler": "^3.70.0"
},
"dependencies": {
"hono": "^4.5.4",
"zod": "^3.23.8",
"zod-form-data": "^2.0.2"
}
}
6 changes: 6 additions & 0 deletions src/handlers/handleCreateAuthOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Context } from 'hono';


export async function handleCreateAuthOptions(context: Context): Promise<Response> {
return context.text('handleCreateAuthOptions');
}
14 changes: 14 additions & 0 deletions src/handlers/handleCreateRegOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Context } from 'hono';
import { zfd } from 'zod-form-data';

import { regOptionsInputSchema } from '../schemas';


/**
* Generate registration options
*/
export async function handleCreateRegOptions(context: Context): Promise<Response> {
const parsedInput = zfd.formData(regOptionsInputSchema).parse(context.req.query());
console.log(parsedInput);
return context.text(`handleCreateRegOptions ${JSON.stringify(parsedInput)}`);
}
6 changes: 6 additions & 0 deletions src/handlers/handleVerifyAuthResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Context } from 'hono';


export async function handleVerifyAuthResponse(context: Context): Promise<Response> {
return context.text('handleVerifyAuthResponse');
}
6 changes: 6 additions & 0 deletions src/handlers/handleVerifyRegResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Context } from 'hono';


export async function handleVerifyRegResponse(context: Context): Promise<Response> {
return context.text('handleVerifyRegResponse');
}
4 changes: 4 additions & 0 deletions src/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { handleCreateRegOptions } from './handleCreateRegOptions';
export { handleCreateAuthOptions } from './handleCreateAuthOptions';
export { handleVerifyRegResponse } from './handleVerifyRegResponse';
export { handleVerifyAuthResponse } from './handleVerifyAuthResponse';
22 changes: 17 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@
*
* Learn more at https://developers.cloudflare.com/workers/
*/
import { Hono } from 'hono';

export default {
async fetch(request, env, ctx): Promise<Response> {
return new Response('Hello from passkeys.dev RP demo API!');
},
} satisfies ExportedHandler<Env>;
import {
handleCreateRegOptions,
handleCreateAuthOptions,
handleVerifyRegResponse,
handleVerifyAuthResponse,
} from './handlers';


const app = new Hono();

app.get('/registration/options', handleCreateRegOptions);
app.get('/authentication/options', handleCreateAuthOptions);
app.post('/registration/verify', handleVerifyRegResponse);
app.post('/registration/verify', handleVerifyAuthResponse);

export default app;
Loading

0 comments on commit f11c30a

Please sign in to comment.