feat: recovery codes UI (recovery sign in + get recovery codes) (#2139)
* feat(web): show recovery codes * feat(web): add recovery sign in * fix: copy * fix: styles * feat: add "copy to clipboard" button * style: copy * fix: copy button bg * style: singularize recovery codes * style: singularize recovery codes * feat: password validation Co-authored-by: Aman Harwara <amanharwara@protonmail.com> Co-authored-by: Mo <mo@standardnotes.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
ChallengePromptInterface,
|
||||
ChallengePrompt,
|
||||
EncryptionService,
|
||||
ChallengeStrings,
|
||||
} from '@standardnotes/services'
|
||||
import { ChallengeResponse } from './ChallengeResponse'
|
||||
import { ChallengeOperation } from './ChallengeOperation'
|
||||
@@ -109,6 +110,27 @@ export class ChallengeService extends AbstractService implements ChallengeServic
|
||||
return value.value as string
|
||||
}
|
||||
|
||||
async promptForAccountPassword(): Promise<boolean> {
|
||||
if (!this.protocolService.hasAccount()) {
|
||||
throw Error('Requiring account password for challenge with no account')
|
||||
}
|
||||
|
||||
const response = await this.promptForChallengeResponse(
|
||||
new Challenge(
|
||||
[new ChallengePrompt(ChallengeValidation.AccountPassword)],
|
||||
ChallengeReason.Custom,
|
||||
true,
|
||||
ChallengeStrings.EnterAccountPassword,
|
||||
),
|
||||
)
|
||||
|
||||
if (response) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wrapping key for operations that require resaving the root key
|
||||
* (changing the account password, signing in, registering, or upgrading protocol)
|
||||
|
||||
@@ -388,7 +388,7 @@ export class SNProtectionService extends AbstractService<ProtectionEvent> implem
|
||||
if (isNullOrUndefined(length)) {
|
||||
SNLog.error(Error('No valid protection session length found. Got ' + length))
|
||||
} else {
|
||||
await this.setSessionLength(length as UnprotectedAccessSecondsDuration)
|
||||
this.setSessionLength(length as UnprotectedAccessSecondsDuration)
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user