userinfo-token-validator 1.0.2 → 1.0.3
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 +15 -0
- package/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,21 @@ on this variables
|
|
|
13
13
|
|
|
14
14
|
to test the library run node tokenValidator-test.js it should give you the response of list of group user associated with and validate userbased on token nd lanId
|
|
15
15
|
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Permissions
|
|
19
|
+
|
|
20
|
+
Only npm users listed as maintainers of this package can publish updates.
|
|
21
|
+
Permissions are managed on npmjs.com under the package’s Maintainers settings. (https://www.npmjs.com/package/userinfo-token-validator - see "Collaborators")
|
|
22
|
+
|
|
23
|
+
If you receive a 403 error while publishing:
|
|
24
|
+
- Ensure you are logged in with `npm whoami`
|
|
25
|
+
- Confirm you are listed as a maintainer
|
|
26
|
+
- Verify the version number has been updated
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
16
31
|
Steps to build and Publish NPM package
|
|
17
32
|
|
|
18
33
|
1. Update Version: Before publishing an update, make sure to update the version number in package.json. You can do this
|
package/index.js
CHANGED
|
@@ -19,7 +19,7 @@ async function checkValidToken(userinfoUrl, token, lanId, redisCacheClient) {
|
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
console.log("Validating token with", userinfoUrl);
|
|
22
|
+
//console.log("Validating token with", userinfoUrl);
|
|
23
23
|
|
|
24
24
|
if (!token || !lanId) {
|
|
25
25
|
console.log("Invalid input: missing token or lanId");
|
|
@@ -34,9 +34,9 @@ async function checkValidToken(userinfoUrl, token, lanId, redisCacheClient) {
|
|
|
34
34
|
},
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
console.log("userinfoUrl:", userinfoUrl);
|
|
38
|
-
console.log("Token:", token);
|
|
39
|
-
console.log("LAN ID:", lanId);
|
|
37
|
+
// console.log("userinfoUrl:", userinfoUrl);
|
|
38
|
+
// console.log("Token:", token);
|
|
39
|
+
// console.log("LAN ID:", lanId);
|
|
40
40
|
|
|
41
41
|
try {
|
|
42
42
|
const response = await axios.get(userinfoUrl, options);
|
|
@@ -47,7 +47,7 @@ async function checkValidToken(userinfoUrl, token, lanId, redisCacheClient) {
|
|
|
47
47
|
const isValid = responseParsed?.lanId?.toString()?.toLowerCase() === lanId?.toString()?.toLowerCase();
|
|
48
48
|
|
|
49
49
|
if (isValid) {
|
|
50
|
-
console.log("Axios...got response. PASSED authentication.");
|
|
50
|
+
//console.log("Axios...got response. PASSED authentication.");
|
|
51
51
|
|
|
52
52
|
// Cache token in Redis for quicker future validation.
|
|
53
53
|
// Ideally, we would save the token with an expiration date, but we don't have that info. Default to cache expiration after 30 minutes.
|
|
@@ -55,14 +55,14 @@ async function checkValidToken(userinfoUrl, token, lanId, redisCacheClient) {
|
|
|
55
55
|
EX: 1800, // 30 minute TTL (delete from Redis cache after this time)
|
|
56
56
|
});
|
|
57
57
|
} else {
|
|
58
|
-
console.log("
|
|
58
|
+
console.log("FAILED authentication. LAN ID: ", lanId);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
return isValid;
|
|
62
62
|
} catch (error) {
|
|
63
63
|
console.log("CATCH ERROR: Token check failed");
|
|
64
64
|
console.log("Error details:", error.message);
|
|
65
|
-
console.log("CATCH ERROR; bad token =", token);
|
|
65
|
+
//console.log("CATCH ERROR; bad token =", token);
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
68
|
}
|