Skip to content

Commit

Permalink
fix: interaction uid is now an alias to its jti, it is not stored any…
Browse files Browse the repository at this point in the history
…more either
  • Loading branch information
panva committed Mar 24, 2021
1 parent 41f4cd8 commit 2d85768
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion example/my_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class MyAdapter {
* - kind {string} - "Interaction" fixed string value
* - exp {number} - timestamp of the interaction's expiration
* - iat {number} - timestamp of the interaction's creation
* - uid {string} - the uid of the authorizing client's established session
* - returnTo {string} - after resolving interactions send the user-agent to this url
* - deviceCode {string} - [DeviceCode user flows only] deviceCode reference
* - params {object} - parsed recognized parameters object
Expand Down
1 change: 0 additions & 1 deletion lib/actions/authorization/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ module.exports = async function interactions(resumeRouteName, ctx, next) {
prompt,
lastSubmission: oidc.result,
accountId: oidc.session.accountId,
uid,
params: oidc.params.toPlainObject(),
trusted: oidc.trusted,
session: oidc.session,
Expand Down
15 changes: 11 additions & 4 deletions lib/models/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const epochTime = require('../helpers/epoch_time');
const hasFormat = require('./mixins/has_format');

module.exports = (provider) => class Interaction extends hasFormat(provider, 'Interaction', instance(provider).BaseModel) {
constructor(id, payload) {
constructor(jti, payload) {
if (arguments.length === 2) {
if (payload.session instanceof instance(provider).BaseModel) {
const { session } = payload;
Expand All @@ -26,12 +26,20 @@ module.exports = (provider) => class Interaction extends hasFormat(provider, 'In
}
}

super({ ...payload, jti: id });
super({ jti, ...payload });
} else {
super(id);
super(jti);
}
}

get uid() {
return this.jti;
}

set uid(value) {
this.jti = value;
}

async save(ttl) {
if (typeof ttl !== 'number') {
throw new TypeError('"ttl" argument must be a number');
Expand All @@ -56,7 +64,6 @@ module.exports = (provider) => class Interaction extends hasFormat(provider, 'In
'returnTo',
'signed',
'grantId',
'uid',
'lastSubmission',
'deviceCode',
];
Expand Down
2 changes: 1 addition & 1 deletion test/configuration/interaction_url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('pathFor related behaviors', () => {
},
});

const url = await i(provider).configuration('interactions.url')({}, { uid: 'foobar' });
const url = await i(provider).configuration('interactions.url')({}, new provider.Interaction('foobar', {}));

expect(url).to.equal('/interaction/foobar');
});
Expand Down

0 comments on commit 2d85768

Please sign in to comment.