@forklaunch/core 0.14.6 → 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.
@@ -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
- const hmac = createHmac("sha256", secretKey);
159
- hmac.update(`${method}
160
- ${path}
161
- ${body}
162
- ${timestamp}
163
- ${nonce}`);
164
- const digest = hmac.digest("base64");
165
- return digest === signature;
176
+ return createHmacToken({
177
+ method,
178
+ path,
179
+ body,
180
+ timestamp,
181
+ nonce,
182
+ secretKey
183
+ }) === signature;
166
184
  }
167
185
  }
168
186
  };
@@ -3303,7 +3321,6 @@ function recordMetric(req, res) {
3303
3321
  httpRequestsTotalCounter.add(1, {
3304
3322
  [ATTR_SERVICE_NAME3]: getEnvVar4("OTEL_SERVICE_NAME"),
3305
3323
  [ATTR_API_NAME]: req.contractDetails?.name,
3306
- [ATTR_CORRELATION_ID]: req.context.correlationId,
3307
3324
  [ATTR_HTTP_REQUEST_METHOD3]: req.method,
3308
3325
  [ATTR_HTTP_ROUTE3]: req.originalPath,
3309
3326
  [ATTR_HTTP_RESPONSE_STATUS_CODE3]: Number(res.statusCode) || 0
@@ -3927,6 +3944,7 @@ export {
3927
3944
  HTTPStatuses,
3928
3945
  OPENAPI_DEFAULT_VERSION,
3929
3946
  OpenTelemetryCollector,
3947
+ createHmacToken,
3930
3948
  delete_,
3931
3949
  discriminateBody,
3932
3950
  discriminateResponseBodies,