@dcl/sdk-commands 7.30.2-39298229670.commit-4f1b1eb → 7.30.2-39664458136.commit-06bfc6c

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 CHANGED
@@ -46,6 +46,8 @@ npx @dcl/sdk-commands build
46
46
  npx @dcl/sdk-commands deploy
47
47
  ```
48
48
 
49
+ Large scenes upload in batches when the target server supports it. While deploying, the linker server exposes the deployment at `/api/deploy`: `GET` returns its state (JSON, or server-sent events with `Accept: text/event-stream`) and `DELETE` cancels it. Cancelling needs the `X-Deploy-Token` header, set with `--deploy-token <token>` (16+ characters) or random per run; the browser gets it in the linker URL fragment (`/#token=...`).
50
+
49
51
  ### Export Static Content
50
52
 
51
53
  ```bash
@@ -0,0 +1,51 @@
1
+ import { CliComponents } from '../../components';
2
+ import { LinkerResponse } from '../../linker-dapp/routes';
3
+ import { CliError } from '../../logic/error';
4
+ import { DeploymentResult, IDeploymentStateComponent } from './state';
5
+ export type DeployContext = {
6
+ signal: AbortSignal;
7
+ state: IDeploymentStateComponent;
8
+ /**
9
+ * Moves to `undeploying` right before the undeploy request is sent, so a cancel is refused from then on.
10
+ * Throws a `DEPLOY_CANCELLED` error when the deployment was already cancelled.
11
+ */
12
+ startUndeploy(): void;
13
+ };
14
+ export type DeployFunction = (linkerResponse: LinkerResponse, context: DeployContext) => Promise<DeploymentResult>;
15
+ export type CancelOutcome = 'cancelled' | 'cancelling' | 'refused' | 'final';
16
+ export declare const PUBLICATION_CHECK_DELAYS_MS: readonly number[];
17
+ export interface IDeploymentComponent {
18
+ state: IDeploymentStateComponent;
19
+ /** Whether a signed deployment can still be started. */
20
+ canStart(): boolean;
21
+ /**
22
+ * Runs the deployment once, moving the state to its final phase. Rejects with the deployment error, or
23
+ * with a `DEPLOY_CANCELLED*` CliError when it was cancelled and the entity did not get published.
24
+ */
25
+ run(linkerResponse: LinkerResponse): Promise<DeploymentResult>;
26
+ /**
27
+ * Cancels the deployment: before the signature it ends as `cancelled` right away, while preparing or
28
+ * uploading it aborts the requests in flight and `run` settles the outcome. It is refused while undeploying,
29
+ * since the world's scenes may already be gone once the undeploy request is sent.
30
+ */
31
+ cancel(): CancelOutcome;
32
+ }
33
+ export declare function deploymentCancelledError(): CliError<"DEPLOY_CANCELLED">;
34
+ export declare function cancelledAfterUndeployError(): CliError<"DEPLOY_CANCELLED_AFTER_UNDEPLOY">;
35
+ export declare function cancelOutcomeUncertainError(): CliError<"DEPLOY_CANCEL_OUTCOME_UNCERTAIN">;
36
+ export declare function createDeployment(options: {
37
+ deploy: DeployFunction;
38
+ state?: IDeploymentStateComponent;
39
+ }): IDeploymentComponent;
40
+ export type PublicationCheckOptions = {
41
+ /** Whether every byte reached the server, so it may still be publishing the entity. */
42
+ fullySent: boolean;
43
+ isPublished: () => Promise<boolean>;
44
+ delaysMs?: readonly number[];
45
+ };
46
+ /**
47
+ * Settles an upload that failed after a cancellation: resolves when the server published the entity anyway,
48
+ * otherwise rejects with a cancellation error. A fully sent upload is checked with backoff while the server
49
+ * may still be publishing it.
50
+ */
51
+ export declare function settleCancelledUpload(components: Pick<CliComponents, 'logger'>, uploadError: unknown, { fullySent, isPublished, delaysMs }: PublicationCheckOptions): Promise<void>;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PUBLICATION_CHECK_DELAYS_MS = void 0;
4
+ exports.deploymentCancelledError = deploymentCancelledError;
5
+ exports.cancelledAfterUndeployError = cancelledAfterUndeployError;
6
+ exports.cancelOutcomeUncertainError = cancelOutcomeUncertainError;
7
+ exports.createDeployment = createDeployment;
8
+ exports.settleCancelledUpload = settleCancelledUpload;
9
+ const error_1 = require("../../logic/error");
10
+ const state_1 = require("./state");
11
+ // Backoff between checks of whether a cancelled upload got published anyway: 30 s of delays, plus up to
12
+ // 5 s per check (6 checks), so the outcome of a cancel settles in about 60 s at worst.
13
+ exports.PUBLICATION_CHECK_DELAYS_MS = [1000, 2000, 4000, 8000, 15000];
14
+ function deploymentCancelledError() {
15
+ return new error_1.CliError('DEPLOY_CANCELLED', 'Deployment cancelled');
16
+ }
17
+ function cancelledAfterUndeployError() {
18
+ return new error_1.CliError('DEPLOY_CANCELLED_AFTER_UNDEPLOY', "Deployment cancelled after the world's previous scenes were removed. Deploy again to publish the scene.");
19
+ }
20
+ function cancelOutcomeUncertainError() {
21
+ return new error_1.CliError('DEPLOY_CANCEL_OUTCOME_UNCERTAIN', 'Deployment cancelled, but it could not be confirmed whether the server published it. ' +
22
+ 'Check the scene before deploying again.');
23
+ }
24
+ const CANCEL_ERRORS = new Set([
25
+ 'DEPLOY_CANCELLED',
26
+ 'DEPLOY_CANCELLED_AFTER_UNDEPLOY',
27
+ 'DEPLOY_CANCEL_OUTCOME_UNCERTAIN'
28
+ ]);
29
+ function createDeployment(options) {
30
+ const { deploy } = options;
31
+ const state = options.state ?? (0, state_1.createDeploymentState)();
32
+ const abortController = new AbortController();
33
+ let undeployStarted = false;
34
+ function canStart() {
35
+ return state.get().phase === 'awaiting-signature';
36
+ }
37
+ function cancelError(error) {
38
+ if (error instanceof error_1.CliError && error.name === 'DEPLOY_CANCEL_OUTCOME_UNCERTAIN')
39
+ return error;
40
+ if (undeployStarted)
41
+ return cancelledAfterUndeployError();
42
+ if (error instanceof error_1.CliError && CANCEL_ERRORS.has(error.name))
43
+ return error;
44
+ return deploymentCancelledError();
45
+ }
46
+ async function run(linkerResponse) {
47
+ if (!canStart())
48
+ throw new Error('The deployment already started');
49
+ state.setPhase('uploading');
50
+ const startUndeploy = () => {
51
+ if (abortController.signal.aborted)
52
+ throw deploymentCancelledError();
53
+ undeployStarted = true;
54
+ state.setPhase('undeploying');
55
+ };
56
+ try {
57
+ const result = await deploy(linkerResponse, { signal: abortController.signal, state, startUndeploy });
58
+ state.deployed(result);
59
+ return result;
60
+ }
61
+ catch (error) {
62
+ if (abortController.signal.aborted) {
63
+ const cancelled = cancelError(error);
64
+ state.cancelled(cancelled.name === 'DEPLOY_CANCELLED' ? undefined : { code: cancelled.name, message: cancelled.message });
65
+ throw cancelled;
66
+ }
67
+ state.failed({
68
+ code: error instanceof error_1.CliError ? error.name : 'DEPLOY_FAILED',
69
+ message: error?.message ?? String(error)
70
+ });
71
+ throw error;
72
+ }
73
+ }
74
+ function cancel() {
75
+ if (state.isFinal())
76
+ return 'final';
77
+ if (state.get().phase === 'undeploying')
78
+ return 'refused';
79
+ const beforeSignature = canStart();
80
+ state.requestCancel();
81
+ abortController.abort();
82
+ if (beforeSignature) {
83
+ state.cancelled();
84
+ return 'cancelled';
85
+ }
86
+ return 'cancelling';
87
+ }
88
+ return { state, canStart, run, cancel };
89
+ }
90
+ /**
91
+ * Settles an upload that failed after a cancellation: resolves when the server published the entity anyway,
92
+ * otherwise rejects with a cancellation error. A fully sent upload is checked with backoff while the server
93
+ * may still be publishing it.
94
+ */
95
+ async function settleCancelledUpload(components, uploadError, { fullySent, isPublished, delaysMs = exports.PUBLICATION_CHECK_DELAYS_MS }) {
96
+ const { logger } = components;
97
+ logger.warn(`Upload interrupted by the cancellation: ${uploadError?.message ?? String(uploadError)}`);
98
+ let answered = false;
99
+ for (let attempt = 0;; attempt++) {
100
+ try {
101
+ if (await isPublished()) {
102
+ logger.warn('The deployment was cancelled after the server received it, and it got published.');
103
+ return;
104
+ }
105
+ answered = true;
106
+ }
107
+ catch (e) {
108
+ logger.warn(`Could not check whether the deployment got published: ${e?.message ?? String(e)}`);
109
+ }
110
+ if ((answered && !fullySent) || attempt >= delaysMs.length)
111
+ break;
112
+ await new Promise((resolve) => setTimeout(resolve, delaysMs[attempt]));
113
+ }
114
+ if (!answered) {
115
+ const error = cancelOutcomeUncertainError();
116
+ logger.warn(error.message);
117
+ throw error;
118
+ }
119
+ logger.warn('Deployment cancelled.');
120
+ throw deploymentCancelledError();
121
+ }
122
+ //# sourceMappingURL=deployment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment.js","sourceRoot":"","sources":["../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E,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,EAAE,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QACjG,CAAC;QACD,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,OAAO,IAAI,QAAQ,CAAC,MAAM;YAAE,MAAK;QACjE,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACxE,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,2BAA2B,EAAE,CAAA;QAC3C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,MAAM,KAAK,CAAA;IACb,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;IACpC,MAAM,wBAAwB,EAAE,CAAA;AAClC,CAAC"}
@@ -7,6 +7,8 @@ interface Options {
7
7
  interface ProgrammaticDeployResult {
8
8
  finish: () => Promise<void>;
9
9
  stop: () => Promise<void>;
10
+ /** Required in the `X-Deploy-Token` header to cancel the deployment through `DELETE /api/deploy`. */
11
+ deployToken: string;
10
12
  }
11
13
  export declare const args: {
12
14
  '--dir': StringConstructor;
@@ -28,6 +30,7 @@ export declare const args: {
28
30
  '-p': string;
29
31
  '--programmatic': BooleanConstructor;
30
32
  '--multi-scene': BooleanConstructor;
33
+ '--deploy-token': StringConstructor;
31
34
  };
32
35
  export declare function help(options: Options): void;
33
36
  export declare function main(options: Options): Promise<ProgrammaticDeployResult | void>;
@@ -22,6 +22,9 @@ const workspace_validations_1 = require("../../logic/workspace-validations");
22
22
  const analytics_features_1 = require("./analytics-features");
23
23
  const config_1 = require("../../logic/config");
24
24
  const fetch_1 = require("../../logic/fetch");
25
+ const upload_1 = require("./upload");
26
+ const deployment_1 = require("./deployment");
27
+ const PUBLICATION_CHECK_TIMEOUT_MS = 5000;
25
28
  exports.args = (0, args_1.declareArgs)({
26
29
  '--dir': String,
27
30
  '--help': Boolean,
@@ -41,7 +44,8 @@ exports.args = (0, args_1.declareArgs)({
41
44
  '--port': Number,
42
45
  '-p': '--port',
43
46
  '--programmatic': Boolean,
44
- '--multi-scene': Boolean
47
+ '--multi-scene': Boolean,
48
+ '--deploy-token': String
45
49
  });
46
50
  function help(options) {
47
51
  options.components.logger.log(`
