skybridge 0.0.0-dev.d5d28ed → 0.0.0-dev.d5dcd8e

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 (61) hide show
  1. package/README.md +0 -1
  2. package/dist/cli/build-helpers.d.ts +1 -1
  3. package/dist/cli/build-helpers.js +2 -7
  4. package/dist/cli/build-helpers.js.map +1 -1
  5. package/dist/cli/build-helpers.test.js +0 -11
  6. package/dist/cli/build-helpers.test.js.map +1 -1
  7. package/dist/cli/build-steps.js +3 -3
  8. package/dist/cli/build-steps.js.map +1 -1
  9. package/dist/cli/resolve-views-dir.d.ts +1 -0
  10. package/dist/cli/{resolve-skybridge-config.js → resolve-views-dir.js} +3 -4
  11. package/dist/cli/resolve-views-dir.js.map +1 -0
  12. package/dist/commands/dev.js +2 -2
  13. package/dist/commands/dev.js.map +1 -1
  14. package/dist/server/auth/providers/custom.d.ts +3 -5
  15. package/dist/server/auth/providers/custom.js +6 -15
  16. package/dist/server/auth/providers/custom.js.map +1 -1
  17. package/dist/server/auth/providers/custom.test.js +9 -37
  18. package/dist/server/auth/providers/custom.test.js.map +1 -1
  19. package/dist/server/auth/providers/descope.js +3 -12
  20. package/dist/server/auth/providers/descope.js.map +1 -1
  21. package/dist/server/auth/providers/descope.test.js +17 -38
  22. package/dist/server/auth/providers/descope.test.js.map +1 -1
  23. package/dist/server/index.d.ts +0 -1
  24. package/dist/server/index.js +0 -1
  25. package/dist/server/index.js.map +1 -1
  26. package/dist/web/bridges/adaptor.js +3 -14
  27. package/dist/web/bridges/adaptor.js.map +1 -1
  28. package/dist/web/bridges/adaptor.test.js +4 -20
  29. package/dist/web/bridges/adaptor.test.js.map +1 -1
  30. package/dist/web/bridges/mcp-app/bridge.js +3 -5
  31. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  32. package/dist/web/bridges/mcp-app/types.d.ts +0 -2
  33. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  34. package/dist/web/hooks/index.d.ts +0 -1
  35. package/dist/web/hooks/index.js +0 -1
  36. package/dist/web/hooks/index.js.map +1 -1
  37. package/dist/web/hooks/test/utils.d.ts +1 -2
  38. package/dist/web/hooks/test/utils.js +1 -1
  39. package/dist/web/hooks/test/utils.js.map +1 -1
  40. package/dist/web/hooks/use-view-state.js +9 -19
  41. package/dist/web/hooks/use-view-state.js.map +1 -1
  42. package/dist/web/hooks/use-view-state.test.js +0 -31
  43. package/dist/web/hooks/use-view-state.test.js.map +1 -1
  44. package/dist/web/plugin/plugin.d.ts +0 -6
  45. package/dist/web/plugin/plugin.js +2 -3
  46. package/dist/web/plugin/plugin.js.map +1 -1
  47. package/package.json +1 -1
  48. package/dist/cli/resolve-skybridge-config.d.ts +0 -5
  49. package/dist/cli/resolve-skybridge-config.js.map +0 -1
  50. package/dist/server/auth/providers/authplane.d.ts +0 -47
  51. package/dist/server/auth/providers/authplane.js +0 -57
  52. package/dist/server/auth/providers/authplane.js.map +0 -1
  53. package/dist/server/auth/providers/authplane.test.d.ts +0 -1
  54. package/dist/server/auth/providers/authplane.test.js +0 -138
  55. package/dist/server/auth/providers/authplane.test.js.map +0 -1
  56. package/dist/web/hooks/use-host-info.d.ts +0 -22
  57. package/dist/web/hooks/use-host-info.js +0 -30
  58. package/dist/web/hooks/use-host-info.js.map +0 -1
  59. package/dist/web/hooks/use-host-info.test.d.ts +0 -1
  60. package/dist/web/hooks/use-host-info.test.js +0 -59
  61. package/dist/web/hooks/use-host-info.test.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"authplane.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/authplane.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,cAAc,EAAE,MAAM,aAAa,CAAC;AAqCzE;;;;GAIG;AACH,SAAS,eAAe,CAAC,KAAa,EAAE,MAAc;IACpD,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1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AC,cAAc,CAAC,IAAI,CAAC,IAAI;YACvF,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,6GAA6G,CAC1J,CAAC;IACJ,CAAC;IAED,OAAO,cAAc,CAAC;QACpB,MAAM;QACN,QAAQ,EAAE,QAAQ,IAAI,QAAQ;QAC9B,OAAO,EAAE,QAAQ;QACjB,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { OAuthConfig } from \"../index.js\";\nimport { type CustomProviderOptions, customProvider } from \"./custom.js\";\n\n/** Options accepted by {@link authplaneProvider}. */\nexport type AuthplaneProviderOptions = {\n /**\n * The authorization server's issuer identifier (RFC 8414 §2) — your\n * Authplane deployment, e.g. `https://auth.acme.com` (or\n * `http://localhost:9000` in local development).\n */\n issuer: string;\n /**\n * This server's resource identifier (RFC 9728 §1.2): the public URL clients\n * reach, advertised as the `resource` field of its protected-resource\n * metadata. Required, unlike the other providers.\n *\n * Authplane binds the access token's `aud` to the RFC 8707 `resource`\n * parameter the client sends, and the client takes that value from the\n * advertised metadata. Setting it explicitly gives the deployment one fixed\n * identifier, which is what the audience is checked against.\n *\n * Resource identifiers are compared by exact string match, so give it in the\n * form it will be advertised and register that same string in Authplane. RFC\n * 8707 §2 asks for the most specific URI available, e.g.\n * `https://acme.example.com/mcp`.\n */\n resource: string;\n /**\n * Expected token `aud`. Defaults to `resource`.\n *\n * RFC 8707 §2 lets an authorization server use the resource identifier\n * verbatim as the audience or map it to another value; set this only for a\n * resource configured in Authplane with such an override, and pass that\n * value verbatim.\n */\n audience?: string;\n} & Omit<CustomProviderOptions, \"issuer\" | \"audience\" | \"baseUrl\">;\n\n/**\n * Rejects anything that cannot serve as an OAuth identifier: RFC 8707 §2\n * requires an absolute URI and forbids a fragment, and the discovery and\n * protected-resource metadata URLs are both built from the scheme and host.\n */\nfunction parseIdentifier(value: string, option: string): URL {\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n throw new Error(\n `authplaneProvider: \\`${option}\\` must be an absolute URL, got ${JSON.stringify(value)}`,\n );\n }\n if (parsed.protocol !== \"https:\" && parsed.protocol !== \"http:\") {\n throw new Error(\n `authplaneProvider: \\`${option}\\` must use the http or https scheme, got ${JSON.stringify(value)}`,\n );\n }\n if (!parsed.host) {\n throw new Error(\n `authplaneProvider: \\`${option}\\` must include a host, got ${JSON.stringify(value)}`,\n );\n }\n if (parsed.hash) {\n throw new Error(\n `authplaneProvider: \\`${option}\\` must not include a fragment, got ${JSON.stringify(value)}`,\n );\n }\n return parsed;\n}\n\n/**\n * OAuth provider for Authplane. `issuer` is the authorization server's issuer\n * identifier and `resource` is this server's resource identifier, which also\n * supplies the expected token audience.\n *\n * Dynamic Client Registration is supported natively, so no registration proxy\n * is needed: clients register with Authplane directly and this server stays out\n * of the authorization path. Pass `serverUrl` to advertise this server as the\n * authorization server instead (see {@link customProvider}).\n */\nexport function authplaneProvider(\n opts: AuthplaneProviderOptions,\n): Promise<OAuthConfig> {\n const { issuer, resource, audience, ...rest } = opts;\n\n parseIdentifier(issuer, \"issuer\");\n const parsedResource = parseIdentifier(resource, \"resource\");\n\n // The advertised resource is the URL-normalised form of this value. Where\n // normalisation would change the string — a bare origin gaining a root path,\n // an uppercase host, an explicit default port — the configured and advertised\n // identifiers would differ, and the audience check compares them exactly.\n // Require the advertised form up front so the two always match.\n if (parsedResource.href !== resource) {\n throw new Error(\n `authplaneProvider: \\`resource\\` must be given in the form it will be advertised. ` +\n `${JSON.stringify(resource)} is advertised as ${JSON.stringify(parsedResource.href)}. ` +\n `Use ${JSON.stringify(parsedResource.href)}, or a path-qualified URL such as \"https://acme.example.com/mcp\", and register the same value in Authplane.`,\n );\n }\n\n return customProvider({\n issuer,\n audience: audience ?? resource,\n baseUrl: resource,\n ...rest,\n });\n}\n"]}
