Skip to content

Commit

Permalink
feat: Added IIdentityManagerGetIdentitiesArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Sep 28, 2020
1 parent 295d176 commit 1e0c9aa
Show file tree
Hide file tree
Showing 31 changed files with 322 additions and 83 deletions.
39 changes: 25 additions & 14 deletions __tests__/graphqlAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,35 @@ import {
IKeyManager,
IDataStore,
IMessageHandler,
} from 'daf-core'
import { MessageHandler } from 'daf-message-handler'
import { KeyManager } from 'daf-key-manager'
import { IdentityManager } from 'daf-identity-manager'
} from '../packages/daf-core'
import { MessageHandler } from '../packages/daf-message-handler'
import { KeyManager } from '../packages/daf-key-manager'
import { IdentityManager } from '../packages/daf-identity-manager'
import { createConnection, Connection } from 'typeorm'
import { DafResolver } from 'daf-resolver'
import { JwtMessageHandler } from 'daf-did-jwt'
import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from 'daf-w3c'
import { EthrIdentityProvider } from 'daf-ethr-did'
import { WebIdentityProvider } from 'daf-web-did'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from 'daf-did-comm'
import { SelectiveDisclosure, ISelectiveDisclosure, SdrMessageHandler } from 'daf-selective-disclosure'
import { KeyManagementSystem, SecretBox } from 'daf-libsodium'
import { Entities, KeyStore, IdentityStore, IDataStoreORM, DataStore, DataStoreORM } from 'daf-typeorm'
import { DafResolver } from '../packages/daf-resolver'
import { JwtMessageHandler } from '../packages/daf-did-jwt'
import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from '../packages/daf-w3c'
import { EthrIdentityProvider } from '../packages/daf-ethr-did'
import { WebIdentityProvider } from '../packages/daf-web-did'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/daf-did-comm'
import {
SelectiveDisclosure,
ISelectiveDisclosure,
SdrMessageHandler,
} from '../packages/daf-selective-disclosure'
import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium'
import {
Entities,
KeyStore,
IdentityStore,
IDataStoreORM,
DataStore,
DataStoreORM,
} from '../packages/daf-typeorm'
import express from 'express'
import { ApolloServer } from 'apollo-server-express'
import { Server } from 'http'
import { createSchema, AgentGraphQLClient, supportedMethods } from 'daf-graphql'
import { createSchema, AgentGraphQLClient, supportedMethods } from '../packages/daf-graphql'
import fs from 'fs'

// Shared tests
Expand Down
37 changes: 24 additions & 13 deletions __tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@ import {
IKeyManager,
IDataStore,
IMessageHandler,
} from 'daf-core'
import { MessageHandler } from 'daf-message-handler'
import { KeyManager } from 'daf-key-manager'
import { IdentityManager } from 'daf-identity-manager'
} from '../packages/daf-core'
import { MessageHandler } from '../packages/daf-message-handler'
import { KeyManager } from '../packages/daf-key-manager'
import { IdentityManager } from '../packages/daf-identity-manager'
import { createConnection, Connection } from 'typeorm'
import { DafResolver } from 'daf-resolver'
import { JwtMessageHandler } from 'daf-did-jwt'
import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from 'daf-w3c'
import { EthrIdentityProvider } from 'daf-ethr-did'
import { WebIdentityProvider } from 'daf-web-did'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from 'daf-did-comm'
import { SelectiveDisclosure, ISelectiveDisclosure, SdrMessageHandler } from 'daf-selective-disclosure'
import { KeyManagementSystem, SecretBox } from 'daf-libsodium'
import { Entities, KeyStore, IdentityStore, IDataStoreORM, DataStore, DataStoreORM } from 'daf-typeorm'
import { DafResolver } from '../packages/daf-resolver'
import { JwtMessageHandler } from '../packages/daf-did-jwt'
import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from '../packages/daf-w3c'
import { EthrIdentityProvider } from '../packages/daf-ethr-did'
import { WebIdentityProvider } from '../packages/daf-web-did'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/daf-did-comm'
import {
SelectiveDisclosure,
ISelectiveDisclosure,
SdrMessageHandler,
} from '../packages/daf-selective-disclosure'
import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium'
import {
Entities,
KeyStore,
IdentityStore,
IDataStoreORM,
DataStore,
DataStoreORM,
} from '../packages/daf-typeorm'
import fs from 'fs'

