Skip to content

Commit

Permalink
feat: Validating all plugin method arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Oct 9, 2020
1 parent 29c6b0e commit 2c868f7
Show file tree
Hide file tree
Showing 104 changed files with 3,306 additions and 891 deletions.
2 changes: 1 addition & 1 deletion __tests__/shared/keyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default (testContext: {
//@ts-ignore
type: 'foobar',
}),
).rejects.toThrow('Key type not supported: foobar')
).rejects.toThrow('No enum match for: foobar')
})

it('should create key with meta data', async () => {
Expand Down
22 changes: 11 additions & 11 deletions __tests__/shared/resolveDid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ export default (testContext: {
expect(didDoc.id).toEqual(didUrl)
})

// it('should throw an error for unsupported did methods', async () => {
// await expect(agent.resolveDid({ didUrl: 'did:foo:bar' })).rejects.toThrow("Unsupported DID method: 'foo'")
// })
it('should throw an error for unsupported did methods', async () => {
await expect(agent.resolveDid({ didUrl: 'did:foo:bar' })).rejects.toThrow("Unsupported DID method: 'foo'")
})

// it('should throw validation error', async () => {
// //@ts-ignore
// await expect(agent.resolveDid()).rejects.toHaveProperty('name', 'ValidationError')
// //@ts-ignore
// await expect(agent.resolveDid({})).rejects.toHaveProperty('name', 'ValidationError')
// //@ts-ignore
// await expect(agent.resolveDid({didUrl: 1})).rejects.toHaveProperty('name', 'ValidationError')
it('should throw validation error', async () => {
//@ts-ignore
await expect(agent.resolveDid()).rejects.toHaveProperty('name', 'ValidationError')
//@ts-ignore
await expect(agent.resolveDid({})).rejects.toHaveProperty('name', 'ValidationError')
//@ts-ignore
await expect(agent.resolveDid({didUrl: 1})).rejects.toHaveProperty('name', 'ValidationError')

// })
})
})
}
1 change: 1 addition & 0 deletions docs/api/daf-core.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export declare class Agent implements IAgent
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [methods](./daf-core.agent.methods.md) | | [IPluginMethodMap](./daf-core.ipluginmethodmap.md) | The map of plugin + override methods |
| [schema](./daf-core.agent.schema.md) | | [IAgentPluginSchema](./daf-core.iagentpluginschema.md) | |
## Methods
Expand Down
11 changes: 11 additions & 0 deletions docs/api/daf-core.agent.schema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [Agent](./daf-core.agent.md) &gt; [schema](./daf-core.agent.schema.md)

## Agent.schema property

<b>Signature:</b>

```typescript
readonly schema: IAgentPluginSchema;
```
2 changes: 1 addition & 1 deletion docs/api/daf-core.ikey.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IKey
| --- | --- | --- |
| [kid](./daf-core.ikey.kid.md) | string | Key ID |
| [kms](./daf-core.ikey.kms.md) | string | Key Management System |
| [meta](./daf-core.ikey.meta.md) | object | Optional. Key metadata. Can be used to store auth data to access remote kms |
| [meta](./daf-core.ikey.meta.md) | object \| null | Optional. Key metadata. Can be used to store auth data to access remote kms |
| [privateKeyHex](./daf-core.ikey.privatekeyhex.md) | string | Optional. Private key |
| [publicKeyHex](./daf-core.ikey.publickeyhex.md) | string | Public key |
| [type](./daf-core.ikey.type.md) | [TKeyType](./daf-core.tkeytype.md) | Key type |
Expand Down
2 changes: 1 addition & 1 deletion docs/api/daf-core.ikey.meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Optional. Key metadata. Can be used to store auth data to access remote kms
<b>Signature:</b>

