Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@blindpay/cli",
"type": "module",
"version": "0.3.1",
"version": "0.4.0",
"description": "Blindpay CLI - manage receivers, bank accounts, payouts, payins, and more from the terminal",
"license": "MIT",
"author": "Blindpay <alves@blindpay.com> (https://blindpay.com/)",
Expand Down
26 changes: 0 additions & 26 deletions src/__tests__/resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,32 +555,6 @@ describe('Partner Fees', () => {
})
})

describe('API Keys', () => {
beforeEach(setupTestEnv)
afterEach(teardownTestEnv)

test('lists API keys', async () => {
mockResponse.body = []
await resources.listApiKeys({ json: true })
expect(lastCall().url).toBe(`${BASE}/api-keys`)
})

test('creates an API key', async () => {
mockResponse.body = { id: 'ak_new', key: 'sk_...' }
await resources.createApiKey({ name: 'test', permission: 'read', json: true })
expect(lastCall().method).toBe('POST')
expect(lastCall().url).toBe(`${BASE}/api-keys`)
expect(lastCall().body).toEqual({ name: 'test', permission: 'read' })
})

test('deletes an API key', async () => {
mockResponse.body = { success: true }
await resources.deleteApiKey('ak_1', { json: true })
expect(lastCall().method).toBe('DELETE')
expect(lastCall().url).toBe(`${BASE}/api-keys/ak_1`)
})
})

describe('Virtual Accounts', () => {
beforeEach(setupTestEnv)
afterEach(teardownTestEnv)
Expand Down
43 changes: 0 additions & 43 deletions src/commands/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,49 +645,6 @@ export async function deletePartnerFee(id: string, options: { json?: boolean } =
}
}

// API Keys
export async function listApiKeys(options: { json: boolean }) {
try {
const ctx = resolveContext()
const res = await apiGet<unknown>(ctx, `${instancePath(ctx)}/api-keys`)
const list = extractList(res)
const maskKey = (s: string | null) => (!s ? '-' : s.length > 8 ? `${s.slice(0, 4)}...${s.slice(-4)}` : '***')
const display = list.map((k: any) => ({ id: k.id, name: k.name, key: maskKey(k.key), permission: k.permission }))
printResult(options.json ? list : display, options.json, ['id', 'name', 'key', 'permission'])
}
catch (e) {
handleApiError(e, options.json)
}
}

export async function createApiKey(options: { name?: string, permission?: string, json: boolean }) {
try {
const ctx = resolveContext()
const body: Record<string, string> = { name: options.name || 'CLI API Key' }
if (options.permission) body.permission = options.permission
const key = await apiPost<{ id: string, key: string }>(ctx, `${instancePath(ctx)}/api-keys`, body)
clack.log.success(`Created API key ${key.id}`)
clack.log.warning(`Secret: ${key.key}`)
clack.log.message('Save this key now — it will not be shown again.')
if (options.json)
console.log(formatOutput(key, true))
}
catch (e) {
handleApiError(e, options.json)
}
}

export async function deleteApiKey(id: string, options: { json?: boolean } = {}) {
try {
const ctx = resolveContext()
await apiDelete(ctx, `${instancePath(ctx)}/api-keys/${id}`)
clack.log.success(`Deleted API key ${id}`)
}
catch (e) {
handleApiError(e, options.json)
}
}

// Virtual Accounts
export async function listVirtualAccounts(options: { customerId: string, json: boolean }) {
try {
Expand Down
31 changes: 0 additions & 31 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ import {
listPartnerFees,
createPartnerFee,
deletePartnerFee,
listApiKeys,
createApiKey,
deleteApiKey,
listVirtualAccounts,
createVirtualAccount,
getVirtualAccount,
Expand Down Expand Up @@ -517,34 +514,6 @@ partnerFees
.option('--json', 'Output as JSON', false)
.action((id, opts) => deletePartnerFee(id, opts))

// ── API Keys ────────────────────────────────────────────────────────────
const apiKeys = program.command('api_keys').description('Manage API keys')
.addHelpText('after', `
Examples:
$ blindpay api_keys list
$ blindpay api_keys create --name "Production Key"
$ blindpay api_keys delete <id>`)

apiKeys
.command('list')
.description('List API keys')
.option('--json', 'Output as JSON', false)
.action(opts => listApiKeys(opts))

apiKeys
.command('create')
.description('Create an API key')
.option('--name <name>', 'Key name', 'CLI API Key')
.option('--permission <permission>', 'Permission level')
.option('--json', 'Output as JSON', false)
.action(opts => createApiKey(opts))

apiKeys
.command('delete <id>')
.description('Delete an API key')
.option('--json', 'Output as JSON', false)
.action((id, opts) => deleteApiKey(id, opts))

// ── Virtual Accounts ────────────────────────────────────────────────────
const virtualAccounts = program.command('virtual_accounts').description('Manage virtual accounts')
.addHelpText('after', `
Expand Down
Loading