@effect/platform-deno 4.0.6 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DenoChildProcessSpawner.d.ts.map +1 -1
- package/dist/DenoChildProcessSpawner.js +70 -16
- package/dist/DenoChildProcessSpawner.js.map +1 -1
- package/dist/DenoClusterHttp.d.ts.map +1 -1
- package/dist/DenoClusterHttp.js +2 -2
- package/dist/DenoClusterHttp.js.map +1 -1
- package/dist/DenoClusterSocket.d.ts.map +1 -1
- package/dist/DenoClusterSocket.js +2 -2
- package/dist/DenoClusterSocket.js.map +1 -1
- package/dist/DenoCrypto.d.ts +126 -9
- package/dist/DenoCrypto.d.ts.map +1 -1
- package/dist/DenoCrypto.js +126 -36
- package/dist/DenoCrypto.js.map +1 -1
- package/dist/DenoFileSystem.d.ts.map +1 -1
- package/dist/DenoFileSystem.js +16 -14
- package/dist/DenoFileSystem.js.map +1 -1
- package/dist/DenoHttpServer.js +15 -9
- package/dist/DenoHttpServer.js.map +1 -1
- package/dist/DenoRedis.d.ts +4 -3
- package/dist/DenoRedis.d.ts.map +1 -1
- package/dist/DenoRedis.js +21 -8
- package/dist/DenoRedis.js.map +1 -1
- package/dist/DenoServices.d.ts +3 -4
- package/dist/DenoServices.d.ts.map +1 -1
- package/dist/DenoServices.js +1 -2
- package/dist/DenoServices.js.map +1 -1
- package/package.json +4 -4
- package/src/DenoChildProcessSpawner.ts +81 -21
- package/src/DenoClusterHttp.ts +2 -2
- package/src/DenoClusterSocket.ts +2 -2
- package/src/DenoCrypto.ts +155 -43
- package/src/DenoFileSystem.ts +22 -20
- package/src/DenoHttpServer.ts +21 -13
- package/src/DenoRedis.ts +30 -10
- package/src/DenoServices.ts +3 -6
package/dist/DenoRedis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DenoRedis.js","sourceRoot":"","sources":["../src/DenoRedis.ts"],"names":[],"mappings":"AAAA
|
|
1
|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AM,CAAC,MAAM,KAAK,GAAG,CACnB,OAAwD,EACA,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;AAE/F;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAsD,EACuB,EAAE,CAC/E,KAAK,CAAC,aAAa,CACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CACzB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CACrB,CACF,CAAA"}
|
package/dist/DenoServices.d.ts
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
* Aggregate Deno platform services layer.
|
|
3
3
|
*
|
|
4
4
|
* This module defines the `DenoServices` union and a single `layer` that
|
|
5
|
-
* provides Deno-backed child process spawning,
|
|
5
|
+
* provides Deno-backed child process spawning, filesystem, path, stdio,
|
|
6
6
|
* and terminal services. Use the layer when a Deno program wants the standard
|
|
7
7
|
* platform services from one place.
|
|
8
8
|
*
|
|
9
9
|
* @stability unstable
|
|
10
10
|
* @since 4.0.0
|
|
11
11
|
*/
|
|
12
|
-
import type { Crypto } from "effect/Crypto";
|
|
13
12
|
import type { FileSystem } from "effect/FileSystem";
|
|
14
13
|
import * as Layer from "effect/Layer";
|
|
15
14
|
import type { Path } from "effect/Path";
|
|
@@ -18,13 +17,13 @@ import type { Stdio } from "effect/Stdio";
|
|
|
18
17
|
import type { Terminal } from "effect/Terminal";
|
|
19
18
|
/**
|
|
20
19
|
* The union of core services provided by the Deno platform layer, including
|
|
21
|
-
* child process spawning,
|
|
20
|
+
* child process spawning, filesystem, path, stdio, and terminal services.
|
|
22
21
|
*
|
|
23
22
|
* @stability unstable
|
|
24
23
|
* @category models
|
|
25
24
|
* @since 4.0.0
|
|
26
25
|
*/
|
|
27
|
-
export type DenoServices = ChildProcessSpawner |
|
|
26
|
+
export type DenoServices = ChildProcessSpawner | FileSystem | Path | Terminal | Stdio;
|
|
28
27
|
/**
|
|
29
28
|
* Provides the default Deno implementations for child process spawning,
|
|
30
29
|
* crypto, filesystem, path, stdio, and terminal services.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DenoServices.d.ts","sourceRoot":"","sources":["../src/DenoServices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"DenoServices.d.ts","sourceRoot":"","sources":["../src/DenoServices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAO/C;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,UAAU,GAAG,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAA;AAErF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAO3C,CAAA"}
|
package/dist/DenoServices.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
import * as DenoChildProcessSpawner from "./DenoChildProcessSpawner.js";
|
|
3
|
-
import * as DenoCrypto from "./DenoCrypto.js";
|
|
4
3
|
import * as DenoFileSystem from "./DenoFileSystem.js";
|
|
5
4
|
import * as DenoPath from "./DenoPath.js";
|
|
6
5
|
import * as DenoStdio from "./DenoStdio.js";
|
|
@@ -13,5 +12,5 @@ import * as DenoTerminal from "./DenoTerminal.js";
|
|
|
13
12
|
* @category layers
|
|
14
13
|
* @since 4.0.0
|
|
15
14
|
*/
|
|
16
|
-
export const layer = DenoChildProcessSpawner.layer.pipe(Layer.provideMerge(Layer.mergeAll(DenoFileSystem.layer,
|
|
15
|
+
export const layer = DenoChildProcessSpawner.layer.pipe(Layer.provideMerge(Layer.mergeAll(DenoFileSystem.layer, DenoPath.layer, DenoStdio.layer, DenoTerminal.layer)));
|
|
17
16
|
//# sourceMappingURL=DenoServices.js.map
|
package/dist/DenoServices.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DenoServices.js","sourceRoot":"","sources":["../src/DenoServices.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DenoServices.js","sourceRoot":"","sources":["../src/DenoServices.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAKrC,OAAO,KAAK,uBAAuB,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAYjD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAA8B,uBAAuB,CAAC,KAAK,CAAC,IAAI,CAChF,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAC/B,cAAc,CAAC,KAAK,EACpB,QAAQ,CAAC,KAAK,EACd,SAAS,CAAC,KAAK,EACf,YAAY,CAAC,KAAK,CACnB,CAAC,CACH,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform-deno",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Platform specific implementations for the Deno runtime",
|
|
7
7
|
"homepage": "https://effect.website",
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"@std/media-types": "npm:@jsr/std__media-types@^1.1.0",
|
|
58
58
|
"@std/path": "npm:@jsr/std__path@^1.1.6",
|
|
59
59
|
"@std/streams": "npm:@jsr/std__streams@^1.2.0",
|
|
60
|
-
"@effect/platform-node-shared": "^4.0
|
|
60
|
+
"@effect/platform-node-shared": "^4.1.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"effect": "^4.0
|
|
63
|
+
"effect": "^4.1.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@std/assert": "npm:@jsr/std__assert@^1.0.19",
|
|
67
67
|
"@testcontainers/redis": "^12.2.1",
|
|
68
68
|
"@types/deno": "^2.7.0",
|
|
69
69
|
"tinybench": "^6.2.2",
|
|
70
|
-
"effect": "^4.0
|
|
70
|
+
"effect": "^4.1.0"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"codegen": "effect-utils codegen",
|
|
@@ -25,13 +25,33 @@ import {
|
|
|
25
25
|
makeHandle,
|
|
26
26
|
ProcessId
|
|
27
27
|
} from "effect/process/ChildProcessSpawner"
|
|
28
|
+
import * as CommandLine from "effect/process/CommandLine"
|
|
29
|
+
import * as Redacted from "effect/Redacted"
|
|
28
30
|
import type * as Scope from "effect/Scope"
|
|
29
31
|
import * as Sink from "effect/Sink"
|
|
30
32
|
import * as Stream from "effect/Stream"
|
|
31
33
|
|
|
34
|
+
const unwrap = (value: string | Redacted.Redacted<string>): string =>
|
|
35
|
+
Redacted.isRedacted(value) ? Redacted.value(value) : value
|
|
36
|
+
|
|
37
|
+
// Deno cannot pass NUL characters to a process. They are rejected before
|
|
38
|
+
// spawning so that the error does not depend on Deno's message.
|
|
39
|
+
const findNulCharacter = (command: ChildProcess.StandardCommand): string | undefined => {
|
|
40
|
+
if (command.command.includes("\0")) return "The command contains a NUL character"
|
|
41
|
+
const index = command.args.findIndex((arg) => unwrap(arg).includes("\0"))
|
|
42
|
+
if (index !== -1) return `Argument ${index + 1} contains a NUL character`
|
|
43
|
+
for (const [name, value] of Object.entries(command.options.env ?? {})) {
|
|
44
|
+
if (value !== undefined && unwrap(value).includes("\0")) {
|
|
45
|
+
return `The environment variable ${name} contains a NUL character`
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return undefined
|
|
49
|
+
}
|
|
50
|
+
|
|
32
51
|
const commandString = (command: ChildProcess.Command): string => {
|
|
33
52
|
const { commands } = flattenCommand(command)
|
|
34
|
-
|
|
53
|
+
const format = Deno.build.os === "windows" ? "windows" : "posix"
|
|
54
|
+
return commands.map((command) => CommandLine.display([command.command, ...command.args], { format })).join(" | ")
|
|
35
55
|
}
|
|
36
56
|
|
|
37
57
|
const toPlatformError = (
|
|
@@ -52,7 +72,7 @@ const toPlatformError = (
|
|
|
52
72
|
module: "ChildProcess",
|
|
53
73
|
method,
|
|
54
74
|
pathOrDescriptor: commandString(command),
|
|
55
|
-
syscall: `${method} ${commandString(command)
|
|
75
|
+
syscall: `${method} ${commandString(command)}`,
|
|
56
76
|
cause
|
|
57
77
|
})
|
|
58
78
|
}
|
|
@@ -70,13 +90,20 @@ const make = Effect.gen(function*() {
|
|
|
70
90
|
const resolveWorkingDirectory = (options: ChildProcess.CommandOptions) =>
|
|
71
91
|
options.cwd === undefined ? undefined : path.resolve(options.cwd)
|
|
72
92
|
|
|
73
|
-
const resolveEnvironment = (
|
|
93
|
+
const resolveEnvironment = (
|
|
94
|
+
options: ChildProcess.CommandOptions
|
|
95
|
+
): { readonly env: Record<string, string>; readonly clearEnv: boolean } | undefined => {
|
|
74
96
|
if (options.env === undefined) return undefined
|
|
75
|
-
const
|
|
97
|
+
const extend = options.extendEnv === true
|
|
98
|
+
// Deno can only add variables to the inherited environment, so removing
|
|
99
|
+
// one needs the whole environment.
|
|
100
|
+
const removes = Object.values(options.env).some((value) => value === undefined)
|
|
101
|
+
const env: Record<string, string> = extend && removes ? Deno.env.toObject() : {}
|
|
76
102
|
for (const [key, value] of Object.entries(options.env)) {
|
|
77
|
-
if (value
|
|
103
|
+
if (value === undefined) delete env[key]
|
|
104
|
+
else env[key] = unwrap(value)
|
|
78
105
|
}
|
|
79
|
-
return env
|
|
106
|
+
return { env, clearEnv: !extend || removes }
|
|
80
107
|
}
|
|
81
108
|
|
|
82
109
|
const resolveStdinOption = (options: ChildProcess.CommandOptions): ChildProcess.StdinConfig => {
|
|
@@ -128,7 +155,8 @@ const make = Effect.gen(function*() {
|
|
|
128
155
|
const setupChildStdin = (
|
|
129
156
|
command: ChildProcess.StandardCommand,
|
|
130
157
|
childProcess: Deno.ChildProcess,
|
|
131
|
-
config: ChildProcess.StdinConfig
|
|
158
|
+
config: ChildProcess.StdinConfig,
|
|
159
|
+
inputFailure: Deferred.Deferred<never, PlatformError.PlatformError>
|
|
132
160
|
) =>
|
|
133
161
|
Effect.suspend(() => {
|
|
134
162
|
if (inputToStdioOption(config.stream) !== "piped") return Effect.succeed(Sink.drain)
|
|
@@ -138,7 +166,14 @@ const make = Effect.gen(function*() {
|
|
|
138
166
|
closeOnDone: config.endOnDone
|
|
139
167
|
})
|
|
140
168
|
return Stream.isStream(config.stream)
|
|
141
|
-
? Effect.as(
|
|
169
|
+
? Effect.as(
|
|
170
|
+
Effect.forkScoped(
|
|
171
|
+
// Record a failure of the source stream so that it can be surfaced
|
|
172
|
+
// by the process exit code
|
|
173
|
+
Stream.run(Stream.tapError(config.stream, (error) => Deferred.fail(inputFailure, error)), sink)
|
|
174
|
+
),
|
|
175
|
+
sink
|
|
176
|
+
)
|
|
142
177
|
: Effect.succeed(sink)
|
|
143
178
|
})
|
|
144
179
|
|
|
@@ -250,11 +285,27 @@ const make = Effect.gen(function*() {
|
|
|
250
285
|
const stderrConfig = resolveOutputOption(cmd.options, "stderr")
|
|
251
286
|
let isReferenced = true
|
|
252
287
|
|
|
288
|
+
if (cmd.options.shell !== undefined && cmd.options.shell !== false && cmd.args.length > 0) {
|
|
289
|
+
return yield* Effect.fail(PlatformError.badArgument({
|
|
290
|
+
module: "ChildProcess",
|
|
291
|
+
method: "spawn",
|
|
292
|
+
description: "The shell option cannot be combined with arguments; pass the whole script as the command"
|
|
293
|
+
}))
|
|
294
|
+
}
|
|
295
|
+
const nulCharacter = findNulCharacter(cmd)
|
|
296
|
+
if (nulCharacter !== undefined) {
|
|
297
|
+
return yield* Effect.fail(PlatformError.badArgument({
|
|
298
|
+
module: "ChildProcess",
|
|
299
|
+
method: "spawn",
|
|
300
|
+
description: nulCharacter
|
|
301
|
+
}))
|
|
302
|
+
}
|
|
303
|
+
|
|
253
304
|
let executable = cmd.command
|
|
254
|
-
let args = cmd.args
|
|
305
|
+
let args: ReadonlyArray<string> = cmd.args.map(unwrap)
|
|
255
306
|
let windowsRawArguments = false
|
|
256
307
|
if (cmd.options.shell) {
|
|
257
|
-
const shellCommand =
|
|
308
|
+
const shellCommand = cmd.command
|
|
258
309
|
if (Deno.build.os === "windows") {
|
|
259
310
|
executable = typeof cmd.options.shell === "string" ? cmd.options.shell : "cmd.exe"
|
|
260
311
|
args = ["/d", "/s", "/c", shellCommand]
|
|
@@ -270,8 +321,8 @@ const make = Effect.gen(function*() {
|
|
|
270
321
|
const [childProcess, exitSignal] = yield* Effect.acquireRelease(
|
|
271
322
|
spawn(cmd, executable, args, {
|
|
272
323
|
...(cwd === undefined ? undefined : { cwd }),
|
|
273
|
-
...(env === undefined ? undefined : { env }),
|
|
274
|
-
clearEnv:
|
|
324
|
+
...(env === undefined ? undefined : { env: env.env }),
|
|
325
|
+
clearEnv: env?.clearEnv ?? false,
|
|
275
326
|
stdin: inputToStdioOption(stdinConfig.stream),
|
|
276
327
|
stdout: outputToStdioOption(stdoutConfig.stream),
|
|
277
328
|
stderr: outputToStdioOption(stderrConfig.stream),
|
|
@@ -302,17 +353,26 @@ const make = Effect.gen(function*() {
|
|
|
302
353
|
}
|
|
303
354
|
return reref
|
|
304
355
|
})
|
|
305
|
-
const
|
|
356
|
+
const inputFailure = Deferred.makeUnsafe<never, PlatformError.PlatformError>()
|
|
357
|
+
const stdin = yield* setupChildStdin(cmd, childProcess, stdinConfig, inputFailure)
|
|
306
358
|
const { all, stderr, stdout } = setupChildOutputStreams(cmd, childProcess, stdoutConfig, stderrConfig)
|
|
307
359
|
const isRunning = Effect.map(Deferred.isDone(exitSignal), (done) => !done)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
360
|
+
// A failed input stream truncates the input of the child process, so
|
|
361
|
+
// its failure takes precedence over the exit status and is surfaced
|
|
362
|
+
// without waiting for the child process to exit
|
|
363
|
+
const exitCode = Effect.flatMap(
|
|
364
|
+
Effect.raceFirst(Deferred.await(exitSignal), Deferred.await(inputFailure)),
|
|
365
|
+
(status) => {
|
|
366
|
+
if (Deferred.isDoneUnsafe(inputFailure)) {
|
|
367
|
+
return Deferred.await(inputFailure)
|
|
368
|
+
}
|
|
369
|
+
if (Predicate.isNull(status.signal)) {
|
|
370
|
+
return Effect.succeed(ExitCode(status.code))
|
|
371
|
+
}
|
|
372
|
+
const error = new globalThis.Error(`Process interrupted due to receipt of signal: '${status.signal}'`)
|
|
373
|
+
return Effect.fail(toPlatformError("exitCode", error, cmd))
|
|
374
|
+
}
|
|
375
|
+
)
|
|
316
376
|
const kill = (options?: ChildProcess.KillOptions | undefined) => {
|
|
317
377
|
const killWithTimeout = withTimeout(childProcess, cmd, options)
|
|
318
378
|
return killWithTimeout((command, childProcess, signal) =>
|
package/src/DenoClusterHttp.ts
CHANGED
|
@@ -19,6 +19,7 @@ import * as ShardingConfig from "effect/cluster/ShardingConfig"
|
|
|
19
19
|
import * as SqlMessageStorage from "effect/cluster/SqlMessageStorage"
|
|
20
20
|
import * as SqlRunnerStorage from "effect/cluster/SqlRunnerStorage"
|
|
21
21
|
import type * as Config from "effect/Config"
|
|
22
|
+
import * as Digest from "effect/crypto/Digest"
|
|
22
23
|
import * as Effect from "effect/Effect"
|
|
23
24
|
import type * as Etag from "effect/http/Etag"
|
|
24
25
|
import type { HttpPlatform } from "effect/http/HttpPlatform"
|
|
@@ -29,7 +30,6 @@ import * as Option from "effect/Option"
|
|
|
29
30
|
import * as RpcSerialization from "effect/rpc/RpcSerialization"
|
|
30
31
|
import type { SqlClient } from "effect/sql/SqlClient"
|
|
31
32
|
import { layerK8sHttpClient } from "./DenoClusterSocket.ts"
|
|
32
|
-
import * as DenoCrypto from "./DenoCrypto.ts"
|
|
33
33
|
import * as DenoHttpClient from "./DenoHttpClient.ts"
|
|
34
34
|
import * as DenoHttpServer from "./DenoHttpServer.ts"
|
|
35
35
|
import type { DenoServices } from "./DenoServices.ts"
|
|
@@ -141,7 +141,7 @@ export const layer = <
|
|
|
141
141
|
? MessageStorage.layerNoop
|
|
142
142
|
: options.storage === "byo"
|
|
143
143
|
? Layer.empty
|
|
144
|
-
:
|
|
144
|
+
: SqlMessageStorage.layer.pipe(Layer.provide(Digest.layerWebCrypto))
|
|
145
145
|
),
|
|
146
146
|
Layer.provide(
|
|
147
147
|
options.storage === "local"
|
package/src/DenoClusterSocket.ts
CHANGED
|
@@ -21,6 +21,7 @@ import * as SocketRunner from "effect/cluster/SocketRunner"
|
|
|
21
21
|
import * as SqlMessageStorage from "effect/cluster/SqlMessageStorage"
|
|
22
22
|
import * as SqlRunnerStorage from "effect/cluster/SqlRunnerStorage"
|
|
23
23
|
import type * as Config from "effect/Config"
|
|
24
|
+
import * as Digest from "effect/crypto/Digest"
|
|
24
25
|
import * as Effect from "effect/Effect"
|
|
25
26
|
import * as FileSystem from "effect/FileSystem"
|
|
26
27
|
import * as Layer from "effect/Layer"
|
|
@@ -30,7 +31,6 @@ import * as RpcSerialization from "effect/rpc/RpcSerialization"
|
|
|
30
31
|
import { Socket } from "effect/socket/Socket"
|
|
31
32
|
import type * as SocketServer from "effect/socket/SocketServer"
|
|
32
33
|
import type { SqlClient } from "effect/sql/SqlClient"
|
|
33
|
-
import * as DenoCrypto from "./DenoCrypto.ts"
|
|
34
34
|
import * as DenoFileSystem from "./DenoFileSystem.ts"
|
|
35
35
|
import * as DenoHttpClient from "./DenoHttpClient.ts"
|
|
36
36
|
import * as DenoSocket from "./DenoSocket.ts"
|
|
@@ -152,7 +152,7 @@ export const layer = <
|
|
|
152
152
|
? MessageStorage.layerNoop
|
|
153
153
|
: options?.storage === "byo"
|
|
154
154
|
? Layer.empty
|
|
155
|
-
:
|
|
155
|
+
: SqlMessageStorage.layer.pipe(Layer.provide(Digest.layerWebCrypto))
|
|
156
156
|
),
|
|
157
157
|
Layer.provide(
|
|
158
158
|
options?.storage === "local"
|
package/src/DenoCrypto.ts
CHANGED
|
@@ -1,66 +1,178 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Deno
|
|
2
|
+
* Deno layers for the `effect/crypto` modules.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Every layer here runs the core WebCrypto layer of its family, so that Deno
|
|
5
|
+
* programs take every crypto layer from `DenoCrypto`. They use the
|
|
6
|
+
* `WebCrypto` reference, which defaults to Deno's `globalThis.crypto`. Layers
|
|
7
|
+
* that need `SecureRandom` get it from {@link layerSecureRandom}, so no layer
|
|
8
|
+
* here has requirements. {@link layer} provides every family at once; provide
|
|
9
|
+
* a family's own layer to pick services selectively.
|
|
5
10
|
*
|
|
6
11
|
* @stability unstable
|
|
7
12
|
* @since 4.0.0
|
|
8
13
|
*/
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
14
|
+
import * as Aead from "effect/crypto/Aead"
|
|
15
|
+
import * as Cipher from "effect/crypto/Cipher"
|
|
16
|
+
import * as Digest from "effect/crypto/Digest"
|
|
17
|
+
import * as Kdf from "effect/crypto/Kdf"
|
|
18
|
+
import * as KeyAgreement from "effect/crypto/KeyAgreement"
|
|
19
|
+
import * as KeyWrap from "effect/crypto/KeyWrap"
|
|
20
|
+
import * as Mac from "effect/crypto/Mac"
|
|
21
|
+
import * as SecureRandom from "effect/crypto/SecureRandom"
|
|
22
|
+
import * as Signature from "effect/crypto/Signature"
|
|
12
23
|
import * as Layer from "effect/Layer"
|
|
13
|
-
import * as PlatformError from "effect/PlatformError"
|
|
14
24
|
|
|
15
25
|
/**
|
|
16
|
-
*
|
|
26
|
+
* Layer that provides `SecureRandom` on the `WebCrypto` reference.
|
|
27
|
+
*
|
|
28
|
+
* **Details**
|
|
29
|
+
*
|
|
30
|
+
* This is `SecureRandom.layerWebCrypto`, re-exported for Deno programs.
|
|
17
31
|
*
|
|
18
32
|
* @stability unstable
|
|
19
|
-
* @category
|
|
33
|
+
* @category layers
|
|
20
34
|
* @since 4.0.0
|
|
21
35
|
*/
|
|
22
|
-
export const
|
|
23
|
-
defaultValue: () => globalThis.crypto
|
|
24
|
-
})
|
|
36
|
+
export const layerSecureRandom: Layer.Layer<SecureRandom.SecureRandom> = SecureRandom.layerWebCrypto
|
|
25
37
|
|
|
26
38
|
/**
|
|
27
|
-
*
|
|
39
|
+
* Layer that provides `Digest` on the `WebCrypto` reference.
|
|
40
|
+
*
|
|
41
|
+
* **Details**
|
|
42
|
+
*
|
|
43
|
+
* This is `Digest.layerWebCrypto`, re-exported for Deno programs.
|
|
28
44
|
*
|
|
29
45
|
* @stability unstable
|
|
30
46
|
* @category layers
|
|
31
47
|
* @since 4.0.0
|
|
32
48
|
*/
|
|
33
|
-
export const
|
|
34
|
-
EffectCrypto.Crypto,
|
|
35
|
-
Effect.gen(function*() {
|
|
36
|
-
const crypto = yield* WebCrypto
|
|
37
|
-
const randomBytes = (size: number): Uint8Array => {
|
|
38
|
-
const bytes = new Uint8Array(size)
|
|
39
|
-
for (let offset = 0; offset < bytes.length; offset += 65_536) {
|
|
40
|
-
crypto.getRandomValues(bytes.subarray(offset, offset + 65_536))
|
|
41
|
-
}
|
|
42
|
-
return bytes
|
|
43
|
-
}
|
|
49
|
+
export const layerDigest: Layer.Layer<Digest.Digest> = Digest.layerWebCrypto
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}),
|
|
58
|
-
(buffer) => new Uint8Array(buffer)
|
|
59
|
-
)
|
|
51
|
+
/**
|
|
52
|
+
* Layer that provides `Mac` on the `WebCrypto` reference.
|
|
53
|
+
*
|
|
54
|
+
* **Details**
|
|
55
|
+
*
|
|
56
|
+
* This is `Mac.layerWebCrypto` with {@link layerSecureRandom}.
|
|
57
|
+
*
|
|
58
|
+
* @stability unstable
|
|
59
|
+
* @category layers
|
|
60
|
+
* @since 4.0.0
|
|
61
|
+
*/
|
|
62
|
+
export const layerMac: Layer.Layer<Mac.Mac> = Mac.layerWebCrypto.pipe(Layer.provide(layerSecureRandom))
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Layer that provides `Kdf` on the `WebCrypto` reference.
|
|
66
|
+
*
|
|
67
|
+
* **Details**
|
|
68
|
+
*
|
|
69
|
+
* This is `Kdf.layerWebCrypto`, re-exported for Deno programs.
|
|
70
|
+
*
|
|
71
|
+
* @stability unstable
|
|
72
|
+
* @category layers
|
|
73
|
+
* @since 4.0.0
|
|
74
|
+
*/
|
|
75
|
+
export const layerKdf: Layer.Layer<Kdf.Kdf> = Kdf.layerWebCrypto
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Layer that provides `Aead` on the `WebCrypto` reference.
|
|
79
|
+
*
|
|
80
|
+
* **Details**
|
|
81
|
+
*
|
|
82
|
+
* This is `Aead.layerWebCrypto` with {@link layerSecureRandom}.
|
|
83
|
+
*
|
|
84
|
+
* @stability unstable
|
|
85
|
+
* @category layers
|
|
86
|
+
* @since 4.0.0
|
|
87
|
+
*/
|
|
88
|
+
export const layerAead: Layer.Layer<Aead.Aead> = Aead.layerWebCrypto.pipe(Layer.provide(layerSecureRandom))
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Layer that provides `Cipher` on the `WebCrypto` reference.
|
|
92
|
+
*
|
|
93
|
+
* **Details**
|
|
94
|
+
*
|
|
95
|
+
* This is `Cipher.layerWebCrypto` with {@link layerSecureRandom}.
|
|
96
|
+
*
|
|
97
|
+
* @stability unstable
|
|
98
|
+
* @category layers
|
|
99
|
+
* @since 4.0.0
|
|
100
|
+
*/
|
|
101
|
+
export const layerCipher: Layer.Layer<Cipher.Cipher> = Cipher.layerWebCrypto.pipe(Layer.provide(layerSecureRandom))
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Layer that provides `Signature` on the `WebCrypto` reference.
|
|
105
|
+
*
|
|
106
|
+
* **Details**
|
|
107
|
+
*
|
|
108
|
+
* This is `Signature.layerWebCrypto` with {@link layerSecureRandom}.
|
|
109
|
+
*
|
|
110
|
+
* @stability unstable
|
|
111
|
+
* @category layers
|
|
112
|
+
* @since 4.0.0
|
|
113
|
+
*/
|
|
114
|
+
export const layerSignature: Layer.Layer<Signature.Signature> = Signature.layerWebCrypto.pipe(
|
|
115
|
+
Layer.provide(layerSecureRandom)
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Layer that provides `KeyAgreement` on the `WebCrypto` reference.
|
|
120
|
+
*
|
|
121
|
+
* **Details**
|
|
122
|
+
*
|
|
123
|
+
* This is `KeyAgreement.layerWebCrypto` with {@link layerSecureRandom}.
|
|
124
|
+
*
|
|
125
|
+
* @stability unstable
|
|
126
|
+
* @category layers
|
|
127
|
+
* @since 4.0.0
|
|
128
|
+
*/
|
|
129
|
+
export const layerKeyAgreement: Layer.Layer<KeyAgreement.KeyAgreement> = KeyAgreement.layerWebCrypto.pipe(
|
|
130
|
+
Layer.provide(layerSecureRandom)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Layer that provides `KeyWrap` on the `WebCrypto` reference.
|
|
135
|
+
*
|
|
136
|
+
* **Details**
|
|
137
|
+
*
|
|
138
|
+
* This is `KeyWrap.layerWebCrypto` with {@link layerSecureRandom}.
|
|
139
|
+
*
|
|
140
|
+
* @stability unstable
|
|
141
|
+
* @category layers
|
|
142
|
+
* @since 4.0.0
|
|
143
|
+
*/
|
|
144
|
+
export const layerKeyWrap: Layer.Layer<KeyWrap.KeyWrap> = KeyWrap.layerWebCrypto.pipe(Layer.provide(layerSecureRandom))
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Layer that provides every `effect/crypto` service on the `WebCrypto`
|
|
148
|
+
* reference.
|
|
149
|
+
*
|
|
150
|
+
* **Details**
|
|
151
|
+
*
|
|
152
|
+
* This merges the family layers of this module, so it requires nothing.
|
|
153
|
+
*
|
|
154
|
+
* @stability unstable
|
|
155
|
+
* @category layers
|
|
156
|
+
* @since 4.0.0
|
|
157
|
+
*/
|
|
158
|
+
export const layer: Layer.Layer<
|
|
159
|
+
| SecureRandom.SecureRandom
|
|
160
|
+
| Digest.Digest
|
|
161
|
+
| Mac.Mac
|
|
162
|
+
| Kdf.Kdf
|
|
163
|
+
| Aead.Aead
|
|
164
|
+
| Cipher.Cipher
|
|
165
|
+
| Signature.Signature
|
|
166
|
+
| KeyAgreement.KeyAgreement
|
|
167
|
+
| KeyWrap.KeyWrap
|
|
168
|
+
> = Layer.mergeAll(
|
|
169
|
+
layerSecureRandom,
|
|
170
|
+
layerDigest,
|
|
171
|
+
layerMac,
|
|
172
|
+
layerKdf,
|
|
173
|
+
layerAead,
|
|
174
|
+
layerCipher,
|
|
175
|
+
layerSignature,
|
|
176
|
+
layerKeyAgreement,
|
|
177
|
+
layerKeyWrap
|
|
66
178
|
)
|
package/src/DenoFileSystem.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @stability unstable
|
|
5
5
|
* @since 4.0.0
|
|
6
6
|
*/
|
|
7
|
-
import { copy as denoCopy,
|
|
7
|
+
import { copy as denoCopy, walk } from "@std/fs"
|
|
8
8
|
import { relative } from "@std/path"
|
|
9
9
|
import * as ByteSize from "effect/ByteSize"
|
|
10
10
|
import * as Effect from "effect/Effect"
|
|
@@ -77,16 +77,6 @@ const chmod: FileSystem.FileSystem["chmod"] = (path, mode) => tryPromise("chmod"
|
|
|
77
77
|
const chown: FileSystem.FileSystem["chown"] = (path, uid, gid) =>
|
|
78
78
|
tryPromise("chown", path, () => Deno.chown(path, uid, gid))
|
|
79
79
|
|
|
80
|
-
const glob: FileSystem.FileSystem["glob"] = (pattern, options) =>
|
|
81
|
-
Effect.map(
|
|
82
|
-
collectAsyncIterable("glob", pattern, () =>
|
|
83
|
-
expandGlob(pattern, {
|
|
84
|
-
root: options?.root ?? Deno.cwd(),
|
|
85
|
-
exclude: options?.exclude ? [...options.exclude] : []
|
|
86
|
-
})),
|
|
87
|
-
(entries) => entries.map((entry) => entry.path)
|
|
88
|
-
)
|
|
89
|
-
|
|
90
80
|
const link: FileSystem.FileSystem["link"] = (existingPath, newPath) =>
|
|
91
81
|
tryPromise("link", existingPath, () => Deno.link(existingPath, newPath))
|
|
92
82
|
|
|
@@ -122,7 +112,7 @@ const remove = removeFactory("remove")
|
|
|
122
112
|
const makeTempDirectoryScoped: FileSystem.FileSystem["makeTempDirectoryScoped"] = (options) =>
|
|
123
113
|
Effect.acquireRelease(
|
|
124
114
|
makeTempDirectoryFactory("makeTempDirectoryScoped")(options),
|
|
125
|
-
(directory) => Effect.orDie(removeFactory("makeTempDirectoryScoped")(directory, { recursive: true }))
|
|
115
|
+
(directory) => Effect.orDie(removeFactory("makeTempDirectoryScoped")(directory, { recursive: true, force: true }))
|
|
126
116
|
)
|
|
127
117
|
|
|
128
118
|
const openOptions = (flag: FileSystem.OpenFlag = "r", mode?: number): Deno.OpenOptions => {
|
|
@@ -151,22 +141,28 @@ const openOptions = (flag: FileSystem.OpenFlag = "r", mode?: number): Deno.OpenO
|
|
|
151
141
|
}
|
|
152
142
|
}
|
|
153
143
|
|
|
154
|
-
|
|
155
|
-
|
|
144
|
+
// `Deno.DirEntry` only reports the first three flags
|
|
145
|
+
const fileType = (info: Deno.DirEntry | Deno.FileInfo): FileSystem.File.Type => {
|
|
146
|
+
const flags: Partial<Deno.FileInfo> = info
|
|
147
|
+
return info.isFile ?
|
|
156
148
|
"File" :
|
|
157
149
|
info.isDirectory ?
|
|
158
150
|
"Directory" :
|
|
159
151
|
info.isSymlink ?
|
|
160
152
|
"SymbolicLink" :
|
|
161
|
-
|
|
153
|
+
flags.isBlockDevice ?
|
|
162
154
|
"BlockDevice" :
|
|
163
|
-
|
|
155
|
+
flags.isCharDevice ?
|
|
164
156
|
"CharacterDevice" :
|
|
165
|
-
|
|
157
|
+
flags.isFifo ?
|
|
166
158
|
"FIFO" :
|
|
167
|
-
|
|
159
|
+
flags.isSocket ?
|
|
168
160
|
"Socket" :
|
|
169
|
-
"Unknown"
|
|
161
|
+
"Unknown"
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const makeFileInfo = (info: Deno.FileInfo): FileSystem.File.Info => ({
|
|
165
|
+
type: fileType(info),
|
|
170
166
|
mtime: Option.fromNullishOr(info.mtime),
|
|
171
167
|
atime: Option.fromNullishOr(info.atime),
|
|
172
168
|
birthtime: Option.fromNullishOr(info.birthtime),
|
|
@@ -412,6 +408,12 @@ const readDirectory: FileSystem.FileSystem["readDirectory"] = (path, options) =>
|
|
|
412
408
|
)
|
|
413
409
|
}
|
|
414
410
|
|
|
411
|
+
const readDirectoryEntries = (path: string) =>
|
|
412
|
+
Effect.map(
|
|
413
|
+
collectAsyncIterable("readDirectoryEntries", path, () => Deno.readDir(path)),
|
|
414
|
+
(entries) => entries.map((entry): FileSystem.DirectoryEntry => ({ name: entry.name, type: fileType(entry) }))
|
|
415
|
+
)
|
|
416
|
+
|
|
415
417
|
const readFile: FileSystem.FileSystem["readFile"] = (path) =>
|
|
416
418
|
tryPromise("readFile", path, (signal) => Deno.readFile(path, { signal }))
|
|
417
419
|
|
|
@@ -525,7 +527,6 @@ const makeFileSystem = Effect.map(Effect.serviceOption(FileSystem.WatchBackend),
|
|
|
525
527
|
chown,
|
|
526
528
|
copy,
|
|
527
529
|
copyFile,
|
|
528
|
-
glob,
|
|
529
530
|
link,
|
|
530
531
|
lstat,
|
|
531
532
|
makeDirectory,
|
|
@@ -535,6 +536,7 @@ const makeFileSystem = Effect.map(Effect.serviceOption(FileSystem.WatchBackend),
|
|
|
535
536
|
makeTempFileScoped,
|
|
536
537
|
open,
|
|
537
538
|
readDirectory,
|
|
539
|
+
readDirectoryEntries,
|
|
538
540
|
readFile,
|
|
539
541
|
readLink,
|
|
540
542
|
realPath,
|