@polaris-auth/client 0.6.1 → 0.8.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.
package/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  The TypeScript client for [Polaris for PHP](https://github.com/univeros/polaris-core), generated from
4
4
  the route manifest: `openapi-fetch` typed by the 52 core endpoints and the routes of the `polaris/audit`,
5
- `polaris/admin`, `polaris/sentinel`, `polaris/sso` and `polaris/scim` plugins, so a request body, its
5
+ `polaris/admin`, `polaris/sentinel`, `polaris/sso`, `polaris/scim`, `polaris/passwordless`,
6
+ `polaris/username`, `polaris/anonymous`, `polaris/multi-session`, `polaris/social` and `polaris/passkey`
7
+ plugins, so a request body, its
6
8
  `data` and its `error` are checked at compile time against the same contract the PHP hosts serve.
7
9
 
8
10
  ```sh
@@ -44,11 +46,17 @@ const trail = await polaris.withToken(accessToken).audit.me();
44
46
  `client.audit` (`me`, `organization`, `types`), `client.admin` (users, sessions, MFA, organizations,
45
47
  audit, drains, stats, keys, grants; see the package README), `client.sentinel` (`listDecisions`,
46
48
  `listIpRules`, `createIpRule`, `deleteIpRule`, `unblock`), `client.sso` (`signIn`, `exchange`, `logout`,
47
- the organization's providers and domains, the operators' list) and `client.scim` (the organization's
48
- connections, the operators' list, and the SCIM server's own routes for a directory client) are generated
49
- into `src/audit.ts`, `src/admin.ts`, `src/sentinel.ts`, `src/sso.ts` and `src/scim.ts` by
50
- `scripts/generate-namespaces.mjs` from the `x-polaris-plugin` marker of the OpenAPI document; a later
51
- plugin gets its namespace the same way. Their errors are RFC 9457 problem documents,
49
+ the organization's providers and domains, the operators' list), `client.scim` (the organization's
50
+ connections, the operators' list, and the SCIM server's own routes for a directory client),
51
+ `client.passwordless` (`magicLinkSend`, `magicLinkVerify`, `magicLinkExchange`, `emailOtpSend`,
52
+ `emailOtpVerify`, `emailOtpVerifyEmail`, `emailOtpResetPassword`, `phoneSend`, `phoneVerify`, `phoneAdd`,
53
+ `phoneConfirm`, `oneTimeTokenGenerate`, `oneTimeTokenVerify`), `client.username` (`signIn`, `update`),
54
+ `client.anonymous` (`signIn`, `convert`), `client.multiSession` (`list`, `switch`, `revoke`,
55
+ `lastMethod`), `client.social` (`start`, `exchange`, `oneTap`, `accounts`, `link`, `unlink`, `token`) and
56
+ `client.passkey` (`registerOptions`, `registerVerify`, `authenticateOptions`, `authenticateVerify`, `list`,
57
+ `rename`, `delete`) are generated into `src/<plugin id>.ts` by `scripts/generate-namespaces.mjs` from the
58
+ `x-polaris-plugin` marker of the OpenAPI document; a later plugin gets its namespace the same way, its id
59
+ camel-cased (`multi-session` is `client.multiSession`). Their errors are RFC 9457 problem documents,
52
60
  `ProblemBody` (`{ type, title, status, detail, error, message, errors? }`), served as
53
61
  `application/problem+json`.
54
62
 
@@ -56,6 +64,51 @@ Response types come from each endpoint's `output.example` in the manifest (JSON
56
64
  `docs/adapters/spec.md` §7): a documented approximation, exact for the shapes the specs show. Error
57
65
  bodies are `ErrorBody` (`{ error, message }`) and `ValidationErrorBody` (`{ errors }`).
58
66
 
67
+ ## Social sign-in
68
+
69
+ `client.social.start()` answers the provider's URL and a `state`; keep the state (`sessionStorage`), send
70
+ the browser to the URL, and on the page the sign-in ends on compare the `state` in the query with it
71
+ before exchanging the `code`:
72
+
73
+ ```ts
74
+ const { data } = await polaris.social.start({ params: { path: { provider: "google" } }, body: {} });
75
+ sessionStorage.setItem("polaris.social.state", data!.data.state);
76
+ location.assign(data!.data.url);
77
+ // ...on /signed-in:
78
+ const query = new URLSearchParams(location.search);
79
+ if (query.get("state") !== sessionStorage.getItem("polaris.social.state")) throw new Error("not the flow this browser started");
80
+ const session = await polaris.social.exchange({ body: { code: query.get("code")! } });
81
+ ```
82
+
83
+ ## Passkeys
84
+
85
+ `registerPasskey()`, `signInWithPasskey()` and `passkeyAssertion()` run the WebAuthn ceremonies of
86
+ `polaris/passkey` in the browser (`navigator.credentials`, a secure context) over the client's routes;
87
+ they are the only hand-written code besides the sentinel retry.
88
+
89
+ ```ts
90
+ import { createClient, registerPasskey, signInWithPasskey, passkeyAssertion } from "@polaris-auth/client";
91
+
92
+ const { passkey, recovery_codes } = await registerPasskey(polaris.withToken(accessToken), "MacBook");
93
+ const session = await signInWithPasskey(polaris); // a prompt
94
+ const autofilled = await signInWithPasskey(polaris, { conditional: true }); // the form's autofill (autocomplete="username webauthn")
95
+ // The passkey as the second factor of a password login that answered mfa_required:
96
+ await polaris.withToken(mfaToken).POST("/auth/mfa/verify", { body: { factor_id, code: await passkeyAssertion(polaris) } });
97
+ ```
98
+
99
+ ## Several accounts on one device
100
+
101
+ With `polaris/multi-session`, every response that carries a token pair also carries the device id in
102
+ `X-Polaris-Device` (and, for a browser, the HttpOnly cookie `polaris_ms_device`). A client that is not a
103
+ browser sends it back on the multi-session routes:
104
+
105
+ ```ts
106
+ const device = signIn.response.headers.get("X-Polaris-Device")!;
107
+ const accounts = await polaris.withToken(access).multiSession.list({ headers: { "X-Polaris-Device": device } });
108
+ const other = await polaris.withToken(access).multiSession.switch({ body: { session_id: accounts.data!.data[1]!.session_id }, headers: { "X-Polaris-Device": device } });
109
+ const button = (await polaris.multiSession.lastMethod({ headers: { "X-Polaris-Device": device } })).data?.data.last_method;
110
+ ```
111
+
59
112
  ## The sentinel challenge
60
113
 
61
114
  With `polaris/sentinel` enforcing, a sign-up, sign-in, password reset or code send may answer `403` with
@@ -89,7 +142,8 @@ npm test # starts examples/slim (installed and set up) and runs regi
89
142
  `src/sso.ts`, `src/scim.ts`) are checked in; CI regenerates them and fails on a difference, so a manifest
90
143
  change ships with its types. `polaris.php` is the application the client is generated for (core with the
91
144
  five plugins that have routes). `POLARIS_URL=http://host:port npm test` runs the test against a server
92
- you started. Node 20 or later.
145
+ you started. Node 20 or later. Every `v*` tag of the monorepo publishes the package to npm through
146
+ trusted publishing (`.github/workflows/npm-publish.yml`, OIDC, provenance attached, no token).
93
147
 
94
148
  ## License
95
149
 
@@ -0,0 +1,513 @@
1
+ import type { Client } from "openapi-fetch";
2
+ import type { paths } from "./schema.js";
3
+ import type { Init } from "./namespace.js";
4
+ /** The `anonymous` plugin's routes as methods of `client.anonymous`. */
5
+ export declare function anonymous(client: Client<paths>): {
6
+ /** POST /anonymous/convert: Convert the guest into an account */
7
+ convert: (init_0: {
8
+ params?: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ } & {
15
+ body: {
16
+ access_token: string;
17
+ } & {};
18
+ } & {
19
+ baseUrl?: string;
20
+ querySerializer?: import("openapi-fetch").QuerySerializerOptions | import("openapi-fetch").QuerySerializer<{
21
+ parameters: {
22
+ query?: never;
23
+ header?: never;
24
+ path?: never;
25
+ cookie?: never;
26
+ };
27
+ requestBody: {
28
+ content: {
29
+ "application/json": {
30
+ access_token: string;
31
+ };
32
+ };
33
+ };
34
+ responses: {
35
+ 200: {
36
+ headers: {
37
+ [name: string]: unknown;
38
+ };
39
+ content: {
40
+ "application/json": {
41
+ data: {
42
+ guest_id: string;
43
+ user_id: string;
44
+ status: string;
45
+ };
46
+ };
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
+ 422: {
66
+ headers: {
67
+ [name: string]: unknown;
68
+ };
69
+ content: {
70
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
71
+ };
72
+ };
73
+ };
74
+ }>;
75
+ bodySerializer?: import("openapi-fetch").BodySerializer<{
76
+ parameters: {
77
+ query?: never;
78
+ header?: never;
79
+ path?: never;
80
+ cookie?: never;
81
+ };
82
+ requestBody: {
83
+ content: {
84
+ "application/json": {
85
+ access_token: string;
86
+ };
87
+ };
88
+ };
89
+ responses: {
90
+ 200: {
91
+ headers: {
92
+ [name: string]: unknown;
93
+ };
94
+ content: {
95
+ "application/json": {
96
+ data: {
97
+ guest_id: string;
98
+ user_id: string;
99
+ status: string;
100
+ };
101
+ };
102
+ };
103
+ };
104
+ 401: {
105
+ headers: {
106
+ [name: string]: unknown;
107
+ };
108
+ content: {
109
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
110
+ };
111
+ };
112
+ 403: {
113
+ headers: {
114
+ [name: string]: unknown;
115
+ };
116
+ content: {
117
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
118
+ };
119
+ };
120
+ 422: {
121
+ headers: {
122
+ [name: string]: unknown;
123
+ };
124
+ content: {
125
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
126
+ };
127
+ };
128
+ };
129
+ }>;
130
+ pathSerializer?: import("openapi-fetch").PathSerializer;
131
+ parseAs?: import("openapi-fetch").ParseAs;
132
+ fetch?: import("openapi-fetch").ClientOptions["fetch"];
133
+ headers?: import("openapi-fetch").HeadersOptions;
134
+ middleware?: import("openapi-fetch").Middleware[];
135
+ } & Omit<RequestInit, "body" | "headers"> & {
136
+ [key: string]: unknown;
137
+ }) => Promise<import("openapi-fetch").FetchResponse<{
138
+ parameters: {
139
+ query?: never;
140
+ header?: never;
141
+ path?: never;
142
+ cookie?: never;
143
+ };
144
+ requestBody: {
145
+ content: {
146
+ "application/json": {
147
+ access_token: string;
148
+ };
149
+ };
150
+ };
151
+ responses: {
152
+ 200: {
153
+ headers: {
154
+ [name: string]: unknown;
155
+ };
156
+ content: {
157
+ "application/json": {
158
+ data: {
159
+ guest_id: string;
160
+ user_id: string;
161
+ status: string;
162
+ };
163
+ };
164
+ };
165
+ };
166
+ 401: {
167
+ headers: {
168
+ [name: string]: unknown;
169
+ };
170
+ content: {
171
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
172
+ };
173
+ };
174
+ 403: {
175
+ headers: {
176
+ [name: string]: unknown;
177
+ };
178
+ content: {
179
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
180
+ };
181
+ };
182
+ 422: {
183
+ headers: {
184
+ [name: string]: unknown;
185
+ };
186
+ content: {
187
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
188
+ };
189
+ };
190
+ };
191
+ }, {
192
+ params?: {
193
+ query?: never;
194
+ header?: never;
195
+ path?: never;
196
+ cookie?: never;
197
+ };
198
+ } & {
199
+ body: {
200
+ access_token: string;
201
+ } & {};
202
+ } & {
203
+ baseUrl?: string;
204
+ querySerializer?: import("openapi-fetch").QuerySerializerOptions | import("openapi-fetch").QuerySerializer<{
205
+ parameters: {
206
+ query?: never;
207
+ header?: never;
208
+ path?: never;
209
+ cookie?: never;
210
+ };
211
+ requestBody: {
212
+ content: {
213
+ "application/json": {
214
+ access_token: string;
215
+ };
216
+ };
217
+ };
218
+ responses: {
219
+ 200: {
220
+ headers: {
221
+ [name: string]: unknown;
222
+ };
223
+ content: {
224
+ "application/json": {
225
+ data: {
226
+ guest_id: string;
227
+ user_id: string;
228
+ status: string;
229
+ };
230
+ };
231
+ };
232
+ };
233
+ 401: {
234
+ headers: {
235
+ [name: string]: unknown;
236
+ };
237
+ content: {
238
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
239
+ };
240
+ };
241
+ 403: {
242
+ headers: {
243
+ [name: string]: unknown;
244
+ };
245
+ content: {
246
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
247
+ };
248
+ };
249
+ 422: {
250
+ headers: {
251
+ [name: string]: unknown;
252
+ };
253
+ content: {
254
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
255
+ };
256
+ };
257
+ };
258
+ }>;
259
+ bodySerializer?: import("openapi-fetch").BodySerializer<{
260
+ parameters: {
261
+ query?: never;
262
+ header?: never;
263
+ path?: never;
264
+ cookie?: never;
265
+ };
266
+ requestBody: {
267
+ content: {
268
+ "application/json": {
269
+ access_token: string;
270
+ };
271
+ };
272
+ };
273
+ responses: {
274
+ 200: {
275
+ headers: {
276
+ [name: string]: unknown;
277
+ };
278
+ content: {
279
+ "application/json": {
280
+ data: {
281
+ guest_id: string;
282
+ user_id: string;
283
+ status: string;
284
+ };
285
+ };
286
+ };
287
+ };
288
+ 401: {
289
+ headers: {
290
+ [name: string]: unknown;
291
+ };
292
+ content: {
293
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
294
+ };
295
+ };
296
+ 403: {
297
+ headers: {
298
+ [name: string]: unknown;
299
+ };
300
+ content: {
301
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
302
+ };
303
+ };
304
+ 422: {
305
+ headers: {
306
+ [name: string]: unknown;
307
+ };
308
+ content: {
309
+ "application/problem+json": import("./schema.js").components["schemas"]["Problem"];
310
+ };
311
+ };
312
+ };
313
+ }>;
314
+ pathSerializer?: import("openapi-fetch").PathSerializer;
315
+ parseAs?: import("openapi-fetch").ParseAs;
316
+ fetch?: import("openapi-fetch").ClientOptions["fetch"];
317
+ headers?: import("openapi-fetch").HeadersOptions;
318
+ middleware?: import("openapi-fetch").Middleware[];
319
+ } & Omit<RequestInit, "body" | "headers">, `${string}/${string}`>>;
320
+ /** POST /anonymous/sign-in: Sign in as a guest */
321
+ signIn: (init_0?: ({
322
+ params?: {
323
+ query?: never;
324
+ header?: never;
325
+ path?: never;
326
+ cookie?: never;
327
+ };
328
+ } & {
329
+ body?: undefined;
330
+ } & {
331
+ baseUrl?: string;
332
+ querySerializer?: import("openapi-fetch").QuerySerializerOptions | import("openapi-fetch").QuerySerializer<{
333
+ parameters: {
334
+ query?: never;
335
+ header?: never;
336
+ path?: never;
337
+ cookie?: never;
338
+ };
339
+ requestBody?: never;
340
+ responses: {
341
+ 201: {
342
+ headers: {
343
+ [name: string]: unknown;
344
+ };
345
+ content: {
346
+ "application/json": {
347
+ data: {
348
+ access_token: string;
349
+ token_type: string;
350
+ expires_in: number;
351
+ refresh_token: string;
352
+ user: {
353
+ id: string;
354
+ email: string;
355
+ email_verified: boolean;
356
+ };
357
+ };
358
+ };
359
+ };
360
+ };
361
+ };
362
+ }>;
363
+ bodySerializer?: import("openapi-fetch").BodySerializer<{
364
+ parameters: {
365
+ query?: never;
366
+ header?: never;
367
+ path?: never;
368
+ cookie?: never;
369
+ };
370
+ requestBody?: never;
371
+ responses: {
372
+ 201: {
373
+ headers: {
374
+ [name: string]: unknown;
375
+ };
376
+ content: {
377
+ "application/json": {
378
+ data: {
379
+ access_token: string;
380
+ token_type: string;
381
+ expires_in: number;
382
+ refresh_token: string;
383
+ user: {
384
+ id: string;
385
+ email: string;
386
+ email_verified: boolean;
387
+ };
388
+ };
389
+ };
390
+ };
391
+ };
392
+ };
393
+ }>;
394
+ pathSerializer?: import("openapi-fetch").PathSerializer;
395
+ parseAs?: import("openapi-fetch").ParseAs;
396
+ fetch?: import("openapi-fetch").ClientOptions["fetch"];
397
+ headers?: import("openapi-fetch").HeadersOptions;
398
+ middleware?: import("openapi-fetch").Middleware[];
399
+ } & Omit<RequestInit, "body" | "headers"> & {
400
+ [key: string]: unknown;
401
+ }) | undefined) => Promise<import("openapi-fetch").FetchResponse<{
402
+ parameters: {
403
+ query?: never;
404
+ header?: never;
405
+ path?: never;
406
+ cookie?: never;
407
+ };
408
+ requestBody?: never;
409
+ responses: {
410
+ 201: {
411
+ headers: {
412
+ [name: string]: unknown;
413
+ };
414
+ content: {
415
+ "application/json": {
416
+ data: {
417
+ access_token: string;
418
+ token_type: string;
419
+ expires_in: number;
420
+ refresh_token: string;
421
+ user: {
422
+ id: string;
423
+ email: string;
424
+ email_verified: boolean;
425
+ };
426
+ };
427
+ };
428
+ };
429
+ };
430
+ };
431
+ }, ({
432
+ params?: {
433
+ query?: never;
434
+ header?: never;
435
+ path?: never;
436
+ cookie?: never;
437
+ };
438
+ } & {
439
+ body?: undefined;
440
+ } & {
441
+ baseUrl?: string;
442
+ querySerializer?: import("openapi-fetch").QuerySerializerOptions | import("openapi-fetch").QuerySerializer<{
443
+ parameters: {
444
+ query?: never;
445
+ header?: never;
446
+ path?: never;
447
+ cookie?: never;
448
+ };
449
+ requestBody?: never;
450
+ responses: {
451
+ 201: {
452
+ headers: {
453
+ [name: string]: unknown;
454
+ };
455
+ content: {
456
+ "application/json": {
457
+ data: {
458
+ access_token: string;
459
+ token_type: string;
460
+ expires_in: number;
461
+ refresh_token: string;
462
+ user: {
463
+ id: string;
464
+ email: string;
465
+ email_verified: boolean;
466
+ };
467
+ };
468
+ };
469
+ };
470
+ };
471
+ };
472
+ }>;
473
+ bodySerializer?: import("openapi-fetch").BodySerializer<{
474
+ parameters: {
475
+ query?: never;
476
+ header?: never;
477
+ path?: never;
478
+ cookie?: never;
479
+ };
480
+ requestBody?: never;
481
+ responses: {
482
+ 201: {
483
+ headers: {
484
+ [name: string]: unknown;
485
+ };
486
+ content: {
487
+ "application/json": {
488
+ data: {
489
+ access_token: string;
490
+ token_type: string;
491
+ expires_in: number;
492
+ refresh_token: string;
493
+ user: {
494
+ id: string;
495
+ email: string;
496
+ email_verified: boolean;
497
+ };
498
+ };
499
+ };
500
+ };
501
+ };
502
+ };
503
+ }>;
504
+ pathSerializer?: import("openapi-fetch").PathSerializer;
505
+ parseAs?: import("openapi-fetch").ParseAs;
506
+ fetch?: import("openapi-fetch").ClientOptions["fetch"];
507
+ headers?: import("openapi-fetch").HeadersOptions;
508
+ middleware?: import("openapi-fetch").Middleware[];
509
+ } & Omit<RequestInit, "body" | "headers"> & {
510
+ [key: string]: unknown;
511
+ }) | undefined, `${string}/${string}`>>;
512
+ };
513
+ export type AnonymousApi = ReturnType<typeof anonymous>;
@@ -0,0 +1,9 @@
1
+ /** The `anonymous` plugin's routes as methods of `client.anonymous`. */
2
+ export function anonymous(client) {
3
+ return {
4
+ /** POST /anonymous/convert: Convert the guest into an account */
5
+ convert: (...init) => client.POST("/anonymous/convert", ...init),
6
+ /** POST /anonymous/sign-in: Sign in as a guest */
7
+ signIn: (...init) => client.POST("/anonymous/sign-in", ...init),
8
+ };
9
+ }
package/dist/index.d.ts CHANGED
@@ -1,23 +1,36 @@
1
1
  import { type Client, type ClientOptions } from "openapi-fetch";
2
2
  import { type AdminApi } from "./admin.js";
3
+ import { type AnonymousApi } from "./anonymous.js";
3
4
  import { type AuditApi } from "./audit.js";
4
5
  import { type ChallengeOptions } from "./challenge.js";
6
+ import { type MultiSessionApi } from "./multi-session.js";
7
+ import { type PasskeyApi } from "./passkey.js";
8
+ import { type PasswordlessApi } from "./passwordless.js";
5
9
  import { type SentinelApi } from "./sentinel.js";
6
10
  import { type ScimApi } from "./scim.js";
11
+ import { type SocialApi } from "./social.js";
7
12
  import { type SsoApi } from "./sso.js";
13
+ import { type UsernameApi } from "./username.js";
8
14
  import type { components, paths } from "./schema.js";
9
15
  export type { components, operations, paths } from "./schema.js";
10
16
  export { admin, type AdminApi } from "./admin.js";
17
+ export { anonymous, type AnonymousApi } from "./anonymous.js";
11
18
  export { audit, type AuditApi } from "./audit.js";
12
19
  export { challengeRetry, type ChallengeOptions } from "./challenge.js";
20
+ export { multiSession, type MultiSessionApi } from "./multi-session.js";
21
+ export { passkey, type PasskeyApi } from "./passkey.js";
22
+ export { passwordless, type PasswordlessApi } from "./passwordless.js";
13
23
  export { sentinel, type SentinelApi } from "./sentinel.js";
14
24
  export { scim, type ScimApi } from "./scim.js";
25
+ export { social, type SocialApi } from "./social.js";
15
26
  export { sso, type SsoApi } from "./sso.js";
27
+ export { username, type UsernameApi } from "./username.js";
28
+ export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAvailable, type SignInWithPasskeyOptions } from "./webauthn.js";
16
29
  /** The `{ error, message }` envelope every non-2xx response of a core route carries. */
17
30
  export type ErrorBody = components["schemas"]["Error"];
18
31
  /** The `{ errors: [...] }` envelope of a core route's 422. */
19
32
  export type ValidationErrorBody = components["schemas"]["ValidationError"];
20
- /** The RFC 9457 problem document every non-2xx response of a plugin route (`audit`, `admin`, `sentinel`, `sso`, `scim`) carries. */
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. */
21
34
  export type ProblemBody = components["schemas"]["Problem"];
22
35
  export interface PolarisClientOptions extends ClientOptions {
23
36
  /** Where Polaris is mounted: `https://app.example.com`, or `https://app.example.com/api/auth` behind a prefix. */
@@ -44,13 +57,29 @@ export interface PolarisClient extends Client<paths> {
44
57
  readonly sso: SsoApi;
45
58
  /** The `polaris/scim` routes: the organization's connections, the operators' list, and the SCIM server itself for a directory client. */
46
59
  readonly scim: ScimApi;
60
+ /** The `polaris/passwordless` routes: `client.passwordless.magicLinkSend()`, `magicLinkExchange()`, `emailOtpSend()`, `emailOtpVerify()`, `phoneSend()`, `phoneVerify()`, `oneTimeTokenGenerate()`, ... */
61
+ readonly passwordless: PasswordlessApi;
62
+ /** The `polaris/username` routes: `client.username.signIn()` (a username or an email) and `update()`. */
63
+ readonly username: UsernameApi;
64
+ /** The `polaris/anonymous` routes: `client.anonymous.signIn()` for a guest and `convert()` once it has an account. */
65
+ readonly anonymous: AnonymousApi;
66
+ /**
67
+ * The `polaris/multi-session` routes: `client.multiSession.list()`, `switch()`, `revoke()`, `lastMethod()`.
68
+ * The device travels as the `X-Polaris-Device` header a sign-in answers (or the HttpOnly cookie in a browser).
69
+ */
70
+ readonly multiSession: MultiSessionApi;
71
+ /** The `polaris/social` routes: `client.social.start()`, `exchange()`, `oneTap()`, `accounts()`, `link()`, `unlink()`, `token()`. */
72
+ readonly social: SocialApi;
73
+ /** The `polaris/passkey` routes (`registerOptions()`, `registerVerify()`, `authenticateOptions()`, `authenticateVerify()`, `list()`, `rename()`, `delete()`); `registerPasskey()` and `signInWithPasskey()` run the browser ceremonies. */
74
+ readonly passkey: PasskeyApi;
47
75
  /** A new client on the same options bound to another token (null for anonymous); this one is unchanged. */
48
76
  withToken(token: string | null): PolarisClient;
49
77
  }
50
78
  /**
51
79
  * An `openapi-fetch` client typed by `paths` (generated from `polaris manifest --format=openapi`), so
52
80
  * `client.POST("/auth/login", { body })` checks the body and types `data` and `error`; the plugins' routes
53
- * are also methods of `client.audit`, `client.admin`, `client.sentinel`, `client.sso` and `client.scim`; `challenge.captcha`
81
+ * 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`
54
83
  * answers a sentinel captcha challenge with one retry. No refresh loop and no storage: when to refresh
55
84
  * and where to keep tokens is the application's policy.
56
85
  */