@@ -57,6 +61,18 @@ function help(options) {
57
61
  --skip-validations Skip permissions verifications on the client side when deploying content
58
62
  --programmatic Enable programmatic mode - returns a promise that resolves when deployment completes
59
63
  --multi-scene Deploy alongside existing scenes in a world (additive deploy, no deletion)
64
+ --deploy-token [token] Token required to cancel the deployment through the API (at least 16 characters).
65
+ Random per run by default
66
+
67
+ Deployment API (linker server):
68
+ POST /api/deploy Sign and start; with 'Prefer: respond-async' it answers 202 right away
69
+ GET /api/deploy Deployment state as JSON, or as server-sent events with 'Accept: text/event-stream'.
70
+ The stream ends after a final state: EventSource clients must close() it then,
71
+ or they reconnect
72
+ DELETE /api/deploy Cancel the deployment. Requires the 'X-Deploy-Token' header (403 otherwise); the
73
+ linker URL carries the token in its fragment ('#token='). Answers 409 while undeploying a world.
74
+ A cancel after the world's scenes were removed ends with the error code
75
+ DEPLOY_CANCELLED_AFTER_UNDEPLOY
60
76
 
61
77
  Example:
62
78
  - Deploy your scene:
@@ -78,6 +94,7 @@ async function main(options) {
78
94
  const multiScene = !!options.args['--multi-scene'];
79
95
  const autoYes = !!options.args['--yes'];
80
96
  const targetContent = options.args['--target-content'];
97
+ const deployToken = (0, utils_1.resolveDeployToken)(options.args['--deploy-token']);
81
98
  if (workspace.projects.length !== 1) {
82
99
  throw new error_1.CliError('DEPLOY_WORKSPACE_NOT_SUPPORTED', i18next_1.default.t('errors.deploy.workspace_not_supported'));
83
100
  }
@@ -158,11 +175,12 @@ async function main(options) {
158
175
  const messageToSign = entityId;
159
176
  const deleteScenesFromWorldPayload = needsDelete && worldName ? (0, utils_1.buildDeleteScenesFromWorldPayload)(worldName) : undefined;
160
177
  const awaitResponse = (0, future_1.default)();
178
+ const deployment = (0, deployment_1.createDeployment)({ deploy: deployEntity });
161
179
  const { program } = await (0, utils_1.getAddressAndSignature)(options.components, awaitResponse, messageToSign, sceneJson, files, !!options.args['--skip-validations'] || !!options.args['--target'] || !!options.args['--target-content'], {
162
180
  openBrowser,
163
181
  linkerPort,
164
182
  isHttps: !!options.args['--https']
165
- }, deployEntity, deleteScenesFromWorldPayload, targetContent, multiScene);
183
+ }, deployment, deployToken, deleteScenesFromWorldPayload, targetContent, multiScene);
166
184
  // Programmatic mode early return
167
185
  if (isProgrammatic) {
168
186
  return {
@@ -173,7 +191,8 @@ async function main(options) {
173
191
  },
174
192
  stop: async () => {
175
193
  void program?.stop();
176
- }
194
+ },
195
+ deployToken
177
196
  };
178
197
  }