@@ -1 +0,0 @@
1
- export {};
@@ -1,138 +0,0 @@
1
- // @vitest-environment node
2
- import { afterEach, describe, expect, it, vi } from "vitest";
3
- import { authplaneProvider } from "./authplane.js";
4
- afterEach(() => vi.restoreAllMocks());
5
- const ISSUER = "https://auth.acme.com";
6
- function discoveryDoc(issuer, scopes) {
7
- return {
8
- issuer,
9
- authorization_endpoint: `${issuer}/authorize`,
10
- token_endpoint: `${issuer}/token`,
11
- registration_endpoint: `${issuer}/register`,
12
- response_types_supported: ["code"],
13
- scopes_supported: scopes,
14
- jwks_uri: `${issuer}/.well-known/jwks.json`,
15
- };
16
- }
17
- function mockDiscovery(docs) {
18
- return vi
19
- .spyOn(globalThis, "fetch")
20
- .mockImplementation(async (input) => {
21
- const url = String(input);
22
- const entry = Object.entries(docs).find(([issuer]) => url === `${issuer}/.well-known/openid-configuration`);
23
- if (entry === undefined) {
24
- return new Response(null, { status: 404 });
25
- }
26
- return new Response(JSON.stringify(discoveryDoc(...entry)), {
27
- headers: { "content-type": "application/json" },
28
- });
29
- });
30
- }
31
- describe("authplaneProvider", () => {
32
- it("derives the audience from the resource the server advertises", async () => {
33
- mockDiscovery({ [ISSUER]: ["checkout"] });
34
- const config = await authplaneProvider({
35
- issuer: ISSUER,
36
- resource: "https://coffee.example.com/mcp",
37
- });
38
- expect(config.verify.audience).toBe("https://coffee.example.com/mcp");
39
- expect(config.verify.issuer).toBe(ISSUER);
40
- expect(config.verify.jwksUri).toBe(`${ISSUER}/.well-known/jwks.json`);
41
- expect(config.baseUrl).toBe("https://coffee.example.com/mcp");
42
- });
43
- it.each([
44
- "https://coffee.example.com/mcp",
45
- "https://coffee.example.com/v2/mcp",
46
- "https://coffee.example.com/",
47
- "http://localhost:3000/mcp",
48
- "https://coffee.example.com:8443/mcp",
49
- ])("passes %s through as both resource and audience", async (resource) => {
50
- mockDiscovery({ [ISSUER]: ["checkout"] });
51
- const config = await authplaneProvider({ issuer: ISSUER, resource });
52
- expect(config.baseUrl).toBe(resource);
53
- expect(config.verify.audience).toBe(resource);
54
- });
55
- // The metadata router serialises the resource identifier through `URL` before
56
- // advertising it. Anything that serialisation would rewrite is refused here,
57
- // so the advertised identifier is always the configured one.
58
- it.each([
59
- // Pathless origin — gains a root path.
60
- ["https://coffee.example.com", "https://coffee.example.com/"],
61
- ["http://localhost:3000", "http://localhost:3000/"],
62
- // Uppercase host — lowercased.
63
- ["https://COFFEE.EXAMPLE.COM/mcp", "https://coffee.example.com/mcp"],
64
- // Explicit default port — dropped.
65
- ["https://coffee.example.com:443/mcp", "https://coffee.example.com/mcp"],
66
- ])("rejects %s and names %s instead", async (resource, published) => {
67
- const fetchSpy = mockDiscovery({ [ISSUER]: ["checkout"] });
68
- expect(() => authplaneProvider({ issuer: ISSUER, resource })).toThrow(`is advertised as ${JSON.stringify(published)}`);
69
- expect(fetchSpy).not.toHaveBeenCalled();
70
- });
71
- it("lets an explicit audience override the default", async () => {
72
- mockDiscovery({ [ISSUER]: ["checkout"] });
73
- const config = await authplaneProvider({
74
- issuer: ISSUER,
75
- resource: "https://coffee.example.com/mcp",
76
- audience: "urn:acme:coffee",
77
- });
78
- expect(config.verify.audience).toBe("urn:acme:coffee");
79
- });
80
- it.each([
81
- ["coffee.example.com/mcp", /must be an absolute URL/],
82
- ["ftp://coffee.example.com/mcp", /must use the http or https scheme/],
83
- ["https://coffee.example.com/mcp#frag", /must not include a fragment/],
84
- ])("rejects the malformed resource %s", async (resource, message) => {
85
- const fetchSpy = mockDiscovery({ [ISSUER]: ["checkout"] });
86
- expect(() => authplaneProvider({ issuer: ISSUER, resource })).toThrow(message);
87
- expect(fetchSpy).not.toHaveBeenCalled();
88
- });
89
- it("rejects a malformed issuer before any discovery", async () => {
90
- const fetchSpy = mockDiscovery({ [ISSUER]: ["checkout"] });
91
- expect(() => authplaneProvider({
92
- issuer: "auth.acme.com",
93
- resource: "https://coffee.example.com/mcp",
94
- })).toThrow(/`issuer` must be an absolute URL/);
95
- expect(fetchSpy).not.toHaveBeenCalled();
96
- });
97
- it("accepts an issuer carrying a trailing slash", async () => {
98
- // Discovery resolves the issuer itself; the provider passes it through
99
- // rather than rewriting the operator's value.
100
- mockDiscovery({ [ISSUER]: ["checkout"] });
101
- const config = await authplaneProvider({
102
- issuer: `${ISSUER}/`,
103
- resource: "https://coffee.example.com/mcp",
104
- });
105
- expect(config.verify.issuer).toBe(ISSUER);
106
- });
107
- it("accepts a local http issuer for development", async () => {
108
- const local = "http://localhost:9000";
109
- mockDiscovery({ [local]: ["checkout"] });
110
- const config = await authplaneProvider({
111
- issuer: local,
112
- resource: "http://localhost:3000/mcp",
113
- });
114
- expect(config.verify.issuer).toBe(local);
115
- expect(config.verify.audience).toBe("http://localhost:3000/mcp");
116
- });
117
- it("forwards scopes and the required-scope floor", async () => {
118
- mockDiscovery({ [ISSUER]: ["checkout", "profile"] });
119
- const config = await authplaneProvider({
120
- issuer: ISSUER,
121
- resource: "https://coffee.example.com/mcp",
122
- scopes: ["checkout"],
123
- requiredScopes: ["checkout"],
124
- });
125
- expect(config.scopesSupported).toEqual(["checkout"]);
126
- expect(config.requiredScopes).toEqual(["checkout"]);
127
- });
128
- it("advertises the registration endpoint for dynamic client registration", async () => {
129
- mockDiscovery({ [ISSUER]: ["checkout"] });
130
- const config = await authplaneProvider({
131
- issuer: ISSUER,
132
- resource: "https://coffee.example.com/mcp",
133
- });
134
- expect(config.oauthMetadata.issuer).toBe(ISSUER);
135
- expect(config.oauthMetadata.registration_endpoint).toBe(`${ISSUER}/register`);
136
- });
137
- });
138
- //# sourceMappingURL=authplane.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authplane.test.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/authplane.test.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;AAEtC,MAAM,MAAM,GAAG,uBAAuB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AC,CAAC;QACjD,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,IAAI,CACrD,GAAG,MAAM,WAAW,CACrB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @vitest-environment node\nimport { afterEach, describe, expect, it, vi } from \"vitest\";\nimport { authplaneProvider } from \"./authplane.js\";\n\nafterEach(() => vi.restoreAllMocks());\n\nconst ISSUER = \"https://auth.acme.com\";\n\nfunction discoveryDoc(issuer: string, scopes: string[]) {\n return {\n issuer,\n authorization_endpoint: `${issuer}/authorize`,\n token_endpoint: `${issuer}/token`,\n registration_endpoint: `${issuer}/register`,\n response_types_supported: [\"code\"],\n scopes_supported: scopes,\n jwks_uri: `${issuer}/.well-known/jwks.json`,\n };\n}\n\nfunction mockDiscovery(docs: Record<string, string[]>) {\n return vi\n .spyOn(globalThis, \"fetch\")\n .mockImplementation(async (input: RequestInfo | URL) => {\n const url = String(input);\n const entry = Object.entries(docs).find(\n ([issuer]) => url === `${issuer}/.well-known/openid-configuration`,\n );\n if (entry === undefined) {\n return new Response(null, { status: 404 });\n }\n return new Response(JSON.stringify(discoveryDoc(...entry)), {\n headers: { \"content-type\": \"application/json\" },\n });\n });\n}\n\ndescribe(\"authplaneProvider\", () => {\n it(\"derives the audience from the resource the server advertises\", async () => {\n mockDiscovery({ [ISSUER]: [\"checkout\"] });\n\n const config = await authplaneProvider({\n issuer: ISSUER,\n resource: \"https://coffee.example.com/mcp\",\n });\n\n expect(config.verify.audience).toBe(\"https://coffee.example.com/mcp\");\n expect(config.verify.issuer).toBe(ISSUER);\n expect(config.verify.jwksUri).toBe(`${ISSUER}/.well-known/jwks.json`);\n expect(config.baseUrl).toBe(\"https://coffee.example.com/mcp\");\n });\n\n it.each([\n \"https://coffee.example.com/mcp\",\n \"https://coffee.example.com/v2/mcp\",\n \"https://coffee.example.com/\",\n \"http://localhost:3000/mcp\",\n \"https://coffee.example.com:8443/mcp\",\n ])(\"passes %s through as both resource and audience\", async (resource) => {\n mockDiscovery({ [ISSUER]: [\"checkout\"] });\n\n const config = await authplaneProvider({ issuer: ISSUER, resource });\n\n expect(config.baseUrl).toBe(resource);\n expect(config.verify.audience).toBe(resource);\n });\n\n // The metadata router serialises the resource identifier through `URL` before\n // advertising it. Anything that serialisation would rewrite is refused here,\n // so the advertised identifier is always the configured one.\n it.each([\n // Pathless origin — gains a root path.\n [\"https://coffee.example.com\", \"https://coffee.example.com/\"],\n [\"http://localhost:3000\", \"http://localhost:3000/\"],\n // Uppercase host — lowercased.\n [\"https://COFFEE.EXAMPLE.COM/mcp\", \"https://coffee.example.com/mcp\"],\n // Explicit default port — dropped.\n [\"https://coffee.example.com:443/mcp\", \"https://coffee.example.com/mcp\"],\n ])(\"rejects %s and names %s instead\", async (resource, published) => {\n const fetchSpy = mockDiscovery({ [ISSUER]: [\"checkout\"] });\n\n expect(() => authplaneProvider({ issuer: ISSUER, resource })).toThrow(\n `is advertised as ${JSON.stringify(published)}`,\n );\n expect(fetchSpy).not.toHaveBeenCalled();\n });\n\n it(\"lets an explicit audience override the default\", async () => {\n mockDiscovery({ [ISSUER]: [\"checkout\"] });\n\n const config = await authplaneProvider({\n issuer: ISSUER,\n resource: \"https://coffee.example.com/mcp\",\n audience: \"urn:acme:coffee\",\n });\n\n expect(config.verify.audience).toBe(\"urn:acme:coffee\");\n });\n\n it.each([\n [\"coffee.example.com/mcp\", /must be an absolute URL/],\n [\"ftp://coffee.example.com/mcp\", /must use the http or https scheme/],\n [\"https://coffee.example.com/mcp#frag\", /must not include a fragment/],\n ])(\"rejects the malformed resource %s\", async (resource, message) => {\n const fetchSpy = mockDiscovery({ [ISSUER]: [\"checkout\"] });\n\n expect(() => authplaneProvider({ issuer: ISSUER, resource })).toThrow(\n message,\n );\n expect(fetchSpy).not.toHaveBeenCalled();\n });\n\n it(\"rejects a malformed issuer before any discovery\", async () => {\n const fetchSpy = mockDiscovery({ [ISSUER]: [\"checkout\"] });\n\n expect(() =>\n authplaneProvider({\n issuer: \"auth.acme.com\",\n resource: \"https://coffee.example.com/mcp\",\n }),\n ).toThrow(/`issuer` must be an absolute URL/);\n expect(fetchSpy).not.toHaveBeenCalled();\n });\n\n it(\"accepts an issuer carrying a trailing slash\", async () => {\n // Discovery resolves the issuer itself; the provider passes it through\n // rather than rewriting the operator's value.\n mockDiscovery({ [ISSUER]: [\"checkout\"] });\n\n const config = await authplaneProvider({\n issuer: `${ISSUER}/`,\n resource: \"https://coffee.example.com/mcp\",\n });\n\n expect(config.verify.issuer).toBe(ISSUER);\n });\n\n it(\"accepts a local http issuer for development\", async () => {\n const local = \"http://localhost:9000\";\n mockDiscovery({ [local]: [\"checkout\"] });\n\n const config = await authplaneProvider({\n issuer: local,\n resource: \"http://localhost:3000/mcp\",\n });\n\n expect(config.verify.issuer).toBe(local);\n expect(config.verify.audience).toBe(\"http://localhost:3000/mcp\");\n });\n\n it(\"forwards scopes and the required-scope floor\", async () => {\n mockDiscovery({ [ISSUER]: [\"checkout\", \"profile\"] });\n\n const config = await authplaneProvider({\n issuer: ISSUER,\n resource: \"https://coffee.example.com/mcp\",\n scopes: [\"checkout\"],\n requiredScopes: [\"checkout\"],\n });\n\n expect(config.scopesSupported).toEqual([\"checkout\"]);\n expect(config.requiredScopes).toEqual([\"checkout\"]);\n });\n\n it(\"advertises the registration endpoint for dynamic client registration\", async () => {\n mockDiscovery({ [ISSUER]: [\"checkout\"] });\n\n const config = await authplaneProvider({\n issuer: ISSUER,\n resource: \"https://coffee.example.com/mcp\",\n });\n\n expect(config.oauthMetadata.issuer).toBe(ISSUER);\n expect(config.oauthMetadata.registration_endpoint).toBe(\n `${ISSUER}/register`,\n );\n });\n});\n"]}
@@ -1,22 +0,0 @@
1
- /**
2
- * Known host applications, as normalized slugs. Unrecognized hosts surface
3
- * their raw `hostInfo.name` string instead.
4
- */
5
- export type Host = "chatgpt" | "claude" | "cursor" | "goose" | "mistral-vibe" | "alpic";
6
- export type HostInfo = {
7
- name: Host | (string & {}) | undefined;
8
- version: string | undefined;
9
- };
10
- /**
11
- * Identity of the host application rendering the view, from the MCP Apps
12
- * `ui/initialize` handshake. `name` is normalized to a {@link Host} slug when
13
- * recognized, otherwise the raw string; both fields are `undefined` until the
14
- * handshake resolves (the view renders first and re-renders once it lands).
15
- *
16
- * @example
17
- * ```tsx
18
- * const { name } = useHostInfo();
19
- * if (name === "claude") return <ClaudeLayout />;
20
- * ```
21
- */
22
- export declare function useHostInfo(): HostInfo;
@@ -1,30 +0,0 @@
1
- import { useMcpAppContext } from "../bridges/index.js";
2
- const HOST_BY_REPORTED_NAME = {
3
- chatgpt: "chatgpt",
4
- Claude: "claude",
5
- Cursor: "cursor",
6
- "MCP-UI Host": "goose",
7
- "Le Chat": "mistral-vibe",
8
- "alpic-playground": "alpic",
9
- };
10
- /**
11
- * Identity of the host application rendering the view, from the MCP Apps
12
- * `ui/initialize` handshake. `name` is normalized to a {@link Host} slug when
13
- * recognized, otherwise the raw string; both fields are `undefined` until the
14
- * handshake resolves (the view renders first and re-renders once it lands).
15
- *
16
- * @example
17
- * ```tsx
18
- * const { name } = useHostInfo();
19
- * if (name === "claude") return <ClaudeLayout />;
20
- * ```
21
- */
22
- export function useHostInfo() {
23
- const hostInfo = useMcpAppContext("hostInfo");
24
- const name = hostInfo?.name;
25
- return {
26
- name: name !== undefined ? (HOST_BY_REPORTED_NAME[name] ?? name) : undefined,
27
- version: hostInfo?.version,
28
- };
29
- }
30
- //# sourceMappingURL=use-host-info.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-host-info.js","sourceRoot":"","sources":["../../../src/web/hooks/use-host-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAcvD,MAAM,qBAAqB,GAAyB;IAClD,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,OAAO;IACtB,SAAS,EAAE,cAAc;IACzB,kBAAkB,EAAE,OAAO;CAC5B,CAAC;AAOF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,QAAQ,EAAE,IAAI,CAAC;IAE5B,OAAO;QACL,IAAI,EACF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACxE,OAAO,EAAE,QAAQ,EAAE,OAAO;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import { useMcpAppContext } from \"../bridges/index.js\";\n\n/**\n * Known host applications, as normalized slugs. Unrecognized hosts surface\n * their raw `hostInfo.name` string instead.\n */\nexport type Host =\n | \"chatgpt\"\n | \"claude\"\n | \"cursor\"\n | \"goose\"\n | \"mistral-vibe\"\n | \"alpic\";\n\nconst HOST_BY_REPORTED_NAME: Record<string, Host> = {\n chatgpt: \"chatgpt\",\n Claude: \"claude\",\n Cursor: \"cursor\",\n \"MCP-UI Host\": \"goose\",\n \"Le Chat\": \"mistral-vibe\",\n \"alpic-playground\": \"alpic\",\n};\n\nexport type HostInfo = {\n name: Host | (string & {}) | undefined;\n version: string | undefined;\n};\n\n/**\n * Identity of the host application rendering the view, from the MCP Apps\n * `ui/initialize` handshake. `name` is normalized to a {@link Host} slug when\n * recognized, otherwise the raw string; both fields are `undefined` until the\n * handshake resolves (the view renders first and re-renders once it lands).\n *\n * @example\n * ```tsx\n * const { name } = useHostInfo();\n * if (name === \"claude\") return <ClaudeLayout />;\n * ```\n */\nexport function useHostInfo(): HostInfo {\n const hostInfo = useMcpAppContext(\"hostInfo\");\n const name = hostInfo?.name;\n\n return {\n name:\n name !== undefined ? (HOST_BY_REPORTED_NAME[name] ?? name) : undefined,\n version: hostInfo?.version,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- export {};
@@ -1,59 +0,0 @@
1
- import { renderHook, waitFor } from "@testing-library/react";
2
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
- import { HostAdaptor } from "../bridges/adaptor.js";
4
- import { McpAppBridge } from "../bridges/mcp-app/bridge.js";
5
- import { getMcpAppHostPostMessageMock, MockResizeObserver, } from "./test/utils.js";
6
- import { useHostInfo } from "./use-host-info.js";
7
- const stubHost = (hostInfo) => {
8
- vi.stubGlobal("parent", {
9
- postMessage: getMcpAppHostPostMessageMock({}, { hostInfo }),
10
- });
11
- };
12
- describe("useHostInfo", () => {
13
- beforeEach(() => {
14
- HostAdaptor.resetInstance();
15
- McpAppBridge.resetInstance();
16
- vi.stubGlobal("openai", undefined);
17
- vi.stubGlobal("skybridge", { hostType: "mcp-app" });
18
- vi.stubGlobal("ResizeObserver", MockResizeObserver);
19
- });
20
- afterEach(() => {
21
- vi.unstubAllGlobals();
22
- vi.resetAllMocks();
23
- McpAppBridge.resetInstance();
24
- HostAdaptor.resetInstance();
25
- });
26
- it("is undefined before the handshake resolves, then populated after", async () => {
27
- stubHost({ name: "Claude", version: "1.2.3" });
28
- const { result } = renderHook(() => useHostInfo());
29
- expect(result.current.name).toBeUndefined();
30
- expect(result.current.version).toBeUndefined();
31
- await waitFor(() => {
32
- expect(result.current.name).toBe("claude");
33
- expect(result.current.version).toBe("1.2.3");
34
- });
35
- });
36
- it.each([
37
- ["chatgpt", "chatgpt"],
38
- ["Claude", "claude"],
39
- ["Cursor", "cursor"],
40
- ["MCP-UI Host", "goose"],
41
- ["Le Chat", "mistral-vibe"],
42
- ["alpic-playground", "alpic"],
43
- ])("normalizes reported name %j to slug %j", async (reported, slug) => {
44
- stubHost({ name: reported, version: "1.0.0" });
45
- const { result } = renderHook(() => useHostInfo());
46
- await waitFor(() => {
47
- expect(result.current.name).toBe(slug);
48
- });
49
- });
50
- it("preserves an unrecognized reported name as-is", async () => {
51
- stubHost({ name: "Some Future Host", version: "9.9.9" });
52
- const { result } = renderHook(() => useHostInfo());
53
- await waitFor(() => {
54
- expect(result.current.name).toBe("Some Future Host");
55
- expect(result.current.version).toBe("9.9.9");
56
- });
57
- });
58
- });
59
- //# sourceMappingURL=use-host-info.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-host-info.test.js","sourceRoot":"","sources":["../../../src/web/hooks/use-host-info.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAa,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,QAAQ,GAAG,CAAC,QAA4C,EAAE,EAAE;IAChE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE;QACtB,WAAW,EAAE,4BAA4B,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;KAC5D,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,UAAU,CAAC,GAAG,EAAE;QACd,WAAW,CAAC,aAAa,EAAE,CAAC;QAC5B,YAAY,CAAC,aAAa,EAAE,CAAC;QAC7B,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACnC,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;QACpD,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE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AAE,CAAC,CAAC;QAC/C,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAEnD,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC7D,QAAQ,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACzD,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAEnD,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACrD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook, waitFor } from \"@testing-library/react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { HostAdaptor } from \"../bridges/adaptor.js\";\nimport { McpAppBridge } from \"../bridges/mcp-app/bridge.js\";\nimport {\n getMcpAppHostPostMessageMock,\n MockResizeObserver,\n} from \"./test/utils.js\";\nimport { type Host, useHostInfo } from \"./use-host-info.js\";\n\nconst stubHost = (hostInfo?: { name: string; version: string }) => {\n vi.stubGlobal(\"parent\", {\n postMessage: getMcpAppHostPostMessageMock({}, { hostInfo }),\n });\n};\n\ndescribe(\"useHostInfo\", () => {\n beforeEach(() => {\n HostAdaptor.resetInstance();\n McpAppBridge.resetInstance();\n vi.stubGlobal(\"openai\", undefined);\n vi.stubGlobal(\"skybridge\", { hostType: \"mcp-app\" });\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n McpAppBridge.resetInstance();\n HostAdaptor.resetInstance();\n });\n\n it(\"is undefined before the handshake resolves, then populated after\", async () => {\n stubHost({ name: \"Claude\", version: \"1.2.3\" });\n const { result } = renderHook(() => useHostInfo());\n\n expect(result.current.name).toBeUndefined();\n expect(result.current.version).toBeUndefined();\n\n await waitFor(() => {\n expect(result.current.name).toBe(\"claude\");\n expect(result.current.version).toBe(\"1.2.3\");\n });\n });\n\n it.each<[string, Host]>([\n [\"chatgpt\", \"chatgpt\"],\n [\"Claude\", \"claude\"],\n [\"Cursor\", \"cursor\"],\n [\"MCP-UI Host\", \"goose\"],\n [\"Le Chat\", \"mistral-vibe\"],\n [\"alpic-playground\", \"alpic\"],\n ])(\"normalizes reported name %j to slug %j\", async (reported, slug) => {\n stubHost({ name: reported, version: \"1.0.0\" });\n const { result } = renderHook(() => useHostInfo());\n\n await waitFor(() => {\n expect(result.current.name).toBe(slug);\n });\n });\n\n it(\"preserves an unrecognized reported name as-is\", async () => {\n stubHost({ name: \"Some Future Host\", version: \"9.9.9\" });\n const { result } = renderHook(() => useHostInfo());\n\n await waitFor(() => {\n expect(result.current.name).toBe(\"Some Future Host\");\n expect(result.current.version).toBe(\"9.9.9\");\n });\n });\n});\n"]}