@forg3t/sdk 0.1.4 → 0.1.5
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/README.md +43 -50
- package/dist/index.d.mts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +27 -5
- package/dist/index.mjs +27 -5
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ There is now also a live bearer-token bootstrap path for first-time tenant creat
|
|
|
33
33
|
- public hostname: `https://api.forg3t.io`
|
|
34
34
|
- auth mode: dashboard bearer token, not project API key
|
|
35
35
|
|
|
36
|
-
This closes the biggest admin-led onboarding gap
|
|
36
|
+
This closes the biggest admin-led onboarding gap. The published npm package now includes the bootstrap flow and request-creation surface, but the overall product is still not fully self-serve enterprise onboarding because tenant lifecycle cleanup, whitebox activation, and some runtime specialization paths remain operator-led.
|
|
37
37
|
|
|
38
38
|
## Local Development
|
|
39
39
|
1. **Build**: `npm run build`
|
|
@@ -43,66 +43,42 @@ This closes the biggest admin-led onboarding gap, but the published npm package
|
|
|
43
43
|
|
|
44
44
|
### Customer Onboarding Smoke
|
|
45
45
|
|
|
46
|
-
Use this as the first real integration gate for a
|
|
46
|
+
Use this as the first real integration gate for a new signed-in customer session.
|
|
47
47
|
The production API hostname is:
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
50
|
export FORG3T_API_URL=https://api.forg3t.io
|
|
51
|
-
export
|
|
52
|
-
export FORG3T_PROJECT_ID=... # optional if default project exists
|
|
51
|
+
export FORG3T_BEARER_TOKEN=eyJ...
|
|
53
52
|
```
|
|
54
53
|
|
|
55
|
-
Then run
|
|
54
|
+
Then run the official onboarding smoke:
|
|
56
55
|
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const client = new Forg3tClient({
|
|
61
|
-
apiUrl: process.env.FORG3T_API_URL,
|
|
62
|
-
apiKey: process.env.FORG3T_API_KEY,
|
|
63
|
-
timeoutMs: 30000,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
async function main() {
|
|
67
|
-
const me = await client.getCurrentUser();
|
|
68
|
-
const projectId = process.env.FORG3T_PROJECT_ID || me.defaultProjectId;
|
|
69
|
-
|
|
70
|
-
if (!projectId) {
|
|
71
|
-
throw new Error('Set FORG3T_PROJECT_ID or configure a default project first.');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const request = await client.createUnlearningRequest(projectId, {
|
|
75
|
-
target: { type: 'phrase', value: 'customer-onboarding-smoke' },
|
|
76
|
-
scope: {},
|
|
77
|
-
accessLevel: 'layer_a_only',
|
|
78
|
-
execution: {
|
|
79
|
-
target: {
|
|
80
|
-
provider: 'custom',
|
|
81
|
-
endpoint: 'https://example.com/inference'
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log({
|
|
87
|
-
requestId: request.id,
|
|
88
|
-
jobId: request.job?.id,
|
|
89
|
-
jobType: request.job?.type,
|
|
90
|
-
jobStatus: request.job?.status
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
main().catch((error) => {
|
|
95
|
-
console.error(error);
|
|
96
|
-
process.exit(1);
|
|
97
|
-
});
|
|
56
|
+
```bash
|
|
57
|
+
npm run smoke:customer-onboarding
|
|
98
58
|
```
|
|
99
59
|
|
|
100
60
|
This validates:
|
|
101
|
-
-
|
|
61
|
+
- bearer-token bootstrap
|
|
102
62
|
- project resolution
|
|
63
|
+
- API key creation
|
|
103
64
|
- unlearning request creation
|
|
65
|
+
- request detail fetch
|
|
66
|
+
- API key revoke
|
|
104
67
|
- job contract correctness
|
|
105
|
-
-
|
|
68
|
+
- first-customer path through the public API hostname
|
|
69
|
+
|
|
70
|
+
### Cleanroom Release Smoke
|
|
71
|
+
|
|
72
|
+
For release verification from a clean temporary install:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
export FORG3T_ONBOARDING_SMOKE_EMAIL=onboarding-smoke@forg3t.io
|
|
76
|
+
export FORG3T_ONBOARDING_SMOKE_PASSWORD=...
|
|
77
|
+
export SUPABASE_ANON_KEY=...
|
|
78
|
+
npm run smoke:cleanroom
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This installs the package into a fresh temporary directory, runs bootstrap, creates a first request, fetches request detail, and revokes the temporary API key. It is the release-candidate gate we use before claiming the SDK package is ready to publish.
|
|
106
82
|
|
|
107
83
|
### First-Time Tenant Bootstrap
|
|
108
84
|
|
|
@@ -145,14 +121,31 @@ Notes:
|
|
|
145
121
|
- Repeating bootstrap with the same bearer token is idempotent and reuses the tenant resources.
|
|
146
122
|
- This flow is live on the control plane today.
|
|
147
123
|
|
|
124
|
+
### First-Time Bootstrap + First Request
|
|
125
|
+
|
|
126
|
+
If you want the full SDK example in one run:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
export FORG3T_API_URL=https://api.forg3t.io
|
|
130
|
+
export FORG3T_BEARER_TOKEN=eyJ...
|
|
131
|
+
npm run example:bootstrap
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This example:
|
|
135
|
+
|
|
136
|
+
1. bootstraps the tenant
|
|
137
|
+
2. creates a temporary project API key
|
|
138
|
+
3. submits the first request
|
|
139
|
+
4. fetches request detail
|
|
140
|
+
5. revokes the temporary API key
|
|
141
|
+
|
|
148
142
|
### Repo Maintainer Smoke
|
|
149
143
|
|
|
150
144
|
If you are working inside the Forg3t SDK repo itself, you can also run the bundled smoke script:
|
|
151
145
|
|
|
152
146
|
```bash
|
|
153
147
|
export FORG3T_API_URL=https://api.forg3t.io
|
|
154
|
-
export
|
|
155
|
-
export FORG3T_PROJECT_ID=...
|
|
148
|
+
export FORG3T_BEARER_TOKEN=eyJ...
|
|
156
149
|
npm run smoke:customer-onboarding
|
|
157
150
|
```
|
|
158
151
|
|
package/dist/index.d.mts
CHANGED
|
@@ -82,7 +82,12 @@ interface CreateApiKeyRequest {
|
|
|
82
82
|
expiresAt?: string;
|
|
83
83
|
}
|
|
84
84
|
interface CreateApiKeyResponse extends ApiKey {
|
|
85
|
-
|
|
85
|
+
key: string;
|
|
86
|
+
plaintextKey?: string;
|
|
87
|
+
}
|
|
88
|
+
interface RevokeApiKeyResponse {
|
|
89
|
+
status: 'revoked' | string;
|
|
90
|
+
revokedAt?: string | null;
|
|
86
91
|
}
|
|
87
92
|
interface AuditEvent {
|
|
88
93
|
id: string;
|
|
@@ -412,8 +417,8 @@ declare class Forg3tClient {
|
|
|
412
417
|
getUnlearningRequest(projectId: string, unlearningRequestId: string, requestId?: string): Promise<UnlearningRequest>;
|
|
413
418
|
listApiKeys(projectId: string, requestId?: string): Promise<ApiKey[]>;
|
|
414
419
|
createApiKey(projectId: string, data: CreateApiKeyRequest, requestId?: string): Promise<CreateApiKeyResponse>;
|
|
415
|
-
rotateApiKey(keyId: string, requestId?: string): Promise<CreateApiKeyResponse>;
|
|
416
|
-
revokeApiKey(keyId: string, requestId?: string): Promise<
|
|
420
|
+
rotateApiKey(projectId: string, keyId: string, requestId?: string): Promise<CreateApiKeyResponse>;
|
|
421
|
+
revokeApiKey(projectId: string, keyId: string, requestId?: string): Promise<RevokeApiKeyResponse>;
|
|
417
422
|
submitJob(projectId: string, data: SubmitJobRequest, requestId?: string): Promise<Job>;
|
|
418
423
|
/**
|
|
419
424
|
* Creates a new job with deduplication support via an optional idempotency key.
|
|
@@ -754,4 +759,4 @@ declare const ENTERPRISE_STRICT_QUALITY_GATE_POLICY: Required<WhiteboxQualityGat
|
|
|
754
759
|
declare function assertDeploymentCompatibility(options: DeploymentCompatibilityOptions): void;
|
|
755
760
|
declare function buildWhiteboxWorkerOptions(profile: Forg3tDeploymentProfile, baseOptions: WhiteboxWorkerBaseOptions): WhiteboxWorkerOptions;
|
|
756
761
|
|
|
757
|
-
export { AccessLevel, type AdapterCommandSpec, type ApiKey, type AuditEvent, type AuditEventFilters, type AuditEventListResponse, type BaseAdapterConfig, type BootstrapTenantRequest, type BootstrapTenantResponse, type BuildModelUnlearningJobInput, type ClaimAssertion, type ClaimJobsRequest, type ClaimScope, type ClaimType, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateIntegrationRequest, type CreateUnlearningRequestParams, type CreateWebhookRequest, type CurrentUserResponse, DEFAULT_WHITEBOX_QUALITY_GATE_POLICY, type DeploymentCompatibilityOptions, ENTERPRISE_STRICT_QUALITY_GATE_POLICY, type EvidenceArtifact, type EvidencePdfResponse, type EvidenceStatusResponse, type ExecutionPlan, type ExecutionStep, type Forg3tAdapterMode, Forg3tApiConnectionError, Forg3tAuthenticationError, Forg3tClient, type Forg3tClientOptions, type Forg3tDeploymentProfile, Forg3tError, Forg3tNotFoundError, Forg3tNotImplementedError, Forg3tRateLimitError, HttpTrainingAdapter, type HttpTrainingAdapterOptions, type Integration, IntegrationMode, IntegrationType, type Job, type JobConfig, type JobError, type JobMutationOptions, type JobResult, type JobStatus, type JobType, type LangChainAdapterConfig, type LocalCommandAdapterOptions, LocalCommandTrainingAdapter, type ModelArtifactReference, type NativeAdapterConfig, type OpenRouterAdapterConfig, type PaginationParams, type Project, type SubmitJobRequest, type TrainingBackendAdapter, type UnlearningClaim, type UnlearningExecutionModelRef, type UnlearningExecutionPlanSpec, type UnlearningExecutionSpec, type UnlearningExecutionTargetSpec, type UnlearningJobSummary, type UnlearningRequest, type UnlearningScope, type UnlearningTarget, type UpdateWebhookRequest, WHITEBOX_QUALITY_GATE_PRESETS, WHITEBOX_QUALITY_GATE_PRESET_EXPLANATIONS, type Webhook, type WebhookDelivery, type WebhookDeliveryFilters, type WhiteboxEvaluationInput, type WhiteboxEvaluationOutput, type WhiteboxJobContext, type WhiteboxQualityGateDecision, type WhiteboxQualityGatePolicy, type WhiteboxQualityGatePreset, type WhiteboxTargetSpec, type WhiteboxUnlearningInput, type WhiteboxUnlearningOutput, type WhiteboxUnlearningPlan, WhiteboxWorker, type WhiteboxWorkerBaseOptions, type WhiteboxWorkerLogger, type WhiteboxWorkerOptions, assertDeploymentCompatibility, buildModelUnlearningPayload, buildWhiteboxWorkerOptions, createNativeTrainingAdapter, evaluateWhiteboxQualityGate, resolveWhiteboxQualityGatePolicy };
|
|
762
|
+
export { AccessLevel, type AdapterCommandSpec, type ApiKey, type AuditEvent, type AuditEventFilters, type AuditEventListResponse, type BaseAdapterConfig, type BootstrapTenantRequest, type BootstrapTenantResponse, type BuildModelUnlearningJobInput, type ClaimAssertion, type ClaimJobsRequest, type ClaimScope, type ClaimType, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateIntegrationRequest, type CreateUnlearningRequestParams, type CreateWebhookRequest, type CurrentUserResponse, DEFAULT_WHITEBOX_QUALITY_GATE_POLICY, type DeploymentCompatibilityOptions, ENTERPRISE_STRICT_QUALITY_GATE_POLICY, type EvidenceArtifact, type EvidencePdfResponse, type EvidenceStatusResponse, type ExecutionPlan, type ExecutionStep, type Forg3tAdapterMode, Forg3tApiConnectionError, Forg3tAuthenticationError, Forg3tClient, type Forg3tClientOptions, type Forg3tDeploymentProfile, Forg3tError, Forg3tNotFoundError, Forg3tNotImplementedError, Forg3tRateLimitError, HttpTrainingAdapter, type HttpTrainingAdapterOptions, type Integration, IntegrationMode, IntegrationType, type Job, type JobConfig, type JobError, type JobMutationOptions, type JobResult, type JobStatus, type JobType, type LangChainAdapterConfig, type LocalCommandAdapterOptions, LocalCommandTrainingAdapter, type ModelArtifactReference, type NativeAdapterConfig, type OpenRouterAdapterConfig, type PaginationParams, type Project, type RevokeApiKeyResponse, type SubmitJobRequest, type TrainingBackendAdapter, type UnlearningClaim, type UnlearningExecutionModelRef, type UnlearningExecutionPlanSpec, type UnlearningExecutionSpec, type UnlearningExecutionTargetSpec, type UnlearningJobSummary, type UnlearningRequest, type UnlearningScope, type UnlearningTarget, type UpdateWebhookRequest, WHITEBOX_QUALITY_GATE_PRESETS, WHITEBOX_QUALITY_GATE_PRESET_EXPLANATIONS, type Webhook, type WebhookDelivery, type WebhookDeliveryFilters, type WhiteboxEvaluationInput, type WhiteboxEvaluationOutput, type WhiteboxJobContext, type WhiteboxQualityGateDecision, type WhiteboxQualityGatePolicy, type WhiteboxQualityGatePreset, type WhiteboxTargetSpec, type WhiteboxUnlearningInput, type WhiteboxUnlearningOutput, type WhiteboxUnlearningPlan, WhiteboxWorker, type WhiteboxWorkerBaseOptions, type WhiteboxWorkerLogger, type WhiteboxWorkerOptions, assertDeploymentCompatibility, buildModelUnlearningPayload, buildWhiteboxWorkerOptions, createNativeTrainingAdapter, evaluateWhiteboxQualityGate, resolveWhiteboxQualityGatePolicy };
|
package/dist/index.d.ts
CHANGED
|
@@ -82,7 +82,12 @@ interface CreateApiKeyRequest {
|
|
|
82
82
|
expiresAt?: string;
|
|
83
83
|
}
|
|
84
84
|
interface CreateApiKeyResponse extends ApiKey {
|
|
85
|
-
|
|
85
|
+
key: string;
|
|
86
|
+
plaintextKey?: string;
|
|
87
|
+
}
|
|
88
|
+
interface RevokeApiKeyResponse {
|
|
89
|
+
status: 'revoked' | string;
|
|
90
|
+
revokedAt?: string | null;
|
|
86
91
|
}
|
|
87
92
|
interface AuditEvent {
|
|
88
93
|
id: string;
|
|
@@ -412,8 +417,8 @@ declare class Forg3tClient {
|
|
|
412
417
|
getUnlearningRequest(projectId: string, unlearningRequestId: string, requestId?: string): Promise<UnlearningRequest>;
|
|
413
418
|
listApiKeys(projectId: string, requestId?: string): Promise<ApiKey[]>;
|
|
414
419
|
createApiKey(projectId: string, data: CreateApiKeyRequest, requestId?: string): Promise<CreateApiKeyResponse>;
|
|
415
|
-
rotateApiKey(keyId: string, requestId?: string): Promise<CreateApiKeyResponse>;
|
|
416
|
-
revokeApiKey(keyId: string, requestId?: string): Promise<
|
|
420
|
+
rotateApiKey(projectId: string, keyId: string, requestId?: string): Promise<CreateApiKeyResponse>;
|
|
421
|
+
revokeApiKey(projectId: string, keyId: string, requestId?: string): Promise<RevokeApiKeyResponse>;
|
|
417
422
|
submitJob(projectId: string, data: SubmitJobRequest, requestId?: string): Promise<Job>;
|
|
418
423
|
/**
|
|
419
424
|
* Creates a new job with deduplication support via an optional idempotency key.
|
|
@@ -754,4 +759,4 @@ declare const ENTERPRISE_STRICT_QUALITY_GATE_POLICY: Required<WhiteboxQualityGat
|
|
|
754
759
|
declare function assertDeploymentCompatibility(options: DeploymentCompatibilityOptions): void;
|
|
755
760
|
declare function buildWhiteboxWorkerOptions(profile: Forg3tDeploymentProfile, baseOptions: WhiteboxWorkerBaseOptions): WhiteboxWorkerOptions;
|
|
756
761
|
|
|
757
|
-
export { AccessLevel, type AdapterCommandSpec, type ApiKey, type AuditEvent, type AuditEventFilters, type AuditEventListResponse, type BaseAdapterConfig, type BootstrapTenantRequest, type BootstrapTenantResponse, type BuildModelUnlearningJobInput, type ClaimAssertion, type ClaimJobsRequest, type ClaimScope, type ClaimType, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateIntegrationRequest, type CreateUnlearningRequestParams, type CreateWebhookRequest, type CurrentUserResponse, DEFAULT_WHITEBOX_QUALITY_GATE_POLICY, type DeploymentCompatibilityOptions, ENTERPRISE_STRICT_QUALITY_GATE_POLICY, type EvidenceArtifact, type EvidencePdfResponse, type EvidenceStatusResponse, type ExecutionPlan, type ExecutionStep, type Forg3tAdapterMode, Forg3tApiConnectionError, Forg3tAuthenticationError, Forg3tClient, type Forg3tClientOptions, type Forg3tDeploymentProfile, Forg3tError, Forg3tNotFoundError, Forg3tNotImplementedError, Forg3tRateLimitError, HttpTrainingAdapter, type HttpTrainingAdapterOptions, type Integration, IntegrationMode, IntegrationType, type Job, type JobConfig, type JobError, type JobMutationOptions, type JobResult, type JobStatus, type JobType, type LangChainAdapterConfig, type LocalCommandAdapterOptions, LocalCommandTrainingAdapter, type ModelArtifactReference, type NativeAdapterConfig, type OpenRouterAdapterConfig, type PaginationParams, type Project, type SubmitJobRequest, type TrainingBackendAdapter, type UnlearningClaim, type UnlearningExecutionModelRef, type UnlearningExecutionPlanSpec, type UnlearningExecutionSpec, type UnlearningExecutionTargetSpec, type UnlearningJobSummary, type UnlearningRequest, type UnlearningScope, type UnlearningTarget, type UpdateWebhookRequest, WHITEBOX_QUALITY_GATE_PRESETS, WHITEBOX_QUALITY_GATE_PRESET_EXPLANATIONS, type Webhook, type WebhookDelivery, type WebhookDeliveryFilters, type WhiteboxEvaluationInput, type WhiteboxEvaluationOutput, type WhiteboxJobContext, type WhiteboxQualityGateDecision, type WhiteboxQualityGatePolicy, type WhiteboxQualityGatePreset, type WhiteboxTargetSpec, type WhiteboxUnlearningInput, type WhiteboxUnlearningOutput, type WhiteboxUnlearningPlan, WhiteboxWorker, type WhiteboxWorkerBaseOptions, type WhiteboxWorkerLogger, type WhiteboxWorkerOptions, assertDeploymentCompatibility, buildModelUnlearningPayload, buildWhiteboxWorkerOptions, createNativeTrainingAdapter, evaluateWhiteboxQualityGate, resolveWhiteboxQualityGatePolicy };
|
|
762
|
+
export { AccessLevel, type AdapterCommandSpec, type ApiKey, type AuditEvent, type AuditEventFilters, type AuditEventListResponse, type BaseAdapterConfig, type BootstrapTenantRequest, type BootstrapTenantResponse, type BuildModelUnlearningJobInput, type ClaimAssertion, type ClaimJobsRequest, type ClaimScope, type ClaimType, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateIntegrationRequest, type CreateUnlearningRequestParams, type CreateWebhookRequest, type CurrentUserResponse, DEFAULT_WHITEBOX_QUALITY_GATE_POLICY, type DeploymentCompatibilityOptions, ENTERPRISE_STRICT_QUALITY_GATE_POLICY, type EvidenceArtifact, type EvidencePdfResponse, type EvidenceStatusResponse, type ExecutionPlan, type ExecutionStep, type Forg3tAdapterMode, Forg3tApiConnectionError, Forg3tAuthenticationError, Forg3tClient, type Forg3tClientOptions, type Forg3tDeploymentProfile, Forg3tError, Forg3tNotFoundError, Forg3tNotImplementedError, Forg3tRateLimitError, HttpTrainingAdapter, type HttpTrainingAdapterOptions, type Integration, IntegrationMode, IntegrationType, type Job, type JobConfig, type JobError, type JobMutationOptions, type JobResult, type JobStatus, type JobType, type LangChainAdapterConfig, type LocalCommandAdapterOptions, LocalCommandTrainingAdapter, type ModelArtifactReference, type NativeAdapterConfig, type OpenRouterAdapterConfig, type PaginationParams, type Project, type RevokeApiKeyResponse, type SubmitJobRequest, type TrainingBackendAdapter, type UnlearningClaim, type UnlearningExecutionModelRef, type UnlearningExecutionPlanSpec, type UnlearningExecutionSpec, type UnlearningExecutionTargetSpec, type UnlearningJobSummary, type UnlearningRequest, type UnlearningScope, type UnlearningTarget, type UpdateWebhookRequest, WHITEBOX_QUALITY_GATE_PRESETS, WHITEBOX_QUALITY_GATE_PRESET_EXPLANATIONS, type Webhook, type WebhookDelivery, type WebhookDeliveryFilters, type WhiteboxEvaluationInput, type WhiteboxEvaluationOutput, type WhiteboxJobContext, type WhiteboxQualityGateDecision, type WhiteboxQualityGatePolicy, type WhiteboxQualityGatePreset, type WhiteboxTargetSpec, type WhiteboxUnlearningInput, type WhiteboxUnlearningOutput, type WhiteboxUnlearningPlan, WhiteboxWorker, type WhiteboxWorkerBaseOptions, type WhiteboxWorkerLogger, type WhiteboxWorkerOptions, assertDeploymentCompatibility, buildModelUnlearningPayload, buildWhiteboxWorkerOptions, createNativeTrainingAdapter, evaluateWhiteboxQualityGate, resolveWhiteboxQualityGatePolicy };
|
package/dist/index.js
CHANGED
|
@@ -132,10 +132,14 @@ var Transport = class {
|
|
|
132
132
|
async request(path, options = {}, requestId) {
|
|
133
133
|
const url = `${this.baseUrl}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
134
134
|
const headers = {
|
|
135
|
-
"Content-Type": "application/json",
|
|
136
135
|
"Accept": "application/json",
|
|
137
136
|
...options.headers || {}
|
|
138
137
|
};
|
|
138
|
+
const hasExplicitContentType = Object.keys(headers).some((key) => key.toLowerCase() === "content-type");
|
|
139
|
+
const hasBody = options.body !== void 0 && options.body !== null;
|
|
140
|
+
if (hasBody && !hasExplicitContentType) {
|
|
141
|
+
headers["Content-Type"] = "application/json";
|
|
142
|
+
}
|
|
139
143
|
if (this.apiKey) {
|
|
140
144
|
headers["x-api-key"] = this.apiKey;
|
|
141
145
|
}
|
|
@@ -395,11 +399,29 @@ var Forg3tClient = class {
|
|
|
395
399
|
body: JSON.stringify(data)
|
|
396
400
|
}, requestId);
|
|
397
401
|
}
|
|
398
|
-
async rotateApiKey(keyId, requestId) {
|
|
399
|
-
|
|
402
|
+
async rotateApiKey(projectId, keyId, requestId) {
|
|
403
|
+
if (!projectId || !keyId) {
|
|
404
|
+
throw new Error("rotateApiKey requires both projectId and keyId.");
|
|
405
|
+
}
|
|
406
|
+
const existingKeys = await this.listApiKeys(projectId, requestId);
|
|
407
|
+
const current = existingKeys.find((item) => item.id === keyId);
|
|
408
|
+
if (!current) {
|
|
409
|
+
throw new Forg3tNotFoundError(`API key ${keyId} was not found in project ${projectId}.`, requestId);
|
|
410
|
+
}
|
|
411
|
+
const rotated = await this.createApiKey(projectId, {
|
|
412
|
+
name: current.name,
|
|
413
|
+
...current.expiresAt ? { expiresAt: current.expiresAt } : {}
|
|
414
|
+
}, requestId);
|
|
415
|
+
await this.revokeApiKey(projectId, keyId, requestId);
|
|
416
|
+
return rotated;
|
|
400
417
|
}
|
|
401
|
-
async revokeApiKey(keyId, requestId) {
|
|
402
|
-
|
|
418
|
+
async revokeApiKey(projectId, keyId, requestId) {
|
|
419
|
+
if (!projectId || !keyId) {
|
|
420
|
+
throw new Error("revokeApiKey requires both projectId and keyId.");
|
|
421
|
+
}
|
|
422
|
+
return this.transport.request(`/v1/projects/${projectId}/api-keys/${keyId}`, {
|
|
423
|
+
method: "DELETE"
|
|
424
|
+
}, requestId);
|
|
403
425
|
}
|
|
404
426
|
// --- Jobs ---
|
|
405
427
|
async submitJob(projectId, data, requestId) {
|
package/dist/index.mjs
CHANGED
|
@@ -74,10 +74,14 @@ var Transport = class {
|
|
|
74
74
|
async request(path, options = {}, requestId) {
|
|
75
75
|
const url = `${this.baseUrl}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
76
76
|
const headers = {
|
|
77
|
-
"Content-Type": "application/json",
|
|
78
77
|
"Accept": "application/json",
|
|
79
78
|
...options.headers || {}
|
|
80
79
|
};
|
|
80
|
+
const hasExplicitContentType = Object.keys(headers).some((key) => key.toLowerCase() === "content-type");
|
|
81
|
+
const hasBody = options.body !== void 0 && options.body !== null;
|
|
82
|
+
if (hasBody && !hasExplicitContentType) {
|
|
83
|
+
headers["Content-Type"] = "application/json";
|
|
84
|
+
}
|
|
81
85
|
if (this.apiKey) {
|
|
82
86
|
headers["x-api-key"] = this.apiKey;
|
|
83
87
|
}
|
|
@@ -337,11 +341,29 @@ var Forg3tClient = class {
|
|
|
337
341
|
body: JSON.stringify(data)
|
|
338
342
|
}, requestId);
|
|
339
343
|
}
|
|
340
|
-
async rotateApiKey(keyId, requestId) {
|
|
341
|
-
|
|
344
|
+
async rotateApiKey(projectId, keyId, requestId) {
|
|
345
|
+
if (!projectId || !keyId) {
|
|
346
|
+
throw new Error("rotateApiKey requires both projectId and keyId.");
|
|
347
|
+
}
|
|
348
|
+
const existingKeys = await this.listApiKeys(projectId, requestId);
|
|
349
|
+
const current = existingKeys.find((item) => item.id === keyId);
|
|
350
|
+
if (!current) {
|
|
351
|
+
throw new Forg3tNotFoundError(`API key ${keyId} was not found in project ${projectId}.`, requestId);
|
|
352
|
+
}
|
|
353
|
+
const rotated = await this.createApiKey(projectId, {
|
|
354
|
+
name: current.name,
|
|
355
|
+
...current.expiresAt ? { expiresAt: current.expiresAt } : {}
|
|
356
|
+
}, requestId);
|
|
357
|
+
await this.revokeApiKey(projectId, keyId, requestId);
|
|
358
|
+
return rotated;
|
|
342
359
|
}
|
|
343
|
-
async revokeApiKey(keyId, requestId) {
|
|
344
|
-
|
|
360
|
+
async revokeApiKey(projectId, keyId, requestId) {
|
|
361
|
+
if (!projectId || !keyId) {
|
|
362
|
+
throw new Error("revokeApiKey requires both projectId and keyId.");
|
|
363
|
+
}
|
|
364
|
+
return this.transport.request(`/v1/projects/${projectId}/api-keys/${keyId}`, {
|
|
365
|
+
method: "DELETE"
|
|
366
|
+
}, requestId);
|
|
345
367
|
}
|
|
346
368
|
// --- Jobs ---
|
|
347
369
|
async submitJob(projectId, data, requestId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forg3t/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Official TypeScript SDK for Forg3t Protocol",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"test:whitebox": "node ../../node_modules/ts-node/dist/bin.js tools/whitebox_hardening_smoke.ts",
|
|
29
29
|
"test:example": "npx tsx examples/quickstart.ts",
|
|
30
30
|
"smoke:staging": "node ../../node_modules/ts-node/dist/bin.js examples/staging-smoke.ts",
|
|
31
|
-
"smoke:customer-onboarding": "
|
|
31
|
+
"smoke:customer-onboarding": "npx tsx examples/bootstrap-onboarding.ts",
|
|
32
|
+
"smoke:cleanroom": "node scripts/run_cleanroom_smoke.js",
|
|
33
|
+
"example:bootstrap": "npx tsx examples/bootstrap-onboarding.ts",
|
|
32
34
|
"test:breaking": "node scripts/detect-breaking-changes.js",
|
|
33
35
|
"test:contract": "node tools/probe_contract.mjs",
|
|
34
36
|
"test:exports": "node tools/exports_smoke_esm.mjs && node tools/exports_smoke_cjs.cjs",
|