Fixes in response format in frontend and backend apis

This commit is contained in:
Raghunandan
2020-05-25 16:51:50 +02:00
parent 6cd55c3b7b
commit a739f2da58
4 changed files with 11 additions and 5 deletions
+5 -1
View File
@@ -58,9 +58,13 @@ function createEnv(plugin: string): PluginEnvironment {
async function main() {
const app = express();
const corsOptions: cors.CorsOptions = {
origin: 'http://localhost:3000',
credentials: true,
};
app.use(helmet());
app.use(cors());
app.use(cors(corsOptions));
app.use(compression());
app.use(express.json());
app.use(requestLoggingHandler());
@@ -40,7 +40,7 @@ type CreateOptions = {
export type GoogleAuthResponse = {
accessToken: string;
idToken: string;
scopes: string;
scope: string;
expiresInSeconds: number;
};
@@ -70,7 +70,7 @@ class GoogleAuth implements OAuthApi, OpenIdConnectApi {
return {
idToken: res.idToken,
accessToken: res.accessToken,
scopes: GoogleAuth.normalizeScopes(res.scopes),
scopes: GoogleAuth.normalizeScopes(res.scope),
expiresAt: new Date(Date.now() + res.expiresInSeconds * 1000),
};
},
@@ -99,7 +99,7 @@ export class DefaultAuthConnector<AuthSession>
}
async refreshSession(): Promise<any> {
const res = await fetch(this.buildUrl('/token', { optional: true }), {
const res = await fetch(this.buildUrl('/refresh', { optional: true }), {
headers: {
'x-requested-with': 'XMLHttpRequest',
},
@@ -63,7 +63,8 @@ export class GoogleAuthProvider
maxAge: THOUSAND_DAYS_MS,
secure: false,
sameSite: 'none',
path: 'localhost:3000/auth/google',
domain: 'localhost',
path: '/auth/google',
httpOnly: true,
};
@@ -123,6 +124,7 @@ export class GoogleAuthProvider
accessToken,
refreshToken,
scope: params.scope,
expiresInSeconds: params.expires_in,
});
},
);