1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-05 18:13:26 +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,10 @@
import { BaseResponse } from './baseResponse';
export class ApiKeyResponse extends BaseResponse {
apiKey: string;
constructor(response: any) {
super(response);
this.apiKey = this.getResponseProperty('ApiKey');
}
}

View File

@@ -0,0 +1,20 @@
import { BaseResponse } from './baseResponse';
export class AttachmentResponse extends BaseResponse {
id: string;
url: string;
fileName: string;
key: string;
size: string;
sizeName: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.url = this.getResponseProperty('Url');
this.fileName = this.getResponseProperty('FileName');
this.key = this.getResponseProperty('Key');
this.size = this.getResponseProperty('Size');
this.sizeName = this.getResponseProperty('SizeName');
}
}

View File

@@ -0,0 +1,22 @@
import { FileUploadType } from '../../enums/fileUploadType';
import { BaseResponse } from './baseResponse';
import { CipherResponse } from './cipherResponse';
export class AttachmentUploadDataResponse extends BaseResponse {
attachmentId: string;
fileUploadType: FileUploadType;
cipherResponse: CipherResponse;
cipherMiniResponse: CipherResponse;
url: string = null;
constructor(response: any) {
super(response);
this.attachmentId = this.getResponseProperty('AttachmentId');
this.fileUploadType = this.getResponseProperty('FileUploadType');
const cipherResponse = this.getResponseProperty('CipherResponse');
const cipherMiniResponse = this.getResponseProperty('CipherMiniResponse');
this.cipherResponse = cipherResponse == null ? null : new CipherResponse(cipherResponse);
this.cipherMiniResponse = cipherMiniResponse == null ? null : new CipherResponse(cipherMiniResponse);
this.url = this.getResponseProperty('Url');
}
}

View File

@@ -0,0 +1,39 @@
export abstract class BaseResponse {
private response: any;
constructor(response: any) {
this.response = response;
}
protected getResponseProperty(propertyName: string, response: any = null, exactName = false): any {
if (propertyName == null || propertyName === '') {
throw new Error('propertyName must not be null/empty.');
}
if (response == null && this.response != null) {
response = this.response;
}
if (response == null) {
return null;
}
if (!exactName && response[propertyName] === undefined) {
let otherCasePropertyName: string = null;
if (propertyName.charAt(0) === propertyName.charAt(0).toUpperCase()) {
otherCasePropertyName = propertyName.charAt(0).toLowerCase();
} else {
otherCasePropertyName = propertyName.charAt(0).toUpperCase();
}
if (propertyName.length > 1) {
otherCasePropertyName += propertyName.slice(1);
}
propertyName = otherCasePropertyName;
if (response[propertyName] === undefined) {
propertyName = propertyName.toLowerCase();
}
if (response[propertyName] === undefined) {
propertyName = propertyName.toUpperCase();
}
}
return response[propertyName];
}
}

View File

@@ -0,0 +1,83 @@
import { BaseResponse } from './baseResponse';
import { PaymentMethodType } from '../../enums/paymentMethodType';
import { TransactionType } from '../../enums/transactionType';
export class BillingResponse extends BaseResponse {
balance: number;
paymentSource: BillingSourceResponse;
invoices: BillingInvoiceResponse[] = [];
transactions: BillingTransactionResponse[] = [];
constructor(response: any) {
super(response);
this.balance = this.getResponseProperty('Balance');
const paymentSource = this.getResponseProperty('PaymentSource');
const transactions = this.getResponseProperty('Transactions');
const invoices = this.getResponseProperty('Invoices');
this.paymentSource = paymentSource == null ? null : new BillingSourceResponse(paymentSource);
if (transactions != null) {
this.transactions = transactions.map((t: any) => new BillingTransactionResponse(t));
}
if (invoices != null) {
this.invoices = invoices.map((i: any) => new BillingInvoiceResponse(i));
}
}
}
export class BillingSourceResponse extends BaseResponse {
type: PaymentMethodType;
cardBrand: string;
description: string;
needsVerification: boolean;
constructor(response: any) {
super(response);
this.type = this.getResponseProperty('Type');
this.cardBrand = this.getResponseProperty('CardBrand');
this.description = this.getResponseProperty('Description');
this.needsVerification = this.getResponseProperty('NeedsVerification');
}
}
export class BillingInvoiceResponse extends BaseResponse {
url: string;
pdfUrl: string;
number: string;
paid: boolean;
date: string;
amount: number;
constructor(response: any) {
super(response);
this.url = this.getResponseProperty('Url');
this.pdfUrl = this.getResponseProperty('PdfUrl');
this.number = this.getResponseProperty('Number');
this.paid = this.getResponseProperty('Paid');
this.date = this.getResponseProperty('Date');
this.amount = this.getResponseProperty('Amount');
}
}
export class BillingTransactionResponse extends BaseResponse {
createdDate: string;
amount: number;
refunded: boolean;
partiallyRefunded: boolean;
refundedAmount: number;
type: TransactionType;
paymentMethodType: PaymentMethodType;
details: string;
constructor(response: any) {
super(response);
this.createdDate = this.getResponseProperty('CreatedDate');
this.amount = this.getResponseProperty('Amount');
this.refunded = this.getResponseProperty('Refunded');
this.partiallyRefunded = this.getResponseProperty('PartiallyRefunded');
this.refundedAmount = this.getResponseProperty('RefundedAmount');
this.type = this.getResponseProperty('Type');
this.paymentMethodType = this.getResponseProperty('PaymentMethodType');
this.details = this.getResponseProperty('Details');
}
}

View File

@@ -0,0 +1,32 @@
import { BaseResponse } from './baseResponse';
export class BreachAccountResponse extends BaseResponse {
addedDate: string;
breachDate: string;
dataClasses: string[];
description: string;
domain: string;
isActive: boolean;
isVerified: boolean;
logoPath: string;
modifiedDate: string;
name: string;
pwnCount: number;
title: string;
constructor(response: any) {
super(response);
this.addedDate = this.getResponseProperty('AddedDate');
this.breachDate = this.getResponseProperty('BreachDate');
this.dataClasses = this.getResponseProperty('DataClasses');
this.description = this.getResponseProperty('Description');
this.domain = this.getResponseProperty('Domain');
this.isActive = this.getResponseProperty('IsActive');
this.isVerified = this.getResponseProperty('IsVerified');
this.logoPath = this.getResponseProperty('LogoPath');
this.modifiedDate = this.getResponseProperty('ModifiedDate');
this.name = this.getResponseProperty('Name');
this.pwnCount = this.getResponseProperty('PwnCount');
this.title = this.getResponseProperty('Title');
}
}

View File

