a0475adc09122d0f9f29dd2b5629b5cc6bc612d5
4 * This renders the interface for submitting a ticket proffer to a third-party.
7 const th
= require('./template-helper');
8 const { sessionNavLinks
} = require('@squeep/authentication-module');
11 function renderProfileOption(profile
) {
12 return `<option value="${profile}">${profile}</option>`;
15 function renderScopeCheckboxTR(scope
) {
16 const defaultChecked
= ['read'];
17 const checked
= defaultChecked
.includes(scope
) ? ' checked' : '';
18 return `<tr class="scope">
19 \t<td><input type="checkbox" id="scopes-${scope}" name="scopes[]" value="${scope}"${checked}></td>
24 function mainContent(ctx
) {
25 const profileOptions
= th
.indented(4, (ctx
?.profilesScopes
?.profiles
|| []).map((profile
) => renderProfileOption(profile
)))
27 const elideScopes
= ['profile', 'email'];
28 const allScopes
= Object
.keys(ctx
?.profilesScopes
?.scopeIndex
|| {});
29 const displayScopes
= (allScopes
).filter((scope
) => !elideScopes
.includes(scope
));
30 const scopesCheckboxRows
= th
.indented(5, displayScopes
.map((scope
) => renderScopeCheckboxTR(scope
)))
33 \t<form method="POST">
35 \t\t\tYou may proactively send a ticket to a third-party site,
36 \t\t\twhich they may redeem for an access token which grants additional
37 \t\t\taccess to the specified resource.
41 \t\t\t<legend>Proffer A Ticket</legend>
42 \t\t\t<label for="profile-select">Profile Granting this Ticket</label>
43 \t\t\t<select id="profile-select" name="profile">
47 \t\t\t<label for="resource-url">Resource URL:</label>
48 \t\t\t<input type="url" id="resource-url" name="resource" size="96">
50 \t\t\t<label for="recipient-url">Recipient URL:</label>
51 \t\t\t<input type="url" id="recipient-url" name="subject" size="96">
54 <legend>Scopes</legend>
62 \t\t\t<label for="scopes-adhoc">Additional Scopes (space separated):</label>
63 \t\t\t<input type="text" id="scopes-adhoc" name="adhoc" size="96">
65 \t\t\t<button type="submit" name="action" value="proffer-ticket">Send Ticket</button>
75 * @param {Object} ctx.profilesScopes.scopeIndex
76 * @param {String[]} ctx.profileScopes.profiles
77 * @param {Object} options
78 * @param {Object} options.manager
79 * @param {String} options.manager.pageTitle
80 * @param {String} options.manager.logoUrl
81 * @param {String[]} options.manager.footerEntries
84 module
.exports
= (ctx
, options
) => {
85 const pagePathLevel
= 1;
87 padeIdentifier: 'ticketProffer',
88 pageTitle: options
.manager
.pageTitle
+ ' - Ticket Proffer',
89 logoUrl: options
.manager
.logoUrl
,
90 footerEntries: options
.manager
.footerEntries
,
91 errorContent: ['Unable to send ticket.'],
93 th
.navLinks(pagePathLevel
, ctx
, htmlOptions
);
94 sessionNavLinks(pagePathLevel
, ctx
, htmlOptions
);
98 return th
.htmlPage(pagePathLevel
, ctx
, htmlOptions
, content
);