skikrumb-api 2.1.2 → 2.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +64 -107
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -64,7 +64,6 @@ class SkiKrumbRealtimeClient {
64
64
  }
65
65
  else if (message.type === 'auth_error' ||
66
66
  message.type === 'error') {
67
- console.error('❌ Authentication/Connection failed:', message.message || message.error);
68
67
  (_a = this.websocket) === null || _a === void 0 ? void 0 : _a.close();
69
68
  reject(new Error(`Connection failed: ${message.message || message.error}`));
70
69
  }
@@ -108,12 +107,10 @@ class SkiKrumbRealtimeClient {
108
107
  }
109
108
  }
110
109
  catch (error) {
111
- console.error('❌ Error parsing realtime message:', error);
112
110
  this.emit('error', error);
113
111
  }
114
112
  };
115
113
  this.websocket.onerror = (error) => {
116
- console.warn('⚠️ Realtime connection event');
117
114
  this.isConnecting = false;
118
115
  this.emit('error', error);
119
116
  reject(error);
@@ -153,9 +150,7 @@ class SkiKrumbRealtimeClient {
153
150
  const delay = this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1);
154
151
  setTimeout(() => {
155
152
  this.connect().catch((error) => {
156
- console.error('❌ Reconnect failed:', error);
157
153
  if (this.reconnectAttempts >= this.maxReconnectAttempts) {
158
- console.error('❌ Max reconnect attempts reached');
159
154
  this.emit('max_reconnect_attempts_reached');
160
155
  }
161
156
  });
@@ -213,9 +208,7 @@ class SkiKrumbRealtimeClient {
213
208
  try {
214
209
  callback(data);
215
210
  }
216
- catch (error) {
217
- console.error(`❌ Error in realtime event listener for '${event}':`, error);
218
- }
211
+ catch (error) { }
219
212
  });
220
213
  }
221
214
  isConnected() {
@@ -319,115 +312,79 @@ export const skiKrumb = (options = {
319
312
  }
320
313
  };
321
314
  const sendMobileLocation = async (payload) => {
322
- try {
323
- const response = await request
324
- .post('devices/location/mobile', { json: payload })
325
- .json();
326
- return response;
327
- }
328
- catch (error) {
329
- console.error('❌ Send Mobile Location Error:', error);
330
- throw error;
331
- }
315
+ const response = await request
316
+ .post('devices/location/mobile', { json: payload })
317
+ .json();
318
+ return response;
332
319
  };
333
320
  const authenticateExternalUser = async (userData) => {
334
- try {
335
- const response = await request
336
- .post('auth/external', { json: userData })
337
- .json();
338
- return response;
339
- }
340
- catch (error) {
341
- console.error('❌ External User Authentication Error:', error);
342
- throw error;
343
- }
321
+ const response = await request
322
+ .post('auth/external', { json: userData })
323
+ .json();
324
+ return response;
344
325
  };
345
326
  const refreshSessionToken = async (currentToken) => {
346
- try {
347
- // Create temporary request with current token
348
- const refreshRequest = ky.create({
349
- prefixUrl: options.url,
350
- headers: {
351
- 'Content-Type': 'application/json',
352
- Authorization: `Bearer ${currentToken}`,
353
- 'x-client': options.requestedWith,
354
- },
355
- });
356
- const response = await refreshRequest.post('auth/external/refresh').json();
357
- return {
358
- success: response.success,
359
- sessionToken: response.sessionToken,
360
- accessibleSerials: response.accessibleSerials,
361
- serialsCount: response.serialsCount,
362
- timestamp: response.timestamp,
363
- };
364
- }
365
- catch (error) {
366
- console.error('❌ Token Refresh Error:', error);
367
- throw error;
368
- }
327
+ // Create temporary request with current token
328
+ const refreshRequest = ky.create({
329
+ prefixUrl: options.url,
330
+ headers: {
331
+ 'Content-Type': 'application/json',
332
+ Authorization: `Bearer ${currentToken}`,
333
+ 'x-client': options.requestedWith,
334
+ },
335
+ });
336
+ const response = await refreshRequest.post('auth/external/refresh').json();
337
+ return {
338
+ success: response.success,
339
+ sessionToken: response.sessionToken,
340
+ accessibleSerials: response.accessibleSerials,
341
+ serialsCount: response.serialsCount,
342
+ timestamp: response.timestamp,
343
+ };
369
344
  };
370
345
  const createSharingLink = async (shareRequest) => {
371
- try {
372
- const requestWithAuth = ky.create({
373
- prefixUrl: options.url,
374
- headers: {
375
- 'Content-Type': 'application/json',
376
- Authorization: `Bearer ${options.apiKey}`,
377
- 'supabase-auth-token': options.supabaseToken || '',
378
- 'x-client': options.requestedWith,
379
- },
380
- });
381
- const response = await requestWithAuth
382
- .post('sharing/create', { json: shareRequest })
383
- .json();
384
- return response;
385
- }
386
- catch (error) {
387
- console.error('❌ Create Sharing Link Error:', error);
388
- throw error;
389
- }
346
+ const requestWithAuth = ky.create({
347
+ prefixUrl: options.url,
348
+ headers: {
349
+ 'Content-Type': 'application/json',
350
+ Authorization: `Bearer ${options.apiKey}`,
351
+ 'supabase-auth-token': options.supabaseToken || '',
352
+ 'x-client': options.requestedWith,
353
+ },
354
+ });
355
+ const response = await requestWithAuth
356
+ .post('sharing/create', { json: shareRequest })
357
+ .json();
358
+ return response;
390
359
  };
391
360
  const previewSharingLink = async (token) => {
392
- try {
393
- const requestWithAuth = ky.create({
394
- prefixUrl: options.url,
395
- headers: {
396
- Authorization: `Bearer ${options.apiKey}`,
397
- 'supabase-auth-token': options.supabaseToken || '',
398
- 'x-client': options.requestedWith,
399
- },
400
- });
401
- const response = await requestWithAuth
402
- .get(`sharing/accept/${token}`)
403
- .json();
404
- return response;
405
- }
406
- catch (error) {
407
- console.error('❌ Preview Sharing Link Error:', error);
408
- throw error;
409
- }
361
+ const requestWithAuth = ky.create({
362
+ prefixUrl: options.url,
363
+ headers: {
364
+ Authorization: `Bearer ${options.apiKey}`,
365
+ 'supabase-auth-token': options.supabaseToken || '',
366
+ 'x-client': options.requestedWith,
367
+ },
368
+ });
369
+ const response = await requestWithAuth
370
+ .get(`sharing/accept/${token}`)
371
+ .json();
372
+ return response;
410
373
  };
411
374
  const acceptSharingLink = async (token, acceptRequest) => {
412
- try {
413
- const requestWithAuth = ky.create({
414
- prefixUrl: options.url,
415
- headers: {
416
- 'Content-Type': 'application/json',
417
- Authorization: `Bearer ${options.apiKey}`,
418
- 'supabase-auth-token': options.supabaseToken || '',
419
- 'x-client': options.requestedWith,
420
- },
421
- });
422
- const response = await requestWithAuth
423
- .post(`sharing/accept/${token}`, { json: acceptRequest })
424
- .json();
425
- return response;
426
- }
427
- catch (error) {
428
- console.error('❌ Accept Sharing Link Error:', error);
429
- throw error;
430
- }
375
+ const requestWithAuth = ky.create({
376
+ prefixUrl: options.url,
377
+ headers: {
378
+ 'Content-Type': 'application/json',
379
+ Authorization: `Bearer ${options.apiKey}`,
380
+ 'supabase-auth-token': options.supabaseToken || '',
381
+ 'x-client': options.requestedWith,
382
+ },
383
+ });
384
+ const response = await requestWithAuth
385
+ .post(`sharing/accept/${token}`, { json: acceptRequest })
386
+ .json();
387
+ return response;
431
388
  };
432
389
  return {
433
390
  createDevice,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skikrumb-api",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Wrapper for the skiKrumb API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",