@smonn/ids 0.14.0 → 0.14.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.
Files changed (2) hide show
  1. package/package.json +3 -2
  2. package/spec/vectors.json +97 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smonn/ids",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "license": "MIT",
5
5
  "author": "Simon Ingeson (https://github.com/smonn)",
6
6
  "repository": {
@@ -11,7 +11,8 @@
11
11
  "ids": "./dist/cli.mjs"
12
12
  },
13
13
  "files": [
14
- "dist"
14
+ "dist",
15
+ "spec/vectors.json"
15
16
  ],
16
17
  "type": "module",
17
18
  "types": "./dist/index.d.mts",
@@ -0,0 +1,97 @@
1
+ {
2
+ "version": 1,
3
+ "vectors": [
4
+ {
5
+ "name": "timestamp_extract_running_example",
6
+ "category": "codec:timestamp",
7
+ "operation": "extract",
8
+ "input": "usr_06f80z92d2dbsqqg28t5cy4tqg",
9
+ "expected": 1780272145000
10
+ },
11
+ {
12
+ "name": "timestamp_generate_running_example",
13
+ "category": "codec:timestamp",
14
+ "operation": "generate",
15
+ "input": { "timestamp": 1780272145000, "rng": "9abcdef0123456789abc" },
16
+ "expected": "usr_06f80z92d2dbsqqg28t5cy4tqg"
17
+ },
18
+ {
19
+ "name": "reverse_extract_running_example",
20
+ "description": "the 6 timestamp bytes are bitwise-inverted before encoding; extract re-inverts them",
21
+ "category": "codec:reverse",
22
+ "operation": "extract",
23
+ "input": "usr_zsgqz0pxjydbsqqg28t5cy4tqg",
24
+ "expected": 1780272145000
25
+ },
26
+ {
27
+ "name": "reverse_generate_running_example",
28
+ "category": "codec:reverse",
29
+ "operation": "generate",
30
+ "input": { "timestamp": 1780272145000, "rng": "9abcdef0123456789abc" },
31
+ "expected": "usr_zsgqz0pxjydbsqqg28t5cy4tqg"
32
+ },
33
+ {
34
+ "name": "to_uuid_running_example",
35
+ "description": "the 16 payload bytes written verbatim as an RFC 9562 lowercase hyphenated UUID",
36
+ "category": "wire",
37
+ "operation": "to_uuid",
38
+ "input": "usr_06f80z92d2dbsqqg28t5cy4tqg",
39
+ "expected": "019e807d-2268-9abc-def0-123456789abc"
40
+ },
41
+ {
42
+ "name": "from_uuid_running_example",
43
+ "category": "wire",
44
+ "operation": "from_uuid",
45
+ "input": "019e807d-2268-9abc-def0-123456789abc",
46
+ "expected": { "ok": true, "id": "usr_06f80z92d2dbsqqg28t5cy4tqg" }
47
+ },
48
+ {
49
+ "name": "from_uuid_uppercase_accept",
50
+ "description": "RFC 9562 parsers accept uppercase hex; output is the same canonical id",
51
+ "category": "wire",
52
+ "operation": "from_uuid",
53
+ "input": "019E807D-2268-9ABC-DEF0-123456789ABC",
54
+ "expected": { "ok": true, "id": "usr_06f80z92d2dbsqqg28t5cy4tqg" }
55
+ },
56
+ {
57
+ "name": "from_uuid_reject_braces",
58
+ "description": "braced {…} form is rejected; only the hyphenated 8-4-4-4-12 form is accepted",
59
+ "category": "wire",
60
+ "operation": "from_uuid",
61
+ "input": "{019e807d-2268-9abc-def0-123456789abc}",
62
+ "expected": { "ok": false, "layer": "uuid" }
63
+ },
64
+ {
65
+ "name": "canonicalize_uppercase",
66
+ "description": "ASCII A-Z folds to lowercase",
67
+ "category": "wire",
68
+ "operation": "canonicalize",
69
+ "input": "USR_06F80Z92D2DBSQQG28T5CY4TQG",
70
+ "expected": { "ok": true, "id": "usr_06f80z92d2dbsqqg28t5cy4tqg" }
71
+ },
72
+ {
73
+ "name": "canonicalize_alias_o_to_zero",
74
+ "description": "Crockford visual alias o/O resolves to 0 before validation",
75
+ "category": "wire",
76
+ "operation": "canonicalize",
77
+ "input": "usr_o6f8oz92d2dbsqqg28t5cy4tqg",
78
+ "expected": { "ok": true, "id": "usr_06f80z92d2dbsqqg28t5cy4tqg" }
79
+ },
80
+ {
81
+ "name": "canonicalize_reject_padding_bit",
82
+ "description": "final base32 char '1' has non-zero low 2 bits (not in [048cgmrw])",
83
+ "category": "wire",
84
+ "operation": "canonicalize",
85
+ "input": "usr_00000000000000000000000001",
86
+ "expected": { "ok": false, "layer": "base32" }
87
+ },
88
+ {
89
+ "name": "canonicalize_reject_wrong_prefix",
90
+ "description": "a well-formed id of a different brand is rejected at the prefix layer (vectors are authored against brand usr)",
91
+ "category": "wire",
92
+ "operation": "canonicalize",
93
+ "input": "org_06f80z92d2dbsqqg28t5cy4tqg",
94
+ "expected": { "ok": false, "layer": "prefix" }
95
+ }
96
+ ]
97
+ }