@@ -12,6 +12,7 @@ import {
1212 getShareBaseUrl ,
1313 readConfig ,
1414 readGlobalConfig ,
15+ resolveAccountApiKey ,
1516 resolveApiKey ,
1617 resolveApiKeyOptional ,
1718 resolveMagicToken ,
@@ -118,7 +119,7 @@ const program = new Command();
118119program
119120 . name ( "dm" )
120121 . description ( "CLI for Draftmark — markdown sharing for async collaboration" )
121- . version ( "0.2.0 " )
122+ . version ( "0.2.1 " )
122123 . option ( "-q, --quiet" , "Suppress all stderr output" )
123124 . option ( "--base-url <url>" , "Override API base URL (default: https://draftmark.app/api/v1)" ) ;
124125
@@ -149,11 +150,11 @@ program
149150
150151 const content = await readContentFromFileOrStdin ( file ) ;
151152
152- // Resolve API key (required for private, optional for public)
153+ // Resolve API key: private docs need an account key (acct_...), public docs are optional
153154 const entry = await getLastEntry ( ) ;
154155 const global = await readGlobalConfig ( ) ;
155156 const apiKey = opts . private
156- ? resolveApiKey ( opts , entry , global )
157+ ? resolveAccountApiKey ( opts , entry , global )
157158 : resolveApiKeyOptional ( opts , entry , global ) ;
158159
159160 const body : Record < string , unknown > = { content } ;
@@ -782,21 +783,28 @@ program
782783 const global = await readGlobalConfig ( ) ;
783784 const entry = entries . length > 0 ? entries [ entries . length - 1 ] : null ;
784785
786+ const envKey = process . env . DM_API_KEY ;
787+ const localKey = entry ?. api_key ;
788+ const globalKey = global . api_key ;
789+
785790 const resolved = {
786791 base_url : getBaseUrl ( ) ,
787792 share_base_url : getShareBaseUrl ( ) ,
788- api_key : {
793+ account_api_key : {
789794 source : ( ( ) => {
790- if ( process . env . DM_API_KEY ) return "env (DM_API_KEY)" ;
791- if ( entry ?. api_key ) return ". draftmark.json" ;
792- if ( global . api_key ) return "~/.config/ draftmark/config .json" ;
795+ if ( envKey ) return "env (DM_API_KEY)" ;
796+ if ( globalKey ) return "~/.config/ draftmark/config .json" ;
797+ if ( localKey ) return ". draftmark.json" ;
793798 return null ;
794799 } ) ( ) ,
795800 value : ( ( ) => {
796- const key = process . env . DM_API_KEY || entry ?. api_key || global . api_key ;
801+ const key = envKey || globalKey || localKey ;
797802 return key ? key . slice ( 0 , 12 ) + "..." : null ;
798803 } ) ( ) ,
799804 } ,
805+ doc_api_key : localKey
806+ ? { source : ".draftmark.json" , value : localKey . slice ( 0 , 12 ) + "..." }
807+ : null ,
800808 magic_token : {
801809 source : ( ( ) => {
802810 if ( process . env . DM_MAGIC_TOKEN ) return "env (DM_MAGIC_TOKEN)" ;
@@ -818,8 +826,13 @@ program
818826 process . stdout . write ( `${ label ( "Share Base URL" , resolved . share_base_url ) } \n` ) ;
819827 process . stdout . write ( "\n" ) ;
820828 process . stdout . write (
821- `${ label ( "API Key" , resolved . api_key . value ? `${ green ( resolved . api_key . value ) } ${ dim ( `(${ resolved . api_key . source } )` ) } ` : dim ( "not set" ) ) } \n`
829+ `${ label ( "Account API Key" , resolved . account_api_key . value ? `${ green ( resolved . account_api_key . value ) } ${ dim ( `(${ resolved . account_api_key . source } )` ) } ` : dim ( "not set" ) ) } \n`
822830 ) ;
831+ if ( resolved . doc_api_key ) {
832+ process . stdout . write (
833+ `${ label ( "Doc API Key" , `${ dim ( resolved . doc_api_key . value ) } ${ dim ( `(${ resolved . doc_api_key . source } )` ) } ` ) } \n`
834+ ) ;
835+ }
823836 process . stdout . write (
824837 `${ label ( "Magic Token" , resolved . magic_token . set ? `${ green ( "set" ) } ${ dim ( `(${ resolved . magic_token . source } )` ) } ` : dim ( "not set" ) ) } \n`
825838 ) ;
0 commit comments