Skip to content

Commit 83138b8

Browse files
committed
chore: testing
1 parent e66c085 commit 83138b8

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,4 @@ obj/
149149
bin/
150150
artifacts/
151151
.nuget/packages/
152+
/tmp

index.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import fs from 'node:fs/promises';
2-
31
let decryptDotnet, decryptWasmJava, decryptJsJava;
42

53
export async function decrypt(key, data, options) {
@@ -13,17 +11,9 @@ export async function decrypt(key, data, options) {
1311
if (!decryptWasmJava) {
1412
decryptWasmJava = import('./dist/teavm/lib.wasm-runtime.js').then(
1513
async ({ load }) =>
16-
load(
17-
await fs.readFile(
18-
new URL(`./dist/teavm/lib.wasm`, import.meta.url),
19-
),
20-
{
21-
memory: {
22-
shared: true,
23-
},
24-
nodejs: true,
25-
},
26-
).then((teavm) => teavm.exports),
14+
load(`${import.meta.dirname}/dist/teavm/lib.wasm`).then(
15+
(teavm) => teavm.exports,
16+
),
2717
);
2818
}
2919
return (await decryptWasmJava).decrypt(key, data);

lib/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515

1616
dependencies {
1717
implementation(libs.bouncycastle.bcpg)
18-
implementation(project(":tools:teavm-plugin"))
18+
// implementation(project(":tools:teavm-plugin"))
1919
teavm(teavm.libs.jsoApis)
2020
}
2121

@@ -34,8 +34,8 @@ teavm.wasmGC {
3434
mainClass = "com.github.renovatebot.Main"
3535
outputDir = file("../dist")
3636
relativePathInOutputDir = "teavm"
37-
strict = true
38-
importedWasmMemory = true
37+
// strict = true
38+
// importedWasmMemory = true
3939
// disassembly = true
4040
obfuscated = false
4141
modularRuntime = true
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package com.github.renovatebot;
22

3+
import java.io.ByteArrayInputStream;
4+
import java.io.IOException;
35
import java.nio.charset.StandardCharsets;
46

7+
import org.bouncycastle.bcpg.ArmoredInputStream;
8+
import org.bouncycastle.openpgp.PGPException;
59
import org.teavm.jso.JSExport;
610

711
public final class Main {
@@ -11,9 +15,13 @@ private Main() {
1115
}
1216

1317
@JSExport
14-
public static String decrypt(String key, String msg) {
15-
final var bytes = "test".getBytes(StandardCharsets.US_ASCII);
18+
public static String decrypt(String key, String msg) throws IOException, PGPException {
19+
final var builder = ArmoredInputStream.builder().setIgnoreCRC(true);
20+
final var bytes = msg.getBytes(StandardCharsets.UTF_8);
21+
final var input = builder.build(new ByteArrayInputStream(bytes));
1622

17-
return "test" + bytes.length;
23+
input.close();
24+
25+
return "test -> " + bytes.length;
1826
}
1927
}

test/teavm/wasm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { decrypt } from '../../index.js';
44
setTimeout(() => {
55
console.error('Forcing exit...');
66
process.abort();
7-
}, 15 * 1000);
7+
}, 5 * 1000).unref();
88

99
const msg =
1010
'wcFMAw+4H7SgaqGOAQ/+Lz6RlbEymbnmMhrktuaGiDPWRNPEQFuMRwwYM6/B/r0JMZa9tskAA5RpyYKxGmJJeuRtlA8GkTw02GoZomlJf/KXJZ95FwSbkXMSRJRD8LJ2402Hw2TaOTaSvfamESnm8zhNo8cok627nkKQkyrpk64heVlU5LIbO2+UgYgbiSQjuXZiW+QuJ1hVRjx011FQgEYc59+22yuKYqd8rrni7TrVqhGRlHCAqvNAGjBI4H7uTFh0sP4auunT/JjxTeTkJoNu8KgS/LdrvISpO67TkQziZo9XD5FOzSN7N3e4f8vO4N4fpjgkIDH/9wyEYe0zYz34xMAFlnhZzqrHycRqzBJuMxGqlFQcKWp9IisLMoVJhLrnvbDLuwwcjeqYkhvODjSs7UDKwTE4X4WmvZr0x4kOclOeAAz/pM6oNVnjgWJd9SnYtoa67bZVkne0k6mYjVhosie8v8icijmJ4OyLZUGWnjZCRd/TPkzQUw+B0yvsop9FYGidhCI+4MVx6W5w7SRtCctxVfCjLpmU4kWaBUUJ5YIQ5xm55yxEYuAsQkxOAYDCMFlV8ntWStYwIG1FsBgJX6VPevXuPPMjWiPNedIpJwBH2PLB4blxMfzDYuCeaIqU4daDaEWxxpuFTTK9fLdJKuipwFG6rwE3OuijeSN+2SLszi834DXtUjQdikHSTQG392+oTmZCFPeffLk/OiV2VpdXF3gGL7sr5M9hOWIZ783q0vW1l6nAElZ7UA//kW+L6QRxbnBVTJK5eCmMY6RJmL76zjqC1jQ0FC10';

0 commit comments

Comments
 (0)