diff --git a/src/components/AuthMethodButton/AuthMethodButton.stories.tsx b/src/components/AuthMethodButton/AuthMethodButton.stories.tsx index 63d074d..e5da010 100644 --- a/src/components/AuthMethodButton/AuthMethodButton.stories.tsx +++ b/src/components/AuthMethodButton/AuthMethodButton.stories.tsx @@ -42,11 +42,22 @@ export default { } } as ComponentMeta; +function tryBase64Decode(input?: string) { + if (!input) return null; + + try { + const decoded = atob(input); + if (btoa(decoded) === input) return decoded; + return null; + } catch (err) { + return null; + } +} + + // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args const Template: ComponentStory = (args, {globals}) => { - const loginHint = - (args as any).loginHint && btoa(atob((args as any).loginHint)) === (args as any).loginHint ? atob((args as any).loginHint) : - (args as any).loginHint; + const loginHint = tryBase64Decode((args as any).loginHint); return (