@@ -13,6 +13,7 @@ import * as olmlib from "../../src/crypto/olmlib";
1313import { sleep } from "../../src/utils" ;
1414import { CRYPTO_ENABLED } from "../../src/client" ;
1515import { DeviceInfo } from "../../src/crypto/deviceinfo" ;
16+ import { logger } from '../../src/logger' ;
1617
1718const Olm = global . Olm ;
1819
@@ -400,4 +401,28 @@ describe("Crypto", function() {
400401 expect ( aliceClient . sendToDevice . mock . calls [ 2 ] [ 2 ] ) . not . toBe ( txnId ) ;
401402 } ) ;
402403 } ) ;
404+
405+ describe ( 'Secret storage' , function ( ) {
406+ it ( "creates secret storage even if there is no keyInfo" , async function ( ) {
407+ jest . spyOn ( logger , 'log' ) . mockImplementation ( ( ) => { } ) ;
408+ jest . setTimeout ( 10000 ) ;
409+ const client = ( new TestClient ( "@a:example.com" , "dev" ) ) . client ;
410+ await client . initCrypto ( ) ;
411+ client . crypto . getSecretStorageKey = async ( ) => null ;
412+ client . crypto . isCrossSigningReady = async ( ) => false ;
413+ client . crypto . baseApis . uploadDeviceSigningKeys = ( ) => null ;
414+ client . crypto . baseApis . setAccountData = ( ) => null ;
415+ client . crypto . baseApis . uploadKeySignatures = ( ) => null ;
416+ client . crypto . baseApis . http . authedRequest = ( ) => null ;
417+ const createSecretStorageKey = async ( ) => {
418+ return {
419+ keyInfo : undefined , // Returning undefined here used to cause a crash
420+ privateKey : Uint8Array . of ( 32 , 33 ) ,
421+ } ;
422+ } ;
423+ await client . crypto . bootstrapSecretStorage ( {
424+ createSecretStorageKey,
425+ } ) ;
426+ } ) ;
427+ } ) ;
403428} ) ;
0 commit comments