@bgord/bun 1.2.6 → 1.2.7
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/content-hash-noop.adapter.d.ts +7 -0
- package/dist/content-hash-noop.adapter.d.ts.map +1 -0
- package/dist/content-hash-noop.adapter.js +6 -0
- package/dist/content-hash-noop.adapter.js.map +1 -0
- package/dist/content-hash-sha256-bun.adapter.d.ts +7 -0
- package/dist/content-hash-sha256-bun.adapter.d.ts.map +1 -0
- package/dist/content-hash-sha256-bun.adapter.js +8 -0
- package/dist/content-hash-sha256-bun.adapter.js.map +1 -0
- package/dist/content-hash.port.d.ts +7 -0
- package/dist/content-hash.port.d.ts.map +1 -0
- package/dist/content-hash.port.js +2 -0
- package/dist/content-hash.port.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/markdown-generator-marked.adapter.d.ts +7 -0
- package/dist/markdown-generator-marked.adapter.d.ts.map +1 -0
- package/dist/markdown-generator-marked.adapter.js +12 -0
- package/dist/markdown-generator-marked.adapter.js.map +1 -0
- package/dist/markdown-generator-noop.adapter.d.ts +5 -0
- package/dist/markdown-generator-noop.adapter.d.ts.map +1 -0
- package/dist/markdown-generator-noop.adapter.js +6 -0
- package/dist/markdown-generator-noop.adapter.js.map +1 -0
- package/dist/markdown-generator.port.d.ts +4 -0
- package/dist/markdown-generator.port.d.ts.map +1 -0
- package/dist/markdown-generator.port.js +3 -0
- package/dist/markdown-generator.port.js.map +1 -0
- package/dist/prerequisites/dns.d.ts +16 -0
- package/dist/prerequisites/dns.d.ts.map +1 -0
- package/dist/prerequisites/dns.js +30 -0
- package/dist/prerequisites/dns.js.map +1 -0
- package/dist/prerequisites/index.d.ts +1 -0
- package/dist/prerequisites/index.d.ts.map +1 -1
- package/dist/prerequisites/index.js +1 -0
- package/dist/prerequisites/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/readme.md +7 -0
- package/src/content-hash-noop.adapter.ts +7 -0
- package/src/content-hash-sha256-bun.adapter.ts +10 -0
- package/src/content-hash.port.ts +5 -0
- package/src/index.ts +6 -0
- package/src/markdown-generator-marked.adapter.ts +15 -0
- package/src/markdown-generator-noop.adapter.ts +7 -0
- package/src/markdown-generator.port.ts +3 -0
- package/src/prerequisites/dns.ts +36 -0
- package/src/prerequisites/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/bun",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@types/yazl": "3.3.0",
|
|
30
30
|
"cspell": "9.4.0",
|
|
31
31
|
"knip": "5.71.0",
|
|
32
|
-
"lefthook": "2.0.
|
|
32
|
+
"lefthook": "2.0.7",
|
|
33
33
|
"only-allow": "1.2.2",
|
|
34
34
|
"shellcheck": "4.1.0",
|
|
35
35
|
"typescript": "5.9.3",
|
|
@@ -37,14 +37,16 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@axiomhq/winston": "1.3.1",
|
|
40
|
-
"@bgord/tools": "1.1.
|
|
40
|
+
"@bgord/tools": "1.1.11",
|
|
41
41
|
"@hono/ua-blocker": "0.1.20",
|
|
42
42
|
"better-auth": "1.4.5",
|
|
43
43
|
"croner": "9.1.0",
|
|
44
44
|
"csv": "6.4.1",
|
|
45
45
|
"hcaptcha": "0.2.0",
|
|
46
46
|
"hono": "4.10.7",
|
|
47
|
+
"isomorphic-dompurify": "2.33.0",
|
|
47
48
|
"lodash": "4.17.21",
|
|
49
|
+
"marked": "17.0.1",
|
|
48
50
|
"node-cache": "5.1.2",
|
|
49
51
|
"nodemailer": "7.0.11",
|
|
50
52
|
"sharp": "0.34.5",
|
package/readme.md
CHANGED
|
@@ -50,6 +50,9 @@ src/
|
|
|
50
50
|
├── command-envelope.ts
|
|
51
51
|
├── command-logger.service.ts
|
|
52
52
|
├── command.types.ts
|
|
53
|
+
├── content-hash-noop.adapter.ts
|
|
54
|
+
├── content-hash-sha256-bun.adapter.ts
|
|
55
|
+
├── content-hash.port.ts
|
|
53
56
|
├── context.middleware.ts
|
|
54
57
|
├── correlation-id.vo.ts
|
|
55
58
|
├── correlation-storage.service.ts
|
|
@@ -148,6 +151,9 @@ src/
|
|
|
148
151
|
├── mailer-smtp.adapter.ts
|
|
149
152
|
├── mailer.port.ts
|
|
150
153
|
├── mailer.vo.ts
|
|
154
|
+
├── markdown-generator-marked.adapter.ts
|
|
155
|
+
├── markdown-generator-noop.adapter.ts
|
|
156
|
+
├── markdown-generator.port.ts
|
|
151
157
|
├── memory-consumption.service.ts
|
|
152
158
|
├── modules
|
|
153
159
|
│ ├── history
|
|
@@ -194,6 +200,7 @@ src/
|
|
|
194
200
|
│ ├── clock-drift.ts
|
|
195
201
|
│ ├── dependency-vulnerabilities.ts
|
|
196
202
|
│ ├── directory.ts
|
|
203
|
+
│ ├── dns.ts
|
|
197
204
|
│ ├── external-api.ts
|
|
198
205
|
│ ├── jobs.ts
|
|
199
206
|
│ ├── log-file.ts
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContentHashPort } from "./content-hash.port";
|
|
2
|
+
|
|
3
|
+
export class ContentHashSha256BunAdapter implements ContentHashPort {
|
|
4
|
+
async hash(content: string) {
|
|
5
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(content));
|
|
6
|
+
const etag = Buffer.from(digest).toString("hex");
|
|
7
|
+
|
|
8
|
+
return { etag };
|
|
9
|
+
}
|
|
10
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -23,6 +23,9 @@ export * from "./clock-system.adapter";
|
|
|
23
23
|
export * from "./command.types";
|
|
24
24
|
export * from "./command-envelope";
|
|
25
25
|
export * from "./command-logger.service";
|
|
26
|
+
export * from "./content-hash.port";
|
|
27
|
+
export * from "./content-hash-noop.adapter";
|
|
28
|
+
export * from "./content-hash-sha256-bun.adapter";
|
|
26
29
|
export * from "./context.middleware";
|
|
27
30
|
export * from "./correlation-id.vo";
|
|
28
31
|
export * from "./correlation-storage.service";
|
|
@@ -124,6 +127,9 @@ export * from "./mailer.vo";
|
|
|
124
127
|
export * from "./mailer-noop.adapter";
|
|
125
128
|
export * from "./mailer-smtp.adapter";
|
|
126
129
|
export * from "./mailer-smtp-with-logger.adapter";
|
|
130
|
+
export * from "./markdown-generator.port";
|
|
131
|
+
export * from "./markdown-generator-marked.adapter";
|
|
132
|
+
export * from "./markdown-generator-noop.adapter";
|
|
127
133
|
export * from "./memory-consumption.service";
|
|
128
134
|
export * as History from "./modules/history";
|
|
129
135
|
export * as Preferences from "./modules/preferences";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import DOMPurify from "isomorphic-dompurify";
|
|
2
|
+
import { Marked } from "marked";
|
|
3
|
+
import type { MarkdownGeneratorPort } from "./markdown-generator.port";
|
|
4
|
+
|
|
5
|
+
export class MarkdownGeneratorMarkedAdapter implements MarkdownGeneratorPort {
|
|
6
|
+
private readonly instance: Marked;
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
this.instance = new Marked();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async generate(content: string) {
|
|
13
|
+
return DOMPurify.sanitize(await this.instance.parse(content));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import dns from "dns/promises";
|
|
2
|
+
import * as tools from "@bgord/tools";
|
|
3
|
+
import type { ClockPort } from "../clock.port";
|
|
4
|
+
import * as prereqs from "../prerequisites.service";
|
|
5
|
+
import { Timeout } from "../timeout.service";
|
|
6
|
+
|
|
7
|
+
export class PrerequisiteDNS implements prereqs.Prerequisite {
|
|
8
|
+
readonly kind = "dns";
|
|
9
|
+
readonly label: prereqs.PrerequisiteLabelType;
|
|
10
|
+
readonly enabled?: boolean = true;
|
|
11
|
+
|
|
12
|
+
private readonly hostname: string;
|
|
13
|
+
readonly timeout: tools.Duration;
|
|
14
|
+
|
|
15
|
+
constructor(config: prereqs.PrerequisiteConfigType & { hostname: string; timeout?: tools.Duration }) {
|
|
16
|
+
this.label = config.label;
|
|
17
|
+
this.enabled = config.enabled === undefined ? true : config.enabled;
|
|
18
|
+
|
|
19
|
+
this.hostname = config.hostname;
|
|
20
|
+
this.timeout = config.timeout ?? tools.Duration.Seconds(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async verify(clock: ClockPort): Promise<prereqs.VerifyOutcome> {
|
|
24
|
+
const stopwatch = new tools.Stopwatch(clock.now());
|
|
25
|
+
|
|
26
|
+
if (!this.enabled) return prereqs.Verification.undetermined(stopwatch.stop());
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await Timeout.run(dns.lookup(this.hostname), this.timeout);
|
|
30
|
+
|
|
31
|
+
return prereqs.Verification.success(stopwatch.stop());
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return prereqs.Verification.failure(stopwatch.stop(), error as Error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|