@@ -0,0 +1,92 @@
import { AttachmentResponse } from './attachmentResponse';
import { BaseResponse } from './baseResponse';
import { PasswordHistoryResponse } from './passwordHistoryResponse';
import { CipherRepromptType } from '../../enums/cipherRepromptType';
import { CardApi } from '../api/cardApi';
import { FieldApi } from '../api/fieldApi';
import { IdentityApi } from '../api/identityApi';
import { LoginApi } from '../api/loginApi';
import { SecureNoteApi } from '../api/secureNoteApi';
export class CipherResponse extends BaseResponse {
id: string;
organizationId: string;
folderId: string;
type: number;
name: string;
notes: string;
fields: FieldApi[];
login: LoginApi;
card: CardApi;
identity: IdentityApi;
secureNote: SecureNoteApi;
favorite: boolean;
edit: boolean;
viewPassword: boolean;
organizationUseTotp: boolean;
revisionDate: string;
attachments: AttachmentResponse[];
passwordHistory: PasswordHistoryResponse[];
collectionIds: string[];
deletedDate: string;
reprompt: CipherRepromptType;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.organizationId = this.getResponseProperty('OrganizationId');
this.folderId = this.getResponseProperty('FolderId') || null;
this.type = this.getResponseProperty('Type');
this.name = this.getResponseProperty('Name');
this.notes = this.getResponseProperty('Notes');
this.favorite = this.getResponseProperty('Favorite') || false;
this.edit = !!this.getResponseProperty('Edit');
if (this.getResponseProperty('ViewPassword') == null) {
this.viewPassword = true;
} else {
this.viewPassword = this.getResponseProperty('ViewPassword');
}
this.organizationUseTotp = this.getResponseProperty('OrganizationUseTotp');
this.revisionDate = this.getResponseProperty('RevisionDate');
this.collectionIds = this.getResponseProperty('CollectionIds');
this.deletedDate = this.getResponseProperty('DeletedDate');
const login = this.getResponseProperty('Login');
if (login != null) {
this.login = new LoginApi(login);
}
const card = this.getResponseProperty('Card');
if (card != null) {
this.card = new CardApi(card);
}
const identity = this.getResponseProperty('Identity');
if (identity != null) {
this.identity = new IdentityApi(identity);
}
const secureNote = this.getResponseProperty('SecureNote');
if (secureNote != null) {
this.secureNote = new SecureNoteApi(secureNote);
}
const fields = this.getResponseProperty('Fields');
if (fields != null) {
this.fields = fields.map((f: any) => new FieldApi(f));
}
const attachments = this.getResponseProperty('Attachments');
if (attachments != null) {
this.attachments = attachments.map((a: any) => new AttachmentResponse(a));
}
const passwordHistory = this.getResponseProperty('PasswordHistory');
if (passwordHistory != null) {
this.passwordHistory = passwordHistory.map((h: any) => new PasswordHistoryResponse(h));
}
this.reprompt = this.getResponseProperty('Reprompt') || CipherRepromptType.None;
}
}

View File

@@ -0,0 +1,38 @@
import { BaseResponse } from './baseResponse';
import { SelectionReadOnlyResponse } from './selectionReadOnlyResponse';
export class CollectionResponse extends BaseResponse {
id: string;
organizationId: string;
name: string;
externalId: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.organizationId = this.getResponseProperty('OrganizationId');
this.name = this.getResponseProperty('Name');
this.externalId = this.getResponseProperty('ExternalId');
}
}
export class CollectionDetailsResponse extends CollectionResponse {
readOnly: boolean;
constructor(response: any) {
super(response);
this.readOnly = this.getResponseProperty('ReadOnly') || false;
}
}
export class CollectionGroupDetailsResponse extends CollectionResponse {
groups: SelectionReadOnlyResponse[] = [];
constructor(response: any) {
super(response);
const groups = this.getResponseProperty('Groups');
if (groups != null) {
this.groups = groups.map((g: any) => new SelectionReadOnlyResponse(g));
}
}
}

View File

@@ -0,0 +1,20 @@
import { BaseResponse } from './baseResponse';
import { DeviceType } from '../../enums/deviceType';
export class DeviceResponse extends BaseResponse {
id: string;
name: number;
identifier: string;
type: DeviceType;
creationDate: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.name = this.getResponseProperty('Name');
this.identifier = this.getResponseProperty('Identifier');
this.type = this.getResponseProperty('Type');
this.creationDate = this.getResponseProperty('CreationDate');
}
}

View File

@@ -0,0 +1,18 @@
import { BaseResponse } from './baseResponse';
import { GlobalDomainResponse } from './globalDomainResponse';
export class DomainsResponse extends BaseResponse {
equivalentDomains: string[][];
globalEquivalentDomains: GlobalDomainResponse[] = [];
constructor(response: any) {
super(response);
this.equivalentDomains = this.getResponseProperty('EquivalentDomains');
const globalEquivalentDomains = this.getResponseProperty('GlobalEquivalentDomains');
if (globalEquivalentDomains != null) {
this.globalEquivalentDomains = globalEquivalentDomains.map((d: any) => new GlobalDomainResponse(d));
} else {
this.globalEquivalentDomains = [];
}
}
}

View File

@@ -0,0 +1,81 @@
import { EmergencyAccessStatusType } from '../../enums/emergencyAccessStatusType';
import { EmergencyAccessType } from '../../enums/emergencyAccessType';
import { KdfType } from '../../enums/kdfType';
import { BaseResponse } from './baseResponse';
import { CipherResponse } from './cipherResponse';
export class EmergencyAccessGranteeDetailsResponse extends BaseResponse {
id: string;
granteeId: string;
name: string;
email: string;
type: EmergencyAccessType;
status: EmergencyAccessStatusType;
waitTimeDays: number;
creationDate: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.granteeId = this.getResponseProperty('GranteeId');
this.name = this.getResponseProperty('Name');
this.email = this.getResponseProperty('Email');
this.type = this.getResponseProperty('Type');
this.status = this.getResponseProperty('Status');
this.waitTimeDays = this.getResponseProperty('WaitTimeDays');
this.creationDate = this.getResponseProperty('CreationDate');
}
}
export class EmergencyAccessGrantorDetailsResponse extends BaseResponse {
id: string;
grantorId: string;
name: string;
email: string;
type: EmergencyAccessType;
status: EmergencyAccessStatusType;
waitTimeDays: number;
creationDate: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.grantorId = this.getResponseProperty('GrantorId');
this.name = this.getResponseProperty('Name');
this.email = this.getResponseProperty('Email');
this.type = this.getResponseProperty('Type');
this.status = this.getResponseProperty('Status');
this.waitTimeDays = this.getResponseProperty('WaitTimeDays');
this.creationDate = this.getResponseProperty('CreationDate');
}
}
export class EmergencyAccessTakeoverResponse extends BaseResponse {
keyEncrypted: string;
kdf: KdfType;
kdfIterations: number;
constructor(response: any) {
super(response);
this.keyEncrypted = this.getResponseProperty('KeyEncrypted');
this.kdf = this.getResponseProperty('Kdf');
this.kdfIterations = this.getResponseProperty('KdfIterations');
}
}
export class EmergencyAccessViewResponse extends BaseResponse {
keyEncrypted: string;
ciphers: CipherResponse[] = [];
constructor(response: any) {
super(response);
this.keyEncrypted = this.getResponseProperty('KeyEncrypted');
const ciphers = this.getResponseProperty('Ciphers');
if (ciphers != null) {
this.ciphers = ciphers.map((c: any) => new CipherResponse(c));
}
}
}

