@makolabs/ripple 1.7.4 → 1.7.5

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
  }>>;
@@ -122,9 +122,11 @@ async function verifyApiKeyToken(apiKey) {
122
122
  // The API returns "scope" (singular) as a space-separated string, not "scopes" array
123
123
  const scopeString = verifyResult.data.data.scope;
124
124
  const scopes = scopeString ? scopeString.split(' ').filter(Boolean) : [];
125
+ const sub = verifyResult.data.data.sub;
125
126
  return {
126
127
  valid: true,
127
- scopes: scopes
128
+ scopes: scopes,
129
+ sub: sub
128
130
  };
129
131
  }
130
132
  }
@@ -335,7 +337,7 @@ export const deleteUsers = command('unchecked', async (userIds) => {
335
337
  });
336
338
  async function fetchUserPermissions(email) {
337
339
  try {
338
- const userData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${email}`);
340
+ const userData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${encodeURIComponent(email)}`);
339
341
  if (userData?.data?.data && Array.isArray(userData.data.data)) {
340
342
  userData.data.data = userData.data.data.filter((key) => key.status === 'active');
341
343
  }
@@ -433,7 +435,7 @@ export const updateUserPermissions = command('unchecked', async (options) => {
433
435
  throw new Error('User has no email address');
434
436
  }
435
437
  // Fetch user's active keys
436
- const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${email}`);
438
+ const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${encodeURIComponent(email)}`);
437
439
  const userKeys = (allKeysData?.data?.data || []).filter((key) => key.status === 'active');
438
440
  if (userKeys.length === 0) {
439
441
  // No active key exists, create new one
@@ -514,7 +516,7 @@ export const generateApiKey = command('unchecked', async (options) => {
514
516
  throw new Error('User has no email address');
515
517
  }
516
518
  // Check if user has existing active key
517
- const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${email}`);
519
+ const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${encodeURIComponent(email)}`);
518
520
  const userKeys = (allKeysData?.data?.data || []).filter((key) => key.status === 'active');
519
521
  let newApiKey;
520
522
  let wasRotated = false;
@@ -622,6 +624,8 @@ export const generateApiKey = command('unchecked', async (options) => {
622
624
  export const verifyToken = command('unchecked', async (options) => {
623
625
  try {
624
626
  const result = await verifyApiKeyToken(options.apiKey);
627
+ console.log('[verifyToken] Current scopes:', result.scopes);
628
+ console.log('[verifyToken] Sub:', result.sub);
625
629
  // Also return the issued token for debugging
626
630
  if (result.valid) {
627
631
  try {
@@ -634,6 +638,7 @@ export const verifyToken = command('unchecked', async (options) => {
634
638
  const finalResult = {
635
639
  valid: result.valid,
636
640
  scopes: result.scopes,
641
+ sub: result.sub,
637
642
  token: tokenResult.data?.data?.access_token
638
643
  };
639
644
  // Ensure result is serializable
@@ -644,7 +649,8 @@ export const verifyToken = command('unchecked', async (options) => {
644
649
  // Return result without token
645
650
  return JSON.parse(JSON.stringify({
646
651
  valid: result.valid,
647
- scopes: result.scopes
652
+ scopes: result.scopes,
653
+ sub: result.sub
648
654
  }));
649
655
  }
650
656
  }
@@ -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.5",
4
4
  "description": "Simple Svelte 5 powered component library ✨",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {