Skip to content

Commit

Permalink
refactor: Updated Claim Interface (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwicks31 authored Nov 9, 2018
1 parent b48ec47 commit de1a4a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ export enum ClaimType {
Work = 'Work',
}

export interface Claim {
readonly [key: string]: string | number | Claim | ReadonlyArray<number | string | Claim>
}

export interface BaseVerifiableClaim {
readonly '@context': any
readonly issuer: string
readonly issuanceDate: string
readonly type: ClaimType
readonly claim: object
readonly claim: Claim
}
export interface VerifiableClaim extends BaseVerifiableClaim {
readonly id: string
Expand Down
3 changes: 2 additions & 1 deletion src/VerifiableClaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CreateVerifiableClaimConfig,
DefaultClaimContext,
VerifiableClaim,
Claim,
} from './Interfaces'

const canonizeClaim = async (document: BaseVerifiableClaim): Promise<string> => {
Expand Down Expand Up @@ -40,7 +41,7 @@ export const configureCreateVerifiableClaim = ({
issuer,
type = ClaimType.Work,
context = {},
}: CreateVerifiableClaimConfig) => async (claim: object): Promise<VerifiableClaim> => {
}: CreateVerifiableClaimConfig) => async (claim: Claim): Promise<VerifiableClaim> => {
const verifiableClaim = {
'@context': { ...DefaultClaimContext, ...claimTypeDefaults[type], ...context },
type,
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Identity,
SignedVerifiableClaim,
SigningAlgorithm,
Claim,
Work,
} from '../../src/Interfaces'
import { getVerifiableClaimSigner } from '../../src/VerifiableClaimSigner'
Expand All @@ -20,7 +21,7 @@ export const claimSigner = getVerifiableClaimSigner()
export const getErrorMessage = (err: Error): string => err.message

export const makeClaim = (
claim: object,
claim: Claim,
type: ClaimType = ClaimType.Work,
context: ClaimContext = DefaultClaimContext,
): BaseVerifiableClaim => {
Expand Down Expand Up @@ -106,7 +107,7 @@ export const MyIdentity: Identity = {
},
}

export const TheRavenClaim: object = {
export const TheRavenClaim: Claim = {
name: 'The Raven',
author: 'Edgar Allan Poe',
tags: 'poem',
Expand Down

0 comments on commit de1a4a3

Please sign in to comment.