@dcl/content-validator 1.0.0-20220104134007.commit-80072ed → 1.0.0-20220105210353.commit-baf07b8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/access.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKxC;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,UAcpB,CAAA"}
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/access.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAaxC;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,UAOpB,CAAA"}
@@ -2,10 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.access = void 0;
4
4
  const dcl_catalyst_commons_1 = require("dcl-catalyst-commons");
5
- const __1 = require("../..");
6
5
  const profiles_1 = require("./profiles");
7
6
  const scenes_1 = require("./scenes");
7
+ const stores_1 = require("./stores");
8
8
  const wearables_1 = require("./wearables");
9
+ const accessCheckers = {
10
+ [dcl_catalyst_commons_1.EntityType.PROFILE]: profiles_1.profiles,
11
+ [dcl_catalyst_commons_1.EntityType.SCENE]: scenes_1.scenes,
12
+ [dcl_catalyst_commons_1.EntityType.WEARABLE]: wearables_1.wearables,
13
+ [dcl_catalyst_commons_1.EntityType.STORE]: stores_1.stores,
14
+ };
9
15
  /**
10
16
  * Validate that the pointers are valid, and that the Ethereum address has write access to them
11
17
  * @public
@@ -13,16 +19,8 @@ const wearables_1 = require("./wearables");
13
19
  exports.access = {
14
20
  validate: async (args) => {
15
21
  const type = args.deployment.entity.type;
16
- switch (type) {
17
- case dcl_catalyst_commons_1.EntityType.SCENE:
18
- return scenes_1.scenes.validate(args);
19
- case dcl_catalyst_commons_1.EntityType.PROFILE:
20
- return profiles_1.profiles.validate(args);
21
- case dcl_catalyst_commons_1.EntityType.WEARABLE:
22
- return wearables_1.wearables.validate(args);
23
- default:
24
- return (0, __1.validationFailed)('Unknown type provided');
25
- }
22
+ const accessChecker = accessCheckers[type];
23
+ return accessChecker.validate(args);
26
24
  },
27
25
  };
28
26
  //# sourceMappingURL=access.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"access.js","sourceRoot":"","sources":["../../../src/validations/access-checker/access.ts"],"names":[],"mappings":";;;AAAA,+DAAiD;AACjD,6BAAwC;AAExC,yCAAqC;AACrC,qCAAiC;AACjC,2CAAuC;AAEvC;;;GAGG;AACU,QAAA,MAAM,GAAe;IAChC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAA;QACxC,QAAQ,IAAI,EAAE;YACZ,KAAK,iCAAU,CAAC,KAAK;gBACnB,OAAO,eAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAC9B,KAAK,iCAAU,CAAC,OAAO;gBACrB,OAAO,mBAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAChC,KAAK,iCAAU,CAAC,QAAQ;gBACtB,OAAO,qBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YACjC;gBACE,OAAO,IAAA,oBAAgB,EAAC,uBAAuB,CAAC,CAAA;SACnD;IACH,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"access.js","sourceRoot":"","sources":["../../../src/validations/access-checker/access.ts"],"names":[],"mappings":";;;AAAA,+DAAiD;AAGjD,yCAAqC;AACrC,qCAAiC;AACjC,qCAAiC;AACjC,2CAAuC;AAEvC,MAAM,cAAc,GAAG;IACrB,CAAC,iCAAU,CAAC,OAAO,CAAC,EAAE,mBAAQ;IAC9B,CAAC,iCAAU,CAAC,KAAK,CAAC,EAAE,eAAM;IAC1B,CAAC,iCAAU,CAAC,QAAQ,CAAC,EAAE,qBAAS;IAChC,CAAC,iCAAU,CAAC,KAAK,CAAC,EAAE,eAAM;CAC3B,CAAA;AAED;;;GAGG;AACU,QAAA,MAAM,GAAe;IAChC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAA;QACxC,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QAE1C,OAAO,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;CACF,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Validation } from '../../types';
2
+ /**
3
+ * Validate that the pointers are valid, and that the Ethereum address has write access to them
4
+ * @public
5
+ */
6
+ export declare const stores: Validation;
7
+ //# sourceMappingURL=stores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/stores.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,UAAU,EAAoB,MAAM,aAAa,CAAA;AAU9D;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,UAuBpB,CAAA"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stores = void 0;
4
+ const urn_resolver_1 = require("@dcl/urn-resolver");
5
+ const types_1 = require("../../types");
6
+ const parseUrnNoFail = async (pointer) => {
7
+ try {
8
+ const parsed = await (0, urn_resolver_1.parseUrn)(pointer);
9
+ if (!parsed || parsed?.type !== 'off-chain')
10
+ return undefined;
11
+ return parsed;
12
+ }
13
+ catch { }
14
+ };
15
+ /**
16
+ * Validate that the pointers are valid, and that the Ethereum address has write access to them
17
+ * @public
18
+ */
19
+ exports.stores = {
20
+ validate: async ({ deployment, externalCalls }) => {
21
+ const pointers = deployment.entity.pointers;
22
+ const ethAddress = externalCalls.ownerAddress(deployment.auditInfo);
23
+ if (pointers.length !== 1)
24
+ return (0, types_1.validationFailed)(`Only one pointer is allowed when you create a Store. Received: ${pointers}`);
25
+ const pointer = pointers[0].toLowerCase();
26
+ const offchainAsset = await parseUrnNoFail(pointer);
27
+ if (!offchainAsset)
28
+ return (0, types_1.validationFailed)(`Store pointers should be a urn, for example (urn:decentraland:off-chain:marketplace-stores:{address}). Invalid pointer: ${pointer}`);
29
+ if (offchainAsset.id !== ethAddress)
30
+ return (0, types_1.validationFailed)(`You can only alter your own store. The pointer address and the signer address are different (address:${offchainAsset.id.toLowerCase()} signer: ${ethAddress.toLowerCase()}).`);
31
+ return types_1.OK;
32
+ },
33
+ };
34
+ //# sourceMappingURL=stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.js","sourceRoot":"","sources":["../../../src/validations/access-checker/stores.ts"],"names":[],"mappings":";;;AAAA,oDAA2D;AAE3D,uCAA8D;AAE9D,MAAM,cAAc,GAAG,KAAK,EAAE,OAAgB,EAAsC,EAAE;IACpF,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,IAAA,uBAAQ,EAAC,OAAO,CAAC,CAAA;QACtC,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE,IAAI,KAAK,WAAW;YAAE,OAAO,SAAS,CAAA;QAC7D,OAAO,MAAM,CAAA;KACd;IAAC,MAAM,GAAE;AACZ,CAAC,CAAA;AAED;;;GAGG;AACU,QAAA,MAAM,GAAe;IAChC,QAAQ,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,EAAE;QAChD,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAA;QAC3C,MAAM,UAAU,GAAG,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;QAEnE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YACvB,OAAO,IAAA,wBAAgB,EAAC,kEAAkE,QAAQ,EAAE,CAAC,CAAA;QAEvG,MAAM,OAAO,GAAY,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;QAClD,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAA;QAEnD,IAAI,CAAC,aAAa;YAChB,OAAO,IAAA,wBAAgB,EACrB,2HAA2H,OAAO,EAAE,CACrI,CAAA;QAEH,IAAI,aAAa,CAAC,EAAE,KAAK,UAAU;YACjC,OAAO,IAAA,wBAAgB,EACrB,wGAAwG,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,UAAU,CAAC,WAAW,EAAE,IAAI,CAC/K,CAAA;QAEH,OAAO,UAAE,CAAA;IACX,CAAC;CACF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"metadata-schema.d.ts","sourceRoot":"","sources":["../../src/validations/metadata-schema.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,QAAQ,+BAYnB,CAAA"}
1
+ {"version":3,"file":"metadata-schema.d.ts","sourceRoot":"","sources":["../../src/validations/metadata-schema.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,QAAQ,+BASnB,CAAA"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.metadata = void 0;
4
- const schemas_1 = require("@dcl/schemas");
5
4
  const dcl_catalyst_commons_1 = require("dcl-catalyst-commons");
6
5
  const _1 = require(".");
7
6
  const types_1 = require("../types");
@@ -13,13 +12,8 @@ exports.metadata = (0, types_1.conditionalValidation)({
13
12
  predicate: ({ deployment }) => {
14
13
  if (deployment.entity.timestamp <= _1.ADR_X_TIMESTAMP)
15
14
  return true;
16
- // todo: move this map to catalyst-commons
17
- const validate = {
18
- [dcl_catalyst_commons_1.EntityType.PROFILE]: schemas_1.Profile.validate,
19
- [dcl_catalyst_commons_1.EntityType.SCENE]: schemas_1.Scene.validate,
20
- [dcl_catalyst_commons_1.EntityType.WEARABLE]: schemas_1.Wearable.validate,
21
- };
22
- return validate[deployment.entity.type](deployment.entity.metadata);
15
+ const { type, metadata } = deployment.entity;
16
+ return dcl_catalyst_commons_1.entityParameters[type].validate(metadata);
23
17
  },
24
18
  message: ({ deployment }) => `The metadata for this entity type (${deployment.entity.type}) is not valid.`,
25
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"metadata-schema.js","sourceRoot":"","sources":["../../src/validations/metadata-schema.ts"],"names":[],"mappings":";;;AAAA,0CAAuD;AACvD,+DAAiD;AACjD,wBAAmC;AACnC,oCAAgD;AAEhD;;;GAGG;AACU,QAAA,QAAQ,GAAG,IAAA,6BAAqB,EAAC;IAC5C,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;QAC5B,IAAI,UAAU,CAAC,MAAM,CAAC,SAAS,IAAI,kBAAe;YAAE,OAAO,IAAI,CAAA;QAC/D,0CAA0C;QAC1C,MAAM,QAAQ,GAAG;YACf,CAAC,iCAAU,CAAC,OAAO,CAAC,EAAE,iBAAO,CAAC,QAAQ;YACtC,CAAC,iCAAU,CAAC,KAAK,CAAC,EAAE,eAAK,CAAC,QAAQ;YAClC,CAAC,iCAAU,CAAC,QAAQ,CAAC,EAAE,kBAAQ,CAAC,QAAQ;SACzC,CAAA;QACD,OAAO,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACrE,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,sCAAsC,UAAU,CAAC,MAAM,CAAC,IAAI,iBAAiB;CAC3G,CAAC,CAAA"}
1
+ {"version":3,"file":"metadata-schema.js","sourceRoot":"","sources":["../../src/validations/metadata-schema.ts"],"names":[],"mappings":";;;AACA,+DAAmE;AACnE,wBAAmC;AACnC,oCAAgD;AAEhD;;;GAGG;AACU,QAAA,QAAQ,GAAG,IAAA,6BAAqB,EAAC;IAC5C,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;QAC5B,IAAI,UAAU,CAAC,MAAM,CAAC,SAAS,IAAI,kBAAe;YAAE,OAAO,IAAI,CAAA;QAE/D,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,MAAM,CAAA;QAE5C,OAAO,uCAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAClD,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,sCAAsC,UAAU,CAAC,MAAM,CAAC,IAAI,iBAAiB;CAC3G,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/content-validator",
3
- "version": "1.0.0-20220104134007.commit-80072ed",
3
+ "version": "1.0.0-20220105210353.commit-baf07b8",
4
4
  "description": "Catalyst content validations",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@dcl/schemas": "^3.1.1",
37
37
  "@dcl/urn-resolver": "^1.3.0",
38
- "dcl-catalyst-commons": "^7.1.3",
38
+ "dcl-catalyst-commons": "7.1.4-20220105153139.commit-79398b8",
39
39
  "ethers": "^5.5.2",
40
40
  "ms": "^2.1.3",
41
41
  "sharp": "^0.29.3"
@@ -43,5 +43,5 @@
43
43
  "files": [
44
44
  "dist"
45
45
  ],
46
- "commit": "80072edc37c4a659139412d5f2eafb33339ed833"
46
+ "commit": "baf07b8226c19a6aa69b8012030c5d38d03d3a03"
47
47
  }