Skip to content

Commit

Permalink
feat: CTypes to iterms (#399)
Browse files Browse the repository at this point in the history
* feat: added optional array of ctypes to iterms

* feat: updating compress and decompress message
  • Loading branch information
Dudleyneedham authored Jun 7, 2021
1 parent 1bf7754 commit a67fc24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/messaging/src/Message.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ describe('Messaging Utilities', () => {
delegationId: undefined,
quote: quoteAttesterSigned,
prerequisiteClaims: undefined,
cTypes: undefined,
}
// Compressed Submit Terms Contentƒ
compressedSubmitTermsContent = [
Expand All @@ -350,6 +351,7 @@ describe('Messaging Utilities', () => {
undefined,
compressedResultAttesterSignedQuote,
undefined,
undefined,
]
// Reject terms Content
rejectTermsContent = {
Expand Down
5 changes: 5 additions & 0 deletions packages/messaging/src/Message.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export function errorCheckMessageBody(body: MessageBody): boolean | void {
'Submit terms pre-requisite claims invalid'
)
}
if (body.content.cTypes) {
body.content.cTypes.map((val) => CTypeUtils.errorCheck(val))
}
break
}
case Message.BodyType.REJECT_TERMS: {
Expand Down Expand Up @@ -305,6 +308,7 @@ export function compressMessage(body: MessageBody): CompressedMessageBody {
? QuoteUtils.compressAttesterSignedQuote(body.content.quote)
: undefined,
body.content.prerequisiteClaims,
body.content.cTypes?.map((val) => CTypeUtils.compress(val)),
]
break
}
Expand Down Expand Up @@ -432,6 +436,7 @@ export function decompressMessage(body: CompressedMessageBody): MessageBody {
? QuoteUtils.decompressAttesterSignedQuote(body[1][3])
: undefined,
prerequisiteClaims: body[1][4],
cTypes: body[1][5]?.map((val) => CTypeUtils.decompress(val)),
}

break
Expand Down
6 changes: 4 additions & 2 deletions packages/types/src/Terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import type { IAttestedClaim, CompressedAttestedClaim } from './AttestedClaim'
import type { ICType } from './CType'
import type { CompressedCType, ICType } from './CType'
import type { IDelegationBaseNode } from './Delegation'
import type {
IQuoteAttesterSigned,
Expand All @@ -19,12 +19,14 @@ export interface ITerms {
delegationId?: IDelegationBaseNode['id']
quote?: IQuoteAttesterSigned
prerequisiteClaims?: ICType['hash']
cTypes?: ICType[]
}

export type CompressedTerms = [
CompressedPartialClaim,
CompressedAttestedClaim[],
IDelegationBaseNode['id'] | undefined,
CompressedQuoteAttesterSigned | undefined,
ICType['hash'] | undefined
ICType['hash'] | undefined,
CompressedCType[] | undefined
]

0 comments on commit a67fc24

Please sign in to comment.