v0-sdk 0.5.2 → 0.5.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.
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  function createFetcher(config = {}) {
4
4
  const baseUrl = config.baseUrl || 'https://api.v0.dev/v1';
5
+ let sessionToken = null;
5
6
  return async function fetcher(url, method, params = {}) {
6
7
  const apiKey = config.apiKey || process.env.V0_API_KEY;
7
8
  if (!apiKey) {
@@ -12,9 +13,12 @@ function createFetcher(config = {}) {
12
13
  const hasBody = method !== 'GET' && params.body;
13
14
  const headers = {
14
15
  Authorization: `Bearer ${apiKey}`,
15
- 'x-session-cache': '1',
16
16
  ...params.headers
17
17
  };
18
+ // Include session token in headers if available
19
+ if (sessionToken) {
20
+ headers['x-session-token'] = sessionToken;
21
+ }
18
22
  if (hasBody) {
19
23
  headers['Content-Type'] = 'application/json';
20
24
  }
@@ -23,6 +27,11 @@ function createFetcher(config = {}) {
23
27
  headers,
24
28
  body: hasBody ? JSON.stringify(params.body) : undefined
25
29
  });
30
+ // Check for session token in response headers
31
+ const newSessionToken = res.headers.get('x-session-token');
32
+ if (newSessionToken) {
33
+ sessionToken = newSessionToken;
34
+ }
26
35
  if (!res.ok) {
27
36
  const text = await res.text();
28
37
  throw new Error(`HTTP ${res.status}: ${text}`);
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  function createFetcher(config = {}) {
2
2
  const baseUrl = config.baseUrl || 'https://api.v0.dev/v1';
3
+ let sessionToken = null;
3
4
  return async function fetcher(url, method, params = {}) {
4
5
  const apiKey = config.apiKey || process.env.V0_API_KEY;
5
6
  if (!apiKey) {
@@ -10,9 +11,12 @@ function createFetcher(config = {}) {
10
11
  const hasBody = method !== 'GET' && params.body;
11
12
  const headers = {
12
13
  Authorization: `Bearer ${apiKey}`,
13
- 'x-session-cache': '1',
14
14
  ...params.headers
15
15
  };
16
+ // Include session token in headers if available
17
+ if (sessionToken) {
18
+ headers['x-session-token'] = sessionToken;
19
+ }
16
20
  if (hasBody) {
17
21
  headers['Content-Type'] = 'application/json';
18
22
  }
@@ -21,6 +25,11 @@ function createFetcher(config = {}) {
21
25
  headers,
22
26
  body: hasBody ? JSON.stringify(params.body) : undefined
23
27
  });
28
+ // Check for session token in response headers
29
+ const newSessionToken = res.headers.get('x-session-token');
30
+ if (newSessionToken) {
31
+ sessionToken = newSessionToken;
32
+ }
24
33
  if (!res.ok) {
25
34
  const text = await res.text();
26
35
  throw new Error(`HTTP ${res.status}: ${text}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v0-sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "TypeScript SDK for the v0 Platform API",
5
5
  "homepage": "https://v0.dev/docs/api",
6
6
  "repository": {