kinde-ops 1.0.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.
Files changed (62) hide show
  1. package/README.md +422 -0
  2. package/dist/cli/commands/config.d.ts +4 -0
  3. package/dist/cli/commands/config.d.ts.map +1 -0
  4. package/dist/cli/commands/config.js +40 -0
  5. package/dist/cli/commands/config.js.map +1 -0
  6. package/dist/cli/commands/organizations.d.ts +4 -0
  7. package/dist/cli/commands/organizations.d.ts.map +1 -0
  8. package/dist/cli/commands/organizations.js +36 -0
  9. package/dist/cli/commands/organizations.js.map +1 -0
  10. package/dist/cli/commands/users.d.ts +4 -0
  11. package/dist/cli/commands/users.d.ts.map +1 -0
  12. package/dist/cli/commands/users.js +60 -0
  13. package/dist/cli/commands/users.js.map +1 -0
  14. package/dist/cli/context/runtime.d.ts +2 -0
  15. package/dist/cli/context/runtime.d.ts.map +1 -0
  16. package/dist/cli/context/runtime.js +25 -0
  17. package/dist/cli/context/runtime.js.map +1 -0
  18. package/dist/cli/index.d.ts +2 -0
  19. package/dist/cli/index.d.ts.map +1 -0
  20. package/dist/cli/index.js +26 -0
  21. package/dist/cli/index.js.map +1 -0
  22. package/dist/kinde/organizations.d.ts +5 -0
  23. package/dist/kinde/organizations.d.ts.map +1 -0
  24. package/dist/kinde/organizations.js +34 -0
  25. package/dist/kinde/organizations.js.map +1 -0
  26. package/dist/kinde/users.d.ts +8 -0
  27. package/dist/kinde/users.d.ts.map +1 -0
  28. package/dist/kinde/users.js +44 -0
  29. package/dist/kinde/users.js.map +1 -0
  30. package/dist/kinde/utils/client.d.ts +3 -0
  31. package/dist/kinde/utils/client.d.ts.map +1 -0
  32. package/dist/kinde/utils/client.js +42 -0
  33. package/dist/kinde/utils/client.js.map +1 -0
  34. package/dist/kinde/utils/error-handler.d.ts +6 -0
  35. package/dist/kinde/utils/error-handler.d.ts.map +1 -0
  36. package/dist/kinde/utils/error-handler.js +21 -0
  37. package/dist/kinde/utils/error-handler.js.map +1 -0
  38. package/dist/kinde/utils/query.d.ts +2 -0
  39. package/dist/kinde/utils/query.d.ts.map +1 -0
  40. package/dist/kinde/utils/query.js +17 -0
  41. package/dist/kinde/utils/query.js.map +1 -0
  42. package/dist/types/config.d.ts +7 -0
  43. package/dist/types/config.d.ts.map +1 -0
  44. package/dist/types/config.js +2 -0
  45. package/dist/types/config.js.map +1 -0
  46. package/dist/types/organization.d.ts +24 -0
  47. package/dist/types/organization.d.ts.map +1 -0
  48. package/dist/types/organization.js +2 -0
  49. package/dist/types/organization.js.map +1 -0
  50. package/dist/types/user.d.ts +36 -0
  51. package/dist/types/user.d.ts.map +1 -0
  52. package/dist/types/user.js +2 -0
  53. package/dist/types/user.js.map +1 -0
  54. package/dist/utils/config/config.d.ts +8 -0
  55. package/dist/utils/config/config.d.ts.map +1 -0
  56. package/dist/utils/config/config.js +55 -0
  57. package/dist/utils/config/config.js.map +1 -0
  58. package/dist/utils/config/secret-store.d.ts +3 -0
  59. package/dist/utils/config/secret-store.d.ts.map +1 -0
  60. package/dist/utils/config/secret-store.js +11 -0
  61. package/dist/utils/config/secret-store.js.map +1 -0
  62. package/package.json +51 -0