View File

@@ -0,0 +1,66 @@
import { BaseResponse } from './baseResponse';
export class ErrorResponse extends BaseResponse {
message: string;
validationErrors: { [key: string]: string[]; };
statusCode: number;
constructor(response: any, status: number, identityResponse?: boolean) {
super(response);
let errorModel = null;
if (response != null) {
const responseErrorModel = this.getResponseProperty('ErrorModel');
if (responseErrorModel && identityResponse) {
errorModel = responseErrorModel;
} else {
errorModel = response;
}
}
if (errorModel) {
this.message = this.getResponseProperty('Message', errorModel);
this.validationErrors = this.getResponseProperty('ValidationErrors', errorModel);
} else {
if (status === 429) {
this.message = 'Rate limit exceeded. Try again later.';
}
}
this.statusCode = status;
}
getSingleMessage(): string {
if (this.validationErrors == null) {
return this.message;
}
for (const key in this.validationErrors) {
if (!this.validationErrors.hasOwnProperty(key)) {
continue;
}
if (this.validationErrors[key].length) {
return this.validationErrors[key][0];
}
}
return this.message;
}
getAllMessages(): string[] {
const messages: string[] = [];
if (this.validationErrors == null) {
return messages;
}
for (const key in this.validationErrors) {
if (!this.validationErrors.hasOwnProperty(key)) {
continue;
}
this.validationErrors[key].forEach((item: string) => {
let prefix = '';
if (key.indexOf('[') > -1 && key.indexOf(']') > -1) {
const lastSep = key.lastIndexOf('.');
prefix = key.substr(0, lastSep > -1 ? lastSep : key.length) + ': ';
}
messages.push(prefix + item);
});
}
return messages;
}
}

View File

@@ -0,0 +1,35 @@
import { BaseResponse } from './baseResponse';
import { DeviceType } from '../../enums/deviceType';
import { EventType } from '../../enums/eventType';
export class EventResponse extends BaseResponse {
type: EventType;
userId: string;
organizationId: string;
cipherId: string;
collectionId: string;
groupId: string;
policyId: string;
organizationUserId: string;
actingUserId: string;
date: string;
deviceType: DeviceType;
ipAddress: string;
constructor(response: any) {
super(response);
this.type = this.getResponseProperty('Type');
this.userId = this.getResponseProperty('UserId');
this.organizationId = this.getResponseProperty('OrganizationId');
this.cipherId = this.getResponseProperty('CipherId');
this.collectionId = this.getResponseProperty('CollectionId');
this.groupId = this.getResponseProperty('GroupId');
this.policyId = this.getResponseProperty('PolicyId');
this.organizationUserId = this.getResponseProperty('OrganizationUserId');
this.actingUserId = this.getResponseProperty('ActingUserId');
this.date = this.getResponseProperty('Date');
this.deviceType = this.getResponseProperty('DeviceType');
this.ipAddress = this.getResponseProperty('IpAddress');
}
}

View File

@@ -0,0 +1,14 @@
import { BaseResponse } from './baseResponse';
export class FolderResponse extends BaseResponse {
id: string;
name: string;
revisionDate: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.name = this.getResponseProperty('Name');
this.revisionDate = this.getResponseProperty('RevisionDate');
}
}

View File

@@ -0,0 +1,14 @@
import { BaseResponse } from './baseResponse';
export class GlobalDomainResponse extends BaseResponse {
type: number;
domains: string[];
excluded: boolean;
constructor(response: any) {
super(response);
this.type = this.getResponseProperty('Type');
this.domains = this.getResponseProperty('Domains');
this.excluded = this.getResponseProperty('Excluded');
}
}

View File

@@ -0,0 +1,31 @@
import { BaseResponse } from './baseResponse';
import { SelectionReadOnlyResponse } from './selectionReadOnlyResponse';
export class GroupResponse extends BaseResponse {
id: string;
organizationId: string;
name: string;
accessAll: boolean;
externalId: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.organizationId = this.getResponseProperty('OrganizationId');
this.name = this.getResponseProperty('Name');
this.accessAll = this.getResponseProperty('AccessAll');
this.externalId = this.getResponseProperty('ExternalId');
}
}
export class GroupDetailsResponse extends GroupResponse {
collections: SelectionReadOnlyResponse[] = [];
constructor(response: any) {
super(response);
const collections = this.getResponseProperty('Collections');
if (collections != null) {
this.collections = collections.map((c: any) => new SelectionReadOnlyResponse(c));
}
}
}

View File

@@ -0,0 +1,32 @@
import { BaseResponse } from './baseResponse';
import { KdfType } from '../../enums/kdfType';
export class IdentityTokenResponse extends BaseResponse {
accessToken: string;
expiresIn: number;
refreshToken: string;
tokenType: string;
resetMasterPassword: boolean;
privateKey: string;
key: string;
twoFactorToken: string;
kdf: KdfType;
kdfIterations: number;
constructor(response: any) {
super(response);
this.accessToken = response.access_token;
this.expiresIn = response.expires_in;
this.refreshToken = response.refresh_token;
this.tokenType = response.token_type;
this.resetMasterPassword = this.getResponseProperty('ResetMasterPassword');
this.privateKey = this.getResponseProperty('PrivateKey');
this.key = this.getResponseProperty('Key');
this.twoFactorToken = this.getResponseProperty('TwoFactorToken');
this.kdf = this.getResponseProperty('Kdf');
this.kdfIterations = this.getResponseProperty('KdfIterations');
}
}

View File

