@instantkom/cli 3.173.0 → 3.174.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ import { BaseCommand } from '../../../base-command.js';
2
+ export default class TokensGet extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<number, {
6
+ max?: number;
7
+ min?: number;
8
+ }>;
9
+ };
10
+ static flags: {
11
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ 'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ };
19
+ run(): Promise<void>;
20
+ }
@@ -0,0 +1,46 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../../base-command.js';
3
+ import { ApiError } from '../../../errors/api-error.js';
4
+ import { resolveToken } from '../../../auth/token-resolver.js';
5
+ import { ApiClient } from '../../../api-client.js';
6
+ export default class TokensGet extends BaseCommand {
7
+ static description = 'Get details for a single API token by ID';
8
+ static args = {
9
+ id: Args.integer({
10
+ description: 'Token ID to fetch',
11
+ required: true,
12
+ }),
13
+ };
14
+ static flags = {
15
+ ...BaseCommand.baseFlags,
16
+ };
17
+ async run() {
18
+ const { args, flags } = await this.parse(TokensGet);
19
+ this.flags = flags;
20
+ const token = await resolveToken({
21
+ flag: flags['api-key'],
22
+ env: process.env.IKM_API_KEY,
23
+ profile: flags.profile ?? 'default',
24
+ });
25
+ if (!token) {
26
+ throw new ApiError('unauthorized', 'Not logged in. Run: ikm auth login');
27
+ }
28
+ const apiUrl = flags['api-url'] ?? process.env.IKM_API_URL ?? 'https://api.instantkom.app';
29
+ const client = new ApiClient({
30
+ id: flags.profile ?? 'default',
31
+ name: 'ikm-cli',
32
+ apiUrl,
33
+ apiKey: token,
34
+ scope: 'customer',
35
+ });
36
+ const result = await client.get(`/v1/api-keys/${args.id}`);
37
+ this.log(this.toFormatted({
38
+ id: result.id,
39
+ name: result.nm ?? result.name ?? '',
40
+ scope: result.token_scope ?? result.tokenScope ?? '',
41
+ last_used: result.last_used_at ?? result.lastUsedAt ?? '',
42
+ expires: result.expires_at ?? result.expiresAt ?? '',
43
+ is_active: result.is_active ?? result.isActive ?? '',
44
+ }));
45
+ }
46
+ }
@@ -0,0 +1,22 @@
1
+ import { BaseCommand } from '../../../../base-command.js';
2
+ export default class TokensIpWhitelistAdd extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ apiKeyId: import("@oclif/core/interfaces").Arg<number, {
6
+ max?: number;
7
+ min?: number;
8
+ }>;
9
+ };
10
+ static flags: {
11
+ ip: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ 'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ };
21
+ run(): Promise<void>;
22
+ }
@@ -0,0 +1,55 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../../../base-command.js';
3
+ import { ApiError } from '../../../../errors/api-error.js';
4
+ import { resolveToken } from '../../../../auth/token-resolver.js';
5
+ import { ApiClient } from '../../../../api-client.js';
6
+ export default class TokensIpWhitelistAdd extends BaseCommand {
7
+ static description = 'Add an IP address to the whitelist for an API token';
8
+ static args = {
9
+ apiKeyId: Args.integer({
10
+ description: 'API token ID',
11
+ required: true,
12
+ }),
13
+ };
14
+ static flags = {
15
+ ...BaseCommand.baseFlags,
16
+ ip: Flags.string({
17
+ description: 'IPv4 address to whitelist',
18
+ required: true,
19
+ }),
20
+ description: Flags.string({
21
+ description: 'Description of this IP whitelist entry',
22
+ }),
23
+ };
24
+ async run() {
25
+ const { args, flags } = await this.parse(TokensIpWhitelistAdd);
26
+ this.flags = flags;
27
+ const token = await resolveToken({
28
+ flag: flags['api-key'],
29
+ env: process.env.IKM_API_KEY,
30
+ profile: flags.profile ?? 'default',
31
+ });
32
+ if (!token) {
33
+ throw new ApiError('unauthorized', 'Not logged in. Run: ikm auth login');
34
+ }
35
+ const apiUrl = flags['api-url'] ?? process.env.IKM_API_URL ?? 'https://api.instantkom.app';
36
+ const client = new ApiClient({
37
+ id: flags.profile ?? 'default',
38
+ name: 'ikm-cli',
39
+ apiUrl,
40
+ apiKey: token,
41
+ scope: 'customer',
42
+ });
43
+ const body = { ip: flags.ip };
44
+ if (flags.description !== undefined) {
45
+ body.description = flags.description;
46
+ }
47
+ const result = await client.post(`/v1/api-keys/${args.apiKeyId}/ip-whitelist`, body);
48
+ this.log(this.toFormatted({
49
+ id: result.id,
50
+ ip: result.ip ?? '',
51
+ description: result.description ?? '',
52
+ status: result.status ?? '',
53
+ }));
54
+ }
55
+ }
@@ -0,0 +1,20 @@
1
+ import { BaseCommand } from '../../../../base-command.js';
2
+ export default class TokensIpWhitelistList extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ apiKeyId: import("@oclif/core/interfaces").Arg<number, {
6
+ max?: number;
7
+ min?: number;
8
+ }>;
9
+ };
10
+ static flags: {
11
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ 'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ };
19
+ run(): Promise<void>;
20
+ }
@@ -0,0 +1,45 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../../../base-command.js';
3
+ import { ApiError } from '../../../../errors/api-error.js';
4
+ import { resolveToken } from '../../../../auth/token-resolver.js';
5
+ import { ApiClient } from '../../../../api-client.js';
6
+ export default class TokensIpWhitelistList extends BaseCommand {
7
+ static description = 'List all whitelisted IPs for an API token';
8
+ static args = {
9
+ apiKeyId: Args.integer({
10
+ description: 'API token ID',
11
+ required: true,
12
+ }),
13
+ };
14
+ static flags = {
15
+ ...BaseCommand.baseFlags,
16
+ };
17
+ async run() {
18
+ const { args, flags } = await this.parse(TokensIpWhitelistList);
19
+ this.flags = flags;
20
+ const token = await resolveToken({
21
+ flag: flags['api-key'],
22
+ env: process.env.IKM_API_KEY,
23
+ profile: flags.profile ?? 'default',
24
+ });
25
+ if (!token) {
26
+ throw new ApiError('unauthorized', 'Not logged in. Run: ikm auth login');
27
+ }
28
+ const apiUrl = flags['api-url'] ?? process.env.IKM_API_URL ?? 'https://api.instantkom.app';
29
+ const client = new ApiClient({
30
+ id: flags.profile ?? 'default',
31
+ name: 'ikm-cli',
32
+ apiUrl,
33
+ apiKey: token,
34
+ scope: 'customer',
35
+ });
36
+ const result = await client.get(`/v1/api-keys/${args.apiKeyId}/ip-whitelist`);
37
+ const items = (Array.isArray(result) ? result : []).map((item) => ({
38
+ id: item.id,
39
+ ip: item.ip ?? '',
40
+ description: item.description ?? '',
41
+ status: item.status ?? '',
42
+ }));
43
+ this.log(this.toFormatted(items));
44
+ }
45
+ }
@@ -0,0 +1,24 @@
1
+ import { BaseCommand } from '../../../../base-command.js';
2
+ export default class TokensIpWhitelistRemove extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ apiKeyId: import("@oclif/core/interfaces").Arg<number, {
6
+ max?: number;
7
+ min?: number;
8
+ }>;
9
+ id: import("@oclif/core/interfaces").Arg<number, {
10
+ max?: number;
11
+ min?: number;
12
+ }>;
13
+ };
14
+ static flags: {
15
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
17
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
+ 'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
20
+ profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
21
+ 'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ };
23
+ run(): Promise<void>;
24
+ }
@@ -0,0 +1,43 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../../../base-command.js';
3
+ import { ApiError } from '../../../../errors/api-error.js';
4
+ import { resolveToken } from '../../../../auth/token-resolver.js';
5
+ import { ApiClient } from '../../../../api-client.js';
6
+ export default class TokensIpWhitelistRemove extends BaseCommand {
7
+ static description = 'Remove an IP address from the whitelist for an API token';
8
+ static args = {
9
+ apiKeyId: Args.integer({
10
+ description: 'API token ID',
11
+ required: true,
12
+ }),
13
+ id: Args.integer({
14
+ description: 'IP whitelist entry ID to remove',
15
+ required: true,
16
+ }),
17
+ };
18
+ static flags = {
19
+ ...BaseCommand.baseFlags,
20
+ };
21
+ async run() {
22
+ const { args, flags } = await this.parse(TokensIpWhitelistRemove);
23
+ this.flags = flags;
24
+ const token = await resolveToken({
25
+ flag: flags['api-key'],
26
+ env: process.env.IKM_API_KEY,
27
+ profile: flags.profile ?? 'default',
28
+ });
29
+ if (!token) {
30
+ throw new ApiError('unauthorized', 'Not logged in. Run: ikm auth login');
31
+ }
32
+ const apiUrl = flags['api-url'] ?? process.env.IKM_API_URL ?? 'https://api.instantkom.app';
33
+ const client = new ApiClient({
34
+ id: flags.profile ?? 'default',
35
+ name: 'ikm-cli',
36
+ apiUrl,
37
+ apiKey: token,
38
+ scope: 'customer',
39
+ });
40
+ await client.delete(`/v1/api-keys/${args.apiKeyId}/ip-whitelist/${args.id}`);
41
+ this.log(`IP whitelist entry ${args.id} removed from token ${args.apiKeyId}.`);
42
+ }
43
+ }
@@ -0,0 +1,21 @@
1
+ import { BaseCommand } from '../../../base-command.js';
2
+ export default class TokensUpdate extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<number, {
6
+ max?: number;
7
+ min?: number;
8
+ }>;
9
+ };
10
+ static flags: {
11
+ name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ 'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ };
20
+ run(): Promise<void>;
21
+ }
@@ -0,0 +1,50 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../../base-command.js';
3
+ import { ApiError } from '../../../errors/api-error.js';
4
+ import { resolveToken } from '../../../auth/token-resolver.js';
5
+ import { ApiClient } from '../../../api-client.js';
6
+ export default class TokensUpdate extends BaseCommand {
7
+ static description = 'Update an API token by ID';
8
+ static args = {
9
+ id: Args.integer({
10
+ description: 'Token ID to update',
11
+ required: true,
12
+ }),
13
+ };
14
+ static flags = {
15
+ ...BaseCommand.baseFlags,
16
+ name: Flags.string({
17
+ description: 'New token name',
18
+ required: true,
19
+ }),
20
+ };
21
+ async run() {
22
+ const { args, flags } = await this.parse(TokensUpdate);
23
+ this.flags = flags;
24
+ const token = await resolveToken({
25
+ flag: flags['api-key'],
26
+ env: process.env.IKM_API_KEY,
27
+ profile: flags.profile ?? 'default',
28
+ });
29
+ if (!token) {
30
+ throw new ApiError('unauthorized', 'Not logged in. Run: ikm auth login');
31
+ }
32
+ const apiUrl = flags['api-url'] ?? process.env.IKM_API_URL ?? 'https://api.instantkom.app';
33
+ const client = new ApiClient({
34
+ id: flags.profile ?? 'default',
35
+ name: 'ikm-cli',
36
+ apiUrl,
37
+ apiKey: token,
38
+ scope: 'customer',
39
+ });
40
+ const result = await client.put(`/v1/api-keys/${args.id}`, {
41
+ name: flags.name,
42
+ });
43
+ this.log(this.toFormatted({
44
+ id: result.id,
45
+ name: result.nm ?? result.name ?? '',
46
+ scope: result.token_scope ?? result.tokenScope ?? '',
47
+ is_active: result.is_active ?? result.isActive ?? '',
48
+ }));
49
+ }
50
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@instantkom/cli",
3
- "version": "3.173.0",
3
+ "version": "3.174.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@instantkom/cli",
9
- "version": "3.173.0",
9
+ "version": "3.174.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@oclif/core": "^4",