internal: incomplete vault systems behind feature flag (#2340)

This commit is contained in:
Mo
2023-06-30 09:01:56 -05:00
committed by GitHub
parent d16e401bb9
commit b032eb9c9b
638 changed files with 20321 additions and 4813 deletions

View File

@@ -1,7 +1,6 @@
import { Challenge, ChallengeValue, ChallengeArtifacts } from '@standardnotes/services'
import { Challenge, ChallengeValue, ChallengeArtifacts, ChallengeValueCallback } from '@standardnotes/services'
import { ChallengeResponse } from './ChallengeResponse'
import { removeFromArray } from '@standardnotes/utils'
import { ValueCallback } from './ChallengeService'
/**
* A challenge operation stores user-submitted values and callbacks.
@@ -15,8 +14,8 @@ export class ChallengeOperation {
constructor(
public challenge: Challenge,
public onValidValue: ValueCallback,
public onInvalidValue: ValueCallback,
public onValidValue: ChallengeValueCallback,
public onInvalidValue: ChallengeValueCallback,
public onNonvalidatedSubmit: (response: ChallengeResponse) => void,
public onComplete: (response: ChallengeResponse) => void,
public onCancel: () => void,

View File

@@ -16,6 +16,7 @@ import {
ChallengePrompt,
EncryptionService,
ChallengeStrings,
ChallengeObserver,
} from '@standardnotes/services'
import { ChallengeResponse } from './ChallengeResponse'
import { ChallengeOperation } from './ChallengeOperation'
@@ -25,16 +26,6 @@ type ChallengeValidationResponse = {
artifacts?: ChallengeArtifacts
}
export type ValueCallback = (value: ChallengeValue) => void
export type ChallengeObserver = {
onValidValue?: ValueCallback
onInvalidValue?: ValueCallback
onNonvalidatedSubmit?: (response: ChallengeResponse) => void
onComplete?: (response: ChallengeResponse) => void
onCancel?: () => void
}
const clearChallengeObserver = (observer: ChallengeObserver) => {
observer.onCancel = undefined
observer.onComplete = undefined
@@ -112,7 +103,7 @@ export class ChallengeService extends AbstractService implements ChallengeServic
return value.value as string
}
async promptForAccountPassword(): Promise<boolean> {
async promptForAccountPassword(): Promise<string | null> {
if (!this.protocolService.hasAccount()) {
throw Error('Requiring account password for challenge with no account')
}
@@ -126,11 +117,7 @@ export class ChallengeService extends AbstractService implements ChallengeServic
),
)
if (response) {
return true
} else {
return false
}
return response?.getValueForType(ChallengeValidation.AccountPassword)?.value as string
}
/**
@@ -175,7 +162,7 @@ export class ChallengeService extends AbstractService implements ChallengeServic
return this.protocolService.isPasscodeLocked()
}
public addChallengeObserver(challenge: Challenge, observer: ChallengeObserver) {
public addChallengeObserver(challenge: Challenge, observer: ChallengeObserver): () => void {
const observers = this.challengeObservers[challenge.id] || []
observers.push(observer)
@@ -303,11 +290,11 @@ export class ChallengeService extends AbstractService implements ChallengeServic
}
public setValidationStatusForChallenge(
challenge: Challenge,
challenge: ChallengeInterface,
value: ChallengeValue,
valid: boolean,
artifacts?: ChallengeArtifacts,
) {
): void {
const operation = this.getChallengeOperation(challenge)
operation.setValueStatus(value, valid, artifacts)