179
198
  try {
@@ -183,12 +202,16 @@ async function main(options) {
183
202
  finally {
184
203
  void program?.stop();
185
204
  }
186
- async function deployEntity(linkerResponse) {
205
+ async function deployEntity(linkerResponse, { signal, state, startUndeploy }) {
187
206
  const { authChain, chainId } = linkerResponse;
207
+ const throwIfCancelled = () => {
208
+ if (signal.aborted)
209
+ throw (0, deployment_1.deploymentCancelledError)();
210
+ };
188
211
  if (isWorld && worldName && targetContent && linkerResponse.address) {
189
212
  options.components.logger.log(`[DEPLOY] Checking permissions for wallet ${linkerResponse.address}...`);
190
213
  try {
191
- const permissionCheck = await (0, utils_1.checkWorldDeploymentPermission)(options.components.logger, worldName, linkerResponse.address, targetContent, sceneJson.scene.parcels);
214
+ const permissionCheck = await (0, utils_1.checkWorldDeploymentPermission)(options.components.logger, worldName, linkerResponse.address, targetContent, sceneJson.scene.parcels, signal);
192
215
  if (!permissionCheck.allowed) {
193
216
  const deniedMsg = permissionCheck.deniedParcels?.length
194
217
  ? `\nYou don't have permission for parcels: ${permissionCheck.deniedParcels.join(', ')}.`
@@ -199,20 +222,23 @@ async function main(options) {
199
222
  options.components.logger.log(`[DEPLOY] Permissions verified.`);
200
223
  }
201
224
  catch (e) {
202
- if (e instanceof error_1.CliError)
225
+ if (e instanceof error_1.CliError || signal.aborted)
203
226
  throw e;
204
227
  options.components.logger.warn(`Could not verify deployment permissions: ${e.message}`);
205
228
  }
206
229
  }
207
230
  // Uploading data
208
- const { client, url } = await (0, utils_1.getCatalyst)(chainId, options.args['--target'], options.args['--target-content']);
231
+ throwIfCancelled();
232
+ const { client, url } = await (0, fetch_1.withDeadline)(() => (0, utils_1.getCatalyst)(chainId, options.args['--target'], options.args['--target-content']), { signal });
233
+ throwIfCancelled();
209
234
  if (needsDelete && worldName && !linkerResponse.deleteSignature) {
210
235
  throw new error_1.CliError('DEPLOY_DELETE_FAILED', `Cannot delete existing scenes from "${worldName}": missing signature for deleting the scenes.`);
211
236
  }
212
237
  if (needsDelete && worldName && linkerResponse.deleteSignature) {
238
+ startUndeploy();
213
239
  options.components.logger.info(`[DEPLOY] deleting scenes for "${worldName}"`);
214
240
  try {
215
- const deleteResponse = await (0, utils_1.deleteWorldScenes)(options.components, worldName, linkerResponse.deleteSignature, targetContent);
241
+ const deleteResponse = await (0, utils_1.deleteWorldScenes)(options.components, worldName, linkerResponse.deleteSignature, targetContent, signal);
216
242
  if (deleteResponse.ok) {
217
243
  await (0, fetch_1.drainResponse)(deleteResponse);
218
244
  options.components.logger.info(`[DEPLOY] existing scenes for "${worldName} deleted successfully"`);
@@ -224,12 +250,14 @@ async function main(options) {
224
250
  }
225
251
  }
226
252
  catch (e) {
227
- if (e instanceof error_1.CliError)
253
+ if (e instanceof error_1.CliError || signal.aborted)
228
254
  throw e;
229
255
  throw new error_1.CliError('DEPLOY_DELETE_FAILED', `Error deleting existing scenes from "${worldName}": ${e.message}\n` +
230
256
  `Hint: Use --multi-scene to deploy alongside existing scenes without deleting them.`);
231
257
  }
232
258
  }
259
+ throwIfCancelled();
260
+ state.setPhase('uploading');
233
261
  (0, beautiful_logs_1.printProgressInfo)(options.components.logger, `Uploading data to: ${url}...`);
234
262
  const deployData = { entityId, files: entityFiles, authChain };
235
263
  const position = sceneJson.scene.base;
@@ -237,40 +265,48 @@ async function main(options) {
237
265
  const worldRealm = isWorld ? `&realm=${sceneJson.worldConfiguration?.name}` : '';
238
266
  const domain = chainId === schemas_1.ChainId.ETHEREUM_MAINNET ? 'https://play.decentraland.org' : 'https://play.decentraland.zone';
239
267
  const sceneUrl = `${domain}/?NETWORK=${network}&position=${position}${worldRealm}`;
268
+ let responseData;
240
269
  try {
241
- const response = (await client.deploy(deployData, {
242
- timeout: 600000
243
- }));
244
- let responseData;
245
- if (response.status !== 200) {
246
- responseData = await response.text();
247
- throw new Error(responseData);
248
- }
249
- responseData = (await response.json());
250
- if (responseData.message) {
251
- (0, beautiful_logs_1.printProgressInfo)(options.components.logger, responseData.message);
270
+ responseData = await (0, upload_1.uploadDeployment)(options.components, client, deployData, { signal, progress: state });
271
+ }
272
+ catch (e) {
273
+ if (signal.aborted) {
274
+ await (0, deployment_1.settleCancelledUpload)(options.components, e, {
275
+ fullySent: state.get().upload?.stage === 'processing',
276
+ isPublished: () => (0, utils_1.isEntityPublished)(client, entityId, {
277
+ world: isWorld && worldName && targetContent ? { name: worldName, targetContent } : undefined,
278
+ timeoutMs: PUBLICATION_CHECK_TIMEOUT_MS
279
+ })
280
+ });
281
+ responseData = {};
252
282
  }
253
- (0, beautiful_logs_1.printSuccess)(options.components.logger, 'Content uploaded successfully', sceneUrl);
254
- options.components.analytics.track('Scene deploy success', {
255
- ...trackProps,
256
- sceneId: entityId,
257
- targetContentServer: url,
258
- worldName: sceneJson.worldConfiguration?.name,
259
- isPortableExperience: !!sceneJson.isPortableExperience,
260
- dependencies,
261
- dependencyVersions,
262
- serverlessMultiplayer: trackFeatures.serverlessMultiplayer
263
- });
264
- if (!isWorld) {
265
- options.components.logger.info('You can close the terminal now');
283
+ else {
284
+ options.components.logger.error('Could not upload content:');
285
+ options.components.logger.error(e.message);
286
+ options.components.analytics.track('Scene deploy failure', { ...trackProps, error: e.message ?? '' });
287
+ if (e instanceof error_1.CliError)
288
+ throw e;
289
+ throw new error_1.CliError('DEPLOY_UPLOAD_FAILED', i18next_1.default.t('errors.deploy.failed_to_upload', { error: e.message }), e.stack);
266
290
  }
267
291
  }
268
- catch (e) {
269
- options.components.logger.error('Could not upload content:');
270
- options.components.logger.error(e.message);
271
- options.components.analytics.track('Scene deploy failure', { ...trackProps, error: e.message ?? '' });
272
- throw new error_1.CliError('DEPLOY_UPLOAD_FAILED', i18next_1.default.t('errors.deploy.failed_to_upload', { error: e.message }), e.stack);
292
+ if (responseData.message) {
293
+ (0, beautiful_logs_1.printProgressInfo)(options.components.logger, responseData.message);
294
+ }
295
+ (0, beautiful_logs_1.printSuccess)(options.components.logger, 'Content uploaded successfully', sceneUrl);
296
+ options.components.analytics.track('Scene deploy success', {
297
+ ...trackProps,
298
+ sceneId: entityId,
299
+ targetContentServer: url,
300
+ worldName: sceneJson.worldConfiguration?.name,
301
+ isPortableExperience: !!sceneJson.isPortableExperience,
302
+ dependencies,
303
+ dependencyVersions,
304
+ serverlessMultiplayer: trackFeatures.serverlessMultiplayer
305
+ });
306
+ if (!isWorld) {
307
+ options.components.logger.info('You can close the terminal now');
273
308
  }
309
+ return { entityId, ...(responseData.message ? { message: responseData.message } : {}) };
274
310
  }
275
311
  }
276
312
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/deploy/index.ts"],"names":[],"mappings":";;;;;;AAoEA,oBAuBC;AAED,oBA+RC;AA5XD,+BAA8B;AAC9B,0CAAkD;AAClD,6DAAuD;AACvD,gEAAuC;AACvC,sDAA6B;AAG7B,qEAA8G;AAC9G,2CAA8C;AAC9C,6CAA4C;AAC5C,+DAA4E;AAC5E,6DAA8E;AAG9E,mCAUgB;AAChB,oCAAqC;AACrC,6EAAqE;AAErE,6DAAwD;AACxD,+CAA+D;AAC/D,6CAAiD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'@well-known-components/http-server';
2
+ import { CliComponents } from '../../components';
3
+ import { LinkerResponse } from '../../linker-dapp/routes';
4
+ import { IDeploymentComponent } from './deployment';
5
+ export declare const DEPLOY_RESOURCE_PATH = "/api/deploy";
6
+ export declare const SSE_HEARTBEAT_INTERVAL_MS = 15000;
7
+ export declare const FOLLOWED_SETTLE_DELAY_MS = 2000;
8
+ export declare const SETTLE_DELAY_MS = 100;
9
+ export declare const DEPLOY_TOKEN_HEADER = "X-Deploy-Token";
10
+ export type DeployRoutesOptions = {
11
+ deployment: IDeploymentComponent;
12
+ /** Required in the `X-Deploy-Token` header to cancel. Never exposed through the API. */
13
+ deployToken: string;
14
+ isWorld: boolean;
15
+ /** Ends the CLI run successfully. */
16
+ resolve: () => void;
17
+ /** Ends the CLI run with an error. */
18
+ reject: (error: Error) => void;
19
+ onLinkerResponse?: (linkerResponse: LinkerResponse) => void;
20
+ heartbeatIntervalMs?: number;
21
+ followedSettleDelayMs?: number;
22
+ };
23
+ /**
24
+ * Exposes the deployment of this CLI run as a resource: POST starts it with the signed payload, GET
25
+ * follows it (JSON or server-sent events) and DELETE cancels it.
26
+ */
27
+ export declare function setDeployResourceRoutes(router: Router<object>, components: Pick<CliComponents, 'logger'>, options: DeployRoutesOptions): Router<object>;
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEPLOY_TOKEN_HEADER = exports.SETTLE_DELAY_MS = exports.FOLLOWED_SETTLE_DELAY_MS = exports.SSE_HEARTBEAT_INTERVAL_MS = exports.DEPLOY_RESOURCE_PATH = void 0;
4
+ exports.setDeployResourceRoutes = setDeployResourceRoutes;
5
+ const crypto_1 = require("crypto");
6
+ const stream_1 = require("stream");
7
+ const deployment_1 = require("./deployment");
8
+ exports.DEPLOY_RESOURCE_PATH = '/api/deploy';
9
+ exports.SSE_HEARTBEAT_INTERVAL_MS = 15000;
10
+ // Keeps the final state readable for clients following the deployment before the CLI exits.
11
+ exports.FOLLOWED_SETTLE_DELAY_MS = 2000;
12
+ exports.SETTLE_DELAY_MS = 100;
13
+ exports.DEPLOY_TOKEN_HEADER = 'X-Deploy-Token';
14
+ function prefersAsync(request) {
15
+ const prefer = request.headers.get('prefer') ?? '';
16
+ return prefer.split(',').some((preference) => preference.split(/[;=]/)[0].trim().toLowerCase() === 'respond-async');
17
+ }
18
+ function acceptsEventStream(request) {
19
+ return (request.headers.get('accept') ?? '').toLowerCase().includes('text/event-stream');
20
+ }
21
+ function hasDeployToken(request, deployToken) {
22
+ const provided = Buffer.from(request.headers.get(exports.DEPLOY_TOKEN_HEADER) ?? '');
23
+ const expected = Buffer.from(deployToken);
24
+ return provided.length === expected.length && (0, crypto_1.timingSafeEqual)(provided, expected);
25
+ }
26
+ function stateEvent(state) {
27
+ return `event: state\ndata: ${JSON.stringify(state)}\n\n`;
28
+ }
29
+ /**
30
+ * Exposes the deployment of this CLI run as a resource: POST starts it with the signed payload, GET
31
+ * follows it (JSON or server-sent events) and DELETE cancels it.
32
+ */
33
+ function setDeployResourceRoutes(router, components, options) {
34
+ const { logger } = components;
35
+ const { deployment, deployToken, isWorld, resolve, reject, onLinkerResponse } = options;
36
+ const heartbeatIntervalMs = options.heartbeatIntervalMs ?? exports.SSE_HEARTBEAT_INTERVAL_MS;
37
+ const followedSettleDelayMs = options.followedSettleDelayMs ?? exports.FOLLOWED_SETTLE_DELAY_MS;
38
+ let followed = false;
39
+ const settle = (end) => {
40
+ setTimeout(end, followed ? followedSettleDelayMs : exports.SETTLE_DELAY_MS);
41
+ };
42
+ const conflict = () => ({ status: 409, body: deployment.state.get() });
43
+ router.post(exports.DEPLOY_RESOURCE_PATH, async (ctx) => {
44
+ const respondAsync = prefersAsync(ctx.request);
45
+ let value;
46
+ try {
47
+ value = (await ctx.request.json());
48
+ }
49
+ catch {
50
+ return { status: 400, body: { message: 'Invalid payload: the body must be JSON' } };
51
+ }
52
+ if (!deployment.canStart())
53
+ return conflict();
54
+ if (!value || !value.address || !value.authChain || !value.chainId) {
55
+ const errorMessage = `Invalid payload: ${Object.keys(value ?? {}).join(' - ')}`;
56
+ logger.error(errorMessage);
57
+ if (!respondAsync)
58
+ settle(resolve);
59
+ return { status: 400, body: { message: errorMessage } };
60
+ }
61
+ onLinkerResponse?.(value);
62
+ const running = deployment.run(value);
63
+ if (respondAsync) {
64
+ followed = true;
65
+ running.then(() => isWorld && settle(resolve), (error) => settle(() => reject(error)));
66
+ return {
67
+ status: 202,
68
+ headers: { Location: exports.DEPLOY_RESOURCE_PATH, 'Preference-Applied': 'respond-async' },
69
+ body: deployment.state.get()
70
+ };
71
+ }
72
+ try {
73
+ await running;
74
+ if (isWorld)
75
+ settle(resolve);
76
+ return {};
77
+ }
78
+ catch (e) {
79
+ settle(() => reject(e));
80
+ return { status: 400, body: { message: e.message } };
81
+ }
82
+ });
83
+ router.get(exports.DEPLOY_RESOURCE_PATH, async (ctx) => {
84
+ followed = true;
85
+ if (!acceptsEventStream(ctx.request)) {
86
+ return { status: 200, body: deployment.state.get() };
87
+ }
88
+ const stream = new stream_1.PassThrough();
89
+ let unsubscribe = () => { };
90
+ let heartbeat;
91
+ const close = () => {
92
+ unsubscribe();
93
+ if (heartbeat)
94
+ clearInterval(heartbeat);
95
+ if (!stream.writableEnded)
96
+ stream.end();
97
+ };
98
+ const send = (state) => {
99
+ if (stream.destroyed || stream.writableEnded)
100
+ return;
101
+ stream.write(stateEvent(state));
102
+ if (state.phase === 'deployed' || state.phase === 'failed' || state.phase === 'cancelled')
103
+ close();
104
+ };
105
+ stream.on('close', close);
106
+ send(deployment.state.get());
107
+ if (!stream.writableEnded) {
108
+ unsubscribe = deployment.state.subscribe(send);
109
+ heartbeat = setInterval(() => {
110
+ if (!stream.destroyed && !stream.writableEnded)
111
+ stream.write(': ping\n\n');
112
+ }, heartbeatIntervalMs);
113
+ heartbeat.unref?.();
114
+ }
115
+ return {
116
+ status: 200,
117
+ headers: {
118
+ 'Content-Type': 'text/event-stream',
119
+ 'Cache-Control': 'no-cache',
120
+ Connection: 'keep-alive'
121
+ },
122
+ body: stream
123
+ };
124
+ });
125
+ router.delete(exports.DEPLOY_RESOURCE_PATH, async (ctx) => {
126
+ if (!hasDeployToken(ctx.request, deployToken)) {
127
+ return { status: 403, body: { message: 'Invalid or missing deploy token' } };
128
+ }
129
+ followed = true;
130
+ const outcome = deployment.cancel();
131
+ if (outcome === 'final' || outcome === 'refused')
132
+ return conflict();
133
+ if (outcome === 'cancelled') {
134
+ logger.warn('Deployment cancelled.');
135
+ settle(() => reject((0, deployment_1.deploymentCancelledError)()));
136
+ }
137
+ else {
138
+ logger.warn('Cancelling the deployment...');
139
+ }
140
+ return { status: 202, body: deployment.state.get() };
141
+ });
142
+ return router;
143
+ }
144
+ //# sourceMappingURL=routes.js.map