@bgord/bun 1.21.7 → 1.21.9
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/alert-channel-composite.adapter.js +1 -1
- package/dist/alert-channel-composite.adapter.js.map +1 -1
- package/dist/cache-repository-redis.adapter.js.map +1 -1
- package/dist/command-envelope.d.ts +4 -4
- package/dist/correlation-id.vo.d.ts +1 -1
- package/dist/correlation-id.vo.d.ts.map +1 -1
- package/dist/crypto-aes-gcm.service.d.ts +2 -2
- package/dist/crypto-aes-gcm.service.d.ts.map +1 -1
- package/dist/crypto-aes-gcm.service.js +2 -2
- package/dist/crypto-aes-gcm.service.js.map +1 -1
- package/dist/crypto-key-provider-file.adapter.d.ts.map +1 -1
- package/dist/crypto-key-provider-file.adapter.js +4 -1
- package/dist/crypto-key-provider-file.adapter.js.map +1 -1
- package/dist/crypto-key-provider-memory.adapter.js.map +1 -1
- package/dist/encryption-iv.vo.d.ts +1 -1
- package/dist/encryption-iv.vo.d.ts.map +1 -1
- package/dist/encryption-key.vo.d.ts +1 -1
- package/dist/encryption-key.vo.d.ts.map +1 -1
- package/dist/event-envelope.d.ts +2 -2
- package/dist/healthcheck-hono.handler.d.ts +1 -67
- package/dist/healthcheck-hono.handler.d.ts.map +1 -1
- package/dist/healthcheck-hono.handler.js +2 -2
- package/dist/healthcheck-hono.handler.js.map +1 -1
- package/dist/id-provider-crypto.adapter.d.ts +1 -1
- package/dist/id-provider-crypto.adapter.d.ts.map +1 -1
- package/dist/id-provider-crypto.adapter.js +3 -1
- package/dist/id-provider-crypto.adapter.js.map +1 -1
- package/dist/job-envelope.d.ts +2 -2
- package/dist/job-registry.adapter.js.map +1 -1
- package/dist/languages.vo.js +1 -1
- package/dist/languages.vo.js.map +1 -1
- package/dist/liveness-hono.handler.d.ts +1 -3
- package/dist/liveness-hono.handler.d.ts.map +1 -1
- package/dist/liveness-hono.handler.js +2 -2
- package/dist/liveness-hono.handler.js.map +1 -1
- package/dist/message-bus-with-logger.adapter.d.ts.map +1 -1
- package/dist/message-bus-with-logger.adapter.js.map +1 -1
- package/dist/modules/history/events/HISTORY_CLEARED_EVENT.d.ts +3 -3
- package/dist/modules/history/events/HISTORY_POPULATED_EVENT.d.ts +8 -6
- package/dist/modules/history/events/HISTORY_POPULATED_EVENT.d.ts.map +1 -1
- package/dist/modules/history/value-objects/history-id.d.ts +3 -1
- package/dist/modules/history/value-objects/history-id.d.ts.map +1 -1
- package/dist/modules/history/value-objects/history-id.js +3 -1
- package/dist/modules/history/value-objects/history-id.js.map +1 -1
- package/dist/modules/history/value-objects/history-operation.d.ts +2 -1
- package/dist/modules/history/value-objects/history-operation.d.ts.map +1 -1
- package/dist/modules/history/value-objects/history-operation.js +3 -1
- package/dist/modules/history/value-objects/history-operation.js.map +1 -1
- package/dist/modules/history/value-objects/history-payload.d.ts +10 -4
- package/dist/modules/history/value-objects/history-payload.d.ts.map +1 -1
- package/dist/modules/history/value-objects/history-payload.js +6 -2
- package/dist/modules/history/value-objects/history-payload.js.map +1 -1
- package/dist/modules/history/value-objects/history-subject.d.ts +1 -1
- package/dist/modules/history/value-objects/history-subject.d.ts.map +1 -1
- package/dist/modules/history/value-objects/history-subject.js +3 -1
- package/dist/modules/history/value-objects/history-subject.js.map +1 -1
- package/dist/modules/history/value-objects/history.d.ts +14 -10
- package/dist/modules/history/value-objects/history.d.ts.map +1 -1
- package/dist/modules/preferences/commands/SET_USER_LANGUAGE_COMMAND.d.ts +3 -3
- package/dist/modules/preferences/events/USER_LANGUAGE_SET_EVENT.d.ts +3 -3
- package/dist/modules/system/events/HOUR_HAS_PASSED_EVENT.d.ts +2 -2
- package/dist/modules/system/events/MINUTE_HAS_PASSED_EVENT.d.ts +2 -2
- package/dist/modules/system/events/SECURITY_VIOLATION_DETECTED_EVENT.d.ts +3 -3
- package/dist/modules/system/jobs/SEND_EMAIL_JOB.d.ts +2 -2
- package/dist/readiness-hono.handler.d.ts +1 -4
- package/dist/readiness-hono.handler.d.ts.map +1 -1
- package/dist/readiness-hono.handler.js +2 -2
- package/dist/readiness-hono.handler.js.map +1 -1
- package/dist/request-context-hono.adapter.d.ts.map +1 -1
- package/dist/request-context-hono.adapter.js +10 -0
- package/dist/request-context-hono.adapter.js.map +1 -1
- package/dist/request-context.port.d.ts +6 -0
- package/dist/request-context.port.d.ts.map +1 -1
- package/dist/shield-maintenance-hono.strategy.js +1 -1
- package/dist/shield-maintenance-hono.strategy.js.map +1 -1
- package/dist/shield-security-hono.strategy.d.ts.map +1 -1
- package/dist/shield-security-hono.strategy.js +4 -4
- package/dist/shield-security-hono.strategy.js.map +1 -1
- package/dist/smtp-port.vo.d.ts +2 -2
- package/dist/smtp-port.vo.d.ts.map +1 -1
- package/dist/smtp-port.vo.js +2 -1
- package/dist/smtp-port.vo.js.map +1 -1
- package/dist/translations-hono.handler.js +1 -1
- package/dist/translations-hono.handler.js.map +1 -1
- package/dist/uuid.vo.d.ts +1 -1
- package/dist/uuid.vo.d.ts.map +1 -1
- package/dist/uuid.vo.js +1 -1
- package/dist/uuid.vo.js.map +1 -1
- package/package.json +10 -10
- package/src/alert-channel-composite.adapter.ts +1 -1
- package/src/cache-repository-redis.adapter.ts +1 -1
- package/src/crypto-aes-gcm.service.ts +8 -12
- package/src/crypto-key-provider-file.adapter.ts +4 -7
- package/src/crypto-key-provider-memory.adapter.ts +1 -1
- package/src/encryption-iv.vo.ts +1 -1
- package/src/encryption-key.vo.ts +1 -1
- package/src/healthcheck-hono.handler.ts +2 -2
- package/src/id-provider-crypto.adapter.ts +3 -2
- package/src/job-registry.adapter.ts +1 -1
- package/src/languages.vo.ts +1 -1
- package/src/liveness-hono.handler.ts +2 -2
- package/src/message-bus-with-logger.adapter.ts +2 -2
- package/src/modules/history/value-objects/history-id.ts +5 -1
- package/src/modules/history/value-objects/history-operation.ts +4 -0
- package/src/modules/history/value-objects/history-payload.ts +11 -1
- package/src/modules/history/value-objects/history-subject.ts +2 -0
- package/src/readiness-hono.handler.ts +2 -2
- package/src/request-context-hono.adapter.ts +9 -0
- package/src/request-context.port.ts +5 -0
- package/src/shield-maintenance-hono.strategy.ts +1 -1
- package/src/shield-security-hono.strategy.ts +4 -5
- package/src/smtp-port.vo.ts +2 -2
- package/src/translations-hono.handler.ts +1 -1
- package/src/uuid.vo.ts +1 -1
package/src/encryption-iv.vo.ts
CHANGED
package/src/encryption-key.vo.ts
CHANGED
|
@@ -16,10 +16,10 @@ export class HealthcheckHonoHandler implements HandlerHonoPort {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
handle() {
|
|
19
|
-
return factory.createHandlers(async (
|
|
19
|
+
return factory.createHandlers(async () => {
|
|
20
20
|
const healthcheck = await this.handler.check();
|
|
21
21
|
|
|
22
|
-
return
|
|
22
|
+
return Response.json(healthcheck, { status: healthcheck.code });
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import type { IdProviderPort } from "./id-provider.port";
|
|
2
|
-
import type
|
|
3
|
+
import { UUID, type UUIDType } from "./uuid.vo";
|
|
3
4
|
|
|
4
5
|
export class IdProviderCryptoAdapter implements IdProviderPort {
|
|
5
6
|
generate(): UUIDType {
|
|
6
|
-
return crypto.randomUUID();
|
|
7
|
+
return v.parse(UUID, crypto.randomUUID());
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -53,6 +53,6 @@ export class JobRegistryAdapter<Job extends GenericJob> implements JobRegistryPo
|
|
|
53
53
|
const entry = this.map.get(name);
|
|
54
54
|
if (!entry) throw new Error(JobRegistryAdapterError.UnknownJob);
|
|
55
55
|
|
|
56
|
-
return entry.handler
|
|
56
|
+
return entry.handler;
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/languages.vo.ts
CHANGED
|
@@ -8,10 +8,10 @@ export class LivenessHonoHandler implements HandlerHonoPort {
|
|
|
8
8
|
private readonly handler = new LivenessHandler();
|
|
9
9
|
|
|
10
10
|
handle() {
|
|
11
|
-
return factory.createHandlers(async (
|
|
11
|
+
return factory.createHandlers(async () => {
|
|
12
12
|
const { headers, ...body } = this.handler.execute();
|
|
13
13
|
|
|
14
|
-
return
|
|
14
|
+
return Response.json(body, { status: 200, headers });
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CorrelationStorage } from "./correlation-storage.service";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LoggerPort } from "./logger.port";
|
|
3
3
|
import type { Message, ToMessageMap } from "./message.types";
|
|
4
4
|
import type { MessageBusPort } from "./message-bus.port";
|
|
5
5
|
|
|
@@ -13,7 +13,7 @@ export class MessageBusWithLoggerAdapter<Messages extends Message> implements Me
|
|
|
13
13
|
async emit<M extends Messages>(message: M): Promise<void> {
|
|
14
14
|
this.deps.Logger.info({
|
|
15
15
|
message: `${message.name} emitted`,
|
|
16
|
-
metadata: message
|
|
16
|
+
metadata: message,
|
|
17
17
|
correlationId: CorrelationStorage.get(),
|
|
18
18
|
...this.base,
|
|
19
19
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { UUID } from "../../../uuid.vo";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
export const HistoryId = v.pipe(UUID, v.brand("HistoryId"));
|
|
6
|
+
|
|
7
|
+
export type HistoryIdType = v.InferOutput<typeof HistoryId>;
|
|
@@ -10,4 +10,8 @@ export const HistoryOperation = v.pipe(
|
|
|
10
10
|
v.string(HistoryOperationError.Type),
|
|
11
11
|
v.minLength(1, HistoryOperationError.Empty),
|
|
12
12
|
v.maxLength(128, HistoryOperationError.TooLong),
|
|
13
|
+
// Stryker disable next-line StringLiteral
|
|
14
|
+
v.brand("HistoryOperation"),
|
|
13
15
|
);
|
|
16
|
+
|
|
17
|
+
export type HistoryOperationType = v.InferOutput<typeof HistoryOperation>;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
|
-
export const HistoryPayload = v.
|
|
3
|
+
export const HistoryPayload = v.pipe(
|
|
4
|
+
v.record(v.string(), v.unknown()),
|
|
5
|
+
// Stryker disable next-line StringLiteral
|
|
6
|
+
v.brand("HistoryPayload"),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export type HistoryPayloadType = v.InferOutput<typeof HistoryPayload>;
|
|
4
10
|
|
|
5
11
|
export const HistoryPayloadParsedError = {
|
|
6
12
|
NotSerializable: "history.payload.parsed.not.serializable",
|
|
@@ -18,4 +24,8 @@ export const HistoryPayloadParsed = v.pipe(
|
|
|
18
24
|
}
|
|
19
25
|
}, HistoryPayloadParsedError.NotSerializable),
|
|
20
26
|
v.transform((value) => JSON.stringify(value)),
|
|
27
|
+
// Stryker disable next-line StringLiteral
|
|
28
|
+
v.brand("HistoryPayloadParsed"),
|
|
21
29
|
);
|
|
30
|
+
|
|
31
|
+
export type HistoryPayloadParsedType = v.InferOutput<typeof HistoryPayloadParsed>;
|
|
@@ -10,6 +10,8 @@ export const HistorySubject = v.pipe(
|
|
|
10
10
|
v.string(HistorySubjectError.Type),
|
|
11
11
|
v.minLength(1, HistorySubjectError.Empty),
|
|
12
12
|
v.maxLength(128, HistorySubjectError.TooLong),
|
|
13
|
+
// Stryker disable next-line StringLiteral
|
|
14
|
+
v.brand("HistorySubject"),
|
|
13
15
|
);
|
|
14
16
|
|
|
15
17
|
export type HistorySubjectType = v.InferOutput<typeof HistorySubject>;
|
|
@@ -12,10 +12,10 @@ export class ReadinessHonoHandler implements HandlerHonoPort {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
handle() {
|
|
15
|
-
return factory.createHandlers(async (
|
|
15
|
+
return factory.createHandlers(async () => {
|
|
16
16
|
const result = await this.handler.check();
|
|
17
17
|
|
|
18
|
-
return
|
|
18
|
+
return Response.json(result.details, { status: result.code, headers: result.headers });
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -3,7 +3,9 @@ import * as tools from "@bgord/tools";
|
|
|
3
3
|
import type { Context } from "hono";
|
|
4
4
|
import { getConnInfo } from "hono/bun";
|
|
5
5
|
import { getCookie } from "hono/cookie";
|
|
6
|
+
import { HTTPException } from "hono/http-exception";
|
|
6
7
|
import type { RequestContext } from "./request-context.port";
|
|
8
|
+
import { ShieldAuthStrategyError } from "./shield-auth.strategy";
|
|
7
9
|
|
|
8
10
|
export class RequestContextHonoAdapter implements RequestContext {
|
|
9
11
|
readonly request: RequestContext["request"];
|
|
@@ -49,6 +51,13 @@ export class RequestContextHonoAdapter implements RequestContext {
|
|
|
49
51
|
|
|
50
52
|
this.identity = {
|
|
51
53
|
userId: () => context.get("user")?.id,
|
|
54
|
+
authenticatedUserId: () => {
|
|
55
|
+
const user = context.get("user");
|
|
56
|
+
|
|
57
|
+
if (user === undefined) throw new Error(ShieldAuthStrategyError.NotAttached);
|
|
58
|
+
if (user === null) throw new HTTPException(401, { message: ShieldAuthStrategyError.Rejected });
|
|
59
|
+
return user.id;
|
|
60
|
+
},
|
|
52
61
|
ip: () =>
|
|
53
62
|
context.req.header("x-real-ip") ||
|
|
54
63
|
context.req.header("x-forwarded-for")?.split(",")[0]?.trim() ||
|
|
@@ -21,6 +21,7 @@ export interface RequestContext {
|
|
|
21
21
|
|
|
22
22
|
readonly identity: {
|
|
23
23
|
userId(): UUIDType | undefined;
|
|
24
|
+
authenticatedUserId(): UUIDType;
|
|
24
25
|
ip(): string | undefined;
|
|
25
26
|
remoteIp(): string | undefined;
|
|
26
27
|
ua(): string | undefined;
|
|
@@ -93,6 +94,10 @@ export interface HasIdentityUserId {
|
|
|
93
94
|
readonly identity: { userId(): UUIDType | undefined };
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
export interface HasIdentityAuthenticatedUserId {
|
|
98
|
+
readonly identity: { authenticatedUserId(): UUIDType };
|
|
99
|
+
}
|
|
100
|
+
|
|
96
101
|
export interface HasIdentityIp {
|
|
97
102
|
readonly identity: { ip(): string | undefined };
|
|
98
103
|
}
|
|
@@ -20,7 +20,7 @@ export class ShieldMaintenanceHonoStrategy implements MiddlewareHonoPort {
|
|
|
20
20
|
|
|
21
21
|
if (!maintenance.enabled) return next();
|
|
22
22
|
|
|
23
|
-
return
|
|
23
|
+
return Response.json(maintenance.body, { status: maintenance.code, headers: maintenance.headers });
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { MiddlewareHandler } from "hono";
|
|
2
|
-
import type { ContentfulStatusCode } from "hono/utils/http-status";
|
|
3
2
|
import type { MiddlewareHonoPort } from "./middleware-hono.port";
|
|
4
3
|
import { RequestContextHonoAdapter } from "./request-context-hono.adapter";
|
|
5
4
|
import type { SecurityPolicy } from "./security-policy.vo";
|
|
@@ -34,10 +33,10 @@ export class ShieldSecurityHonoStrategy implements MiddlewareHonoPort {
|
|
|
34
33
|
return next();
|
|
35
34
|
|
|
36
35
|
case "deny":
|
|
37
|
-
return
|
|
36
|
+
return new Response(action.reason, { status: action.response.status });
|
|
38
37
|
|
|
39
38
|
case "mirage":
|
|
40
|
-
return
|
|
39
|
+
return Response.json({}, { status: action.response.status });
|
|
41
40
|
|
|
42
41
|
case "delay": {
|
|
43
42
|
await this.deps.Sleeper.wait(action.duration);
|
|
@@ -47,10 +46,10 @@ export class ShieldSecurityHonoStrategy implements MiddlewareHonoPort {
|
|
|
47
46
|
return next();
|
|
48
47
|
|
|
49
48
|
case "deny":
|
|
50
|
-
return
|
|
49
|
+
return new Response(action.after.reason, { status: action.after.response.status });
|
|
51
50
|
|
|
52
51
|
case "mirage":
|
|
53
|
-
return
|
|
52
|
+
return Response.json({}, { status: action.after.response.status });
|
|
54
53
|
|
|
55
54
|
default:
|
|
56
55
|
throw new Error(ShieldSecurityHonoStrategyError.Unhandled);
|
package/src/smtp-port.vo.ts
CHANGED
package/src/uuid.vo.ts
CHANGED
|
@@ -2,6 +2,6 @@ import * as v from "valibot";
|
|
|
2
2
|
|
|
3
3
|
export const UUIDError = { Type: "uuid.type" } as const;
|
|
4
4
|
|
|
5
|
-
export const UUID = v.pipe(v.string(UUIDError.Type), v.uuid(UUIDError.Type));
|
|
5
|
+
export const UUID = v.pipe(v.string(UUIDError.Type), v.uuid(UUIDError.Type), v.brand("UUID"));
|
|
6
6
|
|
|
7
7
|
export type UUIDType = v.InferOutput<typeof UUID>;
|