@polaris-auth/client 0.8.0 → 0.10.0

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.
@@ -0,0 +1,19 @@
1
+ /** The `api-keys` plugin's routes as methods of `client.apiKeys`. */
2
+ export function apiKeys(client) {
3
+ return {
4
+ /** POST /api-keys: Create an API key */
5
+ create: (...init) => client.POST("/api-keys", ...init),
6
+ /** DELETE /api-keys/{id}: Revoke an API key */
7
+ delete: (...init) => client.DELETE("/api-keys/{id}", ...init),
8
+ /** GET /api-keys: List API keys */
9
+ list: (...init) => client.GET("/api-keys", ...init),
10
+ /** GET /api-keys/{id}: Read an API key */
11
+ read: (...init) => client.GET("/api-keys/{id}", ...init),
12
+ /** POST /api-keys/{id}/rotate: Rotate an API key */
13
+ rotate: (...init) => client.POST("/api-keys/{id}/rotate", ...init),
14
+ /** PATCH /api-keys/{id}: Update an API key */
15
+ update: (...init) => client.PATCH("/api-keys/{id}", ...init),
16
+ /** POST /api-keys/verify: Verify an API key */
17
+ verify: (...init) => client.POST("/api-keys/verify", ...init),
18
+ };
19
+ }
package/dist/index.d.ts CHANGED
@@ -9,6 +9,10 @@ import { type PasswordlessApi } from "./passwordless.js";
9
9
  import { type SentinelApi } from "./sentinel.js";
10
10
  import { type ScimApi } from "./scim.js";
11
11
  import { type SocialApi } from "./social.js";
12
+ import { type ApiKeysApi } from "./api-keys.js";
13
+ import { type OauthApi } from "./oauth.js";
14
+ import { type McpApi } from "./mcp.js";
15
+ import { type AgentsApi } from "./agents.js";
12
16
  import { type SsoApi } from "./sso.js";
13
17
  import { type UsernameApi } from "./username.js";
14
18
  import type { components, paths } from "./schema.js";
@@ -23,6 +27,10 @@ export { passwordless, type PasswordlessApi } from "./passwordless.js";
23
27
  export { sentinel, type SentinelApi } from "./sentinel.js";
24
28
  export { scim, type ScimApi } from "./scim.js";
25
29
  export { social, type SocialApi } from "./social.js";
30
+ export { apiKeys, type ApiKeysApi } from "./api-keys.js";
31
+ export { oauth, type OauthApi } from "./oauth.js";
32
+ export { mcp, type McpApi } from "./mcp.js";
33
+ export { agents, type AgentsApi } from "./agents.js";
26
34
  export { sso, type SsoApi } from "./sso.js";
27
35
  export { username, type UsernameApi } from "./username.js";
28
36
  export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAvailable, type SignInWithPasskeyOptions } from "./webauthn.js";
@@ -30,7 +38,7 @@ export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAv
30
38
  export type ErrorBody = components["schemas"]["Error"];
31
39
  /** The `{ errors: [...] }` envelope of a core route's 422. */
32
40
  export type ValidationErrorBody = components["schemas"]["ValidationError"];
33
- /** 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`) carries. */
41
+ /** 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. */
34
42
  export type ProblemBody = components["schemas"]["Problem"];
