@makolabs/ripple 1.6.8 → 1.6.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.
|
@@ -93,7 +93,7 @@ async function makeAuthRequest(endpoint, options = {}) {
|
|
|
93
93
|
try {
|
|
94
94
|
data = JSON.parse(text);
|
|
95
95
|
}
|
|
96
|
-
catch
|
|
96
|
+
catch {
|
|
97
97
|
// Not JSON, treat as plain text error (e.g., "404 page not found")
|
|
98
98
|
data = { error: text, message: text };
|
|
99
99
|
}
|
|
@@ -116,7 +116,7 @@ async function verifyApiKeyToken(apiKey) {
|
|
|
116
116
|
const verifyResult = await makeAuthRequest('/auth/verify', {
|
|
117
117
|
method: 'GET',
|
|
118
118
|
headers: {
|
|
119
|
-
|
|
119
|
+
Authorization: `Bearer ${token}`
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
if (verifyResult.ok && verifyResult.data?.data) {
|
|
@@ -129,7 +129,9 @@ async function verifyApiKeyToken(apiKey) {
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
const errorMsg = result.data?.message ||
|
|
132
|
+
const errorMsg = result.data?.message ||
|
|
133
|
+
result.data?.error ||
|
|
134
|
+
`API key verification failed with status ${result.status}`;
|
|
133
135
|
console.warn('[verifyApiKeyToken] Verification failed:', errorMsg);
|
|
134
136
|
return {
|
|
135
137
|
valid: false,
|
|
@@ -460,7 +462,7 @@ export const updateUserPermissions = command('unchecked', async (options) => {
|
|
|
460
462
|
console.log('[updateUserPermissions] Key verification:', verification);
|
|
461
463
|
if (verification.valid) {
|
|
462
464
|
// Check if the scopes match what we expect
|
|
463
|
-
const scopesMatch = filteredPermissions.every(perm => verification.scopes?.includes(perm));
|
|
465
|
+
const scopesMatch = filteredPermissions.every((perm) => verification.scopes?.includes(perm));
|
|
464
466
|
if (!scopesMatch) {
|
|
465
467
|
console.warn('[updateUserPermissions] Scopes mismatch. Expected:', filteredPermissions, 'Got:', verification.scopes);
|
|
466
468
|
}
|
|
@@ -510,7 +512,7 @@ export const generateApiKey = command('unchecked', async (options) => {
|
|
|
510
512
|
const keyId = userKeys[0].id;
|
|
511
513
|
// Get the old API key from Clerk's private_metadata
|
|
512
514
|
currentUser = await makeClerkRequest(`/users/${options.userId}`);
|
|
513
|
-
oldApiKey = currentUser
|
|
515
|
+
oldApiKey = currentUser?.private_metadata?.mako_api_key;
|
|
514
516
|
const rotateResult = await makeAdminRequest(`/admin/keys/${keyId}/rotate`, {
|
|
515
517
|
method: 'POST',
|
|
516
518
|
body: JSON.stringify({
|
|
@@ -542,7 +544,7 @@ export const generateApiKey = command('unchecked', async (options) => {
|
|
|
542
544
|
console.log('[generateApiKey] New key verification:', newKeyVerification);
|
|
543
545
|
if (newKeyVerification.valid) {
|
|
544
546
|
// Check if the scopes match what we expect
|
|
545
|
-
const scopesMatch = filteredPermissions.every(perm => newKeyVerification.scopes?.includes(perm));
|
|
547
|
+
const scopesMatch = filteredPermissions.every((perm) => newKeyVerification.scopes?.includes(perm));
|
|
546
548
|
if (!scopesMatch) {
|
|
547
549
|
console.warn('[generateApiKey] Scopes mismatch. Expected:', filteredPermissions, 'Got:', newKeyVerification.scopes);
|
|
548
550
|
}
|
|
@@ -572,15 +574,17 @@ export const generateApiKey = command('unchecked', async (options) => {
|
|
|
572
574
|
if (!currentUser) {
|
|
573
575
|
currentUser = await makeClerkRequest(`/users/${options.userId}`);
|
|
574
576
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
577
|
+
if (currentUser) {
|
|
578
|
+
await makeClerkRequest(`/users/${options.userId}`, {
|
|
579
|
+
method: 'PATCH',
|
|
580
|
+
body: JSON.stringify({
|
|
581
|
+
private_metadata: {
|
|
582
|
+
...(currentUser.private_metadata || {}),
|
|
583
|
+
mako_api_key: newApiKey
|
|
584
|
+
}
|
|
585
|
+
})
|
|
586
|
+
});
|
|
587
|
+
}
|
|
584
588
|
}
|
|
585
589
|
catch (clerkError) {
|
|
586
590
|
console.error('[generateApiKey] Failed to update Clerk profile:', clerkError);
|
|
@@ -589,9 +593,7 @@ export const generateApiKey = command('unchecked', async (options) => {
|
|
|
589
593
|
const result = {
|
|
590
594
|
success: true,
|
|
591
595
|
apiKey: newApiKey,
|
|
592
|
-
message: wasRotated
|
|
593
|
-
? 'API key rotated successfully'
|
|
594
|
-
: 'API key generated successfully'
|
|
596
|
+
message: wasRotated ? 'API key rotated successfully' : 'API key generated successfully'
|
|
595
597
|
};
|
|
596
598
|
return JSON.parse(JSON.stringify(result));
|
|
597
599
|
}
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
let showApiKey = $state(false);
|
|
32
32
|
let regeneratingApiKey = $state(false);
|
|
33
33
|
let verifyingToken = $state(false);
|
|
34
|
-
let tokenVerification = $state<{ valid?: boolean; scopes?: string[]; error?: string } | null>(
|
|
34
|
+
let tokenVerification = $state<{ valid?: boolean; scopes?: string[]; error?: string } | null>(
|
|
35
|
+
null
|
|
36
|
+
);
|
|
35
37
|
let initialRole = $state<string>('');
|
|
36
38
|
|
|
37
39
|
// Form data
|
|
@@ -187,7 +189,7 @@
|
|
|
187
189
|
role: roleValue,
|
|
188
190
|
permissions: role ? [...role.permissions] : []
|
|
189
191
|
};
|
|
190
|
-
|
|
192
|
+
|
|
191
193
|
// Clear token verification when permissions change
|
|
192
194
|
tokenVerification = null;
|
|
193
195
|
}
|
|
@@ -233,7 +235,7 @@
|
|
|
233
235
|
|
|
234
236
|
try {
|
|
235
237
|
verifyingToken = true;
|
|
236
|
-
formErrors.apiKey
|
|
238
|
+
delete formErrors.apiKey;
|
|
237
239
|
const result = await adapter.verifyToken({ apiKey });
|
|
238
240
|
tokenVerification = result;
|
|
239
241
|
|
|
@@ -449,8 +451,18 @@
|
|
|
449
451
|
{#if tokenVerification.valid}
|
|
450
452
|
<div class="bg-success-50 border-success-200 mt-2 rounded-lg border p-3">
|
|
451
453
|
<div class="flex items-start gap-2">
|
|
452
|
-
<svg
|
|
453
|
-
|
|
454
|
+
<svg
|
|
455
|
+
class="text-success-600 mt-0.5 h-4 w-4 shrink-0"
|
|
456
|
+
fill="none"
|
|
457
|
+
stroke="currentColor"
|
|
458
|
+
viewBox="0 0 24 24"
|
|
459
|
+
>
|
|
460
|
+
<path
|
|
461
|
+
stroke-linecap="round"
|
|
462
|
+
stroke-linejoin="round"
|
|
463
|
+
stroke-width="2"
|
|
464
|
+
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
465
|
+
></path>
|
|
454
466
|
</svg>
|
|
455
467
|
<div class="min-w-0 flex-1">
|
|
456
468
|
<p class="text-success-800 text-xs font-medium">Token verified successfully</p>
|
|
@@ -465,8 +477,18 @@
|
|
|
465
477
|
{:else}
|
|
466
478
|
<div class="bg-danger-50 border-danger-200 mt-2 rounded-lg border p-3">
|
|
467
479
|
<div class="flex items-start gap-2">
|
|
468
|
-
<svg
|
|
469
|
-
|
|
480
|
+
<svg
|
|
481
|
+
class="text-danger-600 mt-0.5 h-4 w-4 shrink-0"
|
|
482
|
+
fill="none"
|
|
483
|
+
stroke="currentColor"
|
|
484
|
+
viewBox="0 0 24 24"
|
|
485
|
+
>
|
|
486
|
+
<path
|
|
487
|
+
stroke-linecap="round"
|
|
488
|
+
stroke-linejoin="round"
|
|
489
|
+
stroke-width="2"
|
|
490
|
+
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
491
|
+
></path>
|
|
470
492
|
</svg>
|
|
471
493
|
<div class="min-w-0 flex-1">
|
|
472
494
|
<p class="text-danger-800 text-xs font-medium">Token verification failed</p>
|