Skip to content

Commit

Permalink
chore: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Nov 28, 2021
1 parent b4e8453 commit 93e5fbc
Show file tree
Hide file tree
Showing 23 changed files with 1,361 additions and 287 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.0.1",
"version": "0.1.1",
"npmClient": "yarn",
"command": {
"publish": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "SSI-SDK-workspace",
"private": true,
"version": "0.0.1",
"version": "0.1.1",
"description": "Sphereon SSI Typescript SDK (Workspace)",
"repository": "[email protected]:Sphereon-Opensource/SSI-SDK.git",
"author": "Sphereon <[email protected]>",
Expand Down
24 changes: 11 additions & 13 deletions packages/lto-did-provider/src/__tests__/lto-did-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('@sphereon/lto-did-provider', () => {
mockContext
)


expect.assertions(4)
return assertExpectedIdentifier(identifier)
})
Expand Down Expand Up @@ -108,19 +107,18 @@ describe('@sphereon/lto-did-provider', () => {

await expect(
ltoDIDProvider.addKey(
{
identifier: {
...IDENTIFIER,
services: [],
},
key: LTO_KEY,
options: {
verificationMethod: LtoVerificationMethod.VerificationMethod,
{
identifier: {
...IDENTIFIER,
services: [],
},
key: LTO_KEY,
options: {
verificationMethod: LtoVerificationMethod.VerificationMethod,
},
},
},
mockContext
)

mockContext
)
).resolves.toEqual(`did:lto:${address}#key`)

// jest.resetAllMocks();
Expand Down
9 changes: 8 additions & 1 deletion packages/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"files": [],
"references": [{ "path": "ssi-sdk-core" }, { "path": "factom-did-provider" }, { "path": "lto-did-provider" }, {"path": "vc-api-issuer"}, {"path": "vc-api-verifier-plugin"}]
"references": [
{ "path": "ssi-sdk-core" },
{ "path": "factom-did-provider" },
{ "path": "lto-did-provider" },
{ "path": "vc-api-issuer" },
{ "path": "vc-api-verifier" },
{ "path": "vc-handler-ld-local" }
]
}
17 changes: 12 additions & 5 deletions packages/vc-api-issuer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,44 @@

---

__Warning: This package still is in every early development. Breaking changes without notice will happen at this point!__
**Warning: This package still is in every early development. Breaking changes without notice will happen at this point!**

---

# vc-api-verifier

A Veramo plugin to issue credentials using the vc-http-api. Based on an older version of the spec (v0.1) and only working for Sphereon's VC API currently. We are working on supporting the latest spec version.

### Installation

```shell
yarn add @sphereon/ssi-sdk-vc-api-issuer
```

### Build

```shell
yarn build
```

### Test

To run the tests a VC_HTTP_API_AUTH_TOKEN environment variable needs to be present with an authorization token.

The test command runs:
* `prettier`
* `jest`
* `coverage`

- `prettier`
- `jest`
- `coverage`

You can also run only a single section of these tests, using for example `yarn test:unit`.

```shell
yarn test
```

### Utility scripts

There are other utility scripts that help with development.

* `yarn fix` - runs `eslint --fix` as well as `prettier` to fix code style.
- `yarn fix` - runs `eslint --fix` as well as `prettier` to fix code style.
34 changes: 17 additions & 17 deletions packages/vc-api-issuer/__tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { getConfig } from '@veramo/cli/build/setup';
import { createObjects } from '@veramo/cli/build/lib/objectCreator';
import { getConfig } from '@veramo/cli/build/setup'
import { createObjects } from '@veramo/cli/build/lib/objectCreator'

jest.setTimeout(30000);
jest.setTimeout(30000)

import vcApiIssuerAgentLogic from './shared/vcApiIssuerAgentLogic';
import vcApiIssuerAgentLogic from './shared/vcApiIssuerAgentLogic'

let agent: any;
let agent: any

const setup = async (): Promise<boolean> => {
const config = getConfig('packages/vc-api-issuer/agent.yml');
config.agent.$args[0].plugins[0].$args[0].authorizationToken = process.env.VC_HTTP_API_AUTH_TOKEN;
const { localAgent } = createObjects(config, { localAgent: '/agent' });
agent = localAgent;
const config = getConfig('packages/vc-api-issuer/agent.yml')
config.agent.$args[0].plugins[0].$args[0].authorizationToken = process.env.VC_HTTP_API_AUTH_TOKEN
const { localAgent } = createObjects(config, { localAgent: '/agent' })
agent = localAgent

return true;
};
return true
}

const tearDown = async (): Promise<boolean> => {
return true;
};
return true
}

const getAgent = () => agent;
const testContext = { getAgent, setup, tearDown };
const getAgent = () => agent
const testContext = { getAgent, setup, tearDown }

