@zhuixin/shared 0.0.0-stage → 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/LICENSE +202 -0
- package/dist/index.cjs +161 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +412 -0
- package/dist/index.d.ts +412 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type TargetPlatform = "ios" | "windows" | "macos" | "android" | "linux";
|
|
4
|
+
type HostPlatform = "darwin" | "win32" | "linux";
|
|
5
|
+
type SourceId = "app-store" | "local-file" | "direct-url" | "microsoft-store" | "winget";
|
|
6
|
+
type PackageFormat = "ipa" | "msix" | "appx" | "exe" | "msi" | "zip" | "dmg" | "apk";
|
|
7
|
+
interface TargetRef {
|
|
8
|
+
platform: TargetPlatform;
|
|
9
|
+
sourceId: SourceId;
|
|
10
|
+
sourceRef: string;
|
|
11
|
+
}
|
|
12
|
+
interface ResolvedTarget {
|
|
13
|
+
targetRef: TargetRef;
|
|
14
|
+
name: string;
|
|
15
|
+
publisher?: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
bundleId?: string;
|
|
18
|
+
packageId?: string;
|
|
19
|
+
iconUrl?: string;
|
|
20
|
+
storeUrl?: string;
|
|
21
|
+
metadata: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
interface TargetRecord extends ResolvedTarget {
|
|
24
|
+
id: string;
|
|
25
|
+
slug: string;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
}
|
|
29
|
+
interface ArtifactRecord {
|
|
30
|
+
id: string;
|
|
31
|
+
targetId: string;
|
|
32
|
+
platform: TargetPlatform;
|
|
33
|
+
packageFormat: PackageFormat;
|
|
34
|
+
architecture?: string;
|
|
35
|
+
sha256: string;
|
|
36
|
+
path: string;
|
|
37
|
+
sizeBytes: number;
|
|
38
|
+
version?: string;
|
|
39
|
+
buildNumber?: string;
|
|
40
|
+
signature?: Record<string, unknown>;
|
|
41
|
+
inspection?: Record<string, unknown>;
|
|
42
|
+
sourceUrl?: string;
|
|
43
|
+
downloadedAt: string;
|
|
44
|
+
isCurrent: boolean;
|
|
45
|
+
}
|
|
46
|
+
type FindingType = "technology" | "route" | "network_endpoint" | "module" | "asset" | "storage" | "native_procedure" | "native_string" | "risk" | "limitation";
|
|
47
|
+
type FindingConfidence = "exact" | "high" | "medium" | "low" | "unknown";
|
|
48
|
+
interface FindingRecord {
|
|
49
|
+
id: string;
|
|
50
|
+
targetId: string;
|
|
51
|
+
artifactId?: string;
|
|
52
|
+
jobId: string;
|
|
53
|
+
evidenceId: string;
|
|
54
|
+
type: FindingType;
|
|
55
|
+
value: string;
|
|
56
|
+
group?: string;
|
|
57
|
+
sourcePath?: string;
|
|
58
|
+
start?: {
|
|
59
|
+
line: number;
|
|
60
|
+
column: number;
|
|
61
|
+
};
|
|
62
|
+
end?: {
|
|
63
|
+
line: number;
|
|
64
|
+
column: number;
|
|
65
|
+
};
|
|
66
|
+
confidence: FindingConfidence;
|
|
67
|
+
metadata: Record<string, unknown>;
|
|
68
|
+
createdAt: string;
|
|
69
|
+
}
|
|
70
|
+
interface EvidenceRecord {
|
|
71
|
+
id: string;
|
|
72
|
+
targetId: string;
|
|
73
|
+
artifactId?: string;
|
|
74
|
+
jobId: string;
|
|
75
|
+
kind: string;
|
|
76
|
+
format: "json" | "markdown" | "text";
|
|
77
|
+
path: string;
|
|
78
|
+
sha256: string;
|
|
79
|
+
summary: Record<string, unknown>;
|
|
80
|
+
parentEvidenceId?: string;
|
|
81
|
+
createdAt: string;
|
|
82
|
+
}
|
|
83
|
+
interface FindingSearchResult {
|
|
84
|
+
items: FindingRecord[];
|
|
85
|
+
total: number;
|
|
86
|
+
limit: number;
|
|
87
|
+
offset: number;
|
|
88
|
+
}
|
|
89
|
+
interface AnalysisRunRecord {
|
|
90
|
+
id: string;
|
|
91
|
+
targetId?: string;
|
|
92
|
+
status: "running" | "completed" | "failed" | "interrupted";
|
|
93
|
+
startedAt: string;
|
|
94
|
+
finishedAt?: string;
|
|
95
|
+
result?: Record<string, unknown>;
|
|
96
|
+
error?: {
|
|
97
|
+
code: string;
|
|
98
|
+
message: string;
|
|
99
|
+
details?: unknown;
|
|
100
|
+
};
|
|
101
|
+
updatedAt: string;
|
|
102
|
+
}
|
|
103
|
+
type JobStatus = "queued" | "resolving" | "awaiting_auth" | "awaiting_license" | "acquiring" | "inspecting" | "registering" | "ready" | "analyzing" | "analyzed" | "failed" | "cancelled" | "interrupted";
|
|
104
|
+
interface JobRecord {
|
|
105
|
+
id: string;
|
|
106
|
+
targetId?: string;
|
|
107
|
+
sourceId?: SourceId;
|
|
108
|
+
capabilityId: string;
|
|
109
|
+
status: JobStatus;
|
|
110
|
+
progress: number;
|
|
111
|
+
params: Record<string, unknown>;
|
|
112
|
+
result?: Record<string, unknown>;
|
|
113
|
+
errorCode?: string;
|
|
114
|
+
errorMessage?: string;
|
|
115
|
+
createdAt: string;
|
|
116
|
+
startedAt?: string;
|
|
117
|
+
finishedAt?: string;
|
|
118
|
+
}
|
|
119
|
+
interface JobEvent {
|
|
120
|
+
jobId: string;
|
|
121
|
+
level: "info" | "warn" | "error";
|
|
122
|
+
message: string;
|
|
123
|
+
payload?: Record<string, unknown>;
|
|
124
|
+
createdAt: string;
|
|
125
|
+
}
|
|
126
|
+
interface SourceDescriptor {
|
|
127
|
+
id: SourceId;
|
|
128
|
+
platform: TargetPlatform;
|
|
129
|
+
displayName: string;
|
|
130
|
+
requiresAuth: boolean;
|
|
131
|
+
status: "ready" | "preview" | "evaluate";
|
|
132
|
+
description: string;
|
|
133
|
+
}
|
|
134
|
+
interface CapabilityDescriptor {
|
|
135
|
+
id: string;
|
|
136
|
+
label: string;
|
|
137
|
+
description: string;
|
|
138
|
+
targetPlatforms: TargetPlatform[];
|
|
139
|
+
packageFormats?: PackageFormat[];
|
|
140
|
+
hostPlatforms?: HostPlatform[];
|
|
141
|
+
available: boolean;
|
|
142
|
+
reason?: string;
|
|
143
|
+
requiresArtifact?: boolean;
|
|
144
|
+
requiresInput?: "function" | "query";
|
|
145
|
+
}
|
|
146
|
+
interface ResolveResult {
|
|
147
|
+
resolutionId: string;
|
|
148
|
+
target: ResolvedTarget;
|
|
149
|
+
provider: SourceDescriptor;
|
|
150
|
+
}
|
|
151
|
+
interface TargetDetail {
|
|
152
|
+
target: TargetRecord;
|
|
153
|
+
artifacts: ArtifactRecord[];
|
|
154
|
+
jobs: JobRecord[];
|
|
155
|
+
}
|
|
156
|
+
interface CoreError {
|
|
157
|
+
code: string;
|
|
158
|
+
message: string;
|
|
159
|
+
details?: unknown;
|
|
160
|
+
}
|
|
161
|
+
interface HealthInfo {
|
|
162
|
+
version: string;
|
|
163
|
+
workspaceRoot: string;
|
|
164
|
+
hostPlatform: HostPlatform;
|
|
165
|
+
store: "sqlite" | "json";
|
|
166
|
+
tools?: ToolInfo[];
|
|
167
|
+
}
|
|
168
|
+
interface ToolInfo {
|
|
169
|
+
id: string;
|
|
170
|
+
label: string;
|
|
171
|
+
path: string;
|
|
172
|
+
available: boolean;
|
|
173
|
+
}
|
|
174
|
+
interface AccountStatus {
|
|
175
|
+
authenticated: boolean;
|
|
176
|
+
email?: string;
|
|
177
|
+
name?: string;
|
|
178
|
+
keychain: "unlocked" | "locked" | "unknown";
|
|
179
|
+
checkedAt: string;
|
|
180
|
+
message?: string;
|
|
181
|
+
}
|
|
182
|
+
interface EntitlementRecord {
|
|
183
|
+
appId?: string | number;
|
|
184
|
+
bundleId?: string;
|
|
185
|
+
name: string;
|
|
186
|
+
version?: string;
|
|
187
|
+
platform?: string;
|
|
188
|
+
}
|
|
189
|
+
interface AccountEntitlements {
|
|
190
|
+
items: EntitlementRecord[];
|
|
191
|
+
checkedAt: string;
|
|
192
|
+
truncated: boolean;
|
|
193
|
+
error?: string;
|
|
194
|
+
}
|
|
195
|
+
interface EntitlementCheck {
|
|
196
|
+
status: "owned" | "not_owned" | "unknown";
|
|
197
|
+
checkedAt: string;
|
|
198
|
+
message?: string;
|
|
199
|
+
entitlement?: EntitlementRecord;
|
|
200
|
+
}
|
|
201
|
+
interface CoreRequest<T = unknown> {
|
|
202
|
+
id: string;
|
|
203
|
+
channel: string;
|
|
204
|
+
payload: T;
|
|
205
|
+
}
|
|
206
|
+
type CoreResponse<T = unknown> = {
|
|
207
|
+
id: string;
|
|
208
|
+
ok: true;
|
|
209
|
+
data: T;
|
|
210
|
+
} | {
|
|
211
|
+
id: string;
|
|
212
|
+
ok: false;
|
|
213
|
+
error: CoreError;
|
|
214
|
+
};
|
|
215
|
+
type CoreEvent = {
|
|
216
|
+
type: "job.updated";
|
|
217
|
+
payload: JobRecord;
|
|
218
|
+
} | {
|
|
219
|
+
type: "job.log";
|
|
220
|
+
payload: JobEvent;
|
|
221
|
+
} | {
|
|
222
|
+
type: "target.updated";
|
|
223
|
+
payload: TargetRecord;
|
|
224
|
+
} | {
|
|
225
|
+
type: "terminal.data";
|
|
226
|
+
payload: {
|
|
227
|
+
sessionId: string;
|
|
228
|
+
data: string;
|
|
229
|
+
};
|
|
230
|
+
} | {
|
|
231
|
+
type: "terminal.exit";
|
|
232
|
+
payload: {
|
|
233
|
+
sessionId: string;
|
|
234
|
+
code: number | null;
|
|
235
|
+
signal?: string | null;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
declare const CHANNELS: {
|
|
239
|
+
readonly health: "health";
|
|
240
|
+
readonly sourcesList: "sources:list";
|
|
241
|
+
readonly targetsResolve: "targets:resolve";
|
|
242
|
+
readonly targetsCreate: "targets:create";
|
|
243
|
+
readonly targetsList: "targets:list";
|
|
244
|
+
readonly targetsGet: "targets:get";
|
|
245
|
+
readonly jobsCreate: "jobs:create";
|
|
246
|
+
readonly jobsGet: "jobs:get";
|
|
247
|
+
readonly jobsCancel: "jobs:cancel";
|
|
248
|
+
readonly capabilitiesList: "capabilities:list";
|
|
249
|
+
readonly findingsSearch: "findings:search";
|
|
250
|
+
readonly evidenceList: "evidence:list";
|
|
251
|
+
readonly terminalStart: "terminal:start";
|
|
252
|
+
readonly terminalInput: "terminal:input";
|
|
253
|
+
readonly terminalStop: "terminal:stop";
|
|
254
|
+
readonly accountStatus: "account:status";
|
|
255
|
+
readonly accountEntitlements: "account:entitlements";
|
|
256
|
+
readonly accountCheckEntitlement: "account:check-entitlement";
|
|
257
|
+
};
|
|
258
|
+
declare const resolveInputSchema: z.ZodObject<{
|
|
259
|
+
input: z.ZodString;
|
|
260
|
+
}, "strip", z.ZodTypeAny, {
|
|
261
|
+
input: string;
|
|
262
|
+
}, {
|
|
263
|
+
input: string;
|
|
264
|
+
}>;
|
|
265
|
+
declare const createTargetSchema: z.ZodObject<{
|
|
266
|
+
resolutionId: z.ZodString;
|
|
267
|
+
}, "strip", z.ZodTypeAny, {
|
|
268
|
+
resolutionId: string;
|
|
269
|
+
}, {
|
|
270
|
+
resolutionId: string;
|
|
271
|
+
}>;
|
|
272
|
+
declare const createJobSchema: z.ZodObject<{
|
|
273
|
+
targetId: z.ZodString;
|
|
274
|
+
capabilityId: z.ZodString;
|
|
275
|
+
artifactId: z.ZodOptional<z.ZodString>;
|
|
276
|
+
input: z.ZodOptional<z.ZodObject<{
|
|
277
|
+
functionName: z.ZodOptional<z.ZodString>;
|
|
278
|
+
query: z.ZodOptional<z.ZodString>;
|
|
279
|
+
kind: z.ZodOptional<z.ZodEnum<["procedures", "strings"]>>;
|
|
280
|
+
mode: z.ZodOptional<z.ZodEnum<["literal", "regex"]>>;
|
|
281
|
+
}, "strict", z.ZodTypeAny, {
|
|
282
|
+
query?: string | undefined;
|
|
283
|
+
functionName?: string | undefined;
|
|
284
|
+
kind?: "procedures" | "strings" | undefined;
|
|
285
|
+
mode?: "literal" | "regex" | undefined;
|
|
286
|
+
}, {
|
|
287
|
+
query?: string | undefined;
|
|
288
|
+
functionName?: string | undefined;
|
|
289
|
+
kind?: "procedures" | "strings" | undefined;
|
|
290
|
+
mode?: "literal" | "regex" | undefined;
|
|
291
|
+
}>>;
|
|
292
|
+
}, "strip", z.ZodTypeAny, {
|
|
293
|
+
targetId: string;
|
|
294
|
+
capabilityId: string;
|
|
295
|
+
input?: {
|
|
296
|
+
query?: string | undefined;
|
|
297
|
+
functionName?: string | undefined;
|
|
298
|
+
kind?: "procedures" | "strings" | undefined;
|
|
299
|
+
mode?: "literal" | "regex" | undefined;
|
|
300
|
+
} | undefined;
|
|
301
|
+
artifactId?: string | undefined;
|
|
302
|
+
}, {
|
|
303
|
+
targetId: string;
|
|
304
|
+
capabilityId: string;
|
|
305
|
+
input?: {
|
|
306
|
+
query?: string | undefined;
|
|
307
|
+
functionName?: string | undefined;
|
|
308
|
+
kind?: "procedures" | "strings" | undefined;
|
|
309
|
+
mode?: "literal" | "regex" | undefined;
|
|
310
|
+
} | undefined;
|
|
311
|
+
artifactId?: string | undefined;
|
|
312
|
+
}>;
|
|
313
|
+
declare const findingsSearchSchema: z.ZodObject<{
|
|
314
|
+
targetId: z.ZodString;
|
|
315
|
+
query: z.ZodOptional<z.ZodString>;
|
|
316
|
+
types: z.ZodOptional<z.ZodArray<z.ZodEnum<["technology", "route", "network_endpoint", "module", "asset", "storage", "native_procedure", "native_string", "risk", "limitation"]>, "many">>;
|
|
317
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
318
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
319
|
+
}, "strip", z.ZodTypeAny, {
|
|
320
|
+
targetId: string;
|
|
321
|
+
query?: string | undefined;
|
|
322
|
+
types?: ("technology" | "route" | "network_endpoint" | "module" | "asset" | "storage" | "native_procedure" | "native_string" | "risk" | "limitation")[] | undefined;
|
|
323
|
+
limit?: number | undefined;
|
|
324
|
+
offset?: number | undefined;
|
|
325
|
+
}, {
|
|
326
|
+
targetId: string;
|
|
327
|
+
query?: string | undefined;
|
|
328
|
+
types?: ("technology" | "route" | "network_endpoint" | "module" | "asset" | "storage" | "native_procedure" | "native_string" | "risk" | "limitation")[] | undefined;
|
|
329
|
+
limit?: number | undefined;
|
|
330
|
+
offset?: number | undefined;
|
|
331
|
+
}>;
|
|
332
|
+
declare const evidenceListSchema: z.ZodObject<{
|
|
333
|
+
targetId: z.ZodString;
|
|
334
|
+
}, "strip", z.ZodTypeAny, {
|
|
335
|
+
targetId: string;
|
|
336
|
+
}, {
|
|
337
|
+
targetId: string;
|
|
338
|
+
}>;
|
|
339
|
+
declare const capabilitiesListSchema: z.ZodOptional<z.ZodObject<{
|
|
340
|
+
targetId: z.ZodOptional<z.ZodString>;
|
|
341
|
+
}, "strip", z.ZodTypeAny, {
|
|
342
|
+
targetId?: string | undefined;
|
|
343
|
+
}, {
|
|
344
|
+
targetId?: string | undefined;
|
|
345
|
+
}>>;
|
|
346
|
+
declare const targetIdSchema: z.ZodObject<{
|
|
347
|
+
targetId: z.ZodString;
|
|
348
|
+
}, "strip", z.ZodTypeAny, {
|
|
349
|
+
targetId: string;
|
|
350
|
+
}, {
|
|
351
|
+
targetId: string;
|
|
352
|
+
}>;
|
|
353
|
+
declare const jobIdSchema: z.ZodObject<{
|
|
354
|
+
jobId: z.ZodString;
|
|
355
|
+
}, "strip", z.ZodTypeAny, {
|
|
356
|
+
jobId: string;
|
|
357
|
+
}, {
|
|
358
|
+
jobId: string;
|
|
359
|
+
}>;
|
|
360
|
+
declare const terminalStartSchema: z.ZodObject<{
|
|
361
|
+
kind: z.ZodLiteral<"ipatool-auth">;
|
|
362
|
+
}, "strip", z.ZodTypeAny, {
|
|
363
|
+
kind: "ipatool-auth";
|
|
364
|
+
}, {
|
|
365
|
+
kind: "ipatool-auth";
|
|
366
|
+
}>;
|
|
367
|
+
declare const terminalInputSchema: z.ZodObject<{
|
|
368
|
+
sessionId: z.ZodString;
|
|
369
|
+
data: z.ZodString;
|
|
370
|
+
}, "strip", z.ZodTypeAny, {
|
|
371
|
+
sessionId: string;
|
|
372
|
+
data: string;
|
|
373
|
+
}, {
|
|
374
|
+
sessionId: string;
|
|
375
|
+
data: string;
|
|
376
|
+
}>;
|
|
377
|
+
declare const terminalStopSchema: z.ZodObject<{
|
|
378
|
+
sessionId: z.ZodString;
|
|
379
|
+
}, "strip", z.ZodTypeAny, {
|
|
380
|
+
sessionId: string;
|
|
381
|
+
}, {
|
|
382
|
+
sessionId: string;
|
|
383
|
+
}>;
|
|
384
|
+
declare const accountStatusSchema: z.ZodObject<{
|
|
385
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
386
|
+
}, "strip", z.ZodTypeAny, {
|
|
387
|
+
force?: boolean | undefined;
|
|
388
|
+
}, {
|
|
389
|
+
force?: boolean | undefined;
|
|
390
|
+
}>;
|
|
391
|
+
declare const accountCheckSchema: z.ZodEffects<z.ZodObject<{
|
|
392
|
+
appId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
393
|
+
bundleId: z.ZodOptional<z.ZodString>;
|
|
394
|
+
}, "strip", z.ZodTypeAny, {
|
|
395
|
+
appId?: string | number | undefined;
|
|
396
|
+
bundleId?: string | undefined;
|
|
397
|
+
}, {
|
|
398
|
+
appId?: string | number | undefined;
|
|
399
|
+
bundleId?: string | undefined;
|
|
400
|
+
}>, {
|
|
401
|
+
appId?: string | number | undefined;
|
|
402
|
+
bundleId?: string | undefined;
|
|
403
|
+
}, {
|
|
404
|
+
appId?: string | number | undefined;
|
|
405
|
+
bundleId?: string | undefined;
|
|
406
|
+
}>;
|
|
407
|
+
declare function parseAppStoreId(input: string): {
|
|
408
|
+
appId: number;
|
|
409
|
+
country: string;
|
|
410
|
+
} | null;
|
|
411
|
+
|
|
412
|
+
export { type AccountEntitlements, type AccountStatus, type AnalysisRunRecord, type ArtifactRecord, CHANNELS, type CapabilityDescriptor, type CoreError, type CoreEvent, type CoreRequest, type CoreResponse, type EntitlementCheck, type EntitlementRecord, type EvidenceRecord, type FindingConfidence, type FindingRecord, type FindingSearchResult, type FindingType, type HealthInfo, type HostPlatform, type JobEvent, type JobRecord, type JobStatus, type PackageFormat, type ResolveResult, type ResolvedTarget, type SourceDescriptor, type SourceId, type TargetDetail, type TargetPlatform, type TargetRecord, type TargetRef, type ToolInfo, accountCheckSchema, accountStatusSchema, capabilitiesListSchema, createJobSchema, createTargetSchema, evidenceListSchema, findingsSearchSchema, jobIdSchema, parseAppStoreId, resolveInputSchema, targetIdSchema, terminalInputSchema, terminalStartSchema, terminalStopSchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var CHANNELS = {
|
|
4
|
+
health: "health",
|
|
5
|
+
sourcesList: "sources:list",
|
|
6
|
+
targetsResolve: "targets:resolve",
|
|
7
|
+
targetsCreate: "targets:create",
|
|
8
|
+
targetsList: "targets:list",
|
|
9
|
+
targetsGet: "targets:get",
|
|
10
|
+
jobsCreate: "jobs:create",
|
|
11
|
+
jobsGet: "jobs:get",
|
|
12
|
+
jobsCancel: "jobs:cancel",
|
|
13
|
+
capabilitiesList: "capabilities:list",
|
|
14
|
+
findingsSearch: "findings:search",
|
|
15
|
+
evidenceList: "evidence:list",
|
|
16
|
+
terminalStart: "terminal:start",
|
|
17
|
+
terminalInput: "terminal:input",
|
|
18
|
+
terminalStop: "terminal:stop",
|
|
19
|
+
accountStatus: "account:status",
|
|
20
|
+
accountEntitlements: "account:entitlements",
|
|
21
|
+
accountCheckEntitlement: "account:check-entitlement"
|
|
22
|
+
};
|
|
23
|
+
var resolveInputSchema = z.object({
|
|
24
|
+
input: z.string().trim().min(1).max(4096)
|
|
25
|
+
});
|
|
26
|
+
var createTargetSchema = z.object({
|
|
27
|
+
resolutionId: z.string().min(1).max(128)
|
|
28
|
+
});
|
|
29
|
+
var createJobSchema = z.object({
|
|
30
|
+
targetId: z.string().uuid(),
|
|
31
|
+
capabilityId: z.string().trim().min(1).max(128),
|
|
32
|
+
artifactId: z.string().uuid().optional(),
|
|
33
|
+
input: z.object({
|
|
34
|
+
functionName: z.string().trim().min(1).max(256).regex(/^[A-Za-z_$][A-Za-z0-9_$.@:-]{0,255}$/).optional(),
|
|
35
|
+
query: z.string().trim().min(1).max(512).optional(),
|
|
36
|
+
kind: z.enum(["procedures", "strings"]).optional(),
|
|
37
|
+
mode: z.enum(["literal", "regex"]).optional()
|
|
38
|
+
}).strict().optional()
|
|
39
|
+
});
|
|
40
|
+
var findingsSearchSchema = z.object({
|
|
41
|
+
targetId: z.string().uuid(),
|
|
42
|
+
query: z.string().trim().max(512).optional(),
|
|
43
|
+
types: z.array(
|
|
44
|
+
z.enum([
|
|
45
|
+
"technology",
|
|
46
|
+
"route",
|
|
47
|
+
"network_endpoint",
|
|
48
|
+
"module",
|
|
49
|
+
"asset",
|
|
50
|
+
"storage",
|
|
51
|
+
"native_procedure",
|
|
52
|
+
"native_string",
|
|
53
|
+
"risk",
|
|
54
|
+
"limitation"
|
|
55
|
+
])
|
|
56
|
+
).optional(),
|
|
57
|
+
limit: z.number().int().min(1).max(1e3).optional(),
|
|
58
|
+
offset: z.number().int().min(0).optional()
|
|
59
|
+
});
|
|
60
|
+
var evidenceListSchema = z.object({
|
|
61
|
+
targetId: z.string().uuid()
|
|
62
|
+
});
|
|
63
|
+
var capabilitiesListSchema = z.object({
|
|
64
|
+
targetId: z.string().uuid().optional()
|
|
65
|
+
}).optional();
|
|
66
|
+
var targetIdSchema = z.object({
|
|
67
|
+
targetId: z.string().uuid()
|
|
68
|
+
});
|
|
69
|
+
var jobIdSchema = z.object({
|
|
70
|
+
jobId: z.string().uuid()
|
|
71
|
+
});
|
|
72
|
+
var terminalStartSchema = z.object({
|
|
73
|
+
kind: z.literal("ipatool-auth")
|
|
74
|
+
});
|
|
75
|
+
var terminalInputSchema = z.object({
|
|
76
|
+
sessionId: z.string().uuid(),
|
|
77
|
+
data: z.string().max(16384)
|
|
78
|
+
});
|
|
79
|
+
var terminalStopSchema = z.object({
|
|
80
|
+
sessionId: z.string().uuid()
|
|
81
|
+
});
|
|
82
|
+
var accountStatusSchema = z.object({
|
|
83
|
+
force: z.boolean().optional()
|
|
84
|
+
});
|
|
85
|
+
var accountCheckSchema = z.object({
|
|
86
|
+
appId: z.union([z.string(), z.number()]).optional(),
|
|
87
|
+
bundleId: z.string().optional()
|
|
88
|
+
}).refine((value) => value.appId !== void 0 || value.bundleId !== void 0, {
|
|
89
|
+
message: "appId or bundleId is required"
|
|
90
|
+
});
|
|
91
|
+
function parseAppStoreId(input) {
|
|
92
|
+
const trimmed = input.trim();
|
|
93
|
+
const numeric = trimmed.match(/^\d+$/);
|
|
94
|
+
if (numeric) {
|
|
95
|
+
return { appId: Number(numeric[0]), country: "cn" };
|
|
96
|
+
}
|
|
97
|
+
const idMatch = trimmed.match(/(?:\/id|\bid=)(\d+)/);
|
|
98
|
+
if (!idMatch) return null;
|
|
99
|
+
const countryMatch = trimmed.match(/apps\.apple\.com\/([a-z]{2})\//i);
|
|
100
|
+
return {
|
|
101
|
+
appId: Number(idMatch[1]),
|
|
102
|
+
country: (countryMatch?.[1] ?? "cn").toLowerCase()
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
CHANNELS,
|
|
107
|
+
accountCheckSchema,
|
|
108
|
+
accountStatusSchema,
|
|
109
|
+
capabilitiesListSchema,
|
|
110
|
+
createJobSchema,
|
|
111
|
+
createTargetSchema,
|
|
112
|
+
evidenceListSchema,
|
|
113
|
+
findingsSearchSchema,
|
|
114
|
+
jobIdSchema,
|
|
115
|
+
parseAppStoreId,
|
|
116
|
+
resolveInputSchema,
|
|
117
|
+
targetIdSchema,
|
|
118
|
+
terminalInputSchema,
|
|
119
|
+
terminalStartSchema,
|
|
120
|
+
terminalStopSchema
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport type TargetPlatform = \"ios\" | \"windows\" | \"macos\" | \"android\" | \"linux\";\nexport type HostPlatform = \"darwin\" | \"win32\" | \"linux\";\nexport type SourceId =\n | \"app-store\"\n | \"local-file\"\n | \"direct-url\"\n | \"microsoft-store\"\n | \"winget\";\nexport type PackageFormat =\n | \"ipa\"\n | \"msix\"\n | \"appx\"\n | \"exe\"\n | \"msi\"\n | \"zip\"\n | \"dmg\"\n | \"apk\";\n\nexport interface TargetRef {\n platform: TargetPlatform;\n sourceId: SourceId;\n sourceRef: string;\n}\n\nexport interface ResolvedTarget {\n targetRef: TargetRef;\n name: string;\n publisher?: string;\n version?: string;\n bundleId?: string;\n packageId?: string;\n iconUrl?: string;\n storeUrl?: string;\n metadata: Record<string, unknown>;\n}\n\nexport interface TargetRecord extends ResolvedTarget {\n id: string;\n slug: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ArtifactRecord {\n id: string;\n targetId: string;\n platform: TargetPlatform;\n packageFormat: PackageFormat;\n architecture?: string;\n sha256: string;\n path: string;\n sizeBytes: number;\n version?: string;\n buildNumber?: string;\n signature?: Record<string, unknown>;\n inspection?: Record<string, unknown>;\n sourceUrl?: string;\n downloadedAt: string;\n isCurrent: boolean;\n}\n\nexport type FindingType =\n | \"technology\"\n | \"route\"\n | \"network_endpoint\"\n | \"module\"\n | \"asset\"\n | \"storage\"\n | \"native_procedure\"\n | \"native_string\"\n | \"risk\"\n | \"limitation\";\n\nexport type FindingConfidence =\n | \"exact\"\n | \"high\"\n | \"medium\"\n | \"low\"\n | \"unknown\";\n\nexport interface FindingRecord {\n id: string;\n targetId: string;\n artifactId?: string;\n jobId: string;\n evidenceId: string;\n type: FindingType;\n value: string;\n group?: string;\n sourcePath?: string;\n start?: { line: number; column: number };\n end?: { line: number; column: number };\n confidence: FindingConfidence;\n metadata: Record<string, unknown>;\n createdAt: string;\n}\n\nexport interface EvidenceRecord {\n id: string;\n targetId: string;\n artifactId?: string;\n jobId: string;\n kind: string;\n format: \"json\" | \"markdown\" | \"text\";\n path: string;\n sha256: string;\n summary: Record<string, unknown>;\n parentEvidenceId?: string;\n createdAt: string;\n}\n\nexport interface FindingSearchResult {\n items: FindingRecord[];\n total: number;\n limit: number;\n offset: number;\n}\n\nexport interface AnalysisRunRecord {\n id: string;\n targetId?: string;\n status: \"running\" | \"completed\" | \"failed\" | \"interrupted\";\n startedAt: string;\n finishedAt?: string;\n result?: Record<string, unknown>;\n error?: { code: string; message: string; details?: unknown };\n updatedAt: string;\n}\n\nexport type JobStatus =\n | \"queued\"\n | \"resolving\"\n | \"awaiting_auth\"\n | \"awaiting_license\"\n | \"acquiring\"\n | \"inspecting\"\n | \"registering\"\n | \"ready\"\n | \"analyzing\"\n | \"analyzed\"\n | \"failed\"\n | \"cancelled\"\n | \"interrupted\";\n\nexport interface JobRecord {\n id: string;\n targetId?: string;\n sourceId?: SourceId;\n capabilityId: string;\n status: JobStatus;\n progress: number;\n params: Record<string, unknown>;\n result?: Record<string, unknown>;\n errorCode?: string;\n errorMessage?: string;\n createdAt: string;\n startedAt?: string;\n finishedAt?: string;\n}\n\nexport interface JobEvent {\n jobId: string;\n level: \"info\" | \"warn\" | \"error\";\n message: string;\n payload?: Record<string, unknown>;\n createdAt: string;\n}\n\nexport interface SourceDescriptor {\n id: SourceId;\n platform: TargetPlatform;\n displayName: string;\n requiresAuth: boolean;\n status: \"ready\" | \"preview\" | \"evaluate\";\n description: string;\n}\n\nexport interface CapabilityDescriptor {\n id: string;\n label: string;\n description: string;\n targetPlatforms: TargetPlatform[];\n packageFormats?: PackageFormat[];\n hostPlatforms?: HostPlatform[];\n available: boolean;\n reason?: string;\n requiresArtifact?: boolean;\n requiresInput?: \"function\" | \"query\";\n}\n\nexport interface ResolveResult {\n resolutionId: string;\n target: ResolvedTarget;\n provider: SourceDescriptor;\n}\n\nexport interface TargetDetail {\n target: TargetRecord;\n artifacts: ArtifactRecord[];\n jobs: JobRecord[];\n}\n\nexport interface CoreError {\n code: string;\n message: string;\n details?: unknown;\n}\n\nexport interface HealthInfo {\n version: string;\n workspaceRoot: string;\n hostPlatform: HostPlatform;\n store: \"sqlite\" | \"json\";\n tools?: ToolInfo[];\n}\n\nexport interface ToolInfo {\n id: string;\n label: string;\n path: string;\n available: boolean;\n}\n\nexport interface AccountStatus {\n authenticated: boolean;\n email?: string;\n name?: string;\n keychain: \"unlocked\" | \"locked\" | \"unknown\";\n checkedAt: string;\n message?: string;\n}\n\nexport interface EntitlementRecord {\n appId?: string | number;\n bundleId?: string;\n name: string;\n version?: string;\n platform?: string;\n}\n\nexport interface AccountEntitlements {\n items: EntitlementRecord[];\n checkedAt: string;\n truncated: boolean;\n error?: string;\n}\n\nexport interface EntitlementCheck {\n status: \"owned\" | \"not_owned\" | \"unknown\";\n checkedAt: string;\n message?: string;\n entitlement?: EntitlementRecord;\n}\n\nexport interface CoreRequest<T = unknown> {\n id: string;\n channel: string;\n payload: T;\n}\n\nexport type CoreResponse<T = unknown> =\n | { id: string; ok: true; data: T }\n | { id: string; ok: false; error: CoreError };\n\nexport type CoreEvent =\n | { type: \"job.updated\"; payload: JobRecord }\n | { type: \"job.log\"; payload: JobEvent }\n | { type: \"target.updated\"; payload: TargetRecord }\n | { type: \"terminal.data\"; payload: { sessionId: string; data: string } }\n | {\n type: \"terminal.exit\";\n payload: { sessionId: string; code: number | null; signal?: string | null };\n };\n\nexport const CHANNELS = {\n health: \"health\",\n sourcesList: \"sources:list\",\n targetsResolve: \"targets:resolve\",\n targetsCreate: \"targets:create\",\n targetsList: \"targets:list\",\n targetsGet: \"targets:get\",\n jobsCreate: \"jobs:create\",\n jobsGet: \"jobs:get\",\n jobsCancel: \"jobs:cancel\",\n capabilitiesList: \"capabilities:list\",\n findingsSearch: \"findings:search\",\n evidenceList: \"evidence:list\",\n terminalStart: \"terminal:start\",\n terminalInput: \"terminal:input\",\n terminalStop: \"terminal:stop\",\n accountStatus: \"account:status\",\n accountEntitlements: \"account:entitlements\",\n accountCheckEntitlement: \"account:check-entitlement\"\n} as const;\n\nexport const resolveInputSchema = z.object({\n input: z.string().trim().min(1).max(4096)\n});\n\nexport const createTargetSchema = z.object({\n resolutionId: z.string().min(1).max(128)\n});\n\nexport const createJobSchema = z.object({\n targetId: z.string().uuid(),\n capabilityId: z.string().trim().min(1).max(128),\n artifactId: z.string().uuid().optional(),\n input: z\n .object({\n functionName: z\n .string()\n .trim()\n .min(1)\n .max(256)\n .regex(/^[A-Za-z_$][A-Za-z0-9_$.@:-]{0,255}$/)\n .optional(),\n query: z.string().trim().min(1).max(512).optional(),\n kind: z.enum([\"procedures\", \"strings\"]).optional(),\n mode: z.enum([\"literal\", \"regex\"]).optional()\n })\n .strict()\n .optional()\n});\n\nexport const findingsSearchSchema = z.object({\n targetId: z.string().uuid(),\n query: z.string().trim().max(512).optional(),\n types: z\n .array(\n z.enum([\n \"technology\",\n \"route\",\n \"network_endpoint\",\n \"module\",\n \"asset\",\n \"storage\",\n \"native_procedure\",\n \"native_string\",\n \"risk\",\n \"limitation\"\n ])\n )\n .optional(),\n limit: z.number().int().min(1).max(1000).optional(),\n offset: z.number().int().min(0).optional()\n});\n\nexport const evidenceListSchema = z.object({\n targetId: z.string().uuid()\n});\n\nexport const capabilitiesListSchema = z\n .object({\n targetId: z.string().uuid().optional()\n })\n .optional();\n\nexport const targetIdSchema = z.object({\n targetId: z.string().uuid()\n});\n\nexport const jobIdSchema = z.object({\n jobId: z.string().uuid()\n});\n\nexport const terminalStartSchema = z.object({\n kind: z.literal(\"ipatool-auth\")\n});\n\nexport const terminalInputSchema = z.object({\n sessionId: z.string().uuid(),\n data: z.string().max(16_384)\n});\n\nexport const terminalStopSchema = z.object({\n sessionId: z.string().uuid()\n});\n\nexport const accountStatusSchema = z.object({\n force: z.boolean().optional()\n});\n\nexport const accountCheckSchema = z\n .object({\n appId: z.union([z.string(), z.number()]).optional(),\n bundleId: z.string().optional()\n })\n .refine((value) => value.appId !== undefined || value.bundleId !== undefined, {\n message: \"appId or bundleId is required\"\n });\n\nexport function parseAppStoreId(input: string): { appId: number; country: string } | null {\n const trimmed = input.trim();\n const numeric = trimmed.match(/^\\d+$/);\n if (numeric) {\n return { appId: Number(numeric[0]), country: \"cn\" };\n }\n\n const idMatch = trimmed.match(/(?:\\/id|\\bid=)(\\d+)/);\n if (!idMatch) return null;\n\n const countryMatch = trimmed.match(/apps\\.apple\\.com\\/([a-z]{2})\\//i);\n return {\n appId: Number(idMatch[1]),\n country: (countryMatch?.[1] ?? \"cn\").toLowerCase()\n };\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAoRX,IAAM,WAAW;AAAA,EACtB,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,yBAAyB;AAC3B;AAEO,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,IAAI;AAC1C,CAAC;AAEM,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AACzC,CAAC;AAEM,IAAM,kBAAkB,EAAE,OAAO;AAAA,EACtC,UAAU,EAAE,OAAO,EAAE,KAAK;AAAA,EAC1B,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,EAC9C,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,EACvC,OAAO,EACJ,OAAO;AAAA,IACN,cAAc,EACX,OAAO,EACP,KAAK,EACL,IAAI,CAAC,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.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Shared AppTrace types and schemas",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/zhuixin-labs/app-evidence.git",
|
|
9
|
+
"directory": "packages/shared"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22.19"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "dist/index.cjs",
|
|
19
|
+
"module": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"zod": "^3.25.76"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"tsup": "^8.5.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
40
|
+
}
|
|
6
41
|
}
|
package/README.md
DELETED