@polaris-auth/client 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polaris-auth/client",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "description": "Typed TypeScript client for Polaris for PHP, generated from the route manifest",
5
5
  "keywords": [
6
6
  "polaris",
@@ -35,7 +35,11 @@
35
35
  "dpop",
36
36
  "device-flow",
37
37
  "ciba",
38
- "token-exchange"
38
+ "token-exchange",
39
+ "mcp",
40
+ "model-context-protocol",
41
+ "ai-agents",
42
+ "agent-auth"
39
43
  ],
40
44
  "homepage": "https://github.com/univeros/polaris-core/tree/main/packages/client-ts#readme",
41
45
  "bugs": "https://github.com/univeros/polaris-core/issues",
package/src/agents.ts ADDED
@@ -0,0 +1,58 @@
1
+ /* Generated by scripts/generate-namespaces.mjs from openapi.json; do not edit. */
2
+ import type { Client } from "openapi-fetch";
3
+ import type { paths } from "./schema.js";
4
+ import type { Init } from "./namespace.js";
5
+
6
+ /** The `agents` plugin's routes as methods of `client.agents`. */
7
+ export function agents(client: Client<paths>) {
8
+ return {
9
+ /** GET /admin/agents: List every agent */
10
+ adminListAgents: (...init: Init<"/admin/agents", "get">) => client.GET("/admin/agents", ...init),
11
+ /** POST /admin/agents/{id}/revoke: Revoke an agent as an operator */
12
+ adminRevokeAgent: (...init: Init<"/admin/agents/{id}/revoke", "post">) => client.POST("/admin/agents/{id}/revoke", ...init),
13
+ /** GET /agents/capabilities: List the capabilities */
14
+ capabilities: (...init: Init<"/agents/capabilities", "get">) => client.GET("/agents/capabilities", ...init),
15
+ /** GET /.well-known/agent-configuration: Agent protocol discovery */
16
+ configuration: (...init: Init<"/.well-known/agent-configuration", "get">) => client.GET("/.well-known/agent-configuration", ...init),
17
+ /** POST /agents/hosts: Create a host */
18
+ createHost: (...init: Init<"/agents/hosts", "post">) => client.POST("/agents/hosts", ...init),
19
+ /** POST /agents/approvals/{id}/decide: Approve or deny a grant request */
20
+ decideApproval: (...init: Init<"/agents/approvals/{id}/decide", "post">) => client.POST("/agents/approvals/{id}/decide", ...init),
21
+ /** DELETE /agents/grants/{id}: Revoke a grant */
22
+ deleteGrant: (...init: Init<"/agents/grants/{id}", "delete">) => client.DELETE("/agents/grants/{id}", ...init),
23
+ /** DELETE /agents/hosts/{id}: Revoke a host */
24
+ deleteHost: (...init: Init<"/agents/hosts/{id}", "delete">) => client.DELETE("/agents/hosts/{id}", ...init),
25
+ /** POST /agents/enroll: Enrol an agent through a host */
26
+ enroll: (...init: Init<"/agents/enroll", "post">) => client.POST("/agents/enroll", ...init),
27
+ /** POST /agents/execute: Execute a capability */
28
+ execute: (...init: Init<"/agents/execute", "post">) => client.POST("/agents/execute", ...init),
29
+ /** GET /agents: List my agents */
30
+ listAgents: (...init: Init<"/agents", "get">) => client.GET("/agents", ...init),
31
+ /** GET /agents/approvals: List pending approvals */
32
+ listApprovals: (...init: Init<"/agents/approvals", "get">) => client.GET("/agents/approvals", ...init),
33
+ /** GET /agents/hosts: List my hosts */
34
+ listHosts: (...init: Init<"/agents/hosts", "get">) => client.GET("/agents/hosts", ...init),
35
+ /** GET /agents/{id}/receipts: List an agent's receipts */
36
+ listReceipts: (...init: Init<"/agents/{id}/receipts", "get">) => client.GET("/agents/{id}/receipts", ...init),
37
+ /** GET /agents/approvals/code: Read the approval behind a user code */
38
+ readApproval: (...init: Init<"/agents/approvals/code", "get">) => client.GET("/agents/approvals/code", ...init),
39
+ /** POST /agents/register: Register an agent */
40
+ register: (...init: Init<"/agents/register", "post">) => client.POST("/agents/register", ...init),
41
+ /** POST /agents/grants/request: Request capability grants */
42
+ requestGrants: (...init: Init<"/agents/grants/request", "post">) => client.POST("/agents/grants/request", ...init),
43
+ /** POST /agents/{id}/resume: Resume an agent */
44
+ resume: (...init: Init<"/agents/{id}/resume", "post">) => client.POST("/agents/{id}/resume", ...init),
45
+ /** POST /agents/{id}/revoke: Revoke an agent */
46
+ revoke: (...init: Init<"/agents/{id}/revoke", "post">) => client.POST("/agents/{id}/revoke", ...init),
47
+ /** GET /agents/session: The agent's session */
48
+ session: (...init: Init<"/agents/session", "get">) => client.GET("/agents/session", ...init),
49
+ /** GET /agents/{id}: Read an agent */
50
+ showAgent: (...init: Init<"/agents/{id}", "get">) => client.GET("/agents/{id}", ...init),
51
+ /** POST /agents/{id}/suspend: Suspend an agent */
52
+ suspend: (...init: Init<"/agents/{id}/suspend", "post">) => client.POST("/agents/{id}/suspend", ...init),
53
+ /** GET /agents/receipts/{id}/verify: Verify a receipt */
54
+ verifyReceipt: (...init: Init<"/agents/receipts/{id}/verify", "get">) => client.GET("/agents/receipts/{id}/verify", ...init),
55
+ };
56
+ }
57
+
58
+ export type AgentsApi = ReturnType<typeof agents>;
package/src/index.ts CHANGED
@@ -11,6 +11,8 @@ import { scim, type ScimApi } from "./scim.js";
11
11
  import { social, type SocialApi } from "./social.js";
