signatur 0.1.0 → 1.1.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.
- package/README.md +184 -1
- package/app.js +991 -4
- package/lib/engines/engine.js +7 -3
- package/lib/engines/inkscape.js +321 -2
- package/lib/util/auth.js +157 -0
- package/lib/util/base.js +63 -3
- package/lib/util/config.js +72 -8
- package/lib/util/date.js +25 -0
- package/lib/util/index.js +8 -0
- package/lib/util/locale.js +16 -0
- package/lib/util/profile.js +679 -0
- package/package.json +45 -18
- package/static/js/bundle.js +5695 -0
- package/static/js/jSignature.min.js +81 -0
- package/static/js/main.js +1802 -0
- package/static/js/plugins/calligraphy.js +196 -0
- package/static/js/plugins/collapsible.js +51 -0
- package/static/js/plugins/console.js +33 -0
- package/static/js/plugins/diagnostics.js +160 -0
- package/static/js/plugins/feedback.js +147 -0
- package/static/js/plugins/fonts.js +37 -0
- package/static/js/plugins/inspiration.js +303 -0
- package/static/js/plugins/jsonhighlight.js +127 -0
- package/static/js/plugins/keyboard.js +166 -0
- package/static/js/plugins/modal.js +352 -0
- package/static/js/plugins/profilemanager.js +896 -0
- package/static/js/plugins/profileselector.js +148 -0
- package/static/js/plugins/texteditor.js +632 -0
- package/static/js/plugins/toast.js +28 -0
- package/static/js/plugins/viewportpreview.js +256 -0
- package/static/js/plugins/welcome.js +210 -0
- package/static/js/util.js +134 -0
- package/test/lib/smoke.js +322 -0
- package/test/lib/util/auth.js +78 -0
- package/test/lib/util/base.js +81 -0
- package/test/lib/util/locale.js +19 -0
- package/test/lib/util/profile.js +966 -0
- package/views/console-pt_pt.ejs +26 -0
- package/views/console.ejs +26 -0
- package/views/forbidden-pt_pt.ejs +29 -0
- package/views/forbidden.ejs +29 -0
- package/views/gateway-pt_pt.ejs +106 -0
- package/views/gateway.ejs +106 -0
- package/views/head.ejs +65 -0
- package/views/layout.ejs +1 -0
- package/views/login-pt_pt.ejs +42 -0
- package/views/login.ejs +42 -0
- package/views/manager-pt_pt.ejs +204 -0
- package/views/manager.ejs +204 -0
- package/views/receipt-pt_pt.ejs +18 -0
- package/views/receipt.ejs +18 -0
- package/views/report-pt_pt.ejs +101 -0
- package/views/report.ejs +102 -0
- package/views/settings-pt_pt.ejs +251 -0
- package/views/settings.ejs +251 -0
- package/views/signature-pt_pt.ejs +28 -0
- package/views/signature.ejs +28 -0
- package/views/text-pt_pt.ejs +13 -0
- package/views/text.ejs +13 -0
- package/views/viewport-pt_pt.ejs +569 -0
- package/views/viewport.ejs +569 -0
- package/views/welcome-pt_pt.ejs +95 -0
- package/views/welcome.ejs +95 -0
package/README.md
CHANGED
|
@@ -4,12 +4,195 @@ Simple vector signature service to be used to convert signatures.
|
|
|
4
4
|
|
|
5
5
|
Signatures from the client-side into beautiful files ready to be downloaded.
|
|
6
6
|
|
|
7
|
+
Supported file format include:
|
|
8
|
+
|
|
9
|
+
* [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) - Scalable Vector Graphics
|
|
10
|
+
* [PDF](https://en.wikipedia.org/wiki/PDF) - Portable Document Format
|
|
11
|
+
* [HPGL](https://en.wikipedia.org/wiki/HP-GL) - Hewlett-Packard Graphics Language
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
* Canvas based drawing, to be used in signatures
|
|
16
|
+
* Viewport for drawing of text and emoji
|
|
17
|
+
* Uses [canvas2svg](http://gliffy.github.io/canvas2svg) for SVG output
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
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. |
|
|
32
|
+
| `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`. |
|
|
33
|
+
|
|
34
|
+
## Authentication
|
|
35
|
+
|
|
36
|
+
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.
|
|
37
|
+
|
|
38
|
+
New users are added through the `npm run user:add <username> <role>` helper which prompts for the password twice (no echo), bcrypts it at cost 10 and rewrites `config/users.json` in place; the running application picks the 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.
|
|
39
|
+
|
|
40
|
+
## Query Parameters
|
|
41
|
+
|
|
42
|
+
The following query parameters are honored by the Signatur HTTP routes. Most of the session level toggles (`theme`, `locale`, `text`, `fullscreen`, etc.) are persisted to the cookie session on first sight and then read from the session on every subsequent request, so they never need to be carried around through the URL once they have been set. The viewport editor still round-trips its visual state through the URL so a `/viewport` link can be shared or bookmarked verbatim, but those keys are scoped to the viewport page and are not propagated to other sections.
|
|
43
|
+
|
|
44
|
+
### Session persistence
|
|
45
|
+
|
|
46
|
+
| Parameter | Session-persisted | Notes |
|
|
47
|
+
| --------------- | :---------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| `theme` | yes | Written to `req.session.theme` on every page that reads it except `/console`, which reads but does not write. |
|
|
49
|
+
| `locale` | yes | Written to `req.session.locale` on every page that reads it. |
|
|
50
|
+
| `text` | yes | Written to `req.session.config.text` on every page that reads it. |
|
|
51
|
+
| `fullscreen` | yes | Written to `req.session.fullscreen` on every page that reads it; the URL query is honored first as a one-shot override and otherwise the session takes over. |
|
|
52
|
+
| `home` | yes | Set via the `/settings` POST body. Controls whether `/` redirects to `/gateway` (default) or `/welcome`. |
|
|
53
|
+
| `show_options` | yes | Set via the `/settings` POST body. Controls whether the technology / elements / location selectors render on welcome and gateway. |
|
|
54
|
+
| `viewport_mode` | yes | Set via the `/settings` POST body. Either `technical` (default) or `store` (simplified `/viewport` for store operators). |
|
|
55
|
+
| `profile` | no | Stored on the session via the `/gateway` POST body (form field), then forwarded as a query string to the editor on redirect. |
|
|
56
|
+
| `variant` | no | Same handling as `profile`. |
|
|
57
|
+
| editor state | no | `font`, `font_size`, `font_size_mode`, `zoom`, `margins`, `rulers`, `crosshair`, `keyboard`, `guidelines`, `caret` are written to the URL by the viewport only, and only while `.viewer-container` is mounted on the page so they never leak into `/welcome`, `/gateway`, `/settings` or any other downstream section. |
|
|
58
|
+
| `engine` | no | Read once per `/convert` POST. |
|
|
59
|
+
| `format` | no | Read once per `/convert` POST. |
|
|
60
|
+
|
|
61
|
+
### Theme and locale
|
|
62
|
+
|
|
63
|
+
| Route | `theme` | `locale` | `fullscreen` |
|
|
64
|
+
| ------------ | :-----: | :------: | :----------: |
|
|
65
|
+
| `/` | yes | yes | yes |
|
|
66
|
+
| `/gateway` | yes | yes | yes |
|
|
67
|
+
| `/welcome` | yes | yes | yes |
|
|
68
|
+
| `/signature` | yes | - | yes |
|
|
69
|
+
| `/viewport` | yes | - | yes |
|
|
70
|
+
| `/report` | yes | yes | yes |
|
|
71
|
+
| `/console` | yes | - | - |
|
|
72
|
+
| `/receipt` | - | yes | - |
|
|
73
|
+
| `/image` | - | yes | - |
|
|
74
|
+
|
|
75
|
+
| Name | Type | Default | Description |
|
|
76
|
+
| ------------ | ----- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `theme` | `str` | `""` | Visual theme identifier applied to the body (e.g. `ldj`). Persisted on the session for subsequent requests. |
|
|
78
|
+
| `locale` | `str` | `""` | Locale identifier used to pick a localized view (e.g. `pt_pt`). Persisted on the session and used to load the matching `*-${locale}.ejs`. |
|
|
79
|
+
| `fullscreen` | `str` | `"0"` | When set to `"1"`, enables the `apple-mobile-web-app-capable` meta. Persisted on the session; the URL query is honored as a one-shot override. |
|
|
80
|
+
|
|
81
|
+
### Text payload (`/viewport`, `/report`, `/text`, `/image`, `/receipt`)
|
|
82
|
+
|
|
83
|
+
| Name | Type | Default | Description |
|
|
84
|
+
| ------ | ----- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| `text` | `str` | `null` | Serialized text payload to seed the editor or render with (`font/character` pairs). Persisted on the session config field. |
|
|
86
|
+
|
|
87
|
+
### Template pre-selection (`/viewport`, `/report`)
|
|
88
|
+
|
|
89
|
+
Forwarded automatically by the gateway POST when the welcome screen is used, but they can also be passed directly to deep-link into the editor with a specific template.
|
|
90
|
+
|
|
91
|
+
| Name | Type | Default | Description |
|
|
92
|
+
| --------- | ----- | ------- | -------------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `profile` | `str` | `null` | Profile ID (matches a file under `static/profiles/*.json`) to pre-select in the profile dropdown. |
|
|
94
|
+
| `variant` | `str` | `null` | Index of the variant to pre-select within the chosen profile, applied after `profile` is restored. |
|
|
95
|
+
|
|
96
|
+
### Viewport editor state (`/viewport`)
|
|
97
|
+
|
|
98
|
+
Read by the client and written back via `history.replaceState` so the editor URL always reflects the current state and can be shared or reloaded.
|
|
99
|
+
|
|
100
|
+
| Name | Type | Default | Description |
|
|
101
|
+
| ---------------- | ----- | ------- | ------------------------------------------------------------------------------------------------------- |
|
|
102
|
+
| `font` | `str` | `null` | Currently selected font name; restored by clicking the matching font element on load. |
|
|
103
|
+
| `font_size` | `int` | `null` | Manual font size in profile units; applied to both the slider and the number input. |
|
|
104
|
+
| `font_size_mode` | `str` | `null` | Either `manual` or `automatic` for the font size mode toggle. |
|
|
105
|
+
| `zoom` | `int` | `null` | Zoom percentage applied to the viewport preview; clamped to the slider's min/max range. |
|
|
106
|
+
| `margins` | `str` | `null` | Four comma-separated values (`left,right,top,bottom`) overriding the profile padding, in profile units. |
|
|
107
|
+
| `rulers` | `str` | `"1"` | When `"0"` hides the horizontal and vertical rulers; any other value (or absent) keeps them visible. |
|
|
108
|
+
| `crosshair` | `str` | `"1"` | When `"0"` disables the hover crosshair lines on the viewport preview. |
|
|
109
|
+
| `keyboard` | `str` | `"1"` | When `"0"` hides the visual keyboard panel until re-toggled. |
|
|
110
|
+
| `guidelines` | `str` | `"1"` | When `"0"` hides the SVG profile bounds and safe area outlines on the preview. |
|
|
111
|
+
| `caret` | `str` | `"1"` | When `"0"` hides the blinking caret in the viewport preview. |
|
|
112
|
+
|
|
113
|
+
### `/convert`
|
|
114
|
+
|
|
115
|
+
| Name | Type | Default | Description |
|
|
116
|
+
| -------- | ----- | ------------ | ---------------------------------------------------------------------------------------- |
|
|
117
|
+
| `engine` | `str` | `"inkscape"` | Conversion engine identifier; resolved against the registered engines (e.g. `inkscape`). |
|
|
118
|
+
| `format` | `str` | `"hpgl"` | Target output format honored by the inkscape engine; one of `svg`, `pdf`, or `hpgl`. |
|
|
119
|
+
|
|
120
|
+
## Profiles
|
|
121
|
+
|
|
122
|
+
The engraving surfaces (medals, plates, rings, etc.) are described by JSON profile files under `static/profiles/`. The schema of these files (and of their companion `*.inspirations.json` files) is documented in [docs/profile-spec.md](docs/profile-spec.md). The authoritative validator lives in `lib/util/profile.js` and is the source the spec document tracks.
|
|
123
|
+
|
|
124
|
+
## Printing
|
|
125
|
+
|
|
126
|
+
Signatur drives two independent print jobs through Colony Print: the **engraving** job that is sent from the `/viewport` editor and the **receipt** job that is printed from `/report`. Both share the same Colony Print server URL and the same secret key, but each one targets its own node and printer so a single Signatur install can drive an engraver and a receipt printer that live on different physical machines without any name collision.
|
|
127
|
+
|
|
128
|
+
The configuration is resolved through a three step fallback chain so existing single printer deployments keep working without any change:
|
|
129
|
+
|
|
130
|
+
1. **Scenario specific `localStorage` keys** (browser side, highest priority).
|
|
131
|
+
2. **Legacy unprefixed `localStorage` keys** (`node`, `printer`) so installs that predate the engrave/receipt split still see their old configuration.
|
|
132
|
+
3. **Server side environment variables** rendered into the page as `data-*` fallbacks (`PRINT_URL`, `ENGRAVE_NODE`/`ENGRAVE_PRINTER` for the engrave button, `PRINT_NODE`/`PRINT_PRINTER` for the receipt button, `PRINT_KEY` for both).
|
|
133
|
+
|
|
134
|
+
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.
|
|
135
|
+
|
|
136
|
+
### Configuration keys
|
|
137
|
+
|
|
138
|
+
| `localStorage` key | Scenario | Server side fallback | Description |
|
|
139
|
+
| ------------------ | -------- | ----------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
140
|
+
| `url` | shared | `PRINT_URL` | Colony Print base URL; used by both the engrave and the receipt flows. |
|
|
141
|
+
| `key` | shared | `PRINT_KEY` | Colony Print secret key; used by both the engrave and the receipt flows. |
|
|
142
|
+
| `engrave_node` | engrave | `ENGRAVE_NODE` (defaults to `PRINT_NODE`) | Colony Print node that receives the engrave job (`POST /nodes/<node>/print`). |
|
|
143
|
+
| `engrave_printer` | engrave | `ENGRAVE_PRINTER` (defaults to `PRINT_PRINTER`) | Printer within the engrave node; reserved for the per-printer engrave endpoint. |
|
|
144
|
+
| `receipt_node` | receipt | `PRINT_NODE` | Colony Print node that receives the receipt (`POST /nodes/<node>/printers/print`). |
|
|
145
|
+
| `receipt_printer` | receipt | `PRINT_PRINTER` | Printer within the receipt node. |
|
|
146
|
+
| `node` | legacy | - | Read as a fallback for both `engrave_node` and `receipt_node` so old installs work. |
|
|
147
|
+
| `printer` | legacy | - | Read as a fallback for both `engrave_printer` and `receipt_printer`. |
|
|
148
|
+
|
|
149
|
+
To configure both scenarios from the Browser's JavaScript console:
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
// shared between both scenarios
|
|
153
|
+
localStorage.setItem("url", "https://colony-print.stage.hive.pt");
|
|
154
|
+
localStorage.setItem("key", "${server-key}");
|
|
155
|
+
|
|
156
|
+
// engraving job (the /viewport "Engrave" action)
|
|
157
|
+
localStorage.setItem("engrave_node", "${engrave-node}");
|
|
158
|
+
localStorage.setItem("engrave_printer", "${engrave-printer}");
|
|
159
|
+
|
|
160
|
+
// receipt printing (the /report "Receipt" action)
|
|
161
|
+
localStorage.setItem("receipt_node", "${receipt-node}");
|
|
162
|
+
localStorage.setItem("receipt_printer", "${receipt-printer}");
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
To read the configuration:
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
console.info(localStorage.getItem("url"));
|
|
169
|
+
console.info(localStorage.getItem("key"));
|
|
170
|
+
console.info(localStorage.getItem("engrave_node"));
|
|
171
|
+
console.info(localStorage.getItem("engrave_printer"));
|
|
172
|
+
console.info(localStorage.getItem("receipt_node"));
|
|
173
|
+
console.info(localStorage.getItem("receipt_printer"));
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The same configuration can also be edited through the `Configure` modal accessible from the gateway and the viewport.
|
|
177
|
+
|
|
178
|
+
## Maintenance
|
|
179
|
+
|
|
180
|
+
### Adding New Emoji
|
|
181
|
+
|
|
182
|
+
To add a new emoji to the system the following steps should be followed:
|
|
183
|
+
|
|
184
|
+
1. Determine the right file name for the new emoji font file (e.g. `coolemojis.ttf` for laser and `coolemojisp.ttf` for pantogrpah)
|
|
185
|
+
2. Place the new font file in the `static/fonts` directory
|
|
186
|
+
3. Add the new emoji "characters" to the `emoji` array in the `viewport.ejs` file
|
|
187
|
+
4. Test the using the local machine `yarn && yarn dev`
|
|
188
|
+
5. Release a new version of the system (Docker Image)
|
|
189
|
+
|
|
7
190
|
## License
|
|
8
191
|
|
|
9
192
|
Signatur is currently licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/).
|
|
10
193
|
|
|
11
194
|
## Build Automation
|
|
12
195
|
|
|
13
|
-
[](https://github.com/hivesolutions/signatur/actions)
|
|
14
197
|
[](https://www.npmjs.com/package/signatur)
|
|
15
198
|
[](https://www.apache.org/licenses/)
|