@makolabs/ripple 1.7.4 → 1.7.6

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.
@@ -26,6 +26,7 @@ export declare const verifyToken: import("@sveltejs/kit").RemoteCommand<{
26
26
  }, Promise<{
27
27
  valid: boolean;
28
28
  scopes?: string[];
29
+ sub?: string;
29
30
  error?: string;
30
31
  token?: string;
31
32
  }>>;
@@ -18,7 +18,12 @@ async function makeClerkRequest(endpoint, options = {}) {
18
18
  if (!CLERK_SECRET_KEY) {
19
19
  throw new Error('CLERK_SECRET_KEY environment variable is required');
20
20
  }
21
- const response = await fetch(`https://api.clerk.com/v1${endpoint}`, {
21
+ const method = options.method || 'GET';
22
+ const url = `https://api.clerk.com/v1${endpoint}`;
23
+ console.log(`[Clerk API] ${method} ${url}`);
24
+ if (options.body)
25
+ console.log(`[Clerk API] Payload: ${options.body}`);
26
+ const response = await fetch(url, {
22
27
  ...options,
23
28
  headers: {
24
29
  Authorization: `Bearer ${CLERK_SECRET_KEY}`,
@@ -28,7 +33,8 @@ async function makeClerkRequest(endpoint, options = {}) {
28
33
  });
29
34
  if (!response.ok) {
30
35
  const errorText = await response.text();
31
- console.error(`[Clerk API] ${response.status} ${response.statusText} - ${errorText}`);
36
+ console.error(`[Clerk API] Response: ${response.status} ${response.statusText}`);
37
+ console.error(`[Clerk API] Body: ${errorText}`);
32
38
  let errorDetails;
33
39
  try {
34
40
  errorDetails = JSON.parse(errorText);
@@ -42,6 +48,8 @@ async function makeClerkRequest(endpoint, options = {}) {
42
48
  throw error;
43
49
  }
44
50
  const data = await response.json();
51
+ console.log(`[Clerk API] Response: ${response.status} ${response.statusText}`);
52
+ console.log(`[Clerk API] Body: ${JSON.stringify(data).slice(0, 500)}`);
45
53
  // Ensure all data is serializable by converting to plain objects
46
54
  return JSON.parse(JSON.stringify(data));
47
55
  }
@@ -56,7 +64,11 @@ async function makeAdminRequest(endpoint, options = {}) {
56
64
  missing.push('PRIVATE_BASE_AUTH_URL');
57
65
  throw new Error(`Admin API configuration missing: ${missing.join(', ')}`);
58
66
  }
67
+ const method = options.method || 'GET';
59
68
  const url = `${PRIVATE_BASE_AUTH_URL}${endpoint}`;
69
+ console.log(`[Admin API] ${method} ${url}`);
70
+ if (options.body)
71
+ console.log(`[Admin API] Payload: ${options.body}`);
60
72
  const response = await fetch(url, {
61
73
  ...options,
62
74
  headers: {
@@ -67,10 +79,13 @@ async function makeAdminRequest(endpoint, options = {}) {
67
79
  });
68
80
  if (!response.ok) {
69
81
  const errorText = await response.text();
70
- console.error(`[Admin API] ${response.status} ${response.statusText} - ${errorText}`);
82
+ console.error(`[Admin API] Response: ${response.status} ${response.statusText}`);
83
+ console.error(`[Admin API] Body: ${errorText}`);
71
84
  throw new Error(`Admin API request failed: ${response.status} ${response.statusText} - ${errorText}`);
72
85
  }
73
86
  const data = await response.json();
87
+ console.log(`[Admin API] Response: ${response.status} ${response.statusText}`);
88
+ console.log(`[Admin API] Body: ${JSON.stringify(data).slice(0, 500)}`);
74
89
  // Ensure all data is serializable by converting to plain objects
75
90
  return JSON.parse(JSON.stringify(data));
76
91
  }
@@ -79,7 +94,11 @@ async function makeAuthRequest(endpoint, options = {}) {
79
94
  if (!PRIVATE_BASE_AUTH_URL) {
80
95
  throw new Error('PRIVATE_BASE_AUTH_URL environment variable is required');
81
96
  }
97
+ const method = options.method || 'GET';
82
98
  const url = `${PRIVATE_BASE_AUTH_URL}${endpoint}`;
99
+ console.log(`[Auth API] ${method} ${url}`);
100
+ if (options.body)
101
+ console.log(`[Auth API] Payload: ${options.body}`);
83
102
  const response = await fetch(url, {
84
103
  ...options,
85
104
  headers: {
@@ -96,6 +115,8 @@ async function makeAuthRequest(endpoint, options = {}) {
96
115
  // Not JSON, treat as plain text error (e.g., "404 page not found")
97
116
  data = { error: text, message: text };
98
117
  }
118
+ console.log(`[Auth API] Response: ${response.status} ${response.statusText}`);
119
+ console.log(`[Auth API] Body: ${JSON.stringify(data).slice(0, 500)}`);
99
120
  return {
100
121
  ok: response.ok,
101
122
  status: response.status,
@@ -122,9 +143,11 @@ async function verifyApiKeyToken(apiKey) {
122
143
  // The API returns "scope" (singular) as a space-separated string, not "scopes" array
123
144
  const scopeString = verifyResult.data.data.scope;
124
145
  const scopes = scopeString ? scopeString.split(' ').filter(Boolean) : [];
146
+ const sub = verifyResult.data.data.sub;
125
147
  return {
126
148
  valid: true,
127
- scopes: scopes
149
+ scopes: scopes,
150
+ sub: sub
128
151
  };
129
152
  }
130
153
  }
@@ -335,7 +358,7 @@ export const deleteUsers = command('unchecked', async (userIds) => {
335
358
  });
336
359
  async function fetchUserPermissions(email) {
337
360
  try {
338
- const userData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${email}`);
361
+ const userData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${encodeURIComponent(email)}`);
339
362
  if (userData?.data?.data && Array.isArray(userData.data.data)) {
340
363
  userData.data.data = userData.data.data.filter((key) => key.status === 'active');
341
364
  }
@@ -433,7 +456,7 @@ export const updateUserPermissions = command('unchecked', async (options) => {
433
456
  throw new Error('User has no email address');
434
457
  }
435
458
  // Fetch user's active keys
436
- const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${email}`);
459
+ const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${encodeURIComponent(email)}`);
437
460
  const userKeys = (allKeysData?.data?.data || []).filter((key) => key.status === 'active');
438
461
  if (userKeys.length === 0) {
439
462
  // No active key exists, create new one
@@ -514,7 +537,7 @@ export const generateApiKey = command('unchecked', async (options) => {
514
537
  throw new Error('User has no email address');
515
538
  }
516
539
  // Check if user has existing active key
517
- const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${email}`);
540
+ const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${encodeURIComponent(email)}`);
518
541
  const userKeys = (allKeysData?.data?.data || []).filter((key) => key.status === 'active');
519
542
  let newApiKey;
520
543
  let wasRotated = false;
@@ -622,6 +645,8 @@ export const generateApiKey = command('unchecked', async (options) => {
622
645
  export const verifyToken = command('unchecked', async (options) => {
623
646
  try {
624
647
  const result = await verifyApiKeyToken(options.apiKey);
648
+ console.log('[verifyToken] Current scopes:', result.scopes);
649
+ console.log('[verifyToken] Sub:', result.sub);
625
650
  // Also return the issued token for debugging
626
651
  if (result.valid) {
627
652
  try {
@@ -634,6 +659,7 @@ export const verifyToken = command('unchecked', async (options) => {
634
659
  const finalResult = {
635
660
  valid: result.valid,
636
661
  scopes: result.scopes,
662
+ sub: result.sub,
637
663
  token: tokenResult.data?.data?.access_token
638
664
  };
639
665
  // Ensure result is serializable
@@ -644,7 +670,8 @@ export const verifyToken = command('unchecked', async (options) => {
644
670
  // Return result without token
645
671
  return JSON.parse(JSON.stringify({
646
672
  valid: result.valid,
647
- scopes: result.scopes
673
+ scopes: result.scopes,
674
+ sub: result.sub
648
675
  }));
649
676
  }
650
677
  }
@@ -32,9 +32,12 @@
32
32
  let showApiKey = $state(false);
33
33
  let regeneratingApiKey = $state(false);
34
34
  let verifyingToken = $state(false);
35
- let tokenVerification = $state<{ valid?: boolean; scopes?: string[]; error?: string } | null>(
36
- null
37
- );
35
+ let tokenVerification = $state<{
36
+ valid?: boolean;
37
+ scopes?: string[];
38
+ sub?: string;
39
+ error?: string;
40
+ } | null>(null);
38
41
  let initialRole = $state<string>('');
39
42
 
40
43
  // Form data
@@ -482,6 +485,11 @@
482
485
  </svg>
483
486
  <div class="min-w-0 flex-1">
484
487
  <p class="text-success-800 text-xs font-medium">Token verified successfully</p>
488
+ {#if tokenVerification.sub}
489
+ <p class="text-success-700 mt-1 text-xs">
490
+ Sub: {tokenVerification.sub}
491
+ </p>
492
+ {/if}
485
493
  {#if tokenVerification.scopes && tokenVerification.scopes.length > 0}
486
494
  <p class="text-success-700 mt-1 text-xs">
487
495
  Scopes: {tokenVerification.scopes.join(', ')}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makolabs/ripple",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "Simple Svelte 5 powered component library ✨",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {