signatur 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +73 -17
  2. package/app.js +581 -23
  3. package/lib/engines/inkscape.js +211 -30
  4. package/lib/util/auth.js +157 -0
  5. package/lib/util/config.js +48 -1
  6. package/lib/util/emojis.js +104 -0
  7. package/lib/util/index.js +4 -0
  8. package/lib/util/profile.js +26 -0
  9. package/package.json +28 -19
  10. package/static/js/bundle.js +2951 -222
  11. package/static/js/main.js +290 -8
  12. package/static/js/plugins/calligraphy.js +196 -0
  13. package/static/js/plugins/collapsible.js +2 -2
  14. package/static/js/plugins/console.js +0 -1
  15. package/static/js/plugins/diagnostics.js +160 -0
  16. package/static/js/plugins/emojis.js +265 -0
  17. package/static/js/plugins/feedback.js +147 -0
  18. package/static/js/plugins/fontsmanager.js +226 -0
  19. package/static/js/plugins/inspiration.js +4 -4
  20. package/static/js/plugins/modal.js +171 -3
  21. package/static/js/plugins/printjobs.js +1195 -0
  22. package/static/js/plugins/texteditor.js +8 -8
  23. package/static/js/plugins/viewportpreview.js +8 -0
  24. package/static/js/plugins/welcome.js +115 -38
  25. package/test/lib/smoke.js +351 -0
  26. package/test/lib/util/auth.js +78 -0
  27. package/test/lib/util/emojis.js +140 -0
  28. package/test/lib/util/profile.js +43 -0
  29. package/views/components.ejs +440 -0
  30. package/views/forbidden-pt_pt.ejs +29 -0
  31. package/views/forbidden.ejs +29 -0
  32. package/views/head.ejs +13 -0
  33. package/views/login-pt_pt.ejs +42 -0
  34. package/views/login.ejs +42 -0
  35. package/views/manager-pt_pt.ejs +1 -1
  36. package/views/manager.ejs +1 -1
  37. package/views/report-pt_pt.ejs +3 -1
  38. package/views/report.ejs +3 -1
  39. package/views/settings-pt_pt.ejs +147 -1
  40. package/views/settings.ejs +147 -1
  41. package/views/signature-pt_pt.ejs +3 -1
  42. package/views/signature.ejs +3 -1
  43. package/views/viewport-pt_pt.ejs +144 -1
  44. package/views/viewport.ejs +144 -1
  45. package/views/welcome-pt_pt.ejs +11 -3
  46. package/views/welcome.ejs +11 -3
  47. package/CHANGELOG.md +0 -307
package/README.md CHANGED
@@ -18,17 +18,26 @@ Supported file format include:
18
18
 
19
19
  ## Configuration
20
20
 
