Skip to content

Commit

Permalink
Quick fix - don't show missing mnemonic at startup (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
GhenadieVP authored Oct 23, 2023
1 parent 1c95349 commit 920e7bf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ extension DeviceFactorSourceClient: DependencyKey {
let mnemonicWithPassphrase = try await secureStorageClient
.loadMnemonicByFactorSourceID(
deviceFactorSource.id,
.checkingAccounts
.checkingAccounts,
false
)
else {
// Failed to find mnemonic for factor source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension SecureStorageClient {
public typealias LoadProfileSnapshotData = @Sendable (ProfileSnapshot.Header.ID) async throws -> Data?

public typealias SaveMnemonicForFactorSource = @Sendable (PrivateHDFactorSource) async throws -> Void
public typealias LoadMnemonicByFactorSourceID = @Sendable (FactorSourceID.FromHash, LoadMnemonicPurpose) async throws -> MnemonicWithPassphrase?
public typealias LoadMnemonicByFactorSourceID = @Sendable (FactorSourceID.FromHash, LoadMnemonicPurpose, _ notifyIfMissing: Bool) async throws -> MnemonicWithPassphrase?
public typealias ContainsMnemonicIdentifiedByFactorSourceID = @Sendable (FactorSourceID.FromHash) async -> Bool

public typealias DeleteMnemonicByFactorSourceID = @Sendable (FactorSourceID.FromHash) async throws -> Void
Expand Down Expand Up @@ -79,6 +79,13 @@ extension SecureStorageClient {
}
}

extension SecureStorageClient {
@Sendable
public func loadMnemonicByFactorSourceID(_ factorSourceID: FactorSourceID.FromHash, _ purpose: LoadMnemonicPurpose) async throws -> MnemonicWithPassphrase? {
try await self.loadMnemonicByFactorSourceID(factorSourceID, purpose, true)
}
}

extension SecureStorageClient {
public func saveDeviceIdentifierIfNeeded(
_ deviceID: UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ extension SecureStorageClient: DependencyKey {
)
)
},
loadMnemonicByFactorSourceID: { factorSourceID, purpose in
loadMnemonicByFactorSourceID: { factorSourceID, purpose, notifyIfMissing in
let key = key(factorSourceID: factorSourceID)
let authPromptValue: String = {
switch purpose {
Expand Down Expand Up @@ -233,7 +233,9 @@ extension SecureStorageClient: DependencyKey {
forKey: key,
authenticationPrompt: authenticationPrompt
) else {
_ = await overlayWindowClient.scheduleAlert(.missingMnemonicAlert)
if notifyIfMissing {
_ = await overlayWindowClient.scheduleAlert(.missingMnemonicAlert)
}
return nil
}
return try jsonDecoder().decode(MnemonicWithPassphrase.self, from: data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension SecureStorageClient: TestDependencyKey {
saveProfileSnapshot: { _ in },
loadProfileSnapshotData: { _ in nil },
saveMnemonicForFactorSource: { _ in },
loadMnemonicByFactorSourceID: { _, _ in nil },
loadMnemonicByFactorSourceID: { _, _, _ in nil },
containsMnemonicIdentifiedByFactorSourceID: { _ in false },
deleteMnemonicByFactorSourceID: { _ in },
deleteProfileAndMnemonicsByFactorSourceIDs: { _, _ in },
Expand Down

0 comments on commit 920e7bf

Please sign in to comment.