@opentunnel/protocol 0.1.0 → 0.2.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/package.json +2 -2
- package/src/api/auth.ts +2 -2
- package/src/api/errors.ts +8 -8
- package/src/newtype.ts +1 -1
- package/src/tunnel.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentunnel/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test": "bun test"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"effect": "4.0.0-
|
|
27
|
+
"effect": "4.0.0-rc.112"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "25.5.0",
|
package/src/api/auth.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "effect";
|
|
2
2
|
import { HttpApiMiddleware, HttpApiSecurity } from "effect/unstable/httpapi";
|
|
3
3
|
import { Tunnel } from "../tunnel.js";
|
|
4
4
|
import { UnauthorizedError } from "./errors.js";
|
|
5
5
|
|
|
6
|
-
export class OpenTunnelAuthorizationToken extends
|
|
6
|
+
export class OpenTunnelAuthorizationToken extends Context.Service<
|
|
7
7
|
OpenTunnelAuthorizationToken,
|
|
8
8
|
Tunnel.Token
|
|
9
9
|
>()("@opentunnel/protocol/OpenTunnelAuthorizationToken") {}
|
package/src/api/errors.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
|
|
3
|
-
export class InvalidRequestError extends Schema.
|
|
3
|
+
export class InvalidRequestError extends Schema.TaggedError<InvalidRequestError>()(
|
|
4
4
|
"InvalidRequestError",
|
|
5
5
|
{ message: Schema.String },
|
|
6
6
|
{ httpApiStatus: 400 },
|
|
7
7
|
) {}
|
|
8
8
|
|
|
9
|
-
export class UnauthorizedError extends Schema.
|
|
9
|
+
export class UnauthorizedError extends Schema.TaggedError<UnauthorizedError>()(
|
|
10
10
|
"UnauthorizedError",
|
|
11
11
|
{ message: Schema.String },
|
|
12
12
|
{ httpApiStatus: 401 },
|
|
13
13
|
) {}
|
|
14
14
|
|
|
15
|
-
export class TunnelNotFoundError extends Schema.
|
|
15
|
+
export class TunnelNotFoundError extends Schema.TaggedError<TunnelNotFoundError>()(
|
|
16
16
|
"TunnelNotFoundError",
|
|
17
17
|
{ tunnelID: Schema.String, message: Schema.String },
|
|
18
18
|
{ httpApiStatus: 404 },
|
|
19
19
|
) {}
|
|
20
20
|
|
|
21
|
-
export class CertificateNotFoundError extends Schema.
|
|
21
|
+
export class CertificateNotFoundError extends Schema.TaggedError<CertificateNotFoundError>()(
|
|
22
22
|
"CertificateNotFoundError",
|
|
23
23
|
{ tunnelID: Schema.String, message: Schema.String },
|
|
24
24
|
{ httpApiStatus: 404 },
|
|
25
25
|
) {}
|
|
26
26
|
|
|
27
|
-
export class InvalidHostnameError extends Schema.
|
|
27
|
+
export class InvalidHostnameError extends Schema.TaggedError<InvalidHostnameError>()(
|
|
28
28
|
"InvalidHostnameError",
|
|
29
29
|
{ provided: Schema.String, expected: Schema.String, message: Schema.String },
|
|
30
30
|
{ httpApiStatus: 400 },
|
|
31
31
|
) {}
|
|
32
32
|
|
|
33
|
-
export class HostnameUnavailableError extends Schema.
|
|
33
|
+
export class HostnameUnavailableError extends Schema.TaggedError<HostnameUnavailableError>()(
|
|
34
34
|
"HostnameUnavailableError",
|
|
35
35
|
{ name: Schema.String, message: Schema.String },
|
|
36
36
|
{ httpApiStatus: 409 },
|
|
37
37
|
) {}
|
|
38
38
|
|
|
39
|
-
export class CertificateInProgressError extends Schema.
|
|
39
|
+
export class CertificateInProgressError extends Schema.TaggedError<CertificateInProgressError>()(
|
|
40
40
|
"CertificateInProgressError",
|
|
41
41
|
{ tunnelID: Schema.String, message: Schema.String },
|
|
42
42
|
{ httpApiStatus: 409 },
|
|
43
43
|
) {}
|
|
44
44
|
|
|
45
|
-
export class ServiceUnavailableError extends Schema.
|
|
45
|
+
export class ServiceUnavailableError extends Schema.TaggedError<ServiceUnavailableError>()(
|
|
46
46
|
"ServiceUnavailableError",
|
|
47
47
|
{ message: Schema.String },
|
|
48
48
|
{ httpApiStatus: 503 },
|
package/src/newtype.ts
CHANGED
package/src/tunnel.ts
CHANGED
|
@@ -10,20 +10,20 @@ export class ID extends Newtype<ID>()("TunnelID", Schema.String) {}
|
|
|
10
10
|
export const Token = Schema.String.pipe(Schema.brand("TunnelToken"));
|
|
11
11
|
export type Token = Schema.Schema.Type<typeof Token>;
|
|
12
12
|
|
|
13
|
-
export class NotFoundError extends Schema.
|
|
13
|
+
export class NotFoundError extends Schema.TaggedError<NotFoundError>()("NotFound", {
|
|
14
14
|
tunnelID: ID,
|
|
15
15
|
}) {}
|
|
16
16
|
|
|
17
|
-
export class NoCertificateError extends Schema.
|
|
17
|
+
export class NoCertificateError extends Schema.TaggedError<NoCertificateError>()("NoCertificate", {
|
|
18
18
|
tunnelID: ID,
|
|
19
19
|
}) {}
|
|
20
20
|
|
|
21
|
-
export class CertificateNotReadyError extends Schema.
|
|
21
|
+
export class CertificateNotReadyError extends Schema.TaggedError<CertificateNotReadyError>()(
|
|
22
22
|
"CertificateNotReady",
|
|
23
23
|
{ tunnelID: ID, currentState: Schema.String },
|
|
24
24
|
) {}
|
|
25
25
|
|
|
26
|
-
export class InvalidHostnameError extends Schema.
|
|
26
|
+
export class InvalidHostnameError extends Schema.TaggedError<InvalidHostnameError>()(
|
|
27
27
|
"InvalidHostname",
|
|
28
28
|
{ provided: CSR.Hostname, expected: CSR.Hostname },
|
|
29
29
|
) {}
|