internal: incomplete vault systems behind feature flag (#2340)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user