12
12
  import { apiKeys, type ApiKeysApi } from "./api-keys.js";
13
13
  import { oauth, type OauthApi } from "./oauth.js";
14
+ import { mcp, type McpApi } from "./mcp.js";
15
+ import { agents, type AgentsApi } from "./agents.js";
14
16
  import { sso, type SsoApi } from "./sso.js";
15
17
  import { username, type UsernameApi } from "./username.js";
16
18
  import type { components, paths } from "./schema.js";
@@ -28,6 +30,8 @@ export { scim, type ScimApi } from "./scim.js";
28
30
  export { social, type SocialApi } from "./social.js";
29
31
  export { apiKeys, type ApiKeysApi } from "./api-keys.js";
30
32
  export { oauth, type OauthApi } from "./oauth.js";
33
+ export { mcp, type McpApi } from "./mcp.js";
34
+ export { agents, type AgentsApi } from "./agents.js";
31
35
  export { sso, type SsoApi } from "./sso.js";
32
36
  export { username, type UsernameApi } from "./username.js";
33
37
  export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAvailable, type SignInWithPasskeyOptions } from "./webauthn.js";
@@ -36,7 +40,7 @@ export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAv
36
40
  export type ErrorBody = components["schemas"]["Error"];
37
41
  /** The `{ errors: [...] }` envelope of a core route's 422. */
38
42
  export type ValidationErrorBody = components["schemas"]["ValidationError"];
39
- /** The RFC 9457 problem document every non-2xx response of a plugin route (`audit`, `admin`, `sentinel`, `sso`, `scim`, `passwordless`, `username`, `anonymous`, `multi-session`, `social`, `passkey`, `api-keys`, `oauth`) carries. */
43
+ /** The RFC 9457 problem document every non-2xx response of a plugin route (`audit`, `admin`, `sentinel`, `sso`, `scim`, `passwordless`, `username`, `anonymous`, `multi-session`, `social`, `passkey`, `api-keys`, `oauth`, `mcp`, `agents`) carries. */
40
44
  export type ProblemBody = components["schemas"]["Problem"];
