@temporary-name/server 0.0.1-alpha.0cb08cf84b740850e7d8dcd1d8b87f78af26071b

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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/dist/adapters/aws-lambda/index.d.mts +26 -0
  4. package/dist/adapters/aws-lambda/index.d.ts +26 -0
  5. package/dist/adapters/aws-lambda/index.mjs +30 -0
  6. package/dist/adapters/fastify/index.d.mts +23 -0
  7. package/dist/adapters/fastify/index.d.ts +23 -0
  8. package/dist/adapters/fastify/index.mjs +30 -0
  9. package/dist/adapters/fetch/index.d.mts +28 -0
  10. package/dist/adapters/fetch/index.d.ts +28 -0
  11. package/dist/adapters/fetch/index.mjs +32 -0
  12. package/dist/adapters/node/index.d.mts +26 -0
  13. package/dist/adapters/node/index.d.ts +26 -0
  14. package/dist/adapters/node/index.mjs +30 -0
  15. package/dist/handler/index.d.mts +22 -0
  16. package/dist/handler/index.d.ts +22 -0
  17. package/dist/handler/index.mjs +8 -0
  18. package/dist/helpers/index.d.mts +149 -0
  19. package/dist/helpers/index.d.ts +149 -0
  20. package/dist/helpers/index.mjs +142 -0
  21. package/dist/index.d.mts +395 -0
  22. package/dist/index.d.ts +395 -0
  23. package/dist/index.mjs +831 -0
  24. package/dist/openapi/index.d.mts +167 -0
  25. package/dist/openapi/index.d.ts +167 -0
  26. package/dist/openapi/index.mjs +15 -0
  27. package/dist/shared/server.BOkueCuE.d.ts +39 -0
  28. package/dist/shared/server.BTVDgKdb.d.mts +9552 -0
  29. package/dist/shared/server.BTVDgKdb.d.ts +9552 -0
  30. package/dist/shared/server.C1RJffw4.mjs +30 -0
  31. package/dist/shared/server.CWiZN27E.d.mts +39 -0
  32. package/dist/shared/server.CjPiuQYH.d.mts +51 -0
  33. package/dist/shared/server.CjPiuQYH.d.ts +51 -0
  34. package/dist/shared/server.D7jtfDRy.mjs +288 -0
  35. package/dist/shared/server.JwVIEHL6.mjs +386 -0
  36. package/dist/shared/server.RQr7F4gX.mjs +1292 -0
  37. package/package.json +87 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Stainless
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ > [!NOTE]
2
+ > In the spirit of writing the press release first, drafting some content here as we go.
3
+
4
+ # Crusty [name WIP]
5
+
6
+ Crusty is an API framework that does the right thing by default.
7
+
8
+ > Everything should be possible, but correct things should be easy
9
+
10
+ Have you ever accidentally left out a single line of code and ended up with an unauthenticated API endpoint? Accidentally rendered an incoherent error format (or worse, returned HTML when you 500)?
11
+
12
+ Crusty takes the lessons from shipping massive production APIs (we built Stripe's API abstractions) and makes them available to everyone.
13
+
14
+ ## What is an API framework?
15
+
16
+ The frameworks you're probably thinking of are more like HTTP frameworks: they offer routing, middleware, and maybe some helpers around authentication and parameter validation.
17
+
18
+ This is great, but there's a layer on top of them that's missing, and every company ends up building themselves:
19
+
20
+ - Authentication & authorization
21
+ - Gating (expose certain request/response params to certain customers)
22
+ - Versioning (this one's gnarly!)
23
+ - Logging
24
+ - Error handling/rendering
25
+ - Rate limiting
26
+ - Idempotency
27
+ - Documentation/spec generation
28
+
29
+ Middleware is powerful for much of this, but in many ways it's lowest-common-denominator and you still need to build a lot of custom code to make these happen.
30
+
31
+ Crusty is a layer on top of your HTTP framework that adds best-in-class primitives for all of these.
@@ -0,0 +1,26 @@
1
+ import { MaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { SendStandardResponseOptions, APIGatewayProxyEventV2, ResponseStream } from '@temporary-name/standard-server-aws-lambda';
3
+ import { I as ImplementedResource, a as InferResourceContext } from '../../shared/server.BTVDgKdb.mjs';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.CWiZN27E.mjs';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ interface AwsLambdaHandlerOptions extends SendStandardResponseOptions {
9
+ }
10
+ type AwsLambdaHandleResult = {
11
+ matched: true;
12
+ } | {
13
+ matched: false;
14
+ };
15
+ /**
16
+ * OpenAPI Handler for AWS Lambda.
17
+ */
18
+ declare class AwsLambdaHandler<T extends ImplementedResource> {
19
+ private readonly sendStandardResponseOptions;
20
+ private readonly standardHandler;
21
+ constructor(resources: T[], options?: AwsLambdaHandlerOptions);
22
+ handle(event: APIGatewayProxyEventV2, responseStream: ResponseStream, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<InferResourceContext<T>>>): Promise<AwsLambdaHandleResult>;
23
+ }
24
+
25
+ export { AwsLambdaHandler };
26
+ export type { AwsLambdaHandleResult, AwsLambdaHandlerOptions };
@@ -0,0 +1,26 @@
1
+ import { MaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { SendStandardResponseOptions, APIGatewayProxyEventV2, ResponseStream } from '@temporary-name/standard-server-aws-lambda';
3
+ import { I as ImplementedResource, a as InferResourceContext } from '../../shared/server.BTVDgKdb.js';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.BOkueCuE.js';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ interface AwsLambdaHandlerOptions extends SendStandardResponseOptions {
9
+ }
10
+ type AwsLambdaHandleResult = {
11
+ matched: true;
12
+ } | {
13
+ matched: false;
14
+ };
15
+ /**
16
+ * OpenAPI Handler for AWS Lambda.
17
+ */
18
+ declare class AwsLambdaHandler<T extends ImplementedResource> {
19
+ private readonly sendStandardResponseOptions;
20
+ private readonly standardHandler;
21
+ constructor(resources: T[], options?: AwsLambdaHandlerOptions);
22
+ handle(event: APIGatewayProxyEventV2, responseStream: ResponseStream, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<InferResourceContext<T>>>): Promise<AwsLambdaHandleResult>;
23
+ }
24
+
25
+ export { AwsLambdaHandler };
26
+ export type { AwsLambdaHandleResult, AwsLambdaHandlerOptions };
@@ -0,0 +1,30 @@
1
+ import { resolveMaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { toStandardLazyRequest, sendStandardResponse } from '@temporary-name/standard-server-aws-lambda';
3
+ import { S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.JwVIEHL6.mjs';
4
+ import '@temporary-name/server';
5
+ import '@temporary-name/standard-server';
6
+ import 'neoqs';
7
+ import '../../shared/server.D7jtfDRy.mjs';
8
+ import 'rou3';
9
+ import '@temporary-name/zod';
10
+
11
+ class AwsLambdaHandler {
12
+ sendStandardResponseOptions;
13
+ standardHandler;
14
+ constructor(resources, options = {}) {
15
+ this.standardHandler = new StandardHandler(resources);
16
+ this.sendStandardResponseOptions = options;
17
+ }
18
+ async handle(event, responseStream, ...rest) {
19
+ const standardRequest = toStandardLazyRequest(event, responseStream);
20
+ const options = resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest));
21
+ const result = await this.standardHandler.handle(standardRequest, options);
22
+ if (!result.matched) {
23
+ return { matched: false };
24
+ }
25
+ await sendStandardResponse(responseStream, result.response, this.sendStandardResponseOptions);
26
+ return { matched: true };
27
+ }
28
+ }
29
+
30
+ export { AwsLambdaHandler };
@@ -0,0 +1,23 @@
1
+ import { MaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { SendStandardResponseOptions, FastifyRequest, FastifyReply } from '@temporary-name/standard-server-fastify';
3
+ import { I as ImplementedResource, a as InferResourceContext } from '../../shared/server.BTVDgKdb.mjs';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.CWiZN27E.mjs';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ type FastifyHandleResult = {
9
+ matched: true;
10
+ } | {
11
+ matched: false;
12
+ };
13
+ interface FastifyHandlerOptions extends SendStandardResponseOptions {
14
+ }
15
+ declare class FastifyHandler<T extends ImplementedResource> {
16
+ private readonly sendStandardResponseOptions;
17
+ private readonly standardHandler;
18
+ constructor(resources: T[], options?: NoInfer<FastifyHandlerOptions>);
19
+ handle(request: FastifyRequest, reply: FastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<InferResourceContext<T>>>): Promise<FastifyHandleResult>;
20
+ }
21
+
22
+ export { FastifyHandler };
23
+ export type { FastifyHandleResult, FastifyHandlerOptions };
@@ -0,0 +1,23 @@
1
+ import { MaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { SendStandardResponseOptions, FastifyRequest, FastifyReply } from '@temporary-name/standard-server-fastify';
3
+ import { I as ImplementedResource, a as InferResourceContext } from '../../shared/server.BTVDgKdb.js';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.BOkueCuE.js';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ type FastifyHandleResult = {
9
+ matched: true;
10
+ } | {
11
+ matched: false;
12
+ };
13
+ interface FastifyHandlerOptions extends SendStandardResponseOptions {
14
+ }
15
+ declare class FastifyHandler<T extends ImplementedResource> {
16
+ private readonly sendStandardResponseOptions;
17
+ private readonly standardHandler;
18
+ constructor(resources: T[], options?: NoInfer<FastifyHandlerOptions>);
19
+ handle(request: FastifyRequest, reply: FastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<InferResourceContext<T>>>): Promise<FastifyHandleResult>;
20
+ }
21
+
22
+ export { FastifyHandler };
23
+ export type { FastifyHandleResult, FastifyHandlerOptions };
@@ -0,0 +1,30 @@
1
+ import { resolveMaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { toStandardLazyRequest, sendStandardResponse } from '@temporary-name/standard-server-fastify';
3
+ import { S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.JwVIEHL6.mjs';
4
+ import '@temporary-name/server';
5
+ import '@temporary-name/standard-server';
6
+ import 'neoqs';
7
+ import '../../shared/server.D7jtfDRy.mjs';
8
+ import 'rou3';
9
+ import '@temporary-name/zod';
10
+
11
+ class FastifyHandler {
12
+ sendStandardResponseOptions;
13
+ standardHandler;
14
+ constructor(resources, options = {}) {
15
+ this.standardHandler = new StandardHandler(resources);
16
+ this.sendStandardResponseOptions = options;
17
+ }
18
+ async handle(request, reply, ...rest) {
19
+ const options = resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest));
20
+ const standardRequest = toStandardLazyRequest(request, reply);
21
+ const result = await this.standardHandler.handle(standardRequest, options);
22
+ if (!result.matched) {
23
+ return { matched: false };
24
+ }
25
+ await sendStandardResponse(reply, result.response, this.sendStandardResponseOptions);
26
+ return { matched: true };
27
+ }
28
+ }
29
+
30
+ export { FastifyHandler };
@@ -0,0 +1,28 @@
1
+ import { MaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { ToFetchResponseOptions } from '@temporary-name/standard-server-fetch';
3
+ import { I as ImplementedResource, a as InferResourceContext } from '../../shared/server.BTVDgKdb.mjs';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.CWiZN27E.mjs';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ type FetchHandleResult = {
9
+ matched: true;
10
+ response: Response;
11
+ } | {
12
+ matched: false;
13
+ response: undefined;
14
+ };
15
+ interface FetchHandlerOptions extends ToFetchResponseOptions {
16
+ }
17
+ /**
18
+ * OpenAPI Handler for Fetch Server
19
+ */
20
+ declare class FetchHandler<T extends ImplementedResource> {
21
+ private readonly toFetchResponseOptions;
22
+ private readonly standardHandler;
23
+ constructor(resources: T[], options?: NoInfer<FetchHandlerOptions>);
24
+ handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<InferResourceContext<T>>>): Promise<FetchHandleResult>;
25
+ }
26
+
27
+ export { FetchHandler };
28
+ export type { FetchHandleResult, FetchHandlerOptions };
@@ -0,0 +1,28 @@
1
+ import { MaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { ToFetchResponseOptions } from '@temporary-name/standard-server-fetch';
3
+ import { I as ImplementedResource, a as InferResourceContext } from '../../shared/server.BTVDgKdb.js';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.BOkueCuE.js';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ type FetchHandleResult = {
9
+ matched: true;
10
+ response: Response;
11
+ } | {
12
+ matched: false;
13
+ response: undefined;
14
+ };
15
+ interface FetchHandlerOptions extends ToFetchResponseOptions {
16
+ }
17
+ /**
18
+ * OpenAPI Handler for Fetch Server
19
+ */
20
+ declare class FetchHandler<T extends ImplementedResource> {
21
+ private readonly toFetchResponseOptions;
22
+ private readonly standardHandler;
23
+ constructor(resources: T[], options?: NoInfer<FetchHandlerOptions>);
24
+ handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<InferResourceContext<T>>>): Promise<FetchHandleResult>;
25
+ }
26
+
27
+ export { FetchHandler };
28
+ export type { FetchHandleResult, FetchHandlerOptions };
@@ -0,0 +1,32 @@
1
+ import { resolveMaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { toStandardLazyRequest, toFetchResponse } from '@temporary-name/standard-server-fetch';
3
+ import { S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.JwVIEHL6.mjs';
4
+ import '@temporary-name/server';
5
+ import '@temporary-name/standard-server';
6
+ import 'neoqs';
7
+ import '../../shared/server.D7jtfDRy.mjs';
8
+ import 'rou3';
9
+ import '@temporary-name/zod';
10
+
11
+ class FetchHandler {
12
+ toFetchResponseOptions;
13
+ standardHandler;
14
+ constructor(resources, options = {}) {
15
+ this.standardHandler = new StandardHandler(resources);
16
+ this.toFetchResponseOptions = options;
17
+ }
18
+ async handle(request, ...rest) {
19
+ const options = resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest));
20
+ const standardRequest = toStandardLazyRequest(request);
21
+ const result = await this.standardHandler.handle(standardRequest, options);
22
+ if (!result.matched) {
23
+ return result;
24
+ }
25
+ return {
26
+ matched: true,
27
+ response: toFetchResponse(result.response, this.toFetchResponseOptions)
28
+ };
29
+ }
30
+ }
31
+
32
+ export { FetchHandler };
@@ -0,0 +1,26 @@
1
+ import { MaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@temporary-name/standard-server-node';
3
+ import { I as ImplementedResource, a as InferResourceContext } from '../../shared/server.BTVDgKdb.mjs';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.CWiZN27E.mjs';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ type NodeHttpHandleResult = {
9
+ matched: true;
10
+ } | {
11
+ matched: false;
12
+ };
13
+ interface NodeHttpHandlerOptions extends SendStandardResponseOptions {
14
+ }
15
+ /**
16
+ * OpenAPI Handler for Node Server
17
+ */
18
+ declare class NodeHttpHandler<T extends ImplementedResource> {
19
+ private readonly sendStandardResponseOptions;
20
+ private readonly standardHandler;
21
+ constructor(resources: T[], options?: NoInfer<NodeHttpHandlerOptions>);
22
+ handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<InferResourceContext<T>>>): Promise<NodeHttpHandleResult>;
23
+ }
24
+
25
+ export { NodeHttpHandler };
26
+ export type { NodeHttpHandleResult, NodeHttpHandlerOptions };
@@ -0,0 +1,26 @@
1
+ import { MaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@temporary-name/standard-server-node';
3
+ import { I as ImplementedResource, a as InferResourceContext } from '../../shared/server.BTVDgKdb.js';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.BOkueCuE.js';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ type NodeHttpHandleResult = {
9
+ matched: true;
10
+ } | {
11
+ matched: false;
12
+ };
13
+ interface NodeHttpHandlerOptions extends SendStandardResponseOptions {
14
+ }
15
+ /**
16
+ * OpenAPI Handler for Node Server
17
+ */
18
+ declare class NodeHttpHandler<T extends ImplementedResource> {
19
+ private readonly sendStandardResponseOptions;
20
+ private readonly standardHandler;
21
+ constructor(resources: T[], options?: NoInfer<NodeHttpHandlerOptions>);
22
+ handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<InferResourceContext<T>>>): Promise<NodeHttpHandleResult>;
23
+ }
24
+
25
+ export { NodeHttpHandler };
26
+ export type { NodeHttpHandleResult, NodeHttpHandlerOptions };
@@ -0,0 +1,30 @@
1
+ import { resolveMaybeOptionalOptions } from '@temporary-name/shared';
2
+ import { toStandardLazyRequest, sendStandardResponse } from '@temporary-name/standard-server-node';
3
+ import { S as StandardHandler, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.JwVIEHL6.mjs';
4
+ import '@temporary-name/server';
5
+ import '@temporary-name/standard-server';
6
+ import 'neoqs';
7
+ import '../../shared/server.D7jtfDRy.mjs';
8
+ import 'rou3';
9
+ import '@temporary-name/zod';
10
+
11
+ class NodeHttpHandler {
12
+ sendStandardResponseOptions;
13
+ standardHandler;
14
+ constructor(resources, options = {}) {
15
+ this.standardHandler = new StandardHandler(resources);
16
+ this.sendStandardResponseOptions = options;
17
+ }
18
+ async handle(request, response, ...rest) {
19
+ const options = resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest));
20
+ const standardRequest = toStandardLazyRequest(request, response);
21
+ const result = await this.standardHandler.handle(standardRequest, options);
22
+ if (!result.matched) {
23
+ return { matched: false };
24
+ }
25
+ await sendStandardResponse(response, result.response, this.sendStandardResponseOptions);
26
+ return { matched: true };
27
+ }
28
+ }
29
+
30
+ export { NodeHttpHandler };
@@ -0,0 +1,22 @@
1
+ export { F as FriendlyStandardHandleOptions, S as StandardHandleOptions, a as StandardHandleResult, b as StandardHandler, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../shared/server.CWiZN27E.mjs';
2
+ import { Input, AnyMethod } from '@temporary-name/server';
3
+ import { StandardLazyRequest, StandardResponse, HTTPPath } from '@temporary-name/shared';
4
+ import { aj as AnyMethod$1, I as ImplementedResource } from '../shared/server.BTVDgKdb.mjs';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ declare function decode(request: StandardLazyRequest, pathParams: Record<string, string> | undefined): Promise<Input>;
9
+ declare function encode(output: unknown, method: AnyMethod): StandardResponse;
10
+
11
+ type StandardMatchResult = {
12
+ method: AnyMethod$1;
13
+ params?: Record<string, string>;
14
+ } | undefined;
15
+ declare class StandardOpenAPIMatcher {
16
+ private readonly tree;
17
+ constructor(resources: ImplementedResource[]);
18
+ match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
19
+ }
20
+
21
+ export { StandardOpenAPIMatcher, decode, encode };
22
+ export type { StandardMatchResult };
@@ -0,0 +1,22 @@
1
+ export { F as FriendlyStandardHandleOptions, S as StandardHandleOptions, a as StandardHandleResult, b as StandardHandler, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../shared/server.BOkueCuE.js';
2
+ import { Input, AnyMethod } from '@temporary-name/server';
3
+ import { StandardLazyRequest, StandardResponse, HTTPPath } from '@temporary-name/shared';
4
+ import { aj as AnyMethod$1, I as ImplementedResource } from '../shared/server.BTVDgKdb.js';
5
+ import '@temporary-name/zod';
6
+ import 'zod/v4/core';
7
+
8
+ declare function decode(request: StandardLazyRequest, pathParams: Record<string, string> | undefined): Promise<Input>;
9
+ declare function encode(output: unknown, method: AnyMethod): StandardResponse;
10
+
11
+ type StandardMatchResult = {
12
+ method: AnyMethod$1;
13
+ params?: Record<string, string>;
14
+ } | undefined;
15
+ declare class StandardOpenAPIMatcher {
16
+ private readonly tree;
17
+ constructor(resources: ImplementedResource[]);
18
+ match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
19
+ }
20
+
21
+ export { StandardOpenAPIMatcher, decode, encode };
22
+ export type { StandardMatchResult };
@@ -0,0 +1,8 @@
1
+ export { S as StandardHandler, a as StandardOpenAPIMatcher, d as decode, b as decodeParams, e as encode, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../shared/server.JwVIEHL6.mjs';
2
+ import '@temporary-name/shared';
3
+ import '../shared/server.D7jtfDRy.mjs';
4
+ import '@temporary-name/zod';
5
+ import '@temporary-name/standard-server';
6
+ import '@temporary-name/server';
7
+ import 'neoqs';
8
+ import 'rou3';
@@ -0,0 +1,149 @@
1
+ import { SerializeOptions, ParseOptions } from 'cookie';
2
+
3
+ /**
4
+ * Encodes a Uint8Array to base64url format
5
+ * Base64url is URL-safe and doesn't use padding
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const text = "Hello World"
10
+ * const encoded = encodeBase64url(new TextEncoder().encode(text))
11
+ * const decoded = decodeBase64url(encoded)
12
+ * expect(new TextDecoder().decode(decoded)).toEqual(text)
13
+ * ```
14
+ */
15
+ declare function encodeBase64url(data: Uint8Array): string;
16
+ /**
17
+ * Decodes a base64url string to Uint8Array
18
+ * Returns undefined if the input is invalid
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const text = "Hello World"
23
+ * const encoded = encodeBase64url(new TextEncoder().encode(text))
24
+ * const decoded = decodeBase64url(encoded)
25
+ * expect(new TextDecoder().decode(decoded)).toEqual(text)
26
+ * ```
27
+ */
28
+ declare function decodeBase64url(base64url: string | undefined | null): Uint8Array<ArrayBuffer> | undefined;
29
+
30
+ interface SetCookieOptions extends SerializeOptions {
31
+ /**
32
+ * Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
33
+ *
34
+ * @default '/'
35
+ */
36
+ path?: string;
37
+ }
38
+ /**
39
+ * Sets a cookie in the response headers,
40
+ *
41
+ * Does nothing if `headers` is `undefined`.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const headers = new Headers()
46
+ *
47
+ * setCookie(headers, 'sessionId', 'abc123', { httpOnly: true, maxAge: 3600 })
48
+ *
49
+ * expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; HttpOnly; Max-Age=3600')
50
+ * ```
51
+ *
52
+ */
53
+ declare function setCookie(headers: Headers | undefined, name: string, value: string, options?: SetCookieOptions): void;
54
+ interface GetCookieOptions extends ParseOptions {
55
+ }
56
+ /**
57
+ * Gets a cookie value from request headers
58
+ *
59
+ * Returns `undefined` if the cookie is not found or headers are `undefined`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const headers = new Headers({ 'Cookie': 'sessionId=abc123; theme=dark' })
64
+ *
65
+ * const sessionId = getCookie(headers, 'sessionId')
66
+ *
67
+ * expect(sessionId).toEqual('abc123')
68
+ * ```
69
+ */
70
+ declare function getCookie(headers: Headers | undefined, name: string, options?: GetCookieOptions): string | undefined;
71
+ /**
72
+ * Deletes a cookie by marking it expired.
73
+ */
74
+ declare function deleteCookie(headers: Headers | undefined, name: string, options?: Omit<SetCookieOptions, 'maxAge'>): void;
75
+
76
+ /**
77
+ * Encrypts a string using AES-GCM with a secret key.
78
+ * The output is base64url encoded to be URL-safe.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const encrypted = await encrypt("Hello, World!", "test-secret-key")
83
+ * const decrypted = await decrypt(encrypted, "test-secret-key")
84
+ * expect(decrypted).toBe("Hello, World!")
85
+ * ```
86
+ */
87
+ declare function encrypt(value: string, secret: string): Promise<string>;
88
+ /**
89
+ * Decrypts a base64url encoded string using AES-GCM with a secret key.
90
+ * Returns the original string if decryption is successful, or undefined if it fails.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const encrypted = await encrypt("Hello, World!", "test-secret-key")
95
+ * const decrypted = await decrypt(encrypted, "test-secret-key")
96
+ * expect(decrypted).toBe("Hello, World!")
97
+ * ```
98
+ */
99
+ declare function decrypt(encrypted: string | undefined | null, secret: string): Promise<string | undefined>;
100
+
101
+ /**
102
+ * Signs a string value using HMAC-SHA256 with a secret key.
103
+ *
104
+ * This function creates a cryptographic signature that can be used to verify
105
+ * the integrity and authenticity of the data. The signature is appended to
106
+ * the original value, separated by a dot, using base64url encoding (no padding).
107
+ *
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const signedValue = await sign("user123", "my-secret-key")
112
+ * expect(signedValue).toEqual("user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA")
113
+ * ```
114
+ */
115
+ declare function sign(value: string, secret: string): Promise<string>;
116
+ /**
117
+ * Verifies and extracts the original value from a signed string.
118
+ *
119
+ * This function validates the signature of a previously signed value using the same
120
+ * secret key. If the signature is valid, it returns the original value. If the
121
+ * signature is invalid or the format is incorrect, it returns undefined.
122
+ *
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
127
+ * const originalValue = await unsign(signedValue, "my-secret-key")
128
+ * expect(originalValue).toEqual("user123")
129
+ * ```
130
+ */
131
+ declare function unsign(signedValue: string | undefined | null, secret: string): Promise<string | undefined>;
132
+ /**
133
+ * Extracts the value part from a signed string without verification.
134
+ *
135
+ * This function simply extracts the original value from a signed string
136
+ * without performing any signature verification. It's useful when you need
137
+ * to access the value quickly without the overhead of cryptographic verification.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
142
+ * const value = getSignedValue(signedValue)
143
+ * expect(value).toEqual("user123")
144
+ * ```
145
+ */
146
+ declare function getSignedValue(signedValue: string | undefined | null): string | undefined;
147
+
148
+ export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, getSignedValue, setCookie, sign, unsign };
149
+ export type { GetCookieOptions, SetCookieOptions };