shelving 1.160.0 → 1.160.2
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/api/util.js +2 -2
- package/package.json +1 -1
- package/util/http.js +2 -3
- package/util/jwt.js +3 -3
package/api/util.js
CHANGED
|
@@ -45,8 +45,8 @@ async function handleEndpoint(endpoint, callback, params, request) {
|
|
|
45
45
|
const content = await getRequestContent(request, handleEndpoints);
|
|
46
46
|
// If content is undefined, it means the request has no body, so params are the only payload.
|
|
47
47
|
// - If the content is a plain object, merge if with the params.
|
|
48
|
-
// - If the content is anything else (e.g. string, number, array),
|
|
49
|
-
const payload = content === undefined ? params : isPlainObject(content) ? { ...content, ...params } :
|
|
48
|
+
// - If the content is anything else (e.g. string, number, array), return it directly (but you'll have no way to access the other params).
|
|
49
|
+
const payload = content === undefined ? params : isPlainObject(content) ? { ...content, ...params } : content;
|
|
50
50
|
// Call `endpoint.handle()` with the payload and request.
|
|
51
51
|
return endpoint.handle(callback, payload, request);
|
|
52
52
|
}
|
package/package.json
CHANGED
package/util/http.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RequestError } from "../error/RequestError.js";
|
|
2
2
|
import { ResponseError } from "../error/ResponseError.js";
|
|
3
3
|
import { Feedback } from "../feedback/Feedback.js";
|
|
4
|
-
import { getDictionary } from "./dictionary.js";
|
|
5
4
|
import { isError } from "./error.js";
|
|
6
5
|
export async function _getMessageJSON(message, MessageError, caller) {
|
|
7
6
|
const trimmed = (await message.text()).trim();
|
|
@@ -16,7 +15,7 @@ export async function _getMessageJSON(message, MessageError, caller) {
|
|
|
16
15
|
}
|
|
17
16
|
export async function _getMessageFormData(message, MessageError, caller) {
|
|
18
17
|
try {
|
|
19
|
-
return
|
|
18
|
+
return await message.formData();
|
|
20
19
|
}
|
|
21
20
|
catch {
|
|
22
21
|
throw new MessageError("Body must be valid valid form multipart data", { caller });
|
|
@@ -30,7 +29,7 @@ export function _getMessageContent(message, MessageError, caller) {
|
|
|
30
29
|
return _getMessageJSON(message, MessageError, caller);
|
|
31
30
|
if (type?.startsWith("multipart/form-data"))
|
|
32
31
|
return _getMessageFormData(message, MessageError, caller);
|
|
33
|
-
|
|
32
|
+
return Promise.resolve();
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
36
35
|
* Get the body content of an HTTP `Request` based on its content type, or throw `RequestError` if the content could not be parsed.
|
package/util/jwt.js
CHANGED
|
@@ -34,9 +34,9 @@ export async function encodeToken({ nbf = "now", iat = "now", exp = DAY * 30, ..
|
|
|
34
34
|
const header = encodeBase64URL(JSON.stringify(HEADER));
|
|
35
35
|
// Encode payload.
|
|
36
36
|
const payload = encodeBase64URL(JSON.stringify({
|
|
37
|
-
nbf: requireDate(nbf).getTime() / 1000, // By JWT convention, times are in seconds.
|
|
38
|
-
iat: requireDate(iat).getTime() / 1000, // By JWT convention, times are in seconds.
|
|
39
|
-
exp: (Date.now() + exp) / 1000, // By JWT convention, times are in seconds.
|
|
37
|
+
nbf: Math.round(requireDate(nbf).getTime() / 1000), // By JWT convention, times are in seconds.
|
|
38
|
+
iat: Math.round(requireDate(iat).getTime() / 1000), // By JWT convention, times are in seconds.
|
|
39
|
+
exp: Math.round((Date.now() + exp) / 1000), // By JWT convention, times are in seconds.
|
|
40
40
|
...claims,
|
|
41
41
|
}));
|
|
42
42
|
// Create signature.
|