@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.d.mts
CHANGED
@@ -257,7 +257,7 @@ type TokenOptions = {
|
|
257
257
|
type DecodeResource = (token: string) => JWTPayload | Promise<JWTPayload>;
|
258
258
|
type AuthMethodsBase = TokenOptions & (HmacMethods | ({
|
259
259
|
readonly decodeResource?: DecodeResource;
|
260
|
-
} & (BasicAuthMethods | JwtAuthMethods)));
|
260
|
+
} & (PermissionSet | RoleSet) & (BasicAuthMethods | JwtAuthMethods)));
|
261
261
|
type PermissionSet = {
|
262
262
|
readonly allowedPermissions: Set<string>;
|
263
263
|
} | {
|
@@ -271,11 +271,11 @@ type RoleSet = {
|
|
271
271
|
/**
|
272
272
|
* Type representing the authentication methods.
|
273
273
|
*/
|
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 & (
|
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 & ({
|
275
275
|
readonly surfacePermissions?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionSchema, BaseRequest>;
|
276
|
-
}
|
276
|
+
} | {
|
277
277
|
readonly surfaceRoles?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionSchema, BaseRequest>;
|
278
|
-
}
|
278
|
+
}) & {
|
279
279
|
readonly sessionSchema?: SessionSchema;
|
280
280
|
readonly requiredScope?: string;
|
281
281
|
readonly scopeHeirarchy?: string[];
|
@@ -1685,6 +1685,25 @@ interface ClusterConfig<ExpressApp> {
|
|
1685
1685
|
|
1686
1686
|
declare function isPortBound(port: number, host?: string): Promise<boolean>;
|
1687
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
|
+
|
1688
1707
|
/**
|
1689
1708
|
* Type guard that checks if an object is a Forklaunch request.
|
1690
1709
|
* A Forklaunch request is an object that contains contract details and follows the Forklaunch request structure.
|
@@ -2156,4 +2175,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
|
|
2156
2175
|
|
2157
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;
|
2158
2177
|
|
2159
|
-
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
@@ -257,7 +257,7 @@ type TokenOptions = {
|
|
257
257
|
type DecodeResource = (token: string) => JWTPayload | Promise<JWTPayload>;
|
258
258
|
type AuthMethodsBase = TokenOptions & (HmacMethods | ({
|
259
259
|
readonly decodeResource?: DecodeResource;
|
260
|
-
} & (BasicAuthMethods | JwtAuthMethods)));
|
260
|
+
} & (PermissionSet | RoleSet) & (BasicAuthMethods | JwtAuthMethods)));
|
261
261
|
type PermissionSet = {
|
262
262
|
readonly allowedPermissions: Set<string>;
|
263
263
|
} | {
|
@@ -271,11 +271,11 @@ type RoleSet = {
|
|
271
271
|
/**
|
272
272
|
* Type representing the authentication methods.
|
273
273
|
*/
|
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 & (
|
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 & ({
|
275
275
|
readonly surfacePermissions?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionSchema, BaseRequest>;
|
276
|
-
}
|
276
|
+
} | {
|
277
277
|
readonly surfaceRoles?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionSchema, BaseRequest>;
|
278
|
-
}
|
278
|
+
}) & {
|
279
279
|
readonly sessionSchema?: SessionSchema;
|
280
280
|
readonly requiredScope?: string;
|
281
281
|
readonly scopeHeirarchy?: string[];
|
@@ -1685,6 +1685,25 @@ interface ClusterConfig<ExpressApp> {
|
|
1685
1685
|
|
1686
1686
|
declare function isPortBound(port: number, host?: string): Promise<boolean>;
|
1687
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
|
+
|
1688
1707
|
/**
|
1689
1708
|
* Type guard that checks if an object is a Forklaunch request.
|
1690
1709
|
* A Forklaunch request is an object that contains contract details and follows the Forklaunch request structure.
|
@@ -2156,4 +2175,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
|
|
2156
2175
|
|
2157
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;
|
2158
2177
|
|
2159
|
-
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
|
};
|
@@ -3978,6 +3997,7 @@ function metricsDefinitions(metrics2) {
|
|
3978
3997
|
HTTPStatuses,
|
3979
3998
|
OPENAPI_DEFAULT_VERSION,
|
3980
3999
|
OpenTelemetryCollector,
|
4000
|
+
createHmacToken,
|
3981
4001
|
delete_,
|
3982
4002
|
discriminateBody,
|
3983
4003
|
discriminateResponseBodies,
|