0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(ui): nativeCallback renaming (#605)

nativeCallback renaming
This commit is contained in:
simeng-li 2022-04-21 17:11:10 +08:00 committed by GitHub
parent 51e6ac6d62
commit 10ca51cfa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View file

@ -26,7 +26,7 @@ describe('SecondarySocialSignIn', () => {
globalThis.logtoNativeSdk = {
platform: 'web',
getPostMessage: jest.fn(() => jest.fn()),
callbackUriScheme: '/logto:',
callbackLink: '/logto:',
};
/* eslint-enable @silverhand/fp/no-mutation */
});

View file

@ -12,13 +12,13 @@ import { PageContext } from './use-page-context';
* @param state
* @param state.uuid - unique id
* @param state.platform - platform
* @param state.callbackUriScheme - callback uri scheme
* @param state.callbackLink - callback uri scheme
*/
type State = {
uuid: string;
platform: 'web' | 'ios' | 'android';
callbackUriScheme?: string;
callbackLink?: string;
};
const storageKeyPrefix = 'social_auth_state';
@ -32,9 +32,9 @@ const getLogtoNativeSdk = () => {
export const generateState = () => {
const uuid = generateRandomString();
const platform = getLogtoNativeSdk()?.platform ?? 'web';
const callbackUriScheme = getLogtoNativeSdk()?.callbackUriScheme;
const callbackLink = getLogtoNativeSdk()?.callbackLink;
const state: State = { uuid, platform, callbackUriScheme };
const state: State = { uuid, platform, callbackLink };
return btoa(JSON.stringify(state));
};
@ -117,7 +117,7 @@ const useSocial = () => {
return;
}
const { platform, callbackUriScheme } = decodedState;
const { platform, callbackLink } = decodedState;
if (platform === 'web') {
window.location.assign(
@ -127,12 +127,12 @@ const useSocial = () => {
return;
}
if (!callbackUriScheme) {
// TODO: native callbackUriScheme not found error message
if (!callbackLink) {
// TODO: native callbackLink not found error message
return;
}
window.location.assign(new URL(`${callbackUriScheme}${window.location.search}`));
window.location.assign(new URL(`${callbackLink}${window.location.search}`));
},
[setToast]
);

View file

@ -2,7 +2,7 @@
type LogtoNativeSdkInfo = {
platform: 'ios' | 'android';
callbackUriScheme: string;
callbackLink: string;
getPostMessage: () => (data: { callbackUri?: string; redirectTo?: string }) => void;
supportedSocialConnectors: string[];
};