@tthr/vue 0.0.22 → 0.0.24

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.
@@ -247,24 +247,29 @@ export default defineEventHandler(async (event) => {
247
247
  const authHeader = getHeader(event, 'authorization');
248
248
  const strandsToken = getHeader(event, 'x-strands-token');
249
249
 
250
- // If using Strands auth, try to validate the token
250
+ // If using Strands auth, validate the token via Tether server
251
251
  if (strandsToken || authHeader?.startsWith('Bearer ')) {
252
252
  const token = strandsToken || authHeader?.replace('Bearer ', '');
253
253
  if (token) {
254
254
  try {
255
- // Try to fetch user identity from Strands auth service
256
- const authResponse = await fetch('https://accounts.strands.gg/api/auth/me', {
257
- headers: { 'Authorization': `Bearer ${token}` },
255
+ // Validate token via Tether server (which checks if Strands Auth is enabled)
256
+ const authResponse = await fetch(`${url}/api/v1/projects/${projectId}/auth/validate`, {
257
+ method: 'POST',
258
+ headers: { 'Content-Type': 'application/json' },
259
+ body: JSON.stringify({ accessToken: token }),
258
260
  });
259
261
  if (authResponse.ok) {
260
- const userData = await authResponse.json();
261
- userIdentity = {
262
- subject: userData.id || userData.sub,
263
- email: userData.email,
264
- ...userData,
265
- };
262
+ const authData = await authResponse.json();
263
+ if (authData.valid) {
264
+ userIdentity = {
265
+ subject: authData.userId,
266
+ email: authData.email,
267
+ name: authData.name,
268
+ };
269
+ }
266
270
  }
267
- } catch {
271
+ } catch (authError) {
272
+ console.warn('[Tether] Auth validation failed:', authError.message);
268
273
  // Auth validation failed - continue without identity
269
274
  }
270
275
  }
@@ -21,12 +21,18 @@ async function loadFunctionRegistry() {
21
21
  try {
22
22
  // Try to import the user's functions index
23
23
  // This path is relative to the Nuxt app's server runtime
24
- const functions = await import('~~/tether/functions/index.ts').catch(() => null);
24
+ console.log('[Tether] Loading custom functions from ~~/tether/functions/index.ts');
25
+ const functions = await import('~~/tether/functions/index.ts').catch((err) => {
26
+ console.warn('[Tether] Failed to import functions:', err.message);
27
+ return null;
28
+ });
25
29
 
26
30
  if (functions) {
31
+ console.log('[Tether] Loaded function modules:', Object.keys(functions));
27
32
  functionRegistry = functions;
28
33
  } else {
29
34
  // No custom functions found - that's OK, we'll proxy everything
35
+ console.log('[Tether] No custom functions found, will proxy all requests');
30
36
  functionRegistry = {};
31
37
  }
32
38
  } catch (error) {
@@ -234,6 +240,7 @@ export default defineEventHandler(async (event) => {
234
240
 
235
241
  // Try to find a custom function
236
242
  const customFn = lookupFunction(body.function);
243
+ console.log(`[Tether] Query: ${body.function}, custom function found: ${!!customFn}`);
237
244
 
238
245
  if (customFn) {
239
246
  // Execute locally with database proxy
@@ -248,24 +255,29 @@ export default defineEventHandler(async (event) => {
248
255
  const authHeader = getHeader(event, 'authorization');
249
256
  const strandsToken = getHeader(event, 'x-strands-token');
250
257
 
251
- // If using Strands auth, try to validate the token
258
+ // If using Strands auth, validate the token via Tether server
252
259
  if (strandsToken || authHeader?.startsWith('Bearer ')) {
253
260
  const token = strandsToken || authHeader?.replace('Bearer ', '');
254
261
  if (token) {
255
262
  try {
256
- // Try to fetch user identity from Strands auth service
257
- const authResponse = await fetch('https://accounts.strands.gg/api/auth/me', {
258
- headers: { 'Authorization': `Bearer ${token}` },
263
+ // Validate token via Tether server (which checks if Strands Auth is enabled)
264
+ const authResponse = await fetch(`${url}/api/v1/projects/${projectId}/auth/validate`, {
265
+ method: 'POST',
266
+ headers: { 'Content-Type': 'application/json' },
267
+ body: JSON.stringify({ accessToken: token }),
259
268
  });
260
269
  if (authResponse.ok) {
261
- const userData = await authResponse.json();
262
- userIdentity = {
263
- subject: userData.id || userData.sub,
264
- email: userData.email,
265
- ...userData,
266
- };
270
+ const authData = await authResponse.json();
271
+ if (authData.valid) {
272
+ userIdentity = {
273
+ subject: authData.userId,
274
+ email: authData.email,
275
+ name: authData.name,
276
+ };
277
+ }
267
278
  }
268
- } catch {
279
+ } catch (authError) {
280
+ console.warn('[Tether] Auth validation failed:', authError.message);
269
281
  // Auth validation failed - continue without identity
270
282
  }
271
283
  }
@@ -283,12 +295,14 @@ export default defineEventHandler(async (event) => {
283
295
  userId: userIdentity?.subject ?? null,
284
296
  };
285
297
 
298
+ console.log(`[Tether] Executing custom function: ${body.function}`);
286
299
  const result = await customFn.handler({
287
300
  db,
288
301
  ctx,
289
302
  auth,
290
303
  args: body.args ?? {},
291
304
  });
305
+ console.log(`[Tether] Function ${body.function} completed`);
292
306
 
293
307
  return { data: result };
294
308
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tthr/vue",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "Tether Vue/Nuxt SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,11 +22,6 @@
22
22
  "dist",
23
23
  "nuxt"
24
24
  ],
25
- "scripts": {
26
- "build": "tsc",
27
- "dev": "tsc --watch",
28
- "typecheck": "tsc --noEmit"
29
- },
30
25
  "dependencies": {
31
26
  "@nuxt/kit": "^3.14.0",
32
27
  "@tthr/client": "latest",
@@ -37,5 +32,10 @@
37
32
  },
38
33
  "peerDependencies": {
39
34
  "vue": "^3.0.0"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "dev": "tsc --watch",
39
+ "typecheck": "tsc --noEmit"
40
40
  }
41
- }
41
+ }