mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-30 13:03:53 +01:00
more apis for account settings
This commit is contained in:
parent
322dcf76ae
commit
2e486d5a7c
@ -12,6 +12,7 @@ import { FolderRequest } from '../models/request/folderRequest';
|
|||||||
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
|
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
|
||||||
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
||||||
import { PasswordRequest } from '../models/request/passwordRequest';
|
import { PasswordRequest } from '../models/request/passwordRequest';
|
||||||
|
import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest';
|
||||||
import { RegisterRequest } from '../models/request/registerRequest';
|
import { RegisterRequest } from '../models/request/registerRequest';
|
||||||
import { TokenRequest } from '../models/request/tokenRequest';
|
import { TokenRequest } from '../models/request/tokenRequest';
|
||||||
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
|
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
|
||||||
@ -38,6 +39,8 @@ export abstract class ApiService {
|
|||||||
postEmailToken: (request: EmailTokenRequest) => Promise<any>;
|
postEmailToken: (request: EmailTokenRequest) => Promise<any>;
|
||||||
postEmail: (request: EmailRequest) => Promise<any>;
|
postEmail: (request: EmailRequest) => Promise<any>;
|
||||||
postPassword: (request: PasswordRequest) => Promise<any>;
|
postPassword: (request: PasswordRequest) => Promise<any>;
|
||||||
|
postSecurityStamp: (request: PasswordVerificationRequest) => Promise<any>;
|
||||||
|
postDeleteAccount: (request: PasswordVerificationRequest) => Promise<any>;
|
||||||
getAccountRevisionDate: () => Promise<number>;
|
getAccountRevisionDate: () => Promise<number>;
|
||||||
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
|
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
|
||||||
postRegister: (request: RegisterRequest) => Promise<any>;
|
postRegister: (request: RegisterRequest) => Promise<any>;
|
||||||
@ -52,6 +55,7 @@ export abstract class ApiService {
|
|||||||
putShareCipher: (id: string, request: CipherShareRequest) => Promise<any>;
|
putShareCipher: (id: string, request: CipherShareRequest) => Promise<any>;
|
||||||
putShareCiphers: (request: CipherBulkShareRequest) => Promise<any>;
|
putShareCiphers: (request: CipherBulkShareRequest) => Promise<any>;
|
||||||
putCipherCollections: (id: string, request: CipherCollectionsRequest) => Promise<any>;
|
putCipherCollections: (id: string, request: CipherCollectionsRequest) => Promise<any>;
|
||||||
|
postPurgeCiphers: (request: PasswordVerificationRequest) => Promise<any>;
|
||||||
postCipherAttachment: (id: string, data: FormData) => Promise<CipherResponse>;
|
postCipherAttachment: (id: string, data: FormData) => Promise<CipherResponse>;
|
||||||
deleteCipherAttachment: (id: string, attachmentId: string) => Promise<any>;
|
deleteCipherAttachment: (id: string, attachmentId: string) => Promise<any>;
|
||||||
postShareCipherAttachment: (id: string, attachmentId: string, data: FormData,
|
postShareCipherAttachment: (id: string, attachmentId: string, data: FormData,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export class EmailRequest {
|
import { EmailTokenRequest } from './emailTokenRequest';
|
||||||
newEmail: string;
|
|
||||||
masterPasswordHash: string;
|
export class EmailRequest extends EmailTokenRequest {
|
||||||
newMasterPasswordHash: string;
|
newMasterPasswordHash: string;
|
||||||
token: string;
|
token: string;
|
||||||
key: string;
|
key: string;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
export class EmailTokenRequest {
|
import { PasswordVerificationRequest } from './passwordVerificationRequest';
|
||||||
|
|
||||||
|
export class EmailTokenRequest extends PasswordVerificationRequest {
|
||||||
newEmail: string;
|
newEmail: string;
|
||||||
masterPasswordHash: string;
|
masterPasswordHash: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export class PasswordRequest {
|
import { PasswordVerificationRequest } from './passwordVerificationRequest';
|
||||||
masterPasswordHash: string;
|
|
||||||
|
export class PasswordRequest extends PasswordVerificationRequest {
|
||||||
newMasterPasswordHash: string;
|
newMasterPasswordHash: string;
|
||||||
key: string;
|
key: string;
|
||||||
}
|
}
|
||||||
|
3
src/models/request/passwordVerificationRequest.ts
Normal file
3
src/models/request/passwordVerificationRequest.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export class PasswordVerificationRequest {
|
||||||
|
masterPasswordHash: string;
|
||||||
|
}
|
@ -18,6 +18,7 @@ import { FolderRequest } from '../models/request/folderRequest';
|
|||||||
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
|
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
|
||||||
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
||||||
import { PasswordRequest } from '../models/request/passwordRequest';
|
import { PasswordRequest } from '../models/request/passwordRequest';
|
||||||
|
import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest';
|
||||||
import { RegisterRequest } from '../models/request/registerRequest';
|
import { RegisterRequest } from '../models/request/registerRequest';
|
||||||
import { TokenRequest } from '../models/request/tokenRequest';
|
import { TokenRequest } from '../models/request/tokenRequest';
|
||||||
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
|
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
|
||||||
@ -82,8 +83,8 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
|
|
||||||
// Production
|
// Production
|
||||||
if (this.isWebClient) {
|
if (this.isWebClient) {
|
||||||
this.apiBaseUrl = 'https://vault.bitwarden.com/api';
|
this.apiBaseUrl = 'https://api.bitwarden.com';
|
||||||
this.identityBaseUrl = 'https://vault.bitwarden.com/identity';
|
this.identityBaseUrl = 'https://identity.bitwarden.com';
|
||||||
} else {
|
} else {
|
||||||
this.apiBaseUrl = 'https://api.bitwarden.com';
|
this.apiBaseUrl = 'https://api.bitwarden.com';
|
||||||
this.identityBaseUrl = 'https://identity.bitwarden.com';
|
this.identityBaseUrl = 'https://identity.bitwarden.com';
|
||||||
@ -263,6 +264,48 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async postSecurityStamp(request: PasswordVerificationRequest): Promise<any> {
|
||||||
|
const authHeader = await this.handleTokenState();
|
||||||
|
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/security-stamp', {
|
||||||
|
body: JSON.stringify(request),
|
||||||
|
cache: 'no-cache',
|
||||||
|
credentials: this.getCredentials(),
|
||||||
|
headers: new Headers({
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
'Authorization': authHeader,
|
||||||
|
'Device-Type': this.deviceType,
|
||||||
|
}),
|
||||||
|
method: 'POST',
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (response.status !== 200) {
|
||||||
|
const error = await this.handleError(response, false);
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async postDeleteAccount(request: PasswordVerificationRequest): Promise<any> {
|
||||||
|
const authHeader = await this.handleTokenState();
|
||||||
|
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/delete', {
|
||||||
|
body: JSON.stringify(request),
|
||||||
|
cache: 'no-cache',
|
||||||
|
credentials: this.getCredentials(),
|
||||||
|
headers: new Headers({
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
'Authorization': authHeader,
|
||||||
|
'Device-Type': this.deviceType,
|
||||||
|
}),
|
||||||
|
method: 'POST',
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (response.status !== 200) {
|
||||||
|
const error = await this.handleError(response, false);
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getAccountRevisionDate(): Promise<number> {
|
async getAccountRevisionDate(): Promise<number> {
|
||||||
const authHeader = await this.handleTokenState();
|
const authHeader = await this.handleTokenState();
|
||||||
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/revision-date', {
|
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/revision-date', {
|
||||||
@ -560,6 +603,27 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async postPurgeCiphers(request: PasswordVerificationRequest): Promise<any> {
|
||||||
|
const authHeader = await this.handleTokenState();
|
||||||
|
const response = await fetch(new Request(this.apiBaseUrl + '/ciphers/purge', {
|
||||||
|
body: JSON.stringify(request),
|
||||||
|
cache: 'no-cache',
|
||||||
|
credentials: this.getCredentials(),
|
||||||
|
headers: new Headers({
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
'Authorization': authHeader,
|
||||||
|
'Device-Type': this.deviceType,
|
||||||
|
}),
|
||||||
|
method: 'POST',
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (response.status !== 200) {
|
||||||
|
const error = await this.handleError(response, false);
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Attachments APIs
|
// Attachments APIs
|
||||||
|
|
||||||
async postCipherAttachment(id: string, data: FormData): Promise<CipherResponse> {
|
async postCipherAttachment(id: string, data: FormData): Promise<CipherResponse> {
|
||||||
|
Loading…
Reference in New Issue
Block a user