remove got dependency from auth-backend
Signed-off-by: Colton Padden <colton.padden@fastmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-auth-backend': patch
|
||||
---
|
||||
|
||||
Replaces the usage of `got` with `node-fetch` in the `getUserPhoto` method of the Microsoft provider
|
||||
@@ -46,7 +46,6 @@
|
||||
"express-promise-router": "^4.1.0",
|
||||
"express-session": "^1.17.1",
|
||||
"fs-extra": "9.1.0",
|
||||
"got": "^11.5.2",
|
||||
"helmet": "^4.0.0",
|
||||
"jose": "^1.27.1",
|
||||
"jwt-decode": "^3.1.0",
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
SignInResolver,
|
||||
} from '../types';
|
||||
import { Logger } from 'winston';
|
||||
import got from 'got';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
type PrivateInfo = {
|
||||
refreshToken: string;
|
||||
@@ -173,19 +173,18 @@ export class MicrosoftAuthProvider implements OAuthHandlers {
|
||||
|
||||
private getUserPhoto(accessToken: string): Promise<string | undefined> {
|
||||
return new Promise(resolve => {
|
||||
got
|
||||
.get('https://graph.microsoft.com/v1.0/me/photos/48x48/$value', {
|
||||
encoding: 'binary',
|
||||
responseType: 'buffer',
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
})
|
||||
.then(photoData => {
|
||||
const photoURL = `data:image/jpeg;base64,${Buffer.from(
|
||||
photoData.body,
|
||||
fetch('https://graph.microsoft.com/v1.0/me/photos/48x48/$value', {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
})
|
||||
.then(response => response.arrayBuffer())
|
||||
.then(arrayBuffer => {
|
||||
console.log(Buffer.from(arrayBuffer).toString('utf-8'));
|
||||
const imageUrl = `data:image/jpeg;base64,${Buffer.from(
|
||||
arrayBuffer,
|
||||
).toString('base64')}`;
|
||||
resolve(photoURL);
|
||||
resolve(imageUrl);
|
||||
})
|
||||
.catch(error => {
|
||||
this.logger.warn(
|
||||
|
||||
Reference in New Issue
Block a user