@fabrika/installation-init 0.9.0-dev.34 → 0.9.0-dev.35

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/installation-init",
3
- "version": "0.9.0-dev.34",
3
+ "version": "0.9.0-dev.35",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "zod": "^3.25.76",
31
- "@fabrika/app": "0.9.0-dev.34",
32
- "@fabrika/auth-core": "0.9.0-dev.34",
33
- "@fabrika/email": "0.9.0-dev.34",
34
- "@fabrika/iam-contract": "0.9.0-dev.34",
35
- "@fabrika/proxy-core": "0.9.0-dev.34"
31
+ "@fabrika/app": "0.9.0-dev.35",
32
+ "@fabrika/auth-core": "0.9.0-dev.35",
33
+ "@fabrika/email": "0.9.0-dev.35",
34
+ "@fabrika/iam-contract": "0.9.0-dev.35",
35
+ "@fabrika/proxy-core": "0.9.0-dev.35"
36
36
  }
37
37
  }
package/src/index.ts CHANGED
@@ -36,7 +36,7 @@ export {
36
36
  } from './environment'
37
37
  export { ghRepoExists, hasGhCli } from './gh'
38
38
  export { action, detail, fail, info, ok, step, url, warn } from './log'
39
- export { type IamOAuthConfig, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp'
39
+ export { type IamOAuthConfig, mcpAuthoringOn, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp'
40
40
  export { type CommandEnv, describeArgument, readEnv, readFlag, requiredSetting, setting, shellWord } from './options'
41
41
  export { assertPinnedTag } from './pin'
42
42
  export { confirm } from './prompt'
package/src/mcp.ts CHANGED
@@ -19,7 +19,7 @@ export interface IamOAuthConfig {
19
19
  readonly resources: readonly OAuthResourceDto[]
20
20
  }
21
21
 
22
- const CLIENT_KEYS = ['provider', 'clientId', 'redirectUris', 'metadataUrl']
22
+ const CLIENT_KEYS = ['provider', 'clientId', 'redirectUris', 'metadataUrl', 'identity']
23
23
  /** IAM's own ceiling: it refuses to boot with more. */
24
24
  const MAX_CLIENTS = 16
25
25
 
@@ -39,7 +39,10 @@ const isHttpsUrl = (value: string): boolean => {
39
39
  const parseClient = (value: unknown, index: number): McpClient => {
40
40
  const client = parseOAuthManagedClient(value)
41
41
  if (client === null || !isObject(value) || !Object.keys(value).every((key) => CLIENT_KEYS.includes(key))) {
42
- throw new Error(`MCP client ${index} must be { provider: ${PROVIDERS}, clientId: <https URL>, redirectUris: [...], metadataUrl? }`)
42
+ throw new Error(
43
+ `MCP client ${index} must be { provider: ${PROVIDERS}, clientId: <https URL>, redirectUris: [...], metadataUrl?, identity? }; `
44
+ + 'identity is { app: <app id>, resource: <https URL> } and only on an external client',
45
+ )
43
46
  }
44
47
  const metadataUrl = value['metadataUrl']
45
48
  if (metadataUrl === undefined) {
@@ -76,6 +79,10 @@ export const parseMcpClientsJson = (raw: string): readonly McpClient[] => {
76
79
  return clients
77
80
  }
78
81
 
82
+ /** MCP authoring is on when the operator registers a client that is not identity-only: those sign people in, nothing more. */
83
+ export const mcpAuthoringOn = (clients: readonly McpClient[] | undefined): boolean =>
84
+ clients?.some((client) => client.identity === undefined) ?? false
85
+
79
86
  /**
80
87
  * IAM's OAuth configuration for one placed installation: the MCP clients (none when MCP authoring is off; the
81
88
  * command-line client is IAM's own and is never listed), and every resource the composition registers, each marked
@@ -108,5 +115,13 @@ export const platformIamOAuthConfig = (
108
115
  if (resources.length === 0) {
109
116
  throw new Error('the platform proxy manifest template declares no OAuth resource on this composition')
110
117
  }
118
+ // An identity token must never be one a platform service accepts: not its app id, not a resource on its hosts.
119
+ const platformHosts = Object.values(composition.placement).flatMap((placement) => placement.hosts)
120
+ for (const { clientId, identity } of clients) {
121
+ if (identity === undefined) continue
122
+ if (template.apps.some((app) => app.id === identity.app) || platformHosts.includes(new URL(identity.resource).hostname)) {
123
+ throw new Error(`MCP client ${clientId}: its identity resource names a platform service's app id or host`)
124
+ }
125
+ }
111
126
  return { clients, resources }
112
127
  }
@@ -6,7 +6,7 @@ export { EMAIL_FLAGS, type InstallationEmail, readInstallationEmail } from './em
6
6
  export { configureEnvironment, type EnvironmentConfig, type EnvironmentEffects, environmentVariables, type ExistingEnvironmentProtection, existingEnvironmentProtection, triggerPlatformWorkflow, } from './environment';
7
7
  export { ghRepoExists, hasGhCli } from './gh';
8
8
  export { action, detail, fail, info, ok, step, url, warn } from './log';
9
- export { type IamOAuthConfig, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp';
9
+ export { type IamOAuthConfig, mcpAuthoringOn, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp';
10
10
  export { type CommandEnv, describeArgument, readEnv, readFlag, requiredSetting, setting, shellWord } from './options';
11
11
  export { assertPinnedTag } from './pin';
12
12
  export { confirm } from './prompt';
@@ -14,6 +14,8 @@ export interface IamOAuthConfig {
14
14
  * client id is refused here, before a deploy writes a value IAM would refuse to boot with.
15
15
  */
16
16
  export declare const parseMcpClientsJson: (raw: string) => readonly McpClient[];
17
+ /** MCP authoring is on when the operator registers a client that is not identity-only: those sign people in, nothing more. */
18
+ export declare const mcpAuthoringOn: (clients: readonly McpClient[] | undefined) => boolean;
17
19
  /**
18
20
  * IAM's OAuth configuration for one placed installation: the MCP clients (none when MCP authoring is off; the
19
21
  * command-line client is IAM's own and is never listed), and every resource the composition registers, each marked