@atlasauth/react 0.4.1 → 0.5.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/CHANGELOG.md +196 -0
- package/dist/AtlasProvider.d.ts +48 -7
- package/dist/AtlasProvider.js +115 -22
- package/dist/AtlasProvider.js.map +1 -1
- package/dist/api-keys.d.ts +63 -0
- package/dist/api-keys.js +227 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/appearance.d.ts +25 -0
- package/dist/appearance.js +56 -1
- package/dist/appearance.js.map +1 -1
- package/dist/captcha.d.ts +43 -0
- package/dist/captcha.js +109 -0
- package/dist/captcha.js.map +1 -0
- package/dist/components.d.ts +2 -0
- package/dist/components.js +4 -1
- package/dist/components.js.map +1 -1
- package/dist/contrast.d.ts +16 -0
- package/dist/contrast.js +57 -0
- package/dist/contrast.js.map +1 -0
- package/dist/flow.d.ts +17 -2
- package/dist/flow.js +88 -9
- package/dist/flow.js.map +1 -1
- package/dist/hooks.d.ts +7 -2
- package/dist/hooks.js.map +1 -1
- package/dist/i18n.js +44 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/instance-settings.d.ts +7 -0
- package/dist/instance-settings.js +12 -0
- package/dist/instance-settings.js.map +1 -0
- package/dist/sign-in.js +3 -2
- package/dist/sign-in.js.map +1 -1
- package/dist/sign-up.d.ts +13 -0
- package/dist/sign-up.js +120 -2
- package/dist/sign-up.js.map +1 -1
- package/dist/styles.d.ts +14 -2
- package/dist/styles.js +30 -13
- package/dist/styles.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CreateUserApiKeyInput, type CreatedUserApiKey, type UserApiKey } from '@atlasauth/js';
|
|
3
|
+
import { useReverification } from './reverification';
|
|
4
|
+
/**
|
|
5
|
+
* End-user API key self-service — the signed-in user's OWN `ak_` keys (or, with
|
|
6
|
+
* `organizationId`, their active organization's), over `/v1/client/me/api_keys`.
|
|
7
|
+
*
|
|
8
|
+
* `useApiKeys()` is the headless half: list + create + rename + revoke, with the
|
|
9
|
+
* step-up wired in — creating a key on a stale session parks the call and flips
|
|
10
|
+
* `reverification.needsReverification`; `completeReverification({ strategy:
|
|
11
|
+
* 'password', password })` re-authenticates in place and finishes the create.
|
|
12
|
+
* `<ApiKeys/>` is the drop-in UI built on it.
|
|
13
|
+
*/
|
|
14
|
+
export type ApiKeysStatus = 'loading' | 'ready' | 'disabled' | 'error';
|
|
15
|
+
export interface UseApiKeysResult {
|
|
16
|
+
status: ApiKeysStatus;
|
|
17
|
+
keys: UserApiKey[];
|
|
18
|
+
/** The scopes / claim names a new key may carry (instance allowlists). */
|
|
19
|
+
allowedScopes: string[];
|
|
20
|
+
allowedClaims: string[];
|
|
21
|
+
maxActiveKeys: number;
|
|
22
|
+
activeCount: number;
|
|
23
|
+
error: string | null;
|
|
24
|
+
reload(): Promise<void>;
|
|
25
|
+
/** Create a key. Resolves with the one-time `secret`; parks for reverification on a stale session. */
|
|
26
|
+
createKey(input?: Omit<CreateUserApiKeyInput, 'organizationId'>): Promise<CreatedUserApiKey>;
|
|
27
|
+
renameKey(id: string, name: string | null): Promise<UserApiKey>;
|
|
28
|
+
revokeKey(id: string): Promise<void>;
|
|
29
|
+
reverification: ReturnType<typeof useReverification>;
|
|
30
|
+
}
|
|
31
|
+
export declare function useApiKeys(options?: {
|
|
32
|
+
organizationId?: string;
|
|
33
|
+
}): UseApiKeysResult;
|
|
34
|
+
/** What a claims slot receives: the draft claims and a setter, scoped to the allowlist. */
|
|
35
|
+
export interface ApiKeyClaimsFieldsContext {
|
|
36
|
+
claims: Record<string, unknown>;
|
|
37
|
+
/** Set (or, with `undefined`, remove) one claim on the key being created. */
|
|
38
|
+
setClaim(name: string, value: unknown): void;
|
|
39
|
+
/** The claim names the application lets a user set. Others are refused by the server. */
|
|
40
|
+
allowedClaims: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface ApiKeysProps {
|
|
43
|
+
/** Manage this (active) organization's keys instead of the user's own. */
|
|
44
|
+
organizationId?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Extra create-form fields whose values go into the key's `claims` — e.g. a
|
|
47
|
+
* spend limit. Only claim names the application allows are accepted.
|
|
48
|
+
*/
|
|
49
|
+
renderClaimsFields?: (ctx: ApiKeyClaimsFieldsContext) => ReactNode;
|
|
50
|
+
/** Alias of `renderClaimsFields`. */
|
|
51
|
+
claimsForm?: (ctx: ApiKeyClaimsFieldsContext) => ReactNode;
|
|
52
|
+
/** Called with the newly created key (including its one-time `secret`). */
|
|
53
|
+
onCreate?: (key: CreatedUserApiKey) => void;
|
|
54
|
+
/** Expiry choices offered, in days. `0` means never. Default `[0, 30, 90, 365]`. */
|
|
55
|
+
expiryOptionsDays?: number[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Drop-in API key manager: list, create (with the reverification prompt when the
|
|
59
|
+
* session is stale), show the new secret once with a copy button, rename, and
|
|
60
|
+
* revoke with a confirmation step.
|
|
61
|
+
*/
|
|
62
|
+
export declare function ApiKeys(props: ApiKeysProps): import("react").JSX.Element | null;
|
|
63
|
+
export type { CreateUserApiKeyInput, CreatedUserApiKey, UserApiKey } from '@atlasauth/js';
|
package/dist/api-keys.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useApiKeys = useApiKeys;
|
|
4
|
+
exports.ApiKeys = ApiKeys;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const js_1 = require("@atlasauth/js");
|
|
8
|
+
const reverification_1 = require("./reverification");
|
|
9
|
+
const components_shared_1 = require("./components-shared");
|
|
10
|
+
function useApiKeys(options = {}) {
|
|
11
|
+
const { organizationId } = options;
|
|
12
|
+
const client = (0, components_shared_1.useMeClient)();
|
|
13
|
+
const reverification = (0, reverification_1.useReverification)();
|
|
14
|
+
const { withReverification } = reverification;
|
|
15
|
+
const [status, setStatus] = (0, react_1.useState)('loading');
|
|
16
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
17
|
+
const [list, setList] = (0, react_1.useState)({ data: [], allowedScopes: [], allowedClaims: [], maxActiveKeys: 0, activeCount: 0 });
|
|
18
|
+
const reload = (0, react_1.useCallback)(async () => {
|
|
19
|
+
try {
|
|
20
|
+
const next = await (0, js_1.listApiKeys)(client, { organizationId });
|
|
21
|
+
setList(next);
|
|
22
|
+
setStatus('ready');
|
|
23
|
+
setError(null);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
// A 403 on the LIST means the feature is off (or org keys are, or the role
|
|
27
|
+
// lacks the permission) — render nothing actionable rather than an error.
|
|
28
|
+
if (err instanceof js_1.ApiKeyRequestError && err.status === 403) {
|
|
29
|
+
setStatus('disabled');
|
|
30
|
+
setError(err.message);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setStatus('error');
|
|
34
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
35
|
+
}
|
|
36
|
+
}, [client, organizationId]);
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
void reload();
|
|
39
|
+
}, [reload]);
|
|
40
|
+
const createKey = (0, react_1.useCallback)(async (input = {}) => {
|
|
41
|
+
const created = await withReverification(() => (0, js_1.createApiKey)(client, { ...input, ...(organizationId ? { organizationId } : {}) }));
|
|
42
|
+
await reload();
|
|
43
|
+
return created;
|
|
44
|
+
}, [client, organizationId, reload, withReverification]);
|
|
45
|
+
const renameKey = (0, react_1.useCallback)(async (id, name) => {
|
|
46
|
+
const updated = await (0, js_1.updateApiKey)(client, id, { name });
|
|
47
|
+
await reload();
|
|
48
|
+
return updated;
|
|
49
|
+
}, [client, reload]);
|
|
50
|
+
const revokeKey = (0, react_1.useCallback)(async (id) => {
|
|
51
|
+
await (0, js_1.revokeApiKey)(client, id);
|
|
52
|
+
await reload();
|
|
53
|
+
}, [client, reload]);
|
|
54
|
+
return {
|
|
55
|
+
status,
|
|
56
|
+
keys: list.data,
|
|
57
|
+
allowedScopes: list.allowedScopes,
|
|
58
|
+
allowedClaims: list.allowedClaims,
|
|
59
|
+
maxActiveKeys: list.maxActiveKeys,
|
|
60
|
+
activeCount: list.activeCount,
|
|
61
|
+
error,
|
|
62
|
+
reload,
|
|
63
|
+
createKey,
|
|
64
|
+
renameKey,
|
|
65
|
+
revokeKey,
|
|
66
|
+
reverification,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function formatLimit(value) {
|
|
70
|
+
if (value === null || value === undefined)
|
|
71
|
+
return '—';
|
|
72
|
+
if (typeof value === 'object')
|
|
73
|
+
return JSON.stringify(value);
|
|
74
|
+
return String(value);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Drop-in API key manager: list, create (with the reverification prompt when the
|
|
78
|
+
* session is stale), show the new secret once with a copy button, rename, and
|
|
79
|
+
* revoke with a confirmation step.
|
|
80
|
+
*/
|
|
81
|
+
function ApiKeys(props) {
|
|
82
|
+
const { organizationId, onCreate, expiryOptionsDays = [0, 30, 90, 365] } = props;
|
|
83
|
+
const renderClaims = props.renderClaimsFields ?? props.claimsForm;
|
|
84
|
+
const api = useApiKeys({ organizationId });
|
|
85
|
+
const t = (0, components_shared_1.useText)();
|
|
86
|
+
const cardClass = (0, components_shared_1.useClass)('card', 'atlas-card');
|
|
87
|
+
const cls = (0, components_shared_1.useClasses)();
|
|
88
|
+
const [creating, setCreating] = (0, react_1.useState)(false);
|
|
89
|
+
const [name, setName] = (0, react_1.useState)('');
|
|
90
|
+
const [expiryDays, setExpiryDays] = (0, react_1.useState)(expiryOptionsDays[0] ?? 0);
|
|
91
|
+
const [scopes, setScopes] = (0, react_1.useState)([]);
|
|
92
|
+
const [claims, setClaims] = (0, react_1.useState)({});
|
|
93
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
94
|
+
const [formError, setFormError] = (0, react_1.useState)(null);
|
|
95
|
+
const [secret, setSecret] = (0, react_1.useState)(null);
|
|
96
|
+
const [copied, setCopied] = (0, react_1.useState)(false);
|
|
97
|
+
const [renaming, setRenaming] = (0, react_1.useState)(null);
|
|
98
|
+
const [confirmRevoke, setConfirmRevoke] = (0, react_1.useState)(null);
|
|
99
|
+
const [password, setPassword] = (0, react_1.useState)('');
|
|
100
|
+
const [reauthError, setReauthError] = (0, react_1.useState)(null);
|
|
101
|
+
const claimsCtx = (0, react_1.useMemo)(() => ({
|
|
102
|
+
claims,
|
|
103
|
+
allowedClaims: api.allowedClaims,
|
|
104
|
+
setClaim: (claim, value) => setClaims((prev) => {
|
|
105
|
+
const next = { ...prev };
|
|
106
|
+
if (value === undefined)
|
|
107
|
+
delete next[claim];
|
|
108
|
+
else
|
|
109
|
+
next[claim] = value;
|
|
110
|
+
return next;
|
|
111
|
+
}),
|
|
112
|
+
}), [claims, api.allowedClaims]);
|
|
113
|
+
if (api.status === 'loading')
|
|
114
|
+
return null;
|
|
115
|
+
if (api.status === 'disabled') {
|
|
116
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: cardClass, "data-atlas": "api-keys", children: [(0, jsx_runtime_1.jsx)("h2", { className: cls('sectionTitle', 'atlas-section-title'), children: t('apiKeys.title') }), (0, jsx_runtime_1.jsx)("p", { className: cls('text', 'atlas-text'), "data-atlas": "api-keys-disabled", children: t('apiKeys.disabled') })] }));
|
|
117
|
+
}
|
|
118
|
+
const now = Date.now();
|
|
119
|
+
const atCap = api.maxActiveKeys > 0 && api.activeCount >= api.maxActiveKeys;
|
|
120
|
+
const resetForm = () => {
|
|
121
|
+
setCreating(false);
|
|
122
|
+
setName('');
|
|
123
|
+
setExpiryDays(expiryOptionsDays[0] ?? 0);
|
|
124
|
+
setScopes([]);
|
|
125
|
+
setClaims({});
|
|
126
|
+
setFormError(null);
|
|
127
|
+
};
|
|
128
|
+
const submit = async () => {
|
|
129
|
+
setBusy(true);
|
|
130
|
+
setFormError(null);
|
|
131
|
+
try {
|
|
132
|
+
const created = await api.createKey({
|
|
133
|
+
...(name.trim() ? { name: name.trim() } : {}),
|
|
134
|
+
...(expiryDays > 0 ? { expiresInSeconds: expiryDays * 24 * 60 * 60 } : {}),
|
|
135
|
+
...(scopes.length > 0 ? { scopes } : {}),
|
|
136
|
+
...(Object.keys(claims).length > 0 ? { claims } : {}),
|
|
137
|
+
});
|
|
138
|
+
setSecret(created.secret);
|
|
139
|
+
setCopied(false);
|
|
140
|
+
resetForm();
|
|
141
|
+
onCreate?.(created);
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
// A cancelled reverification is not an error worth showing.
|
|
145
|
+
if (!(err instanceof Error && err.message === 'Reverification cancelled.')) {
|
|
146
|
+
setFormError(err instanceof Error ? err.message : t('error.generic'));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
setBusy(false);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const confirmIdentity = async () => {
|
|
154
|
+
setReauthError(null);
|
|
155
|
+
try {
|
|
156
|
+
await api.reverification.completeReverification({ strategy: 'password', password });
|
|
157
|
+
setPassword('');
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
setReauthError(err instanceof Error ? err.message : t('error.generic'));
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const copy = async () => {
|
|
164
|
+
if (!secret)
|
|
165
|
+
return;
|
|
166
|
+
try {
|
|
167
|
+
await navigator.clipboard?.writeText(secret);
|
|
168
|
+
setCopied(true);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
/* the secret stays visible for manual copy */
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const saveRename = async () => {
|
|
175
|
+
if (!renaming)
|
|
176
|
+
return;
|
|
177
|
+
setBusy(true);
|
|
178
|
+
try {
|
|
179
|
+
await api.renameKey(renaming.id, renaming.name.trim() || null);
|
|
180
|
+
setRenaming(null);
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
setFormError(err instanceof Error ? err.message : t('error.generic'));
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
setBusy(false);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const revoke = async (id) => {
|
|
190
|
+
setBusy(true);
|
|
191
|
+
try {
|
|
192
|
+
await api.revokeKey(id);
|
|
193
|
+
setConfirmRevoke(null);
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
setFormError(err instanceof Error ? err.message : t('error.generic'));
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
setBusy(false);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const statusOf = (key) => {
|
|
203
|
+
if (key.revoked_at)
|
|
204
|
+
return t('apiKeys.revoked');
|
|
205
|
+
if (key.expires_at && key.expires_at <= now)
|
|
206
|
+
return t('apiKeys.expired');
|
|
207
|
+
return null;
|
|
208
|
+
};
|
|
209
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: cardClass, "data-atlas": "api-keys", children: [(0, jsx_runtime_1.jsx)("h2", { className: cls('sectionTitle', 'atlas-section-title'), children: t('apiKeys.title') }), (0, jsx_runtime_1.jsx)("p", { className: cls('text', 'atlas-text'), children: t(organizationId ? 'apiKeys.organizationSubtitle' : 'apiKeys.subtitle') }), api.error && api.status === 'error' ? ((0, jsx_runtime_1.jsx)("p", { className: cls('alert', 'atlas-alert'), role: "alert", children: api.error })) : null, secret ? ((0, jsx_runtime_1.jsxs)("div", { "data-atlas": "api-key-secret", role: "status", children: [(0, jsx_runtime_1.jsx)("p", { className: cls('text', 'atlas-text'), children: (0, jsx_runtime_1.jsx)("strong", { children: t('apiKeys.secretTitle') }) }), (0, jsx_runtime_1.jsx)("p", { className: cls('text', 'atlas-text'), children: t('apiKeys.secretHint') }), (0, jsx_runtime_1.jsx)("code", { "data-atlas": "api-key-secret-value", children: secret }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", onClick: () => void copy(), children: copied ? t('apiKeys.copied') : t('apiKeys.copy') }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", onClick: () => setSecret(null), children: t('apiKeys.done') })] })) : null, api.reverification.needsReverification ? ((0, jsx_runtime_1.jsxs)("div", { "data-atlas": "api-keys-reverification", role: "dialog", "aria-label": t('reverification.title'), children: [(0, jsx_runtime_1.jsx)("p", { className: cls('text', 'atlas-text'), children: (0, jsx_runtime_1.jsx)("strong", { children: t('reverification.title') }) }), (0, jsx_runtime_1.jsx)("p", { className: cls('text', 'atlas-text'), children: t('reverification.subtitle') }), (0, jsx_runtime_1.jsxs)("label", { className: cls('formField', 'atlas-field'), children: [(0, jsx_runtime_1.jsx)("span", { className: cls('formFieldLabel', 'atlas-field-label'), children: t('reverification.passwordLabel') }), (0, jsx_runtime_1.jsx)("input", { className: cls('formFieldInput', 'atlas-account-input'), type: "password", autoComplete: "current-password", value: password, onChange: (e) => setPassword(e.target.value) })] }), reauthError ? (0, jsx_runtime_1.jsx)("p", { className: cls('formFieldError', 'atlas-error'), role: "alert", children: reauthError }) : null, (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonPrimary', 'atlas-button'), type: "button", onClick: () => void confirmIdentity(), children: t('reverification.submit') }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", onClick: () => {
|
|
210
|
+
setPassword('');
|
|
211
|
+
setReauthError(null);
|
|
212
|
+
api.reverification.cancelReverification();
|
|
213
|
+
}, children: t('reverification.cancel') })] })) : null, api.keys.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: cls('text', 'atlas-text'), "data-atlas": "api-keys-empty", children: t('apiKeys.empty') })) : ((0, jsx_runtime_1.jsx)("ul", { className: cls('list', 'atlas-list'), "data-atlas": "api-keys-list", children: api.keys.map((key) => {
|
|
214
|
+
const state = statusOf(key);
|
|
215
|
+
const limits = key.limits && typeof key.limits === 'object' ? Object.entries(key.limits) : [];
|
|
216
|
+
return ((0, jsx_runtime_1.jsxs)("li", { className: cls('listItem', 'atlas-list-item'), "data-atlas": "api-key", children: [renaming?.id === key.id ? ((0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)("input", { className: cls('formFieldInput', 'atlas-account-input'), "aria-label": t('apiKeys.nameLabel'), value: renaming.name, onChange: (e) => setRenaming({ id: key.id, name: e.target.value }) }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", disabled: busy, onClick: () => void saveRename(), children: t('apiKeys.save') }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", onClick: () => setRenaming(null), children: t('apiKeys.cancel') })] })) : ((0, jsx_runtime_1.jsx)("strong", { children: key.name ?? t('apiKeys.unnamed') })), ' ', (0, jsx_runtime_1.jsxs)("code", { children: [key.prefix, "\u2026"] }), state ? (0, jsx_runtime_1.jsxs)("em", { children: [" \u2014 ", state] }) : null, (0, jsx_runtime_1.jsx)("div", { className: cls('text', 'atlas-text'), children: [
|
|
217
|
+
key.last_used_at
|
|
218
|
+
? t('apiKeys.lastUsed', { date: new Date(key.last_used_at).toLocaleDateString() })
|
|
219
|
+
: t('apiKeys.neverUsed'),
|
|
220
|
+
key.expires_at ? t('apiKeys.expiresOn', { date: new Date(key.expires_at).toLocaleDateString() }) : null,
|
|
221
|
+
key.scopes && key.scopes.length > 0 ? key.scopes.join(', ') : null,
|
|
222
|
+
]
|
|
223
|
+
.filter(Boolean)
|
|
224
|
+
.join(' · ') }), limits.length > 0 ? ((0, jsx_runtime_1.jsxs)("div", { className: cls('text', 'atlas-text'), "data-atlas": "api-key-limits", children: [t('apiKeys.limits'), ": ", limits.map(([k, v]) => `${k} ${formatLimit(v)}`).join(' · ')] })) : null, !key.revoked_at && renaming?.id !== key.id ? (confirmRevoke === key.id ? ((0, jsx_runtime_1.jsxs)("span", { "data-atlas": "api-key-revoke-confirm", children: [(0, jsx_runtime_1.jsx)("span", { className: cls('text', 'atlas-text'), children: t('apiKeys.revokeConfirm') }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", disabled: busy, onClick: () => void revoke(key.id), children: t('apiKeys.revokeConfirmButton') }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", onClick: () => setConfirmRevoke(null), children: t('apiKeys.cancel') })] })) : ((0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", onClick: () => setRenaming({ id: key.id, name: key.name ?? '' }), children: t('apiKeys.rename') }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", onClick: () => setConfirmRevoke(key.id), children: t('apiKeys.revoke') })] }))) : null] }, key.id));
|
|
225
|
+
}) })), formError ? (0, jsx_runtime_1.jsx)("p", { className: cls('alert', 'atlas-alert'), role: "alert", children: formError }) : null, creating ? ((0, jsx_runtime_1.jsxs)("div", { "data-atlas": "api-key-create", children: [(0, jsx_runtime_1.jsxs)("label", { className: cls('formField', 'atlas-field'), children: [(0, jsx_runtime_1.jsx)("span", { className: cls('formFieldLabel', 'atlas-field-label'), children: t('apiKeys.nameLabel') }), (0, jsx_runtime_1.jsx)("input", { className: cls('formFieldInput', 'atlas-account-input'), value: name, maxLength: 100, placeholder: t('apiKeys.namePlaceholder'), onChange: (e) => setName(e.target.value) })] }), (0, jsx_runtime_1.jsxs)("label", { className: cls('formField', 'atlas-field'), children: [(0, jsx_runtime_1.jsx)("span", { className: cls('formFieldLabel', 'atlas-field-label'), children: t('apiKeys.expiresLabel') }), (0, jsx_runtime_1.jsx)("select", { className: cls('formFieldInput', 'atlas-account-input'), value: String(expiryDays), onChange: (e) => setExpiryDays(Number(e.target.value)), children: expiryOptionsDays.map((days) => ((0, jsx_runtime_1.jsx)("option", { value: String(days), children: days > 0 ? t('apiKeys.expiresDays', { days: String(days) }) : t('apiKeys.expiresNever') }, days))) })] }), api.allowedScopes.length > 0 ? ((0, jsx_runtime_1.jsxs)("fieldset", { className: cls('formField', 'atlas-field'), children: [(0, jsx_runtime_1.jsx)("legend", { className: cls('formFieldLabel', 'atlas-field-label'), children: t('apiKeys.scopesLabel') }), api.allowedScopes.map((scope) => ((0, jsx_runtime_1.jsxs)("label", { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: scopes.includes(scope), onChange: (e) => setScopes((prev) => (e.target.checked ? [...prev, scope] : prev.filter((s) => s !== scope))) }), ' ', scope] }, scope)))] })) : null, renderClaims ? renderClaims(claimsCtx) : null, (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonPrimary', 'atlas-button'), type: "button", disabled: busy, onClick: () => void submit(), children: t('apiKeys.submit') }), (0, jsx_runtime_1.jsx)("button", { className: cls('formButtonSecondary', 'atlas-button-secondary'), type: "button", onClick: resetForm, children: t('apiKeys.cancel') })] })) : atCap ? ((0, jsx_runtime_1.jsx)("p", { className: cls('text', 'atlas-text'), "data-atlas": "api-keys-limit", children: t('apiKeys.limitReached', { max: String(api.maxActiveKeys) }) })) : ((0, jsx_runtime_1.jsx)("button", { className: cls('formButtonPrimary', 'atlas-button'), type: "button", onClick: () => setCreating(true), children: t('apiKeys.create') }))] }));
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=api-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../src/api-keys.tsx"],"names":[],"mappings":";;AA4CA,gCAgFC;AAsCD,0BAuUC;;AAzeD,iCAAkF;AAClF,sCASuB;AACvB,qDAAqD;AACrD,2DAAiF;AAgCjF,SAAgB,UAAU,CAAC,UAAuC,EAAE;I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,QAAQ,EAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,MAAM,EAAE,YACpH,CAAC,CAAC,gBAAgB,CAAC,GACb,EACT,mCAAQ,SAAS,EAAE,GAAG,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,EAAE,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,SAAS,YACtG,CAAC,CAAC,gBAAgB,CAAC,GACb,IACL,CACP,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CACV,8BAAG,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,gBAAa,gBAAgB,YACjE,CAAC,CAAC,sBAAsB,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,GAC5D,CACL,CAAC,CAAC,CAAC,CACF,mCAAQ,SAAS,EAAE,GAAG,CAAC,mBAAmB,EAAE,cAAc,CAAC,EAAE,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,YACxG,CAAC,CAAC,gBAAgB,CAAC,GACb,CACV,IACO,CACX,CAAC;AACJ,CAAC"}
|
package/dist/appearance.d.ts
CHANGED
|
@@ -29,6 +29,20 @@ export interface DesignTokens {
|
|
|
29
29
|
borderRadius?: string;
|
|
30
30
|
fontFamily?: string;
|
|
31
31
|
spacingUnit?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Text and icon colour on a `colorPrimary` fill (the primary button label,
|
|
34
|
+
* the avatar initials). Defaults to white or near-black, whichever contrasts
|
|
35
|
+
* more with the resolved `colorPrimary`. With a design active, an explicit
|
|
36
|
+
* value overrides the design's primary ink.
|
|
37
|
+
*/
|
|
38
|
+
colorTextOnPrimary?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The keyboard focus ring (a solid 2px outline on `:focus-visible`). Defaults
|
|
41
|
+
* to the resolved `colorPrimary`; pick a colour with at least 3:1 contrast
|
|
42
|
+
* against `colorBackground`. With a design active, an explicit value replaces
|
|
43
|
+
* the design's ring colour.
|
|
44
|
+
*/
|
|
45
|
+
colorFocusRing?: string;
|
|
32
46
|
}
|
|
33
47
|
/**
|
|
34
48
|
* Every element a customer may target. Named for what it IS, not where it sits.
|
|
@@ -134,6 +148,8 @@ export declare const THEMES: {
|
|
|
134
148
|
readonly colorBackground: "#14171c";
|
|
135
149
|
readonly colorBorder: "#242932";
|
|
136
150
|
readonly colorPrimary: "#6ea8fe";
|
|
151
|
+
readonly colorTextOnPrimary: string;
|
|
152
|
+
readonly colorFocusRing: "#6ea8fe";
|
|
137
153
|
readonly colorDanger: string;
|
|
138
154
|
readonly borderRadius: string;
|
|
139
155
|
readonly fontFamily: string;
|
|
@@ -141,6 +157,8 @@ export declare const THEMES: {
|
|
|
141
157
|
};
|
|
142
158
|
readonly neobrutalist: {
|
|
143
159
|
readonly colorPrimary: "#ffe600";
|
|
160
|
+
readonly colorTextOnPrimary: string;
|
|
161
|
+
readonly colorFocusRing: "#000000";
|
|
144
162
|
readonly colorText: "#000000";
|
|
145
163
|
readonly colorBackground: "#ffffff";
|
|
146
164
|
readonly colorBorder: "#000000";
|
|
@@ -156,6 +174,13 @@ export declare const THEMES: {
|
|
|
156
174
|
* Later wins, and `undefined` never overwrites. A customer setting one variable
|
|
157
175
|
* on the dark theme expects the other eleven to stay dark, not silently revert
|
|
158
176
|
* to the light defaults.
|
|
177
|
+
*
|
|
178
|
+
* `colorTextOnPrimary` and `colorFocusRing` follow the RESOLVED `colorPrimary`
|
|
179
|
+
* unless set explicitly in `variables` (a theme's own values are for its own
|
|
180
|
+
* primary): the label flips to whichever of white / near-black contrasts more,
|
|
181
|
+
* and the focus ring takes the primary. A base theme whose primary would make a
|
|
182
|
+
* poor ring on its own background (neobrutalist yellow on white) keeps its ring
|
|
183
|
+
* while its primary is unchanged.
|
|
159
184
|
*/
|
|
160
185
|
export declare function resolveTokens(appearance?: Appearance): Required<DesignTokens>;
|
|
161
186
|
/** Tokens as CSS custom properties, for the host DOM to inherit. */
|
package/dist/appearance.js
CHANGED
|
@@ -26,6 +26,7 @@ exports.classFor = classFor;
|
|
|
26
26
|
exports.explicitTokens = explicitTokens;
|
|
27
27
|
exports.renderAppearance = renderAppearance;
|
|
28
28
|
const runtime_1 = require("@atlasauth/design/runtime");
|
|
29
|
+
const contrast_1 = require("./contrast");
|
|
29
30
|
var runtime_2 = require("@atlasauth/design/runtime");
|
|
30
31
|
Object.defineProperty(exports, "instanceDesignFrom", { enumerable: true, get: function () { return runtime_2.instanceDesignFrom; } });
|
|
31
32
|
Object.defineProperty(exports, "warnOnce", { enumerable: true, get: function () { return runtime_2.warnOnce; } });
|
|
@@ -46,6 +47,9 @@ exports.DEFAULT_TOKENS = {
|
|
|
46
47
|
borderRadius: '8px',
|
|
47
48
|
fontFamily: 'ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',
|
|
48
49
|
spacingUnit: '4px',
|
|
50
|
+
// Both derived from colorPrimary by resolveTokens unless set explicitly.
|
|
51
|
+
colorTextOnPrimary: '#ffffff',
|
|
52
|
+
colorFocusRing: '#5b5bd6',
|
|
49
53
|
};
|
|
50
54
|
/**
|
|
51
55
|
* §10.3: "prebuilt themes shipped (default, dark, neobrutalist as a demo of the
|
|
@@ -61,10 +65,14 @@ exports.THEMES = {
|
|
|
61
65
|
colorBackground: '#14171c',
|
|
62
66
|
colorBorder: '#242932',
|
|
63
67
|
colorPrimary: '#6ea8fe',
|
|
68
|
+
colorTextOnPrimary: (0, contrast_1.textOnPrimary)('#6ea8fe'),
|
|
69
|
+
colorFocusRing: '#6ea8fe',
|
|
64
70
|
},
|
|
65
71
|
neobrutalist: {
|
|
66
72
|
...exports.DEFAULT_TOKENS,
|
|
67
73
|
colorPrimary: '#ffe600',
|
|
74
|
+
colorTextOnPrimary: (0, contrast_1.textOnPrimary)('#ffe600'),
|
|
75
|
+
colorFocusRing: '#000000',
|
|
68
76
|
colorText: '#000000',
|
|
69
77
|
colorBackground: '#ffffff',
|
|
70
78
|
colorBorder: '#000000',
|
|
@@ -78,6 +86,13 @@ exports.THEMES = {
|
|
|
78
86
|
* Later wins, and `undefined` never overwrites. A customer setting one variable
|
|
79
87
|
* on the dark theme expects the other eleven to stay dark, not silently revert
|
|
80
88
|
* to the light defaults.
|
|
89
|
+
*
|
|
90
|
+
* `colorTextOnPrimary` and `colorFocusRing` follow the RESOLVED `colorPrimary`
|
|
91
|
+
* unless set explicitly in `variables` (a theme's own values are for its own
|
|
92
|
+
* primary): the label flips to whichever of white / near-black contrasts more,
|
|
93
|
+
* and the focus ring takes the primary. A base theme whose primary would make a
|
|
94
|
+
* poor ring on its own background (neobrutalist yellow on white) keeps its ring
|
|
95
|
+
* while its primary is unchanged.
|
|
81
96
|
*/
|
|
82
97
|
function resolveTokens(appearance) {
|
|
83
98
|
const base = appearance?.baseTheme ? exports.THEMES[appearance.baseTheme] : exports.DEFAULT_TOKENS;
|
|
@@ -87,6 +102,13 @@ function resolveTokens(appearance) {
|
|
|
87
102
|
if (value !== undefined)
|
|
88
103
|
resolved[key] = value;
|
|
89
104
|
}
|
|
105
|
+
const primaryChanged = resolved.colorPrimary !== base.colorPrimary;
|
|
106
|
+
if (overrides.colorTextOnPrimary === undefined) {
|
|
107
|
+
resolved.colorTextOnPrimary = (0, contrast_1.textOnPrimary)(resolved.colorPrimary);
|
|
108
|
+
}
|
|
109
|
+
if (overrides.colorFocusRing === undefined && primaryChanged) {
|
|
110
|
+
resolved.colorFocusRing = resolved.colorPrimary;
|
|
111
|
+
}
|
|
90
112
|
return resolved;
|
|
91
113
|
}
|
|
92
114
|
/** Tokens as CSS custom properties, for the host DOM to inherit. */
|
|
@@ -136,11 +158,44 @@ function explicitTokens(appearance) {
|
|
|
136
158
|
* variables inline, no stylesheet, no attributes.
|
|
137
159
|
*/
|
|
138
160
|
function renderAppearance(appearance, instanceDesign, options = {}) {
|
|
139
|
-
|
|
161
|
+
const out = (0, runtime_1.renderDesignAppearance)(appearance, instanceDesign, {
|
|
140
162
|
tokens: explicitTokens(appearance),
|
|
141
163
|
legacyStyle: () => cssVariables(resolveTokens(appearance)),
|
|
142
164
|
frontendApi: options.frontendApi,
|
|
143
165
|
warn: options.warn,
|
|
144
166
|
});
|
|
167
|
+
if (!out.attributes['data-atlas-design'])
|
|
168
|
+
return out;
|
|
169
|
+
return { ...out, style: { ...out.style, ...designAccessibilityVariables(appearance, options.warn ?? runtime_1.warnOnce) } };
|
|
170
|
+
}
|
|
171
|
+
/** Characters an inline token may never contain (mirrors the design system's raw-token guard). */
|
|
172
|
+
const UNSAFE_INLINE = /[;{}<>\\]|\/\*|url\s*\(|expression\s*\(|@import|javascript:/i;
|
|
173
|
+
/**
|
|
174
|
+
* With a design active, the design supplies the primary ink and the focus ring,
|
|
175
|
+
* and the token defaults are not emitted. An EXPLICIT `colorTextOnPrimary` /
|
|
176
|
+
* `colorFocusRing` in `variables` still wins: they go inline on the root. The
|
|
177
|
+
* ring also sets `--atlas-focus-outline-color`, which the design-mode focus
|
|
178
|
+
* outline reads before falling back to the (solid) primary — the design's own
|
|
179
|
+
* `--atlas-color-focus-ring` is translucent, a glow colour, not an outline one.
|
|
180
|
+
*/
|
|
181
|
+
function designAccessibilityVariables(appearance, warn) {
|
|
182
|
+
const vars = {};
|
|
183
|
+
const safe = (key, value) => {
|
|
184
|
+
if (value === undefined)
|
|
185
|
+
return false;
|
|
186
|
+
if (typeof value === 'string' && value.length <= 200 && !UNSAFE_INLINE.test(value))
|
|
187
|
+
return true;
|
|
188
|
+
warn(`appearance.variables.${key} is not a safe CSS value; ignored.`);
|
|
189
|
+
return false;
|
|
190
|
+
};
|
|
191
|
+
const ink = appearance?.variables?.colorTextOnPrimary;
|
|
192
|
+
if (safe('colorTextOnPrimary', ink))
|
|
193
|
+
vars['--atlas-color-text-on-primary'] = ink;
|
|
194
|
+
const ring = appearance?.variables?.colorFocusRing;
|
|
195
|
+
if (safe('colorFocusRing', ring)) {
|
|
196
|
+
vars['--atlas-color-focus-ring'] = ring;
|
|
197
|
+
vars['--atlas-focus-outline-color'] = ring;
|
|
198
|
+
}
|
|
199
|
+
return vars;
|
|
145
200
|
}
|
|
146
201
|
//# sourceMappingURL=appearance.js.map
|
package/dist/appearance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance.js","sourceRoot":"","sources":["../src/appearance.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;
|
|
1
|
+
{"version":3,"file":"appearance.js","sourceRoot":"","sources":["../src/appearance.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AA8MH,sCAgBC;AAGD,oCAOC;AASD,4BAOC;AASD,wCASC;AAWD,4CAaC;AAhSD,uDAQmC;AACnC,yCAA2C;AAE3C,qDAAyE;AAAhE,6GAAA,kBAAkB,OAAA;AAAE,mGAAA,QAAQ,OAAA;AA8FrC,gDAAgD;AACnC,QAAA,YAAY,GAA0B;IACjD,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB;IAC9F,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,cAAc;IAC9F,kBAAkB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY;IACjG,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe;IACjG,aAAa,EAAE,cAAc,EAAE,OAAO;CACvC,CAAC;AAkCW,QAAA,cAAc,GAA2B;IACpD,YAAY,EAAE,SAAS;IACvB,SAAS,EAAE,SAAS;IACpB,eAAe,EAAE,SAAS;IAC1B,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,SAAS;IACtB,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,iE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QACtC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAChG,IAAI,CAAC,wBAAwB,GAAG,oCAAoC,CAAC,CAAC;QACtE,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IACF,MAAM,GAAG,GAAG,UAAU,EAAE,SAAS,EAAE,kBAAkB,CAAC;IACtD,IAAI,IAAI,CAAC,oBAAoB,EAAE,GAAG,CAAC;QAAE,IAAI,CAAC,+BAA+B,CAAC,GAAG,GAAG,CAAC;IACjF,MAAM,IAAI,GAAG,UAAU,EAAE,SAAS,EAAE,cAAc,CAAC;IACnD,IAAI,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,0BAA0B,CAAC,GAAG,IAAI,CAAC;QACxC,IAAI,CAAC,6BAA6B,CAAC,GAAG,IAAI,CAAC;IAC7C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type FlowCaptcha } from '@atlasauth/js';
|
|
2
|
+
/**
|
|
3
|
+
* The captcha half of the prebuilt `<SignIn>`/`<SignUp>`.
|
|
4
|
+
*
|
|
5
|
+
* Driven entirely by the instance's settings (`captchaFlows` from
|
|
6
|
+
* `/v1/appearance`), so switching captcha on in the dashboard makes the
|
|
7
|
+
* components render it with no code change. The widget itself is the shared
|
|
8
|
+
* `@atlasauth/js` renderer the embed widget also uses.
|
|
9
|
+
*
|
|
10
|
+
* Lifecycle: a visible/managed widget is drawn as soon as its slot mounts, so
|
|
11
|
+
* the user can solve it while filling in the form; an invisible one is executed
|
|
12
|
+
* only when the form is submitted. Tokens are single-use, so after a submit
|
|
13
|
+
* spent one the caller `reset()`s, which draws a fresh widget.
|
|
14
|
+
*/
|
|
15
|
+
export interface CaptchaController {
|
|
16
|
+
/** Whether this flow renders a widget at all. */
|
|
17
|
+
needed: boolean;
|
|
18
|
+
/** Callback ref for the element the widget draws into. */
|
|
19
|
+
slotRef: (el: HTMLDivElement | null) => void;
|
|
20
|
+
/** The solved token, rendering/executing the widget first if needed. Null when
|
|
21
|
+
* no captcha is needed, or the provider failed (the server then refuses with
|
|
22
|
+
* CAPTCHA_REQUIRED, which the caller turns into a message). */
|
|
23
|
+
getToken(): Promise<string | null>;
|
|
24
|
+
/** Drop the (spent) widget and, for a visible one, draw a fresh one. */
|
|
25
|
+
reset(): void;
|
|
26
|
+
}
|
|
27
|
+
export declare function useCaptcha(flow: FlowCaptcha | undefined, options: {
|
|
28
|
+
/** Render at all — the caller's "this flow requires a token here" decision. */
|
|
29
|
+
active: boolean;
|
|
30
|
+
/** Draw the widget as soon as the slot mounts. Default: unless invisible. */
|
|
31
|
+
eager?: boolean;
|
|
32
|
+
/** Called with the token when an eagerly drawn widget is solved. */
|
|
33
|
+
onSolved?: (token: string) => void;
|
|
34
|
+
}): CaptchaController;
|
|
35
|
+
/** The element the widget draws into. Empty until the provider renders. */
|
|
36
|
+
export declare function CaptchaSlot({ controller }: {
|
|
37
|
+
controller: CaptchaController;
|
|
38
|
+
}): import("react").JSX.Element | null;
|
|
39
|
+
/**
|
|
40
|
+
* Swap the server's captcha refusals (CAPTCHA_REQUIRED / CAPTCHA_FAILED) for a
|
|
41
|
+
* localized, form-level message. Shared with the other framework SDKs.
|
|
42
|
+
*/
|
|
43
|
+
export { localizeCaptchaErrors } from '@atlasauth/js';
|