@dcl/sdk-commands 7.26.1-32251692034.commit-9055b4b → 7.26.1-32744818241.commit-e61f378
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/dist/commands/sdk-server-logs/index.d.ts +24 -0
- package/dist/commands/sdk-server-logs/index.js +313 -0
- package/dist/commands/sdk-server-logs/index.js.map +1 -0
- package/dist/commands/start/hammurabi-server.d.ts +19 -0
- package/dist/commands/start/hammurabi-server.js +78 -0
- package/dist/commands/start/hammurabi-server.js.map +1 -0
- package/dist/commands/start/index.js +17 -0
- package/dist/commands/start/index.js.map +1 -1
- package/dist/commands/start/server/routes.js +2 -0
- package/dist/commands/start/server/routes.js.map +1 -1
- package/dist/commands/start/server/runtime-env.d.ts +71 -0
- package/dist/commands/start/server/runtime-env.js +253 -0
- package/dist/commands/start/server/runtime-env.js.map +1 -0
- package/dist/commands/start/server/storage-service.d.ts +8 -0
- package/dist/commands/start/server/storage-service.js +156 -0
- package/dist/commands/start/server/storage-service.js.map +1 -0
- package/dist/commands/start/types.d.ts +3 -0
- package/dist/commands/start/utils.d.ts +34 -0
- package/dist/commands/start/utils.js +104 -0
- package/dist/commands/start/utils.js.map +1 -1
- package/dist/commands/storage/env.d.ts +5 -0
- package/dist/commands/storage/env.js +86 -0
- package/dist/commands/storage/env.js.map +1 -0
- package/dist/commands/storage/index.d.ts +26 -0
- package/dist/commands/storage/index.js +142 -0
- package/dist/commands/storage/index.js.map +1 -0
- package/dist/commands/storage/player.d.ts +5 -0
- package/dist/commands/storage/player.js +143 -0
- package/dist/commands/storage/player.js.map +1 -0
- package/dist/commands/storage/scene.d.ts +5 -0
- package/dist/commands/storage/scene.js +105 -0
- package/dist/commands/storage/scene.js.map +1 -0
- package/dist/commands/storage/shared.d.ts +62 -0
- package/dist/commands/storage/shared.js +249 -0
- package/dist/commands/storage/shared.js.map +1 -0
- package/dist/commands/storage/types.d.ts +56 -0
- package/dist/commands/storage/types.js +23 -0
- package/dist/commands/storage/types.js.map +1 -0
- package/dist/components/analytics.d.ts +70 -1
- package/dist/components/analytics.js +3 -2
- package/dist/components/analytics.js.map +1 -1
- package/dist/linker-dapp/routes.d.ts +11 -0
- package/dist/linker-dapp/routes.js +56 -34
- package/dist/linker-dapp/routes.js.map +1 -1
- package/dist/logic/auth-chain-headers.d.ts +11 -0
- package/dist/logic/auth-chain-headers.js +25 -0
- package/dist/logic/auth-chain-headers.js.map +1 -0
- package/dist/logic/bundle.js +31 -0
- package/dist/logic/bundle.js.map +1 -1
- package/dist/logic/config.d.ts +1 -0
- package/dist/logic/config.js +7 -0
- package/dist/logic/config.js.map +1 -1
- package/dist/logic/error.d.ts +1 -1
- package/dist/logic/error.js.map +1 -1
- package/dist/logic/exec.d.ts +1 -0
- package/dist/logic/exec.js +2 -2
- package/dist/logic/exec.js.map +1 -1
- package/dist/logic/lang.js +1 -1
- package/dist/logic/scene-validations.d.ts +8 -1
- package/dist/logic/scene-validations.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,249 @@
|
|
|
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.createStorageInfo = exports.getStorageBaseUrl = exports.makeAuthenticatedRequest = exports.getAuthHeaders = exports.setupStorageCommand = exports.getLinkerDappOptions = exports.confirmAction = exports.buildStorageMetadata = exports.validateWorkspaceAndWorld = void 0;
|
|
7
|
+
const fp_future_1 = __importDefault(require("fp-future"));
|
|
8
|
+
const crypto_1 = require("@dcl/crypto");
|
|
9
|
+
const crypto_2 = require("@dcl/crypto/dist/crypto");
|
|
10
|
+
const eth_connect_1 = require("eth-connect");
|
|
11
|
+
const readline_1 = __importDefault(require("readline"));
|
|
12
|
+
const error_1 = require("../../logic/error");
|
|
13
|
+
const account_1 = require("../../logic/account");
|
|
14
|
+
const auth_chain_headers_1 = require("../../logic/auth-chain-headers");
|
|
15
|
+
const routes_1 = require("../../linker-dapp/routes");
|
|
16
|
+
const run_dapp_1 = require("../../run-dapp");
|
|
17
|
+
const workspace_validations_1 = require("../../logic/workspace-validations");
|
|
18
|
+
const scene_validations_1 = require("../../logic/scene-validations");
|
|
19
|
+
const STORAGE_SERVER_ORG = 'https://storage.decentraland.org';
|
|
20
|
+
/**
|
|
21
|
+
* Validates workspace and extracts world configuration for server-side storage operations
|
|
22
|
+
*/
|
|
23
|
+
const validateWorkspaceAndWorld = async (components, projectRoot, baseURL) => {
|
|
24
|
+
await (0, workspace_validations_1.getValidWorkspace)(components, projectRoot);
|
|
25
|
+
const isLocalTarget = baseURL.includes('localhost') || baseURL.includes('127.0.0.1');
|
|
26
|
+
const sceneJson = await (0, scene_validations_1.getValidSceneJson)(components, projectRoot);
|
|
27
|
+
const worldName = sceneJson.worldConfiguration?.name;
|
|
28
|
+
if (!worldName && !isLocalTarget) {
|
|
29
|
+
throw new error_1.CliError('STORAGE_MISSING_WORLD', 'scene.json must have worldConfiguration.name defined to use storage on remote servers');
|
|
30
|
+
}
|
|
31
|
+
const baseParcel = sceneJson.scene?.base || '0,0';
|
|
32
|
+
const parcels = sceneJson.scene?.parcels || ['0,0'];
|
|
33
|
+
return { worldName, baseParcel, parcels };
|
|
34
|
+
};
|
|
35
|
+
exports.validateWorkspaceAndWorld = validateWorkspaceAndWorld;
|
|
36
|
+
/**
|
|
37
|
+
* Builds metadata for server-side storage service requests (ADR-44 format)
|
|
38
|
+
*/
|
|
39
|
+
const buildStorageMetadata = (worldName, baseParcel) => {
|
|
40
|
+
const meta = {};
|
|
41
|
+
if (worldName) {
|
|
42
|
+
meta.realm = { serverName: worldName };
|
|
43
|
+
meta.realmName = worldName;
|
|
44
|
+
}
|
|
45
|
+
meta.parcel = baseParcel;
|
|
46
|
+
return JSON.stringify(meta);
|
|
47
|
+
};
|
|
48
|
+
exports.buildStorageMetadata = buildStorageMetadata;
|
|
49
|
+
/**
|
|
50
|
+
* Confirms an action with the user
|
|
51
|
+
* Accepts: yes, y, no, n (case insensitive)
|
|
52
|
+
*/
|
|
53
|
+
const confirmAction = async (message) => {
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
const rl = readline_1.default.createInterface({
|
|
56
|
+
input: process.stdin,
|
|
57
|
+
output: process.stdout
|
|
58
|
+
});
|
|
59
|
+
rl.question(`${message} (Yes/No): `, (answer) => {
|
|
60
|
+
rl.close();
|
|
61
|
+
const normalized = answer.toLowerCase().trim();
|
|
62
|
+
resolve(normalized === 'yes' || normalized === 'y');
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
exports.confirmAction = confirmAction;
|
|
67
|
+
/**
|
|
68
|
+
* Extracts linker dApp options from command arguments
|
|
69
|
+
*/
|
|
70
|
+
const getLinkerDappOptions = (args) => {
|
|
71
|
+
return {
|
|
72
|
+
linkerPort: args['--port'],
|
|
73
|
+
openBrowser: !args['--no-browser'],
|
|
74
|
+
isHttps: !!args['--https']
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
exports.getLinkerDappOptions = getLinkerDappOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Common setup for server-side storage commands: validates action, workspace, and world configuration
|
|
80
|
+
*/
|
|
81
|
+
const setupStorageCommand = async (components, projectRoot, action, targetArg, validActions) => {
|
|
82
|
+
const { logger } = components;
|
|
83
|
+
// Validate action
|
|
84
|
+
if (!validActions.includes(action)) {
|
|
85
|
+
throw new error_1.CliError('STORAGE_INVALID_ACTION', `Invalid action '${action}'. Use: ${validActions.join(', ')}`);
|
|
86
|
+
}
|
|
87
|
+
// Get base URL
|
|
88
|
+
const baseURL = (0, exports.getStorageBaseUrl)(targetArg);
|
|
89
|
+
// Validate workspace and world
|
|
90
|
+
const { worldName, baseParcel, parcels } = await (0, exports.validateWorkspaceAndWorld)(components, projectRoot, baseURL);
|
|
91
|
+
if (worldName) {
|
|
92
|
+
logger.info(`World: ${worldName}`);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
logger.info(`Local development mode (no world configuration required)`);
|
|
96
|
+
}
|
|
97
|
+
return { baseURL, worldName, baseParcel, parcels };
|
|
98
|
+
};
|
|
99
|
+
exports.setupStorageCommand = setupStorageCommand;
|
|
100
|
+
/**
|
|
101
|
+
* Sets up routes for the linker dApp specific to server-side storage operations
|
|
102
|
+
*/
|
|
103
|
+
const setStorageRoutes = (router, components, awaitResponse, deployCallback) => {
|
|
104
|
+
const { logger } = components;
|
|
105
|
+
const resolveLinkerPromise = () => setTimeout(() => awaitResponse.resolve(), 100);
|
|
106
|
+
const rejectLinkerPromise = (e) => setTimeout(() => awaitResponse.reject(e), 100);
|
|
107
|
+
router.post('/api/storage', async (ctx) => {
|
|
108
|
+
const value = (await ctx.request.json());
|
|
109
|
+
if (!value.address || !value.authChain) {
|
|
110
|
+
const errorMessage = `Invalid payload: ${Object.keys(value).join(' - ')}`;
|
|
111
|
+
logger.error(errorMessage);
|
|
112
|
+
resolveLinkerPromise();
|
|
113
|
+
return { status: 400, body: { success: false, error: errorMessage } };
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const result = await deployCallback(value);
|
|
117
|
+
resolveLinkerPromise();
|
|
118
|
+
if (!result.success) {
|
|
119
|
+
return { status: 400, body: { success: false, error: result.error } };
|
|
120
|
+
}
|
|
121
|
+
return { body: { success: true, data: result.data } };
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
rejectLinkerPromise(e);
|
|
125
|
+
return { status: 400, body: { success: false, error: e.message } };
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return router;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Gets authentication (private key or linker dApp) and executes callback with signed headers
|
|
132
|
+
*/
|
|
133
|
+
const getAuthHeaders = async (components, awaitResponse, info, linkOptions, deployCallback) => {
|
|
134
|
+
// If DCL_PRIVATE_KEY is set, sign directly without the linker dapp
|
|
135
|
+
if (process.env.DCL_PRIVATE_KEY) {
|
|
136
|
+
const wallet = (0, account_1.createWallet)(process.env.DCL_PRIVATE_KEY);
|
|
137
|
+
const authChain = crypto_1.Authenticator.createSimpleAuthChain(info.rootCID, wallet.address, (0, crypto_2.ethSign)((0, eth_connect_1.hexToBytes)(wallet.privateKey), info.rootCID));
|
|
138
|
+
const linkerResponse = { authChain, address: wallet.address };
|
|
139
|
+
await deployCallback(linkerResponse);
|
|
140
|
+
awaitResponse.resolve();
|
|
141
|
+
return {};
|
|
142
|
+
}
|
|
143
|
+
// Use linker dapp for signing
|
|
144
|
+
const { router: commonRouter } = (0, routes_1.setRoutes)(components, {
|
|
145
|
+
storageType: info.storageType,
|
|
146
|
+
key: info.key,
|
|
147
|
+
value: info.value,
|
|
148
|
+
address: info.address,
|
|
149
|
+
world: info.world,
|
|
150
|
+
action: info.action,
|
|
151
|
+
targetUrl: info.targetUrl,
|
|
152
|
+
rootCID: info.rootCID,
|
|
153
|
+
baseParcel: info.baseParcel,
|
|
154
|
+
parcels: info.parcels,
|
|
155
|
+
skipValidations: info.skipValidations,
|
|
156
|
+
debug: info.debug,
|
|
157
|
+
isWorld: info.isWorld,
|
|
158
|
+
title: 'Storage Service',
|
|
159
|
+
description: 'Manage storage in the Decentraland Storage Service'
|
|
160
|
+
});
|
|
161
|
+
const router = setStorageRoutes(commonRouter, components, awaitResponse, deployCallback);
|
|
162
|
+
const actionLabel = info.action === 'delete' || info.action === 'clear' ? 'delete' : 'deploy';
|
|
163
|
+
components.logger.info(`You need to sign the content before the ${actionLabel}:`);
|
|
164
|
+
const { program } = await (0, run_dapp_1.runDapp)(components, router, { ...linkOptions, uri: `/` });
|
|
165
|
+
return { program };
|
|
166
|
+
};
|
|
167
|
+
exports.getAuthHeaders = getAuthHeaders;
|
|
168
|
+
/**
|
|
169
|
+
* Makes an authenticated request to the server-side storage service
|
|
170
|
+
*/
|
|
171
|
+
const makeAuthenticatedRequest = async (components, info, linkOptions, method, url, body, additionalHeaders) => {
|
|
172
|
+
const { fetch: fetchComponent } = components;
|
|
173
|
+
const awaitResponse = (0, fp_future_1.default)();
|
|
174
|
+
let operationResult = { success: false, error: 'Operation not completed' };
|
|
175
|
+
const { program } = await (0, exports.getAuthHeaders)(components, awaitResponse, info, linkOptions, async (linkerResponse) => {
|
|
176
|
+
const authHeaders = (0, auth_chain_headers_1.createAuthChainHeaders)(linkerResponse.authChain, info.timestamp, info.metadata);
|
|
177
|
+
const headers = {
|
|
178
|
+
...authHeaders,
|
|
179
|
+
...additionalHeaders
|
|
180
|
+
};
|
|
181
|
+
if (method !== 'GET') {
|
|
182
|
+
headers['Content-Type'] = 'application/json';
|
|
183
|
+
}
|
|
184
|
+
const res = await fetchComponent.fetch(url, {
|
|
185
|
+
method,
|
|
186
|
+
headers,
|
|
187
|
+
body: body ? JSON.stringify(body) : undefined
|
|
188
|
+
});
|
|
189
|
+
if (res.ok) {
|
|
190
|
+
try {
|
|
191
|
+
const text = await res.text();
|
|
192
|
+
const responseData = text ? JSON.parse(text) : {};
|
|
193
|
+
operationResult = { success: true, data: responseData.value };
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
operationResult = { success: true };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const errorText = await res.text();
|
|
201
|
+
operationResult = { success: false, error: errorText };
|
|
202
|
+
}
|
|
203
|
+
return operationResult;
|
|
204
|
+
});
|
|
205
|
+
try {
|
|
206
|
+
await awaitResponse;
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
void program?.stop();
|
|
210
|
+
}
|
|
211
|
+
return operationResult;
|
|
212
|
+
};
|
|
213
|
+
exports.makeAuthenticatedRequest = makeAuthenticatedRequest;
|
|
214
|
+
/**
|
|
215
|
+
* Gets the base URL for server-side storage service operations
|
|
216
|
+
*/
|
|
217
|
+
const getStorageBaseUrl = (targetArg) => {
|
|
218
|
+
return targetArg || STORAGE_SERVER_ORG;
|
|
219
|
+
};
|
|
220
|
+
exports.getStorageBaseUrl = getStorageBaseUrl;
|
|
221
|
+
/**
|
|
222
|
+
* Creates storage info object for signing server-side storage service requests
|
|
223
|
+
*/
|
|
224
|
+
const createStorageInfo = (storageType, action, url, worldName, baseParcel, parcels, key, value, address) => {
|
|
225
|
+
const timestamp = String(Date.now());
|
|
226
|
+
const metadata = (0, exports.buildStorageMetadata)(worldName, baseParcel);
|
|
227
|
+
const pathname = new URL(url).pathname;
|
|
228
|
+
const method = action === 'get' ? 'get' : action === 'set' ? 'put' : 'delete';
|
|
229
|
+
const payload = [method, pathname, timestamp, metadata].join(':').toLowerCase();
|
|
230
|
+
return {
|
|
231
|
+
storageType,
|
|
232
|
+
key,
|
|
233
|
+
value,
|
|
234
|
+
address,
|
|
235
|
+
world: worldName,
|
|
236
|
+
action,
|
|
237
|
+
targetUrl: url,
|
|
238
|
+
rootCID: payload,
|
|
239
|
+
timestamp,
|
|
240
|
+
metadata,
|
|
241
|
+
baseParcel,
|
|
242
|
+
parcels,
|
|
243
|
+
skipValidations: true,
|
|
244
|
+
debug: !!process.env.DEBUG,
|
|
245
|
+
isWorld: true
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
exports.createStorageInfo = createStorageInfo;
|
|
249
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/commands/storage/shared.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA2C;AAC3C,wCAA2C;AAC3C,oDAAiD;AACjD,6CAAwC;AAGxC,wDAA+B;AAG/B,6CAA4C;AAC5C,iDAAkD;AAClD,uEAAuE;AACvE,qDAAoE;AACpE,6CAAwC;AACxC,6EAAqE;AACrE,qEAAiE;AAGjE,MAAM,kBAAkB,GAAG,kCAAkC,CAAA;AAE7D;;GAEG;AACI,MAAM,yBAAyB,GAAG,KAAK,EAC5C,UAAyB,EACzB,WAAmB,EACnB,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AAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IACpC,MAAM,QAAQ,GAAG,IAAA,4BAAoB,EAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAC5D,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAA;IAEtC,MAAM,MAAM,GAAG,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;IAC7E,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAE/E,OAAO;QACL,WAAW;QACX,GAAG;QACH,KAAK;QACL,OAAO;QACP,KAAK,EAAE,SAAS;QAChB,MAAM;QACN,SAAS,EAAE,GAAG;QACd,OAAO,EAAE,OAAO;QAChB,SAAS;QACT,QAAQ;QACR,UAAU;QACV,OAAO;QACP,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK;QAC1B,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC,CAAA;AAnCY,QAAA,iBAAiB,qBAmC7B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Result } from 'arg';
|
|
2
|
+
import { CliComponents } from '../../components';
|
|
3
|
+
export declare const args: {
|
|
4
|
+
'--help': BooleanConstructor;
|
|
5
|
+
'-h': string;
|
|
6
|
+
'--dir': StringConstructor;
|
|
7
|
+
'--target': StringConstructor;
|
|
8
|
+
'-t': string;
|
|
9
|
+
'--port': NumberConstructor;
|
|
10
|
+
'-p': string;
|
|
11
|
+
'--https': BooleanConstructor;
|
|
12
|
+
'--no-browser': BooleanConstructor;
|
|
13
|
+
'-b': string;
|
|
14
|
+
'--value': StringConstructor;
|
|
15
|
+
'-v': string;
|
|
16
|
+
'--address': StringConstructor;
|
|
17
|
+
'-a': string;
|
|
18
|
+
'--confirm': BooleanConstructor;
|
|
19
|
+
'-c': string;
|
|
20
|
+
};
|
|
21
|
+
export interface Options {
|
|
22
|
+
args: Result<typeof args>;
|
|
23
|
+
components: CliComponents;
|
|
24
|
+
}
|
|
25
|
+
export type StorageType = 'env' | 'scene' | 'player';
|
|
26
|
+
export interface StorageInfo {
|
|
27
|
+
storageType?: StorageType;
|
|
28
|
+
key?: string;
|
|
29
|
+
value?: string;
|
|
30
|
+
address?: string;
|
|
31
|
+
world?: string;
|
|
32
|
+
action: 'get' | 'set' | 'delete' | 'clear';
|
|
33
|
+
targetUrl: string;
|
|
34
|
+
rootCID: string;
|
|
35
|
+
timestamp: string;
|
|
36
|
+
metadata: string;
|
|
37
|
+
baseParcel: string;
|
|
38
|
+
parcels: string[];
|
|
39
|
+
skipValidations: boolean;
|
|
40
|
+
debug: boolean;
|
|
41
|
+
isWorld: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface LinkerOptions {
|
|
44
|
+
linkerPort?: number;
|
|
45
|
+
openBrowser: boolean;
|
|
46
|
+
isHttps: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface AuthHeaders {
|
|
49
|
+
[key: string]: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ApiResponse {
|
|
52
|
+
ok: boolean;
|
|
53
|
+
status: number;
|
|
54
|
+
text: () => Promise<string>;
|
|
55
|
+
json: () => Promise<any>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.args = void 0;
|
|
4
|
+
const args_1 = require("../../logic/args");
|
|
5
|
+
exports.args = (0, args_1.declareArgs)({
|
|
6
|
+
'--help': Boolean,
|
|
7
|
+
'-h': '--help',
|
|
8
|
+
'--dir': String,
|
|
9
|
+
'--target': String,
|
|
10
|
+
'-t': '--target',
|
|
11
|
+
'--port': Number,
|
|
12
|
+
'-p': '--port',
|
|
13
|
+
'--https': Boolean,
|
|
14
|
+
'--no-browser': Boolean,
|
|
15
|
+
'-b': '--no-browser',
|
|
16
|
+
'--value': String,
|
|
17
|
+
'-v': '--value',
|
|
18
|
+
'--address': String,
|
|
19
|
+
'-a': '--address',
|
|
20
|
+
'--confirm': Boolean,
|
|
21
|
+
'-c': '--confirm'
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/commands/storage/types.ts"],"names":[],"mappings":";;;AAEA,2CAA8C;AAEjC,QAAA,IAAI,GAAG,IAAA,kBAAW,EAAC;IAC9B,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,OAAO;IAClB,cAAc,EAAE,OAAO;IACvB,IAAI,EAAE,cAAc;IACpB,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,MAAM;IACnB,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,OAAO;IACpB,IAAI,EAAE,WAAW;CAClB,CAAC,CAAA"}
|
|
@@ -97,8 +97,77 @@ export type Events = {
|
|
|
97
97
|
code: number;
|
|
98
98
|
creatorAddress: string;
|
|
99
99
|
};
|
|
100
|
+
'Storage Env Set Success': {
|
|
101
|
+
key: string;
|
|
102
|
+
};
|
|
103
|
+
'Storage Env Set Failure': {
|
|
104
|
+
key: string;
|
|
105
|
+
};
|
|
106
|
+
'Storage Env Delete Success': {
|
|
107
|
+
key: string;
|
|
108
|
+
};
|
|
109
|
+
'Storage Env Delete Failure': {
|
|
110
|
+
key: string;
|
|
111
|
+
};
|
|
112
|
+
'Storage Env Clear Success': Record<string, never>;
|
|
113
|
+
'Storage Env Clear Failure': Record<string, never>;
|
|
114
|
+
'Storage Scene Get Success': {
|
|
115
|
+
key: string;
|
|
116
|
+
};
|
|
117
|
+
'Storage Scene Get Failure': {
|
|
118
|
+
key: string;
|
|
119
|
+
};
|
|
120
|
+
'Storage Scene Set Success': {
|
|
121
|
+
key: string;
|
|
122
|
+
};
|
|
123
|
+
'Storage Scene Set Failure': {
|
|
124
|
+
key: string;
|
|
125
|
+
};
|
|
126
|
+
'Storage Scene Delete Success': {
|
|
127
|
+
key: string;
|
|
128
|
+
};
|
|
129
|
+
'Storage Scene Delete Failure': {
|
|
130
|
+
key: string;
|
|
131
|
+
};
|
|
132
|
+
'Storage Scene Clear Success': Record<string, never>;
|
|
133
|
+
'Storage Scene Clear Failure': Record<string, never>;
|
|
134
|
+
'Storage Player Get Success': {
|
|
135
|
+
key: string;
|
|
136
|
+
address: string;
|
|
137
|
+
};
|
|
138
|
+
'Storage Player Get Failure': {
|
|
139
|
+
key: string;
|
|
140
|
+
address: string;
|
|
141
|
+
};
|
|
142
|
+
'Storage Player Set Success': {
|
|
143
|
+
key: string;
|
|
144
|
+
address: string;
|
|
145
|
+
};
|
|
146
|
+
'Storage Player Set Failure': {
|
|
147
|
+
key: string;
|
|
148
|
+
address: string;
|
|
149
|
+
};
|
|
150
|
+
'Storage Player Delete Success': {
|
|
151
|
+
key: string;
|
|
152
|
+
address: string;
|
|
153
|
+
};
|
|
154
|
+
'Storage Player Delete Failure': {
|
|
155
|
+
key: string;
|
|
156
|
+
address: string;
|
|
157
|
+
};
|
|
158
|
+
'Storage Player Clear Success': {
|
|
159
|
+
address: string;
|
|
160
|
+
};
|
|
161
|
+
'Storage Player Clear Failure': {
|
|
162
|
+
address: string;
|
|
163
|
+
};
|
|
164
|
+
'Storage Player Clear All Success': Record<string, never>;
|
|
165
|
+
'Storage Player Clear All Failure': Record<string, never>;
|
|
166
|
+
};
|
|
167
|
+
export type CreateAnalyticsOptions = {
|
|
168
|
+
writeKey?: string;
|
|
100
169
|
};
|
|
101
|
-
export declare function createAnalyticsComponent(components: Pick<CliComponents, 'config' | 'logger' | 'fs'
|
|
170
|
+
export declare function createAnalyticsComponent(components: Pick<CliComponents, 'config' | 'logger' | 'fs'>, options?: CreateAnalyticsOptions): Promise<IAnalyticsComponent | {
|
|
102
171
|
get(): Analytics;
|
|
103
172
|
track: <T extends keyof Events>(eventName: T, eventProps: Events[T]) => void;
|
|
104
173
|
stop(): Promise<void>;
|
|
@@ -10,14 +10,15 @@ const noopAnalytics = {
|
|
|
10
10
|
track() { },
|
|
11
11
|
async stop() { }
|
|
12
12
|
};
|
|
13
|
-
async function createAnalyticsComponent(components) {
|
|
13
|
+
async function createAnalyticsComponent(components, options) {
|
|
14
14
|
const analyticsEnabled = (await (0, config_1.readStringConfig)(components, 'DCL_DISABLE_ANALYTICS')) !== 'true';
|
|
15
15
|
if (!analyticsEnabled) {
|
|
16
16
|
return noopAnalytics;
|
|
17
17
|
}
|
|
18
18
|
const USER_ID = 'sdk-commands-user';
|
|
19
19
|
let anonId = await (0, config_1.readStringConfig)(components, 'DCL_ANON_ID');
|
|
20
|
-
const
|
|
20
|
+
const writeKey = options?.writeKey ?? (0, config_2.getSegmentKey)();
|
|
21
|
+
const analytics = new analytics_node_1.Analytics({ writeKey });
|
|
21
22
|
if (!anonId) {
|
|
22
23
|
anonId = (0, crypto_1.randomUUID)();
|
|
23
24
|
await (0, config_1.writeGlobalConfig)(components, 'DCL_ANON_ID', anonId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/components/analytics.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/components/analytics.ts"],"names":[],"mappings":";;AAqKA,4DAgFC;AArPD,mCAAmC;AACnC,4DAAmD;AAGnD,+BAA8B;AAC9B,qCAAkF;AAClF,4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CAAA;IAE1F,+DAA+D;IAC/D,MAAM,uBAAuB,GAAG;QAC9B,EAAE,EAAE,OAAO,CAAC,QAAQ;QACpB,WAAW,EAAE,OAAO,CAAC,OAAO;QAC5B,UAAU,EAAE,MAAM,IAAA,8BAAqB,GAAE;QACzC,IAAI,EAAE,IAAA,aAAI,GAAE;QACZ,QAAQ,EAAE,IAAA,iBAAQ,GAAE;QACpB,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,IAAI;QACnD,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,IAAI;QAC3C,GAAG,EAAE;YACH,UAAU,EAAE,MAAM;YAClB,cAAc,EAAE,UAAU;SAC3B;KACF,CAAA;IAED,SAAS,KAAK,CAAyB,SAAY,EAAE,UAAqB;QACxE,SAAS,CAAC,KAAK,CAAC;YACd,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE;gBACV,GAAG,UAAU;gBACb,GAAG,uBAAuB;aAC3B;SACF,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,GAAG;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,KAAK;QACL,KAAK,CAAC,IAAI;YACR,iFAAiF;YACjF,+EAA+E;YAC/E,oFAAoF;YACpF,MAAM,SAAS,CAAC,aAAa,EAAE,CAAA;QACjC,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { Router } from '@well-known-components/http-server';
|
|
2
|
+
import { IHttpServerComponent } from '@well-known-components/interfaces';
|
|
2
3
|
import { ChainId } from '@dcl/schemas';
|
|
3
4
|
import { AuthChain } from '@dcl/crypto';
|
|
4
5
|
import { CliComponents } from '../components';
|
|
6
|
+
export declare function forwardedHeaders(request: IHttpServerComponent.IRequest, overrides: Record<string, string>): Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Builds the headers returned to the linker-dapp client from a proxied fetch response.
|
|
9
|
+
*
|
|
10
|
+
* undici transparently decompresses the body but leaves the upstream `content-encoding` and
|
|
11
|
+
* `content-length` in place; forwarding them would make the client re-decode an already-decoded
|
|
12
|
+
* body or truncate it at the wrong length, so both are dropped and the framing is recomputed
|
|
13
|
+
* downstream.
|
|
14
|
+
*/
|
|
15
|
+
export declare function proxiedResponseHeaders(headers: Headers): Record<string, string>;
|
|
5
16
|
/**
|
|
6
17
|
* Set common routes to use on Linker dApp
|
|
7
18
|
* @param components Server components
|
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forwardedHeaders = forwardedHeaders;
|
|
4
|
+
exports.proxiedResponseHeaders = proxiedResponseHeaders;
|
|
3
5
|
exports.setRoutes = setRoutes;
|
|
4
6
|
const path_1 = require("path");
|
|
5
7
|
const stream_1 = require("stream");
|
|
6
8
|
const undici_1 = require("undici");
|
|
7
9
|
const http_server_1 = require("@well-known-components/http-server");
|
|
10
|
+
const STRIPPED_REQUEST_HEADERS = new Set([
|
|
11
|
+
'connection',
|
|
12
|
+
'content-length',
|
|
13
|
+
'keep-alive',
|
|
14
|
+
'proxy-authenticate',
|
|
15
|
+
'proxy-authorization',
|
|
16
|
+
'te',
|
|
17
|
+
'trailer',
|
|
18
|
+
'transfer-encoding',
|
|
19
|
+
'upgrade'
|
|
20
|
+
]);
|
|
21
|
+
function forwardedHeaders(request, overrides) {
|
|
22
|
+
const overriddenNames = new Set(Object.keys(overrides).map((name) => name.toLowerCase()));
|
|
23
|
+
const forwarded = {};
|
|
24
|
+
for (const [key, value] of request.headers) {
|
|
25
|
+
const name = key.toLowerCase();
|
|
26
|
+
if (STRIPPED_REQUEST_HEADERS.has(name) || overriddenNames.has(name))
|
|
27
|
+
continue;
|
|
28
|
+
forwarded[name] = value;
|
|
29
|
+
}
|
|
30
|
+
return { ...forwarded, ...overrides };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Builds the headers returned to the linker-dapp client from a proxied fetch response.
|
|
34
|
+
*
|
|
35
|
+
* undici transparently decompresses the body but leaves the upstream `content-encoding` and
|
|
36
|
+
* `content-length` in place; forwarding them would make the client re-decode an already-decoded
|
|
37
|
+
* body or truncate it at the wrong length, so both are dropped and the framing is recomputed
|
|
38
|
+
* downstream.
|
|
39
|
+
*/
|
|
40
|
+
function proxiedResponseHeaders(headers) {
|
|
41
|
+
const result = {};
|
|
42
|
+
for (const [key, value] of headers) {
|
|
43
|
+
const name = key.toLowerCase();
|
|
44
|
+
if (['content-encoding', 'content-length'].includes(name))
|
|
45
|
+
continue;
|
|
46
|
+
result[name] = value;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
8
50
|
/**
|
|
9
51
|
* Set common routes to use on Linker dApp
|
|
10
52
|
* @param components Server components
|
|
@@ -15,8 +57,6 @@ function setRoutes(components, info, mainRoute = '/') {
|
|
|
15
57
|
const { fs } = components;
|
|
16
58
|
const router = new http_server_1.Router();
|
|
17
59
|
const linkerDapp = (0, path_1.dirname)(require.resolve('@dcl/linker-dapp/package.json'));
|
|
18
|
-
// Dispatcher used by the /auth proxy below to skip TLS verification, mirroring the
|
|
19
|
-
// previous `new https.Agent({ rejectUnauthorized: false })` behavior with native fetch.
|
|
20
60
|
const insecureDispatcher = new undici_1.Agent({ connect: { rejectUnauthorized: false } });
|
|
21
61
|
router.get(mainRoute, async () => ({
|
|
22
62
|
headers: { 'Content-Type': 'text/html' },
|
|
@@ -36,44 +76,26 @@ function setRoutes(components, info, mainRoute = '/') {
|
|
|
36
76
|
body: fs.createReadStream((0, path_1.resolve)(linkerDapp, 'assets', ctx.params.path))
|
|
37
77
|
};
|
|
38
78
|
});
|
|
39
|
-
/* This route acts as a proxy to handle the auth flow with the Decentraland auth dApp,
|
|
40
|
-
* because this latest one validates the communication be on the same domain.
|
|
41
|
-
*/
|
|
42
79
|
router.get('/auth/(.*)', async (ctx) => {
|
|
43
80
|
try {
|
|
44
81
|
const domain = 'decentraland.org';
|
|
45
82
|
const url = `https://${domain}${ctx.url.pathname}${ctx.url.search}`;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
duplex: 'half', // Required by native fetch when streaming a request body.
|
|
57
|
-
dispatcher: insecureDispatcher // Skip TLS verification.
|
|
83
|
+
const response = await components.fetch.fetch(url, {
|
|
84
|
+
method: ctx.request.method,
|
|
85
|
+
headers: forwardedHeaders(ctx.request, {
|
|
86
|
+
host: domain,
|
|
87
|
+
referer: url,
|
|
88
|
+
origin: url
|
|
89
|
+
}),
|
|
90
|
+
body: ctx.request.body,
|
|
91
|
+
duplex: 'half',
|
|
92
|
+
dispatcher: insecureDispatcher
|
|
58
93
|
});
|
|
59
|
-
|
|
60
|
-
// place; forwarding them would make the client re-decode or truncate the body.
|
|
61
|
-
// The headers on a fetch() Response are immutable (mutating them throws
|
|
62
|
-
// `TypeError: immutable`), so build a filtered copy instead of deleting in place.
|
|
63
|
-
const headers = {};
|
|
64
|
-
for (const [key, value] of resp.headers) {
|
|
65
|
-
const name = key.toLowerCase();
|
|
66
|
-
if (name === 'content-encoding' || name === 'content-length')
|
|
67
|
-
continue;
|
|
68
|
-
headers[key] = value;
|
|
69
|
-
}
|
|
70
|
-
// Return the proxied response, including body, status, and headers.
|
|
71
|
-
// `resp.body` is a web ReadableStream; convert it to a Node stream so the
|
|
72
|
-
// http-server can pipe it (it only handles Node streams / Buffers / strings).
|
|
94
|
+
const responseHeaders = proxiedResponseHeaders(response.headers);
|
|
73
95
|
return {
|
|
74
|
-
body:
|
|
75
|
-
status:
|
|
76
|
-
headers
|
|
96
|
+
body: response.body ? stream_1.Readable.fromWeb(response.body) : undefined,
|
|
97
|
+
status: response.status,
|
|
98
|
+
headers: responseHeaders
|
|
77
99
|
};
|
|
78
100
|
}
|
|
79
101
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/linker-dapp/routes.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/linker-dapp/routes.ts"],"names":[],"mappings":";;AAsBA,4CAcC;AAUD,wDAUC;AAQD,8BA0EC;AA1ID,+BAAuC;AACvC,mCAAiC;AACjC,mCAA8B;AAC9B,oEAA2D;AAO3D,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC;IACvC,YAAY;IACZ,gBAAgB;IAChB,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,IAAI;IACJ,SAAS;IACT,mBAAmB;IACnB,SAAS;CACV,CAAC,CAAA;AAEF,SAAgB,gBAAgB,CAC9B,OAAsC,EACtC,SAAiC;IAEjC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IACzF,MAAM,SAAS,GAA2B,EAAE,CAAA;IAE5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;QAC9B,IAAI,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAQ;QAC7E,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IACzB,CAAC;IAED,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,SAAS,EAAE,CAAA;AACvC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAgB;IACrD,MAAM,MAAM,GAA2B,EAAE,CAAA;IAEzC,KAAK,MAA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AAU,CAAA;QACnB,KAAK,IAAI;YACP,OAAO,wBAAwB,CAAA;QACjC,KAAK,OAAO,CAAC;QACb;YACE,OAAO,YAAY,CAAA;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthChain } from '@dcl/crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Creates HTTP headers from an auth chain following ADR-44 (Signed Fetch) format.
|
|
4
|
+
* Used for authenticated requests to Decentraland services.
|
|
5
|
+
*
|
|
6
|
+
* @param authChain - The authentication chain from the linker dApp or wallet signing
|
|
7
|
+
* @param timestamp - Unix timestamp of the request
|
|
8
|
+
* @param metadata - JSON string with request metadata (e.g., { key, value, world })
|
|
9
|
+
* @returns Record of HTTP headers to include in the request
|
|
10
|
+
*/
|
|
11
|
+
export declare function createAuthChainHeaders(authChain: AuthChain, timestamp: string, metadata: string): Record<string, string>;
|