```typescript
meta?: object;
meta?: object | null;
```
6 changes: 4 additions & 2 deletions docs/api/daf-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Provides [Agent](./daf-core.agent.md) implementation and defines [IResolver](./d
| [IService](./daf-core.iservice.md) | Identity service |
| [RemoveContext](./daf-core.removecontext.md) | Removes context parameter from plugin method interface |
| [ResolveDidArgs](./daf-core.resolvedidargs.md) | Input arguments for [resolveDid](./daf-core.iresolver.resolvedid.md) |
| [VerifiableCredential](./daf-core.verifiablecredential.md) | Verifiable Credential [https://github.com/decentralized-identity/did-jwt-vc](https://github.com/decentralized-identity/did-jwt-vc) |
| [VerifiablePresentation](./daf-core.verifiablepresentation.md) | Verifiable Presentation [https://github.com/decentralized-identity/did-jwt-vc](https://github.com/decentralized-identity/did-jwt-vc) |
| [W3CCredential](./daf-core.w3ccredential.md) | W3CCredential [https://github.com/decentralized-identity/did-jwt-vc](https://github.com/decentralized-identity/did-jwt-vc) |
| [W3CPresentation](./daf-core.w3cpresentation.md) | W3CPresentation [https://github.com/decentralized-identity/did-jwt-vc](https://github.com/decentralized-identity/did-jwt-vc) |

## Variables

Expand All @@ -81,6 +85,4 @@ Provides [Agent](./daf-core.agent.md) implementation and defines [IResolver](./d
| --- | --- |
| [TAgent](./daf-core.tagent.md) | Utility type for constructing agent type that has a list of available methods |
| [TKeyType](./daf-core.tkeytype.md) | Cryptographic key type |
| [VerifiableCredential](./daf-core.verifiablecredential.md) | Verifiable Credential [https://github.com/decentralized-identity/did-jwt-vc](https://github.com/decentralized-identity/did-jwt-vc) |
| [VerifiablePresentation](./daf-core.verifiablepresentation.md) | Verifiable Presentation [https://github.com/decentralized-identity/did-jwt-vc](https://github.com/decentralized-identity/did-jwt-vc) |

2 changes: 1 addition & 1 deletion docs/api/daf-core.validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
validate: (args: object, schema: object, schemaPath?: string | undefined) => void
validate: (args: any, schema: object, schemaPath?: string | undefined) => void
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablecredential.__context_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; ["@context"](./daf-core.verifiablecredential.__context_.md)

## VerifiableCredential."@context" property

<b>Signature:</b>

```typescript
'@context': string[];
```
14 changes: 14 additions & 0 deletions docs/api/daf-core.verifiablecredential.credentialstatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; [credentialStatus](./daf-core.verifiablecredential.credentialstatus.md)

## VerifiableCredential.credentialStatus property

<b>Signature:</b>

```typescript
credentialStatus?: {
id: string;
type: string;
};
```
14 changes: 14 additions & 0 deletions docs/api/daf-core.verifiablecredential.credentialsubject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; [credentialSubject](./daf-core.verifiablecredential.credentialsubject.md)

## VerifiableCredential.credentialSubject property

<b>Signature:</b>

```typescript
credentialSubject: {
id?: string;
[x: string]: any;
};
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablecredential.expirationdate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; [expirationDate](./daf-core.verifiablecredential.expirationdate.md)

## VerifiableCredential.expirationDate property

<b>Signature:</b>

```typescript
expirationDate?: string;
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablecredential.id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; [id](./daf-core.verifiablecredential.id.md)

## VerifiableCredential.id property

<b>Signature:</b>

```typescript
id?: string;
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablecredential.issuancedate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; [issuanceDate](./daf-core.verifiablecredential.issuancedate.md)

## VerifiableCredential.issuanceDate property

<b>Signature:</b>

```typescript
issuanceDate: string;
```
14 changes: 14 additions & 0 deletions docs/api/daf-core.verifiablecredential.issuer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; [issuer](./daf-core.verifiablecredential.issuer.md)

## VerifiableCredential.issuer property

<b>Signature:</b>

```typescript
issuer: {
id: string;
[x: string]: any;
};
```
19 changes: 17 additions & 2 deletions docs/api/daf-core.verifiablecredential.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md)

## VerifiableCredential type
## VerifiableCredential interface

Verifiable Credential [https://github.com/decentralized-identity/did-jwt-vc](https://github.com/decentralized-identity/did-jwt-vc)

<b>Signature:</b>

```typescript
export declare type VerifiableCredential = Verifiable<W3CCredential>;
export interface VerifiableCredential
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| ["@context"](./daf-core.verifiablecredential.__context_.md) | string\[\] | |
| [credentialStatus](./daf-core.verifiablecredential.credentialstatus.md) | { id: string; type: string; } | |
| [credentialSubject](./daf-core.verifiablecredential.credentialsubject.md) | { id?: string; \[x: string\]: any; } | |
| [expirationDate](./daf-core.verifiablecredential.expirationdate.md) | string | |
| [id](./daf-core.verifiablecredential.id.md) | string | |
| [issuanceDate](./daf-core.verifiablecredential.issuancedate.md) | string | |
| [issuer](./daf-core.verifiablecredential.issuer.md) | { id: string; \[x: string\]: any; } | |
| [proof](./daf-core.verifiablecredential.proof.md) | { type?: string; \[x: string\]: any; } | |
| [type](./daf-core.verifiablecredential.type.md) | string\[\] | |

14 changes: 14 additions & 0 deletions docs/api/daf-core.verifiablecredential.proof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; [proof](./daf-core.verifiablecredential.proof.md)

## VerifiableCredential.proof property

<b>Signature:</b>

```typescript
proof: {
type?: string;
[x: string]: any;
};
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablecredential.type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiableCredential](./daf-core.verifiablecredential.md) &gt; [type](./daf-core.verifiablecredential.type.md)

## VerifiableCredential.type property

<b>Signature:</b>

```typescript
type: string[];
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablepresentation.__context_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; ["@context"](./daf-core.verifiablepresentation.__context_.md)

## VerifiablePresentation."@context" property

<b>Signature:</b>

```typescript
'@context': string[];
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablepresentation.expirationdate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; [expirationDate](./daf-core.verifiablepresentation.expirationdate.md)

## VerifiablePresentation.expirationDate property

<b>Signature:</b>

```typescript
expirationDate?: string;
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablepresentation.holder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; [holder](./daf-core.verifiablepresentation.holder.md)

## VerifiablePresentation.holder property

<b>Signature:</b>

```typescript
holder: string;
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablepresentation.id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; [id](./daf-core.verifiablepresentation.id.md)

## VerifiablePresentation.id property

<b>Signature:</b>

```typescript
id?: string;
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablepresentation.issuancedate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; [issuanceDate](./daf-core.verifiablepresentation.issuancedate.md)

## VerifiablePresentation.issuanceDate property

<b>Signature:</b>

```typescript
issuanceDate?: string;
```
19 changes: 17 additions & 2 deletions docs/api/daf-core.verifiablepresentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md)

## VerifiablePresentation type
## VerifiablePresentation interface

Verifiable Presentation [https://github.com/decentralized-identity/did-jwt-vc](https://github.com/decentralized-identity/did-jwt-vc)

<b>Signature:</b>

```typescript
export declare type VerifiablePresentation = Verifiable<W3CPresentation>;
export interface VerifiablePresentation
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| ["@context"](./daf-core.verifiablepresentation.__context_.md) | string\[\] | |
| [expirationDate](./daf-core.verifiablepresentation.expirationdate.md) | string | |
| [holder](./daf-core.verifiablepresentation.holder.md) | string | |
| [id](./daf-core.verifiablepresentation.id.md) | string | |
| [issuanceDate](./daf-core.verifiablepresentation.issuancedate.md) | string | |
| [proof](./daf-core.verifiablepresentation.proof.md) | { type?: string; \[x: string\]: any; } | |
| [type](./daf-core.verifiablepresentation.type.md) | string\[\] | |
| [verifiableCredential](./daf-core.verifiablepresentation.verifiablecredential.md) | [VerifiableCredential](./daf-core.verifiablecredential.md)<!-- -->\[\] | |
| [verifier](./daf-core.verifiablepresentation.verifier.md) | string\[\] | |

14 changes: 14 additions & 0 deletions docs/api/daf-core.verifiablepresentation.proof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; [proof](./daf-core.verifiablepresentation.proof.md)

## VerifiablePresentation.proof property

<b>Signature:</b>

```typescript
proof: {
type?: string;
[x: string]: any;
};
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablepresentation.type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; [type](./daf-core.verifiablepresentation.type.md)

## VerifiablePresentation.type property

<b>Signature:</b>

```typescript
type: string[];
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablepresentation.verifiablecredential.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; [verifiableCredential](./daf-core.verifiablepresentation.verifiablecredential.md)

## VerifiablePresentation.verifiableCredential property

<b>Signature:</b>

```typescript
verifiableCredential: VerifiableCredential[];
```
11 changes: 11 additions & 0 deletions docs/api/daf-core.verifiablepresentation.verifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [VerifiablePresentation](./daf-core.verifiablepresentation.md) &gt; [verifier](./daf-core.verifiablepresentation.verifier.md)

## VerifiablePresentation.verifier property

<b>Signature:</b>

```typescript
verifier: string[];
```
Loading

0 comments on commit 2c868f7

Please sign in to comment.