Skip to content

Commit 1de1355

Browse files
chore: change from nomad to k8s (#179)
* chore: change from nomad to k8s * Update infrastructure/eid-wallet/src/routes/+layout.svelte Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * feat: uri extraction * feat: regitry stuff * feat: registry using local db * 📝 Add docstrings to `feat/switch-to-k8s` (#181) Docstrings generation was requested by @coodos. * #179 (comment) The following files were modified: * `infrastructure/evault-provisioner/src/templates/evault.nomad.ts` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * chore: format --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent e7b700c commit 1de1355

File tree

20 files changed

+8819
-6444
lines changed

20 files changed

+8819
-6444
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: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ onMount(async () => {
5353
showSplashScreen = false;
5454
});
5555
56+
const safeAreaTop = $derived.by(
57+
() =>
58+
Number.parseFloat(
59+
getComputedStyle(document.documentElement).getPropertyValue(
60+
"--safe-top",
61+
),
62+
) || 0,
63+
);
64+
65+
$effect(() => console.log("top", safeAreaTop));
66+
5667
onNavigate((navigation) => {
5768
if (!document.startViewTransition) return;
5869
@@ -88,10 +99,31 @@ onNavigate((navigation) => {
8899
});
89100
</script>
90101

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

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,64 +7,64 @@ import { SecretsStore } from "../secrets/secrets-store";
77
import { uint8ArrayToHex } from "../utils/codec";
88

99
export class W3ID {
10-
private static instance: W3IDClass;
11-
private static secretsStore: SecretsStore;
10+
private static instance: W3IDClass;
11+
private static secretsStore: SecretsStore;
1212

13-
private constructor() {}
13+
private constructor() { }
1414

15-
static async get(options?: {
16-
id: string;
17-
driver: Driver;
18-
password?: string;
19-
}) {
20-
if (W3ID.instance) return W3ID.instance;
21-
if (!options)
22-
throw new Error(
23-
"No instance of W3ID exists yet, please create it by passing options"
24-
);
15+
static async get(options?: {
16+
id: string;
17+
driver: Driver;
18+
password?: string;
19+
}) {
20+
if (W3ID.instance) return W3ID.instance;
21+
if (!options)
22+
throw new Error(
23+
"No instance of W3ID exists yet, please create it by passing options"
24+
);
2525

26-
// Initialize secrets store if not already done
27-
if (!W3ID.secretsStore) {
28-
if (!options.password) {
29-
throw new Error("Password is required for secrets store");
30-
}
31-
W3ID.secretsStore = new SecretsStore(
32-
process.env.SECRETS_STORE_PATH!,
33-
options.password
34-
);
35-
}
26+
// Initialize secrets store if not already done
27+
if (!W3ID.secretsStore) {
28+
if (!options.password) {
29+
throw new Error("Password is required for secrets store");
30+
}
31+
W3ID.secretsStore = new SecretsStore(
32+
process.env.SECRETS_STORE_PATH!,
33+
options.password
34+
);
35+
}
3636

37-
const repository = new LogService(options.driver);
38-
const keyId = `w3id-${options.id}`;
37+
const repository = new LogService(options.driver);
38+
const keyId = `w3id-${options.id}`;
3939

40-
try {
41-
// Try to get existing seed
42-
const { seed, nextKeyHash } = await W3ID.secretsStore.getSeed(keyId);
43-
const keyPair = nacl.sign.keyPair.fromSeed(seed);
44-
W3ID.instance = await new W3IDBuilder()
45-
.withId(options.id)
46-
.withRepository(repository)
47-
.withGlobal(true)
48-
.withSigner(createSigner(keyPair))
49-
.withNextKeyHash(nextKeyHash)
50-
.build();
51-
} catch {
52-
// If no seed exists, create new one
53-
const keyPair = nacl.sign.keyPair();
54-
const nextKeyPair = nacl.sign.keyPair();
55-
const nextKeyHash = await hash(uint8ArrayToHex(nextKeyPair.publicKey));
40+
try {
41+
// Try to get existing seed
42+
const { seed, nextKeyHash } = await W3ID.secretsStore.getSeed(keyId);
43+
const keyPair = nacl.sign.keyPair.fromSeed(seed);
44+
W3ID.instance = await new W3IDBuilder()
45+
.withId(options.id)
46+
.withRepository(repository)
47+
.withGlobal(true)
48+
.withSigner(createSigner(keyPair))
49+
.withNextKeyHash(nextKeyHash)
50+
.build();
51+
} catch {
52+
// If no seed exists, create new one
53+
const keyPair = nacl.sign.keyPair();
54+
const nextKeyPair = nacl.sign.keyPair();
55+
const nextKeyHash = await hash(uint8ArrayToHex(nextKeyPair.publicKey));
5656

57-
// Store the seed
58-
await W3ID.secretsStore.storeSeed(keyId, keyPair.secretKey, nextKeyHash);
57+
// Store the seed
58+
await W3ID.secretsStore.storeSeed(keyId, keyPair.secretKey, nextKeyHash);
5959

60-
W3ID.instance = await new W3IDBuilder()
61-
.withId(options.id)
62-
.withRepository(repository)
63-
.withSigner(createSigner(keyPair))
64-
.withNextKeyHash(nextKeyHash)
65-
.build();
66-
}
60+
W3ID.instance = await new W3IDBuilder()
61+
.withId(options.id)
62+
.withRepository(repository)
63+
.withSigner(createSigner(keyPair))
64+
.withNextKeyHash(nextKeyHash)
65+
.build();
66+
}
6767

68-
return W3ID.instance;
69-
}
68+
return W3ID.instance;
69+
}
7070
}

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": {

0 commit comments

Comments
 (0)