@localpreview/protocol 0.1.0
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/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +21 -0
- package/dist/headers.d.ts +19 -0
- package/dist/headers.d.ts.map +1 -0
- package/dist/headers.js +37 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/messages.d.ts +159 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +73 -0
- package/dist/public-domain.d.ts +3 -0
- package/dist/public-domain.d.ts.map +1 -0
- package/dist/public-domain.js +2 -0
- package/dist/subdomain.d.ts +9 -0
- package/dist/subdomain.d.ts.map +1 -0
- package/dist/subdomain.js +22 -0
- package/dist/target.d.ts +14 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +46 -0
- package/dist/tunnel.d.ts +34 -0
- package/dist/tunnel.d.ts.map +1 -0
- package/dist/tunnel.js +7 -0
- package/dist/version.d.ts +20 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +17 -0
- package/package.json +33 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const ErrorCodeSchema: Schema.Literals<readonly ["BODY_TOO_LARGE", "INVALID_SUBDOMAIN", "REQUEST_TIMEOUT", "REQUEST_FAILED", "RELAY_REGISTRATION_FAILED", "SANDBOX_CREATE_FAILED", "SUBDOMAIN_TAKEN", "TUNNEL_NOT_CONNECTED", "TUNNEL_NOT_FOUND", "UNAUTHORIZED"]>;
|
|
3
|
+
export type ErrorCode = Schema.Schema.Type<typeof ErrorCodeSchema>;
|
|
4
|
+
export declare const LocalPreviewErrorSchema: Schema.Struct<{
|
|
5
|
+
readonly code: Schema.Literals<readonly ["BODY_TOO_LARGE", "INVALID_SUBDOMAIN", "REQUEST_TIMEOUT", "REQUEST_FAILED", "RELAY_REGISTRATION_FAILED", "SANDBOX_CREATE_FAILED", "SUBDOMAIN_TAKEN", "TUNNEL_NOT_CONNECTED", "TUNNEL_NOT_FOUND", "UNAUTHORIZED"]>;
|
|
6
|
+
readonly message: Schema.String;
|
|
7
|
+
readonly requestId: Schema.optional<Schema.String>;
|
|
8
|
+
readonly subdomain: Schema.optional<Schema.String>;
|
|
9
|
+
readonly limitBytes: Schema.optional<Schema.Number>;
|
|
10
|
+
}>;
|
|
11
|
+
export type LocalPreviewError = Schema.Schema.Type<typeof LocalPreviewErrorSchema>;
|
|
12
|
+
export declare const makeLocalPreviewError: (error: LocalPreviewError) => LocalPreviewError;
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,eAAe,6OAWjB,CAAC;AAEZ,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAC;AAEnE,eAAO,MAAM,uBAAuB;;;;;;EAMlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEnF,eAAO,MAAM,qBAAqB,GAAI,OAAO,iBAAiB,KAAG,iBAA0B,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export const ErrorCodeSchema = Schema.Literals([
|
|
3
|
+
"BODY_TOO_LARGE",
|
|
4
|
+
"INVALID_SUBDOMAIN",
|
|
5
|
+
"REQUEST_TIMEOUT",
|
|
6
|
+
"REQUEST_FAILED",
|
|
7
|
+
"RELAY_REGISTRATION_FAILED",
|
|
8
|
+
"SANDBOX_CREATE_FAILED",
|
|
9
|
+
"SUBDOMAIN_TAKEN",
|
|
10
|
+
"TUNNEL_NOT_CONNECTED",
|
|
11
|
+
"TUNNEL_NOT_FOUND",
|
|
12
|
+
"UNAUTHORIZED",
|
|
13
|
+
]);
|
|
14
|
+
export const LocalPreviewErrorSchema = Schema.Struct({
|
|
15
|
+
code: ErrorCodeSchema,
|
|
16
|
+
message: Schema.String,
|
|
17
|
+
requestId: Schema.optional(Schema.String),
|
|
18
|
+
subdomain: Schema.optional(Schema.String),
|
|
19
|
+
limitBytes: Schema.optional(Schema.Number),
|
|
20
|
+
});
|
|
21
|
+
export const makeLocalPreviewError = (error) => error;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const LOCALPREVIEW_ADMIN_TOKEN_HEADER = "x-localpreview-admin-token";
|
|
2
|
+
export declare const LOCALPREVIEW_FORWARDED_HOST_HEADER = "x-localpreview-forwarded-host";
|
|
3
|
+
export declare const LOCALPREVIEW_FORWARDED_PROTO_HEADER = "x-localpreview-forwarded-proto";
|
|
4
|
+
export declare const LOCALPREVIEW_PROXY_TOKEN_HEADER = "x-localpreview-proxy-token";
|
|
5
|
+
export type HeaderMap = Readonly<Record<string, string>>;
|
|
6
|
+
export type HeaderPair = readonly [name: string, value: string];
|
|
7
|
+
export type HeaderPairs = ReadonlyArray<HeaderPair>;
|
|
8
|
+
export declare const isHopByHopHeader: (name: string) => boolean;
|
|
9
|
+
export declare const isInternalLocalPreviewHeader: (name: string) => boolean;
|
|
10
|
+
export declare const filterEndToEndHeaders: (headers: HeaderMap) => HeaderMap;
|
|
11
|
+
export declare const filterInternalLocalPreviewHeaders: (headers: HeaderMap) => HeaderMap;
|
|
12
|
+
export declare const filterEndToEndHeaderPairs: (headers: HeaderPairs) => HeaderPairs;
|
|
13
|
+
export declare const filterInternalLocalPreviewHeaderPairs: (headers: HeaderPairs) => HeaderPairs;
|
|
14
|
+
export declare const headerPairsToMap: (headers: HeaderPairs) => HeaderMap;
|
|
15
|
+
export declare const headerMapToPairs: (headers: HeaderMap) => HeaderPairs;
|
|
16
|
+
export declare const flattenHeaderPairs: (headers: HeaderPairs) => Array<string>;
|
|
17
|
+
export declare const headersToMap: (headers: Headers) => HeaderMap;
|
|
18
|
+
export declare const recordToHeaders: (headers: HeaderMap) => Headers;
|
|
19
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../src/headers.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,+BAA+B,+BAA+B,CAAC;AAC5E,eAAO,MAAM,kCAAkC,kCAAkC,CAAC;AAClF,eAAO,MAAM,mCAAmC,mCAAmC,CAAC;AACpF,eAAO,MAAM,+BAA+B,+BAA+B,CAAC;AAS5E,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACzD,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAChE,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAEpD,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAAkD,CAAC;AAEnG,eAAO,MAAM,4BAA4B,GAAI,MAAM,MAAM,KAAG,OACP,CAAC;AAEtD,eAAO,MAAM,qBAAqB,GAAI,SAAS,SAAS,KAAG,SAC8B,CAAC;AAE1F,eAAO,MAAM,iCAAiC,GAAI,SAAS,SAAS,KAAG,SAGpE,CAAC;AAEJ,eAAO,MAAM,yBAAyB,GAAI,SAAS,WAAW,KAAG,WACZ,CAAC;AAEtD,eAAO,MAAM,qCAAqC,GAAI,SAAS,WAAW,KAAG,WACZ,CAAC;AAElE,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,KAAG,SAAwC,CAAC;AAEjG,eAAO,MAAM,gBAAgB,GAAI,SAAS,SAAS,KAAG,WAAsC,CAAC;AAE7F,eAAO,MAAM,kBAAkB,GAAI,SAAS,WAAW,KAAG,KAAK,CAAC,MAAM,CACnB,CAAC;AAEpD,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,KAAG,SAAkD,CAAC;AAEnG,eAAO,MAAM,eAAe,GAAI,SAAS,SAAS,KAAG,OAQpD,CAAC"}
|
package/dist/headers.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const hopByHopHeaders = new Set([
|
|
2
|
+
"connection",
|
|
3
|
+
"keep-alive",
|
|
4
|
+
"proxy-authenticate",
|
|
5
|
+
"proxy-authorization",
|
|
6
|
+
"te",
|
|
7
|
+
"trailer",
|
|
8
|
+
"transfer-encoding",
|
|
9
|
+
"upgrade",
|
|
10
|
+
]);
|
|
11
|
+
export const LOCALPREVIEW_ADMIN_TOKEN_HEADER = "x-localpreview-admin-token";
|
|
12
|
+
export const LOCALPREVIEW_FORWARDED_HOST_HEADER = "x-localpreview-forwarded-host";
|
|
13
|
+
export const LOCALPREVIEW_FORWARDED_PROTO_HEADER = "x-localpreview-forwarded-proto";
|
|
14
|
+
export const LOCALPREVIEW_PROXY_TOKEN_HEADER = "x-localpreview-proxy-token";
|
|
15
|
+
const internalLocalPreviewHeaders = new Set([
|
|
16
|
+
LOCALPREVIEW_ADMIN_TOKEN_HEADER,
|
|
17
|
+
LOCALPREVIEW_FORWARDED_HOST_HEADER,
|
|
18
|
+
LOCALPREVIEW_FORWARDED_PROTO_HEADER,
|
|
19
|
+
LOCALPREVIEW_PROXY_TOKEN_HEADER,
|
|
20
|
+
]);
|
|
21
|
+
export const isHopByHopHeader = (name) => hopByHopHeaders.has(name.toLowerCase());
|
|
22
|
+
export const isInternalLocalPreviewHeader = (name) => internalLocalPreviewHeaders.has(name.toLowerCase());
|
|
23
|
+
export const filterEndToEndHeaders = (headers) => Object.fromEntries(Object.entries(headers).filter(([name]) => !isHopByHopHeader(name)));
|
|
24
|
+
export const filterInternalLocalPreviewHeaders = (headers) => Object.fromEntries(Object.entries(headers).filter(([name]) => !isInternalLocalPreviewHeader(name)));
|
|
25
|
+
export const filterEndToEndHeaderPairs = (headers) => headers.filter(([name]) => !isHopByHopHeader(name));
|
|
26
|
+
export const filterInternalLocalPreviewHeaderPairs = (headers) => headers.filter(([name]) => !isInternalLocalPreviewHeader(name));
|
|
27
|
+
export const headerPairsToMap = (headers) => Object.fromEntries(headers);
|
|
28
|
+
export const headerMapToPairs = (headers) => Object.entries(headers);
|
|
29
|
+
export const flattenHeaderPairs = (headers) => headers.flatMap(([name, value]) => [name, value]);
|
|
30
|
+
export const headersToMap = (headers) => Object.fromEntries(headers.entries());
|
|
31
|
+
export const recordToHeaders = (headers) => {
|
|
32
|
+
const result = new Headers();
|
|
33
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
34
|
+
result.set(name, value);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./errors.js";
|
|
2
|
+
export * from "./headers.js";
|
|
3
|
+
export * from "./messages.js";
|
|
4
|
+
export * from "./public-domain.js";
|
|
5
|
+
export * from "./subdomain.js";
|
|
6
|
+
export * from "./target.js";
|
|
7
|
+
export * from "./tunnel.js";
|
|
8
|
+
export * from "./version.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import type { HeaderPairs } from "./headers.js";
|
|
3
|
+
export declare const RequestIdSchema: Schema.String;
|
|
4
|
+
export type RequestId = Schema.Schema.Type<typeof RequestIdSchema>;
|
|
5
|
+
export declare const RequestStartMessageSchema: Schema.Struct<{
|
|
6
|
+
readonly headers: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
7
|
+
readonly method: Schema.String;
|
|
8
|
+
readonly path: Schema.String;
|
|
9
|
+
readonly requestId: Schema.String;
|
|
10
|
+
readonly type: Schema.Literal<"request-start">;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const RequestChunkMessageSchema: Schema.Struct<{
|
|
13
|
+
readonly chunkBase64: Schema.String;
|
|
14
|
+
readonly requestId: Schema.String;
|
|
15
|
+
readonly type: Schema.Literal<"request-chunk">;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const RequestEndMessageSchema: Schema.Struct<{
|
|
18
|
+
readonly requestId: Schema.String;
|
|
19
|
+
readonly type: Schema.Literal<"request-end">;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const CancelMessageSchema: Schema.Struct<{
|
|
22
|
+
readonly requestId: Schema.String;
|
|
23
|
+
readonly type: Schema.Literal<"cancel">;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const ResponseStartMessageSchema: Schema.Struct<{
|
|
26
|
+
readonly headers: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
27
|
+
readonly requestId: Schema.String;
|
|
28
|
+
readonly status: Schema.Number;
|
|
29
|
+
readonly type: Schema.Literal<"response-start">;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const ResponseChunkMessageSchema: Schema.Struct<{
|
|
32
|
+
readonly chunkBase64: Schema.String;
|
|
33
|
+
readonly requestId: Schema.String;
|
|
34
|
+
readonly type: Schema.Literal<"response-chunk">;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const ResponseEndMessageSchema: Schema.Struct<{
|
|
37
|
+
readonly requestId: Schema.String;
|
|
38
|
+
readonly type: Schema.Literal<"response-end">;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const ResponseErrorMessageSchema: Schema.Struct<{
|
|
41
|
+
readonly message: Schema.String;
|
|
42
|
+
readonly requestId: Schema.String;
|
|
43
|
+
readonly type: Schema.Literal<"response-error">;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const ServerMessageSchema: Schema.Union<readonly [Schema.Struct<{
|
|
46
|
+
readonly headers: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
47
|
+
readonly method: Schema.String;
|
|
48
|
+
readonly path: Schema.String;
|
|
49
|
+
readonly requestId: Schema.String;
|
|
50
|
+
readonly type: Schema.Literal<"request-start">;
|
|
51
|
+
}>, Schema.Struct<{
|
|
52
|
+
readonly chunkBase64: Schema.String;
|
|
53
|
+
readonly requestId: Schema.String;
|
|
54
|
+
readonly type: Schema.Literal<"request-chunk">;
|
|
55
|
+
}>, Schema.Struct<{
|
|
56
|
+
readonly requestId: Schema.String;
|
|
57
|
+
readonly type: Schema.Literal<"request-end">;
|
|
58
|
+
}>, Schema.Struct<{
|
|
59
|
+
readonly requestId: Schema.String;
|
|
60
|
+
readonly type: Schema.Literal<"cancel">;
|
|
61
|
+
}>]>;
|
|
62
|
+
export declare const ClientMessageSchema: Schema.Union<readonly [Schema.Struct<{
|
|
63
|
+
readonly headers: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
64
|
+
readonly requestId: Schema.String;
|
|
65
|
+
readonly status: Schema.Number;
|
|
66
|
+
readonly type: Schema.Literal<"response-start">;
|
|
67
|
+
}>, Schema.Struct<{
|
|
68
|
+
readonly chunkBase64: Schema.String;
|
|
69
|
+
readonly requestId: Schema.String;
|
|
70
|
+
readonly type: Schema.Literal<"response-chunk">;
|
|
71
|
+
}>, Schema.Struct<{
|
|
72
|
+
readonly requestId: Schema.String;
|
|
73
|
+
readonly type: Schema.Literal<"response-end">;
|
|
74
|
+
}>, Schema.Struct<{
|
|
75
|
+
readonly message: Schema.String;
|
|
76
|
+
readonly requestId: Schema.String;
|
|
77
|
+
readonly type: Schema.Literal<"response-error">;
|
|
78
|
+
}>]>;
|
|
79
|
+
export declare const RelayMessageSchema: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
80
|
+
readonly headers: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
81
|
+
readonly method: Schema.String;
|
|
82
|
+
readonly path: Schema.String;
|
|
83
|
+
readonly requestId: Schema.String;
|
|
84
|
+
readonly type: Schema.Literal<"request-start">;
|
|
85
|
+
}>, Schema.Struct<{
|
|
86
|
+
readonly chunkBase64: Schema.String;
|
|
87
|
+
readonly requestId: Schema.String;
|
|
88
|
+
readonly type: Schema.Literal<"request-chunk">;
|
|
89
|
+
}>, Schema.Struct<{
|
|
90
|
+
readonly requestId: Schema.String;
|
|
91
|
+
readonly type: Schema.Literal<"request-end">;
|
|
92
|
+
}>, Schema.Struct<{
|
|
93
|
+
readonly requestId: Schema.String;
|
|
94
|
+
readonly type: Schema.Literal<"cancel">;
|
|
95
|
+
}>]>, Schema.Union<readonly [Schema.Struct<{
|
|
96
|
+
readonly headers: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
97
|
+
readonly requestId: Schema.String;
|
|
98
|
+
readonly status: Schema.Number;
|
|
99
|
+
readonly type: Schema.Literal<"response-start">;
|
|
100
|
+
}>, Schema.Struct<{
|
|
101
|
+
readonly chunkBase64: Schema.String;
|
|
102
|
+
readonly requestId: Schema.String;
|
|
103
|
+
readonly type: Schema.Literal<"response-chunk">;
|
|
104
|
+
}>, Schema.Struct<{
|
|
105
|
+
readonly requestId: Schema.String;
|
|
106
|
+
readonly type: Schema.Literal<"response-end">;
|
|
107
|
+
}>, Schema.Struct<{
|
|
108
|
+
readonly message: Schema.String;
|
|
109
|
+
readonly requestId: Schema.String;
|
|
110
|
+
readonly type: Schema.Literal<"response-error">;
|
|
111
|
+
}>]>]>;
|
|
112
|
+
export type ServerMessage = {
|
|
113
|
+
readonly type: "request-start";
|
|
114
|
+
readonly requestId: RequestId;
|
|
115
|
+
readonly method: string;
|
|
116
|
+
readonly path: string;
|
|
117
|
+
readonly headers: HeaderPairs;
|
|
118
|
+
} | {
|
|
119
|
+
readonly type: "request-chunk";
|
|
120
|
+
readonly requestId: RequestId;
|
|
121
|
+
readonly chunkBase64: string;
|
|
122
|
+
} | {
|
|
123
|
+
readonly type: "request-end";
|
|
124
|
+
readonly requestId: RequestId;
|
|
125
|
+
} | {
|
|
126
|
+
readonly type: "cancel";
|
|
127
|
+
readonly requestId: RequestId;
|
|
128
|
+
};
|
|
129
|
+
export type ClientMessage = {
|
|
130
|
+
readonly type: "response-start";
|
|
131
|
+
readonly requestId: RequestId;
|
|
132
|
+
readonly status: number;
|
|
133
|
+
readonly headers: HeaderPairs;
|
|
134
|
+
} | {
|
|
135
|
+
readonly type: "response-chunk";
|
|
136
|
+
readonly requestId: RequestId;
|
|
137
|
+
readonly chunkBase64: string;
|
|
138
|
+
} | {
|
|
139
|
+
readonly type: "response-end";
|
|
140
|
+
readonly requestId: RequestId;
|
|
141
|
+
} | {
|
|
142
|
+
readonly type: "response-error";
|
|
143
|
+
readonly requestId: RequestId;
|
|
144
|
+
readonly message: string;
|
|
145
|
+
};
|
|
146
|
+
export type RelayMessage = ServerMessage | ClientMessage;
|
|
147
|
+
export declare const encodeRelayMessage: (message: RelayMessage) => string;
|
|
148
|
+
export declare const decodeRelayMessage: (input: string) => RelayMessage;
|
|
149
|
+
export type RelayMessageDecodeResult<A> = {
|
|
150
|
+
readonly ok: true;
|
|
151
|
+
readonly message: A;
|
|
152
|
+
} | {
|
|
153
|
+
readonly error: unknown;
|
|
154
|
+
readonly ok: false;
|
|
155
|
+
};
|
|
156
|
+
export declare const decodeServerRelayMessage: (input: string) => RelayMessageDecodeResult<ServerMessage>;
|
|
157
|
+
export declare const decodeClientRelayMessage: (input: string) => RelayMessageDecodeResult<ClientMessage>;
|
|
158
|
+
export declare const decodeTypedRelayMessage: (input: string) => RelayMessageDecodeResult<RelayMessage>;
|
|
159
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,eAAO,MAAM,eAAe,eAAgB,CAAC;AAC7C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAC;AAInE,eAAO,MAAM,yBAAyB;;;;;;EAMpC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;EAIpC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;EAGlC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;EAG9B,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;EAKrC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;EAIrC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;EAGnC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;EAIrC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;IAKrB,CAAC;AAEZ,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;IAKrB,CAAC;AAEZ,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAoE,CAAC;AAEpG,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,CAAC;AAEN,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,aAAa,CAAC;AAEzD,eAAO,MAAM,kBAAkB,GAAI,SAAS,YAAY,KAAG,MAAiC,CAAC;AAE7F,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,YAChB,CAAC;AAEpC,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAClC;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CACrB,GACD;IACE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;CACpB,CAAC;AAEN,eAAO,MAAM,wBAAwB,GAAI,OAAO,MAAM,KAAG,wBAAwB,CAAC,aAAa,CACjD,CAAC;AAE/C,eAAO,MAAM,wBAAwB,GAAI,OAAO,MAAM,KAAG,wBAAwB,CAAC,aAAa,CACjD,CAAC;AAE/C,eAAO,MAAM,uBAAuB,GAAI,OAAO,MAAM,KAAG,wBAAwB,CAAC,YAAY,CAChD,CAAC"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Result, Schema } from "effect";
|
|
2
|
+
export const RequestIdSchema = Schema.String;
|
|
3
|
+
const HeaderPairsSchema = Schema.Array(Schema.Tuple([Schema.String, Schema.String]));
|
|
4
|
+
export const RequestStartMessageSchema = Schema.Struct({
|
|
5
|
+
headers: HeaderPairsSchema,
|
|
6
|
+
method: Schema.String,
|
|
7
|
+
path: Schema.String,
|
|
8
|
+
requestId: RequestIdSchema,
|
|
9
|
+
type: Schema.Literal("request-start"),
|
|
10
|
+
});
|
|
11
|
+
export const RequestChunkMessageSchema = Schema.Struct({
|
|
12
|
+
chunkBase64: Schema.String,
|
|
13
|
+
requestId: RequestIdSchema,
|
|
14
|
+
type: Schema.Literal("request-chunk"),
|
|
15
|
+
});
|
|
16
|
+
export const RequestEndMessageSchema = Schema.Struct({
|
|
17
|
+
requestId: RequestIdSchema,
|
|
18
|
+
type: Schema.Literal("request-end"),
|
|
19
|
+
});
|
|
20
|
+
export const CancelMessageSchema = Schema.Struct({
|
|
21
|
+
requestId: RequestIdSchema,
|
|
22
|
+
type: Schema.Literal("cancel"),
|
|
23
|
+
});
|
|
24
|
+
export const ResponseStartMessageSchema = Schema.Struct({
|
|
25
|
+
headers: HeaderPairsSchema,
|
|
26
|
+
requestId: RequestIdSchema,
|
|
27
|
+
status: Schema.Number,
|
|
28
|
+
type: Schema.Literal("response-start"),
|
|
29
|
+
});
|
|
30
|
+
export const ResponseChunkMessageSchema = Schema.Struct({
|
|
31
|
+
chunkBase64: Schema.String,
|
|
32
|
+
requestId: RequestIdSchema,
|
|
33
|
+
type: Schema.Literal("response-chunk"),
|
|
34
|
+
});
|
|
35
|
+
export const ResponseEndMessageSchema = Schema.Struct({
|
|
36
|
+
requestId: RequestIdSchema,
|
|
37
|
+
type: Schema.Literal("response-end"),
|
|
38
|
+
});
|
|
39
|
+
export const ResponseErrorMessageSchema = Schema.Struct({
|
|
40
|
+
message: Schema.String,
|
|
41
|
+
requestId: RequestIdSchema,
|
|
42
|
+
type: Schema.Literal("response-error"),
|
|
43
|
+
});
|
|
44
|
+
export const ServerMessageSchema = Schema.Union([
|
|
45
|
+
RequestStartMessageSchema,
|
|
46
|
+
RequestChunkMessageSchema,
|
|
47
|
+
RequestEndMessageSchema,
|
|
48
|
+
CancelMessageSchema,
|
|
49
|
+
]);
|
|
50
|
+
export const ClientMessageSchema = Schema.Union([
|
|
51
|
+
ResponseStartMessageSchema,
|
|
52
|
+
ResponseChunkMessageSchema,
|
|
53
|
+
ResponseEndMessageSchema,
|
|
54
|
+
ResponseErrorMessageSchema,
|
|
55
|
+
]);
|
|
56
|
+
export const RelayMessageSchema = Schema.Union([ServerMessageSchema, ClientMessageSchema]);
|
|
57
|
+
export const encodeRelayMessage = (message) => JSON.stringify(message);
|
|
58
|
+
export const decodeRelayMessage = (input) => JSON.parse(input);
|
|
59
|
+
export const decodeServerRelayMessage = (input) => decodeWithSchema(input, ServerMessageSchema);
|
|
60
|
+
export const decodeClientRelayMessage = (input) => decodeWithSchema(input, ClientMessageSchema);
|
|
61
|
+
export const decodeTypedRelayMessage = (input) => decodeWithSchema(input, RelayMessageSchema);
|
|
62
|
+
const decodeWithSchema = (input, schema) => {
|
|
63
|
+
try {
|
|
64
|
+
const result = Schema.decodeUnknownResult(schema)(JSON.parse(input));
|
|
65
|
+
if (Result.isSuccess(result)) {
|
|
66
|
+
return { message: result.success, ok: true };
|
|
67
|
+
}
|
|
68
|
+
return { error: result.failure, ok: false };
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return { error, ok: false };
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-domain.d.ts","sourceRoot":"","sources":["../src/public-domain.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAC7D,eAAO,MAAM,0BAA0B,6BAA0C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type SubdomainValidationResult = {
|
|
2
|
+
readonly valid: true;
|
|
3
|
+
readonly subdomain: string;
|
|
4
|
+
} | {
|
|
5
|
+
readonly valid: false;
|
|
6
|
+
readonly reason: "invalid-format" | "reserved";
|
|
7
|
+
};
|
|
8
|
+
export declare const validateRequestedSubdomain: (input: string) => SubdomainValidationResult;
|
|
9
|
+
//# sourceMappingURL=subdomain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subdomain.d.ts","sourceRoot":"","sources":["../src/subdomain.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,yBAAyB,GACjC;IACE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GACD;IACE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAAC;CAChD,CAAC;AAEN,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,KAAG,yBAY1D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const reservedSubdomains = new Set([
|
|
2
|
+
"admin",
|
|
3
|
+
"api",
|
|
4
|
+
"app",
|
|
5
|
+
"assets",
|
|
6
|
+
"auth",
|
|
7
|
+
"dashboard",
|
|
8
|
+
"login",
|
|
9
|
+
"static",
|
|
10
|
+
"status",
|
|
11
|
+
"www",
|
|
12
|
+
]);
|
|
13
|
+
export const validateRequestedSubdomain = (input) => {
|
|
14
|
+
const subdomain = input.trim().toLowerCase();
|
|
15
|
+
if (reservedSubdomains.has(subdomain)) {
|
|
16
|
+
return { valid: false, reason: "reserved" };
|
|
17
|
+
}
|
|
18
|
+
if (!/^[a-z0-9](?:[a-z0-9-]{1,30}[a-z0-9])$/.test(subdomain)) {
|
|
19
|
+
return { valid: false, reason: "invalid-format" };
|
|
20
|
+
}
|
|
21
|
+
return { valid: true, subdomain };
|
|
22
|
+
};
|
package/dist/target.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type TunnelTarget = {
|
|
2
|
+
readonly protocol: "http" | "https";
|
|
3
|
+
readonly hostname: string;
|
|
4
|
+
readonly port: number;
|
|
5
|
+
};
|
|
6
|
+
export type ParseTargetResult = {
|
|
7
|
+
readonly ok: true;
|
|
8
|
+
readonly target: TunnelTarget;
|
|
9
|
+
} | {
|
|
10
|
+
readonly ok: false;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const parseTarget: (input: string) => ParseTargetResult;
|
|
14
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../src/target.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,iBA4B3C,CAAC"}
|
package/dist/target.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const parseTarget = (input) => {
|
|
2
|
+
const trimmed = input.trim();
|
|
3
|
+
if (/^\d+$/.test(trimmed)) {
|
|
4
|
+
return makeTarget("http", "127.0.0.1", Number(trimmed));
|
|
5
|
+
}
|
|
6
|
+
const withProtocol = trimmed.includes("://") ? trimmed : `http://${trimmed}`;
|
|
7
|
+
try {
|
|
8
|
+
const url = new URL(withProtocol);
|
|
9
|
+
const protocol = parseProtocol(url.protocol);
|
|
10
|
+
if (protocol === undefined) {
|
|
11
|
+
return { ok: false, message: "Target protocol must be http or https." };
|
|
12
|
+
}
|
|
13
|
+
if (url.port === "") {
|
|
14
|
+
return { ok: false, message: "Target must include a port." };
|
|
15
|
+
}
|
|
16
|
+
return makeTarget(protocol, url.hostname, Number(url.port));
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return {
|
|
20
|
+
ok: false,
|
|
21
|
+
message: "Target must be a port or URL, like 4000 or https://localhost:4000.",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const parseProtocol = (protocol) => {
|
|
26
|
+
if (protocol === "http:") {
|
|
27
|
+
return "http";
|
|
28
|
+
}
|
|
29
|
+
if (protocol === "https:") {
|
|
30
|
+
return "https";
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
};
|
|
34
|
+
const makeTarget = (protocol, hostname, port) => {
|
|
35
|
+
if (!Number.isInteger(port) || port < 1 || port > 65_535) {
|
|
36
|
+
return { ok: false, message: "Target port must be between 1 and 65535." };
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
ok: true,
|
|
40
|
+
target: {
|
|
41
|
+
hostname,
|
|
42
|
+
port,
|
|
43
|
+
protocol,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
};
|
package/dist/tunnel.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const TunnelStatusSchema: Schema.Literals<readonly ["starting", "connected", "disconnected", "expired"]>;
|
|
3
|
+
export type TunnelStatus = Schema.Schema.Type<typeof TunnelStatusSchema>;
|
|
4
|
+
export type TunnelRecord = {
|
|
5
|
+
readonly tunnelId: string;
|
|
6
|
+
readonly subdomain: string;
|
|
7
|
+
readonly relayHttpUrl: string;
|
|
8
|
+
readonly relayWsUrl: string;
|
|
9
|
+
readonly proxyToken: string;
|
|
10
|
+
readonly relayProvider?: "local" | "vercel";
|
|
11
|
+
readonly status: TunnelStatus;
|
|
12
|
+
readonly sandboxId?: string;
|
|
13
|
+
readonly createdAt: string;
|
|
14
|
+
readonly expiresAt: string;
|
|
15
|
+
};
|
|
16
|
+
export type CreateTunnelRequest = {
|
|
17
|
+
readonly requestedSubdomain?: string;
|
|
18
|
+
};
|
|
19
|
+
export type CreateTunnelResponse = {
|
|
20
|
+
readonly tunnelId: string;
|
|
21
|
+
readonly subdomain: string;
|
|
22
|
+
readonly publicUrl: string;
|
|
23
|
+
readonly relayWsUrl: string;
|
|
24
|
+
readonly clientToken: string;
|
|
25
|
+
readonly expiresAt: string;
|
|
26
|
+
readonly protocolVersion: string;
|
|
27
|
+
readonly relaySnapshotVersion: string;
|
|
28
|
+
};
|
|
29
|
+
export type RegisterRelayTunnelRequest = {
|
|
30
|
+
readonly tunnelId: string;
|
|
31
|
+
readonly clientToken: string;
|
|
32
|
+
readonly proxyToken: string;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=tunnel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnel.d.ts","sourceRoot":"","sources":["../src/tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,kBAAkB,gFAKpB,CAAC;AAEZ,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEzE,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC"}
|
package/dist/tunnel.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const LOCALPREVIEW_PROTOCOL_VERSION = "1";
|
|
3
|
+
export declare const LOCALPREVIEW_RELAY_SNAPSHOT_VERSION = "2026-05-25.1";
|
|
4
|
+
export declare const RelayHealthResponseSchema: Schema.Struct<{
|
|
5
|
+
readonly ok: Schema.Literal<true>;
|
|
6
|
+
readonly protocolVersion: Schema.String;
|
|
7
|
+
readonly relaySnapshotVersion: Schema.String;
|
|
8
|
+
readonly service: Schema.String;
|
|
9
|
+
readonly tunnels: Schema.Number;
|
|
10
|
+
}>;
|
|
11
|
+
export type RelayHealthResponse = Schema.Schema.Type<typeof RelayHealthResponseSchema>;
|
|
12
|
+
export type RelayHealthDecodeResult = {
|
|
13
|
+
readonly health: RelayHealthResponse;
|
|
14
|
+
readonly ok: true;
|
|
15
|
+
} | {
|
|
16
|
+
readonly error: unknown;
|
|
17
|
+
readonly ok: false;
|
|
18
|
+
};
|
|
19
|
+
export declare const decodeRelayHealthResponse: (input: unknown) => RelayHealthDecodeResult;
|
|
20
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,mCAAmC,iBAAiB,CAAC;AAElE,eAAO,MAAM,yBAAyB;;;;;;EAMpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEvF,MAAM,MAAM,uBAAuB,GAC/B;IACE,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;CACnB,GACD;IACE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;CACpB,CAAC;AAEN,eAAO,MAAM,yBAAyB,GAAI,OAAO,OAAO,KAAG,uBAQ1D,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Result, Schema } from "effect";
|
|
2
|
+
export const LOCALPREVIEW_PROTOCOL_VERSION = "1";
|
|
3
|
+
export const LOCALPREVIEW_RELAY_SNAPSHOT_VERSION = "2026-05-25.1";
|
|
4
|
+
export const RelayHealthResponseSchema = Schema.Struct({
|
|
5
|
+
ok: Schema.Literal(true),
|
|
6
|
+
protocolVersion: Schema.String,
|
|
7
|
+
relaySnapshotVersion: Schema.String,
|
|
8
|
+
service: Schema.String,
|
|
9
|
+
tunnels: Schema.Number,
|
|
10
|
+
});
|
|
11
|
+
export const decodeRelayHealthResponse = (input) => {
|
|
12
|
+
const result = Schema.decodeUnknownResult(RelayHealthResponseSchema)(input);
|
|
13
|
+
if (Result.isSuccess(result)) {
|
|
14
|
+
return { health: result.success, ok: true };
|
|
15
|
+
}
|
|
16
|
+
return { error: result.failure, ok: false };
|
|
17
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@localpreview/protocol",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"README.md"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"effect": "beta"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "latest",
|
|
24
|
+
"vitest": "latest"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.build.json",
|
|
28
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
29
|
+
"lint": "oxlint .",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
32
|
+
}
|
|
33
|
+
}
|