@bgord/bun 1.6.0 → 1.6.1
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/client.vo.d.ts +3 -1
- package/dist/client.vo.d.ts.map +1 -1
- package/dist/client.vo.js +8 -1
- package/dist/client.vo.js.map +1 -1
- package/dist/http-logger.middleware.js +2 -2
- package/dist/http-logger.middleware.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{visitor-id-hash.adapter.d.ts → visitor-id-client.adapter.d.ts} +2 -2
- package/dist/visitor-id-client.adapter.d.ts.map +1 -0
- package/dist/{visitor-id-hash.adapter.js → visitor-id-client.adapter.js} +2 -2
- package/dist/visitor-id-client.adapter.js.map +1 -0
- package/package.json +1 -1
- package/readme.md +1 -3
- package/src/client.vo.ts +15 -1
- package/src/http-logger.middleware.ts +2 -2
- package/src/index.ts +1 -3
- package/src/{visitor-id-hash.adapter.ts → visitor-id-client.adapter.ts} +1 -1
- package/dist/client-from-hono.adapter.d.ts +0 -6
- package/dist/client-from-hono.adapter.d.ts.map +0 -1
- package/dist/client-from-hono.adapter.js +0 -11
- package/dist/client-from-hono.adapter.js.map +0 -1
- package/dist/visitor-id-hash-hono.adapter.d.ts +0 -13
- package/dist/visitor-id-hash-hono.adapter.d.ts.map +0 -1
- package/dist/visitor-id-hash-hono.adapter.js +0 -12
- package/dist/visitor-id-hash-hono.adapter.js.map +0 -1
- package/dist/visitor-id-hash.adapter.d.ts.map +0 -1
- package/dist/visitor-id-hash.adapter.js.map +0 -1
- package/src/client-from-hono.adapter.ts +0 -16
- package/src/visitor-id-hash-hono.adapter.ts +0 -19
|
@@ -4,11 +4,11 @@ import type { VisitorIdPort } from "./visitor-id.port";
|
|
|
4
4
|
type Dependencies = {
|
|
5
5
|
HashContent: HashContentPort;
|
|
6
6
|
};
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class VisitorIdClientAdapter implements VisitorIdPort {
|
|
8
8
|
private readonly client;
|
|
9
9
|
private readonly deps;
|
|
10
10
|
constructor(client: Client, deps: Dependencies);
|
|
11
11
|
get(): Promise<import("./hash.vo").Hash>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
14
|
-
//# sourceMappingURL=visitor-id-
|
|
14
|
+
//# sourceMappingURL=visitor-id-client.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-id-client.adapter.d.ts","sourceRoot":"","sources":["../src/visitor-id-client.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,sBAAuB,YAAW,aAAa;IAExD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADJ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY;IAG/B,GAAG;CAOV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class VisitorIdClientAdapter {
|
|
2
2
|
client;
|
|
3
3
|
deps;
|
|
4
4
|
constructor(client, deps) {
|
|
@@ -11,4 +11,4 @@ export class VisitorIdHashAdapter {
|
|
|
11
11
|
return this.deps.HashContent.hash(value);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=visitor-id-
|
|
14
|
+
//# sourceMappingURL=visitor-id-client.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-id-client.adapter.js","sourceRoot":"","sources":["../src/visitor-id-client.adapter.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,sBAAsB;IAEd;IACA;IAFnB,YACmB,MAAc,EACd,IAAkB;QADlB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAc;IAClC,CAAC;IAEJ,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAExC,MAAM,KAAK,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -54,7 +54,6 @@ src/
|
|
|
54
54
|
├── certificate-inspector-tls.adapter.ts
|
|
55
55
|
├── certificate-inspector.port.ts
|
|
56
56
|
├── checksum.service.ts
|
|
57
|
-
├── client-from-hono.adapter.ts
|
|
58
57
|
├── client.vo.ts
|
|
59
58
|
├── clock-fixed.adapter.ts
|
|
60
59
|
├── clock-system.adapter.ts
|
|
@@ -277,8 +276,7 @@ src/
|
|
|
277
276
|
├── translations.service.ts
|
|
278
277
|
├── uptime.service.ts
|
|
279
278
|
├── uuid.vo.ts
|
|
280
|
-
├── visitor-id-
|
|
281
|
-
├── visitor-id-hash.adapter.ts
|
|
279
|
+
├── visitor-id-client.adapter.ts
|
|
282
280
|
├── visitor-id.port.ts
|
|
283
281
|
└── weak-etag-extractor.middleware.ts
|
|
284
282
|
```
|
package/src/client.vo.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import { getConnInfo } from "hono/bun";
|
|
3
|
+
|
|
1
4
|
export type ClientIpType = string;
|
|
2
5
|
export type ClientUaType = string;
|
|
3
6
|
export type ClientType = { ip: ClientIpType; ua: ClientUaType };
|
|
@@ -5,10 +8,21 @@ export type ClientType = { ip: ClientIpType; ua: ClientUaType };
|
|
|
5
8
|
export class Client {
|
|
6
9
|
private constructor(private readonly value: ClientType) {}
|
|
7
10
|
|
|
8
|
-
static
|
|
11
|
+
static fromParts(ip: ClientIpType | null | undefined, ua: ClientUaType | null | undefined): Client {
|
|
9
12
|
return new Client({ ip: ip ?? "anon", ua: ua ?? "anon" });
|
|
10
13
|
}
|
|
11
14
|
|
|
15
|
+
static fromHonoContext(context: Context): Client {
|
|
16
|
+
const info = getConnInfo(context);
|
|
17
|
+
|
|
18
|
+
const ip =
|
|
19
|
+
context.req.header("x-real-ip") || context.req.header("x-forwarded-for") || info?.remote?.address;
|
|
20
|
+
|
|
21
|
+
const ua = context.req.header("user-agent");
|
|
22
|
+
|
|
23
|
+
return Client.fromParts(ip, ua);
|
|
24
|
+
}
|
|
25
|
+
|
|
12
26
|
toJSON(): ClientType {
|
|
13
27
|
return this.value;
|
|
14
28
|
}
|
|
@@ -2,7 +2,7 @@ import * as tools from "@bgord/tools";
|
|
|
2
2
|
import { createMiddleware } from "hono/factory";
|
|
3
3
|
import { CacheSourceEnum } from "./cache-resolver.port";
|
|
4
4
|
import { CacheResponse } from "./cache-response.middleware";
|
|
5
|
-
import {
|
|
5
|
+
import { Client } from "./client.vo";
|
|
6
6
|
import type { ClockPort } from "./clock.port";
|
|
7
7
|
import type { LoggerPort } from "./logger.port";
|
|
8
8
|
|
|
@@ -45,7 +45,7 @@ export class HttpLogger {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const correlationId = context.get("requestId");
|
|
48
|
-
const client =
|
|
48
|
+
const client = Client.fromHonoContext(context).toJSON();
|
|
49
49
|
|
|
50
50
|
const httpRequestBeforeMetadata = {
|
|
51
51
|
params: context.req.param(),
|
package/src/index.ts
CHANGED
|
@@ -28,7 +28,6 @@ export * from "./certificate-inspector-noop.adapter";
|
|
|
28
28
|
export * from "./certificate-inspector-tls.adapter";
|
|
29
29
|
export * from "./checksum.service";
|
|
30
30
|
export * from "./client.vo";
|
|
31
|
-
export * from "./client-from-hono.adapter";
|
|
32
31
|
export * from "./clock.port";
|
|
33
32
|
export * from "./clock-fixed.adapter";
|
|
34
33
|
export * from "./clock-system.adapter";
|
|
@@ -197,6 +196,5 @@ export * from "./translations.service";
|
|
|
197
196
|
export * from "./uptime.service";
|
|
198
197
|
export * from "./uuid.vo";
|
|
199
198
|
export * from "./visitor-id.port";
|
|
200
|
-
export * from "./visitor-id-
|
|
201
|
-
export * from "./visitor-id-hash-hono.adapter";
|
|
199
|
+
export * from "./visitor-id-client.adapter";
|
|
202
200
|
export * from "./weak-etag-extractor.middleware";
|
|
@@ -4,7 +4,7 @@ import type { VisitorIdPort } from "./visitor-id.port";
|
|
|
4
4
|
|
|
5
5
|
type Dependencies = { HashContent: HashContentPort };
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class VisitorIdClientAdapter implements VisitorIdPort {
|
|
8
8
|
constructor(
|
|
9
9
|
private readonly client: Client,
|
|
10
10
|
private readonly deps: Dependencies,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-from-hono.adapter.d.ts","sourceRoot":"","sources":["../src/client-from-hono.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,qBAAa,qBAAqB;IAChC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;CAUzC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getConnInfo } from "hono/bun";
|
|
2
|
-
import { Client } from "./client.vo";
|
|
3
|
-
export class ClientFromHonoAdapter {
|
|
4
|
-
static extract(context) {
|
|
5
|
-
const info = getConnInfo(context);
|
|
6
|
-
const ip = context.req.header("x-real-ip") || context.req.header("x-forwarded-for") || info?.remote?.address;
|
|
7
|
-
const ua = context.req.header("user-agent");
|
|
8
|
-
return Client.from(ip, ua);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=client-from-hono.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-from-hono.adapter.js","sourceRoot":"","sources":["../src/client-from-hono.adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,qBAAqB;IAChC,MAAM,CAAC,OAAO,CAAC,OAAgB;QAC7B,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAElC,MAAM,EAAE,GACN,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;QAEpG,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAE5C,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Context } from "hono";
|
|
2
|
-
import type { HashContentPort } from "./hash-content.port";
|
|
3
|
-
import type { VisitorIdPort } from "./visitor-id.port";
|
|
4
|
-
type Dependencies = {
|
|
5
|
-
HashContent: HashContentPort;
|
|
6
|
-
};
|
|
7
|
-
export declare class VisitorIdHashHonoAdapter implements VisitorIdPort {
|
|
8
|
-
private readonly delegate;
|
|
9
|
-
constructor(context: Context, deps: Dependencies);
|
|
10
|
-
get(): Promise<import("./hash.vo").Hash>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=visitor-id-hash-hono.adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-id-hash-hono.adapter.d.ts","sourceRoot":"","sources":["../src/visitor-id-hash-hono.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,wBAAyB,YAAW,aAAa;IAC5D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;gBAEpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;IAI1C,GAAG;CAGV"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ClientFromHonoAdapter } from "./client-from-hono.adapter";
|
|
2
|
-
import { VisitorIdHashAdapter } from "./visitor-id-hash.adapter";
|
|
3
|
-
export class VisitorIdHashHonoAdapter {
|
|
4
|
-
delegate;
|
|
5
|
-
constructor(context, deps) {
|
|
6
|
-
this.delegate = new VisitorIdHashAdapter(ClientFromHonoAdapter.extract(context), deps);
|
|
7
|
-
}
|
|
8
|
-
async get() {
|
|
9
|
-
return this.delegate.get();
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=visitor-id-hash-hono.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-id-hash-hono.adapter.js","sourceRoot":"","sources":["../src/visitor-id-hash-hono.adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAIjE,MAAM,OAAO,wBAAwB;IAClB,QAAQ,CAAuB;IAEhD,YAAY,OAAgB,EAAE,IAAkB;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAoB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-id-hash.adapter.d.ts","sourceRoot":"","sources":["../src/visitor-id-hash.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,KAAK,YAAY,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,CAAC;AAErD,qBAAa,oBAAqB,YAAW,aAAa;IAEtD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADJ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY;IAG/B,GAAG;CAOV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-id-hash.adapter.js","sourceRoot":"","sources":["../src/visitor-id-hash.adapter.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,oBAAoB;IAEZ;IACA;IAFnB,YACmB,MAAc,EACd,IAAkB;QADlB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAc;IAClC,CAAC;IAEJ,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAExC,MAAM,KAAK,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Context } from "hono";
|
|
2
|
-
import { getConnInfo } from "hono/bun";
|
|
3
|
-
import { Client } from "./client.vo";
|
|
4
|
-
|
|
5
|
-
export class ClientFromHonoAdapter {
|
|
6
|
-
static extract(context: Context): Client {
|
|
7
|
-
const info = getConnInfo(context);
|
|
8
|
-
|
|
9
|
-
const ip =
|
|
10
|
-
context.req.header("x-real-ip") || context.req.header("x-forwarded-for") || info?.remote?.address;
|
|
11
|
-
|
|
12
|
-
const ua = context.req.header("user-agent");
|
|
13
|
-
|
|
14
|
-
return Client.from(ip, ua);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Context } from "hono";
|
|
2
|
-
import { ClientFromHonoAdapter } from "./client-from-hono.adapter";
|
|
3
|
-
import type { HashContentPort } from "./hash-content.port";
|
|
4
|
-
import type { VisitorIdPort } from "./visitor-id.port";
|
|
5
|
-
import { VisitorIdHashAdapter } from "./visitor-id-hash.adapter";
|
|
6
|
-
|
|
7
|
-
type Dependencies = { HashContent: HashContentPort };
|
|
8
|
-
|
|
9
|
-
export class VisitorIdHashHonoAdapter implements VisitorIdPort {
|
|
10
|
-
private readonly delegate: VisitorIdHashAdapter;
|
|
11
|
-
|
|
12
|
-
constructor(context: Context, deps: Dependencies) {
|
|
13
|
-
this.delegate = new VisitorIdHashAdapter(ClientFromHonoAdapter.extract(context), deps);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async get() {
|
|
17
|
-
return this.delegate.get();
|
|
18
|
-
}
|
|
19
|
-
}
|