21
- | Name | Type | Default | Description |
22
- | ----------------- | ----- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
23
- | `BASE_URL` | `str` | `http://localhost:3000` | The base URL that is going to be used in the construction of external URLs for Signatur. |
24
- | `SIGNATUR_KEY` | `str` | `None` | Secret key that should be passed in protected calls so that the server side "trusts" the client side (authentication). |
25
- | `HEADLESS_URL` | `str` | `https://headless.stage.hive.pt` | The base URL to be used to access [Headless](https://github.com/hivesolutions/headless). |
26
- | `PRINT_URL` | `str` | `https://colony-print.stage.hive.pt` | Base URL of the [Colony Print](http://colony-print.hive.pt) service used for both the engraving job and the receipt printing. |
27
- | `PRINT_NODE` | `str` | `default` | Name of the Colony Print node to use when printing the report receipt. |
28
- | `PRINT_PRINTER` | `str` | `printer` | Name of the printer (within the receipt node) to use when printing the report receipt. |
29
- | `PRINT_KEY` | `str` | `null` | Secret key used to authenticate against Colony Print; shared by both the engraving job and the receipt printing. |
30
- | `ENGRAVE_NODE` | `str` | value of `PRINT_NODE` | Name of the Colony Print node to use when sending an engraving job; falls back to `PRINT_NODE` so existing single-printer deployments keep working. |
31
- | `ENGRAVE_PRINTER` | `str` | value of `PRINT_PRINTER` | Name of the printer (within the engrave node) to use when sending an engraving job; falls back to `PRINT_PRINTER` for the same backward compat reason. |
21
+ | Name | Type | Default | Description |
22
+ | --------------------- | ------ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
+ | `BASE_URL` | `str` | `http://localhost:3000` | The base URL that is going to be used in the construction of external URLs for Signatur. |
24
+ | `SESSION_SECRET` | `str` | `signatur` | HMAC signing key for the `signatur.sid` cookie-session. Comma separated to support rotation: the first entry signs new cookies, the rest still validate previously issued ones. Changing the key invalidates all live sessions. |
25
+ | `SESSION_MAX_AGE` | `int` | `15552000000` | Lifetime of the `signatur.sid` cookie in milliseconds; the default is ~6 months and the cookie is not rolling, so even active users are logged out once it elapses. |
26
+ | `SIGNATUR_KEY` | `str` | `None` | Secret key that should be passed in protected calls so that the server side "trusts" the client side (authentication). |
27
+ | `HEADLESS_URL` | `str` | `https://headless.stage.hive.pt` | The base URL to be used to access [Headless](https://github.com/hivesolutions/headless). |
28
+ | `PRINT_URL` | `str` | `https://colony-print.stage.hive.pt` | Base URL of the [Colony Print](http://colony-print.hive.pt) service used for both the engraving job and the receipt printing. |
29
+ | `PRINT_NODE` | `str` | `default` | Name of the Colony Print node to use when printing the report receipt. |
30
+ | `PRINT_PRINTER` | `str` | `printer` | Name of the printer (within the receipt node) to use when printing the report receipt. |
31
+ | `PRINT_KEY` | `str` | `null` | Secret key used to authenticate against Colony Print; shared by both the engraving job and the receipt printing. |
32
+ | `ENGRAVE_NODE` | `str` | value of `PRINT_NODE` | Name of the Colony Print node to use when sending an engraving job; falls back to `PRINT_NODE` so existing single-printer deployments keep working. |
33
+ | `ENGRAVE_PRINTER` | `str` | value of `PRINT_PRINTER` | Name of the printer (within the engrave node) to use when sending an engraving job; falls back to `PRINT_PRINTER` for the same backward compat reason. |
34
+ | `FEATURE_CALLIGRAPHY` | `bool` | `false` | Base value of the calligraphy feature flag; when set to a truthy value (`1`, `true`, `yes`, `on`) the calligraphy mode controls render on `/viewport`. May be overridden per session through the `Features` tab on `/settings`. |
35
+
36
+ ## Authentication
37
+
38
+ Every interactive route is gated behind a session login. The list of valid users lives in `config/users.json` (gitignored, with a `config/users.json.example` checked into the repository) as an array of `{ "username": "...", "password_hash": "$2a$...", "role": "admin" | "user" }` entries; the `role` controls whether the user can reach the admin-only surfaces (`/settings`, `/settings/diagnostics`, `/profiles/*`) or just the basic engraving flow.
39
+
40
+ New users are added through the `npm run user:add <username> <role> [password]` helper which prompts for the password twice (no echo) when the third positional argument is omitted, bcrypts the value at cost 10 and rewrites `config/users.json` in place; passing the password as the optional third argument skips the interactive prompts so the same helper can be driven from CI scripts or container entrypoints, while the running application picks every change up automatically through `fs.watch` so no restart is required. The bare `/login` and `/logout` routes, the `/info` endpoint, the static assets and the engine `/convert` endpoint (key authenticated through `SIGNATUR_KEY`) stay public.
32
41
 
33
42
  ## Query Parameters
34
43
 
@@ -126,6 +135,8 @@ The configuration is resolved through a three step fallback chain so existing si
126
135
 
127
136
  The settings page exposes a `Printing` readout that shows the server side base value next to the effective resolved value for each entry, so an operator can verify at a glance which side is active.
128
137
 
138
+ When the engraving job is submitted, the confirm modal walks the multifont array of the print payload, rewrites every `Cool Emojis` entry into the underlying engraving glyph name through the active `coolemojis.mapping.json` and then resolves the engraving `.f3s` payload of every referenced font through a `GET /settings/fonts/resolve?names=...` call. The resulting `{ name: base64 }` map is attached to the gravo print payload as the `extra_fonts` field that colony print plumbs through to gravo pilot on a per print job basis (see [hivesolutions/colony-print#20](https://github.com/hivesolutions/colony-print/issues/20) and [hivesolutions/gravo-pilot#22](https://github.com/hivesolutions/gravo-pilot/issues/22) for the receiving end).
139
+
129
140
  ### Configuration keys
130
141
 
131
142
  | `localStorage` key | Scenario | Server side fallback | Description |
@@ -172,13 +183,58 @@ The same configuration can also be edited through the `Configure` modal accessib
172
183
 
173
184
  ### Adding New Emoji
174
185
 
175
- To add a new emoji to the system the following steps should be followed:
186
+ To add a new emoji to the system, sign in as an admin and use the `Emojis` tab on `/settings`:
187
+
188
+ 1. Upload the replacement `coolemojis.ttf` (display) and, when the catalog of recognised characters changes, the companion `coolemojis.mapping.json`.
189
+ 2. Upload the matching engraving glyph as a `.f3s` file in the `Engraving glyphs` section. The filename must match a value declared on the mapping (e.g. `1101.coracao.f3s`).
190
+ 3. The next time the engraving viewport is opened the new glyphs are picked up automatically; shipping the `.f3s` payload to colony print on every print job through the `extra_fonts` field of the gravo print payload is tracked in #56.
191
+
192
+ The admin UI replaces the previous manual file drop. The on disk layout it owns is documented in [Font Management](#font-management).
193
+
194
+ ### Adding New Fonts
195
+
196
+ To add a new text font (Helvetica, Roman, Script, etc.) to the system, sign in as an admin and use the `Fonts` tab on `/settings`:
197
+
198
+ 1. Pick a lowercase hyphenated font name (e.g. `helvetica4l`).
199
+ 2. Upload both halves together: the display `.ttf` (browser font) and the engraving `.f3s` (engraving machine font). Both halves are required so the two surfaces stay in sync.
200
+ 3. The `Fonts` tab lists every installed font with both halves status; use the per row delete button to remove stale entries.
201
+
202
+ ## Font Management
203
+
204
+ The on disk font catalog owned by the admin UI lives under `static/fonts/`:
205
+
206
+ ```text
207
+ static/fonts/
208
+ coolemojis.ttf display, browser (Emojis tab)
209
+ coolemojis.mapping.json display to engraving bridge (Emojis tab)
210
+ helvetica4l.ttf display, browser (Fonts tab)
211
+ ...
212
+ f3s/
213
+ emoji/ engraving glyphs (Emojis tab)
214
+ 1101.coracao.f3s
215
+ ...
216
+ fonts/ engraving text fonts (Fonts tab)
217
+ helvetica4l.f3s
218
+ ...
219
+ ```
220
+
221
+ Filename invariants are validated server side:
222
+
223
+ * emoji `.f3s` files match `^[a-z0-9]+(?:[-.][a-z0-9]+)*\.f3s$` so the existing `1101.coracao` dotted form keeps working alongside a hyphenated form
224
+ * text font names match `^[a-z0-9]+(?:-[a-z0-9]+)*$` so both halves land at the canonical `<name>.ttf` and `<name>.f3s` paths
225
+
226
+ The following HTTP endpoints back the UI. Every entry is gated by `lib.requireAdmin` except the resolver at the bottom, which is callable by any signed in user so the print confirm modal can attach the engraving payloads to the print envelope without elevating privileges:
176
227
 
177
- 1. Determine the right file name for the new emoji font file (e.g. `coolemojis.ttf` for laser and `coolemojisp.ttf` for pantogrpah)
178
- 2. Place the new font file in the `static/fonts` directory
179
- 3. Add the new emoji "characters" to the `emoji` array in the `viewport.ejs` file
180
- 4. Test the using the local machine `yarn && yarn dev`
181
- 5. Release a new version of the system (Docker Image)
228
+ | Method | Path | Notes |
229
+ | ------ | ------------------------------------------ | --------------------------------------------------------------------------------------------- |
230
+ | `POST` | `/settings/emojis` | Replace the Cool Emojis `.ttf` and, optionally, the companion mapping JSON. |
231
+ | `GET` | `/settings/emojis/f3s` | List installed emoji engraving glyphs as `{ fonts: [{ name, size, mtime }, ...] }`. |
232
+ | `POST` | `/settings/emojis/f3s` | Upload one emoji engraving glyph; form fields are `filename` plus the `file` payload. |
233
+ | `POST` | `/settings/emojis/f3s/:filename/delete` | Delete one emoji engraving glyph by filename. |
234
+ | `GET` | `/settings/fonts` | List installed text fonts as `{ fonts: [{ name, ttf, f3s }, ...] }` rows. |
235
+ | `POST` | `/settings/fonts` | Upload one paired text font; form fields are `name` plus the `ttf` and `f3s` file payloads. |
236
+ | `POST` | `/settings/fonts/:name/delete` | Delete both halves of a text font by canonical name. |
237
+ | `GET` | `/settings/fonts/resolve?names=a,b,c` | Resolve font names into a `{ fonts: { name: base64 } }` engraving payload map. |
182
238
 
183
239
  ## License
184
240