1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-07 11:03:30 +00:00

Split jslib into multiple modules (#363)

* Split jslib into multiple modules
This commit is contained in:
Oscar Hinton
2021-06-03 18:58:57 +02:00
committed by GitHub
parent b1d9b84eae
commit 1016bbfb9e
509 changed files with 8838 additions and 1887 deletions

View File

@@ -0,0 +1,6 @@
export class AttachmentRequest {
fileName: string;
key: string;
fileSize: number;
adminRequest: boolean;
}

View File

@@ -0,0 +1,9 @@
export class BitPayInvoiceRequest {
userId: string;
organizationId: string;
credit: boolean;
amount: number;
returnUrl: string;
name: string;
email: string;
}

View File

@@ -0,0 +1,9 @@
export class CipherBulkDeleteRequest {
ids: string[];
organizationId: string;
constructor(ids: string[], organizationId?: string) {
this.ids = ids == null ? [] : ids;
this.organizationId = organizationId;
}
}

View File

@@ -0,0 +1,9 @@
export class CipherBulkMoveRequest {
ids: string[];
folderId: string;
constructor(ids: string[], folderId: string) {
this.ids = ids == null ? [] : ids;
this.folderId = folderId;
}
}

View File

@@ -0,0 +1,7 @@
export class CipherBulkRestoreRequest {
ids: string[];
constructor(ids: string[]) {
this.ids = ids == null ? [] : ids;
}
}

View File

@@ -0,0 +1,18 @@
import { CipherWithIdRequest } from './cipherWithIdRequest';
import { Cipher } from '../domain/cipher';
export class CipherBulkShareRequest {
ciphers: CipherWithIdRequest[];
collectionIds: string[];
constructor(ciphers: Cipher[], collectionIds: string[]) {
if (ciphers != null) {
this.ciphers = [];
ciphers.forEach(c => {
this.ciphers.push(new CipherWithIdRequest(c));
});
}
this.collectionIds = collectionIds;
}
}

View File

@@ -0,0 +1,7 @@
export class CipherCollectionsRequest {
collectionIds: string[];
constructor(collectionIds: string[]) {
this.collectionIds = collectionIds == null ? [] : collectionIds;
}
}

View File

@@ -0,0 +1,13 @@
import { CipherRequest } from './cipherRequest';
import { Cipher } from '../domain/cipher';
export class CipherCreateRequest {
cipher: CipherRequest;
collectionIds: string[];
constructor(cipher: Cipher) {
this.cipher = new CipherRequest(cipher);
this.collectionIds = cipher.collectionIds;
}
}

View File

@@ -0,0 +1,151 @@
import { CipherRepromptType } from '../../enums/cipherRepromptType';
import { CipherType } from '../../enums/cipherType';
import { Cipher } from '../domain/cipher';
import { CardApi } from '../api/cardApi';
import { FieldApi } from '../api/fieldApi';
import { IdentityApi } from '../api/identityApi';
import { LoginApi } from '../api/loginApi';
import { LoginUriApi } from '../api/loginUriApi';
import { SecureNoteApi } from '../api/secureNoteApi';
import { AttachmentRequest } from './attachmentRequest';
import { PasswordHistoryRequest } from './passwordHistoryRequest';
export class CipherRequest {
type: CipherType;
folderId: string;
organizationId: string;
name: string;
notes: string;
favorite: boolean;
login: LoginApi;
secureNote: SecureNoteApi;
card: CardApi;
identity: IdentityApi;
fields: FieldApi[];
passwordHistory: PasswordHistoryRequest[];
// Deprecated, remove at some point and rename attachments2 to attachments
attachments: { [id: string]: string; };
attachments2: { [id: string]: AttachmentRequest; };
lastKnownRevisionDate: Date;
reprompt: CipherRepromptType;
constructor(cipher: Cipher) {
this.type = cipher.type;
this.folderId = cipher.folderId;
this.organizationId = cipher.organizationId;
this.name = cipher.name ? cipher.name.encryptedString : null;
this.notes = cipher.notes ? cipher.notes.encryptedString : null;
this.favorite = cipher.favorite;
this.lastKnownRevisionDate = cipher.revisionDate;
this.reprompt = cipher.reprompt;
switch (this.type) {
case CipherType.Login:
this.login = new LoginApi();
this.login.uris = null;
this.login.username = cipher.login.username ? cipher.login.username.encryptedString : null;
this.login.password = cipher.login.password ? cipher.login.password.encryptedString : null;
this.login.passwordRevisionDate = cipher.login.passwordRevisionDate != null ?
cipher.login.passwordRevisionDate.toISOString() : null;
this.login.totp = cipher.login.totp ? cipher.login.totp.encryptedString : null;
this.login.autofillOnPageLoad = cipher.login.autofillOnPageLoad;
if (cipher.login.uris != null) {
this.login.uris = cipher.login.uris.map(u => {
const uri = new LoginUriApi();
uri.uri = u.uri != null ? u.uri.encryptedString : null;
uri.match = u.match != null ? u.match : null;
return uri;
});
}
break;
case CipherType.SecureNote:
this.secureNote = new SecureNoteApi();
this.secureNote.type = cipher.secureNote.type;
break;
case CipherType.Card:
this.card = new CardApi();
this.card.cardholderName = cipher.card.cardholderName != null ?
cipher.card.cardholderName.encryptedString : null;
this.card.brand = cipher.card.brand != null ? cipher.card.brand.encryptedString : null;
this.card.number = cipher.card.number != null ? cipher.card.number.encryptedString : null;
this.card.expMonth = cipher.card.expMonth != null ? cipher.card.expMonth.encryptedString : null;
this.card.expYear = cipher.card.expYear != null ? cipher.card.expYear.encryptedString : null;
this.card.code = cipher.card.code != null ? cipher.card.code.encryptedString : null;
break;
case CipherType.Identity:
this.identity = new IdentityApi();
this.identity.title = cipher.identity.title != null ? cipher.identity.title.encryptedString : null;
this.identity.firstName = cipher.identity.firstName != null ?
cipher.identity.firstName.encryptedString : null;
this.identity.middleName = cipher.identity.middleName != null ?
cipher.identity.middleName.encryptedString : null;
this.identity.lastName = cipher.identity.lastName != null ?
cipher.identity.lastName.encryptedString : null;
this.identity.address1 = cipher.identity.address1 != null ?
cipher.identity.address1.encryptedString : null;
this.identity.address2 = cipher.identity.address2 != null ?
cipher.identity.address2.encryptedString : null;
this.identity.address3 = cipher.identity.address3 != null ?
cipher.identity.address3.encryptedString : null;
this.identity.city = cipher.identity.city != null ? cipher.identity.city.encryptedString : null;
this.identity.state = cipher.identity.state != null ? cipher.identity.state.encryptedString : null;
this.identity.postalCode = cipher.identity.postalCode != null ?
cipher.identity.postalCode.encryptedString : null;
this.identity.country = cipher.identity.country != null ?
cipher.identity.country.encryptedString : null;
this.identity.company = cipher.identity.company != null ?
cipher.identity.company.encryptedString : null;
this.identity.email = cipher.identity.email != null ? cipher.identity.email.encryptedString : null;
this.identity.phone = cipher.identity.phone != null ? cipher.identity.phone.encryptedString : null;
this.identity.ssn = cipher.identity.ssn != null ? cipher.identity.ssn.encryptedString : null;
this.identity.username = cipher.identity.username != null ?
cipher.identity.username.encryptedString : null;
this.identity.passportNumber = cipher.identity.passportNumber != null ?
cipher.identity.passportNumber.encryptedString : null;
this.identity.licenseNumber = cipher.identity.licenseNumber != null ?
cipher.identity.licenseNumber.encryptedString : null;
break;
default:
break;
}
if (cipher.fields != null) {
this.fields = cipher.fields.map(f => {
const field = new FieldApi();
field.type = f.type;
field.name = f.name ? f.name.encryptedString : null;
field.value = f.value ? f.value.encryptedString : null;
return field;
});
}
if (cipher.passwordHistory != null) {
this.passwordHistory = [];
cipher.passwordHistory.forEach(ph => {
this.passwordHistory.push({
lastUsedDate: ph.lastUsedDate,
password: ph.password ? ph.password.encryptedString : null,
});
});
}
if (cipher.attachments != null) {
this.attachments = {};
this.attachments2 = {};
cipher.attachments.forEach(attachment => {
const fileName = attachment.fileName ? attachment.fileName.encryptedString : null;
this.attachments[attachment.id] = fileName;
const attachmentRequest = new AttachmentRequest();
attachmentRequest.fileName = fileName;
if (attachment.key != null) {
attachmentRequest.key = attachment.key.encryptedString;
}
this.attachments2[attachment.id] = attachmentRequest;
});
}
}
}

View File

@@ -0,0 +1,13 @@
import { CipherRequest } from './cipherRequest';
import { Cipher } from '../domain/cipher';
export class CipherShareRequest {
cipher: CipherRequest;
collectionIds: string[];
constructor(cipher: Cipher) {
this.cipher = new CipherRequest(cipher);
this.collectionIds = cipher.collectionIds;
}
}

View File

@@ -0,0 +1,12 @@
import { CipherRequest } from './cipherRequest';
import { Cipher } from '../domain/cipher';
export class CipherWithIdRequest extends CipherRequest {
id: string;
constructor(cipher: Cipher) {
super(cipher);
this.id = cipher.id;
}
}

View File

@@ -0,0 +1,17 @@
import { Collection } from '../domain/collection';
import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest';
export class CollectionRequest {
name: string;
externalId: string;
groups: SelectionReadOnlyRequest[] = [];
constructor(collection?: Collection) {
if (collection == null) {
return;
}
this.name = collection.name ? collection.name.encryptedString : null;
this.externalId = collection.externalId;
}
}

View File

@@ -0,0 +1,3 @@
export class DeleteRecoverRequest {
email: string;
}

View File

@@ -0,0 +1,17 @@
import { DeviceType } from '../../enums/deviceType';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
export class DeviceRequest {
type: DeviceType;
name: string;
identifier: string;
pushToken?: string;
constructor(appId: string, platformUtilsService: PlatformUtilsService) {
this.type = platformUtilsService.getDevice();
this.name = platformUtilsService.getDeviceString();
this.identifier = appId;
this.pushToken = null;
}
}

View File

@@ -0,0 +1,7 @@
export class DeviceTokenRequest {
pushToken: string;
constructor() {
this.pushToken = null;
}
}

View File

@@ -0,0 +1,7 @@
import { EmailTokenRequest } from './emailTokenRequest';
export class EmailRequest extends EmailTokenRequest {
newMasterPasswordHash: string;
token: string;
key: string;
}

View File

@@ -0,0 +1,6 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class EmailTokenRequest extends PasswordVerificationRequest {
newEmail: string;
masterPasswordHash: string;
}

View File

@@ -0,0 +1,3 @@
export class EmergencyAccessAcceptRequest {
token: string;
}

View File

@@ -0,0 +1,3 @@
export class EmergencyAccessConfirmRequest {
key: string;
}

View File

@@ -0,0 +1,7 @@
import { EmergencyAccessType } from '../../enums/emergencyAccessType';
export class EmergencyAccessInviteRequest {
email: string;
type: EmergencyAccessType;
waitTimeDays: number;
}

View File

@@ -0,0 +1,4 @@
export class EmergencyAccessPasswordRequest {
newMasterPasswordHash: string;
key: string;
}

View File

@@ -0,0 +1,7 @@
import { EmergencyAccessType } from '../../enums/emergencyAccessType';
export class EmergencyAccessUpdateRequest {
type: EmergencyAccessType;
waitTimeDays: number;
keyEncrypted?: string;
}

View File

@@ -0,0 +1,7 @@
import { EventType } from '../../enums/eventType';
export class EventRequest {
type: EventType;
cipherId: string;
date: string;
}

View File

@@ -0,0 +1,9 @@
import { Folder } from '../domain/folder';
export class FolderRequest {
name: string;
constructor(folder: Folder) {
this.name = folder.name ? folder.name.encryptedString : null;
}
}

View File

@@ -0,0 +1,12 @@
import { FolderRequest } from './folderRequest';
import { Folder } from '../domain/folder';
export class FolderWithIdRequest extends FolderRequest {
id: string;
constructor(folder: Folder) {
super(folder);
this.id = folder.id;
}
}

View File

@@ -0,0 +1,8 @@
import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest';
export class GroupRequest {
name: string;
accessAll: boolean;
externalId: string;
collections: SelectionReadOnlyRequest[] = [];
}

View File

@@ -0,0 +1,5 @@
import { PaymentMethodType } from '../../enums/paymentMethodType';
export class IapCheckRequest {
paymentMethodType: PaymentMethodType;
}

View File

@@ -0,0 +1,9 @@
import { CipherRequest } from './cipherRequest';
import { FolderRequest } from './folderRequest';
import { KvpRequest } from './kvpRequest';
export class ImportCiphersRequest {
ciphers: CipherRequest[] = [];
folders: FolderRequest[] = [];
folderRelationships: KvpRequest<number, number>[] = [];
}

View File

@@ -0,0 +1,9 @@
import { ImportDirectoryRequestGroup } from './importDirectoryRequestGroup';
import { ImportDirectoryRequestUser } from './importDirectoryRequestUser';
export class ImportDirectoryRequest {
groups: ImportDirectoryRequestGroup[] = [];
users: ImportDirectoryRequestUser[] = [];
overwriteExisting = false;
largeImport = false;
}

View File

@@ -0,0 +1,5 @@
export class ImportDirectoryRequestGroup {
name: string;
externalId: string;
users: string[];
}

View File

@@ -0,0 +1,5 @@
export class ImportDirectoryRequestUser {
externalId: string;
email: string;
deleted: boolean;
}

View File

@@ -0,0 +1,9 @@
import { CipherRequest } from './cipherRequest';
import { CollectionRequest } from './collectionRequest';
import { KvpRequest } from './kvpRequest';
export class ImportOrganizationCiphersRequest {
ciphers: CipherRequest[] = [];
collections: CollectionRequest[] = [];
collectionRelationships: KvpRequest<number, number>[] = [];
}

View File

@@ -0,0 +1,8 @@
export { CipherRequest } from './cipherRequest';
export { DeviceRequest } from './deviceRequest';
export { DeviceTokenRequest } from './deviceTokenRequest';
export { FolderRequest } from './folderRequest';
export { PasswordHintRequest } from './passwordHintRequest';
export { RegisterRequest } from './registerRequest';
export { TokenRequest } from './tokenRequest';
export { TwoFactorEmailRequest } from './twoFactorEmailRequest';

View File

@@ -0,0 +1,8 @@
import { PasswordRequest } from './passwordRequest';
import { KdfType } from '../../enums/kdfType';
export class KdfRequest extends PasswordRequest {
kdf: KdfType;
kdfIterations: number;
}

View File

@@ -0,0 +1,9 @@
export class KeysRequest {
publicKey: string;
encryptedPrivateKey: string;
constructor(publicKey: string, encryptedPrivateKey: string) {
this.publicKey = publicKey;
this.encryptedPrivateKey = encryptedPrivateKey;
}
}

View File

@@ -0,0 +1,9 @@
export class KvpRequest<TK, TV> {
key: TK;
value: TV;
constructor(key: TK, value: TV) {
this.key = key;
this.value = value;
}
}

View File

@@ -0,0 +1,26 @@
import { PaymentMethodType } from '../../enums/paymentMethodType';
import { PlanType } from '../../enums/planType';
import { OrganizationKeysRequest } from './organizationKeysRequest';
export class OrganizationCreateRequest {
name: string;
businessName: string;
billingEmail: string;
planType: PlanType;
key: string;
keys: OrganizationKeysRequest;
paymentMethodType: PaymentMethodType;
paymentToken: string;
additionalSeats: number;
additionalStorageGb: number;
premiumAccessAddon: boolean;
collectionName: string;
taxIdNumber: string;
billingAddressLine1: string;
billingAddressLine2: string;
billingAddressCity: string;
billingAddressState: string;
billingAddressPostalCode: string;
billingAddressCountry: string;
}

View File

@@ -0,0 +1,19 @@
import { ImportDirectoryRequestGroup } from './importDirectoryRequestGroup';
export class OrganizationImportGroupRequest {
name: string;
externalId: string;
memberExternalIds: string[];
constructor(model: Required<OrganizationImportGroupRequest> | ImportDirectoryRequestGroup) {
this.name = model.name;
this.externalId = model.externalId;
if (model instanceof ImportDirectoryRequestGroup) {
this.memberExternalIds = model.users;
}
else {
this.memberExternalIds = model.memberExternalIds;
}
}
}

View File

@@ -0,0 +1,13 @@
import { ImportDirectoryRequestUser } from './importDirectoryRequestUser';
export class OrganizationImportMemberRequest {
email: string;
externalId: string;
deleted: boolean;
constructor(model: Required<OrganizationImportMemberRequest> | ImportDirectoryRequestUser) {
this.email = model.email;
this.externalId = model.externalId;
this.deleted = model.deleted;
}
}

View File

@@ -0,0 +1,25 @@
import { ImportDirectoryRequest } from './importDirectoryRequest';
import { OrganizationImportGroupRequest } from './organizationImportGroupRequest';
import { OrganizationImportMemberRequest } from './organizationImportMemberRequest';
export class OrganizationImportRequest {
groups: OrganizationImportGroupRequest[] = [];
members: OrganizationImportMemberRequest[] = [];
overwriteExisting: boolean = false;
largeImport: boolean = false;
constructor(model: {
groups: Required<OrganizationImportGroupRequest>[],
users: Required<OrganizationImportMemberRequest>[], overwriteExisting: boolean, largeImport: boolean;
} | ImportDirectoryRequest) {
if (model instanceof ImportDirectoryRequest) {
this.groups = model.groups.map(g => new OrganizationImportGroupRequest(g));
this.members = model.users.map(u => new OrganizationImportMemberRequest(u));
} else {
this.groups = model.groups.map(g => new OrganizationImportGroupRequest(g));
this.members = model.users.map(u => new OrganizationImportMemberRequest(u));
}
this.overwriteExisting = model.overwriteExisting;
this.largeImport = model.largeImport;
}
}

View File

@@ -0,0 +1,7 @@
import { KeysRequest } from './keysRequest';
export class OrganizationKeysRequest extends KeysRequest {
constructor(publicKey: string, encryptedPrivateKey: string) {
super(publicKey, encryptedPrivateKey);
}
}

View File

@@ -0,0 +1,9 @@
import { TaxInfoUpdateRequest } from './taxInfoUpdateRequest';
export class OrganizationTaxInfoUpdateRequest extends TaxInfoUpdateRequest {
taxId: string;
line1: string;
line2: string;
city: string;
state: string;
}

View File

@@ -0,0 +1,9 @@
import { OrganizationKeysRequest } from './organizationKeysRequest';
export class OrganizationUpdateRequest {
name: string;
identifier: string;
businessName: string;
billingEmail: string;
keys: OrganizationKeysRequest;
}

View File

@@ -0,0 +1,14 @@
import { PlanType } from '../../enums/planType';
import { OrganizationKeysRequest } from './organizationKeysRequest';
export class OrganizationUpgradeRequest {
businessName: string;
planType: PlanType;
additionalSeats: number;
additionalStorageGb: number;
premiumAccessAddon: boolean;
billingAddressCountry: string;
billingAddressPostalCode: string;
keys: OrganizationKeysRequest;
}

View File

@@ -0,0 +1,3 @@
export class OrganizationUserAcceptRequest {
token: string;
}

View File

@@ -0,0 +1,12 @@
type OrganizationUserBulkRequestEntry = {
id: string;
key: string;
};
export class OrganizationUserBulkConfirmRequest {
keys: OrganizationUserBulkRequestEntry[];
constructor(keys: OrganizationUserBulkRequestEntry[]) {
this.keys = keys;
}
}

View File

@@ -0,0 +1,7 @@
export class OrganizationUserBulkRequest {
ids: string[];
constructor(ids: string[]) {
this.ids = ids == null ? [] : ids;
}
}

View File

@@ -0,0 +1,3 @@
export class OrganizationUserConfirmRequest {
key: string;
}

View File

@@ -0,0 +1,12 @@
import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest';
import { OrganizationUserType } from '../../enums/organizationUserType';
import { PermissionsApi } from '../api/permissionsApi';
export class OrganizationUserInviteRequest {
emails: string[] = [];
type: OrganizationUserType;
accessAll: boolean;
collections: SelectionReadOnlyRequest[] = [];
permissions: PermissionsApi;
}

View File

@@ -0,0 +1,3 @@
export class OrganizationUserResetPasswordEnrollmentRequest {
resetPasswordKey: string;
}

View File

@@ -0,0 +1,4 @@
export class OrganizationUserResetPasswordRequest {
newMasterPasswordHash: string;
key: string;
}

View File

@@ -0,0 +1,3 @@
export class OrganizationUserUpdateGroupsRequest {
groupIds: string[] = [];
}

View File

@@ -0,0 +1,11 @@
import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest';
import { OrganizationUserType } from '../../enums/organizationUserType';
import { PermissionsApi } from '../api/permissionsApi';
export class OrganizationUserUpdateRequest {
type: OrganizationUserType;
accessAll: boolean;
collections: SelectionReadOnlyRequest[] = [];
permissions: PermissionsApi;
}

View File

@@ -0,0 +1,7 @@
export class PasswordHintRequest {
email: string;
constructor(email: string) {
this.email = email;
}
}

View File

@@ -0,0 +1,4 @@
export class PasswordHistoryRequest {
password: string;
lastUsedDate: Date;
}

View File

@@ -0,0 +1,6 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class PasswordRequest extends PasswordVerificationRequest {
newMasterPasswordHash: string;
key: string;
}

View File

@@ -0,0 +1,3 @@
export class PasswordVerificationRequest {
masterPasswordHash: string;
}

View File

@@ -0,0 +1,7 @@
import { PaymentMethodType } from '../../enums/paymentMethodType';
import { OrganizationTaxInfoUpdateRequest } from '../request/organizationTaxInfoUpdateRequest';
export class PaymentRequest extends OrganizationTaxInfoUpdateRequest {
paymentMethodType: PaymentMethodType;
paymentToken: string;
}

View File

@@ -0,0 +1,7 @@
import { PolicyType } from '../../enums/policyType';
export class PolicyRequest {
type: PolicyType;
enabled: boolean;
data: any;
}

View File

@@ -0,0 +1,7 @@
export class PreloginRequest {
email: string;
constructor(email: string) {
this.email = email;
}
}

View File

@@ -0,0 +1,5 @@
export class ReferenceEventRequest {
id: string;
layout: string;
flow: string;
}

View File

@@ -0,0 +1,30 @@
import { KeysRequest } from './keysRequest';
import { ReferenceEventRequest } from './referenceEventRequest';
import { KdfType } from '../../enums/kdfType';
export class RegisterRequest {
name: string;
email: string;
masterPasswordHash: string;
masterPasswordHint: string;
key: string;
keys: KeysRequest;
token: string;
organizationUserId: string;
kdf: KdfType;
kdfIterations: number;
referenceData: ReferenceEventRequest;
constructor(email: string, name: string, masterPasswordHash: string, masterPasswordHint: string, key: string,
kdf: KdfType, kdfIterations: number, referenceData: ReferenceEventRequest) {
this.name = name;
this.email = email;
this.masterPasswordHash = masterPasswordHash;
this.masterPasswordHint = masterPasswordHint ? masterPasswordHint : null;
this.key = key;
this.kdf = kdf;
this.kdfIterations = kdfIterations;
this.referenceData = referenceData;
}
}

View File

@@ -0,0 +1,3 @@
export class SeatRequest {
seatAdjustment: number;
}

View File

@@ -0,0 +1,11 @@
export class SelectionReadOnlyRequest {
id: string;
readOnly: boolean;
hidePasswords: boolean;
constructor(id: string, readOnly: boolean, hidePasswords: boolean) {
this.id = id;
this.readOnly = readOnly;
this.hidePasswords = hidePasswords;
}
}

View File

@@ -0,0 +1,3 @@
export class SendAccessRequest {
password: string;
}

View File

@@ -0,0 +1,50 @@
import { SendType } from '../../enums/sendType';
import { SendFileApi } from '../api/sendFileApi';
import { SendTextApi } from '../api/sendTextApi';
import { Send } from '../domain/send';
export class SendRequest {
type: SendType;
fileLength?: number;
name: string;
notes: string;
key: string;
maxAccessCount?: number;
expirationDate: string;
deletionDate: string;
text: SendTextApi;
file: SendFileApi;
password: string;
disabled: boolean;
hideEmail: boolean;
constructor(send: Send, fileLength?: number) {
this.type = send.type;
this.fileLength = fileLength;
this.name = send.name ? send.name.encryptedString : null;
this.notes = send.notes ? send.notes.encryptedString : null;
this.maxAccessCount = send.maxAccessCount;
this.expirationDate = send.expirationDate != null ? send.expirationDate.toISOString() : null;
this.deletionDate = send.deletionDate != null ? send.deletionDate.toISOString() : null;
this.key = send.key != null ? send.key.encryptedString : null;
this.password = send.password;
this.disabled = send.disabled;
this.hideEmail = send.hideEmail;
switch (this.type) {
case SendType.Text:
this.text = new SendTextApi();
this.text.text = send.text.text != null ? send.text.text.encryptedString : null;
this.text.hidden = send.text.hidden;
break;
case SendType.File:
this.file = new SendFileApi();
this.file.fileName = send.file.fileName != null ? send.file.fileName.encryptedString : null;
break;
default:
break;
}
}
}

View File

@@ -0,0 +1,13 @@
import { KeysRequest } from './keysRequest';
import { KdfType } from '../../enums/kdfType';
export class SetPasswordRequest {
masterPasswordHash: string;
key: string;
masterPasswordHint: string;
keys: KeysRequest;
kdf: KdfType;
kdfIterations: number;
orgIdentifier: string;
}

View File

@@ -0,0 +1,3 @@
export class StorageRequest {
storageGbAdjustment: number;
}

View File

@@ -0,0 +1,4 @@
export class TaxInfoUpdateRequest {
country: string;
postalCode: string;
}

View File

@@ -0,0 +1,82 @@
import { TwoFactorProviderType } from '../../enums/twoFactorProviderType';
import { DeviceRequest } from './deviceRequest';
export class TokenRequest {
email: string;
masterPasswordHash: string;
code: string;
codeVerifier: string;
redirectUri: string;
clientId: string;
clientSecret: string;
token: string;
provider: TwoFactorProviderType;
remember: boolean;
device?: DeviceRequest;
constructor(credentials: string[], codes: string[], clientIdClientSecret: string[], provider: TwoFactorProviderType,
token: string, remember: boolean, device?: DeviceRequest) {
if (credentials != null && credentials.length > 1) {
this.email = credentials[0];
this.masterPasswordHash = credentials[1];
} else if (codes != null && codes.length > 2) {
this.code = codes[0];
this.codeVerifier = codes[1];
this.redirectUri = codes[2];
} else if (clientIdClientSecret != null && clientIdClientSecret.length > 1) {
this.clientId = clientIdClientSecret[0];
this.clientSecret = clientIdClientSecret[1];
}
this.token = token;
this.provider = provider;
this.remember = remember;
this.device = device != null ? device : null;
}
toIdentityToken(clientId: string) {
const obj: any = {
scope: 'api offline_access',
client_id: clientId,
};
if (this.clientSecret != null) {
obj.scope = clientId.startsWith('organization') ? 'api.organization' : 'api';
obj.grant_type = 'client_credentials';
obj.client_secret = this.clientSecret;
} else if (this.masterPasswordHash != null && this.email != null) {
obj.grant_type = 'password';
obj.username = this.email;
obj.password = this.masterPasswordHash;
} else if (this.code != null && this.codeVerifier != null && this.redirectUri != null) {
obj.grant_type = 'authorization_code';
obj.code = this.code;
obj.code_verifier = this.codeVerifier;
obj.redirect_uri = this.redirectUri;
} else {
throw new Error('must provide credentials or codes');
}
if (this.device) {
obj.deviceType = this.device.type;
obj.deviceIdentifier = this.device.identifier;
obj.deviceName = this.device.name;
// no push tokens for browser apps yet
// obj.devicePushToken = this.device.pushToken;
}
if (this.token && this.provider != null) {
obj.twoFactorToken = this.token;
obj.twoFactorProvider = this.provider;
obj.twoFactorRemember = this.remember ? '1' : '0';
}
return obj;
}
alterIdentityTokenHeaders(headers: Headers) {
if (this.clientSecret == null && this.masterPasswordHash != null && this.email != null) {
headers.set('Auth-Email', this.email);
}
}
}

View File

@@ -0,0 +1,11 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class TwoFactorEmailRequest extends PasswordVerificationRequest {
email: string;
constructor(email: string, masterPasswordHash: string) {
super();
this.masterPasswordHash = masterPasswordHash;
this.email = email;
}
}

View File

@@ -0,0 +1,7 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
import { TwoFactorProviderType } from '../../enums/twoFactorProviderType';
export class TwoFactorProviderRequest extends PasswordVerificationRequest {
type: TwoFactorProviderType;
}

View File

@@ -0,0 +1,6 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class TwoFactorRecoveryRequest extends PasswordVerificationRequest {
recoveryCode: string;
email: string;
}

View File

@@ -0,0 +1,4 @@
export class UpdateDomainsRequest {
equivalentDomains: string[][];
excludedGlobalEquivalentDomains: number[];
}

View File

@@ -0,0 +1,10 @@
import { CipherWithIdRequest } from './cipherWithIdRequest';
import { FolderWithIdRequest } from './folderWithIdRequest';
export class UpdateKeyRequest {
ciphers: CipherWithIdRequest[] = [];
folders: FolderWithIdRequest[] = [];
masterPasswordHash: string;
privateKey: string;
key: string;
}

View File

@@ -0,0 +1,10 @@
export class UpdateProfileRequest {
name: string;
masterPasswordHint: string;
culture = 'en-US'; // deprecated
constructor(name: string, masterPasswordHint: string) {
this.name = name;
this.masterPasswordHint = masterPasswordHint ? masterPasswordHint : null;
}
}

View File

@@ -0,0 +1,6 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class UpdateTwoFactorAuthenticatorRequest extends PasswordVerificationRequest {
token: string;
key: string;
}

View File

@@ -0,0 +1,7 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class UpdateTwoFactorDuoRequest extends PasswordVerificationRequest {
integrationKey: string;
secretKey: string;
host: string;
}

View File

@@ -0,0 +1,6 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class UpdateTwoFactorEmailRequest extends PasswordVerificationRequest {
token: string;
email: string;
}

View File

@@ -0,0 +1,5 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class UpdateTwoFactorWebAuthnDeleteRequest extends PasswordVerificationRequest {
id: number;
}

View File

@@ -0,0 +1,7 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class UpdateTwoFactorWebAuthnRequest extends PasswordVerificationRequest {
deviceResponse: PublicKeyCredential;
name: string;
id: number;
}

View File

@@ -0,0 +1,10 @@
import { PasswordVerificationRequest } from './passwordVerificationRequest';
export class UpdateTwoFactorYubioOtpRequest extends PasswordVerificationRequest {
key1: string;
key2: string;
key3: string;
key4: string;
key5: string;
nfc: boolean;
}

View File

@@ -0,0 +1,4 @@
export class VerifyBankRequest {
amount1: number;
amount2: number;
}

View File

@@ -0,0 +1,9 @@
export class VerifyDeleteRecoverRequest {
userId: string;
token: string;
constructor(userId: string, token: string) {
this.userId = userId;
this.token = token;
}
}

View File

@@ -0,0 +1,9 @@
export class VerifyEmailRequest {
userId: string;
token: string;
constructor(userId: string, token: string) {
this.userId = userId;
this.token = token;
}
}