X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=src%2Ftemplate%2Fauthorization-request-html.js;h=b23fb9207665077ce54743e39563ff3fe2b9e4a8;hb=f0bf29c75b0fd405ff92fa76f058e61162b87e43;hp=3e312af683721642a18357b1a6e99084aa98daca;hpb=b0103b0d496262c438b40bc20304081dbfe41e73;p=squeep-indie-auther
diff --git a/src/template/authorization-request-html.js b/src/template/authorization-request-html.js
index 3e312af..b23fb92 100644
--- a/src/template/authorization-request-html.js
+++ b/src/template/authorization-request-html.js
@@ -1,16 +1,16 @@
'use strict';
const th = require('./template-helper');
-
+const { sessionNavLinks } = require('@squeep/authentication-module');
/**
- * @param {Object} hApp
- * @param {Object} hApp.properties
- * @param {String[]=} hApp.properties.url
- * @param {String[]=} hApp.properties.summary
- * @param {String[]=} hApp.properties.logo
- * @param {String[]=} hApp.properties.name
- * @returns {String}
+ * @param {object} hApp client identifier h-app
+ * @param {object} hApp.properties properties
+ * @param {string[]=} hApp.properties.url url
+ * @param {string[]=} hApp.properties.summary summary
+ * @param {string[]=} hApp.properties.logo logo
+ * @param {string[]=} hApp.properties.name name
+ * @returns {string} span
*/
function renderClientIdentifierProperties(hApp) {
const properties = hApp.properties || {};
@@ -19,13 +19,13 @@ function renderClientIdentifierProperties(hApp) {
const { url, summary, logo, name } = properties;
parts.push('');
- if (url && url.length) {
+ if (url?.length) {
parts.push(``);
}
- if (summary && summary.length) {
+ if (summary?.length) {
imgTitle = ` title="${summary[0]}"`;
}
- if (logo && logo.length) {
+ if (logo?.length) {
let src, alt;
if (typeof logo[0] === 'string') {
src = logo[0];
@@ -35,10 +35,10 @@ function renderClientIdentifierProperties(hApp) {
}
parts.push(``);
}
- if (name && name.length) {
+ if (name?.length) {
parts.push(properties['name'][0]);
}
- if (url && url.length) {
+ if (url?.length) {
parts.push('');
}
parts.push('');
@@ -47,20 +47,20 @@ function renderClientIdentifierProperties(hApp) {
/**
- * @param {Object} clientIdentifier
- * @param {Object[]} clientIdentifier.items
- * @returns {String}
+ * @param {object} clientIdentifier client identifier
+ * @param {object[]} clientIdentifier.items items
+ * @returns {string} spans
*/
function renderClientIdentifier(clientIdentifier) {
- const hAppEntries = clientIdentifier && clientIdentifier.items || [];
+ const hAppEntries = clientIdentifier?.items || [];
return hAppEntries.map(renderClientIdentifierProperties).join('');
}
/**
- * @param {String} profile
- * @param {Boolean} selected
- * @returns {String}
+ * @param {string} profile profile
+ * @param {boolean} selected is selected
+ * @returns {string} option
*/
function renderProfileOption(profile, selected) {
return ``;
@@ -68,13 +68,13 @@ function renderProfileOption(profile, selected) {
/**
- * @param {String[]} availableProfiles
- * @param {String} hintProfile
- * @returns {String}
+ * @param {string[]} availableProfiles profiles
+ * @param {string} hintProfile profile
+ * @returns {string} fieldset
*/
function renderProfileFieldset(availableProfiles, hintProfile) {
if (!availableProfiles || availableProfiles.length <= 1) {
- const profile = availableProfiles && availableProfiles[0] || hintProfile;
+ const profile = availableProfiles?.[0] || hintProfile;
return ``;
}
return `
@@ -93,12 +93,16 @@ ${availableProfiles.map((profile) => renderProfileOption(profile, profile === hi
/**
- * @param {ScopeDetails} scope
- * @param {String} scope.scope
- * @param {String} scope.description
- * @param {String[]} scope.profiles
- * @param {Boolean} checked
- * @returns {String}
+ * @typedef {object} ScopeDetails
+ * @property {string} scope scope
+ * @property {string} description description
+ * @property {string[]} profiles profiles
+ */
+
+/**
+ * @param {ScopeDetails} scope scope details
+ * @param {boolean} checked is checked
+ * @returns {string} scope li
*/
function renderScopeCheckboxLI(scope, checked) {
let scopeDescription;
@@ -109,21 +113,26 @@ function renderScopeCheckboxLI(scope, checked) {
scopeDescription = '';
}
let profileClass;
- if (scope.profiles && scope.profiles.length) {
- profileClass = ['profile-scope'].concat(scope.profiles.map((profile) => th.escapeCSS(profile))).join(' ');
+ if (scope.profiles?.length) {
+ profileClass = ['profile-scope'].concat(scope.profiles).join(' ');
} else {
profileClass = '';
}
return `