package/README.md ADDED
@@ -0,0 +1,422 @@
1
+ # kinde-ops 🚀
2
+
3
+ > Unofficial CLI tool for creating test data and running simple workflows in Kinde.
4
+
5
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/arobce/kinde-ops/ci.yml?branch=main)](
6
+ [![npm version](https://img.shields.io/npm/v/kinde-ops.svg)](https://www.npmjs.com/package/kinde-ops)
7
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
8
+
9
+ ## 📋 Table of Contents
10
+
11
+ - [Features](#-features)
12
+ - [Installation](#-installation)
13
+ - [Quick Start](#-quick-start)
14
+ - [Configuration](#-configuration)
15
+ - [Commands](#-commands)
16
+ - [Config Commands](#config-commands)
17
+ - [User Commands](#user-commands)
18
+ - [Organization Commands](#organization-commands)
19
+ - [Options](#-options)
20
+ - [Examples](#-examples)
21
+ - [Development](#-development)
22
+ - [Contributing](#-contributing)
23
+ - [License](#-license)
24
+
25
+ ## ✨ Features
26
+
27
+ - 🔧 **Easy Configuration** - Interactive setup wizard for quick onboarding
28
+ - 👥 **User Management** - List, filter, and seed users with advanced options
29
+ - 🏢 **Organization Management** - Manage and seed organizations effortlessly
30
+ - 🎲 **Data Seeding** - Generate realistic test data using Faker.js
31
+ - 🔐 **Secure Credential Storage** - Credentials stored securely in system keychain
32
+ - 🎨 **Beautiful CLI** - Colorful, intuitive interface built with Chalk
33
+ - 🚀 **Developer Focused** - Built for QA teams and developers working with Kinde
34
+
35
+ ## 📦 Installation
36
+
37
+ ### Global Installation (Recommended)
38
+
39
+ ```bash
40
+ npm install -g kinde-ops
41
+ ```
42
+
43
+ ### Local Installation
44
+
45
+ ```bash
46
+ npm install kinde-ops
47
+ ```
48
+
49
+ ### From Source
50
+
51
+ ```bash
52
+ git clone https://github.com/arobce/kinde-ops.git
53
+ cd kinde-ops
54
+ npm install
55
+ npm run build
56
+ npm link
57
+ ```
58
+
59
+ ## 🚀 Quick Start
60
+
61
+ 1. **Initialize your configuration**
62
+
63
+ ```bash
64
+ kinde-ops init
65
+ ```
66
+
67
+ You'll be prompted to enter:
68
+ - Profile name (e.g., "default", "production", "staging")
69
+ - Kinde domain (e.g., your-domain.kinde.com)
70
+ - M2M Client ID
71
+ - M2M Client Secret
72
+
73
+ 2. **List users**
74
+
75
+ ```bash
76
+ kinde-ops users:list
77
+ ```
78
+
79
+ 3. **Seed test data**
80
+
81
+ ```bash
82
+ kinde-ops users:seed --number 10 --base-email test@example.com
83
+ ```
84
+
85
+ ## ⚙️ Configuration
86
+
87
+ ### Profile Management
88
+
89
+ kinde-ops supports multiple profiles for different environments:
90
+
91
+ ```bash
92
+ # Initialize a new profile
93
+ kinde-ops init
94
+
95
+ # Use a specific profile
96
+ kinde-ops users:list --profile production
97
+ ```
98
+
99
+ ### Credential Storage
100
+
101
+ Credentials are securely stored in your system's keychain using [keytar](https://www.npmjs.com/package/keytar):
102
+ - **macOS**: Keychain
103
+ - **Linux**: libsecret
104
+ - **Windows**: Credential Vault
105
+
106
+ ## 📚 Commands
107
+
108
+ ### Config Commands
109
+
110
+ #### `init`
111
+
112
+ Initialize or update your Kinde CLI configuration.
113
+
114
+ ```bash
115
+ kinde-ops init
116
+ ```
117
+
118
+ **Interactive prompts:**
119
+ - Profile name
120
+ - Kinde domain
121
+ - M2M Client ID
122
+ - M2M Client Secret
123
+
124
+ ---
125
+
126
+ ### User Commands
127
+
128
+ #### `users:list`
129
+
130
+ List users with optional filtering and pagination.
131
+
132
+ ```bash
133
+ kinde-ops users:list [options]
134
+ ```
135
+
136
+ **Options:**
137
+
138
+ | Option | Description | Example |
139
+ |--------|-------------|---------|
140
+ | `--page-size <number>` | Number of results per page | `--page-size 50` |
141
+ | `--next-token <token>` | Pagination token for next page | `--next-token abc123` |
142
+ | `--user-id <ids>` | Filter by comma-separated user IDs | `--user-id id1,id2` |
143
+ | `--email <emails>` | Filter by comma-separated emails | `--email user1@test.com,user2@test.com` |
144
+ | `--username <names>` | Filter by comma-separated usernames | `--username john,jane` |
145
+ | `--phone <phones>` | Filter by comma-separated phone numbers | `--phone +1234567890` |
146
+ | `--expand <fields>` | Expand related data: organizations, identities, billing | `--expand organizations,identities` |
147
+ | `--has-organization` | Only return users with at least one organization | `--has-organization` |
148
+ | `--verbose` | Enable detailed output | `--verbose` |
149
+
150
+ **Examples:**
151
+
152
+ ```bash
153
+ # List all users
154
+ kinde-ops users:list
155
+
156
+ # List users with pagination
157
+ kinde-ops users:list --page-size 25
158
+
159
+ # Filter by email
160
+ kinde-ops users:list --email admin@example.com
161
+
162
+ # Expand organizations data
163
+ kinde-ops users:list --expand organizations --verbose
164
+ ```
165
+
166
+ #### `users:seed`
167
+
168
+ Create multiple test users with realistic fake data.
169
+
170
+ ```bash
171
+ kinde-ops users:seed [options]
172
+ ```
173
+
174
+ **Options:**
175
+
176
+ | Option | Description | Default |
177
+ |--------|-------------|---------|
178
+ | `--number <number>` | Number of users to create | Required |
179
+ | `--base-email <email>` | Base email, emails are then generated by prefixing +<number> before the @ symbol | Required |
180
+ | `--is-verified` | Mark users as verified | `false` |
181
+
182
+ **Examples:**
183
+
184
+ ```bash
185
+ # Create verified users with specific email pattern
186
+ kinde-ops users:seed --number 5 --base-email test@mycompany.com --is-verified
187
+ ```
188
+
189
+ ---
190
+
191
+ ### Organization Commands
192
+
193
+ #### `organizations:list`
194
+
195
+ List all organizations with optional pagination.
196
+
197
+ ```bash
198
+ kinde-ops organizations:list [options]
199
+ ```
200
+
201
+ **Options:**
202
+
203
+ | Option | Description |
204
+ |--------|-------------|
205
+ | `--page-size <number>` | Number of results per page |
206
+ | `--verbose` | Enable detailed output |
207
+
208
+ **Examples:**
209
+
210
+ ```bash
211
+ # List all organizations
212
+ kinde-ops organizations:list
213
+
214
+ # List with custom page size
215
+ kinde-ops organizations:list --page-size 50 --verbose
216
+ ```
217
+
218
+ #### `organizations:seed`
219
+
220
+ Create multiple test organizations.
221
+
222
+ ```bash
223
+ kinde-ops organizations:seed [options]
224
+ ```
225
+
226
+ **Options:**
227
+
228
+ | Option | Description |
229
+ |--------|-------------|
230
+ | `--number <number>` | Number of organizations to create |
231
+
232
+ **Examples:**
233
+
234
+ ```bash
235
+ # Create 5 test organizations
236
+ kinde-ops organizations:seed --number 5
237
+ ```
238
+
239
+ ## 🎛️ Options
240
+
241
+ ### Global Options
242
+
243
+ Available for all commands:
244
+
245
+ | Option | Description | Example |
246
+ |--------|-------------|---------|
247
+ | `--profile <name>` | Use a specific configuration profile | `--profile production` |
248
+ | `-h, --help` | Display help for command | |
249
+ | `-V, --version` | Output version number | |
250
+
251
+ ## 💡 Examples
252
+
253
+ ### Complete Workflow Example
254
+
255
+ ```bash
256
+ # 1. Initialize configuration
257
+ kinde-ops init
258
+
259
+ # 2. Create test organizations
260
+ kinde-ops organizations:seed --number 3
261
+
262
+ # 3. Create test users
263
+ kinde-ops users:seed --number 20 --base-email qa@company.com --is-verified
264
+
265
+ # 4. List all users with organization details
266
+ kinde-ops users:list --expand organizations --verbose
267
+
268
+ # 5. Filter specific users
269
+ kinde-ops users:list --email qa1@company.com,qa2@company.com
270
+ ```
271
+
272
+ ### Multi-Environment Setup
273
+
274
+ ```bash
275
+ # Configure development environment
276
+ kinde-ops init
277
+ # Enter profile: dev
278
+ # Enter domain: dev.kinde.com
279
+ # ...
280
+
281
+ # Configure production environment
282
+ kinde-ops init
283
+ # Enter profile: production
284
+ # Enter domain: prod.kinde.com
285
+ # ...
286
+
287
+ # Use different profiles
288
+ kinde-ops users:list --profile dev
289
+ kinde-ops users:list --profile production
290
+ ```
291
+
292
+ ## 🛠️ Development
293
+
294
+ ### Prerequisites
295
+
296
+ - Node.js 18.x or higher
297
+ - npm or yarn
298
+
299
+ ### Setup
300
+
301
+ ```bash
302
+ # Clone the repository
303
+ git clone https://github.com/arobce/kinde-ops.git
304
+ cd kinde-ops
305
+
306
+ # Install dependencies
307
+ npm install
308
+
309
+ # Run in development mode
310
+ npm run dev
311
+
312
+ # Build the project
313
+ npm run build
314
+
315
+ # Link for local testing
316
+ npm link
317
+ ```
318
+
319
+ ### Project Structure
320
+
321
+ ```
322
+ kinde-ops/
323
+ ├── src/
324
+ │ ├── cli/
325
+ │ │ ├── index.ts # Main CLI entry point
326
+ │ │ ├── commands/ # Command implementations
327
+ │ │ │ ├── config.ts
328
+ │ │ │ ├── organizations.ts
329
+ │ │ │ └── users.ts
330
+ │ │ └── context/
331
+ │ │ └── runtime.ts # Profile resolution
332
+ │ ├── kinde/
333
+ │ │ ├── organizations.ts # Organization API calls
334
+ │ │ ├── users.ts # User API calls
335
+ │ │ └── utils/
336
+ │ │ ├── client.ts # HTTP client setup
337
+ │ │ ├── error-handler.ts # Error handling
338
+ │ │ └── query.ts # Query builder
339
+ │ ├── types/ # TypeScript type definitions
340
+ │ └── utils/
341
+ │ └── config/ # Configuration management
342
+ ├── dist/ # Compiled output
343
+ ├── package.json
344
+ ├── tsconfig.json
345
+ └── README.md
346
+ ```
347
+
348
+ ### Scripts
349
+
350
+ | Script | Description |
351
+ |--------|-------------|
352
+ | `npm run dev` | Run CLI in development mode |
353
+ | `npm run build` | Compile TypeScript to JavaScript |
354
+ | `npm run prepublishOnly` | Automatically build before publishing |
355
+
356
+ ## 🔮 Coming Soon
357
+
358
+ ### 🎯 Automated Workflows
359
+
360
+ - **End-to-End Test Scenarios** - Run complete workflows with a single command
361
+ - Generate users → Create organizations → Auto-assign users to organizations
362
+ - Customizable workflow templates for common testing scenarios
363
+ - Batch operations with progress tracking
364
+
365
+ ### 🚀 Enhanced Management
366
+
367
+ - **Advanced User Operations**
368
+ - Bulk user updates and deletions
369
+ - User role management and permissions
370
+ - Import/export user data (CSV, JSON)
371
+ - User activity tracking and reporting
372
+
373
+ - **Organization Management**
374
+ - Assign/remove users from organizations
375
+ - Bulk organization operations
376
+ - Organization hierarchy management
377
+ - Custom organization properties
378
+
379
+ - **Role & Permission Management**
380
+ - Create and manage custom roles
381
+ - Assign roles to users and organizations
382
+ - Permission auditing and reporting
383
+
384
+ ### 📊 Analytics & Reporting
385
+
386
+ - Generate comprehensive reports on users, organizations, and activities
387
+ - Export data in multiple formats (JSON, CSV, HTML)
388
+ - Custom query builder for complex filtering
389
+
390
+ Want to see a feature sooner? [Open an issue](https://github.com/arobce/kinde-ops/issues) or contribute!
391
+
392
+ ## 🤝 Contributing
393
+
394
+ Contributions are welcome! Please follow these steps:
395
+
396
+ 1. Fork the repository
397
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
398
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
399
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
400
+ 5. Open a Pull Request
401
+
402
+ ## 📝 License
403
+
404
+ ISC © Roshan Chapagain
405
+
406
+ ## 🔗 Links
407
+
408
+ - [NPM Package](https://www.npmjs.com/package/kinde-ops)
409
+ - [GitHub Repository](https://github.com/arobce/kinde-ops)
410
+ - [Report Issues](https://github.com/arobce/kinde-ops/issues)
411
+ - [Kinde Documentation](https://kinde.com/docs)
412
+
413
+ ## 🙏 Acknowledgments
414
+
415
+ - Built with [Commander.js](https://github.com/tj/commander.js)
416
+ - Styled with [Chalk](https://github.com/chalk/chalk)
417
+ - Test data from [Faker.js](https://fakerjs.dev/)
418
+ - Secure storage via [Keytar](https://github.com/atom/node-keytar)
419
+
420
+ ---
421
+
422
+ **Made with ❤️ for the Kinde community**
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ declare const createCommands: (program: Command) => void;
3
+ export default createCommands;
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,QAAA,MAAM,cAAc,GAAI,SAAS,OAAO,SAoCvC,CAAA;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,40 @@
1
+ import inquirer from "inquirer";
2
+ import { saveConfig } from "../../utils/config/config.js";
3
+ const createCommands = (program) => {
4
+ program.command("init").description("Initialize Kinde CLI configuration").action(async () => {
5
+ try {
6
+ const answers = await inquirer.prompt([
7
+ {
8
+ type: "input",
9
+ name: "profileName",
10
+ message: "Enter a profile name:",
11
+ default: "default",
12
+ },
13
+ {
14
+ type: "input",
15
+ name: "kindeDomain",
16
+ message: "Enter your Kinde domain (e.g., your-domain.kinde.com):",
17
+ validate: (input) => input ? true : "Kinde domain cannot be empty.",
18
+ },
19
+ {
20
+ type: "input",
21
+ name: "m2mClientId",
22
+ message: "Enter your M2M Client ID:",
23
+ validate: (input) => input ? true : "Client ID cannot be empty.",
24
+ },
25
+ {
26
+ type: "input",
27
+ name: "m2mClientSecret",
28
+ message: "Enter your M2M Client Secret:",
29
+ validate: (input) => input ? true : "Client Secret cannot be empty.",
30
+ },
31
+ ]);
32
+ await saveConfig(answers);
33
+ }
34
+ catch (error) {
35
+ console.error("Error during initialization:", error);
36
+ }
37
+ });
38
+ };
39
+ export default createCommands;
40
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/cli/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE;IACxC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,oCAAoC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACxF,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;gBAClC;oBACI,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,aAAa;oBACnB,OAAO,EAAE,uBAAuB;oBAChC,OAAO,EAAE,SAAS;iBACrB;gBACD;oBACI,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,aAAa;oBACnB,OAAO,EAAE,wDAAwD;oBACjE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,+BAA+B;iBACtE;gBACD;oBACI,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,aAAa;oBACnB,OAAO,EAAE,2BAA2B;oBACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,4BAA4B;iBACnE;gBACD;oBACI,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,iBAAiB;oBACvB,OAAO,EAAE,+BAA+B;oBACxC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gCAAgC;iBACvE;aACJ,CAAC,CAAC;YAEH,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;IACL,CAAC,CAAC,CAAC;AAEP,CAAC,CAAA;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ declare const createCommands: (program: Command) => void;
3
+ export default createCommands;
4
+ //# sourceMappingURL=organizations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/organizations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,QAAA,MAAM,cAAc,GAAI,SAAS,OAAO,SA+BvC,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,36 @@
1
+ import chalk from 'chalk';
2
+ import { handleErrors } from '../../kinde/utils/error-handler.js';
3
+ import { listOrganizations, seedOrganizations } from '../../kinde/organizations.js';
4
+ const createCommands = (program) => {
5
+ program
6
+ .command("organizations:list")
7
+ .description("List organizations")
8
+ .option("--page-size <number>", "Number of results per page", Number)
9
+ .option("--verbose", "Enable verbose output")
10
+ .action(async (options) => {
11
+ try {
12
+ const orgs = await listOrganizations(options);
13
+ console.log(chalk.green(`Successfully fetched ${Array.isArray(orgs) ? orgs.length : 0} organizations.`));
14
+ console.log(orgs);
15
+ }
16
+ catch (error) {
17
+ handleErrors(error);
18
+ }
19
+ });
20
+ program
21
+ .command("organizations:seed")
22
+ .description("Seed multiple organizations")
23
+ .option("--number <number>", "Number of organizations to create", Number)
24
+ .action(async (options) => {
25
+ try {
26
+ const createdOrgs = await seedOrganizations(options.number);
27
+ console.log(chalk.green(`Successfully created ${createdOrgs.length} organizations.`));
28
+ console.log(createdOrgs);
29
+ }
30
+ catch (error) {
31
+ handleErrors(error);
32
+ }
33
+ });
34
+ };
35
+ export default createCommands;
36
+ //# sourceMappingURL=organizations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.js","sourceRoot":"","sources":["../../../src/cli/commands/organizations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEpF,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE;IAExC,OAAO;SACF,OAAO,CAAC,oBAAoB,CAAC;SAC7B,WAAW,CAAC,oBAAoB,CAAC;SACjC,MAAM,CAAC,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,CAAC;SACpE,MAAM,CAAC,WAAW,EAAE,uBAAuB,CAAC;SAC5C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACtB,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,wBAAwB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;YACzG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,YAAY,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACL,CAAC,CAAC,CAAC;IAEP,OAAO;SACF,OAAO,CAAC,oBAAoB,CAAC;SAC7B,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,CAAC;SACxE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACtB,IAAI,CAAC;YACD,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,wBAAwB,WAAW,CAAC,MAAM,iBAAiB,CAAC,CAAC,CAAC;YACtF,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,YAAY,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACL,CAAC,CAAC,CAAC;AAEX,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ declare const createCommands: (program: Command) => void;
3
+ export default createCommands;
4
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/users.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,QAAA,MAAM,cAAc,GAAI,SAAS,OAAO,SA4DvC,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,60 @@
1
+ import chalk from "chalk";
2
+ import { seedUsers, listUsers } from '../../kinde/users.js';
3
+ import { handleErrors } from "../../kinde/utils/error-handler.js";
4
+ const createCommands = (program) => {
5
+ // User list
6
+ program
7
+ .command("users:list")
8
+ .description("List users with optional filters")
9
+ .option("--page-size <number>", "Number of results per page", Number)
10
+ .option("--next-token <token>", "Pagination token")
11
+ .option("--user-id <ids>", "Comma-separated user IDs")
12
+ .option("--email <emails>", "Comma-separated emails")
13
+ .option("--username <names>", "Comma-separated usernames")
14
+ .option("--phone <phones>", "Comma-separated phone numbers")
15
+ .option("--verbose", "Enable verbose output")
16
+ .option("--expand <fields>", "Comma-separated: organizations,identities,billing")
17
+ .option("--has-organization", "Only users with at least one org")
18
+ .action(async (options) => {
19
+ try {
20
+ const users = await listUsers({
21
+ pageSize: options.pageSize,
22
+ nextToken: options.nextToken,
23
+ userId: options.userId?.split(","),
24
+ email: options.email?.split(","),
25
+ username: options.username?.split(","),
26
+ phone: options.phone?.split(","),
27
+ expand: options.expand?.split(","),
28
+ hasOrganization: options.hasOrganization,
29
+ verbose: options.verbose,
30
+ });
31
+ console.log(chalk.green(`Successfully fetched ${Array.isArray(users) ? users.length : 0} users.`));
32
+ console.log(users);
33
+ }
34
+ catch (error) {
35
+ handleErrors(error);
36
+ }
37
+ });
38
+ // Seed User
39
+ program
40
+ .command("users:seed")
41
+ .description("Seed multiple users")
42
+ .requiredOption("--number <number>", "Number of users to create", Number)
43
+ .requiredOption("--base-email <email>", "Base email to generate user emails (e.g., user@example.com)")
44
+ .option("--is-verified", "Mark users as verified")
45
+ .action(async (options) => {
46
+ try {
47
+ const createdUsers = await seedUsers({
48
+ number: options.number,
49
+ baseEmailToAddUsersNumber: options.baseEmail,
50
+ isVerified: options.isVerified,
51
+ });
52
+ console.log(chalk.green(`Successfully created ${createdUsers.length} users.`));
53
+ }
54
+ catch (error) {
55
+ handleErrors(error);
56
+ }
57
+ });
58
+ };
59
+ export default createCommands;
60
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../../src/cli/commands/users.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export declare const resolveProfile: (cliProfile?: string) => Promise<string>;
2
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/cli/context/runtime.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,MAAM,CA0BxE,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { loadConfig } from "../../utils/config/config.js";
2
+ let resolvedProfile = null;
3
+ export const resolveProfile = async (cliProfile) => {
4
+ if (resolvedProfile) {
5
+ return resolvedProfile;
6
+ }
7
+ const config = await loadConfig();
8
+ if (!resolvedProfile) {
9
+ if (config.some(c => c.profileName === 'default')) {
10
+ resolvedProfile = 'default';
11
+ }
12
+ else {
13
+ throw new Error("No profiles found in configuration. Please initialize a profile using 'kinde config init'.");
14
+ }
15
+ }
16
+ if (cliProfile) {
17
+ if (!config.some(c => c.profileName === cliProfile)) {
18
+ throw new Error(`Profile '${cliProfile}' not found in configuration.`);
19
+ }
20
+ resolvedProfile = cliProfile;
21
+ return resolvedProfile;
22
+ }
23
+ return resolvedProfile;
24
+ };
25
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/cli/context/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,IAAI,eAAe,GAAkB,IAAI,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,UAAmB,EAAmB,EAAE;IACzE,IAAI,eAAe,EAAE,CAAC;QAClB,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAEjC,IAAI,CAAC,eAAe,EAAE,CAAC;QACpB,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,SAAS,CAAC,EAAE,CAAC;YAChD,eAAe,GAAG,SAAS,CAAC;QAChC,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;QAElH,CAAC;IACL,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,UAAU,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,YAAY,UAAU,+BAA+B,CAAC,CAAC;QAC3E,CAAC;QACD,eAAe,GAAG,UAAU,CAAC;QAC7B,OAAO,eAAe,CAAC;IAC3B,CAAC;IAGD,OAAO,eAAe,CAAC;AAC3B,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { Command } from 'commander';
2
+ import createUserCommands from './commands/users.js';
3
+ import { resolveProfile } from './context/runtime.js';
4
+ import createConfigCommands from './commands/config.js';
5
+ import createOrganizationCommands from './commands/organizations.js';
6
+ const program = new Command();
7
+ program
8
+ .name('kinde-ops')
9
+ .description('CLI tool for Kinde operations')
10
+ .version('1.0.0');
11
+ // Catch and resolve profile before any command action
12
+ program.hook('preAction', (thisCommand) => {
13
+ const opts = thisCommand.opts();
14
+ const { profile } = opts;
15
+ if (profile) {
16
+ resolveProfile(profile);
17
+ }
18
+ });
19
+ // ----- Config ------
20
+ createConfigCommands(program);
21
+ // ----- Users ------
22
+ createUserCommands(program);
23
+ // ----- Organizations ------
24
+ createOrganizationCommands(program);
25
+ program.parse(process.argv);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,oBAAoB,MAAM,sBAAsB,CAAC;AACxD,OAAO,0BAA0B,MAAM,6BAA6B,CAAC;AAErE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,+BAA+B,CAAC;KAC5C,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB,sDAAsD;AACtD,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,EAAE;IACtC,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;IAChC,MAAM,EAAC,OAAO,EAAC,GAAG,IAAI,CAAC;IAEvB,IAAG,OAAO,EAAE,CAAC;QACT,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,uBAAuB;AACvB,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAE9B,qBAAqB;AACrB,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAE5B,6BAA6B;AAC7B,0BAA0B,CAAC,OAAO,CAAC,CAAC;AAEpC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ListOrganizationOptions } from "../types/organization.js";
2
+ export declare const listOrganizations: (options: ListOrganizationOptions) => Promise<string[] | import("../types/organization.js").Organization[]>;
3
+ export declare const seedOrganizations: (number: number) => Promise<string[]>;
4
+ export declare const createOneOrganization: () => Promise<string>;
5
+ //# sourceMappingURL=organizations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/kinde/organizations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAA6B,MAAM,0BAA0B,CAAC;AAEnG,eAAO,MAAM,iBAAiB,GAAU,SAAS,uBAAuB,0EASvE,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAU,QAAQ,MAAM,sBASrD,CAAA;AAED,eAAO,MAAM,qBAAqB,uBAejC,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { faker } from "@faker-js/faker";
2
+ import { kindeRequest } from "./utils/client.js";
3
+ export const listOrganizations = async (options) => {
4
+ const { verbose, pageSize } = options;
5
+ const orgs = await kindeRequest('GET', `organizations?page_size=${pageSize}`);
6
+ if (verbose) {
7
+ return orgs.organizations;
8
+ }
9
+ return orgs.organizations.map((org) => org.name);
10
+ };
11
+ export const seedOrganizations = async (number) => {
12
+ const createdOrgs = [];
13
+ for (let i = 0; i < number; i++) {
14
+ const orgName = await createOneOrganization();
15
+ createdOrgs.push(orgName);
16
+ }
17
+ return createdOrgs;
18
+ };
19
+ export const createOneOrganization = async () => {
20
+ const fakeOrgName = faker.company.name();
21
+ const orgObject = {
22
+ name: fakeOrgName,
23
+ sender_name: fakeOrgName
24
+ };
25
+ try {
26
+ await kindeRequest('POST', 'organization', orgObject);
27
+ return fakeOrgName;
28
+ }
29
+ catch (error) {
30
+ console.error('Error creating organization:', error);
31
+ throw error;
32
+ }
33
+ };
34
+ //# sourceMappingURL=organizations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.js","sourceRoot":"","sources":["../../src/kinde/organizations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAgC,EAAE,EAAE;IACxE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEtC,MAAM,IAAI,GAAG,MAAM,YAAY,CAA4B,KAAK,EAAE,2BAA2B,QAAQ,EAAE,CAAC,CAAC;IAEzG,IAAI,OAAO,EAAE,CAAC;QACV,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,MAAc,EAAE,EAAE;IACtD,MAAM,WAAW,GAAG,EAAE,CAAC;IAEvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,qBAAqB,EAAE,CAAC;QAC9C,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,WAAW,CAAC;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,IAAI,EAAE;IAC5C,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAEzC,MAAM,SAAS,GAAG;QACd,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,WAAW;KAC3B,CAAA;IAED,IAAI,CAAC;QACD,MAAM,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QACtD,OAAO,WAAW,CAAA;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { CreateUserOptions, ListUserOptions } from "../types/user.js";
2
+ export declare const createUser: (email: string) => Promise<unknown>;
3
+ export declare const listUsers: (options?: ListUserOptions) => Promise<{
4
+ id: string;
5
+ email: string;
6
+ }[]>;
7
+ export declare const seedUsers: (options: CreateUserOptions) => Promise<unknown[]>;
8
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/kinde/users.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE9F,eAAO,MAAM,UAAU,GAAU,OAAO,MAAM,qBAE7C,CAAA;AAED,eAAO,MAAM,SAAS,GAAU,UAAS,eAAoB;;;IAW5D,CAAA;AAED,eAAO,MAAM,SAAS,GAAU,SAAS,iBAAiB,uBAWzD,CAAA"}
@@ -0,0 +1,44 @@
1
+ import { buildQuery } from "./utils/query.js";
2
+ import { kindeRequest } from "./utils/client.js";
3
+ export const createUser = async (email) => {
4
+ return kindeRequest('POST', 'users', { email });
5
+ };
6
+ export const listUsers = async (options = {}) => {
7
+ const query = buildQuery(options);
8
+ const endpoint = query ? `users?${query}` : 'users';
9
+ const users = await kindeRequest('GET', endpoint);
10
+ if (options.verbose) {
11
+ return users.users;
12
+ }
13
+ return users.users.map((user) => ({ id: user.id, email: user.email }));
14
+ };
15
+ export const seedUsers = async (options) => {
16
+ const { number } = options;
17
+ const createdUsers = [];
18
+ for (let i = 1; i <= number; i++) {
19
+ const user = await createOneUser(i, options.baseEmailToAddUsersNumber, options.isVerified);
20
+ createdUsers.push(user);
21
+ }
22
+ return createdUsers;
23
+ };
24
+ const createOneUser = async (count, email, isVerified) => {
25
+ const baseName = email.split("@")[0];
26
+ const baseEmail = baseName + "@" + email.split("@")[1];
27
+ const userObject = {
28
+ profile: {
29
+ given_name: baseName,
30
+ family_name: String(count),
31
+ },
32
+ identities: [
33
+ {
34
+ type: "email",
35
+ is_verified: true,
36
+ details: {
37
+ email: `${baseName}+${count}@${baseEmail.split("@")[1]}`
38
+ }
39
+ }
40
+ ]
41
+ };
42
+ return kindeRequest('POST', 'user', userObject);
43
+ };
44
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/kinde/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;IAC9C,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AACpD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,UAA2B,EAAE,EAAE,EAAE;IAC7D,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAEpD,MAAM,KAAK,GAAG,MAAM,YAAY,CAAoB,KAAK,EAAE,QAAQ,CAAC,CAAC;IAErE,IAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC,KAAK,CAAC;IACvB,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,CAAC,CAAC,CAAC;AACzE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,OAA0B,EAAE,EAAE;IAC1D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,YAAY,GAAG,EAAE,CAAC;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,yBAAyB,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAC3F,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,YAAY,CAAC;AACxB,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,KAAK,EAAE,KAAa,EAAE,KAAa,EAAE,UAAoB,EAAE,EAAE;IAC/E,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,QAAQ,GAAG,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvD,MAAM,UAAU,GAAG;QACf,OAAO,EAAE;YACL,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC;SAE7B;QACD,UAAU,EAAE;YACR;gBACI,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE;oBACL,KAAK,EAAE,GAAG,QAAQ,IAAI,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;iBAC3D;aACJ;SACJ;KACJ,CAAA;IAED,OAAO,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AACpD,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const getManagementToken: () => Promise<string | null>;
2
+ export declare const kindeRequest: <T>(method: "GET" | "POST" | "PUT" | "DELETE", endpoint: string, data?: any) => Promise<T>;
3
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/kinde/utils/client.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,MAAM,GAAG,IAAI,CA+BhE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAU,CAAC,EAClC,QAAQ,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,EACzC,UAAU,MAAM,EAChB,OAAO,GAAG,KACT,OAAO,CAAC,CAAC,CAmBX,CAAA"}
@@ -0,0 +1,42 @@
1
+ import axios from 'axios';
2
+ import { resolveProfile } from '../../cli/context/runtime.js';
3
+ import { loadConfigForProfile } from '../../utils/config/config.js';
4
+ let accessToken = null;
5
+ export const getManagementToken = async () => {
6
+ if (accessToken) {
7
+ return accessToken;
8
+ }
9
+ const profile = await resolveProfile();
10
+ // Load profile-specific environment variables
11
+ const { kindeDomain, m2mClientId, m2mClientSecret } = await loadConfigForProfile(profile);
12
+ const params = new URLSearchParams({
13
+ grant_type: 'client_credentials',
14
+ client_id: m2mClientId,
15
+ client_secret: m2mClientSecret,
16
+ audience: `https://${kindeDomain}/api`,
17
+ scope: 'read:users create:users create:organizations read:organizations',
18
+ });
19
+ const response = await axios.post(`https://${kindeDomain}/oauth2/token`, params.toString(), {
20
+ headers: {
21
+ 'Content-Type': 'application/x-www-form-urlencoded',
22
+ },
23
+ });
24
+ accessToken = response.data.access_token;
25
+ return accessToken;
26
+ };
27
+ export const kindeRequest = async (method, endpoint, data) => {
28
+ const token = await getManagementToken();
29
+ const profile = await resolveProfile();
30
+ const { kindeDomain } = await loadConfigForProfile(profile);
31
+ const response = await axios.request({
32
+ method,
33
+ url: `https://${kindeDomain}/api/v1/${endpoint}`,
34
+ headers: {
35
+ Authorization: `Bearer ${token}`,
36
+ 'Content-Type': 'application/json',
37
+ },
38
+ data,
39
+ });
40
+ return response.data;
41
+ };
42
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/kinde/utils/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,IAAI,WAAW,GAAkB,IAAI,CAAC;AAEtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,IAA4B,EAAE;IACnE,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,cAAc,EAAE,CAAC;IAEvC,8CAA8C;IAC9C,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAG1F,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,UAAU,EAAE,oBAAoB;QAChC,SAAS,EAAE,WAAW;QACtB,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,WAAW,WAAW,MAAM;QACtC,KAAK,EAAE,iEAAiE;KACzE,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAC/B,WAAW,WAAW,eAAe,EACrC,MAAM,CAAC,QAAQ,EAAE,EACjB;QACE,OAAO,EAAE;YACP,cAAc,EAAE,mCAAmC;SACpD;KACF,CACF,CAAC;IAEF,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC;IACzC,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,MAAyC,EACzC,QAAgB,EAChB,IAAU,EACE,EAAE;IACd,MAAM,KAAK,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAEzC,MAAM,OAAO,GAAG,MAAM,cAAc,EAAE,CAAC;IAEvC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAE5D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAI;QACtC,MAAM;QACN,GAAG,EAAE,WAAW,WAAW,WAAW,QAAQ,EAAE;QAChD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,EAAE;YAChC,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI;KACL,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;AAEvB,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ export declare const handleErrors: (error: unknown) => void;
2
+ export declare const parseKindeErrors: (error: {
3
+ code: string;
4
+ message: string;
5
+ }[]) => string[];
6
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../../src/kinde/utils/error-handler.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,SAa1C,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,EAAE,KAAG,MAAM,EAEhF,CAAA"}
@@ -0,0 +1,21 @@
1
+ import axios from "axios";
2
+ import chalk from "chalk";
3
+ export const handleErrors = (error) => {
4
+ if (axios.isAxiosError(error)) {
5
+ console.log(chalk.red('An error occurred:'));
6
+ console.log(chalk.red(`${error.response?.status} - ${error.response?.data?.message || error.message}`));
7
+ console.log(chalk.red('Details:'));
8
+ if (error.response?.data?.errors) {
9
+ error.response.data.errors.forEach((err) => {
10
+ console.log(chalk.red(` Code: ${err.code}, Message: ${err.message}`));
11
+ });
12
+ }
13
+ }
14
+ else {
15
+ console.error('Unexpected error:', error);
16
+ }
17
+ };
18
+ export const parseKindeErrors = (error) => {
19
+ return error.map((err) => `Code: ${err.code}, Message: ${err.message}`);
20
+ };
21
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/kinde/utils/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,EAAE;IAC7C,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,MAAM,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACxG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YACjC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAoC,EAAE,EAAE;gBAC1E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,IAAI,cAAc,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACzE,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAwC,EAAY,EAAE;IACnF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,GAAG,CAAC,IAAI,cAAc,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function buildQuery(params: Record<string, unknown>): string;
2
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/kinde/utils/query.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UAgBzD"}
@@ -0,0 +1,17 @@
1
+ export function buildQuery(params) {
2
+ const searchParams = new URLSearchParams();
3
+ for (const [key, value] of Object.entries(params)) {
4
+ if (value === undefined || value === null)
5
+ continue;
6
+ if (Array.isArray(value)) {
7
+ if (value.length > 0) {
8
+ searchParams.append(key, value.join(","));
9
+ }
10
+ }
11
+ else {
12
+ searchParams.append(key, value.toString());
13
+ }
14
+ }
15
+ return searchParams.toString();
16
+ }
17
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/kinde/utils/query.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,MAA+B;IACxD,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;IAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QAEpD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC,QAAQ,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type KindeConfig = {
2
+ profileName: string;
3
+ kindeDomain: string;
4
+ m2mClientId?: string;
5
+ m2mClientSecret?: string;
6
+ };
7
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ export type Organization = {
2
+ code: string;
3
+ name: string;
4
+ handle: string | null;
5
+ created_on: string;
6
+ is_default: boolean;
7
+ external_id: string | null;
8
+ is_auto_membership_enabled: boolean;
9
+ };
10
+ export type ListOrganizationsResponse = {
11
+ code: string;
12
+ message: string;
13
+ next_token: string;
14
+ organizations: Organization[];
15
+ };
16
+ export type CreateOrganizationOptions = {
17
+ number: number;
18
+ verbose?: boolean;
19
+ };
20
+ export type ListOrganizationOptions = {
21
+ verbose?: boolean;
22
+ pageSize?: number;
23
+ };
24
+ //# sourceMappingURL=organization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../src/types/organization.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,0BAA0B,EAAE,OAAO,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,YAAY,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=organization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.js","sourceRoot":"","sources":["../../src/types/organization.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ export type User = {
2
+ id: string;
3
+ email: string;
4
+ picture?: string;
5
+ full_name: string;
6
+ last_name: string;
7
+ created_on: string;
8
+ first_name: string;
9
+ is_suspended: boolean;
10
+ last_signed_in?: string;
11
+ total_sign_ins: number;
12
+ failed_sign_ins: number;
13
+ };
14
+ export type ListUsersResponse = {
15
+ code: string;
16
+ users: User[];
17
+ message: string;
18
+ next_token: string;
19
+ };
20
+ export type ListUserOptions = {
21
+ pageSize?: number;
22
+ verbose?: boolean;
23
+ nextToken?: string;
24
+ userId?: string[];
25
+ email?: string[];
26
+ username?: string[];
27
+ phone?: string[];
28
+ expand?: Array<"organizations" | "identities" | "billing">;
29
+ hasOrganization?: boolean;
30
+ };
31
+ export type CreateUserOptions = {
32
+ number: number;
33
+ baseEmailToAddUsersNumber: string;
34
+ isVerified?: boolean;
35
+ };
36
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACf,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC,eAAe,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB,EAAE,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { KindeConfig } from '../../types/config.js';
2
+ export declare const loadConfig: () => Promise<KindeConfig[]>;
3
+ export declare const saveConfig: (config: KindeConfig) => Promise<void>;
4
+ export declare const loadConfigForProfile: (profileName: string) => Promise<KindeConfig & {
5
+ m2mClientId: string;
6
+ m2mClientSecret: string;
7
+ }>;
8
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMzD,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,WAAW,EAAE,CAOxD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,QAAQ,WAAW,KAAG,OAAO,CAAC,IAAI,CAmClE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC7B,aAAa,MAAM,KACpB,OAAO,CAAC,WAAW,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAyBxE,CAAC"}
@@ -0,0 +1,55 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { getSecret, saveSecret } from './secret-store.js';
5
+ const CONFIG_DIR = path.join(os.homedir(), '.kinde-ops');
6
+ const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
7
+ export const loadConfig = async () => {
8
+ if (!fs.existsSync(CONFIG_FILE)) {
9
+ return [];
10
+ }
11
+ const data = await fs.promises.readFile(CONFIG_FILE, "utf-8");
12
+ return JSON.parse(data);
13
+ };
14
+ export const saveConfig = async (config) => {
15
+ if (!fs.existsSync(CONFIG_DIR)) {
16
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
17
+ }
18
+ if (!config.m2mClientId || !config.m2mClientSecret) {
19
+ throw new Error("M2M Client ID and Client Secret are required.");
20
+ }
21
+ // Save secrets securely
22
+ await saveSecret(config.profileName, "m2mClientId", config.m2mClientId);
23
+ await saveSecret(config.profileName, "m2mClientSecret", config.m2mClientSecret);
24
+ // Remove secrets before writing to disk
25
+ const { m2mClientId, m2mClientSecret, ...diskConfig } = config;
26
+ const configs = await loadConfig();
27
+ const index = configs.findIndex((c) => c.profileName === config.profileName);
28
+ if (index >= 0) {
29
+ // overwrite existing profile
30
+ configs[index] = diskConfig;
31
+ }
32
+ else {
33
+ // add new profile
34
+ configs.push(diskConfig);
35
+ }
36
+ await fs.promises.writeFile(CONFIG_FILE, JSON.stringify(configs, null, 2), "utf-8");
37
+ };
38
+ export const loadConfigForProfile = async (profileName) => {
39
+ const configs = await loadConfig();
40
+ const profileConfig = configs.find((c) => c.profileName === profileName);
41
+ if (!profileConfig) {
42
+ throw new Error(`Profile ${profileName} not found in configuration.`);
43
+ }
44
+ const m2mClientId = await getSecret(profileName, "m2mClientId");
45
+ const m2mClientSecret = await getSecret(profileName, "m2mClientSecret");
46
+ if (!m2mClientId || !m2mClientSecret) {
47
+ throw new Error(`M2M Client ID or Client Secret not found for profile ${profileName}.`);
48
+ }
49
+ return {
50
+ ...profileConfig,
51
+ m2mClientId,
52
+ m2mClientSecret,
53
+ };
54
+ };
55
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config/config.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ export declare const saveSecret: (profile: string, key: string, value: string) => Promise<void>;
2
+ export declare const getSecret: (profile: string, key: string) => Promise<string | null>;
3
+ //# sourceMappingURL=secret-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret-store.d.ts","sourceRoot":"","sources":["../../../src/utils/config/secret-store.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,GAAU,SAAS,MAAM,EAAE,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CAG1F,CAAA;AAED,eAAO,MAAM,SAAS,GAAU,SAAS,MAAM,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAGnF,CAAA"}
@@ -0,0 +1,11 @@
1
+ import keytar from 'keytar';
2
+ const SERVICE_NAME = 'kinde-ops-cli';
3
+ export const saveSecret = async (profile, key, value) => {
4
+ const account = `${profile}-${key}`;
5
+ await keytar.setPassword(SERVICE_NAME, account, value);
6
+ };
7
+ export const getSecret = async (profile, key) => {
8
+ const account = `${profile}-${key}`;
9
+ return keytar.getPassword(SERVICE_NAME, account);
10
+ };
11
+ //# sourceMappingURL=secret-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret-store.js","sourceRoot":"","sources":["../../../src/utils/config/secret-store.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,YAAY,GAAG,eAAe,CAAC;AAGrC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,OAAe,EAAE,GAAW,EAAE,KAAa,EAAiB,EAAE;IAC3F,MAAM,OAAO,GAAG,GAAG,OAAO,IAAI,GAAG,EAAE,CAAC;IACpC,MAAM,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,OAAe,EAAE,GAAW,EAA0B,EAAE;IACpF,MAAM,OAAO,GAAG,GAAG,OAAO,IAAI,GAAG,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC,CAAA"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "kinde-ops",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool for Kinde operations, QA, and automation",
5
+ "type": "module",
6
+
7
+ "bin": {
8
+ "kinde-ops": "dist/cli/index.js"
9
+ },
10
+
11
+ "files": [
12
+ "dist",
13
+ "README.md"
14
+ ],
15
+
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "dev": "tsx src/cli/index.ts",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+
22
+ "keywords": [
23
+ "kinde",
24
+ "auth",
25
+ "oauth",
26
+ "cli",
27
+ "devtools",
28
+ "qa"
29
+ ],
30
+
31
+ "author": "Roshan Chapagain",
32
+ "license": "ISC",
33
+
34
+ "dependencies": {
35
+ "@faker-js/faker": "^10.1.0",
36
+ "axios": "^1.13.2",
37
+ "chalk": "^5.6.2",
38
+ "commander": "^14.0.2",
39
+ "dotenv": "^17.2.3",
40
+ "inquirer": "^13.1.0",
41
+ "jsonwebtoken": "^9.0.3",
42
+ "keytar": "^7.9.0"
43
+ },
44
+
45
+ "devDependencies": {
46
+ "typescript": "^5.9.3",
47
+ "ts-node": "^10.9.2",
48
+ "tsx": "^4.21.0",
49
+ "@types/node": "^25.0.3"
50
+ }
51
+ }