35
43
  export interface PolarisClientOptions extends ClientOptions {
36
44
  /** Where Polaris is mounted: `https://app.example.com`, or `https://app.example.com/api/auth` behind a prefix. */
@@ -72,6 +80,14 @@ export interface PolarisClient extends Client<paths> {
72
80
  readonly social: SocialApi;
73
81
  /** The `polaris/passkey` routes (`registerOptions()`, `registerVerify()`, `authenticateOptions()`, `authenticateVerify()`, `list()`, `rename()`, `delete()`); `registerPasskey()` and `signInWithPasskey()` run the browser ceremonies. */
74
82
  readonly passkey: PasskeyApi;
83
+ /** The `polaris/api-keys` routes: `client.apiKeys.list()`, `create()`, `read()`, `update()`, `delete()`, `rotate()`, `verify()`. A key goes in `Authorization: Bearer pk_...` like a session token. */
84
+ readonly apiKeys: ApiKeysApi;
85
+ /** The `polaris/oauth-provider` routes: `client.oauth.authorize()`, `decision()`, `token()`, `userinfo()`, `revoke()`, `introspect()`, `register()`, the device, CIBA, consent, client-management and discovery methods. */
86
+ readonly oauth: OauthApi;
87
+ /** The `polaris/mcp` routes: `client.mcp.mcp()` (one JSON-RPC message to `POST /mcp`) and `protectedResource()` (the RFC 9728 metadata). */
88
+ readonly mcp: McpApi;
89
+ /** 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()`. */
90
+ readonly agents: AgentsApi;
75
91
  /** A new client on the same options bound to another token (null for anonymous); this one is unchanged. */
76
92
  withToken(token: string | null): PolarisClient;
77
93
  }
@@ -79,7 +95,7 @@ export interface PolarisClient extends Client<paths> {
79
95
  * An `openapi-fetch` client typed by `paths` (generated from `polaris manifest --format=openapi`), so
80
96
  * `client.POST("/auth/login", { body })` checks the body and types `data` and `error`; the plugins' routes
81
97
  * are also methods of `client.audit`, `client.admin`, `client.sentinel`, `client.sso`, `client.scim`, `client.passwordless`,
82
- * `client.username`, `client.anonymous`, `client.multiSession`, `client.social` and `client.passkey`; `challenge.captcha`
98
+ * `client.username`, `client.anonymous`, `client.multiSession`, `client.social`, `client.passkey`, `client.apiKeys`, `client.oauth`, `client.mcp` and `client.agents`; `challenge.captcha`
83
99
  * answers a sentinel captcha challenge with one retry. No refresh loop and no storage: when to refresh
84
100
  * and where to keep tokens is the application's policy.
85
101
  */
package/dist/index.js CHANGED
@@ -9,6 +9,10 @@ import { passwordless } from "./passwordless.js";
9
9
  import { sentinel } from "./sentinel.js";
10
10
  import { scim } from "./scim.js";
11
11
  import { social } from "./social.js";
12
+ import { apiKeys } from "./api-keys.js";
13
+ import { oauth } from "./oauth.js";
14
+ import { mcp } from "./mcp.js";
15
+ import { agents } from "./agents.js";
12
16
  import { sso } from "./sso.js";
13
17
  import { username } from "./username.js";
14
18
  export { admin } from "./admin.js";
@@ -21,6 +25,10 @@ export { passwordless } from "./passwordless.js";
21
25
  export { sentinel } from "./sentinel.js";
22
26
  export { scim } from "./scim.js";
23
27
  export { social } from "./social.js";
28
+ export { apiKeys } from "./api-keys.js";
29
+ export { oauth } from "./oauth.js";
30
+ export { mcp } from "./mcp.js";
31
+ export { agents } from "./agents.js";
24
32
  export { sso } from "./sso.js";
25
33
  export { username } from "./username.js";
26
34
  export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAvailable } from "./webauthn.js";
@@ -28,7 +36,7 @@ export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAv
28
36
  * An `openapi-fetch` client typed by `paths` (generated from `polaris manifest --format=openapi`), so
29
37
  * `client.POST("/auth/login", { body })` checks the body and types `data` and `error`; the plugins' routes
30
38
  * are also methods of `client.audit`, `client.admin`, `client.sentinel`, `client.sso`, `client.scim`, `client.passwordless`,
31
- * `client.username`, `client.anonymous`, `client.multiSession`, `client.social` and `client.passkey`; `challenge.captcha`
39
+ * `client.username`, `client.anonymous`, `client.multiSession`, `client.social`, `client.passkey`, `client.apiKeys`, `client.oauth`, `client.mcp` and `client.agents`; `challenge.captcha`
32
40
  * answers a sentinel captcha challenge with one retry. No refresh loop and no storage: when to refresh
33
41
  * and where to keep tokens is the application's policy.
34
42
  */
@@ -60,6 +68,10 @@ export function createClient(options) {
60
68
  multiSession: multiSession(client),
61
69
  social: social(client),
62
70
  passkey: passkey(client),
71
+ apiKeys: apiKeys(client),
72
+ oauth: oauth(client),
73
+ mcp: mcp(client),
74
+ agents: agents(client),
63
75
  withToken: (next) => createClient({ ...options, token: next }),
64
76
  };
65
77
  }
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,456 @@
1
+ import type { Client } from "openapi-fetch";
2
+ import type { paths } from "./schema.js";
3
+ import type { Init } from "./namespace.js";
4
+ /** The `mcp` plugin's routes as methods of `client.mcp`. */
5
+ export declare function mcp(client: Client<paths>): {
6
+ /** POST /mcp: Serve an MCP message */
7
+ mcp: (init_0?: ({
8
+ params?: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ } & {
15
+ body?: undefined;
16
+ } & {
17
+ baseUrl?: string;
18
+ querySerializer?: import("openapi-fetch").QuerySerializerOptions | import("openapi-fetch").QuerySerializer<{
19
+ parameters: {
20
+ query?: never;
21
+ header?: never;
22
+ path?: never;
23
+ cookie?: never;
24
+ };
25
+ requestBody?: never;
26
+ responses: {
27
+ 200: {
28
+ headers: {
29
+ [name: string]: unknown;
30
+ };
31
+ content: {
32
+ "application/json": {
33
+ jsonrpc: string;
34
+ id: number;
35
+ result: {
36
+ tools: [];
37
+ };
38
+ };
39
+ };
40
+ };
41
+ 400: {
42
+ headers: {
43
+ [name: string]: unknown;
44
+ };
45
+ content: {
46
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
47
+ };
48
+ };
49
+ 401: {
50
+ headers: {
51
+ [name: string]: unknown;
52
+ };
53
+ content: {
54
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
55
+ };
56
+ };
57
+ 403: {
58
+ headers: {
59
+ [name: string]: unknown;
60
+ };
61
+ content: {
62
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
63
+ };
64
+ };
65
+ };
66
+ }>;
67
+ bodySerializer?: import("openapi-fetch").BodySerializer<{
68
+ parameters: {
69
+ query?: never;
70
+ header?: never;
71
+ path?: never;
72
+ cookie?: never;
73
+ };
74
+ requestBody?: never;
75
+ responses: {
76
+ 200: {
77
+ headers: {
78
+ [name: string]: unknown;
79
+ };
80
+ content: {
81
+ "application/json": {
82
+ jsonrpc: string;
83
+ id: number;
84
+ result: {
85
+ tools: [];
86
+ };
87
+ };
88
+ };
89
+ };
90
+ 400: {
91
+ headers: {
92
+ [name: string]: unknown;
93
+ };
94
+ content: {
95
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
96
+ };
97
+ };
98
+ 401: {
99
+ headers: {
100
+ [name: string]: unknown;
101
+ };
102
+ content: {
103
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
104
+ };
105
+ };
106
+ 403: {
107
+ headers: {
108
+ [name: string]: unknown;
109
+ };
110
+ content: {
111
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
112
+ };
113
+ };
114
+ };
115
+ }>;
116
+ pathSerializer?: import("openapi-fetch").PathSerializer;
117
+ parseAs?: import("openapi-fetch").ParseAs;
118
+ fetch?: import("openapi-fetch").ClientOptions["fetch"];
119
+ headers?: import("openapi-fetch").HeadersOptions;
120
+ middleware?: import("openapi-fetch").Middleware[];
121
+ } & Omit<RequestInit, "body" | "headers"> & {
122
+ [key: string]: unknown;
123
+ }) | undefined) => Promise<import("openapi-fetch").FetchResponse<{
124
+ parameters: {
125
+ query?: never;
126
+ header?: never;
127
+ path?: never;
128
+ cookie?: never;
129
+ };
130
+ requestBody?: never;
131
+ responses: {
132
+ 200: {
133
+ headers: {
134
+ [name: string]: unknown;
135
+ };
136
+ content: {
137
+ "application/json": {
138
+ jsonrpc: string;
139
+ id: number;
140
+ result: {
141
+ tools: [];
142
+ };
143
+ };
144
+ };
145
+ };
146
+ 400: {
147
+ headers: {
148
+ [name: string]: unknown;
149
+ };
150
+ content: {
151
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
152
+ };
153
+ };
154
+ 401: {
155
+ headers: {
156
+ [name: string]: unknown;
157
+ };
158
+ content: {
159
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
160
+ };
161
+ };
162
+ 403: {
163
+ headers: {
164
+ [name: string]: unknown;
165
+ };
166
+ content: {
167
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
168
+ };
169
+ };
170
+ };
171
+ }, ({
172
+ params?: {
173
+ query?: never;
174
+ header?: never;
175
+ path?: never;
176
+ cookie?: never;
177
+ };
178
+ } & {
179
+ body?: undefined;
180
+ } & {
181
+ baseUrl?: string;
182
+ querySerializer?: import("openapi-fetch").QuerySerializerOptions | import("openapi-fetch").QuerySerializer<{
183
+ parameters: {
184
+ query?: never;
185
+ header?: never;
186
+ path?: never;
187
+ cookie?: never;
188
+ };
189
+ requestBody?: never;
190
+ responses: {
191
+ 200: {
192
+ headers: {
193
+ [name: string]: unknown;
194
+ };
195
+ content: {
196
+ "application/json": {
197
+ jsonrpc: string;
198
+ id: number;
199
+ result: {
200
+ tools: [];
201
+ };
202
+ };
203
+ };
204
+ };
205
+ 400: {
206
+ headers: {
207
+ [name: string]: unknown;
208
+ };
209
+ content: {
210
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
211
+ };
212
+ };
213
+ 401: {
214
+ headers: {
215
+ [name: string]: unknown;
216
+ };
217
+ content: {
218
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
219
+ };
220
+ };
221
+ 403: {
222
+ headers: {
223
+ [name: string]: unknown;
224
+ };
225
+ content: {
226
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
227
+ };
228
+ };
229
+ };
230
+ }>;
231
+ bodySerializer?: import("openapi-fetch").BodySerializer<{
232
+ parameters: {
233
+ query?: never;
234
+ header?: never;
235
+ path?: never;
236
+ cookie?: never;
237
+ };
238
+ requestBody?: never;
239
+ responses: {
240
+ 200: {
241
+ headers: {
242
+ [name: string]: unknown;
243
+ };
244
+ content: {
245
+ "application/json": {
246
+ jsonrpc: string;
247
+ id: number;
248
+ result: {
249
+ tools: [];
250
+ };
251
+ };
252
+ };
253
+ };
254
+ 400: {
255
+ headers: {
256
+ [name: string]: unknown;
257
+ };
258
+ content: {
259
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
260
+ };
261
+ };
262
+ 401: {
263
+ headers: {
264
+ [name: string]: unknown;
265
+ };
266
+ content: {
267
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
268
+ };
269
+ };
270
+ 403: {
271
+ headers: {
272
+ [name: string]: unknown;
273
+ };
274
+ content: {
275
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
276
+ };
277
+ };
278
+ };
279
+ }>;
280
+ pathSerializer?: import("openapi-fetch").PathSerializer;
281
+ parseAs?: import("openapi-fetch").ParseAs;
282
+ fetch?: import("openapi-fetch").ClientOptions["fetch"];
283
+ headers?: import("openapi-fetch").HeadersOptions;
284
+ middleware?: import("openapi-fetch").Middleware[];
285
+ } & Omit<RequestInit, "body" | "headers"> & {
286
+ [key: string]: unknown;
287
+ }) | undefined, `${string}/${string}`>>;
288
+ /** GET /.well-known/oauth-protected-resource/mcp: Protected resource metadata of /mcp */
289
+ protectedResource: (init_0?: ({
290
+ params?: {
291
+ query?: never;
292
+ header?: never;
293
+ path?: never;
294
+ cookie?: never;
295
+ };
296
+ } & {
297
+ body?: undefined;
298
+ } & {
299
+ baseUrl?: string;
300
+ querySerializer?: import("openapi-fetch").QuerySerializerOptions | import("openapi-fetch").QuerySerializer<{
301
+ parameters: {
302
+ query?: never;
303
+ header?: never;
304
+ path?: never;
305
+ cookie?: never;
306
+ };
307
+ requestBody?: never;
308
+ responses: {
309
+ 200: {
310
+ headers: {
311
+ [name: string]: unknown;
312
+ };
313
+ content: {
314
+ "application/json": {
315
+ resource: string;
316
+ authorization_servers: string[];
317
+ scopes_supported: string[];
318
+ bearer_methods_supported: string[];
319
+ dpop_signing_alg_values_supported: string[];
320
+ resource_name: string;
321
+ };
322
+ };
323
+ };
324
+ };
325
+ }>;
326
+ bodySerializer?: import("openapi-fetch").BodySerializer<{
327
+ parameters: {
328
+ query?: never;
329
+ header?: never;
330
+ path?: never;
331
+ cookie?: never;
332
+ };
333
+ requestBody?: never;
334
+ responses: {
335
+ 200: {
336
+ headers: {
337
+ [name: string]: unknown;
338
+ };
339
+ content: {
340
+ "application/json": {
341
+ resource: string;
342
+ authorization_servers: string[];
343
+ scopes_supported: string[];
344
+ bearer_methods_supported: string[];
345
+ dpop_signing_alg_values_supported: string[];
346
+ resource_name: string;
347
+ };
348
+ };
349
+ };
350
+ };
351
+ }>;
352
+ pathSerializer?: import("openapi-fetch").PathSerializer;
353
+ parseAs?: import("openapi-fetch").ParseAs;
354
+ fetch?: import("openapi-fetch").ClientOptions["fetch"];
355
+ headers?: import("openapi-fetch").HeadersOptions;
356
+ middleware?: import("openapi-fetch").Middleware[];
357
+ } & Omit<RequestInit, "body" | "headers"> & {
358
+ [key: string]: unknown;
359
+ }) | undefined) => Promise<import("openapi-fetch").FetchResponse<{
360
+ parameters: {
361
+ query?: never;
362
+ header?: never;
363
+ path?: never;
364
+ cookie?: never;
365
+ };
366
+ requestBody?: never;
367
+ responses: {
368
+ 200: {
369
+ headers: {
370
+ [name: string]: unknown;
371
+ };
372
+ content: {
373
+ "application/json": {
374
+ resource: string;
375
+ authorization_servers: string[];
376
+ scopes_supported: string[];
377
+ bearer_methods_supported: string[];
378
+ dpop_signing_alg_values_supported: string[];
379
+ resource_name: string;
380
+ };
381
+ };
382
+ };
383
+ };
384
+ }, ({
385
+ params?: {
386
+ query?: never;
387
+ header?: never;
388
+ path?: never;
389
+ cookie?: never;
390
+ };
391
+ } & {
392
+ body?: undefined;
393
+ } & {
394
+ baseUrl?: string;
395
+ querySerializer?: import("openapi-fetch").QuerySerializerOptions | import("openapi-fetch").QuerySerializer<{
396
+ parameters: {
397
+ query?: never;
398
+ header?: never;
399
+ path?: never;
400
+ cookie?: never;
401
+ };
402
+ requestBody?: never;
403
+ responses: {
404
+ 200: {
405
+ headers: {
406
+ [name: string]: unknown;
407
+ };
408
+ content: {
409
+ "application/json": {
410
+ resource: string;
411
+ authorization_servers: string[];
412
+ scopes_supported: string[];
413
+ bearer_methods_supported: string[];
414
+ dpop_signing_alg_values_supported: string[];
415
+ resource_name: string;
416
+ };
417
+ };
418
+ };
419
+ };
420
+ }>;
421
+ bodySerializer?: import("openapi-fetch").BodySerializer<{
422
+ parameters: {
423
+ query?: never;
424
+ header?: never;
425
+ path?: never;
426
+ cookie?: never;
427
+ };
428
+ requestBody?: never;
429
+ responses: {
430
+ 200: {
431
+ headers: {
432
+ [name: string]: unknown;
433
+ };
434
+ content: {
435
+ "application/json": {
436
+ resource: string;
437
+ authorization_servers: string[];
438
+ scopes_supported: string[];
439
+ bearer_methods_supported: string[];
440
+ dpop_signing_alg_values_supported: string[];
441
+ resource_name: string;
442
+ };
443
+ };
444
+ };
445
+ };
446
+ }>;
447
+ pathSerializer?: import("openapi-fetch").PathSerializer;
448
+ parseAs?: import("openapi-fetch").ParseAs;
449
+ fetch?: import("openapi-fetch").ClientOptions["fetch"];
450
+ headers?: import("openapi-fetch").HeadersOptions;
451
+ middleware?: import("openapi-fetch").Middleware[];
452
+ } & Omit<RequestInit, "body" | "headers"> & {
453
+ [key: string]: unknown;
454
+ }) | undefined, `${string}/${string}`>>;
455
+ };
456
+ export type McpApi = ReturnType<typeof mcp>;
package/dist/mcp.js ADDED
@@ -0,0 +1,9 @@
1
+ /** The `mcp` plugin's routes as methods of `client.mcp`. */
2
+ export function mcp(client) {
3
+ return {
4
+ /** POST /mcp: Serve an MCP message */
5
+ mcp: (...init) => client.POST("/mcp", ...init),
6
+ /** GET /.well-known/oauth-protected-resource/mcp: Protected resource metadata of /mcp */
7
+ protectedResource: (...init) => client.GET("/.well-known/oauth-protected-resource/mcp", ...init),
8
+ };
9
+ }