1- function encodeBase64 ( data : Uint8Array ) : string {
1+ function encodeBase64 ( data : Uint8Array < ArrayBuffer > ) : string {
22 return btoa ( String . fromCharCode ( ...data ) ) ;
33}
44
5- function decodeBase64 ( data : string ) : Uint8Array {
5+ function decodeBase64 ( data : string ) : Uint8Array < ArrayBuffer > {
66 return new Uint8Array ( atob ( data ) . split ( "" ) . map ( ( c ) => c . charCodeAt ( 0 ) ) ) ;
77}
88
@@ -24,9 +24,9 @@ enum AuthenticationState {
2424 * in HMAC-derived binary format
2525 */
2626interface KeySignatures {
27- client : Uint8Array ;
28- server : Uint8Array ;
29- stored : Uint8Array ;
27+ client : Uint8Array < ArrayBuffer > ;
28+ server : Uint8Array < ArrayBuffer > ;
29+ stored : Uint8Array < ArrayBuffer > ;
3030}
3131
3232/**
@@ -63,8 +63,8 @@ function assertValidScramString(str: string) {
6363
6464async function computeScramSignature (
6565 message : string ,
66- rawKey : Uint8Array ,
67- ) : Promise < Uint8Array > {
66+ rawKey : Uint8Array < ArrayBuffer > ,
67+ ) : Promise < Uint8Array < ArrayBuffer > > {
6868 const key = await crypto . subtle . importKey (
6969 "raw" ,
7070 rawKey ,
@@ -82,7 +82,10 @@ async function computeScramSignature(
8282 ) ;
8383}
8484
85- function computeScramProof ( signature : Uint8Array , key : Uint8Array ) : Uint8Array {
85+ function computeScramProof (
86+ signature : Uint8Array < ArrayBuffer > ,
87+ key : Uint8Array < ArrayBuffer > ,
88+ ) : Uint8Array < ArrayBuffer > {
8689 const digest = new Uint8Array ( signature . length ) ;
8790 for ( let i = 0 ; i < digest . length ; i ++ ) {
8891 digest [ i ] = signature [ i ] ^ key [ i ] ;
@@ -95,7 +98,7 @@ function computeScramProof(signature: Uint8Array, key: Uint8Array): Uint8Array {
9598 */
9699async function deriveKeySignatures (
97100 password : string ,
98- salt : Uint8Array ,
101+ salt : Uint8Array < ArrayBuffer > ,
99102 iterations : number ,
100103) : Promise < KeySignatures > {
101104 const pbkdf2Password = await crypto . subtle . importKey (
@@ -217,7 +220,7 @@ export class ScramClient {
217220 }
218221 this . #serverNonce = nonce ;
219222
220- let salt : Uint8Array | undefined ;
223+ let salt : Uint8Array < ArrayBuffer > | undefined ;
221224 if ( ! attrs . s ) {
222225 throw new Error ( Reason . BadSalt ) ;
223226 }
0 commit comments