Skip to content

Commit

Permalink
Merge pull request #10 from solid/bump-rp-dep
Browse files Browse the repository at this point in the history
Update oidc-rp dep to 0.4.1
  • Loading branch information
dmitrizagidulin authored Aug 14, 2017
2 parents f977241 + 944b9e2 commit 333879f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false
language: node_js
node_js:
- ">=7.0"
- ">=6.0"

cache:
directories:
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "solid-auth-oidc",
"version": "0.1.3",
"engines": {
"node": ">= 7.0"
"node": ">= 6.0"
},
"description": "Authentication library for Solid client based on OAuth2/OpenID Connect",
"main": "./lib/index.js",
Expand Down Expand Up @@ -56,7 +56,7 @@
},
"homepage": "https://github.com/solid/solid-auth-oidc",
"dependencies": {
"oidc-rp": "git://github.com/anvilresearch/oidc-rp.git#rc-005"
"@trust/oidc-rp": "^0.4.1"
},
"devDependencies": {
"babel-cli": "^6.24.1",
Expand All @@ -72,7 +72,8 @@
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"standard": "^10.0.2",
"webpack": "^2.5.1"
"webpack": "^2.5.1",
"whatwg-url": "^6.1.0"
},
"standard": {
"globals": [
Expand Down
12 changes: 9 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
https://github.com/solid/solid
*/
'use strict'
const RelyingParty = require('oidc-rp')
const RelyingParty = require('@trust/oidc-rp')
const PoPToken = require('@trust/oidc-rp/lib/PoPToken')
const providerSelectPopupSource = require('./provider-select-popup')

// URI parameter types
Expand Down Expand Up @@ -388,6 +389,10 @@ class ClientAuthOIDC {
return this.sendAuthRequest(client)
}

issuePoPTokenFor (uri, session) {
return PoPToken.issueFor(uri, session)
}

/**
* Validates the auth response in the current uri, initializes the current
* user's ID Token and Access token, and returns the user's WebID
Expand All @@ -401,8 +406,9 @@ class ClientAuthOIDC {
initUserFromResponse (client) {
return client.validateResponse(this.currentLocation(), this.store)
.then(response => {
this.idToken = response.params.id_token
this.accessToken = response.params.access_token
this.idToken = response.idToken
this.accessToken = response.accessToken
this.session = response

this.clearAuthResponseFromUrl()

Expand Down
26 changes: 24 additions & 2 deletions test/auth.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

global.URL = require('url').URL
global.URLSearchParams = require('url').URLSearchParams
global.URL = require('whatwg-url').URL
global.URLSearchParams = require('whatwg-url').URLSearchParams

const localStorage = require('localstorage-memory')

Expand All @@ -17,6 +17,7 @@ chai.should()
const expect = chai.expect

const SolidAuthOIDC = require('../src/index')
const PoPToken = require('@trust/oidc-rp/lib/PoPToken')

describe('SolidAuthOIDC', () => {
var auth
Expand Down Expand Up @@ -494,4 +495,25 @@ describe('SolidAuthOIDC', () => {
expect(url).to.equal('https://example.com/')
})
})

describe('issuePoPTokenFor()', () => {
before(() => {
sinon.stub(PoPToken, 'issueFor').resolves()
})

after(() => {
PoPToken.issueFor.restore()
})

it('should invoke PoPToken.issueFor', () => {
let auth = new SolidAuthOIDC()
let uri = 'https://rs.com'
let session = {}

return auth.issuePoPTokenFor(uri, session)
.then(() => {
expect(PoPToken.issueFor).to.have.been.calledWith(uri, session)
})
})
})
})
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules)/,
query: {
presets: ['es2015']
}
Expand All @@ -25,7 +26,7 @@ module.exports = {
'node-fetch': 'fetch',
'text-encoding': 'TextEncoder',
'urlutils': 'URL',
'webcrypto': 'crypto'
'@trust/webcrypto': 'crypto'
},
devtool: 'source-map'
}

0 comments on commit 333879f

Please sign in to comment.