skybridge 0.0.0-dev.df033f6 → 0.0.0-dev.df0cfdd

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 (267) hide show
  1. package/README.md +3 -0
  2. package/dist/cli/build-helpers.d.ts +6 -2
  3. package/dist/cli/build-helpers.js +37 -12
  4. package/dist/cli/build-helpers.js.map +1 -1
  5. package/dist/cli/build-helpers.test.js +71 -3
  6. package/dist/cli/build-helpers.test.js.map +1 -1
  7. package/dist/cli/build-steps.d.ts +2 -0
  8. package/dist/cli/build-steps.js +73 -0
  9. package/dist/cli/build-steps.js.map +1 -0
  10. package/dist/cli/build-steps.test.js +52 -0
  11. package/dist/cli/build-steps.test.js.map +1 -0
  12. package/dist/cli/header.d.ts +1 -1
  13. package/dist/cli/resolve-skybridge-config.d.ts +5 -0
  14. package/dist/cli/{resolve-views-dir.js → resolve-skybridge-config.js} +4 -3
  15. package/dist/cli/resolve-skybridge-config.js.map +1 -0
  16. package/dist/cli/run-plain.d.ts +18 -0
  17. package/dist/cli/run-plain.js +89 -0
  18. package/dist/cli/run-plain.js.map +1 -0
  19. package/dist/cli/use-nodemon.d.ts +14 -0
  20. package/dist/cli/use-nodemon.js +71 -60
  21. package/dist/cli/use-nodemon.js.map +1 -1
  22. package/dist/cli/use-typescript-check.d.ts +8 -2
  23. package/dist/cli/use-typescript-check.js +70 -67
  24. package/dist/cli/use-typescript-check.js.map +1 -1
  25. package/dist/commands/build.d.ts +0 -2
  26. package/dist/commands/build.js +2 -61
  27. package/dist/commands/build.js.map +1 -1
  28. package/dist/commands/dev.d.ts +1 -0
  29. package/dist/commands/dev.js +35 -3
  30. package/dist/commands/dev.js.map +1 -1
  31. package/dist/context-warnings.d.ts +5 -0
  32. package/dist/context-warnings.js +31 -0
  33. package/dist/context-warnings.js.map +1 -0
  34. package/dist/context-warnings.test.js +28 -0
  35. package/dist/context-warnings.test.js.map +1 -0
  36. package/dist/server/auth/discovery.d.ts +32 -0
  37. package/dist/server/auth/discovery.js +56 -0
  38. package/dist/server/auth/discovery.js.map +1 -0
  39. package/dist/server/auth/discovery.test.js +93 -0
  40. package/dist/server/auth/discovery.test.js.map +1 -0
  41. package/dist/server/auth/index.d.ts +44 -0
  42. package/dist/server/auth/index.js +2 -0
  43. package/dist/server/auth/index.js.map +1 -0
  44. package/dist/server/auth/providers/auth0.d.ts +40 -0
  45. package/dist/server/auth/providers/auth0.js +31 -0
  46. package/dist/server/auth/providers/auth0.js.map +1 -0
  47. package/dist/server/auth/providers/auth0.test.d.ts +1 -0
  48. package/dist/server/auth/providers/auth0.test.js +50 -0
  49. package/dist/server/auth/providers/auth0.test.js.map +1 -0
  50. package/dist/server/auth/providers/authplane.d.ts +49 -0
  51. package/dist/server/auth/providers/authplane.js +57 -0
  52. package/dist/server/auth/providers/authplane.js.map +1 -0
  53. package/dist/server/auth/providers/authplane.test.d.ts +1 -0
  54. package/dist/server/auth/providers/authplane.test.js +140 -0
  55. package/dist/server/auth/providers/authplane.test.js.map +1 -0
  56. package/dist/server/auth/providers/clerk.d.ts +51 -0
  57. package/dist/server/auth/providers/clerk.js +19 -0
  58. package/dist/server/auth/providers/clerk.js.map +1 -0
  59. package/dist/server/auth/providers/clerk.test.d.ts +1 -0
  60. package/dist/server/auth/providers/clerk.test.js +30 -0
  61. package/dist/server/auth/providers/clerk.test.js.map +1 -0
  62. package/dist/server/auth/providers/custom.d.ts +40 -0
  63. package/dist/server/auth/providers/custom.js +56 -0
  64. package/dist/server/auth/providers/custom.js.map +1 -0
  65. package/dist/server/auth/providers/custom.test.d.ts +1 -0
  66. package/dist/server/auth/providers/custom.test.js +158 -0
  67. package/dist/server/auth/providers/custom.test.js.map +1 -0
  68. package/dist/server/auth/providers/descope.d.ts +44 -0
  69. package/dist/server/auth/providers/descope.js +44 -0
  70. package/dist/server/auth/providers/descope.js.map +1 -0
  71. package/dist/server/auth/providers/descope.test.d.ts +1 -0
  72. package/dist/server/auth/providers/descope.test.js +62 -0
  73. package/dist/server/auth/providers/descope.test.js.map +1 -0
  74. package/dist/server/auth/providers/shared.d.ts +2 -0
  75. package/dist/server/auth/providers/shared.js +6 -0
  76. package/dist/server/auth/providers/shared.js.map +1 -0
  77. package/dist/server/auth/providers/shared.test.d.ts +1 -0
  78. package/dist/server/auth/providers/shared.test.js +10 -0
  79. package/dist/server/auth/providers/shared.test.js.map +1 -0
  80. package/dist/server/auth/providers/stytch.d.ts +25 -0
  81. package/dist/server/auth/providers/stytch.js +16 -0
  82. package/dist/server/auth/providers/stytch.js.map +1 -0
  83. package/dist/server/auth/providers/verify-spy.d.ts +12 -0
  84. package/dist/server/auth/providers/verify-spy.js +21 -0
  85. package/dist/server/auth/providers/verify-spy.js.map +1 -0
  86. package/dist/server/auth/providers/workos.d.ts +33 -0
  87. package/dist/server/auth/providers/workos.js +15 -0
  88. package/dist/server/auth/providers/workos.js.map +1 -0
  89. package/dist/server/auth/security-schemes.d.ts +23 -0
  90. package/dist/server/auth/security-schemes.js +64 -0
  91. package/dist/server/auth/security-schemes.js.map +1 -0
  92. package/dist/server/auth/security-schemes.test.d.ts +1 -0
  93. package/dist/server/auth/security-schemes.test.js +99 -0
  94. package/dist/server/auth/security-schemes.test.js.map +1 -0
  95. package/dist/server/auth/setup.d.ts +6 -0
  96. package/dist/server/auth/setup.js +92 -0
  97. package/dist/server/auth/setup.js.map +1 -0
  98. package/dist/server/auth/setup.test.d.ts +1 -0
  99. package/dist/server/auth/setup.test.js +508 -0
  100. package/dist/server/auth/setup.test.js.map +1 -0
  101. package/dist/server/auth/verify.d.ts +46 -0
  102. package/dist/server/auth/verify.js +62 -0
  103. package/dist/server/auth/verify.js.map +1 -0
  104. package/dist/server/auth/verify.test.d.ts +1 -0
  105. package/dist/server/auth/verify.test.js +149 -0
  106. package/dist/server/auth/verify.test.js.map +1 -0
  107. package/dist/server/auth-extra.test-d.js +82 -0
  108. package/dist/server/auth-extra.test-d.js.map +1 -0
  109. package/dist/server/auth.d.ts +39 -1
  110. package/dist/server/auth.js.map +1 -1
  111. package/dist/server/host.d.ts +2 -0
  112. package/dist/server/host.js +11 -0
  113. package/dist/server/host.js.map +1 -0
  114. package/dist/server/host.test.d.ts +1 -0
  115. package/dist/server/host.test.js +13 -0
  116. package/dist/server/host.test.js.map +1 -0
  117. package/dist/server/index.d.ts +13 -2
  118. package/dist/server/index.js +11 -1
  119. package/dist/server/index.js.map +1 -1
  120. package/dist/server/middleware.d.ts +31 -6
  121. package/dist/server/middleware.js +33 -0
  122. package/dist/server/middleware.js.map +1 -1
  123. package/dist/server/middleware.test.js +37 -1
  124. package/dist/server/middleware.test.js.map +1 -1
  125. package/dist/server/requestOrigin.d.ts +7 -0
  126. package/dist/server/requestOrigin.js +25 -0
  127. package/dist/server/requestOrigin.js.map +1 -0
  128. package/dist/server/server.d.ts +93 -25
  129. package/dist/server/server.js +233 -142
  130. package/dist/server/server.js.map +1 -1
  131. package/dist/server/skills-integration.test.d.ts +1 -0
  132. package/dist/server/skills-integration.test.js +79 -0
  133. package/dist/server/skills-integration.test.js.map +1 -0
  134. package/dist/server/skills.d.ts +29 -0
  135. package/dist/server/skills.js +195 -0
  136. package/dist/server/skills.js.map +1 -0
  137. package/dist/server/skills.test.d.ts +1 -0
  138. package/dist/server/skills.test.js +247 -0
  139. package/dist/server/skills.test.js.map +1 -0
  140. package/dist/server/view-name.test-d.d.ts +1 -0
  141. package/dist/server/view-name.test-d.js +8 -0
  142. package/dist/server/view-name.test-d.js.map +1 -0
  143. package/dist/server/view-resource-resolution.test.js +93 -10
  144. package/dist/server/view-resource-resolution.test.js.map +1 -1
  145. package/dist/server/viewsDevServer.js +4 -1
  146. package/dist/server/viewsDevServer.js.map +1 -1
  147. package/dist/test/utils.d.ts +3 -3
  148. package/dist/test/view.test.js +86 -102
  149. package/dist/test/view.test.js.map +1 -1
  150. package/dist/web/bridges/adaptor.d.ts +51 -0
  151. package/dist/web/bridges/adaptor.js +327 -0
  152. package/dist/web/bridges/adaptor.js.map +1 -0
  153. package/dist/web/bridges/adaptor.test.d.ts +1 -0
  154. package/dist/web/bridges/adaptor.test.js +225 -0
  155. package/dist/web/bridges/adaptor.test.js.map +1 -0
  156. package/dist/web/bridges/apps-sdk/bridge.d.ts +6 -2
  157. package/dist/web/bridges/apps-sdk/bridge.js +15 -4
  158. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  159. package/dist/web/bridges/apps-sdk/index.d.ts +0 -1
  160. package/dist/web/bridges/apps-sdk/index.js +0 -1
  161. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  162. package/dist/web/bridges/get-adaptor.d.ts +4 -4
  163. package/dist/web/bridges/get-adaptor.js +6 -11
  164. package/dist/web/bridges/get-adaptor.js.map +1 -1
  165. package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
  166. package/dist/web/bridges/get-adaptor.test.js +32 -0
  167. package/dist/web/bridges/get-adaptor.test.js.map +1 -0
  168. package/dist/web/bridges/mcp-app/bridge.d.ts +13 -2
  169. package/dist/web/bridges/mcp-app/bridge.js +51 -7
  170. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  171. package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
  172. package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
  173. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
  174. package/dist/web/bridges/mcp-app/index.d.ts +0 -1
  175. package/dist/web/bridges/mcp-app/index.js +0 -1
  176. package/dist/web/bridges/mcp-app/index.js.map +1 -1
  177. package/dist/web/bridges/mcp-app/types.d.ts +2 -0
  178. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  179. package/dist/web/bridges/mcp-app/view-tools.test.js +5 -6
  180. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -1
  181. package/dist/web/bridges/types.d.ts +10 -0
  182. package/dist/web/bridges/types.js +14 -1
  183. package/dist/web/bridges/types.js.map +1 -1
  184. package/dist/web/bridges/types.test.d.ts +1 -0
  185. package/dist/web/bridges/types.test.js +19 -0
  186. package/dist/web/bridges/types.test.js.map +1 -0
  187. package/dist/web/components/modal-provider.d.ts +1 -1
  188. package/dist/web/components/modal-provider.js +4 -3
  189. package/dist/web/components/modal-provider.js.map +1 -1
  190. package/dist/web/create-store.test.js +8 -5
  191. package/dist/web/create-store.test.js.map +1 -1
  192. package/dist/web/data-llm.d.ts +1 -1
  193. package/dist/web/data-llm.test.js +18 -5
  194. package/dist/web/data-llm.test.js.map +1 -1
  195. package/dist/web/hooks/index.d.ts +1 -0
  196. package/dist/web/hooks/index.js +1 -0
  197. package/dist/web/hooks/index.js.map +1 -1
  198. package/dist/web/hooks/test/utils.d.ts +2 -1
  199. package/dist/web/hooks/test/utils.js +1 -1
  200. package/dist/web/hooks/test/utils.js.map +1 -1
  201. package/dist/web/hooks/use-call-tool.test.js +37 -23
  202. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  203. package/dist/web/hooks/use-display-mode.test.js +56 -20
  204. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  205. package/dist/web/hooks/use-download.test.js +11 -3
  206. package/dist/web/hooks/use-download.test.js.map +1 -1
  207. package/dist/web/hooks/use-files.test.js +10 -2
  208. package/dist/web/hooks/use-files.test.js.map +1 -1
  209. package/dist/web/hooks/use-host-info.d.ts +22 -0
  210. package/dist/web/hooks/use-host-info.js +30 -0
  211. package/dist/web/hooks/use-host-info.js.map +1 -0
  212. package/dist/web/hooks/use-host-info.test.d.ts +1 -0
  213. package/dist/web/hooks/use-host-info.test.js +59 -0
  214. package/dist/web/hooks/use-host-info.test.js.map +1 -0
  215. package/dist/web/hooks/use-layout.test.js +59 -26
  216. package/dist/web/hooks/use-layout.test.js.map +1 -1
  217. package/dist/web/hooks/use-open-external.test.js +13 -3
  218. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  219. package/dist/web/hooks/use-request-close.test.js +35 -40
  220. package/dist/web/hooks/use-request-close.test.js.map +1 -1
  221. package/dist/web/hooks/use-request-modal.test.js +10 -0
  222. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  223. package/dist/web/hooks/use-request-size.test.js +35 -53
  224. package/dist/web/hooks/use-request-size.test.js.map +1 -1
  225. package/dist/web/hooks/use-set-open-in-app-url.test.js +28 -8
  226. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  227. package/dist/web/hooks/use-tool-info.test.js +37 -27
  228. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  229. package/dist/web/hooks/use-user.test.js +81 -35
  230. package/dist/web/hooks/use-user.test.js.map +1 -1
  231. package/dist/web/hooks/use-view-state.js +19 -9
  232. package/dist/web/hooks/use-view-state.js.map +1 -1
  233. package/dist/web/hooks/use-view-state.test.js +37 -2
  234. package/dist/web/hooks/use-view-state.test.js.map +1 -1
  235. package/package.json +21 -24
  236. package/dist/cli/resolve-views-dir.d.ts +0 -1
  237. package/dist/cli/resolve-views-dir.js.map +0 -1
  238. package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -29
  239. package/dist/web/bridges/apps-sdk/adaptor.js +0 -117
  240. package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
  241. package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -53
  242. package/dist/web/bridges/mcp-app/adaptor.js +0 -283
  243. package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
  244. package/dist/web/plugin/data-llm.test.js +0 -81
  245. package/dist/web/plugin/data-llm.test.js.map +0 -1
  246. package/dist/web/plugin/plugin.d.ts +0 -33
  247. package/dist/web/plugin/plugin.js +0 -189
  248. package/dist/web/plugin/plugin.js.map +0 -1
  249. package/dist/web/plugin/scan-views.d.ts +0 -16
  250. package/dist/web/plugin/scan-views.js +0 -88
  251. package/dist/web/plugin/scan-views.js.map +0 -1
  252. package/dist/web/plugin/scan-views.test.js +0 -99
  253. package/dist/web/plugin/scan-views.test.js.map +0 -1
  254. package/dist/web/plugin/transform-data-llm.d.ts +0 -12
  255. package/dist/web/plugin/transform-data-llm.js +0 -96
  256. package/dist/web/plugin/transform-data-llm.js.map +0 -1
  257. package/dist/web/plugin/transform-data-llm.test.js +0 -81
  258. package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
  259. package/dist/web/plugin/validate-view.d.ts +0 -1
  260. package/dist/web/plugin/validate-view.js +0 -9
  261. package/dist/web/plugin/validate-view.js.map +0 -1
  262. package/dist/web/plugin/validate-view.test.js +0 -24
  263. package/dist/web/plugin/validate-view.test.js.map +0 -1
  264. /package/dist/{web/plugin/data-llm.test.d.ts → cli/build-steps.test.d.ts} +0 -0
  265. /package/dist/{web/plugin/scan-views.test.d.ts → context-warnings.test.d.ts} +0 -0
  266. /package/dist/{web/plugin/validate-view.test.d.ts → server/auth/discovery.test.d.ts} +0 -0
  267. /package/dist/{web/plugin/transform-data-llm.test.d.ts → server/auth-extra.test-d.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/custom.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAyB,MAAM,cAAc,CAAC;AA+BzE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAA2B;IAE3B,MAAM,UAAU,GAAG,MAAM,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAElE,gFAAgF;IAChF,kFAAkF;IAClF,iFAAiF;IACjF,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,CAAC,MAAM,4DAA4D,CAC3E,CAAC;IACJ,CAAC;IAED,iFAAiF;IACjF,yCAAyC;IACzC,MAAM,EACJ,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,KAAK,EACf,GAAG,SAAS,EACb,GAAgC,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC;IAC9D,IAAI,UAAU,GAAG,UAAU,CAAC;IAC5B,IAAI,IA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etadata } from \"@modelcontextprotocol/sdk/shared/auth.js\";\nimport type { ExtraClaims } from \"../../auth.js\";\nimport {\n type DiscoveredMetadata,\n discoverAuthorizationServer,\n} from \"../discovery.js\";\nimport type { OAuthConfig } from \"../index.js\";\nimport { createJwksVerifier, type RegisteredClaims } from \"../verify.js\";\n\n/** Options accepted by {@link customProvider} and the branded providers. */\nexport type CustomProviderOptions = {\n issuer: string;\n /** Expected token `aud`. Omit to skip audience verification — only for IdPs\n * that don't bind an audience (e.g. Clerk). Branded providers whose IdP does\n * bind an audience re-require it in their own options. */\n audience?: string;\n /** Omit to let the server infer the resource origin from request headers. */\n baseUrl?: string;\n /** Advertise THIS server as the authorization server (skybridge-as-AS): the\n * served AS metadata `issuer` and the PRM `authorization_servers` use this URL\n * instead of the IdP's. Needed when skybridge must sit in the auth path — Auth0\n * (the `audience` must be baked into `/authorize`) or the Alpic DCR proxy (Alpic\n * injects the registration endpoint). Use the static public URL; `verify.issuer`\n * stays the IdP (the token's real `iss`). */\n serverUrl?: string;\n /** Advertise this URL as the authorization server (served AS metadata `issuer`\n * and PRM `authorization_servers`). Its own discovery document supplies the\n * advertised endpoints, DCR registration, scopes and the `iss` tokens are\n * verified against; only `jwks_uri` still comes from `issuer`'s document. Use\n * when DCR/authorize/token live at a different URL than the discovery issuer\n * (e.g. Descope's agentic URL vs. its base-project URL). `serverUrl` wins if\n * both are set. */\n authorizationServer?: string;\n scopes?: string[];\n requiredScopes?: string[];\n metadataOverrides?: Omit<Partial<OAuthMetadata>, \"issuer\">;\n};\n\n/**\n * Builds a complete {@link OAuthConfig} from an IdP's OAuth discovery document.\n *\n * @typeParam TExtra - Claims the IdP puts in the access token, reaching handlers\n * as `extra.authInfo.extra`. The branded providers pass their documented claims;\n * pass your own when wiring an IdP by hand.\n */\nexport async function customProvider<TExtra extends ExtraClaims = ExtraClaims>(\n opts: CustomProviderOptions,\n): Promise<OAuthConfig<TExtra & RegisteredClaims>> {\n const discovered = await discoverAuthorizationServer(opts.issuer);\n\n // JWKS verification needs a signing-key URL; without it the server can't verify\n // tokens. (`registration_endpoint` is optional per RFC 8414 — a no-DCR IdP simply\n // omits it; a proxy like Alpic, or pre-registered clients, supply registration.)\n if (!discovered.jwks_uri) {\n throw new Error(\n `${opts.issuer} discovery has no jwks_uri; JWKS verification requires it.`,\n );\n }\n\n // Overrides adjust only advertised metadata; the trust anchor (issuer, jwks_uri)\n // always comes from validated discovery.\n const {\n issuer: _issuer,\n jwks_uri: _jwks,\n ...overrides\n }: Partial<DiscoveredMetadata> = opts.metadataOverrides ?? {};\n let advertised = discovered;\n if (opts.authorizationServer) {\n try {\n advertised = await discoverAuthorizationServer(opts.authorizationServer);\n } catch (err) {\n console.warn(\n `OAuth discovery failed for authorizationServer ${opts.authorizationServer}; advertising ${opts.issuer} metadata instead: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n const base: DiscoveredMetadata = { ...advertised, ...overrides };\n const scopesSupported = opts.scopes ?? base.scopes_supported;\n\n // serverUrl (skybridge-as-AS) overrides the advertised issuer, keeping the\n // IdP as the token issuer. authorizationServer re-asserts its own URL so a\n // failed AS discovery still points clients at the AS. serverUrl wins.\n const advertisedIssuer =\n opts.serverUrl?.replace(/\\/$/, \"\") ??\n opts.authorizationServer?.replace(/\\/$/, \"\");\n const oauthMetadata: DiscoveredMetadata = advertisedIssuer\n ? {\n ...base,\n issuer: advertisedIssuer,\n scopes_supported: scopesSupported,\n }\n : base;\n\n return {\n baseUrl: opts.baseUrl,\n oauthMetadata,\n verifier: createJwksVerifier<TExtra>({\n issuer: advertised.issuer,\n audience: opts.audience,\n jwksUri: advertised.jwks_uri ?? discovered.jwks_uri,\n }),\n scopesSupported,\n requiredScopes: opts.requiredScopes,\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,158 @@
