@miosa/sdk 1.2.2 → 1.2.3
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 +42 -0
- package/dist/index.d.ts +166 -26
- package/dist/index.js +346 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +5 -0
- package/src/index.ts +15 -0
- package/src/resources/deployments.test.ts +66 -0
- package/src/resources/deployments.ts +201 -0
- package/src/resources/docker-deploy.test.ts +102 -0
- package/src/resources/docker-deploy.ts +183 -0
- package/src/resources/phase1.test.ts +187 -0
- package/src/resources/quotas.ts +77 -0
- package/src/resources/sandbox-processes.ts +112 -0
- package/src/resources/sandbox-shares.ts +83 -0
- package/src/resources/tenant-events.ts +32 -0
- package/src/resources/tenant.ts +101 -19
- package/src/resources/webhooks.ts +39 -54
- package/src/resources/workspaces.ts +285 -0
package/dist/index.js
CHANGED
|
@@ -3645,6 +3645,26 @@ function dockerDeployMetadata(metadata) {
|
|
|
3645
3645
|
deployment_product: "docker_deploy"
|
|
3646
3646
|
};
|
|
3647
3647
|
}
|
|
3648
|
+
function dockerDeployProduct(deployment) {
|
|
3649
|
+
return deployment.deployment_product ?? deployment.metadata?.["deployment_product"];
|
|
3650
|
+
}
|
|
3651
|
+
function dockerDeployHostId(deployment) {
|
|
3652
|
+
const metadataHost = deployment.metadata?.["docker_deploy_host_id"];
|
|
3653
|
+
return deployment.docker_deploy_host_id ?? (typeof metadataHost === "string" ? metadataHost : null);
|
|
3654
|
+
}
|
|
3655
|
+
function addDoctorCheck(checks, name, ok, message, details) {
|
|
3656
|
+
checks.push({ name, ok, message, ...details ? { details } : {} });
|
|
3657
|
+
}
|
|
3658
|
+
function hostHealthy(host) {
|
|
3659
|
+
return Boolean(
|
|
3660
|
+
host && host.status === "active" && host.appliance_status === "healthy"
|
|
3661
|
+
);
|
|
3662
|
+
}
|
|
3663
|
+
function probeUrl(publicUrl, probePath) {
|
|
3664
|
+
const url = new URL(publicUrl);
|
|
3665
|
+
url.pathname = probePath.startsWith("/") ? probePath : `/${probePath}`;
|
|
3666
|
+
return url.toString();
|
|
3667
|
+
}
|
|
3648
3668
|
var DeploymentVersions = class {
|
|
3649
3669
|
constructor(http, deploymentId) {
|
|
3650
3670
|
this.http = http;
|
|
@@ -3838,6 +3858,114 @@ var Deployments = class {
|
|
|
3838
3858
|
metadata: dockerDeployMetadata(params.metadata)
|
|
3839
3859
|
});
|
|
3840
3860
|
}
|
|
3861
|
+
/**
|
|
3862
|
+
* Verify a Docker Deploy deployment before telling a user or agent it is
|
|
3863
|
+
* live. Checks product markers, appliance host health, route metadata, and
|
|
3864
|
+
* optionally probes the public URL.
|
|
3865
|
+
*/
|
|
3866
|
+
async doctorDockerDeploy(deploymentId, params = {}) {
|
|
3867
|
+
const checks = [];
|
|
3868
|
+
const deployment = await this.get(deploymentId);
|
|
3869
|
+
const metadata = deployment.metadata ?? {};
|
|
3870
|
+
const product = dockerDeployProduct(deployment);
|
|
3871
|
+
const hostId = dockerDeployHostId(deployment);
|
|
3872
|
+
addDoctorCheck(
|
|
3873
|
+
checks,
|
|
3874
|
+
"deployment_product",
|
|
3875
|
+
product === "docker_deploy",
|
|
3876
|
+
product === "docker_deploy" ? "Deployment is marked for Docker Deploy." : `Expected deployment_product=docker_deploy, got ${String(product ?? "missing")}.`,
|
|
3877
|
+
{ deployment_product: product ?? null }
|
|
3878
|
+
);
|
|
3879
|
+
addDoctorCheck(
|
|
3880
|
+
checks,
|
|
3881
|
+
"docker_deploy_host_id",
|
|
3882
|
+
Boolean(hostId),
|
|
3883
|
+
hostId ? "Deployment has a Docker Deploy host id." : "Deployment has no docker_deploy_host_id.",
|
|
3884
|
+
{ docker_deploy_host_id: hostId }
|
|
3885
|
+
);
|
|
3886
|
+
let host;
|
|
3887
|
+
if (hostId) {
|
|
3888
|
+
try {
|
|
3889
|
+
const rawHost = await this.http.get(
|
|
3890
|
+
`/docker-deploy/hosts/${hostId}`
|
|
3891
|
+
);
|
|
3892
|
+
host = unwrap23(rawHost);
|
|
3893
|
+
addDoctorCheck(
|
|
3894
|
+
checks,
|
|
3895
|
+
"docker_deploy_host_health",
|
|
3896
|
+
hostHealthy(host),
|
|
3897
|
+
hostHealthy(host) ? "Docker Deploy host is active and healthy." : `Docker Deploy host status=${host.status} appliance=${host.appliance_status}.`,
|
|
3898
|
+
{
|
|
3899
|
+
status: host.status,
|
|
3900
|
+
appliance_status: host.appliance_status
|
|
3901
|
+
}
|
|
3902
|
+
);
|
|
3903
|
+
} catch (error) {
|
|
3904
|
+
addDoctorCheck(
|
|
3905
|
+
checks,
|
|
3906
|
+
"docker_deploy_host_health",
|
|
3907
|
+
false,
|
|
3908
|
+
error instanceof Error ? error.message : String(error)
|
|
3909
|
+
);
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
const runtime = metadata["runtime"];
|
|
3913
|
+
const hasRuntimeRoute = typeof runtime === "object" && runtime !== null && typeof runtime["ip"] === "string" && typeof runtime["port"] === "number";
|
|
3914
|
+
addDoctorCheck(
|
|
3915
|
+
checks,
|
|
3916
|
+
"runtime_route",
|
|
3917
|
+
hasRuntimeRoute,
|
|
3918
|
+
hasRuntimeRoute ? "Deployment has appliance runtime route metadata." : "Deployment is missing appliance runtime route metadata.",
|
|
3919
|
+
typeof runtime === "object" && runtime !== null ? runtime : void 0
|
|
3920
|
+
);
|
|
3921
|
+
let probe;
|
|
3922
|
+
const publicUrl = deployment.public_url;
|
|
3923
|
+
const path = params.probePath ?? params.probe_path ?? "/";
|
|
3924
|
+
if (publicUrl && typeof fetch === "function") {
|
|
3925
|
+
const url = probeUrl(publicUrl, path);
|
|
3926
|
+
const controller = new AbortController();
|
|
3927
|
+
const timeout = setTimeout(
|
|
3928
|
+
() => controller.abort(),
|
|
3929
|
+
params.timeoutMs ?? params.timeout_ms ?? 1e4
|
|
3930
|
+
);
|
|
3931
|
+
try {
|
|
3932
|
+
const response = await fetch(url, {
|
|
3933
|
+
method: "GET",
|
|
3934
|
+
signal: controller.signal
|
|
3935
|
+
});
|
|
3936
|
+
probe = { url, ok: response.ok, status: response.status };
|
|
3937
|
+
addDoctorCheck(
|
|
3938
|
+
checks,
|
|
3939
|
+
"public_url_probe",
|
|
3940
|
+
response.ok,
|
|
3941
|
+
response.ok ? `Public URL returned HTTP ${response.status}.` : `Public URL returned HTTP ${response.status}.`,
|
|
3942
|
+
{ url, status: response.status }
|
|
3943
|
+
);
|
|
3944
|
+
} catch (error) {
|
|
3945
|
+
probe = {
|
|
3946
|
+
url,
|
|
3947
|
+
ok: false,
|
|
3948
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3949
|
+
};
|
|
3950
|
+
addDoctorCheck(
|
|
3951
|
+
checks,
|
|
3952
|
+
"public_url_probe",
|
|
3953
|
+
false,
|
|
3954
|
+
probe.error ?? "Public URL probe failed.",
|
|
3955
|
+
{ url }
|
|
3956
|
+
);
|
|
3957
|
+
} finally {
|
|
3958
|
+
clearTimeout(timeout);
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
return {
|
|
3962
|
+
ok: checks.every((check) => check.ok),
|
|
3963
|
+
deployment,
|
|
3964
|
+
...host ? { host } : {},
|
|
3965
|
+
checks,
|
|
3966
|
+
...probe ? { probe } : {}
|
|
3967
|
+
};
|
|
3968
|
+
}
|
|
3841
3969
|
async update(deploymentId, params) {
|
|
3842
3970
|
const body = stripUndefined10({
|
|
3843
3971
|
name: params.name,
|
|
@@ -3954,6 +4082,90 @@ var Deployments = class {
|
|
|
3954
4082
|
}
|
|
3955
4083
|
};
|
|
3956
4084
|
|
|
4085
|
+
// src/resources/docker-deploy.ts
|
|
4086
|
+
function workspaceId(params) {
|
|
4087
|
+
return params?.workspace_id ?? params?.workspaceId;
|
|
4088
|
+
}
|
|
4089
|
+
function ensureBody(params) {
|
|
4090
|
+
const body = {};
|
|
4091
|
+
const id = params.workspace_id ?? params.workspaceId;
|
|
4092
|
+
const externalId = params.external_workspace_id ?? params.externalWorkspaceId;
|
|
4093
|
+
if (id) body.workspace_id = id;
|
|
4094
|
+
if (externalId) body.external_workspace_id = externalId;
|
|
4095
|
+
return body;
|
|
4096
|
+
}
|
|
4097
|
+
function unwrapHost(response) {
|
|
4098
|
+
const host = response.data ?? response.host;
|
|
4099
|
+
if (!host) {
|
|
4100
|
+
throw new Error("Docker Deploy host response was empty.");
|
|
4101
|
+
}
|
|
4102
|
+
return host;
|
|
4103
|
+
}
|
|
4104
|
+
function unwrapTemplates(response) {
|
|
4105
|
+
return response.data ?? response.templates ?? [];
|
|
4106
|
+
}
|
|
4107
|
+
function unwrapTemplate(response) {
|
|
4108
|
+
const template = response.data ?? response.template;
|
|
4109
|
+
if (!template) {
|
|
4110
|
+
throw new Error("Docker Deploy template response was empty.");
|
|
4111
|
+
}
|
|
4112
|
+
return template;
|
|
4113
|
+
}
|
|
4114
|
+
var DockerDeploy = class {
|
|
4115
|
+
constructor(http) {
|
|
4116
|
+
this.http = http;
|
|
4117
|
+
}
|
|
4118
|
+
http;
|
|
4119
|
+
/**
|
|
4120
|
+
* List Docker Deploy appliance hosts scoped to the current tenant.
|
|
4121
|
+
*
|
|
4122
|
+
* Pass a workspace ID to inspect the dedicated always-on appliance machine
|
|
4123
|
+
* for one white-label workspace.
|
|
4124
|
+
*/
|
|
4125
|
+
async listHosts(params = {}) {
|
|
4126
|
+
const res = await this.http.get(
|
|
4127
|
+
"/docker-deploy/hosts",
|
|
4128
|
+
{ workspace_id: workspaceId(params) }
|
|
4129
|
+
);
|
|
4130
|
+
return res.data ?? res.hosts ?? [];
|
|
4131
|
+
}
|
|
4132
|
+
/**
|
|
4133
|
+
* Ensure a workspace has its dedicated Docker Deploy appliance host.
|
|
4134
|
+
*
|
|
4135
|
+
* The host may still be `pending`, `provisioning`, or `bootstrapping` after
|
|
4136
|
+
* this call. Treat `status === "active"` and `appliance_status === "healthy"`
|
|
4137
|
+
* as the ready condition before sending app/container traffic to it.
|
|
4138
|
+
*/
|
|
4139
|
+
async ensureHost(params = {}) {
|
|
4140
|
+
const res = await this.http.post(
|
|
4141
|
+
"/docker-deploy/hosts/ensure",
|
|
4142
|
+
ensureBody(params)
|
|
4143
|
+
);
|
|
4144
|
+
return { host: unwrapHost(res), queued: res.queued ?? false };
|
|
4145
|
+
}
|
|
4146
|
+
/** Fetch one Docker Deploy host by ID. */
|
|
4147
|
+
async getHost(hostId) {
|
|
4148
|
+
const res = await this.http.get(
|
|
4149
|
+
`/docker-deploy/hosts/${hostId}`
|
|
4150
|
+
);
|
|
4151
|
+
return unwrapHost(res);
|
|
4152
|
+
}
|
|
4153
|
+
/** List Docker Deploy starter templates. */
|
|
4154
|
+
async listTemplates() {
|
|
4155
|
+
const res = await this.http.get(
|
|
4156
|
+
"/docker-deploy/templates"
|
|
4157
|
+
);
|
|
4158
|
+
return unwrapTemplates(res);
|
|
4159
|
+
}
|
|
4160
|
+
/** Fetch one Docker Deploy starter template by ID. */
|
|
4161
|
+
async getTemplate(templateId) {
|
|
4162
|
+
const res = await this.http.get(
|
|
4163
|
+
`/docker-deploy/templates/${encodeURIComponent(templateId)}`
|
|
4164
|
+
);
|
|
4165
|
+
return unwrapTemplate(res);
|
|
4166
|
+
}
|
|
4167
|
+
};
|
|
4168
|
+
|
|
3957
4169
|
// src/resources/email.ts
|
|
3958
4170
|
function unwrap24(data) {
|
|
3959
4171
|
if (data && typeof data === "object") {
|
|
@@ -5105,49 +5317,49 @@ var OcWorkspaces = class {
|
|
|
5105
5317
|
/**
|
|
5106
5318
|
* Fetch a single workspace.
|
|
5107
5319
|
*/
|
|
5108
|
-
async get(hostId,
|
|
5320
|
+
async get(hostId, workspaceId2) {
|
|
5109
5321
|
return this.http.get(
|
|
5110
|
-
`${this.base(hostId)}/${
|
|
5322
|
+
`${this.base(hostId)}/${workspaceId2}`
|
|
5111
5323
|
);
|
|
5112
5324
|
}
|
|
5113
5325
|
/**
|
|
5114
5326
|
* Update workspace metadata (name, branch).
|
|
5115
5327
|
*/
|
|
5116
|
-
async update(hostId,
|
|
5328
|
+
async update(hostId, workspaceId2, params) {
|
|
5117
5329
|
return this.http.patch(
|
|
5118
|
-
`${this.base(hostId)}/${
|
|
5330
|
+
`${this.base(hostId)}/${workspaceId2}`,
|
|
5119
5331
|
params
|
|
5120
5332
|
);
|
|
5121
5333
|
}
|
|
5122
5334
|
/**
|
|
5123
5335
|
* Delete a workspace.
|
|
5124
5336
|
*/
|
|
5125
|
-
async delete(hostId,
|
|
5126
|
-
return this.http.delete(`${this.base(hostId)}/${
|
|
5337
|
+
async delete(hostId, workspaceId2) {
|
|
5338
|
+
return this.http.delete(`${this.base(hostId)}/${workspaceId2}`);
|
|
5127
5339
|
}
|
|
5128
5340
|
/**
|
|
5129
5341
|
* Pull the latest changes from the remote repository.
|
|
5130
5342
|
*/
|
|
5131
|
-
async pull(hostId,
|
|
5343
|
+
async pull(hostId, workspaceId2) {
|
|
5132
5344
|
return this.http.post(
|
|
5133
|
-
`${this.base(hostId)}/${
|
|
5345
|
+
`${this.base(hostId)}/${workspaceId2}/pull`
|
|
5134
5346
|
);
|
|
5135
5347
|
}
|
|
5136
5348
|
/**
|
|
5137
5349
|
* Open a terminal session scoped to the workspace root directory.
|
|
5138
5350
|
* Returns a short-lived WebSocket ticket.
|
|
5139
5351
|
*/
|
|
5140
|
-
async openTerminal(hostId,
|
|
5352
|
+
async openTerminal(hostId, workspaceId2) {
|
|
5141
5353
|
return this.http.post(
|
|
5142
|
-
`${this.base(hostId)}/${
|
|
5354
|
+
`${this.base(hostId)}/${workspaceId2}/open-terminal`
|
|
5143
5355
|
);
|
|
5144
5356
|
}
|
|
5145
5357
|
/**
|
|
5146
5358
|
* Stream workspace setup / clone / install events.
|
|
5147
5359
|
*/
|
|
5148
|
-
events(hostId,
|
|
5360
|
+
events(hostId, workspaceId2) {
|
|
5149
5361
|
return this.http.stream(
|
|
5150
|
-
`${this.base(hostId)}/${
|
|
5362
|
+
`${this.base(hostId)}/${workspaceId2}/events`
|
|
5151
5363
|
);
|
|
5152
5364
|
}
|
|
5153
5365
|
};
|
|
@@ -6753,22 +6965,96 @@ var OrgInvites = class {
|
|
|
6753
6965
|
function unwrap41(payload) {
|
|
6754
6966
|
if (payload && typeof payload === "object") {
|
|
6755
6967
|
const p = payload;
|
|
6756
|
-
for (const k of ["data", "tenant", "items"]) {
|
|
6968
|
+
for (const k of ["data", "tenant", "branding", "items"]) {
|
|
6757
6969
|
if (k in p) return p[k];
|
|
6758
6970
|
}
|
|
6759
6971
|
}
|
|
6760
6972
|
return payload;
|
|
6761
6973
|
}
|
|
6762
|
-
var
|
|
6974
|
+
var PreviewDomain = class {
|
|
6975
|
+
constructor(http) {
|
|
6976
|
+
this.http = http;
|
|
6977
|
+
}
|
|
6978
|
+
http;
|
|
6979
|
+
/** Get the tenant's white-label preview domain settings. */
|
|
6980
|
+
async get() {
|
|
6981
|
+
const data = await this.http.get("/tenant/preview-domain");
|
|
6982
|
+
return unwrap41(data);
|
|
6983
|
+
}
|
|
6984
|
+
/** Set the tenant's white-label preview domain. */
|
|
6985
|
+
async set(domain) {
|
|
6986
|
+
const data = await this.http.put("/tenant/preview-domain", {
|
|
6987
|
+
preview_domain: domain
|
|
6988
|
+
});
|
|
6989
|
+
return unwrap41(data);
|
|
6990
|
+
}
|
|
6991
|
+
/** Re-run DNS verification for the configured preview domain. */
|
|
6992
|
+
async verify() {
|
|
6993
|
+
const data = await this.http.post(
|
|
6994
|
+
"/tenant/preview-domain/verify",
|
|
6995
|
+
{}
|
|
6996
|
+
);
|
|
6997
|
+
return unwrap41(data);
|
|
6998
|
+
}
|
|
6999
|
+
/** Remove the tenant's custom preview domain. */
|
|
7000
|
+
async delete() {
|
|
7001
|
+
await this.http.delete("/tenant/preview-domain");
|
|
7002
|
+
}
|
|
7003
|
+
};
|
|
7004
|
+
var Branding = class {
|
|
6763
7005
|
constructor(http) {
|
|
6764
7006
|
this.http = http;
|
|
6765
7007
|
}
|
|
6766
7008
|
http;
|
|
7009
|
+
/** Get tenant branding used by white-label hosted surfaces. */
|
|
7010
|
+
async get() {
|
|
7011
|
+
const data = await this.http.get("/tenant/branding");
|
|
7012
|
+
return unwrap41(data);
|
|
7013
|
+
}
|
|
7014
|
+
/** Update tenant branding used by white-label hosted surfaces. */
|
|
7015
|
+
async set(params) {
|
|
7016
|
+
const body = Object.fromEntries(
|
|
7017
|
+
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
7018
|
+
);
|
|
7019
|
+
const data = await this.http.put("/tenant/branding", {
|
|
7020
|
+
branding: body
|
|
7021
|
+
});
|
|
7022
|
+
return unwrap41(data);
|
|
7023
|
+
}
|
|
7024
|
+
/** Reset tenant branding to platform defaults. */
|
|
7025
|
+
async delete() {
|
|
7026
|
+
await this.http.delete("/tenant/branding");
|
|
7027
|
+
}
|
|
7028
|
+
};
|
|
7029
|
+
var Tenant = class {
|
|
7030
|
+
http;
|
|
7031
|
+
preview_domain;
|
|
7032
|
+
branding;
|
|
7033
|
+
/** camelCase alias for SDK consumers that avoid snake_case properties. */
|
|
7034
|
+
previewDomain;
|
|
7035
|
+
constructor(http) {
|
|
7036
|
+
this.http = http;
|
|
7037
|
+
this.preview_domain = new PreviewDomain(http);
|
|
7038
|
+
this.previewDomain = this.preview_domain;
|
|
7039
|
+
this.branding = new Branding(http);
|
|
7040
|
+
}
|
|
6767
7041
|
/** Get the current tenant's plan, limits, and live usage counters. */
|
|
6768
7042
|
async current() {
|
|
6769
7043
|
const data = await this.http.get("/tenant/plan");
|
|
6770
7044
|
return unwrap41(data);
|
|
6771
7045
|
}
|
|
7046
|
+
/** Convenience alias for `tenant.branding.get()`. */
|
|
7047
|
+
async getBranding() {
|
|
7048
|
+
return this.branding.get();
|
|
7049
|
+
}
|
|
7050
|
+
/** Convenience alias for `tenant.branding.set(...)`. */
|
|
7051
|
+
async setBranding(params) {
|
|
7052
|
+
return this.branding.set(params);
|
|
7053
|
+
}
|
|
7054
|
+
/** Convenience alias for `tenant.branding.delete()`. */
|
|
7055
|
+
async deleteBranding() {
|
|
7056
|
+
await this.branding.delete();
|
|
7057
|
+
}
|
|
6772
7058
|
};
|
|
6773
7059
|
|
|
6774
7060
|
// src/resources/usage.ts
|
|
@@ -6890,43 +7176,35 @@ function stripUndefined25(input) {
|
|
|
6890
7176
|
function idempotencyKey10(key) {
|
|
6891
7177
|
return key ?? randomUUID();
|
|
6892
7178
|
}
|
|
6893
|
-
function
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
7179
|
+
function bodyBuffer(body) {
|
|
7180
|
+
if (Buffer.isBuffer(body)) return body;
|
|
7181
|
+
if (typeof body === "string") return Buffer.from(body, "utf8");
|
|
7182
|
+
return Buffer.from(body);
|
|
7183
|
+
}
|
|
7184
|
+
function verifySignature(body, header, secret, toleranceSec = 300) {
|
|
7185
|
+
const parts = Object.fromEntries(
|
|
7186
|
+
header.split(",").map((chunk) => chunk.split("=", 2)).filter(([key, value]) => key && value)
|
|
7187
|
+
);
|
|
7188
|
+
const timestamp = parts.t;
|
|
7189
|
+
const received = parts.v1;
|
|
7190
|
+
if (!timestamp || !received || !secret) return false;
|
|
7191
|
+
const unixSeconds = Number(timestamp);
|
|
7192
|
+
if (!Number.isFinite(unixSeconds)) return false;
|
|
7193
|
+
const ageSec = Math.abs(Date.now() / 1e3 - unixSeconds);
|
|
7194
|
+
if (ageSec > toleranceSec) {
|
|
7195
|
+
throw new Error("webhook timestamp too old");
|
|
7196
|
+
}
|
|
7197
|
+
const rawBody = bodyBuffer(body);
|
|
7198
|
+
const signed = Buffer.concat([Buffer.from(`${timestamp}.`), rawBody]);
|
|
7199
|
+
const expected = createHmac("sha256", secret).update(signed).digest("hex");
|
|
7200
|
+
try {
|
|
7201
|
+
return timingSafeEqual(
|
|
7202
|
+
Buffer.from(expected, "utf8"),
|
|
7203
|
+
Buffer.from(received, "utf8")
|
|
7204
|
+
);
|
|
7205
|
+
} catch {
|
|
7206
|
+
return false;
|
|
6906
7207
|
}
|
|
6907
|
-
if (timestamp == null || signatures.length === 0) return null;
|
|
6908
|
-
return { timestamp, signatures };
|
|
6909
|
-
}
|
|
6910
|
-
function verifySignature(body, header, secret, options = {}) {
|
|
6911
|
-
const parsed = parseSignatureHeader(header);
|
|
6912
|
-
if (!parsed) return false;
|
|
6913
|
-
const toleranceSeconds = options.toleranceSeconds ?? 300;
|
|
6914
|
-
const ageSeconds = Math.abs(Math.floor(Date.now() / 1e3) - parsed.timestamp);
|
|
6915
|
-
if (ageSeconds > toleranceSeconds) {
|
|
6916
|
-
throw new Error("Webhook signature timestamp is too old");
|
|
6917
|
-
}
|
|
6918
|
-
const bodyBuffer = Buffer.isBuffer(body) ? body : Buffer.from(body);
|
|
6919
|
-
const signedPayload = Buffer.concat([
|
|
6920
|
-
Buffer.from(`${parsed.timestamp}.`),
|
|
6921
|
-
bodyBuffer
|
|
6922
|
-
]);
|
|
6923
|
-
const expected = createHmac("sha256", secret).update(signedPayload).digest("hex");
|
|
6924
|
-
const expectedBuffer = Buffer.from(expected, "hex");
|
|
6925
|
-
return parsed.signatures.some((signature) => {
|
|
6926
|
-
const actualBuffer = Buffer.from(signature, "hex");
|
|
6927
|
-
if (actualBuffer.length !== expectedBuffer.length) return false;
|
|
6928
|
-
return timingSafeEqual(actualBuffer, expectedBuffer);
|
|
6929
|
-
});
|
|
6930
7208
|
}
|
|
6931
7209
|
var Webhooks = class {
|
|
6932
7210
|
constructor(http) {
|
|
@@ -6934,7 +7212,6 @@ var Webhooks = class {
|
|
|
6934
7212
|
}
|
|
6935
7213
|
http;
|
|
6936
7214
|
static verifySignature = verifySignature;
|
|
6937
|
-
static verify_signature = verifySignature;
|
|
6938
7215
|
async list(params = {}) {
|
|
6939
7216
|
const query = stripUndefined25({ ...params });
|
|
6940
7217
|
const data = await this.http.get("/webhooks", query);
|
|
@@ -6999,9 +7276,9 @@ var WorkspaceInvites = class {
|
|
|
6999
7276
|
*
|
|
7000
7277
|
* `POST /workspaces/:id/invites`
|
|
7001
7278
|
*/
|
|
7002
|
-
async create(
|
|
7279
|
+
async create(workspaceId2, params) {
|
|
7003
7280
|
return this.http.post(
|
|
7004
|
-
`/workspaces/${
|
|
7281
|
+
`/workspaces/${workspaceId2}/invites`,
|
|
7005
7282
|
params
|
|
7006
7283
|
);
|
|
7007
7284
|
}
|
|
@@ -7010,9 +7287,9 @@ var WorkspaceInvites = class {
|
|
|
7010
7287
|
*
|
|
7011
7288
|
* `GET /workspaces/:id/invites`
|
|
7012
7289
|
*/
|
|
7013
|
-
async list(
|
|
7290
|
+
async list(workspaceId2) {
|
|
7014
7291
|
const res = await this.http.get(
|
|
7015
|
-
`/workspaces/${
|
|
7292
|
+
`/workspaces/${workspaceId2}/invites`
|
|
7016
7293
|
);
|
|
7017
7294
|
return res.data ?? [];
|
|
7018
7295
|
}
|
|
@@ -7024,9 +7301,9 @@ var WorkspaceInvites = class {
|
|
|
7024
7301
|
*
|
|
7025
7302
|
* `DELETE /workspaces/:id/invites/:invite_id`
|
|
7026
7303
|
*/
|
|
7027
|
-
async revoke(
|
|
7304
|
+
async revoke(workspaceId2, inviteId) {
|
|
7028
7305
|
return this.http.delete(
|
|
7029
|
-
`/workspaces/${
|
|
7306
|
+
`/workspaces/${workspaceId2}/invites/${inviteId}`
|
|
7030
7307
|
);
|
|
7031
7308
|
}
|
|
7032
7309
|
/**
|
|
@@ -7080,9 +7357,9 @@ var WorkspaceMembers = class {
|
|
|
7080
7357
|
*
|
|
7081
7358
|
* `GET /workspaces/:id/members`
|
|
7082
7359
|
*/
|
|
7083
|
-
async list(
|
|
7360
|
+
async list(workspaceId2) {
|
|
7084
7361
|
const res = await this.http.get(
|
|
7085
|
-
`/workspaces/${
|
|
7362
|
+
`/workspaces/${workspaceId2}/members`
|
|
7086
7363
|
);
|
|
7087
7364
|
return res.data ?? res;
|
|
7088
7365
|
}
|
|
@@ -7098,9 +7375,9 @@ var WorkspaceMembers = class {
|
|
|
7098
7375
|
* @throws `MiosaError` with code `NOT_TENANT_MEMBER` if the user is not an
|
|
7099
7376
|
* org member.
|
|
7100
7377
|
*/
|
|
7101
|
-
async add(
|
|
7378
|
+
async add(workspaceId2, params) {
|
|
7102
7379
|
const res = await this.http.post(
|
|
7103
|
-
`/workspaces/${
|
|
7380
|
+
`/workspaces/${workspaceId2}/members`,
|
|
7104
7381
|
params
|
|
7105
7382
|
);
|
|
7106
7383
|
return res.data ?? res;
|
|
@@ -7110,9 +7387,9 @@ var WorkspaceMembers = class {
|
|
|
7110
7387
|
*
|
|
7111
7388
|
* `PATCH /workspaces/:id/members/:user_id`
|
|
7112
7389
|
*/
|
|
7113
|
-
async updateRole(
|
|
7390
|
+
async updateRole(workspaceId2, userId, params) {
|
|
7114
7391
|
const res = await this.http.patch(
|
|
7115
|
-
`/workspaces/${
|
|
7392
|
+
`/workspaces/${workspaceId2}/members/${userId}`,
|
|
7116
7393
|
params
|
|
7117
7394
|
);
|
|
7118
7395
|
return res.data ?? res;
|
|
@@ -7127,9 +7404,9 @@ var WorkspaceMembers = class {
|
|
|
7127
7404
|
*
|
|
7128
7405
|
* @throws `MiosaError` with code `LAST_OWNER` if the target is the sole owner.
|
|
7129
7406
|
*/
|
|
7130
|
-
async remove(
|
|
7407
|
+
async remove(workspaceId2, userId) {
|
|
7131
7408
|
return this.http.delete(
|
|
7132
|
-
`/workspaces/${
|
|
7409
|
+
`/workspaces/${workspaceId2}/members/${userId}`
|
|
7133
7410
|
);
|
|
7134
7411
|
}
|
|
7135
7412
|
};
|
|
@@ -7186,6 +7463,8 @@ var Miosa = class {
|
|
|
7186
7463
|
* Versions, releases, rollback, custom domains.
|
|
7187
7464
|
*/
|
|
7188
7465
|
deployments;
|
|
7466
|
+
/** Docker Deploy appliance hosts — one always-on workspace host, many apps. */
|
|
7467
|
+
dockerDeploy;
|
|
7189
7468
|
/** Credit balance and usage. */
|
|
7190
7469
|
credits;
|
|
7191
7470
|
/** Admin surface (`/api/v1/admin/*`) — requires an admin credential. */
|
|
@@ -7280,6 +7559,7 @@ var Miosa = class {
|
|
|
7280
7559
|
this.computers = new Computers(this.http);
|
|
7281
7560
|
this.sandboxes = new Sandboxes(this.http);
|
|
7282
7561
|
this.deployments = new Deployments(this.http);
|
|
7562
|
+
this.dockerDeploy = new DockerDeploy(this.http);
|
|
7283
7563
|
this.credits = new Credits(this.http);
|
|
7284
7564
|
this.admin = new Admin(this.http);
|
|
7285
7565
|
this.openComputers = new OpenComputers(this.http);
|
|
@@ -7309,6 +7589,6 @@ var Miosa = class {
|
|
|
7309
7589
|
}
|
|
7310
7590
|
};
|
|
7311
7591
|
|
|
7312
|
-
export { Admin, Analytics, ApiKeys, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAudit, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, EgressAudit, EgressNetwork, EgressSecrets, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OAuthFlow, OpenComputers, OrgInvites, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks, WorkspaceInvites, WorkspaceMembers, verifySignature };
|
|
7592
|
+
export { Admin, Analytics, ApiKeys, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAudit, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, DockerDeploy, EgressAudit, EgressNetwork, EgressSecrets, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OAuthFlow, OpenComputers, OrgInvites, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks, WorkspaceInvites, WorkspaceMembers, verifySignature };
|
|
7313
7593
|
//# sourceMappingURL=index.js.map
|
|
7314
7594
|
//# sourceMappingURL=index.js.map
|