-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClientState.ts
112 lines (93 loc) · 2.74 KB
/
ClientState.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { Consent } from '@/shared/model/Consent';
import { NewsLetter } from '@/shared/model/Newsletter';
import { GeoLocation } from '@/shared/model/Geolocation';
import { QueryParams } from '@/shared/model/QueryParams';
import { Participations } from '@guardian/ab-core';
import { ConsentPath, RoutePaths } from '@/shared/model/Routes';
import { UserAttributesResponse } from '@/shared/lib/members-data-api';
import { Stage } from '@/shared/model/Configuration';
import { AppName } from '@/shared/lib/appNameUtils';
import { GatewayError } from '@/shared/model/Errors';
export interface FieldError {
field: string;
message: string;
}
interface ABTesting {
mvtId?: number;
participations?: Participations;
forcedTestVariants?: Participations;
}
interface GlobalMessage {
error?: string;
success?: string;
}
export type IsNativeApp = 'android' | 'ios' | undefined;
// determine what the sign in page view should be
export type SignInView = 'passcode' | 'password';
export interface PageData {
// general page data
returnUrl?: string;
email?: string;
signInPageUrl?: string;
geolocation?: GeoLocation;
fieldErrors?: FieldError[];
formError?: GatewayError;
browserName?: string;
isNativeApp?: IsNativeApp;
accountManagementUrl?: string;
appName?: AppName;
// token
token?: string;
// email sent pages specific
resendEmailAction?: RoutePaths;
changeEmailPage?: RoutePaths;
// onboarding specific
newsletters?: NewsLetter[];
consents?: Consent[];
page?: ConsentPath;
previousPage?: ConsentPath;
// reset password token specific
timeUntilTokenExpiry?: number;
// jobs specific
firstName?: string;
secondName?: string;
userBelongsToGRS?: boolean;
// signed in as page specific
continueLink?: string;
signOutLink?: string;
// subscription specific
newsletterId?: string;
// delete specific
contentAccess?: UserAttributesResponse['contentAccess'];
// okta idx api specific
hasStateHandle?: boolean; // determines if the state handle is present in the encrypted state, so we know if we're in an Okta IDX flow
passcodeUsed?: boolean; // determines if the passcode has been used in the Okta IDX flow, so don't show the passcode page again
}
export interface RecaptchaConfig {
recaptchaSiteKey: string;
}
export interface SentryConfig {
build?: string;
stage?: Stage;
dsn: string;
}
export interface ClientHosts {
idapiBaseUrl: string;
oauthBaseUrl: string;
}
export interface ClientState {
queryParams: QueryParams;
globalMessage?: GlobalMessage;
pageData?: PageData;
csrf?: CsrfState;
abTesting?: ABTesting;
clientHosts: ClientHosts;
recaptchaConfig: RecaptchaConfig;
sentryConfig: SentryConfig;
//just the first group of the request id UUID
shortRequestId?: string;
}
export type CsrfState = {
token?: string;
pageUrl?: string;
};