From 4c8db29ab209a4d500cd34c50ae9ae396bff7ec3 Mon Sep 17 00:00:00 2001 From: Abdul Rashid Date: Wed, 3 Dec 2025 13:11:46 +0530 Subject: [PATCH 1/2] feat: Update protoc to v4.23.4, remove namespaces from generated proto files, and add a new HTTP request configuration file. --- src/proto/api.ts | 51 ++++---------------------------- src/proto/tee-bundle.ts | 9 ++---- src/scripts/generate-proto.sh | 4 ++- src/scripts/remove-namespaces.js | 35 ++++++++++++++++++++++ 4 files changed, 46 insertions(+), 53 deletions(-) create mode 100644 src/scripts/remove-namespaces.js diff --git a/src/proto/api.ts b/src/proto/api.ts index 68f8e205..b0326b07 100644 --- a/src/proto/api.ts +++ b/src/proto/api.ts @@ -1,7 +1,7 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.5.0 -// protoc v3.21.12 +// protoc v4.23.4 // source: api.proto /* eslint-disable */ @@ -18,15 +18,7 @@ export const TranscriptMessageSenderType = { export type TranscriptMessageSenderType = typeof TranscriptMessageSenderType[keyof typeof TranscriptMessageSenderType]; -export namespace TranscriptMessageSenderType { - export type TRANSCRIPT_MESSAGE_SENDER_TYPE_UNKNOWN = - typeof TranscriptMessageSenderType.TRANSCRIPT_MESSAGE_SENDER_TYPE_UNKNOWN; - export type TRANSCRIPT_MESSAGE_SENDER_TYPE_CLIENT = - typeof TranscriptMessageSenderType.TRANSCRIPT_MESSAGE_SENDER_TYPE_CLIENT; - export type TRANSCRIPT_MESSAGE_SENDER_TYPE_SERVER = - typeof TranscriptMessageSenderType.TRANSCRIPT_MESSAGE_SENDER_TYPE_SERVER; - export type UNRECOGNIZED = typeof TranscriptMessageSenderType.UNRECOGNIZED; -} + export function transcriptMessageSenderTypeFromJSON(object: any): TranscriptMessageSenderType { switch (object) { @@ -73,11 +65,7 @@ export const ServiceSignatureType = { export type ServiceSignatureType = typeof ServiceSignatureType[keyof typeof ServiceSignatureType]; -export namespace ServiceSignatureType { - export type SERVICE_SIGNATURE_TYPE_UNKNOWN = typeof ServiceSignatureType.SERVICE_SIGNATURE_TYPE_UNKNOWN; - export type SERVICE_SIGNATURE_TYPE_ETH = typeof ServiceSignatureType.SERVICE_SIGNATURE_TYPE_ETH; - export type UNRECOGNIZED = typeof ServiceSignatureType.UNRECOGNIZED; -} + export function serviceSignatureTypeFromJSON(object: any): ServiceSignatureType { switch (object) { @@ -118,15 +106,7 @@ export const AttestorVersion = { export type AttestorVersion = typeof AttestorVersion[keyof typeof AttestorVersion]; -export namespace AttestorVersion { - export type ATTESTOR_VERSION_UNKNOWN = typeof AttestorVersion.ATTESTOR_VERSION_UNKNOWN; - export type ATTESTOR_VERSION_1_0_0 = typeof AttestorVersion.ATTESTOR_VERSION_1_0_0; - export type ATTESTOR_VERSION_1_1_0 = typeof AttestorVersion.ATTESTOR_VERSION_1_1_0; - export type ATTESTOR_VERSION_2_0_0 = typeof AttestorVersion.ATTESTOR_VERSION_2_0_0; - export type ATTESTOR_VERSION_2_0_1 = typeof AttestorVersion.ATTESTOR_VERSION_2_0_1; - export type ATTESTOR_VERSION_3_0_0 = typeof AttestorVersion.ATTESTOR_VERSION_3_0_0; - export type UNRECOGNIZED = typeof AttestorVersion.UNRECOGNIZED; -} + export function attestorVersionFromJSON(object: any): AttestorVersion { switch (object) { @@ -219,22 +199,7 @@ export const ErrorCode = { export type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode]; -export namespace ErrorCode { - export type ERROR_NO_ERROR = typeof ErrorCode.ERROR_NO_ERROR; - export type ERROR_INTERNAL = typeof ErrorCode.ERROR_INTERNAL; - export type ERROR_BAD_REQUEST = typeof ErrorCode.ERROR_BAD_REQUEST; - export type ERROR_NOT_FOUND = typeof ErrorCode.ERROR_NOT_FOUND; - export type ERROR_PROXY_ERROR = typeof ErrorCode.ERROR_PROXY_ERROR; - export type ERROR_INVALID_CLAIM = typeof ErrorCode.ERROR_INVALID_CLAIM; - export type ERROR_NETWORK_ERROR = typeof ErrorCode.ERROR_NETWORK_ERROR; - export type ERROR_PAYMENT_REFUSED = typeof ErrorCode.ERROR_PAYMENT_REFUSED; - export type ERROR_BGP_ANNOUNCEMENT_OVERLAP = typeof ErrorCode.ERROR_BGP_ANNOUNCEMENT_OVERLAP; - export type ERROR_AUTHENTICATION_FAILED = typeof ErrorCode.ERROR_AUTHENTICATION_FAILED; - export type ERROR_TIMEOUT = typeof ErrorCode.ERROR_TIMEOUT; - export type ERROR_TOPRF_OUT_OF_BOUNDS = typeof ErrorCode.ERROR_TOPRF_OUT_OF_BOUNDS; - export type ERROR_CERTIFICATE_FETCH_FAILED = typeof ErrorCode.ERROR_CERTIFICATE_FETCH_FAILED; - export type UNRECOGNIZED = typeof ErrorCode.UNRECOGNIZED; -} + export function errorCodeFromJSON(object: any): ErrorCode { switch (object) { @@ -322,11 +287,7 @@ export const ZKProofEngine = { ZK_ENGINE_SNARKJS: 0, ZK_ENGINE_GNARK: 1, UNRECOG export type ZKProofEngine = typeof ZKProofEngine[keyof typeof ZKProofEngine]; -export namespace ZKProofEngine { - export type ZK_ENGINE_SNARKJS = typeof ZKProofEngine.ZK_ENGINE_SNARKJS; - export type ZK_ENGINE_GNARK = typeof ZKProofEngine.ZK_ENGINE_GNARK; - export type UNRECOGNIZED = typeof ZKProofEngine.UNRECOGNIZED; -} + export function zKProofEngineFromJSON(object: any): ZKProofEngine { switch (object) { diff --git a/src/proto/tee-bundle.ts b/src/proto/tee-bundle.ts index 7d36ad8f..8264639a 100644 --- a/src/proto/tee-bundle.ts +++ b/src/proto/tee-bundle.ts @@ -1,7 +1,7 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.5.0 -// protoc v3.21.12 +// protoc v4.23.4 // source: tee-bundle.proto /* eslint-disable */ @@ -19,12 +19,7 @@ export const BodyType = { export type BodyType = typeof BodyType[keyof typeof BodyType]; -export namespace BodyType { - export type BODY_TYPE_UNSPECIFIED = typeof BodyType.BODY_TYPE_UNSPECIFIED; - export type BODY_TYPE_K_OUTPUT = typeof BodyType.BODY_TYPE_K_OUTPUT; - export type BODY_TYPE_T_OUTPUT = typeof BodyType.BODY_TYPE_T_OUTPUT; - export type UNRECOGNIZED = typeof BodyType.UNRECOGNIZED; -} + export function bodyTypeFromJSON(object: any): BodyType { switch (object) { diff --git a/src/scripts/generate-proto.sh b/src/scripts/generate-proto.sh index e908d363..a47c6e62 100755 --- a/src/scripts/generate-proto.sh +++ b/src/scripts/generate-proto.sh @@ -2,4 +2,6 @@ mkdir -p src/proto protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \ --ts_proto_out=./src/proto \ --ts_proto_opt=enumsAsLiterals=true,useExactTypes=false \ - --proto_path=./proto ./proto/*.proto \ No newline at end of file + --proto_path=./proto ./proto/*.proto + +node src/scripts/remove-namespaces.js \ No newline at end of file diff --git a/src/scripts/remove-namespaces.js b/src/scripts/remove-namespaces.js new file mode 100644 index 00000000..eeb676db --- /dev/null +++ b/src/scripts/remove-namespaces.js @@ -0,0 +1,35 @@ +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const PROTO_DIR = path.join(__dirname, '../proto'); + +if (!fs.existsSync(PROTO_DIR)) { + console.error(`Directory not found: ${PROTO_DIR}`); + process.exit(1); +} + +const files = fs.readdirSync(PROTO_DIR).filter(file => file.endsWith('.ts')); + +files.forEach(file => { + const filePath = path.join(PROTO_DIR, file); + let content = fs.readFileSync(filePath, 'utf8'); + + // Regex to match "export namespace Name { ... }" blocks + // This assumes the namespace block ends with a closing brace on a new line + // and doesn't contain nested braces that would break a simple regex. + // Given the generated code structure, this should be safe. + const namespaceRegex = /export namespace \w+ \{[\s\S]*?\n\}/g; + + if (namespaceRegex.test(content)) { + console.log(`Found namespaces in ${file}. Removing...`); + content = content.replace(namespaceRegex, ''); + fs.writeFileSync(filePath, content, 'utf8'); + console.log(`Namespaces removed from ${file}.`); + } else { + console.log(`No namespaces found in ${file}.`); + } +}); From bed4f98533a88e30655510854122cafe5b2f58a7 Mon Sep 17 00:00:00 2001 From: Abdul Rashid Date: Wed, 3 Dec 2025 13:20:31 +0530 Subject: [PATCH 2/2] fix lint --- src/scripts/remove-namespaces.js | 54 ++++++++++++++++---------------- tsconfig.json | 16 +++++++--- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/scripts/remove-namespaces.js b/src/scripts/remove-namespaces.js index eeb676db..d7f60ade 100644 --- a/src/scripts/remove-namespaces.js +++ b/src/scripts/remove-namespaces.js @@ -1,35 +1,35 @@ -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; +import fs from 'fs' +import path from 'path' +import { fileURLToPath } from 'url' -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) -const PROTO_DIR = path.join(__dirname, '../proto'); +const PROTO_DIR = path.join(__dirname, '../proto') -if (!fs.existsSync(PROTO_DIR)) { - console.error(`Directory not found: ${PROTO_DIR}`); - process.exit(1); +if(!fs.existsSync(PROTO_DIR)) { + console.error(`Directory not found: ${PROTO_DIR}`) + process.exit(1) } -const files = fs.readdirSync(PROTO_DIR).filter(file => file.endsWith('.ts')); +const files = fs.readdirSync(PROTO_DIR).filter(file => file.endsWith('.ts')) -files.forEach(file => { - const filePath = path.join(PROTO_DIR, file); - let content = fs.readFileSync(filePath, 'utf8'); +for(const file of files) { + const filePath = path.join(PROTO_DIR, file) + let content = fs.readFileSync(filePath, 'utf8') - // Regex to match "export namespace Name { ... }" blocks - // This assumes the namespace block ends with a closing brace on a new line - // and doesn't contain nested braces that would break a simple regex. - // Given the generated code structure, this should be safe. - const namespaceRegex = /export namespace \w+ \{[\s\S]*?\n\}/g; + // Regex to match "export namespace Name { ... }" blocks + // This assumes the namespace block ends with a closing brace on a new line + // and doesn't contain nested braces that would break a simple regex. + // Given the generated code structure, this should be safe. + const namespaceRegex = /export namespace \w+ \{[\s\S]*?\n\}/g - if (namespaceRegex.test(content)) { - console.log(`Found namespaces in ${file}. Removing...`); - content = content.replace(namespaceRegex, ''); - fs.writeFileSync(filePath, content, 'utf8'); - console.log(`Namespaces removed from ${file}.`); - } else { - console.log(`No namespaces found in ${file}.`); - } -}); + if(namespaceRegex.test(content)) { + console.log(`Found namespaces in ${file}. Removing...`) + content = content.replace(namespaceRegex, '') + fs.writeFileSync(filePath, content, 'utf8') + console.log(`Namespaces removed from ${file}.`) + } else { + console.log(`No namespaces found in ${file}.`) + } +} diff --git a/tsconfig.json b/tsconfig.json index 1f7833ad..5440160d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,11 @@ { "compilerOptions": { - "lib": ["ESNext", "DOM", "ESNext.AsyncIterable", "DOM.AsyncIterable"], + "lib": [ + "ESNext", + "DOM", + "ESNext.AsyncIterable", + "DOM.AsyncIterable" + ], "module": "nodenext", "moduleResolution": "nodenext", "allowJs": true, @@ -15,14 +20,17 @@ "noEmit": true, "baseUrl": ".", "paths": { - "#src/*": ["src/*"] + "#src/*": [ + "src/*" + ] } }, "include": [ "src/*.ts", - "src/**/*.ts" + "src/**/*.ts", + "src/**/*.js" ], "exclude": [ "node_modules" ] -} +} \ No newline at end of file