1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

node fetch api

This commit is contained in:
Kyle Spearrin 2018-05-14 23:56:27 -04:00
parent 5850a590ce
commit 17cf059970
4 changed files with 22 additions and 3 deletions

5
package-lock.json generated
View File

@ -5786,6 +5786,11 @@
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=",
"dev": true
},
"node-fetch": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz",
"integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U="
},
"node-forge": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.1.tgz",

View File

@ -73,6 +73,7 @@
"electron-updater": "2.21.4",
"keytar": "4.1.0",
"lunr": "2.1.6",
"node-fetch": "2.1.2",
"node-forge": "0.7.1",
"rxjs": "5.5.6",
"zone.js": "0.8.19"

View File

@ -439,12 +439,10 @@ export class ApiService implements ApiServiceAbstraction {
}
private async handleTokenState(): Promise<string> {
let accessToken: string;
let accessToken = await this.tokenService.getToken();
if (this.tokenService.tokenNeedsRefresh()) {
const tokenResponse = await this.doRefreshToken();
accessToken = tokenResponse.accessToken;
} else {
accessToken = await this.tokenService.getToken();
}
return 'Bearer ' + accessToken;

View File

@ -0,0 +1,15 @@
import { Utils } from '../misc/utils';
import { ApiService } from './api.service';
import { PlatformUtilsService } from '../abstractions/platformUtils.service';
import { TokenService } from '../abstractions/token.service';
import * as fetch from 'node-fetch';
export class NodeApiService extends ApiService {
constructor(tokenService: TokenService, platformUtilsService: PlatformUtilsService,
logoutCallback: Function) {
super(tokenService, platformUtilsService, logoutCallback);
}
}