mirror of
https://github.com/bitwarden/jslib
synced 2025-12-30 15:13:22 +00:00
Replace deps with Injectable decorator
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { CommonModule, DatePipe } from "@angular/common";
|
||||
import { NgModule } from "@angular/core";
|
||||
|
||||
import { AvatarComponent } from "./components/avatar.component";
|
||||
@@ -89,6 +89,6 @@ import { UserNamePipe } from "./pipes/user-name.pipe";
|
||||
VerifyMasterPasswordComponent,
|
||||
ExportScopeCalloutComponent,
|
||||
],
|
||||
providers: [UserNamePipe, SearchPipe],
|
||||
providers: [DatePipe, UserNamePipe, SearchPipe],
|
||||
})
|
||||
export class JslibModule {}
|
||||
|
||||
@@ -97,30 +97,14 @@ import { ValidationService } from "./validation.service";
|
||||
{
|
||||
provide: AppIdServiceAbstraction,
|
||||
useClass: AppIdService,
|
||||
deps: [StorageServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: AuditServiceAbstraction,
|
||||
useClass: AuditService,
|
||||
deps: [CryptoFunctionServiceAbstraction, ApiServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: AuthServiceAbstraction,
|
||||
useClass: AuthService,
|
||||
deps: [
|
||||
CryptoServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
TokenServiceAbstraction,
|
||||
AppIdServiceAbstraction,
|
||||
PlatformUtilsServiceAbstraction,
|
||||
MessagingServiceAbstraction,
|
||||
LogService,
|
||||
KeyConnectorServiceAbstraction,
|
||||
EnvironmentServiceAbstraction,
|
||||
StateServiceAbstraction,
|
||||
TwoFactorServiceAbstraction,
|
||||
I18nServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: CipherServiceAbstraction,
|
||||
@@ -158,45 +142,28 @@ import { ValidationService } from "./validation.service";
|
||||
{
|
||||
provide: FolderServiceAbstraction,
|
||||
useClass: FolderService,
|
||||
deps: [
|
||||
CryptoServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
I18nServiceAbstraction,
|
||||
CipherServiceAbstraction,
|
||||
StateServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{ provide: LogService, useFactory: () => new ConsoleLogService(false) },
|
||||
{
|
||||
provide: CollectionServiceAbstraction,
|
||||
useClass: CollectionService,
|
||||
deps: [CryptoServiceAbstraction, I18nServiceAbstraction, StateServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: EnvironmentServiceAbstraction,
|
||||
useClass: EnvironmentService,
|
||||
deps: [StateServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: TotpServiceAbstraction,
|
||||
useClass: TotpService,
|
||||
deps: [CryptoFunctionServiceAbstraction, LogService, StateServiceAbstraction],
|
||||
},
|
||||
{ provide: TokenServiceAbstraction, useClass: TokenService, deps: [StateServiceAbstraction] },
|
||||
{ provide: TokenServiceAbstraction, useClass: TokenService },
|
||||
{
|
||||
provide: CryptoServiceAbstraction,
|
||||
useClass: CryptoService,
|
||||
deps: [
|
||||
CryptoFunctionServiceAbstraction,
|
||||
PlatformUtilsServiceAbstraction,
|
||||
LogService,
|
||||
StateServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: PasswordGenerationServiceAbstraction,
|
||||
useClass: PasswordGenerationService,
|
||||
deps: [CryptoServiceAbstraction, PolicyServiceAbstraction, StateServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: ApiServiceAbstraction,
|
||||
@@ -280,7 +247,6 @@ import { ValidationService } from "./validation.service";
|
||||
{
|
||||
provide: SettingsServiceAbstraction,
|
||||
useClass: SettingsService,
|
||||
deps: [StateServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: VaultTimeoutServiceAbstraction,
|
||||
@@ -365,17 +331,10 @@ import { ValidationService } from "./validation.service";
|
||||
{
|
||||
provide: ExportServiceAbstraction,
|
||||
useClass: ExportService,
|
||||
deps: [
|
||||
FolderServiceAbstraction,
|
||||
CipherServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
CryptoServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: SearchServiceAbstraction,
|
||||
useClass: SearchService,
|
||||
deps: [CipherServiceAbstraction, LogService, I18nServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: NotificationsServiceAbstraction,
|
||||
@@ -418,64 +377,35 @@ import { ValidationService } from "./validation.service";
|
||||
{
|
||||
provide: EventServiceAbstraction,
|
||||
useClass: EventService,
|
||||
deps: [
|
||||
ApiServiceAbstraction,
|
||||
CipherServiceAbstraction,
|
||||
StateServiceAbstraction,
|
||||
LogService,
|
||||
OrganizationServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: PolicyServiceAbstraction,
|
||||
useClass: PolicyService,
|
||||
deps: [StateServiceAbstraction, OrganizationServiceAbstraction, ApiServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: SendServiceAbstraction,
|
||||
useClass: SendService,
|
||||
deps: [
|
||||
CryptoServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
FileUploadServiceAbstraction,
|
||||
I18nServiceAbstraction,
|
||||
CryptoFunctionServiceAbstraction,
|
||||
StateServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: KeyConnectorServiceAbstraction,
|
||||
useClass: KeyConnectorService,
|
||||
deps: [
|
||||
StateServiceAbstraction,
|
||||
CryptoServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
TokenServiceAbstraction,
|
||||
LogService,
|
||||
OrganizationServiceAbstraction,
|
||||
CryptoFunctionServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: UserVerificationServiceAbstraction,
|
||||
useClass: UserVerificationService,
|
||||
deps: [CryptoServiceAbstraction, I18nServiceAbstraction, ApiServiceAbstraction],
|
||||
},
|
||||
{ provide: PasswordRepromptServiceAbstraction, useClass: PasswordRepromptService },
|
||||
{
|
||||
provide: OrganizationServiceAbstraction,
|
||||
useClass: OrganizationService,
|
||||
deps: [StateServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: ProviderServiceAbstraction,
|
||||
useClass: ProviderService,
|
||||
deps: [StateServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: TwoFactorServiceAbstraction,
|
||||
useClass: TwoFactorService,
|
||||
deps: [I18nServiceAbstraction, PlatformUtilsServiceAbstraction],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
"typescript": "4.3.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/core": "^12.2.13",
|
||||
"@microsoft/signalr": "5.0.10",
|
||||
"@microsoft/signalr-protocol-msgpack": "5.0.10",
|
||||
"big-integer": "1.6.48",
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppIdService as AppIdServiceAbstraction } from "../abstractions/appId.service";
|
||||
import { StorageService } from "../abstractions/storage.service";
|
||||
import { HtmlStorageLocation } from "../enums/htmlStorageLocation";
|
||||
import { Utils } from "../misc/utils";
|
||||
|
||||
@Injectable()
|
||||
export class AppIdService implements AppIdServiceAbstraction {
|
||||
constructor(private storageService: StorageService) {}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { AuditService as AuditServiceAbstraction } from "../abstractions/audit.service";
|
||||
import { CryptoFunctionService } from "../abstractions/cryptoFunction.service";
|
||||
@@ -8,6 +9,7 @@ import { ErrorResponse } from "../models/response/errorResponse";
|
||||
|
||||
const PwnedPasswordsApi = "https://api.pwnedpasswords.com/range/";
|
||||
|
||||
@Injectable()
|
||||
export class AuditService implements AuditServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoFunctionService: CryptoFunctionService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { AppIdService } from "../abstractions/appId.service";
|
||||
import { AuthService as AuthServiceAbstraction } from "../abstractions/auth.service";
|
||||
@@ -29,6 +31,7 @@ import { ErrorResponse } from "../models/response/errorResponse";
|
||||
|
||||
const sessionTimeoutLength = 2 * 60 * 1000; // 2 minutes
|
||||
|
||||
@Injectable()
|
||||
export class AuthService implements AuthServiceAbstraction {
|
||||
get email(): string {
|
||||
return this.logInStrategy instanceof PasswordLogInStrategy ? this.logInStrategy.email : null;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CollectionService as CollectionServiceAbstraction } from "../abstractions/collection.service";
|
||||
import { CryptoService } from "../abstractions/crypto.service";
|
||||
import { I18nService } from "../abstractions/i18n.service";
|
||||
@@ -11,6 +12,7 @@ import { CollectionView } from "../models/view/collectionView";
|
||||
|
||||
const NestingDelimiter = "/";
|
||||
|
||||
@Injectable()
|
||||
export class CollectionService implements CollectionServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoService: CryptoService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import * as bigInt from "big-integer";
|
||||
|
||||
import { CryptoService as CryptoServiceAbstraction } from "../abstractions/crypto.service";
|
||||
@@ -20,6 +22,7 @@ import { ProfileOrganizationResponse } from "../models/response/profileOrganizat
|
||||
import { ProfileProviderOrganizationResponse } from "../models/response/profileProviderOrganizationResponse";
|
||||
import { ProfileProviderResponse } from "../models/response/profileProviderResponse";
|
||||
|
||||
@Injectable()
|
||||
export class CryptoService implements CryptoServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoFunctionService: CryptoFunctionService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { Observable, Subject } from "rxjs";
|
||||
|
||||
import {
|
||||
@@ -7,6 +9,7 @@ import {
|
||||
import { StateService } from "../abstractions/state.service";
|
||||
import { EnvironmentUrls } from "../models/domain/environmentUrls";
|
||||
|
||||
@Injectable()
|
||||
export class EnvironmentService implements EnvironmentServiceAbstraction {
|
||||
private readonly urlsSubject = new Subject<Urls>();
|
||||
urls: Observable<Urls> = this.urlsSubject;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { CipherService } from "../abstractions/cipher.service";
|
||||
import { EventService as EventServiceAbstraction } from "../abstractions/event.service";
|
||||
@@ -8,6 +10,7 @@ import { EventType } from "../enums/eventType";
|
||||
import { EventData } from "../models/data/eventData";
|
||||
import { EventRequest } from "../models/request/eventRequest";
|
||||
|
||||
@Injectable()
|
||||
export class EventService implements EventServiceAbstraction {
|
||||
private inited = false;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import * as papa from "papaparse";
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
@@ -27,6 +29,7 @@ import { CollectionView } from "../models/view/collectionView";
|
||||
import { EventView } from "../models/view/eventView";
|
||||
import { FolderView } from "../models/view/folderView";
|
||||
|
||||
@Injectable()
|
||||
export class ExportService implements ExportServiceAbstraction {
|
||||
constructor(
|
||||
private folderService: FolderService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { CipherService } from "../abstractions/cipher.service";
|
||||
import { CryptoService } from "../abstractions/crypto.service";
|
||||
@@ -17,6 +19,7 @@ import { FolderView } from "../models/view/folderView";
|
||||
|
||||
const NestingDelimiter = "/";
|
||||
|
||||
@Injectable()
|
||||
export class FolderService implements FolderServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoService: CryptoService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { CipherService } from "../abstractions/cipher.service";
|
||||
import { CollectionService } from "../abstractions/collection.service";
|
||||
@@ -82,6 +84,7 @@ import { KvpRequest } from "../models/request/kvpRequest";
|
||||
import { ErrorResponse } from "../models/response/errorResponse";
|
||||
import { CipherView } from "../models/view/cipherView";
|
||||
|
||||
@Injectable()
|
||||
export class ImportService implements ImportServiceAbstraction {
|
||||
featuredImportOptions = featuredImportOptions as readonly ImportOption[];
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { CryptoService } from "../abstractions/crypto.service";
|
||||
import { CryptoFunctionService } from "../abstractions/cryptoFunction.service";
|
||||
@@ -14,6 +16,7 @@ import { KeyConnectorUserKeyRequest } from "../models/request/keyConnectorUserKe
|
||||
import { KeysRequest } from "../models/request/keysRequest";
|
||||
import { IdentityTokenResponse } from "../models/response/identityTokenResponse";
|
||||
|
||||
@Injectable()
|
||||
export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
constructor(
|
||||
private stateService: StateService,
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { OrganizationService as OrganizationServiceAbstraction } from "../abstractions/organization.service";
|
||||
import { StateService } from "../abstractions/state.service";
|
||||
import { OrganizationData } from "../models/data/organizationData";
|
||||
import { Organization } from "../models/domain/organization";
|
||||
|
||||
@Injectable()
|
||||
export class OrganizationService implements OrganizationServiceAbstraction {
|
||||
constructor(private stateService: StateService) {}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import * as zxcvbn from "zxcvbn";
|
||||
|
||||
import { CryptoService } from "../abstractions/crypto.service";
|
||||
@@ -31,6 +33,7 @@ const DefaultOptions = {
|
||||
|
||||
const MaxPasswordsInHistory = 100;
|
||||
|
||||
@Injectable()
|
||||
export class PasswordGenerationService implements PasswordGenerationServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoService: CryptoService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { OrganizationService } from "../abstractions/organization.service";
|
||||
import { PolicyService as PolicyServiceAbstraction } from "../abstractions/policy.service";
|
||||
@@ -13,6 +15,7 @@ import { ResetPasswordPolicyOptions } from "../models/domain/resetPasswordPolicy
|
||||
import { ListResponse } from "../models/response/listResponse";
|
||||
import { PolicyResponse } from "../models/response/policyResponse";
|
||||
|
||||
@Injectable()
|
||||
export class PolicyService implements PolicyServiceAbstraction {
|
||||
policyCache: Policy[];
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ProviderService as ProviderServiceAbstraction } from "../abstractions/provider.service";
|
||||
import { StateService } from "../abstractions/state.service";
|
||||
import { ProviderData } from "../models/data/providerData";
|
||||
import { Provider } from "../models/domain/provider";
|
||||
|
||||
@Injectable()
|
||||
export class ProviderService implements ProviderServiceAbstraction {
|
||||
constructor(private stateService: StateService) {}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import * as lunr from "lunr";
|
||||
|
||||
import { CipherService } from "../abstractions/cipher.service";
|
||||
@@ -10,6 +12,7 @@ import { UriMatchType } from "../enums/uriMatchType";
|
||||
import { CipherView } from "../models/view/cipherView";
|
||||
import { SendView } from "../models/view/sendView";
|
||||
|
||||
@Injectable()
|
||||
export class SearchService implements SearchServiceAbstraction {
|
||||
indexedEntityId?: string = null;
|
||||
private indexing = false;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { CryptoService } from "../abstractions/crypto.service";
|
||||
import { CryptoFunctionService } from "../abstractions/cryptoFunction.service";
|
||||
@@ -20,6 +22,7 @@ import { ErrorResponse } from "../models/response/errorResponse";
|
||||
import { SendResponse } from "../models/response/sendResponse";
|
||||
import { SendView } from "../models/view/sendView";
|
||||
|
||||
@Injectable()
|
||||
export class SendService implements SendServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoService: CryptoService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { SettingsService as SettingsServiceAbstraction } from "../abstractions/settings.service";
|
||||
import { StateService } from "../abstractions/state.service";
|
||||
|
||||
@@ -6,6 +8,7 @@ const Keys = {
|
||||
equivalentDomains: "equivalentDomains",
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class SettingsService implements SettingsServiceAbstraction {
|
||||
constructor(private stateService: StateService) {}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { StateService } from "../abstractions/state.service";
|
||||
import { TokenService as TokenServiceAbstraction } from "../abstractions/token.service";
|
||||
import { Utils } from "../misc/utils";
|
||||
import { IdentityTokenResponse } from "../models/response/identityTokenResponse";
|
||||
|
||||
@Injectable()
|
||||
export class TokenService implements TokenServiceAbstraction {
|
||||
static decodeToken(token: string): Promise<any> {
|
||||
if (token == null) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CryptoFunctionService } from "../abstractions/cryptoFunction.service";
|
||||
import { LogService } from "../abstractions/log.service";
|
||||
import { StateService } from "../abstractions/state.service";
|
||||
@@ -7,6 +9,7 @@ import { Utils } from "../misc/utils";
|
||||
const B32Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
const SteamChars = "23456789BCDFGHJKMNPQRTVWXY";
|
||||
|
||||
@Injectable()
|
||||
export class TotpService implements TotpServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoFunctionService: CryptoFunctionService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { I18nService } from "../abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "../abstractions/platformUtils.service";
|
||||
import {
|
||||
@@ -59,6 +61,7 @@ export const TwoFactorProviders: Partial<Record<TwoFactorProviderType, TwoFactor
|
||||
},
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class TwoFactorService implements TwoFactorServiceAbstraction {
|
||||
private twoFactorProvidersData: Map<TwoFactorProviderType, { [key: string]: string }>;
|
||||
private selectedTwoFactorProviderType: TwoFactorProviderType = null;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { CryptoService } from "../abstractions/crypto.service";
|
||||
import { I18nService } from "../abstractions/i18n.service";
|
||||
@@ -7,6 +9,7 @@ import { VerifyOTPRequest } from "../models/request/account/verifyOTPRequest";
|
||||
import { SecretVerificationRequest } from "../models/request/secretVerificationRequest";
|
||||
import { Verification } from "../types/verification";
|
||||
|
||||
@Injectable()
|
||||
export class UserVerificationService implements UserVerificationServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoService: CryptoService,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import * as forge from "node-forge";
|
||||
|
||||
import { CryptoFunctionService } from "../abstractions/cryptoFunction.service";
|
||||
@@ -5,6 +7,7 @@ import { Utils } from "../misc/utils";
|
||||
import { DecryptParameters } from "../models/domain/decryptParameters";
|
||||
import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey";
|
||||
|
||||
@Injectable()
|
||||
export class WebCryptoFunctionService implements CryptoFunctionService {
|
||||
private crypto: Crypto;
|
||||
private subtle: SubtleCrypto;
|
||||
|
||||
Reference in New Issue
Block a user