@@ -7,6 +7,7 @@ import { exec } from 'child_process';
77import { RegistrationResponseJSON , generateRegistrationOptions , verifyRegistrationResponse } from '@simplewebauthn/server' ;
88import { DynamoDBClient } from '@aws-sdk/client-dynamodb' ;
99import { DynamoDBDocument , PutCommand } from '@aws-sdk/lib-dynamodb' ;
10+ import { putItem } from '../api/aws/services/dynamodb' ;
1011
1112const PORT = 3456 ;
1213const RP_NAME = "Max Rosoff's Website" ;
@@ -86,17 +87,12 @@ async function handleRegistration(req: http.IncomingMessage, res: http.ServerRes
8687 }
8788
8889 const { credential } = verification . registrationInfo ;
89-
90- // Store the credential directly - DynamoDB handles binary data
91- await documentClient . send ( new PutCommand ( {
92- TableName : PASSKEY_CREDENTIALS_TABLE ,
93- Item : {
94- id : Buffer . from ( credential . id ) . toString ( 'base64' ) , // ID as base64 for easy lookup
95- publicKey : credential . publicKey , // Store as Buffer directly
96- counter : credential . counter ,
97- transports : registrationResponse . response . transports
98- }
99- } ) ) ;
90+ await putItem ( PASSKEY_CREDENTIALS_TABLE , {
91+ id : Buffer . from ( credential . id ) . toString ( 'base64' ) ,
92+ publicKey : Buffer . from ( credential . publicKey ) . toString ( 'base64' ) ,
93+ counter : credential . counter ,
94+ transports : registrationResponse . response . transports
95+ } )
10096
10197 console . log ( '✓ Passkey registered successfully!' ) ;
10298 console . log ( '\nYou can now use your passkey to authenticate with sudo console' ) ;
0 commit comments