// Shared tests
Expand Down
41 changes: 26 additions & 15 deletions __tests__/restAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,35 @@ import {
IKeyManager,
IDataStore,
IMessageHandler,
} from 'daf-core'
import { MessageHandler } from 'daf-message-handler'
import { KeyManager } from 'daf-key-manager'
import { IdentityManager } from 'daf-identity-manager'
} from '../packages/daf-core'
import { MessageHandler } from '../packages/daf-message-handler'
import { KeyManager } from '../packages/daf-key-manager'
import { IdentityManager } from '../packages/daf-identity-manager'
import { createConnection, Connection } from 'typeorm'
import { DafResolver } from 'daf-resolver'
import { JwtMessageHandler } from 'daf-did-jwt'
import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from 'daf-w3c'
import { EthrIdentityProvider } from 'daf-ethr-did'
import { WebIdentityProvider } from 'daf-web-did'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from 'daf-did-comm'
import { SelectiveDisclosure, ISelectiveDisclosure, SdrMessageHandler } from 'daf-selective-disclosure'
import { KeyManagementSystem, SecretBox } from 'daf-libsodium'
import { Entities, KeyStore, IdentityStore, IDataStoreORM, DataStore, DataStoreORM } from 'daf-typeorm'
import { AgentRestClient, supportedMethods } from 'daf-rest'
import { DafResolver } from '../packages/daf-resolver'
import { JwtMessageHandler } from '../packages/daf-did-jwt'
import { CredentialIssuer, ICredentialIssuer, W3cMessageHandler } from '../packages/daf-w3c'
import { EthrIdentityProvider } from '../packages/daf-ethr-did'
import { WebIdentityProvider } from '../packages/daf-web-did'
import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/daf-did-comm'
import {
SelectiveDisclosure,
ISelectiveDisclosure,
SdrMessageHandler,
} from '../packages/daf-selective-disclosure'
import { KeyManagementSystem, SecretBox } from '../packages/daf-libsodium'
import {
Entities,
KeyStore,
IdentityStore,
IDataStoreORM,
DataStore,
DataStoreORM,
} from '../packages/daf-typeorm'
import { AgentRestClient, supportedMethods } from '../packages/daf-rest'
import express from 'express'
import { Server } from 'http'
import { AgentRouter } from 'daf-express'
import { AgentRouter } from '../packages/daf-express'
import fs from 'fs'

// Shared tests
Expand Down
10 changes: 10 additions & 0 deletions __tests__/shared/documentationExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ export default (testContext: {
})
})

it('daf-core-IIdentityManager-identityManagerGetIdentities example', async () => {
const aliceIdentities = await agent.identityManagerGetIdentities({
alias: 'alice',
})

const rinkebyIdentities = await agent.identityManagerGetIdentities({
provider: 'did:ethr:rinkeby',
})
})

