@dcl/sdk-commands 7.3.13-6076348032.commit-5985bd0 → 7.3.13-6097928179.commit-904172b

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createQuestByPrompting = exports.validateCreateQuest = exports.urlRegex = exports.executeSubcommand = void 0;
7
+ const fp_future_1 = __importDefault(require("fp-future"));
8
+ const crypto_1 = require("@dcl/crypto/dist/crypto");
9
+ const eth_connect_1 = require("eth-connect");
10
+ const crypto_2 = require("@dcl/crypto");
11
+ const prompts_1 = __importDefault(require("prompts"));
12
+ const account_1 = require("../../logic/account");
13
+ const api_1 = require("../../linker-dapp/api");
14
+ const routes_1 = require("../../linker-dapp/routes");
15
+ const error_1 = require("../../logic/error");
16
+ async function getAddressAndSignature(components, linkerOpts, awaitResponse, info, callback) {
17
+ if (process.env.DCL_PRIVATE_KEY) {
18
+ const wallet = (0, account_1.createWallet)(process.env.DCL_PRIVATE_KEY);
19
+ const signature = (0, crypto_1.ethSign)((0, eth_connect_1.hexToBytes)(wallet.privateKey), info.messageToSign);
20
+ const linkerResponse = { signature, address: wallet.address };
21
+ await callback(linkerResponse);
22
+ awaitResponse.resolve();
23
+ return {};
24
+ }
25
+ const { router } = (0, routes_1.setRoutes)(components, info, '/quests');
26
+ const { logger } = components;
27
+ // We need to wait so the linker-dapp can receive the response and show a nice message.
28
+ const resolveLinkerPromise = () => setTimeout(() => awaitResponse.resolve(), 100);
29
+ router.post('/api/quests', async (ctx) => {
30
+ const value = (await ctx.request.json());
31
+ if (!value.address || !value.signature) {
32
+ const errorMessage = `Invalid payload: ${Object.keys(value).join(' - ')}`;
33
+ logger.error(errorMessage);
34
+ resolveLinkerPromise();
35
+ return { status: 400, body: { message: errorMessage } };
36
+ }
37
+ try {
38
+ await callback(value);
39
+ resolveLinkerPromise();
40
+ return {};
41
+ }
42
+ catch (e) {
43
+ resolveLinkerPromise();
44
+ return { status: 400, body: { message: e.message } };
45
+ }
46
+ });
47
+ const { program } = await (0, api_1.runLinkerApp)(components, router, { ...linkerOpts, uri: `/quests` });
48
+ return { program };
49
+ }
50
+ async function executeSubcommand(components, linkerOps, commandData, commandCallback) {
51
+ const awaitResponse = (0, fp_future_1.default)();
52
+ const timestamp = String(Date.now());
53
+ const pathname = new URL(commandData.url).pathname;
54
+ const payload = [commandData.method, pathname, timestamp, JSON.stringify(commandData.metadata)]
55
+ .join(':')
56
+ .toLowerCase();
57
+ const { program } = await getAddressAndSignature(components, linkerOps, awaitResponse, { messageToSign: payload, extraData: commandData.extraData, actionType: commandData.actionType }, async (linkerResponse) => {
58
+ await commandCallback(createAuthchainHeaders(linkerResponse.address, linkerResponse.signature, payload, timestamp, JSON.stringify(commandData.metadata)));
59
+ });
60
+ try {
61
+ await awaitResponse;
62
+ }
63
+ finally {
64
+ void program?.stop();
65
+ }
66
+ }
67
+ exports.executeSubcommand = executeSubcommand;
68
+ exports.urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/gm;
69
+ function validateStepsAndConnections(quest, _components) {
70
+ if (!quest.definition) {
71
+ throw new error_1.CliError('> Quest must have a definition');
72
+ }
73
+ if (!quest.definition.connections?.length || !Array.isArray(quest.definition.connections)) {
74
+ throw new error_1.CliError("> Quest's definition must have its connections defined");
75
+ }
76
+ if (!quest.definition.connections.every((connection) => connection.stepFrom?.length && connection.stepTo?.length)) {
77
+ throw new error_1.CliError("> Quest's definition must have valid connections");
78
+ }
79
+ if (!quest.definition.steps?.length || !Array.isArray(quest.definition.steps)) {
80
+ throw new error_1.CliError("> Quest's definition must have its steps defined");
81
+ }
82
+ if (!quest.definition.steps.every((step) => step.tasks?.length &&
83
+ Array.isArray(step.tasks) &&
84
+ step.tasks?.every((task) => task.actionItems?.length &&
85
+ Array.isArray(task.actionItems) &&
86
+ task.actionItems?.every((at) => (at.type === 'CUSTOM' || at.type === 'LOCATION' || at.type === 'EMOTE' || at.type === 'JUMP') &&
87
+ Object.keys(at.parameters || {}).length >= 1) &&
88
+ task.description?.length >= 0 &&
89
+ task.id?.length) &&
90
+ step.id?.length &&
91
+ step.description?.length >= 0)) {
92
+ throw new error_1.CliError("> Quest definition's steps must be valid");
93
+ }
94
+ return true;
95
+ }
96
+ function validateCreateQuest(quest, components) {
97
+ if (!(quest.name.length >= 5)) {
98
+ throw new error_1.CliError("> Quest's name must be at least 5 chars");
99
+ }
100
+ if (!(quest.description.length >= 5)) {
101
+ throw new error_1.CliError("> Quest's description must be at least 5 chars");
102
+ }
103
+ if (!quest.imageUrl?.length || !new RegExp(exports.urlRegex).test(quest.imageUrl)) {
104
+ throw new error_1.CliError("> Quest's image URL must be a valid URL");
105
+ }
106
+ validateStepsAndConnections(quest, components);
107
+ if (quest.reward) {
108
+ if (!quest.reward.hook) {
109
+ throw new error_1.CliError("> Quest's reward must have its webhook defined");
110
+ }
111
+ else {
112
+ if (!quest.reward.hook.webhookUrl ||
113
+ !quest.reward.hook.webhookUrl?.length ||
114
+ !new RegExp(exports.urlRegex).test(quest.reward.hook.webhookUrl)) {
115
+ throw new error_1.CliError("> Quest's reward must have a valid Webhook URL");
116
+ }
117
+ }
118
+ if (!quest.reward.items || !quest.reward.items?.length || !Array.isArray(quest.reward.items)) {
119
+ throw new error_1.CliError("> Quest's reward must have its items defined");
120
+ }
121
+ if (!quest.reward.items.every((item) => new RegExp(exports.urlRegex).test(item.imageLink || '') && item.name?.length >= 3)) {
122
+ throw new error_1.CliError("> Quest's reward must have valid items");
123
+ }
124
+ }
125
+ return true;
126
+ }
127
+ exports.validateCreateQuest = validateCreateQuest;
128
+ const createQuestByPrompting = async (components) => {
129
+ let cancelled = false;
130
+ const onCancel = {
131
+ onCancel: () => {
132
+ cancelled = true;
133
+ }
134
+ };
135
+ const { questName } = await (0, prompts_1.default)({
136
+ type: 'text',
137
+ name: 'questName',
138
+ message: 'How do you want to name your Quest?',
139
+ validate: (questName) => questName.length >= 5
140
+ }, onCancel);
141
+ if (cancelled)
142
+ return null;
143
+ const { description } = await (0, prompts_1.default)({
144
+ type: 'text',
145
+ name: 'description',
146
+ message: 'Give a description to your Quest',
147
+ validate: (description) => description.length >= 5
148
+ }, onCancel);
149
+ if (cancelled)
150
+ return null;
151
+ const { imageUrl } = await (0, prompts_1.default)({
152
+ type: 'text',
153
+ name: 'imageUrl',
154
+ message: 'Image URL to display your Quest',
155
+ validate: (imageUrl) => new RegExp(exports.urlRegex).test(imageUrl)
156
+ }, onCancel);
157
+ let { definition } = await (0, prompts_1.default)({
158
+ type: 'text',
159
+ name: 'definition',
160
+ message: 'Paste the Defintion (Steps & Connections) of your Quest',
161
+ validate: (def) => {
162
+ try {
163
+ const input = JSON.parse(def);
164
+ if (validateStepsAndConnections({ definition: input }, { logger: components.logger })) {
165
+ return true;
166
+ }
167
+ return false;
168
+ }
169
+ catch (error) {
170
+ return false;
171
+ }
172
+ }
173
+ }, onCancel);
174
+ definition = JSON.parse(definition);
175
+ if (cancelled)
176
+ return null;
177
+ const { withReward } = await (0, prompts_1.default)({
178
+ type: 'confirm',
179
+ name: 'withReward',
180
+ message: 'Do you want to give rewards to the players?'
181
+ }, onCancel);
182
+ if (cancelled)
183
+ return null;
184
+ if (!withReward) {
185
+ return { name: questName, description, imageUrl, definition };
186
+ }
187
+ const { webhookUrl } = await (0, prompts_1.default)({
188
+ type: 'text',
189
+ name: 'webhookUrl',
190
+ message: 'Insert the Webhook URL of your Rewards Server',
191
+ validate: (webhookUrl) => new RegExp(exports.urlRegex).test(webhookUrl)
192
+ }, onCancel);
193
+ if (cancelled)
194
+ return null;
195
+ const { withRequestBody } = await (0, prompts_1.default)({
196
+ type: 'confirm',
197
+ name: 'withRequestBody',
198
+ message: 'Do you want to send a request body to your webhook?'
199
+ }, onCancel);
200
+ if (cancelled)
201
+ return null;
202
+ let reqBody = {};
203
+ if (withRequestBody) {
204
+ const { requestBody } = await (0, prompts_1.default)({
205
+ type: 'text',
206
+ name: 'requestBody',
207
+ message: 'Insert the request body to send within POST request to your webhook',
208
+ validate: (body) => {
209
+ try {
210
+ JSON.parse(body);
211
+ return true;
212
+ }
213
+ catch (error) {
214
+ return false;
215
+ }
216
+ }
217
+ }, onCancel);
218
+ if (cancelled)
219
+ return null;
220
+ reqBody = JSON.parse(requestBody);
221
+ }
222
+ const { rewardItemsNumber } = await (0, prompts_1.default)({
223
+ type: 'number',
224
+ name: 'rewardItemsNumber',
225
+ message: 'How many items the user will receive?',
226
+ validate: (num) => num > 0
227
+ }, onCancel);
228
+ if (cancelled)
229
+ return null;
230
+ const items = [];
231
+ for (let i = 1; i < rewardItemsNumber + 1; i++) {
232
+ const { itemName } = await (0, prompts_1.default)({
233
+ type: 'text',
234
+ name: 'itemName',
235
+ message: `What is the name of your ${i} reward?`,
236
+ validate: (name) => name.length >= 3
237
+ }, onCancel);
238
+ if (cancelled)
239
+ return null;
240
+ const { itemImage } = await (0, prompts_1.default)({
241
+ type: 'text',
242
+ name: 'itemImage',
243
+ message: `Provide an image link for your ${i} reward`,
244
+ validate: (image) => new RegExp(exports.urlRegex).test(image)
245
+ }, onCancel);
246
+ if (cancelled)
247
+ return null;
248
+ items.push({ name: itemName, imageLink: itemImage });
249
+ }
250
+ return {
251
+ name: questName,
252
+ description,
253
+ imageUrl,
254
+ definition,
255
+ reward: {
256
+ hook: {
257
+ webhookUrl: webhookUrl,
258
+ requestBody: Object.keys(reqBody).length >= 1 ? reqBody : undefined
259
+ },
260
+ items
261
+ }
262
+ };
263
+ };
264
+ exports.createQuestByPrompting = createQuestByPrompting;
265
+ const AUTH_CHAIN_HEADER_PREFIX = 'x-identity-auth-chain-';
266
+ const AUTH_TIMESTAMP_HEADER = 'x-identity-timestamp';
267
+ const AUTH_METADATA_HEADER = 'x-identity-metadata';
268
+ function createAuthchainHeaders(address, signature, payload, timestamp, metadata) {
269
+ const authchain = crypto_2.Authenticator.createSimpleAuthChain(payload, address, signature);
270
+ const headers = {};
271
+ authchain.forEach((link, i) => {
272
+ headers[AUTH_CHAIN_HEADER_PREFIX + i] = JSON.stringify(link);
273
+ });
274
+ headers[AUTH_TIMESTAMP_HEADER] = timestamp;
275
+ headers[AUTH_METADATA_HEADER] = metadata;
276
+ return headers;
277
+ }
278
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/commands/quests/utils.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA2C;AAC3C,oDAAiD;AACjD,6CAAwC;AAExC,wCAA2C;AAC3C,sDAA6B;AAI7B,iDAAkD;AAClD,+CAAuF;AACvF,qDAAoD;AACpD,6CAA4C;AAE5C,KAAK,UAAU,sBAAsB,CACnC,UAAyB,EACzB,UAA0C,EAC1C,aAA4B,EAC5B,IAIC,EACD,QAAsD;IAEtD,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QACxD,MAAM,SAAS,GAAG,IAAA,gBAAO,EAAC,IAAA,wBAAU,EAAC,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;QAC5E,MAAM,cAAc,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7D,MAAM,QAAQ,CAAC,cAAc,CAAC,CAAA;QAC9B,aAAa,CAAC,OAAO,EAAE,CAAA;QACvB,OAAO,EAAE,CAAA;KACV;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAS,EAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAE7B,uFAAuF;IAC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AE;gBACJ,UAAU,EAAE,UAAU;gBACtB,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;aACpE;YACD,KAAK;SACN;KACF,CAAA;AACH,CAAC,CAAA;AAxLY,QAAA,sBAAsB,0BAwLlC;AAED,MAAM,wBAAwB,GAAG,wBAAwB,CAAA;AACzD,MAAM,qBAAqB,GAAG,sBAAsB,CAAA;AACpD,MAAM,oBAAoB,GAAG,qBAAqB,CAAA;AAElD,SAAS,sBAAsB,CAC7B,OAAe,EACf,SAAiB,EACjB,OAAe,EACf,SAAiB,EACjB,QAAgB;IAEhB,MAAM,SAAS,GAAG,sBAAa,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAClF,MAAM,OAAO,GAA2B,EAAE,CAAA;IAC1C,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QAC5B,OAAO,CAAC,wBAAwB,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,qBAAqB,CAAC,GAAG,SAAS,CAAA;IAC1C,OAAO,CAAC,oBAAoB,CAAC,GAAG,QAAQ,CAAA;IAExC,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Router } from '@well-known-components/http-server';
2
+ import { Lifecycle } from '@well-known-components/interfaces';
3
+ import { ChainId } from '@dcl/schemas';
4
+ import { CliComponents } from '../components';
5
+ export interface LinkerdAppOptions {
6
+ openBrowser: boolean;
7
+ linkerPort?: number;
8
+ isHttps: boolean;
9
+ uri: string;
10
+ }
11
+ export interface LinkerResponse {
12
+ address: string;
13
+ signature: string;
14
+ chainId?: ChainId;
15
+ }
16
+ export declare function runLinkerApp(cliComponents: Pick<CliComponents, 'fs' | 'logger' | 'fetch' | 'config'>, router: Router<object>, { isHttps, openBrowser, uri, linkerPort }: LinkerdAppOptions): Promise<{
17
+ program: Lifecycle.ComponentBasedProgram<{
18
+ config: import("@well-known-components/interfaces").IConfigComponent;
19
+ logs: import("@well-known-components/interfaces").ILoggerComponent;
20
+ server: import("@well-known-components/http-server").FullHttpServerComponent<object>;
21
+ fs: import("../components/fs").IFileSystemComponent;
22
+ fetch: import("../components/fetch").IFetchComponent;
23
+ logger: import("@well-known-components/interfaces").ILoggerComponent.ILogger;
24
+ }>;
25
+ }>;
26
+ export declare function getContentType(type: string): "text/css" | "application/js" | "text/plain";
@@ -3,24 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.runLinkerApp = void 0;
6
+ exports.getContentType = exports.runLinkerApp = void 0;
7
7
  const http_server_1 = require("@well-known-components/http-server");
