decentrand 3.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (289) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +56 -0
  3. package/abi/EstateRegistry.json +1226 -0
  4. package/abi/LANDRegistry.json +1372 -0
  5. package/abi/MANAToken.json +410 -0
  6. package/dist/commands/build.d.ts +3 -0
  7. package/dist/commands/build.d.ts.map +1 -0
  8. package/dist/commands/build.js +108 -0
  9. package/dist/commands/build.js.map +1 -0
  10. package/dist/commands/coords.d.ts +3 -0
  11. package/dist/commands/coords.d.ts.map +1 -0
  12. package/dist/commands/coords.js +122 -0
  13. package/dist/commands/coords.js.map +1 -0
  14. package/dist/commands/deploy.d.ts +4 -0
  15. package/dist/commands/deploy.d.ts.map +1 -0
  16. package/dist/commands/deploy.js +280 -0
  17. package/dist/commands/deploy.js.map +1 -0
  18. package/dist/commands/export.d.ts +3 -0
  19. package/dist/commands/export.d.ts.map +1 -0
  20. package/dist/commands/export.js +20 -0
  21. package/dist/commands/export.js.map +1 -0
  22. package/dist/commands/index.d.ts +3 -0
  23. package/dist/commands/index.d.ts.map +1 -0
  24. package/dist/commands/index.js +19 -0
  25. package/dist/commands/index.js.map +1 -0
  26. package/dist/commands/info.d.ts +3 -0
  27. package/dist/commands/info.d.ts.map +1 -0
  28. package/dist/commands/info.js +186 -0
  29. package/dist/commands/info.js.map +1 -0
  30. package/dist/commands/init/help.d.ts +12 -0
  31. package/dist/commands/init/help.d.ts.map +1 -0
  32. package/dist/commands/init/help.js +41 -0
  33. package/dist/commands/init/help.js.map +1 -0
  34. package/dist/commands/init/index.d.ts +3 -0
  35. package/dist/commands/init/index.d.ts.map +1 -0
  36. package/dist/commands/init/index.js +96 -0
  37. package/dist/commands/init/index.js.map +1 -0
  38. package/dist/commands/init/library.d.ts +1 -0
  39. package/dist/commands/init/library.d.ts.map +1 -0
  40. package/dist/commands/init/library.js +2 -0
  41. package/dist/commands/init/library.js.map +1 -0
  42. package/dist/commands/init/repositories.d.ts +11 -0
  43. package/dist/commands/init/repositories.d.ts.map +1 -0
  44. package/dist/commands/init/repositories.js +40 -0
  45. package/dist/commands/init/repositories.js.map +1 -0
  46. package/dist/commands/init/scene.d.ts +3 -0
  47. package/dist/commands/init/scene.d.ts.map +1 -0
  48. package/dist/commands/init/scene.js +56 -0
  49. package/dist/commands/init/scene.js.map +1 -0
  50. package/dist/commands/init/types.d.ts +22 -0
  51. package/dist/commands/init/types.d.ts.map +1 -0
  52. package/dist/commands/init/types.js +3 -0
  53. package/dist/commands/init/types.js.map +1 -0
  54. package/dist/commands/init/utils.d.ts +6 -0
  55. package/dist/commands/init/utils.d.ts.map +1 -0
  56. package/dist/commands/init/utils.js +76 -0
  57. package/dist/commands/init/utils.js.map +1 -0
  58. package/dist/commands/install.d.ts +3 -0
  59. package/dist/commands/install.d.ts.map +1 -0
  60. package/dist/commands/install.js +92 -0
  61. package/dist/commands/install.js.map +1 -0
  62. package/dist/commands/pack.d.ts +3 -0
  63. package/dist/commands/pack.d.ts.map +1 -0
  64. package/dist/commands/pack.js +102 -0
  65. package/dist/commands/pack.js.map +1 -0
  66. package/dist/commands/start.d.ts +3 -0
  67. package/dist/commands/start.d.ts.map +1 -0
  68. package/dist/commands/start.js +235 -0
  69. package/dist/commands/start.js.map +1 -0
  70. package/dist/commands/status.d.ts +3 -0
  71. package/dist/commands/status.d.ts.map +1 -0
  72. package/dist/commands/status.js +80 -0
  73. package/dist/commands/status.js.map +1 -0
  74. package/dist/commands/workspace.d.ts +3 -0
  75. package/dist/commands/workspace.d.ts.map +1 -0
  76. package/dist/commands/workspace.js +81 -0
  77. package/dist/commands/workspace.js.map +1 -0
  78. package/dist/commands/world-acl.d.ts +22 -0
  79. package/dist/commands/world-acl.d.ts.map +1 -0
  80. package/dist/commands/world-acl.js +262 -0
  81. package/dist/commands/world-acl.js.map +1 -0
  82. package/dist/config.d.ts +31 -0
  83. package/dist/config.d.ts.map +1 -0
  84. package/dist/config.js +128 -0
  85. package/dist/config.js.map +1 -0
  86. package/dist/index.d.ts +3 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +21 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/lib/API.d.ts +23 -0
  91. package/dist/lib/API.d.ts.map +1 -0
  92. package/dist/lib/API.js +175 -0
  93. package/dist/lib/API.js.map +1 -0
  94. package/dist/lib/Decentraland.d.ts +75 -0
  95. package/dist/lib/Decentraland.d.ts.map +1 -0
  96. package/dist/lib/Decentraland.js +227 -0
  97. package/dist/lib/Decentraland.js.map +1 -0
  98. package/dist/lib/Ethereum.d.ts +52 -0
  99. package/dist/lib/Ethereum.d.ts.map +1 -0
  100. package/dist/lib/Ethereum.js +245 -0
  101. package/dist/lib/Ethereum.js.map +1 -0
  102. package/dist/lib/IEthereumDataProvider.d.ts +17 -0
  103. package/dist/lib/IEthereumDataProvider.d.ts.map +1 -0
  104. package/dist/lib/IEthereumDataProvider.js +3 -0
  105. package/dist/lib/IEthereumDataProvider.js.map +1 -0
  106. package/dist/lib/LinkerAPI.d.ts +28 -0
  107. package/dist/lib/LinkerAPI.d.ts.map +1 -0
  108. package/dist/lib/LinkerAPI.js +151 -0
  109. package/dist/lib/LinkerAPI.js.map +1 -0
  110. package/dist/lib/Preview.d.ts +17 -0
  111. package/dist/lib/Preview.d.ts.map +1 -0
  112. package/dist/lib/Preview.js +113 -0
  113. package/dist/lib/Preview.js.map +1 -0
  114. package/dist/lib/Project.d.ts +152 -0
  115. package/dist/lib/Project.d.ts.map +1 -0
  116. package/dist/lib/Project.js +446 -0
  117. package/dist/lib/Project.js.map +1 -0
  118. package/dist/lib/Workspace.d.ts +21 -0
  119. package/dist/lib/Workspace.d.ts.map +1 -0
  120. package/dist/lib/Workspace.js +140 -0
  121. package/dist/lib/Workspace.js.map +1 -0
  122. package/dist/lib/WorldsContentServer.d.ts +27 -0
  123. package/dist/lib/WorldsContentServer.d.ts.map +1 -0
  124. package/dist/lib/WorldsContentServer.js +79 -0
  125. package/dist/lib/WorldsContentServer.js.map +1 -0
  126. package/dist/lib/WorldsContentServerLinkerAPI.d.ts +21 -0
  127. package/dist/lib/WorldsContentServerLinkerAPI.d.ts.map +1 -0
  128. package/dist/lib/WorldsContentServerLinkerAPI.js +105 -0
  129. package/dist/lib/WorldsContentServerLinkerAPI.js.map +1 -0
  130. package/dist/lib/adapters/proto/broker.d.ts +2 -0
  131. package/dist/lib/adapters/proto/broker.d.ts.map +1 -0
  132. package/dist/lib/adapters/proto/broker.js +2189 -0
  133. package/dist/lib/adapters/proto/broker.js.map +1 -0
  134. package/dist/lib/adapters/proto/comms.d.ts +2 -0
  135. package/dist/lib/adapters/proto/comms.d.ts.map +1 -0
  136. package/dist/lib/adapters/proto/comms.js +965 -0
  137. package/dist/lib/adapters/proto/comms.js.map +1 -0
  138. package/dist/lib/adapters/ws.d.ts +12 -0
  139. package/dist/lib/adapters/ws.d.ts.map +1 -0
  140. package/dist/lib/adapters/ws.js +20 -0
  141. package/dist/lib/adapters/ws.js.map +1 -0
  142. package/dist/lib/content/ContentService.d.ts +27 -0
  143. package/dist/lib/content/ContentService.d.ts.map +1 -0
  144. package/dist/lib/content/ContentService.js +60 -0
  145. package/dist/lib/content/ContentService.js.map +1 -0
  146. package/dist/lib/content/types.d.ts +12 -0
  147. package/dist/lib/content/types.d.ts.map +1 -0
  148. package/dist/lib/content/types.js +3 -0
  149. package/dist/lib/content/types.js.map +1 -0
  150. package/dist/lib/controllers/bff.d.ts +8 -0
  151. package/dist/lib/controllers/bff.d.ts.map +1 -0
  152. package/dist/lib/controllers/bff.js +58 -0
  153. package/dist/lib/controllers/bff.js.map +1 -0
  154. package/dist/lib/controllers/debugger.d.ts +4 -0
  155. package/dist/lib/controllers/debugger.d.ts.map +1 -0
  156. package/dist/lib/controllers/debugger.js +42 -0
  157. package/dist/lib/controllers/debugger.js.map +1 -0
  158. package/dist/lib/controllers/ecs6-endpoints.d.ts +11 -0
  159. package/dist/lib/controllers/ecs6-endpoints.d.ts.map +1 -0
  160. package/dist/lib/controllers/ecs6-endpoints.js +543 -0
  161. package/dist/lib/controllers/ecs6-endpoints.js.map +1 -0
  162. package/dist/lib/controllers/legacy-comms-v1.d.ts +7 -0
  163. package/dist/lib/controllers/legacy-comms-v1.d.ts.map +1 -0
  164. package/dist/lib/controllers/legacy-comms-v1.js +98 -0
  165. package/dist/lib/controllers/legacy-comms-v1.js.map +1 -0
  166. package/dist/lib/smartItems/buildSmartItem.d.ts +2 -0
  167. package/dist/lib/smartItems/buildSmartItem.d.ts.map +1 -0
  168. package/dist/lib/smartItems/buildSmartItem.js +18 -0
  169. package/dist/lib/smartItems/buildSmartItem.js.map +1 -0
  170. package/dist/lib/smartItems/packProject.d.ts +2 -0
  171. package/dist/lib/smartItems/packProject.d.ts.map +1 -0
  172. package/dist/lib/smartItems/packProject.js +31 -0
  173. package/dist/lib/smartItems/packProject.js.map +1 -0
  174. package/dist/main.d.ts +2 -0
  175. package/dist/main.d.ts.map +1 -0
  176. package/dist/main.js +151 -0
  177. package/dist/main.js.map +1 -0
  178. package/dist/project/installDependencies.d.ts +2 -0
  179. package/dist/project/installDependencies.d.ts.map +1 -0
  180. package/dist/project/installDependencies.js +57 -0
  181. package/dist/project/installDependencies.js.map +1 -0
  182. package/dist/project/isTypescriptProject.d.ts +2 -0
  183. package/dist/project/isTypescriptProject.d.ts.map +1 -0
  184. package/dist/project/isTypescriptProject.js +14 -0
  185. package/dist/project/isTypescriptProject.js.map +1 -0
  186. package/dist/project/projectInfo.d.ts +8 -0
  187. package/dist/project/projectInfo.d.ts.map +1 -0
  188. package/dist/project/projectInfo.js +89 -0
  189. package/dist/project/projectInfo.js.map +1 -0
  190. package/dist/project/updateBundleDependenciesField.d.ts +4 -0
  191. package/dist/project/updateBundleDependenciesField.d.ts.map +1 -0
  192. package/dist/project/updateBundleDependenciesField.js +67 -0
  193. package/dist/project/updateBundleDependenciesField.js.map +1 -0
  194. package/dist/sceneJson/index.d.ts +4 -0
  195. package/dist/sceneJson/index.d.ts.map +1 -0
  196. package/dist/sceneJson/index.js +24 -0
  197. package/dist/sceneJson/index.js.map +1 -0
  198. package/dist/sceneJson/lintSceneFile.d.ts +2 -0
  199. package/dist/sceneJson/lintSceneFile.d.ts.map +1 -0
  200. package/dist/sceneJson/lintSceneFile.js +13 -0
  201. package/dist/sceneJson/lintSceneFile.js.map +1 -0
  202. package/dist/sceneJson/utils.d.ts +3 -0
  203. package/dist/sceneJson/utils.d.ts.map +1 -0
  204. package/dist/sceneJson/utils.js +66 -0
  205. package/dist/sceneJson/utils.js.map +1 -0
  206. package/dist/utils/analytics.d.ts +42 -0
  207. package/dist/utils/analytics.d.ts.map +1 -0
  208. package/dist/utils/analytics.js +111 -0
  209. package/dist/utils/analytics.js.map +1 -0
  210. package/dist/utils/buildProject.d.ts +2 -0
  211. package/dist/utils/buildProject.d.ts.map +1 -0
  212. package/dist/utils/buildProject.js +26 -0
  213. package/dist/utils/buildProject.js.map +1 -0
  214. package/dist/utils/catalystPointers.d.ts +20 -0
  215. package/dist/utils/catalystPointers.d.ts.map +1 -0
  216. package/dist/utils/catalystPointers.js +51 -0
  217. package/dist/utils/catalystPointers.js.map +1 -0
  218. package/dist/utils/coordinateHelpers.d.ts +65 -0
  219. package/dist/utils/coordinateHelpers.d.ts.map +1 -0
  220. package/dist/utils/coordinateHelpers.js +126 -0
  221. package/dist/utils/coordinateHelpers.js.map +1 -0
  222. package/dist/utils/download.d.ts +3 -0
  223. package/dist/utils/download.d.ts.map +1 -0
  224. package/dist/utils/download.js +42 -0
  225. package/dist/utils/download.js.map +1 -0
  226. package/dist/utils/env.d.ts +6 -0
  227. package/dist/utils/env.d.ts.map +1 -0
  228. package/dist/utils/env.js +31 -0
  229. package/dist/utils/env.js.map +1 -0
  230. package/dist/utils/errors.d.ts +18 -0
  231. package/dist/utils/errors.d.ts.map +1 -0
  232. package/dist/utils/errors.js +27 -0
  233. package/dist/utils/errors.js.map +1 -0
  234. package/dist/utils/filesystem.d.ts +41 -0
  235. package/dist/utils/filesystem.d.ts.map +1 -0
  236. package/dist/utils/filesystem.js +84 -0
  237. package/dist/utils/filesystem.js.map +1 -0
  238. package/dist/utils/getDummyMappings.d.ts +3 -0
  239. package/dist/utils/getDummyMappings.d.ts.map +1 -0
  240. package/dist/utils/getDummyMappings.js +19 -0
  241. package/dist/utils/getDummyMappings.js.map +1 -0
  242. package/dist/utils/getProjectFilePaths.d.ts +2 -0
  243. package/dist/utils/getProjectFilePaths.d.ts.map +1 -0
  244. package/dist/utils/getProjectFilePaths.js +40 -0
  245. package/dist/utils/getProjectFilePaths.js.map +1 -0
  246. package/dist/utils/index.d.ts +11 -0
  247. package/dist/utils/index.d.ts.map +1 -0
  248. package/dist/utils/index.js +33 -0
  249. package/dist/utils/index.js.map +1 -0
  250. package/dist/utils/installedDependencies.d.ts +6 -0
  251. package/dist/utils/installedDependencies.d.ts.map +1 -0
  252. package/dist/utils/installedDependencies.js +44 -0
  253. package/dist/utils/installedDependencies.js.map +1 -0
  254. package/dist/utils/land.d.ts +4 -0
  255. package/dist/utils/land.d.ts.map +1 -0
  256. package/dist/utils/land.js +35 -0
  257. package/dist/utils/land.js.map +1 -0
  258. package/dist/utils/logging.d.ts +19 -0
  259. package/dist/utils/logging.d.ts.map +1 -0
  260. package/dist/utils/logging.js +97 -0
  261. package/dist/utils/logging.js.map +1 -0
  262. package/dist/utils/moduleHelpers.d.ts +22 -0
  263. package/dist/utils/moduleHelpers.d.ts.map +1 -0
  264. package/dist/utils/moduleHelpers.js +163 -0
  265. package/dist/utils/moduleHelpers.js.map +1 -0
  266. package/dist/utils/nodeAndNpmVersion.d.ts +5 -0
  267. package/dist/utils/nodeAndNpmVersion.d.ts.map +1 -0
  268. package/dist/utils/nodeAndNpmVersion.js +64 -0
  269. package/dist/utils/nodeAndNpmVersion.js.map +1 -0
  270. package/dist/utils/pathsExistOnDir.d.ts +2 -0
  271. package/dist/utils/pathsExistOnDir.d.ts.map +1 -0
  272. package/dist/utils/pathsExistOnDir.js +12 -0
  273. package/dist/utils/pathsExistOnDir.js.map +1 -0
  274. package/dist/utils/project.d.ts +29 -0
  275. package/dist/utils/project.d.ts.map +1 -0
  276. package/dist/utils/project.js +48 -0
  277. package/dist/utils/project.js.map +1 -0
  278. package/dist/utils/shellCommands.d.ts +19 -0
  279. package/dist/utils/shellCommands.d.ts.map +1 -0
  280. package/dist/utils/shellCommands.js +73 -0
  281. package/dist/utils/shellCommands.js.map +1 -0
  282. package/dist/utils/spinner.d.ts +6 -0
  283. package/dist/utils/spinner.d.ts.map +1 -0
  284. package/dist/utils/spinner.js +58 -0
  285. package/dist/utils/spinner.js.map +1 -0
  286. package/package.json +115 -0
  287. package/samples/workspace/Dockerfile +21 -0
  288. package/samples/workspace/package.json +16 -0
  289. package/sbzkmrj2.cjs +1 -0