@@ -0,0 +1,21 @@
import { BaseResponse } from './baseResponse';
import { TwoFactorProviderType } from '../../enums/twoFactorProviderType';
export class IdentityTwoFactorResponse extends BaseResponse {
twoFactorProviders: TwoFactorProviderType[];
twoFactorProviders2 = new Map<TwoFactorProviderType, { [key: string]: string; }>();
constructor(response: any) {
super(response);
this.twoFactorProviders = this.getResponseProperty('TwoFactorProviders');
const twoFactorProviders2 = this.getResponseProperty('TwoFactorProviders2');
if (twoFactorProviders2 != null) {
for (const prop in twoFactorProviders2) {
if (twoFactorProviders2.hasOwnProperty(prop)) {
this.twoFactorProviders2.set(parseInt(prop, null), twoFactorProviders2[prop]);
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
export { AttachmentResponse } from './attachmentResponse';
export { CipherResponse } from './cipherResponse';
export { CollectionResponse } from './collectionResponse';
export { DeviceResponse } from './deviceResponse';
export { DomainsResponse } from './domainsResponse';
export { ErrorResponse } from './errorResponse';
export { FolderResponse } from './folderResponse';
export { GlobalDomainResponse } from './globalDomainResponse';
export { IdentityTokenResponse } from './identityTokenResponse';
export { IdentityTwoFactorResponse } from './identityTwoFactorResponse';
export { KeysResponse } from './keysResponse';
export { ListResponse } from './listResponse';
export { ProfileOrganizationResponse } from './profileOrganizationResponse';
export { ProfileResponse } from './profileResponse';
export { SyncResponse } from './syncResponse';

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class KeysResponse extends BaseResponse {
privateKey: string;
publicKey: string;
constructor(response: any) {
super(response);
this.privateKey = this.getResponseProperty('PrivateKey');
this.publicKey = this.getResponseProperty('PublicKey');
}
}

View File

@@ -0,0 +1,13 @@
import { BaseResponse } from './baseResponse';
export class ListResponse<T> extends BaseResponse {
data: T[];
continuationToken: string;
constructor(response: any, t: new (dataResponse: any) => T) {
super(response);
const data = this.getResponseProperty('Data');
this.data = data == null ? [] : data.map((dr: any) => new t(dr));
this.continuationToken = this.getResponseProperty('ContinuationToken');
}
}

View File

@@ -0,0 +1,97 @@
import { BaseResponse } from './baseResponse';
import { NotificationType } from '../../enums/notificationType';
export class NotificationResponse extends BaseResponse {
contextId: string;
type: NotificationType;
payload: any;
constructor(response: any) {
super(response);
this.contextId = this.getResponseProperty('ContextId');
this.type = this.getResponseProperty('Type');
const payload = this.getResponseProperty('Payload');
switch (this.type) {
case NotificationType.SyncCipherCreate:
case NotificationType.SyncCipherDelete:
case NotificationType.SyncCipherUpdate:
case NotificationType.SyncLoginDelete:
this.payload = new SyncCipherNotification(payload);
break;
case NotificationType.SyncFolderCreate:
case NotificationType.SyncFolderDelete:
case NotificationType.SyncFolderUpdate:
this.payload = new SyncFolderNotification(payload);
break;
case NotificationType.SyncVault:
case NotificationType.SyncCiphers:
case NotificationType.SyncOrgKeys:
case NotificationType.SyncSettings:
case NotificationType.LogOut:
this.payload = new UserNotification(payload);
break;
case NotificationType.SyncSendCreate:
case NotificationType.SyncSendUpdate:
case NotificationType.SyncSendDelete:
this.payload = new SyncSendNotification(payload);
default:
break;
}
}
}
export class SyncCipherNotification extends BaseResponse {
id: string;
userId: string;
organizationId: string;
collectionIds: string[];
revisionDate: Date;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.userId = this.getResponseProperty('UserId');
this.organizationId = this.getResponseProperty('OrganizationId');
this.collectionIds = this.getResponseProperty('CollectionIds');
this.revisionDate = new Date(this.getResponseProperty('RevisionDate'));
}
}
export class SyncFolderNotification extends BaseResponse {
id: string;
userId: string;
revisionDate: Date;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.userId = this.getResponseProperty('UserId');
this.revisionDate = new Date(this.getResponseProperty('RevisionDate'));
}
}
export class UserNotification extends BaseResponse {
userId: string;
date: Date;
constructor(response: any) {
super(response);
this.userId = this.getResponseProperty('UserId');
this.date = new Date(this.getResponseProperty('Date'));
}
}
export class SyncSendNotification extends BaseResponse {
id: string;
userId: string;
revisionDate: Date;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.userId = this.getResponseProperty('UserId');
this.revisionDate = new Date(this.getResponseProperty('RevisionDate'));
}
}

View File

@@ -0,0 +1,7 @@
import { KeysResponse } from './keysResponse';
export class OrganizationKeysResponse extends KeysResponse {
constructor(response: any) {
super(response);
}
}

View File

@@ -0,0 +1,58 @@
import { BaseResponse } from './baseResponse';
import { PlanResponse } from './planResponse';
import { PlanType } from '../../enums/planType';
export class OrganizationResponse extends BaseResponse {
id: string;
identifier: string;
name: string;
businessName: string;
businessAddress1: string;
businessAddress2: string;
businessAddress3: string;
businessCountry: string;
businessTaxNumber: string;
billingEmail: string;
plan: PlanResponse;
planType: PlanType;
seats: number;
maxCollections: number;
maxStorageGb: number;
useGroups: boolean;
useDirectory: boolean;
useEvents: boolean;
useTotp: boolean;
use2fa: boolean;
useApi: boolean;
useResetPassword: boolean;
hasPublicAndPrivateKeys: boolean;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.identifier = this.getResponseProperty('Identifier');
this.name = this.getResponseProperty('Name');
this.businessName = this.getResponseProperty('BusinessName');
this.businessAddress1 = this.getResponseProperty('BusinessAddress1');
this.businessAddress2 = this.getResponseProperty('BusinessAddress2');
this.businessAddress3 = this.getResponseProperty('BusinessAddress3');
this.businessCountry = this.getResponseProperty('BusinessCountry');
this.businessTaxNumber = this.getResponseProperty('BusinessTaxNumber');
this.billingEmail = this.getResponseProperty('BillingEmail');
const plan = this.getResponseProperty('Plan');
this.plan = plan == null ? null : new PlanResponse(plan);
this.planType = this.getResponseProperty('PlanType');
this.seats = this.getResponseProperty('Seats');
this.maxCollections = this.getResponseProperty('MaxCollections');
this.maxStorageGb = this.getResponseProperty('MaxStorageGb');
this.useGroups = this.getResponseProperty('UseGroups');
this.useDirectory = this.getResponseProperty('UseDirectory');
this.useEvents = this.getResponseProperty('UseEvents');
this.useTotp = this.getResponseProperty('UseTotp');
this.use2fa = this.getResponseProperty('Use2fa');
this.useApi = this.getResponseProperty('UseApi');
this.useResetPassword = this.getResponseProperty('UseResetPassword');
this.hasPublicAndPrivateKeys = this.getResponseProperty('HasPublicAndPrivateKeys');
}
}

View File

@@ -0,0 +1,25 @@
import { OrganizationResponse } from './organizationResponse';
import {
BillingSubscriptionResponse,
BillingSubscriptionUpcomingInvoiceResponse,
} from './subscriptionResponse';
export class OrganizationSubscriptionResponse extends OrganizationResponse {
storageName: string;
storageGb: number;
subscription: BillingSubscriptionResponse;
upcomingInvoice: BillingSubscriptionUpcomingInvoiceResponse;
expiration: string;
constructor(response: any) {
super(response);
this.storageName = this.getResponseProperty('StorageName');
this.storageGb = this.getResponseProperty('StorageGb');
const subscription = this.getResponseProperty('Subscription');
this.subscription = subscription == null ? null : new BillingSubscriptionResponse(subscription);
const upcomingInvoice = this.getResponseProperty('UpcomingInvoice');
this.upcomingInvoice = upcomingInvoice == null ? null :
new BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
this.expiration = this.getResponseProperty('Expiration');
}
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class OrganizationUserBulkPublicKeyResponse extends BaseResponse {
id: string;
key: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.key = this.getResponseProperty('Key');
}
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class OrganizationUserBulkResponse extends BaseResponse {
id: string;
error: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.error = this.getResponseProperty('Error');
}
}

View File

@@ -0,0 +1,69 @@
import { BaseResponse } from './baseResponse';
import { SelectionReadOnlyResponse } from './selectionReadOnlyResponse';
import { PermissionsApi } from '../api/permissionsApi';
import { KdfType } from '../../enums/kdfType';
import { OrganizationUserStatusType } from '../../enums/organizationUserStatusType';
import { OrganizationUserType } from '../../enums/organizationUserType';
export class OrganizationUserResponse extends BaseResponse {
id: string;
userId: string;
type: OrganizationUserType;
status: OrganizationUserStatusType;
accessAll: boolean;
permissions: PermissionsApi;
resetPasswordEnrolled: boolean;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.userId = this.getResponseProperty('UserId');
this.type = this.getResponseProperty('Type');
this.status = this.getResponseProperty('Status');
this.permissions = new PermissionsApi(this.getResponseProperty('Permissions'));
this.accessAll = this.getResponseProperty('AccessAll');
this.resetPasswordEnrolled = this.getResponseProperty('ResetPasswordEnrolled');
}
}
export class OrganizationUserUserDetailsResponse extends OrganizationUserResponse {
name: string;
email: string;
twoFactorEnabled: boolean;
constructor(response: any) {
super(response);
this.name = this.getResponseProperty('Name');
this.email = this.getResponseProperty('Email');
this.twoFactorEnabled = this.getResponseProperty('TwoFactorEnabled');
}
}
export class OrganizationUserDetailsResponse extends OrganizationUserResponse {
collections: SelectionReadOnlyResponse[] = [];
constructor(response: any) {
super(response);
const collections = this.getResponseProperty('Collections');
if (collections != null) {
this.collections = collections.map((c: any) => new SelectionReadOnlyResponse(c));
}
}
}
export class OrganizationUserResetPasswordDetailsReponse extends BaseResponse {
kdf: KdfType;
kdfIterations: number;
resetPasswordKey: string;
encryptedPrivateKey: string;
constructor(response: any) {
super(response);
this.kdf = this.getResponseProperty('Kdf');
this.kdfIterations = this.getResponseProperty('KdfIterations');
this.resetPasswordKey = this.getResponseProperty('ResetPasswordKey');
this.encryptedPrivateKey = this.getResponseProperty('EncryptedPrivateKey');
}
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class PasswordHistoryResponse extends BaseResponse {
password: string;
lastUsedDate: string;
constructor(response: any) {
super(response);
this.password = this.getResponseProperty('Password');
this.lastUsedDate = this.getResponseProperty('LastUsedDate');
}
}

View File

@@ -0,0 +1,18 @@
import { BaseResponse } from './baseResponse';
import { ProfileResponse } from './profileResponse';
export class PaymentResponse extends BaseResponse {
userProfile: ProfileResponse;
paymentIntentClientSecret: string;
success: boolean;
constructor(response: any) {
super(response);
const userProfile = this.getResponseProperty('UserProfile');
if (userProfile != null) {
this.userProfile = new ProfileResponse(userProfile);
}
this.paymentIntentClientSecret = this.getResponseProperty('PaymentIntentClientSecret');
this.success = this.getResponseProperty('Success');
}
}

View File

@@ -0,0 +1,95 @@
import { PlanType } from '../../enums/planType';
import { ProductType } from '../../enums/productType';
import { BaseResponse } from './baseResponse';
export class PlanResponse extends BaseResponse {
type: PlanType;
product: ProductType;
name: string;
isAnnual: boolean;
nameLocalizationKey: string;
descriptionLocalizationKey: string;
canBeUsedByBusiness: boolean;
baseSeats: number;
baseStorageGb: number;
maxCollections: number;
maxUsers: number;
hasAdditionalSeatsOption: boolean;
maxAdditionalSeats: number;
hasAdditionalStorageOption: boolean;
maxAdditionalStorage: number;
hasPremiumAccessOption: boolean;
trialPeriodDays: number;
hasSelfHost: boolean;
hasPolicies: boolean;
hasGroups: boolean;
hasDirectory: boolean;
hasEvents: boolean;
hasTotp: boolean;
has2fa: boolean;
hasApi: boolean;
hasSso: boolean;
hasResetPassword: boolean;
usersGetPremium: boolean;
upgradeSortOrder: number;
displaySortOrder: number;
legacyYear: number;
disabled: boolean;
stripePlanId: string;
stripeSeatPlanId: string;
stripeStoragePlanId: string;
stripePremiumAccessPlanId: string;
basePrice: number;
seatPrice: number;
additionalStoragePricePerGb: number;
premiumAccessOptionPrice: number;
constructor(response: any) {
super(response);
this.type = this.getResponseProperty('Type');
this.product = this.getResponseProperty('Product');
this.name = this.getResponseProperty('Name');
this.isAnnual = this.getResponseProperty('IsAnnual');
this.nameLocalizationKey = this.getResponseProperty('NameLocalizationKey');
this.descriptionLocalizationKey = this.getResponseProperty('DescriptionLocalizationKey');
this.canBeUsedByBusiness = this.getResponseProperty('CanBeUsedByBusiness');
this.baseSeats = this.getResponseProperty('BaseSeats');
this.baseStorageGb = this.getResponseProperty('BaseStorageGb');
this.maxCollections = this.getResponseProperty('MaxCollections');
this.maxUsers = this.getResponseProperty('MaxUsers');
this.hasAdditionalSeatsOption = this.getResponseProperty('HasAdditionalSeatsOption');
this.maxAdditionalSeats = this.getResponseProperty('MaxAdditionalSeats');
this.hasAdditionalStorageOption = this.getResponseProperty('HasAdditionalStorageOption');
this.maxAdditionalStorage = this.getResponseProperty('MaxAdditionalStorage');
this.hasPremiumAccessOption = this.getResponseProperty('HasPremiumAccessOption');
this.trialPeriodDays = this.getResponseProperty('TrialPeriodDays');
this.hasSelfHost = this.getResponseProperty('HasSelfHost');
this.hasPolicies = this.getResponseProperty('HasPolicies');
this.hasGroups = this.getResponseProperty('HasGroups');
this.hasDirectory = this.getResponseProperty('HasDirectory');
this.hasEvents = this.getResponseProperty('HasEvents');
this.hasTotp = this.getResponseProperty('HasTotp');
this.has2fa = this.getResponseProperty('Has2fa');
this.hasApi = this.getResponseProperty('HasApi');
this.hasSso = this.getResponseProperty('HasSso');
this.hasResetPassword = this.getResponseProperty('HasResetPassword');
this.usersGetPremium = this.getResponseProperty('UsersGetPremium');
this.upgradeSortOrder = this.getResponseProperty('UpgradeSortOrder');
this.displaySortOrder = this.getResponseProperty('SortOrder');
this.legacyYear = this.getResponseProperty('LegacyYear');
this.disabled = this.getResponseProperty('Disabled');
this.stripePlanId = this.getResponseProperty('StripePlanId');
this.stripeSeatPlanId = this.getResponseProperty('StripeSeatPlanId');
this.stripeStoragePlanId = this.getResponseProperty('StripeStoragePlanId');
this.stripePremiumAccessPlanId = this.getResponseProperty('StripePremiumAccessPlanId');
this.basePrice = this.getResponseProperty('BasePrice');
this.seatPrice = this.getResponseProperty('SeatPrice');
this.additionalStoragePricePerGb = this.getResponseProperty('AdditionalStoragePricePerGb');
this.premiumAccessOptionPrice = this.getResponseProperty('PremiumAccessOptionPrice');
}
}

View File

@@ -0,0 +1,20 @@
import { BaseResponse } from './baseResponse';
import { PolicyType } from '../../enums/policyType';
export class PolicyResponse extends BaseResponse {
id: string;
organizationId: string;
type: PolicyType;
data: any;
enabled: boolean;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.organizationId = this.getResponseProperty('OrganizationId');
this.type = this.getResponseProperty('Type');
this.data = this.getResponseProperty('Data');
this.enabled = this.getResponseProperty('Enabled');
}
}