describe('Local integration tests', () => {
vcApiIssuerAgentLogic(testContext);
});
vcApiIssuerAgentLogic(testContext)
})
74 changes: 37 additions & 37 deletions packages/vc-api-issuer/__tests__/restAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import 'cross-fetch/polyfill';
import { IAgent, createAgent, IAgentOptions } from '@veramo/core';
import { AgentRestClient } from '@veramo/remote-client';
import express from 'express';
import { Server } from 'http';
import { AgentRouter, RequestWithAgentRouter } from '@veramo/remote-server';
import { getConfig } from '@veramo/cli/build/setup';
import { createObjects } from '@veramo/cli/build/lib/objectCreator';
import { IVcApiIssuer } from '../src';
import { VcApiIssuer } from '../src';
import vcApiIssuerAgentLogic from './shared/vcApiIssuerAgentLogic';
import 'cross-fetch/polyfill'
import { IAgent, createAgent, IAgentOptions } from '@veramo/core'
import { AgentRestClient } from '@veramo/remote-client'
import express from 'express'
import { Server } from 'http'
import { AgentRouter, RequestWithAgentRouter } from '@veramo/remote-server'
import { getConfig } from '@veramo/cli/build/setup'
import { createObjects } from '@veramo/cli/build/lib/objectCreator'
import { IVcApiIssuer } from '../src'
import { VcApiIssuer } from '../src'
import vcApiIssuerAgentLogic from './shared/vcApiIssuerAgentLogic'

jest.setTimeout(30000);
jest.setTimeout(30000)

const port = 3002;
const basePath = '/agent';
let serverAgent: IAgent;
let restServer: Server;
const port = 3002
const basePath = '/agent'
let serverAgent: IAgent
let restServer: Server

if (!process.env.VC_HTTP_API_AUTH_TOKEN) {
jest.clearAllTimers();
throw new Error('Authorization token must be provided');
jest.clearAllTimers()
throw new Error('Authorization token must be provided')
}

const getAgent = (options?: IAgentOptions) =>
Expand All @@ -36,38 +36,38 @@ const getAgent = (options?: IAgentOptions) =>
schema: serverAgent.getSchema(),
}),
],
});
})

const setup = async (): Promise<boolean> => {
const config = getConfig('packages/vc-api-issuer/agent.yml');
config.agent.$args[0].plugins[0].$args[0].authorizationToken = process.env.VC_HTTP_API_AUTH_TOKEN;
const { agent } = createObjects(config, { agent: '/agent' });
serverAgent = agent;
const config = getConfig('packages/vc-api-issuer/agent.yml')
config.agent.$args[0].plugins[0].$args[0].authorizationToken = process.env.VC_HTTP_API_AUTH_TOKEN
const { agent } = createObjects(config, { agent: '/agent' })
serverAgent = agent

const agentRouter = AgentRouter({
exposedMethods: serverAgent.availableMethods(),
});
})

const requestWithAgent = RequestWithAgentRouter({
agent: serverAgent,
});
})

return new Promise((resolve) => {
const app = express();
app.use(basePath, requestWithAgent, agentRouter);
const app = express()
app.use(basePath, requestWithAgent, agentRouter)
restServer = app.listen(port, () => {
resolve(true);
});
});
};
resolve(true)
})
})
}

const tearDown = async (): Promise<boolean> => {
restServer.close();
return true;
};
restServer.close()
return true
}

const testContext = { getAgent, setup, tearDown };
const testContext = { getAgent, setup, tearDown }

describe('REST integration tests', () => {
vcApiIssuerAgentLogic(testContext);
});
vcApiIssuerAgentLogic(testContext)
})
20 changes: 9 additions & 11 deletions packages/vc-api-issuer/__tests__/shared/vcApiIssuerAgentLogic.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { TAgent } from '@veramo/core'
import { IVcApiIssuer } from '../../src/types/IVcApiIssuer'

type ConfiguredAgent = TAgent<IVcApiIssuer>;
type ConfiguredAgent = TAgent<IVcApiIssuer>

export default (testContext: {
getAgent: () => ConfiguredAgent;
setup: () => Promise<boolean>;
tearDown: () => Promise<boolean>;
}) => {
export default (testContext: { getAgent: () => ConfiguredAgent; setup: () => Promise<boolean>; tearDown: () => Promise<boolean> }) => {
describe('Issuer Agent Plugin', () => {
let agent: ConfiguredAgent

Expand All @@ -17,7 +13,7 @@ export default (testContext: {
})

afterAll(async () => {
await new Promise<void>(resolve => setTimeout(() => resolve(), 5000)); // avoid jest open handle error
await new Promise<void>((resolve) => setTimeout(() => resolve(), 10000)) // avoid jest open handle error
await testContext.tearDown()
})

Expand Down Expand Up @@ -47,9 +43,11 @@ export default (testContext: {
type: ['VerifiableCredential', 'UniversityDegreeCredential'],
}

return await expect(agent.issueCredentialUsingVcApi({
credential,
})).resolves.not.toBeNull()
return await expect(
agent.issueCredentialUsingVcApi({
credential,
})
).resolves.not.toBeNull()
})
})
};
}
12 changes: 10 additions & 2 deletions packages/vc-api-issuer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"generate-plugin-schema": "yarn veramo dev generate-plugin-schema"
},
"dependencies": {
"@veramo/core": "^3.1.0",
"@veramo/core": "^3.1.1-next.12",
"cross-fetch": "^3.1.4"
},
"devDependencies": {
Expand All @@ -38,5 +38,13 @@
"repository": "[email protected]:Sphereon-Opensource/SSI-SDK.git",
"author": "Sphereon <[email protected]>",
"license": "Apache-2.0",
"keywords": ["Sphereon", "SSI", "Veramo", "W3C", "VC", "API", "Issuer"]
"keywords": [
"Sphereon",
"SSI",
"Veramo",
"W3C",
"VC",
"API",
"Issuer"
]
}
Loading

0 comments on commit 93e5fbc

Please sign in to comment.