@polaris-auth/client 0.7.0 → 0.9.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 +38 -3
- package/dist/api-keys.d.ts +2657 -0
- package/dist/api-keys.js +19 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +14 -1
- package/dist/oauth.d.ts +8556 -0
- package/dist/oauth.js +57 -0
- package/dist/passkey.d.ts +2028 -0
- package/dist/passkey.js +19 -0
- package/dist/social.d.ts +2791 -0
- package/dist/social.js +23 -0
- package/dist/webauthn.d.ts +27 -0
- package/dist/webauthn.js +129 -0
- package/openapi.json +7332 -1
- package/package.json +18 -3
- package/src/api-keys.ts +26 -0
- package/src/index.ts +23 -2
- package/src/oauth.ts +64 -0
- package/src/passkey.ts +26 -0
- package/src/schema.d.ts +8501 -4043
- package/src/social.ts +30 -0
- package/src/webauthn.ts +172 -0
package/dist/api-keys.js
ADDED
|
@@ -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
|
@@ -4,9 +4,13 @@ import { type AnonymousApi } from "./anonymous.js";
|
|
|
4
4
|
import { type AuditApi } from "./audit.js";
|
|
5
5
|
import { type ChallengeOptions } from "./challenge.js";
|
|
6
6
|
import { type MultiSessionApi } from "./multi-session.js";
|
|
7
|
+
import { type PasskeyApi } from "./passkey.js";
|
|
7
8
|
import { type PasswordlessApi } from "./passwordless.js";
|
|
8
9
|
import { type SentinelApi } from "./sentinel.js";
|
|
9
10
|
import { type ScimApi } from "./scim.js";
|
|
11
|
+
import { type SocialApi } from "./social.js";
|
|
12
|
+
import { type ApiKeysApi } from "./api-keys.js";
|
|
13
|
+
import { type OauthApi } from "./oauth.js";
|
|
10
14
|
import { type SsoApi } from "./sso.js";
|
|
11
15
|
import { type UsernameApi } from "./username.js";
|
|
12
16
|
import type { components, paths } from "./schema.js";
|
|
@@ -16,16 +20,21 @@ export { anonymous, type AnonymousApi } from "./anonymous.js";
|
|
|
16
20
|
export { audit, type AuditApi } from "./audit.js";
|
|
17
21
|
export { challengeRetry, type ChallengeOptions } from "./challenge.js";
|
|
18
22
|
export { multiSession, type MultiSessionApi } from "./multi-session.js";
|
|
23
|
+
export { passkey, type PasskeyApi } from "./passkey.js";
|
|
19
24
|
export { passwordless, type PasswordlessApi } from "./passwordless.js";
|
|
20
25
|
export { sentinel, type SentinelApi } from "./sentinel.js";
|
|
21
26
|
export { scim, type ScimApi } from "./scim.js";
|
|
27
|
+
export { social, type SocialApi } from "./social.js";
|
|
28
|
+
export { apiKeys, type ApiKeysApi } from "./api-keys.js";
|
|
29
|
+
export { oauth, type OauthApi } from "./oauth.js";
|
|
22
30
|
export { sso, type SsoApi } from "./sso.js";
|
|
23
31
|
export { username, type UsernameApi } from "./username.js";
|
|
32
|
+
export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAvailable, type SignInWithPasskeyOptions } from "./webauthn.js";
|
|
24
33
|
/** The `{ error, message }` envelope every non-2xx response of a core route carries. */
|
|
25
34
|
export type ErrorBody = components["schemas"]["Error"];
|
|
26
35
|
/** The `{ errors: [...] }` envelope of a core route's 422. */
|
|
27
36
|
export type ValidationErrorBody = components["schemas"]["ValidationError"];
|
|
28
|
-
/** The RFC 9457 problem document every non-2xx response of a plugin route (`audit`, `admin`, `sentinel`, `sso`, `scim`, `passwordless`, `username`, `anonymous`, `multi-session`) carries. */
|
|
37
|
+
/** 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. */
|
|
29
38
|
export type ProblemBody = components["schemas"]["Problem"];
|
|
30
39
|
export interface PolarisClientOptions extends ClientOptions {
|
|
31
40
|
/** Where Polaris is mounted: `https://app.example.com`, or `https://app.example.com/api/auth` behind a prefix. */
|
|
@@ -63,6 +72,14 @@ export interface PolarisClient extends Client<paths> {
|
|
|
63
72
|
* The device travels as the `X-Polaris-Device` header a sign-in answers (or the HttpOnly cookie in a browser).
|
|
64
73
|
*/
|
|
65
74
|
readonly multiSession: MultiSessionApi;
|
|
75
|
+
/** The `polaris/social` routes: `client.social.start()`, `exchange()`, `oneTap()`, `accounts()`, `link()`, `unlink()`, `token()`. */
|
|
76
|
+
readonly social: SocialApi;
|
|
77
|
+
/** The `polaris/passkey` routes (`registerOptions()`, `registerVerify()`, `authenticateOptions()`, `authenticateVerify()`, `list()`, `rename()`, `delete()`); `registerPasskey()` and `signInWithPasskey()` run the browser ceremonies. */
|
|
78
|
+
readonly passkey: PasskeyApi;
|
|
79
|
+
/** 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. */
|
|
80
|
+
readonly apiKeys: ApiKeysApi;
|
|
81
|
+
/** The `polaris/oauth-provider` routes: `client.oauth.authorize()`, `decision()`, `token()`, `userinfo()`, `revoke()`, `introspect()`, `register()`, the device, CIBA, consent, client-management and discovery methods. */
|
|
82
|
+
readonly oauth: OauthApi;
|
|
66
83
|
/** A new client on the same options bound to another token (null for anonymous); this one is unchanged. */
|
|
67
84
|
withToken(token: string | null): PolarisClient;
|
|
68
85
|
}
|
|
@@ -70,7 +87,7 @@ export interface PolarisClient extends Client<paths> {
|
|
|
70
87
|
* An `openapi-fetch` client typed by `paths` (generated from `polaris manifest --format=openapi`), so
|
|
71
88
|
* `client.POST("/auth/login", { body })` checks the body and types `data` and `error`; the plugins' routes
|
|
72
89
|
* are also methods of `client.audit`, `client.admin`, `client.sentinel`, `client.sso`, `client.scim`, `client.passwordless`,
|
|
73
|
-
* `client.username`, `client.anonymous` and `client.
|
|
90
|
+
* `client.username`, `client.anonymous`, `client.multiSession`, `client.social`, `client.passkey`, `client.apiKeys` and `client.oauth`; `challenge.captcha`
|
|
74
91
|
* answers a sentinel captcha challenge with one retry. No refresh loop and no storage: when to refresh
|
|
75
92
|
* and where to keep tokens is the application's policy.
|
|
76
93
|
*/
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,13 @@ import { anonymous } from "./anonymous.js";
|
|
|
4
4
|
import { audit } from "./audit.js";
|
|
5
5
|
import { challengeRetry } from "./challenge.js";
|
|
6
6
|
import { multiSession } from "./multi-session.js";
|
|
7
|
+
import { passkey } from "./passkey.js";
|
|
7
8
|
import { passwordless } from "./passwordless.js";
|
|
8
9
|
import { sentinel } from "./sentinel.js";
|
|
9
10
|
import { scim } from "./scim.js";
|
|
11
|
+
import { social } from "./social.js";
|
|
12
|
+
import { apiKeys } from "./api-keys.js";
|
|
13
|
+
import { oauth } from "./oauth.js";
|
|
10
14
|
import { sso } from "./sso.js";
|
|
11
15
|
import { username } from "./username.js";
|
|
12
16
|
export { admin } from "./admin.js";
|
|
@@ -14,16 +18,21 @@ export { anonymous } from "./anonymous.js";
|
|
|
14
18
|
export { audit } from "./audit.js";
|
|
15
19
|
export { challengeRetry } from "./challenge.js";
|
|
16
20
|
export { multiSession } from "./multi-session.js";
|
|
21
|
+
export { passkey } from "./passkey.js";
|
|
17
22
|
export { passwordless } from "./passwordless.js";
|
|
18
23
|
export { sentinel } from "./sentinel.js";
|
|
19
24
|
export { scim } from "./scim.js";
|
|
25
|
+
export { social } from "./social.js";
|
|
26
|
+
export { apiKeys } from "./api-keys.js";
|
|
27
|
+
export { oauth } from "./oauth.js";
|
|
20
28
|
export { sso } from "./sso.js";
|
|
21
29
|
export { username } from "./username.js";
|
|
30
|
+
export { registerPasskey, signInWithPasskey, passkeyAssertion, passkeyAutofillAvailable } from "./webauthn.js";
|
|
22
31
|
/**
|
|
23
32
|
* An `openapi-fetch` client typed by `paths` (generated from `polaris manifest --format=openapi`), so
|
|
24
33
|
* `client.POST("/auth/login", { body })` checks the body and types `data` and `error`; the plugins' routes
|
|
25
34
|
* are also methods of `client.audit`, `client.admin`, `client.sentinel`, `client.sso`, `client.scim`, `client.passwordless`,
|
|
26
|
-
* `client.username`, `client.anonymous` and `client.
|
|
35
|
+
* `client.username`, `client.anonymous`, `client.multiSession`, `client.social`, `client.passkey`, `client.apiKeys` and `client.oauth`; `challenge.captcha`
|
|
27
36
|
* answers a sentinel captcha challenge with one retry. No refresh loop and no storage: when to refresh
|
|
28
37
|
* and where to keep tokens is the application's policy.
|
|
29
38
|
*/
|
|
@@ -53,6 +62,10 @@ export function createClient(options) {
|
|
|
53
62
|
username: username(client),
|
|
54
63
|
anonymous: anonymous(client),
|
|
55
64
|
multiSession: multiSession(client),
|
|
65
|
+
social: social(client),
|
|
66
|
+
passkey: passkey(client),
|
|
67
|
+
apiKeys: apiKeys(client),
|
|
68
|
+
oauth: oauth(client),
|
|
56
69
|
withToken: (next) => createClient({ ...options, token: next }),
|
|
57
70
|
};
|
|
58
71
|
}
|