@egendata/client
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -5,3 +5,3 @@ const createClient = require('../lib/client') | ||
const { generateKey } = require('../lib/crypto') | ||
const { JWT } = require('@panva/jose') | ||
const { JWT } = require('jose') | ||
const { CONNECT_TO_OPERATOR_START, CONNECT_TO_OPERATOR } = require('../lib/events') | ||
@@ -8,0 +8,0 @@ jest.mock('axios') |
const createClient = require('../lib/client') | ||
const { createMemoryStore } = require('../lib/memoryStore') | ||
const { JWT } = require('@panva/jose') | ||
const { JWT } = require('jose') | ||
const { connectionInitHandler, connectionEventHandler } = require('./../lib/connection') | ||
@@ -67,3 +67,3 @@ const { sign } = require('../lib/jwt') | ||
const [ token ] = res.write.mock.calls[0] | ||
const [token] = res.write.mock.calls[0] | ||
const result = JWT.decode(token) | ||
@@ -70,0 +70,0 @@ |
@@ -1,2 +0,2 @@ | ||
const { JWE, JWS, JWK } = require('@panva/jose') | ||
const { JWE, JWS, JWK } = require('jose') | ||
const data = require('../lib/data') | ||
@@ -61,3 +61,3 @@ const { generateKey, toPublicKey } = require('../lib/crypto') | ||
expect(tokens.createWriteDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain, area, data: expect.any(Object) } ] | ||
connectionId, [{ domain, area, data: expect.any(Object) }] | ||
) | ||
@@ -113,3 +113,3 @@ }) | ||
payload: { | ||
paths: [ { domain, area, data: createJWE(data) } ] | ||
paths: [{ domain, area, data: createJWE(data) }] | ||
} | ||
@@ -122,3 +122,3 @@ })) | ||
expect(tokens.createReadDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain, area } ] | ||
connectionId, [{ domain, area }] | ||
) | ||
@@ -130,3 +130,3 @@ }) | ||
expect(tokens.createReadDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain: config.clientId, area } ] | ||
connectionId, [{ domain: config.clientId, area }] | ||
) | ||
@@ -173,3 +173,3 @@ }) | ||
payload: { | ||
paths: [ { domain, area } ] | ||
paths: [{ domain, area }] | ||
} | ||
@@ -182,3 +182,3 @@ })) | ||
expect(tokens.createReadDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain, area } ] | ||
connectionId, [{ domain, area }] | ||
) | ||
@@ -190,3 +190,3 @@ }) | ||
expect(tokens.createReadDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain: config.clientId, area } ] | ||
connectionId, [{ domain: config.clientId, area }] | ||
) | ||
@@ -225,3 +225,3 @@ }) | ||
expect(tokens.createWriteDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain, area, data: expect.any(Object) } ] | ||
connectionId, [{ domain, area, data: expect.any(Object) }] | ||
) | ||
@@ -233,3 +233,3 @@ }) | ||
expect(tokens.createWriteDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain: config.clientId, area, data: expect.any(Object) } ] | ||
connectionId, [{ domain: config.clientId, area, data: expect.any(Object) }] | ||
) | ||
@@ -266,5 +266,7 @@ }) | ||
case 'read.response.token': | ||
return { payload: { | ||
paths: [ { domain, area, data: createJWE(data) } ] | ||
} } | ||
return { | ||
payload: { | ||
paths: [{ domain, area, data: createJWE(data) }] | ||
} | ||
} | ||
default: | ||
@@ -284,3 +286,3 @@ throw new Error('Unmocked token') | ||
expect(tokens.createReadDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain, area } ] | ||
connectionId, [{ domain, area }] | ||
) | ||
@@ -292,3 +294,3 @@ }) | ||
expect(tokens.createReadDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain: config.clientId, area } ] | ||
connectionId, [{ domain: config.clientId, area }] | ||
) | ||
@@ -328,3 +330,3 @@ }) | ||
case 'read.response.token': | ||
return { payload: { paths: [ { domain, area } ] } } | ||
return { payload: { paths: [{ domain, area }] } } | ||
default: | ||
@@ -344,3 +346,3 @@ throw new Error('Unmocked token') | ||
expect(tokens.createReadDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain, area } ] | ||
connectionId, [{ domain, area }] | ||
) | ||
@@ -352,3 +354,3 @@ }) | ||
expect(tokens.createReadDataToken).toHaveBeenCalledWith( | ||
connectionId, [ { domain: config.clientId, area } ] | ||
connectionId, [{ domain: config.clientId, area }] | ||
) | ||
@@ -355,0 +357,0 @@ }) |
@@ -97,3 +97,3 @@ const { generateKeyPairSync } = require('crypto') | ||
expect(result).toEqual({ | ||
keys: [ toPublicKey(clientKey) ] | ||
keys: [toPublicKey(clientKey)] | ||
}) | ||
@@ -100,0 +100,0 @@ }) |
@@ -33,3 +33,3 @@ const { createPermissions } = require('../lib/permissions') | ||
keyProvider.generateTemporaryKey.mockResolvedValue(jwk) | ||
shorthandPermissions = [ { area: 'education', types: ['READ'], purpose: 'stuff' } ] | ||
shorthandPermissions = [{ area: 'education', types: ['READ'], purpose: 'stuff' }] | ||
@@ -36,0 +36,0 @@ const result = await createPermissions(shorthandPermissions, clientId, keyProvider) |
@@ -1,2 +0,2 @@ | ||
const { JWT, JWS, JWE, JWK } = require('@panva/jose') | ||
const { JWT, JWS, JWE, JWK } = require('jose') | ||
const { schemas } = require('@egendata/messaging') | ||
@@ -218,3 +218,3 @@ const axios = require('axios') | ||
const authReq = await client.tokens | ||
.createWriteDataToken(connectionId, [ { domain, area, data: jwe } ]) | ||
.createWriteDataToken(connectionId, [{ domain, area, data: jwe }]) | ||
@@ -229,3 +229,3 @@ const payload = JWT.decode(authReq) | ||
const authReq = await client.tokens | ||
.createWriteDataToken(connectionId, [ { domain, area, data: jwe } ]) | ||
.createWriteDataToken(connectionId, [{ domain, area, data: jwe }]) | ||
@@ -238,3 +238,3 @@ const { header } = JWT.decode(authReq, { complete: true }) | ||
const authReq = await client.tokens | ||
.createWriteDataToken(connectionId, [ { domain, area, data: jwe } ]) | ||
.createWriteDataToken(connectionId, [{ domain, area, data: jwe }]) | ||
@@ -247,3 +247,3 @@ const { type } = JWT.decode(authReq) | ||
const authReq = await client.tokens | ||
.createWriteDataToken(connectionId, [ { domain, area, data: jwe } ]) | ||
.createWriteDataToken(connectionId, [{ domain, area, data: jwe }]) | ||
@@ -268,3 +268,3 @@ const payload = JWT.decode(authReq) | ||
const authReq = await client.tokens | ||
.createReadDataToken(connectionId, [ { domain, area } ]) | ||
.createReadDataToken(connectionId, [{ domain, area }]) | ||
@@ -279,3 +279,3 @@ const payload = JWT.decode(authReq) | ||
const authReq = await client.tokens | ||
.createReadDataToken(connectionId, [ { domain, area } ]) | ||
.createReadDataToken(connectionId, [{ domain, area }]) | ||
@@ -288,3 +288,3 @@ const { header } = JWT.decode(authReq, { complete: true }) | ||
const authReq = await client.tokens | ||
.createReadDataToken(connectionId, [ { domain, area } ]) | ||
.createReadDataToken(connectionId, [{ domain, area }]) | ||
@@ -297,3 +297,3 @@ const { type } = JWT.decode(authReq) | ||
const authReq = await client.tokens | ||
.createReadDataToken(connectionId, [ { domain, area } ]) | ||
.createReadDataToken(connectionId, [{ domain, area }]) | ||
@@ -304,3 +304,3 @@ const payload = JWT.decode(authReq) | ||
expect(payload.iss).toBe('https://mycv.work') | ||
expect(payload.paths).toEqual([ { domain, area } ]) | ||
expect(payload.paths).toEqual([{ domain, area }]) | ||
}) | ||
@@ -307,0 +307,0 @@ }) |
@@ -0,1 +1,8 @@ | ||
# [0.6.0](https://github.com/egendata/client/compare/v0.5.0...v0.6.0) (2019-10-02) | ||
### Features | ||
* 🎸 Easier import of events from client ([c539cb8](https://github.com/egendata/client/commit/c539cb8)) | ||
# [0.5.0](https://github.com/egendata/client/compare/v0.4.0...v0.5.0) (2019-10-02) | ||
@@ -2,0 +9,0 @@ |
@@ -39,3 +39,3 @@ const { verify } = require('./jwt') | ||
if (permissions && permissions.approved) { | ||
for (let permission of permissions.approved) { | ||
for (const permission of permissions.approved) { | ||
if (permission.type === 'READ') { | ||
@@ -42,0 +42,0 @@ await client.keyProvider.makeKeyPermanent(permission.kid) |
@@ -1,2 +0,2 @@ | ||
const { JWS, JWE, JWK } = require('@panva/jose') | ||
const { JWS, JWE, JWK } = require('jose') | ||
const { verify } = require('./jwt') | ||
@@ -51,3 +51,3 @@ const { | ||
const result = [] | ||
for (let { domain, area, data } of response.paths) { | ||
for (const { domain, area, data } of response.paths) { | ||
try { | ||
@@ -120,3 +120,3 @@ let decryptedData | ||
const writeKeys = permissionJWKS.keys.map((key) => JWK.asKey(key)) | ||
for (let key of writeKeys) { | ||
for (const key of writeKeys) { | ||
encryptor.recipient(key, { kid: key.kid }) | ||
@@ -123,0 +123,0 @@ } |
@@ -5,2 +5,3 @@ const { createMemoryStore } = require('./memoryStore') | ||
create: require('./client'), | ||
events: require('./events'), | ||
utils: { | ||
@@ -7,0 +8,0 @@ createMemoryStore |
const { token } = require('@egendata/messaging') | ||
const { JWT, JWK } = require('@panva/jose') | ||
const { JWT, JWK } = require('jose') | ||
const { | ||
@@ -4,0 +4,0 @@ emitter, |
@@ -49,2 +49,3 @@ const { generateKey, importPEM, toPublicKey } = require('./crypto') | ||
} | ||
async load (key) { | ||
@@ -54,5 +55,7 @@ const value = await this.keyValueStore.load(key) | ||
} | ||
async save (key, value, ttl) { | ||
return this.keyValueStore.save(key, jsonToBase64(value), ttl) | ||
} | ||
async getKey (kid) { | ||
@@ -67,2 +70,3 @@ if (kid === 'client_key') { | ||
} | ||
async generatePersistentKey ({ use }) { | ||
@@ -73,2 +77,3 @@ const key = await generateKey(this.jwksURI, { use }, this.options.modulusLength) | ||
} | ||
async generateTemporaryKey ({ use }) { | ||
@@ -79,2 +84,3 @@ const key = await generateKey(this.jwksURI, { use }, this.options.modulusLength) | ||
} | ||
async makeKeyPermanent (kid) { | ||
@@ -87,8 +93,11 @@ const key = await this.getKey(kid) | ||
} | ||
async saveKey (key) { | ||
return this.save(`${KEY_PREFIX}${key.kid}`, key) | ||
} | ||
async removeKey (kid) { | ||
await this.keyValueStore.remove(`${KEY_PREFIX}${kid}`) | ||
} | ||
async saveWriteKeys (domain, area, jwks) { | ||
@@ -98,8 +107,11 @@ await this.save(`${WRITE_KEYS_PREFIX}${domain}|${area}`, jwks) | ||
} | ||
async getWriteKeys (domain, area) { | ||
return this.load(`${WRITE_KEYS_PREFIX}${domain}|${area}`) | ||
} | ||
async jwksKeyList () { | ||
return { keys: [ toPublicKey(this.clientKey) ] } | ||
return { keys: [toPublicKey(this.clientKey)] } | ||
} | ||
async jwksKey (kid) { | ||
@@ -114,2 +126,3 @@ let key | ||
} | ||
async getSigningKey (/* domain, area */) { | ||
@@ -116,0 +129,0 @@ // TODO: Create different signing keys for different domains/areas |
@@ -8,3 +8,3 @@ const { v4 } = require('uuid') | ||
const permissions = await permissionsPromise | ||
for (let type of cp.types) { | ||
for (const type of cp.types) { | ||
const permission = { | ||
@@ -11,0 +11,0 @@ id: v4(), |
@@ -18,3 +18,3 @@ const Joi = require('@hapi/joi') | ||
operator: Joi.string().uri().required(), | ||
clientKey: [ Joi.string().required(), schemas.JWK_PRIVATE.required() ], | ||
clientKey: [Joi.string().required(), schemas.JWK_PRIVATE.required()], | ||
keyValueStore: keyValueStore.required(), | ||
@@ -21,0 +21,0 @@ keyOptions: Joi.object().optional(), // TODO: Describe key options |
{ | ||
"name": "@egendata/client", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Client for Egendata Operator", | ||
@@ -34,11 +34,9 @@ "main": "lib/index.js", | ||
"@egendata/messaging": "^0.4.2", | ||
"@hapi/joi": "^15.0.3", | ||
"@panva/jose": "^1.0.1", | ||
"axios": "^0.18.1", | ||
"@hapi/joi": "^15.1.1", | ||
"axios": "^0.19.0", | ||
"body-parser": "^1.19.0", | ||
"case": "^1.6.1", | ||
"express": "^4.16.4", | ||
"http-errors": "^1.7.1", | ||
"jsonwebtoken": "^8.4.0", | ||
"jws": "^3.2.2", | ||
"case": "^1.6.2", | ||
"express": "^4.17.1", | ||
"http-errors": "^1.7.3", | ||
"jose": "^1.10.0", | ||
"moment": "^2.24.0", | ||
@@ -49,22 +47,21 @@ "pem-jwk": "^2.0.0", | ||
"devDependencies": { | ||
"@commitlint/cli": "^8.1.0", | ||
"@commitlint/config-conventional": "^8.1.0", | ||
"@commitlint/cli": "^8.2.0", | ||
"@commitlint/config-conventional": "^8.2.0", | ||
"@semantic-release/changelog": "^3.0.4", | ||
"@semantic-release/git": "^7.0.16", | ||
"@types/jsonwebtoken": "^8.3.2", | ||
"@types/moment": "^2.13.0", | ||
"eslint": "^5.12.1", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-jest": "^22.2.1", | ||
"eslint": "^6.5.1", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jest": "^22.17.0", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"husky": "^3.0.5", | ||
"jest": "^24.8.0", | ||
"lint-staged": "^9.2.5", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"husky": "^3.0.8", | ||
"jest": "^24.9.0", | ||
"lint-staged": "^9.4.1", | ||
"semantic-release": "^15.13.24", | ||
"supertest": "^4.0.2", | ||
"tar": "^4.4.10", | ||
"uuid": "^3.3.2" | ||
"tar": "^5.0.2", | ||
"uuid": "^3.3.3" | ||
}, | ||
@@ -71,0 +68,0 @@ "jest": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97609
11
19
2136
+ Addedjose@^1.10.0
+ Addedaxios@0.19.2(transitive)
- Removed@panva/jose@^1.0.1
- Removedjsonwebtoken@^8.4.0
- Removedjws@^3.2.2
- Removed@panva/jose@1.9.3(transitive)
- Removedbuffer-equal-constant-time@1.0.1(transitive)
- Removedecdsa-sig-formatter@1.0.11(transitive)
- Removedjsonwebtoken@8.5.1(transitive)
- Removedjwa@1.4.1(transitive)
- Removedjws@3.2.2(transitive)
- Removedlodash.includes@4.3.0(transitive)
- Removedlodash.isboolean@3.0.3(transitive)
- Removedlodash.isinteger@4.0.4(transitive)
- Removedlodash.isnumber@3.0.3(transitive)
- Removedlodash.isplainobject@4.0.6(transitive)
- Removedlodash.isstring@4.0.1(transitive)
- Removedlodash.once@4.1.1(transitive)
- Removedsemver@5.7.2(transitive)
Updated@hapi/joi@^15.1.1
Updatedaxios@^0.19.0
Updatedcase@^1.6.2
Updatedexpress@^4.17.1
Updatedhttp-errors@^1.7.3