{"_id":"hof-behaviour-session","_rev":"57-96333484e3a86dd4488aa7b18b1c18aa","name":"hof-behaviour-session","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"hof-behaviour-session","version":"1.0.0","author":{"name":"UKHomeOfficeForms"},"license":"MIT","_id":"hof-behaviour-session@1.0.0","maintainers":[{"name":"joefitter","email":"hello@joefitter.com"}],"homepage":"https://github.com/UKHomeOfficeForms/hof-behaviour-session#readme","bugs":{"url":"https://github.com/UKHomeOfficeForms/hof-behaviour-session/issues"},"dist":{"shasum":"98b1cc5b9c2f450fb89e3b88c8bee3de9ee9c73e","tarball":"https://registry.npmjs.org/hof-behaviour-session/-/hof-behaviour-session-1.0.0.tgz","integrity":"sha512-bTj3x9W+/Du9tGyA0r1+10s1F0ppphidqcipCh96ekNGTV0a6RiddeEga2OR8BFvYrbx2aGl6Ac6NxFmDpIEPQ==","signatures":[{"sig":"MEYCIQConrDbw4RrnwyVX5tysPY7WvKeQbp0Uvhg6DQwVUY0egIhAKzuu6MS9TY3JsWPaXdOQOafKybNnKoOFSPFplLuQdis","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"98b1cc5b9c2f450fb89e3b88c8bee3de9ee9c73e","gitHead":"43fd80d67ebe0a20b959706255f2d6b766fdbd82","scripts":{"test":"npm run test:lint && npm run test:unit","test:lint":"eslint .","test:unit":"istanbul cover _mocha"},"_npmUser":{"name":"joefitter","email":"hello@joefitter.com"},"deprecated":"DEPRECATED, this is built into hof v19 <(^_^)> & should not be installed separately","repository":{"url":"git+https://github.com/UKHomeOfficeForms/hof-behaviour-session.git","type":"git"},"_npmVersion":"3.10.10","description":"HOF Behaviour for reading and writing to the session","directories":{},"_nodeVersion":"6.2.2","dependencies":{"lodash":"^4.17.4","express":"^4.14.1"},"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0","sinon":"^1.17.7","eslint":"^3.15.0","reqres":"^1.2.2","istanbul":"^0.4.5","hof-model":"^2.1.0","proxyquire":"^1.7.11","sinon-chai":"^2.8.0","hof-form-controller":"^2.0.0","eslint-config-homeoffice":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/hof-behaviour-session-1.0.0.tgz_1486651941024_0.24672476178966463","host":"packages-12-west.internal.npmjs.com"}},"1.0.1":{"name":"hof-behaviour-session","version":"1.0.1","author":{"name":"UKHomeOfficeForms"},"license":"MIT","_id":"hof-behaviour-session@1.0.1","maintainers":[{"name":"joefitter","email":"hello@joefitter.com"}],"homepage":"https://github.com/UKHomeOfficeForms/hof-behaviour-session#readme","bugs":{"url":"https://github.com/UKHomeOfficeForms/hof-behaviour-session/issues"},"dist":{"shasum":"cedc173ffab3377137b077575c51f5d416390e15","tarball":"https://registry.npmjs.org/hof-behaviour-session/-/hof-behaviour-session-1.0.1.tgz","integrity":"sha512-toDeWcb8qdc58OtykrT/lVkDE/Rc/jhUoBatTR9coiJU/yWTTeOYOl7DNSUO9MJ/8/iA2BVA0zL4Bcig8I6RLw==","signatures":[{"sig":"MEUCIQCaQrwzwAp1BV7quXpnYqRnq3CbXeZxmjJCZRHFF+4OEQIgV1qjZsjagWkh0kr4ODQI9vL8MckEzHNtp2/WoAu640w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"cedc173ffab3377137b077575c51f5d416390e15","gitHead":"2f9067e33b185c18db2ff7ce42774230d726516a","scripts":{"test":"npm run test:lint && npm run test:unit","test:lint":"eslint .","test:unit":"istanbul cover _mocha"},"_npmUser":{"name":"lennym","email":"leonard.martin@gmail.com"},"deprecated":"DEPRECATED, this is built into hof v19 <(^_^)> & should not be installed separately","repository":{"url":"git+https://github.com/UKHomeOfficeForms/hof-behaviour-session.git","type":"git"},"_npmVersion":"4.5.0","description":"HOF Behaviour for reading and writing to the session","directories":{},"_nodeVersion":"6.9.4","dependencies":{"lodash":"^4.17.4","express":"^4.15.2"},"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0","sinon":"^1.17.7","eslint":"^3.15.0","reqres":"^1.2.2","istanbul":"^0.4.5","hof-model":"^2.1.0","proxyquire":"^1.7.11","sinon-chai":"^2.8.0","hof-form-controller":"^2.0.0","eslint-config-homeoffice":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/hof-behaviour-session-1.0.1.tgz_1493319131826_0.9849953879602253","host":"packages-12-west.internal.npmjs.com"}}},"time":{"created":"2017-02-09T14:52:22.867Z","modified":"2026-09-21T15:12:47.651Z","1.0.0":"2017-02-09T14:52:22.867Z","1.0.1":"2017-04-27T18:52:13.810Z"},"bugs":{"url":"https://github.com/UKHomeOfficeForms/hof-behaviour-session/issues"},"author":{"name":"UKHomeOfficeForms"},"license":"MIT","homepage":"https://github.com/UKHomeOfficeForms/hof-behaviour-session#readme","repository":{"url":"git+https://github.com/UKHomeOfficeForms/hof-behaviour-session.git","type":"git"},"description":"HOF Behaviour for reading and writing to the session","maintainers":[{"email":"aaron.russell@digital.homeoffice.gov.uk","name":"aaronrussellho"},{"email":"sas-hof-test@digital.homeoffice.gov.uk","name":"hof-bot-user"},{"email":"dk4g.blob@gmail.com","name":"dk4g"},{"email":"gregory.wolverson@digital.homeoffice.gov.uk","name":"greg_wolverson_ho"},{"email":"vinodha.samiyappan@digital.homeoffice.gov.uk","name":"vinodha.s"},{"email":"megan.john@digital.homeoffice.gov.uk","name":"meganjohn"},{"email":"nese.zorba@digital.homeoffice.gov.uk","name":"nzorba"},{"email":"rayhannur.rohman@digital.homeoffice.gov.uk","name":"rayhannurrohmanho"},{"email":"vivek.kumar1@digital.homeoffice.gov.uk","name":"vivekkumar-ho"},{"email":"hello@joefitter.com","name":"joefitter"}],"readme":"#hof-behaviour-session\n\nHOF Behaviour for reading and writing to the session\n\n##Usage\n\n###With [mixwith.js](https://github.com/justinfagnani/mixwith.js)\n\n```js\nconst mix = require('mixwith').mix;\nconst Session = require('hof-behaviour-session');\nconst BaseController = require('hof-form-controller');\n\nclass MyController extends mix(BaseController).with(Session) {\n  ...\n}\n```\n`MyController` now extends `hof-form-controller` and has `hof-behaviour-session` functionality mixed in.\n\n##Functionality\n\nThis mixin extends `hof-form-controller` by persisting the form data to the `sessionModel` - assuming the [session-model](https://github.com/UKHomeOfficeForms/hof-form-wizard/blob/master/lib/middleware/session-model.js) middleware has been applied.\n\nThe following form controller methods are used:\n\n* `getValues(req, res, cb)` - calls callback with `null` and a map of all items in the `sessionModel`, extended with `errorValues` - to persist entered values on current step if validation fails\n* `saveValues(req, res, cb)` - Called on success. Sets all step fields in `req.form.values` to the sessionModel, unsets `errorValues`.\n* `getErrors(req)` - returns all errors for fields on the current step (`req.form.options.fields`), excluding redirects. Set to `req.form.errors` in `hof-form-controller`.\n* `setErrors(err, req)` - called on validation error(s). Sets the current step field values as `errorValues` in sessionModel to be used in `getValues`. Sets `errors` to sessionModel - a map of `field-name: error` to be used in `getErrors`.\n* `locals(req, res)` - Extends the result of `super.locals` with `baseUrl` (`req.baseUrl`) and `nextPage` (the result of `this.getNextStep(req, res)`).\n* `missingPrereqHandler(req, res)` - Error handler called when a `MISSING_PREREQ` error is thrown from the [check-progress](https://github.com/UKHomeOfficeForms/hof-form-wizard/blob/master/lib/middleware/check-progress.js) middleware. This occurs if a step is visited out of sequence. This error handler causes the user to be redirected to the last completed step, or the first step if none have been completed.\n* `errorHandler(err, req, res, next)` - checks if `err.code` is `MISSING_PREREQ`, if so calls `missingPrereqHandler`, if not calls `super` to hand over to parent error handler.\n","readmeFilename":"README.md"}