2022-04-09 12:20:21 +08:00
|
|
|
import ky from 'ky';
|
|
|
|
|
2022-04-12 15:03:38 +08:00
|
|
|
export const invokeSocialSignIn = async (
|
|
|
|
connectorId: string,
|
|
|
|
state: string,
|
|
|
|
redirectUri: string
|
|
|
|
) => {
|
2022-04-09 12:20:21 +08:00
|
|
|
type Response = {
|
|
|
|
redirectTo: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
return ky
|
|
|
|
.post('/api/session/sign-in/social', {
|
|
|
|
json: {
|
|
|
|
connectorId,
|
|
|
|
state,
|
|
|
|
redirectUri,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.json<Response>();
|
|
|
|
};
|
|
|
|
|
2022-04-19 16:32:33 +08:00
|
|
|
export const signInWithSocial = async (parameters: {
|
2022-04-09 12:20:21 +08:00
|
|
|
connectorId: string;
|
|
|
|
state: string;
|
|
|
|
redirectUri: string;
|
|
|
|
code: string;
|
|
|
|
}) => {
|
|
|
|
type Response = {
|
|
|
|
redirectTo: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
return ky
|
|
|
|
.post('/api/session/sign-in/social', {
|
|
|
|
json: parameters,
|
|
|
|
})
|
|
|
|
.json<Response>();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const bindSocialAccount = async (connectorId: string) => {
|
|
|
|
type Response = {
|
|
|
|
redirectTo: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
return ky
|
|
|
|
.post('/api/session/sign-in/bind-social-related-user', {
|
|
|
|
json: {
|
|
|
|
connectorId,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.json<Response>();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const registerWithSocial = async (connectorId: string) => {
|
|
|
|
type Response = {
|
|
|
|
redirectTo: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
return ky
|
|
|
|
.post('/api/session/register/social', {
|
|
|
|
json: {
|
|
|
|
connectorId,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.json<Response>();
|
|
|
|
};
|