diff --git a/packages/zcli-core/src/lib/auth.test.ts b/packages/zcli-core/src/lib/auth.test.ts index b84aab6d..3132b948 100644 --- a/packages/zcli-core/src/lib/auth.test.ts +++ b/packages/zcli-core/src/lib/auth.test.ts @@ -37,7 +37,7 @@ describe('Auth', () => { test .stub(auth, 'getLoggedInProfile', () => ({ subdomain: 'z3ntest' })) - .stub(auth.secureStore, 'getPassword', () => 'Basic test_token') + .stub(auth.secureStore, 'getSecret', () => 'Basic test_token') .it('should return token stored in secure store if no env vars are set', async () => { expect(await auth.getAuthorizationToken()).to.equal('Basic test_token') }) @@ -86,7 +86,7 @@ describe('Auth', () => { promptStub.onThirdCall().resolves('123456') }) .stub(CliUx.ux, 'prompt', () => promptStub) - .stub(auth.secureStore, 'setPassword', () => Promise.resolve()) + .stub(auth.secureStore, 'setSecret', () => Promise.resolve()) .stub(auth, 'setLoggedInProfile', () => Promise.resolve()) .nock('https://z3ntest.zendesk.com', api => { api @@ -108,7 +108,7 @@ describe('Auth', () => { promptStub.onThirdCall().resolves('123456') }) .stub(CliUx.ux, 'prompt', () => promptStub) - .stub(auth.secureStore, 'setPassword', () => Promise.resolve()) + .stub(auth.secureStore, 'setSecret', () => Promise.resolve()) .stub(auth, 'setLoggedInProfile', () => Promise.resolve()) .nock('https://z3ntest.example.com', api => { api @@ -129,7 +129,7 @@ describe('Auth', () => { promptStub.onSecondCall().resolves('123456') }) .stub(CliUx.ux, 'prompt', () => promptStub) - .stub(auth.secureStore, 'setPassword', () => Promise.resolve()) + .stub(auth.secureStore, 'setSecret', () => Promise.resolve()) .stub(auth, 'setLoggedInProfile', () => Promise.resolve()) .nock('https://z3ntest.example.com', api => { api @@ -164,7 +164,7 @@ describe('Auth', () => { test .stub(auth, 'getLoggedInProfile', () => ({ subdomain: 'z3ntest' })) - .stub(auth.secureStore, 'deletePassword', () => Promise.resolve(true)) + .stub(auth.secureStore, 'deleteSecret', () => Promise.resolve(true)) .stub(auth.config, 'removeConfig', () => Promise.resolve()) .it('should return true on logout success', async () => { expect(await auth.logout()).to.equal(true) @@ -180,7 +180,7 @@ describe('Auth', () => { test .stub(auth, 'getLoggedInProfile', () => ({ subdomain: 'z3ntest' })) - .stub(auth.secureStore, 'deletePassword', () => Promise.resolve(false)) + .stub(auth.secureStore, 'deleteSecret', () => Promise.resolve(false)) .stub(auth.config, 'removeConfig', () => Promise.resolve()) .do(async () => { await auth.logout() diff --git a/packages/zcli-core/src/lib/auth.ts b/packages/zcli-core/src/lib/auth.ts index 9f8d9913..0183a9bc 100644 --- a/packages/zcli-core/src/lib/auth.ts +++ b/packages/zcli-core/src/lib/auth.ts @@ -39,7 +39,7 @@ export default class Auth { } else { const profile = await this.getLoggedInProfile() if (profile && this.secureStore) { - const authToken = await this.secureStore.getPassword(getAccount(profile.subdomain, profile.domain)) + const authToken = await this.secureStore.getSecret(getAccount(profile.subdomain, profile.domain)) return authToken } @@ -79,7 +79,7 @@ export default class Auth { }) if (testAuth.status === 200 && this.secureStore) { - await this.secureStore.setPassword(account, authToken) + await this.secureStore.setSecret(account, authToken) await this.setLoggedInProfile(subdomain, domain) return true @@ -96,7 +96,7 @@ export default class Auth { const profile = await this.getLoggedInProfile() if (!profile?.subdomain) throw new CLIError(chalk.red('Failed to log out: no active profile found.')) await this.config.removeConfig('activeProfile') - const deleted = await this.secureStore.deletePassword(getAccount(profile.subdomain, profile.domain)) + const deleted = await this.secureStore.deleteSecret(getAccount(profile.subdomain, profile.domain)) if (!deleted) throw new CLIError(chalk.red('Failed to log out: Account, Service not found.')) return true diff --git a/packages/zcli-core/src/lib/secureStore.ts b/packages/zcli-core/src/lib/secureStore.ts index 13db29ca..a28d9f88 100644 --- a/packages/zcli-core/src/lib/secureStore.ts +++ b/packages/zcli-core/src/lib/secureStore.ts @@ -44,15 +44,15 @@ export default class SecureStore { return this.keytar } - setPassword (account: string, password: string) { - return this.keytar?.setPassword(this.serviceName, account, password) + setSecret (account: string, secret: string) { + return this.keytar?.setPassword(this.serviceName, account, secret) } - getPassword (account: string) { + getSecret (account: string) { return this.keytar?.getPassword(this.serviceName, account) } - deletePassword (account: string) { + deleteSecret (account: string) { return this.keytar?.deletePassword(this.serviceName, account) } diff --git a/packages/zcli/src/commands/profiles/remove.ts b/packages/zcli/src/commands/profiles/remove.ts index 86b9aaae..46cee828 100644 --- a/packages/zcli/src/commands/profiles/remove.ts +++ b/packages/zcli/src/commands/profiles/remove.ts @@ -26,7 +26,7 @@ export default class Remove extends Command { return } - const deleted = await secureStore.deletePassword(account) + const deleted = await secureStore.deleteSecret(account) if (!deleted) throw new CLIError(chalk.red(`Profile ${account} not found.`)) console.log(chalk.green(`Removed ${account} profile.`)) }