@r_masseater/masseater-utils 0.15.0 → 0.17.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/README.md +1 -34
- package/dist/cache-B2pb5ulh.mjs +20 -0
- package/dist/cache-B2pb5ulh.mjs.map +1 -0
- package/dist/cache-B_fAwTnH.d.mts +10 -0
- package/dist/cache.d.mts +2 -0
- package/dist/cache.mjs +1 -0
- package/dist/desktop-shell/media-notes.d.mts +1 -9
- package/dist/desktop-shell/media-notes.mjs +1 -1
- package/dist/desktop-shell/release-cli.mjs +1 -1
- package/dist/{socket-port-Cq7YKLFS.mjs → endpoint-BZzLgZs1.mjs} +3 -6
- package/dist/endpoint-BZzLgZs1.mjs.map +1 -0
- package/dist/github-workflow.d.mts +1 -4
- package/dist/github-workflow.mjs +2 -5
- package/dist/github-workflow.mjs.map +1 -1
- package/dist/{headers-CtvGSXbz.mjs → headers-DSqz93yF.mjs} +10 -6
- package/dist/headers-DSqz93yF.mjs.map +1 -0
- package/dist/{headers-NUwRihYD.d.mts → headers-DVWS82Vk.d.mts} +5 -22
- package/dist/{web-analytics-Cvs9PDoh.d.mts → index-B995c2b6.d.mts} +1 -0
- package/dist/{index-8ZrDzBaY.d.mts → index-MqLQZR1B.d.mts} +1 -0
- package/dist/kestrion/npm.d.mts +0 -1
- package/dist/kestrion/npm.mjs +1 -6
- package/dist/kestrion/npm.mjs.map +1 -1
- package/dist/local-server/node.mjs +5 -2
- package/dist/local-server/node.mjs.map +1 -1
- package/dist/local-server.d.mts +1 -5
- package/dist/local-server.mjs +2 -2
- package/dist/match-groups-MH1j-WE-.mjs +7 -0
- package/dist/match-groups-MH1j-WE-.mjs.map +1 -0
- package/dist/model-server.mjs.map +1 -1
- package/dist/plugin-kit.d.mts +3 -17
- package/dist/plugin-kit.mjs +35 -52
- package/dist/plugin-kit.mjs.map +1 -1
- package/dist/{process-l69KvwcT.mjs → process-DTCkAoL_.mjs} +18 -2
- package/dist/process-DTCkAoL_.mjs.map +1 -0
- package/dist/{process-BHJEIAWo.d.mts → process-z7u_XWgI.d.mts} +11 -1
- package/dist/process.d.mts +2 -2
- package/dist/process.mjs +1 -1
- package/dist/security-headers/http.d.mts +2 -4
- package/dist/security-headers/http.mjs +2 -4
- package/dist/security-headers/http.mjs.map +1 -1
- package/dist/security-headers/response.mjs +1 -1
- package/dist/security-headers/static.d.mts +1 -1
- package/dist/security-headers/static.mjs +1 -1
- package/dist/security-headers/vite.d.mts +1 -1
- package/dist/security-headers/vite.mjs +1 -1
- package/dist/security-headers.d.mts +3 -4
- package/dist/security-headers.mjs +2 -2
- package/dist/{static-page-headers-C40Ty9PI.mjs → static-page-headers-C7w-AabA.mjs} +3 -2
- package/dist/static-page-headers-C7w-AabA.mjs.map +1 -0
- package/dist/text.d.mts +4 -0
- package/dist/text.mjs +8 -0
- package/dist/text.mjs.map +1 -0
- package/dist/ui/portfolio.d.mts +0 -1
- package/dist/ui/portfolio.mjs +1 -1
- package/dist/ui/web-analytics.d.mts +1 -2
- package/dist/usage-meter/report.d.mts +18 -2
- package/dist/usage-meter/report.mjs +2 -2
- package/dist/usage-meter.d.mts +1 -2
- package/dist/usage-meter.mjs +1 -3
- package/dist/workers-tracing/effect.d.mts +1 -2
- package/dist/workers-tracing/effect.mjs +1 -1
- package/dist/workers-tracing/effect.mjs.map +1 -1
- package/package.json +3 -1
- package/skills/add-scroll-chip-row/SKILL.md +1 -1
- package/skills/assert-exported-telemetry/SKILL.md +1 -1
- package/skills/build-tauri-app/SKILL.md +1 -1
- package/skills/find-cache-folder/SKILL.md +1 -1
- package/skills/import-custom-format/SKILL.md +1 -1
- package/skills/name-stack-resources/SKILL.md +1 -1
- package/skills/read-hook-input/SKILL.md +1 -1
- package/skills/read-node-ecosystem/SKILL.md +1 -1
- package/skills/run-effect-main/SKILL.md +1 -1
- package/skills/share-types-with-rust/SKILL.md +1 -1
- package/skills/trace-workers/SKILL.md +1 -1
- package/skills/use-model-server/SKILL.md +1 -1
- package/skills/write-actions-steps/SKILL.md +1 -1
- package/dist/headers-CtvGSXbz.mjs.map +0 -1
- package/dist/index-Cz3K0tg_.d.mts +0 -3
- package/dist/process-l69KvwcT.mjs.map +0 -1
- package/dist/socket-port-Cq7YKLFS.mjs.map +0 -1
- package/dist/static-page-headers-C40Ty9PI.mjs.map +0 -1
- package/dist/usage-tally-BBhBouif.d.mts +0 -19
package/README.md
CHANGED
|
@@ -32,31 +32,7 @@ vp add @r_masseater/masseater-utils
|
|
|
32
32
|
|
|
33
33
|
## Install what a subpath needs
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
| Subpath | Install besides this package |
|
|
38
|
-
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
-
| `skerm` | `react` |
|
|
40
|
-
| `plugin-kit` | `effect` and `@effect/platform-node` |
|
|
41
|
-
| `model-server` | Nothing. The server installs its inference runtime into the user's cache folder with `npm` on the first call. |
|
|
42
|
-
| `node-main` | `effect` and `@effect/platform-node` |
|
|
43
|
-
| `github-workflow` | `effect` |
|
|
44
|
-
| `mapped-import` | `effect` and `ts-content-mapper`, plus `vite-plus` for `mapped-import/vite` |
|
|
45
|
-
| `kestrion` | `effect`, plus the readers of the entry you use: `@npmcli/package-json` for `kestrion/npm`, the `@pnpm/*` readers for `kestrion/pnpm` |
|
|
46
|
-
| `vitest-otlp` | `effect`, `@bufbuild/protobuf` and `vite-plus` |
|
|
47
|
-
| `workers-tracing` | `effect`, plus `@tanstack/react-start`, `elysia`, `alchemy` or `@alchemy.run/cloudflare` for the entry that wraps them |
|
|
48
|
-
| `effect2rs` | `effect` |
|
|
49
|
-
| `effect2cs` | `effect` and `quicktype-core` |
|
|
50
|
-
| `process` | `effect` |
|
|
51
|
-
| `security-headers` | `effect`, plus `vite-plus` for `security-headers/vite` |
|
|
52
|
-
| `lapse` | `effect`, `vite-plus`, `@opentelemetry/sdk-node` and `@opentelemetry/exporter-trace-otlp-http` |
|
|
53
|
-
| `local-server` | `effect`, plus `@effect/platform-node`, `@effect/sql-sqlite-node` and `srvx` for `local-server/node` and `local-server/serve` |
|
|
54
|
-
| `browser-test` | `vite-plus`, `@vitest/browser-playwright`, `playwright` and `dejavu-fonts-ttf` |
|
|
55
|
-
| `ui` | `react`, `tailwindcss`, `tw-animate-css`, `@fontsource-variable/roboto-flex`, `class-variance-authority`, `clsx`, `tailwind-merge` and `radix-ui` |
|
|
56
|
-
| `yohaku-protocol` | `effect` |
|
|
57
|
-
| `desktop-shell` | `effect` and `@effect/platform-node`, plus `@tauri-apps/api` and the `@opentelemetry/*` browser packages for `desktop-shell/telemetry`, `vite-plus`, `@tailwindcss/vite` and `@vitejs/plugin-react` for `desktop-shell/vite`, and `react`, `@effect/atom-react`, `@tauri-apps/api`, `lucide-react` and `niconico-embed-player` for `desktop-shell/media-notes` |
|
|
58
|
-
|
|
59
|
-
The `peerDependencies` of `package.json` are the exact list with ranges.
|
|
35
|
+
Every package a subpath needs is an optional peer dependency, so installing this package adds none of them. Install the ones the subpath you import names in its error when it cannot find them, and nothing else.
|
|
60
36
|
|
|
61
37
|
## Tauri desktop apps
|
|
62
38
|
|
|
@@ -73,15 +49,6 @@ import { Console } from "effect";
|
|
|
73
49
|
runMain("my-tool")(Console.log("hello"));
|
|
74
50
|
```
|
|
75
51
|
|
|
76
|
-
```ts
|
|
77
|
-
import { isRecord, parseJson } from "@r_masseater/masseater-utils/plugin-kit";
|
|
78
|
-
|
|
79
|
-
const parsed = parseJson(text);
|
|
80
|
-
if (parsed._tag === "Some" && isRecord(parsed.value)) {
|
|
81
|
-
console.log(parsed.value["tool_name"]);
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
52
|
```ts
|
|
86
53
|
import { ScrollChipRow } from "@r_masseater/masseater-utils/skerm";
|
|
87
54
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Array, Config, Effect, Option, Schema, pipe } from "effect";
|
|
2
|
+
// src/shared/lib/cache.ts
|
|
3
|
+
const taggedError = Schema.TaggedError;
|
|
4
|
+
var CacheRootError = class extends taggedError()("CacheRootError", { message: Schema.String }) {};
|
|
5
|
+
const SEPARATOR = "/";
|
|
6
|
+
const CACHE_DIRECTORY_NAME = ".cache";
|
|
7
|
+
const variable = (name) => Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));
|
|
8
|
+
const baseDirectory = Effect.gen(function* baseDirectory() {
|
|
9
|
+
const cacheHome = yield* variable("XDG_CACHE_HOME");
|
|
10
|
+
const home = yield* variable("HOME");
|
|
11
|
+
const profile = yield* variable("USERPROFILE");
|
|
12
|
+
return pipe(cacheHome, Option.orElse(() => pipe(Option.orElse(home, () => profile), Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`))));
|
|
13
|
+
});
|
|
14
|
+
const cacheRootEffect = (segments) => baseDirectory.pipe(Effect.flatMap(Option.match({
|
|
15
|
+
onNone: () => Effect.fail(CacheRootError.make({ message: "set XDG_CACHE_HOME or HOME" })),
|
|
16
|
+
onSome: (base) => Effect.succeed(pipe([base, ...segments], Array.join(SEPARATOR)))
|
|
17
|
+
})));
|
|
18
|
+
export { CacheRootError as n, cacheRootEffect as r, CACHE_DIRECTORY_NAME as t };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=cache-B2pb5ulh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-B2pb5ulh.mjs","names":["Arr"],"sources":["../src/shared/lib/cache.ts"],"sourcesContent":["import { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class CacheRootError extends taggedError<\n CacheRootError,\n { readonly brand: unique symbol }\n>()(\"CacheRootError\", { message: Schema.String }) {}\n\nconst SEPARATOR = \"/\";\nexport const CACHE_DIRECTORY_NAME = \".cache\";\n\nconst variable = (name: string): Effect.Effect<Option.Option<string>> =>\n Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));\n\nconst baseDirectory: Effect.Effect<Option.Option<string>> = Effect.gen(function* baseDirectory() {\n const cacheHome = yield* variable(\"XDG_CACHE_HOME\");\n const home = yield* variable(\"HOME\");\n const profile = yield* variable(\"USERPROFILE\");\n return pipe(\n cacheHome,\n Option.orElse(() =>\n pipe(\n Option.orElse(home, () => profile),\n Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`),\n ),\n ),\n );\n});\n\nexport const cacheRootEffect = (\n segments: readonly string[],\n): Effect.Effect<string, CacheRootError> =>\n baseDirectory.pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.fail(CacheRootError.make({ message: \"set XDG_CACHE_HOME or HOME\" })),\n onSome: (base) => Effect.succeed(pipe([base, ...segments], Arr.join(SEPARATOR))),\n }),\n ),\n );\n"],"mappings":";;AAEA,MAAM,cAAc,OAAO;AAE3B,IAAa,iBAAb,cAAoC,YAGlC,CAAC,CAAC,kBAAkB,EAAE,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnD,MAAM,YAAY;AAClB,MAAa,uBAAuB;AAEpC,MAAM,YAAY,SAChB,OAAO,OAAO,OAAO,eAAe,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,cAAc,OAAO,IAAI,CAAC;AAEnF,MAAM,gBAAsD,OAAO,IAAI,UAAU,gBAAgB;CAC/F,MAAM,YAAY,OAAO,SAAS,gBAAgB;CAClD,MAAM,OAAO,OAAO,SAAS,MAAM;CACnC,MAAM,UAAU,OAAO,SAAS,aAAa;CAC7C,OAAO,KACL,WACA,OAAO,aACL,KACE,OAAO,OAAO,YAAY,OAAO,GACjC,OAAO,KAAK,cAAc,GAAG,YAAY,YAAY,sBAAsB,CAC7E,CACF,CACF;AACF,CAAC;AAED,MAAa,mBACX,aAEA,cAAc,KACZ,OAAO,QACL,OAAO,MAAM;CACX,cAAc,OAAO,KAAK,eAAe,KAAK,EAAE,SAAS,6BAA6B,CAAC,CAAC;CACxF,SAAS,SAAS,OAAO,QAAQ,KAAK,CAAC,MAAM,GAAG,QAAQ,GAAGA,MAAI,KAAK,SAAS,CAAC,CAAC;AACjF,CAAC,CACH,CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
declare const CacheRootError_base: Schema.Class<CacheRootError, Schema.TaggedStruct<"CacheRootError", {
|
|
3
|
+
readonly message: Schema.String;
|
|
4
|
+
}>, import("effect/Cause").YieldableError & {
|
|
5
|
+
readonly brand: unique symbol;
|
|
6
|
+
}>;
|
|
7
|
+
declare class CacheRootError extends CacheRootError_base {}
|
|
8
|
+
declare const CACHE_DIRECTORY_NAME = ".cache";
|
|
9
|
+
declare const cacheRootEffect: (segments: readonly string[]) => Effect.Effect<string, CacheRootError>;
|
|
10
|
+
export { CacheRootError as n, cacheRootEffect as r, CACHE_DIRECTORY_NAME as t };
|
package/dist/cache.d.mts
ADDED
package/dist/cache.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as CACHE_DIRECTORY_NAME, n as CacheRootError, r as cacheRootEffect } from "./cache-B2pb5ulh.mjs";
|
|
@@ -3,7 +3,6 @@ import { Cause, Effect, Option } from "effect";
|
|
|
3
3
|
import { Atom, AtomRegistry } from "effect/reactivity";
|
|
4
4
|
import { c as Opened, m as Source, n as settledAs, o as Media, r as ApiFailed, t as settled } from "../index-B9MYxbAp.mjs";
|
|
5
5
|
import { ReactNode, SubmitEvent } from "react";
|
|
6
|
-
import { t as SITE_NAMES } from "../index-Cz3K0tg_.mjs";
|
|
7
6
|
import { KeyValueStore } from "effect/persistence";
|
|
8
7
|
/** @internal */
|
|
9
8
|
export declare const openedAtom: Atom.Writable<Option.Option<{
|
|
@@ -40,10 +39,6 @@ export declare const CopyMcpCommand: ({ name }: Readonly<{
|
|
|
40
39
|
export declare const linkAtom: Atom.Writable<string, string>;
|
|
41
40
|
/** @internal */
|
|
42
41
|
export declare const openLinkAtom: Atom.AtomResultFn<string, void, ApiFailed>;
|
|
43
|
-
/** @internal */
|
|
44
|
-
export declare const openFileAtom: Atom.AtomResultFn<string, void, ApiFailed>;
|
|
45
|
-
/** @internal */
|
|
46
|
-
export declare const chooseFileAtom: Atom.AtomResultFn<void, void, ApiFailed>;
|
|
47
42
|
export declare const OpenBar: ({ files, label }: Readonly<{
|
|
48
43
|
files: boolean;
|
|
49
44
|
label: string;
|
|
@@ -59,7 +54,6 @@ type Player = Readonly<{
|
|
|
59
54
|
}>;
|
|
60
55
|
export declare const usePlayer: () => Option.Option<Player>;
|
|
61
56
|
export declare const usePosition: () => Position;
|
|
62
|
-
export declare const usePlayKey: (player: Option.Option<Player>) => void;
|
|
63
57
|
type Hint = Readonly<{
|
|
64
58
|
key: string;
|
|
65
59
|
meaning: string;
|
|
@@ -97,9 +91,7 @@ export declare const Timeline: ({ position, spans, seek }: Readonly<{
|
|
|
97
91
|
spans: readonly Span[];
|
|
98
92
|
seek: (seconds: number) => void;
|
|
99
93
|
}>) => ReactNode;
|
|
100
|
-
export declare const useRangeKey: (player: Option.Option<Player>) => void;
|
|
101
94
|
export declare const clock: (seconds: number) => string;
|
|
102
|
-
export declare const preciseClock: (seconds: number) => string;
|
|
103
95
|
export declare const ignoredKey: (event: KeyboardEvent) => boolean;
|
|
104
96
|
/** @internal */
|
|
105
97
|
export declare const runtime: Atom.AtomRuntime<KeyValueStore.KeyValueStore, never>;
|
|
@@ -122,4 +114,4 @@ type Following = Readonly<{
|
|
|
122
114
|
refresh: () => void;
|
|
123
115
|
}>;
|
|
124
116
|
export declare const useFollowing: ({ event, refresh }: Following) => void;
|
|
125
|
-
export { ApiFailed, type Hint, type Player, type Position, type Range,
|
|
117
|
+
export { ApiFailed, type Hint, type Player, type Position, type Range, type Span, type Tone, settled, settledAs };
|
|
@@ -866,6 +866,6 @@ const useFollowing = ({ event, refresh }) => {
|
|
|
866
866
|
};
|
|
867
867
|
}, [event, refresh]);
|
|
868
868
|
};
|
|
869
|
-
export { ApiFailed, CopyMcpCommand, KeyHints, MediaMeta, MediaPlayer, MediaStage, OpenBar, RangeReadout,
|
|
869
|
+
export { ApiFailed, CopyMcpCommand, KeyHints, MediaMeta, MediaPlayer, MediaStage, OpenBar, RangeReadout, Timeline, anchorAtom, clock, ignoredKey, keyOf, linkAtom, openLinkAtom, openedAtom, pageOf, perMedia, rangeAtom, runtime, savedRange, settled, settledAs, useFollowing, useJump, usePlayer, usePosition, useSubmit };
|
|
870
870
|
|
|
871
871
|
//# sourceMappingURL=media-notes.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Array, Config, DateTime, Effect, FileSystem, Option, Path, Record, Schema, String, pipe } from "effect";
|
|
2
2
|
import { Argument, Command } from "effect/cli";
|
|
3
3
|
import { t as runMain } from "../run-main-CfugYs_u.mjs";
|
|
4
|
-
import { a as
|
|
4
|
+
import { a as outputOf, i as mustSucceed, o as succeeds } from "../process-DTCkAoL_.mjs";
|
|
5
5
|
// src/features/publish-updates/model/manifest.ts
|
|
6
6
|
const Manifest$1 = Schema.fromJsonString(Schema.Struct({
|
|
7
7
|
name: Schema.String,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Duration, Effect,
|
|
1
|
+
import { Duration, Effect, Schedule, Schema } from "effect";
|
|
2
2
|
// src/entities/endpoint/model/endpoint.ts
|
|
3
3
|
const ENDPOINT_FILE = "endpoint.json";
|
|
4
4
|
const HOST = "127.0.0.1";
|
|
@@ -12,9 +12,6 @@ const ServerEndpointJson = Schema.fromJsonString(ServerEndpoint);
|
|
|
12
12
|
const decodeEndpoint = Schema.decodeUnknownEffect(ServerEndpointJson);
|
|
13
13
|
const urlOf = ({ port, token }) => `ws://${HOST}:${port.toString()}/?${TOKEN_PARAMETER}=${encodeURIComponent(token)}`;
|
|
14
14
|
const awaitEndpoint = (read) => read.pipe(Effect.flatMap(decodeEndpoint), Effect.map(urlOf), Effect.retry({ schedule: Schedule.spaced(READ_INTERVAL) }), Effect.orDie);
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
const portOf = Match.type().pipe(Match.tag("UnixPathAddress", () => Option.none()), Match.orElse(({ port }) => Option.some(port)));
|
|
18
|
-
export { TOKEN_PARAMETER as a, ServerEndpoint as i, ENDPOINT_FILE as n, awaitEndpoint as o, HOST as r, portOf as t };
|
|
15
|
+
export { awaitEndpoint as a, TOKEN_PARAMETER as i, HOST as n, ServerEndpoint as r, ENDPOINT_FILE as t };
|
|
19
16
|
|
|
20
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=endpoint-BZzLgZs1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-BZzLgZs1.mjs","names":[],"sources":["../src/entities/endpoint/model/endpoint.ts"],"sourcesContent":["import { Duration, Effect, Schedule, Schema } from \"effect\";\n\nexport const ENDPOINT_FILE = \"endpoint.json\";\nexport const HOST = \"127.0.0.1\";\nexport const TOKEN_PARAMETER = \"token\";\nconst READ_INTERVAL = Duration.fromInputUnsafe(\"1 second\");\n\nexport const ServerEndpoint = Schema.Struct({ port: Schema.Int, token: Schema.String }).annotate({\n identifier: \"ServerEndpoint\",\n});\n\nconst ServerEndpointJson = Schema.fromJsonString(ServerEndpoint);\n\nconst decodeEndpoint = Schema.decodeUnknownEffect(ServerEndpointJson);\n\nconst urlOf = ({ port, token }: typeof ServerEndpoint.Type): string =>\n `ws://${HOST}:${port.toString()}/?${TOKEN_PARAMETER}=${encodeURIComponent(token)}`;\n\nexport const awaitEndpoint = <Failure>(\n read: Effect.Effect<string, Failure>,\n): Effect.Effect<string> =>\n read.pipe(\n Effect.flatMap(decodeEndpoint),\n Effect.map(urlOf),\n Effect.retry({ schedule: Schedule.spaced(READ_INTERVAL) }),\n Effect.orDie,\n );\n"],"mappings":";;AAEA,MAAa,gBAAgB;AAC7B,MAAa,OAAO;AACpB,MAAa,kBAAkB;AAC/B,MAAM,gBAAgB,SAAS,gBAAgB,UAAU;AAEzD,MAAa,iBAAiB,OAAO,OAAO;CAAE,MAAM,OAAO;CAAK,OAAO,OAAO;AAAO,CAAC,CAAC,CAAC,SAAS,EAC/F,YAAY,iBACd,CAAC;AAED,MAAM,qBAAqB,OAAO,eAAe,cAAc;AAE/D,MAAM,iBAAiB,OAAO,oBAAoB,kBAAkB;AAEpE,MAAM,SAAS,EAAE,MAAM,YACrB,QAAQ,KAAK,GAAG,KAAK,SAAS,EAAE,IAAI,gBAAgB,GAAG,mBAAmB,KAAK;AAEjF,MAAa,iBACX,SAEA,KAAK,KACH,OAAO,QAAQ,cAAc,GAC7B,OAAO,IAAI,KAAK,GAChB,OAAO,MAAM,EAAE,UAAU,SAAS,OAAO,aAAa,EAAE,CAAC,GACzD,OAAO,KACT"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Config, Effect, FileSystem, PlatformError, Schema } from "effect";
|
|
2
2
|
import { HttpBody, HttpClient, HttpClientError } from "effect/http";
|
|
3
|
-
import {
|
|
3
|
+
import { c as outputOf, i as CommandFailed, l as succeeds, o as finished, r as Command, s as mustSucceed } from "./process-z7u_XWgI.mjs";
|
|
4
4
|
/** @internal */
|
|
5
5
|
type Failure = Config.ConfigError | HttpBody.HttpBodyError | HttpClientError.HttpClientError;
|
|
6
6
|
/** @internal */
|
|
7
7
|
type Sent<Success> = Effect.Effect<Success, Failure, HttpClient.HttpClient>;
|
|
8
8
|
declare const getJsonOf: <Codec extends Schema.Constraint>(schema: Codec) => (path: string) => Effect.Effect<Codec["Type"], Failure | Schema.SchemaError, HttpClient.HttpClient | Codec["DecodingServices"]>;
|
|
9
9
|
declare const postJsonOf: <Codec extends Schema.Constraint>(schema: Codec) => ({ path, body }: Write) => Effect.Effect<Codec["Type"], Failure | Schema.SchemaError, HttpClient.HttpClient | Codec["DecodingServices"]>;
|
|
10
|
-
declare const removeAt: (path: string) => Sent<void>;
|
|
11
10
|
/** @internal */
|
|
12
11
|
interface Write {
|
|
13
12
|
readonly path: string;
|
|
@@ -18,8 +17,6 @@ declare const patchAt: ({ path, body }: Write) => Sent<void>;
|
|
|
18
17
|
/** @internal */
|
|
19
18
|
export declare const getJson: typeof getJsonOf;
|
|
20
19
|
/** @internal */
|
|
21
|
-
export declare const remove: typeof removeAt;
|
|
22
|
-
/** @internal */
|
|
23
20
|
export declare const post: typeof postTo;
|
|
24
21
|
/** @internal */
|
|
25
22
|
export declare const patch: typeof patchAt;
|
package/dist/github-workflow.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array, Config, Console, Effect, FileSystem, Record, Redacted, Schema, pipe } from "effect";
|
|
2
2
|
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
3
|
-
import { a as
|
|
3
|
+
import { a as outputOf, i as mustSucceed, o as succeeds, r as finished, t as CommandFailed } from "./process-DTCkAoL_.mjs";
|
|
4
4
|
import { Hex } from "effect/encoding";
|
|
5
5
|
// src/shared/api/github/github.ts
|
|
6
6
|
const API = "https://api.github.com";
|
|
@@ -25,14 +25,11 @@ const withBody = Effect.fn("withBody")(function* withBody(method, path, body) {
|
|
|
25
25
|
});
|
|
26
26
|
const getJsonOf = (schema) => (path) => requestTo("GET", path).pipe(Effect.flatMap(execute), Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)));
|
|
27
27
|
const postJsonOf = (schema) => ({ path, body }) => withBody("POST", path, body).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)));
|
|
28
|
-
const removeAt = (path) => requestTo("DELETE", path).pipe(Effect.flatMap(execute), Effect.asVoid);
|
|
29
28
|
const postTo = ({ path, body }) => withBody("POST", path, body).pipe(Effect.asVoid);
|
|
30
29
|
const patchAt = ({ path, body }) => withBody("PATCH", path, body).pipe(Effect.asVoid);
|
|
31
30
|
/** @internal */
|
|
32
31
|
const getJson = getJsonOf;
|
|
33
32
|
/** @internal */
|
|
34
|
-
const remove = removeAt;
|
|
35
|
-
/** @internal */
|
|
36
33
|
const post = postTo;
|
|
37
34
|
/** @internal */
|
|
38
35
|
const patch = patchAt;
|
|
@@ -61,6 +58,6 @@ const fail = Effect.fn("fail")(function* fail(message) {
|
|
|
61
58
|
});
|
|
62
59
|
// src/shared/lib/digest.ts
|
|
63
60
|
const sha256Of = (parts) => Effect.promise(() => new Blob(pipe(parts, Array.map((part) => new Uint8Array(part)))).arrayBuffer()).pipe(Effect.flatMap((bytes) => Effect.promise(() => crypto.subtle.digest("SHA-256", bytes))), Effect.map((digest) => Hex.encode(new Uint8Array(digest))));
|
|
64
|
-
export { CommandFailed, WorkflowFailed, fail, finished, getJson, mask, mustSucceed, outputOf, patch, post, postJson,
|
|
61
|
+
export { CommandFailed, WorkflowFailed, fail, finished, getJson, mask, mustSucceed, outputOf, patch, post, postJson, setEnv, sha256Of, succeeds, warn, writeOutputs };
|
|
65
62
|
|
|
66
63
|
//# sourceMappingURL=github-workflow.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-workflow.mjs","names":["Rec","Arr","Arr"],"sources":["../src/shared/api/github/github.ts","../src/shared/lib/workflow.ts","../src/shared/lib/digest.ts"],"sourcesContent":["import { Config, Effect, Redacted } from \"effect\";\nimport type { Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\nimport type { HttpBody, HttpClientError, HttpMethod } from \"effect/http\";\n\nconst API = \"https://api.github.com\";\nconst HEADERS = {\n accept: \"application/vnd.github+json\",\n \"user-agent\": \"@r_masseater/masseater-utils/github-workflow\",\n \"x-github-api-version\": \"2022-11-28\",\n};\n\n/** @internal */\nexport type Failure = Config.ConfigError | HttpBody.HttpBodyError | HttpClientError.HttpClientError;\n\n/** @internal */\nexport type Sent<Success> = Effect.Effect<Success, Failure, HttpClient.HttpClient>;\n\nconst requestTo = Effect.fn(\"requestTo\")(function* requestTo(\n method: HttpMethod.HttpMethod,\n path: string,\n) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const token = yield* Config.Redacted(\"GH_TOKEN\").pipe(\n Config.orElse(() => Config.Redacted(\"GITHUB_TOKEN\")),\n );\n return HttpClientRequest.make(method)(`${API}/repos/${repository}/${path}`).pipe(\n HttpClientRequest.bearerToken(Redacted.value(token)),\n HttpClientRequest.setHeaders(HEADERS),\n );\n});\n\nconst execute = Effect.fn(\"execute\")(function* execute(\n request: HttpClientRequest.HttpClientRequest,\n) {\n const client = yield* HttpClient.HttpClient;\n const response = yield* client.execute(request);\n return yield* HttpClientResponse.filterStatusOk(response);\n});\n\nconst withBody = Effect.fn(\"withBody\")(function* withBody(\n method: HttpMethod.HttpMethod.WithBody,\n path: string,\n body: unknown,\n) {\n const request = yield* requestTo(method, path);\n const filled = yield* HttpClientRequest.bodyJson(request, body);\n return yield* execute(filled);\n});\n\nconst getJsonOf =\n <Codec extends Schema.Constraint>(schema: Codec) =>\n (\n path: string,\n ): Effect.Effect<\n Codec[\"Type\"],\n Failure | Schema.SchemaError,\n HttpClient.HttpClient | Codec[\"DecodingServices\"]\n > =>\n requestTo(\"GET\", path).pipe(\n Effect.flatMap(execute),\n Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)),\n );\n\nconst postJsonOf =\n <Codec extends Schema.Constraint>(schema: Codec) =>\n ({\n path,\n body,\n }: Write): Effect.Effect<\n Codec[\"Type\"],\n Failure | Schema.SchemaError,\n HttpClient.HttpClient | Codec[\"DecodingServices\"]\n > =>\n withBody(\"POST\", path, body).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)));\n\
|
|
1
|
+
{"version":3,"file":"github-workflow.mjs","names":["Rec","Arr","Arr"],"sources":["../src/shared/api/github/github.ts","../src/shared/lib/workflow.ts","../src/shared/lib/digest.ts"],"sourcesContent":["import { Config, Effect, Redacted } from \"effect\";\nimport type { Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\nimport type { HttpBody, HttpClientError, HttpMethod } from \"effect/http\";\n\nconst API = \"https://api.github.com\";\nconst HEADERS = {\n accept: \"application/vnd.github+json\",\n \"user-agent\": \"@r_masseater/masseater-utils/github-workflow\",\n \"x-github-api-version\": \"2022-11-28\",\n};\n\n/** @internal */\nexport type Failure = Config.ConfigError | HttpBody.HttpBodyError | HttpClientError.HttpClientError;\n\n/** @internal */\nexport type Sent<Success> = Effect.Effect<Success, Failure, HttpClient.HttpClient>;\n\nconst requestTo = Effect.fn(\"requestTo\")(function* requestTo(\n method: HttpMethod.HttpMethod,\n path: string,\n) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const token = yield* Config.Redacted(\"GH_TOKEN\").pipe(\n Config.orElse(() => Config.Redacted(\"GITHUB_TOKEN\")),\n );\n return HttpClientRequest.make(method)(`${API}/repos/${repository}/${path}`).pipe(\n HttpClientRequest.bearerToken(Redacted.value(token)),\n HttpClientRequest.setHeaders(HEADERS),\n );\n});\n\nconst execute = Effect.fn(\"execute\")(function* execute(\n request: HttpClientRequest.HttpClientRequest,\n) {\n const client = yield* HttpClient.HttpClient;\n const response = yield* client.execute(request);\n return yield* HttpClientResponse.filterStatusOk(response);\n});\n\nconst withBody = Effect.fn(\"withBody\")(function* withBody(\n method: HttpMethod.HttpMethod.WithBody,\n path: string,\n body: unknown,\n) {\n const request = yield* requestTo(method, path);\n const filled = yield* HttpClientRequest.bodyJson(request, body);\n return yield* execute(filled);\n});\n\nconst getJsonOf =\n <Codec extends Schema.Constraint>(schema: Codec) =>\n (\n path: string,\n ): Effect.Effect<\n Codec[\"Type\"],\n Failure | Schema.SchemaError,\n HttpClient.HttpClient | Codec[\"DecodingServices\"]\n > =>\n requestTo(\"GET\", path).pipe(\n Effect.flatMap(execute),\n Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)),\n );\n\nconst postJsonOf =\n <Codec extends Schema.Constraint>(schema: Codec) =>\n ({\n path,\n body,\n }: Write): Effect.Effect<\n Codec[\"Type\"],\n Failure | Schema.SchemaError,\n HttpClient.HttpClient | Codec[\"DecodingServices\"]\n > =>\n withBody(\"POST\", path, body).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)));\n\n/** @internal */\nexport interface Write {\n readonly path: string;\n readonly body: unknown;\n}\n\nconst postTo = ({ path, body }: Write): Sent<void> =>\n withBody(\"POST\", path, body).pipe(Effect.asVoid);\n\nconst patchAt = ({ path, body }: Write): Sent<void> =>\n withBody(\"PATCH\", path, body).pipe(Effect.asVoid);\n\n/** @internal */\nexport const getJson = getJsonOf;\n\n/** @internal */\nexport const post = postTo;\n\n/** @internal */\nexport const patch = patchAt;\n\n/** @internal */\nexport const postJson = postJsonOf;\n","import {\n Array as Arr,\n Config,\n Console,\n Effect,\n FileSystem,\n Record as Rec,\n Schema,\n pipe,\n} from \"effect\";\nimport type { PlatformError } from \"effect\";\n\n/** @internal */\nexport type Appended = Effect.Effect<\n void,\n Config.ConfigError | PlatformError.PlatformError,\n FileSystem.FileSystem\n>;\n\nconst taggedError = Schema.TaggedError;\n\nexport class WorkflowFailed extends taggedError<\n WorkflowFailed,\n { readonly brand: unique symbol }\n>()(\"WorkflowFailed\", { message: Schema.String }) {}\n\nconst appendTo = (variable: string, entries: Readonly<Record<string, string>>): Appended =>\n Effect.gen(function* appended() {\n const path = yield* Config.String(variable);\n const fs = yield* FileSystem.FileSystem;\n const lines = pipe(\n Rec.toEntries(entries),\n Arr.map(([name, value]) => `${name}=${value}\\n`),\n Arr.join(\"\"),\n );\n yield* fs.writeFileString(path, lines, { flag: \"a\" });\n });\n\nconst outputsOf = (outputs: Readonly<Record<string, string>>): Appended =>\n appendTo(\"GITHUB_OUTPUT\", outputs);\n\nconst envOf = (variables: Readonly<Record<string, string>>): Appended =>\n appendTo(\"GITHUB_ENV\", variables);\n\n/** @internal */\nexport const writeOutputs = outputsOf;\n\n/** @internal */\nexport const setEnv = envOf;\n\nexport const warn = (message: string): Effect.Effect<void> => Console.log(`::warning::${message}`);\n\nexport const mask = (value: string): Effect.Effect<void> => Console.log(`::add-mask::${value}`);\n\nexport const fail = Effect.fn(\"fail\")(function* fail(message: string) {\n yield* Console.log(`::error::${message}`);\n return yield* WorkflowFailed.make({ message });\n});\n","import { Array as Arr, Effect, pipe } from \"effect\";\nimport { Hex } from \"effect/encoding\";\n\nexport const sha256Of = (parts: readonly Uint8Array[]): Effect.Effect<string> =>\n Effect.promise(() =>\n new Blob(\n pipe(\n parts,\n Arr.map((part) => new Uint8Array(part)),\n ),\n ).arrayBuffer(),\n ).pipe(\n Effect.flatMap((bytes) => Effect.promise(() => crypto.subtle.digest(\"SHA-256\", bytes))),\n Effect.map((digest) => Hex.encode(new Uint8Array(digest))),\n );\n"],"mappings":";;;;;AAKA,MAAM,MAAM;AACZ,MAAM,UAAU;CACd,QAAQ;CACR,cAAc;CACd,wBAAwB;AAC1B;AAQA,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC,CAAC,UAAU,UACjD,QACA,MACA;CACA,MAAM,aAAa,OAAO,OAAO,OAAO,mBAAmB;CAC3D,MAAM,QAAQ,OAAO,OAAO,SAAS,UAAU,CAAC,CAAC,KAC/C,OAAO,aAAa,OAAO,SAAS,cAAc,CAAC,CACrD;CACA,OAAO,kBAAkB,KAAK,MAAM,CAAC,CAAC,GAAG,IAAI,SAAS,WAAW,GAAG,MAAM,CAAC,CAAC,KAC1E,kBAAkB,YAAY,SAAS,MAAM,KAAK,CAAC,GACnD,kBAAkB,WAAW,OAAO,CACtC;AACF,CAAC;AAED,MAAM,UAAU,OAAO,GAAG,SAAS,CAAC,CAAC,UAAU,QAC7C,SACA;CAEA,MAAM,WAAW,QAAO,OADF,WAAW,WAAA,CACF,QAAQ,OAAO;CAC9C,OAAO,OAAO,mBAAmB,eAAe,QAAQ;AAC1D,CAAC;AAED,MAAM,WAAW,OAAO,GAAG,UAAU,CAAC,CAAC,UAAU,SAC/C,QACA,MACA,MACA;CACA,MAAM,UAAU,OAAO,UAAU,QAAQ,IAAI;CAC7C,MAAM,SAAS,OAAO,kBAAkB,SAAS,SAAS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,IAAI,cAAc,SAAS;AAEjG,MAAa,QAAQ,UAAuC,QAAQ,IAAI,eAAe,OAAO;AAE9F,MAAa,OAAO,OAAO,GAAG,MAAM,CAAC,CAAC,UAAU,KAAK,SAAiB;CACpE,OAAO,QAAQ,IAAI,YAAY,SAAS;CACxC,OAAO,OAAO,eAAe,KAAK,EAAE,QAAQ,CAAC;AAC/C,CAAC;;ACtDD,MAAa,YAAY,UACvB,OAAO,cACL,IAAI,KACF,KACE,OACAC,MAAI,KAAK,SAAS,IAAI,WAAW,IAAI,CAAC,CACxC,CACF,CAAC,CAAC,YAAY,CAChB,CAAC,CAAC,KACA,OAAO,SAAS,UAAU,OAAO,cAAc,OAAO,OAAO,OAAO,WAAW,KAAK,CAAC,CAAC,GACtF,OAAO,KAAK,WAAW,IAAI,OAAO,IAAI,WAAW,MAAM,CAAC,CAAC,CAC3D"}
|
|
@@ -41,7 +41,7 @@ const SERVER_RESPONSE_HEADERS = {
|
|
|
41
41
|
const workerDirective = (worker) => Option.fromNullishOr(worker).pipe(Option.map((sources) => pipe(["worker-src 'self'", ...sources], Array.join(" "))), Array.fromOption);
|
|
42
42
|
const frameDirective = (frame) => Option.fromNullishOr(frame).pipe(Option.map((sources) => pipe(["frame-src", ...sources], Array.join(" "))), Array.fromOption);
|
|
43
43
|
const fontDirective = (font) => Option.fromNullishOr(font).pipe(Option.map((sources) => pipe(["font-src 'self'", ...sources], Array.join(" "))), Array.fromOption);
|
|
44
|
-
const contentSecurityPolicy = ({ script, style, worker, font, frame, image = [], styleAttr = false, report = false }) => pipe([
|
|
44
|
+
const contentSecurityPolicy = ({ script, style, worker, font, frame, image = [], connect = [], styleAttr = false, report = false }) => pipe([
|
|
45
45
|
"default-src 'self'",
|
|
46
46
|
pipe([
|
|
47
47
|
"script-src 'self'",
|
|
@@ -54,7 +54,11 @@ const contentSecurityPolicy = ({ script, style, worker, font, frame, image = [],
|
|
|
54
54
|
...fontDirective(font),
|
|
55
55
|
...frameDirective(frame),
|
|
56
56
|
pipe(["img-src 'self' data:", ...image], Array.join(" ")),
|
|
57
|
-
|
|
57
|
+
pipe([
|
|
58
|
+
"connect-src 'self'",
|
|
59
|
+
WEB_ANALYTICS_REPORT_ORIGIN,
|
|
60
|
+
...connect
|
|
61
|
+
], Array.join(" ")),
|
|
58
62
|
OBJECT_SOURCE_NONE,
|
|
59
63
|
BASE_URI_NONE,
|
|
60
64
|
"form-action 'self'",
|
|
@@ -85,7 +89,7 @@ const speculationOf = (url) => Option.match(Option.fromNullishOr(url), {
|
|
|
85
89
|
onNone: () => ({}),
|
|
86
90
|
onSome: (rules) => ({ "Speculation-Rules": `"${rules}"` })
|
|
87
91
|
});
|
|
88
|
-
const serverPageHeaders = ({ image = [], script = [], frame, font, report, speculationRules }) => ({
|
|
92
|
+
const serverPageHeaders = ({ image = [], script = [], connect = [], frame, font, report, speculationRules }) => ({
|
|
89
93
|
...isolationOf(frame),
|
|
90
94
|
...reportingOf(report),
|
|
91
95
|
...speculationOf(speculationRules),
|
|
@@ -93,6 +97,7 @@ const serverPageHeaders = ({ image = [], script = [], frame, font, report, specu
|
|
|
93
97
|
script,
|
|
94
98
|
style: [],
|
|
95
99
|
image: ["blob:", ...image],
|
|
100
|
+
connect,
|
|
96
101
|
styleAttr: true,
|
|
97
102
|
report: Option.isSome(Option.fromNullishOr(report)),
|
|
98
103
|
...Record.getSomes({
|
|
@@ -101,7 +106,6 @@ const serverPageHeaders = ({ image = [], script = [], frame, font, report, specu
|
|
|
101
106
|
})
|
|
102
107
|
})
|
|
103
108
|
});
|
|
104
|
-
const SERVER_PAGE_HEADERS = serverPageHeaders({});
|
|
105
109
|
const EMBEDDED_VIDEO_SOURCES = {
|
|
106
110
|
image: ["https://i.ytimg.com", "https://nicovideo.cdn.nimg.jp"],
|
|
107
111
|
frame: ["https://embed.nicovideo.jp", "https://www.youtube-nocookie.com"],
|
|
@@ -115,6 +119,6 @@ const assetHeaders = ({ page, base = "" }) => pipe([
|
|
|
115
119
|
` Cache-Control: ${ASSET_CACHE_CONTROL}`,
|
|
116
120
|
""
|
|
117
121
|
], Array.join("\n"));
|
|
118
|
-
export {
|
|
122
|
+
export { SERVER_RESPONSE_HEADERS as a, assetHeaders as c, SECURITY_HEADERS_CREDENTIALLESS as i, contentSecurityPolicy as l, EMBEDDED_VIDEO_SOURCES as n, SPECULATION_RULES_FILE as o, SECURITY_HEADERS as r, STATIC_PAGE_HEADERS as s, ASSET_CACHE_CONTROL as t, serverPageHeaders as u };
|
|
119
123
|
|
|
120
|
-
//# sourceMappingURL=headers-
|
|
124
|
+
//# sourceMappingURL=headers-DSqz93yF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers-DSqz93yF.mjs","names":["Arr","Rec"],"sources":["../src/entities/policy/model/headers.ts"],"sourcesContent":["import { Array as Arr, Option, Record as Rec, pipe } from \"effect\";\n\nimport { WEB_ANALYTICS_REPORT_ORIGIN, WEB_ANALYTICS_SCRIPT_ORIGIN } from \"#/shared/config/index.ts\";\n\nconst SECURITY_HEADERS_BASE = {\n \"Strict-Transport-Security\": \"max-age=31536000; includeSubDomains\",\n \"X-Content-Type-Options\": \"nosniff\",\n \"X-Frame-Options\": \"DENY\",\n \"Referrer-Policy\": \"strict-origin-when-cross-origin\",\n \"Permissions-Policy\": \"camera=(), geolocation=(), microphone=(), payment=(), usb=()\",\n} as const;\n\nexport const SECURITY_HEADERS = {\n ...SECURITY_HEADERS_BASE,\n \"Cross-Origin-Opener-Policy\": \"same-origin\",\n \"Cross-Origin-Embedder-Policy\": \"require-corp\",\n \"Cross-Origin-Resource-Policy\": \"same-origin\",\n} as const;\n\nexport const SECURITY_HEADERS_CREDENTIALLESS = {\n ...SECURITY_HEADERS,\n \"Cross-Origin-Embedder-Policy\": \"credentialless\",\n} as const;\n\nconst SECURITY_HEADERS_EMBEDDING = {\n ...SECURITY_HEADERS_BASE,\n \"Cross-Origin-Opener-Policy\": \"same-origin\",\n \"Cross-Origin-Resource-Policy\": \"same-origin\",\n} as const;\n\nexport const ASSET_CACHE_CONTROL = \"public, max-age=31536000, immutable\";\n\nconst OBJECT_SOURCE_NONE = \"object-src 'none'\";\n\nconst BASE_URI_NONE = \"base-uri 'none'\";\n\nconst FRAME_ANCESTORS_NONE = \"frame-ancestors 'none'\";\n\nconst REPORT_ENDPOINT = \"default\";\n\nconst REPORT_TO = `report-to ${REPORT_ENDPOINT}`;\n\nconst REPORT_MAX_AGE = 2_592_000;\n\nexport const SERVER_RESPONSE_HEADERS = {\n ...SECURITY_HEADERS_BASE,\n \"Content-Security-Policy\": pipe(\n [FRAME_ANCESTORS_NONE, BASE_URI_NONE, OBJECT_SOURCE_NONE],\n Arr.join(\"; \"),\n ),\n} as const;\n\nconst workerDirective = (worker: readonly string[] | undefined): readonly string[] =>\n Option.fromNullishOr(worker).pipe(\n Option.map((sources) => pipe([\"worker-src 'self'\", ...sources], Arr.join(\" \"))),\n Arr.fromOption,\n );\n\nconst frameDirective = (frame: readonly string[] | undefined): readonly string[] =>\n Option.fromNullishOr(frame).pipe(\n Option.map((sources) => pipe([\"frame-src\", ...sources], Arr.join(\" \"))),\n Arr.fromOption,\n );\n\nconst fontDirective = (font: readonly string[] | undefined): readonly string[] =>\n Option.fromNullishOr(font).pipe(\n Option.map((sources) => pipe([\"font-src 'self'\", ...sources], Arr.join(\" \"))),\n Arr.fromOption,\n );\n\nexport const contentSecurityPolicy = ({\n script,\n style,\n worker,\n font,\n frame,\n image = [],\n connect = [],\n styleAttr = false,\n report = false,\n}: Readonly<{\n script: readonly string[];\n style: readonly string[];\n worker?: readonly string[];\n font?: readonly string[];\n frame?: readonly string[];\n image?: readonly string[];\n connect?: readonly string[];\n styleAttr?: boolean;\n report?: boolean;\n}>): string =>\n pipe(\n [\n \"default-src 'self'\",\n pipe([\"script-src 'self'\", WEB_ANALYTICS_SCRIPT_ORIGIN, ...script], Arr.join(\" \")),\n pipe([\"style-src 'self'\", ...style], Arr.join(\" \")),\n ...Arr.fromOption(Option.liftPredicate(\"style-src-attr 'unsafe-inline'\", () => styleAttr)),\n ...workerDirective(worker),\n ...fontDirective(font),\n ...frameDirective(frame),\n pipe([\"img-src 'self' data:\", ...image], Arr.join(\" \")),\n pipe([\"connect-src 'self'\", WEB_ANALYTICS_REPORT_ORIGIN, ...connect], Arr.join(\" \")),\n OBJECT_SOURCE_NONE,\n BASE_URI_NONE,\n \"form-action 'self'\",\n FRAME_ANCESTORS_NONE,\n ...Arr.fromOption(Option.liftPredicate(REPORT_TO, () => report)),\n ],\n Arr.join(\"; \"),\n );\n\nexport const STATIC_PAGE_HEADERS = {\n ...SECURITY_HEADERS,\n \"Content-Security-Policy\": contentSecurityPolicy({\n script: [\"'wasm-unsafe-eval'\"],\n style: [],\n worker: [\"blob:\"],\n }),\n} as const;\n\nexport interface PageSources {\n readonly image?: readonly string[];\n readonly frame?: readonly string[];\n readonly script?: readonly string[];\n readonly font?: readonly string[];\n readonly connect?: readonly string[];\n readonly report?: string;\n readonly speculationRules?: string;\n}\n\nconst isolationOf = (frame: readonly string[] | undefined): Readonly<Record<string, string>> =>\n Option.match(Option.fromNullishOr(frame), {\n onNone: () => SECURITY_HEADERS_CREDENTIALLESS,\n onSome: () => SECURITY_HEADERS_EMBEDDING,\n });\n\nconst reportingOf = (report: string | undefined): Readonly<Record<string, string>> =>\n Option.match(Option.fromNullishOr(report), {\n onNone: () => ({}),\n onSome: (url) => ({\n \"Reporting-Endpoints\": `${REPORT_ENDPOINT}=\"${url}\"`,\n \"Report-To\": `{\"group\":\"${REPORT_ENDPOINT}\",\"max_age\":${REPORT_MAX_AGE},\"endpoints\":[{\"url\":\"${url}\"}]}`,\n NEL: `{\"report_to\":\"${REPORT_ENDPOINT}\",\"max_age\":${REPORT_MAX_AGE}}`,\n }),\n });\n\nconst speculationOf = (url: string | undefined): Readonly<Record<string, string>> =>\n Option.match(Option.fromNullishOr(url), {\n onNone: () => ({}),\n onSome: (rules) => ({ \"Speculation-Rules\": `\"${rules}\"` }),\n });\n\nexport const serverPageHeaders = ({\n image = [],\n script = [],\n connect = [],\n frame,\n font,\n report,\n speculationRules,\n}: PageSources): Readonly<Record<string, string>> => ({\n ...isolationOf(frame),\n ...reportingOf(report),\n ...speculationOf(speculationRules),\n \"Content-Security-Policy\": contentSecurityPolicy({\n script,\n style: [],\n image: [\"blob:\", ...image],\n connect,\n styleAttr: true,\n report: Option.isSome(Option.fromNullishOr(report)),\n ...Rec.getSomes({ frame: Option.fromNullishOr(frame), font: Option.fromNullishOr(font) }),\n }),\n});\n\nexport const EMBEDDED_VIDEO_SOURCES = {\n image: [\"https://i.ytimg.com\", \"https://nicovideo.cdn.nimg.jp\"],\n frame: [\"https://embed.nicovideo.jp\", \"https://www.youtube-nocookie.com\"],\n font: [\"data:\"],\n} as const satisfies PageSources;\n\nexport const SPECULATION_RULES_FILE = \"_speculation-rules\";\n\nexport const assetHeaders = ({\n page,\n base = \"\",\n}: Readonly<{ page: Readonly<Record<string, string>>; base?: string }>): string =>\n pipe(\n [\n `${base}/*`,\n ...pipe(\n Rec.toEntries(page),\n Arr.map(([name, value]) => ` ${name}: ${value}`),\n ),\n `${base}/assets/*`,\n ` Cache-Control: ${ASSET_CACHE_CONTROL}`,\n \"\",\n ],\n Arr.join(\"\\n\"),\n );\n"],"mappings":";;;AAIA,MAAM,wBAAwB;CAC5B,6BAA6B;CAC7B,0BAA0B;CAC1B,mBAAmB;CACnB,mBAAmB;CACnB,sBAAsB;AACxB;AAEA,MAAa,mBAAmB;CAC9B,GAAG;CACH,8BAA8B;CAC9B,gCAAgC;CAChC,gCAAgC;AAClC;AAEA,MAAa,kCAAkC;CAC7C,GAAG;CACH,gCAAgC;AAClC;AAEA,MAAM,6BAA6B;CACjC,GAAG;CACH,8BAA8B;CAC9B,gCAAgC;AAClC;AAEA,MAAa,sBAAsB;AAEnC,MAAM,qBAAqB;AAE3B,MAAM,gBAAgB;AAEtB,MAAM,uBAAuB;AAE7B,MAAM,kBAAkB;AAExB,MAAM,YAAY,aAAa;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AM,CAAC,OAAO;AAChB;AAEA,MAAa,yBAAyB;AAEtC,MAAa,gBAAgB,EAC3B,MACA,OAAO,SAEP,KACE;CACE,GAAG,KAAK;CACR,GAAG,KACDA,OAAI,UAAU,IAAI,GAClBD,MAAI,KAAK,CAAC,MAAM,WAAW,KAAK,KAAK,IAAI,OAAO,CAClD;CACA,GAAG,KAAK;CACR,oBAAoB;CACpB;AACF,GACAA,MAAI,KAAK,IAAI,CACf"}
|
|
@@ -18,31 +18,14 @@ declare const SECURITY_HEADERS_CREDENTIALLESS: {
|
|
|
18
18
|
readonly "Cross-Origin-Resource-Policy": "same-origin";
|
|
19
19
|
readonly "Cross-Origin-Embedder-Policy": "credentialless";
|
|
20
20
|
};
|
|
21
|
-
declare const
|
|
22
|
-
readonly "Strict-Transport-Security": "max-age=31536000; includeSubDomains";
|
|
23
|
-
readonly "X-Content-Type-Options": "nosniff";
|
|
24
|
-
readonly "X-Frame-Options": "DENY";
|
|
25
|
-
readonly "Referrer-Policy": "strict-origin-when-cross-origin";
|
|
26
|
-
readonly "Permissions-Policy": "camera=(), geolocation=(), microphone=(), payment=(), usb=()";
|
|
27
|
-
readonly "Cross-Origin-Opener-Policy": "same-origin";
|
|
28
|
-
readonly "Cross-Origin-Resource-Policy": "same-origin";
|
|
29
|
-
};
|
|
30
|
-
declare const ASSET_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
31
|
-
declare const SERVER_RESPONSE_HEADERS: {
|
|
32
|
-
readonly "Strict-Transport-Security": "max-age=31536000; includeSubDomains";
|
|
33
|
-
readonly "X-Content-Type-Options": "nosniff";
|
|
34
|
-
readonly "X-Frame-Options": "DENY";
|
|
35
|
-
readonly "Referrer-Policy": "strict-origin-when-cross-origin";
|
|
36
|
-
readonly "Permissions-Policy": "camera=(), geolocation=(), microphone=(), payment=(), usb=()";
|
|
37
|
-
readonly "Content-Security-Policy": string;
|
|
38
|
-
};
|
|
39
|
-
declare const contentSecurityPolicy: ({ script, style, worker, font, frame, image, styleAttr, report }: Readonly<{
|
|
21
|
+
declare const contentSecurityPolicy: ({ script, style, worker, font, frame, image, connect, styleAttr, report }: Readonly<{
|
|
40
22
|
script: readonly string[];
|
|
41
23
|
style: readonly string[];
|
|
42
24
|
worker?: readonly string[];
|
|
43
25
|
font?: readonly string[];
|
|
44
26
|
frame?: readonly string[];
|
|
45
27
|
image?: readonly string[];
|
|
28
|
+
connect?: readonly string[];
|
|
46
29
|
styleAttr?: boolean;
|
|
47
30
|
report?: boolean;
|
|
48
31
|
}>) => string;
|
|
@@ -62,11 +45,11 @@ interface PageSources {
|
|
|
62
45
|
readonly frame?: readonly string[];
|
|
63
46
|
readonly script?: readonly string[];
|
|
64
47
|
readonly font?: readonly string[];
|
|
48
|
+
readonly connect?: readonly string[];
|
|
65
49
|
readonly report?: string;
|
|
66
50
|
readonly speculationRules?: string;
|
|
67
51
|
}
|
|
68
|
-
declare const serverPageHeaders: ({ image, script, frame, font, report, speculationRules }: PageSources) => Readonly<Record<string, string>>;
|
|
69
|
-
declare const SERVER_PAGE_HEADERS: Readonly<Record<string, string>>;
|
|
52
|
+
declare const serverPageHeaders: ({ image, script, connect, frame, font, report, speculationRules }: PageSources) => Readonly<Record<string, string>>;
|
|
70
53
|
declare const EMBEDDED_VIDEO_SOURCES: {
|
|
71
54
|
readonly image: readonly ["https://i.ytimg.com", "https://nicovideo.cdn.nimg.jp"];
|
|
72
55
|
readonly frame: readonly ["https://embed.nicovideo.jp", "https://www.youtube-nocookie.com"];
|
|
@@ -77,4 +60,4 @@ declare const assetHeaders: ({ page, base }: Readonly<{
|
|
|
77
60
|
page: Readonly<Record<string, string>>;
|
|
78
61
|
base?: string;
|
|
79
62
|
}>) => string;
|
|
80
|
-
export {
|
|
63
|
+
export { SPECULATION_RULES_FILE as a, contentSecurityPolicy as c, SECURITY_HEADERS_CREDENTIALLESS as i, serverPageHeaders as l, PageSources as n, STATIC_PAGE_HEADERS as o, SECURITY_HEADERS as r, assetHeaders as s, EMBEDDED_VIDEO_SOURCES as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./index-B9MYxbAp.mjs";
|
|
1
2
|
declare const WEB_ANALYTICS_SCRIPT_ORIGIN = "https://static.cloudflareinsights.com";
|
|
2
3
|
declare const WEB_ANALYTICS_REPORT_ORIGIN = "https://cloudflareinsights.com";
|
|
3
4
|
export { WEB_ANALYTICS_SCRIPT_ORIGIN as n, WEB_ANALYTICS_REPORT_ORIGIN as t };
|
|
@@ -25,6 +25,7 @@ type StaticPageHeadersOptions = Readonly<{
|
|
|
25
25
|
assetsDir: string;
|
|
26
26
|
home?: string;
|
|
27
27
|
scriptSources: Readonly<Record<string, readonly string[]>>;
|
|
28
|
+
connectSources?: readonly string[];
|
|
28
29
|
permissions: Readonly<Record<string, string>>;
|
|
29
30
|
headTags: readonly HtmlTagDescriptor[];
|
|
30
31
|
}>;
|
package/dist/kestrion/npm.d.mts
CHANGED
|
@@ -11,7 +11,6 @@ declare const RawPackageJson: Schema.$Record<Schema.String, Schema.Codec<Schema.
|
|
|
11
11
|
type PackageJsonFields = typeof RawPackageJson.Type;
|
|
12
12
|
export declare const decodePackageJson: (text: string) => Option.Option<PackageJson>;
|
|
13
13
|
export declare const decodeVersionedPackageJson: (text: string) => Option.Option<VersionedPackageJson>;
|
|
14
|
-
export declare const parsePackageJson: (text: string) => Effect.Effect<PackageJson, PackageJsonUnreadable>;
|
|
15
14
|
export declare const readPackageJson: (directory: string) => Effect.Effect<PackageJson, PackageJsonUnreadable>;
|
|
16
15
|
export declare const readVersionedPackageJson: (directory: string) => Effect.Effect<VersionedPackageJson, PackageJsonUnreadable>;
|
|
17
16
|
export declare const readRawPackageJson: (directory: string) => Effect.Effect<PackageJsonFields, PackageJsonUnreadable>;
|
package/dist/kestrion/npm.mjs
CHANGED
|
@@ -8,7 +8,6 @@ var PackageJsonUnreadable = class extends taggedError()("PackageJsonUnreadable",
|
|
|
8
8
|
reason: Schema.String
|
|
9
9
|
}) {};
|
|
10
10
|
// src/features/read-npm/model/package-json.ts
|
|
11
|
-
const TEXT = "<text>";
|
|
12
11
|
const unreadable = (path) => (cause) => PackageJsonUnreadable.make({
|
|
13
12
|
path,
|
|
14
13
|
reason: String(cause)
|
|
@@ -20,10 +19,6 @@ const RawPackageJson = Schema.Record(Schema.String, Schema.Json);
|
|
|
20
19
|
const decodePackageJson = (text) => Option.flatMap(Option.liftThrowable(contentOf)(text), decodeContent);
|
|
21
20
|
const decodeVersionedPackageJson = (text) => Option.flatMap(Option.liftThrowable(contentOf)(text), decodeVersionedContent);
|
|
22
21
|
const decodedAs = (schema, path) => (content) => Schema.decodeUnknownEffect(schema)(content).pipe(Effect.mapError(unreadable(path)));
|
|
23
|
-
const parsePackageJson = (text) => Effect.try({
|
|
24
|
-
try: () => contentOf(text),
|
|
25
|
-
catch: unreadable(TEXT)
|
|
26
|
-
}).pipe(Effect.flatMap(decodedAs(PackageJsonSchema, TEXT)));
|
|
27
22
|
const loaded = (directory) => Effect.tryPromise({
|
|
28
23
|
try: () => NpmPackageJson.load(directory),
|
|
29
24
|
catch: unreadable(directory)
|
|
@@ -49,6 +44,6 @@ const writePackageJson = Effect.fn("writePackageJson")(function* writePackageJso
|
|
|
49
44
|
catch: unreadable(directory)
|
|
50
45
|
});
|
|
51
46
|
});
|
|
52
|
-
export { PackageJsonUnreadable, decodePackageJson, decodeVersionedPackageJson,
|
|
47
|
+
export { PackageJsonUnreadable, decodePackageJson, decodeVersionedPackageJson, readPackageJson, readRawPackageJson, readVersionedPackageJson, updatePackageJson, writePackageJson };
|
|
53
48
|
|
|
54
49
|
//# sourceMappingURL=npm.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npm.mjs","names":[],"sources":["../../src/features/read-npm/model/unreadable.ts","../../src/features/read-npm/model/package-json.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class PackageJsonUnreadable extends taggedError<\n PackageJsonUnreadable,\n { readonly brand: unique symbol }\n>()(\"PackageJsonUnreadable\", { path: Schema.String, reason: Schema.String }) {}\n","import NpmPackageJson from \"@npmcli/package-json\";\nimport { Effect, Option, Schema } from \"effect\";\n\nimport { PackageJsonSchema, VersionedPackageJsonSchema } from \"#/entities/package-json/index.ts\";\nimport type { PackageJson, VersionedPackageJson } from \"#/entities/package-json/index.ts\";\n\nimport { PackageJsonUnreadable } from \"./unreadable.ts\";\n\nconst
|
|
1
|
+
{"version":3,"file":"npm.mjs","names":[],"sources":["../../src/features/read-npm/model/unreadable.ts","../../src/features/read-npm/model/package-json.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class PackageJsonUnreadable extends taggedError<\n PackageJsonUnreadable,\n { readonly brand: unique symbol }\n>()(\"PackageJsonUnreadable\", { path: Schema.String, reason: Schema.String }) {}\n","import NpmPackageJson from \"@npmcli/package-json\";\nimport { Effect, Option, Schema } from \"effect\";\n\nimport { PackageJsonSchema, VersionedPackageJsonSchema } from \"#/entities/package-json/index.ts\";\nimport type { PackageJson, VersionedPackageJson } from \"#/entities/package-json/index.ts\";\n\nimport { PackageJsonUnreadable } from \"./unreadable.ts\";\n\nconst unreadable =\n (path: string) =>\n (cause: unknown): PackageJsonUnreadable =>\n PackageJsonUnreadable.make({ path, reason: String(cause) });\n\nconst contentOf = (text: string): unknown => new NpmPackageJson().fromJSON(text).content;\n\nconst decodeContent = Schema.decodeUnknownOption(PackageJsonSchema);\n\nconst decodeVersionedContent = Schema.decodeUnknownOption(VersionedPackageJsonSchema);\n\nconst RawPackageJson = Schema.Record(Schema.String, Schema.Json);\n\nexport type PackageJsonFields = typeof RawPackageJson.Type;\n\nexport const decodePackageJson = (text: string): Option.Option<PackageJson> =>\n Option.flatMap(Option.liftThrowable(contentOf)(text), decodeContent);\n\nexport const decodeVersionedPackageJson = (text: string): Option.Option<VersionedPackageJson> =>\n Option.flatMap(Option.liftThrowable(contentOf)(text), decodeVersionedContent);\n\nconst decodedAs =\n <Manifest>(schema: Schema.Codec<Manifest>, path: string) =>\n (content: unknown): Effect.Effect<Manifest, PackageJsonUnreadable> =>\n Schema.decodeUnknownEffect(schema)(content).pipe(Effect.mapError(unreadable(path)));\n\nconst loaded = (directory: string): Effect.Effect<NpmPackageJson, PackageJsonUnreadable> =>\n Effect.tryPromise({ try: () => NpmPackageJson.load(directory), catch: unreadable(directory) });\n\nconst readAs =\n <Manifest>(schema: Schema.Codec<Manifest>) =>\n (directory: string): Effect.Effect<Manifest, PackageJsonUnreadable> =>\n loaded(directory).pipe(Effect.flatMap(({ content }) => decodedAs(schema, directory)(content)));\n\nexport const readPackageJson: (\n directory: string,\n) => Effect.Effect<PackageJson, PackageJsonUnreadable> = readAs(PackageJsonSchema);\n\nexport const readVersionedPackageJson: (\n directory: string,\n) => Effect.Effect<VersionedPackageJson, PackageJsonUnreadable> = readAs(\n VersionedPackageJsonSchema,\n);\n\nexport const readRawPackageJson: (\n directory: string,\n) => Effect.Effect<PackageJsonFields, PackageJsonUnreadable> = readAs(RawPackageJson);\n\nexport const updatePackageJson = Effect.fn(\"updatePackageJson\")(function* updatePackageJson(\n directory: string,\n fields: PackageJsonFields,\n) {\n const manifest = yield* loaded(directory);\n yield* Effect.tryPromise({\n try: () => manifest.update({ ...fields }).save(),\n catch: unreadable(directory),\n });\n});\n\nexport const writePackageJson = Effect.fn(\"writePackageJson\")(function* writePackageJson(\n directory: string,\n fields: PackageJsonFields,\n) {\n const created = yield* Effect.tryPromise({\n try: () => NpmPackageJson.create(directory, { data: { ...fields } }),\n catch: unreadable(directory),\n });\n yield* Effect.tryPromise({ try: () => created.save(), catch: unreadable(directory) });\n});\n"],"mappings":";;;;AAEA,MAAM,cAAc,OAAO;AAE3B,IAAa,wBAAb,cAA2C,YAGzC,CAAC,CAAC,yBAAyB;CAAE,MAAM,OAAO;CAAQ,QAAQ,OAAO;AAAO,CAAC,CAAC,CAAC,CAAC;;ACC9E,MAAM,cACH,UACA,UACC,sBAAsB,KAAK;C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A;CACA,MAAM,UAAU,OAAO,OAAO,WAAW;EACvC,WAAW,eAAe,OAAO,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;EACnE,OAAO,WAAW,SAAS;CAC7B,CAAC;CACD,OAAO,OAAO,WAAW;EAAE,WAAW,QAAQ,KAAK;EAAG,OAAO,WAAW,SAAS;CAAE,CAAC;AACtF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Context, Effect, FileSystem, Layer, Option, Path, Redacted, Schema, String, pipe } from "effect";
|
|
1
|
+
import { Context, Effect, FileSystem, Layer, Match, Option, Path, Redacted, Schema, String, pipe } from "effect";
|
|
2
2
|
import { Mac } from "effect/crypto";
|
|
3
3
|
import { Hex } from "effect/encoding";
|
|
4
|
-
import {
|
|
4
|
+
import { i as TOKEN_PARAMETER, n as HOST, r as ServerEndpoint, t as ENDPOINT_FILE } from "../endpoint-BZzLgZs1.mjs";
|
|
5
5
|
import { layerWebSocket } from "@effect/platform-node/NodeSocketServer";
|
|
6
6
|
import { RpcSerialization, RpcServer } from "effect/rpc";
|
|
7
7
|
import { SocketServer } from "effect/socket";
|
|
@@ -23,6 +23,9 @@ const serverTokenLayer = Layer.sync(ServerToken, () => {
|
|
|
23
23
|
presentedBy: ({ req: { url } }) => pipe(Option.fromUndefinedOr(url), Option.flatMap(tokenIn), Option.exists((given) => Mac.timingSafeEqual(encoder.encode(given), expected)))
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
+
// src/shared/lib/socket-port.ts
|
|
27
|
+
/** @internal */
|
|
28
|
+
const portOf = Match.type().pipe(Match.tag("UnixPathAddress", () => Option.none()), Match.orElse(({ port }) => Option.some(port)));
|
|
26
29
|
// src/features/serve-socket/model/endpoint-file-layer.ts
|
|
27
30
|
const OWNER_ONLY = 384;
|
|
28
31
|
const encodeEndpoint = Schema.encodeEffect(Schema.fromJsonString(ServerEndpoint));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.mjs","names":[],"sources":["../../src/entities/endpoint/model/endpoint-directory.ts","../../src/entities/endpoint/model/server-token.ts","../../src/features/serve-socket/model/endpoint-file-layer.ts","../../src/features/serve-socket/model/transport-layer.ts","../../src/shared/lib/sqlite-layer.ts"],"sourcesContent":["import { Context } from \"effect\";\n\nexport class EndpointDirectory extends Context.Service<EndpointDirectory, string>()(\n \"@r_masseater/masseater-utils/entities/endpoint/model/endpoint-directory/EndpointDirectory\",\n) {}\n","import { Context, Layer, Option, Redacted, String, pipe } from \"effect\";\nimport { Mac } from \"effect/crypto\";\nimport { Hex } from \"effect/encoding\";\n\nimport { TOKEN_PARAMETER } from \"#/entities/endpoint/model/endpoint.ts\";\n\nconst TOKEN_BYTES = 32;\nconst QUERY_MARK = \"?\";\n\ninterface Handshake {\n readonly req: { readonly url?: string | undefined };\n}\n\nexport class ServerToken extends Context.Service<\n ServerToken,\n {\n readonly token: Redacted.Redacted;\n readonly presentedBy: (handshake: Handshake) => boolean;\n }\n>()(\"@r_masseater/masseater-utils/entities/endpoint/model/server-token/ServerToken\") {}\n\nconst encoder = new TextEncoder();\n\nconst tokenIn = (target: string): Option.Option<string> =>\n pipe(\n target,\n String.indexOf(QUERY_MARK),\n Option.map((start) => new URLSearchParams(pipe(target, String.slice(start)))),\n Option.flatMapNullishOr((query) => query.get(TOKEN_PARAMETER)),\n );\n\nexport const serverTokenLayer = Layer.sync(ServerToken, () => {\n const token = Hex.encode(crypto.getRandomValues(new Uint8Array(TOKEN_BYTES)));\n const expected = encoder.encode(token);\n return ServerToken.of({\n token: Redacted.make(token),\n presentedBy: ({ req: { url } }) =>\n pipe(\n Option.fromUndefinedOr(url),\n Option.flatMap(tokenIn),\n Option.exists((given) => Mac.timingSafeEqual(encoder.encode(given), expected)),\n ),\n });\n});\n","import { Effect, FileSystem, Layer, Path, Redacted, Schema } from \"effect\";\nimport { SocketServer } from \"effect/socket\";\n\nimport {\n EndpointDirectory,\n ENDPOINT_FILE,\n ServerEndpoint,\n ServerToken,\n} from \"#/entities/endpoint/index.ts\";\nimport { portOf } from \"#/shared/lib/socket-port.ts\";\n\nconst OWNER_ONLY = 0o600;\n\nconst encodeEndpoint = Schema.encodeEffect(Schema.fromJsonString(ServerEndpoint));\n\nconst endpointText = Effect.gen(function* endpointText() {\n const { address } = yield* SocketServer.SocketServer;\n const { token } = yield* ServerToken;\n const port = yield* Effect.fromOption(portOf(address));\n return yield* encodeEndpoint({ port, token: Redacted.value(token) });\n});\n\n/** @internal */\nexport const endpointFileLayer = Layer.effectDiscard(\n Effect.gen(function* endpointFile() {\n const dataDirectory = yield* EndpointDirectory;\n const path = yield* Path.Path;\n const fs = yield* FileSystem.FileSystem;\n const text = yield* endpointText;\n const file = path.join(dataDirectory, ENDPOINT_FILE);\n const remove = fs.remove(file).pipe(Effect.ignore);\n yield* fs.makeDirectory(dataDirectory, { recursive: true });\n yield* remove;\n yield* Effect.acquireRelease(\n fs.writeFileString(file, text, { mode: OWNER_ONLY }),\n () => remove,\n );\n }),\n);\n","import { layerWebSocket } from \"@effect/platform-node/NodeSocketServer\";\nimport { Effect, Layer } from \"effect\";\nimport { RpcSerialization, RpcServer } from \"effect/rpc\";\n\nimport { HOST, ServerToken, serverTokenLayer } from \"#/entities/endpoint/index.ts\";\nimport { endpointFileLayer } from \"#/features/serve-socket/model/endpoint-file-layer.ts\";\n\nconst ANY_PORT = 0;\n\nconst socketServerLayer = Layer.unwrap(\n Effect.gen(function* socketServer() {\n const { presentedBy } = yield* ServerToken;\n return layerWebSocket({\n host: HOST,\n port: ANY_PORT,\n verifyClient: presentedBy,\n });\n }),\n);\n\n/** @internal */\nexport const transportLayer = Layer.mergeAll(\n RpcServer.layerProtocolSocketServer,\n endpointFileLayer,\n).pipe(\n Layer.provide(RpcSerialization.layerJsonRpc()),\n Layer.provide(socketServerLayer),\n Layer.provideMerge(serverTokenLayer),\n);\n","import { SqliteClient, SqliteMigrator } from \"@effect/sql-sqlite-node\";\nimport { Effect, FileSystem, Layer, Path } from \"effect\";\nimport type { PlatformError } from \"effect\";\nimport { Migrator, SqlClient } from \"effect/sql\";\nimport type { SqlError } from \"effect/sql\";\n\n/** @internal */\nexport type Database = SqliteClient.SqliteClient | SqlClient.SqlClient;\n/** @internal */\nexport type DatabaseFailure =\n | Migrator.MigrationError\n | SqlError.SqlError\n | PlatformError.PlatformError;\n\nconst prepared = (extensions: readonly string[]): Layer.Layer<never, SqlError.SqlError, Database> =>\n Layer.effectDiscard(\n Effect.gen(function* prepare() {\n const client = yield* SqliteClient.SqliteClient;\n yield* Effect.forEach(extensions, (extension) => client.loadExtension(extension), {\n concurrency: 1,\n discard: true,\n });\n const sql = yield* SqlClient.SqlClient;\n yield* sql`pragma foreign_keys = on`;\n }),\n );\n\nconst databaseAt = ({\n directory,\n file,\n migrations,\n extensions,\n}: Readonly<{\n directory: string;\n file: string;\n migrations: Readonly<Record<string, Effect.Effect<void, unknown, SqlClient.SqlClient>>>;\n extensions: readonly string[];\n}>): Layer.Layer<Database, DatabaseFailure, FileSystem.FileSystem | Path.Path> =>\n Layer.unwrap(\n Effect.gen(function* database() {\n const path = yield* Path.Path;\n const fs = yield* FileSystem.FileSystem;\n yield* fs.makeDirectory(directory, { recursive: true });\n const client = SqliteClient.layer({ filename: path.join(directory, file) });\n return SqliteMigrator.layer({ loader: Migrator.fromRecord({ ...migrations }) }).pipe(\n Layer.provideMerge(prepared(extensions)),\n Layer.provideMerge(client),\n );\n }),\n );\n\n/** @internal */\nexport const sqliteLayer = databaseAt;\n"],"mappings":";;;;;;;;;;AAEA,IAAa,oBAAb,cAAuC,QAAQ,QAAmC,CAAC,CACjF,2FACF,CAAC,CAAC,CAAC;;ACEH,MAAM,cAAc;AACpB,MAAM,aAAa;AAMnB,IAAa,cAAb,cAAiC,QAAQ,QAMvC,CAAC,CAAC,+EAA+E,CAAC,CAAC,CAAC;AAEtF,MAAM,UAAU,IAAI,YAAY;AAEhC,MAAM,WAAW,WACf,KACE,QACA,OAAO,QAAQ,UAAU,GACzB,OAAO,KAAK,UAAU,IAAI,gBAAgB,KAAK,QAAQ,OAAO,MAAM,KAAK,CAAC,CAAC,CAAC,GAC5E,OAAO,kBAAkB,UAAU,MAAM,IAAI,eAAe,CAAC,CAC/D;AAEF,MAAa,mBAAmB,MAAM,KAAK,mBAAmB;CAC5D,MAAM,QAAQ,IAAI,OAAO,OAAO,gBAAgB,IAAI,WAAW,WAAW,CAAC,CAAC;CAC5E,MAAM,WAAW,QAAQ,OAAO,KAAK;CACrC,OAAO,YAAY,GAAG;EACpB,OAAO,SAAS,KAAK,KAAK;EAC1B,cAAc,EAAE,KAAK,EAAE,YACrB,KACE,OAAO,gBAAgB,GAAG,GAC1B,OAAO,QAAQ,OAAO,GACtB,OAAO,QAAQ,UAAU,IAAI,gBAAgB,QAAQ,OAAO,KAAK,GAAG,QAAQ,CAAC,CAC/E;CACJ,CAAC;AACH,CAAC;;
|
|
1
|
+
{"version":3,"file":"node.mjs","names":[],"sources":["../../src/entities/endpoint/model/endpoint-directory.ts","../../src/entities/endpoint/model/server-token.ts","../../src/shared/lib/socket-port.ts","../../src/features/serve-socket/model/endpoint-file-layer.ts","../../src/features/serve-socket/model/transport-layer.ts","../../src/shared/lib/sqlite-layer.ts"],"sourcesContent":["import { Context } from \"effect\";\n\nexport class EndpointDirectory extends Context.Service<EndpointDirectory, string>()(\n \"@r_masseater/masseater-utils/entities/endpoint/model/endpoint-directory/EndpointDirectory\",\n) {}\n","import { Context, Layer, Option, Redacted, String, pipe } from \"effect\";\nimport { Mac } from \"effect/crypto\";\nimport { Hex } from \"effect/encoding\";\n\nimport { TOKEN_PARAMETER } from \"#/entities/endpoint/model/endpoint.ts\";\n\nconst TOKEN_BYTES = 32;\nconst QUERY_MARK = \"?\";\n\ninterface Handshake {\n readonly req: { readonly url?: string | undefined };\n}\n\nexport class ServerToken extends Context.Service<\n ServerToken,\n {\n readonly token: Redacted.Redacted;\n readonly presentedBy: (handshake: Handshake) => boolean;\n }\n>()(\"@r_masseater/masseater-utils/entities/endpoint/model/server-token/ServerToken\") {}\n\nconst encoder = new TextEncoder();\n\nconst tokenIn = (target: string): Option.Option<string> =>\n pipe(\n target,\n String.indexOf(QUERY_MARK),\n Option.map((start) => new URLSearchParams(pipe(target, String.slice(start)))),\n Option.flatMapNullishOr((query) => query.get(TOKEN_PARAMETER)),\n );\n\nexport const serverTokenLayer = Layer.sync(ServerToken, () => {\n const token = Hex.encode(crypto.getRandomValues(new Uint8Array(TOKEN_BYTES)));\n const expected = encoder.encode(token);\n return ServerToken.of({\n token: Redacted.make(token),\n presentedBy: ({ req: { url } }) =>\n pipe(\n Option.fromUndefinedOr(url),\n Option.flatMap(tokenIn),\n Option.exists((given) => Mac.timingSafeEqual(encoder.encode(given), expected)),\n ),\n });\n});\n","import { Match, Option } from \"effect\";\nimport type { NetAddress } from \"effect/net\";\n\n/** @internal */\nexport const portOf = Match.type<NetAddress.SocketAddress>().pipe(\n Match.tag(\"UnixPathAddress\", () => Option.none<number>()),\n Match.orElse(({ port }) => Option.some(port)),\n);\n","import { Effect, FileSystem, Layer, Path, Redacted, Schema } from \"effect\";\nimport { SocketServer } from \"effect/socket\";\n\nimport {\n EndpointDirectory,\n ENDPOINT_FILE,\n ServerEndpoint,\n ServerToken,\n} from \"#/entities/endpoint/index.ts\";\nimport { portOf } from \"#/shared/lib/socket-port.ts\";\n\nconst OWNER_ONLY = 0o600;\n\nconst encodeEndpoint = Schema.encodeEffect(Schema.fromJsonString(ServerEndpoint));\n\nconst endpointText = Effect.gen(function* endpointText() {\n const { address } = yield* SocketServer.SocketServer;\n const { token } = yield* ServerToken;\n const port = yield* Effect.fromOption(portOf(address));\n return yield* encodeEndpoint({ port, token: Redacted.value(token) });\n});\n\n/** @internal */\nexport const endpointFileLayer = Layer.effectDiscard(\n Effect.gen(function* endpointFile() {\n const dataDirectory = yield* EndpointDirectory;\n const path = yield* Path.Path;\n const fs = yield* FileSystem.FileSystem;\n const text = yield* endpointText;\n const file = path.join(dataDirectory, ENDPOINT_FILE);\n const remove = fs.remove(file).pipe(Effect.ignore);\n yield* fs.makeDirectory(dataDirectory, { recursive: true });\n yield* remove;\n yield* Effect.acquireRelease(\n fs.writeFileString(file, text, { mode: OWNER_ONLY }),\n () => remove,\n );\n }),\n);\n","import { layerWebSocket } from \"@effect/platform-node/NodeSocketServer\";\nimport { Effect, Layer } from \"effect\";\nimport { RpcSerialization, RpcServer } from \"effect/rpc\";\n\nimport { HOST, ServerToken, serverTokenLayer } from \"#/entities/endpoint/index.ts\";\nimport { endpointFileLayer } from \"#/features/serve-socket/model/endpoint-file-layer.ts\";\n\nconst ANY_PORT = 0;\n\nconst socketServerLayer = Layer.unwrap(\n Effect.gen(function* socketServer() {\n const { presentedBy } = yield* ServerToken;\n return layerWebSocket({\n host: HOST,\n port: ANY_PORT,\n verifyClient: presentedBy,\n });\n }),\n);\n\n/** @internal */\nexport const transportLayer = Layer.mergeAll(\n RpcServer.layerProtocolSocketServer,\n endpointFileLayer,\n).pipe(\n Layer.provide(RpcSerialization.layerJsonRpc()),\n Layer.provide(socketServerLayer),\n Layer.provideMerge(serverTokenLayer),\n);\n","import { SqliteClient, SqliteMigrator } from \"@effect/sql-sqlite-node\";\nimport { Effect, FileSystem, Layer, Path } from \"effect\";\nimport type { PlatformError } from \"effect\";\nimport { Migrator, SqlClient } from \"effect/sql\";\nimport type { SqlError } from \"effect/sql\";\n\n/** @internal */\nexport type Database = SqliteClient.SqliteClient | SqlClient.SqlClient;\n/** @internal */\nexport type DatabaseFailure =\n | Migrator.MigrationError\n | SqlError.SqlError\n | PlatformError.PlatformError;\n\nconst prepared = (extensions: readonly string[]): Layer.Layer<never, SqlError.SqlError, Database> =>\n Layer.effectDiscard(\n Effect.gen(function* prepare() {\n const client = yield* SqliteClient.SqliteClient;\n yield* Effect.forEach(extensions, (extension) => client.loadExtension(extension), {\n concurrency: 1,\n discard: true,\n });\n const sql = yield* SqlClient.SqlClient;\n yield* sql`pragma foreign_keys = on`;\n }),\n );\n\nconst databaseAt = ({\n directory,\n file,\n migrations,\n extensions,\n}: Readonly<{\n directory: string;\n file: string;\n migrations: Readonly<Record<string, Effect.Effect<void, unknown, SqlClient.SqlClient>>>;\n extensions: readonly string[];\n}>): Layer.Layer<Database, DatabaseFailure, FileSystem.FileSystem | Path.Path> =>\n Layer.unwrap(\n Effect.gen(function* database() {\n const path = yield* Path.Path;\n const fs = yield* FileSystem.FileSystem;\n yield* fs.makeDirectory(directory, { recursive: true });\n const client = SqliteClient.layer({ filename: path.join(directory, file) });\n return SqliteMigrator.layer({ loader: Migrator.fromRecord({ ...migrations }) }).pipe(\n Layer.provideMerge(prepared(extensions)),\n Layer.provideMerge(client),\n );\n }),\n );\n\n/** @internal */\nexport const sqliteLayer = databaseAt;\n"],"mappings":";;;;;;;;;;AAEA,IAAa,oBAAb,cAAuC,QAAQ,QAAmC,CAAC,CACjF,2FACF,CAAC,CAAC,CAAC;;ACEH,MAAM,cAAc;AACpB,MAAM,aAAa;AAMnB,IAAa,cAAb,cAAiC,QAAQ,QAMvC,CAAC,CAAC,+EAA+E,CAAC,CAAC,CAAC;AAEtF,MAAM,UAAU,IAAI,YAAY;AAEhC,MAAM,WAAW,WACf,KACE,QACA,OAAO,QAAQ,UAAU,GACzB,OAAO,KAAK,UAAU,IAAI,gBAAgB,KAAK,QAAQ,OAAO,MAAM,KAAK,CAAC,CAAC,CAAC,GAC5E,OAAO,kBAAkB,UAAU,MAAM,IAAI,eAAe,CAAC,CAC/D;AAEF,MAAa,mBAAmB,MAAM,KAAK,mBAAmB;CAC5D,MAAM,QAAQ,IAAI,OAAO,OAAO,gBAAgB,IAAI,WAAW,WAAW,CAAC,CAAC;CAC5E,MAAM,WAAW,QAAQ,OAAO,KAAK;CACrC,OAAO,YAAY,GAAG;EACpB,OAAO,SAAS,KAAK,KAAK;EAC1B,cAAc,EAAE,KAAK,EAAE,YACrB,KACE,OAAO,gBAAgB,GAAG,GAC1B,OAAO,QAAQ,OAAO,GACtB,OAAO,QAAQ,UAAU,IA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C,UAAU,2BACV,iBACF,CAAC,CAAC,KACA,MAAM,QAAQ,iBAAiB,aAAa,CAAC,GAC7C,MAAM,QAAQ,iBAAiB,GAC/B,MAAM,aAAa,gBAAgB,CACrC;;ACdA,MAAM,YAAY,eAChB,MAAM,cACJ,OAAO,IAAI,UAAU,UAAU;CAC7B,MAAM,SAAS,OAAO,aAAa;CACnC,OAAO,OAAO,QAAQ,aAAa,cAAc,OAAO,cAAc,SAAS,GAAG;EAChF,aAAa;EACb,SAAS;CACX,CAAC;CAED,OAAO,CAAA,OADY,UAAU,UACnB;AACZ,CAAC,CACH;AAEF,MAAM,cAAc,EAClB,WACA,MACA,YACA,iBAOA,MAAM,OACJ,OAAO,IAAI,UAAU,WAAW;CAC9B,MAAM,OAAO,OAAO,KAAK;CAEzB,QAAO,OADW,WAAW,WAAA,CACnB,cAAc,WAAW,EAAE,WAAW,KAAK,CAAC;CACtD,MAAM,SAAS,aAAa,MAAM,EAAE,UAAU,KAAK,KAAK,WAAW,IAAI,EAAE,CAAC;CAC1E,OAAO,eAAe,MAAM,EAAE,QAAQ,SAAS,WAAW,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,KAC9E,MAAM,aAAa,SAAS,UAAU,CAAC,GACvC,MAAM,aAAa,MAAM,CAC3B;AACF,CAAC,CACH;;AAGF,MAAa,cAAc"}
|
package/dist/local-server.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { a as ServerEndpoint, i as HOST, o as TOKEN_PARAMETER, r as ENDPOINT_FILE, s as awaitEndpoint, t as ServerUrl } from "./index-DeL_mxdJ.mjs";
|
|
2
|
-
import { Cause, Effect, Layer,
|
|
2
|
+
import { Cause, Effect, Layer, Schema } from "effect";
|
|
3
3
|
import { RpcClient } from "effect/rpc";
|
|
4
|
-
import { NetAddress } from "effect/net";
|
|
5
4
|
/** @internal */
|
|
6
5
|
export declare const socketProtocolLayer: Layer.Layer<RpcClient.Protocol, never, ServerUrl>;
|
|
7
6
|
declare const RequestFailed_base: Schema.Class<RequestFailed, Schema.TaggedStruct<"RequestFailed", {
|
|
@@ -11,8 +10,5 @@ declare const RequestFailed_base: Schema.Class<RequestFailed, Schema.TaggedStruc
|
|
|
11
10
|
readonly brand: unique symbol;
|
|
12
11
|
}>;
|
|
13
12
|
export declare class RequestFailed extends RequestFailed_base {}
|
|
14
|
-
export declare const asRequestFailed: (problem: unknown) => RequestFailed;
|
|
15
13
|
export declare const failed: <Value, Failure, Requirements>(effect: Effect.Effect<Value, Failure, Requirements>) => Effect.Effect<Value, RequestFailed, Requirements>;
|
|
16
|
-
/** @internal */
|
|
17
|
-
export declare const portOf: (input: NetAddress.SocketAddress) => Option.Option<number>;
|
|
18
14
|
export { ENDPOINT_FILE, HOST, ServerEndpoint, ServerUrl, TOKEN_PARAMETER, awaitEndpoint };
|