bump package version to 1.5.0
[squeep-authentication-module] / lib / template / ia-html.js
index 5de476ae04b880d2d94e6e3b1bd3db359aee2095..d3508e1466ce01c54e71833b9749c0cfdcd0d021 100644 (file)
@@ -1,10 +1,23 @@
 'use strict';
 
 const { TemplateHelper: th } = require('@squeep/html-template-helper');
+const { sessionNavLinks } = require('./helpers');
+
+/**
+ * @alias {object} Context
+ */
+
+/**
+ * @alias {object} HtmlOptions
+ */
+
+/**
+ * @typedef {import('../session-manager').AppTemplateCallback} AppTemplateCallback
+ */
 
 /**
  *
- * @returns {String}
+ * @returns {string[]} section
  */
 function mainContent() {
   return [
@@ -14,19 +27,22 @@ function mainContent() {
   ];
 }
 
+
 /**
  * Render any errors from attempting IndieAuth.
- * @param {Object} ctx
- * @param {String[]} ctx.errors
- * @param {Object} options
- * @param {Object} options.manager
- * @param {String} options.manager.pageTitle
- * @param {Object} options.dingus
- * @param {String} options.dingus.selfBaseUrl
- * @returns {String}
+ * @param {Context} ctx context
+ * @param {object} options options
+ * @param {object} options.manager manager options
+ * @param {string} options.manager.pageTitle page title
+ * @param {object} options.dingus dingus options
+ * @param {string} options.dingus.selfBaseUrl base url
+ * @param {AppTemplateCallback} appCb function to mogrify htmlOptions
+ * @returns {string} page
  */
-module.exports = (ctx, options) => {
+module.exports = (ctx, options, appCb = () => {}) => {
+  const pagePathLevel = 1;
   const htmlOptions = {
+    pageIdentifier: 'indieAuthError',
     pageTitle: options.manager.pageTitle,
     logoUrl: options.manager.logoUrl,
     footerEntries: options.manager.footerEntries,
@@ -34,11 +50,14 @@ module.exports = (ctx, options) => {
       '<p>Problems were encountered while trying to authenticate your profile URL.</p>',
     ],
   };
+  appCb(pagePathLevel, ctx, htmlOptions);
+  sessionNavLinks(pagePathLevel, ctx, htmlOptions);
+
   // Ensure there is always an error to report, even if we do not have one, as we ended up here somehow.
   if (!ctx?.errors?.length) {
     ctx.errors = [
       'Unknown Error &mdash; we are not sure what just happened',
     ];
   }
-  return th.htmlPage(2, ctx, htmlOptions, mainContent());
+  return th.htmlPage(pagePathLevel, ctx, htmlOptions, mainContent());
 };
\ No newline at end of file