@taruvi/sdk 1.4.2 → 1.4.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taruvi/sdk",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Taruvi SDK",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
package/src/client.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { HttpClient } from "./lib-internal/http/HttpClient.js";
2
2
  import { TokenClient, type AuthTokens } from "./lib-internal/token/TokenClient.js";
3
3
  import type { TaruviConfig } from "./types.js";
4
+ import packageJson from "../package.json" with { type: "json" };
4
5
 
5
6
  export class Client {
6
7
  private readonly config: TaruviConfig
@@ -30,6 +31,8 @@ export class Client {
30
31
 
31
32
  // Check URL hash for tokens (OAuth callback)
32
33
  this.extractTokensFromUrl()
34
+
35
+ console.info(`Taruvi SDK v${packageJson.version} initialized`)
33
36
  }
34
37
 
35
38
  /**
@@ -82,4 +85,4 @@ export class Client {
82
85
  getConfig(): Readonly<TaruviConfig> {
83
86
  return { ...this.config }
84
87
  }
85
- }
88
+ }
@@ -19,7 +19,7 @@ export class HttpClient {
19
19
  constructor(config: TaruviConfig, tokenClient: TokenClient) {
20
20
  this.config = config
21
21
  this.tokenClient = tokenClient
22
- this.axiosInstance = axios.create({ baseURL: config.apiUrl })
22
+ this.axiosInstance = axios.create({ baseURL: config.apiUrl, withCredentials: true })
23
23
  this.setupInterceptors()
24
24
  }
25
25
 
@@ -1,11 +1,18 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
2
2
  import { Client } from '../../../src/client.js'
3
+ import packageJson from '../../../package.json' with { type: 'json' }
3
4
 
4
5
  describe('Client', () => {
6
+ const consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => undefined)
7
+
5
8
  beforeEach(() => {
6
9
  vi.clearAllMocks()
7
10
  })
8
11
 
12
+ afterEach(() => {
13
+ consoleInfoSpy.mockClear()
14
+ })
15
+
9
16
  describe('constructor', () => {
10
17
  it('throws error when config is not provided', () => {
11
18
  expect(() => new Client(undefined as any)).toThrow('Config is required')
@@ -30,6 +37,16 @@ describe('Client', () => {
30
37
  expect(client).toBeInstanceOf(Client)
31
38
  })
32
39
 
40
+ it('logs the sdk version when initialized', () => {
41
+ new Client({
42
+ apiKey: 'test-key',
43
+ appSlug: 'test-app',
44
+ apiUrl: 'https://api.test.com'
45
+ })
46
+
47
+ expect(consoleInfoSpy).toHaveBeenCalledWith(`Taruvi SDK v${packageJson.version} initialized`)
48
+ })
49
+
33
50
  it('initializes httpClient and tokenClient', () => {
34
51
  const client = new Client({
35
52
  apiKey: 'test-key',
package/tsconfig.json CHANGED
@@ -34,6 +34,7 @@
34
34
  "jsx": "react-jsx",
35
35
  "verbatimModuleSyntax": true,
36
36
  "isolatedModules": true,
37
+ "resolveJsonModule": true,
37
38
  "noUncheckedSideEffectImports": true,
38
39
  "moduleDetection": "force",
39
40
  "skipLibCheck": true,