Skip to content

Commit 6565d3f

Browse files
committed
Preserve canonical MFA method types
1 parent 9c6302c commit 6565d3f

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

‎packages/managed-auth-react/src/lib/types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export type ManagedAuthChoiceType =
8787
export interface ManagedAuthChoice {
8888
id: string;
8989
type: ManagedAuthChoiceType;
90+
mfa_type?: MFAType | null;
9091
label: string;
9192
description?: string | null;
9293
observed_selector?: string | null;

‎packages/managed-auth-react/src/session/state.test.ts‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,18 @@ describe("normalizeManagedAuthState", () => {
107107
const state = managedAuthState({
108108
choices: [
109109
{
110-
id: "sms_code",
110+
id: "text-ending-4821",
111111
type: "mfa_method",
112-
label: "Text me a code",
112+
mfa_type: "sms",
113+
label: "Text ending in 4821",
113114
description: "Six-digit code",
114115
},
116+
{
117+
id: "text-ending-9930",
118+
type: "mfa_method",
119+
mfa_type: "sms",
120+
label: "Text ending in 9930",
121+
},
115122
{
116123
id: "security_key_vendor",
117124
type: "mfa_method",
@@ -121,20 +128,32 @@ describe("normalizeManagedAuthState", () => {
121128
mfa_options: [
122129
{
123130
type: "sms",
124-
label: "Text me a code",
125-
target: "***-***-5678",
131+
label: "Text ending in 4821",
132+
target: "***-***-4821",
133+
},
134+
{
135+
type: "sms",
136+
label: "Text ending in 9930",
137+
target: "***-***-9930",
126138
},
127139
],
128140
});
129141

130142
expect(normalizeManagedAuthState(state).mfa_options).toEqual([
131143
{
132-
id: "sms_code",
144+
id: "text-ending-4821",
133145
type: "sms",
134-
label: "Text me a code",
135-
target: "***-***-5678",
146+
label: "Text ending in 4821",
147+
target: "***-***-4821",
136148
description: "Six-digit code",
137149
},
150+
{
151+
id: "text-ending-9930",
152+
type: "sms",
153+
label: "Text ending in 9930",
154+
target: "***-***-9930",
155+
description: undefined,
156+
},
138157
{
139158
id: "security_key_vendor",
140159
type: "other",

‎packages/managed-auth-react/src/session/state.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function mfaOptionsFromCanonical(
129129
const options = choices
130130
.filter((choice) => choice.type === "mfa_method")
131131
.map((choice) => {
132-
const type = normalizeMFAChoiceId(choice.id);
132+
const type = choice.mfa_type ?? normalizeMFAChoiceId(choice.id);
133133
const target = targets.get(type)?.shift();
134134
return {
135135
id: choice.id,

0 commit comments

Comments
 (0)