@polaris-auth/client 0.0.0-stage → 0.7.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/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
- "name": "@polaris-auth/client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@polaris-auth/client",
3
+ "version": "0.7.0",
4
+ "description": "Typed TypeScript client for Polaris for PHP, generated from the route manifest",
5
+ "keywords": [
6
+ "polaris",
7
+ "authentication",
8
+ "auth",
9
+ "mfa",
10
+ "totp",
11
+ "jwt",
12
+ "oauth",
13
+ "sso",
14
+ "scim",
15
+ "rbac",
16
+ "organizations",
17
+ "multi-tenant",
18
+ "php",
19
+ "laravel",
20
+ "symfony",
21
+ "yii",
22
+ "openapi",
23
+ "openapi-fetch",
24
+ "typescript",
25
+ "client"
26
+ ],
27
+ "homepage": "https://github.com/univeros/polaris-core/tree/main/packages/client-ts#readme",
28
+ "bugs": "https://github.com/univeros/polaris-core/issues",
29
+ "license": "MIT",
30
+ "author": {
31
+ "name": "2am.tech",
32
+ "url": "https://2am.tech"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/univeros/polaris-core.git",
37
+ "directory": "packages/client-ts"
38
+ },
39
+ "type": "module",
40
+ "main": "./dist/index.js",
41
+ "types": "./dist/index.d.ts",
42
+ "exports": {
43
+ ".": {
44
+ "types": "./dist/index.d.ts",
45
+ "import": "./dist/index.js"
46
+ }
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "src",
51
+ "openapi.json"
52
+ ],
53
+ "engines": {
54
+ "node": ">=20"
55
+ },
56
+ "scripts": {
57
+ "generate": "php ../../bin/polaris manifest --format=openapi --bootstrap=polaris.php > openapi.json && openapi-typescript openapi.json -o src/schema.d.ts && node scripts/generate-namespaces.mjs",
58
+ "typecheck": "tsc --noEmit",
59
+ "build": "tsc -p tsconfig.build.json",
60
+ "test": "vitest run"
61
+ },
62
+ "dependencies": {
63
+ "openapi-fetch": "^0.17.0"
64
+ },
65
+ "devDependencies": {
66
+ "@types/node": "^22.20.2",
67
+ "openapi-typescript": "^7.13.0",
68
+ "typescript": "^5.9.3",
69
+ "vitest": "^4.1.11"
70
+ }
71
+ }
package/src/admin.ts ADDED
@@ -0,0 +1,70 @@
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 `admin` plugin's routes as methods of `client.admin`. */
7
+ export function admin(client: Client<paths>) {
8
+ return {
9
+ /** POST /admin/users/{id}/ban: Ban a user */
10
+ banUser: (...init: Init<"/admin/users/{id}/ban", "post">) => client.POST("/admin/users/{id}/ban", ...init),
11
+ /** POST /admin/organizations/{id}/drains: Create an audit drain */
12
+ createDrain: (...init: Init<"/admin/organizations/{id}/drains", "post">) => client.POST("/admin/organizations/{id}/drains", ...init),
13
+ /** POST /admin/grants: Grant an admin role */
14
+ createGrant: (...init: Init<"/admin/grants", "post">) => client.POST("/admin/grants", ...init),
15
+ /** POST /admin/keys: Create an API key */
16
+ createKey: (...init: Init<"/admin/keys", "post">) => client.POST("/admin/keys", ...init),
17
+ /** DELETE /admin/organizations/{id}/drains/{drainId}: Delete an audit drain */
18
+ deleteDrain: (...init: Init<"/admin/organizations/{id}/drains/{drainId}", "delete">) => client.DELETE("/admin/organizations/{id}/drains/{drainId}", ...init),
19
+ /** DELETE /admin/grants/{id}: Revoke an admin grant */
20
+ deleteGrant: (...init: Init<"/admin/grants/{id}", "delete">) => client.DELETE("/admin/grants/{id}", ...init),
21
+ /** DELETE /admin/keys/{id}: Delete an API key */
22
+ deleteKey: (...init: Init<"/admin/keys/{id}", "delete">) => client.DELETE("/admin/keys/{id}", ...init),
23
+ /** DELETE /admin/organizations/{id}: Delete an organization */
24
+ deleteOrganization: (...init: Init<"/admin/organizations/{id}", "delete">) => client.DELETE("/admin/organizations/{id}", ...init),
25
+ /** DELETE /admin/users/{id}: Delete a user */
26
+ deleteUser: (...init: Init<"/admin/users/{id}", "delete">) => client.DELETE("/admin/users/{id}", ...init),
27
+ /** POST /admin/users/{id}/impersonate: Impersonate a user */
28
+ impersonateUser: (...init: Init<"/admin/users/{id}/impersonate", "post">) => client.POST("/admin/users/{id}/impersonate", ...init),
29
+ /** GET /admin/organizations/{id}/drains: List an organization's audit drains */
30
+ listDrains: (...init: Init<"/admin/organizations/{id}/drains", "get">) => client.GET("/admin/organizations/{id}/drains", ...init),
31
+ /** GET /admin/users/{id}/mfa: List a user's MFA factors */
32
+ listFactors: (...init: Init<"/admin/users/{id}/mfa", "get">) => client.GET("/admin/users/{id}/mfa", ...init),
33
+ /** GET /admin/grants: List the admin grants */
34
+ listGrants: (...init: Init<"/admin/grants", "get">) => client.GET("/admin/grants", ...init),
35
+ /** GET /admin/keys: List the API keys */
36
+ listKeys: (...init: Init<"/admin/keys", "get">) => client.GET("/admin/keys", ...init),
37
+ /** GET /admin/organizations: List the organizations */
38
+ listOrganizations: (...init: Init<"/admin/organizations", "get">) => client.GET("/admin/organizations", ...init),
39
+ /** GET /admin/users/{id}/sessions: List a user's sessions */
40
+ listSessions: (...init: Init<"/admin/users/{id}/sessions", "get">) => client.GET("/admin/users/{id}/sessions", ...init),
41
+ /** GET /admin/users: List the users */
42
+ listUsers: (...init: Init<"/admin/users", "get">) => client.GET("/admin/users", ...init),
43
+ /** GET /admin/audit: Query the audit trail */
44
+ queryAudit: (...init: Init<"/admin/audit", "get">) => client.GET("/admin/audit", ...init),
45
+ /** GET /admin/organizations/{id}: Read an organization */
46
+ readOrganization: (...init: Init<"/admin/organizations/{id}", "get">) => client.GET("/admin/organizations/{id}", ...init),
47
+ /** GET /admin/users/{id}: Read a user */
48
+ readUser: (...init: Init<"/admin/users/{id}", "get">) => client.GET("/admin/users/{id}", ...init),
49
+ /** DELETE /admin/users/{id}/mfa/{factorId}: Remove an MFA factor */
50
+ removeFactor: (...init: Init<"/admin/users/{id}/mfa/{factorId}", "delete">) => client.DELETE("/admin/users/{id}/mfa/{factorId}", ...init),
51
+ /** DELETE /admin/users/{id}/mfa: Reset a user's MFA */
52
+ resetMfa: (...init: Init<"/admin/users/{id}/mfa", "delete">) => client.DELETE("/admin/users/{id}/mfa", ...init),
53
+ /** DELETE /admin/users/{id}/sessions: Revoke every session */
54
+ revokeAllSessions: (...init: Init<"/admin/users/{id}/sessions", "delete">) => client.DELETE("/admin/users/{id}/sessions", ...init),
55
+ /** DELETE /admin/users/{id}/sessions/{sessionId}: Revoke a session */
56
+ revokeSession: (...init: Init<"/admin/users/{id}/sessions/{sessionId}", "delete">) => client.DELETE("/admin/users/{id}/sessions/{sessionId}", ...init),
57
+ /** POST /admin/users/{id}/password: Set a user's password */
58
+ setPassword: (...init: Init<"/admin/users/{id}/password", "post">) => client.POST("/admin/users/{id}/password", ...init),
59
+ /** GET /admin/stats: Read the instance statistics */
60
+ stats: (...init: Init<"/admin/stats", "get">) => client.GET("/admin/stats", ...init),
61
+ /** POST /admin/organizations/{id}/drains/{drainId}/test: Test an audit drain */
62
+ testDrain: (...init: Init<"/admin/organizations/{id}/drains/{drainId}/test", "post">) => client.POST("/admin/organizations/{id}/drains/{drainId}/test", ...init),
63
+ /** POST /admin/users/{id}/unban: Unban a user */
64
+ unbanUser: (...init: Init<"/admin/users/{id}/unban", "post">) => client.POST("/admin/users/{id}/unban", ...init),
65
+ /** PATCH /admin/organizations/{id}/members/{userId}/roles: Set a member's roles */
66
+ updateMemberRoles: (...init: Init<"/admin/organizations/{id}/members/{userId}/roles", "patch">) => client.PATCH("/admin/organizations/{id}/members/{userId}/roles", ...init),
67
+ };
68
+ }
69
+
70
+ export type AdminApi = ReturnType<typeof admin>;
@@ -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 `anonymous` plugin's routes as methods of `client.anonymous`. */
7
+ export function anonymous(client: Client<paths>) {
8
+ return {
9
+ /** POST /anonymous/convert: Convert the guest into an account */
10
+ convert: (...init: Init<"/anonymous/convert", "post">) => client.POST("/anonymous/convert", ...init),
11
+ /** POST /anonymous/sign-in: Sign in as a guest */
12
+ signIn: (...init: Init<"/anonymous/sign-in", "post">) => client.POST("/anonymous/sign-in", ...init),
13
+ };
14
+ }
15
+
16
+ export type AnonymousApi = ReturnType<typeof anonymous>;
package/src/audit.ts ADDED
@@ -0,0 +1,18 @@
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 `audit` plugin's routes as methods of `client.audit`. */
7
+ export function audit(client: Client<paths>) {
8
+ return {
9
+ /** GET /audit/me: List the audit events where the caller is the actor or the subject */
10
+ me: (...init: Init<"/audit/me", "get">) => client.GET("/audit/me", ...init),
11
+ /** GET /audit/organization/{id}: List an organization's audit events */
12
+ organization: (...init: Init<"/audit/organization/{id}", "get">) => client.GET("/audit/organization/{id}", ...init),
13
+ /** GET /audit/types: List the audit event names and their descriptions */
14
+ types: (...init: Init<"/audit/types", "get">) => client.GET("/audit/types", ...init),
15
+ };
16
+ }
17
+
18
+ export type AuditApi = ReturnType<typeof audit>;
@@ -0,0 +1,80 @@
1
+ import type { Middleware } from "openapi-fetch";
2
+
3
+ /** How the client answers a challenge of `polaris/sentinel`. */
4
+ export interface ChallengeOptions {
5
+ /**
6
+ * Asked for a captcha token when a request answers `403` with the `sentinel/challenge_required` problem
7
+ * and `challenge: captcha`; the same request is then sent once more with `captcha_token` added to its
8
+ * JSON body. The token comes from the captcha widget the host renders (Turnstile, hCaptcha).
9
+ */
10
+ captcha: () => Promise<string>;
11
+ }
12
+
13
+ const CHALLENGE_ERROR = "sentinel_challenge_required";
14
+ const CAPTCHA = "captcha";
15
+
16
+ /**
17
+ * The transparent challenge retry: the body of every request is kept by its id until the response is
18
+ * in; a captcha challenge asks the host for a token and replays the request once with it. Any other
19
+ * response, and the retried response itself, come back as they are, so a wrong token is one problem
20
+ * document and never a loop. A request without a JSON object body is not retried (nothing to add the token to).
21
+ */
22
+ export function challengeRetry(challenge: ChallengeOptions): Middleware {
23
+ const bodies = new Map<string, string>();
24
+
25
+ return {
26
+ async onRequest({ id, request }) {
27
+ bodies.set(id, await request.clone().text());
28
+ },
29
+ async onResponse({ id, request, response, options }) {
30
+ const fields = jsonFields(bodies.get(id) ?? "");
31
+ bodies.delete(id);
32
+ if (fields === null || response.status !== 403 || !(await isCaptchaChallenge(response))) {
33
+ return undefined;
34
+ }
35
+ const token = await challenge.captcha();
36
+
37
+ return options.fetch(
38
+ new Request(request.url, {
39
+ method: request.method,
40
+ headers: request.headers,
41
+ body: JSON.stringify({ ...fields, captcha_token: token }),
42
+ credentials: request.credentials,
43
+ signal: request.signal,
44
+ }),
45
+ );
46
+ },
47
+ onError({ id }) {
48
+ bodies.delete(id);
49
+ },
50
+ };
51
+ }
52
+
53
+ async function isCaptchaChallenge(response: Response): Promise<boolean> {
54
+ try {
55
+ const problem: unknown = await response.clone().json();
56
+
57
+ return (
58
+ typeof problem === "object" &&
59
+ problem !== null &&
60
+ (problem as { error?: unknown }).error === CHALLENGE_ERROR &&
61
+ (problem as { challenge?: unknown }).challenge === CAPTCHA
62
+ );
63
+ } catch {
64
+ return false;
65
+ }
66
+ }
67
+
68
+ /** The fields of a JSON object body; null for an empty or non-JSON-object body, which cannot take a `captcha_token`. */
69
+ function jsonFields(body: string): Record<string, unknown> | null {
70
+ if (body === "") {
71
+ return null;
72
+ }
73
+ try {
74
+ const parsed: unknown = JSON.parse(body);
75
+
76
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : null;
77
+ } catch {
78
+ return null;
79
+ }
80
+ }
package/src/index.ts ADDED
@@ -0,0 +1,111 @@
1
+ import createOpenApiClient, { type Client, type ClientOptions } from "openapi-fetch";
2
+ import { admin, type AdminApi } from "./admin.js";
3
+ import { anonymous, type AnonymousApi } from "./anonymous.js";
4
+ import { audit, type AuditApi } from "./audit.js";
5
+ import { challengeRetry, type ChallengeOptions } from "./challenge.js";
6
+ import { multiSession, type MultiSessionApi } from "./multi-session.js";
7
+ import { passwordless, type PasswordlessApi } from "./passwordless.js";
8
+ import { sentinel, type SentinelApi } from "./sentinel.js";
9
+ import { scim, type ScimApi } from "./scim.js";
10
+ import { sso, type SsoApi } from "./sso.js";
11
+ import { username, type UsernameApi } from "./username.js";
12
+ import type { components, paths } from "./schema.js";
13
+
14
+ export type { components, operations, paths } from "./schema.js";
15
+ export { admin, type AdminApi } from "./admin.js";
16
+ export { anonymous, type AnonymousApi } from "./anonymous.js";
17
+ export { audit, type AuditApi } from "./audit.js";
18
+ export { challengeRetry, type ChallengeOptions } from "./challenge.js";
19
+ export { multiSession, type MultiSessionApi } from "./multi-session.js";
20
+ export { passwordless, type PasswordlessApi } from "./passwordless.js";
21
+ export { sentinel, type SentinelApi } from "./sentinel.js";
22
+ export { scim, type ScimApi } from "./scim.js";
23
+ export { sso, type SsoApi } from "./sso.js";
24
+ export { username, type UsernameApi } from "./username.js";
25
+
26
+ /** The `{ error, message }` envelope every non-2xx response of a core route carries. */
27
+ export type ErrorBody = components["schemas"]["Error"];
28
+ /** The `{ errors: [...] }` envelope of a core route's 422. */
29
+ export type ValidationErrorBody = components["schemas"]["ValidationError"];
30
+ /** The RFC 9457 problem document every non-2xx response of a plugin route (`audit`, `admin`, `sentinel`, `sso`, `scim`, `passwordless`, `username`, `anonymous`, `multi-session`) carries. */
31
+ export type ProblemBody = components["schemas"]["Problem"];
32
+
33
+ export interface PolarisClientOptions extends ClientOptions {
34
+ /** Where Polaris is mounted: `https://app.example.com`, or `https://app.example.com/api/auth` behind a prefix. */
35
+ baseUrl: string;
36
+ /** Sent as `Authorization: Bearer` on every request: an access token, the `mfa_token` for the MFA gate, or an admin API key (`pak_...`). */
37
+ token?: string | null;
38
+ /**
39
+ * How to answer a `polaris/sentinel` challenge: with `captcha`, a `403 sentinel/challenge_required`
40
+ * with `challenge: captcha` asks it for a token and retries the request once with `captcha_token`
41
+ * in the body. Without it the problem document is returned as any other error.
42
+ */
43
+ challenge?: ChallengeOptions;
44
+ }
45
+
46
+ export interface PolarisClient extends Client<paths> {
47
+ /** The token this client sends; null when anonymous. */
48
+ readonly token: string | null;
49
+ /** The `polaris/audit` routes: `client.audit.me()`, `organization()`, `types()`. */
50
+ readonly audit: AuditApi;
51
+ /** The `polaris/admin` routes for an operator (an admin user's token or an API key): `client.admin.listUsers()`, ... */
52
+ readonly admin: AdminApi;
53
+ /** The `polaris/sentinel` operator routes: `client.sentinel.listDecisions()`, `listIpRules()`, `createIpRule()`, `deleteIpRule()`, `unblock()`. */
54
+ readonly sentinel: SentinelApi;
55
+ /** The `polaris/sso` routes: `client.sso.signIn()`, `exchange()`, the organization's providers and domains, the operators' list. */
56
+ readonly sso: SsoApi;
57
+ /** The `polaris/scim` routes: the organization's connections, the operators' list, and the SCIM server itself for a directory client. */
58
+ readonly scim: ScimApi;
59
+ /** The `polaris/passwordless` routes: `client.passwordless.magicLinkSend()`, `magicLinkExchange()`, `emailOtpSend()`, `emailOtpVerify()`, `phoneSend()`, `phoneVerify()`, `oneTimeTokenGenerate()`, ... */
60
+ readonly passwordless: PasswordlessApi;
61
+ /** The `polaris/username` routes: `client.username.signIn()` (a username or an email) and `update()`. */
62
+ readonly username: UsernameApi;
63
+ /** The `polaris/anonymous` routes: `client.anonymous.signIn()` for a guest and `convert()` once it has an account. */
64
+ readonly anonymous: AnonymousApi;
65
+ /**
66
+ * The `polaris/multi-session` routes: `client.multiSession.list()`, `switch()`, `revoke()`, `lastMethod()`.
67
+ * The device travels as the `X-Polaris-Device` header a sign-in answers (or the HttpOnly cookie in a browser).
68
+ */
69
+ readonly multiSession: MultiSessionApi;
70
+ /** A new client on the same options bound to another token (null for anonymous); this one is unchanged. */
71
+ withToken(token: string | null): PolarisClient;
72
+ }
73
+
74
+ /**
75
+ * An `openapi-fetch` client typed by `paths` (generated from `polaris manifest --format=openapi`), so
76
+ * `client.POST("/auth/login", { body })` checks the body and types `data` and `error`; the plugins' routes
77
+ * are also methods of `client.audit`, `client.admin`, `client.sentinel`, `client.sso`, `client.scim`, `client.passwordless`,
78
+ * `client.username`, `client.anonymous` and `client.multiSession`; `challenge.captcha`
79
+ * answers a sentinel captcha challenge with one retry. No refresh loop and no storage: when to refresh
80
+ * and where to keep tokens is the application's policy.
81
+ */
82
+ export function createClient(options: PolarisClientOptions): PolarisClient {
83
+ const { token = null, challenge, ...clientOptions } = options;
84
+ const client = createOpenApiClient<paths>(clientOptions);
85
+ if (challenge !== undefined) {
86
+ client.use(challengeRetry(challenge));
87
+ }
88
+ if (token !== null) {
89
+ client.use({
90
+ onRequest({ request }) {
91
+ request.headers.set("Authorization", `Bearer ${token}`);
92
+ return request;
93
+ },
94
+ });
95
+ }
96
+
97
+ return {
98
+ ...client,
99
+ token,
100
+ audit: audit(client),
101
+ admin: admin(client),
102
+ sentinel: sentinel(client),
103
+ sso: sso(client),
104
+ scim: scim(client),
105
+ passwordless: passwordless(client),
106
+ username: username(client),
107
+ anonymous: anonymous(client),
108
+ multiSession: multiSession(client),
109
+ withToken: (next: string | null) => createClient({ ...options, token: next }),
110
+ };
111
+ }
@@ -0,0 +1,20 @@
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 `multi-session` plugin's routes as methods of `client.multiSession`. */
7
+ export function multiSession(client: Client<paths>) {
8
+ return {
9
+ /** GET /multi-session/last-method: Read the device's last sign-in method */
10
+ lastMethod: (...init: Init<"/multi-session/last-method", "get">) => client.GET("/multi-session/last-method", ...init),
11
+ /** GET /multi-session/list: List the accounts signed in on this device */
12
+ list: (...init: Init<"/multi-session/list", "get">) => client.GET("/multi-session/list", ...init),
13
+ /** DELETE /multi-session/{sessionId}: Sign one account out of this device */
14
+ revoke: (...init: Init<"/multi-session/{sessionId}", "delete">) => client.DELETE("/multi-session/{sessionId}", ...init),
15
+ /** POST /multi-session/switch: Switch to another account signed in on this device */
16
+ switch: (...init: Init<"/multi-session/switch", "post">) => client.POST("/multi-session/switch", ...init),
17
+ };
18
+ }
19
+
20
+ export type MultiSessionApi = ReturnType<typeof multiSession>;
@@ -0,0 +1,13 @@
1
+ import type { MaybeOptionalInit } from "openapi-fetch";
2
+ import type { paths } from "./schema.js";
3
+
4
+ type RequiredKeysOf<T> = { [K in keyof T]-?: object extends Pick<T, K> ? never : K }[keyof T];
5
+
6
+ /**
7
+ * The argument list of a namespaced method: `openapi-fetch`'s init for the route, required when the
8
+ * route has required params or a body, optional otherwise (the same rule as `client.GET(url, init)`).
9
+ */
10
+ export type Init<Path extends keyof paths, Method extends keyof paths[Path]> =
11
+ RequiredKeysOf<MaybeOptionalInit<paths[Path], Method>> extends never
12
+ ? [(MaybeOptionalInit<paths[Path], Method> & { [key: string]: unknown })?]
13
+ : [MaybeOptionalInit<paths[Path], Method> & { [key: string]: unknown }];
@@ -0,0 +1,38 @@
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 `passwordless` plugin's routes as methods of `client.passwordless`. */
7
+ export function passwordless(client: Client<paths>) {
8
+ return {
9
+ /** POST /email-otp/reset-password: Reset the password with an email code */
10
+ emailOtpResetPassword: (...init: Init<"/email-otp/reset-password", "post">) => client.POST("/email-otp/reset-password", ...init),
11
+ /** POST /email-otp/send: Send an email code */
12
+ emailOtpSend: (...init: Init<"/email-otp/send", "post">) => client.POST("/email-otp/send", ...init),
13
+ /** POST /email-otp/verify: Sign in with an email code */
14
+ emailOtpVerify: (...init: Init<"/email-otp/verify", "post">) => client.POST("/email-otp/verify", ...init),
15
+ /** POST /email-otp/verify-email: Verify the email with a code */
16
+ emailOtpVerifyEmail: (...init: Init<"/email-otp/verify-email", "post">) => client.POST("/email-otp/verify-email", ...init),
17
+ /** POST /magic-link/exchange: Exchange the magic link's code for the session */
18
+ magicLinkExchange: (...init: Init<"/magic-link/exchange", "post">) => client.POST("/magic-link/exchange", ...init),
19
+ /** POST /magic-link/send: Send a magic link */
20
+ magicLinkSend: (...init: Init<"/magic-link/send", "post">) => client.POST("/magic-link/send", ...init),
21
+ /** GET /magic-link/verify: Open a magic link */
22
+ magicLinkVerify: (...init: Init<"/magic-link/verify", "get">) => client.GET("/magic-link/verify", ...init),
23
+ /** POST /one-time-token/generate: Generate a one-time token */
24
+ oneTimeTokenGenerate: (...init: Init<"/one-time-token/generate", "post">) => client.POST("/one-time-token/generate", ...init),
25
+ /** POST /one-time-token/verify: Sign in with a one-time token */
26
+ oneTimeTokenVerify: (...init: Init<"/one-time-token/verify", "post">) => client.POST("/one-time-token/verify", ...init),
27
+ /** POST /phone/add: Add a phone number */
28
+ phoneAdd: (...init: Init<"/phone/add", "post">) => client.POST("/phone/add", ...init),
29
+ /** POST /phone/confirm: Confirm a phone number */
30
+ phoneConfirm: (...init: Init<"/phone/confirm", "post">) => client.POST("/phone/confirm", ...init),
31
+ /** POST /phone/send: Send a phone sign-in code */
32
+ phoneSend: (...init: Init<"/phone/send", "post">) => client.POST("/phone/send", ...init),
33
+ /** POST /phone/verify: Sign in with a phone code */
34
+ phoneVerify: (...init: Init<"/phone/verify", "post">) => client.POST("/phone/verify", ...init),
35
+ };
36
+ }
37
+
38
+ export type PasswordlessApi = ReturnType<typeof passwordless>;