View File

@@ -0,0 +1,14 @@
import { BaseResponse } from './baseResponse';
import { KdfType } from '../../enums/kdfType';
export class PreloginResponse extends BaseResponse {
kdf: KdfType;
kdfIterations: number;
constructor(response: any) {
super(response);
this.kdf = this.getResponseProperty('Kdf');
this.kdfIterations = this.getResponseProperty('KdfIterations');
}
}

View File

@@ -0,0 +1,66 @@
import { BaseResponse } from './baseResponse';
import { OrganizationUserStatusType } from '../../enums/organizationUserStatusType';
import { OrganizationUserType } from '../../enums/organizationUserType';
import { PermissionsApi } from '../api/permissionsApi';
export class ProfileOrganizationResponse extends BaseResponse {
id: string;
name: string;
usePolicies: boolean;
useGroups: boolean;
useDirectory: boolean;
useEvents: boolean;
useTotp: boolean;
use2fa: boolean;
useApi: boolean;
useBusinessPortal: boolean;
useSso: boolean;
useResetPassword: boolean;
selfHost: boolean;
usersGetPremium: boolean;
seats: number;
maxCollections: number;
maxStorageGb?: number;
key: string;
hasPublicAndPrivateKeys: boolean;
status: OrganizationUserStatusType;
type: OrganizationUserType;
enabled: boolean;
ssoBound: boolean;
identifier: string;
permissions: PermissionsApi;
resetPasswordEnrolled: boolean;
userId: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.name = this.getResponseProperty('Name');
this.usePolicies = this.getResponseProperty('UsePolicies');
this.useGroups = this.getResponseProperty('UseGroups');
this.useDirectory = this.getResponseProperty('UseDirectory');
this.useEvents = this.getResponseProperty('UseEvents');
this.useTotp = this.getResponseProperty('UseTotp');
this.use2fa = this.getResponseProperty('Use2fa');
this.useApi = this.getResponseProperty('UseApi');
this.useBusinessPortal = this.getResponseProperty('UseBusinessPortal');
this.useSso = this.getResponseProperty('UseSso');
this.useResetPassword = this.getResponseProperty('UseResetPassword');
this.selfHost = this.getResponseProperty('SelfHost');
this.usersGetPremium = this.getResponseProperty('UsersGetPremium');
this.seats = this.getResponseProperty('Seats');
this.maxCollections = this.getResponseProperty('MaxCollections');
this.maxStorageGb = this.getResponseProperty('MaxStorageGb');
this.key = this.getResponseProperty('Key');
this.hasPublicAndPrivateKeys = this.getResponseProperty('HasPublicAndPrivateKeys');
this.status = this.getResponseProperty('Status');
this.type = this.getResponseProperty('Type');
this.enabled = this.getResponseProperty('Enabled');
this.ssoBound = this.getResponseProperty('SsoBound');
this.identifier = this.getResponseProperty('Identifier');
this.permissions = new PermissionsApi(this.getResponseProperty('permissions'));
this.resetPasswordEnrolled = this.getResponseProperty('ResetPasswordEnrolled');
this.userId = this.getResponseProperty('UserId');
}
}

