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:
@@ -17,7 +17,7 @@ describe('GetRecoveryCodes', () => {
|
||||
settingsClient.getSetting = jest.fn().mockResolvedValue('existing-recovery-codes')
|
||||
})
|
||||
|
||||
it('should return existing recovery codes if they exist', async () => {
|
||||
it('should return existing recovery code if they exist', async () => {
|
||||
const useCase = createUseCase()
|
||||
|
||||
const result = await useCase.execute()
|
||||
@@ -25,7 +25,7 @@ describe('GetRecoveryCodes', () => {
|
||||
expect(result.getValue()).toBe('existing-recovery-codes')
|
||||
})
|
||||
|
||||
it('should generate recovery codes if they do not exist', async () => {
|
||||
it('should generate recovery code if they do not exist', async () => {
|
||||
settingsClient.getSetting = jest.fn().mockResolvedValue(undefined)
|
||||
|
||||
const useCase = createUseCase()
|
||||
@@ -35,7 +35,7 @@ describe('GetRecoveryCodes', () => {
|
||||
expect(result.getValue()).toBe('recovery-codes')
|
||||
})
|
||||
|
||||
it('should return error if recovery codes could not be generated', async () => {
|
||||
it('should return error if recovery code could not be generated', async () => {
|
||||
settingsClient.getSetting = jest.fn().mockResolvedValue(undefined)
|
||||
authClient.generateRecoveryCodes = jest.fn().mockResolvedValue(false)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export class GetRecoveryCodes implements UseCaseInterface<string> {
|
||||
|
||||
const generatedRecoveryCodes = await this.authClient.generateRecoveryCodes()
|
||||
if (generatedRecoveryCodes === false) {
|
||||
return Result.fail('Could not generate recovery codes')
|
||||
return Result.fail('Could not generate recovery code')
|
||||
}
|
||||
|
||||
return Result.ok(generatedRecoveryCodes)
|
||||
|
||||
@@ -150,17 +150,17 @@ describe('SignInWithRecoveryCodes', () => {
|
||||
expect(result.getError()).toEqual('The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.com/help/security for more information.')
|
||||
})
|
||||
|
||||
it('should fail if the sign in with recovery codes fails', async () => {
|
||||
it('should fail if the sign in with recovery code fails', async () => {
|
||||
authManager.signInWithRecoveryCodes = jest.fn().mockReturnValue(false)
|
||||
|
||||
const useCase = createUseCase()
|
||||
const result = await useCase.execute({ recoveryCodes: 'recovery-codes', password: 'foobar', username: 'test@test.te' })
|
||||
|
||||
expect(result.isFailed()).toBe(true)
|
||||
expect(result.getError()).toEqual('Could not sign in with recovery codes')
|
||||
expect(result.getError()).toEqual('Could not sign in with recovery code')
|
||||
})
|
||||
|
||||
it('should sign in with recovery codes', async () => {
|
||||
it('should sign in with recovery code', async () => {
|
||||
authManager.signInWithRecoveryCodes = jest.fn().mockReturnValue({
|
||||
keyParams: {} as AnyKeyParamsContent,
|
||||
session: {} as SessionBody,
|
||||
|
||||
@@ -70,7 +70,7 @@ export class SignInWithRecoveryCodes implements UseCaseInterface<void> {
|
||||
})
|
||||
|
||||
if (signInResult === false) {
|
||||
return Result.fail('Could not sign in with recovery codes')
|
||||
return Result.fail('Could not sign in with recovery code')
|
||||
}
|
||||
|
||||
this.inMemoryStore.removeValue(StorageKey.CodeVerifier)
|
||||
|
||||
Reference in New Issue
Block a user