From ccdb4bac8d0a140d7a90a5e09073ebd92f6a3c33 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Mon, 12 Sep 2022 01:22:23 +0100 Subject: [PATCH] Add window for manually copying the redirect URI for Nintendo Account authentication --- src/app/browser/add-account-manual/index.tsx | 139 +++++++++++++++++++ src/app/browser/index.ts | 2 + src/app/common/types.ts | 2 + src/app/main/na-auth.ts | 71 ++++++++-- 4 files changed, 204 insertions(+), 10 deletions(-) create mode 100644 src/app/browser/add-account-manual/index.tsx diff --git a/src/app/browser/add-account-manual/index.tsx b/src/app/browser/add-account-manual/index.tsx new file mode 100644 index 0000000..75bf1b6 --- /dev/null +++ b/src/app/browser/add-account-manual/index.tsx @@ -0,0 +1,139 @@ +import React, { useCallback, useState } from 'react'; +import { StyleSheet, Text, TextInput, useColorScheme, View } from 'react-native'; +import { Button } from '../components/index.js'; +import { DEFAULT_ACCENT_COLOUR, HIGHLIGHT_COLOUR_DARK, HIGHLIGHT_COLOUR_LIGHT, TEXT_COLOUR_DARK, TEXT_COLOUR_LIGHT } from '../constants.js'; +import ipc, { events } from '../ipc.js'; +import { Root, useEventListener } from '../util.js'; + +export interface AddAccountManualPromptProps { + authoriseurl: string; + client_id: string; +} + +export default function AddAccountManualPrompt(props: AddAccountManualPromptProps) { + const colour_scheme = useColorScheme(); + const theme = colour_scheme === 'light' ? light : dark; + + const [accent_colour, setAccentColour] = React.useState(() => ipc.getAccentColour()); + useEventListener(events, 'systemPreferences:accent-colour', setAccentColour, []); + + useEventListener(events, 'window:refresh', () => true, []); + + const [callback_url, setCallbackUrl] = useState(''); + const callback_url_valid = callback_url.startsWith('npf' + props.client_id + '://auth'); + + const save = useCallback(() => { + if (callback_url_valid) { + location.href = callback_url; + } + }, [callback_url, callback_url_valid]); + + return + + 1. Login to your Nintendo Account + Do not select an account yet. + + +