indraq_cli 2.1.0 → 2.2.1

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 (79) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +41 -15
  3. package/cloud-api/.dockerignore +18 -18
  4. package/cloud-api/.env.example +14 -14
  5. package/cloud-api/Dockerfile +19 -19
  6. package/cloud-api/README.md +93 -93
  7. package/cloud-api/dist/index.js +265 -27
  8. package/cloud-api/node_modules/.package-lock.json +1 -1
  9. package/cloud-api/package-lock.json +2 -2
  10. package/cloud-api/package.json +1 -1
  11. package/cloud-api/sql/001_init.sql +8 -8
  12. package/cloud-api/sql/002_user_providers_and_project_resources.sql +40 -40
  13. package/cloud-api/sql/003_environment_infrastructure.sql +19 -19
  14. package/cloud-api/sql/004_managed_aws_credentials.sql +20 -20
  15. package/cloud-api/sql/005_project_members_and_resource_grants.sql +22 -22
  16. package/cloud-api/sql/006_catalog_identity_password_security.sql +96 -96
  17. package/cloud-api/sql/007_aws_access_key_rotation.sql +16 -16
  18. package/cloud-api/sql/008_provider_scopes.sql +91 -91
  19. package/cloud-api/sql/009_scope_user_secrets_and_project_lifecycle.sql +13 -0
  20. package/cloud-api/src/index.ts +164 -27
  21. package/cloud-api/tsconfig.json +18 -18
  22. package/dist/cli/help-content.d.ts.map +1 -1
  23. package/dist/cli/help-content.js +29 -7
  24. package/dist/cli/help-content.js.map +1 -1
  25. package/dist/modules/access/commands/access.command.js +30 -30
  26. package/dist/modules/aws/services/route53-lookup.service.js.map +1 -1
  27. package/dist/modules/cloud/commands/cloud.command.d.ts +4 -0
  28. package/dist/modules/cloud/commands/cloud.command.d.ts.map +1 -1
  29. package/dist/modules/cloud/commands/cloud.command.js +52 -1
  30. package/dist/modules/cloud/commands/cloud.command.js.map +1 -1
  31. package/dist/modules/cloud/index.d.ts.map +1 -1
  32. package/dist/modules/cloud/index.js +6 -3
  33. package/dist/modules/cloud/index.js.map +1 -1
  34. package/dist/modules/cloud/services/cloud-jenkins.service.js +71 -71
  35. package/dist/modules/cloud/services/user-provider.service.d.ts +2 -8
  36. package/dist/modules/cloud/services/user-provider.service.d.ts.map +1 -1
  37. package/dist/modules/cloud/services/user-provider.service.js +7 -35
  38. package/dist/modules/cloud/services/user-provider.service.js.map +1 -1
  39. package/dist/modules/deploy/commands/build.command.d.ts +1 -0
  40. package/dist/modules/deploy/commands/build.command.d.ts.map +1 -1
  41. package/dist/modules/deploy/commands/build.command.js +12 -5
  42. package/dist/modules/deploy/commands/build.command.js.map +1 -1
  43. package/dist/modules/deploy/index.d.ts.map +1 -1
  44. package/dist/modules/deploy/index.js +11 -4
  45. package/dist/modules/deploy/index.js.map +1 -1
  46. package/dist/modules/prebuild/commands/prebuild.command.d.ts +0 -4
  47. package/dist/modules/prebuild/commands/prebuild.command.d.ts.map +1 -1
  48. package/dist/modules/prebuild/commands/prebuild.command.js +34 -38
  49. package/dist/modules/prebuild/commands/prebuild.command.js.map +1 -1
  50. package/dist/modules/prebuild/index.d.ts.map +1 -1
  51. package/dist/modules/prebuild/index.js +4 -8
  52. package/dist/modules/prebuild/index.js.map +1 -1
  53. package/dist/modules/scaffold/services/docker-template.service.js +95 -95
  54. package/dist/modules/scopes/commands/scope.command.d.ts.map +1 -1
  55. package/dist/modules/scopes/commands/scope.command.js +3 -47
  56. package/dist/modules/scopes/commands/scope.command.js.map +1 -1
  57. package/dist/modules/scopes/services/scope-native.service.js +2 -2
  58. package/dist/modules/scopes/services/scope-native.service.js.map +1 -1
  59. package/dist/modules/users/commands/user.command.d.ts +1 -0
  60. package/dist/modules/users/commands/user.command.d.ts.map +1 -1
  61. package/dist/modules/users/commands/user.command.js +15 -1
  62. package/dist/modules/users/commands/user.command.js.map +1 -1
  63. package/dist/modules/users/index.d.ts.map +1 -1
  64. package/dist/modules/users/index.js +3 -2
  65. package/dist/modules/users/index.js.map +1 -1
  66. package/dist/modules/users/providers/jenkins-user.provider.js +95 -95
  67. package/dist/shared/config/config-files.js +7 -7
  68. package/dist/shared/jenkins/jenkins.service.d.ts.map +1 -1
  69. package/dist/shared/jenkins/jenkins.service.js +13 -8
  70. package/dist/shared/jenkins/jenkins.service.js.map +1 -1
  71. package/dist/shared/jenkins/role-strategy-groovy.js +84 -84
  72. package/docs/ARCHITECTURE.md +29 -29
  73. package/docs/CREATE-DEPLOYMENT-reference.groovy +1105 -1105
  74. package/package.json +9 -5
  75. package/templates/jenkins/CREATE-DEPLOYMENT.groovy +1105 -1105
  76. package/templates/jenkins/Jenkinsfile-Mobile-App +759 -759
  77. package/CHANGELOG_v2.1.0.md +0 -27
  78. package/UPGRADE_v2.0_to_v2.1.md +0 -68
  79. package/cloud-api/dist/index.js.map +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 IndraQ Innovations
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 IndraQ Innovations
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  **One CLI for provider access, project infrastructure and deployments.**
7
7
 
