@@ -29,6 +29,7 @@ function endRequest(requestId, data, error) {
2929 request . resolve ( data )
3030 }
3131}
32+
3233async function cloneCredentialResponse ( credential ) {
3334 try {
3435 const options = { alphabet : "base64url" }
@@ -82,13 +83,44 @@ async function cloneCredentialResponse(credential) {
8283 else {
8384 throw cloneInto ( new Error ( "Unknown credential response type received" ) , window )
8485 }
86+
87+ // Unlike CreatePublicKey, for GetPublicKey, we have a lot of Byte arrays,
88+ // so we need a lot of deconstructions. So no: obj.clientExtensionResults = cloneInto(credential.clientExtensionResults, obj);
89+ const extensions = { }
90+ if ( credential . clientExtensionResults ) {
91+ if ( credential . clientExtensionResults . hmac_get_secret ) {
92+ extensions . hmac_get_secret = { }
93+ extensions . hmac_get_secret . output1 = Uint8Array . fromBase64 ( credential . clientExtensionResults . hmac_get_secret . output1 , options ) ;
94+ if ( credential . clientExtensionResults . hmac_get_secret . output2 ) {
95+ extensions . hmac_get_secret . output2 = Uint8Array . fromBase64 ( credential . clientExtensionResults . hmac_get_secret . output2 , options ) ;
96+ }
97+ }
98+
99+ if ( credential . clientExtensionResults . prf ) {
100+ extensions . prf = { }
101+ if ( credential . clientExtensionResults . prf . results ) {
102+ extensions . prf . results = { }
103+ extensions . prf . results . first = Uint8Array . fromBase64 ( credential . clientExtensionResults . prf . results . first , options ) ;
104+ if ( credential . clientExtensionResults . prf . results . second ) {
105+ extensions . prf . results . second = Uint8Array . fromBase64 ( credential . clientExtensionResults . prf . results . second , options ) ;
106+ }
107+ }
108+ }
109+
110+ if ( credential . clientExtensionResults . large_blob ) {
111+ extensions . large_blob = { }
112+ if ( credential . clientExtensionResults . large_blob . blob ) {
113+ extensions . large_blob . blob = Uint8Array . fromBase64 ( credential . clientExtensionResults . large_blob . blob , options ) ;
114+ }
115+ }
116+ }
85117 obj . response = cloneInto ( response , obj , { cloneFunctions : true } )
86- obj . clientExtensionResults = new window . Object ( ) ;
118+ obj . clientExtensionResults = extensions ;
87119 obj . getClientExtensionResults = function ( ) {
88- // TODO
89- return this . clientExtensionResults
120+ return this . clientExtensionResults ;
90121 }
91122 obj . type = "public-key"
123+
92124 obj . toJSON = function ( ) {
93125 json = new window . Object ( ) ;
94126 json . id = this . id
@@ -115,8 +147,8 @@ async function cloneCredentialResponse(credential) {
115147 throw cloneInto ( new Error ( "Unknown credential type received" ) , window )
116148 }
117149
118- json . authenticatorAttachment = this . authenticatorAttachment
119- json . clientExtensionResults = this . clientExtensionResults
150+ json . authenticatorAttachment = this . authenticatorAttachment ;
151+ json . clientExtensionResults = this . clientExtensionResults ;
120152 json . type = this . type
121153 return json
122154 }
0 commit comments