@forklaunch/core 0.14.7 → 0.14.8
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/lib/http/index.d.mts +24 -5
- package/lib/http/index.d.ts +24 -5
- package/lib/http/index.js +29 -9
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +28 -9
- package/lib/http/index.mjs.map +1 -1
- package/package.json +4 -4
package/lib/http/index.mjs
CHANGED
@@ -83,9 +83,27 @@ function isTypedHandler(maybeTypedHandler) {
|
|
83
83
|
import { isNever } from "@forklaunch/common";
|
84
84
|
|
85
85
|
// src/http/discriminateAuthMethod.ts
|
86
|
-
import { createHmac } from "crypto";
|
87
86
|
import { jwtVerify } from "jose";
|
88
87
|
|
88
|
+
// src/http/createHmacToken.ts
|
89
|
+
import { createHmac } from "crypto";
|
90
|
+
function createHmacToken({
|
91
|
+
method,
|
92
|
+
path,
|
93
|
+
body,
|
94
|
+
timestamp,
|
95
|
+
nonce,
|
96
|
+
secretKey
|
97
|
+
}) {
|
98
|
+
const hmac = createHmac("sha256", secretKey);
|
99
|
+
hmac.update(`${method}
|
100
|
+
${path}
|
101
|
+
${body}
|
102
|
+
${timestamp}
|
103
|
+
${nonce}`);
|
104
|
+
return hmac.digest("base64");
|
105
|
+
}
|
106
|
+
|
89
107
|
// src/http/guards/isBasicAuthMethod.ts
|
90
108
|
function isBasicAuthMethod(maybeBasicAuthMethod) {
|
91
109
|
return typeof maybeBasicAuthMethod === "object" && maybeBasicAuthMethod !== null && "basic" in maybeBasicAuthMethod && maybeBasicAuthMethod.basic != null;
|
@@ -155,14 +173,14 @@ async function discriminateAuthMethod(auth) {
|
|
155
173
|
auth: {
|
156
174
|
secretKeys: auth.hmac.secretKeys,
|
157
175
|
verificationFunction: async (method, path, body, timestamp, nonce, signature, secretKey) => {
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
176
|
+
return createHmacToken({
|
177
|
+
method,
|
178
|
+
path,
|
179
|
+
body,
|
180
|
+
timestamp,
|
181
|
+
nonce,
|
182
|
+
secretKey
|
183
|
+
}) === signature;
|
166
184
|
}
|
167
185
|
}
|
168
186
|
};
|
@@ -3926,6 +3944,7 @@ export {
|
|
3926
3944
|
HTTPStatuses,
|
3927
3945
|
OPENAPI_DEFAULT_VERSION,
|
3928
3946
|
OpenTelemetryCollector,
|
3947
|
+
createHmacToken,
|
3929
3948
|
delete_,
|
3930
3949
|
discriminateBody,
|
3931
3950
|
discriminateResponseBodies,
|