@disconnectme/lightbox-sdk 0.1.3 → 0.1.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/dist/index.cjs CHANGED
@@ -50,7 +50,7 @@ var LightboxClient = class {
50
50
  apiKey;
51
51
  constructor(config) {
52
52
  this.apiKey = config.apiKey;
53
- this.baseUrl = config.baseUrl ?? "https://api.datafin.ai";
53
+ this.baseUrl = config.baseUrl ?? "https://api.lightbox.dev";
54
54
  }
55
55
  async request(path, params) {
56
56
  const url = new URL(path, this.baseUrl);
@@ -93,6 +93,37 @@ var LightboxClient = class {
93
93
  */
94
94
  get: (hash, params) => {
95
95
  return this.request(`/v1/files/${hash}`, params);
96
+ },
97
+ /**
98
+ * Resolve a signed download URL for a file path.
99
+ * Returns the signed URL and its expiration timestamp.
100
+ */
101
+ download: async (params) => {
102
+ const url = new URL("/v1/files/download", this.baseUrl);
103
+ url.searchParams.set("bundle", params.bundle);
104
+ url.searchParams.set("version", params.version);
105
+ url.searchParams.set("file_path", params.file_path);
106
+ const response = await fetch(url.toString(), {
107
+ headers: {
108
+ Authorization: `Bearer ${this.apiKey}`
109
+ },
110
+ redirect: "manual"
111
+ });
112
+ if (response.status === 302) {
113
+ const location = response.headers.get("Location");
114
+ if (!location) {
115
+ throw new Error("Missing Location header on download redirect");
116
+ }
117
+ return {
118
+ download_url: location,
119
+ expires_at: response.headers.get("X-Download-Expires-At")
120
+ };
121
+ }
122
+ const data = await response.json();
123
+ if (!response.ok) {
124
+ throw LightboxError.fromAPIError(data);
125
+ }
126
+ throw new Error("Unexpected response from download endpoint");
96
127
  }
97
128
  };
98
129
  /**
package/dist/index.d.cts CHANGED
@@ -37,7 +37,6 @@ interface FileSearchResult {
37
37
  file_path: string | null;
38
38
  file_size_bytes: number;
39
39
  download_url: string | null;
40
- expires_at: string | null;
41
40
  }
42
41
  interface FileHashResult {
43
42
  bundle: string;
@@ -48,6 +47,9 @@ interface FileHashResult {
48
47
  file_path: string | null;
49
48
  file_size: number;
50
49
  download_url: string | null;
50
+ }
51
+ interface FileDownloadResult {
52
+ download_url: string;
51
53
  expires_at: string | null;
52
54
  }
53
55
  interface FileSearchData {
@@ -122,7 +124,6 @@ interface AppFile {
122
124
  file_path: string | null;
123
125
  file_size_bytes: number;
124
126
  download_url: string | null;
125
- expires_at: string | null;
126
127
  }
127
128
  interface AppSearchData {
128
129
  type: "app_collection";
@@ -201,6 +202,11 @@ interface FileSearchParams extends PaginationParams {
201
202
  min_size?: number;
202
203
  max_size?: number;
203
204
  }
205
+ interface FileDownloadParams {
206
+ bundle: string;
207
+ version: string;
208
+ file_path: string;
209
+ }
204
210
  interface AppSearchParams extends PaginationParams {
205
211
  framework?: string;
206
212
  entitlement?: string;
@@ -371,6 +377,11 @@ declare class LightboxClient {
371
377
  * Returns the apps containing this file and download URLs.
372
378
  */
373
379
  get: (hash: string, params?: PaginationParams) => Promise<FileHashResponse>;
380
+ /**
381
+ * Resolve a signed download URL for a file path.
382
+ * Returns the signed URL and its expiration timestamp.
383
+ */
384
+ download: (params: FileDownloadParams) => Promise<FileDownloadResult>;
374
385
  };
375
386
  /**
376
387
  * App-related API methods (iOS apps)
@@ -473,4 +484,4 @@ declare class LightboxClient {
473
484
  };
474
485
  }
475
486
 
476
- export { type APIError, type APIMetadata, type APIResponse, type AppFile, type AppFilesData, type AppFilesParams, type AppFilesResponse, type AppGetParams, type AppProfile, type AppProfileData, type AppProfileResponse, type AppSearchData, type AppSearchParams, type AppSearchResponse, type AppSummary, type AppVersion, type AppVersionsData, type AppVersionsResponse, type EntitlementItem, type EntitlementListData, type EntitlementListResponse, type FileHashData, type FileHashResponse, type FileHashResult, type FileSearchData, type FileSearchParams, type FileSearchResponse, type FileSearchResult, type FrameworkItem, type FrameworkListData, type FrameworkListResponse, type GenreItem, type GenreListData, type GenreListResponse, type JavaScriptCatalogParams, type JavaScriptCatalogResponse, type JavaScriptScriptsParams, type JavaScriptSitesParams, type JavaScriptSymbolCatalogData, type JavaScriptSymbolCatalogItem, type JavaScriptSymbolCategory, type JavaScriptSymbolCollectionData, type JavaScriptSymbolCollectionResponse, type JavaScriptSymbolObservation, type JavaScriptSymbolParams, LightboxClient, type LightboxClientConfig, LightboxError, type MetadataSearchParams, type Pagination, type PaginationParams, type ScopeMode, type WebCookie, type WebCookieCollectionData, type WebCookieCollectionResponse, type WebDomainCookiesParams, type WebDomainRequestsParams, type WebRequest, type WebRequestCollectionData, type WebRequestCollectionResponse, type WebSiteCookiesParams, type WebSiteRequestsParams };
487
+ export { type APIError, type APIMetadata, type APIResponse, type AppFile, type AppFilesData, type AppFilesParams, type AppFilesResponse, type AppGetParams, type AppProfile, type AppProfileData, type AppProfileResponse, type AppSearchData, type AppSearchParams, type AppSearchResponse, type AppSummary, type AppVersion, type AppVersionsData, type AppVersionsResponse, type EntitlementItem, type EntitlementListData, type EntitlementListResponse, type FileDownloadParams, type FileDownloadResult, type FileHashData, type FileHashResponse, type FileHashResult, type FileSearchData, type FileSearchParams, type FileSearchResponse, type FileSearchResult, type FrameworkItem, type FrameworkListData, type FrameworkListResponse, type GenreItem, type GenreListData, type GenreListResponse, type JavaScriptCatalogParams, type JavaScriptCatalogResponse, type JavaScriptScriptsParams, type JavaScriptSitesParams, type JavaScriptSymbolCatalogData, type JavaScriptSymbolCatalogItem, type JavaScriptSymbolCategory, type JavaScriptSymbolCollectionData, type JavaScriptSymbolCollectionResponse, type JavaScriptSymbolObservation, type JavaScriptSymbolParams, LightboxClient, type LightboxClientConfig, LightboxError, type MetadataSearchParams, type Pagination, type PaginationParams, type ScopeMode, type WebCookie, type WebCookieCollectionData, type WebCookieCollectionResponse, type WebDomainCookiesParams, type WebDomainRequestsParams, type WebRequest, type WebRequestCollectionData, type WebRequestCollectionResponse, type WebSiteCookiesParams, type WebSiteRequestsParams };
package/dist/index.d.ts CHANGED
@@ -37,7 +37,6 @@ interface FileSearchResult {
37
37
  file_path: string | null;
38
38
  file_size_bytes: number;
39
39
  download_url: string | null;
40
- expires_at: string | null;
41
40
  }
42
41
  interface FileHashResult {
43
42
  bundle: string;
@@ -48,6 +47,9 @@ interface FileHashResult {
48
47
  file_path: string | null;
49
48
  file_size: number;
50
49
  download_url: string | null;
50
+ }
51
+ interface FileDownloadResult {
52
+ download_url: string;
51
53
  expires_at: string | null;
52
54
  }
53
55
  interface FileSearchData {
@@ -122,7 +124,6 @@ interface AppFile {
122
124
  file_path: string | null;
123
125
  file_size_bytes: number;
124
126
  download_url: string | null;
125
- expires_at: string | null;
126
127
  }
127
128
  interface AppSearchData {
128
129
  type: "app_collection";
@@ -201,6 +202,11 @@ interface FileSearchParams extends PaginationParams {
201
202
  min_size?: number;
202
203
  max_size?: number;
203
204
  }
205
+ interface FileDownloadParams {
206
+ bundle: string;
207
+ version: string;
208
+ file_path: string;
209
+ }
204
210
  interface AppSearchParams extends PaginationParams {
205
211
  framework?: string;
206
212
  entitlement?: string;
@@ -371,6 +377,11 @@ declare class LightboxClient {
371
377
  * Returns the apps containing this file and download URLs.
372
378
  */
373
379
  get: (hash: string, params?: PaginationParams) => Promise<FileHashResponse>;
380
+ /**
381
+ * Resolve a signed download URL for a file path.
382
+ * Returns the signed URL and its expiration timestamp.
383
+ */
384
+ download: (params: FileDownloadParams) => Promise<FileDownloadResult>;
374
385
  };
