Skip to content

Commit d3276cb

Browse files
committed
chore: change from nomad to k8s
1 parent f446256 commit d3276cb

File tree

7 files changed

+8205
-6247
lines changed

7 files changed

+8205
-6247
lines changed

infrastructure/eid-wallet/src-tauri/gen/apple/eid-wallet.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@
377377
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
378378
CODE_SIGN_ENTITLEMENTS = "eid-wallet_iOS/eid-wallet_iOS.entitlements";
379379
CODE_SIGN_IDENTITY = "iPhone Developer";
380-
DEVELOPMENT_TEAM = 7F2T2WK6DR;
380+
DEVELOPMENT_TEAM = 3FS4B734X5;
381381
ENABLE_BITCODE = NO;
382382
"EXCLUDED_ARCHS[sdk=iphoneos*]" = "arm64-sim x86_64";
383383
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
@@ -430,7 +430,7 @@
430430
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
431431
CODE_SIGN_ENTITLEMENTS = "eid-wallet_iOS/eid-wallet_iOS.entitlements";
432432
CODE_SIGN_IDENTITY = "iPhone Developer";
433-
DEVELOPMENT_TEAM = 7F2T2WK6DR;
433+
DEVELOPMENT_TEAM = 3FS4B734X5;
434434
ENABLE_BITCODE = NO;
435435
"EXCLUDED_ARCHS[sdk=iphoneos*]" = "arm64-sim x86_64";
436436
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;