8
- ![version](https://img.shields.io/badge/version-2.1.0-blue)
8
+ ![version](https://img.shields.io/badge/version-2.2.0-blue)
9
9
  ![node](https://img.shields.io/badge/Node.js-%3E%3D22-green)
10
10
  ![typescript](https://img.shields.io/badge/TypeScript-5.x-blue)
11
11
  ![license](https://img.shields.io/badge/license-MIT-lightgrey)
@@ -19,7 +19,7 @@
19
19
 
20
20
  IndraQ is an internal engineering CLI that connects your team to shared infrastructure without making every developer carry organization administrator credentials.
21
21
 
22
- Instead of configuring “one AWS”, “one Jenkins”, or “one NPM” globally, v2.1 introduces **provider scopes**. A scope is one named account or server such as:
22
+ Instead of configuring “one AWS”, “one Jenkins”, or “one NPM” globally, v2.2 uses **provider scopes** as the only normal deployment credential path. A scope is one named account or server such as:
23
23
 
24
24
  - `AWS — IndraQ Production`
25
25
  - `AWS — Client ABC`
@@ -55,7 +55,7 @@ flowchart LR
55
55
 
56
56
  Teams often manage several servers, customers and cloud accounts at once. A single provider credential creates ambiguity and unnecessary privilege. Scopes solve both problems.
57
57
 
58
- | Problem | v2.1 behavior |
58
+ | Problem | v2.2 behavior |
59
59
  |---|---|
60
60
  | Several AWS accounts | Unlimited named AWS scopes |
61
61
  | Several Jenkins servers | Unlimited named DEV/PROD Jenkins scopes |
@@ -72,7 +72,7 @@ Teams often manage several servers, customers and cloud accounts at once. A sing
72
72
 
73
73
  ### Provider scope
74
74
 
75
- One organization-owned provider account/server plus its encrypted management credential and safe metadata.
75
+ One organization-owned provider account/server plus its encrypted management credential and safe metadata. The management secret is used by the Cloud API for provisioning/administration and is **not returned to normal `USE` members**. AWS/NPM/Jenkins users resolve their own native identities instead.
76
76
 
77
77
  ### Scope membership
78
78
 
@@ -228,7 +228,13 @@ indraq prebuild --env dev
228
228
  ```bash
229
229
  indraq deploy:dev
230
230
  # or
231
- indraq deploy build --env staging
231
+ indraq deploy --env staging
232
+ ```
233
+
234
+ Normal deploys reuse the scopes already saved for that project/environment. Use `--select-scopes` only when you intentionally want to review or change those bindings:
235
+
236
+ ```bash
237
+ indraq deploy --env dev --select-scopes
232
238
  ```
233
239
 
234
240
  ---
@@ -352,7 +358,7 @@ indraq project scopes --env prod
352
358
 
353
359
  ## Prebuild and deploy
354
360
 
355
- `prebuild` reconciles the project before deployment.
361
+ `prebuild` reconciles the project before deployment. It uses an admin-defined shared environment and saved project scope bindings; it does not offer a project-local custom IPv4 fallback.
356
362
 
357
363
  ```mermaid
358
364
  flowchart TD
@@ -398,9 +404,9 @@ This is useful for projects that existed before IndraQ or where DNS/proxy is man
398
404
  ## What `--env` means
399
405
 
400
406
  ```bash
401
- indraq deploy build --env dev
402
- indraq deploy build --env staging
403
- indraq deploy build --env prod
407
+ indraq deploy --env dev
408
+ indraq deploy --env staging
409
+ indraq deploy --env prod
404
410
  ```
405
411
 
406
412
  The flag selects **IndraQ resource state**:
@@ -491,6 +497,19 @@ Provider identities are removed first. Cloud identity is deleted last. Projects
491
497
 
492
498
  ## Command reference
493
499
 
500
+ ### Built-in focused help
501
+
502
+ The CLI help is aligned with the v2.2 scope-first workflow:
503
+
504
+ ```bash
505
+ indraq help scope
506
+ indraq help users
507
+ indraq help deploy
508
+ indraq help configure
509
+ indraq help aws
510
+ ```
511
+
512
+
494
513
  ### Authentication and diagnostics
495
514
 
496
515
  | Command | Use |
@@ -523,6 +542,7 @@ Provider identities are removed first. Cloud identity is deleted last. Projects
523
542
  | Command | Use |
524
543
  |---|---|
525
544
  | `indraq user list` | List organization users |
545
+ | `indraq user scopes [email]` | Show your own or a manageable user's assigned scopes |
526
546
  | `indraq user create [username]` | Create user + select scopes |
527
547
  | `indraq user update [username]` | Password/role operations |
528
548
  | `indraq user delete [username]` | Hard delete after scope cleanup |
@@ -540,6 +560,10 @@ Provider identities are removed first. Cloud identity is deleted last. Projects
540
560
  | `indraq project scopes --env <env>` | Select project provider scopes |
541
561
  | `indraq project add user` | Add project member + synchronize access |
542
562
  | `indraq project delete user` | Remove project member |
563
+ | `indraq project rename [name]` | Rename the current project |
564
+ | `indraq project archive` | Archive the current project and block normal deployment access |
565
+ | `indraq project restore` | Restore an archived project |
566
+ | `indraq project delete` | Permanently delete current project metadata |
543
567
  | `indraq access add user` | Add selected resource grants |
544
568
  | `indraq access delete user` | Remove selected resource grants |
545
569
 
@@ -550,7 +574,8 @@ Provider identities are removed first. Cloud identity is deleted last. Projects
550
574
  | `indraq prebuild --env <env>` | Reconcile infrastructure |
551
575
  | `indraq deploy:dev` | Dev deploy |
552
576
  | `indraq deploy:prod` | Prod deploy |
553
- | `indraq deploy build --env <env>` | Named environment deploy |
577
+ | `indraq deploy --env <env>` | Named environment deploy using saved scope bindings |
578
+ | `indraq deploy --env <env> --select-scopes` | Explicitly review/change project scope bindings before deploy |
554
579
  | `indraq jenkins pipelines --stage dev` | List visible pipelines |
555
580
  | `indraq jenkins run [job] --stage dev` | Run pipeline with discovered parameters |
556
581
  | `indraq jenkins create-deployment` | Bootstrap deployment pipeline |
@@ -633,7 +658,7 @@ Key rules:
633
658
 
634
659
  ### `fetch failed` while configuring NPM
635
660
 
636
- v2.1 surfaces the underlying network/TLS/authentication error where possible. Verify the URL uses the correct scheme and hostname, then compare with the web login. A browser login does not necessarily prove Node.js trusts the same TLS certificate chain.
661
+ v2.2 surfaces the underlying network/TLS/authentication error where possible. Verify the URL uses the correct scheme and hostname, then compare with the web login. A browser login does not necessarily prove Node.js trusts the same TLS certificate chain.
637
662
 
638
663
  ### Jenkins says Role Strategy is not active
639
664
 
@@ -661,7 +686,7 @@ Run prebuild and choose **Skip** for Route53.
661
686
 
662
687
  ---
663
688
 
664
- ## Cloud API upgrade for v2.1
689
+ ## Cloud API upgrade for v2.2
665
690
 
666
691
  The CLI and Cloud API must be upgraded together.
667
692
 
@@ -671,11 +696,12 @@ Apply migrations through:
671
696
  cloud-api/sql/001_*.sql
672
697
  ...
673
698
  cloud-api/sql/008_provider_scopes.sql
699
+ cloud-api/sql/009_scope_user_secrets_and_project_lifecycle.sql
674
700
  ```
675
701
 
676
- Then build/restart the Cloud API. The v2.1 migration adds provider scopes, memberships, personal defaults, project/environment bindings and scope-native identity mappings.
702
+ Migration `009` adds encrypted per-user NPM/Jenkins secrets and project archive metadata (`archived_at`, `archived_by`). v2.2 also hardens project/resource authorization and prevents normal `USE` members from resolving shared provider-management credentials.
677
703
 
678
- See [UPGRADE_v2.0_to_v2.1.md](UPGRADE_v2.0_to_v2.1.md) for the release checklist.
704
+ See [UPGRADE_v2.1_to_v2.2.md](UPGRADE_v2.1_to_v2.2.md) and [RELEASE_CHECKS_v2.2.0.md](RELEASE_CHECKS_v2.2.0.md).
679
705
 
680
706
  ---
681
707
 
@@ -700,7 +726,7 @@ npm --prefix cloud-api run build
700
726
  <div align="center">
701
727
  <img src="docs/assets/indraq-mark.png" alt="IndraQ mark" width="70" />
702
728
 
703
- **IndraQ CLI v2.1.0**
729
+ **IndraQ CLI v2.2.0**
704
730
 
705
731
  Scope-based infrastructure access. Durable projects. Safer deployments.
706
732
  </div>
@@ -1,18 +1,18 @@
1
- node_modules
2
- npm-debug.log*
3
- yarn-debug.log*
4
- yarn-error.log*
5
- pnpm-debug.log*
6
- *.log
7
- .git
8
- .gitignore
9
- .indraq
10
- dist
11
- build
12
- .next
13
- coverage
14
- .cache
15
- .vite
16
- .turbo
17
- .DS_Store
18
- Thumbs.db
1
+ node_modules
2
+ npm-debug.log*
3
+ yarn-debug.log*
4
+ yarn-error.log*
5
+ pnpm-debug.log*
6
+ *.log
7
+ .git
8
+ .gitignore
9
+ .indraq
10
+ dist
11
+ build
12
+ .next
13
+ coverage
14
+ .cache
15
+ .vite
16
+ .turbo
17
+ .DS_Store
18
+ Thumbs.db
@@ -1,14 +1,14 @@
1
- PORT=4010
2
- DATABASE_URL=postgresql://indraq:change-me@127.0.0.1:5432/indraq_cloud
3
- JWT_SECRET=replace-with-64-random-characters
4
- MASTER_KEY=replace-with-64-hex-characters
5
- BOOTSTRAP_ADMIN_EMAIL=admin@example.com
6
- BOOTSTRAP_ADMIN_PASSWORD=change-this-immediately
7
-
8
- # Password-reset email (required for `indraq password reset`)
9
- SMTP_HOST=smtp.example.com
10
- SMTP_PORT=587
11
- SMTP_SECURE=false
12
- SMTP_USER=
13
- SMTP_PASS=
14
- SMTP_FROM=IndraQ <no-reply@example.com>
1
+ PORT=4010
2
+ DATABASE_URL=postgresql://indraq:change-me@127.0.0.1:5432/indraq_cloud
3
+ JWT_SECRET=replace-with-64-random-characters
4
+ MASTER_KEY=replace-with-64-hex-characters
5
+ BOOTSTRAP_ADMIN_EMAIL=admin@example.com
6
+ BOOTSTRAP_ADMIN_PASSWORD=change-this-immediately
7
+
8
+ # Password-reset email (required for `indraq password reset`)
9
+ SMTP_HOST=smtp.example.com
10
+ SMTP_PORT=587
11
+ SMTP_SECURE=false
12
+ SMTP_USER=
13
+ SMTP_PASS=
14
+ SMTP_FROM=IndraQ <no-reply@example.com>
@@ -1,19 +1,19 @@
1
- FROM node:22-alpine AS build
2
- WORKDIR /myapp
3
- # Copy the complete project context. .dockerignore controls all exclusions.
4
- COPY . .
5
- RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
6
- RUN npm run build
7
- RUN npm prune --omit=dev
8
-
9
- FROM node:22-alpine AS runtime
10
- WORKDIR /myapp
11
- RUN apk add --no-cache curl
12
- ENV NODE_ENV=production PORT=4010
13
- # Copy the complete filtered project from the build stage, including generated
14
- # build output and production node_modules. No project filenames are guessed.
15
- COPY --from=build --chown=node:node /myapp ./
16
- USER node
17
- EXPOSE 4010
18
- HEALTHCHECK --interval=30s --timeout=3s CMD curl -fsS http://127.0.0.1:4010/health >/dev/null || exit 1
19
- CMD ["npm", "start"]
1
+ FROM node:22-alpine AS build
2
+ WORKDIR /myapp
3
+ # Copy the complete project context. .dockerignore controls all exclusions.
4
+ COPY . .
5
+ RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
6
+ RUN npm run build
7
+ RUN npm prune --omit=dev
8
+
9
+ FROM node:22-alpine AS runtime
10
+ WORKDIR /myapp
11
+ RUN apk add --no-cache curl
12
+ ENV NODE_ENV=production PORT=4010
13
+ # Copy the complete filtered project from the build stage, including generated
14
+ # build output and production node_modules. No project filenames are guessed.
15
+ COPY --from=build --chown=node:node /myapp ./
16
+ USER node
17
+ EXPOSE 4010
18
+ HEALTHCHECK --interval=30s --timeout=3s CMD curl -fsS http://127.0.0.1:4010/health >/dev/null || exit 1
19
+ CMD ["npm", "start"]
@@ -1,93 +1,93 @@
1
- # IndraQ Cloud API
2
-
3
- Control plane for IndraQ CLI v2.1. The public CLI endpoint is `https://cli.indraq.com`.
4
-
5
- ## Responsibilities
6
-
7
- - authentication and organization RBAC (`user`, `manager`, `admin`)
8
- - provider scopes for AWS/NPM/Jenkins/GHCR
9
- - scope USE/MANAGE membership and audited delegation
10
- - encrypted provider scope secrets
11
- - per-user scope defaults
12
- - per-project/environment scope bindings
13
- - scope-native AWS/NPM/Jenkins identity mappings
14
- - self-service AWS key rotation and password lifecycle
15
- - projects, environments and project resource grants
16
- - audit logging
17
-
18
- ## Requirements
19
-
20
- - Node.js 22+
21
- - PostgreSQL
22
-
23
- ## Configure
24
-
25
- ```bash
26
- npm install
27
- cp .env.example .env
28
- ```
29
-
30
- Required values include:
31
-
32
- ```env
33
- PORT=4010
34
- DATABASE_URL=postgresql://indraq:change-me@127.0.0.1:5432/indraq_cloud
35
- JWT_SECRET=replace-with-at-least-32-random-characters
36
- MASTER_KEY=replace-with-exactly-64-hex-characters
37
- BOOTSTRAP_ADMIN_EMAIL=admin@example.com
38
- BOOTSTRAP_ADMIN_PASSWORD=use-a-strong-password
39
- ```
40
-
41
- `MASTER_KEY` must remain stable because provider scope secrets use AES-256-GCM encryption.
42
-
43
- ## Build / run
44
-
45
- ```bash
46
- npm run build
47
- npm start
48
- ```
49
-
50
- Development:
51
-
52
- ```bash
53
- npm run dev
54
- ```
55
-
56
- Numbered migrations in `sql/` are applied automatically at startup. v2.1 adds:
57
-
58
- ```text
59
- 008_provider_scopes.sql
60
- ```
61
-
62
- ## v2.1 authorization model
63
-
64
- - **Admin** — creates/deletes scopes, grants MANAGE/USE, creates managers/admins, changes organization roles.
65
- - **Manager** — can add/remove normal users only inside scopes where the manager has MANAGE.
66
- - **User** — can use only assigned scopes and rotate only their own managed provider credentials.
67
-
68
- Scope membership operations and secret resolution require an audit reason and are written to `audit_logs`.
69
-
70
- ## Provider scopes
71
-
72
- `provider_scopes` stores named organization accounts/controllers. `provider_scope_members` controls visibility and use. A user cannot discover a scope simply because it exists.
73
-
74
- Related v2.1 tables:
75
-
76
- - `provider_scopes`
77
- - `provider_scope_members`
78
- - `user_scope_defaults`
79
- - `project_environment_scopes`
80
- - `scope_external_accounts`
81
- - `scope_aws_credentials`
82
-
83
- ## Projects
84
-
85
- Projects and infrastructure are durable. Deleting a user removes scope memberships/native identity mappings and the Cloud identity but retains shared project/environment/resource definitions. Ownership is reassigned before hard deletion where required.
86
-
87
- ## Security notes
88
-
89
- - Passwords are bcrypt-hashed.
90
- - Provider secrets are encrypted with AES-256-GCM.
91
- - Secret-resolution responses are `Cache-Control: no-store` and audited.
92
- - Role/account state is re-read from PostgreSQL on protected requests so demotion/disable takes effect without waiting for JWT expiry.
93
- - Keep bootstrap credentials and `MASTER_KEY` out of source control.
1
+ # IndraQ Cloud API
2
+
3
+ Control plane for IndraQ CLI v2.1. The public CLI endpoint is `https://cli.indraq.com`.
4
+
5
+ ## Responsibilities
6
+
7
+ - authentication and organization RBAC (`user`, `manager`, `admin`)
8
+ - provider scopes for AWS/NPM/Jenkins/GHCR
9
+ - scope USE/MANAGE membership and audited delegation
10
+ - encrypted provider scope secrets
11
+ - per-user scope defaults
12
+ - per-project/environment scope bindings
13
+ - scope-native AWS/NPM/Jenkins identity mappings
14
+ - self-service AWS key rotation and password lifecycle
15
+ - projects, environments and project resource grants
16
+ - audit logging
17
+
18
+ ## Requirements
19
+
20
+ - Node.js 22+
21
+ - PostgreSQL
22
+
23
+ ## Configure
24
+
25
+ ```bash
26
+ npm install
27
+ cp .env.example .env
28
+ ```
29
+
30
+ Required values include:
31
+
32
+ ```env
33
+ PORT=4010
34
+ DATABASE_URL=postgresql://indraq:change-me@127.0.0.1:5432/indraq_cloud
35
+ JWT_SECRET=replace-with-at-least-32-random-characters
36
+ MASTER_KEY=replace-with-exactly-64-hex-characters
37
+ BOOTSTRAP_ADMIN_EMAIL=admin@example.com
38
+ BOOTSTRAP_ADMIN_PASSWORD=use-a-strong-password
39
+ ```
40
+
41
+ `MASTER_KEY` must remain stable because provider scope secrets use AES-256-GCM encryption.
42
+
43
+ ## Build / run
44
+
45
+ ```bash
46
+ npm run build
47
+ npm start
48
+ ```
49
+
50
+ Development:
51
+
52
+ ```bash
53
+ npm run dev
54
+ ```
55
+
56
+ Numbered migrations in `sql/` are applied automatically at startup. v2.1 adds:
57
+
58
+ ```text
59
+ 008_provider_scopes.sql
60
+ ```
61
+
62
+ ## v2.1 authorization model
63
+
64
+ - **Admin** — creates/deletes scopes, grants MANAGE/USE, creates managers/admins, changes organization roles.
65
+ - **Manager** — can add/remove normal users only inside scopes where the manager has MANAGE.
66
+ - **User** — can use only assigned scopes and rotate only their own managed provider credentials.
67
+
68
+ Scope membership operations and secret resolution require an audit reason and are written to `audit_logs`.
69
+
70
+ ## Provider scopes
71
+
72
+ `provider_scopes` stores named organization accounts/controllers. `provider_scope_members` controls visibility and use. A user cannot discover a scope simply because it exists.
73
+
74
+ Related v2.1 tables:
75
+
76
+ - `provider_scopes`
77
+ - `provider_scope_members`
78
+ - `user_scope_defaults`
79
+ - `project_environment_scopes`
80
+ - `scope_external_accounts`
81
+ - `scope_aws_credentials`
82
+
83
+ ## Projects
84
+
85
+ Projects and infrastructure are durable. Deleting a user removes scope memberships/native identity mappings and the Cloud identity but retains shared project/environment/resource definitions. Ownership is reassigned before hard deletion where required.
86
+
87
+ ## Security notes
88
+
89
+ - Passwords are bcrypt-hashed.
90
+ - Provider secrets are encrypted with AES-256-GCM.
91
+ - Secret-resolution responses are `Cache-Control: no-store` and audited.
92
+ - Role/account state is re-read from PostgreSQL on protected requests so demotion/disable takes effect without waiting for JWT expiry.
93
+ - Keep bootstrap credentials and `MASTER_KEY` out of source control.