it('daf-core-IIdentityManager-identityManagerGetIdentityByAlias example', async () => {
const identity = await agent.identityManagerGetIdentityByAlias({
alias: 'alice',
Expand Down
24 changes: 23 additions & 1 deletion __tests__/shared/identityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,29 @@ export default (testContext: {
expect(identity7).toEqual(identity4)
})

it.todo('should get identities')
it('should get identities', async () => {
const allIdentities = await agent.identityManagerGetIdentities()
expect(allIdentities.length).toEqual(3)

const aliceIdentities = await agent.identityManagerGetIdentities({
alias: 'alice',
})
expect(aliceIdentities.length).toEqual(2)

const rinkebyIdentities = await agent.identityManagerGetIdentities({
provider: 'did:ethr:rinkeby',
})
expect(rinkebyIdentities.length).toEqual(1)

// Default provider 'did:ethr:rinkeby'
await agent.identityManagerCreateIdentity()

const rinkebyIdentities2 = await agent.identityManagerGetIdentities({
provider: 'did:ethr:rinkeby',
})
expect(rinkebyIdentities2.length).toEqual(2)
})

it.todo('should import identity')
it.todo('should delete identity')
it.todo('should add key to identity')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,30 @@ Returns a list of managed identities
<b>Signature:</b>

```typescript
identityManagerGetIdentities(): Promise<Array<IIdentity>>;
identityManagerGetIdentities(args: IIdentityManagerGetIdentitiesArgs): Promise<Array<IIdentity>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| args | [IIdentityManagerGetIdentitiesArgs](./daf-core.iidentitymanagergetidentitiesargs.md) | Required. Arguments to get the list of identities |

<b>Returns:</b>

Promise&lt;Array&lt;[IIdentity](./daf-core.iidentity.md)<!-- -->&gt;&gt;

## Example


```typescript
const aliceIdentities = await agent.identityManagerGetIdentities({
alias: 'alice'
})

const rinkebyIdentities = await agent.identityManagerGetIdentities({
provider: 'did:ethr:rinkeby'
})

```

2 changes: 1 addition & 1 deletion docs/api/daf-core.iidentitymanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface IIdentityManager extends IPluginMethodMap
| [identityManagerAddService(args, context)](./daf-core.iidentitymanager.identitymanageraddservice.md) | Adds a service to a DID Document |
| [identityManagerCreateIdentity(args, context)](./daf-core.iidentitymanager.identitymanagercreateidentity.md) | Creates and returns a new identity |
| [identityManagerDeleteIdentity(args, context)](./daf-core.iidentitymanager.identitymanagerdeleteidentity.md) | Deletes identity |
| [identityManagerGetIdentities()](./daf-core.iidentitymanager.identitymanagergetidentities.md) | Returns a list of managed identities |
| [identityManagerGetIdentities(args)](./daf-core.iidentitymanager.identitymanagergetidentities.md) | Returns a list of managed identities |
| [identityManagerGetIdentity(args)](./daf-core.iidentitymanager.identitymanagergetidentity.md) | Returns a specific identity |
| [identityManagerGetIdentityByAlias(args)](./daf-core.iidentitymanager.identitymanagergetidentitybyalias.md) | Returns a specific identity by alias |
| [identityManagerGetOrCreateIdentity(args, context)](./daf-core.iidentitymanager.identitymanagergetorcreateidentity.md) | Returns an existing identity or creates a new one for a specific alias |
Expand Down
13 changes: 13 additions & 0 deletions docs/api/daf-core.iidentitymanagergetidentitiesargs.alias.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [IIdentityManagerGetIdentitiesArgs](./daf-core.iidentitymanagergetidentitiesargs.md) &gt; [alias](./daf-core.iidentitymanagergetidentitiesargs.alias.md)

## IIdentityManagerGetIdentitiesArgs.alias property

Optional. Alias

<b>Signature:</b>

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

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [IIdentityManagerGetIdentitiesArgs](./daf-core.iidentitymanagergetidentitiesargs.md)

## IIdentityManagerGetIdentitiesArgs interface

Input arguments for [identityManagerGetIdentities](./daf-core.iidentitymanager.identitymanagergetidentities.md)

<b>Signature:</b>

```typescript
export interface IIdentityManagerGetIdentitiesArgs
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [alias](./daf-core.iidentitymanagergetidentitiesargs.alias.md) | string | Optional. Alias |
| [provider](./daf-core.iidentitymanagergetidentitiesargs.provider.md) | string | Optional. Provider |

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

[Home](./index.md) &gt; [daf-core](./daf-core.md) &gt; [IIdentityManagerGetIdentitiesArgs](./daf-core.iidentitymanagergetidentitiesargs.md) &gt; [provider](./daf-core.iidentitymanagergetidentitiesargs.provider.md)

## IIdentityManagerGetIdentitiesArgs.provider property

Optional. Provider

<b>Signature:</b>

```typescript
provider?: string;
```
1 change: 1 addition & 0 deletions docs/api/daf-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Provides [Agent](./daf-core.agent.md) implementation and defines [IResolver](./d
| [IIdentityManagerAddServiceArgs](./daf-core.iidentitymanageraddserviceargs.md) | Input arguments for [identityManagerAddService](./daf-core.iidentitymanager.identitymanageraddservice.md) |
| [IIdentityManagerCreateIdentityArgs](./daf-core.iidentitymanagercreateidentityargs.md) | Input arguments for [identityManagerCreateIdentity](./daf-core.iidentitymanager.identitymanagercreateidentity.md) |
| [IIdentityManagerDeleteIdentityArgs](./daf-core.iidentitymanagerdeleteidentityargs.md) | Input arguments for [identityManagerDeleteIdentity](./daf-core.iidentitymanager.identitymanagerdeleteidentity.md) |
| [IIdentityManagerGetIdentitiesArgs](./daf-core.iidentitymanagergetidentitiesargs.md) | Input arguments for [identityManagerGetIdentities](./daf-core.iidentitymanager.identitymanagergetidentities.md) |
| [IIdentityManagerGetIdentityArgs](./daf-core.iidentitymanagergetidentityargs.md) | Input arguments for [identityManagerGetIdentity](./daf-core.iidentitymanager.identitymanagergetidentity.md) |
| [IIdentityManagerGetIdentityByAliasArgs](./daf-core.iidentitymanagergetidentitybyaliasargs.md) | Input arguments for [identityManagerGetIdentityByAlias](./daf-core.iidentitymanager.identitymanagergetidentitybyalias.md) |
| [IIdentityManagerGetOrCreateIdentityArgs](./daf-core.iidentitymanagergetorcreateidentityargs.md) | Input arguments for [identityManagerGetOrCreateIdentity](./daf-core.iidentitymanager.identitymanagergetorcreateidentity.md) |
Expand Down
12 changes: 11 additions & 1 deletion docs/api/daf-identity-manager.abstractidentitystore.list.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@
<b>Signature:</b>

```typescript
abstract list(): Promise<IIdentity[]>;
abstract list(args: {
alias?: string;
provider?: string;
}): Promise<IIdentity[]>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| args | { alias?: string; provider?: string; } | |

<b>Returns:</b>

Promise&lt;[IIdentity](./daf-core.iidentity.md)<!-- -->\[\]&gt;
Expand Down
2 changes: 1 addition & 1 deletion docs/api/daf-identity-manager.abstractidentitystore.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ export declare abstract class AbstractIdentityStore
| [get(args)](./daf-identity-manager.abstractidentitystore.get.md) | | |
| [get(args)](./daf-identity-manager.abstractidentitystore.get_1.md) | | |
| [import(args)](./daf-identity-manager.abstractidentitystore.import.md) | | |
| [list()](./daf-identity-manager.abstractidentitystore.list.md) | | |
| [list(args)](./daf-identity-manager.abstractidentitystore.list.md) | | |

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Creates and returns a new identity
<b>Signature:</b>

```typescript
identityManagerCreateIdentity({ provider, alias, kms, options }: IIdentityManagerCreateIdentityArgs, context: IAgentContext<IKeyManager>): Promise<IIdentity>;
identityManagerCreateIdentity(args: IIdentityManagerCreateIdentityArgs, context: IAgentContext<IKeyManager>): Promise<IIdentity>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { provider, alias, kms, options } | [IIdentityManagerCreateIdentityArgs](./daf-core.iidentitymanagercreateidentityargs.md) | |
| args | [IIdentityManagerCreateIdentityArgs](./daf-core.iidentitymanagercreateidentityargs.md) | Required. Arguments to create the identity |
| context | [IAgentContext](./daf-core.iagentcontext.md)<!-- -->&lt;[IKeyManager](./daf-core.ikeymanager.md)<!-- -->&gt; | <a href="../plugin.md#executing-plugin-methods">Execution context</a>. Requires <code>agent</code> that has [IKeyManager](./daf-core.ikeymanager.md) methods |

<b>Returns:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ Returns a list of managed identities
<b>Signature:</b>

```typescript
identityManagerGetIdentities(): Promise<IIdentity[]>;
identityManagerGetIdentities(args: IIdentityManagerGetIdentitiesArgs): Promise<IIdentity[]>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| args | [IIdentityManagerGetIdentitiesArgs](./daf-core.iidentitymanagergetidentitiesargs.md) | Required. Arguments to get the list of identities |

<b>Returns:</b>

Promise&lt;[IIdentity](./daf-core.iidentity.md)<!-- -->\[\]&gt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Returns a specific identity by alias
<b>Signature:</b>

```typescript
identityManagerGetIdentityByAlias({ alias, provider }: IIdentityManagerGetIdentityByAliasArgs): Promise<IIdentity>;
identityManagerGetIdentityByAlias({ alias, provider, }: IIdentityManagerGetIdentityByAliasArgs): Promise<IIdentity>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { alias, provider } | [IIdentityManagerGetIdentityByAliasArgs](./daf-core.iidentitymanagergetidentitybyaliasargs.md) | |
| { alias, provider, } | [IIdentityManagerGetIdentityByAliasArgs](./daf-core.iidentitymanagergetidentitybyaliasargs.md) | |

<b>Returns:</b>

Expand Down
6 changes: 3 additions & 3 deletions docs/api/daf-identity-manager.identitymanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export declare class IdentityManager implements IAgentPlugin
| --- | --- | --- |
| [identityManagerAddKey({ did, key, options }, context)](./daf-identity-manager.identitymanager.identitymanageraddkey.md) | | Adds a key to a DID Document |
| [identityManagerAddService({ did, service, options }, context)](./daf-identity-manager.identitymanager.identitymanageraddservice.md) | | Adds a service to a DID Document |
| [identityManagerCreateIdentity({ provider, alias, kms, options }, context)](./daf-identity-manager.identitymanager.identitymanagercreateidentity.md) | | Creates and returns a new identity |
| [identityManagerCreateIdentity(args, context)](./daf-identity-manager.identitymanager.identitymanagercreateidentity.md) | | Creates and returns a new identity |
| [identityManagerDeleteIdentity({ did }, context)](./daf-identity-manager.identitymanager.identitymanagerdeleteidentity.md) | | Deletes identity |
| [identityManagerGetIdentities()](./daf-identity-manager.identitymanager.identitymanagergetidentities.md) | | Returns a list of managed identities |
| [identityManagerGetIdentities(args)](./daf-identity-manager.identitymanager.identitymanagergetidentities.md) | | Returns a list of managed identities |
| [identityManagerGetIdentity({ did })](./daf-identity-manager.identitymanager.identitymanagergetidentity.md) | | Returns a specific identity |
| [identityManagerGetIdentityByAlias({ alias, provider })](./daf-identity-manager.identitymanager.identitymanagergetidentitybyalias.md) | | Returns a specific identity by alias |
| [identityManagerGetIdentityByAlias({ alias, provider, })](./daf-identity-manager.identitymanager.identitymanagergetidentitybyalias.md) | | Returns a specific identity by alias |
| [identityManagerGetOrCreateIdentity({ provider, alias, kms, options }, context)](./daf-identity-manager.identitymanager.identitymanagergetorcreateidentity.md) | | Returns an existing identity or creates a new one for a specific alias |
| [identityManagerGetProviders()](./daf-identity-manager.identitymanager.identitymanagergetproviders.md) | | Returns a list of available identity providers |
| [identityManagerImportIdentity(identity)](./daf-identity-manager.identitymanager.identitymanagerimportidentity.md) | | Imports identity |
Expand Down
2 changes: 1 addition & 1 deletion docs/api/daf-typeorm.entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
Entities: (typeof Credential | typeof Identity | typeof Claim | typeof Presentation | typeof Message | typeof Key | typeof Service)[]
Entities: (typeof Key | typeof Identity | typeof Service | typeof Claim | typeof Credential | typeof Presentation | typeof Message)[]
```
Loading

0 comments on commit 1e0c9aa

Please sign in to comment.