infrastructure/eid-wallet/src/routes/+layout.svelte

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ onMount(async () => {
5353
showSplashScreen = false;
5454
});
5555
56+
const safeAreaTop = $derived.by(() => parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--safe-top')) || 0);
57+
58+
59+
$effect(() => console.log("top", safeAreaTop))
60+
5661
onNavigate((navigation) => {
5762
if (!document.startViewTransition) return;
5863
@@ -88,10 +93,31 @@ onNavigate((navigation) => {
8893
});
8994
</script>
9095

91-
{#if showSplashScreen}
92-
<SplashScreen />
93-
{:else}
94-
<div class="bg-white h-[100dvh] overflow-scroll">
95-
{@render children?.()}
96-
</div>
97-
{/if}
96+
<main class={`h-[calc(100dvh-${safeAreaTop}px)] overflow-hidden`}>
97+
{#if showSplashScreen}
98+
<SplashScreen />
99+
{:else}
100+
<div class={`bg-white h-[calc(100dvh-${safeAreaTop}px)] overflow-auto`}>
101+
{@render children?.()}
102+
</div>
103+
{/if}
104+
</main>
105+
106+
<style>
107+
:root {
108+
--safe-bottom: env(safe-area-inset-bottom);
109+
--safe-top: env(safe-area-inset-top);
110+
}
111+
112+
body, * {
113+
-webkit-overflow-scrolling: touch; /* keeps momentum scrolling on iOS */
114+
scrollbar-width: none; /* Firefox */
115+
-ms-overflow-style: none; /* IE 10+ */
116+
}
117+
118+
/* Hide scrollbar for WebKit (Chrome, Safari) */
119+
body::-webkit-scrollbar,
120+
*::-webkit-scrollbar {
121+
display: none;
122+
}
123+
</style>

infrastructure/evault-core/src/evault.ts

Lines changed: 84 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { LogService } from "./w3id/log-service";
33
import { GraphQLServer } from "./protocol/graphql-server";
44
import { registerHttpRoutes } from "./http/server";
55
import fastify, {
6-
FastifyInstance,
7-
FastifyRequest,
8-
FastifyReply,
6+
FastifyInstance,
7+
FastifyRequest,
8+
FastifyReply,
99
} from "fastify";
1010
import { renderVoyagerPage } from "graphql-voyager/middleware";
1111
import { createYoga } from "graphql-yoga";
@@ -17,80 +17,89 @@ import { W3ID } from "./w3id/w3id";
1717
dotenv.config({ path: path.resolve(__dirname, "../../../.env") });
1818

1919
class EVault {
20-
server: FastifyInstance;
21-
graphqlServer: GraphQLServer;
22-
logService: LogService;
23-
driver: Driver;
24-
25-
constructor() {
26-
const uri = process.env.NEO4J_URI || "bolt://localhost:7687";
27-
const user = process.env.NEO4J_USER || "neo4j";
28-
const password = process.env.NEO4J_PASSWORD || "neo4j";
29-
30-
if (
31-
!process.env.NEO4J_URI ||
32-
!process.env.NEO4J_USER ||
33-
!process.env.NEO4J_PASSWORD
34-
) {
35-
console.warn(
36-
"Using default Neo4j connection parameters. Set NEO4J_URI, NEO4J_USER, and NEO4J_PASSWORD environment variables for custom configuration."
37-
);
20+
server: FastifyInstance;
21+
graphqlServer: GraphQLServer;
22+
logService: LogService;
23+
driver: Driver;
24+
25+
constructor() {
26+
const uri = process.env.NEO4J_URI || "bolt://localhost:7687";
27+
const user = process.env.NEO4J_USER || "neo4j";
28+
const password = process.env.NEO4J_PASSWORD || "neo4j";
29+
30+
if (
31+
!process.env.NEO4J_URI ||
32+
!process.env.NEO4J_USER ||
33+
!process.env.NEO4J_PASSWORD
34+
) {
35+
console.warn(
36+
"Using default Neo4j connection parameters. Set NEO4J_URI, NEO4J_USER, and NEO4J_PASSWORD environment variables for custom configuration.",
37+
);
38+
}
39+
40+
this.driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
41+
42+
const dbService = new DbService(this.driver);
43+
this.logService = new LogService(this.driver);
44+
this.graphqlServer = new GraphQLServer(dbService);
45+
46+
this.server = fastify({
47+
logger: true,
48+
});
3849
}
3950

40-
this.driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
41-
42-
const dbService = new DbService(this.driver);
43-
this.logService = new LogService(this.driver);
44-
this.graphqlServer = new GraphQLServer(dbService);
45-
46-
this.server = fastify({
47-
logger: true,
48-
});
49-
}
50-
51-
async initialize() {
52-
await registerHttpRoutes(this.server);
53-
54-
const w3id = await W3ID.get({
55-
id: process.env.W3ID as string,
56-
driver: this.driver,
57-
password: process.env.ENCRYPTION_PASSWORD,
58-
});
59-
60-
const yoga = this.graphqlServer.init();
61-
62-
this.server.route({
63-
// Bind to the Yoga's endpoint to avoid rendering on any path
64-
url: yoga.graphqlEndpoint,
65-
method: ["GET", "POST", "OPTIONS"],
66-
handler: (req, reply) =>
67-
yoga.handleNodeRequestAndResponse(req, reply, {
68-
req,
69-
reply,
70-
}),
71-
});
72-
73-
// Mount Voyager endpoint
74-
this.server.get("/voyager", (req: FastifyRequest, reply: FastifyReply) => {
75-
reply.type("text/html").send(
76-
renderVoyagerPage({
77-
endpointUrl: "/graphql",
78-
})
79-
);
80-
});
81-
}
82-
83-
async start() {
84-
await this.initialize();
85-
86-
const port = process.env.NOMAD_PORT_http || process.env.PORT || 4000;
87-
88-
await this.server.listen({ port: Number(port), host: "0.0.0.0" });
89-
console.log(`Server started on http://0.0.0.0:${port}`);
90-
console.log(`GraphQL endpoint available at http://0.0.0.0:${port}/graphql`);
91-
console.log(`GraphQL Voyager available at http://0.0.0.0:${port}/voyager`);
92-
console.log(`API Documentation available at http://0.0.0.0:${port}/docs`);
93-
}
51+
async initialize() {
52+
await registerHttpRoutes(this.server);
53+
54+
const w3id = await W3ID.get({
55+
id: process.env.W3ID as string,
56+
driver: this.driver,
57+
password: process.env.ENCRYPTION_PASSWORD,
58+
});
59+
60+
const yoga = this.graphqlServer.init();
61+
62+
this.server.route({
63+
// Bind to the Yoga's endpoint to avoid rendering on any path
64+
url: yoga.graphqlEndpoint,
65+
method: ["GET", "POST", "OPTIONS"],
66+
handler: (req, reply) =>
67+
yoga.handleNodeRequestAndResponse(req, reply, {
68+
req,
69+
reply,
70+
}),
71+
});
72+
73+
// Mount Voyager endpoint
74+
this.server.get(
75+
"/voyager",
76+
(req: FastifyRequest, reply: FastifyReply) => {
77+
reply.type("text/html").send(
78+
renderVoyagerPage({
79+
endpointUrl: "/graphql",
80+
}),
81+
);
82+
},
83+
);
84+
}
85+
86+
async start() {
87+
await this.initialize();
88+
89+
const port = process.env.NOMAD_PORT_http || process.env.PORT || 4000;
90+
91+
await this.server.listen({ port: Number(port), host: "0.0.0.0" });
92+
console.log(`Server started on http://0.0.0.0:${port}`);
93+
console.log(
94+
`GraphQL endpoint available at http://0.0.0.0:${port}/graphql`,
95+
);
96+
console.log(
97+
`GraphQL Voyager available at http://0.0.0.0:${port}/voyager`,
98+
);
99+
console.log(
100+
`API Documentation available at http://0.0.0.0:${port}/docs`,
101+
);
102+
}
94103
}
95104

96105
const evault = new EVault();

infrastructure/evault-provisioner/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
"test": "vitest"
1212
},
1313
"dependencies": {
14+
"@kubernetes/client-node": "^1.3.0",
1415
"axios": "^1.6.7",
1516
"dotenv": "^16.4.5",
1617
"express": "^4.18.2",
1718
"jose": "^5.2.2",
19+
"sha256": "^0.2.0",
1820
"w3id": "workspace:*"
1921
},
2022
"devDependencies": {

infrastructure/evault-provisioner/src/index.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import express, { Request, Response } from "express";
22
import axios, { AxiosError } from "axios";
3-
import { generateNomadJob } from "./templates/evault.nomad.js";
3+
import { provisionEVault } from "./templates/evault.nomad.js";
44
import dotenv from "dotenv";
5-
import { subscribeToAlloc } from "./listeners/alloc.js";
65
import { W3IDBuilder } from "w3id";
76
import * as jose from "jose";
87

@@ -67,22 +66,9 @@ app.post(
6766

6867
const w3id = userId.id;
6968

70-
const jobJSON = generateNomadJob(w3id, evaultId.id);
69+
await provisionEVault(w3id, evaultId.id);
7170
const jobName = `evault-${w3id}`;
7271

73-
const { data } = await axios.post(
74-
"http://localhost:4646/v1/jobs",
75-
jobJSON,
76-
);
77-
const evalId = data.EvalID;
78-
79-
const sub = subscribeToAlloc(evalId);
80-
sub.on("ready", async (allocId) => {
81-
console.log("Alloc is ready:", allocId);
82-
});
83-
sub.on("error", (err) => {
84-
console.error("Alloc wait failed:", err);
85-
});
8672

8773
res.json({
8874
success: true,

0 commit comments

Comments
 (0)