Skip to content

Commit

Permalink
Rename shared authz request and response types (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe authored Jan 31, 2024
1 parent 2238061 commit 13092a0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions apps/authz/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EvaluationRequestDto } from '@app/authz/app/evaluation-request.dto'
import { generateInboundRequest } from '@app/authz/app/persistence/repository/mock_data'
import { AuthorizationRequest } from '@narval/authz-shared'
import { EvaluationRequest } from '@narval/authz-shared'
import { Body, Controller, Get, Logger, Post } from '@nestjs/common'
import { AppService } from './app.service'

Expand Down Expand Up @@ -32,7 +32,7 @@ export class AppController {
})

// Map the DTO into the TS type because it's nicer to deal with.
const payload: AuthorizationRequest = body
const payload: EvaluationRequest = body

const result = await this.appService.runEvaluation(payload)
this.logger.log({
Expand Down
8 changes: 4 additions & 4 deletions apps/authz/src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { AuthCredential, OpaResult, RegoInput } from '@app/authz/shared/types/do
import {
Action,
Alg,
AuthorizationRequest,
AuthorizationResponse,
Decision,
EvaluationRequest,
EvaluationResponse,
HistoricalTransfer,
Request,
Signature,
Expand Down Expand Up @@ -143,7 +143,7 @@ export class AppService {
authentication,
approvals,
transfers
}: AuthorizationRequest): Promise<AuthorizationResponse> {
}: EvaluationRequest): Promise<EvaluationResponse> {
// Pre-Process
// verify the signatures of the Principal and any Approvals
const decoder = new Decoder()
Expand Down Expand Up @@ -184,7 +184,7 @@ export class AppService {
// Post-processing to evaluate multisigs
const finalDecision = finalizeDecision(resultSet)

const authzResponse: AuthorizationResponse = {
const authzResponse: EvaluationResponse = {
decision: finalDecision.decision,
request,
transactionRequestIntent: intent,
Expand Down
4 changes: 2 additions & 2 deletions apps/authz/src/app/persistence/repository/mock_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Action,
Alg,
AssetId,
AuthorizationRequest,
EvaluationRequest,
Request,
TransactionRequest,
hashRequest
Expand Down Expand Up @@ -258,7 +258,7 @@ export const mockEntityData: RegoData = {

// stub out the actual tx request & signature
// This is what would be the initial input from the external service
export const generateInboundRequest = async (): Promise<AuthorizationRequest> => {
export const generateInboundRequest = async (): Promise<EvaluationRequest> => {
const txRequest = NATIVE_TRANSFER_TX_REQUEST
const request: Request = {
action: Action.SIGN_TRANSACTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ import {
AuthorizationRequestStatus,
SignTransaction
} from '@app/orchestration/policy-engine/core/type/domain.type'
import {
AuthzApplicationClient,
EvaluationResponse
} from '@app/orchestration/policy-engine/http/client/authz-application.client'
import { AuthzApplicationClient } from '@app/orchestration/policy-engine/http/client/authz-application.client'
import { AuthorizationRequestRepository } from '@app/orchestration/policy-engine/persistence/repository/authorization-request.repository'
import { AuthorizationRequestProcessingProducer } from '@app/orchestration/policy-engine/queue/producer/authorization-request-processing.producer'
import { PriceService } from '@app/orchestration/price/core/service/price.service'
import { ChainId } from '@app/orchestration/shared/core/lib/chains.lib'
import { Transfer } from '@app/orchestration/shared/core/type/transfer-feed.type'
import { TransferFeedService } from '@app/orchestration/transfer-feed/core/service/transfer-feed.service'
import { Action, Decision, getAccountId, getAssetId } from '@narval/authz-shared'
import { Action, Decision, EvaluationResponse, getAccountId, getAssetId } from '@narval/authz-shared'
import { Intents, TransferNative } from '@narval/transaction-request-intent'
import { Test, TestingModule } from '@nestjs/testing'
import { MockProxy, mock } from 'jest-mock-extended'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { ApplicationException } from '@app/orchestration/shared/exception/application.exception'
import { AuthorizationRequest, AuthorizationResponse } from '@narval/authz-shared'
import { EvaluationRequest, EvaluationResponse } from '@narval/authz-shared'
import { HttpService } from '@nestjs/axios'
import { HttpStatus, Injectable, Logger } from '@nestjs/common'
import { catchError, lastValueFrom, map, tap } from 'rxjs'

export type EvaluationRequest = AuthorizationRequest
export type EvaluationResponse = AuthorizationResponse

@Injectable()
export class AuthzApplicationClient {
private logger = new Logger(AuthzApplicationClient.name)
Expand Down
4 changes: 2 additions & 2 deletions packages/authz-shared/src/lib/type/domain.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export type Prices = Record<AssetId, Record<string, number>>
* This must include all the data being authorized, and nothing except the data
* being authorized. This is the data that will be hashed and signed.
*/
export type AuthorizationRequest = {
export type EvaluationRequest = {
/**
* The initiator signature of the request using `hashRequest` method to ensure
* SHA256 format.
Expand Down Expand Up @@ -188,7 +188,7 @@ export type ApprovalRequirement = {
countPrincipal: boolean
}

export type AuthorizationResponse = {
export type EvaluationResponse = {
decision: Decision
request?: Request
approvals?: {
Expand Down

0 comments on commit 13092a0

Please sign in to comment.