t3code-cli 0.13.0 → 0.14.1
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/README.md +87 -1
- package/dist/application.d.ts +2 -0
- package/dist/application.js +1 -1
- package/dist/auth.d.ts +50 -0
- package/dist/auth.js +1 -1
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +355 -606
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +1 -1
- package/dist/client-runtime/authorization.d.ts +2 -0
- package/dist/client-runtime/authorization.js +2 -0
- package/dist/client-runtime/connection.d.ts +2 -0
- package/dist/client-runtime/connection.js +2 -0
- package/dist/client-runtime/environment.d.ts +57 -0
- package/dist/client-runtime/environment.js +2 -0
- package/dist/client-runtime/errors.d.ts +28 -0
- package/dist/client-runtime/errors.js +35 -0
- package/dist/client-runtime/operations/projects.d.ts +2 -0
- package/dist/client-runtime/operations/projects.js +2 -0
- package/dist/client-runtime/operations.d.ts +2 -0
- package/dist/client-runtime/operations.js +2 -0
- package/dist/client-runtime/platform.d.ts +26 -0
- package/dist/client-runtime/platform.js +74 -0
- package/dist/client-runtime/relay.d.ts +121 -0
- package/dist/client-runtime/relay.js +245 -0
- package/dist/client-runtime/rpc.d.ts +2 -0
- package/dist/client-runtime/rpc.js +2 -0
- package/dist/client-runtime/state/assets.d.ts +40 -0
- package/dist/client-runtime/state/assets.js +53 -0
- package/dist/client-runtime/state/auth.d.ts +98 -0
- package/dist/client-runtime/state/auth.js +48 -0
- package/dist/client-runtime/state/connections.d.ts +2 -0
- package/dist/client-runtime/state/connections.js +52 -0
- package/dist/client-runtime/state/entities.d.ts +33 -0
- package/dist/client-runtime/state/entities.js +2 -0
- package/dist/client-runtime/state/filesystem.d.ts +42 -0
- package/dist/client-runtime/state/filesystem.js +48 -0
- package/dist/client-runtime/state/git.d.ts +43 -0
- package/dist/client-runtime/state/git.js +18 -0
- package/dist/client-runtime/state/models.d.ts +2 -0
- package/dist/client-runtime/state/models.js +2 -0
- package/dist/client-runtime/state/orchestration.d.ts +128 -0
- package/dist/client-runtime/state/orchestration.js +20 -0
- package/dist/client-runtime/state/presentation.d.ts +277 -0
- package/dist/client-runtime/state/presentation.js +34 -0
- package/dist/client-runtime/state/preview.d.ts +447 -0
- package/dist/client-runtime/state/preview.js +103 -0
- package/dist/client-runtime/state/project-grouping.d.ts +26 -0
- package/dist/client-runtime/state/project-grouping.js +73 -0
- package/dist/client-runtime/state/projects.d.ts +192 -0
- package/dist/client-runtime/state/projects.js +2 -0
- package/dist/client-runtime/state/relay.d.ts +10 -0
- package/dist/client-runtime/state/relay.js +19 -0
- package/dist/client-runtime/state/review.d.ts +28 -0
- package/dist/client-runtime/state/review.js +11 -0
- package/dist/client-runtime/state/runtime.d.ts +2 -0
- package/dist/client-runtime/state/runtime.js +2 -0
- package/dist/client-runtime/state/server.d.ts +1495 -0
- package/dist/client-runtime/state/server.js +207 -0
- package/dist/client-runtime/state/session.d.ts +532 -0
- package/dist/client-runtime/state/session.js +21 -0
- package/dist/client-runtime/state/shell.d.ts +529 -0
- package/dist/client-runtime/state/shell.js +2 -0
- package/dist/client-runtime/state/source-control.d.ts +92 -0
- package/dist/client-runtime/state/source-control.js +36 -0
- package/dist/client-runtime/state/terminal.d.ts +237 -0
- package/dist/client-runtime/state/terminal.js +173 -0
- package/dist/client-runtime/state/thread-settled.d.ts +104 -0
- package/dist/client-runtime/state/thread-settled.js +157 -0
- package/dist/client-runtime/state/thread-sort.d.ts +23 -0
- package/dist/client-runtime/state/thread-sort.js +47 -0
- package/dist/client-runtime/state/threads.d.ts +538 -0
- package/dist/client-runtime/state/threads.js +934 -0
- package/dist/client-runtime/state/vcs.d.ts +442 -0
- package/dist/client-runtime/state/vcs.js +756 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +1 -1
- package/dist/connection.d.ts +7 -0
- package/dist/connection.js +1 -1
- package/dist/contracts.d.ts +2 -0
- package/dist/contracts.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/node.d.ts +6 -0
- package/dist/node.js +1 -1
- package/dist/orchestration.d.ts +1420 -0
- package/dist/orchestration.js +1 -1
- package/dist/preview.d.ts +2 -0
- package/dist/preview.js +2 -0
- package/dist/rpc.d.ts +6043 -0
- package/dist/rpc.js +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +2 -2
- package/dist/shared/DrainableWorker.d.ts +28 -0
- package/dist/shared/DrainableWorker.js +24 -0
- package/dist/shared/KeyedCoalescingWorker.d.ts +13 -0
- package/dist/shared/KeyedCoalescingWorker.js +89 -0
- package/dist/shared/Net.d.ts +43 -0
- package/dist/shared/Net.js +126 -0
- package/dist/shared/String.d.ts +4 -0
- package/dist/shared/String.js +8 -0
- package/dist/shared/Struct.d.ts +5 -0
- package/dist/shared/Struct.js +2 -0
- package/dist/shared/advertisedEndpoint.d.ts +2 -0
- package/dist/shared/advertisedEndpoint.js +2 -0
- package/dist/shared/agentAwareness.d.ts +27 -0
- package/dist/shared/agentAwareness.js +54 -0
- package/dist/shared/backgroundActivitySettings.d.ts +23 -0
- package/dist/shared/backgroundActivitySettings.js +2 -0
- package/dist/shared/chatList.d.ts +12 -0
- package/dist/shared/chatList.js +14 -0
- package/dist/shared/cliArgs.d.ts +33 -0
- package/dist/shared/cliArgs.js +103 -0
- package/dist/shared/composerInlineTokens.d.ts +20 -0
- package/dist/shared/composerInlineTokens.js +72 -0
- package/dist/shared/composerTrigger.d.ts +26 -0
- package/dist/shared/composerTrigger.js +97 -0
- package/dist/shared/connectAuth.d.ts +58 -0
- package/dist/shared/connectAuth.js +89 -0
- package/dist/shared/devHome.d.ts +21 -0
- package/dist/shared/devHome.js +65 -0
- package/dist/shared/devProxy.d.ts +15 -0
- package/dist/shared/devProxy.js +22 -0
- package/dist/shared/dpop.d.ts +32 -0
- package/dist/shared/dpop.js +2724 -0
- package/dist/shared/dpopCommon.d.ts +2 -0
- package/dist/shared/dpopCommon.js +2 -0
- package/dist/shared/filePreview.d.ts +8 -0
- package/dist/shared/filePreview.js +31 -0
- package/dist/shared/git.d.ts +41 -0
- package/dist/shared/git.js +2 -0
- package/dist/shared/hostProcess.d.ts +13 -0
- package/dist/shared/hostProcess.js +2 -0
- package/dist/shared/httpObservability.d.ts +5 -0
- package/dist/shared/httpObservability.js +2 -0
- package/dist/shared/httpReadiness.d.ts +38 -0
- package/dist/shared/httpReadiness.js +110 -0
- package/dist/shared/keybindings.d.ts +35 -0
- package/dist/shared/keybindings.js +330 -0
- package/dist/shared/logging.d.ts +39 -0
- package/dist/shared/logging.js +2 -0
- package/dist/shared/model.d.ts +44 -0
- package/dist/shared/model.js +2 -0
- package/dist/shared/oauthScope.d.ts +23 -0
- package/dist/shared/oauthScope.js +2 -0
- package/dist/shared/observability.d.ts +105 -0
- package/dist/shared/observability.js +346 -0
- package/dist/shared/orchestrationTiming.d.ts +16 -0
- package/dist/shared/orchestrationTiming.js +32 -0
- package/dist/shared/path.d.ts +2 -0
- package/dist/shared/path.js +2 -0
- package/dist/shared/preview.d.ts +35 -0
- package/dist/shared/preview.js +103 -0
- package/dist/shared/previewViewport.d.ts +16 -0
- package/dist/shared/previewViewport.js +159 -0
- package/dist/shared/projectFavicon.d.ts +5 -0
- package/dist/shared/projectFavicon.js +13 -0
- package/dist/shared/projectScripts.d.ts +19 -0
- package/dist/shared/projectScripts.js +18 -0
- package/dist/shared/qrCode.d.ts +87 -0
- package/dist/shared/qrCode.js +870 -0
- package/dist/shared/relayAuth.d.ts +27 -0
- package/dist/shared/relayAuth.js +83 -0
- package/dist/shared/relayClient.d.ts +58 -0
- package/dist/shared/relayClient.js +245 -0
- package/dist/shared/relayJwt.d.ts +39 -0
- package/dist/shared/relayJwt.js +2 -0
- package/dist/shared/relaySigning.d.ts +4 -0
- package/dist/shared/relaySigning.js +2 -0
- package/dist/shared/relayTracing.d.ts +25 -0
- package/dist/shared/relayTracing.js +2 -0
- package/dist/shared/relayUrl.d.ts +5 -0
- package/dist/shared/relayUrl.js +2 -0
- package/dist/shared/remote.d.ts +57 -0
- package/dist/shared/remote.js +2 -0
- package/dist/shared/schemaJson.d.ts +35 -0
- package/dist/shared/schemaJson.js +2 -0
- package/dist/shared/schemaYaml.d.ts +86 -0
- package/dist/shared/schemaYaml.js +99 -0
- package/dist/shared/searchRanking.d.ts +30 -0
- package/dist/shared/searchRanking.js +99 -0
- package/dist/shared/semver.d.ts +23 -0
- package/dist/shared/semver.js +124 -0
- package/dist/shared/serverSettings.d.ts +19 -0
- package/dist/shared/serverSettings.js +103 -0
- package/dist/shared/shell.d.ts +51 -0
- package/dist/shared/shell.js +408 -0
- package/dist/shared/sourceControl.d.ts +26 -0
- package/dist/shared/sourceControl.js +2 -0
- package/dist/shared/t3ProjectFile.d.ts +27 -0
- package/dist/shared/t3ProjectFile.js +25 -0
- package/dist/shared/terminalLabels.d.ts +16 -0
- package/dist/shared/terminalLabels.js +28 -0
- package/dist/shared/toolActivity.d.ts +16 -0
- package/dist/shared/toolActivity.js +159 -0
- package/dist/shared.d.ts +43036 -0
- package/dist/shared.js +25428 -12277
- package/dist/t3tools.d.ts +2 -0
- package/dist/t3tools.js +1 -1
- package/package.json +39 -21
- package/src/auth/index.ts +2 -0
- package/src/auth/pairing.ts +8 -5
- package/src/auth/service.ts +2 -1
- package/src/auth/transport.ts +4 -0
- package/src/auth/type.ts +6 -0
- package/src/bin.ts +10 -7
- package/src/cli/auth.ts +7 -1
- package/src/contracts/index.ts +8 -0
- package/src/orchestration/layer.ts +36 -0
- package/src/orchestration/service.ts +5 -0
- package/src/preview/index.ts +11 -0
- package/src/preview/service.ts +52 -0
- package/src/rpc/error.ts +2 -0
- package/src/rpc/layer.ts +5 -4
- package/src/rpc/operation.ts +5 -4
- package/src/rpc/ws-group.ts +6 -0
- package/src/runtime/index.ts +1 -0
- package/src/runtime/layer.ts +5 -0
- package/src/sql/node-sqlite-client.ts +3 -0
- package/dist/src/application/actions.d.ts +0 -25
- package/dist/src/application/error.d.ts +0 -3
- package/dist/src/application/index.d.ts +0 -4
- package/dist/src/application/layer.d.ts +0 -117
- package/dist/src/application/model-selection.d.ts +0 -34
- package/dist/src/application/models.d.ts +0 -8
- package/dist/src/application/project-commands.d.ts +0 -44
- package/dist/src/application/projects.d.ts +0 -23
- package/dist/src/application/service.d.ts +0 -243
- package/dist/src/application/shell-sequence.d.ts +0 -96
- package/dist/src/application/terminals.d.ts +0 -66
- package/dist/src/application/thread-commands.d.ts +0 -157
- package/dist/src/application/thread-update.d.ts +0 -8
- package/dist/src/application/thread-wait.d.ts +0 -106
- package/dist/src/application/threads.d.ts +0 -660
- package/dist/src/auth/error.d.ts +0 -50
- package/dist/src/auth/index.d.ts +0 -10
- package/dist/src/auth/layer.d.ts +0 -53
- package/dist/src/auth/local-base-dir.d.ts +0 -8
- package/dist/src/auth/local-origin.d.ts +0 -18
- package/dist/src/auth/local-token.d.ts +0 -26
- package/dist/src/auth/local.d.ts +0 -24
- package/dist/src/auth/pairing.d.ts +0 -22
- package/dist/src/auth/remote-error.d.ts +0 -3
- package/dist/src/auth/schema.d.ts +0 -58
- package/dist/src/auth/service.d.ts +0 -27
- package/dist/src/auth/transport.d.ts +0 -22
- package/dist/src/auth/type.d.ts +0 -83
- package/dist/src/cli/env/flag.d.ts +0 -2
- package/dist/src/cli/env/index.d.ts +0 -2
- package/dist/src/cli/env/selection-layer.d.ts +0 -3
- package/dist/src/cli/flags.d.ts +0 -20
- package/dist/src/cli/format/index.d.ts +0 -1
- package/dist/src/cli/format/output.d.ts +0 -12
- package/dist/src/cli/index.d.ts +0 -5
- package/dist/src/cli/runtime/index.d.ts +0 -1
- package/dist/src/cli/runtime/service.d.ts +0 -16
- package/dist/src/cli/scope/index.d.ts +0 -1
- package/dist/src/cli/scope/resolve.d.ts +0 -20
- package/dist/src/cli-path/layer.d.ts +0 -3
- package/dist/src/cli-path/service.d.ts +0 -8
- package/dist/src/config/config.d.ts +0 -49
- package/dist/src/config/credential/cipher-node.d.ts +0 -3
- package/dist/src/config/credential/cipher-web.d.ts +0 -3
- package/dist/src/config/credential/cipher.d.ts +0 -29
- package/dist/src/config/credential/env.d.ts +0 -3
- package/dist/src/config/credential/error.d.ts +0 -8
- package/dist/src/config/credential/index.d.ts +0 -6
- package/dist/src/config/credential/service.d.ts +0 -34
- package/dist/src/config/env/env.d.ts +0 -55
- package/dist/src/config/env/index.d.ts +0 -2
- package/dist/src/config/env/layout.d.ts +0 -11
- package/dist/src/config/environment-name/index.d.ts +0 -1
- package/dist/src/config/environment-name/name.d.ts +0 -10
- package/dist/src/config/error.d.ts +0 -11
- package/dist/src/config/index.d.ts +0 -10
- package/dist/src/config/keystore/error.d.ts +0 -8
- package/dist/src/config/keystore/file.d.ts +0 -9
- package/dist/src/config/keystore/index.d.ts +0 -4
- package/dist/src/config/keystore/keyring-node.d.ts +0 -4
- package/dist/src/config/keystore/service.d.ts +0 -33
- package/dist/src/config/paths/index.d.ts +0 -1
- package/dist/src/config/paths/paths.d.ts +0 -6
- package/dist/src/config/persist/file-mode.d.ts +0 -4
- package/dist/src/config/persist/migration.d.ts +0 -68
- package/dist/src/config/persist/persist.d.ts +0 -40
- package/dist/src/config/persist/schema.d.ts +0 -68
- package/dist/src/config/resolve/resolve.d.ts +0 -40
- package/dist/src/config/selection/index.d.ts +0 -1
- package/dist/src/config/selection/resolve.d.ts +0 -4
- package/dist/src/config/selection/service.d.ts +0 -10
- package/dist/src/config/types.d.ts +0 -36
- package/dist/src/config/url/error.d.ts +0 -10
- package/dist/src/config/url/index.d.ts +0 -2
- package/dist/src/config/url/url.d.ts +0 -6
- package/dist/src/connection/error.d.ts +0 -10
- package/dist/src/connection/index.d.ts +0 -4
- package/dist/src/connection/layer.d.ts +0 -3
- package/dist/src/connection/prepared.d.ts +0 -14
- package/dist/src/connection/service.d.ts +0 -13
- package/dist/src/connection/type.d.ts +0 -10
- package/dist/src/contracts/index.d.ts +0 -1
- package/dist/src/domain/error.d.ts +0 -57
- package/dist/src/domain/helpers.d.ts +0 -179
- package/dist/src/domain/model-config.d.ts +0 -330
- package/dist/src/domain/thread-activities.d.ts +0 -14
- package/dist/src/domain/thread-lifecycle.d.ts +0 -120
- package/dist/src/index.d.ts +0 -3
- package/dist/src/node/connection.d.ts +0 -2
- package/dist/src/node/index.d.ts +0 -1
- package/dist/src/orchestration/index.d.ts +0 -2
- package/dist/src/orchestration/layer.d.ts +0 -1419
- package/dist/src/orchestration/service.d.ts +0 -28
- package/dist/src/rpc/error.d.ts +0 -16
- package/dist/src/rpc/index.d.ts +0 -6
- package/dist/src/rpc/layer.d.ts +0 -5862
- package/dist/src/rpc/operation.d.ts +0 -24
- package/dist/src/rpc/service.d.ts +0 -15
- package/dist/src/rpc/session.d.ts +0 -22
- package/dist/src/rpc/ws-group.d.ts +0 -1984
- package/dist/src/runtime/index.d.ts +0 -1
- package/dist/src/runtime/layer.d.ts +0 -15
- package/dist/src/sql/node-sqlite-client.d.ts +0 -10
- package/dist/src/sql/service.d.ts +0 -17
- package/dist/src/t3tools/index.d.ts +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
//#region upstream-t3code/packages/shared/src/relayAuth.d.ts
|
|
3
|
+
declare const ClerkPublishableKeyDecodeError_base: Schema.Class<ClerkPublishableKeyDecodeError, Schema.TaggedStruct<"ClerkPublishableKeyDecodeError", {
|
|
4
|
+
readonly keyPrefix: Schema.Literals<readonly ["pk_test", "pk_live", "unknown"]>;
|
|
5
|
+
readonly cause: Schema.Defect;
|
|
6
|
+
}>, import("effect/Cause").YieldableError>;
|
|
7
|
+
declare class ClerkPublishableKeyDecodeError extends ClerkPublishableKeyDecodeError_base {
|
|
8
|
+
get message(): string;
|
|
9
|
+
}
|
|
10
|
+
declare const ClerkPublishableKeyFrontendApiError_base: Schema.Class<ClerkPublishableKeyFrontendApiError, Schema.TaggedStruct<"ClerkPublishableKeyFrontendApiError", {
|
|
11
|
+
readonly keyPrefix: Schema.Literals<readonly ["pk_test", "pk_live", "unknown"]>;
|
|
12
|
+
readonly frontendApi: Schema.String;
|
|
13
|
+
readonly reason: Schema.Literals<readonly ["empty", "contains-path", "invalid-url"]>;
|
|
14
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
15
|
+
}>, import("effect/Cause").YieldableError>;
|
|
16
|
+
declare class ClerkPublishableKeyFrontendApiError extends ClerkPublishableKeyFrontendApiError_base {
|
|
17
|
+
get message(): string;
|
|
18
|
+
}
|
|
19
|
+
declare function clerkFrontendApiUrlFromPublishableKey(publishableKey: string): string;
|
|
20
|
+
declare function clerkFrontendApiHostnameFromPublishableKey(publishableKey: string): string;
|
|
21
|
+
declare function isAllowedClerkFrontendApiHostname(hostname: string, configuredHostname: string | null): boolean;
|
|
22
|
+
declare function relayClerkTokenOptions(template: string): {
|
|
23
|
+
readonly template: string;
|
|
24
|
+
readonly skipCache: true;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ClerkPublishableKeyDecodeError, ClerkPublishableKeyFrontendApiError, clerkFrontendApiHostnameFromPublishableKey, clerkFrontendApiUrlFromPublishableKey, isAllowedClerkFrontendApiHostname, relayClerkTokenOptions };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { GT as Defect, JT as Literals, QT as String, eE as TaggedErrorClass, uE as optional } from "../shared.js";
|
|
2
|
+
//#region upstream-t3code/packages/shared/src/relayAuth.ts
|
|
3
|
+
const ClerkPublishableKeyPrefix = Literals([
|
|
4
|
+
"pk_test",
|
|
5
|
+
"pk_live",
|
|
6
|
+
"unknown"
|
|
7
|
+
]);
|
|
8
|
+
var ClerkPublishableKeyDecodeError = class extends TaggedErrorClass()("ClerkPublishableKeyDecodeError", {
|
|
9
|
+
keyPrefix: ClerkPublishableKeyPrefix,
|
|
10
|
+
cause: Defect()
|
|
11
|
+
}) {
|
|
12
|
+
get message() {
|
|
13
|
+
return `Failed to decode Clerk publishable key (${this.keyPrefix}).`;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var ClerkPublishableKeyFrontendApiError = class extends TaggedErrorClass()("ClerkPublishableKeyFrontendApiError", {
|
|
17
|
+
keyPrefix: ClerkPublishableKeyPrefix,
|
|
18
|
+
frontendApi: String,
|
|
19
|
+
reason: Literals([
|
|
20
|
+
"empty",
|
|
21
|
+
"contains-path",
|
|
22
|
+
"invalid-url"
|
|
23
|
+
]),
|
|
24
|
+
cause: optional(Defect())
|
|
25
|
+
}) {
|
|
26
|
+
get message() {
|
|
27
|
+
return `Invalid Clerk frontend API decoded from publishable key (${this.keyPrefix}; ${this.reason}).`;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function parseClerkFrontendApi(publishableKey) {
|
|
31
|
+
const keyPrefix = publishableKey.startsWith("pk_test_") ? "pk_test" : publishableKey.startsWith("pk_live_") ? "pk_live" : "unknown";
|
|
32
|
+
const encodedFrontendApi = publishableKey.split("_").slice(2).join("_");
|
|
33
|
+
let frontendApi;
|
|
34
|
+
try {
|
|
35
|
+
frontendApi = globalThis.atob(encodedFrontendApi).replace(/\$$/u, "");
|
|
36
|
+
} catch (cause) {
|
|
37
|
+
throw new ClerkPublishableKeyDecodeError({
|
|
38
|
+
keyPrefix,
|
|
39
|
+
cause
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (frontendApi.length === 0) throw new ClerkPublishableKeyFrontendApiError({
|
|
43
|
+
keyPrefix,
|
|
44
|
+
frontendApi,
|
|
45
|
+
reason: "empty"
|
|
46
|
+
});
|
|
47
|
+
if (frontendApi.includes("/")) throw new ClerkPublishableKeyFrontendApiError({
|
|
48
|
+
keyPrefix,
|
|
49
|
+
frontendApi,
|
|
50
|
+
reason: "contains-path"
|
|
51
|
+
});
|
|
52
|
+
const url = `https://${frontendApi}`;
|
|
53
|
+
try {
|
|
54
|
+
return {
|
|
55
|
+
hostname: new URL(url).hostname,
|
|
56
|
+
url
|
|
57
|
+
};
|
|
58
|
+
} catch (cause) {
|
|
59
|
+
throw new ClerkPublishableKeyFrontendApiError({
|
|
60
|
+
keyPrefix,
|
|
61
|
+
frontendApi,
|
|
62
|
+
reason: "invalid-url",
|
|
63
|
+
cause
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function clerkFrontendApiUrlFromPublishableKey(publishableKey) {
|
|
68
|
+
return parseClerkFrontendApi(publishableKey).url;
|
|
69
|
+
}
|
|
70
|
+
function clerkFrontendApiHostnameFromPublishableKey(publishableKey) {
|
|
71
|
+
return parseClerkFrontendApi(publishableKey).hostname;
|
|
72
|
+
}
|
|
73
|
+
function isAllowedClerkFrontendApiHostname(hostname, configuredHostname) {
|
|
74
|
+
return hostname.endsWith(".clerk.accounts.dev") || hostname.endsWith(".clerk.accounts.com") || hostname === configuredHostname;
|
|
75
|
+
}
|
|
76
|
+
function relayClerkTokenOptions(template) {
|
|
77
|
+
return {
|
|
78
|
+
template,
|
|
79
|
+
skipCache: true
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { ClerkPublishableKeyDecodeError, ClerkPublishableKeyFrontendApiError, clerkFrontendApiHostnameFromPublishableKey, clerkFrontendApiUrlFromPublishableKey, isAllowedClerkFrontendApiHostname, relayClerkTokenOptions };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { zC as RelayClientInstallProgressEvent } from "../shared.js";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import { HttpClient } from "effect/unstable/http";
|
|
6
|
+
import * as Crypto from "effect/Crypto";
|
|
7
|
+
import * as Path from "effect/Path";
|
|
8
|
+
import * as FileSystem from "effect/FileSystem";
|
|
9
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
10
|
+
//#region upstream-t3code/packages/shared/src/relayClient.d.ts
|
|
11
|
+
declare const CLOUDFLARED_VERSION = "2026.5.2";
|
|
12
|
+
declare const CLOUDFLARED_PATH_ENV_NAME = "T3CODE_CLOUDFLARED_PATH";
|
|
13
|
+
type RelayClientExecutableSource = "override" | "managed" | "path";
|
|
14
|
+
type RelayClientStatus = {
|
|
15
|
+
readonly status: "available";
|
|
16
|
+
readonly executablePath: string;
|
|
17
|
+
readonly source: RelayClientExecutableSource;
|
|
18
|
+
readonly version: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly status: "missing";
|
|
21
|
+
readonly version: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly status: "unsupported";
|
|
24
|
+
readonly platform: NodeJS.Platform;
|
|
25
|
+
readonly arch: string;
|
|
26
|
+
readonly version: string;
|
|
27
|
+
};
|
|
28
|
+
type AvailableRelayClient = Extract<RelayClientStatus, {
|
|
29
|
+
readonly status: "available";
|
|
30
|
+
}>;
|
|
31
|
+
declare const RelayClientInstallError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
32
|
+
readonly _tag: "RelayClientInstallError";
|
|
33
|
+
} & Readonly<A>;
|
|
34
|
+
declare class RelayClientInstallError extends RelayClientInstallError_base<{
|
|
35
|
+
readonly reason: "download_failed" | "invalid_checksum" | "install_locked" | "override_missing" | "unsupported_platform" | "validation_failed" | "write_failed";
|
|
36
|
+
readonly message: string;
|
|
37
|
+
readonly cause?: unknown;
|
|
38
|
+
}> {}
|
|
39
|
+
interface CloudflaredReleaseAsset {
|
|
40
|
+
readonly url: string;
|
|
41
|
+
readonly sha256: string;
|
|
42
|
+
readonly archive: "binary" | "tgz";
|
|
43
|
+
}
|
|
44
|
+
interface CloudflaredRelayClientOptions {
|
|
45
|
+
readonly baseDir: string;
|
|
46
|
+
readonly releaseAsset?: CloudflaredReleaseAsset;
|
|
47
|
+
}
|
|
48
|
+
interface RelayClientShape {
|
|
49
|
+
readonly resolve: Effect.Effect<RelayClientStatus>;
|
|
50
|
+
readonly install: Effect.Effect<AvailableRelayClient, RelayClientInstallError>;
|
|
51
|
+
readonly installWithProgress: (report: (event: RelayClientInstallProgressEvent) => Effect.Effect<void>) => Effect.Effect<AvailableRelayClient, RelayClientInstallError>;
|
|
52
|
+
}
|
|
53
|
+
declare const RelayClient_base: Context.ServiceClass<RelayClient, "@t3tools/shared/relayClient", RelayClientShape>;
|
|
54
|
+
declare class RelayClient extends RelayClient_base {}
|
|
55
|
+
declare const makeCloudflaredRelayClient: (options: CloudflaredRelayClientOptions) => Effect.Effect<RelayClientShape, never, ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | FileSystem.FileSystem | HttpClient.HttpClient | Path.Path>;
|
|
56
|
+
declare const layerCloudflared: (options: CloudflaredRelayClientOptions) => Layer.Layer<RelayClient, never, ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | FileSystem.FileSystem | HttpClient.HttpClient | Path.Path>;
|
|
57
|
+
//#endregion
|
|
58
|
+
export { AvailableRelayClient, CLOUDFLARED_PATH_ENV_NAME, CLOUDFLARED_VERSION, CloudflaredRelayClientOptions, CloudflaredReleaseAsset, RelayClient, RelayClientExecutableSource, RelayClientInstallError, RelayClientShape, RelayClientStatus, layerCloudflared, makeCloudflaredRelayClient };
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { $D as flatMap$1, BT as string, Bk as isSome, CO as scoped, DO as suspend, EO as succeed, GO as currentTimeMillis, HC as get, HD as as, IC as HttpClient, KO as TaggedError, LT as all, Mk as flatMap, OE as FileSystem, QD as fail, QO as effect, RO as void_, RT as map, Rk as getOrUndefined, TE as Path, TO as sleep, Uk as none, VC as filterStatusOk, Wk as some, YD as catch_, ZD as ensuring, aO as gen, bE as ChildProcessSpawner, dO as mapError, eO as fn, gO as orDie, hO as option$1, jD as encodeHex, kk as Service, mD as make, oO as ignore, pE as Crypto, qD as catchTag, vE as make$1, w as HostProcessPlatform, y as HostProcessArchitecture, zT as option, zk as isNone } from "../shared.js";
|
|
2
|
+
//#region upstream-t3code/packages/shared/src/relayClient.ts
|
|
3
|
+
const CLOUDFLARED_VERSION = "2026.5.2";
|
|
4
|
+
const CLOUDFLARED_PATH_ENV_NAME = "T3CODE_CLOUDFLARED_PATH";
|
|
5
|
+
var RelayClientInstallError = class extends TaggedError("RelayClientInstallError") {};
|
|
6
|
+
var CloudflaredCommandError = class extends TaggedError("CloudflaredCommandError") {};
|
|
7
|
+
const CLOUDFLARED_RELEASE_ASSETS = {
|
|
8
|
+
"darwin-arm64": {
|
|
9
|
+
url: "https://github.com/cloudflare/cloudflared/releases/download/2026.5.2/cloudflared-darwin-arm64.tgz",
|
|
10
|
+
sha256: "ba94054c9fd4297645093d59d51442e5e546d07bb0516120e694a13d5b216d38",
|
|
11
|
+
archive: "tgz"
|
|
12
|
+
},
|
|
13
|
+
"darwin-x64": {
|
|
14
|
+
url: "https://github.com/cloudflare/cloudflared/releases/download/2026.5.2/cloudflared-darwin-amd64.tgz",
|
|
15
|
+
sha256: "7240f709506bc2c1eb9da4d89cf2555499c60280ecb854b7d80e8f17d4b7903d",
|
|
16
|
+
archive: "tgz"
|
|
17
|
+
},
|
|
18
|
+
"linux-arm64": {
|
|
19
|
+
url: "https://github.com/cloudflare/cloudflared/releases/download/2026.5.2/cloudflared-linux-arm64",
|
|
20
|
+
sha256: "5a4e8ce2701105271412059f44b6a0bf1ae4542b4d98ff3180c0c019443a5815",
|
|
21
|
+
archive: "binary"
|
|
22
|
+
},
|
|
23
|
+
"linux-x64": {
|
|
24
|
+
url: "https://github.com/cloudflare/cloudflared/releases/download/2026.5.2/cloudflared-linux-amd64",
|
|
25
|
+
sha256: "5286698547f03df745adb2355f04c12dde52ef425491e81f433642d695521886",
|
|
26
|
+
archive: "binary"
|
|
27
|
+
},
|
|
28
|
+
"win32-x64": {
|
|
29
|
+
url: "https://github.com/cloudflare/cloudflared/releases/download/2026.5.2/cloudflared-windows-amd64.exe",
|
|
30
|
+
sha256: "20b9638f685333d623798e733effbad2487093f15ba592f6c7752360ff3b7ab7",
|
|
31
|
+
archive: "binary"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const INSTALL_LOCK_RETRY_COUNT = 100;
|
|
35
|
+
const INSTALL_LOCK_RETRY_DELAY = "100 millis";
|
|
36
|
+
const INSTALL_LOCK_STALE_MS = 300 * 1e3;
|
|
37
|
+
const trimmedString = (name) => string(name).pipe(option, map(flatMap((value) => {
|
|
38
|
+
const trimmed = value.trim();
|
|
39
|
+
return trimmed.length > 0 ? some(trimmed) : none();
|
|
40
|
+
})));
|
|
41
|
+
const CloudflaredConfig = all({
|
|
42
|
+
executableOverride: trimmedString(CLOUDFLARED_PATH_ENV_NAME),
|
|
43
|
+
path: trimmedString("PATH")
|
|
44
|
+
});
|
|
45
|
+
var RelayClient = class extends Service()("@t3tools/shared/relayClient") {};
|
|
46
|
+
function executableFileName(platform) {
|
|
47
|
+
return platform === "win32" ? "cloudflared.exe" : "cloudflared";
|
|
48
|
+
}
|
|
49
|
+
function resolveReleaseAsset(platform, arch) {
|
|
50
|
+
return CLOUDFLARED_RELEASE_ASSETS[`${platform}-${arch}`] ?? null;
|
|
51
|
+
}
|
|
52
|
+
function isAlreadyExists(error) {
|
|
53
|
+
return error.reason._tag === "AlreadyExists";
|
|
54
|
+
}
|
|
55
|
+
const wrapInstallFailure = (reason, message) => (effect) => effect.pipe(mapError((cause) => new RelayClientInstallError({
|
|
56
|
+
reason,
|
|
57
|
+
message,
|
|
58
|
+
cause
|
|
59
|
+
})));
|
|
60
|
+
const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
61
|
+
const crypto = yield* Crypto;
|
|
62
|
+
const fileSystem = yield* FileSystem;
|
|
63
|
+
const httpClient = yield* HttpClient;
|
|
64
|
+
const path = yield* Path;
|
|
65
|
+
const spawner = yield* ChildProcessSpawner;
|
|
66
|
+
const installSemaphore = yield* make(1);
|
|
67
|
+
const platform = yield* HostProcessPlatform;
|
|
68
|
+
const arch = yield* HostProcessArchitecture;
|
|
69
|
+
const releaseAsset = options.releaseAsset ?? resolveReleaseAsset(platform, arch);
|
|
70
|
+
const loadCloudflaredConfig = suspend(() => CloudflaredConfig).pipe(orDie);
|
|
71
|
+
const managedPath = path.join(options.baseDir, "tools", "cloudflared", CLOUDFLARED_VERSION, `${platform}-${arch}`, executableFileName(platform));
|
|
72
|
+
const isExecutableFile = fn("cloudflared.isExecutableFile")(function* (executablePath) {
|
|
73
|
+
const info = yield* fileSystem.stat(executablePath).pipe(option$1);
|
|
74
|
+
if (isNone(info) || info.value.type !== "File") return false;
|
|
75
|
+
return platform === "win32" || (info.value.mode & 73) !== 0;
|
|
76
|
+
});
|
|
77
|
+
const resolvePathExecutable = gen(function* () {
|
|
78
|
+
const pathValue = getOrUndefined((yield* loadCloudflaredConfig).path);
|
|
79
|
+
if (!pathValue) return null;
|
|
80
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
81
|
+
for (const directory of pathValue.split(delimiter)) {
|
|
82
|
+
const trimmed = directory.trim().replace(/^"|"$/gu, "");
|
|
83
|
+
if (trimmed.length === 0) continue;
|
|
84
|
+
const candidate = path.join(trimmed, executableFileName(platform));
|
|
85
|
+
if (yield* isExecutableFile(candidate)) return candidate;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
});
|
|
89
|
+
const resolve = gen(function* () {
|
|
90
|
+
const config = yield* loadCloudflaredConfig;
|
|
91
|
+
if (isSome(config.executableOverride)) return (yield* isExecutableFile(config.executableOverride.value)) ? {
|
|
92
|
+
status: "available",
|
|
93
|
+
executablePath: config.executableOverride.value,
|
|
94
|
+
source: "override",
|
|
95
|
+
version: CLOUDFLARED_VERSION
|
|
96
|
+
} : {
|
|
97
|
+
status: "missing",
|
|
98
|
+
version: CLOUDFLARED_VERSION
|
|
99
|
+
};
|
|
100
|
+
if (yield* isExecutableFile(managedPath)) return {
|
|
101
|
+
status: "available",
|
|
102
|
+
executablePath: managedPath,
|
|
103
|
+
source: "managed",
|
|
104
|
+
version: CLOUDFLARED_VERSION
|
|
105
|
+
};
|
|
106
|
+
const pathExecutable = yield* resolvePathExecutable;
|
|
107
|
+
if (pathExecutable) return {
|
|
108
|
+
status: "available",
|
|
109
|
+
executablePath: pathExecutable,
|
|
110
|
+
source: "path",
|
|
111
|
+
version: CLOUDFLARED_VERSION
|
|
112
|
+
};
|
|
113
|
+
return releaseAsset ? {
|
|
114
|
+
status: "missing",
|
|
115
|
+
version: CLOUDFLARED_VERSION
|
|
116
|
+
} : {
|
|
117
|
+
status: "unsupported",
|
|
118
|
+
platform,
|
|
119
|
+
arch,
|
|
120
|
+
version: CLOUDFLARED_VERSION
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
const runCommand = fn("cloudflared.runCommand")(function* (command, args) {
|
|
124
|
+
const child = yield* spawner.spawn(make$1(command, args, {
|
|
125
|
+
shell: false,
|
|
126
|
+
stdout: "ignore",
|
|
127
|
+
stderr: "ignore"
|
|
128
|
+
}));
|
|
129
|
+
const exitCode = Number(yield* child.exitCode);
|
|
130
|
+
if (exitCode !== 0) return yield* new CloudflaredCommandError({
|
|
131
|
+
command,
|
|
132
|
+
exitCode
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
const downloadAsset = fn("cloudflared.downloadAsset")(function* (asset, report) {
|
|
136
|
+
yield* report("downloading");
|
|
137
|
+
const response = yield* httpClient.execute(get(asset.url)).pipe(flatMap$1(filterStatusOk), mapError((cause) => new RelayClientInstallError({
|
|
138
|
+
reason: "download_failed",
|
|
139
|
+
message: "Could not download the relay client.",
|
|
140
|
+
cause
|
|
141
|
+
})));
|
|
142
|
+
const bytes = new Uint8Array(yield* response.arrayBuffer.pipe(mapError((cause) => new RelayClientInstallError({
|
|
143
|
+
reason: "download_failed",
|
|
144
|
+
message: "Could not read the downloaded relay client binary.",
|
|
145
|
+
cause
|
|
146
|
+
}))));
|
|
147
|
+
yield* report("verifying");
|
|
148
|
+
if (encodeHex(yield* crypto.digest("SHA-256", bytes).pipe(mapError((cause) => new RelayClientInstallError({
|
|
149
|
+
reason: "validation_failed",
|
|
150
|
+
message: "Could not verify the downloaded relay client checksum.",
|
|
151
|
+
cause
|
|
152
|
+
})))) !== asset.sha256) return yield* new RelayClientInstallError({
|
|
153
|
+
reason: "invalid_checksum",
|
|
154
|
+
message: "Downloaded relay client checksum did not match the pinned release."
|
|
155
|
+
});
|
|
156
|
+
return bytes;
|
|
157
|
+
});
|
|
158
|
+
const acquireInstallLock = fn("cloudflared.acquireInstallLock")(function* (lockPath) {
|
|
159
|
+
for (let attempt = 0; attempt < INSTALL_LOCK_RETRY_COUNT; attempt += 1) {
|
|
160
|
+
if (yield* fileSystem.writeFileString(lockPath, "", { flag: "wx" }).pipe(as(true), catch_((error) => isAlreadyExists(error) ? succeed(false) : fail(error)))) return;
|
|
161
|
+
const now = yield* currentTimeMillis;
|
|
162
|
+
const mtime = flatMap(yield* fileSystem.stat(lockPath).pipe(option$1), (info) => info.mtime);
|
|
163
|
+
if (isSome(mtime) && now - mtime.value.getTime() > INSTALL_LOCK_STALE_MS) {
|
|
164
|
+
yield* fileSystem.remove(lockPath, { force: true });
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
yield* sleep(INSTALL_LOCK_RETRY_DELAY);
|
|
168
|
+
}
|
|
169
|
+
return yield* new RelayClientInstallError({
|
|
170
|
+
reason: "install_locked",
|
|
171
|
+
message: "Another relay client installation is still in progress."
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
const installUnlocked = fn("cloudflared.installUnlocked")(function* (report) {
|
|
175
|
+
yield* report("checking");
|
|
176
|
+
const existing = yield* resolve;
|
|
177
|
+
if (existing.status === "available") return existing;
|
|
178
|
+
if (isSome((yield* loadCloudflaredConfig).executableOverride)) return yield* new RelayClientInstallError({
|
|
179
|
+
reason: "override_missing",
|
|
180
|
+
message: `${CLOUDFLARED_PATH_ENV_NAME} does not point to an executable file.`
|
|
181
|
+
});
|
|
182
|
+
if (!releaseAsset) return yield* new RelayClientInstallError({
|
|
183
|
+
reason: "unsupported_platform",
|
|
184
|
+
message: `T3 Code does not provide a managed relay client binary for ${platform}-${arch}.`
|
|
185
|
+
});
|
|
186
|
+
const managedDirectory = path.dirname(managedPath);
|
|
187
|
+
const lockPath = `${managedPath}.lock`;
|
|
188
|
+
yield* fileSystem.makeDirectory(managedDirectory, { recursive: true }).pipe(wrapInstallFailure("write_failed", "Could not create the relay client tool directory."));
|
|
189
|
+
yield* report("waiting_for_lock");
|
|
190
|
+
yield* acquireInstallLock(lockPath).pipe(catchTag("PlatformError", (cause) => fail(new RelayClientInstallError({
|
|
191
|
+
reason: "write_failed",
|
|
192
|
+
message: "Could not acquire the relay client installation lock.",
|
|
193
|
+
cause
|
|
194
|
+
}))));
|
|
195
|
+
return yield* gen(function* () {
|
|
196
|
+
const afterLock = yield* resolve;
|
|
197
|
+
if (afterLock.status === "available") return afterLock;
|
|
198
|
+
const tempDirectory = yield* fileSystem.makeTempDirectoryScoped({
|
|
199
|
+
directory: managedDirectory,
|
|
200
|
+
prefix: ".install-"
|
|
201
|
+
});
|
|
202
|
+
const archivePath = path.join(tempDirectory, releaseAsset.archive === "tgz" ? "cloudflared.tgz" : executableFileName(platform));
|
|
203
|
+
const download = yield* downloadAsset(releaseAsset, report);
|
|
204
|
+
yield* report("installing");
|
|
205
|
+
yield* fileSystem.writeFile(archivePath, download).pipe(wrapInstallFailure("write_failed", "Could not write the relay client download."));
|
|
206
|
+
const executablePath = path.join(tempDirectory, executableFileName(platform));
|
|
207
|
+
if (releaseAsset.archive === "tgz") yield* runCommand("tar", [
|
|
208
|
+
"-xzf",
|
|
209
|
+
archivePath,
|
|
210
|
+
"-C",
|
|
211
|
+
tempDirectory
|
|
212
|
+
]).pipe(wrapInstallFailure("write_failed", "Could not extract the relay client."));
|
|
213
|
+
if (platform !== "win32") yield* fileSystem.chmod(executablePath, 493).pipe(wrapInstallFailure("write_failed", "Could not make the relay client executable."));
|
|
214
|
+
yield* report("validating");
|
|
215
|
+
yield* runCommand(executablePath, ["--version"]).pipe(wrapInstallFailure("validation_failed", "The downloaded relay client binary did not run."));
|
|
216
|
+
const stagedPath = `${managedPath}.${yield* crypto.randomUUIDv4}.tmp`;
|
|
217
|
+
yield* report("activating");
|
|
218
|
+
yield* fileSystem.rename(executablePath, stagedPath).pipe(wrapInstallFailure("write_failed", "Could not stage the relay client."));
|
|
219
|
+
yield* fileSystem.rename(stagedPath, managedPath).pipe(wrapInstallFailure("write_failed", "Could not activate the relay client."), ensuring(fileSystem.remove(stagedPath, { force: true }).pipe(ignore)));
|
|
220
|
+
return {
|
|
221
|
+
status: "available",
|
|
222
|
+
executablePath: managedPath,
|
|
223
|
+
source: "managed",
|
|
224
|
+
version: CLOUDFLARED_VERSION
|
|
225
|
+
};
|
|
226
|
+
}).pipe(scoped, ensuring(fileSystem.remove(lockPath, { force: true }).pipe(ignore)), catch_((cause) => cause instanceof RelayClientInstallError ? fail(cause) : fail(new RelayClientInstallError({
|
|
227
|
+
reason: "write_failed",
|
|
228
|
+
message: "Could not install the relay client.",
|
|
229
|
+
cause
|
|
230
|
+
}))));
|
|
231
|
+
});
|
|
232
|
+
const installWithProgress = (report) => installSemaphore.withPermit(installUnlocked((stage) => report({
|
|
233
|
+
type: "progress",
|
|
234
|
+
stage
|
|
235
|
+
})));
|
|
236
|
+
const install = installWithProgress(() => void_);
|
|
237
|
+
return RelayClient.of({
|
|
238
|
+
resolve,
|
|
239
|
+
install,
|
|
240
|
+
installWithProgress
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
const layerCloudflared = (options) => effect(RelayClient, makeCloudflaredRelayClient(options));
|
|
244
|
+
//#endregion
|
|
245
|
+
export { CLOUDFLARED_PATH_ENV_NAME, CLOUDFLARED_VERSION, RelayClient, RelayClientInstallError, layerCloudflared, makeCloudflaredRelayClient };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import { JWTPayload } from "jose";
|
|
4
|
+
//#region upstream-t3code/packages/shared/src/relayJwt.d.ts
|
|
5
|
+
declare const RELAY_LINK_PROOF_TYP = "t3-env-link+jwt";
|
|
6
|
+
declare const RELAY_MINT_REQUEST_TYP = "t3-cloud-mint+jwt";
|
|
7
|
+
declare const RELAY_HEALTH_REQUEST_TYP = "t3-cloud-health+jwt";
|
|
8
|
+
declare const RELAY_MINT_RESPONSE_TYP = "t3-env-mint+jwt";
|
|
9
|
+
declare const RELAY_HEALTH_RESPONSE_TYP = "t3-env-health+jwt";
|
|
10
|
+
declare const RELAY_ACTIVITY_PUBLISH_TYP = "t3-env-activity+jwt";
|
|
11
|
+
declare const RelayJwtError_base: Schema.Class<RelayJwtError, Schema.TaggedStruct<"RelayJwtError", {
|
|
12
|
+
readonly operation: Schema.Literals<readonly ["sign", "verify"]>;
|
|
13
|
+
readonly typ: Schema.String;
|
|
14
|
+
readonly issuer: Schema.optional<Schema.String>;
|
|
15
|
+
readonly audience: Schema.optional<Schema.String>;
|
|
16
|
+
readonly cause: Schema.Defect;
|
|
17
|
+
}>, import("effect/Cause").YieldableError>;
|
|
18
|
+
declare class RelayJwtError extends RelayJwtError_base {
|
|
19
|
+
get message(): string;
|
|
20
|
+
static diagnosticCode(error: RelayJwtError): string;
|
|
21
|
+
}
|
|
22
|
+
declare function normalizeRelayIssuer(value: string): string;
|
|
23
|
+
declare function decodeRelayJwt(token: string): JWTPayload;
|
|
24
|
+
declare function signRelayJwt(input: {
|
|
25
|
+
readonly privateKey: string;
|
|
26
|
+
readonly typ: string;
|
|
27
|
+
readonly payload: JWTPayload;
|
|
28
|
+
}): Effect.Effect<string, RelayJwtError>;
|
|
29
|
+
declare function verifyRelayJwt(input: {
|
|
30
|
+
readonly publicKey: string;
|
|
31
|
+
readonly token: string;
|
|
32
|
+
readonly typ: string;
|
|
33
|
+
readonly issuer: string;
|
|
34
|
+
readonly audience: string;
|
|
35
|
+
readonly nowEpochSeconds: number;
|
|
36
|
+
readonly maxTokenAge?: string | number;
|
|
37
|
+
}): Effect.Effect<JWTPayload, RelayJwtError>;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { RELAY_ACTIVITY_PUBLISH_TYP, RELAY_HEALTH_REQUEST_TYP, RELAY_HEALTH_RESPONSE_TYP, RELAY_LINK_PROOF_TYP, RELAY_MINT_REQUEST_TYP, RELAY_MINT_RESPONSE_TYP, RelayJwtError, decodeRelayJwt, normalizeRelayIssuer, signRelayJwt, verifyRelayJwt };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $a as RELAY_HEALTH_REQUEST_TYP, Qa as RELAY_ACTIVITY_PUBLISH_TYP, ao as decodeRelayJwt, co as verifyRelayJwt, eo as RELAY_HEALTH_RESPONSE_TYP, io as RelayJwtError, no as RELAY_MINT_REQUEST_TYP, oo as normalizeRelayIssuer, ro as RELAY_MINT_RESPONSE_TYP, so as signRelayJwt, to as RELAY_LINK_PROOF_TYP } from "../shared.js";
|
|
2
|
+
export { RELAY_ACTIVITY_PUBLISH_TYP, RELAY_HEALTH_REQUEST_TYP, RELAY_HEALTH_RESPONSE_TYP, RELAY_LINK_PROOF_TYP, RELAY_MINT_REQUEST_TYP, RELAY_MINT_RESPONSE_TYP, RelayJwtError, decodeRelayJwt, normalizeRelayIssuer, signRelayJwt, verifyRelayJwt };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import { HttpClient } from "effect/unstable/http";
|
|
6
|
+
import * as Tracer from "effect/Tracer";
|
|
7
|
+
//#region upstream-t3code/packages/shared/src/relayTracing.d.ts
|
|
8
|
+
interface RelayClientTracingConfig {
|
|
9
|
+
readonly tracesUrl: string;
|
|
10
|
+
readonly tracesDataset: string;
|
|
11
|
+
readonly tracesToken: string;
|
|
12
|
+
}
|
|
13
|
+
interface RelayClientTracingResource {
|
|
14
|
+
readonly serviceName: string;
|
|
15
|
+
readonly serviceVersion?: string;
|
|
16
|
+
readonly runtime: string;
|
|
17
|
+
readonly client: string;
|
|
18
|
+
readonly component?: string;
|
|
19
|
+
}
|
|
20
|
+
declare const RelayClientTracer_base: Context.Reference<Option.Option<Tracer.Tracer>>;
|
|
21
|
+
declare class RelayClientTracer extends RelayClientTracer_base {}
|
|
22
|
+
declare const withRelayClientTracing: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
23
|
+
declare function makeRelayClientTracingLayer(config: RelayClientTracingConfig | null, resource: RelayClientTracingResource): Layer.Layer<never, never, HttpClient.HttpClient>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { RelayClientTracer, RelayClientTracingConfig, RelayClientTracingResource, makeRelayClientTracingLayer, withRelayClientTracing };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
//#region upstream-t3code/packages/shared/src/remote.d.ts
|
|
3
|
+
declare const readHashParams: (url: URL) => URLSearchParams;
|
|
4
|
+
declare const RemoteBackendUrlMissingError_base: Schema.Class<RemoteBackendUrlMissingError, Schema.TaggedStruct<"RemoteBackendUrlMissingError", {}>, import("effect/Cause").YieldableError>;
|
|
5
|
+
declare class RemoteBackendUrlMissingError extends RemoteBackendUrlMissingError_base {
|
|
6
|
+
get message(): string;
|
|
7
|
+
}
|
|
8
|
+
declare const RemotePairingUrlInvalidError_base: Schema.Class<RemotePairingUrlInvalidError, Schema.TaggedStruct<"RemotePairingUrlInvalidError", {
|
|
9
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
10
|
+
readonly protocol: Schema.optional<Schema.String>;
|
|
11
|
+
}>, import("effect/Cause").YieldableError>;
|
|
12
|
+
declare class RemotePairingUrlInvalidError extends RemotePairingUrlInvalidError_base {
|
|
13
|
+
get message(): string;
|
|
14
|
+
}
|
|
15
|
+
declare const RemoteBackendUrlInvalidError_base: Schema.Class<RemoteBackendUrlInvalidError, Schema.TaggedStruct<"RemoteBackendUrlInvalidError", {
|
|
16
|
+
readonly source: Schema.Literals<readonly ["direct-host", "hosted-pairing-host"]>;
|
|
17
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
18
|
+
readonly protocol: Schema.optional<Schema.String>;
|
|
19
|
+
}>, import("effect/Cause").YieldableError>;
|
|
20
|
+
declare class RemoteBackendUrlInvalidError extends RemoteBackendUrlInvalidError_base {
|
|
21
|
+
get message(): string;
|
|
22
|
+
}
|
|
23
|
+
declare const RemotePairingTokenMissingError_base: Schema.Class<RemotePairingTokenMissingError, Schema.TaggedStruct<"RemotePairingTokenMissingError", {
|
|
24
|
+
readonly host: Schema.String;
|
|
25
|
+
}>, import("effect/Cause").YieldableError>;
|
|
26
|
+
declare class RemotePairingTokenMissingError extends RemotePairingTokenMissingError_base {
|
|
27
|
+
get message(): string;
|
|
28
|
+
}
|
|
29
|
+
declare const RemotePairingCodeMissingError_base: Schema.Class<RemotePairingCodeMissingError, Schema.TaggedStruct<"RemotePairingCodeMissingError", {
|
|
30
|
+
readonly host: Schema.String;
|
|
31
|
+
}>, import("effect/Cause").YieldableError>;
|
|
32
|
+
declare class RemotePairingCodeMissingError extends RemotePairingCodeMissingError_base {
|
|
33
|
+
get message(): string;
|
|
34
|
+
}
|
|
35
|
+
declare const RemotePairingTargetError: Schema.Union<readonly [typeof RemoteBackendUrlMissingError, typeof RemotePairingUrlInvalidError, typeof RemoteBackendUrlInvalidError, typeof RemotePairingTokenMissingError, typeof RemotePairingCodeMissingError]>;
|
|
36
|
+
type RemotePairingTargetError = typeof RemotePairingTargetError.Type;
|
|
37
|
+
interface ResolvedRemotePairingTarget {
|
|
38
|
+
readonly credential: string;
|
|
39
|
+
readonly httpBaseUrl: string;
|
|
40
|
+
readonly wsBaseUrl: string;
|
|
41
|
+
}
|
|
42
|
+
interface HostedPairingRequest {
|
|
43
|
+
readonly host: string;
|
|
44
|
+
readonly token: string;
|
|
45
|
+
readonly label: string;
|
|
46
|
+
}
|
|
47
|
+
declare const getPairingTokenFromUrl: (url: URL) => string | null;
|
|
48
|
+
declare const stripPairingTokenFromUrl: (url: URL) => URL;
|
|
49
|
+
declare const setPairingTokenOnUrl: (url: URL, credential: string) => URL;
|
|
50
|
+
declare const readHostedPairingRequest: (url: URL) => HostedPairingRequest | null;
|
|
51
|
+
declare const resolveRemotePairingTarget: (input: {
|
|
52
|
+
readonly pairingUrl?: string;
|
|
53
|
+
readonly host?: string;
|
|
54
|
+
readonly pairingCode?: string;
|
|
55
|
+
}) => ResolvedRemotePairingTarget;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { HostedPairingRequest, RemoteBackendUrlInvalidError, RemoteBackendUrlMissingError, RemotePairingCodeMissingError, RemotePairingTargetError, RemotePairingTokenMissingError, RemotePairingUrlInvalidError, ResolvedRemotePairingTarget, getPairingTokenFromUrl, readHashParams, readHostedPairingRequest, resolveRemotePairingTarget, setPairingTokenOnUrl, stripPairingTokenFromUrl };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Ca as readHostedPairingRequest, Ea as stripPairingTokenFromUrl, Sa as readHashParams, Ta as setPairingTokenOnUrl, _a as RemotePairingCodeMissingError, ba as RemotePairingUrlInvalidError, ga as RemoteBackendUrlMissingError, ha as RemoteBackendUrlInvalidError, va as RemotePairingTargetError, wa as resolveRemotePairingTarget, xa as getPairingTokenFromUrl, ya as RemotePairingTokenMissingError } from "../shared.js";
|
|
2
|
+
export { RemoteBackendUrlInvalidError, RemoteBackendUrlMissingError, RemotePairingCodeMissingError, RemotePairingTargetError, RemotePairingTokenMissingError, RemotePairingUrlInvalidError, getPairingTokenFromUrl, readHashParams, readHostedPairingRequest, resolveRemotePairingTarget, setPairingTokenOnUrl, stripPairingTokenFromUrl };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import * as Cause from "effect/Cause";
|
|
3
|
+
import * as Result from "effect/Result";
|
|
4
|
+
import * as SchemaGetter from "effect/SchemaGetter";
|
|
5
|
+
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
6
|
+
//#region upstream-t3code/packages/shared/src/schemaJson.d.ts
|
|
7
|
+
declare const decodeJsonResult: <S extends Schema.Codec<unknown, unknown, never, never>>(schema: S) => (input: string) => Result.Result<never, Cause.Cause<Schema.SchemaError>> | Result.Result<S["Type"], never>;
|
|
8
|
+
declare const decodeUnknownJsonResult: <S extends Schema.Codec<unknown, unknown, never, never>>(schema: S) => (input: unknown) => Result.Result<never, Cause.Cause<Schema.SchemaError>> | Result.Result<S["Type"], never>;
|
|
9
|
+
declare const formatSchemaError: (cause: Cause.Cause<Schema.SchemaError>) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Schema transformation: lenient JSONC string ↔ unknown.
|
|
12
|
+
*
|
|
13
|
+
* Same API as `SchemaTransformation.fromJsonString`, but the decode side
|
|
14
|
+
* strips trailing commas and JS-style comments before parsing.
|
|
15
|
+
* Encoding produces strict JSON via `JSON.stringify`.
|
|
16
|
+
*/
|
|
17
|
+
declare const fromLenientJsonString: SchemaTransformation.Transformation<unknown, string, never, never>;
|
|
18
|
+
declare const prettyJsonString: SchemaGetter.Getter<string, string, never>;
|
|
19
|
+
/**
|
|
20
|
+
* Build a schema that decodes a lenient JSON string into `A`.
|
|
21
|
+
*
|
|
22
|
+
* Drop-in replacement for `Schema.fromJsonString(schema)` that tolerates
|
|
23
|
+
* trailing commas and comments in the input.
|
|
24
|
+
*/
|
|
25
|
+
declare const fromLenientJson: <S extends Schema.Top>(schema: S) => Schema.decodeTo<S, Schema.String, never, never>;
|
|
26
|
+
declare function extractJsonObject(raw: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Build a JSON string schema that encodes with stable 2-space formatting.
|
|
29
|
+
*
|
|
30
|
+
* Decode behavior matches `Schema.fromJsonString(schema)`. Encode behavior
|
|
31
|
+
* keeps the transformation schema-based while preserving human-readable JSON.
|
|
32
|
+
*/
|
|
33
|
+
declare const fromJsonStringPretty: <S extends Schema.Top>(schema: S) => Schema.decodeTo<Schema.fromJsonString<S>, Schema.toEncoded<Schema.fromJsonString<S>>, never, never>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { decodeJsonResult, decodeUnknownJsonResult, extractJsonObject, formatSchemaError, fromJsonStringPretty, fromLenientJson, fromLenientJsonString, prettyJsonString };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as fromLenientJsonString, d as decodeJsonResult, f as decodeUnknownJsonResult, g as fromLenientJson, h as fromJsonStringPretty, m as formatSchemaError, p as extractJsonObject, v as prettyJsonString } from "../shared.js";
|
|
2
|
+
export { decodeJsonResult, decodeUnknownJsonResult, extractJsonObject, formatSchemaError, fromJsonStringPretty, fromLenientJson, fromLenientJsonString, prettyJsonString };
|