dropped display name Resolver, uuid -> user-id

Signed-off-by: Filip Swiatczak <filip.swiatczak@gmail.com>
This commit is contained in:
Filip Swiatczak
2021-10-01 17:05:48 +01:00
parent ed52838471
commit ad7bfe6810
3 changed files with 14 additions and 40 deletions
+8 -13
View File
@@ -84,12 +84,6 @@ export type BackstageIdentity = {
entity?: Entity;
};
// Warning: (ae-forgotten-export) The symbol "SignInResolver" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "bitbucketDisplayNameSignInResolver" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const bitbucketDisplayNameSignInResolver: SignInResolver<BitbucketOAuthResult>;
// Warning: (ae-missing-release-tag) "BitbucketOAuthResult" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -108,11 +102,11 @@ export type BitbucketOAuthResult = {
//
// @public (undocumented)
export type BitbucketPassportProfile = Profile & {
id?: string;
displayName?: string;
username?: string;
avatarUrl?: string;
_json?: {
uuid?: string;
links?: {
avatar?: {
href?: string;
@@ -131,16 +125,16 @@ export type BitbucketProviderOptions = {
};
};
// Warning: (ae-missing-release-tag) "bitbucketUserIdSignInResolver" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const bitbucketUserIdSignInResolver: SignInResolver<BitbucketOAuthResult>;
// Warning: (ae-missing-release-tag) "bitbucketUsernameSignInResolver" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const bitbucketUsernameSignInResolver: SignInResolver<BitbucketOAuthResult>;
// Warning: (ae-missing-release-tag) "bitbucketUuidSignInResolver" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const bitbucketUuidSignInResolver: SignInResolver<BitbucketOAuthResult>;
// Warning: (ae-missing-release-tag) "createBitbucketProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -532,7 +526,8 @@ export type WebMessageResponse =
//
// src/identity/types.d.ts:25:5 - (ae-forgotten-export) The symbol "TokenParams" needs to be exported by the entry point index.d.ts
// src/identity/types.d.ts:31:9 - (ae-forgotten-export) The symbol "AnyJWK" needs to be exported by the entry point index.d.ts
// src/providers/bitbucket/provider.d.ts:62:5 - (ae-forgotten-export) The symbol "AuthHandler" needs to be exported by the entry point index.d.ts
// src/providers/bitbucket/provider.d.ts:61:5 - (ae-forgotten-export) The symbol "AuthHandler" needs to be exported by the entry point index.d.ts
// src/providers/bitbucket/provider.d.ts:69:9 - (ae-forgotten-export) The symbol "SignInResolver" needs to be exported by the entry point index.d.ts
// src/providers/types.d.ts:109:5 - (ae-forgotten-export) The symbol "AuthProviderConfig" needs to be exported by the entry point index.d.ts
// src/providers/types.d.ts:115:5 - (ae-forgotten-export) The symbol "ExperimentalIdentityResolver" needs to be exported by the entry point index.d.ts
// src/providers/types.d.ts:132:8 - (tsdoc-missing-deprecation-message) The @deprecated block must include a deprecation message, e.g. describing the recommended alternative
@@ -17,8 +17,7 @@
export {
createBitbucketProvider,
bitbucketUsernameSignInResolver,
bitbucketUuidSignInResolver,
bitbucketDisplayNameSignInResolver,
bitbucketUserIdSignInResolver,
} from './provider';
export type {
BitbucketProviderOptions,
@@ -70,11 +70,11 @@ export type BitbucketOAuthResult = {
};
export type BitbucketPassportProfile = PassportProfile & {
id?: string;
displayName?: string;
username?: string;
avatarUrl?: string;
_json?: {
uuid?: string;
links?: {
avatar?: {
href?: string;
@@ -223,37 +223,17 @@ export const bitbucketUsernameSignInResolver: SignInResolver<BitbucketOAuthResul
return { id: entity.metadata.name, entity, token };
};
export const bitbucketDisplayNameSignInResolver: SignInResolver<BitbucketOAuthResult> =
export const bitbucketUserIdSignInResolver: SignInResolver<BitbucketOAuthResult> =
async (info, ctx) => {
const { result } = info;
if (!result.fullProfile.displayName) {
throw new Error('Bitbucket profile contained no display name');
if (!result.fullProfile.id) {
throw new Error('Bitbucket profile contained no User ID');
}
const entity = await ctx.catalogIdentityClient.findUser({
annotations: {
'bitbucket.org/displayName': result.fullProfile.displayName,
},
});
const claims = getEntityClaims(entity);
const token = await ctx.tokenIssuer.issueToken({ claims });
return { id: entity.metadata.name, entity, token };
};
export const bitbucketUuidSignInResolver: SignInResolver<BitbucketOAuthResult> =
async (info, ctx) => {
const { result } = info;
if (!result.fullProfile?._json?.uuid) {
throw new Error('Bitbucket profile contained no UUID');
}
const entity = await ctx.catalogIdentityClient.findUser({
annotations: {
'bitbucket.org/uuid': result.fullProfile._json?.uuid,
'bitbucket.org/user-id': result.fullProfile.id,
},
});