@carecard/auth-util 3.39.0 → 3.40.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.
|
@@ -159,9 +159,11 @@ depend on those folders being present.
|
|
|
159
159
|
key credential is verified.
|
|
160
160
|
- Generate salts internally for every credential. Never accept caller-selected
|
|
161
161
|
salts and never persist or log the pepper.
|
|
162
|
-
- Normalize
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
- Normalize password edge whitespace through `@carecard/validate`, then NFC,
|
|
163
|
+
before deriving the tag. Creation and verification use identical canonical
|
|
164
|
+
bytes; preserve internal spaces. `@carecard/validate` owns password policy.
|
|
165
|
+
Trim outer signed-token whitespace before verification or decomposition,
|
|
166
|
+
preserving the signed contents and canonical signature encoding checks.
|
|
165
167
|
- Return an invalid verification result for unknown key IDs, malformed,
|
|
166
168
|
non-canonical, differently parameterized, or legacy saved hashes. Throw for
|
|
167
169
|
programmer/configuration errors such as an invalid keyring.
|
package/lib/jwtUtilAuth.js
CHANGED
|
@@ -108,7 +108,7 @@ function verifyJwtSignature(jwt, verificationJwks) {
|
|
|
108
108
|
if (typeof jwt !== 'string') {
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
|
-
const parts = jwt.split('.');
|
|
111
|
+
const parts = jwt.trim().split('.');
|
|
112
112
|
if (parts.length !== 3) {
|
|
113
113
|
return false;
|
|
114
114
|
}
|
|
@@ -129,10 +129,10 @@ function verifyJwtSignature(jwt, verificationJwks) {
|
|
|
129
129
|
|
|
130
130
|
function getHeaderPayloadFromJwt(jwt) {
|
|
131
131
|
try {
|
|
132
|
-
if (typeof jwt !== 'string' || jwt.split('.').length !== 3) {
|
|
132
|
+
if (typeof jwt !== 'string' || jwt.trim().split('.').length !== 3) {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
|
-
const [headerPart, payloadPart] = jwt.split('.');
|
|
135
|
+
const [headerPart, payloadPart] = jwt.trim().split('.');
|
|
136
136
|
const header = decodeJwtPart(headerPart);
|
|
137
137
|
const payload = decodeJwtPart(payloadPart);
|
|
138
138
|
return isDecodedJwtObject(header) && isDecodedJwtObject(payload) ? { header, payload } : null;
|
package/lib/pwdUtilAuth.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { argon2, randomBytes, timingSafeEqual } = require('node:crypto');
|
|
4
4
|
const { promisify } = require('node:util');
|
|
5
|
+
const { normalizeInputWhitespace } = require('@carecard/validate');
|
|
5
6
|
|
|
6
7
|
const deriveArgon2Tag = promisify(argon2);
|
|
7
8
|
const ARGON2_ALGORITHM = 'argon2id';
|
|
@@ -17,12 +18,12 @@ const passwordKeyringSecrets = new WeakMap();
|
|
|
17
18
|
const PASSWORD_HASH_PATTERN =
|
|
18
19
|
/^\$argon2id\$v=19\$m=19456,t=2,p=1\$([A-Za-z0-9+/]{22})\$([A-Za-z0-9+/]{43})$/;
|
|
19
20
|
|
|
20
|
-
// Pattern: Canonicalization - converts
|
|
21
|
+
// Pattern: Canonicalization - converts trimmed NFC password text to stable UTF-8 bytes.
|
|
21
22
|
function createPasswordBuffer(password) {
|
|
22
23
|
if (typeof password !== 'string' || !password.isWellFormed()) {
|
|
23
24
|
throw new TypeError('Password must be a well-formed Unicode string.');
|
|
24
25
|
}
|
|
25
|
-
return Buffer.from(password.normalize('NFC'), 'utf8');
|
|
26
|
+
return Buffer.from(normalizeInputWhitespace(password).normalize('NFC'), 'utf8');
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
// Pattern: Serializer Helper - emits canonical unpadded PHC Base64 text.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carecard/auth-util",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.40.0",
|
|
4
4
|
"repository": "https://github.com/CareCard-ca/pkg-auth-util.git",
|
|
5
5
|
"description": "Auth utility functions",
|
|
6
6
|
"main": "index.js",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"typescript": "6.0.3"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@carecard/common-util": "3.
|
|
54
|
-
"@carecard/validate": "3.
|
|
53
|
+
"@carecard/common-util": "3.40.0",
|
|
54
|
+
"@carecard/validate": "3.40.0",
|
|
55
55
|
"@types/express": "5.0.6"
|
|
56
56
|
},
|
|
57
57
|
"overrides": {
|
package/readme.md
CHANGED
|
@@ -122,8 +122,10 @@ if (result.isValid && result.needsRehash) {
|
|
|
122
122
|
|
|
123
123
|
Keyring entries use `key-id:canonical-base64-32-byte-key`, separated by commas.
|
|
124
124
|
Credential rows persist both the PHC hash and its `hashKeyId`; pepper keys stay
|
|
125
|
-
outside persisted credentials and logs. Passwords
|
|
126
|
-
well-formed Unicode to NFC
|
|
125
|
+
outside persisted credentials and logs. Passwords trim edge whitespace and
|
|
126
|
+
normalize well-formed Unicode to NFC, preserving internal spaces.
|
|
127
|
+
`@carecard/validate` owns password policy. Signed token verification and
|
|
128
|
+
decomposition trim outer whitespace without rewriting signed token contents.
|
|
127
129
|
|
|
128
130
|
JWT signing configuration is one strict private Ed25519 JWK. Verification
|
|
129
131
|
configuration is an RFC 7517 JWKS containing one or more public Ed25519 JWKs.
|