@supersuit/plumabook 0.1.0 → 0.1.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/CHANGELOG.md +5 -0
- package/dist/dnc.d.ts +3 -2
- package/dist/dnc.js +7 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
- The do-not-contact check now refuses a listed name written right before a proof mark. Before, "met Zed Quill¹" passed, because the mark was read as part of the last word. Superscript and subscript digits now break words the way punctuation does, in texts and in list entries alike.
|
|
6
|
+
- `normalizeName` changes only for text that holds those digits, so hashes made with `dncHash` from plain names stay the same. A copy of this check on another machine must make the same change to keep its parity test green.
|
|
7
|
+
|
|
3
8
|
## 0.1.0
|
|
4
9
|
|
|
5
10
|
First release, moved from an app's own PlumaBook tile with its tests, with no change in behaviour.
|
package/dist/dnc.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const DNC_UNSET = "the do-not-contact list is not set, so nothing is posted";
|
|
2
|
-
/** For list entries and texts alike:
|
|
3
|
-
*
|
|
2
|
+
/** For list entries and texts alike: superscript and subscript digits (proof marks, ¹ to ⁹) a break first, then composed to
|
|
3
|
+
* NFKC, accents stripped (NFD, then the marks removed), lowercase, and every character that is not a letter or a digit
|
|
4
|
+
* (apostrophes of any kind and hyphens too) a break, collapsed to single spaces. */
|
|
4
5
|
export declare const normalizeName: (s: string) => string;
|
|
5
6
|
export declare const dncHash: (name: string) => string;
|
|
6
7
|
/** The list as a set of hashes, or null when it is unset, empty or holds no valid hash. */
|
package/dist/dnc.js
CHANGED
|
@@ -6,9 +6,13 @@ import { createHash } from 'node:crypto';
|
|
|
6
6
|
// gives a hash, so the list is built without the names being stored anywhere. A machine-side copy of this check must
|
|
7
7
|
// hash exactly as this does, so keep a parity test beside any such copy.
|
|
8
8
|
export const DNC_UNSET = 'the do-not-contact list is not set, so nothing is posted';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// The superscripts go before NFKC because NFKC turns ¹ into a plain 1, which glued a proof mark to the name before it:
|
|
10
|
+
// "Zed Quill¹" read as "zed quill1" and a listed "zed quill" passed.
|
|
11
|
+
const SCRIPT_DIGITS = /[\u00B2\u00B3\u00B9\u2070\u2074-\u2079\u2080-\u2089]+/gu;
|
|
12
|
+
/** For list entries and texts alike: superscript and subscript digits (proof marks, ¹ to ⁹) a break first, then composed to
|
|
13
|
+
* NFKC, accents stripped (NFD, then the marks removed), lowercase, and every character that is not a letter or a digit
|
|
14
|
+
* (apostrophes of any kind and hyphens too) a break, collapsed to single spaces. */
|
|
15
|
+
export const normalizeName = (s) => s.replace(SCRIPT_DIGITS, ' ').normalize('NFKC').normalize('NFD').replace(/\p{M}+/gu, '').toLowerCase().replace(/[^\p{L}\p{N}]+/gu, ' ').trim();
|
|
12
16
|
export const dncHash = (name) => createHash('sha256').update(normalizeName(name)).digest('hex');
|
|
13
17
|
/** The list as a set of hashes, or null when it is unset, empty or holds no valid hash. */
|
|
14
18
|
export function dncSet(env = process.env) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supersuit/plumabook",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "PlumaBook: a feed where each member's Pluma posts the work it did with them, with a pinned proof on every finished post. Rules, a Firestore store and route handlers for any app that says who its members are and where things are kept.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|