375
386
  /**
376
387
  * App-related API methods (iOS apps)
@@ -473,4 +484,4 @@ declare class LightboxClient {
473
484
  };
474
485
  }
475
486
 
476
- export { type APIError, type APIMetadata, type APIResponse, type AppFile, type AppFilesData, type AppFilesParams, type AppFilesResponse, type AppGetParams, type AppProfile, type AppProfileData, type AppProfileResponse, type AppSearchData, type AppSearchParams, type AppSearchResponse, type AppSummary, type AppVersion, type AppVersionsData, type AppVersionsResponse, type EntitlementItem, type EntitlementListData, type EntitlementListResponse, type FileHashData, type FileHashResponse, type FileHashResult, type FileSearchData, type FileSearchParams, type FileSearchResponse, type FileSearchResult, type FrameworkItem, type FrameworkListData, type FrameworkListResponse, type GenreItem, type GenreListData, type GenreListResponse, type JavaScriptCatalogParams, type JavaScriptCatalogResponse, type JavaScriptScriptsParams, type JavaScriptSitesParams, type JavaScriptSymbolCatalogData, type JavaScriptSymbolCatalogItem, type JavaScriptSymbolCategory, type JavaScriptSymbolCollectionData, type JavaScriptSymbolCollectionResponse, type JavaScriptSymbolObservation, type JavaScriptSymbolParams, LightboxClient, type LightboxClientConfig, LightboxError, type MetadataSearchParams, type Pagination, type PaginationParams, type ScopeMode, type WebCookie, type WebCookieCollectionData, type WebCookieCollectionResponse, type WebDomainCookiesParams, type WebDomainRequestsParams, type WebRequest, type WebRequestCollectionData, type WebRequestCollectionResponse, type WebSiteCookiesParams, type WebSiteRequestsParams };
487
+ export { type APIError, type APIMetadata, type APIResponse, type AppFile, type AppFilesData, type AppFilesParams, type AppFilesResponse, type AppGetParams, type AppProfile, type AppProfileData, type AppProfileResponse, type AppSearchData, type AppSearchParams, type AppSearchResponse, type AppSummary, type AppVersion, type AppVersionsData, type AppVersionsResponse, type EntitlementItem, type EntitlementListData, type EntitlementListResponse, type FileDownloadParams, type FileDownloadResult, type FileHashData, type FileHashResponse, type FileHashResult, type FileSearchData, type FileSearchParams, type FileSearchResponse, type FileSearchResult, type FrameworkItem, type FrameworkListData, type FrameworkListResponse, type GenreItem, type GenreListData, type GenreListResponse, type JavaScriptCatalogParams, type JavaScriptCatalogResponse, type JavaScriptScriptsParams, type JavaScriptSitesParams, type JavaScriptSymbolCatalogData, type JavaScriptSymbolCatalogItem, type JavaScriptSymbolCategory, type JavaScriptSymbolCollectionData, type JavaScriptSymbolCollectionResponse, type JavaScriptSymbolObservation, type JavaScriptSymbolParams, LightboxClient, type LightboxClientConfig, LightboxError, type MetadataSearchParams, type Pagination, type PaginationParams, type ScopeMode, type WebCookie, type WebCookieCollectionData, type WebCookieCollectionResponse, type WebDomainCookiesParams, type WebDomainRequestsParams, type WebRequest, type WebRequestCollectionData, type WebRequestCollectionResponse, type WebSiteCookiesParams, type WebSiteRequestsParams };
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ var LightboxClient = class {
23
23
  apiKey;
24
24
  constructor(config) {
25
25
  this.apiKey = config.apiKey;
26
- this.baseUrl = config.baseUrl ?? "https://api.datafin.ai";
26
+ this.baseUrl = config.baseUrl ?? "https://api.lightbox.dev";
27
27
  }
28
28
  async request(path, params) {
29
29
  const url = new URL(path, this.baseUrl);
@@ -66,6 +66,37 @@ var LightboxClient = class {
66
66
  */
