diff --git a/src/identities/CommandAuthenticate.ts b/src/identities/CommandAuthenticate.ts index 83a5d4c8..5844a151 100644 --- a/src/identities/CommandAuthenticate.ts +++ b/src/identities/CommandAuthenticate.ts @@ -83,12 +83,16 @@ class CommandAuthenticate extends CommandPolykey { this.logger.info( `Authenticated digital identity provider ${providerId}`, ); - process.stdout.write( - binUtils.outputFormatter({ - type: options.format === 'json' ? 'json' : 'list', - data: [message.response.identityId], - }), - ); + let output: string | Uint8Array; + if (options.format === 'json') { + output = binUtils.outputFormatter({ + type: 'json', + data: { identityId: message.response.identityId }, + }); + } else { + output = `${message.response.identityId}\n`; + } + process.stdout.write(output); } else { never(); } diff --git a/src/identities/CommandClaim.ts b/src/identities/CommandClaim.ts index 0c70f0ca..5f2679fc 100644 --- a/src/identities/CommandClaim.ts +++ b/src/identities/CommandClaim.ts @@ -60,14 +60,16 @@ class CommandClaim extends CommandPolykey { }), auth, ); - const output = [`Claim Id: ${claimMessage.claimId}`]; + const data: { claimId: string; url?: string } = { + claimId: claimMessage.claimId, + }; if (claimMessage.url) { - output.push(`Url: ${claimMessage.url}`); + data.url = claimMessage.url; } process.stdout.write( binUtils.outputFormatter({ - type: options.format === 'json' ? 'json' : 'list', - data: output, + type: options.format === 'json' ? 'json' : 'dict', + data, }), ); } finally { diff --git a/src/identities/CommandInvite.ts b/src/identities/CommandInvite.ts index 0f1d9272..ee00f56a 100644 --- a/src/identities/CommandInvite.ts +++ b/src/identities/CommandInvite.ts @@ -59,16 +59,19 @@ class CommandClaim extends CommandPolykey { }), auth, ); - process.stdout.write( - binUtils.outputFormatter({ - type: options.format === 'json' ? 'json' : 'list', - data: [ - `Successfully sent Gestalt Invite notification to Keynode with ID ${nodesUtils.encodeNodeId( - nodeId, - )}`, - ], - }), - ); + const message = `Successfully sent Gestalt Invite notification to Keynode with ID ${nodesUtils.encodeNodeId( + nodeId, + )}`; + let output: string | Uint8Array; + if (options.format === 'json') { + output = binUtils.outputFormatter({ + type: 'json', + data: { message }, + }); + } else { + output = `${message}\n`; + } + process.stdout.write(output); } finally { if (pkClient! != null) await pkClient.stop(); } diff --git a/tests/identities/claim.test.ts b/tests/identities/claim.test.ts index 91ff4a22..99b59b5b 100644 --- a/tests/identities/claim.test.ts +++ b/tests/identities/claim.test.ts @@ -94,7 +94,7 @@ describe('claim', () => { }, ); expect(exitCode).toBe(0); - expect(JSON.parse(stdout)).toEqual(['Claim Id: 0', 'Url: test.com']); + expect(JSON.parse(stdout)).toEqual({ claimId: '0', url: 'test.com' }); // Check for claim on the provider const claim = await testProvider.getClaim( testToken.identityId,