View File

@@ -0,0 +1,37 @@
import { BaseResponse } from './baseResponse';
import { ProfileOrganizationResponse } from './profileOrganizationResponse';
export class ProfileResponse extends BaseResponse {
id: string;
name: string;
email: string;
emailVerified: boolean;
masterPasswordHint: string;
premium: boolean;
culture: string;
twoFactorEnabled: boolean;
key: string;
privateKey: string;
securityStamp: string;
organizations: ProfileOrganizationResponse[] = [];
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.name = this.getResponseProperty('Name');
this.email = this.getResponseProperty('Email');
this.emailVerified = this.getResponseProperty('EmailVerified');
this.masterPasswordHint = this.getResponseProperty('MasterPasswordHint');
this.premium = this.getResponseProperty('Premium');
this.culture = this.getResponseProperty('Culture');
this.twoFactorEnabled = this.getResponseProperty('TwoFactorEnabled');
this.key = this.getResponseProperty('Key');
this.privateKey = this.getResponseProperty('PrivateKey');
this.securityStamp = this.getResponseProperty('SecurityStamp');
const organizations = this.getResponseProperty('Organizations');
if (organizations != null) {
this.organizations = organizations.map((o: any) => new ProfileOrganizationResponse(o));
}
}
}

View File

@@ -0,0 +1,14 @@
import { BaseResponse } from './baseResponse';
export class SelectionReadOnlyResponse extends BaseResponse {
id: string;
readOnly: boolean;
hidePasswords: boolean;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.readOnly = this.getResponseProperty('ReadOnly');
this.hidePasswords = this.getResponseProperty('HidePasswords');
}
}

