@bgord/bun 1.5.2 → 1.5.4
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/crypto-key-provider-file.adapter.d.ts +1 -1
- package/dist/crypto-key-provider-file.adapter.d.ts.map +1 -1
- package/dist/crypto-key-provider-file.adapter.js +2 -1
- package/dist/crypto-key-provider-file.adapter.js.map +1 -1
- package/dist/encryption-bun.adapter.d.ts.map +1 -1
- package/dist/encryption-bun.adapter.js +4 -2
- package/dist/encryption-bun.adapter.js.map +1 -1
- package/dist/environment-loader-encrypted.adapter.d.ts +2 -2
- package/dist/environment-loader-encrypted.adapter.d.ts.map +1 -1
- package/dist/environment-loader-encrypted.adapter.js +2 -4
- package/dist/environment-loader-encrypted.adapter.js.map +1 -1
- package/dist/environment-loader-process.adapter.d.ts +3 -4
- package/dist/environment-loader-process.adapter.d.ts.map +1 -1
- package/dist/environment-loader-process.adapter.js +6 -3
- package/dist/environment-loader-process.adapter.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/crypto-key-provider-file.adapter.ts +3 -2
- package/src/encryption-bun.adapter.ts +6 -2
- package/src/environment-loader-encrypted.adapter.ts +6 -3
- package/src/environment-loader-process.adapter.ts +9 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/bun",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@axiomhq/winston": "1.3.1",
|
|
42
|
-
"@bgord/tools": "1.2.
|
|
42
|
+
"@bgord/tools": "1.2.2",
|
|
43
43
|
"@hono/ua-blocker": "0.1.22",
|
|
44
44
|
"better-auth": "1.4.7",
|
|
45
45
|
"croner": "9.1.0",
|
|
@@ -7,7 +7,7 @@ export const CryptoKeyProviderFileAdapterError = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export class CryptoKeyProviderFileAdapter implements CryptoKeyProviderPort {
|
|
10
|
-
constructor(private readonly path: tools.FilePathAbsolute) {}
|
|
10
|
+
constructor(private readonly path: tools.FilePathAbsolute | tools.FilePathRelative) {}
|
|
11
11
|
|
|
12
12
|
async get() {
|
|
13
13
|
const file = Bun.file(this.path.get());
|
|
@@ -15,7 +15,8 @@ export class CryptoKeyProviderFileAdapter implements CryptoKeyProviderPort {
|
|
|
15
15
|
|
|
16
16
|
if (!exists) throw new Error(CryptoKeyProviderFileAdapterError.MissingFile);
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const content = await file.text();
|
|
19
|
+
const encryptionKey = EncryptionKey.fromString(content.trim());
|
|
19
20
|
|
|
20
21
|
return crypto.subtle.importKey(
|
|
21
22
|
"raw",
|
|
@@ -20,7 +20,9 @@ export class EncryptionBunAdapter implements EncryptionPort {
|
|
|
20
20
|
const iv = EncryptionIV.generate();
|
|
21
21
|
|
|
22
22
|
const file = Bun.file(recipe.input.get());
|
|
23
|
-
|
|
23
|
+
const exists = await file.exists();
|
|
24
|
+
|
|
25
|
+
if (!exists) throw new Error(EncryptionBunAdapterError.MissingFile);
|
|
24
26
|
|
|
25
27
|
const plaintext = await file.arrayBuffer();
|
|
26
28
|
|
|
@@ -55,7 +57,9 @@ export class EncryptionBunAdapter implements EncryptionPort {
|
|
|
55
57
|
const key = await this.deps.CryptoKeyProvider.get();
|
|
56
58
|
|
|
57
59
|
const file = Bun.file(input.get());
|
|
58
|
-
|
|
60
|
+
const exists = await file.exists();
|
|
61
|
+
|
|
62
|
+
if (!exists) throw new Error(EncryptionBunAdapterError.MissingFile);
|
|
59
63
|
|
|
60
64
|
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
61
65
|
|
|
@@ -11,13 +11,16 @@ export class EnvironmentLoaderEncryptedAdapter<Schema extends z.ZodObject<any>>
|
|
|
11
11
|
implements EnvironmentLoaderPort<Schema>
|
|
12
12
|
{
|
|
13
13
|
constructor(
|
|
14
|
-
private readonly config: {
|
|
15
|
-
|
|
14
|
+
private readonly config: {
|
|
15
|
+
type: NodeEnvironmentEnum;
|
|
16
|
+
Schema: Schema;
|
|
17
|
+
path: tools.FilePathAbsolute | tools.FilePathRelative;
|
|
18
|
+
},
|
|
16
19
|
private readonly deps: Dependencies,
|
|
17
20
|
) {}
|
|
18
21
|
|
|
19
22
|
async load() {
|
|
20
|
-
const file = await this.deps.Encryption.view(this.path);
|
|
23
|
+
const file = await this.deps.Encryption.view(this.config.path);
|
|
21
24
|
const content = new TextDecoder().decode(file);
|
|
22
25
|
|
|
23
26
|
return Object.freeze({ ...this.config.Schema.parse(parse(content)), type: this.config.type });
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import type { z } from "zod/v4";
|
|
2
2
|
import type { NodeEnvironmentEnum } from "../src/node-env.vo";
|
|
3
|
-
import type { EnvironmentLoaderPort } from "./environment-loader.port";
|
|
3
|
+
import type { EnvironmentLoaderPort, EnvironmentResultType } from "./environment-loader.port";
|
|
4
4
|
|
|
5
5
|
export class EnvironmentLoaderProcessAdapter<Schema extends z.ZodObject<any>>
|
|
6
6
|
implements EnvironmentLoaderPort<Schema>
|
|
7
7
|
{
|
|
8
|
+
private cached: Readonly<EnvironmentResultType<Schema>> | null = null;
|
|
9
|
+
|
|
8
10
|
constructor(
|
|
9
11
|
private readonly config: { type: NodeEnvironmentEnum; Schema: Schema },
|
|
10
12
|
private env: NodeJS.ProcessEnv,
|
|
11
13
|
) {}
|
|
12
14
|
|
|
13
15
|
async load() {
|
|
16
|
+
if (this.cached) return this.cached;
|
|
17
|
+
|
|
14
18
|
const result = this.config.Schema.parse(this.env);
|
|
15
19
|
|
|
16
|
-
for (const key of Object.keys(result))
|
|
17
|
-
|
|
18
|
-
}
|
|
20
|
+
for (const key of Object.keys(result)) delete process.env[key];
|
|
21
|
+
|
|
22
|
+
this.cached = Object.freeze({ ...result, type: this.config.type });
|
|
19
23
|
|
|
20
|
-
return
|
|
24
|
+
return this.cached;
|
|
21
25
|
}
|
|
22
26
|
}
|