@@ -3,7 +3,7 @@ import fs from "node:fs/promises";
33import { openUplinks } from "@ndn/cli-common" ;
44import { CertNaming , generateSigningKey , type KeyChain , type NamedSigner , type NamedVerifier } from "@ndn/keychain" ;
55import { AltUri } from "@ndn/naming-convention2" ;
6- import { type CaProfile , type ClientChallenge , type ClientChallengeContext , ClientDnsChallenge , ClientEmailChallenge , type ClientEmailInboxImap , ClientNopChallenge , ClientPinChallenge , type ClientPinLikeChallenge , ClientPossessionChallenge , matchProbe , requestCertificate , requestProbe } from "@ndn/ndncert" ;
6+ import { type CaProfile , type ClientChallenge , type ClientChallengeContext , ClientDns01Challenge , ClientDnsChallenge , ClientEmailChallenge , type ClientEmailInboxImap , ClientNopChallenge , ClientPinChallenge , type ClientPinLikeChallenge , ClientPossessionChallenge , matchProbe , requestCertificate , requestProbe } from "@ndn/ndncert" ;
77import { NdnsecKeyChain } from "@ndn/ndnsec" ;
88import { Name } from "@ndn/packet" ;
99import { console , toHex } from "@ndn/util" ;
@@ -51,7 +51,7 @@ export const Ndncert03ClientCommand: CommandModule<{}, Args> = {
5151 . option ( "challenge" , {
5252 demandOption : true ,
5353 array : true ,
54- choices : [ "nop" , "pin" , "email" , "possession" , "dns" ] ,
54+ choices : [ "nop" , "pin" , "email" , "possession" , "dns" , "dns-01" ] ,
5555 desc : "supported challenges" ,
5656 type : "string" ,
5757 } )
@@ -71,7 +71,7 @@ export const Ndncert03ClientCommand: CommandModule<{}, Args> = {
7171 type : "string" ,
7272 } )
7373 . option ( "dns-domain" , {
74- desc : "dns challenge - domain name" ,
74+ desc : "dns/dns-01 challenge - domain name" ,
7575 type : "string" ,
7676 } )
7777 . check ( ( { key } ) => {
@@ -96,8 +96,8 @@ export const Ndncert03ClientCommand: CommandModule<{}, Args> = {
9696 return true ;
9797 } )
9898 . check ( ( { challenge, "dns-domain" : domain } ) => {
99- if ( challenge . includes ( "dns" ) && ! domain ?. includes ( "." ) ) {
100- throw new Error ( "dns challenge enabled but --dns-domain is absent" ) ;
99+ if ( ( challenge . includes ( "dns" ) || challenge . includes ( "dns-01" ) ) && ! domain ?. includes ( "." ) ) {
100+ throw new Error ( "dns/dns-01 challenge enabled but --dns-domain is absent" ) ;
101101 }
102102 return true ;
103103 } ) ;
@@ -202,6 +202,10 @@ class InteractiveClient {
202202 challenges . push ( new ClientDnsChallenge ( this . args [ "dns-domain" ] ! , this . promptDns ( ) ) ) ;
203203 break ;
204204 }
205+ case "dns-01" : {
206+ challenges . push ( new ClientDns01Challenge ( this . args [ "dns-domain" ] ! , this . promptDns ( ) ) ) ;
207+ break ;
208+ }
205209 }
206210 }
207211 return challenges ;
@@ -232,17 +236,13 @@ class InteractiveClient {
232236 private promptDns ( ) : ClientDnsChallenge . Prompt {
233237 return async ( _context , recordName , expectedValue ) => {
234238 console . log ( `\nDNS record for certificate request\n${ recordName } \tIN\tTXT\n${ expectedValue } \n` ) ;
235- while ( true ) {
236- const response = await prompts ( {
237- type : "confirm" ,
238- name : "ready" ,
239- message : "Confirm when DNS record is ready:" ,
240- initial : true ,
241- } ) ;
242- if ( response . ready ) {
243- return ;
244- }
245- }
239+ await prompts ( {
240+ type : "invisible" ,
241+ name : "ready" ,
242+ message : "Press ENTER when DNS record is ready:" ,
243+ } , {
244+ onCancel : ( ) => { throw new Error ( "challenge aborted" ) ; } ,
245+ } ) ;
246246 } ;
247247 }
248248}
0 commit comments