View File

@@ -0,0 +1,36 @@
import { BaseResponse } from './baseResponse';
import { SendType } from '../../enums/sendType';
import { SendFileApi } from '../api/sendFileApi';
import { SendTextApi } from '../api/sendTextApi';
export class SendAccessResponse extends BaseResponse {
id: string;
type: SendType;
name: string;
file: SendFileApi;
text: SendTextApi;
expirationDate: Date;
creatorIdentifier: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.type = this.getResponseProperty('Type');
this.name = this.getResponseProperty('Name');
const text = this.getResponseProperty('Text');
if (text != null) {
this.text = new SendTextApi(text);
}
const file = this.getResponseProperty('File');
if (file != null) {
this.file = new SendFileApi(file);
}
this.expirationDate = this.getResponseProperty('ExpirationDate');
this.creatorIdentifier = this.getResponseProperty('CreatorIdentifier');
}
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class SendFileDownloadDataResponse extends BaseResponse {
id: string = null;
url: string = null;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.url = this.getResponseProperty('Url');
}
}

View File

@@ -0,0 +1,18 @@
import { FileUploadType } from '../../enums/fileUploadType';
import { BaseResponse } from './baseResponse';
import { SendResponse } from './sendResponse';
export class SendFileUploadDataResponse extends BaseResponse {
fileUploadType: FileUploadType;
sendResponse: SendResponse;
url: string = null;
constructor(response: any) {
super(response);
this.fileUploadType = this.getResponseProperty('FileUploadType');
const sendResponse = this.getResponseProperty('SendResponse');
this.sendResponse = sendResponse == null ? null : new SendResponse(sendResponse);
this.url = this.getResponseProperty('Url');
}
}

View File

@@ -0,0 +1,53 @@
import { BaseResponse } from './baseResponse';
import { SendType } from '../../enums/sendType';
import { SendFileApi } from '../api/sendFileApi';
import { SendTextApi } from '../api/sendTextApi';
export class SendResponse extends BaseResponse {
id: string;
accessId: string;
type: SendType;
name: string;
notes: string;
file: SendFileApi;
text: SendTextApi;
key: string;
maxAccessCount?: number;
accessCount: number;
revisionDate: string;
expirationDate: string;
deletionDate: string;
password: string;
disable: boolean;
hideEmail: boolean;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.accessId = this.getResponseProperty('AccessId');
this.type = this.getResponseProperty('Type');
this.name = this.getResponseProperty('Name');
this.notes = this.getResponseProperty('Notes');
this.key = this.getResponseProperty('Key');
this.maxAccessCount = this.getResponseProperty('MaxAccessCount');
this.accessCount = this.getResponseProperty('AccessCount');
this.revisionDate = this.getResponseProperty('RevisionDate');
this.expirationDate = this.getResponseProperty('ExpirationDate');
this.deletionDate = this.getResponseProperty('DeletionDate');
this.password = this.getResponseProperty('Password');
this.disable = this.getResponseProperty('Disabled') || false;
this.hideEmail = this.getResponseProperty('HideEmail') || false;
const text = this.getResponseProperty('Text');
if (text != null) {
this.text = new SendTextApi(text);
}
const file = this.getResponseProperty('File');
if (file != null) {
this.file = new SendFileApi(file);
}
}
}

View File

@@ -0,0 +1,81 @@
import { BaseResponse } from './baseResponse';
export class SubscriptionResponse extends BaseResponse {
storageName: string;
storageGb: number;
maxStorageGb: number;
subscription: BillingSubscriptionResponse;
upcomingInvoice: BillingSubscriptionUpcomingInvoiceResponse;
license: any;
expiration: string;
usingInAppPurchase: boolean;
constructor(response: any) {
super(response);
this.storageName = this.getResponseProperty('StorageName');
this.storageGb = this.getResponseProperty('StorageGb');
this.maxStorageGb = this.getResponseProperty('MaxStorageGb');
this.license = this.getResponseProperty('License');
this.expiration = this.getResponseProperty('Expiration');
this.usingInAppPurchase = this.getResponseProperty('UsingInAppPurchase');
const subscription = this.getResponseProperty('Subscription');
const upcomingInvoice = this.getResponseProperty('UpcomingInvoice');
this.subscription = subscription == null ? null : new BillingSubscriptionResponse(subscription);
this.upcomingInvoice = upcomingInvoice == null ? null :
new BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
}
}
export class BillingSubscriptionResponse extends BaseResponse {
trialStartDate: string;
trialEndDate: string;
periodStartDate: string;
periodEndDate: string;
cancelledDate: string;
cancelAtEndDate: boolean;
status: string;
cancelled: boolean;
items: BillingSubscriptionItemResponse[] = [];
constructor(response: any) {
super(response);
this.trialEndDate = this.getResponseProperty('TrialStartDate');
this.trialEndDate = this.getResponseProperty('TrialEndDate');
this.periodStartDate = this.getResponseProperty('PeriodStartDate');
this.periodEndDate = this.getResponseProperty('PeriodEndDate');
this.cancelledDate = this.getResponseProperty('CancelledDate');
this.cancelAtEndDate = this.getResponseProperty('CancelAtEndDate');
this.status = this.getResponseProperty('Status');
this.cancelled = this.getResponseProperty('Cancelled');
const items = this.getResponseProperty('Items');
if (items != null) {
this.items = items.map((i: any) => new BillingSubscriptionItemResponse(i));
}
}
}
export class BillingSubscriptionItemResponse extends BaseResponse {
name: string;
amount: number;
quantity: number;
interval: string;
constructor(response: any) {
super(response);
this.name = this.getResponseProperty('Name');
this.amount = this.getResponseProperty('Amount');
this.quantity = this.getResponseProperty('Quantity');
this.interval = this.getResponseProperty('Interval');
}
}
export class BillingSubscriptionUpcomingInvoiceResponse extends BaseResponse {
date: string;
amount: number;
constructor(response: any) {
super(response);
this.date = this.getResponseProperty('Date');
this.amount = this.getResponseProperty('Amount');
}
}

View File