8
8
  const interfaces_1 = require("@well-known-components/interfaces");
9
9
  const env_config_provider_1 = require("@well-known-components/env-config-provider");
10
10
  const logger_1 = require("@well-known-components/logger");
11
11
  const path_1 = require("path");
12
- const querystring_1 = __importDefault(require("querystring"));
13
12
  const open_1 = __importDefault(require("open"));
14
- const get_free_port_1 = require("../../../logic/get-free-port");
15
- const routes_1 = require("./routes");
16
- const config_1 = require("../../../logic/config");
17
- const utils_1 = require("../utils");
18
- async function runLinkerApp(cliComponents, awaitResponse, scene, files, port, rootCID, { isHttps, skipValidations, openBrowser }, deployCallback) {
19
- const resolvedPort = await (0, get_free_port_1.getPort)(port);
20
- const sceneInfo = await getSceneInfo(cliComponents, scene, rootCID, skipValidations);
13
+ const get_free_port_1 = require("../logic/get-free-port");
14
+ async function runLinkerApp(cliComponents, router, { isHttps, openBrowser, uri, linkerPort }) {
15
+ const resolvedPort = await (0, get_free_port_1.getPort)(linkerPort);
21
16
  const protocol = isHttps ? 'https' : 'http';
22
- const queryParams = querystring_1.default.stringify(sceneInfo);
23
- const url = `${protocol}://localhost:${resolvedPort}`;
17
+ const url = `${protocol}://localhost:${resolvedPort}${uri}`;
24
18
  const program = await interfaces_1.Lifecycle.run({
25
19
  async initComponents() {
26
20
  const config = (0, env_config_provider_1.createRecordConfigComponent)({
@@ -35,49 +29,44 @@ async function runLinkerApp(cliComponents, awaitResponse, scene, files, port, ro
35
29
  },
36
30
  async main(program) {
37
31
  const { components, startComponents } = program;
38
- const { router } = (0, routes_1.setRoutes)(components, awaitResponse, files, sceneInfo, deployCallback);
39
32
  components.server.setContext(components);
40
33
  components.server.use(router.allowedMethods());
41
34
  components.server.use(router.middleware());
42
35
  await startComponents();
43
36
  if (openBrowser)
44
- await browse(components, url, queryParams);
37
+ await browse(components, url);
45
38
  }
46
39
  });
47
40
  return { program };
48
41
  }
49
42
  exports.runLinkerApp = runLinkerApp;
50
- async function browse({ logger }, url, params) {
43
+ async function browse({ logger }, url) {
51
44
  logger.info('You need to sign the content before the deployment:');
52
45
  setTimeout(async () => {
53
46
  try {
54
- await (0, open_1.default)(`${url}?${params}`);
47
+ await (0, open_1.default)(`${url}`);
55
48
  }
56
49
  catch (e) {
57
- logger.error(`Unable to open browser automatically. Please manually navigate to:\n ${url}?${params}`);
50
+ logger.error(`Unable to open browser automatically. Please manually navigate to:\n ${url}`);
58
51
  }
59
52
  }, 5000);
60
- logger.info(`Signing app ready at ${url}?${params}`);
53
+ logger.info(`Signing app ready at ${url}`);
61
54
  }
62
55
  async function getCredentials({ fs }) {
63
56
  const privateKey = await fs.readFile((0, path_1.resolve)(__dirname, '../../../certs/localhost.key'), 'utf-8');
64
57
  const certificate = await fs.readFile((0, path_1.resolve)(__dirname, '../../../certs/localhost.crt'), 'utf-8');
65
58
  return { key: privateKey, cert: certificate };
66
59
  }
67
- async function getSceneInfo(components, scene, rootCID, skipValidations) {
68
- const { scene: { parcels, base }, display, isPortableExperience } = scene;
69
- return {
70
- baseParcel: base,
71
- parcels,
72
- rootCID,
73
- landRegistry: await (0, config_1.getLandRegistry)(components),
74
- estateRegistry: await (0, config_1.getEstateRegistry)(components),
75
- debug: !!process.env.DEBUG,
76
- title: display?.title,
77
- description: display?.description,
78
- skipValidations,
79
- isPortableExperience: !!isPortableExperience,
80
- isWorld: (0, utils_1.sceneHasWorldCfg)(scene)
81
- };
60
+ function getContentType(type) {
61
+ switch (type) {
62
+ case 'css':
63
+ return 'text/css';
64
+ case 'js':
65
+ return 'application/js';
66
+ case 'media':
67
+ default:
68
+ return 'text/plain';
69
+ }
82
70
  }
71
+ exports.getContentType = getContentType;
83
72
  //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/linker-dapp/api.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAkF;AAClF,kEAA6D;AAC7D,oFAAwF;AACxF,0DAAyE;AACzE,+BAA8B;AAE9B,gDAAuB;AAEvB,0DAAgD;AAezC,KAAK,UAAU,YAAY,CAChC,aAAwE,EACxE,MAAsB,EACtB,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,EAAqB;IAE5D,MAAM,YAAY,GAAG,MAAM,IAAA,uBAAO,EAAC,UAAW,CAAC,CAAA;IAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;IAC3C,MAAM,GAAG,GAAG,GAAG,QAAQ,gBAAgB,YAAY,GAAG,GAAG,EAAE,CAAA;IAC3D,MAAM,OAAO,GAAG,MAAM,sBAAS,CAAC,GAAG,CAAC;QAClC,KAAK,CAAC,cAAc;YAClB,MAAM,MAAM,GAAG,IAAA,iDAA2B,EAAC;gBACzC,gBAAgB,EAAE,YAAY,CAAC,QAAQ,EAAE;gBACzC,gBAAgB,EAAE,SAAS;gBAC3B,GAAG,OAAO,CAAC,GAAG;aACf,CAAC,CAAA;YACF,MAAM,IAAI,GAAG,MAAM,IAAA,kCAAyB,EAA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CAAC,CAAA;IAER,MAAM,CAAC,IAAI,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAA;AAC5C,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,EAAE,EAAE,EAAwC;IACxE,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAA,cAAO,EAAC,SAAS,EAAE,8BAA8B,CAAC,EAAE,OAAO,CAAC,CAAA;IACjG,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAA,cAAO,EAAC,SAAS,EAAE,8BAA8B,CAAC,EAAE,OAAO,CAAC,CAAA;IAClG,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;AAC/C,CAAC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,QAAQ,IAAI,EAAE;QACZ,KAAK,KAAK;YACR,OAAO,UAAU,CAAA;QACnB,KAAK,IAAI;YACP,OAAO,gBAAgB,CAAA;QACzB,KAAK,OAAO,CAAC;QACb;YACE,OAAO,YAAY,CAAA;KACtB;AACH,CAAC;AAVD,wCAUC"}
@@ -0,0 +1,13 @@
1
+ import { Router } from '@well-known-components/http-server';
2
+ import { CliComponents } from '../components';
3
+ /**
4
+ * Set common routes to use on Linker dApp
5
+ * @param components Server components
6
+ * @param info Info to be sent within /api/info body response
7
+ * @param mainRoute route to return the Linker dApp
8
+ */
9
+ export declare function setRoutes<T extends {
10
+ [key: string]: any;
11
+ }>(components: Pick<CliComponents, 'fs' | 'logger' | 'fetch' | 'config'>, info: T, mainRoute?: string): {
12
+ router: Router<{}>;
13
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setRoutes = void 0;
4
+ const path_1 = require("path");
5
+ const http_server_1 = require("@well-known-components/http-server");
6
+ const api_1 = require("../linker-dapp/api");
7
+ /**
8
+ * Set common routes to use on Linker dApp
9
+ * @param components Server components
10
+ * @param info Info to be sent within /api/info body response
11
+ * @param mainRoute route to return the Linker dApp
12
+ */
13
+ function setRoutes(components, info, mainRoute = '/') {
14
+ const { fs } = components;
15
+ const router = new http_server_1.Router();
16
+ const linkerDapp = (0, path_1.dirname)(require.resolve('@dcl/linker-dapp/package.json'));
17
+ router.get(mainRoute, async () => ({
18
+ headers: { 'Content-Type': 'text/html' },
19
+ body: fs.createReadStream((0, path_1.resolve)(linkerDapp, 'index.html'))
20
+ }));
21
+ router.get('/static/:type/:path', async (ctx) => {
22
+ const contentType = (0, api_1.getContentType)(ctx.params.type);
23
+ return {
24
+ headers: { 'Content-Type': contentType },
25
+ body: fs.createReadStream((0, path_1.resolve)(linkerDapp, 'static', ctx.params.type, ctx.params.path))
26
+ };
27
+ });
28
+ router.get('/manifest.json', async () => ({
29
+ headers: { 'Content-Type': 'application/json' },
30
+ body: fs.createReadStream((0, path_1.resolve)(linkerDapp, 'manifest.json'))
31
+ }));
32
+ router.get('/api/info', async () => ({
33
+ body: info
34
+ }));
35
+ return { router };
36
+ }
37
+ exports.setRoutes = setRoutes;
38
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/linker-dapp/routes.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,oEAA2D;AAG3D,4CAAmD;AAEnD;;;;;GAKG;AACH,SAAgB,SAAS,CACvB,UAAqE,EACrE,IAAO,EACP,SAAS,GAAG,GAAG;IAEf,MAAM,EAAE,EAAE,EAAE,GAAG,UAAU,CAAA;IACzB,MAAM,MAAM,GAAG,IAAI,oBAAM,EAAE,CAAA;IAC3B,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC,CAAA;IAE5E,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACjC,OAAO,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;QACxC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAA,cAAO,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;KAC7D,CAAC,CAAC,CAAA;IAEH,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAC9C,MAAM,WAAW,GAAG,IAAA,oBAAc,EAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACnD,OAAO;YACL,OAAO,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;YACxC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAA,cAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC3F,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAA,cAAO,EAAC,UAAU,EAAE,eAAe,CAAC,CAAC;KAChE,CAAC,CAAC,CAAA;IAEH,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACnC,IAAI,EAAE,IAAI;KACX,CAAC,CAAC,CAAA;IAEH,OAAO,EAAE,MAAM,EAAE,CAAA;AACnB,CAAC;AAhCD,8BAgCC"}
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@dcl/sdk-commands",
3
3
  "description": "",
4
- "version": "7.3.13-6076348032.commit-5985bd0",
4
+ "version": "7.3.13-6097928179.commit-904172b",
5
5
  "author": "Decentraland",
6
6
  "bin": {
7
7
  "sdk-commands": "./dist/index.js"
8
8
  },
9
9
  "dependencies": {
10
- "@dcl/ecs": "7.3.13-6076348032.commit-5985bd0",
10
+ "@dcl/crypto": "^3.4.4",
11
+ "@dcl/ecs": "7.3.13-6097928179.commit-904172b",
11
12
  "@dcl/hashing": "1.1.3",
12
- "@dcl/inspector": "7.3.13-6076348032.commit-5985bd0",
13
- "@dcl/linker-dapp": "0.9.1",
13
+ "@dcl/inspector": "7.3.13-6097928179.commit-904172b",
14
+ "@dcl/linker-dapp": "0.10.1",
14
15
  "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
15
16
  "@dcl/protocol": "1.0.0-5812097343.commit-8025576",
16
17
  "@dcl/rpc": "^1.1.1",
@@ -34,6 +35,7 @@
34
35
  "node-fetch": "^2.6.8",
35
36
  "open": "^8.4.0",
36
37
  "portfinder": "^1.0.32",
38
+ "prompts": "^2.4.2",
37
39
  "typescript": "^5.0.2",
38
40
  "undici": "^5.19.1",
39
41
  "uuid": "^9.0.0"
@@ -41,6 +43,7 @@
41
43
  "devDependencies": {
42
44
  "@types/archiver": "^5.3.2",
43
45
  "@types/node-fetch": "^2.6.1",
46
+ "@types/prompts": "^2.4.4",
44
47
  "@types/uuid": "^9.0.1",
45
48
  "@types/ws": "^8.5.4"
46
49
  },
@@ -68,5 +71,5 @@
68
71
  "displayName": "SDK",
69
72
  "tsconfig": "./tsconfig.json"
70
73
  },
71
- "commit": "5985bd0cfdbf63358f639b11bbef3696f89d5f89"
74
+ "commit": "904172b37b1be6a1a3b8b34e72e9a8b216394142"
72
75
  }
@@ -1,37 +0,0 @@
1
- import { Lifecycle } from '@well-known-components/interfaces';
2
- import { ChainId, Scene } from '@dcl/schemas';
3
- import { IFuture } from 'fp-future';
4
- import { IFile } from '../../../logic/scene-validations';
5
- import { CliComponents } from '../../../components';
6
- export interface LinkerResponse {
7
- address: string;
8
- signature: string;
9
- chainId?: ChainId;
10
- }
11
- export interface SceneInfo {
12
- baseParcel: string;
13
- parcels: string[];
14
- rootCID: string;
15
- landRegistry?: string;
16
- estateRegistry?: string;
17
- debug: boolean;
18
- title?: string;
19
- description?: string;
20
- skipValidations: boolean;
21
- isPortableExperience: boolean;
22
- isWorld: boolean;
23
- }
24
- export declare function runLinkerApp(cliComponents: Pick<CliComponents, 'fs' | 'logger' | 'fetch' | 'config'>, awaitResponse: IFuture<void>, scene: Scene, files: IFile[], port: number, rootCID: string, { isHttps, skipValidations, openBrowser }: {
25
- isHttps: boolean;
26
- skipValidations: boolean;
27
- openBrowser: boolean;
28
- }, deployCallback: (linkerResponse: LinkerResponse) => Promise<void>): Promise<{
29
- program: Lifecycle.ComponentBasedProgram<{
30
- config: import("@well-known-components/interfaces").IConfigComponent;
31
- logs: import("@well-known-components/interfaces").ILoggerComponent;
32
- server: import("@well-known-components/http-server").FullHttpServerComponent<object>;
33
- fs: import("../../../components/fs").IFileSystemComponent;
34
- fetch: import("../../../components/fetch").IFetchComponent;
35
- logger: import("@well-known-components/interfaces").ILoggerComponent.ILogger;
36
- }>;
37
- }>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/commands/deploy/linker-dapp/api.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA0E;AAC1E,kEAA6D;AAC7D,oFAAwF;AACxF,0DAAyE;AACzE,+BAA8B;AAE9B,8DAAqC;AACrC,gDAAuB;AAGvB,gEAAsD;AAGtD,qCAAoC;AACpC,kDAA0E;AAC1E,oCAA2C;AAsBpC,KAAK,UAAU,YAAY,CAChC,aAAwE,EACxE,aAA4B,EAC5B,KAAY,EACZ,KAAc,EACd,IAAY,EACZ,OAAe,EACf,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAwE,EAC/G,cAAiE;IAEjE,MAAM,YAAY,GAAG,MAAM,IAAA,uBAAO,EAAC,IAAI,CAAC,CAAA;IACxC,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,CAAA;IACpF,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,C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BAAoB,EACrB,GAAG,KAAK,CAAA;IAET,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,OAAO;QACP,OAAO;QACP,YAAY,EAAE,MAAM,IAAA,wBAAe,EAAC,UAAU,CAAC;QAC/C,cAAc,EAAE,MAAM,IAAA,0BAAiB,EAAC,UAAU,CAAC;QACnD,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK;QAC1B,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,WAAW,EAAE,OAAO,EAAE,WAAW;QACjC,eAAe;QACf,oBAAoB,EAAE,CAAC,CAAC,oBAAoB;QAC5C,OAAO,EAAE,IAAA,wBAAgB,EAAC,KAAK,CAAC;KACjC,CAAA;AACH,CAAC"}
@@ -1,8 +0,0 @@
1
- import { Router } from '@well-known-components/http-server';
2
- import { IFuture } from 'fp-future';
3
- import { CliComponents } from '../../../components';
4
- import { IFile } from '../../../logic/scene-validations';
5
- import { LinkerResponse, SceneInfo } from './api';
6
- export declare function setRoutes(components: Pick<CliComponents, 'fs' | 'logger' | 'fetch' | 'config'>, awaitResponse: IFuture<void>, files: IFile[], sceneInfo: SceneInfo, linkerCallback: (value: LinkerResponse) => Promise<void>): {
7
- router: Router<{}>;
8
- };