From d696d996de67aa01d6f359ec1b9a0539bfa8e9b0 Mon Sep 17 00:00:00 2001 From: JettTech Date: Sun, 25 Aug 2024 22:22:26 -0500 Subject: [PATCH] add no-dpki flag --- flake.lock | 12 ++++++------ ts/src/local/conductor.ts | 7 ++++--- ts/src/local/scenario.ts | 3 ++- ts/src/trycp/conductor/conductor.ts | 18 ++++++++++++++---- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/flake.lock b/flake.lock index ddf22aef..b1bd159e 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ ] }, "locked": { - "lastModified": 1724377159, - "narHash": "sha256-ixjje1JO8ucKT41hs6n2NCde1Vc0+Zc2p2gUbJpCsMw=", + "lastModified": 1724537630, + "narHash": "sha256-gpqINM71zp3kw5XYwUXa84ZtPnCmLLnByuFoYesT1bY=", "owner": "ipetkov", "repo": "crane", - "rev": "3e47b7a86c19142bd3675da49d6acef488b4dac1", + "rev": "3e08f4b1fc9aaede5dd511d8f5f4ef27501e49b0", "type": "github" }, "original": { @@ -184,11 +184,11 @@ ] }, "locked": { - "lastModified": 1724466314, - "narHash": "sha256-ltKuK6shQ64uej1mYNtBsDYxttUNFiv9AcHqk0+0NQM=", + "lastModified": 1724638882, + "narHash": "sha256-ap2jIQi/FuUHR6HCht6ASWhoz8EiB99XmI8Esot38VE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2b5b3edd96ef336b00622dcabc13788fdef9e3ca", + "rev": "19b70f147b9c67a759e35824b241f1ed92e46694", "type": "github" }, "original": { diff --git a/ts/src/local/conductor.ts b/ts/src/local/conductor.ts index 106251f7..65867972 100644 --- a/ts/src/local/conductor.ts +++ b/ts/src/local/conductor.ts @@ -156,9 +156,10 @@ export class Conductor implements IConductor { if (options?.bootstrapServerUrl) { args.push("--bootstrap", options.bootstrapServerUrl.href); } - // if (options?.noDpki) { - // args.push("--dpki", options.noDpki.href); - // } + // add "no-dpki" flag when passed as true + if (options?.noDpki) { + args.push("--no-dpki"); + } args.push(networkType); if (networkType === NetworkType.WebRtc) { args.push(signalingServerUrl.href); diff --git a/ts/src/local/scenario.ts b/ts/src/local/scenario.ts index 4a15957a..8ed3a0ed 100644 --- a/ts/src/local/scenario.ts +++ b/ts/src/local/scenario.ts @@ -63,13 +63,14 @@ export class Scenario { * * @returns The newly added conductor instance. */ - async addConductor() { + async addConductor(noDpki = false) { await this.ensureLocalServices(); assert(this.serviceProcess); assert(this.signalingServerUrl); const conductor = await createConductor(this.signalingServerUrl, { timeout: this.timeout, bootstrapServerUrl: this.bootstrapServerUrl, + noDpki }); this.conductors.push(conductor); return conductor; diff --git a/ts/src/trycp/conductor/conductor.ts b/ts/src/trycp/conductor/conductor.ts index 11f9a908..13ca6220 100644 --- a/ts/src/trycp/conductor/conductor.ts +++ b/ts/src/trycp/conductor/conductor.ts @@ -94,6 +94,7 @@ const HOLO_SIGNALING_SERVER = new URL("wss://sbd-0.main.infra.holo.host"); const HOLO_BOOTSTRAP_SERVEr = new URL("https://devnet-bootstrap.holo.host"); const BOOTSTRAP_SERVER_PLACEHOLDER = ""; const SIGNALING_SERVER_PLACEHOLDER = ""; +const DPKI_CONFIG_DEFAULT = "~" /** * The default partial config for a TryCP conductor. @@ -103,7 +104,7 @@ const SIGNALING_SERVER_PLACEHOLDER = ""; export const DEFAULT_PARTIAL_PLAYER_CONFIG = `signing_service_uri: ~ encryption_service_uri: ~ decryption_service_uri: ~ -dpki: ~ +dpki: ${DPKI_CONFIG_DEFAULT} network: network_type: "quic_bootstrap" bootstrap_service: ${BOOTSTRAP_SERVER_PLACEHOLDER} @@ -170,7 +171,7 @@ export const createTryCpConductor = async ( const conductor = new TryCpConductor(tryCpClient, options?.id); if (options?.startup !== false) { // configure and startup conductor by default - await conductor.configure(options?.partialConfig); + await conductor.configure(options?.partialConfig, options?.noDpki); await conductor.startUp({ logLevel: options?.logLevel }); } return conductor; @@ -196,7 +197,7 @@ export class TryCpConductor implements IConductor { * @param partialConfig - The configuration to add to the default configuration. * @returns An empty success response. */ - async configure(partialConfig?: string) { + async configure(partialConfig?: string, noDpki: boolean = false) { if (!partialConfig) { partialConfig = DEFAULT_PARTIAL_PLAYER_CONFIG.replace( BOOTSTRAP_SERVER_PLACEHOLDER, @@ -205,11 +206,20 @@ export class TryCpConductor implements IConductor { SIGNALING_SERVER_PLACEHOLDER, (this.tryCpClient.signalingServerUrl || HOLO_SIGNALING_SERVER).href ); + if (noDpki) { + partialConfig = DEFAULT_PARTIAL_PLAYER_CONFIG.replace( + DPKI_CONFIG_DEFAULT, + ` + dna_path: None + device_seed_lair_tag: "disabled" + no_dpki: true`) + } } + const response = await this.tryCpClient.call({ type: "configure_player", id: this.id, - partial_config: partialConfig, + partial_config: partialConfig }); assert(response === TRYCP_SUCCESS_RESPONSE); return response;