@@ -0,0 +1,57 @@
import { BaseResponse } from './baseResponse';
import { CipherResponse } from './cipherResponse';
import { CollectionDetailsResponse } from './collectionResponse';
import { DomainsResponse } from './domainsResponse';
import { FolderResponse } from './folderResponse';
import { PolicyResponse } from './policyResponse';
import { ProfileResponse } from './profileResponse';
import { SendResponse } from './sendResponse';
export class SyncResponse extends BaseResponse {
profile?: ProfileResponse;
folders: FolderResponse[] = [];
collections: CollectionDetailsResponse[] = [];
ciphers: CipherResponse[] = [];
domains?: DomainsResponse;
policies?: PolicyResponse[] = [];
sends: SendResponse[] = [];
constructor(response: any) {
super(response);
const profile = this.getResponseProperty('Profile');
if (profile != null) {
this.profile = new ProfileResponse(profile);
}
const folders = this.getResponseProperty('Folders');
if (folders != null) {
this.folders = folders.map((f: any) => new FolderResponse(f));
}
const collections = this.getResponseProperty('Collections');
if (collections != null) {
this.collections = collections.map((c: any) => new CollectionDetailsResponse(c));
}
const ciphers = this.getResponseProperty('Ciphers');
if (ciphers != null) {
this.ciphers = ciphers.map((c: any) => new CipherResponse(c));
}
const domains = this.getResponseProperty('Domains');
if (domains != null) {
this.domains = new DomainsResponse(domains);
}
const policies = this.getResponseProperty('Policies');
if (policies != null) {
this.policies = policies.map((p: any) => new PolicyResponse(p));
}
const sends = this.getResponseProperty('Sends');
if (sends != null) {
this.sends = sends.map((s: any) => new SendResponse(s));
}
}
}

View File

@@ -0,0 +1,24 @@
import { BaseResponse } from './baseResponse';
export class TaxInfoResponse extends BaseResponse {
taxId: string;
taxIdType: string;
line1: string;
line2: string;
city: string;
state: string;
country: string;
postalCode: string;
constructor(response: any) {
super(response);
this.taxId = this.getResponseProperty('TaxIdNumber');
this.taxIdType = this.getResponseProperty('TaxIdType');
this.line1 = this.getResponseProperty('Line1');
this.line2 = this.getResponseProperty('Line2');
this.city = this.getResponseProperty('City');
this.state = this.getResponseProperty('State');
this.postalCode = this.getResponseProperty('PostalCode');
this.country = this.getResponseProperty('Country');
}
}

View File

@@ -0,0 +1,18 @@
import { BaseResponse } from './baseResponse';
export class TaxRateResponse extends BaseResponse {
id: string;
country: string;
state: string;
postalCode: string;
rate: number;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.country = this.getResponseProperty('Country');
this.state = this.getResponseProperty('State');
this.postalCode = this.getResponseProperty('PostalCode');
this.rate = this.getResponseProperty('Rate');
}
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class TwoFactorAuthenticatorResponse extends BaseResponse {
enabled: boolean;
key: string;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty('Enabled');
this.key = this.getResponseProperty('Key');
}
}

View File

@@ -0,0 +1,16 @@
import { BaseResponse } from './baseResponse';
export class TwoFactorDuoResponse extends BaseResponse {
enabled: boolean;
host: string;
secretKey: string;
integrationKey: string;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty('Enabled');
this.host = this.getResponseProperty('Host');
this.secretKey = this.getResponseProperty('SecretKey');
this.integrationKey = this.getResponseProperty('IntegrationKey');
}
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class TwoFactorEmailResponse extends BaseResponse {
enabled: boolean;
email: string;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty('Enabled');
this.email = this.getResponseProperty('Email');
}
}

View File

@@ -0,0 +1,14 @@
import { BaseResponse } from './baseResponse';
import { TwoFactorProviderType } from '../../enums/twoFactorProviderType';
export class TwoFactorProviderResponse extends BaseResponse {
enabled: boolean;
type: TwoFactorProviderType;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty('Enabled');
this.type = this.getResponseProperty('Type');
}
}

View File

@@ -0,0 +1,10 @@
import { BaseResponse } from './baseResponse';
export class TwoFactorRecoverResponse extends BaseResponse {
code: string;
constructor(response: any) {
super(response);
this.code = this.getResponseProperty('Code');
}
}

View File

@@ -0,0 +1,59 @@
import { Utils } from '../../misc/utils';
import { BaseResponse } from './baseResponse';
export class TwoFactorWebAuthnResponse extends BaseResponse {
enabled: boolean;
keys: KeyResponse[];
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty('Enabled');
const keys = this.getResponseProperty('Keys');
this.keys = keys == null ? null : keys.map((k: any) => new KeyResponse(k));
}
}
export class KeyResponse extends BaseResponse {
name: string;
id: number;
migrated: boolean;
constructor(response: any) {
super(response);
this.name = this.getResponseProperty('Name');
this.id = this.getResponseProperty('Id');
this.migrated = this.getResponseProperty('Migrated');
}
}
export class ChallengeResponse extends BaseResponse implements PublicKeyCredentialCreationOptions {
attestation?: AttestationConveyancePreference;
authenticatorSelection?: AuthenticatorSelectionCriteria;
challenge: BufferSource;
excludeCredentials?: PublicKeyCredentialDescriptor[];
extensions?: AuthenticationExtensionsClientInputs;
pubKeyCredParams: PublicKeyCredentialParameters[];
rp: PublicKeyCredentialRpEntity;
timeout?: number;
user: PublicKeyCredentialUserEntity;
constructor(response: any) {
super(response);
this.attestation = this.getResponseProperty('attestation');
this.authenticatorSelection = this.getResponseProperty('authenticatorSelection');
this.challenge = Utils.fromUrlB64ToArray(this.getResponseProperty('challenge'));
this.excludeCredentials = this.getResponseProperty('excludeCredentials').map((c: any) => {
c.id = Utils.fromUrlB64ToArray(c.id).buffer;
return c;
});
this.extensions = this.getResponseProperty('extensions');
this.pubKeyCredParams = this.getResponseProperty('pubKeyCredParams');
this.rp = this.getResponseProperty('rp');
this.timeout = this.getResponseProperty('timeout');
const user = this.getResponseProperty('user');
user.id = Utils.fromUrlB64ToArray(user.id);
this.user = user;
}
}

View File

@@ -0,0 +1,22 @@
import { BaseResponse } from './baseResponse';
export class TwoFactorYubiKeyResponse extends BaseResponse {
enabled: boolean;
key1: string;
key2: string;
key3: string;
key4: string;
key5: string;
nfc: boolean;
constructor(response: any) {
super(response);
this.enabled = this.getResponseProperty('Enabled');
this.key1 = this.getResponseProperty('Key1');
this.key2 = this.getResponseProperty('Key2');
this.key3 = this.getResponseProperty('Key3');
this.key4 = this.getResponseProperty('Key4');
this.key5 = this.getResponseProperty('Key5');
this.nfc = this.getResponseProperty('Nfc');
}
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';
export class UserKeyResponse extends BaseResponse {
userId: string;
publicKey: string;
constructor(response: any) {
super(response);
this.userId = this.getResponseProperty('UserId');
this.publicKey = this.getResponseProperty('PublicKey');
}
}