@delmaredigital/payload-better-auth 0.3.7 → 0.3.9
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 +12 -1
- package/dist/adapter/collections.d.ts.map +1 -1
- package/dist/adapter/collections.js +126 -88
- package/dist/adapter/collections.js.map +1 -1
- package/dist/adapter/index.js +197 -150
- package/dist/adapter/index.js.map +1 -1
- package/dist/components/BeforeLogin.d.ts +1 -1
- package/dist/components/BeforeLogin.d.ts.map +1 -1
- package/dist/components/BeforeLogin.js +15 -7
- package/dist/components/BeforeLogin.js.map +1 -1
- package/dist/components/LoginView.d.ts +2 -2
- package/dist/components/LoginView.d.ts.map +1 -1
- package/dist/components/LoginView.js +660 -218
- package/dist/components/LoginView.js.map +1 -1
- package/dist/components/LoginViewWrapper.d.ts +1 -1
- package/dist/components/LoginViewWrapper.d.ts.map +1 -1
- package/dist/components/LoginViewWrapper.js +14 -4
- package/dist/components/LoginViewWrapper.js.map +1 -1
- package/dist/components/LogoutButton.d.ts +1 -1
- package/dist/components/LogoutButton.d.ts.map +1 -1
- package/dist/components/LogoutButton.js +19 -11
- package/dist/components/LogoutButton.js.map +1 -1
- package/dist/components/PasskeyRegisterButton.d.ts +2 -2
- package/dist/components/PasskeyRegisterButton.d.ts.map +1 -1
- package/dist/components/PasskeyRegisterButton.js +20 -16
- package/dist/components/PasskeyRegisterButton.js.map +1 -1
- package/dist/components/PasskeySignInButton.d.ts +2 -2
- package/dist/components/PasskeySignInButton.d.ts.map +1 -1
- package/dist/components/PasskeySignInButton.js +14 -12
- package/dist/components/PasskeySignInButton.js.map +1 -1
- package/dist/components/auth/ForgotPasswordView.d.ts +1 -1
- package/dist/components/auth/ForgotPasswordView.d.ts.map +1 -1
- package/dist/components/auth/ForgotPasswordView.js +133 -43
- package/dist/components/auth/ForgotPasswordView.js.map +1 -1
- package/dist/components/auth/ResetPasswordView.d.ts +1 -1
- package/dist/components/auth/ResetPasswordView.d.ts.map +1 -1
- package/dist/components/auth/ResetPasswordView.js +154 -50
- package/dist/components/auth/ResetPasswordView.js.map +1 -1
- package/dist/components/auth/index.js +2 -2
- package/dist/components/auth/index.js.map +1 -1
- package/dist/components/management/ApiKeysManagementClient.d.ts +2 -2
- package/dist/components/management/ApiKeysManagementClient.d.ts.map +1 -1
- package/dist/components/management/ApiKeysManagementClient.js +539 -222
- package/dist/components/management/ApiKeysManagementClient.js.map +1 -1
- package/dist/components/management/PasskeysManagementClient.d.ts +2 -2
- package/dist/components/management/PasskeysManagementClient.d.ts.map +1 -1
- package/dist/components/management/PasskeysManagementClient.js +215 -92
- package/dist/components/management/PasskeysManagementClient.js.map +1 -1
- package/dist/components/management/SecurityNavLinks.d.ts +1 -1
- package/dist/components/management/SecurityNavLinks.d.ts.map +1 -1
- package/dist/components/management/SecurityNavLinks.js +51 -24
- package/dist/components/management/SecurityNavLinks.js.map +1 -1
- package/dist/components/management/TwoFactorManagementClient.d.ts +2 -2
- package/dist/components/management/TwoFactorManagementClient.d.ts.map +1 -1
- package/dist/components/management/TwoFactorManagementClient.js +270 -111
- package/dist/components/management/TwoFactorManagementClient.js.map +1 -1
- package/dist/components/management/index.js +2 -2
- package/dist/components/management/index.js.map +1 -1
- package/dist/components/management/views/ApiKeysView.d.ts +1 -1
- package/dist/components/management/views/ApiKeysView.d.ts.map +1 -1
- package/dist/components/management/views/ApiKeysView.js +19 -4
- package/dist/components/management/views/ApiKeysView.js.map +1 -1
- package/dist/components/management/views/PasskeysView.d.ts +1 -1
- package/dist/components/management/views/PasskeysView.d.ts.map +1 -1
- package/dist/components/management/views/PasskeysView.js +16 -4
- package/dist/components/management/views/PasskeysView.js.map +1 -1
- package/dist/components/management/views/TwoFactorView.d.ts +1 -1
- package/dist/components/management/views/TwoFactorView.d.ts.map +1 -1
- package/dist/components/management/views/TwoFactorView.js +16 -4
- package/dist/components/management/views/TwoFactorView.js.map +1 -1
- package/dist/components/management/views/index.js +2 -2
- package/dist/components/management/views/index.js.map +1 -1
- package/dist/components/twoFactor/TwoFactorSetupView.d.ts +1 -1
- package/dist/components/twoFactor/TwoFactorSetupView.d.ts.map +1 -1
- package/dist/components/twoFactor/TwoFactorSetupView.js +240 -87
- package/dist/components/twoFactor/TwoFactorSetupView.js.map +1 -1
- package/dist/components/twoFactor/TwoFactorVerifyView.d.ts +1 -1
- package/dist/components/twoFactor/TwoFactorVerifyView.d.ts.map +1 -1
- package/dist/components/twoFactor/TwoFactorVerifyView.js +108 -45
- package/dist/components/twoFactor/TwoFactorVerifyView.js.map +1 -1
- package/dist/components/twoFactor/index.js +2 -2
- package/dist/components/twoFactor/index.js.map +1 -1
- package/dist/exports/client.js +9 -10
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/components.js +2 -2
- package/dist/exports/components.js.map +1 -1
- package/dist/exports/management.js +3 -3
- package/dist/exports/management.js.map +1 -1
- package/dist/exports/rsc.js +2 -2
- package/dist/exports/rsc.js.map +1 -1
- package/dist/generated-types.js +4 -2
- package/dist/generated-types.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.js +198 -162
- package/dist/plugin/index.js.map +1 -1
- package/dist/scripts/generate-types.js +66 -50
- package/dist/scripts/generate-types.js.map +1 -1
- package/dist/types/apiKey.js +7 -2
- package/dist/types/apiKey.js.map +1 -1
- package/dist/types/betterAuth.js +23 -2
- package/dist/types/betterAuth.js.map +1 -1
- package/dist/utils/access.js +78 -81
- package/dist/utils/access.js.map +1 -1
- package/dist/utils/apiKeyAccess.js +65 -72
- package/dist/utils/apiKeyAccess.js.map +1 -1
- package/dist/utils/betterAuthDefaults.js +8 -8
- package/dist/utils/betterAuthDefaults.js.map +1 -1
- package/dist/utils/detectAuthConfig.js +8 -11
- package/dist/utils/detectAuthConfig.js.map +1 -1
- package/dist/utils/detectEnabledPlugins.js +6 -7
- package/dist/utils/detectEnabledPlugins.js.map +1 -1
- package/dist/utils/firstUserAdmin.js +18 -20
- package/dist/utils/firstUserAdmin.js.map +1 -1
- package/dist/utils/generateScopes.js +40 -41
- package/dist/utils/generateScopes.js.map +1 -1
- package/dist/utils/session.js +8 -9
- package/dist/utils/session.js.map +1 -1
- package/package.json +27 -13
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useEffect, useMemo, useRef } from 'react';
|
|
4
|
-
import { createPayloadAuthClient
|
|
4
|
+
import { createPayloadAuthClient } from '../../exports/client.js';
|
|
5
5
|
/**
|
|
6
6
|
* Group scopes by collection for the UI.
|
|
7
7
|
* Scopes like "posts:read", "posts:write" get grouped under "Posts"
|
|
8
|
-
*/
|
|
9
|
-
function groupScopesByCollection(scopes) {
|
|
8
|
+
*/ function groupScopesByCollection(scopes) {
|
|
10
9
|
const groups = new Map();
|
|
11
|
-
for (const scope of scopes)
|
|
10
|
+
for (const scope of scopes){
|
|
12
11
|
// Parse scope ID like "posts:read" -> collection="posts", type="read"
|
|
13
12
|
const colonIndex = scope.id.indexOf(':');
|
|
14
13
|
let collection;
|
|
@@ -16,11 +15,12 @@ function groupScopesByCollection(scopes) {
|
|
|
16
15
|
if (colonIndex > 0) {
|
|
17
16
|
collection = scope.id.substring(0, colonIndex);
|
|
18
17
|
const typeStr = scope.id.substring(colonIndex + 1);
|
|
19
|
-
type = [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
type = [
|
|
19
|
+
'read',
|
|
20
|
+
'write',
|
|
21
|
+
'delete'
|
|
22
|
+
].includes(typeStr) ? typeStr : 'other';
|
|
23
|
+
} else {
|
|
24
24
|
// No colon - treat as standalone scope
|
|
25
25
|
collection = scope.id;
|
|
26
26
|
type = 'other';
|
|
@@ -31,25 +31,30 @@ function groupScopesByCollection(scopes) {
|
|
|
31
31
|
groups.set(collection, {
|
|
32
32
|
collection,
|
|
33
33
|
label,
|
|
34
|
-
scopes: []
|
|
34
|
+
scopes: []
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
groups.get(collection).scopes.push({
|
|
37
|
+
groups.get(collection).scopes.push({
|
|
38
|
+
type,
|
|
39
|
+
scope
|
|
40
|
+
});
|
|
38
41
|
}
|
|
39
42
|
// Sort groups alphabetically, sort scopes within group by type order
|
|
40
|
-
const typeOrder = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const typeOrder = {
|
|
44
|
+
read: 0,
|
|
45
|
+
write: 1,
|
|
46
|
+
delete: 2,
|
|
47
|
+
other: 3
|
|
48
|
+
};
|
|
49
|
+
return Array.from(groups.values()).sort((a, b)=>a.label.localeCompare(b.label)).map((group)=>({
|
|
50
|
+
...group,
|
|
51
|
+
scopes: group.scopes.sort((a, b)=>typeOrder[a.type] - typeOrder[b.type])
|
|
52
|
+
}));
|
|
47
53
|
}
|
|
48
54
|
/**
|
|
49
55
|
* Client component for API keys management.
|
|
50
56
|
* Lists, creates, and deletes API keys with scope selection.
|
|
51
|
-
*/
|
|
52
|
-
export function ApiKeysManagementClient({ authClient: providedClient, title = 'API Keys', availableScopes = [], defaultScopes = [], } = {}) {
|
|
57
|
+
*/ export function ApiKeysManagementClient({ authClient: providedClient, title = 'API Keys', availableScopes = [], defaultScopes = [] } = {}) {
|
|
53
58
|
const [apiKeys, setApiKeys] = useState([]);
|
|
54
59
|
const [loading, setLoading] = useState(true);
|
|
55
60
|
const [error, setError] = useState(null);
|
|
@@ -63,47 +68,59 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
63
68
|
const [expandedGroups, setExpandedGroups] = useState(new Set());
|
|
64
69
|
const hasScopes = availableScopes.length > 0;
|
|
65
70
|
// Group scopes by collection
|
|
66
|
-
const scopeGroups = useMemo(()
|
|
71
|
+
const scopeGroups = useMemo(()=>groupScopesByCollection(availableScopes), [
|
|
72
|
+
availableScopes
|
|
73
|
+
]);
|
|
67
74
|
// Get all scope IDs by type for bulk actions
|
|
68
|
-
const scopesByType = useMemo(()
|
|
69
|
-
const result = {
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
const scopesByType = useMemo(()=>{
|
|
76
|
+
const result = {
|
|
77
|
+
read: [],
|
|
78
|
+
write: [],
|
|
79
|
+
delete: []
|
|
80
|
+
};
|
|
81
|
+
for (const group of scopeGroups){
|
|
82
|
+
for (const { type, scope } of group.scopes){
|
|
72
83
|
if (type === 'read' || type === 'write' || type === 'delete') {
|
|
73
84
|
result[type].push(scope.id);
|
|
74
85
|
}
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
return result;
|
|
78
|
-
}, [
|
|
79
|
-
|
|
89
|
+
}, [
|
|
90
|
+
scopeGroups
|
|
91
|
+
]);
|
|
92
|
+
const getClient = ()=>providedClient ?? createPayloadAuthClient();
|
|
80
93
|
// Toggle a scope selection
|
|
81
94
|
function toggleScope(scopeId) {
|
|
82
|
-
setSelectedScopes((prev)
|
|
83
|
-
|
|
84
|
-
|
|
95
|
+
setSelectedScopes((prev)=>prev.includes(scopeId) ? prev.filter((s)=>s !== scopeId) : [
|
|
96
|
+
...prev,
|
|
97
|
+
scopeId
|
|
98
|
+
]);
|
|
85
99
|
}
|
|
86
100
|
// Toggle all scopes in a group
|
|
87
101
|
function toggleGroup(group) {
|
|
88
|
-
const groupScopeIds = group.scopes.map((s)
|
|
89
|
-
const allSelected = groupScopeIds.every((id)
|
|
102
|
+
const groupScopeIds = group.scopes.map((s)=>s.scope.id);
|
|
103
|
+
const allSelected = groupScopeIds.every((id)=>selectedScopes.includes(id));
|
|
90
104
|
if (allSelected) {
|
|
91
105
|
// Deselect all in group
|
|
92
|
-
setSelectedScopes((prev)
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
106
|
+
setSelectedScopes((prev)=>prev.filter((id)=>!groupScopeIds.includes(id)));
|
|
107
|
+
} else {
|
|
95
108
|
// Select all in group
|
|
96
|
-
setSelectedScopes((prev)
|
|
109
|
+
setSelectedScopes((prev)=>[
|
|
110
|
+
...new Set([
|
|
111
|
+
...prev,
|
|
112
|
+
...groupScopeIds
|
|
113
|
+
])
|
|
114
|
+
]);
|
|
97
115
|
}
|
|
98
116
|
}
|
|
99
117
|
// Toggle expand/collapse for a group
|
|
100
118
|
function toggleExpanded(collection) {
|
|
101
|
-
setExpandedGroups((prev)
|
|
119
|
+
setExpandedGroups((prev)=>{
|
|
102
120
|
const next = new Set(prev);
|
|
103
121
|
if (next.has(collection)) {
|
|
104
122
|
next.delete(collection);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
123
|
+
} else {
|
|
107
124
|
next.add(collection);
|
|
108
125
|
}
|
|
109
126
|
return next;
|
|
@@ -112,22 +129,26 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
112
129
|
// Bulk toggle all scopes of a type
|
|
113
130
|
function toggleAllOfType(type) {
|
|
114
131
|
const typeScopes = scopesByType[type];
|
|
115
|
-
const allSelected = typeScopes.every((id)
|
|
132
|
+
const allSelected = typeScopes.every((id)=>selectedScopes.includes(id));
|
|
116
133
|
if (allSelected) {
|
|
117
|
-
setSelectedScopes((prev)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
134
|
+
setSelectedScopes((prev)=>prev.filter((id)=>!typeScopes.includes(id)));
|
|
135
|
+
} else {
|
|
136
|
+
setSelectedScopes((prev)=>[
|
|
137
|
+
...new Set([
|
|
138
|
+
...prev,
|
|
139
|
+
...typeScopes
|
|
140
|
+
])
|
|
141
|
+
]);
|
|
121
142
|
}
|
|
122
143
|
}
|
|
123
144
|
// Check if all scopes of a type are selected
|
|
124
145
|
function isAllOfTypeSelected(type) {
|
|
125
|
-
return scopesByType[type].length > 0 && scopesByType[type].every((id)
|
|
146
|
+
return scopesByType[type].length > 0 && scopesByType[type].every((id)=>selectedScopes.includes(id));
|
|
126
147
|
}
|
|
127
148
|
// Check if some (but not all) scopes of a type are selected
|
|
128
149
|
function isSomeOfTypeSelected(type) {
|
|
129
150
|
const typeScopes = scopesByType[type];
|
|
130
|
-
const selectedCount = typeScopes.filter((id)
|
|
151
|
+
const selectedCount = typeScopes.filter((id)=>selectedScopes.includes(id)).length;
|
|
131
152
|
return selectedCount > 0 && selectedCount < typeScopes.length;
|
|
132
153
|
}
|
|
133
154
|
// Clear all selections
|
|
@@ -136,35 +157,37 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
136
157
|
}
|
|
137
158
|
// Select all scopes
|
|
138
159
|
function selectAll() {
|
|
139
|
-
setSelectedScopes(availableScopes.map((s)
|
|
160
|
+
setSelectedScopes(availableScopes.map((s)=>s.id));
|
|
140
161
|
}
|
|
141
162
|
// Get group selection state
|
|
142
163
|
function getGroupState(group) {
|
|
143
|
-
const groupScopeIds = group.scopes.map((s)
|
|
144
|
-
const selectedCount = groupScopeIds.filter((id)
|
|
145
|
-
if (selectedCount === 0)
|
|
146
|
-
|
|
147
|
-
if (selectedCount === groupScopeIds.length)
|
|
148
|
-
return 'all';
|
|
164
|
+
const groupScopeIds = group.scopes.map((s)=>s.scope.id);
|
|
165
|
+
const selectedCount = groupScopeIds.filter((id)=>selectedScopes.includes(id)).length;
|
|
166
|
+
if (selectedCount === 0) return 'none';
|
|
167
|
+
if (selectedCount === groupScopeIds.length) return 'all';
|
|
149
168
|
return 'some';
|
|
150
169
|
}
|
|
151
170
|
// Get scope label by ID
|
|
152
171
|
function getScopeLabel(scopeId) {
|
|
153
|
-
const scope = availableScopes.find((s)
|
|
172
|
+
const scope = availableScopes.find((s)=>s.id === scopeId);
|
|
154
173
|
return scope?.label ?? scopeId;
|
|
155
174
|
}
|
|
156
175
|
// Get short label for scope type
|
|
157
176
|
function getTypeLabel(type) {
|
|
158
|
-
switch
|
|
159
|
-
case 'read':
|
|
160
|
-
|
|
161
|
-
case '
|
|
162
|
-
|
|
177
|
+
switch(type){
|
|
178
|
+
case 'read':
|
|
179
|
+
return 'Read';
|
|
180
|
+
case 'write':
|
|
181
|
+
return 'Write';
|
|
182
|
+
case 'delete':
|
|
183
|
+
return 'Delete';
|
|
184
|
+
default:
|
|
185
|
+
return 'Access';
|
|
163
186
|
}
|
|
164
187
|
}
|
|
165
|
-
useEffect(()
|
|
188
|
+
useEffect(()=>{
|
|
166
189
|
fetchApiKeys();
|
|
167
|
-
|
|
190
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
191
|
}, []);
|
|
169
192
|
async function fetchApiKeys() {
|
|
170
193
|
setLoading(true);
|
|
@@ -174,15 +197,12 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
174
197
|
const result = await client.apiKey.list();
|
|
175
198
|
if (result.error) {
|
|
176
199
|
setError(result.error.message ?? 'Failed to load API keys');
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
200
|
+
} else {
|
|
179
201
|
setApiKeys(result.data ?? []);
|
|
180
202
|
}
|
|
181
|
-
}
|
|
182
|
-
catch {
|
|
203
|
+
} catch {
|
|
183
204
|
setError('Failed to load API keys');
|
|
184
|
-
}
|
|
185
|
-
finally {
|
|
205
|
+
} finally{
|
|
186
206
|
setLoading(false);
|
|
187
207
|
}
|
|
188
208
|
}
|
|
@@ -194,7 +214,9 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
194
214
|
try {
|
|
195
215
|
const client = getClient();
|
|
196
216
|
// Send scopes to server - server will convert to permissions
|
|
197
|
-
const createOptions = {
|
|
217
|
+
const createOptions = {
|
|
218
|
+
name: newKeyName
|
|
219
|
+
};
|
|
198
220
|
if (newKeyExpiry) {
|
|
199
221
|
createOptions.expiresIn = parseInt(newKeyExpiry) * 24 * 60 * 60; // Convert days to seconds
|
|
200
222
|
}
|
|
@@ -205,8 +227,7 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
205
227
|
const result = await client.apiKey.create(createOptions);
|
|
206
228
|
if (result.error) {
|
|
207
229
|
setError(result.error.message ?? 'Failed to create API key');
|
|
208
|
-
}
|
|
209
|
-
else if (result.data) {
|
|
230
|
+
} else if (result.data) {
|
|
210
231
|
setNewlyCreatedKey(result.data.key);
|
|
211
232
|
setShowCreateForm(false);
|
|
212
233
|
setNewKeyName('');
|
|
@@ -214,11 +235,9 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
214
235
|
setSelectedScopes(defaultScopes); // Reset to defaults
|
|
215
236
|
fetchApiKeys();
|
|
216
237
|
}
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
238
|
+
} catch {
|
|
219
239
|
setError('Failed to create API key');
|
|
220
|
-
}
|
|
221
|
-
finally {
|
|
240
|
+
} finally{
|
|
222
241
|
setCreating(false);
|
|
223
242
|
}
|
|
224
243
|
}
|
|
@@ -230,77 +249,111 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
230
249
|
setError(null);
|
|
231
250
|
try {
|
|
232
251
|
const client = getClient();
|
|
233
|
-
const result = await client.apiKey.delete({
|
|
252
|
+
const result = await client.apiKey.delete({
|
|
253
|
+
keyId
|
|
254
|
+
});
|
|
234
255
|
if (result.error) {
|
|
235
256
|
setError(result.error.message ?? 'Failed to delete API key');
|
|
257
|
+
} else {
|
|
258
|
+
setApiKeys((prev)=>prev.filter((k)=>k.id !== keyId));
|
|
236
259
|
}
|
|
237
|
-
|
|
238
|
-
setApiKeys((prev) => prev.filter((k) => k.id !== keyId));
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch {
|
|
260
|
+
} catch {
|
|
242
261
|
setError('Failed to delete API key');
|
|
243
|
-
}
|
|
244
|
-
finally {
|
|
262
|
+
} finally{
|
|
245
263
|
setDeleting(null);
|
|
246
264
|
}
|
|
247
265
|
}
|
|
248
266
|
function formatDate(date) {
|
|
249
|
-
if (!date)
|
|
250
|
-
return 'Never';
|
|
267
|
+
if (!date) return 'Never';
|
|
251
268
|
const d = date instanceof Date ? date : new Date(date);
|
|
252
269
|
return d.toLocaleString();
|
|
253
270
|
}
|
|
254
|
-
return
|
|
271
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
272
|
+
style: {
|
|
255
273
|
maxWidth: '900px',
|
|
256
274
|
margin: '0 auto',
|
|
257
|
-
padding: 'calc(var(--base) * 2)'
|
|
258
|
-
},
|
|
275
|
+
padding: 'calc(var(--base) * 2)'
|
|
276
|
+
},
|
|
277
|
+
children: [
|
|
278
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
279
|
+
style: {
|
|
259
280
|
display: 'flex',
|
|
260
281
|
justifyContent: 'space-between',
|
|
261
282
|
alignItems: 'center',
|
|
262
|
-
marginBottom: 'calc(var(--base) * 2)'
|
|
263
|
-
},
|
|
283
|
+
marginBottom: 'calc(var(--base) * 2)'
|
|
284
|
+
},
|
|
285
|
+
children: [
|
|
286
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
287
|
+
style: {
|
|
264
288
|
color: 'var(--theme-text)',
|
|
265
289
|
fontSize: 'var(--font-size-h2)',
|
|
266
290
|
fontWeight: 600,
|
|
267
|
-
margin: 0
|
|
268
|
-
},
|
|
291
|
+
margin: 0
|
|
292
|
+
},
|
|
293
|
+
children: title
|
|
294
|
+
}),
|
|
295
|
+
/*#__PURE__*/ _jsx("button", {
|
|
296
|
+
onClick: ()=>setShowCreateForm(true),
|
|
297
|
+
style: {
|
|
269
298
|
padding: 'calc(var(--base) * 0.5) calc(var(--base) * 1)',
|
|
270
299
|
background: 'var(--theme-elevation-800)',
|
|
271
300
|
border: 'none',
|
|
272
301
|
borderRadius: 'var(--style-radius-s)',
|
|
273
302
|
color: 'var(--theme-elevation-50)',
|
|
274
303
|
fontSize: 'var(--font-size-small)',
|
|
275
|
-
cursor: 'pointer'
|
|
276
|
-
},
|
|
304
|
+
cursor: 'pointer'
|
|
305
|
+
},
|
|
306
|
+
children: "Create API Key"
|
|
307
|
+
})
|
|
308
|
+
]
|
|
309
|
+
}),
|
|
310
|
+
error && /*#__PURE__*/ _jsx("div", {
|
|
311
|
+
style: {
|
|
277
312
|
color: 'var(--theme-error-500)',
|
|
278
313
|
marginBottom: 'var(--base)',
|
|
279
314
|
fontSize: 'var(--font-size-small)',
|
|
280
315
|
padding: 'calc(var(--base) * 0.75)',
|
|
281
316
|
background: 'var(--theme-error-50)',
|
|
282
317
|
borderRadius: 'var(--style-radius-s)',
|
|
283
|
-
border: '1px solid var(--theme-error-200)'
|
|
284
|
-
},
|
|
318
|
+
border: '1px solid var(--theme-error-200)'
|
|
319
|
+
},
|
|
320
|
+
children: error
|
|
321
|
+
}),
|
|
322
|
+
newlyCreatedKey && /*#__PURE__*/ _jsxs("div", {
|
|
323
|
+
style: {
|
|
285
324
|
marginBottom: 'calc(var(--base) * 1.5)',
|
|
286
325
|
padding: 'calc(var(--base) * 1)',
|
|
287
326
|
background: 'var(--theme-success-50)',
|
|
288
327
|
borderRadius: 'var(--style-radius-m)',
|
|
289
|
-
border: '1px solid var(--theme-success-200)'
|
|
290
|
-
},
|
|
328
|
+
border: '1px solid var(--theme-success-200)'
|
|
329
|
+
},
|
|
330
|
+
children: [
|
|
331
|
+
/*#__PURE__*/ _jsx("div", {
|
|
332
|
+
style: {
|
|
291
333
|
color: 'var(--theme-success-700)',
|
|
292
334
|
fontWeight: 500,
|
|
293
|
-
marginBottom: 'calc(var(--base) * 0.5)'
|
|
294
|
-
},
|
|
335
|
+
marginBottom: 'calc(var(--base) * 0.5)'
|
|
336
|
+
},
|
|
337
|
+
children: "API Key Created"
|
|
338
|
+
}),
|
|
339
|
+
/*#__PURE__*/ _jsx("p", {
|
|
340
|
+
style: {
|
|
295
341
|
color: 'var(--theme-text)',
|
|
296
342
|
opacity: 0.8,
|
|
297
343
|
fontSize: 'var(--font-size-small)',
|
|
298
|
-
marginBottom: 'calc(var(--base) * 0.5)'
|
|
299
|
-
},
|
|
344
|
+
marginBottom: 'calc(var(--base) * 0.5)'
|
|
345
|
+
},
|
|
346
|
+
children: "Copy this key now - you won't be able to see it again:"
|
|
347
|
+
}),
|
|
348
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
349
|
+
style: {
|
|
300
350
|
display: 'flex',
|
|
301
351
|
gap: 'calc(var(--base) * 0.5)',
|
|
302
|
-
alignItems: 'center'
|
|
303
|
-
},
|
|
352
|
+
alignItems: 'center'
|
|
353
|
+
},
|
|
354
|
+
children: [
|
|
355
|
+
/*#__PURE__*/ _jsx("code", {
|
|
356
|
+
style: {
|
|
304
357
|
flex: 1,
|
|
305
358
|
padding: 'calc(var(--base) * 0.5)',
|
|
306
359
|
background: 'var(--theme-elevation-100)',
|
|
@@ -308,63 +361,161 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
308
361
|
fontFamily: 'monospace',
|
|
309
362
|
fontSize: 'var(--font-size-small)',
|
|
310
363
|
color: 'var(--theme-text)',
|
|
311
|
-
wordBreak: 'break-all'
|
|
312
|
-
},
|
|
364
|
+
wordBreak: 'break-all'
|
|
365
|
+
},
|
|
366
|
+
children: newlyCreatedKey
|
|
367
|
+
}),
|
|
368
|
+
/*#__PURE__*/ _jsx("button", {
|
|
369
|
+
onClick: ()=>{
|
|
313
370
|
navigator.clipboard.writeText(newlyCreatedKey);
|
|
314
|
-
},
|
|
371
|
+
},
|
|
372
|
+
style: {
|
|
315
373
|
padding: 'calc(var(--base) * 0.5)',
|
|
316
374
|
background: 'var(--theme-elevation-200)',
|
|
317
375
|
border: 'none',
|
|
318
376
|
borderRadius: 'var(--style-radius-s)',
|
|
319
|
-
cursor: 'pointer'
|
|
320
|
-
},
|
|
377
|
+
cursor: 'pointer'
|
|
378
|
+
},
|
|
379
|
+
children: "Copy"
|
|
380
|
+
})
|
|
381
|
+
]
|
|
382
|
+
})
|
|
383
|
+
]
|
|
384
|
+
}),
|
|
385
|
+
showCreateForm && /*#__PURE__*/ _jsxs("div", {
|
|
386
|
+
style: {
|
|
321
387
|
marginBottom: 'calc(var(--base) * 1.5)',
|
|
322
388
|
padding: 'calc(var(--base) * 1.5)',
|
|
323
389
|
background: 'var(--theme-elevation-50)',
|
|
324
390
|
borderRadius: 'var(--style-radius-m)',
|
|
325
|
-
border: '1px solid var(--theme-elevation-100)'
|
|
326
|
-
},
|
|
391
|
+
border: '1px solid var(--theme-elevation-100)'
|
|
392
|
+
},
|
|
393
|
+
children: [
|
|
394
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
395
|
+
style: {
|
|
327
396
|
color: 'var(--theme-text)',
|
|
328
397
|
fontSize: 'var(--font-size-h4)',
|
|
329
398
|
fontWeight: 500,
|
|
330
|
-
margin: '0 0 var(--base) 0'
|
|
331
|
-
},
|
|
399
|
+
margin: '0 0 var(--base) 0'
|
|
400
|
+
},
|
|
401
|
+
children: "Create New API Key"
|
|
402
|
+
}),
|
|
403
|
+
/*#__PURE__*/ _jsxs("form", {
|
|
404
|
+
onSubmit: handleCreate,
|
|
405
|
+
children: [
|
|
406
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
407
|
+
style: {
|
|
408
|
+
marginBottom: 'var(--base)'
|
|
409
|
+
},
|
|
410
|
+
children: [
|
|
411
|
+
/*#__PURE__*/ _jsx("label", {
|
|
412
|
+
style: {
|
|
332
413
|
display: 'block',
|
|
333
414
|
color: 'var(--theme-text)',
|
|
334
415
|
fontSize: 'var(--font-size-small)',
|
|
335
|
-
marginBottom: 'calc(var(--base) * 0.25)'
|
|
336
|
-
},
|
|
416
|
+
marginBottom: 'calc(var(--base) * 0.25)'
|
|
417
|
+
},
|
|
418
|
+
children: "Name"
|
|
419
|
+
}),
|
|
420
|
+
/*#__PURE__*/ _jsx("input", {
|
|
421
|
+
type: "text",
|
|
422
|
+
value: newKeyName,
|
|
423
|
+
onChange: (e)=>setNewKeyName(e.target.value),
|
|
424
|
+
required: true,
|
|
425
|
+
placeholder: "My API Key",
|
|
426
|
+
style: {
|
|
337
427
|
width: '100%',
|
|
338
428
|
padding: 'calc(var(--base) * 0.5)',
|
|
339
429
|
background: 'var(--theme-input-bg)',
|
|
340
430
|
border: '1px solid var(--theme-elevation-150)',
|
|
341
431
|
borderRadius: 'var(--style-radius-s)',
|
|
342
432
|
color: 'var(--theme-text)',
|
|
343
|
-
boxSizing: 'border-box'
|
|
344
|
-
}
|
|
433
|
+
boxSizing: 'border-box'
|
|
434
|
+
}
|
|
435
|
+
})
|
|
436
|
+
]
|
|
437
|
+
}),
|
|
438
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
439
|
+
style: {
|
|
440
|
+
marginBottom: 'var(--base)'
|
|
441
|
+
},
|
|
442
|
+
children: [
|
|
443
|
+
/*#__PURE__*/ _jsx("label", {
|
|
444
|
+
style: {
|
|
345
445
|
display: 'block',
|
|
346
446
|
color: 'var(--theme-text)',
|
|
347
447
|
fontSize: 'var(--font-size-small)',
|
|
348
|
-
marginBottom: 'calc(var(--base) * 0.25)'
|
|
349
|
-
},
|
|
448
|
+
marginBottom: 'calc(var(--base) * 0.25)'
|
|
449
|
+
},
|
|
450
|
+
children: "Expires in (days, optional)"
|
|
451
|
+
}),
|
|
452
|
+
/*#__PURE__*/ _jsx("input", {
|
|
453
|
+
type: "number",
|
|
454
|
+
value: newKeyExpiry,
|
|
455
|
+
onChange: (e)=>setNewKeyExpiry(e.target.value),
|
|
456
|
+
placeholder: "30",
|
|
457
|
+
min: "1",
|
|
458
|
+
style: {
|
|
350
459
|
width: '100%',
|
|
351
460
|
padding: 'calc(var(--base) * 0.5)',
|
|
352
461
|
background: 'var(--theme-input-bg)',
|
|
353
462
|
border: '1px solid var(--theme-elevation-150)',
|
|
354
463
|
borderRadius: 'var(--style-radius-s)',
|
|
355
464
|
color: 'var(--theme-text)',
|
|
356
|
-
boxSizing: 'border-box'
|
|
357
|
-
}
|
|
465
|
+
boxSizing: 'border-box'
|
|
466
|
+
}
|
|
467
|
+
})
|
|
468
|
+
]
|
|
469
|
+
}),
|
|
470
|
+
hasScopes && /*#__PURE__*/ _jsxs("div", {
|
|
471
|
+
style: {
|
|
472
|
+
marginBottom: 'var(--base)'
|
|
473
|
+
},
|
|
474
|
+
children: [
|
|
475
|
+
/*#__PURE__*/ _jsx("label", {
|
|
476
|
+
style: {
|
|
358
477
|
display: 'block',
|
|
359
478
|
color: 'var(--theme-text)',
|
|
360
479
|
fontSize: 'var(--font-size-small)',
|
|
361
|
-
marginBottom: 'calc(var(--base) * 0.5)'
|
|
362
|
-
},
|
|
480
|
+
marginBottom: 'calc(var(--base) * 0.5)'
|
|
481
|
+
},
|
|
482
|
+
children: "Permissions"
|
|
483
|
+
}),
|
|
484
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
485
|
+
style: {
|
|
363
486
|
display: 'flex',
|
|
364
487
|
flexWrap: 'wrap',
|
|
365
488
|
gap: 'calc(var(--base) * 0.5)',
|
|
366
|
-
marginBottom: 'calc(var(--base) * 0.75)'
|
|
367
|
-
},
|
|
489
|
+
marginBottom: 'calc(var(--base) * 0.75)'
|
|
490
|
+
},
|
|
491
|
+
children: [
|
|
492
|
+
/*#__PURE__*/ _jsx(BulkButton, {
|
|
493
|
+
label: "All Read",
|
|
494
|
+
active: isAllOfTypeSelected('read'),
|
|
495
|
+
indeterminate: isSomeOfTypeSelected('read'),
|
|
496
|
+
onClick: ()=>toggleAllOfType('read')
|
|
497
|
+
}),
|
|
498
|
+
/*#__PURE__*/ _jsx(BulkButton, {
|
|
499
|
+
label: "All Write",
|
|
500
|
+
active: isAllOfTypeSelected('write'),
|
|
501
|
+
indeterminate: isSomeOfTypeSelected('write'),
|
|
502
|
+
onClick: ()=>toggleAllOfType('write')
|
|
503
|
+
}),
|
|
504
|
+
/*#__PURE__*/ _jsx(BulkButton, {
|
|
505
|
+
label: "All Delete",
|
|
506
|
+
active: isAllOfTypeSelected('delete'),
|
|
507
|
+
indeterminate: isSomeOfTypeSelected('delete'),
|
|
508
|
+
onClick: ()=>toggleAllOfType('delete')
|
|
509
|
+
}),
|
|
510
|
+
/*#__PURE__*/ _jsx("div", {
|
|
511
|
+
style: {
|
|
512
|
+
flex: 1
|
|
513
|
+
}
|
|
514
|
+
}),
|
|
515
|
+
/*#__PURE__*/ _jsx("button", {
|
|
516
|
+
type: "button",
|
|
517
|
+
onClick: selectAll,
|
|
518
|
+
style: {
|
|
368
519
|
padding: '4px 8px',
|
|
369
520
|
background: 'transparent',
|
|
370
521
|
border: '1px solid var(--theme-elevation-200)',
|
|
@@ -372,8 +523,14 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
372
523
|
color: 'var(--theme-text)',
|
|
373
524
|
fontSize: '11px',
|
|
374
525
|
cursor: 'pointer',
|
|
375
|
-
opacity: 0.8
|
|
376
|
-
},
|
|
526
|
+
opacity: 0.8
|
|
527
|
+
},
|
|
528
|
+
children: "Select All"
|
|
529
|
+
}),
|
|
530
|
+
/*#__PURE__*/ _jsx("button", {
|
|
531
|
+
type: "button",
|
|
532
|
+
onClick: clearAll,
|
|
533
|
+
style: {
|
|
377
534
|
padding: '4px 8px',
|
|
378
535
|
background: 'transparent',
|
|
379
536
|
border: '1px solid var(--theme-elevation-200)',
|
|
@@ -381,72 +538,140 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
381
538
|
color: 'var(--theme-text)',
|
|
382
539
|
fontSize: '11px',
|
|
383
540
|
cursor: 'pointer',
|
|
384
|
-
opacity: 0.8
|
|
385
|
-
},
|
|
541
|
+
opacity: 0.8
|
|
542
|
+
},
|
|
543
|
+
children: "Clear"
|
|
544
|
+
})
|
|
545
|
+
]
|
|
546
|
+
}),
|
|
547
|
+
/*#__PURE__*/ _jsx("div", {
|
|
548
|
+
style: {
|
|
386
549
|
background: 'var(--theme-input-bg)',
|
|
387
550
|
border: '1px solid var(--theme-elevation-150)',
|
|
388
551
|
borderRadius: 'var(--style-radius-s)',
|
|
389
552
|
maxHeight: '400px',
|
|
390
|
-
overflowY: 'auto'
|
|
391
|
-
},
|
|
553
|
+
overflowY: 'auto'
|
|
554
|
+
},
|
|
555
|
+
children: scopeGroups.map((group)=>{
|
|
392
556
|
const groupState = getGroupState(group);
|
|
393
557
|
const isExpanded = expandedGroups.has(group.collection);
|
|
394
|
-
return
|
|
395
|
-
|
|
396
|
-
|
|
558
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
559
|
+
style: {
|
|
560
|
+
borderBottom: '1px solid var(--theme-elevation-100)'
|
|
561
|
+
},
|
|
562
|
+
children: [
|
|
563
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
564
|
+
style: {
|
|
397
565
|
display: 'flex',
|
|
398
566
|
alignItems: 'center',
|
|
399
567
|
gap: 'calc(var(--base) * 0.5)',
|
|
400
568
|
padding: 'calc(var(--base) * 0.5) calc(var(--base) * 0.75)',
|
|
401
569
|
cursor: 'pointer',
|
|
402
|
-
background: groupState !== 'none' ? 'var(--theme-elevation-50)' : 'transparent'
|
|
403
|
-
},
|
|
570
|
+
background: groupState !== 'none' ? 'var(--theme-elevation-50)' : 'transparent'
|
|
571
|
+
},
|
|
572
|
+
onClick: ()=>toggleExpanded(group.collection),
|
|
573
|
+
children: [
|
|
574
|
+
/*#__PURE__*/ _jsx("span", {
|
|
575
|
+
style: {
|
|
404
576
|
color: 'var(--theme-elevation-500)',
|
|
405
577
|
fontSize: '10px',
|
|
406
578
|
width: '12px',
|
|
407
579
|
transition: 'transform 0.15s',
|
|
408
|
-
transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
409
|
-
},
|
|
580
|
+
transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
581
|
+
},
|
|
582
|
+
children: "▶"
|
|
583
|
+
}),
|
|
584
|
+
/*#__PURE__*/ _jsx(IndeterminateCheckbox, {
|
|
585
|
+
checked: groupState === 'all',
|
|
586
|
+
indeterminate: groupState === 'some',
|
|
587
|
+
onChange: (e)=>{
|
|
410
588
|
e.stopPropagation();
|
|
411
589
|
toggleGroup(group);
|
|
412
|
-
}
|
|
590
|
+
}
|
|
591
|
+
}),
|
|
592
|
+
/*#__PURE__*/ _jsx("span", {
|
|
593
|
+
style: {
|
|
413
594
|
color: 'var(--theme-text)',
|
|
414
595
|
fontSize: 'var(--font-size-small)',
|
|
415
596
|
fontWeight: 500,
|
|
416
|
-
flex: 1
|
|
417
|
-
},
|
|
597
|
+
flex: 1
|
|
598
|
+
},
|
|
599
|
+
children: group.label
|
|
600
|
+
}),
|
|
601
|
+
groupState !== 'none' && /*#__PURE__*/ _jsxs("span", {
|
|
602
|
+
style: {
|
|
418
603
|
padding: '2px 6px',
|
|
419
604
|
background: 'var(--theme-elevation-200)',
|
|
420
605
|
borderRadius: '10px',
|
|
421
606
|
fontSize: '10px',
|
|
422
|
-
color: 'var(--theme-elevation-700)'
|
|
423
|
-
},
|
|
607
|
+
color: 'var(--theme-elevation-700)'
|
|
608
|
+
},
|
|
609
|
+
children: [
|
|
610
|
+
group.scopes.filter((s)=>selectedScopes.includes(s.scope.id)).length,
|
|
611
|
+
"/",
|
|
612
|
+
group.scopes.length
|
|
613
|
+
]
|
|
614
|
+
})
|
|
615
|
+
]
|
|
616
|
+
}),
|
|
617
|
+
isExpanded && /*#__PURE__*/ _jsx("div", {
|
|
618
|
+
style: {
|
|
424
619
|
padding: '0 calc(var(--base) * 0.75) calc(var(--base) * 0.5)',
|
|
425
620
|
paddingLeft: 'calc(var(--base) * 2.5)',
|
|
426
621
|
display: 'flex',
|
|
427
622
|
flexDirection: 'column',
|
|
428
|
-
gap: 'calc(var(--base) * 0.25)'
|
|
429
|
-
},
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
: 'transparent'
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
623
|
+
gap: 'calc(var(--base) * 0.25)'
|
|
624
|
+
},
|
|
625
|
+
children: group.scopes.map(({ type, scope })=>/*#__PURE__*/ _jsxs("label", {
|
|
626
|
+
style: {
|
|
627
|
+
display: 'flex',
|
|
628
|
+
alignItems: 'center',
|
|
629
|
+
gap: 'calc(var(--base) * 0.5)',
|
|
630
|
+
cursor: 'pointer',
|
|
631
|
+
padding: 'calc(var(--base) * 0.25)',
|
|
632
|
+
borderRadius: 'var(--style-radius-s)',
|
|
633
|
+
background: selectedScopes.includes(scope.id) ? 'var(--theme-elevation-100)' : 'transparent'
|
|
634
|
+
},
|
|
635
|
+
children: [
|
|
636
|
+
/*#__PURE__*/ _jsx("input", {
|
|
637
|
+
type: "checkbox",
|
|
638
|
+
checked: selectedScopes.includes(scope.id),
|
|
639
|
+
onChange: ()=>toggleScope(scope.id)
|
|
640
|
+
}),
|
|
641
|
+
/*#__PURE__*/ _jsx("span", {
|
|
642
|
+
style: {
|
|
643
|
+
color: 'var(--theme-text)',
|
|
644
|
+
fontSize: 'var(--font-size-small)'
|
|
645
|
+
},
|
|
646
|
+
children: getTypeLabel(type)
|
|
647
|
+
})
|
|
648
|
+
]
|
|
649
|
+
}, scope.id))
|
|
650
|
+
})
|
|
651
|
+
]
|
|
652
|
+
}, group.collection);
|
|
653
|
+
})
|
|
654
|
+
}),
|
|
655
|
+
/*#__PURE__*/ _jsx("div", {
|
|
656
|
+
style: {
|
|
444
657
|
marginTop: 'calc(var(--base) * 0.5)',
|
|
445
658
|
fontSize: '11px',
|
|
446
|
-
color: selectedScopes.length === 0 ? 'var(--theme-warning-500)' : 'var(--theme-elevation-600)'
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
|
|
659
|
+
color: selectedScopes.length === 0 ? 'var(--theme-warning-500)' : 'var(--theme-elevation-600)'
|
|
660
|
+
},
|
|
661
|
+
children: selectedScopes.length === 0 ? 'No permissions selected. Key will have no access.' : `${selectedScopes.length} permission${selectedScopes.length === 1 ? '' : 's'} selected`
|
|
662
|
+
})
|
|
663
|
+
]
|
|
664
|
+
}),
|
|
665
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
666
|
+
style: {
|
|
667
|
+
display: 'flex',
|
|
668
|
+
gap: 'calc(var(--base) * 0.5)'
|
|
669
|
+
},
|
|
670
|
+
children: [
|
|
671
|
+
/*#__PURE__*/ _jsx("button", {
|
|
672
|
+
type: "submit",
|
|
673
|
+
disabled: creating,
|
|
674
|
+
style: {
|
|
450
675
|
padding: 'calc(var(--base) * 0.5) calc(var(--base) * 1)',
|
|
451
676
|
background: 'var(--theme-elevation-800)',
|
|
452
677
|
border: 'none',
|
|
@@ -454,98 +679,190 @@ export function ApiKeysManagementClient({ authClient: providedClient, title = 'A
|
|
|
454
679
|
color: 'var(--theme-elevation-50)',
|
|
455
680
|
fontSize: 'var(--font-size-small)',
|
|
456
681
|
cursor: creating ? 'not-allowed' : 'pointer',
|
|
457
|
-
opacity: creating ? 0.7 : 1
|
|
458
|
-
},
|
|
682
|
+
opacity: creating ? 0.7 : 1
|
|
683
|
+
},
|
|
684
|
+
children: creating ? 'Creating...' : 'Create'
|
|
685
|
+
}),
|
|
686
|
+
/*#__PURE__*/ _jsx("button", {
|
|
687
|
+
type: "button",
|
|
688
|
+
onClick: ()=>setShowCreateForm(false),
|
|
689
|
+
style: {
|
|
459
690
|
padding: 'calc(var(--base) * 0.5) calc(var(--base) * 1)',
|
|
460
691
|
background: 'transparent',
|
|
461
692
|
border: '1px solid var(--theme-elevation-200)',
|
|
462
693
|
borderRadius: 'var(--style-radius-s)',
|
|
463
694
|
color: 'var(--theme-text)',
|
|
464
695
|
fontSize: 'var(--font-size-small)',
|
|
465
|
-
cursor: 'pointer'
|
|
466
|
-
},
|
|
696
|
+
cursor: 'pointer'
|
|
697
|
+
},
|
|
698
|
+
children: "Cancel"
|
|
699
|
+
})
|
|
700
|
+
]
|
|
701
|
+
})
|
|
702
|
+
]
|
|
703
|
+
})
|
|
704
|
+
]
|
|
705
|
+
}),
|
|
706
|
+
loading ? /*#__PURE__*/ _jsx("div", {
|
|
707
|
+
style: {
|
|
467
708
|
color: 'var(--theme-text)',
|
|
468
709
|
opacity: 0.7,
|
|
469
710
|
textAlign: 'center',
|
|
470
|
-
padding: 'calc(var(--base) * 3)'
|
|
471
|
-
},
|
|
711
|
+
padding: 'calc(var(--base) * 3)'
|
|
712
|
+
},
|
|
713
|
+
children: "Loading API keys..."
|
|
714
|
+
}) : apiKeys.length === 0 ? /*#__PURE__*/ _jsx("div", {
|
|
715
|
+
style: {
|
|
472
716
|
color: 'var(--theme-text)',
|
|
473
717
|
opacity: 0.7,
|
|
474
718
|
textAlign: 'center',
|
|
475
|
-
padding: 'calc(var(--base) * 3)'
|
|
476
|
-
},
|
|
719
|
+
padding: 'calc(var(--base) * 3)'
|
|
720
|
+
},
|
|
721
|
+
children: "No API keys found. Create one to get started."
|
|
722
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
723
|
+
style: {
|
|
477
724
|
background: 'var(--theme-elevation-50)',
|
|
478
725
|
borderRadius: 'var(--style-radius-m)',
|
|
479
726
|
overflow: 'hidden',
|
|
480
|
-
border: '1px solid var(--theme-elevation-100)'
|
|
481
|
-
},
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
: 'none'
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
color: 'var(--theme-elevation-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
727
|
+
border: '1px solid var(--theme-elevation-100)'
|
|
728
|
+
},
|
|
729
|
+
children: apiKeys.map((key, index)=>/*#__PURE__*/ _jsxs("div", {
|
|
730
|
+
style: {
|
|
731
|
+
display: 'flex',
|
|
732
|
+
justifyContent: 'space-between',
|
|
733
|
+
alignItems: 'center',
|
|
734
|
+
padding: 'calc(var(--base) * 1)',
|
|
735
|
+
borderBottom: index < apiKeys.length - 1 ? '1px solid var(--theme-elevation-100)' : 'none'
|
|
736
|
+
},
|
|
737
|
+
children: [
|
|
738
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
739
|
+
style: {
|
|
740
|
+
flex: 1
|
|
741
|
+
},
|
|
742
|
+
children: [
|
|
743
|
+
/*#__PURE__*/ _jsx("div", {
|
|
744
|
+
style: {
|
|
745
|
+
color: 'var(--theme-text)',
|
|
746
|
+
fontWeight: 500,
|
|
747
|
+
marginBottom: 'calc(var(--base) * 0.25)'
|
|
748
|
+
},
|
|
749
|
+
children: key.name
|
|
750
|
+
}),
|
|
751
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
752
|
+
style: {
|
|
753
|
+
color: 'var(--theme-elevation-600)',
|
|
754
|
+
fontSize: 'var(--font-size-small)'
|
|
755
|
+
},
|
|
756
|
+
children: [
|
|
757
|
+
(key.start || key.startsWith) && /*#__PURE__*/ _jsxs("code", {
|
|
758
|
+
children: [
|
|
759
|
+
key.start || key.startsWith,
|
|
760
|
+
"..."
|
|
761
|
+
]
|
|
762
|
+
}),
|
|
763
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
764
|
+
children: [
|
|
765
|
+
" • Created: ",
|
|
766
|
+
formatDate(key.createdAt)
|
|
767
|
+
]
|
|
768
|
+
}),
|
|
769
|
+
key.expiresAt && /*#__PURE__*/ _jsxs("span", {
|
|
770
|
+
children: [
|
|
771
|
+
" • Expires: ",
|
|
772
|
+
formatDate(key.expiresAt)
|
|
773
|
+
]
|
|
774
|
+
}),
|
|
775
|
+
key.lastUsedAt && /*#__PURE__*/ _jsxs("span", {
|
|
776
|
+
children: [
|
|
777
|
+
" • Last used: ",
|
|
778
|
+
formatDate(key.lastUsedAt)
|
|
779
|
+
]
|
|
780
|
+
})
|
|
781
|
+
]
|
|
782
|
+
}),
|
|
783
|
+
key.metadata?.scopes && key.metadata.scopes.length > 0 && /*#__PURE__*/ _jsx("div", {
|
|
784
|
+
style: {
|
|
785
|
+
display: 'flex',
|
|
786
|
+
flexWrap: 'wrap',
|
|
787
|
+
gap: 'calc(var(--base) * 0.25)',
|
|
788
|
+
marginTop: 'calc(var(--base) * 0.5)'
|
|
789
|
+
},
|
|
790
|
+
children: key.metadata.scopes.map((scopeId)=>/*#__PURE__*/ _jsx("span", {
|
|
791
|
+
style: {
|
|
792
|
+
padding: '2px 6px',
|
|
793
|
+
background: 'var(--theme-elevation-100)',
|
|
794
|
+
borderRadius: 'var(--style-radius-s)',
|
|
795
|
+
fontSize: '11px',
|
|
796
|
+
color: 'var(--theme-elevation-700)'
|
|
797
|
+
},
|
|
798
|
+
children: getScopeLabel(scopeId)
|
|
799
|
+
}, scopeId))
|
|
800
|
+
})
|
|
801
|
+
]
|
|
802
|
+
}),
|
|
803
|
+
/*#__PURE__*/ _jsx("button", {
|
|
804
|
+
onClick: ()=>handleDelete(key.id),
|
|
805
|
+
disabled: deleting === key.id,
|
|
806
|
+
style: {
|
|
807
|
+
padding: 'calc(var(--base) * 0.5) calc(var(--base) * 0.75)',
|
|
808
|
+
background: 'transparent',
|
|
809
|
+
border: '1px solid var(--theme-error-300)',
|
|
810
|
+
borderRadius: 'var(--style-radius-s)',
|
|
811
|
+
color: 'var(--theme-error-500)',
|
|
812
|
+
fontSize: 'var(--font-size-small)',
|
|
813
|
+
cursor: deleting === key.id ? 'not-allowed' : 'pointer',
|
|
814
|
+
opacity: deleting === key.id ? 0.7 : 1
|
|
815
|
+
},
|
|
816
|
+
children: deleting === key.id ? 'Deleting...' : 'Delete'
|
|
817
|
+
})
|
|
818
|
+
]
|
|
819
|
+
}, key.id))
|
|
820
|
+
})
|
|
821
|
+
]
|
|
822
|
+
});
|
|
517
823
|
}
|
|
518
824
|
/**
|
|
519
825
|
* Bulk action button with active/indeterminate states
|
|
520
|
-
*/
|
|
521
|
-
|
|
522
|
-
|
|
826
|
+
*/ function BulkButton({ label, active, indeterminate, onClick }) {
|
|
827
|
+
return /*#__PURE__*/ _jsx("button", {
|
|
828
|
+
type: "button",
|
|
829
|
+
onClick: onClick,
|
|
830
|
+
style: {
|
|
523
831
|
padding: '4px 10px',
|
|
524
|
-
background: active
|
|
525
|
-
? 'var(--theme-elevation-700)'
|
|
526
|
-
: indeterminate
|
|
527
|
-
? 'var(--theme-elevation-300)'
|
|
528
|
-
: 'var(--theme-elevation-100)',
|
|
832
|
+
background: active ? 'var(--theme-elevation-700)' : indeterminate ? 'var(--theme-elevation-300)' : 'var(--theme-elevation-100)',
|
|
529
833
|
border: 'none',
|
|
530
834
|
borderRadius: 'var(--style-radius-s)',
|
|
531
835
|
color: active ? 'var(--theme-elevation-50)' : 'var(--theme-text)',
|
|
532
836
|
fontSize: '11px',
|
|
533
837
|
fontWeight: 500,
|
|
534
838
|
cursor: 'pointer',
|
|
535
|
-
transition: 'background 0.15s'
|
|
536
|
-
},
|
|
839
|
+
transition: 'background 0.15s'
|
|
840
|
+
},
|
|
841
|
+
children: label
|
|
842
|
+
});
|
|
537
843
|
}
|
|
538
844
|
/**
|
|
539
845
|
* Checkbox that supports indeterminate state
|
|
540
|
-
*/
|
|
541
|
-
function IndeterminateCheckbox({ checked, indeterminate, onChange, }) {
|
|
846
|
+
*/ function IndeterminateCheckbox({ checked, indeterminate, onChange }) {
|
|
542
847
|
const ref = useRef(null);
|
|
543
|
-
useEffect(()
|
|
848
|
+
useEffect(()=>{
|
|
544
849
|
if (ref.current) {
|
|
545
850
|
ref.current.indeterminate = indeterminate;
|
|
546
851
|
}
|
|
547
|
-
}, [
|
|
548
|
-
|
|
852
|
+
}, [
|
|
853
|
+
indeterminate
|
|
854
|
+
]);
|
|
855
|
+
return /*#__PURE__*/ _jsx("input", {
|
|
856
|
+
ref: ref,
|
|
857
|
+
type: "checkbox",
|
|
858
|
+
checked: checked,
|
|
859
|
+
onChange: ()=>{},
|
|
860
|
+
onClick: onChange,
|
|
861
|
+
style: {
|
|
862
|
+
cursor: 'pointer'
|
|
863
|
+
}
|
|
864
|
+
});
|
|
549
865
|
}
|
|
550
866
|
export default ApiKeysManagementClient;
|
|
867
|
+
|
|
551
868
|
//# sourceMappingURL=ApiKeysManagementClient.js.map
|