492c40d1dfc3d4fba87a0936cff1883359ed8cc1
4 * This renders the interface for submitting a ticket proffer to a third-party.
7 const th
= require('./template-helper');
10 function renderProfileOption(profile
) {
11 return `<option value="${profile}">${profile}</option>`;
14 function renderScopeCheckboxTR(scope
) {
15 const defaultChecked
= ['read'];
16 const checked
= defaultChecked
.includes(scope
) ? ' checked' : '';
17 return `<tr class="scope">
18 \t<td><input type="checkbox" id="scopes-${scope}" name="scopes" value="${scope}"${checked}></td>
23 function mainContent(ctx
) {
24 const profileOptions
= th
.indented(4, (ctx
?.profilesScopes
?.profiles
|| []).map((profile
) => renderProfileOption(profile
)))
26 const elideScopes
= ['profile', 'email'];
27 const allScopes
= Object
.keys(ctx
?.profilesScopes
?.scopeIndex
|| {});
28 const displayScopes
= (allScopes
).filter((scope
) => !elideScopes
.includes(scope
));
29 const scopesCheckboxRows
= th
.indented(4, displayScopes
.map((scope
) => renderScopeCheckboxTR(scope
)))
32 \t<form action="" method="POST">
34 \t\t\tYou may proactively send a ticket to a third-party site,
35 \t\t\twhich they may redeem for an access token which grants additional
36 \t\t\taccess to the specified resource.
40 \t\t\t<legend>Proffer A Ticket</legend>
41 \t\t\t<label for="profile-select">Profile Granting this Ticket</label>
42 \t\t\t<select id="profile-select" name="profile">
46 \t\t\t<label for="resource-url">Resource URL:</label>
47 \t\t\t<input type="url" id="resource-url" name="resource" size="96">
49 \t\t\t<label for="recipient-url">Recipient URL:</label>
50 \t\t\t<input type="url" id="recipient-url" name="subject" size="96">
53 <legend>Scopes</legend>
59 \t\t\t<label for="scopes-adhoc">Additional Scopes (space separated):</label>
60 \t\t\t<input type="text" id="scopes-adhoc" name="adhoc" size="96">
62 \t\t\t<button name="action" value="proffer-ticket">Send Ticket</button>
72 * @param {Object} ctx.profilesScopes.scopeIndex
73 * @param {String[]} ctx.profileScopes.profiles
74 * @param {Object} options
75 * @param {Object} options.manager
76 * @param {String} options.manager.pageTitle
77 * @param {String} options.manager.logoUrl
78 * @param {String[]} options.manager.footerEntries
81 module
.exports
= (ctx
, options
) => {
83 pageTitle: options
.manager
.pageTitle
+ ' - Ticket Proffer',
84 logoUrl: options
.manager
.logoUrl
,
85 footerEntries: options
.manager
.footerEntries
,
92 errorContent: ['Unable to send ticket.'],
97 return th
.htmlPage(2, ctx
, htmlOptions
, content
);