summaryrefslogtreecommitdiff
path: root/packages/anastasis-core/src/reducer-types.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/anastasis-core/src/reducer-types.ts')
-rw-r--r--packages/anastasis-core/src/reducer-types.ts241
1 files changed, 241 insertions, 0 deletions
diff --git a/packages/anastasis-core/src/reducer-types.ts b/packages/anastasis-core/src/reducer-types.ts
new file mode 100644
index 000000000..0d1754bd9
--- /dev/null
+++ b/packages/anastasis-core/src/reducer-types.ts
@@ -0,0 +1,241 @@
+import { Duration } from "@gnu-taler/taler-util";
+
+export type ReducerState =
+ | ReducerStateBackup
+ | ReducerStateRecovery
+ | ReducerStateError;
+
+export interface ContinentInfo {
+ name: string;
+}
+
+export interface CountryInfo {
+ code: string;
+ name: string;
+ continent: string;
+ currency: string;
+}
+
+export interface Policy {
+ methods: {
+ authentication_method: number;
+ provider: string;
+ }[];
+}
+
+export interface PolicyProvider {
+ provider_url: string;
+}
+
+export interface ReducerStateBackup {
+ recovery_state?: undefined;
+ backup_state: BackupStates;
+ code?: undefined;
+ currencies?: string[];
+ continents?: ContinentInfo[];
+ countries?: any;
+ identity_attributes?: { [n: string]: string };
+ authentication_providers?: { [url: string]: AuthenticationProviderStatus };
+ authentication_methods?: AuthMethod[];
+ required_attributes?: any;
+ selected_continent?: string;
+ selected_country?: string;
+ secret_name?: string;
+ policies?: Policy[];
+ /**
+ * Policy providers are providers that we checked to be functional
+ * and that are actually used in policies.
+ */
+ policy_providers?: PolicyProvider[];
+ success_details?: {
+ [provider_url: string]: {
+ policy_version: number;
+ };
+ };
+ payments?: string[];
+ policy_payment_requests?: {
+ payto: string;
+ provider: string;
+ }[];
+
+ core_secret?: {
+ mime: string;
+ value: string;
+ };
+
+ expiration?: Duration;
+}
+
+export interface AuthMethod {
+ type: string;
+ instructions: string;
+ challenge: string;
+ mime_type?: string;
+}
+
+export interface ChallengeInfo {
+ cost: string;
+ instructions: string;
+ type: string;
+ uuid: string;
+}
+
+export interface UserAttributeSpec {
+ label: string;
+ name: string;
+ type: string;
+ uuid: string;
+ widget: string;
+}
+
+export interface ReducerStateRecovery {
+ backup_state?: undefined;
+ recovery_state: RecoveryStates;
+ code?: undefined;
+
+ identity_attributes?: { [n: string]: string };
+
+ continents?: any;
+ countries?: any;
+ required_attributes?: any;
+
+ recovery_information?: {
+ challenges: ChallengeInfo[];
+ policies: {
+ /**
+ * UUID of the associated challenge.
+ */
+ uuid: string;
+ }[][];
+ };
+
+ recovery_document?: {
+ secret_name: string;
+ provider_url: string;
+ version: number;
+ };
+
+ selected_challenge_uuid?: string;
+
+ challenge_feedback?: { [uuid: string]: ChallengeFeedback };
+
+ core_secret?: {
+ mime: string;
+ value: string;
+ };
+
+ authentication_providers?: {
+ [url: string]: {
+ business_name: string;
+ };
+ };
+
+ recovery_error?: any;
+}
+
+export interface ChallengeFeedback {
+ state: string;
+}
+
+export interface ReducerStateError {
+ backup_state?: undefined;
+ recovery_state?: undefined;
+ code: number;
+ hint?: string;
+ message?: string;
+}
+
+export enum BackupStates {
+ ContinentSelecting = "CONTINENT_SELECTING",
+ CountrySelecting = "COUNTRY_SELECTING",
+ UserAttributesCollecting = "USER_ATTRIBUTES_COLLECTING",
+ AuthenticationsEditing = "AUTHENTICATIONS_EDITING",
+ PoliciesReviewing = "POLICIES_REVIEWING",
+ SecretEditing = "SECRET_EDITING",
+ TruthsPaying = "TRUTHS_PAYING",
+ PoliciesPaying = "POLICIES_PAYING",
+ BackupFinished = "BACKUP_FINISHED",
+}
+
+export enum RecoveryStates {
+ ContinentSelecting = "CONTINENT_SELECTING",
+ CountrySelecting = "COUNTRY_SELECTING",
+ UserAttributesCollecting = "USER_ATTRIBUTES_COLLECTING",
+ SecretSelecting = "SECRET_SELECTING",
+ ChallengeSelecting = "CHALLENGE_SELECTING",
+ ChallengePaying = "CHALLENGE_PAYING",
+ ChallengeSolving = "CHALLENGE_SOLVING",
+ RecoveryFinished = "RECOVERY_FINISHED",
+}
+
+export interface MethodSpec {
+ type: string;
+ usage_fee: string;
+}
+
+// FIXME: This should be tagged!
+export type AuthenticationProviderStatusEmpty = {};
+
+export interface AuthenticationProviderStatusOk {
+ annual_fee: string;
+ business_name: string;
+ currency: string;
+ http_status: 200;
+ liability_limit: string;
+ salt: string;
+ storage_limit_in_megabytes: number;
+ truth_upload_fee: string;
+ methods: MethodSpec[];
+}
+
+export interface AuthenticationProviderStatusError {
+ http_status: number;
+ error_code: number;
+}
+
+export type AuthenticationProviderStatus =
+ | AuthenticationProviderStatusEmpty
+ | AuthenticationProviderStatusError
+ | AuthenticationProviderStatusOk;
+
+export interface ReducerStateBackupUserAttributesCollecting
+ extends ReducerStateBackup {
+ backup_state: BackupStates.UserAttributesCollecting;
+ selected_country: string;
+ currencies: string[];
+ required_attributes: UserAttributeSpec[];
+ authentication_providers: { [url: string]: AuthenticationProviderStatus };
+}
+
+export interface ActionArgEnterUserAttributes {
+ identity_attributes: Record<string, string>;
+}
+
+export interface ActionArgAddAuthentication {
+ authentication_method: {
+ type: string;
+ instructions: string;
+ challenge: string;
+ mime?: string;
+ };
+}
+
+export interface ActionArgDeleteAuthentication {
+ authentication_method: number;
+}
+
+export interface ActionArgDeletePolicy {
+ policy_index: number;
+}
+
+export interface ActionArgEnterSecretName {
+ name: string;
+}
+
+export interface ActionArgEnterSecret {
+ secret: {
+ value: string;
+ mime?: string;
+ };
+ expiration: Duration;
+}