@bgord/bun 1.4.2 → 1.4.3
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/encryption-bun.adapter.d.ts +4 -2
- package/dist/encryption-bun.adapter.d.ts.map +1 -1
- package/dist/encryption-bun.adapter.js +11 -0
- package/dist/encryption-bun.adapter.js.map +1 -1
- package/dist/encryption-noop.adapter.d.ts +4 -2
- package/dist/encryption-noop.adapter.d.ts.map +1 -1
- package/dist/encryption-noop.adapter.js +3 -0
- package/dist/encryption-noop.adapter.js.map +1 -1
- package/dist/encryption.port.d.ts +1 -0
- package/dist/encryption.port.d.ts.map +1 -1
- package/dist/prerequisites/node.js +1 -1
- package/dist/prerequisites/node.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/encryption-bun.adapter.ts +20 -0
- package/src/encryption-noop.adapter.ts +5 -0
- package/src/encryption.port.ts +1 -0
- package/src/prerequisites/node.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/bun",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@axiomhq/winston": "1.3.1",
|
|
41
|
-
"@bgord/tools": "1.1.
|
|
41
|
+
"@bgord/tools": "1.1.18",
|
|
42
42
|
"@hono/ua-blocker": "0.1.21",
|
|
43
43
|
"better-auth": "1.4.6",
|
|
44
44
|
"croner": "9.1.0",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
1
2
|
import type { CryptoKeyProviderPort } from "./crypto-key-provider.port";
|
|
2
3
|
import type { EncryptionPort, EncryptionRecipe } from "./encryption.port";
|
|
3
4
|
import { EncryptionIV } from "./encryption-iv.vo";
|
|
@@ -53,4 +54,23 @@ export class EncryptionBunAdapter implements EncryptionPort {
|
|
|
53
54
|
|
|
54
55
|
return recipe.output;
|
|
55
56
|
}
|
|
57
|
+
|
|
58
|
+
async view(input: tools.FilePathRelative | tools.FilePathAbsolute) {
|
|
59
|
+
const key = await this.deps.CryptoKeyProvider.get();
|
|
60
|
+
|
|
61
|
+
const bytes = new Uint8Array(await Bun.file(input.get()).arrayBuffer());
|
|
62
|
+
if (bytes.length < EncryptionIV.LENGTH + 1) throw new Error(EncryptionBunAdapterError.InvalidPayload);
|
|
63
|
+
|
|
64
|
+
const iv = bytes.subarray(0, EncryptionIV.LENGTH);
|
|
65
|
+
const ivBuffer = iv.buffer.slice(iv.byteOffset, iv.byteOffset + iv.byteLength);
|
|
66
|
+
|
|
67
|
+
const ciphertext = bytes.subarray(EncryptionIV.LENGTH);
|
|
68
|
+
|
|
69
|
+
const ciphertextBuffer = ciphertext.buffer.slice(
|
|
70
|
+
ciphertext.byteOffset,
|
|
71
|
+
ciphertext.byteOffset + ciphertext.byteLength,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return crypto.subtle.decrypt({ name: "AES-GCM", iv: ivBuffer }, key, ciphertextBuffer);
|
|
75
|
+
}
|
|
56
76
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
1
2
|
import type { EncryptionPort, EncryptionRecipe } from "./encryption.port";
|
|
2
3
|
|
|
3
4
|
export class EncryptionNoopAdapter implements EncryptionPort {
|
|
@@ -8,4 +9,8 @@ export class EncryptionNoopAdapter implements EncryptionPort {
|
|
|
8
9
|
async decrypt(recipe: EncryptionRecipe) {
|
|
9
10
|
return recipe.output;
|
|
10
11
|
}
|
|
12
|
+
|
|
13
|
+
async view(_input: tools.FilePathRelative | tools.FilePathAbsolute) {
|
|
14
|
+
return new TextEncoder().encode("noop").buffer;
|
|
15
|
+
}
|
|
11
16
|
}
|
package/src/encryption.port.ts
CHANGED
|
@@ -8,4 +8,5 @@ export type EncryptionRecipe = {
|
|
|
8
8
|
export interface EncryptionPort {
|
|
9
9
|
encrypt(recipe: EncryptionRecipe): Promise<tools.FilePathRelative | tools.FilePathAbsolute>;
|
|
10
10
|
decrypt(recipe: EncryptionRecipe): Promise<tools.FilePathRelative | tools.FilePathAbsolute>;
|
|
11
|
+
view(input: tools.FilePathRelative | tools.FilePathAbsolute): Promise<ArrayBuffer>;
|
|
11
12
|
}
|
|
@@ -24,7 +24,7 @@ export class PrerequisiteNode implements prereqs.Prerequisite {
|
|
|
24
24
|
if (!this.enabled) return prereqs.Verification.undetermined(stopwatch.stop());
|
|
25
25
|
|
|
26
26
|
try {
|
|
27
|
-
const current = tools.PackageVersion.
|
|
27
|
+
const current = tools.PackageVersion.fromVersionString(this.current);
|
|
28
28
|
|
|
29
29
|
if (current.isGreaterThanOrEqual(this.version)) return prereqs.Verification.success(stopwatch.stop());
|
|
30
30
|
return prereqs.Verification.failure(stopwatch.stop(), { message: `Version: ${this.current}` });
|