Skip to content

Commit 944b9e2

Browse files
Add helper method issuePoPTokenFor()
1 parent bb8628d commit 944b9e2

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727
'use strict'
2828
const RelyingParty = require('@trust/oidc-rp')
29+
const PoPToken = require('@trust/oidc-rp/lib/PoPToken')
2930
const providerSelectPopupSource = require('./provider-select-popup')
3031

3132
// URI parameter types
@@ -388,6 +389,10 @@ class ClientAuthOIDC {
388389
return this.sendAuthRequest(client)
389390
}
390391

392+
issuePoPTokenFor (uri, session) {
393+
return PoPToken.issueFor(uri, session)
394+
}
395+
391396
/**
392397
* Validates the auth response in the current uri, initializes the current
393398
* user's ID Token and Access token, and returns the user's WebID

test/auth.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ chai.should()
1717
const expect = chai.expect
1818

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

2122
describe('SolidAuthOIDC', () => {
2223
var auth
@@ -494,4 +495,25 @@ describe('SolidAuthOIDC', () => {
494495
expect(url).to.equal('https://example.com/')
495496
})
496497
})
498+
499+
describe('issuePoPTokenFor()', () => {
500+
before(() => {
501+
sinon.stub(PoPToken, 'issueFor').resolves()
502+
})
503+
504+
after(() => {
505+
PoPToken.issueFor.restore()
506+
})
507+
508+
it('should invoke PoPToken.issueFor', () => {
509+
let auth = new SolidAuthOIDC()
510+
let uri = 'https://rs.com'
511+
let session = {}
512+
513+
return auth.issuePoPTokenFor(uri, session)
514+
.then(() => {
515+
expect(PoPToken.issueFor).to.have.been.calledWith(uri, session)
516+
})
517+
})
518+
})
497519
})

0 commit comments

Comments
 (0)