forkit-connect 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/QUICKSTART.md +55 -0
- package/README.md +96 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +4724 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +21 -0
- package/dist/launcher.d.ts +33 -0
- package/dist/launcher.js +9344 -0
- package/dist/ps-list-loader.d.ts +5 -0
- package/dist/ps-list-loader.js +20 -0
- package/dist/v1/agent-observation.d.ts +42 -0
- package/dist/v1/agent-observation.js +499 -0
- package/dist/v1/api.d.ts +276 -0
- package/dist/v1/api.js +390 -0
- package/dist/v1/credential-store.d.ts +92 -0
- package/dist/v1/credential-store.js +797 -0
- package/dist/v1/currency.d.ts +41 -0
- package/dist/v1/currency.js +127 -0
- package/dist/v1/daemon.d.ts +50 -0
- package/dist/v1/daemon.js +265 -0
- package/dist/v1/discovery.d.ts +61 -0
- package/dist/v1/discovery.js +168 -0
- package/dist/v1/filesystem-models.d.ts +11 -0
- package/dist/v1/filesystem-models.js +261 -0
- package/dist/v1/heartbeat.d.ts +45 -0
- package/dist/v1/heartbeat.js +463 -0
- package/dist/v1/lifecycle-monitor.d.ts +78 -0
- package/dist/v1/lifecycle-monitor.js +512 -0
- package/dist/v1/lmstudio.d.ts +11 -0
- package/dist/v1/lmstudio.js +148 -0
- package/dist/v1/ollama.d.ts +19 -0
- package/dist/v1/ollama.js +164 -0
- package/dist/v1/openai-compatible.d.ts +12 -0
- package/dist/v1/openai-compatible.js +124 -0
- package/dist/v1/process-scout.d.ts +50 -0
- package/dist/v1/process-scout.js +715 -0
- package/dist/v1/providers.d.ts +50 -0
- package/dist/v1/providers.js +106 -0
- package/dist/v1/service.d.ts +680 -0
- package/dist/v1/service.js +8286 -0
- package/dist/v1/state.d.ts +87 -0
- package/dist/v1/state.js +1318 -0
- package/dist/v1/test-credential-backend.d.ts +19 -0
- package/dist/v1/test-credential-backend.js +49 -0
- package/dist/v1/types.d.ts +873 -0
- package/dist/v1/types.js +3 -0
- package/dist/v1/update.d.ts +38 -0
- package/dist/v1/update.js +184 -0
- package/dist/v1/vitality-pulse.d.ts +36 -0
- package/dist/v1/vitality-pulse.js +512 -0
- package/package.json +53 -0
package/dist/v1/api.d.ts
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import type { ConnectEffectiveBindingState } from './types';
|
|
2
|
+
export interface ConnectApiConfig {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
sessionRef: string | null;
|
|
5
|
+
}
|
|
6
|
+
export interface ApiCallResult {
|
|
7
|
+
ok: boolean;
|
|
8
|
+
status: number;
|
|
9
|
+
body: unknown;
|
|
10
|
+
contract: ApiContractInfo | null;
|
|
11
|
+
}
|
|
12
|
+
export interface ApiContractInfo {
|
|
13
|
+
version: string | null;
|
|
14
|
+
compatibility: string | null;
|
|
15
|
+
mode: string | null;
|
|
16
|
+
min_client_version: string | null;
|
|
17
|
+
route_capabilities: string[];
|
|
18
|
+
server_capabilities: string[];
|
|
19
|
+
warnings: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface DeviceConnectStartResponse {
|
|
22
|
+
device_code: string;
|
|
23
|
+
user_code: string;
|
|
24
|
+
verification_url: string;
|
|
25
|
+
expires_at: string;
|
|
26
|
+
poll_interval_seconds: number;
|
|
27
|
+
binding_id?: string;
|
|
28
|
+
state?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface DeviceConnectPollPendingResponse {
|
|
31
|
+
status: 'pending';
|
|
32
|
+
poll_interval_seconds?: number;
|
|
33
|
+
expires_at?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface DeviceConnectPollApprovedResponse {
|
|
36
|
+
status: 'approved';
|
|
37
|
+
connect_access_token: string;
|
|
38
|
+
token_type: 'Bearer';
|
|
39
|
+
expires_in_seconds: number;
|
|
40
|
+
binding?: Record<string, unknown> | null;
|
|
41
|
+
}
|
|
42
|
+
export interface DeviceConnectStartRequest {
|
|
43
|
+
connect_device_id?: string | null;
|
|
44
|
+
connect_public_key?: string | null;
|
|
45
|
+
device_label?: string | null;
|
|
46
|
+
client_version?: string | null;
|
|
47
|
+
platform?: string | null;
|
|
48
|
+
arch?: string | null;
|
|
49
|
+
}
|
|
50
|
+
export type EffectiveBindingResponse = Omit<ConnectEffectiveBindingState, 'fetched_at'>;
|
|
51
|
+
export interface ProfileAccessWorkspace {
|
|
52
|
+
id?: string | null;
|
|
53
|
+
gaid?: string | null;
|
|
54
|
+
passportGaid?: string | null;
|
|
55
|
+
workspaceKind?: 'governed_container' | 'passport_shell' | string;
|
|
56
|
+
name?: string | null;
|
|
57
|
+
passportType?: 'model' | 'agent' | 'dataset' | string | null;
|
|
58
|
+
role?: 'owner' | 'maintainer' | 'contributor' | string;
|
|
59
|
+
ownerId?: string | null;
|
|
60
|
+
ownerName?: string | null;
|
|
61
|
+
description?: string | null;
|
|
62
|
+
visibility?: 'private' | 'public' | string;
|
|
63
|
+
verificationStatus?: 'unverified' | 'verified' | 'revoked' | string;
|
|
64
|
+
lifecycleStatus?: 'active' | 'deactivated' | string;
|
|
65
|
+
createdAt?: string | null;
|
|
66
|
+
updatedAt?: string | null;
|
|
67
|
+
}
|
|
68
|
+
export interface ProfileAccessResponse {
|
|
69
|
+
summary?: {
|
|
70
|
+
platformRole?: string;
|
|
71
|
+
tier?: string;
|
|
72
|
+
};
|
|
73
|
+
workspaces?: ProfileAccessWorkspace[];
|
|
74
|
+
}
|
|
75
|
+
export interface ProductSummaryResponse {
|
|
76
|
+
tier?: string | null;
|
|
77
|
+
baseTier?: string | null;
|
|
78
|
+
package?: {
|
|
79
|
+
slug?: string | null;
|
|
80
|
+
name?: string | null;
|
|
81
|
+
baseTier?: string | null;
|
|
82
|
+
} | null;
|
|
83
|
+
planCapabilities?: {
|
|
84
|
+
planKey?: string | null;
|
|
85
|
+
registration?: {
|
|
86
|
+
privatePassports?: number | null;
|
|
87
|
+
draftPassports?: number | null;
|
|
88
|
+
apiKeysPerPassport?: number | null;
|
|
89
|
+
activationTokensPerPassport?: number | null;
|
|
90
|
+
} | null;
|
|
91
|
+
governance?: {
|
|
92
|
+
maxGovernedProjects?: number | null;
|
|
93
|
+
maxGovernedWorkspaces?: number | null;
|
|
94
|
+
maxGovernedPassports?: number | null;
|
|
95
|
+
} | null;
|
|
96
|
+
runtimeSignals?: {
|
|
97
|
+
runtimeSignalsPerMonth?: number | null;
|
|
98
|
+
} | null;
|
|
99
|
+
} | null;
|
|
100
|
+
entitlements?: {
|
|
101
|
+
privatePassports?: number | null;
|
|
102
|
+
draftPassports?: number | null;
|
|
103
|
+
apiKeysPerPassport?: number | null;
|
|
104
|
+
activationTokensPerPassport?: number | null;
|
|
105
|
+
maxProjects?: number | null;
|
|
106
|
+
maxWorkspaces?: number | null;
|
|
107
|
+
maxGovernedPassports?: number | null;
|
|
108
|
+
} | null;
|
|
109
|
+
usage?: {
|
|
110
|
+
passports?: number | null;
|
|
111
|
+
privatePassports?: number | null;
|
|
112
|
+
drafts?: number | null;
|
|
113
|
+
projects?: number | null;
|
|
114
|
+
runtimeSignals?: number | null;
|
|
115
|
+
} | null;
|
|
116
|
+
}
|
|
117
|
+
export interface WorkspaceProject {
|
|
118
|
+
id?: string | null;
|
|
119
|
+
workspaceId?: string | null;
|
|
120
|
+
name?: string | null;
|
|
121
|
+
description?: string | null;
|
|
122
|
+
createdAt?: string | null;
|
|
123
|
+
updatedAt?: string | null;
|
|
124
|
+
passportCount?: number | null;
|
|
125
|
+
status?: string | null;
|
|
126
|
+
}
|
|
127
|
+
export interface WorkspaceProjectsResponse {
|
|
128
|
+
workspace?: ProfileAccessWorkspace | Record<string, unknown> | null;
|
|
129
|
+
projects?: WorkspaceProject[];
|
|
130
|
+
}
|
|
131
|
+
export interface WorkspaceCreateResponse {
|
|
132
|
+
workspace?: ProfileAccessWorkspace | Record<string, unknown> | null;
|
|
133
|
+
}
|
|
134
|
+
export interface WorkspaceProjectCreateResponse {
|
|
135
|
+
workspace?: ProfileAccessWorkspace | Record<string, unknown> | null;
|
|
136
|
+
project?: WorkspaceProject | null;
|
|
137
|
+
}
|
|
138
|
+
export interface PassportDraft {
|
|
139
|
+
id?: string | null;
|
|
140
|
+
ownerId?: string | null;
|
|
141
|
+
passportType?: string | null;
|
|
142
|
+
name?: string | null;
|
|
143
|
+
payload?: Record<string, unknown> | null;
|
|
144
|
+
createdAt?: string | null;
|
|
145
|
+
updatedAt?: string | null;
|
|
146
|
+
}
|
|
147
|
+
export interface PassportDraftListResponse {
|
|
148
|
+
drafts?: PassportDraft[];
|
|
149
|
+
tier?: string | null;
|
|
150
|
+
entitlements?: Record<string, unknown> | null;
|
|
151
|
+
}
|
|
152
|
+
export interface PassportDraftResponse {
|
|
153
|
+
draft?: PassportDraft | null;
|
|
154
|
+
}
|
|
155
|
+
export interface PassportDraftPublishResponse {
|
|
156
|
+
draftId?: string | null;
|
|
157
|
+
draftState?: string | null;
|
|
158
|
+
draft?: PassportDraft | null;
|
|
159
|
+
passport?: {
|
|
160
|
+
id?: number | null;
|
|
161
|
+
gaid?: string | null;
|
|
162
|
+
name?: string | null;
|
|
163
|
+
passportType?: string | null;
|
|
164
|
+
workspaceId?: string | null;
|
|
165
|
+
projectId?: string | null;
|
|
166
|
+
connectionStatus?: string | null;
|
|
167
|
+
} | null;
|
|
168
|
+
}
|
|
169
|
+
export interface PassportResponse {
|
|
170
|
+
passport?: {
|
|
171
|
+
id?: number | string | null;
|
|
172
|
+
gaid?: string | null;
|
|
173
|
+
name?: string | null;
|
|
174
|
+
passportType?: string | null;
|
|
175
|
+
workspaceId?: string | null;
|
|
176
|
+
projectId?: string | null;
|
|
177
|
+
connectionStatus?: string | null;
|
|
178
|
+
metadata?: Record<string, unknown> | null;
|
|
179
|
+
} | null;
|
|
180
|
+
}
|
|
181
|
+
export interface DeploymentCheckinRequest {
|
|
182
|
+
binding_id?: string | null;
|
|
183
|
+
sessionId?: string;
|
|
184
|
+
sessionLabel?: string;
|
|
185
|
+
environment?: string;
|
|
186
|
+
region?: string;
|
|
187
|
+
hostLabel?: string;
|
|
188
|
+
runtimeLabel?: string;
|
|
189
|
+
runtimeMode?: 'active' | 'paused' | 'draining' | string;
|
|
190
|
+
resourceAccuracy?: 'unknown' | 'measured' | 'estimated' | string;
|
|
191
|
+
resourceNote?: string;
|
|
192
|
+
metadata?: Record<string, unknown>;
|
|
193
|
+
}
|
|
194
|
+
export interface DeploymentCheckinResponse {
|
|
195
|
+
gaid?: string | null;
|
|
196
|
+
session?: {
|
|
197
|
+
sessionId?: string | null;
|
|
198
|
+
sessionLabel?: string | null;
|
|
199
|
+
environment?: string | null;
|
|
200
|
+
region?: string | null;
|
|
201
|
+
hostLabel?: string | null;
|
|
202
|
+
runtimeLabel?: string | null;
|
|
203
|
+
runtimeMode?: string | null;
|
|
204
|
+
revokedAt?: string | null;
|
|
205
|
+
resourceAccuracy?: string | null;
|
|
206
|
+
lastCheckinAt?: string | null;
|
|
207
|
+
metadata?: Record<string, unknown> | null;
|
|
208
|
+
} | null;
|
|
209
|
+
}
|
|
210
|
+
export interface DeploymentSessionResponse {
|
|
211
|
+
sessionId?: string | null;
|
|
212
|
+
sessionLabel?: string | null;
|
|
213
|
+
environment?: string | null;
|
|
214
|
+
region?: string | null;
|
|
215
|
+
hostLabel?: string | null;
|
|
216
|
+
runtimeLabel?: string | null;
|
|
217
|
+
runtimeMode?: string | null;
|
|
218
|
+
resourceAccuracy?: string | null;
|
|
219
|
+
lastCheckinAt?: string | null;
|
|
220
|
+
firstSeenAt?: string | null;
|
|
221
|
+
revokedAt?: string | null;
|
|
222
|
+
apiKeyId?: string | null;
|
|
223
|
+
metadata?: Record<string, unknown> | null;
|
|
224
|
+
}
|
|
225
|
+
export interface DeploymentListResponse {
|
|
226
|
+
gaid?: string | null;
|
|
227
|
+
summary?: {
|
|
228
|
+
totalSessions?: number | null;
|
|
229
|
+
activeSessions?: number | null;
|
|
230
|
+
standbySessions?: number | null;
|
|
231
|
+
sleepingSessions?: number | null;
|
|
232
|
+
offlineSessions?: number | null;
|
|
233
|
+
} | null;
|
|
234
|
+
sessions?: DeploymentSessionResponse[];
|
|
235
|
+
}
|
|
236
|
+
export declare class ConnectApiClient {
|
|
237
|
+
private readonly config;
|
|
238
|
+
constructor(config: ConnectApiConfig);
|
|
239
|
+
private getHeaders;
|
|
240
|
+
private parseContract;
|
|
241
|
+
getPassportsMine(limit?: number): Promise<ApiCallResult>;
|
|
242
|
+
getProductSummary(): Promise<ApiCallResult>;
|
|
243
|
+
createPassportDraft(payload: Record<string, unknown>): Promise<ApiCallResult>;
|
|
244
|
+
pushRuntimeSignalEvent(payload: Record<string, unknown>): Promise<ApiCallResult>;
|
|
245
|
+
getDeployments(gaid: string): Promise<ApiCallResult>;
|
|
246
|
+
sendDeploymentCheckin(gaid: string, payload: DeploymentCheckinRequest): Promise<ApiCallResult>;
|
|
247
|
+
getProfileAccess(): Promise<ApiCallResult>;
|
|
248
|
+
getWorkspaceProjects(workspaceId: string): Promise<ApiCallResult>;
|
|
249
|
+
createWorkspace(payload: {
|
|
250
|
+
name: string;
|
|
251
|
+
description?: string | null;
|
|
252
|
+
}): Promise<ApiCallResult>;
|
|
253
|
+
createWorkspaceProject(workspaceId: string, payload: {
|
|
254
|
+
name: string;
|
|
255
|
+
description?: string | null;
|
|
256
|
+
}): Promise<ApiCallResult>;
|
|
257
|
+
getPassportDrafts(): Promise<ApiCallResult>;
|
|
258
|
+
getPassportDraft(draftId: string): Promise<ApiCallResult>;
|
|
259
|
+
getPassport(gaid: string): Promise<ApiCallResult>;
|
|
260
|
+
publishPassportDraft(draftId: string): Promise<ApiCallResult>;
|
|
261
|
+
deletePassportDraft(draftId: string): Promise<ApiCallResult>;
|
|
262
|
+
startDeviceConnect(payload?: DeviceConnectStartRequest): Promise<ApiCallResult>;
|
|
263
|
+
pollDeviceConnect(deviceCode: string): Promise<ApiCallResult>;
|
|
264
|
+
getEffectiveBinding(connectDeviceId?: string | null): Promise<ApiCallResult>;
|
|
265
|
+
assignBindingScope(bindingId: string, workspaceId: string, projectId: string): Promise<ApiCallResult>;
|
|
266
|
+
updateBindingConsent(bindingId: string, consentProfile: unknown): Promise<ApiCallResult>;
|
|
267
|
+
refreshBindingPresence(bindingId: string, payload?: Record<string, unknown>): Promise<ApiCallResult>;
|
|
268
|
+
/**
|
|
269
|
+
* POST /api/v1/passports/:gaid/api-keys
|
|
270
|
+
* Requires session token (Bearer auth). Creates a runtime-signal API key for the
|
|
271
|
+
* owned passport. Returns the rawKey exactly once — caller must persist it.
|
|
272
|
+
*/
|
|
273
|
+
createPassportApiKey(gaid: string, label?: string): Promise<ApiCallResult>;
|
|
274
|
+
private parseBody;
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=api.d.ts.map
|
package/dist/v1/api.js
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectApiClient = void 0;
|
|
4
|
+
const CONNECT_API_CONTRACT_VERSION = 'connect.v1';
|
|
5
|
+
const CONNECT_API_CLIENT_CAPABILITIES = [
|
|
6
|
+
'additive-json',
|
|
7
|
+
'binding-capability-profile-v1',
|
|
8
|
+
'binding-consent-profile-v1',
|
|
9
|
+
'binding-presence-v1',
|
|
10
|
+
];
|
|
11
|
+
function readConnectClientVersion() {
|
|
12
|
+
const configured = String(process.env.FORKIT_CONNECT_VERSION || '').trim();
|
|
13
|
+
return configured || '0.1.0-local';
|
|
14
|
+
}
|
|
15
|
+
function parseCapabilityHeader(value) {
|
|
16
|
+
return [...new Set(String(value || '')
|
|
17
|
+
.split(',')
|
|
18
|
+
.map((entry) => entry.trim().toLowerCase())
|
|
19
|
+
.filter(Boolean))];
|
|
20
|
+
}
|
|
21
|
+
class ConnectApiClient {
|
|
22
|
+
config;
|
|
23
|
+
constructor(config) {
|
|
24
|
+
this.config = config;
|
|
25
|
+
}
|
|
26
|
+
getHeaders(extra) {
|
|
27
|
+
const headers = {
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
'X-Forkit-Client-Name': 'forkit-connect',
|
|
30
|
+
'X-Forkit-Client-Version': readConnectClientVersion(),
|
|
31
|
+
'X-Forkit-Contract-Version': CONNECT_API_CONTRACT_VERSION,
|
|
32
|
+
'X-Forkit-Client-Capabilities': CONNECT_API_CLIENT_CAPABILITIES.join(','),
|
|
33
|
+
...extra,
|
|
34
|
+
};
|
|
35
|
+
if (this.config.sessionRef) {
|
|
36
|
+
headers.Authorization = `Bearer ${this.config.sessionRef}`;
|
|
37
|
+
}
|
|
38
|
+
return headers;
|
|
39
|
+
}
|
|
40
|
+
parseContract(res) {
|
|
41
|
+
const version = res.headers.get('x-forkit-contract-version');
|
|
42
|
+
const compatibility = res.headers.get('x-forkit-contract-compatibility');
|
|
43
|
+
const mode = res.headers.get('x-forkit-contract-mode');
|
|
44
|
+
const minClientVersion = res.headers.get('x-forkit-min-client-version');
|
|
45
|
+
const routeCapabilities = parseCapabilityHeader(res.headers.get('x-forkit-route-capabilities'));
|
|
46
|
+
const serverCapabilities = parseCapabilityHeader(res.headers.get('x-forkit-server-capabilities'));
|
|
47
|
+
const warningsHeader = res.headers.get('x-forkit-contract-warnings');
|
|
48
|
+
if (!version
|
|
49
|
+
&& !compatibility
|
|
50
|
+
&& !mode
|
|
51
|
+
&& !minClientVersion
|
|
52
|
+
&& routeCapabilities.length === 0
|
|
53
|
+
&& serverCapabilities.length === 0
|
|
54
|
+
&& !warningsHeader) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
version: version || null,
|
|
59
|
+
compatibility: compatibility || null,
|
|
60
|
+
mode: mode || null,
|
|
61
|
+
min_client_version: minClientVersion || null,
|
|
62
|
+
route_capabilities: routeCapabilities,
|
|
63
|
+
server_capabilities: serverCapabilities,
|
|
64
|
+
warnings: String(warningsHeader || '')
|
|
65
|
+
.split('|')
|
|
66
|
+
.map((entry) => entry.trim())
|
|
67
|
+
.filter(Boolean),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async getPassportsMine(limit = 100) {
|
|
71
|
+
const safeLimit = Math.min(Math.max(Math.trunc(Number(limit) || 100), 1), 100);
|
|
72
|
+
const url = `${this.config.baseUrl}/api/v1/passports/mine?limit=${safeLimit}`;
|
|
73
|
+
const res = await fetch(url, {
|
|
74
|
+
method: 'GET',
|
|
75
|
+
headers: this.getHeaders(),
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
ok: res.ok,
|
|
79
|
+
status: res.status,
|
|
80
|
+
body: await this.parseBody(res),
|
|
81
|
+
contract: this.parseContract(res),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async getProductSummary() {
|
|
85
|
+
const url = `${this.config.baseUrl}/product/summary`;
|
|
86
|
+
const res = await fetch(url, {
|
|
87
|
+
method: 'GET',
|
|
88
|
+
headers: this.getHeaders(),
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
ok: res.ok,
|
|
92
|
+
status: res.status,
|
|
93
|
+
body: await this.parseBody(res),
|
|
94
|
+
contract: this.parseContract(res),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async createPassportDraft(payload) {
|
|
98
|
+
const url = `${this.config.baseUrl}/api/v1/passport-drafts`;
|
|
99
|
+
const res = await fetch(url, {
|
|
100
|
+
method: 'POST',
|
|
101
|
+
headers: this.getHeaders(),
|
|
102
|
+
body: JSON.stringify(payload),
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
ok: res.ok,
|
|
106
|
+
status: res.status,
|
|
107
|
+
body: await this.parseBody(res),
|
|
108
|
+
contract: this.parseContract(res),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async pushRuntimeSignalEvent(payload) {
|
|
112
|
+
const url = `${this.config.baseUrl}/api/v1/runtime-signals/events`;
|
|
113
|
+
const res = await fetch(url, {
|
|
114
|
+
method: 'POST',
|
|
115
|
+
headers: this.getHeaders(),
|
|
116
|
+
body: JSON.stringify(payload),
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
ok: res.ok,
|
|
120
|
+
status: res.status,
|
|
121
|
+
body: await this.parseBody(res),
|
|
122
|
+
contract: this.parseContract(res),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async getDeployments(gaid) {
|
|
126
|
+
const url = `${this.config.baseUrl}/api/v1/passports/${encodeURIComponent(gaid)}/deployments`;
|
|
127
|
+
const res = await fetch(url, {
|
|
128
|
+
method: 'GET',
|
|
129
|
+
headers: this.getHeaders(),
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
ok: res.ok,
|
|
133
|
+
status: res.status,
|
|
134
|
+
body: await this.parseBody(res),
|
|
135
|
+
contract: this.parseContract(res),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async sendDeploymentCheckin(gaid, payload) {
|
|
139
|
+
const url = `${this.config.baseUrl}/api/v1/passports/${encodeURIComponent(gaid)}/deployments/checkin`;
|
|
140
|
+
const res = await fetch(url, {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
headers: this.getHeaders(),
|
|
143
|
+
body: JSON.stringify(payload),
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
ok: res.ok,
|
|
147
|
+
status: res.status,
|
|
148
|
+
body: await this.parseBody(res),
|
|
149
|
+
contract: this.parseContract(res),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async getProfileAccess() {
|
|
153
|
+
const url = `${this.config.baseUrl}/api/profiles/access`;
|
|
154
|
+
const res = await fetch(url, {
|
|
155
|
+
method: 'GET',
|
|
156
|
+
headers: this.getHeaders(),
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
ok: res.ok,
|
|
160
|
+
status: res.status,
|
|
161
|
+
body: await this.parseBody(res),
|
|
162
|
+
contract: this.parseContract(res),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
async getWorkspaceProjects(workspaceId) {
|
|
166
|
+
const url = `${this.config.baseUrl}/api/v1/workspaces/${encodeURIComponent(workspaceId)}/projects`;
|
|
167
|
+
const res = await fetch(url, {
|
|
168
|
+
method: 'GET',
|
|
169
|
+
headers: this.getHeaders(),
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
ok: res.ok,
|
|
173
|
+
status: res.status,
|
|
174
|
+
body: await this.parseBody(res),
|
|
175
|
+
contract: this.parseContract(res),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
async createWorkspace(payload) {
|
|
179
|
+
const url = `${this.config.baseUrl}/api/v1/workspaces`;
|
|
180
|
+
const res = await fetch(url, {
|
|
181
|
+
method: 'POST',
|
|
182
|
+
headers: this.getHeaders(),
|
|
183
|
+
body: JSON.stringify(payload),
|
|
184
|
+
});
|
|
185
|
+
return {
|
|
186
|
+
ok: res.ok,
|
|
187
|
+
status: res.status,
|
|
188
|
+
body: await this.parseBody(res),
|
|
189
|
+
contract: this.parseContract(res),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
async createWorkspaceProject(workspaceId, payload) {
|
|
193
|
+
const url = `${this.config.baseUrl}/api/v1/workspaces/${encodeURIComponent(workspaceId)}/projects`;
|
|
194
|
+
const res = await fetch(url, {
|
|
195
|
+
method: 'POST',
|
|
196
|
+
headers: this.getHeaders(),
|
|
197
|
+
body: JSON.stringify(payload),
|
|
198
|
+
});
|
|
199
|
+
return {
|
|
200
|
+
ok: res.ok,
|
|
201
|
+
status: res.status,
|
|
202
|
+
body: await this.parseBody(res),
|
|
203
|
+
contract: this.parseContract(res),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
async getPassportDrafts() {
|
|
207
|
+
const url = `${this.config.baseUrl}/api/v1/passport-drafts`;
|
|
208
|
+
const res = await fetch(url, {
|
|
209
|
+
method: 'GET',
|
|
210
|
+
headers: this.getHeaders(),
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
ok: res.ok,
|
|
214
|
+
status: res.status,
|
|
215
|
+
body: await this.parseBody(res),
|
|
216
|
+
contract: this.parseContract(res),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
async getPassportDraft(draftId) {
|
|
220
|
+
const url = `${this.config.baseUrl}/api/v1/passport-drafts/${encodeURIComponent(draftId)}`;
|
|
221
|
+
const res = await fetch(url, {
|
|
222
|
+
method: 'GET',
|
|
223
|
+
headers: this.getHeaders(),
|
|
224
|
+
});
|
|
225
|
+
return {
|
|
226
|
+
ok: res.ok,
|
|
227
|
+
status: res.status,
|
|
228
|
+
body: await this.parseBody(res),
|
|
229
|
+
contract: this.parseContract(res),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
async getPassport(gaid) {
|
|
233
|
+
const url = `${this.config.baseUrl}/api/v1/passports/${encodeURIComponent(gaid)}`;
|
|
234
|
+
const res = await fetch(url, {
|
|
235
|
+
method: 'GET',
|
|
236
|
+
headers: this.getHeaders(),
|
|
237
|
+
});
|
|
238
|
+
return {
|
|
239
|
+
ok: res.ok,
|
|
240
|
+
status: res.status,
|
|
241
|
+
body: await this.parseBody(res),
|
|
242
|
+
contract: this.parseContract(res),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
async publishPassportDraft(draftId) {
|
|
246
|
+
const url = `${this.config.baseUrl}/api/v1/passport-drafts/${encodeURIComponent(draftId)}/publish`;
|
|
247
|
+
const res = await fetch(url, {
|
|
248
|
+
method: 'POST',
|
|
249
|
+
headers: this.getHeaders(),
|
|
250
|
+
body: JSON.stringify({}),
|
|
251
|
+
});
|
|
252
|
+
return {
|
|
253
|
+
ok: res.ok,
|
|
254
|
+
status: res.status,
|
|
255
|
+
body: await this.parseBody(res),
|
|
256
|
+
contract: this.parseContract(res),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
async deletePassportDraft(draftId) {
|
|
260
|
+
const url = `${this.config.baseUrl}/api/v1/passport-drafts/${encodeURIComponent(draftId)}`;
|
|
261
|
+
const res = await fetch(url, {
|
|
262
|
+
method: 'DELETE',
|
|
263
|
+
headers: this.getHeaders(),
|
|
264
|
+
});
|
|
265
|
+
return {
|
|
266
|
+
ok: res.ok,
|
|
267
|
+
status: res.status,
|
|
268
|
+
body: await this.parseBody(res),
|
|
269
|
+
contract: this.parseContract(res),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
async startDeviceConnect(payload = {}) {
|
|
273
|
+
const url = `${this.config.baseUrl}/api/auth/connect/device/start`;
|
|
274
|
+
const res = await fetch(url, {
|
|
275
|
+
method: 'POST',
|
|
276
|
+
headers: this.getHeaders(),
|
|
277
|
+
body: JSON.stringify(payload),
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
ok: res.ok,
|
|
281
|
+
status: res.status,
|
|
282
|
+
body: await this.parseBody(res),
|
|
283
|
+
contract: this.parseContract(res),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
async pollDeviceConnect(deviceCode) {
|
|
287
|
+
const url = `${this.config.baseUrl}/api/auth/connect/device/poll`;
|
|
288
|
+
const res = await fetch(url, {
|
|
289
|
+
method: 'POST',
|
|
290
|
+
headers: this.getHeaders(),
|
|
291
|
+
body: JSON.stringify({ device_code: deviceCode }),
|
|
292
|
+
});
|
|
293
|
+
return {
|
|
294
|
+
ok: res.ok,
|
|
295
|
+
status: res.status,
|
|
296
|
+
body: await this.parseBody(res),
|
|
297
|
+
contract: this.parseContract(res),
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
async getEffectiveBinding(connectDeviceId) {
|
|
301
|
+
const url = `${this.config.baseUrl}/api/v1/connect/bindings/effective`;
|
|
302
|
+
const res = await fetch(url, {
|
|
303
|
+
method: 'GET',
|
|
304
|
+
headers: this.getHeaders(connectDeviceId
|
|
305
|
+
? { 'X-Connect-Device-Id': connectDeviceId }
|
|
306
|
+
: undefined),
|
|
307
|
+
});
|
|
308
|
+
return {
|
|
309
|
+
ok: res.ok,
|
|
310
|
+
status: res.status,
|
|
311
|
+
body: await this.parseBody(res),
|
|
312
|
+
contract: this.parseContract(res),
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
async assignBindingScope(bindingId, workspaceId, projectId) {
|
|
316
|
+
const url = `${this.config.baseUrl}/api/v1/connect/bindings/${encodeURIComponent(bindingId)}/scope`;
|
|
317
|
+
const res = await fetch(url, {
|
|
318
|
+
method: 'POST',
|
|
319
|
+
headers: this.getHeaders(),
|
|
320
|
+
body: JSON.stringify({
|
|
321
|
+
workspace_id: workspaceId,
|
|
322
|
+
project_id: projectId,
|
|
323
|
+
}),
|
|
324
|
+
});
|
|
325
|
+
return {
|
|
326
|
+
ok: res.ok,
|
|
327
|
+
status: res.status,
|
|
328
|
+
body: await this.parseBody(res),
|
|
329
|
+
contract: this.parseContract(res),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
async updateBindingConsent(bindingId, consentProfile) {
|
|
333
|
+
const url = `${this.config.baseUrl}/api/v1/connect/bindings/${encodeURIComponent(bindingId)}/consent`;
|
|
334
|
+
const res = await fetch(url, {
|
|
335
|
+
method: 'PATCH',
|
|
336
|
+
headers: this.getHeaders(),
|
|
337
|
+
body: JSON.stringify({
|
|
338
|
+
consent_profile: consentProfile,
|
|
339
|
+
}),
|
|
340
|
+
});
|
|
341
|
+
return {
|
|
342
|
+
ok: res.ok,
|
|
343
|
+
status: res.status,
|
|
344
|
+
body: await this.parseBody(res),
|
|
345
|
+
contract: this.parseContract(res),
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
async refreshBindingPresence(bindingId, payload = {}) {
|
|
349
|
+
const url = `${this.config.baseUrl}/api/v1/connect/bindings/${encodeURIComponent(bindingId)}/presence`;
|
|
350
|
+
const res = await fetch(url, {
|
|
351
|
+
method: 'POST',
|
|
352
|
+
headers: this.getHeaders(),
|
|
353
|
+
body: JSON.stringify(payload),
|
|
354
|
+
});
|
|
355
|
+
return {
|
|
356
|
+
ok: res.ok,
|
|
357
|
+
status: res.status,
|
|
358
|
+
body: await this.parseBody(res),
|
|
359
|
+
contract: this.parseContract(res),
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* POST /api/v1/passports/:gaid/api-keys
|
|
364
|
+
* Requires session token (Bearer auth). Creates a runtime-signal API key for the
|
|
365
|
+
* owned passport. Returns the rawKey exactly once — caller must persist it.
|
|
366
|
+
*/
|
|
367
|
+
async createPassportApiKey(gaid, label) {
|
|
368
|
+
const url = `${this.config.baseUrl}/api/v1/passports/${encodeURIComponent(gaid)}/api-keys`;
|
|
369
|
+
const res = await fetch(url, {
|
|
370
|
+
method: 'POST',
|
|
371
|
+
headers: this.getHeaders(),
|
|
372
|
+
body: JSON.stringify({ label: label ?? 'Forkit Connect (auto)' }),
|
|
373
|
+
});
|
|
374
|
+
return {
|
|
375
|
+
ok: res.ok,
|
|
376
|
+
status: res.status,
|
|
377
|
+
body: await this.parseBody(res),
|
|
378
|
+
contract: this.parseContract(res),
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
async parseBody(res) {
|
|
382
|
+
const contentType = res.headers.get('content-type') ?? '';
|
|
383
|
+
if (contentType.includes('application/json')) {
|
|
384
|
+
return res.json();
|
|
385
|
+
}
|
|
386
|
+
return res.text();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
exports.ConnectApiClient = ConnectApiClient;
|
|
390
|
+
//# sourceMappingURL=api.js.map
|