@@ -15,7 +15,7 @@ import {
1515describe ( 'Passkey utils' , ( ) => {
1616 describe ( 'serialization' , ( ) => {
1717 it ( 'convertJSONToPublicKeyCreateOptions()' , ( ) => {
18- const pkCreateOptions : PublicKeyCredentialCreationOptionsJSON = {
18+ const pkCreateOptions = {
1919 rp : {
2020 name : 'clerk.com' ,
2121 id : 'clerk.com' ,
@@ -27,19 +27,19 @@ describe('Passkey utils', () => {
2727 } ,
2828 excludeCredentials : [
2929 {
30- type : 'public-key' ,
30+ type : 'public-key' as const ,
3131 id : 'cmFuZG9tX2lk' ,
3232 } ,
3333 ] ,
3434 authenticatorSelection : {
3535 requireResidentKey : true ,
36- residentKey : 'required' ,
37- userVerification : 'required' ,
36+ residentKey : 'required' as const ,
37+ userVerification : 'required' as const ,
3838 } ,
39- attestation : 'none' ,
39+ attestation : 'none' as const ,
4040 pubKeyCredParams : [
4141 {
42- type : 'public-key' ,
42+ type : 'public-key' as const ,
4343 alg : - 7 ,
4444 } ,
4545 ] ,
@@ -61,21 +61,23 @@ describe('Passkey utils', () => {
6161 userVerification : 'required' ,
6262 } ) ;
6363
64- expect ( bufferToBase64Url ( result . user . id ) ) . toEqual ( pkCreateOptions . user . id ) ;
64+ expect ( bufferToBase64Url ( result . user . id as ArrayBuffer ) ) . toEqual ( pkCreateOptions . user . id ) ;
6565
66- expect ( bufferToBase64Url ( result . excludeCredentials [ 0 ] . id ) ) . toEqual ( pkCreateOptions . excludeCredentials [ 0 ] . id ) ;
66+ expect ( bufferToBase64Url ( result . excludeCredentials [ 0 ] . id as ArrayBuffer ) ) . toEqual (
67+ pkCreateOptions . excludeCredentials [ 0 ] . id ,
68+ ) ;
6769 } ) ;
6870
6971 it ( 'convertJSONToPublicKeyCreateOptions()' , ( ) => {
70- const pkCreateOptions : PublicKeyCredentialRequestOptionsJSON = {
72+ const pkCreateOptions = {
7173 rpId : 'clerk.com' ,
7274 allowCredentials : [
7375 {
74- type : 'public-key' ,
76+ type : 'public-key' as const ,
7577 id : 'cmFuZG9tX2lk' ,
7678 } ,
7779 ] ,
78- userVerification : 'required' ,
80+ userVerification : 'required' as const ,
7981 timeout : 10000 ,
8082 challenge : 'Y2hhbGxlbmdlXzEyMw' , // challenge_123 encoded as base64url
8183 } ;
@@ -84,21 +86,23 @@ describe('Passkey utils', () => {
8486
8587 expect ( result . rpId ) . toEqual ( 'clerk.com' ) ;
8688 expect ( result . userVerification ) . toEqual ( 'required' ) ;
87- expect ( bufferToBase64Url ( result . allowCredentials [ 0 ] . id ) ) . toEqual ( pkCreateOptions . allowCredentials [ 0 ] . id ) ;
89+ expect ( bufferToBase64Url ( result . allowCredentials [ 0 ] . id as ArrayBuffer ) ) . toEqual (
90+ pkCreateOptions . allowCredentials [ 0 ] . id ,
91+ ) ;
8892 } ) ;
8993
9094 it ( 'serializePublicKeyCredential()' , ( ) => {
91- const publicKeyCredential : PublicKeyCredentialWithAuthenticatorAttestationResponse = {
92- type : 'public-key' ,
95+ const publicKeyCredential = {
96+ type : 'public-key' as const ,
9397 id : 'credentialId_123' ,
9498 rawId : new Uint8Array ( [ 99 , 114 , 101 , 100 , 101 , 110 , 116 , 105 , 97 , 108 , 73 , 100 , 95 , 49 , 50 , 51 ] ) ,
95- authenticatorAttachment : 'cross-platform' ,
99+ authenticatorAttachment : 'cross-platform' as AuthenticatorAttachment ,
96100 response : {
97101 clientDataJSON : new Uint8Array ( [ 110 , 116 , 105 , 97 ] ) ,
98102 attestationObject : new Uint8Array ( [ 108 , 73 , 100 , 95 , 49 ] ) ,
99- getTransports : ( ) => [ 'usb' ] ,
103+ getTransports : ( ) => [ 'usb' ] as AuthenticatorTransport [ ] ,
100104 } ,
101- } ;
105+ } as any as PublicKeyCredentialWithAuthenticatorAttestationResponse ;
102106
103107 const result = serializePublicKeyCredential ( publicKeyCredential ) ;
104108
@@ -112,18 +116,18 @@ describe('Passkey utils', () => {
112116 } ) ;
113117
114118 it ( 'serializePublicKeyCredentialAssertion()' , ( ) => {
115- const publicKeyCredential : PublicKeyCredentialWithAuthenticatorAssertionResponse = {
116- type : 'public-key' ,
119+ const publicKeyCredential = {
120+ type : 'public-key' as const ,
117121 id : 'credentialId_123' ,
118122 rawId : new Uint8Array ( [ 99 , 114 , 101 , 100 , 101 , 110 , 116 , 105 , 97 , 108 , 73 , 100 , 95 , 49 , 50 , 51 ] ) ,
119- authenticatorAttachment : 'cross-platform' ,
123+ authenticatorAttachment : 'cross-platform' as AuthenticatorAttachment ,
120124 response : {
121125 clientDataJSON : new Uint8Array ( [ 110 , 116 , 105 , 97 ] ) ,
122126 signature : new Uint8Array ( [ 108 , 73 , 100 , 95 , 49 ] ) ,
123127 authenticatorData : new Uint8Array ( [ 108 , 73 , 100 , 95 , 49 ] ) ,
124128 userHandle : null ,
125129 } ,
126- } ;
130+ } as any as PublicKeyCredentialWithAuthenticatorAssertionResponse ;
127131
128132 const result = serializePublicKeyCredentialAssertion ( publicKeyCredential ) ;
129133
0 commit comments