1
+ // @vitest-environment node
2
+ import http from "node:http";
3
+ import { afterEach, describe, expect, it, vi } from "vitest";
4
+ import { customProvider } from "./custom.js";
5
+ import { lastJwksConfig as jwks } from "./verify-spy.js";
6
+ vi.mock("../verify.js", () => import("./verify-spy.js"));
7
+ const servers = [];
8
+ afterEach(() => {
9
+ for (const srv of servers.splice(0)) {
10
+ srv.close();
11
+ }
12
+ });
13
+ function doc(origin, extra = {}) {
14
+ return {
15
+ issuer: origin,
16
+ authorization_endpoint: `${origin}/authorize`,
17
+ token_endpoint: `${origin}/token`,
18
+ registration_endpoint: `${origin}/register`,
19
+ response_types_supported: ["code"],
20
+ scopes_supported: ["openid", "email", "profile"],
21
+ jwks_uri: `${origin}/jwks`,
22
+ ...extra,
23
+ };
24
+ }
25
+ // Serves the discovery doc (built from the live origin) at the OIDC well-known path.
26
+ async function serveDiscovery(extra = {}) {
27
+ let origin = "";
28
+ const srv = http.createServer((req, res) => {
29
+ if (req.url !== "/.well-known/openid-configuration") {
30
+ res.writeHead(404).end();
31
+ return;
32
+ }
33
+ res.setHeader("content-type", "application/json");
34
+ res.end(JSON.stringify(doc(origin, extra)));
35
+ });
36
+ await new Promise((resolve) => srv.listen(0, resolve));
37
+ servers.push(srv);
38
+ origin = `http://localhost:${srv.address().port}`;
39
+ return origin;
40
+ }
41
+ describe("customProvider", () => {
42
+ it("builds an OAuthConfig from discovery", async () => {
43
+ const base = await serveDiscovery();
44
+ const config = await customProvider({
45
+ issuer: base,
46
+ audience: "my-api",
47
+ baseUrl: "https://app.example.test",
48
+ scopes: ["openid"],
49
+ });
50
+ expect(config.baseUrl).toBe("https://app.example.test");
51
+ expect(jwks()).toEqual({
52
+ issuer: base,
53
+ audience: "my-api",
54
+ jwksUri: `${base}/jwks`,
55
+ });
56
+ expect(config.scopesSupported).toEqual(["openid"]);
57
+ expect(config.oauthMetadata.registration_endpoint).toBe(`${base}/register`);
58
+ });
59
+ it("ignores a runtime issuer override (keeps the discovered trust anchor)", async () => {
60
+ const base = await serveDiscovery();
61
+ const config = await customProvider({
62
+ issuer: base,
63
+ audience: "a",
64
+ metadataOverrides: { issuer: "https://evil.test" },
65
+ });
66
+ expect(jwks().issuer).toBe(base);
67
+ expect(config.oauthMetadata.issuer).toBe(base);
68
+ });
69
+ it("ignores a runtime jwks_uri override (keeps the discovered signing keys)", async () => {
70
+ const base = await serveDiscovery();
71
+ await customProvider({
72
+ issuer: base,
73
+ audience: "a",
74
+ metadataOverrides: { jwks_uri: "https://evil.test/keys" },
75
+ });
76
+ expect(jwks().jwksUri).toBe(`${base}/jwks`);
77
+ });
78
+ it("serves metadata without a registration_endpoint when the IdP has no DCR", async () => {
79
+ const base = await serveDiscovery({ registration_endpoint: undefined });
80
+ const config = await customProvider({ issuer: base, audience: "a" });
81
+ expect(config.oauthMetadata.registration_endpoint).toBeUndefined();
82
+ expect(jwks().issuer).toBe(base);
83
+ });
84
+ it("throws when discovery has no jwks_uri (token verification needs it)", async () => {
85
+ const base = await serveDiscovery({ jwks_uri: undefined });
86
+ await expect(customProvider({ issuer: base, audience: "a" })).rejects.toThrow(/jwks_uri/);
87
+ });
88
+ it("serverUrl advertises this server as the AS, keeping the IdP as the token issuer", async () => {
89
+ const base = await serveDiscovery();
90
+ const config = await customProvider({
91
+ issuer: base,
92
+ audience: "a",
93
+ serverUrl: "https://app.example.test/",
94
+ scopes: ["openid"],
95
+ });
96
+ // AS metadata + advertised scopes reflect this server.
97
+ expect(config.oauthMetadata.issuer).toBe("https://app.example.test");
98
+ expect(config.oauthMetadata.scopes_supported).toEqual(["openid"]);
99
+ // but the token's issuer is still verified against the IdP.
100
+ expect(jwks().issuer).toBe(base);
101
+ });
102
+ it("authorizationServer supplies the advertised metadata and the verified issuer", async () => {
103
+ const base = await serveDiscovery();
104
+ const as = await serveDiscovery({ scopes_supported: ["checkout"] });
105
+ const config = await customProvider({
106
+ issuer: base,
107
+ audience: "a",
108
+ authorizationServer: `${as}/`,
109
+ });
110
+ expect(config.oauthMetadata.issuer).toBe(as);
111
+ expect(config.oauthMetadata.authorization_endpoint).toBe(`${as}/authorize`);
112
+ expect(config.oauthMetadata.registration_endpoint).toBe(`${as}/register`);
113
+ expect(config.scopesSupported).toEqual(["checkout"]);
114
+ expect(jwks()).toEqual({
115
+ issuer: as,
116
+ audience: "a",
117
+ jwksUri: `${as}/jwks`,
118
+ });
119
+ });
120
+ it("falls back to the issuer's metadata when the authorizationServer is undiscoverable", async () => {
121
+ const base = await serveDiscovery();
122
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => { });
123
+ const config = await customProvider({
124
+ issuer: base,
125
+ audience: "a",
126
+ authorizationServer: `${base}/agentic/P1/MS1`,
127
+ });
128
+ expect(warn).toHaveBeenCalledOnce();
129
+ expect(config.oauthMetadata.issuer).toBe(`${base}/agentic/P1/MS1`);
130
+ expect(config.oauthMetadata.authorization_endpoint).toBe(`${base}/authorize`);
131
+ expect(jwks().issuer).toBe(base);
132
+ warn.mockRestore();
133
+ });
134
+ it("serverUrl takes precedence over authorizationServer", async () => {
135
+ const base = await serveDiscovery();
136
+ const as = await serveDiscovery();
137
+ const config = await customProvider({
138
+ issuer: base,
139
+ audience: "a",
140
+ serverUrl: "https://app.example.test/",
141
+ authorizationServer: as,
142
+ });
143
+ expect(config.oauthMetadata.issuer).toBe("https://app.example.test");
144
+ expect(config.oauthMetadata.token_endpoint).toBe(`${as}/token`);
145
+ expect(jwks().issuer).toBe(as);
146
+ });
147
+ it("applies metadataOverrides over discovered values", async () => {
148
+ const base = await serveDiscovery();
149
+ const config = await customProvider({
150
+ issuer: base,
151
+ audience: "a",
152
+ baseUrl: "https://app.example.test",
153
+ metadataOverrides: { token_endpoint: "https://override/token" },
154
+ });
155
+ expect(config.oauthMetadata.token_endpoint).toBe("https://override/token");
156
+ });
157
+ });
158
+ //# sourceMappingURL=custom.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.test.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/custom.test.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM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:http\";\nimport { afterEach, describe, expect, it, vi } from \"vitest\";\nimport { customProvider } from \"./custom.js\";\nimport { lastJwksConfig as jwks } from \"./verify-spy.js\";\n\nvi.mock(\"../verify.js\", () => import(\"./verify-spy.js\"));\n\nconst servers: http.Server[] = [];\nafterEach(() => {\n for (const srv of servers.splice(0)) {\n srv.close();\n }\n});\n\nfunction doc(origin: string, extra: Record<string, unknown> = {}) {\n return {\n issuer: origin,\n authorization_endpoint: `${origin}/authorize`,\n token_endpoint: `${origin}/token`,\n registration_endpoint: `${origin}/register`,\n response_types_supported: [\"code\"],\n scopes_supported: [\"openid\", \"email\", \"profile\"],\n jwks_uri: `${origin}/jwks`,\n ...extra,\n };\n}\n\n// Serves the discovery doc (built from the live origin) at the OIDC well-known path.\nasync function serveDiscovery(extra: Record<string, unknown> = {}) {\n let origin = \"\";\n const srv = http.createServer((req, res) => {\n if (req.url !== \"/.well-known/openid-configuration\") {\n res.writeHead(404).end();\n return;\n }\n res.setHeader(\"content-type\", \"application/json\");\n res.end(JSON.stringify(doc(origin, extra)));\n });\n await new Promise<void>((resolve) => srv.listen(0, resolve));\n servers.push(srv);\n origin = `http://localhost:${(srv.address() as { port: number }).port}`;\n return origin;\n}\n\ndescribe(\"customProvider\", () => {\n it(\"builds an OAuthConfig from discovery\", async () => {\n const base = await serveDiscovery();\n\n const config = await customProvider({\n issuer: base,\n audience: \"my-api\",\n baseUrl: \"https://app.example.test\",\n scopes: [\"openid\"],\n });\n\n expect(config.baseUrl).toBe(\"https://app.example.test\");\n expect(jwks()).toEqual({\n issuer: base,\n audience: \"my-api\",\n jwksUri: `${base}/jwks`,\n });\n expect(config.scopesSupported).toEqual([\"openid\"]);\n expect(config.oauthMetadata.registration_endpoint).toBe(`${base}/register`);\n });\n\n it(\"ignores a runtime issuer override (keeps the discovered trust anchor)\", async () => {\n const base = await serveDiscovery();\n const config = await customProvider({\n issuer: base,\n audience: \"a\",\n metadataOverrides: { issuer: \"https://evil.test\" } as never,\n });\n expect(jwks().issuer).toBe(base);\n expect(config.oauthMetadata.issuer).toBe(base);\n });\n\n it(\"ignores a runtime jwks_uri override (keeps the discovered signing keys)\", async () => {\n const base = await serveDiscovery();\n await customProvider({\n issuer: base,\n audience: \"a\",\n metadataOverrides: { jwks_uri: \"https://evil.test/keys\" } as never,\n });\n expect(jwks().jwksUri).toBe(`${base}/jwks`);\n });\n\n it(\"serves metadata without a registration_endpoint when the IdP has no DCR\", async () => {\n const base = await serveDiscovery({ registration_endpoint: undefined });\n const config = await customProvider({ issuer: base, audience: \"a\" });\n expect(config.oauthMetadata.registration_endpoint).toBeUndefined();\n expect(jwks().issuer).toBe(base);\n });\n\n it(\"throws when discovery has no jwks_uri (token verification needs it)\", async () => {\n const base = await serveDiscovery({ jwks_uri: undefined });\n await expect(\n customProvider({ issuer: base, audience: \"a\" }),\n ).rejects.toThrow(/jwks_uri/);\n });\n\n it(\"serverUrl advertises this server as the AS, keeping the IdP as the token issuer\", async () => {\n const base = await serveDiscovery();\n const config = await customProvider({\n issuer: base,\n audience: \"a\",\n serverUrl: \"https://app.example.test/\",\n scopes: [\"openid\"],\n });\n // AS metadata + advertised scopes reflect this server.\n expect(config.oauthMetadata.issuer).toBe(\"https://app.example.test\");\n expect(config.oauthMetadata.scopes_supported).toEqual([\"openid\"]);\n // but the token's issuer is still verified against the IdP.\n expect(jwks().issuer).toBe(base);\n });\n\n it(\"authorizationServer supplies the advertised metadata and the verified issuer\", async () => {\n const base = await serveDiscovery();\n const as = await serveDiscovery({ scopes_supported: [\"checkout\"] });\n\n const config = await customProvider({\n issuer: base,\n audience: \"a\",\n authorizationServer: `${as}/`,\n });\n\n expect(config.oauthMetadata.issuer).toBe(as);\n expect(config.oauthMetadata.authorization_endpoint).toBe(`${as}/authorize`);\n expect(config.oauthMetadata.registration_endpoint).toBe(`${as}/register`);\n expect(config.scopesSupported).toEqual([\"checkout\"]);\n expect(jwks()).toEqual({\n issuer: as,\n audience: \"a\",\n jwksUri: `${as}/jwks`,\n });\n });\n\n it(\"falls back to the issuer's metadata when the authorizationServer is undiscoverable\", async () => {\n const base = await serveDiscovery();\n const warn = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const config = await customProvider({\n issuer: base,\n audience: \"a\",\n authorizationServer: `${base}/agentic/P1/MS1`,\n });\n\n expect(warn).toHaveBeenCalledOnce();\n expect(config.oauthMetadata.issuer).toBe(`${base}/agentic/P1/MS1`);\n expect(config.oauthMetadata.authorization_endpoint).toBe(\n `${base}/authorize`,\n );\n expect(jwks().issuer).toBe(base);\n warn.mockRestore();\n });\n\n it(\"serverUrl takes precedence over authorizationServer\", async () => {\n const base = await serveDiscovery();\n const as = await serveDiscovery();\n const config = await customProvider({\n issuer: base,\n audience: \"a\",\n serverUrl: \"https://app.example.test/\",\n authorizationServer: as,\n });\n expect(config.oauthMetadata.issuer).toBe(\"https://app.example.test\");\n expect(config.oauthMetadata.token_endpoint).toBe(`${as}/token`);\n expect(jwks().issuer).toBe(as);\n });\n\n it(\"applies metadataOverrides over discovered values\", async () => {\n const base = await serveDiscovery();\n const config = await customProvider({\n issuer: base,\n audience: \"a\",\n baseUrl: \"https://app.example.test\",\n metadataOverrides: { token_endpoint: \"https://override/token\" },\n });\n expect(config.oauthMetadata.token_endpoint).toBe(\"https://override/token\");\n });\n});\n"]}
@@ -0,0 +1,44 @@
1
+ import type { ExtraClaims } from "../../auth.js";
2
+ import type { OAuthConfig } from "../index.js";
3
+ import type { RegisteredClaims } from "../verify.js";
4
+ import { type CustomProviderOptions } from "./custom.js";
5
+ /**
6
+ * Claims a Descope session JWT carries. Roles and permissions are nested per
7
+ * tenant when the project uses tenants, and flat otherwise. `email` arrives only
8
+ * through a Custom Claims flow action or a JWT template.
9
+ *
10
+ * @see https://docs.descope.com/authorization/session-management
11
+ * @see https://docs.descope.com/management/token/jwt-templates
12
+ */
13
+ export type DescopeClaims = {
14
+ /** Authentication methods used, e.g. `["otp"]`. */
15
+ amr?: string[];
16
+ /** Descope Resource Name: where the token is stored. */
17
+ drn?: string;
18
+ /** The user's active tenant. */
19
+ dct?: string;
20
+ /** Associated tenants, keyed by tenant id. */
21
+ tenants?: Record<string, {
22
+ roles?: string[];
23
+ permissions?: string[];
24
+ }>;
25
+ /** Roles, when the project has no tenants. */
26
+ roles?: string[];
27
+ /** Permissions, when the project has no tenants. */
28
+ permissions?: string[];
29
+ /** Only via a Custom Claims action or JWT template; not a default claim. */
30
+ email?: string;
31
+ };
32
+ /**
33
+ * OAuth provider for a Descope MCP Server. `url` is the MCP Server's **Discovery
34
+ * URL** (a.k.a. Issuer) from the console's Connection Information, e.g.
35
+ * `https://api.descope.com/v1/apps/agentic/<projectId>/<mcpServerId>` (or your
36
+ * custom domain). Requires DCR enabled on the MCP Server. For Descope with DCR
37
+ * disabled and Alpic's DCR proxy, use {@link customProvider} with `serverUrl`
38
+ * instead (see `examples/auth-descope-alpic`). The token `audience` defaults to
39
+ * the **Project ID** derived from the URL — Descope binds `aud` to [DCR client
40
+ * id, project id], not the server URL; pass `audience` to override.
41
+ */
42
+ export declare function descopeProvider<TCustom extends ExtraClaims = Record<never, never>>(opts: {
43
+ url: string;
44
+ } & Omit<CustomProviderOptions, "issuer">): Promise<OAuthConfig<DescopeClaims & TCustom & RegisteredClaims>>;
@@ -0,0 +1,44 @@
1
+ import { customProvider } from "./custom.js";
2
+ /**
3
+ * Turns the console's Discovery URL into the authorization server's base URL:
4
+ * drops a `/.well-known/openid-configuration` (or `oauth-authorization-server`)
5
+ * suffix, since discovery appends that path itself, and any trailing slash.
6
+ */
7
+ function toAuthorizationServerUrl(discoveryUrl) {
8
+ return discoveryUrl.replace(/\/\.well-known\/[^?#]*$/, "").replace(/\/$/, "");
9
+ }
10
+ /**
11
+ * Derives the Descope Project ID from an MCP Server URL
12
+ * (`…/agentic/<projectId>/<mcpServerId>`). Descope binds the token `aud` to the
13
+ * project id, so it doubles as the audience.
14
+ */
15
+ function projectIdFromUrl(url) {
16
+ const projectId = url.match(/\/agentic\/([^/]+)\/[^/]+/)?.[1];
17
+ if (!projectId) {
18
+ throw new Error(`Could not derive the Descope project id from "${url}"; pass an explicit \`audience\`.`);
19
+ }
20
+ return projectId;
21
+ }
22
+ /**
23
+ * OAuth provider for a Descope MCP Server. `url` is the MCP Server's **Discovery
24
+ * URL** (a.k.a. Issuer) from the console's Connection Information, e.g.
25
+ * `https://api.descope.com/v1/apps/agentic/<projectId>/<mcpServerId>` (or your
26
+ * custom domain). Requires DCR enabled on the MCP Server. For Descope with DCR
27
+ * disabled and Alpic's DCR proxy, use {@link customProvider} with `serverUrl`
28
+ * instead (see `examples/auth-descope-alpic`). The token `audience` defaults to
29
+ * the **Project ID** derived from the URL — Descope binds `aud` to [DCR client
30
+ * id, project id], not the server URL; pass `audience` to override.
31
+ */
32
+ export function descopeProvider(opts) {
33
+ const { url, audience, ...rest } = opts;
34
+ const asUrl = toAuthorizationServerUrl(url);
35
+ const projectId = projectIdFromUrl(asUrl);
36
+ const issuer = `${asUrl.slice(0, asUrl.indexOf("/agentic/"))}/${projectId}`;
37
+ return customProvider({
38
+ issuer,
39
+ audience: audience ?? projectId,
40
+ authorizationServer: asUrl,
41
+ ...rest,
42
+ });
43
+ }
44
+ //# sourceMappingURL=descope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descope.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/descope.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,cAAc,EAAE,MAAM,aAAa,CAAC;AA2BzE;;;;GAIG;AACH,SAAS,wBAAwB,CAAC,YAAoB;IACpD,OAAO,YAAY,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,iDAAiD,GAAG,mCAAmC,CACxF,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAG7B,IAA6D;IAE7D,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACxC,MAAM,KAAK,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;IAC5E,OAAO,cAAc,CAA0B;QAC7C,MAAM;QACN,QAAQ,EAAE,QAAQ,IAAI,SAAS;QAC/B,mBAAmB,EAAE,KAAK;QAC1B,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ExtraClaims } from \"../../auth.js\";\nimport type { OAuthConfig } from \"../index.js\";\nimport type { RegisteredClaims } from \"../verify.js\";\nimport { type CustomProviderOptions, customProvider } from \"./custom.js\";\n\n/**\n * Claims a Descope session JWT carries. Roles and permissions are nested per\n * tenant when the project uses tenants, and flat otherwise. `email` arrives only\n * through a Custom Claims flow action or a JWT template.\n *\n * @see https://docs.descope.com/authorization/session-management\n * @see https://docs.descope.com/management/token/jwt-templates\n */\nexport type DescopeClaims = {\n /** Authentication methods used, e.g. `[\"otp\"]`. */\n amr?: string[];\n /** Descope Resource Name: where the token is stored. */\n drn?: string;\n /** The user's active tenant. */\n dct?: string;\n /** Associated tenants, keyed by tenant id. */\n tenants?: Record<string, { roles?: string[]; permissions?: string[] }>;\n /** Roles, when the project has no tenants. */\n roles?: string[];\n /** Permissions, when the project has no tenants. */\n permissions?: string[];\n /** Only via a Custom Claims action or JWT template; not a default claim. */\n email?: string;\n};\n\n/**\n * Turns the console's Discovery URL into the authorization server's base URL:\n * drops a `/.well-known/openid-configuration` (or `oauth-authorization-server`)\n * suffix, since discovery appends that path itself, and any trailing slash.\n */\nfunction toAuthorizationServerUrl(discoveryUrl: string): string {\n return discoveryUrl.replace(/\\/\\.well-known\\/[^?#]*$/, \"\").replace(/\\/$/, \"\");\n}\n\n/**\n * Derives the Descope Project ID from an MCP Server URL\n * (`…/agentic/<projectId>/<mcpServerId>`). Descope binds the token `aud` to the\n * project id, so it doubles as the audience.\n */\nfunction projectIdFromUrl(url: string): string {\n const projectId = url.match(/\\/agentic\\/([^/]+)\\/[^/]+/)?.[1];\n if (!projectId) {\n throw new Error(\n `Could not derive the Descope project id from \"${url}\"; pass an explicit \\`audience\\`.`,\n );\n }\n return projectId;\n}\n\n/**\n * OAuth provider for a Descope MCP Server. `url` is the MCP Server's **Discovery\n * URL** (a.k.a. Issuer) from the console's Connection Information, e.g.\n * `https://api.descope.com/v1/apps/agentic/<projectId>/<mcpServerId>` (or your\n * custom domain). Requires DCR enabled on the MCP Server. For Descope with DCR\n * disabled and Alpic's DCR proxy, use {@link customProvider} with `serverUrl`\n * instead (see `examples/auth-descope-alpic`). The token `audience` defaults to\n * the **Project ID** derived from the URL — Descope binds `aud` to [DCR client\n * id, project id], not the server URL; pass `audience` to override.\n */\nexport function descopeProvider<\n TCustom extends ExtraClaims = Record<never, never>,\n>(\n opts: { url: string } & Omit<CustomProviderOptions, \"issuer\">,\n): Promise<OAuthConfig<DescopeClaims & TCustom & RegisteredClaims>> {\n const { url, audience, ...rest } = opts;\n const asUrl = toAuthorizationServerUrl(url);\n const projectId = projectIdFromUrl(asUrl);\n const issuer = `${asUrl.slice(0, asUrl.indexOf(\"/agentic/\"))}/${projectId}`;\n return customProvider<DescopeClaims & TCustom>({\n issuer,\n audience: audience ?? projectId,\n authorizationServer: asUrl,\n ...rest,\n });\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ // @vitest-environment node
2
+ import { afterEach, describe, expect, it, vi } from "vitest";
3
+ import { descopeProvider } from "./descope.js";
4
+ import { lastJwksConfig as jwks } from "./verify-spy.js";
5
+ vi.mock("../verify.js", () => import("./verify-spy.js"));
6
+ afterEach(() => vi.restoreAllMocks());
7
+ function discoveryDoc(issuer, scopes) {
8
+ return {
9
+ issuer,
10
+ authorization_endpoint: `${issuer}/authorize`,
11
+ token_endpoint: `${issuer}/token`,
12
+ registration_endpoint: `${issuer}/register`,
13
+ response_types_supported: ["code"],
14
+ scopes_supported: scopes,
15
+ jwks_uri: `${issuer}/.well-known/jwks.json`,
16
+ };
17
+ }
18
+ const PROJECT = "https://api.descope.com/v1/apps/P123";
19
+ const AGENTIC = "https://api.descope.com/v1/apps/agentic/P123/MS456";
20
+ function mockDiscovery(docs) {
21
+ return vi
22
+ .spyOn(globalThis, "fetch")
23
+ .mockImplementation(async (input) => {
24
+ const url = String(input);
25
+ const entry = Object.entries(docs).find(([issuer]) => url === `${issuer}/.well-known/openid-configuration`);
26
+ if (entry === undefined) {
27
+ return new Response(null, { status: 404 });
28
+ }
29
+ return new Response(JSON.stringify(discoveryDoc(...entry)), {
30
+ headers: { "content-type": "application/json" },
31
+ });
32
+ });
33
+ }
34
+ describe("descopeProvider", () => {
35
+ it("verifies against the agentic issuer it advertises", async () => {
36
+ const fetchSpy = mockDiscovery({
37
+ [PROJECT]: ["openid", "profile", "email", "phone"],
38
+ [AGENTIC]: ["checkout"],
39
+ });
40
+ const config = await descopeProvider({ url: AGENTIC });
41
+ expect(fetchSpy).toHaveBeenCalledWith(`${PROJECT}/.well-known/openid-configuration`, expect.anything());
42
+ expect(jwks().issuer).toBe(AGENTIC);
43
+ expect(jwks().audience).toBe("P123");
44
+ expect(config.oauthMetadata.issuer).toBe(AGENTIC);
45
+ expect(config.oauthMetadata.registration_endpoint).toBe(`${AGENTIC}/register`);
46
+ expect(config.scopesSupported).toEqual(["checkout"]);
47
+ });
48
+ it("accepts a URL carrying the well-known suffix", async () => {
49
+ mockDiscovery({ [PROJECT]: ["openid"], [AGENTIC]: ["checkout"] });
50
+ const config = await descopeProvider({
51
+ url: `${AGENTIC}/.well-known/openid-configuration`,
52
+ });
53
+ expect(config.oauthMetadata.issuer).toBe(AGENTIC);
54
+ expect(config.scopesSupported).toEqual(["checkout"]);
55
+ });
56
+ it("lets an explicit audience override the derived project id", async () => {
57
+ mockDiscovery({ [PROJECT]: ["openid"], [AGENTIC]: ["checkout"] });
58
+ await descopeProvider({ url: AGENTIC, audience: "custom" });
59
+ expect(jwks().audience).toBe("custom");
60
+ });
61
+ });
62
+ //# sourceMappingURL=descope.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descope.test.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/descope.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,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEzD,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAEzD,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;AAEtC,SAAS,YAAY,CAAC,MAAc,EAAE,MAAgB;IACpD,OAAO;QACL,MAAM;QACN,sBAAsB,EAAE,GAAG,MAAM,YAAY;QAC7C,cAAc,EAAE,GAAG,MAAM,QAAQ;QACjC,qBAAqB,EAAE,GAAG,MAAM,WAAW;QAC3C,wBAAwB,EAAE,CAAC,MAAM,CAAC;QAClC,gBAAgB,EAAE,MAAM;QACxB,QAAQ,EAAE,GAAG,MAAM,wBAAwB;KAC5C,CAAC;AACJ,CA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AO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE5D,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @vitest-environment node\nimport { afterEach, describe, expect, it, vi } from \"vitest\";\nimport { descopeProvider } from \"./descope.js\";\nimport { lastJwksConfig as jwks } from \"./verify-spy.js\";\n\nvi.mock(\"../verify.js\", () => import(\"./verify-spy.js\"));\n\nafterEach(() => vi.restoreAllMocks());\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\nconst PROJECT = \"https://api.descope.com/v1/apps/P123\";\nconst AGENTIC = \"https://api.descope.com/v1/apps/agentic/P123/MS456\";\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(\"descopeProvider\", () => {\n it(\"verifies against the agentic issuer it advertises\", async () => {\n const fetchSpy = mockDiscovery({\n [PROJECT]: [\"openid\", \"profile\", \"email\", \"phone\"],\n [AGENTIC]: [\"checkout\"],\n });\n\n const config = await descopeProvider({ url: AGENTIC });\n\n expect(fetchSpy).toHaveBeenCalledWith(\n `${PROJECT}/.well-known/openid-configuration`,\n expect.anything(),\n );\n expect(jwks().issuer).toBe(AGENTIC);\n expect(jwks().audience).toBe(\"P123\");\n expect(config.oauthMetadata.issuer).toBe(AGENTIC);\n expect(config.oauthMetadata.registration_endpoint).toBe(\n `${AGENTIC}/register`,\n );\n expect(config.scopesSupported).toEqual([\"checkout\"]);\n });\n\n it(\"accepts a URL carrying the well-known suffix\", async () => {\n mockDiscovery({ [PROJECT]: [\"openid\"], [AGENTIC]: [\"checkout\"] });\n\n const config = await descopeProvider({\n url: `${AGENTIC}/.well-known/openid-configuration`,\n });\n\n expect(config.oauthMetadata.issuer).toBe(AGENTIC);\n expect(config.scopesSupported).toEqual([\"checkout\"]);\n });\n\n it(\"lets an explicit audience override the derived project id\", async () => {\n mockDiscovery({ [PROJECT]: [\"openid\"], [AGENTIC]: [\"checkout\"] });\n\n await descopeProvider({ url: AGENTIC, audience: \"custom\" });\n\n expect(jwks().audience).toBe(\"custom\");\n });\n});\n"]}
@@ -0,0 +1,2 @@
1
+ /** Normalises a bare host to an https issuer URL and strips a trailing slash. */
2
+ export declare function toIssuerUrl(domain: string): string;
@@ -0,0 +1,6 @@
1
+ /** Normalises a bare host to an https issuer URL and strips a trailing slash. */
2
+ export function toIssuerUrl(domain) {
3
+ const withScheme = /^https?:\/\//.test(domain) ? domain : `https://${domain}`;
4
+ return withScheme.replace(/\/$/, "");
5
+ }
6
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/shared.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,MAAM,EAAE,CAAC;IAC9E,OAAO,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC","sourcesContent":["/** Normalises a bare host to an https issuer URL and strips a trailing slash. */\nexport function toIssuerUrl(domain: string): string {\n const withScheme = /^https?:\\/\\//.test(domain) ? domain : `https://${domain}`;\n return withScheme.replace(/\\/$/, \"\");\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { toIssuerUrl } from "./shared.js";
3
+ describe("toIssuerUrl", () => {
4
+ it("adds https to a bare host, preserves an explicit scheme, strips a trailing slash", () => {
5
+ expect(toIssuerUrl("acme.authkit.app")).toBe("https://acme.authkit.app");
6
+ expect(toIssuerUrl("https://acme.authkit.app/")).toBe("https://acme.authkit.app");
7
+ expect(toIssuerUrl("http://localhost:3000")).toBe("http://localhost:3000");
8
+ });
9
+ });
10
+ //# sourceMappingURL=shared.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.test.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/shared.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,kFAAkF,EAAE,GAAG,EAAE;QAC1F,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACzE,MAAM,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAC,CAAC,IAAI,CACnD,0BAA0B,CAC3B,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { toIssuerUrl } from \"./shared.js\";\n\ndescribe(\"toIssuerUrl\", () => {\n it(\"adds https to a bare host, preserves an explicit scheme, strips a trailing slash\", () => {\n expect(toIssuerUrl(\"acme.authkit.app\")).toBe(\"https://acme.authkit.app\");\n expect(toIssuerUrl(\"https://acme.authkit.app/\")).toBe(\n \"https://acme.authkit.app\",\n );\n expect(toIssuerUrl(\"http://localhost:3000\")).toBe(\"http://localhost:3000\");\n });\n});\n"]}
@@ -0,0 +1,25 @@
1
+ import type { ExtraClaims } from "../../auth.js";
2
+ import type { OAuthConfig } from "../index.js";
3
+ import type { RegisteredClaims } from "../verify.js";
4
+ import { type CustomProviderOptions } from "./custom.js";
5
+ /**
6
+ * Claims a Stytch Connected Apps access token carries. Beyond the subject,
7
+ * everything is project-configured through the client's access-token template.
8
+ *
9
+ * @see https://stytch.com/docs/api-reference/consumer/api/connected-apps/tokens/connected-app-access-token-object
10
+ * @see https://stytch.com/docs/api/connected-apps-create
11
+ */
12
+ export type StytchClaims = {
13
+ /** Only when the client's access-token template adds it. */
14
+ email?: string;
15
+ };
16
+ /**
17
+ * OAuth provider for Stytch Connected Apps. `domain` is the project domain,
18
+ * e.g. `acme.customers.stytch.dev`, or a configured custom domain. Requires
19
+ * DCR enabled in the Stytch dashboard. `audience` is the Stytch Project ID
20
+ * (the default token audience).
21
+ */
22
+ export declare function stytchProvider<TCustom extends ExtraClaims = Record<never, never>>(opts: {
23
+ domain: string;
24
+ audience: string;
25
+ } & Omit<CustomProviderOptions, "issuer" | "audience">): Promise<OAuthConfig<StytchClaims & TCustom & RegisteredClaims>>;
@@ -0,0 +1,16 @@
1
+ import { customProvider } from "./custom.js";
2
+ import { toIssuerUrl } from "./shared.js";
3
+ /**
4
+ * OAuth provider for Stytch Connected Apps. `domain` is the project domain,
5
+ * e.g. `acme.customers.stytch.dev`, or a configured custom domain. Requires
6
+ * DCR enabled in the Stytch dashboard. `audience` is the Stytch Project ID
7
+ * (the default token audience).
8
+ */
9
+ export function stytchProvider(opts) {
10
+ const { domain, ...rest } = opts;
11
+ return customProvider({
12
+ issuer: toIssuerUrl(domain),
13
+ ...rest,
14
+ });
15
+ }
16
+ //# sourceMappingURL=stytch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stytch.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/stytch.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,cAAc,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc1C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAG5B,IAGC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACjC,OAAO,cAAc,CAAyB;QAC5C,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;QAC3B,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ExtraClaims } from \"../../auth.js\";\nimport type { OAuthConfig } from \"../index.js\";\nimport type { RegisteredClaims } from \"../verify.js\";\nimport { type CustomProviderOptions, customProvider } from \"./custom.js\";\nimport { toIssuerUrl } from \"./shared.js\";\n\n/**\n * Claims a Stytch Connected Apps access token carries. Beyond the subject,\n * everything is project-configured through the client's access-token template.\n *\n * @see https://stytch.com/docs/api-reference/consumer/api/connected-apps/tokens/connected-app-access-token-object\n * @see https://stytch.com/docs/api/connected-apps-create\n */\nexport type StytchClaims = {\n /** Only when the client's access-token template adds it. */\n email?: string;\n};\n\n/**\n * OAuth provider for Stytch Connected Apps. `domain` is the project domain,\n * e.g. `acme.customers.stytch.dev`, or a configured custom domain. Requires\n * DCR enabled in the Stytch dashboard. `audience` is the Stytch Project ID\n * (the default token audience).\n */\nexport function stytchProvider<\n TCustom extends ExtraClaims = Record<never, never>,\n>(\n opts: { domain: string; audience: string } & Omit<\n CustomProviderOptions,\n \"issuer\" | \"audience\"\n >,\n): Promise<OAuthConfig<StytchClaims & TCustom & RegisteredClaims>> {\n const { domain, ...rest } = opts;\n return customProvider<StytchClaims & TCustom>({\n issuer: toIssuerUrl(domain),\n ...rest,\n });\n}\n"]}
@@ -0,0 +1,12 @@
1
+ export declare const createJwksVerifier: import("vitest").Mock<typeof import("../verify.js").createJwksVerifier>;
2
+ /**
3
+ * The JWKS parameters a provider handed to `createJwksVerifier`: the issuer and
4
+ * JWKS URL it derived from discovery, and the audience it expects. Substitute
5
+ * this module for `../verify.js` to assert on them:
6
+ *
7
+ * ```ts
8
+ * vi.mock("../verify.js", () => import("./verify-spy.js"));
9
+ * import { lastJwksConfig as jwks } from "./verify-spy.js";
10
+ * ```
11
+ */
12
+ export declare const lastJwksConfig: () => import("../verify.js").JwksVerifyConfig;
@@ -0,0 +1,21 @@
1
+ import { vi } from "vitest";
2
+ const actual = await vi.importActual("../verify.js");
3
+ export const createJwksVerifier = vi.fn(actual.createJwksVerifier);
4
+ /**
5
+ * The JWKS parameters a provider handed to `createJwksVerifier`: the issuer and
6
+ * JWKS URL it derived from discovery, and the audience it expects. Substitute
7
+ * this module for `../verify.js` to assert on them:
8
+ *
9
+ * ```ts
10
+ * vi.mock("../verify.js", () => import("./verify-spy.js"));
11
+ * import { lastJwksConfig as jwks } from "./verify-spy.js";
12
+ * ```
13
+ */
14
+ export const lastJwksConfig = () => {
15
+ const call = createJwksVerifier.mock.lastCall;
16
+ if (!call) {
17
+ throw new Error("createJwksVerifier was not called");
18
+ }
19
+ return call[0];
20
+ };
21
+ //# sourceMappingURL=verify-spy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-spy.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/verify-spy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,MAAM,MAAM,GACV,MAAM,EAAE,CAAC,YAAY,CAAgC,cAAc,CAAC,CAAC;AAEvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import { vi } from \"vitest\";\n\nconst actual =\n await vi.importActual<typeof import(\"../verify.js\")>(\"../verify.js\");\n\nexport const createJwksVerifier = vi.fn(actual.createJwksVerifier);\n\n/**\n * The JWKS parameters a provider handed to `createJwksVerifier`: the issuer and\n * JWKS URL it derived from discovery, and the audience it expects. Substitute\n * this module for `../verify.js` to assert on them:\n *\n * ```ts\n * vi.mock(\"../verify.js\", () => import(\"./verify-spy.js\"));\n * import { lastJwksConfig as jwks } from \"./verify-spy.js\";\n * ```\n */\nexport const lastJwksConfig = () => {\n const call = createJwksVerifier.mock.lastCall;\n if (!call) {\n throw new Error(\"createJwksVerifier was not called\");\n }\n return call[0];\n};\n"]}
@@ -0,0 +1,33 @@
1
+ import type { ExtraClaims } from "../../auth.js";
2
+ import type { OAuthConfig } from "../index.js";
3
+ import type { RegisteredClaims } from "../verify.js";
4
+ import { type CustomProviderOptions } from "./custom.js";
5
+ /**
6
+ * Claims a WorkOS AuthKit access token carries. All optional: `org_id`, `role`
7
+ * and `permissions` appear only when an organization is selected at sign-in, and
8
+ * `email` only when a JWT template adds it.
9
+ *
10
+ * @see https://workos.com/docs/authkit/sessions/integrating-sessions/access-token
11
+ * @see https://workos.com/docs/authkit/jwt-templates
12
+ */
13
+ export type WorkosClaims = {
14
+ /** Session id, used for signing out. */
15
+ sid?: string;
16
+ /** Organization selected at sign-in. */
17
+ org_id?: string;
18
+ /** Role of the selected organization membership. */
19
+ role?: string;
20
+ /** Permissions assigned to the role. */
21
+ permissions?: string[];
22
+ /** Only when a JWT template adds it; not a default AuthKit claim. */
23
+ email?: string;
24
+ };
25
+ /**
26
+ * OAuth provider for WorkOS AuthKit. `domain` is the AuthKit domain, e.g.
27
+ * `acme.authkit.app`. Requires DCR enabled in the WorkOS dashboard
28
+ * (Connect → Configuration). `audience` is the MCP server's Resource Indicator.
29
+ */
30
+ export declare function workosProvider<TCustom extends ExtraClaims = Record<never, never>>(opts: {
31
+ domain: string;
32
+ audience: string;
33
+ } & Omit<CustomProviderOptions, "issuer" | "audience">): Promise<OAuthConfig<WorkosClaims & TCustom & RegisteredClaims>>;
@@ -0,0 +1,15 @@
1
+ import { customProvider } from "./custom.js";
2
+ import { toIssuerUrl } from "./shared.js";
3
+ /**
4
+ * OAuth provider for WorkOS AuthKit. `domain` is the AuthKit domain, e.g.
5
+ * `acme.authkit.app`. Requires DCR enabled in the WorkOS dashboard
6
+ * (Connect → Configuration). `audience` is the MCP server's Resource Indicator.
7
+ */
8
+ export function workosProvider(opts) {
9
+ const { domain, ...rest } = opts;
10
+ return customProvider({
11
+ issuer: toIssuerUrl(domain),
12
+ ...rest,
13
+ });
14
+ }
15
+ //# sourceMappingURL=workos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workos.js","sourceRoot":"","sources":["../../../../src/server/auth/providers/workos.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,cAAc,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAuB1C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAG5B,IAGC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACjC,OAAO,cAAc,CAAyB;QAC5C,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;QAC3B,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ExtraClaims } from \"../../auth.js\";\nimport type { OAuthConfig } from \"../index.js\";\nimport type { RegisteredClaims } from \"../verify.js\";\nimport { type CustomProviderOptions, customProvider } from \"./custom.js\";\nimport { toIssuerUrl } from \"./shared.js\";\n\n/**\n * Claims a WorkOS AuthKit access token carries. All optional: `org_id`, `role`\n * and `permissions` appear only when an organization is selected at sign-in, and\n * `email` only when a JWT template adds it.\n *\n * @see https://workos.com/docs/authkit/sessions/integrating-sessions/access-token\n * @see https://workos.com/docs/authkit/jwt-templates\n */\nexport type WorkosClaims = {\n /** Session id, used for signing out. */\n sid?: string;\n /** Organization selected at sign-in. */\n org_id?: string;\n /** Role of the selected organization membership. */\n role?: string;\n /** Permissions assigned to the role. */\n permissions?: string[];\n /** Only when a JWT template adds it; not a default AuthKit claim. */\n email?: string;\n};\n\n/**\n * OAuth provider for WorkOS AuthKit. `domain` is the AuthKit domain, e.g.\n * `acme.authkit.app`. Requires DCR enabled in the WorkOS dashboard\n * (Connect → Configuration). `audience` is the MCP server's Resource Indicator.\n */\nexport function workosProvider<\n TCustom extends ExtraClaims = Record<never, never>,\n>(\n opts: { domain: string; audience: string } & Omit<\n CustomProviderOptions,\n \"issuer\" | \"audience\"\n >,\n): Promise<OAuthConfig<WorkosClaims & TCustom & RegisteredClaims>> {\n const { domain, ...rest } = opts;\n return customProvider<WorkosClaims & TCustom>({\n issuer: toIssuerUrl(domain),\n ...rest,\n });\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { AuthInfo } from "../auth.js";
2
+ import type { SecurityScheme, ToolAuth } from "../server.js";
3
+ export declare function authToSecuritySchemes(auth: ToolAuth): SecurityScheme[];
4
+ export declare function securitySchemesAllowAnonymous(schemes: SecurityScheme[] | undefined): boolean;
5
+ export type SchemeFailure = {
6
+ error: "invalid_token" | "insufficient_scope";
7
+ description: string;
8
+ scopes: string[];
9
+ };
10
+ export declare function evaluateSecuritySchemes(schemes: SecurityScheme[] | undefined, authInfo: AuthInfo | undefined): SchemeFailure | undefined;
11
+ export declare function httpStatusForFailure(failure: SchemeFailure): 401 | 403;
12
+ export declare function clientPrefersInBandChallenge(userAgent: string | undefined): boolean;
13
+ export declare function wwwAuthenticateHeader(failure: SchemeFailure, resourceMetadataUrl?: string): string;
14
+ export declare function inBandChallengeResult(failure: SchemeFailure, resourceMetadataUrl?: string): {
15
+ isError: boolean;
16
+ content: {
17
+ type: "text";
18
+ text: string;
19
+ }[];
20
+ _meta: {
21
+ "mcp/www_authenticate": string[];
22
+ };
23
+ };