mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-13 01:58:44 +02:00
platform specific identity client id
This commit is contained in:
parent
e27df6bc09
commit
0b57d8b7f3
@ -1,6 +1,7 @@
|
|||||||
import { DeviceType } from '../enums/deviceType';
|
import { DeviceType } from '../enums/deviceType';
|
||||||
|
|
||||||
export abstract class PlatformUtilsService {
|
export abstract class PlatformUtilsService {
|
||||||
|
identityClientId: string;
|
||||||
getDevice: () => DeviceType;
|
getDevice: () => DeviceType;
|
||||||
getDeviceString: () => string;
|
getDeviceString: () => string;
|
||||||
isFirefox: () => boolean;
|
isFirefox: () => boolean;
|
||||||
|
@ -18,13 +18,13 @@ export class TokenRequest {
|
|||||||
this.device = device != null ? device : null;
|
this.device = device != null ? device : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
toIdentityToken() {
|
toIdentityToken(clientId: string) {
|
||||||
const obj: any = {
|
const obj: any = {
|
||||||
grant_type: 'password',
|
grant_type: 'password',
|
||||||
username: this.email,
|
username: this.email,
|
||||||
password: this.masterPasswordHash,
|
password: this.masterPasswordHash,
|
||||||
scope: 'api offline_access',
|
scope: 'api offline_access',
|
||||||
client_id: 'browser',
|
client_id: clientId,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.device) {
|
if (this.device) {
|
||||||
|
@ -27,7 +27,7 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
deviceType: string;
|
deviceType: string;
|
||||||
logoutCallback: Function;
|
logoutCallback: Function;
|
||||||
|
|
||||||
constructor(private tokenService: TokenService, platformUtilsService: PlatformUtilsService,
|
constructor(private tokenService: TokenService, private platformUtilsService: PlatformUtilsService,
|
||||||
logoutCallback: Function) {
|
logoutCallback: Function) {
|
||||||
this.logoutCallback = logoutCallback;
|
this.logoutCallback = logoutCallback;
|
||||||
this.deviceType = platformUtilsService.getDevice().toString();
|
this.deviceType = platformUtilsService.getDevice().toString();
|
||||||
@ -75,7 +75,7 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
|
|
||||||
async postIdentityToken(request: TokenRequest): Promise<IdentityTokenResponse | IdentityTwoFactorResponse> {
|
async postIdentityToken(request: TokenRequest): Promise<IdentityTokenResponse | IdentityTwoFactorResponse> {
|
||||||
const response = await fetch(new Request(this.identityBaseUrl + '/connect/token', {
|
const response = await fetch(new Request(this.identityBaseUrl + '/connect/token', {
|
||||||
body: this.qsStringify(request.toIdentityToken()),
|
body: this.qsStringify(request.toIdentityToken(this.platformUtilsService.identityClientId)),
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
|
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
|
||||||
|
Loading…
Reference in New Issue
Block a user