@@ -113,11 +113,18 @@ export async function createPublicKeyCredential(origin: string, options: Credent
113113}
114114
115115export async function getPublicKeyCredential ( origin : string , options : CredentialRequestOptions , sameOriginWithAncestors : boolean , userConsentCallback : Promise < boolean > ) {
116+ // Step 1
117+ if ( ! options . publicKey ) {
118+ throw new Error ( 'options missing' ) ;
119+ }
120+
116121 // Step 2
117122 if ( ! sameOriginWithAncestors ) {
118123 throw new Error ( `sameOriginWithAncestors has to be true` ) ;
119124 }
120125
126+ // No timeout
127+
121128 // Step 7
122129 const rpID = options . publicKey . rpId || getDomainFromOrigin ( origin ) ;
123130
@@ -136,6 +143,8 @@ export async function getPublicKeyCredential(origin: string, options: Credential
136143 const authenticatorExtensionInput = new Uint8Array ( CBOR . encodeCanonical ( { hash : customClientDataHash } ) ) ;
137144 authenticatorExtensions = new Map ( [ [ PSK_EXTENSION_IDENTIFIER , byteArrayToBase64 ( authenticatorExtensionInput , true ) ] ] ) ;
138145 // clientExtensions = {[PSK_EXTENSION_IDENTIFIER]: {clientDataJSON: customClientDataJSON}}; // ToDo Add to response
146+ } else {
147+ log . warn ( 'PSK client extension processing failed. Wrong input.' ) ;
139148 }
140149 }
141150 }
@@ -147,21 +156,29 @@ export async function getPublicKeyCredential(origin: string, options: Credential
147156 const clientDataHashDigest = await window . crypto . subtle . digest ( 'SHA-256' , new TextEncoder ( ) . encode ( JSON . stringify ( clientDataJSON ) ) ) ;
148157 const clientDataHash = new Uint8Array ( clientDataHashDigest ) ;
149158
150- // Step 18: Simplified, just for 1 authenticator
159+ // Handle only 1 authenticator
160+ // Step 18
161+ if ( options . publicKey . userVerification && ( options . publicKey . userVerification === 'required' ) ) {
162+ throw new Error ( `cKey does not support user verification` ) ;
163+ }
164+
151165 const userVerification = options . publicKey . userVerification === "required" ;
152166 const userPresence = ! userVerification ;
167+
168+ const allowCredentialDescriptorList = options . publicKey . allowCredentials ; // No filtering
169+
153170 const assertionCreationData = await Authenticator . authenticatorGetAssertion ( userConsentCallback ,
154171 rpID ,
155172 clientDataHash ,
156173 userPresence ,
157174 userVerification ,
158- options . publicKey . allowCredentials ,
175+ allowCredentialDescriptorList ,
159176 authenticatorExtensions ) ;
160177
161178 log . debug ( 'Received assertion response' ) ;
162179
163180 return {
164- getClientExtensionResults : ( ) => ( { } ) ,
181+ getClientExtensionResults : ( ) => ( clientExtensions ) , // ToDo Add client extension output
165182 id : assertionCreationData . credentialId ,
166183 rawId : base64ToByteArray ( assertionCreationData . credentialId , true ) ,
167184 response : {
0 commit comments