55 * Registers this baudbot server with a Slack broker workspace using:
66 * - broker URL
77 * - workspace ID
8- * - one-time auth code from OAuth callback
8+ * - registration token from dashboard callback
99 *
1010 * On success, stores broker config and generated server key material in:
1111 * - admin config: ~/.baudbot/.env
@@ -47,8 +47,7 @@ export function usageText() {
4747 "Options:" ,
4848 " --broker-url URL Broker base URL (e.g. https://broker.example.com)" ,
4949 " --workspace-id ID Slack workspace ID (e.g. T0123ABCD)" ,
50- " --registration-token TOKEN 10-minute registration token from dashboard callback" ,
51- " --auth-code CODE Legacy one-time auth code (fallback)" ,
50+ " --registration-token TOKEN Registration token from dashboard callback (required)" ,
5251 " -v, --verbose Show detailed registration progress" ,
5352 " -h, --help Show this help" ,
5453 "" ,
@@ -61,7 +60,6 @@ export function parseArgs(argv) {
6160 brokerUrl : "" ,
6261 workspaceId : "" ,
6362 registrationToken : "" ,
64- authCode : "" ,
6563 verbose : false ,
6664 help : false ,
6765 } ;
@@ -109,15 +107,6 @@ export function parseArgs(argv) {
109107 continue ;
110108 }
111109
112- if ( arg . startsWith ( "--auth-code=" ) ) {
113- out . authCode = arg . slice ( "--auth-code=" . length ) ;
114- continue ;
115- }
116- if ( arg === "--auth-code" ) {
117- i ++ ;
118- out . authCode = argv [ i ] || "" ;
119- continue ;
120- }
121110
122111 throw new Error ( `unknown argument: ${ arg } ` ) ;
123112 }
@@ -215,18 +204,15 @@ export async function fetchBrokerPubkeys(brokerUrl, fetchImpl = fetch) {
215204
216205export function mapRegisterError ( status , errorText ) {
217206 const text = String ( errorText || "request failed" ) ;
207+ if ( status === 400 && / m i s s i n g r e g i s t r a t i o n p r o o f / i. test ( text ) ) {
208+ return "registration token is required" ;
209+ }
218210 if ( status === 403 && / i n v a l i d r e g i s t r a t i o n t o k e n / i. test ( text ) ) {
219211 return "invalid registration token — re-run OAuth install and use a fresh token" ;
220212 }
221213 if ( status === 403 && / r e g i s t r a t i o n t o k e n a l r e a d y u s e d / i. test ( text ) ) {
222214 return "registration token already used — re-run OAuth install and use a fresh token" ;
223215 }
224- if ( status === 403 && / i n v a l i d a u t h c o d e / i. test ( text ) ) {
225- return "invalid auth code — re-run OAuth install and use the new auth code" ;
226- }
227- if ( status === 403 && / a u t h c o d e a l r e a d y c o n s u m e d / i. test ( text ) ) {
228- return "auth code already consumed — re-install the Slack app to get a fresh code" ;
229- }
230216 if ( status === 409 && / a l r e a d y a c t i v e / i. test ( text ) ) {
231217 return "workspace already active — unregister the current server first" ;
232218 }
@@ -285,7 +271,6 @@ export async function registerWithBroker({
285271 brokerUrl,
286272 workspaceId,
287273 registrationToken,
288- authCode,
289274 serverKeys,
290275 fetchImpl = fetch ,
291276 logger = ( ) => { } ,
@@ -298,8 +283,7 @@ export async function registerWithBroker({
298283 workspace_id : workspaceId ,
299284 server_pubkey : serverKeys . server_pubkey ,
300285 server_signing_pubkey : serverKeys . server_signing_pubkey ,
301- ...( registrationToken ? { registration_token : registrationToken } : { } ) ,
302- ...( authCode ? { auth_code : authCode } : { } ) ,
286+ registration_token : registrationToken ,
303287 } ;
304288
305289 logger ( `Registering workspace ${ workspaceId } at ${ endpoint } ` ) ;
@@ -536,18 +520,16 @@ async function collectInputs(parsedArgs) {
536520 || existing . SLACK_BROKER_WORKSPACE_ID
537521 || ( await prompt ( "Workspace ID (starts with T): " ) ) ;
538522
539- const registrationToken = parsedArgs . registrationToken || ( await prompt ( "Registration token (leave blank to use auth code): " ) ) ;
540- const authCode = parsedArgs . authCode || ( ! registrationToken ? ( await prompt ( "Auth code (legacy): " ) ) : "" ) ;
523+ const registrationToken = parsedArgs . registrationToken || ( await prompt ( "Registration token: " ) ) ;
541524
542- if ( ! registrationToken && ! authCode ) {
543- throw new Error ( "registration token or auth code is required" ) ;
525+ if ( ! registrationToken ) {
526+ throw new Error ( "registration token is required" ) ;
544527 }
545528
546529 return {
547530 brokerUrl : normalizeBrokerUrl ( brokerUrl ) ,
548531 workspaceId : workspaceId . trim ( ) ,
549532 registrationToken,
550- authCode,
551533 configTargets,
552534 } ;
553535}
@@ -556,16 +538,15 @@ export async function runRegistration({
556538 brokerUrl,
557539 workspaceId,
558540 registrationToken,
559- authCode,
560541 fetchImpl = fetch ,
561542 logger = ( ) => { } ,
562543} ) {
563544 if ( ! validateWorkspaceId ( workspaceId ) ) {
564545 throw new Error ( "workspace ID must match Slack team ID format (e.g. T0123ABCD)" ) ;
565546 }
566547
567- if ( ! registrationToken && ! authCode ) {
568- throw new Error ( "registration token or auth code is required" ) ;
548+ if ( ! registrationToken ) {
549+ throw new Error ( "registration token is required" ) ;
569550 }
570551
571552 const normalizedBrokerUrl = normalizeBrokerUrl ( brokerUrl ) ;
@@ -576,7 +557,6 @@ export async function runRegistration({
576557 brokerUrl : normalizedBrokerUrl ,
577558 workspaceId,
578559 registrationToken,
579- authCode,
580560 serverKeys,
581561 fetchImpl,
582562 logger,
0 commit comments