@fabrika/installation-init 0.9.0-dev.35 → 0.9.0-dev.36
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 +6 -6
- package/src/index.ts +9 -1
- package/src/mcp.ts +36 -3
- package/types/src/index.d.ts +1 -1
- package/types/src/mcp.d.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/installation-init",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.36",
|
|
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.
|
|
32
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
33
|
-
"@fabrika/email": "0.9.0-dev.
|
|
34
|
-
"@fabrika/iam-contract": "0.9.0-dev.
|
|
35
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
31
|
+
"@fabrika/app": "0.9.0-dev.36",
|
|
32
|
+
"@fabrika/auth-core": "0.9.0-dev.36",
|
|
33
|
+
"@fabrika/email": "0.9.0-dev.36",
|
|
34
|
+
"@fabrika/iam-contract": "0.9.0-dev.36",
|
|
35
|
+
"@fabrika/proxy-core": "0.9.0-dev.36"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -36,7 +36,15 @@ 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 {
|
|
39
|
+
export {
|
|
40
|
+
type IamOAuthConfig,
|
|
41
|
+
type IdentityAppSchema,
|
|
42
|
+
identityAppSchemas,
|
|
43
|
+
mcpAuthoringOn,
|
|
44
|
+
type McpClient,
|
|
45
|
+
parseMcpClientsJson,
|
|
46
|
+
platformIamOAuthConfig,
|
|
47
|
+
} from './mcp'
|
|
40
48
|
export { type CommandEnv, describeArgument, readEnv, readFlag, requiredSetting, setting, shellWord } from './options'
|
|
41
49
|
export { assertPinnedTag } from './pin'
|
|
42
50
|
export { confirm } from './prompt'
|
package/src/mcp.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// is resolved from, so the two cannot disagree: each `oauth` row's registered resource in the manifest, and IAM's
|
|
6
6
|
// `FABRIKA_IAM_OAUTH_CONFIG`, which issues tokens for exactly those resources.
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import type { AppSchema, RoleDef } from '@fabrika/auth-core'
|
|
9
|
+
import { IAM_APP_ID, OAUTH_CLIENT_PROVIDERS, type OAuthManagedClient, type OAuthResourceDto, parseOAuthManagedClient } from '@fabrika/iam-contract'
|
|
9
10
|
import { platformOAuthResourceUris, platformOAuthServed, type PlatformProxyComposition, type PlatformProxyManifestTemplate } from './proxy-manifest'
|
|
10
11
|
|
|
11
12
|
/** One operator-registered MCP client: its CIMD identity, plus where IAM fetches it when that differs. */
|
|
@@ -41,7 +42,7 @@ const parseClient = (value: unknown, index: number): McpClient => {
|
|
|
41
42
|
if (client === null || !isObject(value) || !Object.keys(value).every((key) => CLIENT_KEYS.includes(key))) {
|
|
42
43
|
throw new Error(
|
|
43
44
|
`MCP client ${index} must be { provider: ${PROVIDERS}, clientId: <https URL>, redirectUris: [...], metadataUrl?, identity? }; `
|
|
44
|
-
+ 'identity is { app: <app id>, resource: <https URL
|
|
45
|
+
+ 'identity is { app: <app id>, resource: <https URL>, roles?: [{ key, name }] } and only on an external client',
|
|
45
46
|
)
|
|
46
47
|
}
|
|
47
48
|
const metadataUrl = value['metadataUrl']
|
|
@@ -76,9 +77,39 @@ export const parseMcpClientsJson = (raw: string): readonly McpClient[] => {
|
|
|
76
77
|
if (ids.size !== clients.length) {
|
|
77
78
|
throw new Error('the MCP client list names one client id twice')
|
|
78
79
|
}
|
|
80
|
+
identityAppSchemas(clients)
|
|
79
81
|
return clients
|
|
80
82
|
}
|
|
81
83
|
|
|
84
|
+
/** An external application's vocabulary in IAM: its declared roles, each granting no action (ADR-0049). */
|
|
85
|
+
export interface IdentityAppSchema {
|
|
86
|
+
readonly app: string
|
|
87
|
+
readonly schema: AppSchema
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The vocabulary each external application that declares roles reconciles into IAM, once per app. The deploy writes it
|
|
92
|
+
* with the provisioning key it already holds, so the application needs no IAM credential to declare its roles. Two
|
|
93
|
+
* clients of one app must declare the same roles.
|
|
94
|
+
*/
|
|
95
|
+
export const identityAppSchemas = (clients: readonly McpClient[]): readonly IdentityAppSchema[] => {
|
|
96
|
+
const declared = new Map<string, string>()
|
|
97
|
+
const schemas: IdentityAppSchema[] = []
|
|
98
|
+
for (const { clientId, identity } of clients) {
|
|
99
|
+
if (identity === undefined) continue
|
|
100
|
+
const roles = JSON.stringify(identity.roles ?? null)
|
|
101
|
+
const known = declared.get(identity.app)
|
|
102
|
+
if (known !== undefined && known !== roles) {
|
|
103
|
+
throw new Error(`MCP client ${clientId}: another client of \`${identity.app}\` declares other roles`)
|
|
104
|
+
}
|
|
105
|
+
declared.set(identity.app, roles)
|
|
106
|
+
if (known !== undefined || identity.roles === undefined) continue
|
|
107
|
+
const entries = identity.roles.map((role): [string, RoleDef] => [role.key, { name: role.name, permissions: [] }])
|
|
108
|
+
schemas.push({ app: identity.app, schema: { scopes: [], actions: [], roles: Object.fromEntries(entries) } })
|
|
109
|
+
}
|
|
110
|
+
return schemas
|
|
111
|
+
}
|
|
112
|
+
|
|
82
113
|
/** MCP authoring is on when the operator registers a client that is not identity-only: those sign people in, nothing more. */
|
|
83
114
|
export const mcpAuthoringOn = (clients: readonly McpClient[] | undefined): boolean =>
|
|
84
115
|
clients?.some((client) => client.identity === undefined) ?? false
|
|
@@ -119,7 +150,9 @@ export const platformIamOAuthConfig = (
|
|
|
119
150
|
const platformHosts = Object.values(composition.placement).flatMap((placement) => placement.hosts)
|
|
120
151
|
for (const { clientId, identity } of clients) {
|
|
121
152
|
if (identity === undefined) continue
|
|
122
|
-
|
|
153
|
+
// IAM's own id is no proxy app's: a roles reconcile under it would rewrite IAM's vocabulary.
|
|
154
|
+
const platformApps = [IAM_APP_ID, ...template.apps.map((app) => app.id)]
|
|
155
|
+
if (platformApps.includes(identity.app) || platformHosts.includes(new URL(identity.resource).hostname)) {
|
|
123
156
|
throw new Error(`MCP client ${clientId}: its identity resource names a platform service's app id or host`)
|
|
124
157
|
}
|
|
125
158
|
}
|
package/types/src/index.d.ts
CHANGED
|
@@ -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, mcpAuthoringOn, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp';
|
|
9
|
+
export { type IamOAuthConfig, type IdentityAppSchema, identityAppSchemas, 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';
|
package/types/src/mcp.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AppSchema } from '@fabrika/auth-core';
|
|
1
2
|
import { type OAuthManagedClient, type OAuthResourceDto } from '@fabrika/iam-contract';
|
|
2
3
|
import { type PlatformProxyComposition, type PlatformProxyManifestTemplate } from './proxy-manifest';
|
|
3
4
|
/** One operator-registered MCP client: its CIMD identity, plus where IAM fetches it when that differs. */
|
|
@@ -14,6 +15,17 @@ export interface IamOAuthConfig {
|
|
|
14
15
|
* client id is refused here, before a deploy writes a value IAM would refuse to boot with.
|
|
15
16
|
*/
|
|
16
17
|
export declare const parseMcpClientsJson: (raw: string) => readonly McpClient[];
|
|
18
|
+
/** An external application's vocabulary in IAM: its declared roles, each granting no action (ADR-0049). */
|
|
19
|
+
export interface IdentityAppSchema {
|
|
20
|
+
readonly app: string;
|
|
21
|
+
readonly schema: AppSchema;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The vocabulary each external application that declares roles reconciles into IAM, once per app. The deploy writes it
|
|
25
|
+
* with the provisioning key it already holds, so the application needs no IAM credential to declare its roles. Two
|
|
26
|
+
* clients of one app must declare the same roles.
|
|
27
|
+
*/
|
|
28
|
+
export declare const identityAppSchemas: (clients: readonly McpClient[]) => readonly IdentityAppSchema[];
|
|
17
29
|
/** MCP authoring is on when the operator registers a client that is not identity-only: those sign people in, nothing more. */
|
|
18
30
|
export declare const mcpAuthoringOn: (clients: readonly McpClient[] | undefined) => boolean;
|
|
19
31
|
/**
|