@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.
- package/lib/http/index.d.mts +24 -6
- package/lib/http/index.d.ts +24 -6
- package/lib/http/index.js +29 -10
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +28 -10
- package/lib/http/index.mjs.map +1 -1
- package/package.json +28 -28
package/lib/http/index.d.mts
CHANGED
@@ -75,7 +75,6 @@ declare class OpenTelemetryCollector<AppliedMetricsDefinition extends MetricsDef
|
|
75
75
|
declare const httpRequestsTotalCounter: Counter<{
|
76
76
|
"service.name": string;
|
77
77
|
"api.name": string;
|
78
|
-
"correlation.id": string;
|
79
78
|
"http.request.method": string;
|
80
79
|
"http.route": string;
|
81
80
|
"http.response.status_code": number;
|
@@ -258,7 +257,7 @@ type TokenOptions = {
|
|
258
257
|
type DecodeResource = (token: string) => JWTPayload | Promise<JWTPayload>;
|
259
258
|
type AuthMethodsBase = TokenOptions & (HmacMethods | ({
|
260
259
|
readonly decodeResource?: DecodeResource;
|
261
|
-
} & (BasicAuthMethods | JwtAuthMethods)));
|
260
|
+
} & (PermissionSet | RoleSet) & (BasicAuthMethods | JwtAuthMethods)));
|
262
261
|
type PermissionSet = {
|
263
262
|
readonly allowedPermissions: Set<string>;
|
264
263
|
} | {
|
@@ -272,11 +271,11 @@ type RoleSet = {
|
|
272
271
|
/**
|
273
272
|
* Type representing the authentication methods.
|
274
273
|
*/
|
275
|
-
type SchemaAuthMethods<SV extends AnySchemaValidator, ParamsSchema extends ParamsObject<SV>, ReqBody extends Body<SV>, QuerySchema extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method>, SessionSchema extends SessionObject<SV>, BaseRequest> = AuthMethodsBase & (
|
274
|
+
type SchemaAuthMethods<SV extends AnySchemaValidator, ParamsSchema extends ParamsObject<SV>, ReqBody extends Body<SV>, QuerySchema extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method>, SessionSchema extends SessionObject<SV>, BaseRequest> = AuthMethodsBase & ({
|
276
275
|
readonly surfacePermissions?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionSchema, BaseRequest>;
|
277
|
-
}
|
276
|
+
} | {
|
278
277
|
readonly surfaceRoles?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionSchema, BaseRequest>;
|
279
|
-
}
|
278
|
+
}) & {
|
280
279
|
readonly sessionSchema?: SessionSchema;
|
281
280
|
readonly requiredScope?: string;
|
282
281
|
readonly scopeHeirarchy?: string[];
|
@@ -1686,6 +1685,25 @@ interface ClusterConfig<ExpressApp> {
|
|
1686
1685
|
|
1687
1686
|
declare function isPortBound(port: number, host?: string): Promise<boolean>;
|
1688
1687
|
|
1688
|
+
/**
|
1689
|
+
* Creates an HMAC token for a given method, path, body, timestamp, nonce, and secret key.
|
1690
|
+
* @param method - The HTTP method to use.
|
1691
|
+
* @param path - The path to use.
|
1692
|
+
* @param body - The body to use.
|
1693
|
+
* @param timestamp - The timestamp to use.
|
1694
|
+
* @param nonce - The nonce to use.
|
1695
|
+
* @param secretKey - The secret key to use.
|
1696
|
+
* @returns The HMAC token.
|
1697
|
+
*/
|
1698
|
+
declare function createHmacToken({ method, path, body, timestamp, nonce, secretKey }: {
|
1699
|
+
method: string;
|
1700
|
+
path: string;
|
1701
|
+
body: string;
|
1702
|
+
timestamp: string;
|
1703
|
+
nonce: string;
|
1704
|
+
secretKey: string;
|
1705
|
+
}): string;
|
1706
|
+
|
1689
1707
|
/**
|
1690
1708
|
* Type guard that checks if an object is a Forklaunch request.
|
1691
1709
|
* A Forklaunch request is an object that contains contract details and follows the Forklaunch request structure.
|
@@ -2157,4 +2175,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
|
|
2157
2175
|
|
2158
2176
|
declare function recordMetric<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ResBodyMap extends Record<string, unknown>, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Extract<keyof VersionedReqs, string>, SessionSchema>, res: ForklaunchResponse<unknown, ResBodyMap, ResHeaders, LocalsObj, Extract<keyof VersionedReqs, string>>): void;
|
2159
2177
|
|
2160
|
-
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type AuthMethods, type AuthMethodsBase, type BasicAuthMethods, type Body, type BodyObject, type ClusterConfig, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type DecodeResource, type DocsConfiguration, type ErrorContainer, type ExpressLikeApplicationOptions, type ExpressLikeAuthMapper, type ExpressLikeGlobalAuthOptions, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeRouterOptions, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaGlobalAuthOptions, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractBody, type ExtractContentType, type ExtractLiveTypeFn, type ExtractResponseBody, type ExtractedParamsObject, type FetchFunction, type FileBody, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HmacMethods, type HttpContractDetails, type HttpMethod, type JsonBody, type JwtAuthMethods, type LiveSdkFunction, type LiveTypeFunction, type LiveTypeFunctionRequestInit, type LiveTypeRouteDefinition, type LogFn, type LoggerMeta, type MapControllerToSdk, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type MapSessionSchema, type MapToFetch, type MapToSdk, type MapVersionedReqsSchema, type MapVersionedRespsSchema, type Method, type MetricType, type MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type MultipartForm, type NestableRouterBasedHandler, type NumberOnlyObject, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, type QueryObject, type RawTypedResponseBody, type RequestContext, type ResolvedForklaunchAuthRequest, type ResolvedForklaunchRequest, type ResolvedForklaunchResponse, type ResponseBody, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type RouterMap, type RoutingStrategy, type SchemaAuthMethods, type SdkHandler, type SdkRouter, type ServerSentEventBody, type SessionObject, type StatusCode, type StringOnlyObject, type TelemetryOptions, type TextBody, type ToFetchMap, type TypedBody, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, type TypedRequestBody, type TypedResponseBody, type UnknownBody, type UnknownResponseBody, type UrlEncodedForm, type VersionSchema, type VersionedRequests, type VersionedResponses, delete_, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCodeForStatus, head, httpRequestsTotalCounter, httpServerDurationHistogram, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, sdkClient, sdkRouter, trace, typedAuthHandler, typedHandler };
|
2178
|
+
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type AuthMethods, type AuthMethodsBase, type BasicAuthMethods, type Body, type BodyObject, type ClusterConfig, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type DecodeResource, type DocsConfiguration, type ErrorContainer, type ExpressLikeApplicationOptions, type ExpressLikeAuthMapper, type ExpressLikeGlobalAuthOptions, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeRouterOptions, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaGlobalAuthOptions, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractBody, type ExtractContentType, type ExtractLiveTypeFn, type ExtractResponseBody, type ExtractedParamsObject, type FetchFunction, type FileBody, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HmacMethods, type HttpContractDetails, type HttpMethod, type JsonBody, type JwtAuthMethods, type LiveSdkFunction, type LiveTypeFunction, type LiveTypeFunctionRequestInit, type LiveTypeRouteDefinition, type LogFn, type LoggerMeta, type MapControllerToSdk, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type MapSessionSchema, type MapToFetch, type MapToSdk, type MapVersionedReqsSchema, type MapVersionedRespsSchema, type Method, type MetricType, type MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type MultipartForm, type NestableRouterBasedHandler, type NumberOnlyObject, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, type QueryObject, type RawTypedResponseBody, type RequestContext, type ResolvedForklaunchAuthRequest, type ResolvedForklaunchRequest, type ResolvedForklaunchResponse, type ResponseBody, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type RouterMap, type RoutingStrategy, type SchemaAuthMethods, type SdkHandler, type SdkRouter, type ServerSentEventBody, type SessionObject, type StatusCode, type StringOnlyObject, type TelemetryOptions, type TextBody, type ToFetchMap, type TypedBody, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, type TypedRequestBody, type TypedResponseBody, type UnknownBody, type UnknownResponseBody, type UrlEncodedForm, type VersionSchema, type VersionedRequests, type VersionedResponses, createHmacToken, delete_, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCodeForStatus, head, httpRequestsTotalCounter, httpServerDurationHistogram, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, sdkClient, sdkRouter, trace, typedAuthHandler, typedHandler };
|
package/lib/http/index.d.ts
CHANGED
@@ -75,7 +75,6 @@ declare class OpenTelemetryCollector<AppliedMetricsDefinition extends MetricsDef
|
|
75
75
|
declare const httpRequestsTotalCounter: Counter<{
|
76
76
|
"service.name": string;
|
77
77
|
"api.name": string;
|
78
|
-
"correlation.id": string;
|
79
78
|
"http.request.method": string;
|
80
79
|
"http.route": string;
|
81
80
|
"http.response.status_code": number;
|
@@ -258,7 +257,7 @@ type TokenOptions = {
|
|
258
257
|
type DecodeResource = (token: string) => JWTPayload | Promise<JWTPayload>;
|
259
258
|
type AuthMethodsBase = TokenOptions & (HmacMethods | ({
|
260
259
|
readonly decodeResource?: DecodeResource;
|
261
|
-
} & (BasicAuthMethods | JwtAuthMethods)));
|
260
|
+
} & (PermissionSet | RoleSet) & (BasicAuthMethods | JwtAuthMethods)));
|
262
261
|
type PermissionSet = {
|
263
262
|
readonly allowedPermissions: Set<string>;
|
264
263
|
} | {
|
@@ -272,11 +271,11 @@ type RoleSet = {
|
|
272
271
|
/**
|
273
272
|
* Type representing the authentication methods.
|
274
273
|
*/
|
275
|
-
type SchemaAuthMethods<SV extends AnySchemaValidator, ParamsSchema extends ParamsObject<SV>, ReqBody extends Body<SV>, QuerySchema extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method>, SessionSchema extends SessionObject<SV>, BaseRequest> = AuthMethodsBase & (
|
274
|
+
type SchemaAuthMethods<SV extends AnySchemaValidator, ParamsSchema extends ParamsObject<SV>, ReqBody extends Body<SV>, QuerySchema extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method>, SessionSchema extends SessionObject<SV>, BaseRequest> = AuthMethodsBase & ({
|
276
275
|
readonly surfacePermissions?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionSchema, BaseRequest>;
|
277
|
-
}
|
276
|
+
} | {
|
278
277
|
readonly surfaceRoles?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionSchema, BaseRequest>;
|
279
|
-
}
|
278
|
+
}) & {
|
280
279
|
readonly sessionSchema?: SessionSchema;
|
281
280
|
readonly requiredScope?: string;
|
282
281
|
readonly scopeHeirarchy?: string[];
|
@@ -1686,6 +1685,25 @@ interface ClusterConfig<ExpressApp> {
|
|
1686
1685
|
|
1687
1686
|
declare function isPortBound(port: number, host?: string): Promise<boolean>;
|
1688
1687
|
|
1688
|
+
/**
|
1689
|
+
* Creates an HMAC token for a given method, path, body, timestamp, nonce, and secret key.
|
1690
|
+
* @param method - The HTTP method to use.
|
1691
|
+
* @param path - The path to use.
|
1692
|
+
* @param body - The body to use.
|
1693
|
+
* @param timestamp - The timestamp to use.
|
1694
|
+
* @param nonce - The nonce to use.
|
1695
|
+
* @param secretKey - The secret key to use.
|
1696
|
+
* @returns The HMAC token.
|
1697
|
+
*/
|
1698
|
+
declare function createHmacToken({ method, path, body, timestamp, nonce, secretKey }: {
|
1699
|
+
method: string;
|
1700
|
+
path: string;
|
1701
|
+
body: string;
|
1702
|
+
timestamp: string;
|
1703
|
+
nonce: string;
|
1704
|
+
secretKey: string;
|
1705
|
+
}): string;
|
1706
|
+
|
1689
1707
|
/**
|
1690
1708
|
* Type guard that checks if an object is a Forklaunch request.
|
1691
1709
|
* A Forklaunch request is an object that contains contract details and follows the Forklaunch request structure.
|
@@ -2157,4 +2175,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
|
|
2157
2175
|
|
2158
2176
|
declare function recordMetric<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ResBodyMap extends Record<string, unknown>, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Extract<keyof VersionedReqs, string>, SessionSchema>, res: ForklaunchResponse<unknown, ResBodyMap, ResHeaders, LocalsObj, Extract<keyof VersionedReqs, string>>): void;
|
2159
2177
|
|
2160
|
-
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type AuthMethods, type AuthMethodsBase, type BasicAuthMethods, type Body, type BodyObject, type ClusterConfig, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type DecodeResource, type DocsConfiguration, type ErrorContainer, type ExpressLikeApplicationOptions, type ExpressLikeAuthMapper, type ExpressLikeGlobalAuthOptions, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeRouterOptions, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaGlobalAuthOptions, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractBody, type ExtractContentType, type ExtractLiveTypeFn, type ExtractResponseBody, type ExtractedParamsObject, type FetchFunction, type FileBody, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HmacMethods, type HttpContractDetails, type HttpMethod, type JsonBody, type JwtAuthMethods, type LiveSdkFunction, type LiveTypeFunction, type LiveTypeFunctionRequestInit, type LiveTypeRouteDefinition, type LogFn, type LoggerMeta, type MapControllerToSdk, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type MapSessionSchema, type MapToFetch, type MapToSdk, type MapVersionedReqsSchema, type MapVersionedRespsSchema, type Method, type MetricType, type MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type MultipartForm, type NestableRouterBasedHandler, type NumberOnlyObject, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, type QueryObject, type RawTypedResponseBody, type RequestContext, type ResolvedForklaunchAuthRequest, type ResolvedForklaunchRequest, type ResolvedForklaunchResponse, type ResponseBody, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type RouterMap, type RoutingStrategy, type SchemaAuthMethods, type SdkHandler, type SdkRouter, type ServerSentEventBody, type SessionObject, type StatusCode, type StringOnlyObject, type TelemetryOptions, type TextBody, type ToFetchMap, type TypedBody, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, type TypedRequestBody, type TypedResponseBody, type UnknownBody, type UnknownResponseBody, type UrlEncodedForm, type VersionSchema, type VersionedRequests, type VersionedResponses, delete_, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCodeForStatus, head, httpRequestsTotalCounter, httpServerDurationHistogram, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, sdkClient, sdkRouter, trace, typedAuthHandler, typedHandler };
|
2178
|
+
export { ATTR_API_NAME, ATTR_CORRELATION_ID, type AuthMethods, type AuthMethodsBase, type BasicAuthMethods, type Body, type BodyObject, type ClusterConfig, type ConstrainedForklaunchRouter, type ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, type DecodeResource, type DocsConfiguration, type ErrorContainer, type ExpressLikeApplicationOptions, type ExpressLikeAuthMapper, type ExpressLikeGlobalAuthOptions, type ExpressLikeHandler, type ExpressLikeRouter, type ExpressLikeRouterOptions, type ExpressLikeSchemaAuthMapper, type ExpressLikeSchemaGlobalAuthOptions, type ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractBody, type ExtractContentType, type ExtractLiveTypeFn, type ExtractResponseBody, type ExtractedParamsObject, type FetchFunction, type FileBody, type ForklaunchBaseRequest, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, type ForklaunchNextFunction, type ForklaunchRequest, type ForklaunchResErrors, type ForklaunchResHeaders, type ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, type ForklaunchSendableData, type ForklaunchStatusResponse, HTTPStatuses, type HeadersObject, type HmacMethods, type HttpContractDetails, type HttpMethod, type JsonBody, type JwtAuthMethods, type LiveSdkFunction, type LiveTypeFunction, type LiveTypeFunctionRequestInit, type LiveTypeRouteDefinition, type LogFn, type LoggerMeta, type MapControllerToSdk, type MapParamsSchema, type MapReqBodySchema, type MapReqHeadersSchema, type MapReqQuerySchema, type MapResBodyMapSchema, type MapResHeadersSchema, type MapSchema, type MapSessionSchema, type MapToFetch, type MapToSdk, type MapVersionedReqsSchema, type MapVersionedRespsSchema, type Method, type MetricType, type MetricsDefinition, type MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type MultipartForm, type NestableRouterBasedHandler, type NumberOnlyObject, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, type ParamsDictionary, type ParamsObject, type PathBasedHandler, type PathMatch, type PathOrMiddlewareBasedHandler, type PathParamHttpContractDetails, type PathParamMethod, type QueryObject, type RawTypedResponseBody, type RequestContext, type ResolvedForklaunchAuthRequest, type ResolvedForklaunchRequest, type ResolvedForklaunchResponse, type ResponseBody, type ResponseCompiledSchema, type ResponseShape, type ResponsesObject, type RouterMap, type RoutingStrategy, type SchemaAuthMethods, type SdkHandler, type SdkRouter, type ServerSentEventBody, type SessionObject, type StatusCode, type StringOnlyObject, type TelemetryOptions, type TextBody, type ToFetchMap, type TypedBody, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, type TypedRequestBody, type TypedResponseBody, type UnknownBody, type UnknownResponseBody, type UrlEncodedForm, type VersionSchema, type VersionedRequests, type VersionedResponses, createHmacToken, delete_, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCodeForStatus, head, httpRequestsTotalCounter, httpServerDurationHistogram, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, sdkClient, sdkRouter, trace, typedAuthHandler, typedHandler };
|
package/lib/http/index.js
CHANGED
@@ -41,6 +41,7 @@ __export(http_exports, {
|
|
41
41
|
HTTPStatuses: () => HTTPStatuses,
|
42
42
|
OPENAPI_DEFAULT_VERSION: () => OPENAPI_DEFAULT_VERSION,
|
43
43
|
OpenTelemetryCollector: () => OpenTelemetryCollector,
|
44
|
+
createHmacToken: () => createHmacToken,
|
44
45
|
delete_: () => delete_,
|
45
46
|
discriminateBody: () => discriminateBody,
|
46
47
|
discriminateResponseBodies: () => discriminateResponseBodies,
|
@@ -159,9 +160,27 @@ function isTypedHandler(maybeTypedHandler) {
|
|
159
160
|
var import_common2 = require("@forklaunch/common");
|
160
161
|
|
161
162
|
// src/http/discriminateAuthMethod.ts
|
162
|
-
var import_crypto = require("crypto");
|
163
163
|
var import_jose = require("jose");
|
164
164
|
|
165
|
+
// src/http/createHmacToken.ts
|
166
|
+
var import_crypto = require("crypto");
|
167
|
+
function createHmacToken({
|
168
|
+
method,
|
169
|
+
path,
|
170
|
+
body,
|
171
|
+
timestamp,
|
172
|
+
nonce,
|
173
|
+
secretKey
|
174
|
+
}) {
|
175
|
+
const hmac = (0, import_crypto.createHmac)("sha256", secretKey);
|
176
|
+
hmac.update(`${method}
|
177
|
+
${path}
|
178
|
+
${body}
|
179
|
+
${timestamp}
|
180
|
+
${nonce}`);
|
181
|
+
return hmac.digest("base64");
|
182
|
+
}
|
183
|
+
|
165
184
|
// src/http/guards/isBasicAuthMethod.ts
|
166
185
|
function isBasicAuthMethod(maybeBasicAuthMethod) {
|
167
186
|
return typeof maybeBasicAuthMethod === "object" && maybeBasicAuthMethod !== null && "basic" in maybeBasicAuthMethod && maybeBasicAuthMethod.basic != null;
|
@@ -231,14 +250,14 @@ async function discriminateAuthMethod(auth) {
|
|
231
250
|
auth: {
|
232
251
|
secretKeys: auth.hmac.secretKeys,
|
233
252
|
verificationFunction: async (method, path, body, timestamp, nonce, signature, secretKey) => {
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
253
|
+
return createHmacToken({
|
254
|
+
method,
|
255
|
+
path,
|
256
|
+
body,
|
257
|
+
timestamp,
|
258
|
+
nonce,
|
259
|
+
secretKey
|
260
|
+
}) === signature;
|
242
261
|
}
|
243
262
|
}
|
244
263
|
};
|
@@ -3354,7 +3373,6 @@ function recordMetric(req, res) {
|
|
3354
3373
|
httpRequestsTotalCounter.add(1, {
|
3355
3374
|
[import_semantic_conventions3.ATTR_SERVICE_NAME]: (0, import_common10.getEnvVar)("OTEL_SERVICE_NAME"),
|
3356
3375
|
[ATTR_API_NAME]: req.contractDetails?.name,
|
3357
|
-
[ATTR_CORRELATION_ID]: req.context.correlationId,
|
3358
3376
|
[import_semantic_conventions3.ATTR_HTTP_REQUEST_METHOD]: req.method,
|
3359
3377
|
[import_semantic_conventions3.ATTR_HTTP_ROUTE]: req.originalPath,
|
3360
3378
|
[import_semantic_conventions3.ATTR_HTTP_RESPONSE_STATUS_CODE]: Number(res.statusCode) || 0
|
@@ -3979,6 +3997,7 @@ function metricsDefinitions(metrics2) {
|
|
3979
3997
|
HTTPStatuses,
|
3980
3998
|
OPENAPI_DEFAULT_VERSION,
|
3981
3999
|
OpenTelemetryCollector,
|
4000
|
+
createHmacToken,
|
3982
4001
|
delete_,
|
3983
4002
|
discriminateBody,
|
3984
4003
|
discriminateResponseBodies,
|