Skip to content

Commit 21d4aa0

Browse files
author
Llorenç Muntaner
authored
Add canister flag to enable open id generic in frontend (#3296)
* Add canister flag to enable open id generic in frontend * Add it to feature flags
1 parent 9a47f65 commit 21d4aa0

File tree

13 files changed

+28
-0
lines changed

13 files changed

+28
-0
lines changed

src/frontend/src/lib/generated/internet_identity_idl.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const idlFactory = ({ IDL }) => {
5555
'archive_config' : IDL.Opt(ArchiveConfig),
5656
'canister_creation_cycles_cost' : IDL.Opt(IDL.Nat64),
5757
'analytics_config' : IDL.Opt(IDL.Opt(AnalyticsConfig)),
58+
'feature_flag_enable_generic_open_id_fe' : IDL.Opt(IDL.Bool),
5859
'related_origins' : IDL.Opt(IDL.Vec(IDL.Text)),
5960
'feature_flag_continue_from_another_device' : IDL.Opt(IDL.Bool),
6061
'openid_configs' : IDL.Opt(IDL.Vec(OpenIdConfig)),
@@ -850,6 +851,7 @@ export const init = ({ IDL }) => {
850851
'archive_config' : IDL.Opt(ArchiveConfig),
851852
'canister_creation_cycles_cost' : IDL.Opt(IDL.Nat64),
852853
'analytics_config' : IDL.Opt(IDL.Opt(AnalyticsConfig)),
854+
'feature_flag_enable_generic_open_id_fe' : IDL.Opt(IDL.Bool),
853855
'related_origins' : IDL.Opt(IDL.Vec(IDL.Text)),
854856
'feature_flag_continue_from_another_device' : IDL.Opt(IDL.Bool),
855857
'openid_configs' : IDL.Opt(IDL.Vec(OpenIdConfig)),

src/frontend/src/lib/generated/internet_identity_types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ export interface InternetIdentityInit {
279279
'archive_config' : [] | [ArchiveConfig],
280280
'canister_creation_cycles_cost' : [] | [bigint],
281281
'analytics_config' : [] | [[] | [AnalyticsConfig]],
282+
'feature_flag_enable_generic_open_id_fe' : [] | [boolean],
282283
'related_origins' : [] | [Array<string>],
283284
'feature_flag_continue_from_another_device' : [] | [boolean],
284285
'openid_configs' : [] | [Array<OpenIdConfig>],

src/frontend/src/lib/state/featureFlags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export const ADD_ACCESS_METHOD = createFeatureFlagStore(
9999
export const ENABLE_GENERIC_OPEN_ID = createFeatureFlagStore(
100100
"ENABLE_GENERIC_OPEN_ID",
101101
false,
102+
() => canisterConfig.feature_flag_enable_generic_open_id_fe[0],
102103
);
103104

104105
export const CONTINUE_FROM_ANOTHER_DEVICE = createFeatureFlagStore(

src/frontend/src/lib/utils/domainUtils.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe("isOfficialOrigin", () => {
2222
new_flow_origins: [],
2323
dummy_auth: [],
2424
feature_flag_continue_from_another_device: [],
25+
feature_flag_enable_generic_open_id_fe: [],
2526
});
2627

2728
// Default related origins for most tests

src/frontend/src/lib/utils/iiConnection.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const DEFAULT_INIT: InternetIdentityInit = {
8282
new_flow_origins: [],
8383
dummy_auth: [],
8484
feature_flag_continue_from_another_device: [],
85+
feature_flag_enable_generic_open_id_fe: [],
8586
};
8687

8788
const mockActor = {

src/frontend/src/lib/utils/isRegistrationAllowed.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe("isRegistrationAllowed", () => {
2222
new_flow_origins: [],
2323
dummy_auth: [],
2424
feature_flag_continue_from_another_device: [],
25+
feature_flag_enable_generic_open_id_fe: [],
2526
};
2627
};
2728

src/internet_identity/internet_identity.did

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ type InternetIdentityInit = record {
291291
dummy_auth : opt opt DummyAuthConfig;
292292
// Feature flags
293293
feature_flag_continue_from_another_device : opt bool;
294+
feature_flag_enable_generic_open_id_fe : opt bool;
294295
};
295296

296297
type ChallengeKey = text;

src/internet_identity/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ fn config() -> InternetIdentityInit {
503503
dummy_auth: Some(persistent_state.dummy_auth.clone()),
504504
feature_flag_continue_from_another_device: persistent_state
505505
.feature_flag_continue_from_another_device,
506+
feature_flag_enable_generic_open_id_fe: persistent_state
507+
.feature_flag_enable_generic_open_id_fe,
506508
})
507509
}
508510

@@ -634,6 +636,11 @@ fn apply_install_arg(maybe_arg: Option<InternetIdentityInit>) {
634636
persistent_state.feature_flag_continue_from_another_device = Some(flag);
635637
})
636638
}
639+
if let Some(flag) = arg.feature_flag_enable_generic_open_id_fe {
640+
state::persistent_state_mut(|persistent_state| {
641+
persistent_state.feature_flag_enable_generic_open_id_fe = Some(flag);
642+
})
643+
}
637644
}
638645
}
639646

src/internet_identity/src/state.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ pub struct PersistentState {
144144
pub dummy_auth: Option<DummyAuthConfig>,
145145
// Feature flags
146146
pub feature_flag_continue_from_another_device: Option<bool>,
147+
pub feature_flag_enable_generic_open_id_fe: Option<bool>,
147148
}
148149

149150
impl Default for PersistentState {
@@ -168,6 +169,7 @@ impl Default for PersistentState {
168169
is_production: None,
169170
dummy_auth: None,
170171
feature_flag_continue_from_another_device: None,
172+
feature_flag_enable_generic_open_id_fe: None,
171173
}
172174
}
173175
}

src/internet_identity/src/storage/storable/storable_persistent_state.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub struct StorablePersistentState {
4545

4646
// Feature flags
4747
feature_flag_continue_from_another_device: Option<bool>,
48+
feature_flag_enable_generic_open_id_fe: Option<bool>,
4849
}
4950

5051
impl Storable for StorablePersistentState {
@@ -92,6 +93,7 @@ impl From<PersistentState> for StorablePersistentState {
9293
is_production: s.is_production,
9394
dummy_auth: s.dummy_auth,
9495
feature_flag_continue_from_another_device: s.feature_flag_continue_from_another_device,
96+
feature_flag_enable_generic_open_id_fe: s.feature_flag_enable_generic_open_id_fe,
9597
}
9698
}
9799
}
@@ -117,6 +119,7 @@ impl From<StorablePersistentState> for PersistentState {
117119
is_production: s.is_production,
118120
dummy_auth: s.dummy_auth,
119121
feature_flag_continue_from_another_device: s.feature_flag_continue_from_another_device,
122+
feature_flag_enable_generic_open_id_fe: s.feature_flag_enable_generic_open_id_fe,
120123
}
121124
}
122125
}
@@ -170,6 +173,7 @@ mod tests {
170173
is_production: None,
171174
dummy_auth: None,
172175
feature_flag_continue_from_another_device: None,
176+
feature_flag_enable_generic_open_id_fe: None,
173177
};
174178

175179
assert_eq!(StorablePersistentState::default(), expected_defaults);
@@ -199,6 +203,7 @@ mod tests {
199203
is_production: None,
200204
dummy_auth: None,
201205
feature_flag_continue_from_another_device: None,
206+
feature_flag_enable_generic_open_id_fe: None,
202207
};
203208
assert_eq!(PersistentState::default(), expected_defaults);
204209
}

0 commit comments

Comments
 (0)