@disconnectme/lightbox-sdk 0.1.0

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 ADDED
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ LightboxClient: () => LightboxClient,
24
+ LightboxError: () => LightboxError
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/client.ts
29
+ var LightboxError = class _LightboxError extends Error {
30
+ constructor(message, code, type, requestId, param) {
31
+ super(message);
32
+ this.code = code;
33
+ this.type = type;
34
+ this.requestId = requestId;
35
+ this.param = param;
36
+ this.name = "LightboxError";
37
+ }
38
+ static fromAPIError(error) {
39
+ return new _LightboxError(
40
+ error.error.message,
41
+ error.error.code,
42
+ error.error.type,
43
+ error.error.request_id,
44
+ error.error.param
45
+ );
46
+ }
47
+ };
48
+ var LightboxClient = class {
49
+ baseUrl;
50
+ apiKey;
51
+ constructor(config) {
52
+ this.apiKey = config.apiKey;
53
+ this.baseUrl = config.baseUrl ?? "https://api.datafin.ai";
54
+ }
55
+ async request(path, params) {
56
+ const url = new URL(path, this.baseUrl);
57
+ if (params) {
58
+ for (const [key, value] of Object.entries(params)) {
59
+ if (value === void 0 || value === null) continue;
60
+ if (Array.isArray(value)) {
61
+ url.searchParams.set(key, value.join(","));
62
+ } else {
63
+ url.searchParams.set(key, String(value));
64
+ }
65
+ }
66
+ }
67
+ const response = await fetch(url.toString(), {
68
+ headers: {
69
+ Authorization: `Bearer ${this.apiKey}`,
70
+ "Content-Type": "application/json"
71
+ }
72
+ });
73
+ const data = await response.json();
74
+ if (!response.ok) {
75
+ throw LightboxError.fromAPIError(data);
76
+ }
77
+ return data;
78
+ }
79
+ /**
80
+ * File-related API methods
81
+ */
82
+ files = {
83
+ /**
84
+ * Search for files across apps by extension, filename, bundle, etc.
85
+ * Requires at least one of `extensions` or `filenames`.
86
+ */
87
+ search: (params) => {
88
+ return this.request("/v1/files/search", params);
89
+ },
90
+ /**
91
+ * Get all occurrences of a file by its hash.
92
+ * Returns the apps containing this file and download URLs.
93
+ */
94
+ get: (hash, params) => {
95
+ return this.request(`/v1/files/${hash}`, params);
96
+ }
97
+ };
98
+ /**
99
+ * App-related API methods (iOS apps)
100
+ */
101
+ apps = {
102
+ /**
103
+ * Search for iOS apps by framework, permission, genre, developer, name, or bundle.
104
+ * Requires at least one filter parameter.
105
+ */
106
+ search: (params) => {
107
+ return this.request("/v1/apps/ios/search", params);
108
+ },
109
+ /**
110
+ * Get detailed profile for a specific app bundle.
111
+ * Use `version` param to get a specific version, defaults to latest.
112
+ * Use `include` to specify which fields to include (frameworks, permissions, privacy, urls, files, all).
113
+ */
114
+ get: (bundle, params) => {
115
+ const queryParams = {};
116
+ if (params?.version) queryParams.version = params.version;
117
+ if (params?.include) queryParams.include = params.include.join(",");
118
+ return this.request(
119
+ `/v1/apps/ios/${encodeURIComponent(bundle)}`,
120
+ queryParams
121
+ );
122
+ },
123
+ /**
124
+ * List all available versions for an app bundle.
125
+ */
126
+ versions: (bundle, params) => {
127
+ return this.request(
128
+ `/v1/apps/ios/${encodeURIComponent(bundle)}/versions`,
129
+ params
130
+ );
131
+ },
132
+ /**
133
+ * List files within an app, optionally filtered by extension, name, path, or size.
134
+ */
135
+ files: (bundle, params) => {
136
+ return this.request(
137
+ `/v1/apps/ios/${encodeURIComponent(bundle)}/files`,
138
+ params
139
+ );
140
+ },
141
+ /**
142
+ * Metadata endpoints for discovering available filter values
143
+ */
144
+ metadata: {
145
+ /**
146
+ * Get all available App Store genres with app counts.
147
+ * Returns a fixed set of 26 genres.
148
+ */
149
+ genres: () => {
150
+ return this.request("/v1/apps/ios/metadata/genres");
151
+ },
152
+ /**
153
+ * Get available frameworks with app counts.
154
+ * Supports pagination and search.
155
+ * @param params.search - Filter by framework name (case-insensitive contains)
156
+ * @param params.sort - Sort by 'popularity' (default) or 'name'
157
+ * @param params.limit - Results per page (default 100, max 1000)
158
+ * @param params.offset - Pagination offset
159
+ */
160
+ frameworks: (params) => {
161
+ return this.request("/v1/apps/ios/metadata/frameworks", params);
162
+ },
163
+ /**
164
+ * Get available permissions (iOS entitlements) with app counts.
165
+ * Supports pagination and search.
166
+ * @param params.search - Filter by permission key (case-insensitive contains)
167
+ * @param params.sort - Sort by 'popularity' (default) or 'name'
168
+ * @param params.limit - Results per page (default 100, max 1000)
169
+ * @param params.offset - Pagination offset
170
+ */
171
+ permissions: (params) => {
172
+ return this.request("/v1/apps/ios/metadata/permissions", params);
173
+ }
174
+ }
175
+ };
176
+ };
177
+ // Annotate the CommonJS export names for ESM import in node:
178
+ 0 && (module.exports = {
179
+ LightboxClient,
180
+ LightboxError
181
+ });
@@ -0,0 +1,307 @@
1
+ interface APIMetadata {
2
+ api_version: string;
3
+ query_time_ms: number;
4
+ data_sources: string[];
5
+ data_freshness: string | null;
6
+ credits_used: number;
7
+ request_id: string;
8
+ }
9
+ interface Pagination {
10
+ limit: number;
11
+ offset: number;
12
+ returned: number;
13
+ has_more: boolean;
14
+ next_offset?: number;
15
+ }
16
+ interface APIResponse<T> {
17
+ _metadata: APIMetadata;
18
+ query: Record<string, unknown>;
19
+ data: T;
20
+ pagination: Pagination | null;
21
+ }
22
+ interface APIError {
23
+ error: {
24
+ code: string;
25
+ message: string;
26
+ type: string;
27
+ param?: string;
28
+ request_id: string;
29
+ };
30
+ }
31
+ interface FileSearchResult {
32
+ bundle: string;
33
+ version: string;
34
+ file_name: string;
35
+ file_extension: string;
36
+ file_hash: string;
37
+ file_path: string | null;
38
+ file_size_bytes: number;
39
+ download_url: string | null;
40
+ expires_at: string | null;
41
+ }
42
+ interface FileHashResult {
43
+ bundle: string;
44
+ version: string;
45
+ type: string;
46
+ name: string;
47
+ created_at: string;
48
+ file_path: string | null;
49
+ file_size: number;
50
+ download_url: string | null;
51
+ expires_at: string | null;
52
+ }
53
+ interface FileSearchData {
54
+ type: "file_collection";
55
+ summary: {
56
+ returned: number;
57
+ };
58
+ files: FileSearchResult[];
59
+ }
60
+ interface FileHashData {
61
+ type: "file_occurrences";
62
+ file: {
63
+ file_hash: string;
64
+ total_occurrences: number;
65
+ app_count: number;
66
+ } | null;
67
+ apps: FileHashResult[];
68
+ }
69
+ interface AppSummary {
70
+ bundle: string;
71
+ version: string;
72
+ name: string;
73
+ type: string;
74
+ genre: string | null;
75
+ developer: string | null;
76
+ review_count: number | null;
77
+ rating: number | null;
78
+ app_store_url: string | null;
79
+ frameworks: string[];
80
+ permissions: string[];
81
+ created_at: string;
82
+ }
83
+ interface AppProfile {
84
+ bundle: string;
85
+ version: string;
86
+ name: string;
87
+ type: string;
88
+ genre: string | null;
89
+ developer: string | null;
90
+ review_count: number | null;
91
+ rating: number | null;
92
+ app_store_url: string | null;
93
+ created_at: string;
94
+ frameworks?: string[];
95
+ permissions?: string[];
96
+ privacy?: unknown[];
97
+ urls?: unknown[];
98
+ files?: unknown[];
99
+ }
100
+ interface AppVersion {
101
+ version: string;
102
+ created_at: string;
103
+ review_count: number | null;
104
+ rating: number | null;
105
+ genre: string | null;
106
+ developer: string | null;
107
+ }
108
+ interface AppFile {
109
+ bundle: string;
110
+ version: string;
111
+ file_name: string;
112
+ file_extension: string;
113
+ file_hash: string;
114
+ file_path: string | null;
115
+ file_size_bytes: number;
116
+ download_url: string | null;
117
+ expires_at: string | null;
118
+ }
119
+ interface AppSearchData {
120
+ type: "app_collection";
121
+ summary: {
122
+ total_matches: number;
123
+ returned: number;
124
+ };
125
+ apps: AppSummary[];
126
+ }
127
+ interface AppProfileData {
128
+ type: "app_profile";
129
+ app: AppProfile;
130
+ }
131
+ interface AppVersionsData {
132
+ type: "version_collection";
133
+ versions: AppVersion[];
134
+ }
135
+ interface AppFilesData {
136
+ type: "file_collection";
137
+ app: {
138
+ bundle: string;
139
+ version: string;
140
+ };
141
+ summary: {
142
+ returned: number;
143
+ };
144
+ files: AppFile[];
145
+ }
146
+ interface PaginationParams {
147
+ limit?: number;
148
+ offset?: number;
149
+ }
150
+ interface FileSearchParams extends PaginationParams {
151
+ extensions?: string[];
152
+ filenames?: string[];
153
+ bundles?: string[];
154
+ exclude_bundles?: string[];
155
+ exclude_hashes?: string[];
156
+ bundle_prefix?: string;
157
+ min_size?: number;
158
+ max_size?: number;
159
+ }
160
+ interface AppSearchParams extends PaginationParams {
161
+ framework?: string;
162
+ permission?: string;
163
+ genre?: string;
164
+ developer?: string;
165
+ name?: string;
166
+ bundle?: string;
167
+ }
168
+ interface AppGetParams {
169
+ version?: string;
170
+ include?: string[];
171
+ }
172
+ interface AppFilesParams extends PaginationParams {
173
+ version?: string;
174
+ extension?: string;
175
+ name?: string;
176
+ path?: string;
177
+ min_size?: number;
178
+ max_size?: number;
179
+ }
180
+ interface GenreItem {
181
+ name: string;
182
+ app_count: number;
183
+ }
184
+ interface FrameworkItem {
185
+ name: string;
186
+ app_count: number;
187
+ }
188
+ interface PermissionItem {
189
+ key: string;
190
+ app_count: number;
191
+ }
192
+ interface GenreListData {
193
+ type: "genre_list";
194
+ total: number;
195
+ genres: GenreItem[];
196
+ }
197
+ interface FrameworkListData {
198
+ type: "framework_list";
199
+ total: number;
200
+ frameworks: FrameworkItem[];
201
+ }
202
+ interface PermissionListData {
203
+ type: "permission_list";
204
+ total: number;
205
+ permissions: PermissionItem[];
206
+ }
207
+ interface MetadataSearchParams extends PaginationParams {
208
+ search?: string;
209
+ sort?: "popularity" | "name";
210
+ }
211
+ type FileSearchResponse = APIResponse<FileSearchData>;
212
+ type FileHashResponse = APIResponse<FileHashData>;
213
+ type AppSearchResponse = APIResponse<AppSearchData>;
214
+ type AppProfileResponse = APIResponse<AppProfileData>;
215
+ type AppVersionsResponse = APIResponse<AppVersionsData>;
216
+ type AppFilesResponse = APIResponse<AppFilesData>;
217
+ type GenreListResponse = APIResponse<GenreListData>;
218
+ type FrameworkListResponse = APIResponse<FrameworkListData>;
219
+ type PermissionListResponse = APIResponse<PermissionListData>;
220
+
221
+ interface LightboxClientConfig {
222
+ apiKey: string;
223
+ baseUrl?: string;
224
+ }
225
+ declare class LightboxError extends Error {
226
+ code: string;
227
+ type: string;
228
+ requestId: string;
229
+ param?: string | undefined;
230
+ constructor(message: string, code: string, type: string, requestId: string, param?: string | undefined);
231
+ static fromAPIError(error: APIError): LightboxError;
232
+ }
233
+ declare class LightboxClient {
234
+ private baseUrl;
235
+ private apiKey;
236
+ constructor(config: LightboxClientConfig);
237
+ private request;
238
+ /**
239
+ * File-related API methods
240
+ */
241
+ files: {
242
+ /**
243
+ * Search for files across apps by extension, filename, bundle, etc.
244
+ * Requires at least one of `extensions` or `filenames`.
245
+ */
246
+ search: (params: FileSearchParams) => Promise<FileSearchResponse>;
247
+ /**
248
+ * Get all occurrences of a file by its hash.
249
+ * Returns the apps containing this file and download URLs.
250
+ */
251
+ get: (hash: string, params?: PaginationParams) => Promise<FileHashResponse>;
252
+ };
253
+ /**
254
+ * App-related API methods (iOS apps)
255
+ */
256
+ apps: {
257
+ /**
258
+ * Search for iOS apps by framework, permission, genre, developer, name, or bundle.
259
+ * Requires at least one filter parameter.
260
+ */
261
+ search: (params: AppSearchParams) => Promise<AppSearchResponse>;
262
+ /**
263
+ * Get detailed profile for a specific app bundle.
264
+ * Use `version` param to get a specific version, defaults to latest.
265
+ * Use `include` to specify which fields to include (frameworks, permissions, privacy, urls, files, all).
266
+ */
267
+ get: (bundle: string, params?: AppGetParams) => Promise<AppProfileResponse>;
268
+ /**
269
+ * List all available versions for an app bundle.
270
+ */
271
+ versions: (bundle: string, params?: PaginationParams) => Promise<AppVersionsResponse>;
272
+ /**
273
+ * List files within an app, optionally filtered by extension, name, path, or size.
274
+ */
275
+ files: (bundle: string, params?: AppFilesParams) => Promise<AppFilesResponse>;
276
+ /**
277
+ * Metadata endpoints for discovering available filter values
278
+ */
279
+ metadata: {
280
+ /**
281
+ * Get all available App Store genres with app counts.
282
+ * Returns a fixed set of 26 genres.
283
+ */
284
+ genres: () => Promise<GenreListResponse>;
285
+ /**
286
+ * Get available frameworks with app counts.
287
+ * Supports pagination and search.
288
+ * @param params.search - Filter by framework name (case-insensitive contains)
289
+ * @param params.sort - Sort by 'popularity' (default) or 'name'
290
+ * @param params.limit - Results per page (default 100, max 1000)
291
+ * @param params.offset - Pagination offset
292
+ */
293
+ frameworks: (params?: MetadataSearchParams) => Promise<FrameworkListResponse>;
294
+ /**
295
+ * Get available permissions (iOS entitlements) with app counts.
296
+ * Supports pagination and search.
297
+ * @param params.search - Filter by permission key (case-insensitive contains)
298
+ * @param params.sort - Sort by 'popularity' (default) or 'name'
299
+ * @param params.limit - Results per page (default 100, max 1000)
300
+ * @param params.offset - Pagination offset
301
+ */
302
+ permissions: (params?: MetadataSearchParams) => Promise<PermissionListResponse>;
303
+ };
304
+ };
305
+ }
306
+
307
+ 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 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, LightboxClient, type LightboxClientConfig, LightboxError, type MetadataSearchParams, type Pagination, type PaginationParams, type PermissionItem, type PermissionListData, type PermissionListResponse };
@@ -0,0 +1,307 @@
1
+ interface APIMetadata {
2
+ api_version: string;
3
+ query_time_ms: number;
4
+ data_sources: string[];
5
+ data_freshness: string | null;
6
+ credits_used: number;
7
+ request_id: string;
8
+ }
9
+ interface Pagination {
10
+ limit: number;
11
+ offset: number;
12
+ returned: number;
13
+ has_more: boolean;
14
+ next_offset?: number;
15
+ }
16
+ interface APIResponse<T> {
17
+ _metadata: APIMetadata;
18
+ query: Record<string, unknown>;
19
+ data: T;
20
+ pagination: Pagination | null;
21
+ }
22
+ interface APIError {
23
+ error: {
24
+ code: string;
25
+ message: string;
26
+ type: string;
27
+ param?: string;
28
+ request_id: string;
29
+ };
30
+ }
31
+ interface FileSearchResult {
32
+ bundle: string;
33
+ version: string;
34
+ file_name: string;
35
+ file_extension: string;
36
+ file_hash: string;
37
+ file_path: string | null;
38
+ file_size_bytes: number;
39
+ download_url: string | null;
40
+ expires_at: string | null;
41
+ }
42
+ interface FileHashResult {
43
+ bundle: string;
44
+ version: string;
45
+ type: string;
46
+ name: string;
47
+ created_at: string;
48
+ file_path: string | null;
49
+ file_size: number;
50
+ download_url: string | null;
51
+ expires_at: string | null;
52
+ }
53
+ interface FileSearchData {
54
+ type: "file_collection";
55
+ summary: {
56
+ returned: number;
57
+ };
58
+ files: FileSearchResult[];
59
+ }
60
+ interface FileHashData {
61
+ type: "file_occurrences";
62
+ file: {
63
+ file_hash: string;
64
+ total_occurrences: number;
65
+ app_count: number;
66
+ } | null;
67
+ apps: FileHashResult[];
68
+ }
69
+ interface AppSummary {
70
+ bundle: string;
71
+ version: string;
72
+ name: string;
73
+ type: string;
74
+ genre: string | null;
75
+ developer: string | null;
76
+ review_count: number | null;
77
+ rating: number | null;
78
+ app_store_url: string | null;
79
+ frameworks: string[];
80
+ permissions: string[];
81
+ created_at: string;
82
+ }
83
+ interface AppProfile {
84
+ bundle: string;
85
+ version: string;
86
+ name: string;
87
+ type: string;
88
+ genre: string | null;
89
+ developer: string | null;
90
+ review_count: number | null;
91
+ rating: number | null;
92
+ app_store_url: string | null;
93
+ created_at: string;
94
+ frameworks?: string[];
95
+ permissions?: string[];
96
+ privacy?: unknown[];
97
+ urls?: unknown[];
98
+ files?: unknown[];
99
+ }
100
+ interface AppVersion {
101
+ version: string;
102
+ created_at: string;
103
+ review_count: number | null;
104
+ rating: number | null;
105
+ genre: string | null;
106
+ developer: string | null;
107
+ }
108
+ interface AppFile {
109
+ bundle: string;
110
+ version: string;
111
+ file_name: string;
112
+ file_extension: string;
113
+ file_hash: string;
114
+ file_path: string | null;
115
+ file_size_bytes: number;
116
+ download_url: string | null;
117
+ expires_at: string | null;
118
+ }
119
+ interface AppSearchData {
120
+ type: "app_collection";
121
+ summary: {
122
+ total_matches: number;
123
+ returned: number;
124
+ };
125
+ apps: AppSummary[];
126
+ }
127
+ interface AppProfileData {
128
+ type: "app_profile";
129
+ app: AppProfile;
130
+ }
131
+ interface AppVersionsData {
132
+ type: "version_collection";
133
+ versions: AppVersion[];
134
+ }
135
+ interface AppFilesData {
136
+ type: "file_collection";
137
+ app: {
138
+ bundle: string;
139
+ version: string;
140
+ };
141
+ summary: {
142
+ returned: number;
143
+ };
144
+ files: AppFile[];
145
+ }
146
+ interface PaginationParams {
147
+ limit?: number;
148
+ offset?: number;
149
+ }
150
+ interface FileSearchParams extends PaginationParams {
151
+ extensions?: string[];
152
+ filenames?: string[];
153
+ bundles?: string[];
154
+ exclude_bundles?: string[];
155
+ exclude_hashes?: string[];
156
+ bundle_prefix?: string;
157
+ min_size?: number;
158
+ max_size?: number;
159
+ }
160
+ interface AppSearchParams extends PaginationParams {
161
+ framework?: string;
162
+ permission?: string;
163
+ genre?: string;
164
+ developer?: string;
165
+ name?: string;
166
+ bundle?: string;
167
+ }
168
+ interface AppGetParams {
169
+ version?: string;
170
+ include?: string[];
171
+ }
172
+ interface AppFilesParams extends PaginationParams {
173
+ version?: string;
174
+ extension?: string;
175
+ name?: string;
176
+ path?: string;
177
+ min_size?: number;
178
+ max_size?: number;
179
+ }
180
+ interface GenreItem {
181
+ name: string;
182
+ app_count: number;
183
+ }
184
+ interface FrameworkItem {
185
+ name: string;
186
+ app_count: number;
187
+ }
188
+ interface PermissionItem {
189
+ key: string;
190
+ app_count: number;
191
+ }
192
+ interface GenreListData {
193
+ type: "genre_list";
194
+ total: number;
195
+ genres: GenreItem[];
196
+ }
197
+ interface FrameworkListData {
198
+ type: "framework_list";
199
+ total: number;
200
+ frameworks: FrameworkItem[];
201
+ }
202
+ interface PermissionListData {
203
+ type: "permission_list";
204
+ total: number;
205
+ permissions: PermissionItem[];
206
+ }
207
+ interface MetadataSearchParams extends PaginationParams {
208
+ search?: string;
209
+ sort?: "popularity" | "name";
210
+ }
211
+ type FileSearchResponse = APIResponse<FileSearchData>;
212
+ type FileHashResponse = APIResponse<FileHashData>;
213
+ type AppSearchResponse = APIResponse<AppSearchData>;
214
+ type AppProfileResponse = APIResponse<AppProfileData>;
215
+ type AppVersionsResponse = APIResponse<AppVersionsData>;
216
+ type AppFilesResponse = APIResponse<AppFilesData>;
217
+ type GenreListResponse = APIResponse<GenreListData>;
218
+ type FrameworkListResponse = APIResponse<FrameworkListData>;
219
+ type PermissionListResponse = APIResponse<PermissionListData>;
220
+
221
+ interface LightboxClientConfig {
222
+ apiKey: string;
223
+ baseUrl?: string;
224
+ }
225
+ declare class LightboxError extends Error {
226
+ code: string;
227
+ type: string;
228
+ requestId: string;
229
+ param?: string | undefined;
230
+ constructor(message: string, code: string, type: string, requestId: string, param?: string | undefined);
231
+ static fromAPIError(error: APIError): LightboxError;
232
+ }
233
+ declare class LightboxClient {
234
+ private baseUrl;
235
+ private apiKey;
236
+ constructor(config: LightboxClientConfig);
237
+ private request;
238
+ /**
239
+ * File-related API methods
240
+ */
241
+ files: {
242
+ /**
243
+ * Search for files across apps by extension, filename, bundle, etc.
244
+ * Requires at least one of `extensions` or `filenames`.
245
+ */
246
+ search: (params: FileSearchParams) => Promise<FileSearchResponse>;
247
+ /**
248
+ * Get all occurrences of a file by its hash.
249
+ * Returns the apps containing this file and download URLs.
250
+ */
251
+ get: (hash: string, params?: PaginationParams) => Promise<FileHashResponse>;
252
+ };
253
+ /**
254
+ * App-related API methods (iOS apps)
255
+ */
256
+ apps: {
257
+ /**
258
+ * Search for iOS apps by framework, permission, genre, developer, name, or bundle.
259
+ * Requires at least one filter parameter.
260
+ */
261
+ search: (params: AppSearchParams) => Promise<AppSearchResponse>;
262
+ /**
263
+ * Get detailed profile for a specific app bundle.
264
+ * Use `version` param to get a specific version, defaults to latest.
265
+ * Use `include` to specify which fields to include (frameworks, permissions, privacy, urls, files, all).
266
+ */
267
+ get: (bundle: string, params?: AppGetParams) => Promise<AppProfileResponse>;
268
+ /**
269
+ * List all available versions for an app bundle.
270
+ */
271
+ versions: (bundle: string, params?: PaginationParams) => Promise<AppVersionsResponse>;
272
+ /**
273
+ * List files within an app, optionally filtered by extension, name, path, or size.
274
+ */
275
+ files: (bundle: string, params?: AppFilesParams) => Promise<AppFilesResponse>;
276
+ /**
277
+ * Metadata endpoints for discovering available filter values
278
+ */
279
+ metadata: {
280
+ /**
281
+ * Get all available App Store genres with app counts.
282
+ * Returns a fixed set of 26 genres.
283
+ */
284
+ genres: () => Promise<GenreListResponse>;
285
+ /**
286
+ * Get available frameworks with app counts.
287
+ * Supports pagination and search.
288
+ * @param params.search - Filter by framework name (case-insensitive contains)
289
+ * @param params.sort - Sort by 'popularity' (default) or 'name'
290
+ * @param params.limit - Results per page (default 100, max 1000)
291
+ * @param params.offset - Pagination offset
292
+ */
293
+ frameworks: (params?: MetadataSearchParams) => Promise<FrameworkListResponse>;
294
+ /**
295
+ * Get available permissions (iOS entitlements) with app counts.
296
+ * Supports pagination and search.
297
+ * @param params.search - Filter by permission key (case-insensitive contains)
298
+ * @param params.sort - Sort by 'popularity' (default) or 'name'
299
+ * @param params.limit - Results per page (default 100, max 1000)
300
+ * @param params.offset - Pagination offset
301
+ */
302
+ permissions: (params?: MetadataSearchParams) => Promise<PermissionListResponse>;
303
+ };
304
+ };
305
+ }
306
+
307
+ 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 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, LightboxClient, type LightboxClientConfig, LightboxError, type MetadataSearchParams, type Pagination, type PaginationParams, type PermissionItem, type PermissionListData, type PermissionListResponse };
package/dist/index.js ADDED
@@ -0,0 +1,153 @@
1
+ // src/client.ts
2
+ var LightboxError = class _LightboxError extends Error {
3
+ constructor(message, code, type, requestId, param) {
4
+ super(message);
5
+ this.code = code;
6
+ this.type = type;
7
+ this.requestId = requestId;
8
+ this.param = param;
9
+ this.name = "LightboxError";
10
+ }
11
+ static fromAPIError(error) {
12
+ return new _LightboxError(
13
+ error.error.message,
14
+ error.error.code,
15
+ error.error.type,
16
+ error.error.request_id,
17
+ error.error.param
18
+ );
19
+ }
20
+ };
21
+ var LightboxClient = class {
22
+ baseUrl;
23
+ apiKey;
24
+ constructor(config) {
25
+ this.apiKey = config.apiKey;
26
+ this.baseUrl = config.baseUrl ?? "https://api.datafin.ai";
27
+ }
28
+ async request(path, params) {
29
+ const url = new URL(path, this.baseUrl);
30
+ if (params) {
31
+ for (const [key, value] of Object.entries(params)) {
32
+ if (value === void 0 || value === null) continue;
33
+ if (Array.isArray(value)) {
34
+ url.searchParams.set(key, value.join(","));
35
+ } else {
36
+ url.searchParams.set(key, String(value));
37
+ }
38
+ }
39
+ }
40
+ const response = await fetch(url.toString(), {
41
+ headers: {
42
+ Authorization: `Bearer ${this.apiKey}`,
43
+ "Content-Type": "application/json"
44
+ }
45
+ });
46
+ const data = await response.json();
47
+ if (!response.ok) {
48
+ throw LightboxError.fromAPIError(data);
49
+ }
50
+ return data;
51
+ }
52
+ /**
53
+ * File-related API methods
54
+ */
55
+ files = {
56
+ /**
57
+ * Search for files across apps by extension, filename, bundle, etc.
58
+ * Requires at least one of `extensions` or `filenames`.
59
+ */
60
+ search: (params) => {
61
+ return this.request("/v1/files/search", params);
62
+ },
63
+ /**
64
+ * Get all occurrences of a file by its hash.
65
+ * Returns the apps containing this file and download URLs.
66
+ */
67
+ get: (hash, params) => {
68
+ return this.request(`/v1/files/${hash}`, params);
69
+ }
70
+ };
71
+ /**
72
+ * App-related API methods (iOS apps)
73
+ */
74
+ apps = {
75
+ /**
76
+ * Search for iOS apps by framework, permission, genre, developer, name, or bundle.
77
+ * Requires at least one filter parameter.
78
+ */
79
+ search: (params) => {
80
+ return this.request("/v1/apps/ios/search", params);
81
+ },
82
+ /**
83
+ * Get detailed profile for a specific app bundle.
84
+ * Use `version` param to get a specific version, defaults to latest.
85
+ * Use `include` to specify which fields to include (frameworks, permissions, privacy, urls, files, all).
86
+ */
87
+ get: (bundle, params) => {
88
+ const queryParams = {};
89
+ if (params?.version) queryParams.version = params.version;
90
+ if (params?.include) queryParams.include = params.include.join(",");
91
+ return this.request(
92
+ `/v1/apps/ios/${encodeURIComponent(bundle)}`,
93
+ queryParams
94
+ );
95
+ },
96
+ /**
97
+ * List all available versions for an app bundle.
98
+ */
99
+ versions: (bundle, params) => {
100
+ return this.request(
101
+ `/v1/apps/ios/${encodeURIComponent(bundle)}/versions`,
102
+ params
103
+ );
104
+ },
105
+ /**
106
+ * List files within an app, optionally filtered by extension, name, path, or size.
107
+ */
108
+ files: (bundle, params) => {
109
+ return this.request(
110
+ `/v1/apps/ios/${encodeURIComponent(bundle)}/files`,
111
+ params
112
+ );
113
+ },
114
+ /**
115
+ * Metadata endpoints for discovering available filter values
116
+ */
117
+ metadata: {
118
+ /**
119
+ * Get all available App Store genres with app counts.
120
+ * Returns a fixed set of 26 genres.
121
+ */
122
+ genres: () => {
123
+ return this.request("/v1/apps/ios/metadata/genres");
124
+ },
125
+ /**
126
+ * Get available frameworks with app counts.
127
+ * Supports pagination and search.
128
+ * @param params.search - Filter by framework name (case-insensitive contains)
129
+ * @param params.sort - Sort by 'popularity' (default) or 'name'
130
+ * @param params.limit - Results per page (default 100, max 1000)
131
+ * @param params.offset - Pagination offset
132
+ */
133
+ frameworks: (params) => {
134
+ return this.request("/v1/apps/ios/metadata/frameworks", params);
135
+ },
136
+ /**
137
+ * Get available permissions (iOS entitlements) with app counts.
138
+ * Supports pagination and search.
139
+ * @param params.search - Filter by permission key (case-insensitive contains)
140
+ * @param params.sort - Sort by 'popularity' (default) or 'name'
141
+ * @param params.limit - Results per page (default 100, max 1000)
142
+ * @param params.offset - Pagination offset
143
+ */
144
+ permissions: (params) => {
145
+ return this.request("/v1/apps/ios/metadata/permissions", params);
146
+ }
147
+ }
148
+ };
149
+ };
150
+ export {
151
+ LightboxClient,
152
+ LightboxError
153
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@disconnectme/lightbox-sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the Lightbox Data API by Disconnect",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=18.0.0"
8
+ },
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.cts",
20
+ "default": "./dist/index.cjs"
21
+ }
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsup",
29
+ "dev": "tsup --watch",
30
+ "prepublishOnly": "npm run build"
31
+ },
32
+ "devDependencies": {
33
+ "tsup": "^8.3.5",
34
+ "typescript": "^5.7.2"
35
+ },
36
+ "keywords": [
37
+ "lightbox",
38
+ "api",
39
+ "sdk",
40
+ "ios",
41
+ "apps"
42
+ ],
43
+ "license": "MIT"
44
+ }