@prairielearn/signed-token 1.0.1 → 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/CHANGELOG.md +12 -0
- package/package.json +3 -3
- package/src/index.ts +5 -5
- package/tsconfig.json +2 -2
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prairielearn/signed-token",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@prairielearn/tsconfig": "*",
|
|
16
16
|
"@types/debug": "^4.1.8",
|
|
17
|
-
"@types/node": "^18.
|
|
17
|
+
"@types/node": "^18.17.1",
|
|
18
18
|
"mocha": "^10.2.0",
|
|
19
|
-
"typescript": "^5.1.
|
|
19
|
+
"typescript": "^5.1.6"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"base64url": "^3.0.1",
|
package/src/index.ts
CHANGED
|
@@ -25,7 +25,7 @@ export function generateSignedToken(data: any, secretKey: string) {
|
|
|
25
25
|
dateString,
|
|
26
26
|
checkString,
|
|
27
27
|
encodedSignature,
|
|
28
|
-
})}
|
|
28
|
+
})}`,
|
|
29
29
|
);
|
|
30
30
|
const token = encodedSignature + sep + checkString;
|
|
31
31
|
debug(`generateSignedToken(): token = ${token}`);
|
|
@@ -35,7 +35,7 @@ export function generateSignedToken(data: any, secretKey: string) {
|
|
|
35
35
|
export function getCheckedSignedTokenData(
|
|
36
36
|
token: string,
|
|
37
37
|
secretKey: string,
|
|
38
|
-
options: CheckOptions = {}
|
|
38
|
+
options: CheckOptions = {},
|
|
39
39
|
) {
|
|
40
40
|
debug(`getCheckedSignedTokenData(): token = ${token}`);
|
|
41
41
|
debug(`getCheckedSignedTokenData(): secretKey = ${secretKey}`);
|
|
@@ -61,7 +61,7 @@ export function getCheckedSignedTokenData(
|
|
|
61
61
|
const encodedCheckSignature = base64url.encode(checkSignature);
|
|
62
62
|
if (encodedCheckSignature !== tokenSignature) {
|
|
63
63
|
debug(
|
|
64
|
-
`getCheckedSignedTokenData(): FAIL - signature mismatch: checkSig=${encodedCheckSignature} != tokenSig=${tokenSignature}
|
|
64
|
+
`getCheckedSignedTokenData(): FAIL - signature mismatch: checkSig=${encodedCheckSignature} != tokenSig=${tokenSignature}`,
|
|
65
65
|
);
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
@@ -79,7 +79,7 @@ export function getCheckedSignedTokenData(
|
|
|
79
79
|
const elapsedTime = currentTime - tokenDate.getTime();
|
|
80
80
|
if (elapsedTime > options.maxAge) {
|
|
81
81
|
debug(
|
|
82
|
-
`getCheckedSignedTokenData(): FAIL - too old: elapsedTime=${elapsedTime} > maxAge=${options.maxAge}
|
|
82
|
+
`getCheckedSignedTokenData(): FAIL - too old: elapsedTime=${elapsedTime} > maxAge=${options.maxAge}`,
|
|
83
83
|
);
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
@@ -107,7 +107,7 @@ export function checkSignedToken(
|
|
|
107
107
|
token: string,
|
|
108
108
|
data: any,
|
|
109
109
|
secretKey: string,
|
|
110
|
-
options: CheckOptions = {}
|
|
110
|
+
options: CheckOptions = {},
|
|
111
111
|
) {
|
|
112
112
|
debug(`checkSignedToken(): token = ${token}`);
|
|
113
113
|
debug(`checkSignedToken(): data = ${JSON.stringify(data)}`);
|
package/tsconfig.json
CHANGED