41
45
 
42
46
  export interface PolarisClientOptions extends ClientOptions {
@@ -84,6 +88,10 @@ export interface PolarisClient extends Client<paths> {
84
88
  readonly apiKeys: ApiKeysApi;
85
89
  /** The `polaris/oauth-provider` routes: `client.oauth.authorize()`, `decision()`, `token()`, `userinfo()`, `revoke()`, `introspect()`, `register()`, the device, CIBA, consent, client-management and discovery methods. */
86
90
  readonly oauth: OauthApi;
91
+ /** The `polaris/mcp` routes: `client.mcp.mcp()` (one JSON-RPC message to `POST /mcp`) and `protectedResource()` (the RFC 9728 metadata). */
92
+ readonly mcp: McpApi;
93
+ /** The `polaris/agents` routes: the owner's (`register()`, `listAgents()`, `listApprovals()`, `decideApproval()`, `revoke()`, ...), the agent's (`requestGrants()`, `execute()`, `session()`; `@polaris-auth/agent` signs them) and `configuration()`. */
94
+ readonly agents: AgentsApi;
87
95
  /** A new client on the same options bound to another token (null for anonymous); this one is unchanged. */
88
96
  withToken(token: string | null): PolarisClient;
89
97
  }
@@ -92,7 +100,7 @@ export interface PolarisClient extends Client<paths> {
92
100
  * An `openapi-fetch` client typed by `paths` (generated from `polaris manifest --format=openapi`), so
93
101
  * `client.POST("/auth/login", { body })` checks the body and types `data` and `error`; the plugins' routes
94
102
  * are also methods of `client.audit`, `client.admin`, `client.sentinel`, `client.sso`, `client.scim`, `client.passwordless`,
95
- * `client.username`, `client.anonymous`, `client.multiSession`, `client.social`, `client.passkey`, `client.apiKeys` and `client.oauth`; `challenge.captcha`
103
+ * `client.username`, `client.anonymous`, `client.multiSession`, `client.social`, `client.passkey`, `client.apiKeys`, `client.oauth`, `client.mcp` and `client.agents`; `challenge.captcha`
96
104
  * answers a sentinel captcha challenge with one retry. No refresh loop and no storage: when to refresh
97
105
  * and where to keep tokens is the application's policy.
98
106
  */
@@ -127,6 +135,8 @@ export function createClient(options: PolarisClientOptions): PolarisClient {
127
135
  passkey: passkey(client),
128
136
  apiKeys: apiKeys(client),
129
137
  oauth: oauth(client),
138
+ mcp: mcp(client),
139
+ agents: agents(client),
130
140
  withToken: (next: string | null) => createClient({ ...options, token: next }),
131
141
  };
132
142
  }
package/src/mcp.ts ADDED
@@ -0,0 +1,16 @@
1
+ /* Generated by scripts/generate-namespaces.mjs from openapi.json; do not edit. */
2
+ import type { Client } from "openapi-fetch";
3
+ import type { paths } from "./schema.js";
4
+ import type { Init } from "./namespace.js";
5
+
6
+ /** The `mcp` plugin's routes as methods of `client.mcp`. */
7
+ export function mcp(client: Client<paths>) {
8
+ return {
9
+ /** POST /mcp: Serve an MCP message */
10
+ mcp: (...init: Init<"/mcp", "post">) => client.POST("/mcp", ...init),
11
+ /** GET /.well-known/oauth-protected-resource/mcp: Protected resource metadata of /mcp */
12
+ protectedResource: (...init: Init<"/.well-known/oauth-protected-resource/mcp", "get">) => client.GET("/.well-known/oauth-protected-resource/mcp", ...init),
13
+ };
14
+ }
15
+
16
+ export type McpApi = ReturnType<typeof mcp>;