@akc42/server-utils 4.0.0 → 4.0.1
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/debug.js +2 -1
- package/package.json +1 -1
- package/base32-utils.js +0 -89
package/debug.js
CHANGED
|
@@ -20,7 +20,8 @@ import { EventEmitter } from 'node:events';
|
|
|
20
20
|
import { setTimeout } from 'node:timers/promises';
|
|
21
21
|
import chalk from "chalk";
|
|
22
22
|
import {openDatabase} from '@akc42/sqlite-db';
|
|
23
|
-
import {
|
|
23
|
+
import { messageFormatter, COLOURS } from './message-formatter.js';
|
|
24
|
+
import { DebugHelper} from './debug-helper.js';
|
|
24
25
|
|
|
25
26
|
class DebugLogEvents extends EventEmitter {}
|
|
26
27
|
/*
|
package/package.json
CHANGED
package/base32-utils.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@licence
|
|
3
|
-
Copyright (c) 2025 Alan Chandler, all rights reserved
|
|
4
|
-
|
|
5
|
-
This file is part of PASv5, an implementation of the Patient Administration
|
|
6
|
-
System used to support Accuvision's Laser Eye Clinics.
|
|
7
|
-
|
|
8
|
-
PASv5 is licenced to Accuvision (and its successors in interest) free of royality payments
|
|
9
|
-
and in perpetuity in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
|
|
10
|
-
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Accuvision
|
|
11
|
-
may modify, or employ an outside party to modify, any of the software provided that
|
|
12
|
-
this modified software is only used as part of Accuvision's internal business processes.
|
|
13
|
-
|
|
14
|
-
The software may be run on either Accuvision's own computers or on external computing
|
|
15
|
-
facilities provided by a third party, provided that the software remains soley for use
|
|
16
|
-
by Accuvision (or by potential or existing customers in interacting with Accuvision).
|
|
17
|
-
*/
|
|
18
|
-
export function hexToBase32(input) {
|
|
19
|
-
let output = '';
|
|
20
|
-
let next = 0;
|
|
21
|
-
let lshift = 0;
|
|
22
|
-
for(let i = 0; i< input.length; i++) {
|
|
23
|
-
let digit = parseInt(input.charAt(i), 16);
|
|
24
|
-
if (!Number.isInteger(digit)) throw new RangeError('Expected string to include only HEX digits');
|
|
25
|
-
if (lshift > 0) {
|
|
26
|
-
const rshift = 4 - lshift;
|
|
27
|
-
const remainder = digit & (2**rshift - 1);
|
|
28
|
-
next |= digit >>> rshift;
|
|
29
|
-
output += alphabet.charAt(next);
|
|
30
|
-
lshift = (lshift + 1) % 5;
|
|
31
|
-
next = remainder << lshift;
|
|
32
|
-
} else {
|
|
33
|
-
lshift++;
|
|
34
|
-
next = digit << lshift;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (lshift > 0) output += alphabet.charAt(next);
|
|
38
|
-
return output;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/*
|
|
42
|
-
|
|
43
|
-
The code below was obtained from elsewhere with the attached notice
|
|
44
|
-
|
|
45
|
-
MIT License
|
|
46
|
-
|
|
47
|
-
Copyright (c) 2016-2021 Linus Unnebäck
|
|
48
|
-
|
|
49
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
50
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
51
|
-
in the Software without restriction, including without limitation the rights
|
|
52
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
53
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
54
|
-
furnished to do so, subject to the following conditions:
|
|
55
|
-
|
|
56
|
-
The above copyright notice and this permission notice shall be included in all
|
|
57
|
-
copies or substantial portions of the Software.
|
|
58
|
-
|
|
59
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
60
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
61
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
62
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
63
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
64
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
65
|
-
SOFTWARE.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'
|
|
70
|
-
|
|
71
|
-
export function base32ToHex (input) {
|
|
72
|
-
input = input.replace(/=+$/, '')
|
|
73
|
-
const length = input.length
|
|
74
|
-
let bits = 0;
|
|
75
|
-
let value = 0;
|
|
76
|
-
let index = 0;
|
|
77
|
-
const output = new Uint8Array(Math.ceil(length * 5 / 8) | 0)
|
|
78
|
-
for (var i = 0; i < length; i++) {
|
|
79
|
-
value = (value << 5) | alphabet.indexOf(input[i].toUpperCase())
|
|
80
|
-
bits += 5
|
|
81
|
-
if (bits >= 8) {
|
|
82
|
-
output[index++] = (value >>> (bits - 8)) & 255
|
|
83
|
-
bits -= 8
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return Buffer.from(output).toString('hex');
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|