Skip to content

Commit c40f84d

Browse files
committed
avoid node v8 features
1 parent 4e3691f commit c40f84d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"scripts": {
3434
"start": "NODE_ENV=test npm test -- -w",
3535
"lint": "standard",
36-
"test:cmd": "node --harmony node_modules/.bin/ava test/**/*.spec.js --timeout=30s",
37-
"test": "NODE_ENV=test nyc --check-coverage --lines 80 npm run test:cmd",
36+
"test": "NODE_ENV=test nyc --check-coverage --lines 80 ava test/**/*.spec.js --timeout=30s",
3837
"coverage": "nyc report --reporter=lcov",
3938
"ci.coverage": "nyc report --reporter=text-lcov | coveralls"
4039
},

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function handleKeycloakValidation (tkn, reply) {
3232
return invalidate()
3333
}
3434

35-
const { expiresIn, ...credentials } = tkn.getData(internals.userInfoFields)
35+
const { expiresIn, credentials } = tkn.getData(internals.userInfoFields)
3636
const userData = { credentials }
3737

3838
cache.set(tkn.get(), userData, expiresIn)

src/token.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ function token (field) {
106106
const content = getContent()
107107

108108
return {
109-
scope: getScope(content),
110109
expiresIn: getExpiration(content),
111-
...getUserInfo(content, userInfoFields)
110+
credentials: Object.assign({
111+
scope: getScope(content)
112+
}, getUserInfo(content, userInfoFields))
112113
}
113114
}
114115

test/token.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,21 @@ test('get user data of token', (t) => {
6363

6464
t.truthy(data)
6565
t.is(data.expiresIn, 4000)
66-
t.is(data.sub, fixtures.content.userData.sub)
67-
t.falsy(data.name)
68-
t.deepEqual(data.scope.sort(), ['editor', 'other-app:creator', 'realm:admin'])
66+
t.is(data.credentials.sub, fixtures.content.userData.sub)
67+
t.falsy(data.credentials.name)
68+
t.deepEqual(data.credentials.scope.sort(), ['editor', 'other-app:creator', 'realm:admin'])
6969
})
7070

71-
test('get user data of token', (t) => {
71+
test('get user data of token – additional fields', (t) => {
7272
const jwt = `bearer ${fixtures.jwt.userData}`
7373
const tkn = token(jwt)
7474
const data = tkn.getData(['name'])
7575

7676
t.truthy(data)
7777
t.is(data.expiresIn, 4000)
78-
t.is(data.sub, fixtures.content.userData.sub)
79-
t.is(data.name, fixtures.content.userData.name)
80-
t.deepEqual(data.scope.sort(), ['editor', 'other-app:creator', 'realm:admin'])
78+
t.is(data.credentials.sub, fixtures.content.userData.sub)
79+
t.is(data.credentials.name, fixtures.content.userData.name)
80+
t.deepEqual(data.credentials.scope.sort(), ['editor', 'other-app:creator', 'realm:admin'])
8181
})
8282

8383
test('get user data of token – default expiration', (t) => {
@@ -87,5 +87,5 @@ test('get user data of token – default expiration', (t) => {
8787

8888
t.truthy(data)
8989
t.is(data.expiresIn, 60000)
90-
t.deepEqual(data.scope.sort(), ['editor', 'other-app:creator', 'realm:admin'])
90+
t.deepEqual(data.credentials.scope.sort(), ['editor', 'other-app:creator', 'realm:admin'])
9191
})

0 commit comments

Comments
 (0)