Open History to see the last commit
1import * as Config from "effect/Config";
2import * as Context from "effect/Context";
3import * as Effect from "effect/Effect";
4import * as Layer from "effect/Layer";
5import * as Redacted from "effect/Redacted";
6import * as Schema from "effect/Schema";
7
8export const ApnsEnvironment = Schema.Literals(["sandbox", "production"]);
9export type ApnsEnvironment = typeof ApnsEnvironment.Type;
10
11export const ManagedEndpointCleanupMode = Schema.Literals(["off", "dry-run", "enabled"]);
12export type ManagedEndpointCleanupMode = typeof ManagedEndpointCleanupMode.Type;
13const decodeManagedEndpointCleanupMode = Schema.decodeUnknownEffect(ManagedEndpointCleanupMode);
14
15export const managedEndpointCleanupModeConfig = Config.String("RELAY_TUNNEL_CLEANUP_MODE").pipe(
16 Config.withDefault("off"),
17 Config.map((value) => value.trim() || "off"),
18 Config.mapEffect((value) =>
19 decodeManagedEndpointCleanupMode(value).pipe(
20 Effect.mapError((error) => new Config.ConfigError(error)),
21 ),
22 ),
23);
24
25export interface ApnsCredentials {
26 readonly teamId: string;
27 readonly keyId: string;
28 readonly privateKey: Redacted.Redacted<string>;
29 readonly bundleId: string;
30 readonly environment: ApnsEnvironment;
31}
32
33export class RelayConfiguration extends Context.Service<
34 RelayConfiguration,
35 {
36 readonly relayIssuer: string;
37 readonly apns: ApnsCredentials | null;
38 readonly fcmServiceAccount?: Redacted.Redacted<string>;
39 readonly clerkSecretKey: Redacted.Redacted<string>;
40 readonly clerkPublishableKey: string;
41 readonly clerkJwtAudience: string;
42 readonly apnsDeliveryJobSigningSecret: Redacted.Redacted<string>;
43 readonly cloudMintPrivateKey: Redacted.Redacted<string>;
44 readonly cloudMintPublicKey: string;
45 readonly managedEndpointBaseDomain: string | undefined;
46 readonly managedEndpointNamespace: string | undefined;
47 readonly managedEndpointCleanupMode?: ManagedEndpointCleanupMode;
48 }
49>()("t3code-relay/Config/RelayConfiguration") {}
50
51export const make = (configuration: RelayConfiguration["Service"]) =>
52 RelayConfiguration.of(configuration);
53
54export const layer = (configuration: RelayConfiguration["Service"]) =>
55 Layer.succeed(RelayConfiguration, make(configuration));