67
67
  get: (hash, params) => {
68
68
  return this.request(`/v1/files/${hash}`, params);
69
+ },
70
+ /**
71
+ * Resolve a signed download URL for a file path.
72
+ * Returns the signed URL and its expiration timestamp.
73
+ */
74
+ download: async (params) => {
75
+ const url = new URL("/v1/files/download", this.baseUrl);
76
+ url.searchParams.set("bundle", params.bundle);
77
+ url.searchParams.set("version", params.version);
78
+ url.searchParams.set("file_path", params.file_path);
79
+ const response = await fetch(url.toString(), {
80
+ headers: {
81
+ Authorization: `Bearer ${this.apiKey}`
82
+ },
83
+ redirect: "manual"
84
+ });
85
+ if (response.status === 302) {
86
+ const location = response.headers.get("Location");
87
+ if (!location) {
88
+ throw new Error("Missing Location header on download redirect");
89
+ }
90
+ return {
91
+ download_url: location,
92
+ expires_at: response.headers.get("X-Download-Expires-At")
93
+ };
94
+ }
95
+ const data = await response.json();
96
+ if (!response.ok) {
97
+ throw LightboxError.fromAPIError(data);
98
+ }
99
+ throw new Error("Unexpected response from download endpoint");
69
100
  }
70
101
  };
71
102
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disconnectme/lightbox-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "TypeScript SDK for the Lightbox Data API by Disconnect",
5
5
  "type": "module",
6
6
  "engines": {