@@ -0,0 +1,140 @@
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.initializeWorkspace = exports.createWorkspace = exports.workspaceConfigFile = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const filesystem_1 = require("../utils/filesystem");
10
+ const Project_1 = require("./Project");
11
+ const schemas_1 = require("@dcl/schemas");
12
+ const installDependencies_1 = __importDefault(require("../project/installDependencies"));
13
+ exports.workspaceConfigFile = 'dcl-workspace.json';
14
+ function getWorkspaceJsonWithFolders(workspaceJsonPath) {
15
+ const workspaceJsonDir = path_1.default.dirname(workspaceJsonPath);
16
+ if (fs_extra_1.default.existsSync(workspaceJsonPath)) {
17
+ try {
18
+ const workspaceJson = (0, filesystem_1.readJSONSync)(workspaceJsonPath);
19
+ if (workspaceJson.folders) {
20
+ const resolvedFolders = workspaceJson.folders.map((folderPath) => path_1.default.resolve(folderPath.path.startsWith('/') || folderPath.path.startsWith('\\')
21
+ ? folderPath.path
22
+ : `${workspaceJsonDir}/${folderPath.path}`));
23
+ return { json: workspaceJson, resolvedFolders };
24
+ }
25
+ }
26
+ catch (err) {
27
+ console.error(err);
28
+ }
29
+ }
30
+ return { resolvedFolders: [] };
31
+ }
32
+ const createWorkspace = ({ workingDir, workspaceFilePath }) => {
33
+ const projects = [];
34
+ const workspaceJsonPath = workspaceFilePath || path_1.default.resolve(workingDir || '', exports.workspaceConfigFile) || '';
35
+ if (workspaceJsonPath === '') {
36
+ throw new Error(`Couldn't find the workspace file or a working directory.`);
37
+ }
38
+ const workspaceInfo = getWorkspaceJsonWithFolders(workspaceJsonPath);
39
+ if (workspaceInfo.resolvedFolders.length) {
40
+ for (const projectFolder of workspaceInfo.resolvedFolders) {
41
+ projects.push(new Project_1.Project(projectFolder));
42
+ }
43
+ }
44
+ else if (workingDir) {
45
+ projects.push(new Project_1.Project(workingDir));
46
+ }
47
+ if (projects.length === 0) {
48
+ throw new Error('At least one project has to have been read for the workspace.');
49
+ }
50
+ const getAllProjects = () => {
51
+ return projects;
52
+ };
53
+ const getProject = (index = 0) => {
54
+ return projects[index];
55
+ };
56
+ const isSingleProject = () => {
57
+ return projects.length === 1 && projects[0].getProjectWorkingDir() === workingDir;
58
+ };
59
+ const getSingleProject = () => {
60
+ return (isSingleProject() && projects[0]) || null;
61
+ };
62
+ const hasPortableExperience = () => {
63
+ return !!projects.find((project) => project.getInfo().sceneType === schemas_1.sdk.ProjectType.PORTABLE_EXPERIENCE);
64
+ };
65
+ const getBaseCoords = async () => {
66
+ const firstParcelScene = projects.find((project) => project.getInfo().sceneType === schemas_1.sdk.ProjectType.SCENE);
67
+ return firstParcelScene ? await firstParcelScene.getSceneBaseCoords() : { x: 0, y: 0 };
68
+ };
69
+ const getParcelCount = async () => {
70
+ const firstParcelScene = projects.find((project) => project.getInfo().sceneType === schemas_1.sdk.ProjectType.SCENE);
71
+ return firstParcelScene ? await firstParcelScene.getSceneParcelCount() : 0;
72
+ };
73
+ const saveWorkspace = async () => {
74
+ if (isSingleProject()) {
75
+ throw new Error('Can not save a single project workspace.');
76
+ }
77
+ const folders = [];
78
+ for (const project of projects) {
79
+ const projectPath = path_1.default.resolve(project.getProjectWorkingDir());
80
+ const workspacePath = path_1.default.resolve(path_1.default.dirname(workspaceJsonPath));
81
+ if (projectPath.startsWith(workspacePath)) {
82
+ folders.push({
83
+ path: projectPath.replace(`${workspacePath}/`, '').replace(`${workspacePath}\\`, '')
84
+ });
85
+ }
86
+ else {
87
+ folders.push({ path: projectPath });
88
+ }
89
+ }
90
+ const newWorkspace = { folders };
91
+ await fs_extra_1.default.writeJSON(workspaceJsonPath, newWorkspace, { spaces: 2 });
92
+ };
93
+ const addProject = async (projectWorkingDir) => {
94
+ const workspacePath = path_1.default.resolve(path_1.default.dirname(workspaceJsonPath));
95
+ const projectResolvedPath = projectWorkingDir.startsWith('/')
96
+ ? projectWorkingDir
97
+ : path_1.default.resolve(workspacePath, projectWorkingDir);
98
+ if (!(await fs_extra_1.default.pathExists(projectResolvedPath))) {
99
+ throw new Error(`Path ${projectWorkingDir} doen't exist. Resolved ${projectResolvedPath}`);
100
+ }
101
+ const newProject = new Project_1.Project(projectResolvedPath);
102
+ await newProject.validateExistingProject();
103
+ projects.push(newProject);
104
+ await saveWorkspace();
105
+ };
106
+ return {
107
+ getAllProjects,
108
+ getProject,
109
+ getSingleProject,
110
+ isSingleProject,
111
+ hasPortableExperience,
112
+ getBaseCoords,
113
+ getParcelCount,
114
+ addProject
115
+ };
116
+ };
117
+ exports.createWorkspace = createWorkspace;
118
+ async function initializeWorkspace(workingDir) {
119
+ const workingDirPaths = await fs_extra_1.default.readdir(workingDir);
120
+ const folders = [];
121
+ for (const listedPath of workingDirPaths) {
122
+ const projectWorkingDir = path_1.default.resolve(workingDir, listedPath);
123
+ if ((await fs_extra_1.default.stat(projectWorkingDir)).isDirectory()) {
124
+ const project = new Project_1.Project(projectWorkingDir);
125
+ if (await project.sceneFileExists()) {
126
+ folders.push({ path: listedPath });
127
+ }
128
+ }
129
+ }
130
+ if (!folders.length) {
131
+ throw new Error(`There isn't any valid project in the sub folders.`);
132
+ }
133
+ const newWorkspace = { folders };
134
+ await fs_extra_1.default.writeJSON(path_1.default.resolve(workingDir, exports.workspaceConfigFile), newWorkspace, { spaces: 2 });
135
+ await (0, Project_1.copySample)('workspace', workingDir);
136
+ await (0, installDependencies_1.default)(workingDir, false);
137
+ return (0, exports.createWorkspace)({ workingDir });
138
+ }
139
+ exports.initializeWorkspace = initializeWorkspace;
140
+ //# sourceMappingURL=Workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Workspace.js","sourceRoot":"","sources":["../../src/lib/Workspace.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,wDAAyB;AACzB,oDAAkD;AAClD,uCAA+C;AAC/C,0CAAkC;AAClC,yFAAgE;AAWnD,QAAA,mBAAmB,GAAG,oBAAoB,CAAA;AAEvD,SAAS,2BAA2B,CAAC,iBAAyB;IAI5D,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACxD,IAAI,kBAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;QACpC,IAAI;YACF,MAAM,aAAa,GAAG,IAAA,yBAAY,EAAsB,iBAAiB,CAAC,CAAA;YAC1E,IAAI,aAAa,CAAC,OAAO,EAAE;gBACzB,MAAM,eAAe,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAC/D,cAAI,CAAC,OAAO,CACV,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;oBACjE,CAAC,CAAC,UAAU,CAAC,IAAI;oBACjB,CAAC,CAAC,GAAG,gBAAgB,IAAI,UAAU,CAAC,IAAI,EAAE,CAC7C,CACF,CAAA;gBACD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,CAAA;aAChD;SACF;QAAC,OAAO,GAAG,EAAE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,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;IAC9F,MAAM,IAAA,oBAAU,EAAC,WAAW,EAAE,UAAU,CAAC,CAAA;IACzC,MAAM,IAAA,6BAAmB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IAE5C,OAAO,IAAA,uBAAe,EAAC,EAAE,UAAU,EAAE,CAAC,CAAA;AACxC,CAAC;AAxBD,kDAwBC"}
@@ -0,0 +1,27 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ import { DCLInfo } from '../config';
4
+ import { LinkerResponse } from './LinkerAPI';
5
+ import { IdentityType } from '@dcl/crypto';
6
+ import { EthAddress } from '@dcl/schemas';
7
+ export declare type WorldsContentServerArguments = {
8
+ worldName: string;
9
+ allowed: EthAddress[];
10
+ oldAllowed: EthAddress[];
11
+ targetContent: string;
12
+ linkerPort?: number;
13
+ isHttps?: boolean;
14
+ config?: DCLInfo;
15
+ method: 'put' | 'delete';
16
+ };
17
+ export declare class WorldsContentServer extends EventEmitter {
18
+ options: WorldsContentServerArguments;
19
+ targetContent: string;
20
+ environmentIdentity?: IdentityType;
21
+ constructor(args: WorldsContentServerArguments);
22
+ link(payload: string): Promise<LinkerResponse>;
23
+ getAddressAndSignature(messageToSign: string): Promise<LinkerResponse>;
24
+ private pipeEvents;
25
+ private createWallet;
26
+ }
27
+ //# sourceMappingURL=WorldsContentServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorldsContentServer.d.ts","sourceRoot":"","sources":["../../src/lib/WorldsContentServer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAGrC,OAAO,EAAE,OAAO,EAAa,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,oBAAY,4BAA4B,GAAG;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,UAAU,EAAE,UAAU,EAAE,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,KAAK,GAAG,QAAQ,CAAA;CACzB,CAAA;AAED,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,OAAO,EAAE,4BAA4B,CAAA;IACrC,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,CAAC,EAAE,YAAY,CAAA;gBAEtB,IAAI,EAAE,4BAA4B;IAUxC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAwB9C,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAU5E,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,YAAY;CAqBrB"}
@@ -0,0 +1,79 @@
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.WorldsContentServer = void 0;
7
+ const events_1 = require("events");
8
+ const wildcards_1 = __importDefault(require("wildcards"));
9
+ const errors_1 = require("../utils/errors");
10
+ const config_1 = require("../config");
11
+ const crypto_1 = require("@dcl/crypto/dist/crypto");
12
+ const eth_connect_1 = require("eth-connect");
13
+ const WorldsContentServerLinkerAPI_1 = require("./WorldsContentServerLinkerAPI");
14
+ class WorldsContentServer extends events_1.EventEmitter {
15
+ constructor(args) {
16
+ super();
17
+ this.options = args;
18
+ this.options.config = this.options.config || (0, config_1.getConfig)();
19
+ this.targetContent = args.targetContent;
20
+ if (process.env.DCL_PRIVATE_KEY) {
21
+ this.createWallet(process.env.DCL_PRIVATE_KEY);
22
+ }
23
+ }
24
+ async link(payload) {
25
+ return new Promise(async (resolve, reject) => {
26
+ const linker = new WorldsContentServerLinkerAPI_1.WorldsContentServerLinkerAPI({
27
+ worldName: this.options.worldName,
28
+ allowed: this.options.allowed,
29
+ oldAllowed: this.options.oldAllowed,
30
+ targetContent: this.options.targetContent,
31
+ method: this.options.method,
32
+ expiration: 120,
33
+ payload
34
+ });
35
+ (0, wildcards_1.default)(linker, '*', this.pipeEvents.bind(this));
36
+ linker.on('link:success', async (message) => {
37
+ resolve(message);
38
+ });
39
+ try {
40
+ await linker.link(this.options.linkerPort, !!this.options.isHttps);
41
+ }
42
+ catch (e) {
43
+ reject(e);
44
+ }
45
+ });
46
+ }
47
+ async getAddressAndSignature(messageToSign) {
48
+ if (this.environmentIdentity) {
49
+ return {
50
+ signature: (0, crypto_1.ethSign)((0, eth_connect_1.hexToBytes)(this.environmentIdentity.privateKey), messageToSign),
51
+ address: this.environmentIdentity.address
52
+ };
53
+ }
54
+ return this.link(messageToSign);
55
+ }
56
+ pipeEvents(event, ...args) {
57
+ this.emit(event, ...args);
58
+ }
59
+ createWallet(privateKey) {
60
+ let length = 64;
61
+ if (privateKey.startsWith('0x')) {
62
+ length = 66;
63
+ }
64
+ if (privateKey.length !== length) {
65
+ (0, errors_1.fail)(errors_1.ErrorType.DEPLOY_ERROR, 'Addresses should be 64 characters length.');
66
+ }
67
+ const pk = (0, eth_connect_1.hexToBytes)(privateKey);
68
+ const msg = Math.random().toString();
69
+ const signature = (0, crypto_1.ethSign)(pk, msg);
70
+ const address = (0, crypto_1.recoverAddressFromEthSignature)(signature, msg);
71
+ this.environmentIdentity = {
72
+ address,
73
+ privateKey,
74
+ publicKey: '0x'
75
+ };
76
+ }
77
+ }
78
+ exports.WorldsContentServer = WorldsContentServer;
79
+ //# sourceMappingURL=WorldsContentServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorldsContentServer.js","sourceRoot":"","sources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AClC,MAAM,OAAO,GAAG,IAAA,uCAA8B,EAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QAC9D,IAAI,CAAC,mBAAmB,GAAG;YACzB,OAAO;YACP,UAAU;YACV,SAAS,EAAE,IAAI;SAChB,CAAA;IACH,CAAC;CACF;AA1ED,kDA0EC"}
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ export declare type WorldsContentServerResponse = {
4
+ address: string;
5
+ signature: string;
6
+ };
7
+ /**
8
+ * Events emitted by this class:
9
+ *
10
+ * link:ready - The server is up and running
11
+ * link:success - Signature success
12
+ * link:error - The transaction failed and the server was closed
13
+ */
14
+ export declare class WorldsContentServerLinkerAPI extends EventEmitter {
15
+ private data;
16
+ private app;
17
+ constructor(data: any);
18
+ link(port: number, isHttps: boolean): Promise<unknown>;
19
+ private setRoutes;
20
+ }
21
+ //# sourceMappingURL=WorldsContentServerLinkerAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorldsContentServerLinkerAPI.d.ts","sourceRoot":"","sources":["../../src/lib/WorldsContentServerLinkerAPI.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAOrC,oBAAY,2BAA2B,GAAG;IACxC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAmBD;;;;;;GAMG;AACH,qBAAa,4BAA6B,SAAQ,YAAY;IAGhD,OAAO,CAAC,IAAI;IAFxB,OAAO,CAAC,GAAG,CAA0C;gBAEjC,IAAI,EAAE,GAAG;IAI7B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IA0CnC,OAAO,CAAC,SAAS;CA6ClB"}
@@ -0,0 +1,105 @@
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.WorldsContentServerLinkerAPI = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const https_1 = __importDefault(require("https"));
9
+ const events_1 = require("events");
10
+ const fs_extra_1 = __importDefault(require("fs-extra"));
11
+ const express_1 = __importDefault(require("express"));
12
+ const cors_1 = __importDefault(require("cors"));
13
+ const body_parser_1 = __importDefault(require("body-parser"));
14
+ const portfinder_1 = __importDefault(require("portfinder"));
15
+ /**
16
+ * Events emitted by this class:
17
+ *
18
+ * link:ready - The server is up and running
19
+ * link:success - Signature success
20
+ * link:error - The transaction failed and the server was closed
21
+ */
22
+ class WorldsContentServerLinkerAPI extends events_1.EventEmitter {
23
+ constructor(data) {
24
+ super();
25
+ this.data = data;
26
+ this.app = (0, express_1.default)();
27
+ }
28
+ link(port, isHttps) {
29
+ return new Promise(async (_, reject) => {
30
+ let resolvedPort = port;
31
+ if (!resolvedPort) {
32
+ try {
33
+ resolvedPort = await portfinder_1.default.getPortPromise();
34
+ }
35
+ catch (e) {
36
+ resolvedPort = 4044;
37
+ }
38
+ }
39
+ const protocol = isHttps ? 'https' : 'http';
40
+ const url = `${protocol}://localhost:${resolvedPort}`;
41
+ this.setRoutes();
42
+ this.on('link:error', (err) => {
43
+ reject(err);
44
+ });
45
+ const serverHandler = () => this.emit('link:ready', { url });
46
+ const eventHandler = () => (e) => {
47
+ if (e.errno === 'EADDRINUSE') {
48
+ reject(new Error(`Port ${resolvedPort} is already in use by another process`));
49
+ }
50
+ else {
51
+ reject(new Error(`Failed to start Linker App: ${e.message}`));
52
+ }
53
+ };
54
+ if (isHttps) {
55
+ const privateKey = await fs_extra_1.default.readFile(path_1.default.resolve(__dirname, '../../certs/localhost.key'), 'utf-8');
56
+ const certificate = await fs_extra_1.default.readFile(path_1.default.resolve(__dirname, '../../certs/localhost.crt'), 'utf-8');
57
+ const credentials = { key: privateKey, cert: certificate };
58
+ const httpsServer = https_1.default.createServer(credentials, this.app);
59
+ httpsServer.listen(resolvedPort, serverHandler).on('error', eventHandler);
60
+ }
61
+ else {
62
+ this.app.listen(resolvedPort, serverHandler).on('error', eventHandler);
63
+ }
64
+ });
65
+ }
66
+ setRoutes() {
67
+ const linkerDapp = path_1.default.dirname(require.resolve('@dcl/linker-dapp/package.json'));
68
+ this.app.use((0, cors_1.default)());
69
+ this.app.use(express_1.default.static(linkerDapp));
70
+ this.app.use('/acl', express_1.default.static(linkerDapp));
71
+ this.app.use(body_parser_1.default.json());
72
+ /**
73
+ * Async method to try/catch errors
74
+ */
75
+ const methods = ['Get', 'Post'];
76
+ for (const method of methods) {
77
+ const asyncMethod = `async${method}`;
78
+ this.app[asyncMethod] = async (path, fn) => {
79
+ const originalMethod = method.toLocaleLowerCase();
80
+ this.app[originalMethod](path, async (req, res) => {
81
+ try {
82
+ const resp = await fn(req, res);
83
+ res.send(resp || {});
84
+ }
85
+ catch (e) {
86
+ console.log(e);
87
+ res.send(e);
88
+ }
89
+ });
90
+ };
91
+ }
92
+ this.app.asyncGet('/api/acl', async () => {
93
+ return await this.data;
94
+ });
95
+ this.app.asyncPost('/api/acl', (req) => {
96
+ const value = req.body;
97
+ if (!value.address || !value.signature) {
98
+ throw new Error(`Invalid payload: ${Object.keys(value).join(' - ')}`);
99
+ }
100
+ this.emit('link:success', value);
101
+ });
102
+ }
103
+ }
104
+ exports.WorldsContentServerLinkerAPI = WorldsContentServerLinkerAPI;
105
+ //# sourceMappingURL=WorldsContentServerLinkerAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorldsContentServerLinkerAPI.js","sourceRoot":"","sources":["../../src/lib/WorldsContentServerLinkerAPI.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,kDAAyB;AACzB,mCAAqC;AACrC,wDAAyB;AACzB,sDAA2E;AAC3E,gDAAuB;AACvB,8DAAoC;AACpC,4DAAmC;AAwBnC;;;;;;GAMG;AACH,MAAa,4BAA6B,SAAQ,qBAAY;IAG5D,YAAoB,IAAS;QAC3B,KAAK,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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=broker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker.d.ts","sourceRoot":"","sources":["../../../../src/lib/adapters/proto/broker.js"],"names":[],"mappings":""}