Skip to content

Commit

Permalink
Swap references from identity-service to bio-auth-service. (#63)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Kennedy <[email protected]>
  • Loading branch information
Jeff Kennedy authored May 12, 2021
1 parent a31fb54 commit acae914
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @mac-arrap @voutasaurus @jsaur @matt-raffel-kiva @saltonmassally
* @mac-arrap @voutasaurus @jsaur @matt-raffel-kiva
6 changes: 3 additions & 3 deletions src/config/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"DD_AGENT_HOST": "datadog-apm-cluster-agent-metrics-api.datadog.svc.cluster.local",
"DD_TRACE_AGENT_HOSTNAME": "datadog-apm-cluster-agent-metrics-api.datadog.svc.cluster.local",
"DD_TRACE_AGENT_PORT": 8126,
"IDENTITY_SERVICE_BACKEND": "template",
"IDENTITY_SERVICE_URL": "http://protocol-identity-service:3005",
"BIO_AUTH_SERVICE_BACKEND": "template",
"BIO_AUTH_SERVICE_URL": "http://protocol-bio-auth-service:3005",
"JAEGER_ENDPOINT": "http://jaeger-collector:14268/api/traces",
"JWT_EXPIRE_SECONDS": 36000,
"JWT_SIGNATURE_ALGORITHM": "RS256",
Expand All @@ -23,7 +23,7 @@
"local": {
"JWKS_PROVIDER_DOMAIN": "kiva-protocol-standalone.auth0.com",
"DD_TRACE_AGENT_HOSTNAME": "",
"IDENTITY_SERVICE_URL": "http://protocol-identity-service:8080",
"BIO_AUTH_SERVICE_URL": "http://protocol-bio-auth-service:8080",
"JAEGER_ENDPOINT": "http://jaeger:14268/api/traces",
"MAX_LOG_LENGTH": 5000,
"TRACER": ""
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/impl/fingerprint.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IPlugin } from '../plugin.interface';
import { ProtocolException } from 'protocol-common/protocol.exception';
import { ProtocolErrorCode } from 'protocol-common/protocol.errorcode';
import { IIdentityService } from '../../remote/identity.service.interface';
import { IBioAuthService } from '../../remote/bio.auth.service.interface';
import { Logger } from 'protocol-common/logger';
import { VerifyFingerprintTemplateDto } from '../dto/verify.fingerprint.template.dto';
import { VerifyFingerprintImageDto } from '../dto/verify.fingerprint.image.dto';
Expand All @@ -18,7 +18,7 @@ export class FingerprintPlugin implements IPlugin {
* We pass in the parent class as context so we can access the sms module
*/
constructor(
private readonly identityService: IIdentityService,
private readonly bioAuthService: IBioAuthService,
private readonly externalIdDbGateway: ExternalIdDbGateway
) { }

Expand All @@ -39,9 +39,9 @@ export class FingerprintPlugin implements IPlugin {
let response;
try {
if (VerifyFingerprintImageDto.isInstance(params)) {
response = await this.identityService.verifyFingerprint(params.position, params.image, dids);
response = await this.bioAuthService.verifyFingerprint(params.position, params.image, dids);
} else {
response = await this.identityService.verifyFingerprintTemplate(params.position, params.template, dids);
response = await this.bioAuthService.verifyFingerprintTemplate(params.position, params.template, dids);
}
} catch(e) {
// Handle specific error codes
Expand Down Expand Up @@ -73,7 +73,7 @@ export class FingerprintPlugin implements IPlugin {

private async fingerprintQualityCheck(e: any, dids: string): Promise<any> {
try {
const response = await this.identityService.qualityCheck(dids);
const response = await this.bioAuthService.qualityCheck(dids);
e.details = e.details || {};
e.details.bestPositions = response.data;
} catch (ex) {
Expand All @@ -88,6 +88,6 @@ export class FingerprintPlugin implements IPlugin {
for (const datum of data) {
datum.did = id;
}
await this.identityService.templatize(data);
await this.bioAuthService.templatize(data);
}
}
6 changes: 3 additions & 3 deletions src/plugins/plugin.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PluginTypeEnum } from './plugin.type.enum';
import { FingerprintPlugin } from './impl/fingerprint.plugin';
import { SmsOtpPlugin } from './impl/sms.otp.plugin';
import { SmsService } from '../sms/sms.service';
import { IIdentityService } from '../remote/identity.service.interface';
import { IBioAuthService } from '../remote/bio.auth.service.interface';
import { TokenPlugin } from './impl/token.plugin';
import { TokenService } from '../token/token.service';
import { ExternalIdDbGateway } from '../db/external.id.db.gateway';
Expand All @@ -22,7 +22,7 @@ export class PluginFactory {
* These are set as optional so that in testing we can only inject the specific dependencies we need
*/
constructor(
@Optional() private readonly identityService?: IIdentityService,
@Optional() private readonly bioAuthService?: IBioAuthService,
@Optional() private readonly tokenService?: TokenService,
@Optional() private readonly smsService?: SmsService,
@Optional() private readonly externalIdDbGateway?: ExternalIdDbGateway
Expand All @@ -31,7 +31,7 @@ export class PluginFactory {
public create(pluginType: string): IPlugin {
switch (pluginType) {
case PluginTypeEnum.FINGERPRINT:
return new FingerprintPlugin(this.identityService, this.externalIdDbGateway);
return new FingerprintPlugin(this.bioAuthService, this.externalIdDbGateway);
case PluginTypeEnum.SMS_OTP:
return new SmsOtpPlugin(this.smsService);
case PluginTypeEnum.TOKEN:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export abstract class IIdentityService {
export abstract class IBioAuthService {
abstract verifyFingerprint(position: number, image: string, dids: string): Promise<any>;
abstract verifyFingerprintTemplate(position: number, template: string, dids: string): Promise<any>;
abstract templatize(data: any): Promise<any>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ProtocolHttpService } from 'protocol-common/protocol.http.service';
import { AxiosRequestConfig } from 'axios';
import { HttpService, Injectable } from '@nestjs/common';
import { IIdentityService } from '../identity.service.interface';
import { IBioAuthService } from '../bio.auth.service.interface';

/**
* This service class is a facade for the IdentityService HTTP API.
Expand All @@ -10,16 +10,14 @@ import { IIdentityService } from '../identity.service.interface';
* be set in a country profile, so the process of setting the backend will change.
*/
@Injectable()
export class IdentityService implements IIdentityService {
export class BioAuthService implements IBioAuthService {

private readonly backend: string;
private readonly baseUrl: string;
private readonly http: ProtocolHttpService;

constructor(httpService: HttpService) {
this.http = new ProtocolHttpService(httpService);
this.backend = process.env.IDENTITY_SERVICE_BACKEND;
this.baseUrl = process.env.IDENTITY_SERVICE_URL;
this.baseUrl = process.env.BIO_AUTH_SERVICE_URL;
}

/**
Expand All @@ -33,9 +31,9 @@ export class IdentityService implements IIdentityService {
public async verifyFingerprint(position: number, image: string, dids: string): Promise<any> {
const request: AxiosRequestConfig = {
method: 'POST',
url: this.baseUrl + '/api/v1/verify',
url: `${this.baseUrl}/api/v1/verify`,
data: {
backend: this.backend,
backend: 'template',
position,
image,
filters: {
Expand All @@ -56,9 +54,9 @@ export class IdentityService implements IIdentityService {
public async verifyFingerprintTemplate(position: number, template: string, dids: string): Promise<any> {
const request: AxiosRequestConfig = {
method: 'POST',
url: this.baseUrl + '/api/v1/verify',
url: `${this.baseUrl}/api/v1/verify`,
data: {
backend: this.backend,
backend: 'template',
position,
image: template,
filters: {
Expand All @@ -77,7 +75,7 @@ export class IdentityService implements IIdentityService {
public async templatize(data: any): Promise<any> {
const request: AxiosRequestConfig = {
method: 'POST',
url: this.baseUrl + '/api/v1/templatizer/bulk/' + this.backend,
url: `${this.baseUrl}/api/v1/templatizer/bulk/template`,
data,
};
return this.http.requestWithRetry(request);
Expand All @@ -90,7 +88,7 @@ export class IdentityService implements IIdentityService {
public async qualityCheck(dids: string): Promise<any> {
const request: AxiosRequestConfig = {
method: 'GET',
url: this.baseUrl + '/api/v1/positions/' + this.backend + `/dids=${dids}`,
url: `${this.baseUrl}/api/v1/positions/template/dids=${dids}`,
};
return this.http.requestWithRetry(request);
}
Expand Down
10 changes: 5 additions & 5 deletions src/remote/remote.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpModule, Module } from '@nestjs/common';
import { IdentityService } from './impl/identity.service';
import { BioAuthService } from './impl/bio.auth.service';
import { AgencyService } from './impl/agency.service';
import { IIdentityService } from './identity.service.interface';
import { IBioAuthService } from './bio.auth.service.interface';
import { IAgencyService } from './agency.service.interface';
import { SmsTwillioService } from './impl/sms.twillio.service';
import { ISmsService } from './sms.service.interface';
Expand All @@ -12,8 +12,8 @@ import { JwksService } from './impl/jwks.service';
@Module({
imports: [HttpModule],
providers: [{
provide: IIdentityService,
useClass: IdentityService
provide: IBioAuthService,
useClass: BioAuthService
}, {
provide: IAgencyService,
useClass: AgencyService
Expand All @@ -26,6 +26,6 @@ import { JwksService } from './impl/jwks.service';
provide: IJwksService,
useClass: JwksService
}],
exports: [IIdentityService, IAgencyService, ISmsService, IJwksService]
exports: [IBioAuthService, IAgencyService, ISmsService, IJwksService]
})
export class RemoteModule {}
10 changes: 5 additions & 5 deletions test/e2e/escrow.fingerprint.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { EscrowService } from '../../src/escrow/escrow.service';
import { WalletCredentials } from '../../src/db/entity/wallet.credentials';
import { PluginFactory } from '../../src/plugins/plugin.factory';
import { IAgencyService } from '../../src/remote/agency.service.interface';
import { IIdentityService } from '../../src/remote/identity.service.interface';
import { IBioAuthService } from '../../src/remote/bio.auth.service.interface';
import { MockAgencyService } from '../mock/mock.agency.service';
import { MockIdentityService } from '../mock/mock.identity.service';
import { MockBioAuthService } from '../mock/mock.bio.auth.service';
import { MockRepository } from '../mock/mock.repository';
import { ExternalId } from '../../src/db/entity/external.id';
import { ExternalIdDbGateway } from '../../src/db/external.id.db.gateway';
Expand All @@ -33,7 +33,7 @@ describe('EscrowController (e2e) using fingerprint plugin', () => {
did = 'agentId123'; // Right now identity service returns did, eventually it will return agentId

const mockAgencyService = new MockAgencyService('foo');
const mockIdentityService = new MockIdentityService(status, did);
const mockBioAuthService = new MockBioAuthService(status, did);

// Set up ExternalId repository
const mockExternalId = new ExternalId();
Expand Down Expand Up @@ -83,8 +83,8 @@ describe('EscrowController (e2e) using fingerprint plugin', () => {
useValue: mockAgencyService,
},
{
provide: IIdentityService,
useValue: mockIdentityService
provide: IBioAuthService,
useValue: mockBioAuthService
},
PluginFactory,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IIdentityService } from '../../src/remote/identity.service.interface';
import { IBioAuthService } from '../../src/remote/bio.auth.service.interface';

export class MockIdentityService implements IIdentityService {
export class MockBioAuthService implements IBioAuthService {

constructor(private readonly status: string, private readonly did: string) {}

Expand Down

0 comments on commit acae914

Please sign in to comment.