decentraland-dapps 16.19.3 → 16.20.0
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/lib/entities.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuthIdentity } from '@dcl/crypto';
|
|
1
2
|
import { Entity, EntityType } from '@dcl/schemas/dist/platform/entity';
|
|
2
3
|
import { ProfileEntity } from './types';
|
|
3
4
|
export declare class EntitiesOperator {
|
|
@@ -7,14 +8,6 @@ export declare class EntitiesOperator {
|
|
|
7
8
|
private catalystContentClientWithoutGbCollector;
|
|
8
9
|
private readonly peerAPI;
|
|
9
10
|
constructor(peerUrl: string, peerWithNoGbCollectorUrl?: string | undefined);
|
|
10
|
-
/**
|
|
11
|
-
* Uses the provider to request the user for a signature to
|
|
12
|
-
* deploy an entity.
|
|
13
|
-
*
|
|
14
|
-
* @param address - The address of the deployer of the entity.
|
|
15
|
-
* @param entityId - The entity id that it's going to be deployed.
|
|
16
|
-
*/
|
|
17
|
-
private authenticateEntityDeployment;
|
|
18
11
|
/**
|
|
19
12
|
* Gets the first {@link ProfileEntity} out of multiple possible profile entities or
|
|
20
13
|
* returns the last one in case the given address has no profile entities.
|
|
@@ -32,5 +25,5 @@ export declare class EntitiesOperator {
|
|
|
32
25
|
* @param entityType - The type of the entity.
|
|
33
26
|
* @param address - The owner / soon to be owner of the entity.
|
|
34
27
|
*/
|
|
35
|
-
deployEntityWithoutNewFiles(entityMetadata: Entity['metadata'], hashesByKey: Map<string, string>, entityType: EntityType, pointer: string,
|
|
28
|
+
deployEntityWithoutNewFiles(entityMetadata: Entity['metadata'], hashesByKey: Map<string, string>, entityType: EntityType, pointer: string, identity: AuthIdentity): Promise<any>;
|
|
36
29
|
}
|
package/dist/lib/entities.js
CHANGED
|
@@ -10,41 +10,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EntitiesOperator = void 0;
|
|
13
|
-
const ethers_1 = require("ethers");
|
|
14
13
|
const crypto_1 = require("@dcl/crypto");
|
|
15
14
|
const ContentClient_1 = require("dcl-catalyst-client/dist/client/ContentClient");
|
|
16
15
|
const DeploymentBuilder_1 = require("dcl-catalyst-client/dist/client/utils/DeploymentBuilder");
|
|
17
|
-
const eth_1 = require("./eth");
|
|
18
16
|
const peer_1 = require("./peer");
|
|
19
17
|
const fetch_component_1 = require("@well-known-components/fetch-component");
|
|
20
18
|
class EntitiesOperator {
|
|
21
19
|
constructor(peerUrl, peerWithNoGbCollectorUrl) {
|
|
22
20
|
this.peerUrl = peerUrl;
|
|
23
21
|
this.peerWithNoGbCollectorUrl = peerWithNoGbCollectorUrl;
|
|
24
|
-
this.catalystContentClient = (0, ContentClient_1.createContentClient)({
|
|
22
|
+
this.catalystContentClient = (0, ContentClient_1.createContentClient)({
|
|
23
|
+
url: `${peerUrl}/content`,
|
|
24
|
+
fetcher: (0, fetch_component_1.createFetchComponent)()
|
|
25
|
+
});
|
|
25
26
|
this.catalystContentClientWithoutGbCollector = peerWithNoGbCollectorUrl
|
|
26
|
-
? (0, ContentClient_1.createContentClient)({
|
|
27
|
+
? (0, ContentClient_1.createContentClient)({
|
|
28
|
+
url: `${peerUrl}/content`,
|
|
29
|
+
fetcher: (0, fetch_component_1.createFetchComponent)()
|
|
30
|
+
})
|
|
27
31
|
: null;
|
|
28
32
|
this.peerAPI = new peer_1.PeerAPI(peerUrl);
|
|
29
33
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Uses the provider to request the user for a signature to
|
|
32
|
-
* deploy an entity.
|
|
33
|
-
*
|
|
34
|
-
* @param address - The address of the deployer of the entity.
|
|
35
|
-
* @param entityId - The entity id that it's going to be deployed.
|
|
36
|
-
*/
|
|
37
|
-
authenticateEntityDeployment(address, entityId) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const provider = yield (0, eth_1.getConnectedProvider)();
|
|
40
|
-
if (!provider)
|
|
41
|
-
throw new Error("The provider couldn't be retrieved when creating the auth chain");
|
|
42
|
-
const eth = new ethers_1.ethers.providers.Web3Provider(provider);
|
|
43
|
-
const personal = eth.getSigner(address);
|
|
44
|
-
const signature = yield personal.signMessage(entityId);
|
|
45
|
-
return crypto_1.Authenticator.createSimpleAuthChain(entityId, address, signature);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
34
|
/**
|
|
49
35
|
* Gets the first {@link ProfileEntity} out of multiple possible profile entities or
|
|
50
36
|
* returns the last one in case the given address has no profile entities.
|
|
@@ -70,7 +56,7 @@ class EntitiesOperator {
|
|
|
70
56
|
* @param entityType - The type of the entity.
|
|
71
57
|
* @param address - The owner / soon to be owner of the entity.
|
|
72
58
|
*/
|
|
73
|
-
deployEntityWithoutNewFiles(entityMetadata, hashesByKey, entityType, pointer,
|
|
59
|
+
deployEntityWithoutNewFiles(entityMetadata, hashesByKey, entityType, pointer, identity) {
|
|
74
60
|
var _a, _b;
|
|
75
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
62
|
const options = {
|
|
@@ -83,7 +69,7 @@ class EntitiesOperator {
|
|
|
83
69
|
const catalystContentClient = (_a = this.catalystContentClientWithoutGbCollector) !== null && _a !== void 0 ? _a : this.catalystContentClient;
|
|
84
70
|
const contentUrl = (_b = this.peerWithNoGbCollectorUrl) !== null && _b !== void 0 ? _b : this.peerUrl;
|
|
85
71
|
const entityToDeploy = yield (0, DeploymentBuilder_1.buildEntityWithoutNewFiles)((0, fetch_component_1.createFetchComponent)(), Object.assign({ contentUrl: `${contentUrl}/content` }, options));
|
|
86
|
-
const authChain =
|
|
72
|
+
const authChain = crypto_1.Authenticator.signPayload(identity, entityToDeploy.entityId);
|
|
87
73
|
return catalystContentClient.deploy(Object.assign(Object.assign({}, entityToDeploy), { authChain }));
|
|
88
74
|
});
|
|
89
75
|
}
|
package/dist/lib/entities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../src/lib/entities.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../src/lib/entities.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAyD;AAEzD,iFAGsD;AAEtD,+FAAoG;AAEpG,iCAAgC;AAChC,4EAA6E;AAE7E,MAAa,gBAAgB;IAM3B,YACU,OAAe,EACf,wBAAiC;QADjC,YAAO,GAAP,OAAO,CAAQ;QACf,6BAAwB,GAAxB,wBAAwB,CAAS;QAEzC,IAAI,CAAC,qBAAqB,GAAG,IAAA,mCAAmB,EAAC;YAC/C,GAAG,EAAE,GAAG,OAAO,UAAU;YACzB,OAAO,EAAE,IAAA,sCAAoB,GAAE;SAChC,CAAC,CAAA;QACF,IAAI,CAAC,uCAAuC,GAAG,wBAAwB;YACrE,CAAC,CAAC,IAAA,mCAAmB,EAAC;gBAClB,GAAG,EAAE,GAAG,OAAO,UAAU;gBACzB,OAAO,EAAE,IAAA,sCAAoB,GAAE;aAChC,CAAC;YACJ,CAAC,CAAC,IAAI,CAAA;QACR,IAAI,CAAC,OAAO,GAAG,IAAI,cAAO,CAAC,OAAO,CAAC,CAAA;IACrC,CAAC;IAED;;;;;OAKG;IACG,gBAAgB,CAAC,OAAe;;YACpC,MAAM,QAAQ,GAAa,MAAM,IAAI,CAAC,qBAAqB,CAAC,uBAAuB,CACjF,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CACxB,CAAA;YAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;gBACvB,OAAO,QAAQ,CAAC,CAAC,CAAkB,CAAA;aACpC;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAA;QAC/C,CAAC;KAAA;IAED;;;;;;;;;OASG;IACG,2BAA2B,CAC/B,cAAkC,EAClC,WAAgC,EAChC,UAAsB,EACtB,OAAe,EACf,QAAsB;;;YAEtB,MAAM,OAAO,GAAmC;gBAC9C,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,cAAc;gBACxB,WAAW;gBACX,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAA;YAED,MAAM,qBAAqB,GACzB,MAAA,IAAI,CAAC,uCAAuC,mCAAI,IAAI,CAAC,qBAAqB,CAAA;YAC5E,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,wBAAwB,mCAAI,IAAI,CAAC,OAAO,CAAA;YAEhE,MAAM,cAAc,GAAG,MAAM,IAAA,8CAA0B,EACrD,IAAA,sCAAoB,GAAE,kBACpB,UAAU,EAAE,GAAG,UAAU,UAAU,IAAK,OAAO,EAClD,CAAA;YAED,MAAM,SAAS,GAAG,sBAAa,CAAC,WAAW,CACzC,QAAQ,EACR,cAAc,CAAC,QAAQ,CACxB,CAAA;YAED,OAAO,qBAAqB,CAAC,MAAM,iCAC9B,cAAc,KACjB,SAAS,IACT,CAAA;;KACH;CACF;AArFD,4CAqFC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { AuthIdentity } from '@dcl/crypto';
|
|
2
|
+
export declare const NO_IDENTITY_FOUND_ERROR_MESSAGE = "No identity found";
|
|
1
3
|
declare type CreateProfileSagaOptions = {
|
|
4
|
+
getIdentity: () => AuthIdentity | undefined;
|
|
2
5
|
peerUrl: string;
|
|
3
6
|
peerWithNoGbCollectorUrl?: string;
|
|
4
7
|
};
|
|
5
|
-
export declare function createProfileSaga({ peerUrl, peerWithNoGbCollectorUrl }: CreateProfileSagaOptions): () => Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
8
|
+
export declare function createProfileSaga({ getIdentity, peerUrl, peerWithNoGbCollectorUrl }: CreateProfileSagaOptions): () => Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
6
9
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createProfileSaga = void 0;
|
|
3
|
+
exports.createProfileSaga = exports.NO_IDENTITY_FOUND_ERROR_MESSAGE = void 0;
|
|
4
4
|
const effects_1 = require("redux-saga/effects");
|
|
5
5
|
const entity_1 = require("@dcl/schemas/dist/platform/entity");
|
|
6
6
|
const peer_1 = require("../../lib/peer");
|
|
@@ -8,7 +8,8 @@ const entities_1 = require("../../lib/entities");
|
|
|
8
8
|
const actions_1 = require("../wallet/actions");
|
|
9
9
|
const actions_2 = require("./actions");
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
|
-
|
|
11
|
+
exports.NO_IDENTITY_FOUND_ERROR_MESSAGE = 'No identity found';
|
|
12
|
+
function createProfileSaga({ getIdentity, peerUrl, peerWithNoGbCollectorUrl }) {
|
|
12
13
|
const peerApi = new peer_1.PeerAPI(peerUrl);
|
|
13
14
|
const entities = new entities_1.EntitiesOperator(peerUrl, peerWithNoGbCollectorUrl);
|
|
14
15
|
function* profileSaga() {
|
|
@@ -68,7 +69,13 @@ function createProfileSaga({ peerUrl, peerWithNoGbCollectorUrl }) {
|
|
|
68
69
|
const profileMetadata = {
|
|
69
70
|
avatars: [newAvatar, ...profileWithContentHashes.avatars.slice(1)]
|
|
70
71
|
};
|
|
71
|
-
|
|
72
|
+
const identity = getIdentity();
|
|
73
|
+
if (identity) {
|
|
74
|
+
yield (0, effects_1.call)([entities, 'deployEntityWithoutNewFiles'], profileMetadata, (0, utils_1.getHashesByKeyMap)(newAvatar), entity_1.EntityType.PROFILE, address, identity);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
throw new Error(exports.NO_IDENTITY_FOUND_ERROR_MESSAGE);
|
|
78
|
+
}
|
|
72
79
|
return newAvatar;
|
|
73
80
|
}
|
|
74
81
|
return profileSaga;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sagas.js","sourceRoot":"","sources":["../../../src/modules/profile/sagas.ts"],"names":[],"mappings":";;;AAAA,gDAAqE;
|
|
1
|
+
{"version":3,"file":"sagas.js","sourceRoot":"","sources":["../../../src/modules/profile/sagas.ts"],"names":[],"mappings":";;;AAAA,gDAAqE;AAGrE,8DAA8D;AAC9D,yCAAwC;AACxC,iDAAqD;AACrD,+CAK0B;AAC1B,uCAckB;AAClB,mCAA0E;AAG7D,QAAA,+BAA+B,GAAG,mBAAmB,CAAA;AAQlE,SAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,OAAO,EACP,wBAAwB,EACC;IACzB,MAAM,OAAO,GAAG,IAAI,cAAO,CAAC,OAAO,CAAC,CAAA;IACpC,MAAM,QAAQ,GAAG,IAAI,2BAAgB,CAAC,OAAO,EAAE,wBAAwB,CAAC,CAAA;IAExE,QAAQ,CAAC,CAAC,WAAW;QACnB,MAAM,IAAA,mBAAS,EAAC,8BAAoB,EAAE,wBAAwB,CAAC,CAAA;QAC/D,MAAM,IAAA,mBAAS,EACb,gDAAsC,EACtC,2BAA2B,CAC5B,CAAA;QACD,MAAM,IAAA,mBAAS,EAAC,0CAAgC,EAAE,cAAc,CAAC,CAAA;QACjE,MAAM,IAAA,oBAAU,EAAC,gCAAsB,EAAE,YAAY,CAAC,CAAA;QACtD,MAAM,IAAA,oBAAU,EAAC,wBAAc,EAAE,YAAY,CAAC,CAAA;IAChD,CAAC;IAED,QAAQ,CAAC,CAAC,wBAAwB,CAAC,MAAgC;QACjE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAA;QAClC,IAAI;YACF,MAAM,OAAO,GAAY,MAAM,IAAA,cAAI,EAAC,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAA;YACvE,MAAM,IAAA,aAAG,EAAC,IAAA,4BAAkB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;SAChD;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAA,aAAG,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