chore: format with prettier

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2022-01-25 09:11:48 +01:00
parent beff00764f
commit 3cd9123a32
6 changed files with 108 additions and 100 deletions
@@ -205,45 +205,47 @@ export class BitbucketAuthProvider implements OAuthHandlers {
}
}
export const bitbucketUsernameSignInResolver: SignInResolver<BitbucketOAuthResult> =
async (info, ctx) => {
const { result } = info;
export const bitbucketUsernameSignInResolver: SignInResolver<
BitbucketOAuthResult
> = async (info, ctx) => {
const { result } = info;
if (!result.fullProfile.username) {
throw new Error('Bitbucket profile contained no Username');
}
if (!result.fullProfile.username) {
throw new Error('Bitbucket profile contained no Username');
}
const entity = await ctx.catalogIdentityClient.findUser({
annotations: {
'bitbucket.org/username': result.fullProfile.username,
},
});
const entity = await ctx.catalogIdentityClient.findUser({
annotations: {
'bitbucket.org/username': result.fullProfile.username,
},
});
const claims = getEntityClaims(entity);
const token = await ctx.tokenIssuer.issueToken({ claims });
const claims = getEntityClaims(entity);
const token = await ctx.tokenIssuer.issueToken({ claims });
return { id: entity.metadata.name, entity, token };
};
return { id: entity.metadata.name, entity, token };
};
export const bitbucketUserIdSignInResolver: SignInResolver<BitbucketOAuthResult> =
async (info, ctx) => {
const { result } = info;
export const bitbucketUserIdSignInResolver: SignInResolver<
BitbucketOAuthResult
> = async (info, ctx) => {
const { result } = info;
if (!result.fullProfile.id) {
throw new Error('Bitbucket profile contained no User ID');
}
if (!result.fullProfile.id) {
throw new Error('Bitbucket profile contained no User ID');
}
const entity = await ctx.catalogIdentityClient.findUser({
annotations: {
'bitbucket.org/user-id': result.fullProfile.id,
},
});
const entity = await ctx.catalogIdentityClient.findUser({
annotations: {
'bitbucket.org/user-id': result.fullProfile.id,
},
});
const claims = getEntityClaims(entity);
const token = await ctx.tokenIssuer.issueToken({ claims });
const claims = getEntityClaims(entity);
const token = await ctx.tokenIssuer.issueToken({ claims });
return { id: entity.metadata.name, entity, token };
};
return { id: entity.metadata.name, entity, token };
};
export type BitbucketProviderOptions = {
/**
@@ -184,21 +184,22 @@ export class GithubAuthProvider implements OAuthHandlers {
}
}
export const githubDefaultSignInResolver: SignInResolver<GithubOAuthResult> =
async (info, ctx) => {
const { fullProfile } = info.result;
export const githubDefaultSignInResolver: SignInResolver<
GithubOAuthResult
> = async (info, ctx) => {
const { fullProfile } = info.result;
const userId = fullProfile.username || fullProfile.id;
const userId = fullProfile.username || fullProfile.id;
const token = await ctx.tokenIssuer.issueToken({
claims: {
sub: `user:default/${userId}`,
ent: [`user:default/${userId}`],
},
});
const token = await ctx.tokenIssuer.issueToken({
claims: {
sub: `user:default/${userId}`,
ent: [`user:default/${userId}`],
},
});
return { id: userId, token };
};
return { id: userId, token };
};
export type GithubProviderOptions = {
/**
@@ -220,25 +220,26 @@ export const microsoftEmailSignInResolver: SignInResolver<OAuthResult> = async (
return { id: entity.metadata.name, entity, token };
};
export const microsoftDefaultSignInResolver: SignInResolver<OAuthResult> =
async (info, ctx) => {
const { profile } = info;
export const microsoftDefaultSignInResolver: SignInResolver<
OAuthResult
> = async (info, ctx) => {
const { profile } = info;
if (!profile.email) {
throw new Error('Profile contained no email');
}
if (!profile.email) {
throw new Error('Profile contained no email');
}
const userId = profile.email.split('@')[0];
const userId = profile.email.split('@')[0];
const token = await ctx.tokenIssuer.issueToken({
claims: {
sub: `user:default/${userId}`,
ent: [`user:default/${userId}`],
},
});
const token = await ctx.tokenIssuer.issueToken({
claims: {
sub: `user:default/${userId}`,
ent: [`user:default/${userId}`],
},
});
return { id: userId, token };
};
return { id: userId, token };
};
export type MicrosoftProviderOptions = {
/**
@@ -211,19 +211,20 @@ export class OidcAuthProvider implements OAuthHandlers {
}
}
export const oAuth2DefaultSignInResolver: SignInResolver<OidcAuthResult> =
async (info, ctx) => {
const { profile } = info;
export const oAuth2DefaultSignInResolver: SignInResolver<
OidcAuthResult
> = async (info, ctx) => {
const { profile } = info;
if (!profile.email) {
throw new Error('Profile contained no email');
}
const userId = profile.email.split('@')[0];
const token = await ctx.tokenIssuer.issueToken({
claims: { sub: userId, ent: [`user:default/${userId}`] },
});
return { id: userId, token };
};
if (!profile.email) {
throw new Error('Profile contained no email');
}
const userId = profile.email.split('@')[0];
const token = await ctx.tokenIssuer.issueToken({
claims: { sub: userId, ent: [`user:default/${userId}`] },
});
return { id: userId, token };
};
/**
* OIDC provider callback options. An auth handler and a sign in resolver
@@ -31,18 +31,19 @@ type CostInsightsPageLoadingProps = {
dispatchReset: (loadingActions: string[]) => void;
};
export const mapLoadingToProps: MapLoadingToProps<CostInsightsPageLoadingProps> =
({ state, actions, dispatch }) => ({
loadingActions: actions,
loadingGroups: state[DefaultLoadingAction.UserGroups],
loadingBillingDate: state[DefaultLoadingAction.LastCompleteBillingDate],
loadingInitial: state[DefaultLoadingAction.CostInsightsInitial],
dispatchInitial: (isLoading: boolean) =>
dispatch({ [DefaultLoadingAction.CostInsightsInitial]: isLoading }),
dispatchInsights: (isLoading: boolean) =>
dispatch({ [DefaultLoadingAction.CostInsightsPage]: isLoading }),
dispatchNone: (loadingActions: string[]) =>
dispatch(getResetState(loadingActions)),
dispatchReset: (loadingActions: string[]) =>
dispatch(getResetStateWithoutInitial(loadingActions)),
});
export const mapLoadingToProps: MapLoadingToProps<
CostInsightsPageLoadingProps
> = ({ state, actions, dispatch }) => ({
loadingActions: actions,
loadingGroups: state[DefaultLoadingAction.UserGroups],
loadingBillingDate: state[DefaultLoadingAction.LastCompleteBillingDate],
loadingInitial: state[DefaultLoadingAction.CostInsightsInitial],
dispatchInitial: (isLoading: boolean) =>
dispatch({ [DefaultLoadingAction.CostInsightsInitial]: isLoading }),
dispatchInsights: (isLoading: boolean) =>
dispatch({ [DefaultLoadingAction.CostInsightsPage]: isLoading }),
dispatchNone: (loadingActions: string[]) =>
dispatch(getResetState(loadingActions)),
dispatchReset: (loadingActions: string[]) =>
dispatch(getResetStateWithoutInitial(loadingActions)),
});
@@ -28,20 +28,22 @@ type CostInsightsTabsLoadingProps = {
dispatchReset: (loadingActions: string[]) => void;
};
export const mapFiltersToProps: MapFiltersToProps<CostInsightsTabsFilterProps> =
({ pageFilters, setPageFilters }) => ({
...pageFilters,
setGroup: (group: Group) =>
setPageFilters({
...pageFilters,
group: group.id,
project: null,
}),
});
export const mapFiltersToProps: MapFiltersToProps<
CostInsightsTabsFilterProps
> = ({ pageFilters, setPageFilters }) => ({
...pageFilters,
setGroup: (group: Group) =>
setPageFilters({
...pageFilters,
group: group.id,
project: null,
}),
});
export const mapLoadingToProps: MapLoadingToProps<CostInsightsTabsLoadingProps> =
({ actions, dispatch }) => ({
loadingActions: actions,
dispatchReset: (loadingActions: string[]) =>
dispatch(getResetStateWithoutInitial(loadingActions)),
});
export const mapLoadingToProps: MapLoadingToProps<
CostInsightsTabsLoadingProps
> = ({ actions, dispatch }) => ({
loadingActions: actions,
dispatchReset: (loadingActions: string[]) =>
dispatch(getResetStateWithoutInitial(loadingActions)),
});