Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Claim Interface #226

Merged
merged 10 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | Array<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