Skip to content

Commit

Permalink
Rename shared authz request and response types
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe committed Jan 31, 2024
1 parent 0636da8 commit bc4c78b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 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
@@ -1,11 +1,11 @@
import { ApplicationException } from '@app/orchestration/shared/exception/application.exception'
import { AuthorizationRequest, AuthorizationResponse } from '@narval/authz-shared'
import { EvaluationRequest, EvaluationResponse } from '@narval/authz-shared'

Check failure on line 2 in apps/orchestration/src/policy-engine/http/client/authz-application.client.ts

View workflow job for this annotation

GitHub Actions / Build and test

Import declaration conflicts with local declaration of 'EvaluationRequest'.

Check failure on line 2 in apps/orchestration/src/policy-engine/http/client/authz-application.client.ts

View workflow job for this annotation

GitHub Actions / Build and test

Import declaration conflicts with local declaration of 'EvaluationResponse'.

Check failure on line 2 in apps/orchestration/src/policy-engine/http/client/authz-application.client.ts

View workflow job for this annotation

GitHub Actions / Build and test

Import declaration conflicts with local declaration of 'EvaluationRequest'.

Check failure on line 2 in apps/orchestration/src/policy-engine/http/client/authz-application.client.ts

View workflow job for this annotation

GitHub Actions / Build and test

Import declaration conflicts with local declaration of 'EvaluationResponse'.
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
export type EvaluationRequest = EvaluationRequest
export type EvaluationResponse = EvaluationResponse

@Injectable()
export class AuthzApplicationClient {
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 bc4c78b

Please sign in to comment.